Documentation

CslibFrontier.Computability.Circuit.Frontier.TensorNetwork.ClauseNetwork

The clause network of a CNF formula #

The explicit Boolean tensor network of the fixed-density case of Theorem 1.1 of [OAI26k] (Appendix D.2): its contraction is the number of satisfying assignments of the formula, it is bipartite with its rows first, and its degree is bounded by the clause width.

Number the literal occurrences of a formula φ with m clauses 0, …, N - 1 in order (Cslib.Logic.PL.occurrences). Occurrence u has three edges, 3 u, 3 u + 1 and 3 u + 2.

So the occurrences of a variable form a chain of equality vertices, subdivided by the link vertices, and every edge joins a row to a column. The links and equality vertices force the three edges of every occurrence to carry the value of its variable, so for any row tables the contraction is the sum, over the assignments of the variables, of the product of the row entries at the words the assignment puts on the rows (ClauseNetwork.contraction_network); the ports of a row carry the literals of its clause in order (ClauseNetwork.map_clausePorts_occurrences). With the clause tables (ClauseNetwork.clauseRow), a row entry is one exactly when the clause has a true literal, so the contraction is the model count (ClauseNetwork.contraction_clauseNetwork). Weighted tables give the constraint network of a weighted CSP (Cslib.Circuits.Frontier.ClauseNetwork.cspNetwork). This is the network of Appendix D.2 with equality chains in place of equality trees: its equality vertices have degree at most four (ClauseNetwork.length_qPorts_le), which is all that Theorem D.1 needs, and the subdivision is built in. It does not merge repeated variables of a clause; their edges are joined by the chain.

The tables are listed from the first 2 ^ B numbers (ExplicitTensorNetwork.boundedTable), for a bound B on the degrees, so that the network is computed from constant-length lists; for the clause network of width k formulas, B = max k 4 (ClauseNetwork.clauseNetwork).

Main definitions #

Main results #

References #

Occurrence data #

Occurrence u: its clause, its position in the clause and its literal, with a default past the end.

The variable of occurrence u.

The polarity of occurrence u.

The previous occurrence of the variable of occurrence u, or u itself if there is none.

The network #

The equality tensor on w ports: one at the all-false and the all-true words.

The clause tensor: zero at the one word z that falsifies every literal, one elsewhere.

The ports of clause i: the edges 3 u of its occurrences u.

The ports of the equality vertex of occurrence w: 3 w, 3 w + 1, and 3 u + 2 for the occurrences u whose previous occurrence is w.

The falsifying word of a clause vertex with the ports ps, as a number.

The row vertex i with the row tables row: its ports are those of clause i, and its entry at a word of value idx is row i idx.

The clause tables: the table of clause i is zero exactly at its falsifying word.

The link vertex of occurrence u.

The equality vertex of occurrence w.

The network of an occurrence list with m row vertices, row tables row and degree bound B, with its number of rows m + N: the row vertices, the link vertices, and then the equality vertices.

The clause network of a formula, for clause width at most k.

The occurrence data #

The occurrence with a given number, as a member of the list.

theorem Cslib.Circuits.Frontier.ClauseNetwork.prev_spec (os : List (Logic.PL.Occurrence ℕ)) (u : ℕ) :
(prev os u < u ∧ var os (prev os u) = var os u ∧ ∀ (w : ℕ), prev os u < w → w < u → var os w ≠ var os u) ∨ prev os u = u ∧ ∀ w < u, var os w ≠ var os u

The previous occurrence. Either prev u < u is an occurrence of the same variable with no occurrence of that variable strictly between, or u is the first occurrence of its variable.

theorem Cslib.Circuits.Frontier.ClauseNetwork.eq_of_prev_eq (os : List (Logic.PL.Occurrence ℕ)) {w u u' : ℕ} (hu : prev os u = w) (hu' : prev os u' = w) (hne : u ≠ w) (hne' : u' ≠ w) :
u = u'

Two occurrences u < u' whose previous occurrence is the same w include w itself.

Tables #

theorem Cslib.Circuits.Frontier.ClauseNetwork.eqEntry_lsbValue (bs : List Bool) :
eqEntry bs.length (BitString.lsbValue bs) = if ∀ a ∈ bs, ∀ b ∈ bs, a = b then 1 else 0

The equality tensor at a word: one exactly when all its bits are equal.

The clause tensor at a word of the length of its falsifying word: zero exactly at that word.

Ports #

theorem Cslib.Circuits.Frontier.ClauseNetwork.mem_qPorts {os : List (Logic.PL.Occurrence ℕ)} {w j : ℕ} :
j ∈ qPorts os w ↔ j = 3 * w ∨ j = 3 * w + 1 ∨ ∃ u < os.length, prev os u = w ∧ 3 * u + 2 = j

The number of ports of clause i is its number of occurrences.

The ports of a clause carry its literals in order: reading the literal of the occurrence of each port of clause i gives back the clause.

An equality vertex has at most four ports.

The network: sizes and bipartition #

@[simp]
theorem Cslib.Circuits.Frontier.ClauseNetwork.fst_network (os : List (Logic.PL.Occurrence ℕ)) (row : ℕ → ℕ → ℕ) (B m : ℕ) :
(network os B m row).1 = m + os.length
@[simp]
theorem Cslib.Circuits.Frontier.ClauseNetwork.isRowsFirstBipartite_network (os : List (Logic.PL.Occurrence ℕ)) (row : ℕ → ℕ → ℕ) (B m : ℕ) (hcl : ∀ o ∈ os, o.clause < m) :

The network is rows-first bipartite when every occurrence names one of the m clauses.

Degrees #

The degree bound: if every clause has at most B occurrences, every vertex has at most max B 4 ports.

theorem Cslib.Circuits.Frontier.ClauseNetwork.length_table_network (os : List (Logic.PL.Occurrence ℕ)) (row : ℕ → ℕ → ℕ) (B m : ℕ) (hB : ∀ (i : ℕ), List.count i (List.map Logic.PL.Occurrence.clause os) ≤ B) (v : List ℕ × List ℕ) :
v ∈ (network os (max B 4) m row).2.vertices → v.2.length = 2 ^ v.1.length

Full tables: under the degree bound, every table lists 2 ^ (number of ports) values.

The contraction #

theorem Cslib.Circuits.Frontier.ClauseNetwork.contraction_network (os : List (Logic.PL.Occurrence ℕ)) (B m : ℕ) (row : ℕ → ℕ → ℕ) (hB : ∀ (i : ℕ), List.count i (List.map Logic.PL.Occurrence.clause os) ≤ B) {S : Finset ℕ} (hS : (List.map (fun (o : Logic.PL.Occurrence ℕ) => o.lit.1) os).toFinset = S) :
(network os (max B 4) m row).2.contraction = ∑ τ : ↥S → Bool, (List.map (fun (i : ℕ) => row i (BitString.lsbValue (List.map (fun (j : ℕ) => if h : var os (j / 3) ∈ S then τ ⟨var os (j / 3), h⟩ else false) (clausePorts os i)))) (List.range m)).prod

The contraction of a network is its weighted sum over assignments. For the set S of the variables of the occurrences, the contraction is the sum, over the assignments τ of S, of the product of the row entries at the values of the words that τ puts on the ports of the rows.

The contraction of the clause network #

The contraction of the clause network is the model count, for formulas whose clauses have at most k literals.

The degree bound: for clauses of at most k literals, every vertex has at most max k 4 ports.

Full tables, for clauses of at most k literals.

The clause network has three edges per literal occurrence.

The clause network has one vertex per clause and two per literal occurrence.