A small command-line tool that prints the truth table for a propositional logic expression.
The tool is a single self-contained script with no runtime dependencies. The easiest way to run it is with uv, which reads the inline script metadata and picks a suitable Python automatically:
uv run truth_table.py "a & b"Or, since it has a shebang and no dependencies, run it directly with any Python 3.14+:
./truth_table.py "~(a | b)"
# or
python3 truth_table.py "a ^ b ^ c"- Atoms are single letters (
a-z,A-Z). - Operators, highest to lowest precedence:
~— NOT (negation, binds tightest)&|^— AND, OR, XOR (left-associative)
- Use parentheses
( )to override precedence.
$ uv run truth_table.py "a & b"
a │ b │ expr
───┼───┼──────
T │ T │ T
T │ F │ F
F │ T │ F
F │ F │ FThe main tool was hand-written, the auxiliary stuff like the test file and the readme was made with Claude Code.