Dutch for tree. Also: 💥.
A Lean 4 formalisation of tree calculus — specifically the triage (five-rule) variant suggested by Johannes Bader and used on that site / in Barry Jay’s later work. Programs and values are unlabeled binary trees (leaf / stem / fork); the sole operator is △.
You can also explore terms visually: the #tree t command renders an interactive tree right in the Lean infoview. Orange nodes are redexes: click one to rewrite it, or use the controls to step, play, and run through a reduction. Under the hood, every step is computed by a rewrite function formally proved sound against the reduction relation.
Requires the Lean toolchain pinned in lean-toolchain (leanprover/lean4:v4.35.0, managed by elan). On a fresh clone:
lake exe cache get # download prebuilt Mathlib oleans (don't recompile Mathlib!)
lake buildThis project explores two different ways to formalise tree calculus:
TreeCalculus.Term: The canonical syntax. Terms are nodes with an ordered list of arguments. It also defines the rewrite rules andReduces; normal forms and divergence are inTreeCalculus.lean.TreeCalculus.ValOrRedex: An alternative presentation split intoValueandValOrRedextypes.
Both are kept around to compare them. Note that their reduction relations are currently slightly different: ValOrRedex drops trailing arguments, meaning its confluence theorem doesn't immediately carry over to Term.
- Barry Jay. Reflective Programs in Tree Calculus. (book)
- treecalcul.us — demos and specification (Johannes Bader)
- Barry Jay. Calculus, calculi — original three-rule tree calculus vs triage calculus
Copyright (c) 2025-2026 Aron Adler. Released under the Apache License 2.0; see also NOTICE.
