disp is under heavy development and much of the codebase is AI-written — explore this website at your peril :)

disp, from first principles

From five rewrite rules over binary trees to claims, checkers that are lenses, and programs proved equal. Code blocks marked ▶ run against the real compiler, in your tab.

Every example is a region of lib/tests/by_example.test.disp, which the test suite runs; the README shows the same file.

Section 1Motivation

1.1 · What is disp?

Disp is a dependently typed programming language based on the computational model of the tree calculus, rather than the λ-calculus. Its types are programs you can run. A type is a claim: a program that takes a witness and a challenge and answers true or false.

v : T  ⟺  T(v, c) = true for every challenge c

Traditional type theory keeps a separate judgment Γ ⊢ v : T, derived by inference rules that live outside the language. Disp has no such machinery. Checking a value against a type is applying the type, and the verdicts are ordinary values too: Refuted with the challenge that failed, Open when nothing has failed yet, and Proved when a checker covers every challenge at once. §4 places this in the family tree of types as predicates, and §5 is how a checker earns the right to say Proved.

1.2 · Why does this design exist?

The long-term aspiration is a self-improving optimizer: a program that, given a specification of "good program" (encoded as a type — which is just a predicate), searches for programs satisfying it and improves the search program itself over time. For that loop to close, every component — the specification, the checker, the scoring function, the candidate programs — must live inside a single self-inspecting computational universe.

Compare the mainstream proof assistants. Lean, Rocq, and Agda all descend from the LCF traditionEdinburgh LCF (Gordon, Milner & Wadsworth, 1979) established the 'small trusted kernel + everything else as a library' architecture: only the kernel can mint theorems, so soundness reduces to auditing it, yet each still ships a trusted kernel written in its implementation language — Lean 4 self-hosts its elaborator, but the trusted kernel is C++; Rocq's and Agda's checkers remain in OCaml and Haskell. Those kernels accumulate host-language machinery — mutable hash tables, exceptions, pattern-match compilation — with no counterpart in the language being implemented. Disp applies the LCF discipline from the start, and more literally: the checker is a tree program checking tree programs.

The operating principle, and this walkthrough's spine: the object language is the specification; host implementations are optimizations. The TypeScript runtime (src/core/tree.ts) and the Rust evaluators accelerate the in-language definitions, and must produce identical decisions — they are validated against the in-language reference, byte for byte.

Section 2From λ-calculus to trees

The untyped λ-calculus has terms M, N ::= x | λx. M | M N and one rule, β-reduction: (λx. M) N →β M[x ≔ N]. Its key limitation, for our purposes: λ-terms cannot inspect their own structure by reduction. Given a λ-term f, there is no β-reducible context in which we can ask "is f a function or an atom?". Everything is a function.

2.1 · The SKI detour

Curry and Schönfinkel showed bound variables are dispensable: three combinators suffice.

CombinatorDefinitionBehaviour
Iλx. xI(x) = x
Kλx. λy. xK(x, y) = x
Sλx. λy. λz. (x z)(y z)S(x, y, z) = x(z, y(z))

Disp's compiler does exactly this: it removes every binder and leaves S, K and I. The playground's tree viewer shows it happening, one rewrite at a time, and then shows the result running, one rule at a time. Here is that viewer, with a guide:

1 / 10 I, the identity {x} => x

The viewer starts on the code as written, binder and all: x sits above the body that uses it. The line under the tree names the next rewrite. Here the body is x itself, so the whole function becomes I.

Put your cursor on a definition or test.

You'll watch its binders come off and the tree reduce, one step at a time. Select any expression to see just that part.

a variable, in one colour wherever it goes
leaf: t, the only atom
stem: a leaf applied to one thing
fork: a leaf applied to two things
an application still waiting to run
K
one that can run now, lettered with its rule (K, S, or F for triage); the bigger ring is the one that runs next
△
△ or f: a step that only adds a branch
S
a branch labelled S that runs the S rule once it's called (K and I likewise)

This is the playground's tree viewer. Type your own expression in its box at the top.

