Composing a function with ![…] #
[UPSTREAM] candidate for Mathlib/Data/Fin/VecNotation.lean. This file restates
Fin.comp_cons for Matrix.vecCons, so that f ∘ ![a, b] rewrites to ![f a, f b].
Matrix.vecCons is a def rather than a reducible alias of Fin.cons, so
Fin.comp_cons does not fire on a vector literal, and mathlib has no vecCons form.
The primed lemmas state the same equations on the lambda fun i => f (![a, b] i).
simp does not identify f ∘ v with fun i => f (v i), and the lambda is the form
that structural recursion through a Fin n → α argument produces (a substitution's
fun i => (ts i).subst σ), whereas ∘ is the form mathlib's Equiv.map_rel and
Fin.comp_cons produce; a rewrite set that pushes f into a literal needs both.
Main statements #
Matrix.comp_vecCons,Matrix.comp_vecEmpty:f ∘ ![…]pushesfinto the literal.Matrix.comp_vecCons',Matrix.comp_vecEmpty': the same forfun i => f (![…] i).Matrix.comp_vec2': the two-element case, whichsimpcannot reach fromcomp_vecCons'becausecons_val_fin_onefirst turns the tail into a constant function.
theorem
Matrix.comp_vecCons
{α : Type u_1}
{β : Type u_2}
{n : ℕ}
(f : α → β)
(a : α)
(v : Fin n → α)
:
f ∘ vecCons a v = vecCons (f a) (f ∘ v)
theorem
Matrix.comp_vecCons'
{α : Type u_1}
{β : Type u_2}
{n : ℕ}
(f : α → β)
(a : α)
(v : Fin n → α)
:
(fun (i : Fin n.succ) => f (vecCons a v i)) = vecCons (f a) fun (i : Fin n) => f (v i)
theorem
Matrix.comp_vecEmpty'
{α : Type u_1}
{β : Type u_2}
(f : α → β)
:
(fun (i : Fin 0) => f (![] i)) = ![]
theorem
Matrix.comp_vec2'
{α : Type u_1}
{β : Type u_2}
(f : α → β)
(a b : α)
:
(fun (i : Fin (Nat.succ 0).succ) => f (![a, b] i)) = ![f a, f b]