Centralized certificate verification (trust choke point) #
Every LeanCert reflective tactic ultimately closes a decidable certificate
proposition, normally of the form check … = true. This module is the single place where that goal
gets closed, and therefore the single place where the trusted base of the
resulting proof is decided:
| Mode | Closes with | Trusted base |
|---|---|---|
.native | nativeEqTrue | kernel + compiler/runtime (native auxiliary axiom) |
.kernel | cached kernel proof | kernel only (foundational axioms) |
.auto | kernel, then native | kernel when it succeeds; fallback is reported |
Design rules:
.kernelnever falls back to native verification. Failure is a hard error telling the user how to opt in to native trust explicitly..automay fall back, and reports when it does (trace[leancert.verification]always; onelogInfoper process on first fallback).- The typed boundary reduces the
Decidableinstance first, so a conclusivefalseresult is data rather than an exception. Successful kernel proofs still go throughmkAuxLemmafor eager kernel validation and per-module caching. - Native mode uses Lean's structured
nativeEqTrueprimitive directly:.notTrueis rejection, while compilation/evaluation exceptions are infrastructure failures.
Select the mode globally with set_option leancert.trust "kernel" (likewise
"native", "auto"), or per invocation with (trust := kernel|native|auto).
The per-invocation setting takes precedence.
Caveat for .auto: the heartbeat budget bounds elaboration-side work, but
kernel reduction itself is not heartbeat-interruptible; a pathologically large
certificate can exceed the budget wall-clock. Calibrated cost gates therefore
route predictably large finite sums, integrations, and optimization
certificates directly to native verification.
Reported once per process on the first .auto-mode native fallback, so a
file with hundreds of certificate checks does not produce hundreds of
messages. Per-invocation detail is always available under
trace[leancert.verification].
How a certificate goal is allowed to be verified.
- native : VerificationMode
Close with
native_decide; the proof additionally trusts the Lean compiler and runtime (Lean.ofReduceBool). - kernel : VerificationMode
Close with
decide +kernel; kernel-only trusted base. Never falls back to native verification. - auto : VerificationMode
Try the kernel route first, fall back to
native_decide, reporting the fallback.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Which route actually closed a certificate goal.
- kernel : VerificationUsed
- native : VerificationUsed
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Why a particular verification route was used.
This distinguishes an explicit native request from the two reasons that
.auto can use native verification.
- explicitNative : VerificationCause
The caller explicitly requested native verification.
- explicitKernel : VerificationCause
The caller explicitly requested kernel verification.
- autoKernel : VerificationCause
Auto mode successfully used kernel verification.
- autoNativeGate : VerificationCause
Auto mode selected native verification before attempting the kernel because a calibrated cost gate fired.
- autoNativeFallback : VerificationCause
Auto mode used native verification after its kernel attempt failed.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Structured telemetry for one successfully closed certificate goal.
The event is returned directly to the caller. It is not stored globally, so speculative tactic attempts can discard it together with their proof state.
- requested : VerificationMode
The resolved policy in force for this certificate closure.
- used : VerificationUsed
The route that actually closed the certificate.
- cause : VerificationCause
Why that route was selected.
Human-readable auto-gate explanation, present exactly for
autoNativeGateevents.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Verification telemetry for zero or more retained certificate closures.
- events : Array VerificationEvent
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Infrastructure failures while checking a Boolean certificate.
An ordinary checker result of false is deliberately not represented here:
it is the .rejected case of VerificationResult.
- malformedCertificateGoal
(detail : String)
: VerificationFailure
The proposed certificate goal was not a closed decidable proposition.
- kernelFailure
(detail : String)
: VerificationFailure
Kernel reduction could not determine or validate the checker result.
- nativeFailure
(detail : String)
: VerificationFailure
Native compilation or evaluation failed before producing a result.
- internalError
(detail : String)
: VerificationFailure
The verification protocol itself encountered an unexpected invariant failure.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Typed result of attempting to close one Boolean certificate goal.
Only .accepted mutates the retained tactic state. Both .rejected and
.failed restore the complete state saved on entry.
- accepted
(event : VerificationEvent)
: VerificationResult
The checker evaluated to
true; the certificate goal is assigned. - rejected : VerificationResult
The checker conclusively evaluated to
false. - failed
(failure : VerificationFailure)
: VerificationResult
The checker could not be evaluated or its proof could not be retained.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Regard one successful certificate closure as aggregate usage.
Instances For
Aggregate usage containing one successful certificate closure.
Equations
- LeanCert.Tactic.VerificationUsage.singleton event = event.toUsage
Instances For
Combine independently retained verification events, preserving order.
Instances For
Number of retained certificates closed by kernel reduction.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Number of retained certificates closed by native reduction.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Reasons for auto-mode decisions that bypassed kernel verification.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- LeanCert.Tactic.VerificationMode.ofString? "native" = some LeanCert.Tactic.VerificationMode.native
- LeanCert.Tactic.VerificationMode.ofString? "kernel" = some LeanCert.Tactic.VerificationMode.kernel
- LeanCert.Tactic.VerificationMode.ofString? "auto" = some LeanCert.Tactic.VerificationMode.auto
- LeanCert.Tactic.VerificationMode.ofString? x✝ = none
Instances For
Option-value spelling of the mode ("kernel" / "native" / "auto").
Equations
Instances For
Configuration for certificate verification. Tactics resolve this from
options via VerificationConfig.current; public (trust := …) syntax
overrides it per invocation.
- mode : VerificationMode
- kernelHeartbeats : Nat
Heartbeat budget for the kernel attempt in
.automode.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Read the verification configuration from the current options
(leancert.trust, leancert.trust.kernelHeartbeats).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Auto-mode cost gate #
Thresholds come from scripts/bench-trust/baselines/ (see the README there):
kernel reduction is essentially free for point/bound/Newton certificates,
cheap for moderate partition/subdivision counts, and crosses over to
"markedly worse than native" around 10^4 finite-sum terms (superlinear time,
+1.5 GiB RSS). The gate reads scale parameters syntactically off the
certificate goal; anything it does not recognize is attempted normally.
The checker names below are unresolved Name literals because this module
deliberately imports only Lean (everything in LeanCert imports it back).
LeanCert/Test/TrustModes.lean builds these applications with resolved
names and asserts the gate fires, so a checker rename breaks CI rather than
silently disabling the gate.
If the certificate is predictably past the kernel/native crossover,
return a human-readable reason to skip the kernel attempt in auto mode.
none means "attempt the kernel".
Equations
- One or more equations did not get rendered due to their size.
Instances For
Close a decidable certificate goal (normally check … = true) according to the
verification mode and return a typed result.
Only .accepted retains state changes. Rejection, malformed goals, and
verification infrastructure failures restore the complete tactic state saved
on entry, including environment declarations and messages.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Close the current goal as a LeanCert certificate check according to the
configured verification route (leancert.trust, or a (trust := …) override
active via withTrustMode). For tactic implementations that embed certificate
obligations inside quoted proof terms — (by leancert_verify_cert) — where
the typed boundary cannot be called directly. Not intended for end users.
Equations
- LeanCert.Tactic.tacticLeancert_verify_cert = Lean.ParserDescr.node `LeanCert.Tactic.tacticLeancert_verify_cert 1024 (Lean.ParserDescr.nonReservedSymbol "leancert_verify_cert" false)
Instances For
Public per-invocation syntax: (trust := kernel|native|auto) #
Tactics accept an optional trailing leancertTrustItem; when present it
overrides the leancert.trust option for that invocation only (implemented
by running the tactic core under withOptions, so every certificate check in
the invocation — including nested fallback strategies — honors it).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Parser category for verification modes. auto needs an explicit branch
because it is a reserved Lean token rather than an ident.
Equations
Instances For
Equations
- LeanCert.Tactic.leancertTrustMode_ = Lean.ParserDescr.node `LeanCert.Tactic.leancertTrustMode_ 1022 (Lean.ParserDescr.const `ident)
Instances For
Equations
- LeanCert.Tactic.leancertTrustModeAuto = Lean.ParserDescr.node `LeanCert.Tactic.leancertTrustModeAuto 1022 (Lean.ParserDescr.nonReservedSymbol "auto" false)
Instances For
Per-invocation verification route for LeanCert tactics:
(trust := kernel), (trust := native), or (trust := auto).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Elaborate an optional (trust := …) item.
Equations
- One or more equations did not get rendered due to their size.
- LeanCert.Tactic.elabTrustItem? none = pure none
Instances For
Run act with leancert.trust overridden to mode? when provided.
Equations
- LeanCert.Tactic.withTrustMode none act = act
- LeanCert.Tactic.withTrustMode (some m) act = Lean.withOptions (fun (o : Lean.Options) => o.set `leancert.trust m.asString) act
Instances For
#assert_trust: CI trust manifests #
#assert_trust kernel thm / #assert_trust native thm pin a theorem's trust
class. Drift in either direction fails: a kernel-clean theorem acquiring
native-compiler trust is a regression, and a native-pinned theorem losing its
native dependency means the manifest should be tightened to kernel.
sorryAx and unrecognized axioms always fail.
Trust classification of a single axiom.
- foundational : TrustClass
- nativeCompiler : TrustClass
Lean.ofReduceBool/Lean.ofReduceNat/Lean.trustCompiler, or a per-declarationnative_decideauxiliary (<decl>._native.native_decide.ax_*). - sorryAx : TrustClass
- custom : TrustClass
Anything else.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Classify an axiom name into its trust class.
Equations
- One or more equations did not get rendered due to their size.