Documentation

WeightedNetKAT.WNKA.Explicit

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    def Listed.Li.getSum {α : Type u_1} {β : Type u_2} [Listed α] [Listed β] :
    Fin (size (α β)) Fin (size α) Fin (size β)
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      def Listed.Li.getProd {α : Type u_1} {β : Type u_2} [Listed α] [Listed β] :
      Fin (size (α × β)) Fin (size α) × Fin (size β)
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        theorem Listed.decodeFin_getSum {α : Type u_1} {β : Type u_2} [Listed α] [Listed β] (i : Fin (size (α β))) :
        theorem Listed.decodeFin_getProd {α : Type u_1} {β : Type u_2} [Listed α] [Listed β] (i : Fin (size (α × β))) :
        @[simp]
        theorem Listed.Li.getSum_encodeFin {α : Type u_1} {β : Type u_2} [Listed α] [Listed β] (i : α β) :
        @[simp]
        theorem Listed.Li.getProd_encodeFin {α : Type u_1} {β : Type u_2} [Listed α] [Listed β] (i : α × β) :
        @[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 : Type u_4) (N : Type u_5) (𝒮 : Type u_6) (Q : Type u_7) [Semiring 𝒮] [Listed F] [Listed N] [Listed Q] :
        Type u_6

        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.EC {𝒮 : Type u_3} {X : Type u_4} {Y : Type u_5} [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.EC_eq_C {𝒮 : Type u_3} {X : Type u_4} {Y : Type u_5} [Listed X] [Listed Y] {m₁ : EMatrix Unit X 𝒮} {m₂ : EMatrix Unit Y 𝒮} {i : Unit} {j : X Y} :
                EC[m₁,m₂] i j = m₁.asMatrix.fromCols m₂.asMatrix i j
                def WeightedNetKAT.S.ER {𝒮 : Type u_3} {X : Type u_4} {Y : Type u_5} [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.ER_eq_C {𝒮 : Type u_3} {X : Type u_4} {Y : Type u_5} [Listed X] [Listed Y] {m₁ : EMatrix X Unit 𝒮} {m₂ : EMatrix Y Unit 𝒮} {i : X Y} {j : Unit} :
                    ER[m₁,m₂] i j = m₁.asMatrix.fromRows m₂.asMatrix i j
                    def EMatrix.fromBlocks {𝒮 : Type u_3} {X : Type u_4} {Y : Type u_5} {Z : Type u_6} {W : Type u_7} [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
                    Instances For
                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        @[simp]
                        theorem WeightedNetKAT.S.EB_eq_δ {𝒮 : Type u_3} {X : Type u_4} {Y : Type u_5} {Z : Type u_6} {W : Type u_7} [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} :
                        EB[[mxy,mxw],[mzy,mzw]] i j = Matrix.fromBlocks mxy.asMatrix mxw.asMatrix mzy.asMatrix mzw.asMatrix i j
                        @[reducible, inline]
                        abbrev WeightedNetKAT.Eη₂ {𝒮 : Type u_3} [Semiring 𝒮] {X : Type u_4} {Y : Type u_5} [instX : Listed X] [instY : Listed Y] (i : X) (j : Y) :
                        EMatrix X Y 𝒮
                        Equations
                        Instances For
                          def WeightedNetKAT.boxₑ {Pk : Type u_4} [Listed Pk] {X : Type u_7} [Listed X] {Q : Type u_5} [Mul Q] [AddCommMonoid Q] {Z : Type u_6} [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_5} [Listed α] [Unique α] (i : Li[α]) :
                            @[simp]
                            theorem WeightedNetKAT.boxₑ_eq_box {Pk : Type u_4} [Listed Pk] {X : Type u_7} [Listed X] [Fintype X] {Q : Type u_5} [Mul Q] [AddCommMonoid Q] {Z : Type u_6} [Listed Z] [Unique Z] (l : EMatrix Z X Q) (r : EMatrix Pk Pk (EMatrix X Z Q)) :
                            def WeightedNetKAT.foxₑ {Pk : Type u_4} [Listed Pk] {A : Type u_5} {B : Type u_6} {C : Type u_7} {Q : Type u_8} [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 u_4} [Listed Pk] {A : Type u_5} {B : Type u_6} {C : Type u_7} {Q : Type u_8} [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 u_4} [Listed Pk] {A : Type u_5} {B : Type u_6} {Q : Type u_7} [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 u_4} [Listed Pk] {A : Type u_5} {B : Type u_6} {Q : Type u_7} [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 u_4} [Listed Pk] {A : Type u_5} {B : Type u_6} {Q : Type u_7} [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 u_4} [Listed Pk] {A : Type u_5} {B : Type u_6} {Q : Type u_7} [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 u_4} [Listed Pk] {A : Type u_5} {B : Type u_6} {C : Type u_7} {Q : Type u_8} [AddCommMonoid Q] [Mul Q] [Listed A] [Listed B] [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 u_4} [Listed Pk] {A : Type u_5} {B : Type u_6} {C : Type u_7} {Q : Type u_8} [AddCommMonoid Q] [Mul Q] [Listed A] [Listed B] [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.ER {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [KStar 𝒮] [Listed N] (p : RPol 𝒮) :
                                    EMatrix Pk[F,N] Pk[F,N] (EMatrix (S p) Unit 𝒮)
                                    Equations
                                    Instances For
                                      def WeightedNetKAT.RPol.ER_heart {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [KStar 𝒮] [Listed N] [DecidableEq N] (p₁ : RPol 𝒮) :
                                      Equations
                                      Instances For
                                        theorem WeightedNetKAT.RPol.ER_iter {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [KStar 𝒮] [Listed N] [DecidableEq N] (p₁ : RPol 𝒮) :
                                        wnk_rpol {~p₁*}.ER = EMatrix.ofFn fun (α β : Li[Pk[F,N]]) => ER[γ : Li[Pk[F,N]], MulOpposite.op (p₁.ER_heart.asNMatrix γ β) p₁.ER.asNMatrix α γ,EMatrix.ofFn fun (x x_1 : Li[Unit]) => p₁.ER_heart.asNMatrix α β]
                                        @[simp]
                                        theorem WeightedNetKAT.RPol.EMatrix.asMatrix_one {X : Type u_4} {α : Type u_5} [Listed X] [DecidableEq X] [Zero α] [One α] :
                                        @[simp]
                                        theorem WeightedNetKAT.RPol.EC_eq_C {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] {p : RPol 𝒮} :
                                        theorem EMatrix.apply_encodeFin {m : Type u_4} {n : Type u_5} {α : Type u_6} [Listed m] [Listed n] {M : NMatrix (Listed.size m) (Listed.size n) α} {i : m} {j : n} :
                                        @[simp]
                                        def WeightedNetKAT.RPol.ι_aux {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] (p : RPol 𝒮) :
                                        Matrix Unit (S p) 𝒮
                                        Equations
                                        Instances For
                                          def WeightedNetKAT.RPol.𝒪_aux {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [KStar 𝒮] [Listed N] (p : RPol 𝒮) :
                                          Matrix Pk[F,N] Pk[F,N] (Matrix (S p) Unit 𝒮)
                                          Equations
                                          Instances For
                                            def WeightedNetKAT.RPol.EB {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [KStar 𝒮] [Listed N] [DecidableEq N] (p : RPol 𝒮) :
                                            EMatrix Pk[F,N] Pk[F,N] (EMatrix (S p) (S p) 𝒮)
                                            Equations
                                            Instances For
                                              @[simp]
                                              def WeightedNetKAT.RPol.δ_aux {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [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 u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [KStar 𝒮] [Listed N] [DecidableEq N] (p : RPol 𝒮) :
                                                EWNKA[F,N,𝒮,S p]
                                                Equations
                                                Instances For
                                                  def WeightedNetKAT.WNKA.toEWNKA {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] {Q : Type u_4} [Listed Q] (𝔄 : WNKA[F,N,𝒮,Q]) :
                                                  EWNKA[F,N,𝒮,Q]
                                                  Equations
                                                  Instances For
                                                    def WeightedNetKAT.EWNKA.toWNKA {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] {Q : Type u_4} [Listed Q] (𝔈 : EWNKA[F,N,𝒮,Q]) :
                                                    WNKA[F,N,𝒮,Q]
                                                    Equations
                                                    Instances For
                                                      @[simp]
                                                      theorem WeightedNetKAT.WNKA.toWNKA_toEWNKA {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] {Q : Type u_4} [Listed Q] (𝔄 : WNKA[F,N,𝒮,Q]) :
                                                      𝔄.toEWNKA.toWNKA = 𝔄
                                                      @[simp]
                                                      theorem WeightedNetKAT.EWNKA.toEWNKA_toWNKA {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] {Q : Type u_4} [Listed Q] (𝔈 : EWNKA[F,N,𝒮,Q]) :
                                                      𝔈.toWNKA.toEWNKA = 𝔈
                                                      @[simp]
                                                      theorem WeightedNetKAT.RPol.wnka_toEWNKA {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [OmegaCompletePartialOrder 𝒮] [OrderBot 𝒮] [IsPositiveOrderedAddMonoid 𝒮] [Listed N] [DecidableEq F] [DecidableEq N] [KStar 𝒮] [LawfulKStar 𝒮] [KStarIter 𝒮] [MulLeftMono 𝒮] [MulRightMono 𝒮] [OmegaContinuousNonUnitalSemiring 𝒮] (p : RPol 𝒮) :
                                                      @[simp]
                                                      theorem WeightedNetKAT.RPol.ewnka_toWNKA {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [OmegaCompletePartialOrder 𝒮] [OrderBot 𝒮] [IsPositiveOrderedAddMonoid 𝒮] [Listed N] [DecidableEq F] [DecidableEq N] [KStar 𝒮] [LawfulKStar 𝒮] [KStarIter 𝒮] [MulLeftMono 𝒮] [MulRightMono 𝒮] [OmegaContinuousNonUnitalSemiring 𝒮] (p : RPol 𝒮) :
                                                      def WeightedNetKAT.RPol.wnka_fast {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] [DecidableEq N] [KStar 𝒮] (p : RPol 𝒮) :
                                                      WNKA[F,N,𝒮,S p]
                                                      Equations
                                                      Instances For
                                                        @[simp]
                                                        def WeightedNetKAT.EWNKA.toEWNKA_ι_apply {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] {Q : Type u_4} [Listed Q] (𝔈 : EWNKA[F,N,𝒮,Q]) {α : Unit} {β : Q} :
                                                        𝔈.toWNKA.ι α β = 𝔈.ι α β
                                                        Equations
                                                        • =
                                                        Instances For
                                                          @[simp]
                                                          def WeightedNetKAT.EWNKA.toEWNKA_δ_apply {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] {Q : Type u_4} [Listed Q] (𝔈 : EWNKA[F,N,𝒮,Q]) {α β : Pk[F,N]} :
                                                          𝔈.toWNKA.δ α β = (𝔈.δ α β).asMatrix
                                                          Equations
                                                          • =
                                                          Instances For
                                                            @[simp]
                                                            def WeightedNetKAT.EWNKA.toEWNKA_𝒪_apply {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] {Q : Type u_4} [Listed Q] (𝔈 : EWNKA[F,N,𝒮,Q]) {α β : Pk[F,N]} :
                                                            𝔈.toWNKA.𝒪 α β = (𝔈.𝒪 α β).asMatrix
                                                            Equations
                                                            • =
                                                            Instances For
                                                              def WeightedNetKAT.EWNKA.sem {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] {Q : Type u_4} [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 u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] {Q : Type u_4} [Listed Q] (𝔈 : EWNKA[F,N,𝒮,Q]) :
                                                                Type (max u_2 u_3)

                                                                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 u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] {Q : Type u_4} [Listed Q] {𝔈 : EWNKA[F,N,𝒮,Q]} (p : 𝔈.Precompute) (β : Pk[F,N]) :
                                                                  𝒮
                                                                  Equations
                                                                  Instances For
                                                                    @[noinline, specialize #[]]
                                                                    def WeightedNetKAT.EWNKA.semArray_aux {F : Type u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] {Q : Type u_4} [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 u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] {Q : Type u_4} [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 u_1} [Listed F] {N : Type u_2} {𝒮 : Type u_3} [Semiring 𝒮] [Listed N] {Q : Type u_4} [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, β)