Documentation

CslibFrontier.Computability.Circuit.Monotone.DualRail

The dual-rail translation of De Morgan circuits #

A De Morgan circuit becomes a monotone circuit by computing, for every wire, both its value and its negation [Gol77]. The monotone circuit (Cslib.Circuits.Monotone.dualRail) has 2 n + 1 inputs: input 0 is the constant true, and the input i of the De Morgan circuit is carried positively by input 2 i + 1 and negatively by input 2 i + 2 (railBits). Each gate is replaced by two gates, carrying it positively and negatively: an AND gate by the AND of the positive rails and the OR of the negative rails, an OR gate dually, a negation by copies of the crossed rails (idempotent disjunctions), and a constant by the constant and its negation (dualGates). Every wire w of the De Morgan circuit is then carried by the wires 2 w + 1 and 2 w + 2 (railWire), uniformly for inputs and gates, so the translation of a gate depends on the gate alone, not on its position.

The translation works on gate lists (dualCode): it keeps well-formedness (isCodeFrom_dualCode), and evaluating the translated list on the dual-rail inputs gives the dual-rail values (evalCode_dualCode). The translated circuit computes the same function on the dual-rail inputs (eval_dualRail) and has twice the size (size_dualRail). Each original AND or OR gate contributes exactly one AND gate, while negations and constants contribute none, so the translated AND cost is exactly the original binary-gate cost (cost_dualRail).

Main definitions #

Main results #

References #

Dual-rail wires and inputs #

The wire carrying wire w positively (b = true), 2 w + 1, or negatively, 2 w + 2. Wire 0 is the constant true.

The dual-rail values: the constant true, then each value followed by its negation.

@[simp]

The dual-rail list railBits x has length 2 * x.length + 1.

@[simp]

Wire 0 of railBits x carries the constant true.

@[simp]

Entry 0 of railBits x is true.

The positive rail of a value.

The negative rail of a value.

Gates #

The two monotone gates computing a De Morgan gate positively and negatively, from its operation and its wires g.2: an AND gate by the AND of the positive rails and the OR of the negative rails, an OR gate dually, a negation by the crossed rails (each in an idempotent disjunction), a constant by the constant and its negation.

@[simp]

Each De Morgan gate translates to exactly two monotone gates.

The dual-rail translation of a gate list: each gate by its two monotone gates.

@[simp]

The translated gate list dualCode gates has twice the length of gates.

theorem Cslib.Circuits.Monotone.dualCode_append (gates gates' : List (Boolean.Op × List ℕ)) :
dualCode (gates ++ gates') = dualCode gates ++ dualCode gates'

The translation keeps well-formedness: the gates of a De Morgan gate list reading the first n + k wires become gates reading the first 2 n + 1 + 2 k wires.

The translated gate list computes the dual-rail values: on the dual-rail inputs, the gates translating gate j carry the value of gate j and its negation.

Circuits #

The dual-rail inputs of an input of a De Morgan circuit (railBits).

Listing the bits of railBitString x gives railBits (List.ofFn x).

The dual-rail code of a De Morgan circuit c is a valid monotone circuit code.

The dual-rail translation of a De Morgan circuit: a monotone circuit on the 2 n + 1 dual-rail inputs with two gates for every gate.

The code of dualRail c consists of dualCode c.code.1 and the positive output rails.

The dual-rail translation has twice the size.

The dual-rail translation has exactly one AND gate per original binary AND or OR gate. Negations become idempotent OR gates and therefore have no AND cost.

The dual-rail translation computes the same function on the dual-rail inputs.