Documentation

CslibFrontier.Computability.Complexity.FineGrained.ContractionPartitionFunction

Weighted #CSP by tensor contraction #

For every fixed arity bound k and weight bound W, one native machine computes the partition function F.partitionFunction wt of every weighted Boolean CSP instance F : CSP Rel ℕ whose constraints have between one and k variables, in time 2 ^ (A (N + 1) / √⌊log₂ (n + 2)⌋) times a polynomial in the encoding length, and in polynomial space, where N is the number of variable occurrences and n the number of variables (ContractionPartitionFunction.exists_partitionFunctionCounter). The weights wt R w at patterns of length at most k must be at most W and polynomial-time in the relation symbol R; both hold over a finite relation alphabet (ContractionPartitionFunction.exists_partitionFunctionCounter_of_finite).

On instances in which every variable occurs at most Δ times, N ≤ Δ n, so the time is 2 ^ O_{k,W,Δ}(n / √log n) times a polynomial (ContractionPartitionFunction.exists_partitionFunctionCounter_boundedDegree). Weighted counting problems on bounded-degree graphs, such as independent sets and the hard-core model (ContractionPartitionFunction.exists_hardCoreCounter), or perfect matchings with one Boolean variable per edge, are such instances.

The machine is that of ContractionCounting.exists_modelCounter with weighted tables: it writes out the constraint network of the instance (Cslib.Circuits.Frontier.ClauseNetwork.cspNetwork), whose contraction is the partition function, and contracts it modulo 2 ^ ((W + 1) 3 N), which exceeds the partition function, with the contraction algorithm of Theorem D.1 of [OAI26k] (CountingSimulation.fastContractionAlgorithm). The network has s = 3 N edges, at most 3 N vertices and degree at most max k 4, so it is admissible at size s. The empty instance is answered directly.

Constraints with an empty scope are excluded: arbitrarily many of them would break the bound on the number of vertices that admissibility requires. The rate is that of Theorem D.1; no claim of novelty is made for the application.

Main results #

References #

The instances handed to the contraction algorithm: nonempty, with every constraint of between one and k variables.

The precision of the contraction, (W + 1) 3 N for N variable occurrences.

The input of the contraction algorithm: the precision and the constraint network.

The answer off the guard: one for the empty instance, zero otherwise.

def Cslib.Complexity.ContractionPartitionFunction.count {Rel : Type} (k W : ℕ) (wt : Rel → List Bool → ℕ) (F : Logic.PL.CSP Rel ℕ) :

The value computed by the machine.

The machine: the guard, then the contraction algorithm on the constraint network or the direct answer.

Correctness #

theorem Cslib.Complexity.ContractionPartitionFunction.count_eq {Rel : Type} {k W : ℕ} {wt : Rel → List Bool → ℕ} (hW : ∀ (R : Rel) (w : List Bool), w.length ≤ k → wt R w ≤ W) {F : Logic.PL.CSP Rel ℕ} (hk : ∀ c ∈ F, 1 ≤ c.scope.length ∧ c.scope.length ≤ k) :

The machine computes the partition function of every instance whose constraints have between one and k variables, when the weights at patterns of length at most k are at most W.

Resources #

Admissibility: the constraint network of a guarded instance with N variable occurrences is admissible at size 3 N, its number of edges, with constant k + 4.

theorem Cslib.Complexity.ContractionPartitionFunction.exists_partitionFunctionCounter {Rel : Type} (encRel : Rel ↪ List Bool) (k W : ℕ) (wt : Rel → List Bool → ℕ) (hwt : ∀ (w : List Bool), w.length ≤ k → Turing.MultiTapeTM.ComputableInPolyTime (fun (R : Rel) => wt R w) encRel Turing.MultiTapeTM.encNat) (hW : ∀ (R : Rel) (w : List Bool), w.length ≤ k → wt R w ≤ W) :
∃ (count : Logic.PL.CSP Rel ℕ → ℕ) (A : ℕ) (e : ℕ) (b : ℕ), (∀ (F : Logic.PL.CSP Rel ℕ), (∀ c ∈ F, 1 ≤ c.scope.length ∧ c.scope.length ≤ k) → count F = Logic.PL.CSP.partitionFunction wt F) ∧ Turing.MultiTapeTM.ComputableInO count (encCSP encRel Turing.MultiTapeTM.encNat) Turing.MultiTapeTM.encNat (fun (F : Logic.PL.CSP Rel ℕ) => 2 ^ (A * (F.vars.length + 1) / (Nat.log 2 (F.numVars + 2)).sqrt) * (((encCSP encRel Turing.MultiTapeTM.encNat) F).length + 1) ^ e) fun (F : Logic.PL.CSP Rel ℕ) => (((encCSP encRel Turing.MultiTapeTM.encNat) F).length + 1) ^ b

Weighted #CSP by tensor contraction. For each arity bound k and weight bound W, one machine computes F.partitionFunction wt on every instance F whose constraints have between one and k variables, in time 2 ^ (A (N + 1) / √⌊log₂ (n + 2)⌋) times a polynomial in the encoding length and in polynomial space, where N is the number of variable occurrences and n the number of variables. The weights at patterns of length at most k are at most W and polynomial-time in the relation symbol.

