Skip to content

Commit

Permalink
chore: rename Fin.cast to Fin.castIso (#5584)
Browse files Browse the repository at this point in the history
Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>
  • Loading branch information
Ruben-VandeVelde and Parcly-Taxel committed Jul 4, 2023
1 parent 409bee4 commit b0bb297
Show file tree
Hide file tree
Showing 19 changed files with 171 additions and 169 deletions.
8 changes: 4 additions & 4 deletions Mathlib/Algebra/BigOperators/Fin.lean
Expand Up @@ -187,7 +187,7 @@ theorem prod_Ioi_succ {M : Type _} [CommMonoid M] {n : ℕ} (i : Fin n) (v : Fin

@[to_additive]
theorem prod_congr' {M : Type _} [CommMonoid M] {a b : ℕ} (f : Fin b → M) (h : a = b) :
(∏ i : Fin a, f (cast h i)) = ∏ i : Fin b, f i := by
(∏ i : Fin a, f (castIso h i)) = ∏ i : Fin b, f i := by
subst h
congr
#align fin.prod_congr' Fin.prod_congr'
Expand Down Expand Up @@ -334,7 +334,7 @@ def finFunctionFinEquiv {m n : ℕ} : (Fin n → Fin m) ≃ Fin (m ^ n) :=
fun a => by
dsimp
induction' n with n ih
· haveI : Subsingleton (Fin (m ^ 0)) := (Fin.cast <| pow_zero _).toEquiv.subsingleton
· haveI : Subsingleton (Fin (m ^ 0)) := (Fin.castIso <| pow_zero _).toEquiv.subsingleton
exact Subsingleton.elim _ _
simp_rw [Fin.forall_iff, Fin.ext_iff] at ih
ext
Expand Down Expand Up @@ -394,14 +394,14 @@ def finPiFinEquiv {m : ℕ} {n : Fin m → ℕ} : (∀ i : Fin m, Fin (n i)) ≃
refine' Fin.consInduction _ _ n
· intro a
haveI : Subsingleton (Fin (∏ i : Fin 0, i.elim0)) :=
(Fin.cast <| prod_empty).toEquiv.subsingleton
(Fin.castIso <| prod_empty).toEquiv.subsingleton
exact Subsingleton.elim _ _
· intro n x xs ih a
simp_rw [Fin.forall_iff, Fin.ext_iff] at ih
ext
simp_rw [Fin.sum_univ_succ, Fin.cons_succ]
have := fun i : Fin n =>
Fintype.prod_equiv (Fin.cast <| Fin.val_succ i).toEquiv
Fintype.prod_equiv (Fin.castIso <| Fin.val_succ i).toEquiv
(fun j => (Fin.cons x xs : _ → ℕ) (Fin.castLE (Fin.is_lt _).le j))
(fun j => (Fin.cons x xs : _ → ℕ) (Fin.castLE (Nat.succ_le_succ (Fin.is_lt _).le) j))
fun j => rfl
Expand Down
14 changes: 7 additions & 7 deletions Mathlib/AlgebraicTopology/DoldKan/Faces.lean
Expand Up @@ -85,7 +85,7 @@ theorem comp_Hσ_eq {Y : C} {n a q : ℕ} {φ : Y ⟶ X _[n + 1]} (v : HigherFac
swap
· rintro ⟨k, hk⟩
suffices φ ≫ X.δ (⟨a + 2 + k, by linarith⟩ : Fin (n + 2)) = 0 by
simp only [this, Fin.natAdd_mk, Fin.cast_mk, zero_comp, smul_zero]
simp only [this, Fin.natAdd_mk, Fin.castIso_mk, zero_comp, smul_zero]
convert v ⟨a + k + 1, by linarith⟩ (by rw [Fin.val_mk] ; linarith)
dsimp
linarith
Expand All @@ -95,21 +95,21 @@ theorem comp_Hσ_eq {Y : C} {n a q : ℕ} {φ : Y ⟶ X _[n + 1]} (v : HigherFac
· rintro ⟨k, hk⟩
rw [assoc, X.δ_comp_σ_of_gt', v.comp_δ_eq_zero_assoc, zero_comp, zsmul_zero]
· simp only [Fin.lt_iff_val_lt_val]
dsimp [Fin.natAdd, Fin.cast]
dsimp [Fin.natAdd, Fin.castIso]
linarith
· intro h
rw [Fin.pred_eq_iff_eq_succ, Fin.ext_iff] at h
dsimp [Fin.cast] at h
dsimp [Fin.castIso] at h
linarith
· dsimp [Fin.cast, Fin.pred]
· dsimp [Fin.castIso, Fin.pred]
rw [Nat.pred_eq_sub_one, Nat.succ_add_sub_one]
linarith
simp only [assoc]
conv_lhs =>
congr
· rw [Fin.sum_univ_castSucc]
· rw [Fin.sum_univ_castSucc, Fin.sum_univ_castSucc]
dsimp [Fin.cast, Fin.castLE, Fin.castLT]
dsimp [Fin.castIso, Fin.castLE, Fin.castLT]
/- the purpose of the following `simplif` is to create three subgoals in order
to finish the proof -/
have simplif :
Expand Down Expand Up @@ -152,12 +152,12 @@ theorem comp_Hσ_eq_zero {Y : C} {n q : ℕ} {φ : Y ⟶ X _[n + 1]} (v : Higher
AlternatingFaceMapComplex.obj_d_eq]
rw [← Fin.sum_congr' _ (show 2 + (n + 1) = n + 1 + 2 by linarith), Fin.sum_trunc]
· simp only [Fin.sum_univ_castSucc, Fin.sum_univ_zero, zero_add, Fin.last, Fin.castLE_mk,
Fin.cast_mk, Fin.castSucc_mk]
Fin.castIso_mk, Fin.castSucc_mk]
simp only [Fin.mk_zero, Fin.val_zero, pow_zero, one_zsmul, Fin.mk_one, Fin.val_one, pow_one,
neg_smul, comp_neg]
erw [δ_comp_σ_self, δ_comp_σ_succ, add_right_neg]
· intro j
dsimp [Fin.cast, Fin.castLE, Fin.castLT]
dsimp [Fin.castIso, Fin.castLE, Fin.castLT]
rw [comp_zsmul, comp_zsmul, δ_comp_σ_of_gt', v.comp_δ_eq_zero_assoc, zero_comp, zsmul_zero]
· simp only [Fin.lt_iff_val_lt_val]
dsimp [Fin.succ]
Expand Down
10 changes: 5 additions & 5 deletions Mathlib/Analysis/Analytic/Basic.lean
Expand Up @@ -1177,23 +1177,23 @@ def changeOriginIndexEquiv :
invFun s :=
⟨s.1 - s.2.card, s.2.card,
⟨s.2.map
(Fin.cast <| (tsub_add_cancel_of_le <| card_finset_fin_le s.2).symm).toEquiv.toEmbedding,
(Fin.castIso <| (tsub_add_cancel_of_le <| card_finset_fin_le s.2).symm).toEquiv.toEmbedding,
Finset.card_map _⟩⟩
left_inv := by
rintro ⟨k, l, ⟨s : Finset (Fin <| k + l), hs : s.card = l⟩⟩
dsimp only [Subtype.coe_mk]
-- Lean can't automatically generalize `k' = k + l - s.card`, `l' = s.card`, so we explicitly
-- formulate the generalized goal
suffices ∀ k' l', k' = k → l' = l → ∀ (hkl : k + l = k' + l') (hs'),
(⟨k', l', ⟨Finset.map (Fin.cast hkl).toEquiv.toEmbedding s, hs'⟩⟩ :
(⟨k', l', ⟨Finset.map (Fin.castIso hkl).toEquiv.toEmbedding s, hs'⟩⟩ :
Σk l : ℕ, { s : Finset (Fin (k + l)) // s.card = l }) = ⟨k, l, ⟨s, hs⟩⟩ by
apply this <;> simp only [hs, add_tsub_cancel_right]
rintro _ _ rfl rfl hkl hs'
simp only [Equiv.refl_toEmbedding, Fin.cast_refl, Finset.map_refl, eq_self_iff_true,
simp only [Equiv.refl_toEmbedding, Fin.castIso_refl, Finset.map_refl, eq_self_iff_true,
OrderIso.refl_toEquiv, and_self_iff, heq_iff_eq]
right_inv := by
rintro ⟨n, s⟩
simp [tsub_add_cancel_of_le (card_finset_fin_le s), Fin.cast_to_equiv]
simp [tsub_add_cancel_of_le (card_finset_fin_le s), Fin.castIso_to_equiv]
#align formal_multilinear_series.change_origin_index_equiv FormalMultilinearSeries.changeOriginIndexEquiv

theorem changeOriginSeries_summable_aux₁ {r r' : ℝ≥0} (hr : (r + r' : ℝ≥0∞) < p.radius) :
Expand Down Expand Up @@ -1320,7 +1320,7 @@ theorem changeOrigin_eval (h : (‖x‖₊ + ‖y‖₊ : ℝ≥0∞) < p.radius
changeOriginIndexEquiv_symm_apply_snd_fst, changeOriginIndexEquiv_symm_apply_snd_snd_coe]
rw [ContinuousMultilinearMap.curryFinFinset_apply_const]
have : ∀ (m) (hm : n = m), p n (s.piecewise (fun _ => x) fun _ => y) =
p m ((s.map (Fin.cast hm).toEquiv.toEmbedding).piecewise (fun _ => x) fun _ => y) := by
p m ((s.map (Fin.castIso hm).toEquiv.toEmbedding).piecewise (fun _ => x) fun _ => y) := by
rintro m rfl
simp [Finset.piecewise]
apply this
Expand Down

0 comments on commit b0bb297

Please sign in to comment.