Symbolic aggregate tokens #
AggValue T K is the symbolic aggregate token of the general HAVING
semantics: an aggregate function together with the ≼-sorted occurrence
payload of the originating group, projected to pairs (value of the
aggregated term, occurrence annotation) – exactly the data of
Having.havingGroup that the possible-world semantics of an aggregate
comparison consumes. It is the one-level analogue of KTensor
(deliberately un-quotiented, so the possible worlds of the group can be
read off the token); there is no recursion: ProvSQL rejects aggregation,
grouping and ordering over aggregate values, and likewise rejects
deduplication and difference on token-carrying relations, so no linear
order or decidable equality on tokens is required by any permitted
downstream operator (SeqAggFunc being a function type, structural
decidable equality would not be available anyway).
Readings of a token #
valOn– the aggregate value in one possible world of the group, matchingHaving.aggValOnon the originating group (valOn_ofGroup);specialize– the world-faithful reading: restrict to the occurrences whose annotation is realized by a valuation and aggregate those;collapse– the deterministic reading: aggregate the whole sequence. This is the value ProvSQL displays for an uncompared aggregate (the actual-world value, renderedv (*)), and the reading through which the data-part adequacy of the general evaluator is stated;predProv– the predicate provenance of a comparison against the token: the⊕-sum, over the non-empty possible worlds of the group, of the world annotation times the characteristic value of the comparison. On a token built from a group it coincides with the fused semantics'Having.havingProv(predProv_ofGroup) – the seed of the regression bridge between the general and the fused evaluators.
mapAnn pushes a function K → K' through the annotations of a token:
value-only readings are unchanged (collapse_mapAnn) and specialize
composes with the pushforward (specialize_mapAnn). This is the token
layer of the hom-commutation metatheorem for the general evaluator.
Lifted column values #
A column of a token-carrying relation holds either a regular value or a
token: T ⊕ AggValue T K. AggValue.mapAnnSum and AggValue.collapseSum
extend the pushforward and the deterministic reading to such lifted
values; the kind-indexed syntax of the general evaluator governs
statically which columns hold which arm.
A symbolic aggregate token: an aggregate function together with the (≼-sorted) occurrence payload of the originating group – for each occurrence, the value of the aggregated term paired with the occurrence annotation.
- agg : SeqAggFunc T
The sequence aggregate applied by every reading of the token.
The occurrence payload: values of the aggregated term paired with the occurrence annotations, in the group's ≼-order.
Instances For
Dependency graph
The token of a group with occurrence sequence U, aggregating the
term t with f: the projection of the group payload.
Equations
- AggValue.ofGroup f t U = { agg := f, occs := List.map (fun (p : AnnotatedTuple T K m) => (t.eval p.1, p.2)) U }
Instances For
Dependency graph
The occurrence annotations of a token, as a function on positions.
Instances For
Dependency graph
The aggregate value of the token in the possible world W of its
group: the aggregate of the values of the kept occurrences, in order.
Instances For
Dependency graph
The deterministic reading: the aggregate of the whole occurrence sequence.
Instances For
Dependency graph
The world-faithful reading under a valuation ν of the annotations:
restrict to the occurrences whose annotation ν realizes, and aggregate
those in order.
Equations
- a.specialize ν = a.agg (List.map Prod.fst (List.filter (fun (o : T × K) => ν o.2) a.occs))
Instances For
Dependency graph
Pushforward of h : K → K' through the annotations of a token; the
values are untouched.
Equations
Instances For
Dependency graph
Predicate provenance of an atomic comparison against a token: the
⊕-sum, over the non-empty possible worlds of the token's group, of the
world annotation times the characteristic value of the comparison between
the world's aggregate value and the regular value c. Non-empty worlds
only: the predicate provenance already enforces group existence, exactly
as in the fused semantics Having.havingProv.
Equations
Instances For
Dependency graph
Reindexing bridges #
The occurrence payload of ofGroup is a List.map image of the group
sequence, so worlds over the token and worlds over the group live over
propositionally – not definitionally – equal position types. The bridges
below transport seqOf, worldAnn and the two readings along the
length-preserving equivalence finCongr.
seqOf commutes with mapping the underlying list, up to reindexing
the world along the length equality.
Dependency graph
The whole-sequence world: seqOf over univ is the identity.
Dependency graph
Filtering a list is taking the subsequence of the positions whose element satisfies the predicate.
Dependency graph
The readings, related #
collapse is the aggregate value of the whole-group world.
Dependency graph
specialize is the aggregate value of the world of realized
occurrences.
Dependency graph
The occurrence payload of ofGroup has the length of the group
sequence.
Dependency graph
The world value of the token of a group is the aggregate value of the fused semantics on that world.
Dependency graph
The annotations of the token of a group are the occurrence annotations.
Dependency graph
The world annotation transports along the reindexing.
Dependency graph
Regression bridge, token side. The predicate provenance of a comparison against the token of a group is the fused semantics' predicate provenance of the same comparison on that group.
Dependency graph
Pushforward lemmas #
The deterministic reading is unchanged by the pushforward.
Dependency graph
The world-faithful reading composes with the pushforward.
Dependency graph
Lifted column values #
Pushforward of h : K → K' on a lifted column value: data is
untouched, a token maps its annotations.
Equations
Instances For
Dependency graph
Deterministic reading of a lifted column value: data is itself, a token collapses.
Equations
Instances For
Dependency graph
The deterministic reading of a lifted value is unchanged by the pushforward.