Documentation

Provenance.WinRow

Windows are needed in every basis of the whole algebra #

win is in every basis of the whole algebra in the minimal universe. The witness is count(*) OVER (… EXCLUDE CURRENT ROW) on a unary relation holding n copies of one value, which writes n − 1 on every row. A window-free query of the minimal universe writes, on that family of instances and for n large, only values p(n) for finitely many polynomials p with natural coefficients, which n − 1 is not.

The polynomials are Mathlib's Polynomial ℕ; what the invariant needs of them is that two of them are eventually equal, or eventually strictly ordered one way, which is read off their real asymptotics.

The instance holding n copies of the row (1) in R.

Equations
Instances For
    Dependency graph

    The whole partition less the current row: ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW.

    Equations
    Instances For
      Dependency graph

      The witness: count(#1) OVER (EXCLUDE CURRENT ROW) on R.

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

        Eventual comparison of polynomials with natural coefficients #

        @[reducible, inline]

        A polynomial with natural coefficients, read as a function of n.

        Equations
        Instances For
          Dependency graph
          inductive WinRow.Poly.Cmp (p q : Poly) (N : ℕ) :

          How two polynomials compare from some point on.

          Instances For
            Dependency graph
            def WinRow.Decided (V : Set Poly) (N : ℕ) :

            Every pair of a finite set of polynomials is decided from N on.

            Equations
            Instances For
              Dependency graph

              Polynomial bags #

              A relation computed on the instance with n copies is, for n large, a bag of finitely many shapes: a row of polynomials, each repeated a polynomial number of times.

              structure WinRow.Shape (k : ℕ) :

              A shape: a row of polynomials with a polynomial multiplicity.

              Instances For
                Dependency graph
                def WinRow.Shape.rowAt {k : ℕ} (s : Shape k) (n : ℕ) :

                The row of a shape at n.

                Equations
                Instances For
                  Dependency graph
                  def WinRow.Shape.inst {k : ℕ} (s : Shape k) (n : ℕ) :

                  The copies of a shape at n.

                  Equations
                  Instances For
                    Dependency graph
                    @[reducible, inline]
                    abbrev WinRow.PolyBag (k : ℕ) :

                    A bag of shapes.

                    Equations
                    Instances For
                      Dependency graph
                      def WinRow.PolyBag.inst {k : ℕ} (L : PolyBag k) (n : ℕ) :

                      The relation a bag of shapes stands for at n.

                      Equations
                      Instances For
                        Dependency graph

                        The polynomials the rows of a bag hold.

                        Equations
                        Instances For
                          Dependency graph

                          The multiplicities of a bag.

                          Equations
                          Instances For
                            Dependency graph
                            noncomputable def WinRow.PolyBag.scale {k : ℕ} (m : Poly) (L : PolyBag k) :

                            Scaling every multiplicity.

                            Equations
                            Instances For
                              Dependency graph
                              def WinRow.PolyBag.mapRows {k k' : ℕ} (f : (Fin k → Poly) → Fin k' → Poly) (L : PolyBag k) :

                              Mapping the rows.

                              Equations
                              Instances For
                                Dependency graph
                                noncomputable def WinRow.PolyBag.bindShapes {k₁ k₂ : ℕ} (L₁ : PolyBag k₁) (F : Shape k₁ → PolyBag k₂) :
                                PolyBag (k₁ + k₂)

                                A bag of shapes under each shape, as an apply reads its right side.

                                Equations
                                Instances For
                                  Dependency graph

                                  Symbolic terms, and the shift from the threshold #

                                  A function-free term over a row of polynomials is a polynomial. A predicate over decided polynomials reads alike at the threshold and at every larger n, because the values at n are the image of the values at the threshold under a faithful map (Provenance.Genericity).

                                  def WinRow.ctxAt {c : ℕ} (cγ : Fin c → Poly) (n : ℕ) :
                                  Fin c → ℕ

                                  A context of polynomials at n.

                                  Equations
                                  Instances For
                                    Dependency graph

                                    The constants of a query as polynomials.

                                    Equations
                                    Instances For
                                      Dependency graph
                                      noncomputable def WinRow.TermIn.polyOf {c k : ℕ} (t : TermIn ℕ c k) (row : Fin k → Poly) (cγ : Fin c → Poly) :

                                      The polynomial a function-free term reads as.

                                      Equations
                                      Instances For
                                        Dependency graph
                                        noncomputable def WinRow.TermGIn.polyOf {c k : ℕ} {κ : Fin k → ColKind} (t : TermGIn ℕ c κ) (row : Fin k → Poly) (cγ : Fin c → Poly) :

                                        The polynomial a function-free term of the general syntax reads as.

                                        Equations
                                        Instances For
                                          Dependency graph
                                          noncomputable def WinRow.ProjColIn.polyOf {c k : ℕ} {κ : Fin k → ColKind} (p : ProjColIn ℕ c κ) (row : Fin k → Poly) (cγ : Fin c → Poly) :

                                          The polynomial a function-free projection column reads as.

                                          Equations
                                          Instances For
                                            Dependency graph

                                            The count polynomials of a query #

                                            A polynomial is a count polynomial of a query if, for n large, its value is one of the counts the query computes on the instance with n copies (AggQueryIn.countValsAll, over every context). There are finitely many, because the counts a query computes on that instance are at most a constant in number (AggQueryIn.exists_polyBound_countTypes over a base set of constant size).

                                            def WinRow.CountPolys {c k : ℕ} {κ : Fin k → ColKind} {l : List (String × ℕ)} (q : AggQueryIn ℕ c k κ l) :

                                            The count polynomials of a closed query.

                                            Equations
                                            Instances For
                                              Dependency graph
                                              def WinRow.CountPolysHole {c k : ℕ} {κ : Fin k → ColKind} {l : List (String × ℕ)} (q : AggQueryIn ℕ c k κ l) (s : String) (m : ℕ) :

                                              The count polynomials of a term with a hole, over every binding of it.

                                              Equations
                                              Instances For
                                                Dependency graph

                                                The base set of the instance family: the instance's value, the zero, and the query's constants.

                                                Equations
                                                Instances For
                                                  Dependency graph

                                                  The invariant's vocabulary #

                                                  def WinRow.Univ {c k : ℕ} {κ : Fin k → ColKind} {l : List (String × ℕ)} (q : AggQueryIn ℕ c k κ l) (cγ : Fin c → Poly) :

                                                  The values a closed query may write at a context of polynomials: its constants, the instance's value, the context, and its counts.

                                                  Equations
                                                  Instances For
                                                    Dependency graph
                                                    def WinRow.UnivHole {c k : ℕ} {κ : Fin k → ColKind} {l : List (String × ℕ)} (q : AggQueryIn ℕ c k κ l) (s : String) (m : ℕ) (cγ : Fin c → Poly) :

                                                    The same for a term with a hole, its counts taken over every binding.

                                                    Equations
                                                    Instances For
                                                      Dependency graph
                                                      def WinRow.ClosedSym {c k : ℕ} {κ : Fin k → ColKind} {l : List (String × ℕ)} (q : AggQueryIn ℕ c k κ l) (cγ : Fin c → Poly) :

                                                      The invariant for a closed query: for n large its result on the instance with n copies is a bag of shapes, with values in Univ, and whether it settles there does not depend on n.

                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For
                                                        Dependency graph
                                                        def WinRow.BodySym {c k : ℕ} {κ : Fin k → ColKind} {l : List (String × ℕ)} (q : AggQueryIn ℕ c k κ l) (s : String) (m : ℕ) (cγ : Fin c → Poly) (W : Set Poly) :

                                                        The invariant for a term with a hole: uniformly in the bag the hole is bound to, provided its values lie in a given finite set.

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

                                                          Bag lemmas the cases need #

                                                          Every multiplicity is the zero polynomial: the bag is empty at every n ≥ 1.

                                                          Equations
                                                          Instances For
                                                            Dependency graph
                                                            def WinRow.dedupAt {k : ℕ} (N : ℕ) :

                                                            Duplicate elimination at the threshold: one copy of each row the shapes of non-zero multiplicity have at N, the last of them kept.

                                                            Equations
                                                            Instances For
                                                              Dependency graph

                                                              Universe bookkeeping #

                                                              Counting the rows of a bag #

                                                              The invariant #

                                                              The row #

                                                              Windows are needed: win is in every basis of the whole algebra over ℕ with the counting aggregate.

                                                              Dependency graph