Tables, typed #
A table is a bag of tuples, indexed by Tab α β: a relation with duplicates kept. Its rows are
the Tup α β tuples of Cvc.Typed.Theory.Relation, built with mkTup.
The bag operators are restated at a table's index (tableUnionMax, tableCount, …); tableToBag
crosses to Bag, for bagMap and bagFold. cvc5 marks every table-specific kind experimental.
Crossing to and from bags #
Both directions are the identity on terms: a table is a bag of tuples, and only the index differs.
Table operators #
Equi-join: the product, keeping the pairings whose given column pairs agree.
The result's sort is the product's, since the pairs only filter.
Equations
- Cvc.Typed.Term.tableJoin columns lft rgt = Cvc.Untyped.Term.tableJoin columns lft.erase rgt.erase
Instances For
Partitions the table, putting rows that agree on the given columns in the same part.
Answers a bag of tables. The columns choose what is compared and so do not reach the result's sort.
Equations
- Cvc.Typed.Term.tableGroup columns table = Cvc.Untyped.Term.tableGroup columns table.erase
Instances For
Folds each group of rows that agree on the given columns.
The groups are tableGroup's, but the answer is a bag of accumulators rather than a bag of
tables: f runs over each group's rows starting from init, and the result collects one value of
gamma per group.
f is a function-sorted term, which Term.lambda builds. Its two arguments are a row of the table
and the accumulator, in that order, and its result is the new accumulator — so gamma is fixed by
init and by f's codomain together. This is SQL's GROUP BY with an aggregate function.
The columns only say what is grouped, so they do not reach the result's sort. With none of them every row is in one group, which is an ordinary fold over the whole table.
Equations
- Cvc.Typed.Term.tableAggregate columns f init table = Cvc.Untyped.Term.tableAggregate columns f.erase init.erase table.erase
Instances For
Projects every row onto the given columns, in the order given.
Columns are written cols% [2, 0]. Untyped.Term.tableProject takes them as an Array Nat, for
columns known only at run time.
Equations
- Cvc.Typed.Term.tableProject cols table = Cvc.Untyped.Term.tableProject cols.toArray table.erase
Instances For
The bag operators, at a table's index #
N-ary version of tableUnionMax, requires at least two elements.
Equations
- Cvc.Typed.Term.tableUnionMaxN tables atLeastTwoElements = Cvc.Untyped.Term.bagUnionMaxN tables atLeastTwoElements
Instances For
N-ary version of tableUnionDisjoint, requires at least two elements.
Equations
- Cvc.Typed.Term.tableUnionDisjointN tables atLeastTwoElements = Cvc.Untyped.Term.bagUnionDisjointN tables atLeastTwoElements
Instances For
N-ary version of tableInterMin, requires at least two elements.
Equations
- Cvc.Typed.Term.tableInterMinN tables atLeastTwoElements = Cvc.Untyped.Term.bagInterMinN tables atLeastTwoElements
Instances For
The empty table of the given shape.
Equations
- Cvc.Typed.Term.tableEmpty' α β = do let __do_lift ← Cvc.Srt.of (Cvc.Tup α β) Cvc.Untyped.Term.bagEmpty __do_lift