Documentation

Complexitylib.Circuits.ExactFourier.Internal.SlotAssembly

Exact Fourier circuits: slot assembly #

Adapted from OpenAI's formalization at revision adc7f1241b42e322a6451854ab7e4b4c146bf78a. Source: https://github.com/openai/math/blob/adc7f1241b42e322a6451854ab7e4b4c146bf78a/lean/OAI/Computability/FourierCircuit/SlotAssembly.lean

Imports, namespaces, module visibility, documentation, and formatting are adapted for complexitylib. The source theorem statements and mathematical arguments are retained.

@[reducible, inline]

The collection of copies of each species in an inventory.

Equations
Instances For
    @[reducible, inline]
    abbrev Complexity.ExactFourier.Packing.ActiveSpace {τ : Type} (D : τ → Type) (k : τ → ℕ) :

    The dependent coordinate space of all active species copies.

    Equations
    Instances For
      def Complexity.ExactFourier.Packing.inventoryMatrix {τ : Type} [DecidableEq τ] {D : τ → Type} {A : (t : τ) → Matrix (D t) (D t) ℂ} (k : τ → ℕ) :

      The block diagonal action of every matrix copy in the active inventory.

      Equations
      Instances For
        theorem Complexity.ExactFourier.Packing.layer_decompose {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} {π : Type} [Fintype π] [DecidableEq π] {β : π → Type} [(p : π) → Fintype (β p)] [(p : π) → DecidableEq (β p)] (S : (p : π) → Step D A (β p)) :
        (Matrix.blockDiagonal' fun (p : π) => (S p).matrix) = (Matrix.blockDiagonal' fun (p : π) => (S p).monoPart) * Embedded.matrix (Embedded.sigmaEmbed fun (p : π) => (S p).activeTuple) (Matrix.blockDiagonal' fun (p : π) => optionalMatrix A (S p).kind)
        theorem Complexity.ExactFourier.Packing.gather_active {τ : Type} [Fintype τ] [DecidableEq τ] {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} {π : Type} [Fintype π] [DecidableEq π] {β : π → Type} [(p : π) → Fintype (β p)] [(p : π) → DecidableEq (β p)] (k : τ → ℕ) (S : (p : π) → Step D A (β p)) (hc : ∀ (t : τ), Fintype.card { p : π // (S p).kind = some t } = k t) :
        ∃ (e : ActiveSpace D k ↪ (p : π) × β p), Embedded.matrix e (inventoryMatrix k) = Embedded.matrix (Embedded.sigmaEmbed fun (p : π) => (S p).activeTuple) (Matrix.blockDiagonal' fun (p : π) => optionalMatrix A (S p).kind)
        def Complexity.ExactFourier.Packing.inventoryWithIdentity {τ : Type} [DecidableEq τ] {D : τ → Type} {A : (t : τ) → Matrix (D t) (D t) ℂ} {ν : Type} [DecidableEq ν] (k : τ → ℕ) :

        Extend the active inventory matrix by an identity block of spare coordinates.

        Equations
        Instances For
          theorem Complexity.ExactFourier.Packing.assemble_slot {τ : Type} [Fintype τ] [DecidableEq τ] {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} {π : Type} [Fintype π] [DecidableEq π] {β : π → Type} [(p : π) → Fintype (β p)] [(p : π) → DecidableEq (β p)] {ν : Type} [Fintype ν] [DecidableEq ν] (k : τ → ℕ) (S : (p : π) → Step D A (β p)) (hc : ∀ (t : τ), Fintype.card { p : π // (S p).kind = some t } = k t) (hw : Fintype.card (ActiveSpace D k ⊕ ν) ≤ Fintype.card ((p : π) × β p)) :
          ∃ (M : Matrix ((p : π) × β p) ((p : π) × β p) ℂ) (e : ActiveSpace D k ⊕ ν ↪ (p : π) × β p), MonomialMatrix M ∧ (Matrix.blockDiagonal' fun (p : π) => (S p).matrix) = M * Embedded.matrix e (inventoryWithIdentity k)

          One full slot, with spectators carrying arbitrary data, is exactly one J call.

          @[reducible, inline]

          A species' coordinate type, with a singleton for the identity species.

          Equations
          Instances For
            @[instance_reducible]
            instance Complexity.ExactFourier.Packing.speciesDomainFintype {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] (s : Option τ) :
            Equations
            • One or more equations did not get rendered due to their size.
            @[instance_reducible]
            instance Complexity.ExactFourier.Packing.speciesDomainDecidableEq {τ : Type} {D : τ → Type} [(t : τ) → DecidableEq (D t)] (s : Option τ) :
            Equations
            • One or more equations did not get rendered due to their size.
            def Complexity.ExactFourier.Packing.speciesMatrix {τ : Type} {D : τ → Type} {A : (t : τ) → Matrix (D t) (D t) ℂ} (s : Option τ) :

            The species matrix, using a one-coordinate identity for the absent species.

            Equations
            Instances For
              @[reducible, inline]
              abbrev Complexity.ExactFourier.Packing.speciesCopies {τ : Type} (k : τ → ℕ) (I : ℕ) :
              Option τ → ℕ

              The number of copies of an active species or of the identity species.

              Equations
              Instances For
                @[reducible, inline]
                abbrev Complexity.ExactFourier.Packing.SpeciesSpace {τ : Type} (D : τ → Type) (k : τ → ℕ) (I : ℕ) :

                Coordinates grouped by species, copy index, and coordinate within a copy.

                Equations
                Instances For
                  def Complexity.ExactFourier.Packing.speciesCoordinates {τ : Type} {D : τ → Type} (k : τ → ℕ) (I : ℕ) :

                  Regroup active inventory and spare coordinates by their optional species.

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

                    A pair of optional species with at least one active member.

                    Equations
                    Instances For
                      @[reducible, inline]

                      The product coordinate type for a live pair of species.

                      Equations
                      Instances For
                        def Complexity.ExactFourier.Packing.pairMatrix {τ : Type} {D : τ → Type} {A : (t : τ) → Matrix (D t) (D t) ℂ} (p : LivePair τ) :

                        The tensor product of the two matrices of a live species pair.

                        Equations
                        Instances For
                          @[reducible, inline]
                          abbrev Complexity.ExactFourier.Packing.LiveSpace {τ : Type} (D : τ → Type) (k : τ → ℕ) (I : ℕ) :

                          All copies of live pair coordinates in the tensor-square inventory.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            def Complexity.ExactFourier.Packing.liveCoordinates {τ : Type} {D : τ → Type} (k : τ → ℕ) (I : ℕ) :

                            Separate live pair coordinates from the identity-only tensor-square coordinates.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              structure Complexity.ExactFourier.Packing.Frame {τ : Type} (D : τ → Type) [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] (α : Type) [Fintype α] [DecidableEq α] :

                              A monomial factor followed in matrix-product order by one embedded species call.

                              • mono : Matrix α α ℂ

                                The monomial matrix factor attached to the call.

                              • monomial : MonomialMatrix self.mono
                              • type : τ

                                The species called by this frame.

                              • tuple : D self.type ↪ α

                                The ambient coordinates occupied by the species call.

                              Instances For
                                noncomputable def Complexity.ExactFourier.Packing.Frame.matrix {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} {α : Type} [Fintype α] [DecidableEq α] (f : Frame D α) :
                                Matrix α α ℂ

                                The product of the frame's monomial factor and its embedded species matrix.

                                Equations
                                Instances For
                                  def Complexity.ExactFourier.Packing.Frame.pre {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {α : Type} [Fintype α] [DecidableEq α] (M : Matrix α α ℂ) (hm : MonomialMatrix M) (f : Frame D α) :
                                  Frame D α

                                  Multiply an additional monomial factor into the front of a frame.

                                  Equations
                                  Instances For
                                    structure Complexity.ExactFourier.Packing.FramedWord {τ : Type} (D : τ → Type) [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] (α : Type) [Fintype α] [DecidableEq α] :

                                    A list of species-call frames together with a final monomial factor.

                                    • frames : List (Frame D α)

                                      The ordered list of monomial-and-call frames.

                                    • tail : Matrix α α ℂ

                                      The final monomial matrix in the word's product.

                                    • tail_monomial : MonomialMatrix self.tail
                                    Instances For
                                      noncomputable def Complexity.ExactFourier.Packing.FramedWord.matrix {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} {α : Type} [Fintype α] [DecidableEq α] (W : FramedWord D α) :
                                      Matrix α α ℂ

                                      Multiply all frame matrices in order and then the final monomial factor.

                                      Equations
                                      Instances For
                                        def Complexity.ExactFourier.Packing.FramedWord.types {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {α : Type} [Fintype α] [DecidableEq α] (W : FramedWord D α) :
                                        List τ

                                        The ordered sequence of species called by the frames.

                                        Equations
                                        Instances For
                                          def Complexity.ExactFourier.Packing.FramedWord.pre {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {α : Type} [Fintype α] [DecidableEq α] (M : Matrix α α ℂ) (hm : MonomialMatrix M) (W : FramedWord D α) :

                                          Absorb a leading monomial factor into the first frame or the final tail.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            @[simp]
                                            theorem Complexity.ExactFourier.Packing.FramedWord.matrix_pre {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} {α : Type} [Fintype α] [DecidableEq α] (M : Matrix α α ℂ) (hm : MonomialMatrix M) (W : FramedWord D α) :
                                            (pre M hm W).matrix = M * W.matrix
                                            @[simp]
                                            theorem Complexity.ExactFourier.Packing.FramedWord.types_pre {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {α : Type} [Fintype α] [DecidableEq α] (M : Matrix α α ℂ) (hm : MonomialMatrix M) (W : FramedWord D α) :
                                            (pre M hm W).types = W.types
                                            def Complexity.ExactFourier.Packing.Word.framed {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} {α : Type} [Fintype α] [DecidableEq α] :
                                            Word D A α → FramedWord D α

                                            Collect monomial steps into adjacent call frames and a final monomial tail.

                                            Equations
                                            Instances For
                                              @[simp]
                                              theorem Complexity.ExactFourier.Packing.Word.matrix_framed {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} {α : Type} [Fintype α] [DecidableEq α] (W : Word D A α) :
                                              @[simp]
                                              theorem Complexity.ExactFourier.Packing.Word.types_framed {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} {α : Type} [Fintype α] [DecidableEq α] (W : Word D A α) :
                                              def Complexity.ExactFourier.Packing.Frame.word {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} {α : Type} [Fintype α] [DecidableEq α] (f : Frame D α) :
                                              Word D A α

                                              Expand one frame into its monomial step and embedded species call.

                                              Equations
                                              Instances For
                                                @[simp]
                                                theorem Complexity.ExactFourier.Packing.Frame.matrix_word {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} {α : Type} [Fintype α] [DecidableEq α] (f : Frame D α) :
                                                def Complexity.ExactFourier.Packing.speciesWord {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} (s : Option τ) :

                                                The identity word or one full-coordinate call to the selected species.

                                                Equations
                                                Instances For
                                                  @[simp]
                                                  theorem Complexity.ExactFourier.Packing.speciesWord_matrix {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} (s : Option τ) :
                                                  noncomputable def Complexity.ExactFourier.Packing.standardPair {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} (p : LivePair τ) :
                                                  Word D A (PairDomain D p)

                                                  Realize a live pair by the standard tensor product of its species words.

                                                  Equations
                                                  Instances For
                                                    @[simp]
                                                    theorem Complexity.ExactFourier.Packing.standardPair_matrix {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} (p : LivePair τ) :
                                                    def Complexity.ExactFourier.Packing.pairBaseline {τ : Type} [DecidableEq τ] {D : τ → Type} [(t : τ) → Fintype (D t)] (p : LivePair τ) (t : τ) :

                                                    The number of calls to each species in the standard pair realization.

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For
                                                      @[simp]
                                                      theorem Complexity.ExactFourier.Packing.speciesWord_count {τ : Type} [DecidableEq τ] {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} (s : Option τ) (t : τ) :
                                                      @[simp]
                                                      theorem Complexity.ExactFourier.Packing.standardPair_count {τ : Type} [DecidableEq τ] {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} (p : LivePair τ) (t : τ) :
                                                      structure Complexity.ExactFourier.Packing.PairComparison {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} :

                                                      Exact two-factor comparison; identity factors have width one and zero price.

                                                      Instances For
                                                        def Complexity.ExactFourier.Packing.PairComparison.delta {τ : Type} [DecidableEq τ] {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} (c : PairComparison) (t : τ) :

                                                        The signed call savings relative to the standard pair realization.

                                                        Equations
                                                        Instances For
                                                          @[reducible, inline]

                                                          Extend species prices by assigning zero to the identity species.

                                                          Equations
                                                          Instances For
                                                            def Complexity.ExactFourier.Packing.pairPrice {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] (p : τ → ℝ) (s : LivePair τ) :

                                                            The standard tensor-product price of a live pair, weighted by coordinate dimensions.

                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            Instances For
                                                              theorem Complexity.ExactFourier.Packing.pair_baseline_price {τ : Type} [Fintype τ] [DecidableEq τ] {D : τ → Type} [(t : τ) → Fintype (D t)] (p : τ → ℝ) (s : LivePair τ) :
                                                              ∑ t : τ, p t * ↑(pairBaseline s t) = pairPrice p s
                                                              theorem Complexity.ExactFourier.Packing.comparison_ineq {τ : Type} [Fintype τ] [DecidableEq τ] {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} (p : τ → ℝ) (c : PairComparison) :
                                                              ∑ t : τ, p t * ↑(c.delta t) ≤ 0 ↔ pairPrice p c.pair ≤ Word.weight p c.word
                                                              @[reducible, inline]

                                                              The live pair consisting of one active species and the identity species.

                                                              Equations
                                                              Instances For

                                                                Adjoin a singleton coordinate factor without changing the coordinate space.

                                                                Equations
                                                                Instances For
                                                                  noncomputable def Complexity.ExactFourier.Packing.singleComparison {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} (t : τ) (W : Word D A (D t)) (hW : W.matrix = A t) :

                                                                  Regard any realization of one species as a comparison for its singleton pair.

                                                                  Equations
                                                                  • One or more equations did not get rendered due to their size.
                                                                  Instances For
                                                                    @[simp]
                                                                    theorem Complexity.ExactFourier.Packing.singleComparison_price {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} (p : τ → ℝ) (t : τ) (W : Word D A (D t)) (hW : W.matrix = A t) :
                                                                    @[simp]
                                                                    theorem Complexity.ExactFourier.Packing.singleComparison_weight {τ : Type} {D : τ → Type} [(t : τ) → Fintype (D t)] [(t : τ) → DecidableEq (D t)] {A : (t : τ) → Matrix (D t) (D t) ℂ} (p : τ → ℝ) (t : τ) (W : Word D A (D t)) (hW : W.matrix = A t) :