Normalizing and bounding circuits built with combinators #
Fills the simp set circuit_simps and registers the rules of the tactic circuit_bound for the
circuit combinators Circuit.comp, Circuit.append, Circuit.pi, Circuit.wiring,
Circuit.wiringOn, Circuit.oneGate, Circuit.mapOp, Circuit.iterate, Formula.gate and
Formula.toCircuit.
simp only [circuit_simps, step]rewrites the function, size, program cost and exact depths of the circuitstepto those of its parts. The simp set unfolds no definition, so the definitions of the construction are named beside it.circuit_bound [step]proves a bound(step k).depth ≤ 2. Composition only bounds the depth, so the depth rulesCircuit.depth_comp_le,Circuit.depth_append_le,Circuit.depth_pi_leandCircuit.depth_iterate_le, and those ofdepthWith, are registered with@[circuit_bound]instead of being simp lemmas.
A module that proves a bound of a named circuit tags it @[circuit_bound], and later
constructions that contain the circuit then use the bound without naming it.
The simp set holds the lemmas that a proof in the library uses through it. A lemma of the same
kind that is missing, such as Circuit.eval_iterate or Formula.eval_gate₂, is added here with
its first use.
Main definitions #
Circuit.costProgram: the simplification procedure ofcircuit_simpsfor the program cost of a combinator or compiled formula. It appliesCircuit.cost_program_comp,Circuit.cost_program_append,Circuit.cost_program_pi,Circuit.cost_program_wiring,Circuit.cost_program_wiringOn,Circuit.cost_program_oneGate,Circuit.cost_program_iterateandFormula.cost_toCircuit, which cannot be simp lemmas of a set that also rewrites the gate count, an implicit argument of the cost.
The supremum over Fin 0 is ⊥.
The supremum over Fin 1 is the value at 0.
The supremum over Fin 2 is the maximum of the values at 0 and 1.
Rewrites the program cost of a circuit built with a combinator to the costs of its parts, by
Circuit.cost_program_comp and the like. Those are not simp lemmas: once simp has rewritten the
gate count, an implicit argument of Program.cost, by Circuit.size_comp they no longer match.
This procedure reads only the circuit and the cost function.