The difference in place of the selection #
{∅, Π, −, apply, γ, win, μ^⊎} generates the whole algebra in the
minimal universe: a selection is an apply of its input with a closed test
that holds the empty tuple once where the predicate is true at the row and
nothing elsewhere. The tests are built from the difference alone, except
for the order: x < y is read by a window counting, over the relation
{x, y} (a bag recursion of one round), the rows strictly before y, and
that count is compared with 0 as a key, which Explode allows.
The classes of the basis with the difference in place of the
selection: ∅, Π, −, the apply, γ, win, μ^⊎.
Equations
Instances For
Dependency graph
Truth values as relations of arity 0 #
A relation read as the bag of its rows.
Equations
- DiffBasis.rows X = X
Instances For
Dependency graph
The value an expression names: a constant, or a position of the context.
Equations
- DiffBasis.val γ e = Sum.elim id γ e
Instances For
Dependency graph
The relation of arity 0 holding the empty tuple once where b
holds, and nothing elsewhere.
Instances For
Dependency graph
One row, of the value e names.
Equations
- DiffBasis.param1 e = AggQueryIn.Param (fun (x : Fin 1) => e) (ColKind.allReg 1)
Instances For
Dependency graph
Every row projected onto no column.
Equations
- DiffBasis.proj0 q = AggQueryIn.castKind ⋯ (AggQueryIn.Proj (fun (j : Fin 0) => j.elim0) q)
Instances For
Dependency graph
Dependency graph
The rows of X that are rows of Y, by two differences.
Equations
- DiffBasis.inter X Y = X.Diff (X.Diff Y)
Instances For
Dependency graph
Truth negated: the unit minus the test.
Equations
Instances For
Dependency graph
Both tests hold.
Equations
- DiffBasis.andT A B = DiffBasis.inter A B
Instances For
Dependency graph
One of the two tests holds.
Equations
- DiffBasis.orT A B = DiffBasis.notT (DiffBasis.andT (DiffBasis.notT A) (DiffBasis.notT B))
Instances For
Dependency graph
Equality and nulls #
The two values are equal.
Equations
- DiffBasis.eqT a b = DiffBasis.proj0 (DiffBasis.inter (DiffBasis.param1 a) (DiffBasis.param1 b))
Instances For
Dependency graph
The value is not null.
Equations
- DiffBasis.nnT a = match ValueType.nullVal with | none => AggQueryIn.unitC | some ν => DiffBasis.notT (DiffBasis.eqT a (Sum.inl ν))
Instances For
Dependency graph
The order #
An expression read one position further in, past the row of an apply's left side.
Equations
- DiffBasis.liftE e = Sum.map id (Fin.natAdd 1) e
Instances For
Dependency graph
The round of the recursion building {a, b}: the row of b, once
per row of the recursive relation other than b.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
Dependency graph
{a, b} – {a} where the two are equal – as a bag recursion of
one round from a.
Equations
- DiffBasis.pairZ s a b = AggQueryIn.Mu s (DiffBasis.param1 a) (DiffBasis.stepBody s b)
Instances For
Dependency graph
A way to build {a, b} from two expressions, at every context.
Equations
- DiffBasis.PairQ T = ({C : ℕ} → T ⊕ Fin C → T ⊕ Fin C → AggQueryIn T C 1 (ColKind.allReg 1))
Instances For
Dependency graph
What {a, b} is asked: defined everywhere, {a} where the two
are equal and {a, b} otherwise.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
{a, b} by a bag recursion of one round.
Equations
- DiffBasis.prZ s a b = DiffBasis.pairZ s a b
Instances For
Dependency graph
The frame of the rows strictly before the current one, its peers and itself excluded.
Equations
- DiffBasis.beforeW = { cond := FrameCond.lt (OrderSpec.asc 1), self := false }
Instances For
Dependency graph
Dependency graph
Dependency graph
Whether a sorts strictly before b, ascending.
Equations
- DiffBasis.ltO a b = (OrderSpec.asc 1).lt (fun (x : Fin 1) => a) fun (x : Fin 1) => b
Instances For
Dependency graph
Dependency graph
{a, b} with, on each row, the number of rows strictly before it,
the count read as a key.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The value an expression names, as a term.
Equations
Instances For
Dependency graph
Each row's count, beside the value b.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
a < b, nulls aside: the row of b in {a, b} has a row strictly
before it.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
Dependency graph
Comparisons, in Kleene's logic #
The comparison holds, read two-valued: the order through ltT, the
equalities through eqT.
Equations
- DiffBasis.opE cnt pr CompOp.eq a b = DiffBasis.eqT a b
- DiffBasis.opE cnt pr CompOp.syneq a b = DiffBasis.eqT a b
- DiffBasis.opE cnt pr CompOp.ne a b = DiffBasis.notT (DiffBasis.eqT a b)
- DiffBasis.opE cnt pr CompOp.synne a b = DiffBasis.notT (DiffBasis.eqT a b)
- DiffBasis.opE cnt pr CompOp.lt a b = DiffBasis.ltT cnt (fun {C : ℕ} => pr) a b
- DiffBasis.opE cnt pr CompOp.gt a b = DiffBasis.ltT cnt (fun {C : ℕ} => pr) b a
- DiffBasis.opE cnt pr CompOp.le a b = DiffBasis.notT (DiffBasis.ltT cnt (fun {C : ℕ} => pr) b a)
- DiffBasis.opE cnt pr CompOp.ge a b = DiffBasis.notT (DiffBasis.ltT cnt (fun {C : ℕ} => pr) a b)
Instances For
Dependency graph
A comparison's truth and falsity: for a null-strict one, both
values non-null and the comparison, or its negation; for IS [NOT] DISTINCT FROM, equality, which is never unknown.
Equations
- One or more equations did not get rendered due to their size.
- DiffBasis.cmpTF cnt pr CompOp.syneq a b = (DiffBasis.eqT a b, DiffBasis.notT (DiffBasis.eqT a b))
- DiffBasis.cmpTF cnt pr CompOp.synne a b = (DiffBasis.notT (DiffBasis.eqT a b), DiffBasis.eqT a b)
Instances For
Dependency graph
Predicates #
A term of the minimal signature as an expression of the test's context, the row of the selection's input coming first.
Equations
- DiffBasis.termE (TermGIn.const a) = Sum.inl a
- DiffBasis.termE (TermGIn.outer j) = Sum.inr (Fin.natAdd n j)
- DiffBasis.termE (TermGIn.index k a) = Sum.inr (Fin.castAdd c k)
- DiffBasis.termE (TermGIn.provIndex k a) = Sum.inr (Fin.castAdd c k)
- DiffBasis.termE x✝ = Sum.inl 0
Instances For
Dependency graph
The test of a predicate, true and false: the first holds the empty tuple where the predicate is true at the row, the second where it is false.
Equations
- One or more equations did not get rendered due to their size.
- DiffBasis.predTF cnt pr (GenPredIn.cmp op t₁ t₂) = DiffBasis.cmpTF cnt (fun {C : ℕ} => pr) op (DiffBasis.termE t₁) (DiffBasis.termE t₂)
- DiffBasis.predTF cnt pr (GenPredIn.aggCmp k a op t) = DiffBasis.cmpTF cnt (fun {C : ℕ} => pr) op (Sum.inr (Fin.castAdd c k)) (DiffBasis.termE t)
- DiffBasis.predTF cnt pr φ.not = ((DiffBasis.predTF cnt (fun {C : ℕ} => pr) φ).2, (DiffBasis.predTF cnt (fun {C : ℕ} => pr) φ).1)
Instances For
Dependency graph
The tests are in the fragment #
The classes every test uses: ∅, Π, −, γ and win; the pair
{a, b} adds its own.
Instances For
Dependency graph
What a closed test is asked: its classes, its signature, a schema
satisfying Q, no relation mentioned, and defined everywhere.
- uses : AggQueryIn.usesOnly S q
- sig : AggQueryIn.inSig Θ q
- over (sch : Schema) : Q sch → AggQueryIn.overSchema sch q
- noM (x : String) : AggQueryIn.noMention x q
- preg : q.paramsReg
Instances For
Dependency graph
A pair construction whose pairs are in the fragment.
Equations
- DiffBasis.PairOK S Θ Q pr = ∀ {C : ℕ} (a b : T ⊕ Fin C), DiffBasis.TestOK S Θ Q (pr a b)
Instances For
Dependency graph
A selection as an apply #
Dependency graph
A selection written with the apply: each row of the input meets the test of the predicate at that row, which holds the empty tuple once where the predicate is true and nothing elsewhere.
Equations
- DiffBasis.selX cnt pr φ q = AggQueryIn.castKind ⋯ (q.Apply (DiffBasis.predTF cnt (fun {C : ℕ} => pr) φ).1)
Instances For
Dependency graph
Dependency graph
The pass #
The basis with the difference #
{∅, Π, −, apply, γ, win, μ^⊎} generates the whole algebra in the
minimal universe: every query of the algebra over a schema, in the
signature with a count as its only aggregate, is matched by one over those
seven classes, defined and equal wherever the query is. First the query is
matched over {∅, Π, σ, apply, γ, win, μ^⊎} (basisRecOps_generatesOnRec),
then each selection of the match becomes an apply of its test
(DiffBasis.exists_selPass), the order being read by a window and its
count compared as a key.
Dependency graph
basisRecDiffOps is a basis of the whole algebra in the minimal
universe over ℕ: it generates over every schema, and no proper subset
does.