mathlib documentation

data.​typevec

data.​typevec

Tuples of types, and their categorical structure.

Features:

typevec n : n-tuples of types α ⟹ β : n-tuples of maps f ⊚ g : composition

Also, support functions for operating with n-tuples of types, such as:

append1 α β : append type β to n-tuple α to obtain an (n+1)-tuple drop α : drops the last element of an (n+1)-tuple last α : returns the last element of an (n+1)-tuple append_fun f g : appends a function g to an n-tuple of functions drop_fun f : drops the last function from an n+1-tuple last_fun f : returns the last function of a tuple.

Since e.g. append1 α.drop α.last is propositionally equal to α but not definitionally equal to it, we need support functions and lemmas to mediate between constructions.

def typevec  :
Type (u_1+1)

n-tuples of types, as a category

Equations
@[instance]

Equations
def typevec.​arrow {n : } :
typevec ntypevec nType (max u_1 u_2)

arrow in the category of typevec

Equations
@[instance]
def typevec.​arrow.​inhabited {n : } (α : typevec n) (β : typevec n) [Π (i : fin2 n), inhabited (β i)] :

Equations
def typevec.​id {n : } {α : typevec n} :
α.arrow α

identity of arrow composition

Equations
def typevec.​comp {n : } {α : typevec n} {β : typevec n} {γ : typevec n} :
β.arrow γα.arrow βα.arrow γ

arrow composition in the category of typevec

Equations
@[simp]
theorem typevec.​id_comp {n : } {α : typevec n} {β : typevec n} (f : α.arrow β) :

@[simp]
theorem typevec.​comp_id {n : } {α : typevec n} {β : typevec n} (f : α.arrow β) :

theorem typevec.​comp_assoc {n : } {α : typevec n} {β : typevec n} {γ : typevec n} {δ : typevec n} (h : γ.arrow δ) (g : β.arrow γ) (f : α.arrow β) :

def typevec.​append1 {n : } :
typevec nType u_1typevec (n + 1)

Support for extending a typevec by one element.

Equations
def typevec.​drop {n : } :
typevec (n + 1)typevec n

retain only a n-length prefix of the argument

Equations
def typevec.​last {n : } :
typevec (n + 1)Type u

take the last value of a (n+1)-length vector

Equations
@[instance]

Equations
theorem typevec.​drop_append1 {n : } {α : typevec n} {β : Type u_1} {i : fin2 n} :
::: β).drop i = α i

@[simp]
theorem typevec.​drop_append1' {n : } {α : typevec n} {β : Type u_1} :
::: β).drop = α

theorem typevec.​last_append1 {n : } {α : typevec n} {β : Type u_1} :
::: β).last = β

@[simp]
theorem typevec.​append1_drop_last {n : } (α : typevec (n + 1)) :
α.drop ::: α.last = α

def typevec.​append1_cases {n : } {C : typevec (n + 1)Sort u} (H : Π (α : typevec n) (β : Type u_1), C ::: β)) (γ : typevec (n + 1)) :
C γ

cases on (n+1)-length vectors

Equations
@[simp]
theorem typevec.​append1_cases_append1 {n : } {C : typevec (n + 1)Sort u} (H : Π (α : typevec n) (β : Type u_1), C ::: β)) (α : typevec n) (β : Type u_1) :
typevec.append1_cases H ::: β) = H α β

def typevec.​split_fun {n : } {α : typevec (n + 1)} {α' : typevec (n + 1)} :
α.drop.arrow α'.drop(α.last → α'.last)α.arrow α'

append an arrow and a function for arbitrary source and target type vectors

Equations
def typevec.​append_fun {n : } {α : typevec n} {α' : typevec n} {β : Type u_1} {β' : Type u_2} :
α.arrow α'(β → β')::: β).arrow (α' ::: β')

append an arrow and a function as well as their respective source and target types / typevecs

Equations
def typevec.​drop_fun {n : } {α : typevec (n + 1)} {β : typevec (n + 1)} :
α.arrow βα.drop.arrow β.drop

split off the prefix of an arrow

Equations
def typevec.​last_fun {n : } {α : typevec (n + 1)} {β : typevec (n + 1)} :
α.arrow βα.last → β.last

