Documentation

LeanCert.Tactic.Verification

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:

ModeCloses withTrusted base
.nativenativeEqTruekernel + compiler/runtime (native auxiliary axiom)
.kernelcached kernel proofkernel only (foundational axioms)
.autokernel, then nativekernel when it succeeds; fallback is reported

Design rules:

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

      Which route actually closed a certificate goal.

      Instances For
        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
            • 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.

              Instances For
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Verification telemetry for zero or more retained certificate closures.

                  Instances For
                    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

                          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.

                          Instances For
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              Regard one successful certificate closure as aggregate usage.

                              Equations
                              Instances For

                                Aggregate usage containing one successful certificate closure.

                                Equations
                                Instances For

                                  Combine independently retained verification events, preserving order.

                                  Equations
                                  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

                                          Configuration for certificate verification. Tactics resolve this from options via VerificationConfig.current; public (trust := …) syntax overrides it per invocation.

                                          Instances For
                                            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
                                                      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

                                                            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
                                                              Instances For

                                                                Run act with leancert.trust overridden to mode? when provided.

                                                                Equations
                                                                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.

                                                                  Instances For
                                                                    @[instance_reducible]
                                                                    Equations
                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For

                                                                      Classify an axiom name into its trust class.

                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For

                                                                        #assert_trust kernel thm: thm depends on foundational axioms only. #assert_trust native thm: thm additionally depends on native-compiler trust (and nothing worse). Any sorryAx or unrecognized axiom fails both.

                                                                        Equations
                                                                        • One or more equations did not get rendered due to their size.
                                                                        Instances For