A tool for checking syntax and creating truth tables for well-formated formulas.
It was written and tested in Python 3.7.4.
py main.py -i <input> -<actions>
<input>
should be a in the strict type of writing (for each operation, there needs to be a pair of parentheses ).
List of available actions
p - Will parse the input (this will run by default with any other action).
s - Will check the syntax.
e - Will evaluate all the possible interpretations. See second example.
c - In conjunction with e
will run only 1 interpretation passed as an argument with a dictionary. See first example.
t - Will print the tree. See third example.
r - Will print the reconstructed tree (as a formula).
o - Will output the evaluation to a file.
py main.py -i "(((P&R)|Q)@S)" -e -c {\"P\":\"True\",\"R\":\"True\",\"Q\":\"True\",\"S\":\"False\"}
+------+------+------+-------+-------+-----------+---------------+
| P | R | Q | S | (P&R) | ((P&R)|Q) | (((P&R)|Q)@S) |
+------+------+------+-------+-------+-----------+---------------+
| True | True | True | False | True | True | False |
+------+------+------+-------+-------+-----------+---------------+
py main.py -i "((P&R)|Q)" -e
+-------+-------+-------+-------+-----------+
| P | R | Q | (P&R) | ((P&R)|Q) |
+-------+-------+-------+-------+-----------+
| True | True | True | True | True |
| True | True | False | True | True |
| True | False | True | False | True |
| True | False | False | False | False |
| False | True | True | False | True |
| False | True | False | False | False |
| False | False | True | False | True |
| False | False | False | False | False |
+-------+-------+-------+-------+-----------+
py main.py -i "((P&R)|Q)" -t
┌Q
|┤
│ ┌P
└&┤
└R