Skip to content

Commit

Permalink
chore: adaptations to lean 4.8.0 (#12578)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
  • Loading branch information
Ruben-VandeVelde and semorrison committed May 1, 2024
1 parent 4fce67d commit bd932a4
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Mathlib/Algebra/Module/LinearMap/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ def toSemilinearMap (fₗ : M →ₑ+[σ.toMonoidHom] M₂) : M →ₛₗ[σ] M

instance : SemilinearMapClass (M →ₑ+[σ.toMonoidHom] M₂) σ M M₂ where

instance : CoeTC (M →ₑ+[σ.toMonoidHom] M₂) (M →ₛₗ[σ] M₂) :=
instance instCoeTCSemilinearMap : CoeTC (M →ₑ+[σ.toMonoidHom] M₂) (M →ₛₗ[σ] M₂) :=
⟨toSemilinearMap⟩

/-- A `DistribMulActionHom` between two modules is a linear map. -/
Expand Down
4 changes: 0 additions & 4 deletions Mathlib/Analysis/SpecialFunctions/Integrals.lean
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,6 @@ theorem integral_sin_pow :
(∫ x in a..b, sin x ^ (n + 2)) =
(sin a ^ (n + 1) * cos a - sin b ^ (n + 1) * cos b) / (n + 2) +
(n + 1) / (n + 2) * ∫ x in a..b, sin x ^ n := by
have : n + 20 := by omega
have : (n : ℝ) + 20 := by norm_cast
field_simp
convert eq_sub_iff_add_eq.mp (integral_sin_pow_aux n) using 1
ring
Expand Down Expand Up @@ -749,8 +747,6 @@ theorem integral_cos_pow :
(∫ x in a..b, cos x ^ (n + 2)) =
(cos b ^ (n + 1) * sin b - cos a ^ (n + 1) * sin a) / (n + 2) +
(n + 1) / (n + 2) * ∫ x in a..b, cos x ^ n := by
have : n + 20 := by omega
have : (n : ℝ) + 20 := by norm_cast
field_simp
convert eq_sub_iff_add_eq.mp (integral_cos_pow_aux n) using 1
ring
Expand Down
8 changes: 5 additions & 3 deletions Mathlib/CategoryTheory/Bicategory/Functor.lean
Original file line number Diff line number Diff line change
Expand Up @@ -499,16 +499,18 @@ instance : Inhabited (Pseudofunctor B B) :=
⟨id B⟩

/-- Composition of pseudofunctors. -/
@[simps]
def comp (F : Pseudofunctor B C) (G : Pseudofunctor C D) : Pseudofunctor B D :=
{
(F : PrelaxFunctor B C).comp
{ (F : PrelaxFunctor B C).comp
(G : PrelaxFunctor C D) with
mapId := fun a => (G.mapFunctor _ _).mapIso (F.mapId a) ≪≫ G.mapId (F.obj a)
mapComp := fun f g =>
(G.mapFunctor _ _).mapIso (F.mapComp f g) ≪≫ G.mapComp (F.map f) (F.map g) }
#align category_theory.pseudofunctor.comp CategoryTheory.Pseudofunctor.comp

-- `comp` is near the `maxHeartbeats` limit (and seems to go over in CI),
-- so we defer creating its `@[simp]` lemmas until a separate command.
attribute [simps] comp

/-- Construct a pseudofunctor from an oplax functor whose `mapId` and `mapComp` are isomorphisms.
-/
@[simps]
Expand Down
8 changes: 5 additions & 3 deletions Mathlib/CategoryTheory/Category/Preorder.lean
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ def homOfLE {x y : X} (h : x ≤ y) : x ⟶ y :=
ULift.up (PLift.up h)
#align category_theory.hom_of_le CategoryTheory.homOfLE

alias _root_.LE.le.hom := homOfLE
@[inherit_doc homOfLE]
abbrev _root_.LE.le.hom := @homOfLE
#align has_le.le.hom LE.le.hom

@[simp]
theorem homOfLE_refl {x : X} : (le_refl x).hom = 𝟙 x :=
theorem homOfLE_refl {x : X} (h : x ≤ x) : h.hom = 𝟙 x :=
rfl
#align category_theory.hom_of_le_refl CategoryTheory.homOfLE_refl

Expand All @@ -88,7 +89,8 @@ theorem leOfHom {x y : X} (h : x ⟶ y) : x ≤ y :=
h.down.down
#align category_theory.le_of_hom CategoryTheory.leOfHom

alias _root_.Quiver.Hom.le := leOfHom
@[nolint defLemma, inherit_doc leOfHom]
abbrev _root_.Quiver.Hom.le := @leOfHom
#align quiver.hom.le Quiver.Hom.le

-- Porting note: why does this lemma exist? With proof irrelevance, we don't need to simplify proofs
Expand Down
10 changes: 8 additions & 2 deletions Mathlib/CategoryTheory/Limits/Shapes/Products.lean
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,10 @@ instance {ι : Type*} (f : ι → Type*) (g : (i : ι) → (f i) → C)
HasProduct fun p : Σ i, f i => g p.1 p.2 where
exists_limit := Nonempty.intro
{ cone := Fan.mk (∏ fun i => ∏ g i) (fun X => Pi.π (fun i => ∏ g i) X.1 ≫ Pi.π (g X.1) X.2)
isLimit := mkFanLimit _ (fun s => Pi.lift fun b => Pi.lift fun c => s.proj ⟨b, c⟩) }
isLimit := mkFanLimit _ (fun s => Pi.lift fun b => Pi.lift fun c => s.proj ⟨b, c⟩)
-- Adaptation note: nightly-2024-04-01
-- Both of these proofs were previously by `aesop_cat`.
(by aesop_cat) (by intro s m w; simp only [Fan.mk_pt]; symm; ext i x; simp_all) }

/-- An iterated product is a product over a sigma type. -/
@[simps]
Expand All @@ -500,7 +503,10 @@ instance {ι : Type*} (f : ι → Type*) (g : (i : ι) → (f i) → C)
{ cocone := Cofan.mk (∐ fun i => ∐ g i)
(fun X => Sigma.ι (g X.1) X.2 ≫ Sigma.ι (fun i => ∐ g i) X.1)
isColimit := mkCofanColimit _
(fun s => Sigma.desc fun b => Sigma.desc fun c => s.inj ⟨b, c⟩) }
(fun s => Sigma.desc fun b => Sigma.desc fun c => s.inj ⟨b, c⟩)
-- Adaptation note: nightly-2024-04-01
-- Both of these proofs were previously by `aesop_cat`.
(by aesop_cat) (by intro s m w; simp only [Cofan.mk_pt]; symm; ext i x; simp_all) }

