research39 min studyLesson 1000 in Mathematics

Formalizing structures and trusted kernels

Package algebraic data with laws, transport a finite structure, and audit what a checked proof actually assumes.

On this page

What you’ll understand

  • Package a carrier, operations, and laws without confusing data with mere existence.
  • Transport a concrete monoid structure along a verified equivalence.
  • Separate elaboration and tactics from kernel checking, declared axioms, and the correctness of the formal statement.

A formal theorem lives in an environment containing definitions, proof terms, and sometimes declared axioms. The kernel checks a proposed term against that environment; it does not decide whether the theorem expresses the intended informal claim or whether every admitted axiom is justified. Formalizing a structure therefore has two tasks: choose faithful mathematical data and laws, then verify a proof under a clearly identified foundation. A transported two-element monoid will make the data visible before we examine the trust boundary of an actual proof assistant.

A structure packages operations and their obligations

A small monoid can be represented by a small set-level carrier, a binary operation on it, a chosen unit, and proofs of associativity and the two unit laws. The operations are data, while the law fields assert identities for every tuple of carrier elements. In a setting with function extensionality, these law fields are mere propositions when the carrier is a set. This does not make the entire structure a mere proposition: different carriers or operation tables remain genuine alternatives.

Universe levels follow the carrier field and its packaging. Quantifying over all small monoids generally belongs in a larger universe than a single small carrier. One must also distinguish a chosen structure from a mere assertion that such a structure exists. The latter may be propositionally truncated and cannot automatically supply an operation table. Names such as group or ring are not enough: the signature and laws must be checked for omitted conditions, including whether an inverse is data or merely asserted to exist.

Mon⁡(A)=∑m:A→A→A∑e:A(Assoc⁡(m)×LeftUnit⁡(m,e)×RightUnit⁡(m,e)).\operatorname{Mon}(A)=\sum_{m:A\to A\to A}\sum_{e:A}\bigl(\operatorname{Assoc}(m)\times\operatorname{LeftUnit}(m,e)\times\operatorname{RightUnit}(m,e)\bigr).
The carrier A is fixed in this display and is separately assumed to be a set; the operation and unit are selected data.↔ Scroll wide equations horizontally.

An equivalence transports operations as well as elements

Given an equivalence between carriers, define the new unit by mapping the old unit, and define the new operation by moving both arguments back, using the old operation, then mapping the result forward. Inverse laws supply the identities needed to transport associativity and the unit equations. A bare equivalence does not usually preserve an unchanged operation table. The operation must be transported or a separate homomorphism property must be proved.

In a univalent foundation, appropriate structure-identity principles relate equivalences preserving structure to equalities of the corresponding packaged structures. Their hypotheses concern the specified signature and laws; univalence of carriers alone does not bypass the operation obligations. A conventional proof assistant with a different equality theory may instead use explicit isomorphisms and rewriting lemmas. Both styles can formalize the same algebraic calculation while relying on different foundational rules and offering different judgmental computations.

e′=f(e),m′(x,y)=f(m(f−1(x),f−1(y))).e'=f(e),\qquad m'(x,y)=f\bigl(m(f^{-1}(x),f^{-1}(y))\bigr).
This is transport of the entire operation, not merely renaming the carrier while silently retaining its old table.↔ Scroll wide equations horizontally.

The kernel certifies a term relative to its environment

Lean's official reference describes a small kernel that checks elaborated core terms and new declarations. The elaborator resolves notation, implicit arguments, and tactics before that check; ordinary tactic success must still produce an acceptable term. The kernel does not itself run the surface termination checker or general unification search. Recursive definitions are elaborated into accepted recursors. These implementation facts concern Lean's specified core theory, whose proof-irrelevant Prop is not identical to the proof-relevant intensional theory used throughout the preceding examples.

An axiom is a declared constant, not a theorem whose consistency the kernel proves. Lean tracks proof dependencies so an axiom audit can reveal classical choice, other foundational assumptions, and unfinished-proof placeholders. The reference also distinguishes native-evaluation proofs that expand the trusted computational base. A checked result is therefore relative to its environment, checking implementation and relevant execution assumptions. It still requires human scrutiny that its formal statement matches the intended mathematical problem; a perfectly checked theorem about the wrong operation proves the wrong claim.

