Documentation

CslibFrontier.Computability.Circuit.StraightLine

Programs from closed-form gate values #

A construction often describes its gates by a closed formula for each gate value, because that is how locality and counting arguments read them. Program.exists_eval_eq_of_lines turns such a description into a program: if line j is a line whose gate wires point before gate j, and h x j is what line j computes from the input x and the values h x, then some program with those operations has gate values h x.

Main results #

theorem Cslib.Circuits.Program.exists_eval_eq_of_prefixLines {σ : Signature} {U : Type u} {n : ℕ} {X : Type u_1} (I : Interpretation σ U) (input : X → Fin n → U) {G : ℕ} (line : (j : Fin G) → Line σ n ↑j) (h : X → Fin G → U) :
(∀ (x : X) (j : Fin G), h x j = (line j).eval I (input x) fun (t : Fin ↑j) => h x (Fin.castLE ⋯ t)) → ∃ (P : Program σ n G), (∀ (x : X), P.eval I (input x) = h x) ∧ ∀ (j : Fin G), (P.lines j).op = (line j).op

Programs from lines over the gates before each one. Let line j be a line over the gates before j, and let h x j be its value on the inputs input x and the values h x of the earlier gates, for x in any type X. Then some program has gate values h x on the inputs input x, and its gate j performs the operation of line j.

theorem Cslib.Circuits.Program.exists_eval_eq_of_lines {σ : Signature} {U : Type u} {n : ℕ} (I : Interpretation σ U) {G : ℕ} (line : Fin G → Line σ n G) (h : (Fin n → U) → Fin G → U) (hearly : ∀ (j : Fin G) (a : Fin (σ.Arity (line j).op)) (t : Fin G), (line j).wires a = Wire.gate t → t < j) (heval : ∀ (x : Fin n → U) (j : Fin G), h x j = (line j).eval I x (h x)) :
∃ (P : Program σ n G), (∀ (x : Fin n → U), P.eval I x = h x) ∧ ∀ (j : Fin G), (P.lines j).op = (line j).op

Programs from closed-form gate values. Let line j be a line over all G gates whose gate wires point to gates before j, and let h x j be the value of line j on the input x and the gate values h x. Then some program on n inputs with G gates has gate values h x, and its gate j performs the operation of line j.