Documentation

CslibFrontier.Computability.Circuit.Inputization

Gate inputization and projection-aware deduplication #

For a multi-output function g : (Fin n → U) → Fin k → U, the non-input components nonInputComponents g are the distinct functions fun x => g x j that are not input projections fun x => x i. Their number is the exact complexity of g whenever g lists the wire functions of a program, and it is the price of computing g alongside any other function f:

Repeated components are counted once and components that are input projections are not counted, since an output wire may be an input wire and designating outputs is free.

Main definitions #

Main results #

References #

These are library generalizations, to arbitrary signatures and interpretations, of Ilango, Loff and Oliveira, Proposition 14 (pp. 22:21–22:22), where g lists the gates of De Morgan formulas, and of its use in the proof of Lemma 16 (p. 22:22), where the gap between the complexities of T • g and of g measures the cost of computing T from the components of g.

noncomputable def Cslib.Circuits.nonInputComponents {U : Type u} {n k : ℕ} (g : (Fin n → U) → Fin k → U) :
Finset ((Fin n → U) → U)

The distinct components fun x => g x j of g that are not input projections fun x => x i. Repeated components are counted once.

theorem Cslib.Circuits.mem_nonInputComponents {U : Type u} {n k : ℕ} {g : (Fin n → U) → Fin k → U} {h : (Fin n → U) → U} :
h ∈ nonInputComponents g ↔ (∃ (j : Fin k), (fun (x : Fin n → U) => g x j) = h) ∧ ∀ (i : Fin n), h ≠ fun (x : Fin n → U) => x i

A non-input component of g is a component of g that differs from every input projection.

theorem Cslib.Circuits.card_nonInputComponents_le {U : Type u} {n k : ℕ} (g : (Fin n → U) → Fin k → U) :

There are at most as many non-input components as components.

theorem Cslib.Circuits.card_nonInputComponents_eq {U : Type u} {n k : ℕ} {g : (Fin n → U) → Fin k → U} (hinj : Function.Injective fun (j : Fin k) (x : Fin n → U) => g x j) (hproj : ∀ (j : Fin k) (i : Fin n), (fun (x : Fin n → U) => g x j) ≠ fun (x : Fin n → U) => x i) :

When the components of g are pairwise distinct and none is an input projection, all k of them are counted.

noncomputable def Cslib.Circuits.Program.componentGates {σ : Signature} {U : Type u} {n k s : ℕ} (p : Program σ n s) (I : Interpretation σ U) (g : (Fin n → U) → Fin k → U) :

The gates of p computing a component of g.

theorem Cslib.Circuits.Program.mem_componentGates {σ : Signature} {U : Type u} {n k s : ℕ} {p : Program σ n s} {I : Interpretation σ U} {g : (Fin n → U) → Fin k → U} {t : Fin s} :
t ∈ p.componentGates I g ↔ ∃ (j : Fin k), p.gateFunction I t = fun (x : Fin n → U) => g x j

A component gate is a gate whose function is some component of g.

Component gates #

theorem Cslib.Circuits.Circuit.nonInputComponents_subset_image_componentGates {σ : Signature} {U : Type u} {n m k : ℕ} {I : Interpretation σ U} {g : (Fin n → U) → Fin k → U} (c : Circuit σ n m) (hg : ∀ (j : Fin k), ∃ (o : Fin m), ∀ (x : Fin n → U), c.eval I x o = g x j) :

In a circuit whose outputs include every component of g, each non-input component of g is the function of a gate computing a component of g: an output computing it cannot be an input wire.

theorem Cslib.Circuits.Circuit.card_nonInputComponents_le_card_componentGates {σ : Signature} {U : Type u} {n m k : ℕ} {I : Interpretation σ U} {g : (Fin n → U) → Fin k → U} (c : Circuit σ n m) (hg : ∀ (j : Fin k), ∃ (o : Fin m), ∀ (x : Fin n → U), c.eval I x o = g x j) :

