Relative circuit complexity #
The complexity C(f | g) of f relative to g is the least number of gates needed to compute
f when the values of g come for free: the circuit reads an input x followed by the values
g x. Such a circuit only ever sees inputs of this form, which make up the graph of g, so
computing f given g is computing f of the first part of the input, on the graph of g.
Relative complexity is defined as this complexity on a support, C(f | g) = C^Γ(f ∘ π) where
Γ is the graph of g and π forgets the values of g. The reading in terms of circuits on
x and g x is recovered by ecomplexityGiven_le_iff.
The rules of relative complexity follow from the calculus of support complexity. Knowing g
never makes f harder, and knowing more never makes it harder either.
Computing g and then f from it gives the chain rule C(f) ≤ C(g) + C(f | g), and its
variant for computing f and g together. Relative complexity satisfies the triangle
inequality C(f | h) ≤ C(g | h) + C(f | g), and every function is free given itself.
The complexity C(f | g) of f relative to g: the least size of a single circuit satisfying
c.eval I (Fin.append x (g x)) = f x for every x, or ⊤ if there is none.
Each evaluation supplies only x and g x; values of g at other inputs are not provided.
graph g specifies the inputs on which the circuit must be correct, and onFirstInputs k f
specifies its required output on those inputs.
Instances For
A circuit computes f of the first n inputs on the graph of g exactly when, reading an
input followed by the values of g on it, it outputs the values of f on that input.
Computing the graph map x ↦ (x, g x) costs no more than computing g.
Every function is free given itself: C(f | f) = 0.
Knowing g never makes f harder: C(f | g) ≤ C(f).
The chain rule: computing g and then f from it gives C(f) ≤ C(g) + C(f | g).
Computing f and g together costs at most computing f and then g given f.
The triangle inequality: C(f | h) ≤ C(g | h) + C(f | g). Given h, compute g, and then
f from g.
Over a complete basis #
The complexity C(f | g) of f relative to g over a complete basis, as a natural
number.