-
Notifications
You must be signed in to change notification settings - Fork 1
Grammar
Logic-app input files must have the .logic extension, and follow this format:
-
One or more propositions. A proposition starts with the
propkeyword followed by a logical sentence.-
A sentence can be any propositional logical expression, with terminals and operators.
- Terminals (AKA atoms) are the smallest logical unit. A terminal can either be a boolean literal or a boolean variable.
- A boolean literal is either
TorF(symbol variant) orTrueorFalse(reserved word variant). - A boolean variable can be named anything you can name a Java variable. That means single letters (excluding
TandF) or longer form words with optional underscores. In testing and in documentation we typically use single letters because this is the norm in logic.
- A boolean literal is either
- Supported operators:
Class Resword Symbol Conjunction and&Disjunction or|Negation not~Implication implies->Equivalence iff<->-
Notably "nand" and "xor" operations are not directly supported. They can be indirectly crafted as such:
~(A & B) # nand (A | B) & (~A | ~B) # xor -
Use of parentheses to indicate order of operations is recommended, but there is a grammar-level order of operations that holds otherwise:
- Negation
- Conjunction
- Disjunction
- Implication
- Equivalence.
- Terminals (AKA atoms) are the smallest logical unit. A terminal can either be a boolean literal or a boolean variable.
-
-
A command. More than one command may be specified, but use cases for this are limited.
- A command starts with the
cmdkeyword and is followed by a controlled-natural-language-style command. Supported commands:-
just parse: Output nothing. Useful if you just want to check the syntax and validation of your input. -
translate to [variant]. Supported variants:-
reserved word variant: Changes all the operators and boolean literals to their reserved-word-variant equivalents. E.g.->will change toimplies. -
symbol variant: Changes all the operators and boolean literals to their symbol-variant equivalents. E.g.implieswill change to->.
-
-
convert to [conversion]. Supported conversions:-
NNF: Change each proposition to Negation Normal Form. That is, the sentence will only consist of&and|operators, and~operators will only appear directly next to terminals. -
CNF: Conjunctive Normal Form. I.e. NNF, and&operators will always be logically higher than|operators. -
DIMACS CNF: Special kind of text format that can be read by most SAT solvers. Simplified spec here.
-
-
solve [what]. Supported solvings:-
satisfiability: See SAT Solving wiki page.
-
-
- A command starts with the
-
Any number of configuration items.
- A config item starts with the
configkeyword, followed by the config key, an=character, and then the value in string format. E.g.:
config solver="sat4j"- The string may be specified using single or double quotes.
- See the config wiki entry for valid config keys and values.
- A config item starts with the
-
Optionally, comments! Comments start with
#and run to the end of the line. -
The grammar is whitespace-blind, so you can place multiple propositions and commands on the same line. For obvious reasons, this is not recommended.
The grammar works with two variants:
- The
symbol variant, which uses symbols as operators and the short-form boolean literals, e.g.->,&,T. - The
reserved word variant, which uses words as operators and the long-form boolean literals, e.g.implies,and,True.
Mixing these variants is allowed, but will trigger warnings.