A circuit whose outputs include every component of g has at least as many gates computing components of g as g has non-input components (Ilango, Loff and Oliveira, Proposition 14, first statement).

theorem Cslib.Circuits.card_nonInputComponents_le_ecomplexity {σ : Signature} {U : Type u} {n k : ℕ} (I : Interpretation σ U) (g : (Fin n → U) → Fin k → U) :

Computing g costs at least one gate for each non-input component of g.

Inputization #

theorem Cslib.Circuits.Circuit.card_nonInputComponents_add_ecomplexityGiven_le {σ : Signature} {U : Type u} {n m k : ℕ} {I : Interpretation σ U} {g : (Fin n → U) → Fin k → U} {f : (Fin n → U) → Fin m → U} (c : Circuit σ n (k + m)) (hc : c.Computes I fun (x : Fin n → U) => Fin.append (g x) (f x)) :

Inputization (generalizing Ilango, Loff and Oliveira, Proposition 14 and the proof of Lemma 16, p. 22:22). In a circuit computing g followed by f, the gates computing components of g are at least as many as the non-input components of g, and the remaining gates compute f from x and g x.

theorem Cslib.Circuits.card_nonInputComponents_add_ecomplexityGiven_le {σ : Signature} {U : Type u} {n m k : ℕ} (I : Interpretation σ U) (g : (Fin n → U) → Fin k → U) (f : (Fin n → U) → Fin m → U) :
↑(nonInputComponents g).card + ecomplexityGiven I f g ≤ ecomplexity I fun (x : Fin n → U) => Fin.append (g x) (f x)

Inputization. Computing g followed by f costs at least one gate for each non-input component of g, plus the complexity of f given g.

Exact complexity #

theorem Cslib.Circuits.ecomplexity_le_card_nonInputComponents {σ : Signature} {U : Type u} {n k s : ℕ} (I : Interpretation σ U) (p : Program σ n s) (g : (Fin n → U) → Fin k → U) (hwires : ∀ (j : Fin k), ∃ (w : Wire n s), p.wireFunction I w = fun (x : Fin n → U) => g x j) (hgates : ∀ (t : Fin s), (∀ (i : Fin n), p.gateFunction I t ≠ fun (x : Fin n → U) => x i) → ∃ (j : Fin k), p.gateFunction I t = fun (x : Fin n → U) => g x j) :

When every component of g is a wire function of p and every gate of p that is not an input projection computes a component of g, computing g costs at most one gate per non-input component (Ilango, Loff and Oliveira, Proposition 14, second statement).

theorem Cslib.Circuits.ecomplexity_eq_card_nonInputComponents {σ : Signature} {U : Type u} {n k s : ℕ} (I : Interpretation σ U) (p : Program σ n s) (g : (Fin n → U) → Fin k → U) (hwires : ∀ (j : Fin k), ∃ (w : Wire n s), p.wireFunction I w = fun (x : Fin n → U) => g x j) (hgates : ∀ (t : Fin s), (∀ (i : Fin n), p.gateFunction I t ≠ fun (x : Fin n → U) => x i) → ∃ (j : Fin k), p.gateFunction I t = fun (x : Fin n → U) => g x j) :

When g lists wire functions of p covering every gate of p that is not an input projection, the complexity of g is its number of non-input components (Ilango, Loff and Oliveira, Proposition 14).

Computing all gates of a program costs one gate per distinct gate function that is not an input projection.

theorem Cslib.Circuits.ecomplexity_append_eq_card_nonInputComponents_add_ecomplexityGiven {σ : Signature} {U : Type u} {n m k : ℕ} (I : Interpretation σ U) {g : (Fin n → U) → Fin k → U} (f : (Fin n → U) → Fin m → U) (hg : ecomplexity I g ≤ ↑(nonInputComponents g).card) :
(ecomplexity I fun (x : Fin n → U) => Fin.append (g x) (f x)) = ↑(nonInputComponents g).card + ecomplexityGiven I f g

When computing g costs only its non-input components, computing g followed by f costs exactly those components plus the complexity of f given g.