Theorem Proving

epistemic

Theorem Proving

Definition

Theorem proving is the discipline of constructing formal mathematical proofs that demonstrate specific properties hold for a system under all possible conditions. Unlike testing, which validates behavior against a finite set of inputs, theorem proving provides absolute certainty: a proven property holds universally, with no counterexample possible. The proof itself serves as a machine-checkable certificate of correctness, verified by a small trusted kernel that is orders of magnitude simpler than the system being proven.

The field divides into two major branches. Interactive theorem provers (ITPs) such as Lean4, Coq, Isabelle/HOL, and Agda provide a formal language for expressing propositions and a tactic language for constructing proofs, with human guidance directing the proof search. Automated theorem provers (ATPs) such as Z3, Vampire, and E attempt to discover proofs without human intervention, typically for decidable fragments of first-order logic. Modern systems increasingly blur this boundary: Lean4's omega and decide tactics invoke automated solvers, while ATPs can be called as oracles within interactive proofs.

In the context of safety-critical and intelligence platforms, theorem proving provides guarantees that no amount of testing can match. A proof that a security policy correctly enforces access control holds for every possible request, not merely the requests in a test suite. This distinction is especially important for epistemic systems where the correctness of reasoning processes directly impacts the trustworthiness of conclusions drawn from evidence.

Historical Foundations

The theoretical underpinnings of theorem proving trace back to the early twentieth century. Frege's Begriffsschrift (1879) introduced the first formal logical system, Gentzen's natural deduction and sequent calculus (1935) provided the proof-theoretic foundations still used today, and Curry and Howard independently observed the correspondence between proofs and programs that would later bear their names.

EraMilestoneSignificance
1879Frege's BegriffsschriftFirst formal logical calculus
1935Gentzen's sequent calculusFoundation for proof search and cut elimination
1958Curry-Howard correspondenceProofs as programs, propositions as types
1972Edinburgh LCFFirst tactic-based interactive prover with a small trusted kernel
1985Coq (Calculus of Constructions)Dependent types for expressive specifications
2005Gonthier's Four Color Theorem proofFirst major mathematical result machine-verified
2017Lean (Microsoft Research)Modern ITP with metaprogramming and automation
2021Lean4Production-grade rewrite with compiled tactics and FFI
2025Prismatic QEVE integrationLean4 proofs in epistemic verification pipelines

The LCF approach, pioneered by Robin Milner, established the architectural pattern still dominant today: a small, trusted proof-checking kernel (typically hundreds of lines) validates all proof steps, while an arbitrarily complex tactic layer constructs proofs. This ensures that bugs in tactics cannot produce invalid proofs -- only the kernel must be correct.

Interactive vs Automated Proving

The choice between interactive and automated theorem proving depends on the complexity and expressiveness required by the property being verified.

DimensionInteractive (ITP)Automated (ATP)
Human effortHigh -- user guides proof constructionLow -- solver searches autonomously
ExpressivenessArbitrary higher-order logic, dependent typesTypically first-order, quantifier-free fragments
Proof outputFull proof term, machine-checkableProof trace or SAT certificate
ScalabilityLimited by human bandwidthLimited by decidability and search space
ConfidenceKernel-verified, highest assuranceSound within theory, potential for solver bugs
Use caseComplex invariants, security policies, algorithmsSMT obligations, arithmetic bounds, decidable theories

In practice, modern verification workflows combine both: an interactive prover establishes the high-level proof structure, delegating decidable sub-goals to automated tactics. Lean4's omega tactic handles linear arithmetic, simp applies rewriting rules automatically, and native_decide compiles decision procedures for finite domains.

Dependent Type Theory

Lean4 is built on the Calculus of Inductive Constructions (CIC), a dependent type theory where types can depend on values. This expressiveness allows specifications to capture precise invariants that simpler type systems cannot express.

-- A vector type where the length is part of the type
inductive Vec (a : Type) : Nat -> Type where
  | nil  : Vec a 0
  | cons : a -> Vec a n -> Vec a (n + 1)

-- append preserves length at the type level
def Vec.append : Vec a m -> Vec a n -> Vec a (m + n)
  | .nil,       ys => ys
  | .cons x xs, ys => .cons x (xs.append ys)

