Documentation

CslibFrontier.Logics.Propositional.CSP.PrimalGraph

Primal graphs of constraint satisfaction problems and nice-tree DP invariants #

For a constraint satisfaction problem F : CSP Rel V, the primal graph CSP.primalGraph F places an edge between distinct variables that appear together in the scope of some constraint of F. Every constraint scope is therefore a clique of CSP.primalGraph F, so every constraint scope is covered by some bag of any RootedTreeDecomposition or NiceTreeDecomposition of CSP.primalGraph F (and likewise for CSP.activePrimalGraph F on F.vars.toFinset, which remains finite even when V is infinite).

Over any valid SimpleGraph.NiceTree V covering all constraint scopes of F, we define the exact partial-assignment count CSP.subtreeSatCount and recursive dynamic-programming specification CSP.specDPCount / CSP.specDPDecide, proving the leaf, introduce, forget, and join recurrences and the root identity CSP.specDPCount = F.modelCount sem.

Main definitions #

Main results #

def Cslib.Logic.PL.CSP.primalGraph {Rel : Type u_1} {V : Type u_2} (F : CSP Rel V) :

The primal graph of F: distinct variables sharing a constraint scope are adjacent.

theorem Cslib.Logic.PL.CSP.primalGraph_adj {Rel : Type u_1} {V : Type u_2} {F : CSP Rel V} {u v : V} :
F.primalGraph.Adj u v ↔ u ≠ v ∧ ∃ c ∈ F, u ∈ c.scope ∧ v ∈ c.scope
@[instance_reducible]
theorem Cslib.Logic.PL.CSP.isClique_scope_of_mem {Rel : Type u_1} {V : Type u_2} [DecidableEq V] (F : CSP Rel V) {c : Constraint Rel V} (hc : c ∈ F) :

The scope of every constraint of F forms a clique in F.primalGraph.

Every constraint scope of F lies in some bag of any nice tree decomposition of F.primalGraph.

theorem Cslib.Logic.PL.CSP.exists_bag_subset_scope_of_mem {Rel : Type u_1} {V : Type u_2} [DecidableEq V] {F : CSP Rel V} {n : ℕ} (R : F.primalGraph.RootedTreeDecomposition n) {c : Constraint Rel V} (hc : c ∈ F) :
∃ (i : Fin (n + 1)), c.scope.toFinset ⊆ R.bag i

Every constraint scope of F lies in some bag of any rooted tree decomposition of F.primalGraph.

def Cslib.Logic.PL.CSP.activePrimalGraph {Rel : Type u_1} {V : Type u_2} [DecidableEq V] (F : CSP Rel V) :

The primal graph induced on the active variables F.vars.toFinset.

@[instance_reducible]
theorem Cslib.Logic.PL.CSP.mem_vars_finset_of_mem {Rel : Type u_1} {V : Type u_2} [DecidableEq V] {F : CSP Rel V} {c : Constraint Rel V} (hc : c ∈ F) {v : V} (hv : v ∈ c.scope) :

Lift a nice tree decomposition of F.activePrimalGraph into NiceTree V preserving validity, empty root bag, width, size, and constraint-scope coverage.

Exact subtree counting and DP recurrences #

noncomputable def Cslib.Logic.PL.CSP.subtreeSatSet {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Finite D] (sem : Rel → List D → Bool) (F : CSP Rel V) (U S B : Finset V) (α : V → D) :
Finset (↥(S ∩ U) → D)

Finite set of partial assignments on S ∩ U agreeing with α on B and satisfying every constraint of F whose scope lies inside S.

noncomputable def Cslib.Logic.PL.CSP.subtreeSatCount {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Finite D] (sem : Rel → List D → Bool) (F : CSP Rel V) (U S B : Finset V) (α : V → D) :

Number of satisfying partial extensions of α on S ∩ U.