split off the last function of an arrow

Equations
def typevec.​nil_fun {α : typevec 0} {β : typevec 0} :
α.arrow β

arrow in the category of 0-length vectors

Equations
theorem typevec.​eq_of_drop_last_eq {n : } {α : typevec (n + 1)} {β : typevec (n + 1)} {f g : α.arrow β} :

@[simp]
theorem typevec.​drop_fun_split_fun {n : } {α : typevec (n + 1)} {α' : typevec (n + 1)} (f : α.drop.arrow α'.drop) (g : α.last → α'.last) :

def typevec.​arrow.​mp {n : } {α β : typevec n} :
α = βα.arrow β

turn an equality into an arrow

Equations
def typevec.​arrow.​mpr {n : } {α β : typevec n} :
α = ββ.arrow α

turn an equality into an arrow, with reverse direction

Equations
def typevec.​to_append1_drop_last {n : } {α : typevec (n + 1)} :
α.arrow (α.drop ::: α.last)

decompose a vector into its prefix appended with its last element

Equations
def typevec.​from_append1_drop_last {n : } {α : typevec (n + 1)} :
(α.drop ::: α.last).arrow α

stitch two bits of a vector back together

Equations
@[simp]
theorem typevec.​last_fun_split_fun {n : } {α : typevec (n + 1)} {α' : typevec (n + 1)} (f : α.drop.arrow α'.drop) (g : α.last → α'.last) :

@[simp]
theorem typevec.​drop_fun_append_fun {n : } {α : typevec n} {α' : typevec n} {β : Type u_1} {β' : Type u_2} (f : α.arrow α') (g : β → β') :

@[simp]
theorem typevec.​last_fun_append_fun {n : } {α : typevec n} {α' : typevec n} {β : Type u_1} {β' : Type u_2} (f : α.arrow α') (g : β → β') :

theorem typevec.​split_drop_fun_last_fun {n : } {α : typevec (n + 1)} {α' : typevec (n + 1)} (f : α.arrow α') :

theorem typevec.​split_fun_inj {n : } {α : typevec (n + 1)} {α' : typevec (n + 1)} {f f' : α.drop.arrow α'.drop} {g g' : α.last → α'.last} :
typevec.split_fun f g = typevec.split_fun f' g'f = f' g = g'

theorem typevec.​append_fun_inj {n : } {α : typevec n} {α' : typevec n} {β : Type u_1} {β' : Type u_2} {f f' : α.arrow α'} {g g' : β → β'} :
f ::: g = f' ::: g'f = f' g = g'

theorem typevec.​split_fun_comp {n : } {α₀ : typevec (n + 1)} {α₁ : typevec (n + 1)} {α₂ : typevec (n + 1)} (f₀ : α₀.drop.arrow α₁.drop) (f₁ : α₁.drop.arrow α₂.drop) (g₀ : α₀.last → α₁.last) (g₁ : α₁.last → α₂.last) :
typevec.split_fun (typevec.comp f₁ f₀) (g₁ g₀) = typevec.comp (typevec.split_fun f₁ g₁) (typevec.split_fun f₀ g₀)

theorem typevec.​append_fun_comp_split_fun {n : } {α : typevec n} {γ : typevec n} {β : Type u_1} {δ : Type u_2} {ε : typevec (n + 1)} (f₀ : ε.drop.arrow α) (f₁ : α.arrow γ) (g₀ : ε.last → β) (g₁ : β → δ) :
typevec.comp (f₁ ::: g₁) (typevec.split_fun f₀ g₀) = typevec.split_fun (typevec.comp f₁ f₀) (g₁ g₀)

theorem typevec.​append_fun_comp {n : } {α₀ : typevec n} {α₁ : typevec n} {α₂ : typevec n} {β₀ : Type u_1} {β₁ : Type u_2} {β₂ : Type u_3} (f₀ : α₀.arrow α₁) (f₁ : α₁.arrow α₂) (g₀ : β₀ → β₁) (g₁ : β₁ → β₂) :
typevec.comp f₁ f₀ ::: g₁ g₀ = typevec.comp (f₁ ::: g₁) (f₀ ::: g₀)

theorem typevec.​append_fun_comp' {n : } {α₀ : typevec n} {α₁ : typevec n} {α₂ : typevec n} {β₀ : Type u_1} {β₁ : Type u_2} {β₂ : Type u_3} (f₀ : α₀.arrow α₁) (f₁ : α₁.arrow α₂) (g₀ : β₀ → β₁) (g₁ : β₁ → β₂) :
typevec.comp (f₁ ::: g₁) (f₀ ::: g₀) = typevec.comp f₁ f₀ ::: g₁ g₀

theorem typevec.​nil_fun_comp {α₀ : typevec 0} (f₀ : α₀.arrow fin2.elim0) :

theorem typevec.​append_fun_comp_id {n : } {α : typevec n} {β₀ β₁ β₂ : Type u_1} (g₀ : β₀ → β₁) (g₁ : β₁ → β₂) :

@[simp]
theorem typevec.​drop_fun_comp {n : } {α₀ : typevec (n + 1)} {α₁ : typevec (n + 1)} {α₂ : typevec (n + 1)} (f₀ : α₀.arrow α₁) (f₁ : α₁.arrow α₂) :

@[simp]
theorem typevec.​last_fun_comp {n : } {α₀ : typevec (n + 1)} {α₁ : typevec (n + 1)} {α₂ : typevec (n + 1)} (f₀ : α₀.arrow α₁) (f₁ : α₁.arrow α₂) :

theorem typevec.​append_fun_aux {n : } {α : typevec n} {α' : typevec n} {β : Type u_1} {β' : Type u_2} (f : ::: β).arrow (α' ::: β')) :

theorem typevec.​append_fun_id_id {n : } {α : typevec n} {β : Type u_1} :

simp set for the manipulation of typevec and arrow expressions

def typevec.​cases_nil {β : typevec 0Sort u_2} (f : β fin2.elim0) (v : typevec 0) :
β v

cases distinction for 0-length type vector

Equations
def typevec.​cases_cons (n : ) {β : typevec (n + 1)Sort u_2} (f : Π (t : Type u_1) (v : typevec n), β (v ::: t)) (v : typevec (n + 1)) :
β v

cases distinction for (n+1)-length type vector

Equations
theorem typevec.​cases_nil_append1 {β : typevec 0Sort u_2} (f : β fin2.elim0) :

theorem typevec.​cases_cons_append1 (n : ) {β : typevec (n + 1)Sort u_2} (f : Π (t : Type u_1) (v : typevec n), β (v ::: t)) (v : typevec n) (α : Type u_1) :
typevec.cases_cons n f (v ::: α) = f α v

def typevec.​typevec_cases_nil₃ {β : Π (v : typevec 0) (v' : typevec 0), v.arrow v'Sort u_3} (f : β fin2.elim0 fin2.elim0 typevec.nil_fun) (v : typevec 0) (v' : typevec 0) (fs : v.arrow v') :
β v v' fs

cases distinction for an arrow in the category of 0-length type vectors

Equations
def typevec.​typevec_cases_cons₃ (n : ) {β : Π (v : typevec (n + 1)) (v' : typevec (n + 1)), v.arrow v'Sort u_3} (F : Π (t : Type u_1) (t' : Type u_2) (f : t → t') (v : typevec n) (v' : typevec n) (fs : v.arrow v'), β (v ::: t) (v' ::: t') (fs ::: f)) (v : typevec (n + 1)) (v' : typevec (n + 1)) (fs : v.arrow v') :
β v v' fs

cases distinction for an arrow in the category of (n+1)-length type vectors

Equations

specialized cases distinction for an arrow in the category of 0-length type vectors

Equations
def typevec.​typevec_cases_cons₂ (n : ) (t : Type u_1) (t' : Type u_2) (v : typevec n) (v' : typevec n) {β : (v ::: t).arrow (v' ::: t')Sort u_3} (F : Π (f : t → t') (fs : v.arrow v'), β (fs ::: f)) (fs : (v ::: t).arrow (v' ::: t')) :
β fs

specialized cases distinction for an arrow in the category of (n+1)-length type vectors

Equations
theorem typevec.​typevec_cases_cons₂_append_fun (n : ) (t : Type u_1) (t' : Type u_2) (v : typevec n) (v' : typevec n) {β : (v ::: t).arrow (v' ::: t')Sort u_3} (F : Π (f : t → t') (fs : v.arrow v'), β (fs ::: f)) (f : t → t') (fs : v.arrow v') :
typevec.typevec_cases_cons₂ n t t' v v' F (fs ::: f) = F f fs

def typevec.​pred_last {n : } (α : typevec n) {β : Type u_1} (p : β → Prop) ⦃i : fin2 (n + 1) :
::: β) i → Prop

pred_last α p x predicates p of the last element of x : α.append1 β.

Equations
def typevec.​rel_last {n : } (α : typevec n) {β γ : Type u_1} (r : β → γ → Prop) ⦃i : fin2 (n + 1) :
::: β) i::: γ) i → Prop

rel_last α r x y says that p the last elements of x y : α.append1 β are related by r and all the other elements are equal.

Equations
def typevec.​repeat (n : ) :
Type u_1typevec n

repeat n t is a n-length type vector that contains n occurences of t

Equations
def typevec.​prod {n : } :
typevec ntypevec ntypevec n

prod α β is the pointwise product of the components of α and β

Equations
def typevec.​const {β : Type u_1} (x : β) {n : } (α : typevec n) :

const x α is an arrow that ignores its source and constructs a typevec that contains nothing but x

Equations
def typevec.​repeat_eq {n : } (α : typevec n) :
(α.prod α).arrow (typevec.repeat n Prop)

vector of equality on a product of vectors

Equations
theorem typevec.​const_append1 {β : Type u_1} {γ : Type u_2} (x : γ) {n : } (α : typevec n) :
typevec.const x ::: β) = typevec.const x α ::: λ (_x : β), x

