Documentation

Provenance.SymCells

Codes as columns, and comparisons between them #

A code (Provenance.SymCode) is stored in 7 + k columns, k the number of parameter components: a flag saying whether the code is fresh, the value (or the gap's lower bound, the least value of the cut for the gap below it), a flag for the gap below the least value, the gap's upper bound and a flag for the gap above the greatest, two columns placing the code against its value – before it, at it or after it, which is what an order on cells reads – and the rank written in unary over the two constants 0 and ValueType.nonzero taken in increasing order (Sym.therm).

A comparison between two cells is a predicate over their columns (Sym.cellCmp), written in a small syntax of comparisons over columns, constants and the ambient context (Sym.SP) that compiles both to the general predicates (Sym.SP.toGen) and to the classical selections of a FILTER clause (Sym.SP.toSel). Its three-valued truth on the encodings of two codes is exactly that of the comparison between the values they stand for (Sym.eval3_cellCmp), unknown included: a comparison with the null is unknown whatever the code it is compared with.

Comparisons over columns, constants and the context #

inductive Sym.SA (T : Type) (c n : ℕ) :

An argument of a comparison: a constant, a column, or a value of the context.

Instances For
    Dependency graph
    def Sym.SA.eval {T : Type} {c n : ℕ} :
    SA T c n → Tuple T n → (Fin c → T) → T

    What an argument reads on a row in a context.

    Equations
    Instances For
      Dependency graph
      inductive Sym.SP (T : Type) (c n : ℕ) :

      A predicate of comparisons, the shape every translated comparison has.

      Instances For
        Dependency graph
        def Sym.SP.eval3 {T : Type} [ValueType T] {c n : ℕ} :
        SP T c n → Tuple T n → (Fin c → T) → Kleene

        Its three-valued truth.

        Equations
        Instances For
          Dependency graph
          def Sym.SA.toG {T : Type} {c n : ℕ} :
          SA T c n → TermGIn T c (ColKind.allReg n)

          An argument as a term of the general syntax over regular columns.

          Equations
          Instances For
            Dependency graph
            Dependency graph
            theorem Sym.SP.hasAggAtom_toGen {T : Type} [ValueType T] {c n : ℕ} (p : SP T c n) :

            A translated predicate reads no aggregate column.

            Dependency graph
            def Sym.SA.toT {T : Type} {n : ℕ} :
            SA T 0 n → Term T n

            An argument as a term of a classical selection, where there is no context.

            Equations
            Instances For
              Dependency graph
              def Sym.boolOf {T : Type} {n : ℕ} (op : CompOp) (t₁ t₂ : Term T n) :

              A comparison as a Boolean term.

              Equations
              Instances For
                Dependency graph
                def Sym.SP.toSel {T : Type} {n : ℕ} :
                SP T 0 n → Selection T n

                The predicate as a classical selection.

                Equations
                Instances For
                  Dependency graph

                  The columns of a code #

                  def Sym.sLo {T : Type} [ValueType T] :
                  T

                  The smaller of the two constants.

                  Equations
                  Instances For
                    Dependency graph
                    def Sym.sHi {T : Type} [ValueType T] :
                    T

                    The larger of the two constants.

                    Equations
                    Instances For
                      Dependency graph
                      def Sym.therm {T : Type} [ValueType T] (k r : ℕ) :
                      Fin k → T

                      A rank in unary: k columns, the first r holding the larger of the two constants and the others the smaller, so that the ranks are ordered as their columns are, lexicographically.

                      Equations
                      Instances For
                        Dependency graph
                        def Sym.wbFlag {T : Type} [ValueType T] :
                        WithBot T → T

                        Whether the gap is below the least value.

                        Equations
                        Instances For
                          Dependency graph
                          def Sym.wtVal {T : Type} [ValueType T] :
                          WithTop T → T

                          A gap's upper bound as a column (0 above the greatest value).

                          Equations
                          Instances For
                            Dependency graph
                            def Sym.wtFlag {T : Type} [ValueType T] :
                            WithTop T → T

                            Whether the gap is above the greatest value.

                            Equations
                            Instances For
                              Dependency graph
                              def Sym.upOf {T : Type} [ValueType T] (C : Finset T) (l : WithBot T) :

                              The gap's upper bound: the least non-null value of the cut above the lower bound.

                              Equations
                              Instances For
                                Dependency graph
                                def Sym.lval {T : Type} [ValueType T] (C : Finset T) :
                                WithBot T → T

                                A gap's lower bound as a column: the least value of the cut for the gap below it (0 if the cut holds no non-null value).

                                Equations
                                Instances For
                                  Dependency graph
                                  def Sym.posA {T : Type} [ValueType T] :
                                  Code T → T

                                  Where a code sits against its value column, first column: before it (a gap below the least value), at it (a concrete value), after it (a gap above its lower bound) read as (sLo, sLo), (sLo, sHi), (sHi, sLo).

                                  Equations
                                  Instances For
                                    Dependency graph
                                    def Sym.posB {T : Type} [ValueType T] :
                                    Code T → T

                                    The second column.

                                    Equations
                                    Instances For
                                      Dependency graph
                                      def Sym.enc {T : Type} [ValueType T] (C : Finset T) (k : ℕ) :
                                      Code T → Tuple T (7 + k)

                                      A code as 7 + k columns.

                                      Equations
                                      Instances For
                                        Dependency graph
                                        @[reducible, inline]
                                        abbrev Sym.iF (k : ℕ) :
                                        Fin (7 + k)

                                        The column of the fresh flag.

                                        Equations
                                        Instances For
                                          Dependency graph
                                          @[reducible, inline]
                                          abbrev Sym.iV (k : ℕ) :
                                          Fin (7 + k)

                                          The column of the value or of the gap's lower bound.

                                          Equations
                                          Instances For
                                            Dependency graph
                                            @[reducible, inline]
                                            abbrev Sym.iB (k : ℕ) :
                                            Fin (7 + k)

                                            The column of the below-the-least flag.

                                            Equations
                                            Instances For
                                              Dependency graph
                                              @[reducible, inline]
                                              abbrev Sym.iH (k : ℕ) :
                                              Fin (7 + k)

                                              The column of the gap's upper bound.

                                              Equations
                                              Instances For
                                                Dependency graph
                                                @[reducible, inline]
                                                abbrev Sym.iHB (k : ℕ) :
                                                Fin (7 + k)

                                                The column of the above-the-greatest flag.

                                                Equations
                                                Instances For
                                                  Dependency graph
                                                  @[reducible, inline]
                                                  abbrev Sym.iSA (k : ℕ) :
                                                  Fin (7 + k)

                                                  The first column placing the code against its value.

                                                  Equations
                                                  Instances For
                                                    Dependency graph
                                                    @[reducible, inline]
                                                    abbrev Sym.iSB (k : ℕ) :
                                                    Fin (7 + k)

                                                    The second.

                                                    Equations
                                                    Instances For
                                                      Dependency graph
                                                      @[reducible, inline]
                                                      abbrev Sym.iR {k : ℕ} (j : Fin k) :
                                                      Fin (7 + k)

                                                      The j-th column of the rank.

                                                      Equations
                                                      Instances For
                                                        Dependency graph

                                                        Comparing two cells #

                                                        def Sym.isZ {T : Type} [ValueType T] {c n : ℕ} (a : SA T c n) :
                                                        SP T c n

                                                        The argument is 0.

                                                        Equations
                                                        Instances For
                                                          Dependency graph
                                                          def Sym.isN {T : Type} [ValueType T] {c n : ℕ} (a : SA T c n) :
                                                          SP T c n

                                                          The argument is ValueType.nonzero.

                                                          Equations
                                                          Instances For
                                                            Dependency graph
                                                            def Sym.wrap {T : Type} {c n : ℕ} (a : SA T c n) (Q : SP T c n) :
                                                            SP T c n

                                                            A comparison made strict in a concrete value: unknown where the value is null, Q elsewhere.

                                                            Equations
                                                            Instances For
                                                              Dependency graph
                                                              def Sym.orAll {T : Type} {c n : ℕ} :
                                                              List (SP T c n) → SP T c n

                                                              The disjunction of a list.

                                                              Equations
                                                              Instances For
                                                                Dependency graph
                                                                def Sym.andAll {T : Type} {c n : ℕ} :
                                                                List (SP T c n) → SP T c n

                                                                The conjunction of a list.

                                                                Equations
                                                                Instances For
                                                                  Dependency graph
                                                                  def Sym.isLo {T : Type} [ValueType T] {c n : ℕ} (a : SA T c n) :
                                                                  SP T c n

                                                                  The argument is the smaller constant.

                                                                  Equations
                                                                  Instances For
                                                                    Dependency graph
                                                                    def Sym.isHi {T : Type} [ValueType T] {c n : ℕ} (a : SA T c n) :
                                                                    SP T c n

                                                                    The argument is the larger constant.

                                                                    Equations
                                                                    Instances For
                                                                      Dependency graph
                                                                      def Sym.thLt {T : Type} [ValueType T] {c n k : ℕ} (x y : Fin (7 + k) → SA T c n) :
                                                                      SP T c n

                                                                      The first rank below the second.

                                                                      Equations
                                                                      Instances For
                                                                        Dependency graph
                                                                        def Sym.thEq {T : Type} {c n k : ℕ} (x y : Fin (7 + k) → SA T c n) :
                                                                        SP T c n

                                                                        The two ranks equal.

                                                                        Equations
                                                                        Instances For
                                                                          Dependency graph
                                                                          def Sym.ltCF {T : Type} [ValueType T] {c n k : ℕ} (a : SA T c n) (y : Fin (7 + k) → SA T c n) :
                                                                          SP T c n

                                                                          A concrete value below a fresh cell.

                                                                          Equations
                                                                          Instances For
                                                                            Dependency graph
                                                                            def Sym.ltFC {T : Type} [ValueType T] {c n k : ℕ} (x : Fin (7 + k) → SA T c n) (b : SA T c n) :
                                                                            SP T c n

                                                                            A fresh cell below a concrete value.

                                                                            Equations
                                                                            Instances For
                                                                              Dependency graph
                                                                              def Sym.ltFF {T : Type} [ValueType T] {c n k : ℕ} (x y : Fin (7 + k) → SA T c n) :
                                                                              SP T c n

                                                                              A fresh cell below another.

                                                                              Equations
                                                                              • One or more equations did not get rendered due to their size.
                                                                              Instances For
                                                                                Dependency graph
                                                                                def Sym.eqFF {T : Type} {c n k : ℕ} (x y : Fin (7 + k) → SA T c n) :
                                                                                SP T c n

                                                                                Two fresh cells equal.

                                                                                Equations
                                                                                Instances For
                                                                                  Dependency graph
                                                                                  def Sym.branchCF {T : Type} [ValueType T] {c n k : ℕ} (op : CompOp) (a : SA T c n) (y : Fin (7 + k) → SA T c n) :
                                                                                  SP T c n

                                                                                  A concrete value compared with a fresh cell.

                                                                                  Equations
                                                                                  Instances For
                                                                                    Dependency graph
                                                                                    def Sym.branchFC {T : Type} [ValueType T] {c n k : ℕ} (op : CompOp) (x : Fin (7 + k) → SA T c n) (b : SA T c n) :
                                                                                    SP T c n

                                                                                    A fresh cell compared with a concrete value.

                                                                                    Equations
                                                                                    Instances For
                                                                                      Dependency graph
                                                                                      def Sym.branchFF {T : Type} [ValueType T] {c n k : ℕ} (op : CompOp) (x y : Fin (7 + k) → SA T c n) :
                                                                                      SP T c n

                                                                                      Two fresh cells compared.

                                                                                      Equations
                                                                                      Instances For
                                                                                        Dependency graph
                                                                                        def Sym.cellCmp {T : Type} [ValueType T] {c n k : ℕ} (op : CompOp) (x y : Fin (7 + k) → SA T c n) :
                                                                                        SP T c n

                                                                                        Two cells compared: by their values where both are concrete, and through the bounds and ranks of the codes elsewhere.

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

                                                                                          What a comparison of cells reads #

                                                                                          The comparison of two cells is the comparison of their values #

                                                                                          def Sym.CodeOK {T : Type} [ValueType T] (C : Finset T) {k : ℕ} (par : Fin k → T) (x : Code T) :

                                                                                          The codes a cell may hold where the symbolic evaluation is faithful: the code of a fresh component, a value of the cut, or the null.

                                                                                          Equations
                                                                                          Instances For
                                                                                            Dependency graph
                                                                                            theorem Sym.eval3_cellCmp {T : Type} [ValueType T] {C : Finset T} {c n k : ℕ} {par : Fin k → T} (op : CompOp) (x y : Fin (7 + k) → SA T c n) (u : Tuple T n) (γ : Fin c → T) {cx cy : Code T} (hcx : CodeOK C par cx) (hcy : CodeOK C par cy) (hx : ∀ (i : Fin (7 + k)), (x i).eval u γ = enc C k cx i) (hy : ∀ (i : Fin (7 + k)), (y i).eval u γ = enc C k cy i) :
                                                                                            (cellCmp op x y).eval3 u γ = op.eval3 (dec C par cx) (dec C par cy)

                                                                                            The comparison of two cells is the comparison of the values they stand for, in all three truth values.

                                                                                            Dependency graph