Documentation

Cslib.Computability.Circuit.Wire

Circuit wires and renamings #

A Wire inputCount gateCount refers to an original input or an internal gate. 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.

@[reducible, inline]
abbrev Cslib.Circuits.Wire (inputCount gateCount : ) :

A wire is either an original input or the output of an earlier gate.

Equations
Instances For
    @[reducible, inline]
    abbrev Cslib.Circuits.Wire.input {inputCount gateCount : } (input : Fin inputCount) :
    Wire inputCount gateCount

    Regard an original input as a wire.

    Equations
    Instances For
      @[reducible, inline]
      abbrev Cslib.Circuits.Wire.gate {inputCount gateCount : } (gate : Fin gateCount) :
      Wire inputCount gateCount

      Regard a gate output as a wire.

      Equations
      Instances For
        structure Cslib.Circuits.Wire.Renaming (inputCount sourceGateCount targetGateCount : ) :

        A renaming of gate wires that fixes every original input. Gate wires may be sent to either inputs or gates in the target namespace.

        • gates : Fin sourceGateCountWire inputCount targetGateCount

          The target wire representing each source gate.

        Instances For
          def Cslib.Circuits.Wire.Renaming.apply {inputCount sourceGateCount targetGateCount : } (ρ : Renaming inputCount sourceGateCount targetGateCount) :
          Wire inputCount sourceGateCountWire inputCount targetGateCount

          Apply an input-fixing wire renaming.

          Equations
          Instances For
            @[instance_reducible]
            instance Cslib.Circuits.Wire.Renaming.instCoeFunForall {inputCount sourceGateCount targetGateCount : } :
            CoeFun (Renaming inputCount sourceGateCount targetGateCount) fun (x : Renaming inputCount sourceGateCount targetGateCount) => Wire inputCount sourceGateCountWire inputCount targetGateCount
            Equations
            @[simp]
            theorem Cslib.Circuits.Wire.Renaming.apply_input {inputCount sourceGateCount targetGateCount : } (ρ : Renaming inputCount sourceGateCount targetGateCount) (input : Fin inputCount) :
            ρ.apply (Wire.input input) = Wire.input input
            @[simp]
            theorem Cslib.Circuits.Wire.Renaming.apply_gate {inputCount sourceGateCount targetGateCount : } (ρ : Renaming inputCount sourceGateCount targetGateCount) (gate : Fin sourceGateCount) :
            ρ.apply (Wire.gate gate) = ρ.gates gate
            def Cslib.Circuits.Wire.Renaming.id {inputCount gateCount : } :
            Renaming inputCount gateCount gateCount

            The identity wire renaming.

            Equations
            Instances For
              @[simp]
              theorem Cslib.Circuits.Wire.Renaming.id_apply {inputCount gateCount : } (wire : Wire inputCount gateCount) :
              id.apply wire = wire
              def Cslib.Circuits.Wire.Renaming.comp {inputCount sourceGateCount middleGateCount targetGateCount : } (outer : Renaming inputCount middleGateCount targetGateCount) (inner : Renaming inputCount sourceGateCount middleGateCount) :
              Renaming inputCount sourceGateCount targetGateCount

              Compose input-fixing wire renamings.

              Equations
              Instances For
                @[simp]
                theorem Cslib.Circuits.Wire.Renaming.comp_apply {inputCount sourceGateCount middleGateCount targetGateCount : } (outer : Renaming inputCount middleGateCount targetGateCount) (inner : Renaming inputCount sourceGateCount middleGateCount) (wire : Wire inputCount sourceGateCount) :
                (outer.comp inner).apply wire = outer.apply (inner.apply wire)
                def Cslib.Circuits.Wire.Renaming.castSucc {inputCount gateCount : } :
                Renaming inputCount gateCount (gateCount + 1)

                Include all wires into a namespace with one additional gate.

                Equations
                Instances For
                  @[simp]
                  theorem Cslib.Circuits.Wire.Renaming.castSucc_apply {inputCount gateCount : } (wire : Wire inputCount gateCount) :
                  def Cslib.Circuits.Wire.Renaming.skipLast {inputCount sourceGateCount targetGateCount : } (prior : Renaming inputCount sourceGateCount targetGateCount) (replacement : Wire inputCount targetGateCount) :
                  Renaming inputCount (sourceGateCount + 1) targetGateCount

                  Extend a renaming while replacing the new last gate by an existing wire.

                  Equations
                  Instances For
                    theorem Cslib.Circuits.Wire.Renaming.skipLast_gate_last {inputCount sourceGateCount targetGateCount : } (prior : Renaming inputCount sourceGateCount targetGateCount) (replacement : Wire inputCount targetGateCount) :
                    (prior.skipLast replacement).apply (gate (Fin.last sourceGateCount)) = replacement
                    @[simp]
                    theorem Cslib.Circuits.Wire.Renaming.skipLast_lastWire {inputCount sourceGateCount targetGateCount : } (prior : Renaming inputCount sourceGateCount targetGateCount) (replacement : Wire inputCount targetGateCount) :
                    (prior.skipLast replacement).apply (Fin.last (inputCount + sourceGateCount)) = replacement
                    @[simp]
                    theorem Cslib.Circuits.Wire.Renaming.skipLast_castSucc {inputCount sourceGateCount targetGateCount : } (prior : Renaming inputCount sourceGateCount targetGateCount) (replacement : Wire inputCount targetGateCount) (wire : Wire inputCount sourceGateCount) :
                    (prior.skipLast replacement).apply (Fin.castSucc wire) = prior.apply wire
                    def Cslib.Circuits.Wire.Renaming.appendLast {inputCount sourceGateCount targetGateCount : } (prior : Renaming inputCount sourceGateCount targetGateCount) :
                    Renaming inputCount (sourceGateCount + 1) (targetGateCount + 1)

                    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
                      theorem Cslib.Circuits.Wire.Renaming.appendLast_gate_last {inputCount sourceGateCount targetGateCount : } (prior : Renaming inputCount sourceGateCount targetGateCount) :
                      prior.appendLast.apply (gate (Fin.last sourceGateCount)) = gate (Fin.last targetGateCount)
                      @[simp]
                      theorem Cslib.Circuits.Wire.Renaming.appendLast_lastWire {inputCount sourceGateCount targetGateCount : } (prior : Renaming inputCount sourceGateCount targetGateCount) :
                      prior.appendLast.apply (Fin.last (inputCount + sourceGateCount)) = gate (Fin.last targetGateCount)
                      @[simp]
                      theorem Cslib.Circuits.Wire.Renaming.appendLast_castSucc {inputCount sourceGateCount targetGateCount : } (prior : Renaming inputCount sourceGateCount targetGateCount) (wire : Wire inputCount sourceGateCount) :
                      prior.appendLast.apply (Fin.castSucc wire) = Fin.castSucc (prior.apply wire)
                      def Cslib.Circuits.Wire.Renaming.ofPermutation {inputCount gateCount : } (permutation : Equiv.Perm (Fin gateCount)) :
                      Renaming inputCount gateCount gateCount

                      Rename gate wires by a permutation.

                      Equations
                      Instances For
                        theorem Cslib.Circuits.Wire.Renaming.ofPermutation_gate {inputCount gateCount : } (permutation : Equiv.Perm (Fin gateCount)) (gate : Fin gateCount) :
                        (ofPermutation permutation).apply (Wire.gate gate) = Wire.gate (permutation gate)
                        theorem Cslib.Circuits.Wire.Renaming.value_apply {inputCount sourceGateCount targetGateCount : } {U : Type u_1} (ρ : Renaming inputCount sourceGateCount targetGateCount) (inputs : Fin inputCountU) (oldGates : Fin sourceGateCountU) (newGates : Fin targetGateCountU) (preservesGates : ∀ (gate : Fin sourceGateCount), (fun (i : Fin (inputCount + targetGateCount)) => Fin.addCases inputs newGates i) (ρ.gates gate) = oldGates gate) (wire : Wire inputCount sourceGateCount) :
                        (fun (i : Fin (inputCount + targetGateCount)) => Fin.addCases inputs newGates i) (ρ.apply wire) = (fun (i : Fin (inputCount + sourceGateCount)) => Fin.addCases inputs oldGates i) wire

                        A source and target gate valuation agree along a renaming when they agree on the image of every source gate. Original inputs agree automatically.