Documentation

CslibFrontier.Tactic.LRATTauto

Propositional tautologies over Prop from LRAT certificates #

lrat_tauto proves a goal built from ∧, ∨, →, ¬, ↔, True and False over arbitrary propositions, the atoms, from an LRAT certificate cert : Array LRAT.IntAction: one generated at elaboration time by the CDCL solver, or one supplied as lrat_tauto using cert. The kernel checks the certificate; the proof uses no native evaluation, and its axioms are those of Cslib.Logic.PL.Proposition.eval_prop_of_checkLRATRat.

The tactic reads the goal P as a proposition A : Proposition (Fin n) and a valuation v : Fin n → Prop of its atoms, with A.eval v ↔ P. It then applies Cslib.Logic.PL.Proposition.eval_prop_of_checkLRATRat to A and v. Its hypothesis, that Cslib.Logic.PL.CNF.checkLRATRat accepts cert on (imp A falsum).plaistedGreenbaumNumberedCNF, is proved by decide for the checker built for kernel reduction, Cslib.Logic.PL.CNF.checkLRATKernel, and rewritten with Cslib.Logic.PL.CNF.checkLRATKernel_eq_checkLRATRat. So the kernel runs that checker, and only that run is trusted; where the certificate came from does not matter. The goals proved are the classical tautologies, since eval_prop_of_checkLRATRat decides each atom classically. Without using, P is P₁ → ⋯ → Pₖ → G for the goal G and the premises Pᵢ that the tactic finds in the context or is given as lrat_tauto [t₁, …, tₙ] (see "Hypotheses and leaves"); the trusted step is the same, on a larger formula.

Reading the goal #

Hypotheses and leaves #

Without using, the tactic proves P₁ → ⋯ → Pₖ → G for the goal G and premises Pᵢ, read over shared atoms, and applies the proof to the premises' proofs; nothing is reverted. The premises are:

Premises that a certificate does not need would still cost the kernel their clauses, so they are dropped, terms as well as hypotheses: an unused term does not appear in the proof. The solver refutes the formula with all the premises; those with a clause among the hints of the trimmed certificate (one of the definitional clauses of its subformulas, or the clause of its imp node asserting it) are kept, the formula is read again from them alone, numbering its atoms afresh, and the solver refutes that formula. The kernel checks the certificate for that formula. If the solver finds the smaller formula satisfiable, which the selection does not rule out, the formula with all the premises and its certificate are used. This selection is untrusted, like the solver. Premises that share no atom with the goal are not dropped before solving: they can still matter, as a contradictory pair does.

A certificate supplied with using refutes the formula of the goal with only the terms as premises, t₁ → ⋯ → tₙ → G for lrat_tauto [t₁, …, tₙ] using cert and G without terms, and lrat_tauto? [t₁, …, tₙ] prints that formula: the clause numbers of a fixed certificate should not depend on the context, so neither the hypotheses nor the facts found by rfl are premises, and no premise is dropped. Pass the hypotheses that a supplied certificate needs as terms, or revert them.

The certificate #

The certificate refutes the numbered Plaisted–Greenbaum transformation of imp A falsum (Cslib.Logic.PL.Proposition.plaistedGreenbaumNumberedCNF), in which the atom numbered i is the DIMACS variable i + 1 and the clauses are numbered 1, 2, … in order. It keeps, for each subformula, only the direction of its Tseitin definition that the subformula's polarity needs. lrat_tauto? prints that formula in DIMACS form, with the atoms in comment lines, so that a SAT solver producing LRAT proofs can refute it. The lines of a textual LRAT proof are the addRup, addEmpty and del actions of the certificate; the checker rejects RAT steps, which some solvers emit after preprocessing (CaDiCaL does not with --plain).

The kernel checks the certificate once, as an auxiliary lemma that the proof then cites. If it fails, lrat_tauto evaluates the checker in the kernel to tell a rejected certificate from one the kernel cannot evaluate, such as a definition from another module whose body is not exposed, and reports which.

Generating the certificate #

