Documentation

Complexitylib.Circuits.Encoding.FixedWidth.Conversion

Conversion between raw circuits and fixed-width descriptions #

Canonical zero padding makes valid fixed-width descriptions exactly equivalent to nonempty topologically ordered raw circuits within the gate bound. The two round trips preserve every gate, reference, and control bit.

@[simp]

A fixed-width reference word serializes to the expected little-endian bits.

theorem Complexity.CircuitCode.FixedWidth.GateSlot.toRawGate_ofRawGate {width : } {gate : RawGate} (hinput0 : gate.input₀ < 2 ^ width) (hinput1 : gate.input₁ < 2 ^ width) :
(ofRawGate width gate).toRawGate = gate

Encoding and decoding a raw gate is exact when both references fit.

@[simp]

Every fixed slot is recovered after conversion through raw-gate syntax.

theorem Complexity.CircuitCode.FixedWidth.Description.toRawCircuit_ofRawCircuit {inputWidth gateBound : } {circuit : RawCircuit} (htopological : RawCircuit.TopologicallyWellFormed inputWidth circuit) (hbound : List.length circuit gateBound) :
(ofRawCircuit circuit hbound).toRawCircuit = circuit

Encoding a bounded topologically ordered raw circuit and converting it back preserves the exact gate list.

theorem Complexity.CircuitCode.FixedWidth.Description.ofRawCircuit_wellFormed {inputWidth gateBound : } {circuit : RawCircuit} (hcircuit : RawCircuit.WellFormed inputWidth circuit) (hbound : List.length circuit gateBound) :
(ofRawCircuit circuit hbound).WellFormed

A bounded valid raw circuit produces a valid fixed-width description.

theorem Complexity.CircuitCode.FixedWidth.Description.ofRawCircuit_toRawCircuit {inputWidth gateBound : } {description : Description inputWidth gateBound} (hcanonical : description.CanonicallyPadded) :
ofRawCircuit description.toRawCircuit = description

Canonical padding makes conversion from a description through raw syntax an exact round trip.

def Complexity.CircuitCode.FixedWidth.wellFormedEquiv (inputWidth gateBound : ) :
ValidDescription inputWidth gateBound BoundedRawCircuit inputWidth gateBound

Valid fixed-width descriptions are exactly bounded valid raw circuits.

Equations
Instances For
    @[simp]
    theorem Complexity.CircuitCode.FixedWidth.wellFormedEquiv_apply_val {inputWidth gateBound : } (description : ValidDescription inputWidth gateBound) :
    ((wellFormedEquiv inputWidth gateBound) description) = (↑description).toRawCircuit

    The forward equivalence map is the raw-circuit view of a valid fixed-width description.

    @[simp]
    theorem Complexity.CircuitCode.FixedWidth.wellFormedEquiv_symm_val {inputWidth gateBound : } (circuit : BoundedRawCircuit inputWidth gateBound) :
    ((wellFormedEquiv inputWidth gateBound).symm circuit) = Description.ofRawCircuit circuit

    The inverse equivalence map is canonical fixed-width conversion of a bounded raw circuit.

    @[instance_reducible]
    noncomputable instance Complexity.CircuitCode.FixedWidth.instFintypeBoundedRawCircuit (inputWidth gateBound : ) :
    Fintype (BoundedRawCircuit inputWidth gateBound)
    Equations
    • One or more equations did not get rendered due to their size.