In this example, the type Vec a n encodes the list length n as part of the type itself. The append function's return type Vec a (m + n) is a theorem stating that appending a vector of length m to a vector of length n produces a vector of length m + n. The compiler verifies this automatically -- no separate proof is needed.

Key concepts in dependent type theory relevant to Prismatic's verification infrastructure include:

  • Propositions as types: A proposition P is represented as a type; a proof of P is a term of that type
  • Proof irrelevance: Two proofs of the same proposition are interchangeable (in Prop)
  • Universe polymorphism: Types are organized into a hierarchy (Type 0, Type 1, ...) to avoid paradoxes
  • Inductive families: Data types indexed by values, enabling precise specifications

The Curry-Howard Correspondence

The Curry-Howard correspondence is the foundational insight connecting logic and computation: every type corresponds to a proposition, and every program of that type corresponds to a proof of that proposition. This isomorphism means that type-checking a program is equivalent to verifying a proof.

LogicProgrammingExample
PropositionTypeNat -> Nat
ProofProgramfun n => n + 1
Implication (A implies B)Function typeA -> B
Conjunction (A and B)Product typeA x B
Disjunction (A or B)Sum typeA + B
Universal quantifierDependent function(n : Nat) -> P n
Existential quantifierDependent pair(n, proof)
FalseEmpty typeEmpty

For the Prismatic Platform, this correspondence means that verified Lean4 code is simultaneously a program and a proof of its specification. When the QEVE framework validates an epistemic property, the Lean4 proof term is both executable verification logic and a mathematical certificate of correctness.

Proof Tactics and Strategies

Tactics are the primary interface for constructing proofs in interactive theorem provers. A tactic transforms a proof goal (an unproven proposition) into zero or more simpler sub-goals. When all sub-goals are discharged, the proof is complete.

-- Proving commutativity of addition in Lean4
theorem add_comm : forall (m n : Nat), m + n = n + m := by
  intro m n
  induction m with
  | zero => simp [Nat.zero_add, Nat.add_zero]
  | succ m ih => simp [Nat.succ_add, Nat.add_succ, ih]

Common tactic families used in Prismatic's verification workflows include:

TacticPurposeAutomation Level
introIntroduce hypotheses from the goalManual
applyApply a lemma matching the goal's shapeManual
inductionStructural induction on an inductive typeManual
simpSimplification using rewriting rulesSemi-automated
omegaLinear arithmetic decision procedureFully automated
decideDecision procedure for decidable propositionsFully automated
aesopAutomated reasoning by searchFully automated
native_decideCompiled decision procedure for finite domainsFully automated

The art of interactive theorem proving lies in decomposing complex goals into sub-goals amenable to automated tactics. Experienced practitioners develop intuition for when manual structural reasoning is needed versus when automation can handle the remaining obligations.

Lean4 in the Prismatic Platform

The Prismatic Platform integrates Lean4 as its primary theorem prover within the QEVE (Quantitative Epistemic Verification Engine) framework. Lean4 was chosen for its combination of expressiveness, performance (compiled tactics), metaprogramming capabilities, and active development momentum.

Prismatic's Lean4 integration covers three verification domains:

Data Integrity Invariants: Proofs that storage operations preserve data consistency across the seven backend adapters. For example, proving that the ETS cache adapter's write-through policy guarantees that a successful write is visible to all subsequent reads.

Security Policy Correctness: Formal proofs that RBAC policies correctly enforce access control, that authentication flows cannot be bypassed, and that information flow constraints prevent unauthorized data exposure.

Epistemic Axiom Compliance: Verification that the NABLA Infinity framework's seven axioms are satisfied by the platform's reasoning pipelines. This includes proving that signal plurality requirements are met, that contradiction preservation is maintained, and that provenance chains are complete.

-- Simplified epistemic axiom: signal plurality
-- Every belief must be supported by at least 2 independent sources
theorem signal_plurality_preserved
    (b : Belief) (sources : List Source)
    (h_plurality : sources.length >= 2)
    (h_independent : Pairwise Independent sources)
    : ValidBelief b sources := by
  exact ValidBelief.mk b sources h_plurality h_independent

Trinity Gate Formal Necessity Layer

