Boolean Logic and Explicit Grouping
Removing the guesswork from "AND" and "OR" through mandatory structural syntax.
The Ambiguity of Precedence
In mathematics and programming, we learn an "order of operations" (PEMDAS). Typically, multiplication binds tighter than addition. In logic, AND usually binds tighter than OR.
In natural language, however, there is no agreed-upon standard. Consider:
"I want a burger and fries or a salad."
Does this mean:
1. (Burger AND Fries) OR (Salad) -> Only two distinct meal options.
2. (Burger) AND (Fries OR Salad) -> You definitely get a burger, plus a side dish.
A human resolves this ambiguity through intonation or context. A parser cannot. If a policy document says "Access is granted if the user is an admin or a moderator and the audit log is enabled", a misinterpretation of the precedence could lead to a massive security hole (granting access to any admin regardless of audit logging).
Explicit Grouping Strategy
CNL-PL solves this by rejecting standard precedence assumptions. It requires the user to be explicit. It does this not with parentheses (which look unnatural in text), but with Distributive Keywords:
- Both ... and ...: Forces an AND group.
- Either ... or ...: Forces an OR group.
- Neither ... nor ...: Forces a NOR group.
The grammar enforces that if you mix operators at the same level, you must use these grouping constructs.
Invalid: User is admin or User is dev and System is prod
Valid: Either (User is admin) or (both (User is dev) and (System is prod))
(Note: In the actual surface syntax, we use the keywords to delimit the clauses naturally).
The Logic Tree
This syntax forces the user to mentally construct a Logic Tree. The AST mirrors this tree exactly.
The root of a condition is a boolean node. Its children are either atomic SVO assertions (leaves) or other boolean nodes (branches). By enforcing this structure at the syntax level, we ensure that the logical intent is preserved 100% into the compiled Plan. There is no stage where the compiler "infers" precedence; it simply reads the tree the user wrote.
This approach also simplifies error reporting. If the user writes an ambiguous sentence, the error message can specifically point out the lack of grouping keywords, guiding the user to clarify their intent.