Entails
Browse documentation

Proof checking

Guard certificates in Entails and Lean

entails check docs/counter.entails original_safe --engine entails
entails check docs/counter.entails original_safe --engine lean

The Entails checker checks initialization and evaluates a native step for each representative admitted by a supplied invariant. Head positions zero, one, and at least two cover the cases because the head moves at most one cell per step. The checker considers every possible symbol read for that representative head region. If all the cases preserve the invariant, induction gives nonacceptance at every deadline. Missing rows reject, and acceptance is forbidden by the invariant.

The Lean backend builds the obligations from the same parsed source. Lean’s kernel checks the generated definitions and induction proof. The Entails checker is a separate implementation against the executable semantics. Its exhaustive finite check is specific to guard certificates. It supplies no independent kernel for general Entails theorems.

The WebAssembly playground implements the same representative case split for a restricted source grammar. It reads machine states, tape symbols, transitions, and the guard induction proof term. It reports the first failed obligation. To rebuild the committed browser asset from a checkout, install Rust’s wasm32-unknown-unknown target and run sh scripts/build-wasm.sh. CI checks both the published asset and a fresh build with the same WebAssembly tests.

Type theory and axioms

Entails currently checks first-order executable definitions, inductive data, and a particular guard proof term. Its emitted proofs use Lean’s dependent type theory, based on the Calculus of Constructions with universes, inductive families, proof-irrelevant Prop, and quotients. The generated guarded-counter theorem reports just propext (propositional extensionality). Lean can also admit its standard Quot.sound (quotient soundness) and Classical.choice (choice) axioms. The paranoid policy permits those three names and rejects any other dependency, including sorryAx. The separate executable checker evaluates transitions and does not invoke a general logic. Lean’s account of axioms and computation

Paranoid checking

entails check docs/counter.entails original_safe --paranoid --forest

The CLI elaborates the generated theorem, audits the axioms used by that theorem, exports its transitive proof dependency closure as NDJSON, and replays it through Lean’s hardened checker and Lean4Lean. Success also requires the Entails checker to accept the same guard certificate. The export must contain the named theorem and pass a second axiom audit over its declarations. An optional --kernel /absolute/path/to/checker runs an additional local executable, passing the NDJSON path as its only argument. The command requires exit status zero from every requested checker. An invalid axiom audit rejects the check. A missing checker, failed replay, timeout, or disagreement gives an inconclusive result.

The proof artifact includes Entails.checked_cases_preserve, a theorem that turns successful finite Boolean case checks into preservation for a concrete configuration. It is part of the proof of the checked counter, so replay checks that theorem too. The remaining trust boundary includes the translation from the original Entails source, the Lean exporter, the replay executables, and their toolchains. Formal equivalence of the Python or Rust implementation to the model and metatheory of a general Entails kernel are future work. Run external checkers and Lake projects you trust. This CLI path does not supply the process sandbox of lake comparator. Lean external kernels

Import Lean modules

Point the CLI at a trusted Lake project with already-built dependencies. It uses the toolchain pinned by that project. The toolchain must provide the bundled replay executables if paranoid checking is requested.

entails check docs/counter.entails original_safe \
  --lean-project /path/to/lake/project \
  --lean-import Mathlib.Data.Nat.Basic \
  --lean-import Cslib.Computability.Languages.Language \
  --paranoid

Repeat --lean-import as needed. On entails emit-lean, this flag adds imports to a standalone Lean source file, which you can extend with Lean declarations and compile using lake env lean in the project. Library declarations the checked theorem uses appear in its dependency closure. The import currently exposes the modules on the Lean side. Entails-level names, lemma application, and a semantics bridge for CSLib’s machine models are separate implementation steps. Keep dependencies pinned in Lake instead of copying their sources into the Entails standard library. CSLib releases · Mathlib releases

For instance, this Lean theorem uses a declaration from each of the imported modules. It was checked in the pinned research workspace after appending it to the emitted counter source.

theorem library_bridge_probe (x y : List Nat) (a b c : Nat) :
    (x ∈ ({y} : Language Nat) ↔ x = y) ∧ a / b / c = a / c / b :=
  ⟨Language.mem_singleton x y, Nat.div_right_comm a b c⟩

A Lean-compatible kernel checks elaborated declarations. Lean and Lake still handle import resolution, syntax and tactics. Compiling imported executable definitions with a native Entails backend also needs a lowering for the supported definitions after proof erasure.

Evidence for richer proof rules

For fixed-width arithmetic, the candidate design is verified bit-blasting with a proof-producing SAT solver and an LRAT checker. The solver searches and the checker verifies its evidence against the encoded goal. Lean’s bv_decide already provides such a workflow. Formally verified SAT proof checkers also appear in the 2026 SAT Competition.

For supported SMT theories, evaluate cvc5’s Alethe proofs and check them with Carcara. The encoding from an Entails obligation and the accepted proof rules both need a sound interpretation. cvc5 Alethe proof output

General quantified proofs need an explicit calculus and proof terms. AI-guided search can suggest statements, invariants, or terms. A checked proof requires independently checkable evidence.