Documentation

CslibFrontier.Computability.Circuit.Boolean.CodeTemplate

Uniform instantiation of fixed De Morgan formula templates #

Specializes Cslib.Circuits.Circuit.formulaCode and the typed formula (·.toCircuit.code) rules from CslibFrontier.Computability.Circuit.Encoding.Combinators to De Morgan formulas.

Main definitions #

Main results #

@[reducible, inline]
abbrev Cslib.Circuits.Boolean.formulaCode {m : ℕ} (n : ℕ) (F : Formula signature m) (wires : Fin m → ℕ) :

Instantiate a De Morgan formula at raw wire numbers.

theorem Cslib.Circuits.Boolean.formulaCode_eq_code {n m : ℕ} (F : Formula signature m) (wires : Fin m → Fin n) :
(formulaCode n F fun (i : Fin m) => ↑(wires i)) = (Formula.rename wires F).toCircuit.code

Instantiating valid input wires constructs the renamed formula's circuit code.

theorem Cslib.Circuits.Boolean.computableInPolyTime_formulaCode {α : Type} {enc : α ↪ List Bool} {n : α → ℕ} {m : ℕ} (F : Formula signature m) {wires : α → Fin m → ℕ} (hn : Turing.MultiTapeTM.ComputableInPolyTime n enc Turing.MultiTapeTM.encNat) (hwires : ∀ (i : Fin m), Turing.MultiTapeTM.ComputableInPolyTime (fun (a : α) => wires a i) enc Turing.MultiTapeTM.encNat) :
Turing.MultiTapeTM.ComputableInPolyTime (fun (a : α) => formulaCode (n a) F (wires a)) enc encCode

A fixed formula's instantiated code is polynomial-time in the target input count and selected binary wire numbers.

Emit the circuit code of a De Morgan input leaf (Formula.input (w a)).toCircuit.

Emit the circuit code of a De Morgan constant leaf (Formula.const b).toCircuit.

Emit the circuit code of a negated De Morgan formula (F a).not.toCircuit.

Emit the circuit code of a conjunction ((F a).and (G a)).toCircuit.

Emit the circuit code of a disjunction ((F a).or (G a)).toCircuit.

theorem Cslib.Circuits.Boolean.computableInPolyTime_code_ite_toCircuit {α : Type} {enc : α ↪ List Bool} {n : α → ℕ} {p : α → Prop} [(a : α) → Decidable (p a)] {t e : (a : α) → Formula signature (n a)} (hp : Turing.MultiTapeTM.ComputableInPolyTime (fun (a : α) => decide (p a)) enc Turing.MultiTapeTM.encBool) (ht : Turing.MultiTapeTM.ComputableInPolyTime (fun (a : α) => (t a).toCircuit.code) enc encCode) (he : Turing.MultiTapeTM.ComputableInPolyTime (fun (a : α) => (e a).toCircuit.code) enc encCode) :

Emit the circuit code of a conditional choice of De Morgan formulas.