Building circuits from available functions #
An existing circuit can be inserted into a synthesis construction by wiring its inputs to available functions. Its outputs then become available at a cost of its number of gates, while all previously computed functions remain available. Repeated inputs share their original wires.
Synthesis.Builder accumulates available wires and gate costs through Builder.start and
Builder.add. Each appended construction is charged once; selecting and reusing wires is free.
Builder.finish selects the outputs and checks the requested bound. These operations compose
ordinary Synthesis certificates; they do not search for a cheaper construction.
Main definitions #
Cslib.Circuits.Synthesis.Builder: available wires and their accumulated synthesis bound.
Main results #
Cslib.Circuits.Synthesis.circuit: applying a circuit costs its number of gates.Cslib.Circuits.Synthesis.extend: append a construction fed by the wires built so far.Cslib.Circuits.Synthesis.Builder.finish: select outputs within a requested gate budget.
References #
- Adapted from MassProduction/Nonuniform/FlagSelection.lean in S. Schlesinger, Boolean circuit mass production formalization.
A circuit whose inputs are fed by available functions computes its outputs with as many additional gates as it has. The functions feeding the inputs may repeat.
Append a construction whose inputs are among the targets built so far, keeping those targets
available. This is the certificate behind Builder.add. The new family u is explicit, so a
chain of extend steps accumulates the syntactic union s ∪ t₁ ∪ ⋯ ∪ tₖ, and membership in it
can be checked without unfolding.
A sequence of certified constructions, including every wire available along the way.
Original sources and all outputs built so far.
- cost : ℕ
Sum of the appended constructions' gate budgets.
The accumulated synthesis certificate.
Begin with the source wires, without adding gates.
Append a construction whose inputs are available, retaining both old and new wires.
Select outputs from the final wires and enlarge the accumulated budget.