Expand description
A call-by-value evaluator for the kernel’s computational fragment — the engine behind
native_decide.
Unlike normalize, which β/ι/δ-reduces by SUBSTITUTION
and normalizes under binders to full normal form, this evaluates a CLOSED term to weak
head normal form using an ENVIRONMENT (no substitution), stopping as soon as the head
constructor is known. So deciding Eq Nat 10000 10000 is a linear environment walk, not
a quadratic substitution blowup — the point of native_decide.
TRUST: native_decide trusts this evaluator to agree with the kernel’s reduction (as
Lean’s native_decide trusts its compiler). It is validated by a differential test
against normalize, and fail-safes to None (declining) on anything it cannot decide,
but it IS part of the trusted base whenever native_decide is used.
Functions§
- eval_
bool - Evaluate a closed Bool term to
true/false, orNoneif it does not reduce to a Bool constructor within the fuel budget (fail-safe). - eval_
bool_ tree - The tree-walking interpreter decision — walks the
Termeach step. The fallback foreval_booland the differential oracle the compiled path is validated against. - native_
compile_ bool - Compile a ground Bool decision into native closures and run it —
Noneif the term is outside the compilable fragment (the caller falls back to theeval_boolinterpreter). Semantics are IDENTICAL toeval_bool/normalize(differential-tested), so theofReduceBoolcertificatenative_decidebuilds is equally sound. - native_
compile_ decide - Compile a closed Bool decision to native closures and run it —
Noneif it does not reduce to a Bool constructor (fail-safe; the caller falls back to the tree-walking interpreter). Unlikenative_compile_bool, this handles the FULL computational fragment (recursion, pattern matching, definitions), so recursor-based decisions compile to native code. Its verdict is IDENTICAL toeval_bool_tree/normalize(differential-tested). - native_
decide - Build a
native_decideproof ofpropfrom aDecidable propinstanceinst: if the decision procedure NATIVELY evaluates totrue, return the proof termof_decide_eq_true prop inst (ofReduceBool (decide prop inst) true (refl Bool true)), which the (main) kernel checks by running this evaluator via thereduceBoolhook — never by re-normalizing the decision procedure. ReturnsNone(fail-safe) when the decision is nottrue, so it can only ever produce proofs of genuinely-true goals.