Bridge to Std.Sat.CNF #
This module connects cslib's list-based conjunctive normal form (Cslib.Logic.PL.CNF) to Lean's
array-backed Std.Sat.CNF, Std.Sat.CNF.relabelFin, Std.Sat.CNF.dimacs, and finite-variable
Std.Sat.CNF (Fin n) formulas.
Because Std.Sat.CNF.Clause wraps its literal list cleanly via ofLiterals and literals, the
clause and formula conversions toStdSat and ofStdSat form exact bijections preserving
evaluation, satisfiability, unsatisfiability, variable occurrences, relabeling, and finite model
counts (CNF.modelCountOn and CNF.modelCount).
Main definitions #
Cslib.Logic.PL.Clause.toStdSat,Cslib.Logic.PL.Clause.ofStdSat,Cslib.Logic.PL.Clause.equivStdSat: bijection between list clauses andStd.Sat.CNF.Clause.Cslib.Logic.PL.CNF.toStdSat,Cslib.Logic.PL.CNF.ofStdSat,Cslib.Logic.PL.CNF.equivStdSat: exact equivalence betweenCNFformulas andStd.Sat.CNF.
Main results #
Cslib.Logic.PL.CNF.eval_toStdSat,Cslib.Logic.PL.CNF.eval_ofStdSat: evaluation agreement.Cslib.Logic.PL.CNF.unsat_toStdSat_iff,Cslib.Logic.PL.CNF.satisfiable_ofStdSat_iff: satisfiability and unsatisfiability correspondence, includingStd.Sat.CNF.relabelFin.Cslib.Logic.PL.CNF.relabel_toStdSat,Cslib.Logic.PL.CNF.relabel_ofStdSat: compatibility with variable relabeling.Cslib.Logic.PL.CNF.modelCountOn_ofStdSat_univ,Cslib.Logic.PL.CNF.card_sat_eq_two_pow_mul_modelCount: model-count correspondence forStd.Sat.CNF (Fin n)with both declared-universe counting (Finset.univ,Finset.range n) and occurring-variable counting (CNF.modelCount).
Conversions between list clauses/formulas and Std.Sat.CNF #
Convert a list clause to a Std.Sat.CNF.Clause.
Convert a Std.Sat.CNF.Clause to a list clause by extracting its literals.
List clauses and Std.Sat.CNF.Clause are in exact bijection.
Convert a list-based CNF formula to a Std.Sat.CNF.
Convert a Std.Sat.CNF formula to a list-based CNF.
List CNF formulas and Std.Sat.CNF are in exact bijection.
Evaluation, satisfiability, and variable occurrences #
Evaluation of Clause.toStdSat agrees with Clause.eval.
Evaluation of Clause.ofStdSat agrees with Std.Sat.CNF.Clause.eval.
A Clause is satisfied in Std.Sat.CNF iff it evaluates to true.
Evaluation of CNF.toStdSat agrees with CNF.eval.
Evaluation of CNF.ofStdSat agrees with Std.Sat.CNF.eval.
CNF.toStdSat is Std.Sat.CNF.Sat iff CNF.eval is true.
CNF.Satisfiable holds iff φ.toStdSat has a satisfying assignment.
CNF.toStdSat is Std.Sat.CNF.Unsat iff ¬ φ.Satisfiable.
A Std.Sat.CNF is unsatisfiable iff its ofStdSat conversion is not satisfiable.
A Std.Sat.CNF is not Unsat iff ofStdSat f is satisfiable.
A Std.Sat.CNF has a Sat assignment iff ofStdSat f is satisfiable.
Variable membership in Clause.toStdSat matches Clause literal membership.
Variable membership in CNF.toStdSat matches CNF.mem_vars.
Clause.toStdSat commutes with variable relabeling.
Clause.ofStdSat commutes with variable relabeling.
CNF.toStdSat commutes with variable relabeling.
CNF.ofStdSat commutes with variable relabeling.
Std.Sat.CNF.relabelFin preserves satisfiability under CNF.ofStdSat.
Every variable occurring in CNF.ofStdSat f is strictly below f.numLiterals.
Every variable occurring in CNF.ofStdSat (f.relabel Fin.val) for f : Std.Sat.CNF (Fin n) is
strictly below n.
For f : Std.Sat.CNF (Fin n), CNF.modelCountOn Finset.univ of CNF.ofStdSat f equals the
number of assignments a : Fin n → Bool with f.eval a = true.
For f : Std.Sat.CNF (Fin n), the cardinality of {a : Fin n → Bool // f.eval a = true}
equals (CNF.ofStdSat f).modelCountOn Finset.univ.
Embedding Fin n into ℕ via Fin.val equates Std.Sat.CNF (Fin n) model counting with
CNF.modelCountOn (Finset.range n).
Express the exact Std.Sat.CNF (Fin n) model count using the occurring-variable
CNF.modelCount of CNF.ofStdSat f.
Classical Std.Sat.CNF.Sat version of CNF.card_eval_eq_two_pow_mul_modelCount.
A Std.Sat.CNF (Fin n) formula has a positive number of models iff it is satisfiable.
For f : Std.Sat.CNF ℕ, declared-universe model counting on Finset.range f.numLiterals
agrees with occurring-variable CNF.modelCount.
Every Clause converts to a Std.Sat.CNF.Clause of the same length.
Every Std.Sat.CNF.Clause converts to a list clause of the same length.
Every CNF converts to a Std.Sat.CNF with the same number of clauses.
Every Std.Sat.CNF converts to a CNF with the same number of clauses.