Documentation

CslibFrontier.Computability.Complexity.FineGrained.ContractionMatching

Permanents and perfect matchings of bounded degree by tensor contraction #

For each d, one machine computes the permanent of an n × n 0/1 matrix with at most d nonzero entries in each row and each column (ContractionMatching.exists_permanentCounter), and one machine computes the number of perfect matchings of a graph on n vertices of maximum degree d (ContractionMatching.exists_perfectMatchingCounter). Both run, on every input, in time 2 ^ (A (n + 1) / √⌊log₂ (n + 2)⌋) times a polynomial in the encoding length, and in polynomial space, with constants depending only on d. The inputs are standard encodings: a matrix is a list of rows (encList encBits, read by Cslib.Complexity.boolTableMatrix), and a graph is a vertex and edge list (Cslib.Complexity.encGraph, read as Cslib.Complexity.Graph.induced).

Both problems are Holant problems: one Boolean variable per edge of a graph, and one exactly-one constraint per vertex on its incident edges. A polynomial-time reduction builds this instance: Cslib.Logic.PL.CSP.permanentInstance for matrices, and Cslib.Complexity.Graph.perfectMatchingInstance for graphs, whose certificate Cslib.Complexity.Graph.computableInPolyTime_perfectMatchingInstance sits beside the graph API. In the instance every variable occurs twice, and every scope has at most d variables. Its exactly-one partition function is the permanent (Cslib.Logic.PL.CSP.partitionFunction_permanentInstance) or the number of perfect matchings (Cslib.Complexity.Graph.partitionFunction_perfectMatchingInstance). The counter of ContractionPartitionFunction.exists_partitionFunctionCounter_of_finite, which applies Theorem D.1 of [OAI26k], then computes it. That counter excludes empty scopes, so an instance with an empty or overlong scope is first replaced by ContractionMatching.zeroInstance (ContractionMatching.guarded). Under the degree promise this happens only when a vertex has no edge, and then the count is zero. The time bound transfers from the instance's variables to n by Nat.mul_succ_div_sqrt_log_two_le, and through the reduction by Turing.MultiTapeTM.ComputableInO.comp_polyTime.

Source relation #

No novelty is claimed. Corollary 1.3 of [OAI26k] (p. 2, proved on p. 3) counts perfect matchings in time 2 ^ o(v + e) through a circuit-to-3-CNF encoding with O(v + e) variables and clauses, and the fixed-density case of its Theorem 1.1 (p. 2, proved in Appendix D.2, p. 54) gives the rate 2 ^ O(n / √log n) for such formulas. At maximum degree d this is the rate here. The bounded-degree permanent is also Theorem 6.1 of [OD26] (p. 13), with the weaker exponent n (log log n) ^ 2 / √log n and by a different route. The formalization uses the Holant encoding with exactly-one tables instead of the 3-CNF encoding.

Main definitions #

Main results #

References #

Exactly-one instances in which every variable occurs at most twice #

The instance answered in place of an instance with an empty or overlong scope: one exactly-one constraint on a repeated variable, whose partition function is zero.

The instance handed to the counter: F itself when each of its constraints has between one and d variables, and zeroInstance otherwise.

Guarding preserves the partition function of an instance whose constraints have at most d variables: if one of them has none, both partition functions are zero.

theorem Cslib.Complexity.ContractionMatching.exists_exactlyOneCounter {α : Type} {enc : α ↪ List Bool} (d C : ℕ) {inst : α → Logic.PL.CSP Unit ℕ} {size : α → ℕ} (hinst : Turing.MultiTapeTM.ComputableInPolyTime inst enc (encCSP Turing.MultiTapeTM.encUnit Turing.MultiTapeTM.encNat)) (hocc : ∀ (a : α) (v : ℕ), List.count v (inst a).vars ≤ 2) (hsize : ∀ (a : α), List.length (inst a) ≤ C * size a + C) :
∃ (count : α → ℕ) (A : ℕ) (e : ℕ) (b : ℕ), (∀ (a : α), (∀ c ∈ inst a, c.scope.length ≤ d) → count a = Logic.PL.CSP.partitionFunction Logic.PL.CSP.exactlyOneWeight (inst a)) ∧ Turing.MultiTapeTM.ComputableInO count enc Turing.MultiTapeTM.encNat (fun (a : α) => 2 ^ (A * (size a + 1) / (Nat.log 2 (size a + 2)).sqrt) * ((enc a).length + 1) ^ e) fun (a : α) => ((enc a).length + 1) ^ b

