Boolean circuits scheduled in layers #
Each node reads only the preceding layer. Constants allow evaluation with no input wires; copies carry values across layers; NAND nodes may read a wire twice. The last layer supplies all outputs, and the empty program preserves all inputs. Wire indices have binary encodings.
The number of scheduled layers counts copies and empty layers too. It is not identified here
with the depth of a De Morgan circuit. Layered.Compile converts ordinary shared circuits into
exactly two layers per designated-output depth, with output selection as separate wiring.
Main definitions #
Cslib.Circuits.Boolean.Layered.Node: constants, copies and NANDs.Cslib.Circuits.Boolean.Layered.eval: evaluation of a list of layers.Cslib.Circuits.Boolean.Layered.outputWidth: the number of wires in the final row.Cslib.Circuits.Boolean.Layered.select: ordered output wiring, allowing repeated wires.Cslib.Circuits.Boolean.Layered.WellFormed: all references read the preceding layer.Cslib.Circuits.Boolean.Layered.encNode: two tag bits and binary wire indices.
References #
The consecutive-layer presentation, including inserted copy gates, is used in C. Gentry, Fully homomorphic encryption using ideal lattices, Section 2.
Instances For
A node is valid when each of its references exists in the preceding layer.
Instances For
Evaluate one node. Invalid references read false; correctness of a client interpreter
may require Node.Valid rather than preserving this fallback.