The Trinity Gate is the Prismatic Platform's three-layer verification gate through which all epistemic claims must pass before being established as platform knowledge. Theorem proving provides the third and most rigorous layer: formal necessity.

LayerMethodWhat It VerifiesTool
1. Structural ConsistencyGraph theoryBelief network forms a valid DAGKuzuDB queries
2. Logical ConsistencyRule-based reasoningPropositions follow logical rulesElixir rule engine
3. Formal NecessityTheorem provingClaims proven in formal systemsLean4

The formal necessity layer ensures that critical claims are not merely consistent or logically sound but are mathematically proven. This is particularly important for security-critical properties (where a single counterexample could represent an exploitable vulnerability) and for epistemic properties (where reasoning correctness determines the trustworthiness of all downstream conclusions).

The QEVE framework orchestrates the interaction between these layers: when a claim reaches the formal necessity check, QEVE translates the claim into a Lean4 proposition, invokes the prover, and either accepts the resulting proof certificate or reports the unprovable obligation back to the epistemic pipeline for further investigation.

Theorem Proving vs Property-Based Testing

Theorem proving and property-based testing are complementary verification techniques that occupy different points on the assurance-effort tradeoff.

DimensionTheorem ProvingProperty-Based Testing
CoverageAll possible inputs (universal)Random sample of inputs (statistical)
Assurance levelAbsolute (mathematical proof)High confidence (no counterexample found)
Effort requiredHigh (expert knowledge, proof construction)Moderate (property definition, generator writing)
Feedback speedSlow (proof development takes hours to days)Fast (seconds to minutes per test run)
CounterexamplesN/A (proves impossibility of counterexamples)Automatic shrinking to minimal counterexample
MaintenanceProofs must track specification changesTests adapt more easily to changes
Tool maturityLean4, Coq (academic roots, growing adoption)StreamData, PropEr (mature, widely adopted)

The Prismatic Platform uses both: property-based testing with StreamData provides rapid feedback during development, while Lean4 proofs provide the highest assurance for critical invariants that survive into the Trinity Gate formal necessity layer. The Monte Carlo verification component of QEVE bridges the gap by using statistical methods to build confidence before investing in full formal proofs.

Practical Considerations

Deploying theorem proving in a production platform introduces engineering challenges beyond proof construction.

Proof maintenance: As specifications evolve, proofs must be updated. Lean4's type-checking ensures that broken proofs are caught immediately (they fail to compile), but updating proofs requires expertise. Prismatic mitigates this by keeping proofs modular and aligned with the platform's compositional architecture.

Proof performance: Complex proofs can take significant compilation time. Lean4's compiled tactics and incremental compilation help, but large proof developments may still require minutes to build. The QEVE framework caches verified proof certificates to avoid re-verification.

Specification fidelity: A proof is only as meaningful as its specification. If the formal model diverges from the actual system behavior, the proof guarantees nothing about the real system. Prismatic addresses this through the adapter contract test suite, which validates that the formal model and the implementation agree on observable behavior.

Expertise requirements: Theorem proving requires specialized knowledge. The White Team's invariant-prover agent encapsulates this expertise, providing a reusable interface that other platform components can invoke without deep familiarity with Lean4's tactic language.

  • Formal Verification - Broader discipline encompassing theorem proving, model checking, and abstract interpretation
  • Lean4 - Interactive theorem prover used by the platform for QEVE proofs
  • QEVE - Verification engine orchestrating Lean4, NABLA, and Monte Carlo verification
  • Trinity Gate - Three-layer verification gate where theorem proving provides formal necessity
  • Property-Based Testing - Probabilistic complement to formal proofs using random input generation
  • Monte Carlo Verification - Statistical verification bridging testing and formal proof
  • Epistemic Pipeline - 16-level pipeline where proven properties feed confidence scoring
  • NABLA Infinity - Epistemic framework whose axioms are formally verified
  • Consciousness Traits - Platform traits whose invariants are proven in Lean4
  • Typespec - Elixir type annotations complementing formal proofs at the implementation level

See Also

  • Architecture - Verification architecture and Trinity Gate integration
  • Technologies - Proof assistant tooling and formal methods stack
  • Agents - White Team invariant-prover agent specification

Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL