Mathlib.Data.Fin.Tuple.Basic
204 declarations. Mathlib docs · Source
Operation on tuples
We interpret maps ∀ i : Fin n, α i as n-tuples of elements of possibly varying type α i,
(α 0, …, α (n-1)). A particular case is Fin n → α of elements with all the same type.
In this case when α i is a constant map, then tuples are isomorphic (but not definitionally equal)
to Vectors.
Main declarations
There are three (main) ways to consider Fin n as a subtype of Fin (n + 1), hence three (main)
ways to move between tuples of length n and of length n + 1 by adding/removing an entry.
Adding at the start
Fin.succ: Sendi : Fin ntoi + 1 : Fin (n + 1). This is defined in Core.Fin.cases: Induction/recursion principle forFin: To prove a property/define a function for allFin (n + 1), it is enough to prove/define it for0and fori.succfor alli : Fin n. This is defined in Core.Fin.cons: Turn a tuplef : Fin n → αand an entrya : αinto a tupleFin.cons a f : Fin (n + 1) → αby addingaat the start. In general, tuples can be dependent functions, in which casef : ∀ i : Fin n, α i.succanda : α 0. This is a special case ofFin.cases.Fin.tail: Turn a tuplef : Fin (n + 1) → αinto a tupleFin.tail f : Fin n → αby forgetting the start. In general, tuples can be dependent functions, in which caseFin.tail f : ∀ i : Fin n, α i.succ.
Adding at the end
Fin.castSucc: Sendi : Fin ntoi : Fin (n + 1). This is defined in Core.Fin.lastCases: Induction/recursion principle forFin: To prove a property/define a function for allFin (n + 1), it is enough to prove/define it forlast nand fori.castSuccfor alli : Fin n. This is defined in Core.Fin.snoc: Turn a tuplef : Fin n → αand an entrya : αinto a tupleFin.snoc f a : Fin (n + 1) → αby addingaat the end. In general, tuples can be dependent functions, in which casef : ∀ i : Fin n, α i.castSuccanda : α (last n). This is a special case ofFin.lastCases.Fin.init: Turn a tuplef : Fin (n + 1) → αinto a tupleFin.init f : Fin n → αby forgetting the end. In general, tuples can be dependent functions, in which caseFin.init f : ∀ i : Fin n, α i.castSucc.
Adding in the middle
For a pivot p : Fin (n + 1),
Fin.succAbove: Sendi : Fin ntoi : Fin (n + 1)ifi < p,i + 1 : Fin (n + 1)ifp ≤ i.
Fin.succAboveCases: Induction/recursion principle forFin: To prove a property/define a function for allFin (n + 1), it is enough to prove/define it forpand forp.succAbove ifor alli : Fin n.Fin.insertNth: Turn a tuplef : Fin n → αand an entrya : αinto a tupleFin.insertNth f a : Fin (n + 1) → αby addingain positionp. In general, tuples can be dependent functions, in which casef : ∀ i : Fin n, α (p.succAbove i)anda : α p. This is a special case ofFin.succAboveCases.Fin.removeNth: Turn a tuplef : Fin (n + 1) → αinto a tupleFin.removeNth p f : Fin n → αby forgetting thep-th value. In general, tuples can be dependent functions, in which caseFin.removeNth f : ∀ i : Fin n, α (succAbove p i).
p = 0 means we add at the start. p = last n means we add at the end.
Miscellaneous
Fin.find p h: returns the first indexi : Fin nwherep iis satisfied given the hypothesis thath : ∃ i, p i.Fin.append a b: append two tuples.Fin.repeat n a: repeat a tuplentimes.
In the previous section, we have discussed inserting or removing elements on the left of a
tuple. In this section, we do the same on the right. A difference is that Fin (n+1) is constructed
inductively from Fin n starting from the left, not from the right. This implies that Lean needs
more help to realize that elements belong to the right types, i.e., we need to insert casts at
several places.
theorem Fin.find.congr_simp E1 #
∀ {n : ℕ} (p p_1 : Fin n → Prop) (e_p : p = p_1) {inst : DecidablePred p} [inst_1 : DecidablePred p_1] (h : ∃ k, p k),
Fin.find p h = Fin.find p_1 ⋯
theorem Fin.tuple0_le E1 #
∀ {α : Fin 0 → Type u_1} [inst : (i : Fin 0) → Preorder (α i)] (f g : (i : Fin 0) → α i), f ≤ g
def Fin.tail E1 #
{n : ℕ} → {α : Fin (n + 1) → Sort u} → ((i : Fin (n + 1)) → α i) → (i : Fin n) → α i.succ
The tail of an n+1 tuple, i.e., its last n entries.
theorem Fin.tail_def E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} {q : (i : Fin (n + 1)) → α i}, (Fin.tail fun k ↦ q k) = fun k ↦ q k.succ
def Fin.cons E3 #
{n : ℕ} → {α : Fin (n + 1) → Sort u} → α 0 → ((i : Fin n) → α i.succ) → (i : Fin (n + 1)) → α i
Adding an element at the beginning of an n-tuple, to get an n+1-tuple.
theorem Fin.tail_cons E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} (x : α 0) (p : (i : Fin n) → α i.succ), Fin.tail (Fin.cons x p) = p
theorem Fin.cons_succ E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} (x : α 0) (p : (i : Fin n) → α i.succ) (i : Fin n), Fin.cons x p i.succ = p i
theorem Fin.cons_comp_succ E0 #
∀ {n : ℕ} {α : Sort u_1} (x : α) (p : Fin n → α), Fin.cons x p ∘ Fin.succ = p
theorem Fin.cons_zero E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} (x : α 0) (p : (i : Fin n) → α i.succ), Fin.cons x p 0 = x
theorem Fin.cons_one E0 #
∀ {n : ℕ} {α : Fin (n + 2) → Sort u_1} (x : α 0) (p : (i : Fin n.succ) → α i.succ), Fin.cons x p 1 = p 0
theorem Fin.cons_last E0 #
∀ {n : ℕ} {α : Fin (n + 2) → Sort u_1} (x : α 0) (p : (i : Fin n.succ) → α i.succ),
Fin.cons x p (Fin.last (n + 1)) = p (Fin.last n)
theorem Fin.cons_update E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} (x : α 0) (p : (i : Fin n) → α i.succ) (i : Fin n) (y : α i.succ),
Fin.cons x (Function.update p i y) = Function.update (Fin.cons x p) i.succ y
Updating a tuple and adding an element at the beginning commute.
theorem Fin.cons_injective2 E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u}, Function.Injective2 Fin.cons
As a binary function, Fin.cons is injective.
theorem Fin.cons_inj E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} {x₀ y₀ : α 0} {x y : (i : Fin n) → α i.succ},
Fin.cons x₀ x = Fin.cons y₀ y ↔ x₀ = y₀ ∧ x = y
theorem Fin.cons_left_injective E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} (x : (i : Fin n) → α i.succ), Function.Injective fun x₀ ↦ Fin.cons x₀ x
theorem Fin.cons_right_injective E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} (x₀ : α 0), Function.Injective (Fin.cons x₀)
theorem Fin.update_cons_zero E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} (x : α 0) (p : (i : Fin n) → α i.succ) (z : α 0),
Function.update (Fin.cons x p) 0 z = Fin.cons z p
Adding an element at the beginning of a tuple and then updating it amounts to adding it directly.
theorem Fin.cons_self_tail E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} (q : (i : Fin (n + 1)) → α i), Fin.cons (q 0) (Fin.tail q) = q
Concatenating the first element of a tuple with its tail gives back the original tuple
theorem Fin.cons_zero_succ E0 #
∀ {n : ℕ}, Fin.cons 0 Fin.succ = id
def Fin.consEquiv E3 #
{n : ℕ} → (α : Fin (n + 1) → Type u_1) → α 0 × ((i : Fin n) → α i.succ) ≃ ((i : Fin (n + 1)) → α i)
Equivalence between tuples of length n + 1 and pairs of an element and a tuple of length n
given by separating out the first element of the tuple.
This is Fin.cons as an Equiv.
theorem Fin.consEquiv_symm_apply E0 #
∀ {n : ℕ} (α : Fin (n + 1) → Type u_1) (f : (i : Fin (n + 1)) → α i), (Fin.consEquiv α).symm f = (f 0, Fin.tail f)
theorem Fin.consEquiv_apply E0 #
∀ {n : ℕ} (α : Fin (n + 1) → Type u_1) (f : α 0 × ((i : Fin n) → α i.succ)), (Fin.consEquiv α) f = Fin.cons f.1 f.2
def Fin.consCases E1 #
{n : ℕ} →
{α : Fin (n + 1) → Sort u} →
{motive : ((i : Fin n.succ) → α i) → Sort v} →
((x₀ : α 0) → (x : (i : Fin n) → α i.succ) → motive (Fin.cons x₀ x)) → (x : (i : Fin n.succ) → α i) → motive x
Recurse on an n+1-tuple by splitting it into a single element and an n-tuple.
theorem Fin.consCases_cons E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} {motive : ((i : Fin n.succ) → α i) → Sort v}
(cons : (x₀ : α 0) → (x : (i : Fin n) → α i.succ) → motive (Fin.cons x₀ x)) (x₀ : α 0) (x : (i : Fin n) → α i.succ),
Fin.consCases cons (Fin.cons x₀ x) = cons x₀ x
def Fin.consInduction E1 #
{α : Sort u_1} →
{motive : {n : ℕ} → (Fin n → α) → Sort v} →
motive Fin.elim0 →
({n : ℕ} → (x₀ : α) → (x : Fin n → α) → motive x → motive (Fin.cons x₀ x)) → {n : ℕ} → (x : Fin n → α) → motive x
Recurse on a tuple by splitting into Fin.elim0 and Fin.cons.
theorem Fin.cons_injective_of_injective E1 #
∀ {n : ℕ} {α : Type u_1} {x₀ : α} {x : Fin n → α},
x₀ ∉ Set.range x → Function.Injective x → Function.Injective (Fin.cons x₀ x)
theorem Fin.cons_injective_iff E0 #
∀ {n : ℕ} {α : Type u_1} {x₀ : α} {x : Fin n → α},
Function.Injective (Fin.cons x₀ x) ↔ x₀ ∉ Set.range x ∧ Function.Injective x
theorem Fin.exists_cons E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Type u_1} (q : (i : Fin (n + 1)) → α i), ∃ x₀ x, q = Fin.cons x₀ x
theorem Fin.forall_fin_zero_pi E0 #
∀ {α : Fin 0 → Sort u_1} {P : ((i : Fin 0) → α i) → Prop}, (∀ (x : (i : Fin 0) → α i), P x) ↔ P finZeroElim
theorem Fin.exists_fin_zero_pi E0 #
∀ {α : Fin 0 → Sort u_1} {P : ((i : Fin 0) → α i) → Prop}, (∃ x, P x) ↔ P finZeroElim
theorem Fin.forall_fin_succ_pi E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} {P : ((i : Fin (n + 1)) → α i) → Prop},
(∀ (x : (i : Fin (n + 1)) → α i), P x) ↔ ∀ (a : α 0) (v : (i : Fin n) → α i.succ), P (Fin.cons a v)
theorem Fin.exists_fin_succ_pi E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} {P : ((i : Fin (n + 1)) → α i) → Prop}, (∃ x, P x) ↔ ∃ a v, P (Fin.cons a v)
theorem Fin.tail_update_zero E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} (q : (i : Fin (n + 1)) → α i) (z : α 0),
Fin.tail (Function.update q 0 z) = Fin.tail q
Updating the first element of a tuple does not change the tail.
theorem Fin.tail_update_succ E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u} (q : (i : Fin (n + 1)) → α i) (i : Fin n) (y : α i.succ),
Fin.tail (Function.update q i.succ y) = Function.update (Fin.tail q) i y
Updating a nonzero element and taking the tail commute.
theorem Fin.comp_cons E1 #
∀ {n : ℕ} {α : Sort u_1} {β : Sort u_2} (g : α → β) (y : α) (q : Fin n → α), g ∘ Fin.cons y q = Fin.cons (g y) (g ∘ q)
theorem Fin.comp_tail E1 #
∀ {n : ℕ} {α : Sort u_1} {β : Sort u_2} (g : α → β) (q : Fin n.succ → α), g ∘ Fin.tail q = Fin.tail (g ∘ q)
theorem Fin.le_cons E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Type u_1} [inst : (i : Fin (n + 1)) → Preorder (α i)] {x : α 0}
{q : (i : Fin (n + 1)) → α i} {p : (i : Fin n) → α i.succ}, q ≤ Fin.cons x p ↔ q 0 ≤ x ∧ Fin.tail q ≤ p
theorem Fin.cons_le E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Type u_1} [inst : (i : Fin (n + 1)) → Preorder (α i)] {x : α 0}
{q : (i : Fin (n + 1)) → α i} {p : (i : Fin n) → α i.succ}, Fin.cons x p ≤ q ↔ x ≤ q 0 ∧ p ≤ Fin.tail q
theorem Fin.cons_le_cons E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Type u_1} [inst : (i : Fin (n + 1)) → Preorder (α i)] {x₀ y₀ : α 0}
{x y : (i : Fin n) → α i.succ}, Fin.cons x₀ x ≤ Fin.cons y₀ y ↔ x₀ ≤ y₀ ∧ x ≤ y
theorem Fin.range_fin_succ E1 #
∀ {n : ℕ} {α : Type u_1} (f : Fin (n + 1) → α), Set.range f = insert (f 0) (Set.range (Fin.tail f))
theorem Fin.range_cons E0 #
∀ {α : Type u_1} {n : ℕ} (x : α) (b : Fin n → α), Set.range (Fin.cons x b) = insert x (Set.range b)
def Fin.append E1 #
{m n : ℕ} → {α : Sort u_1} → (Fin m → α) → (Fin n → α) → Fin (m + n) → α
Append a tuple of length m to a tuple of length n to get a tuple of length m + n.
This is a non-dependent version of Fin.add_cases.
theorem Fin.append_left E0 #
∀ {m n : ℕ} {α : Sort u_1} (u : Fin m → α) (v : Fin n → α) (i : Fin m), Fin.append u v (Fin.castAdd n i) = u i
theorem Fin.append_left' E0 #
∀ {m n : ℕ} {α : Sort u_1} (u : Fin m → α) (v : Fin n → α) (i : Fin m), Fin.append u v (Fin.castLE ⋯ i) = u i
Variant of append_left using Fin.castLE instead of Fin.castAdd.
theorem Fin.append_right E0 #
∀ {m n : ℕ} {α : Sort u_1} (u : Fin m → α) (v : Fin n → α) (i : Fin n), Fin.append u v (Fin.natAdd m i) = v i
theorem Fin.append_right_nil E1 #
∀ {m n : ℕ} {α : Sort u_1} (u : Fin m → α) (v : Fin n → α) (hv : n = 0), Fin.append u v = u ∘ Fin.cast ⋯
theorem Fin.append_elim0 E0 #
∀ {m : ℕ} {α : Sort u_1} (u : Fin m → α), Fin.append u Fin.elim0 = u ∘ Fin.cast ⋯
theorem Fin.append_left_nil E1 #
∀ {m n : ℕ} {α : Sort u_1} (u : Fin m → α) (v : Fin n → α) (hu : m = 0), Fin.append u v = v ∘ Fin.cast ⋯
theorem Fin.elim0_append E0 #
∀ {n : ℕ} {α : Sort u_1} (v : Fin n → α), Fin.append Fin.elim0 v = v ∘ Fin.cast ⋯
theorem Fin.append_assoc E1 #
∀ {m n : ℕ} {α : Sort u_1} {p : ℕ} (a : Fin m → α) (b : Fin n → α) (c : Fin p → α),
Fin.append (Fin.append a b) c = Fin.append a (Fin.append b c) ∘ Fin.cast ⋯
theorem Fin.append_left_eq_cons E1 #
∀ {α : Sort u_1} {n : ℕ} (x₀ : Fin 1 → α) (x : Fin n → α), Fin.append x₀ x = Fin.cons (x₀ 0) x ∘ Fin.cast ⋯
Appending a one-tuple to the left is the same as Fin.cons.
theorem Fin.cons_eq_append E1 #
∀ {n : ℕ} {α : Sort u_1} (x : α) (xs : Fin n → α), Fin.cons x xs = Fin.append (Fin.cons x Fin.elim0) xs ∘ Fin.cast ⋯
Fin.cons is the same as appending a one-tuple to the left.
theorem Fin.append_cast_left E0 #
∀ {α : Sort u_1} {n m : ℕ} (xs : Fin n → α) (ys : Fin m → α) (n' : ℕ) (h : n' = n),
Fin.append (xs ∘ Fin.cast h) ys = Fin.append xs ys ∘ Fin.cast ⋯
theorem Fin.append_cast_right E0 #
∀ {α : Sort u_1} {n m : ℕ} (xs : Fin n → α) (ys : Fin m → α) (m' : ℕ) (h : m' = m),
Fin.append xs (ys ∘ Fin.cast h) = Fin.append xs ys ∘ Fin.cast ⋯
theorem Fin.append_rev E1 #
∀ {α : Sort u_1} {m n : ℕ} (xs : Fin m → α) (ys : Fin n → α) (i : Fin (m + n)),
Fin.append xs ys i.rev = Fin.append (ys ∘ Fin.rev) (xs ∘ Fin.rev) (Fin.cast ⋯ i)
theorem Fin.append_comp_rev E1 #
∀ {α : Sort u_1} {m n : ℕ} (xs : Fin m → α) (ys : Fin n → α),
Fin.append xs ys ∘ Fin.rev = Fin.append (ys ∘ Fin.rev) (xs ∘ Fin.rev) ∘ Fin.cast ⋯
theorem Fin.append_castAdd_natAdd E1 #
∀ {m n : ℕ} {α : Sort u_1} {f : Fin (m + n) → α},
(Fin.append (fun i ↦ f (Fin.castAdd n i)) fun i ↦ f (Fin.natAdd m i)) = f
theorem Fin.addCases_castAdd_natAdd E1 #
∀ {m n : ℕ} {γ : Fin (m + n) → Sort u_2} (v : (i : Fin (m + n)) → γ i) (i : Fin (m + n)),
Fin.addCases (fun i ↦ v (Fin.castAdd n i)) (fun j ↦ v (Fin.natAdd m j)) i = v i
Splitting a dependent finite sequence v into an initial part and a final part, and then concatenating these components, produces an identical sequence.
theorem Fin.append_comp_sumElim E1 #
∀ {m n : ℕ} {α : Sort u_1} {xs : Fin m → α} {ys : Fin n → α},
Fin.append xs ys ∘ Sum.elim (Fin.castAdd n) (Fin.natAdd m) = Sum.elim xs ys
theorem Fin.append_injective_iff E0 #
∀ {m n : ℕ} {α : Sort u_1} {xs : Fin m → α} {ys : Fin n → α},
Function.Injective (Fin.append xs ys) ↔
Function.Injective xs ∧ Function.Injective ys ∧ ∀ (i : Fin m) (j : Fin n), xs i ≠ ys j
def Fin.repeat E1 #
{n : ℕ} → {α : Sort u_1} → (m : ℕ) → (Fin n → α) → Fin (m * n) → α
Repeat a m times. For example Fin.repeat 2 ![0, 3, 7] = ![0, 3, 7, 0, 3, 7].
theorem Fin.repeat_apply E0 #
∀ {m n : ℕ} {α : Sort u_1} (a : Fin n → α) (i : Fin (m * n)), Fin.repeat m a i = a i.modNat
theorem Fin.repeat_zero E0 #
∀ {n : ℕ} {α : Sort u_1} (a : Fin n → α), Fin.repeat 0 a = Fin.elim0 ∘ Fin.cast ⋯
theorem Fin.repeat_one E0 #
∀ {n : ℕ} {α : Sort u_1} (a : Fin n → α), Fin.repeat 1 a = a ∘ Fin.cast ⋯
theorem Fin.repeat_succ E1 #
∀ {n : ℕ} {α : Sort u_1} (a : Fin n → α) (m : ℕ), Fin.repeat m.succ a = Fin.append a (Fin.repeat m a) ∘ Fin.cast ⋯
theorem Fin.repeat_add E0 #
∀ {n : ℕ} {α : Sort u_1} (a : Fin n → α) (m₁ m₂ : ℕ),
Fin.repeat (m₁ + m₂) a = Fin.append (Fin.repeat m₁ a) (Fin.repeat m₂ a) ∘ Fin.cast ⋯
theorem Fin.repeat_rev E1 #
∀ {m n : ℕ} {α : Sort u_1} (a : Fin n → α) (k : Fin (m * n)), Fin.repeat m a k.rev = Fin.repeat m (a ∘ Fin.rev) k
theorem Fin.repeat_comp_rev E1 #
∀ {m n : ℕ} {α : Sort u_1} (a : Fin n → α), Fin.repeat m a ∘ Fin.rev = Fin.repeat m (a ∘ Fin.rev)
def Fin.init E1 #
{n : ℕ} → {α : Fin (n + 1) → Sort u_1} → ((i : Fin (n + 1)) → α i) → (i : Fin n) → α i.castSucc
The beginning of an n+1 tuple, i.e., its first n entries
theorem Fin.init_def E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} {q : (i : Fin (n + 1)) → α i}, (Fin.init fun k ↦ q k) = fun k ↦ q k.castSucc
def Fin.snoc E1 #
{n : ℕ} → {α : Fin (n + 1) → Sort u_1} → ((i : Fin n) → α i.castSucc) → α (Fin.last n) → (i : Fin (n + 1)) → α i
Adding an element at the end of an n-tuple, to get an n+1-tuple. The name snoc comes from
cons (i.e., adding an element to the left of a tuple) read in reverse order.
theorem Fin.init_snoc E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (x : α (Fin.last n)) (p : (i : Fin n) → α i.castSucc),
Fin.init (Fin.snoc p x) = p
theorem Fin.snoc_castSucc E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (x : α (Fin.last n)) (p : (i : Fin n) → α i.castSucc) (i : Fin n),
Fin.snoc p x i.castSucc = p i
theorem Fin.snoc_apply_zero E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (x : α (Fin.last n)) (p : (i : Fin n) → α i.castSucc) [inst : NeZero n],
Fin.snoc p x 0 = p 0
theorem Fin.snoc_comp_castSucc E0 #
∀ {n : ℕ} {α : Sort u_2} {a : α} {f : Fin n → α}, Fin.snoc f a ∘ Fin.castSucc = f
theorem Fin.snoc_last E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (x : α (Fin.last n)) (p : (i : Fin n) → α i.castSucc),
Fin.snoc p x (Fin.last n) = x
theorem Fin.snoc_zero E1 #
∀ {α : Sort u_2} (p : Fin 0 → α) (x : α), Fin.snoc p x = fun x_1 ↦ x
theorem Fin.snoc_comp_natAdd E0 #
∀ {n m : ℕ} {α : Sort u_2} (f : Fin (m + n) → α) (a : α), Fin.snoc f a ∘ Fin.natAdd m = Fin.snoc (f ∘ Fin.natAdd m) a
theorem Fin.snoc_castAdd E0 #
∀ {m n : ℕ} {α : Fin (n + m + 1) → Sort u_2} (f : (i : Fin (n + m)) → α i.castSucc) (a : α (Fin.last (n + m)))
(i : Fin n), Fin.snoc f a (Fin.castAdd (m + 1) i) = f (Fin.castAdd m i)
theorem Fin.snoc_comp_castAdd E0 #
∀ {n m : ℕ} {α : Sort u_2} (f : Fin (n + m) → α) (a : α), Fin.snoc f a ∘ Fin.castAdd (m + 1) = f ∘ Fin.castAdd m
theorem Fin.snoc_update E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (x : α (Fin.last n)) (p : (i : Fin n) → α i.castSucc) (i : Fin n)
(y : α i.castSucc), Fin.snoc (Function.update p i y) x = Function.update (Fin.snoc p x) i.castSucc y
Updating a tuple and adding an element at the end commute.
theorem Fin.update_snoc_last E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (x : α (Fin.last n)) (p : (i : Fin n) → α i.castSucc) (z : α (Fin.last n)),
Function.update (Fin.snoc p x) (Fin.last n) z = Fin.snoc p z
Adding an element at the beginning of a tuple and then updating it amounts to adding it directly.
theorem Fin.range_snoc E0 #
∀ {n : ℕ} {α : Type u_2} (f : Fin n → α) (x : α), Set.range (Fin.snoc f x) = insert x (Set.range f)
theorem Fin.snoc_injective2 E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1}, Function.Injective2 Fin.snoc
As a binary function, Fin.snoc is injective.
theorem Fin.snoc_inj E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} {x y : (i : Fin n) → α i.castSucc} {xₙ yₙ : α (Fin.last n)},
Fin.snoc x xₙ = Fin.snoc y yₙ ↔ x = y ∧ xₙ = yₙ
theorem Fin.snoc_right_injective E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (x : (i : Fin n) → α i.castSucc), Function.Injective (Fin.snoc x)
theorem Fin.snoc_left_injective E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (xₙ : α (Fin.last n)), Function.Injective fun x ↦ Fin.snoc x xₙ
theorem Fin.snoc_init_self E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (q : (i : Fin (n + 1)) → α i), Fin.snoc (Fin.init q) (q (Fin.last n)) = q
Concatenating the first element of a tuple with its tail gives back the original tuple
theorem Fin.init_update_last E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (q : (i : Fin (n + 1)) → α i) (z : α (Fin.last n)),
Fin.init (Function.update q (Fin.last n) z) = Fin.init q
Updating the last element of a tuple does not change the beginning.
theorem Fin.init_update_castSucc E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (q : (i : Fin (n + 1)) → α i) (i : Fin n) (y : α i.castSucc),
Fin.init (Function.update q i.castSucc y) = Function.update (Fin.init q) i y
Updating an element and taking the beginning commute.
theorem Fin.tail_init_eq_init_tail E1 #
∀ {n : ℕ} {β : Sort u_2} (q : Fin (n + 2) → β), Fin.tail (Fin.init q) = Fin.init (Fin.tail q)
tail and init commute. We state this lemma in a non-dependent setting, as otherwise it
would involve a cast to convince Lean that the two types are equal, making it harder to use.
theorem Fin.cons_snoc_eq_snoc_cons E1 #
∀ {n : ℕ} {β : Sort u_2} (a : β) (q : Fin n → β) (b : β), Fin.cons a (Fin.snoc q b) = Fin.snoc (Fin.cons a q) b
cons and snoc commute. We state this lemma in a non-dependent setting, as otherwise it
would involve a cast to convince Lean that the two types are equal, making it harder to use.
theorem Fin.comp_snoc E1 #
∀ {n : ℕ} {α : Sort u_2} {β : Sort u_3} (g : α → β) (q : Fin n → α) (y : α), g ∘ Fin.snoc q y = Fin.snoc (g ∘ q) (g y)
theorem Fin.append_right_eq_snoc E1 #
∀ {α : Sort u_2} {n : ℕ} (x : Fin n → α) (x₀ : Fin 1 → α), Fin.append x x₀ = Fin.snoc x (x₀ 0)
Appending a one-tuple to the right is the same as Fin.snoc.
theorem Fin.snoc_eq_append E1 #
∀ {n : ℕ} {α : Sort u_2} (xs : Fin n → α) (x : α), Fin.snoc xs x = Fin.append xs (Fin.cons x Fin.elim0)
Fin.snoc is the same as appending a one-tuple
theorem Fin.append_left_snoc E1 #
∀ {n m : ℕ} {α : Sort u_2} (xs : Fin n → α) (x : α) (ys : Fin m → α),
Fin.append (Fin.snoc xs x) ys = Fin.append xs (Fin.cons x ys) ∘ Fin.cast ⋯
theorem Fin.append_right_cons E1 #
∀ {n m : ℕ} {α : Sort u_2} (xs : Fin n → α) (y : α) (ys : Fin m → α),
Fin.append xs (Fin.cons y ys) = Fin.append (Fin.snoc xs y) ys ∘ Fin.cast ⋯
theorem Fin.append_cons E1 #
∀ {m n : ℕ} {α : Sort u_2} (a : α) (as : Fin n → α) (bs : Fin m → α),
Fin.append (Fin.cons a as) bs = Fin.cons a (Fin.append as bs) ∘ Fin.cast ⋯
theorem Fin.append_snoc E1 #
∀ {m n : ℕ} {α : Sort u_2} (as : Fin n → α) (bs : Fin m → α) (b : α),
Fin.append as (Fin.snoc bs b) = Fin.snoc (Fin.append as bs) b
theorem Fin.comp_init E1 #
∀ {n : ℕ} {α : Sort u_2} {β : Sort u_3} (g : α → β) (q : Fin n.succ → α), g ∘ Fin.init q = Fin.init (g ∘ q)
def Fin.snocEquiv E1 #
{n : ℕ} → (α : Fin (n + 1) → Type u_2) → α (Fin.last n) × ((i : Fin n) → α i.castSucc) ≃ ((i : Fin (n + 1)) → α i)
Equivalence between tuples of length n + 1 and pairs of an element and a tuple of length n
given by separating out the last element of the tuple.
This is Fin.snoc as an Equiv.
theorem Fin.snocEquiv_symm_apply E0 #
∀ {n : ℕ} (α : Fin (n + 1) → Type u_2) (f : (i : Fin (n + 1)) → α i),
(Fin.snocEquiv α).symm f = (f (Fin.last n), Fin.init f)
theorem Fin.snocEquiv_apply E0 #
∀ {n : ℕ} (α : Fin (n + 1) → Type u_2) (f : α (Fin.last n) × ((i : Fin n) → α i.castSucc)),
(Fin.snocEquiv α) f = Fin.snoc f.2 f.1
def Fin.snocCases E1 #
{n : ℕ} →
{α : Fin (n + 1) → Sort u_1} →
{motive : ((i : Fin n.succ) → α i) → Sort u_2} →
((xs : (i : Fin n) → α i.castSucc) → (x : α (Fin.last n)) → motive (Fin.snoc xs x)) →
(x : (i : Fin n.succ) → α i) → motive x
Recurse on an n+1-tuple by splitting it its initial n-tuple and its last element.
theorem Fin.snocCases_snoc E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} {motive : ((i : Fin (n + 1)) → α i) → Sort u_2}
(snoc : (x : (i : Fin n) → α i.castSucc) → (x₀ : α (Fin.last n)) → motive (Fin.snoc x x₀))
(x : (i : Fin n) → Fin.init α i) (x₀ : α (Fin.last n)), Fin.snocCases snoc (Fin.snoc x x₀) = snoc x x₀
def Fin.snocInduction E1 #
{α : Sort u_2} →
{motive : {n : ℕ} → (Fin n → α) → Sort u_3} →
motive Fin.elim0 →
({n : ℕ} → (x : Fin n → α) → (x₀ : α) → motive x → motive (Fin.snoc x x₀)) → {n : ℕ} → (x : Fin n → α) → motive x
Recurse on a tuple by splitting into Fin.elim0 and Fin.snoc.
theorem Fin.snoc_injective_of_injective E1 #
∀ {n : ℕ} {α : Type u_2} {x₀ : α} {x : Fin n → α},
Function.Injective x → x₀ ∉ Set.range x → Function.Injective (Fin.snoc x x₀)
theorem Fin.snoc_injective_iff E0 #
∀ {n : ℕ} {α : Type u_2} {x₀ : α} {x : Fin n → α},
Function.Injective (Fin.snoc x x₀) ↔ Function.Injective x ∧ x₀ ∉ Set.range x
def Fin.succAboveCases E1 #
{n : ℕ} →
{α : Fin (n + 1) → Sort u} → (i : Fin (n + 1)) → α i → ((j : Fin n) → α (i.succAbove j)) → (j : Fin (n + 1)) → α j
Define a function on Fin (n + 1) from a value on i : Fin (n + 1) and values on each
Fin.succAbove i j, j : Fin n. This version is elaborated as eliminator and works for
propositions, see also Fin.insertNth for a version without an @[elab_as_elim]
attribute.
theorem Fin.forall_iff_succ E1 #
∀ {n : ℕ} {P : Fin (n + 1) → Prop}, (∀ (i : Fin (n + 1)), P i) ↔ P 0 ∧ ∀ (i : Fin n), P i.succ
Alias of Fin.forall_fin_succ.
theorem Fin.exists_iff_succ E1 #
∀ {n : ℕ} {P : Fin (n + 1) → Prop}, (∃ i, P i) ↔ P 0 ∨ ∃ i, P i.succ
Alias of Fin.exists_fin_succ.
theorem Fin.forall_iff_castSucc E1 #
∀ {n : ℕ} {P : Fin (n + 1) → Prop}, (∀ (i : Fin (n + 1)), P i) ↔ P (Fin.last n) ∧ ∀ (i : Fin n), P i.castSucc
theorem Fin.forall_fin_add E1 #
∀ {m n : ℕ} (P : Fin (m + n) → Prop),
(∀ (i : Fin (m + n)), P i) ↔ (∀ (i : Fin m), P (Fin.castAdd n i)) ∧ ∀ (j : Fin n), P (Fin.natAdd m j)
A finite sequence of properties P holds for {0, ..., m + n - 1} iff
it holds separately for both {0, ..., m - 1} and {m, ..., m + n - 1}.
theorem Fin.forall_fin_add_pi E1 #
∀ {m n : ℕ} {γ : Fin (m + n) → Sort u_3} {P : ((i : Fin (m + n)) → γ i) → Prop},
(∀ (v : (i : Fin (m + n)) → γ i), P v) ↔
∀ (vₘ : (i : Fin m) → γ (Fin.castAdd n i)) (vₙ : (j : Fin n) → γ (Fin.natAdd m j)), P fun i ↦ Fin.addCases vₘ vₙ i
A property holds for all dependent finite sequence of length m + n iff it holds for the concatenation of all pairs of length m sequences and length n sequences.
theorem Fin.exists_iff_castSucc E1 #
∀ {n : ℕ} {P : Fin (n + 1) → Prop}, (∃ i, P i) ↔ P (Fin.last n) ∨ ∃ i, P i.castSucc
theorem Fin.forall_iff_succAbove E1 #
∀ {n : ℕ} {P : Fin (n + 1) → Prop} (p : Fin (n + 1)),
(∀ (i : Fin (n + 1)), P i) ↔ P p ∧ ∀ (i : Fin n), P (p.succAbove i)
theorem Fin.exists_iff_succAbove E1 #
∀ {n : ℕ} {P : Fin (n + 1) → Prop} (p : Fin (n + 1)), (∃ i, P i) ↔ P p ∨ ∃ i, P (p.succAbove i)
def Fin.removeNth E1 #
{n : ℕ} → {α : Fin (n + 1) → Sort u_1} → (p : Fin (n + 1)) → ((i : Fin (n + 1)) → α i) → (i : Fin n) → α (p.succAbove i)
Remove the p-th entry of a tuple.
def Fin.insertNth E1 #
{n : ℕ} →
{α : Fin (n + 1) → Sort u_1} → (i : Fin (n + 1)) → α i → ((j : Fin n) → α (i.succAbove j)) → (j : Fin (n + 1)) → α j
Insert an element into a tuple at a given position. For i = 0 see Fin.cons,
for i = Fin.last n see Fin.snoc. See also Fin.succAboveCases for a version elaborated
as an eliminator.
theorem Fin.insertNth_apply_same E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (i : Fin (n + 1)) (x : α i) (p : (j : Fin n) → α (i.succAbove j)),
i.insertNth x p i = x
theorem Fin.insertNth_apply_succAbove E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (i : Fin (n + 1)) (x : α i) (p : (j : Fin n) → α (i.succAbove j)) (j : Fin n),
i.insertNth x p (i.succAbove j) = p j
theorem Fin.succAbove_cases_eq_insertNth E0 #
@Fin.succAboveCases = @Fin.insertNth
theorem Fin.removeNth_apply E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (p : Fin (n + 1)) (f : (i : Fin (n + 1)) → α i) (i : Fin n),
p.removeNth f i = f (p.succAbove i)
theorem Fin.cons_comp_succ_succAbove E0 #
∀ {n : ℕ} {β : Sort u_2} (x : β) (p : Fin (n + 1) → β) (i : Fin (n + 1)),
Fin.cons x p ∘ i.succ.succAbove = Fin.cons x (i.removeNth p)
theorem Fin.removeNth_fun_const E1 #
∀ {α : Type u_3} {n : ℕ} (i : Fin (n + 1)) (a : α), (i.removeNth fun x ↦ a) = fun x ↦ a
theorem Fin.removeNth_insertNth E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (p : Fin (n + 1)) (a : α p) (f : (i : Fin n) → α (p.succAbove i)),
p.removeNth (p.insertNth a f) = f
theorem Fin.removeNth_zero E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (f : (i : Fin (n + 1)) → α i), Fin.removeNth 0 f = Fin.tail f
theorem Fin.removeNth_last E0 #
∀ {n : ℕ} {α : Type u_3} (f : Fin (n + 1) → α), (Fin.last n).removeNth f = Fin.init f
theorem Fin.insertNth_comp_succAbove E0 #
∀ {n : ℕ} {β : Sort u_2} (i : Fin (n + 1)) (x : β) (p : Fin n → β), i.insertNth x p ∘ i.succAbove = p
theorem Fin.insertNth_eq_iff E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} {p : Fin (n + 1)} {a : α p} {f : (i : Fin n) → α (p.succAbove i)}
{g : (j : Fin (n + 1)) → α j}, p.insertNth a f = g ↔ a = g p ∧ f = p.removeNth g
theorem Fin.insertNth_injective2 E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} {p : Fin (n + 1)}, Function.Injective2 p.insertNth
As a binary function, Fin.insertNth is injective.
theorem Fin.insertNth_inj E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} {p : Fin (n + 1)} {x y : (i : Fin n) → α (p.succAbove i)} {xₚ yₚ : α p},
p.insertNth xₚ x = p.insertNth yₚ y ↔ xₚ = yₚ ∧ x = y
theorem Fin.insertNth_left_injective E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} {p : Fin (n + 1)} (x : (i : Fin n) → α (p.succAbove i)),
Function.Injective fun x_1 ↦ p.insertNth x_1 x
theorem Fin.insertNth_right_injective E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} {p : Fin (n + 1)} (x : α p), Function.Injective (p.insertNth x)
theorem Fin.insertNth_apply_below E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} {i j : Fin (n + 1)} (h : j < i) (x : α i) (p : (k : Fin n) → α (i.succAbove k)),
i.insertNth x p j = ⋯ ▸ p (j.castPred ⋯)
theorem Fin.insertNth_apply_above E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} {i j : Fin (n + 1)} (h : i < j) (x : α i) (p : (k : Fin n) → α (i.succAbove k)),
i.insertNth x p j = ⋯ ▸ p (j.pred ⋯)
theorem Fin.insertNth_zero E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (x : α 0) (p : (j : Fin n) → α (Fin.succAbove 0 j)),
Fin.insertNth 0 x p = Fin.cons x fun j ↦ cast ⋯ (p j)
theorem Fin.insertNth_zero' E0 #
∀ {n : ℕ} {β : Sort u_2} (x : β) (p : Fin n → β), Fin.insertNth 0 x p = Fin.cons x p
theorem Fin.insertNth_last E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (x : α (Fin.last n)) (p : (j : Fin n) → α ((Fin.last n).succAbove j)),
(Fin.last n).insertNth x p = Fin.snoc (fun j ↦ cast ⋯ (p j)) x
theorem Fin.insertNth_last' E0 #
∀ {n : ℕ} {β : Sort u_2} (x : β) (p : Fin n → β), (Fin.last n).insertNth x p = Fin.snoc p x
theorem Fin.insertNth_rev E1 #
∀ {n : ℕ} {α : Sort u_3} (i : Fin (n + 1)) (a : α) (f : Fin n → α) (j : Fin (n + 1)),
i.insertNth a f j.rev = i.rev.insertNth a (f ∘ Fin.rev) j
theorem Fin.insertNth_comp_rev E1 #
∀ {n : ℕ} {α : Sort u_3} (i : Fin (n + 1)) (x : α) (p : Fin n → α),
i.insertNth x p ∘ Fin.rev = i.rev.insertNth x (p ∘ Fin.rev)
theorem Fin.insertNth_succ_cons E0 #
∀ {n : ℕ} {α : Sort u_3} (i : Fin (n + 1)) (x a : α) (p : Fin n → α),
i.succ.insertNth x (Fin.cons a p) = Fin.cons a (i.insertNth x p)
theorem Fin.cons_rev E1 #
∀ {α : Sort u_3} {n : ℕ} (a : α) (f : Fin n → α) (i : Fin (n + 1)), Fin.cons a f i.rev = Fin.snoc (f ∘ Fin.rev) a i
theorem Fin.cons_comp_rev E1 #
∀ {α : Sort u_3} {n : ℕ} (a : α) (f : Fin n → α), Fin.cons a f ∘ Fin.rev = Fin.snoc (f ∘ Fin.rev) a
theorem Fin.snoc_rev E1 #
∀ {α : Sort u_3} {n : ℕ} (a : α) (f : Fin n → α) (i : Fin (n + 1)), Fin.snoc f a i.rev = Fin.cons a (f ∘ Fin.rev) i
theorem Fin.snoc_comp_rev E1 #
∀ {α : Sort u_3} {n : ℕ} (a : α) (f : Fin n → α), Fin.snoc f a ∘ Fin.rev = Fin.cons a (f ∘ Fin.rev)
theorem Fin.insertNth_binop E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (op : (j : Fin (n + 1)) → α j → α j → α j) (i : Fin (n + 1)) (x y : α i)
(p q : (j : Fin n) → α (i.succAbove j)),
(i.insertNth (op i x y) fun j ↦ op (i.succAbove j) (p j) (q j)) = fun j ↦ op j (i.insertNth x p j) (i.insertNth y q j)
theorem Fin.insertNth_le_iff E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Type u_3} [inst : (i : Fin (n + 1)) → Preorder (α i)] {i : Fin (n + 1)} {x : α i}
{p : (j : Fin n) → α (i.succAbove j)} {q : (j : Fin (n + 1)) → α j},
i.insertNth x p ≤ q ↔ x ≤ q i ∧ p ≤ fun j ↦ q (i.succAbove j)
theorem Fin.le_insertNth_iff E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Type u_3} [inst : (i : Fin (n + 1)) → Preorder (α i)] {i : Fin (n + 1)} {x : α i}
{p : (j : Fin n) → α (i.succAbove j)} {q : (j : Fin (n + 1)) → α j},
q ≤ i.insertNth x p ↔ q i ≤ x ∧ (fun j ↦ q (i.succAbove j)) ≤ p
theorem Fin.removeNth_update E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (p : Fin (n + 1)) (x : α p) (f : (j : Fin (n + 1)) → α j),
p.removeNth (Function.update f p x) = p.removeNth f
theorem Fin.removeNth_update_succAbove E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (p : Fin (n + 1)) (i : Fin n) (x : α (p.succAbove i))
(f : (j : Fin (n + 1)) → α j), p.removeNth (Function.update f (p.succAbove i) x) = Function.update (p.removeNth f) i x
theorem Fin.insertNth_removeNth E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (p : Fin (n + 1)) (x : α p) (f : (j : Fin (n + 1)) → α j),
p.insertNth x (p.removeNth f) = Function.update f p x
theorem Fin.insertNth_self_removeNth E1 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (p : Fin (n + 1)) (f : (j : Fin (n + 1)) → α j),
p.insertNth (f p) (p.removeNth f) = f
theorem Fin.range_insertNth E0 #
∀ {n : ℕ} {α : Type u_3} (p : Fin (n + 1)) (x : α) (f : Fin n → α),
Set.range (p.insertNth x f) = Set.insert x (Set.range f)
theorem Fin.update_insertNth E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (p : Fin (n + 1)) (x y : α p) (f : (i : Fin n) → α (p.succAbove i)),
Function.update (p.insertNth x f) p y = p.insertNth y f
theorem Fin.insertNth_update E0 #
∀ {n : ℕ} {α : Fin (n + 1) → Sort u_1} (p : Fin (n + 1)) (x : α p) (i : Fin n) (y : α (p.succAbove i))
(f : (j : Fin n) → α (p.succAbove j)),
p.insertNth x (Function.update f i y) = Function.update (p.insertNth x f) (p.succAbove i) y
def Fin.insertNthEquiv E1 #
{n : ℕ} →
(α : Fin (n + 1) → Type u) → (p : Fin (n + 1)) → α p × ((i : Fin n) → α (p.succAbove i)) ≃ ((i : Fin (n + 1)) → α i)
Equivalence between tuples of length n + 1 and pairs of an element and a tuple of length n
given by separating out the p-th element of the tuple.
This is Fin.insertNth as an Equiv.
theorem Fin.insertNthEquiv_symm_apply E0 #
∀ {n : ℕ} (α : Fin (n + 1) → Type u) (p : Fin (n + 1)) (f : (i : Fin (n + 1)) → α i),
(Fin.insertNthEquiv α p).symm f = (f p, p.removeNth f)
theorem Fin.insertNthEquiv_apply E0 #
∀ {n : ℕ} (α : Fin (n + 1) → Type u_3) (p : Fin (n + 1)) (f : α p × ((i : Fin n) → α (p.succAbove i))),
(Fin.insertNthEquiv α p) f = p.insertNth f.1 f.2
theorem Fin.insertNthEquiv_zero E0 #
∀ {n : ℕ} (α : Fin (n + 1) → Type u_3), Fin.insertNthEquiv α 0 = Fin.consEquiv α
theorem Fin.insertNthEquiv_last E0 #
∀ (n : ℕ) (α : Type u_3), Fin.insertNthEquiv (fun x ↦ α) (Fin.last n) = Fin.snocEquiv fun x ↦ α
Note this lemma can only be written about non-dependent tuples as insertNth (last n) = snoc is
not a definitional equality.
theorem Fin.removeNth_removeNth_heq_swap E1 #
∀ {n : ℕ} {α : Fin (n + 2) → Sort u_3} (m : (i : Fin (n + 2)) → α i) (i : Fin (n + 1)) (j : Fin (n + 2)),
i.removeNth (j.removeNth m) ≍ (i.predAbove j).removeNth ((j.succAbove i).removeNth m)
A HEq version of Fin.removeNth_removeNth_eq_swap.
theorem Fin.removeNth_removeNth_eq_swap E1 #
∀ {n : ℕ} {α : Sort u_3} (m : Fin (n + 2) → α) (i : Fin (n + 1)) (j : Fin (n + 2)),
i.removeNth (j.removeNth m) = (i.predAbove j).removeNth ((j.succAbove i).removeNth m)
Given an (n + 2)-tuple m and two indexes i : Fin (n + 1) and j : Fin (n + 2),
one can remove jth element from m, then remove ith element from the result,
or one can remove (j.succAbove i)th element from m,
then remove (i.predAbove j)th element from the result.
These two operations correspond to removing the same two elements in a different order,
so they result in the same n-tuple.
def Fin.find E1 #
{n : ℕ} → (p : Fin n → Prop) → [DecidablePred p] → (∃ k, p k) → Fin n
Fin.find p h returns the smallest index k : Fin n where p k is satisfied,
given that it is satisfied for some k.
theorem Fin.find_spec E1 #
∀ {n : ℕ} {p : Fin n → Prop} [inst : DecidablePred p] (h : ∃ k, p k), p (Fin.find p h)
Fin.find p h satisfies p.
theorem Fin.find_min E1 #
∀ {n : ℕ} {p : Fin n → Prop} [inst : DecidablePred p] (h : ∃ k, p k) {j : Fin n}, j < Fin.find p h → ¬p j
For m : Fin n, if m < Fin.find p h then m does not satisfy p.
theorem Fin.find_le_of_pos E1 #
∀ {n : ℕ} {p : Fin n → Prop} [inst : DecidablePred p] (h : ∃ k, p k) {j : Fin n}, p j → Fin.find p h ≤ j
For m : Fin n, if m satisfies p, then Fin.find p h ≤ m.
theorem Fin.find_eq_iff E0 #
∀ {n : ℕ} {p : Fin n → Prop} [inst : DecidablePred p] {i : Fin n} (h : ∃ k, p k), Fin.find p h = i ↔ p i ∧ ∀ j < i, ¬p j
theorem Fin.val_find E0 #
∀ {n : ℕ} {p : Fin n → Prop} [inst : DecidablePred p] (h : ∃ k, p k), ↑(Fin.find p h) = Nat.find ⋯
theorem Fin.find_nat_lt E1 #
∀ {n : ℕ} {p : ℕ → Prop} [inst : DecidablePred p] (h : ∃ k < n, p k), Nat.find ⋯ = ↑(Fin.find (fun x ↦ p ↑x) ⋯)
theorem Fin.find_lt_iff E0 #
∀ {n : ℕ} {p : Fin n → Prop} [inst : DecidablePred p] (h : ∃ k, p k) (i : Fin n), Fin.find p h < i ↔ ∃ m < i, p m
theorem Fin.find_le_iff E0 #
∀ {n : ℕ} {p : Fin n → Prop} [inst : DecidablePred p] (h : ∃ k, p k) (i : Fin n), Fin.find p h ≤ i ↔ ∃ m ≤ i, p m
theorem Fin.lt_find_iff E0 #
∀ {n : ℕ} {p : Fin n → Prop} [inst : DecidablePred p] (h : ∃ k, p k) (i : Fin n), i < Fin.find p h ↔ ∀ m ≤ i, ¬p m
theorem Fin.le_find_iff E0 #
∀ {n : ℕ} {p : Fin n → Prop} [inst : DecidablePred p] (h : ∃ k, p k) (i : Fin n), i ≤ Fin.find p h ↔ ∀ m < i, ¬p m
theorem Fin.find_eq_zero E0 #
∀ {n : ℕ} {p : Fin (n + 1) → Prop} [inst : DecidablePred p] (h : ∃ k, p k), Fin.find p h = 0 ↔ p 0
theorem Fin.find_of_not_zero E1 #
∀ {n : ℕ} {p : Fin (n + 1) → Prop} [inst : DecidablePred p] (h : ∃ i, p i) (h0 : ¬p 0),
Fin.find p h = (Fin.find (fun k ↦ p k.succ) ⋯).succ
theorem Fin.find_eq_dite E1 #
∀ {n : ℕ} {p : Fin (n + 1) → Prop} [inst : DecidablePred p] (h : ∃ i, p i),
Fin.find p h = if h0 : p 0 then 0 else (Fin.find (fun k ↦ p k.succ) ⋯).succ
theorem Fin.find_mono_of_le E1 #
∀ {n : ℕ} {p q : Fin n → Prop} [inst : DecidablePred p] [inst_1 : DecidablePred q] {i : Fin n} (hi : q i)
(hpq : ∀ j ≤ i, q j → p j), Fin.find p ⋯ ≤ Fin.find q ⋯
If a predicate q holds at some x and implies p up to that x, then
the earliest xq such that q xq is at least the smallest xp where p xp.
The stronger version of Fin.find_mono, since this one needs
implication only up to Fin.find _ while the other requires q implying p everywhere.
theorem Fin.find_mono E1 #
∀ {n : ℕ} {p q : Fin n → Prop} [inst : DecidablePred p] [inst_1 : DecidablePred q],
(∀ (i : Fin n), q i → p i) → ∀ {hp : ∃ i, p i} {hq : ∃ i, q i}, Fin.find p hp ≤ Fin.find q hq
A weak version of Fin.find_mono_of_le, requiring q implies p everywhere.
theorem Fin.find_congr E1 #
∀ {n : ℕ} {p q : Fin n → Prop} [inst : DecidablePred p] [inst_1 : DecidablePred q] {i : Fin n} (hi : p i)
(hpq : ∀ j ≤ i, p j ↔ q j), Fin.find p ⋯ = Fin.find q ⋯
If a predicate p holds at some x and agrees with q up to that x, then
their Fin.find agree. The stronger version of Fin.find_congr', since this one needs
agreement only up to Fin.find _ while the other requires p = q.
Usage of this lemma will likely be via obtain ⟨x, hx⟩ := hp; apply Fin.find_congr hx to unify q,
or provide it explicitly with rw [Fin.find_congr (q := q) hx].
theorem Fin.find_congr' E1 #
∀ {n : ℕ} {p q : Fin n → Prop} [inst : DecidablePred p] [inst_1 : DecidablePred q] {hp : ∃ i, p i} {hq : ∃ i, q i},
(∀ {i : Fin n}, p i ↔ q i) → Fin.find p hp = Fin.find q hq
A weak version of Fin.find_congr, requiring p = q everywhere.
theorem Fin.find_le E1 #
∀ {n : ℕ} {p : Fin n → Prop} [inst : DecidablePred p] {i : Fin n} (hi : p i), Fin.find p ⋯ ≤ i
theorem Fin.find_pos E1 #
∀ {n : ℕ} {p : Fin (n + 1) → Prop} [inst : DecidablePred p] (h : ∃ i, p i), 0 < Fin.find p h ↔ ¬p 0
theorem Fin.find_of_find_le E1 #
∀ {m n : ℕ} {p : Fin (m + n) → Prop} [inst : DecidablePred p] {hᵢ : ∃ i, p i} (hm : m ≤ ↑(Fin.find p hᵢ)),
Fin.find p hᵢ = Fin.natAdd m (Fin.find (fun j ↦ p (Fin.natAdd m j)) ⋯)
theorem Fin.find?_eq_dite E1 #
∀ {n : ℕ} {p : Fin n → Bool}, Fin.find? p = if h : ∃ i, p i = true then some (Fin.find (fun x ↦ p x = true) h) else none
theorem Fin.find?_decide_eq_dite E1 #
∀ {n : ℕ} {p : Fin n → Prop} [inst : DecidablePred p],
(Fin.find? fun x ↦ decide (p x)) = if h : ∃ i, p i then some (Fin.find p h) else none
theorem Fin.get_find?_eq_find_of_eq_true E1 #
∀ {n : ℕ} {i : Fin n} {p : Fin n → Bool} (h : p i = true), (Fin.find? p).get ⋯ = Fin.find (fun x ↦ p x = true) ⋯
theorem Fin.find?_decide_get_eq_find E1 #
∀ {n : ℕ} {p : Fin n → Prop} [inst : DecidablePred p] (h : ∃ i, p i),
(Fin.find? fun x ↦ decide (p x)).get ⋯ = Fin.find p h
theorem Fin.find_mem_find?_decide E1 #
∀ {n : ℕ} {p : Fin n → Prop} [inst : DecidablePred p] (h : ∃ i, p i), Fin.find p h ∈ Fin.find? fun b ↦ decide (p b)
theorem Fin.mem_find?_iff E0 #
∀ {n : ℕ} {p : Fin n → Bool} {i : Fin n}, i ∈ Fin.find? p ↔ p i = true ∧ ∀ j < i, ¬p j = true
theorem Fin.find?_eq_some_find_of_exists E1 #
∀ {n : ℕ} {p : Fin n → Bool} (h : ∃ i, p i = true), Fin.find? p = some (Fin.find (fun x ↦ p x = true) h)
theorem Fin.find?_eq_some_find_of_isSome E1 #
∀ {n : ℕ} {p : Fin n → Bool} (h : (Fin.find? p).isSome = true), Fin.find? p = some (Fin.find (fun x ↦ p x = true) ⋯)
def Fin.contractNth E1 #
{n : ℕ} → {α : Sort u_1} → Fin (n + 1) → (α → α → α) → (Fin (n + 1) → α) → Fin n → α
Sends (g₀, ..., gₙ) to (g₀, ..., op gⱼ gⱼ₊₁, ..., gₙ).
theorem Fin.contractNth_apply_of_lt E1 #
∀ {n : ℕ} {α : Sort u_1} (j : Fin (n + 1)) (op : α → α → α) (g : Fin (n + 1) → α) (k : Fin n),
↑k < ↑j → j.contractNth op g k = g k.castSucc
theorem Fin.contractNth_apply_of_eq E0 #
∀ {n : ℕ} {α : Sort u_1} (j : Fin (n + 1)) (op : α → α → α) (g : Fin (n + 1) → α) (k : Fin n),
↑k = ↑j → j.contractNth op g k = op (g k.castSucc) (g k.succ)
theorem Fin.contractNth_apply_of_gt E1 #
∀ {n : ℕ} {α : Sort u_1} (j : Fin (n + 1)) (op : α → α → α) (g : Fin (n + 1) → α) (k : Fin n),
↑j < ↑k → j.contractNth op g k = g k.succ
theorem Fin.contractNth_apply_of_ne E1 #
∀ {n : ℕ} {α : Sort u_1} (j : Fin (n + 1)) (op : α → α → α) (g : Fin (n + 1) → α) (k : Fin n),
↑j ≠ ↑k → j.contractNth op g k = g (j.succAbove k)
theorem Fin.comp_contractNth E1 #
∀ {n : ℕ} {α : Sort u_1} {β : Sort u_2} (opα : α → α → α) (opβ : β → β → β) {f : α → β},
(∀ (x y : α), f (opα x y) = opβ (f x) (f y)) →
∀ (j : Fin (n + 1)) (g : Fin (n + 1) → α), f ∘ j.contractNth opα g = j.contractNth opβ (f ∘ g)
theorem Fin.sigma_eq_of_eq_comp_cast E1 #
∀ {α : Type u_1} {a b : (ii : ℕ) × (Fin ii → α)} (h : a.fst = b.fst), a.snd = b.snd ∘ Fin.cast h → a = b
To show two sigma pairs of tuples agree, it to show the second elements are related via
Fin.cast.
theorem Fin.sigma_eq_iff_eq_comp_cast E1 #
∀ {α : Type u_1} {a b : (ii : ℕ) × (Fin ii → α)}, a = b ↔ ∃ (h : a.fst = b.fst), a.snd = b.snd ∘ Fin.cast h
Fin.sigma_eq_of_eq_comp_cast as an iff.
def piFinTwoEquiv E1 #
(α : Fin 2 → Type u) → ((i : Fin 2) → α i) ≃ α 0 × α 1
Π i : Fin 2, α i is equivalent to α 0 × α 1. See also finTwoArrowEquiv for a
non-dependent version and prodEquivPiFinTwo for a version with inputs α β : Type u.
theorem piFinTwoEquiv_apply E0 #
∀ (α : Fin 2 → Type u), ⇑(piFinTwoEquiv α) = fun f ↦ (f 0, f 1)
theorem piFinTwoEquiv_symm_apply E0 #
∀ (α : Fin 2 → Type u), ⇑(piFinTwoEquiv α).symm = fun p ↦ Fin.cons p.1 (Fin.cons p.2 finZeroElim)