Skip to content

Commit 34368d1

Browse files
fix(Data/Fin/Basic): castPred consistency redefinition. (#9780)
This PR redefines castPred to be more consistent with the definition of both `pred` and `castSucc`, so that the relationship between `castSucc` and `castPred` and `succ` and `pred` becomes exactly analogous. It also adds some supplementary and analogous lemmas designed to facilitate this. As `castPred` is no longer dependent on `predAbove`, its definition is moved to a more appropriate place.
1 parent e8248a2 commit 34368d1

File tree

2 files changed

+221
-136
lines changed

2 files changed

+221
-136
lines changed

Mathlib/AlgebraicTopology/SimplexCategory.lean

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,8 @@ instance {n : ℕ} {i : Fin (n + 1)} : Epi (σ i) := by
543543
-- This was not needed before leanprover/lean4#2644
544544
dsimp
545545
rw [Fin.predAbove_below i b (by simpa only [Fin.coe_eq_castSucc] using h)]
546-
simp only [len_mk, Fin.coe_eq_castSucc, Fin.castPred_castSucc]
546+
simp only [len_mk, Fin.coe_eq_castSucc]
547+
rfl
547548
· use b.succ
548549
-- This was not needed before leanprover/lean4#2644
549550
dsimp
@@ -623,12 +624,11 @@ theorem eq_σ_comp_of_not_injective' {n : ℕ} {Δ' : SimplexCategory} (θ : mk
623624
· -- This was not needed before leanprover/lean4#2644
624625
dsimp
625626
rw [Fin.predAbove_below i x h']
626-
have eq := Fin.castSucc_castPred (gt_of_gt_of_ge (Fin.castSucc_lt_last i) h')
627627
dsimp [δ]
628-
erw [Fin.succAbove_below i.succ x.castPred _]
628+
erw [Fin.succAbove_below _ _ _]
629629
swap
630-
· rwa [eq, ← Fin.le_castSucc_iff]
631-
rw [eq]
630+
· exact (Fin.castSucc_lt_succ_iff.mpr h')
631+
rfl
632632
· simp only [not_le] at h'
633633
let y := x.pred <| by rintro (rfl : x = 0); simp at h'
634634
have hy : x = y.succ := (Fin.succ_pred x _).symm
@@ -673,22 +673,18 @@ theorem eq_σ_comp_of_not_injective {n : ℕ} {Δ' : SimplexCategory} (θ : mk (
673673
· exfalso
674674
exact h₂ h'.symm
675675
rcases hθ₂ with ⟨x, y, ⟨h₁, h₂⟩⟩
676-
let z := x.castPred
677-
use z
678-
rw [← show Fin.castSucc z = x from
679-
Fin.castSucc_castPred (lt_of_lt_of_le h₂ (Fin.le_last y))] at h₁ h₂
676+
use x.castPred ((Fin.le_last _).trans_lt' h₂).ne
680677
apply eq_σ_comp_of_not_injective'
681-
rw [Fin.castSucc_lt_iff_succ_le] at h₂
682678
apply le_antisymm
683-
· exact θ.toOrderHom.monotone (le_of_lt (Fin.castSucc_lt_succ z))
684-
· rw [h₁]
685-
exact θ.toOrderHom.monotone h₂
679+
· exact θ.toOrderHom.monotone (le_of_lt (Fin.castSucc_lt_succ _))
680+
· rw [Fin.castSucc_castPred, h₁]
681+
exact θ.toOrderHom.monotone ((Fin.succ_castPred_le_iff _).mpr h₂)
686682
#align simplex_category.eq_σ_comp_of_not_injective SimplexCategory.eq_σ_comp_of_not_injective
687683

688684
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
689685
(i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
690686
by_cases h : i < Fin.last (n + 1)
691-
· use θ ≫ σ (Fin.castPred i)
687+
· use θ ≫ σ (Fin.castPred i h.ne)
692688
ext1
693689
ext1
694690
ext1 x
@@ -699,23 +695,18 @@ theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ
699695
-- This was not needed before leanprover/lean4#2644
700696
dsimp
701697
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
702-
erw [Fin.predAbove_below (Fin.castPred i) (θ.toOrderHom x)
703-
(by simpa [Fin.castSucc_castPred h] using h')]
698+
erw [Fin.predAbove_below _ _ (by exact h')]
704699
dsimp [δ]
705700
erw [Fin.succAbove_below i]
706701
swap
707-
· simp only [Fin.lt_iff_val_lt_val, Fin.coe_castSucc]
708-
exact
709-
lt_of_le_of_lt (Fin.coe_castPred_le_self _)
710-
(Fin.lt_iff_val_lt_val.mp ((Ne.le_iff_lt (hi x)).mp h'))
711-
rw [Fin.castSucc_castPred]
712-
apply lt_of_le_of_lt h' h
702+
· rw [(hi x).le_iff_lt] at h'
703+
exact h'
704+
rfl
713705
· simp only [not_le] at h'
714706
-- The next three tactics used to be a simp only call before leanprover/lean4#2644
715707
rw [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk, OrderHom.coe_mk]
716708
erw [OrderHom.coe_mk]
717-
erw [Fin.predAbove_above (Fin.castPred i) (θ.toOrderHom x)
718-
(by simpa only [Fin.castSucc_castPred h] using h')]
709+
erw [Fin.predAbove_above _ _ (by exact h')]
719710
dsimp [δ]
720711
rw [Fin.succAbove_above i _]
721712
-- This was not needed before leanprover/lean4#2644
@@ -725,11 +716,12 @@ theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ
725716
Nat.le_sub_one_of_lt (Fin.lt_iff_val_lt_val.mp h')
726717
· obtain rfl := le_antisymm (Fin.le_last i) (not_lt.mp h)
727718
use θ ≫ σ (Fin.last _)
728-
ext x : 4
719+
ext x : 3
729720
dsimp [δ, σ]
730-
dsimp only [Fin.castPred]
731-
rw [Fin.predAbove_last, Fin.succAbove_last, Fin.castSucc_castPred]
732-
exact (Ne.le_iff_lt (hi x)).mp (Fin.le_last _)
721+
simp_rw [Fin.succAbove_last, Fin.predAbove_last_apply]
722+
split_ifs with h
723+
· exact ((hi x) h).elim
724+
· rfl
733725
#align simplex_category.eq_comp_δ_of_not_surjective' SimplexCategory.eq_comp_δ_of_not_surjective'
734726

735727
theorem eq_comp_δ_of_not_surjective {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))

0 commit comments

Comments
 (0)