SKI is combinatorially complete: every closed λ-term compiles to it. But it inherits the limitation of λ-calculus. The viewer can read a shape and tell you "this is S", but no SKI program can: there is no reducible operation that asks "is this an S or a K?"

2.2 · Tree calculus

Tree calculus, due to Barry Jay, keeps combinatorial completeness and adds exactly the missing power. There is one base piece: t (written △ in the literature — the "leaf"). Trees are assembled by application, and every tree in normal formin tree calculus, every tree is already in normal form — reduction only happens through apply is one of:

t (leaf)  ·  t u (stem)  ·  t u v (fork)

Application is not a syntactic constructor; it's an external operation apply : Tree × Tree → Tree. Trees by themselves don't reduce; reduction happens only through apply.

2.3 · The five rules

apply(f, x) is defined by five rules that partition on the shape of f — and, for the last, on the shape of x:

Pattern of fShape of xResultName
tanyt xL (build a stem)
t uanyt u xs (build a fork)
t t banybK (constant)
t (t c) bany(c x)(b x)S (composition)
t (t c d) btcF (triage on x)
t ud u
t u vb u v

The first two rules are passive — they just grow trees. K and S match their SKI counterparts. The fifth rule — F, the triagethe third reduction rule: a function of shape t (t c d) b dispatches on the shape of its argument (leaf, stem, or fork) — the primitive reflection mechanism — is the new ingredient: it is the only rule whose behavior depends on the shape of the argument. Reduction itself can inspect tree shape.

The lab below evaluates any expression you type. Names that aren't known definitions parse as named leaves — free variables with no shape of their own, drawn as fruit — so K x y and S f g x reduce exactly as they do on paper. Step it forward one reduction at a time and watch which rule carries it: the amber letter marks the next redexa reducible expression: an application whose function (and, for triage, argument) is in the right shape for a rule to fire, and pruned leaves fall where all pruned leaves go. Click the grove and drive it from the keyboard — space runs and pauses, ←/→ step back and forward, shift+←/→ hop between the examples — or use the media-player controls above it. The selector icons are worth a poke: parallel fires every ready redex per round, which is legal because tree calculus is confluent, and nature off turns the grove back into a plain diagram.

not false press ▶ (or →) to fire the next reduction 0 steps · parallel
Edits parse as you type; Enter (re)starts the tree; space runs, ← → step, r resets. Combinators: t (△), K, S, not, and, or, add, and plain numbers. Any other name — x, y, f … — is a free variable: a named leaf the reductions carry along symbolically.

Booleans are the two smallest trees (true = t, false = t t); not is one triage: the F rule reads the argument's shape and picks a branch.

2.4 · Bracket abstraction: compiling λ to trees

Surface disp has binders; trees don't. The bridge is bracket abstraction: [x].M ("abstract x out of M") produces a closed expression in I, K, S and application:

When M is…Then [x].M =Why
x not free in MK MK M v = M
x itselfII v = v
N PS ([x].N) ([x].P)substitute in both halves

Nested binders peel inside-out: [x].[y].y = [x].I = K I. The compiler adds two semantics-preserving optimizations — η-reductionthe identity λx.(f x) = f when x is not free in f; the application and the bound variable cancel ([x].(N x) = N when x ∉ N) and K-composition (S (K p) (K q) → K (p q)) — which substantially shrink the output. These live in src/elab/cir.ts and are part of definitional equality: once compilation finishes, there is nothing in the runtime that is not a tree.

2.5 · Hash-consing and O(1) equality

The runtime stores every distinct tree exactly once (hash-consingstructural sharing: identical subtrees share one heap cell, so structural equality collapses to integer-identity comparison), so structural equality reduces to an identity check:

export function treeEqual(a, b) {
  return a.id === b.id   // O(1) — no traversal
}

Why does this matter so much? Because conversion checking in a dependent type system is structural equality of normal forms — the hot loop of every proof assistant. Making conversion O(1) keeps checking cheap. It also makes every test and every claim that compares two results (fn(x) == gn(x)) a single identity check, because deterministic elaboration produces identical trees for identical programs.

