SAT and bounded string constraints: reduction correctness
DefinitionEncoding of CNF formulas as string constraints#✓fully proved
SAT as string constraints: each clause is a disjunction of word
equations x = [b], one per literal.
def encodeCNF (φ : CNF) : Formula Bool ℕ :=
andChain (φ.map (fun C =>
orChain (C.map (fun l =>
Formula.atom (Atom.eq (Term.var l.1) (Term.const [l.2]))))))
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
inductive Formula (α : Type*) (V : Type*) where
| atom : Atom α V → Formula α V
| and : Formula α V → Formula α V → Formula α V
| or : Formula α V → Formula α V → Formula α V
| true : Formula α V
| false : Formula α V
CSLibExt/AutomatedReasoning/StringConstraints/Syntax.lean:150
def andChain : List (Formula α V) → Formula α V
| [] => .true
| f :: fs => .and f (andChain fs)
CSLibExt/AutomatedReasoning/StringConstraints/Syntax.lean:158
def orChain : List (Formula α V) → Formula α V
| [] => .false
| f :: fs => .or f (orChain fs)
CSLibExt/AutomatedReasoning/StringConstraints/Syntax.lean:163
inductive Atom (α : Type*) (V : Type*) where
| eq : Term α V → Term α V → Atom α V
| mem : Term α V → EncodedRegex α → Atom α V
| lenLe : Term α V → ℕ → Atom α V
| lenGe : Term α V → ℕ → Atom α V
CSLibExt/AutomatedReasoning/StringConstraints/Syntax.lean:134
inductive Term (α : Type*) (V : Type*) where
| const : List α → Term α V
| var : V → Term α V
| append : Term α V → Term α V → Term α V
| hom : (α → List α) → Term α V → Term α V
CSLibExt/AutomatedReasoning/StringConstraints/Syntax.lean:74
Uses 7 · Used by 2
TheoremCorrectness of the SAT-to-string-constraints translation#✓fully proved
Correctness of the SAT-to-string-constraints translation at
length bound 1: Boolean assignments become length-≤ 1 string
assignments and back.
theorem cnfSat_iff_stringSat (φ : CNF) :
CNFSat φ ↔ ∃ σ : ℕ → List Bool, (∀ i, (σ i).length ≤ 1) ∧
Sat σ (encodeCNF φ)
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
def CNFSat (φ : CNF) : Prop :=
∃ v : Nat → Bool, ∀ C ∈ φ, ∃ (x : Nat) (b : Bool), (x, b) ∈ C ∧ v x = b
CSLibExt/Logics/Propositional/CNF/Basic.lean:36
def Sat (σ : V → List α) : Formula α V → Prop
| .atom a => SatAtom σ a
| .and f g => Sat σ f ∧ Sat σ g
| .or f g => Sat σ f ∨ Sat σ g
| .true => True
| .false => False
CSLibExt/AutomatedReasoning/StringConstraints/Syntax.lean:183
def encodeCNF (φ : CNF) : Formula Bool ℕ :=
andChain (φ.map (fun C =>
orChain (C.map (fun l =>
Formula.atom (Atom.eq (Term.var l.1) (Term.const [l.2]))))))
CSLibExt/AutomatedReasoning/StringConstraints/Complexity.lean:65
Uses 13 · Used by 1
TheoremSAT iff the bounded-search specification holds of the encoding#✓fully proved
SAT iff the bounded-search specification holds of the encoding at
length bound 1, for any variable list covering the variables of the
encoding. This is the bridge from the reduction to the bounded-search
specification: boundedSatSpec_iff (soundness / completeness of the
finite search) plus the reduction correctness.
theorem cnfSat_iff_boundedSatSpec (φ : CNF) (vs : List ℕ)
(hvars : ∀ i ∈ varsOfFormula (encodeCNF φ), i ∈ vs) :
CNFSat φ ↔ boundedSatSpec vs (encodeCNF φ) 1 = true
abbrev CNF := List CNFClause
CSLibExt/Logics/Propositional/CNF/Basic.lean:33
def varsOfFormula : Formula α V → List V
| .atom a => varsOfAtom a
| .and f g => varsOfFormula f ++ varsOfFormula g
| .or f g => varsOfFormula f ++ varsOfFormula g
| .true => []
| .false => []
CSLibExt/AutomatedReasoning/StringConstraints/Syntax.lean:168
def encodeCNF (φ : CNF) : Formula Bool ℕ :=
andChain (φ.map (fun C =>
orChain (C.map (fun l =>
Formula.atom (Atom.eq (Term.var l.1) (Term.const [l.2]))))))
CSLibExt/AutomatedReasoning/StringConstraints/Complexity.lean:65
def CNFSat (φ : CNF) : Prop :=
∃ v : Nat → Bool, ∀ C ∈ φ, ∃ (x : Nat) (b : Bool), (x, b) ∈ C ∧ v x = b
CSLibExt/Logics/Propositional/CNF/Basic.lean:36
noncomputable def boundedSatSpec (vs : List V) (φ : Formula α V) (B : ℕ) : Bool :=
(assignLists vs B).any (fun l => satB (getVal l) φ)
CSLibExt/AutomatedReasoning/StringConstraints/Bounded.lean:414
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.