Successors and predecessor operations of Fin n #
This file contains a number of definitions and lemmas
related to Fin.succ, Fin.pred, and related operations on Fin n.
Main definitions #
finCongr:Fin.castas anEquiv, equivalence betweenFin nandFin mwhenn = m;Fin.succAbove: embedsFin nintoFin (n + 1)skippingp.Fin.predAbove: the (partial) inverse ofFin.succAbove.
succ and casts into larger Fin types #
The Fin.succ_one_eq_two in Lean only applies in Fin (n+2).
This one instead uses a NeZero n typeclass hypothesis.
The Fin.le_zero_iff in Lean only applies in Fin (n+1).
This one instead uses a NeZero n typeclass hypothesis.
The 'identity' equivalence between Fin m and Fin n when m = n.
Instances For
While in many cases finCongr is better than Equiv.cast/cast, sometimes we want to apply
a generic theorem about cast.
While in many cases Fin.cast is better than Equiv.cast/cast, sometimes we want to apply
a generic theorem about cast.
The Fin.castSucc_zero in Lean only applies in Fin (n+1).
This one instead uses a NeZero n typeclass hypothesis.
castSucc i is positive when i is positive.
The Fin.castSucc_pos in Lean only applies in Fin (n+1).
This one instead uses a NeZero n typeclass hypothesis.
pred #
A version of the right-to-left implication of castPred_le_castPred_iff
that deduces i ≠ last n from i ≤ j and j ≠ last n.
A version of the right-to-left implication of castPred_lt_castPred_iff
that deduces i ≠ last n from i < j.
succAbove p i embeds Fin n into Fin (n + 1) with a hole around p.
Instances For
Embedding i : Fin n into Fin (n + 1) with a hole around p : Fin (n + 1)
embeds i by castSucc when the resulting i.castSucc < p.
Embedding i : Fin n into Fin (n + 1) with a hole around p : Fin (n + 1)
embeds i by succ when the resulting p < i.succ.
Embedding i : Fin n into Fin (n + 1) with a hole around p : Fin (n + 1)
never results in p itself
Given a fixed pivot p : Fin (n + 1), p.succAbove is injective.
Given a fixed pivot p : Fin (n + 1), p.succAbove is injective.
Embedding Fin n into Fin (n + 1) with a hole around zero embeds by succ.
Embedding Fin n into Fin (n + 1) with a hole around last n embeds by castSucc.
Embedding i : Fin n into Fin (n + 1) using a pivot p that is greater
results in a value that is less than p.
Embedding i : Fin n into Fin (n + 1) using a pivot p that is lesser
results in a value that is greater than p.
Embedding a positive Fin n results in a positive Fin (n + 1)
The range of p.succAbove is everything except p.
succAbove is injective at the pivot
succAbove is injective at the pivot
succ commutes with succAbove.
castSucc commutes with succAbove.
pred commutes with succAbove.
By moving succ to the outside of this expression, we create opportunities for further
simplification using succAbove_zero or succ_succAbove_zero.
predAbove p i surjects i : Fin (n+1) into Fin n by subtracting one if p < i.
Instances For
Sending Fin (n+1) to Fin n by subtracting one from anything above p
then back to Fin (n+1) with a gap around p is the identity away from p.
Sending Fin (n+1) to Fin n by subtracting one from anything above p
then back to Fin (n+1) with a gap around p.succ is the identity away from p.succ.
Sending Fin n into Fin (n + 1) with a gap at p
then back to Fin n by subtracting one from anything above p is the identity.
succ commutes with predAbove.
castSucc commutes with predAbove.
Given i : Fin (n + 2) and j : Fin (n + 1),
there are two ways to represent the order embedding Fin n → Fin (n + 2)
leaving holes at i and i.succAbove j.
One is i.succAbove ∘ j.succAbove.
It corresponds to embedding Fin n to Fin (n + 1) leaving a hole at j,
then embedding the result to Fin (n + 2) leaving a hole at i.
The other one is (i.succAbove j).succAbove ∘ (j.predAbove i).succAbove.
It corresponds to swapping the roles of i and j.
This lemma says that these two ways are equal.
It is used in Fin.removeNth_removeNth_eq_swap
to show that two ways of removing 2 elements from a sequence give the same answer.