Section 3A first look at disp

The notation is small, and from Section 4 onward we will read it constantly, so it pays to nail down what the symbols mean. The grammar's authoritative source is SYNTAX.typ.

3.1 · Binders and application

{x} => body                // λx. body — the value lambda
{x, y} => body             // λx. λy. body  (curried)
{x : A} -> B               // the Pi type: for all x : A, B
A -> B                     // sugar for {_ : A} -> B
f(a, b)                    // application: the same tree as f(a)(b)
xs.map(succ)               // a glued .name(...) call: map(xs, succ)

The two arrows divide the work: a fat => binder is a value lambda, lowered via bracket abstraction (§2.4); a thin -> binder is a type — it desugars to an application of the library Pi former, and every parameter needs its : T. Application is a call, f(a, b), and a function given too few arguments is partially applied. The literal t denotes the leaf — the only "literal" the language truly has; numbers and strings are sugar for particular trees built by application.

3.2 · Declarations and tests

// a definition names a tree; a test reduces both sides and demands the
// identical tree, or the file fails to load
i := {x} => x
k := {x, y} => x
test i(t) = t
test k(t, t(t)) = t

// `:` is a type signature, checked only in a `use`d module (not raw); `:=>`
// binds the named parameters, and `rec` lets the body call itself
rec count_down : {n : Nat} -> List(Nat) :=> if (is_zero(n)) { [] } else { cons(n, count_down(nat_pred(n))) }
test count_down(3) = [3, 2, 1]

// a glued `.name(...)` calls a function with the value in front as its first argument
test [1, 2, 3].map(succ) = [2, 3, 4]

A test is a compile-time obligation: parse both sides, reduce, demand the identical tree. If the equation does not hold, the file fails to load. Every example on this page is a test in one file, lib/tests/by_example.test.disp, so everything it shows is checked whenever the test suite runs.

The claim layer this page teaches uses :: signatures, which are written for the reader and never checked; its checks are claims (§4). A single-colon : annotation is checked when a module is loaded, by lib/kernel/, the older checker the claim layer is replacing (§5.5).

3.3 · Modules

open use "path/to/file.disp" loads a module and splices its exports into scope. Modules are hermetic: a used file sees only its own definitions, its own opens, and its declared givens — never the user's scope. A module that needs something from outside declares it explicitly (given X : T) and callers fill it (use "f.disp" { X := v }) — which makes every module a checkable functor from its givens to its exports. open use raw loads only a file's values and skips its annotations, which is how the claim layer's files open each other.

Section 4Claims: a type is a test

Section 1 said a type is a program you run. This section makes that exact. In disp a type, a specification, a typing rule's conclusion and an equation between programs are all the same kind of thing: a claim, a program that takes a witness and a challenge and answers true or false. The claim holds when some witness passes every challenge. Nothing else is built in.

4.1 · Four traditions

TraditionWhat T isWhat v isThe relation v : T
Set theorya setan elementv ∈ T (primitive)
Predicate logica formula φ(x)an assignmentφ evaluates to true at v
Martin-Löf type theorya typea terma derivation Γ ⊢ v : T
dispa claim: a program {witness, challenge} => Boola witness (any tree)no challenge makes T(v, c) false

Disp's row is closest to predicate logic, with one difference that carries everything else: the claim, the witness and the challenge are all trees. A claim is not a formula that needs an interpretation before it can be applied; it is the function you apply. Its traditional name is types as predicates, and its nearest ancestor is NuPRL, whose types are also predicates over untyped terms. The difference is that NuPRL's terms are λ-terms you can only observe by running them, while disp's are trees a claim can take apart (§2.3).

4.2 · Booleans are shapes

For a claim's answer to be a tree, the language needs booleans that are trees. Disp's are the two smallest distinguishable ones:

true = t  ·  false = t(t)

A boolean carries no eliminator of its own. It is raw data, and using it is a triage: the F rule reads the argument's shape (leaf or stem) and picks a branch. if (c) { a } else { b } is sugar for exactly that. Here is a hand-built not, one F-rule firing per call:

// the two booleans are the two smallest distinguishable trees
test tree_eq(true, t) = true
test tree_eq(false, t(t)) = true

// elimination is a triage: the F rule reads the shape
shape_not := t(t(false, t(t, true)), t(t, t(t, true)))
test shape_not(true) = false
test shape_not(false) = true

4.3 · Asking every tree

A claim talks about every tree, and there are infinitely many. Disp lists them anyway: Trees is a stream of every tree, smallest first. The honest check walks that stream looking for a challenge the witness fails, up to a budget of steps. It has three possible answers, and only two of them can come from search:

  • Refuted, with the challenge that failed. Final: anyone can re-run it.
  • Open: no failure within the budget. This proves nothing.
  • Proved: needs a shortcut that covers every tree at once (§5).
// A claim is a program from a witness and a challenge to a Bool. This one says a
// function takes numbers to numbers. It says nothing about trees that are not numbers.

nat_fn := {g, x} => if (NatR(x)) { NatR(g(x)) } else { true }

// `Trees` is every tree there is, smallest first. The honest check searches it for
// a challenge the witness fails, up to a budget.

by_search := honest(Trees.as_items)
test by_search(nat_fn, {n} => pair(n, n), 60) = refuted(1)

// A failure is final, but running out of budget proves nothing. Open only means
// "no failure so far". This program is wrong on 3, the 65th tree:

sneaky := {n} => if (n == 3) { t(t) } else { n }
test by_search(nat_fn, sneaky, 64) = "Open"
test by_search(nat_fn, sneaky, 65) = refuted(3)
test by_search(nat_fn, succ, 150) = "Open"

sneaky is the reason Open is not a verdict: it behaves until the 65th tree. A larger budget can turn Open into Refuted, never into Proved. Note also what the claim leaves out: nat_fn answers true on every challenge that is not a number, so it says nothing about them. That is how a claim restricts itself to a type.

Section 5Checkers are lenses

Search can refute but never prove, because the stream of trees never ends. Every checker that says Proved is a shortcut: it replaces "every tree" with something finite. This section is about how disp keeps shortcuts honest, and what is left that you have to trust.

5.1 · Proved needs a finite list

over is the honest check run on a list instead of a stream. When the list runs out without a failure, the answer is Proved. That is only sound if the list really covers every challenge that matters, and saying so is a claim of its own.

5.2 · Lenses and their law

A lens between two claims carries witnesses forward and challenges back: lens(fwd, back). A checker, a typing rule and an optimization are all lenses. Its law, lens_holds, says: a witness that passes the pulled-back challenge is carried to a witness that passes the original. Read backwards, every counterexample to the target claim pulls back to a counterexample to the source. The law is itself a claim, so the honest check can refute a wrong shortcut with a concrete tree:

// The stream of trees never ends, so search can never say Proved. A finite list
// of challenges can, when every tree is covered by something on the list:

bool_fn := {v, x} => if (Bool(x)) { Bool(v(x)) } else { true }
test over(bool_fn, not, [true, false]) = "Proved"

// The cover is a lens: it carries witnesses forward and challenges back. Its
// promise is that a witness passing the pulled-back challenge passes the original.
// That promise is itself a claim, so search can catch a bad shortcut. This one
// sends every tree to `true`, and misses a program that fails only on `false`:

half_bad := {x} => if (x) { true } else { pair(x, x) }
bool_cover := lens({w} => w, {_w, x} => if (Bool(x)) { x } else { true })
bad_cover := lens({w} => w, {_w, _x} => true)
test by_search(lens_holds(bool_fn, bool_fn, bool_cover), half_bad, 60) = "Open"
test by_search(lens_holds(bool_fn, bool_fn, bad_cover), half_bad, 60) = refuted(false)

bool_cover sends each boolean challenge to itself, so passing the two booleans really does cover the claim. bad_cover sends everything to true, and search finds the tree it misses: false, where half_bad fails. Lenses compose (lens_then): forward maps run in order, backward maps in reverse, so a checker built from small certified steps is certified too.

5.3 · The five rules you trust

