Concept 1 of 8

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.

A program through the parser, the elaborator and the kernel
1 / 6

Step 1 of 6: Parse

let id : forall {a : Type} -> a -> a = \x -> x
let three = id 3
let test = assert : three === 3
in  three
Your result
Complete example · with imports
Full example and walkthrough
Elaborated
let id : forall {a : Type} -> a -> a = \x -> x
let three = id 3
let test = assert : three === 3
in  three
Your result
Complete example · with imports

Elaborated 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
  1. Parse. The parser reads the text into a syntax tree. Nothing is known about types yet. (lines 2: id 3)
  2. Infer an argument. id has an implicit type argument, {a : Type}. The elaborator finds from the argument 3 that a is Natural, and writes id @Natural 3. (lines 2: id 3)
  3. Expand an assertion. assert : three === 3 becomes refl, the proof that a value equals itself, at the type Equal @0 Natural three 3. It is a proof because three computes to 3. (lines 3: assert : three === 3)
  4. 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)
  5. What if the proof did not fit?. The shown assertion checks. If the elaborator instead supplied refl for three === 4, the kernel would reject that proof: the two sides compute to different numbers. (lines 3: three === 3)
  6. Use the checked term. omegyu type prints the checked term's type, omegyu normalize its normal form; omegyu run carries out an action and omegyu evm build compiles 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.