Step 1 · Hypergraph
Definition
A hypergraph (in the sense of BDF26) is a tuple where:
- is a finite set of vertices, interpreted as propositions of a formal mathematical language;
- is a finite set of hyperedges, each interpreted as a single application of a deductive rule;
- is a colouring, assigning to every hyperedge the label of the deductive rule it applies.
Each hyperedge is itself a tuple
with the (ordered) tuple of premises, the (ordered) tuple of conclusions, and .
Within a single edge, all vertices are distinct: premises are pairwise distinct, conclusions are pairwise distinct, and no premise coincides with a conclusion of the same edge.
The four structural axioms
Following Barkeshli–Douglas–Freedman (BDF26), the hypergraph satisfies:
-
(D) Directed. Every edge has a distinguished input side and output side. Inputs and outputs are typed differently and never coincide within an edge.
-
(O) Ordered. Inputs and outputs are tuples, not sets: as positions even if the underlying vertices were equal. The order matters because the position carries the deductive role (which premise is the major premise, etc.).
-
(C) Coloured. Each edge carries a colour recording which deductive rule was applied. Two edges with identical input and output tuples but different colours are different edges.
-
(A) Acyclic. No proposition is its own descendant. Formally, the transitive closure of the input-to-output relation
is irreflexive.
We additionally require to be connected: any two vertices are linked by an undirected path through hyperedge incidence (a vertex is incident to an edge if it appears in its input or output tuple).
Example: modus ponens
The single inference step
corresponds to a hyperedge with , , , , and . Drawn with vertices as circles and the hyperedge as a coloured box:
Example: conjunction introduction
The rule
is a hyperedge with the same shape (, ) but a different colour: . The colouring is what distinguishes these two two-in-one-out edges.
Example: a small derivation
Stringing two edges together: from premises , , we derive in two steps (one MP, then one -I). The resulting hypergraph has five vertices and two hyperedges:
Lean encoding
The structure lives in
ProofAtlas/Hypergraph/Basic.lean:
structure Hyperedge (V : Type u) (C : Type v) where
inArity : Nat
inVertex : Fin inArity → V
outArity : Nat
outVertex : Fin outArity → V
color : C
inArity_pos : 0 < inArity
outArity_pos : 0 < outArity
inputOutputDisjoint : ∀ i j, inVertex i ≠ outVertex j
inVertex_injective : Function.Injective inVertex
outVertex_injective : Function.Injective outVertex
structure Hypergraph (V : Type u) (C : Type v) where
edges : Type w
edge : edges → Hyperedge V C
acyclic : Hypergraph.IsAcyclic edge
connected : ∀ u v, Relation.ReflTransGen (incidence) u v
The axioms (D), (O), (C) live per edge as Hyperedge fields;
(A) is the cross-edge acyclic field on Hypergraph.
From Lean.Expr to hypergraph
Every Lean proof term e : Lean.Expr induces a hypergraph
automatically, via
Lean.Expr.toHypergraph e : Hypergraph (Fin (countSubterms e)) ExprColor
defined in ProofAtlas/Mapping/Expr.lean. The five
structural proofs (inArity_pos, outArity_pos,
inputOutputDisjoint, inVertex_injective, outVertex_injective,
plus acyclic and connected) are all sorry-free.
The load-bearing lemma is vertex_has_parent: every non-root DFS
vertex is incident to the hyperedge of its parent compound subterm.
It is proved by induction on the twelve Lean.Expr constructors;
the six compound cases each split into a child-block case analysis
with shifted induction hypotheses.
References
[BDF26] Maissam Barkeshli, Michael R. Douglas, Michael H. Freedman, Artificial Intelligence and the Structure of Mathematics, arXiv:2604.06107, 2026. §2.1. arxiv.org/abs/2604.06107