Skip to content

Commit

Permalink
feat: Fin.exists_fin_succ' (#10459)
Browse files Browse the repository at this point in the history
Adds `Fin.exists_fin_succ'`, which is analogous to [`Fin.forall_fin_succ'`](https://leanprover-community.github.io/mathlib4_docs/Mathlib/Data/Fin/Basic.html#Fin.forall_fin_succ').
  • Loading branch information
enricozb committed Feb 12, 2024
1 parent b569e06 commit 839d7c0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Mathlib/Data/Fin/Basic.lean
Expand Up @@ -996,6 +996,11 @@ theorem forall_fin_succ' {P : Fin (n + 1) → Prop} :
theorem eq_castSucc_or_eq_last {n : Nat} (i : Fin (n + 1)) :
(∃ j : Fin n, i = j.castSucc) ∨ i = last n := i.lastCases (Or.inr rfl) (Or.inl ⟨·, rfl⟩)

theorem exists_fin_succ' {P : Fin (n + 1) → Prop} :
(∃ i, P i) ↔ (∃ i : Fin n, P i.castSucc) ∨ P (.last _) :=
fun ⟨i, h⟩ => Fin.lastCases Or.inr (fun i hi => Or.inl ⟨i, hi⟩) i h,
fun h => h.elim (fun ⟨i, hi⟩ => ⟨i.castSucc, hi⟩) (fun h => ⟨.last _, h⟩)⟩

/--
The `Fin.castSucc_zero` in `Std` only applies in `Fin (n+1)`.
This one instead uses a `NeZero n` typeclass hypothesis.
Expand Down

0 comments on commit 839d7c0

Please sign in to comment.