# 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

```latex
\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)

```text
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**: `AB` means A AND B; `A'` and `!A` both mean NOT A.
- **Note**: Put a space after word operators, e.g. `"not A"`.

## Settings (override with `\def`)

```latex
\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.
