Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Order): Fin.succAboveOrderIso #21303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4243,6 +4243,7 @@ import Mathlib.Order.Filter.Ultrafilter.Defs
import Mathlib.Order.Filter.ZeroAndBoundedAtFilter
import Mathlib.Order.Fin.Basic
import Mathlib.Order.Fin.Finset
import Mathlib.Order.Fin.SuccAboveOrderIso
import Mathlib.Order.Fin.Tuple
import Mathlib.Order.FixedPoints
import Mathlib.Order.GaloisConnection.Basic
Expand Down
11 changes: 11 additions & 0 deletions Mathlib/Data/Fin/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,17 @@ lemma succAbove_predAbove {p : Fin n} {i : Fin (n + 1)} (h : i ≠ castSucc p) :
· rw [predAbove_of_le_castSucc _ _ (Fin.le_of_lt h), succAbove_castPred_of_lt _ _ h]
· rw [predAbove_of_castSucc_lt _ _ h, succAbove_pred_of_lt _ _ h]

/-- 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`. -/
@[simp]
lemma succ_succAbove_predAbove {n : ℕ} {p : Fin n} {i : Fin (n + 1)} (h : i ≠ p.succ) :
p.succ.succAbove (p.predAbove i) = i := by
obtain h | h := Fin.lt_or_lt_of_ne h
· rw [predAbove_of_le_castSucc _ _ (le_castSucc_iff.2 h),
succAbove_castPred_of_lt _ _ h]
· rw [predAbove_of_castSucc_lt _ _ (Fin.lt_of_le_of_lt (p.castSucc_le_succ) h),
succAbove_pred_of_lt _ _ h]

/-- 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. -/
@[simp]
Expand Down
37 changes: 37 additions & 0 deletions Mathlib/Order/Fin/SuccAboveOrderIso.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/

import Mathlib.Order.Fin.Basic
import Mathlib.Data.Fintype.Basic
import Mathlib.Tactic.FinCases

/-!
# The order isomorphism `Fin (n + 1) ≃o {i}ᶜ`

Given `i : Fin (n + 2)`, we show that `Fin.succAboveOrderEmb` induces
an order isomorphism `Fin (n + 1) ≃o ({i}ᶜ : Finset (Fin (n + 2)))`.

-/

open Finset

/-- Given `i : Fin (n + 2)`, this is the order isomorphism
between `Fin (n + 1)` and the finite set `{i}ᶜ`. -/
noncomputable def Fin.succAboveOrderIso {n : ℕ} (i : Fin (n + 2)) :
Fin (n + 1) ≃o ({i}ᶜ : Finset (Fin (n + 2))) where
toEquiv :=
Equiv.ofBijective (f := fun a ↦ ⟨Fin.succAboveOrderEmb i a,
by simpa using Fin.succAbove_ne i a⟩) (by
constructor
· intro a b h
exact (Fin.succAboveOrderEmb i).injective (by simpa using h)
· rintro ⟨j, hj⟩
simp only [mem_compl, mem_singleton] at hj
obtain rfl | ⟨i, rfl⟩ := Fin.eq_zero_or_eq_succ i
· exact ⟨j.pred hj, by simp⟩
· exact ⟨i.predAbove j, by aesop⟩)
map_rel_iff' {a b} := by
simp only [Equiv.ofBijective_apply, Subtype.mk_le_mk, OrderEmbedding.le_iff_le]
Loading