Documentation

CslibFrontier.Computability.Circuit.Arithmetic.ClauseSum

Clause sums #

A clause is a list of literals together with a weight; it contributes its weight when all its literals hold and 1 otherwise. A clause sum sums the product of the contributions of a family of clauses over all assignments of the bits (clauseSum). This file adds two variants:

Main definitions #

Main results #

References #

noncomputable def Cslib.Circuits.Arithmetic.clauseSum {R : Type u_2} {V : Type u_3} {Θ : Type u_4} [CommSemiring R] [Fintype V] [DecidableEq V] [Fintype Θ] (lits : Θ → List (V × Bool)) (wt : Θ → R) :
R

A clause sum: the sum, over the bits x, of the product over the clauses κ of the weight of κ if all its literals hold, and 1 otherwise. A literal (b, e) holds when x b = e.

def Cslib.Circuits.Arithmetic.clauseSumWith {R : Type u_1} [CommSemiring R] {ι : Type u_2} {α : Type u_3} {Θ : Type u_4} [Fintype α] [DecidableEq α] [Fintype Θ] (lits : Θ → List ((ι ⊕ α) × Bool)) (wt : Θ → R) (x : ι → Bool) :
R

A clause sum with the bits on ι fixed to x: the sum runs over the bits on α only.

def Cslib.Circuits.Arithmetic.withInputs {ι : Type u_2} {α : Type u_3} {Θ : Type u_4} (lits : Θ → List ((ι ⊕ α) × Bool)) :
Θ ⊕ ι → List ((ι ⊕ α) × Bool)

One more clause for every fixed bit: the literal that the bit is set.

noncomputable def Cslib.Circuits.Arithmetic.inputWeights {R : Type u_1} [CommSemiring R] {ι : Type u_2} {Θ : Type u_4} (wt : Θ → R) :
Θ ⊕ ι → MvPolynomial ι R

The weights: the constants wt, and the variable of every fixed bit.

theorem Cslib.Circuits.Arithmetic.clauseSum_withInputs {R : Type u_1} [CommSemiring R] {ι : Type u_2} {α : Type u_3} {Θ : Type u_4} [Fintype α] [DecidableEq α] [Fintype Θ] [Fintype ι] [DecidableEq ι] (lits : Θ → List ((ι ⊕ α) × Bool)) (wt : Θ → R) :

Fixed bits as variables. With one clause per fixed bit whose weight is its variable, the clause sum over all bits is the monomial extension of the clause sum with fixed bits.

def Cslib.Circuits.Arithmetic.domainClauseSum {R : Type u_1} [CommSemiring R] {ι : Type u_2} {D : Type u_3} {Θ : Type u_4} [Fintype D] [DecidableEq D] {E : D → Type u_5} [(d : D) → Fintype (E d)] [(d : D) → DecidableEq (E d)] [Fintype Θ] (lits : Θ → List ((ι ⊕ (d : D) × E d) × Bool)) (wt : Θ → R) (x : ι → Bool) :
R

A clause sum over the functions g : ∀ d, E d, with the bits on ι fixed to x. A literal (⟨d, e⟩, b) about g says g d = e (for b = true) or g d ≠ e.

noncomputable def Cslib.Circuits.Arithmetic.oneHotLits {ι : Type u_2} {D : Type u_3} {Θ : Type u_4} {E : D → Type u_5} [(d : D) → Fintype (E d)] (lits : Θ → List ((ι ⊕ (d : D) × E d) × Bool)) :
Θ ⊕ D ⊕ ((d : D) × E d) × (d : D) × E d → List ((ι ⊕ (d : D) × E d) × Bool)

The clauses of lits, then one clause per point that no value is taken, then one per pair of bits that both are set.

def Cslib.Circuits.Arithmetic.oneHotWeights {R : Type u_1} [CommSemiring R] {D : Type u_3} {Θ : Type u_4} [DecidableEq D] {E : D → Type u_5} [(d : D) → DecidableEq (E d)] (wt : Θ → R) :
Θ ⊕ D ⊕ ((d : D) × E d) × (d : D) × E d → R

Their weights: those of wt, 0 for a point without a value, and 0 for two values at one point.

theorem Cslib.Circuits.Arithmetic.domainClauseSum_eq_clauseSumWith {R : Type u_1} [CommSemiring R] {ι : Type u_2} {D : Type u_3} {Θ : Type u_4} [Fintype D] [DecidableEq D] {E : D → Type u_5} [(d : D) → Fintype (E d)] [(d : D) → DecidableEq (E d)] [Fintype Θ] (lits : Θ → List ((ι ⊕ (d : D) × E d) × Bool)) (wt : Θ → R) (x : ι → Bool) :

Clause sums over finite domains are clause sums over bits: the bits are the one-hot encoding of the function, and the clauses oneHotLits with weights oneHotWeights kill every assignment of the bits that is not one.

theorem Cslib.Circuits.Arithmetic.domainClauseSum_sumElim {R : Type u_1} [CommSemiring R] {ι : Type u_2} {D : Type u_3} {Θ : Type u_4} [Fintype D] [DecidableEq D] {E : D → Type u_5} [(d : D) → Fintype (E d)] [(d : D) → DecidableEq (E d)] [Fintype Θ] {Θ' : Type u_6} [Fintype Θ'] (lits : Θ → List ((ι ⊕ (d : D) × E d) × Bool)) (wt : Θ → R) (lits' : Θ' → List ((ι ⊕ (d : D) × E d) × Bool)) (wt' : Θ' → R) (x : ι → Bool) (c : R) (h : ∀ (g : (d : D) → E d), (∏ κ : Θ', if ∀ l ∈ lits' κ, Sum.elim x (Pi.oneHot g) l.1 = l.2 then wt' κ else 1) = c) :
domainClauseSum (Sum.elim lits lits') (Sum.elim wt wt') x = domainClauseSum lits wt x * c

Clauses whose product does not depend on the function factor out of the sum.