Circuit wires and renamings #
A Wire inputCount gateCount refers to an original input or an internal gate.
A valuation of wires is assembled with Wire.elim from values for the inputs and
values for the gates. Wire.index numbers the inputs first and then the gates in order,
so that a gate reads only wires with a smaller index.
Wire.Renaming fixes the original inputs and maps each gate to an input or gate
in the target namespace. This file provides identity and composition, extension
by a gate, replacement of the last gate, and renaming by a permutation.
Equations
- Cslib.Circuits.instDecidableEqWire.decEq (Cslib.Circuits.Wire.input a) (Cslib.Circuits.Wire.input b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Cslib.Circuits.instDecidableEqWire.decEq (Cslib.Circuits.Wire.input input) (Cslib.Circuits.Wire.gate gate) = isFalse ⋯
- Cslib.Circuits.instDecidableEqWire.decEq (Cslib.Circuits.Wire.gate gate) (Cslib.Circuits.Wire.input input) = isFalse ⋯
- Cslib.Circuits.instDecidableEqWire.decEq (Cslib.Circuits.Wire.gate a) (Cslib.Circuits.Wire.gate b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
Instances For
Define a function on wires from its values on inputs and on gates.
Equations
- Cslib.Circuits.Wire.elim inputs gates (Cslib.Circuits.Wire.input i) = inputs i
- Cslib.Circuits.Wire.elim inputs gates (Cslib.Circuits.Wire.gate j) = gates j
Instances For
Equations
- Cslib.Circuits.Wire.instFintype = Fintype.ofEquiv (Fin inputCount ⊕ Fin gateCount) (Cslib.Circuits.Wire.equiv inputCount gateCount).symm
The position of a wire when the inputs are listed first, followed by the gates in program order. A gate reads only wires whose index is below its own.
Equations
- (Cslib.Circuits.Wire.input i).index = Fin.castAdd gateCount i
- (Cslib.Circuits.Wire.gate j).index = Fin.natAdd inputCount j
Instances For
Regard a wire as a wire in a namespace with one additional gate.
Equations
Instances For
A wire in a namespace with one additional gate is either the new last gate or an earlier wire.
Equations
- Cslib.Circuits.Wire.lastCases last castSucc (Cslib.Circuits.Wire.input i) = castSucc (Cslib.Circuits.Wire.input i)
- Cslib.Circuits.Wire.lastCases last castSucc (Cslib.Circuits.Wire.gate j) = Fin.lastCases last (fun (j : Fin gateCount) => castSucc (Cslib.Circuits.Wire.gate j)) j
Instances For
Regard a wire as a wire of the same program continued by extra further gates.
Equations
Instances For
A renaming of gate wires that fixes every original input. Gate wires may be sent to either inputs or gates in the target namespace.
The target wire representing each source gate.
Instances For
Apply an input-fixing wire renaming.
Equations
Instances For
The identity wire renaming.
Equations
Instances For
Compose input-fixing wire renamings.
Instances For
Include all wires into a namespace with one additional gate.
Equations
- Cslib.Circuits.Wire.Renaming.castSucc = { gates := fun (gate : Fin gateCount) => Cslib.Circuits.Wire.gate gate.castSucc }
Instances For
Extend a renaming while replacing the new last gate by an existing wire.
Equations
Instances For
Extend a renaming and retain the new last gate as a fresh target gate.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Rename gate wires by a permutation.
Equations
- Cslib.Circuits.Wire.Renaming.ofPermutation permutation = { gates := fun (gate : Fin gateCount) => Cslib.Circuits.Wire.gate (permutation gate) }
Instances For
A source and target gate valuation agree along a renaming when they agree on the image of every source gate. Original inputs agree automatically.