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,Cslib.Circuits.Boolean.Layered.Node.code,Cslib.Circuits.Boolean.Layered.Node.Valid,Cslib.Circuits.Boolean.Layered.Node.eval: constants, copies and NANDs, together with their tuple code, reference validity, and node evaluation.Cslib.Circuits.Boolean.Layered.evalLayer,Cslib.Circuits.Boolean.Layered.eval: evaluation of a single layer and 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 uniquely determined by its tag-and-index tuple Node.code.
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.
Instances For
The output width of an empty schedule is the input width.
The output width of a concatenated schedule is the output width of the second from the first.
The empty layer schedule is well-formed for any input width.
layer :: layers is well-formed iff every node in layer is valid for inputCount and
layers is well-formed for layer.length.
A concatenated schedule is well-formed iff the first is well-formed and the second is well-formed for the output width of the first.