/-- An iterated coproduct is a coproduct over a sigma type. -/
@[simps]
Expand Down
18 changes: 12 additions & 6 deletions Mathlib/CategoryTheory/Limits/Shapes/Pullbacks.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1695,9 +1695,12 @@ instance hasPullback_of_right_factors_mono (f : X ⟶ Z) : HasPullback i (f ≫

instance pullback_snd_iso_of_right_factors_mono (f : X ⟶ Z) :
IsIso (pullback.snd : pullback i (f ≫ i) ⟶ _) := by
convert (congrArg IsIso (show _ ≫ pullback.snd = _ from
limit.isoLimitCone_hom_π ⟨_, pullbackIsPullbackOfCompMono (𝟙 _) f i⟩ WalkingCospan.right)).mp
inferInstance;
-- Adaptation note: nightly-testing 2024-04-01
-- this could not be placed directly in the `show from` without `dsimp`
have := limit.isoLimitCone_hom_π ⟨_, pullbackIsPullbackOfCompMono (𝟙 _) f i⟩ WalkingCospan.right
dsimp only [cospan_right, id_eq, eq_mpr_eq_cast, PullbackCone.mk_pt, PullbackCone.mk_π_app,
Functor.const_obj_obj, cospan_one] at this
convert (congrArg IsIso (show _ ≫ pullback.snd = _ from this)).mp inferInstance
· exact (Category.id_comp _).symm
· exact (Category.id_comp _).symm
#align category_theory.limits.pullback_snd_iso_of_right_factors_mono CategoryTheory.Limits.pullback_snd_iso_of_right_factors_mono
Expand Down Expand Up @@ -1771,9 +1774,12 @@ instance hasPullback_of_left_factors_mono (f : X ⟶ Z) : HasPullback (f ≫ i)

instance pullback_snd_iso_of_left_factors_mono (f : X ⟶ Z) :
IsIso (pullback.fst : pullback (f ≫ i) i ⟶ _) := by
convert (congrArg IsIso (show _ ≫ pullback.fst = _ from
limit.isoLimitCone_hom_π ⟨_, pullbackIsPullbackOfCompMono f (𝟙 _) i⟩ WalkingCospan.left)).mp
inferInstance;
-- Adaptation note: nightly-testing 2024-04-01
-- this could not be placed directly in the `show from` without `dsimp`
have := limit.isoLimitCone_hom_π ⟨_, pullbackIsPullbackOfCompMono f (𝟙 _) i⟩ WalkingCospan.left
dsimp only [cospan_left, id_eq, eq_mpr_eq_cast, PullbackCone.mk_pt, PullbackCone.mk_π_app,
Functor.const_obj_obj, cospan_one] at this
convert (congrArg IsIso (show _ ≫ pullback.fst = _ from this)).mp inferInstance
· exact (Category.id_comp _).symm
· exact (Category.id_comp _).symm
#align category_theory.limits.pullback_snd_iso_of_left_factors_mono CategoryTheory.Limits.pullback_snd_iso_of_left_factors_mono
Expand Down
9 changes: 8 additions & 1 deletion Mathlib/Computability/Halting.lean
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,14 @@ theorem rice (C : Set (ℕ →. ℕ)) (h : ComputablePred fun c => eval c ∈ C)
fixed_point₂
(Partrec.cond (h.comp fst) ((Partrec.nat_iff.2 hg).comp snd).to₂
((Partrec.nat_iff.2 hf).comp snd).to₂).to₂
aesop
simp only [Bool.cond_decide] at e
by_cases H : eval c ∈ C
· simp only [H, if_true] at e
change (fun b => g b) ∈ C
rwa [← e]
· simp only [H, if_false] at e
rw [e] at H
contradiction
#align computable_pred.rice ComputablePred.rice

theorem rice₂ (C : Set Code) (H : ∀ cf cg, eval cf = eval cg → (cf ∈ C ↔ cg ∈ C)) :
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Data/Fin/Tuple/NatAntidiagonal.lean
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ theorem antidiagonalTuple_zero_zero : antidiagonalTuple 0 0 = [![]] :=
#align list.nat.antidiagonal_tuple_zero_zero List.Nat.antidiagonalTuple_zero_zero

@[simp]
theorem antidiagonalTuple_zero_succ (n : ℕ) : antidiagonalTuple 0 n.succ = [] :=
theorem antidiagonalTuple_zero_succ (n : ℕ) : antidiagonalTuple 0 (n + 1) = [] :=
rfl
#align list.nat.antidiagonal_tuple_zero_succ List.Nat.antidiagonalTuple_zero_succ

Expand Down
8 changes: 5 additions & 3 deletions Mathlib/Data/List/GetD.lean
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ section getD

variable (d : α)

variable {n d} in
@[simp]
theorem getD_nil : getD [] n d = d :=
rfl
#align list.nthd_nil List.getD_nilₓ -- argument order

variable {x xs d} in
@[simp]
theorem getD_cons_zero : getD (x :: xs) 0 d = x :=
rfl
Expand All @@ -51,7 +53,7 @@ theorem getD_eq_get {n : ℕ} (hn : n < l.length) : l.getD n d = l.get ⟨n, hn
| nil => simp at hn
| cons head tail ih =>
cases n
· exact getD_cons_zero _ _ _
· exact getD_cons_zero
· exact ih _

@[simp]
Expand All @@ -67,7 +69,7 @@ theorem getD_map {n : ℕ} (f : α → β) : (map f l).getD n (f d) = f (l.getD

theorem getD_eq_default {n : ℕ} (hn : l.length ≤ n) : l.getD n d = d := by
induction l generalizing n with
| nil => exact getD_nil _ _
| nil => exact getD_nil
| cons head tail ih =>
cases n
· simp at hn
Expand All @@ -77,7 +79,7 @@ theorem getD_eq_default {n : ℕ} (hn : l.length ≤ n) : l.getD n d = d := by
/-- An empty list can always be decidably checked for the presence of an element.
Not an instance because it would clash with `DecidableEq α`. -/
def decidableGetDNilNe {α} (a : α) : DecidablePred fun i : ℕ => getD ([] : List α) i a ≠ a :=
fun _ => isFalse fun H => H (getD_nil _ _)
fun _ => isFalse fun H => H getD_nil
#align list.decidable_nthd_nil_ne List.decidableGetDNilNeₓ -- argument order

@[simp]
Expand Down
5 changes: 2 additions & 3 deletions Mathlib/Data/QPF/Univariate/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,8 @@ theorem Fix.ind_aux (a : q.P.A) (f : q.P.B a → q.P.W) :
have : Fix.mk (abs ⟨a, fun x => ⟦f x⟧⟩) = ⟦Wrepr ⟨a, f⟩⟧ := by
apply Quot.sound; apply Wequiv.abs'
rw [PFunctor.W.dest_mk, abs_map, abs_repr, ← abs_map, PFunctor.map_eq]
conv =>
rhs
simp only [Wrepr, recF_eq, PFunctor.W.dest_mk, abs_repr, Function.comp]
simp only [Wrepr, recF_eq, PFunctor.W.dest_mk, abs_repr, Function.comp]
rfl
rw [this]
apply Quot.sound
apply Wrepr_equiv
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Data/Rat/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ lemma mk'_mul_mk' (n₁ n₂ : ℤ) (d₁ d₂ : ℕ) (hd₁ hd₂ hnd₁ hnd₂
(h₂₁ : n₂.natAbs.Coprime d₁) :
mk' n₁ d₁ hd₁ hnd₁ * mk' n₂ d₂ hd₂ hnd₂ = mk' (n₁ * n₂) (d₁ * d₂) (Nat.mul_ne_zero hd₁ hd₂) (by
rw [Int.natAbs_mul]; exact (hnd₁.mul h₂₁).mul_right (h₁₂.mul hnd₂)) := by
rw [mul_def]; dsimp; rw [mk_eq_normalize]
rw [mul_def]; dsimp; simp [mk_eq_normalize]

lemma mul_eq_mkRat (q r : ℚ) : q * r = mkRat (q.num * r.num) (q.den * r.den) := by
rw [mul_def, normalize_eq_mkRat]
Expand Down
9 changes: 3 additions & 6 deletions Mathlib/Data/Seq/Computation.lean
Original file line number Diff line number Diff line change
Expand Up @@ -919,26 +919,23 @@ instance instAlternativeComputation : Alternative Computation :=
@[simp]
theorem ret_orElse (a : α) (c₂ : Computation α) : (pure a <|> c₂) = pure a :=
destruct_eq_pure <| by
unfold HOrElse.hOrElse instHOrElse
unfold OrElse.orElse instOrElse Alternative.orElse instAlternativeComputation
unfold_projs
simp [orElse]
#align computation.ret_orelse Computation.ret_orElse

-- Porting note: Added unfolds as the code does not work without it
@[simp]
theorem orElse_pure (c₁ : Computation α) (a : α) : (think c₁ <|> pure a) = pure a :=
destruct_eq_pure <| by
unfold HOrElse.hOrElse instHOrElse
unfold OrElse.orElse instOrElse Alternative.orElse instAlternativeComputation
unfold_projs
simp [orElse]
#align computation.orelse_ret Computation.orElse_pure

-- Porting note: Added unfolds as the code does not work without it
@[simp]
theorem orElse_think (c₁ c₂ : Computation α) : (think c₁ <|> think c₂) = think (c₁ <|> c₂) :=
destruct_eq_think <| by
unfold HOrElse.hOrElse instHOrElse
unfold OrElse.orElse instOrElse Alternative.orElse instAlternativeComputation
unfold_projs
simp [orElse]
#align computation.orelse_think Computation.orElse_think

Expand Down
2 changes: 1 addition & 1 deletion Mathlib/GroupTheory/CoprodI.lean
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ theorem mem_equivPair_tail_iff {i j : ι} {w : Word M} (m : M i) :
· subst k
by_cases hij : j = i <;> simp_all
· by_cases hik : i = k
· subst i; simp_all [eq_comm, and_comm, or_comm]
· subst i; simp_all [@eq_comm _ m g, @eq_comm _ k j, or_comm]
· simp [hik, Ne.symm hik]

theorem mem_of_mem_equivPair_tail {i j : ι} {w : Word M} (m : M i) :
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/GroupTheory/Sylow.lean
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def fixedPointsMulLeftCosetsEquivQuotient (H : Subgroup G) [Finite (H : Set G)]
(fun a => (@mem_fixedPoints_mul_left_cosets_iff_mem_normalizer _ _ _ ‹_› _).symm)
(by
intros
dsimp only [instHasEquiv]
unfold_projs
rw [leftRel_apply (α := normalizer H), leftRel_apply]
rfl)
#align sylow.fixed_points_mul_left_cosets_equiv_quotient Sylow.fixedPointsMulLeftCosetsEquivQuotient
Expand Down
2 changes: 2 additions & 0 deletions Mathlib/Init/Data/Nat/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace Nat

set_option linter.deprecated false

theorem add_one_pos (n : ℕ) : 0 < n + 1 := succ_pos n

protected theorem bit0_succ_eq (n : ℕ) : bit0 (succ n) = succ (succ (bit0 n)) :=
show succ (succ n + n) = succ (succ (n + n)) from congrArg succ (succ_add n n)
#align nat.bit0_succ_eq Nat.bit0_succ_eq
Expand Down
4 changes: 2 additions & 2 deletions Mathlib/Init/Data/Nat/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ protected theorem bit0_inj : ∀ {n m : ℕ}, bit0 n = bit0 m → n = m
| n + 1, 0, h => by contradiction
| n + 1, m + 1, h => by
have : succ (succ (n + n)) = succ (succ (m + m)) := by
unfold bit0 at h; simp [add_one, add_succ, succ_add] at h
have aux : n + n = m + m := h; rw [aux]
unfold bit0 at h; simp only [add_one, add_succ, succ_add, succ_inj'] at h
rw [h]
have : n + n = m + m := by repeat injection this with this
have : n = m := Nat.bit0_inj this
rw [this]
Expand Down

0 comments on commit bd932a4

Please sign in to comment.