git clone https://github.com/Ted-Barrett/propositional-logic-evaluator.git
cd propositional-logic-evaluator
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 main.py "(P | Q)"
git clone https://github.com/Ted-Barrett/propositional-logic-evaluator.git
cd propositional-logic-evaluator
python -m venv venv
venv\Scripts\activate.bat
pip install -r requirements.txt
python main.py "(P | Q)"
The program will print the results and also write them to a csv, truth_table.csv
.
Note that truth_table.csv will be overwritten each time the program is run.
$ python3 main.py "((P => Q) => R)" "(Q <+> R)"
P Q R | ((P => Q) => R) (Q <+> R)
--- --- --- --- ----------------- -----------
0 0 0 | 0 0
0 0 1 | 1 1
0 1 0 | 0 1
0 1 1 | 1 0
1 0 0 | 1 0
1 0 1 | 1 1
1 1 0 | 0 1
1 1 1 | 1 0
The calculator takes in as many propositional logic statements as you want. Each must be contained within brackets and quotes, and separated by a space.
A propositional logic statement must be bracketed, unless it is a variable or constant. Express True and False with t and f, and variables with upper-case letters.
The following are all valid commands:
python3 main.py "(P | ~f)"
python3 main.py "(P => Q)" "((P => ~Q) | R)" "(P | Q)"
python3 main.py "(((P <=> Q) => t) & S)"
Valid connectives are:
&
: And
|
: Or
=>
: Implication
<=>
: Biimplication
<+>
: Exclusive Or
To negate an expression or variable, put an ~
in front of it. You should not include more brackets than necessary,
as this will break the program.
Please note that this project was made for hobby purposes and therefore there is no guarantee for the accuracy of the results produced.