Boolean logic truth table
Expression | p=1,q=1 | p=1,q=0 | p=0,q=1 | p=0,q=0 |
---|---|---|---|---|
1 | 1 | 1 | 1 | 1 |
p or q | 1 | 1 | 1 | 0 |
p or not q | 1 | 1 | 0 | 1 |
p | 1 | 1 | 0 | 0 |
not p or q | 1 | 0 | 1 | 1 |
q | 1 | 0 | 1 | 0 |
not (p xor q) | 1 | 0 | 0 | 1 |
p and q | 1 | 0 | 0 | 0 |
not p or not q | 0 | 1 | 1 | 1 |
p xor q | 0 | 1 | 1 | 0 |
not q | 0 | 1 | 0 | 1 |
not p and q | 0 | 1 | 0 | 0 |
not p | 0 | 0 | 1 | 1 |
p and not q | 0 | 0 | 1 | 0 |
not p and not q | 0 | 0 | 0 | 1 |
0 | 0 | 0 | 0 | 0 |
Note that (not p or q) is equivalent to the expression (if p then q) or (p <= q)
(not(p xor q)) is equivalent to (if and only if p then q) or (p=q)
(p and not q) is equivalent to (p > q)
(p xor q) is equivalent to (p != q)
For expressions with more than two variables, the problem becomes soon complex. The problem, wether an expression with n boolean variables can be true with any combination of these variables hard to solve (see Boolean satisfiability problem).