theorem typevec.​eq_nil_fun {α : typevec 0} {β : typevec 0} (f : α.arrow β) :

theorem typevec.​const_nil {β : Type u_1} (x : β) (α : typevec 0) :

def typevec.​pred_last' {n : } (α : typevec n) {β : Type u_1} :
(β → Prop)::: β).arrow (typevec.repeat (n + 1) Prop)

predicate on a type vector to constrain only the last object

Equations
def typevec.​rel_last' {n : } (α : typevec n) {β : Type u_1} :
(β → β → Prop)((α ::: β).prod ::: β)).arrow (typevec.repeat (n + 1) Prop)

predicate on the product of two type vectors to constrain only their last object

Equations
def typevec.​curry {n : } :
(typevec (n + 1)Type u_1)Type utypevec nType u_1

given F : typevec.{u} (n+1) → Type u, curry F : Type u → typevec.{u} → Type u, i.e. its first argument can be fed in separately from the rest of the vector of arguments

Equations
@[instance]
def typevec.​curry.​inhabited {n : } (F : typevec (n + 1)Type u_1) (α : Type u) (β : typevec n) [I : inhabited (F ::: α))] :

Equations
def typevec.​drop_repeat (α : Type u_1) {n : } :

arrow to remove one element of a repeat vector

Equations
def typevec.​of_repeat {α : Type u_1} {n : } {i : fin2 n} :
typevec.repeat n α i → α

