The pipeline and the kernel
How a program goes from text to a checked term, why the elaborator is not trusted, and what the kernel checks again.
What happens to id 3 when the type of 3 is left implicit? The
elaborator fills in the missing argument. A separate checker, the
kernel, checks the resulting term rather than trusting the inference.
It can reuse previously checked imports.
Step 1 of 6: Parse
let id : forall {a : Type} -> a -> a = \x -> x
let three = id 3
let test = assert : three === 3
in threeFull example and walkthrough
let id : forall {a : Type} -> a -> a = \x -> x
let three = id 3
let test = assert : three === 3
in threeElaborated term
let id = ((\{a : Type} (x : a) -> x) : forall {a : Type} -> a -> a)
let three = id @Natural 3
let test = (refl @0 @Natural @three : Equal @0 Natural three 3)
in three- Parse. The parser reads the text into a syntax tree. Nothing is known about types yet. (lines 2:
id 3) - Infer an argument.
idhas an implicit type argument,{a : Type}. The elaborator finds from the argument3thataisNatural, and writesid @Natural 3. (lines 2:id 3) - Expand an assertion.
assert : three === 3becomesrefl, the proof that a value equals itself, at the typeEqual @0 Natural three 3. It is a proof becausethreecomputes to3. (lines 3:assert : three === 3) - Check again. The elaborator's output is one closed term. The kernel type-checks it from scratch, without the elaborator's reasoning. (lines 1–4)
- What if the proof did not fit?. The shown assertion checks. If the elaborator instead supplied
reflforthree === 4, the kernel would reject that proof: the two sides compute to different numbers. (lines 3:three === 3) - Use the checked term.
omegyu typeprints the checked term's type,omegyu normalizeits normal form;omegyu runcarries out an action andomegyu evm buildcompiles a contract. (lines 4:three)
What the elaborator does
Use omegyu elaborate to see what was filled in. Here the result contains
id @Natural 3, even though the source never wrote @Natural. See
implicit arguments for how
to supply that argument yourself.
What the kernel checks
For assert : three === 3, the proof only checks if three and 3 agree
by computation. Follow normalisation to see how
the comparison works. The compiler pipeline
identifies the implementation responsible for each stage.
What is assumed
Type checking establishes that the term has its type. It does not establish that the type says what its author intended or that the EVM back end emits correct bytecode. See what is checked, tested and assumed.