theorem Cslib.Complexity.ContractionPartitionFunction.exists_partitionFunctionCounter_boundedDegree {Rel : Type} (encRel : Rel ↪ List Bool) (k W : ℕ) (wt : Rel → List Bool → ℕ) (hwt : ∀ (w : List Bool), w.length ≤ k → Turing.MultiTapeTM.ComputableInPolyTime (fun (R : Rel) => wt R w) encRel Turing.MultiTapeTM.encNat) (hW : ∀ (R : Rel) (w : List Bool), w.length ≤ k → wt R w ≤ W) :
∃ (count : Logic.PL.CSP Rel ℕ → ℕ) (T : Logic.PL.CSP Rel ℕ → ℕ) (S : Logic.PL.CSP Rel ℕ → ℕ) (e : ℕ) (b : ℕ), (∀ (F : Logic.PL.CSP Rel ℕ), (∀ c ∈ F, 1 ≤ c.scope.length ∧ c.scope.length ≤ k) → count F = Logic.PL.CSP.partitionFunction wt F) ∧ Turing.MultiTapeTM.ComputableInO count (encCSP encRel Turing.MultiTapeTM.encNat) Turing.MultiTapeTM.encNat T S ∧ (∀ (F : Logic.PL.CSP Rel ℕ), S F = (((encCSP encRel Turing.MultiTapeTM.encNat) F).length + 1) ^ b) ∧ ∀ (Δ : ℕ), ∃ (A : ℕ), ∀ (F : Logic.PL.CSP Rel ℕ), (∀ (v : ℕ), List.count v F.vars ≤ Δ) → T F ≤ 2 ^ (A * (F.numVars + 1) / (Nat.log 2 (F.numVars + 2)).sqrt) * (((encCSP encRel Turing.MultiTapeTM.encNat) F).length + 1) ^ e

Weighted #CSP on bounded-degree instances. For each arity bound k and weight bound W, one machine computes F.partitionFunction wt on every instance F whose constraints have between one and k variables, in polynomial space, and for each occurrence bound Δ its time on instances in which every variable occurs at most Δ times is 2 ^ (A (n + 1) / √⌊log₂ (n + 2)⌋) times a polynomial in the encoding length, for n variables. The machine, its time and space functions and the degree e of the polynomial are fixed before Δ; only A depends on Δ.

theorem Cslib.Complexity.ContractionPartitionFunction.exists_partitionFunctionCounter_of_finite {Rel : Type} [Finite Rel] (encRel : Rel ↪ List Bool) (k : ℕ) (wt : Rel → List Bool → ℕ) :
∃ (count : Logic.PL.CSP Rel ℕ → ℕ) (T : Logic.PL.CSP Rel ℕ → ℕ) (S : Logic.PL.CSP Rel ℕ → ℕ) (e : ℕ) (b : ℕ), (∀ (F : Logic.PL.CSP Rel ℕ), (∀ c ∈ F, 1 ≤ c.scope.length ∧ c.scope.length ≤ k) → count F = Logic.PL.CSP.partitionFunction wt F) ∧ Turing.MultiTapeTM.ComputableInO count (encCSP encRel Turing.MultiTapeTM.encNat) Turing.MultiTapeTM.encNat T S ∧ (∀ (F : Logic.PL.CSP Rel ℕ), S F = (((encCSP encRel Turing.MultiTapeTM.encNat) F).length + 1) ^ b) ∧ ∀ (Δ : ℕ), ∃ (A : ℕ), ∀ (F : Logic.PL.CSP Rel ℕ), (∀ (v : ℕ), List.count v F.vars ≤ Δ) → T F ≤ 2 ^ (A * (F.numVars + 1) / (Nat.log 2 (F.numVars + 2)).sqrt) * (((encCSP encRel Turing.MultiTapeTM.encNat) F).length + 1) ^ e

Weighted #CSP by tensor contraction over a finite relation alphabet: the weights at patterns of length at most k are then bounded and polynomial-time in the relation symbol.

theorem Cslib.Complexity.ContractionPartitionFunction.exists_hardCoreCounter (t : ℕ) :
∃ (count : Logic.PL.CSP Bool ℕ → ℕ) (T : Logic.PL.CSP Bool ℕ → ℕ) (S : Logic.PL.CSP Bool ℕ → ℕ) (e : ℕ) (b : ℕ), (∀ (n : ℕ) (E : List (ℕ × ℕ)), (∀ x ∈ E, x.1 < n ∧ x.2 < n) → count (Logic.PL.CSP.hardCore n E) = ∑ I ∈ (Finset.range n).powerset with ∀ x ∈ E, ¬(x.1 ∈ I ∧ x.2 ∈ I), t ^ I.card) ∧ Turing.MultiTapeTM.ComputableInO count (encCSP Turing.MultiTapeTM.encBool Turing.MultiTapeTM.encNat) Turing.MultiTapeTM.encNat T S ∧ (∀ (F : Logic.PL.CSP Bool ℕ), S F = (((encCSP Turing.MultiTapeTM.encBool Turing.MultiTapeTM.encNat) F).length + 1) ^ b) ∧ ∀ (Δ : ℕ), ∃ (A : ℕ), ∀ (n : ℕ) (E : List (ℕ × ℕ)), (∀ x ∈ E, x.1 < n ∧ x.2 < n) → (∀ (v : ℕ), List.count v (List.flatMap (fun (x : ℕ × ℕ) => [x.1, x.2]) E) ≤ Δ) → T (Logic.PL.CSP.hardCore n E) ≤ 2 ^ (A * (n + 1) / (Nat.log 2 (n + 2)).sqrt) * (((encCSP Turing.MultiTapeTM.encBool Turing.MultiTapeTM.encNat) (Logic.PL.CSP.hardCore n E)).length + 1) ^ e

Independent sets of bounded-degree graphs. For each fugacity t, one machine computes, on the encoded hard-core instance CSP.hardCore n E of a graph on the vertices 0, …, n - 1 with edge list E, the sum of t ^ |I| over the independent sets I of the graph (for t = 1, their number), in polynomial space, and for each degree bound Δ in time 2 ^ (A (n + 1) / √⌊log₂ (n + 2)⌋) times a polynomial in the encoding length on graphs whose vertices have at most Δ incident edges.