A calculator for logic.
- Install Stack, the Haskell tool
- Clone this repo
cd
into the repo$ stack install
$ logiczoo-exe
logiczoo-exe (logicaltruth | equivalent | truthtable)
The parser recognizes the following logic operators:
- Not: "~", "!"
- And: "&", "^"
- Or: "|", "v"
- If: "->"
- Iff: "<->"
- Xor: "x"
Spaces are ignored. Two-place operators must be wrapped in parentheses. For example, the parser will accept (A&B)
but not A&B
.
To see the truth table for a sentence:
$ logiczoo-exe truthtable --sentence "~(A&B)"
A B --- True
A ~B --- False
~A B --- False
~A ~B --- False
To check if something is logically true (i.e. true on all models):
$ logiczoo-exe logicaltruth --sentence "(Av~A)"
True
$ logiczoo-exe logicaltruth --sentence "(AvB)"
False
To check if two sentences are equivalent:
$ logiczoo-exe equivalent --sentence "(~A&~B)" --sentence "~(AxB)"
False
$ logiczoo-exe equivalent --sentence "(~A&~B)" --sentence "~(AvB)"
True