Skip to content

adamchalmers/logiczoo

Repository files navigation

logiczoo

A calculator for logic.

Installing:

  • Install Stack, the Haskell tool
  • Clone this repo
  • cd into the repo
  • $ stack install
  • $ logiczoo-exe

Usage:

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.

Examples:

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

About

A calculator for logic

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published