Γ⊢t:Pcertifies P relative to the declarations and axioms in Γ.\Gamma\vdash t:P\quad\text{certifies P relative to the declarations and axioms in }\Gamma.
Kernel acceptance checks the formal judgment; it is not an internal proof of the consistency or informal adequacy of every assumption.↔ Scroll wide equations horizontally.

Transport XOR through Boolean negation

Take the Boolean XOR monoid with unit false. Transport it along Boolean negation, which is its own inverse. Compute the new operation table, its unit, and a direct finite check of associativity.

  1. Negation sends the old unit false to true, so the transported unit is true. The transported operation on x and y is the negation of XOR applied to the negations of x and y.

  2. For inputs (false,false), (false,true), (true,false), and (true,true), the outputs are respectively true, false, false, and true. This is the XNOR table, and substituting true in either argument returns the other input.

  3. Encoding false by zero and true by one, the transported operation is one plus x plus y modulo two. Either parenthesization of a threefold product gives x+y+z modulo two, because the two added ones cancel. This verifies associativity in all eight Boolean cases, independently of an unexecuted proof-assistant script.

x⋆y=1+x+y(mod2),(x⋆y)⋆z=x+y+z=x⋆(y⋆z)(mod2).x\star y=1+x+y\pmod2,\qquad (x\star y)\star z=x+y+z=x\star(y\star z)\pmod2.
The modular calculation verifies all finite cases; the lesson does not claim that a Lean source file was executed.↔ Scroll wide equations horizontally.
The result

The transported monoid has unit true and the XNOR operation. Retaining the old XOR table with the new unit would fail the unit law.

Explore the model

Interactive lab

Interactive lab · modular

Check the finite arithmetic behind the transported table

Pause and Reset, then set modulus to 2 and additive step to 1. Predict residues 0, 1, 0 after two Steps; two added ones cancel, as in the associativity calculation. For a fresh comparison Reset and set modulus to 2 and step to 0: all residues remain 0. Construct the full four-entry XNOR table on paper; this orbit does not check a monoid record, audit axioms, or run a trusted kernel. Edits retain time; Reset and both controls are required for each fresh run.

Check the finite arithmetic behind the transported tableAddition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Current readings: Residue r0: 0; Orbit period · m/gcd(m,a): 12; Distinct residues visited: 1 of 12. All parameters are adjustable with the labeled controls below.Repeated addition modulo 12: the current residue is 0, and the orbit period is 12.01234567891011+ 5mod 12An additive orbitn = 0rₙ = 0Period = 12Cycle starts at 0:0 → 5 → 10 → 3 →8 → 1 → 6 → 11 →4 → 9 → 2 → 7 → 0Exact residues · two additions per second
Additive orbitCurrent residue / next edge
Residue r0
0
Orbit period · m/gcd(m,a)
12
Distinct residues visited
1 of 12
t = 0 s

Addition modulo m starts at zero: rₙ = na mod m. Playback advances two additions per second. The orbit has period m/gcd(m,a), including period one for a = 0. This is not a cryptographic security test or a primality algorithm. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forFinite arithmetic can verify a concrete law, while a formal certificate additionally fixes its exact structure and assumptions.

Check your understanding

What does kernel acceptance of a proof term establish when its environment contains a declared axiom?

Try it yourself

On Bool, use logical OR with unit false. Verify the unit and associativity laws, then show why the structure is not a group. Explain why a checked monoid certificate alone would not establish a group theorem.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Use the two Boolean cases for the unit laws and the statement that a threefold OR is true exactly when at least one input is true.

Compare with the solution

OR with false returns the other argument on either side. Both parenthesizations of a threefold OR are false only when all three inputs are false, so they agree in all eight cases. The element true has no inverse because OR of true with either Boolean is true, never the unit false. Thus the monoid laws hold while the inverse requirement fails. A kernel-checked term for the monoid record would certify exactly those recorded laws; calling the object a group without an additional inverse proof would change the claim.

Take it with you

  • Structure records contain chosen data and precisely quantified laws.
  • Transporting a carrier equivalence requires transporting operations and checking preservation.
  • A trusted kernel checks formal judgments relative to explicit axioms, not the correctness of an informal intention.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.