projection for a repeat vector

Equations
theorem typevec.​const_iff_true {n : } {α : typevec n} {i : fin2 n} {x : α i} {p : Prop} :

def typevec.​prod.​fst {n : } {α β : typevec n} :
(α.prod β).arrow α

left projection of a prod vector

Equations
def typevec.​prod.​snd {n : } {α β : typevec n} :
(α.prod β).arrow β

right projection of a prod vector

Equations
def typevec.​prod.​diag {n : } {α : typevec n} :
α.arrow (α.prod α)

introduce a product where both components are the same

Equations
def typevec.​prod.​mk {n : } {α β : typevec n} (i : fin2 n) :
α iβ iα.prod β i

constructor for prod

Equations
def typevec.​prod.​map {n : } {α α' β β' : typevec n} :
α.arrow βα'.arrow β'(α.prod α').arrow (β.prod β')

prod is functorial

Equations
theorem typevec.​fst_prod_mk {n : } {α α' β β' : typevec n} (f : α.arrow β) (g : α'.arrow β') :

theorem typevec.​snd_prod_mk {n : } {α α' β β' : typevec n} (f : α.arrow β) (g : α'.arrow β') :

theorem typevec.​repeat_eq_iff_eq {n : } {α : typevec n} {i : fin2 n} {x y : α i} :