theorem Cslib.Logic.PL.CSP.subtreeSatCount_congr {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Finite D] (sem : Rel → List D → Bool) {F : CSP Rel V} {U S B : Finset V} (hU : F.vars.toFinset ⊆ U) {α β : V → D} (h : ∀ v ∈ B ∩ U, α v = β v) :
subtreeSatCount sem F U S B α = subtreeSatCount sem F U S B β
theorem Cslib.Logic.PL.CSP.subtreeSatCount_empty_eq_modelCountOn {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Fintype D] [Inhabited D] (sem : Rel → List D → Bool) {F : CSP Rel V} {U S : Finset V} (hU : F.vars.toFinset ⊆ U) (hF : ∀ c ∈ F, c.scope.toFinset ⊆ S) (α : V → D) :
subtreeSatCount sem F U S ∅ α = modelCountOn sem F (S ∩ U)
theorem Cslib.Logic.PL.CSP.subtreeSatCount_root_eq_modelCount {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Fintype D] [Inhabited D] (sem : Rel → List D → Bool) {F : CSP Rel V} {S : Finset V} (hS : F.vars.toFinset ⊆ S) (α : V → D) :
theorem Cslib.Logic.PL.CSP.subtreeSatCount_leaf {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Finite D] [Inhabited D] (sem : Rel → List D → Bool) (F : CSP Rel V) (U : Finset V) (α : V → D) :
subtreeSatCount sem F U ∅ ∅ α = if ∀ c ∈ F, c.scope = [] → Constraint.eval sem (fun (x : V) => default) c = true then 1 else 0
theorem Cslib.Logic.PL.CSP.subtreeSatCount_introduce {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Finite D] (sem : Rel → List D → Bool) {F : CSP Rel V} {U S B : Finset V} {v : V} (hvS : v ∉ S) (hBS : B ⊆ S) (hU : F.vars.toFinset ⊆ U) (hcov : ∀ c ∈ F, c.scope.toFinset ⊆ insert v S → c.scope.toFinset ⊆ S ∨ c.scope.toFinset ⊆ insert v B) (α : V → D) :
subtreeSatCount sem F U (insert v S) (insert v B) α = if ∀ c ∈ F, c.scope.toFinset ⊆ insert v B → v ∈ c.scope → Constraint.eval sem α c = true then subtreeSatCount sem F U S B α else 0
theorem Cslib.Logic.PL.CSP.subtreeSatCount_forget {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Fintype D] [Inhabited D] (sem : Rel → List D → Bool) {F : CSP Rel V} {U S B : Finset V} {v : V} (hvB : v ∈ B) (hBS : B ⊆ S) (hU : F.vars.toFinset ⊆ U) (α : V → D) :
subtreeSatCount sem F U S (B.erase v) α = if v ∈ U then ∑ d : D, subtreeSatCount sem F U S B (Function.update α v d) else subtreeSatCount sem F U S B (Function.update α v default)
theorem Cslib.Logic.PL.CSP.subtreeSatCount_join {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Finite D] (sem : Rel → List D → Bool) {F : CSP Rel V} {U S_L S_R B : Finset V} (hdisj : Disjoint (S_L \ B) S_R) (hBLS : B ⊆ S_L) (hU : F.vars.toFinset ⊆ U) (hcov : ∀ c ∈ F, c.scope.toFinset ⊆ S_L ∪ S_R → c.scope.toFinset ⊆ S_L ∨ c.scope.toFinset ⊆ S_R) (α : V → D) :
subtreeSatCount sem F U (S_L ∪ S_R) B α = subtreeSatCount sem F U S_L B α * subtreeSatCount sem F U S_R B α
noncomputable def Cslib.Logic.PL.CSP.specDPCount {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Fintype D] [Inhabited D] (sem : Rel → List D → Bool) (F : CSP Rel V) (U : Finset V) :
SimpleGraph.NiceTree V → (V → D) → ℕ

Nice-tree dynamic programming specification returning the exact number of satisfying partial extensions on T.subtreeVerts ∩ U extending α on T.bag.

noncomputable def Cslib.Logic.PL.CSP.specDPDecide {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Fintype D] [Inhabited D] (sem : Rel → List D → Bool) (F : CSP Rel V) (U : Finset V) :
SimpleGraph.NiceTree V → (V → D) → Bool

Nice-tree dynamic programming specification for satisfiability.

theorem Cslib.Logic.PL.CSP.specDPCount_eq_subtreeSatCount {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Fintype D] [Inhabited D] (sem : Rel → List D → Bool) {F : CSP Rel V} {U : Finset V} (hU : F.vars.toFinset ⊆ U) {T : SimpleGraph.NiceTree V} :
T.LocalValid → (∀ c ∈ F, c.scope.toFinset ⊆ T.subtreeVerts → SimpleGraph.NiceTree.CoversFinset c.scope.toFinset T) → ∀ (α : V → D), specDPCount sem F U T α = subtreeSatCount sem F U T.subtreeVerts T.bag α
theorem Cslib.Logic.PL.CSP.specDPCount_pos_iff_specDPDecide {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Fintype D] [Inhabited D] (sem : Rel → List D → Bool) (F : CSP Rel V) (U : Finset V) (T : SimpleGraph.NiceTree V) (α : V → D) :
0 < specDPCount sem F U T α ↔ specDPDecide sem F U T α = true
theorem Cslib.Logic.PL.CSP.specDPCount_eq_modelCount {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Fintype D] [Inhabited D] (sem : Rel → List D → Bool) {F : CSP Rel V} {T : SimpleGraph.NiceTree V} (hval : T.LocalValid) (hbag : T.bag = ∅) (hsub : F.vars.toFinset ⊆ T.subtreeVerts) (hcov : ∀ c ∈ F, SimpleGraph.NiceTree.CoversFinset c.scope.toFinset T) (α : V → D) :
specDPCount sem F F.vars.toFinset T α = modelCount sem F
theorem Cslib.Logic.PL.CSP.specDPDecide_eq_true_iff_satisfiable {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Fintype D] [Inhabited D] (sem : Rel → List D → Bool) {F : CSP Rel V} {T : SimpleGraph.NiceTree V} (hval : T.LocalValid) (hbag : T.bag = ∅) (hsub : F.vars.toFinset ⊆ T.subtreeVerts) (hcov : ∀ c ∈ F, SimpleGraph.NiceTree.CoversFinset c.scope.toFinset T) (α : V → D) :
theorem Cslib.Logic.PL.CSP.specDPCount_primalGraph_eq_modelCount {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Fintype D] [Inhabited D] (sem : Rel → List D → Bool) {F : CSP Rel V} (N : F.primalGraph.NiceTreeDecomposition) (α : V → D) :
theorem Cslib.Logic.PL.CSP.specDPCount_activePrimalGraph_eq_modelCount {Rel : Type u_1} {V : Type u_2} {D : Type u_3} [DecidableEq V] [Fintype D] [Inhabited D] (sem : Rel → List D → Bool) {F : CSP Rel V} (N : F.activePrimalGraph.NiceTreeDecomposition) (α : V → D) :