Logic is Geometry: Set Theory
Why CNL-PL reduces all reasoning to set operations, and how this enables performance at scale.
The Isomorphism
There is a well-known isomorphism (structural equivalence) between Boolean Logic and Set Theory.
- A Predicate P(x) is equivalent to the Set S = {x | P(x) is true}.
- Logical AND (P(x) ∧ Q(x)) is equivalent to Set Intersection (S_P ∩ S_Q).
- Logical OR (P(x) ∨ Q(x)) is equivalent to Set Union (S_P ∪ S_Q).
- Logical NOT (¬P(x)) is equivalent to Set Difference (Universe \ S_P).
CNL-PL takes this mathematical truth and makes it the foundation of its physical implementation. When the user writes a logic rule, the engine does not "think" in terms of truth values; it computes in terms of sets.
The Bitset Advantage
Because we map every entity to a dense integer (0, 1, 2...), a Set can be represented as a Bitset (a bitmap). If the bit at index 5 is set to 1, it means Entity #5 is in the set.
This transforms logical reasoning into CPU-native arithmetic. Computing the intersection of two sets containing millions of items is done by performing a bitwise AND instruction on the memory words holding the bits. This is orders of magnitude faster than iterating through lists of objects or pointers.
Relational Algebra
This approach extends to relations. A binary relation (Subject -> Object) is a set of pairs. In our architecture, this is stored as a Relation Matrix (an array of bitsets).
Complex queries involving "joins" (e.g., "Find users who manage a secure server") become vector operations. We take the bitset of "Secure Servers", and we "project" it backwards through the "Manages" relation matrix using bitwise ORs. The result is the bitset of "Users". This is essentially a specialized form of Linear Algebra over the Boolean Semiring (GF(2)).
By grounding the language theory in this rigorous mathematical framework, we ensure that the system scales predictably and behaves correctly, avoiding the exponential complexity traps common in naive rule engines.