Documentation

CslibFrontier.Computability.Circuit.SumOfTerms.Basic

Circuits adding dictionary terms #

Nullary gates produce members of a prescribed dictionary, interpreted in any additive carrier. The standard dictionary cost charges those terms and makes binary addition and wiring free. Separate addition costs and arbitrary uniform weights are also provided.

Main definitions #

Main results #

References #

Free binary addition and a nullary gate for each dictionary term.

@[instance_reducible]
def Cslib.Circuits.SumOfTerms.instDecidableEqOp.decEq {T✝ : Type u_1} [DecidableEq T✝] (x✝ x✝¹ : Op T✝) :
Decidable (x✝ = x✝¹)
@[reducible, inline]

Addition reads two wires; dictionary terms read none.

@[reducible, inline]

The signature for sums of dictionary terms.

def Cslib.Circuits.SumOfTerms.interpretation {T : Type u_1} {V : Type u_2} [Add V] (value : T → V) :

Interpret dictionary terms by their values and addition by carrier addition.

@[simp]
theorem Cslib.Circuits.SumOfTerms.interpretation_add {T : Type u_1} {V : Type u_2} [Add V] (value : T → V) (args : Fin 2 → V) :
interpretation value Op.add args = args 0 + args 1

Interpreting .add adds its two arguments in V.

@[simp]
theorem Cslib.Circuits.SumOfTerms.interpretation_term {T : Type u_1} {V : Type u_2} [Add V] (value : T → V) (t : T) (args : Fin 0 → V) :
interpretation value (Op.term t) args = value t

Interpreting .term t evaluates the dictionary term t via value.

def Cslib.Circuits.SumOfTerms.dictionaryCost {T : Type u_1} (weight : T → ℕ) :
Op T → ℕ

Charge each dictionary term its weight; addition is free.

@[simp]
theorem Cslib.Circuits.SumOfTerms.dictionaryCost_add {T : Type u_1} (weight : T → ℕ) :

Addition has dictionaryCost zero.

@[simp]
theorem Cslib.Circuits.SumOfTerms.dictionaryCost_term {T : Type u_1} (weight : T → ℕ) (t : T) :
dictionaryCost weight (Op.term t) = weight t

The dictionaryCost of .term t is weight t.

@[reducible, inline]

Count dictionary gates, with free addition.

Count additions; dictionary gates are free.

def Cslib.Circuits.SumOfTerms.weightedCost {T : Type u_1} (addition term : ℕ) :
Op T → ℕ

Assign one weight to additions and another to dictionary gates.

theorem Cslib.Circuits.SumOfTerms.cost_weightedCost {T : Type u_1} {n g : ℕ} (p : Program (signature T) n g) (addition term : ℕ) :
p.cost (weightedCost addition term) = addition * p.cost addCost + term * p.cost termCost

Uniform weights separate into the addition and dictionary gate counts.