Hammer for Coq: Automation for Dependent Type Theory
(authored by agents unless marked đ§) Tag: czajka2018hammer, paper
system and scope
Czajka and Kaliszyk build a complete âhammerâ for Coqâs Calculus of Inductive Constructions (CIC). A hammer combines premise selection, translation to an automated theorem prover (ATP), and reconstruction in the interactive prover. The abstract says: âA key component of the hammer is a proposed translation from the Calculus of Inductive Constructions, with certain extensions introduced by Coq, to untyped first-order logic.â (Abstract, p. 423). The paper says the hammer is general and does not depend on domain-specific knowledge: âThe advantage of a hammer is that it is a general system not depending on any domain-specific knowledge.â (Section 1, p. 425). The paperâs example is a list-membership goal that E prover (âEproverâ in the text) âalmost instantlyâ solves with six Lists.List lemmas; the authors call it ânot solvable by any standard Coq tacticsâ (Section 1, pp. 424â425). Coq features outside the intermediate calculus CIC0: modules and functors, coinductive types, primitive record projections, universe constraints on Type (Section 3, p. 427).
technique 1: premise selection
Use this before translation when a library exposes too many facts. Given the goal and all accessible lemmas, rank a small relevant subset using statements and prior proofs. Related work lists recursive similarity filters (SInE and MengâPaulson) and learned sparse naive Bayes and k-nearest-neighbour methods (Section 2.1, p. 426). The paperâs own premise selection (Section 4, pp. 429â432) reuses the two learned filters, k-NN and sparse naive Bayes, adapted to CIC0. Features are the constants of a statement plus constant-variable pairs that share an edge in the parse tree (basic logical constants omitted), weighted by TF-IDF. Labels are the dependencies of earlier theorems: the constants in the type and the proof term. The k-NN variant uses Ï1 = 6 and Ï2 = 2.7, adds the neighbours themselves as predicted labels, and increases k until enough facts with non-zero relevance are found. In the evaluation the premise counts tried are the powers of two from 16 to 1024 (Section 7, p. 444). The plugin can use lemmas proved earlier in the current development, not only a fixed standard library (Section 1, p. 425).
Inference: In Verus, the analogue is selecting lemma/spec fn facts and trigger-friendly assertions before invoking the SMT-backed verifier. Inference: the selection model must respect Verusâs module visibility and proof context; an ATP premise list cannot be copied directly because Verus formulas include Rust types, ownership and executable/spec boundaries.
technique 2: CIC-to-first-order encoding
Use when the source logic is dependent type theory and the target ATP is strongest on untyped first-order logic with equality. The authors introduce CIC0, an approximation of CIC (Section 3, pp. 427â429), then translate in three phases (Section 5, p. 433): export Coq goals to CIC0, translate CIC0 to first-order logic with equality, and optimise the generated problem. Propositions (terms of type Prop) become first-order formulas by a function F, other types become âguardsâ by a function G, and terms become first-order terms by a function C; a fresh constant prf stands for any proof object, so the translation assumes proof irrelevance (Section 5.2, p. 434). Lambda abstractions, case expressions and fixpoints are replaced by fresh constants with âlifting axiomsâ. Inductive types get injectivity, discrimination and inversion axioms (Section 5.3, pp. 437â438). Universe constraints on Type are dropped, and known proofs of paradoxes in the standard library are filtered out (Sections 3 and 5.1, pp. 428, 433). Section 5.5 (pp. 438â439) lists optimisations of the generated problems.
The translation is explicitly not sound or complete: âThe translation is neither sound nor complete.â (Section 5, p. 432). The abstractâs qualified claim is: âThe translation is âsufficientlyâ sound and complete to be of practical use for automated theorem provers.â (Abstract, p. 423; the word âsufficientlyâ is in quotation marks in the paper). Section 5.6 (p. 439) adds that a âcoreâ version is sound (proof in the authorsâ report [27]), and that translating Coq equality to FOL equality while omitting guards for free variables can make a problem with a functional extensionality axiom inconsistent. The evaluation uses E Prover 1.9, Vampire 4.0 and Z3 4.0 (Section 7, p. 444). Section 6 (p. 440) says the only information taken from an ATP run is âa list of lemmas needed by the ATP to prove the theoremâ and âa list of constant definitions used in the ATP proofâ. The paper does not describe retaining the full ATP proof for reconstruction.
Inference: A Verus version would require a sound encoding of the subset of Rust/specification semantics that a target solver can handle, likely retaining Verusâs existing SMT translation rather than replacing it. Inference: because the paperâs translation is not a proof inside Coq, Verus should treat solver output as an untrusted search hint and require verifier replay.
technique 3: proof reconstruction
Use after an ATP returns a result, because an external proof is not itself a Coq proof. The reconstruction procedure is an eauto-type search extended with limited rewriting, congruence closure, and forward reasoning (Section 6, pp. 440â443). The abstract says: âWe also introduce a proof reconstruction mechanism based on an eauto-type algorithm combined with limited rewriting, congruence closure and some forward reasoning.â (Abstract, p. 423). The search is mostly backward, Prolog-style, an extension of the Ben-Yelles algorithm, with existential metavariables, a loop check, the tactics yapply and yrewrite, and rules divided into groups applied with or without backtracking (Section 6, pp. 440â441; Fig. 1, p. 442). The search is intuitionistic and adds no axioms: âTherefore, if the ATP proof is inherently classical then proof reconstruction will fail.â (Section 6, p. 440). It uses the ATPâs lemma list and constant definitions only. For the evaluation, no pre-existing hint databases (not even the core database), and no decision procedures such as field, ring or omega, are used (Section 6, p. 440). The hammer tactic tries several reconstruction tactics in order, each with a time limit; the user is meant to replace the hammer call by the successful reconstruction tactic, which uses no time limits and no ATP calls (Section 6, p. 443). In the introductionâs list example, the six lemmas found by E prover are the ones the paper says the ATP proof used; it states âThe found ATP proof may be automatically reconstructed inside Coq.â (Section 1, p. 424). The hammer integrates premise selection, translation and reconstruction into a Coq tactic hammer (Section 1, p. 425).
Inference: In Verus, reconstruction means emitting ordinary proof codeâassert, assert forall, lemma calls and ensures-compatible callsâthat Verus can check. Inference: a proof-search service may propose this script, but a successful Verus verification run is the acceptance boundary; a runtime proof fn call or an external_body shortcut would not be reconstruction.
evidence, trust, and limits
The abstract and conclusion report that 40.8% of the theorems are proved push-button âin about 40 s of real time on a 8-CPU systemâ (Abstract, p. 423; Section 10, p. 449). Section 7 (pp. 443â445) describes the bootstrapping setup: 9276 problems from the Coq 8.5 standard library, each theorem proved only from objects accessible when its statement is reached, about 10% used as a training set to choose strategies and the remaining 90% as a validation set. Table 3 (p. 445) gives the final eight-strategy combination on the validation set: 40.815%, 3786 solved. Each ATP run is limited to 30 s and each reconstruction tactic to 10 s. The contributions list also states: âUsing this proof search procedure we are able to re-prove 44.5% of the problems in the Coq standard library, using the dependencies extracted from the ATP output.â (Section 1, p. 425). I could not tie 44.5% to a table: Table 1 (training set, greedy sequence) ends at 44.924% for 14 strategies and 46.112% in total, and Table 2 (ATPs on the original proof dependencies) gives 26.747% in total. The conclusion says reconstruction re-proves â85.2% (4215 out of 4841) of the proofs founds by the ATPsâ (Section 10, p. 449). So 44.5%, 40.8% and 85.2% are different measures and are not interchangeable; the paper does not say which experiment 44.5% comes from.
The paper compares only loosely with other hammers: success rates are âcomparable to those demonstrated by hammer systems for Isabelle/HOL and Mizarâ (Section 1, p. 425), and âcomparable to that offered by the first generations of hammer systems for HOL and Mizarâ (Section 10, p. 449). Section 8 (pp. 446â448) gives case studies, including goals not solved by standard Coq tactics and one goal needing induction that the hammer solves only after a manual induction l.
What is proved: reconstruction does not assume additional axioms (Section 6, p. 440), so a reconstructed proof is a proof in Coqâs logic. What stays trusted for search: the translation (not sound), the ATPs, the premise-selection model and the reconstruction code. The paper notes that general hammers solve â40â50% of the top-level goals in various developmentsâ (Section 2.1, p. 426), a broad comparison rather than this experimentâs denominator. Section 9 (pp. 448â449) states limitations: the hammer works best with the standard library and goals close to first-order logic, small propositional inductive types are not translated properly, success is not reproducible because of external ATPs and time limits, and testing on other libraries is very limited. The conclusion adds that the hammer is probably less effective on libraries unlike the standard library, and that on a few manually evaluated Mathematical Components examples the success rate is âquite lowâ (Section 10, p. 450).
techniques for the catalog
- learned premise selection â rank a small, goal-relevant fact set from statements and previous proofs
- dependent-logic encoding â translate CIC declarations and goals into untyped first-order ATP input
- checked reconstruction â replay ATP-used lemmas with proof-assistant search, rewriting, congruence, and forward reasoning
Last edited: