Propositional logic evaluator.
Supported operators and symbols:
- Not:
not
,¬
,!
,∼
- And:
and
,&
,&&
,∧
- Or:
or
,|
,||
,∨
- XOr:
xor
,⊕
- Implication:
->
,=>
,⇒
,→
,⊃
- Biconditional:
<->
,<=>
,⇔
,↔
,iff
,xnor
- Logical equivalence:
=
,==
,eq
,≡
- Not equal:
!=
,≠
- parentheses:
()
,{}
,[]
- True:
1
,true
,True
- False:
0
,false
,False
- Variables:
a-z
,A-Z
Note: the order of evaluation of operators are: not
, and
, or
, xor
, →
, ↔
, ≡
and ≠
. Please use parentheses in order to adjust the operator priorities. incorrect expressions result in wrong tables.
Note: Characters are case sensetive. for example q
is not the same as Q
.
Example:
- Truth table for
P ∨ (Q ∧ R) ≡ (P ∨ Q) ∧ (P ∨ R)
orP or (Q and R) == (P or Q) and (P or R)
P | Q | R | (Q ∧ R) | (P ∨ (Q ∧ R)) | (P ∨ Q) | (P ∨ R) | ((P ∨ Q) ∧ (P ∨ R)) | ((P ∨ (Q ∧ R)) ≡ ((P ∨ Q) ∧ (P ∨ R))) |
---|---|---|---|---|---|---|---|---|
true | true | true | true | true | true | true | true | true |
true | true | false | false | true | true | true | true | true |
true | false | true | false | true | true | true | true | true |
true | false | false | false | true | true | true | true | true |
false | true | true | true | true | true | true | true | true |
false | true | false | false | false | true | false | false | true |
false | false | true | false | false | false | true | false | true |
false | false | false | false | false | false | false | false | true |
- Truth table for
(P ∧ (∼ Q)) ⇔ (P ⇒ Q)
or(P and (not Q) <-> (P -> Q))
P | Q | ¬Q | (P ∧ ¬Q) | (P → Q) | ((P ∧ ¬Q) ↔ (P → Q)) |
---|---|---|---|---|---|
true | true | false | false | true | false |
true | false | true | true | false | false |
false | true | false | false | true | false |
false | false | true | false | true | false |
- Truth table for
not true or not false
P | Q | ¬P | ¬Q | (¬P ∨ ¬Q) |
---|---|---|---|---|
false | true | true | false | true |
How to run
- install
rust
. see here for the instructions. - run
cargo run
to run the app. - run
cargo test
to run the tests.
How to use
You can export the truth tables to one of the following formats or print it to terminal.
- csv
- html
- pdf (at the moment, does not support displaying some math characters)
let s = "(P and not Q) <-> (P -> Q)";//"(P ∧ (∼ Q)) ⇔ (P ⇒ Q)";
let tokens = from_text;
match new
Or you can evaluate for specific values for P
and Q
only.
let s = "(∼ P) ∨ (∼ Q)";
let tokens = from_text;
let evaluator = new.unwrap;
let mut values = new;
values.insert;
values.insert;
let mut result = evaluator.evaluate.unwrap;
for v in values.iter.rev
let result = EvaluatorResult;
println!;
// result.save_to_html("test.html");
// result.save_to_csv("test.csv");
// result.save_to_pdf("test.pdf");