Resource-accounted circuit composition #
This module exposes serial composition of two circuits over the same basis. The construction shares every inner output and therefore has exact additive size, rather than duplicating the inner circuit once per outer use.
Main results #
Circuit.eval_compose-- exact functional composition.Circuit.size_compose-- exact additive size.Circuit.depth_compose_le-- depth is at most the sum of source depths.Circuit.eval_parallel-- parallel composition appends output tuples.Circuit.size_parallel-- parallel composition also has exact additive size.
Composition preserves outer wire semantics after feeding the inner circuit's result to the outer circuit.
Every embedded outer wire has depth at most the inner circuit depth plus its original outer-circuit wire depth.
Serial composition has exactly additive size under the library convention.
The K inner output gates become internal gates, so no output gate is lost or
double-counted.
Parallel composition #
Parallel composition preserves every right-component wire value after shifting its internal-gate block past the left component.
Any positive finite family of single-output circuits with shared primary
inputs can be packed into one multi-output circuit. Its size is exactly the sum
of the source sizes, and output i is the output of source circuit i.