Documentation

Complexitylib.Circuits.Encoding.FixedWidth.Defs

Fixed-width binary circuit descriptions -- definitions #

This module gives fan-in-two raw circuits an Algebraic-style gate-slot view. Every slot has fixed-width binary references, and a bounded description stores exactly gateBound slots together with an explicit active gate count. Active slots must point strictly backward; inactive slots are canonically zero.

The representation is proof-free and finite. A later codec flattens it into the Boolean cube used by approximate counting without parsing variable-length fields.

Positive binary width sufficient for every wire below inputWidth + gateBound. Keeping the width positive lets the verified binary comparator handle even the one-wire edge case.

Equations
Instances For

    Positive binary width sufficient for every gate count through gateBound.

    Equations
    Instances For

      Three control bits and two fixed-width wire references per gate.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Width of a flattened bounded description: one count field followed by exactly gateBound gate slots.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          instance Complexity.CircuitCode.FixedWidth.instNeZeroNatCodeWidth (inputWidth gateBound : ) :
          NeZero (codeWidth inputWidth gateBound)

          One fixed-width fan-in-two gate slot.

          The operation bit uses the existing raw codec convention: true is AND and false is OR. Reference words are little-endian so the circuit comparator can validate them directly.

          • op : Bool

            Raw operation selector.

          • negated0 : Bool

            Whether the first input is negated.

          • negated1 : Bool

            Whether the second input is negated.

          • input0 : BitString width

            Little-endian first wire reference.

          • input1 : BitString width

            Little-endian second wire reference.

          Instances For
            def Complexity.CircuitCode.FixedWidth.instDecidableEqGateSlot.decEq {width✝ : } (x✝ x✝¹ : GateSlot width✝) :
            Decidable (x✝ = x✝¹)
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Product view used to enumerate fixed-width gate slots exactly.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                @[instance_reducible]
                Equations
                • One or more equations did not get rendered due to their size.

                Natural value of the first little-endian reference word.

                Equations
                Instances For

                  Natural value of the second little-endian reference word.

                  Equations
                  Instances For

                    Convert a fixed slot to the existing proof-free gate syntax.

                    Equations
                    Instances For

                      Canonical all-zero inactive slot.

                      Equations
                      Instances For

                        Both binary references point to already available wires.

                        Equations
                        Instances For
                          @[instance_reducible]
                          instance Complexity.CircuitCode.FixedWidth.GateSlot.instDecidableWellFormedAt {width : } (slot : GateSlot width) (available : ) :
                          Decidable (slot.WellFormedAt available)
                          Equations
                          structure Complexity.CircuitCode.FixedWidth.Description (inputWidth gateBound : ) :

                          A bounded fixed-slot description.

                          gateCount.val slots are active, while all remaining slots are present so the eventual bit encoding has one parameter-determined width.

                          • gateCount : Fin (gateBound + 1)

                            Number of active gates, ranging from zero through gateBound.

                          • slots : Fin gateBoundGateSlot (referenceWidth inputWidth gateBound)

                            Fixed collection of gate slots.

                          Instances For
                            def Complexity.CircuitCode.FixedWidth.instDecidableEqDescription.decEq {inputWidth✝ gateBound✝ : } (x✝ x✝¹ : Description inputWidth✝ gateBound✝) :
                            Decidable (x✝ = x✝¹)
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              def Complexity.CircuitCode.FixedWidth.descriptionEquiv (inputWidth gateBound : ) :
                              Description inputWidth gateBound Fin (gateBound + 1) × (Fin gateBoundGateSlot (referenceWidth inputWidth gateBound))

                              Product view used to enumerate bounded descriptions exactly.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                @[instance_reducible]
                                noncomputable instance Complexity.CircuitCode.FixedWidth.instFintypeDescription (inputWidth gateBound : ) :
                                Fintype (Description inputWidth gateBound)
                                Equations
                                • One or more equations did not get rendered due to their size.
                                def Complexity.CircuitCode.FixedWidth.Description.gateCountNat {inputWidth gateBound : } (description : Description inputWidth gateBound) :

                                Active gate count as a natural number.

                                Equations
                                Instances For
                                  def Complexity.CircuitCode.FixedWidth.Description.activeSlot {inputWidth gateBound : } (description : Description inputWidth gateBound) (index : Fin description.gateCountNat) :
                                  GateSlot (referenceWidth inputWidth gateBound)

                                  View an active slot through the full fixed slot array.

                                  Equations
                                  Instances For
                                    def Complexity.CircuitCode.FixedWidth.Description.toRawCircuit {inputWidth gateBound : } (description : Description inputWidth gateBound) :

                                    Existing raw-circuit syntax represented by the active slots.

                                    Equations
                                    Instances For
                                      def Complexity.CircuitCode.FixedWidth.Description.Positive {inputWidth gateBound : } (description : Description inputWidth gateBound) :

                                      The description has at least one active gate, hence a designated output.

                                      Equations
                                      Instances For
                                        def Complexity.CircuitCode.FixedWidth.Description.TopologicallyWellFormed {inputWidth gateBound : } (description : Description inputWidth gateBound) :

                                        Every active gate points to a primary input or an earlier active gate.

                                        Equations
                                        Instances For
                                          def Complexity.CircuitCode.FixedWidth.Description.CanonicallyPadded {inputWidth gateBound : } (description : Description inputWidth gateBound) :

                                          Every inactive slot is the canonical all-zero slot.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            def Complexity.CircuitCode.FixedWidth.Description.WellFormed {inputWidth gateBound : } (description : Description inputWidth gateBound) :

                                            Valid fixed-width descriptions are nonempty, topologically ordered, and canonically padded.

                                            Equations
                                            Instances For
                                              @[instance_reducible]
                                              instance Complexity.CircuitCode.FixedWidth.Description.instDecidablePositive {inputWidth gateBound : } (description : Description inputWidth gateBound) :
                                              Decidable description.Positive
                                              Equations
                                              @[instance_reducible]
                                              instance Complexity.CircuitCode.FixedWidth.Description.instDecidableTopologicallyWellFormed {inputWidth gateBound : } (description : Description inputWidth gateBound) :
                                              Equations
                                              @[instance_reducible]
                                              instance Complexity.CircuitCode.FixedWidth.Description.instDecidableCanonicallyPadded {inputWidth gateBound : } (description : Description inputWidth gateBound) :
                                              Equations
                                              @[instance_reducible]
                                              instance Complexity.CircuitCode.FixedWidth.Description.instDecidableWellFormed {inputWidth gateBound : } (description : Description inputWidth gateBound) :
                                              Decidable description.WellFormed
                                              Equations