Documentation

Mathlib.Data.Fin.Tuple.Basic

Operation on tuples #

We interpret maps ∀ i : Fin n, α i∀ 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.

We define the following operations:

@[simp]
theorem Fin.tuple0_le {α : Fin 0Type u_1} [inst : (i : Fin 0) → Preorder (α i)] (f : (i : Fin 0) → α i) (g : (i : Fin 0) → α i) :
f g
def Fin.tail {n : } {α : Fin (n + 1)Type u} (q : (i : Fin (n + 1)) → α i) (i : Fin n) :
α (Fin.succ i)

The tail of an n+1 tuple, i.e., its last n entries.

Equations
theorem Fin.tail_def {n : } {α : Fin (n + 1)Type u_1} {q : (i : Fin (n + 1)) → α i} :
(Fin.tail fun k => q k) = fun k => q (Fin.succ k)
def Fin.cons {n : } {α : Fin (n + 1)Type u} (x : α 0) (p : (i : Fin n) → α (Fin.succ i)) (i : Fin (n + 1)) :
α i

Adding an element at the beginning of an n-tuple, to get an n+1-tuple.

Equations
@[simp]
theorem Fin.tail_cons {n : } {α : Fin (n + 1)Type u} (x : α 0) (p : (i : Fin n) → α (Fin.succ i)) :
@[simp]
theorem Fin.cons_succ {n : } {α : Fin (n + 1)Type u} (x : α 0) (p : (i : Fin n) → α (Fin.succ i)) (i : Fin n) :
Fin.cons x p (Fin.succ i) = p i
@[simp]
theorem Fin.cons_zero {n : } {α : Fin (n + 1)Type u} (x : α 0) (p : (i : Fin n) → α (Fin.succ i)) :
Fin.cons x p 0 = x
@[simp]
theorem Fin.cons_update {n : } {α : Fin (n + 1)Type u} (x : α 0) (p : (i : Fin n) → α (Fin.succ i)) (i : Fin n) (y : α (Fin.succ i)) :

Updating a tuple and adding an element at the beginning commute.

theorem Fin.cons_injective2 {n : } {α : Fin (n + 1)Type u} :

As a binary function, Fin.cons is injective.

@[simp]
theorem Fin.cons_eq_cons {n : } {α : Fin (n + 1)Type u} {x₀ : α 0} {y₀ : α 0} {x : (i : Fin n) → α (Fin.succ i)} {y : (i : Fin n) → α (Fin.succ i)} :
Fin.cons x₀ x = Fin.cons y₀ y x₀ = y₀ x = y
theorem Fin.cons_left_injective {n : } {α : Fin (n + 1)Type u} (x : (i : Fin n) → α (Fin.succ i)) :
Function.Injective fun x₀ => Fin.cons x₀ x
theorem Fin.cons_right_injective {n : } {α : Fin (n + 1)Type u} (x₀ : α 0) :
theorem Fin.update_cons_zero {n : } {α : Fin (n + 1)Type u} (x : α 0) (p : (i : Fin n) → α (Fin.succ i)) (z : α 0) :

Adding an element at the beginning of a tuple and then updating it amounts to adding it directly.