def typevec.​subtype_ {n : } {α : typevec n} :
α.arrow (typevec.repeat n Prop)typevec n

given a predicate vector p over vector α, subtype_ p is the type of vectors that contain an α that satisfies p

Equations
def typevec.​to_subtype {n : } {α : typevec n} (p : α.arrow (typevec.repeat n Prop)) :
typevec.arrow (λ (i : fin2 n), {x // typevec.of_repeat (p i x)}) (typevec.subtype_ p)

arrow that rearranges the type of subtype_ to turn a subtype of vector into a vector of subtypes

Equations
def typevec.​of_subtype {n : } {α : typevec n} (p : α.arrow (typevec.repeat n Prop)) :
(typevec.subtype_ p).arrow (λ (i : fin2 n), {x // typevec.of_repeat (p i x)})

arrow that rearranges the type of subtype_ to turn a vector of subtypes into a subtype of vector

Equations
def typevec.​to_subtype' {n : } {α : typevec n} (p : (α.prod α).arrow (typevec.repeat n Prop)) :

similar to to_subtype adapted to relations (i.e. predicate on product)

Equations
def typevec.​of_subtype' {n : } {α : typevec n} (p : (α.prod α).arrow (typevec.repeat n Prop)) :
(typevec.subtype_ p).arrow (λ (i : fin2 n), {x // typevec.of_repeat (p i (typevec.prod.mk i x.fst x.snd))})

similar to of_subtype adapted to relations (i.e. predicate on product)

Equations

similar to diag but the target vector is a subtype_ guaranteeing the equality of the components

Equations
theorem typevec.​append_prod_append_fun {n : } {α α' β β' : typevec n} {φ φ' ψ ψ' : Type u} {f₀ : α.arrow α'} {g₀ : β.arrow β'} {f₁ : φ → φ'} {g₁ : ψ → ψ'} :
typevec.prod.map f₀ g₀ ::: prod.map f₁ g₁ = typevec.prod.map (f₀ ::: f₁) (g₀ ::: g₁)

@[simp]

@[simp]
theorem typevec.​drop_fun_to_subtype {n : } {α : typevec (n + 1)} (p : α.arrow (typevec.repeat (n + 1) Prop)) :
typevec.drop_fun (typevec.to_subtype p) = typevec.to_subtype (λ (i : fin2 n) (x : α i.fs), p i.fs x)

@[simp]
theorem typevec.​last_fun_to_subtype {n : } {α : typevec (n + 1)} (p : α.arrow (typevec.repeat (n + 1) Prop)) :

@[simp]
theorem typevec.​last_fun_of_subtype {n : } {α : typevec (n + 1)} (p : α.arrow (typevec.repeat (n + 1) Prop)) :

@[simp]
theorem typevec.​drop_fun_rel_last {n : } {α : typevec n} {β : Type u_1} (R : β → β → Prop) :

@[simp]
theorem typevec.​drop_fun_prod {n : } {α α' β β' : typevec (n + 1)} (f : α.arrow β) (f' : α'.arrow β') :

@[simp]
theorem typevec.​last_fun_prod {n : } {α α' β β' : typevec (n + 1)} (f : α.arrow β) (f' : α'.arrow β') :

@[simp]
theorem typevec.​to_subtype_of_subtype {n : } {α : typevec n} (p : α.arrow (typevec.repeat n Prop)) :
typevec.comp (typevec.to_subtype p) (typevec.of_subtype (λ (i : fin2 n) (x : α i), p i x)) = typevec.id

@[simp]
theorem typevec.​to_subtype_of_subtype_assoc {n : } {α : typevec n} {β : typevec n} (p : α.arrow (typevec.repeat n Prop)) (f : β.arrow (typevec.subtype_ p)) :
typevec.comp (typevec.to_subtype p) (typevec.comp (typevec.of_subtype (λ (i : fin2 n) (x : α i), p i x)) f) = f