A lens law is a claim over every tree, so search alone can't prove one either. Something has to be argued by hand, and in disp that is five rule lenseslenses whose laws are argued on paper once, so every certificate built from them is trusted:

  • Finite cover: over exhausts a list.
  • Case split: a type's cases cover all its members (the confirmer's table).
  • Generic run: running a program on a symbolic case covers every concrete member of that case.
  • Induction: a claim that holds at zero, and holds at n+1 whenever it holds at n, holds everywhere.
  • Composition: lens_then of two lawful lenses is lawful.

A certificate is a finite tree built from these rules, and certify checks one by running it. Everything else, including every clever optimizer that produces certificates, is untrusted: a bad certificate fails to check, and a refutation re-runs anywhere.

5.4 · Why the floor can't go lower

Why not prove the five rules inside disp, too? Because a checker can't prove its own soundness. This is Löb's theorem, and in disp it has a concrete form: turning "this run succeeds" into the success itself would solve the halting problem, so no checker can cash in a promise about its own runs. Open is the honest record that no such procedure exists. The five hand-argued rules are the smallest base that can be trusted, and a successor checker can only be trusted one level down from the one that admitted it (research/LOB_AND_CURRY.md).

5.5 · What runs today

The claim layer lives in lib/claim.disp, with the rule lenses and certify in lib/tests/claim.test.disp. The checker that still verifies : annotations when a module is loaded is lib/kernel/, an earlier design the claim layer is replacing. If you meet it in the library, that is why.

Section 6What claims can say

A type theory usually earns its keep with function types, equality and induction. In disp each is a claim, and each is checked by the machinery of Sections 4 and 5.

6.1 · Function types

A claim about a function has to test it somewhere. A higher-order claim, about functions that take functions, is harder: the argument is itself a function, and you can't try it everywhere. Disp's answer is that a member of a function type is a lens: the program, plus a back map naming the point of its argument it relied on. implies(A, B) challenges such a pair with an argument and a challenge for the result, so search can test it at one point and refute it with a concrete counterexample:

// A member of a function type is a lens too: the program, and a back map naming
// the point of its argument it relied on. `implies(A, B)` challenges it with an
// argument and a challenge for the result, so a claim about functions of
// functions is tested at one point and search can refute it.

is_nat := {w, _c} => NatR(w)
offered := Trees.as_items.s_map({g} => pair(g, t))

// "apply the argument to 3" is a fine Nat-valued function of a Nat function,
// as long as it admits it looked at 3:
test honest(offered, implies(nat_fn, is_nat), lens({g} => g(3), {_g, _y} => 3), 40) = "Open"

// returning the function itself is not a Nat; the counterexample is the
// function `t(t)` together with the challenge it was called with
test honest(offered, implies(nat_fn, is_nat), lens({g} => g, {_g, _y} => 3), 40) = refuted(pair(t(t), t))

6.2 · Equality

Comparing two trees is instant, since every distinct tree is stored once (§2.5). It is also too strict: two different programs can do the same thing, and an optimizer needs to know when. Equality at a type is a claim: the two programs agree at every challenge of that type. id and shift (which rebuilds a number from its predecessor) are different trees and are certified equal at Nat -> Nat by a case split: zero, and one more than some number.

6.3 · Induction

A case split is enough when each case can be run symbolically. Recursive programs need induction: in the second case, each program's recursive call on the smaller number is named by one shared token, so the check compares the two step functions instead of unrolling them.

// This is what an optimizer needs: two different programs, known to do the same
// thing. Comparing trees is instant, and too strict. These are different programs:

dbl_add := {d2, n} => if (is_zero(n)) { zero } else { add(2, d2(nat_pred(n))) }
test tree_eq(dbl_step, dbl_add) = false

// Two cases cover every number, zero and one more than some number, and each
// program's recursive call on the smaller number is named by one token. Both cases
// match, so the programs agree on every number:

test eq_by_induction(dbl_step, dbl_add) = "Proved"

// A wrong step disagrees on a case, and the checker returns a number to run:

wrong_step := {d2, n} => if (is_zero(n)) { zero } else { succ(d2(nat_pred(n))) }
test eq_by_induction(dbl_step, wrong_step) = refuted(1)

// Whether this reaches the rewrites that matter is the project's biggest open
// question (FOUNDATIONS.md, Q1). Map fusion and strength reduction are not yet
// attempted here. The rules for building shortcuts are the trusted part, and they
// have not themselves been proved sound.

The point of all this is to search for programs. cegis (counterexample-guided synthesis) tries candidates against a claim in order. Each challenge that refutes a candidate is kept and tried first on the next one, so wrong candidates fail fast:

// Search for a program: `cegis` tries candidates in order, and keeps every
// challenge that refuted one to try first on the next. Here the claim is "acts
// as the identity on booleans", the candidates are the first 40 trees, and the
// answer comes back with the two booleans it learned to test.

bool_id := {v, x} => if (Bool(x)) { v(x) == x } else { true }
test cegis(Trees.as_items, bool_id, candidates, [], 30) = pair(idfns.head, [false, true])

This is a small search over a fixed list. Searching a space worth searching, and scoring candidates by cost as well as by correctness, is the work Section 7 describes.

Section 7Where it is going

The goal is in GOALS.md:

I want to synthesize the best possible programs given a specification… turn the type checker into a function that takes a program and returns 1 or 0, combine that with functions that measure performance or program size, and somehow turn all that into a function represented purely in some low-level deterministic Turing-complete calculus. — GOALS.md

The comparison page splits that goal into five requirements and grades disp twice: on what runs today, and on what the design could reach by the arguments written down so far. This section is the short version of the second grade.

7.1 · What runs

Everything in Sections 2 to 6: programs are trees any program can take apart; claims, the honest search, lenses and their laws; certificates from the five rules; equality by case split and by induction; and a small cegis search. The tests in lib/tests/ run all of it, and the examples on this page are one of those files.

7.2 · What is designed

  • Cost in the score. A search scores each candidate by the checker's verdict times its cost, and a cost bound is one more claim (research/OPTIMIZER.typ §2).
  • A model of the machine. A hardware model is an ordinary program that runs assembly and returns its output and cycle count, so "this assembly does what the spec says" is a claim over it (§9 of the same note).
  • Handing work to a faster language. Effects are data, and one impure driver at the edge of the program performs them. That driver is where work goes to a faster language and comes back with its outputs, time and memory (FOUNDATIONS.md §8).
  • Wider search. A claim can generate its own candidates instead of filtering every tree (research/CLAIMS_OVER_TREES.md §4). Whether search over a space worth searching is affordable is the project's main open question.

7.3 · What has no argument yet

Two things the goal asks for have no design behind them. Nothing writes new claims for the search to satisfy; it only keeps the counterexamples it finds. And no second, independent checker confirms certificates; the honest search is independent, but it can only refute. Self-application, an optimizer improving itself, is possible in principle, but by Löb's theorem (§5.4) each new version is trusted one level less than the one that admitted it.

