The verification contract
For every input inside the node’s declared shape domain and value domain, a PROVED kernel satisfies all three of:- Semantic equivalence. Every output element equals the spec’s value, with numbers treated as real numbers.
- No overflow. Integer index arithmetic never wraps, and float intermediates stay finite.
- Execution safety. No out-of-bounds access, no two programs writing the same address, and every output element is written.
TheFormalEra.Engine.Implements (specs/TheFormalEra/Engine/Basic.lean). For every lane of every program that executes a store:
- two lanes never write the same address;
- every write lands inside the output tensor and stores the spec’s value as a finite float;
- every element of the output is written.
Numbers are real numbers. Floating-point rounding and associativity are out of scope by design. Re-ordering or re-associating a sum, a different tile size, or a different accumulation order are all the same function. The question verification answers is: is this the same mathematical function?
The pipeline, one kernel at a time
Each annotated kernel goes through these stages, once per constexpr configuration (every@triton.autotune config is a separate program):
A PASS is declared only after the Lean kernel accepts the certificate, and
#print axioms of its main theorem lists only propext, Classical.choice and Quot.sound.
What a certificate looks like
A certificate is an ordinary Lean 4 file in.theformalera/proofs/. It starts with the lifted kernel semantics:
implements: the lifted kernel satisfies Implements for the Op Spec of its node. Values are FVal: real numbers plus ±∞ and NaN, with exact real arithmetic on finite values.
Value subgoals and the Lemma Hub
Most of a proof is index reasoning: the tiles cover the iteration space exactly once, every reduction term is added once. Once that is done, what remains for each output element is an algebraic subgoal: “this expression over loaded values equals the Op Spec’s expression”. The tactictfe_close closes those subgoals:
- Try
ring_nf. If it closes the goal, the goal is trivial and is never stored as a lemma. - Otherwise, replace every non-arithmetic subterm (tensor reads, reductions) with a variable and normalise. The same algebra then gives the same statement, whatever the tile sizes, layout or operation order.
- Look the canonical statement up among the retrieved lemmas: a hit.
- On a miss, run a portfolio of closing tactics under a time budget: a search. If it succeeds, the result becomes a new lemma.
Where the engine runs
The engine is the same in all three run modes; only its location changes:
See Run modes.
