Directory macros/latex/contrib/boolalg
boolalg
A LaTeX package for Boolean algebra: generate truth tables, simplify expressions step-by-step, and prove equivalences directly in your document. Everything runs in pure TeX—no external scripts, Python, or --shell-escape needed.
Quick Start
\usepackage{boolalg} % Truth table with sub-expressions \btable{A'B + AB'} % Step-by-step simplification citing Boolean laws \bsimplify{(A + B)(A + B')} % Prove equivalence or find a counterexample \bprove{A \oplus B = (A + B)(AB)'} \bprove{A + B = AB} % prints counterexample: A=0, B=1
Commands
\btable{<expr>}— Truth table (aliases:\btruth,\truthtable,\btruthtable,\booltruthtable)\btable*{<expr>}— Truth table with simplified answer\bsimplify{<expr>}— Step-by-step simplification (alias:\boolsimplify)\bsimplify*{<expr>}— Final simplified answer only\bprove{<lhs> = <rhs>}— Step-by-step proof or counterexample (alias:\boolprove)
Input Syntax (highest to lowest priority)
Variables : Single letters A-Z, a-z Constants : 0, 1 Grouping : ( ... ) 1. NOT : not, \lnot, \neg, ', !, ~ 2. AND : AB, *, ., &, and, \land, \wedge, \cdot NAND : nand, \nand, \uparrow, \barwedge 3. OR : +, |, or, \lor, \vee NOR : nor, \nor, \downarrow 4. XOR : ^, xor, \xor, \oplus XNOR : xnor, \xnor, \odot, \equiv, \iff
- Examples:
ABmeans A AND B;A'and!Aboth mean NOT A. - Note: Put a space after word operators, e.g.
"not A".
Settings (override with \def)
\def\boolfname{f} % Name of the output column (use \empty to hide) \def\booltablemaxvars{5} % Skip truth tables with more than 5 variables \def\boolandsym{\land} % Customise operator symbols (e.g. \def\boolandsym{\land})
Documentation
See boolalg-doc.pdf for the compiled reference manual and rendered examples.
Author & License
Param Srivastava
Released under the LaTeX Project Public License (LPPL) v1.3c or later.
Download the contents of this package in one zip archive (160.9k).
Boolalg – Truth tables, step-by-step simplification, and algebraic proofs for Boolean
The boolalg package provides pure-TeX macros for parsing, evaluating, simplifying, and proving Boolean algebra expressions without requiring external tools, Python, or shell-escape:
– \btable and \btable*: Generate truth tables with intermediate subexpression columns and optional simplified results. – \bsimplify and \bsimplify*: Perform step-by-step algebraic simplification with explicit law justifications (Idempotence, Absorption, Consensus theorem, De Morgan’s laws, Distributivity, etc.). – \bprove: Construct step-by-step algebraic proofs between two equivalent expressions, or automatically find and print a concrete counterexample if the claim is false.
Expressions support flexible input syntax including implicit multiplication (AB), postfix primes (A'), prefix operators (!, ~), English words (and, or, xor, nand, nor, xnor, not), and standard LaTeX math symbols (\land, \lor, \oplus, \lnot, etc.).
| Package | Boolalg |
| Version | 1.0.0 |
| Licenses | The LaTeX Project Public License 1.3c |
| Copyright | 2026 Param Srivastava |
| Maintainer | Param Srivastava |
| Topics | Logic |
| See also | luatruthtable truthtable |