Take operations on tuples #
We define the take
operation on n
-tuples, which restricts a tuple to its first m
elements.
theorem
Fin.take_repeat
{n : ℕ}
{α : Type u_2}
{n' : ℕ}
(m : ℕ)
(h : m ≤ n)
(a : Fin n' → α)
:
Fin.take (m * n') ⋯ (Fin.repeat n a) = Fin.repeat m a
@[simp]
theorem
Fin.take_update_of_lt
{n : ℕ}
{α : Fin n → Sort u_1}
(m : ℕ)
(h : m ≤ n)
(v : (i : Fin n) → α i)
(i : Fin m)
(x : α (Fin.castLE h i))
:
Fin.take m h (Function.update v (Fin.castLE h i) x) = Function.update (Fin.take m h v) i x
theorem
Fin.take_addCases_left
{n : ℕ}
{n' : ℕ}
{motive : Fin (n + n') → Sort u_2}
(m : ℕ)
(h : m ≤ n)
(u : (i : Fin n) → motive (Fin.castAdd n' i))
(v : (i : Fin n') → motive (Fin.natAdd n i))
:
Taking the first m ≤ n
elements of an addCases u v
, where u
is a n
-tuple, is the same as
taking the first m
elements of u
.
theorem
Fin.take_append_left
{n : ℕ}
{n' : ℕ}
{α : Sort u_2}
(m : ℕ)
(h : m ≤ n)
(u : Fin n → α)
(v : Fin n' → α)
:
Fin.take m ⋯ (Fin.append u v) = Fin.take m h u
Version of take_addCases_left
that specializes addCases
to append
.
theorem
Fin.take_addCases_right
{n : ℕ}
{n' : ℕ}
{motive : Fin (n + n') → Sort u_2}
(m : ℕ)
(h : m ≤ n')
(u : (i : Fin n) → motive (Fin.castAdd n' i))
(v : (i : Fin n') → motive (Fin.natAdd n i))
:
(Fin.take (n + m) ⋯ fun (i : Fin (n + n')) => Fin.addCases u v i) = fun (i : Fin (n + m)) =>
Fin.addCases u (Fin.take m h v) i
Taking the first n + m
elements of an addCases u v
, where v
is a n'
-tuple and m ≤ n'
,
is the same as appending u
with the first m
elements of v
.
theorem
Fin.take_append_right
{n : ℕ}
{n' : ℕ}
{α : Sort u_2}
(m : ℕ)
(h : m ≤ n')
(u : Fin n → α)
(v : Fin n' → α)
:
Fin.take (n + m) ⋯ (Fin.append u v) = Fin.append u (Fin.take m h v)
Version of take_addCases_right
that specializes addCases
to append
.