@[simp]
theorem Fin.cons_self_tail {n : } {α : Fin (n + 1)Type 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

def Fin.consCases {n : } {α : Fin (n + 1)Type u} {P : ((i : Fin (Nat.succ n)) → α i) → Sort v} (h : (x₀ : α 0) → (x : (i : Fin n) → α (Fin.succ i)) → P (Fin.cons x₀ x)) (x : (i : Fin (Nat.succ n)) → α i) :
P x

Recurse on an n+1-tuple by splitting it into a single element and an n-tuple.

Equations
@[simp]
theorem Fin.consCases_cons {n : } {α : Fin (n + 1)Type u} {P : ((i : Fin (Nat.succ n)) → α i) → Sort v} (h : (x₀ : α 0) → (x : (i : Fin n) → α (Fin.succ i)) → P (Fin.cons x₀ x)) (x₀ : α 0) (x : (i : Fin n) → α (Fin.succ i)) :
Fin.consCases h (Fin.cons x₀ x) = h x₀ x
def Fin.consInduction {α : Type u_1} {P : {n : } → (Fin nα) → Sort v} (h0 : P 0 Fin.elim0) (h : {n : } → (x₀ : α) → (x : Fin nα) → P n xP (n + 1) (Fin.cons x₀ x)) {n : } (x : Fin nα) :
P n x

Recurse on an tuple by splitting into Fin.elim0 and Fin.cons.

Equations
theorem Fin.cons_injective_of_injective {n : } {α : Type u_1} {x₀ : α} {x : Fin nα} (hx₀ : ¬x₀ Set.range x) (hx : Function.Injective x) :
theorem Fin.cons_injective_iff {n : } {α : Type u_1} {x₀ : α} {x : Fin nα} :
@[simp]
theorem Fin.forall_fin_zero_pi {α : Fin 0Sort u_1} {P : ((i : Fin 0) → α i) → Prop} :
((x : (i : Fin 0) → α i) → P x) P finZeroElim
@[simp]
theorem Fin.exists_fin_zero_pi {α : Fin 0Sort u_1} {P : ((i : Fin 0) → α i) → Prop} :
(x, P x) P finZeroElim
theorem Fin.forall_fin_succ_pi {n : } {α : Fin (n + 1)Type u} {P : ((i : Fin (n + 1)) → α i) → Prop} :
((x : (i : Fin (n + 1)) → α i) → P x) (a : α 0) → (v : (i : Fin n) → α (Fin.succ i)) → P (Fin.cons a v)
theorem Fin.exists_fin_succ_pi {n : } {α : Fin (n + 1)Type u} {P : ((i : Fin (n + 1)) → α i) → Prop} :
(x, P x) a v, P (Fin.cons a v)
@[simp]
theorem Fin.tail_update_zero {n : } {α : Fin (n + 1)Type u} (q : (i : Fin (n + 1)) → α i) (z : α 0) :

Updating the first element of a tuple does not change the tail.

@[simp]
theorem Fin.tail_update_succ {n : } {α : Fin (n + 1)Type u} (q : (i : Fin (n + 1)) → α i) (i : Fin n) (y : α (Fin.succ i)) :

Updating a nonzero element and taking the tail commute.

theorem Fin.comp_cons {n : } {α : Type u_1} {β : Type u_2} (g : αβ) (y : α) (q : Fin nα) :
g Fin.cons y q = Fin.cons (g y) (g q)
theorem Fin.comp_tail {n : } {α : Type u_1} {β : Type u_2} (g : αβ) (q : Fin (Nat.succ n)α) :
theorem Fin.le_cons {n : } {α : Fin (n + 1)Type u} [inst : (i : Fin (n + 1)) → Preorder (α i)] {x : α 0} {q : (i : Fin (n + 1)) → α i} {p : (i : Fin n) → α (Fin.succ i)} :
q Fin.cons x p q 0 x Fin.tail q p
theorem Fin.cons_le {n : } {α : Fin (n + 1)Type u} [inst : (i : Fin (n + 1)) → Preorder (α i)] {x : α 0} {q : (i : Fin (n + 1)) → α i} {p : (i : Fin n) → α (Fin.succ i)} :
Fin.cons x p q x q 0 p Fin.tail q
theorem Fin.cons_le_cons {n : } {α : Fin (n + 1)Type u} [inst : (i : Fin (n + 1)) → Preorder (α i)] {x₀ : α 0} {y₀ : α 0} {x : (i : Fin n) → α (Fin.succ i)} {y : (i : Fin n) → α (Fin.succ i)} :
Fin.cons x₀ x Fin.cons y₀ y x₀ y₀ x y
theorem Fin.pi_lex_lt_cons_cons {n : } {α : Fin (n + 1)Type u} {x₀ : α 0} {y₀ : α 0} {x : (i : Fin n) → α (Fin.succ i)} {y : (i : Fin n) → α (Fin.succ i)} (s : {i : Fin (Nat.succ n)} → α iα iProp) :
Pi.Lex (fun x x_1 => x < x_1) s (Fin.cons x₀ x) (Fin.cons y₀ y) s 0 x₀ y₀ x₀ = y₀ Pi.Lex (fun x x_1 => x < x_1) (fun i => s (Fin.succ i)) x y
theorem Fin.range_fin_succ {n : } {α : Type u_1} (f : Fin (n + 1)α) :
@[simp]
theorem Fin.range_cons {α : Type u_1} {n : } (x : α) (b : Fin nα) :
def Fin.append {m : } {n : } {α : Type u_1} (a : Fin mα) (b : 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.

Equations
@[simp]
theorem Fin.append_left {m : } {n : } {α : Type u_1} (u : Fin mα) (v : Fin nα) (i : Fin m) :
Fin.append u v ((Fin.castAdd n).toEmbedding i) = u i
@[simp]
theorem Fin.append_right {m : } {n : } {α : Type u_1} (u : Fin mα) (v : Fin nα) (i : Fin n) :
Fin.append u v ((Fin.natAdd m).toEmbedding i) = v i
theorem Fin.append_right_nil {m : } {n : } {α : Type u_1} (u : Fin mα) (v : Fin nα) (hv : n = 0) :
Fin.append u v = u (RelIso.toRelEmbedding (Fin.cast (_ : m + n = m))).toEmbedding
@[simp]
theorem Fin.append_elim0' {m : } {α : Type u_1} (u : Fin mα) :
Fin.append u Fin.elim0' = u (RelIso.toRelEmbedding (Fin.cast (_ : m + 0 = m))).toEmbedding
theorem Fin.append_left_nil {m : } {n : } {α : Type u_1} (u : Fin mα) (v : Fin nα) (hu : m = 0) :
Fin.append u v = v (RelIso.toRelEmbedding (Fin.cast (_ : m + n = n))).toEmbedding
@[simp]
theorem Fin.elim0'_append {n : } {α : Type u_1} (v : Fin nα) :
Fin.append Fin.elim0' v = v (RelIso.toRelEmbedding (Fin.cast (_ : 0 + n = n))).toEmbedding
theorem Fin.append_assoc {m : } {n : } {p : } {α : Type u_1} (a : Fin mα) (b : Fin nα) (c : Fin pα) :
Fin.append (Fin.append a b) c = Fin.append a (Fin.append b c) (RelIso.toRelEmbedding (Fin.cast (_ : m + n + p = m + (n + p)))).toEmbedding
def Fin.repeat {n : } {α : Type u_1} (m : ) (a : Fin nα) :
Fin (m * n)α

Repeat a m times. For example Fin.repeat 2 ![0, 3, 7] = ![0, 3, 7, 0, 3, 7].

Equations
@[simp]
theorem Fin.repeat_apply {m : } {n : } {α : Type u_1} (a : Fin nα) (i : Fin (m * n)) :
Fin.repeat m a i = a (Fin.modNat i)
@[simp]
theorem Fin.repeat_zero {n : } {α : Type u_1} (a : Fin nα) :
Fin.repeat 0 a = Fin.elim0' (RelIso.toRelEmbedding (Fin.cast (_ : 0 * n = 0))).toEmbedding
@[simp]
theorem Fin.repeat_one {n : } {α : Type u_1} (a : Fin nα) :
Fin.repeat 1 a = a (RelIso.toRelEmbedding (Fin.cast (_ : 1 * n = n))).toEmbedding
theorem Fin.repeat_succ {n : } {α : Type u_1} (a : Fin nα) (m : ) :
Fin.repeat (Nat.succ m) a = Fin.append a (Fin.repeat m a) (RelIso.toRelEmbedding (Fin.cast (_ : Nat.succ m * n = n + m * n))).toEmbedding
@[simp]
theorem Fin.repeat_add {n : } {α : Type u_1} (a : Fin nα) (m₁ : ) (m₂ : ) :
Fin.repeat (m₁ + m₂) a = Fin.append (Fin.repeat m₁ a) (Fin.repeat m₂ a) (RelIso.toRelEmbedding (Fin.cast (_ : (m₁ + m₂) * n = m₁ * n + m₂ * n))).toEmbedding

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.

def Fin.init {n : } {α : Fin (n + 1)Type u} (q : (i : Fin (n + 1)) → α i) (i : Fin n) :
α (Fin.castSucc.toEmbedding i)

The beginning of an n+1 tuple, i.e., its first n entries

Equations
  • Fin.init q i = q (Fin.castSucc.toEmbedding i)
theorem Fin.init_def {n : } {α : Fin (n + 1)Type u_1} {q : (i : Fin (n + 1)) → α i} :
(Fin.init fun k => q k) = fun k => q (Fin.castSucc.toEmbedding k)
def Fin.snoc {n : } {α : Fin (n + 1)Type u} (p : (i : Fin n) → α (Fin.castSucc.toEmbedding i)) (x : α (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.

Equations
@[simp]
theorem Fin.init_snoc {n : } {α : Fin (n + 1)Type u} (x : α (Fin.last n)) (p : (i : Fin n) → α (Fin.castSucc.toEmbedding i)) :
@[simp]
theorem Fin.snoc_cast_succ {n : } {α : Fin (n + 1)Type u} (x : α (Fin.last n)) (p : (i : Fin n) → α (Fin.castSucc.toEmbedding i)) (i : Fin n) :
Fin.snoc p x (Fin.castSucc.toEmbedding i) = p i
@[simp]
theorem Fin.snoc_comp_cast_succ {n : } {α : Type u_1} {a : α} {f : Fin nα} :
Fin.snoc f a Fin.castSucc.toEmbedding = f
@[simp]
theorem Fin.snoc_last {n : } {α : Fin (n + 1)Type u} (x : α (Fin.last n)) (p : (i : Fin n) → α (Fin.castSucc.toEmbedding i)) :
Fin.snoc p x (Fin.last n) = x
@[simp]
theorem Fin.snoc_comp_nat_add {n : } {m : } {α : Type u_1} (f : Fin (m + n)α) (a : α) :
Fin.snoc f a (Fin.natAdd m).toEmbedding = Fin.snoc (f (Fin.natAdd m).toEmbedding) a
@[simp]
theorem Fin.snoc_cast_add {m : } {n : } {α : Fin (n + m + 1)Type u_1} (f : (i : Fin (n + m)) → α (Fin.castSucc.toEmbedding i)) (a : α (Fin.last (n + m))) (i : Fin n) :
Fin.snoc f a ((Fin.castAdd (m + 1)).toEmbedding i) = f ((Fin.castAdd m).toEmbedding i)
@[simp]
theorem Fin.snoc_comp_cast_add {n : } {m : } {α : Type u_1} (f : Fin (n + m)α) (a : α) :
Fin.snoc f a (Fin.castAdd (m + 1)).toEmbedding = f (Fin.castAdd m).toEmbedding
@[simp]
theorem Fin.snoc_update {n : } {α : Fin (n + 1)Type u} (x : α (Fin.last n)) (p : (i : Fin n) → α (Fin.castSucc.toEmbedding i)) (i : Fin n) (y : α (Fin.castSucc.toEmbedding i)) :
Fin.snoc (Function.update p i y) x = Function.update (Fin.snoc p x) (Fin.castSucc.toEmbedding i) y

Updating a tuple and adding an element at the end commute.

theorem Fin.update_snoc_last {n : } {α : Fin (n + 1)Type u} (x : α (Fin.last n)) (p : (i : Fin n) → α (Fin.castSucc.toEmbedding i)) (z : α (Fin.last n)) :

Adding an element at the beginning of a tuple and then updating it amounts to adding it directly.

@[simp]
theorem Fin.snoc_init_self {n : } {α : Fin (n + 1)Type u} (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

@[simp]
theorem Fin.init_update_last {n : } {α : Fin (n + 1)Type u} (q : (i : Fin (n + 1)) → α i) (z : α (Fin.last n)) :

Updating the last element of a tuple does not change the beginning.

@[simp]
theorem Fin.init_update_castSucc {n : } {α : Fin (n + 1)Type u} (q : (i : Fin (n + 1)) → α i) (i : Fin n) (y : α (Fin.castSucc.toEmbedding i)) :
Fin.init (Function.update q (Fin.castSucc.toEmbedding i) y) = Function.update (Fin.init q) i y

Updating an element and taking the beginning commute.

theorem Fin.tail_init_eq_init_tail {n : } {β : Type u_1} (q : Fin (n + 2)β) :

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 {n : } {β : Type u_1} (a : β) (q : Fin nβ) (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 {n : } {α : Type u_1} {β : Type u_2} (g : αβ) (q : Fin nα) (y : α) :
g Fin.snoc q y = Fin.snoc (g q) (g y)
theorem Fin.comp_init {n : } {α : Type u_1} {β : Type u_2} (g : αβ) (q : Fin (Nat.succ n)α) :
def Fin.succAboveCases {n : } {α : Fin (n + 1)Sort u} (i : Fin (n + 1)) (x : α i) (p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding 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.

Equations
  • One or more equations did not get rendered due to their size.
theorem Fin.forall_iff_succAbove {n : } {p : Fin (n + 1)Prop} (i : Fin (n + 1)) :
((j : Fin (n + 1)) → p j) p i ((j : Fin n) → p ((Fin.succAbove i).toEmbedding j))
def Fin.insertNth {n : } {α : Fin (n + 1)Type u} (i : Fin (n + 1)) (x : α i) (p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding 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.

Equations
@[simp]
theorem Fin.insertNth_apply_same {n : } {α : Fin (n + 1)Type u} (i : Fin (n + 1)) (x : α i) (p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)) :
Fin.insertNth i x p i = x
@[simp]
theorem Fin.insertNth_apply_succAbove {n : } {α : Fin (n + 1)Type u} (i : Fin (n + 1)) (x : α i) (p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)) (j : Fin n) :
Fin.insertNth i x p ((Fin.succAbove i).toEmbedding j) = p j
@[simp]
theorem Fin.insertNth_comp_succAbove {n : } {β : Type v} (i : Fin (n + 1)) (x : β) (p : Fin nβ) :
Fin.insertNth i x p (Fin.succAbove i).toEmbedding = p
theorem Fin.insertNth_eq_iff {n : } {α : Fin (n + 1)Type u} {i : Fin (n + 1)} {x : α i} {p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)} {q : (j : Fin (n + 1)) → α j} :
Fin.insertNth i x p = q q i = x p = fun j => q ((Fin.succAbove i).toEmbedding j)
theorem Fin.eq_insertNth_iff {n : } {α : Fin (n + 1)Type u} {i : Fin (n + 1)} {x : α i} {p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)} {q : (j : Fin (n + 1)) → α j} :
q = Fin.insertNth i x p q i = x p = fun j => q ((Fin.succAbove i).toEmbedding j)
theorem Fin.insertNth_apply_below {n : } {α : Fin (n + 1)Type u} {i : Fin (n + 1)} {j : Fin (n + 1)} (h : j < i) (x : α i) (p : (k : Fin n) → α ((Fin.succAbove i).toEmbedding k)) :
Fin.insertNth i x p j = Eq.recOn (_ : (Fin.succAbove i).toEmbedding (Fin.castLt j (_ : j < n)) = j) (p (Fin.castLt j (_ : j < n)))
theorem Fin.insertNth_apply_above {n : } {α : Fin (n + 1)Type u} {i : Fin (n + 1)} {j : Fin (n + 1)} (h : i < j) (x : α i) (p : (k : Fin n) → α ((Fin.succAbove i).toEmbedding k)) :
Fin.insertNth i x p j = Eq.recOn (_ : (Fin.succAbove i).toEmbedding (Fin.pred j (_ : j 0)) = j) (p (Fin.pred j (_ : j 0)))
theorem Fin.insertNth_zero {n : } {α : Fin (n + 1)Type u} (x : α 0) (p : (j : Fin n) → α ((Fin.succAbove 0).toEmbedding j)) :
Fin.insertNth 0 x p = Fin.cons x fun j => cast (_ : α ((Fin.succAbove 0).toEmbedding j) = α (Fin.succ j)) (p j)
@[simp]
theorem Fin.insertNth_zero' {n : } {β : Type v} (x : β) (p : Fin nβ) :
theorem Fin.insertNth_last {n : } {α : Fin (n + 1)Type u} (x : α (Fin.last n)) (p : (j : Fin n) → α ((Fin.succAbove (Fin.last n)).toEmbedding j)) :
Fin.insertNth (Fin.last n) x p = Fin.snoc (fun j => cast (_ : α ((Fin.succAbove (Fin.last n)).toEmbedding j) = α (Fin.castSucc.toEmbedding j)) (p j)) x
@[simp]
theorem Fin.insertNth_last' {n : } {β : Type v} (x : β) (p : Fin nβ) :
@[simp]
theorem Fin.insertNth_zero_right {n : } {α : Fin (n + 1)Type u} [inst : (j : Fin (n + 1)) → Zero (α j)] (i : Fin (n + 1)) (x : α i) :
theorem Fin.insertNth_binop {n : } {α : Fin (n + 1)Type u} (op : (j : Fin (n + 1)) → α jα jα j) (i : Fin (n + 1)) (x : α i) (y : α i) (p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)) (q : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)) :
(Fin.insertNth i (op i x y) fun j => op ((Fin.succAbove i).toEmbedding j) (p j) (q j)) = fun j => op j (Fin.insertNth i x p j) (Fin.insertNth i y q j)
@[simp]
theorem Fin.insertNth_mul {n : } {α : Fin (n + 1)Type u} [inst : (j : Fin (n + 1)) → Mul (α j)] (i : Fin (n + 1)) (x : α i) (y : α i) (p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)) (q : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)) :
Fin.insertNth i (x * y) (p * q) = Fin.insertNth i x p * Fin.insertNth i y q
@[simp]
theorem Fin.insertNth_add {n : } {α : Fin (n + 1)Type u} [inst : (j : Fin (n + 1)) → Add (α j)] (i : Fin (n + 1)) (x : α i) (y : α i) (p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)) (q : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)) :
Fin.insertNth i (x + y) (p + q) = Fin.insertNth i x p + Fin.insertNth i y q
@[simp]
theorem Fin.insertNth_div {n : } {α : Fin (n + 1)Type u} [inst : (j : Fin (n + 1)) → Div (α j)] (i : Fin (n + 1)) (x : α i) (y : α i) (p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)) (q : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)) :
Fin.insertNth i (x / y) (p / q) = Fin.insertNth i x p / Fin.insertNth i y q
@[simp]
theorem Fin.insertNth_sub {n : } {α : Fin (n + 1)Type u} [inst : (j : Fin (n + 1)) → Sub (α j)] (i : Fin (n + 1)) (x : α i) (y : α i) (p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)) (q : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)) :
Fin.insertNth i (x - y) (p - q) = Fin.insertNth i x p - Fin.insertNth i y q
@[simp]
theorem Fin.insertNth_sub_same {n : } {α : Fin (n + 1)Type u} [inst : (j : Fin (n + 1)) → AddGroup (α j)] (i : Fin (n + 1)) (x : α i) (y : α i) (p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)) :
theorem Fin.insertNth_le_iff {n : } {α : Fin (n + 1)Type u} [inst : (i : Fin (n + 1)) → Preorder (α i)] {i : Fin (n + 1)} {x : α i} {p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)} {q : (j : Fin (n + 1)) → α j} :
Fin.insertNth i x p q x q i p fun j => q ((Fin.succAbove i).toEmbedding j)
theorem Fin.le_insertNth_iff {n : } {α : Fin (n + 1)Type u} [inst : (i : Fin (n + 1)) → Preorder (α i)] {i : Fin (n + 1)} {x : α i} {p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)} {q : (j : Fin (n + 1)) → α j} :
q Fin.insertNth i x p q i x (fun j => q ((Fin.succAbove i).toEmbedding j)) p
theorem Fin.insertNth_mem_Icc {n : } {α : Fin (n + 1)Type u} [inst : (i : Fin (n + 1)) → Preorder (α i)] {i : Fin (n + 1)} {x : α i} {p : (j : Fin n) → α ((Fin.succAbove i).toEmbedding j)} {q₁ : (j : Fin (n + 1)) → α j} {q₂ : (j : Fin (n + 1)) → α j} :
Fin.insertNth i x p Set.Icc q₁ q₂ x Set.Icc (q₁ i) (q₂ i) p Set.Icc (fun j => q₁ ((Fin.succAbove i).toEmbedding j)) fun j => q₂ ((Fin.succAbove i).toEmbedding j)
theorem Fin.preimage_insertNth_Icc_of_mem {n : } {α : Fin (n + 1)Type u} [inst : (i : Fin (n + 1)) → Preorder (α i)] {i : Fin (n + 1)} {x : α i} {q₁ : (j : Fin (n + 1)) → α j} {q₂ : (j : Fin (n + 1)) → α j} (hx : x Set.Icc (q₁ i) (q₂ i)) :
Fin.insertNth i x ⁻¹' Set.Icc q₁ q₂ = Set.Icc (fun j => q₁ ((Fin.succAbove i).toEmbedding j)) fun j => q₂ ((Fin.succAbove i).toEmbedding j)
theorem Fin.preimage_insertNth_Icc_of_not_mem {n : } {α : Fin (n + 1)Type u} [inst : (i : Fin (n + 1)) → Preorder (α i)] {i : Fin (n + 1)} {x : α i} {q₁ : (j : Fin (n + 1)) → α j} {q₂ : (j : Fin (n + 1)) → α j} (hx : ¬x Set.Icc (q₁ i) (q₂ i)) :
def Fin.find {n : } (p : Fin nProp) [inst : DecidablePred p] :