Without using, the tactic runs the CDCL solver Cslib.Algorithms.Lean.CDCL.solveCompact on the formula, in Lean's interpreter during elaboration. If the formula is satisfiable, the goal does not follow propositionally from the premises, and the error shows an assignment of truth values to the atoms, read as independent propositions, under which the goal's propositional structure is false and the premises are true; when the context has propositional hypotheses, it names them. It need not be a countermodel of the goal itself, since the atoms may not be able to take those values: for ∀ n : ℕ, 0 + n = n, the one atom 0 + n = n, which the reflexivity check does not prove, is assigned False. Otherwise the solver returns a certificate, which is proved correct (Cslib.Algorithms.Lean.CDCL.solveCompact_unsat) but is not trusted here: the kernel checks it as it checks a supplied one. The certificate is first trimmed to the steps that the empty clause depends on, without the deletions (Cslib.Logic.PL.CNF.trimCert), and the clauses it adds are renumbered n + 1, n + 2, … after the n clauses of the formula (Cslib.Logic.PL.CNF.renumberCert), which keeps the kernel checker's trie shallow. Both are proved to preserve acceptance (Cslib.Logic.PL.CNF.checkLRUP_renumberCert_trimCert), so the result is not checked before the kernel checks it. set_option trace.lrat_tauto true reports the sizes of the formula and of the certificate and the times taken.

The solver is a single private definition, generateCert. Its type, Cslib.Algorithms.Lean.DPLL.Result, guarantees neither a model nor a certificate, so a replacement must meet this contract on each formula φ it is given:

The CDCL solver meets it (Cslib.Algorithms.Lean.CDCL.solveCompact_sat, Cslib.Algorithms.Lean.CDCL.solveCompact_unsat), and so does the DPLL solver Cslib.Algorithms.Lean.DPLL.solve (Cslib.Algorithms.Lean.DPLL.solve_sat, Cslib.Algorithms.Lean.DPLL.solve_unsat), which replaces it by changing that definition alone. A replacement that breaks the contract still cannot prove a goal that is not a tautology, since the kernel checks every certificate; the tactic then fails, or shows a wrong assignment.

Main definitions #

Limitations #

lrat_tauto closes a goal built from ∧, ∨, →, ¬, ↔, True and False over arbitrary propositions, from an LRAT certificate that refutes the numbered Plaisted–Greenbaum transformation of the negated goal. The certificate is generated by the CDCL solver at elaboration time, or supplied as lrat_tauto using cert with cert : Array LRAT.IntAction; when the goal does not follow propositionally from the hypotheses, the error shows an assignment to the atoms, read as independent propositions, under which it is false and they are true. The kernel checks the certificate by evaluating Cslib.Logic.PL.CNF.checkLRATKernel. Leading binders over non-propositions, such as ∀ p q : Prop, are introduced first. a ≠ b is read as ¬a = b. The atoms are the maximal subterms that are not connectives, compared at reducible transparency, and an equation b = a is the same atom as a = b.

Without using, the propositional hypotheses of the context are premises, then the terms of lrat_tauto [t₁, …, tₙ], proofs of propositions that must elaborate without metavariables, with the equations and HEqs that rfl proves at instance transparency; the premises that the certificate does not need are dropped before the kernel check. lrat_tauto -hyps does not use the hypotheses.

A supplied certificate refutes the formula of the goal with the terms alone as premises. It is a closed term the kernel can evaluate: a literal, or a definition whose body it can unfold. A certificate the checker rejects is reported as such.

lrat_tauto? [t₁, …, tₙ] prints the formula a supplied certificate must refute, in DIMACS form.

lrat_tauto? prints the formula that a certificate for lrat_tauto using must refute: the numbered Plaisted–Greenbaum transformation of the negated goal in DIMACS form, preceded by comment lines naming the variable of each atom. lrat_tauto? [t₁, …, tₙ] prints the formula of t₁ → ⋯ → tₙ → G for the goal G, which lrat_tauto [t₁, …, tₙ] using takes. It leaves the goal unchanged.