Wire accounting and shared gates #
For a circuit with no unused gates, let w count original input occurrences
and let e sum each gate's uses beyond its first. Double counting gives
w + e + size = totalFanIn + outputCount. Thus a binary single-output
circuit satisfies w + e = size + 1. Every shared gate contributes at least
one to e, so w + sharedGates.card ≤ size + 1 as well.
Uses include designated outputs and count repeated gate arguments separately. No assumption of distinct arguments, Boolean values, positive input count, or gated outputs is needed. The no-unused-gates hypothesis is essential to the balance equation: an unused gate has no first use to subtract.
These generic extensions of CSLib's circuit model are candidates for upstreaming. They count structural sharing, without assigning a semantic or communication cost to a shared gate.
Exact wire-use accounting for a circuit without unused gates.
Fan-in at most two bounds input occurrences plus excess gate uses.