Documentation

WeightedNetKAT.WNKA.Explicit

@[simp]
theorem Listed.array_sum_eq_finset_sum {ι : Type u_1} {α : Type u_2} [Listed ι] [AddCommMonoid α] (f : ια) :
(Array.map f array).sum = i : Fin (size ι), f (decodeFin i)
structure WeightedNetKAT.EWNKA (F N 𝒮 Q : Type) [Semiring 𝒮] [Listed F] [Listed N] [Listed Q] :

An efficient version of [WNKA] that uses explicit matrices.

  • ι : EMatrix Unit Q 𝒮

    ι is the initial weightings.

  • δ : EMatrix Pk[F,N] Pk[F,N] (EMatrix Q Q 𝒮)

    δ is a family of transition functions δ[α,β] : Q → 𝒞 𝒮 Q indexed by packet pairs.

  • 𝒪 : EMatrix Pk[F,N] Pk[F,N] (EMatrix Q Unit 𝒮)

    𝒪 is a family of output weightings 𝒪[α,β] : 𝒞 𝒮 Q indexed by packet pairs. Note that we use 𝒪 instead of λ, since λ is the function symbol in Lean.

Instances For
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      def WeightedNetKAT.S. {𝒮 X Y : Type} [Listed X] [Listed Y] :
      EMatrix Unit X 𝒮EMatrix Unit Y 𝒮EMatrix Unit (X Y) 𝒮
      Equations
      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[simp]
          theorem WeightedNetKAT.S.Eι_eq_ι {𝒮 X Y : Type} [Listed X] [Listed Y] {m₁ : EMatrix Unit X 𝒮} {m₂ : EMatrix Unit Y 𝒮} {i : Unit} {j : X Y} :
          Eι[m₁,m₂] i j = m₁.asMatrix.fromCols m₂.asMatrix i j
          def WeightedNetKAT.S.E𝒪_lambda {𝒮 X Y : Type} [Listed X] [Listed Y] :
          EMatrix X Unit 𝒮EMatrix Y Unit 𝒮EMatrix (X Y) Unit 𝒮
          Equations
          Instances For
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              @[simp]
              theorem WeightedNetKAT.S.E𝒪_lambda_eq_𝒪 {𝒮 X Y : Type} [Listed X] [Listed Y] {m₁ : EMatrix X Unit 𝒮} {m₂ : EMatrix Y Unit 𝒮} {i : X Y} {j : Unit} :
              E𝒪_lambda[m₁,m₂] i j = m₁.asMatrix.fromRows m₂.asMatrix i j
              theorem WeightedNetKAT.S.E𝒪_lambda_eq_𝒪' {𝒮 X Y : Type} [Listed X] [Listed Y] {m₁ : Matrix X Unit 𝒮} {m₂ : Matrix Y Unit 𝒮} {i : X Y} {j : Unit} :
              def WeightedNetKAT.S.Eδ_delta {𝒮 : Type} {X : Type u_1} {Y : Type u_2} {Z : Type u_3} {W : Type u_4} [Listed X] [Listed Y] [Listed Z] [Listed W] :
              EMatrix X Y 𝒮EMatrix X W 𝒮EMatrix Z Y 𝒮EMatrix Z W 𝒮EMatrix (X Z) (Y W) 𝒮
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  @[simp]
                  theorem WeightedNetKAT.S.Eδ_delta_eq_δ {𝒮 : Type} {X : Type u_1} {Y : Type u_2} {Z : Type u_3} {W : Type u_4} [Listed X] [Listed Y] [Listed Z] [Listed W] (mxy : EMatrix X Y 𝒮) (mxw : EMatrix X W 𝒮) (mzy : EMatrix Z Y 𝒮) (mzw : EMatrix Z W 𝒮) {i : X Z} {j : Y W} :
                  @[reducible, inline]
                  abbrev WeightedNetKAT.Eη₂ {𝒮 : Type} [Semiring 𝒮] {X Y : Type} [instX : Listed X] [instY : Listed Y] (i : X) (j : Y) :
                  EMatrix X Y 𝒮
                  Equations
                  Instances For
                    def WeightedNetKAT.boxₑ {Pk : Type} [Listed Pk] {X : Type u_1} [Listed X] {Q : Type} [Mul Q] [AddCommMonoid Q] {Z : Type} [Listed Z] [Unique Z] (l : EMatrix Z X Q) (r : EMatrix Pk Pk (EMatrix X Z Q)) :
                    EMatrix Pk Pk Q
                    Equations
                    Instances For
                      @[simp]
                      theorem Liste.decodeFin_unique {α : Type u_1} [Listed α] [Unique α] (i : Li[α]) :
                      @[simp]
                      theorem WeightedNetKAT.boxₑ_eq_box {Pk : Type} [Listed Pk] {X : Type u_1} [Listed X] [Fintype X] {Q : Type} [Mul Q] [AddCommMonoid Q] {Z : Type} [Listed Z] [Unique Z] (l : EMatrix Z X Q) (r : EMatrix Pk Pk (EMatrix X Z Q)) :
                      def WeightedNetKAT.foxₑ {Pk : Type} [Listed Pk] {A B C Q : Type} [AddCommMonoid Q] [Mul Q] [Listed A] [Listed B] [Listed C] (l : EMatrix A B Q) (r : EMatrix Pk Pk (EMatrix B C Q)) :
                      EMatrix Pk Pk (EMatrix A C Q)
                      Equations
                      Instances For
                        @[simp]
                        theorem WeightedNetKAT.foxₑ_eq_fox {Pk : Type} [Listed Pk] {A B C Q : Type} [AddCommMonoid Q] [Mul Q] [Listed A] [Listed B] [Listed C] [Fintype A] [Fintype B] [Fintype C] (l : EMatrix A B Q) (r : EMatrix Pk Pk (EMatrix B C Q)) :
                        @[inline, specialize #[]]
                        def WeightedNetKAT.soxₑ {Pk : Type} [Listed Pk] {A B Q : Type} [AddCommMonoid Q] [Mul Q] [Listed A] [Listed B] (l : EMatrix Pk Pk Q) (r : EMatrix Pk Pk (EMatrix A B Q)) :
                        EMatrix Pk Pk (EMatrix A B Q)
                        Equations
                        Instances For
                          @[simp]
                          theorem WeightedNetKAT.soxₑ_eq_sox {Pk : Type} [Listed Pk] {A B Q : Type} [AddCommMonoid Q] [Mul Q] [Listed A] [Listed B] [Fintype A] [Fintype B] [Fintype Pk] (l : EMatrix Pk Pk Q) (r : EMatrix Pk Pk (EMatrix A B Q)) :
                          def WeightedNetKAT.sox'ₑ {Pk : Type} [Listed Pk] {A B Q : Type} [AddCommMonoid Q] [Mul Q] [Listed A] [Listed B] (l : EMatrix Pk Pk (EMatrix A B Q)) (r : EMatrix Pk Pk Q) :
                          EMatrix Pk Pk (EMatrix A B Q)
                          Equations
                          Instances For
                            @[simp]
                            theorem WeightedNetKAT.sox'ₑ_eq_sox' {Pk : Type} [Listed Pk] {A B Q : Type} [AddCommMonoid Q] [Mul Q] [Listed A] [Listed B] [Fintype A] [Fintype B] [Fintype Pk] (l : EMatrix Pk Pk (EMatrix A B Q)) (r : EMatrix Pk Pk Q) :
                            def WeightedNetKAT.croxₑ {Pk : Type} [Listed Pk] {A B C Q : Type} [AddCommMonoid Q] [Mul Q] [Listed A] [Listed B] [DecidableEq C] [Listed C] (l : EMatrix Pk Pk (EMatrix A B Q)) (r : EMatrix Pk Pk (EMatrix B C Q)) :
                            EMatrix Pk Pk (EMatrix A C Q)
                            Equations
                            Instances For
                              @[simp]
                              theorem WeightedNetKAT.croxₑ_eq_crox {Pk : Type} [Listed Pk] {A B C Q : Type} [AddCommMonoid Q] [Mul Q] [Listed A] [Listed B] [DecidableEq C] [Listed C] [Fintype A] [Fintype B] [Fintype C] [Fintype Pk] (l : EMatrix Pk Pk (EMatrix A B Q)) (r : EMatrix Pk Pk (EMatrix B C Q)) :
                              def WeightedNetKAT.RPol.E𝒪_lambda {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [KStar 𝒮] [Listed N] (p : RPol 𝒮) :
                              EMatrix Pk[F,N] Pk[F,N] (EMatrix (S p) Unit 𝒮)
                              Equations
                              Instances For
                                def WeightedNetKAT.RPol.E𝒪_heart {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [KStar 𝒮] [Listed N] [DecidableEq N] (p₁ : RPol 𝒮) :
                                Equations
                                Instances For
                                  theorem WeightedNetKAT.RPol.E𝒪_lambda_iter {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [KStar 𝒮] [Listed N] [DecidableEq N] (p₁ : RPol 𝒮) :
                                  @[simp]
                                  theorem WeightedNetKAT.RPol.EMatrix.asMatrix_one {X : Type u_1} {α : Type u_2} [Listed X] [DecidableEq X] [Zero α] [One α] :
                                  @[simp]
                                  theorem WeightedNetKAT.RPol.Eι_eq_ι {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] {p : RPol 𝒮} :
                                  theorem EMatrix.apply_encodeFin {m : Type u_1} {n : Type u_2} {α : Type u_3} [Listed m] [Listed n] {M : NMatrix (Listed.size m) (Listed.size n) α} {i : m} {j : n} :
                                  def WeightedNetKAT.RPol.ι_aux {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] (p : RPol 𝒮) :
                                  Matrix Unit (S p) 𝒮
                                  Equations
                                  Instances For
                                    def WeightedNetKAT.RPol.𝒪_aux {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [KStar 𝒮] [Listed N] (p : RPol 𝒮) :
                                    Matrix Pk[F,N] Pk[F,N] (Matrix (S p) Unit 𝒮)
                                    Equations
                                    Instances For
                                      def WeightedNetKAT.RPol.Eδ_delta {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [KStar 𝒮] [Listed N] [DecidableEq N] (p : RPol 𝒮) :
                                      EMatrix Pk[F,N] Pk[F,N] (EMatrix (S p) (S p) 𝒮)
                                      Equations
                                      Instances For
                                        def WeightedNetKAT.RPol.δ_aux {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [KStar 𝒮] [Listed N] [DecidableEq N] (p : RPol 𝒮) :
                                        Matrix Pk[F,N] Pk[F,N] (Matrix (S p) (S p) 𝒮)
                                        Equations
                                        Instances For
                                          def WeightedNetKAT.RPol.ewnka {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [KStar 𝒮] [Listed N] [DecidableEq N] (p : RPol 𝒮) :
                                          EWNKA[F,N,𝒮,S p]
                                          Equations
                                          Instances For
                                            def WeightedNetKAT.WNKA.toEWNKA {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] {Q : Type} [Listed Q] (𝔄 : WNKA[F,N,𝒮,Q]) :
                                            EWNKA[F,N,𝒮,Q]
                                            Equations
                                            Instances For
                                              def WeightedNetKAT.EWNKA.toWNKA {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] {Q : Type} [Listed Q] (𝔈 : EWNKA[F,N,𝒮,Q]) :
                                              WNKA[F,N,𝒮,Q]
                                              Equations
                                              Instances For
                                                @[simp]
                                                theorem WeightedNetKAT.WNKA.toWNKA_toEWNKA {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] {Q : Type} [Listed Q] (𝔄 : WNKA[F,N,𝒮,Q]) :
                                                𝔄.toEWNKA.toWNKA = 𝔄
                                                @[simp]
                                                theorem WeightedNetKAT.EWNKA.toEWNKA_toWNKA {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] {Q : Type} [Listed Q] (𝔈 : EWNKA[F,N,𝒮,Q]) :
                                                𝔈.toWNKA.toEWNKA = 𝔈
                                                def WeightedNetKAT.RPol.wnka_fast {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] [DecidableEq N] [KStar 𝒮] (p : RPol 𝒮) :
                                                WNKA[F,N,𝒮,S p]
                                                Equations
                                                Instances For
                                                  @[simp]
                                                  def WeightedNetKAT.EWNKA.toEWNKA_ι_apply {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] {Q : Type} [Listed Q] (𝔈 : EWNKA[F,N,𝒮,Q]) {α : Unit} {β : Q} :
                                                  𝔈.toWNKA.ι α β = 𝔈.ι α β
                                                  Equations
                                                  • =
                                                  Instances For
                                                    @[simp]
                                                    def WeightedNetKAT.EWNKA.toEWNKA_δ_apply {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] {Q : Type} [Listed Q] (𝔈 : EWNKA[F,N,𝒮,Q]) {α β : Pk[F,N]} :
                                                    𝔈.toWNKA.δ α β = (𝔈.δ α β).asMatrix
                                                    Equations
                                                    • =
                                                    Instances For
                                                      @[simp]
                                                      def WeightedNetKAT.EWNKA.toEWNKA_𝒪_apply {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] {Q : Type} [Listed Q] (𝔈 : EWNKA[F,N,𝒮,Q]) {α β : Pk[F,N]} :
                                                      𝔈.toWNKA.𝒪 α β = (𝔈.𝒪 α β).asMatrix
                                                      Equations
                                                      • =
                                                      Instances For
                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          def WeightedNetKAT.EWNKA.sem {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] {Q : Type} [Listed Q] [DecidableEq N] (𝒜 : EWNKA[F,N,𝒮,Q]) :
                                                          GS F N →c 𝒮
                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For
                                                            structure WeightedNetKAT.EWNKA.Precompute {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] {Q : Type} [Listed Q] (𝔈 : EWNKA[F,N,𝒮,Q]) :

                                                            Stores partial computation of the weight of a trace.

                                                            We want to compute the prefix as little as possible, and reuse it the final computation with 𝒪. This structure turned out to be crucial for performance, as Lean would push the computation of the prefix into the lambda where the final β was given, leading it to recomputing the prefix for every final packet.

                                                            This gives roughly a |Pk[F,N]| times speed up.

                                                            Instances For
                                                              @[inline, specialize #[]]
                                                              def WeightedNetKAT.EWNKA.Precompute.finish {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] {Q : Type} [Listed Q] {𝔈 : EWNKA[F,N,𝒮,Q]} (p : 𝔈.Precompute) (β : Pk[F,N]) :
                                                              𝒮
                                                              Equations
                                                              Instances For
                                                                @[noinline, specialize #[]]
                                                                def WeightedNetKAT.EWNKA.semArray_aux {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] {Q : Type} [Listed Q] (𝒜 : EWNKA[F,N,𝒮,Q]) (α_xs : Array Pk[F,N]) (h : 0 < α_xs.size) :
                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For
                                                                  @[inline, specialize #[]]
                                                                  def WeightedNetKAT.EWNKA.semArray {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] {Q : Type} [Listed Q] (𝒜 : EWNKA[F,N,𝒮,Q]) (α_xs : Array Pk[F,N]) (h : 0 < α_xs.size) :
                                                                  Equations
                                                                  Instances For
                                                                    theorem WeightedNetKAT.EWNKA.semArray_eq_sem {F : Type} [Listed F] {N 𝒮 : Type} [Semiring 𝒮] [Listed N] {Q : Type} [Listed Q] [DecidableEq N] {𝔈 : EWNKA[F,N,𝒮,Q]} {α_xs : Array Pk[F,N]} {β : Pk[F,N]} (h : 0 < α_xs.size) :
                                                                    (𝔈.semArray α_xs h).finish β = 𝔈.sem (α_xs.toList.head , α_xs.toList.tail, β)