Documentation

CslibFrontier.Logics.Propositional.CNF.StdSat

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 #

Main results #

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.

@[simp]
theorem Cslib.Logic.PL.Clause.mem_toStdSat {α : Type u_1} {c : Clause α} {l : Literal α} :
@[simp]
def Cslib.Logic.PL.CNF.toStdSat {α : Type u_1} (φ : CNF α) :

Convert a list-based CNF formula to a Std.Sat.CNF.

def Cslib.Logic.PL.CNF.ofStdSat {α : Type u_1} (f : Std.Sat.CNF α) :
CNF α

Convert a Std.Sat.CNF formula to a list-based CNF.

@[simp]
theorem Cslib.Logic.PL.CNF.ofStdSat_toStdSat {α : Type u_1} (φ : CNF α) :

List CNF formulas and Std.Sat.CNF are in exact bijection.

@[simp]
@[simp]
@[simp]
theorem Cslib.Logic.PL.CNF.mem_ofStdSat {α : Type u_1} {f : Std.Sat.CNF α} {c : Clause α} :

Evaluation, satisfiability, and variable occurrences #

@[simp]
theorem Cslib.Logic.PL.Clause.eval_toStdSat {α : Type u_1} (σ : α → Bool) (c : Clause α) :

Evaluation of Clause.toStdSat agrees with Clause.eval.

@[simp]

Evaluation of Clause.ofStdSat agrees with Std.Sat.CNF.Clause.eval.

A Clause is satisfied in Std.Sat.CNF iff it evaluates to true.

@[simp]
theorem Cslib.Logic.PL.CNF.eval_toStdSat {α : Type u_1} (σ : α → Bool) (φ : CNF α) :

Evaluation of CNF.toStdSat agrees with CNF.eval.

@[simp]
theorem Cslib.Logic.PL.CNF.eval_ofStdSat {α : Type u_1} (σ : α → Bool) (f : Std.Sat.CNF α) :

Evaluation of CNF.ofStdSat agrees with Std.Sat.CNF.eval.

theorem Cslib.Logic.PL.CNF.sat_toStdSat_iff {α : Type u_1} (σ : α → Bool) (φ : CNF α) :

CNF.toStdSat is Std.Sat.CNF.Sat iff CNF.eval is true.

CNF.Satisfiable holds iff φ.toStdSat has a satisfying assignment.

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.

theorem Cslib.Logic.PL.Clause.varMem_toStdSat_iff {α : Type u_1} (c : Clause α) (v : α) :

Variable membership in Clause.toStdSat matches Clause literal membership.

theorem Cslib.Logic.PL.CNF.varMem_toStdSat_iff {α : Type u_1} (φ : CNF α) (v : α) :

Variable membership in CNF.toStdSat matches CNF.mem_vars.

Relabeling, relabelFin, and finite Fin n model counting #

@[simp]
theorem Cslib.Logic.PL.Clause.relabel_toStdSat {α : Type u_1} {β : Type u_2} (r : α → β) (c : Clause α) :

Clause.toStdSat commutes with variable relabeling.

@[simp]
theorem Cslib.Logic.PL.Clause.relabel_ofStdSat {α : Type u_1} {β : Type u_2} (r : α → β) (c : Std.Sat.CNF.Clause α) :

Clause.ofStdSat commutes with variable relabeling.

@[simp]
theorem Cslib.Logic.PL.CNF.relabel_toStdSat {α : Type u_1} {β : Type u_2} (r : α → β) (φ : CNF α) :

CNF.toStdSat commutes with variable relabeling.

@[simp]
theorem Cslib.Logic.PL.CNF.relabel_ofStdSat {α : Type u_1} {β : Type u_2} (r : α → β) (f : Std.Sat.CNF α) :

CNF.ofStdSat commutes with variable relabeling.

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.

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.

@[simp]

Every Clause converts to a Std.Sat.CNF.Clause of the same length.

@[simp]

Every Std.Sat.CNF.Clause converts to a list clause of the same length.

@[simp]

Every CNF converts to a Std.Sat.CNF with the same number of clauses.

@[simp]

Every Std.Sat.CNF converts to a CNF with the same number of clauses.