Unix truth table generator for propositional logic formulas developed with Haskell.
This program employs syntax analysis algorithms for the propositional logic language, balanced parentheses algorithms for syntax, and propositional logic interpretations for semantics. It is developed using a custom data structure implementation.
Made exclusively for Unix systems.
The program makes use of the STACK v2.7.5 or higher packager.
https://docs.haskellstack.org/en/v2.7.5/README/
- Clone the repository.
git clone https://github.com/richardfm77/truthtables.git
cd truthtables
- Config proyect.
stack setup
- Compile.
stack build
- Run tests.
stack test
stack exec truthtables-exe
Enter the propositional logic formula you want to know its truth table.
It is important that the input has the following format.
-
Atomic formulas of propositional logic must be alphabetic characters, they can be lowercase or uppercase, except for the 'v' character. For example: p,q,r,s,t,...
-
The propositional logic operators have the following syntax:
-
Not --> Not (exp) where exp is a formula of propositional logic.
-
Or --> Or (exp1) (exp2) where exp1 and exp2 are formulas of propositional logic.
-
And --> And (exp1) (exp2) where exp1 and exp2 are formulas of propositional logic.
-
Implies --> Implies (exp1) (exp2) where exp1 and exp2 are formulas of propositional logic.
-
Equal --> Equal (exp1) (exp2) where exp1 and exp2 are formulas of propositional logic.
-
-
Example 1.
Input: The input is in standard unix input.
Or p q
Output: The output is in standard unix output
---------------------- | p | q | ('p'v'q') | ------------ | F | F | F | ------------ | F | T | T | ------------ | T | F | T | ------------ | T | T | T |
-
Example 2.
Input: The input is in standard unix input.
Equal (Implies p q) (Or (Not p) q)
Output: The output is in standard unix output
---------------------------------------------------------- | p | q | (('p'=>'q')<=>(¬('p')v'q')) | ------------ | F | F | T | ------------ | F | T | T | ------------ | T | F | T | ------------ | T | T | T |
-
Example 3.
Input: The input is in standard unix input.
Implies (And (Implies p q) (Implies q r)) (Implies p r)
Output: The output is in standard unix output
-------------------------------------------------------------------------------- | q | p | r | ((('p'=>'q')^('q'=>'r'))=>('p'=>'r')) | ---------------- | F | F | F | T | ---------------- | F | F | T | T | ---------------- | F | T | F | T | ---------------- | F | T | T | T | ---------------- | T | F | F | T | ---------------- | T | F | T | T | ---------------- | T | T | F | T | ---------------- | T | T | T | T |