Circuit simulation and exact costs #
The cost of a program is the sum of the costs of its lines (Program.cost_eq_sum), so a bound on
the cost of every operation bounds the cost of the program by the number of gates
(Program.cost_le_mul). Costs add up along the composition of circuits
(Circuit.cost_program_comp, Circuit.cost_program_append, Circuit.cost_program_pi).
Replacing each gate by a supplied circuit also preserves costs exactly, charging the source
operation the entire cost of its replacement (Circuit.cost_program_simulate).
Main definitions #
Cslib.Circuits.Circuit.simulate: replace every gate by its implementation circuit.
Main results #
Cslib.Circuits.Circuit.eval_simulate: simulation preserves all circuit outputs.Cslib.Circuits.Program.cost_simulateProgram,Cslib.Circuits.Circuit.cost_program_simulate: exact arbitrary weighted cost under simulation.Cslib.Circuits.Program.cost_eq_sum: program cost as a sum over gates.Cslib.Circuits.Circuit.cost_program_comp,Cslib.Circuits.Circuit.cost_program_append,Cslib.Circuits.Circuit.cost_program_pi: exact composition costs.
Replacing the gates by circuits computing their operations computes the same function.
The costs of circuits built from smaller ones. They are not simp lemmas: simp would first
rewrite the number of gates, an implicit argument of Program.cost, by Circuit.size_comp and the
like, after which they no longer match. They apply with rw and simp only.