Section 8References

  1. Schönfinkel, M. (1924). Über die Bausteine der mathematischen Logik Mathematische Annalen 92, 305–316; English translation in van Heijenoort, From Frege to Gödel, Harvard UP 1967.
  2. Curry, H. B., & Feys, R. (1958). Combinatory Logic, Vol. I North-Holland. The classical reference for the combinatory calculus and bracket abstraction.
  3. Howard, W. A. (1980). The formulae-as-types notion of construction In Seldin & Hindley (eds.), To H. B. Curry, 479–490, Academic Press; circulated 1969.
  4. Martin-Löf, P. (1984). Intuitionistic Type Theory Sambin notes, Padua lectures 1980. Bibliopolis.
  5. Scott, D. S. (1976). Data types as lattices SIAM J. Computing 5(3):522–587. The lattice-theoretic origin of the encoding now called "Scott encoding".
  6. Reynolds, J. C. (1983). Types, abstraction and parametric polymorphism Information Processing 83, 513–523. The foundational paper on relational parametricity.
  7. Constable, R. L., et al. (1986). Implementing Mathematics with the Nuprl Proof Development System Prentice-Hall. The computational type theory tradition — types as predicates over untyped terms — that §4 locates disp within.
  8. Rushby, J., Owre, S., & Shankar, N. (1998). Subtypes for Specifications: Predicate Subtyping in PVS IEEE Transactions on Software Engineering 24(9). The solver-checked pole of the predicate-type family.
  9. Vazou, N., Seidel, E. L., Jhala, R., Vytiniotis, D., & Peyton Jones, S. (2014). LiquidHaskell: Experience with Refinement Types in the Real World Haskell Symposium 2014.
  10. Jay, B. (2021). Reflective Programs in Tree Calculus Self-published; sources and PDFs on GitHub.
  11. Cohen, C., Coquand, T., Huber, S., & Mörtberg, A. (2018). Cubical Type Theory: a constructive interpretation of the univalence axiom TYPES 2015, LIPIcs 69.
  12. The Univalent Foundations Program (2013). Homotopy Type Theory: Univalent Foundations of Mathematics IAS Princeton.
  13. Gordon, M., Milner, R., & Wadsworth, C. P. (1979). Edinburgh LCF: A Mechanised Logic of Computation LNCS 78, Springer. The progenitor of the small-trusted-kernel tradition that informs disp’s discipline.
  14. Mac Lane, S., & Moerdijk, I. (1994). Sheaves in Geometry and Logic Springer. Standard reference for elementary topos theory and the subobject classifier.
  15. Lambek, J., & Scott, P. J. (1986). Introduction to Higher Order Categorical Logic Cambridge University Press.
  16. de Moura, L., et al. The Lean theorem prover & programming language
  17. The Rocq Development Team The Rocq Prover (formerly Coq)
  18. The Agda Team Agda — dependently typed functional programming language

Section 9Glossary

Tree calculus
An abstract rewriting system on values built from one nullary constructor (the leaf t), with binary application. The K, S, and triage rules make it Turing complete and structurally complete: every program can decide the shape of every value by reduction alone.
Triage
The F rule: a function of shape t(t(c, d), b) dispatches on the shape of its argument (leaf, stem, or fork). The primitive reflection mechanism.
Hash-consing
Storing each distinct tree exactly once and identifying trees by integer ID. Makes structural equality an O(1) identity check.
Bracket abstraction
The algorithm [x].M that removes a free variable, leaving a closed combinator expression in I, K, S. Bridges the surface λ-syntax to tree calculus.
Claim
A program {witness, challenge} => Bool. It holds when some witness passes every challenge. Types, specifications, typing rules and equations between programs are all claims.
Witness / challenge
The two arguments of a claim: what is offered as evidence, and what it is tested on. A witness may be a function, which is how "for every x some y" becomes one witness.
Honest check
honest: search a stream of challenges for one the witness fails, up to a budget. It can refute, or report Open; it can never prove.
Refuted / Open / Proved
The three verdicts. Refuted carries the failing challenge and is final. Open means no failure was found, and proves nothing. Proved needs a finite cover or a certificate.
Lens
A map between claims: witnesses go forward, challenges come back. Checkers, typing rules and optimizations are lenses. Its law, lens_holds, is itself a claim the honest check can refute.
Rule lenses
The five lenses whose laws are argued by hand: finite cover, case split, generic run, induction and composition. They are the trusted base.
Certificate
A finite tree built from the rule lenses that certify checks by running it. A bad certificate fails to check; nothing that produces certificates has to be trusted.
cegis
Counterexample-guided synthesis: try candidates against a claim, keeping every refuting challenge to try first on the next candidate.
Löb ceiling
A checker cannot prove its own soundness, so the rule lenses are argued outside disp, and a successor checker is trusted one level less than the one that admitted it.

This walkthrough is commentary. The ground truth is the code it runs: lib/claim.disp, lib/tests/claim.test.disp and lib/tests/by_example.test.disp, with the reasoning in CLAIMS_OVER_TREES.md and the syntax in SYNTAX.typ.