Course page · chapter in the book · slides · Boole Lab
A minimal kernel for equational logic, tactics and the axioms of Boolean algebra — exactly the code that runs in the notebooks of the chapter and in the Boole Lab. Python 3.10 or newer is enough, with no additional libraries. Save the files in one folder (for example next to a downloaded notebook).
Each file opens in a reader with colored syntax, line numbers you can link to, an outline and names that lead to their definitions; the reader has a link to the raw file.
kernel.py — the kernel: five rules (Refl, Symm,
Trans, CongrArg, Inst), the environment of axioms and theoremssyntax.py — reading and printing terms and proofs (also in a Lean-like
notation)tactics.py — pattern matching, the tactics rw and
calc, a small solverboolean.py — Huntington's axioms (1904) and the first theoremsac.py — associativity and commutativity as a tactic: the normal form of
sums written down as kernel rules (ac_rfl), and matching modulo associativity and commutativityrobbins.py — the Robbins algebra and Lean-like tactic blocks
(rw, nth_rw, rw_ac, ac_simp, auto, …), lemmas with
hypotheses and sections with constants, measures of the size of a proofrobbins_proof.py — Robbins algebras are Boolean: the whole proof
from the Robbins equation to Huntington's equation, checked by the kernel (the deep dive
Proof compression in the book)library.py — a library of theorems of Boolean algebra (from
x + x = x through associativity and De Morgan's laws to the Robbins equation, single axioms, the
median and Boolean differences), each with a full tactic script that uses only earlier theorems; every theorem
has an English name and a Polish one for the Polish editionsolver.py — the solver for hints and auto: library proofs
expanded to the facts allowed in an exercise, and the normal form (a sum of minterms), so it finds a proof of
every true equationtheories.py — other axiom systems for bl theory: a single
axiom (DN1, Sh1), Veroff's two-equation basis, a pair that is not a basis, median algebra, the Robbins algebra and
four theories with constants for the stages of its proof; finite models (Veroff's three-element model M1) in which
a goal can be refutedtacticals.py — tactics made of tactics, as in LCF and Lean 4
(first, try, repeat, <;>, all_goals, …):
the parser, a runner that records a trace, and an analysis of a good tactic (does every repeat stop?
can every alternative matter?); the tactic workshop of the Boole Lab and bl tactic name := … use itlab.py — the driver: proof state, tactics written as in Lean 4, suggestions,
export to Lean; in a terminal: python3 lab.py (Polish names: python3 lab.py --pl)robbins_lab.py — the two complete proofs of the Robbins theorem,
step by step: Mann's, written out as in mathlib, and McCune's (EQP, 1996; every equation quoted with its EQP
justification, each step one call of auto), stage by stage in the theories robbins,
robbins_ab, robbins_e, robbins_cd and robbins_c;
bl replay mann, bl replay mccunelean/Lecture03.lean — the first proofs of the lecturelean/KernelSoundness.lean — the kernel and its
soundness theorem, checked by Lean's kernel (#print axioms: no axioms)lean/BooleLabEn.lean — the whole Boole Lab libraryExample:
from boolean import theory_with_theorems
from syntax import lean
B, proofs = theory_with_theorems()
print(lean(proofs["add_idem"]))
The Polish book and slides show a Polish version of the lecture code
(jadro/: jadro.py, skladnia.py, taktyki.py,
boole.py). It is generated from these English files with a dictionary of names and comments, so the two
versions are the same program.