Exactly-one counting on bounded-occurrence instances by tensor contraction. Let inst be a polynomial-time map to exactly-one instances in which every variable occurs at most twice and whose number of constraints is at most C * size a + C. For each d, one machine computes the partition function of inst a whenever its constraints have at most d variables. On every input it runs in time 2 ^ (A (size a + 1) / √⌊log₂ (size a + 2)⌋) times a polynomial in the encoding length, and in polynomial space. The machine first replaces an instance with an empty or overlong scope by zeroInstance (guarded), then runs the counter of ContractionPartitionFunction.exists_partitionFunctionCounter_of_finite.

Permanents #

Entry (i, j) of the matrix with rows rows: entry j of row i, or false when it is missing.

The shared 0/1 matrix of a list of rows, read through rowEntry.

theorem Cslib.Complexity.ContractionMatching.exists_permanentCounter (d : ℕ) :
∃ (count : List (List Bool) → ℕ) (A : ℕ) (e : ℕ) (b : ℕ), (∀ (rows : List (List Bool)), (∀ (i : Fin rows.length), {j : Fin rows.length | boolTableMatrix rows i j ≠ 0}.card ≤ d) → (∀ (j : Fin rows.length), {i : Fin rows.length | boolTableMatrix rows i j ≠ 0}.card ≤ d) → count rows = (boolTableMatrix rows).permanent) ∧ Turing.MultiTapeTM.ComputableInO count (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encBits) Turing.MultiTapeTM.encNat (fun (rows : List (List Bool)) => 2 ^ (A * (rows.length + 1) / (Nat.log 2 (rows.length + 2)).sqrt) * (((Turing.MultiTapeTM.encList Turing.MultiTapeTM.encBits) rows).length + 1) ^ e) fun (rows : List (List Bool)) => (((Turing.MultiTapeTM.encList Turing.MultiTapeTM.encBits) rows).length + 1) ^ b

The 0/1 permanent with at most d nonzero entries per row and column in time 2 ^ O(n / √log n). For each d, one machine reads a list of rows rows (encoded by encList encBits) and, when every row and every column of the n × n matrix boolTableMatrix rows has at most d nonzero entries, outputs its permanent. On every input it runs in time 2 ^ (A (n + 1) / √⌊log₂ (n + 2)⌋) times a polynomial in the encoding length, and in polynomial space, for n = rows.length. The constants A, e and b depend only on d.

Perfect matchings #

theorem Cslib.Complexity.ContractionMatching.exists_perfectMatchingCounter (d : ℕ) :
∃ (count : Graph → ℕ) (A : ℕ) (e : ℕ) (b : ℕ), (∀ (G : Graph), (∀ (v : { v : ℕ // v ∈ G.vertices }), Nat.card ↑(G.induced.neighborSet v) ≤ d) → count G = Nat.card { M : G.induced.Subgraph // M.IsPerfectMatching }) ∧ Turing.MultiTapeTM.ComputableInO count encGraph Turing.MultiTapeTM.encNat (fun (G : Graph) => 2 ^ (A * (G.vertices.toFinset.card + 1) / (Nat.log 2 (G.vertices.toFinset.card + 2)).sqrt) * ((encGraph G).length + 1) ^ e) fun (G : Graph) => ((encGraph G).length + 1) ^ b

Perfect matchings of graphs of maximum degree d in time 2 ^ O(n / √log n). For each d, one machine reads a graph G (encoded by encGraph) and, when every vertex of G.induced has at most d neighbours, outputs the number of perfect matchings of G.induced. On every input it runs in time 2 ^ (A (n + 1) / √⌊log₂ (n + 2)⌋) times a polynomial in the encoding length, and in polynomial space, for n distinct declared vertices. The constants A, e and b depend only on d.