find p returns the first index n where p n is satisfied, and none if it is never satisfied.

Equations
  • One or more equations did not get rendered due to their size.
  • Fin.find _p = none
theorem Fin.find_spec {n : } (p : Fin nProp) [inst : DecidablePred p] {i : Fin n} :
i Fin.find pp i

If find p = some i, then p i holds

theorem Fin.isSome_find_iff {n : } {p : Fin nProp} [inst : DecidablePred p] :

find p does not return none if and only if p i holds at some index i.

theorem Fin.find_eq_none_iff {n : } {p : Fin nProp} [inst : DecidablePred p] :
Fin.find p = none ∀ (i : Fin n), ¬p i

find p returns none if and only if p i never holds.

theorem Fin.find_min {n : } {p : Fin nProp} [inst : DecidablePred p] {i : Fin n} :
i Fin.find p∀ {j : Fin n}, j < i¬p j

If find p returns some i, then p j does not hold for j < i, i.e., i is minimal among the indices where p holds.

theorem Fin.find_min' {n : } {p : Fin nProp} [inst : DecidablePred p] {i : Fin n} (h : i Fin.find p) {j : Fin n} (hj : p j) :
i j
theorem Fin.nat_find_mem_find {n : } {p : Fin nProp} [inst : DecidablePred p] (h : i hin, p { val := i, isLt := hin }) :
{ val := Nat.find h, isLt := (_ : Nat.find h < n) } Fin.find p
theorem Fin.mem_find_iff {n : } {p : Fin nProp} [inst : DecidablePred p] {i : Fin n} :
i Fin.find p p i ∀ (j : Fin n), p ji j
theorem Fin.find_eq_some_iff {n : } {p : Fin nProp} [inst : DecidablePred p] {i : Fin n} :
Fin.find p = some i p i ∀ (j : Fin n), p ji j
theorem Fin.mem_find_of_unique {n : } {p : Fin nProp} [inst : DecidablePred p] (h : ∀ (i j : Fin n), p ip ji = j) {i : Fin n} (hi : p i) :
theorem Fin.sigma_eq_of_eq_comp_cast {α : Type u_1} {a : (ii : ) × (Fin iiα)} {b : (ii : ) × (Fin iiα)} (h : a.fst = b.fst) :
a.snd = b.snd (RelIso.toRelEmbedding (Fin.cast h)).toEmbeddinga = 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 {α : Type u_1} {a : (ii : ) × (Fin iiα)} {b : (ii : ) × (Fin iiα)} :
a = b h, a.snd = b.snd (RelIso.toRelEmbedding (Fin.cast h)).toEmbedding

Fin.sigma_eq_of_eq_comp_cast as an iff.