Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

truth-table

A small command-line tool that prints the truth table for a propositional logic expression.

Usage

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"

Expression syntax

  • 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 │  F

AI usage

The main tool was hand-written, the auxiliary stuff like the test file and the readme was made with Claude Code.

About

Truth table generator for propositional logic

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages