Indices for tuples, relations and tables #
Tup α β is the tuple of components α ++ [β], Rel α β a set of such tuples and Tab α β a
bag of them. Splitting the last component off keeps the list non-empty and lets signatures name it,
so that relational join is typed by its signature alone:
relJoin : Term (Rel α μ) → Term (Rel (μ :: α') β') → Env (Term (Rel (α ++ α') β'))
Neither a relation nor a table is a sort of its own, so relToSet/relOfSet and
tableToBag/tableOfBag cross over for free.
Equations
- Cvc.ToTypList.instConsOfToTyp = { typs := Cvc.ToTyp.typ α :: Cvc.ToTypList.typs αs }
The Typs of α ++ [β], which is what every index here describes.
Equations
Instances For
Instances for nesting #
These indices carry no data, so their comparisons are trivial. They exist only so that a container
of them can be written: relGroup answers a Set (Rel α β).
Equations
- Cvc.instDecidableEqTup x✝¹ x✝ = isTrue ⋯
Equations
- Cvc.instDecidableEqRel x✝¹ x✝ = isTrue ⋯
Equations
- Cvc.instDecidableEqTab x✝¹ x✝ = isTrue ⋯
Equations
- Cvc.instOrdTup = { compare := fun (x x_1 : Cvc.Tup α β) => Ordering.eq }
Equations
- Cvc.instOrdRel = { compare := fun (x x_1 : Cvc.Rel α β) => Ordering.eq }
Equations
- Cvc.instOrdTab = { compare := fun (x x_1 : Cvc.Tab α β) => Ordering.eq }
Equations
- Cvc.instToTypTupOfToTypList = { typ := Cvc.Typ.prod (Cvc.ToTypList.typsOf α β) }
Equations
- Cvc.instToTypRelOfToTypList = { typ := Cvc.Typ.set (Cvc.Typ?.prod (Cvc.ToTypList.typsOf α β)) }
Equations
- Cvc.instToTypTabOfToTypList = { typ := Cvc.Typ.bag (Cvc.Typ?.prod (Cvc.ToTypList.typsOf α β)) }
Positions #
A Col is a component's position that knows the component's type, and a Cols a selection of
positions that knows the index it lands at, which is what types projection
(Cvc.Typed.Term.tupProject and friends). Positions count from zero over α ++ [β], and are
written with col% and cols% under open Cvc.
Equations
The position as a number, counting from zero over α ++ [β].
Equations
- c.toNat = Cvc.Col.idx✝ c
Instances For
Positions to project onto, in order, along with the index they land at.
last and cons are the only builders, so the positions collected and the components the result
index describes stay in step, and the selection cannot come out empty. A position may appear twice
and they need not increase, so this reorders and duplicates as readily as it selects.
Instances For
A component's position, written as a numeral: col%2 is the third component.
Out of range is a type error, there being no ColHead instance left to end the chain. Declared at
maximum precedence, so it needs no parentheses as a function argument.
Equations
- Cvc.«termCol%_» = Lean.ParserDescr.node `Cvc.«termCol%_» 1024 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "col%") (Lean.ParserDescr.const `num))
Instances For
A selection of positions: cols% [2, 0] projects onto the third component then the first.
An element may be any Col term, so a named column works — cols% [dept, 0] — and a numeral is
shorthand for col% of it.
Equations
- One or more equations did not get rendered due to their size.