diff --git a/.github/actions/get-mathlib-ci/action.yml b/.github/actions/get-mathlib-ci/action.yml index 22e91ffce22f42..1eb37c550cef16 100644 --- a/.github/actions/get-mathlib-ci/action.yml +++ b/.github/actions/get-mathlib-ci/action.yml @@ -10,7 +10,7 @@ inputs: # Default pinned commit used by workflows unless they explicitly override. # Update this ref as needed to pick up changes to mathlib-ci scripts # This is also updated automatically by .github/workflows/update_dependencies.yml - default: 78f34ded6a5f5aa11ea5b7c3120fe5d8422db1da + default: aafe3df227b81f681afa3978f9eab0e2bbcd0582 path: description: Checkout destination path. required: false diff --git a/.github/workflows/build_template.yml b/.github/workflows/build_template.yml index 4bb5c0359367d5..1c2f9a8bf2284d 100644 --- a/.github/workflows/build_template.yml +++ b/.github/workflows/build_template.yml @@ -733,17 +733,36 @@ jobs: run: | lake exe graph + - name: Checkout local actions + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ github.workflow_sha }} + fetch-depth: 1 + sparse-checkout: .github/actions + path: workflow-actions + + - name: Get mathlib-ci + uses: ./workflow-actions/.github/actions/get-mathlib-ci + + - name: dump declarations and transitive-import counts + run: | + lake env lean --run "${CI_SCRIPTS_DIR}/pr_summary/dumpReasonableDecls.lean" \ + --out decls.txt --imports-out imports.json Mathlib + - name: upload the import graph uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: import-graph - path: import_graph.dot - ## the default is 90, but we build often, so unless there's a reason - ## to care about old copies in the future, just say 7 days for now - retention-days: 7 + path: | + import_graph.dot + decls.txt + imports.json + ## Master pushes: 90 days, so later PRs forked from these commits + ## can consume the dumps from the artifact. Other branches: 7 days. + retention-days: ${{ github.ref == 'refs/heads/master' && '90' || '7' }} - name: clean up the import graph file - run: rm import_graph.dot + run: rm -f import_graph.dot decls.txt imports.json - name: check all scripts build successfully run: | diff --git a/Archive/Examples/Eisenstein.lean b/Archive/Examples/Eisenstein.lean index a12cf0f39819b9..5e8b4c00345d38 100644 --- a/Archive/Examples/Eisenstein.lean +++ b/Archive/Examples/Eisenstein.lean @@ -59,7 +59,7 @@ example : Irreducible (X ^ 4 - 10 * X ^ 2 + 1 : ℤ[X]) := by CharP.ker_intAlgebraMap_eq_span 3, span_singleton_pow, mem_span_singleton] norm_num rw [hfq, ← modByMonicHom_apply, map_add] - convert zero_add _ + convert! zero_add _ · rw [← LinearMap.mem_ker, mem_ker_modByMonic hq_monic] rw [pow_two, ← sub_mul] apply dvd_mul_left diff --git a/Archive/Imo/Imo1959Q2.lean b/Archive/Imo/Imo1959Q2.lean index f74b5be11fec59..d65fb89ea1cd0f 100644 --- a/Archive/Imo/Imo1959Q2.lean +++ b/Archive/Imo/Imo1959Q2.lean @@ -60,7 +60,7 @@ theorem sqrt_two_mul_sub_one_le_one : sqrt (2 * x - 1) ≤ 1 ↔ x ≤ 1 := by theorem isGood_iff_eq_sqrt_two (hx : x ∈ Icc (1 / 2) 1) : IsGood x A ↔ A = sqrt 2 := by have : sqrt (2 * x - 1) ≤ 1 := sqrt_two_mul_sub_one_le_one.2 hx.2 simp only [isGood_iff, hx.1, abs_sub_comm _ (1 : ℝ), abs_of_nonneg (sub_nonneg.2 this), and_true] - suffices 2 = A * sqrt 2 ↔ A = sqrt 2 by convert this using 2; ring + suffices 2 = A * sqrt 2 ↔ A = sqrt 2 by convert! this using 2; ring rw [← div_eq_iff, div_sqrt, eq_comm] positivity diff --git a/Archive/Imo/Imo1982Q3.lean b/Archive/Imo/Imo1982Q3.lean index 98d2fbaf94cd09..ed2dee108f5b35 100644 --- a/Archive/Imo/Imo1982Q3.lean +++ b/Archive/Imo/Imo1982Q3.lean @@ -74,7 +74,7 @@ end Imo1982Q3 theorem imo1982_q3a (hx : Antitone x) (h0 : x 0 = 1) (hp : ∀ k, 0 < x k) : ∃ n : ℕ, 3.999 ≤ ∑ k ∈ range n, (x k) ^ 2 / x (k + 1) := by use 4000 - convert Imo1982Q3.ineq (Nat.succ_ne_zero 3998) hx h0 hp + convert! Imo1982Q3.ineq (Nat.succ_ne_zero 3998) hx h0 hp norm_num /-- Part b of the problem is solved by `x k = (1 / 2) ^ k`. -/ @@ -88,6 +88,6 @@ theorem imo1982_q3b : ∃ x : ℕ → ℝ, Antitone x ∧ x 0 = 1 ∧ (∀ k, 0 simp_rw [← pow_mul, pow_succ, ← div_eq_mul_inv, div_div_eq_mul_div, mul_comm, mul_div_assoc, ← mul_sum, div_eq_mul_inv, this, ← two_add_two_eq_four, ← mul_two, mul_lt_mul_iff_of_pos_left two_pos] - convert NNReal.coe_lt_coe.2 <| geom_sum_lt (inv_ne_zero two_ne_zero) two_inv_lt_one n + convert! NNReal.coe_lt_coe.2 <| geom_sum_lt (inv_ne_zero two_ne_zero) two_inv_lt_one n · simp · norm_num diff --git a/Archive/Imo/Imo1994Q1.lean b/Archive/Imo/Imo1994Q1.lean index fc9895a0964e58..16409d17ebcc29 100644 --- a/Archive/Imo/Imo1994Q1.lean +++ b/Archive/Imo/Imo1994Q1.lean @@ -54,7 +54,7 @@ theorem imo1994_q1 (n : ℕ) (m : ℕ) (A : Finset ℕ) (hm : #A = m + 1) -- `i ↦ m-i` -- We reindex the sum by fin (m+1) have : ∑ x ∈ A, x = ∑ i : Fin (m + 1), a i := by - convert sum_image fun x _ y _ => a.eq_iff_eq.1 + convert! sum_image fun x _ y _ => a.eq_iff_eq.1 rw [← coe_inj]; simp [a] rw [this]; clear this -- The main proof is a simple calculation by rearranging one of the two sums diff --git a/Archive/Imo/Imo1998Q2.lean b/Archive/Imo/Imo1998Q2.lean index 10f87262bc1468..fe51caef4ee585 100644 --- a/Archive/Imo/Imo1998Q2.lean +++ b/Archive/Imo/Imo1998Q2.lean @@ -210,7 +210,7 @@ end theorem clear_denominators {a b k : ℕ} (ha : 0 < a) (hb : 0 < b) : (b - 1 : ℚ) / (2 * b) ≤ k / a ↔ ((b : ℕ) - 1) * a ≤ k * (2 * b) := by rw [div_le_div_iff₀] - on_goal 1 => convert Nat.cast_le (α := ℚ) + on_goal 1 => convert! Nat.cast_le (α := ℚ) all_goals simp [ha, hb] end diff --git a/Archive/Imo/Imo2001Q5.lean b/Archive/Imo/Imo2001Q5.lean index 00ea647e1aa560..8b8f45817bbd96 100644 --- a/Archive/Imo/Imo2001Q5.lean +++ b/Archive/Imo/Imo2001Q5.lean @@ -104,7 +104,7 @@ lemma x_pos : 0 < s.x := by have col := s.ABC_eq; rw [h, mul_zero] at col replace col : Collinear ℝ {s.A, s.B, s.C} := by apply collinear_of_sin_eq_zero; rw [col, Real.sin_zero] - apply s.not_collinear_BAC; convert col using 1; grind + apply s.not_collinear_BAC; convert! col using 1; grind lemma Q_ne_A : s.Q ≠ s.A := by by_contra h; have := s.ABQ_eq @@ -127,7 +127,7 @@ lemma x_lt_pi_div_three : s.x < π / 3 := by have col : ∠ s.A s.C s.B = 0 := by linarith [s.ACB_eq, angle_nonneg s.A s.C s.B] replace col : Collinear ℝ {s.A, s.C, s.B} := by apply collinear_of_sin_eq_zero; rw [col, Real.sin_zero] - apply s.not_collinear_BAC; convert col using 1; grind + apply s.not_collinear_BAC; convert! col using 1; grind lemma APB_eq : ∠ s.A s.P s.B = 5 * π / 6 - 2 * s.x := by have := angle_add_angle_add_angle_eq_pi s.P s.A_ne_B diff --git a/Archive/Imo/Imo2006Q3.lean b/Archive/Imo/Imo2006Q3.lean index 22daf36f13ad66..9a60dba50d1b0b 100644 --- a/Archive/Imo/Imo2006Q3.lean +++ b/Archive/Imo/Imo2006Q3.lean @@ -79,8 +79,8 @@ theorem subst_proof₁ (x y z s : ℝ) (hxyz : x + y + z = 0) : · rw [div_mul_eq_mul_div, le_div_iff₀' zero_lt_32] exact subst_wlog h' hxyz rcases (mul_nonneg_of_three x y z).resolve_left h' with h | h - · convert this y z x _ h using 2 <;> linarith - · convert this z x y _ h using 2 <;> linarith + · convert! this y z x _ h using 2 <;> linarith + · convert! this z x y _ h using 2 <;> linarith theorem proof₁ {a b c : ℝ} : |a * b * (a ^ 2 - b ^ 2) + b * c * (b ^ 2 - c ^ 2) + c * a * (c ^ 2 - a ^ 2)| ≤ diff --git a/Archive/Imo/Imo2006Q5.lean b/Archive/Imo/Imo2006Q5.lean index 802399e503790c..cb8ebeaf4d7784 100644 --- a/Archive/Imo/Imo2006Q5.lean +++ b/Archive/Imo/Imo2006Q5.lean @@ -72,7 +72,7 @@ theorem Polynomial.isPeriodicPt_eval_two {P : Polynomial ℤ} {t : ℤ} have Hdvd : C.Chain (· ∣ ·) := by rw [Cycle.chain_map, periodicOrbit_chain' _ ht] intro n - convert sub_dvd_eval_sub ((fun x => P.eval x)^[n + 1] t) ((fun x => P.eval x)^[n] t) P <;> + convert! sub_dvd_eval_sub ((fun x => P.eval x)^[n + 1] t) ((fun x => P.eval x)^[n] t) P <;> rw [Function.iterate_succ_apply'] -- Any two entries in C have the same absolute value. have Habs : @@ -112,7 +112,7 @@ theorem Polynomial.isPeriodicPt_eval_two {P : Polynomial ℤ} {t : ℤ} -- They must have opposite sign, so that P^{k + 1}(t) - P^k(t) = P^{k + 2}(t) - P^{k + 1}(t). rcases Int.natAbs_eq_natAbs_iff.1 (Habs n n.succ) with hn' | hn' · apply (hn _).elim - convert hn' <;> simp only [Function.iterate_succ_apply'] + convert! hn' <;> simp only [Function.iterate_succ_apply'] -- We deduce P^{k + 2}(t) = P^k(t) and hence P(P(t)) = t. · rw [neg_sub, sub_right_inj] at hn' simp only [Function.iterate_succ_apply'] at hn' diff --git a/Archive/Imo/Imo2008Q2.lean b/Archive/Imo/Imo2008Q2.lean index 4b42c50b06d645..485185b47bd7bf 100644 --- a/Archive/Imo/Imo2008Q2.lean +++ b/Archive/Imo/Imo2008Q2.lean @@ -51,7 +51,7 @@ theorem imo2008_q2a (x y z : ℝ) (h : x * y * z = 1) (hx : x ≠ 1) (hy : y ≠ have hmn_ne_zero : m + n ≠ 0 := by contrapose hz; field_simp; linarith have hc_sub_sub : c - (c - m - n) = m + n := by abel rw [ge_iff_le, ← sub_nonneg] - convert sq_nonneg ((c * (m ^ 2 + n ^ 2 + m * n) - m * (m + n) ^ 2) / (m * n * (m + n))) + convert! sq_nonneg ((c * (m ^ 2 + n ^ 2 + m * n) - m * (m + n) ^ 2) / (m * n * (m + n))) simp [field, hc_sub_sub]; ring def rationalSolutions := diff --git a/Archive/Imo/Imo2010Q5.lean b/Archive/Imo/Imo2010Q5.lean index 7e660b13f98668..31379441aa4ea8 100644 --- a/Archive/Imo/Imo2010Q5.lean +++ b/Archive/Imo/Imo2010Q5.lean @@ -79,7 +79,7 @@ lemma push {B : Fin 6 → ℕ} {i : Fin 6} (rB : Reachable B) (hi : i < 5) : Reachable (B - single i (B i) + single (i + 1) (2 * B i)) := by obtain hc | hc := (B i).eq_zero_or_pos · rwa [hc, mul_zero, single_zero, single_zero, add_zero, tsub_zero] - · convert (rB.move1 hi hc).push hi using 1 + · convert! (rB.move1 hi hc).push hi using 1 ext k; simp only [add_apply, sub_apply] rcases eq_or_ne k i with rfl | hk · simp_rw [single_eq_same, tsub_self, single_succ] @@ -92,29 +92,29 @@ termination_by B i /-- `(0, 0, 5, 11, 0, 0)` is reachable. -/ lemma five_eleven : Reachable (single 2 5 + single 3 11) := by have R : Reachable (single 1 3 + single 2 1 + single 3 1 + single 4 1 + single 5 1) := by - convert base.push (show 0 < 5 by decide) using 1; decide + convert! base.push (show 0 < 5 by decide) using 1; decide replace R : Reachable (single 2 7 + single 3 1 + single 4 1 + single 5 1) := by - convert R.push (show 1 < 5 by decide) using 1; decide + convert! R.push (show 1 < 5 by decide) using 1; decide replace R : Reachable (single 2 7 + single 4 3 + single 5 1) := by - convert R.push (show 3 < 5 by decide) using 1; decide + convert! R.push (show 3 < 5 by decide) using 1; decide replace R : Reachable (single 2 7 + single 5 7) := by - convert R.push (show 4 < 5 by decide) using 1; decide + convert! R.push (show 4 < 5 by decide) using 1; decide replace R : Reachable (single 2 6 + single 3 2 + single 5 7) := by - convert R.move1 (show 2 < 5 by decide) (by decide) using 1; decide + convert! R.move1 (show 2 < 5 by decide) (by decide) using 1; decide replace R : Reachable (single 2 6 + single 3 1 + single 4 2 + single 5 7) := by - convert R.move1 (show 3 < 5 by decide) (by decide) using 1; decide + convert! R.move1 (show 3 < 5 by decide) (by decide) using 1; decide replace R : Reachable (single 2 6 + single 3 1 + single 5 11) := by - convert R.push (show 4 < 5 by decide) using 1; decide + convert! R.push (show 4 < 5 by decide) using 1; decide replace R : Reachable (single 2 6 + single 4 11) := by - convert R.move2 (show 3 < 4 by decide) (by decide) using 1; decide - convert R.move2 (show 2 < 4 by decide) (by decide) using 1; decide + convert! R.move2 (show 3 < 4 by decide) (by decide) using 1; decide + convert! R.move2 (show 2 < 4 by decide) (by decide) using 1; decide /-- Decrement $B_i$ and double $B_{i+1}$, assuming $B_{i+2} = 0$, by doing `push, move2`. -/ lemma double {B : Fin 6 → ℕ} {i : Fin 6} (rB : Reachable B) (hi : i < 4) (pB : 0 < B i) (zB : B (i + 2) = 0) : Reachable (B + single (i + 1) (B (i + 1)) - single i 1) := by - convert (rB.push (show i + 1 < 5 by grind)).move2 hi (by - rw [add_apply, sub_apply, single_succ]; grind) + convert! + (rB.push (show i + 1 < 5 by grind)).move2 hi (by rw [add_apply, sub_apply, single_succ]; grind) ext k; simp only [comp_apply, add_apply, sub_apply] have (j : Fin 6) : j + 1 + 1 = j + 2 := by grind rcases eq_or_ne k i with rfl | hk @@ -132,7 +132,7 @@ lemma doubles {B : Fin 6 → ℕ} {i : Fin 6} (rB : Reachable B) (hi : i < 4) (z Reachable (update (B - single i (B i)) (i + 1) (B (i + 1) * 2 ^ B i)) := by obtain hc | hc := (B i).eq_zero_or_pos · rwa [hc, single_zero, tsub_zero, pow_zero, mul_one, update_eq_self] - · convert (rB.double hi hc zB).doubles hi (by + · convert! (rB.double hi hc zB).doubles hi (by rw [sub_apply, add_apply, single_eq_of_ne (by simp), zB, zero_add, zero_tsub]) using 1 ext k simp_rw [sub_apply, add_apply, single_eq_same, single_succ, single_succ', add_zero, tsub_zero, @@ -149,9 +149,9 @@ termination_by B i lemma exp {B : Fin 6 → ℕ} {i : Fin 6} (rB : Reachable B) (hi : i < 4) (pB : 0 < B i) (zB : B (i + 1) = 0) (zB' : B (i + 2) = 0) : Reachable (B - single i (B i) + single (i + 1) (2 ^ B i)) := by - convert (rB.move1 (show i < 5 by grind) pB).doubles hi (by + convert! (rB.move1 (show i < 5 by grind) pB).doubles hi (by rw [add_apply, sub_apply, zB', single_eq_of_ne (by simp), tsub_zero, - single_eq_of_ne (by simp), zero_add]) using 1 + single_eq_of_ne (by simp), zero_add]) using 1 simp_rw [add_apply, sub_apply, single_eq_same, single_succ, single_succ', zB, zero_tsub, zero_add, add_zero, ← pow_succ', Nat.sub_add_cancel pB] ext k; simp only [add_apply, sub_apply] @@ -167,7 +167,7 @@ lemma exp_mid {k n : ℕ} (h : Reachable (single 2 (k + 1) + single 3 n)) (hn : Reachable (single 2 k + single 3 (2 ^ n)) := by have md := h.exp (show 3 < 4 by decide) (by simp [hn]) (by simp [add_apply, single_eq_of_ne]) (by simp [add_apply, single_eq_of_ne]) - convert md.move2 (show 2 < 4 by decide) (by + convert! md.move2 (show 2 < 4 by decide) (by simp only [add_apply, sub_apply, single_eq_same] iterate 3 rw [single_eq_of_ne (by decide)] simp) using 1 @@ -192,7 +192,7 @@ lemma reduce {m n : ℕ} (h : Reachable (single 3 n)) (hmn : m ≤ n) : Reachabl | base => exact h | succ k _ ih => apply ih - convert h.move2 (show 3 < 4 by decide) k.succ_pos + convert! h.move2 (show 3 < 4 by decide) k.succ_pos ext i; simp only [sub_apply, comp_apply] rcases eq_or_ne i 3 with rfl | i3 · rw [swap_apply_of_ne_of_ne (by decide) (by decide)] @@ -231,7 +231,7 @@ theorem result : Reachable (single 5 (2010 ^ 2010 ^ 2010)) := by -- See https://github.com/leanprover/lean4/issues/11713 set m : ℕ := 2010 have hm : m = 2010 := by rfl - convert ((quarter_target hm).push (show 3 < 5 by decide)).push (show 4 < 5 by decide) + convert! ((quarter_target hm).push (show 3 < 5 by decide)).push (show 4 < 5 by decide) simp only [single_eq_same, tsub_self, Fin.reduceAdd, zero_add, single_inj] rw [← mul_assoc, show 2 * 2 = 4 by rfl, mul_comm, Nat.div_mul_cancel] trans 2010 ^ 2 diff --git a/Archive/Imo/Imo2015Q6.lean b/Archive/Imo/Imo2015Q6.lean index 330154cb6f49a4..28cb4886f76cef 100644 --- a/Archive/Imo/Imo2015Q6.lean +++ b/Archive/Imo/Imo2015Q6.lean @@ -161,7 +161,7 @@ lemma sum_telescope {m n : ℕ} (hm : N ≤ m) (hn : m < n) : include ht in lemma le_sum_pool : ∑ i ∈ range b, (i : ℤ) ≤ ∑ x ∈ pool a t, x := by - convert sum_range_le_sum fun x mx ↦ (mem_Icc.mp ((pool_subset_Icc ha) mx)).1 + convert! sum_range_le_sum fun x mx ↦ (mem_Icc.mp ((pool_subset_Icc ha) mx)).1 · rw [hbN _ ht] · rw [zero_add] @@ -169,7 +169,7 @@ include ht in lemma sum_pool_le : ∑ x ∈ pool a t, x ≤ ∑ i ∈ range (b - 1), (2014 - i : ℤ) := by have zmp := zero_mem_pool ha hbN ht rw [← insert_erase zmp, sum_insert (notMem_erase _ _), zero_add] - convert sum_le_sum_range fun x mx ↦ ?_ + convert! sum_le_sum_range fun x mx ↦ ?_ · rw [card_erase_of_mem zmp, hbN _ ht] · exact (mem_Icc.mp ((pool_subset_Icc ha) (mem_erase.mp mx).2)).2 diff --git a/Archive/Imo/Imo2019Q2.lean b/Archive/Imo/Imo2019Q2.lean index 7d447ae03db0c8..9a8aafe704dd53 100644 --- a/Archive/Imo/Imo2019Q2.lean +++ b/Archive/Imo/Imo2019Q2.lean @@ -309,7 +309,7 @@ theorem sbtw_A_B₁_C : Sbtw ℝ cfg.A cfg.B₁ cfg.C := theorem sbtw_A_A₁_A₂ : Sbtw ℝ cfg.A cfg.A₁ cfg.A₂ := by refine Sphere.sbtw_secondInter cfg.A_mem_circumsphere ?_ - convert cfg.sbtw_B_A₁_C.dist_lt_max_dist _ + convert! cfg.sbtw_B_A₁_C.dist_lt_max_dist _ change _ = max (dist (cfg.triangleABC.points 1) _) (dist (cfg.triangleABC.points 2) _) simp_rw [circumsphere_center, circumsphere_radius, dist_circumcenter_eq_circumradius, max_self] @@ -375,7 +375,7 @@ variable [Module.Oriented ℝ V (Fin 2)] theorem two_zsmul_oangle_QPA₂_eq_two_zsmul_oangle_BAA₂ : (2 : ℤ) • ∡ cfg.Q cfg.P cfg.A₂ = (2 : ℤ) • ∡ cfg.B cfg.A cfg.A₂ := by refine two_zsmul_oangle_of_parallel cfg.QP_parallel_BA ?_ - convert AffineSubspace.Parallel.refl (k := ℝ) (P := Pt) _ using 1 + convert! AffineSubspace.Parallel.refl (k := ℝ) (P := Pt) _ using 1 rw [cfg.collinear_PAA₁A₂.affineSpan_eq_of_ne (Set.mem_insert_of_mem _ (Set.mem_insert_of_mem _ (Set.mem_insert_of_mem _ (Set.mem_singleton _)))) (Set.mem_insert_of_mem _ (Set.mem_insert _ _)) cfg.A₂_ne_A, diff --git a/Archive/Imo/Imo2024Q1.lean b/Archive/Imo/Imo2024Q1.lean index 41f351c433b42c..680dc4c3d6fc48 100644 --- a/Archive/Imo/Imo2024Q1.lean +++ b/Archive/Imo/Imo2024Q1.lean @@ -52,7 +52,7 @@ lemma condition_sub_two_mul_int_iff {α : ℝ} (m : ℤ) : Condition (α - 2 * m simp_rw [← Finset.sum_sub_distrib, mul_sub] norm_cast simp_rw [Int.floor_sub_intCast, sub_sub_cancel_left] - convert condition_two_mul_int (-m) n hn + convert! condition_two_mul_int (-m) n hn norm_cast rw [Int.floor_intCast] simp @@ -76,9 +76,9 @@ lemma mem_Ico_one_of_mem_Ioo (h : α ∈ Set.Ioo 0 2) : α ∈ Set.Ico 1 2 := by apply hr.ne' suffices ⌈α⁻¹⌉₊ = (1 : ℤ) from mod_cast this apply Int.eq_one_of_dvd_one (Int.zero_le_ofNat _) - convert hc ⌈α⁻¹⌉₊ (zero_lt_one.trans hr) + convert! hc ⌈α⁻¹⌉₊ (zero_lt_one.trans hr) rw [← Finset.add_sum_Ico_eq_sum_Icc hr.le] - convert (add_zero _).symm + convert! (add_zero _).symm · rw [Int.floor_eq_iff] constructor · rw [Int.cast_one] @@ -129,7 +129,7 @@ lemma mem_Ico_n_of_mem_Ioo (h : α ∈ Set.Ioo 0 2) {n : ℕ} (hn : 0 < n) : by_contra rw [show ⌊(k + 1 : ℕ) * α⌋ = 2 * k by lia] at hc have hc' : ((k + 1 : ℕ) : ℤ) ∣ ((k + 1 : ℕ) : ℤ) * ((k + 1 : ℕ) : ℤ) - 1 := by - convert hc using 1 + convert! hc using 1 push_cast ring rw [dvd_sub_right (dvd_mul_right _ _), ← isUnit_iff_dvd_one, Int.isUnit_iff] at hc' @@ -140,7 +140,7 @@ lemma mem_Ico_n_of_mem_Ioo (h : α ∈ Set.Ioo 0 2) {n : ℕ} (hn : 0 < n) : ring · rw [Int.floor_eq_iff] at hk' rw [div_le_iff₀ (by norm_cast; lia), mul_comm α] - convert hk'.1 + convert! hk'.1 push_cast ring @@ -153,7 +153,7 @@ lemma not_condition_of_mem_Ioo {α : ℝ} (h : α ∈ Set.Ioo 0 2) : ¬Condition have hna := (hc.mem_Ico_n_of_mem_Ioo h hn).1 rcases h with ⟨-, h2⟩ have hna' : 2 - (n : ℝ)⁻¹ ≤ α := by - convert hna using 1 + convert! hna using 1 field rw [sub_eq_add_neg, ← le_sub_iff_add_le', neg_le, neg_sub] at hna' rw [le_inv_comm₀ (by linarith) (mod_cast hn), ← not_lt] at hna' @@ -167,7 +167,7 @@ lemma condition_iff_of_mem_Ico {α : ℝ} (h : α ∈ Set.Ico 0 2) : Condition | inl h => exact h | inr ho => exact False.elim (not_condition_of_mem_Ioo ho hc) · rintro rfl - convert condition_two_mul_int 0 + convert! condition_two_mul_int 0 norm_num recall Imo2024Q1.Condition (α : ℝ) := (∀ n : ℕ, 0 < n → (n : ℤ) ∣ ∑ i ∈ Finset.Icc 1 n, ⌊i * α⌋) diff --git a/Archive/Imo/Imo2024Q2.lean b/Archive/Imo/Imo2024Q2.lean index b863dbed4e0a09..6334c708815153 100644 --- a/Archive/Imo/Imo2024Q2.lean +++ b/Archive/Imo/Imo2024Q2.lean @@ -32,12 +32,12 @@ lemma dvd_pow_iff_of_dvd_sub {a b d n : ℕ} {z : ℤ} (ha : a.Coprime d) d ∣ a ^ n + b ↔ (((ZMod.unitOfCoprime _ ha) ^ z : (ZMod d)ˣ) : ZMod d) + b = 0 := by rcases hd with ⟨k, hk⟩ rw [← ZMod.natCast_eq_zero_iff] - convert Iff.rfl + convert! Iff.rfl push_cast congr suffices (((ZMod.unitOfCoprime _ ha) ^ z : (ZMod d)ˣ) : ZMod d) = (((ZMod.unitOfCoprime _ ha) ^ (n : ℤ) : (ZMod d)ˣ) : ZMod d) by - convert this + convert! this rw [sub_eq_iff_eq_add] at hk rw [hk, zpow_add, zpow_mul] norm_cast @@ -139,11 +139,11 @@ lemma ab_add_one_dvd_a_pow_large_n_add_b : a * b + 1 ∣ a ^ h.large_n + b := by norm_cast simp only [mul_inv_cancel, Units.val_one, ZMod.coe_unitOfCoprime] norm_cast - convert ZMod.natCast_self (a * b + 1) using 2 + convert! ZMod.natCast_self (a * b + 1) using 2 exact add_comm _ _ lemma ab_add_one_dvd_b_pow_large_n_add_a : a * b + 1 ∣ b ^ h.large_n + a := by - convert h.symm.ab_add_one_dvd_a_pow_large_n_add_b using 1 + convert! h.symm.ab_add_one_dvd_a_pow_large_n_add_b using 1 · rw [mul_comm] · rw [h.symm_large_n] diff --git a/Archive/Imo/Imo2024Q3.lean b/Archive/Imo/Imo2024Q3.lean index 0fd39443836125..0c740c9682efe2 100644 --- a/Archive/Imo/Imo2024Q3.lean +++ b/Archive/Imo/Imo2024Q3.lean @@ -113,7 +113,7 @@ lemma apply_add_one_eq_card {n : ℕ} (h : N ≤ n) : simp @[simp] lemma nth_apply_eq_zero (n : ℕ) : Nat.nth (a · = 0) n = 0 := by - convert Nat.nth_false _ with i + convert! Nat.nth_false _ with i simp only [(hc.pos i).ne'] lemma nth_apply_add_one_eq {n : ℕ} (h : N ≤ n) : Nat.nth (a · = a n) (a (n + 1) - 1) = n := by @@ -173,7 +173,7 @@ lemma exists_infinite_setOf_apply_eq : ∃ m, {i | a i = m}.Infinite := by rintro _ ⟨⟨_, rfl⟩, hi⟩ _ ⟨⟨_, rfl⟩, hj⟩ h simp only [Set.mem_Ico, zero_le, true_and, not_lt] at hi hj simp only [add_left_inj] at h - convert congr(a $h) using 1 <;> simp [apply_nth_zero] + convert! congr(a $h) using 1 <;> simp [apply_nth_zero] refine (Set.infinite_of_injOn_mapsTo hinj (fun i hi ↦ ?_) (hr.diff (Set.finite_Ico _ _))) (hi 1) simp only [Set.mem_diff, Set.mem_range, Set.mem_Ico, zero_le, true_and, not_lt] at hi rcases hi with ⟨⟨_, rfl⟩, hi⟩ @@ -244,7 +244,7 @@ lemma card_lt_M_of_M_le {n : ℕ} (h : M a N ≤ n) : have ha : M a N ≤ a (Nat.nth (a · = n) (M a N - 1)) := (Nat.nth_mem _ hin').symm ▸ h refine ⟨ha, ?_⟩ suffices H : a (Nat.nth (fun x ↦ a x = n) (M a N - 1) + 1) = M a N from Nat.le_of_eq H.symm - convert hc.apply_nth_add_one_eq hin' (N_lt_of_M_le_apply ha).le using 1 + convert! hc.apply_nth_add_one_eq hin' (N_lt_of_M_le_apply ha).le using 1 lemma bddAbove_setOf_infinite_setOf_apply_eq : BddAbove {m | {i | a i = m}.Infinite} := by refine ⟨M a N, fun x hi ↦ ?_⟩ @@ -257,7 +257,7 @@ lemma infinite_setOf_apply_eq_anti {j k : ℕ} (hj : 0 < j) (hk : {i | a i = k}. have hinj : Set.InjOn (· + 1) {i | a (i + 1) = k} := (add_left_injective _).injOn rw [← Set.infinite_image_iff hinj] have hk0 : ({i | a i = k} \ {0}).Infinite := hk.diff (Set.finite_singleton _) - convert hk0 using 1 + convert! hk0 using 1 ext i simp only [Set.mem_image, Set.mem_setOf_eq, Set.mem_diff, Set.mem_singleton_iff] refine ⟨?_, ?_⟩ @@ -336,7 +336,7 @@ lemma bddAbove_setOf_k_lt_card : BddAbove {m | ∀ hf : {i | a i = m}.Finite, k lemma k_pos : 0 < k a := by by_contra! hn apply nonpos_iff_eq_zero.mp hn ▸ hc.infinite_setOf_apply_eq_k - convert Set.finite_empty + convert! Set.finite_empty ext i simp [(hc.pos i).ne'] @@ -542,8 +542,9 @@ lemma apply_sub_one_big_of_apply_small_of_N'_lt {i : ℕ} (h : Small a (a i)) (h lemma apply_sub_two_small_of_apply_small_of_N'_lt {i : ℕ} (h : Small a (a i)) (hN' : N' a N < i) : Small a (a (i - 2)) := by - convert hc.apply_sub_one_small_of_apply_big_of_N'_le - (hc.apply_sub_one_big_of_apply_small_of_N'_lt h hN') (by lia) using 1 + convert! + hc.apply_sub_one_small_of_apply_big_of_N'_le + (hc.apply_sub_one_big_of_apply_small_of_N'_lt h hN') (by lia) using 1 lemma N_add_one_lt_apply_of_apply_big_of_N'_le {i : ℕ} (h : Big a (a i)) (hN' : N' a N ≤ i) : N + 1 < a i := by @@ -567,7 +568,7 @@ lemma setOf_apply_eq_of_apply_big_of_N'_le {i : ℕ} (h : Big a (a i)) (hN' : N' rw [← Set.Finite.toFinset_subset_toFinset (hs := hf') (ht := hf)] at hs refine (Finset.eq_of_subset_of_card_le hs (hck.trans ?_)).symm have hs : #((Finset.Icc 1 (k a)).image (fun t ↦ Nat.nth (a · = t) (a i - 1) + 1)) = k a := by - convert Finset.card_image_of_injOn fun t ht u hu htu ↦ ?_ + convert! Finset.card_image_of_injOn fun t ht u hu htu ↦ ?_ · simp only [Nat.card_Icc, add_tsub_cancel_right] · simp only [add_left_inj] at htu simp only [Finset.coe_Icc, Set.mem_Icc] at ht hu @@ -608,7 +609,7 @@ lemma small_apply_sub_one_of_apply_eq_of_apply_big_of_N'_le {i j : ℕ} (hj : a lemma apply_add_one_eq_card_small_le_card_eq {i : ℕ} (hi : N' a N < i) (hib : Big a (a i)) : a (i + 1) = #{m ∈ Finset.range (k a + 1) | a i ≤ #{j ∈ Finset.range i | a j = m}} := by rw [hc.apply_add_one_eq_card (hc.N_lt_N'.trans hi).le] - convert Finset.card_image_of_injOn (f := fun j ↦ Nat.nth (a · = j) (a i - 1) + 1) ?_ using 1 + convert! Finset.card_image_of_injOn (f := fun j ↦ Nat.nth (a · = j) (a i - 1) + 1) ?_ using 1 · congr ext j simp only [Finset.mem_filter, Finset.mem_range, Finset.mem_image] @@ -666,7 +667,7 @@ lemma apply_eq_card_small_le_card_eq_of_small {i : ℕ} (hi : N' a N + 1 < i) ext j simp only [Finset.mem_filter, Finset.mem_range, and_congr_right_iff] intro hj - convert Iff.rfl using 2 + convert! Iff.rfl using 2 congr 1 ext t simp only [Finset.mem_filter, Finset.mem_range] @@ -751,8 +752,8 @@ lemma exists_apply_sub_two_eq_of_apply_eq {i j : ℕ} (hi : N' a N + 2 < i) (hij congr 1 ext t simp only [Finset.mem_filter, Finset.mem_range] - refine ⟨fun ⟨htj, htj'⟩ ↦ ⟨?_, by convert htj' using 1⟩, - fun ⟨htj, htj'⟩ ↦ ⟨by lia, by convert htj' using 1⟩⟩ + refine ⟨fun ⟨htj, htj'⟩ ↦ ⟨?_, by convert! htj' using 1⟩, + fun ⟨htj, htj'⟩ ↦ ⟨by lia, by convert! htj' using 1⟩⟩ by_contra htj'' have ht1 : t = j - 1 := by lia subst ht1 @@ -866,7 +867,7 @@ lemma p_le_two_mul_k {n : ℕ} (hn : N' a N + 2 < n) (hs : Small a (a n)) : p a by_contra hlt obtain ⟨x, hx, y, hy, hxyne, hxy⟩ : ∃ x ∈ Finset.range (k a + 1), ∃ y ∈ Finset.range (k a + 1), x ≠ y ∧ a (n + 2 * x) = a (n + 2 * y) := by - convert Finset.exists_ne_map_eq_of_card_lt_of_maps_to (t := Finset.Icc 1 (k a)) ?_ ?_ + convert! Finset.exists_ne_map_eq_of_card_lt_of_maps_to (t := Finset.Icc 1 (k a)) ?_ ?_ · simp · rintro i - simp only [Finset.coe_Icc, Set.mem_Icc] @@ -923,7 +924,7 @@ lemma exists_p_eq : ∃ b c, ∀ n, b < n → p a (N' a N + 2 * n) = c := by · have hs : Small a (a (N' a N + 2 * (2 + t + u))) := by rw [hc.small_apply_N'_add_iff_even] simp - convert hc.p_apply_le_p_apply_add_two (by lia) hs using 1 + convert! hc.p_apply_le_p_apply_add_two (by lia) hs using 1 refine ⟨1 + t, c, fun n hn ↦ ?_⟩ rw [show n = 2 + t + (n - (2 + t)) by lia] exact heqc _ @@ -937,7 +938,7 @@ lemma exists_a_apply_add_eq : ∃ b c, 0 < c ∧ ∀ n, b < n → have := hc.p_pos (N' a N + 2 * (b + 2)) rcases hc.even_p (by lia) (hs (b + 2)) with ⟨_, _⟩ lia - · convert hc.apply_add_p_eq (by lia) (hs n) using 3 + · convert! hc.apply_add_p_eq (by lia) (hs n) using 3 rcases hc.even_p (by lia) (hs n) with ⟨_, ht⟩ simp [ht, ← two_mul] @@ -948,8 +949,8 @@ theorem result {a : ℕ → ℕ} {N : ℕ} (h : Condition a N) : obtain ⟨b, c, hc, hbc⟩ := h.exists_a_apply_add_eq a N obtain ⟨t, _⟩ | ⟨t, _⟩ := Nat.even_or_odd (Condition.N' a N) · refine .inl ⟨c, Condition.N' a N / 2 + b + 1, hc, fun m hm ↦ ?_⟩ - convert hbc (m - t) (by lia) using 1 <;> dsimp only <;> congr <;> lia + convert! hbc (m - t) (by lia) using 1 <;> dsimp only <;> congr <;> lia · refine .inr ⟨c, Condition.N' a N / 2 + b + 1, hc, fun m hm ↦ ?_⟩ - convert hbc (m - t) (by lia) using 1 <;> dsimp only <;> congr 1 <;> lia + convert! hbc (m - t) (by lia) using 1 <;> dsimp only <;> congr 1 <;> lia end Imo2024Q3 diff --git a/Archive/Imo/Imo2024Q5.lean b/Archive/Imo/Imo2024Q5.lean index 54e33c55cab4e4..ebdb10c91fe044 100644 --- a/Archive/Imo/Imo2024Q5.lean +++ b/Archive/Imo/Imo2024Q5.lean @@ -184,17 +184,17 @@ lemma Path.exists_mem_fst_eq (p : Path N) (r : Fin (N + 2)) : ∃ c ∈ p.cells, rw [Fin.le_def] have h := r.isLt rw [Nat.lt_succ_iff] at h - convert h + convert! h have hig : r ≤ (p.cells[i]).1 := of_decide_eq_true (List.findIdx_getElem (w := hi)) refine ⟨p.cells[i], List.getElem_mem _, ?_⟩ refine (hig.lt_or_eq.resolve_left fun h => ?_).symm rcases Nat.eq_zero_or_pos i with hi | hi - · simp only [hi, List.getElem_zero, p.head_first_row, Fin.not_lt_zero] at h + · simp [hi, List.getElem_zero, p.head_first_row] at h · suffices r ≤ p.cells[i - 1].1 by have hi' : i - 1 < i := by lia exact of_decide_eq_false (List.not_of_lt_findIdx hi') this have ha : Adjacent p.cells[i - 1] p.cells[i] := by - convert List.isChain_iff_getElem.1 p.valid_move_seq (i - 1) ?_ + convert! List.isChain_iff_getElem.1 p.valid_move_seq (i - 1) ?_ · simp [Nat.sub_add_cancel hi] · lia exact ha.le_of_lt h @@ -243,18 +243,18 @@ lemma Path.findFstEq_eq_find?_le (p : Path N) (r : Fin (N + 2)) : p.findFstEq r (p.cells.find? (fun c ↦ r ≤ c.1)).get (List.find?_isSome.2 (by simpa using p.exists_mem_le_fst r)) := by rw [findFstEq] - convert rfl using 2 + convert! rfl using 2 refine (find?_eq_eq_find?_le p.nonempty ?_ p.valid_move_seq).symm simp [p.head_first_row] lemma Path.firstMonster_isSome {p : Path N} {m : MonsterData N} : (p.firstMonster m).isSome = true ↔ ∃ x, x ∈ p.cells ∧ x ∈ m.monsterCells := by - convert List.find?_isSome + convert! List.find?_isSome simp lemma Path.firstMonster_eq_none {p : Path N} {m : MonsterData N} : (p.firstMonster m) = none ↔ ∀ x, x ∈ p.cells → x ∉ m.monsterCells := by - convert List.find?_eq_none + convert! List.find?_eq_none simp lemma Path.one_lt_length_cells (p : Path N) : 1 < p.cells.length := by @@ -280,7 +280,7 @@ def Path.tail (p : Path N) : Path N where · exact p.nonempty head_first_row := by split_ifs with h - · convert h + · convert! h rw [List.head_tail] · exact p.head_first_row last_last_row := by @@ -339,7 +339,7 @@ lemma Path.firstMonster_eq_of_findFstEq_mem {p : Path N} {m : MonsterData N} List.isChain_iff_getElem.1 p.valid_move_seq 0 (by lia) simp_rw [Adjacent, Nat.dist] at adj have hc0 : (p.cells[0].1 : ℕ) = 0 := by - convert Fin.ext_iff.1 p.head_first_row + convert! Fin.ext_iff.1 p.head_first_row exact List.getElem_zero _ have hc1 : (p.cells[1].1 : ℕ) ≠ 0 := Fin.val_ne_iff.2 h0 have h1 : (p.cells[1].1 : ℕ) = 1 := by lia @@ -388,7 +388,7 @@ lemma Path.findFstEq_fst_sub_one_mem (p : Path N) {r : Fin (N + 2)} (hr : r ≠ Option.some.injEq, forall_eq'] at ha nth_rw 1 [← cells.takeWhile_append_dropWhile (p := fun c ↦ !decide (r ≤ c.1))] refine List.mem_append_left _ ?_ - convert List.getLast_mem ht using 1 + convert! List.getLast_mem ht using 1 have htr : ((List.takeWhile (fun c ↦ !decide (r ≤ c.1)) cells).getLast ht).1 < r := by simpa using List.mem_takeWhile_imp (List.getLast_mem ht) have hdr : r ≤ ((List.dropWhile (fun c ↦ !decide (r ≤ c.1)) cells).head hd').1 := by @@ -452,7 +452,7 @@ def Path.reflect (p : Path N) : Path N where lemma Path.firstMonster_reflect (p : Path N) (m : MonsterData N) : p.reflect.firstMonster m.reflect = (p.firstMonster m).map Cell.reflect := by simp_rw [firstMonster, reflect, List.find?_map] - convert rfl + convert! rfl simp only [Function.comp_apply, decide_eq_decide, MonsterData.monsterCells] refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · rcases h with ⟨i, hi⟩ @@ -470,7 +470,7 @@ lemma Strategy.play_comp_castLE (s : Strategy N) (m : MonsterData N) {k₁ k₂ case refl => rfl case step k' hk' hki => rw [← hki, ← Fin.castLE_comp_castLE hk' (Nat.le_succ k'), ← Function.comp_assoc] - convert rfl + convert! rfl exact Fin.snoc_comp_castSucc.symm lemma Strategy.play_apply_of_le (s : Strategy N) (m : MonsterData N) {i k₁ k₂ : ℕ} (hi : i < k₁) @@ -509,7 +509,7 @@ lemma Strategy.play_two (s : Strategy N) (m : MonsterData N) {k : ℕ} (hk : 2 < · have h : (1 : Fin 2) = Fin.last 1 := rfl simp only [Fin.snoc_zero, Nat.reduceAdd, Fin.mk_one, Fin.isValue, Matrix.cons_val] simp only [h, Fin.snoc_last] - convert rfl + convert! rfl simp_rw [Fin.fin_one_eq_zero, Matrix.cons_val] lemma Strategy.WinsIn.mono (s : Strategy N) (m : MonsterData N) {k₁ k₂ : ℕ} (h : s.WinsIn m k₁) @@ -555,7 +555,7 @@ lemma row1_mem_monsterCells_monsterData12 (hN : 2 ≤ N) (c₁ c₂ : Fin (N + 1 lemma row2_mem_monsterCells_monsterData12 (hN : 2 ≤ N) {c₁ c₂ : Fin (N + 1)} (h : c₁ ≠ c₂) : (⟨2, by lia⟩, c₂) ∈ (monsterData12 hN c₁ c₂).monsterCells := by - convert Set.mem_range_self (row2 hN) + convert! Set.mem_range_self (row2 hN) exact (monsterData12_apply_row2 hN h).symm lemma Strategy.not_forcesWinIn_two (s : Strategy N) (hN : 2 ≤ N) : ¬ s.ForcesWinIn 2 := by @@ -568,7 +568,7 @@ lemma Strategy.not_forcesWinIn_two (s : Strategy N) (hN : 2 ≤ N) : ¬ s.Forces have h1r : m1.1 = 1 := Path.findFstEq_fst _ _ have h2r : m2.1 = 2 := Path.findFstEq_fst _ _ have h1 : m1 ∈ m.monsterCells := by - convert row1_mem_monsterCells_monsterData12 hN m1.2 m2.2 + convert! row1_mem_monsterCells_monsterData12 hN m1.2 m2.2 refine ⟨m, fun i ↦ ?_⟩ fin_cases i · simp only [Strategy.play_zero, Path.firstMonster_eq_of_findFstEq_mem h1, Option.isSome_some] @@ -585,7 +585,7 @@ lemma Strategy.not_forcesWinIn_two (s : Strategy N) (hN : 2 ≤ N) : ¬ s.Forces exact Path.findFstEq_fst_sub_one_mem _ two_ne_zero · rw [Path.firstMonster_isSome] refine ⟨m2, Path.findFstEq_mem_cells _ _, ?_⟩ - convert row2_mem_monsterCells_monsterData12 hN h using 1 + convert! row2_mem_monsterCells_monsterData12 hN h using 1 simpa [Prod.ext_iff, h2r, Fin.ext_iff] lemma Strategy.ForcesWinIn.three_le {s : Strategy N} {k : ℕ} (hf : s.ForcesWinIn k) @@ -986,7 +986,7 @@ lemma winningStrategy_play_two_of_edge_N (hN : 2 ≤ N) {m : MonsterData N} simp_rw [winningStrategy_play_two hN, path1, path1OfEdgeN, path2, path2OfEdgeNDef, if_neg hc₁0, dif_neg hc₁0, if_pos hc₁N, dif_pos hc₁N, if_pos hc₁r0, dif_pos hc₁r0, ← Path.firstMonster_reflect, MonsterData.reflect_reflect] - convert rfl using 4 + convert! rfl using 4 nth_rw 2 [← m.reflect_reflect] rw [Path.firstMonster_reflect] rcases ((path1OfEdge0 hN).firstMonster m.reflect).eq_none_or_eq_some with h | h @@ -1021,10 +1021,10 @@ lemma winningStrategy_forcesWinIn_three (hN : 2 ≤ N) : intro m rcases winningStrategy_play_one_eq_none_or_play_two_eq_none hN m with h | h · rw [Strategy.WinsIn] - convert Set.mem_range_self (⟨1, by simp⟩ : Fin 3) + convert! Set.mem_range_self (⟨1, by simp⟩ : Fin 3) exact h.symm · rw [Strategy.WinsIn] - convert Set.mem_range_self (⟨2, by simp⟩ : Fin 3) + convert! Set.mem_range_self (⟨2, by simp⟩ : Fin 3) exact h.symm /-- This is to be determined by the solver of the original problem (and much of the difficulty diff --git a/Archive/Imo/Imo2024Q6.lean b/Archive/Imo/Imo2024Q6.lean index 8e26eb7b9494f6..31c71c33fe46ec 100644 --- a/Archive/Imo/Imo2024Q6.lean +++ b/Archive/Imo/Imo2024Q6.lean @@ -58,7 +58,7 @@ lemma Aquaesulian.injective : Function.Injective f := by @[simp] lemma Aquaesulian.apply_zero : f 0 = 0 := by refine h.injective ?_ - convert h.apply_apply_add 0 using 1 <;> simp + convert! h.apply_apply_add 0 using 1 <;> simp @[simp] lemma Aquaesulian.apply_neg_apply_add (x : G) : f (-(f x)) + x = 0 := by @@ -82,7 +82,7 @@ lemma Aquaesulian.apply_neg_of_apply_eq {x₁ x₂ : G} (hx : f x₁ = x₂) : f lemma Aquaesulian.apply_neg_eq_neg_iff {x₁ x₂ : G} : f (-x₂) = -x₁ ↔ f x₁ = x₂ := by refine ⟨fun hn ↦ ?_, h.apply_neg_of_apply_eq⟩ - convert h.apply_neg_of_apply_eq hn <;> rw [neg_neg] + convert! h.apply_neg_of_apply_eq hn <;> rw [neg_neg] lemma Aquaesulian.pair_lemma {x u v : G} (huv : u ≠ v) (hx : f x = u ∨ f u = x) (hy : f x = v ∨ f v = x) : f x = v ∨ f x = u := by @@ -97,14 +97,14 @@ lemma Aquaesulian.g_two {x y u v : G} (huv : u ≠ v) (hx : f x + f (-x) = u) f (x + y) = -(f (-x)) + -(f (-y)) + v ∨ f (x + y) = -(f (-x)) + -(f (-y)) + u := by refine h.pair_lemma ?_ ?_ ?_ · simp [huv] - · convert h x (-(f (-y))) using 2 + · convert! h x (-(f (-y))) using 2 · rw [h.apply_neg_apply_neg, add_comm] · rw [← hx] abel · rw [← hx] abel_nf · rw [h.apply_neg_apply_neg, add_comm] - · convert h y (-(f (-x))) using 2 + · convert! h y (-(f (-x))) using 2 · rw [h.apply_neg_apply_neg] · rw [← hy] abel diff --git a/Archive/Kuratowski.lean b/Archive/Kuratowski.lean index 49059d8452860a..7f7f7d8d6b22a4 100644 --- a/Archive/Kuratowski.lean +++ b/Archive/Kuratowski.lean @@ -102,7 +102,7 @@ theorem mem_theFourteen_iff_isObtainable {s t : Set X} : complement operations from a single set `s` is at most 14. -/ theorem ncard_isObtainable_le_fourteen (s : Set X) : {t | IsObtainable s t}.ncard ≤ 14 := by classical - convert Set.ncard_coe_finset _ ▸ (theFourteen s).toFinset_card_le + convert! Set.ncard_coe_finset _ ▸ (theFourteen s).toFinset_card_le simp [Set.ext_iff, mem_theFourteen_iff_isObtainable] end Topology.ClosureCompl diff --git a/Archive/MinimalSheffer.lean b/Archive/MinimalSheffer.lean index 5eb903463f1085..329aa377c84033 100644 --- a/Archive/MinimalSheffer.lean +++ b/Archive/MinimalSheffer.lean @@ -121,7 +121,7 @@ lemma sup_le (h₁ : a ≤ c) (h₂ : b ≤ c) : aᶜ | bᶜ ≤ c := by rw [h₂] have l1 := (abba (aᶜ | (b | c)) (b | c | c)).symm rw [comm _ (aᶜ | _), ← le_def] at l1 - convert l1 using 1 + convert! l1 using 1 have l2 := veroff (b | c) c a rw [comm _ a, ← h₁, comm, comm _ aᶜ] at l2 nth_rw 1 [l2, comm (b | c) c, comm b, veroff] diff --git a/Archive/MiuLanguage/DecisionSuf.lean b/Archive/MiuLanguage/DecisionSuf.lean index 39c987397c5418..e4b1c5f4d9f5fd 100644 --- a/Archive/MiuLanguage/DecisionSuf.lean +++ b/Archive/MiuLanguage/DecisionSuf.lean @@ -163,7 +163,7 @@ theorem le_pow2_and_pow2_eq_mod3 (a : ℕ) (h : a % 3 = 1 ∨ a % 3 = 2) : obtain ⟨m, hm⟩ := le_pow2_and_pow2_eq_mod3' (a % 3) (a / 3) h use m constructor - · convert hm.1; exact (mod_add_div a 3).symm + · convert! hm.1; exact (mod_add_div a 3).symm · rw [hm.2, mod_mod _ 3] end Arithmetic @@ -194,7 +194,7 @@ theorem der_replicate_I_of_mod3 (c : ℕ) (h : c % 3 = 1 ∨ c % 3 = 2) : replicate ((2 ^ m - c) / 3) U ++ replicate ((2 ^ m - c) / 3 % 2) U) := by apply der_cons_replicate_I_replicate_U_append_of_der_cons_replicate_I_append c ((2 ^ m - c) / 3) h - convert hw₂ using 4 + convert! hw₂ using 4 -- now we must show `c + 3 * ((2 ^ m - c) / 3) = 2 ^ m` rw [Nat.mul_div_cancel'] · exact add_tsub_cancel_of_le hm.1 @@ -220,7 +220,7 @@ example (c : ℕ) (h : c % 3 = 1 ∨ c % 3 = 2) : Derivable (M :: replicate c I) replicate ((2 ^ m - c) / 3) U ++ replicate ((2 ^ m - c) / 3 % 2) U) := by apply der_cons_replicate_I_replicate_U_append_of_der_cons_replicate_I_append c ((2 ^ m - c) / 3) h - convert hw₂ using 4 + convert! hw₂ using 4 -- now we must show `c + 3 * ((2 ^ m - c) / 3) = 2 ^ m` rw [Nat.mul_div_cancel'] · exact add_tsub_cancel_of_le hm.1 diff --git a/Archive/Sensitivity.lean b/Archive/Sensitivity.lean index b48847812ab9a1..228e4a2fb4edbb 100644 --- a/Archive/Sensitivity.lean +++ b/Archive/Sensitivity.lean @@ -90,7 +90,7 @@ theorem succ_n_eq (p q : Q n.succ) : p = q ↔ p 0 = q 0 ∧ π p = π q := by by_cases hx : x = 0 · rwa [hx] · rw [← Fin.succ_pred x hx] - convert congr_fun h (Fin.pred x hx) + convert! congr_fun h (Fin.pred x hx) /-- The adjacency relation defining the graph structure on `Q n`: `p.adjacent q` if there is an edge from `p` to `q` in `Q n`. -/ @@ -383,21 +383,21 @@ theorem exists_eigenvalue (H : Set (Q m.succ)) (hH : Card H ≥ 2 ^ m + 1) : suffices 0 < dim (W ⊓ img) by exact mod_cast exists_mem_ne_zero_of_rank_pos this have dim_le : dim (W ⊔ img) ≤ 2 ^ (m + 1 : Cardinal) := by - convert ← Submodule.rank_le (W ⊔ img) + convert! ← Submodule.rank_le (W ⊔ img) rw [← Nat.cast_succ] apply dim_V have dim_add : dim (W ⊔ img) + dim (W ⊓ img) = dim W + 2 ^ m := by - convert ← Submodule.rank_sup_add_rank_inf_eq W img + convert! ← Submodule.rank_sup_add_rank_inf_eq W img rw [rank_range_of_injective (g m) g_injective] apply dim_V have dimW : dim W = card H := by have li : LinearIndependent ℝ (H.restrict e) := by - convert (dualBases_e_ε m.succ).basis.linearIndependent.comp _ Subtype.val_injective + convert! (dualBases_e_ε m.succ).basis.linearIndependent.comp _ Subtype.val_injective rw [(dualBases_e_ε _).coe_basis] rfl have hdW := rank_span li rw [Set.range_restrict] at hdW - convert hdW + convert! hdW rw [← (dualBases_e_ε _).coe_basis, Cardinal.mk_image_eq (dualBases_e_ε _).basis.injective, Cardinal.mk_fintype] rw [← finrank_eq_rank ℝ] at dim_le dim_add dimW ⊢ @@ -452,7 +452,7 @@ theorem huang_degree_theorem (H : Set (Q m.succ)) (hH : Card H ≥ 2 ^ m + 1) : norm_cast apply card_le_card rw [Set.toFinset_inter] - convert inter_subset_inter_right coeffs_support + convert! inter_subset_inter_right coeffs_support end diff --git a/Archive/Wiedijk100Theorems/AbelRuffini.lean b/Archive/Wiedijk100Theorems/AbelRuffini.lean index 9e686d91399255..b4e87d9ea25164 100644 --- a/Archive/Wiedijk100Theorems/AbelRuffini.lean +++ b/Archive/Wiedijk100Theorems/AbelRuffini.lean @@ -55,7 +55,7 @@ variable [Nontrivial R] theorem degree_Phi : (Φ R a b).degree = ((5 : ℕ) : WithBot ℕ) := by suffices degree (X ^ 5 - C (a : R) * X) = ((5 : ℕ) : WithBot ℕ) by rwa [Φ, degree_add_eq_left_of_degree_lt] - convert (degree_C_le (R := R)).trans_lt (WithBot.coe_lt_coe.mpr (show 0 < 5 by simp)) + convert! (degree_C_le (R := R)).trans_lt (WithBot.coe_lt_coe.mpr (show 0 < 5 by simp)) rw [degree_sub_eq_left_of_degree_lt] <;> rw [degree_X_pow] exact (degree_C_mul_X_le (a : R)).trans_lt (WithBot.coe_lt_coe.mpr (show 1 < 5 by simp)) @@ -134,7 +134,7 @@ theorem real_roots_Phi_ge (hab : b < a) : 2 ≤ Fintype.card ((Φ ℚ a b).rootS obtain ⟨x, y, hxy, hx, hy⟩ := real_roots_Phi_ge_aux a b hab have key : ↑({x, y} : Finset ℝ) ⊆ (Φ ℚ a b).rootSet ℝ := by simp [Set.insert_subset, mem_rootSet_of_ne q_ne_zero, hx, hy] - convert Fintype.card_le_of_embedding (Set.embeddingOfSubset _ _ key) + convert! Fintype.card_le_of_embedding (Set.embeddingOfSubset _ _ key) simp only [Finset.coe_sort_coe, Fintype.card_coe, Finset.card_singleton, Finset.card_insert_of_notMem (mt Finset.mem_singleton.mp hxy)] diff --git a/Archive/Wiedijk100Theorems/AreaOfACircle.lean b/Archive/Wiedijk100Theorems/AreaOfACircle.lean index dab12166f1f201..71aaa05c5d0099 100644 --- a/Archive/Wiedijk100Theorems/AreaOfACircle.lean +++ b/Archive/Wiedijk100Theorems/AreaOfACircle.lean @@ -98,12 +98,12 @@ theorem area_disc : volume (disc r) = NNReal.pi * r ^ 2 := by obtain heq | hlt := hle.eq_or_lt; · simp [← heq] have hderiv : ∀ x ∈ Ioo (-r : ℝ) r, HasDerivAt F (2 * f x) x := by rintro x ⟨hx1, hx2⟩ - convert + convert! ((hasDerivAt_const x ((r : ℝ) ^ 2)).mul - ((hasDerivAt_arcsin _ _).comp x - ((hasDerivAt_const x (r : ℝ)⁻¹).mul (hasDerivAt_id' x)))).add - ((hasDerivAt_id' x).mul ((((hasDerivAt_id' x).fun_pow 2).const_sub ((r : ℝ) ^ 2)).sqrt _)) - using 1 + ((hasDerivAt_arcsin _ _).comp x + ((hasDerivAt_const x (r : ℝ)⁻¹).mul (hasDerivAt_id' x)))).add + ((hasDerivAt_id' x).mul + ((((hasDerivAt_id' x).fun_pow 2).const_sub ((r : ℝ) ^ 2)).sqrt _)) using 1 · have h₁ : 0 < (r : ℝ) ^ 2 - x ^ 2 := sub_pos_of_lt (sq_lt_sq' hx1 hx2) have h : sqrt ((r : ℝ) ^ 2 - x ^ 2) ^ 3 = ((r : ℝ) ^ 2 - x ^ 2) * sqrt ((r : ℝ) ^ 2 - x ^ 2) := by diff --git a/Archive/Wiedijk100Theorems/AscendingDescendingSequences.lean b/Archive/Wiedijk100Theorems/AscendingDescendingSequences.lean index 213794df94ade2..ec92034f0ad98c 100644 --- a/Archive/Wiedijk100Theorems/AscendingDescendingSequences.lean +++ b/Archive/Wiedijk100Theorems/AscendingDescendingSequences.lean @@ -91,7 +91,7 @@ private lemma maxIncSequencesTo_lt {i j : α} (hij : i < j) (hfij : f i < f j) : exact (hti.2 hx).trans_lt hij refine ⟨insert j t, ?_, ?_, ?_⟩ next => - convert hti.insert j using 1 + convert! hti.insert j using 1 next => simp next => rw [max_eq_left hij.le] next => diff --git a/Archive/Wiedijk100Theorems/CubingACube.lean b/Archive/Wiedijk100Theorems/CubingACube.lean index 31c9c0f26df100..b495afdf771008 100644 --- a/Archive/Wiedijk100Theorems/CubingACube.lean +++ b/Archive/Wiedijk100Theorems/CubingACube.lean @@ -137,7 +137,7 @@ variable (h : Correct cs) include h theorem toSet_subset_unitCube {i} : (cs i).toSet ⊆ unitCube.toSet := by - convert h.iUnion_eq ▸ subset_iUnion _ i + convert! h.iUnion_eq ▸ subset_iUnion _ i theorem side_subset {i j} : (cs i).side j ⊆ Ico 0 1 := by simpa only [side_unitCube] using toSet_subset.1 h.toSet_subset_unitCube j @@ -154,7 +154,7 @@ theorem zero_le_b {i j} : 0 ≤ (cs i).b j := theorem b_add_w_le_one {j} : (cs i).b j + (cs i).w ≤ 1 := by have : side (cs i) j ⊆ Ico 0 1 := side_subset h rw [side, Ico_subset_Ico_iff] at this - · convert this.2 + · convert! this.2 · simp [hw] theorem nontrivial_fin : Nontrivial (Fin n) := @@ -169,7 +169,7 @@ theorem w_ne_one [Nontrivial ι] (i : ι) : (cs i).w ≠ 1 := by have h2p : p ∈ (cs i).toSet := by intro j; constructor · trans (0 : ℝ) - · rw [← add_le_add_iff_right (1 : ℝ)]; convert b_add_w_le_one h + · rw [← add_le_add_iff_right (1 : ℝ)]; convert! b_add_w_le_one h · rw [hi] · rw [zero_add] · apply zero_le_b h @@ -197,7 +197,7 @@ theorem shiftUp_bottom_subset_bottoms (hc : (cs i).xm ≠ 1) : rw [onFun, comp_apply, comp_apply, toSet_disjoint, exists_fin_succ] at this rcases this with (h0 | ⟨j, hj⟩) · rw [hp0]; symm; apply eq_of_Ico_disjoint h0 (by simp [hw]) _ - convert hi' 0; rw [hp0]; rfl + convert! hi' 0; rw [hp0]; rfl · exfalso; apply not_disjoint_iff.mpr ⟨tail p j, hps j, hi' j.succ⟩ hj end Correct @@ -237,7 +237,7 @@ theorem valley_unitCube [Nontrivial ι] (h : Correct cs) : Valley cs unitCube := · rw [h0]; exact h.zero_le_b · exact (hi 0).1 intro j; exact hi _ - · intro i _ _; rw [toSet_subset]; intro j; convert h.side_subset using 1; simp [side_tail] + · intro i _ _; rw [toSet_subset]; intro j; convert! h.side_subset using 1; simp [side_tail] · intro i _; exact h.w_ne_one i /-- the cubes which lie in the valley `c` -/ @@ -252,7 +252,7 @@ theorem tail_sub (hi : i ∈ bcubes cs c) : ∀ j, (cs i).tail.side j ⊆ c.tail rw [← toSet_subset]; exact hi.2 theorem bottom_mem_side (hi : i ∈ bcubes cs c) : c.b 0 ∈ (cs i).side 0 := by - convert b_mem_side (cs i) _ using 1; rw [hi.1] + convert! b_mem_side (cs i) _ using 1; rw [hi.1] theorem b_le_b (hi : i ∈ bcubes cs c) (j : Fin n) : c.b j.succ ≤ (cs i).b j.succ := (tail_sub hi j <| b_mem_side _ _).1 @@ -422,13 +422,13 @@ theorem mi_not_onBoundary (j : Fin n) : ¬OnBoundary (mi_mem_bcubes : mi h v ∈ intro j₂ by_cases hj₂ : j₂ = j · cases hj₂; refine ⟨x, ?_, ?_⟩ - · convert hi'.2 j using 1; simp [i, p] - apply h3x h2i'' i_i''.symm; convert hi''.2 j using 1; simp [i, p', hj'.symm] + · convert! hi'.2 j using 1; simp [i, p] + apply h3x h2i'' i_i''.symm; convert! hi''.2 j using 1; simp [i, p', hj'.symm] by_cases h2j₂ : j₂ = j' - · cases h2j₂; refine ⟨x', hx'.1, ?_⟩; convert hi''.2 j' using 1; simp [p'] + · cases h2j₂; refine ⟨x', hx'.1, ?_⟩; convert! hi''.2 j' using 1; simp [p'] refine ⟨(cs i).b j₂.succ, ?_, ?_⟩ - · convert hi'.2 j₂ using 1; simp [p, hj₂] - · convert hi''.2 j₂ using 1; simp [p', h2j₂] + · convert! hi'.2 j₂ using 1; simp [p, hj₂] + · convert! hi''.2 j₂ using 1; simp [p', h2j₂] variable {h v} @@ -466,7 +466,7 @@ theorem valley_mi : Valley cs (cs (mi h v)).shiftUp := by · intro j'; by_cases h : j' = j · simp only [if_pos h]; exact h ▸ h3w · simp only [if_neg h]; exact hp2 j' - · simp only [toSet, not_forall, mem_setOf_eq]; use j; rw [if_pos rfl]; convert h2w + · simp only [toSet, not_forall, mem_setOf_eq]; use j; rw [if_pos rfl]; convert! h2w · intro j'; by_cases h : j' = j · simp only [if_pos h, side_tail]; exact h ▸ hw · simp only [if_neg h]; apply hi.2; apply h2p2 @@ -480,7 +480,7 @@ theorem valley_mi : Valley cs (cs (mi h v)).shiftUp := by · exact hi''.2 · rw [tail_cons]; exact h3p3 have h3i'' : (cs i).w < (cs i'').w := by - apply mi_strict_minimal _ h2i''; rintro rfl; apply h2p3; convert hi''.2 + apply mi_strict_minimal _ h2i''; rintro rfl; apply h2p3; convert! hi''.2 let p' := @cons n (fun _ => ℝ) (cs i).xm p3 have hp' : p' ∈ (cs i').toSet := by simpa [i, p', toSet, forall_iff_succ, hi'.symm] using h1p3 have h2p' : p' ∈ (cs i'').toSet := by diff --git a/Counterexamples/CliffordAlgebraNotInjective.lean b/Counterexamples/CliffordAlgebraNotInjective.lean index ce016c182617a7..98e8270597431f 100644 --- a/Counterexamples/CliffordAlgebraNotInjective.lean +++ b/Counterexamples/CliffordAlgebraNotInjective.lean @@ -234,7 +234,7 @@ theorem quot_obv : α • x' - β • y' - γ • z' = 0 := by dsimp only [gen] simp_rw [← map_smul, ← map_sub, ← Submodule.Quotient.mk_smul _ (_ : K), ← Submodule.Quotient.mk_sub] - convert LinearMap.map_zero _ using 2 + convert! LinearMap.map_zero _ using 2 rw [Submodule.Quotient.mk_eq_zero] simp +decide [sub_zero] diff --git a/Counterexamples/EulerSumOfPowers.lean b/Counterexamples/EulerSumOfPowers.lean index 72e92f06908961..69b1fba2b18bcd 100644 --- a/Counterexamples/EulerSumOfPowers.lean +++ b/Counterexamples/EulerSumOfPowers.lean @@ -76,7 +76,7 @@ lemma sumOfPowersConjecture_of_ringHom {R S : Type*} [Semiring R] [Semiring S] { SumOfPowersConjectureWith R n := by intro a b ha ha₀ hb hsum have h : (· ^ n) ∘ f = f ∘ (· ^ n) := by ext; simp - convert conj (a.map f) (f b) ?_ ?_ ?_ (by simp [h, hsum, List.sum_map_hom]) <;> grind + convert! conj (a.map f) (f b) ?_ ?_ ?_ (by simp [h, hsum, List.sum_map_hom]) <;> grind /-- Given an injective ring homomorphism from `R` to `S`, the conjecture over `S` implies the conjecture over `R`. -/ diff --git a/Counterexamples/MapFloor.lean b/Counterexamples/MapFloor.lean index 075e16714ac418..c45e5c9454e12d 100644 --- a/Counterexamples/MapFloor.lean +++ b/Counterexamples/MapFloor.lean @@ -65,7 +65,7 @@ theorem pos_iff {p : ℤ[ε]} : 0 < p ↔ 0 < p.trailingCoeff := by ⟨?_, fun h => ⟨p.natTrailingDegree, fun m hm => (coeff_eq_zero_of_lt_natTrailingDegree hm).symm, h⟩⟩ rintro ⟨n, hn⟩ - convert hn.2 + convert! hn.2 exact (natTrailingDegree_le_of_ne_zero hn.2.ne').antisymm (le_natTrailingDegree (by rintro rfl; cases hn.2.false) fun m hm => (hn.1 _ hm).symm) diff --git a/Counterexamples/NowhereDifferentiable.lean b/Counterexamples/NowhereDifferentiable.lean index 2497df7520bf8f..998caa01d49e12 100644 --- a/Counterexamples/NowhereDifferentiable.lean +++ b/Counterexamples/NowhereDifferentiable.lean @@ -160,7 +160,7 @@ theorem weierstrass_remainder {a : ℝ} (ha : 0 < a) {b : ℕ} (hb : Odd b) {x : · -- Show that the first term (after simplification) satisfies the bound suffices a ^ m * (2 / 3 * b ^ m * |seq b x m - x|) ≤ a ^ m * (1 + cos ((b ^ m * x - ⌊b ^ m * x + 2⁻¹⌋) * π)) by - convert this using 1 + convert! this using 1 ring refine mul_le_mul_of_nonneg_left ?_ (pow_nonneg ha.le _) trans 1 @@ -261,7 +261,7 @@ theorem not_differentiableAt_weierstrass obtain ⟨f', h⟩ := this have : Tendsto (fun m ↦ (seq b x m - x)⁻¹ * (weierstrass a b (seq b x m) - weierstrass a b x)) atTop (𝓝 (f' 1)) := by - convert (h.lim_real 1).comp (tendsto_seq_sub_inv hb1 x) + convert! (h.lim_real 1).comp (tendsto_seq_sub_inv hb1 x) simp have h := (continuous_abs.tendsto _).comp this contrapose! h @@ -274,7 +274,7 @@ theorem not_differentiableAt_weierstrass exact weierstrass_slope ha hb hab' x m have hpos : 0 < 2 / 3 - π / (a * b - 1) := by rw [sub_pos, div_lt_iff₀ (by simpa using hab'), ← div_lt_iff₀' (by norm_num), lt_sub_iff_add_lt] - convert hab using 1 + convert! hab using 1 grind exact (tendsto_const_nhds_iff.mpr rfl).pos_mul_atTop hpos (tendsto_pow_atTop_atTop_of_one_lt hab') diff --git a/Counterexamples/Phillips.lean b/Counterexamples/Phillips.lean index fc086f68755d25..efe03d538ec013 100644 --- a/Counterexamples/Phillips.lean +++ b/Counterexamples/Phillips.lean @@ -283,7 +283,7 @@ theorem exists_discrete_support_nonpos (f : BoundedAdditiveMeasure α) : have I1 : ∀ n, ε / 2 ≤ f (↑(s (n + 1)) \ ↑(s n)) := by intro n rw [div_le_iff₀' (show (0 : ℝ) < 2 by simp), hε] - convert hF (s n) u using 2 + convert! hF (s n) u using 2 · dsimp ext x simp only [u, not_exists, mem_iUnion, mem_diff] @@ -361,7 +361,7 @@ theorem discretePart_apply (f : BoundedAdditiveMeasure α) (s : Set α) : theorem continuousPart_apply_eq_zero_of_countable (f : BoundedAdditiveMeasure α) (s : Set α) (hs : s.Countable) : f.continuousPart s = 0 := by simp only [continuousPart, restrict_apply] - convert f.apply_countable s hs using 2 + convert! f.apply_countable s hs using 2 ext x simp [and_comm] diff --git a/Counterexamples/SorgenfreyLine.lean b/Counterexamples/SorgenfreyLine.lean index 25b780bcb1b451..71a0c5b4d0edd3 100644 --- a/Counterexamples/SorgenfreyLine.lean +++ b/Counterexamples/SorgenfreyLine.lean @@ -221,7 +221,7 @@ theorem isClosed_of_subset_antidiagonal {s : Set (ℝₗ × ℝₗ)} {c : ℝₗ exact closure_minimal (hs : s ⊆ {x | x.1 + x.2 = c}) (isClosed_antidiagonal c) H rcases mem_closure_iff.1 H (Ici (x, y)) (isClopen_Ici_prod _).2 self_mem_Ici with ⟨⟨x', y'⟩, ⟨hx : x ≤ x', hy : y ≤ y'⟩, H⟩ - convert H + convert! H · refine hx.antisymm ?_ rwa [← add_le_add_iff_right, hs _ H, add_le_add_iff_left] · refine hy.antisymm ?_ diff --git a/Counterexamples/TopologistsSineCurve.lean b/Counterexamples/TopologistsSineCurve.lean index e28ebfe1d74302..b2db6093cdeb70 100644 --- a/Counterexamples/TopologistsSineCurve.lean +++ b/Counterexamples/TopologistsSineCurve.lean @@ -82,7 +82,7 @@ lemma closure_S : closure S = T := by have : ContinuousAt (fun x ↦ sin x⁻¹) x := continuous_sin.continuousAt.comp <| continuousAt_inv₀ h.ne' refine tendsto_nhds_unique ?_ hf_lim.2 - convert this.tendsto.comp hf_lim.1 with n + convert! this.tendsto.comp hf_lim.1 with n obtain ⟨y, hy⟩ := hf_mem n simp [← hy.2] · -- Show that every `p ∈ T` is the limit of a sequence in `S`. diff --git a/Counterexamples/ZeroDivisorsInAddMonoidAlgebras.lean b/Counterexamples/ZeroDivisorsInAddMonoidAlgebras.lean index 78c59342600104..d3e6059c5ef7fc 100644 --- a/Counterexamples/ZeroDivisorsInAddMonoidAlgebras.lean +++ b/Counterexamples/ZeroDivisorsInAddMonoidAlgebras.lean @@ -97,7 +97,7 @@ theorem zero_divisors_of_torsion {R A} [Nontrivial R] [Ring R] [AddMonoid A] (a (nsmul_ne_zero_of_lt_addOrderOf one_ne_zero (Nat.succ_le_iff.mp o2)) simp only [a0, single_eq_of_ne', Ne, not_false_iff] · simpa only [single_eq_same] using zero_ne_one - · convert Commute.geom_sum₂_mul (R := AddMonoidAlgebra R A) _ (addOrderOf a) using 3 + · convert! Commute.geom_sum₂_mul (R := AddMonoidAlgebra R A) _ (addOrderOf a) using 3 · rw [single_zero_one, one_pow, mul_one] · rw [single_pow, one_pow, addOrderOf_nsmul_eq_zero, single_zero_one, one_pow, sub_self] · simp only [single_zero_one, Commute.one_right] diff --git a/Mathlib.lean b/Mathlib.lean index 788c3262b42970..a33b80d38619f9 100644 --- a/Mathlib.lean +++ b/Mathlib.lean @@ -158,6 +158,7 @@ public import Mathlib.Algebra.Category.ModuleCat.Differentials.Basic public import Mathlib.Algebra.Category.ModuleCat.Differentials.Presheaf public import Mathlib.Algebra.Category.ModuleCat.EnoughInjectives public import Mathlib.Algebra.Category.ModuleCat.EpiMono +public import Mathlib.Algebra.Category.ModuleCat.Ext.Basic public import Mathlib.Algebra.Category.ModuleCat.Ext.DimensionShifting public import Mathlib.Algebra.Category.ModuleCat.Ext.Finite public import Mathlib.Algebra.Category.ModuleCat.Ext.HasExt @@ -779,6 +780,7 @@ public import Mathlib.Algebra.Module.LinearMap.Basic public import Mathlib.Algebra.Module.LinearMap.Defs public import Mathlib.Algebra.Module.LinearMap.DivisionRing public import Mathlib.Algebra.Module.LinearMap.End +public import Mathlib.Algebra.Module.LinearMap.FiniteRange public import Mathlib.Algebra.Module.LinearMap.Polynomial public import Mathlib.Algebra.Module.LinearMap.Prod public import Mathlib.Algebra.Module.LinearMap.Rat @@ -1324,6 +1326,7 @@ public import Mathlib.AlgebraicGeometry.AffineSpace public import Mathlib.AlgebraicGeometry.AffineTransitionLimit public import Mathlib.AlgebraicGeometry.AlgClosed.Basic public import Mathlib.AlgebraicGeometry.Artinian +public import Mathlib.AlgebraicGeometry.Birational.Dominant public import Mathlib.AlgebraicGeometry.Birational.RationalMap public import Mathlib.AlgebraicGeometry.ColimitsOver public import Mathlib.AlgebraicGeometry.Cover.Directed @@ -1573,6 +1576,7 @@ public import Mathlib.AlgebraicTopology.SimplicialSet.NerveNondegenerate public import Mathlib.AlgebraicTopology.SimplicialSet.NonDegenerateSimplices public import Mathlib.AlgebraicTopology.SimplicialSet.NonDegenerateSimplicesSubcomplex public import Mathlib.AlgebraicTopology.SimplicialSet.Nonempty +public import Mathlib.AlgebraicTopology.SimplicialSet.Nonsingular public import Mathlib.AlgebraicTopology.SimplicialSet.Op public import Mathlib.AlgebraicTopology.SimplicialSet.Path public import Mathlib.AlgebraicTopology.SimplicialSet.PiZero @@ -1689,6 +1693,7 @@ public import Mathlib.Analysis.CStarAlgebra.Unitary.Maps public import Mathlib.Analysis.CStarAlgebra.Unitary.Span public import Mathlib.Analysis.CStarAlgebra.Unitization public import Mathlib.Analysis.CStarAlgebra.lpSpace +public import Mathlib.Analysis.Calculus.AbsolutelyMonotone public import Mathlib.Analysis.Calculus.AddTorsor.AffineMap public import Mathlib.Analysis.Calculus.AddTorsor.Coord public import Mathlib.Analysis.Calculus.BumpFunction.Basic @@ -4858,6 +4863,7 @@ public import Mathlib.LinearAlgebra.AffineSpace.AffineEquiv public import Mathlib.LinearAlgebra.AffineSpace.AffineMap public import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic public import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Defs +public import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Shift public import Mathlib.LinearAlgebra.AffineSpace.Basis public import Mathlib.LinearAlgebra.AffineSpace.Centroid public import Mathlib.LinearAlgebra.AffineSpace.Ceva @@ -5107,6 +5113,7 @@ public import Mathlib.LinearAlgebra.Projection public import Mathlib.LinearAlgebra.Projectivization.Action public import Mathlib.LinearAlgebra.Projectivization.Basic public import Mathlib.LinearAlgebra.Projectivization.Cardinality +public import Mathlib.LinearAlgebra.Projectivization.Collinear public import Mathlib.LinearAlgebra.Projectivization.Constructions public import Mathlib.LinearAlgebra.Projectivization.Independence public import Mathlib.LinearAlgebra.Projectivization.Subspace @@ -5342,6 +5349,7 @@ public import Mathlib.MeasureTheory.Function.LpSeminorm.TriangleInequality public import Mathlib.MeasureTheory.Function.LpSeminorm.Trim public import Mathlib.MeasureTheory.Function.LpSpace.Basic public import Mathlib.MeasureTheory.Function.LpSpace.Complete +public import Mathlib.MeasureTheory.Function.LpSpace.CompleteOfCompleteLp public import Mathlib.MeasureTheory.Function.LpSpace.ContinuousCompMeasurePreserving public import Mathlib.MeasureTheory.Function.LpSpace.ContinuousFunctions public import Mathlib.MeasureTheory.Function.LpSpace.DomAct.Basic @@ -5518,6 +5526,7 @@ public import Mathlib.MeasureTheory.Measure.QuasiMeasurePreserving public import Mathlib.MeasureTheory.Measure.Real public import Mathlib.MeasureTheory.Measure.Regular public import Mathlib.MeasureTheory.Measure.RegularityCompacts +public import Mathlib.MeasureTheory.Measure.ResolventTransform public import Mathlib.MeasureTheory.Measure.Restrict public import Mathlib.MeasureTheory.Measure.SeparableMeasure public import Mathlib.MeasureTheory.Measure.Stieltjes @@ -5686,6 +5695,7 @@ public import Mathlib.NumberTheory.LSeries.ZMod public import Mathlib.NumberTheory.LSeries.ZetaZeros public import Mathlib.NumberTheory.LegendreSymbol.AddCharacter public import Mathlib.NumberTheory.LegendreSymbol.Basic +public import Mathlib.NumberTheory.LegendreSymbol.Complex public import Mathlib.NumberTheory.LegendreSymbol.GaussEisensteinLemmas public import Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol public import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic @@ -6358,10 +6368,12 @@ public import Mathlib.RingTheory.Artinian.Module public import Mathlib.RingTheory.Artinian.Ring public import Mathlib.RingTheory.Bezout public import Mathlib.RingTheory.Bialgebra.Basic +public import Mathlib.RingTheory.Bialgebra.Convolution public import Mathlib.RingTheory.Bialgebra.Equiv public import Mathlib.RingTheory.Bialgebra.GroupLike public import Mathlib.RingTheory.Bialgebra.Hom public import Mathlib.RingTheory.Bialgebra.MonoidAlgebra +public import Mathlib.RingTheory.Bialgebra.SymmetricAlgebra public import Mathlib.RingTheory.Bialgebra.TensorProduct public import Mathlib.RingTheory.Binomial public import Mathlib.RingTheory.ChainOfDivisors @@ -6613,6 +6625,7 @@ public import Mathlib.RingTheory.LittleWedderburn public import Mathlib.RingTheory.LocalIso public import Mathlib.RingTheory.LocalProperties.Basic public import Mathlib.RingTheory.LocalProperties.Exactness +public import Mathlib.RingTheory.LocalProperties.FinitePresentation public import Mathlib.RingTheory.LocalProperties.Injective public import Mathlib.RingTheory.LocalProperties.InjectiveDimension public import Mathlib.RingTheory.LocalProperties.IntegrallyClosed @@ -7004,6 +7017,7 @@ public import Mathlib.SetTheory.Cardinal.Arithmetic public import Mathlib.SetTheory.Cardinal.Basic public import Mathlib.SetTheory.Cardinal.Cofinality.Basic public import Mathlib.SetTheory.Cardinal.Cofinality.Club +public import Mathlib.SetTheory.Cardinal.Cofinality.Enum public import Mathlib.SetTheory.Cardinal.Cofinality.Ordinal public import Mathlib.SetTheory.Cardinal.Continuum public import Mathlib.SetTheory.Cardinal.CountableCover @@ -7228,6 +7242,7 @@ public import Mathlib.Tactic.Linter.Lint public import Mathlib.Tactic.Linter.MinImports public import Mathlib.Tactic.Linter.Multigoal public import Mathlib.Tactic.Linter.OldObtain +public import Mathlib.Tactic.Linter.OverlappingInstances public import Mathlib.Tactic.Linter.PPRoundtrip public import Mathlib.Tactic.Linter.PrivateModule public import Mathlib.Tactic.Linter.Style @@ -7974,6 +7989,7 @@ public import Mathlib.Topology.Sheaves.Abelian public import Mathlib.Topology.Sheaves.AddCommGrpCat public import Mathlib.Topology.Sheaves.Alexandrov public import Mathlib.Topology.Sheaves.CommRingCat +public import Mathlib.Topology.Sheaves.EtaleSpace public import Mathlib.Topology.Sheaves.Flasque public import Mathlib.Topology.Sheaves.Forget public import Mathlib.Topology.Sheaves.Functors diff --git a/Mathlib/Algebra/AffineMonoid/Irreducible.lean b/Mathlib/Algebra/AffineMonoid/Irreducible.lean index 233b25ec015a41..25361838cedfaf 100644 --- a/Mathlib/Algebra/AffineMonoid/Irreducible.lean +++ b/Mathlib/Algebra/AffineMonoid/Irreducible.lean @@ -74,7 +74,7 @@ lemma Submonoid.closure_irreducible [Monoid.FG M] : -- Pick a minimal set `S` generating `M`. obtain ⟨S, hSgen, hSmax⟩ := Submonoid.exists_minimal_closure_eq_top M -- We claim that `S` is the set of irreducible elements of `M`. - convert hSgen + convert! hSgen -- We already know that `S` contains all irreducible elements... refine (irreducible_subset_of_submonoidClosure_eq_top hSgen).antisymm fun r hrS ↦ ?_ -- So let us for contradiction assume that `r ∈ S` is reducible. diff --git a/Mathlib/Algebra/Algebra/Operations.lean b/Mathlib/Algebra/Algebra/Operations.lean index 6d78838e2478c4..54267e7ffb5618 100644 --- a/Mathlib/Algebra/Algebra/Operations.lean +++ b/Mathlib/Algebra/Algebra/Operations.lean @@ -902,7 +902,7 @@ protected theorem map_div {B : Type*} [CommSemiring B] [Algebra R B] (I J : Subm · rintro hx refine ⟨h.symm x, fun z hz => ?_, h.apply_symm_apply x⟩ obtain ⟨xz, xz_mem, hxz⟩ := hx (h z) ⟨z, hz, rfl⟩ - convert xz_mem + convert! xz_mem apply h.injective rw [map_mul, h.apply_symm_apply, hxz] diff --git a/Mathlib/Algebra/Algebra/Spectrum/Basic.lean b/Mathlib/Algebra/Algebra/Spectrum/Basic.lean index c92c29f7a2d357..0d9e485f9e4da1 100644 --- a/Mathlib/Algebra/Algebra/Spectrum/Basic.lean +++ b/Mathlib/Algebra/Algebra/Spectrum/Basic.lean @@ -101,6 +101,15 @@ local notation "↑ₐ" => algebraMap R A theorem mem_iff {r : R} {a : A} : r ∈ σ a ↔ ¬IsUnit (↑ₐ r - a) := Iff.rfl +@[simp] +theorem resolvent_zero_of_mem_spectrum {r : R} {a : A} (hr : r ∈ σ a) : + resolvent a r = 0 := Ring.inverse_non_unit _ (mem_iff.mp hr) + +theorem mem_spectrum_iff_resolvent_zero [Nontrivial A] {r : R} {a : A} : + r ∈ σ a ↔ resolvent a r = 0 := by + refine ⟨resolvent_zero_of_mem_spectrum, fun hr ↦ ?_⟩ + simpa [mem_iff, Ring.not_isUnit_iff_inverse_eq_zero] + theorem notMem_iff {r : R} {a : A} : r ∉ σ a ↔ IsUnit (↑ₐ r - a) := by simp [mem_iff] diff --git a/Mathlib/Algebra/Algebra/Spectrum/Quasispectrum.lean b/Mathlib/Algebra/Algebra/Spectrum/Quasispectrum.lean index 72dab6b30b5fac..352921912f0081 100644 --- a/Mathlib/Algebra/Algebra/Spectrum/Quasispectrum.lean +++ b/Mathlib/Algebra/Algebra/Spectrum/Quasispectrum.lean @@ -156,13 +156,13 @@ def unitsFstOne_mulEquiv_quasiregular : unitsFstOne R A ≃* (PreQuasiregular A) { val := 1 + PreQuasiregular.equiv.symm x.val inv := 1 + PreQuasiregular.equiv.symm x⁻¹.val val_inv := by - convert congr((1 + $(inv_add_add_mul_eq_zero x) : Unitization R A)) using 1 + convert! congr((1 + $(inv_add_add_mul_eq_zero x) : Unitization R A)) using 1 · simp only [mul_one, PreQuasiregular.equiv_symm_apply, one_mul, mul_add, add_mul, inr_add, inr_mul] abel · simp only [inr_zero, add_zero] inv_val := by - convert congr((1 + $(add_inv_add_mul_eq_zero x) : Unitization R A)) using 1 + convert! congr((1 + $(add_inv_add_mul_eq_zero x) : Unitization R A)) using 1 · simp only [mul_one, PreQuasiregular.equiv_symm_apply, one_mul, mul_add, add_mul, inr_add, inr_mul] abel @@ -216,8 +216,8 @@ lemma IsQuasiregular.isUnit_one_add {R : Type*} [Semiring R] {x : R} (hx : IsQua IsUnit (1 + x) := by obtain ⟨y, hy₁, hy₂⟩ := isQuasiregular_iff.mp hx refine ⟨⟨1 + x, 1 + y, ?_, ?_⟩, rfl⟩ - · convert congr(1 + $(hy₁)) using 1 <;> [noncomm_ring; simp] - · convert congr(1 + $(hy₂)) using 1 <;> [noncomm_ring; simp] + · convert! congr(1 + $(hy₁)) using 1 <;> [noncomm_ring; simp] + · convert! congr(1 + $(hy₂)) using 1 <;> [noncomm_ring; simp] lemma isQuasiregular_iff_isUnit {R : Type*} [Ring R] {x : R} : IsQuasiregular x ↔ IsUnit (1 + x) := by @@ -229,7 +229,7 @@ lemma isQuasiregular_iff_isUnit {R : Type*} [Ring R] {x : R} : case' h.right => have := congr($(hx.val_inv_mul) - 1) all_goals rw [← sub_add_cancel (↑hx.unit⁻¹ : R) 1, sub_self] at this - convert this using 1 + convert! this using 1 noncomm_ring -- interestingly, this holds even in the semiring case. @@ -314,7 +314,7 @@ lemma spectrum_subset_quasispectrum (R : Type*) {A : Type*} [CommSemiring R] [Ri lemma quasispectrum_eq_spectrum_union_zero (R : Type*) {A : Type*} [Semifield R] [Ring A] [Algebra R A] (a : A) : quasispectrum R a = spectrum R a ∪ {0} := by - convert quasispectrum_eq_spectrum_union R a + convert! quasispectrum_eq_spectrum_union R a simp lemma mem_quasispectrum_iff {R A : Type*} [Semifield R] [Ring A] @@ -518,10 +518,10 @@ protected lemma comp {R₁ R₂ R₃ A : Type*} [Semifield R₁] [Field R₂] [F (hf : QuasispectrumRestricts a f) (hg : QuasispectrumRestricts a g) : QuasispectrumRestricts a e where left_inv := by - convert hfge ▸ hf.left_inv.comp hg.left_inv + convert! hfge ▸ hf.left_inv.comp hg.left_inv congrm (⇑$(IsScalarTower.algebraMap_eq R₁ R₂ R₃)) rightInvOn := by - convert hfge ▸ hg.rightInvOn.comp hf.rightInvOn fun _ ↦ hf.apply_mem + convert! hfge ▸ hg.rightInvOn.comp hf.rightInvOn fun _ ↦ hf.apply_mem congrm (⇑$(IsScalarTower.algebraMap_eq R₁ R₂ R₃)) end NonUnital diff --git a/Mathlib/Algebra/Algebra/Subalgebra/Basic.lean b/Mathlib/Algebra/Algebra/Subalgebra/Basic.lean index 0929d4e5ac04d1..89b7e8ae8207bd 100644 --- a/Mathlib/Algebra/Algebra/Subalgebra/Basic.lean +++ b/Mathlib/Algebra/Algebra/Subalgebra/Basic.lean @@ -725,7 +725,7 @@ scoped instance faithfulSMul : letI := (inclusion h).toModule; FaithfulSMul S T := letI := (inclusion h).toModule ⟨fun {x y} h ↦ Subtype.ext <| by - convert Subtype.ext_iff.mp (h 1) using 1 <;> exact (mul_one _).symm⟩ + convert! Subtype.ext_iff.mp (h 1) using 1 <;> exact (mul_one _).symm⟩ end inclusion diff --git a/Mathlib/Algebra/Algebra/Subalgebra/Centralizer.lean b/Mathlib/Algebra/Algebra/Subalgebra/Centralizer.lean index 34561e733bd8cf..50fffbc6381b3c 100644 --- a/Mathlib/Algebra/Algebra/Subalgebra/Centralizer.lean +++ b/Mathlib/Algebra/Algebra/Subalgebra/Centralizer.lean @@ -111,7 +111,7 @@ lemma centralizer_coe_image_includeRight_eq_center_tensorProduct (Subalgebra.centralizer R (S : Set B)).val).range := by have eq1 := centralizer_coe_image_includeLeft_eq_center_tensorProduct R B A S apply_fun Subalgebra.comap (Algebra.TensorProduct.comm R A B).toAlgHom at eq1 - convert eq1 + convert! eq1 · ext x simpa [mem_centralizer_iff] using ⟨fun h b hb ↦ (Algebra.TensorProduct.comm R A B).symm.injective <| by aesop, fun h b hb ↦ diff --git a/Mathlib/Algebra/Algebra/Subalgebra/Lattice.lean b/Mathlib/Algebra/Algebra/Subalgebra/Lattice.lean index 5e4698cedbf0b8..d9931ad9c270b7 100644 --- a/Mathlib/Algebra/Algebra/Subalgebra/Lattice.lean +++ b/Mathlib/Algebra/Algebra/Subalgebra/Lattice.lean @@ -517,6 +517,34 @@ theorem subset_adjoin : s ⊆ adjoin R s := @[aesop 80% (rule_sets := [SetLike])] theorem mem_adjoin_of_mem {s : Set A} {x : A} (hx : x ∈ s) : x ∈ adjoin R s := subset_adjoin hx +/- +The following set-up allows one to write `xₖ : R[x₁, ..., xₙ]` instead of +`(⟨xₖ, "membership proof"⟩ : R[x₁, ..., xₙ])`. + +The idea is to recurse through the list of `x₁, ..., xₙ` until we find the appropriate `xₖ`. +By design, it only triggers if the set is of the form `insert x₁ (insert x₂ (...(s)))` or +`{x₁, ..., xₙ}`. +-/ + +variable {α : Type*} + +/-- Supporting class for coercions `xₖ : R[x₁, ..., xₙ]`. -/ +class CoeAdjoinAux (x : α) (s : Set α) : Prop where mem : x ∈ s + +scoped instance (x : α) : CoeAdjoinAux x {x} := ⟨Set.mem_singleton x⟩ + +scoped instance (x : α) (s : Set α) : CoeAdjoinAux x (insert x s) := ⟨Set.mem_insert x s⟩ + +scoped instance (x y : α) (s : Set α) [CoeAdjoinAux x s] : CoeAdjoinAux x (insert y s) := + ⟨Set.mem_insert_of_mem y CoeAdjoinAux.mem⟩ + +/-- Enables notation `xₖ : R[x₁, ..., xₙ]` instead of +`(⟨xₖ, "membership proof"⟩ : R[x₁, ..., xₙ])`. -/ +scoped instance {A B : Type*} [CommSemiring A] [Semiring B] [Algebra A B] + (s : Set B) (x : B) [CoeAdjoinAux x s] : + CoeDep B x (adjoin A s) where + coe := ⟨x, mem_adjoin_of_mem CoeAdjoinAux.mem⟩ + theorem adjoin_le {S : Subalgebra R A} (H : s ⊆ S) : adjoin R s ≤ S := Algebra.gc.l_le H @@ -713,7 +741,7 @@ theorem mem_adjoin_of_map_mul {s} {x : A} {f : A →ₗ[R] B} (hf : ∀ a₁ a | algebraMap r => have : f 1 ∈ adjoin R (f '' (s ∪ {1})) := subset_adjoin ⟨1, ⟨Set.subset_union_right <| Set.mem_singleton 1, rfl⟩⟩ - convert Subalgebra.smul_mem (adjoin R (f '' (s ∪ {1}))) this r + convert! Subalgebra.smul_mem (adjoin R (f '' (s ∪ { 1 }))) this r rw [algebraMap_eq_smul_one] exact f.map_smul _ _ | add y z _ _ hy hz => simpa [hy, hz] using Subalgebra.add_mem _ hy hz @@ -860,8 +888,8 @@ theorem eqOn_adjoin_iff {φ ψ : A →ₐ[R] B} {s : Set A} : theorem adjoin_ext {s : Set A} ⦃φ₁ φ₂ : adjoin R s →ₐ[R] B⦄ (h : ∀ x hx, φ₁ ⟨x, subset_adjoin hx⟩ = φ₂ ⟨x, subset_adjoin hx⟩) : φ₁ = φ₂ := ext fun ⟨x, hx⟩ ↦ adjoin_induction h (fun _ ↦ φ₂.commutes _ ▸ φ₁.commutes _) - (fun _ _ _ _ h₁ h₂ ↦ by convert congr_arg₂ (· + ·) h₁ h₂ <;> rw [← map_add] <;> rfl) - (fun _ _ _ _ h₁ h₂ ↦ by convert congr_arg₂ (· * ·) h₁ h₂ <;> rw [← map_mul] <;> rfl) hx + (fun _ _ _ _ h₁ h₂ ↦ by convert! congr_arg₂ (· + ·) h₁ h₂ <;> rw [← map_add] <;> rfl) + (fun _ _ _ _ h₁ h₂ ↦ by convert! congr_arg₂ (· * ·) h₁ h₂ <;> rw [← map_mul] <;> rfl) hx theorem ext_of_eq_adjoin {S : Subalgebra R A} {s : Set A} (hS : S = adjoin R s) ⦃φ₁ φ₂ : S →ₐ[R] B⦄ (h : ∀ x hx, φ₁ ⟨x, hS.ge (subset_adjoin hx)⟩ = φ₂ ⟨x, hS.ge (subset_adjoin hx)⟩) : @@ -977,7 +1005,7 @@ theorem comap_map_eq (f : A →ₐ[R] B) (S : Subalgebra R A) : theorem comap_map_eq_self {f : A →ₐ[R] B} {S : Subalgebra R A} (h : f ⁻¹' {0} ⊆ S) : (S.map f).comap f = S := by - convert comap_map_eq f S + convert! comap_map_eq f S rwa [left_eq_sup, Algebra.adjoin_le_iff] end Subalgebra diff --git a/Mathlib/Algebra/BigOperators/Fin.lean b/Mathlib/Algebra/BigOperators/Fin.lean index 73ac53464e1500..9e42dbf60f91fc 100644 --- a/Mathlib/Algebra/BigOperators/Fin.lean +++ b/Mathlib/Algebra/BigOperators/Fin.lean @@ -663,7 +663,7 @@ def finPiFinEquiv {m : ℕ} {n : Fin m → ℕ} : (∀ i : Fin m, Fin (n i)) ≃ simp_rw [Fin.val_zero, Fintype.prod_empty, Nat.div_one, mul_one, Fin.cons_zero, Fin.prod_univ_succ, Fin.castLE_zero, Fin.cons_zero, ← Nat.div_div_eq_div_mul, mul_left_comm (_ % _ : ℕ), ← mul_sum] - convert Nat.mod_add_div _ _ + convert! Nat.mod_add_div _ _ exact ih (a / x) (Nat.div_lt_of_lt_mul <| a.is_lt.trans_eq (Fin.prod_univ_succ _))) theorem finPiFinEquiv_apply {m : ℕ} {n : Fin m → ℕ} (f : ∀ i : Fin m, Fin (n i)) : diff --git a/Mathlib/Algebra/BigOperators/Finprod.lean b/Mathlib/Algebra/BigOperators/Finprod.lean index 1de4d50576a677..ec2b992d915110 100644 --- a/Mathlib/Algebra/BigOperators/Finprod.lean +++ b/Mathlib/Algebra/BigOperators/Finprod.lean @@ -336,7 +336,7 @@ variable {α β ι G M N : Type*} [CommMonoid M] [CommMonoid N] @[to_additive] theorem finprod_eq_mulIndicator_apply (s : Set α) (f : α → M) (a : α) : ∏ᶠ _ : a ∈ s, f a = mulIndicator s f a := by - classical convert finprod_eq_if (M := M) (p := a ∈ s) (x := f a) + classical convert! finprod_eq_if (M := M) (p := a ∈ s) (x := f a) @[to_additive (attr := simp)] theorem finprod_apply_ne_one (f : α → M) (a : α) : ∏ᶠ _ : f a ≠ 1, f a = f a := by @@ -1065,8 +1065,8 @@ theorem finprod_mem_sUnion {t : Set (Set α)} (h : t.PairwiseDisjoint id) (ht₀ lemma finprod_option {f : Option α → M} (hf : HasFiniteMulSupport (f ∘ some)) : ∏ᶠ o, f o = f none * ∏ᶠ a, f (some a) := by replace hf : (mulSupport f).Finite := by simpa [finite_option] - convert finprod_mem_insert' f (show none ∉ Set.range Option.some by simp) - (hf.subset inter_subset_right) + convert! + finprod_mem_insert' f (show none ∉ Set.range Option.some by simp) (hf.subset inter_subset_right) · simp · rw [finprod_mem_range] exact Option.some_injective _ diff --git a/Mathlib/Algebra/BigOperators/Finsupp/Basic.lean b/Mathlib/Algebra/BigOperators/Finsupp/Basic.lean index 824ecac1ed7986..a797fc8270a518 100644 --- a/Mathlib/Algebra/BigOperators/Finsupp/Basic.lean +++ b/Mathlib/Algebra/BigOperators/Finsupp/Basic.lean @@ -185,6 +185,20 @@ theorem prod_congr {f : α →₀ M} {g1 g2 : α → M → N} (h : ∀ x ∈ f.s f.prod g1 = f.prod g2 := Finset.prod_congr rfl h +/-- The product over two finsupps agree if the functions agree and are well-behaved within the +shared support. -/ +@[to_additive (attr := gcongr) +/-- The sum over two finsupps agree if the functions agree and are well-behaved within the +shared support. -/] +theorem prod_congr_of_eq_on_union [DecidableEq α] {f1 f2 : α →₀ M} {g1 g2 : α → M → N} + (h : ∀ x ∈ f1.support ∪ f2.support, g1 x (f1 x) = g2 x (f2 x)) + (h1 : ∀ x ∈ f1.support ∪ f2.support, g1 x 0 = 1) + (h2 : ∀ x ∈ f1.support ∪ f2.support, g2 x 0 = 1) : + f1.prod g1 = f2.prod g2 := by + rw [Finsupp.prod_of_support_subset f1 Finset.subset_union_left _ h1, + Finsupp.prod_of_support_subset f2 Finset.subset_union_right _ h2] + exact Finset.prod_congr rfl h + @[to_additive] theorem prod_eq_single {f : α →₀ M} (a : α) {g : α → M → N} (h₀ : ∀ b, f b ≠ 0 → b ≠ a → g b (f b) = 1) (h₁ : f a = 0 → g a 0 = 1) : diff --git a/Mathlib/Algebra/BigOperators/Group/Finset/Basic.lean b/Mathlib/Algebra/BigOperators/Group/Finset/Basic.lean index f0c05c6a1fa5f9..b8dd9eb0e5e698 100644 --- a/Mathlib/Algebra/BigOperators/Group/Finset/Basic.lean +++ b/Mathlib/Algebra/BigOperators/Group/Finset/Basic.lean @@ -153,6 +153,7 @@ lemma prod_filter_not_mul_prod_filter (s : Finset ι) (p : ι → Prop) [Decidab (∏ x ∈ s with ¬p x, f x) * ∏ x ∈ s with p x, f x = ∏ x ∈ s, f x := by rw [mul_comm, prod_filter_mul_prod_filter_not] +set_option backward.isDefEq.respectTransparency false in @[to_additive] theorem prod_filter_xor (p q : ι → Prop) [DecidablePred p] [DecidablePred q] : (∏ x ∈ s with (Xor (p x) (q x)), f x) = @@ -596,7 +597,7 @@ theorem prod_multiset_map_count [DecidableEq ι] (s : Multiset ι) {M : Type*} [ @[to_additive] theorem prod_multiset_count [DecidableEq M] (s : Multiset M) : s.prod = ∏ m ∈ s.toFinset, m ^ s.count m := by - convert prod_multiset_map_count s id + convert! prod_multiset_map_count s id rw [Multiset.map_id] @[to_additive] diff --git a/Mathlib/Algebra/BigOperators/Group/Finset/Defs.lean b/Mathlib/Algebra/BigOperators/Group/Finset/Defs.lean index 8c0c7daef6d965..5581009ca29a22 100644 --- a/Mathlib/Algebra/BigOperators/Group/Finset/Defs.lean +++ b/Mathlib/Algebra/BigOperators/Group/Finset/Defs.lean @@ -400,13 +400,13 @@ end ToList @[to_additive] theorem _root_.Equiv.Perm.prod_comp (σ : Equiv.Perm ι) (s : Finset ι) (f : ι → M) (hs : { a | σ a ≠ a } ⊆ s) : (∏ x ∈ s, f (σ x)) = ∏ x ∈ s, f x := by - convert (prod_map s σ.toEmbedding f).symm + convert! (prod_map s σ.toEmbedding f).symm exact (map_perm hs).symm @[to_additive] theorem _root_.Equiv.Perm.prod_comp' (σ : Equiv.Perm ι) (s : Finset ι) (f : ι → ι → M) (hs : { a | σ a ≠ a } ⊆ s) : (∏ x ∈ s, f (σ x) x) = ∏ x ∈ s, f x (σ.symm x) := by - convert σ.prod_comp s (fun x => f x (σ.symm x)) hs + convert! σ.prod_comp s (fun x => f x (σ.symm x)) hs rw [Equiv.symm_apply_apply] end CommMonoid @@ -782,7 +782,7 @@ theorem disjoint_sum_right {a : Multiset α} {i : Multiset (Multiset α)} : theorem disjoint_finsetSum_left {i : Finset ι} {f : ι → Multiset α} {a : Multiset α} : Disjoint (i.sum f) a ↔ ∀ b ∈ i, Disjoint (f b) a := by - convert @disjoint_sum_left _ a (map f i.val) + convert! @disjoint_sum_left _ a (map f i.val) simp @[deprecated (since := "2026-04-08")] alias disjoint_finset_sum_left := disjoint_finsetSum_left diff --git a/Mathlib/Algebra/BigOperators/Group/Finset/Piecewise.lean b/Mathlib/Algebra/BigOperators/Group/Finset/Piecewise.lean index 79ee76108083fb..ef8a3fbe8da4e4 100644 --- a/Mathlib/Algebra/BigOperators/Group/Finset/Piecewise.lean +++ b/Mathlib/Algebra/BigOperators/Group/Finset/Piecewise.lean @@ -184,14 +184,14 @@ theorem prod_piecewise [DecidableEq ι] (s t : Finset ι) (f g : ι → M) : @[to_additive] theorem prod_inter_mul_prod_diff [DecidableEq ι] (s t : Finset ι) (f : ι → M) : (∏ x ∈ s ∩ t, f x) * ∏ x ∈ s \ t, f x = ∏ x ∈ s, f x := by - convert (s.prod_piecewise t f f).symm + convert! (s.prod_piecewise t f f).symm simp +unfoldPartialApp [Finset.piecewise] @[to_additive] theorem prod_eq_mul_prod_diff_singleton [DecidableEq ι] {s : Finset ι} (i : ι) (f : ι → M) (h : i ∉ s → f i = 1) : ∏ x ∈ s, f x = f i * ∏ x ∈ s \ {i}, f x := by by_cases hs : i ∈ s - · convert (s.prod_inter_mul_prod_diff {i} f).symm + · convert! (s.prod_inter_mul_prod_diff { i } f).symm simp [hs] · simp_all only [not_false_eq_true, forall_const, one_mul] apply Finset.prod_congr <;> aesop diff --git a/Mathlib/Algebra/BigOperators/Group/List/Basic.lean b/Mathlib/Algebra/BigOperators/Group/List/Basic.lean index ab99b94bf57ebc..87538fdb3643ae 100644 --- a/Mathlib/Algebra/BigOperators/Group/List/Basic.lean +++ b/Mathlib/Algebra/BigOperators/Group/List/Basic.lean @@ -306,7 +306,7 @@ lemma eq_of_prod_take_eq [LeftCancelMonoid M] {L L' : List M} (h : L.length = L' refine ext_get h fun i h₁ h₂ => ?_ have : (L.take (i + 1)).prod = (L'.take (i + 1)).prod := h' _ (Nat.succ_le_of_lt h₁) rw [prod_take_succ L i h₁, prod_take_succ L' i h₂, h' i (Nat.le_of_lt h₁)] at this - convert mul_left_cancel this + convert! mul_left_cancel this section Group diff --git a/Mathlib/Algebra/BigOperators/Group/Multiset/Basic.lean b/Mathlib/Algebra/BigOperators/Group/Multiset/Basic.lean index c90841397d546a..a4f7d95f92c9c3 100644 --- a/Mathlib/Algebra/BigOperators/Group/Multiset/Basic.lean +++ b/Mathlib/Algebra/BigOperators/Group/Multiset/Basic.lean @@ -93,7 +93,7 @@ theorem prod_hom (s : Multiset M) {F : Type*} [FunLike F M N] theorem prod_hom' (s : Multiset ι) {F : Type*} [FunLike F M N] [MonoidHomClass F M N] (f : F) (g : ι → M) : (s.map fun i => f <| g i).prod = f (s.map g).prod := by - convert (s.map g).prod_hom f + convert! (s.map g).prod_hom f exact (map_map _ _ _).symm @[to_additive] @@ -197,7 +197,7 @@ theorem prod_map_div : (m.map fun i => f i / g i).prod = (m.map f).prod / (m.map @[to_additive] theorem prod_map_zpow {n : ℤ} : (m.map fun i => f i ^ n).prod = (m.map f).prod ^ n := by - convert (m.map f).prod_hom (zpowGroupHom n : G →* G) + convert! (m.map f).prod_hom (zpowGroupHom n : G →* G) simp only [map_map, Function.comp_apply, zpowGroupHom_apply] end DivisionCommMonoid diff --git a/Mathlib/Algebra/BigOperators/Intervals.lean b/Mathlib/Algebra/BigOperators/Intervals.lean index 936f8892405154..ca21305873a8e0 100644 --- a/Mathlib/Algebra/BigOperators/Intervals.lean +++ b/Mathlib/Algebra/BigOperators/Intervals.lean @@ -38,7 +38,7 @@ theorem prod_Ico_add' [AddCommMonoid α] [PartialOrder α] [IsOrderedCancelAddMo theorem prod_Ico_add [AddCommMonoid α] [PartialOrder α] [IsOrderedCancelAddMonoid α] [ExistsAddOfLE α] [LocallyFiniteOrder α] (f : α → M) (a b c : α) : (∏ x ∈ Ico a b, f (c + x)) = ∏ x ∈ Ico (a + c) (b + c), f x := by - convert prod_Ico_add' f a b c using 2 + convert! prod_Ico_add' f a b c using 2 rw [add_comm] @[to_additive (attr := simp)] @@ -256,8 +256,8 @@ lemma Finset.prod_fin_Icc_eq_prod_nat_Icc [CommMonoid α] {n : ℕ} (a b : Fin n lemma Fin.prod_Iic_div [CommGroup M] {n : ℕ} (a : Fin n) (f : Fin (n + 1) → M) : ∏ i ∈ Iic a, (f i.succ / f i.castSucc) = f a.succ / f 0 := by rw [← prod_ite_mem_eq, prod_fin_eq_prod_range] - convert prod_range_div (fun i ↦ if hi : i < n + 1 then f ⟨i, hi⟩ else 1) (a + 1) - using 1 with k hk + convert! prod_range_div (fun i ↦ if hi : i < n + 1 then f ⟨i, hi⟩ else 1) (a + 1) using 1 with k + hk · exact prod_congr_of_eq_on_inter (by grind) (by grind) (by simp_all; grind) · grind @@ -267,7 +267,7 @@ lemma Fin.prod_Icc_div [CommGroup M] {n : ℕ} {a b : Fin n} (hab : a ≤ b) (f : Fin (n + 1) → M) : ∏ i ∈ Icc a b, (f i.succ / f i.castSucc) = f b.succ / f a.castSucc := by rw [prod_fin_Icc_eq_prod_nat_Icc] - convert Finset.prod_Icc_div (Fin.le_def.1 hab) (fun i ↦ if hi : i < n + 1 then f ⟨i, hi⟩ else 1) + convert! Finset.prod_Icc_div (Fin.le_def.1 hab) (fun i ↦ if hi : i < n + 1 then f ⟨i, hi⟩ else 1) · simp_all grind · grind diff --git a/Mathlib/Algebra/BigOperators/Pi.lean b/Mathlib/Algebra/BigOperators/Pi.lean index 5e4db3a80f1724..ef5f7165e1941d 100644 --- a/Mathlib/Algebra/BigOperators/Pi.lean +++ b/Mathlib/Algebra/BigOperators/Pi.lean @@ -71,7 +71,7 @@ theorem pi_eq_sum_univ {ι : Type*} [Fintype ι] [DecidableEq ι] {R : Type*} [N /-- Decomposing `x : ι → R` as a sum along the canonical basis `Pi.single i 1` for `i : ι`. -/ theorem pi_eq_sum_univ' {ι : Type*} [Fintype ι] [DecidableEq ι] {R : Type*} [NonAssocSemiring R] (x : ι → R) : x = ∑ i, (x i) • Pi.single (M := fun _ ↦ R) i 1 := by - convert pi_eq_sum_univ x + convert! pi_eq_sum_univ x aesop section CommSemiring @@ -227,6 +227,6 @@ theorem eqOn_finsetProd {ι α β : Type*} [CommMonoid α] theorem eqOn_fun_finsetProd {ι α β : Type*} [CommMonoid α] {s : Set β} {f f' : ι → β → α} (h : ∀ (i : ι), Set.EqOn (f i) (f' i) s) (v : Finset ι) : Set.EqOn (fun b ↦ ∏ i ∈ v, f i b) (fun b ↦ ∏ i ∈ v, f' i b) s := by - convert eqOn_finsetProd h v <;> simp + convert! eqOn_finsetProd h v <;> simp end EqOn diff --git a/Mathlib/Algebra/BigOperators/Ring/Finset.lean b/Mathlib/Algebra/BigOperators/Ring/Finset.lean index 2ee8d72944e41c..321296c1a7d889 100644 --- a/Mathlib/Algebra/BigOperators/Ring/Finset.lean +++ b/Mathlib/Algebra/BigOperators/Ring/Finset.lean @@ -164,7 +164,7 @@ lemma sum_prod_piFinset [Fintype ι] (s : Finset κ) (g : ι → κ → R) : lemma sum_pow' (s : Finset κ) (f : κ → R) (n : ℕ) : (∑ a ∈ s, f a) ^ n = ∑ p ∈ piFinset fun _i : Fin n ↦ s, ∏ i, f (p i) := by - convert @prod_univ_sum (Fin n) _ _ _ _ _ (fun _i ↦ s) fun _i d ↦ f d; simp + convert! @prod_univ_sum (Fin n) _ _ _ _ _ (fun _i ↦ s) fun _i d ↦ f d; simp /-- The product of `f a + g a` over all of `s` is the sum over the powerset of `s` of the product of `f` over a subset `t` times the product of `g` over the complement of `t` -/ @@ -266,7 +266,7 @@ lemma prod_sub_ordered [LinearOrder ι] (s : Finset ι) (f g : ι → R) : (∏ i ∈ s, f i) - ∑ i ∈ s, g i * (∏ j ∈ s with j < i, (f j - g j)) * ∏ j ∈ s with i < j, f j := by simp only [sub_eq_add_neg] - convert prod_add_ordered s f fun i => -g i + convert! prod_add_ordered s f fun i => -g i simp /-- `∏ i, (1 - f i) = 1 - ∑ i, f i * (∏ j < i, 1 - f j)`. This formula is useful in construction of diff --git a/Mathlib/Algebra/Category/Grp/EpiMono.lean b/Mathlib/Algebra/Category/Grp/EpiMono.lean index b18633df0d6b3a..441946c54d9b03 100644 --- a/Mathlib/Algebra/Category/Grp/EpiMono.lean +++ b/Mathlib/Algebra/Category/Grp/EpiMono.lean @@ -245,7 +245,7 @@ theorem h_apply_fromCoset_nin_range (x : B) (hx : x ∈ f.hom.range) (b : B) (hb (fromCoset ⟨b • ↑f.hom.range, b, rfl⟩) (fromCoset_ne_of_nin_range _ hb) (by simp)] simp only [g_apply_fromCoset, leftCoset_assoc] refine Equiv.swap_apply_of_ne_of_ne (fromCoset_ne_of_nin_range _ fun r => hb ?_) (by simp) - convert Subgroup.mul_mem _ (Subgroup.inv_mem _ hx) r + convert! Subgroup.mul_mem _ (Subgroup.inv_mem _ hx) r rw [← mul_assoc, inv_mul_cancel, one_mul] theorem agree : f.hom.range = { x | h x = g x } := by diff --git a/Mathlib/Algebra/Category/Grp/ZModuleEquivalence.lean b/Mathlib/Algebra/Category/Grp/ZModuleEquivalence.lean index 9fee49a7fe3309..0bd7d8a74a67f4 100644 --- a/Mathlib/Algebra/Category/Grp/ZModuleEquivalence.lean +++ b/Mathlib/Algebra/Category/Grp/ZModuleEquivalence.lean @@ -35,7 +35,7 @@ instance forget₂_addCommGroup_full : (forget₂ (ModuleCat ℤ) AddCommGrpCat. { toFun := f, map_add' := map_add f.hom } (fun n x => by - convert AddMonoidHom.map_zsmul f.hom n x <;> + convert! AddMonoidHom.map_zsmul f.hom n x <;> ext <;> apply int_smul_eq_zsmul), rfl⟩ /-- The forgetful functor from `ℤ` modules to `AddCommGrpCat` is essentially surjective. -/ diff --git a/Mathlib/Algebra/Category/ModuleCat/Basic.lean b/Mathlib/Algebra/Category/ModuleCat/Basic.lean index d4d14bdef164ea..81478929dde94b 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Basic.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Basic.lean @@ -9,6 +9,7 @@ public import Mathlib.Algebra.Category.ModuleCat.Semi public import Mathlib.Algebra.Category.Grp.Preadditive public import Mathlib.CategoryTheory.Linear.Basic public import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor +public import Mathlib.LinearAlgebra.BilinearMap /-! # The category of `R`-modules @@ -386,6 +387,15 @@ lemma isZero_iff_subsingleton : IsZero M ↔ Subsingleton M where lemma isZero_of_iff_subsingleton {M : Type*} [AddCommGroup M] [Module R M] : IsZero (of R M) ↔ Subsingleton M := isZero_iff_subsingleton +@[simp] +lemma ofHom_zero {M N : Type v} [AddCommGroup M] [Module R M] + [AddCommGroup N] [Module R N] : ModuleCat.ofHom (0 : M →ₗ[R] N) = 0 := rfl + +@[simp] +lemma ofHom_add {M N : Type v} [AddCommGroup M] [Module R M] + [AddCommGroup N] [Module R N] (f g : M →ₗ[R] N) : + ModuleCat.ofHom (f + g) = ModuleCat.ofHom f + ModuleCat.ofHom g := rfl + end AddCommGroup section SMul @@ -456,6 +466,9 @@ variable {S : Type u} [CommRing S] instance : Linear S (ModuleCat.{v} S) := ModuleCat.Algebra.instLinear +lemma lsmul_eq_smul_id (M : ModuleCat.{v} S) (s : S) : + ModuleCat.ofHom (LinearMap.lsmul S M s) = s • 𝟙 M := rfl + variable {X Y X' Y' : ModuleCat.{v} S} set_option backward.privateInPublic true in diff --git a/Mathlib/Algebra/Category/ModuleCat/Descent.lean b/Mathlib/Algebra/Category/ModuleCat/Descent.lean index b63d64b4b6aeef..f5bb399eb354fd 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Descent.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Descent.lean @@ -60,7 +60,8 @@ def comonadicExtendScalars (hf : f.FaithfullyFlat) : ComonadicLeftAdjoint (extendScalars f) := by have := preservesFiniteLimits_extendScalars_of_flat hf.flat have := reflectsIsomorphisms_extendScalars_of_faithfullyFlat hf - convert Comonad.comonadicOfHasPreservesFSplitEqualizersOfReflectsIsomorphisms + convert! + Comonad.comonadicOfHasPreservesFSplitEqualizersOfReflectsIsomorphisms (extendRestrictScalarsAdj f) · exact ⟨inferInstance⟩ · exact ⟨inferInstance⟩ diff --git a/Mathlib/Algebra/Category/ModuleCat/EpiMono.lean b/Mathlib/Algebra/Category/ModuleCat/EpiMono.lean index aa4917794699a3..a9a88bee1e05ce 100644 --- a/Mathlib/Algebra/Category/ModuleCat/EpiMono.lean +++ b/Mathlib/Algebra/Category/ModuleCat/EpiMono.lean @@ -38,14 +38,14 @@ theorem range_eq_top_of_epi [Epi f] : LinearMap.range f.hom = ⊤ := theorem mono_iff_ker_eq_bot : Mono f ↔ LinearMap.ker f.hom = ⊥ := ⟨fun _ => ker_eq_bot_of_mono _, fun hf => - ConcreteCategory.mono_of_injective _ <| by convert LinearMap.ker_eq_bot.1 hf⟩ + ConcreteCategory.mono_of_injective _ <| by convert! LinearMap.ker_eq_bot.1 hf⟩ theorem mono_iff_injective : Mono f ↔ Function.Injective f := by rw [mono_iff_ker_eq_bot, LinearMap.ker_eq_bot] theorem epi_iff_range_eq_top : Epi f ↔ LinearMap.range f.hom = ⊤ := ⟨fun _ => range_eq_top_of_epi _, fun hf => - ConcreteCategory.epi_of_surjective _ <| by convert LinearMap.range_eq_top.1 hf⟩ + ConcreteCategory.epi_of_surjective _ <| by convert! LinearMap.range_eq_top.1 hf⟩ theorem epi_iff_surjective : Epi f ↔ Function.Surjective f := by rw [epi_iff_range_eq_top, LinearMap.range_eq_top] diff --git a/Mathlib/Algebra/Category/ModuleCat/Ext/Basic.lean b/Mathlib/Algebra/Category/ModuleCat/Ext/Basic.lean new file mode 100644 index 00000000000000..ac503df5cf226f --- /dev/null +++ b/Mathlib/Algebra/Category/ModuleCat/Ext/Basic.lean @@ -0,0 +1,53 @@ +/- +Copyright (c) 2026 Nailin Guan. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Nailin Guan +-/ + +module + +public import Mathlib.Algebra.Category.Grp.Zero +public import Mathlib.Algebra.Category.ModuleCat.Ext.HasExt +public import Mathlib.Algebra.Homology.DerivedCategory.Ext.Linear +public import Mathlib.RingTheory.Ideal.Maps + +/-! + +# Some basic lemmas for manipulating `Ext` over `ModuleCat` + +-/ + +@[expose] public section + +universe v u + +open LinearMap CategoryTheory Limits + +variable {R : Type u} [CommRing R] + +variable {M N : Type v} [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N] + +namespace CategoryTheory.Abelian + +variable [Small.{v} R] {M N : ModuleCat.{v} R} + +/-- If `r • N = 0`, then `r • 𝟙 M` induces the zero endomorphism on `Ext M N n`. -/ +lemma Ext.postcomp_smul_id_eq_zero_of_mem_annihilator {r : R} (mem_ann : r ∈ Module.annihilator R N) + (n : ℕ) : AddCommGrpCat.ofHom ((Ext.mk₀ (r • 𝟙 M)).postcomp N (add_zero n)) = 0 := by + ext h + have : r • 𝟙 N = 0 := by + simp [← ModuleCat.lsmul_eq_smul_id, Module.mem_annihilator_iff_lsmul_eq_zero.mp mem_ann] + have smul_eq : r • h = (Ext.mk₀ (r • 𝟙 N)).comp h (zero_add n) := by simp [Ext.mk₀_smul] + simp [Ext.mk₀_smul, this, smul_eq] + +/-- `r • 𝟙 M` induces a monomorphism in `Ext M N n` if and only if scalar multiplication by `r` +is faithful on `Ext M N n`. -/ +lemma Ext.postcomp_smul_id_mono_iff (r : R) (i : ℕ) : + Mono (AddCommGrpCat.ofHom ((Ext.mk₀ (r • 𝟙 M)).postcomp N (add_zero i))) ↔ + IsSMulRegular (Ext N M i) r := by + simp only [IsSMulRegular, AddCommGrpCat.mono_iff_injective] + congr! + ext + simp [Ext.mk₀_smul] + +end CategoryTheory.Abelian diff --git a/Mathlib/Algebra/Category/ModuleCat/Free.lean b/Mathlib/Algebra/Category/ModuleCat/Free.lean index 8db2775319996f..7b4c01add2785e 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Free.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Free.lean @@ -84,7 +84,7 @@ theorem linearIndependent_shortExact {w : ι' → S.X₃} (hw : LinearIndependen LinearIndependent R (Sum.elim (S.f ∘ v) (S.g.hom.toFun.invFun ∘ w)) := by apply linearIndependent_leftExact hS'.exact hv _ hS'.mono_f rfl dsimp - convert hw + convert! hw ext apply Function.rightInverse_invFun ((epi_iff_surjective _).mp hS'.epi_g) @@ -144,7 +144,7 @@ theorem span_rightExact {w : ι' → S.X₃} (hv : ⊤ ≤ span R (range v)) ⊤ ≤ span R (range (Sum.elim (S.f ∘ v) (S.g.hom.toFun.invFun ∘ w))) := by refine span_exact hS ?_ hv ?_ · simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, Sum.elim_comp_inl] - · convert hw + · convert! hw simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, Sum.elim_comp_inr] rw [ModuleCat.epi_iff_surjective] at hE rw [← Function.comp_assoc, Function.RightInverse.comp_eq_id (Function.rightInverse_invFun hE), diff --git a/Mathlib/Algebra/Category/ModuleCat/Sheaf/PullbackFree.lean b/Mathlib/Algebra/Category/ModuleCat/Sheaf/PullbackFree.lean index c4fecc4bd5cd51..8fb91292c0d3f0 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Sheaf/PullbackFree.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Sheaf/PullbackFree.lean @@ -107,7 +107,7 @@ instance [F.Final] : IsIso (pullbackObjUnitToUnit φ) := by intro M rw [← ((pullbackPushforwardAdjunction.{u} φ).homEquiv _ _).bijective.of_comp_iff', ← (unitHomEquiv _).bijective.of_comp_iff'] - convert (bijective_pushforwardSections φ M).comp (unitHomEquiv _).bijective + convert! (bijective_pushforwardSections φ M).comp (unitHomEquiv _).bijective ext f : 1 dsimp rw [pushforwardSections_unitHomEquiv, EmbeddingLike.apply_eq_iff_eq, diff --git a/Mathlib/Algebra/Category/ModuleCat/Subobject.lean b/Mathlib/Algebra/Category/ModuleCat/Subobject.lean index 81560275d7964c..01e1f412cfaecc 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Subobject.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Subobject.lean @@ -47,8 +47,9 @@ noncomputable def subobjectModule : Subobject M ≃o Submodule R M := · ext x rfl) left_inv := fun N => by - convert congr_arg LinearMap.range (ModuleCat.hom_ext_iff.mp - (underlyingIso_arrow (ofHom N.subtype))) using 1 + convert! + congr_arg LinearMap.range + (ModuleCat.hom_ext_iff.mp (underlyingIso_arrow (ofHom N.subtype))) using 1 · have : (underlyingIso (ofHom N.subtype)).inv = ofHom (underlyingIso (ofHom N.subtype)).symm.toLinearEquiv.toLinearMap := by @@ -58,7 +59,7 @@ noncomputable def subobjectModule : Subobject M ≃o Submodule R M := · exact (Submodule.range_subtype _).symm map_rel_iff' := fun {S T} => by refine ⟨fun h => ?_, fun h => mk_le_mk_of_comm (↟(Submodule.inclusion h)) rfl⟩ - convert LinearMap.range_comp_le_range (ofMkLEMk _ _ h).hom (ofHom T.subtype).hom + convert! LinearMap.range_comp_le_range (ofMkLEMk _ _ h).hom (ofHom T.subtype).hom · rw [← hom_comp, ofMkLEMk_comp] exact (Submodule.range_subtype _).symm · exact (Submodule.range_subtype _).symm } diff --git a/Mathlib/Algebra/Category/ModuleCat/Topology/Basic.lean b/Mathlib/Algebra/Category/ModuleCat/Topology/Basic.lean index b628050da40e5a..15fa2d48b8b7e6 100644 --- a/Mathlib/Algebra/Category/ModuleCat/Topology/Basic.lean +++ b/Mathlib/Algebra/Category/ModuleCat/Topology/Basic.lean @@ -52,7 +52,7 @@ attribute [instance] topologicalSpace isTopologicalAddGroup continuousSMul /-- Make an object in `TopModuleCat R` from an unbundled topological module. -/ abbrev of (M : Type v) [AddCommGroup M] [Module R M] [TopologicalSpace M] [ContinuousAdd M] [ContinuousSMul R M] : TopModuleCat R := - have : ContinuousNeg M := ⟨by convert continuous_const_smul (-1 : R) (T := M); ext; simp⟩ + have : ContinuousNeg M := ⟨by convert! continuous_const_smul (-1 : R) (T := M); ext; simp⟩ have : IsTopologicalAddGroup M := ⟨⟩ ⟨.of R M⟩ @@ -447,7 +447,7 @@ def freeAdj : free.{max v u} R ⊣ forget₂ (TopModuleCat.{max v u} R) TopCat.{ refine sInf_le ⟨continuousSMul_induced (Finsupp.lift _ R X id), continuousAdd_induced (Finsupp.lift _ R X id), ?_⟩ rw [coinduced_le_iff_le_induced, induced_compose] - convert induced_id.symm.le + convert! induced_id.symm.le ext simp [coe_freeObj]⟩, naturality {X Y} f := by diff --git a/Mathlib/Algebra/Category/Ring/FilteredColimits.lean b/Mathlib/Algebra/Category/Ring/FilteredColimits.lean index 6d16674327f61a..5c8c249872fc8f 100644 --- a/Mathlib/Algebra/Category/Ring/FilteredColimits.lean +++ b/Mathlib/Algebra/Category/Ring/FilteredColimits.lean @@ -376,6 +376,7 @@ protected lemma nontrivial {F : J ⥤ CommRingCat.{v}} [IsFilteredOrEmpty J] (Types.FilteredColimit.isColimit_eq_iff' (isColimitOfPreserves (forget _) hc) _ _).mp h exact zero_ne_one (((F.map f).hom.map_zero.symm.trans e).trans (F.map f).hom.map_one) +set_option linter.overlappingInstances false in omit [IsFiltered J] in instance {F : J ⥤ CommRingCat.{v}} [IsFilteredOrEmpty J] [HasColimit F] [∀ i, Nontrivial (F.obj i)] : Nontrivial ↑(Limits.colimit F) := diff --git a/Mathlib/Algebra/Category/Ring/Instances.lean b/Mathlib/Algebra/Category/Ring/Instances.lean index c84965f0c2bddb..f7bab1f53e7db6 100644 --- a/Mathlib/Algebra/Category/Ring/Instances.lean +++ b/Mathlib/Algebra/Category/Ring/Instances.lean @@ -48,7 +48,7 @@ theorem CommRingCat.isLocalHom_comp {R S T : CommRingCat} (f : R ⟶ S) (g : S theorem isLocalHom_of_iso {R S : CommRingCat} (f : R ≅ S) : IsLocalHom f.hom.hom := { map_nonunit := fun a ha => by - convert f.inv.hom.isUnit_map ha + convert! f.inv.hom.isUnit_map ha simp } -- see Note [lower instance priority] diff --git a/Mathlib/Algebra/Category/Ring/Topology.lean b/Mathlib/Algebra/Category/Ring/Topology.lean index aa7885d7d76426..0091d90b2d3289 100644 --- a/Mathlib/Algebra/Category/Ring/Topology.lean +++ b/Mathlib/Algebra/Category/Ring/Topology.lean @@ -97,7 +97,7 @@ lemma isClosedEmbedding_precomp_of_surjective refine ⟨isEmbedding_precomp_of_surjective f hf, ?_⟩ have : IsClosed (⋂ i : RingHom.ker f.hom, { f : A ⟶ R | f i = 0 }) := isClosed_iInter fun x ↦ (isClosed_singleton (x := 0)).preimage (continuous_apply (R := R) x.1) - convert this + convert! this ext x simp only [Set.mem_range, Set.mem_iInter, Set.mem_setOf_eq, Subtype.forall, RingHom.mem_ker] constructor @@ -130,9 +130,11 @@ lemma isClosedEmbedding_hom [IsTopologicalRing R] [T1Space R] : let f : CommRingCat.of (MvPolynomial A (⊥_ CommRingCat)) ⟶ A := CommRingCat.ofHom (MvPolynomial.eval₂Hom (initial.to A).hom id) have : Function.Surjective f := Function.LeftInverse.surjective (g := .X) fun x ↦ by simp [f] - convert ((mvPolynomialHomeomorph A R (.of _)).trans - (.uniqueProd (⊥_ CommRingCat ⟶ R) _)).isClosedEmbedding.comp - (isClosedEmbedding_precomp_of_surjective f this) using 2 with g + convert! + ((mvPolynomialHomeomorph A R (.of _)).trans + (.uniqueProd (⊥_ CommRingCat ⟶ R) _)).isClosedEmbedding.comp + (isClosedEmbedding_precomp_of_surjective f this) using + 2 with g ext x simp +instances [f] @@ -177,8 +179,9 @@ lemma isEmbedding_pushout [IsTopologicalRing R] (φ : A ⟶ B) (ψ : A ⟶ C) : ((isEmbedding_graph continuous_id).prodMap Homeomorph.sumArrowHomeomorphProdArrow.isEmbedding) have H := (mvPolynomialHomeomorph B R A).symm.isEmbedding.prodMap (mvPolynomialHomeomorph C R A).symm.isEmbedding - convert ((H.comp hF).comp (mvPolynomialHomeomorph _ R A).isEmbedding).comp - (isEmbedding_precomp_of_surjective (R := R) fBC hfBC) + convert! + ((H.comp hF).comp (mvPolynomialHomeomorph _ R A).isEmbedding).comp + (isEmbedding_precomp_of_surjective (R := R) fBC hfBC) have (s : _) : (pushout.inr φ ψ).hom (ψ.hom s) = (pushout.inl φ ψ).hom (φ.hom s) := congr($(pushout.condition (f := φ)).hom s).symm ext f s <;> simp [fB, fC, fBC, PB, PC, PBC, F, this] diff --git a/Mathlib/Algebra/Category/Ring/Under/Basic.lean b/Mathlib/Algebra/Category/Ring/Under/Basic.lean index 35373fdd03ca0d..0738186265fa2a 100644 --- a/Mathlib/Algebra/Category/Ring/Under/Basic.lean +++ b/Mathlib/Algebra/Category/Ring/Under/Basic.lean @@ -80,7 +80,7 @@ def toUnder {A B : Type u} [CommRing A] [CommRing B] [Algebra R A] [Algebra R B] @[simp] lemma toUnder_right {A B : Type u} [CommRing A] [CommRing B] [Algebra R A] [Algebra R B] (f : A →ₐ[R] B) (a : A) : - f.toUnder.right a = f a := + Under.Hom.right f.toUnder a = f a := rfl @[simp] @@ -130,7 +130,7 @@ variable [Algebra R S] variable (R S) in /-- The base change functor `A ↦ S ⊗[R] A`. -/ -@[simps! map_right] +@[simps! obj_right map_right] def tensorProd : Under R ⥤ Under S where obj A := mkUnder S (S ⊗[R] A) map f := Algebra.TensorProduct.map (AlgHom.id S S) (toAlgHom f) |>.toUnder diff --git a/Mathlib/Algebra/Category/Ring/Under/Property.lean b/Mathlib/Algebra/Category/Ring/Under/Property.lean index 39e77c4dc39754..4bbb44166ea2f4 100644 --- a/Mathlib/Algebra/Category/Ring/Under/Property.lean +++ b/Mathlib/Algebra/Category/Ring/Under/Property.lean @@ -8,6 +8,7 @@ module public import Mathlib.Algebra.Category.Ring.Under.Limits public import Mathlib.CategoryTheory.Limits.MorphismProperty public import Mathlib.CategoryTheory.ObjectProperty.FiniteProducts +public import Mathlib.CategoryTheory.ConcreteCategory.EpiMono /-! # Properties of `P.Under ⊤ R` for `R : CommRingCat` @@ -19,6 +20,8 @@ In this file we translate ring theoretic properties of a property of ring homomo - `CommRingCat.Under.hasFiniteLimits`: If `P` is stable under finite products and equalizers, `P.Under ⊤ R` has finite limits. +- `RingHom.HasStableEqualizers.preservesFiniteLimits_pushout`: If `P` has stable equalizers, + base change along arbitrary morphisms preserve finite limits. -/ @[expose] public section @@ -80,6 +83,18 @@ lemma RingHom.HasFiniteProducts.hasFiniteProducts (hQi : RespectsIso Q) (hQp : H have := hQp.createsFiniteProductsForget hQi R exact CategoryTheory.hasLimit_of_created D (Under.forget _ _ R) +lemma RingHom.HasFiniteProducts.preservesFiniteProducts_pushout (hQi : RingHom.RespectsIso Q) + (hQp : RingHom.HasFiniteProducts Q) [(toMorphismProperty Q).IsStableUnderCobaseChange] + {R S : CommRingCat.{u}} (f : R ⟶ S) : + PreservesFiniteProducts (Under.pushout (toMorphismProperty Q) ⊤ f) := by + have := hQp.createsFiniteProductsForget hQi R + refine ⟨fun n ↦ ⟨fun {K} ↦ ?_⟩⟩ + have : PreservesLimit K (Under.pushout (toMorphismProperty Q) ⊤ f ⋙ + Under.forget (toMorphismProperty Q) ⊤ S) := by + rw [preservesLimit_iff_of_natIso _ (Under.pushoutCompForgetIso _)] + infer_instance + exact preservesLimit_of_reflects_of_preserves _ (MorphismProperty.Under.forget _ ⊤ S) + /-- If `Q` is stable under equalizers, the inclusion from the subcategory of `Under R` defined by `Q` creates equalizers. -/ @[implicit_reducible] @@ -117,3 +132,74 @@ lemma Under.hasFiniteLimits (hQi : RingHom.RespectsIso Q) hasFiniteLimits_of_hasEqualizers_and_finite_products end CommRingCat + +variable (P : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop) + +open RingHom + +variable {P} + +lemma CommRingCat.preservesLimit_parallelPair_tensorProd_iff_tensorEqualizer_bijective + {R S : CommRingCat.{u}} [Algebra R S] {A B : Under R} {f g : A ⟶ B} : + PreservesLimit (parallelPair f g) (tensorProd R S) ↔ + Function.Bijective ((toAlgHom f).tensorEqualizer R S (toAlgHom g)) := by + let c : Fork f g := Under.equalizerFork f g + let hc : IsLimit c := Under.equalizerForkIsLimit f g + let ι : R.mkUnder (AlgHom.equalizer (toAlgHom f) (toAlgHom g)) ⟶ A := + (AlgHom.equalizer (toAlgHom f) (toAlgHom g)).val.toUnder + let h' := (R.tensorProd S).map ι + have w' : h' ≫ (tensorProd R S).map f = h' ≫ (tensorProd R S).map g := by + simpa using congr((R.tensorProd S).map $(CommRingCat.Under.equalizer_comp f g)) + let e : IsLimit ((R.tensorProd S).mapCone c) ≃ IsLimit (Fork.ofι h' w') := + isLimitMapConeForkEquiv (tensorProd R S) (Under.equalizer_comp f g) + rw [preservesLimit_iff_isLimit_mapCone hc, e.nonempty_congr, + (Under.equalizerForkIsLimit _ _).nonempty_isLimit_iff_isIso_lift] + have heq : (Under.equalizerForkIsLimit _ _).lift (Fork.ofι h' w') = + (AlgHom.tensorEqualizer S S (toAlgHom f) (toAlgHom g)).toUnder ≫ + Under.homMk (CommRingCat.ofHom (.id _)) := by + refine Fork.IsLimit.hom_ext (Under.equalizerForkIsLimit _ _) ?_ + rw [Fork.IsLimit.lift_ι] + ext : 2 + dsimp + ext x <;> rfl + rw [heq, ← isIso_iff_of_reflects_iso _ (CategoryTheory.Under.forget S), + ConcreteCategory.isIso_iff_bijective] + rfl + +lemma RingHom.HasStableEqualizers.preservesLimit_parallelPair_tensorProd + (hPse : HasStableEqualizers P) {R S : CommRingCat.{u}} [Algebra R S] + {A B : Under R} (f g : A ⟶ B) (hA : P A.hom.hom) (hB : P B.hom.hom) : + PreservesLimit (parallelPair f g) (CommRingCat.tensorProd R S) := by + rw [CommRingCat.preservesLimit_parallelPair_tensorProd_iff_tensorEqualizer_bijective] + exact hPse _ _ hA hB + +lemma RingHom.HasStableEqualizers.preservesEqualizers_pushout (hPi : RespectsIso P) + (hPe : HasEqualizers P) (hPse : HasStableEqualizers P) + [(toMorphismProperty P).IsStableUnderCobaseChange] {R S : CommRingCat.{u}} (f : R ⟶ S) : + PreservesLimitsOfShape WalkingParallelPair (Under.pushout (toMorphismProperty P) ⊤ f) := by + refine ⟨fun {K} ↦ ?_⟩ + have := hPe.createsLimitsWalkingParallelPair hPi R + algebraize [f.hom] + have : PreservesLimit (K ⋙ Under.forget (toMorphismProperty P) ⊤ R) + (CategoryTheory.Under.pushout f) := by + rw [← CommRingCat.ofHom_hom f, + ← preservesLimit_iff_of_natIso _ (CommRingCat.tensorProdIsoPushout R S), + ← preservesLimit_iff_of_iso_diagram _ (diagramIsoParallelPair _).symm] + exact hPse.preservesLimit_parallelPair_tensorProd _ _ ((K.obj _).prop) ((K.obj _).prop) + have : PreservesLimit K (Under.pushout (toMorphismProperty P) ⊤ f ⋙ + Under.forget (toMorphismProperty P) ⊤ S) := by + rw [preservesLimit_iff_of_natIso _ (Under.pushoutCompForgetIso _)] + infer_instance + exact preservesLimit_of_reflects_of_preserves _ (Under.forget _ ⊤ S) + +/-- If `P` is a property of ring homs that is stable under finite products and +equalizers, and the latter are preserved by arbitrary base change, +pushout along any ring homomorphism preserves finite limits. -/ +lemma RingHom.HasStableEqualizers.preservesFiniteLimits_pushout (hPi : RingHom.RespectsIso P) + (hPp : HasFiniteProducts P) (hPe : HasEqualizers P) (hPse : HasStableEqualizers P) + [(toMorphismProperty P).IsStableUnderCobaseChange] {R S : CommRingCat.{u}} (f : R ⟶ S) : + PreservesFiniteLimits (Under.pushout (toMorphismProperty P) ⊤ f) := + have := hPp.preservesFiniteProducts_pushout hPi f + have := hPse.preservesEqualizers_pushout hPi hPe f + have := CommRingCat.Under.hasFiniteLimits hPi hPp hPe + preservesFiniteLimits_of_preservesEqualizers_and_finiteProducts _ diff --git a/Mathlib/Algebra/CharP/Basic.lean b/Mathlib/Algebra/CharP/Basic.lean index 6cc0ef06bd00f9..41e04d7a60168d 100644 --- a/Mathlib/Algebra/CharP/Basic.lean +++ b/Mathlib/Algebra/CharP/Basic.lean @@ -145,7 +145,7 @@ instance Nat.lcm.charP [CharP S q] : CharP (R × S) (Nat.lcm p q) where /-- The characteristic of the product of two rings of the same characteristic is the same as the characteristic of the rings -/ instance Prod.charP [CharP S p] : CharP (R × S) p := by - convert Nat.lcm.charP R S p p; simp + convert! Nat.lcm.charP R S p p; simp instance Prod.charZero_of_left [CharZero R] : CharZero (R × S) where cast_injective _ _ h := CharZero.cast_injective congr(Prod.fst $h) diff --git a/Mathlib/Algebra/CharP/Invertible.lean b/Mathlib/Algebra/CharP/Invertible.lean index 1ffa05c0ca238b..7b36b94527fc62 100644 --- a/Mathlib/Algebra/CharP/Invertible.lean +++ b/Mathlib/Algebra/CharP/Invertible.lean @@ -66,7 +66,7 @@ def invertibleOfCoprime {n : ℕ} (h : n.Coprime p) : theorem invOf_eq_of_coprime {n : ℕ} [Invertible (n : R)] (h : n.Coprime p) : ⅟(n : R) = n.gcdA p := by letI : Invertible (n : R) := invertibleOfCoprime h - convert (rfl : ⅟(n : R) = _) + convert! (rfl : ⅟(n : R) = _) theorem CharP.isUnit_natCast_iff {n : ℕ} (hp : p.Prime) : IsUnit (n : R) ↔ ¬p ∣ n where mp h := by diff --git a/Mathlib/Algebra/CharP/MixedCharZero.lean b/Mathlib/Algebra/CharP/MixedCharZero.lean index 9e2ea58e82ce6f..6d184970dc9fdb 100644 --- a/Mathlib/Algebra/CharP/MixedCharZero.lean +++ b/Mathlib/Algebra/CharP/MixedCharZero.lean @@ -126,10 +126,10 @@ lemma reduce_to_maximal_ideal {p : ℕ} (hp : Nat.Prime p) : · exact hM_max · cases CharP.exists (R ⧸ M) with | intro r hr => - convert hr + convert! hr have r_dvd_p : r ∣ p := by rw [← CharP.cast_eq_zero_iff (R ⧸ M) r p] - convert congr_arg (Ideal.Quotient.factor hM_ge) (CharP.cast_eq_zero (R ⧸ I) p) + convert! congr_arg (Ideal.Quotient.factor hM_ge) (CharP.cast_eq_zero (R ⧸ I) p) symm apply (Nat.Prime.eq_one_or_self_of_dvd hp r r_dvd_p).resolve_left exact CharP.char_ne_one (R ⧸ M) r diff --git a/Mathlib/Algebra/CharP/Reduced.lean b/Mathlib/Algebra/CharP/Reduced.lean index d6155a4a33388f..73cbf0284089b8 100644 --- a/Mathlib/Algebra/CharP/Reduced.lean +++ b/Mathlib/Algebra/CharP/Reduced.lean @@ -45,5 +45,5 @@ variable {R : Type*} [CommRing R] [IsReduced R] theorem ExpChar.pow_prime_pow_mul_eq_one_iff (p k m : ℕ) [ExpChar R p] (x : R) : x ^ (p ^ k * m) = 1 ↔ x ^ m = 1 := by rw [pow_mul'] - convert ← (iterateFrobenius_inj R p k).eq_iff + convert! ← (iterateFrobenius_inj R p k).eq_iff apply map_one diff --git a/Mathlib/Algebra/Colimit/DirectLimit.lean b/Mathlib/Algebra/Colimit/DirectLimit.lean index 5c33f2bbbe1238..bab0b703504194 100644 --- a/Mathlib/Algebra/Colimit/DirectLimit.lean +++ b/Mathlib/Algebra/Colimit/DirectLimit.lean @@ -833,8 +833,8 @@ end NonUnitalStarRing namespace Algebra variable [CommSemiring R] -variable [∀ i, Semiring (G i)] [∀ i j h, RingHomClass (T h) (G i) (G j)] -variable [∀ i, Algebra R (G i)] [∀ i j h, AlgHomClass (T h) R (G i) (G j)] +variable [∀ i, Semiring (G i)] [∀ i, Algebra R (G i)] +variable [∀ i j h, AlgHomClass (T h) R (G i) (G j)] variable [Nonempty ι] variable (G f) in diff --git a/Mathlib/Algebra/Colimit/Module.lean b/Mathlib/Algebra/Colimit/Module.lean index 2d4596841a34ad..55ff912d75383f 100644 --- a/Mathlib/Algebra/Colimit/Module.lean +++ b/Mathlib/Algebra/Colimit/Module.lean @@ -271,7 +271,7 @@ theorem exists_eq_of_of_eq {i x y} (h : of R ι G f i x = of R ι G f i y) : bigger module in the directed system. -/ theorem of.zero_exact {i x} (H : of R ι G f i x = 0) : ∃ j hij, f i j hij x = (0 : G j) := by - convert exists_eq_of_of_eq (H.trans (map_zero <| _).symm) + convert! exists_eq_of_of_eq (H.trans (map_zero <| _).symm) rw [map_zero] end DirectLimit diff --git a/Mathlib/Algebra/ContinuedFractions/Computation/Approximations.lean b/Mathlib/Algebra/ContinuedFractions/Computation/Approximations.lean index e98e45c0fc96ea..aa95a87fc5f321 100644 --- a/Mathlib/Algebra/ContinuedFractions/Computation/Approximations.lean +++ b/Mathlib/Algebra/ContinuedFractions/Computation/Approximations.lean @@ -366,8 +366,14 @@ theorem sub_convs_eq {ifp : IntFractPair K} have : ¬g.TerminatedAt n' := (not_congr of_terminatedAt_n_iff_succ_nth_intFractPair_stream_eq_none).2 this exact Or.inr this - have determinant_eq : pA * B - pB * A = (-1) ^ n := - (SimpContFract.of v).determinant_aux n_eq_zero_or_not_terminatedAt_pred_n + have determinant_eq : pA * B - pB * A = (-1) ^ n := by + match hn : n with + | 0 => subst n; simp [pA, pB, A, B, pred_conts, conts] + | n' + 1 => + subst n + simp only [succ_ne_zero, false_or] at n_eq_zero_or_not_terminatedAt_pred_n + rw [add_tsub_cancel_right] at n_eq_zero_or_not_terminatedAt_pred_n + exact (SimpContFract.of v).determinant n_eq_zero_or_not_terminatedAt_pred_n -- now all we got to do is to rewrite this equality in our goal and re-arrange terms; -- however, for this, we first have to derive quite a few tedious inequalities. have pB_ineq : (fib n : K) ≤ pB := diff --git a/Mathlib/Algebra/ContinuedFractions/Determinant.lean b/Mathlib/Algebra/ContinuedFractions/Determinant.lean index a543d9e0e8e5a4..1f66d5645ac9eb 100644 --- a/Mathlib/Algebra/ContinuedFractions/Determinant.lean +++ b/Mathlib/Algebra/ContinuedFractions/Determinant.lean @@ -5,22 +5,16 @@ Authors: Kevin Kappelmann -/ module +public import Mathlib.Algebra.BigOperators.Group.Finset.Basic public import Mathlib.Algebra.ContinuedFractions.ContinuantsRecurrence public import Mathlib.Algebra.ContinuedFractions.TerminatedStable public import Mathlib.Tactic.Ring /-! -# Determinant Formula for Simple Continued Fraction +# Determinant Formula for Generalized Continued Fraction -## Summary - -We derive the so-called *determinant formula* for `SimpContFract`: -`Aₙ * Bₙ₊₁ - Bₙ * Aₙ₊₁ = (-1)^(n + 1)`. - -## TODO - -Generalize this for `GenContFract` version: -`Aₙ * Bₙ₊₁ - Bₙ * Aₙ₊₁ = (-a₀) * (-a₁) * .. * (-aₙ₊₁)`. +We derive the so-called *determinant formula* for `GenContFract`: +`Aₙ * Bₙ₊₁ - Bₙ * Aₙ₊₁ = (-a₀) * (-a₁) * .. * (-aₙ)`. ## References @@ -32,19 +26,20 @@ public section open GenContFract -namespace SimpContFract +variable {K : Type*} [Field K] + +namespace GenContFract -variable {K : Type*} [Field K] {s : SimpContFract K} {n : ℕ} +variable {g : GenContFract K} {n : ℕ} -theorem determinant_aux (hyp : n = 0 ∨ ¬(↑s : GenContFract K).TerminatedAt (n - 1)) : - ((↑s : GenContFract K).contsAux n).a * ((↑s : GenContFract K).contsAux (n + 1)).b - - ((↑s : GenContFract K).contsAux n).b * ((↑s : GenContFract K).contsAux (n + 1)).a = - (-1) ^ n := by +private theorem determinant_aux (hyp : n = 0 ∨ ¬g.TerminatedAt (n - 1)) : + (g.contsAux n).a * (g.contsAux (n + 1)).b - + (g.contsAux n).b * (g.contsAux (n + 1)).a = + ∏ i ∈ Finset.range n, - (g.partNums.get? i).getD 0 := by induction n with | zero => simp [contsAux] | succ n IH => -- set up some shorthand notation - let g := (↑s : GenContFract K) let conts := contsAux g (n + 2) set pred_conts := contsAux g (n + 1) with pred_conts_eq set ppred_conts := contsAux g n with ppred_conts_eq @@ -53,23 +48,45 @@ theorem determinant_aux (hyp : n = 0 ∨ ¬(↑s : GenContFract K).TerminatedAt let ppA := ppred_conts.a let ppB := ppred_conts.b -- let's change the goal to something more readable - change pA * conts.b - pB * conts.a = (-1) ^ (n + 1) + change pA * conts.b - pB * conts.a = ∏ i ∈ Finset.range (n + 1), -(g.partNums.get? i).getD 0 have not_terminated_at_n : ¬TerminatedAt g n := Or.resolve_left hyp n.succ_ne_zero obtain ⟨gp, s_nth_eq⟩ : ∃ gp, g.s.get? n = some gp := Option.ne_none_iff_exists'.1 not_terminated_at_n -- unfold the recurrence relation for `conts` once and simplify to derive the following - suffices pA * (ppB + gp.b * pB) - pB * (ppA + gp.b * pA) = (-1) ^ (n + 1) by - simp only [conts, contsAux_recurrence s_nth_eq ppred_conts_eq pred_conts_eq] - have gp_a_eq_one : gp.a = 1 := s.property _ _ (partNum_eq_s_a s_nth_eq) - rw [gp_a_eq_one, this.symm] + suffices ppA * pB - ppB * pA = ∏ i ∈ Finset.range n, - (g.partNums.get? i).getD 0 by + rw [Finset.prod_range_succ, ← this, partNum_eq_s_a s_nth_eq, Option.getD_some] + subst conts + rw [contsAux_recurrence s_nth_eq ppred_conts_eq pred_conts_eq] ring - suffices ppA * pB - ppB * pA = (-1) ^ n by grind exact IH <| Or.inr <| mt (terminated_stable <| n.sub_le 1) not_terminated_at_n -/-- The determinant formula `Aₙ * Bₙ₊₁ - Bₙ * Aₙ₊₁ = (-1)^(n + 1)`. -/ +/-- The determinant formula `Aₙ * Bₙ₊₁ - Bₙ * Aₙ₊₁ = (-a₀) * (-a₁) * .. * (-aₙ)`. -/ +theorem determinant : + g.nums n * g.dens (n + 1) - g.dens n * g.nums (n + 1) = + ∏ i ∈ Finset.range (n + 1), - (g.partNums.get? i).getD 0 := by + rcases em <| TerminatedAt g n with terminatedAt_n | not_terminatedAt_n + · rw [dens_stable_of_terminated n.le_succ terminatedAt_n, + nums_stable_of_terminated n.le_succ terminatedAt_n, Finset.prod_range_succ, + partNum_none_iff_s_none.mpr terminatedAt_n] + grind + · exact determinant_aux <| Or.inr <| not_terminatedAt_n +end GenContFract + +namespace SimpContFract + +variable {s : SimpContFract K} {n : ℕ} + +/-- The determinant formula `Aₙ * Bₙ₊₁ - Bₙ * Aₙ₊₁ = (-1) ^ (n + 1)` for `SimpContFract`. -/ theorem determinant (not_terminatedAt_n : ¬(↑s : GenContFract K).TerminatedAt n) : (↑s : GenContFract K).nums n * (↑s : GenContFract K).dens (n + 1) - - (↑s : GenContFract K).dens n * (↑s : GenContFract K).nums (n + 1) = (-1) ^ (n + 1) := - determinant_aux <| Or.inr <| not_terminatedAt_n + (↑s : GenContFract K).dens n * (↑s : GenContFract K).nums (n + 1) = (-1) ^ (n + 1) := calc + _ = ∏ i ∈ Finset.range (n + 1), - ((↑s : GenContFract K).partNums.get? i).getD 0 := + (↑s : GenContFract K).determinant + _ = ∏ i ∈ Finset.range (n + 1), -1 := Finset.prod_congr rfl fun i hi ↦ by + rw [Finset.mem_range] at hi + obtain ⟨gp, s_ith_eq⟩ : ∃ gp, (↑s : GenContFract K).s.get? i = some gp := + Option.ne_none_iff_exists'.1 <| mt (terminated_stable <| Nat.le_of_succ_le_succ hi) ‹_› + rw [partNum_eq_s_a s_ith_eq, s.property i gp.a <| partNum_eq_s_a s_ith_eq, Option.getD_some] + _ = (-1) ^ (n + 1) := by rw [Finset.prod_const, Finset.card_range] end SimpContFract diff --git a/Mathlib/Algebra/DirectSum/LinearMap.lean b/Mathlib/Algebra/DirectSum/LinearMap.lean index 4cb9d438df2c70..23b8e8137f2fc3 100644 --- a/Mathlib/Algebra/DirectSum/LinearMap.lean +++ b/Mathlib/Algebra/DirectSum/LinearMap.lean @@ -92,7 +92,7 @@ lemma trace_eq_zero_of_mapsTo_ne (h : IsInternal N) [IsNoetherian R M] let κ := fun i ↦ Module.Free.ChooseBasisIndex R (N i) let b : (i : s) → Basis (κ i) R (N i) := fun i ↦ Module.Free.chooseBasis R (N i) replace h : IsInternal fun i : s ↦ N i := by - convert DirectSum.isInternal_ne_bot_iff.mpr h <;> simp [s] + convert! DirectSum.isInternal_ne_bot_iff.mpr h <;> simp [s] simp_rw [trace_eq_matrix_trace R (h.collectedBasis b), Matrix.trace, diag_toMatrix_directSum_collectedBasis_eq_zero_of_mapsTo_ne h b σ hσ hf (by simp [s]), Pi.zero_apply, Finset.sum_const_zero] diff --git a/Mathlib/Algebra/DirectSum/Module.lean b/Mathlib/Algebra/DirectSum/Module.lean index e10dff85371f95..557a0b847006b6 100644 --- a/Mathlib/Algebra/DirectSum/Module.lean +++ b/Mathlib/Algebra/DirectSum/Module.lean @@ -213,6 +213,14 @@ theorem component.of [DecidableEq ι] (i j : ι) (b : M j) : component R ι M i ((lof R ι M j) b) = if h : j = i then Eq.recOn h b else 0 := DFinsupp.single_apply +lemma component_comp_lof [DecidableEq ι] (i j : ι) : + component R ι M i ∘ₗ lof R ι M j = if h : j = i then h ▸ .id else 0 := by + aesop (add simp component.of) + +@[simp] +lemma component_comp_lof_same [DecidableEq ι] (i : ι) : component R ι M i ∘ₗ lof R ι M i = .id := by + simp [component_comp_lof] + section map variable {R} {N : ι → Type*} @@ -348,7 +356,7 @@ variable [DecidableEq ι] [∀ i j, AddCommMonoid (δ i j)] [∀ i j, Module R ( /-- `curry` as a linear map. -/ def sigmaLcurry : (⨁ i : Σ _, _, δ i.1 i.2) →ₗ[R] ⨁ (i) (j), δ i j := - { sigmaCurry with map_smul' := fun r ↦ by convert DFinsupp.sigmaCurry_smul (δ := δ) r } + { sigmaCurry with map_smul' := fun r ↦ by convert! DFinsupp.sigmaCurry_smul (δ := δ) r } @[simp] theorem sigmaLcurry_apply (f : ⨁ i : Σ _, _, δ i.1 i.2) (i : ι) (j : α i) : diff --git a/Mathlib/Algebra/EuclideanDomain/Basic.lean b/Mathlib/Algebra/EuclideanDomain/Basic.lean index effdf332f59f71..c814217adb3ee0 100644 --- a/Mathlib/Algebra/EuclideanDomain/Basic.lean +++ b/Mathlib/Algebra/EuclideanDomain/Basic.lean @@ -8,7 +8,7 @@ module public import Mathlib.Algebra.EuclideanDomain.Defs public import Mathlib.Algebra.Ring.Divisibility.Basic public import Mathlib.Algebra.GroupWithZero.Divisibility -public import Mathlib.Algebra.Ring.Basic +public import Mathlib.Algebra.Ring.Equiv /-! # Lemmas about Euclidean domains @@ -413,3 +413,28 @@ theorem div_eq_div_iff_mul_eq_mul_of_dvd {x y z t : R} (h1 : y ≠ 0) (h2 : t end Div end EuclideanDomain + +section RingEquiv + +variable {R S : Type*} [EuclideanDomain R] [CommRing S] + +/-- If `S` is a nontrivial commutative ring isomorphic to a Euclidean domain + `R` then it is also a Euclidean domain. -/ +protected abbrev RingEquiv.euclideanDomain (e : S ≃+* R) : EuclideanDomain S where + toNontrivial := e.nontrivial + quotient a b := e.symm (e a / e b) + remainder a b := e.symm (e a % e b) + r a b := EuclideanDomain.r (e a) (e b) + r_wellFounded := InvImage.wf e EuclideanDomain.r_wellFounded + quotient_zero a := by simp + quotient_mul_add_remainder_eq a b := by + apply e.injective + simpa using EuclideanDomain.quotient_mul_add_remainder_eq (e a) (e b) + remainder_lt a b hb := by + have hb' : e b ≠ 0 := by simpa using hb + simpa using EuclideanDomain.remainder_lt (e a) hb' + mul_left_not_lt a b hb := by + have hb' : e b ≠ 0 := by simpa using hb + simpa using EuclideanDomain.mul_left_not_lt (e a) hb' + +end RingEquiv diff --git a/Mathlib/Algebra/Field/IsField.lean b/Mathlib/Algebra/Field/IsField.lean index 95650bb70874d0..69710a3312cc6f 100644 --- a/Mathlib/Algebra/Field/IsField.lean +++ b/Mathlib/Algebra/Field/IsField.lean @@ -77,7 +77,7 @@ noncomputable def IsField.toSemifield {R : Type u} [Semiring R] (h : IsField R) __ := h inv a := if ha : a = 0 then 0 else Classical.choose (h.mul_inv_cancel ha) inv_zero := dif_pos rfl - mul_inv_cancel a ha := by convert Classical.choose_spec (h.mul_inv_cancel ha); exact dif_neg ha + mul_inv_cancel a ha := by convert! Classical.choose_spec (h.mul_inv_cancel ha); exact dif_neg ha nnqsmul := _ nnqsmul_def _ _ := rfl diff --git a/Mathlib/Algebra/Field/Subfield/Basic.lean b/Mathlib/Algebra/Field/Subfield/Basic.lean index 0f34ab90c7b2b1..8535be0b023ae4 100644 --- a/Mathlib/Algebra/Field/Subfield/Basic.lean +++ b/Mathlib/Algebra/Field/Subfield/Basic.lean @@ -275,7 +275,7 @@ theorem sInf_toSubring (s : Set (Subfield K)) : theorem isGLB_sInf (S : Set (Subfield K)) : IsGLB S (sInf S) := by have : ∀ {s t : Subfield K}, (s : Set K) ≤ t ↔ s ≤ t := by simp [SetLike.coe_subset_coe] refine IsGLB.of_image this ?_ - convert isGLB_biInf (s := S) (f := SetLike.coe) + convert! isGLB_biInf (s := S) (f := SetLike.coe) exact coe_sInf _ /-- Subfields of a ring form a complete lattice. -/ diff --git a/Mathlib/Algebra/FiniteSupport/Basic.lean b/Mathlib/Algebra/FiniteSupport/Basic.lean index 023df61b0ac575..d4a8e2c5c0c6eb 100644 --- a/Mathlib/Algebra/FiniteSupport/Basic.lean +++ b/Mathlib/Algebra/FiniteSupport/Basic.lean @@ -7,10 +7,13 @@ module public import Mathlib.Algebra.BigOperators.Group.Finset.Lemmas public import Mathlib.Algebra.FiniteSupport.Defs +public import Mathlib.Algebra.Group.Action.Pi +public import Mathlib.Algebra.GroupWithZero.Action.Defs public import Mathlib.Algebra.Order.Group.Indicator public import Mathlib.Data.Set.Finite.Lattice -import Mathlib.Algebra.Group.Support +import Mathlib.Algebra.GroupWithZero.Indicator +import Mathlib.Algebra.Module.Basic /-! # Make `fun_prop` work for finite (multiplicative) support @@ -181,6 +184,54 @@ lemma HasFiniteMulSupport.of_comp [One β] (hfg : (f ∘ g).HasFiniteMulSupport) refine Set.Finite.subset hfg fun _ ha ↦ Set.mem_setOf.mpr fun H ↦ Set.mem_setOf.mp ha ?_ grind +-- The additive version is a special case of `Function.HasFiniteSupport.smul_left`. +@[fun_prop] +lemma HasFiniteSupport.hasFiniteMulSupport_fun_pow {M : Type*} [Monoid M] (f : α → M) {g : α → ℕ} + (hg : g.HasFiniteSupport) : + (fun a : α ↦ f a ^ g a).HasFiniteMulSupport := + Set.Finite.subset hg fun a ha ↦ by contrapose! ha; simp_all + +section MulZeroClass + +variable {M : Type*} [MulZeroClass M] + +@[to_fun (attr := fun_prop)] +lemma HasFiniteSupport.mul_left {f : α → M} (hf : f.HasFiniteSupport) (g : α → M) : + (f * g).HasFiniteSupport := + Set.Finite.subset hf fun _ ha ↦ support_mul_subset_left f g ha + +@[to_fun (attr := fun_prop)] +lemma HasFiniteSupport.mul_right (f : α → M) {g : α → M} (hg : g.HasFiniteSupport) : + (f * g).HasFiniteSupport := + Set.Finite.subset hg fun _ ha ↦ support_mul_subset_right f g ha + +end MulZeroClass + end Function +@[fun_prop] +lemma Multiset.hasFiniteSupport_count {α : Type*} [DecidableEq α] (s : Multiset α) : + (count · s).HasFiniteSupport := + s.toFinset.finite_toSet.subset <| by simp + end + +namespace Function.HasFiniteSupport + +public section SMul + +variable {α R M : Type*} [Zero M] + +@[to_fun (attr := fun_prop)] +lemma smul_left [Zero R] [SMulWithZero R M] {f : α → R} (hf : f.HasFiniteSupport) (g : α → M) : + (f • g).HasFiniteSupport := + Set.Finite.subset hf fun _ ha ↦ support_smul_subset_left f g ha + +@[to_fun (attr := fun_prop)] +lemma smul_right [SMulZeroClass R M] (f : α → R) {g : α → M} (hg : g.HasFiniteSupport) : + (f • g).HasFiniteSupport := + Set.Finite.subset hg fun _ ha ↦ support_smul_subset_right f g ha + +end SMul + +end Function.HasFiniteSupport diff --git a/Mathlib/Algebra/GCDMonoid/Basic.lean b/Mathlib/Algebra/GCDMonoid/Basic.lean index b269f4d38a43e6..5c5fb38a783f39 100644 --- a/Mathlib/Algebra/GCDMonoid/Basic.lean +++ b/Mathlib/Algebra/GCDMonoid/Basic.lean @@ -624,7 +624,7 @@ theorem isUnit_gcd_of_eq_mul_gcd {α : Type*} [CommMonoidWithZero α] [GCDMonoid IsUnit (gcd x' y') := by rw [← associated_one_iff_isUnit] refine Associated.of_mul_left ?_ (Associated.refl <| gcd x y) h - convert (gcd_mul_left' (gcd x y) x' y').symm using 1 + convert! (gcd_mul_left' (gcd x y) x' y').symm using 1 rw [← ex, ← ey, mul_one] theorem extract_gcd {α : Type*} [CommMonoidWithZero α] [GCDMonoid α] (x y : α) : diff --git a/Mathlib/Algebra/GCDMonoid/IntegrallyClosed.lean b/Mathlib/Algebra/GCDMonoid/IntegrallyClosed.lean index dc872600aad875..ecd0c87bd2578b 100644 --- a/Mathlib/Algebra/GCDMonoid/IntegrallyClosed.lean +++ b/Mathlib/Algebra/GCDMonoid/IntegrallyClosed.lean @@ -28,7 +28,7 @@ theorem IsLocalization.surj_of_gcd_domain [GCDMonoid R] (M : Submonoid R) [IsLoc obtain ⟨x', y', hx', hy', hu⟩ := extract_gcd x y use x', y', hu rw [mul_comm, IsLocalization.mul_mk'_eq_mk'_of_mul] - convert IsLocalization.mk'_mul_cancel_left (M := M) (S := A) _ _ using 2 + convert! IsLocalization.mk'_mul_cancel_left (M := M) (S := A) _ _ using 2 grind instance (priority := 100) GCDMonoid.toIsIntegrallyClosed diff --git a/Mathlib/Algebra/Group/Action/Basic.lean b/Mathlib/Algebra/Group/Action/Basic.lean index af1f28cd06a114..c414d3ab2fdfc8 100644 --- a/Mathlib/Algebra/Group/Action/Basic.lean +++ b/Mathlib/Algebra/Group/Action/Basic.lean @@ -150,7 +150,7 @@ variable (M α) in @[to_additive /-- Embedding of `α` into functions `M → α` induced by an additive action of `M` on `α`. -/] def toFun : α ↪ M → α := - ⟨fun y x ↦ x • y, fun y₁ y₂ H ↦ one_smul M y₁ ▸ one_smul M y₂ ▸ by convert congr_fun H 1⟩ + ⟨fun y x ↦ x • y, fun y₁ y₂ H ↦ one_smul M y₁ ▸ one_smul M y₂ ▸ by convert! congr_fun H 1⟩ @[to_additive (attr := simp)] lemma toFun_apply (x : M) (y : α) : MulAction.toFun M α y x = x • y := rfl diff --git a/Mathlib/Algebra/Group/Action/Defs.lean b/Mathlib/Algebra/Group/Action/Defs.lean index 5f738b497f24ce..e5fdffe7603b9c 100644 --- a/Mathlib/Algebra/Group/Action/Defs.lean +++ b/Mathlib/Algebra/Group/Action/Defs.lean @@ -614,8 +614,8 @@ end CompatibleScalar /-- Typeclass for multiplicative actions on multiplicative structures. The key axiom here is `smul_mul : g • (x * y) = (g • x) * (g • y)`. -If `G` is a group (with group law multiplication) and `Γ` is its automorphism -group then there is a natural instance of `MulDistribMulAction Γ G`. +If `G` is a multiplicative group with automorphism group `Γ`, then there is a natural instance of +`MulDistribMulAction Γ G`. The axiom is also satisfied by a Galois group $Gal(L/K)$ acting on the field `L`, but here you can use the even stronger class `MulSemiringAction`, which captures @@ -627,11 +627,27 @@ class MulDistribMulAction (M N : Type*) [Monoid M] [Monoid N] extends MulAction /-- Distributivity of `•` across `*` -/ smul_mul : ∀ (r : M) (x y : N), r • (x * y) = r • x * r • y +/-- Typeclass for additive actions on additive structures. + +The key axiom here is `vadd_add : g +ᵥ (x + y) = (g +ᵥ x) + (g +ᵥ y)`. +If `G` is an additive group with additive automorphism group `Γ`, then there is a natural instance +of `AddDistribAddAction Γ G`. -/ +@[ext] +class AddDistribAddAction (M N : Type*) [AddMonoid M] [AddMonoid N] extends AddAction M N where + /-- Acting on `0` by a scalar gives `0` -/ + vadd_zero : ∀ r : M, r +ᵥ (0 : N) = 0 + /-- Distributivity of `+ᵥ` across `+` -/ + vadd_add : ∀ (r : M) (x y : N), r +ᵥ (x + y) = (r +ᵥ x) + (r +ᵥ y) + export MulDistribMulAction (smul_one) +export AddDistribAddAction (vadd_zero) + +attribute [to_additive existing] MulDistribMulAction section MulDistribMulAction variable [Monoid M] [Monoid N] [MulDistribMulAction M N] +@[to_additive] lemma smul_mul' (a : M) (b₁ b₂ : N) : a • (b₁ * b₂) = a • b₁ * a • b₂ := MulDistribMulAction.smul_mul .. diff --git a/Mathlib/Algebra/Group/Action/End.lean b/Mathlib/Algebra/Group/Action/End.lean index 8fde4399617920..ae70099641ac33 100644 --- a/Mathlib/Algebra/Group/Action/End.lean +++ b/Mathlib/Algebra/Group/Action/End.lean @@ -108,6 +108,7 @@ namespace MulAut variable [Monoid M] /-- The tautological action by `MulAut M` on `M`. -/ +@[to_additive /-- The tautological action by `AddAut M` on `M`. -/] instance applyMulAction : MulAction (MulAut M) M where smul := (· <| ·) one_smul _ := rfl @@ -116,16 +117,15 @@ instance applyMulAction : MulAction (MulAut M) M where /-- The tautological action by `MulAut M` on `M`. This generalizes `Function.End.applyMulAction`. -/ +@[to_additive /-- The tautological action by `AddAut M` on `M`. -/] instance applyMulDistribMulAction : MulDistribMulAction (MulAut M) M where - smul := (· <| ·) - one_smul _ := rfl - mul_smul _ _ _ := rfl smul_one := map_one smul_mul := map_mul -@[simp] protected lemma smul_def (f : MulAut M) (a : M) : f • a = f a := rfl +@[to_additive (attr := simp)] protected lemma smul_def (f : MulAut M) (a : M) : f • a = f a := rfl /-- `MulAut.applyDistribMulAction` is faithful. -/ +@[to_additive /-- `AddAut.applyAddDistribAddAction` is faithful. -/] instance apply_faithfulSMul : FaithfulSMul (MulAut M) M where eq_of_smul_eq_smul := MulEquiv.ext end MulAut @@ -135,16 +135,8 @@ end MulAut namespace AddAut variable [AddMonoid M] -/-- The tautological action by `AddAut M` on `M`. -/ -instance applyMulAction : MulAction (AddAut M) M where - smul := (· <| ·) - one_smul _ := rfl - mul_smul _ _ _ := rfl - -@[simp] protected lemma smul_def (f : AddAut M) (a : M) : f • a = f a := rfl - -/-- `AddAut.applyDistribMulAction` is faithful. -/ -instance apply_faithfulSMul : FaithfulSMul (AddAut M) M where eq_of_smul_eq_smul := AddEquiv.ext +@[deprecated (since := "2026-05-26")] alias smul_def := AddAut.vadd_def +@[deprecated (since := "2026-05-26")] alias apply_faithfulSMul := apply_faithfulVAdd end AddAut diff --git a/Mathlib/Algebra/Group/Action/Equidecomp.lean b/Mathlib/Algebra/Group/Action/Equidecomp.lean index 44183e8a430f6c..c84317733ea596 100644 --- a/Mathlib/Algebra/Group/Action/Equidecomp.lean +++ b/Mathlib/Algebra/Group/Action/Equidecomp.lean @@ -191,7 +191,7 @@ theorem IsDecompOn.of_leftInvOn {f g : X → X} {A : Set X} {S : Finset G} noncomputable def symm (f : Equidecomp X G) : Equidecomp X G where toPartialEquiv := f.toPartialEquiv.symm isDecompOn' := by classical exact ⟨f.witness⁻¹, by - convert f.isDecompOn.of_leftInvOn f.leftInvOn + convert! f.isDecompOn.of_leftInvOn f.leftInvOn rw [image_source_eq_target, symm_source]⟩ theorem map_target {f : Equidecomp X G} {x : X} (h : x ∈ f.target) : diff --git a/Mathlib/Algebra/Group/End.lean b/Mathlib/Algebra/Group/End.lean index 613586bd651ae7..116f29bec9aa51 100644 --- a/Mathlib/Algebra/Group/End.lean +++ b/Mathlib/Algebra/Group/End.lean @@ -635,9 +635,16 @@ namespace MulAut variable (M) [Mul M] -/-- The group operation on multiplicative automorphisms is defined by `g h => MulEquiv.trans h g`. -This means that multiplication agrees with composition, `(g*h)(x) = g (h x)`. --/ +/-- If `M` is a type with multiplicative, then multiplicative automorphisms of `M` have the +structure of a group. -/ +@[to_additive /-- If `M` is a type with addition, then additive automorphisms of `M` have the +structure of a group. + +We give `AddAut M` the structure of an additive group rather than a multiplicative group to help +with `to_additive` translation. Without this, any proof in group theory making use of the +conjugation action `G →* MulAut G` would be impossible to `to_additive`-ize because a correct +additivization would require inserting `Additive` around `AddAut G` and dealing with these extra +`Additive`s in the proof, but `to_additive` is unable to do this automatically. -/] instance : Group (MulAut M) where mul g h := MulEquiv.trans h g one := MulEquiv.refl _ @@ -647,50 +654,56 @@ instance : Group (MulAut M) where mul_one _ := rfl inv_mul_cancel := MulEquiv.self_trans_symm +@[to_additive] instance : Inhabited (MulAut M) := ⟨1⟩ -@[simp] +@[to_additive (attr := simp)] theorem coe_mul (e₁ e₂ : MulAut M) : ⇑(e₁ * e₂) = e₁ ∘ e₂ := rfl -@[simp] +@[to_additive (attr := simp)] theorem coe_one : ⇑(1 : MulAut M) = id := rfl -@[simp] +@[to_additive (attr := simp)] theorem coe_inv (e : MulAut M) : ⇑e⁻¹ = e.symm := rfl +@[to_additive] theorem mul_def (e₁ e₂ : MulAut M) : e₁ * e₂ = e₂.trans e₁ := rfl +@[to_additive] theorem one_def : (1 : MulAut M) = MulEquiv.refl _ := rfl +@[to_additive] theorem inv_def (e₁ : MulAut M) : e₁⁻¹ = e₁.symm := rfl -@[simp] +@[to_additive (attr := simp)] theorem inv_symm (e : MulAut M) : e⁻¹.symm = e := rfl -@[simp] +@[to_additive (attr := simp)] theorem symm_inv (e : MulAut M) : (e.symm)⁻¹ = e := rfl -@[simp] +@[to_additive (attr := simp)] theorem inv_apply (e : MulAut M) (m : M) : e⁻¹ m = e.symm m := by rw [inv_def] -@[simp] +@[to_additive (attr := simp)] theorem mul_apply (e₁ e₂ : MulAut M) (m : M) : (e₁ * e₂) m = e₁ (e₂ m) := rfl -@[simp] +@[to_additive (attr := simp)] theorem one_apply (m : M) : (1 : MulAut M) m = m := rfl +@[to_additive] theorem apply_inv_self (e : MulAut M) (m : M) : e (e⁻¹ m) = m := MulEquiv.apply_symm_apply _ _ +@[to_additive] theorem inv_apply_self (e : MulAut M) (m : M) : e⁻¹ (e m) = m := MulEquiv.apply_symm_apply _ _ @@ -704,6 +717,8 @@ def toPerm : MulAut M →* Equiv.Perm M where mapping multiplication in `G` into multiplication in the automorphism group `MulAut G`. See also the type `ConjAct G` for any group `G`, which has a `MulAction (ConjAct G) G` instance where `conj G` acts on `G` by conjugation. -/ +@[to_additive /-- Group conjugation, `AddAut.addConj g h = g + h + -g`, as an additive homomorphism +mapping addition in `G` into addition in the additive automorphism group `AddAut G`. -/] def conj [Group G] : G →* MulAut G where toFun g := { toFun h := g * h * g⁻¹ @@ -714,19 +729,20 @@ def conj [Group G] : G →* MulAut G where map_mul' _ _ := by ext; simp [mul_assoc] map_one' := by ext; simp -@[simp] +@[to_additive (attr := simp)] theorem conj_apply [Group G] (g h : G) : conj g h = g * h * g⁻¹ := rfl -@[simp] +@[to_additive (attr := simp)] theorem conj_symm_apply [Group G] (g h : G) : (conj g).symm h = g⁻¹ * h * g := rfl +@[to_additive] theorem conj_inv_apply [Group G] (g h : G) : (conj g)⁻¹ h = g⁻¹ * h * g := rfl /-- Isomorphic groups have isomorphic automorphism groups. -/ -@[simps] +@[to_additive (attr := simps) /-- Isomorphic groups have isomorphic automorphism groups. -/] def congr [Group G] {H : Type*} [Group H] (ϕ : G ≃* H) : MulAut G ≃* MulAut H where toFun f := ϕ.symm.trans (f.trans ϕ) @@ -741,127 +757,45 @@ namespace AddAut variable (A) [Add A] -/-- The group operation on additive automorphisms is defined by `g h => AddEquiv.trans h g`. -This means that multiplication agrees with composition, `(g*h)(x) = g (h x)`. --/ -instance : Group (AddAut A) where - mul g h := AddEquiv.trans h g - one := AddEquiv.refl _ - inv := AddEquiv.symm - mul_assoc _ _ _ := rfl - one_mul _ := rfl - mul_one _ := rfl - inv_mul_cancel := AddEquiv.self_trans_symm - -instance : Inhabited (AddAut A) := - ⟨1⟩ - -@[simp] -theorem coe_mul (e₁ e₂ : AddAut A) : ⇑(e₁ * e₂) = e₁ ∘ e₂ := - rfl - -@[simp] -theorem coe_one : ⇑(1 : AddAut A) = id := - rfl - -@[simp] -theorem coe_inv (e : AddAut A) : ⇑e⁻¹ = e.symm := rfl - -theorem mul_def (e₁ e₂ : AddAut A) : e₁ * e₂ = e₂.trans e₁ := - rfl - -theorem one_def : (1 : AddAut A) = AddEquiv.refl _ := - rfl - -theorem inv_def (e₁ : AddAut A) : e₁⁻¹ = e₁.symm := - rfl - -@[simp] -theorem mul_apply (e₁ e₂ : AddAut A) (a : A) : (e₁ * e₂) a = e₁ (e₂ a) := - rfl - -@[simp] -theorem one_apply (a : A) : (1 : AddAut A) a = a := - rfl - -@[simp] -theorem inv_symm (e : AddAut A) : e⁻¹.symm = e := rfl - -@[simp] -theorem symm_inv (e : AddAut A) : e.symm⁻¹ = e := rfl - -@[simp] -theorem inv_apply (e : AddAut A) (a : A) : e⁻¹ a = e.symm a := rfl - -theorem inv_apply_self (e : AddAut A) (a : A) : e⁻¹ (e a) = a := - AddEquiv.apply_symm_apply _ _ - -theorem apply_inv_self (e : AddAut A) (a : A) : e (e⁻¹ a) = a := - AddEquiv.apply_symm_apply _ _ +@[deprecated (since := "2026-05-26")] alias coe_mul := coe_add +@[deprecated (since := "2026-05-26")] alias coe_one := coe_zero +@[deprecated (since := "2026-05-26")] alias coe_inv := coe_neg +@[deprecated (since := "2026-05-26")] alias mul_def := add_def +@[deprecated (since := "2026-05-26")] alias one_def := zero_def +@[deprecated (since := "2026-05-26")] alias inv_def := neg_def +@[deprecated (since := "2026-05-26")] alias mul_apply := add_apply +@[deprecated (since := "2026-05-26")] alias one_apply := zero_apply +@[deprecated (since := "2026-05-26")] alias inv_symm := neg_symm +@[deprecated (since := "2026-05-26")] alias symm_inv := symm_neg +@[deprecated (since := "2026-05-26")] alias inv_apply := neg_apply +@[deprecated (since := "2026-05-26")] alias inv_apply_self := neg_apply_self +@[deprecated (since := "2026-05-26")] alias apply_inv_self := apply_neg_self /-- Monoid hom from the group of multiplicative automorphisms to the group of permutations. -/ -def toPerm : AddAut A →* Equiv.Perm A where +def toPerm : AddAut A →+ Additive (Equiv.Perm A) where toFun := AddEquiv.toEquiv - map_one' := rfl - map_mul' _ _ := rfl - -/-- Additive group conjugation, `AddAut.conj g h = g + h - g`, as an additive monoid -homomorphism mapping addition in `G` into multiplication in the automorphism group `AddAut G` -(written additively in order to define the map). -/ -def conj [AddGroup G] : G →+ Additive (AddAut G) where - toFun g := - @Additive.ofMul (AddAut G) - { toFun := fun h => g + h + -g - -- this definition is chosen to match `MulAut.conj` - invFun := fun h => -g + h + g - left_inv := fun _ => by - simp only [add_assoc, neg_add_cancel_left, neg_add_cancel, add_zero] - right_inv := fun _ => by - simp only [add_assoc, add_neg_cancel_left, add_neg_cancel, add_zero] - map_add' := by simp only [add_assoc, neg_add_cancel_left, forall_const] } - map_add' g₁ g₂ := by - apply Additive.toMul.injective; ext h - change g₁ + g₂ + h + -(g₁ + g₂) = g₁ + (g₂ + h + -g₂) + -g₁ - simp only [add_assoc, neg_add_rev] - map_zero' := by - apply Additive.toMul.injective; ext - simp only [zero_add, neg_zero, add_zero, toMul_ofMul, toMul_zero, one_apply] - rfl - -@[simp] -theorem conj_apply [AddGroup G] (g h : G) : (conj g).toMul h = g + h + -g := - rfl - -@[simp] -theorem conj_symm_apply [AddGroup G] (g h : G) : (conj g).toMul.symm h = -g + h + g := - rfl + map_zero' := rfl + map_add' _ _ := rfl -theorem conj_inv_apply [AddGroup G] (g h : G) : (conj g).toMul⁻¹ h = -g + h + g := - rfl +@[deprecated (since := "2026-05-26")] alias conj := addConj +@[deprecated (since := "2026-05-26")] alias conj_apply := addConj_apply +@[deprecated (since := "2026-05-26")] alias conj_symm_apply := addConj_symm_apply +@[deprecated (since := "2026-05-26")] alias conj_inv_apply := addConj_neg_apply -theorem neg_conj_apply [AddGroup G] (g h : G) : (-conj g).toMul h = -g + h + g := by +@[deprecated "use `addConj_neg_apply` instead" (since := "2026-05-26")] +theorem neg_conj_apply [AddGroup G] (g h : G) : (-addConj g) h = -g + h + g := by simp -/-- Isomorphic additive groups have isomorphic automorphism groups. -/ -@[simps] -def congr [AddGroup G] {H : Type*} [AddGroup H] (ϕ : G ≃+ H) : - AddAut G ≃* AddAut H where - toFun f := ϕ.symm.trans (f.trans ϕ) - invFun f := ϕ.trans (f.trans ϕ.symm) - left_inv _ := by simp [DFunLike.ext_iff] - right_inv _ := by simp [DFunLike.ext_iff] - map_mul' := by simp [DFunLike.ext_iff] - end AddAut variable (G) /-- `Multiplicative G` and `G` have isomorphic automorphism groups. -/ @[simps!] -def MulAutMultiplicative [AddGroup G] : MulAut (Multiplicative G) ≃* AddAut G := +def MulAutMultiplicative [AddGroup G] : MulAut (Multiplicative G) ≃* Multiplicative (AddAut G) := { AddEquiv.toMultiplicative.symm with map_mul' := fun _ _ ↦ rfl } /-- `Additive G` and `G` have isomorphic automorphism groups. -/ @[simps!] -def AddAutAdditive [Group G] : AddAut (Additive G) ≃* MulAut G := - { MulEquiv.toAdditive.symm with map_mul' := fun _ _ ↦ rfl } +def AddAutAdditive [Group G] : AddAut (Additive G) ≃+ Additive (MulAut G) := + { MulEquiv.toAdditive.symm with map_add' := fun _ _ ↦ rfl } diff --git a/Mathlib/Algebra/Group/Fin/Tuple.lean b/Mathlib/Algebra/Group/Fin/Tuple.lean index 42d22e374e40e8..7d566c015fa76d 100644 --- a/Mathlib/Algebra/Group/Fin/Tuple.lean +++ b/Mathlib/Algebra/Group/Fin/Tuple.lean @@ -111,7 +111,7 @@ variable [Zero α] @[simp] lemma tail_zero : vecTail (0 : Fin n.succ → α) = 0 := rfl @[simp] lemma cons_eq_zero_iff {v : Fin n → α} {x : α} : vecCons x v = 0 ↔ x = 0 ∧ v = 0 where - mp h := ⟨congr_fun h 0, by convert congr_arg vecTail h⟩ + mp h := ⟨congr_fun h 0, by convert! congr_arg vecTail h⟩ mpr := fun ⟨hx, hv⟩ ↦ by simp [hx, hv] lemma cons_nonzero_iff {v : Fin n → α} {x : α} : vecCons x v ≠ 0 ↔ x ≠ 0 ∨ v ≠ 0 where diff --git a/Mathlib/Algebra/Group/Finsupp.lean b/Mathlib/Algebra/Group/Finsupp.lean index 5c98fbc6d8651b..4f87ef389726c9 100644 --- a/Mathlib/Algebra/Group/Finsupp.lean +++ b/Mathlib/Algebra/Group/Finsupp.lean @@ -269,7 +269,7 @@ lemma induction₂ {motive : (ι →₀ M) → Prop} (f : ι →₀ M) (zero : m a ∉ f.support → b ≠ 0 → motive f → motive (f + single a b)) : motive f := by classical refine f.induction zero ?_ - convert add_single using 7 + convert! add_single using 7 apply (addCommute_of_disjoint _).eq simp_all @@ -315,7 +315,7 @@ lemma induction_on_max₂ (f : ι →₀ M) (zero : motive 0) motive f → motive (f + single a b)) : motive f := by classical refine f.induction_on_max zero ?_ - convert add_single using 7 with _ _ _ H + convert! add_single using 7 with _ _ _ H have := fun c hc ↦ (H c hc).ne apply (addCommute_of_disjoint _).eq simp_all [not_imp_not] diff --git a/Mathlib/Algebra/Group/ForwardDiff.lean b/Mathlib/Algebra/Group/ForwardDiff.lean index 0628ecfede324c..2c95d310a551fa 100644 --- a/Mathlib/Algebra/Group/ForwardDiff.lean +++ b/Mathlib/Algebra/Group/ForwardDiff.lean @@ -151,7 +151,7 @@ theorem fwdDiff_iter_eq_sum_shift (f : M → G) (n : ℕ) (y : M) : rw [← coe_fwdDiffₗ, this, ← Module.End.pow_apply] -- use binomial theorem `Commute.add_pow` to expand this have : Commute (shiftₗ M G h) (-1) := (Commute.one_right _).neg_right - convert congr_fun (LinearMap.congr_fun (this.add_pow n) f) y using 3 + convert! congr_fun (LinearMap.congr_fun (this.add_pow n) f) y using 3 · simp only [sub_eq_add_neg] · rw [LinearMap.sum_apply, sum_apply] congr 1 with k @@ -174,8 +174,8 @@ of `f` at `y`. -/ theorem shift_eq_sum_fwdDiff_iter (f : M → G) (n : ℕ) (y : M) : f (y + n • h) = ∑ k ∈ range (n + 1), n.choose k • Δ_[h]^[k] f y := by - convert congr_fun (LinearMap.congr_fun - ((Commute.one_right (fwdDiffₗ M G h)).add_pow n) f) y using 1 + convert! + congr_fun (LinearMap.congr_fun ((Commute.one_right (fwdDiffₗ M G h)).add_pow n) f) y using 1 · rw [← shiftₗ_pow_apply h f, shiftₗ] · simp [Module.End.pow_apply, coe_fwdDiffₗ] diff --git a/Mathlib/Algebra/Group/Pointwise/Set/Finite.lean b/Mathlib/Algebra/Group/Pointwise/Set/Finite.lean index 36e300751f2dbe..835186f78f36a2 100644 --- a/Mathlib/Algebra/Group/Pointwise/Set/Finite.lean +++ b/Mathlib/Algebra/Group/Pointwise/Set/Finite.lean @@ -182,7 +182,7 @@ theorem card_pow_eq_card_pow_card_univ [∀ k : ℕ, DecidablePred (· ∈ S ^ k apply fintypeMul refine Set.eq_of_subset_of_card_le ?_ (le_trans (ge_of_eq h) ?_) · exact mul_subset_mul Set.Subset.rfl (Set.singleton_subset_iff.mpr ha) - · convert key a (S ^ n) (S ^ n * {a}) fun b hb ↦ Set.mul_mem_mul hb (Set.mem_singleton a) + · convert! key a (S ^ n) (S ^ n * { a }) fun b hb ↦ Set.mul_mem_mul hb (Set.mem_singleton a) rw [pow_succ', ← h₂, ← mul_assoc, ← pow_succ', h₂, mul_singleton, forall_mem_image] intro x hx rwa [mul_inv_cancel_right] diff --git a/Mathlib/Algebra/Group/Subgroup/Basic.lean b/Mathlib/Algebra/Group/Subgroup/Basic.lean index 83b4cc4a47dc35..e1178faf93592f 100644 --- a/Mathlib/Algebra/Group/Subgroup/Basic.lean +++ b/Mathlib/Algebra/Group/Subgroup/Basic.lean @@ -259,7 +259,7 @@ attribute [to_additive] Subgroup.Characteristic attribute [class] Characteristic instance (priority := 100) normal_of_characteristic [h : H.Characteristic] : H.Normal := - ⟨fun a ha b => (SetLike.ext_iff.mp (h.fixed (AddAut.conj b)) a).mpr ha⟩ + ⟨fun a ha b => (SetLike.ext_iff.mp (h.fixed (AddAut.addConj b)) a).mpr ha⟩ end AddSubgroup @@ -331,33 +331,30 @@ theorem _root_.CommGroup.normalizer_eq_top {G : Type*} [CommGroup G] (s : Set G) ext simp [mem_set_normalizer_iff] +@[to_additive] theorem mem_normalizer_iff_conj_image_eq {s : Set G} {g : G} : g ∈ normalizer s ↔ MulAut.conj g '' s = s := by simp_rw [mem_set_normalizer_iff'', Set.ext_iff, Set.mem_image, MulAut.conj_apply] refine forall_congr' fun h ↦ ?_ simp_rw [mul_inv_eq_iff_eq_mul, ← eq_inv_mul_iff_mul_eq, ← mul_assoc, exists_eq_right, iff_comm] -theorem _root_.AddSubgroup.mem_normalizer_iff_conj_image_eq {G : Type*} [AddGroup G] {s : Set G} - {g : G} : g ∈ AddSubgroup.normalizer s ↔ AddAut.conj g '' s = s := by - simp_rw [AddSubgroup.mem_set_normalizer_iff'', Set.ext_iff, Set.mem_image, AddAut.conj_apply] - refine forall_congr' fun h ↦ ?_ - simp_rw [add_neg_eq_iff_eq_add, ← eq_neg_add_iff_add_eq, ← add_assoc, exists_eq_right, iff_comm] +@[to_additive] +theorem mem_normalizer_iff_map_conj_eq {H : Subgroup G} {g : G} : + g ∈ normalizer H ↔ H.map (MulAut.conj g) = H := + .trans mem_normalizer_iff_conj_image_eq (.symm SetLike.ext'_iff) +@[deprecated (since := "2026-05-12")] +alias _root_.AddSubgroup.mem_normalizer_iff_conj_image_eq := + AddSubgroup.mem_normalizer_iff_addConj_image_eq + +@[to_additive] theorem normalizer_le_normalizer_closure (s : Set G) : normalizer s ≤ normalizer (closure s) := by intro g hg have : MulAut.conj g '' (closure s) = closure (MulAut.conj g '' s) := - congr(SetLike.coe $(MulAut.conj g |>.toMonoidHom.map_closure s)) + congr($(MulAut.conj g |>.toMonoidHom.map_closure s)) rw [mem_normalizer_iff_conj_image_eq.mp hg] at this rwa [mem_normalizer_iff_conj_image_eq] -theorem _root_.AddSubgroup.normalizer_le_normalizer_closure {G : Type*} [AddGroup G] (s : Set G) : - AddSubgroup.normalizer s ≤ AddSubgroup.normalizer (AddSubgroup.closure s) := by - intro g hg - have : AddAut.conj g '' (AddSubgroup.closure s) = AddSubgroup.closure (AddAut.conj g '' s) := - congr(SetLike.coe $(AddAut.conj g |>.toAddMonoidHom.map_closure s)) - rw [AddSubgroup.mem_normalizer_iff_conj_image_eq.mp hg] at this - rwa [AddSubgroup.mem_normalizer_iff_conj_image_eq] - variable {H} @[to_additive] @@ -371,6 +368,26 @@ variable (H) in theorem normalizer_eq_top [h : H.Normal] : normalizer (H : Set G) = ⊤ := normalizer_eq_top_iff.mpr h +@[to_additive] +theorem le_set_normalizer_iff {s : Set G} : + H ≤ normalizer s ↔ ∀ h ∈ H, ∀ g ∈ s, h * g * h⁻¹ ∈ s := by + refine ⟨fun hH h hh g hg ↦ hH hh g |>.mp hg, fun hH h hh k ↦ ⟨fun hk ↦ hH h hh k hk, fun hk ↦ ?_⟩⟩ + simpa [mul_assoc] using hH h⁻¹ (inv_mem hh) _ hk + +@[to_additive] +theorem le_normalizer_iff : H ≤ normalizer K ↔ ∀ h ∈ H, ∀ k ∈ K, h * k * h⁻¹ ∈ K := by + refine ⟨fun hH h hh g hg ↦ hH hh g |>.mp hg, fun hH h hh k ↦ ⟨fun hk ↦ hH h hh k hk, fun hk ↦ ?_⟩⟩ + simpa [mul_assoc] using hH h⁻¹ (inv_mem hh) _ hk + +@[to_additive] +theorem le_normalizer_closure_iff {s : Set G} : + H ≤ normalizer (closure s) ↔ ∀ h ∈ H, ∀ g ∈ s, h * g * h⁻¹ ∈ closure s := by + refine ⟨fun hH h hh g hg ↦ hH hh g |>.mp <| mem_closure_of_mem hg, fun hH h hh ↦ ?_⟩ + rw [mem_normalizer_iff_map_conj_eq, MonoidHom.map_closure] + apply le_antisymm <| by simpa using hH h hh + rw [closure_le, ← MonoidHom.map_closure] + exact fun g hg ↦ ⟨_, hH _ (inv_mem hh) g hg, by simp [mul_assoc]⟩ + variable {N : Type*} [Group N] /-- The preimage of the normalizer is contained in the normalizer of the preimage. -/ @@ -383,17 +400,12 @@ theorem le_normalizer_comap (f : N →* G) : /-- The image of the normalizer is contained in the normalizer of the image. -/ @[to_additive /-- The image of the normalizer is contained in the normalizer of the image. -/] -theorem le_normalizer_map (f : G →* N) : (normalizer H).map f ≤ normalizer (H.map f) := fun _ => by - simp only [and_imp, mem_map, exists_imp, mem_normalizer_iff] - rintro x hx rfl n - constructor - · rintro ⟨y, hy, rfl⟩ - use x * y * x⁻¹, (hx y).1 hy - simp - · rintro ⟨y, hyH, hy⟩ - use x⁻¹ * y * x - rw [hx] - simp [hy, hyH, mul_assoc] +theorem le_normalizer_map (f : G →* N) : (normalizer H).map f ≤ normalizer (H.map f) := by + intro x hx + obtain ⟨y, hy, rfl⟩ := Subgroup.mem_map.mp hx + have : .comp (MulAut.conj (f y)) f = f.comp (MulAut.conj y) := by ext; simp -- todo: extract lemma + rw [mem_normalizer_iff_map_conj_eq] at hy ⊢ + rw [map_map, this, ← map_map, hy] @[to_additive] theorem comap_normalizer_eq_of_le_range {f : N →* G} (h : H ≤ f.range) : @@ -850,13 +862,22 @@ instance (priority := 100) normal_subgroupOf {H N : Subgroup G} [N.Normal] : (N.subgroupOf H).Normal := Subgroup.normal_comap _ +@[to_additive] +theorem comap_normalClosure_image_ge (s : Set G) (f : G →* N) : + (normalClosure s) ≤ (normalClosure (f '' s)).comap f := by + simp [normalClosure_le_normal, ← Set.image_subset_iff, subset_normalClosure] + +@[to_additive] +theorem map_normalClosure_le (s : Set G) (f : G →* N) : + (normalClosure s).map f ≤ normalClosure (f '' s) := by + simp [map_le_iff_le_comap, comap_normalClosure_image_ge] + @[to_additive] theorem map_normalClosure (s : Set G) (f : G →* N) (hf : Surjective f) : (normalClosure s).map f = normalClosure (f '' s) := by have : Normal (map f (normalClosure s)) := Normal.map inferInstance f hf apply le_antisymm - · simp [map_le_iff_le_comap, normalClosure_le_normal, coe_comap, - ← Set.image_subset_iff, subset_normalClosure] + · exact map_normalClosure_le s f · exact normalClosure_le_normal (Set.image_mono subset_normalClosure) @[to_additive] diff --git a/Mathlib/Algebra/Group/Subgroup/Defs.lean b/Mathlib/Algebra/Group/Subgroup/Defs.lean index 097719ec5895a1..f1dd1dd3f60220 100644 --- a/Mathlib/Algebra/Group/Subgroup/Defs.lean +++ b/Mathlib/Algebra/Group/Subgroup/Defs.lean @@ -638,7 +638,7 @@ namespace Normal @[to_additive] theorem conj_mem' (nH : H.Normal) (n : G) (hn : n ∈ H) (g : G) : g⁻¹ * n * g ∈ H := by - convert nH.conj_mem n hn g⁻¹ + convert! nH.conj_mem n hn g⁻¹ rw [inv_inv] @[to_additive] diff --git a/Mathlib/Algebra/Group/Subgroup/Ker.lean b/Mathlib/Algebra/Group/Subgroup/Ker.lean index 6ce710f02a8be2..1aa93164bf554e 100644 --- a/Mathlib/Algebra/Group/Subgroup/Ker.lean +++ b/Mathlib/Algebra/Group/Subgroup/Ker.lean @@ -116,7 +116,7 @@ theorem rangeRestrict_surjective (f : G →* N) : Function.Surjective f.rangeRes @[to_additive (attr := simp)] lemma rangeRestrict_injective_iff {f : G →* N} : Injective f.rangeRestrict ↔ Injective f := by - convert Set.injective_codRestrict _ + convert! Set.injective_codRestrict _ @[to_additive] theorem map_range (g : N →* P) (f : G →* N) : f.range.map g = (g.comp f).range := by diff --git a/Mathlib/Algebra/Group/Subgroup/Lattice.lean b/Mathlib/Algebra/Group/Subgroup/Lattice.lean index d8cecbc566480e..d9e6e73cfe5255 100644 --- a/Mathlib/Algebra/Group/Subgroup/Lattice.lean +++ b/Mathlib/Algebra/Group/Subgroup/Lattice.lean @@ -210,7 +210,7 @@ theorem bot_or_nontrivial (H : Subgroup G) : H = ⊥ ∨ Nontrivial H := by /-- A subgroup is either the trivial subgroup or contains a non-identity element. -/ @[to_additive /-- A subgroup is either the trivial subgroup or contains a nonzero element. -/] theorem bot_or_exists_ne_one (H : Subgroup G) : H = ⊥ ∨ ∃ x ∈ H, x ≠ (1 : G) := by - convert H.bot_or_nontrivial + convert! H.bot_or_nontrivial rw [nontrivial_iff_exists_ne_one] @[to_additive] diff --git a/Mathlib/Algebra/Group/Subgroup/Pointwise.lean b/Mathlib/Algebra/Group/Subgroup/Pointwise.lean index e9297af7d965b9..70dbed2a6f0557 100644 --- a/Mathlib/Algebra/Group/Subgroup/Pointwise.lean +++ b/Mathlib/Algebra/Group/Subgroup/Pointwise.lean @@ -330,30 +330,17 @@ theorem inf_mul_assoc (A B C : Subgroup G) (h : C ≤ A) : suffices y * z * z⁻¹ ∈ A by simpa exact mul_mem hyz (inv_mem (h hz)) -@[to_additive] -lemma conj_mem_sup_of_mem_inf_normalizer_of_mem_inf - {H K : Subgroup G} {s : G} (hs : s ∈ normalizer H ⊓ normalizer K) (g : G) (hg : g ∈ H ⊔ K) : - s * g * s⁻¹ ∈ H ⊔ K := by - simp only [mem_inf, mem_normalizer_iff] at hs - rw [sup_eq_closure] at hg - refine closure_induction ?_ ?_ ?_ ?_ hg - · intro x hx - obtain hl | hr := (mem_union x _ _).mpr hx - · exact mem_sup_left (by rwa [← hs.1]) - · exact mem_sup_right (by rwa [← hs.2]) - · simp - · intros x y hx hy hsx hsy - rw [show s * (x * y) * s⁻¹ = (s * x * s⁻¹) * (s * y * s⁻¹) by simp] - exact mul_mem hsx hsy - · intros x hx hsx - exact inv_mem_iff.mp (by simpa [← mul_assoc]) - @[to_additive] lemma normalizer_inf_normalizer_le_normalizer_sup (H K : Subgroup G) : normalizer H ⊓ normalizer K ≤ normalizer ((H ⊔ K : Subgroup G) : Set G) := by - intro s hs g - refine ⟨conj_mem_sup_of_mem_inf_normalizer_of_mem_inf hs g, ?_⟩ - simpa [← mul_assoc] using conj_mem_sup_of_mem_inf_normalizer_of_mem_inf (inv_mem hs) (s * g * s⁻¹) + intro g hg + simp_rw [mem_inf, mem_normalizer_iff_map_conj_eq, map_sup, hg.1, hg.2] at hg ⊢ + +@[to_additive] +lemma conj_mem_sup_of_mem_inf_normalizer_of_mem_inf + {H K : Subgroup G} {s : G} (hs : s ∈ normalizer H ⊓ normalizer K) (g : G) (hg : g ∈ H ⊔ K) : + s * g * s⁻¹ ∈ H ⊔ K := + (normalizer_inf_normalizer_le_normalizer_sup H K hs g).mp hg @[to_additive] lemma normalizer_le_normalizer_sup_of_normalizer_le_left diff --git a/Mathlib/Algebra/Group/Submonoid/Saturation.lean b/Mathlib/Algebra/Group/Submonoid/Saturation.lean index 2e6b8f41913b0e..5e1d41a9e8860b 100644 --- a/Mathlib/Algebra/Group/Submonoid/Saturation.lean +++ b/Mathlib/Algebra/Group/Submonoid/Saturation.lean @@ -158,7 +158,7 @@ instance : InfSet (SaturatedSubmonoid M) where mul_mem' hx hy := by rw [Set.mem_iInter₂] at *; exact fun s hs ↦ mul_mem (hx s hs) (hy s hs) one_mem' := Set.mem_iInter₂.mpr fun _ _ ↦ one_mem _ mulSaturated := by - convert Submonoid.MulSaturated.sInf (f := toSubmonoid '' f) (by simp) + convert! Submonoid.MulSaturated.sInf (f := toSubmonoid '' f) (by simp) ext; simp [Submonoid.mem_sInf] } @[to_additive] diff --git a/Mathlib/Algebra/GroupWithZero/Action/Basic.lean b/Mathlib/Algebra/GroupWithZero/Action/Basic.lean index f7b2f1e25ee64e..0c3ecd9f75ad47 100644 --- a/Mathlib/Algebra/GroupWithZero/Action/Basic.lean +++ b/Mathlib/Algebra/GroupWithZero/Action/Basic.lean @@ -86,7 +86,7 @@ variable (G) This is a stronger version of `MulAction.toPermHom`. -/ @[simps] -def DistribMulAction.toAddAut [DistribMulAction G A] : G →* AddAut A where +def DistribMulAction.toAddAut [DistribMulAction G A] : G →* Multiplicative (AddAut A) where toFun := toAddEquiv _ map_one' := AddEquiv.ext (one_smul _) map_mul' _ _ := AddEquiv.ext (mul_smul _ _) @@ -99,20 +99,6 @@ def smulMonoidWithZeroHom [MonoidWithZero M₀] [MulZeroOneClass N₀] [MulActio [IsScalarTower M₀ N₀ N₀] [SMulCommClass M₀ N₀ N₀] : M₀ × N₀ →*₀ N₀ := { smulMonoidHom with map_zero' := smul_zero _ } -namespace AddAut - -/-- The tautological action by `AddAut A` on `A`. - -This generalizes `Function.End.applyMulAction`. -/ -instance applyDistribMulAction [AddMonoid A] : DistribMulAction (AddAut A) A where - smul := (· <| ·) - smul_zero := map_zero - smul_add := map_add - one_smul _ := rfl - mul_smul _ _ _ := rfl - -end AddAut - lemma IsUnit.smul_sub_iff_sub_inv_smul [Group G] [Monoid R] [AddGroup R] [DistribMulAction G R] [IsScalarTower G R R] [SMulCommClass G R R] (r : G) (a : R) : IsUnit (r • (1 : R) - a) ↔ IsUnit (1 - r⁻¹ • a) := by diff --git a/Mathlib/Algebra/GroupWithZero/Action/Defs.lean b/Mathlib/Algebra/GroupWithZero/Action/Defs.lean index 9d70c4351413a8..f7ad5ae6267f1a 100644 --- a/Mathlib/Algebra/GroupWithZero/Action/Defs.lean +++ b/Mathlib/Algebra/GroupWithZero/Action/Defs.lean @@ -347,8 +347,6 @@ class DistribMulAction (M A : Type*) [Monoid M] [AddMonoid A] extends MulAction /-- Scalar multiplication distributes across addition -/ smul_add : ∀ (a : M) (x y : A), a • (x + y) = a • x + a • y -attribute [to_additive existing (dont_translate := M) DistribMulAction] MulDistribMulAction - section variable [Monoid M] [AddMonoid A] [DistribMulAction M A] diff --git a/Mathlib/Algebra/GroupWithZero/Associated.lean b/Mathlib/Algebra/GroupWithZero/Associated.lean index f954c4071a8ea3..ed2f121e36380d 100644 --- a/Mathlib/Algebra/GroupWithZero/Associated.lean +++ b/Mathlib/Algebra/GroupWithZero/Associated.lean @@ -5,6 +5,7 @@ Authors: Johannes Hölzl, Jens Wagemaker -/ module +public import Mathlib.Algebra.Order.IsBotOne public import Mathlib.Algebra.Prime.Lemmas public import Mathlib.Order.BoundedOrder.Basic @@ -173,7 +174,7 @@ theorem Associated.mul_mul [CommMonoid M] {a₁ a₂ b₁ b₂ : M} theorem Associated.pow_pow [CommMonoid M] {a b : M} {n : ℕ} (h : a ~ᵤ b) : a ^ n ~ᵤ b ^ n := by induction n with | zero => simp [Associated.refl] - | succ n ih => convert h.mul_mul ih <;> rw [pow_succ'] + | succ n ih => convert! h.mul_mul ih <;> rw [pow_succ'] protected theorem Associated.dvd [Monoid M] {a b : M} : a ~ᵤ b → a ∣ b := fun ⟨u, hu⟩ => ⟨u, hu.symm⟩ @@ -523,18 +524,21 @@ theorem mul_mono {a b c d : Associates M} (h₁ : a ≤ b) (h₂ : c ≤ d) : a let ⟨y, hy⟩ := h₂ ⟨x * y, by simp [hx, hy, mul_comm, mul_left_comm]⟩ -theorem one_le {a : Associates M} : 1 ≤ a := - Dvd.intro _ (one_mul a) +instance : IsBotOneClass (Associates M) where + isBot_one a := Dvd.intro _ (one_mul a) + +instance instOrderBot : OrderBot (Associates M) where + bot_le _ := one_le + +@[deprecated _root_.one_le (since := "2026-05-07")] +protected theorem one_le {a : Associates M} : 1 ≤ a := + one_le theorem le_mul_right {a b : Associates M} : a ≤ a * b := ⟨b, rfl⟩ theorem le_mul_left {a b : Associates M} : a ≤ b * a := by rw [mul_comm]; exact le_mul_right -instance instOrderBot : OrderBot (Associates M) where - bot := 1 - bot_le _ := one_le - end Order @[simp] @@ -555,7 +559,6 @@ theorem mk_le_mk_of_dvd {a b : M} : a ∣ b → Associates.mk a ≤ Associates.m theorem mk_le_mk_iff_dvd {a b : M} : Associates.mk a ≤ Associates.mk b ↔ a ∣ b := mk_dvd_mk - @[simp] theorem isPrimal_mk {a : M} : IsPrimal (Associates.mk a) ↔ IsPrimal a := by simp_rw [IsPrimal, forall_associated, mk_surjective.exists, mk_mul_mk, mk_dvd_mk] @@ -564,7 +567,6 @@ theorem isPrimal_mk {a : M} : IsPrimal (Associates.mk a) ↔ IsPrimal a := by exact ⟨a₁, a₂ * u, h₁, Units.mul_right_dvd.mpr h₂, mul_assoc _ _ _⟩ · exact ⟨a₁, a₂, h₁, h₂, congr_arg _ eq⟩ - @[simp] theorem decompositionMonoid_iff : DecompositionMonoid (Associates M) ↔ DecompositionMonoid M := by simp_rw [_root_.decompositionMonoid_iff, forall_associated, isPrimal_mk] diff --git a/Mathlib/Algebra/GroupWithZero/Units/Basic.lean b/Mathlib/Algebra/GroupWithZero/Units/Basic.lean index 54f918a50061ce..9916a90765c529 100644 --- a/Mathlib/Algebra/GroupWithZero/Units/Basic.lean +++ b/Mathlib/Algebra/GroupWithZero/Units/Basic.lean @@ -152,7 +152,7 @@ theorem IsUnit.ringInverse {a : M₀} : IsUnit a → IsUnit a⁻¹ʳ theorem isUnit_ringInverse {a : M₀} : IsUnit a⁻¹ʳ ↔ IsUnit a := ⟨fun h => by cases subsingleton_or_nontrivial M₀ - · convert h + · convert! h · contrapose h rw [Ring.inverse_non_unit _ h] exact not_isUnit_zero, diff --git a/Mathlib/Algebra/Homology/CommSq.lean b/Mathlib/Algebra/Homology/CommSq.lean index 6ff1d59d50cb96..06a429e92f39f0 100644 --- a/Mathlib/Algebra/Homology/CommSq.lean +++ b/Mathlib/Algebra/Homology/CommSq.lean @@ -64,7 +64,7 @@ noncomputable def CommSq.isColimitEquivIsColimitCokernelCofork (sq : CommSq f g (fun s ↦ PushoutCocone.IsColimit.desc h (biprod.inl ≫ s.π) (biprod.inr ≫ s.π) (by rw [← sub_eq_zero, ← assoc, ← assoc, ← Preadditive.sub_comp] - convert s.condition <;> cat_disch)) + convert! s.condition <;> cat_disch)) (fun s ↦ by dsimp ext @@ -98,8 +98,8 @@ noncomputable def CommSq.isColimitEquivIsColimitCokernelCofork (sq : CommSq f g (by simp [s.condition])) .one) (fun s m hm₁ hm₂ ↦ by apply Cofork.IsColimit.hom_ext h - convert (h.fac (CokernelCofork.ofπ (biprod.desc s.inl s.inr) - (by simp [s.condition])) .one).symm + convert! + (h.fac (CokernelCofork.ofπ (biprod.desc s.inl s.inr) (by simp [s.condition])) .one).symm cat_disch) left_inv _ := Subsingleton.elim _ _ right_inv _ := Subsingleton.elim _ _ @@ -144,7 +144,7 @@ noncomputable def CommSq.isLimitEquivIsLimitKernelFork (sq : CommSq fst snd f g) (fun s ↦ PullbackCone.IsLimit.lift h (s.ι ≫ biprod.fst) (s.ι ≫ biprod.snd) (by rw [← sub_eq_zero, assoc, assoc, ← Preadditive.comp_sub] - convert s.condition <;> cat_disch)) + convert! s.condition <;> cat_disch)) (fun s ↦ by dsimp ext @@ -176,8 +176,8 @@ noncomputable def CommSq.isLimitEquivIsLimitKernelFork (sq : CommSq fst snd f g) (by simp [s.condition])) .zero =≫ biprod.snd) (fun s m hm₁ hm₂ ↦ by apply Fork.IsLimit.hom_ext h - convert (h.fac (KernelFork.ofι (biprod.lift s.fst s.snd) - (by simp [s.condition])) .zero).symm + convert! + (h.fac (KernelFork.ofι (biprod.lift s.fst s.snd) (by simp [s.condition])) .zero).symm cat_disch) left_inv _ := Subsingleton.elim _ _ right_inv _ := Subsingleton.elim _ _ diff --git a/Mathlib/Algebra/Homology/DerivedCategory/Basic.lean b/Mathlib/Algebra/Homology/DerivedCategory/Basic.lean index 6b18fdc818b5aa..9f8b1b0bfac6aa 100644 --- a/Mathlib/Algebra/Homology/DerivedCategory/Basic.lean +++ b/Mathlib/Algebra/Homology/DerivedCategory/Basic.lean @@ -94,6 +94,7 @@ variable {C} /-- The localization functor `CochainComplex C ℤ ⥤ DerivedCategory C`. -/ def Q : CochainComplex C ℤ ⥤ DerivedCategory C := HomologicalComplexUpToQuasiIso.Q +set_option backward.isDefEq.respectTransparency false in instance : (Q (C := C)).IsLocalization (HomologicalComplex.quasiIso C (ComplexShape.up ℤ)) := by dsimp only [Q, DerivedCategory] @@ -125,6 +126,7 @@ lemma quotientCompQhIso_inv_naturality {K L : CochainComplex C ℤ} (f : K ⟶ L (quotientCompQhIso C).inv.app K ≫ Qh.map ((HomotopyCategory.quotient _ _).map f) := (quotientCompQhIso C).inv.naturality f +set_option backward.isDefEq.respectTransparency false in instance : Qh.IsLocalization (HomotopyCategory.quasiIso C (ComplexShape.up ℤ)) := by dsimp [Qh, DerivedCategory] infer_instance diff --git a/Mathlib/Algebra/Homology/DerivedCategory/KInjective.lean b/Mathlib/Algebra/Homology/DerivedCategory/KInjective.lean index fc71341ebfa741..e69f08aafa28d6 100644 --- a/Mathlib/Algebra/Homology/DerivedCategory/KInjective.lean +++ b/Mathlib/Algebra/Homology/DerivedCategory/KInjective.lean @@ -74,7 +74,7 @@ lemma bijective_toSmallShiftedHom_of_isKInjective [L.IsKInjective] : (SmallShiftedHom.equiv _ DerivedCategory.Q).bijective, ← Function.Bijective.of_comp_iff' (Iso.homCongr ((quotientCompQhIso C).symm.app K) ((Q.commShiftIso n).symm.app L ≪≫ (quotientCompQhIso C).symm.app (L⟦n⟧))).bijective] - convert (CochainComplex.IsKInjective.Qh_map_bijective _ _).comp (toHom_bijective K L n) + convert! (CochainComplex.IsKInjective.Qh_map_bijective _ _).comp (toHom_bijective K L n) ext x obtain ⟨x, rfl⟩ := x.mk_surjective simp [toHom_mk, ShiftedHom.map] diff --git a/Mathlib/Algebra/Homology/DerivedCategory/KProjective.lean b/Mathlib/Algebra/Homology/DerivedCategory/KProjective.lean index 865f95d1c027d8..48bd3ef6a42769 100644 --- a/Mathlib/Algebra/Homology/DerivedCategory/KProjective.lean +++ b/Mathlib/Algebra/Homology/DerivedCategory/KProjective.lean @@ -75,7 +75,7 @@ lemma bijective_toSmallShiftedHom_of_isKProjective [K.IsKProjective] : (SmallShiftedHom.equiv _ DerivedCategory.Q).bijective, ← Function.Bijective.of_comp_iff' (Iso.homCongr ((quotientCompQhIso C).symm.app K) ((Q.commShiftIso n).symm.app L ≪≫ (quotientCompQhIso C).symm.app (L⟦n⟧))).bijective] - convert (CochainComplex.IsKProjective.Qh_map_bijective _ _).comp (toHom_bijective K L n) + convert! (CochainComplex.IsKProjective.Qh_map_bijective _ _).comp (toHom_bijective K L n) ext x obtain ⟨x, rfl⟩ := x.mk_surjective simp [toHom_mk, ShiftedHom.map] diff --git a/Mathlib/Algebra/Homology/DifferentialObject.lean b/Mathlib/Algebra/Homology/DifferentialObject.lean index 298660c786b1a0..c6b10e7c02e11d 100644 --- a/Mathlib/Algebra/Homology/DifferentialObject.lean +++ b/Mathlib/Algebra/Homology/DifferentialObject.lean @@ -86,7 +86,7 @@ def dgoToHomologicalComplex : { X := fun i => X.obj i d := fun i j => if h : i + b = j then X.d i ≫ X.objEqToHom (show i + (1 : ℤ) • b = j by simp [h]) else 0 - shape := fun i j w => by dsimp at w; convert dif_neg w + shape := fun i j w => by dsimp at w; convert! dif_neg w d_comp_d' := fun i j k hij hjk => by dsimp at hij hjk; substs hij hjk simp [objEqToHom_d_assoc] } diff --git a/Mathlib/Algebra/Homology/HomotopyFiber.lean b/Mathlib/Algebra/Homology/HomotopyFiber.lean index e5efe421ca2e24..bcb49936da5332 100644 --- a/Mathlib/Algebra/Homology/HomotopyFiber.lean +++ b/Mathlib/Algebra/Homology/HomotopyFiber.lean @@ -42,7 +42,7 @@ class HasHomotopyFiber (φ : F ⟶ G) : Prop where instance [HasBinaryBiproducts C] : HasHomotopyFiber φ where hasBinaryBiproduct _ _ _ := inferInstance -variable [HasHomotopyFiber φ] [DecidableRel c.Rel] +variable [HasHomotopyFiber φ] instance : HasHomotopyCofiber ((opFunctor C c).map φ.op) where hasBinaryBiproduct i j hij := by diff --git a/Mathlib/Algebra/Homology/LeftResolution/Basic.lean b/Mathlib/Algebra/Homology/LeftResolution/Basic.lean index a4e5526bed1168..494125a9dc4d6e 100644 --- a/Mathlib/Algebra/Homology/LeftResolution/Basic.lean +++ b/Mathlib/Algebra/Homology/LeftResolution/Basic.lean @@ -103,7 +103,7 @@ lemma exactAt_map_chainComplex_succ (n : ℕ) : rw [HomologicalComplex.exactAt_iff' _ (n + 2) (n + 1) n (ComplexShape.prev_eq' _ (by dsimp; lia)) (by simp), ShortComplex.exact_iff_epi_kernel_lift] - convert epi_comp (ι.map (Λ.chainComplexXIso X n).hom) (Λ.π.app _) + convert! epi_comp (ι.map (Λ.chainComplexXIso X n).hom) (Λ.π.app _) rw [← cancel_mono (kernel.ι _), kernel.lift_ι] simp [map_chainComplex_d] diff --git a/Mathlib/Algebra/Homology/Single.lean b/Mathlib/Algebra/Homology/Single.lean index 4ab1e05842a022..c6a560579c4004 100644 --- a/Mathlib/Algebra/Homology/Single.lean +++ b/Mathlib/Algebra/Homology/Single.lean @@ -52,7 +52,7 @@ noncomputable def single (j : ι) : V ⥤ HomologicalComplex V c where previously was `rw [if_neg h]; simp`, but that fails with "motive not type correct" This is because dsimp does not simplify numerals; this note should be removable once https://github.com/leanprover/lean4/pull/8433 lands. -/ - convert (id_zero (C := V)).symm + convert! (id_zero (C := V)).symm all_goals simp [if_neg h] map_comp f g := by ext diff --git a/Mathlib/Algebra/Homology/SpectralObject/Basic.lean b/Mathlib/Algebra/Homology/SpectralObject/Basic.lean index 96a0a4e46065e2..533d72f4923669 100644 --- a/Mathlib/Algebra/Homology/SpectralObject/Basic.lean +++ b/Mathlib/Algebra/Homology/SpectralObject/Basic.lean @@ -74,7 +74,7 @@ lemma δ_naturality {i j k : ι} (f : i ⟶ j) (g : j ⟶ k) (homMk₂ (α.app 0) (α.app 1) (β.app 1) (naturality' α 0 1) (by simpa only [hαβ] using naturality' β 0 1) : mk₂ f g ⟶ mk₂ f' g') dsimp at h - convert h <;> cat_disch + convert! h <;> cat_disch end diff --git a/Mathlib/Algebra/Homology/SpectralObject/EpiMono.lean b/Mathlib/Algebra/Homology/SpectralObject/EpiMono.lean index 89c2844ed467a9..fbfb0a96a8290d 100644 --- a/Mathlib/Algebra/Homology/SpectralObject/EpiMono.lean +++ b/Mathlib/Algebra/Homology/SpectralObject/EpiMono.lean @@ -86,10 +86,10 @@ lemma isIso_map_fourδ₄Toδ₃ (h : (X.H n₁).map (twoδ₁Toδ₀ f₃ f₄ apply ShortComplex.isIso_homologyMap_of_epi_of_isIso_of_mono' · exact (X.exact₂ f₃ f₄ f₃₄ h₃₄ _).epi_f h · dsimp - convert (inferInstance : IsIso ((X.H n₂).map (𝟙 _))) + convert! (inferInstance : IsIso ((X.H n₂).map (𝟙 _))) cat_disch · dsimp - convert (inferInstance : Mono ((X.H n₃).map (𝟙 (mk₁ f₁)))) + convert! (inferInstance : Mono ((X.H n₃).map (𝟙 (mk₁ f₁)))) cat_disch lemma isIso_map_fourδ₄Toδ₃_of_isZero (h : IsZero ((X.H n₁).obj (mk₁ f₄)) := by cat_disch) @@ -116,10 +116,10 @@ lemma isIso_map_fourδ₁Toδ₀ (h : (X.H n₂).map (twoδ₂Toδ₁ f₂ f₃ IsIso (X.map f₂₃ f₄ f₅ f₃ f₄ f₅ (fourδ₁Toδ₀ f₂ f₃ f₄ f₅ f₂₃ h₂₃) n₀ n₁ n₂ hn₁ hn₂) := by apply ShortComplex.isIso_homologyMap_of_epi_of_isIso_of_mono' · dsimp - convert (inferInstance : Epi ((X.H n₀).map (𝟙 _))) + convert! (inferInstance : Epi ((X.H n₀).map (𝟙 _))) cat_disch · dsimp - convert (inferInstance : IsIso ((X.H n₁).map (𝟙 _))) + convert! (inferInstance : IsIso ((X.H n₁).map (𝟙 _))) cat_disch · exact (X.exact₂ f₂ f₃ f₂₃ h₂₃ n₂).mono_g h diff --git a/Mathlib/Algebra/Homology/SpectralObject/Page.lean b/Mathlib/Algebra/Homology/SpectralObject/Page.lean index 8f06e24911d776..d7f3d7201e6a46 100644 --- a/Mathlib/Algebra/Homology/SpectralObject/Page.lean +++ b/Mathlib/Algebra/Homology/SpectralObject/Page.lean @@ -99,7 +99,7 @@ def shortComplexMap (hn₁ : n₀ + 1 = n₁ := by lia) (hn₂ : n₁ + 1 = n₂ lemma shortComplexMap_id (hn₁ : n₀ + 1 = n₁ := by lia) (hn₂ : n₁ + 1 = n₂ := by lia) : X.shortComplexMap f₁ f₂ f₃ f₁ f₂ f₃ (𝟙 _) n₀ n₁ n₂ hn₁ hn₂ = 𝟙 _ := by ext - all_goals dsimp; convert (X.H _).map_id _; cat_disch + all_goals dsimp; convert! (X.H _).map_id _; cat_disch @[reassoc, simp] lemma shortComplexMap_comp (hn₁ : n₀ + 1 = n₁ := by lia) (hn₂ : n₁ + 1 = n₂ := by lia) : diff --git a/Mathlib/Algebra/Jordan/Basic.lean b/Mathlib/Algebra/Jordan/Basic.lean index 28f792a102ec39..d395627577d3e3 100644 --- a/Mathlib/Algebra/Jordan/Basic.lean +++ b/Mathlib/Algebra/Jordan/Basic.lean @@ -163,7 +163,7 @@ theorem two_nsmul_lie_lmul_lmul_add_eq_lie_lmul_lmul_add [IsCommJordan A] (a b : 2 • (⁅L a, L (a * b)⁆ + ⁅L b, L (b * a)⁆) = ⁅L (a * a), L b⁆ + ⁅L (b * b), L a⁆ := by suffices 2 • ⁅L a, L (a * b)⁆ + 2 • ⁅L b, L (b * a)⁆ + ⁅L b, L (a * a)⁆ + ⁅L a, L (b * b)⁆ = 0 by rwa [← sub_eq_zero, ← sub_sub, sub_eq_add_neg, sub_eq_add_neg, lie_skew, lie_skew, nsmul_add] - convert (commute_lmul_lmul_sq (a + b)).lie_eq using 1 + convert! (commute_lmul_lmul_sq (a + b)).lie_eq using 1 simp only [add_mul, mul_add, map_add, lie_add, add_lie, mul_comm b a, (commute_lmul_lmul_sq a).lie_eq, (commute_lmul_lmul_sq b).lie_eq, zero_add, add_zero, two_smul] abel diff --git a/Mathlib/Algebra/Lie/Basic.lean b/Mathlib/Algebra/Lie/Basic.lean index 88d0dfd8916718..f1a9094f84b662 100644 --- a/Mathlib/Algebra/Lie/Basic.lean +++ b/Mathlib/Algebra/Lie/Basic.lean @@ -121,7 +121,7 @@ lemma lie_swap_lie [Bracket L₂ L₁] [AddCommGroup M] [IsLieTower L₁ L₂ M] (x : L₁) (y : L₂) (m : M) : ⁅⁅x, y⁆, m⁆ = -⁅⁅y, x⁆, m⁆ := by have h1 := leibniz_lie x y m have h2 := leibniz_lie y x m - convert congr($h1.symm - $h2) using 1 <;> simp only [add_sub_cancel_right, sub_add_cancel_right] + convert! congr($h1.symm - $h2) using 1 <;> simp only [add_sub_cancel_right, sub_add_cancel_right] end IsLieTower diff --git a/Mathlib/Algebra/Lie/Basis.lean b/Mathlib/Algebra/Lie/Basis.lean index b18c3bce23cf19..a4d699e4ba0b6c 100644 --- a/Mathlib/Algebra/Lie/Basis.lean +++ b/Mathlib/Algebra/Lie/Basis.lean @@ -367,10 +367,10 @@ lemma borelUpper_le_biSup : ext i simpa using congr_fun χ.property.choose_spec.2.symm i replace hu : u ∈ ⨆ χ, ⨆ (_ : χ ∈ s), rootSpace b.cartan χ := by - convert hu; rw [iSup_subtype', iSup_subtype', ← e.iSup_comp]; rfl + convert! hu; rw [iSup_subtype', iSup_subtype', ← e.iSup_comp]; rfl replace hv : v ∈ ⨆ χ, ⨆ (_ : χ ∈ s), rootSpace b.cartan χ := by - convert hv; rw [iSup_subtype', iSup_subtype', ← e.iSup_comp]; rfl - convert mem_biSup_genWeightSpace_of hs hu hv + convert! hv; rw [iSup_subtype', iSup_subtype', ← e.iSup_comp]; rfl + convert! mem_biSup_genWeightSpace_of hs hu hv rw [iSup_subtype', iSup_subtype', ← e.iSup_comp]; rfl /-- Lemma 4.4 from [Geck](Geck2017). -/ @@ -450,13 +450,13 @@ lemma iSupIndep_rootSpace : simpa using this.2 have key := LieModule.iSupIndep_genWeightSpace R b.cartan L have h₀ : Disjoint (rootSpace b.cartan 0) (U ⊔ V) := by - convert key.disjoint_biSup_biSup (hU0.union_right hV0) + convert! key.disjoint_biSup_biSup (hU0.union_right hV0) rw [iSup_union, hsU', hsV'] have h₁ : Disjoint U (V ⊔ rootSpace b.cartan 0) := by - convert key.disjoint_biSup_biSup (hUV.union_right hU0.symm) + convert! key.disjoint_biSup_biSup (hUV.union_right hU0.symm) rw [iSup_union, hs0', hsV'] have h₂ : Disjoint V (rootSpace b.cartan 0 ⊔ U) := by - convert key.disjoint_biSup_biSup (Disjoint.union_left hV0 hUV).symm + convert! key.disjoint_biSup_biSup (Disjoint.union_left hV0 hUV).symm rw [iSup_union, hs0', hsU'] simp [iSupIndep_fin_three, h₀, h₁, h₂] diff --git a/Mathlib/Algebra/Lie/Derivation/Killing.lean b/Mathlib/Algebra/Lie/Derivation/Killing.lean index e57b295206a5a7..eceaee0ebeef75 100644 --- a/Mathlib/Algebra/Lie/Derivation/Killing.lean +++ b/Mathlib/Algebra/Lie/Derivation/Killing.lean @@ -91,7 +91,7 @@ instance instIsKilling_range_ad : LieAlgebra.IsKilling R 𝕀 := the adjoint action is nondegenerate. -/ lemma killingForm_restrict_range_ad_nondegenerate : ((killingForm R 𝔻).restrict 𝕀).Nondegenerate := by - convert LieAlgebra.IsKilling.killingForm_nondegenerate R 𝕀 + convert! LieAlgebra.IsKilling.killingForm_nondegenerate R 𝕀 exact killingForm_restrict_range_ad R L set_option backward.isDefEq.respectTransparency false in diff --git a/Mathlib/Algebra/Lie/Free.lean b/Mathlib/Algebra/Lie/Free.lean index a57c27ee357639..d92c65136e24f6 100644 --- a/Mathlib/Algebra/Lie/Free.lean +++ b/Mathlib/Algebra/Lie/Free.lean @@ -181,6 +181,7 @@ def of : X → FreeLieAlgebra R X := fun x => Quot.mk _ (lib.of R x) variable {L : Type w} [LieRing L] [LieAlgebra R L] +set_option backward.isDefEq.respectTransparency false in /-- An auxiliary definition used to construct the equivalence `lift` below. -/ def liftAux (f : X → CommutatorRing L) := lib.lift R f @@ -197,6 +198,7 @@ theorem liftAux_map_mul (f : X → L) (a b : lib R X) : liftAux R f (a * b) = ⁅liftAux R f a, liftAux R f b⁆ := map_mul _ a b +set_option backward.isDefEq.respectTransparency false in theorem liftAux_spec (f : X → L) (a b : lib R X) (h : FreeLieAlgebra.Rel R X a b) : liftAux R f a = liftAux R f b := by induction h with @@ -208,6 +210,7 @@ theorem liftAux_spec (f : X → L) (a b : lib R X) (h : FreeLieAlgebra.Rel R X a | mul_left c' _ h₂ => simp only [liftAux_map_mul, h₂] | mul_right c' _ h₂ => simp only [liftAux_map_mul, h₂] +set_option backward.isDefEq.respectTransparency false in /-- The quotient map as a `NonUnitalAlgHom`. -/ def mk : lib R X →ₙₐ[R] CommutatorRing (FreeLieAlgebra R X) where toFun := Quot.mk (Rel R X) diff --git a/Mathlib/Algebra/Lie/Nilpotent.lean b/Mathlib/Algebra/Lie/Nilpotent.lean index 45dc61da8b14e4..c9b3a49592389d 100644 --- a/Mathlib/Algebra/Lie/Nilpotent.lean +++ b/Mathlib/Algebra/Lie/Nilpotent.lean @@ -573,7 +573,7 @@ theorem lcs_add_le_iff (l k : ℕ) : N₁.lcs (l + k) ≤ N₂ ↔ N₁.lcs l rw [(by abel : l + (k + 1) = l + 1 + k), ih, ucs_succ, lcs_succ, top_lie_le_iff_le_normalizer] theorem lcs_le_iff (k : ℕ) : N₁.lcs k ≤ N₂ ↔ N₁ ≤ N₂.ucs k := by - convert lcs_add_le_iff (R := R) (L := L) (M := M) 0 k + convert! lcs_add_le_iff (R := R) (L := L) (M := M) 0 k rw [zero_add] theorem gc_lcs_ucs (k : ℕ) : diff --git a/Mathlib/Algebra/Lie/NonUnitalNonAssocAlgebra.lean b/Mathlib/Algebra/Lie/NonUnitalNonAssocAlgebra.lean index 3adc22863c3d97..34a498271a86f8 100644 --- a/Mathlib/Algebra/Lie/NonUnitalNonAssocAlgebra.lean +++ b/Mathlib/Algebra/Lie/NonUnitalNonAssocAlgebra.lean @@ -78,6 +78,7 @@ namespace LieHom variable {R L} variable {L₂ : Type w} [LieRing L₂] [LieAlgebra R L₂] +set_option backward.isDefEq.respectTransparency false in /-- Regarding the `LieRing` of a `LieAlgebra` as a `NonUnitalNonAssocRing`, we can regard a `LieHom` as a `NonUnitalAlgHom`. -/ @[simps] @@ -87,6 +88,7 @@ def toNonUnitalAlgHom (f : L →ₗ⁅R⁆ L₂) : CommutatorRing L →ₙₐ[R] map_zero' := f.toLinearMap.map_zero map_mul' := f.map_lie } +set_option backward.isDefEq.respectTransparency false in theorem toNonUnitalAlgHom_injective : Function.Injective (toNonUnitalAlgHom : _ → CommutatorRing L →ₙₐ[R] CommutatorRing L₂) := fun _ _ h => ext <| NonUnitalAlgHom.congr_fun h diff --git a/Mathlib/Algebra/Lie/Submodule.lean b/Mathlib/Algebra/Lie/Submodule.lean index cd5c87eb5945c4..a5a978511e024c 100644 --- a/Mathlib/Algebra/Lie/Submodule.lean +++ b/Mathlib/Algebra/Lie/Submodule.lean @@ -974,7 +974,7 @@ lemma map_le_range {M' : Type*} @[simp] lemma map_incl_lt_iff_lt_top {N' : LieSubmodule R L N} : N'.map (LieSubmodule.incl N) < N ↔ N' < ⊤ := by - convert (LieSubmodule.mapOrderEmbedding (f := N.incl) Subtype.coe_injective).lt_iff_lt + convert! (LieSubmodule.mapOrderEmbedding (f := N.incl) Subtype.coe_injective).lt_iff_lt simp @[simp] diff --git a/Mathlib/Algebra/Lie/Weights/Basic.lean b/Mathlib/Algebra/Lie/Weights/Basic.lean index e201cd4b044862..153c3b7c19d15f 100644 --- a/Mathlib/Algebra/Lie/Weights/Basic.lean +++ b/Mathlib/Algebra/Lie/Weights/Basic.lean @@ -552,7 +552,7 @@ lemma map_posFittingComp_eq (e : M ≃ₗ⁅R,L⁆ M₂) : rw [this] exact LieSubmodule.map_mono (map_posFittingComp_le _) rw [← LieSubmodule.map_comp] - convert LieSubmodule.map_id + convert! LieSubmodule.map_id ext simp diff --git a/Mathlib/Algebra/Lie/Weights/Cartan.lean b/Mathlib/Algebra/Lie/Weights/Cartan.lean index 9712d99c452293..ac6795709a85ac 100644 --- a/Mathlib/Algebra/Lie/Weights/Cartan.lean +++ b/Mathlib/Algebra/Lie/Weights/Cartan.lean @@ -75,7 +75,7 @@ lemma toEnd_pow_apply_mem {χ₁ χ₂ : H → R} {x : L} {m : M} | zero => simpa using hm | succ n IH => simp only [pow_succ', Module.End.mul_apply, toEnd_apply_apply] - convert lie_mem_genWeightSpace_of_mem_genWeightSpace hx IH using 2 + convert! lie_mem_genWeightSpace_of_mem_genWeightSpace hx IH using 2 rw [succ_nsmul, ← add_assoc, add_comm (n • _)] lemma mem_biSup_genWeightSpace_of {s : Set (H → R)} (hs : ∀ᵉ (χ₁ ∈ s) (χ₂ ∈ s), χ₁ + χ₂ ∈ s) @@ -309,7 +309,7 @@ lemma mem_corootSpace' {x : H} : exists_and_right, exists_eq_right, mem_setOf_eq, s] refine ⟨fun ⟨_, y, hy, z, hz, hyz⟩ ↦ ⟨y, hy, z, hz, hyz⟩, fun ⟨y, hy, z, hz, hyz⟩ ↦ ⟨?_, y, hy, z, hz, hyz⟩⟩ - convert + convert! (rootSpaceProduct R L H α (-α) 0 (add_neg_cancel α) (⟨y, hy⟩ ⊗ₜ[R] ⟨z, hz⟩)).property using 0 simp [hyz] diff --git a/Mathlib/Algebra/Lie/Weights/IsSimple.lean b/Mathlib/Algebra/Lie/Weights/IsSimple.lean index 5b756b0f2647ab..46c7955c7d3236 100644 --- a/Mathlib/Algebra/Lie/Weights/IsSimple.lean +++ b/Mathlib/Algebra/Lie/Weights/IsSimple.lean @@ -259,7 +259,7 @@ private theorem chi_in_q_aux (h_chi_in_q : ↑χ ∈ q) : have h_zero_weight : H.toLieSubmodule.incl y ∈ genWeightSpace L (0 : H → K) := by apply toLieSubmodule_le_rootSpace_zero exact y.property - convert lie_mem_genWeightSpace_of_mem_genWeightSpace hx_χ h_zero_weight + convert! lie_mem_genWeightSpace_of_mem_genWeightSpace hx_χ h_zero_weight ext h; simp have h_bracket_decomp : ⁅x_χ, m_α⁆ ∈ genWeightSpace L (χ.toLinear + α.toLinear) ⊔ @@ -324,7 +324,7 @@ private theorem chi_not_in_q_aux (h_chi_not_in_q : ↑χ ∉ q) : rw [hi] at h_equiv exact h_chi_not_in_q (h_equiv.mpr (by rw [hj, Weight.toLinear_neg] - convert q.smul_mem (-1) hαq using 1 + convert! q.smul_mem (-1) hαq using 1 rw [neg_smul, one_smul])) obtain ⟨i, hi⟩ := exists_root_index χ (Weight.coe_toLinear_ne_zero_iff.mp w_chi) obtain ⟨j, hj⟩ := exists_root_index α hα₀ @@ -413,7 +413,7 @@ private theorem invtSubmoduleToLieIdeal_aux (hm_α : m_α ∈ sl2SubmoduleOfRoot by_cases w_chi : χ.toLinear = 0 · have hx_χ_in_H : x_χ ∈ H.toLieSubmodule := by rw [← rootSpace_zero_eq K L H] - convert hx_χ; ext h; simp only [Pi.zero_apply] + convert! hx_χ; ext h; simp only [Pi.zero_apply] have h_apply : (χ.toLinear : H → K) h = 0 := by rw [w_chi, LinearMap.zero_apply] exact h_apply.symm apply LieSubmodule.mem_iSup_of_mem ⟨α, hαq, hα₀⟩ diff --git a/Mathlib/Algebra/Lie/Weights/Killing.lean b/Mathlib/Algebra/Lie/Weights/Killing.lean index 4c4a222cc7db18..5e7f645f6b0e01 100644 --- a/Mathlib/Algebra/Lie/Weights/Killing.lean +++ b/Mathlib/Algebra/Lie/Weights/Killing.lean @@ -160,7 +160,7 @@ variable [FiniteDimensional K L] [IsKilling K L] instance : InvolutiveNeg (Weight K H L) where neg α := ⟨-α, by by_cases hα : α.IsZero - · convert α.genWeightSpace_ne_bot; rw [hα, neg_zero] + · convert! α.genWeightSpace_ne_bot; rw [hα, neg_zero] · intro e obtain ⟨x, hx, x_ne0⟩ := α.exists_ne_zero have := mem_ker_killingForm_of_mem_rootSpace_of_forall_rootSpace_neg K L H hx diff --git a/Mathlib/Algebra/Lie/Weights/RootSystem.lean b/Mathlib/Algebra/Lie/Weights/RootSystem.lean index dcb388499ada96..80f11ac0d01b73 100644 --- a/Mathlib/Algebra/Lie/Weights/RootSystem.lean +++ b/Mathlib/Algebra/Lie/Weights/RootSystem.lean @@ -274,7 +274,7 @@ lemma chainTopCoeff_zero_right [Nontrivial L] (hα : α.IsNonZero) : obtain ⟨k, hk⟩ : ∃ k : K, k • f = (toEnd K L L f ^ (chainTopCoeff α (0 : Weight K H L) + 1)) x := by have : (toEnd K L L f ^ (chainTopCoeff α (0 : Weight K H L) + 1)) x ∈ rootSpace H (-α) := by - convert toEnd_pow_apply_mem hf hx (chainTopCoeff α (0 : Weight K H L) + 1) using 2 + convert! toEnd_pow_apply_mem hf hx (chainTopCoeff α (0 : Weight K H L) + 1) using 2 rw [coe_chainTop', Weight.coe_zero, add_zero, succ_nsmul', add_assoc, smul_neg, neg_add_cancel, add_zero] simpa using (finrank_eq_one_iff_of_nonzero' ⟨f, hf⟩ (by simpa using isSl2.f_ne_zero)).mp @@ -398,7 +398,7 @@ def rootSystem : rintro ⟨α, hα⟩ - ⟨⟨β, hβ⟩, rfl⟩ simpa using ⟨reflectRoot α β, by simpa using reflectRoot_isNonZero α β <| by simpa using hβ, rfl⟩) - (by convert span_weight_isNonZero_eq_top K L H; ext; simp) + (by convert! span_weight_isNonZero_eq_top K L H; ext; simp) instance : (rootSystem H).IsRootSystem := RootPairing.isRootSystem_mk'' fun α β ↦ diff --git a/Mathlib/Algebra/Module/DedekindDomain.lean b/Mathlib/Algebra/Module/DedekindDomain.lean index 6d4ed4a7c864f9..fc699e5eb4a0f5 100644 --- a/Mathlib/Algebra/Module/DedekindDomain.lean +++ b/Mathlib/Algebra/Module/DedekindDomain.lean @@ -22,14 +22,12 @@ public section universe u v -variable {R : Type u} [CommRing R] [IsDomain R] {M : Type v} [AddCommGroup M] [Module R M] +variable {R : Type u} [CommRing R] [IsDedekindDomain R] {M : Type v} [AddCommGroup M] [Module R M] open scoped DirectSum namespace Submodule -variable [IsDedekindDomain R] - open UniqueFactorizationMonoid /-- Over a Dedekind domain, an `I`-torsion module is the internal direct sum of its `p i ^ e i`- @@ -42,7 +40,7 @@ theorem isInternal_prime_power_torsion_of_is_torsion_by_ideal have prime_of_mem := fun p (hp : p ∈ P.toFinset) => prime_of_factor p (Multiset.mem_toFinset.mp hp) apply torsionBySet_isInternal (p := fun p => p ^ P.count p) _ - · convert hM + · convert! hM rw [← Finset.inf_eq_iInf, IsDedekindDomain.inf_pow_eq_prod_of_prime, ← Finset.prod_multiset_count, ← associated_iff_eq] · exact factors_prod hI diff --git a/Mathlib/Algebra/Module/Equiv/Basic.lean b/Mathlib/Algebra/Module/Equiv/Basic.lean index 8495f58a40800d..d54d846e37e0eb 100644 --- a/Mathlib/Algebra/Module/Equiv/Basic.lean +++ b/Mathlib/Algebra/Module/Equiv/Basic.lean @@ -278,7 +278,7 @@ variable {modM : Module ℤ M} {modM₂ : Module ℤ M₂} {modM₃ : Module ℤ equivalence between ℤ-modules -/ def toIntLinearEquiv : M ≃ₗ[ℤ] M₂ := by refine e.toLinearEquiv fun c a ↦ ?_ - convert e.toAddMonoidHom.map_zsmul c a using 1 + convert! e.toAddMonoidHom.map_zsmul c a using 1 · exact congr(e $(int_smul_eq_zsmul ..)) · exact int_smul_eq_zsmul .. diff --git a/Mathlib/Algebra/Module/Equiv/Defs.lean b/Mathlib/Algebra/Module/Equiv/Defs.lean index d99677823a8bf6..5d4616cf15966c 100644 --- a/Mathlib/Algebra/Module/Equiv/Defs.lean +++ b/Mathlib/Algebra/Module/Equiv/Defs.lean @@ -296,6 +296,7 @@ variable [RingHomCompTriple σ₁₃ σ₃₄ σ₁₄] [RingHomCompTriple σ₄ variable [RingHomCompTriple σ₂₃ σ₃₄ σ₂₄] [RingHomCompTriple σ₄₃ σ₃₂ σ₄₂] variable (e₁₂ : M₁ ≃ₛₗ[σ₁₂] M₂) (e₂₃ : M₂ ≃ₛₗ[σ₂₃] M₃) +set_option linter.overlappingInstances false in /-- Linear equivalences are transitive. -/ -- Note: the `RingHomCompTriple σ₃₂ σ₂₁ σ₃₁` is unused, but is convenient to carry around -- implicitly for lemmas like `LinearEquiv.self_trans_symm`. diff --git a/Mathlib/Algebra/Module/FinitePresentation.lean b/Mathlib/Algebra/Module/FinitePresentation.lean index ba90a5cd241acd..71029470069912 100644 --- a/Mathlib/Algebra/Module/FinitePresentation.lean +++ b/Mathlib/Algebra/Module/FinitePresentation.lean @@ -137,7 +137,7 @@ lemma Module.finitePresentation_of_free_of_surjective [Module.Free R M] [Module. by simpa [Set.range_comp, LinearMap.range_eq_top], ?_⟩ let f : M →ₗ[R] (Set.finite_range (l ∘ b)).toFinset →₀ R := Finsupp.lmapDomain _ _ π ∘ₗ b.repr.toLinearMap - convert hl'.map f + convert! hl'.map f ext x; simp only [LinearMap.mem_ker, Submodule.mem_map] constructor · intro hx @@ -384,7 +384,7 @@ lemma Module.FinitePresentation.exists_lift_of_isLocalizedModule · simp only [smul_zero] apply IsLocalizedModule.exists_of_eq (S := S) (f := f) rw [← LinearMap.comp_apply, map_zero, hi, LinearMap.comp_apply] - convert map_zero (s₀ • g) + convert! map_zero (s₀ • g) rw [← LinearMap.mem_ker, ← hτ] exact Submodule.subset_span x.prop choose s' hs' using this @@ -395,7 +395,7 @@ lemma Module.FinitePresentation.exists_lift_of_isLocalizedModule simp only [s₁] rw [SetLike.mem_coe, LinearMap.mem_ker, LinearMap.smul_apply, ← Finset.prod_erase_mul _ _ (Finset.mem_univ ⟨x, hxσ⟩), mul_smul] - convert smul_zero _ + convert! smul_zero _ exact hs' ⟨x, hxσ⟩ refine ⟨Submodule.liftQ _ _ this ∘ₗ (LinearMap.quotKerEquivOfSurjective _ hπ).symm.toLinearMap, s₁ * s₀, ?_⟩ @@ -586,7 +586,7 @@ lemma IsLocalizedModule.exists_isLocalizedModule_powers_of_finitePresentation ⟨IsLocalizedModule.map_units f, fun y ↦ ⟨⟨y, 1⟩, by simp⟩, by simpa using ⟨1, S.one_mem⟩⟩ obtain ⟨r, hrp, H⟩ := exists_bijective_map_powers S f (.id (R := R) (M := M')) f <| by - convert show Function.Bijective LinearMap.id from Function.bijective_id + convert! show Function.Bijective LinearMap.id from Function.bijective_id apply IsLocalizedModule.ext S f · exact IsLocalizedModule.map_units f · simp [IsLocalizedModule.map_comp] diff --git a/Mathlib/Algebra/Module/GradedModule.lean b/Mathlib/Algebra/Module/GradedModule.lean index ef3b584f93367d..b5cd34d70ed2ac 100644 --- a/Mathlib/Algebra/Module/GradedModule.lean +++ b/Mathlib/Algebra/Module/GradedModule.lean @@ -191,20 +191,21 @@ end SetLike namespace GradedModule variable [AddCommMonoid M] [Module A M] [SetLike σ M] [AddSubmonoidClass σ' A] - [AddSubmonoidClass σ M] [SetLike.GradedMonoid 𝓐] [SetLike.GradedSMul 𝓐 𝓜] + [AddSubmonoidClass σ M] [SetLike.GradedSMul 𝓐 𝓜] + [DecidableEq ιA] [DecidableEq ιM] [GradedRing 𝓐] /-- The smul multiplication of `A` on `⨁ i, 𝓜 i` from `(⨁ i, 𝓐 i) →+ (⨁ i, 𝓜 i) →+ ⨁ i, 𝓜 i` turns `⨁ i, 𝓜 i` into an `A`-module -/ @[implicit_reducible] -def isModule [DecidableEq ιA] [DecidableEq ιM] [GradedRing 𝓐] : Module A (⨁ i, 𝓜 i) := +def isModule : Module A (⨁ i, 𝓜 i) := { Module.compHom _ (DirectSum.decomposeRingEquiv 𝓐 : A ≃+* ⨁ i, 𝓐 i).toRingHom with smul := fun a b => DirectSum.decompose 𝓐 a • b } /-- `⨁ i, 𝓜 i` and `M` are isomorphic as `A`-modules. "The internal version" and "the external version" are isomorphism as `A`-modules. -/ -def linearEquiv [DecidableEq ιA] [DecidableEq ιM] [GradedRing 𝓐] [DirectSum.Decomposition 𝓜] : +def linearEquiv [DirectSum.Decomposition 𝓜] : @LinearEquiv A A _ _ (RingHom.id A) (RingHom.id A) _ _ M (⨁ i, 𝓜 i) _ _ _ (by letI := isModule 𝓐 𝓜; infer_instance) := by letI h := isModule 𝓐 𝓜 @@ -223,7 +224,7 @@ def linearEquiv [DecidableEq ιA] [DecidableEq ιM] [GradedRing 𝓐] [DirectSum DirectSum.Gmodule.smulAddMonoidHom _ _ (decompose 𝓐 ↑(decompose 𝓐 x i)) (decomposeAddEquiv 𝓜 ↑(decompose 𝓜 y j)) from DirectSum.Gmodule.smul_def _ _ _ _] simp only [decomposeAddEquiv_apply, decompose_coe, Gmodule.smulAddMonoidHom_apply_of_of] - convert DirectSum.decompose_coe 𝓜 _ + convert! DirectSum.decompose_coe 𝓜 _ rfl end GradedModule diff --git a/Mathlib/Algebra/Module/Injective.lean b/Mathlib/Algebra/Module/Injective.lean index da35d3423cc89f..68b5c4debd2949 100644 --- a/Mathlib/Algebra/Module/Injective.lean +++ b/Mathlib/Algebra/Module/Injective.lean @@ -292,7 +292,7 @@ theorem ExtensionOfMaxAdjoin.extendIdealTo_wd (h : Module.Baer R Q) {y : N} (r r (eq1 : r • y = r' • y) : ExtensionOfMaxAdjoin.extendIdealTo i f h y r = ExtensionOfMaxAdjoin.extendIdealTo i f h y r' := by rw [← sub_eq_zero, ← map_sub] - convert ExtensionOfMaxAdjoin.extendIdealTo_wd' i f h (r - r') _ + convert! ExtensionOfMaxAdjoin.extendIdealTo_wd' i f h (r - r') _ rw [sub_smul, sub_eq_zero, eq1] theorem ExtensionOfMaxAdjoin.extendIdealTo_eq (h : Module.Baer R Q) {y : N} (r : R) diff --git a/Mathlib/Algebra/Module/LinearMap/FiniteRange.lean b/Mathlib/Algebra/Module/LinearMap/FiniteRange.lean new file mode 100644 index 00000000000000..ec403ae2982f64 --- /dev/null +++ b/Mathlib/Algebra/Module/LinearMap/FiniteRange.lean @@ -0,0 +1,271 @@ +/- +Copyright (c) 2026 Patrick Massot. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Patrick Massot, Anatole Dedecker +-/ +module + +public import Mathlib.RingTheory.Finiteness.Cofinite +public import Mathlib.Algebra.Module.Submodule.EqLocus + +/-! +# `HasFiniteRange` predicate on linear maps, and the associated equivalence relation + +In this file, we define: + +* `LinearMap.HasFiniteRange`: a predicate expressing that a linear map has finitely generated range. +* `LinearMap.HasNoetherianRange`: a predicate expressing that a linear map has noetherian range, + i.e, all submodules of the range are finitely generated. This should be thought of as the + "better behaved" version of `LinearMap.HasFiniteRange`: for example, `HasNoetherianRange` + is always stable by addition, whereas `HasFiniteRange` might not be. The two notions agree + over noetherian rings (hence, in particular, over fields). +* `LinearMap.finiteRange`: the submodule of `E →ₗ[K] F` consisting of linear maps with + *noetherian* ranges. We allow ourself this slightly abusive name because the more natural + definition (the submodule of linear maps with finitely generated ranges) only makes sense over a + noetherian ring, in which case the two notions agree. +* `LinearMap.FiniteRangeSetoid.setoid`: the setoid on `E →ₗ[K] F` associated to + `LinearMap.finiteRange`. This identifies linear maps which differ by a linear map with + noetherian range. Equivalently, two linear maps are equivalent for this + relation if and only if they agree on a subspace `A` of the domain such that `E ⧸ A` is + noetherian. As with `LinearMap.finiteRange`, we allow ourself a slightly abusive name because the + more natural definition in terms of `LinearMap.HasFiniteRange` is only well behaved over a + noetherian ring, in which case the two notions agree. + This is an instance in the scope `LinearMap.FiniteRangeSetoid`, + so opening this scope allows this relation to be denoted by `≈`. +-/ + +@[expose] public section + +open LinearMap Submodule Module + +namespace LinearMap + +variable {K V V' V₂ V₂' V₃ : Type*} + +section Semiring + +variable [Semiring K] + [AddCommMonoid V] [Module K V] + [AddCommMonoid V₂] [Module K V₂] + [AddCommMonoid V₃] [Module K V₃] + +/-- A linear map **has Noetherian range** if its range is a Noetherian module. -/ +def HasNoetherianRange (f : V →ₗ[K] V₂) := IsNoetherian K f.range + +/-- A linear map **has finite range** if its range is finitely generated. -/ +def HasFiniteRange (f : V →ₗ[K] V₂) := f.range.FG + +lemma hasNoetherianRange_iff_range {f : V →ₗ[K] V₂} : + f.HasNoetherianRange ↔ IsNoetherian K f.range := + Iff.rfl + +lemma hasFiniteRange_iff_range {f : V →ₗ[K] V₂} : + f.HasFiniteRange ↔ f.range.FG := + Iff.rfl + +alias ⟨HasNoetherianRange.isNoetherian_range, _⟩ := hasNoetherianRange_iff_range +alias ⟨HasFiniteRange.fg_range, _⟩ := hasFiniteRange_iff_range + +lemma HasNoetherianRange.hasFiniteRange {u : V →ₗ[K] V₂} (h : u.HasNoetherianRange) : + u.HasFiniteRange := + have := h.isNoetherian_range; FG.of_finite + +@[simp] lemma HasNoetherianRange.zero : (0 : V →ₗ[K] V₂).HasNoetherianRange := by + simp [HasNoetherianRange, isNoetherian_submodule, Submodule.fg_bot] + +@[simp] lemma HasFiniteRange.zero : (0 : V →ₗ[K] V₂).HasFiniteRange := + HasNoetherianRange.zero.hasFiniteRange + +lemma HasNoetherianRange.comp_left {u : V →ₗ[K] V₂} (h : u.HasNoetherianRange) + (v : V₂ →ₗ[K] V₃) : (v ∘ₗ u).HasNoetherianRange := by + rw [LinearMap.HasNoetherianRange, LinearMap.range_comp] at * + infer_instance + +lemma HasFiniteRange.comp_left {u : V →ₗ[K] V₂} (h : u.HasFiniteRange) + (v : V₂ →ₗ[K] V₃) : (v ∘ₗ u).HasFiniteRange := by + rw [LinearMap.HasFiniteRange, LinearMap.range_comp] at * + exact Submodule.FG.map v h + +@[simp] lemma HasNoetherianRange.of_isNoetherian_dom [IsNoetherian K V] {f : V →ₗ[K] V₂} : + f.HasNoetherianRange := + hasNoetherianRange_iff_range.mpr inferInstance + +@[simp] lemma HasFiniteRange.of_finite_dom [Module.Finite K V] {f : V →ₗ[K] V₂} : + f.HasFiniteRange := by + simp [HasFiniteRange] + +@[simp] lemma HasNoetherianRange.of_isNoetherian_rng [IsNoetherian K V₂] {f : V →ₗ[K] V₂} : + f.HasNoetherianRange := + hasNoetherianRange_iff_range.mpr inferInstance + +@[simp] lemma HasFiniteRange.of_isNoetherian_rng [IsNoetherian K V₂] {f : V →ₗ[K] V₂} : + f.HasFiniteRange := + HasNoetherianRange.of_isNoetherian_rng.hasFiniteRange + +end Semiring + +section Ring + +variable [Ring K] + [AddCommGroup V] [Module K V] + [AddCommGroup V₂] [Module K V₂] + [AddCommGroup V₃] [Module K V₃] + +lemma HasFiniteRange.hasNoetherianRange [IsNoetherianRing K] {u : V →ₗ[K] V₂} + (h : u.HasFiniteRange) : u.HasNoetherianRange := by + rw [HasNoetherianRange] + have := Finite.of_fg h.fg_range + infer_instance + +lemma hasNoetherianRange_iff_hasFiniteRange [IsNoetherianRing K] {u : V →ₗ[K] V₂} : + u.HasNoetherianRange ↔ u.HasFiniteRange := + ⟨HasNoetherianRange.hasFiniteRange, HasFiniteRange.hasNoetherianRange⟩ + +lemma HasNoetherianRange.comp_right {v : V₂ →ₗ[K] V₃} (h : v.HasNoetherianRange) + (u : V →ₗ[K] V₂) : (v ∘ₗ u).HasNoetherianRange := by + rw [HasNoetherianRange, LinearMap.range_comp] at * + exact isNoetherian_of_le map_le_range + +lemma HasFiniteRange.comp_right [IsNoetherianRing K] {v : V₂ →ₗ[K] V₃} (h : v.HasFiniteRange) + (u : V →ₗ[K] V₂) : (v ∘ₗ u).HasFiniteRange := + h.hasNoetherianRange.comp_right _ |>.hasFiniteRange + +@[simp] lemma HasNoetherianRange.neg {f : V →ₗ[K] V₂} + (hf : f.HasNoetherianRange) : (-f).HasNoetherianRange := by + rwa [HasNoetherianRange, LinearMap.range_neg] + +@[simp] lemma HasFiniteRange.neg {f : V →ₗ[K] V₂} + (hf : f.HasFiniteRange) : (-f).HasFiniteRange := by + rwa [HasFiniteRange, LinearMap.range_neg] + +@[simp] lemma HasNoetherianRange.add {f g : V →ₗ[K] V₂} + (hf : f.HasNoetherianRange) (hg : g.HasNoetherianRange) : (f + g).HasNoetherianRange := by + rw [HasNoetherianRange] at * + exact isNoetherian_of_le (range_add_le f g) + +@[simp] lemma HasFiniteRange.add [IsNoetherianRing K] {f g : V →ₗ[K] V₂} + (hf : f.HasFiniteRange) (hg : g.HasFiniteRange) : (f + g).HasFiniteRange := + hf.hasNoetherianRange.add hg.hasNoetherianRange |>.hasFiniteRange + +@[simp] lemma HasNoetherianRange.sub {f g : V →ₗ[K] V₂} + (hf : f.HasNoetherianRange) (hg : g.HasNoetherianRange) : (f - g).HasNoetherianRange := + sub_eq_add_neg f g ▸ hf.add hg.neg + +@[simp] lemma HasFiniteRange.sub [IsNoetherianRing K] {f g : V →ₗ[K] V₂} + (hf : f.HasFiniteRange) (hg : g.HasFiniteRange) : (f - g).HasFiniteRange := + sub_eq_add_neg f g ▸ hf.add hg.neg + +theorem hasNoetherianRange_iff_quotient_ker {f : V →ₗ[K] V₂} : + f.HasNoetherianRange ↔ IsNoetherian K (V ⧸ f.ker) := + f.quotKerEquivRange.isNoetherian_iff.symm + +@[simp] +theorem ker_coFG_iff_hasFiniteRange {f : V →ₗ[K] V₂} : + f.ker.CoFG ↔ f.HasFiniteRange := + range_fg_iff_ker_cofg.symm + +alias ⟨HasNoetherianRange.quotient_ker, _⟩ := hasNoetherianRange_iff_quotient_ker +alias ⟨_, HasFiniteRange.cofg_ker⟩ := ker_coFG_iff_hasFiniteRange + +end Ring + +section CommRing + +variable [CommRing K] + [AddCommGroup V] [Module K V] + [AddCommGroup V₂] [Module K V₂] + [AddCommGroup V₃] [Module K V₃] + +@[simp] lemma HasNoetherianRange.smul {f : V →ₗ[K] V₂} + (hf : f.HasNoetherianRange) (c : K) : (c • f).HasNoetherianRange := + hf.comp_left (lsmul K V₂ c) + +@[simp] lemma HasFiniteRange.smul {f : V →ₗ[K] V₂} + (hf : f.HasFiniteRange) (c : K) : (c • f).HasFiniteRange := + hf.comp_left (lsmul K V₂ c) + +variable (K V V₂) in +/-- `LinearMap.finiteRange` is the submodule of `V →ₗ[K] W` consisting of linear maps satisfying +`LinearMap.HasNoetherianRange`. We allow ourself this slightly abusive name because the set of +linear maps satisfying `LinearMap.HasFiniteRange` is only a submodule over a noetherian ring, +in which case the two notions agree. -/ +def finiteRange : Submodule K (V →ₗ[K] V₂) where + carrier := {u | u.HasNoetherianRange} + add_mem' hu hv := by simp_all + zero_mem' := by simp + smul_mem' c hu := by simp_all + +lemma mem_finiteRange_iff_hasNoetherianRange {f : V →ₗ[K] V₂} : + f ∈ finiteRange K V V₂ ↔ f.HasNoetherianRange := + Iff.rfl + +lemma mem_finiteRange_iff_hasFiniteRange [IsNoetherianRing K] {f : V →ₗ[K] V₂} : + f ∈ finiteRange K V V₂ ↔ f.HasFiniteRange := by + rw [mem_finiteRange_iff_hasNoetherianRange, hasNoetherianRange_iff_hasFiniteRange] + +end CommRing + +section Setoid + +variable [CommRing K] + [AddCommGroup V] [Module K V] + [AddCommGroup V₂] [Module K V₂] + [AddCommGroup V₃] [Module K V₃] + +namespace FiniteRangeSetoid + +/-- This is the equivalence relation on linear maps such that `u ≈ v` precisely +when `u - v` is a linear map with noetherian range. We allow ourself this slightly abusive name +because the more natural definition (`u - v` has finitely generated range) only yields a +well-behaved relation (more precisely, an additive congruence relation compatible with composition +on both sides) over a noetherian ring, in which case the two notions agree. + +This setoid is declared as an instance in scope `LinearMap.FiniteRangeSetoid`. -/ +scoped instance setoid : Setoid (V →ₗ[K] V₂) := (LinearMap.finiteRange K V V₂).quotientRel + +lemma equiv_iff_hasNoetherianRange {u v : V →ₗ[K] V₂} : u ≈ v ↔ (u - v).HasNoetherianRange := + Submodule.quotientRel_def _ + +lemma equiv_iff_hasFiniteRange [IsNoetherianRing K] {u v : V →ₗ[K] V₂} : + u ≈ v ↔ (u - v).HasFiniteRange := by + rw [equiv_iff_hasNoetherianRange, hasNoetherianRange_iff_hasFiniteRange] + +lemma equiv_iff_isNoetherian_quotient_eqLocus {u v : V →ₗ[K] V₂} : + u ≈ v ↔ IsNoetherian K (V ⧸ eqLocus u v) := by + rw [equiv_iff_hasNoetherianRange, hasNoetherianRange_iff_quotient_ker, eqLocus_eq_ker_sub] + +lemma equiv_iff_eqLocus_coFG [IsNoetherianRing K] {u v : V →ₗ[K] V₂} : + u ≈ v ↔ (eqLocus u v).CoFG := by + rw [eqLocus_eq_ker_sub, ker_coFG_iff_hasFiniteRange, equiv_iff_hasFiniteRange] + +lemma equiv_of_eqOn_of_isNoetherian {u v : V →ₗ[K] V₂} (A : Submodule K V) + [quot_A_noeth : IsNoetherian K (V ⧸ A)] (eqOn_A : Set.EqOn u v A) : u ≈ v := by + have A_le : A ≤ eqLocus u v := le_eqLocus.mpr eqOn_A + rw [equiv_iff_isNoetherian_quotient_eqLocus] + refine isNoetherian_of_surjective (A.mapQ (eqLocus u v) id A_le) (by simp [range_mapQ]) + +lemma equiv_of_eqOn_coFG [IsNoetherianRing K] {u v : V →ₗ[K] V₂} {A : Submodule K V} + (A_coFG : A.CoFG) (eqOn_A : Set.EqOn u v A) : u ≈ v := + equiv_iff_eqLocus_coFG.mpr <| A_coFG.of_le <| le_eqLocus.mpr eqOn_A + +@[gcongr] +lemma equiv_comp_right {u : V →ₗ[K] V₂} {v v' : V₂ →ₗ[K] V₃} (h' : v ≈ v') : + v ∘ₗ u ≈ v' ∘ₗ u := by + rw [equiv_iff_hasNoetherianRange] at * + exact h'.comp_right u + +@[gcongr] +lemma equiv_comp_left {u v : V →ₗ[K] V₂} {u' : V₂ →ₗ[K] V₃} (h : u ≈ v) : + u' ∘ₗ u ≈ u' ∘ₗ v := by + rw [equiv_iff_hasNoetherianRange] at * + simpa only [LinearMap.comp_sub] using h.comp_left u' + +lemma equiv_comp {u v : V →ₗ[K] V₂} {u' v' : V₂ →ₗ[K] V₃} (h : u ≈ v) (h' : u' ≈ v') : + u' ∘ₗ u ≈ v' ∘ₗ v := by + grw [equiv_comp_right h', equiv_comp_left h] + +end FiniteRangeSetoid + +end Setoid + +end LinearMap diff --git a/Mathlib/Algebra/Module/LocalizedModule/Basic.lean b/Mathlib/Algebra/Module/LocalizedModule/Basic.lean index 07dd45e351c516..d4e732feb760fb 100644 --- a/Mathlib/Algebra/Module/LocalizedModule/Basic.lean +++ b/Mathlib/Algebra/Module/LocalizedModule/Basic.lean @@ -123,7 +123,7 @@ def liftOn {α : Type*} (x : LocalizedModule S M) (f : M × S → α) Quotient.liftOn x f (by simpa +instances only [r.setoid, ← oreEqv_eq_r S M] using wd) theorem liftOn_mk {α : Type*} {f : M × S → α} (wd : ∀ (p p' : M × S), p ≈ p' → f p = f p') - (m : M) (s : S) : liftOn (mk m s) f wd = f ⟨m, s⟩ := by convert Quotient.liftOn_mk f wd ⟨m, s⟩ + (m : M) (s : S) : liftOn (mk m s) f wd = f ⟨m, s⟩ := by convert! Quotient.liftOn_mk f wd ⟨m, s⟩ /-- If `f : M × S → M × S → α` respects the equivalence relation `LocalizedModule.r`, then `f` descents to a map `LocalizedModule M S → LocalizedModule M S → α`. @@ -135,7 +135,7 @@ def liftOn₂ {α : Type*} (x y : LocalizedModule S M) (f : M × S → M × S theorem liftOn₂_mk {α : Type*} (f : M × S → M × S → α) (wd : ∀ (p q p' q' : M × S), p ≈ p' → q ≈ q' → f p q = f p' q') (m m' : M) (s s' : S) : liftOn₂ (mk m s) (mk m' s') f wd = f ⟨m, s⟩ ⟨m', s'⟩ := by - convert Quotient.liftOn₂_mk f wd _ _ + convert! Quotient.liftOn₂_mk f wd _ _ /-- If `S` contains `0` then the localization at `S` is trivial. -/ theorem subsingleton (h : 0 ∈ S) : Subsingleton (LocalizedModule S M) := by diff --git a/Mathlib/Algebra/Module/LocalizedModule/Int.lean b/Mathlib/Algebra/Module/LocalizedModule/Int.lean index cef950b6bfb040..e43294f55d06fe 100644 --- a/Mathlib/Algebra/Module/LocalizedModule/Int.lean +++ b/Mathlib/Algebra/Module/LocalizedModule/Int.lean @@ -134,10 +134,10 @@ theorem smul_mem_finsetIntegerMultiple_span [DecidableEq M] (x : M) (s : Finset obtain ⟨x', hx', hx''⟩ := hx obtain ⟨a, ha⟩ := (IsLocalizedModule.eq_iff_exists S f).mp hx'' use a * y - convert (Submodule.span R - (IsLocalizedModule.finsetIntegerMultiple S f s : Set M)).smul_mem - a hx' using 1 - convert ha.symm using 1 + convert! + (Submodule.span R (IsLocalizedModule.finsetIntegerMultiple S f s : Set M)).smul_mem a hx' + using 1 + convert! ha.symm using 1 simp only [Submonoid.smul_def, ← smul_smul] end IsLocalizedModule diff --git a/Mathlib/Algebra/Module/LocalizedModule/IsLocalization.lean b/Mathlib/Algebra/Module/LocalizedModule/IsLocalization.lean index 15ff7aee7b8fb1..89f0714709261a 100644 --- a/Mathlib/Algebra/Module/LocalizedModule/IsLocalization.lean +++ b/Mathlib/Algebra/Module/LocalizedModule/IsLocalization.lean @@ -43,7 +43,7 @@ variable (A) the associated linear map `R →ₗ[R] A` is a localization of modules with respect to `S`. -/ lemma isLocalizedModule_iff_isLocalization' : IsLocalizedModule S (Algebra.linearMap R A) ↔ IsLocalization S A := by - convert isLocalizedModule_iff_isLocalization (S := S) (A := R) (Aₛ := A) + convert! isLocalizedModule_iff_isLocalization (S := S) (A := R) (Aₛ := A) exact (Submonoid.map_id S).symm instance [IsLocalization S A] : IsLocalizedModule S (Algebra.linearMap R A) := diff --git a/Mathlib/Algebra/Module/NatInt.lean b/Mathlib/Algebra/Module/NatInt.lean index 3ef0af81898905..9daa84aa1c71eb 100644 --- a/Mathlib/Algebra/Module/NatInt.lean +++ b/Mathlib/Algebra/Module/NatInt.lean @@ -134,7 +134,7 @@ should normally have exactly one `ℕ`-module structure by design. -/ @[implicit_reducible] def AddCommMonoid.uniqueNatModule : Unique (Module ℕ M) where default := inferInstance - uniq P := (Module.ext' P _) fun n => by convert nat_smul_eq_nsmul P n + uniq P := (Module.ext' P _) fun n => by convert! nat_smul_eq_nsmul P n /-- All `ℕ`-module structures are equal. See also `AddCommMonoid.uniqueNatModule`. -/ instance AddCommMonoid.subsingletonNatModule : Subsingleton (Module ℕ M) := @@ -186,7 +186,7 @@ should normally have exactly one `ℤ`-module structure by design. -/ @[implicit_reducible] def AddCommGroup.uniqueIntModule : Unique (Module ℤ M) where default := inferInstance - uniq P := (Module.ext' P _) fun n => by convert int_smul_eq_zsmul P n + uniq P := (Module.ext' P _) fun n => by convert! int_smul_eq_zsmul P n end AddCommGroup diff --git a/Mathlib/Algebra/Module/PID.lean b/Mathlib/Algebra/Module/PID.lean index 3a0d5fd8cef26b..afc20225a1d2ba 100644 --- a/Mathlib/Algebra/Module/PID.lean +++ b/Mathlib/Algebra/Module/PID.lean @@ -80,7 +80,7 @@ theorem Submodule.isInternal_prime_power_torsion_of_pid [Module.Finite R M] torsionBy R M (IsPrincipal.generator (p : Ideal R) ^ (factors (⊤ : Submodule R M).annihilator).count ↑p) := by - convert isInternal_prime_power_torsion hM + convert! isInternal_prime_power_torsion hM rw [← torsionBySet_span_singleton_eq, Ideal.submodule_span_eq, ← Ideal.span_singleton_pow, Ideal.span_singleton_generator] @@ -120,8 +120,9 @@ theorem _root_.Ideal.torsionOf_eq_span_pow_pOrder (x : M) : (Associates.mk <| generator <| torsionOf R M x) ∣ Associates.mk p ^ n := by ext n; rw [← Associates.mk_pow, Associates.mk_dvd_mk, ← mem_iff_generator_dvd]; rfl have := (isTorsion'_powers_iff p).mp hM x; rw [prop] at this - convert Associates.eq_pow_find_of_dvd_irreducible_pow (Associates.irreducible_mk.mpr hp) - this.choose_spec + convert! + Associates.eq_pow_find_of_dvd_irreducible_pow (Associates.irreducible_mk.mpr hp) + this.choose_spec theorem p_pow_smul_lift {x y : M} {k : ℕ} (hM' : Module.IsTorsionBy R M (p ^ pOrder hM y)) (h : p ^ k • x ∈ R ∙ y) : ∃ a : R, p ^ k • x = p ^ k • a • y := by @@ -132,7 +133,7 @@ theorem p_pow_smul_lift {x y : M} {k : ℕ} (hM' : Module.IsTorsionBy R M (p ^ p · have : f.symm ⟨p ^ k • x, h⟩ ∈ R ∙ Ideal.Quotient.mk (R ∙ p ^ (pOrder hM y - k) * p ^ k) (p ^ k) := by rw [← Quotient.torsionBy_eq_span_singleton, mem_torsionBy_iff, ← f.symm.map_smul] - · convert f.symm.map_zero; ext + · convert! f.symm.map_zero; ext rw [coe_smul_of_tower, coe_mk, coe_zero, smul_smul, ← pow_add, Nat.sub_add_cancel hk, @hM' x] · exact mem_nonZeroDivisors_of_ne_zero (pow_ne_zero _ hp.ne_zero) @@ -141,7 +142,7 @@ theorem p_pow_smul_lift {x y : M} {k : ℕ} (hM' : Module.IsTorsionBy R M (p ^ p dsimp only [smul_eq_mul, LinearEquiv.trans_apply, Submodule.quotEquivOfEq_mk, quotTorsionOfEquivSpanSingleton_apply_mk] at ha rw [smul_smul, mul_comm]; exact congr_arg ((↑) : _ → M) ha.symm - · symm; convert Ideal.torsionOf_eq_span_pow_pOrder hp hM y + · symm; convert! Ideal.torsionOf_eq_span_pow_pOrder hp hM y rw [← pow_add, Nat.sub_add_cancel hk] · use 0 rw [zero_smul, smul_zero, ← Nat.sub_add_cancel hk.le, pow_add, mul_smul, hM', @@ -155,7 +156,7 @@ theorem exists_smul_eq_zero_and_mk_eq {z : M} (hz : Module.IsTorsionBy R M (p ^ have f1 := mk_surjective (R ∙ z) (f 1) have : p ^ k • f1.choose ∈ R ∙ z := by rw [← Quotient.mk_eq_zero, mk_smul, f1.choose_spec, ← f.map_smul] - convert f.map_zero; change _ • Submodule.Quotient.mk _ = _ + convert! f.map_zero; change _ • Submodule.Quotient.mk _ = _ rw [← mk_smul, Quotient.mk_eq_zero, smul_eq_mul, mul_one] exact Submodule.mem_span_singleton_self _ obtain ⟨a, ha⟩ := p_pow_smul_lift hp hM hz this diff --git a/Mathlib/Algebra/Module/Presentation/Tensor.lean b/Mathlib/Algebra/Module/Presentation/Tensor.lean index 6228317222b3af..113f78c9782890 100644 --- a/Mathlib/Algebra/Module/Presentation/Tensor.lean +++ b/Mathlib/Algebra/Module/Presentation/Tensor.lean @@ -82,7 +82,7 @@ noncomputable def isPresentationCoreTensor : erw [Finsupp.apply_linearCombination A (LinearMap.applyₗ (solution₂.var g₂))] have := s.linearCombination_var_relation (.inl ⟨r₁, g₂⟩) erw [Finsupp.linearCombination_embDomain] at this - convert this + convert! this ext g₁ simp) }) postcomp_desc _ := by aesop diff --git a/Mathlib/Algebra/Module/Projective.lean b/Mathlib/Algebra/Module/Projective.lean index 00e6a6bda6d6a2..c04d5236d6454d 100644 --- a/Mathlib/Algebra/Module/Projective.lean +++ b/Mathlib/Algebra/Module/Projective.lean @@ -59,6 +59,7 @@ projective module universe w v u open LinearMap hiding id +open DirectSum hiding id_apply open Finsupp /- The actual implementation we choose: `P` is projective if the natural surjection @@ -287,4 +288,21 @@ theorem Projective.of_lifting_property {R : Type u} [Ring R] {P : Type v} [AddCo end OfLiftingProperty +section DirectSum + +variable {R : Type u} [Semiring R] +variable {ι : Type v} {M : ι → Type w} [(i : ι) → AddCommMonoid (M i)] [(i : ι) → Module R (M i)] + +theorem Projective.directSum_iff : Projective R (⨁ i, M i) ↔ ∀ (i : ι), Projective R (M i) := by + classical + refine ⟨fun H i ↦ ?_, fun H ↦ ?_⟩ + · exact .of_split (DirectSum.lof ..) (DirectSum.component ..) (by simp) + · let e : (⨁ i, M i) ≃ₗ[R] Π₀ i, M i := .refl .. + exact Projective.of_equiv' e.symm + +instance Projective.directSum [∀ (i : ι), Projective R (M i)] : Projective R (⨁ i, M i) := + directSum_iff.mpr ‹_› + +end DirectSum + end Module diff --git a/Mathlib/Algebra/Module/SpanRank.lean b/Mathlib/Algebra/Module/SpanRank.lean index 33f0758e90c49e..b987823c938eba 100644 --- a/Mathlib/Algebra/Module/SpanRank.lean +++ b/Mathlib/Algebra/Module/SpanRank.lean @@ -154,7 +154,7 @@ lemma spanRank_span_range_of_linearIndependent [RankCondition R] {ι : Type u} { rw [this] refine le_trans ?_ ((Module.Basis.span hs).le_span (R := R) (J := Subtype.val ⁻¹' x.1) ?_) · rw [mk_range_eq] - exact .of_comp (f := Subtype.val) (by convert hv; ext; simp [Module.Basis.span_apply]) + exact .of_comp (f := Subtype.val) (by convert! hv; ext; simp [Module.Basis.span_apply]) · apply map_injective_of_injective (f := (span R _).subtype) (injective_subtype _) simp [map_span, Set.image_preimage_eq_inter_range, Set.inter_eq_self_of_subset_left, ← x.2] @@ -210,7 +210,7 @@ lemma lift_spanRank_le_iff_exists_span_set_card_le (p : Submodule R M) {a : Card if and only if there is a generating subset with cardinality less than or equal to `a`. -/ lemma FG.spanRank_le_iff_exists_span_set_card_le (p : Submodule R M) {a : Cardinal} : p.spanRank ≤ a ↔ ∃ s : Set M, #s ≤ a ∧ span R s = p := by - convert lift_spanRank_le_iff_exists_span_set_card_le p (a := a) <;> simp + convert! lift_spanRank_le_iff_exists_span_set_card_le p (a := a) <;> simp @[simp] lemma spanRank_eq_zero_iff_eq_bot {I : Submodule R M} : I.spanRank = 0 ↔ I = ⊥ := by diff --git a/Mathlib/Algebra/Module/SpanRankOperations.lean b/Mathlib/Algebra/Module/SpanRankOperations.lean index d9e70da64c568f..1fbbd6c6ab8a0d 100644 --- a/Mathlib/Algebra/Module/SpanRankOperations.lean +++ b/Mathlib/Algebra/Module/SpanRankOperations.lean @@ -36,7 +36,7 @@ variable {R A : Type*} [CommRing R] [CommRing A] [Algebra R A] lemma Submodule.spanRank_baseChange_le : (N.baseChange A).spanRank ≤ N.spanRank.lift := by obtain ⟨s, hs₁, hs₂⟩ := N.exists_span_set_card_eq_spanRank grw [← hs₁, ← hs₂, baseChange_span, spanRank_span_le_card] - convert Cardinal.mk_image_le_lift (f := TensorProduct.mk R A M 1) (s := s) + convert! Cardinal.mk_image_le_lift (f := TensorProduct.mk R A M 1) (s := s) · exact (Cardinal.lift_id' _).symm · exact Cardinal.lift_umax.symm diff --git a/Mathlib/Algebra/Module/Submodule/Ker.lean b/Mathlib/Algebra/Module/Submodule/Ker.lean index 2d3c9b7861fc8c..876ecf85efa630 100644 --- a/Mathlib/Algebra/Module/Submodule/Ker.lean +++ b/Mathlib/Algebra/Module/Submodule/Ker.lean @@ -217,6 +217,17 @@ alias _root_.LinearMapClass.ker_eq_bot := ker_eq_bot end Ring +section CommSemiring + +variable [Semiring R] [CommSemiring R₂] +variable [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module R₂ M₂] +variable {τ₁₂ : R →+* R₂} + +theorem ker_le_ker_smul (f : M →ₛₗ[τ₁₂] M₂) (c : R₂) : ker f ≤ ker (c • f) := by + simpa only [ker] using Submodule.comap_le_comap_smul _ _ _ + +end CommSemiring + section Semifield variable [Semifield K] diff --git a/Mathlib/Algebra/Module/Submodule/Map.lean b/Mathlib/Algebra/Module/Submodule/Map.lean index 5950a0e1955d2b..c41af3f34468ea 100644 --- a/Mathlib/Algebra/Module/Submodule/Map.lean +++ b/Mathlib/Algebra/Module/Submodule/Map.lean @@ -599,22 +599,25 @@ end Submodule namespace Submodule -variable {N N₂ : Type*} -variable [CommSemiring R] [CommSemiring R₂] +variable {S N N₂ : Type*} +variable [CommSemiring S] [Semiring R] [CommSemiring R₂] variable [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module R₂ M₂] -variable [AddCommMonoid N] [AddCommMonoid N₂] [Module R N] [Module R N₂] -variable {τ₁₂ : R →+* R₂} {τ₂₁ : R₂ →+* R} -variable [RingHomInvPair τ₁₂ τ₂₁] [RingHomInvPair τ₂₁ τ₁₂] +variable [AddCommMonoid N] [AddCommMonoid N₂] [Module S N] [Module S N₂] +variable {τ₁₂ : R →+* R₂} variable (p : Submodule R M) (q : Submodule R₂ M₂) -variable (pₗ : Submodule R N) (qₗ : Submodule R N₂) +variable (pₗ : Submodule S N) (qₗ : Submodule S N₂) -theorem comap_le_comap_smul (fₗ : N →ₗ[R] N₂) (c : R) : comap fₗ qₗ ≤ comap (c • fₗ) qₗ := by +theorem comap_le_comap_smul (f : M →ₛₗ[τ₁₂] M₂) (c : R₂) : comap f q ≤ comap (c • f) q := by simp only [SetLike.le_def, mem_comap, LinearMap.smul_apply] exact fun _ h ↦ smul_mem _ _ h +theorem map_smul_le_map [RingHomSurjective τ₁₂] (f : M →ₛₗ[τ₁₂] M₂) (c : R₂) : + map (c • f) p ≤ map f p := by + grw [map_le_iff_le_comap, ← comap_le_comap_smul (map f p) f c, ← map_le_iff_le_comap] + /-- Given modules `M`, `M₂` over a commutative ring, together with submodules `p ⊆ M`, `q ⊆ M₂`, the set of maps $\{f ∈ Hom(M, M₂) | f(p) ⊆ q \}$ is a submodule of `Hom(M, M₂)`. -/ -def compatibleMaps : Submodule R (N →ₗ[R] N₂) where +def compatibleMaps : Submodule S (N →ₗ[S] N₂) where carrier := { fₗ | pₗ ≤ comap fₗ qₗ } zero_mem' := by simp add_mem' {f₁ f₂} h₁ h₂ := by @@ -629,17 +632,19 @@ end Submodule namespace LinearMap -variable [Semiring R] [AddCommMonoid M] [AddCommMonoid M₁] [Module R M] [Module R M₁] +variable [Semiring R] [Semiring R₂] +variable [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module R₂ M₂] +variable {σ₁₂ : R →+* R₂} {σ₂₁ : R₂ →+* R} /-- The `LinearMap` from the preimage of a submodule to itself. This is the linear version of `AddMonoidHom.addSubmonoidComap` and `AddMonoidHom.addSubgroupComap`. -/ @[simps!] -def submoduleComap (f : M →ₗ[R] M₁) (q : Submodule R M₁) : q.comap f →ₗ[R] q := +def submoduleComap (f : M →ₛₗ[σ₁₂] M₂) (q : Submodule R₂ M₂) : q.comap f →ₛₗ[σ₁₂] q := f.restrict fun _ ↦ Submodule.mem_comap.1 -theorem submoduleComap_surjective_of_surjective (f : M →ₗ[R] M₁) (q : Submodule R M₁) +theorem submoduleComap_surjective_of_surjective (f : M →ₛₗ[σ₁₂] M₂) (q : Submodule R₂ M₂) (hf : Surjective f) : Surjective (f.submoduleComap q) := fun y ↦ by obtain ⟨x, hx⟩ := hf y use ⟨x, Submodule.mem_comap.mpr (hx ▸ y.2)⟩ @@ -653,23 +658,22 @@ This is the linear version of `AddMonoidHom.addSubmonoidMap` and `AddMonoidHom.a TODO: Consider making this an `abbrev`, dropping its API, and renaming to something like `restrictSubmodule`. -/ -def submoduleMap (f : M →ₗ[R] M₁) (p : Submodule R M) : p →ₗ[R] p.map f := +def submoduleMap [RingHomSurjective σ₁₂] (f : M →ₛₗ[σ₁₂] M₂) (p : Submodule R M) : + p →ₛₗ[σ₁₂] p.map f := f.restrict fun x hx ↦ Submodule.mem_map.mpr ⟨x, hx, rfl⟩ @[simp] -theorem submoduleMap_coe_apply (f : M →ₗ[R] M₁) {p : Submodule R M} (x : p) : - ↑(f.submoduleMap p x) = f x := rfl +theorem submoduleMap_coe_apply [RingHomSurjective σ₁₂] (f : M →ₛₗ[σ₁₂] M₂) {p : Submodule R M} + (x : p) : ↑(f.submoduleMap p x) = f x := rfl -theorem submoduleMap_surjective (f : M →ₗ[R] M₁) (p : Submodule R M) : +theorem submoduleMap_surjective [RingHomSurjective σ₁₂] (f : M →ₛₗ[σ₁₂] M₂) (p : Submodule R M) : Function.Surjective (f.submoduleMap p) := f.toAddMonoidHom.addSubmonoidMap_surjective _ @[grind inj] -theorem submoduleMap_injective {f : M →ₗ[R] M₁} (hf : Injective f) (p : Submodule R M) : - Injective (f.submoduleMap p) := +theorem submoduleMap_injective [RingHomSurjective σ₁₂] {f : M →ₛₗ[σ₁₂] M₂} (hf : Injective f) + (p : Submodule R M) : Injective (f.submoduleMap p) := f.toAddMonoidHom.addSubmonoidMap_injective hf _ -variable [Semiring R₂] [AddCommMonoid M₂] [Module R₂ M₂] {σ₂₁ : R₂ →+* R} - open Submodule theorem map_codRestrict [RingHomSurjective σ₂₁] (p : Submodule R M) (f : M₂ →ₛₗ[σ₂₁] M) (h p') : diff --git a/Mathlib/Algebra/Module/Submodule/Range.lean b/Mathlib/Algebra/Module/Submodule/Range.lean index cfd5a18a782438..af73d5e971206b 100644 --- a/Mathlib/Algebra/Module/Submodule/Range.lean +++ b/Mathlib/Algebra/Module/Submodule/Range.lean @@ -261,6 +261,17 @@ theorem ker_le_iff [RingHomSurjective τ₁₂] {p : Submodule R M} : end Ring +section CommSemiring + +variable [Semiring R] [CommSemiring R₂] +variable [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module R₂ M₂] +variable {τ₁₂ : R →+* R₂} [RingHomSurjective τ₁₂] + +theorem range_smul_le_range (f : M →ₛₗ[τ₁₂] M₂) (c : R₂) : range (c • f) ≤ range f := by + simpa only [range_eq_map] using Submodule.map_smul_le_map _ _ _ + +end CommSemiring + section Semifield variable [Semifield K] diff --git a/Mathlib/Algebra/Module/Submodule/RestrictScalars.lean b/Mathlib/Algebra/Module/Submodule/RestrictScalars.lean index e8c99e85d95369..26aca7cdc39ede 100644 --- a/Mathlib/Algebra/Module/Submodule/RestrictScalars.lean +++ b/Mathlib/Algebra/Module/Submodule/RestrictScalars.lean @@ -82,14 +82,12 @@ instance restrictScalars.isScalarTower (p : Submodule R M) : smul_assoc r s x := Subtype.ext <| smul_assoc r s (x : M) variable {R M} in -@[gcongr] -lemma restrictScalars_le {s t : Submodule R M} : +@[gcongr, simp] lemma restrictScalars_le {s t : Submodule R M} : s.restrictScalars S ≤ t.restrictScalars S ↔ s ≤ t := Iff.rfl variable {R M} in -@[gcongr] -lemma restrictScalars_lt {s t : Submodule R M} : +@[gcongr, simp] lemma restrictScalars_lt {s t : Submodule R M} : s.restrictScalars S < t.restrictScalars S ↔ s < t := Iff.rfl diff --git a/Mathlib/Algebra/Module/Submodule/Union.lean b/Mathlib/Algebra/Module/Submodule/Union.lean index 29dbb5e9fdb41e..d0d0cd335e64d3 100644 --- a/Mathlib/Algebra/Module/Submodule/Union.lean +++ b/Mathlib/Algebra/Module/Submodule/Union.lean @@ -79,10 +79,10 @@ lemma Submodule.iUnion_ssubset_of_forall_ne_top_of_card_lt (s : Finset ι) (p : obtain ⟨z₁, -, z₂, -, h⟩ := exists_ne_map_eq_of_encard_lt_of_maps_to (by simpa) hf' exact ⟨z₁, z₂, h⟩ replace ht : y ∈ p k := by - have : (t₁ - t₂) • y ∈ p k := by convert sub_mem ht₁ ht₂ using 1; module + have : (t₁ - t₂) • y ∈ p k := by convert! sub_mem ht₁ ht₂ using 1; module refine ((p k).smul_mem_iff ?_).mp this rwa [sub_ne_zero] - replace ht : x ∈ p k := by convert sub_mem ht₁ ((p k).smul_mem t₁ ht); simp + replace ht : x ∈ p k := by convert! sub_mem ht₁ ((p k).smul_mem t₁ ht); simp simpa using ⟨k, hk, ht⟩ variable [Finite ι] [Infinite K] diff --git a/Mathlib/Algebra/Module/Torsion/Basic.lean b/Mathlib/Algebra/Module/Torsion/Basic.lean index 234865b3c92a94..31b3af552ce7d4 100644 --- a/Mathlib/Algebra/Module/Torsion/Basic.lean +++ b/Mathlib/Algebra/Module/Torsion/Basic.lean @@ -134,7 +134,7 @@ theorem iSupIndep.linearIndependent' {ι R M : Type*} {v : ι → M} [Ring R] have : r • v i ∈ (⊥ : Submodule R M) := by rw [← hv, Submodule.mem_inf] refine ⟨Submodule.mem_span_singleton.mpr ⟨r, rfl⟩, ?_⟩ - convert hi + convert! hi ext simp rw [← Submodule.mem_bot R, ← h_ne_zero i] @@ -495,7 +495,8 @@ theorem iSup_torsionBy_eq_torsionBy_prod (hq : (S : Set ι).Pairwise <| (IsCopri theorem supIndep_torsionBy (hq : (S : Set ι).Pairwise <| (IsCoprime on q)) : S.SupIndep fun i => torsionBy R M <| q i := by - convert supIndep_torsionBySet_ideal (M := M) fun i hi j hj ij => + convert! + supIndep_torsionBySet_ideal (M := M) fun i hi j hj ij => (Ideal.sup_eq_top_iff_isCoprime (q i) _).mpr <| hq hi hj ij exact (torsionBySet_span_singleton_eq (R := R) (M := M) _).symm @@ -534,7 +535,8 @@ theorem torsionBy_isInternal {q : ι → R} (hq : (S : Set ι).Pairwise <| (IsCo DirectSum.IsInternal fun i : S => torsionBy R M <| q i := by rw [← Module.isTorsionBySet_span_singleton_iff, Ideal.submodule_span_eq, ← Ideal.finset_inf_span_singleton _ _ hq, Finset.inf_eq_iInf] at hM - convert torsionBySet_isInternal + convert! + torsionBySet_isInternal (fun i hi j hj ij => (Ideal.sup_eq_top_iff_isCoprime (q i) _).mpr <| hq hi hj ij) hM exact (torsionBySet_span_singleton_eq _ (R := R) (M := M)).symm diff --git a/Mathlib/Algebra/Module/ZLattice/Basic.lean b/Mathlib/Algebra/Module/ZLattice/Basic.lean index 9587b73067d755..d64159380b87c0 100644 --- a/Mathlib/Algebra/Module/ZLattice/Basic.lean +++ b/Mathlib/Algebra/Module/ZLattice/Basic.lean @@ -220,7 +220,7 @@ theorem norm_fract_le [HasSolidNorm K] (m : E) : ‖fract b m‖ ≤ ∑ i, ‖b _ = ∑ i, ‖Int.fract (b.repr m i)‖ * ‖b i‖ := by simp_rw [norm_smul] _ ≤ ∑ i, ‖b i‖ := Finset.sum_le_sum fun i _ => ?_ suffices ‖Int.fract ((b.repr m) i)‖ ≤ 1 by - convert mul_le_mul_of_nonneg_right this (norm_nonneg _ : 0 ≤ ‖b i‖) + convert! mul_le_mul_of_nonneg_right this (norm_nonneg _ : 0 ≤ ‖b i‖) exact (one_mul _).symm rw [(norm_one.symm : 1 = ‖(1 : K)‖)] apply norm_le_norm_of_abs_le_abs @@ -321,7 +321,7 @@ instance [Finite ι] : DiscreteTopology (span ℤ (Set.range b)) := by have h : Set.MapsTo b.equivFun (span ℤ (Set.range b)) (span ℤ (Set.range (Pi.basisFun ℝ ι))) := by intro _ hx rwa [SetLike.mem_coe, Basis.mem_span_iff_repr_mem] at hx ⊢ - convert DiscreteTopology.of_continuous_injective ((continuous_equivFun_basis b).restrict h) ?_ + convert! DiscreteTopology.of_continuous_injective ((continuous_equivFun_basis b).restrict h) ?_ · exact discreteTopology_pi_basisFun · refine Subtype.map_injective _ (Basis.equivFun b).injective @@ -366,14 +366,14 @@ protected theorem isAddFundamentalDomain' [Finite ι] [MeasurableSpace E] [Opens theorem measure_fundamentalDomain_ne_zero [Finite ι] [MeasurableSpace E] [BorelSpace E] {μ : Measure E} [Measure.IsAddHaarMeasure μ] : μ (fundamentalDomain b) ≠ 0 := by - convert (ZSpan.isAddFundamentalDomain b μ).measure_ne_zero (NeZero.ne μ) + convert! (ZSpan.isAddFundamentalDomain b μ).measure_ne_zero (NeZero.ne μ) exact inferInstanceAs <| VAddInvariantMeasure (span ℤ (Set.range b)).toAddSubgroup E μ theorem measure_fundamentalDomain [Fintype ι] [DecidableEq ι] [MeasurableSpace E] (μ : Measure E) [BorelSpace E] [Measure.IsAddHaarMeasure μ] (b₀ : Basis ι ℝ E) : μ (fundamentalDomain b) = ENNReal.ofReal |b₀.det b| * μ (fundamentalDomain b₀) := by have : FiniteDimensional ℝ E := b.finiteDimensional_of_finite - convert μ.addHaar_preimage_linearEquiv (b.equiv b₀ (Equiv.refl ι)) (fundamentalDomain b₀) + convert! μ.addHaar_preimage_linearEquiv (b.equiv b₀ (Equiv.refl ι)) (fundamentalDomain b₀) · rw [Set.eq_preimage_iff_image_eq (LinearEquiv.bijective _), map_fundamentalDomain, Basis.map_equiv, Equiv.refl_symm, Basis.reindex_refl] · simp @@ -500,7 +500,7 @@ instance instModuleFinite_of_discrete_submodule {E : Type*} [NormedAddCommGroup suffices Module.Finite ℤ L₀ by have : L₀.map (f.restrictScalars ℤ) = L := SetLike.ext'_iff.mpr h_img - convert this ▸ Module.Finite.map L₀ (f.restrictScalars ℤ) + convert! this ▸ Module.Finite.map L₀ (f.restrictScalars ℤ) have : DiscreteTopology L₀ := by refine DiscreteTopology.preimage_of_continuous_injective (L : Set E) ?_ (injective_subtype _) exact LinearMap.continuous_of_finiteDimensional f @@ -534,7 +534,7 @@ theorem ZLattice.rank [hs : IsZLattice K L] : finrank ℤ L = finrank K E := by LinearIndependent.map' b₀.linearIndependent (L.subtype) (ker_subtype _) -- We prove some assertions that will be useful later on have h_spanL : span ℤ (Set.range b) = L := by - convert congrArg (map (Submodule.subtype L)) b₀.span_eq + convert! congrArg (map (Submodule.subtype L)) b₀.span_eq · rw [map_span, Set.range_comp] rfl · exact (map_subtype_top _).symm @@ -602,7 +602,7 @@ theorem ZLattice.rank [hs : IsZLattice K L] : finrank ℤ L = finrank K E := by · -- To prove that `finrank K E ≤ finrank ℤ L`, we use the fact `b` generates `E` over `K` -- and thus `finrank K E ≤ card b = finrank ℤ L` rw [← topEquiv.finrank_eq, ← h_spanE] - convert finrank_span_le_card (R := K) (Set.range b) + convert! finrank_span_le_card (R := K) (Set.range b) variable {ι : Type*} [hs : IsZLattice K L] (b : Basis ι ℤ L) @@ -647,7 +647,7 @@ theorem ZLattice.isAddFundamentalDomain {E : Type*} [NormedAddCommGroup E] [Norm [FiniteDimensional ℝ E] {L : Submodule ℤ E} [DiscreteTopology L] [IsZLattice ℝ L] [Finite ι] (b : Basis ι ℤ L) [MeasurableSpace E] [OpensMeasurableSpace E] (μ : Measure E) : IsAddFundamentalDomain L (fundamentalDomain (b.ofZLatticeBasis ℝ)) μ := by - convert ZSpan.isAddFundamentalDomain (b.ofZLatticeBasis ℝ) μ + convert! ZSpan.isAddFundamentalDomain (b.ofZLatticeBasis ℝ) μ all_goals exact (b.ofZLatticeBasis_span ℝ).symm instance instCountable_of_discrete_submodule {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] @@ -795,7 +795,7 @@ lemma IsZLattice.isCompact_range_of_periodic (hf' : ∀ z w, w ∈ L → f (z + w) = f z) : IsCompact (Set.range f) := by have := ZLattice.module_free ℝ L let b := Module.Free.chooseBasis ℤ L - convert (b.ofZLatticeBasis ℝ).parallelepiped.isCompact.image hf + convert! (b.ofZLatticeBasis ℝ).parallelepiped.isCompact.image hf refine le_antisymm ?_ (Set.image_subset_range _ _) rintro _ ⟨x, rfl⟩ let x' : L := b.repr.symm (Finsupp.equivFunOnFinite.symm diff --git a/Mathlib/Algebra/Module/ZLattice/Covolume.lean b/Mathlib/Algebra/Module/ZLattice/Covolume.lean index f80dac1228c44b..05d7349d94a083 100644 --- a/Mathlib/Algebra/Module/ZLattice/Covolume.lean +++ b/Mathlib/Algebra/Module/ZLattice/Covolume.lean @@ -313,7 +313,7 @@ theorem tendsto_card_div_pow (b : Basis ι ℤ L) {s : Set (ι → ℝ)} (hs₁ Tendsto (fun n : ℕ ↦ (Nat.card (s ∩ (n : ℝ)⁻¹ • L : Set (ι → ℝ)) : ℝ) / n ^ card ι) atTop (𝓝 (volume.real s / covolume L)) := by classical - convert tendsto_card_div_pow'' b hs₁ hs₂ ?_ + convert! tendsto_card_div_pow'' b hs₁ hs₂ ?_ · simp only [measureReal_def] rw [volume_image_eq_volume_div_covolume L b, ENNReal.toReal_div, ENNReal.toReal_ofReal (covolume_pos L volume).le] @@ -331,7 +331,7 @@ theorem tendsto_card_le_div {X : Set (ι → ℝ)} (hX : ∀ ⦃x⦄ ⦃r : ℝ refine Fintype.equivOfCardEq ?_ rw [← finrank_eq_card_chooseBasisIndex, ZLattice.rank ℝ, finrank_fintype_fun_eq_card] let b := (Module.Free.chooseBasis ℤ L).reindex e - convert tendsto_card_le_div'' b hX h₁ h₂ h₃ ?_ + convert! tendsto_card_le_div'' b hX h₁ h₂ h₃ ?_ · simp only [measureReal_def] rw [volume_image_eq_volume_div_covolume L b, ENNReal.toReal_div, ENNReal.toReal_ofReal (covolume_pos L volume).le] @@ -354,7 +354,7 @@ theorem tendsto_card_div_pow' {s : Set E} (hs₁ : IsBounded s) (hs₂ : Measura Tendsto (fun n : ℕ ↦ (Nat.card (s ∩ (n : ℝ)⁻¹ • L : Set E) : ℝ) / n ^ finrank ℝ E) atTop (𝓝 (volume.real s / covolume L)) := by let b := Module.Free.chooseBasis ℤ L - convert tendsto_card_div_pow'' b hs₁ hs₂ ?_ + convert! tendsto_card_div_pow'' b hs₁ hs₂ ?_ · rw [← finrank_eq_card_chooseBasisIndex, ZLattice.rank ℝ L] · simp only [measureReal_def] rw [volume_image_eq_volume_div_covolume' L b hs₂.nullMeasurableSet, ENNReal.toReal_div, @@ -373,7 +373,7 @@ theorem tendsto_card_le_div' [Nontrivial E] {X : Set E} {F : E → ℝ} Nat.card ({x ∈ X | F x ≤ c} ∩ L : Set E) / (c : ℝ)) atTop (𝓝 (volume.real {x ∈ X | F x ≤ 1} / covolume L)) := by let b := Module.Free.chooseBasis ℤ L - convert tendsto_card_le_div'' b hX ?_ h₂ h₃ ?_ + convert! tendsto_card_le_div'' b hX ?_ h₂ h₃ ?_ · simp only [measureReal_def] rw [volume_image_eq_volume_div_covolume' L b h₃.nullMeasurableSet, ENNReal.toReal_div, ENNReal.toReal_ofReal (covolume_pos L volume).le] diff --git a/Mathlib/Algebra/Module/ZLattice/Summable.lean b/Mathlib/Algebra/Module/ZLattice/Summable.lean index f5153042db9894..6eebe7ce684f72 100644 --- a/Mathlib/Algebra/Module/ZLattice/Summable.lean +++ b/Mathlib/Algebra/Module/ZLattice/Summable.lean @@ -194,7 +194,7 @@ lemma exists_finsetSum_norm_rpow_le_tsum : refine (Finset.sum_le_sum_of_subset_of_nonneg hn (by intros; positivity)).trans ?_ dsimp simp only [Submodule.norm_coe] - convert sum_piFinset_Icc_rpow_le b rfl n r hr with x + convert! sum_piFinset_Icc_rpow_le b rfl n r hr with x simp [e, Finsupp.linearCombination] by_cases hA' : A ≤ 1 · refine ⟨B, hB, fun r hr s ↦ (H r hr s).trans ?_⟩ diff --git a/Mathlib/Algebra/MonoidAlgebra/Basic.lean b/Mathlib/Algebra/MonoidAlgebra/Basic.lean index beafcef436f651..b31a6c45dcec4c 100644 --- a/Mathlib/Algebra/MonoidAlgebra/Basic.lean +++ b/Mathlib/Algebra/MonoidAlgebra/Basic.lean @@ -656,10 +656,10 @@ lemma algHom_ext_iff {φ₁ φ₂ : R[M] →ₐ[R] A} : (∀ x, φ₁ (single x variable (R A) in /-- `AddMonoidAlgebra.domCongr` as an `AddMonoidHom` from `AddAut`. -/ @[simps] -def domCongrAut : AddAut M →* A[M] ≃ₐ[R] A[M] where - toFun := AddMonoidAlgebra.domCongr R A - map_one' := by ext; simp [AddAut.one_def] - map_mul' _ _ := by ext; simp [AddAut.mul_def] +def domCongrAut : AddAut M →+ Additive (A[M] ≃ₐ[R] A[M]) where + toFun f := .ofMul (AddMonoidAlgebra.domCongr R A f) + map_zero' := by ext; simp [AddAut.zero_def] + map_add' _ _ := by ext; simp [AddAut.add_def] end lift diff --git a/Mathlib/Algebra/MonoidAlgebra/Grading.lean b/Mathlib/Algebra/MonoidAlgebra/Grading.lean index 4224d143ee24d4..618855dacd15c4 100644 --- a/Mathlib/Algebra/MonoidAlgebra/Grading.lean +++ b/Mathlib/Algebra/MonoidAlgebra/Grading.lean @@ -125,7 +125,7 @@ def decomposeAux : R[M] →ₐ[R] ⨁ i : ι, gradeBy R f i := symm dsimp +instances only [toAdd_one, Eq.ndrec, Set.mem_setOf_eq, ne_eq, OneHom.toFun_eq_coe, OneHom.coe_mk, toAdd_mul] - convert DirectSum.of_mul_of (A := (fun i : ι => gradeBy R f i)) _ _ + convert! DirectSum.of_mul_of (A := (fun i : ι => gradeBy R f i)) _ _ repeat { rw [map_add] } simp only [SetLike.coe_gMul] exact Eq.trans (by rw [one_mul]) (single_mul_single ..).symm } diff --git a/Mathlib/Algebra/MvPolynomial/Basic.lean b/Mathlib/Algebra/MvPolynomial/Basic.lean index f3eb44382587c7..5864892d7b989a 100644 --- a/Mathlib/Algebra/MvPolynomial/Basic.lean +++ b/Mathlib/Algebra/MvPolynomial/Basic.lean @@ -1029,7 +1029,7 @@ lemma mem_coeffsIn_iff_coeffs_subset : p ∈ coeffsIn σ M ↔ (p.coeffs : Set S refine ⟨fun h x _ ↦ h x, fun h i ↦ ?_⟩ by_cases hp : i ∈ p.support · exact h hp - · convert M.zero_mem + · convert! M.zero_mem simpa using hp end Module diff --git a/Mathlib/Algebra/MvPolynomial/Comap.lean b/Mathlib/Algebra/MvPolynomial/Comap.lean index 44f783485ab228..42d07387513d8b 100644 --- a/Mathlib/Algebra/MvPolynomial/Comap.lean +++ b/Mathlib/Algebra/MvPolynomial/Comap.lean @@ -78,7 +78,7 @@ theorem comap_comp (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R) theorem comap_eq_id_of_eq_id (f : MvPolynomial σ R →ₐ[R] MvPolynomial σ R) (hf : ∀ φ, f φ = φ) (x : σ → R) : comap f x = x := by - convert comap_id_apply x + convert! comap_id_apply x ext1 φ simp [hf, AlgHom.id_apply] diff --git a/Mathlib/Algebra/MvPolynomial/CommRing.lean b/Mathlib/Algebra/MvPolynomial/CommRing.lean index 179dbb992331bd..5c3e6834ebc6ba 100644 --- a/Mathlib/Algebra/MvPolynomial/CommRing.lean +++ b/Mathlib/Algebra/MvPolynomial/CommRing.lean @@ -112,13 +112,13 @@ section Vars theorem vars_neg : (-p).vars = p.vars := by simp [vars, degrees_neg] theorem vars_sub_subset [DecidableEq σ] : (p - q).vars ⊆ p.vars ∪ q.vars := by - convert vars_add_subset p (-q) using 2 <;> simp [sub_eq_add_neg] + convert! vars_add_subset p (-q) using 2 <;> simp [sub_eq_add_neg] @[simp] theorem vars_sub_of_disjoint [DecidableEq σ] (hpq : Disjoint p.vars q.vars) : (p - q).vars = p.vars ∪ q.vars := by rw [← vars_neg q] at hpq - convert vars_add_of_disjoint hpq using 2 <;> simp [sub_eq_add_neg] + convert! vars_add_of_disjoint hpq using 2 <;> simp [sub_eq_add_neg] end Vars diff --git a/Mathlib/Algebra/MvPolynomial/Degrees.lean b/Mathlib/Algebra/MvPolynomial/Degrees.lean index 0decdace651b86..7b595c7d04643f 100644 --- a/Mathlib/Algebra/MvPolynomial/Degrees.lean +++ b/Mathlib/Algebra/MvPolynomial/Degrees.lean @@ -82,7 +82,8 @@ def degrees (p : MvPolynomial σ R) : Multiset σ := p.support.sup fun s : σ →₀ ℕ => toMultiset s theorem degrees_def [DecidableEq σ] (p : MvPolynomial σ R) : - p.degrees = p.support.sup fun s : σ →₀ ℕ => Finsupp.toMultiset s := by rw [degrees]; convert rfl + p.degrees = p.support.sup fun s : σ →₀ ℕ => Finsupp.toMultiset s := by rw [degrees]; convert! + rfl theorem degrees_monomial (s : σ →₀ ℕ) (a : R) : degrees (monomial s a) ≤ toMultiset s := by classical @@ -217,7 +218,7 @@ def degreeOf (n : σ) (p : MvPolynomial σ R) : ℕ := p.degrees.count n theorem degreeOf_def [DecidableEq σ] (n : σ) (p : MvPolynomial σ R) : - p.degreeOf n = p.degrees.count n := by rw [degreeOf]; convert rfl + p.degreeOf n = p.degrees.count n := by rw [degreeOf]; convert! rfl theorem degreeOf_eq_sup (n : σ) (f : MvPolynomial σ R) : degreeOf n f = f.support.sup fun m => m n := by @@ -297,7 +298,7 @@ theorem degreeOf_mul_le (i : σ) (f g : MvPolynomial σ R) : degreeOf i (f * g) ≤ degreeOf i f + degreeOf i g := by classical simp only [degreeOf] - convert Multiset.count_le_of_le i degrees_mul_le + convert! Multiset.count_le_of_le i degrees_mul_le rw [Multiset.count_add] theorem degreeOf_sum_le {ι : Type*} (i : σ) (s : Finset ι) (f : ι → MvPolynomial σ R) : @@ -335,7 +336,7 @@ theorem degreeOf_mul_X_self (j : σ) (f : MvPolynomial σ R) : simp only [degreeOf] apply (Multiset.count_le_of_le j degrees_mul_le).trans simp only [Multiset.count_add, add_le_add_iff_left] - convert Multiset.count_le_of_le j <| degrees_X' j + convert! Multiset.count_le_of_le j <| degrees_X' j rw [Multiset.count_singleton_self] theorem degreeOf_X_pow_of_ne {i j : σ} (k : ℕ) (h : i ≠ j) : @@ -407,13 +408,13 @@ theorem degreeOf_eq_of_degreeOf_add_lt {i : σ} (h : (p + q).degreeOf i < p.degr theorem degreeOf_C_mul_le (p : MvPolynomial σ R) (i : σ) (c : R) : (C c * p).degreeOf i ≤ p.degreeOf i := by unfold degreeOf - convert Multiset.count_le_of_le i degrees_mul_le + convert! Multiset.count_le_of_le i degrees_mul_le simp only [degrees_C, zero_add] theorem degreeOf_mul_C_le (p : MvPolynomial σ R) (i : σ) (c : R) : (p * C c).degreeOf i ≤ p.degreeOf i := by unfold degreeOf - convert Multiset.count_le_of_le i degrees_mul_le + convert! Multiset.count_le_of_le i degrees_mul_le simp only [degrees_C, add_zero] theorem degreeOf_rename_of_injective {p : MvPolynomial σ R} {f : σ → τ} (h : Function.Injective f) diff --git a/Mathlib/Algebra/MvPolynomial/Equiv.lean b/Mathlib/Algebra/MvPolynomial/Equiv.lean index 7f75f77ee60549..2999a5ddaaf116 100644 --- a/Mathlib/Algebra/MvPolynomial/Equiv.lean +++ b/Mathlib/Algebra/MvPolynomial/Equiv.lean @@ -499,7 +499,7 @@ theorem optionEquivLeft_elim_eval (s : S₁ → R) (y : R) (f : MvPolynomial (Op let φ : (MvPolynomial S₁ R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by - convert Polynomial.map_C (eval s) + convert! Polynomial.map_C (eval s) exact (eval_C _).symm } change aeval (fun x ↦ Option.elim x y s) f = @@ -681,7 +681,7 @@ theorem eval_eq_eval_mv_eval' (s : Fin n → R) (y : R) (f : MvPolynomial (Fin ( let φ : (MvPolynomial (Fin n) R)[X] →ₐ[R] R[X] := { Polynomial.mapRingHom (eval s) with commutes' := fun r => by - convert Polynomial.map_C (eval s) + convert! Polynomial.map_C (eval s) exact (eval_C _).symm } change aeval (Fin.cons y s : Fin (n + 1) → R) f = @@ -725,7 +725,7 @@ lemma totalDegree_coeff_finSuccEquiv_add_le (f : MvPolynomial (Fin (n + 1)) R) ( (fun s => Finsupp.sum s fun _ e => e) -- Then cons i σ is a monomial index of p with total degree equal to the desired bound let σ' : Fin (n + 1) →₀ ℕ := cons i σ - convert le_totalDegree (s := σ') _ + convert! le_totalDegree (s := σ') _ · rw [totalDegree, hσ2, sum_cons, add_comm] · rw [← mem_support_coeff_finSuccEquiv] exact hσ1 @@ -802,7 +802,7 @@ lemma degreeOf_eq_natDegree [DecidableEq σ] (a : σ) (p : MvPolynomial σ R) : degreeOf a p = (optionEquivLeft R {b // b ≠ a} (rename (Equiv.optionSubtypeNe a).symm p)).natDegree := by rw [natDegree_optionEquivLeft, eq_comm] - convert degreeOf_rename_of_injective (Equiv.injective (Equiv.optionSubtypeNe a).symm) a + convert! degreeOf_rename_of_injective (Equiv.injective (Equiv.optionSubtypeNe a).symm) a rw [Equiv.optionSubtypeNe_symm_apply, dif_pos rfl] theorem degreeOf_coeff_finSuccEquiv (p : MvPolynomial (Fin (n + 1)) R) (j : Fin n) (i : ℕ) : @@ -874,6 +874,10 @@ lemma Polynomial.toMvPolynomial_injective (i : σ) : EquivLike.injective_comp] exact MvPolynomial.rename_injective (fun x ↦ i) fun _ _ _ ↦ rfl +lemma Polynomial.toMvPolynomial_inj {i : σ} {p q : R[X]} : + toMvPolynomial (R := R) i p = toMvPolynomial i q ↔ p = q := + ⟨fun h ↦ Polynomial.toMvPolynomial_injective i h, fun h ↦ by rw [h]⟩ + @[simp] lemma MvPolynomial.eval_comp_toMvPolynomial (f : σ → R) (i : σ) : (eval f).comp (toMvPolynomial (R := R) i) = Polynomial.evalRingHom (f i) := by diff --git a/Mathlib/Algebra/MvPolynomial/Funext.lean b/Mathlib/Algebra/MvPolynomial/Funext.lean index e4bc0a79200a5e..571af32ac4a8d0 100644 --- a/Mathlib/Algebra/MvPolynomial/Funext.lean +++ b/Mathlib/Algebra/MvPolynomial/Funext.lean @@ -37,7 +37,7 @@ private theorem funext_fin {n : ℕ} {p : MvPolynomial (Fin n) R} | zero => apply (MvPolynomial.isEmptyRingEquiv R (Fin 0)).injective rw [map_zero] - convert h _ finZeroElim + convert! h _ finZeroElim | succ n ih => apply (finSuccEquiv R n).injective rw [map_zero] @@ -66,7 +66,7 @@ theorem funext_set (h : ∀ x ∈ Set.pi .univ s, eval x p = eval x q) : suffices p = 0 by rw [this, map_zero] refine funext_fin (s ∘ f) (fun _ ↦ hs _) fun x hx ↦ ?_ choose g hg using fun i ↦ (hs i).nonempty - convert h (Function.extend f x g) fun i _ ↦ ?_ + convert! h (Function.extend f x g) fun i _ ↦ ?_ · simp only [eval, eval₂Hom_rename, Function.extend_comp hf] obtain ⟨i, rfl⟩ | nex := em (∃ x, f x = i) · rw [hf.extend_apply]; exact hx _ ⟨⟩ diff --git a/Mathlib/Algebra/MvPolynomial/Nilpotent.lean b/Mathlib/Algebra/MvPolynomial/Nilpotent.lean index 4c3e1149197c78..817993a0c2ab17 100644 --- a/Mathlib/Algebra/MvPolynomial/Nilpotent.lean +++ b/Mathlib/Algebra/MvPolynomial/Nilpotent.lean @@ -63,7 +63,7 @@ theorem isUnit_iff : IsUnit P ↔ IsUnit (P.coeff 0) ∧ ∀ i ≠ 0, IsNilpoten let e := (optionEquivLeft _ _).symm.trans (renameEquiv R (Equiv.optionSubtypeNe i)) have H := (Polynomial.coeff_isUnit_isNilpotent_of_isUnit (H.map e.symm)).2 (n i) hi simp only [ne_eq, isNilpotent_iff] at H - convert ← H (n.equivMapDomain (Equiv.optionSubtypeNe i).symm).some + convert! ← H (n.equivMapDomain (Equiv.optionSubtypeNe i).symm).some refine (optionEquivLeft_coeff_some_coeff_none _ _ _ _).trans ?_ simp [Finsupp.equivMapDomain_eq_mapDomain, coeff_rename_mapDomain _ (Equiv.optionSubtypeNe i).symm.injective] @@ -79,7 +79,7 @@ instance : IsLocalHom (algebraMap R (MvPolynomial σ R)) := theorem isUnit_iff_totalDegree_of_isReduced [IsReduced R] : IsUnit P ↔ IsUnit (P.coeff 0) ∧ P.totalDegree = 0 := by - convert isUnit_iff (P := P) + convert! isUnit_iff (P := P) rw [totalDegree_eq_zero_iff] simp [not_imp_comm (a := _ = (0 : R)), Finsupp.ext_iff] diff --git a/Mathlib/Algebra/MvPolynomial/Variables.lean b/Mathlib/Algebra/MvPolynomial/Variables.lean index 7e19c42a224604..a832754446ea5a 100644 --- a/Mathlib/Algebra/MvPolynomial/Variables.lean +++ b/Mathlib/Algebra/MvPolynomial/Variables.lean @@ -72,7 +72,7 @@ def vars (p : MvPolynomial σ R) : Finset σ := theorem vars_def [DecidableEq σ] (p : MvPolynomial σ R) : p.vars = p.degrees.toFinset := by rw [vars] - convert rfl + convert! rfl @[simp] theorem vars_0 : (0 : MvPolynomial σ R).vars = ∅ := by diff --git a/Mathlib/Algebra/Notation/Indicator.lean b/Mathlib/Algebra/Notation/Indicator.lean index 4bd45854615a3f..0e659ac8b3a3c5 100644 --- a/Mathlib/Algebra/Notation/Indicator.lean +++ b/Mathlib/Algebra/Notation/Indicator.lean @@ -204,7 +204,7 @@ lemma mulIndicator_inter_mulSupport (s : Set α) (f : α → M) : lemma comp_mulIndicator (h : M → β) (f : α → M) {s : Set α} {x : α} [DecidablePred (· ∈ s)] : h (s.mulIndicator f x) = s.piecewise (h ∘ f) (const α (h 1)) x := by letI := Classical.decPred (· ∈ s) - convert s.apply_piecewise f (const α 1) (fun _ => h) (x := x) using 2 + convert! s.apply_piecewise f (const α 1) (fun _ => h) (x := x) using 2 @[to_additive] lemma mulIndicator_comp_right {s : Set α} (f : β → α) {g : α → M} {x : β} : diff --git a/Mathlib/Algebra/Order/Antidiag/Finsupp.lean b/Mathlib/Algebra/Order/Antidiag/Finsupp.lean index 5f98bc13254b64..7d7efc43d009cf 100644 --- a/Mathlib/Algebra/Order/Antidiag/Finsupp.lean +++ b/Mathlib/Algebra/Order/Antidiag/Finsupp.lean @@ -141,9 +141,9 @@ lemma mapRange_finsuppAntidiag_eq {e : μ ≃+ μ'} {s : Finset ι} {n : μ} : rw [mem_map_equiv, this] apply mapRange_finsuppAntidiag_subset rw [← mem_map_equiv] - convert hf + convert! hf rw [map_map, hh] - convert map_refl + convert! map_refl apply Function.Embedding.equiv_symm_toEmbedding_trans_toEmbedding end AddCommMonoid diff --git a/Mathlib/Algebra/Order/Antidiag/Nat.lean b/Mathlib/Algebra/Order/Antidiag/Nat.lean index 1da55e696c5940..0aa55fa23256da 100644 --- a/Mathlib/Algebra/Order/Antidiag/Nat.lean +++ b/Mathlib/Algebra/Order/Antidiag/Nat.lean @@ -192,7 +192,7 @@ private theorem primeFactorsPiBij_inj (d n : ℕ) dsimp only [Nat.primeFactorsPiBij] apply ne_of_mem_of_not_mem (s := {x | p ∣ x}) <;> simp_rw [Set.mem_setOf_eq] · rw [Finset.prod_filter] - convert Finset.dvd_prod_of_mem _ (mem_attach (n.primeFactors) ⟨p, hp⟩) + convert! Finset.dvd_prod_of_mem _ (mem_attach (n.primeFactors) ⟨p, hp⟩) rw [if_pos rfl] · rw [mem_primeFactors] at hp rw [Prime.dvd_finsetProd_iff hp.1.prime] diff --git a/Mathlib/Algebra/Order/Antidiag/Prod.lean b/Mathlib/Algebra/Order/Antidiag/Prod.lean index 9217a07c264188..e53c0810966ba6 100644 --- a/Mathlib/Algebra/Order/Antidiag/Prod.lean +++ b/Mathlib/Algebra/Order/Antidiag/Prod.lean @@ -77,6 +77,7 @@ instance [AddMonoid A] : Subsingleton (HasAntidiagonal A) where -- The goal of this lemma is to allow to rewrite antidiagonal -- when the decidability instances obfuscate Lean +set_option linter.overlappingInstances false in lemma hasAntidiagonal_congr (A : Type*) [AddMonoid A] [H1 : HasAntidiagonal A] [H2 : HasAntidiagonal A] : H1.antidiagonal = H2.antidiagonal := by congr!; subsingleton diff --git a/Mathlib/Algebra/Order/Archimedean/Class.lean b/Mathlib/Algebra/Order/Archimedean/Class.lean index 6ce4fd44749f45..0d946dc1124554 100644 --- a/Mathlib/Algebra/Order/Archimedean/Class.lean +++ b/Mathlib/Algebra/Order/Archimedean/Class.lean @@ -678,7 +678,7 @@ theorem mem_closedBallSubgroup_iff {a : M} {c : MulArchimedeanClass M} : variable (M) in @[to_additive (attr := simp)] theorem ballSubgroup_top : ballSubgroup (M := M) ⊤ = ⊥ := by - convert subgroup_eq_bot M + convert! subgroup_eq_bot M simp variable (M) in diff --git a/Mathlib/Algebra/Order/BigOperators/Group/Finset.lean b/Mathlib/Algebra/Order/BigOperators/Group/Finset.lean index dbca76f00bf72b..1da58707e8c8cc 100644 --- a/Mathlib/Algebra/Order/BigOperators/Group/Finset.lean +++ b/Mathlib/Algebra/Order/BigOperators/Group/Finset.lean @@ -677,7 +677,7 @@ alias finset_sum_eq_sup_iff_disjoint := finsetSum_eq_sup_iff_disjoint theorem sup_powerset_len [DecidableEq α] (x : Multiset α) : (Finset.sup (Finset.range (card x + 1)) fun k => x.powersetCard k) = x.powerset := by - convert bind_powerset_len x using 1 + convert! bind_powerset_len x using 1 rw [Multiset.bind, Multiset.join, ← Finset.range_val, ← Finset.sum_eq_multiset_sum] exact Eq.symm (finsetSum_eq_sup_iff_disjoint.mpr fun _ _ _ _ h => pairwise_disjoint_powersetCard x h) diff --git a/Mathlib/Algebra/Order/BigOperators/GroupWithZero/Finset.lean b/Mathlib/Algebra/Order/BigOperators/GroupWithZero/Finset.lean index bdfe4ca17dd65e..f94bbb07939676 100644 --- a/Mathlib/Algebra/Order/BigOperators/GroupWithZero/Finset.lean +++ b/Mathlib/Algebra/Order/BigOperators/GroupWithZero/Finset.lean @@ -48,7 +48,7 @@ lemma prod_le_prod (h0 : ∀ i ∈ s, 0 ≤ f i) (h1 : ∀ i ∈ s, f i ≤ g i) /-- If each `f i`, `i ∈ s` belongs to `[0, 1]`, then their product is less than or equal to one. See also `Finset.prod_le_one'` for the case of an ordered commutative multiplicative monoid. -/ lemma prod_le_one (h0 : ∀ i ∈ s, 0 ≤ f i) (h1 : ∀ i ∈ s, f i ≤ 1) : ∏ i ∈ s, f i ≤ 1 := by - convert ← prod_le_prod h0 h1 + convert! ← prod_le_prod h0 h1 exact Finset.prod_const_one /-- A version of `Finset.one_le_prod'` for `PosMulMono` in place of `MulLeftMono`. -/ diff --git a/Mathlib/Algebra/Order/BigOperators/GroupWithZero/List.lean b/Mathlib/Algebra/Order/BigOperators/GroupWithZero/List.lean index 1c670ac4fb37e8..db81bed9305aa6 100644 --- a/Mathlib/Algebra/Order/BigOperators/GroupWithZero/List.lean +++ b/Mathlib/Algebra/Order/BigOperators/GroupWithZero/List.lean @@ -56,7 +56,7 @@ theorem prod_map_le_prod_map₀ {ι : Type*} {s : List ι} (f : ι → R) (g : theorem prod_map_le_pow_length₀ {F L : Type*} [FunLike F L R] {f : F} {r : R} {t : List L} (hf0 : ∀ x ∈ t, 0 ≤ f x) (hf : ∀ x ∈ t, f x ≤ r) : (map f t).prod ≤ r ^ length t := by - convert prod_map_le_prod_map₀ f (Function.const L r) hf0 hf + convert! prod_map_le_prod_map₀ f (Function.const L r) hf0 hf simp [map_const, prod_replicate] omit [PosMulMono R] diff --git a/Mathlib/Algebra/Order/CauSeq/Basic.lean b/Mathlib/Algebra/Order/CauSeq/Basic.lean index dcacc72c459780..68952d25c4f114 100644 --- a/Mathlib/Algebra/Order/CauSeq/Basic.lean +++ b/Mathlib/Algebra/Order/CauSeq/Basic.lean @@ -631,7 +631,7 @@ instance : LE (CauSeq α abs) := theorem lt_of_lt_of_eq {f g h : CauSeq α abs} (fg : f < g) (gh : g ≈ h) : f < h := show Pos (h - f) by - convert pos_add_limZero fg (neg_limZero gh) using 1 + convert! pos_add_limZero fg (neg_limZero gh) using 1 simp theorem lt_of_eq_of_lt {f g h : CauSeq α abs} (fg : f ≈ g) (gh : g < h) : f < h := by @@ -640,7 +640,7 @@ theorem lt_of_eq_of_lt {f g h : CauSeq α abs} (fg : f ≈ g) (gh : g < h) : f < theorem lt_trans {f g h : CauSeq α abs} (fg : f < g) (gh : g < h) : f < h := show Pos (h - f) by - convert add_pos fg gh using 1 + convert! add_pos fg gh using 1 simp theorem lt_irrefl {f : CauSeq α abs} : ¬f < f diff --git a/Mathlib/Algebra/Order/CompleteField.lean b/Mathlib/Algebra/Order/CompleteField.lean index b27461635cb892..368aabd6624c2a 100644 --- a/Mathlib/Algebra/Order/CompleteField.lean +++ b/Mathlib/Algebra/Order/CompleteField.lean @@ -266,7 +266,7 @@ def inducedOrderRingHom : α →+*o β := suffices ∀ x, 0 < x → inducedAddHom α β (x * x) = inducedAddHom α β x * inducedAddHom α β x by intro x obtain h | rfl | h := lt_trichotomy x 0 - · convert this (-x) (neg_pos.2 h) using 1 + · convert! this (-x) (neg_pos.2 h) using 1 · rw [neg_mul, mul_neg, neg_neg] · simp_rw [map_neg, neg_mul, mul_neg, neg_neg] · simp only [mul_zero, map_zero] @@ -288,7 +288,7 @@ def inducedOrderRingIso : β ≃+*o γ := map_le_map_iff' := by dsimp refine ⟨fun h => ?_, fun h => inducedMap_mono _ _ h⟩ - convert inducedMap_mono γ β h <;> + convert! inducedMap_mono γ β h <;> · rw [inducedOrderRingHom, AddMonoidHom.coe_fn_mkRingHomOfMulSelfOfTwoNeZero, inducedAddHom] dsimp rw [inducedMap_inv_self β γ _] } diff --git a/Mathlib/Algebra/Order/Field/Basic.lean b/Mathlib/Algebra/Order/Field/Basic.lean index 25b0ac4f017443..d3df4f72f66b0c 100644 --- a/Mathlib/Algebra/Order/Field/Basic.lean +++ b/Mathlib/Algebra/Order/Field/Basic.lean @@ -217,10 +217,10 @@ theorem inv_strictAntiOn : StrictAntiOn (fun x : α => x⁻¹) (Set.Ioi 0) := fu (inv_lt_inv₀ hy hx).2 xy theorem inv_pow_le_inv_pow_of_le (a1 : 1 ≤ a) {m n : ℕ} (mn : m ≤ n) : (a ^ n)⁻¹ ≤ (a ^ m)⁻¹ := by - convert one_div_pow_le_one_div_pow_of_le a1 mn using 1 <;> simp + convert! one_div_pow_le_one_div_pow_of_le a1 mn using 1 <;> simp theorem inv_pow_lt_inv_pow_of_lt (a1 : 1 < a) {m n : ℕ} (mn : m < n) : (a ^ n)⁻¹ < (a ^ m)⁻¹ := by - convert one_div_pow_lt_one_div_pow_of_lt a1 mn using 1 <;> simp + convert! one_div_pow_lt_one_div_pow_of_lt a1 mn using 1 <;> simp theorem inv_pow_anti (a1 : 1 ≤ a) : Antitone fun n : ℕ => (a ^ n)⁻¹ := fun _ _ => inv_pow_le_inv_pow_of_le a1 @@ -236,7 +236,7 @@ theorem le_iff_forall_one_lt_le_mul₀ {α : Type*} · simp_rw [zero_mul] at h exact h 2 one_lt_two refine le_of_forall_gt_imp_ge_of_dense fun x hbx => ?_ - convert h (x / b) ((one_lt_div hb).mpr hbx) + convert! h (x / b) ((one_lt_div hb).mpr hbx) rw [mul_div_cancel₀ _ hb.ne'] theorem div_nat_le_self_of_nonnneg (ha : 0 ≤ a) (n : ℕ) : a / n ≤ a := @@ -425,22 +425,22 @@ theorem sub_inv_antitoneOn_Icc_left (ha : b < c) : theorem inv_antitoneOn_Ioi : AntitoneOn (fun x : α ↦ x⁻¹) (Set.Ioi 0) := by - convert sub_inv_antitoneOn_Ioi (α := α) + convert! sub_inv_antitoneOn_Ioi (α := α) exact (sub_zero _).symm theorem inv_antitoneOn_Iio : AntitoneOn (fun x : α ↦ x⁻¹) (Set.Iio 0) := by - convert sub_inv_antitoneOn_Iio (α := α) + convert! sub_inv_antitoneOn_Iio (α := α) exact (sub_zero _).symm theorem inv_antitoneOn_Icc_right (ha : 0 < a) : AntitoneOn (fun x : α ↦ x⁻¹) (Set.Icc a b) := by - convert sub_inv_antitoneOn_Icc_right ha + convert! sub_inv_antitoneOn_Icc_right ha exact (sub_zero _).symm theorem inv_antitoneOn_Icc_left (hb : b < 0) : AntitoneOn (fun x : α ↦ x⁻¹) (Set.Icc a b) := by - convert sub_inv_antitoneOn_Icc_left hb + convert! sub_inv_antitoneOn_Icc_left hb exact (sub_zero _).symm /-! ### Relating two divisions -/ @@ -538,7 +538,9 @@ theorem sub_one_div_inv_le_two (a2 : 2 ≤ a) : (1 - 1 / a)⁻¹ ≤ 2 := by -- move `1 / a` to the left and `2⁻¹` to the right. rw [le_sub_iff_add_le, add_comm, ← le_sub_iff_add_le] -- take inverses on both sides and use the assumption `2 ≤ a`. - convert (one_div a).le.trans (inv_anti₀ zero_lt_two a2) using 1 + convert! (one_div a).le.trans (inv_anti₀ zero_lt_two a2) using 1 + -- show `1 - 1 / 2 = 1 / 2`. + -- show `1 - 1 / 2 = 1 / 2`. rw [sub_eq_iff_eq_add, ← two_mul, mul_inv_cancel₀ two_ne_zero] diff --git a/Mathlib/Algebra/Order/Floor/Ring.lean b/Mathlib/Algebra/Order/Floor/Ring.lean index 51a93b92512cf2..b6a38d85ba6a37 100644 --- a/Mathlib/Algebra/Order/Floor/Ring.lean +++ b/Mathlib/Algebra/Order/Floor/Ring.lean @@ -271,7 +271,7 @@ theorem mul_fract_eq_one_iff_exists_int {x : R} {k : R} (hk : 1 < k) : rw [fract, mul_sub, sub_eq_iff_eq_add'] refine ⟨fun hx ↦ ⟨⌊x⌋, hx⟩, ?_⟩ rintro ⟨n, hn⟩ - convert hn + convert! hn have hk0 : 0 < (k : R) := zero_le_one.trans_lt hk rw [floor_eq_iff, ← mul_le_mul_iff_right₀ hk0, ← mul_lt_mul_iff_right₀ hk0, hn] simp [mul_add, hk] @@ -674,7 +674,7 @@ theorem ceil_sub_intCast (a : R) (z : ℤ) : ⌈a - z⌉ = ⌈a⌉ - z := @[simp] theorem ceil_sub_natCast (a : R) (n : ℕ) : ⌈a - n⌉ = ⌈a⌉ - n := by - convert ceil_sub_intCast a n using 1 + convert! ceil_sub_intCast a n using 1 simp @[simp] @@ -772,7 +772,7 @@ lemma ceil_div_ceil_inv_sub_one (ha : 1 ≤ a) : ⌈⌈(a - 1)⁻¹⌉ / a⌉ = refine le_antisymm (ceil_le.2 <| div_le_self (by positivity) ha.le) <| ?_ rw [le_ceil_iff, sub_lt_comm, div_eq_mul_inv, ← mul_one_sub, ← lt_div_iff₀ (sub_pos.2 <| inv_lt_one_of_one_lt₀ ha)] - convert ceil_lt_add_one (R := k) _ using 1 + convert! ceil_lt_add_one (R := k) _ using 1 field lemma ceil_lt_mul (hb : 1 < b) (hba : ⌈(b - 1)⁻¹⌉ / b < a) : ⌈a⌉ < b * a := by diff --git a/Mathlib/Algebra/Order/Floor/Semifield.lean b/Mathlib/Algebra/Order/Floor/Semifield.lean index e3bdf9a4329851..49670521edd546 100644 --- a/Mathlib/Algebra/Order/Floor/Semifield.lean +++ b/Mathlib/Algebra/Order/Floor/Semifield.lean @@ -45,7 +45,7 @@ theorem floor_div_ofNat (a : K) (n : ℕ) [n.AtLeastTwo] : /-- Natural division is the floor of field division. -/ theorem floor_div_eq_div (m n : ℕ) : ⌊(m : K) / n⌋₊ = m / n := by - convert floor_div_natCast (m : K) n + convert! floor_div_natCast (m : K) n rw [m.floor_natCast] end LinearOrderedSemifield diff --git a/Mathlib/Algebra/Order/Group/Int/Sum.lean b/Mathlib/Algebra/Order/Group/Int/Sum.lean index b325c6fd59c347..ed9a90f4a2ba7f 100644 --- a/Mathlib/Algebra/Order/Group/Int/Sum.lean +++ b/Mathlib/Algebra/Order/Group/Int/Sum.lean @@ -45,7 +45,7 @@ lemma sum_le_sum_Ioc {s : Finset ℤ} {c : ℤ} (hs : ∀ x ∈ s, x ≤ c) : /-- Sharp upper bound for the sum of a finset of integers that is bounded above, `range` version. -/ lemma sum_le_sum_range {s : Finset ℤ} {c : ℤ} (hs : ∀ x ∈ s, x ≤ c) : ∑ x ∈ s, x ≤ ∑ n ∈ range #s, (c - n) := by - convert sum_le_sum_Ioc hs + convert! sum_le_sum_Ioc hs refine sum_nbij (c - ·) ?_ ?_ ?_ (fun _ _ ↦ rfl) · intro x mx; rw [mem_Ioc]; dsimp only; rw [mem_range] at mx; lia · intro x mx y my (h : c - x = c - y); lia @@ -71,7 +71,7 @@ lemma sum_Ico_le_sum {s : Finset ℤ} {c : ℤ} (hs : ∀ x ∈ s, c ≤ x) : /-- Sharp lower bound for the sum of a finset of integers that is bounded below, `range` version. -/ lemma sum_range_le_sum {s : Finset ℤ} {c : ℤ} (hs : ∀ x ∈ s, c ≤ x) : ∑ n ∈ range #s, (c + n) ≤ ∑ x ∈ s, x := by - convert sum_Ico_le_sum hs + convert! sum_Ico_le_sum hs refine sum_nbij (c + ·) ?_ ?_ ?_ (fun _ _ ↦ rfl) · intro x mx; rw [mem_Ico]; dsimp only; rw [mem_range] at mx; lia · intro x mx y my (h : c + x = c + y); lia diff --git a/Mathlib/Algebra/Order/Group/Unbundled/Abs.lean b/Mathlib/Algebra/Order/Group/Unbundled/Abs.lean index 307d844fe2d132..4bfefb2a0f32e8 100644 --- a/Mathlib/Algebra/Order/Group/Unbundled/Abs.lean +++ b/Mathlib/Algebra/Order/Group/Unbundled/Abs.lean @@ -133,10 +133,10 @@ lemma mabs_mabs_div_mabs_le (a b : α) : |(|a|ₘ / |b|ₘ)|ₘ ≤ |a / b|ₘ : rw [mabs, sup_le_iff] constructor · apply div_le_iff_le_mul.2 - convert mabs_mul_le (a / b) b + convert! mabs_mul_le (a / b) b rw [div_mul_cancel] · rw [div_eq_mul_inv, mul_inv_rev, inv_inv, mul_inv_le_iff_le_mul, mabs_div_comm] - convert mabs_mul_le (b / a) a + convert! mabs_mul_le (b / a) a · rw [div_mul_cancel] @[to_additive] lemma sup_div_inf_eq_mabs_div (a b : α) : (a ⊔ b) / (a ⊓ b) = |b / a|ₘ := by diff --git a/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean b/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean index c2945a3447455b..a3dd23fc9da2e6 100644 --- a/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean +++ b/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean @@ -16,6 +16,7 @@ public import Mathlib.Algebra.Order.Group.Units public import Mathlib.Algebra.Order.GroupWithZero.Unbundled.Basic public import Mathlib.Algebra.Order.Monoid.OrderDual public import Mathlib.Algebra.Order.Monoid.TypeTags +public import Mathlib.Data.Int.Basic public import Mathlib.Data.Set.Function /-! @@ -577,6 +578,20 @@ lemma lt_mul_exp_iff_le {x y : ℤᵐ⁰} (hy : y ≠ 0) : x < y * exp 1 ↔ x lift x to Multiplicative ℤ using hx rw [← log_le_log, ← log_lt_log] <;> simp [log_mul, Int.lt_add_one_iff] +lemma exists_exp_neg_natCast_lt {x : ℤᵐ⁰} (hx : x ≠ 0) : + ∃ (k : ℕ), exp (-(k : ℤ)) < x := by + obtain ⟨y, hnz, hyx⟩ := WithZero.exists_ne_zero_and_lt hx + use (-y.log).toNat + apply lt_of_le_of_lt _ hyx + rw [← WithZero.le_log_iff_exp_le hnz, Int.neg_le_iff] + exact Int.self_le_toNat _ + +lemma exists_exp_neg_natCast_lt_and_lt {x y : ℤᵐ⁰} (hx : x ≠ 0) (hy : y ≠ 0) : + ∃ (k : ℕ), exp (-(k : ℤ)) < x ∧ exp (-(k : ℤ)) < y := by + obtain ⟨z, hz, hzx, hzy⟩ := WithZero.exists_ne_zero_and_le_and_le hx hy + obtain ⟨k, hk⟩ := exists_exp_neg_natCast_lt hz + grind + lemma le_exp_log {x : Gᵐ⁰} : x ≤ exp (log x) := by cases x diff --git a/Mathlib/Algebra/Order/Hom/Monoid.lean b/Mathlib/Algebra/Order/Hom/Monoid.lean index 61b4fa4b088fe8..64b8eb756a69a8 100644 --- a/Mathlib/Algebra/Order/Hom/Monoid.lean +++ b/Mathlib/Algebra/Order/Hom/Monoid.lean @@ -320,11 +320,11 @@ theorem coe_orderHom (f : α →*o β) : ((f : α →o β) : α → β) = f := @[to_additive] theorem toMonoidHom_injective : Injective (toMonoidHom : _ → α →* β) := fun f g h => - ext <| by convert DFunLike.ext_iff.1 h using 0 + ext <| by convert! DFunLike.ext_iff.1 h using 0 @[to_additive] theorem toOrderHom_injective : Injective (toOrderHom : _ → α →o β) := fun f g h => - ext <| by convert DFunLike.ext_iff.1 h using 0 + ext <| by convert! DFunLike.ext_iff.1 h using 0 /-- Copy of an `OrderMonoidHom` with a new `toFun` equal to the old one. Useful to fix definitional equalities. -/ @@ -548,11 +548,11 @@ theorem coe_orderIso (f : α ≃*o β) : ((f : α →o β) : α → β) = f := @[to_additive] theorem toMulEquiv_injective : Injective (toMulEquiv : _ → α ≃* β) := fun f g h => - ext <| by convert DFunLike.ext_iff.1 h using 0 + ext <| by convert! DFunLike.ext_iff.1 h using 0 @[to_additive] theorem toOrderIso_injective : Injective (toOrderIso : _ → α ≃o β) := fun f g h => - ext <| by convert DFunLike.ext_iff.1 h using 0 + ext <| by convert! DFunLike.ext_iff.1 h using 0 variable (α) @@ -736,7 +736,7 @@ protected lemma strictMono : StrictMono f := protected lemma strictMono_symm : StrictMono f.symm := strictMono_of_le_iff_le <| fun a b ↦ by rw [← map_le_map_iff f] - convert Iff.rfl <;> + convert! Iff.rfl <;> exact f.toEquiv.apply_symm_apply _ end Preorder diff --git a/Mathlib/Algebra/Order/Hom/MonoidWithZero.lean b/Mathlib/Algebra/Order/Hom/MonoidWithZero.lean index 82a46fa3173df0..75788dbd1d66da 100644 --- a/Mathlib/Algebra/Order/Hom/MonoidWithZero.lean +++ b/Mathlib/Algebra/Order/Hom/MonoidWithZero.lean @@ -131,10 +131,10 @@ theorem coe_orderMonoidHom (f : α →*₀o β) : ⇑(f : α →*o β) = f := rfl theorem toOrderMonoidHom_injective : Injective (toOrderMonoidHom : _ → α →*o β) := fun f g h => - ext <| by convert DFunLike.ext_iff.1 h using 0 + ext <| by convert! DFunLike.ext_iff.1 h using 0 theorem toMonoidWithZeroHom_injective : Injective (toMonoidWithZeroHom : _ → α →*₀ β) := - fun f g h => ext <| by convert DFunLike.ext_iff.1 h using 0 + fun f g h => ext <| by convert! DFunLike.ext_iff.1 h using 0 /-- Copy of an `OrderMonoidWithZeroHom` with a new `toFun` equal to the old one. Useful to fix definitional equalities. -/ diff --git a/Mathlib/Algebra/Order/Hom/Ring.lean b/Mathlib/Algebra/Order/Hom/Ring.lean index a3feecbe0a6ee6..d78055b1526ca8 100644 --- a/Mathlib/Algebra/Order/Hom/Ring.lean +++ b/Mathlib/Algebra/Order/Hom/Ring.lean @@ -463,7 +463,7 @@ theorem coe_toOrderRingHom_refl : (OrderRingIso.refl α : α →+*o α) = OrderR rfl theorem toOrderRingHom_injective : Injective (toOrderRingHom : α ≃+*o β → α →+*o β) := - fun f g h => DFunLike.coe_injective <| by convert DFunLike.ext'_iff.1 h using 0 + fun f g h => DFunLike.coe_injective <| by convert! DFunLike.ext'_iff.1 h using 0 end NonAssocSemiring diff --git a/Mathlib/Algebra/Order/Invertible.lean b/Mathlib/Algebra/Order/Invertible.lean index ccdf4d4e138f23..983786f2539f8e 100644 --- a/Mathlib/Algebra/Order/Invertible.lean +++ b/Mathlib/Algebra/Order/Invertible.lean @@ -41,6 +41,5 @@ theorem invOf_le_one [Invertible a] (h : 1 ≤ a) : ⅟a ≤ 1 := theorem invOf_lt_one [Invertible a] (h : 1 < a) : ⅟a < 1 := mul_invOf_self a ▸ lt_mul_of_one_lt_left (invOf_pos.2 <| one_pos.trans h) h -theorem pos_invOf_of_invertible_cast [Nontrivial R] (n : ℕ) - [Invertible (n : R)] : 0 < ⅟(n : R) := +theorem pos_invOf_of_invertible_cast (n : ℕ) [Invertible (n : R)] : 0 < ⅟(n : R) := invOf_pos.2 <| Nat.cast_pos.2 <| pos_of_invertible_cast (R := R) n diff --git a/Mathlib/Algebra/Order/Module/HahnEmbedding.lean b/Mathlib/Algebra/Order/Module/HahnEmbedding.lean index f62941aabb2aa1..26f472ff8b55b4 100644 --- a/Mathlib/Algebra/Order/Module/HahnEmbedding.lean +++ b/Mathlib/Algebra/Order/Module/HahnEmbedding.lean @@ -158,7 +158,7 @@ abbrev stratum' (c : FiniteArchimedeanClass M) : Submodule K (baseDomain u) := theorem iSupIndep_stratum' : iSupIndep u.stratum' := by apply (iSupIndep_map_orderIso_iff (Submodule.mapIic u.baseDomain)).mp apply iSupIndep.of_coe_Iic_comp - convert u.iSupIndep_stratum + convert! u.iSupIndep_stratum ext1 c simpa using le_iSup _ _ @@ -366,7 +366,7 @@ theorem truncLT_mem_range_baseEmbedding (x : seed.baseEmbedding.domain) · rw [HahnSeries.coe_truncLTLinearMap, HahnSeries.coeff_truncLT_of_le hdc] have hcd : c.val ≤ d.val := hdc simp only [DFinsupp.mk_apply, hcd, ↓reduceIte] - convert LinearMap.map_zero _ + convert! LinearMap.map_zero _ simp /-- `HahnEmbedding.Seed.baseEmbedding` is a partial Hahn embedding. -/ @@ -569,7 +569,7 @@ theorem isWF_support_evalCoeff [IsOrderedAddMonoid R] [Archimedean R] (x : M) : have hmem' (n : ℕ) : seq n ∈ (ofLex (f.val y)).coeff.support := by specialize hmem n rw [Function.mem_support] at ⊢ hmem - convert hmem using 1 + convert! hmem using 1 refine (f.evalCoeff_eq ((ball_strictAnti K).antitone ?_ hy)).symm simpa using hanti.antitone (show 0 ≤ n by simp) obtain hwf := (ofLex (f.val y)).isWF_support @@ -587,7 +587,7 @@ def eval [IsOrderedAddMonoid R] [Archimedean R] (x : M) : @[simp] theorem eval_zero [IsOrderedAddMonoid R] [Archimedean R] : f.eval 0 = 0 := by unfold eval - convert toLex_zero + convert! toLex_zero ext c rw [f.evalCoeff_eq (y := 0) (by simp)] simp diff --git a/Mathlib/Algebra/Order/Monoid/LocallyFiniteOrder.lean b/Mathlib/Algebra/Order/Monoid/LocallyFiniteOrder.lean index 44942b4a803d64..0fda32118f060b 100644 --- a/Mathlib/Algebra/Order/Monoid/LocallyFiniteOrder.lean +++ b/Mathlib/Algebra/Order/Monoid/LocallyFiniteOrder.lean @@ -78,7 +78,7 @@ def LocallyFiniteOrder.addMonoidHom : map_zero' := by simp map_add' a b := by wlog hab : a ≤ b generalizing a b - · convert this b a (le_of_not_ge hab) using 1 <;> simp only [add_comm] + · convert! this b a (le_of_not_ge hab) using 1 <;> simp only [add_comm] obtain ha | ha := le_total 0 a <;> obtain hb | hb := le_total 0 b · have : -b ≤ a := by trans 0 <;> simp [ha, hb] simp [ha, hb, card_Ico_zero_add, this] diff --git a/Mathlib/Algebra/Order/Rearrangement.lean b/Mathlib/Algebra/Order/Rearrangement.lean index e212f91a232c05..44b20c6d3cf59b 100644 --- a/Mathlib/Algebra/Order/Rearrangement.lean +++ b/Mathlib/Algebra/Order/Rearrangement.lean @@ -121,8 +121,9 @@ theorem AntivaryOn.sum_smul_le_sum_smul_comp_perm (hfg : AntivaryOn f g s) `f` and `g` monovary together on `s`. Stated by permuting the entries of `f`. -/ theorem MonovaryOn.sum_comp_perm_smul_le_sum_smul (hfg : MonovaryOn f g s) (hσ : {x | σ x ≠ x} ⊆ s) : ∑ i ∈ s, f (σ i) • g i ≤ ∑ i ∈ s, f i • g i := by - convert hfg.sum_smul_comp_perm_le_sum_smul - (show { x | σ⁻¹ x ≠ x } ⊆ s by simp [set_support_symm_eq, hσ]) using 1 + convert! + hfg.sum_smul_comp_perm_le_sum_smul + (show {x | σ⁻¹ x ≠ x} ⊆ s by simp [set_support_symm_eq, hσ]) using 1 exact σ.sum_comp' s (fun i j ↦ f i • g j) hσ /-- **Rearrangement Inequality**: Pointwise scalar multiplication of `f` and `g` is minimized when @@ -211,10 +212,10 @@ theorem MonovaryOn.sum_comp_perm_smul_eq_sum_smul_iff (hfg : MonovaryOn f g s) · apply eq_iff_eq_cancel_right.2 rw [σ.sum_comp' s (fun i j ↦ f i • g j) hσ] congr - · convert h.comp_right σ + · convert! h.comp_right σ · rw [comp_assoc, inv_def, symm_comp_self, comp_id] · rw [σ.eq_preimage_iff_image_eq, Set.image_perm hσ] - · convert h.comp_right σ.symm + · convert! h.comp_right σ.symm · rw [comp_assoc, self_comp_symm, comp_id] · rw [σ.symm.eq_preimage_iff_image_eq] exact Set.image_perm hσinv diff --git a/Mathlib/Algebra/Order/Ring/Abs.lean b/Mathlib/Algebra/Order/Ring/Abs.lean index 55b6b50ea5fdc0..b2438fbcd6f484 100644 --- a/Mathlib/Algebra/Order/Ring/Abs.lean +++ b/Mathlib/Algebra/Order/Ring/Abs.lean @@ -89,7 +89,7 @@ section LinearStrictOrderedRing variable [Ring α] [LinearOrder α] [IsStrictOrderedRing α] {n : ℕ} {a b : α} lemma abs_pow_eq_one (a : α) (h : n ≠ 0) : |a ^ n| = 1 ↔ |a| = 1 := by - convert pow_left_inj₀ (abs_nonneg a) zero_le_one h + convert! pow_left_inj₀ (abs_nonneg a) zero_le_one h exacts [(pow_abs _ _).symm, (one_pow _).symm] lemma abs_eq_iff_mul_self_eq : |a| = |b| ↔ a * a = b * b := by diff --git a/Mathlib/Algebra/Order/Ring/Archimedean.lean b/Mathlib/Algebra/Order/Ring/Archimedean.lean index f85be72d328284..6bc0565a98cf90 100644 --- a/Mathlib/Algebra/Order/Ring/Archimedean.lean +++ b/Mathlib/Algebra/Order/Ring/Archimedean.lean @@ -62,7 +62,7 @@ private theorem mk_mul_le_of_le {x₁ y₁ x₂ y₂ : R} (hx : mk x₁ ≤ mk x obtain ⟨m, hm⟩ := hx obtain ⟨n, hn⟩ := hy use m * n - convert mul_le_mul hm hn (abs_nonneg _) (nsmul_nonneg (abs_nonneg _) _) using 1 <;> + convert! mul_le_mul hm hn (abs_nonneg _) (nsmul_nonneg (abs_nonneg _) _) using 1 <;> simp_rw [ArchimedeanOrder.val_of, abs_mul] ring diff --git a/Mathlib/Algebra/Order/Ring/StandardPart.lean b/Mathlib/Algebra/Order/Ring/StandardPart.lean index 809309e70f1788..7335e3be07016c 100644 --- a/Mathlib/Algebra/Order/Ring/StandardPart.lean +++ b/Mathlib/Algebra/Order/Ring/StandardPart.lean @@ -216,7 +216,7 @@ instance : Archimedean (FiniteResidueField K) where · obtain ⟨n, hn⟩ := ((mk_ne_zero.1 hy.ne').trans (mk_ne_zero.1 hx.ne').symm).le refine ⟨n, mk.monotone' ?_⟩ change x.1 ≤ n • y.1 - convert ← hn + convert! ← hn · exact abs_of_pos <| lt_of_mk_lt_mk hx · exact abs_of_pos <| lt_of_mk_lt_mk hy @@ -461,10 +461,10 @@ theorem stdPart_eq_sInf (f : ℝ →+*o K) (x : K) : stdPart x = sInf {r | x < f · rw [stdPart_of_mk_ne_zero hx.ne] have hr {r} := hx.trans_le (mk_map_nonneg_of_archimedean f r) obtain h | h := le_or_gt 0 x - · convert Real.sInf_empty.symm + · convert! Real.sInf_empty.symm rw [Set.eq_empty_iff_forall_notMem] exact fun r ↦ (lt_of_mk_lt_mk_of_nonneg hr h).not_gt - · convert Real.sInf_univ.symm + · convert! Real.sInf_univ.symm rw [Set.eq_univ_iff_forall] exact fun r ↦ lt_of_mk_lt_mk_of_nonpos hr h.le diff --git a/Mathlib/Algebra/Order/Ring/Unbundled/Basic.lean b/Mathlib/Algebra/Order/Ring/Unbundled/Basic.lean index cd50c663197a9e..8beb12c95faf3f 100644 --- a/Mathlib/Algebra/Order/Ring/Unbundled/Basic.lean +++ b/Mathlib/Algebra/Order/Ring/Unbundled/Basic.lean @@ -441,7 +441,7 @@ theorem nonpos_of_mul_nonpos_right [PosMulStrictMono R] @[simp] theorem mul_nonneg_iff_of_pos_left [PosMulStrictMono R] (h : 0 < c) : 0 ≤ c * b ↔ 0 ≤ b := by - convert mul_le_mul_iff_right₀ h + convert! mul_le_mul_iff_right₀ h simp @[simp] diff --git a/Mathlib/Algebra/Order/Star/Basic.lean b/Mathlib/Algebra/Order/Star/Basic.lean index f9505185526ebb..a08f2154d10610 100644 --- a/Mathlib/Algebra/Order/Star/Basic.lean +++ b/Mathlib/Algebra/Order/Star/Basic.lean @@ -213,7 +213,7 @@ theorem star_left_conjugate_nonneg {a : R} (ha : 0 ≤ a) (c : R) : 0 ≤ star c refine AddSubmonoid.closure_induction (fun x hx => ?_) (by rw [mul_zero, zero_mul]) (fun x y _ _ hx hy => ?_) ha · obtain ⟨x, rfl⟩ := hx - convert star_mul_self_nonneg (x * c) using 1 + convert! star_mul_self_nonneg (x * c) using 1 rw [star_mul, ← mul_assoc, mul_assoc _ _ c] · calc 0 ≤ star c * x * c + 0 := by rw [add_zero]; exact hx diff --git a/Mathlib/Algebra/Order/Sub/Unbundled/Basic.lean b/Mathlib/Algebra/Order/Sub/Unbundled/Basic.lean index 674f09d7ba6863..5d0cf4b2868b44 100644 --- a/Mathlib/Algebra/Order/Sub/Unbundled/Basic.lean +++ b/Mathlib/Algebra/Order/Sub/Unbundled/Basic.lean @@ -56,7 +56,7 @@ theorem lt_of_tsub_lt_tsub_right_of_le (h : c ≤ b) (h2 : a - c < b - c) : a < exact h2.false theorem tsub_add_tsub_cancel (hab : b ≤ a) (hcb : c ≤ b) : a - b + (b - c) = a - c := by - convert tsub_add_cancel_of_le (tsub_le_tsub_right hab c) using 2 + convert! tsub_add_cancel_of_le (tsub_le_tsub_right hab c) using 2 rw [tsub_tsub, add_tsub_cancel_of_le hcb] theorem tsub_tsub_tsub_cancel_right (h : c ≤ b) : a - c - (b - c) = a - b := by diff --git a/Mathlib/Algebra/Order/SuccPred.lean b/Mathlib/Algebra/Order/SuccPred.lean index cea3e544d7b243..7ea24dde4fa4e9 100644 --- a/Mathlib/Algebra/Order/SuccPred.lean +++ b/Mathlib/Algebra/Order/SuccPred.lean @@ -241,34 +241,36 @@ theorem add_one_inj [NoMaxOrder α] : x + 1 = y + 1 ↔ x = y := by end Add +@[simp] +theorem lt_two_iff [AddMonoidWithOne α] [SuccAddOrder α] [NoMaxOrder α] : x < 2 ↔ x ≤ 1 := by + rw [← one_add_one_eq_two, lt_add_one_iff] + section AddMonoidWithOne -variable [AddMonoidWithOne α] [NoMaxOrder α] [SuccAddOrder α] +variable [AddMonoidWithOne α] [SuccAddOrder α] [IsBotZeroClass α] [NeZero (1 : α)] @[simp] -theorem lt_one_iff [IsBotZeroClass α] : x < 1 ↔ x = 0 := by - rw [← zero_add 1, lt_add_one_iff, nonpos_iff_eq_zero] +theorem lt_one_iff : x < 1 ↔ x = 0 := by + simpa using (one_le_iff_ne_zero (x := x)).not -theorem le_one_iff [IsBotZeroClass α] : x ≤ 1 ↔ x = 0 ∨ x = 1 := by +theorem le_one_iff : x ≤ 1 ↔ x = 0 ∨ x = 1 := by rw [le_iff_lt_or_eq, lt_one_iff] @[simp] -theorem Iio_one [IsBotZeroClass α] : Set.Iio (1 : α) = {0} := by +theorem Iio_one : Set.Iio (1 : α) = {0} := by ext; simp -theorem Iic_one [IsBotZeroClass α] : Set.Iic (1 : α) = {0, 1} := by +theorem Iic_one : Set.Iic (1 : α) = {0, 1} := by ext; simp [le_one_iff] -@[simp] -theorem lt_two_iff : x < 2 ↔ x ≤ 1 := by - rw [← one_add_one_eq_two, lt_add_one_iff] +variable [NoMaxOrder α] -theorem le_two_iff [IsBotZeroClass α] : x ≤ 2 ↔ x = 0 ∨ x = 1 ∨ x = 2 := by +theorem le_two_iff : x ≤ 2 ↔ x = 0 ∨ x = 1 ∨ x = 2 := by rw [le_iff_lt_or_eq, lt_two_iff, le_one_iff, or_assoc] -theorem Iio_two [IsBotZeroClass α] : Set.Iio (2 : α) = {0, 1} := by +theorem Iio_two : Set.Iio (2 : α) = {0, 1} := by ext; simp [le_one_iff] -theorem Iic_two [IsBotZeroClass α] : Set.Iic (2 : α) = {0, 1, 2} := by +theorem Iic_two : Set.Iic (2 : α) = {0, 1, 2} := by ext; simp [le_two_iff] end AddMonoidWithOne diff --git a/Mathlib/Algebra/Order/ToIntervalMod.lean b/Mathlib/Algebra/Order/ToIntervalMod.lean index 20794291bfb051..0ac987cb2d166d 100644 --- a/Mathlib/Algebra/Order/ToIntervalMod.lean +++ b/Mathlib/Algebra/Order/ToIntervalMod.lean @@ -83,7 +83,7 @@ theorem toIcoMod_mem_Ico (a b : α) : toIcoMod hp a b ∈ Set.Ico a (a + p) := sub_toIcoDiv_zsmul_mem_Ico hp a b theorem toIcoMod_mem_Ico' (b : α) : toIcoMod hp 0 b ∈ Set.Ico 0 p := by - convert toIcoMod_mem_Ico hp 0 b + convert! toIcoMod_mem_Ico hp 0 b exact (zero_add p).symm theorem toIocMod_mem_Ioc (a b : α) : toIocMod hp a b ∈ Set.Ioc a (a + p) := @@ -1407,14 +1407,14 @@ theorem iUnion_Ioc_add_zsmul : ⋃ n : ℤ, Ioc (a + n • p) (a + (n + 1) • p rcases sub_toIocDiv_zsmul_mem_Ioc hp a b with ⟨hl, hr⟩ refine ⟨toIocDiv hp a b, ⟨lt_sub_iff_add_lt.mp hl, ?_⟩⟩ rw [add_smul, one_smul, ← add_assoc] - convert sub_le_iff_le_add.mp hr using 1; abel + convert! sub_le_iff_le_add.mp hr using 1; abel theorem iUnion_Ico_add_zsmul : ⋃ n : ℤ, Ico (a + n • p) (a + (n + 1) • p) = univ := by refine eq_univ_iff_forall.mpr fun b => mem_iUnion.mpr ?_ rcases sub_toIcoDiv_zsmul_mem_Ico hp a b with ⟨hl, hr⟩ refine ⟨toIcoDiv hp a b, ⟨le_sub_iff_add_le.mp hl, ?_⟩⟩ rw [add_smul, one_smul, ← add_assoc] - convert sub_lt_iff_lt_add.mp hr using 1; abel + convert! sub_lt_iff_lt_add.mp hr using 1; abel theorem iUnion_Icc_add_zsmul : ⋃ n : ℤ, Icc (a + n • p) (a + (n + 1) • p) = univ := by simpa only [iUnion_Ioc_add_zsmul hp a, univ_subset_iff] using diff --git a/Mathlib/Algebra/Polynomial/AlgebraMap.lean b/Mathlib/Algebra/Polynomial/AlgebraMap.lean index e513752ccb8e9e..31ab4a5df5786d 100644 --- a/Mathlib/Algebra/Polynomial/AlgebraMap.lean +++ b/Mathlib/Algebra/Polynomial/AlgebraMap.lean @@ -62,7 +62,7 @@ instance algebraOfAlgebra : Algebra R A[X] where toFinsupp_injective <| by dsimp only [RingHom.toFun_eq_coe, RingHom.comp_apply] simp_rw [toFinsupp_mul, toFinsupp_C] - convert Algebra.commutes' r p.toFinsupp + convert! Algebra.commutes' r p.toFinsupp algebraMap := C.comp (algebraMap R A) @[simp] @@ -613,7 +613,7 @@ theorem dvd_term_of_dvd_eval_of_dvd_terms {z p : S} {f : S[X]} (i : ℕ) (dvd_ev apply Finset.dvd_sum intro j hj exact dvd_terms j (Finset.ne_of_mem_erase hj) - · convert dvd_zero p + · convert! dvd_zero p rw [notMem_support_iff] at hi simp [hi] @@ -659,7 +659,7 @@ theorem aeval_endomorphism {M : Type*} [AddCommGroup M] [Module R M] (f : M → exact map_sum (LinearMap.applyₗ v) _ _ lemma X_sub_C_pow_dvd_iff {n : ℕ} : (X - C t) ^ n ∣ p ↔ X ^ n ∣ p.comp (X + C t) := by - convert (map_dvd_iff <| algEquivAevalXAddC t).symm using 2 + convert! (map_dvd_iff <| algEquivAevalXAddC t).symm using 2 simp [C_eq_algebraMap] lemma comp_X_add_C_eq_zero_iff : p.comp (X + C t) = 0 ↔ p = 0 := @@ -669,7 +669,7 @@ lemma comp_X_add_C_ne_zero_iff : p.comp (X + C t) ≠ 0 ↔ p ≠ 0 := comp_X_ad lemma dvd_comp_C_mul_X_add_C_iff (p q : R[X]) (a b : R) [Invertible a] : p ∣ q.comp (C a * X + C b) ↔ p.comp (C ⅟a * (X - C b)) ∣ q := by - convert map_dvd_iff <| algEquivCMulXAddC a b using 2 + convert! map_dvd_iff <| algEquivCMulXAddC a b using 2 simp [← comp_eq_aeval, comp_assoc, ← mul_assoc, ← C_mul] lemma dvd_comp_X_sub_C_iff (p q : R[X]) (a : R) : diff --git a/Mathlib/Algebra/Polynomial/Basic.lean b/Mathlib/Algebra/Polynomial/Basic.lean index db5c596a13dd02..d106502236c636 100644 --- a/Mathlib/Algebra/Polynomial/Basic.lean +++ b/Mathlib/Algebra/Polynomial/Basic.lean @@ -633,7 +633,7 @@ theorem notMem_support_iff : n ∉ p.support ↔ p.coeff n = 0 := by simp @[aesop simp] theorem coeff_C : coeff (C a) n = ite (n = 0) a 0 := by - convert coeff_monomial (a := a) (m := n) (n := 0) using 2 + convert! coeff_monomial (a := a) (m := n) (n := 0) using 2 simp [eq_comm] @[simp] @@ -806,7 +806,7 @@ theorem smul_X_eq_monomial {n} : a • X ^ n = monomial n (a : R) := by rw [X_pow_eq_monomial, smul_monomial, smul_eq_mul, mul_one] theorem support_X_pow (H : ¬(1 : R) = 0) (n : ℕ) : (X ^ n : R[X]).support = singleton n := by - convert support_monomial n H + convert! support_monomial n H exact X_pow_eq_monomial n theorem support_X_empty (H : (1 : R) = 0) : (X : R[X]).support = ∅ := by @@ -913,7 +913,7 @@ protected theorem induction_on {motive : R[X] → Prop} (p : R[X]) (C : ∀ a, m | succ n ih => exact monomial _ _ ih have B : ∀ s : Finset ℕ, motive (s.sum fun n : ℕ => Polynomial.C (p.coeff n) * X ^ n) := by apply Finset.induction - · convert C 0 + · convert! C 0 exact C_0.symm · intro n s ns ih rw [sum_insert ns] diff --git a/Mathlib/Algebra/Polynomial/BigOperators.lean b/Mathlib/Algebra/Polynomial/BigOperators.lean index 0274236ff2ffb2..3886e38da6077a 100644 --- a/Mathlib/Algebra/Polynomial/BigOperators.lean +++ b/Mathlib/Algebra/Polynomial/BigOperators.lean @@ -229,7 +229,7 @@ theorem coeff_multiset_prod_of_natDegree_le (n : ℕ) (hl : ∀ p ∈ t, natDegr theorem coeff_prod_of_natDegree_le (f : ι → R[X]) (n : ℕ) (h : ∀ p ∈ s, natDegree (f p) ≤ n) : coeff (∏ i ∈ s, f i) (#s * n) = ∏ i ∈ s, coeff (f i) n := by obtain ⟨l, hl⟩ := s - convert coeff_multiset_prod_of_natDegree_le (l.map f) n ?_ + convert! coeff_multiset_prod_of_natDegree_le (l.map f) n ?_ · simp · simp · simpa using h @@ -266,7 +266,7 @@ theorem prod_X_sub_C_nextCoeff {s : Finset ι} (f : ι → R) : theorem multiset_prod_X_sub_C_coeff_card_pred (t : Multiset R) (ht : 0 < Multiset.card t) : (t.map fun x => X - C x).prod.coeff ((Multiset.card t) - 1) = -t.sum := by nontriviality R - convert multiset_prod_X_sub_C_nextCoeff (by assumption) + convert! multiset_prod_X_sub_C_nextCoeff (by assumption) rw [nextCoeff, if_neg] swap · rw [natDegree_multiset_prod_of_monic] diff --git a/Mathlib/Algebra/Polynomial/CancelLeads.lean b/Mathlib/Algebra/Polynomial/CancelLeads.lean index 963350a3567d4e..bb61c6a76fc056 100644 --- a/Mathlib/Algebra/Polynomial/CancelLeads.lean +++ b/Mathlib/Algebra/Polynomial/CancelLeads.lean @@ -53,7 +53,7 @@ theorem natDegree_cancelLeads_lt_of_natDegree_le_natDegree_of_comm (h : p.natDegree ≤ q.natDegree) (hq : 0 < q.natDegree) : (p.cancelLeads q).natDegree < q.natDegree := by by_cases hp : p = 0 - · convert hq + · convert! hq simp [hp, cancelLeads] rw [cancelLeads, sub_eq_add_neg, tsub_eq_zero_iff_le.mpr h, pow_zero, mul_one] by_cases h0 : diff --git a/Mathlib/Algebra/Polynomial/Degree/IsMonicOfDegree.lean b/Mathlib/Algebra/Polynomial/Degree/IsMonicOfDegree.lean index 415f893a9dc8d2..0acdfb7850f3fb 100644 --- a/Mathlib/Algebra/Polynomial/Degree/IsMonicOfDegree.lean +++ b/Mathlib/Algebra/Polynomial/Degree/IsMonicOfDegree.lean @@ -267,7 +267,7 @@ lemma IsMonicOfDegree.of_dvd_add {a b r : R[X]} {m n : ℕ} (hmn : n ≤ m) (ha lemma IsMonicOfDegree.of_dvd_sub {a b r : R[X]} {m n : ℕ} (hmn : n ≤ m) (ha : IsMonicOfDegree a m) (hb : IsMonicOfDegree b n) (hr : r.natDegree < m) (h : b ∣ a - r) : ∃ q : R[X], IsMonicOfDegree q (m - n) ∧ a = q * b + r := by - convert ha.of_dvd_add hmn hb ?_ h using 4 with q + convert! ha.of_dvd_add hmn hb ?_ h using 4 with q · rw [sub_neg_eq_add] · rwa [natDegree_neg] diff --git a/Mathlib/Algebra/Polynomial/Degree/Lemmas.lean b/Mathlib/Algebra/Polynomial/Degree/Lemmas.lean index 7d783b482f6dec..42f608a6073af3 100644 --- a/Mathlib/Algebra/Polynomial/Degree/Lemmas.lean +++ b/Mathlib/Algebra/Polynomial/Degree/Lemmas.lean @@ -82,7 +82,7 @@ theorem natDegree_add_le_iff_left {n : ℕ} (p q : R[X]) (qn : q.natDegree ≤ n (p + q).natDegree ≤ n ↔ p.natDegree ≤ n := by refine ⟨fun h => ?_, fun h => natDegree_add_le_of_degree_le h qn⟩ refine natDegree_le_iff_coeff_eq_zero.mpr fun m hm => ?_ - convert natDegree_le_iff_coeff_eq_zero.mp h m hm using 1 + convert! natDegree_le_iff_coeff_eq_zero.mp h m hm using 1 rw [coeff_add, natDegree_le_iff_coeff_eq_zero.mp qn _ hm, add_zero] theorem natDegree_add_le_iff_right {n : ℕ} (p q : R[X]) (pn : p.natDegree ≤ n) : diff --git a/Mathlib/Algebra/Polynomial/Derivative.lean b/Mathlib/Algebra/Polynomial/Derivative.lean index 8e5b18bf65ce4b..09c1861101d102 100644 --- a/Mathlib/Algebra/Polynomial/Derivative.lean +++ b/Mathlib/Algebra/Polynomial/Derivative.lean @@ -97,7 +97,7 @@ theorem derivative_C_mul_X_sq (a : R) : derivative (C a * X ^ 2) = C (a * 2) * X rw [derivative_C_mul_X_pow, Nat.cast_two, pow_one] theorem derivative_X_pow (n : ℕ) : derivative (X ^ n : R[X]) = C (n : R) * X ^ (n - 1) := by - convert derivative_C_mul_X_pow (1 : R) n <;> simp + convert! derivative_C_mul_X_pow (1 : R) n <;> simp @[simp] theorem derivative_X_pow_succ (n : ℕ) : @@ -539,19 +539,19 @@ theorem iterate_derivative_mul_X_pow (n m : ℕ) (p : R[X]) : theorem iterate_derivative_mul_X {n : ℕ} (p : R[X]) : derivative^[n] (p * X) = (derivative^[n] p) * X + n • derivative^[n - 1] p := by - convert p.iterate_derivative_mul_X_pow n 1; · simp + convert! p.iterate_derivative_mul_X_pow n 1; · simp rcases n with rfl | n <;> simp [sum_range_succ] theorem iterate_derivative_derivative_mul_X {n : ℕ} (p : R[X]) : derivative^[n] (derivative p * X) = (derivative^[n + 1] p) * X + n • derivative^[n] p := by - convert (derivative p).iterate_derivative_mul_X_pow n 1; · simp + convert! (derivative p).iterate_derivative_mul_X_pow n 1; · simp rcases n with rfl | n <;> simp [sum_range_succ] theorem iterate_derivative_derivative_mul_X_sq {n : ℕ} (p : R[X]) : derivative^[n] (derivative^[2] p * X ^ 2) = (derivative^[n + 2] p) * X ^ 2 + (2 * n) • (derivative^[n + 1] p) * X + (n * (n - 1)) • derivative^[n] p := by - convert (derivative^[2] p).iterate_derivative_mul_X_pow n 2 + convert! (derivative^[2] p).iterate_derivative_mul_X_pow n 2 rcases n with rfl | n; · simp rcases n with rfl | n; · simp [sum_range_succ, ← mul_assoc] suffices ((n + 1 + 1) * (n + 1) / 2) * 2 = (n + 1 + 1) * (n + 1) by diff --git a/Mathlib/Algebra/Polynomial/Div.lean b/Mathlib/Algebra/Polynomial/Div.lean index 29a02efd5c24d1..38002ad6857ee4 100644 --- a/Mathlib/Algebra/Polynomial/Div.lean +++ b/Mathlib/Algebra/Polynomial/Div.lean @@ -422,7 +422,7 @@ theorem map_dvd_map [Ring S] (f : R →+* S) (hf : Function.Injective f) {x y : @[simp] theorem modByMonic_one (p : R[X]) : p %ₘ 1 = 0 := - (modByMonic_eq_zero_iff_dvd (by convert monic_one (R := R))).2 (one_dvd _) + (modByMonic_eq_zero_iff_dvd (by convert! monic_one (R := R))).2 (one_dvd _) @[simp] theorem divByMonic_one (p : R[X]) : p /ₘ 1 = p := by @@ -789,7 +789,7 @@ lemma _root_.Irreducible.isRoot_eq_bot_of_natDegree_ne_one (hi : Irreducible p) (hdeg : p.natDegree ≠ 1) : p.IsRoot = ⊥ := le_bot_iff.mp fun _ ↦ hi.not_isRoot_of_natDegree_ne_one hdeg -lemma _root_.Irreducible.subsingleton_isRoot [IsLeftCancelMulZero R] +lemma _root_.Irreducible.subsingleton_isRoot (hi : Irreducible p) : { x | p.IsRoot x }.Subsingleton := fun _ hx ↦ (subsingleton_isRoot_of_natDegree_eq_one <| natDegree_eq_of_degree_eq_some <| degree_eq_one_of_irreducible_of_root hi hx) hx diff --git a/Mathlib/Algebra/Polynomial/EraseLead.lean b/Mathlib/Algebra/Polynomial/EraseLead.lean index 2e3cc9c33cdc25..d6c8a91e6136ed 100644 --- a/Mathlib/Algebra/Polynomial/EraseLead.lean +++ b/Mathlib/Algebra/Polynomial/EraseLead.lean @@ -322,13 +322,13 @@ theorem induction_with_natDegree_le (motive : R[X] → Prop) (N : ℕ) (zero : m motive f → motive g → motive (f + g)) (f : R[X]) (df : f.natDegree ≤ N) : motive f := by induction hf : #f.support generalizing f with | zero => - convert zero + convert! zero simpa [support_eq_empty, card_eq_zero] using hf | succ c hc => rw [← eraseLead_add_C_mul_X_pow f] cases c - · convert C_mul_pow f.natDegree f.leadingCoeff ?_ df using 1 - · convert zero_add (C (leadingCoeff f) * X ^ f.natDegree) + · convert! C_mul_pow f.natDegree f.leadingCoeff ?_ df using 1 + · convert! zero_add (C (leadingCoeff f) * X ^ f.natDegree) rw [← card_support_eq_zero, card_support_eraseLead' hf] · rw [leadingCoeff_ne_zero, Ne, ← card_support_eq_zero, hf] exact zero_ne_one.symm diff --git a/Mathlib/Algebra/Polynomial/Eval/Defs.lean b/Mathlib/Algebra/Polynomial/Eval/Defs.lean index c4479910af3a9a..6cfdf3fe6d567d 100644 --- a/Mathlib/Algebra/Polynomial/Eval/Defs.lean +++ b/Mathlib/Algebra/Polynomial/Eval/Defs.lean @@ -80,7 +80,7 @@ theorem eval₂_monomial {n : ℕ} {r : R} : (monomial n r).eval₂ f x = f r * @[simp] theorem eval₂_X_pow {n : ℕ} : (X ^ n).eval₂ f x = x ^ n := by rw [X_pow_eq_monomial] - convert eval₂_monomial f x (n := n) (r := 1) + convert! eval₂_monomial f x (n := n) (r := 1) simp @[simp] @@ -260,13 +260,13 @@ theorem eval₂_at_apply {S : Type*} [Semiring S] (f : R →+* S) (r : R) : @[simp] theorem eval₂_at_one {S : Type*} [Semiring S] (f : R →+* S) : p.eval₂ f 1 = f (p.eval 1) := by - convert eval₂_at_apply (p := p) f 1 + convert! eval₂_at_apply (p := p) f 1 simp @[simp] theorem eval₂_at_natCast {S : Type*} [Semiring S] (f : R →+* S) (n : ℕ) : p.eval₂ f n = f (p.eval n) := by - convert eval₂_at_apply (p := p) f n + convert! eval₂_at_apply (p := p) f n simp @[simp] @@ -778,7 +778,7 @@ theorem intCast_comp (i : ℤ) : comp (i : R[X]) p = i := by cases i <;> simp @[simp] theorem eval₂_at_intCast {S : Type*} [Ring S] (f : R →+* S) (n : ℤ) : p.eval₂ f n = f (p.eval n) := by - convert eval₂_at_apply (p := p) f n + convert! eval₂_at_apply (p := p) f n simp theorem mul_X_sub_intCast_comp {n : ℕ} : diff --git a/Mathlib/Algebra/Polynomial/Eval/Degree.lean b/Mathlib/Algebra/Polynomial/Eval/Degree.lean index 0ea93154dbfed2..2040f65da66435 100644 --- a/Mathlib/Algebra/Polynomial/Eval/Degree.lean +++ b/Mathlib/Algebra/Polynomial/Eval/Degree.lean @@ -238,7 +238,7 @@ lemma isUnit_of_isUnit_leadingCoeff_of_isUnit_map (hf : IsUnit f.leadingCoeff) rw [degree_map_eq_of_leadingCoeff_ne_zero] at dz · rw [eq_C_of_degree_eq_zero dz] refine IsUnit.map C ?_ - convert hf + convert! hf change coeff f 0 = coeff f (natDegree f) rw [(degree_eq_iff_natDegree_eq _).1 dz] · rfl diff --git a/Mathlib/Algebra/Polynomial/Laurent.lean b/Mathlib/Algebra/Polynomial/Laurent.lean index 4006a861e9f960..e3b674a50ed46d 100644 --- a/Mathlib/Algebra/Polynomial/Laurent.lean +++ b/Mathlib/Algebra/Polynomial/Laurent.lean @@ -189,7 +189,7 @@ theorem _root_.Polynomial.toLaurent_C_mul_T (n : ℕ) (r : R) : @[simp] theorem _root_.Polynomial.toLaurent_C (r : R) : toLaurent (Polynomial.C r) = C r := by - convert Polynomial.toLaurent_C_mul_T 0 r + convert! Polynomial.toLaurent_C_mul_T 0 r simp only [Int.ofNat_zero, T_zero, mul_one] @[simp] @@ -244,12 +244,12 @@ protected theorem induction_on {M : R[T;T⁻¹] → Prop} (p : R[T;T⁻¹]) (h_C · exact fun m => h_C_mul_T_Z m a have B : ∀ s : Finset ℤ, M (s.sum fun n : ℤ => C (p n) * T n) := by apply Finset.induction - · convert h_C 0 + · convert! h_C 0 simp only [Finset.sum_empty, map_zero] · intro n s ns ih rw [Finset.sum_insert ns] exact h_add A ih - convert B p.support + convert! B p.support ext a simp_rw [← single_eq_C_mul_T] rw [Finset.sum_apply', Finset.sum_eq_single a, single_eq_same] @@ -268,7 +268,7 @@ protected theorem induction_on' {motive : R[T;T⁻¹] → Prop} (p : R[T;T⁻¹] (C_mul_T : ∀ (n : ℤ) (a : R), motive (C a * T n)) : motive p := by refine p.induction_on (fun a => ?_) (fun {p q} => add p q) ?_ ?_ <;> try exact fun n f _ => C_mul_T _ f - convert C_mul_T 0 a + convert! C_mul_T 0 a exact (mul_one _).symm theorem commute_T (n : ℤ) (f : R[T;T⁻¹]) : Commute (T n) f := @@ -375,7 +375,7 @@ theorem reduce_to_polynomial_of_mul_T (f : R[T;T⁻¹]) {Q : R[T;T⁻¹] → Pro induction f using LaurentPolynomial.induction_on_mul_T with | _ f n induction n with | zero => simpa only [Nat.cast_zero, neg_zero, T_zero, mul_one] using Qf _ - | succ n hn => convert QT _ _; simpa using hn + | succ n hn => convert! QT _ _; simpa using hn section Support @@ -542,7 +542,7 @@ theorem mk'_one_X_pow (n : ℕ) : @[simp] theorem mk'_one_X : IsLocalization.mk' R[T;T⁻¹] 1 (⟨X, 1, pow_one X⟩ : Submonoid.powers (X : R[X])) = T (-1) := by - convert mk'_one_X_pow 1 + convert! mk'_one_X_pow 1 exact (pow_one X).symm /-- Given a ring homomorphism `f : R →+* S` and a unit `x` in `S`, the induced homomorphism diff --git a/Mathlib/Algebra/Polynomial/Monic.lean b/Mathlib/Algebra/Polynomial/Monic.lean index 6b06c2d8c9f6ca..0d7f0841a6c6b6 100644 --- a/Mathlib/Algebra/Polynomial/Monic.lean +++ b/Mathlib/Algebra/Polynomial/Monic.lean @@ -192,7 +192,7 @@ theorem eq_one_of_map_eq_one {S : Type*} [Semiring S] [Nontrivial S] (f : R →+ exact one_ne_zero have hndeg : p.natDegree = 0 := WithBot.coe_eq_coe.mp ((degree_eq_natDegree hp.ne_zero).symm.trans hdeg) - convert eq_C_of_degree_eq_zero hdeg + convert! eq_C_of_degree_eq_zero hdeg rw [← hndeg, ← Polynomial.leadingCoeff, hp.leadingCoeff, C.map_one] theorem natDegree_pow (hp : p.Monic) (n : ℕ) : (p ^ n).natDegree = n * p.natDegree := by diff --git a/Mathlib/Algebra/Polynomial/RingDivision.lean b/Mathlib/Algebra/Polynomial/RingDivision.lean index bb683214c01175..387133c4b134b1 100644 --- a/Mathlib/Algebra/Polynomial/RingDivision.lean +++ b/Mathlib/Algebra/Polynomial/RingDivision.lean @@ -111,7 +111,7 @@ theorem rootMultiplicity_eq_rootMultiplicity {p : R[X]} {t : R} : simp_rw [rootMultiplicity_eq_multiplicity, comp_X_add_C_eq_zero_iff] congr 1 rw [C_0, sub_zero] - convert (multiplicity_map_eq <| algEquivAevalXAddC t).symm using 2 + convert! (multiplicity_map_eq <| algEquivAevalXAddC t).symm using 2 simp [C_eq_algebraMap] /-- See `Polynomial.rootMultiplicity_eq_natTrailingDegree'` for the special case of `t = 0`. -/ @@ -205,7 +205,7 @@ theorem prime_X_sub_C (r : R) : Prime (X - C r) := exact id⟩ theorem prime_X : Prime (X : R[X]) := by - convert prime_X_sub_C (0 : R) + convert! prime_X_sub_C (0 : R) simp theorem Monic.prime_of_degree_eq_one (hp1 : degree p = 1) (hm : Monic p) : Prime p := diff --git a/Mathlib/Algebra/Polynomial/Roots.lean b/Mathlib/Algebra/Polynomial/Roots.lean index 3602e5faa42aa9..41cffb24152941 100644 --- a/Mathlib/Algebra/Polynomial/Roots.lean +++ b/Mathlib/Algebra/Polynomial/Roots.lean @@ -364,7 +364,7 @@ def nthRootsFinset (n : ℕ) {R : Type*} (a : R) [CommRing R] [IsDomain R] : Fin lemma nthRootsFinset_def (n : ℕ) {R : Type*} (a : R) [CommRing R] [IsDomain R] [DecidableEq R] : nthRootsFinset n a = Multiset.toFinset (nthRoots n a) := by unfold nthRootsFinset - convert rfl + convert! rfl @[simp] theorem mem_nthRootsFinset {n : ℕ} (h : 0 < n) (a : R) {x : R} : @@ -540,7 +540,7 @@ def rootSet (p : T[X]) (S) [CommRing S] [IsDomain S] [Algebra T S] : Set S := theorem rootSet_def (p : T[X]) (S) [CommRing S] [IsDomain S] [Algebra T S] [DecidableEq S] : p.rootSet S = (p.aroots S).toFinset := by rw [rootSet] - convert rfl + convert! rfl @[simp] theorem rootSet_C [CommRing S] [IsDomain S] [Algebra T S] (a : T) : (C a).rootSet S = ∅ := by @@ -816,7 +816,7 @@ theorem C_leadingCoeff_mul_prod_multiset_X_sub_C (hroots : Multiset.card p.roots can be written `p = ∏(X - a)`, for `a` in `p.roots`. -/ theorem prod_multiset_X_sub_C_of_monic_of_roots_card_eq (hp : p.Monic) (hroots : Multiset.card p.roots = p.natDegree) : (p.roots.map fun a => X - C a).prod = p := by - convert C_leadingCoeff_mul_prod_multiset_X_sub_C hroots + convert! C_leadingCoeff_mul_prod_multiset_X_sub_C hroots rw [hp.leadingCoeff, C_1, one_mul] theorem Monic.isUnit_leadingCoeff_of_dvd {a p : R[X]} (hp : Monic p) (hap : a ∣ p) : @@ -826,7 +826,7 @@ theorem Monic.isUnit_leadingCoeff_of_dvd {a p : R[X]} (hp : Monic p) (hap : a theorem card_roots_le_one_of_irreducible (hirr : Irreducible p) : p.roots.card ≤ 1 := by obtain hp | ⟨x, hx⟩ := p.roots.empty_or_exists_mem · simp [hp] - convert p.card_roots' + convert! p.card_roots' exact (natDegree_eq_of_degree_eq_some <| degree_eq_one_of_irreducible_of_root hirr <| isRoot_of_mem_roots hx).symm @@ -886,7 +886,7 @@ theorem count_map_roots [IsDomain A] [DecidableEq B] {p : A[X]} {f : A →+* B} rw [← Multiset.filter_eq] refine (Multiset.prod_dvd_prod_of_le <| Multiset.map_le_map <| Multiset.filter_le (Eq b) _).trans ?_ - convert Polynomial.map_dvd f p.prod_multiset_X_sub_C_dvd + convert! Polynomial.map_dvd f p.prod_multiset_X_sub_C_dvd simp only [Polynomial.map_multiset_prod, Multiset.map_map, Function.comp_apply, Polynomial.map_sub, map_X, map_C] diff --git a/Mathlib/Algebra/Polynomial/RuleOfSigns.lean b/Mathlib/Algebra/Polynomial/RuleOfSigns.lean index d0335ff0694f79..754ca2bf825c69 100644 --- a/Mathlib/Algebra/Polynomial/RuleOfSigns.lean +++ b/Mathlib/Algebra/Polynomial/RuleOfSigns.lean @@ -209,7 +209,7 @@ lemma signVariations_eraseLead_mul_X_sub_C (hη : 0 < η) (hP₀ : 0 < leadingCo lemma succ_signVariations_X_sub_C_mul_monomial {d c} (hc : c ≠ 0) (hη : 0 < η) : (monomial d c).signVariations + 1 ≤ ((X - C η) * monomial d c).signVariations := by have h₁ : nextCoeff ((X - C η) * monomial d c) = -(η * c) := by - convert coeff_mul_monomial (X - C η) d 0 c using 1 + convert! coeff_mul_monomial (X - C η) d 0 c using 1 · simp [hc, nextCoeff, natDegree_mul (X_sub_C_ne_zero η)] · simp have h₂ : eraseLead ((X - C η) * monomial d c) ≠ 0 := by diff --git a/Mathlib/Algebra/Polynomial/SumIteratedDerivative.lean b/Mathlib/Algebra/Polynomial/SumIteratedDerivative.lean index 397f0f9e441105..3dfbf95ffe2ba2 100644 --- a/Mathlib/Algebra/Polynomial/SumIteratedDerivative.lean +++ b/Mathlib/Algebra/Polynomial/SumIteratedDerivative.lean @@ -143,7 +143,7 @@ theorem aeval_iterate_derivative_self (p : R[X]) (q : ℕ) (r : A) {p' : A[X]} simp_rw [hp, iterate_derivative_mul, iterate_derivative_X_sub_pow, ← smul_mul_assoc, smul_smul] rw [sum_range_succ', Nat.choose_zero_right, one_mul, tsub_zero, Nat.descFactorial_self, tsub_self, pow_zero, smul_mul_assoc, one_mul, Function.iterate_zero_apply, eval_add, eval_smul] - convert zero_add _ + convert! zero_add _ rw [eval_finsetSum] apply sum_eq_zero intro x hx diff --git a/Mathlib/Algebra/Prime/Lemmas.lean b/Mathlib/Algebra/Prime/Lemmas.lean index 600e11ba5d41a3..704735cad894a0 100644 --- a/Mathlib/Algebra/Prime/Lemmas.lean +++ b/Mathlib/Algebra/Prime/Lemmas.lean @@ -48,11 +48,11 @@ theorem comap_prime (hinv : ∀ a, g (f a : N) = a) (hp : Prime (f p)) : Prime p ⟨fun h => hp.1 <| by simp [h], fun h => hp.2.1 <| h.map f, fun a b h => by refine (hp.2.2 (f a) (f b) <| by - convert map_dvd f h + convert! map_dvd f h simp).imp ?_ ?_ <;> · intro h - convert ← map_dvd g h <;> apply hinv⟩ + convert! ← map_dvd g h <;> apply hinv⟩ theorem MulEquiv.prime_iff {E : Type*} [EquivLike E M N] [MulEquivClass E M N] (e : E) : Prime (e p) ↔ Prime p := by diff --git a/Mathlib/Algebra/QuadraticAlgebra/NormDeterminant.lean b/Mathlib/Algebra/QuadraticAlgebra/NormDeterminant.lean index c8959dc459100d..efa45141de504c 100644 --- a/Mathlib/Algebra/QuadraticAlgebra/NormDeterminant.lean +++ b/Mathlib/Algebra/QuadraticAlgebra/NormDeterminant.lean @@ -30,7 +30,7 @@ theorem det_toLinearMap_eq_norm (z : QuadraticAlgebra R a b) : have : !![z.re, a * z.im; z.im, z.re + b * z.im].det = z.norm := by simp [norm] ring - convert this + convert! this apply LinearEquiv.eq_symm_apply _ |>.mp ext1 w apply basis .. |>.repr.injective diff --git a/Mathlib/Algebra/QuadraticDiscriminant.lean b/Mathlib/Algebra/QuadraticDiscriminant.lean index 0b8720a5988fe0..d468d87f32ef32 100644 --- a/Mathlib/Algebra/QuadraticDiscriminant.lean +++ b/Mathlib/Algebra/QuadraticDiscriminant.lean @@ -139,7 +139,7 @@ theorem discrim_le_zero (h : ∀ x : K, 0 ≤ a * (x * x) + b * x + c) : discrim linarith -- if a > 0 · have ha' : 0 ≤ 4 * a := mul_nonneg zero_le_four ha.le - convert neg_nonpos.2 (mul_nonneg ha' (h (-b / (2 * a)))) using 1 + convert! neg_nonpos.2 (mul_nonneg ha' (h (-b / (2 * a)))) using 1 field lemma discrim_le_zero_of_nonpos (h : ∀ x : K, a * (x * x) + b * x + c ≤ 0) : discrim a b c ≤ 0 := diff --git a/Mathlib/Algebra/Quaternion.lean b/Mathlib/Algebra/Quaternion.lean index 45ac70fdc75648..ddf0adc010ee10 100644 --- a/Mathlib/Algebra/Quaternion.lean +++ b/Mathlib/Algebra/Quaternion.lean @@ -1173,6 +1173,18 @@ instance instRatCast : RatCast ℍ[R] where ratCast q := (q : R) @[norm_cast] lemma coe_ratCast (q : ℚ) : ↑(q : R) = (q : ℍ[R]) := rfl +section ofScientific +open OfScientific (ofScientific) +variable (m : ℕ) (s : Bool) (e : ℕ) + +@[norm_cast] lemma coe_ofScientific : ((ofScientific m s e : R) : ℍ[R]) = ofScientific m s e := rfl +@[simp] lemma re_ofScientific : (ofScientific m s e : ℍ[R]).re = ofScientific m s e := rfl +@[simp] lemma imI_ofScientific : (ofScientific m s e : ℍ[R]).imI = 0 := rfl +@[simp] lemma imJ_ofScientific : (ofScientific m s e : ℍ[R]).imJ = 0 := rfl +@[simp] lemma imK_ofScientific : (ofScientific m s e : ℍ[R]).imK = 0 := rfl + +end ofScientific + variable [LinearOrder R] [IsStrictOrderedRing R] (a b : ℍ[R]) @[simps -isSimp] diff --git a/Mathlib/Algebra/Regular/SMul.lean b/Mathlib/Algebra/Regular/SMul.lean index d504d483816eff..3d343ced450708 100644 --- a/Mathlib/Algebra/Regular/SMul.lean +++ b/Mathlib/Algebra/Regular/SMul.lean @@ -224,7 +224,7 @@ variable {G : Type*} [Group G] of the inverse given by groups, since there is no `LeftCancelSMul` typeclass. -/ theorem isSMulRegular_of_group [MulAction G R] (g : G) : IsSMulRegular R g := by intro x y h - convert congr_arg (g⁻¹ • ·) h using 1 <;> simp [← smul_assoc] + convert! congr_arg (g⁻¹ • ·) h using 1 <;> simp [← smul_assoc] end Group diff --git a/Mathlib/Algebra/Ring/AddAut.lean b/Mathlib/Algebra/Ring/AddAut.lean index c7009b3e0136ab..d8bda5c81870f6 100644 --- a/Mathlib/Algebra/Ring/AddAut.lean +++ b/Mathlib/Algebra/Ring/AddAut.lean @@ -29,7 +29,7 @@ variable {R : Type*} [Semiring R] /-- Left multiplication by a unit of a semiring as an additive automorphism. -/ @[simps! +simpRhs] -def mulLeft : Rˣ →* AddAut R := +def mulLeft : Rˣ →* Multiplicative (AddAut R) := DistribMulAction.toAddAut _ _ /-- Right multiplication by a unit of a semiring as an additive automorphism. -/ diff --git a/Mathlib/Algebra/Ring/Aut.lean b/Mathlib/Algebra/Ring/Aut.lean index f8cd5a3e7dc4fe..684a264ccf1283 100644 --- a/Mathlib/Algebra/Ring/Aut.lean +++ b/Mathlib/Algebra/Ring/Aut.lean @@ -49,7 +49,7 @@ instance : Inhabited (RingAut R) := ⟨1⟩ /-- Monoid homomorphism from ring automorphisms to additive automorphisms. -/ -def toAddAut : RingAut R →* AddAut R where +def toAddAut : RingAut R →* Multiplicative (AddAut R) where toFun := RingEquiv.toAddEquiv map_one' := rfl map_mul' _ _ := rfl diff --git a/Mathlib/Algebra/Ring/Defs.lean b/Mathlib/Algebra/Ring/Defs.lean index 398e284f9da78c..1583b6e91a0bf9 100644 --- a/Mathlib/Algebra/Ring/Defs.lean +++ b/Mathlib/Algebra/Ring/Defs.lean @@ -146,6 +146,12 @@ class Semiring (α : Type u) extends AddCommMonoid α, MonoidWithZero α, NonUni /-- A `Ring` is a `Semiring` with negation making it an additive group. -/ class Ring (R : Type u) extends Semiring R, AddCommGroup R, AddGroupWithOne R +-- Add some short-cut instances to avoid going through the less used ring type classes. +instance [Semiring α] : Distrib α := inferInstance +instance [Semiring α] : MulZeroClass α := inferInstance +instance [Semiring α] : MulZeroOneClass α := inferInstance +attribute [instance] Semiring.toMonoid + /-! ### Semirings -/ diff --git a/Mathlib/Algebra/Ring/Divisibility/Basic.lean b/Mathlib/Algebra/Ring/Divisibility/Basic.lean index d00b8e581f8fe5..1dbced56baea73 100644 --- a/Mathlib/Algebra/Ring/Divisibility/Basic.lean +++ b/Mathlib/Algebra/Ring/Divisibility/Basic.lean @@ -182,7 +182,7 @@ variable [NonUnitalCommRing α] theorem dvd_mul_sub_mul {k a b x y : α} (hab : k ∣ a - b) (hxy : k ∣ x - y) : k ∣ a * x - b * y := by - convert dvd_add (hxy.mul_left a) (hab.mul_right y) using 1 + convert! dvd_add (hxy.mul_left a) (hab.mul_right y) using 1 rw [mul_sub_left_distrib, mul_sub_right_distrib] simp only [sub_eq_add_neg, add_assoc, neg_add_cancel_left] diff --git a/Mathlib/Algebra/Ring/Ext.lean b/Mathlib/Algebra/Ring/Ext.lean index 0d6416b3b6feeb..b63f01d32ac5e8 100644 --- a/Mathlib/Algebra/Ring/Ext.lean +++ b/Mathlib/Algebra/Ring/Ext.lean @@ -339,8 +339,10 @@ theorem toNonUnitalRing_injective : theorem toNonAssocRing_injective : Function.Injective (@toNonAssocRing R) := by - intro _ _ _ - ext <;> congr + intro _ _ h + ext x y + · exact congrArg (·.toAdd.add x y) h + · exact congrArg (·.toMul.mul x y) h theorem toSemiring_injective : Function.Injective (@toSemiring R) := by diff --git a/Mathlib/Algebra/Ring/GeomSum.lean b/Mathlib/Algebra/Ring/GeomSum.lean index 4a08fe78ade23e..ebe98646620e31 100644 --- a/Mathlib/Algebra/Ring/GeomSum.lean +++ b/Mathlib/Algebra/Ring/GeomSum.lean @@ -152,7 +152,7 @@ lemma geom_sum₂_mul_of_ge (hxy : y ≤ x) (n : ℕ) : lemma geom_sum₂_mul_of_le (hxy : x ≤ y) (n : ℕ) : (∑ i ∈ range n, x ^ i * y ^ (n - 1 - i)) * (y - x) = y ^ n - x ^ n := by rw [← Finset.sum_range_reflect] - convert geom_sum₂_mul_of_ge hxy n using 3 + convert! geom_sum₂_mul_of_ge hxy n using 3 simp_all only [Finset.mem_range] rw [mul_comm] congr @@ -284,7 +284,7 @@ protected lemma Commute.geom_sum₂_Ico_mul (h : Commute x y) {m n : ℕ} have hp := Commute.pow_pow (Commute.op h.symm) (n - 1 - k) k simpa [Commute, SemiconjBy] using hp simp only [this] - convert (Commute.op h).mul_geom_sum₂_Ico hmn + convert! (Commute.op h).mul_geom_sum₂_Ico hmn lemma geom_sum_Ico_mul (x : R) {m n : ℕ} (hmn : m ≤ n) : (∑ i ∈ Finset.Ico m n, x ^ i) * (x - 1) = x ^ n - x ^ m := by diff --git a/Mathlib/Algebra/Ring/Idempotent.lean b/Mathlib/Algebra/Ring/Idempotent.lean index 83c8270ccafcb9..5e11e9f0f17344 100644 --- a/Mathlib/Algebra/Ring/Idempotent.lean +++ b/Mathlib/Algebra/Ring/Idempotent.lean @@ -143,7 +143,7 @@ theorem sub_iff [NonUnitalRing R] [IsAddTorsionFree R] {p q : R} simp_rw [sub_mul, add_mul, mul_assoc, hq.eq, add_sub_cancel_left, ← mul_assoc] at h2 exact h2.symm.trans h1 rw [hpq.eq, and_self, ← nsmul_right_inj (by simp : 2 ≠ 0), ← zero_add (2 • p)] - convert congrArg (· + 2 • p) h using 1 + convert! congrArg (· + 2 • p) h using 1 simp [sub_mul, mul_sub, hp.eq, hpq.eq, two_nsmul, sub_add, sub_sub] end IsIdempotentElem diff --git a/Mathlib/Algebra/Ring/Parity.lean b/Mathlib/Algebra/Ring/Parity.lean index 44d5c39bcaf2e4..8672c229f5f79c 100644 --- a/Mathlib/Algebra/Ring/Parity.lean +++ b/Mathlib/Algebra/Ring/Parity.lean @@ -220,27 +220,27 @@ lemma Odd.sub_odd (ha : Odd a) (hb : Odd b) : Even (a - b) := by @[simp] lemma even_add_one : Even (a + 1) ↔ Odd a := - ⟨(by convert ·.sub_odd odd_one; rw [eq_sub_iff_add_eq]), (·.add_one)⟩ + ⟨(by convert! ·.sub_odd odd_one; rw [eq_sub_iff_add_eq]), (·.add_one)⟩ @[simp] lemma even_sub_one : Even (a - 1) ↔ Odd a := - ⟨(by convert ·.add_odd odd_one; rw [sub_add_cancel]), (·.sub_odd odd_one)⟩ + ⟨(by convert! ·.add_odd odd_one; rw [sub_add_cancel]), (·.sub_odd odd_one)⟩ @[simp] lemma even_add_two : Even (a + 2) ↔ Even a := - ⟨(by convert ·.sub even_two; rw [eq_sub_iff_add_eq]), (·.add even_two)⟩ + ⟨(by convert! ·.sub even_two; rw [eq_sub_iff_add_eq]), (·.add even_two)⟩ @[simp] lemma even_sub_two : Even (a - 2) ↔ Even a := - ⟨(by convert ·.add even_two; rw [sub_add_cancel]), (·.sub even_two)⟩ + ⟨(by convert! ·.add even_two; rw [sub_add_cancel]), (·.sub even_two)⟩ @[simp] lemma odd_add_one : Odd (a + 1) ↔ Even a := - ⟨(by convert ·.sub_odd odd_one; rw [eq_sub_iff_add_eq]), (·.add_one)⟩ + ⟨(by convert! ·.sub_odd odd_one; rw [eq_sub_iff_add_eq]), (·.add_one)⟩ @[simp] lemma odd_sub_one : Odd (a - 1) ↔ Even a := - ⟨(by convert ·.add_odd odd_one; rw [sub_add_cancel]), (·.sub_odd odd_one)⟩ + ⟨(by convert! ·.add_odd odd_one; rw [sub_add_cancel]), (·.sub_odd odd_one)⟩ @[simp] lemma odd_add_two : Odd (a + 2) ↔ Odd a := by diff --git a/Mathlib/Algebra/Ring/Subring/Basic.lean b/Mathlib/Algebra/Ring/Subring/Basic.lean index c87b165c881707..4916cd9a6d7a6a 100644 --- a/Mathlib/Algebra/Ring/Subring/Basic.lean +++ b/Mathlib/Algebra/Ring/Subring/Basic.lean @@ -1152,7 +1152,7 @@ theorem comap_map_eq (f : R →+* S) (s : Subring R) : theorem comap_map_eq_self {f : R →+* S} {s : Subring R} (h : f ⁻¹' {0} ⊆ s) : (s.map f).comap f = s := by - convert comap_map_eq f s + convert! comap_map_eq f s rwa [left_eq_sup, closure_le] theorem comap_map_eq_self_of_injective @@ -1163,5 +1163,5 @@ end Subring theorem AddSubgroup.int_mul_mem {G : AddSubgroup R} (k : ℤ) {g : R} (h : g ∈ G) : (k : R) * g ∈ G := by - convert AddSubgroup.zsmul_mem G h k using 1 + convert! AddSubgroup.zsmul_mem G h k using 1 rw [zsmul_eq_mul] diff --git a/Mathlib/Algebra/Ring/Subsemiring/Basic.lean b/Mathlib/Algebra/Ring/Subsemiring/Basic.lean index e49a70e64d89b9..d3a7ab89c659ad 100644 --- a/Mathlib/Algebra/Ring/Subsemiring/Basic.lean +++ b/Mathlib/Algebra/Ring/Subsemiring/Basic.lean @@ -390,7 +390,7 @@ theorem closure_eq_of_le {s : Set R} {t : Subsemiring R} (h₁ : s ⊆ t) (h₂ theorem mem_map_equiv {f : R ≃+* S} {K : Subsemiring R} {x : S} : x ∈ K.map (f : R →+* S) ↔ f.symm x ∈ K := by - convert @Set.mem_image_equiv _ _ (↑K) f.toEquiv x using 1 + convert! @Set.mem_image_equiv _ _ (↑K) f.toEquiv x using 1 theorem map_equiv_eq_comap_symm (f : R ≃+* S) (K : Subsemiring R) : K.map (f : R →+* S) = K.comap f.symm := diff --git a/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean b/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean index 8199498397b672..ee81cf588c266b 100644 --- a/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean +++ b/Mathlib/Algebra/SkewMonoidAlgebra/Basic.lean @@ -1078,7 +1078,7 @@ theorem mapDomain_mul [MulSemiringAction α β] [MulSemiringAction α₂ β] ext a b c rw [sum_mapDomain_index (by simp) (by simp [smul_add, mul_add, single_add])] simp_rw [hf] - convert this using 4 + convert! this using 4 rw [map_sum] /-- If f : G → H is a multiplicative homomorphism between two monoids and diff --git a/Mathlib/Algebra/Star/NonUnitalSubalgebra.lean b/Mathlib/Algebra/Star/NonUnitalSubalgebra.lean index 57667d66965a5a..74e8b6544b458d 100644 --- a/Mathlib/Algebra/Star/NonUnitalSubalgebra.lean +++ b/Mathlib/Algebra/Star/NonUnitalSubalgebra.lean @@ -1224,7 +1224,7 @@ lemma adjoin_le_centralizer_centralizer (s : Set A) : adjoin R s ≤ centralizer R (centralizer R s) := by rw [← toNonUnitalSubalgebra_le_iff, centralizer_toNonUnitalSubalgebra, adjoin_toNonUnitalSubalgebra] - convert NonUnitalAlgebra.adjoin_le_centralizer_centralizer R (s ∪ star s) + convert! NonUnitalAlgebra.adjoin_le_centralizer_centralizer R (s ∪ star s) rw [StarMemClass.star_coe_eq] simp diff --git a/Mathlib/Algebra/Star/StarRingHom.lean b/Mathlib/Algebra/Star/StarRingHom.lean index 3a978d56dbf996..a3b62713103402 100644 --- a/Mathlib/Algebra/Star/StarRingHom.lean +++ b/Mathlib/Algebra/Star/StarRingHom.lean @@ -260,27 +260,26 @@ namespace StarRingEquivClass -- See note [lower instance priority] instance (priority := 50) {F A B : Type*} [Add A] [Mul A] [Star A] [Add B] [Mul B] [Star B] [EquivLike F A B] [hF : StarRingEquivClass F A B] : - StarHomClass F A B := - { hF with } + StarHomClass F A B where + __ := hF -- See note [lower instance priority] instance (priority := 100) {F A B : Type*} [NonUnitalNonAssocSemiring A] [Star A] - [NonUnitalNonAssocSemiring B] [Star B] [EquivLike F A B] [RingEquivClass F A B] - [StarRingEquivClass F A B] : NonUnitalStarRingHomClass F A B := - { } + [NonUnitalNonAssocSemiring B] [Star B] [EquivLike F A B] [StarRingEquivClass F A B] : + NonUnitalStarRingHomClass F A B where /-- Turn an element of a type `F` satisfying `StarRingEquivClass F A B` into an actual `StarRingEquiv`. This is declared as the default coercion from `F` to `A ≃⋆+* B`. -/ @[coe] def toStarRingEquiv {F A B : Type*} [Add A] [Mul A] [Star A] [Add B] [Mul B] [Star B] - [EquivLike F A B] [RingEquivClass F A B] [StarRingEquivClass F A B] (f : F) : A ≃⋆+* B := + [EquivLike F A B] [StarRingEquivClass F A B] (f : F) : A ≃⋆+* B := { (RingEquivClass.toRingEquiv f : A ≃+* B) with map_star' := map_star f } /-- Any type satisfying `StarRingEquivClass` can be cast into `StarRingEquiv` via `StarRingEquivClass.toStarRingEquiv`. -/ instance instCoeHead {F A B : Type*} [Add A] [Mul A] [Star A] [Add B] [Mul B] [Star B] - [EquivLike F A B] [RingEquivClass F A B] [StarRingEquivClass F A B] : CoeHead F (A ≃⋆+* B) := + [EquivLike F A B] [StarRingEquivClass F A B] : CoeHead F (A ≃⋆+* B) := ⟨toStarRingEquiv⟩ end StarRingEquivClass diff --git a/Mathlib/Algebra/Star/Subalgebra.lean b/Mathlib/Algebra/Star/Subalgebra.lean index 5c70c3f315a805..973298bd7d4871 100644 --- a/Mathlib/Algebra/Star/Subalgebra.lean +++ b/Mathlib/Algebra/Star/Subalgebra.lean @@ -579,7 +579,7 @@ variable (R) lemma adjoin_le_centralizer_centralizer (s : Set A) : adjoin R s ≤ centralizer R (centralizer R s) := by rw [← toSubalgebra_le_iff, centralizer_toSubalgebra, adjoin_toSubalgebra] - convert Algebra.adjoin_le_centralizer_centralizer R (s ∪ star s) + convert! Algebra.adjoin_le_centralizer_centralizer R (s ∪ star s) rw [StarMemClass.star_coe_eq] simp diff --git a/Mathlib/Algebra/Star/TensorProduct.lean b/Mathlib/Algebra/Star/TensorProduct.lean index e4b70bb63681dd..2ba906bc061389 100644 --- a/Mathlib/Algebra/Star/TensorProduct.lean +++ b/Mathlib/Algebra/Star/TensorProduct.lean @@ -35,7 +35,7 @@ noncomputable instance : InvolutiveStar (A ⊗[R] B) where star_involutive x := by simp_rw [star] rw [congr_congr] - convert congr($congr_refl_refl x) <;> ext <;> simp + convert! congr($congr_refl_refl x) <;> ext <;> simp noncomputable instance : StarAddMonoid (A ⊗[R] B) where star_add := map_add _ diff --git a/Mathlib/Algebra/Symmetrized.lean b/Mathlib/Algebra/Symmetrized.lean index 9a6ac8283f9827..87503423a78036 100644 --- a/Mathlib/Algebra/Symmetrized.lean +++ b/Mathlib/Algebra/Symmetrized.lean @@ -318,7 +318,7 @@ instance [Ring α] [Invertible (2 : α)] : IsCommJordan αˢʸᵐ where rw [add_mul, ← add_assoc, ← mul_assoc, ← mul_assoc] rw [unsym_mul_self] rw [← mul_assoc, ← mul_assoc, ← mul_assoc, ← mul_assoc, ← sub_eq_zero, ← mul_sub] - convert mul_zero (⅟(2 : α) * ⅟(2 : α)) + convert! mul_zero (⅟(2 : α) * ⅟(2 : α)) rw [add_sub_add_right_eq_sub, add_assoc, add_assoc, add_sub_add_left_eq_sub, add_comm, add_sub_add_right_eq_sub, sub_eq_zero] -- Rearrange RHS diff --git a/Mathlib/Algebra/TrivSqZeroExt/Basic.lean b/Mathlib/Algebra/TrivSqZeroExt/Basic.lean index 780d60faf98b42..6eafdd9b83c3dc 100644 --- a/Mathlib/Algebra/TrivSqZeroExt/Basic.lean +++ b/Mathlib/Algebra/TrivSqZeroExt/Basic.lean @@ -707,7 +707,7 @@ abbrev invertibleFstOfInvertible (x : tsze R M) [Invertible x] : Invertible x.fs theorem fst_invOf (x : tsze R M) [Invertible x] [Invertible x.fst] : (⅟x).fst = ⅟(x.fst) := by letI := invertibleFstOfInvertible x - convert (rfl : _ = ⅟x.fst) + convert! (rfl : _ = ⅟x.fst) theorem mul_left_eq_one (r : R) (x : tsze R M) (h : r * x.fst = 1) : (inl r + inr (-((r •> x.snd) <• r))) * x = 1 := by @@ -728,17 +728,17 @@ variable [SMulCommClass R Rᵐᵒᵖ M] abbrev invertibleOfInvertibleFst (x : tsze R M) [Invertible x.fst] : Invertible x where invOf := (⅟x.fst, -(⅟x.fst •> x.snd <• ⅟x.fst)) invOf_mul_self := by - convert mul_left_eq_one _ _ (invOf_mul_self x.fst) + convert! mul_left_eq_one _ _ (invOf_mul_self x.fst) ext <;> simp mul_invOf_self := by - convert mul_right_eq_one _ _ (mul_invOf_self x.fst) + convert! mul_right_eq_one _ _ (mul_invOf_self x.fst) ext <;> simp [smul_comm] theorem snd_invOf (x : tsze R M) [Invertible x] [Invertible x.fst] : (⅟x).snd = -(⅟x.fst •> x.snd <• ⅟x.fst) := by letI := invertibleOfInvertibleFst x - convert congr_arg (TrivSqZeroExt.snd (R := R) (M := M)) (_ : _ = ⅟x) - convert rfl + convert! congr_arg (TrivSqZeroExt.snd (R := R) (M := M)) (_ : _ = ⅟x) + convert! rfl /-- Together `TrivSqZeroExt.detInvertibleOfInvertible` and `TrivSqZeroExt.invertibleOfDetInvertible` form an equivalence, although both sides of the equiv are subsingleton anyway. -/ @@ -788,7 +788,7 @@ protected theorem inv_one : (1 : tsze R M)⁻¹ = (1 : tsze R M) := by rw [← inl_one, TrivSqZeroExt.inv_inl, inv_one] protected theorem inv_mul_cancel {x : tsze R M} (hx : fst x ≠ 0) : x⁻¹ * x = 1 := by - convert mul_left_eq_one _ _ (_root_.inv_mul_cancel₀ hx) using 2 + convert! mul_left_eq_one _ _ (_root_.inv_mul_cancel₀ hx) using 2 ext <;> simp variable [SMulCommClass R Rᵐᵒᵖ M] diff --git a/Mathlib/Algebra/Tropical/BigOperators.lean b/Mathlib/Algebra/Tropical/BigOperators.lean index 44cc67224797c5..c9dd058dada748 100644 --- a/Mathlib/Algebra/Tropical/BigOperators.lean +++ b/Mathlib/Algebra/Tropical/BigOperators.lean @@ -50,7 +50,7 @@ theorem Multiset.trop_sum [AddCommMonoid R] (s : Multiset R) : theorem trop_sum [AddCommMonoid R] (s : Finset S) (f : S → R) : trop (∑ i ∈ s, f i) = ∏ i ∈ s, trop (f i) := by - convert Multiset.trop_sum (s.val.map f) + convert! Multiset.trop_sum (s.val.map f) simp only [Multiset.map_map, Function.comp_apply] rfl @@ -66,7 +66,7 @@ theorem Multiset.untrop_prod [AddCommMonoid R] (s : Multiset (Tropical R)) : theorem untrop_prod [AddCommMonoid R] (s : Finset S) (f : S → Tropical R) : untrop (∏ i ∈ s, f i) = ∑ i ∈ s, untrop (f i) := by - convert Multiset.untrop_prod (s.val.map f) + convert! Multiset.untrop_prod (s.val.map f) simp only [Multiset.map_map, Function.comp_apply] rfl @@ -84,7 +84,7 @@ theorem Multiset.trop_inf [LinearOrder R] [OrderTop R] (s : Multiset R) : theorem Finset.trop_inf [LinearOrder R] [OrderTop R] (s : Finset S) (f : S → R) : trop (s.inf f) = ∑ i ∈ s, trop (f i) := by - convert Multiset.trop_inf (s.val.map f) + convert! Multiset.trop_inf (s.val.map f) simp only [Multiset.map_map, Function.comp_apply] rfl @@ -106,7 +106,7 @@ theorem Multiset.untrop_sum [LinearOrder R] [OrderTop R] (s : Multiset (Tropical theorem Finset.untrop_sum' [LinearOrder R] [OrderTop R] (s : Finset S) (f : S → Tropical R) : untrop (∑ i ∈ s, f i) = s.inf (untrop ∘ f) := by - convert Multiset.untrop_sum (s.val.map f) + convert! Multiset.untrop_sum (s.val.map f) simp only [Multiset.map_map, Function.comp_apply, inf_def] theorem untrop_sum_eq_sInf_image [ConditionallyCompleteLinearOrder R] (s : Finset S) diff --git a/Mathlib/AlgebraicGeometry/AffineScheme.lean b/Mathlib/AlgebraicGeometry/AffineScheme.lean index 6d88881da5d29d..bbf0e4b5ae7347 100644 --- a/Mathlib/AlgebraicGeometry/AffineScheme.lean +++ b/Mathlib/AlgebraicGeometry/AffineScheme.lean @@ -264,7 +264,7 @@ theorem isAffineOpen_opensRange {X Y : Scheme} [IsAffine X] (f : X ⟶ Y) exact Subtype.range_val.symm theorem isAffineOpen_top (X : Scheme) [IsAffine X] : IsAffineOpen (⊤ : X.Opens) := by - convert isAffineOpen_opensRange (𝟙 X) + convert! isAffineOpen_opensRange (𝟙 X) ext1 exact Set.range_id.symm @@ -321,8 +321,9 @@ theorem Scheme.map_PrimeSpectrum_basicOpen_of_affine theorem isBasis_basicOpen (X : Scheme) [IsAffine X] : Opens.IsBasis (Set.range (X.basicOpen : Γ(X, ⊤) → X.Opens)) := by - convert PrimeSpectrum.isBasis_basic_opens.of_isInducing - (TopCat.homeoOfIso (Scheme.forgetToTop.mapIso X.isoSpec)).isInducing using 1 + convert! + PrimeSpectrum.isBasis_basic_opens.of_isInducing + (TopCat.homeoOfIso (Scheme.forgetToTop.mapIso X.isoSpec)).isInducing using 1 ext V simp only [Set.mem_range, exists_exists_eq_and, Set.mem_setOf, ← Opens.coe_inj (V := V), ← Scheme.toSpecΓ_preimage_basicOpen] @@ -496,9 +497,8 @@ lemma fromSpec_app_of_le (V : X.Opens) (h : U ≤ V) : include hU in protected theorem isCompact : IsCompact (U : Set X) := by - convert @IsCompact.image _ _ _ _ Set.univ hU.fromSpec PrimeSpectrum.compactSpace.1 - (by fun_prop) - convert hU.range_fromSpec.symm + convert! @IsCompact.image _ _ _ _ Set.univ hU.fromSpec PrimeSpectrum.compactSpace.1 (by fun_prop) + convert! hU.range_fromSpec.symm exact Set.image_univ theorem _root_.AlgebraicGeometry.Scheme.Hom.isAffineOpen_iff_of_isOpenImmersion @@ -594,8 +594,9 @@ include hU in theorem basicOpen : IsAffineOpen (X.basicOpen f) := by rw [← hU.fromSpec_image_basicOpen, Scheme.Hom.isAffineOpen_iff_of_isOpenImmersion] - convert isAffineOpen_opensRange - (Spec.map (CommRingCat.ofHom <| algebraMap Γ(X, U) (Localization.Away f))) + convert! + isAffineOpen_opensRange + (Spec.map (CommRingCat.ofHom <| algebraMap Γ(X, U) (Localization.Away f))) exact Opens.ext (PrimeSpectrum.localization_away_comap_range (Localization.Away f) f).symm lemma Spec_basicOpen {R : CommRingCat} (f : R) : @@ -657,7 +658,7 @@ theorem isLocalization_basicOpen : apply (IsLocalization.isLocalization_iff_of_ringEquiv (Submonoid.powers f) (asIso <| basicOpenSectionsToAffine hU f).commRingCatIsoToRingEquiv).mpr - convert StructureSheaf.IsLocalization.to_basicOpen _ f using 1 + convert! StructureSheaf.IsLocalization.to_basicOpen _ f using 1 apply Algebra.algebra_ext intro _ congr 1 @@ -802,7 +803,7 @@ theorem isLocalization_stalk' (y : PrimeSpectrum Γ(X, U)) (hy : hU.fromSpec y (S := X.presheaf.stalk (hU.fromSpec y)) _ y.asIdeal.primeCompl _ (TopCat.Presheaf.algebra_section_stalk X.presheaf ⟨hU.fromSpec y, hy⟩) _ _ (asIso <| hU.fromSpec.stalkMap y).commRingCatIsoToRingEquiv).mpr - convert StructureSheaf.IsLocalization.to_stalk Γ(X, U) y using 1 + convert! StructureSheaf.IsLocalization.to_stalk Γ(X, U) y using 1 delta IsLocalization.AtPrime StructureSheaf.stalkAlgebra congr! simp [RingHom.algebraMap_toAlgebra, ← CommRingCat.hom_comp, IsAffineOpen.fromSpec_app_self] @@ -1032,7 +1033,7 @@ theorem of_affine_open_cover {X : Scheme} {P : X.affineOpens → Prop} obtain ⟨i, hi⟩ := Opens.mem_iSup.mp (iSup_U.ge (Set.mem_univ x)) obtain ⟨f, g, e, hf⟩ := exists_basicOpen_le_affine_inter V.prop (U i).prop x ⟨x.prop, hi⟩ refine ⟨f, hf, ?_⟩ - convert basicOpen _ g (hU i) using 1 + convert! basicOpen _ g (hU i) using 1 ext1 exact e choose f hf₁ hf₂ using this diff --git a/Mathlib/AlgebraicGeometry/AffineSpace.lean b/Mathlib/AlgebraicGeometry/AffineSpace.lean index b892058edf577c..15a4630cd7fdba 100644 --- a/Mathlib/AlgebraicGeometry/AffineSpace.lean +++ b/Mathlib/AlgebraicGeometry/AffineSpace.lean @@ -318,7 +318,7 @@ lemma isPullback_map {S T : Scheme.{max u v}} (f : S ⟶ T) : IsPullback (map n f) (𝔸(n; S) ↘ S) (𝔸(n; T) ↘ T) f := by refine (IsPullback.paste_horiz_iff (.flip <| .of_hasPullback _ _) (map_over f)).mp ?_ simp only [terminal.comp_from, ] - convert (IsPullback.of_hasPullback _ _).flip + convert! (IsPullback.of_hasPullback _ _).flip rw [← toSpecMvPoly, ← toSpecMvPoly, map_toSpecMvPoly] /-- `𝔸(n; S)` is functorial w.r.t. `n`. -/ @@ -374,7 +374,7 @@ instance [Finite n] : LocallyOfFinitePresentation (𝔸(n; S) ↘ S) := rw [← terminal.comp_from (Spec.map (CommRingCat.ofHom C)), MorphismProperty.cancel_right_of_respectsIso (P := @LocallyOfFinitePresentation), HasRingHomProperty.Spec_iff (P := @LocallyOfFinitePresentation), RingHom.FinitePresentation] - convert (inferInstance : Algebra.FinitePresentation (ULift ℤ) ℤ[n]) + convert! (inferInstance : Algebra.FinitePresentation (ULift ℤ) ℤ[n]) exact Algebra.algebra_ext _ _ fun _ ↦ rfl lemma isOpenMap_over : IsOpenMap (𝔸(n; S) ↘ S) := by diff --git a/Mathlib/AlgebraicGeometry/AffineTransitionLimit.lean b/Mathlib/AlgebraicGeometry/AffineTransitionLimit.lean index 08b1ad50d9a1fe..ddcd6db5faee5d 100644 --- a/Mathlib/AlgebraicGeometry/AffineTransitionLimit.lean +++ b/Mathlib/AlgebraicGeometry/AffineTransitionLimit.lean @@ -237,18 +237,20 @@ instance [∀ {i j} (f : i ⟶ j), IsAffineHom (D.map f)] {i : I} (U : (D.obj i).Opens) {j k : Over i} (f : j ⟶ k) : IsAffineHom ((opensDiagram D i U).map f) := by refine ⟨fun V hV ↦ ?_⟩ - convert ((hV.image_of_isOpenImmersion (D.map k.hom ⁻¹ᵁ U).ι).preimage - (D.map f.left)).preimage_of_isOpenImmersion (D.map j.hom ⁻¹ᵁ U).ι ?_ + convert! + ((hV.image_of_isOpenImmersion (D.map k.hom ⁻¹ᵁ U).ι).preimage + (D.map f.left)).preimage_of_isOpenImmersion + (D.map j.hom ⁻¹ᵁ U).ι ?_ · ext x change _ ∈ V ↔ _ refine ⟨fun h ↦ ⟨⟨(D.map f.left).base x.1, ?_⟩, ?_, rfl⟩, ?_⟩ · change (D.map f.left ≫ D.map k.hom).base x.1 ∈ U rw [← D.map_comp, Over.w f] exact x.2 - · convert h + · convert! h exact Subtype.ext (by simp) · rintro ⟨⟨_, hU⟩, hV, rfl⟩ - convert hV + convert! hV exact Subtype.ext (by simp) · simp only [opensDiagram_obj, Scheme.Opens.opensRange_ι] rintro x ⟨⟨y, h₁ : (D.map k.hom).base y ∈ U⟩, h₂, e⟩ @@ -314,8 +316,9 @@ lemma isBasis_preimage_isAffineOpen [IsCofiltered I] [∀ {i j} (f : i ⟶ j), I obtain ⟨s, rfl⟩ := (D.map j.hom ⁻¹ᵁ V).topIso.symm.commRingCatIsoToRingEquiv.surjective s have h : c.π.app j.left ⁻¹ᵁ D.map j.hom ⁻¹ᵁ V = c.π.app i ⁻¹ᵁ V := congr($(c.w j.hom) ⁻¹ᵁ V) have : r = (c.π.app j.left).appLE (D.map j.hom ⁻¹ᵁ V) (c.π.app i ⁻¹ᵁ V) h.ge s := by - convert show r = ((topIso _).inv ≫ ((opensCone D c i V).π.app j).appTop ≫ (topIso _).hom) s - from (c.π.app i ⁻¹ᵁ V).topIso.commRingCatIsoToRingEquiv.symm_apply_eq.mp hs.symm using 3 + convert! + show r = ((topIso _).inv ≫ ((opensCone D c i V).π.app j).appTop ≫ (topIso _).hom) s from + (c.π.app i ⁻¹ᵁ V).topIso.commRingCatIsoToRingEquiv.symm_apply_eq.mp hs.symm using 3 simp [Scheme.Hom.app_eq_appLE, Scheme.Hom.resLE_appLE] refine ⟨_, ⟨j.left, _, (hV.preimage _).basicOpen s, rfl⟩, ?_⟩ simp only [Functor.const_obj_obj, Scheme.preimage_basicOpen] at this ⊢ @@ -731,14 +734,14 @@ lemma exists_appTop_map_eq_zero_of_isLimit [∀ {i j} (f : i ⟶ j), IsAffineHom have (j : Over i) : IsAffine ((opensDiagram D i U).obj j) := hU.preimage (D.map _) obtain ⟨j, f, hj⟩ := exists_appTop_map_eq_zero_of_isAffine_of_isLimit _ _ (isLimitOpensCone D c hc i U) (.mk (𝟙 i)) (((opensDiagramι D i U).app _).appTop s) (by - convert congr((c.pt.presheaf.map (homOfLE le_top).op).hom $hs) using 1 + convert! congr((c.pt.presheaf.map (homOfLE le_top).op).hom $hs) using 1 · simp [Scheme.Hom.app_eq_appLE, Scheme.Hom.resLE_appLE, ← ConcreteCategory.comp_apply]; rfl · simp) refine ⟨U, hU, hxU, j.left, j.hom, ?_⟩ have hf : f.left = j.hom := by simpa using Over.w f let t' : Γ(D.map j.hom ⁻¹ᵁ U, ⊤) ⟶ Γ(D.obj j.left, D.map j.hom ⁻¹ᵁ U) := (D.obj _).presheaf.map (eqToHom ((D.map j.hom ⁻¹ᵁ U).ι_image_top.symm)).op - convert congr(t' $hj) + convert! congr(t' $hj) · dsimp [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict] simp only [Scheme.Hom.app_eq_appLE, homOfLE_leOfHom, ← ConcreteCategory.comp_apply, hf, Scheme.Hom.map_appLE, TopologicalSpace.Opens.map_top, Scheme.Hom.resLE_appLE] @@ -761,7 +764,7 @@ lemma exists_appTop_map_eq_zero_of_isLimit [∀ {i j} (f : i ⟶ j), IsAffineHom have h₂ : D.map (fk (Finset.mem_insert_self _ _)) ⁻¹ᵁ U l ≤ D.map (fk (Finset.mem_insert_of_mem (Finset.mem_image_of_mem _ hl))) ⁻¹ᵁ D.map (f l) ⁻¹ᵁ U l := by rw [← Scheme.Hom.comp_preimage, ← D.map_comp, h₁] - convert congr((D.map (fk _)).appLE _ _ h₂ $(H l)) + convert! congr((D.map (fk _)).appLE _ _ h₂ $(H l)) · dsimp [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict] simp [Scheme.Hom.app_eq_appLE, ← ConcreteCategory.comp_apply, -CommRingCat.hom_comp, Scheme.Hom.appLE_comp_appLE, ← Functor.map_comp, h₁] @@ -788,8 +791,9 @@ lemma exists_app_map_eq_zero_of_isLimit [∀ {i j} (f : i ⟶ j), IsAffineHom (D dsimp at hf refine ⟨j.left, f.left, ?_⟩ have hf' : f.left = j.hom := by simpa using Over.w f - convert congr((D.obj j.left).presheaf.map (homOfLE - (show D.map f.left ⁻¹ᵁ U ≤ (D.map j.hom ⁻¹ᵁ U).ι ''ᵁ ⊤ by simp [hf'])).op $hf) + convert! + congr((D.obj j.left).presheaf.map + (homOfLE (show D.map f.left ⁻¹ᵁ U ≤ (D.map j.hom ⁻¹ᵁ U).ι ''ᵁ ⊤ by simp [hf'])).op $hf) · dsimp [Scheme.Opens.toScheme_presheaf_obj] rw [← ConcreteCategory.comp_apply, ← ConcreteCategory.comp_apply] congr! 2 @@ -834,8 +838,8 @@ lemma exists_appTop_π_eq_of_isLimit [∀ {i j} (f : i ⟶ j), IsAffineHom (D.ma rwa [Cone.w] · have H : c.π.app j.left ⁻¹ᵁ (D.map j.hom ⁻¹ᵁ U).ι ''ᵁ ⊤ ≤ (c.π.app i ⁻¹ᵁ U).ι ''ᵁ ⊤ := by simp [← Scheme.Hom.comp_preimage] - convert congr(c.pt.presheaf.map (homOfLE H).op $hj) - · convert ConcreteCategory.comp_apply _ _ _ + convert! congr(c.pt.presheaf.map (homOfLE H).op $hj) + · convert! ConcreteCategory.comp_apply _ _ _ congr simp [Scheme.Hom.app_eq_appLE, Scheme.Hom.resLE_appLE] · dsimp [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict] @@ -903,8 +907,9 @@ lemma exists_appTop_π_eq_of_isLimit [∀ {i j} (f : i ⟶ j), IsAffineHom (D.ma rw [← Functor.map_comp, ← Functor.map_comp, Category.assoc, Category.assoc, hk₁ x.2 y.2, hk₂ x.2 y.2, le_inf_iff] exact ⟨fVx.le, fVy.le⟩ - convert congr(((D.map (fk'k ≫ fk (hjS x.2 y.2))).app _ ≫ - (D.obj k').presheaf.map (homOfLE H).op) $(hj x y)) using 1 + convert! + congr(((D.map (fk'k ≫ fk (hjS x.2 y.2))).app _ ≫ (D.obj k').presheaf.map (homOfLE H).op) + $(hj x y)) using 1 · dsimp [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict] simp only [← ConcreteCategory.comp_apply] congr 2 @@ -920,7 +925,7 @@ lemma exists_appTop_π_eq_of_isLimit [∀ {i j} (f : i ⟶ j), IsAffineHom (D.ma have H : c.π.app (i (σi y)) ⁻¹ᵁ U (σi y) ≤ c.π.app k' ⁻¹ᵁ D.map (fk'k ≫ fk (hiS (hσiσ _))) ⁻¹ᵁ U (σi y) := by rw [← Scheme.Hom.comp_preimage, Cone.w] - convert congr(c.pt.presheaf.map (homOfLE H).op ((c.π.app k').app _ $(ht₀ ⟨_, hσiσ y⟩))).symm + convert! congr(c.pt.presheaf.map (homOfLE H).op ((c.π.app k').app _ $(ht₀ ⟨_, hσiσ y⟩))).symm · refine (ht (σi y)).symm.trans ?_ dsimp [Scheme.Opens.toScheme_presheaf_obj] rw [← ConcreteCategory.comp_apply, ← ConcreteCategory.comp_apply] @@ -979,7 +984,8 @@ lemma Scheme.exists_isQuasiAffine_of_isLimit [IsCofiltered I] rwa [← preimage_basicOpen_top, ← Hom.comp_preimage, ← Hom.comp_preimage, c.w, c.w, preimage_basicOpen_top]) refine ⟨l, (D.map (flk ≫ fkj)).appTop r, ?_, ?_⟩ - · convert (hU.preimage (D.map (flk ≫ fki))).basicOpen + · convert! + (hU.preimage (D.map (flk ≫ fki))).basicOpen ((D.obj _).presheaf.map (homOfLE le_top).op ((D.map (flk ≫ fkj)).appTop r)) using 1 rwa [Scheme.basicOpen_res, eq_comm, inf_eq_right, Functor.map_comp, elementwise_of% Scheme.Hom.comp_appTop, ← Scheme.preimage_basicOpen_top, Functor.map_comp, diff --git a/Mathlib/AlgebraicGeometry/Birational/Dominant.lean b/Mathlib/AlgebraicGeometry/Birational/Dominant.lean new file mode 100644 index 00000000000000..51b3684889c0f1 --- /dev/null +++ b/Mathlib/AlgebraicGeometry/Birational/Dominant.lean @@ -0,0 +1,90 @@ +/- +Copyright (c) 2026 Justus Springer. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Justus Springer +-/ +module + +public import Mathlib.AlgebraicGeometry.Birational.RationalMap +/-! + +# Dominant rational maps + +This file defines `RationalMap.IsDominant` and establishes its connection to +`IsDominant` on the underlying partial maps. + +## Main definition + +- `Scheme.RationalMap.IsDominant`: a rational map is dominant if some (equivalently, any) + representative partial map has dominant underlying morphism. + +-/ + +@[expose] public section + +universe u + +open CategoryTheory + +namespace AlgebraicGeometry + +variable {X Y : Scheme.{u}} + +namespace Scheme + +namespace PartialMap + +/-- Restricting a dominant partial map to a dense open yields a dominant partial map. -/ +lemma isDominant_restrict_hom (f : X.PartialMap Y) [IsDominant f.hom] (U : X.Opens) + (hU : Dense (U : Set X)) (hU' : U ≤ f.domain) : IsDominant (f.restrict U hU hU').hom := by + dsimp only [restrict_domain, restrict_hom] + have : IsDominant (X.homOfLE hU') := Opens.isDominant_homOfLE hU hU' + rwa [IsDominant.comp_iff] + +/-- If a restriction of `f` is dominant, then `f` is dominant. -/ +lemma isDominant_hom_of_isDominant_restrict_hom (f : X.PartialMap Y) (U : X.Opens) + (hU : Dense (U : Set X)) (hU' : U ≤ f.domain) [H : IsDominant (f.restrict U hU hU').hom] : + IsDominant f.hom := + IsDominant.of_comp (X.homOfLE hU') f.hom (H := H) + +/-- `f.hom` is dominant iff any restriction of `f` is. -/ +lemma isDominant_hom_iff_isDominant_restrict_hom (f : X.PartialMap Y) (U : X.Opens) + (hU : Dense (U : Set X)) (hU' : U ≤ f.domain) : + IsDominant f.hom ↔ IsDominant (f.restrict U hU hU').hom := + ⟨fun _ ↦ f.isDominant_restrict_hom U hU hU', + fun _ ↦ f.isDominant_hom_of_isDominant_restrict_hom U hU hU'⟩ + +/-- Dominance of the underlying morphism is invariant under equivalence of partial maps. -/ +lemma isDominant_hom_iff_of_equiv (f g : X.PartialMap Y) (h : f.equiv g) : + IsDominant f.hom ↔ IsDominant g.hom := by + obtain ⟨W, hW, hWl, hWr, h⟩ := h + have e₁ := isDominant_hom_iff_isDominant_restrict_hom f W hW hWl + have e₂ := isDominant_hom_iff_isDominant_restrict_hom g W hW hWr + dsimp only [restrict_domain, restrict_hom] at ⊢ e₁ e₂ h + rw [e₁, h, ← e₂] + +end PartialMap + +/-- A rational map is dominant if some (equivalently, any) representative partial map has +dominant underlying morphism. -/ +@[mk_iff, stacks 0A1Z] +protected class RationalMap.IsDominant (f : X ⤏ Y) : Prop where + out : Quotient.liftOn f (fun g ↦ IsDominant g.hom) <| fun _ _ h ↦ + propext (PartialMap.isDominant_hom_iff_of_equiv _ _ h) + +@[simp] +lemma PartialMap.isDominant_toRationalMap_iff (f : X.PartialMap Y) : + f.toRationalMap.IsDominant ↔ IsDominant f.hom := + f.toRationalMap.isDominant_iff + +instance (f : X.PartialMap Y) [IsDominant f.hom] : + f.toRationalMap.IsDominant := by + rwa [f.isDominant_toRationalMap_iff] + +instance (f : X ⤏ Y) [f.IsDominant] : + IsDominant f.representative.hom := by + rwa [← f.representative.isDominant_toRationalMap_iff, f.toRationalMap_representative] + +end Scheme + +end AlgebraicGeometry diff --git a/Mathlib/AlgebraicGeometry/Birational/RationalMap.lean b/Mathlib/AlgebraicGeometry/Birational/RationalMap.lean index bd67cca3b9d31e..1b1973efa37275 100644 --- a/Mathlib/AlgebraicGeometry/Birational/RationalMap.lean +++ b/Mathlib/AlgebraicGeometry/Birational/RationalMap.lean @@ -254,7 +254,7 @@ lemma equiv_of_fromSpecStalkOfMem_eq [IrreducibleSpace X] ((Set.image_subset_range _ _).trans_eq (Subtype.range_val)).trans inf_le_right, ?_⟩ rw [← cancel_epi (Scheme.Hom.isoImage _ _).hom] simp only [restrict_hom, ← Category.assoc] at e ⊢ - convert e using 2 <;> rw [← cancel_mono (Scheme.Opens.ι _)] <;> simp + convert! e using 2 <;> rw [← cancel_mono (Scheme.Opens.ι _)] <;> simp · rw [← f.fromSpecStalkOfMem_restrict hdense inf_le_left ⟨hxf, hxg⟩, ← g.fromSpecStalkOfMem_restrict hdense inf_le_right ⟨hxf, hxg⟩] at H simpa only [fromSpecStalkOfMem, restrict_domain, Opens.fromSpecStalkOfMem, Spec.map_inv, @@ -334,6 +334,20 @@ lemma PartialMap.toRationalMap_eq_iff {f g : X.PartialMap Y} : f.toRationalMap = g.toRationalMap ↔ f.equiv g := Quotient.eq +/-- An arbitrarily chosen partial map representing `f`. Use `RationalMap.toPartialMap` instead +if `X` is reduced and `Y` is separated. -/ +noncomputable def RationalMap.representative (f : X ⤏ Y) : X.PartialMap Y := + f.exists_rep.choose + +@[simp] +lemma RationalMap.toRationalMap_representative (f : X ⤏ Y) : + f.representative.toRationalMap = f := + f.exists_rep.choose_spec + +lemma PartialMap.representative_toRationalMap_equiv (f : X.PartialMap Y) : + f.toRationalMap.representative.equiv f := by + rw [← PartialMap.toRationalMap_eq_iff, f.toRationalMap.toRationalMap_representative] + @[simp] lemma PartialMap.restrict_toRationalMap (f : X.PartialMap Y) (U : X.Opens) (hU : Dense (U : Set X)) (hU' : U ≤ f.domain) : @@ -516,7 +530,7 @@ def RationalMap.toPartialMap [IsReduced X] [Y.IsSeparated] (f : X ⤏ Y) : X.Par IsPullback.isoPullback_hom_snd_assoc] change _ ≫ _ ≫ (g x).hom = _ ≫ _ ≫ (g y).hom simp_rw [← cancel_epi (X.isoOfEq congr($(hg₂ x) ⊓ $(hg₂ y))).hom, ← Category.assoc] - convert (PartialMap.equiv_iff_of_isSeparated (S := ⊤_ _) (f := g x) (g := g y)).mp ?_ using 1 + convert! (PartialMap.equiv_iff_of_isSeparated (S := ⊤_ _) (f := g x) (g := g y)).mp ?_ using 1 · dsimp; congr 1; simp [g, ← cancel_mono (Opens.ι _)] · dsimp; congr 1; simp [g, ← cancel_mono (Opens.ι _)] · rw [← PartialMap.toRationalMap_eq_iff, hg₁, hg₁] diff --git a/Mathlib/AlgebraicGeometry/Cover/Directed.lean b/Mathlib/AlgebraicGeometry/Cover/Directed.lean index 66524d329a8402..d72b37063ec79d 100644 --- a/Mathlib/AlgebraicGeometry/Cover/Directed.lean +++ b/Mathlib/AlgebraicGeometry/Cover/Directed.lean @@ -186,7 +186,7 @@ instance locallyDirectedPullbackCover : Cover.LocallyDirected (𝒰.pullback₁ simp only [Precoverage.ZeroHypercover.pullback₁_toPreZeroHypercover, PreZeroHypercover.pullback₁_X, Iso.trans_inv, Iso.symm_inv, pullback.congrHom_inv, Category.assoc, iso] - convert P.pullback_fst (pullback.snd f (𝒰.f j)) _ (𝒰.property_trans hij) + convert! P.pullback_fst (pullback.snd f (𝒰.f j)) _ (𝒰.property_trans hij) apply pullback.hom_ext <;> simp [pullback.condition] end BaseChange @@ -315,7 +315,7 @@ instance : Preorder X.directedAffineCover.I₀ := inferInstanceAs <| Preorder X. instance : Scheme.Cover.LocallyDirected X.directedAffineCover := .ofIsBasisOpensRange (by intros; simp; rfl) <| by - convert X.isBasis_affineOpens + convert! X.isBasis_affineOpens simp @[simp] diff --git a/Mathlib/AlgebraicGeometry/Cover/Open.lean b/Mathlib/AlgebraicGeometry/Cover/Open.lean index b6dec005a93fb7..920ff977a9ab90 100644 --- a/Mathlib/AlgebraicGeometry/Cover/Open.lean +++ b/Mathlib/AlgebraicGeometry/Cover/Open.lean @@ -178,8 +178,8 @@ lemma OpenCover.pullbackCoverAffineRefinementObjIso_inv_map (f : X ⟶ Y) (𝒰 PreZeroHypercover.pullback₁_f, pullbackSymmetry_inv_comp_fst, IsIso.inv_comp_eq, limit.lift_π_assoc, PullbackCone.mk_pt, cospan_left, PullbackCone.mk_π_app, pullbackSymmetry_hom_comp_fst] - convert pullbackSymmetry_inv_comp_snd_assoc - ((𝒰.X i.1).affineCover.f i.2) (pullback.fst _ _) _ using 2 + convert! + pullbackSymmetry_inv_comp_snd_assoc ((𝒰.X i.1).affineCover.f i.2) (pullback.fst _ _) _ using 2 exact pullbackRightPullbackFstIso_hom_snd _ _ _ set_option backward.isDefEq.respectTransparency false in @@ -194,7 +194,7 @@ lemma OpenCover.pullbackCoverAffineRefinementObjIso_inv_pullbackHom AffineOpenCover.openCover_f, pullbackCoverAffineRefinementObjIso, Iso.trans_inv, asIso_inv, Iso.symm_inv, Category.assoc, pullbackSymmetry_inv_comp_snd, IsIso.inv_comp_eq, limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app, Category.comp_id] - convert pullbackSymmetry_inv_comp_fst ((𝒰.X i.1).affineCover.f i.2) (pullback.fst _ _) + convert! pullbackSymmetry_inv_comp_fst ((𝒰.X i.1).affineCover.f i.2) (pullback.fst _ _) exact pullbackRightPullbackFstIso_hom_fst _ _ _ /-- A family of elements spanning the unit ideal of `R` gives an affine open cover of `Spec R`. -/ diff --git a/Mathlib/AlgebraicGeometry/Cover/QuasiCompact.lean b/Mathlib/AlgebraicGeometry/Cover/QuasiCompact.lean index fb4b3e4e81c93a..efc7522e29d69a 100644 --- a/Mathlib/AlgebraicGeometry/Cover/QuasiCompact.lean +++ b/Mathlib/AlgebraicGeometry/Cover/QuasiCompact.lean @@ -150,7 +150,7 @@ instance [IsAffine S] {P : MorphismProperty Scheme.{u}} (𝒰 : S.AffineCover P) instance [IsEmpty S] : QuasiCompactCover 𝒰 where isCompactOpenCovered_of_isAffineOpen {U} hU := by - convert IsCompactOpenCovered.empty + convert! IsCompactOpenCovered.empty simp [eq_bot_iff] variable {P : MorphismProperty Scheme.{u}} diff --git a/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Basic.lean b/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Basic.lean index c0973851c4a65a..f19ccad7c1d53a 100644 --- a/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Basic.lean +++ b/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Basic.lean @@ -306,7 +306,7 @@ lemma baseChange_polynomial : (W⁄B).polynomial = (W⁄A).polynomial.map (mapRi variable {W} in lemma Equation.baseChange {x y : A} (h : (W⁄A).Equation x y) : (W⁄B).Equation (f x) (f y) := by - convert Equation.map f.toRingHom h using 1 + convert! Equation.map f.toRingHom h using 1 rw [AlgHom.toRingHom_eq_coe, map_baseChange] variable {f} in diff --git a/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Formula.lean b/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Formula.lean index febcdf799a0bd0..e9ccf5e5ae66bc 100644 --- a/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Formula.lean +++ b/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Formula.lean @@ -272,7 +272,7 @@ lemma addPolynomial_slope {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁ rw [equation_iff] at h₁ h₂ rw [slope_of_Y_ne rfl hy] rw [negY, ← sub_ne_zero] at hy - replace hy : y₁ - (-y₁ - x₁ * W.a₁ - W.a₃) ≠ 0 := by convert hy using 1; ring + replace hy : y₁ - (-y₁ - x₁ * W.a₁ - W.a₃) ≠ 0 := by convert! hy using 1; ring ext · rfl · simp only [addX] diff --git a/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean b/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean index 7c3be2d89611b2..4c615b5efafb90 100644 --- a/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean +++ b/Mathlib/AlgebraicGeometry/EllipticCurve/Affine/Point.lean @@ -301,10 +301,10 @@ lemma XYIdeal_neg_mul {x y : F} (h : W.Nonsingular x y) : simp_rw [XYIdeal, XClass, YClass, span_pair_mul_span_pair, mul_comm, ← map_mul, AdjoinRoot.mk_eq_mk.mpr ⟨1, Y_rw⟩, map_mul, span_insert, ← span_singleton_mul_span_singleton, ← Ideal.mul_sup, ← span_insert] - convert mul_top (_ : Ideal W.CoordinateRing) using 2 + convert! mul_top (_ : Ideal W.CoordinateRing) using 2 on_goal 2 => infer_instance simp_rw [← Set.image_singleton (f := mk W), ← Set.image_insert_eq, ← map_span] - convert map_top (R := F[X][Y]) (mk W) using 1 + convert! map_top (R := F[X][Y]) (mk W) using 1 apply congr_arg simp_rw [eq_top_iff_one, mem_span_insert', mem_span_singleton'] rcases ((nonsingular_iff' ..).mp h).right with hx | hy @@ -341,7 +341,7 @@ lemma XYIdeal_mul_XYIdeal [DecidableEq F] {x₁ x₂ y₁ y₂ : F} ← sub_eq_add_neg, ← sub_mul, ← map_sub <| mk W, sub_sub_sub_cancel_right, span_insert, ← span_singleton_mul_span_singleton, ← sup_rw, ← Ideal.sup_mul, ← Ideal.sup_mul] apply congr_arg (_ ∘ _) - convert top_mul (_ : Ideal W.CoordinateRing) + convert! top_mul (_ : Ideal W.CoordinateRing) simp_rw [XClass, ← Set.image_singleton (f := mk W), ← map_span, ← Ideal.map_sup, eq_top_iff_one, mem_map_iff_of_surjective _ AdjoinRoot.mk_surjective, ← span_insert, mem_span_insert', mem_span_singleton'] @@ -432,14 +432,18 @@ lemma degree_norm_smul_basis [IsDomain R] (p q : R[X]) : · exact (hq hq').elim -- `hq'` should be `rfl` · rw [hq'] at hdpq hdq -- line should be redundant rcases le_or_gt dp (dq + 1) with hpq | hpq - · convert (degree_sub_eq_right_of_degree_lt <| (degree_sub_le _ _).trans_lt <| - max_lt_iff.mpr ⟨hdp.trans_lt _, hdpq.trans_lt _⟩).trans + · convert! + (degree_sub_eq_right_of_degree_lt <| + (degree_sub_le _ _).trans_lt <| + max_lt_iff.mpr ⟨hdp.trans_lt _, hdpq.trans_lt _⟩).trans (max_eq_right_of_lt _).symm <;> rw [hdq] <;> exact WithBot.coe_lt_coe.mpr <| by dsimp; linarith only [hpq] · rw [sub_sub] - convert (degree_sub_eq_left_of_degree_lt <| (degree_add_le _ _).trans_lt <| + convert! + (degree_sub_eq_left_of_degree_lt <| + (degree_add_le _ _).trans_lt <| max_lt_iff.mpr ⟨hdpq.trans_lt _, hdq.trans_lt _⟩).trans - (max_eq_left_of_lt _).symm <;> rw [hdp] <;> + (max_eq_left_of_lt _).symm <;> rw [hdp] <;> exact WithBot.coe_lt_coe.mpr <| by dsimp; linarith only [hpq] lemma degree_norm_ne_one [IsDomain R] (x : W'.CoordinateRing) : @@ -823,7 +827,7 @@ noncomputable abbrev baseChange [Algebra F K] [IsScalarTower R F K] : lemma map_baseChange [Algebra F K] [IsScalarTower R F K] [Algebra F L] [IsScalarTower R F L] (f : K →ₐ[F] L) (P : (W'⁄F).Point) : map f (baseChange F K P) = baseChange F L P := by have : Subsingleton (F →ₐ[F] L) := inferInstance - convert map_map (Algebra.ofId F K) f P + convert! map_map (Algebra.ofId F K) f P end Point diff --git a/Mathlib/AlgebraicGeometry/EllipticCurve/DivisionPolynomial/Degree.lean b/Mathlib/AlgebraicGeometry/EllipticCurve/DivisionPolynomial/Degree.lean index 6e6525ccbfe8cf..13c51f156243ec 100644 --- a/Mathlib/AlgebraicGeometry/EllipticCurve/DivisionPolynomial/Degree.lean +++ b/Mathlib/AlgebraicGeometry/EllipticCurve/DivisionPolynomial/Degree.lean @@ -236,7 +236,7 @@ lemma natDegree_preΨ'_le (n : ℕ) : (W.preΨ' n).natDegree ≤ (n ^ 2 - if Eve @[simp] lemma coeff_preΨ' (n : ℕ) : (W.preΨ' n).coeff ((n ^ 2 - if Even n then 4 else 1) / 2) = if Even n then n / 2 else n := by - convert (W.natDegree_coeff_preΨ' n).right using 1 + convert! (W.natDegree_coeff_preΨ' n).right using 1 rcases n.even_or_odd' with ⟨n, rfl | rfl⟩ <;> simp [expCoeff, n.not_even_two_mul_add_one] lemma coeff_preΨ'_ne_zero {n : ℕ} (h : (n : R) ≠ 0) : diff --git a/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Basic.lean b/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Basic.lean index 2ba34bec61ea71..3dbd6ab76983f1 100644 --- a/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Basic.lean +++ b/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Basic.lean @@ -273,7 +273,7 @@ lemma equation_smul (P : Fin 3 → R) {u : R} (hu : IsUnit u) : W'.Equation (u have hP (u : R) {P : Fin 3 → R} (hP : W'.Equation P) : W'.Equation <| u • P := by rw [equation_iff] at hP ⊢ linear_combination (norm := (simp only [smul_fin3_ext]; ring1)) u ^ 6 * hP - ⟨fun h => by convert hP ↑hu.unit⁻¹ h; rw [smul_smul, hu.val_inv_mul, one_smul], hP u⟩ + ⟨fun h => by convert! hP (↑hu.unit⁻¹) h; rw [smul_smul, hu.val_inv_mul, one_smul], hP u⟩ lemma equation_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.Equation P ↔ W'.Equation Q := by rcases h with ⟨u, rfl⟩ @@ -565,7 +565,7 @@ lemma baseChange_polynomial : (W'⁄B).polynomial = .map f (W'⁄A).polynomial : variable {W'} in lemma Equation.baseChange {P : Fin 3 → A} (h : (W'⁄A).Equation P) : (W'⁄B).Equation (f ∘ P) := by - convert Equation.map f.toRingHom h using 1 + convert! Equation.map f.toRingHom h using 1 rw [AlgHom.toRingHom_eq_coe, map_baseChange] variable {f} in diff --git a/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Point.lean b/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Point.lean index 03b6d1e22afe5e..982090c35d0dd6 100644 --- a/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Point.lean +++ b/Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Point.lean @@ -217,8 +217,8 @@ lemma add_smul_of_not_equiv {P Q : Fin 3 → R} (h : ¬P ≈ Q) {u v : R} (hu : lemma add_smul_equiv (P Q : Fin 3 → R) {u v : R} (hu : IsUnit u) (hv : IsUnit v) : W'.add (u • P) (v • Q) ≈ W'.add P Q := by by_cases h : P ≈ Q - · exact ⟨hu.unit ^ 4, by convert (add_smul_of_equiv h hu hv).symm⟩ - · exact ⟨(hu.unit * hv.unit) ^ 2, by convert (add_smul_of_not_equiv h hu hv).symm⟩ + · exact ⟨hu.unit ^ 4, by convert! (add_smul_of_equiv h hu hv).symm⟩ + · exact ⟨(hu.unit * hv.unit) ^ 2, by convert! (add_smul_of_not_equiv h hu hv).symm⟩ lemma add_equiv {P P' Q Q' : Fin 3 → R} (hP : P ≈ P') (hQ : Q ≈ Q') : W'.add P Q ≈ W'.add P' Q' := by diff --git a/Mathlib/AlgebraicGeometry/EllipticCurve/ModelsWithJ.lean b/Mathlib/AlgebraicGeometry/EllipticCurve/ModelsWithJ.lean index 7179657b09d9e6..2853054fa8f308 100644 --- a/Mathlib/AlgebraicGeometry/EllipticCurve/ModelsWithJ.lean +++ b/Mathlib/AlgebraicGeometry/EllipticCurve/ModelsWithJ.lean @@ -87,7 +87,7 @@ variable (R) [W.IsElliptic] It is of j-invariant 0 (see `WeierstrassCurve.ofJ0_j`). -/ instance [hu : Fact (IsUnit (3 : R))] : (ofJ0 R).IsElliptic := by rw [isElliptic_iff, ofJ0_Δ] - convert (hu.out.pow 3).neg + convert! (hu.out.pow 3).neg norm_num1 -- TODO: change to `[IsUnit ...]` once https://github.com/leanprover-community/mathlib4/issues/17458 is merged @@ -100,7 +100,7 @@ lemma ofJ0_j [Fact (IsUnit (3 : R))] : (ofJ0 R).j = 0 := by It is of j-invariant 1728 (see `WeierstrassCurve.ofJ1728_j`). -/ instance [hu : Fact (IsUnit (2 : R))] : (ofJ1728 R).IsElliptic := by rw [isElliptic_iff, ofJ1728_Δ] - convert (hu.out.pow 6).neg + convert! (hu.out.pow 6).neg norm_num1 -- TODO: change to `[IsUnit ...]` once https://github.com/leanprover-community/mathlib4/issues/17458 is merged diff --git a/Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Basic.lean b/Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Basic.lean index de570bf3c88465..4081c153035379 100644 --- a/Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Basic.lean +++ b/Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Basic.lean @@ -263,7 +263,7 @@ lemma equation_smul (P : Fin 3 → R) {u : R} (hu : IsUnit u) : W'.Equation (u have hP (u : R) {P : Fin 3 → R} (hP : W'.Equation P) : W'.Equation <| u • P := by rw [equation_iff] at hP ⊢ linear_combination (norm := (simp only [smul_fin3_ext]; ring1)) u ^ 3 * hP - ⟨fun h => by convert hP ↑hu.unit⁻¹ h; rw [smul_smul, hu.val_inv_mul, one_smul], hP u⟩ + ⟨fun h => by convert! hP (↑hu.unit⁻¹) h; rw [smul_smul, hu.val_inv_mul, one_smul], hP u⟩ lemma equation_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.Equation P ↔ W'.Equation Q := by rcases h with ⟨u, rfl⟩ @@ -540,7 +540,7 @@ lemma baseChange_polynomial : (W'⁄B).polynomial = .map f (W'⁄A).polynomial : variable {W'} in lemma Equation.baseChange {P : Fin 3 → A} (h : (W'⁄A).Equation P) : (W'⁄B).Equation (f ∘ P) := by - convert Equation.map f.toRingHom h using 1 + convert! Equation.map f.toRingHom h using 1 rw [AlgHom.toRingHom_eq_coe, map_baseChange] variable {f} in diff --git a/Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Point.lean b/Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Point.lean index b3cca1497603be..7ab6f1ad571321 100644 --- a/Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Point.lean +++ b/Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Point.lean @@ -205,8 +205,8 @@ lemma add_smul_of_not_equiv {P Q : Fin 3 → R} (h : ¬P ≈ Q) {u v : R} (hu : lemma add_smul_equiv (P Q : Fin 3 → R) {u v : R} (hu : IsUnit u) (hv : IsUnit v) : W'.add (u • P) (v • Q) ≈ W'.add P Q := by by_cases h : P ≈ Q - · exact ⟨hu.unit ^ 4, by convert (add_smul_of_equiv h hu hv).symm⟩ - · exact ⟨(hu.unit * hv.unit) ^ 2, by convert (add_smul_of_not_equiv h hu hv).symm⟩ + · exact ⟨hu.unit ^ 4, by convert! (add_smul_of_equiv h hu hv).symm⟩ + · exact ⟨(hu.unit * hv.unit) ^ 2, by convert! (add_smul_of_not_equiv h hu hv).symm⟩ lemma add_equiv {P P' Q Q' : Fin 3 → R} (hP : P ≈ P') (hQ : Q ≈ Q') : W'.add P Q ≈ W'.add P' Q' := by diff --git a/Mathlib/AlgebraicGeometry/FunctionField.lean b/Mathlib/AlgebraicGeometry/FunctionField.lean index 52ee1d92e86f0b..04b8ec01e7439f 100644 --- a/Mathlib/AlgebraicGeometry/FunctionField.lean +++ b/Mathlib/AlgebraicGeometry/FunctionField.lean @@ -70,10 +70,10 @@ theorem genericPoint_eq_of_isOpenImmersion {X Y : Scheme} (f : X ⟶ Y) [IsOpenI [hX : IrreducibleSpace X] [IrreducibleSpace Y] : f (genericPoint X) = genericPoint Y := by apply ((genericPoint_spec Y).eq _).symm - convert (genericPoint_spec X).image f.continuous + convert! (genericPoint_spec X).image f.continuous symm rw [← Set.univ_subset_iff] - convert subset_closure_inter_of_isPreirreducible_of_isOpen _ f.isOpenEmbedding.isOpen_range _ + convert! subset_closure_inter_of_isPreirreducible_of_isOpen _ f.isOpenEmbedding.isOpen_range _ · rw [Set.univ_inter, Set.image_univ] · apply PreirreducibleSpace.isPreirreducible_univ (X := Y) · exact ⟨_, trivial, Set.mem_range_self hX.2.some⟩ @@ -108,7 +108,7 @@ theorem genericPoint_eq_bot_of_affine (R : CommRingCat) [IsDomain R] : instance functionField_isFractionRing_of_affine (R : CommRingCat.{u}) [IsDomain R] : IsFractionRing R (Spec R).functionField := by - convert StructureSheaf.IsLocalization.to_stalk R (genericPoint (Spec R)) + convert! StructureSheaf.IsLocalization.to_stalk R (genericPoint (Spec R)) delta IsFractionRing IsLocalization.AtPrime -- Porting note: `congr` does not work for `Iff` apply Eq.to_iff @@ -129,9 +129,11 @@ theorem IsAffineOpen.primeIdealOf_genericPoint {X : Scheme} [IsIntegral X] {U : ((genericPoint_spec X).mem_open_set_iff U.isOpen).mpr (by simpa using h)⟩ = genericPoint (Spec Γ(X, U)) := by delta IsAffineOpen.primeIdealOf - convert + convert! genericPoint_eq_of_isOpenImmersion (U.toScheme.isoSpec.hom ≫ Spec.map (X.presheaf.map (eqToHom U.isOpenEmbedding_obj_top).op)) + -- Porting note: this was `ext1` + -- Porting note: this was `ext1` apply Subtype.ext exact (genericPoint_eq_of_isOpenImmersion U.ι).symm @@ -140,8 +142,11 @@ theorem functionField_isFractionRing_of_isAffineOpen [IsIntegral X] (U : X.Opens (hU : IsAffineOpen U) [Nonempty U] : IsFractionRing Γ(X, U) X.functionField := by delta IsFractionRing Scheme.functionField - convert hU.isLocalization_stalk ⟨genericPoint X, - (((genericPoint_spec X).mem_open_set_iff U.isOpen).mpr (by simpa using ‹Nonempty U›))⟩ using 1 + convert! + hU.isLocalization_stalk + ⟨genericPoint X, + (((genericPoint_spec X).mem_open_set_iff U.isOpen).mpr (by simpa using ‹Nonempty U›))⟩ + using 1 rw [hU.primeIdealOf_genericPoint, genericPoint_eq_bot_of_affine] ext; exact mem_nonZeroDivisors_iff_ne_zero diff --git a/Mathlib/AlgebraicGeometry/GammaSpecAdjunction.lean b/Mathlib/AlgebraicGeometry/GammaSpecAdjunction.lean index 72f057cee51587..6eba84730ee53b 100644 --- a/Mathlib/AlgebraicGeometry/GammaSpecAdjunction.lean +++ b/Mathlib/AlgebraicGeometry/GammaSpecAdjunction.lean @@ -119,7 +119,7 @@ abbrev toToΓSpecMapBasicOpen : set_option backward.isDefEq.respectTransparency false in /-- `r` is a unit as a section on the basic open defined by `r`. -/ theorem isUnit_res_toΓSpecMapBasicOpen : IsUnit (X.toToΓSpecMapBasicOpen r r) := by - convert + convert! (X.presheaf.map <| (eqToHom <| X.toΓSpecMapBasicOpen_eq r).op).hom.isUnit_map (X.toRingedSpace.isUnit_res_basicOpen r) rw [← CommRingCat.comp_apply, ← Functor.map_comp] @@ -174,7 +174,7 @@ def toΓSpecCBasicOpens : rw [show algebraMap (Γ.obj (op X)) ((structureSheaf (Γ.obj (op X))).obj.obj _) = algebraMap _ ((structureSheafInType (Γ.obj (op X)) (Γ.obj (op X))).obj.obj _) from rfl, X.toΓSpecCApp_spec r.unop] - convert X.toΓSpecCApp_spec s.unop + convert! X.toΓSpecCApp_spec s.unop symm apply X.presheaf.map_comp @@ -275,7 +275,7 @@ theorem Γ_Spec_left_triangle : toSpecΓ (Γ.obj (op X)) ≫ X.toΓSpec.c.app (o have := X.toΓSpecSheafedSpace_app_spec 1 unfold toToΓSpecMapBasicOpen toΓSpecMapBasicOpen at this rw! [basicOpen_one] at this - convert this + convert! this exact (X.presheaf.map_id ..).symm end LocallyRingedSpace diff --git a/Mathlib/AlgebraicGeometry/Geometrically/Basic.lean b/Mathlib/AlgebraicGeometry/Geometrically/Basic.lean index d3eb8af73b44f4..b6c245a2f37e03 100644 --- a/Mathlib/AlgebraicGeometry/Geometrically/Basic.lean +++ b/Mathlib/AlgebraicGeometry/Geometrically/Basic.lean @@ -112,7 +112,7 @@ lemma geometrically_iff_forall_fiberToSpecResidueField : apply H y (Spec.map φ) p snd simp only [Scheme.SpecToEquivOfField, Equiv.coe_fn_symm_mk] at h refine .flip (.of_bot (.flip ?_) ?_ (IsPullback.of_hasPullback f (Y.fromSpecResidueField y)).flip) - · convert h + · convert! h simp [p] · simp [p, Scheme.Hom.fiberToSpecResidueField] diff --git a/Mathlib/AlgebraicGeometry/Gluing.lean b/Mathlib/AlgebraicGeometry/Gluing.lean index f489cb2080de5b..83735f1e939ffd 100644 --- a/Mathlib/AlgebraicGeometry/Gluing.lean +++ b/Mathlib/AlgebraicGeometry/Gluing.lean @@ -397,7 +397,7 @@ theorem isOpenMap_fromGlued : IsOpenMap 𝒰.fromGlued := by constructor · rw [← Set.image_preimage_eq_inter_range] apply (𝒰.f (𝒰.idx x)).isOpenEmbedding.isOpenMap - convert hU (𝒰.idx x) using 1 + convert! hU (𝒰.idx x) using 1 simp only [← ι_fromGlued, gluedCover_U, Hom.comp_base, TopCat.hom_comp, ContinuousMap.coe_comp, Set.preimage_comp] congr! 1 @@ -706,7 +706,7 @@ lemma glueDataι_naturality {i j : Shrink.{u} J} (f : ↓i ⟶ ↓j) : rw [← cancel_epi (V F ↓i ↓j).ι, ← this, ← Category.assoc, ← (Iso.eq_inv_comp _).mp (homOfLE_tAux F ↓i ↓j (𝟙 _) f), ← Category.assoc, ← Category.assoc, Category.assoc] - convert Category.id_comp _ + convert! Category.id_comp _ simp [← cancel_mono (Opens.ι _), V] /-- (Implementation detail) diff --git a/Mathlib/AlgebraicGeometry/Group/Abelian.lean b/Mathlib/AlgebraicGeometry/Group/Abelian.lean index da915447a92aa0..fbe78d4ba2d6ff 100644 --- a/Mathlib/AlgebraicGeometry/Group/Abelian.lean +++ b/Mathlib/AlgebraicGeometry/Group/Abelian.lean @@ -111,8 +111,9 @@ theorem isCommMonObj_of_isProper_of_isIntegral_tensorObj_of_isAlgClosed [IsAlgCl γ.left.isClosedMap ((H ⟨_, hyU⟩).subset (Set.image_subset_iff.mpr fun _ ↦ by simp [← Scheme.Hom.comp_apply, -Scheme.Hom.comp_base, γ])) ?_ ?_ · let α : G ⊗ G ⟶ G ⊗ G := toUnit _ ≫ x ⊗ₘ 𝟙 _ - convert ((IrreducibleSpace.isIrreducible_univ _).image α.left - α.left.continuous.continuousOn).isPreirreducible + convert! + ((IrreducibleSpace.isIrreducible_univ _).image α.left + α.left.continuous.continuousOn).isPreirreducible rw [Over.tensorHom_left] simp [Set.range_comp, Scheme.Pullback.range_map, x] · exact ⟨y, subset_closure (by simp), rfl⟩ @@ -120,7 +121,7 @@ theorem isCommMonObj_of_isProper_of_isIntegral_tensorObj_of_isAlgClosed [IsAlgCl · simp [xe, ← Scheme.Hom.comp_apply, -Scheme.Hom.comp_base] · simp only [xe, γ, ← Scheme.Hom.comp_apply, ← Over.comp_left] congr 6; ext <;> simp - convert congr((snd G G).left $this) using 1 + convert! congr((snd G G).left $this) using 1 · simp [γ, ← Scheme.Hom.comp_apply] · simp [xe, ← Scheme.Hom.comp_apply, -Scheme.Hom.comp_base] · simp diff --git a/Mathlib/AlgebraicGeometry/IdealSheaf/Subscheme.lean b/Mathlib/AlgebraicGeometry/IdealSheaf/Subscheme.lean index 339afd4cfd4147..5a1987b459cd30 100644 --- a/Mathlib/AlgebraicGeometry/IdealSheaf/Subscheme.lean +++ b/Mathlib/AlgebraicGeometry/IdealSheaf/Subscheme.lean @@ -174,7 +174,7 @@ lemma ideal_le_ker_glueDataObjι (U V : X.affineOpens) : simp only [Scheme.Hom.comp_app, Scheme.Opens.ι_app, Scheme.homOfLE_app, ← Functor.map_comp_assoc, Scheme.Hom.app_eq _ H, Scheme.Opens.toScheme_presheaf_map, ← Functor.map_comp, Category.assoc] simp only [CommRingCat.hom_comp, RingHom.comp_apply] - convert RingHom.map_zero _ using 2 + convert! RingHom.map_zero _ using 2 rw [← RingHom.mem_ker, ker_glueDataObjι_appTop, ← Ideal.mem_comap, Ideal.comap_comap, ← CommRingCat.hom_comp] simp only [Scheme.affineBasicOpen_coe, homOfLE_leOfHom, Scheme.Hom.comp_base, @@ -538,7 +538,7 @@ lemma subschemeι_app (U : X.affineOpens) : I.subschemeι.app U = Functor.op_obj, Functor.op_map, unop_comp, unop_inv, Quiver.Hom.unop_op, Hom.app_appIso_inv_assoc, TopologicalSpace.Opens.carrier_eq_coe, TopologicalSpace.Opens.map_coe, homOfLE_leOfHom] - convert (Category.comp_id _).symm + convert! (Category.comp_id _).symm exact CategoryTheory.Functor.map_id _ _ lemma subschemeι_app_surjective (U : X.affineOpens) : @@ -693,7 +693,7 @@ def Hom.toImage : X ⟶ f.image := @[reassoc (attr := simp)] lemma Hom.toImage_imageι : f.toImage ≫ f.imageι = f := by - convert f.toImageAux_spec using 2 + convert! f.toImageAux_spec using 2 exact Scheme.Hom.copyBase_eq _ _ _ instance [QuasiCompact f] : IsDominant f.toImage where diff --git a/Mathlib/AlgebraicGeometry/Limits.lean b/Mathlib/AlgebraicGeometry/Limits.lean index 2a63763f30703c..3425814d02ad2f 100644 --- a/Mathlib/AlgebraicGeometry/Limits.lean +++ b/Mathlib/AlgebraicGeometry/Limits.lean @@ -266,7 +266,7 @@ private lemma isOpenImmersion_sigmaDesc_aux rw [IsOpenImmersion.iff_isIso_stalkMap] constructor · suffices Topology.IsOpenEmbedding (Sigma.desc α ∘ sigmaMk f) by - convert this.comp (sigmaMk f).symm.isOpenEmbedding; ext; simp + convert! this.comp (sigmaMk f).symm.isOpenEmbedding; ext; simp refine .of_continuous_injective_isOpenMap ?_ ?_ ?_ · fun_prop · rintro ⟨ix, x⟩ ⟨iy, y⟩ e @@ -295,7 +295,7 @@ lemma isOpenImmersion_sigmaDesc [Small.{u} σ] (hα : Pairwise (Disjoint on (Set.range <| α ·))) : IsOpenImmersion (Sigma.desc α) := by obtain ⟨ι, ⟨e⟩⟩ := Small.equiv_small (α := σ) - convert IsOpenImmersion.comp ((Sigma.reindex e.symm g).inv) (Sigma.desc fun i ↦ α _) + convert! IsOpenImmersion.comp ((Sigma.reindex e.symm g).inv) (Sigma.desc fun i ↦ α _) · refine Sigma.hom_ext _ _ fun i ↦ ?_ obtain ⟨i, rfl⟩ := e.symm.surjective i simp @@ -352,7 +352,7 @@ lemma isCompl_range_inl_inr : lemma isCompl_opensRange_inl_inr : IsCompl (coprod.inl : X ⟶ X ⨿ Y).opensRange (coprod.inr : Y ⟶ X ⨿ Y).opensRange := by - convert isCompl_range_inl_inr X Y + convert! isCompl_range_inl_inr X Y simp only [isCompl_iff, disjoint_iff, codisjoint_iff, ← TopologicalSpace.Opens.coe_inj] rfl @@ -421,7 +421,7 @@ lemma nonempty_isColimit_binaryCofanMk_of_isCompl {X Y S : Scheme.{u}} let i : BinaryCofan.mk f g ≅ c' := Cofan.ext (Iso.refl _) (by rintro (b | b) <;> rfl) refine ⟨IsColimit.ofIsoColimit (Nonempty.some ?_) i.symm⟩ let fi (j : WalkingPair) : WalkingPair.casesOn j X Y ⟶ S := WalkingPair.casesOn j f g - convert nonempty_isColimit_cofanMk_of fi _ _ + convert! nonempty_isColimit_cofanMk_of fi _ _ · intro i cases i <;> (simp [fi]; infer_instance) · simpa [← WalkingPair.equivBool.symm.iSup_comp, iSup_bool_eq, ← codisjoint_iff] using hf.2 @@ -466,7 +466,7 @@ instance : FinitaryExtensive Scheme where · dsimp refine fun {Z} f ↦ (nonempty_isColimit_binaryCofanMk_of_isCompl _ _ ?_).some rw [Scheme.Hom.opensRange_pullbackFst, Scheme.Hom.opensRange_pullbackFst] - convert (isCompl_range_inl_inr X Y).map (CompleteLatticeHom.setPreimage f) + convert! (isCompl_range_inl_inr X Y).map (CompleteLatticeHom.setPreimage f) simp [isCompl_iff, disjoint_iff, codisjoint_iff, ← TopologicalSpace.Opens.coe_inj] variable {X Y} @@ -659,8 +659,8 @@ private lemma IsAffineOpen.iSup_of_disjoint_aux [Finite ι] {U : ι → X.Opens} (hU : ∀ i, IsAffineOpen (U i)) (hU' : Pairwise (Disjoint on U)) : IsAffineOpen (iSup U) := by have := isOpenImmersion_sigmaDesc _ (fun i ↦ (U i).ι) - (fun i j e ↦ by convert hU' e using 0; simp [← Opens.coe_disjoint]) - convert isAffineOpen_opensRange (Sigma.desc fun i ↦ (U i).ι) + (fun i j e ↦ by convert! hU' e using 0; simp [← Opens.coe_disjoint]) + convert! isAffineOpen_opensRange (Sigma.desc fun i ↦ (U i).ι) · ext simp [(sigmaMk _).symm.exists_congr_left, ← Scheme.Hom.comp_apply, Scheme.Opens.exists_toScheme] · have (i : _) : IsAffine _ := hU i @@ -686,15 +686,16 @@ lemma IsAffineOpen.biSup_of_disjoint {s : Set σ} (hs : s.Finite) lemma IsAffineOpen.sup_of_disjoint {U V : X.Opens} (hU : IsAffineOpen U) (hV : IsAffineOpen V) (H : Disjoint U V) : IsAffineOpen (U ⊔ V) := by - convert iSup_of_disjoint (U := fun i : Unit ⊕ Unit ↦ i.elim (fun _ ↦ U) (fun _ ↦ V)) (by simp_all) - (by simp_all [_root_.Pairwise, Unique.forall_iff, ← Opens.coe_disjoint, disjoint_comm]) + convert! + iSup_of_disjoint (U := fun i : Unit ⊕ Unit ↦ i.elim (fun _ ↦ U) (fun _ ↦ V)) (by simp_all) + (by simp_all [_root_.Pairwise, Unique.forall_iff, ← Opens.coe_disjoint, disjoint_comm]) aesop instance (priority := low) [Finite X] [DiscreteTopology X] : IsAffine X := have : IsAffineOpen (⨆ (x : X), (⟨{x}, isOpen_discrete _⟩ : X.Opens)) := .iSup_of_disjoint (fun i ↦ .of_subsingleton Set.subsingleton_singleton) fun i j e ↦ by simpa [← TopologicalSpace.Opens.coe_disjoint] - have : IsAffine (⊤ : X.Opens).toScheme := show IsAffineOpen _ by convert this; ext; simp + have : IsAffine (⊤ : X.Opens).toScheme := show IsAffineOpen _ by convert! this; ext; simp .of_isIso X.topIso.inv end Coproduct diff --git a/Mathlib/AlgebraicGeometry/Modules/Tilde.lean b/Mathlib/AlgebraicGeometry/Modules/Tilde.lean index b5d687ac24567b..d968c7b6dc9a2b 100644 --- a/Mathlib/AlgebraicGeometry/Modules/Tilde.lean +++ b/Mathlib/AlgebraicGeometry/Modules/Tilde.lean @@ -384,7 +384,7 @@ def presentationTilde (s : Set M) (hs : Submodule.span R s = ⊤) tilde.map (ModuleCat.ofHom (Finsupp.linearCombination R (↑)))) (by simp only [Category.assoc, Iso.hom_inv_id_assoc, Preadditive.IsIso.comp_left_eq_zero] rw [← tilde.map_comp, ← ModuleCat.ofHom_comp] - convert tilde.map_zero + convert! tilde.map_zero exact congr(ModuleCat.ofHom $(H₁.linearMap_comp_eq_zero))) ?_ letI h₁ := ModuleCat.isColimitCokernelCofork _ _ H₁ (by simp [← LinearMap.range_eq_top, Finsupp.range_linearCombination, hs]) diff --git a/Mathlib/AlgebraicGeometry/Morphisms/Affine.lean b/Mathlib/AlgebraicGeometry/Morphisms/Affine.lean index 648670f27fc4a1..9d36185a73b8d5 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/Affine.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/Affine.lean @@ -75,7 +75,7 @@ instance {X : Scheme} (r : Γ(X, ⊤)) : constructor intro U hU fapply (Scheme.Hom.isAffineOpen_iff_of_isOpenImmersion (X.basicOpen r).ι).mp - convert hU.basicOpen (X.presheaf.map (homOfLE le_top).op r) + convert! hU.basicOpen (X.presheaf.map (homOfLE le_top).op r) rw [X.basicOpen_res] ext1 refine Set.image_preimage_eq_inter_range.trans ?_ @@ -126,7 +126,7 @@ lemma isAffine_of_isAffineOpen_basicOpen (s : Set Γ(X, ⊤)) exact hs₂ _ i.2 · simp only [Opens.map_top, morphismRestrict_app] refine IsIso.comp_isIso' ?_ inferInstance - convert isIso_ΓSpec_adjunction_unit_app_basicOpen i.1 using 0 + convert! isIso_ΓSpec_adjunction_unit_app_basicOpen i.1 using 0 exact congr(IsIso ((ΓSpec.adjunction.unit.app X).app $(by simp))) set_option backward.isDefEq.respectTransparency false in @@ -221,7 +221,7 @@ instance {U V X : Scheme.{u}} (f : U ⟶ X) (g : V ⟶ X) [IsAffineHom f] [IsAff have : IsAffine (f ⁻¹ᵁ W).toScheme := hW.preimage f have : IsAffine (g ⁻¹ᵁ W).toScheme := hW.preimage g let i : (f ⁻¹ᵁ W).toScheme ⨿ (g ⁻¹ᵁ W).toScheme ⟶ U ⨿ V := coprod.map (f ⁻¹ᵁ W).ι (g ⁻¹ᵁ W).ι - convert isAffineOpen_opensRange i + convert! isAffineOpen_opensRange i apply le_antisymm · intro x hx obtain ⟨(x | x), rfl⟩ := (coprodMk U V).surjective x @@ -253,14 +253,14 @@ lemma isAffineHom_of_isInducing exact ⟨⟨U', hU'⟩ ⊓ U, inf_le_right, Opens.ext (by simpa [e] using hVU)⟩ obtain ⟨r, hrU', hxr⟩ := hU.exists_basicOpen_le ⟨f x, hxV⟩ hxU refine ⟨_, hxr, hU.basicOpen r, ?_⟩ - convert hV.basicOpen (f.app _ (Y.presheaf.map (homOfLE hU'U).op r)) using 1 + convert! hV.basicOpen (f.app _ (Y.presheaf.map (homOfLE hU'U).op r)) using 1 simp only [Scheme.preimage_basicOpen, ← CommRingCat.comp_apply, f.naturality] simpa using ((Opens.map f.base).map (homOfLE hrU')).le · obtain ⟨_, ⟨U, hU, rfl⟩, hyU, hU'⟩ := Y.isBasis_affineOpens.exists_subset_of_mem_open hy hf₂.isOpen_compl rw [Set.subset_compl_iff_disjoint_right, ← Set.preimage_eq_empty_iff] at hU' refine ⟨U, hyU, hU, ?_⟩ - convert isAffineOpen_bot _ + convert! isAffineOpen_bot _ exact Opens.ext hU' lemma IsAffineOpen.isCompact_pullback_inf {X Y Z : Scheme.{u}} {f : X ⟶ Z} {g : Y ⟶ Z} @@ -275,7 +275,7 @@ lemma IsAffineOpen.isCompact_pullback_inf {X Y Z : Scheme.{u}} {f : X ⟶ Z} {g IsOpenImmersion.lift W.ι (Scheme.Opens.ι _ ≫ g) <| by simpa [Set.range_comp] let p : pullback f' q ⟶ pullback f g := pullback.map _ _ _ _ U.ι (Scheme.Opens.ι _) W.ι (by simp [f']) (by simp [q]) - convert isCompact_range p.continuous + convert! isCompact_range p.continuous simp [p, Scheme.Pullback.range_map] set_option backward.isDefEq.respectTransparency false in @@ -303,7 +303,7 @@ theorem diagonal_isAffine_iff_forall_isAffineOpen_inf [IsAffine Y] (f : X ⟶ Y) exact .of_isIso this.isoPullback.hom · introv H h₁ h₂ have : IsAffineOpen (pullback.fst f₁ f₂ ≫ f₁).opensRange := by - convert H _ _ (isAffineOpen_opensRange f₁) (isAffineOpen_opensRange f₂) using 1 + convert! H _ _ (isAffineOpen_opensRange f₁) (isAffineOpen_opensRange f₂) using 1 exact Opens.ext (IsOpenImmersion.range_pullback_to_base_of_left _ _) change IsAffine _ at this exact .of_isIso (pullback.fst f₁ f₂ ≫ f₁).isoOpensRange.hom diff --git a/Mathlib/AlgebraicGeometry/Morphisms/AffineAnd.lean b/Mathlib/AlgebraicGeometry/Morphisms/AffineAnd.lean index 06424f0fb4b481..795563aef108b4 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/AffineAnd.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/AffineAnd.lean @@ -304,11 +304,11 @@ lemma HasAffineProperty.coprodDesc_affineAnd {P : MorphismProperty Scheme.{u}} refine this _ ?_ ?_ · have : (Limits.coprod.desc f g).app W ≫ e.hom ≫ Limits.prod.fst = f.app W := by simp [e, Scheme.Hom.app_eq_appLE, Scheme.Hom.appLE_comp_appLE] - convert (hf W hW).2 + convert! (hf W hW).2 exact congr(($this).1) · have : (Limits.coprod.desc f g).app W ≫ e.hom ≫ Limits.prod.snd = g.app W := by simp [e, Scheme.Hom.app_eq_appLE, Scheme.Hom.appLE_comp_appLE] - convert (hg W hW).2 + convert! (hg W hW).2 exact congr(($this).1) end diff --git a/Mathlib/AlgebraicGeometry/Morphisms/Basic.lean b/Mathlib/AlgebraicGeometry/Morphisms/Basic.lean index f0dde4f5e73528..b81c411ae442f6 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/Basic.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/Basic.lean @@ -207,11 +207,11 @@ lemma coprodMap {X Y X' Y' : Scheme.{u}} (f : X ⟶ X') (g : Y ⟶ Y') (hf : P f rintro (⟨⟨⟩⟩ | ⟨⟨⟩⟩) · rw [← MorphismProperty.cancel_left_of_respectsIso P (isPullback_inl_inl_coprodMap f g).flip.isoPullback.hom] - convert hf + convert! hf simp [Scheme.Cover.pullbackHom, coprodOpenCover] · rw [← MorphismProperty.cancel_left_of_respectsIso P (isPullback_inr_inr_coprodMap f g).flip.isoPullback.hom] - convert hg + convert! hg simp [Scheme.Cover.pullbackHom, coprodOpenCover] end IsZariskiLocalAtTarget diff --git a/Mathlib/AlgebraicGeometry/Morphisms/ClosedImmersion.lean b/Mathlib/AlgebraicGeometry/Morphisms/ClosedImmersion.lean index 11b2dd219c4a67..103ec5cd8db757 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/ClosedImmersion.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/ClosedImmersion.lean @@ -351,7 +351,7 @@ instance IsClosedImmersion.isZariskiLocalAtTarget : IsZariskiLocalAtTarget @IsCl and being surjective on global sections. -/ instance IsClosedImmersion.hasAffineProperty : HasAffineProperty @IsClosedImmersion (fun X _ f ↦ IsAffine X ∧ Function.Surjective (f.appTop)) := by - convert HasAffineProperty.of_isZariskiLocalAtTarget @IsClosedImmersion + convert! HasAffineProperty.of_isZariskiLocalAtTarget @IsClosedImmersion refine ⟨fun ⟨h₁, h₂⟩ ↦ of_surjective_of_isAffine _ h₂, by apply isAffine_surjective_of_isAffine⟩ lemma isClosedImmersion_iff_isAffineHom {f : X ⟶ Y} : diff --git a/Mathlib/AlgebraicGeometry/Morphisms/Constructors.lean b/Mathlib/AlgebraicGeometry/Morphisms/Constructors.lean index 174ce320905f19..5d6f69b2002583 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/Constructors.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/Constructors.lean @@ -78,14 +78,18 @@ theorem HasAffineProperty.diagonal_of_openCover (P) {Q} [HasAffineProperty P Q] apply of_openCover 𝒱 rintro ⟨i, j, k⟩ dsimp [𝒱] - convert (Q.cancel_left_of_respectsIso - ((pullbackDiagonalMapIso _ _ ((𝒰' i).f j) ((𝒰' i).f k)).inv ≫ - pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) _ _) (pullback.snd _ _)).mp _ using 1 + convert! + (Q.cancel_left_of_respectsIso + ((pullbackDiagonalMapIso _ _ ((𝒰' i).f j) ((𝒰' i).f k)).inv ≫ + pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) _ _) + (pullback.snd _ _)).mp + _ + using 1 · simp · ext1 <;> simp · simp only [Category.assoc, limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app, Category.comp_id] - convert h𝒰' i j k + convert! h𝒰' i j k ext1 <;> simp [Scheme.Cover.pullbackHom] theorem HasAffineProperty.diagonal_of_openCover_diagonal @@ -108,7 +112,7 @@ theorem HasAffineProperty.diagonal_of_diagonal_of_isPullback h.isoPullback_inv_snd] rintro U V f₁ f₂ hU hV hf₁ hf₂ rw [← Q.cancel_left_of_respectsIso (pullbackDiagonalMapIso f _ f₁ f₂).hom] - convert HasAffineProperty.of_isPullback (P := P) (.of_hasPullback _ _) H + convert! HasAffineProperty.of_isPullback (P := P) (.of_hasPullback _ _) H · apply pullback.hom_ext <;> simp · infer_instance · infer_instance diff --git a/Mathlib/AlgebraicGeometry/Morphisms/Descent.lean b/Mathlib/AlgebraicGeometry/Morphisms/Descent.lean index 8784a110c853ba..e66b740b2661f0 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/Descent.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/Descent.lean @@ -196,7 +196,7 @@ nonrec lemma HasAffineProperty.descendsAlong_of_affineAnd apply IsZariskiLocalAtTarget.descendsAlong_inf_quasiCompact _ _ H₁ introv h hf have : IsAffine Y := by - convert isAffine_of_isAffineHom g + convert! isAffine_of_isAffineHom g exact MorphismProperty.of_pullback_fst_of_descendsAlong h <| AlgebraicGeometry.HasAffineProperty.affineAnd_le_isAffineHom P inferInstance _ hf wlog hY : ∃ S, Y = Spec S generalizing Y diff --git a/Mathlib/AlgebraicGeometry/Morphisms/FinitePresentation.lean b/Mathlib/AlgebraicGeometry/Morphisms/FinitePresentation.lean index 20b222fa620488..1a1a4b0ca4664e 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/FinitePresentation.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/FinitePresentation.lean @@ -124,9 +124,11 @@ nonrec lemma Scheme.Hom.isLocallyConstructible_image (f : X ⟶ Y) MorphismProperty.pullback_snd _ _ inferInstance have inst : QuasiCompact (Y.affineCover.pullbackHom f i) := MorphismProperty.pullback_snd _ _ inferInstance - convert (this (Y.affineCover.pullbackHom f i) (hs.preimage_of_isOpenEmbedding - ((Y.affineCover.pullback₁ f).f i).isOpenEmbedding) - ⟨_, rfl⟩).preimage_of_isOpenEmbedding (Y.affineCover.f i).isoOpensRange.inv.isOpenEmbedding + convert! + (this (Y.affineCover.pullbackHom f i) + (hs.preimage_of_isOpenEmbedding ((Y.affineCover.pullback₁ f).f i).isOpenEmbedding) + ⟨_, rfl⟩).preimage_of_isOpenEmbedding + (Y.affineCover.f i).isoOpensRange.inv.isOpenEmbedding refine .trans ?_ ((Scheme.homeoOfIso (Y.affineCover.f i).isoOpensRange).image_eq_preimage_symm _) apply Set.image_injective.mpr Subtype.val_injective @@ -145,8 +147,7 @@ nonrec lemma Scheme.Hom.isLocallyConstructible_image (f : X ⟶ Y) refine .iUnion fun i ↦ ?_ have inst : QuasiCompact (𝒰.f i ≫ f) := HasAffineProperty.iff_of_isAffine.mpr (inferInstanceAs (CompactSpace (Spec _))) - convert this (hs.preimage_of_isOpenEmbedding (𝒰.f i).isOpenEmbedding) _ - (𝒰.f i ≫ f) ⟨_, rfl⟩ + convert! this (hs.preimage_of_isOpenEmbedding (𝒰.f i).isOpenEmbedding) _ (𝒰.f i ≫ f) ⟨_, rfl⟩ rw [Scheme.Hom.comp_base, ← TopCat.Hom.hom, ← TopCat.Hom.hom, TopCat.hom_comp, ContinuousMap.coe_comp, Set.image_comp, Set.image_preimage_eq_inter_range, coe_opensRange] obtain ⟨S, rfl⟩ := hX diff --git a/Mathlib/AlgebraicGeometry/Morphisms/Flat.lean b/Mathlib/AlgebraicGeometry/Morphisms/Flat.lean index ea2689ea7b4b83..8aaf2ed315f40a 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/Flat.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/Flat.lean @@ -304,7 +304,7 @@ lemma mono_pushoutSection_of_iSup_eq {ι : Type*} [Finite ι] (VX : ι → X.Ope suffices (ψY.comp (pushoutSection H hUST hUSX hUY).hom).comp e.inv.hom = φ.comp (Algebra.TensorProduct.map (AlgHom.id Γ(T, UT) Γ(T, UT)) ψ).toRingHom by refine .of_comp (f := ψY) ?_ - convert (hφ.comp hψ').comp e.commRingCatIsoToRingEquiv.injective + convert! (hφ.comp hψ').comp e.commRingCatIsoToRingEquiv.injective ext1 x; simpa using congr($this (e.hom x)) ext1 · have H₁ : e.inv.hom.comp Algebra.TensorProduct.includeLeftRingHom = @@ -421,7 +421,7 @@ lemma isIso_pushoutSection_of_iSup_eq · rintro ⟨i | ⟨i, j⟩⟩ · simp [f₁, f₂] · simpa [f₁, f₂] using c'.w (Quiver.Hom.op <| Pairwise.Hom.left i j) - convert e.isIso_hom using 1 + convert! e.isIso_hom using 1 · refine hc'.hom_ext fun i ↦ ?_ rw [hc'.fac] ext1 @@ -443,7 +443,7 @@ lemma mono_pushoutSection_of_isCompact_of_flat_left [Flat iX] (hUS : IsAffineOpen US) (hUX : IsAffineOpen UX) (hUT : IsCompact (X := T) UT) : Mono (pushoutSection H hUST hUSX hUY) := by suffices Mono (pushoutSection H.flip hUSX hUST (hUY.trans (inf_comm _ _))) by - rw [← mono_comp_iff_of_isIso (pushoutSymmetry _ _).hom]; convert this; cat_disch + rw [← mono_comp_iff_of_isIso (pushoutSymmetry _ _).hom]; convert! this; cat_disch exact mono_pushoutSection_of_isCompact_of_flat_right _ _ _ _ hUS hUX hUT lemma isIso_pushoutSection_of_isQuasiSeparated_of_flat_right [Flat f] @@ -466,7 +466,7 @@ lemma isIso_pushoutSection_of_isQuasiSeparated_of_flat_left [Flat iX] (hUT : IsCompact (X := T) UT) (hUT' : IsQuasiSeparated (α := T) UT) : IsIso (pushoutSection H hUST hUSX hUY) := by suffices IsIso (pushoutSection H.flip hUSX hUST (hUY.trans (inf_comm _ _))) by - rw [← isIso_comp_left_iff (pushoutSymmetry _ _).hom]; convert this; cat_disch + rw [← isIso_comp_left_iff (pushoutSymmetry _ _).hom]; convert! this; cat_disch exact isIso_pushoutSection_of_isQuasiSeparated_of_flat_right _ _ _ _ hUS hUX hUT hUT' lemma mono_pushoutSection_of_isCompact_of_flat_left_of_ringHomFlat [Flat iX] @@ -484,7 +484,7 @@ lemma mono_pushoutSection_of_isCompact_of_flat_right_of_ringHomFlat [Flat f] (hUX : IsCompact (X := X) UX) (hiX : (iX.appLE US UX hUSX).hom.Flat) : Mono (pushoutSection H hUST hUSX hUY) := by suffices Mono (pushoutSection H.flip hUSX hUST (hUY.trans (inf_comm _ _))) by - rw [← mono_comp_iff_of_isIso (pushoutSymmetry _ _).hom]; convert this; cat_disch + rw [← mono_comp_iff_of_isIso (pushoutSymmetry _ _).hom]; convert! this; cat_disch exact mono_pushoutSection_of_isCompact_of_flat_left_of_ringHomFlat _ _ _ _ hUS hUX hUT hiX set_option backward.isDefEq.respectTransparency false in @@ -495,7 +495,7 @@ lemma isIso_pushoutSection_of_isCompact_of_flat_right_of_ringHomFlat [Flat f] (hiX : (iX.appLE US UX hUSX).hom.Flat) : IsIso (pushoutSection H hUST hUSX hUY) := by suffices IsIso (pushoutSection H.flip hUSX hUST (hUY.trans (inf_comm _ _))) by - rw [← isIso_comp_left_iff (pushoutSymmetry _ _).hom]; convert this; cat_disch + rw [← isIso_comp_left_iff (pushoutSymmetry _ _).hom]; convert! this; cat_disch obtain ⟨I, hI, e⟩ := isCompact_iff_finite_and_eq_biUnion_affineOpens.mp hUT have hIUT (i : I) : i.1 ≤ UT := by rw [e]; intro i; aesop have := hI.to_subtype diff --git a/Mathlib/AlgebraicGeometry/Morphisms/FormallyUnramified.lean b/Mathlib/AlgebraicGeometry/Morphisms/FormallyUnramified.lean index d4a60f4ee35d62..897283b0a8f0f7 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/FormallyUnramified.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/FormallyUnramified.lean @@ -163,7 +163,7 @@ instance [FormallyUnramified f] [LocallyOfFiniteType f] (x : X) : suffices h : Algebra.IsSeparable (IsLocalRing.ResidueField <| Y.presheaf.stalk (f x)) (IsLocalRing.ResidueField <| X.presheaf.stalk x) by - convert h + convert! h refine Algebra.algebra_ext _ _ fun x ↦ ?_ obtain ⟨x, rfl⟩ := IsLocalRing.residue_surjective x rfl diff --git a/Mathlib/AlgebraicGeometry/Morphisms/Immersion.lean b/Mathlib/AlgebraicGeometry/Morphisms/Immersion.lean index c586ee106540ff..2ca18c67c4095c 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/Immersion.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/Immersion.lean @@ -92,7 +92,7 @@ instance [IsImmersion f] : IsClosedImmersion f.liftCoborder := by simp only [Scheme.Hom.liftCoborder_ι]; infer_instance have : IsPreimmersion f.liftCoborder := .of_comp f.liftCoborder f.coborderRange.ι refine .of_isPreimmersion _ ?_ - convert isClosed_preimage_val_coborder + convert! isClosed_preimage_val_coborder apply Set.image_injective.mpr f.coborderRange.ι.isEmbedding.injective rw [← Set.range_comp, ← TopCat.coe_comp, ← Scheme.Hom.comp_base, f.liftCoborder_ι] exact (Set.image_preimage_eq_of_subset (by simpa using subset_coborder)).symm @@ -221,7 +221,7 @@ theorem comp_iff {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsImmersion g] : set_option backward.isDefEq.respectTransparency false in instance : IsImmersion (prod.lift (𝟙 X) (𝟙 X)) := by rw [← MorphismProperty.cancel_right_of_respectsIso @IsImmersion _ (prodIsoPullback X X).hom] - convert (inferInstance : IsImmersion (pullback.diagonal (terminal.from X))) + convert! (inferInstance : IsImmersion (pullback.diagonal (terminal.from X))) ext : 1 <;> simp instance (f g : X ⟶ Y) : IsImmersion (equalizer.ι f g) := diff --git a/Mathlib/AlgebraicGeometry/Morphisms/IsIso.lean b/Mathlib/AlgebraicGeometry/Morphisms/IsIso.lean index 71ddd0de646a6f..45624f1d13c12d 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/IsIso.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/IsIso.lean @@ -46,7 +46,7 @@ example : IsZariskiLocalAtTarget (isomorphisms Scheme) := inferInstance set_option backward.isDefEq.respectTransparency false in instance : HasAffineProperty (isomorphisms Scheme) fun X _ f _ ↦ IsAffine X ∧ IsIso (f.appTop) := by - convert HasAffineProperty.of_isZariskiLocalAtTarget (isomorphisms Scheme) with X Y f hY + convert! HasAffineProperty.of_isZariskiLocalAtTarget (isomorphisms Scheme) with X Y f hY exact ⟨fun ⟨_, _⟩ ↦ (arrow_mk_iso_iff (isomorphisms _) (arrowIsoSpecΓOfIsAffine f)).mpr (inferInstanceAs (IsIso (Spec.map (f.appTop)))), fun (_ : IsIso f) ↦ ⟨.of_isIso f, inferInstance⟩⟩ diff --git a/Mathlib/AlgebraicGeometry/Morphisms/OpenImmersion.lean b/Mathlib/AlgebraicGeometry/Morphisms/OpenImmersion.lean index e278345099f6b1..c2bf27541b780d 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/OpenImmersion.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/OpenImmersion.lean @@ -76,7 +76,7 @@ theorem IsOpenImmersion.of_openCover_source (f : X ⟶ Y) refine IsOpenImmersion.iff_isIso_stalkMap.mpr ⟨.of_continuous_injective_isOpenMap f.continuous hf ?_, ?_⟩ · intro U hU - convert (⨆ i, ((𝒰.f i ≫ f) ''ᵁ (𝒰.f i ⁻¹ᵁ ⟨U, hU⟩))).2 + convert! (⨆ i, ((𝒰.f i ≫ f) ''ᵁ (𝒰.f i ⁻¹ᵁ ⟨U, hU⟩))).2 ext x exact ⟨fun ⟨x, _, _⟩ ↦ by have := 𝒰.exists_eq x; simp; grind, by simp; grind⟩ · intro x @@ -103,7 +103,7 @@ theorem isOpenImmersion_eq_inf : instance : IsZariskiLocalAtTarget (stalkwise (Function.Bijective ·)) := by apply stalkwiseIsZariskiLocalAtTarget_of_respectsIso rw [RingHom.toMorphismProperty_respectsIso_iff] - convert (inferInstance : (MorphismProperty.isomorphisms CommRingCat).RespectsIso) + convert! (inferInstance : (MorphismProperty.isomorphisms CommRingCat).RespectsIso) ext exact (ConcreteCategory.isIso_iff_bijective _).symm diff --git a/Mathlib/AlgebraicGeometry/Morphisms/QuasiCompact.lean b/Mathlib/AlgebraicGeometry/Morphisms/QuasiCompact.lean index 4440bf8c46f313..949d58eebb95fe 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/QuasiCompact.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/QuasiCompact.lean @@ -60,7 +60,7 @@ instance (priority := 900) quasiCompact_of_isIso {X Y : Scheme} (f : X ⟶ Y) [I QuasiCompact f := by constructor intro U _ hU' - convert hU'.image (inv f.base).hom.continuous_toFun using 1 + convert! hU'.image (inv f.base).hom.continuous_toFun using 1 rw [Set.image_eq_preimage_of_inverse] · delta Function.LeftInverse exact IsIso.inv_hom_id_apply f.base @@ -84,9 +84,9 @@ theorem isCompact_and_isOpen_iff_finite_and_eq_biUnion_affineOpens {U : Set X} : theorem isCompact_iff_finite_and_eq_biUnion_affineOpens {U : X.Opens} : IsCompact (X := X) U ↔ ∃ s : Set X.affineOpens, s.Finite ∧ U = ⨆ i ∈ s, (i : X.Opens) := by - convert isCompact_and_isOpen_iff_finite_and_eq_biUnion_affineOpens (U := U.1) using 4 with s + convert! isCompact_and_isOpen_iff_finite_and_eq_biUnion_affineOpens (U := U.1) using 4 with s · simp [U.isOpen] - · convert SetLike.coe_injective.eq_iff.symm; simp + · convert! SetLike.coe_injective.eq_iff.symm; simp theorem isCompact_and_isOpen_iff_finite_and_eq_biUnion_basicOpen [IsAffine X] {U : Set X} : IsCompact U ∧ IsOpen U ↔ ∃ s : Set Γ(X, ⊤), s.Finite ∧ U = ⋃ i ∈ s, X.basicOpen i := @@ -267,7 +267,7 @@ theorem exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact (X : Scheme swap · change (X.presheaf.map (homOfLE _).op) ((X.presheaf.map (homOfLE _).op).hom x) = 0 have H : (X.presheaf.map (homOfLE _).op) x = 0 := H - convert congr_arg (X.presheaf.map (homOfLE _).op).hom H + convert! congr_arg (X.presheaf.map (homOfLE _).op).hom H · simp only [← CommRingCat.comp_apply, ← Functor.map_comp] · rfl · rw [map_zero] diff --git a/Mathlib/AlgebraicGeometry/Morphisms/QuasiFinite.lean b/Mathlib/AlgebraicGeometry/Morphisms/QuasiFinite.lean index afbdcc7b2ade4d..bf8b7375fbea2a 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/QuasiFinite.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/QuasiFinite.lean @@ -221,7 +221,7 @@ nonrec lemma LocallyQuasiFinite.of_fiberToSpecResidueField pullback.map _ _ _ _ (pullback.fst _ _) (Spec.map ((Y.affineCover.f i).residueFieldMap _)) (Y.affineCover.f i) (by simp [pullback.condition]) (by simp) have : IsClosedImmersion g := .of_isPreimmersion _ (isClosed_discrete _) - convert (inferInstance : LocallyQuasiFinite <| g ≫ f.fiberToSpecResidueField _) using 1 + convert! (inferInstance : LocallyQuasiFinite <| g ≫ f.fiberToSpecResidueField _) using 1 simp [g, Hom.fiberToSpecResidueField] obtain ⟨R, rfl⟩ := hY wlog hX : ∃ S, X = Spec S @@ -232,7 +232,7 @@ nonrec lemma LocallyQuasiFinite.of_fiberToSpecResidueField let g : (X.affineCover.f i ≫ f).fiber x ⟶ f.fiber x := pullback.map _ _ _ _ (X.affineCover.f i) (𝟙 _) (𝟙 _) (by simp) (by simp) have : IsClosedImmersion g := .of_isPreimmersion _ (isClosed_discrete _) - convert (inferInstance : LocallyQuasiFinite <| g ≫ f.fiberToSpecResidueField _) using 1 + convert! (inferInstance : LocallyQuasiFinite <| g ≫ f.fiberToSpecResidueField _) using 1 simp [g, Hom.fiberToSpecResidueField] obtain ⟨S, rfl⟩ := hX obtain ⟨φ, rfl⟩ := Spec.map_surjective f @@ -275,8 +275,9 @@ nonrec lemma locallyQuasiFinite_iff_isDiscrete_preimage_singleton wlog hY : ∃ R, Y = Spec R · refine (IsZariskiLocalAtTarget.iff_of_openCover Y.affineCover).mpr fun i ↦ this (f := pullback.snd _ _) (fun x ↦ ?_) ⟨_, rfl⟩ - convert (H (Y.affineCover.f i x)).preimage ((pullback.fst f _).continuous.continuousOn) - (pullback.fst f (Y.affineCover.f i)).isOpenEmbedding.injective + convert! + (H (Y.affineCover.f i x)).preimage ((pullback.fst f _).continuous.continuousOn) + (pullback.fst f (Y.affineCover.f i)).isOpenEmbedding.injective ext simp [← (Y.affineCover.f i).isOpenEmbedding.injective.eq_iff, ← Scheme.Hom.comp_apply, -Hom.comp_base, pullback.condition] @@ -298,8 +299,9 @@ nonrec lemma LocallyQuasiFinite.of_finite_preimage_singleton wlog hY : ∃ R, Y = Spec R · refine (IsZariskiLocalAtTarget.iff_of_openCover Y.affineCover).mpr fun i ↦ this (f := pullback.snd _ _) (fun x ↦ ?_) ⟨_, rfl⟩ - convert (hf (Y.affineCover.f i x)).preimage - (pullback.fst f (Y.affineCover.f i)).isOpenEmbedding.injective.injOn + convert! + (hf (Y.affineCover.f i x)).preimage + (pullback.fst f (Y.affineCover.f i)).isOpenEmbedding.injective.injOn ext simp [← (Y.affineCover.f i).isOpenEmbedding.injective.eq_iff, ← Scheme.Hom.comp_apply, -Hom.comp_base, pullback.condition] @@ -346,7 +348,7 @@ lemma Scheme.Hom.QuasiFiniteAt.quasiFiniteAt let e := IsLocalization.algEquiv (hV.primeIdealOf ⟨x, hxV⟩).asIdeal.primeCompl (X.presheaf.stalk (⟨x, hxV⟩ : V.1)) (Localization.AtPrime (hV.primeIdealOf ⟨x, hxV⟩).asIdeal) rw [RingHom.QuasiFiniteAt, Algebra.QuasiFiniteAt, ← RingHom.quasiFinite_algebraMap] - convert (RingHom.QuasiFinite.of_finite e.finite).comp (hx.comp H) + convert! (RingHom.QuasiFinite.of_finite e.finite).comp (hx.comp H) rw [← CommRingCat.hom_comp, f.germ_stalkMap, ← X.presheaf.germ_res (homOfLE hVU) _ hxV, Scheme.Hom.app_eq_appLE, Scheme.Hom.appLE_map_assoc, CommRingCat.hom_comp, ← RingHom.comp_assoc, IsScalarTower.algebraMap_eq Γ(Y, U) Γ(X, V), e.toAlgHom.comp_algebraMap.symm] @@ -358,8 +360,9 @@ lemma Scheme.Hom.quasiFiniteAt [LocallyQuasiFinite f] (x : X) : introv hf algebraize [f] refine .of_comp (g := algebraMap R _) ?_ - convert RingHom.quasiFinite_algebraMap.mpr (inferInstance : - Algebra.QuasiFinite R (Localization.AtPrime J)) + convert! + RingHom.quasiFinite_algebraMap.mpr + (inferInstance : Algebra.QuasiFinite R (Localization.AtPrime J)) ext; simp; rfl set_option backward.isDefEq.respectTransparency false in @@ -390,7 +393,7 @@ nonrec lemma Scheme.Hom.quasiFiniteAt_iff_isOpen_singleton_asFiber · obtain ⟨i, y, hy⟩ := Y.affineCover.exists_eq (f x) obtain ⟨x, rfl, rfl⟩ := Scheme.Pullback.exists_preimage_pullback _ _ hy.symm let ι := Y.affineCover.f i - convert this (f := pullback.snd f ι) (x := x) ⟨_, rfl⟩ using 1 + convert! this (f := pullback.snd f ι) (x := x) ⟨_, rfl⟩ using 1 · exact (RingHom.QuasiFinite.respectsIso.arrow_mk_iso_iff (Scheme.stalkMapIsoOfIsPullback (.of_hasPullback f ι) x)) have H : pullback.snd f ι ⁻¹' {pullback.snd f ι x} = @@ -401,8 +404,9 @@ nonrec lemma Scheme.Hom.quasiFiniteAt_iff_isOpen_singleton_asFiber let f' : pullback.snd f ι ⁻¹' {pullback.snd f ι x} → f ⁻¹' {f (pullback.fst f ι x)} := Set.MapsTo.restrict (pullback.fst f ι) _ _ fun a ha ↦ H.le ha have : Topology.IsOpenEmbedding f' := by - convert (f ⁻¹' {f (pullback.fst f ι x)}).restrictPreimage_isOpenEmbedding - (pullback.fst f ι).isOpenEmbedding using 0 + convert! + (f ⁻¹' {f (pullback.fst f ι x)}).restrictPreimage_isOpenEmbedding + (pullback.fst f ι).isOpenEmbedding using 0 dsimp [f', Set.restrictPreimage] congr! rw [this.isOpen_iff_image_isOpen, Set.image_singleton]; rfl @@ -410,7 +414,7 @@ nonrec lemma Scheme.Hom.quasiFiniteAt_iff_isOpen_singleton_asFiber wlog hX : ∃ S, X = Spec S · obtain ⟨i, x, rfl⟩ := X.affineCover.exists_eq x let ι := X.affineCover.f i - convert this (x := x) _ (f := ι ≫ f) ⟨_, rfl⟩ using 1 + convert! this (x := x) _ (f := ι ≫ f) ⟨_, rfl⟩ using 1 · exact quasiFiniteAt_comp_iff_of_isOpenImmersion.symm rw [((f ⁻¹' {f (ι x)}).restrictPreimage_isOpenEmbedding ι.isOpenEmbedding).isOpen_iff_image_isOpen, Set.image_singleton]; rfl diff --git a/Mathlib/AlgebraicGeometry/Morphisms/RingHomProperties.lean b/Mathlib/AlgebraicGeometry/Morphisms/RingHomProperties.lean index 826d4095dee4af..53e5f2bf79d156 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/RingHomProperties.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/RingHomProperties.lean @@ -468,8 +468,9 @@ lemma stalkwise {P} (hP : RingHom.RespectsIso P) : ∀ (p : Ideal S) (_ : p.IsPrime), P (Localization.localRingHom _ p φ rfl) := by have := stalkwiseIsZariskiLocalAtTarget_of_respectsIso hP have := stalkwise_isZariskiLocalAtSource_of_respectsIso hP - convert of_isZariskiLocalAtSource_of_isZariskiLocalAtTarget - (P := AlgebraicGeometry.stalkwise P) with R S _ _ φ + convert! + of_isZariskiLocalAtSource_of_isZariskiLocalAtTarget (P := AlgebraicGeometry.stalkwise P) with R + S _ _ φ exact (stalkwise_SpecMap_iff hP (CommRingCat.ofHom φ)).symm lemma stableUnderComposition (hP : RingHom.StableUnderComposition Q) : diff --git a/Mathlib/AlgebraicGeometry/Morphisms/Separated.lean b/Mathlib/AlgebraicGeometry/Morphisms/Separated.lean index a9a5b335ead4cc..1bed75b024ca52 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/Separated.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/Separated.lean @@ -133,7 +133,7 @@ instance [IsSeparated g] : rw [← MorphismProperty.cancel_left_of_respectsIso @IsClosedImmersion (pullback.fst f (𝟙 Y))] rw [← MorphismProperty.cancel_right_of_respectsIso @IsClosedImmersion _ (pullback.congrHom rfl (Category.id_comp g)).inv] - convert (inferInstance : IsClosedImmersion (pullback.mapDesc f (𝟙 _) g)) using 1 + convert! (inferInstance : IsClosedImmersion (pullback.mapDesc f (𝟙 _) g)) using 1 ext : 1 <;> simp [pullback.condition] end IsSeparated @@ -274,7 +274,7 @@ instance isClosedImmersion_equalizer_ι_left {S : Scheme} {X Y : Over S} [IsSepa ((Limits.isPullback_equalizer_prod f g).map (Over.forget _)).flip ?_ rw [← MorphismProperty.cancel_right_of_respectsIso @IsClosedImmersion _ (Over.prodLeftIsoPullback Y Y).hom] - convert (inferInstance : IsClosedImmersion (pullback.diagonal Y.hom)) + convert! (inferInstance : IsClosedImmersion (pullback.diagonal Y.hom)) ext1 <;> simp [← Over.comp_left] set_option backward.isDefEq.respectTransparency false in @@ -358,7 +358,7 @@ end Scheme instance IsSeparated.hasAffineProperty : HasAffineProperty @IsSeparated fun X _ _ _ ↦ X.IsSeparated := by - convert HasAffineProperty.of_isZariskiLocalAtTarget @IsSeparated with X Y f hY + convert! HasAffineProperty.of_isZariskiLocalAtTarget @IsSeparated with X Y f hY rw [Scheme.isSeparated_iff, ← terminal.comp_from f, IsSeparated.comp_iff] rfl diff --git a/Mathlib/AlgebraicGeometry/Morphisms/Smooth.lean b/Mathlib/AlgebraicGeometry/Morphisms/Smooth.lean index a4691fe0efbde2..90a3aaee05e490 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/Smooth.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/Smooth.lean @@ -86,7 +86,7 @@ lemma Smooth.iff_forall_exists_isStandardSmooth (f : X ⟶ Y) : ∀ (x : X), ∃ (U : Y.Opens) (_ : IsAffineOpen U) (V : X.Opens) (_ : IsAffineOpen V) (_ : x ∈ V) (e : V ≤ f ⁻¹ᵁ U), (f.appLE U V e).hom.IsStandardSmooth := by have : HasRingHomProperty @Smooth.{u} (Locally IsStandardSmooth) := by - convert (inferInstance : HasRingHomProperty @Smooth.{u} RingHom.Smooth) + convert! (inferInstance : HasRingHomProperty (@Smooth.{u}) RingHom.Smooth) ext f rw [RingHom.smooth_iff_locally_isStandardSmooth] rw [HasRingHomProperty.iff_exists_appLE_locally (P := @Smooth)] @@ -279,8 +279,9 @@ lemma exists_smooth_of_formallySmooth_stalk IsAffineOpen.isoSpec_hom, IsAffineOpen.toSpecΓ_fromSpec] at hrx · have := hV.isLocalization_basicOpen r rw [← RingHom.smooth_algebraMap] at hr - convert RingHom.Smooth.propertyIsLocal.respectsIso.1 _ - (IsLocalization.algEquiv (.powers r) _ Γ(X, X.basicOpen r)).toRingEquiv hr + convert! + RingHom.Smooth.propertyIsLocal.respectsIso.1 _ + (IsLocalization.algEquiv (.powers r) _ Γ(X, X.basicOpen r)).toRingEquiv hr ext dsimp simp only [IsScalarTower.algebraMap_apply Γ(Y, U) Γ(X, V) (Localization _), diff --git a/Mathlib/AlgebraicGeometry/Morphisms/SurjectiveOnStalks.lean b/Mathlib/AlgebraicGeometry/Morphisms/SurjectiveOnStalks.lean index df70ea5e9d912d..3ad7c42378a0c3 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/SurjectiveOnStalks.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/SurjectiveOnStalks.lean @@ -121,9 +121,10 @@ lemma isEmbedding_pullback {X Y S : Scheme.{u}} (f : X ⟶ S) (g : Y ⟶ S) [Sur obtain ⟨ψ, rfl⟩ : ∃ ψ, Spec.map ψ = g' := ⟨_, Spec.map_preimage _⟩ algebraize [φ.hom, ψ.hom] rw [HasRingHomProperty.Spec_iff (P := @SurjectiveOnStalks)] at H - convert ((iX.isOpenEmbedding.prodMap iY.isOpenEmbedding).isEmbedding.comp - (PrimeSpectrum.isEmbedding_tensorProductTo_of_surjectiveOnStalks R A B H)).comp - (Scheme.homeoOfIso (pullbackSpecIso R A B)).isEmbedding + convert! + ((iX.isOpenEmbedding.prodMap iY.isOpenEmbedding).isEmbedding.comp + (PrimeSpectrum.isEmbedding_tensorProductTo_of_surjectiveOnStalks R A B H)).comp + (Scheme.homeoOfIso (pullbackSpecIso R A B)).isEmbedding ext1 x obtain ⟨x, rfl⟩ := (Scheme.homeoOfIso (pullbackSpecIso R A B).symm).surjective x simp only [Scheme.homeoOfIso_apply, Function.comp_apply] @@ -194,7 +195,7 @@ lemma isEmbedding_pullback {X Y S : Scheme.{u}} (f : X ⟶ S) (g : Y ⟶ S) [Sur ((𝒲 i.1).f i.2.2 ≫ (𝒰.pullback₁ g).f i.1) (𝒰.f i.1) (by simp [pullback.condition]) (by simp [pullback.condition]) inferInstance inferInstance inferInstance - convert this using 7 + convert! this using 7 apply pullback.hom_ext <;> simp [𝓤, Scheme.Cover.pullbackHom] diff --git a/Mathlib/AlgebraicGeometry/Morphisms/UnderlyingMap.lean b/Mathlib/AlgebraicGeometry/Morphisms/UnderlyingMap.lean index a49107cc73248b..e71b9335da7474 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/UnderlyingMap.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/UnderlyingMap.lean @@ -258,7 +258,7 @@ lemma IsDominant.of_comp_of_isOpenImmersion IsDominant f := by rw [isDominant_iff, DenseRange] at H ⊢ simp only [Scheme.Hom.comp_base, TopCat.coe_comp, Set.range_comp] at H - convert H.preimage g.isOpenEmbedding.isOpenMap using 1 + convert! H.preimage g.isOpenEmbedding.isOpenMap using 1 rw [Set.preimage_image_eq _ g.isOpenEmbedding.injective] lemma Opens.isDominant_ι {U : X.Opens} (hU : Dense (X := X) U) : IsDominant U.ι := diff --git a/Mathlib/AlgebraicGeometry/Morphisms/UniversallyOpen.lean b/Mathlib/AlgebraicGeometry/Morphisms/UniversallyOpen.lean index 6aa9ada9c7d9a1..04e00844ee99cf 100644 --- a/Mathlib/AlgebraicGeometry/Morphisms/UniversallyOpen.lean +++ b/Mathlib/AlgebraicGeometry/Morphisms/UniversallyOpen.lean @@ -124,7 +124,7 @@ lemma isOpenMap_of_generalizingMap [LocallyOfFinitePresentation f] obtain ⟨S, rfl⟩ := hX obtain ⟨φ, rfl⟩ := Spec.map_surjective f algebraize [φ.hom] - convert PrimeSpectrum.isOpenMap_comap_of_hasGoingDown_of_finitePresentation + convert! PrimeSpectrum.isOpenMap_comap_of_hasGoingDown_of_finitePresentation · rwa [Algebra.HasGoingDown.iff_generalizingMap_primeSpectrumComap] · apply (HasRingHomProperty.Spec_iff (P := @LocallyOfFinitePresentation)).mp inferInstance @@ -137,7 +137,7 @@ lemma Flat.generalizingMap [Flat f] : GeneralizingMap f := by intro U V e algebraize [(f.appLE U V e).hom] apply Algebra.HasGoingDown.iff_generalizingMap_primeSpectrumComap.mp - convert Algebra.HasGoingDown.of_flat + convert! Algebra.HasGoingDown.of_flat exact HasRingHomProperty.appLE @Flat f ‹_› U V e /-- A flat morphism, locally of finite presentation is universally open. -/ diff --git a/Mathlib/AlgebraicGeometry/Noetherian.lean b/Mathlib/AlgebraicGeometry/Noetherian.lean index 7984fc67b132fb..9e57b460d25af5 100644 --- a/Mathlib/AlgebraicGeometry/Noetherian.lean +++ b/Mathlib/AlgebraicGeometry/Noetherian.lean @@ -175,7 +175,7 @@ theorem isLocallyNoetherian_iff_openCover (𝒰 : Scheme.OpenCover X) : /-- If `R` is a Noetherian ring, `Spec R` is a Noetherian topological space. -/ instance {R : CommRingCat} [IsNoetherianRing R] : NoetherianSpace (Spec R) := by - convert PrimeSpectrum.instNoetherianSpace (R := R) + convert! PrimeSpectrum.instNoetherianSpace (R := R) lemma noetherianSpace_of_isAffine [IsAffine X] [IsNoetherianRing Γ(X, ⊤)] : NoetherianSpace X := @@ -209,7 +209,7 @@ instance (priority := 100) {Z : Scheme} [IsLocallyNoetherian X] rw [Opens.map_coe, ← Set.preimage_inter_range] apply f.isOpenEmbedding.isInducing.isCompact_preimage' · apply (noetherianSpace_set_iff _).mp - · convert noetherianSpace_of_isAffineOpen U hU + · convert! noetherianSpace_of_isAffineOpen U hU apply IsLocallyNoetherian.component_noetherian ⟨U, hU⟩ · exact Set.inter_subset_left · exact Set.inter_subset_right @@ -225,7 +225,7 @@ instance (priority := 100) IsLocallyNoetherian.quasiSeparatedSpace [IsLocallyNoe · rw [← Set.preimage_inter_range, IsAffineOpen.range_fromSpec, Set.inter_comm] apply hInd.isCompact_preimage' · apply (noetherianSpace_set_iff _).mp - · convert noetherianSpace_of_isAffineOpen U.1 U.2 + · convert! noetherianSpace_of_isAffineOpen U.1 U.2 apply IsLocallyNoetherian.component_noetherian · exact Set.inter_subset_left · rw [IsAffineOpen.range_fromSpec] @@ -287,14 +287,14 @@ theorem isNoetherian_iff_of_finite_iSup_eq_top {ι} [Finite ι] {S : ι → X.af apply (isLocallyNoetherian_iff_of_iSup_eq_top hS).mp exact h.toIsLocallyNoetherian · intro h - convert IsNoetherian.mk + convert! IsNoetherian.mk · exact isLocallyNoetherian_of_affine_cover hS h · constructor rw [← Opens.coe_top, ← hS, Opens.iSup_mk] apply isCompact_iUnion intro i apply isCompact_iff_isCompact_univ.mpr - convert CompactSpace.isCompact_univ + convert! CompactSpace.isCompact_univ have : NoetherianSpace (S i) := by apply noetherianSpace_of_isAffineOpen (S i).1 (S i).2 apply NoetherianSpace.compactSpace (S i) @@ -308,7 +308,7 @@ theorem isNoetherian_iff_of_finite_affine_openCover {𝒰 : Scheme.OpenCover.{v, apply (isLocallyNoetherian_iff_of_affine_openCover _).mp exact h.toIsLocallyNoetherian · intro hNoeth - convert IsNoetherian.mk + convert! IsNoetherian.mk · exact (isLocallyNoetherian_iff_of_affine_openCover _).mpr hNoeth · exact Scheme.OpenCover.compactSpace 𝒰 @@ -326,7 +326,7 @@ instance (priority := 100) IsNoetherian.noetherianSpace [IsNoetherian X] : rw [X.affineCover.finiteSubcover_X] apply Scheme.isAffine_affineCover let U : X.affineOpens := ⟨Scheme.Hom.opensRange (𝒰.f i), isAffineOpen_opensRange _⟩ - convert noetherianSpace_of_isAffineOpen U.1 U.2 + convert! noetherianSpace_of_isAffineOpen U.1 U.2 apply IsLocallyNoetherian.component_noetherian /-- Any morphism of schemes `f : X ⟶ Y` with `X` Noetherian is quasi-compact. -/ diff --git a/Mathlib/AlgebraicGeometry/Normalization.lean b/Mathlib/AlgebraicGeometry/Normalization.lean index 3d1641c5aa46b4..c90633e152413c 100644 --- a/Mathlib/AlgebraicGeometry/Normalization.lean +++ b/Mathlib/AlgebraicGeometry/Normalization.lean @@ -205,7 +205,7 @@ instance : IsIntegralHom f.fromNormalization := by letI := (f.app U).hom.toAlgebra change (algebraMap Γ(Y, U) (integralClosure Γ(Y, U) Γ(X, f ⁻¹ᵁ U))).IsIntegral exact algebraMap_isIntegral_iff.mpr inferInstance - convert IsIntegralHom.SpecMap_iff.mpr this + convert! IsIntegralHom.SpecMap_iff.mpr this rw [← cancel_mono U.2.fromSpec] simp [IsAffineOpen.isoSpec_hom, e, ι_fromNormalization] @@ -237,7 +237,7 @@ lemma toNormalization_app_preimage (U : Y.affineOpens) : have H : f.toNormalization ⁻¹ᵁ f.fromNormalization ⁻¹ᵁ U = (f ⁻¹ᵁ U).ι ''ᵁ (((f ⁻¹ᵁ U).ι ≫ f.toNormalization) ⁻¹ᵁ f.fromNormalization ⁻¹ᵁ U) := by simp [← Scheme.Hom.comp_preimage] - convert congr($(Scheme.Hom.congr_app (f.ι_toNormalization U) (f.fromNormalization ⁻¹ᵁ U)) ≫ + convert! congr($(Scheme.Hom.congr_app (f.ι_toNormalization U) (f.fromNormalization ⁻¹ᵁ U)) ≫ X.presheaf.map (eqToHom H).op) using 1 · simp [Hom.app_eq_appLE] dsimp @@ -350,8 +350,9 @@ instance [IsReduced X] : IsReduced f.normalization := instance [IsIntegral X] : IsIntegral f.normalization := have : IrreducibleSpace f.normalization := by rw [irreducibleSpace_def] - convert ((IrreducibleSpace.isIrreducible_univ X).image _ - f.toNormalization.continuous.continuousOn).closure + convert! + ((IrreducibleSpace.isIrreducible_univ X).image _ + f.toNormalization.continuous.continuousOn).closure simpa using f.toNormalization.denseRange.closure_range.symm isIntegral_of_irreducibleSpace_of_isReduced _ @@ -641,7 +642,7 @@ instance [Smooth g] : IsIso (f.normalizationPullback g) := by ((pullback.snd f g).normalizationObjIso hV).inv ≫ (pullback.snd f g).normalization.presheaf.map (eqToHom (by simp only [W, ← Scheme.Hom.comp_preimage, Scheme.Hom.normalizationPullback_snd])).op - convert show IsIso φ by dsimp only [φ]; infer_instance using 1 + convert! show IsIso φ by dsimp only [φ]; infer_instance using 1 ext1 · dsimp [φ] simp only [Scheme.Hom.app_eq_appLE, colimit.ι_desc_assoc, span_left, PushoutCocone.mk_pt, diff --git a/Mathlib/AlgebraicGeometry/OpenImmersion.lean b/Mathlib/AlgebraicGeometry/OpenImmersion.lean index 33f0bea355d643..3d3d379bb46ecc 100644 --- a/Mathlib/AlgebraicGeometry/OpenImmersion.lean +++ b/Mathlib/AlgebraicGeometry/OpenImmersion.lean @@ -654,7 +654,7 @@ theorem isPullback_lift_id {X U Y : Scheme.{u}} (f : X ⟶ Y) (g : U ⟶ Y) [IsOpenImmersion g] (H : Set.range f ⊆ Set.range g) : IsPullback (IsOpenImmersion.lift g f H) (𝟙 _) g f := by - convert IsPullback.of_id_snd.paste_horiz (IsKernelPair.id_of_mono g) + convert! IsPullback.of_id_snd.paste_horiz (IsKernelPair.id_of_mono g) · exact (Category.comp_id _).symm · simp @@ -704,8 +704,10 @@ lemma isPullback {U V X Y : Scheme.{u}} (g : U ⟶ V) (iU : U ⟶ X) (iV : V ⟶ (H' : f ⁻¹ᵁ iV.opensRange = iU.opensRange) : IsPullback g iU iV f := by let e := IsOpenImmersion.isoOfRangeEq (pullback.snd iV f) iU (by simpa [range_pullbackSnd] using congr(($H').1)) - convert (IsPullback.of_horiz_isIso (show CommSq e.inv iU (pullback.snd iV f) (𝟙 X) from - ⟨by simp [e]⟩)).paste_horiz (IsPullback.of_hasPullback iV f) + convert! + (IsPullback.of_horiz_isIso + (show CommSq e.inv iU (pullback.snd iV f) (𝟙 X) from ⟨by simp [e]⟩)).paste_horiz + (IsPullback.of_hasPullback iV f) simp [← cancel_mono iV, e, pullback.condition, H] /-- If `f` is an open immersion `X ⟶ Y`, the global sections of `X` diff --git a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Basic.lean b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Basic.lean index f3895c978cad52..2597206406c34e 100644 --- a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Basic.lean +++ b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Basic.lean @@ -79,7 +79,7 @@ theorem basicOpen_eq_iSup_proj (f : A) : theorem isBasis_basicOpen : TopologicalSpace.Opens.IsBasis (Set.range (basicOpen 𝒜)) := by delta TopologicalSpace.Opens.IsBasis - convert ProjectiveSpectrum.isTopologicalBasis_basic_opens 𝒜 + convert! ProjectiveSpectrum.isTopologicalBasis_basic_opens 𝒜 exact (Set.range_comp _ _).symm /-- If `{ xᵢ }` spans the irrelevant ideal of `A`, then `D₊(xᵢ)` covers `Proj A`. -/ @@ -117,15 +117,16 @@ lemma iSup_basicOpen_eq_top' {ι : Type*} (f : ι → A) · rw [DirectSum.decompose_of_mem_ne 𝒜 hn hn', sub_zero] exact Ideal.subset_span ⟨_, rfl⟩ | algebraMap r => - convert zero_mem (Ideal.span _) + convert! zero_mem (Ideal.span _) rw [sub_eq_zero] exact (DirectSum.decompose_of_mem_same 𝒜 r.2).symm | add x y hx hy _ _ => rw [map_add, add_sub_add_comm] exact add_mem ‹_› ‹_› | mul x y hx hy hx' hy' => - convert add_mem (Ideal.mul_mem_left _ x hy') - (Ideal.mul_mem_right (GradedRing.projZeroRingHom 𝒜 y) _ hx') using 1 + convert! + add_mem (Ideal.mul_mem_left _ x hy') + (Ideal.mul_mem_right (GradedRing.projZeroRingHom 𝒜 y) _ hx') using 1 rw [map_mul] ring @@ -164,7 +165,7 @@ noncomputable def basicOpenIsoSpec : (basicOpen 𝒜 f).toScheme ≅ Spec (.of <| Away 𝒜 f) := have : IsIso (basicOpenToSpec 𝒜 f) := by apply (isIso_iff_of_reflects_iso _ Scheme.forgetToLocallyRingedSpace).mp ?_ - convert ProjectiveSpectrum.Proj.isIso_toSpec 𝒜 f f_deg hm using 1 + convert! ProjectiveSpectrum.Proj.isIso_toSpec 𝒜 f f_deg hm using 1 refine Eq.trans ?_ (ΓSpec.locallyRingedSpaceAdjunction.homEquiv_apply _ _ _).symm dsimp [basicOpenToSpec, Scheme.Opens.toSpecΓ] simp only [eqToHom_op, Category.assoc, ← Spec.map_comp] @@ -344,7 +345,7 @@ def affineOpenCover : (Proj 𝒜).AffineOpenCover := rw [← DirectSum.sum_support_decompose 𝒜 z] refine Ideal.sum_mem _ fun c hc ↦ if hc0 : c = 0 then ?_ else Ideal.subset_span ⟨⟨⟨c, Nat.pos_iff_ne_zero.mpr hc0⟩, _⟩, rfl⟩ - convert Ideal.zero_mem _ + convert! Ideal.zero_mem _ subst hc0 exact hz diff --git a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Functor.lean b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Functor.lean index 1174f931fab343..65b2a377e24f94 100644 --- a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Functor.lean +++ b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Functor.lean @@ -210,7 +210,7 @@ theorem map_comp : map (g.comp f) (irrelevant_le_map_comp hf hg) = map g hg ≫ set_option backward.isDefEq.respectTransparency false in theorem map_id : map (.id 𝒜) (by simp) = 𝟙 (Proj 𝒜) := by refine (affineOpenCover _).openCover.hom_ext _ _ fun s ↦ ?_ - convert awayι_comp_map (.id 𝒜) _ _ _ s.2.2 using 1 + convert! awayι_comp_map (.id 𝒜) _ _ _ s.2.2 using 1 simp end Proj diff --git a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Proper.lean b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Proper.lean index 29825cc7cd11c4..046a7827b71b73 100644 --- a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Proper.lean +++ b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Proper.lean @@ -46,24 +46,24 @@ lemma lift_awayMapₐ_awayMapₐ_surjective {d e : ℕ} {f : A} (hf : f ∈ 𝒜 exact this.elim _ _ have : n = j * (d + e) := by apply DirectSum.degree_eq_of_mem_mem 𝒜 hb' - · convert SetLike.pow_mem_graded _ _ using 2 + · convert! SetLike.pow_mem_graded _ _ using 2 · infer_instance · exact hx ▸ SetLike.mul_mem_graded hf hg · exact hx ▸ hfg let x0 : NumDenSameDeg 𝒜 (.powers f) := { deg := j * (d * (e + 1)) num := ⟨a * g ^ (j * (d - 1)), by - convert SetLike.mul_mem_graded ha (SetLike.pow_mem_graded _ hg) using 2 + convert! SetLike.mul_mem_graded ha (SetLike.pow_mem_graded _ hg) using 2 rw [this] cases d · contradiction · simp; ring⟩ - den := ⟨f ^ (j * (e + 1)), by convert SetLike.pow_mem_graded _ hf using 2; ring⟩ + den := ⟨f ^ (j * (e + 1)), by convert! SetLike.pow_mem_graded _ hf using 2; ring⟩ den_mem := ⟨_,rfl⟩ } let y0 : NumDenSameDeg 𝒜 (.powers g) := { deg := j * (d * e) - num := ⟨f ^ (j * e), by convert SetLike.pow_mem_graded _ hf using 2; ring⟩ - den := ⟨g ^ (j * d), by convert SetLike.pow_mem_graded _ hg using 2; ring⟩ + num := ⟨f ^ (j * e), by convert! SetLike.pow_mem_graded _ hf using 2; ring⟩ + den := ⟨g ^ (j * d), by convert! SetLike.pow_mem_graded _ hg using 2; ring⟩ den_mem := ⟨_,rfl⟩ } use mk x0 ⊗ₜ mk y0 ext @@ -101,8 +101,9 @@ instance isSeparated : IsSeparated (toSpecZero 𝒜) := by (Algebra.TensorProduct.lift (awayMapₐ 𝒜 j.2.2 rfl) (awayMapₐ 𝒜 i.2.2 (mul_comm _ _)) (fun _ _ ↦ .all _ _)).toRingHom have : Function.Surjective F := lift_awayMapₐ_awayMapₐ_surjective 𝒜 i.2.2 j.2.2 rfl i.1.2 - convert IsClosedImmersion.spec_of_surjective - (CommRingCat.ofHom (R := Away 𝒜 i.2.1 ⊗[𝒜 0] Away 𝒜 j.2.1) F) this using 1 + convert! + IsClosedImmersion.spec_of_surjective + (CommRingCat.ofHom (R := Away 𝒜 i.2.1 ⊗[𝒜 0] Away 𝒜 j.2.1) F) this using 1 rw [← cancel_mono (pullbackSpecIso ..).inv] apply pullback.hom_ext · simp only [Iso.trans_hom, congrHom_hom, Category.assoc, Iso.hom_inv_id, Category.comp_id, @@ -215,7 +216,7 @@ theorem valuativeCriterion_existence_aux refine zero_lt_iff.mpr fun hKmax ↦ ?_ have (i : _) : ψ i = 0 := le_zero_iff.mp (hKmax ▸ Finset.le_max' _ _ (by simp)) simp only [ψ, map_pow, pow_eq_zero_iff', map_eq_zero, ne_eq] at this - have : φ 1 = 0 := by convert (this j).1; ext; simp + have : φ 1 = 0 := by convert! (this j).1; ext; simp simp only [map_one, one_ne_zero] at this letI := (awayMap 𝒜 (f := x j) (hxdi i₀) rfl).toAlgebra have := Away.isLocalization_mul (hxdi j) (hxdi i₀) rfl (hdi _).ne' @@ -244,15 +245,16 @@ theorem valuativeCriterion_existence_aux obtain ⟨a, ai, hai, rfl⟩ := h simp only [smul_eq_mul] at hai have H : (∏ i, x i ^ ai i) * x i₀ ^ (a * (d j - 1)) ∈ 𝒜 ((a * d i₀) • d j) := by - convert SetLike.mul_mem_graded (SetLike.prod_pow_mem_graded 𝒜 d x ai fun _ _ ↦ hxdi _) - (SetLike.pow_mem_graded (a * (d j - 1)) (hxdi i₀)) using 2 + convert! + SetLike.mul_mem_graded (SetLike.prod_pow_mem_graded 𝒜 d x ai fun _ _ ↦ hxdi _) + (SetLike.pow_mem_graded (a * (d j - 1)) (hxdi i₀)) using 2 simp only [smul_eq_mul, hai] cases h : d j · cases (hdi j).ne' h · simp only [add_tsub_cancel_right]; ring suffices valuation O K (φ (Away.mk 𝒜 (hxdi j) _ _ H) / φ (Away.isLocalizationElem (hxdi j) (hxdi i₀)) ^ a) ≤ 1 by - convert this + convert! this rw [eq_div_iff (pow_ne_zero _ hunit.ne_zero), ← hφ'1, ← hφ'1, RingHom.comp_apply, ← map_pow, ← map_mul] congr @@ -341,7 +343,7 @@ lemma valuativeCriterion_existence [Algebra.FiniteType (𝒜 0) A] : exact congr_arg Subtype.val (e.apply_symm_apply _) refine ⟨⟨Spec.map (CommRingCat.ofHom φ'') ≫ Proj.awayι 𝒜 _ (hxd _ i₀.2) (hd _ _).bot_lt, ?_, ?_⟩⟩ · rw [← Spec.map_comp_assoc] - convert IsOpenImmersion.lift_fac _ _ this using 1 + convert! IsOpenImmersion.lift_fac _ _ this using 1 change _ = φ ≫ _ rw [← Spec.map_preimage φ, ← CommRingCat.ofHom_hom (Spec.preimage φ), ← hφ, ← CommRingCat.ofHom_comp] diff --git a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Scheme.lean b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Scheme.lean index 2c707a758533b3..0df625c2b1eb3b 100644 --- a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Scheme.lean +++ b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Scheme.lean @@ -290,7 +290,7 @@ theorem mem_carrier_iff' (q : Spec.T A⁰_ f) (a : A) : · rw [Set.mem_image]; refine ⟨_, h, rfl⟩ · rw [Set.mem_image] at h; rcases h with ⟨x, h, hx⟩ change x ∈ q.asIdeal at h - convert h + convert! h rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk] dsimp only [Subtype.coe_mk]; rw [← hx]; rfl) @@ -301,7 +301,7 @@ theorem mem_carrier_iff_of_mem (hm : 0 < m) (q : Spec.T A⁰_ f) (a : A) {n} (hn trans (HomogeneousLocalization.mk ⟨m * n, ⟨proj 𝒜 n a ^ m, by rw [← smul_eq_mul]; mem_tac⟩, ⟨f ^ n, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.asIdeal · refine ⟨fun h ↦ h n, fun h i ↦ if hi : i = n then hi ▸ h else ?_⟩ - convert zero_mem q.asIdeal + convert! zero_mem q.asIdeal apply HomogeneousLocalization.val_injective simp only [proj_apply, decompose_of_mem_ne _ hn (Ne.symm hi), zero_pow hm.ne', HomogeneousLocalization.val_mk, Localization.mk_zero, HomogeneousLocalization.val_zero] @@ -326,7 +326,7 @@ theorem num_mem_carrier_iff (hm : 0 < m) (q : Spec.T A⁰_ f) have : f ^ n ≠ 0 := fun e ↦ by have := HomogeneousLocalization.subsingleton 𝒜 (x := .powers f) ⟨n, e⟩ exact IsEmpty.elim (inferInstanceAs (IsEmpty (PrimeSpectrum (A⁰_ f)))) q - convert mem_carrier_iff_of_mem_mul f_deg hm q z.num.1 (n := n) ?_ using 2 + convert! mem_carrier_iff_of_mem_mul f_deg hm q z.num.1 (n := n) ?_ using 2 · apply HomogeneousLocalization.val_injective; simp only [hn, HomogeneousLocalization.val_mk] · have := degree_eq_of_mem_mem 𝒜 (SetLike.pow_mem_graded n f_deg) (hn.symm ▸ z.den.2) this rw [← smul_eq_mul, this]; exact z.num.2 @@ -383,10 +383,10 @@ variable (hm : 0 < m) (q : Spec.T A⁰_ f) include hm theorem carrier.zero_mem : (0 : A) ∈ carrier f_deg q := fun i => by - convert Submodule.zero_mem q.1 using 1 + convert! Submodule.zero_mem q.1 using 1 rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk, HomogeneousLocalization.val_zero]; simp_rw [map_zero, zero_pow hm.ne'] - convert Localization.mk_zero (S := Submonoid.powers f) _ using 1 + convert! Localization.mk_zero (S := Submonoid.powers f) _ using 1 theorem carrier.smul_mem (c x : A) (hx : x ∈ carrier f_deg q) : c • x ∈ carrier f_deg q := by revert c @@ -442,7 +442,7 @@ theorem carrier.denom_notMem : f ∉ carrier.asIdeal f_deg hm q := fun rid => q.isPrime.ne_top <| (Ideal.eq_top_iff_one _).mpr (by - convert rid m + convert! rid m rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_one, HomogeneousLocalization.val_mk] dsimp @@ -460,7 +460,7 @@ theorem carrier.asIdeal.prime : (carrier.asIdeal f_deg hm q).IsPrime := (carrier.asIdeal.ne_top f_deg hm q) fun {x y} ⟨nx, hnx⟩ ⟨ny, hny⟩ hxy => show (∀ _, _ ∈ _) ∨ ∀ _, _ ∈ _ by rw [← and_forall_ne nx, and_iff_left, ← and_forall_ne ny, and_iff_left] - · apply q.2.mem_or_mem; convert hxy (nx + ny) using 1 + · apply q.2.mem_or_mem; convert! hxy (nx + ny) using 1 dsimp simp_rw [decompose_of_mem_same 𝒜 hnx, decompose_of_mem_same 𝒜 hny, decompose_of_mem_same 𝒜 (SetLike.GradedMonoid.toGradedMul.mul_mem hnx hny), @@ -469,10 +469,10 @@ theorem carrier.asIdeal.prime : (carrier.asIdeal f_deg hm q).IsPrime := HomogeneousLocalization.val_mul, Localization.mk_mul] simp only [Submonoid.mk_mul_mk, mk_eq_monoidOf_mk'] all_goals - intro n hn; convert q.1.zero_mem using 1 + intro n hn; convert! q.1.zero_mem using 1 rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk, HomogeneousLocalization.val_zero]; simp_rw [proj_apply] - convert mk_zero (S := Submonoid.powers f) _ + convert! mk_zero (S := Submonoid.powers f) _ rw [decompose_of_mem_ne 𝒜 _ hn.symm, zero_pow hm.ne'] · first | exact hnx | exact hny @@ -680,7 +680,7 @@ lemma toSpec_base_apply_eq {f} (x : Proj| pbo f) : lemma toSpec_base_isIso {f} {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) : IsIso (toSpec 𝒜 f).base := by - convert (projIsoSpecTopComponent f_deg hm).isIso_hom + convert! (projIsoSpecTopComponent f_deg hm).isIso_hom exact ConcreteCategory.hom_ext _ _ <| toSpec_base_apply_eq 𝒜 lemma mk_mem_toSpec_base_apply {f} (x : Proj| pbo f) @@ -694,7 +694,7 @@ lemma toSpec_preimage_basicOpen {f} (Opens.map (toSpec 𝒜 f).base).obj (sbo (HomogeneousLocalization.mk t)) = Opens.comap ⟨_, continuous_subtype_val⟩ (pbo t.num.1) := Opens.ext <| Opens.map_coe _ _ ▸ by - convert (ProjIsoSpecTopComponent.ToSpec.preimage_basicOpen f t) + convert! (ProjIsoSpecTopComponent.ToSpec.preimage_basicOpen f t) exact funext fun _ => toSpec_base_apply_eq _ _ @[reassoc] @@ -742,7 +742,7 @@ lemma isLocalization_atPrime (f) (x : pbo f) {m} (f_deg : f ∈ 𝒜 m) (hm : 0 ⟨f ^ i, SetLike.pow_mem_graded _ f_deg⟩, ⟨_, rfl⟩⟩, (mk_mem_toSpec_base_apply _ _ _).not.mpr <| x.1.1.toIdeal.primeCompl.pow_mem hb' m⟩⟩, val_injective _ ?_⟩ - · convert SetLike.mul_mem_graded a.2 (SetLike.pow_mem_graded (m - 1) hb) using 2 + · convert! SetLike.mul_mem_graded a.2 (SetLike.pow_mem_graded (m - 1) hb) using 2 rw [← succ_nsmul', tsub_add_cancel_of_le (by lia), mul_comm, smul_eq_mul] · simp only [RingHom.algebraMap_toAlgebra, map_mk, GradedRingHom.id_apply, val_mul, val_mk, mk_eq_mk', ← IsLocalization.mk'_mul, Submonoid.mk_mul_mk, IsLocalization.mk'_eq_iff_eq] diff --git a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean index b756f0661b51ec..bdb664d7556e7f 100644 --- a/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean +++ b/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean @@ -236,7 +236,7 @@ theorem zeroLocus_bUnion (s : Set (Set A)) : theorem vanishingIdeal_iUnion {γ : Sort*} (t : γ → Set (ProjectiveSpectrum 𝒜)) : vanishingIdeal (⋃ i, t i) = ⨅ i, vanishingIdeal (t i) := HomogeneousIdeal.toIdeal_injective <| by - convert (gc_ideal 𝒜).u_iInf; exact HomogeneousIdeal.toIdeal_iInf _ + convert! (gc_ideal 𝒜).u_iInf; exact HomogeneousIdeal.toIdeal_iInf _ theorem zeroLocus_inf (I J : Ideal A) : zeroLocus 𝒜 ((I ⊓ J : Ideal A) : Set A) = zeroLocus 𝒜 I ∪ zeroLocus 𝒜 J := @@ -287,7 +287,7 @@ instance zariskiTopology : TopologicalSpace (ProjectiveSpectrum 𝒜) := let f : Zs → Set _ := fun i => Classical.choose (h i.2) have H : (Set.iInter fun i ↦ zeroLocus 𝒜 (f i)) ∈ Set.range (zeroLocus 𝒜) := ⟨_, zeroLocus_iUnion 𝒜 _⟩ - convert H using 2 + convert! H using 2 funext i exact (Classical.choose_spec (h i.2)).symm) (by diff --git a/Mathlib/AlgebraicGeometry/Properties.lean b/Mathlib/AlgebraicGeometry/Properties.lean index dd3e75425f2bbc..61bd12ec15f0da 100644 --- a/Mathlib/AlgebraicGeometry/Properties.lean +++ b/Mathlib/AlgebraicGeometry/Properties.lean @@ -161,7 +161,7 @@ theorem reduce_to_affine_nbhd (P : ∀ (X : Scheme) (_ : X), Prop) ∀ (X : Scheme) (x : X), P X x := by intro X x obtain ⟨y, e⟩ := X.affineCover.covers x - convert h₂ (X.affineCover.f (X.affineCover.idx x)) y _ + convert! h₂ (X.affineCover.f (X.affineCover.idx x)) y _ · rw [e] apply h₁ @@ -289,7 +289,7 @@ theorem isIntegral_of_irreducibleSpace_of_isReduced [IsReduced X] [H : Irreducib replace e := congr_arg (X.presheaf.germ U x hxU) e rw [map_mul, map_zero] at e refine zero_ne_one' (X.presheaf.stalk x) (isUnit_zero_iff.1 ?_) - convert hx₁.mul hx₂ + convert! hx₁.mul hx₂ exact e.symm exact NoZeroDivisors.to_isDomain _ @@ -315,7 +315,7 @@ lemma IsIntegral.of_isIso {X Y : Scheme.{u}} [h : IsIntegral X] (f : X ⟶ Y) [I exact Nonempty.map f inferInstance instance {R : CommRingCat} [IsDomain R] : IrreducibleSpace (Spec R) := by - convert PrimeSpectrum.irreducibleSpace (R := R) + convert! PrimeSpectrum.irreducibleSpace (R := R) instance {R : CommRingCat} [IsDomain R] : IsIntegral (Spec R) := isIntegral_of_irreducibleSpace_of_isReduced _ @@ -354,10 +354,9 @@ lemma coheight_eq_of_isOpenImmersion {U X : Scheme} {x : U} (f : U ⟶ X) [IsOpe open Order in lemma idealHeight_eq_coheight (R : CommRingCat) (x : Spec R) : x.asIdeal.height = coheight x := by - rw [Ideal.height_eq_primeHeight x.asIdeal, Ideal.primeHeight, + rw [PrimeSpectrum.height_eq_orderHeight, ← Order.coheight_orderIso (specOrderIsoPrimeSpectrum R), ← height_ofDual, specOrderIsoPrimeSpectrum_apply, OrderDual.ofDual_toDual] - rfl open Order in @[stacks 02IZ] diff --git a/Mathlib/AlgebraicGeometry/Pullbacks.lean b/Mathlib/AlgebraicGeometry/Pullbacks.lean index a78cb1086037af..a6e1ef33885911 100644 --- a/Mathlib/AlgebraicGeometry/Pullbacks.lean +++ b/Mathlib/AlgebraicGeometry/Pullbacks.lean @@ -605,7 +605,7 @@ lemma _root_.AlgebraicGeometry.Scheme.isPullback_of_openCover (lift fWX fWY h) f := by rw [← IsPullback.paste_vert_iff this.flip (by ext <;> simp [f])] simpa using .of_hasPullback _ _ - convert (inferInstance : IsIso (H'.isoPullback.inv ≫ (H i).isoPullback.hom)) + convert! (inferInstance : IsIso (H'.isoPullback.inv ≫ (H i).isoPullback.hom)) aesop (add simp [Iso.eq_inv_comp, Scheme.Cover.pullbackHom]) exact MorphismProperty.of_zeroHypercover_target (P := .isomorphisms Scheme) (Scheme.Pullback.openCoverOfLeft 𝒰 fXZ fYZ) H₁ diff --git a/Mathlib/AlgebraicGeometry/QuasiAffine.lean b/Mathlib/AlgebraicGeometry/QuasiAffine.lean index b90fc50db99ff3..c31781fe196c03 100644 --- a/Mathlib/AlgebraicGeometry/QuasiAffine.lean +++ b/Mathlib/AlgebraicGeometry/QuasiAffine.lean @@ -65,7 +65,7 @@ lemma IsQuasiAffine.isBasis_basicOpen (X : Scheme.{u}) [IsQuasiAffine X] : refine ⟨_, ⟨r, ?_, rfl⟩, hxr, (Set.preimage_mono hrU).trans_eq (Set.preimage_image_eq _ X.toSpecΓ.isEmbedding.injective)⟩ rw [← Hom.isAffineOpen_iff_of_isOpenImmersion X.toSpecΓ] - convert IsAffineOpen.Spec_basicOpen r + convert! IsAffineOpen.Spec_basicOpen r exact SetLike.coe_injective (Set.image_preimage_eq_of_subset (hrU.trans (Set.image_subset_range _ _))) @@ -84,7 +84,7 @@ lemma IsQuasiAffine.of_forall_exists_mem_basicOpen (X : Scheme.{u}) [CompactSpac obtain ⟨r, hr, hxr⟩ := H x refine ⟨PrimeSpectrum.basicOpen r, (X.toSpecΓ_preimage_basicOpen r).ge hxr, ?_⟩ suffices IsOpenImmersion ((X.basicOpen r).ι ≫ X.toSpecΓ) by - convert this <;> rw [toSpecΓ_preimage_basicOpen] + convert! this <;> rw [toSpecΓ_preimage_basicOpen] rw [← Opens.toSpecΓ_SpecMap_presheaf_map_top] have := isLocalization_basicOpen_of_qcqs isCompact_univ isQuasiSeparated_univ r exact MorphismProperty.comp_mem _ hr.isoSpec.hom _ inferInstance (.of_isLocalization r) diff --git a/Mathlib/AlgebraicGeometry/Restrict.lean b/Mathlib/AlgebraicGeometry/Restrict.lean index 4af3250749b579..b19efafbf58c6f 100644 --- a/Mathlib/AlgebraicGeometry/Restrict.lean +++ b/Mathlib/AlgebraicGeometry/Restrict.lean @@ -168,7 +168,7 @@ lemma stalkIso_inv {X : Scheme.{u}} (U : X.Opens) (x : U) : apply TopCat.Presheaf.stalk_hom_ext intro W hxW simp only [Category.comp_id, U.germ_stalkIso_hom_assoc] - convert (Scheme.Hom.germ_stalkMap U.ι (U.ι ''ᵁ W) x ⟨_, hxW, rfl⟩).symm + convert! (Scheme.Hom.germ_stalkMap U.ι (U.ι ''ᵁ W) x ⟨_, hxW, rfl⟩).symm refine (U.toScheme.presheaf.germ_res (homOfLE ?_) _ _).symm exact (Set.preimage_image_eq _ Subtype.val_injective).le @@ -380,6 +380,23 @@ lemma Scheme.Hom.isoImage_inv_ι (f.isoImage U).inv ≫ U.ι ≫ f = (f ''ᵁ U).ι := IsOpenImmersion.isoOfRangeEq_inv_fac _ _ _ +@[reassoc] +lemma Scheme.Hom.isoImage_hom_homOfLE + {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] (U V : Opens X) (e : U ≤ V) : + (f.isoImage U).hom ≫ Y.homOfLE (f.image_mono e) = X.homOfLE e ≫ (f.isoImage V).hom := by + simp [← cancel_mono (f ''ᵁ V).ι] + +@[reassoc] +lemma Scheme.Hom.isoImage_inv_homOfLE + {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] (U V : Opens X) (e : U ≤ V) : + (f.isoImage U).inv ≫ X.homOfLE e = Y.homOfLE (f.image_mono e) ≫ (f.isoImage V).inv := by + simp [← cancel_mono (f.isoImage V).hom, ← f.isoImage_hom_homOfLE] + +@[reassoc (attr := simp)] +lemma Scheme.Opens.isoImage_ι_inv_ι {X : Scheme.{u}} (U : Opens X) (V : Opens U) : + (U.ι.isoImage V).inv ≫ V.ι = X.homOfLE (U.ι_image_le V) := by + simp [← cancel_mono U.ι] + /-- If `f : X ⟶ Y` is an open immersion, then `X` is isomorphic to its image in `Y`. -/ def Scheme.Hom.isoOpensRange {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] : X ≅ f.opensRange := @@ -577,6 +594,17 @@ theorem morphismRestrict_comp {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) ( pullbackRestrictIsoRestrict_inv_fst_assoc] rfl +@[reassoc] +theorem morphismRestrict_homOfLE {X Y : Scheme.{u}} (f : X ⟶ Y) (U V : Y.Opens) (e : U ≤ V) : + (f ∣_ U) ≫ Y.homOfLE e = X.homOfLE (f.preimage_mono e) ≫ (f ∣_ V) := by + simp [← cancel_mono V.ι] + +@[reassoc (attr := simp)] +lemma Scheme.Hom.isoImage_preimage_hom_homOfLE {X Y : Scheme.{u}} (f : X ⟶ Y) [IsOpenImmersion f] + (U : Y.Opens) : + (f.isoImage (f ⁻¹ᵁ U)).hom ≫ Y.homOfLE (f.image_preimage_le U) = f ∣_ U := by + simp [← cancel_mono U.ι] + instance {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso f] (U : Y.Opens) : IsIso (f ∣_ U) := by delta morphismRestrict; infer_instance @@ -622,6 +650,20 @@ theorem morphismRestrict_appLE {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (V rw [Scheme.Hom.appLE, morphismRestrict_app', Scheme.Opens.toScheme_presheaf_map, Scheme.Hom.appLE_map] +@[reassoc] +theorem morphismRestrict_homOfLE_isoImage_ι_hom + {X : Scheme.{u}} {U V : X.Opens} (e : U ≤ V) (W : Opens V) : + X.homOfLE e ∣_ W ≫ (V.ι.isoImage W).hom = + (U.ι.isoImage (X.homOfLE e ⁻¹ᵁ W)).hom ≫ X.homOfLE (X.ι_image_homOfLE_le_ι_image e W) := by + simp [← cancel_mono (V.ι ''ᵁ W).ι] + +@[reassoc] +theorem isoImage_ι_inv_morphismRestrict_homOfLE {X : Scheme.{u}} {U V : X.Opens} + (e : U ≤ V) (W : Opens V) : + (U.ι.isoImage (X.homOfLE e ⁻¹ᵁ W)).inv ≫ X.homOfLE e ∣_ W = + X.homOfLE (X.ι_image_homOfLE_le_ι_image e W) ≫ (V.ι.isoImage W).inv := by + simp [← cancel_mono (V.ι.isoImage W).hom, morphismRestrict_homOfLE_isoImage_ι_hom] + set_option backward.isDefEq.respectTransparency false in /-- Restricting a morphism onto the image of an open immersion is isomorphic to the base change along the immersion. -/ @@ -647,17 +689,27 @@ def morphismRestrictEq {X Y : Scheme.{u}} (f : X ⟶ Y) {U V : Y.Opens} (e : U = Arrow.mk (f ∣_ U) ≅ Arrow.mk (f ∣_ V) := eqToIso (by subst e; rfl) +@[reassoc] +lemma morphismRestrict_ι_image_ι_isoImage_inv + {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (V : U.toScheme.Opens) : + f ∣_ U.ι ''ᵁ V ≫ (U.ι.isoImage V).inv = (X.homOfLE (image_morphismRestrict_preimage f U V).ge ≫ + ((f ⁻¹ᵁ U).ι.isoImage ((f ∣_ U) ⁻¹ᵁ V)).inv) ≫ f ∣_ U ∣_ V := by + simp [← cancel_mono (Scheme.Opens.ι _)] + +@[reassoc] +lemma morphismRestrict_morphismRestrict_ι_isoImage_hom + {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (V : U.toScheme.Opens) : + f ∣_ U ∣_ V ≫ (U.ι.isoImage V).hom = (((f ⁻¹ᵁ U).ι.isoImage ((f ∣_ U) ⁻¹ᵁ V)).hom ≫ + X.homOfLE (image_morphismRestrict_preimage f U V).le) ≫ f ∣_ U.ι ''ᵁ V := by + simp [← cancel_mono (Scheme.Opens.ι _)] + /-- Restricting a morphism twice is isomorphic to one restriction. -/ def morphismRestrictRestrict {X Y : Scheme.{u}} (f : X ⟶ Y) (U : Y.Opens) (V : U.toScheme.Opens) : Arrow.mk (f ∣_ U ∣_ V) ≅ Arrow.mk (f ∣_ U.ι ''ᵁ V) := by refine Arrow.isoMk' _ _ ((Scheme.Opens.ι _).isoImage _ ≪≫ Scheme.isoOfEq _ ?_) ((Scheme.Opens.ι _).isoImage _) ?_ · exact image_morphismRestrict_preimage f U V - · rw [← cancel_mono (Scheme.Opens.ι _), Iso.trans_hom, Category.assoc, Category.assoc, - Category.assoc, morphismRestrict_ι, Scheme.isoOfEq_hom_ι_assoc, - Scheme.Hom.isoImage_hom_ι_assoc, - Scheme.Hom.isoImage_hom_ι, - morphismRestrict_ι_assoc, morphismRestrict_ι] + · simp [← cancel_mono (Scheme.Opens.ι _)] set_option backward.isDefEq.respectTransparency false in /-- Restricting a morphism twice onto a basic open set is isomorphic to one restriction. -/ diff --git a/Mathlib/AlgebraicGeometry/Scheme.lean b/Mathlib/AlgebraicGeometry/Scheme.lean index b4f0a2c51f3453..b5b8a5122dd60b 100644 --- a/Mathlib/AlgebraicGeometry/Scheme.lean +++ b/Mathlib/AlgebraicGeometry/Scheme.lean @@ -449,7 +449,7 @@ def copyBase {X Y : Scheme} (f : X.Hom Y) (g : X → Y) (h : f.base = g) : X ⟶ c := f.c ≫ (TopCat.Presheaf.pushforwardEq (by subst h; rfl) _).hom prop x := by subst h - convert f.prop x using 4 + convert! f.prop x using 4 cat_disch lemma copyBase_eq {X Y : Scheme} (f : X.Hom Y) (g : X → Y) (h : f.base = g) : @@ -862,7 +862,7 @@ theorem basicOpen_eq_of_affine {R : CommRingCat} (f : R) : @[simp] theorem basicOpen_eq_of_affine' {R : CommRingCat} (f : Γ(Spec R, ⊤)) : (Spec R).basicOpen f = PrimeSpectrum.basicOpen ((Scheme.ΓSpecIso R).hom f) := by - convert basicOpen_eq_of_affine ((Scheme.ΓSpecIso R).hom f) + convert! basicOpen_eq_of_affine ((Scheme.ΓSpecIso R).hom f) exact (Iso.hom_inv_id_apply (Scheme.ΓSpecIso R) f).symm set_option backward.isDefEq.respectTransparency false in @@ -913,7 +913,7 @@ theorem Spec_zeroLocus_eq_zeroLocus {R : CommRingCat} (s : Set R) : theorem Spec_zeroLocus {R : CommRingCat} (s : Set Γ(Spec R, ⊤)) : (Spec R).zeroLocus s = PrimeSpectrum.zeroLocus ((Scheme.ΓSpecIso R).inv ⁻¹' s) := by - convert Spec_zeroLocus_eq_zeroLocus ((Scheme.ΓSpecIso R).inv ⁻¹' s) + convert! Spec_zeroLocus_eq_zeroLocus ((Scheme.ΓSpecIso R).inv ⁻¹' s) rw [Set.image_preimage_eq] exact (ConcreteCategory.bijective_of_isIso (C := CommRingCat) _).2 section Stalks diff --git a/Mathlib/AlgebraicGeometry/Sites/BigZariski.lean b/Mathlib/AlgebraicGeometry/Sites/BigZariski.lean index 8e3567745f550a..ae82a05062643d 100644 --- a/Mathlib/AlgebraicGeometry/Sites/BigZariski.lean +++ b/Mathlib/AlgebraicGeometry/Sites/BigZariski.lean @@ -110,7 +110,7 @@ lemma preservesLimitsOfShape_discrete_of_isSheaf_zariskiTopology {F : Scheme.{u} refine Presieve.preservesProduct_of_isSheafFor F ?_ initialIsInitial (Sigma.cocone (Discrete.functor <| unop ∘ X)) (coproductIsCoproduct' _) ?_ ?_ · apply hF.isSheafFor - convert (⊥_ Scheme).bot_mem_grothendieckTopology + convert! (⊥_ Scheme).bot_mem_grothendieckTopology rw [eq_bot_iff] rintro Y f ⟨g, _, _, ⟨i⟩, _⟩ exact i.elim diff --git a/Mathlib/AlgebraicGeometry/Sites/Small.lean b/Mathlib/AlgebraicGeometry/Sites/Small.lean index 48e6a2ebd8e39a..05562694f4777b 100644 --- a/Mathlib/AlgebraicGeometry/Sites/Small.lean +++ b/Mathlib/AlgebraicGeometry/Sites/Small.lean @@ -93,8 +93,9 @@ def overPretopology : Pretopology (Over S) where rintro X _ T ⟨𝒰, h, rfl⟩ H choose V h hV using H refine ⟨𝒰.bind (fun j => V ((𝒰.f j).asOver S) ⟨j⟩), inferInstance, ?_⟩ - convert Presieve.ofArrows_bind _ (fun j ↦ (𝒰.f j).asOver S) _ - (fun Y f H j ↦ ((V f H).X j).asOver S) (fun Y f H j ↦ ((V f H).f j).asOver S) + convert! + Presieve.ofArrows_bind _ (fun j ↦ (𝒰.f j).asOver S) _ (fun Y f H j ↦ ((V f H).X j).asOver S) + (fun Y f H j ↦ ((V f H).f j).asOver S) apply hV /-- The topology on `Over S` induced from the topology on `Scheme` defined by `P`. @@ -196,9 +197,10 @@ def smallPretopology : Pretopology (Q.Over ⊤ S) where let 𝒱j (j : 𝒰.I₀) : (Cover (precoverage P) ((𝒰.X j).asOverProp S (p j)).left) := V ((𝒰.f j).asOverProp S) ⟨j⟩ refine ⟨𝒰.bind (fun j ↦ 𝒱j j), inferInstance, fun j ↦ pV _ _ _, ?_⟩ - convert Presieve.ofArrows_bind _ (fun j ↦ ((𝒰.f j).asOverProp S)) _ - (fun Y f H j ↦ ((V f H).X j).asOverProp S (pV _ _ _)) - (fun Y f H j ↦ ((V f H).f j).asOverProp S) + convert! + Presieve.ofArrows_bind _ (fun j ↦ ((𝒰.f j).asOverProp S)) _ + (fun Y f H j ↦ ((V f H).X j).asOverProp S (pV _ _ _)) + (fun Y f H j ↦ ((V f H).f j).asOverProp S) apply hV set_option backward.isDefEq.respectTransparency false in diff --git a/Mathlib/AlgebraicGeometry/Sites/SmallAffineZariski.lean b/Mathlib/AlgebraicGeometry/Sites/SmallAffineZariski.lean index 1e641cd065ca97..7e0512859ee737 100644 --- a/Mathlib/AlgebraicGeometry/Sites/SmallAffineZariski.lean +++ b/Mathlib/AlgebraicGeometry/Sites/SmallAffineZariski.lean @@ -355,12 +355,12 @@ noncomputable def isColimitCocone : IsColimit (cocone X) := (U.2.isoSpec.hom ≫ colimit.ι F U) <| by rw [Pullback.range_fst, Opens.range_ι, ← Hom.coe_opensRange, Hom.opensRange_comp_of_isIso, ← Scheme.Hom.coe_preimage] - convert congr($(D.toBase_preimage_eq_opensRange_ι U).1) + convert! congr($(D.toBase_preimage_eq_opensRange_ι U).1) · delta cocone congr with U simp [D, relativeGluingData, restrictIsoSpec] · simp - convert (inferInstance : IsIso e.hom) + convert! (inferInstance : IsIso e.hom) rw [← cancel_mono U.1.ι, ← Iso.inv_comp_eq] simp [e, ← pullback.condition, IsAffineOpen.isoSpec_hom] .ofPointIso (colimit.isColimit F) diff --git a/Mathlib/AlgebraicGeometry/Spec.lean b/Mathlib/AlgebraicGeometry/Spec.lean index e0efd2553c4ba5..e312d427ededc6 100644 --- a/Mathlib/AlgebraicGeometry/Spec.lean +++ b/Mathlib/AlgebraicGeometry/Spec.lean @@ -291,7 +291,7 @@ theorem Spec_Γ_naturality {R S : CommRingCat.{u}} (f : R ⟶ S) : @[simps! hom_app inv_app] def LocallyRingedSpace.SpecΓIdentity : Spec.toLocallyRingedSpace.rightOp ⋙ Γ ≅ 𝟭 _ := Iso.symm <| NatIso.ofComponents.{u, u, u + 1, u + 1} (fun R ↦ asIso (toSpecΓ R) :) - fun {X Y} f => by convert Spec_Γ_naturality (R := X) (S := Y) f + fun {X Y} f => by convert! Spec_Γ_naturality (R := X) (S := Y) f end SpecΓ diff --git a/Mathlib/AlgebraicGeometry/Stalk.lean b/Mathlib/AlgebraicGeometry/Stalk.lean index 15f6f4b03d7e74..72a527c40f8f2e 100644 --- a/Mathlib/AlgebraicGeometry/Stalk.lean +++ b/Mathlib/AlgebraicGeometry/Stalk.lean @@ -337,7 +337,7 @@ lemma stalkClosedPointTo_fromSpecStalk (x : X) : refine TopCat.Presheaf.stalk_hom_ext _ fun U hxU ↦ ?_ simp only [TopCat.Presheaf.stalkCongr_hom, TopCat.Presheaf.germ_stalkSpecializes] have : X.fromSpecStalk x = Spec.map (𝟙 (X.presheaf.stalk x)) ≫ X.fromSpecStalk x := by simp - convert germ_stalkClosedPointTo_Spec_fromSpecStalk (𝟙 (X.presheaf.stalk x)) U hxU + convert! germ_stalkClosedPointTo_Spec_fromSpecStalk (𝟙 (X.presheaf.stalk x)) U hxU @[reassoc] lemma Spec_stalkClosedPointTo_fromSpecStalk : diff --git a/Mathlib/AlgebraicGeometry/StructureSheaf.lean b/Mathlib/AlgebraicGeometry/StructureSheaf.lean index e299ee3e66f5da..053111c9e5155a 100644 --- a/Mathlib/AlgebraicGeometry/StructureSheaf.lean +++ b/Mathlib/AlgebraicGeometry/StructureSheaf.lean @@ -395,7 +395,7 @@ lemma isUnit_basicOpen_end (f : R) : have := (isUnit_basicOpen f).map (algebraMap _ (Module.End Γ(R, basicOpen f) Γ(M, basicOpen f))) rw [Module.End.isUnit_iff] at this ⊢ - convert this + convert! this ext a simp @@ -481,8 +481,8 @@ theorem exists_le_iSup_basicOpen_and_smul_eq_smul_and_eq_const have : n i j + 1 ≤ N := (t ×ˢ t).le_sup (f := fun x ↦ n x.1 x.2 + 1) (b := ⟨_, _⟩) (by simp) rw [← Nat.sub_add_cancel this, pow_add, mul_smul, mul_smul] congr 1 - convert (hn i j).symm using 1 <;> module - · convert congr((structureSheafInType R M).presheaf.map (homOfLE ?_).op $((H i).symm)) using 1 + convert! (hn i j).symm using 1 <;> module + · convert! congr((structureSheafInType R M).presheaf.map (homOfLE ?_).op $((H i).symm)) using 1 · refine Subtype.ext <| funext fun x ↦ LocalizedModule.mk_eq.mpr ⟨1, ?_⟩ simp [Submonoid.smul_def, pow_succ', mul_smul] · simp @@ -512,8 +512,9 @@ theorem toBasicOpenₗ_surjective (f : R) : Function.Surjective (toBasicOpenₗ ← Finset.sum_smul, hc] public instance (f : R) : IsLocalizedModule.Away f (toOpenₗ R M (basicOpen f)) := by - convert IsLocalizedModule.of_linearEquiv (.powers f) (LocalizedModule.mkLinearMap (.powers f) M) - (.ofBijective _ ⟨toBasicOpenₗ_injective _, toBasicOpenₗ_surjective _⟩) + convert! + IsLocalizedModule.of_linearEquiv (.powers f) (LocalizedModule.mkLinearMap (.powers f) M) + (.ofBijective _ ⟨toBasicOpenₗ_injective _, toBasicOpenₗ_surjective _⟩) ext x simp [toOpenₗ] @@ -524,7 +525,7 @@ instance isIso_toBasicOpenₗ (f : R) : set_option backward.isDefEq.respectTransparency false in public lemma toOpenₗ_top_bijective : Function.Bijective (toOpenₗ R M ⊤) := by have : IsLocalizedModule ⊥ (toOpenₗ R M ⊤) := by - convert (inferInstance : IsLocalizedModule (.powers 1) (toOpenₗ R M (basicOpen 1))) + convert! (inferInstance : IsLocalizedModule (.powers 1) (toOpenₗ R M (basicOpen 1))) rw [PrimeSpectrum.basicOpen_one, Submonoid.powers_one] refine ⟨fun x y e ↦ by simpa using (IsLocalizedModule.eq_iff_exists ⊥ _).mp e, fun x ↦ ?_⟩ obtain ⟨⟨x, _, rfl⟩, rfl⟩ := IsLocalizedModule.mk'_surjective ⊥ (toOpenₗ R M ⊤) x @@ -643,7 +644,7 @@ theorem toOpenₗ_germ (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top theorem isUnit_toStalk (x : PrimeSpectrum.Top R) (f : R) (hf : x ∈ basicOpen f) : IsUnit (toStalk R x f) := by - convert (isUnit_basicOpen f).map ((structurePresheafInCommRingCat R).germ _ x hf).hom + convert! (isUnit_basicOpen f).map ((structurePresheafInCommRingCat R).germ _ x hf).hom exact ((structurePresheafInCommRingCat R).germ_res_apply (homOfLE (le_top : basicOpen f ≤ ⊤)) x hf (algebraMap R Γ(R, ⊤) f)).symm @@ -653,7 +654,7 @@ theorem isUnit_toStalkₗ' (x : PrimeSpectrum.Top R) (f : R) (hf : x ∈ basicOp (Module.End ((structurePresheafInCommRingCat R).stalk x) ((structurePresheafInModuleCat R M).stalk x))) rw [Module.End.isUnit_iff] at this ⊢ - convert this + convert! this ext a simp only [Module.algebraMap_end_apply] rw [toStalk_smul] @@ -768,8 +769,9 @@ theorem localizationToStalk_stalkToFiberRingHom (x : PrimeSpectrum.Top R) : instance (x : PrimeSpectrum.Top R) : IsLocalizedModule x.asIdeal.primeCompl (toStalkₗ' R M x).hom := by - convert IsLocalizedModule.of_linearEquiv x.asIdeal.primeCompl - (LocalizedModule.mkLinearMap x.asIdeal.primeCompl M) (stalkIsoₗ R M x).toLinearEquiv.symm + convert! + IsLocalizedModule.of_linearEquiv x.asIdeal.primeCompl + (LocalizedModule.mkLinearMap x.asIdeal.primeCompl M) (stalkIsoₗ R M x).toLinearEquiv.symm ext m refine .trans ?_ (localizationtoStalkₗ_mk ..).symm dsimp +instances [toStalkₗ', toOpenₗ] @@ -795,8 +797,9 @@ def toStalkₗ (x : PrimeSpectrum.Top R) : public instance (x : PrimeSpectrum.Top R) : IsLocalizedModule x.asIdeal.primeCompl (toStalkₗ R M x) := by - convert IsLocalizedModule.of_linearEquiv x.asIdeal.primeCompl - (toStalkₗ' R M x).hom (modulePresheafStalkIso R M x).symm + convert! + IsLocalizedModule.of_linearEquiv x.asIdeal.primeCompl (toStalkₗ' R M x).hom + (modulePresheafStalkIso R M x).symm ext m let α : TopCat.Presheaf.stalk (moduleStructurePresheaf R M).presheaf x ≅ (forget₂ _ _).obj ((structurePresheafInModuleCat R M).stalk x) := @@ -846,8 +849,9 @@ def commRingCatStalkEquivModuleStalk (x : PrimeSpectrum.Top R) : public instance (x : PrimeSpectrum.Top R) : IsLocalization.AtPrime ((structurePresheafInCommRingCat R).stalk x) x.asIdeal := by refine (isLocalizedModule_iff_isLocalization' _ _).mp ?_ - convert IsLocalizedModule.of_linearEquiv x.asIdeal.primeCompl (toStalkₗ R R x) - (commRingCatStalkEquivModuleStalk R x) + convert! + IsLocalizedModule.of_linearEquiv x.asIdeal.primeCompl (toStalkₗ R R x) + (commRingCatStalkEquivModuleStalk R x) let α : TopCat.Presheaf.stalk (moduleStructurePresheaf R R).presheaf x ≅ (forget₂ CommRingCat RingCat ⋙ forget₂ RingCat AddCommGrpCat).obj ((structurePresheafInCommRingCat R).stalk x) := @@ -969,7 +973,7 @@ def Localizations.comapFun (y : PrimeSpectrum.Top S) : have := IsLocalizedModule.map_units (S := y.asIdeal.primeCompl) (LocalizedModule.mkLinearMap y.asIdeal.primeCompl N) ⟨σ x, x.2⟩ rw [Module.End.isUnit_iff] at this ⊢ - convert this using 2 with a + convert! this using 2 with a exact (IsScalarTower.algebraMap_smul ..).symm) { __ := g, map_smul' r x := by simpa [Localizations] using (IsScalarTower.algebraMap_smul ..).symm } diff --git a/Mathlib/AlgebraicGeometry/ZariskisMainTheorem.lean b/Mathlib/AlgebraicGeometry/ZariskisMainTheorem.lean index 43c1de99f1bc83..141410f5c3014c 100644 --- a/Mathlib/AlgebraicGeometry/ZariskisMainTheorem.lean +++ b/Mathlib/AlgebraicGeometry/ZariskisMainTheorem.lean @@ -103,14 +103,14 @@ theorem exists_etale_isCompl_of_quasiFiniteAt [IsSeparated f] refine ⟨Spec (.of R), Spec.map φ ≫ hU.fromSpec, inferInstance, ⟨⟨P, ‹_›⟩, ?_⟩, W₁, W₂, ⟨g ⟨P', ‹_›⟩, ?_⟩, ?_, ‹_›, ?_⟩ · dsimp [Spec.map_apply] - convert hU.fromSpec_primeIdealOf ⟨f x, hxU⟩ + convert! hU.fromSpec_primeIdealOf ⟨f x, hxU⟩ · exact PrimeSpectrum.ext (Ideal.over_def _ _).symm · simp [h] · exact ⟨⟨P', ‹_›⟩, heP', rfl⟩ · simp [isCompl_iff, disjoint_iff, codisjoint_iff, W₂, SetLike.ext'_iff] · trans hV.fromSpec ⟨P'.comap Algebra.TensorProduct.includeRight.toRingHom, inferInstance⟩ · simp [← Scheme.Hom.comp_apply, -Scheme.Hom.comp_base, g, reassoc_of% he₁]; rfl - convert hV.fromSpec_primeIdealOf ⟨x, hxV⟩ + convert! hV.fromSpec_primeIdealOf ⟨x, hxV⟩ variable {X Y S : Scheme.{u}} (f : X ⟶ Y) @@ -154,7 +154,7 @@ lemma Scheme.Hom.exists_mem_and_isIso_morphismRestrict_toNormalization · rw [← Scheme.Hom.inv_image, ← SetLike.coe_subset_coe] simpa [← Scheme.Hom.opensRange_comp, ι, e, Scheme.Hom.normalizationCoprodIso, Set.range_comp] using Set.subset_preimage_image _ _ - convert (inferInstance : IsIso (Scheme.isoOfEq _ Heq).hom) + convert! (inferInstance : IsIso (Scheme.isoOfEq _ Heq).hom) rw [Iso.comp_inv_eq, ← Iso.inv_comp_eq, ← cancel_mono (Scheme.Opens.ι _)] have : V.ι ≫ (H.coconePointUniqueUpToIso (colimit.isColimit _)).hom = coprod.inl := H.comp_coconePointUniqueUpToIso_hom _ ⟨.left⟩ @@ -214,7 +214,7 @@ lemma Scheme.Hom.exists_isIso_morphismRestrict_toNormalization ((morphismRestrictRestrict ..).symm ≪≫ morphismRestrictOpensRange ..)).mp ?_ have : Opens.ι _ ''ᵁ (𝒰.f x).opensRange = V x := by simp only [Opens.iSupOpenCover, 𝒰, ← opensRange_comp, homOfLE_ι, Opens.opensRange_ι] - convert hV x + convert! hV x refine ⟨⨆ x : { x | f.QuasiFiniteAt x }, V x, this, ?_⟩ ext x suffices (∃ i : { x | f.QuasiFiniteAt x }, toNormalization f x ∈ V i) ↔ f.QuasiFiniteAt x by @@ -265,7 +265,7 @@ lemma Scheme.Hom.exists_isIso_morphismRestrict_toNormalization have := (inferInstance : IsIso ((toNormalization f ∣_ V y).app (Scheme.homOfLE _ hrV).opensRange)) simp only [Opens.toScheme_presheaf_obj, app_eq_appLE, morphismRestrict_appLE] at this ⊢ - convert this <;> + convert! this <;> simp [Scheme.Hom.image_preimage_eq_opensRange_inf, -Scheme.preimage_basicOpen, f.toNormalization.preimage_mono, hrV, H] have : (f.appLE U W H).hom.QuasiFinite := by @@ -275,7 +275,7 @@ lemma Scheme.Hom.exists_isIso_morphismRestrict_toNormalization exact .of_isIntegral_of_finiteType (IsIntegralHom.isIntegral_app f.fromNormalization _ hU) ⟨r, (hU.preimage f.fromNormalization).isLocalization_basicOpen _⟩ this have hxU : f x ∈ U := by - convert show _ ∈ U from (normalization f).basicOpen_le _ hxV + convert! show _ ∈ U from (normalization f).basicOpen_le _ hxV rw [← Scheme.Hom.comp_apply, f.toNormalization_fromNormalization] refine .of_comp (g := (Y.presheaf.germ U _ hxU).hom) ?_ rw [← CommRingCat.hom_comp, f.germ_stalkMap, ← X.presheaf.germ_res (homOfLE H) _ hxV, @@ -321,8 +321,11 @@ lemma Scheme.Hom.mem_quasiFiniteLocus [LocallyOfFiniteType f] instance [LocallyOfFiniteType f] [IsSeparated f] [QuasiCompact f] : IsOpenImmersion (f.quasiFiniteLocus.ι ≫ f.toNormalization) := by obtain ⟨U, hU, e⟩ := Scheme.Hom.exists_isIso_morphismRestrict_toNormalization f - convert (inferInstance : IsOpenImmersion ((X.isoOfEq (U := f.quasiFiniteLocus) - (SetLike.coe_injective e.symm)).hom ≫ f.toNormalization ∣_ U ≫ U.ι)) using 1 + convert! + (inferInstance : + IsOpenImmersion + ((X.isoOfEq (U := f.quasiFiniteLocus) (SetLike.coe_injective e.symm)).hom ≫ + f.toNormalization ∣_ U ≫ U.ι)) using 1 simp lemma Scheme.Hom.quasiFiniteLocus_eq_top [LocallyQuasiFinite f] [LocallyOfFiniteType f] : @@ -351,8 +354,12 @@ instance [LocallyOfFiniteType f] : instance [LocallyQuasiFinite f] [LocallyOfFiniteType f] [IsSeparated f] [QuasiCompact f] : IsOpenImmersion f.toNormalization := by - convert (inferInstance : IsOpenImmersion (X.topIso.inv ≫ (X.isoOfEq - f.quasiFiniteLocus_eq_top).inv ≫ f.quasiFiniteLocus.ι ≫ f.toNormalization)) using 1 + convert! + (inferInstance : + IsOpenImmersion + (X.topIso.inv ≫ + (X.isoOfEq f.quasiFiniteLocus_eq_top).inv ≫ + f.quasiFiniteLocus.ι ≫ f.toNormalization)) using 1 simp -- In particular it is surjective (by infer_instance), since it is a priori dominant. diff --git a/Mathlib/AlgebraicTopology/CechNerve.lean b/Mathlib/AlgebraicTopology/CechNerve.lean index d38ac4b1d73a8d..a9fdcf1b7f7410 100644 --- a/Mathlib/AlgebraicTopology/CechNerve.lean +++ b/Mathlib/AlgebraicTopology/CechNerve.lean @@ -306,7 +306,7 @@ def cechConerveEquiv (F : Arrow C) (X : CosimplicialObject.Augmented C) : rw [WidePushout.ι_desc] nth_rw 2 [← Category.comp_id A.right] congr 1 - convert X.right.map_id _ + convert! X.right.map_id _ ext ⟨a, ha⟩ simp diff --git a/Mathlib/AlgebraicTopology/DoldKan/Faces.lean b/Mathlib/AlgebraicTopology/DoldKan/Faces.lean index 54107ab3f728b2..6cab6acea43b2e 100644 --- a/Mathlib/AlgebraicTopology/DoldKan/Faces.lean +++ b/Mathlib/AlgebraicTopology/DoldKan/Faces.lean @@ -80,7 +80,7 @@ theorem comp_Hσ_eq {Y : C} {n a q : ℕ} {φ : Y ⟶ X _⦋n + 1⦌} (v : Highe · rintro ⟨k, hk⟩ suffices φ ≫ X.δ (⟨a + 2 + k, by lia⟩ : Fin (n + 2)) = 0 by simp only [this, Fin.natAdd_mk, Fin.cast_mk, zero_comp, smul_zero] - convert v ⟨a + k + 1, by lia⟩ (by rw [Fin.val_mk]; lia) + convert! v ⟨a + k + 1, by lia⟩ (by rw [Fin.val_mk]; lia) dsimp lia -- cleaning up the second sum diff --git a/Mathlib/AlgebraicTopology/DoldKan/GammaCompN.lean b/Mathlib/AlgebraicTopology/DoldKan/GammaCompN.lean index 265f71c3d9cf6c..14a8c7741d4c01 100644 --- a/Mathlib/AlgebraicTopology/DoldKan/GammaCompN.lean +++ b/Mathlib/AlgebraicTopology/DoldKan/GammaCompN.lean @@ -144,7 +144,7 @@ lemma N₂Γ₂ToKaroubiIso_inv_app (X : ChainComplex C ℕ) : ext n dsimp [N₂Γ₂ToKaroubiIso] simp only [comp_id, PInfty_f_idem_assoc, AlternatingFaceMapComplex.obj_X, Γ₀_obj_obj] - convert comp_id _ + convert! comp_id _ apply (Γ₀.splitting X).hom_ext' intro A rw [Splitting.ι_desc] diff --git a/Mathlib/AlgebraicTopology/FundamentalGroupoid/InducedMaps.lean b/Mathlib/AlgebraicTopology/FundamentalGroupoid/InducedMaps.lean index 2c72338fb24bde..1ff39a0d918e88 100644 --- a/Mathlib/AlgebraicTopology/FundamentalGroupoid/InducedMaps.lean +++ b/Mathlib/AlgebraicTopology/FundamentalGroupoid/InducedMaps.lean @@ -155,10 +155,10 @@ theorem heq_path_of_eq_image : exact hfg set_option backward.privateInPublic true in -private theorem start_path : f x₀ = g x₂ := by convert hfg 0 <;> simp only [Path.source] +private theorem start_path : f x₀ = g x₂ := by convert! hfg 0 <;> simp only [Path.source] set_option backward.privateInPublic true in -private theorem end_path : f x₁ = g x₃ := by convert hfg 1 <;> simp only [Path.target] +private theorem end_path : f x₁ = g x₃ := by convert! hfg 1 <;> simp only [Path.target] set_option backward.isDefEq.respectTransparency false in set_option backward.privateInPublic true in diff --git a/Mathlib/AlgebraicTopology/FundamentalGroupoid/SimplyConnected.lean b/Mathlib/AlgebraicTopology/FundamentalGroupoid/SimplyConnected.lean index 0bf5739df1590b..25c8f97db9970d 100644 --- a/Mathlib/AlgebraicTopology/FundamentalGroupoid/SimplyConnected.lean +++ b/Mathlib/AlgebraicTopology/FundamentalGroupoid/SimplyConnected.lean @@ -94,7 +94,7 @@ theorem simply_connected_iff_paths_homotopic : theorem simply_connected_iff_paths_homotopic' : SimplyConnectedSpace Y ↔ PathConnectedSpace Y ∧ ∀ {x y : Y} (p₁ p₂ : Path x y), Path.Homotopic p₁ p₂ := by - convert simply_connected_iff_paths_homotopic (Y := Y) + convert! simply_connected_iff_paths_homotopic (Y := Y) simp [Path.Homotopic.Quotient, Setoid.eq_top_iff]; rfl set_option backward.isDefEq.respectTransparency false in diff --git a/Mathlib/AlgebraicTopology/ModelCategory/FundamentalLemma.lean b/Mathlib/AlgebraicTopology/ModelCategory/FundamentalLemma.lean index 9181514d9cff64..2c2e7570f012b7 100644 --- a/Mathlib/AlgebraicTopology/ModelCategory/FundamentalLemma.lean +++ b/Mathlib/AlgebraicTopology/ModelCategory/FundamentalLemma.lean @@ -77,7 +77,7 @@ lemma bijective_rightHomotopyClassToHom : (by rwa [← weakEquivalence_iff]) rw [← Function.Bijective.of_comp_iff _ (LeftHomotopyClass.postcomp_bijective_of_fibration_of_weakEquivalence _ p)] - convert (Iso.homCongr (Iso.refl (L.obj X)) (asIso (L.map p))).bijective.comp hY' + convert! (Iso.homCongr (Iso.refl (L.obj X)) (asIso (L.map p))).bijective.comp hY' ext f obtain ⟨f, rfl⟩ := f.mk_surjective simp @@ -91,7 +91,7 @@ lemma bijective_rightHomotopyClassToHom : (by rwa [← weakEquivalence_iff]) rw [← Function.Bijective.of_comp_iff _ (RightHomotopyClass.precomp_bijective_of_cofibration_of_weakEquivalence Y i)] - convert (Iso.homCongr (asIso (L.map i)) (Iso.refl (L.obj Y))).symm.bijective.comp hX' + convert! (Iso.homCongr (asIso (L.map i)) (Iso.refl (L.obj Y))).symm.bijective.comp hX' ext f obtain ⟨f, rfl⟩ := f.mk_surjective simp diff --git a/Mathlib/AlgebraicTopology/ModelCategory/Homotopy.lean b/Mathlib/AlgebraicTopology/ModelCategory/Homotopy.lean index a16d714f750d0f..6481743a905853 100644 --- a/Mathlib/AlgebraicTopology/ModelCategory/Homotopy.lean +++ b/Mathlib/AlgebraicTopology/ModelCategory/Homotopy.lean @@ -157,11 +157,11 @@ lemma postcomp_bijective_of_weakEquivalence have hi : Function.Bijective (fun (f : LeftHomotopyClass X Y) ↦ f.postcomp h.i) := by rw [← Function.Bijective.of_comp_iff' (postcomp_bijective_of_fibration_of_weakEquivalence X h.r)] - convert Function.bijective_id + convert! Function.bijective_id ext φ obtain ⟨φ, rfl⟩ := φ.mk_surjective simp - convert (postcomp_bijective_of_fibration_of_weakEquivalence X h.p).comp hi using 1 + convert! (postcomp_bijective_of_fibration_of_weakEquivalence X h.p).comp hi using 1 ext φ obtain ⟨φ, rfl⟩ := φ.mk_surjective simp @@ -204,11 +204,11 @@ lemma precomp_bijective_of_weakEquivalence have hj : Function.Bijective (fun (g : RightHomotopyClass Y Z) ↦ g.precomp h.p) := by rw [← Function.Bijective.of_comp_iff' (precomp_bijective_of_cofibration_of_weakEquivalence Z h.s)] - convert Function.bijective_id + convert! Function.bijective_id ext φ obtain ⟨φ, rfl⟩ := φ.mk_surjective simp - convert (precomp_bijective_of_cofibration_of_weakEquivalence Z h.i).comp hj using 1 + convert! (precomp_bijective_of_cofibration_of_weakEquivalence Z h.i).comp hj using 1 ext φ obtain ⟨φ, rfl⟩ := φ.mk_surjective simp diff --git a/Mathlib/AlgebraicTopology/ModelCategory/LeftHomotopy.lean b/Mathlib/AlgebraicTopology/ModelCategory/LeftHomotopy.lean index 896925077ca3f0..fa71f02f92b853 100644 --- a/Mathlib/AlgebraicTopology/ModelCategory/LeftHomotopy.lean +++ b/Mathlib/AlgebraicTopology/ModelCategory/LeftHomotopy.lean @@ -167,7 +167,7 @@ lemma exists_good_cylinder {f g : X ⟶ Y} (h : P.LeftHomotopy f g) : i₁ := coprod.inr ≫ d.i π := d.p ≫ P.π }, ⟨by rw [cofibration_iff] - convert d.hi + convert! d.hi aesop⟩, ⟨{ h := d.p ≫ h.h }⟩⟩ /-- The covering homotopy theorem: if `p : E ⟶ B` is a fibration, diff --git a/Mathlib/AlgebraicTopology/ModelCategory/RightHomotopy.lean b/Mathlib/AlgebraicTopology/ModelCategory/RightHomotopy.lean index 51b005600ec4f0..452c95a55f093c 100644 --- a/Mathlib/AlgebraicTopology/ModelCategory/RightHomotopy.lean +++ b/Mathlib/AlgebraicTopology/ModelCategory/RightHomotopy.lean @@ -170,7 +170,7 @@ lemma exists_good_pathObject {f g : X ⟶ Y} (h : P.RightHomotopy f g) : p₁ := d.p ≫ prod.snd ι := P.ι ≫ d.i }, ⟨by rw [fibration_iff] - convert d.hp + convert! d.hp aesop⟩, ⟨{ h := h.h ≫ d.i }⟩⟩ /-- The homotopy extension theorem: if `p : A ⟶ X` is a cofibration, diff --git a/Mathlib/AlgebraicTopology/Quasicategory/Basic.lean b/Mathlib/AlgebraicTopology/Quasicategory/Basic.lean index 3b21f50c23afec..98cbb7dbd1c4b4 100644 --- a/Mathlib/AlgebraicTopology/Quasicategory/Basic.lean +++ b/Mathlib/AlgebraicTopology/Quasicategory/Basic.lean @@ -44,14 +44,10 @@ class Quasicategory (S : SSet) : Prop where lemma Quasicategory.hornFilling {S : SSet} [Quasicategory S] ⦃n : ℕ⦄ ⦃i : Fin (n + 1)⦄ (h0 : 0 < i) (hn : i < Fin.last n) (σ₀ : (Λ[n, i] : SSet) ⟶ S) : ∃ σ : Δ[n] ⟶ S, σ₀ = Λ[n, i].ι ≫ σ := by - cases n using Nat.casesAuxOn with - | zero => simp [Fin.lt_def] at hn - | succ n => - cases n using Nat.casesAuxOn with - | zero => - simp only [Fin.lt_def, Fin.val_zero, Fin.val_last, zero_add, Nat.lt_one_iff] at h0 hn - simp [hn] at h0 - | succ n => exact Quasicategory.hornFilling' σ₀ h0 hn + match n with + | 0 + | 1 => lia + | n + 2 => exact Quasicategory.hornFilling' σ₀ h0 hn /-- Every Kan complex is a quasicategory. -/ @[kerodon 003C] diff --git a/Mathlib/AlgebraicTopology/SimplexCategory/Basic.lean b/Mathlib/AlgebraicTopology/SimplexCategory/Basic.lean index fae9a62b62afc5..4580b1d1ca244b 100644 --- a/Mathlib/AlgebraicTopology/SimplexCategory/Basic.lean +++ b/Mathlib/AlgebraicTopology/SimplexCategory/Basic.lean @@ -244,7 +244,7 @@ theorem δ_comp_δ {n} {i j : Fin (n + 2)} (H : i ≤ j) : theorem δ_comp_δ' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : i.castSucc < j) : δ i ≫ δ j = - δ (j.pred fun (hj : j = 0) => by simp [hj, Fin.not_lt_zero] at H) ≫ + δ (j.pred H.ne_zero) ≫ δ (Fin.castSucc i) := by rw [← δ_comp_δ] · rw [Fin.succ_pred] @@ -351,7 +351,7 @@ theorem δ_comp_σ_of_gt {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : j.castSucc @[reassoc] theorem δ_comp_σ_of_gt' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : j.succ < i) : δ i ≫ σ j = σ (j.castLT ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le H i.is_le))) ≫ - δ (i.pred fun (hi : i = 0) => by simp only [Fin.not_lt_zero, hi] at H) := by + δ (i.pred H.ne_zero) := by rw [← δ_comp_σ_of_gt] · simp · rw [Fin.castSucc_castLT, ← Fin.succ_lt_succ_iff, Fin.succ_pred] @@ -660,7 +660,7 @@ instance : (forget SimplexCategory).ReflectsIsomorphisms := by_cases h' : y₁ < y₂ · by_contra h'' apply not_le.mpr h' - convert f.toOrderHom.monotone (le_of_not_ge h'') + convert! f.toOrderHom.monotone (le_of_not_ge h'') all_goals exact (ConcreteCategory.congr_hom (Iso.inv_hom_id (asIso ((forget SimplexCategory).map f))) _).symm diff --git a/Mathlib/AlgebraicTopology/SimplexCategory/GeneratorsRelations/NormalForms.lean b/Mathlib/AlgebraicTopology/SimplexCategory/GeneratorsRelations/NormalForms.lean index 8059c66eb31537..ca7e85ec11cc33 100644 --- a/Mathlib/AlgebraicTopology/SimplexCategory/GeneratorsRelations/NormalForms.lean +++ b/Mathlib/AlgebraicTopology/SimplexCategory/GeneratorsRelations/NormalForms.lean @@ -278,7 +278,7 @@ lemma standardσ_simplicialInsert (hL : IsAdmissible (m + 1) L) (j : ℕ) (hj : · have : ∀ (j k : ℕ) (h : j < (k + 1)), Fin.ofNat (k + 1) j = j := by simp -- helps grind below have : a < m + 2 := by grind -- helps grind below have : σ (Fin.ofNat (m + 2) a) ≫ σ (.ofNat _ j) = σ (.ofNat _ (j + 1)) ≫ σ (.ofNat _ a) := by - convert σ_comp_σ_nat (n := m) a j (by grind) (by grind) (by grind) <;> grind + convert! σ_comp_σ_nat (n := m) a j (by grind) (by grind) (by grind) <;> grind grind [standardσ_cons] set_option backward.isDefEq.respectTransparency false in diff --git a/Mathlib/AlgebraicTopology/SimplicialObject/Basic.lean b/Mathlib/AlgebraicTopology/SimplicialObject/Basic.lean index 9e464896e985ff..8f864032e3a2e0 100644 --- a/Mathlib/AlgebraicTopology/SimplicialObject/Basic.lean +++ b/Mathlib/AlgebraicTopology/SimplicialObject/Basic.lean @@ -121,7 +121,7 @@ theorem δ_comp_δ {n} {i j : Fin (n + 2)} (H : i ≤ j) : theorem δ_comp_δ' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : Fin.castSucc i < j) : X.δ j ≫ X.δ i = X.δ (Fin.castSucc i) ≫ - X.δ (j.pred fun (hj : j = 0) => by simp [hj, Fin.not_lt_zero] at H) := by + X.δ (j.pred H.ne_zero) := by dsimp [δ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ' H] @[reassoc] @@ -185,7 +185,7 @@ theorem δ_comp_σ_of_gt {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : Fin.castSu @[reassoc] theorem δ_comp_σ_of_gt' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : j.succ < i) : X.σ j ≫ X.δ i = - X.δ (i.pred fun (hi : i = 0) => by simp only [Fin.not_lt_zero, hi] at H) ≫ + X.δ (i.pred H.ne_zero) ≫ X.σ (j.castLT ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le H i.is_le))) := by dsimp [δ, σ] simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_of_gt' H] @@ -586,7 +586,7 @@ theorem δ_comp_δ {n} {i j : Fin (n + 2)} (H : i ≤ j) : @[reassoc] theorem δ_comp_δ' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : Fin.castSucc i < j) : X.δ i ≫ X.δ j = - X.δ (j.pred fun (hj : j = 0) => by simp only [hj, Fin.not_lt_zero] at H) ≫ + X.δ (j.pred H.ne_zero) ≫ X.δ (Fin.castSucc i) := by dsimp [δ] simp only [← X.map_comp, SimplexCategory.δ_comp_δ' H] @@ -653,8 +653,7 @@ theorem δ_comp_σ_of_gt {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : Fin.castSu theorem δ_comp_σ_of_gt' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : j.succ < i) : X.δ i ≫ X.σ j = X.σ (j.castLT ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le H i.is_le))) ≫ - X.δ (i.pred <| - fun (hi : i = 0) => by simp only [Fin.not_lt_zero, hi] at H) := by + X.δ (i.pred H.ne_zero) := by dsimp [δ, σ] simp only [← X.map_comp, SimplexCategory.δ_comp_σ_of_gt' H] diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/PairingCore.lean b/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/PairingCore.lean index 8b7977f23d7e31..330a213011dbc3 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/PairingCore.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/PairingCore.lean @@ -166,6 +166,10 @@ lemma pairing_p_symm_equivI (x : h.ι) : DFunLike.coe (F := h.I ≃ h.II) h.pairing.p.symm (h.equivI x) = h.equivII x := by simp [pairing] +lemma type₁_pairing (x : h.ι) : + h.type₁ x = h.pairing.p (h.equivII x) := by + simp +instances + /-- The condition that `h : A.PairingCore` is proper, i.e. for each `s : h.ι`, the type (II) simplex `h.type₂ s` is uniquely a `1`-codimensional face of the type (I) simplex `h.type₁ s`. -/ @@ -183,6 +187,11 @@ instance [h.IsProper] : h.pairing.IsProper where obtain ⟨s, rfl⟩ := h.equivII.surjective x simpa using h.isUniquelyCodimOneFace s +lemma isProper_pairing_iff : + h.pairing.IsProper ↔ h.IsProper := by + refine ⟨fun _ ↦ ⟨fun s ↦ ?_⟩, fun _ ↦ inferInstance⟩ + simpa [type₁_pairing] using h.pairing.isUniquelyCodimOneFace (h.equivII s) + set_option backward.isDefEq.respectTransparency false in @[simp] lemma isUniquelyCodimOneFace_index [h.IsProper] (s : h.ι) : @@ -234,6 +243,18 @@ instance [h.IsRegular] : h.pairing.IsRegular where exact ⟨fun ⟨f, hf⟩ ↦ this.false ⟨fun n ↦ h.equivII.symm (f n), fun n ↦ by simpa [ancestralRel_iff] using hf n⟩⟩ +lemma isRegular_pairing_iff (h : A.PairingCore) : + h.pairing.IsRegular ↔ h.IsRegular := by + refine ⟨fun _ ↦ ?_, fun _ ↦ inferInstance⟩ + have : h.IsProper := by + rw [← isProper_pairing_iff] + infer_instance + constructor + have := h.pairing.wf + rw [wellFounded_iff_isEmpty_descending_chain] at this ⊢ + exact ⟨fun ⟨f, hf⟩ ↦ this.false + ⟨fun n ↦ h.equivII (f n), fun n ↦ by simpa [ancestralRel_iff] using hf n⟩⟩ + end PairingCore end SSet.Subcomplex diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/Rank.lean b/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/Rank.lean index 974207b6f56ab2..28299b8bd37ccd 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/Rank.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/Rank.lean @@ -166,6 +166,16 @@ noncomputable def weakRankFunctionEquiv : left_inv _ := by simp right_inv _ := by simp +variable {h α} [WellFoundedLT α] + +lemma RankFunction.isRegular [h.IsProper] (f : h.RankFunction α) : h.IsRegular := by + rw [← isRegular_pairing_iff] + exact (h.rankFunctionEquiv α f).isRegular + +lemma WeakRankFunction.isRegular [h.IsProper] (f : h.WeakRankFunction α) : h.IsRegular := by + rw [← isRegular_pairing_iff] + exact (h.weakRankFunctionEquiv α f).isRegular + end PairingCore end SSet.Subcomplex diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/RankNat.lean b/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/RankNat.lean index cc30af680937c8..fe5a68c55b9ffc 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/RankNat.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/RankNat.lean @@ -23,9 +23,13 @@ universe u open Simplicial -namespace SSet.Subcomplex.Pairing +namespace SSet.Subcomplex -variable {X : SSet.{u}} {A : X.Subcomplex} (P : A.Pairing) +variable {X : SSet.{u}} {A : X.Subcomplex} + +namespace Pairing + +variable (P : A.Pairing) instance (y : P.II) : Finite { x // P.AncestralRel x y } := by let T := { x : P.II // P.AncestralRel x y } @@ -94,4 +98,22 @@ lemma isRegular_iff_nonempty_weakRankFunction [P.IsProper] : P.IsRegular ↔ Nonempty (P.WeakRankFunction ℕ) := ⟨fun _ ↦ inferInstance, fun ⟨h⟩ ↦ h.isRegular⟩ -end SSet.Subcomplex.Pairing +end Pairing + +namespace PairingCore + +variable (P : A.PairingCore) + +lemma isRegular_iff_nonempty_rankFunction [P.IsProper] : + P.IsRegular ↔ Nonempty (P.RankFunction ℕ) := by + rw [← isRegular_pairing_iff, Pairing.isRegular_iff_nonempty_rankFunction] + exact (P.rankFunctionEquiv ℕ).symm.nonempty_congr + +lemma isRegular_iff_nonempty_weakRankFunction [P.IsProper] : + P.IsRegular ↔ Nonempty (P.WeakRankFunction ℕ) := by + rw [← isRegular_pairing_iff, Pairing.isRegular_iff_nonempty_weakRankFunction] + exact (P.weakRankFunctionEquiv ℕ).symm.nonempty_congr + +end PairingCore + +end SSet.Subcomplex diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/Basic.lean b/Mathlib/AlgebraicTopology/SimplicialSet/Basic.lean index 5738073ea7d012..29e480f1da8453 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/Basic.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/Basic.lean @@ -200,7 +200,7 @@ lemma δ_comp_δ_apply {n} {i j : Fin (n + 2)} (H : i ≤ j) (x : S _⦋n + 2⦌ lemma δ_comp_δ'_apply {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : Fin.castSucc i < j) (x : S _⦋n + 2⦌) : S.δ i (S.δ j x) = - S.δ (j.pred fun (hj : j = 0) => by simp [hj, Fin.not_lt_zero] at H) (S.δ i.castSucc x) := + S.δ (j.pred H.ne_zero) (S.δ i.castSucc x) := congr_hom (S.δ_comp_δ' H) x lemma δ_comp_δ''_apply {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : i ≤ Fin.castSucc j) @@ -239,7 +239,7 @@ lemma δ_comp_σ_of_gt_apply {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : Fin.ca lemma δ_comp_σ_of_gt'_apply {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : j.succ < i) (x : S _⦋n + 1⦌) : S.δ i (S.σ j x) = S.σ (j.castLT ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le H i.is_le))) - (S.δ (i.pred fun (hi : i = 0) => by simp only [Fin.not_lt_zero, hi] at H) x) := + (S.δ (i.pred H.ne_zero) x) := congr_hom (S.δ_comp_σ_of_gt' H) x lemma σ_comp_σ_apply {n} {i j : Fin (n + 1)} (H : i ≤ j) (x : S _⦋n⦌) : diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/HomotopyCat.lean b/Mathlib/AlgebraicTopology/SimplicialSet/HomotopyCat.lean index 8e961857e5c6b9..06fa48920be456 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/HomotopyCat.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/HomotopyCat.lean @@ -363,7 +363,7 @@ def lift : V.HomotopyCategory ⥤ D := (Cat.FreeRefl.lift' obj (fun f ↦ map f) map_id) (by rintro _ _ _ _ ⟨h⟩ simp only [Functor.map_comp] - convert map_comp h <;> apply Cat.FreeRefl.lift'_map) + convert! map_comp h <;> apply Cat.FreeRefl.lift'_map) @[simp] lemma lift_obj_mk (x : V _⦋0⦌₂) : (lift obj map map_id map_comp).obj (mk x) = obj x := rfl diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/HornColimits.lean b/Mathlib/AlgebraicTopology/SimplicialSet/HornColimits.lean index 300aab948d5c2e..ad417247be5419 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/HornColimits.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/HornColimits.lean @@ -275,15 +275,15 @@ def desc.multicofork : fin_cases x · simp only [← cancel_epi (stdSimplex.facePairIso.{u} (n := 3) 1 3 (by simp)).hom, ← Category.assoc] - convert h₁₃ <;> decide + convert! h₁₃ <;> decide · dsimp simp only [← cancel_epi (stdSimplex.facePairIso.{u} (n := 3) 1 2 (by simp)).hom, ← Category.assoc] - convert h₁₂ <;> decide + convert! h₁₂ <;> decide · dsimp simp only [← cancel_epi (stdSimplex.facePairIso.{u} (n := 3) 0 1 (by simp)).hom, ← Category.assoc] - convert h₂₃ <;> decide) + convert! h₂₃ <;> decide) @[simp, reassoc] lemma desc.multicofork_π_zero : @@ -362,15 +362,15 @@ def desc.multicofork : · dsimp simp only [← cancel_epi (stdSimplex.facePairIso.{u} (n := 3) 2 3 (by simp)).hom, ← Category.assoc] - convert h₂₃ <;> decide + convert! h₂₃ <;> decide · dsimp simp only [← cancel_epi (stdSimplex.facePairIso.{u} (n := 3) 1 2 (by simp)).hom, ← Category.assoc] - convert h₁₂ <;> decide + convert! h₁₂ <;> decide · dsimp simp only [← cancel_epi (stdSimplex.facePairIso.{u} (n := 3) 0 2 (by simp)).hom, ← Category.assoc] - convert h₀₂ <;> decide) + convert! h₀₂ <;> decide) @[simp, reassoc] lemma desc.multicofork_π_zero : diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/Nerve.lean b/Mathlib/AlgebraicTopology/SimplicialSet/Nerve.lean index 1734cd5bf1dbfa..7a3fdd012330a8 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/Nerve.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/Nerve.lean @@ -234,7 +234,7 @@ lemma homEquiv_comp {x₀ x₁ x₂ : ComposableArrows C 0} obtain ⟨f₀₁, rfl⟩ := edgeMk_surjective e₀₁ obtain ⟨f₁₂, rfl⟩ := edgeMk_surjective e₁₂ obtain ⟨f₀₂, rfl⟩ := edgeMk_surjective e₀₂ - convert (nerve.nonempty_compStruct_iff _ _ _).1 ⟨h⟩ <;> apply homEquiv_edgeMk + convert! (nerve.nonempty_compStruct_iff _ _ _).1 ⟨h⟩ <;> apply homEquiv_edgeMk set_option backward.isDefEq.respectTransparency false in lemma σ_zero_nerveEquiv_symm (x : C) : diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/Nonsingular.lean b/Mathlib/AlgebraicTopology/SimplicialSet/Nonsingular.lean new file mode 100644 index 00000000000000..50bb14b9e13fba --- /dev/null +++ b/Mathlib/AlgebraicTopology/SimplicialSet/Nonsingular.lean @@ -0,0 +1,107 @@ +/- +Copyright (c) 2026 Joël Riou. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Joël Riou, Robin Carlier, Christian Merten +-/ +module + +public import Mathlib.AlgebraicTopology.SimplicialSet.ProdStdSimplex + +/-! +# Nonsingular simplicial sets + +In this file, we introduce a typeclass `SSet.Nonsingular` for a +simplicial set `X : SSet`: it says that for any non-degenerate simplex +`x : X _⦋n⦌`, the corresponding morphism `Δ[n] ⟶ X` is a monomorphism. +This notion is useful in the context of the study of the subdivision +functor (TODO @joelriou). + +The condition `SSet.Nonsingular` is a weaker condition compared +to the notion of "polyhedral complex" which appears in the article +*Simplicial approximation* by Jardine, and which says that there +exists a monomorphism `X ⟶ nerve T` where `T` is a partially ordered type. + +## References +* [Vegard Fjellbo and John Rognes, + *Exponentials of non-singular simplicial sets*][fjellbo-rognes-2022] +* [J. F. Jardine, *Simplicial approximation*][jardine-2004] + +-/ + +public section + +universe u + +open CategoryTheory MonoidalCategory Simplicial + +namespace SSet + +variable {X Y : SSet.{u}} + +variable (X) in +/-- A simplicial set `X` is nonsingular if for any +nondegenerate simplex `x` (of dimension `n`), the corresponding +morphism `Δ[n] ⟶ X` is a monomorphism. -/ +@[kerodon 02MG] +class Nonsingular where + mono {n : ℕ} (x : X.nonDegenerate n) : Mono (yonedaEquiv.symm x.val) + +attribute [instance] Nonsingular.mono + +lemma Nonsingular.mono' [X.Nonsingular] + {n : ℕ} (x : X _⦋n⦌) (hx : x ∈ X.nonDegenerate n) : + Mono (yonedaEquiv.symm x) := mono ⟨x, hx⟩ + +@[kerodon 02MK] +lemma Nonsingular.of_mono (f : X ⟶ Y) [Mono f] [Y.Nonsingular] : + X.Nonsingular where + mono := by + intro n ⟨x, hx⟩ + rw [← nonDegenerate_iff_of_mono f] at hx + have := mono' _ hx + rw [← SSet.yonedaEquiv_symm_comp] at this + exact mono_of_mono _ f + +lemma Nonsingular.of_iso (e : X ≅ Y) [X.Nonsingular] : Y.Nonsingular := + .of_mono e.inv + +instance (A : X.Subcomplex) [X.Nonsingular] : (A : SSet).Nonsingular := + .of_mono A.ι + +@[kerodon 02MT] +instance (T : Type*) [PartialOrder T] : (nerve T).Nonsingular where + mono := by + intro n ⟨x, hx⟩ + rw [PartialOrder.mem_nerve_nonDegenerate_iff_injective] at hx + simp only [NatTrans.mono_iff_mono_app, mono_iff_injective] + intro ⟨⟨k⟩⟩ i j hij + ext l : 1 + exact hx (Functor.congr_obj hij l) + +instance (n : SimplexCategory) : (stdSimplex.{u}.obj n).Nonsingular := + Nonsingular.of_iso (stdSimplex.isoNerve _).symm + +instance (n m : SimplexCategory) : + (stdSimplex.{u}.obj n ⊗ stdSimplex.obj m).Nonsingular := + Nonsingular.of_iso (prodStdSimplex.isoNerve _ _).symm + +@[kerodon 02MH] +lemma nonDegenerate_δ [X.Nonsingular] + {n : ℕ} {x : X _⦋n + 1⦌} (hx : x ∈ X.nonDegenerate _) (i : Fin (n + 2)) : + X.δ i x ∈ X.nonDegenerate _ := by + have := Nonsingular.mono' x hx + have : X.δ i x = (yonedaEquiv.symm x).app _ + (stdSimplex.objEquiv.symm (SimplexCategory.δ i)) := rfl + rw [this, nonDegenerate_iff_of_mono, stdSimplex.mem_nonDegenerate_iff_mono, + Equiv.apply_symm_apply] + infer_instance + +lemma Nonsingular.δ_injective [X.Nonsingular] + {n : ℕ} (x : X _⦋n + 1⦌) (hx : x ∈ X.nonDegenerate _) + (i j : Fin (n + 2)) (hij : X.δ i x = X.δ j x) : i = j := by + apply SimplexCategory.δ_injective + apply stdSimplex.objEquiv.symm.injective + have := mono' x hx + exact injective_of_mono ((yonedaEquiv.symm x).app _) hij + +end SSet diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/Path.lean b/Mathlib/AlgebraicTopology/SimplicialSet/Path.lean index d8653e1ddc3406..234a2939fa28db 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/Path.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/Path.lean @@ -373,7 +373,7 @@ def horn.spineId {n : ℕ} (i : Fin (n + 3)) (h₀ : 0 < i) (hₙ : i < Fin.last (n + 2)) : Path (Λ[n + 2, i] : SSet.{u}) (n + 2) := Λ[n + 2, i].liftPath (stdSimplex.spineId (n + 2)) (by simp) (fun j ↦ by - convert (horn.primitiveEdge.{u} h₀ hₙ j).2 + convert! (horn.primitiveEdge.{u} h₀ hₙ j).2 ext a fin_cases a <;> rfl) diff --git a/Mathlib/AlgebraicTopology/SimplicialSet/StrictSegal.lean b/Mathlib/AlgebraicTopology/SimplicialSet/StrictSegal.lean index 5e2e0a06875543..ce9df0560ff8c1 100644 --- a/Mathlib/AlgebraicTopology/SimplicialSet/StrictSegal.lean +++ b/Mathlib/AlgebraicTopology/SimplicialSet/StrictSegal.lean @@ -166,7 +166,7 @@ theorem spineToSimplex_interval (f : Path X m) (j l : ℕ) (hjl : j + l ≤ m) : apply sx.spineInjective l dsimp only [spineEquiv, Equiv.coe_fn_mk] rw [spine_spineToSimplex_apply] - convert spine_map_subinterval X m h j l hjl <| sx.spineToSimplex m h f + convert! spine_map_subinterval X m h j l hjl <| sx.spineToSimplex m h f exact sx.spine_spineToSimplex_apply m h f |>.symm theorem spineToSimplex_edge (f : Path X m) (j l : ℕ) (hjl : j + l ≤ m) : diff --git a/Mathlib/Analysis/Analytic/Basic.lean b/Mathlib/Analysis/Analytic/Basic.lean index 1cd0e0a022d2d3..bd5e66693eb5a2 100644 --- a/Mathlib/Analysis/Analytic/Basic.lean +++ b/Mathlib/Analysis/Analytic/Basic.lean @@ -157,7 +157,7 @@ theorem HasFPowerSeriesOnBall.comp_sub (hf : HasFPowerSeriesOnBall f p x r) (y : { r_le := hf.r_le r_pos := hf.r_pos hasSum := fun {z} hz => by - convert hf.hasSum hz using 2 + convert! hf.hasSum hz using 2 abel } theorem HasFPowerSeriesWithinOnBall.comp_sub (hf : HasFPowerSeriesWithinOnBall f p s x r) (y : E) : @@ -169,7 +169,7 @@ theorem HasFPowerSeriesWithinOnBall.comp_sub (hf : HasFPowerSeriesWithinOnBall f simp only [add_singleton, image_add_right, mem_insert_iff, add_eq_left, mem_preimage] at hz1 ⊢ abel_nf at hz1 assumption - convert hf.hasSum this hz2 using 2 + convert! hf.hasSum this hz2 using 2 abel theorem HasFPowerSeriesAt.comp_sub (hf : HasFPowerSeriesAt f p x) (y : E) : @@ -192,7 +192,7 @@ theorem AnalyticOnNhd.comp_sub (hf : AnalyticOnNhd 𝕜 f s) (y : E) : intro x hx simp only [add_singleton, image_add_right, mem_preimage] at hx rw [show x = (x - y) + y by abel] - apply (hf (x - y) (by convert hx using 1; abel)).comp_sub + apply (hf (x - y) (by convert! hx using 1; abel)).comp_sub theorem AnalyticWithinAt.comp_sub (hf : AnalyticWithinAt 𝕜 f s x) (y : E) : AnalyticWithinAt 𝕜 (fun z ↦ f (z - y)) (s + {y}) (x + y) := by @@ -204,7 +204,7 @@ theorem AnalyticOn.comp_sub (hf : AnalyticOn 𝕜 f s) (y : E) : intro x hx simp only [add_singleton, image_add_right, mem_preimage] at hx rw [show x = (x - y) + y by abel] - apply (hf (x - y) (by convert hx using 1; abel)).comp_sub + apply (hf (x - y) (by convert! hx using 1; abel)).comp_sub theorem HasFPowerSeriesWithinOnBall.hasSum_sub (hf : HasFPowerSeriesWithinOnBall f p s x r) {y : E} (hy : y ∈ (insert x s) ∩ Metric.eball x r) : @@ -243,7 +243,7 @@ lemma HasFPowerSeriesWithinOnBall.congr {f g : E → F} {p : FormalMultilinearSe HasFPowerSeriesWithinOnBall g p s x r := by refine ⟨h.r_le, h.r_pos, ?_⟩ intro y hy h'y - convert h.hasSum hy h'y using 1 + convert! h.hasSum hy h'y using 1 simp only [mem_insert_iff, add_eq_left] at hy rcases hy with rfl | hy · simpa using h'' @@ -258,7 +258,7 @@ lemma HasFPowerSeriesWithinOnBall.congr' {f g : E → F} {p : FormalMultilinearS (h' : EqOn g f (insert x s ∩ Metric.eball x r)) : HasFPowerSeriesWithinOnBall g p s x r := by refine ⟨h.r_le, h.r_pos, fun {y} hy h'y ↦ ?_⟩ - convert h.hasSum hy h'y using 1 + convert! h.hasSum hy h'y using 1 exact h' ⟨hy, by simpa [edist_eq_enorm_sub] using h'y⟩ lemma HasFPowerSeriesWithinAt.congr {f g : E → F} {p : FormalMultilinearSeries 𝕜 E F} {s : Set E} @@ -279,7 +279,7 @@ theorem HasFPowerSeriesOnBall.congr (hf : HasFPowerSeriesOnBall f p x r) { r_le := hf.r_le r_pos := hf.r_pos hasSum := fun {y} hy => by - convert hf.hasSum hy using 1 + convert! hf.hasSum hy using 1 apply hg.symm simpa [edist_eq_enorm_sub] using hy } @@ -798,8 +798,9 @@ theorem HasFPowerSeriesWithinOnBall.isBigO_image_sub_image_sub_deriv_principal exact Metric.eball_subset_eball hr.le hy' set A : ℕ → F := fun n => (p n fun _ => y.1 - x) - p n fun _ => y.2 - x have hA : HasSum (fun n => A (n + 2)) (f y.1 - f y.2 - p 1 fun _ => y.1 - y.2) := by - convert (hasSum_nat_add_iff' 2).2 - ((hf.hasSum_sub ⟨ys.1, hy.1⟩).sub (hf.hasSum_sub ⟨ys.2, hy.2⟩)) using 1 + convert! + (hasSum_nat_add_iff' 2).2 + ((hf.hasSum_sub ⟨ys.1, hy.1⟩).sub (hf.hasSum_sub ⟨ys.2, hy.2⟩)) using 1 rw [Finset.sum_range_succ, Finset.sum_range_one, hf.coeff_zero, hf.coeff_zero, sub_self, zero_add, ← Subsingleton.pi_single_eq (0 : Fin 1) (y.1 - x), Pi.single, ← Subsingleton.pi_single_eq (0 : Fin 1) (y.2 - x), Pi.single, ← (p 1).map_update_sub, @@ -953,7 +954,7 @@ theorem HasFPowerSeriesWithinOnBall.tendstoUniformlyOn' {r' : ℝ≥0} (hf : HasFPowerSeriesWithinOnBall f p s x r) (h : (r' : ℝ≥0∞) < r) : TendstoUniformlyOn (fun n y => p.partialSum n (y - x)) f atTop (insert x s ∩ Metric.ball (x : E) r') := by - convert (hf.tendstoUniformlyOn h).comp fun y => y - x using 1 + convert! (hf.tendstoUniformlyOn h).comp fun y => y - x using 1 · simp [Function.comp_def] · ext z simp [dist_eq_norm] @@ -975,7 +976,7 @@ theorem HasFPowerSeriesWithinOnBall.tendstoLocallyUniformlyOn' TendstoLocallyUniformlyOn (fun n y => p.partialSum n (y - x)) f atTop (insert x s ∩ Metric.eball (x : E) r) := by have A : ContinuousOn (fun y : E => y - x) (insert x s ∩ Metric.eball (x : E) r) := by fun_prop - convert hf.tendstoLocallyUniformlyOn.comp (fun y : E => y - x) _ A using 1 + convert! hf.tendstoLocallyUniformlyOn.comp (fun y : E => y - x) _ A using 1 · ext z simp · intro z @@ -1115,7 +1116,7 @@ theorem hasFPowerSeriesAt_iff : have : (‖z‖₊ : ENNReal) ≤ p.radius := by simp only [dist_zero_right] at h apply FormalMultilinearSeries.le_radius_of_tendsto - convert tendsto_norm.comp (h le_z).summable.tendsto_atTop_zero + convert! tendsto_norm.comp (h le_z).summable.tendsto_atTop_zero simp [norm_smul, mul_comm] refine lt_of_lt_of_le ?_ this simp only [ENNReal.coe_pos] diff --git a/Mathlib/Analysis/Analytic/Binomial.lean b/Mathlib/Analysis/Analytic/Binomial.lean index 7688f92d8ac58c..f4abdc9dea8ee1 100644 --- a/Mathlib/Analysis/Analytic/Binomial.lean +++ b/Mathlib/Analysis/Analytic/Binomial.lean @@ -102,7 +102,7 @@ theorem one_add_cpow_hasFPowerSeriesOnBall_zero {a : ℂ} : HasFPowerSeriesOnBall (fun x ↦ (1 + x) ^ a) (binomialSeries ℂ a) 0 1 := by suffices (binomialSeries ℂ a = FormalMultilinearSeries.ofScalars ℂ fun n ↦ iteratedDeriv n (fun (x : ℂ) ↦ (1 + x) ^ a) 0 / n !) by - convert AnalyticOn.hasFPowerSeriesOnSubball _ _ _ + convert! AnalyticOn.hasFPowerSeriesOnSubball _ _ _ · norm_num · -- TODO: use `fun_prop` for this subgoal apply AnalyticOn.cpow (analyticOn_const.add analyticOn_id) analyticOn_const @@ -171,7 +171,7 @@ theorem one_div_one_sub_cpow_hasFPowerSeriesOnBall_zero (a : ℂ) : theorem one_div_one_sub_pow_hasFPowerSeriesOnBall_zero (a : ℕ) : HasFPowerSeriesOnBall (fun x ↦ 1 / (1 - x) ^ (a + 1)) (.ofScalars ℂ (𝕜 := ℂ) fun n ↦ ↑(Nat.choose (a + n) a)) 0 1 := by - convert one_div_one_sub_cpow_hasFPowerSeriesOnBall_zero (a + 1) using 3 with z n + convert! one_div_one_sub_cpow_hasFPowerSeriesOnBall_zero (a + 1) using 3 with z n · norm_cast · rw [eq_comm, add_right_comm, add_sub_cancel_right, ← Nat.cast_add, Ring.choose_natCast, Nat.choose_symm_add] @@ -184,7 +184,7 @@ theorem one_div_sub_pow_hasFPowerSeriesOnBall_zero (a : ℕ) {z : ℂ} (hz : z have := this.compContinuousLinearMap have H : 1 / ‖(z⁻¹ • 1 : ℂ →L[ℂ] ℂ)‖ₑ = ‖z‖ₑ := by simp [enorm_smul, enorm_inv, hz] simp only [one_div, ContinuousLinearMap.coe_smul', H, Function.comp_def] at this - convert (this.const_smul (c := (z ^ (a + 1))⁻¹)).congr ?_ using 2 + convert! (this.const_smul (c := (z ^ (a + 1))⁻¹)).congr ?_ using 2 · ext n simp only [FormalMultilinearSeries.smul_apply, ContinuousMultilinearMap.smul_apply, FormalMultilinearSeries.compContinuousLinearMap_apply] @@ -213,8 +213,9 @@ theorem one_div_one_sub_sq_hasFPowerSeriesOnBall_zero : theorem hasFPowerSeriesOnBall_ofScalars_mul_add_zero (a b : ℂ) : HasFPowerSeriesOnBall (fun x ↦ (b - a) / (1 - x) + a / (1 - x) ^ 2) (.ofScalars ℂ fun n ↦ a * n + b) 0 1 := by - convert (one_div_one_sub_hasFPowerSeriesOnBall_zero.const_smul (c := b - a)).add - (one_div_one_sub_sq_hasFPowerSeriesOnBall_zero.const_smul (c := a)) using 2 + convert! + (one_div_one_sub_hasFPowerSeriesOnBall_zero.const_smul (c := b - a)).add + (one_div_one_sub_sq_hasFPowerSeriesOnBall_zero.const_smul (c := a)) using 2 · simp [div_eq_mul_inv] · ext; simp; ring @@ -226,7 +227,7 @@ lemma one_div_sub_sq_sub_one_div_sq_hasFPowerSeriesOnBall_zero (w x : ℂ) (hw : · simpa only [sub_sub_sub_cancel_right, zero_add, sub_sq_comm w, zpow_neg, zpow_natCast, mul_comm] using (one_div_sub_sq_hasFPowerSeriesOnBall_zero (z := w - x) (by simp [sub_eq_zero, hw])).comp_sub x - · convert hasFPowerSeriesOnBall_const.mono _ le_top + · convert! hasFPowerSeriesOnBall_const.mono _ le_top · ext (_ | _) <;> simp [zpow_ofNat] · simpa [sub_eq_zero] @@ -241,7 +242,7 @@ theorem one_add_rpow_hasFPowerSeriesOnBall_zero {a : ℝ} : have H : binomialSeries ℂ a = (binomialSeries ℂ (a : ℂ)).restrictScalars (𝕜 := ℝ) := by aesop have : HasFPowerSeriesOnBall (fun x ↦ (1 + x) ^ (a : ℂ)) (binomialSeries ℂ a) (.ofRealCLM 0) 1 := Complex.ofRealCLM.map_zero ▸ H ▸ Complex.one_add_cpow_hasFPowerSeriesOnBall_zero.restrictScalars - convert (Complex.reCLM.comp_hasFPowerSeriesOnBall this.compContinuousLinearMap).congr ?_ + convert! (Complex.reCLM.comp_hasFPowerSeriesOnBall this.compContinuousLinearMap).congr ?_ · ext; simp [Function.comp_def] · simp · intro x hx; simp_all; norm_cast @@ -261,7 +262,7 @@ theorem one_div_one_sub_rpow_hasFPowerSeriesOnBall_zero (a : ℝ) : (.ofScalars ℝ fun n ↦ Ring.choose (a + n - 1) n) 0 1 := by have := (Complex.one_div_one_sub_cpow_hasFPowerSeriesOnBall_zero a).restrictScalars (𝕜 := ℝ) rw [← Complex.ofRealCLM.map_zero] at this - convert (Complex.reCLM.comp_hasFPowerSeriesOnBall this.compContinuousLinearMap).congr ?_ using 1 + convert! (Complex.reCLM.comp_hasFPowerSeriesOnBall this.compContinuousLinearMap).congr ?_ using 1 · ext n simp only [ContinuousLinearMap.compFormalMultilinearSeries_apply, ContinuousLinearMap.compContinuousMultilinearMap_coe, Function.comp_apply, @@ -280,7 +281,7 @@ theorem one_div_sub_pow_hasFPowerSeriesOnBall_zero (a : ℕ) {r : ℝ} (hr : r have := (Complex.one_div_sub_pow_hasFPowerSeriesOnBall_zero a (z := r) (by simpa)).restrictScalars (𝕜 := ℝ) rw [← Complex.ofRealCLM.map_zero] at this - convert (Complex.reCLM.comp_hasFPowerSeriesOnBall this.compContinuousLinearMap) using 2 + convert! (Complex.reCLM.comp_hasFPowerSeriesOnBall this.compContinuousLinearMap) using 2 · simp [-Complex.inv_re, ← Complex.ofReal_pow, ← Complex.ofReal_inv, ← Complex.ofReal_sub] · ext n simp only [ContinuousLinearMap.compFormalMultilinearSeries_apply, @@ -310,8 +311,9 @@ theorem one_div_one_sub_sq_hasFPowerSeriesOnBall_zero : theorem hasFPowerSeriesOnBall_ofScalars_mul_add_zero (a b : ℝ) : HasFPowerSeriesOnBall (fun x ↦ (b - a) / (1 - x) + a / (1 - x) ^ 2) (.ofScalars ℝ (a * · + b)) 0 1 := by - convert (one_div_one_sub_hasFPowerSeriesOnBall_zero.const_smul (c := b - a)).add - (one_div_one_sub_sq_hasFPowerSeriesOnBall_zero.const_smul (c := a)) using 2 + convert! + (one_div_one_sub_hasFPowerSeriesOnBall_zero.const_smul (c := b - a)).add + (one_div_one_sub_sq_hasFPowerSeriesOnBall_zero.const_smul (c := a)) using 2 · simp [div_eq_mul_inv] · ext; simp; ring diff --git a/Mathlib/Analysis/Analytic/CPolynomialDef.lean b/Mathlib/Analysis/Analytic/CPolynomialDef.lean index b70ae678d0d476..bd2d56420786ae 100644 --- a/Mathlib/Analysis/Analytic/CPolynomialDef.lean +++ b/Mathlib/Analysis/Analytic/CPolynomialDef.lean @@ -243,7 +243,7 @@ theorem HasFiniteFPowerSeriesOnBall.bound_zero_of_eq_zero (hf : ∀ y ∈ Metric exact le_top · intro y hy rw [hf (x + y)] - · convert hasSum_zero + · convert! hasSum_zero rw [hp, ContinuousMultilinearMap.zero_apply] · rwa [Metric.mem_eball, edist_eq_enorm_sub, add_comm, add_sub_cancel_right, ← edist_zero_right, ← Metric.mem_eball] diff --git a/Mathlib/Analysis/Analytic/Composition.lean b/Mathlib/Analysis/Analytic/Composition.lean index e67f66be85f999..2e5c85c799cb8a 100644 --- a/Mathlib/Analysis/Analytic/Composition.lean +++ b/Mathlib/Analysis/Analytic/Composition.lean @@ -121,7 +121,7 @@ theorem applyComposition_single (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} refine p.congr (by simp) fun i hi1 hi2 => ?_ dsimp congr 1 - convert Composition.single_embedding hn ⟨i, hi2⟩ using 1 + convert! Composition.single_embedding hn ⟨i, hi2⟩ using 1 obtain ⟨j_val, j_property⟩ := j have : j_val = 0 := le_bot_iff.1 (Nat.lt_succ_iff.1 j_property) rw! [this] @@ -151,7 +151,7 @@ theorem applyComposition_update (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} let j' := c.invEmbedding j suffices B : Function.update v j z ∘ r = Function.update (v ∘ r) j' z by rw [B] suffices C : Function.update v (r j') z ∘ r = Function.update (v ∘ r) j' z by - convert C; exact (c.embedding_comp_inv j).symm + convert! C; exact (c.embedding_comp_inv j).symm exact Function.update_comp_eq_of_injective _ (c.embedding _).injective _ _ · simp only [h, Function.update_of_ne, Ne, not_false_iff] let r : Fin (c.blocksFun k) → Fin n := c.embedding k @@ -386,7 +386,7 @@ theorem comp_id (p : FormalMultilinearSeries 𝕜 E F) (x : E) : p.comp (id 𝕜 obtain ⟨i, hi⟩ : ∃ (i : Fin b.blocks.length), b.blocks[i] = k := List.get_of_mem hk let j : Fin b.length := ⟨i.val, b.blocks_length ▸ i.prop⟩ - have A : 1 < b.blocksFun j := by convert lt_k + have A : 1 < b.blocksFun j := by convert! lt_k ext v rw [compAlongComposition_apply, ContinuousMultilinearMap.zero_apply] apply ContinuousMultilinearMap.map_coord_zero _ j @@ -485,10 +485,10 @@ theorem comp_summable_nnreal (q : FormalMultilinearSeries 𝕜 F G) (p : FormalM refine Summable.mul_left _ ?_ have : ∀ n : ℕ, HasSum (fun c : Composition n => (4 ^ n : ℝ≥0)⁻¹) (2 ^ (n - 1) / 4 ^ n) := by intro n - convert hasSum_fintype fun c : Composition n => (4 ^ n : ℝ≥0)⁻¹ + convert! hasSum_fintype fun c : Composition n => (4 ^ n : ℝ≥0)⁻¹ simp [Finset.card_univ, composition_card, div_eq_mul_inv] refine NNReal.summable_sigma.2 ⟨fun n => (this n).summable, (NNReal.summable_nat_add_iff 1).1 ?_⟩ - convert (NNReal.summable_geometric (NNReal.div_lt_one_of_lt one_lt_two)).mul_left (1 / 4) using 1 + convert! (NNReal.summable_geometric (NNReal.div_lt_one_of_lt one_lt_two)).mul_left (1 / 4) using 1 ext1 n rw [(this _).tsum_eq, add_tsub_cancel_right] simp [field, pow_succ, mul_pow, show (4 : ℝ≥0) = 2 * 2 by norm_num] @@ -1164,7 +1164,7 @@ theorem sizeUpTo_sizeUpTo_add (a : Composition n) (b : Composition a.length) {i | succ j IHj => have A : j < blocksFun b ⟨i, hi⟩ := lt_trans (lt_add_one j) hj have B : j < length (sigmaCompositionAux a b ⟨i, (length_gather a b).symm ▸ hi⟩) := by - convert A; rw [← length_sigmaCompositionAux] + convert! A; rw [← length_sigmaCompositionAux] have C : sizeUpTo b i + j < sizeUpTo b (i + 1) := by simp only [sizeUpTo_succ b hi, add_lt_add_iff_left] exact A diff --git a/Mathlib/Analysis/Analytic/Constructions.lean b/Mathlib/Analysis/Analytic/Constructions.lean index b0d3cf783d3c00..b1b63381419934 100644 --- a/Mathlib/Analysis/Analytic/Constructions.lean +++ b/Mathlib/Analysis/Analytic/Constructions.lean @@ -794,8 +794,9 @@ lemma formalMultilinearSeries_geometric_apply_norm [NormOneClass A] (n : ℕ) : lemma one_le_formalMultilinearSeries_geometric_radius : 1 ≤ (formalMultilinearSeries_geometric 𝕜 A).radius := by - convert formalMultilinearSeries_geometric_eq_ofScalars 𝕜 A ▸ - FormalMultilinearSeries.inv_le_ofScalars_radius_of_tendsto A _ one_ne_zero (by simp) + convert! + formalMultilinearSeries_geometric_eq_ofScalars 𝕜 A ▸ + FormalMultilinearSeries.inv_le_ofScalars_radius_of_tendsto A _ one_ne_zero (by simp) simp lemma formalMultilinearSeries_geometric_radius [NormOneClass A] : @@ -829,7 +830,7 @@ analytic at any unit. -/ lemma analyticAt_inverse [HasSummableGeomSeries A] (z : Aˣ) : AnalyticAt 𝕜 Ring.inverse (z : A) := by rcases subsingleton_or_nontrivial A with hA | hA - · convert analyticAt_const (v := (0 : A)) + · convert! analyticAt_const (v := (0 : A)) · let f1 : A → A := fun a ↦ a * z.inv let f2 : A → A := fun b ↦ (1 - b)⁻¹ʳ let f3 : A → A := fun c ↦ 1 - z.inv * c @@ -862,7 +863,7 @@ lemma analyticOnNhd_inverse [HasSummableGeomSeries A] : variable (𝕜 𝕝) in lemma hasFPowerSeriesOnBall_inv_one_sub : HasFPowerSeriesOnBall (fun x : 𝕝 ↦ (1 - x)⁻¹) (formalMultilinearSeries_geometric 𝕜 𝕝) 0 1 := by - convert hasFPowerSeriesOnBall_inverse_one_sub 𝕜 𝕝 + convert! hasFPowerSeriesOnBall_inverse_one_sub 𝕜 𝕝 exact Ring.inverse_eq_inv'.symm variable (𝕝) in @@ -874,7 +875,7 @@ lemma analyticAt_inv_one_sub : AnalyticAt 𝕜 (fun x : 𝕝 ↦ (1 - x)⁻¹) 0 away from 0. -/ @[fun_prop] lemma analyticAt_inv {z : 𝕝} (hz : z ≠ 0) : AnalyticAt 𝕜 Inv.inv z := by - convert analyticAt_inverse (𝕜 := 𝕜) (Units.mk0 _ hz) + convert! analyticAt_inverse (𝕜 := 𝕜) (Units.mk0 _ hz) exact Ring.inverse_eq_inv'.symm /-- `x⁻¹` is analytic away from zero -/ @@ -1064,7 +1065,7 @@ theorem Finset.analyticWithinAt_fun_prod {A : Type*} [NormedCommRing A] [NormedA theorem Finset.analyticWithinAt_prod {A : Type*} [NormedCommRing A] [NormedAlgebra 𝕜 A] {f : α → E → A} {c : E} {s : Set E} (N : Finset α) (h : ∀ n ∈ N, AnalyticWithinAt 𝕜 (f n) s c) : AnalyticWithinAt 𝕜 (∏ n ∈ N, f n) s c := by - convert N.analyticWithinAt_fun_prod h + convert! N.analyticWithinAt_fun_prod h simp /-- Finite products of analytic functions are analytic -/ @@ -1080,7 +1081,7 @@ theorem Finset.analyticAt_fun_prod {A : Type*} [NormedCommRing A] [NormedAlgebra theorem Finset.analyticAt_prod {α : Type*} {A : Type*} [NormedCommRing A] [NormedAlgebra 𝕜 A] {f : α → E → A} {c : E} (N : Finset α) (h : ∀ n ∈ N, AnalyticAt 𝕜 (f n) c) : AnalyticAt 𝕜 (∏ n ∈ N, f n) c := by - convert N.analyticAt_fun_prod h + convert! N.analyticAt_fun_prod h simp /-- Finite products of analytic functions are analytic -/ @@ -1181,7 +1182,7 @@ theorem HasFPowerSeriesWithinOnBall.compContinuousLinearMap simp only [ENNReal.div_pos_iff, ne_eq, enorm_ne_top, not_false_eq_true, and_true] exact pos_iff_ne_zero.mp hf.r_pos hasSum hy1 hy2 := by - convert hf.hasSum _ _ + convert! hf.hasSum _ _ · simp · simp only [Set.mem_insert_iff, add_eq_left, Set.mem_preimage, map_add] at hy1 ⊢ rcases hy1 with (hy1 | hy1) <;> simp [hy1] diff --git a/Mathlib/Analysis/Analytic/ConvergenceRadius.lean b/Mathlib/Analysis/Analytic/ConvergenceRadius.lean index 06d1363bb19a8e..2419d517f62cd4 100644 --- a/Mathlib/Analysis/Analytic/ConvergenceRadius.lean +++ b/Mathlib/Analysis/Analytic/ConvergenceRadius.lean @@ -377,7 +377,7 @@ theorem radius_compContinuousLinearMap_linearIsometryEquiv_eq [Nontrivial E] (p.compContinuousLinearMap u.toLinearIsometry.toContinuousLinearMap).radius = p.radius := by refine le_antisymm ?_ <| le_radius_compContinuousLinearMap _ _ have _ : Nontrivial F := u.symm.toEquiv.nontrivial - convert radius_compContinuousLinearMap_le p u.toContinuousLinearEquiv + convert! radius_compContinuousLinearMap_le p u.toContinuousLinearEquiv have : u.toContinuousLinearEquiv.symm.toContinuousLinearMap = u.symm.toLinearIsometry.toContinuousLinearMap := rfl simp [this] diff --git a/Mathlib/Analysis/Analytic/Inverse.lean b/Mathlib/Analysis/Analytic/Inverse.lean index 83e61eff0ea51c..21921fa95cb22d 100644 --- a/Mathlib/Analysis/Analytic/Inverse.lean +++ b/Mathlib/Analysis/Analytic/Inverse.lean @@ -135,13 +135,12 @@ theorem leftInv_comp (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (p.leftInv i x c.length) (p.applyComposition c v) := by simp only [leftInv, ContinuousMultilinearMap.neg_apply, neg_inj, ContinuousMultilinearMap.sum_apply] - convert - (sum_toFinset_eq_subtype - (fun c : Composition (n + 2) => c.length < n + 2) - (fun c : Composition (n + 2) => - (ContinuousMultilinearMap.compAlongComposition - (p.compContinuousLinearMap (i.symm : F →L[𝕜] E)) c (p.leftInv i x c.length)) - fun j : Fin (n + 2) => p 1 fun _ : Fin 1 => v j)).symm.trans + convert! + (sum_toFinset_eq_subtype (fun c : Composition (n + 2) => c.length < n + 2) + (fun c : Composition (n + 2) => + (ContinuousMultilinearMap.compAlongComposition + (p.compContinuousLinearMap (i.symm : F →L[𝕜] E)) c (p.leftInv i x c.length)) + fun j : Fin (n + 2) => p 1 fun _ : Fin 1 => v j)).symm.trans _ simp only [compContinuousLinearMap_applyComposition, ContinuousMultilinearMap.compAlongComposition_apply] @@ -642,7 +641,7 @@ lemma HasFPowerSeriesAt.eventually_hasSum_of_comp {f : E → F} {g : F → G} (partialSum_continuous q a).continuousAt apply this.tendsto.comp apply Tendsto.sub h'y - convert tendsto_const_nhds + convert! tendsto_const_nhds exact (HasFPowerSeriesAt.coeff_zero hf fun _ ↦ 0).symm apply u_closed.mem_of_tendsto this filter_upwards [Ici_mem_atTop b₀] with b hb using vu (hab _ _ ha hb) diff --git a/Mathlib/Analysis/Analytic/IsolatedZeros.lean b/Mathlib/Analysis/Analytic/IsolatedZeros.lean index 1d2c07aa36a4bf..5c111cc646b8e4 100644 --- a/Mathlib/Analysis/Analytic/IsolatedZeros.lean +++ b/Mathlib/Analysis/Analytic/IsolatedZeros.lean @@ -52,7 +52,7 @@ namespace HasSum variable {a : ℕ → E} theorem hasSum_at_zero (a : ℕ → E) : HasSum (fun n => (0 : 𝕜) ^ n • a n) (a 0) := by - convert hasSum_single (α := E) 0 fun b h ↦ _ <;> simp [*] + convert! hasSum_single (α := E) 0 fun b h ↦ _ <;> simp [*] theorem exists_hasSum_smul_of_apply_eq_zero (hs : HasSum (fun m => z ^ m • a m) s) (ha : ∀ k < n, a k = 0) : ∃ t : E, z ^ n • t = s ∧ HasSum (fun m => z ^ m • a (m + n)) t := by @@ -66,7 +66,7 @@ theorem exists_hasSum_smul_of_apply_eq_zero (hs : HasSum (fun m => z ^ m • a m Finset.sum_eq_zero fun k hk => by simp [ha k (Finset.mem_range.mp hk)] have h2 : HasSum (fun m => z ^ (m + n) • a (m + n)) s := by simpa [h1] using (hasSum_nat_add_iff' n).mpr hs - convert h2.const_smul (z⁻¹ ^ n) using 2 with x + convert! h2.const_smul (z⁻¹ ^ n) using 2 with x · match_scalars simp [field, pow_add] · simp only [inv_pow] @@ -82,7 +82,7 @@ theorem has_fpower_series_dslope_fslope (hp : HasFPowerSeriesAt f p z₀) : simp only [hasFPowerSeriesAt_iff, coeff_fslope] at hp ⊢ refine hp.mono fun x hx => ?_ by_cases h : x = 0 - · convert hasSum_single (α := E) 0 _ <;> intros <;> simp [*] + · convert! hasSum_single (α := E) 0 _ <;> intros <;> simp [*] · have hxx : ∀ n : ℕ, x⁻¹ * x ^ (n + 1) = x ^ n := fun n => by simp [field, _root_.pow_succ] suffices HasSum (fun n => x⁻¹ • x ^ (n + 1) • p.coeff (n + 1)) (x⁻¹ • (f (z₀ + x) - f z₀)) by simpa [dslope, slope, h, smul_smul, hxx] using this diff --git a/Mathlib/Analysis/Analytic/OfScalars.lean b/Mathlib/Analysis/Analytic/OfScalars.lean index 8f8ae97debe2ae..47d7b0d043060d 100644 --- a/Mathlib/Analysis/Analytic/OfScalars.lean +++ b/Mathlib/Analysis/Analytic/OfScalars.lean @@ -238,9 +238,9 @@ theorem ofScalars_radius_eq_of_tendsto [NormOneClass E] {r : NNReal} (hr : r ≠ (hc : Tendsto (fun n ↦ ‖c n‖ / ‖c n.succ‖) atTop (𝓝 r)) : (ofScalars E c).radius = ofNNReal r := by suffices Tendsto (fun n ↦ ‖c n.succ‖ / ‖c n‖) atTop (𝓝 r⁻¹) by - convert ofScalars_radius_eq_inv_of_tendsto E c (inv_ne_zero hr) this + convert! ofScalars_radius_eq_inv_of_tendsto E c (inv_ne_zero hr) this simp - convert hc.inv₀ (NNReal.coe_ne_zero.mpr hr) using 1 + convert! hc.inv₀ (NNReal.coe_ne_zero.mpr hr) using 1 simp /-- The ratio test stating that if `‖c n.succ‖ / ‖c n‖` tends to zero, the radius is unbounded. @@ -280,7 +280,7 @@ theorem ofScalars_radius_eq_zero_of_tendsto [NormOneClass E] · filter_upwards [hc.eventually_ge_atTop (2 * r⁻¹), eventually_ne_atTop 0] with n hc hn simp only [ofScalars_norm, norm_mul, norm_norm, norm_pow, NNReal.norm_eq] rw [mul_comm ‖c n‖, ← mul_assoc, ← div_le_div_iff₀, mul_div_assoc] - · convert hc + · convert! hc rw [pow_succ, div_mul_cancel_left₀, NNReal.coe_inv] aesop · simp_all @@ -317,7 +317,7 @@ theorem ofScalars_radius_eq_inv_of_tendsto_ENNReal [NormOneClass E] {r : ℝ≥0 simp_all · have hr' := toReal_ne_zero.mp hr.ne.symm have hr'' := toNNReal_ne_zero.mpr hr' -- this result could go in ENNReal - convert ofScalars_radius_eq_inv_of_tendsto E c hr'' ?_ + convert! ofScalars_radius_eq_inv_of_tendsto E c hr'' ?_ · simp [ENNReal.coe_inv hr'', ENNReal.coe_toNNReal (toReal_ne_zero.mp hr.ne.symm).2] · simp_rw [ENNReal.coe_toNNReal_eq_toReal] refine Tendsto.congr' ?_ <| (tendsto_toReal hr'.2).comp hc' diff --git a/Mathlib/Analysis/Analytic/Order.lean b/Mathlib/Analysis/Analytic/Order.lean index a740430c245744..18bd98441c364a 100644 --- a/Mathlib/Analysis/Analytic/Order.lean +++ b/Mathlib/Analysis/Analytic/Order.lean @@ -298,8 +298,8 @@ theorem AnalyticAt.analyticOrderAt_deriv_add_one {x : 𝕜} (hf : AnalyticAt · simp_rw [← Nat.cast_smul_eq_nsmul 𝕜] fun_prop rwa [← Pi.add_def, analyticOrderAt_add_eq_right_of_lt] - rw [this, ← Order.succ_le_iff_of_not_isMax (not_isMax_iff.mpr ⟨⊤, ENat.coe_lt_top s⟩), - ENat.succ_def, ← Nat.cast_add_one, natCast_le_analyticOrderAt (by fun_prop)] + rw [this, ← ENat.add_one_le_iff (ENat.coe_ne_top _), ← Nat.cast_add_one, + natCast_le_analyticOrderAt (by fun_prop)] exact ⟨deriv F, hFa.deriv, by simp⟩ theorem AnalyticAt.analyticOrderAt_sub_eq_one_of_deriv_ne_zero {x : 𝕜} (hf : AnalyticAt 𝕜 f x) @@ -385,7 +385,7 @@ lemma AnalyticAt.exists_eventuallyEq_sum_add_pow_mul [CharZero 𝕜] [CompleteSp (fun z : 𝕜 ↦ ∑ i ∈ .range n, (z ^ i / i.factorial) • iteratedDeriv i f 0) 0 := by refine Finset.analyticAt_fun_sum _ fun i hi ↦ ?_ fun_prop - convert (natCast_le_analyticOrderAt (hf.fun_sub this)).mp ?_ + convert! (natCast_le_analyticOrderAt (hf.fun_sub this)).mp ?_ · simp · rw [natCast_le_analyticOrderAt_iff_iteratedDeriv_eq_zero (hf.fun_sub this)] intro i hi diff --git a/Mathlib/Analysis/Analytic/Polynomial.lean b/Mathlib/Analysis/Analytic/Polynomial.lean index e48dc758bfe01c..3636136f585bec 100644 --- a/Mathlib/Analysis/Analytic/Polynomial.lean +++ b/Mathlib/Analysis/Analytic/Polynomial.lean @@ -32,7 +32,7 @@ theorem AnalyticWithinAt.aeval_polynomial (hf : AnalyticWithinAt 𝕜 f s z) (p refine p.induction_on (fun k ↦ ?_) (fun p q hp hq ↦ ?_) fun p i hp ↦ ?_ · simp_rw [aeval_C]; apply analyticWithinAt_const · simp_rw [aeval_add]; exact hp.add hq - · convert hp.mul hf + · convert! hp.mul hf simp_rw [pow_succ, aeval_mul, ← mul_assoc, aeval_X] theorem AnalyticAt.aeval_polynomial (hf : AnalyticAt 𝕜 f z) (p : A[X]) : diff --git a/Mathlib/Analysis/Analytic/Uniqueness.lean b/Mathlib/Analysis/Analytic/Uniqueness.lean index ff9392fefd0bb9..4b2d69f24953b6 100644 --- a/Mathlib/Analysis/Analytic/Uniqueness.lean +++ b/Mathlib/Analysis/Analytic/Uniqueness.lean @@ -167,7 +167,7 @@ theorem eqOn_zero_of_preconnected_of_eventuallyEq_zero_aux [CompleteSpace F] {f have A : HasSum (fun n : ℕ => q n fun _ : Fin n => z - y) (f z) := has_series.hasSum_sub hz have B : HasSum (fun n : ℕ => q n fun _ : Fin n => z - y) 0 := by have : HasFPowerSeriesAt 0 q y := has_series.hasFPowerSeriesAt.congr yu - convert hasSum_zero (α := F) using 1 + convert! hasSum_zero (α := F) using 1 ext n exact this.apply_eq_zero n _ exact HasSum.unique A B diff --git a/Mathlib/Analysis/Asymptotics/AsymptoticEquivalent.lean b/Mathlib/Analysis/Asymptotics/AsymptoticEquivalent.lean index 8143012f41d696..efee98d87146b4 100644 --- a/Mathlib/Analysis/Asymptotics/AsymptoticEquivalent.lean +++ b/Mathlib/Analysis/Asymptotics/AsymptoticEquivalent.lean @@ -76,7 +76,7 @@ nonrec theorem IsEquivalent.isBigO (h : u ~[l] v) : u =O[l] v := (IsBigO.congr_of_sub h.isBigO.symm).mp (isBigO_refl _ _) theorem IsEquivalent.isBigO_symm (h : u ~[l] v) : v =O[l] u := by - convert h.isLittleO.right_isBigO_add + convert! h.isLittleO.right_isBigO_add simp theorem IsEquivalent.isTheta (h : u ~[l] v) : u =Θ[l] v := @@ -167,7 +167,7 @@ theorem IsLittleO.isEquivalent (huv : (u - v) =o[l] v) : u ~[l] v := huv theorem IsEquivalent.neg (huv : u ~[l] v) : (fun x ↦ -u x) ~[l] fun x ↦ -v x := by rw [IsEquivalent] - convert huv.isLittleO.neg_left.neg_right + convert! huv.isLittleO.neg_left.neg_right simp [neg_add_eq_sub] end NormedAddCommGroup @@ -184,10 +184,10 @@ theorem isEquivalent_iff_exists_eq_mul : constructor <;> rintro ⟨φ, hφ, h⟩ <;> [refine ⟨φ + 1, ?_, ?_⟩; refine ⟨φ - 1, ?_, ?_⟩] · conv in 𝓝 _ => rw [← zero_add (1 : β)] exact hφ.add tendsto_const_nhds - · convert h.fun_add (EventuallyEq.refl l v) <;> simp [add_mul] + · convert! h.fun_add (EventuallyEq.refl l v) <;> simp [add_mul] · conv in 𝓝 _ => rw [← sub_self (1 : β)] exact hφ.sub tendsto_const_nhds - · convert h.fun_sub (EventuallyEq.refl l v); simp [sub_mul] + · convert! h.fun_sub (EventuallyEq.refl l v); simp [sub_mul] theorem IsEquivalent.exists_eq_mul (huv : u ~[l] v) : ∃ (φ : α → β) (_ : Tendsto φ l (𝓝 1)), u =ᶠ[l] φ * v := @@ -213,7 +213,7 @@ theorem isEquivalent_iff_tendsto_one (hz : ∀ᶠ x in l, v x ≠ 0) : simp only [Pi.sub_apply, sub_div] at this have key : Tendsto (fun x ↦ v x / v x) l (𝓝 1) := (tendsto_congr' <| hz.mono fun x hnz ↦ @div_self _ _ (v x) hnz).mpr tendsto_const_nhds - convert this.add key + convert! this.add key · simp · simp · exact isEquivalent_of_tendsto_one @@ -227,8 +227,9 @@ theorem IsEquivalent.smul {α E 𝕜 : Type*} [NormedField 𝕜] [NormedAddCommG (fun x ↦ a x • u x) ~[l] fun x ↦ b x • v x := by rcases hab.exists_eq_mul with ⟨φ, hφ, habφ⟩ have : ((fun x ↦ a x • u x) - (fun x ↦ b x • v x)) =ᶠ[l] fun x ↦ b x • (φ x • u x - v x) := by - convert (habφ.comp₂ (· • ·) <| EventuallyEq.refl _ u).fun_sub - (EventuallyEq.refl _ fun x ↦ b x • v x) using 1 + convert! + (habφ.comp₂ (· • ·) <| EventuallyEq.refl _ u).fun_sub + (EventuallyEq.refl _ fun x ↦ b x • v x) using 1 ext rw [Pi.mul_apply, mul_comm, mul_smul, ← smul_sub] refine (isLittleO_congr this.symm <| EventuallyEq.rfl).mp ((isBigO_refl b l).smul_isLittleO ?_) @@ -286,7 +287,7 @@ protected theorem IsEquivalent.inv (huv : u ~[l] v) : u⁻¹ ~[l] v⁻¹ := by rcases huv with ⟨φ, hφ, h⟩ rw [← inv_one] refine ⟨fun x ↦ (φ x)⁻¹, Tendsto.inv₀ hφ (by simp), ?_⟩ - convert h.fun_inv + convert! h.fun_inv simp [mul_comm] protected theorem IsEquivalent.div (htu : t ~[l] u) (hvw : v ~[l] w) : @@ -321,7 +322,7 @@ theorem IsEquivalent.tendsto_atTop_iff [OrderTopology β] (huv : u ~[l] v) : theorem IsEquivalent.tendsto_atBot [OrderTopology β] (huv : u ~[l] v) (hu : Tendsto u l atBot) : Tendsto v l atBot := by - convert tendsto_neg_atTop_atBot.comp (huv.neg.tendsto_atTop <| tendsto_neg_atBot_atTop.comp hu) + convert! tendsto_neg_atTop_atBot.comp (huv.neg.tendsto_atTop <| tendsto_neg_atBot_atTop.comp hu) ext simp diff --git a/Mathlib/Analysis/Asymptotics/Defs.lean b/Mathlib/Analysis/Asymptotics/Defs.lean index 1b97e119250e7b..51fddaaf99e009 100644 --- a/Mathlib/Analysis/Asymptotics/Defs.lean +++ b/Mathlib/Analysis/Asymptotics/Defs.lean @@ -1312,7 +1312,7 @@ theorem IsBigOWith.mul {f₁ f₂ : α → R} {g₁ g₂ : α → S} {c₁ c₂ simp only [IsBigOWith_def] at * filter_upwards [h₁, h₂] with _ hx₁ hx₂ apply le_trans (norm_mul_le _ _) - convert mul_le_mul hx₁ hx₂ (norm_nonneg _) (le_trans (norm_nonneg _) hx₁) using 1 + convert! mul_le_mul hx₁ hx₂ (norm_nonneg _) (le_trans (norm_nonneg _) hx₁) using 1 rw [norm_mul, mul_mul_mul_comm] theorem IsBigO.mul {f₁ f₂ : α → R} {g₁ g₂ : α → S} (h₁ : f₁ =O[l] g₁) (h₂ : f₂ =O[l] g₂) : @@ -1375,7 +1375,7 @@ theorem IsLittleO.pow {f : α → R} {g : α → S} (h : f =o[l] g) {n : ℕ} (h obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn.ne'; clear hn induction n with | zero => simpa only [pow_one] - | succ n ihn => convert ihn.mul h <;> simp [pow_succ] + | succ n ihn => convert! ihn.mul h <;> simp [pow_succ] theorem IsLittleO.of_pow [NormOneClass S] {f : α → S} {g : α → R} {n : ℕ} (h : (f ^ n) =o[l] (g ^ n)) (hn : n ≠ 0) : f =o[l] g := diff --git a/Mathlib/Analysis/Asymptotics/Lemmas.lean b/Mathlib/Analysis/Asymptotics/Lemmas.lean index 788c0d0b079715..483261194923fb 100644 --- a/Mathlib/Analysis/Asymptotics/Lemmas.lean +++ b/Mathlib/Analysis/Asymptotics/Lemmas.lean @@ -279,7 +279,7 @@ theorem IsBigOWith.smul (h₁ : IsBigOWith c l k₁ k₂) (h₂ : IsBigOWith c' simp only [IsBigOWith_def] at * filter_upwards [h₁, h₂] with _ hx₁ hx₂ apply le_trans (norm_smul_le _ _) - convert mul_le_mul hx₁ hx₂ (norm_nonneg _) (le_trans (norm_nonneg _) hx₁) using 1 + convert! mul_le_mul hx₁ hx₂ (norm_nonneg _) (le_trans (norm_nonneg _) hx₁) using 1 rw [norm_smul, mul_mul_mul_comm] theorem IsBigO.smul (h₁ : k₁ =O[l] k₂) (h₂ : f' =O[l] g') : @@ -437,13 +437,13 @@ theorem IsLittleO.of_tendsto_div_atTop (h : Tendsto (fun x ↦ g x / f x) l atTo intro x h h0 simp only [h0, zero_div] at h grind - · convert Tendsto.comp tendsto_inv_atTop_zero h + · convert! Tendsto.comp tendsto_inv_atTop_zero h simp theorem IsLittleO.of_tendsto_div_atBot (h : Tendsto (fun x ↦ g x / f x) l atBot) : f =o[l] g := by refine IsLittleO.of_neg_left (IsLittleO.of_tendsto_div_atTop ?_) rw [← tendsto_neg_atBot_iff] - convert h using 2 + convert! h using 2 simp [div_neg_eq_neg_div] end div_tendsto_infty @@ -570,7 +570,7 @@ theorem isLittleO_norm_pow_norm_pow {m n : ℕ} (h : m < n) : (isLittleO_pow_pow h).comp_tendsto tendsto_norm_zero theorem isLittleO_pow_id {n : ℕ} (h : 1 < n) : (fun x : 𝕜 => x ^ n) =o[𝓝 0] fun x => x := by - convert isLittleO_pow_pow h (𝕜 := 𝕜) + convert! isLittleO_pow_pow h (𝕜 := 𝕜) simp only [pow_one] theorem isLittleO_norm_pow_id {n : ℕ} (h : 1 < n) : diff --git a/Mathlib/Analysis/Asymptotics/SpecificAsymptotics.lean b/Mathlib/Analysis/Asymptotics/SpecificAsymptotics.lean index 976ec385bd3ad3..9bf8b0f69de378 100644 --- a/Mathlib/Analysis/Asymptotics/SpecificAsymptotics.lean +++ b/Mathlib/Analysis/Asymptotics/SpecificAsymptotics.lean @@ -110,7 +110,7 @@ theorem Asymptotics.IsBigO.trans_tendsto_norm_atTop {α : Type*} {u v : α → Tendsto (fun x => ‖v x‖) l atTop := by rcases huv.exists_pos with ⟨c, hc, hcuv⟩ rw [IsBigOWith] at hcuv - convert Tendsto.atTop_div_const hc (tendsto_atTop_mono' l hcuv hu) + convert! Tendsto.atTop_div_const hc (tendsto_atTop_mono' l hcuv hu) rw [mul_div_cancel_left₀ _ hc.ne.symm] end NormedLinearOrderedField diff --git a/Mathlib/Analysis/Asymptotics/Theta.lean b/Mathlib/Analysis/Asymptotics/Theta.lean index ef28392c865f30..9b2bcb74a399f9 100644 --- a/Mathlib/Analysis/Asymptotics/Theta.lean +++ b/Mathlib/Analysis/Asymptotics/Theta.lean @@ -284,7 +284,7 @@ theorem isTheta_of_div_tendsto_nhds_ne_zero {c : 𝕜} {f g : α → 𝕜} f =Θ[l] g := by refine ⟨isBigO_of_div_tendsto_nhds_of_ne_zero h hc, isBigO_of_div_tendsto_nhds_of_ne_zero ?_ (inv_ne_zero hc)⟩ - convert h.inv₀ hc using 1 + convert! h.inv₀ hc using 1 ext simp diff --git a/Mathlib/Analysis/BoxIntegral/Basic.lean b/Mathlib/Analysis/BoxIntegral/Basic.lean index 907f94655b6723..9f8867a2600227 100644 --- a/Mathlib/Analysis/BoxIntegral/Basic.lean +++ b/Mathlib/Analysis/BoxIntegral/Basic.lean @@ -483,7 +483,10 @@ theorem to_subbox_aux (h : Integrable I l f vol) (hJ : J ≤ I) : Tendsto (integralSum f vol) (l.toFilteriUnion I (Prepartition.single I J hJ)) (𝓝 y) := by refine (cauchy_map_iff_exists_tendsto.1 (h.cauchy_map_integralSum_toFilteriUnion (.single I J hJ))).imp fun y hy ↦ ⟨?_, hy⟩ - convert hy.comp (l.tendsto_embedBox_toFilteriUnion_top hJ) -- faster than `exact` here + convert! + hy.comp + (l.tendsto_embedBox_toFilteriUnion_top hJ) -- faster than `exact` here + -- faster than `exact` here /-- If `f` is integrable on a box `I`, then it is integrable on any subbox of `I`. -/ theorem to_subbox (h : Integrable I l f vol) (hJ : J ≤ I) : Integrable J l f vol := @@ -805,7 +808,7 @@ theorem HasIntegral.of_bRiemann_eq_false_of_forall_isLittleO (hl : l.bRiemann = rw [Finset.mem_filter] at hJ; obtain ⟨hJ, hJs⟩ := hJ refine Hδ₁ c _ ⟨π.tag_mem_Icc _, hJs⟩ _ (hεs0 _) _ (π.le_of_mem' _ hJ) ?_ (hπδ.2 hlH J hJ) fun hD => (Finset.le_sup hJ).trans (hπδ.3 hD) - convert hπδ.1 J hJ using 3; exact (if_pos hJs).symm + convert! hπδ.1 J hJ using 3; exact (if_pos hJs).symm refine (dist_sum_sum_le_of_le _ this).trans ?_ rw [sum_comp] refine (sum_le_sum ?_).trans (hεs _ ?_) @@ -825,7 +828,7 @@ theorem HasIntegral.of_bRiemann_eq_false_of_forall_isLittleO (hl : l.bRiemann = rw [Finset.mem_filter] at hJ; obtain ⟨hJ, hJs⟩ := hJ refine Hδ₂ c _ ⟨π.tag_mem_Icc _, hJs⟩ _ ε'0 _ (π.le_of_mem' _ hJ) ?_ (fun hH => hπδ.2 hH J hJ) fun hD => (Finset.le_sup hJ).trans (hπδ.3 hD) - convert hπδ.1 J hJ using 3; exact (if_neg hJs).symm + convert! hπδ.1 J hJ using 3; exact (if_neg hJs).symm _ ≤ ∑ J ∈ π.boxes, ε' * B J := by gcongr · exact fun _ _ _ ↦ mul_nonneg ε'0.le (hB0 _) diff --git a/Mathlib/Analysis/BoxIntegral/Integrability.lean b/Mathlib/Analysis/BoxIntegral/Integrability.lean index 9f724990366c46..a7e944a69d5371 100644 --- a/Mathlib/Analysis/BoxIntegral/Integrability.lean +++ b/Mathlib/Analysis/BoxIntegral/Integrability.lean @@ -274,7 +274,7 @@ theorem IntegrableOn.hasBoxIntegral [CompleteSpace E] {f : (ι → ℝ) → E} { have : l.MemBaseSet I c ((hfi' n).convergenceR (δ n) c) (π.filter fun J => Nx (π.tag J) = n) := (hπ.filter _).mono' _ le_rfl le_rfl fun J hJ => (hrn J hJ).le - convert (hfi' n).dist_integralSum_sum_integral_le_of_memBaseSet (δ0 _) this using 2 + convert! (hfi' n).dist_integralSum_sum_integral_le_of_memBaseSet (δ0 _) this using 2 · refine sum_congr rfl fun J hJ => ?_ simp [hNxn J hJ] · refine sum_congr rfl fun J hJ => ?_ @@ -305,7 +305,7 @@ theorem ContinuousOn.hasBoxIntegral [CompleteSpace E] {f : (ι → ℝ) → E} ( (l : IntegrationParams) : HasIntegral.{u, v, v} I l f μ.toBoxAdditive.toSMul (∫ x in I, f x ∂μ) := by obtain ⟨y, hy⟩ := BoxIntegral.integrable_of_continuousOn l hc μ - convert hy + convert! hy have : IntegrableOn f I μ := IntegrableOn.mono_set (hc.integrableOn_compact I.isCompact_Icc) Box.coe_subset_Icc exact HasIntegral.unique (IntegrableOn.hasBoxIntegral this ⊥ rfl) (HasIntegral.mono hy bot_le) @@ -317,7 +317,7 @@ theorem AEContinuous.hasBoxIntegral [CompleteSpace E] {f : (ι → ℝ) → E} ( (hc : ∀ᵐ x ∂μ, ContinuousAt f x) (l : IntegrationParams) : HasIntegral.{u, v, v} I l f μ.toBoxAdditive.toSMul (∫ x in I, f x ∂μ) := by obtain ⟨y, hy⟩ := integrable_of_bounded_and_ae_continuous l hb μ hc - convert hy + convert! hy refine HasIntegral.unique (IntegrableOn.hasBoxIntegral ?_ ⊥ rfl) (HasIntegral.mono hy bot_le) constructor · let v := {x : (ι → ℝ) | ContinuousAt f x} diff --git a/Mathlib/Analysis/BoxIntegral/Partition/Basic.lean b/Mathlib/Analysis/BoxIntegral/Partition/Basic.lean index 3ae1a413b276e3..e88622d3d35486 100644 --- a/Mathlib/Analysis/BoxIntegral/Partition/Basic.lean +++ b/Mathlib/Analysis/BoxIntegral/Partition/Basic.lean @@ -198,7 +198,7 @@ theorem iUnion_def' : π.iUnion = ⋃ J ∈ π.boxes, ↑J := rfl @[simp] theorem mem_iUnion : x ∈ π.iUnion ↔ ∃ J ∈ π, x ∈ J := by - convert Set.mem_iUnion₂ + convert! Set.mem_iUnion₂ rw [Box.mem_coe, exists_prop] @[simp] @@ -329,7 +329,7 @@ theorem biUnionIndex_le (πi : ∀ J, Prepartition J) (J : Box ι) : π.biUnionI · rw [biUnionIndex, dif_neg hJ] theorem mem_biUnionIndex (hJ : J ∈ π.biUnion πi) : J ∈ πi (π.biUnionIndex πi J) := by - convert (π.mem_biUnion.1 hJ).choose_spec.2 <;> exact dif_pos hJ + convert! (π.mem_biUnion.1 hJ).choose_spec.2 <;> exact dif_pos hJ theorem le_biUnionIndex (hJ : J ∈ π.biUnion πi) : J ≤ π.biUnionIndex πi J := le_of_mem _ (π.mem_biUnionIndex hJ) @@ -548,11 +548,11 @@ theorem filter_true : (π.filter fun _ => True) = π := theorem iUnion_filter_not (π : Prepartition I) (p : Box ι → Prop) : (π.filter fun J => ¬p J).iUnion = π.iUnion \ (π.filter p).iUnion := by simp only [Prepartition.iUnion] - convert + convert! (@Set.biUnion_diff_biUnion_eq (ι → ℝ) (Box ι) π.boxes (π.filter p).boxes (↑) _).symm using 4 · simp +contextual · rw [Set.PairwiseDisjoint] - convert π.pairwiseDisjoint + convert! π.pairwiseDisjoint rw [Set.union_eq_left, filter_boxes, coe_filter] exact fun _ ⟨h, _⟩ => h @@ -560,7 +560,7 @@ open scoped Classical in theorem sum_fiberwise {α M} [AddCommMonoid M] (π : Prepartition I) (f : Box ι → α) (g : Box ι → M) : (∑ y ∈ π.boxes.image f, ∑ J ∈ (π.filter fun J => f J = y).boxes, g J) = ∑ J ∈ π.boxes, g J := by - convert sum_fiberwise_of_maps_to (fun _ => Finset.mem_image_of_mem f) g + convert! sum_fiberwise_of_maps_to (fun _ => Finset.mem_image_of_mem f) g open scoped Classical in /-- Union of two disjoint prepartitions. -/ diff --git a/Mathlib/Analysis/BoxIntegral/Partition/Tagged.lean b/Mathlib/Analysis/BoxIntegral/Partition/Tagged.lean index 46b58f40fd0212..84e1f0310b0e78 100644 --- a/Mathlib/Analysis/BoxIntegral/Partition/Tagged.lean +++ b/Mathlib/Analysis/BoxIntegral/Partition/Tagged.lean @@ -72,7 +72,7 @@ theorem iUnion_toPrepartition : π.toPrepartition.iUnion = π.iUnion := rfl @[simp] theorem mem_iUnion : x ∈ π.iUnion ↔ ∃ J ∈ π, x ∈ J := by - convert Set.mem_iUnion₂ + convert! Set.mem_iUnion₂ rw [Box.mem_coe, mem_toPrepartition, exists_prop] theorem subset_iUnion (h : J ∈ π) : ↑J ⊆ π.iUnion := diff --git a/Mathlib/Analysis/BoxIntegral/UnitPartition.lean b/Mathlib/Analysis/BoxIntegral/UnitPartition.lean index bafcb5e7e5ff80..b8f218c8f6b7d6 100644 --- a/Mathlib/Analysis/BoxIntegral/UnitPartition.lean +++ b/Mathlib/Analysis/BoxIntegral/UnitPartition.lean @@ -458,7 +458,7 @@ theorem _root_.tendsto_card_div_pow_atTop_volume (hs₁ : IsBounded s) (hs₂ : MeasurableSet s) (hs₃ : volume (frontier s) = 0) : Tendsto (fun n : ℕ ↦ (Nat.card ↑(s ∩ (n : ℝ)⁻¹ • L) : ℝ) / n ^ card ι) atTop (𝓝 (volume.real s)) := by - convert tendsto_tsum_div_pow_atTop_integral s (fun _ ↦ 1) continuous_const hs₁ hs₂ hs₃ + convert! tendsto_tsum_div_pow_atTop_integral s (fun _ ↦ 1) continuous_const hs₁ hs₂ hs₃ · rw [tsum_const, nsmul_eq_mul, mul_one, Nat.cast_inj] · rw [setIntegral_const, smul_eq_mul, mul_one] diff --git a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Continuity.lean b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Continuity.lean index ac8de4fd93f24c..d41724ad722113 100644 --- a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Continuity.lean +++ b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Continuity.lean @@ -236,8 +236,10 @@ theorem continuousOn_cfc {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜) (hf : ContinuousOn f s := by cfc_cont_tac) : ContinuousOn (cfc f) {a | p a ∧ spectrum 𝕜 a ⊆ s} := continuousOn_iff_continuous_restrict.mpr <| by - convert continuous_cfcHomSuperset_left hs ⟨_, hf.restrict⟩ - ((↑) : {a | p a ∧ spectrum 𝕜 a ⊆ s} → A) continuous_subtype_val (fun x ↦ x.2.2) with x + convert! + continuous_cfcHomSuperset_left hs ⟨_, hf.restrict⟩ ((↑) : {a | p a ∧ spectrum 𝕜 a ⊆ s} → A) + continuous_subtype_val (fun x ↦ x.2.2) with + x rw [cfcHomSuperset_apply, Set.restrict_apply, cfc_apply _ _ x.2.1 (hf.mono x.2.2)] congr! @@ -736,11 +738,13 @@ theorem continuousOn_cfcₙ {s : Set 𝕜} (hs : IsCompact s) (f : 𝕜 → 𝕜 ContinuousOn (cfcₙ f · : A → A) {a | p a ∧ quasispectrum 𝕜 a ⊆ s} := by by_cases hs0 : 0 ∈ s · rw [continuousOn_iff_continuous_restrict] - convert continuous_cfcₙHomSuperset_left hs (hs0 := ⟨hs0⟩) ⟨⟨_, hf.restrict⟩, hf0⟩ - (X := {a : A | p a ∧ quasispectrum 𝕜 a ⊆ s}) continuous_subtype_val (fun x ↦ x.2.2) with x + convert! + continuous_cfcₙHomSuperset_left hs (hs0 := ⟨hs0⟩) ⟨⟨_, hf.restrict⟩, hf0⟩ (X := + {a : A | p a ∧ quasispectrum 𝕜 a ⊆ s}) continuous_subtype_val (fun x ↦ x.2.2) with + x rw [cfcₙHomSuperset_apply, Set.restrict_apply, cfcₙ_apply _ _ (hf.mono x.2.2) hf0 x.2.1] congr! - · convert continuousOn_empty _ + · convert! continuousOn_empty _ rw [Set.eq_empty_iff_forall_notMem] exact fun a ha ↦ hs0 <| ha.2 <| quasispectrum.zero_mem 𝕜 a diff --git a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Instances.lean b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Instances.lean index f7597a30199e1b..15ab3086848860 100644 --- a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Instances.lean +++ b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Instances.lean @@ -118,7 +118,7 @@ lemma cfcₙAux_mem_range_inr (f : C(σₙ 𝕜 a, 𝕜)₀) : rw [SetLike.mem_coe, NonUnitalStarSubalgebra.mem_comap, cfcₙAux_id hp₁ a ha] exact ⟨a, rfl⟩ · simp only [NonUnitalStarAlgHom.coe_range] - convert IsClosed.preimage (Unitization.continuous_fst (𝕜 := 𝕜)) isClosed_singleton + convert! IsClosed.preimage (Unitization.continuous_fst (𝕜 := 𝕜)) isClosed_singleton aesop variable [CStarRing A] @@ -170,7 +170,7 @@ theorem RCLike.nonUnitalContinuousFunctionalCalculusIsClosedEmbedding : toNonUnitalContinuousFunctionalCalculus := RCLike.nonUnitalContinuousFunctionalCalculus hp₁ isClosedEmbedding a ha := by apply isometry_inr (𝕜 := 𝕜) (A := A) |>.isClosedEmbedding |>.of_comp_iff.mp - convert isClosedEmbedding_cfcₙAux hp₁ a ha + convert! isClosedEmbedding_cfcₙAux hp₁ a ha congrm (⇑$(inrNonUnitalStarAlgHom_comp_cfcₙHom_eq_cfcₙAux hp₁ a ha)) end RCLike diff --git a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Isometric.lean b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Isometric.lean index 85ebd14b8493a3..55669d08594c0a 100644 --- a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Isometric.lean +++ b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Isometric.lean @@ -74,7 +74,7 @@ lemma IsGreatest.norm_cfc [Nontrivial A] (f : 𝕜 → 𝕜) (a : A) |>.image_of_continuousOn hf.norm |>.exists_isGreatest <| (ContinuousFunctionalCalculus.spectrum_nonempty a ha).image _ obtain ⟨x, hx', rfl⟩ := hx.1 - convert hx + convert! hx rw [cfc_apply f a, norm_cfcHom a _] apply le_antisymm · apply ContinuousMap.norm_le _ (norm_nonneg _) |>.mpr @@ -85,7 +85,7 @@ lemma IsGreatest.norm_cfc [Nontrivial A] (f : 𝕜 → 𝕜) (a : A) lemma IsGreatest.nnnorm_cfc [Nontrivial A] (f : 𝕜 → 𝕜) (a : A) (hf : ContinuousOn f (σ 𝕜 a) := by cfc_cont_tac) (ha : p a := by cfc_tac) : IsGreatest ((fun x ↦ ‖f x‖₊) '' σ 𝕜 a) ‖cfc f a‖₊ := by - convert Real.toNNReal_monotone.map_isGreatest (.norm_cfc f a) + convert! Real.toNNReal_monotone.map_isGreatest (.norm_cfc f a) all_goals simp [Set.image_image, norm_toNNReal] lemma norm_apply_le_norm_cfc (f : 𝕜 → 𝕜) (a : A) ⦃x : 𝕜⦄ (hx : x ∈ σ 𝕜 a) @@ -264,7 +264,7 @@ lemma IsGreatest.norm_cfcₙ (f : 𝕜 → 𝕜) (a : A) |>.image_of_continuousOn hf.norm |>.exists_isGreatest <| (quasispectrum.nonempty 𝕜 a).image _ obtain ⟨x, hx', rfl⟩ := hx.1 - convert hx + convert! hx rw [cfcₙ_apply f a, norm_cfcₙHom a _] apply le_antisymm · apply ContinuousMap.norm_le _ (norm_nonneg _) |>.mpr @@ -275,7 +275,7 @@ lemma IsGreatest.norm_cfcₙ (f : 𝕜 → 𝕜) (a : A) lemma IsGreatest.nnnorm_cfcₙ (f : 𝕜 → 𝕜) (a : A) (hf : ContinuousOn f (σₙ 𝕜 a) := by cfc_cont_tac) (hf₀ : f 0 = 0 := by cfc_zero_tac) (ha : p a := by cfc_tac) : IsGreatest ((fun x ↦ ‖f x‖₊) '' σₙ 𝕜 a) ‖cfcₙ f a‖₊ := by - convert Real.toNNReal_monotone.map_isGreatest (.norm_cfcₙ f a) + convert! Real.toNNReal_monotone.map_isGreatest (.norm_cfcₙ f a) all_goals simp [Set.image_image, norm_toNNReal] lemma norm_apply_le_norm_cfcₙ (f : 𝕜 → 𝕜) (a : A) ⦃x : 𝕜⦄ (hx : x ∈ σₙ 𝕜 a) @@ -455,7 +455,7 @@ lemma IsGreatest.nnnorm_cfc_nnreal [Nontrivial A] (f : ℝ≥0 → ℝ≥0) (a : rw [cfc_nnreal_eq_real ..] obtain ⟨-, ha'⟩ := nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts.mp ha rw [← SpectrumRestricts] at ha' - convert IsGreatest.nnnorm_cfc (fun x : ℝ ↦ (f x.toNNReal : ℝ)) a ?hf_cont + convert! IsGreatest.nnnorm_cfc (fun x : ℝ ↦ (f x.toNNReal : ℝ)) a ?hf_cont case hf_cont => exact continuous_subtype_val.comp_continuousOn <| ContinuousOn.comp ‹_› continuous_real_toNNReal.continuousOn <| ha'.image ▸ Set.mapsTo_image .. simp [Set.image_image, ← ha'.image] @@ -529,7 +529,7 @@ lemma IsGreatest.nnnorm_cfcₙ_nnreal (f : ℝ≥0 → ℝ≥0) (a : A) (ha : 0 ≤ a := by cfc_tac) : IsGreatest (f '' σₙ ℝ≥0 a) ‖cfcₙ f a‖₊ := by rw [cfcₙ_nnreal_eq_real ..] obtain ⟨-, ha'⟩ := nonneg_iff_isSelfAdjoint_and_quasispectrumRestricts.mp ha - convert IsGreatest.nnnorm_cfcₙ (fun x : ℝ ↦ (f x.toNNReal : ℝ)) a ?hf_cont (by simpa) + convert! IsGreatest.nnnorm_cfcₙ (fun x : ℝ ↦ (f x.toNNReal : ℝ)) a ?hf_cont (by simpa) case hf_cont => exact continuous_subtype_val.comp_continuousOn <| ContinuousOn.comp ‹_› continuous_real_toNNReal.continuousOn <| ha'.image ▸ Set.mapsTo_image .. simp [Set.image_image, ← ha'.image] diff --git a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/NonUnital.lean b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/NonUnital.lean index daaf1353034ccd..8e874f08aa4074 100644 --- a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/NonUnital.lean +++ b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/NonUnital.lean @@ -475,7 +475,7 @@ lemma cfcₙ_comp (g f : R → R) (a : A) ext simp rw [cfcₙ_apply .., cfcₙ_apply f a, - cfcₙ_apply _ _ (by convert hg) (ha := cfcₙHom_predicate (show p a from ha) _), + cfcₙ_apply _ _ (by convert! hg) (ha := cfcₙHom_predicate (show p a from ha) _), ← cfcₙHom_comp _ _] swap · exact ⟨.mk _ <| hf.restrict.codRestrict fun x ↦ by rw [sp_eq]; use x.1; simp, Subtype.ext hf0⟩ @@ -840,7 +840,7 @@ lemma isClosedEmbedding_cfcₙHom_of_cfcHom [ClosedEmbeddingContinuousFunctional Filter.comap_comap] refine .symm <| inf_eq_left.mpr <| le_top.trans <| eq_top_iff.mp ?_ have : ∀ U ∈ 𝓤 (C(Unit, R)), (0, 0) ∈ U := fun U hU ↦ refl_mem_uniformity hU - convert Filter.comap_const_of_mem this with ⟨u, v⟩ <;> + convert! Filter.comap_const_of_mem this with ⟨u, v⟩ <;> ext ⟨x, rfl⟩ <;> [exact map_zero u; exact map_zero v] instance ContinuousFunctionalCalculus.toNonUnital [ContinuousFunctionalCalculus R A p] : diff --git a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Order.lean b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Order.lean index 1c620b900e2bae..f0ad4b5961e47b 100644 --- a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Order.lean +++ b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Order.lean @@ -221,7 +221,7 @@ variable [PartialOrder A] [StarOrderedRing A] lemma nnnorm_mem_spectrum_of_nonneg [Nontrivial A] {a : A} (ha : 0 ≤ a := by cfc_tac) : ‖a‖₊ ∈ spectrum ℝ≥0 a := by have : IsSelfAdjoint a := .of_nonneg ha - convert NNReal.spectralRadius_mem_spectrum (a := a) ?_ (.nnreal_of_nonneg ha) + convert! NNReal.spectralRadius_mem_spectrum (a := a) ?_ (.nnreal_of_nonneg ha) · simp [this.spectrumRestricts.spectralRadius_eq, this.spectralRadius_eq_nnnorm] · exact this.spectrumRestricts.image ▸ (spectrum.nonempty a).image _ @@ -480,7 +480,7 @@ lemma star_right_conjugate_le_norm_smul {a b : A} (hb : IsSelfAdjoint b := by cf lemma isClosed_nonneg : IsClosed {a : A | 0 ≤ a} := by suffices IsClosed {a : A⁺¹ | 0 ≤ a} by rw [Unitization.isometry_inr (𝕜 := ℂ) |>.isClosedEmbedding.isClosed_iff_image_isClosed] - convert this.inter <| (Unitization.isometry_inr (𝕜 := ℂ)).isClosedEmbedding.isClosed_range + convert! this.inter <| (Unitization.isometry_inr (𝕜 := ℂ)).isClosedEmbedding.isClosed_range ext a simp only [Set.mem_image, Set.mem_setOf_eq, Set.mem_inter_iff, Set.mem_range, ← exists_and_left] congr! 2 with x diff --git a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Restrict.lean b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Restrict.lean index 53cb75a105c542..ae98b71f0e4926 100644 --- a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Restrict.lean +++ b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Restrict.lean @@ -76,7 +76,7 @@ lemma starAlgHom_id {a : A} {φ : C(spectrum S a, S) →⋆ₐ[S] A} {f : C(S, R (h : SpectrumRestricts a f) (h_id : φ (.restrict (spectrum S a) <| .id S) = a) : h.starAlgHom φ (.restrict (spectrum R a) <| .id R) = a := by simp only [SpectrumRestricts.starAlgHom_apply] - convert h_id + convert! h_id ext x exact h.rightInvOn x.2 @@ -239,7 +239,7 @@ lemma nonUnitalStarAlgHom_id {a : A} {φ : C(σₙ S a, S)₀ →⋆ₙₐ[S] A} (h : QuasispectrumRestricts a f) (h_id : φ (.id _) = a) : h.nonUnitalStarAlgHom φ (.id _) = a := by simp only [QuasispectrumRestricts.nonUnitalStarAlgHom_apply] - convert h_id + convert! h_id ext x exact h.rightInvOn x.2 diff --git a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unique.lean b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unique.lean index 91c04a0b1a975a..d9cb6432619780 100644 --- a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unique.lean +++ b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unique.lean @@ -41,7 +41,7 @@ instance (priority := 100) RCLike.instContinuousMapUniqueHom [TopologicalSpace A ContinuousMap.UniqueHom 𝕜 A where eq_of_continuous_of_map_id s _ φ ψ hφ hψ h := ContinuousMap.starAlgHom_ext_map_X hφ hψ <| by - convert h using 1 + convert! h using 1 all_goals exact congr_arg _ (by ext; simp) instance Real.instContinuousMapUniqueHom [TopologicalSpace A] @@ -123,13 +123,13 @@ noncomputable def realContinuousMapOfNNReal (φ : C(X, ℝ≥0) →⋆ₐ[ℝ≥ have := congr(φ $(f.toNNReal_mul_add_neg_mul_add_mul_neg_eq g)) simp only [map_add, map_mul, sub_mul, mul_sub] at this ⊢ rw [← sub_eq_zero] at this ⊢ - convert this using 1 + convert! this using 1 abel map_add' f g := by have := congr(φ $(f.toNNReal_add_add_neg_add_neg_eq g)) simp only [map_add] at this ⊢ rw [← sub_eq_zero] at this ⊢ - convert this using 1 + convert! this using 1 abel commutes' r := by obtain (hr | hr) := le_total 0 r diff --git a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unital.lean b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unital.lean index 65594cdafcbad2..ae87b6c4067a91 100644 --- a/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unital.lean +++ b/Mathlib/Analysis/CStarAlgebra/ContinuousFunctionalCalculus/Unital.lean @@ -610,7 +610,7 @@ lemma cfc_comp (g f : R → R) (a : A) (ha : p a := by cfc_tac) ext simp rw [cfc_apply .., cfc_apply f a, - cfc_apply _ _ (cfcHom_predicate (show p a from ha) _) (by convert hg), ← cfcHom_comp _ _] + cfc_apply _ _ (cfcHom_predicate (show p a from ha) _) (by convert! hg), ← cfcHom_comp _ _] swap · exact ContinuousMap.mk _ <| hf.restrict.codRestrict fun x ↦ by rw [sp_eq]; use x.1; simp · congr @@ -784,7 +784,7 @@ lemma cfc_inv (hf' : ∀ x ∈ spectrum R a, f x ≠ 0) lemma cfc_inv_id (a : Aˣ) (ha : p a := by cfc_tac) : cfc (fun x ↦ x⁻¹ : R → R) (a : A) = a⁻¹ := by rw [← Ring.inverse_unit] - convert cfc_inv (id : R → R) (a : A) ?_ + convert! cfc_inv (id : R → R) (a : A) ?_ · exact (cfc_id R (a : A)).symm · rintro x hx rfl exact spectrum.zero_notMem R a.isUnit hx diff --git a/Mathlib/Analysis/CStarAlgebra/Fuglede.lean b/Mathlib/Analysis/CStarAlgebra/Fuglede.lean index e8df875edb5f3b..d3fd6ac3d9857e 100644 --- a/Mathlib/Analysis/CStarAlgebra/Fuglede.lean +++ b/Mathlib/Analysis/CStarAlgebra/Fuglede.lean @@ -132,7 +132,7 @@ public lemma isStarNormal_iff_forall_exp_mul_exp_mem_unitary {a : A} : refine ⟨fun ha x ↦ ?_, fun ha ↦ ?_⟩ /- If `a` is normal, then clearly `exp (x • a) * exp (- x • star a) = exp (I • x • 2 • ℑ a)` and the latter is clearly an exponential unitary. -/ - · convert (selfAdjoint.expUnitary (x • (2 : ℝ) • ℑ a)).2 + · convert! (selfAdjoint.expUnitary (x • (2 : ℝ) • ℑ a)).2 have hcomm := star_comm_self (x := a) |>.symm.smul_left x |>.smul_right (-x) rw [← exp_add_of_commute hcomm] simp [imaginaryPart_apply_coe, smul_comm (2 : ℝ) I, smul_comm x I, smul_smul I I, smul_add x, @@ -142,7 +142,7 @@ public lemma isStarNormal_iff_forall_exp_mul_exp_mem_unitary {a : A} : · have key : ∀ x : ℝ, exp (- x • a) * exp (x • star a) = exp (x • star a) * exp (- x • a) := by intro x let u : unitary A := ⟨_, ha x⟩ - convert congr(($(Unitary.star_eq_inv u) : A)) + convert! congr(($(Unitary.star_eq_inv u) : A)) · simp [u, star_exp] · simp_rw [u, ← Unitary.val_inv_toUnits_apply, neg_smul, ← Units.mul_eq_one_iff_eq_inv, Unitary.val_toUnits_apply] diff --git a/Mathlib/Analysis/CStarAlgebra/Matrix.lean b/Mathlib/Analysis/CStarAlgebra/Matrix.lean index 19583896a8fc29..2dae014aca2719 100644 --- a/Mathlib/Analysis/CStarAlgebra/Matrix.lean +++ b/Mathlib/Analysis/CStarAlgebra/Matrix.lean @@ -151,6 +151,7 @@ def l2OpNormedRingAux : NormedRing (Matrix n n 𝕜) := open Bornology Filter open scoped Topology Uniformity +set_option backward.isDefEq.respectTransparency false in /-- The metric on `Matrix m n 𝕜` arising from the operator norm given by the identification with (continuous) linear maps of `EuclideanSpace`. -/ @[instance_reducible] @@ -218,7 +219,7 @@ lemma l2_opNorm_mul (A : Matrix m n 𝕜) (B : Matrix n l 𝕜) : simp only [l2_opNorm_def] have := (toEuclideanLin (n := n) (m := m) (𝕜 := 𝕜) ≪≫ₗ toContinuousLinearMap) A |>.opNorm_comp_le <| (toEuclideanLin (n := l) (m := n) (𝕜 := 𝕜) ≪≫ₗ toContinuousLinearMap) B - convert this + convert! this ext1 x exact congr(toLp 2 ($(Matrix.toLin'_mul A B) x)) diff --git a/Mathlib/Analysis/CStarAlgebra/Multiplier.lean b/Mathlib/Analysis/CStarAlgebra/Multiplier.lean index 2a9c2a448bf523..77def5fd570085 100644 --- a/Mathlib/Analysis/CStarAlgebra/Multiplier.lean +++ b/Mathlib/Analysis/CStarAlgebra/Multiplier.lean @@ -533,7 +533,7 @@ theorem norm_fst_eq_snd (a : 𝓜(𝕜, A)) : ‖a.fst‖ = ‖a.snd‖ := by have h1 b : C * ‖f b‖₊ * ‖b‖₊ ≤ C * ‖f‖₊ * ‖b‖₊ ^ 2 := by grw [f.le_opNNNorm b]; ring_nf; rfl have := NNReal.div_le_of_le_mul <| f.opNNNorm_le_bound _ <| by simpa only [sqrt_sq, sqrt_mul] using fun b ↦ sqrt_le_sqrt.2 <| (h b).trans (h1 b) - convert NNReal.rpow_le_rpow this two_pos.le + convert! NNReal.rpow_le_rpow this two_pos.le · simp only [NNReal.rpow_two, div_pow, sq_sqrt] simp only [sq, mul_self_div_self] · simp only [NNReal.rpow_two, sq_sqrt] diff --git a/Mathlib/Analysis/CStarAlgebra/Spectrum.lean b/Mathlib/Analysis/CStarAlgebra/Spectrum.lean index 7ceef869235773..03df3365bc1290 100644 --- a/Mathlib/Analysis/CStarAlgebra/Spectrum.lean +++ b/Mathlib/Analysis/CStarAlgebra/Spectrum.lean @@ -118,7 +118,7 @@ theorem IsSelfAdjoint.spectralRadius_eq_nnnorm {a : A} (ha : IsSelfAdjoint a) : spectralRadius ℂ a = ‖a‖₊ := by have hconst : Tendsto (fun _n : ℕ => (‖a‖₊ : ℝ≥0∞)) atTop _ := tendsto_const_nhds refine tendsto_nhds_unique ?_ hconst - convert + convert! (spectrum.pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius (a : A)).comp (tendsto_pow_atTop_atTop_of_one_lt one_lt_two) using 1 refine funext fun n => ?_ @@ -145,7 +145,7 @@ theorem IsStarNormal.spectralRadius_eq_nnnorm (a : A) [IsStarNormal a] : ((ENNReal.continuous_pow 2).tendsto (spectralRadius ℂ a)).comp (spectrum.pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius a) rw [← heq] at h₂ - convert tendsto_nhds_unique h₂ (pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius (a⋆ * a)) + convert! tendsto_nhds_unique h₂ (pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius (a⋆ * a)) rw [(IsSelfAdjoint.star_mul_self a).spectralRadius_eq_nnnorm, sq, nnnorm_star_mul_self, coe_mul] namespace CStarAlgebra @@ -169,8 +169,6 @@ theorem sqrt_toReal_spectralRadius_self_mul_star_eq_norm (a : A) : end CStarAlgebra -variable [StarModule ℂ A] - /-- Any element of the spectrum of a selfadjoint is real. -/ theorem IsSelfAdjoint.mem_spectrum_eq_re {a : A} (ha : IsSelfAdjoint a) {z : ℂ} (hz : z ∈ spectrum ℂ a) : z = z.re := by @@ -213,7 +211,7 @@ lemma IsSelfAdjoint.isConnected_spectrum_compl {a : A} (ha : IsSelfAdjoint a) : suffices IsConnected (((σ ℂ a)ᶜ ∩ {z | 0 ≤ z.im}) ∪ (σ ℂ a)ᶜ ∩ {z | z.im ≤ 0}) by rw [← Set.inter_union_distrib_left, ← Set.setOf_or] at this rw [← Set.inter_univ (σ ℂ a)ᶜ] - convert this using 2 + convert! this using 2 exact Eq.symm <| Set.eq_univ_of_forall (fun z ↦ le_total 0 z.im) refine IsConnected.union ?nonempty ?upper ?lower case nonempty => diff --git a/Mathlib/Analysis/CStarAlgebra/Unitary/Connected.lean b/Mathlib/Analysis/CStarAlgebra/Unitary/Connected.lean index eeaa9842871cdd..41a18371763e21 100644 --- a/Mathlib/Analysis/CStarAlgebra/Unitary/Connected.lean +++ b/Mathlib/Analysis/CStarAlgebra/Unitary/Connected.lean @@ -67,7 +67,7 @@ lemma Unitary.two_mul_one_sub_le_norm_sub_one_sq {u : A} (hu : u ∈ unitary A) have := spectrum.subset_circle_of_unitary hu hz simp only [mem_sphere_iff_norm, sub_zero] at this rw [← cfc_id' ℂ u, ← cfc_one ℂ u, ← cfc_sub ..] - convert norm_apply_le_norm_cfc (fun z ↦ z - 1) u hz + convert! norm_apply_le_norm_cfc (fun z ↦ z - 1) u hz simpa using congr(Real.sqrt $(norm_sub_one_sq_eq_of_norm_eq_one this)).symm lemma Unitary.norm_sub_one_sq_eq {u : A} (hu : u ∈ unitary A) {x : ℝ} @@ -315,7 +315,7 @@ lemma Unitary.joined (u v : unitary A) (huv : ‖(v - u : A)‖ < 2) : lemma Unitary.isPathConnected_ball (u : unitary A) (δ : ℝ) (hδ₀ : 0 < δ) (hδ₂ : δ < 2) : IsPathConnected (ball (u : unitary A) δ) := by suffices IsPathConnected (ball (1 : unitary A) δ) by - convert this |>.image (f := (u * ·)) (by fun_prop) + convert! this |>.image (f := (u * ·)) (by fun_prop) ext v rw [← inv_mul_cancel u] simp [-inv_mul_cancel, Subtype.dist_eq, dist_eq_norm, ← mul_sub] diff --git a/Mathlib/Analysis/Calculus/AbsolutelyMonotone.lean b/Mathlib/Analysis/Calculus/AbsolutelyMonotone.lean new file mode 100644 index 00000000000000..edd4a6a92a2432 --- /dev/null +++ b/Mathlib/Analysis/Calculus/AbsolutelyMonotone.lean @@ -0,0 +1,122 @@ +/- +Copyright (c) 2025 Michael R. Douglas. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Michael R. Douglas +-/ +module + +public import Mathlib.Analysis.Calculus.ContDiff.Operations +public import Mathlib.Analysis.Calculus.IteratedDeriv.Lemmas + +/-! +# Absolutely monotone functions + +A function `f : ℝ → ℝ` is *absolutely monotone* on a set `s` if its iterated derivatives are all +nonnegative on `s`. + +## Main definitions + +* `AbsolutelyMonotoneOn` — there exists a Taylor series for `f` on `s` with nonnegative terms at + each point of `s`. + +## Main results + +* `AbsolutelyMonotoneOn.contDiffOn` — the function is `C^∞` on `s`. +* `AbsolutelyMonotoneOn.of_contDiff` — a globally `C^∞` function with nonnegative iterated + derivatives on `s` is absolutely monotone on `s`. +* `AbsolutelyMonotoneOn.iff_iteratedDerivWithin_nonneg` — under `UniqueDiffOn`, the definition + is equivalent to `f` being `C^∞` on `s` with every iterated derivative within `s` nonnegative. +* `AbsolutelyMonotoneOn.add` — closure under addition. +* `AbsolutelyMonotoneOn.smul` — closure under nonnegative scalar multiplication. + +## Implementation + +The precise definition is phrased via the existence of a Taylor series with nonnegative terms +(`HasFTaylorSeriesUpToOn`) rather than via `iteratedDerivWithin`. This avoids forcing a +`UniqueDiffOn s` hypothesis on every result: without `UniqueDiffOn`, "the" iterated derivative +within `s` is not canonical, but the existence of a Taylor series is intrinsic to `f` and `s`. +When `s` does satisfy `UniqueDiffOn`, the condition reduces to `f` being `C^∞` on `s` with every +iterated derivative within `s` nonnegative. + +## References + +* [D. V. Widder, *The Laplace Transform*][widder1941] +-/ + +public section + +open Set Filter +open scoped ContDiff + +/-- A function `f : ℝ → ℝ` is **absolutely monotone on a set `s`** if, heuristically, all +iterated derivatives of `f` on `s` are nonnegative. For technical reasons related to unique +differentiability, the precise definition is phrased as the existence of a Taylor series for +`f` on `s` whose `n`th term, evaluated at the all-ones tuple, is nonnegative for every `n` and +every `x ∈ s`. See `AbsolutelyMonotoneOn.iff_iteratedDerivWithin_nonneg` for the equivalence +under `UniqueDiffOn`. -/ +def AbsolutelyMonotoneOn (f : ℝ → ℝ) (s : Set ℝ) : Prop := + ∃ p : ℝ → FormalMultilinearSeries ℝ ℝ ℝ, + HasFTaylorSeriesUpToOn ∞ f p s ∧ + ∀ (n : ℕ) ⦃x : ℝ⦄, x ∈ s → 0 ≤ p x n fun _ ↦ (1 : ℝ) + +namespace AbsolutelyMonotoneOn + +variable {f g : ℝ → ℝ} {s : Set ℝ} + +/-- An absolutely monotone function on `s` is `C^∞` on `s`. -/ +theorem contDiffOn (hf : AbsolutelyMonotoneOn f s) : ContDiffOn ℝ ∞ f s := by + obtain ⟨_, hp, _⟩ := hf + exact hp.contDiffOn + +/-- A globally `C^∞` function whose iterated derivatives are nonnegative on `s` is absolutely +monotone on `s`. The set `s` need *not* satisfy `UniqueDiffOn`. -/ +theorem of_contDiff (hf : ContDiff ℝ ∞ f) (h : ∀ n : ℕ, ∀ x ∈ s, 0 ≤ iteratedDeriv n f x) : + AbsolutelyMonotoneOn f s := by + refine ⟨ftaylorSeries ℝ f, (hf.ftaylorSeries).hasFTaylorSeriesUpToOn s, fun n x hx => ?_⟩ + exact iteratedDeriv_eq_iteratedFDeriv (𝕜 := ℝ) (f := f) ▸ h n x hx + +/-- Under `UniqueDiffOn`, a Taylor witness for an absolutely monotone function agrees with +`iteratedDerivWithin`, so the latter is nonnegative on `s`. -/ +theorem iteratedDerivWithin_nonneg (hf : AbsolutelyMonotoneOn f s) (hs : UniqueDiffOn ℝ s) + (n : ℕ) {x : ℝ} (hx : x ∈ s) : 0 ≤ iteratedDerivWithin n f s x := by + obtain ⟨p, hp, hp_nn⟩ := hf + have heq : p x n = iteratedFDerivWithin ℝ n f s x := + hp.eq_iteratedFDerivWithin_of_uniqueDiffOn (mod_cast le_top) hs hx + rw [iteratedDerivWithin_eq_iteratedFDerivWithin, ← heq] + exact hp_nn n hx + +/-- Under `UniqueDiffOn`, a function is absolutely monotone on `s` iff it is `C^∞` on `s` with +every iterated derivative within `s` nonnegative. -/ +theorem iff_iteratedDerivWithin_nonneg (hs : UniqueDiffOn ℝ s) : + AbsolutelyMonotoneOn f s ↔ + ContDiffOn ℝ ∞ f s ∧ ∀ n : ℕ, ∀ x ∈ s, 0 ≤ iteratedDerivWithin n f s x := by + refine ⟨fun hf => ⟨hf.contDiffOn, fun n x hx => hf.iteratedDerivWithin_nonneg hs n hx⟩, ?_⟩ + rintro ⟨hcont, hnn⟩ + refine ⟨ftaylorSeriesWithin ℝ f s, hcont.ftaylorSeriesWithin hs, fun n x hx => ?_⟩ + exact iteratedDerivWithin_eq_iteratedFDerivWithin (𝕜 := ℝ) (f := f) (s := s) ▸ hnn n x hx + +/-! ### Closure properties -/ + +/-- The sum of two absolutely monotone functions is absolutely monotone. -/ +theorem add (hf : AbsolutelyMonotoneOn f s) (hg : AbsolutelyMonotoneOn g s) : + AbsolutelyMonotoneOn (f + g) s := by + obtain ⟨p, hp, hp_nn⟩ := hf + obtain ⟨q, hq, hq_nn⟩ := hg + refine ⟨p + q, hp.add hq, fun n x hx => ?_⟩ + simp only [Pi.add_apply, FormalMultilinearSeries.add_apply, + ContinuousMultilinearMap.add_apply] + exact add_nonneg (hp_nn n hx) (hq_nn n hx) + +/-- A nonnegative scalar multiple of an absolutely monotone function is absolutely monotone. -/ +theorem smul {c : ℝ} (hf : AbsolutelyMonotoneOn f s) (hc : 0 ≤ c) : + AbsolutelyMonotoneOn (c • f) s := by + obtain ⟨p, hp, hp_nn⟩ := hf + -- Witness: post-composition by the CLM `y ↦ c * y`. + set T : ℝ →L[ℝ] ℝ := c • ContinuousLinearMap.id ℝ ℝ with hT + have hcomp : (T ∘ f) = c • f := by ext x; simp [hT, smul_eq_mul] + refine ⟨_, hcomp ▸ hp.continuousLinearMap_comp T, fun n x hx => ?_⟩ + simp only [ContinuousLinearMap.compContinuousMultilinearMap_coe, Function.comp_apply, hT, + ContinuousLinearMap.smul_apply, ContinuousLinearMap.id_apply, smul_eq_mul] + exact mul_nonneg hc (hp_nn n hx) + +end AbsolutelyMonotoneOn diff --git a/Mathlib/Analysis/Calculus/ContDiff/Basic.lean b/Mathlib/Analysis/Calculus/ContDiff/Basic.lean index 9ccf558790591a..8782686073b4aa 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/Basic.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/Basic.lean @@ -372,7 +372,8 @@ theorem HasFTaylorSeriesUpToOn.comp_continuousAffineMap rw [map_zero] rfl · intro m hm x hx - convert (hA m).hasFDerivAt.comp_hasFDerivWithinAt x + convert! + (hA m).hasFDerivAt.comp_hasFDerivWithinAt x ((hf.fderivWithin m hm (g x) hx).comp x g.hasFDerivWithinAt (Subset.refl _)) ext y v change p (g x) (Nat.succ m) (g.contLinear ∘ cons y v) @@ -530,7 +531,8 @@ theorem HasFTaylorSeriesUpToOn.prodMk {n : ℕ∞ω} constructor · intro x hx; rw [← hf.zero_eq x hx, ← hg.zero_eq x hx]; rfl · intro m hm x hx - convert (L m).hasFDerivAt.comp_hasFDerivWithinAt x + convert! + (L m).hasFDerivAt.comp_hasFDerivWithinAt x ((hf.fderivWithin m hm x hx).prodMk (hg.fderivWithin m hm x hx)) · intro m hm exact (L m).continuous.comp_continuousOn ((hf.cont m hm).prodMk (hg.cont m hm)) diff --git a/Mathlib/Analysis/Calculus/ContDiff/Convolution.lean b/Mathlib/Analysis/Calculus/ContDiff/Convolution.lean index 4ba4b0ebc9d423..eee8c3b135d650 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/Convolution.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/Convolution.lean @@ -115,7 +115,7 @@ variable [IsAddLeftInvariant μ] [SFinite μ] theorem _root_.HasCompactSupport.hasDerivAt_convolution_right (hf : LocallyIntegrable f₀ μ) (hcg : HasCompactSupport g₀) (hg : ContDiff 𝕜 1 g₀) (x₀ : 𝕜) : HasDerivAt (f₀ ⋆[L, μ] g₀) ((f₀ ⋆[L, μ] deriv g₀) x₀) x₀ := by - convert (hcg.hasFDerivAt_convolution_right L hf hg x₀).hasDerivAt using 1 + convert! (hcg.hasFDerivAt_convolution_right L hf hg x₀).hasDerivAt using 1 rw [convolution_precompR_apply L hf (hcg.fderiv 𝕜) (hg.continuous_fderiv one_ne_zero)] rfl @@ -322,7 +322,7 @@ theorem contDiffOn_convolution_right_with_param_aux {G : Type uP} {E' : Type uP} rintro ⟨p, y⟩ ⟨hp, hy⟩ exact hgs p y hp hy apply ih (L.precompR (P × G) :) B - convert hg.2.2 + convert! hg.2.2 | top ih => rw [contDiffOn_infty] at hg ⊢ exact fun n ↦ ih n L hgs (hg n) diff --git a/Mathlib/Analysis/Calculus/ContDiff/Defs.lean b/Mathlib/Analysis/Calculus/ContDiff/Defs.lean index 2c96fd557ada1f..9a5802b7534894 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/Defs.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/Defs.lean @@ -366,7 +366,7 @@ theorem contDiffWithinAt_succ_iff_hasFDerivWithinAt (hn : n ≠ ∞) : exact Hp.analyticOn (H'p rfl 0) apply (contDiffWithinAt_iff_of_ne_infty hn).2 refine ⟨u, ?_, fun y : E => (p y).shift, ?_⟩ - · convert @self_mem_nhdsWithin _ _ x u + · convert! @self_mem_nhdsWithin _ _ x u have : x ∈ insert x s := by simp exact insert_eq_of_mem (mem_of_mem_nhdsWithin this hu) · rw [hasFTaylorSeriesUpToOn_succ_iff_right] at Hp @@ -390,14 +390,14 @@ theorem contDiffWithinAt_succ_iff_hasFDerivWithinAt (hn : n ≠ ∞) : HasFDerivWithinAt (fun z => (continuousMultilinearCurryFin0 𝕜 E F).symm (f z)) (FormalMultilinearSeries.unshift (p' y) (f y) 1).curryLeft (v ∩ u) y rw [← Function.comp_def _ f, LinearIsometryEquiv.comp_hasFDerivWithinAt_iff'] - convert (f'_eq_deriv y hy.2).mono inter_subset_right + convert! (f'_eq_deriv y hy.2).mono inter_subset_right rw [← Hp'.zero_eq y hy.1] ext z change ((p' y 0) (init (@cons 0 (fun _ => E) z 0))) (@cons 0 (fun _ => E) z 0 (last 0)) = ((p' y 0) 0) z congr norm_num [eq_iff_true_of_subsingleton] - · convert (Hp'.mono inter_subset_left).congr fun x hx => Hp'.zero_eq x hx.1 using 1 + · convert! (Hp'.mono inter_subset_left).congr fun x hx => Hp'.zero_eq x hx.1 using 1 · ext x y change p' x 0 (init (@snoc 0 (fun _ : Fin 1 => E) 0 y)) y = p' x 0 0 y rw [init_snoc] @@ -731,7 +731,7 @@ theorem contDiffOn_of_continuousOn_differentiableOn {n : ℕ∞} simp only [ftaylorSeriesWithin, ContinuousMultilinearMap.curry0_apply, iteratedFDerivWithin_zero_apply] · intro k hk y hy - convert (Hdiff k (lt_of_lt_of_le (mod_cast hk) (mod_cast hm)) y hy).hasFDerivWithinAt + convert! (Hdiff k (lt_of_lt_of_le (mod_cast hk) (mod_cast hm)) y hy).hasFDerivWithinAt · intro k hk exact Hcont k (le_trans (mod_cast hk) (mod_cast hm)) @@ -993,7 +993,7 @@ theorem ContDiffAt.differentiableAt_iteratedFDeriv {f : E → F} {n : ℕ∞ω} {m : ℕ} {x : E} (h : ContDiffAt 𝕜 n f x) (hmn : ↑m < n) : DifferentiableAt 𝕜 (iteratedFDeriv 𝕜 m f) x := by rw [← differentiableWithinAt_univ] - convert (h.differentiableWithinAt_iteratedFDerivWithin hmn (by simp [uniqueDiffOn_univ])) + convert! (h.differentiableWithinAt_iteratedFDerivWithin hmn (by simp [uniqueDiffOn_univ])) exact iteratedFDerivWithin_univ.symm @[fun_prop] @@ -1168,7 +1168,7 @@ theorem contDiff_succ_iff_hasFDerivAt {n : ℕ} : theorem contDiff_one_iff_hasFDerivAt : ContDiff 𝕜 1 f ↔ ∃ f' : E → E →L[𝕜] F, Continuous f' ∧ ∀ x, HasFDerivAt f (f' x) x := by - convert contDiff_succ_iff_hasFDerivAt using 4; simp + convert! contDiff_succ_iff_hasFDerivAt using 4; simp theorem AnalyticOn.contDiff (hf : AnalyticOn 𝕜 f univ) : ContDiff 𝕜 n f := by rw [← contDiffOn_univ] diff --git a/Mathlib/Analysis/Calculus/ContDiff/FTaylorSeries.lean b/Mathlib/Analysis/Calculus/ContDiff/FTaylorSeries.lean index 2f15c0d70dc234..53ded4d8e91d6e 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/FTaylorSeries.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/FTaylorSeries.lean @@ -232,7 +232,7 @@ theorem HasFTaylorSeriesUpToOn.hasFDerivWithinAt (h : HasFTaylorSeriesUpToOn n f (continuousMultilinearCurryFin1 𝕜 E F (p x 1)) s x from H.congr A (A x hx) rw [LinearIsometryEquiv.comp_hasFDerivWithinAt_iff'] have : ((0 : ℕ) : ℕ∞) < n := pos_iff_ne_zero.mpr hn - convert h.fderivWithin _ this x hx + convert! h.fderivWithin _ this x hx ext y v change (p x 1) (snoc 0 y) = (p x 1) (cons y v) congr with i @@ -301,7 +301,7 @@ theorem HasFTaylorSeriesUpToOn.shift_of_succ change HasFDerivWithinAt (continuousMultilinearCurryRightEquiv' 𝕜 m E F ∘ (p · m.succ)) (p x m.succ.succ).curryRight.curryLeft s x rw [(continuousMultilinearCurryRightEquiv' 𝕜 m E F).comp_hasFDerivWithinAt_iff'] - convert H.fderivWithin _ A x hx + convert! H.fderivWithin _ A x hx ext y v change p x (m + 2) (snoc (cons y (init v)) (v (last _))) = p x (m + 2) (cons y v) rw [← cons_snoc_eq_snoc_cons, snoc_init_self] @@ -338,7 +338,7 @@ theorem hasFTaylorSeriesUpToOn_succ_nat_iff_right {n : ℕ} : ((p x).shift m.succ).curryLeft s x := Htaylor.fderivWithin _ A x hx rw [LinearIsometryEquiv.comp_hasFDerivWithinAt_iff' (f' := ((p x).shift m.succ).curryLeft)] at this - convert this + convert! this ext y v change (p x (Nat.succ (Nat.succ m))) (cons y v) = diff --git a/Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean b/Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean index a48e0ab31bdaff..c8d5ce06b8d54e 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/FaaDiBruno.lean @@ -267,7 +267,7 @@ lemma one_lt_partSize_index_zero (c : OrderedFinpartition (n + 1)) (hc : range ( c.emb (c.index 0) ⟨c.partSize (c.index 0) - 1, Nat.sub_one_lt_of_lt (c.partSize_pos _)⟩} ⊆ range (c.emb (c.index 0)) := by simp [insert_subset] simp only [emb_zero] at this - convert Nat.card_mono Subtype.finite this + convert! Nat.card_mono Subtype.finite this simp only [Nat.card_eq_fintype_card, Fintype.card_ofFinset, toFinset_singleton] apply (Finset.card_pair ?_).symm exact ((Fin.zero_le _).trans_lt (c.parts_strictMono ((pos_iff_ne_zero' (c.index 0)).mpr h))).ne @@ -383,7 +383,7 @@ def extendMiddle (c : OrderedFinpartition n) (k : Fin c.length) : OrderedFinpart · simp only [hm, ↓reduceDIte] exact strictMono_succ.comp ((c.emb_strictMono m).comp (by exact fun ⦃a b⦄ h ↦ h)) parts_strictMono := by - convert strictMono_succ.comp c.parts_strictMono with m + convert! strictMono_succ.comp c.parts_strictMono with m rcases eq_or_ne m k with rfl | hm · simp only [↓reduceDIte, update_self, add_tsub_cancel_right, comp_apply, cast_mk] let a : Fin (c.partSize m + 1) := ⟨c.partSize m, lt_add_one (c.partSize m)⟩ @@ -549,7 +549,7 @@ def eraseMiddle (c : OrderedFinpartition (n + 1)) (hc : range (c.emb 0) ≠ {0}) parts_strictMono i j hij := by simp only [Fin.lt_def] rw [← Nat.add_lt_add_iff_right (k := 1)] - convert Fin.lt_def.1 (c.parts_strictMono hij) + convert! Fin.lt_def.1 (c.parts_strictMono hij) · rcases eq_or_ne i (c.index 0) with rfl | hi -- We do not yet replace `omega` with `lia` here, as it is measurably slower. · simp only [↓reduceDIte, update_self, succ_mk, cast_mk, val_pred] @@ -1084,7 +1084,7 @@ theorem HasFTaylorSeriesUpToOn.comp {n : WithTop ℕ∞} {g : F → G} {f : E t (f x) := hg.fderivWithin c.length (cm.trans_lt hm) (f x) (h hx) have K : HasFDerivWithinAt f ((continuousMultilinearCurryFin1 𝕜 E F) (p x 1)) s x := hf.hasFDerivWithinAt hm.ne_bot hx - convert HasFDerivWithinAt.linear_multilinear_comp (J.comp x K h) I B + convert! HasFDerivWithinAt.linear_multilinear_comp (J.comp x K h) I B simp only [B, Nat.succ_eq_add_one, Fintype.sum_option, comp_apply, faaDiBruno_aux1, faaDiBruno_aux2] have B : HasFDerivWithinAt (fun x ↦ (q (f x)).taylorComp (p x) m) @@ -1095,7 +1095,7 @@ theorem HasFTaylorSeriesUpToOn.comp {n : WithTop ℕ∞} {g : F → G} {f : E ((q (f x)).compAlongOrderedFinpartition (p x) (c.extend i)) = (q (f x)).taylorComp (p x) (m + 1) by rw [← this] - convert B + convert! B ext v simp only [Nat.succ_eq_add_one, Fintype.sum_option, ContinuousMultilinearMap.curryLeft_apply, ContinuousMultilinearMap.sum_apply, ContinuousMultilinearMap.add_apply, diff --git a/Mathlib/Analysis/Calculus/ContDiff/Operations.lean b/Mathlib/Analysis/Calculus/ContDiff/Operations.lean index 0005b8008d5480..d58073bb7ec730 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/Operations.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/Operations.lean @@ -80,7 +80,7 @@ theorem hasFTaylorSeriesUpToOn_pi' {n : ℕ∞ω} : ∀ i, HasFTaylorSeriesUpToOn n (fun x => Φ x i) (fun x m => (@ContinuousLinearMap.proj 𝕜 _ ι F' _ _ _ i).compContinuousMultilinearMap (P' x m)) s := by - convert hasFTaylorSeriesUpToOn_pi (𝕜 := 𝕜) (φ := fun i x ↦ Φ x i); ext; rfl + convert! hasFTaylorSeriesUpToOn_pi (𝕜 := 𝕜) (φ := fun i x ↦ Φ x i); ext; rfl theorem contDiffWithinAt_pi : ContDiffWithinAt 𝕜 n Φ s x ↔ ∀ i, ContDiffWithinAt 𝕜 n (fun x => Φ x i) s x := by @@ -405,7 +405,7 @@ theorem iteratedFDerivWithin_fun_sum_apply {ι : Type*} {f : ι → E → F} {u {x : E} (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (h : ∀ j ∈ u, ContDiffWithinAt 𝕜 i (f j) s x) : iteratedFDerivWithin 𝕜 i (fun z ↦ ∑ j ∈ u, f j z) s x = ∑ j ∈ u, iteratedFDerivWithin 𝕜 i (f j) s x := by - convert iteratedFDerivWithin_sum_apply hs hx h + convert! iteratedFDerivWithin_sum_apply hs hx h rw [Finset.sum_apply] theorem iteratedFDeriv_sum_apply {ι : Type*} {f : ι → E → F} {u : Finset ι} {n : ℕ} {x : E} @@ -418,7 +418,7 @@ theorem iteratedFDeriv_sum_apply {ι : Type*} {f : ι → E → F} {u : Finset theorem iteratedFDeriv_fun_sum_apply {ι : Type*} {f : ι → E → F} {u : Finset ι} {n : ℕ} {x : E} (h : ∀ j ∈ u, ContDiffAt 𝕜 n (f j) x) : iteratedFDeriv 𝕜 n (fun z ↦ ∑ j ∈ u, f j z) x = ∑ j ∈ u, iteratedFDeriv 𝕜 n (f j) x := by - convert iteratedFDeriv_sum_apply h + convert! iteratedFDeriv_sum_apply h rw [Finset.sum_apply] theorem iteratedFDeriv_sum {ι : Type*} {f : ι → E → F} {u : Finset ι} {i : ℕ} @@ -867,7 +867,7 @@ theorem contDiffAt_map_inverse [CompleteSpace E] (e : E ≃L[𝕜] F) : have h₁ : ContDiff 𝕜 n O₁ := contDiff_id.clm_comp contDiff_const have h₂ : ContDiff 𝕜 n O₂ := contDiff_const.clm_comp contDiff_id refine h₁.contDiffAt.comp _ (ContDiffAt.comp _ ?_ h₂.contDiffAt) - convert contDiffAt_ringInverse 𝕜 (1 : (E →L[𝕜] E)ˣ) + convert! contDiffAt_ringInverse 𝕜 (1 : (E →L[𝕜] E)ˣ) simp [O₂, one_def] /-- At an invertible map `e : M →L[R] M₂` between Banach spaces, the operation of @@ -929,7 +929,7 @@ theorem OpenPartialHomeomorph.contDiffAt_symm [CompleteSpace E] (f : OpenPartial have h_deriv : HasFDerivAt f (e : E →L[𝕜] F) (f.symm x) := by rw [he] exact hff' (f.symm x) hxu - convert f.hasFDerivAt_symm hx.1 h_deriv + convert! f.hasFDerivAt_symm hx.1 h_deriv simp [← he] · -- Then we check that the formula, being a composition of `ContDiff` pieces, is -- itself `ContDiff` diff --git a/Mathlib/Analysis/Calculus/ContDiff/RestrictScalars.lean b/Mathlib/Analysis/Calculus/ContDiff/RestrictScalars.lean index 2e9c81530c8f24..a5c18a1e804903 100644 --- a/Mathlib/Analysis/Calculus/ContDiff/RestrictScalars.lean +++ b/Mathlib/Analysis/Calculus/ContDiff/RestrictScalars.lean @@ -80,7 +80,7 @@ to `𝕜'`. theorem ContDiffAt.restrictScalars_iteratedFDeriv_eventuallyEq (h : ContDiffAt 𝕜' n f x) : (restrictScalars 𝕜) ∘ (iteratedFDeriv 𝕜' n f) =ᶠ[𝓝 x] iteratedFDeriv 𝕜 n f := by have h' : ContDiffWithinAt 𝕜' n f Set.univ x := h - convert (h'.restrictScalars_iteratedFDerivWithin_eventuallyEq _ trivial) + convert! (h'.restrictScalars_iteratedFDerivWithin_eventuallyEq _ trivial) <;> simp [iteratedFDerivWithin_univ.symm, uniqueDiffOn_univ] /-- diff --git a/Mathlib/Analysis/Calculus/Deriv/Abs.lean b/Mathlib/Analysis/Calculus/Deriv/Abs.lean index d1c6735bbcc1db..52c70a137aea08 100644 --- a/Mathlib/Analysis/Calculus/Deriv/Abs.lean +++ b/Mathlib/Analysis/Calculus/Deriv/Abs.lean @@ -75,37 +75,37 @@ theorem hasDerivAt_abs {x : ℝ} (hx : x ≠ 0) : theorem HasStrictFDerivAt.abs_of_neg (hf : HasStrictFDerivAt f f' x) (h₀ : f x < 0) : HasStrictFDerivAt (fun x ↦ |f x|) (-f') x := by - convert (hasStrictDerivAt_abs_neg h₀).hasStrictFDerivAt.comp x hf using 1 + convert! (hasStrictDerivAt_abs_neg h₀).hasStrictFDerivAt.comp x hf using 1 ext y simp theorem HasFDerivAt.abs_of_neg (hf : HasFDerivAt f f' x) (h₀ : f x < 0) : HasFDerivAt (fun x ↦ |f x|) (-f') x := by - convert (hasDerivAt_abs_neg h₀).hasFDerivAt.comp x hf using 1 + convert! (hasDerivAt_abs_neg h₀).hasFDerivAt.comp x hf using 1 ext y simp theorem HasStrictFDerivAt.abs_of_pos (hf : HasStrictFDerivAt f f' x) (h₀ : 0 < f x) : HasStrictFDerivAt (fun x ↦ |f x|) f' x := by - convert (hasStrictDerivAt_abs_pos h₀).hasStrictFDerivAt.comp x hf using 1 + convert! (hasStrictDerivAt_abs_pos h₀).hasStrictFDerivAt.comp x hf using 1 ext y simp theorem HasFDerivAt.abs_of_pos (hf : HasFDerivAt f f' x) (h₀ : 0 < f x) : HasFDerivAt (fun x ↦ |f x|) f' x := by - convert (hasDerivAt_abs_pos h₀).hasFDerivAt.comp x hf using 1 + convert! (hasDerivAt_abs_pos h₀).hasFDerivAt.comp x hf using 1 ext y simp theorem HasStrictFDerivAt.abs (hf : HasStrictFDerivAt f f' x) (h₀ : f x ≠ 0) : HasStrictFDerivAt (fun x ↦ |f x|) ((SignType.sign (f x) : ℝ) • f') x := by - convert (hasStrictDerivAt_abs h₀).hasStrictFDerivAt.comp x hf using 1 + convert! (hasStrictDerivAt_abs h₀).hasStrictFDerivAt.comp x hf using 1 ext y simp [mul_comm] theorem HasFDerivAt.abs (hf : HasFDerivAt f f' x) (h₀ : f x ≠ 0) : HasFDerivAt (fun x ↦ |f x|) ((SignType.sign (f x) : ℝ) • f') x := by - convert (hasDerivAt_abs h₀).hasFDerivAt.comp x hf using 1 + convert! (hasDerivAt_abs h₀).hasFDerivAt.comp x hf using 1 ext y simp [mul_comm] @@ -120,12 +120,12 @@ theorem hasDerivWithinAt_abs (s : Set ℝ) {x : ℝ} (hx : x ≠ 0) : theorem HasFDerivWithinAt.abs_of_neg (hf : HasFDerivWithinAt f f' s x) (h₀ : f x < 0) : HasFDerivWithinAt (fun x ↦ |f x|) (-f') s x := by - convert (hasDerivAt_abs_neg h₀).comp_hasFDerivWithinAt x hf using 1 + convert! (hasDerivAt_abs_neg h₀).comp_hasFDerivWithinAt x hf using 1 simp theorem HasFDerivWithinAt.abs_of_pos (hf : HasFDerivWithinAt f f' s x) (h₀ : 0 < f x) : HasFDerivWithinAt (fun x ↦ |f x|) f' s x := by - convert (hasDerivAt_abs_pos h₀).comp_hasFDerivWithinAt x hf using 1 + convert! (hasDerivAt_abs_pos h₀).comp_hasFDerivWithinAt x hf using 1 simp theorem HasFDerivWithinAt.abs (hf : HasFDerivWithinAt f f' s x) diff --git a/Mathlib/Analysis/Calculus/Deriv/Add.lean b/Mathlib/Analysis/Calculus/Deriv/Add.lean index c208e50a2b6c5a..456dcd8510a1df 100644 --- a/Mathlib/Analysis/Calculus/Deriv/Add.lean +++ b/Mathlib/Analysis/Calculus/Deriv/Add.lean @@ -196,7 +196,7 @@ theorem HasDerivAtFilter.fun_sum (h : ∀ i ∈ u, HasDerivAtFilter (A i) (A' i) theorem HasDerivAtFilter.sum (h : ∀ i ∈ u, HasDerivAtFilter (A i) (A' i) L) : HasDerivAtFilter (∑ i ∈ u, A i) (∑ i ∈ u, A' i) L := by - convert HasDerivAtFilter.fun_sum h + convert! HasDerivAtFilter.fun_sum h simp theorem HasStrictDerivAt.fun_sum (h : ∀ i ∈ u, HasStrictDerivAt (A i) (A' i) x) : @@ -328,7 +328,7 @@ theorem differentiableOn_neg : DifferentiableOn 𝕜 (Neg.neg : 𝕜 → 𝕜) s lemma differentiableAt_comp_neg {a : 𝕜} : DifferentiableAt 𝕜 (fun x ↦ f (-x)) a ↔ DifferentiableAt 𝕜 f (-a) := by refine ⟨fun H ↦ ?_, fun H ↦ H.comp a differentiable_neg.differentiableAt⟩ - convert ((neg_neg a).symm ▸ H).comp (-a) differentiable_neg.differentiableAt + convert! ((neg_neg a).symm ▸ H).comp (-a) differentiable_neg.differentiableAt ext simp only [Function.comp_apply, neg_neg] @@ -460,8 +460,8 @@ lemma differentiableAt_comp_sub_const {a b : 𝕜} : lemma differentiableAt_comp_const_sub {a b : 𝕜} : DifferentiableAt 𝕜 (fun x ↦ f (b - x)) a ↔ DifferentiableAt 𝕜 f (b - a) := by refine ⟨fun H ↦ ?_, fun H ↦ H.comp a (differentiable_id.const_sub _).differentiableAt⟩ - convert ((sub_sub_cancel _ a).symm ▸ H).comp (b - a) - (differentiable_id.const_sub _).differentiableAt + convert! + ((sub_sub_cancel _ a).symm ▸ H).comp (b - a) (differentiable_id.const_sub _).differentiableAt ext simp diff --git a/Mathlib/Analysis/Calculus/Deriv/Basic.lean b/Mathlib/Analysis/Calculus/Deriv/Basic.lean index 99f63e9aa8d90e..74f4ba8a3d68de 100644 --- a/Mathlib/Analysis/Calculus/Deriv/Basic.lean +++ b/Mathlib/Analysis/Calculus/Deriv/Basic.lean @@ -771,6 +771,7 @@ theorem hasDerivWithinAt_ofNat (n : ℕ) [OfNat F n] : HasDerivWithinAt (ofNat(n theorem hasDerivAt_const : HasDerivAt (fun _ => c) 0 x := hasDerivAtFilter_const _ _ +@[simp] theorem hasDerivAt_zero : HasDerivAt (0 : 𝕜 → F) 0 x := hasDerivAtFilter_zero _ @@ -922,7 +923,7 @@ lemma HasDerivAt.comp_semilinear (hf : HasDerivAt f f' x) : let R : 𝕜 →SL[σ'] 𝕜 := ⟨σ'.toSemilinearMap, σ'.isometry.continuous⟩ have hR (k : 𝕜) : R k = σ' k := rfl rw [hasDerivAt_iff_hasFDerivAt] - convert HasFDerivAt.comp_semilinear L R (f' := toSpanSingleton 𝕜 f') ?_ + convert! HasFDerivAt.comp_semilinear L R (f' := toSpanSingleton 𝕜 f') ?_ · ext simp [R] · rwa [← hasDerivAt_iff_hasFDerivAt, hR, RingHomInvPair.comp_apply_eq] diff --git a/Mathlib/Analysis/Calculus/Deriv/Comp.lean b/Mathlib/Analysis/Calculus/Deriv/Comp.lean index 5817329ccc094e..8904a0bd28c6d9 100644 --- a/Mathlib/Analysis/Calculus/Deriv/Comp.lean +++ b/Mathlib/Analysis/Calculus/Deriv/Comp.lean @@ -161,7 +161,7 @@ theorem HasDerivAtFilter.comp_hasFDerivAtFilter {f : E → 𝕜'} {f' : E →L[ {L'' : Filter (E × E)} (hh₂ : HasDerivAtFilter h₂ h₂' L') (hf : HasFDerivAtFilter f f' L'') (hL : Tendsto (Prod.map f f) L'' L') : HasFDerivAtFilter (h₂ ∘ f) (h₂' • f') L'' := by - convert (hh₂.restrictScalars 𝕜).comp hf hL + convert! (hh₂.restrictScalars 𝕜).comp hf hL ext x simp [mul_comm] diff --git a/Mathlib/Analysis/Calculus/Deriv/Inv.lean b/Mathlib/Analysis/Calculus/Deriv/Inv.lean index 4f6215baaf24da..d2ef70ed083d9a 100644 --- a/Mathlib/Analysis/Calculus/Deriv/Inv.lean +++ b/Mathlib/Analysis/Calculus/Deriv/Inv.lean @@ -103,7 +103,7 @@ variable {c : 𝕜 → 𝕜} {c' : 𝕜} @[to_fun] theorem HasDerivWithinAt.inv (hc : HasDerivWithinAt c c' s x) (hx : c x ≠ 0) : HasDerivWithinAt (c⁻¹) (-c' / c x ^ 2) s x := by - convert (hasDerivAt_inv hx).comp_hasDerivWithinAt x hc using 1 + convert! (hasDerivAt_inv hx).comp_hasDerivWithinAt x hc using 1 ring @[to_fun] @@ -143,7 +143,7 @@ variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜 theorem HasDerivWithinAt.fun_div (hc : HasDerivWithinAt c c' s x) (hd : HasDerivWithinAt d d' s x) (hx : d x ≠ 0) : HasDerivWithinAt (fun y => c y / d y) ((c' * d x - c x * d') / d x ^ 2) s x := by - convert hc.fun_mul ((hasDerivAt_inv hx).comp_hasDerivWithinAt x hd) using 1 + convert! hc.fun_mul ((hasDerivAt_inv hx).comp_hasDerivWithinAt x hd) using 1 · simp only [div_eq_mul_inv, (· ∘ ·)] · simp [field] ring @@ -155,7 +155,7 @@ theorem HasDerivWithinAt.div (hc : HasDerivWithinAt c c' s x) (hd : HasDerivWith theorem HasStrictDerivAt.fun_div (hc : HasStrictDerivAt c c' x) (hd : HasStrictDerivAt d d' x) (hx : d x ≠ 0) : HasStrictDerivAt (fun y => c y / d y) ((c' * d x - c x * d') / d x ^ 2) x := by - convert hc.fun_mul ((hasStrictDerivAt_inv hx).comp x hd) using 1 + convert! hc.fun_mul ((hasStrictDerivAt_inv hx).comp x hd) using 1 · simp only [div_eq_mul_inv, (· ∘ ·)] · simp [field] ring diff --git a/Mathlib/Analysis/Calculus/Deriv/MeanValue.lean b/Mathlib/Analysis/Calculus/Deriv/MeanValue.lean index a996d804ec797b..2da41777d06175 100644 --- a/Mathlib/Analysis/Calculus/Deriv/MeanValue.lean +++ b/Mathlib/Analysis/Calculus/Deriv/MeanValue.lean @@ -103,12 +103,12 @@ theorem exists_ratio_hasDerivAt_eq_ratio_slope' {lfa lga lfb lgb : ℝ} have hha : Tendsto h (𝓝[>] a) (𝓝 <| lgb * lfa - lfb * lga) := by have : Tendsto h (𝓝[>] a) (𝓝 <| (lgb - lga) * lfa - (lfb - lfa) * lga) := (tendsto_const_nhds.mul hfa).sub (tendsto_const_nhds.mul hga) - convert this using 2 + convert! this using 2 ring have hhb : Tendsto h (𝓝[<] b) (𝓝 <| lgb * lfa - lfb * lga) := by have : Tendsto h (𝓝[<] b) (𝓝 <| (lgb - lga) * lfb - (lfb - lfa) * lgb) := (tendsto_const_nhds.mul hfb).sub (tendsto_const_nhds.mul hgb) - convert this using 2 + convert! this using 2 ring let h' x := (lgb - lga) * f' x - (lfb - lfa) * g' x have hhh' : ∀ x ∈ Ioo a b, HasDerivAt h (h' x) x := by diff --git a/Mathlib/Analysis/Calculus/Deriv/Mul.lean b/Mathlib/Analysis/Calculus/Deriv/Mul.lean index 931cd244bab57f..64ab0635d2cedf 100644 --- a/Mathlib/Analysis/Calculus/Deriv/Mul.lean +++ b/Mathlib/Analysis/Calculus/Deriv/Mul.lean @@ -65,11 +65,11 @@ theorem hasDerivAt_of_bilinear (hu : x ∈ tsupport v → HasDerivAt u u' x) · simpa using (B.hasFDerivAt_of_bilinear (hu hxv).hasFDerivAt (hv hxu).hasFDerivAt).hasDerivAt · have hx : x ∉ tsupport fun x ↦ B (u x) (v x) := mt (closure_mono (fun x ↦ mt fun h ↦ by simp [h]) ·) hxv - convert HasDerivAt.of_notMem_tsupport hx + convert! HasDerivAt.of_notMem_tsupport hx simp [(hv hxu).unique <| .of_notMem_tsupport hxv, image_eq_zero_of_notMem_tsupport hxv] · have hx : x ∉ tsupport fun x ↦ B (u x) (v x) := mt (closure_mono (fun x ↦ mt fun h ↦ by simp [h]) ·) hxu - convert HasDerivAt.of_notMem_tsupport hx + convert! HasDerivAt.of_notMem_tsupport hx by_cases hxv : x ∈ tsupport v · simp [image_eq_zero_of_notMem_tsupport hxu, (hu hxv).unique <| .of_notMem_tsupport hxu] · simp [image_eq_zero_of_notMem_tsupport hxu, image_eq_zero_of_notMem_tsupport hxv] @@ -299,7 +299,7 @@ theorem deriv_mul (hc : DifferentiableAt 𝕜 c x) (hd : DifferentiableAt 𝕜 d theorem HasDerivWithinAt.mul_const (hc : HasDerivWithinAt c c' s x) (d : 𝔸) : HasDerivWithinAt (fun y => c y * d) (c' * d) s x := by - convert hc.mul (hasDerivWithinAt_const x s d) using 1 + convert! hc.mul (hasDerivWithinAt_const x s d) using 1 rw [mul_zero, add_zero] theorem HasDerivAt.mul_const (hc : HasDerivAt c c' x) (d : 𝔸) : @@ -312,7 +312,7 @@ theorem hasDerivAt_mul_const (c : 𝕜) : HasDerivAt (fun x => x * c) c x := by theorem HasStrictDerivAt.mul_const (hc : HasStrictDerivAt c c' x) (d : 𝔸) : HasStrictDerivAt (fun y => c y * d) (c' * d) x := by - convert hc.mul (hasStrictDerivAt_const x d) using 1 + convert! hc.mul (hasStrictDerivAt_const x d) using 1 rw [mul_zero, add_zero] theorem derivWithin_mul_const (hc : DifferentiableWithinAt 𝕜 c s x) (d : 𝔸) : @@ -351,7 +351,7 @@ theorem deriv_mul_const_field' (v : 𝕜') : (deriv fun x => u x * v) = fun x => theorem HasDerivWithinAt.const_mul (c : 𝔸) (hd : HasDerivWithinAt d d' s x) : HasDerivWithinAt (fun y => c * d y) (c * d') s x := by - convert (hasDerivWithinAt_const x s c).mul hd using 1 + convert! (hasDerivWithinAt_const x s c).mul hd using 1 rw [zero_mul, zero_add] theorem HasDerivAt.const_mul (c : 𝔸) (hd : HasDerivAt d d' x) : @@ -364,7 +364,7 @@ theorem hasDerivAt_const_mul (c : 𝕜) : HasDerivAt (fun y => c * y) c x := by theorem HasStrictDerivAt.const_mul (c : 𝔸) (hd : HasStrictDerivAt d d' x) : HasStrictDerivAt (fun y => c * d y) (c * d') x := by - convert (hasStrictDerivAt_const _ _).mul hd using 1 + convert! (hasStrictDerivAt_const _ _).mul hd using 1 rw [zero_mul, zero_add] theorem derivWithin_const_mul (c : 𝔸) (hd : DifferentiableWithinAt 𝕜 d s x) : @@ -417,7 +417,7 @@ theorem HasDerivAt.fun_finsetProd (hf : ∀ i ∈ u, HasDerivAt (f i) (f' i) x) theorem HasDerivAt.finsetProd (hf : ∀ i ∈ u, HasDerivAt (f i) (f' i) x) : HasDerivAt (∏ i ∈ u, f i) (∑ i ∈ u, (∏ j ∈ u.erase i, f j x) • f' i) x := by - convert HasDerivAt.fun_finsetProd hf; simp + convert! HasDerivAt.fun_finsetProd hf; simp @[deprecated (since := "2026-04-08")] alias HasDerivAt.finset_prod := HasDerivAt.finsetProd @@ -431,7 +431,7 @@ alias HasDerivWithinAt.fun_finset_prod := HasDerivWithinAt.fun_finsetProd theorem HasDerivWithinAt.finsetProd (hf : ∀ i ∈ u, HasDerivWithinAt (f i) (f' i) s x) : HasDerivWithinAt (∏ i ∈ u, f i) (∑ i ∈ u, (∏ j ∈ u.erase i, f j x) • f' i) s x := by - convert HasDerivWithinAt.fun_finsetProd hf; simp + convert! HasDerivWithinAt.fun_finsetProd hf; simp @[deprecated (since := "2026-04-08")] alias HasDerivWithinAt.finset_prod := HasDerivWithinAt.finsetProd @@ -446,7 +446,7 @@ alias HasStrictDerivAt.fun_finset_prod := HasStrictDerivAt.fun_finsetProd theorem HasStrictDerivAt.finsetProd (hf : ∀ i ∈ u, HasStrictDerivAt (f i) (f' i) x) : HasStrictDerivAt (∏ i ∈ u, f i) (∑ i ∈ u, (∏ j ∈ u.erase i, f j x) • f' i) x := by - convert HasStrictDerivAt.fun_finsetProd hf; simp + convert! HasStrictDerivAt.fun_finsetProd hf; simp @[deprecated (since := "2026-04-08")] alias HasStrictDerivAt.finset_prod := HasStrictDerivAt.finsetProd @@ -476,7 +476,7 @@ alias derivWithin_fun_finset_prod := derivWithin_fun_finsetProd theorem derivWithin_finsetProd (hf : ∀ i ∈ u, DifferentiableWithinAt 𝕜 (f i) s x) : derivWithin (∏ i ∈ u, f i) s x = ∑ i ∈ u, (∏ j ∈ u.erase i, f j x) • derivWithin (f i) s x := by - convert derivWithin_fun_finsetProd hf; simp + convert! derivWithin_fun_finsetProd hf; simp @[deprecated (since := "2026-04-08")] alias derivWithin_finset_prod := derivWithin_finsetProd @@ -498,7 +498,7 @@ alias DifferentiableAt.fun_finset_prod := DifferentiableAt.fun_finsetProd @[fun_prop] theorem DifferentiableAt.finsetProd (hd : ∀ i ∈ u, DifferentiableAt 𝕜 (f i) x) : DifferentiableAt 𝕜 (∏ i ∈ u, f i) x := by - convert DifferentiableAt.fun_finsetProd hd; simp + convert! DifferentiableAt.fun_finsetProd hd; simp @[deprecated (since := "2026-04-08")] alias DifferentiableAt.finset_prod := DifferentiableAt.finsetProd @@ -516,7 +516,7 @@ alias DifferentiableWithinAt.fun_finset_prod := DifferentiableWithinAt.fun_finse @[fun_prop] theorem DifferentiableWithinAt.finsetProd (hd : ∀ i ∈ u, DifferentiableWithinAt 𝕜 (f i) s x) : DifferentiableWithinAt 𝕜 (∏ i ∈ u, f i) s x := by - convert DifferentiableWithinAt.fun_finsetProd hd; simp + convert! DifferentiableWithinAt.fun_finsetProd hd; simp @[deprecated (since := "2026-04-08")] alias DifferentiableWithinAt.finset_prod := DifferentiableWithinAt.finsetProd diff --git a/Mathlib/Analysis/Calculus/Deriv/Pi.lean b/Mathlib/Analysis/Calculus/Deriv/Pi.lean index 47d8d0e7533d1c..17a2428521779d 100644 --- a/Mathlib/Analysis/Calculus/Deriv/Pi.lean +++ b/Mathlib/Analysis/Calculus/Deriv/Pi.lean @@ -18,7 +18,7 @@ variable {𝕜 ι : Type*} [DecidableEq ι] [NontriviallyNormedField 𝕜] theorem hasDerivAt_update (x : ι → 𝕜) (i : ι) (y : 𝕜) : HasDerivAt (Function.update x i) (Pi.single i (1 : 𝕜)) y := by - convert (hasFDerivAt_update x y).hasDerivAt + convert! (hasFDerivAt_update x y).hasDerivAt ext z j rw [Pi.single, Function.update_apply] split_ifs with h diff --git a/Mathlib/Analysis/Calculus/Deriv/Star.lean b/Mathlib/Analysis/Calculus/Deriv/Star.lean index 0c49359f807a05..1d0a0f93e6b796 100644 --- a/Mathlib/Analysis/Calculus/Deriv/Star.lean +++ b/Mathlib/Analysis/Calculus/Deriv/Star.lean @@ -76,7 +76,7 @@ open scoped ComplexConjugate lemma HasDerivAt.star_conj {f : 𝕜 → F} {f' : F} (hf : HasDerivAt f f' x) : HasDerivAt (star ∘ f ∘ conj) (star f') (conj x) := by rw [hasDerivAt_iff_hasFDerivAt] - convert hf.hasFDerivAt.star_star + convert! hf.hasFDerivAt.star_star ext simp @@ -85,8 +85,8 @@ lemma HasDerivAt.star_conj {f : 𝕜 → F} {f' : F} (hf : HasDerivAt f f' x) : @[simp] lemma hasDerivAt_star_conj_iff {f : 𝕜 → F} {x : 𝕜} {f' : F} : HasDerivAt (star ∘ f ∘ conj) f' x ↔ HasDerivAt f (star f') (conj x) := - ⟨fun hf ↦ by convert hf.star_conj; simp [Function.comp_def], - fun hf ↦ by convert hf.star_conj <;> simp⟩ + ⟨fun hf ↦ by convert! hf.star_conj; simp [Function.comp_def], + fun hf ↦ by convert! hf.star_conj <;> simp⟩ /-- If `f` has derivative `f'` at `z`, then `conj ∘ f ∘ conj` has derivative `conj f'` at `conj z`. -/ @@ -110,8 +110,8 @@ lemma DifferentiableAt.star_conj {f : 𝕜 → F} (hf : DifferentiableAt 𝕜 f @[simp] lemma differentiableAt_star_conj_iff {f : 𝕜 → F} : DifferentiableAt 𝕜 (star ∘ f ∘ conj) x ↔ DifferentiableAt 𝕜 f (conj x) := - ⟨fun hf ↦ by convert hf.star_conj; simp [Function.comp_def], - fun hf ↦ by convert hf.star_conj; simp⟩ + ⟨fun hf ↦ by convert! hf.star_conj; simp [Function.comp_def], + fun hf ↦ by convert! hf.star_conj; simp⟩ /-- If `f` is differentiable at `conj z`, then `conj ∘ f ∘ conj` is differentiable at `z`. -/ lemma DifferentiableAt.conj_conj {f : 𝕜 → 𝕜} (hf : DifferentiableAt 𝕜 f x) : @@ -130,7 +130,7 @@ lemma deriv_star_conj {f : 𝕜 → F} : deriv (star ∘ f ∘ conj) = star ∘ deriv f ∘ conj := by ext z by_cases hf : DifferentiableAt 𝕜 f (conj z) - · convert hf.hasDerivAt.star_conj.deriv; simp + · convert! hf.hasDerivAt.star_conj.deriv; simp · have := differentiableAt_star_conj_iff.not.2 hf simp_all [deriv_zero_of_not_differentiableAt] diff --git a/Mathlib/Analysis/Calculus/Deriv/ZPow.lean b/Mathlib/Analysis/Calculus/Deriv/ZPow.lean index a9c2cda0c75897..4f3d64e754953d 100644 --- a/Mathlib/Analysis/Calculus/Deriv/ZPow.lean +++ b/Mathlib/Analysis/Calculus/Deriv/ZPow.lean @@ -42,7 +42,7 @@ theorem hasStrictDerivAt_zpow (m : ℤ) (x : 𝕜) (h : x ≠ 0 ∨ 0 ≤ m) : have : ∀ m : ℤ, 0 < m → HasStrictDerivAt (· ^ m) ((m : 𝕜) * x ^ (m - 1)) x := fun m hm ↦ by lift m to ℕ using hm.le simp only [zpow_natCast, Int.cast_natCast] - convert hasStrictDerivAt_pow m x using 2 + convert! hasStrictDerivAt_pow m x using 2 rw [← Int.ofNat_one, ← Int.ofNat_sub, zpow_natCast] norm_cast at hm rcases lt_trichotomy m 0 with (hm | hm | hm) @@ -50,7 +50,7 @@ theorem hasStrictDerivAt_zpow (m : ℤ) (x : 𝕜) (h : x ≠ 0 ∨ 0 ≤ m) : have := (hasStrictDerivAt_inv ?_).scomp _ (this (-m) (neg_pos.2 hm)) <;> [skip; exact zpow_ne_zero _ hx] simp only [Function.comp_def, zpow_neg, inv_inv, smul_eq_mul] at this - convert this using 1 + convert! this using 1 rw [sq, mul_inv, inv_inv, Int.cast_neg, neg_mul, neg_mul_neg, ← zpow_add₀ hx, mul_assoc, ← zpow_add₀ hx] congr diff --git a/Mathlib/Analysis/Calculus/FDeriv/Add.lean b/Mathlib/Analysis/Calculus/FDeriv/Add.lean index 87d70486e27ee5..c8f870d8d1f8bd 100644 --- a/Mathlib/Analysis/Calculus/FDeriv/Add.lean +++ b/Mathlib/Analysis/Calculus/FDeriv/Add.lean @@ -402,23 +402,23 @@ variable {ι : Type*} {u : Finset ι} {A : ι → E → F} {A' : ι → E →L[ theorem HasStrictFDerivAt.fun_sum (h : ∀ i ∈ u, HasStrictFDerivAt (A i) (A' i) x) : HasStrictFDerivAt (fun y => ∑ i ∈ u, A i y) (∑ i ∈ u, A' i) x := by simp only [hasStrictFDerivAt_iff_isLittleO] at * - convert IsLittleO.sum h + convert! IsLittleO.sum h simp [Finset.sum_sub_distrib, ContinuousLinearMap.sum_apply] @[fun_prop] theorem HasStrictFDerivAt.sum (h : ∀ i ∈ u, HasStrictFDerivAt (A i) (A' i) x) : HasStrictFDerivAt (∑ i ∈ u, A i) (∑ i ∈ u, A' i) x := by - convert HasStrictFDerivAt.fun_sum h; simp + convert! HasStrictFDerivAt.fun_sum h; simp theorem HasFDerivAtFilter.fun_sum (h : ∀ i ∈ u, HasFDerivAtFilter (A i) (A' i) L) : HasFDerivAtFilter (fun y => ∑ i ∈ u, A i y) (∑ i ∈ u, A' i) L := by simp only [hasFDerivAtFilter_iff_isLittleO] at * - convert IsLittleO.sum h + convert! IsLittleO.sum h simp [ContinuousLinearMap.sum_apply] theorem HasFDerivAtFilter.sum (h : ∀ i ∈ u, HasFDerivAtFilter (A i) (A' i) L) : HasFDerivAtFilter (∑ i ∈ u, A i) (∑ i ∈ u, A' i) L := by - convert HasFDerivAtFilter.fun_sum h; simp + convert! HasFDerivAtFilter.fun_sum h; simp @[fun_prop] theorem HasFDerivWithinAt.fun_sum (h : ∀ i ∈ u, HasFDerivWithinAt (A i) (A' i) s x) : diff --git a/Mathlib/Analysis/Calculus/FDeriv/Analytic.lean b/Mathlib/Analysis/Calculus/FDeriv/Analytic.lean index 927f191ab2c285..a2f38ed508b71f 100644 --- a/Mathlib/Analysis/Calculus/FDeriv/Analytic.lean +++ b/Mathlib/Analysis/Calculus/FDeriv/Analytic.lean @@ -182,7 +182,7 @@ theorem HasFPowerSeriesWithinOnBall.hasFDerivWithinAt [CompleteSpace F] HasFDerivWithinAt f (continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1)) (insert x s) (x + y) := by rcases eq_or_ne y 0 with rfl | h''y - · convert (h.changeOrigin hy h'y).hasFPowerSeriesWithinAt.hasFDerivWithinAt + · convert! (h.changeOrigin hy h'y).hasFPowerSeriesWithinAt.hasFDerivWithinAt simp · have Z := (h.changeOrigin hy h'y).hasFPowerSeriesWithinAt.hasFDerivWithinAt apply (Z.mono (subset_insert _ _)).mono_of_mem_nhdsWithin @@ -245,7 +245,7 @@ protected theorem HasFPowerSeriesWithinOnBall.fderivWithin_of_mem [CompleteSpace HasFPowerSeriesWithinOnBall (fderivWithin 𝕜 f s) p.derivSeries s x r := by have : insert x s = s := insert_eq_of_mem hx rw [← this] at hu - convert h.fderivWithin hu + convert! h.fderivWithin hu exact this.symm /-- If a function is analytic on a set `s`, so is its Fréchet derivative. -/ @@ -274,7 +274,7 @@ protected theorem AnalyticOnNhd.iteratedFDeriv [CompleteSpace F] (h : AnalyticOn | succ n IH => rw [iteratedFDeriv_succ_eq_comp_left] -- Porting note: for reasons that I do not understand at all, `?g` cannot be inlined. - convert ContinuousLinearMap.comp_analyticOnNhd ?g IH.fderiv + convert! ContinuousLinearMap.comp_analyticOnNhd ?g IH.fderiv case g => exact ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (n + 1) ↦ E) F).symm simp @@ -328,7 +328,7 @@ theorem HasFPowerSeriesWithinOnBall.hasSum_derivSeries_of_hasFDerivWithinAt apply HasFDerivWithinAt.fderivWithin _ (hu _ h'y) exact a.hasFDerivAt.comp_hasFDerivWithinAt (x + y) hf' rw [this] at Z - convert Z with n + convert! Z with n ext v simp only [FormalMultilinearSeries.derivSeries, ContinuousLinearMap.coe_sum', Finset.sum_apply, ContinuousLinearMap.compFormalMultilinearSeries_apply, @@ -542,7 +542,7 @@ theorem CPolynomialOn.iteratedFDeriv (h : CPolynomialOn 𝕜 f s) (n : ℕ) : exact ((continuousMultilinearCurryFin0 𝕜 E F).symm : F →L[𝕜] E [×0]→L[𝕜] F).comp_cpolynomialOn h | succ n IH => rw [iteratedFDeriv_succ_eq_comp_left] - convert ContinuousLinearMap.comp_cpolynomialOn ?g IH.fderiv + convert! ContinuousLinearMap.comp_cpolynomialOn ?g IH.fderiv case g => exact ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (n + 1) ↦ E) F).symm simp @@ -616,7 +616,7 @@ theorem changeOrigin_toFormalMultilinearSeries [DecidableEq ι] : protected theorem hasStrictFDerivAt [DecidableEq ι] : HasStrictFDerivAt f (f.linearDeriv x) x := by rw [← changeOrigin_toFormalMultilinearSeries] - convert f.hasFiniteFPowerSeriesOnBall.hasStrictFDerivAt (y := x) ENNReal.coe_lt_top + convert! f.hasFiniteFPowerSeriesOnBall.hasStrictFDerivAt (y := x) ENNReal.coe_lt_top rw [zero_add] protected theorem hasFDerivAt [DecidableEq ι] : HasFDerivAt f (f.linearDeriv x) x := @@ -630,7 +630,7 @@ protected theorem hasStrictFDerivAt_uncurry [DecidableEq ι] |>.continuousMultilinearMapOption have Hf := (f.hasStrictFDerivAt (fun _ ↦ fa)).comp (f := fun fx _ ↦ fx) fa (hasStrictFDerivAt_pi.2 fun _ ↦ hasStrictFDerivAt_id _) - convert Hf using 1 + convert! Hf using 1 ext g · suffices ∑ i, fa.1 (Function.update fa.2 i 0) = ∑ i, fa.1 fun j ↦ (Function.update (fun _ ↦ fa) (some i) (g, 0) (some j)).2 j by @@ -653,8 +653,9 @@ theorem _root_.HasStrictFDerivAt.continuousMultilinearMap_apply {G : Type*} HasStrictFDerivAt (fun x ↦ f x (g · x)) (ContinuousMultilinearMap.apply 𝕜 E F (g · x) ∘L f' + ∑ i, (f x).toContinuousLinearMap (g · x) i ∘L g' i) x := by - convert ContinuousMultilinearMap.hasStrictFDerivAt_uncurry (f x, (g · x)) - |>.comp x (hf.prodMk (hasStrictFDerivAt_pi.2 hg)) + convert! + ContinuousMultilinearMap.hasStrictFDerivAt_uncurry (f x, (g · x)) |>.comp x + (hf.prodMk (hasStrictFDerivAt_pi.2 hg)) ext simp @@ -666,8 +667,10 @@ theorem _root_.HasFDerivWithinAt.continuousMultilinearMap_apply {G : Type*} HasFDerivWithinAt (fun x ↦ f x (g · x)) (ContinuousMultilinearMap.apply 𝕜 E F (g · x) ∘L f' + ∑ i, (f x).toContinuousLinearMap (g · x) i ∘L g' i) s x := by - convert ContinuousMultilinearMap.hasStrictFDerivAt_uncurry (f x, (g · x)) - |>.hasFDerivAt.comp_hasFDerivWithinAt x (hf.prodMk (hasFDerivWithinAt_pi.2 hg)) + convert! + ContinuousMultilinearMap.hasStrictFDerivAt_uncurry + (f x, (g · x)) |>.hasFDerivAt.comp_hasFDerivWithinAt + x (hf.prodMk (hasFDerivWithinAt_pi.2 hg)) ext simp @@ -794,7 +797,7 @@ theorem derivSeries_apply_diag (n : ℕ) (x : E) : compContinuousMultilinearMap_coe, ContinuousLinearEquiv.coe_coe, LinearIsometryEquiv.coe_coe, Function.comp_apply, ContinuousMultilinearMap.sum_apply, map_sum, coe_sum', Finset.sum_apply, continuousMultilinearCurryFin1_apply, Matrix.zero_empty] - convert Finset.sum_const _ + convert! Finset.sum_const _ · rw [Fin.snoc_zero, changeOriginSeriesTerm_apply, Finset.piecewise_same, add_comm] · rw [← card, card_subtype, ← Finset.powerset_univ, ← Finset.powersetCard_eq_filter, Finset.card_powersetCard, ← card, card_fin, eq_comm, add_comm, Nat.choose_succ_self_right] @@ -847,7 +850,7 @@ theorem factorial_smul (n : ℕ) : theorem hasSum_iteratedFDeriv [CharZero 𝕜] {y : E} (hy : y ∈ Metric.eball 0 r) : HasSum (fun n ↦ (n ! : 𝕜)⁻¹ • iteratedFDeriv 𝕜 n f x fun _ ↦ y) (f (x + y)) := by - convert h.hasSum hy with n + convert! h.hasSum hy with n rw [← h.factorial_smul y n, smul_comm, ← smul_assoc, nsmul_eq_mul, mul_inv_cancel₀ <| cast_ne_zero.mpr n.factorial_ne_zero, one_smul] diff --git a/Mathlib/Analysis/Calculus/FDeriv/ContinuousAlternatingMap.lean b/Mathlib/Analysis/Calculus/FDeriv/ContinuousAlternatingMap.lean index 80d8efd9fab5e1..51b8a804c12d29 100644 --- a/Mathlib/Analysis/Calculus/FDeriv/ContinuousAlternatingMap.lean +++ b/Mathlib/Analysis/Calculus/FDeriv/ContinuousAlternatingMap.lean @@ -86,16 +86,17 @@ theorem HasFDerivAt.continuousAlternatingMapCompContinuousLinearMap HasFDerivAt (fun x ↦ (f x).compContinuousLinearMap (g x)) (compContinuousLinearMapCLM (g x) ∘L f' + (f x).fderivCompContinuousLinearMap (g x) ∘L g') x := by - convert hasStrictFDerivAt_compContinuousLinearMap (f x, (g x)) |>.hasFDerivAt - |>.comp x (hf.prodMk hg) + convert! + hasStrictFDerivAt_compContinuousLinearMap (f x, (g x)) |>.hasFDerivAt |>.comp x (hf.prodMk hg) theorem HasFDerivWithinAt.continuousAlternatingMapCompContinuousLinearMap (hf : HasFDerivWithinAt f f' s x) (hg : HasFDerivWithinAt g g' s x) : HasFDerivWithinAt (fun x ↦ (f x).compContinuousLinearMap (g x)) (compContinuousLinearMapCLM (g x) ∘L f' + (f x).fderivCompContinuousLinearMap (g x) ∘L g') s x := by - convert hasStrictFDerivAt_compContinuousLinearMap (f x, (g x)) |>.hasFDerivAt - |>.comp_hasFDerivWithinAt x (hf.prodMk hg) + convert! + hasStrictFDerivAt_compContinuousLinearMap (f x, (g x)) |>.hasFDerivAt |>.comp_hasFDerivWithinAt + x (hf.prodMk hg) theorem fderivWithin_continuousAlternatingMapCompContinuousLinearMap (hf : DifferentiableWithinAt 𝕜 f s x) (hg : DifferentiableWithinAt 𝕜 g s x) diff --git a/Mathlib/Analysis/Calculus/FDeriv/ContinuousMultilinearMap.lean b/Mathlib/Analysis/Calculus/FDeriv/ContinuousMultilinearMap.lean index 1a0341c1b2ef17..09fe25ff901c5f 100644 --- a/Mathlib/Analysis/Calculus/FDeriv/ContinuousMultilinearMap.lean +++ b/Mathlib/Analysis/Calculus/FDeriv/ContinuousMultilinearMap.lean @@ -65,7 +65,7 @@ theorem ContinuousMultilinearMap.hasStrictFDerivAt_compContinuousLinearMap fg.1.fderivCompContinuousLinearMap fg.2 ∘L .snd _ _ _) fg := by have := (compContinuousLinearMapContinuousMultilinear 𝕜 F G H).hasStrictFDerivAt fg.2 - convert this.comp fg hasStrictFDerivAt_snd |>.clm_apply hasStrictFDerivAt_fst + convert! this.comp fg hasStrictFDerivAt_snd |>.clm_apply hasStrictFDerivAt_fst ext <;> simp [fderivCompContinuousLinearMap] theorem HasStrictFDerivAt.continuousMultilinearMapCompContinuousLinearMap @@ -81,16 +81,19 @@ theorem HasFDerivAt.continuousMultilinearMapCompContinuousLinearMap HasFDerivAt (fun x ↦ (f x).compContinuousLinearMap (g · x)) (compContinuousLinearMapL (g · x) ∘L f' + (f x).fderivCompContinuousLinearMap (g · x) ∘L .pi g') x := by - convert hasStrictFDerivAt_compContinuousLinearMap (f x, (g · x)) |>.hasFDerivAt - |>.comp x (hf.prodMk (hasFDerivAt_pi.2 hg)) + convert! + hasStrictFDerivAt_compContinuousLinearMap (f x, (g · x)) |>.hasFDerivAt |>.comp x + (hf.prodMk (hasFDerivAt_pi.2 hg)) theorem HasFDerivWithinAt.continuousMultilinearMapCompContinuousLinearMap (hf : HasFDerivWithinAt f f' s x) (hg : ∀ i, HasFDerivWithinAt (g i) (g' i) s x) : HasFDerivWithinAt (fun x ↦ (f x).compContinuousLinearMap (g · x)) (compContinuousLinearMapL (g · x) ∘L f' + (f x).fderivCompContinuousLinearMap (g · x) ∘L .pi g') s x := by - convert hasStrictFDerivAt_compContinuousLinearMap (f x, (g · x)) |>.hasFDerivAt - |>.comp_hasFDerivWithinAt x (hf.prodMk (hasFDerivWithinAt_pi.2 hg)) + convert! + hasStrictFDerivAt_compContinuousLinearMap + (f x, (g · x)) |>.hasFDerivAt |>.comp_hasFDerivWithinAt + x (hf.prodMk (hasFDerivWithinAt_pi.2 hg)) theorem fderivWithin_continuousMultilinearMapCompContinuousLinearMap (hf : DifferentiableWithinAt 𝕜 f s x) (hg : ∀ i, DifferentiableWithinAt 𝕜 (g i) s x) diff --git a/Mathlib/Analysis/Calculus/FDeriv/Equiv.lean b/Mathlib/Analysis/Calculus/FDeriv/Equiv.lean index ebc8b559e4cd49..d383e0571d7875 100644 --- a/Mathlib/Analysis/Calculus/FDeriv/Equiv.lean +++ b/Mathlib/Analysis/Calculus/FDeriv/Equiv.lean @@ -107,7 +107,7 @@ theorem comp_hasFDerivWithinAt_iff {f : G → E} {s : Set G} {x : G} {f' : G → theorem comp_hasStrictFDerivAt_iff {f : G → E} {x : G} {f' : G →L[𝕜] E} : HasStrictFDerivAt (iso ∘ f) ((iso : E →L[𝕜] F).comp f') x ↔ HasStrictFDerivAt f f' x := by refine ⟨fun H => ?_, fun H => iso.hasStrictFDerivAt.comp x H⟩ - convert iso.symm.hasStrictFDerivAt.comp x H using 1 <;> + convert! iso.symm.hasStrictFDerivAt.comp x H using 1 <;> ext z <;> apply (iso.symm_apply_apply _).symm theorem comp_hasFDerivAt_iff {f : G → E} {x : G} {f' : G →L[𝕜] E} : diff --git a/Mathlib/Analysis/Calculus/FDeriv/Measurable.lean b/Mathlib/Analysis/Calculus/FDeriv/Measurable.lean index 84564b73eab3b1..605dd565d39f79 100644 --- a/Mathlib/Analysis/Calculus/FDeriv/Measurable.lean +++ b/Mathlib/Analysis/Calculus/FDeriv/Measurable.lean @@ -373,7 +373,7 @@ variable [CompleteSpace F] Borel-measurable. -/ theorem measurableSet_of_differentiableAt : MeasurableSet { x | DifferentiableAt 𝕜 f x } := by have : IsComplete (univ : Set (E →L[𝕜] F)) := complete_univ - convert measurableSet_of_differentiableAt_of_isComplete 𝕜 f this + convert! measurableSet_of_differentiableAt_of_isComplete 𝕜 f this simp @[fun_prop] @@ -701,7 +701,7 @@ Borel-measurable. -/ theorem measurableSet_of_differentiableWithinAt_Ici : MeasurableSet { x | DifferentiableWithinAt ℝ f (Ici x) x } := by have : IsComplete (univ : Set F) := complete_univ - convert measurableSet_of_differentiableWithinAt_Ici_of_isComplete f this + convert! measurableSet_of_differentiableWithinAt_Ici_of_isComplete f this simp @[fun_prop] @@ -859,7 +859,7 @@ lemma isOpen_B_with_param {r s t : ℝ} (hf : Continuous f.uncurry) (K : Set (E IsOpen {p : α × E | p.2 ∈ B (f p.1) K r s t} := by suffices H : IsOpen (⋃ L ∈ K, {p : α × E | p.2 ∈ A (f p.1) L r t ∧ p.2 ∈ A (f p.1) L s t}) by - convert H; ext p; simp [B] + convert! H; ext p; simp [B] refine isOpen_biUnion (fun L _ ↦ ?_) exact (isOpen_A_with_param hf L).inter (isOpen_A_with_param hf L) @@ -894,7 +894,7 @@ values in a complete space is Borel-measurable. -/ theorem measurableSet_of_differentiableAt_with_param (hf : Continuous f.uncurry) : MeasurableSet {p : α × E | DifferentiableAt 𝕜 (f p.1) p.2} := by have : IsComplete (univ : Set (E →L[𝕜] F)) := complete_univ - convert measurableSet_of_differentiableAt_of_isComplete_with_param hf this + convert! measurableSet_of_differentiableAt_of_isComplete_with_param hf this simp theorem measurable_fderiv_with_param (hf : Continuous f.uncurry) : diff --git a/Mathlib/Analysis/Calculus/FDeriv/Mul.lean b/Mathlib/Analysis/Calculus/FDeriv/Mul.lean index 7f4a5277b96fff..221f2d046450c0 100644 --- a/Mathlib/Analysis/Calculus/FDeriv/Mul.lean +++ b/Mathlib/Analysis/Calculus/FDeriv/Mul.lean @@ -176,7 +176,7 @@ theorem HasStrictFDerivAt.mul' {x : E} (ha : HasStrictFDerivAt a a' x) @[to_fun (attr := fun_prop)] theorem HasStrictFDerivAt.mul (hc : HasStrictFDerivAt c c' x) (hd : HasStrictFDerivAt d d' x) : HasStrictFDerivAt (c * d) (c x • d' + d x • c') x := by - convert hc.mul' hd + convert! hc.mul' hd ext z apply mul_comm @@ -190,7 +190,7 @@ theorem HasFDerivWithinAt.mul' (ha : HasFDerivWithinAt a a' s x) (hb : HasFDeriv @[to_fun (attr := fun_prop)] theorem HasFDerivWithinAt.mul (hc : HasFDerivWithinAt c c' s x) (hd : HasFDerivWithinAt d d' s x) : HasFDerivWithinAt (c * d) (c x • d' + d x • c') s x := by - convert hc.mul' hd + convert! hc.mul' hd ext z apply mul_comm @@ -204,7 +204,7 @@ theorem HasFDerivAt.mul' (ha : HasFDerivAt a a' x) (hb : HasFDerivAt b b' x) : @[to_fun (attr := fun_prop)] theorem HasFDerivAt.mul (hc : HasFDerivAt c c' x) (hd : HasFDerivAt d d' x) : HasFDerivAt (c * d) (c x • d' + d x • c') x := by - convert hc.mul' hd + convert! hc.mul' hd ext z apply mul_comm @@ -274,7 +274,7 @@ theorem HasStrictFDerivAt.mul_const' (ha : HasStrictFDerivAt a a' x) (b : 𝔸) @[fun_prop] theorem HasStrictFDerivAt.mul_const (hc : HasStrictFDerivAt c c' x) (d : 𝔸') : HasStrictFDerivAt (fun y => c y * d) (d • c') x := by - convert hc.mul_const' d + convert! hc.mul_const' d ext z apply mul_comm @@ -286,7 +286,7 @@ theorem HasFDerivWithinAt.mul_const' (ha : HasFDerivWithinAt a a' s x) (b : 𝔸 @[fun_prop] theorem HasFDerivWithinAt.mul_const (hc : HasFDerivWithinAt c c' s x) (d : 𝔸') : HasFDerivWithinAt (fun y => c y * d) (d • c') s x := by - convert hc.mul_const' d + convert! hc.mul_const' d ext z apply mul_comm @@ -298,7 +298,7 @@ theorem HasFDerivAt.mul_const' (ha : HasFDerivAt a a' x) (b : 𝔸) : @[fun_prop] theorem HasFDerivAt.mul_const (hc : HasFDerivAt c c' x) (d : 𝔸') : HasFDerivAt (fun y => c y * d) (d • c') x := by - convert hc.mul_const' d + convert! hc.mul_const' d ext z apply mul_comm @@ -683,7 +683,7 @@ theorem fderiv_inverse (x : Rˣ) : fderiv 𝕜 (@Ring.inverse R _) x = -mulLeftR theorem hasStrictFDerivAt_ringInverse (x : Rˣ) : HasStrictFDerivAt Ring.inverse (-mulLeftRight 𝕜 R ↑x⁻¹ ↑x⁻¹) x := by - convert (analyticAt_inverse (𝕜 := 𝕜) x).hasStrictFDerivAt + convert! (analyticAt_inverse (𝕜 := 𝕜) x).hasStrictFDerivAt exact (fderiv_inverse x).symm variable {h : E → R} {z : E} {S : Set E} diff --git a/Mathlib/Analysis/Calculus/FDeriv/Norm.lean b/Mathlib/Analysis/Calculus/FDeriv/Norm.lean index b6bcdb7896031e..e2d0003e6a7904 100644 --- a/Mathlib/Analysis/Calculus/FDeriv/Norm.lean +++ b/Mathlib/Analysis/Calculus/FDeriv/Norm.lean @@ -62,7 +62,7 @@ theorem ContDiffAt.contDiffAt_norm_smul (ht : t ≠ 0) (h : ContDiffAt ℝ n ( have h1 : ContDiffAt ℝ n (fun y ↦ t⁻¹ • y) (t • x) := (contDiff_const_smul t⁻¹).contDiffAt have h2 : ContDiffAt ℝ n (fun y ↦ |t| * ‖y‖) x := h.const_smul |t| conv at h2 => enter [4]; rw [← one_smul ℝ x, ← inv_mul_cancel₀ ht, mul_smul] - convert h2.comp (t • x) h1 using 1 + convert! h2.comp (t • x) h1 using 1 ext y simp only [Function.comp_apply] rw [norm_smul, ← mul_assoc, norm_eq_abs, ← abs_mul, mul_inv_cancel₀ ht, abs_one, one_mul] @@ -71,7 +71,7 @@ theorem contDiffAt_norm_smul_iff (ht : t ≠ 0) : ContDiffAt ℝ n (‖·‖) x ↔ ContDiffAt ℝ n (‖·‖) (t • x) where mp h := h.contDiffAt_norm_smul ht mpr hd := by - convert hd.contDiffAt_norm_smul (inv_ne_zero ht) + convert! hd.contDiffAt_norm_smul (inv_ne_zero ht) rw [smul_smul, inv_mul_cancel₀ ht, one_smul] theorem ContDiffAt.contDiffAt_norm_of_smul (h : ContDiffAt ℝ n (‖·‖) (t • x)) : @@ -95,7 +95,7 @@ theorem HasStrictFDerivAt.hasStrictFDerivAt_norm_smul hasStrictFDerivAt_id (t • x) |>.const_smul t⁻¹ have h2 : HasStrictFDerivAt (fun y ↦ |t| * ‖y‖) (|t| • f) x := h.const_smul |t| conv at h2 => enter [3]; rw [← one_smul ℝ x, ← inv_mul_cancel₀ ht, mul_smul] - convert h2.comp (t • x) h1 with y + convert! h2.comp (t • x) h1 with y · rw [norm_smul, ← mul_assoc, norm_eq_abs, ← abs_mul, mul_inv_cancel₀ ht, abs_one, one_mul] ext y simp only [coe_smul', Pi.smul_apply, smul_eq_mul, comp_smulₛₗ, map_inv₀, RingHom.id_apply, @@ -119,7 +119,7 @@ theorem HasFDerivAt.hasFDerivAt_norm_smul hasFDerivAt_id (t • x) |>.const_smul t⁻¹ have h2 : HasFDerivAt (fun y ↦ |t| * ‖y‖) (|t| • f) x := h.const_smul |t| conv at h2 => enter [3]; rw [← one_smul ℝ x, ← inv_mul_cancel₀ ht, mul_smul] - convert h2.comp (t • x) h1 using 2 with y + convert! h2.comp (t • x) h1 using 2 with y · simp only [Function.comp_apply] rw [norm_smul, ← mul_assoc, norm_eq_abs, ← abs_mul, mul_inv_cancel₀ ht, abs_one, one_mul] · ext y @@ -141,7 +141,7 @@ theorem differentiableAt_norm_smul (ht : t ≠ 0) : DifferentiableAt ℝ (‖·‖) x ↔ DifferentiableAt ℝ (‖·‖) (t • x) where mp hd := (hd.hasFDerivAt.hasFDerivAt_norm_smul ht).differentiableAt mpr hd := by - convert (hd.hasFDerivAt.hasFDerivAt_norm_smul (inv_ne_zero ht)).differentiableAt + convert! (hd.hasFDerivAt.hasFDerivAt_norm_smul (inv_ne_zero ht)).differentiableAt rw [smul_smul, inv_mul_cancel₀ ht, one_smul] theorem DifferentiableAt.differentiableAt_norm_of_smul (h : DifferentiableAt ℝ (‖·‖) (t • x)) : diff --git a/Mathlib/Analysis/Calculus/FDeriv/Symmetric.lean b/Mathlib/Analysis/Calculus/FDeriv/Symmetric.lean index 5cb50a282a9eb6..97ce608ae1fb7e 100644 --- a/Mathlib/Analysis/Calculus/FDeriv/Symmetric.lean +++ b/Mathlib/Analysis/Calculus/FDeriv/Symmetric.lean @@ -178,7 +178,7 @@ theorem IsSymmSndFDerivWithinAt.iteratedFDerivWithin_cons {x v w : E} iteratedFDerivWithin 𝕜 2 f s x ![v, w] = iteratedFDerivWithin 𝕜 2 f s x ![w, v] := by simp_rw [isSymmSndFDerivWithinAt_iff_iteratedFDerivWithin hs hx, ContinuousMultilinearMap.ext_iff, ContinuousMultilinearMap.domDomCongr_apply] at hf - convert hf ![w, v] using 2 + convert! hf ![w, v] using 2 ext i fin_cases i <;> simp @@ -249,7 +249,7 @@ theorem Convex.taylor_approx_two_segment {v w : E} (hv : x + v ∈ interior s) rw [← smul_smul] apply s_conv.interior.add_smul_mem this _ ht rw [add_assoc] at hw - convert s_conv.add_smul_mem_interior xs hw ⟨hpos, h_lt_1.le⟩ using 1 + convert! s_conv.add_smul_mem_interior xs hw ⟨hpos, h_lt_1.le⟩ using 1 module -- define a function `g` on `[0,1]` (identified with `[v, v + w]`) such that `g 1 - g 0` is the -- quantity to be estimated. We will check that its derivative is given by an explicit @@ -273,7 +273,7 @@ theorem Convex.taylor_approx_two_segment {v w : E} (hv : x + v ∈ interior s) · apply_rules [HasDerivAt.hasDerivWithinAt, HasDerivAt.smul_const, hasDerivAt_mul_const] · suffices H : HasDerivWithinAt (fun u => ((u * h) ^ 2 / 2) • f'' w w) ((((2 : ℕ) : ℝ) * (t * h) ^ (2 - 1) * (1 * h) / 2) • f'' w w) (Icc 0 1) t by - convert H using 2 + convert! H using 2 ring apply_rules [HasDerivAt.hasDerivWithinAt, HasDerivAt.smul_const, hasDerivAt_id', HasDerivAt.pow, HasDerivAt.mul_const] @@ -316,7 +316,7 @@ theorem Convex.taylor_approx_two_segment {v w : E} (hv : x + v ∈ interior s) have I : ‖g 1 - g 0‖ ≤ ε * ((‖v‖ + ‖w‖) * ‖w‖) * h ^ 2 := by simpa only [mul_one, sub_zero] using norm_image_sub_le_of_norm_deriv_le_segment' g_deriv g'_bound 1 (right_mem_Icc.2 zero_le_one) - convert I using 1 + convert! I using 1 · congr 1 simp only [g, add_zero, one_mul, zero_div, zero_mul, sub_zero, zero_smul, Ne, not_false_iff, zero_pow, reduceCtorEq] @@ -336,29 +336,29 @@ theorem Convex.isLittleO_alternate_sum_square {v w : E} (h4v : x + (4 : ℝ) • have A : (1 : ℝ) / 2 ∈ Ioc (0 : ℝ) 1 := ⟨by simp, by norm_num⟩ have B : (1 : ℝ) / 2 ∈ Icc (0 : ℝ) 1 := ⟨by simp, by norm_num⟩ have h2v2w : x + (2 : ℝ) • v + (2 : ℝ) • w ∈ interior s := by - convert s_conv.interior.add_smul_sub_mem h4v h4w B using 1 + convert! s_conv.interior.add_smul_sub_mem h4v h4w B using 1 module have h2vww : x + (2 • v + w) + w ∈ interior s := by - convert h2v2w using 1 + convert! h2v2w using 1 module have h2v : x + (2 : ℝ) • v ∈ interior s := by - convert s_conv.add_smul_sub_mem_interior xs h4v A using 1 + convert! s_conv.add_smul_sub_mem_interior xs h4v A using 1 module have h2w : x + (2 : ℝ) • w ∈ interior s := by - convert s_conv.add_smul_sub_mem_interior xs h4w A using 1 + convert! s_conv.add_smul_sub_mem_interior xs h4w A using 1 module have hvw : x + (v + w) ∈ interior s := by - convert s_conv.add_smul_sub_mem_interior xs h2v2w A using 1 + convert! s_conv.add_smul_sub_mem_interior xs h2v2w A using 1 module have h2vw : x + (2 • v + w) ∈ interior s := by - convert s_conv.interior.add_smul_sub_mem h2v h2v2w B using 1 + convert! s_conv.interior.add_smul_sub_mem h2v h2v2w B using 1 module have hvww : x + (v + w) + w ∈ interior s := by - convert s_conv.interior.add_smul_sub_mem h2w h2v2w B using 1 + convert! s_conv.interior.add_smul_sub_mem h2w h2v2w B using 1 module have TA1 := s_conv.taylor_approx_two_segment hf xs hx h2vw h2vww have TA2 := s_conv.taylor_approx_two_segment hf xs hx hvw hvww - convert TA1.sub TA2 using 1 + convert! TA1.sub TA2 using 1 ext h simp only [two_smul, smul_add, ← add_assoc, map_add, ContinuousLinearMap.add_apply] @@ -372,8 +372,9 @@ theorem Convex.second_derivative_within_at_symmetric_of_mem_interior {v w : E} (h4v : x + (4 : ℝ) • v ∈ interior s) (h4w : x + (4 : ℝ) • w ∈ interior s) : f'' w v = f'' v w := by have A : (fun h : ℝ => h ^ 2 • (f'' w v - f'' v w)) =o[𝓝[>] 0] fun h => h ^ 2 := by - convert (s_conv.isLittleO_alternate_sum_square hf xs hx h4v h4w).sub - (s_conv.isLittleO_alternate_sum_square hf xs hx h4w h4v) using 1 + convert! + (s_conv.isLittleO_alternate_sum_square hf xs hx h4v h4w).sub + (s_conv.isLittleO_alternate_sum_square hf xs hx h4w h4v) using 1 ext h simp only [add_comm, smul_add, smul_sub] abel diff --git a/Mathlib/Analysis/Calculus/FormalMultilinearSeries.lean b/Mathlib/Analysis/Calculus/FormalMultilinearSeries.lean index d583ba95bba822..abe0d80a50dcb9 100644 --- a/Mathlib/Analysis/Calculus/FormalMultilinearSeries.lean +++ b/Mathlib/Analysis/Calculus/FormalMultilinearSeries.lean @@ -280,7 +280,7 @@ theorem order_zero : (0 : FormalMultilinearSeries 𝕜 E F).order = 0 := by simp theorem ne_zero_of_order_ne_zero (hp : p.order ≠ 0) : p ≠ 0 := fun h => by simp [h] at hp theorem order_eq_find [DecidablePred fun n => p n ≠ 0] (hp : ∃ n, p n ≠ 0) : - p.order = Nat.find hp := by convert Nat.sInf_def hp + p.order = Nat.find hp := by convert! Nat.sInf_def hp theorem order_eq_find' [DecidablePred fun n => p n ≠ 0] (hp : p ≠ 0) : p.order = Nat.find (FormalMultilinearSeries.ne_iff.mp hp) := @@ -319,7 +319,7 @@ theorem mkPiRing_coeff_eq (p : FormalMultilinearSeries 𝕜 𝕜 E) (n : ℕ) : @[simp] theorem apply_eq_prod_smul_coeff : p n y = (∏ i, y i) • p.coeff n := by - convert (p n).toMultilinearMap.map_smul_univ y 1 + convert! (p n).toMultilinearMap.map_smul_univ y 1 simp only [Pi.one_apply, smul_eq_mul, mul_one] theorem coeff_eq_zero : p.coeff n = 0 ↔ p n = 0 := by diff --git a/Mathlib/Analysis/Calculus/Implicit.lean b/Mathlib/Analysis/Calculus/Implicit.lean index 6ec8a5cd2b6d28..a299b7bfd3802b 100644 --- a/Mathlib/Analysis/Calculus/Implicit.lean +++ b/Mathlib/Analysis/Calculus/Implicit.lean @@ -230,7 +230,7 @@ theorem hasStrictFDerivAt_implicitFunction_fderiv : (fderiv 𝕜 (φ.implicitFunction (φ.leftFun φ.pt)) (φ.rightFun φ.pt)) (φ.rightFun φ.pt) := by have := φ.hasStrictFDerivAt.to_localInverse.comp (φ.rightFun φ.pt) ((hasStrictFDerivAt_const _ _).prodMk (hasStrictFDerivAt_id _)) - convert this + convert! this exact this.hasFDerivAt.fderiv theorem differentiableAt_implicitFunction (φ : ImplicitFunctionData 𝕜 E F G) : @@ -261,7 +261,7 @@ theorem hasStrictFDerivAt_implicitFunction (g'inv : G →L[𝕜] E) (hg'inv : φ.rightDeriv.comp g'inv = ContinuousLinearMap.id 𝕜 G) (hg'invf : φ.leftDeriv.comp g'inv = 0) : HasStrictFDerivAt (φ.implicitFunction (φ.leftFun φ.pt)) g'inv (φ.rightFun φ.pt) := by - convert φ.hasStrictFDerivAt_implicitFunction_fderiv + convert! φ.hasStrictFDerivAt_implicitFunction_fderiv ext1 x rw [eq_comm, fderiv_implicitFunction_apply_eq_iff] simp_all [DFunLike.ext_iff] @@ -423,8 +423,9 @@ theorem to_implicitFunctionOfComplemented (hf : HasStrictFDerivAt f f' a) (hf' : (hker : f'.ker.ClosedComplemented) : HasStrictFDerivAt (hf.implicitFunctionOfComplemented f f' hf' hker (f a)) f'.ker.subtypeL 0 := by - convert (implicitFunctionDataOfComplemented f f' hf hf' hker).hasStrictFDerivAt_implicitFunction - f'.ker.subtypeL _ _ + convert! + (implicitFunctionDataOfComplemented f f' hf hf' hker).hasStrictFDerivAt_implicitFunction + f'.ker.subtypeL _ _ swap · ext simp only [Classical.choose_spec hker, implicitFunctionDataOfComplemented, diff --git a/Mathlib/Analysis/Calculus/ImplicitContDiff.lean b/Mathlib/Analysis/Calculus/ImplicitContDiff.lean index 61878e05e24336..e0bdd104a1df87 100644 --- a/Mathlib/Analysis/Calculus/ImplicitContDiff.lean +++ b/Mathlib/Analysis/Calculus/ImplicitContDiff.lean @@ -43,7 +43,7 @@ theorem contDiffAt_implicitFunction {φ : ImplicitFunctionData 𝕜 E₁ E₂ F} ContDiffAt 𝕜 n φ.implicitFunction.uncurry (φ.prodFun φ.pt) := by rw [implicitFunction_def, Function.uncurry_curry, ← HasStrictFDerivAt.localInverse_def] refine ContDiffAt.to_localInverse ?_ (φ.hasStrictFDerivAt.hasFDerivAt) pn - convert hl.prodMk hr <;> simp + convert! hl.prodMk hr <;> simp end ImplicitFunctionData diff --git a/Mathlib/Analysis/Calculus/InverseFunctionTheorem/ApproximatesLinearOn.lean b/Mathlib/Analysis/Calculus/InverseFunctionTheorem/ApproximatesLinearOn.lean index 11988c4b077cf6..12be69422c973e 100644 --- a/Mathlib/Analysis/Calculus/InverseFunctionTheorem/ApproximatesLinearOn.lean +++ b/Mathlib/Analysis/Calculus/InverseFunctionTheorem/ApproximatesLinearOn.lean @@ -233,7 +233,7 @@ theorem surjOn_closedBall_of_nonlinearRightInverse · exact IH.2 _ = f'symm.nnnorm * (1 - ((c : ℝ) * f'symm.nnnorm) ^ n.succ) / (1 - (c : ℝ) * f'symm.nnnorm) * dist (f b) y := by - replace Jcf' : (1 : ℝ) - f'symm.nnnorm * c ≠ 0 := by convert Jcf' using 1; ring + replace Jcf' : (1 : ℝ) - f'symm.nnnorm * c ≠ 0 := by convert! Jcf' using 1; ring simp [field, pow_succ, -mul_eq_mul_left_iff] ring refine ⟨?_, Ign⟩ @@ -313,7 +313,7 @@ protected theorem antilipschitz (hf : ApproximatesLinearOn f (f' : E →L[𝕜] (hc : Subsingleton E ∨ c < N⁻¹) : AntilipschitzWith (N⁻¹ - c)⁻¹ (s.restrict f) := by rcases hc with hE | hc · exact AntilipschitzWith.of_subsingleton - convert (f'.antilipschitz.restrict s).add_lipschitzWith hf.lipschitz_sub hc + convert! (f'.antilipschitz.restrict s).add_lipschitzWith hf.lipschitz_sub hc simp [restrict] protected theorem injective (hf : ApproximatesLinearOn f (f' : E →L[𝕜] F) s c) diff --git a/Mathlib/Analysis/Calculus/InverseFunctionTheorem/ContDiff.lean b/Mathlib/Analysis/Calculus/InverseFunctionTheorem/ContDiff.lean index 87303606543f11..add6679659423f 100644 --- a/Mathlib/Analysis/Calculus/InverseFunctionTheorem/ContDiff.lean +++ b/Mathlib/Analysis/Calculus/InverseFunctionTheorem/ContDiff.lean @@ -69,7 +69,7 @@ theorem to_localInverse (hf : ContDiffAt 𝕂 n f a) have := hf.localInverse_apply_image hf' hn apply (hf.toOpenPartialHomeomorph f hf' hn).contDiffAt_symm (image_mem_toOpenPartialHomeomorph_target hf hf' hn) - · convert hf' - · convert hf + · convert! hf' + · convert! hf end ContDiffAt diff --git a/Mathlib/Analysis/Calculus/InverseFunctionTheorem/FiniteDimensional.lean b/Mathlib/Analysis/Calculus/InverseFunctionTheorem/FiniteDimensional.lean index 7942a00615383a..786bee9c4324cb 100644 --- a/Mathlib/Analysis/Calculus/InverseFunctionTheorem/FiniteDimensional.lean +++ b/Mathlib/Analysis/Calculus/InverseFunctionTheorem/FiniteDimensional.lean @@ -44,7 +44,7 @@ theorem exists_homeomorph_extension {E : Type*} [NormedAddCommGroup E] [NormedSp have hg : ApproximatesLinearOn g (f' : E →L[ℝ] F) univ (lipschitzExtensionConstant F * c) := by apply LipschitzOnWith.approximatesLinearOn rw [lipschitzOnWith_univ] - convert hu + convert! hu ext x simp only [g, add_sub_cancel_left, ContinuousLinearEquiv.coe_coe, Pi.sub_apply] haveI : FiniteDimensional ℝ E := f'.symm.finiteDimensional diff --git a/Mathlib/Analysis/Calculus/IteratedDeriv/Defs.lean b/Mathlib/Analysis/Calculus/IteratedDeriv/Defs.lean index b74f3bc2dae41e..301c2076a2ee07 100644 --- a/Mathlib/Analysis/Calculus/IteratedDeriv/Defs.lean +++ b/Mathlib/Analysis/Calculus/IteratedDeriv/Defs.lean @@ -312,7 +312,7 @@ differentiation operation. -/ theorem iteratedDeriv_eq_iterate : iteratedDeriv n f = deriv^[n] f := by ext x rw [← iteratedDerivWithin_univ] - convert iteratedDerivWithin_eq_iterate (F := F) + convert! iteratedDerivWithin_eq_iterate (F := F) simp [derivWithin_univ] theorem iteratedDerivWithin_of_isOpen (hs : IsOpen s) : @@ -341,7 +341,7 @@ lemma AnalyticAt.hasFPowerSeriesAt {𝕜 : Type*} [NontriviallyNormedField 𝕜] HasFPowerSeriesAt f (FormalMultilinearSeries.ofScalars 𝕜 (fun n ↦ iteratedDeriv n f x / n.factorial)) x := by obtain ⟨p, hp⟩ := h - convert hp + convert! hp obtain ⟨r, hpr⟩ := hp ext n have h_fact_smul := hpr.factorial_smul 1 diff --git a/Mathlib/Analysis/Calculus/LagrangeMultipliers.lean b/Mathlib/Analysis/Calculus/LagrangeMultipliers.lean index 1a2d30db0a7667..983f9829f75c8a 100644 --- a/Mathlib/Analysis/Calculus/LagrangeMultipliers.lean +++ b/Mathlib/Analysis/Calculus/LagrangeMultipliers.lean @@ -71,7 +71,9 @@ theorem IsLocalExtrOn.exists_linear_map_of_hasStrictFDerivAt (LinearMap.coprodEquiv ℝ) rcases e.surjective Λ' with ⟨⟨Λ, Λ₀⟩, rfl⟩ refine ⟨Λ, Λ₀, e.map_ne_zero_iff.1 h0, fun x => ?_⟩ - convert LinearMap.congr_fun (LinearMap.range_le_ker_iff.1 hΛ') x using 1 + convert! LinearMap.congr_fun (LinearMap.range_le_ker_iff.1 hΛ') x using 1 + -- squeezed `simp [mul_comm]` to speed up elaboration + -- squeezed `simp [mul_comm]` to speed up elaboration simp only [e, smul_eq_mul, LinearEquiv.trans_apply, LinearEquiv.prodCongr_apply, LinearEquiv.refl_apply, LinearMap.ringLmapEquivSelf_symm_apply, LinearMap.coprodEquiv_apply, diff --git a/Mathlib/Analysis/Calculus/LineDeriv/Basic.lean b/Mathlib/Analysis/Calculus/LineDeriv/Basic.lean index fe86d614d1312f..26b5023a3eb74e 100644 --- a/Mathlib/Analysis/Calculus/LineDeriv/Basic.lean +++ b/Mathlib/Analysis/Calculus/LineDeriv/Basic.lean @@ -303,7 +303,7 @@ theorem hasLineDerivWithinAt_congr_set (h : s =ᶠ[𝓝 x] t) : apply hasDerivWithinAt_congr_set let F := fun (t : 𝕜) ↦ x + t • v have B : ContinuousAt F 0 := by apply Continuous.continuousAt; fun_prop - have : s =ᶠ[𝓝 (F 0)] t := by convert h; simp [F] + have : s =ᶠ[𝓝 (F 0)] t := by convert! h; simp [F] exact B.preimage_mem_nhds this theorem lineDifferentiableWithinAt_congr_set (h : s =ᶠ[𝓝 x] t) : @@ -318,7 +318,7 @@ theorem lineDerivWithin_congr_set (h : s =ᶠ[𝓝 x] t) : apply derivWithin_congr_set let F := fun (t : 𝕜) ↦ x + t • v have B : ContinuousAt F 0 := by apply Continuous.continuousAt; fun_prop - have : s =ᶠ[𝓝 (F 0)] t := by convert h; simp [F] + have : s =ᶠ[𝓝 (F 0)] t := by convert! h; simp [F] exact B.preimage_mem_nhds this theorem Filter.EventuallyEq.hasLineDerivAt_iff (h : f₀ =ᶠ[𝓝 x] f₁) : @@ -326,7 +326,7 @@ theorem Filter.EventuallyEq.hasLineDerivAt_iff (h : f₀ =ᶠ[𝓝 x] f₁) : apply hasDerivAt_iff let F := fun (t : 𝕜) ↦ x + t • v have B : ContinuousAt F 0 := by apply Continuous.continuousAt; fun_prop - have : f₀ =ᶠ[𝓝 (F 0)] f₁ := by convert h; simp [F] + have : f₀ =ᶠ[𝓝 (F 0)] f₁ := by convert! h; simp [F] exact B.preimage_mem_nhds this theorem Filter.EventuallyEq.lineDifferentiableAt_iff (h : f₀ =ᶠ[𝓝 x] f₁) : @@ -503,7 +503,7 @@ theorem HasLineDerivWithinAt.smul (h : HasLineDerivWithinAt 𝕜 f f' s x v) (c have B : HasDerivWithinAt (fun t ↦ f (x + t • v)) f' s' (g 0) := by simpa [g] using h have Z := B.scomp (0 : 𝕜) A.hasDerivWithinAt (mapsTo_preimage g s') simp only [g, s', Function.comp_def, smul_eq_mul, mul_comm c, ← smul_smul] at Z - convert Z + convert! Z ext t simp [← smul_smul] diff --git a/Mathlib/Analysis/Calculus/LineDeriv/IntegrationByParts.lean b/Mathlib/Analysis/Calculus/LineDeriv/IntegrationByParts.lean index e17ed658c074d6..8340a614624533 100644 --- a/Mathlib/Analysis/Calculus/LineDeriv/IntegrationByParts.lean +++ b/Mathlib/Analysis/Calculus/LineDeriv/IntegrationByParts.lean @@ -72,13 +72,14 @@ lemma integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable_aux1 [Sig · intro t ht have : (x, t) ∈ tsupport g := tsupport_comp_subset_preimage (f := fun y ↦ (x, y)) g (by fun_prop) ht - convert (hf (x, t) this).scomp_of_eq t ((hasDerivAt_id t).add (hasDerivAt_const t (-t))) + convert! (hf (x, t) this).scomp_of_eq t ((hasDerivAt_id t).add (hasDerivAt_const t (-t))) (by simp) <;> simp · intro t ht have : (x, t) ∈ tsupport f := tsupport_comp_subset_preimage (f := fun y ↦ (x, y)) f (by fun_prop) ht - convert (hg (x, t) this).scomp_of_eq t ((hasDerivAt_id t).add (hasDerivAt_const t (-t))) - (by simp) <;> simp + convert! + (hg (x, t) this).scomp_of_eq t ((hasDerivAt_id t).add (hasDerivAt_const t (-t))) + (by simp) <;> simp _ = - ∫ x, B (f' x) (g x) ∂(μ.prod volume) := by rw [integral_neg, integral_prod _ hf'g] variable [BorelSpace E] @@ -158,7 +159,7 @@ theorem integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable (Set.ext_iff.mp (tsupport_comp_eq_preimage g L.symm.toHomeomorph) x).mp hx specialize hf (L.symm x) h2x rw [this] at hf - convert hf.of_comp using 1 + convert! hf.of_comp using 1 · simp · simp [← hL] · intro x hx @@ -167,7 +168,7 @@ theorem integral_bilinear_hasLineDerivAt_right_eq_neg_left_of_integrable (Set.ext_iff.mp (tsupport_comp_eq_preimage f L.symm.toHomeomorph) x).mp hx specialize hg (L.symm x) h2x rw [this] at hg - convert hg.of_comp using 1 + convert! hg.of_comp using 1 · simp · simp [← hL] diff --git a/Mathlib/Analysis/Calculus/LogDeriv.lean b/Mathlib/Analysis/Calculus/LogDeriv.lean index b9fd883b3618cb..90db509ede78e6 100644 --- a/Mathlib/Analysis/Calculus/LogDeriv.lean +++ b/Mathlib/Analysis/Calculus/LogDeriv.lean @@ -150,6 +150,6 @@ theorem AnalyticAt.tendsto_mul_logDeriv_simple_zero [CompleteSpace 𝕜] (𝓝[≠] x) (𝓝 1) := by have h_slope := hasDerivAt_iff_tendsto_slope.mp hf.differentiableAt.hasDerivAt rw [← div_self hf'] - convert hf.deriv.continuousAt.tendsto.mono_left nhdsWithin_le_nhds |>.div h_slope hf' using 2 + convert! hf.deriv.continuousAt.tendsto.mono_left nhdsWithin_le_nhds |>.div h_slope hf' using 2 simp [logDeriv, slope, hfx] field diff --git a/Mathlib/Analysis/Calculus/MeanValue.lean b/Mathlib/Analysis/Calculus/MeanValue.lean index 0b42a9bdeb31e3..807a954454a326 100644 --- a/Mathlib/Analysis/Calculus/MeanValue.lean +++ b/Mathlib/Analysis/Calculus/MeanValue.lean @@ -152,7 +152,7 @@ theorem image_le_of_liminf_slope_right_le_deriv_boundary {f : ℝ → ℝ} {a b exact hx intro x hx have : ContinuousWithinAt (fun r => B x + r * (x - a)) (Ioi 0) 0 := by fun_prop - convert continuousWithinAt_const.closure_le _ this (Hr x hx) using 1 <;> simp + convert! continuousWithinAt_const.closure_le _ this (Hr x hx) using 1 <;> simp /-- General fencing theorem for continuous functions with an estimate on the derivative. Let `f` and `B` be continuous functions on `[a, b]` such that @@ -317,7 +317,7 @@ theorem norm_image_sub_le_of_norm_deriv_right_le_segment {f' : ℝ → E} {C : have hB : ∀ x, HasDerivAt B C x := by intro x simpa using (hasDerivAt_const x C).mul ((hasDerivAt_id x).sub (hasDerivAt_const x a)) - convert image_norm_le_of_norm_deriv_right_le_deriv_boundary hg hg' _ hB bound + convert! image_norm_le_of_norm_deriv_right_le_deriv_boundary hg hg' _ hB bound simp only [g, B]; rw [sub_self, norm_zero, sub_self, mul_zero] /-- A function on `[a, b]` with the norm of the derivative within `[a, b]` @@ -662,9 +662,11 @@ lemma isLittleO_pow_succ {x₀ : E} {n : ℕ} (hs : Convex ℝ s) (hx₀s : x₀ gcongr exact norm_sub_le_of_mem_segment hy filter_upwards [this] with x ⟨h_segment, h⟩ - convert (convex_segment x₀ x).norm_image_sub_le_of_norm_hasFDerivWithin_le - (f := fun x ↦ f x - f x₀) (y := x) (x := x₀) (s := segment ℝ x₀ x) ?_ h - (left_mem_segment ℝ x₀ x) (right_mem_segment ℝ x₀ x) using 1 + convert! + (convex_segment x₀ x).norm_image_sub_le_of_norm_hasFDerivWithin_le (f := fun x ↦ f x - f x₀) + (y := x) (x := x₀) (s := segment ℝ x₀ x) ?_ h + (left_mem_segment ℝ x₀ x) + (right_mem_segment ℝ x₀ x) using 1 · simp · simp only [hasFDerivWithinAt_sub_const_iff] exact fun x hx ↦ (hff' x (h_segment hx)).mono h_segment @@ -677,7 +679,7 @@ theorem isLittleO_pow_succ_real {f f' : ℝ → E} {x₀ : ℝ} {n : ℕ} {s : S · rw [Asymptotics.isLittleO_iff] at h ⊢ simpa using h · rw [Asymptotics.isLittleO_iff] at hf' ⊢ - convert hf' using 4 with c hc x + convert! hf' using 4 with c hc x simp end Convex diff --git a/Mathlib/Analysis/Calculus/ParametricIntegral.lean b/Mathlib/Analysis/Calculus/ParametricIntegral.lean index dcc712ca6c90fb..0e3ea6293533a6 100644 --- a/Mathlib/Analysis/Calculus/ParametricIntegral.lean +++ b/Mathlib/Analysis/Calculus/ParametricIntegral.lean @@ -111,7 +111,7 @@ theorem hasFDerivAt_integral_of_dominated_loc_of_lip' {F' : α → H →L[𝕜] by_cases hE : CompleteSpace E; swap · rcases subsingleton_or_nontrivial H with hH | hH · have : Subsingleton (H →L[𝕜] E) := inferInstance - convert hasFDerivAt_of_subsingleton _ x₀ + convert! hasFDerivAt_of_subsingleton _ x₀ · have : ¬(CompleteSpace (H →L[𝕜] E)) := by simpa [SeparatingDual.completeSpace_continuousLinearMap_iff] using hE simp only [integral, hE, ↓reduceDIte, this] diff --git a/Mathlib/Analysis/Calculus/Rademacher.lean b/Mathlib/Analysis/Calculus/Rademacher.lean index 14b3940d46e7f2..d582d301482c81 100644 --- a/Mathlib/Analysis/Calculus/Rademacher.lean +++ b/Mathlib/Analysis/Calculus/Rademacher.lean @@ -86,7 +86,7 @@ theorem ae_lineDifferentiableAt have h's : DifferentiableAt ℝ (fun t ↦ f (p + t • v)) (s + 0) := by simpa using hs have : DifferentiableAt ℝ (fun t ↦ s + t) 0 := differentiableAt_id.const_add _ simp only [LineDifferentiableAt] - convert h's.comp 0 this with _ t + convert! h's.comp 0 this with _ t simp only [add_assoc, Function.comp_apply, add_smul] theorem locallyIntegrable_lineDeriv (hf : LipschitzWith C f) (v : E) : @@ -257,7 +257,7 @@ theorem ae_exists_fderiv_of_countable let L : StrongDual ℝ E := LinearMap.toContinuousLinearMap (B.constr ℝ (fun i ↦ lineDeriv ℝ f x (B i))) refine ⟨L, fun v hv ↦ ?_⟩ - have J : L v = lineDeriv ℝ f x v := by convert (hx v hv).symm <;> simp [L, B.sum_repr v] + have J : L v = lineDeriv ℝ f x v := by convert! (hx v hv).symm <;> simp [L, B.sum_repr v] simpa [J] using (h'x v hv).hasLineDerivAt omit [MeasurableSpace E] in diff --git a/Mathlib/Analysis/Calculus/SmoothSeries.lean b/Mathlib/Analysis/Calculus/SmoothSeries.lean index 3a2018ee9f057a..a4e9ff00e3668c 100644 --- a/Mathlib/Analysis/Calculus/SmoothSeries.lean +++ b/Mathlib/Analysis/Calculus/SmoothSeries.lean @@ -92,7 +92,7 @@ theorem hasDerivAt_tsum_of_isPreconnected (hu : Summable u) (ht : IsOpen t) (hg' : ∀ n y, y ∈ t → ‖g' n y‖ ≤ u n) (hy₀ : y₀ ∈ t) (hg0 : Summable fun n => g n y₀) (hy : y ∈ t) : HasDerivAt (fun z => ∑' n, g n z) (∑' n, g' n y) y := by simp_rw [hasDerivAt_iff_hasFDerivAt] at hg ⊢ - convert hasFDerivAt_tsum_of_isPreconnected hu ht h't hg ?_ hy₀ hg0 hy + convert! hasFDerivAt_tsum_of_isPreconnected hu ht h't hg ?_ hy₀ hg0 hy · exact (ContinuousLinearMap.smulRightL 𝕜 𝕜 F 1).map_tsum <| .of_norm_bounded hu fun n ↦ hg' n y hy · simpa diff --git a/Mathlib/Analysis/Calculus/Taylor.lean b/Mathlib/Analysis/Calculus/Taylor.lean index 90ac78008a641a..76825e8e75a768 100644 --- a/Mathlib/Analysis/Calculus/Taylor.lean +++ b/Mathlib/Analysis/Calculus/Taylor.lean @@ -140,7 +140,7 @@ theorem monomial_has_deriv_aux (t x : ℝ) (n : ℕ) : HasDerivAt (fun y => (x - y) ^ (n + 1)) (-(n + 1) * (x - t) ^ n) t := by simp_rw [sub_eq_neg_add] rw [← neg_one_mul, mul_comm (-1 : ℝ), mul_assoc, mul_comm (-1 : ℝ), ← mul_assoc] - convert ((hasDerivAt_id t).neg.add_const x).pow (n + 1) + convert! ((hasDerivAt_id t).neg.add_const x).pow (n + 1) simp only [Nat.cast_add, Nat.cast_one] theorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k : ℕ} {s t : Set ℝ} @@ -152,7 +152,7 @@ theorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k : ((k ! : ℝ)⁻¹ * (x - y) ^ k) • iteratedDerivWithin (k + 1) f s y) t y := by replace hf : HasDerivWithinAt (iteratedDerivWithin (k + 1) f s) (iteratedDerivWithin (k + 2) f s y) t y := by - convert (hf.mono_of_mem_nhdsWithin hs).hasDerivWithinAt using 1 + convert! (hf.mono_of_mem_nhdsWithin hs).hasDerivWithinAt using 1 rw [iteratedDerivWithin_succ] exact (derivWithin_of_mem_nhdsWithin hs ht hf).symm have : HasDerivWithinAt (fun t => ((k + 1 : ℝ) * k !)⁻¹ * (x - t) ^ (k + 1)) @@ -162,7 +162,7 @@ theorem hasDerivWithinAt_taylor_coeff_within {f : ℝ → E} {x y : ℝ} {k : field rw [this] exact (monomial_has_deriv_aux y x _).hasDerivWithinAt.const_mul _ - convert this.smul hf using 1 + convert! this.smul hf using 1 field_simp module @@ -191,8 +191,10 @@ theorem hasDerivWithinAt_taylorWithinEval {f : ℝ → E} {x y : ℝ} {n : ℕ} have hdiff : DifferentiableOn ℝ (iteratedDerivWithin k f s) s' := (hf.differentiableOn_iteratedDerivWithin (mod_cast coe_lt_succ) hs_unique).mono h specialize hk hf.of_succ ((hdiff y hy).mono_of_mem_nhdsWithin hs') - convert hk.add (hasDerivWithinAt_taylor_coeff_within hs'_unique - (nhdsWithin_mono _ h self_mem_nhdsWithin) hf') using 1 + convert! + hk.add + (hasDerivWithinAt_taylor_coeff_within hs'_unique (nhdsWithin_mono _ h self_mem_nhdsWithin) + hf') using 1 exact (add_sub_cancel _ _).symm /-- Calculate the derivative of the Taylor polynomial with respect to `x₀`. @@ -250,8 +252,9 @@ theorem taylor_isLittleO {f : ℝ → E} {x₀ : ℝ} {n : ℕ} {s : Set ℝ} · simp replace hs' := uniqueDiffOn_convex hs (hs.nontrivial_iff_nonempty_interior.1 hs') simp only [Nat.cast_add, Nat.cast_one] at hf - convert Convex.isLittleO_pow_succ_real hs hx₀s ?_ (h (hf.derivWithin hs' le_rfl)) - (f := fun x ↦ f x - taylorWithinEval f (n + 1) s x₀ x) using 1 + convert! + Convex.isLittleO_pow_succ_real hs hx₀s ?_ (h (hf.derivWithin hs' le_rfl)) (f := fun x ↦ + f x - taylorWithinEval f (n + 1) s x₀ x) using 1 · simp · intro x hx refine HasDerivWithinAt.sub ?_ (hasDerivAt_taylorWithinEval_succ f n).hasDerivWithinAt @@ -281,7 +284,7 @@ theorem Real.taylor_tendsto {f : ℝ → ℝ} {x₀ : ℝ} {n : ℕ} {s : Set (hs : Convex ℝ s) (hx₀s : x₀ ∈ s) (hf : ContDiffOn ℝ n f s) : Filter.Tendsto (fun x ↦ (f x - taylorWithinEval f n s x₀ x) / (x - x₀) ^ n) (𝓝[s] x₀) (𝓝 0) := by - convert _root_.taylor_tendsto hs hx₀s hf using 2 with x + convert! _root_.taylor_tendsto hs hx₀s hf using 2 with x simp [div_eq_inv_mul] @@ -479,7 +482,7 @@ theorem taylor_integral_remainder_aux [NormedAddCommGroup F] [NormedSpace ℝ F] rw [sub_add_eq_sub_sub, ih] simp only [Nat.factorial, Nat.succ_eq_add_one, Nat.cast_mul, Nat.cast_add, Nat.cast_one] have := hf (n + 1) (by rfl) - convert this.symm using 1 + convert! this.symm using 1 · simp only [sub_self, ne_eq, Nat.add_eq_zero_iff, one_ne_zero, and_false, not_false_eq_true, zero_pow, zero_div, zero_smul, zero_sub, deriv_div_const, Nat.factorial] apply fun (a b c d : F) (_ : b = c) (_ : a = -d) ↦ show a - b = -c - d by grind diff --git a/Mathlib/Analysis/Calculus/UniformLimitsDeriv.lean b/Mathlib/Analysis/Calculus/UniformLimitsDeriv.lean index 45e7bca2eba51a..2e008f60735e90 100644 --- a/Mathlib/Analysis/Calculus/UniformLimitsDeriv.lean +++ b/Mathlib/Analysis/Calculus/UniformLimitsDeriv.lean @@ -360,7 +360,7 @@ theorem hasFDerivAt_of_tendstoUniformlyOnFilter [NeBot l] apply ((this ε hε).filter_mono curry_le_prod).mono intro n hn rw [dist_eq_norm] at hn ⊢ - convert hn using 2 + convert! hn using 2 module · -- (Almost) the definition of the derivatives rw [Metric.tendsto_nhds] diff --git a/Mathlib/Analysis/Calculus/VectorField.lean b/Mathlib/Analysis/Calculus/VectorField.lean index afaf566c25c560..2f0c18003f0756 100644 --- a/Mathlib/Analysis/Calculus/VectorField.lean +++ b/Mathlib/Analysis/Calculus/VectorField.lean @@ -562,7 +562,7 @@ lemma _root_.exists_continuousLinearEquiv_fderivWithin_symm_eq have hN' : ContDiffWithinAt 𝕜 1 (fun y ↦ ((N y).symm : F →L[𝕜] E)) s x := by have : ContDiffWithinAt 𝕜 1 (ContinuousLinearMap.inverse ∘ (fun y ↦ (N y : E →L[𝕜] F))) s x := (contDiffAt_map_inverse (N x)).comp_contDiffWithinAt x hN - convert this with y + convert! this with y simp only [Function.comp_apply, ContinuousLinearMap.inverse_equiv] refine ⟨N, hN, hN', eN, fun v ↦ ?_⟩ have A' y : ContinuousLinearMap.compL 𝕜 F E F (N y : E →L[𝕜] F) ((N y).symm : F →L[𝕜] E) diff --git a/Mathlib/Analysis/Complex/AbelLimit.lean b/Mathlib/Analysis/Complex/AbelLimit.lean index f83a7ed78aef25..e5c69cb9bf16d0 100644 --- a/Mathlib/Analysis/Complex/AbelLimit.lean +++ b/Mathlib/Analysis/Complex/AbelLimit.lean @@ -233,7 +233,7 @@ theorem tendsto_tsum_powerSeries_nhdsWithin_stolzSet _ = _ := by rw [← mul_rotate, mul_div_cancel_right₀ _ (by linarith only [zn]), div_mul_cancel₀ _ (by linarith only [hM])] - convert add_lt_add S₁ S₂ using 1 + convert! add_lt_add S₁ S₂ using 1 linarith only /-- **Abel's limit theorem**. Given a power series converging at 1, the corresponding function @@ -270,7 +270,7 @@ theorem tendsto_tsum_powerSeries_nhdsWithin_lt replace h := Complex.tendsto_tsum_powerSeries_nhdsWithin_lt h rw [tendsto_map'_iff] at h rw [Metric.tendsto_nhdsWithin_nhds] at h ⊢ - convert h + convert! h simp_rw [Function.comp_apply, dist_eq_norm] norm_cast diff --git a/Mathlib/Analysis/Complex/Angle.lean b/Mathlib/Analysis/Complex/Angle.lean index 4faa1bded52fe7..85128732d363be 100644 --- a/Mathlib/Analysis/Complex/Angle.lean +++ b/Mathlib/Analysis/Complex/Angle.lean @@ -104,7 +104,7 @@ lemma norm_sub_mem_Icc_angle (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) : _ = 2 * (1 - θ.cos) := by linear_combination θ.cos_sq_add_sin_sq _ ≤ 2 * (1 - (1 - θ ^ 2 / 2)) := by gcongr; exact Real.one_sub_sq_div_two_le_cos _ = _ := by ring - · convert hθ + · convert! hθ ring /-- Chord-length is always less than arc-length. -/ diff --git a/Mathlib/Analysis/Complex/Basic.lean b/Mathlib/Analysis/Complex/Basic.lean index aff044a00312c0..56eac1c32d7a6b 100644 --- a/Mathlib/Analysis/Complex/Basic.lean +++ b/Mathlib/Analysis/Complex/Basic.lean @@ -311,8 +311,9 @@ lemma _root_.Filter.Tendsto.ofReal {α : Type*} {l : Filter α} {f : α → ℝ} /-- The only continuous ring homomorphism from `ℝ` to `ℂ` is the identity. -/ theorem ringHom_eq_ofReal_of_continuous {f : ℝ →+* ℂ} (h : Continuous f) : f = ofRealHom := by - convert congr_arg AlgHom.toRingHom <| Subsingleton.elim (AlgHom.mk' f <| map_real_smul f h) - (Algebra.ofId ℝ ℂ) + convert! + congr_arg AlgHom.toRingHom <| + Subsingleton.elim (AlgHom.mk' f <| map_real_smul f h) (Algebra.ofId ℝ ℂ) /-- Continuous linear map version of the canonical embedding of `ℝ` in `ℂ`. -/ def ofRealCLM : ℝ →L[ℝ] ℂ := diff --git a/Mathlib/Analysis/Complex/BranchLogRoot.lean b/Mathlib/Analysis/Complex/BranchLogRoot.lean index 78f13cb30db58e..2a00d8bd917320 100644 --- a/Mathlib/Analysis/Complex/BranchLogRoot.lean +++ b/Mathlib/Analysis/Complex/BranchLogRoot.lean @@ -51,7 +51,7 @@ theorem exists_continuousOn_eqOn_exp_comp (hUc : IsSimplyConnected U) (hUo : IsO refine ⟨g, ?hg_cont, ?hg_inv⟩ case hg_cont => rw [continuousOn_iff_continuous_restrict] - convert map_continuous f + convert! map_continuous f ext z exact hg z case hg_inv => diff --git a/Mathlib/Analysis/Complex/Convex.lean b/Mathlib/Analysis/Complex/Convex.lean index 7e12a67c4ea9a5..66f002d230f6ba 100644 --- a/Mathlib/Analysis/Complex/Convex.lean +++ b/Mathlib/Analysis/Complex/Convex.lean @@ -98,11 +98,12 @@ lemma Convex.rectangle_subset {U : Set ℂ} (U_convex : Convex ℝ U) {z w : ℂ instance : PathConnectedSpace ℂˣ := have : PathConnectedSpace { z : ℂ // z ≠ 0 } := (isPathConnected_iff_pathConnectedSpace (F := {0}ᶜ)).mp (by - convert (((convex_halfSpace_im_gt 0).isPathConnected ⟨.I, by simp⟩).union - ((convex_halfSpace_re_gt 0).isPathConnected ⟨1, by simp⟩) ⟨1 + .I, by simp⟩).union - (((convex_halfSpace_im_lt 0).isPathConnected ⟨-.I, by simp⟩).union - ((convex_halfSpace_re_lt 0).isPathConnected ⟨-1, by simp⟩) ⟨-1 - .I, by simp⟩) - ⟨1 - .I, by simp⟩ using 1 + convert! + (((convex_halfSpace_im_gt 0).isPathConnected ⟨.I, by simp⟩).union + ((convex_halfSpace_re_gt 0).isPathConnected ⟨1, by simp⟩) ⟨1 + .I, by simp⟩).union + (((convex_halfSpace_im_lt 0).isPathConnected ⟨-.I, by simp⟩).union + ((convex_halfSpace_re_lt 0).isPathConnected ⟨-1, by simp⟩) ⟨-1 - .I, by simp⟩) + ⟨1 - .I, by simp⟩ using 1 ext x refine ⟨?_, by aesop⟩ simp +contextual [Complex.ext_iff, -not_and, not_and_or, or_imp, ← ne_eq, ← lt_or_lt_iff_ne]) diff --git a/Mathlib/Analysis/Complex/CoveringMap.lean b/Mathlib/Analysis/Complex/CoveringMap.lean index bc7060861e9749..3ea0da9b427166 100644 --- a/Mathlib/Analysis/Complex/CoveringMap.lean +++ b/Mathlib/Analysis/Complex/CoveringMap.lean @@ -62,7 +62,7 @@ theorem Polynomial.isCoveringMapOn_eval (p : 𝕜[X]) : theorem isCoveringMapOn_npow (n : ℕ) (hn : (n : 𝕜) ≠ 0) : IsCoveringMapOn (fun x : 𝕜 ↦ x ^ n) {0}ᶜ := by - convert (X ^ n).isCoveringMapOn_eval.mono fun x' h ↦ _ with x + convert! (X ^ n).isCoveringMapOn_eval.mono fun x' h ↦ _ with x · simp · assumption · simpa [derivative_X_pow, hn, show n ≠ 0 by aesop] using fun _ ↦ Ne.symm h @@ -70,16 +70,17 @@ theorem isCoveringMapOn_npow (n : ℕ) (hn : (n : 𝕜) ≠ 0) : /-- `(· ^ n) : 𝕜 \ {0} → 𝕜 \ {0}` is a covering map (if `n ≠ 0` in `𝕜`). -/ theorem isCoveringMap_npow (n : ℕ) (hn : (n : 𝕜) ≠ 0) : IsCoveringMap fun x : {x : 𝕜 // x ≠ 0} ↦ (⟨x ^ n, pow_ne_zero n x.2⟩ : {x : 𝕜 // x ≠ 0}) := by - convert (isCoveringMapOn_npow n hn).isCoveringMap_restrictPreimage.comp_homeomorph - (.setCongr (s := {x | x ≠ 0}) _) using 1 + convert! + (isCoveringMapOn_npow n hn).isCoveringMap_restrictPreimage.comp_homeomorph + (.setCongr (s := {x | x ≠ 0}) _) using 1 ext; simp [show n ≠ 0 by aesop] /-- `(· ^ n) : 𝕜 \ {0} → 𝕜 \ {0}` is a covering map (if `n ≠ 0` in `𝕜`). -/ theorem isCoveringMap_zpow (n : ℤ) (hn : (n : 𝕜) ≠ 0) : IsCoveringMap fun x : {x : 𝕜 // x ≠ 0} ↦ (⟨x ^ n, zpow_ne_zero n x.2⟩ : {x : 𝕜 // x ≠ 0}) := by obtain ⟨n, rfl | rfl⟩ := n.eq_nat_or_neg - · convert isCoveringMap_npow n _ <;> aesop - · convert (isCoveringMap_npow n _).comp_homeomorph (.inv₀ 𝕜) + · convert! isCoveringMap_npow n _ <;> aesop + · convert! (isCoveringMap_npow n _).comp_homeomorph (.inv₀ 𝕜) · simp [Homeomorph.inv₀] · simpa using hn @@ -87,9 +88,9 @@ theorem isCoveringMapOn_zpow (n : ℤ) (hn : (n : 𝕜) ≠ 0) : IsCoveringMapOn (fun x : 𝕜 ↦ x ^ n) {0}ᶜ := by have (x : 𝕜) : x ^ n = 0 ↔ x = 0 := zpow_eq_zero_iff (by aesop) refine .of_isCoveringMap_restrictPreimage _ (by simp) ?_ ?_ - · convert isClosed_singleton (x := (0 : 𝕜)).isOpen_compl using 1 + · convert! isClosed_singleton (x := (0 : 𝕜)).isOpen_compl using 1 ext; simp [this] - · convert (isCoveringMap_zpow n hn).comp_homeomorph (.ofEqSubtypes _) using 1 + · convert! (isCoveringMap_zpow n hn).comp_homeomorph (.ofEqSubtypes _) using 1 ext; simpa using (this _).not attribute [-instance] Units.mulAction' @@ -103,7 +104,7 @@ theorem isQuotientCoveringMap_npow (n : ℕ) (hn : (n : 𝕜) ≠ 0) (by fun_prop) (.restrictPreimage _ surj) have : IsQuotientMap fun x : 𝕜ˣ ↦ x ^ n := by let e := unitsHomeomorphNeZero (G₀ := 𝕜) - convert (e.symm.isQuotientMap.comp this).comp (e.trans (.ofEqSubtypes _)).isQuotientMap + convert! (e.symm.isQuotientMap.comp this).comp (e.trans (.ofEqSubtypes _)).isQuotientMap · exact (e.left_inv _).symm · ext; simp [NeZero.ne] refine this.isQuotientCoveringMap_of_subgroup _ @@ -120,8 +121,8 @@ theorem isQuotientCoveringMap_zpow (n : ℤ) (hn : (n : 𝕜) ≠ 0) obtain ⟨n, rfl | rfl⟩ := n.eq_nat_or_neg · exact isQuotientCoveringMap_npow n (by aesop) (by simpa using surj) rw [show (zpowGroupHom (α := 𝕜ˣ) (-n)).ker = (powMonoidHom n).ker by ext; simp] - convert (isQuotientCoveringMap_npow n (by aesop) _).homeomorph_comp (.inv 𝕜ˣ) using 1 + convert! (isQuotientCoveringMap_npow n (by aesop) _).homeomorph_comp (.inv 𝕜ˣ) using 1 · ext; simp - convert inv_involutive.surjective.comp surj; simp + convert! inv_involutive.surjective.comp surj; simp end diff --git a/Mathlib/Analysis/Complex/Exponential.lean b/Mathlib/Analysis/Complex/Exponential.lean index c6040e68c47939..fe589ea2143973 100644 --- a/Mathlib/Analysis/Complex/Exponential.lean +++ b/Mathlib/Analysis/Complex/Exponential.lean @@ -93,7 +93,7 @@ variable (x y : ℂ) theorem exp_zero : exp 0 = 1 := by rw [exp] refine lim_eq_of_equiv_const fun ε ε0 => ⟨1, fun j hj => ?_⟩ - convert (config := .unfoldSameFun) ε0 -- ε0 : ε > 0 but goal is _ < ε + convert! (config := .unfoldSameFun) ε0 -- ε0 : ε > 0 but goal is _ < ε rcases j with - | j · exact absurd hj (not_le_of_gt zero_lt_one) · dsimp [exp'] @@ -475,7 +475,7 @@ lemma norm_exp_sub_sum_le_exp_norm_sub_sum (x : ℂ) (n : ℕ) : exact Real.sum_le_exp_of_nonneg (norm_nonneg _) _ lemma norm_exp_le_exp_norm (x : ℂ) : ‖exp x‖ ≤ Real.exp ‖x‖ := by - convert norm_exp_sub_sum_le_exp_norm_sub_sum x 0 using 1 <;> simp + convert! norm_exp_sub_sum_le_exp_norm_sub_sum x 0 using 1 <;> simp lemma norm_exp_sub_sum_le_norm_mul_exp (x : ℂ) (n : ℕ) : ‖exp x - ∑ m ∈ range n, x ^ m / m.factorial‖ ≤ ‖x‖ ^ n * Real.exp ‖x‖ := by @@ -528,7 +528,7 @@ open Complex Finset nonrec theorem exp_bound {x : ℝ} (hx : |x| ≤ 1) {n : ℕ} (hn : 0 < n) : |exp x - ∑ m ∈ range n, x ^ m / m.factorial| ≤ |x| ^ n * (n.succ / (n.factorial * n)) := by have hxc : ‖(x : ℂ)‖ ≤ 1 := mod_cast hx - convert exp_bound hxc hn using 2 <;> + convert! exp_bound hxc hn using 2 <;> norm_cast theorem exp_bound' {x : ℝ} (h1 : 0 ≤ x) (h2 : x ≤ 1) {n : ℕ} (hn : 0 < n) : @@ -574,7 +574,7 @@ theorem expNear_sub (n x r₁ r₂) : expNear n x r₁ - theorem exp_approx_end (n m : ℕ) (x : ℝ) (e₁ : n + 1 = m) (h : |x| ≤ 1) : |exp x - expNear m x 0| ≤ |x| ^ m / m.factorial * ((m + 1) / m) := by simp only [expNear, mul_zero, add_zero] - convert exp_bound (n := m) h ?_ using 1 + convert! exp_bound (n := m) h ?_ using 1 · simp [field] · lia @@ -584,8 +584,9 @@ theorem exp_approx_succ {n} {x a₁ b₁ : ℝ} (m : ℕ) (e₁ : n + 1 = m) (a |exp x - expNear n x a₁| ≤ |x| ^ n / n.factorial * b₁ := by grw [abs_sub_le, h] subst e₁; rw [expNear_succ, expNear_sub, abs_mul] - convert mul_le_mul_of_nonneg_left (a := |x| ^ n / ↑(Nat.factorial n)) - (le_sub_iff_add_le'.1 e) ?_ using 1 + convert! + mul_le_mul_of_nonneg_left (a := |x| ^ n / ↑(Nat.factorial n)) (le_sub_iff_add_le'.1 e) ?_ + using 1 · simp [mul_add, pow_succ', div_eq_mul_inv, abs_mul, abs_inv, Nat.factorial] ac_rfl · simp [div_nonneg, abs_nonneg] diff --git a/Mathlib/Analysis/Complex/ExponentialBounds.lean b/Mathlib/Analysis/Complex/ExponentialBounds.lean index d7bea712ba84f4..56d1b556a6c820 100644 --- a/Mathlib/Analysis/Complex/ExponentialBounds.lean +++ b/Mathlib/Analysis/Complex/ExponentialBounds.lean @@ -77,8 +77,7 @@ theorem log_two_near_10 : |log 2 - 287209 / 414355| ≤ 1 / 10 ^ 10 := by norm_num1 at z rw [one_div (2 : ℝ), log_inv, ← sub_eq_add_neg, _root_.abs_sub_comm] at z apply le_trans (_root_.abs_sub_le _ _ _) (add_le_add z _) - simp_rw [sum_range_succ] - norm_num + norm_num [sum_range_succ] theorem log_two_gt_d9 : 0.6931471803 < log 2 := lt_of_lt_of_le (by norm_num1) (sub_le_comm.1 (abs_sub_le_iff.1 log_two_near_10).2) @@ -86,4 +85,40 @@ theorem log_two_gt_d9 : 0.6931471803 < log 2 := theorem log_two_lt_d9 : log 2 < 0.6931471808 := lt_of_le_of_lt (sub_le_iff_le_add.1 (abs_sub_le_iff.1 log_two_near_10).1) (by norm_num) +theorem log_three_near_10 : |log 3 - 109861228867 / 100000000000| ≤ 1 / 10 ^ 10 := by + suffices |log 3 - 109861228867 / 100000000000| ≤ + (2 / 3) ^ 71 / 3⁻¹ + (1 / 10 ^ 10 - (2 / 3) ^ 71 / 3⁻¹) by + norm_num1 at * + assumption + have t : |2 / 3| = (2 : ℝ) / 3 := by norm_num + have z := abs_log_sub_add_sum_range_le (x := 2 / 3) (by norm_num) 70 + rw [t, show (1 - (2 : ℝ) / 3) = (1 / 3 : ℝ) by norm_num, one_div (3 : ℝ), log_inv, + ← sub_eq_add_neg, _root_.abs_sub_comm] at z + apply le_trans (_root_.abs_sub_le _ _ _) (add_le_add z _) + norm_num [sum_range_succ] + +theorem log_three_gt_d9 : 1.0986122885 < log 3 := + lt_of_lt_of_le (by norm_num1) (sub_le_comm.1 (abs_sub_le_iff.1 log_three_near_10).2) + +theorem log_three_lt_d9 : log 3 < 1.0986122888 := + lt_of_le_of_lt (sub_le_iff_le_add.1 (abs_sub_le_iff.1 log_three_near_10).1) (by norm_num) + +theorem log_five_near_10 : |log 5 - 160943791243 / 100000000000| ≤ 1 / 10 ^ 10 := by + suffices |log 5 - 160943791243 / 100000000000| ≤ + (4 / 5) ^ 131 / 5⁻¹ + (1 / 10 ^ 10 - (4 / 5) ^ 131 / 5⁻¹) by + norm_num1 at * + assumption + have t : |4 / 5| = (4 : ℝ) / 5 := by norm_num + have z := abs_log_sub_add_sum_range_le (x := 4 / 5) (by norm_num) 130 + rw [t, show (1 - (4 : ℝ) / 5) = (1 / 5 : ℝ) by norm_num, one_div (5 : ℝ), log_inv, + ← sub_eq_add_neg, _root_.abs_sub_comm] at z + apply le_trans (_root_.abs_sub_le _ _ _) (add_le_add z _) + norm_num [sum_range_succ] + +theorem log_five_gt_d9 : 1.6094379123 < log 5 := + lt_of_lt_of_le (by norm_num1) (sub_le_comm.1 (abs_sub_le_iff.1 log_five_near_10).2) + +theorem log_five_lt_d9 : log 5 < 1.6094379126 := + lt_of_le_of_lt (sub_le_iff_le_add.1 (abs_sub_le_iff.1 log_five_near_10).1) (by norm_num) + end Real diff --git a/Mathlib/Analysis/Complex/Hadamard.lean b/Mathlib/Analysis/Complex/Hadamard.lean index 4e7bca3f74d0a5..95cbb65a5bc8f7 100644 --- a/Mathlib/Analysis/Complex/Hadamard.lean +++ b/Mathlib/Analysis/Complex/Hadamard.lean @@ -426,7 +426,7 @@ lemma norm_le_interpStrip_of_mem_verticalStrip_zero (z : ℂ) · simp only [tendsto_const_nhds_iff] -- Proof that we can let epsilon tend to zero. · rw [interpStrip_eq_of_mem_verticalStrip _ _ hz] - convert ContinuousWithinAt.tendsto _ using 2 + convert! ContinuousWithinAt.tendsto _ using 2 · simp only [ofReal_zero, zero_add] · simp_rw [← ofReal_add] have : ∀ x ∈ Ioi 0, (x + sSupNormIm f 0) ^ (1 - z.re) * (x + sSupNormIm f 1) ^ z.re diff --git a/Mathlib/Analysis/Complex/HasPrimitives.lean b/Mathlib/Analysis/Complex/HasPrimitives.lean index 39732041f120db..ce8389f6b12e97 100644 --- a/Mathlib/Analysis/Complex/HasPrimitives.lean +++ b/Mathlib/Analysis/Complex/HasPrimitives.lean @@ -70,12 +70,12 @@ private lemma mem_closedBall_aux (z_in_ball : z ∈ closedBall c r) (y_in_I : y private lemma mem_ball_of_map_re_aux {a₁ a₂ b : ℝ} (ha₁ : a₁ + b * I ∈ ball c r) (ha₂ : a₂ + b * I ∈ ball c r) : (fun (x : ℝ) ↦ x + b * I) '' [[a₁, a₂]] ⊆ ball c r := by - convert Convex.rectangle_subset (convex_ball c r) ha₁ ha₂ ?_ ?_ using 1 <;> + convert! Convex.rectangle_subset (convex_ball c r) ha₁ ha₂ ?_ ?_ using 1 <;> simp [horizontalSegment_eq a₁ a₂ b, ha₁, ha₂, Rectangle] private lemma mem_ball_of_map_im_aux₁ {a b₁ b₂ : ℝ} (hb₁ : a + b₁ * I ∈ ball c r) (hb₂ : a + b₂ * I ∈ ball c r) : (fun (y : ℝ) ↦ a + y * I) '' [[b₁, b₂]] ⊆ ball c r := by - convert Convex.rectangle_subset (convex_ball c r) hb₁ hb₂ ?_ ?_ using 1 <;> + convert! Convex.rectangle_subset (convex_ball c r) hb₁ hb₂ ?_ ?_ using 1 <;> simp [verticalSegment_eq a b₁ b₂, hb₁, hb₂, Rectangle] private lemma mem_ball_of_map_im_aux₂ {w : ℂ} (hw : w ∈ ball z (r - dist z c)) : diff --git a/Mathlib/Analysis/Complex/Liouville.lean b/Mathlib/Analysis/Complex/Liouville.lean index 9a89efdcaef4d2..e41f3c7a152acd 100644 --- a/Mathlib/Analysis/Complex/Liouville.lean +++ b/Mathlib/Analysis/Complex/Liouville.lean @@ -142,7 +142,7 @@ theorem eq_const_of_tendsto_cocompact [Nontrivial E] {f : E → F} (hf : Differe Set.univ = t ∪ tᶜ := t.union_compl_self.symm _ ⊆ t ∪ s := by gcongr obtain ⟨c', hc'⟩ := hf.exists_eq_const_of_bounded h_bdd - convert hc' + convert! hc' exact tendsto_nhds_unique hb (by simpa [hc'] using tendsto_const_nhds) /-- A corollary of Liouville's theorem where the function tends to a finite value at infinity diff --git a/Mathlib/Analysis/Complex/LocallyUniformLimit.lean b/Mathlib/Analysis/Complex/LocallyUniformLimit.lean index 49a1a56ac5287d..e4b73ec97a8bfb 100644 --- a/Mathlib/Analysis/Complex/LocallyUniformLimit.lean +++ b/Mathlib/Analysis/Complex/LocallyUniformLimit.lean @@ -185,8 +185,10 @@ theorem hasSum_deriv_of_summable_norm {u : ι → ℝ} (hu : Summable u) HasSum (fun i : ι => deriv (F i) z) (deriv (fun w : ℂ => ∑' i : ι, F i w) z) := by rw [HasSum] have hc := (tendstoUniformlyOn_tsum hu hF_le).tendstoLocallyUniformlyOn - convert (hc.deriv (Eventually.of_forall fun s => - DifferentiableOn.fun_sum fun i _ => hf i) hU).tendsto_at hz using 1 + convert! + (hc.deriv (Eventually.of_forall fun s => DifferentiableOn.fun_sum fun i _ => hf i) + hU).tendsto_at + hz using 1 ext1 s exact (deriv_fun_sum fun i _ => (hf i).differentiableAt (hU.mem_nhds hz)).symm diff --git a/Mathlib/Analysis/Complex/OpenMapping.lean b/Mathlib/Analysis/Complex/OpenMapping.lean index 470a5fbc65c825..8ce1b615c2303f 100644 --- a/Mathlib/Analysis/Complex/OpenMapping.lean +++ b/Mathlib/Analysis/Complex/OpenMapping.lean @@ -251,7 +251,7 @@ theorem Polynomial.isOpenQuotientMap_eval (p : Polynomial ℂ) (hp : p.natDegree namespace Complex theorem isOpenQuotientMap_pow (n : ℕ) [NeZero n] : IsOpenQuotientMap (· ^ n : ℂ → ℂ) := by - convert Polynomial.isOpenQuotientMap_eval (.X ^ n) _ + convert! Polynomial.isOpenQuotientMap_eval (.X ^ n) _ · simp · simpa using NeZero.ne n @@ -271,7 +271,7 @@ theorem isOpenQuotientMap_zpow_compl_zero (n : ℤ) [NeZero n] : · have : NeZero n := ⟨Nat.cast_ne_zero.mp (NeZero.ne (n : ℤ))⟩ exact isOpenQuotientMap_pow_compl_zero n · have : NeZero n := ⟨Nat.cast_ne_zero.mp <| neg_ne_zero.mp (NeZero.ne (-n : ℤ))⟩ - convert (isOpenQuotientMap_pow_compl_zero n).comp (Homeomorph.inv₀ ℂ).isOpenQuotientMap + convert! (isOpenQuotientMap_pow_compl_zero n).comp (Homeomorph.inv₀ ℂ).isOpenQuotientMap simp [Homeomorph.inv₀] end Complex diff --git a/Mathlib/Analysis/Complex/PhragmenLindelof.lean b/Mathlib/Analysis/Complex/PhragmenLindelof.lean index a45986b5bd0738..914557a609c68b 100644 --- a/Mathlib/Analysis/Complex/PhragmenLindelof.lean +++ b/Mathlib/Analysis/Complex/PhragmenLindelof.lean @@ -204,8 +204,9 @@ theorem horizontal_strip (hfd : DiffContOnCl ℂ f (im ⁻¹' Ioo a b)) ((differentiable_id.sub_const _).const_mul _).neg.cexp).const_mul _).cexp replace hd : DiffContOnCl ℂ (fun w => g ε w • f w) (Ioo (-R) R ×ℂ Ioo (a - b) (a + b)) := (hgd.diffContOnCl.smul hfd).mono inter_subset_right - convert norm_le_of_forall_mem_frontier_norm_le ((isBounded_Ioo _ _).reProdIm (isBounded_Ioo _ _)) - hd (fun w hw => _) _ + convert! + norm_le_of_forall_mem_frontier_norm_le ((isBounded_Ioo _ _).reProdIm (isBounded_Ioo _ _)) hd + (fun w hw => _) _ · rw [frontier_reProdIm, closure_Ioo (neg_lt_self hR₀).ne, frontier_Ioo hab, closure_Ioo hab.ne, frontier_Ioo (neg_lt_self hR₀)] at hw by_cases him : w.im = a - b ∨ w.im = a + b diff --git a/Mathlib/Analysis/Complex/Poisson.lean b/Mathlib/Analysis/Complex/Poisson.lean index d0d19b46dfc6cb..4a0d2429ef660a 100644 --- a/Mathlib/Analysis/Complex/Poisson.lean +++ b/Mathlib/Analysis/Complex/Poisson.lean @@ -85,7 +85,7 @@ private lemma re_herglotzRieszKernel_le_aux (φ θ r R : ℝ) (h₁ : 0 < r) (h have h_subst : (R ^ 2 - r ^ 2) / (R ^ 2 + r ^ 2 - 2 * R * r * Real.cos (θ - φ)) ≤ (R + r) / (R - r) := by rw [div_le_div_iff₀] <;> nlinarith [mul_pos h₁ (sub_pos.mpr h₂)] - convert h_subst using 1 + convert! h_subst using 1 rw [← div_eq_mul_inv, poissonKernel_eq_re_herglotzRieszKernel_aux] suffices (R * R * normSq (cexp (θ * I)) + r * r * normSq (cexp (φ * I)) - 2 * (R * Real.cos θ * (r * Real.cos φ) + R * Real.sin θ * (r * Real.sin φ))) = diff --git a/Mathlib/Analysis/Complex/Polynomial/Basic.lean b/Mathlib/Analysis/Complex/Polynomial/Basic.lean index 9e325ce4b70220..0497165b9d3ba6 100644 --- a/Mathlib/Analysis/Complex/Polynomial/Basic.lean +++ b/Mathlib/Analysis/Complex/Polynomial/Basic.lean @@ -185,7 +185,7 @@ then `p` is divisible by a quadratic polynomial. -/ lemma Polynomial.quadratic_dvd_of_aeval_eq_zero_im_ne_zero (p : ℝ[X]) {z : ℂ} (h0 : aeval z p = 0) (hz : z.im ≠ 0) : X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2) ∣ p := by rw [← map_dvd_map' (algebraMap ℝ ℂ)] - convert p.mul_star_dvd_of_aeval_eq_zero_im_ne_zero h0 hz + convert! p.mul_star_dvd_of_aeval_eq_zero_im_ne_zero h0 hz calc map (algebraMap ℝ ℂ) (X ^ 2 - C (2 * z.re) * X + C (‖z‖ ^ 2)) _ = X ^ 2 - C (↑(2 * z.re) : ℂ) * X + C (‖z‖ ^ 2 : ℂ) := by simp diff --git a/Mathlib/Analysis/Complex/Positivity.lean b/Mathlib/Analysis/Complex/Positivity.lean index e040eb68fe472f..fa36ef97d7808a 100644 --- a/Mathlib/Analysis/Complex/Positivity.lean +++ b/Mathlib/Analysis/Complex/Positivity.lean @@ -75,8 +75,9 @@ set `c - ℝ≥0`. -/ theorem apply_le_of_iteratedDeriv_alternating {f : ℂ → ℂ} {c : ℂ} (hf : Differentiable ℂ f) (h : ∀ n ≠ 0, 0 ≤ (-1) ^ n * iteratedDeriv n f c) ⦃z : ℂ⦄ (hz : z ≤ c) : f c ≤ f z := by - convert apply_le_of_iteratedDeriv_nonneg (f := fun z ↦ f (-z)) - (hf.comp <| differentiable_neg) (fun n hn ↦ ?_) (neg_le_neg_iff.mpr hz) using 1 + convert! + apply_le_of_iteratedDeriv_nonneg (f := fun z ↦ f (-z)) (hf.comp <| differentiable_neg) + (fun n hn ↦ ?_) (neg_le_neg_iff.mpr hz) using 1 · simp only [neg_neg] · simp only [neg_neg] · simpa only [iteratedDeriv_comp_neg, neg_neg, smul_eq_mul] using h n hn diff --git a/Mathlib/Analysis/Complex/TaylorSeries.lean b/Mathlib/Analysis/Complex/TaylorSeries.lean index eb3f6db079961e..ab6844609a75e1 100644 --- a/Mathlib/Analysis/Complex/TaylorSeries.lean +++ b/Mathlib/Analysis/Complex/TaylorSeries.lean @@ -54,7 +54,7 @@ lemma hasSum_taylorSeries_on_ball : have H := (hf.mono <| Metric.closedBall_subset_ball hr').hasFPowerSeriesOnBall hr'₀ |>.hasSum_iteratedFDeriv hz' simp only [add_sub_cancel] at H - convert H using 4 with n + convert! H using 4 with n simpa only [iteratedDeriv_eq_iteratedFDeriv, smul_eq_mul, mul_one, Finset.prod_const, Finset.card_fin] using ((iteratedFDeriv ℂ n f c).map_smul_univ (fun _ ↦ z - c) (fun _ ↦ 1)).symm @@ -71,7 +71,7 @@ include hz in is given by evaluating its Taylor series at `c` on this open ball. -/ lemma taylorSeries_eq_on_ball' {f : ℂ → ℂ} (hf : DifferentiableOn ℂ f (Metric.ball c r)) : ∑' n : ℕ, (n ! : ℂ)⁻¹ * iteratedDeriv n f c * (z - c) ^ n = f z := by - convert taylorSeries_eq_on_ball hf hz using 3 with n + convert! taylorSeries_eq_on_ball hf hz using 3 with n rw [mul_right_comm, smul_eq_mul, smul_eq_mul, mul_assoc] end ball @@ -111,7 +111,7 @@ include hz in is given by evaluating its Taylor series at `c` on this open ball. -/ lemma taylorSeries_eq_on_eball' {f : ℂ → ℂ} (hf : DifferentiableOn ℂ f (Metric.eball c r)) : ∑' n : ℕ, (n ! : ℂ)⁻¹ * iteratedDeriv n f c * (z - c) ^ n = f z := by - convert taylorSeries_eq_on_eball hf hz using 3 with n + convert! taylorSeries_eq_on_eball hf hz using 3 with n rw [mul_right_comm, smul_eq_mul, smul_eq_mul, mul_assoc] @[deprecated (since := "2026-01-24")] @@ -142,7 +142,7 @@ lemma taylorSeries_eq_of_entire : its Taylor series at any point `c`. -/ lemma taylorSeries_eq_of_entire' {f : ℂ → ℂ} (hf : Differentiable ℂ f) : ∑' n : ℕ, (n ! : ℂ)⁻¹ * iteratedDeriv n f c * (z - c) ^ n = f z := by - convert taylorSeries_eq_of_entire hf c z using 3 with n + convert! taylorSeries_eq_of_entire hf c z using 3 with n rw [mul_right_comm, smul_eq_mul, smul_eq_mul, mul_assoc] end entire diff --git a/Mathlib/Analysis/Complex/Trigonometric.lean b/Mathlib/Analysis/Complex/Trigonometric.lean index a8957cd0c6c181..22eeb80938f413 100644 --- a/Mathlib/Analysis/Complex/Trigonometric.lean +++ b/Mathlib/Analysis/Complex/Trigonometric.lean @@ -331,13 +331,13 @@ theorem sin_add_mul_I (x y : ℂ) : sin (x + y * I) = sin x * cosh y + cos x * s rw [sin_add, cos_mul_I, sin_mul_I, mul_assoc] theorem sin_eq (z : ℂ) : sin z = sin z.re * cosh z.im + cos z.re * sinh z.im * I := by - convert sin_add_mul_I z.re z.im; exact (re_add_im z).symm + convert! sin_add_mul_I z.re z.im; exact (re_add_im z).symm theorem cos_add_mul_I (x y : ℂ) : cos (x + y * I) = cos x * cosh y - sin x * sinh y * I := by rw [cos_add, cos_mul_I, sin_mul_I, mul_assoc] theorem cos_eq (z : ℂ) : cos z = cos z.re * cosh z.im - sin z.re * sinh z.im * I := by - convert cos_add_mul_I z.re z.im; exact (re_add_im z).symm + convert! cos_add_mul_I z.re z.im; exact (re_add_im z).symm theorem sin_sub_sin : sin x - sin y = 2 * sin ((x - y) / 2) * cos ((x + y) / 2) := by have s1 := sin_add ((x + y) / 2) ((x - y) / 2) diff --git a/Mathlib/Analysis/Complex/UpperHalfPlane/Manifold.lean b/Mathlib/Analysis/Complex/UpperHalfPlane/Manifold.lean index 48a4fc371d48c3..9ee16c35b35656 100644 --- a/Mathlib/Analysis/Complex/UpperHalfPlane/Manifold.lean +++ b/Mathlib/Analysis/Complex/UpperHalfPlane/Manifold.lean @@ -124,7 +124,7 @@ lemma eq_zero_of_frequently {f : ℍ → ℂ} (hf : MDiff f) {τ : ℍ} (hτ : rw [mdifferentiable_iff] at hf have := hf.analyticOnNhd isOpen_upperHalfPlaneSet ext w - convert this.eqOn_zero_of_preconnected_of_frequently_eq_zero (z₀ := ↑τ) ?_ τ.2 ?_ w.im_pos + convert! this.eqOn_zero_of_preconnected_of_frequently_eq_zero (z₀ := ↑τ) ?_ τ.2 ?_ w.im_pos · rw [Function.comp_apply, ofComplex_apply] · exact (Complex.isConnected_of_upperHalfPlane subset_rfl (by grind)).isPreconnected · contrapose! hτ @@ -162,8 +162,9 @@ lemma hasStrictDerivAt_smul {g : GL (Fin 2) ℝ} (hg : 0 < g.val.det) (τ : ℍ) refine this.congr_of_eventuallyEq ?_ rw [← isOpenEmbedding_coe.map_nhds_eq, eventuallyEq_map] simp [Function.comp_def, coe_smul_of_det_pos hg] - convert ((hasStrictDerivAt_id (τ : ℂ)).const_mul _ |>.add_const _).div - ((hasStrictDerivAt_id (τ : ℂ)).const_mul _ |>.add_const _) _ using 2 + convert! + ((hasStrictDerivAt_id (τ : ℂ)).const_mul _ |>.add_const _).div + ((hasStrictDerivAt_id (τ : ℂ)).const_mul _ |>.add_const _) _ using 2 · simp [Matrix.det_fin_two]; ring · apply denom_ne_zero @@ -231,7 +232,7 @@ lemma hasStrictFDerivAt_smul (g : GL (Fin 2) ℝ) (τ : ℍ) : HasStrictFDerivAt (fun z ↦ ↑(g • ofComplex z) : ℂ → ℂ) (smulFDeriv g τ) τ := by wlog hg : 0 < g.det.val generalizing g · replace hg := g.det.ne_zero.lt_or_gt.resolve_right hg - convert Complex.conjCLE.hasStrictFDerivAt.neg.comp _ (this (J * g) (by simpa)) + convert! Complex.conjCLE.hasStrictFDerivAt.neg.comp _ (this (J * g) (by simpa)) · simp [mul_smul, coe_J_smul] · ext simp diff --git a/Mathlib/Analysis/Complex/UpperHalfPlane/Measure.lean b/Mathlib/Analysis/Complex/UpperHalfPlane/Measure.lean index 340e7b286823bc..985c8b34f2a157 100644 --- a/Mathlib/Analysis/Complex/UpperHalfPlane/Measure.lean +++ b/Mathlib/Analysis/Complex/UpperHalfPlane/Measure.lean @@ -100,7 +100,7 @@ instance : SMulInvariantMeasure (GL (Fin 2) ℝ) ℍ volume := by (hasStrictFDerivAt_smul g _).hasFDerivAt.hasFDerivWithinAt) hinj (fun z ↦ ↑((1 / ‖z.im‖₊) ^ 2 : NNReal)) - convert main using 1 + convert! main using 1 · simp [Set.image_image] · apply setLIntegral_congr_fun (measurableEmbedding_coe.measurableSet_image.mpr hs) rintro _ ⟨τ, -, rfl⟩ diff --git a/Mathlib/Analysis/Complex/UpperHalfPlane/ProperAction.lean b/Mathlib/Analysis/Complex/UpperHalfPlane/ProperAction.lean index 73679d61ab0067..aa9604b24b4f2c 100644 --- a/Mathlib/Analysis/Complex/UpperHalfPlane/ProperAction.lean +++ b/Mathlib/Analysis/Complex/UpperHalfPlane/ProperAction.lean @@ -89,7 +89,7 @@ private lemma absq_le {K : Set ℍ} (hK : IsCompact K) : let S : SL(2, ℝ) := ⟨!![0, -1; 1, 0], by simp⟩ obtain ⟨A, hA⟩ := cdsq_le (K := S • K) (hK.image <| continuous_const_smul S) refine ⟨A, fun g hg ↦ ?_⟩ - convert hA (S * g) (by rwa [mul_smul, Set.smul_mem_smul_set_iff]) using 1 + convert! hA (S * g) (by rwa [mul_smul, Set.smul_mem_smul_set_iff]) using 1 rw [Matrix.SpecialLinearGroup.coe_mul, Matrix.eta_fin_two g.val, Matrix.mul_fin_two] simp @@ -102,7 +102,7 @@ lemma isProperMap_smul_I : IsProperMap fun g : SL(2, ℝ) ↦ g • I := by let : SeminormedAddCommGroup (Matrix (Fin 2) (Fin 2) ℝ) := Matrix.seminormedAddCommGroup have : ProperSpace (Matrix (Fin 2) (Fin 2) ℝ) := pi_properSpace have : IsCompact {m : Matrix (Fin 2) (Fin 2) ℝ | ∀ i j, |m i j| ≤ max √A √A'} := by - convert ProperSpace.isCompact_closedBall (0 : Matrix (Fin 2) (Fin 2) ℝ) (max √A √A') + convert! ProperSpace.isCompact_closedBall (0 : Matrix (Fin 2) (Fin 2) ℝ) (max √A √A') simp only [le_sup_iff, Fin.forall_fin_two, Fin.isValue, Metric.closedBall, dist_zero_right, Matrix.norm_def, pi_norm_le_iff_of_nonempty, Real.norm_eq_abs] #adaptation_note /-- Before https://github.com/leanprover/lean4/pull/13166 diff --git a/Mathlib/Analysis/Complex/ValueDistribution/FirstMainTheorem.lean b/Mathlib/Analysis/Complex/ValueDistribution/FirstMainTheorem.lean index 9e704089df90ab..a08119f5e7bbc6 100644 --- a/Mathlib/Analysis/Complex/ValueDistribution/FirstMainTheorem.lean +++ b/Mathlib/Analysis/Complex/ValueDistribution/FirstMainTheorem.lean @@ -147,7 +147,7 @@ theorem abs_characteristic_sub_characteristic_shift_le {r : ℝ} (h : Meromorphi using (posLog_norm_add_le (f θ - a₀) a₀) · simp only [abs_of_nonpos (le_of_not_ge h), neg_sub, tsub_le_iff_right, add_comm (log⁺ ‖a₀‖ + log 2), ← add_assoc] - convert posLog_norm_add_le (-f θ) (a₀) using 2 + convert! posLog_norm_add_le (-f θ) (a₀) using 2 · rw [← norm_neg] abel_nf · simp diff --git a/Mathlib/Analysis/Complex/ValueDistribution/LogCounting/Asymptotic.lean b/Mathlib/Analysis/Complex/ValueDistribution/LogCounting/Asymptotic.lean index ff717c725ae84f..14f6c3a5f03b14 100644 --- a/Mathlib/Analysis/Complex/ValueDistribution/LogCounting/Asymptotic.lean +++ b/Mathlib/Analysis/Complex/ValueDistribution/LogCounting/Asymptotic.lean @@ -46,28 +46,13 @@ is little o of the logarithmic counting function attached to `single e`. -/ lemma one_isLittleO_logCounting_single [DecidableEq E] [ProperSpace E] {e : E} : (1 : ℝ → ℝ) =o[atTop] logCounting (single e 1) := by - rw [isLittleO_iff] - intro c hc - simp only [Pi.one_apply, norm_eq_abs, eventually_atTop, abs_one] - use exp (|log ‖e‖| + c⁻¹) - intro b hb - have h₁b : 1 ≤ b := by - calc 1 - _ ≤ exp (|log ‖e‖| + c⁻¹) := one_le_exp (by positivity) - _ ≤ b := hb - have h₁c : ‖e‖ ≤ exp (|log ‖e‖| + c⁻¹) := by - calc ‖e‖ - _ ≤ exp (log ‖e‖) := le_exp_log ‖e‖ - _ ≤ exp (|log ‖e‖| + c⁻¹) := - exp_monotone (le_add_of_le_of_nonneg (le_abs_self _) (inv_pos.2 hc).le) - rw [← inv_mul_le_iff₀ hc, mul_one, abs_of_nonneg (logCounting_nonneg - (single_pos.2 Int.one_pos).le h₁b)] - calc c⁻¹ - _ ≤ logCounting (single e 1) (exp (|log ‖e‖| + c⁻¹)) := by - simp [logCounting_single_eq_log_sub_const h₁c, le_sub_iff_add_le', le_abs_self (log ‖e‖)] - _ ≤ logCounting (single e 1) b := by - apply logCounting_mono (single_pos.2 Int.one_pos).le (mem_Ioi.2 (exp_pos _)) _ hb - simpa [mem_Ioi] using one_pos.trans_le h₁b + have hΘ : (fun r ↦ log r - log ‖e‖) =Θ[atTop] log := + (IsEquivalent.sub_isLittleO IsEquivalent.refl isLittleO_const_log_atTop).isTheta + have h₁ : (1 : ℝ → ℝ) =o[atTop] fun r ↦ log r - log ‖e‖ := + (hΘ.isLittleO_congr_right).2 isLittleO_const_log_atTop + refine h₁.congr' EventuallyEq.rfl ?_ + filter_upwards [eventually_ge_atTop ‖e‖] with r hr + simp [logCounting_single_eq_log_sub_const hr] /-- A non-negative function with locally finite support is zero if and only if its logarithmic counting @@ -123,17 +108,8 @@ function for its pole divisor is asymptotically bounded. theorem logCounting_isBigO_one_iff_analyticOnNhd {f : 𝕜 → E} (h : Meromorphic f) : logCounting f ⊤ =O[atTop] (1 : ℝ → ℝ) ↔ AnalyticOnNhd 𝕜 (toMeromorphicNFOn f univ) univ := by simp only [logCounting, reduceDIte] - rw [← Function.locallyFinsuppWithin.zero_iff_logCounting_bounded (negPart_nonneg _)] - constructor - · intro h₁f z hz - apply (meromorphicNFOn_toMeromorphicNFOn f univ - trivial).meromorphicOrderAt_nonneg_iff_analyticAt.1 - rw [meromorphicOrderAt_toMeromorphicNFOn h.meromorphicOn (by trivial), ← WithTop.untop₀_nonneg, - ← h.meromorphicOn.divisor_apply (by trivial), ← negPart_eq_zero, - ← locallyFinsuppWithin.negPart_apply] - aesop - · intro h₁f - rwa [negPart_eq_zero, ← h.meromorphicOn.divisor_of_toMeromorphicNFOn, - (meromorphicNFOn_toMeromorphicNFOn _ _).divisor_nonneg_iff_analyticOnNhd] + rw [← locallyFinsuppWithin.zero_iff_logCounting_bounded (negPart_nonneg _), negPart_eq_zero, + ← h.meromorphicOn.divisor_of_toMeromorphicNFOn, + (meromorphicNFOn_toMeromorphicNFOn _ _).divisor_nonneg_iff_analyticOnNhd] end ValueDistribution diff --git a/Mathlib/Analysis/ConstantSpeed.lean b/Mathlib/Analysis/ConstantSpeed.lean index d7ab627aaaba27..b01b287321c026 100644 --- a/Mathlib/Analysis/ConstantSpeed.lean +++ b/Mathlib/Analysis/ConstantSpeed.lean @@ -200,7 +200,7 @@ monotonically maps `s` onto `t`, then `φ` is just a translation (on `s`). theorem unique_unit_speed {φ : ℝ → ℝ} (φm : MonotoneOn φ s) (hfφ : HasUnitSpeedOn (f ∘ φ) s) (hf : HasUnitSpeedOn f (φ '' s)) ⦃x : ℝ⦄ (xs : x ∈ s) : EqOn φ (fun y => y - x + φ x) s := by dsimp only [HasUnitSpeedOn] at hf hfφ - convert HasConstantSpeedOnWith.ratio one_ne_zero φm hfφ hf xs using 3 + convert! HasConstantSpeedOnWith.ratio one_ne_zero φm hfφ hf xs using 3 simp /-- If both `f` and `f ∘ φ` have unit speed (on `Icc 0 t` and `Icc 0 s` respectively) @@ -211,7 +211,7 @@ theorem unique_unit_speed_on_Icc_zero {s t : ℝ} (hs : 0 ≤ s) (ht : 0 ≤ t) (hfφ : HasUnitSpeedOn (f ∘ φ) (Icc 0 s)) (hf : HasUnitSpeedOn f (Icc 0 t)) : EqOn φ id (Icc 0 s) := by rw [← φst] at hf - convert unique_unit_speed φm hfφ hf ⟨le_rfl, hs⟩ using 1 + convert! unique_unit_speed φm hfφ hf ⟨le_rfl, hs⟩ using 1 have : φ 0 = 0 := by have hm : 0 ∈ φ '' Icc 0 s := by simp only [φst, ht, mem_Icc, le_refl, and_self] obtain ⟨x, xs, hx⟩ := hm diff --git a/Mathlib/Analysis/Convex/Basic.lean b/Mathlib/Analysis/Convex/Basic.lean index a1039fdb828d5a..de07cfd5c9ac2a 100644 --- a/Mathlib/Analysis/Convex/Basic.lean +++ b/Mathlib/Analysis/Convex/Basic.lean @@ -643,7 +643,7 @@ lemma convex_of_nonneg_surjective_algebraMap [FaithfulSMul R A] {s : Set M} intro u hu v hv a b ha hb hab obtain ⟨c, hc1, hc2⟩ := halg ha obtain ⟨d, hd1, hd2⟩ := halg hb - convert hs hu hv hc1 hd1 _ using 2 + convert! hs hu hv hc1 hd1 _ using 2 · rw [← hc2, algebraMap_smul] · rw [← hd2, algebraMap_smul] rw [← hc2, ← hd2, ← algebraMap.coe_add] at hab diff --git a/Mathlib/Analysis/Convex/Between.lean b/Mathlib/Analysis/Convex/Between.lean index 6d5dbd0f6dcccf..644e30e935d809 100644 --- a/Mathlib/Analysis/Convex/Between.lean +++ b/Mathlib/Analysis/Convex/Between.lean @@ -658,10 +658,10 @@ lemma closedInterior_face_eq_affineSegment {n : ℕ} (s : Simplex R P n) {i j : simp [max_eq_left hji.le, min_eq_right hji.le] rw [h', (s.face (Finset.card_pair h)).closedInterior_eq_affineSegment, face_points, face_points] congr 2 - · convert Finset.orderEmbOfFin_zero _ _ + · convert! Finset.orderEmbOfFin_zero _ _ · exact (Finset.min'_pair i j).symm · lia - · convert Finset.orderEmbOfFin_last _ _ + · convert! Finset.orderEmbOfFin_last _ _ · exact (Finset.max'_pair i j).symm · lia @@ -712,10 +712,10 @@ lemma mem_interior_face_iff_sbtw [IsDomain R] [IsTorsionFree R V] {n : ℕ} simp [max_eq_left hji.le, min_eq_right hji.le] rw [h', mem_interior_iff_sbtw, face_points, face_points] congr! 4 - · convert Finset.orderEmbOfFin_zero _ _ + · convert! Finset.orderEmbOfFin_zero _ _ · exact (Finset.min'_pair i j).symm · lia - · convert Finset.orderEmbOfFin_last _ _ + · convert! Finset.orderEmbOfFin_last _ _ · exact (Finset.max'_pair i j).symm · lia @@ -941,8 +941,10 @@ theorem wbtw_or_wbtw_smul_vadd_of_nonneg (x : P) (v : V) {r₁ r₂ : R} (hr₁ theorem wbtw_smul_vadd_smul_vadd_of_nonpos_of_le (x : P) (v : V) {r₁ r₂ : R} (hr₁ : r₁ ≤ 0) (hr₂ : r₂ ≤ r₁) : Wbtw R x (r₁ • v +ᵥ x) (r₂ • v +ᵥ x) := by - convert wbtw_smul_vadd_smul_vadd_of_nonneg_of_le x (-v) (Left.nonneg_neg_iff.2 hr₁) - (neg_le_neg_iff.2 hr₂) using 1 <;> + convert! + wbtw_smul_vadd_smul_vadd_of_nonneg_of_le x (-v) (Left.nonneg_neg_iff.2 hr₁) + (neg_le_neg_iff.2 hr₂) using + 1 <;> rw [neg_smul_neg] theorem wbtw_or_wbtw_smul_vadd_of_nonpos (x : P) (v : V) {r₁ r₂ : R} (hr₁ : r₁ ≤ 0) (hr₂ : r₂ ≤ 0) : @@ -953,8 +955,10 @@ theorem wbtw_or_wbtw_smul_vadd_of_nonpos (x : P) (v : V) {r₁ r₂ : R} (hr₁ theorem wbtw_smul_vadd_smul_vadd_of_nonpos_of_nonneg (x : P) (v : V) {r₁ r₂ : R} (hr₁ : r₁ ≤ 0) (hr₂ : 0 ≤ r₂) : Wbtw R (r₁ • v +ᵥ x) x (r₂ • v +ᵥ x) := by - convert wbtw_smul_vadd_smul_vadd_of_nonneg_of_le (r₁ • v +ᵥ x) v (Left.nonneg_neg_iff.2 hr₁) - (neg_le_sub_iff_le_add.2 ((le_add_iff_nonneg_left r₁).2 hr₂)) using 1 <;> + convert! + wbtw_smul_vadd_smul_vadd_of_nonneg_of_le (r₁ • v +ᵥ x) v (Left.nonneg_neg_iff.2 hr₁) + (neg_le_sub_iff_le_add.2 ((le_add_iff_nonneg_left r₁).2 hr₂)) using + 1 <;> simp [sub_smul, ← add_vadd] theorem wbtw_smul_vadd_smul_vadd_of_nonneg_of_nonpos (x : P) (v : V) {r₁ r₂ : R} (hr₁ : 0 ≤ r₁) @@ -1101,12 +1105,12 @@ theorem sbtw_pointReflection_of_ne {x y : P} (h : x ≠ y) : Sbtw R y x (pointRe exact (pointReflection_involutive R x).injective.ne h theorem wbtw_midpoint (x y : P) : Wbtw R x (midpoint R x y) y := by - convert wbtw_pointReflection R (midpoint R x y) x + convert! wbtw_pointReflection R (midpoint R x y) x rw [pointReflection_midpoint_left] theorem sbtw_midpoint_of_ne {x y : P} (h : x ≠ y) : Sbtw R x (midpoint R x y) y := by have h : midpoint R x y ≠ x := by simp [h] - convert sbtw_pointReflection_of_ne R h + convert! sbtw_pointReflection_of_ne R h rw [pointReflection_midpoint_left] end LinearOrderedField diff --git a/Mathlib/Analysis/Convex/Birkhoff.lean b/Mathlib/Analysis/Convex/Birkhoff.lean index 7be75ff975a0dc..2083948fd5b2da 100644 --- a/Mathlib/Analysis/Convex/Birkhoff.lean +++ b/Mathlib/Analysis/Convex/Birkhoff.lean @@ -11,7 +11,6 @@ public import Mathlib.Analysis.Convex.Jensen public import Mathlib.Analysis.Normed.Module.Convex public import Mathlib.Combinatorics.Hall.Basic public import Mathlib.Analysis.Convex.DoublyStochasticMatrix -public import Mathlib.Tactic.Linarith /-! # Birkhoff's theorem @@ -126,15 +125,11 @@ private lemma doublyStochastic_sum_perm_aux (M : Matrix n n R) gcongr rw [ssubset_iff_of_subset (monotone_filter_right _ _)] · simp_rw [mem_filter_univ, not_not, Prod.exists] - refine ⟨i, σ i, hMi'.ne', ?_⟩ - simp [N, Equiv.toPEquiv_apply] + exact ⟨i, σ i, hMi'.ne', by simp [N, Equiv.toPEquiv_apply]⟩ · rintro ⟨i', j'⟩ _ hN' hM' - dsimp at hN' hM' - simp only [sub_apply, hM', smul_apply, PEquiv.toMatrix_apply, Equiv.toPEquiv_apply, - Option.mem_def, Option.some.injEq, smul_eq_mul, mul_ite, mul_one, mul_zero, zero_sub, - neg_eq_zero, ite_eq_right_iff, Classical.not_imp, N] at hN' - obtain ⟨rfl, _⟩ := hN' - linarith [hi' i' (by simp)] + have hσ' : σ i' ≠ j' := by + simpa [Equiv.toPEquiv_apply] using hσ i' j' hM' + exact hN' <| by simp [N, hM', hσ', Equiv.toPEquiv_apply] obtain ⟨w, hw, hw'⟩ := ih _ hd' _ s' hs' this rfl refine ⟨w + fun σ' => if σ' = σ then M i (σ i) else 0, ?_⟩ simp only [Pi.add_apply, add_smul, sum_add_distrib, hw', ite_smul, zero_smul, diff --git a/Mathlib/Analysis/Convex/Caratheodory.lean b/Mathlib/Analysis/Convex/Caratheodory.lean index 7cd7dd08e02fe2..5e03e56b84c3ae 100644 --- a/Mathlib/Analysis/Convex/Caratheodory.lean +++ b/Mathlib/Analysis/Convex/Caratheodory.lean @@ -77,7 +77,7 @@ theorem mem_convexHull_erase [DecidableEq E] {t : Finset E} (h : ¬AffineIndepen conv_rhs => rw [← insert_erase hi₀, sum_insert (notMem_erase i₀ t), hk, zero_add] _ = ∑ e ∈ t, (f e - f i₀ / g i₀ * g e) := rfl _ = 1 := by rw [sum_sub_distrib, fsum, ← mul_sum, gsum, mul_zero, sub_zero] - refine ⟨⟨i₀, hi₀⟩, k, ?_, by convert ksum, ?_⟩ + refine ⟨⟨i₀, hi₀⟩, k, ?_, by convert! ksum, ?_⟩ · simp only [k, and_imp, sub_nonneg, mem_erase, Ne] intro e _ het by_cases hes : e ∈ s @@ -155,7 +155,7 @@ theorem convexHull_eq_union : convexHull 𝕜 s = Caratheodory.minCardFinsetOfMemConvexHull_subseteq hx, Caratheodory.affineIndependent_minCardFinsetOfMemConvexHull hx, Caratheodory.mem_minCardFinsetOfMemConvexHull hx⟩ - · iterate 3 convert Set.iUnion_subset _; intro + · iterate 3 convert! Set.iUnion_subset _; intro exact convexHull_mono ‹_› /-- A more explicit version of `convexHull_eq_union`. -/ diff --git a/Mathlib/Analysis/Convex/Combination.lean b/Mathlib/Analysis/Convex/Combination.lean index 48e48fcb09f569..ce97f12f200196 100644 --- a/Mathlib/Analysis/Convex/Combination.lean +++ b/Mathlib/Analysis/Convex/Combination.lean @@ -242,7 +242,7 @@ theorem convex_iff_sum_mem : Convex R s ↔ ∀ (t : Finset E) (w : E → R), by_cases h_cases : x = y · rw [h_cases, ← add_smul, hab, one_smul] exact hy - · convert h {x, y} (fun z => if z = y then b else a) _ _ _ + · convert! h { x, y } (fun z => if z = y then b else a) _ _ _ · simp only [sum_pair h_cases, if_neg h_cases, if_pos trivial] · grind · simp only [sum_pair h_cases, if_neg h_cases, if_pos trivial, hab] diff --git a/Mathlib/Analysis/Convex/Cone/Extension.lean b/Mathlib/Analysis/Convex/Cone/Extension.lean index ac70c5e315fdc3..b1b22e905185b1 100644 --- a/Mathlib/Analysis/Convex/Cone/Extension.lean +++ b/Mathlib/Analysis/Convex/Cone/Extension.lean @@ -125,7 +125,7 @@ theorem exists_top (p : E →ₗ.[ℝ] ℝ) (hp_nonneg : ∀ x : p.domain, (x : directedOn_image.2 (hcd.mono LinearPMap.domain_mono.monotone) rcases (mem_sSup_of_directed (cne.image _) hdir).1 hx with ⟨_, ⟨f, hfc, rfl⟩, hfx⟩ have : f ≤ LinearPMap.sSup c hcd := LinearPMap.le_sSup _ hfc - convert ← hcs hfc ⟨x, hfx⟩ hxs using 1 + convert! ← hcs hfc ⟨x, hfx⟩ hxs using 1 exact this.2 rfl obtain ⟨q, hpq, hqs, hq⟩ := zorn_le_nonempty₀ S hSc p hp_nonneg refine ⟨q, hpq, ?_, hqs⟩ diff --git a/Mathlib/Analysis/Convex/Continuous.lean b/Mathlib/Analysis/Convex/Continuous.lean index 60510a54c5e82e..a6aaec87944436 100644 --- a/Mathlib/Analysis/Convex/Continuous.lean +++ b/Mathlib/Analysis/Convex/Continuous.lean @@ -82,7 +82,7 @@ lemma ConvexOn.exists_lipschitzOnWith_of_isBounded (hf : ConvexOn ℝ (ball x₀ lemma ConcaveOn.exists_lipschitzOnWith_of_isBounded (hf : ConcaveOn ℝ (ball x₀ r) f) (hr : r' < r) (hf' : IsBounded (f '' ball x₀ r)) : ∃ K, LipschitzOnWith K f (ball x₀ r') := by - replace hf' : IsBounded ((-f) '' ball x₀ r) := by convert hf'.neg; ext; simp [neg_eq_iff_eq_neg] + replace hf' : IsBounded ((-f) '' ball x₀ r) := by convert! hf'.neg; ext; simp [neg_eq_iff_eq_neg] simpa using hf.neg.exists_lipschitzOnWith_of_isBounded hr hf' lemma ConvexOn.isBoundedUnder_abs (hf : ConvexOn ℝ C f) {x₀ : E} (hC : C ∈ 𝓝 x₀) : @@ -168,7 +168,7 @@ lemma ConcaveOn.continuousOn_tfae (hC : IsOpen C) (hC' : C.Nonempty) (hf : Conca have := hf.neg.continuousOn_tfae hC hC' simp only [locallyLipschitzOn_neg_iff, continuousOn_neg_iff, continuousAt_neg_iff, abs_neg] at this - convert this using 8 <;> exact (Equiv.neg ℝ).exists_congr (by simp) + convert! this using 8 <;> exact (Equiv.neg ℝ).exists_congr (by simp) lemma ConvexOn.locallyLipschitzOn_iff_continuousOn (hC : IsOpen C) (hf : ConvexOn ℝ C f) : LocallyLipschitzOn C f ↔ ContinuousOn f C := by diff --git a/Mathlib/Analysis/Convex/Deriv.lean b/Mathlib/Analysis/Convex/Deriv.lean index e019ff474af538..21c1d7869eacbb 100644 --- a/Mathlib/Analysis/Convex/Deriv.lean +++ b/Mathlib/Analysis/Convex/Deriv.lean @@ -238,7 +238,7 @@ lemma convexOn_of_hasDerivWithinAt2_nonneg {D : Set ℝ} (hD : Convex ℝ D) {f · rw [differentiableOn_congr this] exact fun x hx ↦ (hf'' _ hx).differentiableWithinAt · rintro x hx - convert hf''₀ _ hx using 1 + convert! hf''₀ _ hx using 1 dsimp rw [deriv_eqOn isOpen_interior (fun y hy ↦ ?_) hx] exact (hf'' _ hy).congr this <| by rw [this hy] @@ -254,7 +254,7 @@ lemma concaveOn_of_hasDerivWithinAt2_nonpos {D : Set ℝ} (hD : Convex ℝ D) {f · rw [differentiableOn_congr this] exact fun x hx ↦ (hf'' _ hx).differentiableWithinAt · rintro x hx - convert hf''₀ _ hx using 1 + convert! hf''₀ _ hx using 1 dsimp rw [deriv_eqOn isOpen_interior (fun y hy ↦ ?_) hx] exact (hf'' _ hy).congr this <| by rw [this hy] diff --git a/Mathlib/Analysis/Convex/Gauge.lean b/Mathlib/Analysis/Convex/Gauge.lean index 9fb5689a4a7e0d..6e2eea7f3179a9 100644 --- a/Mathlib/Analysis/Convex/Gauge.lean +++ b/Mathlib/Analysis/Convex/Gauge.lean @@ -102,7 +102,7 @@ theorem gauge_zero' : gauge (0 : Set E) = 0 := by obtain rfl | hx := eq_or_ne x 0 · simp only [csInf_Ioi, mem_zero, Pi.zero_apply, sep_true, smul_zero] · simp only [mem_zero, Pi.zero_apply, inv_eq_zero, smul_eq_zero] - convert Real.sInf_empty + convert! Real.sInf_empty exact eq_empty_iff_forall_notMem.2 fun r hr => hr.2.elim (ne_of_gt hr.1) hx @[simp] @@ -203,7 +203,7 @@ theorem Convex.gauge_le (hs : Convex ℝ s) (h₀ : (0 : E) ∈ s) (absorbs : Ab by_cases ha : 0 ≤ a · rw [gauge_le_eq hs h₀ absorbs ha] exact convex_iInter fun i => convex_iInter fun _ => hs.smul _ - · convert convex_empty (𝕜 := ℝ) + · convert! convex_empty (𝕜 := ℝ) exact eq_empty_iff_forall_notMem.2 fun x hx => ha <| (gauge_nonneg _).trans hx theorem Balanced.starConvex (hs : Balanced ℝ s) : StarConvex ℝ 0 s := @@ -360,7 +360,7 @@ theorem interior_subset_gauge_lt_one (s : Set E) : interior s ⊆ { x | gauge s theorem gauge_lt_one_eq_self_of_isOpen (hs₁ : Convex ℝ s) (hs₀ : (0 : E) ∈ s) (hs₂ : IsOpen s) : { x | gauge s x < 1 } = s := by refine (gauge_lt_one_subset_self hs₁ ‹_› <| absorbent_nhds_zero <| hs₂.mem_nhds hs₀).antisymm ?_ - convert interior_subset_gauge_lt_one s + convert! interior_subset_gauge_lt_one s exact hs₂.interior_eq.symm theorem gauge_lt_one_of_mem_of_isOpen (hs₂ : IsOpen s) {x : E} (hx : x ∈ s) : @@ -543,9 +543,9 @@ theorem gauge_closure_zero : gauge (closure (0 : Set E)) = 0 := funext fun x ↦ simp only [← singleton_zero, gauge_def', mem_closure_zero_iff_norm, norm_smul, mul_eq_zero, norm_eq_zero, inv_eq_zero] rcases (norm_nonneg x).eq_or_lt' with hx | hx - · convert csInf_Ioi (a := (0 : ℝ)) + · convert! csInf_Ioi (a := (0 : ℝ)) exact Set.ext fun r ↦ and_iff_left (.inr hx) - · convert Real.sInf_empty + · convert! Real.sInf_empty exact eq_empty_of_forall_notMem fun r ⟨hr₀, hr⟩ ↦ hx.ne' <| hr.resolve_left hr₀.out.ne' @[simp] diff --git a/Mathlib/Analysis/Convex/Independent.lean b/Mathlib/Analysis/Convex/Independent.lean index a5e1b2e7559a1a..c7b9a8a152a995 100644 --- a/Mathlib/Analysis/Convex/Independent.lean +++ b/Mathlib/Analysis/Convex/Independent.lean @@ -93,7 +93,7 @@ protected theorem ConvexIndependent.range {p : ι → E} (hc : ConvexIndependent let f : Set.range p → ι := fun x => x.property.choose have hf : ∀ x, p (f x) = x := fun x => x.property.choose_spec let fe : Set.range p ↪ ι := ⟨f, fun x₁ x₂ he => Subtype.ext (hf x₁ ▸ hf x₂ ▸ he ▸ rfl)⟩ - convert hc.comp_embedding fe + convert! hc.comp_embedding fe ext rw [Embedding.coeFn_mk, comp_apply, hf] diff --git a/Mathlib/Analysis/Convex/Jensen.lean b/Mathlib/Analysis/Convex/Jensen.lean index c5478929caf55e..ed073f079b1b25 100644 --- a/Mathlib/Analysis/Convex/Jensen.lean +++ b/Mathlib/Analysis/Convex/Jensen.lean @@ -54,7 +54,7 @@ theorem ConvexOn.map_centerMass_le (hf : ConvexOn 𝕜 s f) (h₀ : ∀ i ∈ t, f (t.centerMass w p) ≤ t.centerMass w (f ∘ p) := by have hmem' : ∀ i ∈ t, (p i, (f ∘ p) i) ∈ { p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2 } := fun i hi => ⟨hmem i hi, le_rfl⟩ - convert (hf.convex_epigraph.centerMass_mem h₀ h₁ hmem').2 <;> + convert! (hf.convex_epigraph.centerMass_mem h₀ h₁ hmem').2 <;> simp only [centerMass, Function.comp, Prod.smul_fst, Prod.fst_sum, Prod.smul_snd, Prod.snd_sum] /-- Concave **Jensen's inequality**, `Finset.centerMass` version. -/ diff --git a/Mathlib/Analysis/Convex/PathConnected.lean b/Mathlib/Analysis/Convex/PathConnected.lean index 5275a4a3966a82..2daa2c26a7bec5 100644 --- a/Mathlib/Analysis/Convex/PathConnected.lean +++ b/Mathlib/Analysis/Convex/PathConnected.lean @@ -109,7 +109,7 @@ protected theorem IsTopologicalAddGroup.pathConnectedSpace : PathConnectedSpace is path connected in `p` then the complement of `q` is path connected in `E`. -/ theorem isPathConnected_compl_of_isPathConnected_compl_zero {p q : Submodule ℝ E} (hpq : IsCompl p q) (hpc : IsPathConnected ({0}ᶜ : Set p)) : IsPathConnected (qᶜ : Set E) := by - convert (hpc.image continuous_subtype_val).add q.isPathConnected using 1 + convert! (hpc.image continuous_subtype_val).add q.isPathConnected using 1 trans Submodule.prodEquivOfIsCompl p q hpq '' ({0}ᶜ ×ˢ univ) · rw [prod_univ, LinearEquiv.image_eq_preimage_symm] ext @@ -123,12 +123,12 @@ theorem segment_image_Ico {x y : ℝ} (h : x < y) : (Path.segment x y) '' Ico 0 simp_rw [Path.segment_apply, ← image_image _ Subtype.val (Ico 0 1)] simp only [lineMap_apply, vsub_eq_sub, smul_eq_mul, vadd_eq_add, image_subtype_val_Ico, Icc.coe_zero, Icc.coe_one] - convert image_affine_Ico (sub_pos_of_lt h) x 0 1 using 2 <;> ring + convert! image_affine_Ico (sub_pos_of_lt h) x 0 1 using 2 <;> ring theorem segment_image_Ioc {x y : ℝ} (h : x < y) : (Path.segment x y) '' Ioc 0 1 = Ioc x y := by simp_rw [Path.segment_apply, ← image_image _ Subtype.val (Ioc 0 1)] simp only [lineMap_apply, vsub_eq_sub, smul_eq_mul, vadd_eq_add, image_subtype_val_Ioc, Icc.coe_zero, Icc.coe_one] - convert image_affine_Ioc (sub_pos_of_lt h) x 0 1 using 2 <;> ring + convert! image_affine_Ioc (sub_pos_of_lt h) x 0 1 using 2 <;> ring end Real diff --git a/Mathlib/Analysis/Convex/Segment.lean b/Mathlib/Analysis/Convex/Segment.lean index 753c068b626707..55af8816d0d3cd 100644 --- a/Mathlib/Analysis/Convex/Segment.lean +++ b/Mathlib/Analysis/Convex/Segment.lean @@ -206,24 +206,24 @@ theorem openSegment_eq_image (x y : E) : theorem segment_eq_image' (x y : E) : [x -[𝕜] y] = (fun θ : 𝕜 => x + θ • (y - x)) '' Icc (0 : 𝕜) 1 := by - convert segment_eq_image 𝕜 x y using 2 + convert! segment_eq_image 𝕜 x y using 2 simp only [smul_sub, sub_smul, one_smul] abel theorem openSegment_eq_image' (x y : E) : openSegment 𝕜 x y = (fun θ : 𝕜 => x + θ • (y - x)) '' Ioo (0 : 𝕜) 1 := by - convert openSegment_eq_image 𝕜 x y using 2 + convert! openSegment_eq_image 𝕜 x y using 2 simp only [smul_sub, sub_smul, one_smul] abel theorem segment_eq_image_lineMap (x y : E) : [x -[𝕜] y] = AffineMap.lineMap x y '' Icc (0 : 𝕜) 1 := by - convert segment_eq_image 𝕜 x y using 2 + convert! segment_eq_image 𝕜 x y using 2 exact AffineMap.lineMap_apply_module _ _ _ theorem openSegment_eq_image_lineMap (x y : E) : openSegment 𝕜 x y = AffineMap.lineMap x y '' Ioo (0 : 𝕜) 1 := by - convert openSegment_eq_image 𝕜 x y using 2 + convert! openSegment_eq_image 𝕜 x y using 2 exact AffineMap.lineMap_apply_module _ _ _ theorem lineMap_mem_openSegment (a b : E) {t : 𝕜} (ht : t ∈ Ioo 0 1) : @@ -297,7 +297,7 @@ lemma segment_inter_subset_endpoint_of_linearIndependent_sub have Hy : y = (y - c) + c := by abel rw [Hx, Hy, smul_add, smul_add] at H have : c + q • (y - c) = c + p • (x - c) := by - convert H using 1 <;> simp [sub_smul] + convert! H using 1 <;> simp [sub_smul] obtain ⟨rfl, rfl⟩ : p = 0 ∧ q = 0 := h.eq_zero_of_pair' ((add_right_inj c).1 this).symm simp @@ -324,7 +324,7 @@ lemma segment_inter_eq_endpoint_of_linearIndependent_of_ne apply segment_inter_eq_endpoint_of_linearIndependent_sub simp only [add_sub_add_left_eq_sub] suffices H : LinearIndependent 𝕜 ![(-1 : 𝕜) • x + t • y, (-1 : 𝕜) • x + s • y] by - convert H using 1; simp only [neg_smul, one_smul]; abel_nf + convert! H using 1; simp only [neg_smul, one_smul]; abel_nf nontriviality 𝕜 rw [LinearIndependent.pair_add_smul_add_smul_iff] aesop @@ -343,7 +343,7 @@ theorem midpoint_mem_segment [Invertible (2 : 𝕜)] (x y : E) : midpoint 𝕜 x theorem mem_openSegment_sub_add [Invertible (2 : 𝕜)] (x y : E) : x ∈ openSegment 𝕜 (x - y) (x + y) := by - convert midpoint_mem_openSegment (𝕜 := 𝕜) (x - y) (x + y) + convert! midpoint_mem_openSegment (𝕜 := 𝕜) (x - y) (x + y) rw [midpoint_sub_add] theorem mem_segment_sub_add [Invertible (2 : 𝕜)] (x y : E) : x ∈ [x - y -[𝕜] x + y] := @@ -351,7 +351,7 @@ theorem mem_segment_sub_add [Invertible (2 : 𝕜)] (x y : E) : x ∈ [x - y -[ theorem mem_openSegment_add_sub [Invertible (2 : 𝕜)] (x y : E) : x ∈ openSegment 𝕜 (x + y) (x - y) := by - convert midpoint_mem_openSegment (𝕜 := 𝕜) (x + y) (x - y) + convert! midpoint_mem_openSegment (𝕜 := 𝕜) (x + y) (x - y) rw [midpoint_add_sub] theorem mem_segment_add_sub [Invertible (2 : 𝕜)] (x y : E) : x ∈ [x + y -[𝕜] x - y] := diff --git a/Mathlib/Analysis/Convex/Side.lean b/Mathlib/Analysis/Convex/Side.lean index e96ba115ac515b..000cf596517e4f 100644 --- a/Mathlib/Analysis/Convex/Side.lean +++ b/Mathlib/Analysis/Convex/Side.lean @@ -748,7 +748,7 @@ theorem isConnected_setOf_wSameSide {s : AffineSubspace ℝ P} (x : P) (h : (s : · rw [setOf_wSameSide_eq_image2 hx hp, ← Set.image_prod] refine (isConnected_Ici.prod (isConnected_iff_connectedSpace.2 ?_)).image _ ((continuous_fst.smul continuous_const).vadd continuous_snd).continuousOn - convert AddTorsor.connectedSpace s.direction s + convert! AddTorsor.connectedSpace s.direction s theorem isPreconnected_setOf_wSameSide (s : AffineSubspace ℝ P) (x : P) : IsPreconnected { y | s.WSameSide x y } := by @@ -765,7 +765,7 @@ theorem isConnected_setOf_sSameSide {s : AffineSubspace ℝ P} {x : P} (hx : x rw [setOf_sSameSide_eq_image2 hx hp, ← Set.image_prod] refine (isConnected_Ioi.prod (isConnected_iff_connectedSpace.2 ?_)).image _ ((continuous_fst.smul continuous_const).vadd continuous_snd).continuousOn - convert AddTorsor.connectedSpace s.direction s + convert! AddTorsor.connectedSpace s.direction s theorem isPreconnected_setOf_sSameSide (s : AffineSubspace ℝ P) (x : P) : IsPreconnected { y | s.SSameSide x y } := by @@ -789,7 +789,7 @@ theorem isConnected_setOf_wOppSide {s : AffineSubspace ℝ P} (x : P) (h : (s : · rw [setOf_wOppSide_eq_image2 hx hp, ← Set.image_prod] refine (isConnected_Iic.prod (isConnected_iff_connectedSpace.2 ?_)).image _ ((continuous_fst.smul continuous_const).vadd continuous_snd).continuousOn - convert AddTorsor.connectedSpace s.direction s + convert! AddTorsor.connectedSpace s.direction s theorem isPreconnected_setOf_wOppSide (s : AffineSubspace ℝ P) (x : P) : IsPreconnected { y | s.WOppSide x y } := by @@ -806,7 +806,7 @@ theorem isConnected_setOf_sOppSide {s : AffineSubspace ℝ P} {x : P} (hx : x rw [setOf_sOppSide_eq_image2 hx hp, ← Set.image_prod] refine (isConnected_Iio.prod (isConnected_iff_connectedSpace.2 ?_)).image _ ((continuous_fst.smul continuous_const).vadd continuous_snd).continuousOn - convert AddTorsor.connectedSpace s.direction s + convert! AddTorsor.connectedSpace s.direction s theorem isPreconnected_setOf_sOppSide (s : AffineSubspace ℝ P) (x : P) : IsPreconnected { y | s.SOppSide x y } := by diff --git a/Mathlib/Analysis/Convex/SimplicialComplex/Basic.lean b/Mathlib/Analysis/Convex/SimplicialComplex/Basic.lean index f3ac4cc75bc7ac..fb37553a12e151 100644 --- a/Mathlib/Analysis/Convex/SimplicialComplex/Basic.lean +++ b/Mathlib/Analysis/Convex/SimplicialComplex/Basic.lean @@ -82,7 +82,7 @@ theorem mem_space_iff : x ∈ K.space ↔ ∃ s ∈ K.faces, x ∈ convexHull simp [space] theorem convexHull_subset_space (hs : s ∈ K.faces) : convexHull 𝕜 s ⊆ K.space := by - convert subset_biUnion_of_mem hs + convert! subset_biUnion_of_mem hs rfl protected theorem subset_space (hs : s ∈ K.faces) : (s : Set E) ⊆ K.space := diff --git a/Mathlib/Analysis/Convex/Slope.lean b/Mathlib/Analysis/Convex/Slope.lean index 191b5a019bea56..9fc671d386ac95 100644 --- a/Mathlib/Analysis/Convex/Slope.lean +++ b/Mathlib/Analysis/Convex/Slope.lean @@ -206,8 +206,8 @@ theorem ConvexOn.secant_mono (hf : ConvexOn 𝕜 s f) {a x y : 𝕜} (ha : a ∈ · simp rcases lt_or_gt_of_ne hxa with hxa | hxa · rcases lt_or_gt_of_ne hya with hya | hya - · convert hf.secant_mono_aux3 hx ha hxy hya using 1 <;> rw [← neg_div_neg_eq] <;> simp - · convert hf.slope_mono_adjacent hx hy hxa hya using 1 + · convert! hf.secant_mono_aux3 hx ha hxy hya using 1 <;> rw [← neg_div_neg_eq] <;> simp + · convert! hf.slope_mono_adjacent hx hy hxa hya using 1 rw [← neg_div_neg_eq]; simp · exact hf.secant_mono_aux2 ha hy hxa hxy @@ -246,9 +246,9 @@ theorem StrictConvexOn.secant_strict_mono (hf : StrictConvexOn 𝕜 s f) {a x y (f x - f a) / (x - a) < (f y - f a) / (y - a) := by rcases lt_or_gt_of_ne hxa with hxa | hxa · rcases lt_or_gt_of_ne hya with hya | hya - · convert hf.secant_strict_mono_aux3 hx ha hxy hya using 1 <;> rw [← neg_div_neg_eq] <;> + · convert! hf.secant_strict_mono_aux3 hx ha hxy hya using 1 <;> rw [← neg_div_neg_eq] <;> simp - · convert hf.slope_strict_mono_adjacent hx hy hxa hya using 1 + · convert! hf.slope_strict_mono_adjacent hx hy hxa hya using 1 rw [← neg_div_neg_eq]; simp · exact hf.secant_strict_mono_aux2 ha hy hxa hxy diff --git a/Mathlib/Analysis/Convex/SpecificFunctions/Basic.lean b/Mathlib/Analysis/Convex/SpecificFunctions/Basic.lean index 94dfe931b0ba52..0784a2b67c997c 100644 --- a/Mathlib/Analysis/Convex/SpecificFunctions/Basic.lean +++ b/Mathlib/Analysis/Convex/SpecificFunctions/Basic.lean @@ -110,13 +110,13 @@ theorem one_add_mul_self_lt_rpow_one_add {s : ℝ} (hs : -1 ≤ s) (hs' : s ≠ apply exp_strictMono rcases lt_or_gt_of_ne hs' with hs' | hs' · rw [← div_lt_iff₀ hp', ← div_lt_div_right_of_neg hs'] - convert strictConcaveOn_log_Ioi.secant_strict_mono (zero_lt_one' ℝ) hs2 hs1 hs4 hs3 _ using 1 + convert! strictConcaveOn_log_Ioi.secant_strict_mono (zero_lt_one' ℝ) hs2 hs1 hs4 hs3 _ using 1 · rw [add_sub_cancel_left, log_one, sub_zero] · rw [add_sub_cancel_left, div_div, log_one, sub_zero] · gcongr exact mul_lt_of_one_lt_left hs' hp · rw [← div_lt_iff₀ hp', ← div_lt_div_iff_of_pos_right hs'] - convert strictConcaveOn_log_Ioi.secant_strict_mono (zero_lt_one' ℝ) hs1 hs2 hs3 hs4 _ using 1 + convert! strictConcaveOn_log_Ioi.secant_strict_mono (zero_lt_one' ℝ) hs1 hs2 hs3 hs4 _ using 1 · rw [add_sub_cancel_left, div_div, log_one, sub_zero] · rw [add_sub_cancel_left, log_one, sub_zero] · gcongr @@ -151,13 +151,13 @@ theorem rpow_one_add_lt_one_add_mul_self {s : ℝ} (hs : -1 ≤ s) (hs' : s ≠ apply exp_strictMono rcases lt_or_gt_of_ne hs' with hs' | hs' · rw [← lt_div_iff₀ hp1, ← div_lt_div_right_of_neg hs'] - convert strictConcaveOn_log_Ioi.secant_strict_mono (zero_lt_one' ℝ) hs1 hs2 hs3 hs4 _ using 1 + convert! strictConcaveOn_log_Ioi.secant_strict_mono (zero_lt_one' ℝ) hs1 hs2 hs3 hs4 _ using 1 · rw [add_sub_cancel_left, div_div, log_one, sub_zero] · rw [add_sub_cancel_left, log_one, sub_zero] · gcongr exact lt_mul_of_lt_one_left hs' hp2 · rw [← lt_div_iff₀ hp1, ← div_lt_div_iff_of_pos_right hs'] - convert strictConcaveOn_log_Ioi.secant_strict_mono (zero_lt_one' ℝ) hs2 hs1 hs4 hs3 _ using 1 + convert! strictConcaveOn_log_Ioi.secant_strict_mono (zero_lt_one' ℝ) hs2 hs1 hs4 hs3 _ using 1 · rw [add_sub_cancel_left, log_one, sub_zero] · rw [add_sub_cancel_left, div_div, log_one, sub_zero] · gcongr @@ -210,7 +210,7 @@ theorem convexOn_rpow {p : ℝ} (hp : 1 ≤ p) : ConvexOn ℝ (Ici 0) fun x : exact (strictConvexOn_rpow hp).convexOn theorem convexOn_rpow_left {b : ℝ} (hb : 0 < b) : ConvexOn ℝ Set.univ (fun (x : ℝ) => b ^ x) := by - convert convexOn_exp.comp_linearMap (LinearMap.mul ℝ ℝ (Real.log b)) using 1 + convert! convexOn_exp.comp_linearMap (LinearMap.mul ℝ ℝ (Real.log b)) using 1 ext x simp [Real.rpow_def_of_pos hb] diff --git a/Mathlib/Analysis/Convex/SpecificFunctions/Deriv.lean b/Mathlib/Analysis/Convex/SpecificFunctions/Deriv.lean index cc113fe23a219e..33d22c76e8fff5 100644 --- a/Mathlib/Analysis/Convex/SpecificFunctions/Deriv.lean +++ b/Mathlib/Analysis/Convex/SpecificFunctions/Deriv.lean @@ -83,8 +83,8 @@ theorem int_prod_range_nonneg (m : ℤ) (n : ℕ) (hn : Even n) : refine mul_nonneg ihn ?_; generalize (1 + 1) * n = k rcases le_or_gt m k with hmk | hmk · have : m ≤ k + 1 := hmk.trans (lt_add_one (k : ℤ)).le - convert mul_nonneg_of_nonpos_of_nonpos (sub_nonpos_of_le hmk) _ - convert sub_nonpos_of_le this + convert! mul_nonneg_of_nonpos_of_nonpos (sub_nonpos_of_le hmk) _ + convert! sub_nonpos_of_le this · exact mul_nonneg (sub_nonneg_of_le hmk.le) (sub_nonneg_of_le hmk) theorem int_prod_range_pos {m : ℤ} {n : ℕ} (hn : Even n) (hm : m ∉ Ico (0 : ℤ) n) : @@ -114,7 +114,7 @@ section SqrtMulLog theorem hasDerivAt_sqrt_mul_log {x : ℝ} (hx : x ≠ 0) : HasDerivAt (fun x => √x * log x) ((2 + log x) / (2 * √x)) x := by - convert (hasDerivAt_sqrt hx).mul (hasDerivAt_log hx) using 1 + convert! (hasDerivAt_sqrt hx).mul (hasDerivAt_log hx) using 1 rw [add_div, div_mul_cancel_left₀ two_ne_zero, ← div_eq_mul_inv, sqrt_div_self', add_comm, one_div, one_div, ← div_eq_inv_mul] @@ -140,8 +140,9 @@ theorem deriv2_sqrt_mul_log (x : ℝ) : refine (hasDerivWithinAt_const _ _ 0).congr_of_mem (fun x hx => ?_) hx rw [sqrt_eq_zero_of_nonpos hx, mul_zero, div_zero] · have h₀ : √x ≠ 0 := sqrt_ne_zero'.2 hx - convert (((hasDerivAt_log hx.ne').const_add 2).div ((hasDerivAt_sqrt hx.ne').const_mul 2) <| - mul_ne_zero two_ne_zero h₀).deriv using 1 + convert! + (((hasDerivAt_log hx.ne').const_add 2).div ((hasDerivAt_sqrt hx.ne').const_mul 2) <| + mul_ne_zero two_ne_zero h₀).deriv using 1 nth_rw 3 [← mul_self_sqrt hx.le] field diff --git a/Mathlib/Analysis/Convex/Star.lean b/Mathlib/Analysis/Convex/Star.lean index a375ccd0faeee6..1681d767da1ebe 100644 --- a/Mathlib/Analysis/Convex/Star.lean +++ b/Mathlib/Analysis/Convex/Star.lean @@ -156,7 +156,7 @@ variable [Module 𝕜 E] [Module 𝕜 F] {x y z : E} {s : Set E} theorem StarConvex.mem [ZeroLEOneClass 𝕜] (hs : StarConvex 𝕜 x s) (h : s.Nonempty) : x ∈ s := by obtain ⟨y, hy⟩ := h - convert hs hy zero_le_one le_rfl (add_zero 1) + convert! hs hy zero_le_one le_rfl (add_zero 1) rw [one_smul, zero_smul, add_zero] theorem starConvex_iff_forall_pos (hx : x ∈ s) : StarConvex 𝕜 x s ↔ diff --git a/Mathlib/Analysis/Convex/StdSimplex.lean b/Mathlib/Analysis/Convex/StdSimplex.lean index 795c64bf9773fc..6d15a5177c2763 100644 --- a/Mathlib/Analysis/Convex/StdSimplex.lean +++ b/Mathlib/Analysis/Convex/StdSimplex.lean @@ -86,6 +86,8 @@ theorem ite_eq_mem_stdSimplex (i : ι) : (if i = · then (1 : 𝕜) else 0) ∈ variable [IsOrderedRing 𝕜] +set_option linter.overlappingInstances false + #adaptation_note /-- nightly-2024-03-11 we need a type annotation on the segment in the following two lemmas. -/ @@ -148,7 +150,7 @@ theorem convexHull_basis_eq_stdSimplex [DecidableEq ι] : /-- `stdSimplex 𝕜 ι` is the convex hull of the points `Pi.single i 1` for `i : ι`. -/ theorem convexHull_rangle_single_eq_stdSimplex [DecidableEq ι] : convexHull R (range fun i : ι ↦ Pi.single i 1) = stdSimplex R ι := by - convert convexHull_basis_eq_stdSimplex R ι + convert! convexHull_basis_eq_stdSimplex R ι aesop variable {ι R} diff --git a/Mathlib/Analysis/Convex/StoneSeparation.lean b/Mathlib/Analysis/Convex/StoneSeparation.lean index 0aeefbef488dff..7926af5443eda2 100644 --- a/Mathlib/Analysis/Convex/StoneSeparation.lean +++ b/Mathlib/Analysis/Convex/StoneSeparation.lean @@ -65,8 +65,10 @@ theorem not_disjoint_segment_convexHull_triple {p q u v x y z : E} (hz : z ∈ s · simp [w, Fin.sum_univ_succ] linear_combination (au * bv - 1 * au) * habz + (-(1 * az * au) + au) * habv + az * av * habu have hz : ∀ i, z i ∈ ({p, q, az • x + bz • y} : Set E) := fun i => by fin_cases i <;> simp [z] - convert (Finset.centerMass_mem_convexHull (Finset.univ : Finset (Fin 3)) (fun i _ => hw₀ i) - (by rwa [hw]) fun i _ => hz i : Finset.univ.centerMass w z ∈ _) + convert! + (Finset.centerMass_mem_convexHull (Finset.univ : Finset (Fin 3)) (fun i _ => hw₀ i) + (by rwa [hw]) fun i _ => hz i : + Finset.univ.centerMass w z ∈ _) rw [Finset.centerMass, hw] trans (az * av + bz * au)⁻¹ • ((az * av * bu) • p + ((bz * au * bv) • q + (au * av) • (az • x + bz • y))) diff --git a/Mathlib/Analysis/Convex/Strict.lean b/Mathlib/Analysis/Convex/Strict.lean index 0fccb78045d6a9..2604263348abc9 100644 --- a/Mathlib/Analysis/Convex/Strict.lean +++ b/Mathlib/Analysis/Convex/Strict.lean @@ -361,7 +361,7 @@ theorem strictConvex_iff_div : ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → (a / (a + b)) • x + (b / (a + b)) • y ∈ interior s := ⟨fun h x hx y hy hxy a b ha hb ↦ h hx hy hxy (by positivity) (by positivity) (by field), fun h x hx y hy hxy a b ha hb hab ↦ by - convert h hx hy hxy ha hb <;> rw [hab, div_one]⟩ + convert! h hx hy hxy ha hb <;> rw [hab, div_one]⟩ theorem StrictConvex.mem_smul_of_zero_mem (hs : StrictConvex 𝕜 s) (zero_mem : (0 : E) ∈ s) (hx : x ∈ s) (hx₀ : x ≠ 0) {t : 𝕜} (ht : 1 < t) : x ∈ t • interior s := by diff --git a/Mathlib/Analysis/Convex/Visible.lean b/Mathlib/Analysis/Convex/Visible.lean index c22d2e245e0eb5..4edf4e41f7bf90 100644 --- a/Mathlib/Analysis/Convex/Visible.lean +++ b/Mathlib/Analysis/Convex/Visible.lean @@ -78,7 +78,7 @@ lemma IsVisible.of_convexHull_of_pos {ι : Type*} {t : Finset ι} {a : ι → V} (hi : i ∈ t) (hwi : 0 < w i) : IsVisible 𝕜 (convexHull 𝕜 s) x (a i) := by classical obtain hwi | hwi : w i = 1 ∨ w i < 1 := eq_or_lt_of_le <| (single_le_sum hw₀ hi).trans_eq hw₁ - · convert hw + · convert! hw rw [← one_smul 𝕜 (a i), ← hwi, eq_comm] rw [← hwi, ← sub_eq_zero, ← sum_erase_eq_sub hi, sum_eq_zero_iff_of_nonneg fun j hj ↦ hw₀ _ <| erase_subset _ _ hj] at hw₁ diff --git a/Mathlib/Analysis/Convolution.lean b/Mathlib/Analysis/Convolution.lean index 76e2530c5a9983..e11a45fc803e23 100644 --- a/Mathlib/Analysis/Convolution.lean +++ b/Mathlib/Analysis/Convolution.lean @@ -143,7 +143,7 @@ theorem _root_.HasCompactSupport.convolution_integrand_bound_left (hcf : HasComp (hf : Continuous f) {x t : G} {s : Set G} (hx : x ∈ s) : ‖L (f (x - t)) (g t)‖ ≤ (-tsupport f + s).indicator (fun t => (‖L‖ * ⨆ i, ‖f i‖) * ‖g t‖) t := by - convert hcf.convolution_integrand_bound_right L.flip hf hx using 1 + convert! hcf.convolution_integrand_bound_right L.flip hf hx using 1 simp_rw [L.opNorm_flip, mul_right_comm] end NoMeasurability @@ -307,9 +307,11 @@ theorem _root_.HasCompactSupport.convolutionExistsAt {x₀ : G} (μ.restrict (tsupport fun t : G => L (f t) (g (x₀ - t)))) := by apply (hg.comp v.continuous).continuousOn.aestronglyMeasurable_of_isCompact h exact (isClosed_tsupport _).measurableSet - convert ((v.continuous.measurable.measurePreserving - (μ.restrict (tsupport fun t => L (f t) (g (x₀ - t))))).aestronglyMeasurable_comp_iff - v.measurableEmbedding).1 A + convert! + ((v.continuous.measurable.measurePreserving + (μ.restrict (tsupport fun t => L (f t) (g (x₀ - t))))).aestronglyMeasurable_comp_iff + v.measurableEmbedding).1 + A ext x simp only [v, Homeomorph.neg, sub_eq_add_neg, val_toAddUnits_apply, Homeomorph.trans_apply, Equiv.neg_apply, Homeomorph.homeomorph_mk_coe, Homeomorph.coe_addLeft] @@ -368,7 +370,7 @@ theorem convolutionExistsAt_flip : theorem ConvolutionExistsAt.integrable_swap (h : ConvolutionExistsAt f g x L μ) : Integrable (fun t => L (f (x - t)) (g t)) μ := by - convert h.comp_sub_left x + convert! h.comp_sub_left x simp_rw [sub_sub_self] theorem convolutionExistsAt_iff_integrable_swap : @@ -504,7 +506,7 @@ theorem support_convolution_subset_swap : support (f ⋆[L, μ] g) ⊆ support g apply h2x simp_rw [Set.mem_add, ← exists_and_left, not_exists, not_and_or, notMem_support] at hx rw [convolution_def] - convert integral_zero G F using 2 + convert! integral_zero G F using 2 ext t rcases hx (x - t) t with (h | h | h) · rw [h, (L _).map_zero] @@ -770,7 +772,7 @@ theorem dist_convolution_le {f : G → ℝ} {x₀ : G} {R ε : ℝ} {z₀ : E'} (hmg : AEStronglyMeasurable g μ) (hg : ∀ x ∈ ball x₀ R, dist (g x) z₀ ≤ ε) : dist ((f ⋆[lsmul ℝ ℝ, μ] g : G → E') x₀) z₀ ≤ ε := by have hif : Integrable f μ := integrable_of_integral_eq_one hintf - convert (dist_convolution_le' (lsmul ℝ ℝ) hε hif hf hmg hg).trans _ + convert! (dist_convolution_le' (lsmul ℝ ℝ) hε hif hf hmg hg).trans _ · simp_rw [lsmul_apply, integral_smul_const, hintf, one_smul] · simp_rw [Real.norm_of_nonneg (hnf _), hintf, mul_one] exact (mul_le_mul_of_nonneg_right opNorm_lsmul_le hε).trans_eq (one_mul ε) @@ -904,7 +906,7 @@ theorem convolution_assoc (hL : ∀ (x : E) (y : E') (z : E''), L₂ (L x y) z = (measurePreserving_sub_prod μ ν).map_eq suffices Integrable (uncurry fun x y => L₃ (f y) (L₄ (g x) (k (x₀ - y - x)))) (μ.prod ν) by rw [← h3] at this - convert this.comp_measurable (measurable_sub.prodMk measurable_snd) + convert! this.comp_measurable (measurable_sub.prodMk measurable_snd) ext ⟨x, y⟩ simp +unfoldPartialApp only [uncurry, Function.comp_apply, sub_sub_sub_cancel_right] @@ -964,7 +966,7 @@ theorem posConvolution_eq_convolution_indicator (f : ℝ → E) (g : ℝ → E') indicator_of_mem (mem_Ioi.mpr <| sub_pos.mpr ht.2)] · rw [indicator_of_notMem (notMem_Ioo_of_ge ht), indicator_of_notMem (notMem_Ioi.mpr (sub_nonpos_of_le ht)), map_zero] - · convert (integral_zero ℝ F).symm with t + · convert! (integral_zero ℝ F).symm with t by_cases ht : 0 < t · rw [indicator_of_notMem (_ : x - t ∉ Ioi 0), map_zero] rw [notMem_Ioi] at h ⊢ @@ -989,7 +991,7 @@ theorem integral_posConvolution [CompleteSpace E] [CompleteSpace E'] [CompleteSp L (∫ x : ℝ in Ioi 0, f x ∂ν) (∫ x : ℝ in Ioi 0, g x ∂μ) := by rw [← integrable_indicator_iff measurableSet_Ioi] at hf hg simp_rw [← integral_indicator measurableSet_Ioi] - convert integral_convolution L hf hg using 4 with x + convert! integral_convolution L hf hg using 4 with x apply posConvolution_eq_convolution_indicator end Nonneg diff --git a/Mathlib/Analysis/Distribution/ContDiffMapSupportedIn.lean b/Mathlib/Analysis/Distribution/ContDiffMapSupportedIn.lean index 210179d1e80e85..675ef827c942fb 100644 --- a/Mathlib/Analysis/Distribution/ContDiffMapSupportedIn.lean +++ b/Mathlib/Analysis/Distribution/ContDiffMapSupportedIn.lean @@ -381,14 +381,14 @@ noncomputable def fderivLM : else 0 map_add' f g := by split_ifs with hk - · have hk' : 0 < (n : ℕ∞ω) := mod_cast (ENat.add_one_pos.trans_le hk) + · have hk' : 0 < (n : ℕ∞ω) := mod_cast (add_pos_of_right zero_lt_one k).trans_le hk ext simp [fderiv_add (f.contDiff.differentiable hk'.ne').differentiableAt (g.contDiff.differentiable hk'.ne').differentiableAt] · simp map_smul' c f := by split_ifs with hk - · have hk' : 0 < (n : ℕ∞ω) := mod_cast (ENat.add_one_pos.trans_le hk) + · have hk' : 0 < (n : ℕ∞ω) := mod_cast (add_pos_of_right zero_lt_one k).trans_le hk ext simp [fderiv_const_smul (f.contDiff.differentiable hk'.ne').differentiableAt] · simp diff --git a/Mathlib/Analysis/Distribution/SchwartzSpace/Basic.lean b/Mathlib/Analysis/Distribution/SchwartzSpace/Basic.lean index 68e057c21b6d33..d72492b71f3b0c 100644 --- a/Mathlib/Analysis/Distribution/SchwartzSpace/Basic.lean +++ b/Mathlib/Analysis/Distribution/SchwartzSpace/Basic.lean @@ -5,13 +5,19 @@ Authors: Moritz Doll -/ module -public import Mathlib.Analysis.LocallyConvex.WithSeminorms +public import Mathlib.Analysis.Calculus.IteratedDeriv.Defs +public import Mathlib.Analysis.Distribution.TemperateGrowth public import Mathlib.Analysis.Normed.Group.ZeroAtInfty -public import Mathlib.Analysis.Normed.Lp.SmoothApprox public import Mathlib.Analysis.SpecialFunctions.Pow.Real -public import Mathlib.Analysis.Distribution.TemperateGrowth -public import Mathlib.Topology.Algebra.UniformFilterBasis public import Mathlib.MeasureTheory.Function.L2Space +public import Mathlib.Tactic.FunProp +public import Mathlib.Topology.Algebra.UniformFilterBasis + +import Mathlib.Analysis.Calculus.ContDiff.Bounds +import Mathlib.Analysis.Calculus.ContDiff.Operations +import Mathlib.Analysis.Normed.Lp.SmoothApprox +import Mathlib.Tactic.MoveAdd + /-! # Schwartz space @@ -230,7 +236,7 @@ variable [NormedField 𝕜] [NormedSpace 𝕜 F] [SMulCommClass ℝ 𝕜 F] [Nor instance instSMul : SMul 𝕜 𝓢(E, F) := ⟨fun c f => { toFun := c • (f : E → F) - smooth' := (f.smooth _).const_smul c + smooth' := by exact (f.smooth _).const_smul c decay' k n := by use f.seminormAux k n * ‖c‖ intro x @@ -263,13 +269,13 @@ private theorem seminormAux_smul_le (k n : ℕ) (c : 𝕜) (f : 𝓢(E, F)) : instance instNSMul : SMul ℕ 𝓢(E, F) := ⟨fun c f => { toFun := c • (f : E → F) - smooth' := (f.smooth _).const_smul c + smooth' := by exact (f.smooth _).const_smul c decay' := by simpa [← Nat.cast_smul_eq_nsmul ℝ] using ((c : ℝ) • f).decay' }⟩ instance instZSMul : SMul ℤ 𝓢(E, F) := ⟨fun c f => { toFun := c • (f : E → F) - smooth' := (f.smooth _).const_smul c + smooth' := by exact (f.smooth _).const_smul c decay' := by simpa [← Int.cast_smul_eq_zsmul ℝ] using ((c : ℝ) • f).decay' }⟩ end SMul @@ -278,7 +284,7 @@ section Zero instance instZero : Zero 𝓢(E, F) := ⟨{ toFun := fun _ => 0 - smooth' := contDiff_const + smooth' := by exact contDiff_const decay' := fun _ _ => ⟨1, fun _ => by simp⟩ }⟩ instance instInhabited : Inhabited 𝓢(E, F) := @@ -305,7 +311,7 @@ section Neg instance instNeg : Neg 𝓢(E, F) := ⟨fun f => - ⟨-f, (f.smooth _).neg, fun k n => by + ⟨-f, by exact (f.smooth _).neg, fun k n => by use f.seminormAux k n intro x grw [f.decay_neg_aux k n x, f.le_seminormAux k n x]⟩⟩ @@ -319,7 +325,7 @@ section Add instance instAdd : Add 𝓢(E, F) := ⟨fun f g => - ⟨f + g, (f.smooth _).add (g.smooth _), fun k n => by + ⟨f + g, by exact (f.smooth _).add (g.smooth _), fun k n => by use f.seminormAux k n + g.seminormAux k n intro x grw [decay_add_le_aux k n f g x, f.le_seminormAux k n x, g.le_seminormAux k n x]⟩⟩ @@ -341,7 +347,7 @@ section Sub instance instSub : Sub 𝓢(E, F) := ⟨fun f g => - ⟨f - g, (f.smooth _).sub (g.smooth _), by + ⟨f - g, by exact (f.smooth _).sub (g.smooth _), by intro k n refine ⟨f.seminormAux k n + g.seminormAux k n, fun x => ?_⟩ grw [← f.le_seminormAux k n x, ← g.le_seminormAux k n x] @@ -681,11 +687,11 @@ variable [NormedSpace 𝕜 E] [NormedSpace 𝕜 G] /-- The map `f ↦ (x ↦ B (f x) (g x))` as a continuous `𝕜`-linear map on Schwartz space, where `B` is a continuous `𝕜`-linear map and `g` is a function of temperate growth. -/ def bilinLeftCLM (B : E →L[𝕜] F →L[𝕜] G) {g : D → F} (hg : g.HasTemperateGrowth) : - 𝓢(D, E) →L[𝕜] 𝓢(D, G) := by - refine mkCLM (fun f x => B (f x) (g x)) + 𝓢(D, E) →L[𝕜] 𝓢(D, G) := + mkCLM (fun f x => B (f x) (g x)) (fun _ _ _ => by simp) (fun _ _ _ => by simp) (fun f => (B.bilinearRestrictScalars ℝ).isBoundedBilinearMap.contDiff.comp - ((f.smooth ⊤).prodMk hg.1)) ?_ + ((f.smooth ⊤).prodMk hg.1)) <| by rintro ⟨k, n⟩ rcases hg.norm_iteratedFDeriv_le_uniform n with ⟨l, C, hC, hgrowth⟩ use @@ -773,7 +779,7 @@ theorem smulLeftCLM_compL_smulLeftCLM {g₁ g₂ : E → 𝕜} (hg₁ : g₁.Has theorem smulLeftCLM_smul {g : E → 𝕜} (hg : g.HasTemperateGrowth) (c : 𝕜) : smulLeftCLM F (c • g) = c • smulLeftCLM F g := by have : (fun (_ : E) ↦ c).HasTemperateGrowth := by fun_prop - convert (smulLeftCLM_compL_smulLeftCLM this hg).symm using 1 + convert! (smulLeftCLM_compL_smulLeftCLM this hg).symm using 1 simp theorem smulLeftCLM_add {g₁ g₂ : E → 𝕜} (hg₁ : g₁.HasTemperateGrowth) @@ -917,9 +923,9 @@ variable [NormedSpace 𝕜 F] /-- Composition with a function on the right is a continuous linear map on Schwartz space provided that the function is temperate and growths polynomially near infinity. -/ def compCLM {g : D → E} (hg : g.HasTemperateGrowth) - (hg_upper : ∃ (k : ℕ) (C : ℝ), ∀ x, ‖x‖ ≤ C * (1 + ‖g x‖) ^ k) : 𝓢(E, F) →L[𝕜] 𝓢(D, F) := by - refine mkCLM (fun f => f ∘ g) (fun _ _ _ => by simp) (fun _ _ _ => rfl) - (fun f => (f.smooth ⊤).comp hg.1) ?_ + (hg_upper : ∃ (k : ℕ) (C : ℝ), ∀ x, ‖x‖ ≤ C * (1 + ‖g x‖) ^ k) : 𝓢(E, F) →L[𝕜] 𝓢(D, F) := + mkCLM (fun f => f ∘ g) (fun _ _ _ => by simp) (fun _ _ _ => rfl) + (fun f => (f.smooth ⊤).comp hg.1) <| by rintro ⟨k, n⟩ rcases hg.norm_iteratedFDeriv_le_uniform n with ⟨l, C, hC, hgrowth⟩ rcases hg_upper with ⟨kg, Cg, hg_upper'⟩ @@ -1125,7 +1131,7 @@ lemma integrable_pow_mul_iteratedFDeriv variable (μ) in lemma integrable_pow_mul (f : 𝓢(D, V)) (k : ℕ) : Integrable (fun x ↦ ‖x‖ ^ k * ‖f x‖) μ := by - convert integrable_pow_mul_iteratedFDeriv μ f k 0 with x + convert! integrable_pow_mul_iteratedFDeriv μ f k 0 with x simp @[fun_prop] diff --git a/Mathlib/Analysis/Distribution/SchwartzSpace/Fourier.lean b/Mathlib/Analysis/Distribution/SchwartzSpace/Fourier.lean index 539f3d7454f562..e3a8167086a257 100644 --- a/Mathlib/Analysis/Distribution/SchwartzSpace/Fourier.lean +++ b/Mathlib/Analysis/Distribution/SchwartzSpace/Fourier.lean @@ -259,7 +259,7 @@ theorem integral_fourier_mul_eq (f : 𝓢(V, ℂ)) (g : 𝓢(V, ℂ)) : Version where the multiplication is replaced by a general bilinear form `M`. -/ theorem integral_bilin_fourierInv_eq (f : 𝓢(V, E)) (g : 𝓢(V, F)) (M : E →L[ℂ] F →L[ℂ] G) : ∫ ξ, M (𝓕⁻ f ξ) (g ξ) = ∫ x, M (f x) (𝓕⁻ g x) := by - convert (integral_bilin_fourier_eq (𝓕⁻ f) (𝓕⁻ g) M).symm + convert! (integral_bilin_fourier_eq (𝓕⁻ f) (𝓕⁻ g) M).symm · exact (FourierTransform.fourier_fourierInv_eq g).symm · exact (FourierTransform.fourier_fourierInv_eq f).symm diff --git a/Mathlib/Analysis/Distribution/Sobolev.lean b/Mathlib/Analysis/Distribution/Sobolev.lean index 2dee899f1db877..f92508dc030efc 100644 --- a/Mathlib/Analysis/Distribution/Sobolev.lean +++ b/Mathlib/Analysis/Distribution/Sobolev.lean @@ -252,7 +252,7 @@ theorem MemSobolev.fourier_memL1 {s : ℝ} (hs : Module.finrank ℝ E < 2 * s) { norm_cast simp_rw [ofReal_norm] at h simp_rw [← enorm_pow] - convert h using 4 + convert! h using 4 rw [← Real.rpow_mul_natCast (by positivity)] simp apply ((integrable_rpow_neg_one_add_norm_sq hs).congr _).lintegral_lt_top @@ -264,7 +264,7 @@ theorem MemSobolev.fourier_memL1 {s : ℝ} (hs : Module.finrank ℝ E < 2 * s) { use this.toLp • u rw [MeasureTheory.Lp.toTemperedDistribution_smul_eq] · rw [← hu, smulLeftCLM_smulLeftCLM_apply (by fun_prop) (by fun_prop)] - convert (smulLeftCLM_const 1 (𝓕 f)).symm using 1 + convert! (smulLeftCLM_const 1 (𝓕 f)).symm using 1 · simp · congr ext x diff --git a/Mathlib/Analysis/Distribution/TemperateGrowth.lean b/Mathlib/Analysis/Distribution/TemperateGrowth.lean index 5c2f91652269fc..9ac74e75efeddc 100644 --- a/Mathlib/Analysis/Distribution/TemperateGrowth.lean +++ b/Mathlib/Analysis/Distribution/TemperateGrowth.lean @@ -5,11 +5,18 @@ Authors: Moritz Doll, Anatole Dedecker, Sébastien Gouëzel -/ module -public import Mathlib.Analysis.Calculus.ContDiff.Bounds -public import Mathlib.Analysis.SpecialFunctions.JapaneseBracket -public import Mathlib.Analysis.InnerProductSpace.Calculus +public import Mathlib.Analysis.Calculus.ContDiff.FTaylorSeries +public import Mathlib.Analysis.Calculus.ContDiff.Defs +public import Mathlib.Analysis.InnerProductSpace.Defs +public import Mathlib.MeasureTheory.Function.L1Space.Integrable +public import Mathlib.MeasureTheory.Integral.Bochner.Basic public import Mathlib.Tactic.MoveAdd +import Mathlib.Analysis.Calculus.ContDiff.Bounds +import Mathlib.Analysis.InnerProductSpace.Calculus +import Mathlib.Analysis.SpecialFunctions.JapaneseBracket +import Mathlib.Analysis.SpecialFunctions.Pow.Deriv + /-! # Functions and measures of temperate growth -/ @[expose] public section @@ -201,7 +208,7 @@ theorem HasTemperateGrowth.add (hf : f.HasTemperateGrowth) (hg : g.HasTemperateG @[to_fun (attr := fun_prop)] theorem HasTemperateGrowth.sub (hf : f.HasTemperateGrowth) (hg : g.HasTemperateGrowth) : (f - g).HasTemperateGrowth := by - convert hf.add hg.neg using 1 + convert! hf.add hg.neg using 1 grind @[fun_prop] @@ -319,7 +326,7 @@ variable (H) in theorem hasTemperateGrowth_norm_sq : (fun (x : H) ↦ ‖x‖ ^ 2).HasTemperateGrowth := by apply _root_.Function.HasTemperateGrowth.of_fderiv (C := 1) (k := 2) · rw [fderiv_norm_sq] - convert (2 • innerSL ℝ).hasTemperateGrowth + convert! (2 • innerSL ℝ).hasTemperateGrowth · exact .norm_sq ℝ differentiable_id · intro x rw [norm_pow, norm_norm, one_mul, add_pow_two] diff --git a/Mathlib/Analysis/Distribution/TestFunction.lean b/Mathlib/Analysis/Distribution/TestFunction.lean index a331c32d6c3da7..c515b7de323347 100644 --- a/Mathlib/Analysis/Distribution/TestFunction.lean +++ b/Mathlib/Analysis/Distribution/TestFunction.lean @@ -567,7 +567,7 @@ lemma lineDerivCLM_apply {f : 𝓓^{n}(Ω, F)} {v : E} {x : E} : (lineDerivCLM 𝕜 v f : 𝓓^{k}(Ω, F)) x = if k + 1 ≤ n then lineDeriv ℝ f x v else 0 := by rw [lineDerivCLM_eq_fderivCLM, fderivCLM_apply] split_ifs with hk - · have hk' : 0 < (n : ℕ∞ω) := mod_cast (ENat.add_one_pos.trans_le hk) + · have hk' : 0 < (n : ℕ∞ω) := mod_cast (add_pos_of_right zero_lt_one k).trans_le hk rw [(f.contDiff.differentiable hk'.ne').differentiableAt.lineDeriv_eq_fderiv] · rfl diff --git a/Mathlib/Analysis/Fourier/AddCircle.lean b/Mathlib/Analysis/Fourier/AddCircle.lean index 4a0e6ec25a7c13..a29469c3576dde 100644 --- a/Mathlib/Analysis/Fourier/AddCircle.lean +++ b/Mathlib/Analysis/Fourier/AddCircle.lean @@ -192,7 +192,7 @@ theorem fourier_add_half_inv_index {n : ℤ} (hn : n ≠ 0) (hT : 0 < T) (x : Ad Metric.unitSphere.coe_mul] have : (@toCircle T (n • (T / 2 / n) : ℝ) : ℂ) = -1 := by rw [zsmul_eq_mul, toCircle, Function.Periodic.lift_coe, Circle.coe_exp] - convert Complex.exp_pi_mul_I using 3 + convert! Complex.exp_pi_mul_I using 3 field_simp rw [this]; simp @@ -259,7 +259,7 @@ theorem coeFn_fourierLp (p : ℝ≥0∞) [Fact (1 ≤ p)] (n : ℤ) : `Lp ℂ p haarAddCircle`. -/ theorem span_fourierLp_closure_eq_top {p : ℝ≥0∞} [Fact (1 ≤ p)] (hp : p ≠ ∞) : (span ℂ (range (@fourierLp T _ p _))).topologicalClosure = ⊤ := by - convert + convert! (ContinuousMap.toLp_denseRange ℂ (@haarAddCircle T hT) ℂ hp).topologicalClosure_map_submodule span_fourier_closure_eq_top rw [map_span] @@ -277,8 +277,9 @@ theorem orthonormal_fourier : Orthonormal ℂ (@fourierLp T _ 2 _) := by · simp [h] have hij : j + -i ≠ 0 := by exact sub_ne_zero.mpr (Ne.symm h) - convert integral_eq_zero_of_add_right_eq_neg (μ := haarAddCircle) - (fourier_add_half_inv_index hij hT.elim) + convert! + integral_eq_zero_of_add_right_eq_neg (μ := haarAddCircle) + (fourier_add_half_inv_index hij hT.elim) end Monomials @@ -462,7 +463,7 @@ theorem hasSum_sq_fourierCoeffOn haveI := Fact.mk (by linarith : 0 < b - a) rw [← add_sub_cancel a b] at hL2 have h := hL2.memLp_liftIoc.haarAddCircle - convert hasSum_sq_fourierCoeff h.toLp using 1 + convert! hasSum_sq_fourierCoeff h.toLp using 1 · simp [fourierCoeff_congr_ae h.coeFn_toLp, fourierCoeff_liftIoc_eq] · nth_rw 2 [← add_sub_cancel a b] rw [← AddCircle.integral_liftIoc_eq_intervalIntegral, ← Function.comp_def (f := (‖·‖ ^ 2))] @@ -503,7 +504,7 @@ theorem hasSum_fourier_series_of_summable (h : Summable (fourierCoeff f)) : converges everywhere pointwise to `f`. -/ theorem has_pointwise_sum_fourier_series_of_summable (h : Summable (fourierCoeff f)) (x : AddCircle T) : HasSum (fun i => fourierCoeff f i • fourier i x) (f x) := by - convert (ContinuousMap.evalCLM ℂ x).hasSum (hasSum_fourier_series_of_summable h) + convert! (ContinuousMap.evalCLM ℂ x).hasSum (hasSum_fourier_series_of_summable h) end Convergence @@ -537,7 +538,7 @@ theorem hasDerivAt_fourier (n : ℤ) (x : ℝ) : refine (?_ : HasDerivAt (fun y => exp (2 * π * I * n * y / T)) _ _).comp_ofReal rw [(fun α β => by ring : ∀ α β : ℂ, α * exp β = exp β * α)] refine (hasDerivAt_exp _).comp (x : ℂ) ?_ - convert hasDerivAt_mul_const (2 * ↑π * I * ↑n / T) using 1 + convert! hasDerivAt_mul_const (2 * ↑π * I * ↑n / T) using 1 ext1 y; ring theorem hasDerivAt_fourier_neg (n : ℤ) (x : ℝ) : @@ -550,7 +551,7 @@ variable {T} theorem has_antideriv_at_fourier_neg (hT : Fact (0 < T)) {n : ℤ} (hn : n ≠ 0) (x : ℝ) : HasDerivAt (fun y : ℝ => (T : ℂ) / (-2 * π * I * n) * fourier (-n) (y : AddCircle T)) (fourier (-n) (x : AddCircle T)) x := by - convert (hasDerivAt_fourier_neg T n x).div_const (-2 * π * I * n / T) using 1 + convert! (hasDerivAt_fourier_neg T n x).div_const (-2 * π * I * n / T) using 1 · ext1 y; rw [div_div_eq_mul_div]; ring · simp [mul_div_cancel_left₀, hn, (Fact.out : 0 < T).ne', Real.pi_pos.ne'] diff --git a/Mathlib/Analysis/Fourier/AddCircleMulti.lean b/Mathlib/Analysis/Fourier/AddCircleMulti.lean index cf36d3e4f5a05c..b2f003cf804611 100644 --- a/Mathlib/Analysis/Fourier/AddCircleMulti.lean +++ b/Mathlib/Analysis/Fourier/AddCircleMulti.lean @@ -178,17 +178,17 @@ lemma measurePreserving_equivPiIoc : measurable_subtype_coe (α := {x : d → ℝ // ∀ i, x i ∈ Ioc (a i) (a i + 1)}) simp only [Function.comp_def] at this simp_rw [coe_symm_measurableEquivPiIoc, ← this] - convert (measurePreserving_pi _ _ (fun i => AddCircle.measurePreserving_mk 1 (a i))).map_eq.symm + convert! (measurePreserving_pi _ _ (fun i => AddCircle.measurePreserving_mk 1 (a i))).map_eq.symm · simp [volume, AddCircle.haarAddCircle] - · convert (map_comap_subtype_coe (MeasurableSet.univ_pi' - (fun i => measurableSet_Ioc (a := a i))) volume) - convert (Measure.restrict_pi_pi (fun i => volume) (fun i => Ioc (a i) (a i + 1))).symm + · convert! + (map_comap_subtype_coe (MeasurableSet.univ_pi' (fun i => measurableSet_Ioc (a := a i))) volume) + convert! (Measure.restrict_pi_pi (fun i => volume) (fun i => Ioc (a i) (a i + 1))).symm grind theorem lintegral_preimage (f : UnitAddTorus d → ℝ≥0∞) (a : d → ℝ) : ∫⁻ x : UnitAddTorus d, f x = ∫⁻ (x : d → ℝ) in {x : d → ℝ | ∀ i, x i ∈ Ioc (a i) (a i + 1)}, f (fun i => x i) := by - convert lintegral_map_equiv (μ := volume.comap Subtype.val) f (measurableEquivPiIoc a).symm + convert! lintegral_map_equiv (μ := volume.comap Subtype.val) f (measurableEquivPiIoc a).symm · exact (measurePreserving_equivPiIoc a).symm.map_eq.symm · rw [← lintegral_subtype_comap (MeasurableSet.univ_pi' (fun i => measurableSet_Ioc))] rfl @@ -197,7 +197,7 @@ theorem integral_preimage {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] (f : UnitAddTorus d → E) (a : d → ℝ) : ∫ x : UnitAddTorus d, f x = ∫ (x : d → ℝ) in {x : d → ℝ | ∀ i, x i ∈ Ioc (a i) (a i + 1)}, f (fun i => x i) := by - convert integral_map_equiv (μ := volume.comap Subtype.val) (measurableEquivPiIoc a).symm f + convert! integral_map_equiv (μ := volume.comap Subtype.val) (measurableEquivPiIoc a).symm f · exact (measurePreserving_equivPiIoc a).symm.map_eq.symm · rw [← integral_subtype_comap (MeasurableSet.univ_pi' (fun i => measurableSet_Ioc))] rfl diff --git a/Mathlib/Analysis/Fourier/Convolution.lean b/Mathlib/Analysis/Fourier/Convolution.lean index 3ecf80926f6b94..7d6a45f64d377e 100644 --- a/Mathlib/Analysis/Fourier/Convolution.lean +++ b/Mathlib/Analysis/Fourier/Convolution.lean @@ -54,12 +54,12 @@ theorem integrable_prod_sub (B : F₁ →L[𝕜] F₂ →L[𝕜] F₃) {f₁ : E have : Integrable (fun x ↦ ((∫ y, ‖f₁ y‖) * ‖f₂ x‖)) := by apply hf₂.norm.bdd_mul (by fun_prop) (c := ‖(∫ y, ‖f₁ y‖)‖) filter_upwards with; rfl - convert this using 1 + convert! this using 1 ext x simp_rw [norm_mul, norm_norm] rw [integral_mul_const] congr 1 - convert integral_sub_right_eq_self _ x (μ := volume) + convert! integral_sub_right_eq_self _ x (μ := volume) rfl open FourierTransform @@ -89,7 +89,7 @@ theorem fourier_bilin_convolution_eq_integral (B : F₁ →L[𝕜] F₂ →L[ congr ext y -- Linear change of variables - convert integral_sub_right_eq_self _ y (μ := volume) + convert! integral_sub_right_eq_self _ y (μ := volume) congr simp @@ -215,7 +215,7 @@ theorem convolution_apply (B : F₁ →L[ℂ] F₂ →L[ℂ] F₃) (f : 𝓢(E, exact ⟨SchwartzMap.seminorm ℝ 0 0 g, fun x ⟨y, hy⟩ ↦ hy ▸ norm_le_seminorm ℝ g y⟩ · exact f.integrable.integrable_convolution B g.integrable · have : Integrable (fun ξ ↦ B (𝓕 f ξ) (𝓕 g ξ)) volume := (pairing B (𝓕 f) (𝓕 g)).integrable - convert this + convert! this rw [← fourier_convolution_apply B f g, fourier_convolution, pairing_apply_apply] diff --git a/Mathlib/Analysis/Fourier/FiniteAbelian/Orthogonality.lean b/Mathlib/Analysis/Fourier/FiniteAbelian/Orthogonality.lean index a822d8e1b75e34..619b123068af91 100644 --- a/Mathlib/Analysis/Fourier/FiniteAbelian/Orthogonality.lean +++ b/Mathlib/Analysis/Fourier/FiniteAbelian/Orthogonality.lean @@ -30,7 +30,7 @@ section AddGroup variable [AddGroup G] section Semifield -variable [Fintype G] [Semifield R] [IsDomain R] [CharZero R] {ψ : AddChar G R} +variable [Fintype G] [Semifield R] [CharZero R] {ψ : AddChar G R} lemma expect_eq_ite (ψ : AddChar G R) : 𝔼 a, ψ a = if ψ = 0 then 1 else 0 := by simp [Fintype.expect_eq_sum_div_card, sum_eq_ite, ite_div] diff --git a/Mathlib/Analysis/Fourier/FourierTransform.lean b/Mathlib/Analysis/Fourier/FourierTransform.lean index 1ae41a8c269724..5b68556816ea00 100644 --- a/Mathlib/Analysis/Fourier/FourierTransform.lean +++ b/Mathlib/Analysis/Fourier/FourierTransform.lean @@ -206,7 +206,7 @@ theorem integral_fourierIntegral_swap apply hM.comp_aestronglyMeasurable A' -- `exact` works, but `apply` is 10x faster! · filter_upwards with ⟨ξ, x⟩ simp only [Function.uncurry_apply_pair, norm_mul, norm_norm, ge_iff_le, ← mul_assoc] - convert M.le_opNorm₂ (g ξ) (e (-L x ξ) • f x) using 2 + convert! M.le_opNorm₂ (g ξ) (e (-L x ξ) • f x) using 2 simp variable [CompleteSpace E] [CompleteSpace F] diff --git a/Mathlib/Analysis/Fourier/FourierTransformDeriv.lean b/Mathlib/Analysis/Fourier/FourierTransformDeriv.lean index 42ae27da32748a..82dad07434eedc 100644 --- a/Mathlib/Analysis/Fourier/FourierTransformDeriv.lean +++ b/Mathlib/Analysis/Fourier/FourierTransformDeriv.lean @@ -5,13 +5,14 @@ Authors: Alex Kontorovich, David Loeffler, Heather Macbeth, Sébastien Gouëzel -/ module -public import Mathlib.Analysis.Calculus.ParametricIntegral -public import Mathlib.Analysis.Calculus.ContDiff.CPolynomial +public import Mathlib.Analysis.Calculus.FDeriv.Analytic public import Mathlib.Analysis.Fourier.AddCircle public import Mathlib.Analysis.Fourier.FourierTransform -public import Mathlib.Analysis.Calculus.FDeriv.Analytic -public import Mathlib.Analysis.Calculus.LineDeriv.IntegrationByParts -public import Mathlib.Analysis.Calculus.ContDiff.Bounds + +import Mathlib.Analysis.Calculus.ContDiff.Bounds +import Mathlib.Analysis.Calculus.ContDiff.CPolynomial +import Mathlib.Analysis.Calculus.LineDeriv.IntegrationByParts +import Mathlib.Analysis.Calculus.ParametricIntegral /-! # Derivatives of the Fourier transform @@ -115,7 +116,7 @@ lemma hasFDerivAt_fourierChar_neg_bilinear_right (v : V) (w : W) : HasFDerivAt (fun w ↦ (𝐞 (-L v w) : ℂ)) ((-2 * π * I * 𝐞 (-L v w)) • (ofRealCLM ∘L (L v))) w := by have ha : HasFDerivAt (fun w' : W ↦ L v w') (L v) w := ContinuousLinearMap.hasFDerivAt (L v) - convert (hasDerivAt_fourierChar (-L v w)).hasFDerivAt.comp w ha.neg using 1 + convert! (hasDerivAt_fourierChar (-L v w)).hasFDerivAt.comp w ha.neg using 1 ext y simp only [neg_mul, ContinuousLinearMap.coe_smul', ContinuousLinearMap.coe_comp', Pi.smul_apply, Function.comp_apply, ofRealCLM_apply, smul_eq_mul, ContinuousLinearMap.comp_neg, @@ -171,7 +172,7 @@ set_option backward.isDefEq.respectTransparency false in lemma hasFDerivAt_fourierChar_smul (v : V) (w : W) : HasFDerivAt (fun w' ↦ 𝐞 (-L v w') • f v) (𝐞 (-L v w) • fourierSMulRight L f v) w := by have ha : HasFDerivAt (fun w' : W ↦ L v w') (L v) w := ContinuousLinearMap.hasFDerivAt (L v) - convert ((hasDerivAt_fourierChar (-L v w)).hasFDerivAt.comp w ha.neg).smul_const (f v) + convert! ((hasDerivAt_fourierChar (-L v w)).hasFDerivAt.comp w ha.neg).smul_const (f v) ext w' : 1 simp_rw [fourierSMulRight, ContinuousLinearMap.smul_apply, ContinuousLinearMap.smulRight_apply] rw [ContinuousLinearMap.comp_apply, ContinuousLinearMap.neg_apply, @@ -273,7 +274,7 @@ theorem fourierIntegral_fderiv [MeasurableSpace V] [BorelSpace V] [FiniteDimensi · simp only [A, neg_mul, neg_smul, neg_neg] · have : Integrable (fun x ↦ (-(2 * ↑π * I * ↑((L y) w)) • ((g x : ℂ) • f x))) μ := ((fourierIntegral_convergent_iff' _ _).2 hf).smul _ - convert this using 2 with x + convert! this using 2 with x simp only [A, neg_mul, neg_smul, smul_smul] · exact (fourierIntegral_convergent_iff' _ _).2 (hf'.apply_continuousLinearMap _) · exact (fourierIntegral_convergent_iff' _ _).2 hf @@ -798,7 +799,7 @@ lemma hasDerivAt_fourier rw [ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.flip_apply, ContinuousLinearMap.mul_apply', one_mul, map_smul] exact congr_arg (fun x ↦ v • x) (one_smul ℝ (f v)).symm - convert (VectorFourier.hasFDerivAt_fourierIntegral L hf hf'' w).hasDerivAt using 1 + convert! (VectorFourier.hasFDerivAt_fourierIntegral L hf hf'' w).hasDerivAt using 1 rw [fourierIntegral_continuousLinearMap_apply' h_int, VectorFourier.fourierIntegral, fourier_real_eq] simp [fourierSMulRight, L, ContinuousLinearMap.smul_apply, @@ -841,7 +842,7 @@ theorem iteratedDeriv_fourier {f : ℝ → E} {N : ℕ∞} {n : ℕ} iteratedDeriv n (𝓕 f) = 𝓕 (fun x : ℝ ↦ (-2 * π * I * x) ^ n • f x) := by ext x : 1 have A (n : ℕ) (hn : n ≤ N) : Integrable (fun v ↦ ‖v‖ ^ n * ‖f v‖) := by - convert (hf n hn).norm with x + convert! (hf n hn).norm with x simp [norm_smul] have B : AEStronglyMeasurable f := by simpa using (hf 0 zero_le).1 rw [iteratedDeriv, iteratedFDeriv_fourier A B hn, diff --git a/Mathlib/Analysis/Fourier/Inversion.lean b/Mathlib/Analysis/Fourier/Inversion.lean index 18c273dcb241d1..1277a33325b9df 100644 --- a/Mathlib/Analysis/Fourier/Inversion.lean +++ b/Mathlib/Analysis/Fourier/Inversion.lean @@ -83,7 +83,7 @@ lemma tendsto_integral_gaussian_smul (hf : Integrable f) (h'f : Integrable (𝓕 have B : Continuous fun p : V × V => (- innerₗ V) p.1 p.2 := continuous_inner.neg simpa using (VectorFourier.fourierIntegral_convergent_iff Real.continuous_fourierChar B v).2 h'f - convert tendsto_integral_cexp_sq_smul this using 4 with c w + convert! tendsto_integral_cexp_sq_smul this using 4 with c w · rw [Submonoid.smul_def, Real.fourierChar_apply, smul_smul, ← Complex.exp_add, real_inner_comm] congr 3 simp only [ofReal_mul, ofReal_ofNat] @@ -127,7 +127,7 @@ lemma tendsto_integral_gaussian_smul' (hf : Integrable f) {v : V} (h'f : Continu have B := tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero (finrank ℝ V / 2) 1 zero_lt_one |>.comp A |>.const_mul (π ^ (-finrank ℝ V / 2 : ℝ)) rw [mul_zero] at B - convert B using 2 with x + convert! B using 2 with x simp only [neg_mul, one_mul, Function.comp_apply, ← mul_assoc, ← rpow_natCast, φ] congr 1 rw [mul_rpow (by positivity) (by positivity), ← rpow_mul pi_nonneg, diff --git a/Mathlib/Analysis/Fourier/LpSpace.lean b/Mathlib/Analysis/Fourier/LpSpace.lean index 7efc4420fe5ef5..702a38dd177a69 100644 --- a/Mathlib/Analysis/Fourier/LpSpace.lean +++ b/Mathlib/Analysis/Fourier/LpSpace.lean @@ -113,7 +113,7 @@ theorem SchwartzMap.toLp_fourierInv_eq (f : 𝓢(E, F)) : 𝓕⁻ (f.toLp 2) = ( use 1 intro f rw [one_mul] - convert (norm_fourier_toL2_eq (𝓕⁻ f)).symm.le + convert! (norm_fourier_toL2_eq (𝓕⁻ f)).symm.le simp @[deprecated (since := "2025-12-31")] diff --git a/Mathlib/Analysis/Fourier/Notation.lean b/Mathlib/Analysis/Fourier/Notation.lean index ac54e1412c21b5..fa130a45039688 100644 --- a/Mathlib/Analysis/Fourier/Notation.lean +++ b/Mathlib/Analysis/Fourier/Notation.lean @@ -264,8 +264,6 @@ variable (R E) in /-- The Fourier transform as a continuous linear equivalence. -/ def fourierCLE : E ≃L[R] F where __ := fourierEquiv R E - continuous_toFun := continuous_fourier - continuous_invFun := continuous_fourierInv @[simp] lemma fourierCLE_apply (f : E) : fourierCLE R E f = 𝓕 f := rfl diff --git a/Mathlib/Analysis/Fourier/PoissonSummation.lean b/Mathlib/Analysis/Fourier/PoissonSummation.lean index 4d507a1386050a..cc7e59172f12b9 100644 --- a/Mathlib/Analysis/Fourier/PoissonSummation.lean +++ b/Mathlib/Analysis/Fourier/PoissonSummation.lean @@ -76,7 +76,7 @@ theorem Real.fourierCoeff_tsum_comp_add {f : C(ℝ, ℂ)} -- Swap sum and integral. _ = ∑' n : ℤ, ∫ x in (0 : ℝ)..1, (e * f.comp (ContinuousMap.addRight n)) x := by refine (intervalIntegral.tsum_intervalIntegral_eq_of_summable_norm ?_).symm - convert hf ⟨uIcc 0 1, isCompact_uIcc⟩ using 1 + convert! hf ⟨uIcc 0 1, isCompact_uIcc⟩ using 1 exact funext fun n => neK _ _ _ = ∑' n : ℤ, ∫ x in (0 : ℝ)..1, (e * f).comp (ContinuousMap.addRight n) x := by simp only [mul_comp] at eadd ⊢ @@ -85,7 +85,7 @@ theorem Real.fourierCoeff_tsum_comp_add {f : C(ℝ, ℂ)} _ = ∫ x, e x * f x := by suffices Integrable (e * f) from this.hasSum_intervalIntegral_comp_add_int.tsum_eq apply integrable_of_summable_norm_Icc - convert hf ⟨Icc 0 1, isCompact_Icc⟩ using 1 + convert! hf ⟨Icc 0 1, isCompact_Icc⟩ using 1 simp_rw [mul_comp] at eadd ⊢ simp_rw [eadd] exact funext fun n => neK ⟨Icc 0 1, isCompact_Icc⟩ _ @@ -107,9 +107,9 @@ theorem Real.tsum_eq_tsum_fourier {f : C(ℝ, ℂ)} let F : C(UnitAddCircle, ℂ) := ⟨(f.periodic_tsum_comp_add_zsmul 1).lift, continuous_coinduced_dom.mpr (map_continuous _)⟩ have : Summable (fourierCoeff F) := by - convert h_sum + convert! h_sum exact Real.fourierCoeff_tsum_comp_add h_norm _ - convert (has_pointwise_sum_fourier_series_of_summable this x).tsum_eq.symm using 1 + convert! (has_pointwise_sum_fourier_series_of_summable this x).tsum_eq.symm using 1 · simpa only [F, coe_mk, ← QuotientAddGroup.mk_zero, Periodic.lift_coe, zsmul_one, comp_apply, coe_addRight, zero_add] using (hasSum_apply (summable_of_locally_summable_norm h_norm).hasSum x).tsum_eq @@ -148,7 +148,7 @@ theorem isBigO_norm_Icc_restrict_atTop {f : C(ℝ, E)} {b : ℝ} (hb : 0 < b) refine fun y => (hd y.1 (by linarith [hx.1, y.2.1])).trans ?_ have A : ∀ x : ℝ, 0 ≤ |x| ^ (-b) := fun x => by positivity rw [mul_assoc, mul_le_mul_iff_right₀ hc, norm_of_nonneg (A _), norm_of_nonneg (A _)] - convert claim x (by linarith only [hx.1]) y.1 y.2.1 + convert! claim x (by linarith only [hx.1]) y.1 y.2.1 · apply abs_of_nonneg; linarith [y.2.1] · exact abs_of_pos hx'.1 @@ -156,7 +156,7 @@ theorem isBigO_norm_Icc_restrict_atBot {f : C(ℝ, E)} {b : ℝ} (hb : 0 < b) (hf : f =O[atBot] fun x : ℝ => |x| ^ (-b)) (R S : ℝ) : (fun x : ℝ => ‖f.restrict (Icc (x + R) (x + S))‖) =O[atBot] fun x : ℝ => |x| ^ (-b) := by have h1 : (f.comp (ContinuousMap.mk _ continuous_neg)) =O[atTop] fun x : ℝ => |x| ^ (-b) := by - convert hf.comp_tendsto tendsto_neg_atTop_atBot using 1 + convert! hf.comp_tendsto tendsto_neg_atTop_atBot using 1 ext1 x; simp only [Function.comp_apply, abs_neg] have h2 := (isBigO_norm_Icc_restrict_atTop hb h1 (-S) (-R)).comp_tendsto tendsto_neg_atBot_atTop have : (fun x : ℝ => |x| ^ (-b)) ∘ Neg.neg = fun x : ℝ => |x| ^ (-b) := by diff --git a/Mathlib/Analysis/Fourier/RiemannLebesgueLemma.lean b/Mathlib/Analysis/Fourier/RiemannLebesgueLemma.lean index 668dda39a82e3a..d45231572cf6f0 100644 --- a/Mathlib/Analysis/Fourier/RiemannLebesgueLemma.lean +++ b/Mathlib/Analysis/Fourier/RiemannLebesgueLemma.lean @@ -180,7 +180,7 @@ variable (f) theorem tendsto_integral_exp_inner_smul_cocompact : Tendsto (fun w : V => ∫ v, 𝐞 (-⟪v, w⟫) • f v) (cocompact V) (𝓝 0) := by by_cases hfi : Integrable f; swap - · convert tendsto_const_nhds (x := (0 : E)) with w + · convert! tendsto_const_nhds (x := (0 : E)) with w apply integral_undef rwa [Real.fourierIntegral_convergent_iff] refine Metric.tendsto_nhds.mpr fun ε hε => ?_ @@ -261,8 +261,10 @@ theorem tendsto_integral_exp_smul_cocompact (μ : Measure V) [μ.IsAddHaarMeasur -- isomorphism between duals derived from A let Adual : StrongDual ℝ V ≃L[ℝ] StrongDual ℝ V' := A.arrowCongrSL (.refl _ _) have : (μ.map Aₘ).IsAddHaarMeasure := A.isAddHaarMeasure_map _ - convert (tendsto_integral_exp_smul_cocompact_of_inner_product (f ∘ A.symm) (μ.map Aₘ)).comp - Adual.toHomeomorph.toCocompactMap.cocompact_tendsto' with w + convert! + (tendsto_integral_exp_smul_cocompact_of_inner_product (f ∘ A.symm) (μ.map Aₘ)).comp + Adual.toHomeomorph.toCocompactMap.cocompact_tendsto' with + w suffices ∫ v, 𝐞 (-w v) • f v ∂μ = ∫ (x : V), 𝐞 (-w (A.symm (Aₘ x))) • f (A.symm (Aₘ x)) ∂μ by simpa [Function.comp_apply, integral_map_equiv, Adual] simp [Aₘ] diff --git a/Mathlib/Analysis/FunctionalSpaces/SobolevInequality.lean b/Mathlib/Analysis/FunctionalSpaces/SobolevInequality.lean index 7c6669e0607510..1793353fe9f39b 100644 --- a/Mathlib/Analysis/FunctionalSpaces/SobolevInequality.lean +++ b/Mathlib/Analysis/FunctionalSpaces/SobolevInequality.lean @@ -225,7 +225,7 @@ theorem T_lmarginal_antitone [Fintype ι] [∀ i, SigmaFinite (μ i)] rw [Finset.antitone_iff_forall_insert_le] intro s i hi -- apply the lemma designed to encapsulate the inductive step - convert T_insert_le_T_lmarginal_singleton μ hp₀ s ?_ i hi (hf.lmarginal μ) using 2 + convert! T_insert_le_T_lmarginal_singleton μ hp₀ s ?_ i hi (hf.lmarginal μ) using 2 · rw [← lmarginal_union μ f hf] · rw [← insert_compl_insert hi] rfl @@ -285,7 +285,7 @@ theorem lintegral_prod_lintegral_pow_le [Fintype ι] [∀ i, SigmaFinite (μ i)] have h3 : (#ι - 1 : ℝ) * ((1 : ℝ) / (#ι - 1 : ℝ)) ≤ 1 := by field_simp; rfl have h4 : p = 1 + 1 / (↑#ι - 1) := by simp [field]; rw [mul_comm, hp.sub_one_mul_conj] rw [h4] - convert lintegral_mul_prod_lintegral_pow_le μ h2 h3 hf using 2 + convert! lintegral_mul_prod_lintegral_pow_le μ h2 h3 hf using 2 field_simp simp @@ -338,7 +338,7 @@ theorem lintegral_pow_le_pow_lintegral_fderiv_aux [Fintype ι] calc ‖u x‖ₑ _ ≤ ∫⁻ xᵢ in Iic (x i), ‖deriv (u ∘ update x i) xᵢ‖ₑ := by apply le_trans (by simp) (HasCompactSupport.enorm_le_lintegral_Ici_deriv _ _ _) - · exact hu.comp (by convert contDiff_update 1 x i) + · exact hu.comp (by convert! contDiff_update 1 x i) · exact h2u.comp_isClosedEmbedding (isClosedEmbedding_update x i) _ ≤ ∫⁻ xᵢ, ‖fderiv ℝ u (update x i xᵢ)‖ₑ := ?_ gcongr with y @@ -493,7 +493,7 @@ theorem eLpNorm_le_eLpNorm_fderiv_of_eq_inner {u : E → F'} have hnp : (0 : ℝ) < n - p := by simp_rw [sub_pos]; exact h2p rcases hp.eq_or_lt with rfl | hp -- the case `p = 1` - · convert eLpNorm_le_eLpNorm_fderiv_one μ hu h2u hn using 2 + · convert! eLpNorm_le_eLpNorm_fderiv_one μ hu h2u hn using 2 · suffices (p' : ℝ) = n' by simpa using this rw [← inv_inj, hp'] simp [field, n', NNReal.conjExponent, *] @@ -556,8 +556,9 @@ theorem eLpNorm_le_eLpNorm_fderiv_of_eq_inner {u : E → F'} _ ≤ C * γ * ((∫⁻ x, ‖u x‖ₑ ^ (p' : ℝ) ∂μ) ^ (1 / q) * (∫⁻ x, ‖fderiv ℝ u x‖ₑ ^ (p : ℝ) ∂μ) ^ (1 / (p : ℝ))) := by gcongr - convert ENNReal.lintegral_mul_le_Lp_mul_Lq μ - (.symm <| .conjExponent <| show 1 < (p : ℝ) from hp) ?_ ?_ using 5 + convert! + ENNReal.lintegral_mul_le_Lp_mul_Lq μ (.symm <| .conjExponent <| show 1 < (p : ℝ) from hp) + ?_ ?_ using 5 · simp [γ, n, q, ← ENNReal.rpow_mul, ← h3γ] · borelize F' fun_prop @@ -681,7 +682,7 @@ theorem eLpNorm_le_eLpNorm_fderiv_of_le [FiniteDimensional ℝ F] calc eLpNorm u q μ = eLpNorm u q (μ.restrict s) := by rw [eLpNorm_restrict_eq_of_support_subset h2u] _ ≤ eLpNorm u p' (μ.restrict s) * t := by - convert eLpNorm_le_eLpNorm_mul_rpow_measure_univ this hu.continuous.aestronglyMeasurable + convert! eLpNorm_le_eLpNorm_mul_rpow_measure_univ this hu.continuous.aestronglyMeasurable rw [ENNReal.coe_rpow_of_nonneg] · simp [ENNReal.coe_toNNReal hs.measure_lt_top.ne] · rw [one_div, one_div] diff --git a/Mathlib/Analysis/InnerProductSpace/Basic.lean b/Mathlib/Analysis/InnerProductSpace/Basic.lean index 0df3c135b15b5d..6db945fad96026 100644 --- a/Mathlib/Analysis/InnerProductSpace/Basic.lean +++ b/Mathlib/Analysis/InnerProductSpace/Basic.lean @@ -356,7 +356,7 @@ theorem linearIndependent_of_ne_zero_of_inner_eq_zero {ι : Type*} {v : ι → E have h' : g i * ⟪v i, v i⟫ = ⟪v i, ∑ j ∈ s, g j • v j⟫ := by rw [inner_sum] symm - convert Finset.sum_eq_single (M := 𝕜) i ?_ ?_ + convert! Finset.sum_eq_single (M := 𝕜) i ?_ ?_ · rw [inner_smul_right] · intro j _hj hji rw [inner_smul_right, ho hji.symm, mul_zero] @@ -817,7 +817,7 @@ theorem real_inner_div_norm_mul_norm_eq_neg_one_iff (x y : F) : the equality case for Cauchy-Schwarz. -/ theorem inner_eq_one_iff_of_norm_eq_one {x y : E} (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) : ⟪x, y⟫ = 1 ↔ x = y := by - convert inner_eq_norm_mul_iff (𝕜 := 𝕜) (E := E) using 2 <;> simp [hx, hy] + convert! inner_eq_norm_mul_iff (𝕜 := 𝕜) (E := E) using 2 <;> simp [hx, hy] /-- If the inner product of two unit vectors is `-1`, then the two vectors are negations of each other. -/ @@ -852,7 +852,7 @@ theorem inner_lt_norm_mul_iff_real {x y : F} : ⟪x, y⟫_ℝ < ‖x‖ * ‖y /-- If the inner product of two unit vectors is strictly less than `1`, then the two vectors are distinct. One form of the equality case for Cauchy-Schwarz. -/ theorem inner_lt_one_iff_real_of_norm_eq_one {x y : F} (hx : ‖x‖ = 1) (hy : ‖y‖ = 1) : - ⟪x, y⟫_ℝ < 1 ↔ x ≠ y := by convert inner_lt_norm_mul_iff_real (F := F) <;> simp [hx, hy] + ⟪x, y⟫_ℝ < 1 ↔ x ≠ y := by convert! inner_lt_norm_mul_iff_real (F := F) <;> simp [hx, hy] /-- The sphere of radius `r = ‖y‖` is tangent to the plane `⟪x, y⟫ = ‖y‖ ^ 2` at `x = y`. -/ theorem eq_of_norm_le_re_inner_eq_norm_sq {x y : E} (hle : ‖x‖ ≤ ‖y‖) (h : re ⟪x, y⟫ = ‖y‖ ^ 2) : @@ -1000,6 +1000,8 @@ example : (instInnerProductSpaceRealComplex : InnerProductSpace ℝ ℂ) = RCLike.toInnerProductSpaceReal := rfl +theorem Real.inner_apply (x y : ℝ) : inner ℝ x y = x * y := by rw [mul_comm]; rfl + section IsPosSemidef variable [NormedAddCommGroup E] [InnerProductSpace ℝ E] diff --git a/Mathlib/Analysis/InnerProductSpace/Calculus.lean b/Mathlib/Analysis/InnerProductSpace/Calculus.lean index efec86444df931..85393a4cd9d432 100644 --- a/Mathlib/Analysis/InnerProductSpace/Calculus.lean +++ b/Mathlib/Analysis/InnerProductSpace/Calculus.lean @@ -138,7 +138,7 @@ section include 𝕜 theorem contDiff_norm_sq : ContDiff ℝ n fun x : E => ‖x‖ ^ 2 := by - convert (reCLM : 𝕜 →L[ℝ] ℝ).contDiff.comp ((contDiff_id (E := E)).inner 𝕜 (contDiff_id (E := E))) + convert! (reCLM : 𝕜 →L[ℝ] ℝ).contDiff.comp ((contDiff_id (E := E)).inner 𝕜 (contDiff_id (E := E))) exact (inner_self_eq_norm_sq _).symm theorem ContDiff.norm_sq (hf : ContDiff ℝ n f) : ContDiff ℝ n fun x => ‖f x‖ ^ 2 := @@ -197,7 +197,7 @@ open scoped RealInnerProductSpace theorem hasStrictFDerivAt_norm_sq (x : F) : HasStrictFDerivAt (fun x => ‖x‖ ^ 2) (2 • (innerSL ℝ x)) x := by simp only [sq, ← @inner_self_eq_norm_mul_norm ℝ] - convert (hasStrictFDerivAt_id x).inner ℝ (hasStrictFDerivAt_id x) + convert! (hasStrictFDerivAt_id x).inner ℝ (hasStrictFDerivAt_id x) ext y simp [two_smul, real_inner_comm] diff --git a/Mathlib/Analysis/InnerProductSpace/Defs.lean b/Mathlib/Analysis/InnerProductSpace/Defs.lean index 7048d51799729e..cc34ea1e8dda94 100644 --- a/Mathlib/Analysis/InnerProductSpace/Defs.lean +++ b/Mathlib/Analysis/InnerProductSpace/Defs.lean @@ -359,7 +359,7 @@ theorem inner_mul_inner_self_le (x y : F) : ‖⟪x, y⟫‖ * ‖⟪y, x⟫‖ obtain ⟨hx, hy⟩ : (0 ≤ normSqF x ∧ 0 ≤ normSqF y) := ⟨inner_self_nonneg, inner_self_nonneg⟩ positivity · have hzero' : ‖⟪x, y⟫‖ ≠ 0 := norm_ne_zero_iff.2 hzero - convert cauchy_schwarz_aux' (𝕜 := 𝕜) (⟪x, y⟫ • x) y (t / ‖⟪x, y⟫‖) using 3 + convert! cauchy_schwarz_aux' (𝕜 := 𝕜) (⟪x, y⟫ • x) y (t / ‖⟪x, y⟫‖) using 3 · field_simp rw [normSq, normSq, inner_smul_right, inner_smul_left, ← mul_assoc _ _ ⟪x, x⟫, mul_conj] diff --git a/Mathlib/Analysis/InnerProductSpace/Dual.lean b/Mathlib/Analysis/InnerProductSpace/Dual.lean index 193f1befcc71cb..1b5d9ae1b582e4 100644 --- a/Mathlib/Analysis/InnerProductSpace/Dual.lean +++ b/Mathlib/Analysis/InnerProductSpace/Dual.lean @@ -221,7 +221,7 @@ instance [NormedAddCommGroup E] [CompleteSpace E] [InnerProductSpace ℝ E] : continuous_uncurry := continuous_inner bijective_left := (toDual ℝ E).bijective bijective_right := by - convert (toDual ℝ E).bijective + convert! (toDual ℝ E).bijective ext y simp diff --git a/Mathlib/Analysis/InnerProductSpace/GramSchmidtOrtho.lean b/Mathlib/Analysis/InnerProductSpace/GramSchmidtOrtho.lean index 9c7c828dbc2281..321c82d092f333 100644 --- a/Mathlib/Analysis/InnerProductSpace/GramSchmidtOrtho.lean +++ b/Mathlib/Analysis/InnerProductSpace/GramSchmidtOrtho.lean @@ -117,7 +117,7 @@ theorem gramSchmidt_inv_triangular (v : ι → E) {i j : ι} (hij : i < j) : rw [gramSchmidt_def'' 𝕜 v] simp only [inner_add_right, inner_sum, inner_smul_right] set b : ι → E := gramSchmidt 𝕜 v - convert zero_add (0 : 𝕜) + convert! zero_add (0 : 𝕜) · exact gramSchmidt_orthogonal 𝕜 v hij.ne' apply Finset.sum_eq_zero rintro k hki' @@ -371,7 +371,7 @@ theorem gramSchmidtOrthonormalBasis_inv_blockTriangular : theorem gramSchmidtOrthonormalBasis_det [DecidableEq ι] : (gramSchmidtOrthonormalBasis h f).toBasis.det f = ∏ i, ⟪gramSchmidtOrthonormalBasis h f i, f i⟫ := by - convert Matrix.det_of_upperTriangular (gramSchmidtOrthonormalBasis_inv_blockTriangular h f) + convert! Matrix.det_of_upperTriangular (gramSchmidtOrthonormalBasis_inv_blockTriangular h f) exact ((gramSchmidtOrthonormalBasis h f).repr_apply_apply (f _) _).symm end OrthonormalBasis diff --git a/Mathlib/Analysis/InnerProductSpace/JointEigenspace.lean b/Mathlib/Analysis/InnerProductSpace/JointEigenspace.lean index 506a725531613a..a2b446dbaae0ef 100644 --- a/Mathlib/Analysis/InnerProductSpace/JointEigenspace.lean +++ b/Mathlib/Analysis/InnerProductSpace/JointEigenspace.lean @@ -133,13 +133,17 @@ theorem iSup_iInf_eq_top_of_commute {ι : Type*} {T : ι → E →ₗ[𝕜] E} /-- In finite dimensions, given a commuting family of symmetric linear operators, the inner product space on which they act decomposes as an internal direct sum of joint eigenspaces. -/ -theorem LinearMap.IsSymmetric.directSum_isInternal_of_pairwise_commute [DecidableEq (n → 𝕜)] +theorem directSum_isInternal_of_pairwise_commute [DecidableEq (n → 𝕜)] (hT : ∀ i, (T i).IsSymmetric) (hC : Pairwise (Commute on T)) : DirectSum.IsInternal (fun α : n → 𝕜 ↦ ⨅ j, eigenspace (T j) (α j)) := by rw [OrthogonalFamily.isInternal_iff] · rw [iSup_iInf_eq_top_of_commute hT hC, top_orthogonal_eq_bot] · exact orthogonalFamily_iInf_eigenspaces hT +@[deprecated (since := "2026-05-24")] +alias LinearMap.IsSymmetric.directSum_isInternal_of_pairwise_commute := + directSum_isInternal_of_pairwise_commute + end RCLike end IsSymmetric diff --git a/Mathlib/Analysis/InnerProductSpace/LinearPMap.lean b/Mathlib/Analysis/InnerProductSpace/LinearPMap.lean index b0e8ab31277576..9cf3e7608ebd4c 100644 --- a/Mathlib/Analysis/InnerProductSpace/LinearPMap.lean +++ b/Mathlib/Analysis/InnerProductSpace/LinearPMap.lean @@ -166,7 +166,7 @@ theorem mem_adjoint_domain_of_exists (y : F) (h : ∃ w : E, ∀ x : T.domain, obtain ⟨w, hw⟩ := h rw [T.mem_adjoint_domain_iff] have : Continuous ((innerSL 𝕜 w).comp T.domain.subtypeL) := by fun_prop - convert this using 1 + convert! this using 1 exact funext fun x => (hw x).symm theorem adjoint_apply_of_not_dense (hT : ¬Dense (T.domain : Set E)) (y : T†.domain) : T† y = 0 := by diff --git a/Mathlib/Analysis/InnerProductSpace/NormPow.lean b/Mathlib/Analysis/InnerProductSpace/NormPow.lean index 7151281c244162..31e04699fc7e43 100644 --- a/Mathlib/Analysis/InnerProductSpace/NormPow.lean +++ b/Mathlib/Analysis/InnerProductSpace/NormPow.lean @@ -43,12 +43,12 @@ theorem hasFDerivAt_norm_rpow (x : E) {p : ℝ} (hp : 1 < p) : ring_nf _ =o[𝓝 0] (fun x : E ↦ ‖x‖ * 1) := by refine (isBigO_refl _ _).mul_isLittleO <| (isLittleO_const_iff <| by simp).mpr ?_ - convert continuousAt_id.norm.rpow_const (.inr h2p.le) |>.tendsto + convert! continuousAt_id.norm.rpow_const (.inr h2p.le) |>.tendsto simp [h2p.ne'] _ =O[𝓝 0] (fun (x : E) ↦ x - 0) := by simp_rw [mul_one, isBigO_norm_left (f' := fun x ↦ x), sub_zero, isBigO_refl] · apply HasStrictFDerivAt.hasFDerivAt - convert (hasStrictFDerivAt_norm_sq x).rpow_const (p := p / 2) (by simp [hx]) using 0 + convert! (hasStrictFDerivAt_norm_sq x).rpow_const (p := p / 2) (by simp [hx]) using 0 simp_rw [← Real.rpow_natCast_mul (norm_nonneg _), ← Nat.cast_smul_eq_nsmul ℝ, smul_smul] ring_nf @@ -58,7 +58,7 @@ theorem differentiable_norm_rpow {p : ℝ} (hp : 1 < p) : theorem hasDerivAt_norm_rpow (x : ℝ) {p : ℝ} (hp : 1 < p) : HasDerivAt (fun x : ℝ ↦ ‖x‖ ^ p) (p * ‖x‖ ^ (p - 2) * x) x := by - convert hasFDerivAt_norm_rpow x hp |>.hasDerivAt using 1; simp + convert! hasFDerivAt_norm_rpow x hp |>.hasDerivAt using 1; simp theorem hasDerivAt_abs_rpow (x : ℝ) {p : ℝ} (hp : 1 < p) : HasDerivAt (fun x : ℝ ↦ |x| ^ p) (p * |x| ^ (p - 2) * x) x := by diff --git a/Mathlib/Analysis/InnerProductSpace/OfNorm.lean b/Mathlib/Analysis/InnerProductSpace/OfNorm.lean index 1ac2adecaa0ea3..49ffd3cc9cd697 100644 --- a/Mathlib/Analysis/InnerProductSpace/OfNorm.lean +++ b/Mathlib/Analysis/InnerProductSpace/OfNorm.lean @@ -118,7 +118,7 @@ theorem inner_.norm_sq (x : E) : ‖x‖ ^ 2 = re (inner_ 𝕜 x x) := by simp only [inner_, normSq_apply, ofNat_re, ofNat_im, map_sub, map_add, ofReal_re, ofReal_im, mul_re, inv_re, mul_im, I_re, inv_im] have h₁ : ‖x - x‖ = 0 := by simp - have h₂ : ‖x + x‖ = 2 • ‖x‖ := by convert norm_nsmul 𝕜 2 x using 2; module + have h₂ : ‖x + x‖ = 2 • ‖x‖ := by convert! norm_nsmul 𝕜 2 x using 2; module rw [h₁, h₂] ring @@ -132,10 +132,10 @@ theorem inner_.conj_symm (x y : E) : conj (inner_ 𝕜 y x) = inner_ 𝕜 x y := have hI' := I_mul_I_of_nonzero hI have I_smul (v : E) : ‖(I : 𝕜) • v‖ = ‖v‖ := by rw [norm_smul, norm_I_of_ne_zero hI, one_mul] have h₁ : ‖(I : 𝕜) • y - x‖ = ‖(I : 𝕜) • x + y‖ := by - convert I_smul ((I : 𝕜) • x + y) using 2 + convert! I_smul ((I : 𝕜) • x + y) using 2 linear_combination (norm := module) -hI' • x have h₂ : ‖(I : 𝕜) • y + x‖ = ‖(I : 𝕜) • x - y‖ := by - convert (I_smul ((I : 𝕜) • y + x)).symm using 2 + convert! (I_smul ((I : 𝕜) • y + x)).symm using 2 linear_combination (norm := module) -hI' • y rw [h₁, h₂] ring diff --git a/Mathlib/Analysis/InnerProductSpace/Orientation.lean b/Mathlib/Analysis/InnerProductSpace/Orientation.lean index 48a770f98db49f..8837c31940f679 100644 --- a/Mathlib/Analysis/InnerProductSpace/Orientation.lean +++ b/Mathlib/Analysis/InnerProductSpace/Orientation.lean @@ -215,7 +215,7 @@ theorem volumeForm_robust_neg (b : OrthonormalBasis (Fin n) ℝ E) (hb : b.toBas let e : OrthonormalBasis (Fin n.succ) ℝ E := o.finOrthonormalBasis n.succ_pos Fact.out simp_rw [volumeForm] apply e.det_eq_neg_det_of_opposite_orientation b - convert hb.symm + convert! hb.symm exact o.finOrthonormalBasis_orientation _ _ @[simp] @@ -253,7 +253,7 @@ theorem abs_volumeForm_apply_le (v : Fin n → E) : |o.volumeForm v| ≤ ∏ i : · intro i _ positivity intro i _ - convert abs_real_inner_le_norm (b i) (v i) + convert! abs_real_inner_le_norm (b i) (v i) simp [b.orthonormal.1 i] theorem volumeForm_apply_le (v : Fin n → E) : o.volumeForm v ≤ ∏ i : Fin n, ‖v i‖ := @@ -311,7 +311,7 @@ theorem volumeForm_comp_linearIsometryEquiv (φ : E ≃ₗᵢ[ℝ] E) rcases n with - | n · refine o.eq_or_eq_neg_of_isEmpty.elim ?_ ?_ <;> rintro rfl <;> simp have : FiniteDimensional ℝ E := .of_fact_finrank_eq_succ n - convert o.volumeForm_map φ (φ ∘ x) + convert! o.volumeForm_map φ (φ ∘ x) · symm rwa [← o.map_eq_iff_det_pos φ.toLinearEquiv] at hφ rw [_i.out, Fintype.card_fin] diff --git a/Mathlib/Analysis/InnerProductSpace/Orthogonal.lean b/Mathlib/Analysis/InnerProductSpace/Orthogonal.lean index eb3dbd9461af9f..ff11ca04944a18 100644 --- a/Mathlib/Analysis/InnerProductSpace/Orthogonal.lean +++ b/Mathlib/Analysis/InnerProductSpace/Orthogonal.lean @@ -113,7 +113,7 @@ theorem orthogonal_eq_inter : Kᗮ = ⨅ v : K, (innerSL 𝕜 (v : E)).ker := by /-- The orthogonal complement of any submodule `K` is closed. -/ theorem isClosed_orthogonal : IsClosed (Kᗮ : Set E) := by rw [orthogonal_eq_inter K] - convert isClosed_iInter <| fun v : K => ContinuousLinearMap.isClosed_ker (innerSL 𝕜 (v : E)) + convert! isClosed_iInter <| fun v : K => ContinuousLinearMap.isClosed_ker (innerSL 𝕜 (v : E)) simp /-- In a complete space, the orthogonal complement of any submodule `K` is complete. -/ @@ -372,7 +372,7 @@ theorem IsOrtho.map_iff (f : E ≃ₗᵢ[𝕜] F) {U V : Submodule 𝕜 E} : @[simp] theorem IsOrtho.comap_iff (f : E ≃ₗᵢ[𝕜] F) {U V : Submodule 𝕜 F} : U.comap (f : E →ₗ[𝕜] F) ⟂ V.comap (f : E →ₗ[𝕜] F) ↔ U ⟂ V := by - convert IsOrtho.map_iff f.symm using 2 <;> + convert! IsOrtho.map_iff f.symm using 2 <;> exact Submodule.comap_equiv_eq_map_symm (f : E ≃ₗ[𝕜] F) _ end Submodule diff --git a/Mathlib/Analysis/InnerProductSpace/Orthonormal.lean b/Mathlib/Analysis/InnerProductSpace/Orthonormal.lean index aa2f444b27f6d6..d70a9099f6a927 100644 --- a/Mathlib/Analysis/InnerProductSpace/Orthonormal.lean +++ b/Mathlib/Analysis/InnerProductSpace/Orthonormal.lean @@ -193,7 +193,7 @@ theorem Orthonormal.comp {ι' : Type*} {v : ι → E} (hv : Orthonormal 𝕜 v) classical rw [orthonormal_iff_ite] at hv ⊢ intro i j - convert hv (f i) (f j) using 1 + convert! hv (f i) (f j) using 1 simp [hf.eq_iff] /-- An injective family `v : ι → E` is orthonormal if and only if `Subtype.val : (range v) → E` is diff --git a/Mathlib/Analysis/InnerProductSpace/PiL2.lean b/Mathlib/Analysis/InnerProductSpace/PiL2.lean index 78f09a00c16529..39460e363ca116 100644 --- a/Mathlib/Analysis/InnerProductSpace/PiL2.lean +++ b/Mathlib/Analysis/InnerProductSpace/PiL2.lean @@ -198,7 +198,7 @@ variable [Fintype ι] @[simp] theorem finrank_euclideanSpace : Module.finrank 𝕜 (EuclideanSpace 𝕜 ι) = Fintype.card ι := by - convert (WithLp.linearEquiv 2 𝕜 (ι → 𝕜)).finrank_eq + convert! (WithLp.linearEquiv 2 𝕜 (ι → 𝕜)).finrank_eq simp theorem finrank_euclideanSpace_fin {n : ℕ} : @@ -248,7 +248,7 @@ def DirectSum.IsInternal.isometryL2OfOrthogonalFamily [DecidableEq ι] {V : ι suffices ∀ (v w : PiLp 2 fun i => V i), ⟪v, w⟫ = ⟪e₂ (e₁.symm v), e₂ (e₁.symm w)⟫ by intro v₀ w₀ simp only [LinearEquiv.trans_apply] - convert this (toLp 2 (e₁ (e₂.symm v₀))) (toLp 2 (e₁ (e₂.symm w₀))) <;> simp + convert! this (toLp 2 (e₁ (e₂.symm v₀))) (toLp 2 (e₁ (e₂.symm w₀))) <;> simp intro v w trans ⟪∑ i, (V i).subtypeₗᵢ (v i), ∑ i, (V i).subtypeₗᵢ (w i)⟫ · simp only [sum_inner, hV'.inner_right_fintype, PiLp.inner_apply] @@ -505,7 +505,7 @@ protected theorem sum_inner_mul_inner (b : OrthonormalBasis ι 𝕜 E) (x y : E) ∑ i, ⟪x, b i⟫ * ⟪b i, y⟫ = ⟪x, y⟫ := by have := congr_arg (innerSL 𝕜 x) (b.sum_repr y) rw [map_sum] at this - convert this + convert! this rw [map_smul, b.repr_apply_apply, mul_comm] simp @@ -519,7 +519,7 @@ lemma sum_sq_norm_inner_right (b : OrthonormalBasis ι 𝕜 E) (x : E) : lemma sum_sq_norm_inner_left (b : OrthonormalBasis ι 𝕜 E) (x : E) : ∑ i, ‖⟪x, b i⟫‖ ^ 2 = ‖x‖ ^ 2 := by - convert sum_sq_norm_inner_right b x using 2 with i - + convert! sum_sq_norm_inner_right b x using 2 with i - rw [← inner_conj_symm, RCLike.norm_conj] open scoped RealInnerProductSpace in @@ -599,7 +599,7 @@ def _root_.Module.Basis.toOrthonormalBasis (v : Basis ι 𝕜 E) (hv : Orthonorm let q : EuclideanSpace 𝕜 ι := toLp 2 (v.equivFun y) have key : ⟪p, q⟫ = ⟪∑ i, p i • v i, ∑ i, q i • v i⟫ := by simp [inner_sum, inner_smul_right, hv.inner_left_fintype, PiLp.inner_apply] - convert key + convert! key · rw [← v.equivFun.symm_apply_apply x, v.equivFun_symm_apply] · rw [← v.equivFun.symm_apply_apply y, v.equivFun_symm_apply]) @@ -718,7 +718,7 @@ protected def span [DecidableEq E] {v' : ι' → E} (h : Orthonormal 𝕜 v') (s let e₀ : OrthonormalBasis s 𝕜 _ := OrthonormalBasis.mk (by - convert orthonormal_span (h.comp ((↑) : s → ι') Subtype.val_injective) + convert! orthonormal_span (h.comp ((↑) : s → ι') Subtype.val_injective) simp [e₀', Basis.span_apply]) e₀'.span_eq.ge let φ : span 𝕜 (s.image v' : Set E) ≃ₗᵢ[𝕜] span 𝕜 (range (v' ∘ ((↑) : s → ι'))) := @@ -931,7 +931,7 @@ theorem OrthonormalBasis.toMatrix_orthonormalBasis_conjTranspose_mul_self [Finty (a : OrthonormalBasis ι' 𝕜 E) (b : OrthonormalBasis ι 𝕜 E) : (a.toBasis.toMatrix b)ᴴ * a.toBasis.toMatrix b = 1 := by ext i j - convert a.repr.inner_map_map (b i) (b j) + convert! a.repr.inner_map_map (b i) (b j) · simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, star_def, PiLp.inner_apply, inner_apply'] congr diff --git a/Mathlib/Analysis/InnerProductSpace/Positive.lean b/Mathlib/Analysis/InnerProductSpace/Positive.lean index 38b2fcbbe3fda1..f09b2d61f4f04e 100644 --- a/Mathlib/Analysis/InnerProductSpace/Positive.lean +++ b/Mathlib/Analysis/InnerProductSpace/Positive.lean @@ -214,7 +214,7 @@ theorem isPositive_linearIsometryEquiv_conj_iff {T : E →ₗ[𝕜] E} (f : E {A : E →ₗ[𝕜] E} (b : OrthonormalBasis ι 𝕜 E) : (A.toMatrix b.toBasis b.toBasis).PosSemidef ↔ A.IsPositive := by rw [← Matrix.isPositive_toEuclideanLin_iff] - convert isPositive_linearIsometryEquiv_conj_iff b.repr + convert! isPositive_linearIsometryEquiv_conj_iff b.repr ext simp [LinearMap.toMatrix] @@ -365,7 +365,7 @@ theorem isPositive_self_comp_adjoint [CompleteSpace E] [CompleteSpace F] (S : E @[aesop safe apply] theorem IsPositive.adjoint_conj [CompleteSpace E] [CompleteSpace F] {T : E →L[𝕜] E} (hT : T.IsPositive) (S : F →L[𝕜] E) : (S† ∘L T ∘L S).IsPositive := by - convert hT.conj_adjoint (S†) + convert! hT.conj_adjoint (S†) rw [adjoint_adjoint] theorem isPositive_adjoint_comp_self [CompleteSpace E] [CompleteSpace F] (S : E →L[𝕜] F) : @@ -390,7 +390,7 @@ theorem _root_.LinearMap.isPositive_self_comp_adjoint (S : E →ₗ[𝕜] F) : @[aesop safe apply] theorem _root_.LinearMap.IsPositive.adjoint_conj {T : E →ₗ[𝕜] E} (hT : T.IsPositive) (S : F →ₗ[𝕜] E) : (S.adjoint ∘ₗ T ∘ₗ S).IsPositive := by - convert hT.conj_adjoint S.adjoint + convert! hT.conj_adjoint S.adjoint rw [LinearMap.adjoint_adjoint] theorem _root_.LinearMap.isPositive_adjoint_comp_self (S : E →ₗ[𝕜] F) : diff --git a/Mathlib/Analysis/InnerProductSpace/Projection/Basic.lean b/Mathlib/Analysis/InnerProductSpace/Projection/Basic.lean index 3cae48ca82f6c4..676ab7984e189e 100644 --- a/Mathlib/Analysis/InnerProductSpace/Projection/Basic.lean +++ b/Mathlib/Analysis/InnerProductSpace/Projection/Basic.lean @@ -137,7 +137,7 @@ theorem orthogonalProjectionFn_norm_sq (v : E) : set p := K.orthogonalProjectionFn v have h' : ⟪v - p, p⟫ = 0 := orthogonalProjectionFn_inner_eq_zero _ _ (orthogonalProjectionFn_mem v) - convert norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero (v - p) p h' using 2 <;> simp + convert! norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero (v - p) p h' using 2 <;> simp /-- The orthogonal projection onto a complete subspace. -/ def orthogonalProjection : E →L[𝕜] K := @@ -411,7 +411,7 @@ theorem starProjection_singleton {v : E} (w : E) : (((‖v‖ ^ 2 : ℝ) : 𝕜)⁻¹ * ((‖v‖ ^ 2 : ℝ) : 𝕜)) • (𝕜 ∙ v).starProjection w = (((‖v‖ ^ 2 : ℝ) : 𝕜)⁻¹ * ⟪v, w⟫) • v := by simp [mul_smul, smul_starProjection_singleton 𝕜 w, -map_pow] - convert key using 1 <;> match_scalars <;> field_simp [hv'] + convert! key using 1 <;> match_scalars <;> field_simp [hv'] /-- Formula for orthogonal projection onto a single unit vector. -/ theorem starProjection_unit_singleton {v : E} (hv : ‖v‖ = 1) (w : E) : @@ -450,7 +450,7 @@ theorem IsOrtho.starProjection_comp_starProjection {U V : Submodule 𝕜 E} theorem orthogonalProjection_comp_subtypeL_eq_zero_iff {U V : Submodule 𝕜 E} [U.HasOrthogonalProjection] : U.orthogonalProjection ∘L V.subtypeL = 0 ↔ U ⟂ V := ⟨fun h u hu v hv => by - convert starProjection_inner_eq_zero v u hu using 2 + convert! starProjection_inner_eq_zero v u hu using 2 have : U.orthogonalProjection v = 0 := DFunLike.congr_fun h (⟨_, hv⟩ : V) rw [starProjection_apply, this, Submodule.coe_zero, sub_zero], Submodule.IsOrtho.orthogonalProjection_comp_subtypeL⟩ diff --git a/Mathlib/Analysis/InnerProductSpace/Projection/FiniteDimensional.lean b/Mathlib/Analysis/InnerProductSpace/Projection/FiniteDimensional.lean index 4859a3e25751cb..8808764b35d86b 100644 --- a/Mathlib/Analysis/InnerProductSpace/Projection/FiniteDimensional.lean +++ b/Mathlib/Analysis/InnerProductSpace/Projection/FiniteDimensional.lean @@ -111,7 +111,7 @@ theorem finrank_add_inf_finrank_orthogonal' {K₁ K₂ : Submodule 𝕜 E} that of `E`. -/ theorem finrank_add_finrank_orthogonal [FiniteDimensional 𝕜 E] (K : Submodule 𝕜 E) : finrank 𝕜 K + finrank 𝕜 Kᗮ = finrank 𝕜 E := by - convert Submodule.finrank_add_inf_finrank_orthogonal (le_top : K ≤ ⊤) using 1 + convert! Submodule.finrank_add_inf_finrank_orthogonal (le_top : K ≤ ⊤) using 1 · rw [inf_top_eq] · simp @@ -402,7 +402,7 @@ theorem maximal_orthonormal_iff_basis_of_finiteDimensional (hv : Orthonormal have hv_coe : range ((↑) : v → E) = v := by simp constructor · refine fun h => ⟨Basis.mk hv.linearIndependent _, Basis.coe_mk _ ?_⟩ - convert h.ge + convert! h.ge · rintro ⟨h, coe_h⟩ rw [← h.span_eq, coe_h, hv_coe] diff --git a/Mathlib/Analysis/InnerProductSpace/Projection/Minimal.lean b/Mathlib/Analysis/InnerProductSpace/Projection/Minimal.lean index 6ae2a163f50db1..6e1e5fbdfe7621 100644 --- a/Mathlib/Analysis/InnerProductSpace/Projection/Minimal.lean +++ b/Mathlib/Analysis/InnerProductSpace/Projection/Minimal.lean @@ -51,7 +51,7 @@ theorem exists_norm_eq_iInf_of_complete_convex {K : Set F} (ne : K.Nonempty) (h have norm_tendsto : Tendsto (fun n => ‖u - w n‖) atTop (𝓝 δ) := by have h : Tendsto (fun _ : ℕ => δ) atTop (𝓝 δ) := tendsto_const_nhds have h' : Tendsto (fun n : ℕ => δ + 1 / (n + 1)) atTop (𝓝 δ) := by - convert h.add tendsto_one_div_add_atTop_nhds_zero_nat + convert! h.add tendsto_one_div_add_atTop_nhds_zero_nat simp only [add_zero] exact tendsto_of_tendsto_of_tendsto_of_le_of_le h h' (fun x => δ_le _) fun x => le_of_lt (hw _) -- Step 2: Prove that the sequence `w : ℕ → K` is a Cauchy sequence @@ -130,7 +130,7 @@ theorem exists_norm_eq_iInf_of_complete_convex {K : Set F} (ne : K.Nonempty) (h use v, hv have h_cont : Continuous fun v => ‖u - v‖ := by fun_prop have : Tendsto (fun n => ‖u - w n‖) atTop (𝓝 ‖u - v‖) := by - convert Tendsto.comp h_cont.continuousAt w_tendsto + convert! Tendsto.comp h_cont.continuousAt w_tendsto exact tendsto_nhds_unique this norm_tendsto /-- Characterization of minimizers for the projection on a convex set in a real inner product diff --git a/Mathlib/Analysis/InnerProductSpace/Projection/Reflection.lean b/Mathlib/Analysis/InnerProductSpace/Projection/Reflection.lean index 60a5da6f20eaaf..4d8a0b48016da6 100644 --- a/Mathlib/Analysis/InnerProductSpace/Projection/Reflection.lean +++ b/Mathlib/Analysis/InnerProductSpace/Projection/Reflection.lean @@ -51,7 +51,7 @@ def reflection : E ≃ₗᵢ[𝕜] E := let w : K := K.orthogonalProjection x let v := x - w have : ⟪v, w⟫ = 0 := starProjection_inner_eq_zero x w w.2 - convert norm_sub_eq_norm_add this using 2 + convert! norm_sub_eq_norm_add this using 2 · dsimp [reflectionLinearEquiv, v, w] abel · simp only [v, add_sub_cancel] } @@ -160,7 +160,7 @@ theorem reflection_sub {v w : F} (h : ‖v‖ = ‖w‖) : reflection (ℝ ∙ ( rw [Submodule.mem_orthogonal_singleton_iff_inner_left] rw [real_inner_add_sub_eq_zero_iff] exact h - convert congr_arg₂ (· + ·) h₂ h₁ using 1 + convert! congr_arg₂ (· + ·) h₂ h₁ using 1 · simp · abel diff --git a/Mathlib/Analysis/InnerProductSpace/Projection/Submodule.lean b/Mathlib/Analysis/InnerProductSpace/Projection/Submodule.lean index 22dd5d909dbab5..b28b4b28e06839 100644 --- a/Mathlib/Analysis/InnerProductSpace/Projection/Submodule.lean +++ b/Mathlib/Analysis/InnerProductSpace/Projection/Submodule.lean @@ -47,7 +47,7 @@ theorem sup_orthogonal_inf_of_hasOrthogonalProjection {K₁ K₂ : Submodule variable {K} in /-- If `K` admits an orthogonal projection, then `K` and `Kᗮ` span the whole space. -/ theorem sup_orthogonal_of_hasOrthogonalProjection [K.HasOrthogonalProjection] : K ⊔ Kᗮ = ⊤ := by - convert Submodule.sup_orthogonal_inf_of_hasOrthogonalProjection (le_top : K ≤ ⊤) using 2 + convert! Submodule.sup_orthogonal_inf_of_hasOrthogonalProjection (le_top : K ≤ ⊤) using 2 simp /-- If `K` admits an orthogonal projection, then the orthogonal complement of its orthogonal @@ -87,7 +87,7 @@ of all elements equal to zero. Then `Kᗮ = ⊥`, `Kᗮᗮ = ⊤`. -/ theorem orthogonal_orthogonal_eq_closure [CompleteSpace E] : Kᗮᗮ = K.topologicalClosure := by refine le_antisymm ?_ ?_ - · convert Submodule.orthogonal_orthogonal_monotone K.le_topologicalClosure using 1 + · convert! Submodule.orthogonal_orthogonal_monotone K.le_topologicalClosure using 1 rw [K.topologicalClosure.orthogonal_orthogonal] · exact K.topologicalClosure_minimal K.le_orthogonal_orthogonal Kᗮ.isClosed_orthogonal @@ -150,7 +150,7 @@ theorem starProjection_tendsto_self {ι : Type*} [Preorder ι] have : (⨆ i, U i).topologicalClosure.HasOrthogonalProjection := by rw [top_unique hU'] infer_instance - convert starProjection_tendsto_closure_iSup U hU x + convert! starProjection_tendsto_closure_iSup U hU x rw [eq_comm, starProjection_eq_self_iff, top_unique hU'] trivial diff --git a/Mathlib/Analysis/InnerProductSpace/Rayleigh.lean b/Mathlib/Analysis/InnerProductSpace/Rayleigh.lean index 75aa1e71cd5cca..a6d1ebadaf3ce1 100644 --- a/Mathlib/Analysis/InnerProductSpace/Rayleigh.lean +++ b/Mathlib/Analysis/InnerProductSpace/Rayleigh.lean @@ -201,7 +201,7 @@ variable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F] theorem _root_.LinearMap.IsSymmetric.hasStrictFDerivAt_reApplyInnerSelf {T : F →L[ℝ] F} (hT : (T : F →ₗ[ℝ] F).IsSymmetric) (x₀ : F) : HasStrictFDerivAt T.reApplyInnerSelf (2 • (innerSL ℝ (T x₀))) x₀ := by - convert T.hasStrictFDerivAt.inner ℝ (hasStrictFDerivAt_id x₀) using 1 + convert! T.hasStrictFDerivAt.inner ℝ (hasStrictFDerivAt_id x₀) using 1 ext y rw [ContinuousLinearMap.smul_apply, ContinuousLinearMap.comp_apply, fderivInnerCLM_apply, ContinuousLinearMap.prod_apply, innerSL_apply_apply, id, ContinuousLinearMap.id_apply, @@ -213,7 +213,7 @@ theorem linearly_dependent_of_isLocalExtrOn (hT : IsSelfAdjoint T) {x₀ : F} (hextr : IsLocalExtrOn T.reApplyInnerSelf (sphere (0 : F) ‖x₀‖) x₀) : ∃ a b : ℝ, (a, b) ≠ 0 ∧ a • x₀ + b • T x₀ = 0 := by have H : IsLocalExtrOn T.reApplyInnerSelf {x : F | ‖x‖ ^ 2 = ‖x₀‖ ^ 2} x₀ := by - convert hextr + convert! hextr ext x simp -- find Lagrange multipliers for the function `T.re_apply_inner_self` and the @@ -245,7 +245,7 @@ theorem eq_smul_self_of_isLocalExtrOn_real (hT : IsSelfAdjoint T) {x₀ : F} have hc : T x₀ = (-b⁻¹ * a) • x₀ := by linear_combination (norm := match_scalars <;> field) b⁻¹ • h₂ set c : ℝ := -b⁻¹ * a - convert hc + convert! hc simpa [field, inner_smul_left, mul_comm a] using congr_arg (fun x => ⟪x, x₀⟫_ℝ) hc end Real @@ -276,7 +276,7 @@ quotient. -/ theorem hasEigenvector_of_isMaxOn (hT : IsSelfAdjoint T) {x₀ : E} (hx₀ : x₀ ≠ 0) (hextr : IsMaxOn T.reApplyInnerSelf (sphere (0 : E) ‖x₀‖) x₀) : HasEigenvector (T : E →ₗ[𝕜] E) (⨆ x : { x : E // x ≠ 0 }, T.rayleighQuotient x : ℝ) x₀ := by - convert hT.hasEigenvector_of_isLocalExtrOn hx₀ (Or.inr hextr.localize) + convert! hT.hasEigenvector_of_isLocalExtrOn hx₀ (Or.inr hextr.localize) have hx₀' : 0 < ‖x₀‖ := by simp [hx₀] have hx₀'' : x₀ ∈ sphere (0 : E) ‖x₀‖ := by simp rw [T.iSup_rayleigh_eq_iSup_rayleigh_sphere hx₀'] @@ -295,7 +295,7 @@ quotient. -/ theorem hasEigenvector_of_isMinOn (hT : IsSelfAdjoint T) {x₀ : E} (hx₀ : x₀ ≠ 0) (hextr : IsMinOn T.reApplyInnerSelf (sphere (0 : E) ‖x₀‖) x₀) : HasEigenvector (T : E →ₗ[𝕜] E) (⨅ x : { x : E // x ≠ 0 }, T.rayleighQuotient x : ℝ) x₀ := by - convert hT.hasEigenvector_of_isLocalExtrOn hx₀ (Or.inl hextr.localize) + convert! hT.hasEigenvector_of_isLocalExtrOn hx₀ (Or.inl hextr.localize) have hx₀' : 0 < ‖x₀‖ := by simp [hx₀] have hx₀'' : x₀ ∈ sphere (0 : E) ‖x₀‖ := by simp rw [T.iInf_rayleigh_eq_iInf_rayleigh_sphere hx₀'] diff --git a/Mathlib/Analysis/InnerProductSpace/Reproducing.lean b/Mathlib/Analysis/InnerProductSpace/Reproducing.lean index e5afb58cb220c8..7fe97d9977d220 100644 --- a/Mathlib/Analysis/InnerProductSpace/Reproducing.lean +++ b/Mathlib/Analysis/InnerProductSpace/Reproducing.lean @@ -197,8 +197,7 @@ theorem posSemidef_tfae : List.TFAE [K.PosSemidef, K.IsHermitian ∧ ∀ (f : X obtain ⟨v, hv⟩ := exists_ne (0 : V) tfae_have 1 → 2 := fun h ff ↦ by rw [Finsupp.sum_comm] - convert h (ff.sum fun xv z ↦ .single xv.1 - ((z / ‖v‖ ^ 2) • (innerSL 𝕜 v).smulRight xv.2)) v + convert! h (ff.sum fun xv z ↦ .single xv.1 ((z / ‖v‖ ^ 2) • (innerSL 𝕜 v).smulRight xv.2)) v simp [Finsupp.sum_sum_index, inner_add_right, inner_add_left, ← smul_assoc, hv] simp [inner_smul_left, inner_smul_right, ← mul_assoc, mul_comm] tfae_have 2 → 3 := fun h vv ↦ by diff --git a/Mathlib/Analysis/InnerProductSpace/SingularValues.lean b/Mathlib/Analysis/InnerProductSpace/SingularValues.lean index 29e365fda845fc..fe226adee921b1 100644 --- a/Mathlib/Analysis/InnerProductSpace/SingularValues.lean +++ b/Mathlib/Analysis/InnerProductSpace/SingularValues.lean @@ -134,7 +134,7 @@ theorem sq_singularValues_of_lt {n : ℕ} (hn : finrank 𝕜 E = n) {i : ℕ} (h theorem hasEigenvalue_adjoint_comp_self_sq_singularValues {n : ℕ} (hn : n < finrank 𝕜 E) : End.HasEigenvalue (adjoint T ∘ₗ T) (T.singularValues n ^ 2) := by - convert T.isSymmetric_adjoint_comp_self.hasEigenvalue_eigenvalues rfl ⟨n, hn⟩ using 1 + convert! T.isSymmetric_adjoint_comp_self.hasEigenvalue_eigenvalues rfl ⟨n, hn⟩ using 1 simp [← T.sq_singularValues_fin] theorem singularValues_antitone : Antitone T.singularValues := by @@ -162,7 +162,7 @@ theorem injective_iff_forall_lt_finrank_singularValues_pos : use i, i.isLt simp [RCLike.ofReal_eq_zero.mp hi, T.singularValues_fin rfl] · intro ⟨i, h, hz⟩ - convert T.isSymmetric_adjoint_comp_self.hasEigenvalue_eigenvalues rfl ⟨i, h⟩ + convert! T.isSymmetric_adjoint_comp_self.hasEigenvalue_eigenvalues rfl ⟨i, h⟩ rw [← sq_singularValues_of_lt, le_antisymm hz (T.singularValues_nonneg i)] simp diff --git a/Mathlib/Analysis/InnerProductSpace/Spectrum.lean b/Mathlib/Analysis/InnerProductSpace/Spectrum.lean index 40db395b63cfff..3a764c774eaaf8 100644 --- a/Mathlib/Analysis/InnerProductSpace/Spectrum.lean +++ b/Mathlib/Analysis/InnerProductSpace/Spectrum.lean @@ -234,8 +234,9 @@ private theorem card_filter_unsortedEigenvalues_eq (hT : T.IsSymmetric) (hn : Module.finrank 𝕜 E = n) (μ : 𝕜) : Finset.card {i | hT.unsortedEigenvalues hn i = μ} = Module.finrank 𝕜 (eigenspace T μ) := by by_cases hμ : HasEigenvalue T μ - · convert hT.direct_sum_isInternal.card_filter_subordinateOrthonormalBasisIndex_eq hn - hT.orthogonalFamily_eigenspaces' ⟨μ, hμ⟩ with i + · convert! + hT.direct_sum_isInternal.card_filter_subordinateOrthonormalBasisIndex_eq hn + hT.orthogonalFamily_eigenspaces' ⟨μ, hμ⟩ with i unfold unsortedEigenvalues let ⟨x, hx⟩ := hT.direct_sum_isInternal.subordinateOrthonormalBasisIndex hn i hT.orthogonalFamily_eigenspaces' @@ -370,9 +371,9 @@ theorem sort_roots_charpoly_eq_eigenvalues (hT : T.IsSymmetric) (hn : Module.fin simp_rw [hT.roots_charpoly_eq_eigenvalues, Fin.univ_val_map, Multiset.map_coe, List.map_ofFn, Function.comp_def, RCLike.ofReal_re, Multiset.coe_sort] have := hn.symm - convert List.mergeSort_of_pairwise ?_ + convert! List.mergeSort_of_pairwise ?_ simp_rw [decide_eq_true_eq, ← List.sortedGE_iff_pairwise] - convert (hT.eigenvalues_antitone hn).sortedGE_ofFn + convert! (hT.eigenvalues_antitone hn).sortedGE_ofFn theorem eigenvalues_eq_eigenvalues_iff {E' : Type*} [NormedAddCommGroup E'] [InnerProductSpace 𝕜 E'] [FiniteDimensional 𝕜 E'] {T' : E' →ₗ[𝕜] E'} (hT : T.IsSymmetric) (hn : Module.finrank 𝕜 E = n) diff --git a/Mathlib/Analysis/InnerProductSpace/Subspace.lean b/Mathlib/Analysis/InnerProductSpace/Subspace.lean index 7c4ad95e590b1e..f94e9483b448c3 100644 --- a/Mathlib/Analysis/InnerProductSpace/Subspace.lean +++ b/Mathlib/Analysis/InnerProductSpace/Subspace.lean @@ -181,7 +181,7 @@ theorem OrthogonalFamily.norm_sq_diff_sum [DecidableEq ι] (f : ∀ i, G i) (s (∑ i ∈ s₁ \ s₂, ‖F i‖ ^ 2) + ∑ i ∈ s₂ \ s₁, ‖F i‖ ^ 2 := by have hs : Disjoint (s₁ \ s₂) (s₂ \ s₁) := disjoint_sdiff_sdiff simpa only [Finset.sum_union hs] using hV.norm_sum F (s₁ \ s₂ ∪ s₂ \ s₁) - convert this using 4 + convert! this using 4 · refine Finset.sum_congr rfl fun i hi => ?_ simp only [hF₁ i hi] · refine Finset.sum_congr rfl fun i hi => ?_ @@ -220,13 +220,13 @@ theorem OrthogonalFamily.summable_iff_norm_sq_summable [CompleteSpace E] (f : have has : a ≤ s₁ ⊓ s₂ := le_inf hs₁ hs₂ rw [hV.norm_sq_diff_sum] have Hs₁ : ∑ x ∈ s₁ \ s₂, ‖f x‖ ^ 2 < ε ^ 2 / 2 := by - convert H _ hs₁ _ has + convert! H _ hs₁ _ has have : s₁ ⊓ s₂ ⊆ s₁ := Finset.inter_subset_left rw [← Finset.sum_sdiff this, add_tsub_cancel_right, Finset.abs_sum_of_nonneg'] · simp · exact fun i => sq_nonneg _ have Hs₂ : ∑ x ∈ s₂ \ s₁, ‖f x‖ ^ 2 < ε ^ 2 / 2 := by - convert H _ hs₂ _ has + convert! H _ hs₂ _ has have : s₁ ⊓ s₂ ⊆ s₂ := Finset.inter_subset_right rw [← Finset.sum_sdiff this, add_tsub_cancel_right, Finset.abs_sum_of_nonneg'] · simp diff --git a/Mathlib/Analysis/InnerProductSpace/TensorProduct.lean b/Mathlib/Analysis/InnerProductSpace/TensorProduct.lean index 00acc51790a69b..b6845890790c9e 100644 --- a/Mathlib/Analysis/InnerProductSpace/TensorProduct.lean +++ b/Mathlib/Analysis/InnerProductSpace/TensorProduct.lean @@ -469,7 +469,7 @@ theorem Orthonormal.tmul theorem Orthonormal.basisTensorProduct {b₁ : Basis ι₁ 𝕜 E} {b₂ : Basis ι₂ 𝕜 F} (hb₁ : Orthonormal 𝕜 b₁) (hb₂ : Orthonormal 𝕜 b₂) : Orthonormal 𝕜 (b₁.tensorProduct b₂) := by - convert hb₁.tmul hb₂ + convert! hb₁.tmul hb₂ exact b₁.tensorProduct_apply' b₂ _ namespace OrthonormalBasis diff --git a/Mathlib/Analysis/InnerProductSpace/TwoDim.lean b/Mathlib/Analysis/InnerProductSpace/TwoDim.lean index d8018b1a19152a..9e6e5d472f877b 100644 --- a/Mathlib/Analysis/InnerProductSpace/TwoDim.lean +++ b/Mathlib/Analysis/InnerProductSpace/TwoDim.lean @@ -108,7 +108,7 @@ theorem areaForm_apply_self (x : E) : ω x x = 0 := by theorem areaForm_swap (x y : E) : ω x y = -ω y x := by simp only [areaForm_to_volumeForm] - convert o.volumeForm.map_swap ![y, x] (_ : (0 : Fin 2) ≠ 1) + convert! o.volumeForm.map_swap ![y, x] (_ : (0 : Fin 2) ≠ 1) · ext i fin_cases i <;> rfl · simp @@ -157,7 +157,7 @@ theorem areaForm_map {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F theorem areaForm_comp_linearIsometryEquiv (φ : E ≃ₗᵢ[ℝ] E) (hφ : 0 < LinearMap.det (φ.toLinearEquiv : E →ₗ[ℝ] E)) (x y : E) : o.areaForm (φ x) (φ y) = o.areaForm x y := by - convert o.areaForm_map φ (φ x) (φ y) + convert! o.areaForm_map φ (φ x) (φ y) · symm rwa [← o.map_eq_iff_det_pos φ.toLinearEquiv] at hφ rw [@Fact.out (finrank ℝ E = 2), Fintype.card_fin] @@ -308,7 +308,7 @@ theorem rightAngleRotation_map {F : Type*} [NormedAddCommGroup F] [InnerProductS /-- `J` commutes with any positively-oriented isometric automorphism. -/ theorem linearIsometryEquiv_comp_rightAngleRotation (φ : E ≃ₗᵢ[ℝ] E) (hφ : 0 < LinearMap.det (φ.toLinearEquiv : E →ₗ[ℝ] E)) (x : E) : φ (J x) = J (φ x) := by - convert (o.rightAngleRotation_map φ (φ x)).symm + convert! (o.rightAngleRotation_map φ (φ x)).symm · simp · symm rwa [← o.map_eq_iff_det_pos φ.toLinearEquiv] at hφ diff --git a/Mathlib/Analysis/InnerProductSpace/l2Space.lean b/Mathlib/Analysis/InnerProductSpace/l2Space.lean index 0f7e1b57659a11..347b70bc4b4e0a 100644 --- a/Mathlib/Analysis/InnerProductSpace/l2Space.lean +++ b/Mathlib/Analysis/InnerProductSpace/l2Space.lean @@ -154,7 +154,7 @@ theorem inner_single_left [DecidableEq ι] (i : ι) (a : G i) (f : lp G 2) : ⟪lp.single 2 i a, f⟫ = ⟪a, f i⟫ := by refine (hasSum_inner (lp.single 2 i a) f).unique ?_ simp_rw [lp.coeFn_single] - convert hasSum_ite_eq i ⟪a, f i⟫ using 1 + convert! hasSum_ite_eq i ⟪a, f i⟫ using 1 ext j split_ifs with h · subst h; rw [Pi.single_eq_same] @@ -177,7 +177,7 @@ include hV protected theorem summable_of_lp (f : lp G 2) : Summable fun i => V i (f i) := by rw [hV.summable_iff_norm_sq_summable] - convert (lp.memℓp f).summable _ + convert! (lp.memℓp f).summable _ · norm_cast · norm_num @@ -198,7 +198,7 @@ protected def linearIsometry (hV : OrthogonalFamily 𝕜 G V) : lp G 2 →ₗᵢ suffices ‖∑' i : ι, V i (f i)‖ ^ (2 : ℝ≥0∞).toReal = ‖f‖ ^ (2 : ℝ≥0∞).toReal by exact Real.rpow_left_injOn H.ne' (norm_nonneg _) (norm_nonneg _) this refine tendsto_nhds_unique ?_ (lp.hasSum_norm H f) - convert (hV.summable_of_lp f).hasSum.norm.rpow_const (Or.inr H.le) using 1 + convert! (hV.summable_of_lp f).hasSum.norm.rpow_const (Or.inr H.le) using 1 ext s exact mod_cast (hV.norm_sum f s).symm @@ -344,7 +344,7 @@ theorem Orthonormal.isHilbertSum {v : ι → E} (hv : Orthonormal 𝕜 v) (hsp : ⊤ ≤ (span 𝕜 (Set.range v)).topologicalClosure) : IsHilbertSum 𝕜 (fun _ : ι => 𝕜) fun i => LinearIsometry.toSpanSingleton 𝕜 E (hv.1 i) := IsHilbertSum.mk hv.orthogonalFamily (by - convert hsp + convert! hsp simp [← LinearMap.span_singleton_eq_range, ← Submodule.span_iUnion]) theorem Submodule.isHilbertSumOrthogonal (K : Submodule 𝕜 E) [hK : CompleteSpace K] : @@ -398,7 +398,7 @@ instance instFunLike : FunLike (HilbertBasis ι 𝕜 E) ι E where protected theorem repr_symm_single [DecidableEq ι] (b : HilbertBasis ι 𝕜 E) (i : ι) : b.repr.symm (lp.single 2 i (1 : 𝕜)) = b i := by dsimp +instances [instFunLike] - convert rfl + convert! rfl protected theorem repr_self [DecidableEq ι] (b : HilbertBasis ι 𝕜 E) (i : ι) : @@ -456,7 +456,7 @@ protected theorem dense_span (b : HilbertBasis ι 𝕜 E) : protected theorem hasSum_inner_mul_inner (b : HilbertBasis ι 𝕜 E) (x y : E) : HasSum (fun i => ⟪x, b i⟫ * ⟪b i, y⟫) ⟪x, y⟫ := by - convert (b.hasSum_repr y).mapL (innerSL 𝕜 x) using 1 + convert! (b.hasSum_repr y).mapL (innerSL 𝕜 x) using 1 ext i rw [innerSL_apply_apply, b.repr_apply_apply, inner_smul_right, mul_comm] diff --git a/Mathlib/Analysis/LocallyConvex/AbsConvexOpen.lean b/Mathlib/Analysis/LocallyConvex/AbsConvexOpen.lean index 79624fc127d040..812c09cfba3a10 100644 --- a/Mathlib/Analysis/LocallyConvex/AbsConvexOpen.lean +++ b/Mathlib/Analysis/LocallyConvex/AbsConvexOpen.lean @@ -110,7 +110,7 @@ theorem with_gaugeSeminormFamily : WithSeminorms (gaugeSeminormFamily 𝕜 E) := refine SeminormFamily.withSeminorms_of_hasBasis _ ?_ refine (nhds_hasBasis_absConvex_open 𝕜 E).to_hasBasis (fun s hs => ?_) fun s hs => ?_ · refine ⟨s, ⟨?_, rfl.subset⟩⟩ - convert (gaugeSeminormFamily _ _).basisSets_singleton_mem ⟨s, hs⟩ one_pos + convert! (gaugeSeminormFamily _ _).basisSets_singleton_mem ⟨s, hs⟩ one_pos rw [gaugeSeminormFamily_ball, Subtype.coe_mk] refine ⟨s, ⟨?_, rfl.subset⟩⟩ rw [SeminormFamily.basisSets_iff] at hs diff --git a/Mathlib/Analysis/LocallyConvex/Barrelled.lean b/Mathlib/Analysis/LocallyConvex/Barrelled.lean index 3d60f65543520b..415a5456bcaa8f 100644 --- a/Mathlib/Analysis/LocallyConvex/Barrelled.lean +++ b/Mathlib/Analysis/LocallyConvex/Barrelled.lean @@ -105,7 +105,7 @@ theorem Seminorm.continuous_iSup refine Seminorm.continuous_of_lowerSemicontinuous _ ?_ rw [Seminorm.coe_iSup_eq bdd] rw [Seminorm.bddAbove_range_iff] at bdd - convert lowerSemicontinuous_ciSup (f := fun i x ↦ p i x) bdd (fun i ↦ (hp i).lowerSemicontinuous) + convert! lowerSemicontinuous_ciSup (f := fun i x ↦ p i x) bdd (fun i ↦ (hp i).lowerSemicontinuous) exact iSup_apply end defs @@ -138,7 +138,7 @@ instance BaireSpace.instBarrelledSpace [TopologicalSpace E] [IsTopologicalAddGro -- radius `2*n` is a neighborhood of zero. refine Seminorm.continuous' (r := n + n) ?_ rw [p.closedBall_zero_eq] at hxn ⊢ - have hxn' : p x ≤ n := by convert interior_subset hxn + have hxn' : p x ≤ n := by convert! interior_subset hxn -- By definition, we have `p x' ≤ n` for `x'` sufficiently close to `x`. -- In other words, `p (x + y) ≤ n` for `y` sufficiently close to `0`. rw [mem_interior_iff_mem_nhds, ← map_add_left_nhds_zero] at hxn diff --git a/Mathlib/Analysis/LocallyConvex/SeparatingDual.lean b/Mathlib/Analysis/LocallyConvex/SeparatingDual.lean index 017db44ca9d888..dd9d59916af86e 100644 --- a/Mathlib/Analysis/LocallyConvex/SeparatingDual.lean +++ b/Mathlib/Analysis/LocallyConvex/SeparatingDual.lean @@ -222,9 +222,7 @@ theorem exists_continuousLinearEquiv_apply_eq smul_eq_mul, mul_sub, mul_one] rw [mul_comm _ (G y), ← mul_assoc, mul_inv_cancel₀ Gy] simp only [smul_sub, one_mul, add_sub_cancel] - abel - continuous_toFun := by fun_prop - continuous_invFun := by fun_prop } + abel } exact ⟨A, show x + G x • (y - x) = y by simp [Gx]⟩ end Field diff --git a/Mathlib/Analysis/LocallyConvex/WithSeminorms.lean b/Mathlib/Analysis/LocallyConvex/WithSeminorms.lean index b9dceb24d859fd..46fa0bc06a98bf 100644 --- a/Mathlib/Analysis/LocallyConvex/WithSeminorms.lean +++ b/Mathlib/Analysis/LocallyConvex/WithSeminorms.lean @@ -330,7 +330,7 @@ theorem WithSeminorms.hasBasis_ball (hp : WithSeminorms p) {x : E} : (fun sr : Finset ι × ℝ => 0 < sr.2) fun sr => (sr.1.sup p).ball x sr.2 := by have : IsTopologicalAddGroup E := hp.topologicalAddGroup rw [← map_add_left_nhds_zero] - convert hp.hasBasis_zero_ball.map (x + ·) using 1 + convert! hp.hasBasis_zero_ball.map (x + ·) using 1 ext sr : 1 -- Porting note: extra type ascriptions needed on `0` have : (sr.fst.sup p).ball (x +ᵥ (0 : E)) sr.snd = x +ᵥ (sr.fst.sup p).ball 0 sr.snd := @@ -545,7 +545,7 @@ theorem WithSeminorms.isVonNBounded_iff_seminorm_bounded {s : Set E} (hp : WithS rw [hp.isVonNBounded_iff_finset_seminorm_bounded] constructor · intro hI i - convert hI {i} + convert! hI { i } rw [Finset.sup_singleton] intro hi I by_cases! hI : I.Nonempty @@ -654,7 +654,7 @@ theorem continuous_of_continuous_comp {q : SeminormFamily 𝕝₂ F ι'} [Topolo simp_rw [ContinuousAt, f.map_zero, q.withSeminorms_iff_nhds_eq_iInf.mp hq, Filter.tendsto_iInf, Filter.tendsto_comap_iff] intro i - convert (hf i).continuousAt.tendsto + convert! (hf i).continuousAt.tendsto exact (map_zero _).symm @[deprecated (since := "2026-03-09")] diff --git a/Mathlib/Analysis/MeanInequalities.lean b/Mathlib/Analysis/MeanInequalities.lean index 3bc7e6ec8dbaaf..a94e89345a6651 100644 --- a/Mathlib/Analysis/MeanInequalities.lean +++ b/Mathlib/Analysis/MeanInequalities.lean @@ -141,7 +141,7 @@ theorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 -- for `exp` and numbers `log (z i)` with weights `w i`. · have := convexOn_exp.map_sum_le hw hw' fun i _ => Set.mem_univ <| log (z i) simp only [exp_sum, smul_eq_mul, mul_comm (w _) (log _)] at this - convert this using 1 <;> [apply prod_congr rfl; apply sum_congr rfl] <;> intro i hi + convert! this using 1 <;> [apply prod_congr rfl; apply sum_congr rfl] <;> intro i hi · rcases eq_or_lt_of_le (hz i hi) with hz | hz · simp [A i hi hz.symm] · exact rpow_def_of_pos hz _ @@ -153,7 +153,7 @@ theorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 theorem geom_mean_le_arith_mean {ι : Type*} (s : Finset ι) (w : ι → ℝ) (z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i) (hw' : 0 < ∑ i ∈ s, w i) (hz : ∀ i ∈ s, 0 ≤ z i) : (∏ i ∈ s, z i ^ w i) ^ (∑ i ∈ s, w i)⁻¹ ≤ (∑ i ∈ s, w i * z i) / (∑ i ∈ s, w i) := by - convert geom_mean_le_arith_mean_weighted s (fun i => (w i) / ∑ i ∈ s, w i) z ?_ ?_ hz using 2 + convert! geom_mean_le_arith_mean_weighted s (fun i => (w i) / ∑ i ∈ s, w i) z ?_ ?_ hz using 2 · rw [← finsetProd_rpow _ _ (fun i hi => rpow_nonneg (hz _ hi) _) _] refine Finset.prod_congr rfl (fun _ ih => ?_) rw [div_eq_mul_inv, rpow_mul (hz _ ih)] @@ -211,14 +211,14 @@ theorem geom_mean_eq_arith_mean_weighted_iff' (w z : ι → ℝ) (hw : ∀ i ∈ apply (sum_eq_zero_iff_of_nonneg ?_).mp h.symm j hj exact fun i hi => (mul_nonneg_iff_of_pos_left (hw i hi)).mpr (hz i hi) · intro h - convert h i his + convert! h i his exact hzi.symm · rw [hzi] exact zero_rpow hwi · have hz' := fun i h => lt_of_le_of_ne (hz i h) (fun a => (ne_of_gt (hw i h)) (A i h a.symm)) have := strictConvexOn_exp.map_sum_eq_iff hw hw' fun i _ => Set.mem_univ <| log (z i) simp only [exp_sum, smul_eq_mul, mul_comm (w _) (log _)] at this - convert this using 1 + convert! this using 1 · apply Eq.congr <;> [apply prod_congr rfl; apply sum_congr rfl] <;> intro i hi <;> @@ -369,7 +369,7 @@ theorem harm_mean_le_geom_mean {ι : Type*} (s : Finset ι) (hs : s.Nonempty) (w set n := ∑ i ∈ s, w i nth_rw 1 [div_eq_mul_inv, (show n = (n⁻¹)⁻¹ by simp), ← mul_inv, Finset.mul_sum _ _ n⁻¹] simp_rw [inv_mul_eq_div n ((w _) / (z _)), div_right_comm _ _ n] - convert this + convert! this rw [← Real.finsetProd_rpow s _ (fun i hi ↦ by positivity [hz i hi])] refine Finset.prod_congr rfl (fun i hi => ?_) rw [← Real.rpow_mul (le_of_lt <| hz i hi) (w _) n⁻¹, div_eq_mul_inv (w _) n] @@ -512,8 +512,9 @@ product of their `L^p` and `L^q` norms when `p`, `q`, and `r` form a `Real.Holde theorem Lr_le_Lp_mul_Lq (f g : ι → ℝ≥0) {p q r : ℝ} (hpqr : p.HolderTriple q r) : (∑ i ∈ s, (f i * g i) ^ r) ^ (1 / r) ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by - convert rpow_le_rpow_iff (inv_eq_one_div r ▸ inv_pos.mpr hpqr.pos' : 0 < 1 / r) |>.mpr <| - Lr_rpow_le_Lp_mul_Lq s f g hpqr using 1 + convert! + rpow_le_rpow_iff (inv_eq_one_div r ▸ inv_pos.mpr hpqr.pos' : 0 < 1 / r) |>.mpr <| + Lr_rpow_le_Lp_mul_Lq s f g hpqr using 1 have hr := hpqr.pos'.ne' simp only [← rpow_mul, mul_rpow] field_simp @@ -588,8 +589,9 @@ theorem Lr_rpow_le_Lp_mul_Lq_tsum {f g : ι → ℝ≥0} {p q r : ℝ} (hpqr : p theorem Lr_le_Lp_mul_Lq_tsum {f g : ι → ℝ≥0} {p q r : ℝ} (hpqr : p.HolderTriple q r) (hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) : (∑' i, (f i * g i) ^ r) ^ (1 / r) ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) := by - convert rpow_le_rpow_iff (inv_eq_one_div r ▸ inv_pos.mpr hpqr.pos') |>.mpr <| - Lr_rpow_le_Lp_mul_Lq_tsum hpqr hf hg + convert! + rpow_le_rpow_iff (inv_eq_one_div r ▸ inv_pos.mpr hpqr.pos') |>.mpr <| + Lr_rpow_le_Lp_mul_Lq_tsum hpqr hf hg have hr := hpqr.pos'.ne' simp only [← rpow_mul, mul_rpow] field_simp @@ -776,7 +778,7 @@ with real-valued nonnegative functions. -/ theorem inner_le_Lp_mul_Lq_of_nonneg (hpq : HolderConjugate p q) (hf : ∀ i ∈ s, 0 ≤ f i) (hg : ∀ i ∈ s, 0 ≤ g i) : ∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by - convert inner_le_Lp_mul_Lq s f g hpq using 3 <;> apply sum_congr rfl <;> intro i hi <;> + convert! inner_le_Lp_mul_Lq s f g hpq using 3 <;> apply sum_congr rfl <;> intro i hi <;> simp only [abs_of_nonneg, hf i hi, hg i hi] /-- **Hölder inequality**: the sum of (the `r`-power of) the product of two functions is bounded @@ -785,7 +787,7 @@ by (the `r`-power of) the product of their `L^p` and `L^q` norms, when `p`, `q`, theorem Lr_rpow_le_Lp_mul_Lq_of_nonneg {ι : Type*} (s : Finset ι) {f g : ι → ℝ} {p q r : ℝ} (hpqr : p.HolderTriple q r) (hf : ∀ i ∈ s, 0 ≤ f i) (hg : ∀ i ∈ s, 0 ≤ g i) : ∑ i ∈ s, (f i * g i) ^ r ≤ (∑ i ∈ s, f i ^ p) ^ (r / p) * (∑ i ∈ s, g i ^ q) ^ (r / q) := by - convert Lr_rpow_le_Lp_mul_Lq s f g hpqr using 3 with i hi + convert! Lr_rpow_le_Lp_mul_Lq s f g hpqr using 3 with i hi · rw [abs_of_nonneg (mul_nonneg (hf i hi) (hg i hi))] all_goals congr! with i hi @@ -861,9 +863,10 @@ theorem Lr_le_Lp_mul_Lq_tsum_of_nonneg (hpqr : p.HolderTriple q r) (hf : ∀ i, have hf' : 0 ≤ ∑' i, f i ^ p := tsum_nonneg fun i ↦ rpow_nonneg (hf i) p have hg' : 0 ≤ ∑' i, g i ^ q := tsum_nonneg fun i ↦ rpow_nonneg (hg i) q have hr := hpqr.pos' - convert rpow_le_rpow_iff (tsum_nonneg fun i ↦ by positivity [hf i, hg i]) (by positivity) - (inv_eq_one_div r ▸ inv_pos.mpr hr) |>.mpr <| - Lr_rpow_le_Lp_mul_Lq_tsum_of_nonneg hpqr hf hg hf_sum hg_sum using 1 + convert! + rpow_le_rpow_iff (tsum_nonneg fun i ↦ by positivity [hf i, hg i]) (by positivity) + (inv_eq_one_div r ▸ inv_pos.mpr hr) |>.mpr <| + Lr_rpow_le_Lp_mul_Lq_tsum_of_nonneg hpqr hf hg hf_sum hg_sum using 1 rw [mul_rpow (rpow_nonneg hf' _) (rpow_nonneg hg' _), ← Real.rpow_mul hg', ← Real.rpow_mul hf'] field_simp @@ -899,7 +902,7 @@ sum of the `p`-th powers of `f i`. Version for sums over finite sets, with nonne functions. -/ theorem rpow_sum_le_const_mul_sum_rpow_of_nonneg (hp : 1 ≤ p) (hf : ∀ i ∈ s, 0 ≤ f i) : (∑ i ∈ s, f i) ^ p ≤ (#s : ℝ) ^ (p - 1) * ∑ i ∈ s, f i ^ p := by - convert rpow_sum_le_const_mul_sum_rpow s f hp using 2 <;> apply sum_congr rfl <;> intro i hi <;> + convert! rpow_sum_le_const_mul_sum_rpow s f hp using 2 <;> apply sum_congr rfl <;> intro i hi <;> simp only [abs_of_nonneg, hf i hi] /-- **Minkowski inequality**: the `L_p` seminorm of the sum of two vectors is less than or equal @@ -908,7 +911,7 @@ functions. -/ theorem Lp_add_le_of_nonneg (hp : 1 ≤ p) (hf : ∀ i ∈ s, 0 ≤ f i) (hg : ∀ i ∈ s, 0 ≤ g i) : (∑ i ∈ s, (f i + g i) ^ p) ^ (1 / p) ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) + (∑ i ∈ s, g i ^ p) ^ (1 / p) := by - convert Lp_add_le s f g hp using 2 <;> [skip; congr 1; congr 1] <;> apply sum_congr rfl <;> + convert! Lp_add_le s f g hp using 2 <;> [skip; congr 1; congr 1] <;> apply sum_congr rfl <;> intro i hi <;> simp only [abs_of_nonneg, hf i hi, hg i hi, add_nonneg] @@ -987,7 +990,7 @@ theorem inner_le_Lp_mul_Lq (hpq : p.HolderConjugate q) : have := ENNReal.coe_le_coe.2 (@NNReal.inner_le_Lp_mul_Lq _ s (fun i => ENNReal.toNNReal (f i)) (fun i => ENNReal.toNNReal (g i)) _ _ hpq) simp [ENNReal.coe_rpow_of_nonneg, hpq.pos.le, hpq.symm.pos.le] at this - convert this using 1 <;> [skip; congr 2] <;> [skip; skip; simp; skip; simp] <;> + convert! this using 1 <;> [skip; congr 2] <;> [skip; skip; simp; skip; simp] <;> · refine Finset.sum_congr rfl fun i hi => ?_ simp [H'.1 i hi, H'.2 i hi, -WithZero.coe_mul] @@ -1013,12 +1016,12 @@ lemma inner_le_weight_mul_Lp_of_nonneg (s : Finset ι) {p : ℝ} (hp : 1 ≤ p) simp_rw [coe_rpow_of_nonneg _ <| inv_nonneg.2 hp₀.le, coe_finsetSum, ← ENNReal.toNNReal_rpow, ← ENNReal.toNNReal_mul, sum_congr rfl fun i hi ↦ coe_toNNReal (H'.2 i hi)] at this simp only [toNNReal_mul, coe_mul, sub_nonneg, hp₁.le, coe_rpow_of_nonneg, coe_finsetSum] at this - convert this using 2 with i hi + convert! this using 2 with i hi · obtain hw | hw := eq_or_ne (w i) 0 · simp [hw] rw [coe_toNNReal (H'.1 _ hi), coe_toNNReal] simpa [mul_eq_top, hw, hp₀, hp₀.not_gt, H'.1 _ hi] using H'.2 _ hi - · convert rfl with i hi + · convert! rfl with i hi exact coe_toNNReal (H'.1 _ hi) /-- For `1 ≤ p`, the `p`-th power of the sum of `f i` is bounded above by a constant times the diff --git a/Mathlib/Analysis/MeanInequalitiesPow.lean b/Mathlib/Analysis/MeanInequalitiesPow.lean index c11351d9785525..e07ad45e6921b3 100644 --- a/Mathlib/Analysis/MeanInequalitiesPow.lean +++ b/Mathlib/Analysis/MeanInequalitiesPow.lean @@ -118,8 +118,8 @@ theorem rpow_add_le_mul_rpow_add_rpow (z₁ z₂ : ℝ≥0) {p : ℝ} (hp : 1 (z₁ + z₂) ^ p ≤ (2 : ℝ≥0) ^ (p - 1) * (z₁ ^ p + z₂ ^ p) := by rcases eq_or_lt_of_le hp with (rfl | h'p) · simp only [rpow_one, sub_self, rpow_zero, one_mul]; rfl - convert rpow_arith_mean_le_arith_mean2_rpow (1 / 2) (1 / 2) (2 * z₁) (2 * z₂) (add_halves 1) hp - using 1 + convert! + rpow_arith_mean_le_arith_mean2_rpow (1 / 2) (1 / 2) (2 * z₁) (2 * z₂) (add_halves 1) hp using 1 · simp only [one_div, inv_mul_cancel_left₀, Ne, two_ne_zero, not_false_iff] · have A : p - 1 ≠ 0 := ne_of_gt (sub_pos.2 h'p) @@ -271,8 +271,9 @@ theorem rpow_arith_mean_le_arith_mean2_rpow (w₁ w₂ z₁ z₂ : ℝ≥0∞) ( /-- Unweighted mean inequality, version for two elements of `ℝ≥0∞` and real exponents. -/ theorem rpow_add_le_mul_rpow_add_rpow (z₁ z₂ : ℝ≥0∞) {p : ℝ} (hp : 1 ≤ p) : (z₁ + z₂) ^ p ≤ (2 : ℝ≥0∞) ^ (p - 1) * (z₁ ^ p + z₂ ^ p) := by - convert rpow_arith_mean_le_arith_mean2_rpow (1 / 2) (1 / 2) (2 * z₁) (2 * z₂) - (ENNReal.add_halves 1) hp using 1 + convert! + rpow_arith_mean_le_arith_mean2_rpow (1 / 2) (1 / 2) (2 * z₁) (2 * z₂) (ENNReal.add_halves 1) hp + using 1 · simp [← mul_assoc, ENNReal.inv_mul_cancel two_ne_zero ofNat_ne_top] · simp only [mul_rpow_of_nonneg _ _ (zero_le_one.trans hp), rpow_sub _ _ two_ne_zero ofNat_ne_top, ENNReal.div_eq_inv_mul, rpow_one, mul_one] @@ -365,7 +366,7 @@ theorem rpow_add_le_mul_rpow_add_rpow'' (z₁ z₂ : ℝ≥0∞) {p : ℝ≥0∞ LpAddConst p * (z₁ ^ p.toReal⁻¹ + z₂ ^ p.toReal⁻¹) := by by_cases p_zero : p = 0 · simp [p_zero, LpAddConst_zero] - convert rpow_add_le_mul_rpow_add_rpow' z₁ z₂ (p := p.toReal⁻¹) (by positivity) using 1 + convert! rpow_add_le_mul_rpow_add_rpow' z₁ z₂ (p := p.toReal⁻¹) (by positivity) using 1 rw [← ENNReal.toReal_inv, ENNReal.ofReal_toReal (by simpa), inv_inv] end ENNReal diff --git a/Mathlib/Analysis/MellinTransform.lean b/Mathlib/Analysis/MellinTransform.lean index aaf94516e55c1e..ec65cf9baa8f92 100644 --- a/Mathlib/Analysis/MellinTransform.lean +++ b/Mathlib/Analysis/MellinTransform.lean @@ -390,7 +390,7 @@ theorem mellin_hasDerivAt_of_isBigO_rpow [NormedSpace ℂ E] {a b : ℝ} refine (ae_restrict_mem measurableSet_Ioi).mono fun t ht y _ => ?_ have ht' : (t : ℂ) ≠ 0 := ofReal_ne_zero.mpr (ne_of_gt ht) have u1 : HasDerivAt (fun z : ℂ => (t : ℂ) ^ (z - 1)) (t ^ (y - 1) * log t) y := by - convert ((hasDerivAt_id' y).sub_const 1).const_cpow (Or.inl ht') using 1 + convert! ((hasDerivAt_id' y).sub_const 1).const_cpow (Or.inl ht') using 1 rw [ofReal_log (le_of_lt ht)] ring exact u1.smul_const (f t) diff --git a/Mathlib/Analysis/Meromorphic/Basic.lean b/Mathlib/Analysis/Meromorphic/Basic.lean index 49c044035dba9c..2a85d8fa4af22c 100644 --- a/Mathlib/Analysis/Meromorphic/Basic.lean +++ b/Mathlib/Analysis/Meromorphic/Basic.lean @@ -90,7 +90,7 @@ lemma smul {f : 𝕜 → 𝕜} {g : 𝕜 → E} (hf : MeromorphicAt f x) (hg : M rcases hf with ⟨m, hf⟩ rcases hg with ⟨n, hg⟩ refine ⟨m + n, ?_⟩ - convert hf.smul hg using 2 with z + convert! hf.smul hg using 2 with z simp module @@ -100,7 +100,7 @@ lemma mul {f g : 𝕜 → 𝕜'} (hf : MeromorphicAt f x) (hg : MeromorphicAt g rcases hf with ⟨m, hf⟩ rcases hg with ⟨n, hg⟩ refine ⟨m + n, ?_⟩ - convert hf.mul hg using 2 with z + convert! hf.mul hg using 2 with z simp module @@ -122,7 +122,7 @@ theorem prod (hf : ∀ σ ∈ s, MeromorphicAt (F σ) x) : @[fun_prop] theorem fun_prod (h : ∀ σ ∈ s, MeromorphicAt (F σ) x) : MeromorphicAt (fun z ↦ ∏ n ∈ s, F n z) x := by - convert prod h (s := s) + convert! prod h (s := s) simp /-- Finprods of meromorphic functions are meromorphic. -/ @@ -151,7 +151,7 @@ theorem sum (h : ∀ σ ∈ s, MeromorphicAt (G σ) x) : @[fun_prop] theorem fun_sum (h : ∀ σ ∈ s, MeromorphicAt (G σ) x) : MeromorphicAt (fun z ↦ ∑ n ∈ s, G n z) x := by - convert sum h (s := s) + convert! sum h (s := s) simp /-- Finsums of meromorphic functions are meromorphic. -/ @@ -164,7 +164,7 @@ theorem finsum (hF : ∀ i, MeromorphicAt (F i) x) : @[to_fun (attr := fun_prop)] lemma neg {f : 𝕜 → E} (hf : MeromorphicAt f x) : MeromorphicAt (-f) x := by - convert (MeromorphicAt.const (-1 : 𝕜) x).smul hf using 1 + convert! (MeromorphicAt.const (-1 : 𝕜) x).smul hf using 1 ext1 z simp only [Pi.neg_apply, Pi.smul_apply', neg_smul, one_smul] @@ -176,7 +176,7 @@ lemma neg_iff {f : 𝕜 → E} : @[to_fun (attr := fun_prop)] lemma sub {f g : 𝕜 → E} (hf : MeromorphicAt f x) (hg : MeromorphicAt g x) : MeromorphicAt (f - g) x := by - convert hf.add hg.neg using 1 + convert! hf.add hg.neg using 1 ext1 z simp_rw [Pi.sub_apply, Pi.add_apply, Pi.neg_apply, sub_eq_add_neg] diff --git a/Mathlib/Analysis/Meromorphic/Divisor.lean b/Mathlib/Analysis/Meromorphic/Divisor.lean index d11d81dd6dd08f..f012314865d5ab 100644 --- a/Mathlib/Analysis/Meromorphic/Divisor.lean +++ b/Mathlib/Analysis/Meromorphic/Divisor.lean @@ -180,7 +180,7 @@ The divisor of a constant function is `0`. -/ @[simp] theorem divisor_ofNat (n : ℕ) : divisor (ofNat(n) : 𝕜 → 𝕜) U = 0 := by - convert divisor_const (n : 𝕜) + convert! divisor_const (n : 𝕜) simp [Semiring.toGrindSemiring_ofNat 𝕜 n] /-! @@ -318,7 +318,7 @@ theorem divisor_fun_prod {ι : Type*} {s : Finset ι} {f : ι → 𝕜 → 𝕜} (h₁f : ∀ i ∈ s, MeromorphicOn (f i) U) (h₂f : ∀ i ∈ s, ∀ z ∈ U, meromorphicOrderAt (f i) z ≠ ⊤) : divisor (fun x ↦ ∏ i ∈ s, f i x) U = ∑ i ∈ s, divisor (f i) U := by - convert divisor_prod h₁f h₂f + convert! divisor_prod h₁f h₂f exact (Finset.prod_apply _ s f).symm /-- The divisor of the inverse is the negative of the divisor. -/ diff --git a/Mathlib/Analysis/Meromorphic/NormalForm.lean b/Mathlib/Analysis/Meromorphic/NormalForm.lean index c740a4f9fff20e..75c430a7f71f17 100644 --- a/Mathlib/Analysis/Meromorphic/NormalForm.lean +++ b/Mathlib/Analysis/Meromorphic/NormalForm.lean @@ -297,7 +297,7 @@ theorem meromorphicNFAt_fun_prod {x : 𝕜} {ι : Type*} {s : Finset ι} {f : ι (h₁f : ∀ i ∈ s, MeromorphicNFAt (f i) x) (h₂f : Set.Subsingleton {σ ∈ s | f σ x = 0}) : MeromorphicNFAt (fun a ↦ ∏ i ∈ s, f i a) x := by - convert meromorphicNFAt_prod h₁f h₂f + convert! meromorphicNFAt_prod h₁f h₂f exact (Finset.prod_apply _ s f).symm /-- @@ -610,7 +610,7 @@ theorem meromorphicNFOn_fun_prod {ι : Type*} {s : Finset ι} {f : ι → 𝕜 (h₁f : ∀ i ∈ s, MeromorphicNFOn (f i) U) (h₂f : ∀ x ∈ U, Set.Subsingleton {σ ∈ s | f σ x = 0}) : MeromorphicNFOn (fun x ↦ ∏ i ∈ s, f i x) U := by - convert meromorphicNFOn_prod h₁f h₂f + convert! meromorphicNFOn_prod h₁f h₂f exact (Finset.prod_apply _ s f).symm /-- diff --git a/Mathlib/Analysis/Meromorphic/Order.lean b/Mathlib/Analysis/Meromorphic/Order.lean index 00c76cd85b7062..6b1d596151a53e 100644 --- a/Mathlib/Analysis/Meromorphic/Order.lean +++ b/Mathlib/Analysis/Meromorphic/Order.lean @@ -358,7 +358,7 @@ The order of a constant function is `⊤` if the constant is zero and `0` otherw -/ @[simp] theorem meromorphicOrderAt_const_ofNat (z₀ : 𝕜) (n : ℕ) [Decidable ((n : 𝕜) = 0)] : meromorphicOrderAt (ofNat(n) : 𝕜 → 𝕜) z₀ = if (n : 𝕜) = 0 then ⊤ else (0 : WithTop ℤ) := by - convert meromorphicOrderAt_const z₀ (n : 𝕜) + convert! meromorphicOrderAt_const z₀ (n : 𝕜) simp [Semiring.toGrindSemiring_ofNat 𝕜 n] /-- The order of `(· - x) ^ n` at `x` is `n`. -/ @@ -370,7 +370,7 @@ The order of a constant function is `⊤` if the constant is zero and `0` otherw /-- The order of `(· - x) ^ n` at `x` is `n`. -/ @[simp, to_fun] theorem meromorphicOrderAt_pow_id_sub_const {n : ℕ} : meromorphicOrderAt ((· - x) ^ n) x = n := by - convert meromorphicOrderAt_zpow_id_sub_const + convert! meromorphicOrderAt_zpow_id_sub_const simp only [zpow_natCast] /-- The order of `· - x` at `x` is `1`. -/ @@ -456,7 +456,7 @@ The order is additive in products of meromorphic functions. theorem meromorphicOrderAt_fun_prod {x : 𝕜} {ι : Type*} {s : Finset ι} {f : ι → 𝕜 → 𝕜} (hf : ∀ i ∈ s, MeromorphicAt (f i) x) : meromorphicOrderAt (fun a ↦ ∏ i ∈ s, f i a) x = ∑ i ∈ s, meromorphicOrderAt (f i) x := by - convert meromorphicOrderAt_prod hf + convert! meromorphicOrderAt_prod hf exact (Finset.prod_apply _ s f).symm /-- The order multiplies by `n` when taking a meromorphic function to its `n`th power. -/ @@ -792,8 +792,9 @@ function has zero or infinite order is codiscrete within its domain of meromorph theorem codiscreteWithin_setOf_meromorphicOrderAt_eq_zero_or_top (h₁f : MeromorphicOn f U) (h₂f : ∀ u ∈ U, meromorphicOrderAt f u ≠ ⊤) : {u ∈ U | meromorphicOrderAt f u = 0 ∨ meromorphicOrderAt f u = ⊤} ∈ codiscreteWithin U := by - convert mem_codiscrete_subtype_iff_mem_codiscreteWithin.1 - h₁f.codiscrete_setOf_meromorphicOrderAt_eq_zero_or_top + convert! + mem_codiscrete_subtype_iff_mem_codiscreteWithin.1 + h₁f.codiscrete_setOf_meromorphicOrderAt_eq_zero_or_top aesop end MeromorphicOn diff --git a/Mathlib/Analysis/Meromorphic/TrailingCoefficient.lean b/Mathlib/Analysis/Meromorphic/TrailingCoefficient.lean index 459e144ce25152..7a830cde3f2de0 100644 --- a/Mathlib/Analysis/Meromorphic/TrailingCoefficient.lean +++ b/Mathlib/Analysis/Meromorphic/TrailingCoefficient.lean @@ -432,7 +432,7 @@ theorem meromorphicTrailingCoeffAt_fun_prod {ι : Type*} {s : Finset ι} {f : ι {x : 𝕜} (h : ∀ σ ∈ s, MeromorphicAt (f σ) x) : meromorphicTrailingCoeffAt (fun z ↦ ∏ n ∈ s, f n z) x = ∏ n ∈ s, meromorphicTrailingCoeffAt (f n) x := by - convert meromorphicTrailingCoeffAt_prod h + convert! meromorphicTrailingCoeffAt_prod h simp /-- @@ -495,7 +495,7 @@ The trailing coefficient of the power of a function is the power of the trailing lemma MeromorphicAt.meromorphicTrailingCoeffAt_pow {n : ℕ} {f : 𝕜 → 𝕜} (h₁ : MeromorphicAt f x) : meromorphicTrailingCoeffAt (f ^ n) x = (meromorphicTrailingCoeffAt f x) ^ n := by - convert h₁.meromorphicTrailingCoeffAt_zpow (n := n) <;> simp + convert! h₁.meromorphicTrailingCoeffAt_zpow (n := n) <;> simp /-- The trailing coefficient of the power of a function is the power of the trailing coefficient. diff --git a/Mathlib/Analysis/Normed/Affine/Isometry.lean b/Mathlib/Analysis/Normed/Affine/Isometry.lean index ec549fa8c0989e..4c7b87b6630837 100644 --- a/Mathlib/Analysis/Normed/Affine/Isometry.lean +++ b/Mathlib/Analysis/Normed/Affine/Isometry.lean @@ -745,7 +745,7 @@ include 𝕜 in is an isometry if `f` is one. -/ theorem vadd_vsub {f : P → P₂} (hf : Isometry f) {p : P} {g : V → V₂} (hg : ∀ v, g v = f (v +ᵥ p) -ᵥ f p) : Isometry g := by - convert (vaddConst 𝕜 (f p)).symm.isometry.comp (hf.comp (vaddConst 𝕜 p).isometry) + convert! (vaddConst 𝕜 (f p)).symm.isometry.comp (hf.comp (vaddConst 𝕜 p).isometry) exact funext hg variable (𝕜) in diff --git a/Mathlib/Analysis/Normed/Affine/Simplex.lean b/Mathlib/Analysis/Normed/Affine/Simplex.lean index ad3c73ffb4f6bd..ea42a187843e1d 100644 --- a/Mathlib/Analysis/Normed/Affine/Simplex.lean +++ b/Mathlib/Analysis/Normed/Affine/Simplex.lean @@ -70,7 +70,7 @@ lemma Scalene.dist_ne {s : Simplex R P n} (hs : s.Scalene) {i₁ i₂ i₃ i₄ by grind, by grind⟩ simp_rw [Scalene] - convert (Injective.of_comp_iff' _ (Equiv.bijective f)).symm + convert! (Injective.of_comp_iff' _ (Equiv.bijective f)).symm #adaptation_note /-- Before https://github.com/leanprover/lean4/pull/13166 (replacing grind's canonicalizer with a type-directed normalizer), `grind` closed this goal. It is not yet clear whether this is due to defeq abuse in Mathlib or a problem in the new @@ -92,8 +92,8 @@ lemma Equilateral.dist_eq {s : Simplex R P n} (he : s.Equilateral) {i₁ i₂ i @[simp] lemma equilateral_reindex_iff {s : Simplex R P m} (e : Fin (m + 1) ≃ Fin (n + 1)) : (s.reindex e).Equilateral ↔ s.Equilateral := by refine ⟨fun ⟨r, hr⟩ ↦ ⟨r, fun i j hij ↦ ?_⟩, fun ⟨r, hr⟩ ↦ ⟨r, fun i j hij ↦ ?_⟩⟩ - · convert hr (e i) (e j) (e.injective.ne hij) using 2 <;> simp - · convert hr (e.symm i) (e.symm j) (e.symm.injective.ne hij) using 2 + · convert! hr (e i) (e j) (e.injective.ne hij) using 2 <;> simp + · convert! hr (e.symm i) (e.symm j) (e.symm.injective.ne hij) using 2 /-- A simplex is regular if it is equivalent under an isometry to any reindexing. -/ def Regular (s : Simplex R P n) : Prop := @@ -120,13 +120,13 @@ lemma Regular.equilateral {s : Simplex R P n} (hr : s.Regular) : s.Equilateral : nth_rw 2 [← x.dist_eq] simp_rw [← Function.comp_apply (f := x), ← hx] simp only [comp_apply, Equiv.swap_apply_left] - convert rfl + convert! rfl rw [Equiv.swap_apply_of_ne_of_ne (by simp [hn]) (by lia)] · rcases hr ((Equiv.swap 0 i).trans (Equiv.swap 1 j)) with ⟨x, hx⟩ nth_rw 2 [← x.dist_eq] simp_rw [← Function.comp_apply (f := x), ← hx] simp only [Equiv.coe_trans, comp_apply, Equiv.swap_apply_left] - convert rfl + convert! rfl · exact Equiv.swap_apply_of_ne_of_ne hi hij · rw [Equiv.swap_apply_of_ne_of_ne (by simp [hn]) (Ne.symm hi)] simp diff --git a/Mathlib/Analysis/Normed/Algebra/Exponential.lean b/Mathlib/Analysis/Normed/Algebra/Exponential.lean index 9bd381749db9eb..68a0c3a11a0f61 100644 --- a/Mathlib/Analysis/Normed/Algebra/Exponential.lean +++ b/Mathlib/Analysis/Normed/Algebra/Exponential.lean @@ -377,7 +377,7 @@ theorem isUnit_exp_of_mem_ball [CharZero 𝕂] {x : 𝔸} theorem invOf_exp_of_mem_ball [CharZero 𝕂] {x : 𝔸} (hx : x ∈ Metric.eball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) [Invertible (exp x)] : ⅟(exp x) = exp (-x) := by - letI := invertibleExpOfMemBall hx; convert (rfl : ⅟(exp x) = _) + letI := invertibleExpOfMemBall hx; convert! (rfl : ⅟(exp x) = _) /-- Any continuous ring homomorphism commutes with `NormedSpace.exp`. -/ theorem map_exp_of_mem_ball [Algebra 𝕂 𝔹] [CharZero 𝕂] {F} [FunLike F 𝔸 𝔹] [RingHomClass F 𝔸 𝔹] diff --git a/Mathlib/Analysis/Normed/Algebra/GelfandFormula.lean b/Mathlib/Analysis/Normed/Algebra/GelfandFormula.lean index 4fb3b14ff21579..f0fa1372fb78e5 100644 --- a/Mathlib/Analysis/Normed/Algebra/GelfandFormula.lean +++ b/Mathlib/Analysis/Normed/Algebra/GelfandFormula.lean @@ -75,7 +75,7 @@ end NonTriviallyNormedField theorem hasDerivAt_resolvent_const_right [NontriviallyNormedField 𝕜] [NontriviallyNormedField A] [NormedAlgebra 𝕜 A] [CompleteSpace A] {a : A} {k : 𝕜} (hk : k ∈ resolventSet 𝕜 a) : HasDerivAt (resolvent · k) (resolvent a k ^ 2) a := by - convert hasFDerivAt_resolvent (𝕜 := A) hk |>.hasDerivAt + convert! hasFDerivAt_resolvent (𝕜 := A) hk |>.hasDerivAt simp [resolvent, pow_two] open ENNReal in @@ -107,7 +107,7 @@ theorem limsup_pow_nnnorm_pow_one_div_le_spectralRadius (a : A) : let p : FormalMultilinearSeries ℂ ℂ A := fun n => ContinuousMultilinearMap.mkPiRing ℂ (Fin n) (a ^ n) suffices h : (r : ℝ≥0∞) ≤ p.radius by - convert h + convert! h simp only [p, p.radius_eq_liminf, ← norm_toNNReal, norm_mkPiRing] congr ext n @@ -133,7 +133,7 @@ instead of `nnnorm`. -/ theorem pow_norm_pow_one_div_tendsto_nhds_spectralRadius (a : A) : Tendsto (fun n : ℕ => ENNReal.ofReal (‖a ^ n‖ ^ (1 / n : ℝ))) atTop (𝓝 (spectralRadius ℂ a)) := by - convert pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius a using 1 + convert! pow_nnnorm_pow_one_div_tendsto_nhds_spectralRadius a using 1 ext1 rw [← ofReal_rpow_of_nonneg (norm_nonneg _) _, ← coe_nnnorm, coe_nnreal_eq] simp diff --git a/Mathlib/Analysis/Normed/Algebra/GelfandMazur.lean b/Mathlib/Analysis/Normed/Algebra/GelfandMazur.lean index 62ccf26cb8650f..a01ba8752906a8 100644 --- a/Mathlib/Analysis/Normed/Algebra/GelfandMazur.lean +++ b/Mathlib/Analysis/Normed/Algebra/GelfandMazur.lean @@ -394,7 +394,7 @@ lemma exists_isMonicOfDegree_two_and_aeval_eq_zero (x : F) : have h' (r : ℝ) : √M ≤ ‖x - algebraMap ℝ F r‖ := by rw [← sq_le_sq₀ M.sqrt_nonneg (norm_nonneg _), Real.sq_sqrt (norm_nonneg _), ← norm_pow, Commute.sub_sq <| algebraMap_eq_smul_one (A := F) r ▸ commute_algebraMap_right r x] - convert isMinOn_univ_iff.mp h (2 * r, r ^ 2) using 4 <;> + convert! isMinOn_univ_iff.mp h (2 * r, r ^ 2) using 4 <;> simp [two_mul, add_mul, ← commutes, smul_def, mul_add] have := tendsto_norm_atTop_iff_cobounded.mpr <| tendsto_φ_cobounded (by positivity) h' simp only [norm_φ_eq_norm_φ_of_isMinOn h (norm_ne_zero_iff.mpr H)] at this diff --git a/Mathlib/Analysis/Normed/Algebra/QuaternionExponential.lean b/Mathlib/Analysis/Normed/Algebra/QuaternionExponential.lean index e2c6cc5a027e3e..a9da2d7116e7fc 100644 --- a/Mathlib/Analysis/Normed/Algebra/QuaternionExponential.lean +++ b/Mathlib/Analysis/Normed/Algebra/QuaternionExponential.lean @@ -87,10 +87,10 @@ theorem hasSum_expSeries_of_imaginary {q : Quaternion ℝ} (hq : q.re = 0) {c s replace hc := hasSum_coe.mpr hc replace hs := (hs.div_const ‖q‖).smul_const q refine HasSum.even_add_odd ?_ ?_ - · convert hc using 1 + · convert! hc using 1 ext n : 1 rw [expSeries_even_of_imaginary hq] - · convert hs using 1 + · convert! hs using 1 ext n : 1 rw [expSeries_odd_of_imaginary hq] diff --git a/Mathlib/Analysis/Normed/Algebra/Spectrum.lean b/Mathlib/Analysis/Normed/Algebra/Spectrum.lean index 7092d45ca1c739..2dfce7ecbc61eb 100644 --- a/Mathlib/Analysis/Normed/Algebra/Spectrum.lean +++ b/Mathlib/Analysis/Normed/Algebra/Spectrum.lean @@ -254,7 +254,7 @@ theorem spectralRadius_le_pow_nnnorm_pow_one_div (a : A) (n : ℕ) : ENNReal.coe_mul] using coe_mono (Real.toNNReal_mono (norm_le_norm_mul_of_mem pow_mem)) -- take (n + 1)ᵗʰ roots and clean up the left-hand side have hn : 0 < ((n + 1 : ℕ) : ℝ) := mod_cast Nat.succ_pos' - convert monotone_rpow_of_nonneg (one_div_pos.mpr hn).le nnnorm_pow_le using 1 + convert! monotone_rpow_of_nonneg (one_div_pos.mpr hn).le nnnorm_pow_le using 1 all_goals dsimp · rw [one_div, pow_rpow_inv_natCast] positivity @@ -389,7 +389,7 @@ theorem exp_mem_exp [RCLike 𝕜] [NormedRing A] [NormedAlgebra 𝕜 A] [Complet simpa only [pow_succ, Algebra.smul_mul_assoc] using hb.tsum_mul_right (a - ↑ₐ z) have h₃ : exp (a - ↑ₐ z) = 1 + (a - ↑ₐ z) * b := by rw [exp_eq_tsum 𝕜] - convert (expSeries_summable' (𝕂 := 𝕜) (a - ↑ₐ z)).tsum_eq_zero_add + convert! (expSeries_summable' (𝕂 := 𝕜) (a - ↑ₐ z)).tsum_eq_zero_add · simp only [Nat.factorial_zero, Nat.cast_one, inv_one, pow_zero, one_smul] · exact h₀.symm rw [spectrum.mem_iff, IsUnit.sub_iff, ← one_mul (↑ₐ (exp z)), hexpmul, ← _root_.sub_mul, @@ -658,7 +658,7 @@ lemma _root_.NNReal.spectralRadius_mem_spectrum {A : Type*} [NormedRing A] [Norm obtain ⟨x, hx₁, hx₂⟩ := spectrum.exists_nnnorm_eq_spectralRadius_of_nonempty ha rw [← hx₂, ENNReal.toNNReal_coe, ← spectrum.algebraMap_mem_iff ℝ, NNReal.algebraMap_eq_coe] have : 0 ≤ x := ha'.rightInvOn hx₁ ▸ NNReal.zero_le_coe - convert hx₁ + convert! hx₁ simpa lemma _root_.Real.spectralRadius_mem_spectrum {A : Type*} [NormedRing A] [NormedAlgebra ℝ A] @@ -733,8 +733,9 @@ theorem upperHemicontinuous_quasispectrum [NontriviallyNormedField 𝕜] [Proper [NonUnitalNormedRing A] [NormedSpace 𝕜 A] [SMulCommClass 𝕜 A A] [IsScalarTower 𝕜 A A] [CompleteSpace A] : UpperHemicontinuous (quasispectrum 𝕜 : A → Set 𝕜) := by - convert upperHemicontinuous_spectrum 𝕜 (WithLp 1 (Unitization 𝕜 A)) |>.comp - unitization_isometry_inr.continuous + convert! + upperHemicontinuous_spectrum 𝕜 (WithLp 1 (Unitization 𝕜 A)) |>.comp + unitization_isometry_inr.continuous ext1 a rw [Unitization.quasispectrum_eq_spectrum_inr, ← AlgEquiv.spectrum_eq (unitizationAlgEquiv 𝕜 (𝕜 := 𝕜) (A := A) |>.symm)] diff --git a/Mathlib/Analysis/Normed/Algebra/UnitizationL1.lean b/Mathlib/Analysis/Normed/Algebra/UnitizationL1.lean index 3bc2a9e12ec42c..eac472266901f4 100644 --- a/Mathlib/Analysis/Normed/Algebra/UnitizationL1.lean +++ b/Mathlib/Analysis/Normed/Algebra/UnitizationL1.lean @@ -51,7 +51,7 @@ noncomputable def uniformEquiv_unitization_addEquiv_prod : WithLp 1 (Unitization 𝕜 A) ≃ᵤ WithLp 1 (𝕜 × A) := { unitization_addEquiv_prod 𝕜 A with uniformContinuous_invFun := uniformContinuous_comap' uniformContinuous_id - uniformContinuous_toFun := uniformContinuous_iff.mpr le_rfl } + uniformContinuous_toFun := uniformContinuous_iff_le_comap.mpr le_rfl } instance instCompleteSpace [CompleteSpace 𝕜] [CompleteSpace A] : CompleteSpace (WithLp 1 (Unitization 𝕜 A)) := diff --git a/Mathlib/Analysis/Normed/Field/Approximation.lean b/Mathlib/Analysis/Normed/Field/Approximation.lean index 97598f2c22f3aa..45800411ce9a60 100644 --- a/Mathlib/Analysis/Normed/Field/Approximation.lean +++ b/Mathlib/Analysis/Normed/Field/Approximation.lean @@ -78,7 +78,7 @@ theorem exists_roots_norm_sub_lt_of_norm_coeff_sub_lt (hε : 0 < ε) {a : K} (ha congr rw [hg.eval_eq_prod_roots_of_monic hgm] _ ≤ ‖g.eval a - f.eval a‖ + ‖f.eval a‖ := by - convert norm_add_le (g.eval a - f.eval a) (f.eval a) + convert! norm_add_le (g.eval a - f.eval a) (f.eval a) simp _ = ‖(∑ i ∈ Finset.range (g.natDegree + 1), C (g.coeff i - f.coeff i) * X ^ i).eval a‖ := by rw [← eval_sub] @@ -96,7 +96,8 @@ theorem exists_roots_norm_sub_lt_of_norm_coeff_sub_lt (hε : 0 < ε) {a : K} (ha -- (fun i ↦ (C (g.coeff i - f.coeff i) * X ^ i).eval a) _ < _ := by rw [hdeg] - convert Finset.sum_lt_sum_of_nonempty (g := fun i ↦ ε * (‖a‖ ⊔ 1) ^ ↑f.natDegree) + convert! + Finset.sum_lt_sum_of_nonempty (g := fun i ↦ ε * (‖a‖ ⊔ 1) ^ ↑f.natDegree) (Finset.nonempty_range_add_one) ?_ · simp [mul_assoc] · simp only [Finset.mem_range, norm_mul, norm_pow] diff --git a/Mathlib/Analysis/Normed/Field/Krasner.lean b/Mathlib/Analysis/Normed/Field/Krasner.lean index 8966dac2e328b4..2054044e2888d8 100644 --- a/Mathlib/Analysis/Normed/Field/Krasner.lean +++ b/Mathlib/Analysis/Normed/Field/Krasner.lean @@ -67,7 +67,7 @@ theorem krasner [Field K] [Algebra K L] IsKrasner.krasner' hx sp hy h variable [NontriviallyNormedField K] [CompleteSpace K] [IsUltrametricDist K] - [NormedAlgebra K L] [Algebra.IsAlgebraic K L] + [NormedAlgebra K L] /-- Krasner's lemma assuming `Normal K L`. -/ theorem of_completeSpace_of_normal [Normal K L] : IsKrasner K L where @@ -114,7 +114,7 @@ If `K` is a complete nontrivially normed field and `L` is an algebraic extension such that the norm of `L` extends the norm on `K`, then `IsKrasner K L` holds. This corresponds to the classical Krasner's lemma. -/ -instance of_completeSpace : IsKrasner K L where +instance of_completeSpace [Algebra.IsAlgebraic K L] : IsKrasner K L where krasner' {x} {y} xsep sp yint kr := by -- Reduce to the case `L = algebraic closure of K` to apply the previous lemma. let C := AlgebraicClosure K diff --git a/Mathlib/Analysis/Normed/Field/ProperSpace.lean b/Mathlib/Analysis/Normed/Field/ProperSpace.lean index ae5e6929671483..22555e6cc03fcc 100644 --- a/Mathlib/Analysis/Normed/Field/ProperSpace.lean +++ b/Mathlib/Analysis/Normed/Field/ProperSpace.lean @@ -41,7 +41,7 @@ lemma ProperSpace.of_nontriviallyNormedField_of_weaklyLocallyCompactSpace rcases NormedField.exists_one_lt_norm 𝕜 with ⟨c, hc⟩ have hC n : IsCompact (closedBall (0 : 𝕜) (‖c‖ ^ n * r)) := by have : c ^ n ≠ 0 := pow_ne_zero _ <| fun h ↦ by simp [h, zero_le_one.not_gt] at hc - convert hr.smul (c ^ n) + convert! hr.smul (c ^ n) ext simp only [mem_closedBall, dist_zero_right, Set.mem_smul_set_iff_inv_smul_mem₀ this, smul_eq_mul, norm_mul, norm_inv, norm_pow, diff --git a/Mathlib/Analysis/Normed/Field/UnitBall.lean b/Mathlib/Analysis/Normed/Field/UnitBall.lean index eb78b31718b9ce..99252ea7420fb0 100644 --- a/Mathlib/Analysis/Normed/Field/UnitBall.lean +++ b/Mathlib/Analysis/Normed/Field/UnitBall.lean @@ -248,7 +248,7 @@ theorem unitSphereToUnits_apply_coe [NormedDivisionRing 𝕜] (x : sphere (0 : theorem unitSphereToUnits_injective [NormedDivisionRing 𝕜] : Function.Injective (unitSphereToUnits 𝕜) := fun x y h => - Subtype.ext <| by convert congr_arg Units.val h + Subtype.ext <| by convert! congr_arg Units.val h instance Metric.unitSphere.instGroup [NormedDivisionRing 𝕜] : Group (sphere (0 : 𝕜) 1) := fast_instance% unitSphereToUnits_injective.group (unitSphereToUnits 𝕜) (Units.ext rfl) diff --git a/Mathlib/Analysis/Normed/Group/Basic.lean b/Mathlib/Analysis/Normed/Group/Basic.lean index a84822245f2c57..31d106e1c1cf32 100644 --- a/Mathlib/Analysis/Normed/Group/Basic.lean +++ b/Mathlib/Analysis/Normed/Group/Basic.lean @@ -352,7 +352,7 @@ theorem NormedGroup.nhds_basis_norm_lt (x : E) : @[to_additive] theorem NormedGroup.nhds_one_basis_norm_lt : (𝓝 (1 : E)).HasBasis (fun ε : ℝ => 0 < ε) fun ε => { y | ‖y‖ < ε } := by - convert NormedGroup.nhds_basis_norm_lt (1 : E) using 1 + convert! NormedGroup.nhds_basis_norm_lt (1 : E) using 1 simp @[deprecated (since := "2026-02-17")] @@ -364,7 +364,7 @@ alias NormedAddCommGroup.nhds_zero_basis_norm_lt := NormedAddGroup.nhds_zero_bas @[to_additive] theorem NormedGroup.uniformity_basis_dist : (𝓤 E).HasBasis (fun ε : ℝ => 0 < ε) fun ε => { p : E × E | ‖p.fst⁻¹ * p.snd‖ < ε } := by - convert Metric.uniformity_basis_dist (α := E) using 1 + convert! Metric.uniformity_basis_dist (α := E) using 1 simp [dist_eq_norm_inv_mul] open Finset @@ -393,8 +393,11 @@ theorem norm_toNNReal' : ‖a‖.toNNReal = ‖a‖₊ := lemma toReal_enorm' (x : E) : ‖x‖ₑ.toReal = ‖x‖ := by simp [enorm] @[to_additive (attr := simp) ofReal_norm] -lemma ofReal_norm' (x : E) : .ofReal ‖x‖ = ‖x‖ₑ := by - simp [enorm, ENNReal.ofReal, Real.toNNReal, nnnorm] +lemma ofReal_norm' (x : E) : .ofReal ‖x‖ = ‖x‖ₑ := ENNReal.ofReal_eq_coe_nnreal _ + +@[deprecated (since := "2026-05-25")] alias ofReal_norm_eq_enorm := ofReal_norm + +@[deprecated (since := "2026-05-25")] alias ofReal_norm_eq_enorm' := ofReal_norm' @[to_additive enorm_eq_iff_norm_eq] theorem enorm'_eq_iff_norm_eq {x : E} {y : F} : ‖x‖ₑ = ‖y‖ₑ ↔ ‖x‖ = ‖y‖ := by @@ -621,12 +624,9 @@ lemma exists_enorm_lt' (E : Type*) [TopologicalSpace E] [ESeminormedMonoid E] @[to_additive (attr := simp) enorm_neg] lemma enorm_inv' (a : E) : ‖a⁻¹‖ₑ = ‖a‖ₑ := by simp [enorm] -@[to_additive ofReal_norm_eq_enorm] -lemma ofReal_norm_eq_enorm' (a : E) : .ofReal ‖a‖ = ‖a‖ₑ := ENNReal.ofReal_eq_coe_nnreal _ - @[to_additive] theorem edist_eq_enorm_inv_mul (a b : E) : edist a b = ‖a⁻¹ * b‖ₑ := by - rw [edist_dist, dist_eq_norm_inv_mul, ofReal_norm_eq_enorm'] + rw [edist_dist, dist_eq_norm_inv_mul, ofReal_norm'] @[deprecated (since := "2026-02-11")] alias edist_one_eq_enorm := edist_one_right @@ -794,7 +794,7 @@ alias nndist_eq_nnnorm := nndist_eq_nnnorm_sub @[to_additive] theorem edist_eq_enorm_div (a b : E) : edist a b = ‖a / b‖ₑ := by - rw [edist_dist, dist_eq_norm_div, ofReal_norm_eq_enorm'] + rw [edist_dist, dist_eq_norm_div, ofReal_norm'] @[to_additive] theorem dist_inv (x y : E) : dist x⁻¹ y = dist x y⁻¹ := by diff --git a/Mathlib/Analysis/Normed/Group/Defs.lean b/Mathlib/Analysis/Normed/Group/Defs.lean index 6e2caaeb22d910..986529b3cc34e4 100644 --- a/Mathlib/Analysis/Normed/Group/Defs.lean +++ b/Mathlib/Analysis/Normed/Group/Defs.lean @@ -410,8 +410,8 @@ abbrev GroupSeminorm.toSeminormedGroup [Group E] (f : GroupSeminorm E) : Seminor norm := f dist_eq _ _ := rfl dist_self x := by simp only [inv_mul_cancel, map_one_eq_zero] - dist_triangle x y z := by convert map_mul_le_add f (x⁻¹ * y) (y⁻¹ * z) using 2; group - dist_comm x y := by convert map_inv_eq_map f (y⁻¹ * x) using 2; group + dist_triangle x y z := by convert! map_mul_le_add f (x⁻¹ * y) (y⁻¹ * z) using 2; group + dist_comm x y := by convert! map_inv_eq_map f (y⁻¹ * x) using 2; group -- See note [reducible non-instances] /-- Construct a seminormed group from a seminorm, i.e., registering the pseudodistance and the diff --git a/Mathlib/Analysis/Normed/Group/Pointwise.lean b/Mathlib/Analysis/Normed/Group/Pointwise.lean index 3df8055aeac512..2bcb46700978cd 100644 --- a/Mathlib/Analysis/Normed/Group/Pointwise.lean +++ b/Mathlib/Analysis/Normed/Group/Pointwise.lean @@ -179,7 +179,7 @@ theorem smul_closedBall_one : x • closedBall (1 : E) δ = closedBall x δ := b @[to_additive] theorem mul_ball_one : s * ball 1 δ = thickening δ s := by rw [thickening_eq_biUnion_ball] - convert iUnion₂_mul (fun x (_ : x ∈ s) => {x}) (ball (1 : E) δ) + convert! iUnion₂_mul (fun x (_ : x ∈ s) => { x }) (ball (1 : E) δ) · exact s.biUnion_of_singleton.symm ext x simp_rw [singleton_mul_ball, mul_one] diff --git a/Mathlib/Analysis/Normed/Group/Real.lean b/Mathlib/Analysis/Normed/Group/Real.lean index 859e6e82e23086..fb729daff80fc0 100644 --- a/Mathlib/Analysis/Normed/Group/Real.lean +++ b/Mathlib/Analysis/Normed/Group/Real.lean @@ -102,7 +102,7 @@ lemma enorm_ofReal_of_nonneg {a : ℝ} (ha : 0 ≤ a) : ‖ENNReal.ofReal a‖ @[simp] lemma enorm_abs (r : ℝ) : ‖|r|‖ₑ = ‖r‖ₑ := by simp [enorm] theorem enorm_eq_ofReal (hr : 0 ≤ r) : ‖r‖ₑ = .ofReal r := by - rw [← ofReal_norm_eq_enorm, norm_of_nonneg hr] + rw [← ofReal_norm, norm_of_nonneg hr] theorem enorm_eq_ofReal_abs (r : ℝ) : ‖r‖ₑ = ENNReal.ofReal |r| := by rw [← enorm_eq_ofReal (abs_nonneg _), enorm_abs] diff --git a/Mathlib/Analysis/Normed/Group/SemiNormedGrp/Kernels.lean b/Mathlib/Analysis/Normed/Group/SemiNormedGrp/Kernels.lean index c51708fdf40500..4366f50ec0c35c 100644 --- a/Mathlib/Analysis/Normed/Group/SemiNormedGrp/Kernels.lean +++ b/Mathlib/Analysis/Normed/Group/SemiNormedGrp/Kernels.lean @@ -193,7 +193,7 @@ set_option backward.isDefEq.respectTransparency false in @[reassoc (attr := simp)] theorem comp_explicitCokernelπ {X Y : SemiNormedGrp.{u}} (f : X ⟶ Y) : f ≫ explicitCokernelπ f = 0 := by - convert (cokernelCocone f).w WalkingParallelPairHom.left + convert! (cokernelCocone f).w WalkingParallelPairHom.left simp @[simp] @@ -216,7 +216,7 @@ theorem explicitCokernelDesc_unique {X Y Z : SemiNormedGrp.{u}} {f : X ⟶ Y} {g e = explicitCokernelDesc w := by apply (isColimitCokernelCocone f).uniq (Cofork.ofπ g (by simp [w])) rintro (_ | _) - · convert w.symm + · convert! w.symm simp · exact he diff --git a/Mathlib/Analysis/Normed/Group/Ultra.lean b/Mathlib/Analysis/Normed/Group/Ultra.lean index 69447066f6860d..ce6c8c8133b2cc 100644 --- a/Mathlib/Analysis/Normed/Group/Ultra.lean +++ b/Mathlib/Analysis/Normed/Group/Ultra.lean @@ -61,7 +61,7 @@ lemma isUltrametricDist_of_isNonarchimedean_norm {S' : Type*} [SeminormedAddGrou lemma isNonarchimedean_norm {R} [SeminormedAddCommGroup R] [IsUltrametricDist R] : IsNonarchimedean (‖·‖ : R → ℝ) := by intro x y - convert dist_triangle_max 0 x (x + y) using 1 + convert! dist_triangle_max 0 x (x + y) using 1 · simp · congr <;> simp [SeminormedAddGroup.dist_eq] diff --git a/Mathlib/Analysis/Normed/Lp/PiLp.lean b/Mathlib/Analysis/Normed/Lp/PiLp.lean index 99a53333c347a5..d02183e9069d89 100644 --- a/Mathlib/Analysis/Normed/Lp/PiLp.lean +++ b/Mathlib/Analysis/Normed/Lp/PiLp.lean @@ -1140,8 +1140,6 @@ variable [Semiring 𝕜] [∀ i, SeminormedAddCommGroup (β i)] [∀ i, Module @[simps! apply symm_apply] def continuousLinearEquiv : PiLp p β ≃L[𝕜] ∀ i, β i where toLinearEquiv := WithLp.linearEquiv _ _ _ - continuous_toFun := continuous_ofLp _ _ - continuous_invFun := continuous_toLp p _ lemma coe_continuousLinearEquiv : ⇑(PiLp.continuousLinearEquiv p 𝕜 β) = ofLp := rfl diff --git a/Mathlib/Analysis/Normed/Lp/ProdLp.lean b/Mathlib/Analysis/Normed/Lp/ProdLp.lean index c7940af3390717..42446607269ab1 100644 --- a/Mathlib/Analysis/Normed/Lp/ProdLp.lean +++ b/Mathlib/Analysis/Normed/Lp/ProdLp.lean @@ -184,7 +184,7 @@ variable {p α β} theorem prod_edist_eq_card (f g : WithLp 0 (α × β)) : edist f g = (if edist f.fst g.fst = 0 then 0 else 1) + (if edist f.snd g.snd = 0 then 0 else 1) := by - convert if_pos rfl + convert! if_pos rfl theorem prod_edist_eq_add (hp : 0 < p.toReal) (f g : WithLp p (α × β)) : edist f g = (edist f.fst g.fst ^ p.toReal + edist f.snd g.snd ^ p.toReal) ^ (1 / p.toReal) := @@ -251,7 +251,7 @@ variable {p α β} theorem prod_dist_eq_card (f g : WithLp 0 (α × β)) : dist f g = (if dist f.fst g.fst = 0 then 0 else 1) + (if dist f.snd g.snd = 0 then 0 else 1) := by - convert if_pos rfl + convert! if_pos rfl theorem prod_dist_eq_add (hp : 0 < p.toReal) (f g : WithLp p (α × β)) : dist f g = (dist f.fst g.fst ^ p.toReal + dist f.snd g.snd ^ p.toReal) ^ (1 / p.toReal) := @@ -288,7 +288,7 @@ variable {p α β} @[simp] theorem prod_norm_eq_card (f : WithLp 0 (α × β)) : ‖f‖ = (if ‖f.fst‖ = 0 then 0 else 1) + (if ‖f.snd‖ = 0 then 0 else 1) := by - convert if_pos rfl + convert! if_pos rfl theorem prod_norm_eq_sup (f : WithLp ∞ (α × β)) : ‖f‖ = ‖f.fst‖ ⊔ ‖f.snd‖ := rfl diff --git a/Mathlib/Analysis/Normed/Lp/SmoothApprox.lean b/Mathlib/Analysis/Normed/Lp/SmoothApprox.lean index 2fb2ad44aaaf50..aea9b538161c8f 100644 --- a/Mathlib/Analysis/Normed/Lp/SmoothApprox.lean +++ b/Mathlib/Analysis/Normed/Lp/SmoothApprox.lean @@ -105,7 +105,7 @@ theorem _root_.MeasureTheory.Lp.dense_hasCompactSupport_contDiff {p : ℝ≥0∞ use ⟨g, hg₄.coeFn_toLp, hg₁, hg₂⟩ rw [Metric.mem_closedBall, dist_comm, Lp.dist_def, ← le_ofReal_iff_toReal_le ((Lp.memLp f).sub (Lp.memLp hg₄.toLp)).eLpNorm_ne_top hε.le] - convert hg₃ using 1 + convert! hg₃ using 1 apply eLpNorm_congr_ae gcongr exact hg₄.coeFn_toLp diff --git a/Mathlib/Analysis/Normed/Lp/lpSpace.lean b/Mathlib/Analysis/Normed/Lp/lpSpace.lean index b3c6728b62dee5..515909235bb8db 100644 --- a/Mathlib/Analysis/Normed/Lp/lpSpace.lean +++ b/Mathlib/Analysis/Normed/Lp/lpSpace.lean @@ -587,7 +587,7 @@ theorem norm_apply_le_norm (hp : p ≠ 0) (f : lp E p) (i : α) : ‖f i‖ ≤ have hp'' : 0 < p.toReal := ENNReal.toReal_pos hp hp' have : ∀ i, 0 ≤ ‖f i‖ ^ p.toReal := fun i ↦ by positivity rw [← Real.rpow_le_rpow_iff (norm_nonneg _) (norm_nonneg' _) hp''] - convert le_hasSum (hasSum_norm hp'' f) i fun i _ => this i + convert! le_hasSum (hasSum_norm hp'' f) i fun i _ => this i lemma lipschitzWith_one_eval (p : ℝ≥0∞) [Fact (1 ≤ p)] (i : α) : LipschitzWith 1 (fun x : lp E p ↦ x i) := diff --git a/Mathlib/Analysis/Normed/Module/Alternating/Basic.lean b/Mathlib/Analysis/Normed/Module/Alternating/Basic.lean index 363541833fd6b1..b66cdf9d425823 100644 --- a/Mathlib/Analysis/Normed/Module/Alternating/Basic.lean +++ b/Mathlib/Analysis/Normed/Module/Alternating/Basic.lean @@ -470,7 +470,7 @@ def fderivCompContinuousLinearMap (f : F [⋀^ι]→L[𝕜] G) (g : E →L[𝕜] trans ∑ i, f fun j ↦ Function.update (fun _ ↦ g) i dg j (v j) · simp · rw [← Finset.sum_add_sum_compl {a, b}, Finset.sum_pair hne, Finset.sum_eq_zero, add_zero] - · convert f.map_add_swap _ hne with i + · convert! f.map_add_swap _ hne with i rcases eq_or_ne i a with rfl | hia · simp [heq, hne, hne.symm] · rcases eq_or_ne i b with rfl | hib diff --git a/Mathlib/Analysis/Normed/Module/Connected.lean b/Mathlib/Analysis/Normed/Module/Connected.lean index 85ed8cf12cd5e9..d6856e77058738 100644 --- a/Mathlib/Analysis/Normed/Module/Connected.lean +++ b/Mathlib/Analysis/Normed/Module/Connected.lean @@ -91,7 +91,7 @@ theorem Set.Countable.isPathConnected_compl_of_one_lt_rank rw [sub_eq_add_neg _ x] apply Eq.subset apply segment_inter_eq_endpoint_of_linearIndependent_of_ne _ htt'.symm - convert hy.units_smul ![-1, 1] + convert! hy.units_smul ![-1, 1] simp [← List.ofFn_inj] obtain ⟨t, ht⟩ : Set.Nonempty ({t : ℝ | ([c + x -[ℝ] c + t • y] ∩ s).Nonempty} ∪ {t : ℝ | ([c - x -[ℝ] c + t • y] ∩ s).Nonempty})ᶜ := ((A.union B).dense_compl ℝ).nonempty @@ -101,12 +101,12 @@ theorem Set.Countable.isPathConnected_compl_of_one_lt_rank have JA : JoinedIn sᶜ a z := by apply JoinedIn.of_segment_subset rw [subset_compl_iff_disjoint_right, disjoint_iff_inter_eq_empty] - convert ht.2 + convert! ht.2 exact Ia.symm have JB : JoinedIn sᶜ b z := by apply JoinedIn.of_segment_subset rw [subset_compl_iff_disjoint_right, disjoint_iff_inter_eq_empty] - convert ht.1 + convert! ht.1 exact Ib.symm exact JA.trans JB.symm diff --git a/Mathlib/Analysis/Normed/Module/FiniteDimension.lean b/Mathlib/Analysis/Normed/Module/FiniteDimension.lean index 70ba4db566859a..b2e12ce3545649 100644 --- a/Mathlib/Analysis/Normed/Module/FiniteDimension.lean +++ b/Mathlib/Analysis/Normed/Module/FiniteDimension.lean @@ -266,9 +266,6 @@ where `ι` is a finite type. -/ def ContinuousLinearEquiv.piRing (ι : Type*) [Fintype ι] [DecidableEq ι] : ((ι → 𝕜) →L[𝕜] E) ≃L[𝕜] ι → E := { LinearMap.toContinuousLinearMap.symm.trans (LinearEquiv.piRing 𝕜 E ι 𝕜) with - continuous_toFun := by - refine continuous_pi fun i ↦ ?_ - exact (apply 𝕜 E (Pi.single i 1)).continuous continuous_invFun := by simp_rw [LinearEquiv.invFun_eq_symm, LinearEquiv.trans_symm, LinearEquiv.symm_symm] refine AddMonoidHomClass.continuous_of_bound @@ -644,8 +641,10 @@ theorem summable_norm_mul_geometric_of_norm_lt_one' {F : Type*} [NormedRing F] simpa [Nat.cast_pow] using (isBigO_norm_left.mpr (isBigO_norm_right.mpr hu)).mul (isBigO_refl (fun n ↦ (‖r‖ ^ n)) atTop) _ =O[atTop] fun n ↦ ‖r' ^ n‖ := by - convert isBigO_norm_right.mpr (isBigO_norm_left.mpr - (isLittleO_pow_const_mul_const_pow_const_pow_of_norm_lt k hrr').isBigO) + convert! + isBigO_norm_right.mpr + (isBigO_norm_left.mpr + (isLittleO_pow_const_mul_const_pow_const_pow_of_norm_lt k hrr').isBigO) simp only [norm_pow, norm_mul] theorem summable_of_isEquivalent {ι E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] diff --git a/Mathlib/Analysis/Normed/Module/MStructure.lean b/Mathlib/Analysis/Normed/Module/MStructure.lean index a07d3c7f5337d2..7550374313cde0 100644 --- a/Mathlib/Analysis/Normed/Module/MStructure.lean +++ b/Mathlib/Analysis/Normed/Module/MStructure.lean @@ -155,7 +155,7 @@ theorem mul [FaithfulSMul M X] {P Q : M} (h₁ : IsLprojection X P) (h₂ : IsLp theorem join [FaithfulSMul M X] {P Q : M} (h₁ : IsLprojection X P) (h₂ : IsLprojection X Q) : IsLprojection X (P + Q - P * Q) := by - convert (Lcomplement_iff _).mp (h₁.Lcomplement.mul h₂.Lcomplement) using 1 + convert! (Lcomplement_iff _).mp (h₁.Lcomplement.mul h₂.Lcomplement) using 1 noncomm_ring instance Subtype.instCompl : Compl { f : M // IsLprojection X f } := @@ -196,7 +196,7 @@ instance Subtype.partialOrder [FaithfulSMul M X] : le_trans P Q R h₁ h₂ := by simp only [coe_inf] at h₁ h₂ ⊢ rw [h₁, mul_assoc, ← h₂] - le_antisymm P Q h₁ h₂ := Subtype.ext (by convert (P.prop.commute Q.prop).eq) + le_antisymm P Q h₁ h₂ := Subtype.ext (by convert! (P.prop.commute Q.prop).eq) theorem le_def [FaithfulSMul M X] (P Q : { P : M // IsLprojection X P }) : P ≤ Q ↔ (P : M) = ↑(P ⊓ Q) := diff --git a/Mathlib/Analysis/Normed/Module/Multilinear/Basic.lean b/Mathlib/Analysis/Normed/Module/Multilinear/Basic.lean index d9d2341dcdbd71..d4eeb3d24b5df3 100644 --- a/Mathlib/Analysis/Normed/Module/Multilinear/Basic.lean +++ b/Mathlib/Analysis/Normed/Module/Multilinear/Basic.lean @@ -240,7 +240,7 @@ theorem norm_image_sub_le_of_bound' [DecidableEq ι] (f : MultilinearMap 𝕜 E (add_le_add Hrec I) _ = C * ∑ i ∈ insert i s, ∏ j, if j = i then ‖m₁ i - m₂ i‖ else max ‖m₁ j‖ ‖m₂ j‖ := by simp [his, add_comm, left_distrib] - convert A univ + convert! A univ simp /-- If `f` satisfies a boundedness property around `0`, one can deduce a bound on `f m₁ - f m₂` @@ -313,11 +313,11 @@ theorem restr_norm_le {k n : ℕ} (f : MultilinearMap 𝕜 (fun _ : Fin n => G) (s : Finset (Fin n)) (hk : #s = k) (z : G) {C : ℝ} (H : ∀ m, ‖f m‖ ≤ C * ∏ i, ‖m i‖) (v : Fin k → G) : ‖f.restr s hk z v‖ ≤ C * ‖z‖ ^ (n - k) * ∏ i, ‖v i‖ := by rw [mul_right_comm, mul_assoc] - convert H _ using 2 + convert! H _ using 2 simp only [apply_dite norm, Fintype.prod_dite, prod_const ‖z‖, Finset.card_univ, Fintype.card_of_subtype sᶜ fun _ => mem_compl, card_compl, Fintype.card_fin, hk, ← (s.orderIsoOfFin hk).symm.bijective.prod_comp fun x => ‖v x‖] - convert rfl + convert! rfl end MultilinearMap @@ -718,7 +718,7 @@ theorem norm_mkPiAlgebra_of_empty [IsEmpty ι] : ‖ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A‖ = ‖(1 : A)‖ := by apply le_antisymm · apply opNorm_le_bound <;> simp - · convert ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A) fun _ => 1 + · convert! ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A) fun _ => 1 simp @[simp] @@ -726,7 +726,7 @@ theorem norm_mkPiAlgebra [NormOneClass A] : ‖ContinuousMultilinearMap.mkPiAlge cases isEmpty_or_nonempty ι · simp [norm_mkPiAlgebra_of_empty] · refine le_antisymm norm_mkPiAlgebra_le ?_ - convert ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A) fun _ => 1 + convert! ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebra 𝕜 ι A) fun _ => 1 simp end @@ -753,7 +753,7 @@ theorem norm_mkPiAlgebraFin_zero : ‖ContinuousMultilinearMap.mkPiAlgebraFin refine le_antisymm ?_ ?_ · refine opNorm_le_bound (norm_nonneg (1 : A)) ?_ simp - · convert ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 0 A) fun _ => (1 : A) + · convert! ratio_le_opNorm (ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 0 A) fun _ => (1 : A) simp theorem norm_mkPiAlgebraFin_le : @@ -1072,13 +1072,13 @@ def compContinuousLinearMapLRight (g : ContinuousMultilinearMap 𝕜 E₁ G) : intro h f i f₁ f₂ ext x simp only [compContinuousLinearMap_apply, add_apply] - convert g.map_update_add (fun j ↦ f j (x j)) i (f₁ (x i)) (f₂ (x i)) <;> + convert! g.map_update_add (fun j ↦ f j (x j)) i (f₁ (x i)) (f₂ (x i)) <;> exact apply_update (fun (i : ι) (f : E i →L[𝕜] E₁ i) ↦ f (x i)) f i _ _ map_update_smul' := by intro h f i a f₀ ext x simp only [compContinuousLinearMap_apply, smul_apply] - convert g.map_update_smul (fun j ↦ f j (x j)) i a (f₀ (x i)) <;> + convert! g.map_update_smul (fun j ↦ f j (x j)) i a (f₀ (x i)) <;> exact apply_update (fun (i : ι) (f : E i →L[𝕜] E₁ i) ↦ f (x i)) f i _ _ } (‖g‖) (fun f ↦ by simp [norm_compContinuousLinearMap_le]) @@ -1107,12 +1107,12 @@ noncomputable def compContinuousLinearMapMultilinear : ext g x change (g fun j ↦ update f i (f₁ + f₂) j <| x j) = (g fun j ↦ update f i f₁ j <| x j) + g fun j ↦ update f i f₂ j (x j) - convert g.map_update_add (fun j ↦ f j (x j)) i (f₁ (x i)) (f₂ (x i)) <;> + convert! g.map_update_add (fun j ↦ f j (x j)) i (f₁ (x i)) (f₂ (x i)) <;> exact apply_update (fun (i : ι) (f : E i →L[𝕜] E₁ i) ↦ f (x i)) f i _ _ map_update_smul' f i a f₀ := by ext g x change (g fun j ↦ update f i (a • f₀) j <| x j) = a • g fun j ↦ update f i f₀ j (x j) - convert g.map_update_smul (fun j ↦ f j (x j)) i a (f₀ (x i)) <;> + convert! g.map_update_smul (fun j ↦ f j (x j)) i a (f₀ (x i)) <;> exact apply_update (fun (i : ι) (f : E i →L[𝕜] E₁ i) ↦ f (x i)) f i _ _ /-- If `f` is a collection of continuous linear maps, then the construction diff --git a/Mathlib/Analysis/Normed/Module/MultipliableUniformlyOn.lean b/Mathlib/Analysis/Normed/Module/MultipliableUniformlyOn.lean index 2151c22bcd0467..2f96bba86fc9c1 100644 --- a/Mathlib/Analysis/Normed/Module/MultipliableUniformlyOn.lean +++ b/Mathlib/Analysis/Normed/Module/MultipliableUniformlyOn.lean @@ -99,7 +99,7 @@ lemma hasProdUniformlyOn_one_add (hK : IsCompact K) (hu : Summable u) filter_upwards [h] with i hi using fun x ↦ hi x x.2 have hM : Multipliable fun i ↦ 1 + f' i := multipliable_one_add_of_summable (hu.of_norm_bounded_eventually (by simpa using hf'_bd)) - convert ContinuousMap.tendsto_iff_tendstoUniformly.mp hM.hasProd + convert! ContinuousMap.tendsto_iff_tendstoUniformly.mp hM.hasProd · simp [f'] · exact funext fun k ↦ ContinuousMap.tprod_apply hM k diff --git a/Mathlib/Analysis/Normed/Module/PiTensorProduct/ProjectiveSeminorm.lean b/Mathlib/Analysis/Normed/Module/PiTensorProduct/ProjectiveSeminorm.lean index 08275090fd53ad..b2319ec8628f80 100644 --- a/Mathlib/Analysis/Normed/Module/PiTensorProduct/ProjectiveSeminorm.lean +++ b/Mathlib/Analysis/Normed/Module/PiTensorProduct/ProjectiveSeminorm.lean @@ -114,7 +114,7 @@ theorem projectiveSeminorm_apply (x : ⨂[𝕜] i, E i) : theorem projectiveSeminorm_tprod_le (m : Π i, E i) : projectiveSeminorm (⨂ₜ[𝕜] i, m i) ≤ ∏ i, ‖m i‖ := by - convert ciInf_le (bddBelow_projectiveSemiNormAux _) ⟨FreeAddMonoid.of ((1 : 𝕜), m), ?_⟩ + convert! ciInf_le (bddBelow_projectiveSemiNormAux _) ⟨FreeAddMonoid.of ((1 : 𝕜), m), ?_⟩ · simp [projectiveSeminormAux] · simp [mem_lifts_iff] diff --git a/Mathlib/Analysis/Normed/Module/RCLike/Real.lean b/Mathlib/Analysis/Normed/Module/RCLike/Real.lean index 3009146f78351a..e09623c37462a6 100644 --- a/Mathlib/Analysis/Normed/Module/RCLike/Real.lean +++ b/Mathlib/Analysis/Normed/Module/RCLike/Real.lean @@ -59,7 +59,7 @@ theorem dist_smul_add_one_sub_smul_le {r : ℝ} {x y : E} (h : r ∈ Icc 0 1) : theorem closure_ball (x : E) {r : ℝ} (hr : r ≠ 0) : closure (ball x r) = closedBall x r := by refine Subset.antisymm closure_ball_subset_closedBall fun y hy => ?_ have : ContinuousWithinAt (fun c : ℝ => c • (y - x) + x) (Ico 0 1) 1 := by fun_prop - convert this.mem_closure _ _ + convert! this.mem_closure _ _ · rw [one_smul, sub_add_cancel] · simp [closure_Ico zero_ne_one, zero_le_one] · rintro c ⟨hc0, hc1⟩ diff --git a/Mathlib/Analysis/Normed/Module/WeakDual.lean b/Mathlib/Analysis/Normed/Module/WeakDual.lean index e87a1ab65cb66b..857a24373b9937 100644 --- a/Mathlib/Analysis/Normed/Module/WeakDual.lean +++ b/Mathlib/Analysis/Normed/Module/WeakDual.lean @@ -172,7 +172,7 @@ def continuousLinearMapToWeakDual : StrongDual 𝕜 E →L[𝕜] WeakDual 𝕜 E theorem dual_norm_topology_le_weak_dual_topology : (UniformSpace.toTopologicalSpace : TopologicalSpace (StrongDual 𝕜 E)) ≤ (instTopologicalSpaceWeakDual .. : TopologicalSpace (WeakDual 𝕜 E)) := by - convert (@toWeakDual_continuous _ _ _ _ (by assumption)).le_induced + convert! (@toWeakDual_continuous _ _ _ _ (by assumption)).le_induced exact induced_id.symm end Dual diff --git a/Mathlib/Analysis/Normed/Operator/Banach.lean b/Mathlib/Analysis/Normed/Operator/Banach.lean index 9af071be0edbf7..c8246b741c8091 100644 --- a/Mathlib/Analysis/Normed/Operator/Banach.lean +++ b/Mathlib/Analysis/Normed/Operator/Banach.lean @@ -414,7 +414,7 @@ noncomputable def leftInverse_of_injective_of_isClosed_range rintro ⟨y, x, rfl⟩ have aux := hfK.le_mul_dist x 0 simp only [dist_zero_right, map_zero] at aux - convert aux + convert! aux exact f.rangeRestrict.leftInverse_apply_of_inj (by rw [ker_codRestrict]; exact LinearMap.ker_eq_bot.mpr hf) x) diff --git a/Mathlib/Analysis/Normed/Operator/BoundedLinearMaps.lean b/Mathlib/Analysis/Normed/Operator/BoundedLinearMaps.lean index a44502c3cae6be..7607b3481dc65f 100644 --- a/Mathlib/Analysis/Normed/Operator/BoundedLinearMaps.lean +++ b/Mathlib/Analysis/Normed/Operator/BoundedLinearMaps.lean @@ -542,7 +542,7 @@ protected theorem isOpen [CompleteSpace E] : IsOpen (range ((↑) : (E ≃L[𝕜 refine fun e => IsOpen.mem_nhds ?_ (mem_range_self _) let O : (E →L[𝕜] F) → E →L[𝕜] E := fun f => (e.symm : F →L[𝕜] E).comp f have h_O : Continuous O := (isBoundedBilinearMap_comp (𝕜 := 𝕜) (F := F) (G := E)).continuous_right - convert show IsOpen (O ⁻¹' { x | IsUnit x }) from Units.isOpen.preimage h_O using 1 + convert! show IsOpen (O ⁻¹' {x | IsUnit x}) from Units.isOpen.preimage h_O using 1 ext f' constructor · rintro ⟨e', rfl⟩ diff --git a/Mathlib/Analysis/Normed/Operator/Compact/Basic.lean b/Mathlib/Analysis/Normed/Operator/Compact/Basic.lean index 3b752e92f3ca67..5d56fbdd627983 100644 --- a/Mathlib/Analysis/Normed/Operator/Compact/Basic.lean +++ b/Mathlib/Analysis/Normed/Operator/Compact/Basic.lean @@ -445,7 +445,7 @@ theorem isClosed_setOf_isCompactOperator {𝕜₁ 𝕜₂ : Type*} [Nontrivially rcases hTv with ⟨t, ht, htx⟩ refine ⟨t, ht, ?_⟩ rw [mem_preimage, mem_vadd_set_iff_neg_vadd_mem, vadd_eq_add, neg_add_eq_sub] at htx ⊢ - convert hVU _ htx _ (huv x hx) using 1 + convert! hVU _ htx _ (huv x hx) using 1 rw [ContinuousLinearMap.sub_apply] abel diff --git a/Mathlib/Analysis/Normed/Operator/Compact/FredholmAlternative.lean b/Mathlib/Analysis/Normed/Operator/Compact/FredholmAlternative.lean index 20d58f09b39d7f..6f8d04b6f65c5b 100644 --- a/Mathlib/Analysis/Normed/Operator/Compact/FredholmAlternative.lean +++ b/Mathlib/Analysis/Normed/Operator/Compact/FredholmAlternative.lean @@ -173,7 +173,7 @@ theorem hasEigenvalue_or_mem_resolventSet (hT : IsCompactOperator T) (hμ : μ replace h₂ : ¬ (S : X → X).Bijective := by rw [spectrum.mem_resolventSet_iff, ← IsUnit.neg_iff, ContinuousLinearMap.isUnit_iff_bijective] at h₂ - convert h₂ + convert! h₂ ext x simp [S] replace h₂ : ¬ (S : X → X).Surjective := by grind [Function.Bijective, hK.injective] diff --git a/Mathlib/Analysis/Normed/Operator/Extend.lean b/Mathlib/Analysis/Normed/Operator/Extend.lean index 80fc7a52ef3152..e44677a95ff1ab 100644 --- a/Mathlib/Analysis/Normed/Operator/Extend.lean +++ b/Mathlib/Analysis/Normed/Operator/Extend.lean @@ -195,7 +195,7 @@ theorem extendOfNorm_eq (h_dense : DenseRange e) (h_norm : ∃ C, ∀ x, ‖f x (x : E) : f.extendOfNorm e (e x) = f x := by have := (f.compLeftInverse e).extend_eq (e := (LinearMap.range e).subtypeL) (by simpa using h_dense) isUniformEmbedding_subtype_val.isUniformInducing - convert this ⟨e x, LinearMap.mem_range_self e x⟩ + convert! this ⟨e x, LinearMap.mem_range_self e x⟩ exact (compLeftInverse_apply_of_bdd _ _ h_norm _ _ rfl).symm theorem norm_extendOfNorm_apply_le (h_dense : DenseRange e) (C : ℝ) @@ -327,7 +327,7 @@ def extendOfIsometry (h_dense₁ : DenseRange e₁) (h_dense₂ : DenseRange e refine h_dense₁.induction ?_ (isClosed_eq (by simp only [ContinuousLinearEquiv.coe_toLinearEquiv]; fun_prop) continuous_norm) rintro x ⟨y, rfl⟩ - convert h_norm y + convert! h_norm y apply LinearMap.extendOfNorm_eq h_dense₁ (by use 1; simp [h_norm]) } theorem extendOfIsometry_apply (h_dense₁ : DenseRange e₁) (h_dense₂ : DenseRange e₂) diff --git a/Mathlib/Analysis/Normed/Operator/Mul.lean b/Mathlib/Analysis/Normed/Operator/Mul.lean index 34bda47df590c5..faae470656da15 100644 --- a/Mathlib/Analysis/Normed/Operator/Mul.lean +++ b/Mathlib/Analysis/Normed/Operator/Mul.lean @@ -112,7 +112,7 @@ instance _root_.NormedAlgebra.instRegularNormedAlgebra {𝕜 R : Type*} [Nontriv [SeminormedRing R] [NormedAlgebra 𝕜 R] [NormOneClass R] : RegularNormedAlgebra 𝕜 R where isometry_mul' := AddMonoidHomClass.isometry_of_norm (mul 𝕜 R) <| fun x => le_antisymm (opNorm_mul_apply_le _ _ _) <| by - convert ratio_le_opNorm ((mul 𝕜 R) x) (1 : R) + convert! ratio_le_opNorm ((mul 𝕜 R) x) (1 : R) simp [norm_one] variable [RegularNormedAlgebra 𝕜 R] diff --git a/Mathlib/Analysis/Normed/Operator/NormedSpace.lean b/Mathlib/Analysis/Normed/Operator/NormedSpace.lean index 560ac9585c1feb..0178cf84c0ddcf 100644 --- a/Mathlib/Analysis/Normed/Operator/NormedSpace.lean +++ b/Mathlib/Analysis/Normed/Operator/NormedSpace.lean @@ -200,10 +200,11 @@ theorem opNorm_comp_linearIsometryEquiv (f : F →SL[σ₂₃] G) (g : F' ≃ₛ · haveI := g.symm.toLinearEquiv.toEquiv.subsingleton simp refine le_antisymm ?_ ?_ - · convert f.opNorm_comp_le g.toLinearIsometry.toContinuousLinearMap + · convert! f.opNorm_comp_le g.toLinearIsometry.toContinuousLinearMap simp [g.toLinearIsometry.norm_toContinuousLinearMap] - · convert (f.comp g.toLinearIsometry.toContinuousLinearMap).opNorm_comp_le - g.symm.toLinearIsometry.toContinuousLinearMap + · convert! + (f.comp g.toLinearIsometry.toContinuousLinearMap).opNorm_comp_le + g.symm.toLinearIsometry.toContinuousLinearMap · ext simp haveI := g.symm.surjective.nontrivial @@ -244,7 +245,7 @@ protected theorem antilipschitz (e : E ≃SL[σ₁₂] F) : theorem one_le_norm_mul_norm_symm [RingHomIsometric σ₁₂] [Nontrivial E] (e : E ≃SL[σ₁₂] F) : 1 ≤ ‖(e : E →SL[σ₁₂] F)‖ * ‖(e.symm : F →SL[σ₂₁] E)‖ := by rw [mul_comm] - convert (e.symm : F →SL[σ₂₁] E).opNorm_comp_le (e : E →SL[σ₁₂] F) + convert! (e.symm : F →SL[σ₂₁] E).opNorm_comp_le (e : E →SL[σ₁₂] F) rw [e.coe_symm_comp_coe, ContinuousLinearMap.norm_id] theorem norm_pos [RingHomIsometric σ₁₂] [Nontrivial E] (e : E ≃SL[σ₁₂] F) : diff --git a/Mathlib/Analysis/Normed/Order/Hom/Basic.lean b/Mathlib/Analysis/Normed/Order/Hom/Basic.lean index bb65587d1cc24c..b965dfda85e085 100644 --- a/Mathlib/Analysis/Normed/Order/Hom/Basic.lean +++ b/Mathlib/Analysis/Normed/Order/Hom/Basic.lean @@ -33,7 +33,7 @@ abbrev GroupSeminormClass.toSeminormedGroup [Group α] [GroupSeminormClass F α dist_eq _ _ := rfl dist_self _ := by simp dist_comm x y := by simp [← map_inv_eq_map f (x⁻¹ * y)] - dist_triangle x y z := by convert map_mul_le_add f (x⁻¹ * y) (y⁻¹ * z) using 2; group + dist_triangle x y z := by convert! map_mul_le_add f (x⁻¹ * y) (y⁻¹ * z) using 2; group @[to_additive] lemma GroupSeminormClass.toSeminormedGroup_norm_eq [Group α] [GroupSeminormClass F α ℝ] diff --git a/Mathlib/Analysis/Normed/Order/Hom/Ultra.lean b/Mathlib/Analysis/Normed/Order/Hom/Ultra.lean index 4ee73fd2852c50..f6901611ecbf11 100644 --- a/Mathlib/Analysis/Normed/Order/Hom/Ultra.lean +++ b/Mathlib/Analysis/Normed/Order/Hom/Ultra.lean @@ -35,5 +35,5 @@ lemma AddGroupSeminormClass.isUltrametricDist [AddGroup α] [AddGroupSeminormCla ⟨fun x y z ↦ by simp +instances only [hd, dist_eq_norm_neg_add, AddGroupSeminormClass.toSeminormedAddGroup_norm_eq] - convert hna (-x + y) (-y + z) using 2 + convert! hna (-x + y) (-y + z) using 2 rw [add_assoc, ← add_assoc y, add_neg_cancel, zero_add]⟩ diff --git a/Mathlib/Analysis/Normed/Order/Lattice.lean b/Mathlib/Analysis/Normed/Order/Lattice.lean index 89fe7a06c04dad..402142c6b44f90 100644 --- a/Mathlib/Analysis/Normed/Order/Lattice.lean +++ b/Mathlib/Analysis/Normed/Order/Lattice.lean @@ -132,8 +132,9 @@ instance (priority := 100) HasSolidNorm.continuousInf : ContinuousInf α := by have : ∀ p : α × α, ‖p.1 ⊓ p.2 - q.1 ⊓ q.2‖ ≤ ‖p.1 - q.1‖ + ‖p.2 - q.2‖ := fun _ => norm_inf_sub_inf_le_add_norm _ _ _ _ refine squeeze_zero (fun e => norm_nonneg _) this ?_ - convert ((continuous_fst.tendsto q).sub <| tendsto_const_nhds).norm.add - ((continuous_snd.tendsto q).sub <| tendsto_const_nhds).norm + convert! + ((continuous_fst.tendsto q).sub <| tendsto_const_nhds).norm.add + ((continuous_snd.tendsto q).sub <| tendsto_const_nhds).norm simp set_option backward.isDefEq.respectTransparency false in diff --git a/Mathlib/Analysis/Normed/Ring/InfiniteSum.lean b/Mathlib/Analysis/Normed/Ring/InfiniteSum.lean index bbe3dfd5ee6869..42db3ae793bb65 100644 --- a/Mathlib/Analysis/Normed/Ring/InfiniteSum.lean +++ b/Mathlib/Analysis/Normed/Ring/InfiniteSum.lean @@ -58,8 +58,10 @@ theorem summable_mul_of_summable_norm' {f : ι → R} {g : ι' → R} rw [← prod_atTop_atTop_eq] have := Tendsto.prodMap h'f.hasSum h'g.hasSum rw [← nhds_prod_eq] at this - convert ((continuous_mul (M := R)).continuousAt - (x := (∑' (i : ι), f i, ∑' (j : ι'), g j))).tendsto.comp this with p + convert! + ((continuous_mul (M := R)).continuousAt (x := (∑' (i : ι), f i, ∑' (j : ι'), g j))).tendsto.comp + this with + p simp [sum_product, ← mul_sum, ← sum_mul] /-- Product of two infinite sums indexed by arbitrary types. @@ -150,7 +152,7 @@ theorem tsum_mul_tsum_eq_tsum_sum_range_of_summable_norm [CompleteSpace R] {f g theorem hasSum_sum_range_mul_of_summable_norm [CompleteSpace R] {f g : ℕ → R} (hf : Summable fun x => ‖f x‖) (hg : Summable fun x => ‖g x‖) : HasSum (fun n ↦ ∑ k ∈ range (n + 1), f k * g (n - k)) ((∑' n, f n) * ∑' n, g n) := by - convert (summable_norm_sum_mul_range_of_summable_norm hf hg).of_norm.hasSum + convert! (summable_norm_sum_mul_range_of_summable_norm hf hg).of_norm.hasSum exact tsum_mul_tsum_eq_tsum_sum_range_of_summable_norm hf hg theorem tsum_mul_tsum_eq_tsum_sum_range_of_summable_norm' {f g : ℕ → R} @@ -164,7 +166,7 @@ theorem hasSum_sum_range_mul_of_summable_norm' {f g : ℕ → R} (hf : Summable fun x => ‖f x‖) (h'f : Summable f) (hg : Summable fun x => ‖g x‖) (h'g : Summable g) : HasSum (fun n ↦ ∑ k ∈ range (n + 1), f k * g (n - k)) ((∑' n, f n) * ∑' n, g n) := by - convert (summable_sum_mul_range_of_summable_norm' hf h'f hg h'g).hasSum + convert! (summable_sum_mul_range_of_summable_norm' hf h'f hg h'g).hasSum exact tsum_mul_tsum_eq_tsum_sum_range_of_summable_norm' hf h'f hg h'g end Nat diff --git a/Mathlib/Analysis/Normed/Ring/Lemmas.lean b/Mathlib/Analysis/Normed/Ring/Lemmas.lean index ad9dc11b8dc775..08751154c27ac6 100644 --- a/Mathlib/Analysis/Normed/Ring/Lemmas.lean +++ b/Mathlib/Analysis/Normed/Ring/Lemmas.lean @@ -168,7 +168,7 @@ instance (priority := 100) NonUnitalSeminormedRing.toContinuousMul [NonUnitalSem _ ≤ ‖e.1‖ * ‖e.2 - x.2‖ + ‖e.1 - x.1‖ * ‖x.2‖ := norm_add_le_of_le (norm_mul_le _ _) (norm_mul_le _ _) refine squeeze_zero (fun e => norm_nonneg _) this ?_ - convert + convert! ((continuous_fst.tendsto x).norm.mul ((continuous_snd.tendsto x).sub tendsto_const_nhds).norm).add (((continuous_fst.tendsto x).sub tendsto_const_nhds).norm.mul tendsto_const_nhds) @@ -213,8 +213,10 @@ lemma lipschitzWith_sub : LipschitzWith 2 (fun (p : ℝ≥0 × ℝ≥0) ↦ p.1 rw [← NNReal.isometry_coe.lipschitzWith_iff] have : Isometry (Prod.map ((↑) : ℝ≥0 → ℝ) ((↑) : ℝ≥0 → ℝ)) := NNReal.isometry_coe.prodMap NNReal.isometry_coe - convert (((LipschitzWith.prod_fst.comp this.lipschitz).sub - (LipschitzWith.prod_snd.comp this.lipschitz)).max_const 0) + convert! + (((LipschitzWith.prod_fst.comp this.lipschitz).sub + (LipschitzWith.prod_snd.comp this.lipschitz)).max_const + 0) norm_num end NNReal diff --git a/Mathlib/Analysis/Normed/Ring/Units.lean b/Mathlib/Analysis/Normed/Ring/Units.lean index e9e308a0eb2bbc..0992672add03a7 100644 --- a/Mathlib/Analysis/Normed/Ring/Units.lean +++ b/Mathlib/Analysis/Normed/Ring/Units.lean @@ -176,7 +176,7 @@ theorem inverse_add_norm_diff_first_order (x : Rˣ) : /-- The function `fun t ↦ Ring.inverse (x + t) - x⁻¹ + x⁻¹ * t * x⁻¹` is `O(t ^ 2)` as `t → 0`. -/ theorem inverse_add_norm_diff_second_order (x : Rˣ) : (fun t : R => (↑x + t)⁻¹ʳ - ↑x⁻¹ + ↑x⁻¹ * t * ↑x⁻¹) =O[𝓝 0] fun t => ‖t‖ ^ 2 := by - convert inverse_add_norm_diff_nth_order x 2 using 2 + convert! inverse_add_norm_diff_nth_order x 2 using 2 simp only [sum_range_succ, sum_range_zero, zero_add, pow_zero, pow_one, add_mul, one_mul, ← sub_sub, neg_mul, sub_neg_eq_add] diff --git a/Mathlib/Analysis/Normed/Unbundled/SeminormFromBounded.lean b/Mathlib/Analysis/Normed/Unbundled/SeminormFromBounded.lean index 93fd45b5db61ff..f9928117449d40 100644 --- a/Mathlib/Analysis/Normed/Unbundled/SeminormFromBounded.lean +++ b/Mathlib/Analysis/Normed/Unbundled/SeminormFromBounded.lean @@ -317,7 +317,7 @@ theorem seminormFromBounded_of_mul_le (f_nonneg : 0 ≤ f) {x : R} · rw [← mul_one (f x), ← div_self hy0, ← mul_div_assoc, div_le_iff₀ (lt_of_le_of_ne' (f_nonneg _) hy0), mul_div_assoc, div_self hy0, mul_one] exact hx y - convert le_ciSup h_bdd (1 : R) + convert! le_ciSup h_bdd (1 : R) by_cases h0 : f x = 0 · rw [mul_one, h0, zero_div] · have heq : f 1 = 1 := by diff --git a/Mathlib/Analysis/Normed/Unbundled/SeminormFromConst.lean b/Mathlib/Analysis/Normed/Unbundled/SeminormFromConst.lean index 8131a0a5890ab7..d3ea0bf1ac6bde 100644 --- a/Mathlib/Analysis/Normed/Unbundled/SeminormFromConst.lean +++ b/Mathlib/Analysis/Normed/Unbundled/SeminormFromConst.lean @@ -190,7 +190,7 @@ theorem seminormFromConst_isPowMul : IsPowMul (seminormFromConst' c f) := fun x (tendsto_atTop_atTop_of_monotone (fun _ _ hnk ↦ mul_le_mul_right hnk m) _) rintro n; use n; exact le_mul_of_one_le_left' hm apply tendsto_nhds_unique hlim - convert (tendsto_seminormFromConst_seq_atTop hf1 hc hpm x).pow m using 1 + convert! (tendsto_seminormFromConst_seq_atTop hf1 hc hpm x).pow m using 1 ext n simp only [seminormFromConst_seq, div_pow, ← hpm _ hm, ← pow_mul, mul_pow, mul_comm m n] diff --git a/Mathlib/Analysis/Normed/Unbundled/SmoothingSeminorm.lean b/Mathlib/Analysis/Normed/Unbundled/SmoothingSeminorm.lean index 526d185ba6de8c..c738a8c586bd57 100644 --- a/Mathlib/Analysis/Normed/Unbundled/SmoothingSeminorm.lean +++ b/Mathlib/Analysis/Normed/Unbundled/SmoothingSeminorm.lean @@ -330,7 +330,7 @@ private theorem μ_bddAbove (hμ1 : μ 1 ≤ 1) {s : ℕ → ℕ} (hs : ∀ n : private theorem μ_bddAbove' (hμ1 : μ 1 ≤ 1) {s : ℕ → ℕ} (hs : ∀ n : ℕ, s n ≤ n) (x : R) (ψ : ℕ → ℕ) : BddAbove ((fun n : ℕ => μ (x ^ s (ψ n)) ^ (1 / (ψ n : ℝ))) '' Set.univ) := by rw [Set.image_eq_range] - convert μ_bddAbove μ hμ1 hs x ψ + convert! μ_bddAbove μ hμ1 hs x ψ ext simp [one_div, Set.mem_range, Subtype.exists, Set.mem_univ, exists_const] @@ -366,7 +366,8 @@ private theorem μ_limsup_le_one {s : ℕ → ℕ} (hs_le : ∀ n : ℕ, s n ≤ (mul_nonneg (cast_nonneg _) (one_div_nonneg.mpr (cast_nonneg _))) · have hμ_lim : Tendsto (fun n : ℕ => μ x ^ (↑(s (ψ n)) * (1 / (ψ n : ℝ)))) atTop (𝓝 1) := by nth_rw 1 [← rpow_zero (μ x)] - convert Tendsto.rpow tendsto_const_nhds hψ_lim + convert! + Tendsto.rpow tendsto_const_nhds hψ_lim (Or.inl (ne_of_gt (lt_of_lt_of_le zero_lt_one (not_lt.mp hμx)))) · simp only [rpow_zero, mul_one_div, Function.comp_apply] · rw [rpow_zero] diff --git a/Mathlib/Analysis/Normed/Unbundled/SpectralNorm.lean b/Mathlib/Analysis/Normed/Unbundled/SpectralNorm.lean index e20a5106256907..d37f6500061b51 100644 --- a/Mathlib/Analysis/Normed/Unbundled/SpectralNorm.lean +++ b/Mathlib/Analysis/Normed/Unbundled/SpectralNorm.lean @@ -162,7 +162,7 @@ theorem spectralValue_X_pow (n : ℕ) : spectralValue (X ^ n : R[X]) = 0 := by rw [spectralValue] unfold spectralValueTerms simp_rw [coeff_X_pow n, natDegree_X_pow] - convert ciSup_const using 2 + convert! ciSup_const using 2 · ext m by_cases hmn : m < n · rw [if_pos hmn, rpow_eq_zero_iff_of_nonneg (norm_nonneg _), if_neg (_root_.ne_of_lt hmn), diff --git a/Mathlib/Analysis/ODE/Gronwall.lean b/Mathlib/Analysis/ODE/Gronwall.lean index e982b8cccf1f50..03ebd3aaf1fb0f 100644 --- a/Mathlib/Analysis/ODE/Gronwall.lean +++ b/Mathlib/Analysis/ODE/Gronwall.lean @@ -55,17 +55,18 @@ theorem hasDerivAt_gronwallBound (δ K ε x : ℝ) : by_cases hK : K = 0 · subst K simp only [gronwallBound_K0, zero_mul, zero_add] - convert ((hasDerivAt_id x).const_mul ε).const_add δ + convert! ((hasDerivAt_id x).const_mul ε).const_add δ rw [mul_one] · simp only [gronwallBound_of_K_ne_0 hK] - convert (((hasDerivAt_id x).const_mul K).exp.const_mul δ).add - ((((hasDerivAt_id x).const_mul K).exp.sub_const 1).const_mul (ε / K)) using 1 + convert! + (((hasDerivAt_id x).const_mul K).exp.const_mul δ).add + ((((hasDerivAt_id x).const_mul K).exp.sub_const 1).const_mul (ε / K)) using 1 simp only [id] field theorem hasDerivAt_gronwallBound_shift (δ K ε x a : ℝ) : HasDerivAt (fun y => gronwallBound δ K ε (y - a)) (K * gronwallBound δ K ε (x - a) + ε) x := by - convert (hasDerivAt_gronwallBound δ K ε _).comp x ((hasDerivAt_id x).sub_const a) using 1 + convert! (hasDerivAt_gronwallBound δ K ε _).comp x ((hasDerivAt_id x).sub_const a) using 1 rw [id, mul_one] theorem gronwallBound_x0 (δ K ε : ℝ) : gronwallBound δ K ε 0 = δ := by @@ -122,7 +123,7 @@ theorem le_gronwallBound_of_liminf_deriv_right_le {f f' : ℝ → ℝ} {δ K ε · exact hx intro x hx change f x ≤ (fun ε' => gronwallBound δ K ε' (x - a)) ε - convert continuousWithinAt_const.closure_le _ _ (H x hx) + convert! continuousWithinAt_const.closure_le _ _ (H x hx) · simp only [closure_Ioi, self_mem_Ici] exact (gronwallBound_continuous_ε δ K (x - a)).continuousWithinAt @@ -281,18 +282,20 @@ theorem ODE_solution_unique_of_mem_Icc_left fun _ ht' ↦ mem_Iic.mpr <| neg_le_neg ht' suffices EqOn (f ∘ Neg.neg) (g ∘ Neg.neg) (Icc (-b) (-a)) by rw [eqOn_comp_right_iff] at this - convert this + convert! this simp apply ODE_solution_unique_of_mem_Icc_right hv' (hf.comp continuousOn_neg hmt1) _ (fun _ ht ↦ hfs _ (hmt2 ht)) (hg.comp continuousOn_neg hmt1) _ (fun _ ht ↦ hgs _ (hmt2 ht)) (by simp [hb]) · intro t ht - convert HasFDerivWithinAt.comp_hasDerivWithinAt t (hf' (-t) (hmt2 ht)) - (hasDerivAt_neg t).hasDerivWithinAt (hmt3 t) + convert! + HasFDerivWithinAt.comp_hasDerivWithinAt t (hf' (-t) (hmt2 ht)) + (hasDerivAt_neg t).hasDerivWithinAt (hmt3 t) simp · intro t ht - convert HasFDerivWithinAt.comp_hasDerivWithinAt t (hg' (-t) (hmt2 ht)) - (hasDerivAt_neg t).hasDerivWithinAt (hmt3 t) + convert! + HasFDerivWithinAt.comp_hasDerivWithinAt t (hg' (-t) (hmt2 ht)) + (hasDerivAt_neg t).hasDerivWithinAt (hmt3 t) simp /-- A version of `ODE_solution_unique_of_mem_Icc_right` for uniqueness in a closed interval whose diff --git a/Mathlib/Analysis/ODE/PicardLindelof.lean b/Mathlib/Analysis/ODE/PicardLindelof.lean index 5d11f3514a1220..edfe54041d89bb 100644 --- a/Mathlib/Analysis/ODE/PicardLindelof.lean +++ b/Mathlib/Analysis/ODE/PicardLindelof.lean @@ -468,7 +468,7 @@ lemma exists_forall_closedBall_funSpace_dist_le_mul [CompleteSpace E] · nth_rw 1 [← hα, dist_next_next] apply Filter.Tendsto.mul_const apply Filter.Tendsto.const_mul - convert hasSum_geometric_of_lt_one C.2 (h y hy).1 |>.tendsto_sum_nat + convert! hasSum_geometric_of_lt_one C.2 (h y hy).1 |>.tendsto_sum_nat simp [NNReal.coe_sub <| le_of_lt (h y hy).1, NNReal.coe_one] end diff --git a/Mathlib/Analysis/ODE/Transform.lean b/Mathlib/Analysis/ODE/Transform.lean index f3d13a15c1822e..34159766ddc293 100644 --- a/Mathlib/Analysis/ODE/Transform.lean +++ b/Mathlib/Analysis/ODE/Transform.lean @@ -45,7 +45,7 @@ lemma IsIntegralCurveOn.comp_add (hγ : IsIntegralCurveOn γ v s) (dt : ℝ) : lemma isIntegralCurveOn_comp_add {dt : ℝ} : IsIntegralCurveOn (γ ∘ (· + dt)) (v ∘ (· + dt)) (-dt +ᵥ s) ↔ IsIntegralCurveOn γ v s := by refine ⟨fun hγ ↦ ?_, fun hγ ↦ hγ.comp_add _⟩ - convert hγ.comp_add (-dt) + convert! hγ.comp_add (-dt) · ext t simp only [comp_apply, neg_add_cancel_right] · ext t @@ -64,7 +64,7 @@ lemma isIntegralCurveAt_comp_add {dt : ℝ} : IsIntegralCurveAt (γ ∘ (· + dt)) (v ∘ (· + dt)) (t₀ - dt) ↔ IsIntegralCurveAt γ v t₀ := by simp_rw [isIntegralCurveAt_iff_exists_pos] congrm ∃ ε > 0, ?_ - convert isIntegralCurveOn_comp_add + convert! isIntegralCurveOn_comp_add simp [neg_add_eq_sub] lemma IsIntegralCurveAt.comp_add (hγ : IsIntegralCurveAt γ v t₀) (dt : ℝ) : @@ -87,7 +87,7 @@ lemma IsIntegralCurve.comp_add (hγ : IsIntegralCurve γ v) (dt : ℝ) : lemma isIntegralCurve_comp_add {dt : ℝ} : IsIntegralCurve (γ ∘ (· + dt)) (v ∘ (· + dt)) ↔ IsIntegralCurve γ v := by simp_rw [← isIntegralCurveOn_univ] - convert isIntegralCurveOn_comp_add + convert! isIntegralCurveOn_comp_add simp lemma isIntegralCurve_comp_sub {dt : ℝ} : @@ -117,7 +117,7 @@ lemma isIntegralCurveOn_comp_mul_ne_zero {a : ℝ} (ha : a ≠ 0) : rw [mem_inv_smul_set_iff₀ ha, smul_eq_mul, mul_comm] rfl refine ⟨fun hγ ↦ ?_, heq ▸ fun hγ ↦ hγ.comp_mul a⟩ - convert hγ.comp_mul a⁻¹ + convert! hγ.comp_mul a⁻¹ · ext t simp only [comp_apply, mul_assoc, inv_mul_eq_div, div_self ha, mul_one] · ext t @@ -131,7 +131,7 @@ lemma IsIntegralCurveAt.comp_mul_ne_zero (hγ : IsIntegralCurveAt γ v t₀) {a rw [isIntegralCurveAt_iff_exists_pos] at * obtain ⟨ε, hε, h⟩ := hγ refine ⟨ε / |a|, by positivity, ?_⟩ - convert h.comp_mul a + convert! h.comp_mul a ext t rw [mem_setOf_eq, Metric.mem_ball, Metric.mem_ball, Real.dist_eq, Real.dist_eq, lt_div_iff₀ (abs_pos.mpr ha), ← abs_mul, sub_mul, div_mul_cancel₀ _ ha] @@ -139,7 +139,7 @@ lemma IsIntegralCurveAt.comp_mul_ne_zero (hγ : IsIntegralCurveAt γ v t₀) {a lemma isIntegralCurveAt_comp_mul_ne_zero {a : ℝ} (ha : a ≠ 0) : IsIntegralCurveAt (γ ∘ (· * a)) (a • v ∘ (· * a)) (t₀ / a) ↔ IsIntegralCurveAt γ v t₀ := by refine ⟨fun hγ ↦ ?_, fun hγ ↦ hγ.comp_mul_ne_zero ha⟩ - convert hγ.comp_mul_ne_zero (inv_ne_zero ha) + convert! hγ.comp_mul_ne_zero (inv_ne_zero ha) · ext t simp only [comp_apply, mul_assoc, inv_mul_eq_div, div_self ha, mul_one] · ext t @@ -155,7 +155,7 @@ lemma IsIntegralCurve.comp_mul (hγ : IsIntegralCurve γ v) (a : ℝ) : lemma isIntegralCurve_comp_mul_ne_zero {a : ℝ} (ha : a ≠ 0) : IsIntegralCurve (γ ∘ (· * a)) (a • v ∘ (· * a)) ↔ IsIntegralCurve γ v := by refine ⟨fun hγ ↦ ?_, fun hγ ↦ hγ.comp_mul _⟩ - convert hγ.comp_mul a⁻¹ + convert! hγ.comp_mul a⁻¹ · ext t simp only [comp_apply, mul_assoc, inv_mul_eq_div, div_self ha, mul_one] · ext t diff --git a/Mathlib/Analysis/Oscillation.lean b/Mathlib/Analysis/Oscillation.lean index 044eafdbcc6e3d..724add9e759f04 100644 --- a/Mathlib/Analysis/Oscillation.lean +++ b/Mathlib/Analysis/Oscillation.lean @@ -157,7 +157,7 @@ theorem uniform_oscillation {K : Set E} (comp : IsCompact K) {f : E → F} {ε : ENNReal} (hK : ∀ x ∈ K, oscillation f x < ε) : ∃ δ > 0, ∀ x ∈ K, ediam (f '' (eball x (ENNReal.ofReal δ))) ≤ ε := by simp only [← oscillationWithin_univ_eq_oscillation] at hK - convert ← comp.uniform_oscillationWithin hK + convert! ← comp.uniform_oscillationWithin hK exact inter_univ _ end IsCompact diff --git a/Mathlib/Analysis/PSeries.lean b/Mathlib/Analysis/PSeries.lean index ffdf8264c6785e..afaaa117b85f66 100644 --- a/Mathlib/Analysis/PSeries.lean +++ b/Mathlib/Analysis/PSeries.lean @@ -5,10 +5,12 @@ Authors: Yury Kudryashov -/ module -public import Mathlib.Analysis.SpecialFunctions.Pow.NNReal public import Mathlib.Analysis.SpecialFunctions.Pow.Continuity public import Mathlib.Analysis.SumOverResidueClass +import Mathlib.Analysis.Asymptotics.SpecificAsymptotics +import Mathlib.Analysis.Normed.Module.FiniteDimension + /-! # Convergence of `p`-series @@ -62,13 +64,14 @@ theorem le_sum_schlomilch' (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f exacts [hu n.zero_le, hu n.le_succ] have : ∀ k ∈ Ico (u n) (u (n + 1)), f k ≤ f (u n) := fun k hk => hf (Nat.succ_le_of_lt (h_pos n)) (mem_Ico.mp hk).1 - convert sum_le_sum this + convert! sum_le_sum this simp theorem le_sum_condensed' (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (n : ℕ) : (∑ k ∈ Ico 1 (2 ^ n), f k) ≤ ∑ k ∈ range n, 2 ^ k • f (2 ^ k) := by - convert le_sum_schlomilch' hf (fun n => pow_pos zero_lt_two n) - (fun m n hm => pow_right_mono₀ one_le_two hm) n using 2 + convert! + le_sum_schlomilch' hf (fun n => pow_pos zero_lt_two n) + (fun m n hm => pow_right_mono₀ one_le_two hm) n using 2 simp [pow_succ, mul_two] theorem le_sum_schlomilch (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n) @@ -96,13 +99,14 @@ theorem sum_schlomilch_le' (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f have : ∀ k ∈ Ico (u n + 1) (u (n + 1) + 1), f (u (n + 1)) ≤ f k := fun k hk => hf (Nat.lt_of_le_of_lt (Nat.succ_le_of_lt (h_pos n)) <| (Nat.lt_succ_of_le le_rfl).trans_le (mem_Ico.mp hk).1) (Nat.le_of_lt_succ <| (mem_Ico.mp hk).2) - convert sum_le_sum this + convert! sum_le_sum this simp theorem sum_condensed_le' (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (n : ℕ) : (∑ k ∈ range n, 2 ^ k • f (2 ^ (k + 1))) ≤ ∑ k ∈ Ico 2 (2 ^ n + 1), f k := by - convert sum_schlomilch_le' hf (fun n => pow_pos zero_lt_two n) - (fun m n hm => pow_right_mono₀ one_le_two hm) n using 2 + convert! + sum_schlomilch_le' hf (fun n => pow_pos zero_lt_two n) + (fun m n hm => pow_right_mono₀ one_le_two hm) n using 2 simp [pow_succ, mul_two] theorem sum_schlomilch_le {C : ℕ} (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n) @@ -122,7 +126,7 @@ theorem sum_schlomilch_le {C : ℕ} (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f gcongr · exact h_nonneg (u (k + 1)) exact mod_cast h_succ_diff k - convert sum_le_sum this + convert! sum_le_sum this simp [smul_sum] theorem sum_condensed_le (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (n : ℕ) : @@ -204,8 +208,9 @@ theorem summable_condensed_iff {f : ℕ → ℝ≥0} (hf : ∀ ⦃m n⦄, 0 < m have h_succ_diff : SuccDiffBounded 2 (2 ^ ·) := by intro n simp [pow_succ, mul_two, two_mul] - convert summable_schlomilch_iff hf (pow_pos zero_lt_two) (pow_right_strictMono₀ _root_.one_lt_two) - two_ne_zero h_succ_diff + convert! + summable_schlomilch_iff hf (pow_pos zero_lt_two) (pow_right_strictMono₀ _root_.one_lt_two) + two_ne_zero h_succ_diff simp [pow_succ, mul_two] end NNReal @@ -231,8 +236,9 @@ theorem summable_condensed_iff_of_nonneg {f : ℕ → ℝ} (h_nonneg : ∀ n, 0 have h_succ_diff : SuccDiffBounded 2 (2 ^ ·) := by intro n simp [pow_succ, mul_two, two_mul] - convert summable_schlomilch_iff_of_nonneg h_nonneg h_mono (pow_pos zero_lt_two) - (pow_right_strictMono₀ one_lt_two) two_ne_zero h_succ_diff + convert! + summable_schlomilch_iff_of_nonneg h_nonneg h_mono (pow_pos zero_lt_two) + (pow_right_strictMono₀ one_lt_two) two_ne_zero h_succ_diff simp [pow_succ, mul_two] /-- Cauchy condensation test for eventually antitone and nonnegative series of real numbers. -/ @@ -243,7 +249,7 @@ theorem summable_condensed_iff_of_eventually_nonneg {f : ℕ → ℝ} (h_nonneg rw [Filter.eventually_atTop] at h_mono rcases h_nonneg with ⟨n, hn⟩ rcases h_mono with ⟨m, hm⟩ - convert summable_condensed_iff_of_nonneg (f := fun k ↦ f (max k (n + m))) _ _ using 1 + convert! summable_condensed_iff_of_nonneg (f := fun k ↦ f (max k (n + m))) _ _ using 1 · rw [summable_congr_atTop] have h_pow := tendsto_pow_atTop_atTop_of_one_lt (r := 2) (by simp) filter_upwards [h_pow.eventually_ge_atTop (n + m)] with _ hk using by simp [max_eq_left hk] @@ -444,32 +450,17 @@ section shifted open Filter Asymptotics Topology --- see https://github.com/leanprover-community/mathlib4/issues/29041 -set_option linter.unusedSimpArgs false in lemma Real.summable_one_div_nat_add_rpow (a : ℝ) (s : ℝ) : Summable (fun n : ℕ ↦ 1 / |n + a| ^ s) ↔ 1 < s := by - suffices ∀ (b c : ℝ), Summable (fun n : ℕ ↦ 1 / |n + b| ^ s) → - Summable (fun n : ℕ ↦ 1 / |n + c| ^ s) by - simp_rw [← summable_one_div_nat_rpow, Iff.intro (this a 0) (this 0 a), add_zero, Nat.abs_cast] - refine fun b c h ↦ summable_of_isBigO_nat h (isBigO_of_div_tendsto_nhds ?_ 1 ?_) - · filter_upwards [eventually_gt_atTop (Nat.ceil |b|)] with n hn hx - have hna : 0 < n + b := by linarith [lt_of_abs_lt ((abs_neg b).symm ▸ Nat.lt_of_ceil_lt hn)] - exfalso - revert hx - positivity - · simp_rw [Pi.div_def, div_div, mul_one_div, one_div_div] - refine (?_ : Tendsto (fun x : ℝ ↦ |x + b| ^ s / |x + c| ^ s) atTop (𝓝 1)).comp - tendsto_natCast_atTop_atTop - have : Tendsto (fun x : ℝ ↦ 1 + (b - c) / x) atTop (𝓝 1) := by - simpa using tendsto_const_nhds.add ((tendsto_const_nhds (X := ℝ)).div_atTop tendsto_id) - have : Tendsto (fun x ↦ (x + b) / (x + c)) atTop (𝓝 1) := by - refine (this.comp (tendsto_id.atTop_add (tendsto_const_nhds (x := c)))).congr' ?_ - filter_upwards [eventually_gt_atTop (-c)] with x hx - simp [field, (by linarith : 0 < x + c).ne'] - apply (one_rpow s ▸ (continuousAt_rpow_const _ s (by simp)).tendsto.comp this).congr' - filter_upwards [eventually_gt_atTop (-b), eventually_gt_atTop (-c)] with x hb hc - rw [neg_lt_iff_pos_add] at hb hc - rw [Function.comp_apply, div_rpow hb.le hc.le, abs_of_pos hb, abs_of_pos hc] + have hnorm : Tendsto (fun n : ℕ ↦ ‖(n : ℝ)‖) atTop atTop := + tendsto_natCast_atTop_atTop.congr' (by simp) + have h_abs : (fun n : ℕ ↦ |n + a|) ~[atTop] (·) := by + apply (IsEquivalent.refl.add_const_of_norm_tendsto_atTop hnorm).congr_left + · filter_upwards [eventually_gt_atTop (Nat.ceil |a|)] with _ hn + rw [abs_of_pos] + linarith [lt_of_abs_lt ((abs_neg a).symm ▸ Nat.lt_of_ceil_lt hn)] + rw [← summable_one_div_nat_rpow, Asymptotics.IsEquivalent.summable_iff_nat] + simpa [one_div] using (IsEquivalent.rpow (fun n ↦ by positivity) h_abs).inv lemma Real.summable_one_div_int_add_rpow (a : ℝ) (s : ℝ) : Summable (fun n : ℤ ↦ 1 / |n + a| ^ s) ↔ 1 < s := by diff --git a/Mathlib/Analysis/Polynomial/Basic.lean b/Mathlib/Analysis/Polynomial/Basic.lean index 813621521feaf9..480ca8bcb02df2 100644 --- a/Mathlib/Analysis/Polynomial/Basic.lean +++ b/Mathlib/Analysis/Polynomial/Basic.lean @@ -121,13 +121,13 @@ end PolynomialAtTop section PolynomialAtBot theorem isEquivalent_atBot_lead : P.eval ~[atBot] (P.leadingCoeff * · ^ P.natDegree) := by - convert (P.comp (-X)).isEquivalent_atTop_lead.comp_tendsto tendsto_neg_atBot_atTop using 2 + convert! (P.comp (-X)).isEquivalent_atTop_lead.comp_tendsto tendsto_neg_atBot_atTop using 2 · simp · rw [Function.comp_apply, comp_neg_X_leadingCoeff_eq, ← mul_rotate] simp [natDegree_comp, ← mul_pow, mul_comm] theorem abs_tendsto_atBot (hdeg : 0 < P.degree) : Tendsto (|P.eval ·|) atBot atTop := by - convert ((P.comp (-X)).abs_tendsto_atTop (by simp [hdeg])).comp tendsto_neg_atBot_atTop using 2 + convert! ((P.comp (-X)).abs_tendsto_atTop (by simp [hdeg])).comp tendsto_neg_atBot_atTop using 2 simp theorem isBoundedUnder_abs_atBot_iff : @@ -269,7 +269,7 @@ theorem isEquivalent_atBot_div : theorem div_tendsto_atBot_zero_of_degree_lt (hdeg : P.degree < Q.degree) : Tendsto (fun x ↦ eval x P / eval x Q) atBot (𝓝 0) := by rw [← P.degree_comp_neg_X, ← Q.degree_comp_neg_X] at hdeg - convert (div_tendsto_atTop_zero_of_degree_lt _ _ hdeg).comp tendsto_neg_atBot_atTop using 2 + convert! (div_tendsto_atTop_zero_of_degree_lt _ _ hdeg).comp tendsto_neg_atBot_atTop using 2 simp theorem div_tendsto_atBot_zero_iff_degree_lt (hQ : Q ≠ 0) : @@ -280,7 +280,7 @@ theorem div_tendsto_atBot_zero_iff_degree_lt (hQ : Q ≠ 0) : rw [Ne, comp_eq_zero_iff] simp [hQ] rw [← div_tendsto_atTop_zero_iff_degree_lt _ _ hQ] - convert h.comp tendsto_neg_atTop_atBot using 2 + convert! h.comp tendsto_neg_atTop_atBot using 2 simp theorem div_tendsto_atBot_leadingCoeff_div_of_degree_eq (hdeg : P.degree = Q.degree) : @@ -294,8 +294,8 @@ theorem abs_div_tendsto_atBot_atTop_of_degree_gt (hdeg : Q.degree < P.degree) (h replace hQ : Q.comp (-X) ≠ 0 := by rw [Ne, comp_eq_zero_iff] simp [hQ] - convert (abs_div_tendsto_atTop_atTop_of_degree_gt _ _ hdeg hQ).comp - tendsto_neg_atBot_atTop using 2 + convert! (abs_div_tendsto_atTop_atTop_of_degree_gt _ _ hdeg hQ).comp tendsto_neg_atBot_atTop + using 2 simp end PolynomialDivAtBot @@ -310,7 +310,7 @@ theorem isLittleO_atTop_of_degree_lt (h : P.degree < Q.degree) : P.eval =o[atTop theorem isLittleO_atBot_of_degree_lt (h : P.degree < Q.degree) : P.eval =o[atBot] Q.eval := by rw [← P.degree_comp_neg_X, ← Q.degree_comp_neg_X] at h - convert (isLittleO_atTop_of_degree_lt _ _ h).comp_tendsto tendsto_neg_atBot_atTop using 2 + convert! (isLittleO_atTop_of_degree_lt _ _ h).comp_tendsto tendsto_neg_atBot_atTop using 2 all_goals simp theorem isBigO_atTop_of_degree_le (h : P.degree ≤ Q.degree) : P.eval =O[atTop] Q.eval := by @@ -325,7 +325,7 @@ theorem isBigO_atTop_of_degree_le (h : P.degree ≤ Q.degree) : P.eval =O[atTop] theorem isBigO_atBot_of_degree_le (h : P.degree ≤ Q.degree) : P.eval =O[atBot] Q.eval := by rw [← P.degree_comp_neg_X, ← Q.degree_comp_neg_X] at h - convert (isBigO_atTop_of_degree_le _ _ h).comp_tendsto tendsto_neg_atBot_atTop using 2 + convert! (isBigO_atTop_of_degree_le _ _ h).comp_tendsto tendsto_neg_atBot_atTop using 2 all_goals simp @[deprecated (since := "2026-02-05")] alias isBigO_of_degree_le := isBigO_atTop_of_degree_le diff --git a/Mathlib/Analysis/Quaternion.lean b/Mathlib/Analysis/Quaternion.lean index 2a78a192abd196..eea6dabf67969a 100644 --- a/Mathlib/Analysis/Quaternion.lean +++ b/Mathlib/Analysis/Quaternion.lean @@ -32,7 +32,7 @@ The following notation is available with `open Quaternion` or `open scoped Quate quaternion, normed ring, normed space, normed algebra -/ -@[expose] public section +@[expose] public noncomputable section @[inherit_doc] scoped[Quaternion] notation "ℍ" => Quaternion ℝ @@ -50,7 +50,7 @@ theorem inner_self (a : ℍ) : ⟪a, a⟫ = normSq a := theorem inner_def (a b : ℍ) : ⟪a, b⟫ = (a * star b).re := rfl -noncomputable instance : NormedAddCommGroup ℍ := +instance : NormedAddCommGroup ℍ := @InnerProductSpace.Core.toNormedAddCommGroup ℝ ℍ _ _ _ { toInner := inferInstance conj_inner_symm := fun x y => by simp [inner_def, mul_comm] @@ -59,7 +59,7 @@ noncomputable instance : NormedAddCommGroup ℍ := add_left := fun x y z => by simp only [inner_def, add_mul, re_add] smul_left := fun x y r => by simp [inner_def] } -noncomputable instance : InnerProductSpace ℝ ℍ := +instance : InnerProductSpace ℝ ℍ := InnerProductSpace.ofCore _ theorem normSq_eq_norm_mul_self (a : ℍ) : normSq a = ‖a‖ * ‖a‖ := by @@ -84,11 +84,11 @@ theorem norm_star (a : ℍ) : ‖star a‖ = ‖a‖ := by theorem nnnorm_star (a : ℍ) : ‖star a‖₊ = ‖a‖₊ := Subtype.ext <| norm_star a -noncomputable instance : NormedDivisionRing ℍ where +instance : NormedDivisionRing ℍ where dist_eq _ _ := rfl norm_mul _ _ := by simp_rw [norm_eq_sqrt_real_inner, inner_self]; simp -noncomputable instance : NormedAlgebra ℝ ℍ where +instance : NormedAlgebra ℝ ℍ where norm_smul_le := norm_smul_le toAlgebra := Quaternion.algebra @@ -139,7 +139,7 @@ theorem coeComplex_coe (r : ℝ) : ((r : ℂ) : ℍ) = r := rfl /-- Coercion `ℂ →ₐ[ℝ] ℍ` as an algebra homomorphism. -/ -noncomputable def ofComplex : ℂ →ₐ[ℝ] ℍ where +def ofComplex : ℂ →ₐ[ℝ] ℍ where toFun := (↑) map_one' := rfl map_zero' := rfl @@ -159,7 +159,7 @@ lemma norm_toLp_equivTuple (x : ℍ) : ‖WithLp.toLp 2 (equivTuple ℝ x)‖ = /-- `QuaternionAlgebra.linearEquivTuple` as a `LinearIsometryEquiv`. -/ @[simps apply symm_apply] -noncomputable def linearIsometryEquivTuple : ℍ ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin 4) := +def linearIsometryEquivTuple : ℍ ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin 4) := { (QuaternionAlgebra.linearEquivTuple (-1 : ℝ) (0 : ℝ) (-1 : ℝ)).trans (WithLp.linearEquiv 2 ℝ (Fin 4 → ℝ)).symm with toFun := fun a => !₂[a.1, a.2, a.3, a.4] diff --git a/Mathlib/Analysis/RCLike/Basic.lean b/Mathlib/Analysis/RCLike/Basic.lean index d96e13a97e3ae7..61526831694472 100644 --- a/Mathlib/Analysis/RCLike/Basic.lean +++ b/Mathlib/Analysis/RCLike/Basic.lean @@ -577,9 +577,6 @@ instance : StarModule ℝ K where theorem ofReal_natCast (n : ℕ) : ((n : ℝ) : K) = n := map_natCast (algebraMap ℝ K) n -@[rclike_simps, norm_cast] -lemma ofReal_nnratCast (q : ℚ≥0) : ((q : ℝ) : K) = q := map_nnratCast (algebraMap ℝ K) _ - @[simp, rclike_simps] theorem natCast_re (n : ℕ) : re (n : K) = n := by rw [← ofReal_natCast, ofReal_re] @@ -614,6 +611,16 @@ theorem intCast_re (n : ℤ) : re (n : K) = n := by rw [← ofReal_intCast, ofRe @[simp, rclike_simps, norm_cast] theorem intCast_im (n : ℤ) : im (n : K) = 0 := by rw [← ofReal_intCast, ofReal_im] +@[rclike_simps, norm_cast] +theorem ofReal_nnratCast (n : ℚ≥0) : ((n : ℝ) : K) = n := + map_nnratCast _ n + +@[simp, rclike_simps] +theorem nnratCast_re (q : ℚ≥0) : re (q : K) = q := by rw [← ofReal_nnratCast, ofReal_re] + +@[simp, rclike_simps, norm_cast] +theorem nnratCast_im (q : ℚ≥0) : im (q : K) = 0 := by rw [← ofReal_nnratCast, ofReal_im] + @[rclike_simps, norm_cast] theorem ofReal_ratCast (n : ℚ) : ((n : ℝ) : K) = n := map_ratCast _ n @@ -624,6 +631,20 @@ theorem ratCast_re (q : ℚ) : re (q : K) = q := by rw [← ofReal_ratCast, ofRe @[simp, rclike_simps, norm_cast] theorem ratCast_im (q : ℚ) : im (q : K) = 0 := by rw [← ofReal_ratCast, ofReal_im] +open OfScientific (ofScientific) + +@[rclike_simps, norm_cast] +theorem ofReal_ofScientific (m : ℕ) (s : Bool) (e : ℕ) : + ((ofScientific m s e : ℝ) : K) = ofScientific m s e := ofReal_nnratCast _ + +@[simp, rclike_simps] +theorem ofScientific_re (m : ℕ) (s : Bool) (e : ℕ) : + re (ofScientific m s e : K) = ofScientific m s e := by rw [← ofReal_ofScientific, ofReal_re] + +@[simp, rclike_simps, norm_cast] +theorem ofScientific_im (m : ℕ) (s : Bool) (e : ℕ) : + im (ofScientific m s e : K) = 0 := by rw [← ofReal_ofScientific, ofReal_im] + /-! ### Norm -/ theorem norm_of_nonneg {r : ℝ} (h : 0 ≤ r) : ‖(r : K)‖ = r := @@ -1230,7 +1251,7 @@ lemma norm_le_im_iff_eq_I_mul_norm {z : K} : · simp [h, im_eq_zero] · have : (I : K) ≠ 0 := fun _ ↦ by simp_all rw [← mul_right_inj' (neg_ne_zero.mpr this)] - convert norm_le_re_iff_eq_norm (z := -I * z) using 2 + convert! norm_le_re_iff_eq_norm (z := -I * z) using 2 all_goals simp [neg_mul, ← mul_assoc, I_mul_I_of_nonzero this, norm_I_of_ne_zero this] lemma im_le_neg_norm_iff_eq_neg_I_mul_norm {z : K} : diff --git a/Mathlib/Analysis/RCLike/Lemmas.lean b/Mathlib/Analysis/RCLike/Lemmas.lean index 713e8292513c9b..354fa7cf92ac53 100644 --- a/Mathlib/Analysis/RCLike/Lemmas.lean +++ b/Mathlib/Analysis/RCLike/Lemmas.lean @@ -89,7 +89,7 @@ namespace RCLike @[simp, rclike_simps] theorem reCLM_norm : ‖(reCLM : StrongDual ℝ K)‖ = 1 := by apply le_antisymm (LinearMap.mkContinuous_norm_le _ zero_le_one _) - convert ContinuousLinearMap.ratio_le_opNorm (reCLM : StrongDual ℝ K) (1 : K) + convert! ContinuousLinearMap.ratio_le_opNorm (reCLM : StrongDual ℝ K) (1 : K) simp @[simp, rclike_simps] diff --git a/Mathlib/Analysis/Real/Cardinality.lean b/Mathlib/Analysis/Real/Cardinality.lean index bc81900ac79a29..ff769aca889f04 100644 --- a/Mathlib/Analysis/Real/Cardinality.lean +++ b/Mathlib/Analysis/Real/Cardinality.lean @@ -136,10 +136,10 @@ theorem increasing_cantorFunction (h1 : 0 < c) (h2 : c < 1 / 2) {n : ℕ} {f g : refine lt_of_lt_of_le ?_ (cantorFunction_le (le_of_lt h1) h3 hg_min) have : c / (1 - c) < 1 := by rw [div_lt_one, lt_sub_iff_add_lt] - · convert _root_.add_lt_add h2 h2 + · convert! _root_.add_lt_add h2 h2 norm_num rwa [sub_pos] - convert this + convert! this · rw [cantorFunction_succ _ (le_of_lt h1) h3, div_eq_mul_inv, ← tsum_geometric_of_lt_one (le_of_lt h1) h3] apply zero_add @@ -188,7 +188,7 @@ theorem mk_real : #ℝ = 𝔠 := by apply mk_quotient_le.trans apply (mk_subtype_le _).trans_eq rw [← power_def, mk_nat, mkRat, aleph0_power_aleph0] - · convert mk_le_of_injective (cantorFunction_injective _ _) + · convert! mk_le_of_injective (cantorFunction_injective _ _) · rw [← power_def, mk_bool, mk_nat, two_power_aleph0] · exact 1 / 3 · simp @@ -212,12 +212,12 @@ theorem mk_Ioi_real (a : ℝ) : #(Ioi a) = 𝔠 := by intro h refine _root_.ne_of_lt ?_ mk_univ_real have hu : Iio a ∪ {a} ∪ Ioi a = Set.univ := by - convert @Iic_union_Ioi ℝ _ _ + convert! @Iic_union_Ioi ℝ _ _ exact Iio_union_right rw [← hu] grw [mk_union_le, mk_union_le] have h2 : (fun x => a + a - x) '' Ioi a = Iio a := by - convert @image_const_sub_Ioi ℝ _ _ _ + convert! @image_const_sub_Ioi ℝ _ _ _ simp rw [← h2] refine add_lt_of_lt (cantor _).le ?_ h diff --git a/Mathlib/Analysis/Real/Hyperreal.lean b/Mathlib/Analysis/Real/Hyperreal.lean index 35e64c6c0f343c..801634559d96f3 100644 --- a/Mathlib/Analysis/Real/Hyperreal.lean +++ b/Mathlib/Analysis/Real/Hyperreal.lean @@ -785,7 +785,7 @@ theorem infinitePos_add_not_infiniteNeg {x y : ℝ*} : InfinitePos x → ¬InfiniteNeg y → InfinitePos (x + y) := by intro hip hnin r obtain ⟨r₂, hr₂⟩ := not_forall.mp hnin - convert add_lt_add_of_lt_of_le (hip (r + -r₂)) (not_lt.mp hr₂) using 1 + convert! add_lt_add_of_lt_of_le (hip (r + -r₂)) (not_lt.mp hr₂) using 1 simp set_option linter.deprecated false in diff --git a/Mathlib/Analysis/Real/OfDigits.lean b/Mathlib/Analysis/Real/OfDigits.lean index 9a2c55b4899209..7617135d820ea8 100644 --- a/Mathlib/Analysis/Real/OfDigits.lean +++ b/Mathlib/Analysis/Real/OfDigits.lean @@ -74,7 +74,7 @@ theorem ofDigits_le_one {b : ℕ} (digits : ℕ → Fin b) : ofDigits digits ≤ obtain rfl | hb := (Nat.one_le_of_lt (b_pos digits)).eq_or_lt · simp [ofDigits, ofDigitsTerm] rify at hb - convert Summable.tsum_mono summable_ofDigitsTerm _ (fun _ ↦ ofDigitsTerm_le) + convert! Summable.tsum_mono summable_ofDigitsTerm _ (fun _ ↦ ofDigitsTerm_le) · simp_rw [pow_succ', mul_inv, ← inv_pow, ← mul_assoc] rw [tsum_mul_left, tsum_geometric_of_lt_one (by positivity) (by simp [inv_lt_one_iff₀, hb])] have := sub_pos.mpr hb @@ -102,8 +102,9 @@ theorem abs_ofDigits_sub_ofDigits_le {b : ℕ} {x y : ℕ → Fin b} {n : ℕ} Finset.sum_congr rfl fun i hi ↦ by simp [ofDigitsTerm, hxy i (Finset.mem_range.mp hi)] rw [this, add_sub_add_left_eq_sub, ← mul_sub, abs_mul, abs_of_nonneg (by positivity)] apply mul_le_of_le_one_right (by positivity) - convert abs_sub_le_of_le_of_le (ofDigits_nonneg _) (ofDigits_le_one _) - (ofDigits_nonneg _) (ofDigits_le_one _) + convert! + abs_sub_le_of_le_of_le (ofDigits_nonneg _) (ofDigits_le_one _) (ofDigits_nonneg _) + (ofDigits_le_one _) simp /-- Converts a real number `x` from the interval `[0, 1)` into sequence of @@ -149,7 +150,7 @@ theorem hasSum_ofDigitsTerm_digits (x : ℝ) {b : ℕ} [NeZero b] (hb : 1 < b) ( rw [hasSum_iff_tendsto_nat_of_summable_norm (by exact summable_ofDigitsTerm.abs)] refine tendsto_of_tendsto_of_tendsto_of_le_of_le ?_ tendsto_const_nhds (le_sum_ofDigitsTerm_digits hx) (sum_ofDigitsTerm_digits_le hx) - convert tendsto_const_nhds.sub (tendsto_pow_atTop_nhds_zero_of_abs_lt_one _) + convert! tendsto_const_nhds.sub (tendsto_pow_atTop_nhds_zero_of_abs_lt_one _) · simp · simp [abs_of_nonneg, inv_lt_one_iff₀, hb] @@ -179,7 +180,7 @@ theorem ofDigits_const_last_eq_one (b : ℕ) [NeZero b] : /-- A generalization of the identity `0.(9) = 1` to arbitrary positional numeral systems. -/ theorem ofDigits_const_last_eq_one' {b : ℕ} (hb : 1 < b) : ofDigits (fun _ ↦ (⟨b - 1, Nat.sub_one_lt_of_lt hb⟩ : Fin b)) = 1 := by - convert ofDigits_const_last_eq_one (b - 1) + convert! ofDigits_const_last_eq_one (b - 1) · grind · constructor grind diff --git a/Mathlib/Analysis/Real/Pi/Irrational.lean b/Mathlib/Analysis/Real/Pi/Irrational.lean index 3ce4808cca74a2..1651c973d025d5 100644 --- a/Mathlib/Analysis/Real/Pi/Irrational.lean +++ b/Mathlib/Analysis/Real/Pi/Irrational.lean @@ -82,15 +82,15 @@ private lemma recursion' (n : ℕ) : have hu₁_eval_neg_one : u₁ (-1) = 0 := by simp only [u₁, f]; simp have t : u₂ 1 * v₂ 1 - u₂ (-1) * v₂ (-1) = 2 * (0 ^ n * cos θ) := by simp [u₂, v₂, f, ← two_mul] have hf (x) : HasDerivAt f (- 2 * x) x := by - convert (hasDerivAt_pow 2 x).const_sub 1 using 1 + convert! (hasDerivAt_pow 2 x).const_sub 1 using 1 simp have hu₁ (x) : HasDerivAt u₁ (u₁' x) x := by - convert (hf x).pow _ using 1 + convert! (hf x).pow _ using 1 simp only [Nat.add_succ_sub_one, u₁', Nat.cast_add_one] ring have hv₁ (x) : HasDerivAt v₁ (v₁' x) x := (hasDerivAt_mul_const θ).sin have hu₂ (x) : HasDerivAt u₂ (u₂' x) x := by - convert (hasDerivAt_id' x).fun_mul ((hf x).fun_pow _) using 1 + convert! (hasDerivAt_id' x).fun_mul ((hf x).fun_pow _) using 1 simp only [u₂'] ring have hv₂ (x) : HasDerivAt v₂ (v₂' x) x := (hasDerivAt_mul_const θ).cos diff --git a/Mathlib/Analysis/Real/Pi/Wallis.lean b/Mathlib/Analysis/Real/Pi/Wallis.lean index b55c4a8e3d704a..ec14dbd01d3e8f 100644 --- a/Mathlib/Analysis/Real/Pi/Wallis.lean +++ b/Mathlib/Analysis/Real/Pi/Wallis.lean @@ -87,7 +87,7 @@ theorem W_le (k : ℕ) : W k ≤ π / 2 := by theorem le_W (k : ℕ) : ((2 : ℝ) * k + 1) / (2 * k + 2) * (π / 2) ≤ W k := by rw [← le_div_iff₀ pi_div_two_pos, div_eq_inv_mul (W k) _] rw [W_eq_integral_sin_pow_div_integral_sin_pow, le_div_iff₀ (integral_sin_pow_pos _)] - convert integral_sin_pow_succ_le (2 * k + 1) + convert! integral_sin_pow_succ_le (2 * k + 1) rw [integral_sin_pow (2 * k)] simp diff --git a/Mathlib/Analysis/Seminorm.lean b/Mathlib/Analysis/Seminorm.lean index 925181a5acb12c..5b85fdc6f4f9dd 100644 --- a/Mathlib/Analysis/Seminorm.lean +++ b/Mathlib/Analysis/Seminorm.lean @@ -93,7 +93,7 @@ def Seminorm.ofSMulLE [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] (f : E rw [inv_mul_cancel_left₀ (norm_ne_zero_iff.mpr h)] specialize smul_le r⁻¹ (r • x) rw [norm_inv] at smul_le - convert smul_le + convert! smul_le simp [h] end Of @@ -1015,7 +1015,7 @@ variable [Module ℝ E] [IsScalarTower ℝ 𝕜 E] (p : Seminorm 𝕜 E) (x : E) /-- Seminorm-balls are convex. -/ theorem convex_ball : Convex ℝ (ball p x r) := by - convert (p.convexOn.translate_left (-x)).convex_lt r + convert! (p.convexOn.translate_left (-x)).convex_lt r ext y rw [preimage_univ, sep_univ, p.mem_ball, sub_eq_add_neg] rfl diff --git a/Mathlib/Analysis/SpecialFunctions/ArithmeticGeometricMean.lean b/Mathlib/Analysis/SpecialFunctions/ArithmeticGeometricMean.lean index 19faece604b370..491d320e82f600 100644 --- a/Mathlib/Analysis/SpecialFunctions/ArithmeticGeometricMean.lean +++ b/Mathlib/Analysis/SpecialFunctions/ArithmeticGeometricMean.lean @@ -243,7 +243,7 @@ lemma agm_eq_agm_agmSequences_fst_agmSequences_snd (n : ℕ) : refine tendsto_nhds_unique ?_ tendsto_agmSequences_snd_agm have key := @tendsto_agmSequences_snd_agm x y rw [← tendsto_add_atTop_iff_nat (n + 1)] at key - convert key using 2 with m + convert! key using 2 with m simp_rw [agmSequences, Prod.mk.eta, ← iterate_add_apply, add_right_comm] lemma agm_eq_agm_gm_am : agm x y = agm (sqrt (x * y)) ((x + y) / 2) := by diff --git a/Mathlib/Analysis/SpecialFunctions/Arsinh.lean b/Mathlib/Analysis/SpecialFunctions/Arsinh.lean index a8f3ac3f434ce4..69b898bf6ee3fc 100644 --- a/Mathlib/Analysis/SpecialFunctions/Arsinh.lean +++ b/Mathlib/Analysis/SpecialFunctions/Arsinh.lean @@ -158,8 +158,9 @@ theorem arsinh_neg_iff : arsinh x < 0 ↔ x < 0 := lt_iff_lt_of_le_iff_le arsinh_nonneg_iff theorem hasStrictDerivAt_arsinh (x : ℝ) : HasStrictDerivAt arsinh (√(1 + x ^ 2))⁻¹ x := by - convert sinhHomeomorph.toOpenPartialHomeomorph.hasStrictDerivAt_symm (mem_univ x) (cosh_pos _).ne' - (hasStrictDerivAt_sinh _) using 2 + convert! + sinhHomeomorph.toOpenPartialHomeomorph.hasStrictDerivAt_symm (mem_univ x) (cosh_pos _).ne' + (hasStrictDerivAt_sinh _) using 2 exact (cosh_arsinh _).symm theorem hasDerivAt_arsinh (x : ℝ) : HasDerivAt arsinh (√(1 + x ^ 2))⁻¹ x := diff --git a/Mathlib/Analysis/SpecialFunctions/Bernstein.lean b/Mathlib/Analysis/SpecialFunctions/Bernstein.lean index 9dda84b3391df9..30d5dbaae35c12 100644 --- a/Mathlib/Analysis/SpecialFunctions/Bernstein.lean +++ b/Mathlib/Analysis/SpecialFunctions/Bernstein.lean @@ -112,7 +112,7 @@ theorem probability (n : ℕ) (x : I) : (∑ k : Fin (n + 1), bernstein n k x) = theorem variance {n : ℕ} (hn : n ≠ 0) (x : I) : (∑ k : Fin (n + 1), (x - k/ₙ : ℝ) ^ 2 * bernstein n k x) = (x : ℝ) * (1 - x) / n := by - convert congr(Polynomial.aeval (x : ℝ) $(bernsteinPolynomial.variance ℝ n) / n ^ 2) using 1 + convert! congr(Polynomial.aeval (x : ℝ) $(bernsteinPolynomial.variance ℝ n) / n ^ 2) using 1 · simp only [z, bernstein_apply, nsmul_eq_mul, bernsteinPolynomial, Finset.sum_range, map_sum, Polynomial.coe_aeval_eq_eval, Polynomial.eval_mul, Polynomial.eval_pow, Polynomial.eval_sub, Polynomial.eval_natCast, Polynomial.eval_X, Polynomial.eval_one] diff --git a/Mathlib/Analysis/SpecialFunctions/BinaryEntropy.lean b/Mathlib/Analysis/SpecialFunctions/BinaryEntropy.lean index 0cd279e890e3a8..5a54ece56f0992 100644 --- a/Mathlib/Analysis/SpecialFunctions/BinaryEntropy.lean +++ b/Mathlib/Analysis/SpecialFunctions/BinaryEntropy.lean @@ -282,7 +282,7 @@ private lemma tendsto_log_one_sub_sub_log_nhdsLT_one_atBot : have : MapsTo ((1 : ℝ) - ·) (Iio 1) (Ioi 0) := by intro p hx simp_all only [mem_Iio, mem_Ioi, sub_pos] - convert ContinuousWithinAt.tendsto_nhdsWithin (x := (1 : ℝ)) contF.continuousWithinAt this + convert! ContinuousWithinAt.tendsto_nhdsWithin (x := (1 : ℝ)) contF.continuousWithinAt this exact Eq.symm (sub_eq_zero_of_eq rfl) · have h₁ : (1 : ℝ) - (2 : ℝ)⁻¹ < 1 := by norm_num filter_upwards [Ico_mem_nhdsLT h₁] with p hx @@ -384,7 +384,7 @@ lemma qaryEntropy_strictMonoOn (qLe2 : 2 ≤ q) : · simp_all only [mem_Ioi, mul_pos_iff_of_pos_left, show 0 < (q : ℝ) - 1 by linarith] · have qpos : 0 < (q : ℝ) := by positivity have : q * p < q - 1 := by - convert mul_lt_mul_of_pos_left hp.2 qpos using 1 + convert! mul_lt_mul_of_pos_left hp.2 qpos using 1 simp only [mul_sub, mul_one, isUnit_iff_ne_zero, ne_eq, ne_of_gt qpos, not_false_eq_true, IsUnit.mul_inv_cancel] linarith @@ -426,7 +426,7 @@ lemma binEntropy_strictMonoOn : StrictMonoOn binEntropy (Icc 0 2⁻¹) := by /-- Binary entropy is strictly decreasing in interval [1/2, 1]. -/ lemma binEntropy_strictAntiOn : StrictAntiOn binEntropy (Icc 2⁻¹ 1) := by rw [show (Icc (2⁻¹ : ℝ) 1) = Icc (1 / 2) 1 by norm_num, ← qaryEntropy_two] - convert qaryEntropy_strictAntiOn (by rfl) using 1 + convert! qaryEntropy_strictAntiOn (by rfl) using 1 norm_num /-! ### Strict concavity of entropy -/ diff --git a/Mathlib/Analysis/SpecialFunctions/Complex/Arctan.lean b/Mathlib/Analysis/SpecialFunctions/Complex/Arctan.lean index 8087dc3e00f567..c21a3ec5615687 100644 --- a/Mathlib/Analysis/SpecialFunctions/Complex/Arctan.lean +++ b/Mathlib/Analysis/SpecialFunctions/Complex/Arctan.lean @@ -128,7 +128,7 @@ theorem hasSum_arctan {z : ℂ} (hz : ‖z‖ < 1) : simp_rw [← mul_comm 2 _] at this refine this.prod_fiberwise fun k => ?_ dsimp only - convert hasSum_fintype (_ : Fin 2 → ℂ) using 1 + convert! hasSum_fintype (_ : Fin 2 → ℂ) using 1 rw [Fin.sum_univ_two, Fin.val_zero, Fin.val_one, Odd.neg_one_pow (n := 2 * k + 0 + 1) (by simp), neg_add_cancel, zero_mul, zero_div, mul_zero, zero_add, show 2 * k + 1 + 1 = 2 * (k + 1) by ring, Even.neg_one_pow (n := 2 * (k + 1)) (by simp), diff --git a/Mathlib/Analysis/SpecialFunctions/Complex/Arg.lean b/Mathlib/Analysis/SpecialFunctions/Complex/Arg.lean index 4ac8e9707dacdb..f1e483709208a3 100644 --- a/Mathlib/Analysis/SpecialFunctions/Complex/Arg.lean +++ b/Mathlib/Analysis/SpecialFunctions/Complex/Arg.lean @@ -111,12 +111,13 @@ theorem arg_cos_add_sin_mul_I {θ : ℝ} (hθ : θ ∈ Set.Ioc (-π) π) : arg ( rw [← one_mul (_ + _), ← ofReal_one, arg_mul_cos_add_sin_mul_I zero_lt_one hθ] theorem arg_exp (z : ℂ) : arg (exp z) = toIocMod Real.two_pi_pos (-π) z.im := by - convert arg_mul_cos_add_sin_mul_I (Real.exp_pos z.re) - (θ := toIocMod Real.two_pi_pos (-π) z.im) _ using 1 + convert! + arg_mul_cos_add_sin_mul_I (Real.exp_pos z.re) (θ := toIocMod Real.two_pi_pos (-π) z.im) _ + using 1 · rw [← exp_mul_I, ofReal_exp, toIocMod] push_cast rw [exp_mul_I_periodic.sub_zsmul_eq, ← exp_add, re_add_im] - · convert toIocMod_mem_Ioc .. + · convert! toIocMod_mem_Ioc .. ring lemma arg_exp_mul_I (θ : ℝ) : @@ -335,7 +336,7 @@ lemma norm_eq_one_iff' : ‖x‖ = 1 ↔ ∃ θ ∈ Set.Ioc (-π) π, exp (θ * constructor · rintro ⟨θ, rfl⟩ refine ⟨toIocMod (mul_pos two_pos Real.pi_pos) (-π) θ, ?_, ?_⟩ - · convert toIocMod_mem_Ioc _ _ _ + · convert! toIocMod_mem_Ioc _ _ _ ring · rw [eq_sub_of_add_eq <| toIocMod_add_toIocDiv_zsmul _ _ θ, ofReal_sub, ofReal_zsmul, ofReal_mul, ofReal_ofNat, exp_mul_I_periodic.sub_zsmul_eq] @@ -486,7 +487,8 @@ theorem arg_cos_add_sin_mul_I_coe_angle (θ : Real.Angle) : theorem arg_mul_coe_angle {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) : (arg (x * y) : Real.Angle) = arg x + arg y := by - convert arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (norm_pos_iff.mpr hx) (norm_pos_iff.mpr hy)) + convert! + arg_mul_cos_add_sin_mul_I_coe_angle (mul_pos (norm_pos_iff.mpr hx) (norm_pos_iff.mpr hy)) (arg x + arg y : Real.Angle) using 3 simp_rw [← Real.Angle.coe_add, Real.Angle.sin_coe, Real.Angle.cos_coe, ofReal_cos, ofReal_sin, cos_add_sin_I, ofReal_add, add_mul, exp_add, ofReal_mul] @@ -602,9 +604,11 @@ theorem tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re have : ∀ᶠ x : ℂ in 𝓝 z, x.re < 0 := continuous_re.tendsto z (gt_mem_nhds hre) filter_upwards [self_mem_nhdsWithin, mem_nhdsWithin_of_mem_nhds this] with _ him hre rw [arg, if_neg hre.not_ge, if_neg him.not_ge] - convert (Real.continuousAt_arcsin.comp_continuousWithinAt - ((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div - continuous_norm.continuousWithinAt _)).sub_const π using 1 + convert! + (Real.continuousAt_arcsin.comp_continuousWithinAt + ((continuous_im.continuousAt.comp_continuousWithinAt continuousWithinAt_neg).div + continuous_norm.continuousWithinAt _)).sub_const + π using 1 · simp [him] · lift z to ℝ using him simpa using hre.ne diff --git a/Mathlib/Analysis/SpecialFunctions/Complex/Circle.lean b/Mathlib/Analysis/SpecialFunctions/Complex/Circle.lean index 0d08a7c0d9ab8a..6bca65ccb25844 100644 --- a/Mathlib/Analysis/SpecialFunctions/Complex/Circle.lean +++ b/Mathlib/Analysis/SpecialFunctions/Complex/Circle.lean @@ -394,7 +394,7 @@ open AddCircle theorem Circle.isAddQuotientCoveringMap_exp : IsAddQuotientCoveringMap exp (AddSubgroup.zmultiples (2 * π)) := by - convert (isAddQuotientCoveringMap_coe _).homeomorph_comp (homeomorphCircle _) + convert! (isAddQuotientCoveringMap_coe _).homeomorph_comp (homeomorphCircle _) on_goal 2 => simp ext; simp [homeomorphCircle_apply, toCircle] @@ -414,10 +414,12 @@ theorem Circle.isQuotientCoveringMap_zpow (n : ℤ) [NeZero n] : refine Topology.IsQuotientMap.isQuotientCoveringMap_of_isDiscrete_ker_monoidHom (f := zpowGroupHom (α := Circle) n) ?_ (Set.Finite.isDiscrete <| .of_preimage ?_ e.surjective) · refine .of_comp e.continuous (continuous_zpow n) ?_ - convert e.isQuotientMap.comp <| IsUnit.isQuotientMap_zsmul (M := ℝ) - (QuotientAddGroup.mk' (AddSubgroup.zmultiples (1 : ℝ))) isQuotientMap_quotient_mk' n hn + convert! + e.isQuotientMap.comp <| + IsUnit.isQuotientMap_zsmul (M := ℝ) (QuotientAddGroup.mk' (AddSubgroup.zmultiples (1 : ℝ))) + isQuotientMap_quotient_mk' n hn ext; simp [zpowGroupHom, e, homeomorphCircle_apply, toCircle_zsmul] - · convert finite_torsion_of_isSMulRegular_int (1 : ℝ) n fun _ ↦ by simp [NeZero.ne] + · convert! finite_torsion_of_isSMulRegular_int (1 : ℝ) n fun _ ↦ by simp [NeZero.ne] ext simp [e, homeomorphCircle_apply, ← toCircle_zsmul, ← (injective_toCircle one_ne_zero).eq_iff] diff --git a/Mathlib/Analysis/SpecialFunctions/Complex/CircleAddChar.lean b/Mathlib/Analysis/SpecialFunctions/Complex/CircleAddChar.lean index 0d93d862f1370d..4f8e207c7027df 100644 --- a/Mathlib/Analysis/SpecialFunctions/Complex/CircleAddChar.lean +++ b/Mathlib/Analysis/SpecialFunctions/Complex/CircleAddChar.lean @@ -5,10 +5,10 @@ Authors: David Loeffler -/ module +public import Mathlib.Analysis.Complex.Polynomial.Basic public import Mathlib.Analysis.SpecialFunctions.Complex.Circle public import Mathlib.NumberTheory.LegendreSymbol.AddCharacter public import Mathlib.RingTheory.RootsOfUnity.AlgebraicallyClosed -public import Mathlib.Topology.Instances.AddCircle.Real /-! # Additive characters valued in the unit circle diff --git a/Mathlib/Analysis/SpecialFunctions/Complex/Log.lean b/Mathlib/Analysis/SpecialFunctions/Complex/Log.lean index 3073de182943f4..4e8f07b53d9af8 100644 --- a/Mathlib/Analysis/SpecialFunctions/Complex/Log.lean +++ b/Mathlib/Analysis/SpecialFunctions/Complex/Log.lean @@ -200,9 +200,9 @@ alias ⟨_, _root_.Set.Countable.preimage_cexp⟩ := countable_preimage_exp theorem tendsto_log_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) : Tendsto log (𝓝[{ z : ℂ | z.im < 0 }] z) (𝓝 <| Real.log ‖z‖ - π * I) := by - convert + convert! (continuous_ofReal.continuousAt.comp_continuousWithinAt - (continuous_norm.continuousWithinAt.log _)).tendsto.add + (continuous_norm.continuousWithinAt.log _)).tendsto.add (((continuous_ofReal.tendsto _).comp <| tendsto_arg_nhdsWithin_im_neg_of_re_neg_of_im_zero hre him).mul tendsto_const_nhds) using 1 @@ -212,9 +212,9 @@ theorem tendsto_log_nhdsWithin_im_neg_of_re_neg_of_im_zero {z : ℂ} (hre : z.re theorem continuousWithinAt_log_of_re_neg_of_im_zero {z : ℂ} (hre : z.re < 0) (him : z.im = 0) : ContinuousWithinAt log { z : ℂ | 0 ≤ z.im } z := by - convert + convert! (continuous_ofReal.continuousAt.comp_continuousWithinAt - (continuous_norm.continuousWithinAt.log _)).tendsto.add + (continuous_norm.continuousWithinAt.log _)).tendsto.add ((continuous_ofReal.continuousAt.comp_continuousWithinAt <| continuousWithinAt_arg_of_re_neg_of_im_zero hre him).mul tendsto_const_nhds) using 1 diff --git a/Mathlib/Analysis/SpecialFunctions/Complex/LogBounds.lean b/Mathlib/Analysis/SpecialFunctions/Complex/LogBounds.lean index cf3c8c709aa0a7..6e8b5e3d37582d 100644 --- a/Mathlib/Analysis/SpecialFunctions/Complex/LogBounds.lean +++ b/Mathlib/Analysis/SpecialFunctions/Complex/LogBounds.lean @@ -10,6 +10,8 @@ public import Mathlib.Analysis.SpecialFunctions.Integrals.Basic public import Mathlib.Analysis.Calculus.Deriv.Shift public import Mathlib.Analysis.SpecificLimits.RCLike +import Mathlib.Analysis.SpecialFunctions.Complex.LogDeriv + /-! # Estimates for the complex logarithm @@ -42,9 +44,11 @@ open intervalIntegral in /-- Represent `log (1 + z)` as an integral over the unit interval -/ lemma log_eq_integral {z : ℂ} (hz : 1 + z ∈ slitPlane) : log (1 + z) = z * ∫ (t : ℝ) in (0 : ℝ)..1, (1 + t • z)⁻¹ := by - convert (integral_unitInterval_deriv_eq_sub (continuousOn_one_add_mul_inv hz) - (fun _ ht ↦ hasDerivAt_log <| - StarConvex.add_smul_mem starConvex_one_slitPlane hz ht.1 ht.2)).symm using 1 + convert! + (integral_unitInterval_deriv_eq_sub (continuousOn_one_add_mul_inv hz) + (fun _ ht ↦ + hasDerivAt_log <| + StarConvex.add_smul_mem starConvex_one_slitPlane hz ht.1 ht.2)).symm using 1 simp only [log_one, sub_zero] /-- Represent `log (1 - z)⁻¹` as an integral over the unit interval -/ @@ -52,7 +56,7 @@ lemma log_inv_eq_integral {z : ℂ} (hz : 1 - z ∈ slitPlane) : log (1 - z)⁻¹ = z * ∫ (t : ℝ) in (0 : ℝ)..1, (1 - t • z)⁻¹ := by rw [sub_eq_add_neg 1 z] at hz ⊢ rw [log_inv _ <| slitPlane_arg_ne_pi hz, neg_eq_iff_eq_neg, ← neg_mul] - convert log_eq_integral hz using 5 + convert! log_eq_integral hz using 5 rw [sub_eq_add_neg, smul_neg] /-! @@ -90,9 +94,9 @@ lemma hasDerivAt_logTaylor (n : ℕ) (z : ℂ) : simp only [mul_div_assoc] have : HasDerivAt (fun x : ℂ ↦ (x ^ (n + 1) / (n + 1))) (z ^ n) z := by simp_rw [div_eq_mul_inv] - convert HasDerivAt.mul_const (hasDerivAt_pow (n + 1) z) (((n : ℂ) + 1)⁻¹) using 1 + convert! HasDerivAt.mul_const (hasDerivAt_pow (n + 1) z) (((n : ℂ) + 1)⁻¹) using 1 simp [field] - convert HasDerivAt.const_mul _ this using 2 + convert! HasDerivAt.const_mul _ this using 2 ring /-! @@ -101,7 +105,7 @@ lemma hasDerivAt_logTaylor (n : ℕ) (z : ℂ) : lemma hasDerivAt_log_sub_logTaylor (n : ℕ) {z : ℂ} (hz : 1 + z ∈ slitPlane) : HasDerivAt (fun z : ℂ ↦ log (1 + z) - logTaylor (n + 1) z) ((-z) ^ n * (1 + z)⁻¹) z := by - convert ((hasDerivAt_log hz).comp_const_add 1 z).sub (hasDerivAt_logTaylor n z) using 1 + convert! ((hasDerivAt_log hz).comp_const_add 1 z).sub (hasDerivAt_logTaylor n z) using 1 have hz' : -z ≠ 1 := by intro H rw [neg_eq_iff_eq_neg] at H @@ -123,7 +127,7 @@ lemma norm_one_add_mul_inv_le {t : ℝ} (ht : t ∈ Set.Icc 0 1) {z : ℂ} (hz : rw [norm_mul, Complex.norm_of_nonneg ht.1] _ ≤ ‖1 + t * z‖ := by rw [← norm_neg (t * z), ← sub_neg_eq_add] - convert norm_sub_norm_le 1 (-(t * z)) + convert! norm_sub_norm_le 1 (-(t * z)) exact norm_one.symm lemma integrable_pow_mul_norm_one_add_mul_inv (n : ℕ) {z : ℂ} (hz : ‖z‖ < 1) : @@ -151,7 +155,7 @@ lemma norm_log_sub_logTaylor_le (n : ℕ) {z : ℂ} (hz : ‖z‖ < 1) : exact (Continuous.continuousOn (by fun_prop)).mul <| continuousOn_one_add_mul_inv <| mem_slitPlane_of_norm_lt_one hz have H : f z = z * ∫ t in (0 : ℝ)..1, (-(t * z)) ^ n * (1 + t * z)⁻¹ := by - convert (integral_unitInterval_deriv_eq_sub hcont hderiv).symm using 1 + convert! (integral_unitInterval_deriv_eq_sub hcont hderiv).symm using 1 · simp only [f, zero_add, add_zero, log_one, logTaylor_at_zero, sub_self, sub_zero] · simp only [f', real_smul, zero_add, smul_eq_mul] @@ -175,7 +179,7 @@ lemma norm_log_sub_logTaylor_le (n : ℕ) {z : ℂ} (hz : ‖z‖ < 1) : /-- The difference `log (1+z) - z` is bounded by `‖z‖^2/(2*(1-‖z‖))` when `‖z‖ < 1`. -/ lemma norm_log_one_add_sub_self_le {z : ℂ} (hz : ‖z‖ < 1) : ‖log (1 + z) - z‖ ≤ ‖z‖ ^ 2 * (1 - ‖z‖)⁻¹ / 2 := by - convert norm_log_sub_logTaylor_le 1 hz using 2 + convert! norm_log_sub_logTaylor_le 1 hz using 2 · simp [logTaylor_succ, logTaylor_zero, sub_eq_add_neg] · norm_num @@ -197,7 +201,7 @@ lemma log_sub_logTaylor_isBigO (n : ℕ) : open scoped Topology in lemma log_sub_self_isBigO : (fun z ↦ log (1 + z) - z) =O[𝓝 0] fun z ↦ z ^ 2 := by - convert log_sub_logTaylor_isBigO 1 + convert! log_sub_logTaylor_isBigO 1 simp [logTaylor_succ, logTaylor_zero] lemma norm_log_one_add_le {z : ℂ} (hz : ‖z‖ < 1) : @@ -229,12 +233,12 @@ lemma norm_log_one_sub_inv_add_logTaylor_neg_le (n : ℕ) {z : ℂ} (hz : ‖z rw [sub_eq_add_neg, log_inv _ <| slitPlane_arg_ne_pi <| mem_slitPlane_of_norm_lt_one <| (norm_neg z).symm ▸ hz, ← sub_neg_eq_add, ← neg_sub', norm_neg] - convert norm_log_sub_logTaylor_le n <| (norm_neg z).symm ▸ hz using 4 <;> rw [norm_neg] + convert! norm_log_sub_logTaylor_le n <| (norm_neg z).symm ▸ hz using 4 <;> rw [norm_neg] /-- The difference `log (1-z)⁻¹ - z` is bounded by `‖z‖^2/(2*(1-‖z‖))` when `‖z‖ < 1`. -/ lemma norm_log_one_sub_inv_sub_self_le {z : ℂ} (hz : ‖z‖ < 1) : ‖log (1 - z)⁻¹ - z‖ ≤ ‖z‖ ^ 2 * (1 - ‖z‖)⁻¹ / 2 := by - convert norm_log_one_sub_inv_add_logTaylor_neg_le 1 hz using 2 + convert! norm_log_one_sub_inv_add_logTaylor_neg_le 1 hz using 2 · simp [logTaylor_succ, logTaylor_zero, sub_eq_add_neg] · norm_num @@ -270,7 +274,7 @@ lemma hasSum_taylorSeries_log {z : ℂ} (hz : ‖z‖ < 1) : · linarith exact (isBigOWith_of_le' atTop this).isBigO refine IsBigO.trans_isLittleO H ?_ - convert isLittleO_pow_pow_of_lt_left (norm_nonneg z) hz + convert! isLittleO_pow_pow_of_lt_left (norm_nonneg z) hz exact (one_pow _).symm /-- The series `∑ z^n/n` converges to `-log (1-z)` on the open unit disk. -/ @@ -278,7 +282,7 @@ lemma hasSum_taylorSeries_neg_log {z : ℂ} (hz : ‖z‖ < 1) : HasSum (fun n : ℕ ↦ z ^ n / n) (-log (1 - z)) := by conv => enter [1, n]; rw [← neg_neg (z ^ n / n)] refine HasSum.neg ?_ - convert hasSum_taylorSeries_log (z := -z) (norm_neg z ▸ hz) using 2 with n + convert! hasSum_taylorSeries_log (z := -z) (norm_neg z ▸ hz) using 2 with n rcases n.eq_zero_or_pos with rfl | hn · simp simp [field, pow_add, ← mul_pow] @@ -365,7 +369,7 @@ lemma tendsto_pow_exp_of_isLittleO_sub_add_div {f : ℕ → ℂ} (t : ℂ) Tendsto (fun n ↦ f n ^ n) atTop (𝓝 (exp t)) := by rw [show (fun n ↦ f n ^ n) = (fun n ↦ (1 + (f n - 1)) ^ n) by ext; simp] refine tendsto_one_add_pow_exp_of_tendsto (tendsto_sub_nhds_zero_iff.1 ?_) - convert hf.tendsto_inv_smul_nhds_zero.congr' ?_ + convert! hf.tendsto_inv_smul_nhds_zero.congr' ?_ filter_upwards [eventually_ne_atTop 0] with n h0 simp field_simp [n.cast_ne_zero.2 h0] diff --git a/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/Rpow/ConjSqrt.lean b/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/Rpow/ConjSqrt.lean index b5b34a11866a91..b9c6cf68f86e3b 100644 --- a/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/Rpow/ConjSqrt.lean +++ b/Mathlib/Analysis/SpecialFunctions/ContinuousFunctionalCalculus/Rpow/ConjSqrt.lean @@ -52,6 +52,8 @@ lemma conjSqrt_le_conjSqrt {c a b : A} (h : a ≤ b) : conjSqrt c a ≤ conjSqrt variable [IsSemitopologicalRing A] [T2Space A] +set_option linter.overlappingInstances false + @[grind =] lemma isStrictlyPositive_conjSqrt_iff (c a : A) (hc : IsStrictlyPositive c := by cfc_tac) : IsStrictlyPositive (conjSqrt c a) ↔ IsStrictlyPositive a := by diff --git a/Mathlib/Analysis/SpecialFunctions/Elliptic/Weierstrass.lean b/Mathlib/Analysis/SpecialFunctions/Elliptic/Weierstrass.lean index 28058fe0e8c107..4a0abb1a736926 100644 --- a/Mathlib/Analysis/SpecialFunctions/Elliptic/Weierstrass.lean +++ b/Mathlib/Analysis/SpecialFunctions/Elliptic/Weierstrass.lean @@ -126,9 +126,9 @@ lemma isClosed_lattice : IsClosed (X := ℂ) L.lattice := (inferInstanceAs (DiscreteTopology L.lattice)) lemma isClosed_of_subset_lattice {s : Set ℂ} (hs : s ⊆ L.lattice) : IsClosed s := by - convert L.isClosed_lattice.isClosedMap_subtype_val _ - (isClosed_discrete (α := L.lattice) ((↑) ⁻¹' s)) - convert Set.image_preimage_eq_inter_range.symm using 1 + convert! + L.isClosed_lattice.isClosedMap_subtype_val _ (isClosed_discrete (α := L.lattice) ((↑) ⁻¹' s)) + convert! Set.image_preimage_eq_inter_range.symm using 1 simpa lemma isOpen_compl_lattice_diff {s : Set ℂ} : IsOpen (L.lattice \ s)ᶜ := @@ -287,7 +287,7 @@ lemma weierstrassPExcept_of_notMem (l₀ : ℂ) (hl : l₀ ∉ L.lattice) : lemma hasSumLocallyUniformly_weierstrassP : HasSumLocallyUniformly (fun (l : L.lattice) (z : ℂ) ↦ 1 / (z - ↑l) ^ 2 - 1 / l ^ 2) ℘[L] := by - convert L.hasSumLocallyUniformly_weierstrassPExcept (L.ω₁ / 2) using 3 with l + convert! L.hasSumLocallyUniformly_weierstrassPExcept (L.ω₁ / 2) using 3 with l · rw [if_neg]; exact fun e ↦ L.ω₁_div_two_notMem_lattice (e ▸ l.2) · rw [L.weierstrassPExcept_of_notMem _ L.ω₁_div_two_notMem_lattice] @@ -298,7 +298,7 @@ lemma hasSum_weierstrassP (z : ℂ) : lemma differentiableOn_weierstrassP : DifferentiableOn ℂ ℘[L] L.latticeᶜ := by rw [← L.weierstrassPExcept_of_notMem _ L.ω₁_div_two_notMem_lattice] - convert L.differentiableOn_weierstrassPExcept _ + convert! L.differentiableOn_weierstrassPExcept _ simp [L.ω₁_div_two_notMem_lattice] @[simp] @@ -538,7 +538,7 @@ lemma derivWeierstrassPExcept_of_notMem (l₀ : ℂ) (hl : l₀ ∉ L.lattice) : lemma hasSumLocallyUniformly_derivWeierstrassP : HasSumLocallyUniformly (fun (l : L.lattice) (z : ℂ) ↦ - 2 / (z - l) ^ 3) ℘'[L] := by - convert L.hasSumLocallyUniformly_derivWeierstrassPExcept (L.ω₁ / 2) using 3 with l z + convert! L.hasSumLocallyUniformly_derivWeierstrassPExcept (L.ω₁ / 2) using 3 with l z · rw [if_neg, neg_div]; exact fun e ↦ L.ω₁_div_two_notMem_lattice (e ▸ l.2) · rw [L.derivWeierstrassPExcept_of_notMem _ L.ω₁_div_two_notMem_lattice] @@ -549,7 +549,7 @@ lemma hasSum_derivWeierstrassP (z : ℂ) : lemma differentiableOn_derivWeierstrassP : DifferentiableOn ℂ ℘'[L] L.latticeᶜ := by rw [← L.derivWeierstrassPExcept_of_notMem _ L.ω₁_div_two_notMem_lattice] - convert L.differentiableOn_derivWeierstrassPExcept _ + convert! L.differentiableOn_derivWeierstrassPExcept _ simp [L.ω₁_div_two_notMem_lattice] @[simp] @@ -734,8 +734,10 @@ lemma hasFPowerSeriesOnBall_weierstrassPExcept (l₀ x : ℂ) (r : NNReal) (hr0 HasFPowerSeriesOnBall ℘[L - l₀] (L.weierstrassPExceptSeries l₀ x) x r := by constructor · apply FormalMultilinearSeries.le_radius_of_tendsto (l := 0) - convert tendsto_norm.comp (L.weierstrassPExceptSeries_hasSum l₀ (x + r) x - ?_).summable.tendsto_atTop_zero using 2 with i + convert! + tendsto_norm.comp + (L.weierstrassPExceptSeries_hasSum l₀ (x + r) x ?_).summable.tendsto_atTop_zero using + 2 with i · simp · simp · intro l hl @@ -749,7 +751,7 @@ lemma hasFPowerSeriesOnBall_weierstrassPExcept (l₀ x : ℂ) (r : NNReal) (hr0 have A (l : ↥L.lattice) (hl : ↑l ≠ l₀) : r < ‖↑l - x‖ := by simpa [-Metric.mem_closedBall, mem_closedBall_iff_norm] using Set.subset_compl_comm.mp hr ⟨l.2, hl⟩ - convert this (fun l hl ↦ hz.trans (A l hl)) with i + convert! this (fun l hl ↦ hz.trans (A l hl)) with i rw [weierstrassPExceptSeries, FormalMultilinearSeries.ofScalars_apply_eq, FormalMultilinearSeries.coeff_ofScalars, smul_eq_mul] @@ -797,7 +799,7 @@ lemma hasFPowerSeriesOnBall_derivWeierstrassPExcept (l₀ x : ℂ) (r : NNReal) refine .congr ?_ ((L.eqOn_deriv_weierstrassPExcept_derivWeierstrassPExcept l₀).mono (.trans ?_ hr)) · have := (L.hasFPowerSeriesOnBall_weierstrassPExcept l₀ x r hr0 hr).fderiv - convert (ContinuousLinearMap.apply ℂ ℂ (1 : ℂ)).comp_hasFPowerSeriesOnBall this + convert! (ContinuousLinearMap.apply ℂ ℂ (1 : ℂ)).comp_hasFPowerSeriesOnBall this ext n simp [weierstrassPExceptSeries, derivWeierstrassPExceptSeries] ring @@ -1045,7 +1047,7 @@ private lemma analyticAt_relation (x : ℂ) : AnalyticAt ℂ L.relation x := by · lift x to L.lattice using hx have := L.analyticAt_relation_zero rw [← sub_self x.1] at this - convert this.comp (f := (· - x.1)) (by fun_prop) + convert! this.comp (f := (· - x.1)) (by fun_prop) ext a simp · have : AnalyticAt ℂ (fun z ↦ ℘'[L] z ^ 2 - 4 * ℘[L] z ^ 3 + L.g₂ * ℘[L] z + L.g₃) x := by diff --git a/Mathlib/Analysis/SpecialFunctions/Exp.lean b/Mathlib/Analysis/SpecialFunctions/Exp.lean index 23fe81ee128f93..26a805eee4d867 100644 --- a/Mathlib/Analysis/SpecialFunctions/Exp.lean +++ b/Mathlib/Analysis/SpecialFunctions/Exp.lean @@ -81,7 +81,7 @@ lemma exp_sub_sum_range_isBigO_pow (n : ℕ) : · refine .of_bound (n.succ / (n ! * n)) ?_ rw [NormedAddGroup.nhds_zero_basis_norm_lt.eventually_iff] refine ⟨1, one_pos, fun x hx ↦ ?_⟩ - convert exp_bound hx.out.le hn using 1 + convert! exp_bound hx.out.le hn using 1 simp [field] lemma exp_sub_sum_range_succ_isLittleO_pow (n : ℕ) : @@ -224,7 +224,7 @@ theorem tendsto_exp_neg_atTop_nhds_zero : Tendsto (fun x => exp (-x)) atTop ( /-- The real exponential function tends to `1` at `0`. -/ theorem tendsto_exp_nhds_zero_nhds_one : Tendsto exp (𝓝 0) (𝓝 1) := by - convert continuous_exp.tendsto 0 + convert! continuous_exp.tendsto 0 simp theorem tendsto_exp_atBot : Tendsto exp atBot (𝓝 0) := @@ -288,12 +288,12 @@ theorem tendsto_div_pow_mul_exp_add_atTop (b c : ℝ) (n : ℕ) (hb : 0 ≠ b) : Tendsto (fun x => x ^ n / (b * exp x + c)) atTop (𝓝 0) := by have H : ∀ d e, 0 < d → Tendsto (fun x : ℝ => x ^ n / (d * exp x + e)) atTop (𝓝 0) := by intro b' c' h - convert (tendsto_mul_exp_add_div_pow_atTop b' c' n h).inv_tendsto_atTop using 1 + convert! (tendsto_mul_exp_add_div_pow_atTop b' c' n h).inv_tendsto_atTop using 1 ext x simp rcases lt_or_gt_of_ne hb with h | h · exact H b c h - · convert (H (-b) (-c) (neg_pos.mpr h)).neg using 1 + · convert! (H (-b) (-c) (neg_pos.mpr h)).neg using 1 · ext x field_simp rw [← neg_add (b * exp x) c, div_neg, neg_neg] diff --git a/Mathlib/Analysis/SpecialFunctions/Exponential.lean b/Mathlib/Analysis/SpecialFunctions/Exponential.lean index 7df936a7bdfcd1..4032b7535520ec 100644 --- a/Mathlib/Analysis/SpecialFunctions/Exponential.lean +++ b/Mathlib/Analysis/SpecialFunctions/Exponential.lean @@ -71,7 +71,7 @@ variable {𝕂 𝔸 : Type*} [NontriviallyNormedField 𝕂] [NormedRing 𝔸] [C `1 : 𝔸 →L[𝕂] 𝔸` at zero, as long as it converges on a neighborhood of zero. -/ theorem hasStrictFDerivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝔸).radius) : HasStrictFDerivAt exp (1 : 𝔸 →L[𝕂] 𝔸) 0 := by - convert (hasFPowerSeriesAt_exp_zero_of_radius_pos h).hasStrictFDerivAt + convert! (hasFPowerSeriesAt_exp_zero_of_radius_pos h).hasStrictFDerivAt ext x change x = expSeries 𝕂 𝔸 1 fun _ => x simp [expSeries_apply_eq, Nat.factorial] @@ -286,7 +286,7 @@ theorem hasFDerivAt_exp_smul_const_of_mem_ball' (x : 𝔸) (t : 𝕊) (htx : t • x ∈ Metric.eball (0 : 𝔸) (expSeries 𝕂 𝔸).radius) : HasFDerivAt (fun u : 𝕊 => exp (u • x)) (((1 : 𝕊 →L[𝕂] 𝕊).smulRight x).smulRight (exp (t • x))) t := by - convert hasFDerivAt_exp_smul_const_of_mem_ball 𝕂 _ _ htx using 1 + convert! hasFDerivAt_exp_smul_const_of_mem_ball 𝕂 _ _ htx using 1 ext t' change Commute (t' • x) (exp (t • x)) exact (((Commute.refl x).smul_left t').smul_right t).exp_right @@ -307,7 +307,7 @@ theorem hasStrictFDerivAt_exp_smul_const_of_mem_ball' (x : 𝔸) (t : 𝕊) HasStrictFDerivAt (fun u : 𝕊 => exp (u • x)) (((1 : 𝕊 →L[𝕂] 𝕊).smulRight x).smulRight (exp (t • x))) t := by let ⟨_, _⟩ := analyticAt_exp_of_mem_ball (t • x) htx - convert hasStrictFDerivAt_exp_smul_const_of_mem_ball 𝕂 _ _ htx using 1 + convert! hasStrictFDerivAt_exp_smul_const_of_mem_ball 𝕂 _ _ htx using 1 ext t' change Commute (t' • x) (exp (t • x)) exact (((Commute.refl x).smul_left t').smul_right t).exp_right diff --git a/Mathlib/Analysis/SpecialFunctions/Gamma/Basic.lean b/Mathlib/Analysis/SpecialFunctions/Gamma/Basic.lean index 913835f73bcfbb..bf6ca286384c5b 100644 --- a/Mathlib/Analysis/SpecialFunctions/Gamma/Basic.lean +++ b/Mathlib/Analysis/SpecialFunctions/Gamma/Basic.lean @@ -158,7 +158,7 @@ private theorem Gamma_integrand_intervalIntegrable (s : ℂ) {X : ℝ} (hs : 0 < private theorem Gamma_integrand_deriv_integrable_A {s : ℂ} (hs : 0 < s.re) {X : ℝ} (hX : 0 ≤ X) : IntervalIntegrable (fun x => -((-x).exp * x ^ s) : ℝ → ℂ) volume 0 X := by - convert (Gamma_integrand_intervalIntegrable (s + 1) _ hX).neg + convert! (Gamma_integrand_intervalIntegrable (s + 1) _ hX).neg · simp only [ofReal_exp, ofReal_neg, add_sub_cancel_right]; rfl · simp only [add_re, one_re]; linarith @@ -300,7 +300,7 @@ private theorem Gamma_eq_GammaAux (s : ℂ) (n : ℕ) (h1 : -s.re < ↑n) : Gamm simp only [sub_sub_cancel_left] at i0 refine lt_add_of_lt_of_nonneg i0 ?_ rw [← Nat.cast_zero, Nat.cast_le]; exact Nat.zero_le k - convert (u <| n - ⌊1 - s.re⌋₊).symm; rw [Nat.add_sub_of_le] + convert! (u <| n - ⌊1 - s.re⌋₊).symm; rw [Nat.add_sub_of_le] by_cases h : 0 ≤ 1 - s.re · apply Nat.le_of_lt_succ exact_mod_cast lt_of_le_of_lt (Nat.floor_le h) (by linarith : 1 - s.re < n + 1) @@ -465,7 +465,7 @@ in terms of the Gamma function. -/ lemma integral_rpow_mul_exp_neg_mul_Ioi {a r : ℝ} (ha : 0 < a) (hr : 0 < r) : ∫ t : ℝ in Ioi 0, t ^ (a - 1) * exp (-(r * t)) = (1 / r) ^ a * Gamma a := by rw [← ofReal_inj, ofReal_mul, ← Gamma_ofReal, ofReal_cpow (by positivity), ofReal_div] - convert integral_cpow_mul_exp_neg_mul_Ioi (by rwa [ofReal_re] : 0 < (a : ℂ).re) hr + convert! integral_cpow_mul_exp_neg_mul_Ioi (by rwa [ofReal_re] : 0 < (a : ℂ).re) hr refine integral_ofReal.symm.trans <| setIntegral_congr_fun measurableSet_Ioi (fun t ht ↦ ?_) norm_cast simp_rw [← ofReal_cpow ht.le, RCLike.ofReal_mul, coe_algebraMap] diff --git a/Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean b/Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean index c621c3abf18fd8..fe2b591e75040d 100644 --- a/Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean +++ b/Mathlib/Analysis/SpecialFunctions/Gamma/Beta.lean @@ -80,7 +80,7 @@ theorem betaIntegral_convergent {u v : ℂ} (hu : 0 < re u) (hv : 0 < re v) : (x : ℂ) ^ (u - 1) * (1 - (x : ℂ)) ^ (v - 1) : ℝ → ℂ) volume 0 1 := by refine (betaIntegral_convergent_left hu v).trans ?_ rw [IntervalIntegrable.iff_comp_neg] - convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1 + convert! ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1 · ext1 x conv_lhs => rw [mul_comm] congr 2 <;> · push_cast; ring @@ -170,9 +170,9 @@ theorem betaIntegral_recurrence {u v : ℂ} (hu : 0 < re u) (hv : 0 < re v) : simp_rw [id] at A have B : HasDerivAt (fun y : ℂ => 1 - y) (-1) ↑x := by apply HasDerivAt.const_sub; apply hasDerivAt_id - convert HasDerivAt.comp (↑x) A B using 1 + convert! HasDerivAt.comp (↑x) A B using 1 ring - convert (U.mul V).comp_ofReal using 1 + convert! (U.mul V).comp_ofReal using 1 ring have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub ((betaIntegral_convergent hu' hv).const_mul v) @@ -189,11 +189,11 @@ theorem betaIntegral_recurrence {u v : ℂ} (hu : 0 < re u) (hv : 0 < re v) : rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul, intervalIntegral.integral_const_mul] at int_ev · rw [betaIntegral, betaIntegral, ← sub_eq_zero] - convert int_ev <;> ring + convert! int_ev <;> ring · apply IntervalIntegrable.const_mul - convert betaIntegral_convergent hu hv'; ring + convert! betaIntegral_convergent hu hv'; ring · apply IntervalIntegrable.const_mul - convert betaIntegral_convergent hu' hv; ring + convert! betaIntegral_convergent hu' hv; ring /-- Explicit formula for the Beta function when second argument is a positive integer. -/ theorem betaIntegral_eval_nat_add_one_right {u : ℂ} (hu : 0 < re u) (n : ℕ) : @@ -302,13 +302,16 @@ theorem approx_Gamma_integral_tendsto_Gamma_integral {s : ℂ} (hs : 0 < re s) : exact ⟨hx, hn⟩ · simp_rw [mul_comm] refine (Tendsto.comp (continuous_ofReal.tendsto _) ?_).const_mul _ - convert Real.tendsto_one_add_div_pow_exp (-x) using 1 + convert! Real.tendsto_one_add_div_pow_exp (-x) using 1 ext1 n rw [neg_div, ← sub_eq_add_neg] -- let `convert` identify the remaining goals - convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1) - (Real.GammaIntegral_convergent hs) _ - ((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1 + convert! + tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1) + (Real.GammaIntegral_convergent hs) _ + ((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1 + -- limit of f is the integrand we want + -- limit of f is the integrand we want · ext1 n rw [MeasureTheory.integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : ℝ) _)), @@ -409,13 +412,15 @@ theorem Gamma_mul_Gamma_one_sub (z : ℂ) : Gamma z * Gamma (1 - z) = π / sin ( Complex.Gamma_neg_nat_eq_zero, mul_zero] refine tendsto_nhds_unique ((GammaSeq_tendsto_Gamma z).mul (GammaSeq_tendsto_Gamma <| 1 - z)) ?_ have : ↑π / sin (↑π * z) = 1 * (π / sin (π * z)) := by rw [one_mul] - convert Tendsto.congr' ((eventually_ne_atTop 0).mp (Eventually.of_forall fun n hn => - (GammaSeq_mul z hn).symm)) (Tendsto.mul _ _) - · convert tendsto_natCast_div_add_atTop (1 - z) using 1; ext1 n; rw [add_sub_assoc] + convert! + Tendsto.congr' + ((eventually_ne_atTop 0).mp (Eventually.of_forall fun n hn => (GammaSeq_mul z hn).symm)) + (Tendsto.mul _ _) + · convert! tendsto_natCast_div_add_atTop (1 - z) using 1; ext1 n; rw [add_sub_assoc] · have : ↑π / sin (↑π * z) = 1 / (sin (π * z) / π) := by simp - convert tendsto_const_nhds.div _ (div_ne_zero hs pi_ne) + convert! tendsto_const_nhds.div _ (div_ne_zero hs pi_ne) rw [← tendsto_mul_iff_of_ne_zero tendsto_const_nhds pi_ne, div_mul_cancel₀ _ pi_ne] - convert tendsto_euler_sin_prod z using 1 + convert! tendsto_euler_sin_prod z using 1 ext1 n; rw [mul_comm, ← mul_assoc] /-- The Gamma function does not vanish on `ℂ` (except at non-positive integers, where the function @@ -464,7 +469,7 @@ noncomputable def GammaSeq (s : ℝ) (n : ℕ) := theorem GammaSeq_tendsto_Gamma (s : ℝ) : Tendsto (GammaSeq s) atTop (𝓝 <| Gamma s) := by suffices Tendsto ((↑) ∘ GammaSeq s : ℕ → ℂ) atTop (𝓝 <| Complex.Gamma s) by exact (Complex.continuous_re.tendsto (Complex.Gamma ↑s)).comp this - convert Complex.GammaSeq_tendsto_Gamma s + convert! Complex.GammaSeq_tendsto_Gamma s ext1 n dsimp only [GammaSeq, Function.comp_apply, Complex.GammaSeq] push_cast @@ -543,7 +548,7 @@ theorem Gamma_mul_Gamma_add_half (s : ℂ) : Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * (2 : ℂ) ^ (1 - 2 * s) * ↑(√π) := by suffices (fun z => (Gamma z)⁻¹ * (Gamma (z + 1 / 2))⁻¹) = fun z => (Gamma (2 * z))⁻¹ * (2 : ℂ) ^ (2 * z - 1) / ↑(√π) by - convert congr_arg Inv.inv (congr_fun this s) using 1 + convert! congr_arg Inv.inv (congr_fun this s) using 1 · rw [mul_inv, inv_inv, inv_inv] · rw [div_eq_mul_inv, mul_inv, mul_inv, inv_inv, inv_inv, ← cpow_neg, neg_sub] have h1 : AnalyticOnNhd ℂ (fun z : ℂ => (Gamma z)⁻¹ * (Gamma (z + 1 / 2))⁻¹) univ := by diff --git a/Mathlib/Analysis/SpecialFunctions/Gamma/BohrMollerup.lean b/Mathlib/Analysis/SpecialFunctions/Gamma/BohrMollerup.lean index 53ea0ff4d7ae44..9ecdefb2fc89f5 100644 --- a/Mathlib/Analysis/SpecialFunctions/Gamma/BohrMollerup.lean +++ b/Mathlib/Analysis/SpecialFunctions/Gamma/BohrMollerup.lean @@ -96,10 +96,9 @@ theorem Gamma_mul_add_mul_le_rpow_Gamma_mul_rpow_Gamma {s t a b : ℝ} (hs : 0 < exact continuousAt_rpow_const _ _ (Or.inl (mem_Ioi.mp hx).ne') -- now apply Hölder: rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst] - convert + convert! MeasureTheory.integral_mul_le_Lp_mul_Lq_of_nonneg e (posf' a s) (posf' b t) (f_mem_Lp ha hs) - (f_mem_Lp hb ht) using - 1 + (f_mem_Lp hb ht) using 1 · refine setIntegral_congr_fun measurableSet_Ioi fun x hx => ?_ dsimp only have A : exp (-x) = exp (-a * x) * exp (-b * x) := by @@ -235,7 +234,7 @@ theorem tendsto_logGammaSeq_of_le_one (hf_conv : ConvexOn ℝ (Ioi 0) f) exact Tendsto.sub tendsto_const_nhds (tendsto_log_nat_add_one_sub_log.const_mul _) · filter_upwards with n rw [sub_le_iff_le_add', sub_le_iff_le_add'] - convert le_logGammaSeq hf_conv (@hf_feq) hx hx' n using 1 + convert! le_logGammaSeq hf_conv (@hf_feq) hx hx' n using 1 ring · change ∀ᶠ n : ℕ in atTop, logGammaSeq x n ≤ f x - f 1 filter_upwards [eventually_ne_atTop 0] with n hn using @@ -248,7 +247,7 @@ theorem tendsto_logGammaSeq (hf_conv : ConvexOn ℝ (Ioi 0) f) refine this ⌈x - 1⌉₊ ?_ ?_ · rcases lt_or_ge x 1 with ⟨⟩ · rwa [Nat.ceil_eq_zero.mpr (by linarith : x - 1 ≤ 0), Nat.cast_zero] - · convert Nat.ceil_lt_add_one (by linarith : 0 ≤ x - 1) + · convert! Nat.ceil_lt_add_one (by linarith : 0 ≤ x - 1) abel · rw [← sub_le_iff_le_add]; exact Nat.le_ceil _ intro m @@ -286,7 +285,7 @@ theorem tendsto_logGammaSeq (hf_conv : ConvexOn ℝ (Ioi 0) f) dsimp only [Function.comp_apply] rw [sub_add_cancel, Nat.add_sub_cancel] rw [this] at hm - convert hm.sub (tendsto_log_nat_add_one_sub_log.const_mul x) using 2 + convert! hm.sub (tendsto_log_nat_add_one_sub_log.const_mul x) using 2 · ring · have := hf_feq ((Nat.cast_nonneg m).trans_lt hy) rw [sub_add_cancel] at this @@ -354,9 +353,9 @@ theorem Gamma_strictAntiOn_Ioc : StrictAntiOn Gamma (Ioc 0 1) := Gamma_one.symm ▸ Gamma_three_div_two_lt_one theorem Gamma_strictMonoOn_Ici : StrictMonoOn Gamma (Ici 2) := by - convert - convexOn_Gamma.strictMonoOn (by simp : (0 : ℝ) < 3 / 2) - (by norm_num : (3 / 2 : ℝ) < 2) (Gamma_two.symm ▸ Gamma_three_div_two_lt_one) + convert! + convexOn_Gamma.strictMonoOn (by simp : (0 : ℝ) < 3 / 2) (by norm_num : (3 / 2 : ℝ) < 2) + (Gamma_two.symm ▸ Gamma_three_div_two_lt_one) symm rw [inter_eq_right] exact fun x hx => two_pos.trans_le <| mem_Ici.mp hx @@ -416,15 +415,14 @@ theorem log_doublingGamma_eq : theorem doublingGamma_log_convex_Ioi : ConvexOn ℝ (Ioi (0 : ℝ)) (log ∘ doublingGamma) := by refine (((ConvexOn.add ?_ ?_).add ?_).add_const _).congr log_doublingGamma_eq.symm - · convert - convexOn_log_Gamma.comp_affineMap (DistribSMul.toLinearMap ℝ ℝ (1 / 2 : ℝ)).toAffineMap - using 1 + · convert! + convexOn_log_Gamma.comp_affineMap (DistribSMul.toLinearMap ℝ ℝ (1 / 2 : ℝ)).toAffineMap using 1 · simpa only [zero_div] using (preimage_const_mul_Ioi₀ (0 : ℝ) one_half_pos).symm · ext1 x simp only [LinearMap.coe_toAffineMap, Function.comp_apply, DistribSMul.toLinearMap_apply] rw [smul_eq_mul, mul_comm, mul_one_div] · refine ConvexOn.subset ?_ (Ioi_subset_Ioi <| neg_one_lt_zero.le) (convex_Ioi _) - convert + convert! convexOn_log_Gamma.comp_affineMap ((DistribSMul.toLinearMap ℝ ℝ (1 / 2 : ℝ)).toAffineMap + AffineMap.const ℝ ℝ (1 / 2 : ℝ)) using 1 diff --git a/Mathlib/Analysis/SpecialFunctions/Gamma/Deligne.lean b/Mathlib/Analysis/SpecialFunctions/Gamma/Deligne.lean index b098d210c928d5..fa8d2a794a3389 100644 --- a/Mathlib/Analysis/SpecialFunctions/Gamma/Deligne.lean +++ b/Mathlib/Analysis/SpecialFunctions/Gamma/Deligne.lean @@ -103,7 +103,7 @@ lemma Gammaℝ_residue_zero : Tendsto (fun s ↦ s * Gammaℝ s) (𝓝[≠] 0) ( refine Tendsto.mono_left (ContinuousAt.tendsto ?_) nhdsWithin_le_nhds exact continuousAt_const.mul ((continuousAt_const_cpow (ofReal_ne_zero.mpr pi_ne_zero)).comp (by fun_prop)) - convert mul_one (2 : ℂ) ▸ (h'.mul h) using 2 with z + convert! mul_one (2 : ℂ) ▸ (h'.mul h) using 2 with z rw [Gammaℝ] ring_nf @@ -187,7 +187,7 @@ lemma inv_Gammaℝ_two_sub {s : ℂ} (hs : ∀ (n : ℕ), s ≠ -n) : rcases n with - | m · rwa [Nat.cast_zero, neg_zero] · rw [Ne, sub_eq_iff_eq_add] - convert hs m using 2 + convert! hs m using 2 push_cast ring rw [(by ring : 2 - s = 1 - (s - 1)), inv_Gammaℝ_one_sub h', diff --git a/Mathlib/Analysis/SpecialFunctions/Gamma/Deriv.lean b/Mathlib/Analysis/SpecialFunctions/Gamma/Deriv.lean index f9d6e745bee19c..185a3ff403c56f 100644 --- a/Mathlib/Analysis/SpecialFunctions/Gamma/Deriv.lean +++ b/Mathlib/Analysis/SpecialFunctions/Gamma/Deriv.lean @@ -50,7 +50,7 @@ transform of `log t * exp (-t)`. -/ theorem hasDerivAt_GammaIntegral {s : ℂ} (hs : 0 < s.re) : HasDerivAt GammaIntegral (∫ t : ℝ in Ioi 0, t ^ (s - 1) * (Real.log t * Real.exp (-t))) s := by rw [GammaIntegral_eq_mellin] - convert (mellin_hasDerivAt_of_isBigO_rpow (E := ℂ) _ _ (lt_add_one _) _ hs).2 + convert! (mellin_hasDerivAt_of_isBigO_rpow (E := ℂ) _ _ (lt_add_one _) _ hs).2 · refine (Continuous.continuousOn ?_).locallyIntegrableOn measurableSet_Ioi exact continuous_ofReal.comp (Real.continuous_exp.comp continuous_neg) · rw [← isBigO_norm_left] diff --git a/Mathlib/Analysis/SpecialFunctions/Gamma/Digamma.lean b/Mathlib/Analysis/SpecialFunctions/Gamma/Digamma.lean index 996d69a5ee3317..33d46fb89f36b0 100644 --- a/Mathlib/Analysis/SpecialFunctions/Gamma/Digamma.lean +++ b/Mathlib/Analysis/SpecialFunctions/Gamma/Digamma.lean @@ -8,6 +8,8 @@ module public import Mathlib.Analysis.Meromorphic.Complex public import Mathlib.NumberTheory.Harmonic.GammaDeriv +import Mathlib.Analysis.SpecialFunctions.Complex.LogDeriv + /-! # The digamma function diff --git a/Mathlib/Analysis/SpecialFunctions/Gaussian/FourierTransform.lean b/Mathlib/Analysis/SpecialFunctions/Gaussian/FourierTransform.lean index 640bb373d46507..f2ea3961909028 100644 --- a/Mathlib/Analysis/SpecialFunctions/Gaussian/FourierTransform.lean +++ b/Mathlib/Analysis/SpecialFunctions/Gaussian/FourierTransform.lean @@ -245,7 +245,7 @@ theorem integrable_cexp_neg_sum_mul_add {ι : Type*} [Fintype ι] {b : ι → Integrable (fun (v : ι → ℝ) ↦ cexp (-∑ i, b i * (v i : ℂ) ^ 2 + ∑ i, c i * v i)) := by simp_rw [← Finset.sum_neg_distrib, ← Finset.sum_add_distrib, Complex.exp_sum, ← neg_mul] apply Integrable.fintype_prod (f := fun i (v : ℝ) ↦ cexp (-b i * v ^ 2 + c i * v)) (fun i ↦ ?_) - convert integrable_cexp_quadratic (hb i) (c i) 0 using 3 with x + convert! integrable_cexp_quadratic (hb i) (c i) 0 using 3 with x simp only [add_zero] theorem integrable_cexp_neg_mul_sum_add {ι : Type*} [Fintype ι] (hb : 0 < b.re) (c : ι → ℂ) : @@ -259,7 +259,7 @@ theorem integrable_cexp_neg_mul_sq_norm_add_of_euclideanSpace rw [← (PiLp.volume_preserving_toLp ι).integrable_comp_emb (MeasurableEquiv.toLp 2 _).measurableEmbedding] simp only [neg_mul, Function.comp_def] - convert integrable_cexp_neg_mul_sum_add hb (fun i ↦ c * w i) using 3 with v + convert! integrable_cexp_neg_mul_sum_add hb (fun i ↦ c * w i) using 3 with v simp only [EuclideanSpace.norm_eq, norm_eq_abs, sq_abs, PiLp.inner_apply, RCLike.inner_apply, conj_trivial, ofReal_sum, ofReal_mul, Finset.mul_sum, neg_mul, Finset.sum_neg_distrib, mul_assoc] @@ -274,8 +274,7 @@ theorem integrable_cexp_neg_mul_sq_norm_add (hb : 0 < b.re) (c : ℂ) (w : V) : Integrable (fun (v : V) ↦ cexp (-b * ‖v‖ ^ 2 + c * ⟪w, v⟫)) := by let e := (stdOrthonormalBasis ℝ V).repr.symm rw [← e.measurePreserving.integrable_comp_emb e.toHomeomorph.measurableEmbedding] - convert integrable_cexp_neg_mul_sq_norm_add_of_euclideanSpace - hb c (e.symm w) with v + convert! integrable_cexp_neg_mul_sq_norm_add_of_euclideanSpace hb c (e.symm w) with v simp only [neg_mul, Function.comp_apply, LinearIsometryEquiv.norm_map, LinearIsometryEquiv.symm_symm, LinearIsometryEquiv.inner_map_eq_flip] @@ -288,7 +287,7 @@ theorem integral_cexp_neg_sum_mul_add {ι : Type*} [Fintype ι] {b : ι → ℂ} rw [integral_fintype_prod_volume_eq_prod (f := fun i (v : ℝ) ↦ cexp (-b i * v ^ 2 + c i * v))] congr with i have : (-b i).re < 0 := by simpa using hb i - convert integral_cexp_quadratic this (c i) 0 using 1 <;> simp [div_neg] + convert! integral_cexp_quadratic this (c i) 0 using 1 <;> simp [div_neg] theorem integral_cexp_neg_mul_sum_add {ι : Type*} [Fintype ι] (hb : 0 < b.re) (c : ι → ℂ) : ∫ v : ι → ℝ, cexp (-b * ∑ i, (v i : ℂ) ^ 2 + ∑ i, c i * v i) @@ -304,7 +303,7 @@ theorem integral_cexp_neg_mul_sq_norm_add_of_euclideanSpace rw [← (PiLp.volume_preserving_toLp ι).integral_comp (MeasurableEquiv.toLp 2 _).measurableEmbedding] simp only [neg_mul] - convert integral_cexp_neg_mul_sum_add hb (fun i ↦ c * w i) using 5 with _x y + convert! integral_cexp_neg_mul_sum_add hb (fun i ↦ c * w i) using 5 with _x y · simp only [EuclideanSpace.norm_eq, norm_eq_abs, sq_abs, neg_mul, neg_inj, mul_eq_mul_left_iff] norm_cast left @@ -325,8 +324,8 @@ theorem integral_cexp_neg_mul_sq_norm_add (π / b) ^ (Module.finrank ℝ V / 2 : ℂ) * cexp (c ^ 2 * ‖w‖ ^ 2 / (4 * b)) := by let e := (stdOrthonormalBasis ℝ V).repr.symm rw [← e.measurePreserving.integral_comp e.toHomeomorph.measurableEmbedding] - convert integral_cexp_neg_mul_sq_norm_add_of_euclideanSpace - hb c (e.symm w) <;> simp [LinearIsometryEquiv.inner_map_eq_flip] + convert! integral_cexp_neg_mul_sq_norm_add_of_euclideanSpace hb c (e.symm w) <;> + simp [LinearIsometryEquiv.inner_map_eq_flip] theorem integral_cexp_neg_mul_sq_norm (hb : 0 < b.re) : ∫ v : V, cexp (-b * ‖v‖ ^ 2) = (π / b) ^ (Module.finrank ℝ V / 2 : ℂ) := by @@ -335,7 +334,7 @@ theorem integral_cexp_neg_mul_sq_norm (hb : 0 < b.re) : theorem integral_rexp_neg_mul_sq_norm {b : ℝ} (hb : 0 < b) : ∫ v : V, rexp (-b * ‖v‖ ^ 2) = (π / b) ^ (Module.finrank ℝ V / 2 : ℝ) := by rw [← ofReal_inj] - convert integral_cexp_neg_mul_sq_norm (show 0 < (b : ℂ).re from hb) (V := V) + convert! integral_cexp_neg_mul_sq_norm (show 0 < (b : ℂ).re from hb) (V := V) · change ofRealLI (∫ (v : V), rexp (-b * ‖v‖ ^ 2)) = ∫ (v : V), cexp (-↑b * ↑‖v‖ ^ 2) rw [← ofRealLI.integral_comp_comm] simp [ofRealLI] @@ -347,7 +346,7 @@ theorem _root_.fourier_gaussian_innerProductSpace' (hb : 0 < b.re) (x w : V) : (π / b) ^ (Module.finrank ℝ V / 2 : ℂ) * cexp (-π ^ 2 * ‖x - w‖ ^ 2 / b) := by simp only [neg_mul, fourier_eq', ofReal_neg, ofReal_mul, ofReal_ofNat, smul_eq_mul, ← Complex.exp_add, real_inner_comm w] - convert integral_cexp_neg_mul_sq_norm_add hb (2 * π * Complex.I) (x - w) using 3 with v + convert! integral_cexp_neg_mul_sq_norm_add hb (2 * π * Complex.I) (x - w) using 3 with v · congr 1 simp [inner_sub_left] ring diff --git a/Mathlib/Analysis/SpecialFunctions/Gaussian/GaussianIntegral.lean b/Mathlib/Analysis/SpecialFunctions/Gaussian/GaussianIntegral.lean index 7974faebd6a6cb..ec4bc1bc43bcc3 100644 --- a/Mathlib/Analysis/SpecialFunctions/Gaussian/GaussianIntegral.lean +++ b/Mathlib/Analysis/SpecialFunctions/Gaussian/GaussianIntegral.lean @@ -82,10 +82,10 @@ theorem integrableOn_rpow_mul_exp_neg_rpow {p s : ℝ} (hs : -1 < s) (hp : 1 ≤ (ContinuousOn.mul (fun x hx => h_rpow x s hx) (fun x hx => ?_)) (IsLittleO.isBigO ?_) · rw [← Function.comp_def (fun x => exp (-x)) (· ^ p)] exact ContinuousAt.comp_continuousWithinAt (h_exp _) (h_rpow x p hx) - · convert rpow_mul_exp_neg_mul_rpow_isLittleO_exp_neg s hp (by simp : (0 : ℝ) < 1) using 3 + · convert! rpow_mul_exp_neg_mul_rpow_isLittleO_exp_neg s hp (by simp : (0 : ℝ) < 1) using 3 rw [neg_mul, one_mul] · simp_rw [← hp, Real.rpow_one] - convert Real.GammaIntegral_convergent (by linarith : 0 < s + 1) using 2 + convert! Real.GammaIntegral_convergent (by linarith : 0 < s + 1) using 2 rw [add_sub_cancel_right, mul_comm] theorem integrableOn_rpow_mul_exp_neg_mul_rpow {p s b : ℝ} (hs : -1 < s) (hp : 1 ≤ p) (hb : 0 < b) : @@ -165,7 +165,7 @@ theorem integrable_mul_cexp_neg_mul_sq {b : ℂ} (hb : 0 < b.re) : · fun_prop have := (integrable_mul_exp_neg_mul_sq hb).hasFiniteIntegral rw [← hasFiniteIntegral_norm_iff] at this ⊢ - convert this + convert! this rw [norm_mul, norm_mul, norm_cexp_neg_mul_sq b, norm_real, norm_of_nonneg (exp_pos _).le] theorem integral_mul_cexp_neg_mul_sq {b : ℂ} (hb : 0 < b.re) : @@ -174,7 +174,7 @@ theorem integral_mul_cexp_neg_mul_sq {b : ℂ} (hb : 0 < b.re) : have A : ∀ x : ℂ, HasDerivAt (fun x => -(2 * b)⁻¹ * cexp (-b * x ^ 2)) (x * cexp (-b * x ^ 2)) x := by intro x - convert ((hasDerivAt_pow 2 x).const_mul (-b)).cexp.const_mul (-(2 * b)⁻¹) using 1 + convert! ((hasDerivAt_pow 2 x).const_mul (-b)).cexp.const_mul (-(2 * b)⁻¹) using 1 field have B : Tendsto (fun y : ℝ ↦ -(2 * b)⁻¹ * cexp (-b * (y : ℂ) ^ 2)) atTop (𝓝 (-(2 * b)⁻¹ * 0)) := by @@ -182,8 +182,9 @@ theorem integral_mul_cexp_neg_mul_sq {b : ℂ} (hb : 0 < b.re) : simp_rw [norm_cexp_neg_mul_sq b] exact tendsto_exp_atBot.comp ((tendsto_pow_atTop two_ne_zero).const_mul_atTop_of_neg (neg_lt_zero.2 hb)) - convert integral_Ioi_of_hasDerivAt_of_tendsto' (fun x _ => (A ↑x).comp_ofReal) - (integrable_mul_cexp_neg_mul_sq hb).integrableOn B using 1 + convert! + integral_Ioi_of_hasDerivAt_of_tendsto' (fun x _ => (A ↑x).comp_ofReal) + (integrable_mul_cexp_neg_mul_sq hb).integrableOn B using 1 simp only [mul_zero, ofReal_zero, zero_pow, Ne, not_false_iff, Complex.exp_zero, mul_one, sub_neg_eq_add, zero_add, reduceCtorEq] @@ -229,7 +230,7 @@ theorem integral_gaussian (b : ℝ) : ∫ x : ℝ, exp (-b * x ^ 2) = √(π / b refine (sq_eq_sq₀ (by positivity) (by positivity)).1 ?_ rw [← ofReal_inj, ofReal_pow, ← coe_algebraMap, RCLike.algebraMap_eq_ofReal, ← integral_ofReal, sq_sqrt (div_pos pi_pos hb).le, ← RCLike.algebraMap_eq_ofReal, coe_algebraMap, ofReal_div] - convert integral_gaussian_sq_complex (by rwa [ofReal_re] : 0 < (b : ℂ).re) with _ x + convert! integral_gaussian_sq_complex (by rwa [ofReal_re] : 0 < (b : ℂ).re) with _ x rw [ofReal_exp, ofReal_mul, ofReal_pow, ofReal_neg] theorem continuousAt_gaussian_integral (b : ℂ) (hb : 0 < re b) : @@ -270,7 +271,7 @@ theorem integral_gaussian_complex {b : ℂ} (hb : 0 < re b) : · rw [← ofReal_one, ← ofReal_div] · rw [← ofReal_one, ← ofReal_ofNat, ← ofReal_div] rw [← ofReal_cpow, ofReal_inj] - · convert integral_gaussian (1 : ℝ) using 1 + · convert! integral_gaussian (1 : ℝ) using 1 rw [sqrt_eq_rpow] · rw [div_one]; exact pi_pos.le · -- squares of both sides agree @@ -317,7 +318,7 @@ theorem integral_gaussian_Ioi (b : ℝ) : · rwa [← IntegrableOn, integrableOn_Ioi_exp_neg_mul_sq_iff, not_lt] rw [← RCLike.ofReal_inj (K := ℂ), ← integral_ofReal, ← RCLike.algebraMap_eq_ofReal, coe_algebraMap] - convert integral_gaussian_complex_Ioi (by rwa [ofReal_re] : 0 < (b : ℂ).re) + convert! integral_gaussian_complex_Ioi (by rwa [ofReal_re] : 0 < (b : ℂ).re) · simp · rw [sqrt_eq_rpow, ← ofReal_div, ofReal_div, ofReal_cpow] · simp @@ -328,7 +329,7 @@ set_option linter.unusedSimpArgs false in /-- The special-value formula `Γ(1/2) = √π`, which is equivalent to the Gaussian integral. -/ theorem Real.Gamma_one_half_eq : Real.Gamma (1 / 2) = √π := by rw [Gamma_eq_integral one_half_pos, ← integral_comp_rpow_Ioi_of_pos zero_lt_two] - convert congr_arg (fun x : ℝ => 2 * x) (integral_gaussian_Ioi 1) using 1 + convert! congr_arg (fun x : ℝ => 2 * x) (integral_gaussian_Ioi 1) using 1 · rw [← integral_const_mul] refine setIntegral_congr_fun measurableSet_Ioi fun x hx => ?_ dsimp only @@ -343,7 +344,7 @@ theorem Real.Gamma_one_half_eq : Real.Gamma (1 / 2) = √π := by /-- The special-value formula `Γ(1/2) = √π`, which is equivalent to the Gaussian integral. -/ theorem Complex.Gamma_one_half_eq : Complex.Gamma (1 / 2) = (π : ℂ) ^ (1 / 2 : ℂ) := by - convert congr_arg ((↑) : ℝ → ℂ) Real.Gamma_one_half_eq + convert! congr_arg ((↑) : ℝ → ℂ) Real.Gamma_one_half_eq · simpa only [one_div, ofReal_inv, ofReal_ofNat] using Gamma_ofReal (1 / 2) · rw [sqrt_eq_rpow, ofReal_cpow pi_pos.le, ofReal_div, ofReal_ofNat, ofReal_one] diff --git a/Mathlib/Analysis/SpecialFunctions/Gaussian/PoissonSummation.lean b/Mathlib/Analysis/SpecialFunctions/Gaussian/PoissonSummation.lean index 8289d76547c935..4e994579ccd3c2 100644 --- a/Mathlib/Analysis/SpecialFunctions/Gaussian/PoissonSummation.lean +++ b/Mathlib/Analysis/SpecialFunctions/Gaussian/PoissonSummation.lean @@ -5,9 +5,10 @@ Authors: David Loeffler -/ module -public import Mathlib.Analysis.SpecialFunctions.Gaussian.FourierTransform public import Mathlib.Analysis.Fourier.PoissonSummation +import Mathlib.Analysis.SpecialFunctions.Gaussian.FourierTransform + /-! # Poisson summation applied to the Gaussian @@ -49,7 +50,7 @@ lemma rexp_neg_quadratic_isLittleO_rpow_atTop {a : ℝ} (ha : a < 0) (b s : ℝ) lemma cexp_neg_quadratic_isLittleO_rpow_atTop {a : ℂ} (ha : a.re < 0) (b : ℂ) (s : ℝ) : (fun x : ℝ ↦ cexp (a * x ^ 2 + b * x)) =o[atTop] (· ^ s) := by apply Asymptotics.IsLittleO.of_norm_left - convert rexp_neg_quadratic_isLittleO_rpow_atTop ha b.re s with x + convert! rexp_neg_quadratic_isLittleO_rpow_atTop ha b.re s with x simp_rw [Complex.norm_exp, add_re, ← ofReal_pow, mul_comm (_ : ℂ) ↑(_ : ℝ), re_ofReal_mul, mul_comm _ (re _)] @@ -77,7 +78,7 @@ theorem tendsto_rpow_abs_mul_exp_neg_mul_sq_cocompact {a : ℝ} (ha : 0 < a) (s theorem isLittleO_exp_neg_mul_sq_cocompact {a : ℂ} (ha : 0 < a.re) (s : ℝ) : (fun x : ℝ => Complex.exp (-a * x ^ 2)) =o[cocompact ℝ] fun x : ℝ => |x| ^ s := by - convert cexp_neg_quadratic_isLittleO_abs_rpow_cocompact (?_ : (-a).re < 0) 0 s using 1 + convert! cexp_neg_quadratic_isLittleO_abs_rpow_cocompact (?_ : (-a).re < 0) 0 s using 1 · simp_rw [zero_mul, add_zero] · rwa [neg_re, neg_lt_zero] @@ -87,37 +88,32 @@ theorem Complex.tsum_exp_neg_quadratic {a : ℂ} (ha : 0 < a.re) (b : ℂ) : (∑' n : ℤ, cexp (-π * a * n ^ 2 + 2 * π * b * n)) = 1 / a ^ (1 / 2 : ℂ) * ∑' n : ℤ, cexp (-π / a * (n + I * b) ^ 2) := by let f : ℝ → ℂ := fun x ↦ cexp (-π * a * x ^ 2 + 2 * π * b * x) - have hCf : Continuous f := by - refine Complex.continuous_exp.comp (Continuous.add ?_ ?_) - · exact continuous_const.mul (Complex.continuous_ofReal.pow 2) - · exact continuous_const.mul Complex.continuous_ofReal have hFf : 𝓕 f = fun x : ℝ ↦ 1 / a ^ (1 / 2 : ℂ) * cexp (-π / a * (x + I * b) ^ 2) := fourier_gaussian_pi' ha b - have h1 : 0 < (↑π * a).re := by + have h1 : 0 < (π * a).re := by rw [re_ofReal_mul] exact mul_pos pi_pos ha - have h2 : 0 < (↑π / a).re := by + have h2 : 0 < (π / a).re := by rw [div_eq_mul_inv, re_ofReal_mul, inv_re] refine mul_pos pi_pos (div_pos ha <| normSq_pos.mpr ?_) contrapose! ha rw [ha, zero_re] have f_bd : f =O[cocompact ℝ] (fun x => |x| ^ (-2 : ℝ)) := by - convert (cexp_neg_quadratic_isLittleO_abs_rpow_cocompact ?_ _ (-2)).isBigO + convert! (cexp_neg_quadratic_isLittleO_abs_rpow_cocompact ?_ _ (-2)).isBigO rwa [neg_mul, neg_re, neg_lt_zero] have Ff_bd : (𝓕 f) =O[cocompact ℝ] (fun x => |x| ^ (-2 : ℝ)) := by rw [hFf] - have : ∀ (x : ℝ), -↑π / a * (↑x + I * b) ^ 2 = - -↑π / a * x ^ 2 + (-2 * π * I * b) / a * x + π * b ^ 2 / a := by + have : ∀ (x : ℝ), -π / a * (x + I * b) ^ 2 = + -π / a * x ^ 2 + (-2 * π * I * b) / a * x + π * b ^ 2 / a := by intro x; ring_nf; rw [I_sq]; ring simp_rw [this] conv => enter [2, x]; rw [Complex.exp_add, ← mul_assoc _ _ (Complex.exp _), mul_comm] refine ((cexp_neg_quadratic_isLittleO_abs_rpow_cocompact - (?_) (-2 * ↑π * I * b / a) (-2)).isBigO.const_mul_left _).const_mul_left _ + ?_ (-2 * π * I * b / a) (-2)).isBigO.const_mul_left _).const_mul_left _ rwa [neg_div, neg_re, neg_lt_zero] - convert Real.tsum_eq_tsum_fourier_of_rpow_decay hCf one_lt_two f_bd Ff_bd 0 using 1 + convert! Real.tsum_eq_tsum_fourier_of_rpow_decay (by fun_prop) one_lt_two f_bd Ff_bd 0 using 1 · simp only [f, zero_add, ofReal_intCast] - · rw [← tsum_mul_left] - simp only [QuotientAddGroup.mk_zero, fourier_eval_zero, mul_one, hFf, ofReal_intCast] + · simp [← tsum_mul_left, hFf] theorem Complex.tsum_exp_neg_mul_int_sq {a : ℂ} (ha : 0 < a.re) : (∑' n : ℤ, cexp (-π * a * (n : ℂ) ^ 2)) = diff --git a/Mathlib/Analysis/SpecialFunctions/ImproperIntegrals.lean b/Mathlib/Analysis/SpecialFunctions/ImproperIntegrals.lean index 01f5993138b03f..125055d56bec26 100644 --- a/Mathlib/Analysis/SpecialFunctions/ImproperIntegrals.lean +++ b/Mathlib/Analysis/SpecialFunctions/ImproperIntegrals.lean @@ -117,7 +117,7 @@ theorem integrableOn_add_rpow_Ioi_of_lt {a c m : ℝ} (ha : a < -1) (hc : -m < c IntegrableOn (fun (x : ℝ) ↦ (x + m) ^ a) (Ioi c) := by have hd : ∀ x ∈ Ici c, HasDerivAt (fun t ↦ (t + m) ^ (a + 1) / (a + 1)) ((x + m) ^ a) x := by intro x hx - convert (((hasDerivAt_id _).add_const _).rpow_const _).div_const _ using 1 + convert! (((hasDerivAt_id _).add_const _).rpow_const _).div_const _ using 1 · simp [show a + 1 ≠ 0 by linarith] left; linarith [mem_Ici.mp hx, id_eq x] have ht : Tendsto (fun t ↦ ((t + m) ^ (a + 1)) / (a + 1)) atTop (nhds (0 / (a + 1))) := by @@ -174,12 +174,12 @@ theorem integral_Ioi_rpow_of_lt {a : ℝ} (ha : a < -1) {c : ℝ} (hc : 0 < c) : ∫ t : ℝ in Ioi c, t ^ a = -c ^ (a + 1) / (a + 1) := by have hd : ∀ x ∈ Ici c, HasDerivAt (fun t => t ^ (a + 1) / (a + 1)) (x ^ a) x := by intro x hx - convert (hasDerivAt_rpow_const (p := a + 1) (Or.inl (hc.trans_le hx).ne')).div_const _ using 1 + convert! (hasDerivAt_rpow_const (p := a + 1) (Or.inl (hc.trans_le hx).ne')).div_const _ using 1 simp [show a + 1 ≠ 0 from ne_of_lt (by linarith), mul_comm] have ht : Tendsto (fun t => t ^ (a + 1) / (a + 1)) atTop (𝓝 (0 / (a + 1))) := by apply Tendsto.div_const simpa only [neg_neg] using tendsto_rpow_neg_atTop (by linarith : 0 < -(a + 1)) - convert integral_Ioi_of_hasDerivAt_of_tendsto' hd (integrableOn_Ioi_rpow_of_lt ha hc) ht using 1 + convert! integral_Ioi_of_hasDerivAt_of_tendsto' hd (integrableOn_Ioi_rpow_of_lt ha hc) ht using 1 simp only [neg_div, zero_div, zero_sub] theorem integrableOn_Ioi_norm_cpow_of_lt {a : ℂ} (ha : a.re < -1) {c : ℝ} (hc : 0 < c) : diff --git a/Mathlib/Analysis/SpecialFunctions/Integrability/Basic.lean b/Mathlib/Analysis/SpecialFunctions/Integrability/Basic.lean index 96f7c817bb4104..ba049d6ee37a70 100644 --- a/Mathlib/Analysis/SpecialFunctions/Integrability/Basic.lean +++ b/Mathlib/Analysis/SpecialFunctions/Integrability/Basic.lean @@ -7,7 +7,8 @@ module public import Mathlib.Analysis.SpecialFunctions.Log.NegMulLog public import Mathlib.Analysis.SpecialFunctions.NonIntegrable -public import Mathlib.Analysis.SpecialFunctions.Pow.Deriv + +import Mathlib.Analysis.SpecialFunctions.Pow.Deriv /-! # Integrability of Special Functions @@ -50,7 +51,7 @@ theorem intervalIntegrable_rpow' {r : ℝ} (h : -1 < r) : rw [intervalIntegrable_iff, uIoc_of_le hc] have hderiv : ∀ x ∈ Ioo 0 c, HasDerivAt (fun x : ℝ => x ^ (r + 1) / (r + 1)) (x ^ r) x := by intro x hx - convert (Real.hasDerivAt_rpow_const (p := r + 1) (Or.inl hx.1.ne')).div_const (r + 1) using 1 + convert! (Real.hasDerivAt_rpow_const (p := r + 1) (Or.inl hx.1.ne')).div_const (r + 1) using 1 simp [(by linarith : r + 1 ≠ 0)] apply integrableOn_deriv_of_nonneg _ hderiv · intro x hx; apply rpow_nonneg hx.1.le diff --git a/Mathlib/Analysis/SpecialFunctions/Integrability/LogMeromorphic.lean b/Mathlib/Analysis/SpecialFunctions/Integrability/LogMeromorphic.lean index a221ecbed4268d..5260e2f25a1184 100644 --- a/Mathlib/Analysis/SpecialFunctions/Integrability/LogMeromorphic.lean +++ b/Mathlib/Analysis/SpecialFunctions/Integrability/LogMeromorphic.lean @@ -12,6 +12,8 @@ public import Mathlib.Analysis.SpecialFunctions.Log.PosLog public import Mathlib.LinearAlgebra.Complex.FiniteDimensional public import Mathlib.MeasureTheory.Integral.CircleIntegral +import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv + /-! # Integrability for Logarithms of Meromorphic Functions diff --git a/Mathlib/Analysis/SpecialFunctions/Integrals/Basic.lean b/Mathlib/Analysis/SpecialFunctions/Integrals/Basic.lean index 6d6facddf5b5d1..962a5e55889e4d 100644 --- a/Mathlib/Analysis/SpecialFunctions/Integrals/Basic.lean +++ b/Mathlib/Analysis/SpecialFunctions/Integrals/Basic.lean @@ -152,7 +152,7 @@ theorem integral_rpow {r : ℝ} (h : -1 < r ∨ r ≠ -1 ∧ (0 : ℝ) ∉ [[a, have : (∫ x in a..b, (x : ℂ) ^ (r : ℂ)) = ((b : ℂ) ^ (r + 1 : ℂ) - (a : ℂ) ^ (r + 1 : ℂ)) / (r + 1) := integral_cpow h' - apply_fun Complex.re at this; convert this + apply_fun Complex.re at this; convert! this · simp_rw [intervalIntegral_eq_integral_uIoc, Complex.real_smul, Complex.re_ofReal_mul, rpow_def, ← RCLike.re_eq_complex_re, smul_eq_mul] rw [integral_re] @@ -382,15 +382,16 @@ theorem integral_mul_cpow_one_add_sq {t : ℂ} (ht : t ≠ -1) : apply integral_eq_sub_of_hasDerivAt · intro x _ have f : HasDerivAt (fun y : ℂ => 1 + y ^ 2) (2 * x : ℂ) x := by - convert (hasDerivAt_pow 2 (x : ℂ)).const_add 1 + convert! (hasDerivAt_pow 2 (x : ℂ)).const_add 1 simp have g : ∀ {z : ℂ}, 0 < z.re → HasDerivAt (fun z => z ^ (t + 1) / (2 * (t + 1))) (z ^ t / 2) z := by intro z hz - convert (HasDerivAt.cpow_const (c := t + 1) (hasDerivAt_id _) - (Or.inl hz)).div_const (2 * (t + 1)) using 1 + convert! + (HasDerivAt.cpow_const (c := t + 1) (hasDerivAt_id _) (Or.inl hz)).div_const + (2 * (t + 1)) using 1 simp [field] - convert (HasDerivAt.comp (↑x) (g _) f).comp_ofReal using 1 + convert! (HasDerivAt.comp (↑x) (g _) f).comp_ofReal using 1 · ring · exact mod_cast add_pos_of_pos_of_nonneg zero_lt_one (sq_nonneg x) · apply Continuous.intervalIntegrable @@ -409,7 +410,7 @@ theorem integral_mul_rpow_one_add_sq {t : ℝ} (ht : t ≠ -1) : rw [ofReal_cpow, ofReal_add, ofReal_pow, ofReal_one] exact add_nonneg zero_le_one (sq_nonneg x) rw [← ofReal_inj] - convert integral_mul_cpow_one_add_sq (_ : (t : ℂ) ≠ -1) + convert! integral_mul_cpow_one_add_sq (_ : (t : ℂ) ≠ -1) · rw [← intervalIntegral.integral_ofReal] congr with x : 1 rw [ofReal_mul, this x t] @@ -453,7 +454,7 @@ theorem integral_sin_pow : (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 field_simp - convert eq_sub_iff_add_eq.mp (integral_sin_pow_aux n) using 1 + convert! eq_sub_iff_add_eq.mp (integral_sin_pow_aux n) using 1 ring @[simp] @@ -526,7 +527,7 @@ theorem integral_cos_pow : (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 field_simp - convert eq_sub_iff_add_eq.mp (integral_cos_pow_aux n) using 1 + convert! eq_sub_iff_add_eq.mp (integral_cos_pow_aux n) using 1 ring @[simp] @@ -611,7 +612,7 @@ theorem integral_sin_pow_even_mul_cos_pow_even (m n : ℕ) : @[simp] theorem integral_sin_sq_mul_cos_sq : ∫ x in a..b, sin x ^ 2 * cos x ^ 2 = (b - a) / 8 - (sin (4 * b) - sin (4 * a)) / 32 := by - convert integral_sin_pow_even_mul_cos_pow_even 1 1 using 1 + convert! integral_sin_pow_even_mul_cos_pow_even 1 1 using 1 have h1 : ∀ c : ℝ, (↑1 - c) / ↑2 * ((↑1 + c) / ↑2) = (↑1 - c ^ 2) / 4 := fun c => by ring have h2 : Continuous fun x => cos (2 * x) ^ 2 := by fun_prop have h3 : ∀ x, cos x * sin x = sin (2 * x) / 2 := by intro; rw [sin_two_mul]; ring diff --git a/Mathlib/Analysis/SpecialFunctions/Integrals/LogTrigonometric.lean b/Mathlib/Analysis/SpecialFunctions/Integrals/LogTrigonometric.lean index 203500841cf2e0..c10c30138f248c 100644 --- a/Mathlib/Analysis/SpecialFunctions/Integrals/LogTrigonometric.lean +++ b/Mathlib/Analysis/SpecialFunctions/Integrals/LogTrigonometric.lean @@ -7,6 +7,9 @@ module public import Mathlib.Analysis.SpecialFunctions.Integrability.LogMeromorphic +import Mathlib.Analysis.Analytic.Order +import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv + /-! # Integral of `log ∘ sin` diff --git a/Mathlib/Analysis/SpecialFunctions/JapaneseBracket.lean b/Mathlib/Analysis/SpecialFunctions/JapaneseBracket.lean index 6390825a6ef65a..52a2ab800666ac 100644 --- a/Mathlib/Analysis/SpecialFunctions/JapaneseBracket.lean +++ b/Mathlib/Analysis/SpecialFunctions/JapaneseBracket.lean @@ -5,9 +5,12 @@ Authors: Moritz Doll -/ module -public import Mathlib.Analysis.SpecialFunctions.Integrability.Basic -public import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar -public import Mathlib.MeasureTheory.Integral.Layercake +public import Mathlib.MeasureTheory.Function.L1Space.Integrable +public import Mathlib.MeasureTheory.Measure.Haar.OfBasis + +import Mathlib.Analysis.SpecialFunctions.Integrability.Basic +import Mathlib.MeasureTheory.Integral.Layercake +import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar /-! # Japanese Bracket diff --git a/Mathlib/Analysis/SpecialFunctions/Log/Basic.lean b/Mathlib/Analysis/SpecialFunctions/Log/Basic.lean index 641e4fb4f88eac..f6c9ca89695e40 100644 --- a/Mathlib/Analysis/SpecialFunctions/Log/Basic.lean +++ b/Mathlib/Analysis/SpecialFunctions/Log/Basic.lean @@ -305,7 +305,7 @@ theorem log_sqrt {x : ℝ} (hx : 0 ≤ x) : log (√x) = log x / 2 := by theorem log_le_sub_one_of_pos {x : ℝ} (hx : 0 < x) : log x ≤ x - 1 := by rw [le_sub_iff_add_le] - convert add_one_le_exp (log x) + convert! add_one_le_exp (log x) rw [exp_log hx] lemma one_sub_inv_le_log_of_pos (hx : 0 < x) : 1 - x⁻¹ ≤ log x := by diff --git a/Mathlib/Analysis/SpecialFunctions/Log/Deriv.lean b/Mathlib/Analysis/SpecialFunctions/Log/Deriv.lean index 498d28dd9a8062..a8ca2fea64a7fa 100644 --- a/Mathlib/Analysis/SpecialFunctions/Log/Deriv.lean +++ b/Mathlib/Analysis/SpecialFunctions/Log/Deriv.lean @@ -44,7 +44,7 @@ theorem hasStrictDerivAt_log_of_pos (hx : 0 < x) : HasStrictDerivAt log x⁻¹ x theorem hasStrictDerivAt_log (hx : x ≠ 0) : HasStrictDerivAt log x⁻¹ x := by rcases hx.lt_or_gt with hx | hx - · convert (hasStrictDerivAt_log_of_pos (neg_pos.mpr hx)).comp x (hasStrictDerivAt_neg x) using 1 + · convert! (hasStrictDerivAt_log_of_pos (neg_pos.mpr hx)).comp x (hasStrictDerivAt_neg x) using 1 · ext y; exact (log_neg_eq_log y).symm · ring · exact hasStrictDerivAt_log_of_pos hx @@ -75,7 +75,7 @@ theorem contDiffAt_log {n : ℕ∞ω} {x : ℝ} : ContDiffAt ℝ n log x ↔ x refine ⟨fun h ↦ continuousAt_log_iff.1 h.continuousAt, fun hx ↦ ?_⟩ have A y (hy : 0 < y) : ContDiffAt ℝ n log y := by apply expPartialHomeomorph.contDiffAt_symm_deriv (f₀' := y) hy.ne' (by simpa) - · convert hasDerivAt_exp (log y) + · convert! hasDerivAt_exp (log y) rw [exp_log hy] · exact analyticAt_rexp.contDiffAt rcases hx.lt_or_gt with hx | hx @@ -83,7 +83,7 @@ theorem contDiffAt_log {n : ℕ∞ω} {x : ℝ} : ContDiffAt ℝ n log x ↔ x apply ContDiffAt.comp · apply A _ (Left.neg_pos_iff.mpr hx) apply contDiffAt_id.neg - convert this + convert! this ext x simp · exact A x hx @@ -227,7 +227,7 @@ theorem abs_log_sub_add_sum_range_le {x : ℝ} (h : |x| < 1) (n : ℕ) : have : HasDerivAt F ((∑ i ∈ range n, ↑(i + 1) * y ^ i / (↑i + 1)) + (-1) / (1 - y)) y := .add (.fun_sum fun i _ ↦ (hasDerivAt_pow (i + 1) y).div_const ((i : ℝ) + 1)) (((hasDerivAt_id y).const_sub _).log <| sub_ne_zero.2 hy.2.ne') - convert this using 1 + convert! this using 1 calc -y ^ n / (1 - y) = ∑ i ∈ Finset.range n, y ^ i + -1 / (1 - y) := by simp [field, geom_sum_eq hy.2.ne, sub_ne_zero.2 hy.2.ne, sub_ne_zero.2 hy.2.ne'] @@ -387,7 +387,7 @@ theorem hasSum_log_sub_log_of_abs_lt_one {x : ℝ} (h : |x| < 1) : ring_nf rw [← h_term_eq_goal, (mul_right_injective₀ (two_ne_zero' ℕ)).hasSum_iff] · have h₁ := (hasSum_pow_div_log_of_abs_lt_one (Eq.trans_lt (abs_neg x) h)).mul_left (-1) - convert h₁.add (hasSum_pow_div_log_of_abs_lt_one h) using 1 + convert! h₁.add (hasSum_pow_div_log_of_abs_lt_one h) using 1 ring_nf · intro m hm rw [range_two_mul, Set.mem_setOf_eq, ← Nat.even_add_one] at hm @@ -403,7 +403,7 @@ theorem hasSum_log_one_add_inv {a : ℝ} (h : 0 < a) : · linarith · linarith · exact div_pos one_pos (by linarith) - convert hasSum_log_sub_log_of_abs_lt_one h₁ using 1 + convert! hasSum_log_sub_log_of_abs_lt_one h₁ using 1 have h₂ : (2 : ℝ) * a + 1 ≠ 0 := by linarith have h₃ := h.ne' rw [← log_div] @@ -420,16 +420,17 @@ theorem hasSum_log_one_add {a : ℝ} (h : 0 ≤ a) : (log (1 + a)) := by obtain (rfl | ha0) := eq_or_ne a 0 · simp [hasSum_zero] - · convert hasSum_log_one_add_inv (inv_pos.mpr (lt_of_le_of_ne h ha0.symm)) using 4 + · convert! hasSum_log_one_add_inv (inv_pos.mpr (lt_of_le_of_ne h ha0.symm)) using 4 all_goals simp [field, add_comm] lemma le_log_one_add_of_nonneg {x : ℝ} (hx : 0 ≤ x) : 2 * x / (x + 2) ≤ log (1 + x) := by - convert le_hasSum (hasSum_log_one_add hx) 0 (by intros; positivity) using 1 + convert! le_hasSum (hasSum_log_one_add hx) 0 (by intros; positivity) using 1 simp [field] lemma lt_log_one_add_of_pos {x : ℝ} (hx : 0 < x) : 2 * x / (x + 2) < log (1 + x) := by - convert lt_hasSum (hasSum_log_one_add hx.le) 0 (by intros; positivity) - 1 (by positivity) (by positivity) using 1 + convert! + lt_hasSum (hasSum_log_one_add hx.le) 0 (by intros; positivity) 1 (by positivity) + (by positivity) using 1 simp [field] end Real diff --git a/Mathlib/Analysis/SpecialFunctions/Log/ENNRealLogExp.lean b/Mathlib/Analysis/SpecialFunctions/Log/ENNRealLogExp.lean index ac8f42fa1811b5..f1733727682ffd 100644 --- a/Mathlib/Analysis/SpecialFunctions/Log/ENNRealLogExp.lean +++ b/Mathlib/Analysis/SpecialFunctions/Log/ENNRealLogExp.lean @@ -122,7 +122,7 @@ lemma _root_.EReal.tendsto_exp_nhds_top_nhds_top : Filter.Tendsto exp (𝓝 ⊤) continuous_exp.tendsto ⊤ lemma _root_.EReal.tendsto_exp_nhds_zero_nhds_one : Filter.Tendsto exp (𝓝 0) (𝓝 1) := by - convert continuous_exp.tendsto 0 + convert! continuous_exp.tendsto 0 simp lemma _root_.EReal.tendsto_exp_nhds_bot_nhds_zero : Filter.Tendsto exp (𝓝 ⊥) (𝓝 0) := @@ -132,7 +132,7 @@ lemma tendsto_rpow_atTop_of_one_lt_base {b : ℝ≥0∞} (hb : 1 < b) : Filter.Tendsto (b ^ · : ℝ → ℝ≥0∞) Filter.atTop (𝓝 ⊤) := by simp_rw [ENNReal.rpow_eq_exp_mul_log] refine EReal.tendsto_exp_nhds_top_nhds_top.comp ?_ - convert EReal.Tendsto.mul_const tendsto_coe_atTop _ _ + convert! EReal.Tendsto.mul_const tendsto_coe_atTop _ _ · rw [EReal.top_mul_of_pos (zero_lt_log_iff.2 hb)] all_goals simp @@ -140,7 +140,7 @@ lemma tendsto_rpow_atTop_of_base_lt_one {b : ℝ≥0∞} (hb : b < 1) : Filter.Tendsto (b ^ · : ℝ → ℝ≥0∞) Filter.atTop (𝓝 0) := by simp_rw [ENNReal.rpow_eq_exp_mul_log] refine EReal.tendsto_exp_nhds_bot_nhds_zero.comp ?_ - convert EReal.Tendsto.mul_const tendsto_coe_atTop _ _ + convert! EReal.Tendsto.mul_const tendsto_coe_atTop _ _ · rw [EReal.top_mul_of_neg (log_lt_zero_iff.2 hb)] all_goals simp @@ -148,7 +148,7 @@ lemma tendsto_rpow_atBot_of_one_lt_base {b : ℝ≥0∞} (hb : 1 < b) : Filter.Tendsto (b ^ · : ℝ → ℝ≥0∞) Filter.atBot (𝓝 0) := by simp_rw [ENNReal.rpow_eq_exp_mul_log] refine EReal.tendsto_exp_nhds_bot_nhds_zero.comp ?_ - convert EReal.Tendsto.mul_const tendsto_coe_atBot _ _ + convert! EReal.Tendsto.mul_const tendsto_coe_atBot _ _ · rw [EReal.bot_mul_of_pos (zero_lt_log_iff.2 hb)] all_goals simp @@ -156,7 +156,7 @@ lemma tendsto_rpow_atBot_of_base_lt_one {b : ℝ≥0∞} (hb : b < 1) : Filter.Tendsto (b ^ · : ℝ → ℝ≥0∞) Filter.atBot (𝓝 ⊤) := by simp_rw [ENNReal.rpow_eq_exp_mul_log] refine EReal.tendsto_exp_nhds_top_nhds_top.comp ?_ - convert EReal.Tendsto.mul_const tendsto_coe_atBot _ _ + convert! EReal.Tendsto.mul_const tendsto_coe_atBot _ _ · rw [EReal.bot_mul_of_neg (log_lt_zero_iff.2 hb)] all_goals simp diff --git a/Mathlib/Analysis/SpecialFunctions/Log/Monotone.lean b/Mathlib/Analysis/SpecialFunctions/Log/Monotone.lean index 849f0c54910b05..11c472c0be494e 100644 --- a/Mathlib/Analysis/SpecialFunctions/Log/Monotone.lean +++ b/Mathlib/Analysis/SpecialFunctions/Log/Monotone.lean @@ -72,7 +72,7 @@ theorem log_div_self_rpow_antitoneOn {a : ℝ} (ha : 0 < a) : mul_div_assoc, mul_le_mul_iff_right₀ (one_div_pos.mpr ha)] have hbound {z : ℝ} (hz : z ∈ Ici (rexp a⁻¹)) : z ^ a ∈ {b | rexp 1 ≤ b} := by rw [mem_setOf_eq] - convert rpow_le_rpow _ hz (le_of_lt ha) using 1 + convert! rpow_le_rpow _ hz (le_of_lt ha) using 1 · simp only [← exp_mul, Real.exp_eq_exp, field] positivity refine log_div_self_antitoneOn (hbound hex) (hbound (hex.trans hxy)) ?_ @@ -80,7 +80,7 @@ theorem log_div_self_rpow_antitoneOn {a : ℝ} (ha : 0 < a) : theorem log_div_sqrt_antitoneOn : AntitoneOn (fun x : ℝ ↦ log x / √x) <| .Ici (exp 2) := by simp_rw [sqrt_eq_rpow] - convert log_div_self_rpow_antitoneOn one_half_pos + convert! log_div_self_rpow_antitoneOn one_half_pos norm_num end Real diff --git a/Mathlib/Analysis/SpecialFunctions/Log/NegMulLog.lean b/Mathlib/Analysis/SpecialFunctions/Log/NegMulLog.lean index 19ef6b7dacf6bd..da6eb99e59ea35 100644 --- a/Mathlib/Analysis/SpecialFunctions/Log/NegMulLog.lean +++ b/Mathlib/Analysis/SpecialFunctions/Log/NegMulLog.lean @@ -55,7 +55,7 @@ lemma continuous_mul_log : Continuous fun x ↦ x * log x := by simp only [nhdsWithin_singleton, Filter.tendsto_sup] refine ⟨⟨tendsto_log_mul_self_nhdsLT_zero, ?_⟩, ?_⟩ · simpa only [rpow_one] using tendsto_log_mul_rpow_nhdsGT_zero zero_lt_one - · convert tendsto_pure_nhds (fun x ↦ log x * x) 0 + · convert! tendsto_pure_nhds (fun x ↦ log x * x) 0 simp @[fun_prop] diff --git a/Mathlib/Analysis/SpecialFunctions/Log/PosLog.lean b/Mathlib/Analysis/SpecialFunctions/Log/PosLog.lean index 1d10fdb63a1995..c0f14e0220eb92 100644 --- a/Mathlib/Analysis/SpecialFunctions/Log/PosLog.lean +++ b/Mathlib/Analysis/SpecialFunctions/Log/PosLog.lean @@ -197,7 +197,7 @@ lemma posLog_norm_sum_le {E : Type*} [SeminormedAddCommGroup E] {α : Type*} (s Estimate for `log⁺` of a sum. See `Real.posLog_sum` for a variant involving multiple summands. -/ theorem posLog_add : log⁺ (x + y) ≤ log 2 + log⁺ x + log⁺ y := by - convert posLog_sum Finset.univ ![x, y] using 1 <;> simp [add_assoc] + convert! posLog_sum Finset.univ ![x, y] using 1 <;> simp [add_assoc] /-- Variant of `posLog_add` for norms of elements in normed additive commutative groups, using diff --git a/Mathlib/Analysis/SpecialFunctions/OrdinaryHypergeometric.lean b/Mathlib/Analysis/SpecialFunctions/OrdinaryHypergeometric.lean index 54109c74f5976f..69e305c14fcc94 100644 --- a/Mathlib/Analysis/SpecialFunctions/OrdinaryHypergeometric.lean +++ b/Mathlib/Analysis/SpecialFunctions/OrdinaryHypergeometric.lean @@ -199,16 +199,16 @@ are non-positive integers. -/ theorem ordinaryHypergeometricSeries_radius_eq_one (habc : ∀ kn : ℕ, ↑kn ≠ -a ∧ ↑kn ≠ -b ∧ ↑kn ≠ -c) : (ordinaryHypergeometricSeries 𝔸 a b c).radius = 1 := by - convert ofScalars_radius_eq_of_tendsto 𝔸 _ one_ne_zero ?_ + convert! ofScalars_radius_eq_of_tendsto 𝔸 _ one_ne_zero ?_ suffices Tendsto (fun k : ℕ ↦ (a + k)⁻¹ * (b + k)⁻¹ * (c + k) * ((1 : 𝕂) + k)) atTop (𝓝 1) by simp_rw [ordinaryHypergeometricSeries_norm_div_succ_norm a b c _ (fun n _ ↦ habc n)] simp only [← norm_inv, ← norm_mul, NNReal.coe_one] - convert Filter.Tendsto.norm this + convert! Filter.Tendsto.norm this exact norm_one.symm have (k : ℕ) : (a + k)⁻¹ * (b + k)⁻¹ * (c + k) * ((1 : 𝕂) + k) = (c + k) / (a + k) * ((1 + k) / (b + k)) := by field simp_rw [this] apply (mul_one (1 : 𝕂)) ▸ Filter.Tendsto.mul <;> - convert tendsto_add_mul_div_add_mul_atTop_nhds _ _ (1 : 𝕂) one_ne_zero <;> simp + convert! tendsto_add_mul_div_add_mul_atTop_nhds _ _ (1 : 𝕂) one_ne_zero <;> simp end RCLike diff --git a/Mathlib/Analysis/SpecialFunctions/PolarCoord.lean b/Mathlib/Analysis/SpecialFunctions/PolarCoord.lean index 3ca87f8a6ffbab..3f905e6b88a150 100644 --- a/Mathlib/Analysis/SpecialFunctions/PolarCoord.lean +++ b/Mathlib/Analysis/SpecialFunctions/PolarCoord.lean @@ -63,7 +63,7 @@ def polarCoord : OpenPartialHomeomorph (ℝ × ℝ) (ℝ × ℝ) where · conv_rhs => rw [← sqrt_sq (le_of_lt hr), ← one_mul (r ^ 2), ← sin_sq_add_cos_sq θ] congr 1 ring - · convert Complex.arg_mul_cos_add_sin_mul_I hr ⟨hθ.1, hθ.2.le⟩ + · convert! Complex.arg_mul_cos_add_sin_mul_I hr ⟨hθ.1, hθ.2.le⟩ simp only [Complex.equivRealProd_symm_apply, Complex.ofReal_mul, Complex.ofReal_cos, Complex.ofReal_sin] ring @@ -101,9 +101,11 @@ theorem hasFDerivAt_polarCoord_symm (p : ℝ × ℝ) : HasFDerivAt polarCoord.symm (fderivPolarCoordSymm p) p := by unfold fderivPolarCoordSymm rw [Matrix.toLin_finTwoProd_toContinuousLinearMap] - convert HasFDerivAt.prodMk (𝕜 := ℝ) - (hasFDerivAt_fst.mul ((hasDerivAt_cos p.2).comp_hasFDerivAt p hasFDerivAt_snd)) - (hasFDerivAt_fst.mul ((hasDerivAt_sin p.2).comp_hasFDerivAt p hasFDerivAt_snd)) using 2 <;> + convert! + HasFDerivAt.prodMk (𝕜 := ℝ) + (hasFDerivAt_fst.mul ((hasDerivAt_cos p.2).comp_hasFDerivAt p hasFDerivAt_snd)) + (hasFDerivAt_fst.mul ((hasDerivAt_sin p.2).comp_hasFDerivAt p hasFDerivAt_snd)) using + 2 <;> simp [smul_smul, add_comm, neg_mul, smul_neg, neg_smul _ (ContinuousLinearMap.snd ℝ ℝ ℝ)] theorem det_fderivPolarCoordSymm (p : ℝ × ℝ) : @@ -266,9 +268,10 @@ theorem integral_comp_pi_polarCoord_symm {E : Type*} [NormedAddCommGroup E] [Nor (∫ p in (Set.univ.pi fun _ : ι ↦ polarCoord.target), (∏ i, (p i).1) • f (fun i ↦ polarCoord.symm (p i))) = ∫ p, f p := by rw [← setIntegral_univ (f := f), ← setIntegral_congr_set pi_polarCoord_symm_target_ae_eq_univ] - convert (integral_image_eq_integral_abs_det_fderiv_smul volume measurableSet_pi_polarCoord_target - (fun p _ ↦ (hasFDerivAt_pi_polarCoord_symm p).hasFDerivWithinAt) - injOn_pi_polarCoord_symm f).symm using 1 + convert! + (integral_image_eq_integral_abs_det_fderiv_smul volume measurableSet_pi_polarCoord_target + (fun p _ ↦ (hasFDerivAt_pi_polarCoord_symm p).hasFDerivWithinAt) injOn_pi_polarCoord_symm + f).symm using 1 refine setIntegral_congr_fun measurableSet_pi_polarCoord_target fun x hx ↦ ?_ simp_rw [det_fderivPiPolarCoordSymm, Finset.abs_prod, abs_fst_of_mem_pi_polarCoord_target hx] @@ -285,9 +288,10 @@ theorem lintegral_comp_pi_polarCoord_symm (f : (ι → ℝ × ℝ) → ℝ≥0 ∫⁻ p in (Set.univ.pi fun _ : ι ↦ polarCoord.target), (∏ i, .ofReal (p i).1) * f (fun i ↦ polarCoord.symm (p i)) = ∫⁻ p, f p := by rw [← setLIntegral_univ f, ← setLIntegral_congr pi_polarCoord_symm_target_ae_eq_univ] - convert (lintegral_image_eq_lintegral_abs_det_fderiv_mul volume measurableSet_pi_polarCoord_target - (fun p _ ↦ (hasFDerivAt_pi_polarCoord_symm p).hasFDerivWithinAt) - injOn_pi_polarCoord_symm f).symm using 1 + convert! + (lintegral_image_eq_lintegral_abs_det_fderiv_mul volume measurableSet_pi_polarCoord_target + (fun p _ ↦ (hasFDerivAt_pi_polarCoord_symm p).hasFDerivWithinAt) injOn_pi_polarCoord_symm + f).symm using 1 refine setLIntegral_congr_fun measurableSet_pi_polarCoord_target (fun x hx ↦ ?_) simp_rw [det_fderivPiPolarCoordSymm, Finset.abs_prod, ENNReal.ofReal_prod_of_nonneg (fun _ _ ↦ abs_nonneg _), abs_fst_of_mem_pi_polarCoord_target hx] diff --git a/Mathlib/Analysis/SpecialFunctions/Pow/Asymptotics.lean b/Mathlib/Analysis/SpecialFunctions/Pow/Asymptotics.lean index e18a4589bdd58f..6e8052e52569d0 100644 --- a/Mathlib/Analysis/SpecialFunctions/Pow/Asymptotics.lean +++ b/Mathlib/Analysis/SpecialFunctions/Pow/Asymptotics.lean @@ -107,12 +107,12 @@ theorem tendsto_rpow_div_mul_add (a b c : ℝ) (hb : 0 ≠ b) : /-- The function `x ^ (1 / x)` tends to `1` at `+∞`. -/ theorem tendsto_rpow_div : Tendsto (fun x => x ^ ((1 : ℝ) / x)) atTop (𝓝 1) := by - convert tendsto_rpow_div_mul_add (1 : ℝ) _ (0 : ℝ) zero_ne_one + convert! tendsto_rpow_div_mul_add (1 : ℝ) _ (0 : ℝ) zero_ne_one ring /-- The function `x ^ (-1 / x)` tends to `1` at `+∞`. -/ theorem tendsto_rpow_neg_div : Tendsto (fun x => x ^ (-(1 : ℝ) / x)) atTop (𝓝 1) := by - convert tendsto_rpow_div_mul_add (-(1 : ℝ)) _ (0 : ℝ) zero_ne_one + convert! tendsto_rpow_div_mul_add (-(1 : ℝ)) _ (0 : ℝ) zero_ne_one ring /-- The function `exp(x) / x ^ s` tends to `+∞` at `+∞`, for any real number `s`. -/ diff --git a/Mathlib/Analysis/SpecialFunctions/Pow/Continuity.lean b/Mathlib/Analysis/SpecialFunctions/Pow/Continuity.lean index 0175e7acf4f2f2..b7d14ef68dde16 100644 --- a/Mathlib/Analysis/SpecialFunctions/Pow/Continuity.lean +++ b/Mathlib/Analysis/SpecialFunctions/Pow/Continuity.lean @@ -304,9 +304,9 @@ theorem continuousAt_cpow_zero_of_re_pos {z : ℂ} (hz : 0 < z.re) : refine squeeze_zero (fun _ => norm_nonneg _) (fun _ => norm_cpow_le _ _) ?_ simp only [div_eq_mul_inv, ← Real.exp_neg] refine Tendsto.zero_mul_isBoundedUnder_le ?_ ?_ - · convert - (continuous_fst.norm.tendsto ((0 : ℂ), z)).rpow - ((continuous_re.comp continuous_snd).tendsto _) _ <;> + · convert! + (continuous_fst.norm.tendsto ((0 : ℂ), z)).rpow ((continuous_re.comp continuous_snd).tendsto _) + _ <;> simp [hz, Real.zero_rpow hz.ne'] · simp only [Function.comp_def, Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] rcases exists_gt |im z| with ⟨C, hC⟩ @@ -457,11 +457,11 @@ private theorem continuousAt_rpow_const_of_pos {x : ℝ≥0∞} {y : ℝ} (h : 0 ContinuousAt (fun a : ℝ≥0∞ => a ^ y) x := by by_cases hx : x = ⊤ · rw [hx, ContinuousAt] - convert ENNReal.tendsto_rpow_at_top h + convert! ENNReal.tendsto_rpow_at_top h simp [h] lift x to ℝ≥0 using hx rw [continuousAt_coe_iff] - convert continuous_coe.continuousAt.comp (NNReal.continuousAt_rpow_const (Or.inr h.le)) using 1 + convert! continuous_coe.continuousAt.comp (NNReal.continuousAt_rpow_const (Or.inr h.le)) using 1 ext1 x simp [← coe_rpow_of_nonneg _ h.le] @@ -479,7 +479,7 @@ theorem continuous_rpow_const {y : ℝ} : Continuous fun a : ℝ≥0∞ => a ^ y theorem tendsto_const_mul_rpow_nhds_zero_of_pos {c : ℝ≥0∞} (hc : c ≠ ∞) {y : ℝ} (hy : 0 < y) : Tendsto (fun x : ℝ≥0∞ => c * x ^ y) (𝓝 0) (𝓝 0) := by - convert ENNReal.Tendsto.const_mul (ENNReal.continuous_rpow_const.tendsto 0) _ + convert! ENNReal.Tendsto.const_mul (ENNReal.continuous_rpow_const.tendsto 0) _ · simp [hy] · exact Or.inr hc diff --git a/Mathlib/Analysis/SpecialFunctions/Pow/Deriv.lean b/Mathlib/Analysis/SpecialFunctions/Pow/Deriv.lean index 4c840810bbd198..566b8fd23b72c0 100644 --- a/Mathlib/Analysis/SpecialFunctions/Pow/Deriv.lean +++ b/Mathlib/Analysis/SpecialFunctions/Pow/Deriv.lean @@ -7,12 +7,13 @@ Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébasti module public import Mathlib.Analysis.SpecialFunctions.Pow.Continuity -public import Mathlib.Analysis.SpecialFunctions.Complex.LogDeriv public import Mathlib.Analysis.Calculus.FDeriv.Extend public import Mathlib.Analysis.Calculus.Deriv.Prod public import Mathlib.Analysis.SpecialFunctions.Log.Deriv public import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv +import Mathlib.Analysis.SpecialFunctions.Complex.LogDeriv + /-! # Derivatives of power function on `ℂ`, `ℝ`, `ℝ≥0`, and `ℝ≥0∞` @@ -85,7 +86,7 @@ theorem HasStrictFDerivAt.const_cpow (hf : HasStrictFDerivAt f f' x) (h0 : c ≠ theorem HasFDerivAt.cpow (hf : HasFDerivAt f f' x) (hg : HasFDerivAt g g' x) (h0 : f x ∈ slitPlane) : HasFDerivAt (fun x => f x ^ g x) ((g x * f x ^ (g x - 1)) • f' + (f x ^ g x * Complex.log (f x)) • g') x := by - convert (@Complex.hasFDerivAt_cpow ((fun x => (f x, g x)) x) h0).comp x (hf.prodMk hg) + convert! (@Complex.hasFDerivAt_cpow ((fun x => (f x, g x)) x) h0).comp x (hf.prodMk hg) theorem HasFDerivAt.const_cpow (hf : HasFDerivAt f f' x) (h0 : c ≠ 0 ∨ f x ≠ 0) : HasFDerivAt (fun x => c ^ f x) ((c ^ f x * Complex.log c) • f') x := @@ -94,8 +95,8 @@ theorem HasFDerivAt.const_cpow (hf : HasFDerivAt f f' x) (h0 : c ≠ 0 ∨ f x theorem HasFDerivWithinAt.cpow (hf : HasFDerivWithinAt f f' s x) (hg : HasFDerivWithinAt g g' s x) (h0 : f x ∈ slitPlane) : HasFDerivWithinAt (fun x => f x ^ g x) ((g x * f x ^ (g x - 1)) • f' + (f x ^ g x * Complex.log (f x)) • g') s x := by - convert (@Complex.hasFDerivAt_cpow ((fun x => (f x, g x)) x) h0).comp_hasFDerivWithinAt x - (hf.prodMk hg) + convert! + (@Complex.hasFDerivAt_cpow ((fun x => (f x, g x)) x) h0).comp_hasFDerivWithinAt x (hf.prodMk hg) theorem HasFDerivWithinAt.const_cpow (hf : HasFDerivWithinAt f f' s x) (h0 : c ≠ 0 ∨ f x ≠ 0) : HasFDerivWithinAt (fun x => c ^ f x) ((c ^ f x * Complex.log c) • f') s x := @@ -259,9 +260,9 @@ theorem hasDerivAt_ofReal_cpow_const' {x : ℝ} (hx : x ≠ 0) {r : ℂ} (hr : r rcases lt_or_gt_of_ne hx.symm with (hx | hx) · -- easy case : `0 < x` apply HasDerivAt.comp_ofReal (e := fun y => (y : ℂ) ^ (r + 1) / (r + 1)) - convert HasDerivAt.div_const (𝕜 := ℂ) ?_ (r + 1) using 1 + convert! HasDerivAt.div_const (𝕜 := ℂ) ?_ (r + 1) using 1 · exact (mul_div_cancel_right₀ _ hr).symm - · convert HasDerivAt.cpow_const ?_ ?_ using 1 + · convert! HasDerivAt.cpow_const ?_ ?_ using 1 · rw [add_sub_cancel_right, mul_comm]; exact (mul_one _).symm · exact hasDerivAt_id (x : ℂ) · simp [hx] @@ -274,20 +275,20 @@ theorem hasDerivAt_ofReal_cpow_const' {x : ℝ} (hx : x ≠ 0) {r : ℂ} (hr : r rw [ofReal_cpow_of_nonpos (le_of_lt hx)] suffices HasDerivAt (fun y : ℝ => (-↑y) ^ (r + 1) * exp (↑π * I * (r + 1))) ((r + 1) * (-↑x) ^ r * exp (↑π * I * r)) x by - convert this.div_const (r + 1) using 1 + convert! this.div_const (r + 1) using 1 conv_rhs => rw [mul_assoc, mul_comm, mul_div_cancel_right₀ _ hr] rw [mul_add ((π : ℂ) * _), mul_one, exp_add, exp_pi_mul_I, mul_comm (_ : ℂ) (-1 : ℂ), neg_one_mul] simp_rw [mul_neg, ← neg_mul, ← ofReal_neg] suffices HasDerivAt (fun y : ℝ => (↑(-y) : ℂ) ^ (r + 1)) (-(r + 1) * ↑(-x) ^ r) x by - convert this.neg.mul_const _ using 1; ring + convert! this.neg.mul_const _ using 1; ring suffices HasDerivAt (fun y : ℝ => (y : ℂ) ^ (r + 1)) ((r + 1) * ↑(-x) ^ r) (-x) by - convert @HasDerivAt.scomp ℝ _ ℂ _ _ x ℝ _ _ _ _ _ _ _ _ this (hasDerivAt_neg x) using 1 + convert! @HasDerivAt.scomp ℝ _ ℂ _ _ x ℝ _ _ _ _ _ _ _ _ this (hasDerivAt_neg x) using 1 rw [real_smul, ofReal_neg 1, ofReal_one]; ring suffices HasDerivAt (fun y : ℂ => y ^ (r + 1)) ((r + 1) * ↑(-x) ^ r) ↑(-x) by exact this.comp_ofReal conv in ↑_ ^ _ => rw [(by ring : r = r + 1 - 1)] - convert HasDerivAt.cpow_const ?_ ?_ using 1 + convert! HasDerivAt.cpow_const ?_ ?_ using 1 · rw [add_sub_cancel_right, add_sub_cancel_right]; exact (mul_one _).symm · exact hasDerivAt_id ((-x : ℝ) : ℂ) · simp [hx] @@ -349,7 +350,7 @@ theorem hasStrictFDerivAt_rpow_of_pos (p : ℝ × ℝ) (hp : 0 < p.1) : have : (fun x : ℝ × ℝ => x.1 ^ x.2) =ᶠ[𝓝 p] fun x => exp (log x.1 * x.2) := (continuousAt_fst.eventually (lt_mem_nhds hp)).mono fun p hp => rpow_def_of_pos hp _ refine HasStrictFDerivAt.congr_of_eventuallyEq ?_ this.symm - convert ((hasStrictFDerivAt_fst.log hp.ne').fun_mul hasStrictFDerivAt_snd).exp using 1 + convert! ((hasStrictFDerivAt_fst.log hp.ne').fun_mul hasStrictFDerivAt_snd).exp using 1 rw [rpow_sub_one hp.ne', ← rpow_def_of_pos hp, smul_add, smul_smul, mul_div_left_comm, div_eq_mul_inv, smul_smul, smul_smul, mul_assoc, add_comm] @@ -362,8 +363,9 @@ theorem hasStrictFDerivAt_rpow_of_neg (p : ℝ × ℝ) (hp : p.1 < 0) : have : (fun x : ℝ × ℝ => x.1 ^ x.2) =ᶠ[𝓝 p] fun x => exp (log x.1 * x.2) * cos (x.2 * π) := (continuousAt_fst.eventually (gt_mem_nhds hp)).mono fun p hp => rpow_def_of_neg hp _ refine HasStrictFDerivAt.congr_of_eventuallyEq ?_ this.symm - convert ((hasStrictFDerivAt_fst.log hp.ne).fun_mul hasStrictFDerivAt_snd).exp.fun_mul - (hasStrictFDerivAt_snd.mul_const π).cos using 1 + convert! + ((hasStrictFDerivAt_fst.log hp.ne).fun_mul hasStrictFDerivAt_snd).exp.fun_mul + (hasStrictFDerivAt_snd.mul_const π).cos using 1 simp_rw [rpow_sub_one hp.ne, smul_add, ← add_assoc, smul_smul, ← add_smul, ← mul_assoc, mul_comm (cos _), ← rpow_def_of_neg hp] rw [div_eq_mul_inv, add_comm]; congr 2 <;> ring @@ -386,8 +388,9 @@ theorem differentiableAt_rpow_of_ne (p : ℝ × ℝ) (hp : p.1 ≠ 0) : theorem _root_.HasStrictDerivAt.rpow {f g : ℝ → ℝ} {f' g' : ℝ} (hf : HasStrictDerivAt f f' x) (hg : HasStrictDerivAt g g' x) (h : 0 < f x) : HasStrictDerivAt (fun x => f x ^ g x) (f' * g x * f x ^ (g x - 1) + g' * f x ^ g x * Real.log (f x)) x := by - convert (hasStrictFDerivAt_rpow_of_pos ((fun x => (f x, g x)) x) h).comp_hasStrictDerivAt x - (hf.prodMk hg) using 1 + convert! + (hasStrictFDerivAt_rpow_of_pos ((fun x => (f x, g x)) x) h).comp_hasStrictDerivAt x + (hf.prodMk hg) using 1 simp [mul_assoc, mul_comm] theorem hasStrictDerivAt_rpow_const_of_ne {x : ℝ} (hx : x ≠ 0) (p : ℝ) : @@ -395,7 +398,7 @@ theorem hasStrictDerivAt_rpow_const_of_ne {x : ℝ} (hx : x ≠ 0) (p : ℝ) : rcases hx.lt_or_gt with hx | hx · have := (hasStrictFDerivAt_rpow_of_neg (x, p) hx).comp_hasStrictDerivAt x ((hasStrictDerivAt_id x).prodMk (hasStrictDerivAt_const x p)) - convert this using 1; simp + convert! this using 1; simp · simpa using (hasStrictDerivAt_id x).rpow (hasStrictDerivAt_const x p) hx theorem hasStrictDerivAt_const_rpow {a : ℝ} (ha : 0 < a) (x : ℝ) : @@ -668,7 +671,7 @@ variable {f g : ℝ → ℝ} {f' g' x y p : ℝ} {s : Set ℝ} theorem HasDerivWithinAt.rpow (hf : HasDerivWithinAt f f' s x) (hg : HasDerivWithinAt g g' s x) (h : 0 < f x) : HasDerivWithinAt (fun x => f x ^ g x) (f' * g x * f x ^ (g x - 1) + g' * f x ^ g x * Real.log (f x)) s x := by - convert (hf.hasFDerivWithinAt.rpow hg.hasFDerivWithinAt h).hasDerivWithinAt using 1 + convert! (hf.hasFDerivWithinAt.rpow hg.hasFDerivWithinAt h).hasDerivWithinAt using 1 dsimp; ring theorem HasDerivAt.rpow (hf : HasDerivAt f f' x) (hg : HasDerivAt g g' x) (h : 0 < f x) : @@ -679,7 +682,7 @@ theorem HasDerivAt.rpow (hf : HasDerivAt f f' x) (hg : HasDerivAt g g' x) (h : 0 theorem HasDerivWithinAt.rpow_const (hf : HasDerivWithinAt f f' s x) (hx : f x ≠ 0 ∨ 1 ≤ p) : HasDerivWithinAt (fun y => f y ^ p) (f' * p * f x ^ (p - 1)) s x := by - convert (hasDerivAt_rpow_const hx).comp_hasDerivWithinAt x hf using 1 + convert! (hasDerivAt_rpow_const hx).comp_hasDerivWithinAt x hf using 1 ring theorem HasDerivAt.rpow_const (hf : HasDerivAt f f' x) (hx : f x ≠ 0 ∨ 1 ≤ p) : @@ -722,7 +725,7 @@ variable {a : ℝ} theorem HasDerivWithinAt.const_rpow (ha : 0 < a) (hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (a ^ f ·) (Real.log a * f' * a ^ f x) s x := by - convert (hasDerivWithinAt_const x s a).rpow hf ha using 1 + convert! (hasDerivWithinAt_const x s a).rpow hf ha using 1 ring theorem HasDerivAt.const_rpow (ha : 0 < a) (hf : HasDerivAt f f' x) : diff --git a/Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean b/Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean index 7fcd68993eee23..c76491e3102c03 100644 --- a/Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean +++ b/Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean @@ -705,7 +705,7 @@ theorem mul_rpow_eq_ite (x y : ℝ≥0∞) (z : ℝ) : rcases eq_or_ne z 0 with (rfl | hz); · simp replace hz := hz.lt_or_gt wlog hxy : x ≤ y - · convert this y x z hz (le_of_not_ge hxy) using 2 <;> simp only [mul_comm, and_comm, or_comm] + · convert! this y x z hz (le_of_not_ge hxy) using 2 <;> simp only [mul_comm, and_comm, or_comm] rcases eq_or_ne x 0 with (rfl | hx0) · induction y <;> rcases hz with hz | hz <;> simp [*, hz.not_gt] rcases eq_or_ne y 0 with (rfl | hy0) diff --git a/Mathlib/Analysis/SpecialFunctions/Pow/Real.lean b/Mathlib/Analysis/SpecialFunctions/Pow/Real.lean index 441564fddc9a30..8c3d5bd70fd10e 100644 --- a/Mathlib/Analysis/SpecialFunctions/Pow/Real.lean +++ b/Mathlib/Analysis/SpecialFunctions/Pow/Real.lean @@ -660,11 +660,11 @@ theorem rpow_le_one {x z : ℝ} (hx1 : 0 ≤ x) (hx2 : x ≤ 1) (hz : 0 ≤ z) : gcongr theorem rpow_lt_one_of_one_lt_of_neg {x z : ℝ} (hx : 1 < x) (hz : z < 0) : x ^ z < 1 := by - convert rpow_lt_rpow_of_exponent_lt hx hz + convert! rpow_lt_rpow_of_exponent_lt hx hz exact (rpow_zero x).symm theorem rpow_le_one_of_one_le_of_nonpos {x z : ℝ} (hx : 1 ≤ x) (hz : z ≤ 0) : x ^ z ≤ 1 := by - convert rpow_le_rpow_of_exponent_le hx hz + convert! rpow_le_rpow_of_exponent_le hx hz exact (rpow_zero x).symm theorem one_lt_rpow {x z : ℝ} (hx : 1 < x) (hz : 0 < z) : 1 < x ^ z := by @@ -677,12 +677,12 @@ theorem one_le_rpow {x z : ℝ} (hx : 1 ≤ x) (hz : 0 ≤ z) : 1 ≤ x ^ z := b theorem one_lt_rpow_of_pos_of_lt_one_of_neg (hx1 : 0 < x) (hx2 : x < 1) (hz : z < 0) : 1 < x ^ z := by - convert rpow_lt_rpow_of_exponent_gt hx1 hx2 hz + convert! rpow_lt_rpow_of_exponent_gt hx1 hx2 hz exact (rpow_zero x).symm theorem one_le_rpow_of_pos_of_le_one_of_nonpos (hx1 : 0 < x) (hx2 : x ≤ 1) (hz : z ≤ 0) : 1 ≤ x ^ z := by - convert rpow_le_rpow_of_exponent_ge hx1 hx2 hz + convert! rpow_le_rpow_of_exponent_ge hx1 hx2 hz exact (rpow_zero x).symm theorem rpow_lt_one_iff_of_pos (hx : 0 < x) : x ^ y < 1 ↔ 1 < x ∧ y < 0 ∨ x < 1 ∧ 0 < y := by diff --git a/Mathlib/Analysis/SpecialFunctions/Sigmoid.lean b/Mathlib/Analysis/SpecialFunctions/Sigmoid.lean index 957e4634d6d5fd..a1707859907c38 100644 --- a/Mathlib/Analysis/SpecialFunctions/Sigmoid.lean +++ b/Mathlib/Analysis/SpecialFunctions/Sigmoid.lean @@ -135,7 +135,7 @@ lemma tendsto_sigmoid_atBot : Tendsto sigmoid atBot (𝓝 0) := lemma hasDerivAt_sigmoid (x : ℝ) : HasDerivAt sigmoid (sigmoid x * (1 - sigmoid x)) x := by - convert (hasDerivAt_neg' x |>.exp.const_add 1 |>.inv <| by positivity) using 1 + convert! (hasDerivAt_neg' x |>.exp.const_add 1 |>.inv <| by positivity) using 1 rw [← sigmoid_neg, ← sigmoid_mul_rexp_neg x, sigmoid_def] field [sq] diff --git a/Mathlib/Analysis/SpecialFunctions/SmoothTransition.lean b/Mathlib/Analysis/SpecialFunctions/SmoothTransition.lean index 5f2a1674a7de7e..cd24266ad8eb62 100644 --- a/Mathlib/Analysis/SpecialFunctions/SmoothTransition.lean +++ b/Mathlib/Analysis/SpecialFunctions/SmoothTransition.lean @@ -109,7 +109,7 @@ theorem hasDerivAt_polynomial_eval_inv_mul (p : ℝ[X]) (x : ℝ) : refine ((tendsto_polynomial_inv_mul_zero (p * X)).mono_left inf_le_left).congr fun x ↦ ?_ simp [slope_def_field, div_eq_mul_inv, mul_right_comm] · have := ((p.hasDerivAt x⁻¹).mul (hasDerivAt_neg _).exp).comp x (hasDerivAt_inv hx.ne') - convert this.congr_of_eventuallyEq _ using 1 + convert! this.congr_of_eventuallyEq _ using 1 · simp [expNegInvGlue, hx.not_ge] ring · filter_upwards [lt_mem_nhds hx] with y hy @@ -131,7 +131,7 @@ theorem contDiff_polynomial_eval_inv_mul {n : ℕ∞} (p : ℝ[X]) : | succ m ihm => rw [show ((m + 1 : ℕ) : WithTop ℕ∞) = m + 1 from rfl] refine contDiff_succ_iff_deriv.2 ⟨differentiable_polynomial_eval_inv_mul _, by simp, ?_⟩ - convert ihm (X ^ 2 * (p - derivative (R := ℝ) p)) using 2 + convert! ihm (X ^ 2 * (p - derivative (R := ℝ) p)) using 2 exact (hasDerivAt_polynomial_eval_inv_mul p _).deriv /-- The function `expNegInvGlue` is smooth. -/ diff --git a/Mathlib/Analysis/SpecialFunctions/Stirling.lean b/Mathlib/Analysis/SpecialFunctions/Stirling.lean index c966bbaec1bf4b..3c2a3664a553a3 100644 --- a/Mathlib/Analysis/SpecialFunctions/Stirling.lean +++ b/Mathlib/Analysis/SpecialFunctions/Stirling.lean @@ -79,7 +79,7 @@ theorem log_stirlingSeq_diff_hasSum (m : ℕ) : let f (k : ℕ) := (1 : ℝ) / (2 * k + 1) * ((1 / (2 * ↑(m + 1) + 1)) ^ 2) ^ k change HasSum (fun k => f (k + 1)) _ rw [hasSum_nat_add_iff] - convert (hasSum_log_one_add_inv m.cast_add_one_pos).mul_left ((↑(m + 1) : ℝ) + 1 / 2) using 1 + convert! (hasSum_log_one_add_inv m.cast_add_one_pos).mul_left ((↑(m + 1) : ℝ) + 1 / 2) using 1 · ext k dsimp only [f] rw [← pow_mul, pow_add] @@ -240,7 +240,7 @@ lemma factorial_isEquivalent_stirling : apply Asymptotics.isEquivalent_of_tendsto_one have : sqrt π ≠ 0 := by positivity nth_rewrite 2 [← div_self this] - convert tendsto_stirlingSeq_sqrt_pi.div tendsto_const_nhds this using 1 + convert! tendsto_stirlingSeq_sqrt_pi.div tendsto_const_nhds this using 1 ext n simp [field, stirlingSeq, mul_right_comm] diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean index a06fde5b158b41..1908802a7dd306 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean @@ -155,7 +155,7 @@ theorem two_nsmul_eq_iff {ψ θ : Angle} : (2 : ℕ) • ψ = (2 : ℕ) • θ simp_rw [← natCast_zsmul, Nat.cast_ofNat, two_zsmul_eq_iff] theorem two_nsmul_eq_zero_iff {θ : Angle} : (2 : ℕ) • θ = 0 ↔ θ = 0 ∨ θ = π := by - convert two_nsmul_eq_iff <;> simp + convert! two_nsmul_eq_iff <;> simp theorem two_nsmul_ne_zero_iff {θ : Angle} : (2 : ℕ) • θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by rw [← not_or, ← two_nsmul_eq_zero_iff] @@ -463,7 +463,7 @@ theorem neg_pi_lt_toReal (θ : Angle) : -π < θ.toReal := by theorem toReal_le_pi (θ : Angle) : θ.toReal ≤ π := by induction θ using Real.Angle.induction_on - convert toIocMod_le_right two_pi_pos _ _ + convert! toIocMod_le_right two_pi_pos _ _ ring theorem abs_toReal_le_pi (θ : Angle) : |θ.toReal| ≤ π := @@ -580,11 +580,11 @@ theorem toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff {θ : ℝ} {k : ℤ} : theorem toReal_coe_eq_self_sub_two_pi_iff {θ : ℝ} : (θ : Angle).toReal = θ - 2 * π ↔ θ ∈ Set.Ioc π (3 * π) := by - convert @toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff θ 1 <;> norm_num + convert! @toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff θ 1 <;> norm_num theorem toReal_coe_eq_self_add_two_pi_iff {θ : ℝ} : (θ : Angle).toReal = θ + 2 * π ↔ θ ∈ Set.Ioc (-3 * π) (-π) := by - convert @toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff θ (-1) using 2 <;> norm_num + convert! @toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff θ (-1) using 2 <;> norm_num theorem two_nsmul_toReal_eq_two_mul_sub_two_pi {θ : Angle} : ((2 : ℕ) • θ).toReal = 2 * θ.toReal - 2 * π ↔ π / 2 < θ.toReal := by @@ -936,7 +936,7 @@ lemma abs_toReal_add_eq_two_pi_sub_abs_toReal_add_abs_toReal {θ ψ : Angle} (hs · obtain ⟨hθ', hψ'⟩ : (-θ).sign = 1 ∧ (-ψ).sign = 1 := by grind [sign_neg, neg_neg] have hsa' : (-θ + -ψ).sign ≠ 1 := by rwa [← hθ', ne_comm, ← neg_add, sign_neg, sign_neg, neg_injective.ne_iff] - convert abs_toReal_add_eq_two_pi_sub_abs_toReal_add_abs_toReal_aux hθ' hψ' hsa' using 1 + convert! abs_toReal_add_eq_two_pi_sub_abs_toReal_add_abs_toReal_aux hθ' hψ' hsa' using 1 all_goals simp [-neg_add_rev, ← neg_add, abs_toReal_neg] · grind [sign_eq_zero_iff, coe_pi_add_coe_pi] · exact abs_toReal_add_eq_two_pi_sub_abs_toReal_add_abs_toReal_aux h (hs ▸ h) (h ▸ hsa.symm) diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Arctan.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Arctan.lean index 75f958a523fd1d..87a236b2f5b280 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Arctan.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Arctan.lean @@ -39,7 +39,7 @@ theorem tan_add tan (x + y) = (tan x + tan y) / (1 - tan x * tan y) := by simpa only [← Complex.ofReal_inj, Complex.ofReal_sub, Complex.ofReal_add, Complex.ofReal_div, Complex.ofReal_mul, Complex.ofReal_tan] using - @Complex.tan_add (x : ℂ) (y : ℂ) (by convert h <;> norm_cast) + @Complex.tan_add (x : ℂ) (y : ℂ) (by convert! h <;> norm_cast) theorem tan_add' (h : (∀ k : ℤ, x ≠ (2 * k + 1) * π / 2) ∧ ∀ l : ℤ, y ≠ (2 * l + 1) * π / 2) : @@ -52,7 +52,7 @@ theorem tan_sub {x y : ℝ} tan (x - y) = (tan x - tan y) / (1 + tan x * tan y) := by simpa only [← Complex.ofReal_inj, Complex.ofReal_sub, Complex.ofReal_add, Complex.ofReal_div, Complex.ofReal_mul, Complex.ofReal_tan] using - @Complex.tan_sub (x : ℂ) (y : ℂ) (by convert h <;> norm_cast) + @Complex.tan_sub (x : ℂ) (y : ℂ) (by convert! h <;> norm_cast) theorem tan_sub' {x y : ℝ} (h : (∀ k : ℤ, x ≠ (2 * k + 1) * π / 2) ∧ ∀ l : ℤ, y ≠ (2 * l + 1) * π / 2) : diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean index ad33732b70832e..0b458980a6f4da 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean @@ -969,34 +969,36 @@ theorem tan_int_mul_pi_sub (x : ℝ) (n : ℤ) : tan (n * π - x) = -tan x := tan_neg x ▸ tan_periodic.int_mul_sub_eq n theorem tendsto_sin_pi_div_two : Tendsto sin (𝓝[<] (π / 2)) (𝓝 1) := by - convert continuous_sin.continuousWithinAt.tendsto + convert! continuous_sin.continuousWithinAt.tendsto simp theorem tendsto_cos_pi_div_two : Tendsto cos (𝓝[<] (π / 2)) (𝓝[>] 0) := by apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within - · convert continuous_cos.continuousWithinAt.tendsto + · convert! continuous_cos.continuousWithinAt.tendsto simp · filter_upwards [Ioo_mem_nhdsLT (neg_lt_self pi_div_two_pos)] with x hx exact cos_pos_of_mem_Ioo hx theorem tendsto_tan_pi_div_two : Tendsto tan (𝓝[<] (π / 2)) atTop := by - convert tendsto_cos_pi_div_two.inv_tendsto_nhdsGT_zero.atTop_mul_pos zero_lt_one - tendsto_sin_pi_div_two using 1 + convert! + tendsto_cos_pi_div_two.inv_tendsto_nhdsGT_zero.atTop_mul_pos zero_lt_one + tendsto_sin_pi_div_two using 1 simp only [Pi.inv_apply, ← div_eq_inv_mul, ← tan_eq_sin_div_cos] theorem tendsto_sin_neg_pi_div_two : Tendsto sin (𝓝[>] (-(π / 2))) (𝓝 (-1)) := by - convert continuous_sin.continuousWithinAt.tendsto using 2 + convert! continuous_sin.continuousWithinAt.tendsto using 2 simp theorem tendsto_cos_neg_pi_div_two : Tendsto cos (𝓝[>] (-(π / 2))) (𝓝[>] 0) := by apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within - · convert continuous_cos.continuousWithinAt.tendsto + · convert! continuous_cos.continuousWithinAt.tendsto simp · filter_upwards [Ioo_mem_nhdsGT (neg_lt_self pi_div_two_pos)] with x hx exact cos_pos_of_mem_Ioo hx theorem tendsto_tan_neg_pi_div_two : Tendsto tan (𝓝[>] (-(π / 2))) atBot := by - convert tendsto_cos_neg_pi_div_two.inv_tendsto_nhdsGT_zero.atTop_mul_neg (by simp) + convert! + tendsto_cos_neg_pi_div_two.inv_tendsto_nhdsGT_zero.atTop_mul_neg (by simp) tendsto_sin_neg_pi_div_two using 1 simp only [Pi.inv_apply, ← div_eq_inv_mul, ← tan_eq_sin_div_cos] @@ -1268,7 +1270,7 @@ theorem sinh_add_pi_mul_I (z : ℂ) : sinh (z + π * I) = -sinh z := sinh_antiperiodic z theorem sinh_periodic : Function.Periodic sinh (2 * π * I) := by - convert sinh_antiperiodic.periodic_two_mul using 1 + convert! sinh_antiperiodic.periodic_two_mul using 1 ring @[simp] @@ -1283,7 +1285,7 @@ theorem cosh_add_pi_mul_I (z : ℂ) : cosh (z + π * I) = -cosh z := cosh_antiperiodic z theorem cosh_periodic : Function.Periodic cosh (2 * π * I) := by - convert cosh_antiperiodic.periodic_two_mul using 1 + convert! cosh_antiperiodic.periodic_two_mul using 1 ring @[simp] diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Bounds.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Bounds.lean index 0b8c6ac67592ab..3b3720b8b28d92 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Bounds.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Bounds.lean @@ -209,7 +209,7 @@ theorem cos_lt_one_div_sqrt_sq_add_one {x : ℝ} (hx1 : -(3 * π / 2) ≤ x) (hx suffices ∀ {y : ℝ}, 0 < y → y ≤ 3 * π / 2 → cos y < 1 / √(y ^ 2 + 1) by rcases lt_or_lt_iff_ne.mpr hx3.symm with ⟨h⟩ · exact this h hx2 - · convert this (by linarith : 0 < -x) (by linarith) using 1 + · convert! this (by linarith : 0 < -x) (by linarith) using 1 · rw [cos_neg] · rw [neg_sq] intro y hy1 hy2 diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/ChebyshevGauss.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/ChebyshevGauss.lean index ee57b6dd899082..f44143431db645 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/ChebyshevGauss.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/ChebyshevGauss.lean @@ -55,7 +55,7 @@ private theorem sum_exp {n : ℕ} {k : ℤ} (hn : n ≠ 0) (hk : ¬ (2 * n : ℤ have hf {s a b t : ℂ} (h : s * a⁻¹ * b = t) (ha : a ≠ 0) (hb : b ≠ 0) : s = a / b * t := by linear_combination (norm := field) h * a / b apply hf this (Complex.exp_ne_zero _) (by grind [exp_sub_one_ne_zero]) - convert geom_sum_mul (exp (k / n * π * I)) n using 1 + convert! geom_sum_mul (exp (k / n * π * I)) n using 1 · simp_rw [sum_mul] congr! 1 with i hi rw [← Complex.exp_nat_mul, ← Complex.exp_add] diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/Extremal.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/Extremal.lean index 55e0f66353f5d6..1af1d845979ab0 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/Extremal.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/Extremal.lean @@ -175,7 +175,7 @@ private theorem sumNodes_eq_coeff {n : ℕ} {P : ℝ[X]} (hP : P.degree ≤ n) : grw [hP] norm_cast simp - convert (Lagrange.coeff_eq_sum (strictAntiOn_node n).injOn this).symm using 2 + convert! (Lagrange.coeff_eq_sum (strictAntiOn_node n).injOn this).symm using 2 · exact Eq.symm (Nat.range_succ_eq_Iic n) · simp @@ -194,8 +194,7 @@ private theorem negOnePow_mul_leadingCoeffC_pos {n i : ℕ} (hi : i ≤ n) : theorem coeff_le_of_forall_abs_le_one {n : ℕ} {P : ℝ[X]} (hPdeg : P.degree ≤ n) (hPbnd : ∀ x ∈ Set.Icc (-1) 1, |P.eval x| ≤ 1) : P.coeff n ≤ 2 ^ (n - 1) := by - convert sumNodes_le_sumNodes_T - (fun i hi => le_of_lt <| negOnePow_mul_leadingCoeffC_pos hi) hPbnd + convert! sumNodes_le_sumNodes_T (fun i hi => le_of_lt <| negOnePow_mul_leadingCoeffC_pos hi) hPbnd · rw [sumNodes_eq_coeff hPdeg] · rw [sumNodes_T_eq] @@ -214,8 +213,7 @@ theorem leadingCoeff_le_of_forall_abs_le_one {n : ℕ} {P : ℝ[X]} theorem coeff_eq_iff_of_forall_abs_le_one {n : ℕ} {P : ℝ[X]} (hPdeg : P.degree ≤ n) (hPbnd : ∀ x ∈ Set.Icc (-1) 1, |P.eval x| ≤ 1) : P.coeff n = 2 ^ (n - 1) ↔ P = T ℝ n := by - convert sumNodes_eq_sumNodes_T_iff - (fun i hi => negOnePow_mul_leadingCoeffC_pos hi) hPdeg hPbnd + convert! sumNodes_eq_sumNodes_T_iff (fun i hi => negOnePow_mul_leadingCoeffC_pos hi) hPdeg hPbnd · rw [sumNodes_eq_coeff hPdeg] · rw [sumNodes_T_eq] @@ -249,8 +247,9 @@ private theorem sumNodes_eq_eval_iterate_derivative {n k : ℕ} (hk : k ≤ n) ( simp_rw [sumNodes, iterateDerivativeC] have h₁ : P.degree < (Finset.range (n + 1)).card := by rw [Finset.card_range]; grw [hP]; norm_cast; simp - convert (Lagrange.eval_iterate_derivative_eq_sum (strictAntiOn_node n).injOn h₁ - (show k < _ by simp [hk]) x).symm + convert! + (Lagrange.eval_iterate_derivative_eq_sum (strictAntiOn_node n).injOn h₁ + (show k < _ by simp [hk]) x).symm rw [Finset.mul_sum] grind [Nat.range_succ_eq_Iic, Nat.card_Iic] @@ -288,8 +287,8 @@ theorem eval_iterate_derivative_le_of_forall_abs_le_one {n : ℕ} {P : ℝ[X]} by_cases! hk : n < k · rw [iterate_derivative_eq_zero_of_degree_lt (by grw [hPdeg]; simpa), iterate_derivative_eq_zero_of_degree_lt (by simp [hk])] - convert sumNodes_le_sumNodes_T - (fun i hi => negOnePow_mul_iterateDerivativeC_nonneg hi hx) hPbnd using 1 + convert! + sumNodes_le_sumNodes_T (fun i hi => negOnePow_mul_iterateDerivativeC_nonneg hi hx) hPbnd using 1 · rw [sumNodes_eq_eval_iterate_derivative hk x hPdeg] · rw [sumNodes_eq_eval_iterate_derivative hk x (le_of_eq (degree_T ℝ n))] @@ -297,8 +296,9 @@ theorem eval_iterate_derivative_eq_iff_of_bounded {n : ℕ} {P : ℝ[X]} {k : ℕ} (hk₁ : 0 < k) (hk₂ : k ≤ n) {x : ℝ} (hx : 1 ≤ x) (hPdeg : P.degree ≤ n) (hPbnd : ∀ x ∈ Set.Icc (-1) 1, |P.eval x| ≤ 1) : (derivative^[k] P).eval x = (derivative^[k] (T ℝ n)).eval x ↔ P = T ℝ n := by - convert sumNodes_eq_sumNodes_T_iff - (fun i hi => negOnePow_mul_iterateDerivativeC_pos hk₁ hk₂ hi hx) hPdeg hPbnd using 2 + convert! + sumNodes_eq_sumNodes_T_iff (fun i hi => negOnePow_mul_iterateDerivativeC_pos hk₁ hk₂ hi hx) + hPdeg hPbnd using 2 · rw [sumNodes_eq_eval_iterate_derivative hk₂ x hPdeg] · rw [sumNodes_eq_eval_iterate_derivative hk₂ x (le_of_eq (degree_T ℝ n))] diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/Orthogonality.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/Orthogonality.lean index 494efbc07e25bd..51998fd7926032 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/Orthogonality.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/Orthogonality.lean @@ -72,7 +72,7 @@ theorem integrable_measureT {f : ℝ → ℝ} (hf : ContinuousOn f (Set.Icc (-1) rw [measureT, restrict_withDensity (by measurability), integrable_withDensity_iff (by fun_prop) (by simp)] unfold IntegrableOn at this - convert this + convert! this open Set in theorem integral_measureT_eq_integral_cos {f : ℝ → ℝ} : diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/RootsExtrema.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/RootsExtrema.lean index c7032f200465f6..ce2395f4574158 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/RootsExtrema.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Chebyshev/RootsExtrema.lean @@ -59,14 +59,14 @@ theorem one_lt_eval_T_real {n : ℤ} (hn : n ≠ 0) {x : ℝ} (hx : 1 < x) : theorem one_le_negOnePow_mul_eval_T_real (n : ℤ) {x : ℝ} (hx : x ≤ -1) : 1 ≤ n.negOnePow * (T ℝ n).eval x := by rw [← neg_neg x, T_eval_neg] - convert one_le_eval_T_real n (le_neg_of_le_neg hx) + convert! one_le_eval_T_real n (le_neg_of_le_neg hx) rw [Int.cast_negOnePow, ← mul_assoc, ← mul_zpow] simp theorem one_lt_negOnePow_mul_eval_T_real {n : ℤ} (hn : n ≠ 0) {x : ℝ} (hx : x < -1) : 1 < n.negOnePow * (T ℝ n).eval x := by rw [← neg_neg x, T_eval_neg] - convert one_lt_eval_T_real hn (lt_neg_of_lt_neg hx) + convert! one_lt_eval_T_real hn (lt_neg_of_lt_neg hx) rw [Int.cast_negOnePow, ← mul_assoc, ← mul_zpow] simp @@ -102,7 +102,7 @@ theorem abs_eval_T_real_eq_one_iff {n : ℕ} (hn : n ≠ 0) (x : ℝ) : gcongr exact div_le_one_of_le₀ (arccos_le_pi x) (by positivity) refine ⟨k, by simpa using hkn, ?_⟩ - convert congr(cos ($hk.symm / n)) + convert! congr(cos ($hk.symm / n)) rw [mul_div_cancel_left₀ _ (by simpa), cos_arccos (by grind) (by grind)] · rintro ⟨k, hk, rfl⟩ rw [T_real_cos, abs_cos_eq_one_iff] @@ -111,7 +111,7 @@ theorem abs_eval_T_real_eq_one_iff {n : ℕ} (hn : n ≠ 0) (x : ℝ) : theorem eval_T_real_cos_int_mul_pi_div {k : ℕ} {n : ℕ} (hn : n ≠ 0) : (T ℝ n).eval (cos (k * π / n)) = (k : ℤ).negOnePow := by rw [T_real_cos, Int.cast_negOnePow] - convert Real.cos_int_mul_pi k using 2 + convert! Real.cos_int_mul_pi k using 2 simp [field] theorem eval_T_real_eq_one_iff {n : ℕ} (hn : n ≠ 0) (x : ℝ) : @@ -312,7 +312,7 @@ theorem irrational_of_isRoot_T_real {n : ℕ} {x : ℝ} (hroot : (T ℝ n).IsRoo obtain ⟨k, hk₁, hk₂⟩ := Finset.mem_image.mp hroot have hn : n ≠ 0 := by grind suffices Irrational (cos ((Rat.divInt (2 * k + 1) (2 * n)) * π)) by - rw [← hk₂]; convert this using 2; push_cast; field_simp + rw [← hk₂]; convert! this using 2; push_cast; field_simp apply irrational_cos_rat_mul_pi contrapose! hnz have : (Rat.divInt (2 * k + 1) (2 * n)).den = 2 * (n / n.gcd (2 * k + 1)) := calc @@ -321,12 +321,12 @@ theorem irrational_of_isRoot_T_real {n : ℕ} {x : ℝ} (hroot : (T ℝ n).IsRoo Nat.mul_div_assoc _ (Nat.gcd_dvd_left ..)] have hn : 2 * k + 1 = n := Nat.eq_of_dvd_of_lt_two_mul (by simp) (Nat.gcd_eq_left_iff_dvd.mp <| Nat.eq_of_dvd_of_div_eq_one (Nat.gcd_dvd_left ..) (by grind [Rat.den_pos])) (by grind) - rw_mod_cast [← hk₂, hn]; convert cos_pi_div_two using 2; push_cast; field_simp + rw_mod_cast [← hk₂, hn]; convert! cos_pi_div_two using 2; push_cast; field_simp theorem abs_iterate_derivative_T_real_le (n : ℤ) (k : ℕ) {x : ℝ} (hx : |x| ≤ 1) : |(derivative^[k] (T ℝ n)).eval x| ≤ (derivative^[k] (T ℝ n)).eval 1 := by wlog hn : 0 ≤ n - · convert this (-n) k hx (by grind) using 1 <;> rw [T_neg] + · convert! this (-n) k hx (by grind) using 1 <;> rw [T_neg] lift n to ℕ using hn have := T_iterate_derivative_mem_span_T (R := ℝ) n k obtain ⟨f, hfsupp, hfderiv⟩ := Submodule.mem_span_set.mp this diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Complex.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Complex.lean index 824805a6d1f58f..7932da5e271491 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Complex.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Complex.lean @@ -145,7 +145,7 @@ theorem tan_sub {x y : ℂ} rcases h with ⟨x_ne, minus_y_ne⟩ | ⟨x_eq, minus_y_eq⟩ · refine .inl ⟨x_ne, fun l => ?_⟩ rw [Ne, neg_eq_iff_eq_neg] - convert minus_y_ne (-l - 1) using 2 + convert! minus_y_ne (-l - 1) using 2 push_cast ring · refine .inr ⟨x_eq, ?_⟩ @@ -154,7 +154,7 @@ theorem tan_sub {x y : ℂ} push_cast ring rw [tan_neg] at this - convert this using 2 + convert! this using 2 ring theorem tan_sub' {x y : ℂ} @@ -181,7 +181,7 @@ theorem tan_eq {z : ℂ} (∃ k : ℤ, (z.re : ℂ) = (2 * k + 1) * π / 2) ∧ ∃ l : ℤ, (z.im : ℂ) * I = (2 * l + 1) * π / 2) : tan z = (tan z.re + tanh z.im * I) / (1 - tan z.re * tanh z.im * I) := by - convert tan_add_mul_I h; exact (re_add_im z).symm + convert! tan_add_mul_I h; exact (re_add_im z).symm /-- `tan x` takes the junk value `0` when `cos x = 0` -/ lemma tan_eq_zero_of_cos_eq_zero {x} (h : cos x = 0) : tan x = 0 := by @@ -237,7 +237,7 @@ theorem cos_surjective : Function.Surjective cos := by simp only [zero_add, one_ne_zero, mul_zero] at hw refine ⟨log w / I, cos_eq_iff_quadratic.2 ?_⟩ rw [div_mul_cancel₀ _ I_ne_zero, exp_log w₀] - convert hw using 1 + convert! hw using 1 ring @[simp] diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/ComplexDeriv.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/ComplexDeriv.lean index 50422d5b225f57..4d51e2e7c975cd 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/ComplexDeriv.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/ComplexDeriv.lean @@ -26,7 +26,7 @@ open Set Filter open scoped Real theorem hasStrictDerivAt_tan {x : ℂ} (h : cos x ≠ 0) : HasStrictDerivAt tan (1 / cos x ^ 2) x := by - convert (hasStrictDerivAt_sin x).div (hasStrictDerivAt_cos x) h using 1 + convert! (hasStrictDerivAt_sin x).div (hasStrictDerivAt_cos x) h using 1 rw_mod_cast [← sin_sq_add_cos_sq x] ring diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Cotangent.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Cotangent.lean index 8797ac0313c150..a1a2b1c90bed39 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Cotangent.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Cotangent.lean @@ -404,7 +404,7 @@ theorem iteratedDerivWithin_cot_pi_mul_eq_mul_tsum_div_pow {k : ℕ} (hk : 1 ≤ (hz : z ∈ ℍₒ) : iteratedDerivWithin k (fun x : ℂ ↦ π * cot (π * x)) ℍₒ z = (-1) ^ k * k ! * ∑' n : ℤ, 1 / (z + n) ^ (k + 1) := by - convert iteratedDerivWithin_cot_pi_mul_eq_mul_tsum_zpow hk hz with n + convert! iteratedDerivWithin_cot_pi_mul_eq_mul_tsum_zpow hk hz with n rw [show (-1 - k : ℤ) = -(k + 1 :) by norm_cast; lia, zpow_neg_coe_of_pos _ (by lia), one_div] diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Deriv.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Deriv.lean index 6642d8173ff07b..2ed674ee551988 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Deriv.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Deriv.lean @@ -33,8 +33,11 @@ namespace Complex /-- The complex sine function is everywhere strictly differentiable, with the derivative `cos x`. -/ theorem hasStrictDerivAt_sin (x : ℂ) : HasStrictDerivAt sin (cos x) x := by simp only [cos, div_eq_mul_inv] - convert ((((hasStrictDerivAt_id x).fun_neg.mul_const I).cexp.sub - ((hasStrictDerivAt_id x).mul_const I).cexp).mul_const I).mul_const (2 : ℂ)⁻¹ using 1 + convert! + ((((hasStrictDerivAt_id x).fun_neg.mul_const I).cexp.sub + ((hasStrictDerivAt_id x).mul_const I).cexp).mul_const + I).mul_const + (2 : ℂ)⁻¹ using 1 simp only [id] rw [sub_mul, mul_assoc, mul_assoc, I_mul_I, neg_one_mul, neg_neg, mul_one, one_mul, mul_assoc, I_mul_I, mul_neg_one, sub_neg_eq_add, add_comm] @@ -82,8 +85,10 @@ theorem deriv_sin : deriv sin = cos := `-sin x`. -/ theorem hasStrictDerivAt_cos (x : ℂ) : HasStrictDerivAt cos (-sin x) x := by simp only [sin, div_eq_mul_inv, neg_mul_eq_neg_mul] - convert (((hasStrictDerivAt_id x).mul_const I).cexp.add - ((hasStrictDerivAt_id x).fun_neg.mul_const I).cexp).mul_const (2 : ℂ)⁻¹ using 1 + convert! + (((hasStrictDerivAt_id x).mul_const I).cexp.add + ((hasStrictDerivAt_id x).fun_neg.mul_const I).cexp).mul_const + (2 : ℂ)⁻¹ using 1 simp only [id] ring diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/DerivHyp.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/DerivHyp.lean index 3c1dd210ba1950..bed1acdb86f3ba 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/DerivHyp.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/DerivHyp.lean @@ -37,8 +37,8 @@ namespace Complex `cosh x`. -/ theorem hasStrictDerivAt_sinh (x : ℂ) : HasStrictDerivAt sinh (cosh x) x := by simp only [cosh, div_eq_mul_inv] - convert ((hasStrictDerivAt_exp x).sub (hasStrictDerivAt_id x).fun_neg.cexp).mul_const (2 : ℂ)⁻¹ - using 1 + convert! + ((hasStrictDerivAt_exp x).sub (hasStrictDerivAt_id x).fun_neg.cexp).mul_const (2 : ℂ)⁻¹ using 1 rw [id, mul_neg_one, sub_eq_add_neg, neg_neg] /-- The complex hyperbolic sine function is everywhere differentiable, with the derivative @@ -84,8 +84,8 @@ theorem deriv_sinh : deriv sinh = cosh := derivative `sinh x`. -/ theorem hasStrictDerivAt_cosh (x : ℂ) : HasStrictDerivAt cosh (sinh x) x := by simp only [sinh, div_eq_mul_inv] - convert ((hasStrictDerivAt_exp x).add (hasStrictDerivAt_id x).fun_neg.cexp).mul_const (2 : ℂ)⁻¹ - using 1 + convert! + ((hasStrictDerivAt_exp x).add (hasStrictDerivAt_id x).fun_neg.cexp).mul_const (2 : ℂ)⁻¹ using 1 rw [id, mul_neg_one, sub_eq_add_neg] /-- The complex hyperbolic cosine function is everywhere differentiable, with the derivative diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/EulerSineProd.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/EulerSineProd.lean index 2b5e39a274e515..5efad8d26a4da7 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/EulerSineProd.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/EulerSineProd.lean @@ -67,9 +67,9 @@ theorem integral_cos_mul_cos_pow_aux (hn : 2 ≤ n) (hz : z ≠ 0) : intro x _ have b : HasDerivAt (fun y : ℝ => (cos y : ℂ)) (-sin x) x := by simpa using (hasDerivAt_cos x).ofReal_comp - convert HasDerivAt.comp x (hasDerivAt_pow _ _) b using 1 + convert! HasDerivAt.comp x (hasDerivAt_pow _ _) b using 1 ring - convert (config := { sameFun := true }) + convert! (config := { sameFun := true }) integral_mul_deriv_eq_deriv_mul der1 (fun x _ => antideriv_cos_comp_const_mul hz x) _ _ using 2 · ext1 x; rw [mul_comm] · rw [Complex.ofReal_zero, mul_zero, Complex.sin_zero, zero_div, mul_zero, sub_zero, @@ -92,7 +92,7 @@ theorem integral_sin_mul_sin_mul_cos_pow_eq (hn : 2 ≤ n) (hz : z ≠ 0) : ((cos x : ℂ) ^ n - (n - 1) * (sin x : ℂ) ^ 2 * (cos x : ℂ) ^ (n - 2)) x := by intro x _ have c := HasDerivAt.comp (x : ℂ) (hasDerivAt_pow (n - 1) _) (Complex.hasDerivAt_cos x) - convert ((Complex.hasDerivAt_sin x).fun_mul c).comp_ofReal using 1 + convert! ((Complex.hasDerivAt_sin x).fun_mul c).comp_ofReal using 1 · simp only [Complex.ofReal_sin, Complex.ofReal_cos, Function.comp] · simp only [Complex.ofReal_cos, Complex.ofReal_sin] rw [mul_neg, mul_neg, ← sub_eq_add_neg, Function.comp_apply] @@ -102,7 +102,7 @@ theorem integral_sin_mul_sin_mul_cos_pow_eq (hn : 2 ≤ n) (hz : z ≠ 0) : rw [Nat.cast_sub (one_le_two.trans hn), Nat.cast_one] rw [Nat.sub_sub, this] ring - convert + convert! integral_mul_deriv_eq_deriv_mul der1 (fun x _ => antideriv_sin_comp_const_mul hz x) _ _ using 1 · refine integral_congr fun x _ => ?_ ring_nf @@ -139,7 +139,7 @@ theorem integral_cos_mul_cos_pow (hn : 2 ≤ n) (hz : z ≠ 0) : have := integral_cos_mul_cos_pow_aux hn hz rw [integral_sin_mul_sin_mul_cos_pow_eq hn hz, sub_eq_neg_add, mul_add, ← sub_eq_iff_eq_add] at this - convert congr_arg (fun u : ℂ => -u * (2 * z) ^ 2 / n ^ 2) this using 1 <;> field + convert! congr_arg (fun u : ℂ => -u * (2 * z) ^ 2 / n ^ 2) this using 1 <;> field /-- Note this also holds for `z = 0`, but we do not need this case for `sin_pi_mul_eq`. -/ theorem integral_cos_mul_cos_pow_even (n : ℕ) (hz : z ≠ 0) : @@ -147,7 +147,7 @@ theorem integral_cos_mul_cos_pow_even (n : ℕ) (hz : z ≠ 0) : ∫ x in (0 : ℝ)..π / 2, Complex.cos (2 * z * x) * (cos x : ℂ) ^ (2 * n + 2)) = (2 * n + 1 : ℂ) / (2 * n + 2) * ∫ x in (0 : ℝ)..π / 2, Complex.cos (2 * z * x) * (cos x : ℂ) ^ (2 * n) := by - convert integral_cos_mul_cos_pow (by lia : 2 ≤ 2 * n + 2) hz using 3 + convert! integral_cos_mul_cos_pow (by lia : 2 ≤ 2 * n + 2) hz using 3 · simp only [Nat.cast_add, Nat.cast_mul, Nat.cast_two] nth_rw 2 [← mul_one (2 : ℂ)] rw [← mul_add, mul_pow, ← div_div] @@ -229,11 +229,11 @@ theorem sin_pi_mul_eq (z : ℂ) (n : ℕ) : rw [this, Complex.ofReal_mul, Complex.ofReal_div] have : (C : ℂ) ≠ 0 := Complex.ofReal_ne_zero.mpr (integral_cos_pow_pos _).ne' have : 2 * (n : ℂ) + 1 ≠ 0 := by - convert (Nat.cast_add_one_ne_zero (2 * n) : (↑(2 * n) + 1 : ℂ) ≠ 0) + convert! (Nat.cast_add_one_ne_zero (2 * n) : (↑(2 * n) + 1 : ℂ) ≠ 0) simp have : (n : ℂ) + 1 ≠ 0 := Nat.cast_add_one_ne_zero n simp [field] - convert integral_cos_mul_cos_pow_even n hz + convert! integral_cos_mul_cos_pow_even n hz rw [Nat.cast_succ] end IntegralRecursion @@ -280,13 +280,13 @@ theorem _root_.Complex.tendsto_euler_sin_prod (z : ℂ) : Tendsto.congr (fun n => sin_pi_mul_eq z n) tendsto_const_nhds have : 𝓝 (Complex.sin (π * z)) = 𝓝 (Complex.sin (π * z) * 1) := by rw [mul_one] simp_rw [this, mul_div_assoc] at A - convert (tendsto_mul_iff_of_ne_zero _ one_ne_zero).mp A + convert! (tendsto_mul_iff_of_ne_zero _ one_ne_zero).mp A suffices Tendsto (fun n : ℕ => (∫ x in (0 : ℝ)..π / 2, Complex.cos (2 * z * x) * (cos x : ℂ) ^ n) / (∫ x in (0 : ℝ)..π / 2, cos x ^ n : ℝ)) atTop (𝓝 1) from this.comp (tendsto_id.const_mul_atTop' zero_lt_two) have : ContinuousOn (fun x : ℝ ↦ Complex.cos (2 * z * x)) (Icc 0 (π / 2)) := by fun_prop - convert tendsto_integral_cos_pow_mul_div this using 1 + convert! tendsto_integral_cos_pow_mul_div this using 1 · ext1 n; congr 2 with x : 1; rw [mul_comm] · rw [Complex.ofReal_zero, mul_zero, Complex.cos_zero] @@ -294,7 +294,7 @@ theorem _root_.Complex.tendsto_euler_sin_prod (z : ℂ) : theorem _root_.Real.tendsto_euler_sin_prod (x : ℝ) : Tendsto (fun n : ℕ => π * x * ∏ j ∈ Finset.range n, ((1 : ℝ) - x ^ 2 / ((j : ℝ) + 1) ^ 2)) atTop (𝓝 <| sin (π * x)) := by - convert (Complex.continuous_re.tendsto _).comp (Complex.tendsto_euler_sin_prod x) using 1 + convert! (Complex.continuous_re.tendsto _).comp (Complex.tendsto_euler_sin_prod x) using 1 · ext1 n rw [Function.comp_apply, ← Complex.ofReal_mul, Complex.re_ofReal_mul] suffices diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/InverseDeriv.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/InverseDeriv.lean index 63656e08066a62..2f102a8ae3e251 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/InverseDeriv.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/InverseDeriv.lean @@ -61,14 +61,14 @@ theorem contDiffAt_arcsin {x : ℝ} (h₁ : x ≠ -1) (h₂ : x ≠ 1) {n : ℕ theorem hasDerivWithinAt_arcsin_Ici {x : ℝ} (h : x ≠ -1) : HasDerivWithinAt arcsin (1 / √(1 - x ^ 2)) (Ici x) x := by rcases eq_or_ne x 1 with (rfl | h') - · convert (hasDerivWithinAt_const (1 : ℝ) _ (π / 2)).congr _ _ <;> + · convert! (hasDerivWithinAt_const (1 : ℝ) _ (π / 2)).congr _ _ <;> simp +contextual [arcsin_of_one_le] · exact (hasDerivAt_arcsin h h').hasDerivWithinAt theorem hasDerivWithinAt_arcsin_Iic {x : ℝ} (h : x ≠ 1) : HasDerivWithinAt arcsin (1 / √(1 - x ^ 2)) (Iic x) x := by rcases em (x = -1) with (rfl | h') - · convert (hasDerivWithinAt_const (-1 : ℝ) _ (-(π / 2))).congr _ _ <;> + · convert! (hasDerivWithinAt_const (-1 : ℝ) _ (-(π / 2))).congr _ _ <;> simp +contextual [arcsin_of_le_neg_one] · exact (hasDerivAt_arcsin h' h).hasDerivWithinAt diff --git a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Series.lean b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Series.lean index 37d773c2794887..45714e812c4fa6 100644 --- a/Mathlib/Analysis/SpecialFunctions/Trigonometric/Series.lean +++ b/Mathlib/Analysis/SpecialFunctions/Trigonometric/Series.lean @@ -42,7 +42,7 @@ theorem Complex.hasSum_cos' (z : ℂ) : simp_rw [← mul_comm 2 _] at this refine this.prod_fiberwise fun k => ?_ dsimp only - convert hasSum_fintype (_ : Fin 2 → ℂ) using 1 + convert! hasSum_fintype (_ : Fin 2 → ℂ) using 1 rw [Fin.sum_univ_two] simp_rw [Fin.val_zero, Fin.val_one, add_zero, pow_succ, pow_mul, mul_pow, neg_sq, ← two_mul, neg_mul, mul_neg, neg_div, add_neg_cancel, zero_div, add_zero, @@ -59,7 +59,7 @@ theorem Complex.hasSum_sin' (z : ℂ) : simp_rw [← mul_comm 2 _] at this refine this.prod_fiberwise fun k => ?_ dsimp only - convert hasSum_fintype (_ : Fin 2 → ℂ) using 1 + convert! hasSum_fintype (_ : Fin 2 → ℂ) using 1 rw [Fin.sum_univ_two] simp_rw [Fin.val_zero, Fin.val_one, add_zero, pow_succ, pow_mul, mul_pow, neg_sq, sub_self, zero_mul, zero_div, zero_add, neg_mul, mul_neg, neg_div, ← neg_add', ← two_mul, @@ -68,13 +68,13 @@ theorem Complex.hasSum_sin' (z : ℂ) : /-- The power series expansion of `Complex.cos`. -/ theorem Complex.hasSum_cos (z : ℂ) : HasSum (fun n : ℕ => (-1) ^ n * z ^ (2 * n) / ↑(2 * n)!) (Complex.cos z) := by - convert Complex.hasSum_cos' z using 1 + convert! Complex.hasSum_cos' z using 1 simp_rw [mul_pow, pow_mul, Complex.I_sq, mul_comm] /-- The power series expansion of `Complex.sin`. -/ theorem Complex.hasSum_sin (z : ℂ) : HasSum (fun n : ℕ => (-1) ^ n * z ^ (2 * n + 1) / ↑(2 * n + 1)!) (Complex.sin z) := by - convert Complex.hasSum_sin' z using 1 + convert! Complex.hasSum_sin' z using 1 simp_rw [mul_pow, pow_succ, pow_mul, Complex.I_sq, ← mul_assoc, mul_div_assoc, div_right_comm, div_self Complex.I_ne_zero, mul_comm _ ((-1 : ℂ) ^ _), mul_one_div, mul_div_assoc, mul_assoc] diff --git a/Mathlib/Analysis/SpecificLimits/Basic.lean b/Mathlib/Analysis/SpecificLimits/Basic.lean index 4857e7c7bbe409..a1aac4e3484e9e 100644 --- a/Mathlib/Analysis/SpecificLimits/Basic.lean +++ b/Mathlib/Analysis/SpecificLimits/Basic.lean @@ -38,14 +38,13 @@ theorem NNRat.tendsto_inv_atTop_nhds_zero_nat : Tendsto (fun n : ℕ ↦ (n : theorem NNRat.tendsto_algebraMap_inv_atTop_nhds_zero_nat (𝕜 : Type*) [Semiring 𝕜] [Algebra ℚ≥0 𝕜] [TopologicalSpace 𝕜] [ContinuousSMul ℚ≥0 𝕜] : Tendsto (algebraMap ℚ≥0 𝕜 ∘ fun n : ℕ ↦ (n : ℚ≥0)⁻¹) atTop (𝓝 0) := by - convert (continuous_algebraMap ℚ≥0 𝕜).continuousAt.tendsto.comp - tendsto_inv_atTop_nhds_zero_nat + convert! (continuous_algebraMap ℚ≥0 𝕜).continuousAt.tendsto.comp tendsto_inv_atTop_nhds_zero_nat rw [map_zero] theorem tendsto_inv_atTop_nhds_zero_nat {𝕜 : Type*} [DivisionSemiring 𝕜] [CharZero 𝕜] [TopologicalSpace 𝕜] [ContinuousSMul ℚ≥0 𝕜] : Tendsto (fun n : ℕ ↦ (n : 𝕜)⁻¹) atTop (𝓝 0) := by - convert NNRat.tendsto_algebraMap_inv_atTop_nhds_zero_nat 𝕜 + convert! NNRat.tendsto_algebraMap_inv_atTop_nhds_zero_nat 𝕜 simp theorem tendsto_const_div_atTop_nhds_zero_nat {𝕜 : Type*} [DivisionSemiring 𝕜] [CharZero 𝕜] @@ -77,7 +76,7 @@ theorem tendsto_algebraMap_inv_atTop_nhds_zero_nat {𝕜 : Type*} (A : Type*) [Semifield 𝕜] [CharZero 𝕜] [TopologicalSpace 𝕜] [ContinuousSMul ℚ≥0 𝕜] [Semiring A] [Algebra 𝕜 A] [TopologicalSpace A] [ContinuousSMul 𝕜 A] : Tendsto (algebraMap 𝕜 A ∘ fun n : ℕ ↦ (n : 𝕜)⁻¹) atTop (𝓝 0) := by - convert (continuous_algebraMap 𝕜 A).continuousAt.tendsto.comp tendsto_inv_atTop_nhds_zero_nat + convert! (continuous_algebraMap 𝕜 A).continuousAt.tendsto.comp tendsto_inv_atTop_nhds_zero_nat rw [map_zero] /-- The limit of `n / (n + x)` is 1, for any constant `x` (valid in `ℝ` or any topological division @@ -85,7 +84,7 @@ algebra over `ℚ≥0`, e.g., `ℂ`). -/ theorem tendsto_natCast_div_add_atTop {𝕜 : Type*} [DivisionSemiring 𝕜] [TopologicalSpace 𝕜] [CharZero 𝕜] [ContinuousSMul ℚ≥0 𝕜] [IsTopologicalSemiring 𝕜] [ContinuousInv₀ 𝕜] (x : 𝕜) : Tendsto (fun n : ℕ ↦ (n : 𝕜) / (n + x)) atTop (𝓝 1) := by - convert Tendsto.congr' ((eventually_ne_atTop 0).mp (Eventually.of_forall fun n hn ↦ _)) _ + convert! Tendsto.congr' ((eventually_ne_atTop 0).mp (Eventually.of_forall fun n hn ↦ _)) _ · exact fun n : ℕ ↦ 1 / (1 + x / n) · simp [Nat.cast_ne_zero.mpr hn, add_div'] · have : 𝓝 (1 : 𝕜) = 𝓝 (1 / (1 + x * (0 : 𝕜))) := by @@ -331,7 +330,7 @@ theorem tsum_geometric_of_lt_one {r : ℝ} (h₁ : 0 ≤ r) (h₂ : r < 1) : ∑ (hasSum_geometric_of_lt_one h₁ h₂).tsum_eq theorem hasSum_geometric_two : HasSum (fun n : ℕ ↦ ((1 : ℝ) / 2) ^ n) 2 := by - convert hasSum_geometric_of_lt_one _ _ <;> norm_num + convert! hasSum_geometric_of_lt_one _ _ <;> norm_num theorem summable_geometric_two : Summable fun n : ℕ ↦ ((1 : ℝ) / 2) ^ n := ⟨_, hasSum_geometric_two⟩ @@ -348,7 +347,7 @@ theorem sum_geometric_two_le (n : ℕ) : (∑ i ∈ range n, (1 / (2 : ℝ)) ^ i intro i apply pow_nonneg norm_num - convert summable_geometric_two.sum_le_tsum (range n) (fun i _ ↦ this i) + convert! summable_geometric_two.sum_le_tsum (range n) (fun i _ ↦ this i) exact tsum_geometric_two.symm theorem tsum_geometric_inv_two : (∑' n : ℕ, (2 : ℝ)⁻¹ ^ n) = 2 := @@ -367,7 +366,8 @@ theorem tsum_geometric_inv_two_ge (n : ℕ) : le_add_iff_nonneg_left, pow_add, _root_.tsum_mul_right, tsum_geometric_inv_two] theorem hasSum_geometric_two' (a : ℝ) : HasSum (fun n : ℕ ↦ a / 2 / 2 ^ n) a := by - convert HasSum.mul_left (a / 2) + convert! + HasSum.mul_left (a / 2) (hasSum_geometric_of_lt_one (le_of_lt one_half_pos) one_half_lt_one) using 1 · funext n simp only [one_div, inv_pow] @@ -402,7 +402,7 @@ theorem ENNReal.tsum_geometric (r : ℝ≥0∞) : ∑' n : ℕ, r ^ n = (1 - r) rcases lt_or_ge r 1 with hr | hr · rcases ENNReal.lt_iff_exists_coe.1 hr with ⟨r, rfl, hr'⟩ norm_cast at * - convert ENNReal.tsum_coe_eq (NNReal.hasSum_geometric hr) + convert! ENNReal.tsum_coe_eq (NNReal.hasSum_geometric hr) rw [ENNReal.coe_inv <| ne_of_gt <| tsub_pos_iff_lt.2 hr, coe_sub, coe_one] · rw [tsub_eq_zero_iff_le.mpr hr, ENNReal.inv_zero, ENNReal.tsum_eq_iSup_nat, iSup_eq_top] refine fun a ha ↦ @@ -464,7 +464,7 @@ include hu in `f n` to the limit of `f` is bounded above by `C * r^n / (1 - r)`. -/ theorem edist_le_of_edist_le_geometric_of_tendsto {a : α} (ha : Tendsto f atTop (𝓝 a)) (n : ℕ) : edist (f n) a ≤ C * r ^ n / (1 - r) := by - convert edist_le_tsum_of_edist_le_of_tendsto _ hu ha _ + convert! edist_le_tsum_of_edist_le_of_tendsto _ hu ha _ simp only [pow_add, ENNReal.tsum_mul_left, ENNReal.tsum_geometric, div_eq_mul_inv, mul_assoc] include hu in @@ -494,7 +494,7 @@ include hu ha in theorem edist_le_of_edist_le_geometric_two_of_tendsto (n : ℕ) : edist (f n) a ≤ 2 * C / 2 ^ n := by simp only [div_eq_mul_inv, ENNReal.inv_pow] at * rw [mul_assoc, mul_comm] - convert edist_le_of_edist_le_geometric_of_tendsto 2⁻¹ C hu ha n using 1 + convert! edist_le_of_edist_le_geometric_of_tendsto 2⁻¹ C hu ha n using 1 rw [ENNReal.one_sub_inv_two, div_eq_mul_inv, inv_inv] include hu ha in @@ -540,7 +540,7 @@ theorem dist_le_of_le_geometric_of_tendsto₀ {a : α} (ha : Tendsto f atTop ( theorem dist_le_of_le_geometric_of_tendsto {a : α} (ha : Tendsto f atTop (𝓝 a)) (n : ℕ) : dist (f n) a ≤ C * r ^ n / (1 - r) := by have := aux_hasSum_of_le_geometric hr hu - convert dist_le_tsum_of_dist_le_of_tendsto _ hu ⟨_, this⟩ ha n + convert! dist_le_tsum_of_dist_le_of_tendsto _ hu ⟨_, this⟩ ha n simp only [pow_add, mul_left_comm C, mul_div_right_comm] rw [mul_comm] exact (this.mul_left _).tsum_eq.symm @@ -564,7 +564,7 @@ theorem dist_le_of_le_geometric_two_of_tendsto₀ {a : α} (ha : Tendsto f atTop `f n` to the limit of `f` is bounded above by `C / 2^n`. -/ theorem dist_le_of_le_geometric_two_of_tendsto {a : α} (ha : Tendsto f atTop (𝓝 a)) (n : ℕ) : dist (f n) a ≤ C / 2 ^ n := by - convert dist_le_tsum_of_dist_le_of_tendsto _ hu₂ (summable_geometric_two' C) ha n + convert! dist_le_tsum_of_dist_le_of_tendsto _ hu₂ (summable_geometric_two' C) ha n simp only [add_comm n, pow_add, ← div_div] symm exact ((hasSum_geometric_two' C).div_const _).tsum_eq diff --git a/Mathlib/Analysis/SpecificLimits/Fibonacci.lean b/Mathlib/Analysis/SpecificLimits/Fibonacci.lean index 8423b2c198dab6..f7c6231eb10990 100644 --- a/Mathlib/Analysis/SpecificLimits/Fibonacci.lean +++ b/Mathlib/Analysis/SpecificLimits/Fibonacci.lean @@ -35,6 +35,6 @@ theorem tendsto_fib_succ_div_fib_atTop : /-- The limit of `fib n / fib (n + 1)` as `n → ∞` is the negative conjugate of the golden ratio. -/ theorem tendsto_fib_div_fib_succ_atTop : Tendsto (fun n ↦ (fib n / fib (n + 1) : ℝ)) atTop (𝓝 (-ψ)) := by - convert tendsto_fib_succ_div_fib_atTop.inv₀ (by positivity) using 2 + convert! tendsto_fib_succ_div_fib_atTop.inv₀ (by positivity) using 2 · rw [inv_div] · rw [inv_goldenRatio] diff --git a/Mathlib/Analysis/SpecificLimits/FloorPow.lean b/Mathlib/Analysis/SpecificLimits/FloorPow.lean index fa299173faec20..34f9f3fb667f6b 100644 --- a/Mathlib/Analysis/SpecificLimits/FloorPow.lean +++ b/Mathlib/Analysis/SpecificLimits/FloorPow.lean @@ -203,7 +203,7 @@ theorem tendsto_div_of_monotone_of_tendsto_div_floor_pow (u : ℕ → ℝ) (l : exact tendsto_pow_atTop_atTop_of_one_lt (cone k) have B : Tendsto (fun n : ℕ => (⌊c k ^ (n + 1)⌋₊ : ℝ) / ⌊c k ^ n⌋₊) atTop (𝓝 (c k)) := by simp only [one_mul, div_one] at A - convert A using 1 + convert! A using 1 ext1 n field [(zero_lt_one.trans (cone k)).ne'] filter_upwards [(tendsto_order.1 B).2 a hk] with n hn diff --git a/Mathlib/Analysis/SpecificLimits/Normed.lean b/Mathlib/Analysis/SpecificLimits/Normed.lean index 8defaef2b591c0..3e35c746f7fcfe 100644 --- a/Mathlib/Analysis/SpecificLimits/Normed.lean +++ b/Mathlib/Analysis/SpecificLimits/Normed.lean @@ -298,7 +298,7 @@ theorem tsum_geometric_le_of_norm_lt_one (x : R) (h : ‖x‖ < 1) : refine le_trans (norm_add_le _ _) ?_ have : ‖∑' b : ℕ, (fun n ↦ x ^ (n + 1)) b‖ ≤ (1 - ‖x‖)⁻¹ - 1 := by refine tsum_of_norm_bounded ?_ fun b ↦ norm_pow_le' _ (Nat.succ_pos b) - convert (hasSum_nat_add_iff' 1).mpr (hasSum_geometric_of_lt_one (norm_nonneg x) h) + convert! (hasSum_nat_add_iff' 1).mpr (hasSum_geometric_of_lt_one (norm_nonneg x) h) simp linarith · simp only [tsum_eq_zero_of_not_summable hx, norm_zero] @@ -344,7 +344,7 @@ theorem geom_series_eq_inverse (x : R) (h : ‖x‖ < 1) : theorem hasSum_geom_series_inverse (x : R) (h : ‖x‖ < 1) : HasSum (fun i ↦ x ^ i) (1 - x)⁻¹ʳ := by - convert (summable_geometric_of_norm_lt_one h).hasSum + convert! (summable_geometric_of_norm_lt_one h).hasSum exact (geom_series_eq_inverse x h).symm lemma isUnit_one_sub_of_norm_lt_one {x : R} (h : ‖x‖ < 1) : IsUnit (1 - x) := @@ -448,8 +448,10 @@ lemma hasSum_choose_mul_geometric_of_norm_lt_one' _ ≤ (2 * n).choose k := choose_le_choose k (by lia) _ ≤ (2 * n) ^ k := Nat.choose_le_pow _ _ _ = 2 ^ k * n ^ k := Nat.mul_pow 2 n k - convert hasSum_sum_range_mul_of_summable_norm' I1 ih.summable - (summable_norm_geometric_of_norm_lt_one hr) (summable_geometric_of_norm_lt_one hr) with n + convert! + hasSum_sum_range_mul_of_summable_norm' I1 ih.summable + (summable_norm_geometric_of_norm_lt_one hr) (summable_geometric_of_norm_lt_one hr) with + n · have : ∑ i ∈ Finset.range (n + 1), ↑((i + k).choose k) * r ^ i * r ^ (n - i) = ∑ i ∈ Finset.range (n + 1), ↑((i + k).choose k) * r ^ n := by apply Finset.sum_congr rfl (fun i hi ↦ ?_) @@ -469,7 +471,7 @@ lemma tsum_choose_mul_geometric_of_norm_lt_one' (k : ℕ) {r : R} (hr : ‖r‖ lemma hasSum_choose_mul_geometric_of_norm_lt_one (k : ℕ) {r : 𝕜} (hr : ‖r‖ < 1) : HasSum (fun n ↦ (n + k).choose k * r ^ n) (1 / (1 - r) ^ (k + 1)) := by - convert hasSum_choose_mul_geometric_of_norm_lt_one' k hr + convert! hasSum_choose_mul_geometric_of_norm_lt_one' k hr simp lemma tsum_choose_mul_geometric_of_norm_lt_one (k : ℕ) {r : 𝕜} (hr : ‖r‖ < 1) : @@ -478,8 +480,8 @@ lemma tsum_choose_mul_geometric_of_norm_lt_one (k : ℕ) {r : 𝕜} (hr : ‖r lemma summable_descFactorial_mul_geometric_of_norm_lt_one (k : ℕ) {r : R} (hr : ‖r‖ < 1) : Summable (fun n ↦ (n + k).descFactorial k * r ^ n) := by - convert (summable_choose_mul_geometric_of_norm_lt_one k hr).mul_left (k.factorial : R) - using 2 with n + convert! (summable_choose_mul_geometric_of_norm_lt_one k hr).mul_left (k.factorial : R) using + 2 with n simp [← mul_assoc, descFactorial_eq_factorial_mul_choose (n + k) k] open Polynomial in @@ -505,7 +507,7 @@ theorem summable_pow_mul_geometric_of_norm_lt_one (k : ℕ) {r : R} (hr : ‖r simp_rw [mul_assoc] simp only [Finset.mem_range] at hi exact (hk _ hi).mul_left _ - convert this using 1 + convert! this using 1 ext n simp [ha n, add_mul, sum_mul] @@ -516,10 +518,10 @@ theorem hasSum_coe_mul_geometric_of_norm_lt_one' {x : R} (h : ‖x‖ < 1) : HasSum (fun n ↦ n * x ^ n : ℕ → R) (x * ((1 - x)⁻¹ʳ) ^ 2) := by have A : HasSum (fun (n : ℕ) ↦ (n + 1) * x ^ n) ((1 - x)⁻¹ʳ ^ 2) := by - convert hasSum_choose_mul_geometric_of_norm_lt_one' 1 h with n + convert! hasSum_choose_mul_geometric_of_norm_lt_one' 1 h with n simp have B : HasSum (fun (n : ℕ) ↦ x ^ n) ((1 - x)⁻¹ʳ) := hasSum_geom_series_inverse x h - convert A.sub B using 1 + convert! A.sub B using 1 · ext n simp [add_mul] · symm @@ -538,7 +540,7 @@ theorem tsum_coe_mul_geometric_of_norm_lt_one' /-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`, `HasSum` version. -/ theorem hasSum_coe_mul_geometric_of_norm_lt_one {r : 𝕜} (hr : ‖r‖ < 1) : HasSum (fun n ↦ n * r ^ n : ℕ → 𝕜) (r / (1 - r) ^ 2) := by - convert hasSum_coe_mul_geometric_of_norm_lt_one' hr using 1 + convert! hasSum_coe_mul_geometric_of_norm_lt_one' hr using 1 simp [div_eq_mul_inv] /-- If `‖r‖ < 1`, then `∑' n : ℕ, n * r ^ n = r / (1 - r) ^ 2`. -/ @@ -638,7 +640,7 @@ theorem summable_of_ratio_norm_eventually_le {α : Type*} [SeminormedAddCommGrou simp only conv_rhs => rw [mul_comm, ← zero_add N] refine le_geom (u := fun n ↦ ‖f (n + N)‖) hr₀ n fun i _ ↦ ?_ - convert hN (i + N) (N.le_add_left i) using 3 + convert! hN (i + N) (N.le_add_left i) using 3 ac_rfl · refine .of_norm_bounded_eventually_nat summable_zero ?_ filter_upwards [h] with _ hn @@ -663,7 +665,7 @@ theorem not_summable_of_ratio_norm_eventually_ge {α : Type*} [SeminormedAddComm rw [← @summable_nat_add_iff α _ _ _ _ N] refine mt Summable.tendsto_atTop_zero fun h' ↦ not_tendsto_atTop_of_tendsto_nhds (tendsto_norm_zero.comp h') ?_ - convert tendsto_atTop_of_geom_le _ hr _ + convert! tendsto_atTop_of_geom_le _ hr _ · refine lt_of_le_of_ne (norm_nonneg _) ?_ intro h'' specialize hN₀ N hNN₀ @@ -742,9 +744,9 @@ theorem Antitone.cauchySeq_series_mul_of_tendsto_zero_of_bounded (hfa : Antitone CauchySeq fun n ↦ ∑ i ∈ range n, f i • z i := by have hfa' : Monotone fun n ↦ -f n := fun _ _ hab ↦ neg_le_neg <| hfa hab have hf0' : Tendsto (fun n ↦ -f n) atTop (𝓝 0) := by - convert hf0.neg + convert! hf0.neg simp - convert (hfa'.cauchySeq_series_mul_of_tendsto_zero_of_bounded hf0' hzb).neg + convert! (hfa'.cauchySeq_series_mul_of_tendsto_zero_of_bounded hf0' hzb).neg simp theorem norm_sum_neg_one_pow_le (n : ℕ) : ‖∑ i ∈ range n, (-1 : ℝ) ^ i‖ ≤ 1 := by @@ -950,6 +952,7 @@ lemma tendsto_smul_congr_of_tendsto_left_cobounded_of_isBoundedUnder · rw [← tendsto_zero_iff_norm_tendsto_zero] exact tendsto_zero_of_isBoundedUnder_smul_of_tendsto_cobounded hmul.norm.isBoundedUnder_le hf₁ +set_option linter.overlappingInstances false in -- The use case in mind for this is when `K = ℝ`, and `R = ℝ` or `ℂ` lemma tendsto_smul_comp_nat_floor_of_tendsto_nsmul [NormSMulClass ℤ K] [LinearOrder K] [IsStrictOrderedRing K] [FloorSemiring K] [HasSolidNorm K] {g : ℕ → R} {t : R} diff --git a/Mathlib/Analysis/SumIntegralComparisons.lean b/Mathlib/Analysis/SumIntegralComparisons.lean index 3f94e17c23565f..8b7e0f244ba4bc 100644 --- a/Mathlib/Analysis/SumIntegralComparisons.lean +++ b/Mathlib/Analysis/SumIntegralComparisons.lean @@ -75,8 +75,10 @@ lemma integral_le_sum_Ico_of_le (hab : a ≤ b) (h : ∀ i ∈ Ico a b, ∀ x ∈ Ico (i : ℝ) (i + 1 : ℕ), g x ≤ f i) (hg : IntegrableOn g (Set.Ico a b)) : ∫ x in a..b, g x ≤ ∑ i ∈ Finset.Ico a b, f i := by - convert neg_le_neg (sum_Ico_le_integral_of_le (f := -f) (g := -g) hab - (fun i hi x hx ↦ neg_le_neg (h i hi x hx)) hg.neg) <;> simp + convert! + neg_le_neg + (sum_Ico_le_integral_of_le (f := -f) (g := -g) hab (fun i hi x hx ↦ neg_le_neg (h i hi x hx)) + hg.neg) <;> simp theorem AntitoneOn.integral_le_sum (hf : AntitoneOn f (Icc x₀ (x₀ + a))) : (∫ x in x₀..x₀ + a, f x) ≤ ∑ i ∈ Finset.range a, f (x₀ + i) := by @@ -90,7 +92,7 @@ theorem AntitoneOn.integral_le_sum (hf : AntitoneOn f (Icc x₀ (x₀ + a))) : · simp only [add_le_add_iff_left, Nat.cast_le, Nat.le_succ] calc ∫ x in x₀..x₀ + a, f x = ∑ i ∈ Finset.range a, ∫ x in x₀ + i..x₀ + (i + 1 : ℕ), f x := by - convert (intervalIntegral.sum_integral_adjacent_intervals hint).symm + convert! (intervalIntegral.sum_integral_adjacent_intervals hint).symm simp only [Nat.cast_zero, add_zero] _ ≤ ∑ i ∈ Finset.range a, ∫ _ in x₀ + i..x₀ + (i + 1 : ℕ), f (x₀ + i) := by gcongr with i hi @@ -151,7 +153,7 @@ theorem AntitoneOn.sum_le_integral (hf : AntitoneOn f (Icc x₀ (x₀ + a))) : · refine mem_Icc.2 ⟨le_add_of_nonneg_right (Nat.cast_nonneg _), ?_⟩ simp only [add_le_add_iff_left, Nat.cast_le, ia] _ = ∫ x in x₀..x₀ + a, f x := by - convert intervalIntegral.sum_integral_adjacent_intervals hint + convert! intervalIntegral.sum_integral_adjacent_intervals hint simp only [Nat.cast_zero, add_zero] theorem AntitoneOn.sum_le_integral_Ico (hab : a ≤ b) (hf : AntitoneOn f (Set.Icc a b)) : diff --git a/Mathlib/Analysis/SumOverResidueClass.lean b/Mathlib/Analysis/SumOverResidueClass.lean index 87d8ea7e7248a1..b29da2f5d98ff7 100644 --- a/Mathlib/Analysis/SumOverResidueClass.lean +++ b/Mathlib/Analysis/SumOverResidueClass.lean @@ -44,7 +44,7 @@ lemma summable_indicator_mod_iff_summable {R : Type*} [AddCommGroup R] [Topologi intro n hn contrapose! hn exact (Nat.range_mul_add m k).symm ▸ mem_of_indicator_ne_zero hn - convert (Function.Injective.summable_iff hg hg').symm using 3 + convert! (Function.Injective.summable_iff hg hg').symm using 3 simp only [Function.comp_apply, mem_setOf_eq, Nat.cast_add, Nat.cast_mul, CharP.cast_eq_zero, zero_mul, zero_add, le_add_iff_nonneg_left, zero_le, and_self, indicator_of_mem, g] @@ -92,8 +92,9 @@ lemma summable_indicator_mod_iff {m : ℕ} [NeZero m] {f : ℕ → ℝ} (hf : An Summable ({n : ℕ | (n : ZMod m) = k}.indicator f) ↔ Summable f := by refine ⟨fun H ↦ ?_, fun H ↦ Summable.indicator H _⟩ rw [Finset.sum_indicator_mod m f] - convert summable_sum (s := Finset.univ) - fun a _ ↦ summable_indicator_mod_iff_summable_indicator_mod hf a H + convert! + summable_sum (s := Finset.univ) fun a _ ↦ + summable_indicator_mod_iff_summable_indicator_mod hf a H simp only [Finset.sum_apply] open ZMod diff --git a/Mathlib/CategoryTheory/Abelian/Basic.lean b/Mathlib/CategoryTheory/Abelian/Basic.lean index 06d807758cb9d0..9f7d3225a75779 100644 --- a/Mathlib/CategoryTheory/Abelian/Basic.lean +++ b/Mathlib/CategoryTheory/Abelian/Basic.lean @@ -208,7 +208,7 @@ lemma isNormalMonoCategory : IsNormalMonoCategory C where rw [KernelFork.ι_ofι] at hg rw [← cancel_mono f, hg, ← aux, KernelFork.ι_ofι] · simp only [KernelFork.ι_ofι, Category.assoc] - convert limit.lift_π s WalkingParallelPair.zero using 2 + convert! limit.lift_π s WalkingParallelPair.zero using 2 rw [IsIso.inv_comp_eq, eq_comm] exact (imageMonoFactorisation f).fac }⟩ @@ -235,7 +235,7 @@ lemma isNormalEpiCategory : IsNormalEpiCategory C where rw [CokernelCofork.π_ofπ] at hg rw [← cancel_epi f, hg, ← aux, CokernelCofork.π_ofπ] · simp only [CokernelCofork.π_ofπ, ← Category.assoc] - convert colimit.ι_desc s WalkingParallelPair.one using 2 + convert! colimit.ι_desc s WalkingParallelPair.one using 2 rw [IsIso.comp_inv_eq, IsIso.comp_inv_eq, eq_comm, ← imageMonoFactorisation_e'] exact (imageMonoFactorisation f).fac }⟩ @@ -380,7 +380,7 @@ set_option backward.isDefEq.respectTransparency false in See `CategoryTheory.Abelian.ofCoimageImageComparisonIsIso` for the converse. -/ instance : IsIso (coimageImageComparison f) := by - convert + convert! Iso.isIso_hom (IsImage.isoExt (coimageStrongEpiMonoFactorisation f).toMonoIsImage (imageStrongEpiMonoFactorisation f).toMonoIsImage) diff --git a/Mathlib/CategoryTheory/Abelian/GrothendieckCategory/EnoughInjectives.lean b/Mathlib/CategoryTheory/Abelian/GrothendieckCategory/EnoughInjectives.lean index 7f35272a940182..04ea5c03facb02 100644 --- a/Mathlib/CategoryTheory/Abelian/GrothendieckCategory/EnoughInjectives.lean +++ b/Mathlib/CategoryTheory/Abelian/GrothendieckCategory/EnoughInjectives.lean @@ -254,8 +254,8 @@ noncomputable def transfiniteCompositionOfShapeMapFromBot (j : J) : isColimit := colimitOfDiagramTerminal isTerminalTop _ map_mem k hk := by dsimp [MonoOver.forget] - convert pushouts_ofLE_le_largerSubobject hG - (transfiniteIterate (largerSubobject hG) k.1 A₀) using 2 + convert! + pushouts_ofLE_le_largerSubobject hG (transfiniteIterate (largerSubobject hG) k.1 A₀) using 2 all_goals rw [Set.Iic.succ_eq_of_not_isMax hk, transfiniteIterate_succ _ _ _ (Set.not_isMax_coe _ hk)] diff --git a/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean b/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean index 8857a1aa064c6e..21e1139fae40f8 100644 --- a/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean +++ b/Mathlib/CategoryTheory/Abelian/NonPreadditive.lean @@ -246,7 +246,7 @@ instance epi_r {A : C} : Epi (r A) := by · intro s m h haveI : Mono (prod.lift (𝟙 A) (0 : A ⟶ A)) := mono_of_mono_fac (prod.lift_fst _ _) apply (cancel_mono (prod.lift (𝟙 A) (0 : A ⟶ A))).1 - convert h + convert! h apply Limits.prod.hom_ext <;> simp let hp2 : IsColimit (CokernelCofork.ofπ (Limits.prod.snd : A ⨯ A ⟶ A) hlp) := epiIsCokernelOfKernel _ hp1 diff --git a/Mathlib/CategoryTheory/Abelian/Pseudoelements.lean b/Mathlib/CategoryTheory/Abelian/Pseudoelements.lean index 495672a4b366ac..e7709d66db784b 100644 --- a/Mathlib/CategoryTheory/Abelian/Pseudoelements.lean +++ b/Mathlib/CategoryTheory/Abelian/Pseudoelements.lean @@ -272,7 +272,8 @@ theorem pseudo_injective_of_mono {P Q : C} (f : P ⟶ Q) [Mono f] : Function.Inj intro abar abar' induction abar, abar' using Quotient.inductionOn₂ with | _ a a' refine fun ha ↦ Quotient.sound ?_ - have : (⟦(a.hom ≫ f : Over Q)⟧ : Quotient (setoid Q)) = ⟦↑(a'.hom ≫ f)⟧ := by convert ha + have : (⟦(a.hom ≫ f : Over Q)⟧ : Quotient (setoid Q)) = ⟦↑(a'.hom ≫ f)⟧ := by convert! + ha have ⟨R, p, q, ep, Eq, comm⟩ := Quotient.exact this exact ⟨R, p, q, ep, Eq, (cancel_mono f).1 <| by simp only [Category.assoc] diff --git a/Mathlib/CategoryTheory/Adhesive/Basic.lean b/Mathlib/CategoryTheory/Adhesive/Basic.lean index 7a11a34188b3e5..75fb2b48e07d30 100644 --- a/Mathlib/CategoryTheory/Adhesive/Basic.lean +++ b/Mathlib/CategoryTheory/Adhesive/Basic.lean @@ -94,8 +94,8 @@ theorem IsPushout.isVanKampen_iff (H : IsPushout f g h i) : · intro H F' c' α fα eα hα refine Iff.trans ?_ ((H (F'.map WalkingSpan.Hom.fst) (F'.map WalkingSpan.Hom.snd) (c'.ι.app _) (c'.ι.app _) - (α.app _) (α.app _) (α.app _) fα (by convert hα WalkingSpan.Hom.fst) - (by convert hα WalkingSpan.Hom.snd) ?_ ?_ ?_).trans ?_) + (α.app _) (α.app _) (α.app _) fα (by convert! hα WalkingSpan.Hom.fst) + (by convert! hα WalkingSpan.Hom.snd) ?_ ?_ ?_).trans ?_) · have : F'.map WalkingSpan.Hom.fst ≫ c'.ι.app WalkingSpan.left = F'.map WalkingSpan.Hom.snd ≫ c'.ι.app WalkingSpan.right := by simp only [Cocone.w] @@ -183,7 +183,8 @@ theorem is_coprod_iff_isPushout {X E Y YE : C} (c : BinaryCofan X E) (hc : IsCol refine ⟨H, ⟨Limits.PushoutCocone.isColimitAux' _ ?_⟩⟩ intro s dsimp - refine ⟨h.desc (BinaryCofan.mk (c.inr ≫ s.inr) s.inl), h.fac _ ⟨WalkingPair.right⟩, ?_, ?_⟩ + refine ⟨BinaryCofan.IsColimit.desc h (c.inr ≫ s.inr) s.inl, + BinaryCofan.IsColimit.inr_desc h _ _, ?_, ?_⟩ · apply BinaryCofan.IsColimit.hom_ext hc · rw [← H.w_assoc]; erw [h.fac _ ⟨WalkingPair.right⟩]; exact s.condition · rw [← Category.assoc]; exact h.fac _ ⟨WalkingPair.left⟩ diff --git a/Mathlib/CategoryTheory/Adjunction/FullyFaithful.lean b/Mathlib/CategoryTheory/Adjunction/FullyFaithful.lean index fcf8ee9bc006ff..5de687029c1d24 100644 --- a/Mathlib/CategoryTheory/Adjunction/FullyFaithful.lean +++ b/Mathlib/CategoryTheory/Adjunction/FullyFaithful.lean @@ -277,8 +277,10 @@ theorem isIso_map_unit_of_isLeftAdjoint_comp {E : Type*} [Category* E] let FF := FullyFaithful.ofFullyFaithful R apply isIso_of_coyoneda_map_bijective intro Y - convert ((adj2.homEquiv (R.obj (L.obj X)) Y).trans <| FF.homEquiv.symm.trans <| - (h.homEquiv X (S.obj Y)).trans (adj2.homEquiv X Y).symm).bijective using 1 + convert! + ((adj2.homEquiv (R.obj (L.obj X)) Y).trans <| + FF.homEquiv.symm.trans <| + (h.homEquiv X (S.obj Y)).trans (adj2.homEquiv X Y).symm).bijective using 1 ext x have := adj2.counit_naturality x simp_all [Adjunction.homEquiv] diff --git a/Mathlib/CategoryTheory/Category/Basic.lean b/Mathlib/CategoryTheory/Category/Basic.lean index 1a55f91f20c3e1..247a1928c37d7c 100644 --- a/Mathlib/CategoryTheory/Category/Basic.lean +++ b/Mathlib/CategoryTheory/Category/Basic.lean @@ -295,16 +295,16 @@ scoped infixr:80 " ≫= " => whisker_eq @[to_dual eq_of_comp_right_eq] theorem eq_of_comp_left_eq {f g : X ⟶ Y} (w : ∀ {Z : C} (h : Y ⟶ Z), f ≫ h = g ≫ h) : f = g := by - convert w (𝟙 Y) <;> simp + convert! w (𝟙 Y) <;> simp @[to_dual eq_of_comp_right_eq'] theorem eq_of_comp_left_eq' (f g : X ⟶ Y) (w : (fun {Z} (h : Y ⟶ Z) => f ≫ h) = fun {Z} (h : Y ⟶ Z) => g ≫ h) : f = g := - eq_of_comp_left_eq @fun Z h => by convert congr_fun (congr_fun w Z) h + eq_of_comp_left_eq @fun Z h => by convert! congr_fun (congr_fun w Z) h @[to_dual id_of_comp_right_id] theorem id_of_comp_left_id (f : X ⟶ X) (w : ∀ {Y : C} (g : X ⟶ Y), f ≫ g = g) : f = 𝟙 X := by - convert w (𝟙 X) + convert! w (𝟙 X) simp @[to_dual (reorder := f g' g) ite_comp] @@ -344,7 +344,7 @@ theorem cancel_epi_assoc_iff (f : X ⟶ Y) [Epi f] {g h : Y ⟶ Z} {W : C} {k l @[to_dual] theorem cancel_epi_id (f : X ⟶ Y) [Epi f] {h : Y ⟶ Y} : f ≫ h = f ↔ h = 𝟙 Y := by - convert cancel_epi f + convert! cancel_epi f simp /-- The composition of epimorphisms is again an epimorphism. This version takes `Epi f` and `Epi g` diff --git a/Mathlib/CategoryTheory/Category/PartialFun.lean b/Mathlib/CategoryTheory/Category/PartialFun.lean index ecd59cab06f707..64b08617c38de7 100644 --- a/Mathlib/CategoryTheory/Category/PartialFun.lean +++ b/Mathlib/CategoryTheory/Category/PartialFun.lean @@ -111,7 +111,7 @@ noncomputable def partialFunToPointed : PartialFun ⥤ Pointed := by map := fun f => ⟨Option.elim' none fun a => (f a).toOption, rfl⟩ map_id := fun X => Pointed.Hom.ext <| funext fun o => Option.recOn o rfl fun a => (by dsimp [CategoryStruct.id] - convert Part.some_toOption a) + convert! Part.some_toOption a) map_comp := fun f g => Pointed.Hom.ext <| funext fun o => Option.recOn o rfl fun a => by dsimp [CategoryStruct.comp] rw [Part.bind_toOption g (f a), Option.elim'_eq_elim] } @@ -172,5 +172,5 @@ noncomputable def typeToPartialFunIsoPartialFunToPointed : fun f => Pointed.Hom.ext <| funext fun a => Option.recOn a rfl fun a => by - convert Part.some_toOption _ + convert! Part.some_toOption _ simpa using (Part.get_eq_iff_mem (by trivial)).mp rfl diff --git a/Mathlib/CategoryTheory/CofilteredSystem.lean b/Mathlib/CategoryTheory/CofilteredSystem.lean index ae3d9b169742fd..b69d6870326a84 100644 --- a/Mathlib/CategoryTheory/CofilteredSystem.lean +++ b/Mathlib/CategoryTheory/CofilteredSystem.lean @@ -169,7 +169,7 @@ def toPreimages : J ⥤ Type v where rw [mem_iInter] at h ⊢ intro f rw [← mem_preimage, preimage_preimage, mem_preimage] - convert h (g ≫ f); rw [F.map_comp]; rfl) + convert! h (g ≫ f); rw [F.map_comp]; rfl) instance toPreimages_finite [∀ j, Finite (F.obj j)] : ∀ j, Finite ((F.toPreimages s).obj j) := fun _ => Subtype.finite diff --git a/Mathlib/CategoryTheory/Comma/Final.lean b/Mathlib/CategoryTheory/Comma/Final.lean index 45ef53f49668ff..7cfb87dbd53f62 100644 --- a/Mathlib/CategoryTheory/Comma/Final.lean +++ b/Mathlib/CategoryTheory/Comma/Final.lean @@ -57,7 +57,7 @@ private lemma final_fst_small [R.Final] : (fst L R).Final := by (Final.colimitIso (Grothendieck.pre (functor L) R) (grothendieckProj L ⋙ G)).symm ≪≫ HasColimit.isoOfNatIso (Iso.refl _) ≪≫ Final.colimitIso (grothendieckPrecompFunctorEquivalence L R).functor (fst L R ⋙ G) - convert i.isIso_inv + convert! i.isIso_inv apply colimit.hom_ext intro ⟨a, b, f⟩ simp only [colimit.ι_pre, comp_obj, fst_obj, grothendieckPrecompFunctorEquivalence_functor, diff --git a/Mathlib/CategoryTheory/Comma/StructuredArrow/Final.lean b/Mathlib/CategoryTheory/Comma/StructuredArrow/Final.lean index 2f1b4b60f6abb4..73ac1c5cb28d5f 100644 --- a/Mathlib/CategoryTheory/Comma/StructuredArrow/Final.lean +++ b/Mathlib/CategoryTheory/Comma/StructuredArrow/Final.lean @@ -57,7 +57,7 @@ private lemma final_of_final_costructuredArrowToOver_small (L : A ⥤ T) (R : B _ ≅ colimit <| grothendieckProj (𝟭 T) ⋙ G := Final.colimitIso _ _ _ ≅ colimit G := (colimitIsoColimitGrothendieck (𝟭 T) G).symm - convert Iso.isIso_hom i + convert! Iso.isIso_hom i simp only [Iso.trans_def, comp_obj, grothendieckProj_obj, Grothendieck.pre_obj_base, Grothendieck.pre_obj_fiber, Iso.trans_assoc, Iso.trans_hom, Iso.symm_hom, i] rw [← Iso.inv_comp_eq, Iso.eq_inv_comp] diff --git a/Mathlib/CategoryTheory/Dialectica/Monoidal.lean b/Mathlib/CategoryTheory/Dialectica/Monoidal.lean index 1f2f7e26ffc636..720e1466f935d9 100644 --- a/Mathlib/CategoryTheory/Dialectica/Monoidal.lean +++ b/Mathlib/CategoryTheory/Dialectica/Monoidal.lean @@ -52,11 +52,11 @@ set_option backward.isDefEq.respectTransparency false in · have := (Subobject.pullback (prod.map π₁ π₁ : (X₁.src ⨯ Y₁.src) ⨯ X₂.tgt ⨯ Y₂.tgt ⟶ _)).monotone (Hom.le f) rw [← Subobject.pullback_comp, ← Subobject.pullback_comp] at this - convert this using 3 <;> simp + convert! this using 3 <;> simp · have := (Subobject.pullback (prod.map π₂ π₂ : (X₁.src ⨯ Y₁.src) ⨯ X₂.tgt ⨯ Y₂.tgt ⟶ _)).monotone (Hom.le g) rw [← Subobject.pullback_comp, ← Subobject.pullback_comp] at this - convert this using 3 <;> simp + convert! this using 3 <;> simp /-- The unit for the tensor `X ⊗ Y` in `Dial C`. -/ @[simps] def tensorUnitImpl : Dial C := { src := ⊤_ _, tgt := ⊤_ _, rel := ⊤ } diff --git a/Mathlib/CategoryTheory/DifferentialObject.lean b/Mathlib/CategoryTheory/DifferentialObject.lean index 5f756fa36b4e6b..f955c315e588fa 100644 --- a/Mathlib/CategoryTheory/DifferentialObject.lean +++ b/Mathlib/CategoryTheory/DifferentialObject.lean @@ -311,16 +311,16 @@ instance : HasShift (DifferentialObject S C) S := add := shiftFunctorAdd C assoc_hom_app := fun m₁ m₂ m₃ X => by ext1 - convert shiftFunctorAdd_assoc_hom_app m₁ m₂ m₃ X.obj + convert! shiftFunctorAdd_assoc_hom_app m₁ m₂ m₃ X.obj dsimp [shiftFunctorAdd'] simp zero_add_hom_app := fun n X => by ext1 - convert shiftFunctorAdd_zero_add_hom_app n X.obj + convert! shiftFunctorAdd_zero_add_hom_app n X.obj simp add_zero_hom_app := fun n X => by ext1 - convert shiftFunctorAdd_add_zero_hom_app n X.obj + convert! shiftFunctorAdd_add_zero_hom_app n X.obj simp } end diff --git a/Mathlib/CategoryTheory/EffectiveEpi/Extensive.lean b/Mathlib/CategoryTheory/EffectiveEpi/Extensive.lean index c311f3fb4b0695..056791f16214a0 100644 --- a/Mathlib/CategoryTheory/EffectiveEpi/Extensive.lean +++ b/Mathlib/CategoryTheory/EffectiveEpi/Extensive.lean @@ -39,15 +39,15 @@ instance [F.ReflectsEffectiveEpis] : F.ReflectsFiniteEffectiveEpiFamilies where reflects {α _ B} X π h := by simp only [← effectiveEpi_desc_iff_effectiveEpiFamily] apply F.effectiveEpi_of_map - convert (inferInstance : - EffectiveEpi (inv (sigmaComparison F X) ≫ (Sigma.desc (fun a ↦ F.map (π a))))) + convert! + (inferInstance : + EffectiveEpi (inv (sigmaComparison F X) ≫ (Sigma.desc (fun a ↦ F.map (π a))))) simp instance [F.PreservesEffectiveEpis] : F.PreservesFiniteEffectiveEpiFamilies where preserves {α _ B} X π h := by simp only [← effectiveEpi_desc_iff_effectiveEpiFamily] - convert (inferInstance : - EffectiveEpi ((sigmaComparison F X) ≫ (F.map (Sigma.desc π)))) + convert! (inferInstance : EffectiveEpi ((sigmaComparison F X) ≫ (F.map (Sigma.desc π)))) simp end CategoryTheory diff --git a/Mathlib/CategoryTheory/Enriched/Basic.lean b/Mathlib/CategoryTheory/Enriched/Basic.lean index 5b1c62e13158cd..0431277a7f98a9 100644 --- a/Mathlib/CategoryTheory/Enriched/Basic.lean +++ b/Mathlib/CategoryTheory/Enriched/Basic.lean @@ -127,14 +127,14 @@ instance : EnrichedCategory W (TransportEnrichment F C) where simp only [comp_whiskerRight, Category.assoc, Functor.LaxMonoidal.μ_natural_left_assoc, Functor.LaxMonoidal.left_unitality_inv_assoc] simp_rw [← F.map_comp] - convert F.map_id _ + convert! F.map_id _ simp comp_id X Y := by simp only [MonoidalCategory.whiskerLeft_comp, Category.assoc, Functor.LaxMonoidal.μ_natural_right_assoc, Functor.LaxMonoidal.right_unitality_inv_assoc] simp_rw [← F.map_comp] - convert F.map_id _ + convert! F.map_id _ simp assoc P Q R S := by rw [comp_whiskerRight, Category.assoc, μ_natural_left_assoc, diff --git a/Mathlib/CategoryTheory/Extensive.lean b/Mathlib/CategoryTheory/Extensive.lean index e3c7e717c6f9cd..9a0743bcf54162 100644 --- a/Mathlib/CategoryTheory/Extensive.lean +++ b/Mathlib/CategoryTheory/Extensive.lean @@ -253,7 +253,7 @@ instance types.finitaryExtensive : FinitaryExtensive (Type u) := by rcases f x with (⟨⟨⟩⟩ | ⟨⟨⟩⟩) exacts [Or.inl rfl, Or.inr rfl] let eX : { p : Z × PUnit // f p.fst = Sum.inl p.snd } ≃ { x : Z // f x = Sum.inl PUnit.unit } := - ⟨fun p => ⟨p.1.1, by convert p.2⟩, fun x => ⟨⟨_, _⟩, x.2⟩, fun _ => by ext; rfl, + ⟨fun p => ⟨p.1.1, by convert! p.2⟩, fun x => ⟨⟨_, _⟩, x.2⟩, fun _ => by ext; rfl, fun _ => by ext; rfl⟩ let eY : { p : Z × PUnit // f p.fst = Sum.inr p.snd } ≃ { x : Z // f x = Sum.inr PUnit.unit } := ⟨fun p => ⟨p.1.1, p.2.trans (congr_arg Sum.inr <| Subsingleton.elim _ _)⟩, @@ -301,10 +301,10 @@ noncomputable def finitaryExtensiveTopCatAux (Z : TopCat.{u}) · rintro x ⟨⟨⟩, hx⟩; refine ⟨⟨⟨x, PUnit.unit⟩, hx.symm⟩, rfl⟩ refine ((TopCat.binaryCofan_isColimit_iff _).mpr ⟨?_, ?_, ?_⟩).some · refine ⟨(Homeomorph.prodPUnit Z).isEmbedding.comp .subtypeVal, ?_⟩ - convert f.hom.2.1 _ isOpen_range_inl + convert! f.hom.2.1 _ isOpen_range_inl · refine ⟨(Homeomorph.prodPUnit Z).isEmbedding.comp .subtypeVal, ?_⟩ - convert f.hom.2.1 _ isOpen_range_inr - · convert Set.isCompl_range_inl_range_inr.preimage f + convert! f.hom.2.1 _ isOpen_range_inr + · convert! Set.isCompl_range_inl_range_inr.preimage f instance finitaryExtensive_TopCat : FinitaryExtensive TopCat.{u} := by rw [finitaryExtensive_iff_of_isTerminal TopCat.{u} _ TopCat.isTerminalPUnit _ @@ -329,7 +329,7 @@ instance finitaryExtensive_TopCat : FinitaryExtensive TopCat.{u} := by fun {l'} h₁ _ => TopCat.ext fun x => hl' x (l' x) (ConcreteCategory.congr_hom h₁ x).symm⟩ apply (IsEmbedding.inl (X := X') (Y := Y')).isInducing.continuous_iff.mpr - convert s.fst.hom.2 using 1 + convert! s.fst.hom.2 using 1 exact (funext hl).symm · refine ⟨⟨hαY.symm⟩, ⟨PullbackCone.isLimitAux' _ ?_⟩⟩ intro s @@ -347,7 +347,7 @@ instance finitaryExtensive_TopCat : FinitaryExtensive TopCat.{u} := by fun {l'} h₁ _ => TopCat.ext fun x => hl' x (l' x) (ConcreteCategory.congr_hom h₁ x).symm⟩ apply (IsEmbedding.inr (X := X') (Y := Y')).isInducing.continuous_iff.mpr - convert s.fst.hom.2 using 1 + convert! s.fst.hom.2 using 1 exact (funext hl).symm · intro Z f exact finitaryExtensiveTopCatAux Z f @@ -591,11 +591,12 @@ lemma FinitaryPreExtensive.isPullback_sigmaDesc [HasPullbacks C] [FinitaryPreExt (Limits.Sigma.desc fun (p : ι × ι') ↦ pullback.fst (f p.1) (g p.2) ≫ Sigma.ι X p.1) (Limits.Sigma.desc fun (p : ι × ι') ↦ pullback.snd (f p.1) (g p.2) ≫ Sigma.ι Y p.2) (Limits.Sigma.desc f) (Limits.Sigma.desc g) := by - convert IsUniversalColimit.isPullback_prod_of_isColimit - (d := Cofan.mk _ (Sigma.ι fun (p : ι × ι') ↦ pullback (f p.1) (g p.2))) - (hd := coproductIsCoproduct (fun (p : ι × ι') ↦ pullback (f p.1) (g p.2))) - (a := Cofan.mk _ <| fun i ↦ Sigma.ι _ i) (b := Cofan.mk _ <| fun i ↦ Sigma.ι _ i) - ?_ ?_ f g (Sigma.desc f) (Sigma.desc g) (fun i j ↦ IsPullback.of_hasPullback (f i) (g j)) + convert! + IsUniversalColimit.isPullback_prod_of_isColimit (d := + Cofan.mk _ (Sigma.ι fun (p : ι × ι') ↦ pullback (f p.1) (g p.2))) (hd := + coproductIsCoproduct (fun (p : ι × ι') ↦ pullback (f p.1) (g p.2))) (a := + Cofan.mk _ <| fun i ↦ Sigma.ι _ i) (b := Cofan.mk _ <| fun i ↦ Sigma.ι _ i) ?_ ?_ f g + (Sigma.desc f) (Sigma.desc g) (fun i j ↦ IsPullback.of_hasPullback (f i) (g j)) · ext simp [Cofan.IsColimit.desc, Sigma.ι, coproductIsCoproduct] · ext diff --git a/Mathlib/CategoryTheory/Filtered/Basic.lean b/Mathlib/CategoryTheory/Filtered/Basic.lean index abc400bfb542aa..a4f192619b9061 100644 --- a/Mathlib/CategoryTheory/Filtered/Basic.lean +++ b/Mathlib/CategoryTheory/Filtered/Basic.lean @@ -685,7 +685,7 @@ theorem _root_.CategoryTheory.Functor.ranges_directed (F : C ⥤ Type*) (j : C) let ⟨l, li, lk, e⟩ := cospan ij kj refine ⟨⟨l, lk ≫ kj⟩, e ▸ ?_, ?_⟩ <;> simp_rw [F.map_comp] <;> - convert Set.range_comp_subset_range _ _ + convert! Set.range_comp_subset_range _ _ /-- Given a "bowtie" of morphisms ``` diff --git a/Mathlib/CategoryTheory/FintypeCat.lean b/Mathlib/CategoryTheory/FintypeCat.lean index 3d923a311c6891..5a91c38d3e71d0 100644 --- a/Mathlib/CategoryTheory/FintypeCat.lean +++ b/Mathlib/CategoryTheory/FintypeCat.lean @@ -234,9 +234,9 @@ attribute [local instance] FintypeCat.fintype in @[simp] theorem incl_mk_nat_card (n : ℕ) : Fintype.card (incl.obj (mk n)) = n := by - convert Finset.card_fin n + convert! Finset.card_fin n dsimp [incl, mk, len] - convert (Fintype.ofEquiv_card Equiv.ulift).symm + convert! (Fintype.ofEquiv_card Equiv.ulift).symm end Skeleton diff --git a/Mathlib/CategoryTheory/Functor/Flat.lean b/Mathlib/CategoryTheory/Functor/Flat.lean index c308abbe359157..2b41684d7e3f6b 100644 --- a/Mathlib/CategoryTheory/Functor/Flat.lean +++ b/Mathlib/CategoryTheory/Functor/Flat.lean @@ -222,7 +222,7 @@ theorem uniq {K : J ⥤ C} {c : Cone K} (hc : IsLimit c) (s : Cone (K ⋙ F)) intro j injection c₀.π.naturality (BiconeHom.left j) with _ e₁ injection c₀.π.naturality (BiconeHom.right j) with _ e₂ - convert e₁.symm.trans e₂ <;> simp [c₁, c₂] + convert! e₁.symm.trans e₂ <;> simp [c₁, c₂] have : c.extend g₁.right = c.extend g₂.right := by unfold Cone.extend congr 1 diff --git a/Mathlib/CategoryTheory/Functor/KanExtension/Dense.lean b/Mathlib/CategoryTheory/Functor/KanExtension/Dense.lean index caaaa537dcfffe..b2f46a4eb8abd7 100644 --- a/Mathlib/CategoryTheory/Functor/KanExtension/Dense.lean +++ b/Mathlib/CategoryTheory/Functor/KanExtension/Dense.lean @@ -58,6 +58,12 @@ lemma isDense_iff_nonempty_isPointwiseLeftKanExtension (F : C ⥤ D) : Nonempty ((LeftExtension.mk _ (rightUnitor F).inv).IsPointwiseLeftKanExtension) := ⟨fun _ ↦ ⟨fun _ ↦ F.denseAt _⟩, fun ⟨h⟩ ↦ ⟨fun _ ↦ ⟨h _⟩⟩⟩ +instance (F : C ⥤ D) [F.IsDense] : Functor.IsLeftKanExtension (𝟭 D) (Functor.rightUnitor F).inv := + ((Functor.isDense_iff_nonempty_isPointwiseLeftKanExtension F).mp ‹_›).some.isLeftKanExtension + +instance (F : C ⥤ D) [F.IsDense] : F.HasPointwiseLeftKanExtension F := + fun X ↦ (Functor.IsDense.isDenseAt F X).some.hasPointwiseLeftKanExtensionAt + lemma IsDense.of_iso {F G : C ⥤ D} (e : F ≅ G) [F.IsDense] : G.IsDense where isDenseAt Y := by @@ -163,6 +169,39 @@ lemma isStrongGenerator_of_isDense [F.IsDense] : ((ShrinkHoms.equivalence _).symm.trans ((Shrink.equivalence _)).symm)) prop_diag_obj := by simp }⟩⟩)) +/-- If `F` is dense, the left Kan extension of `F` along `F` is isomorphic to the identity. -/ +noncomputable def IsDense.leftKanExtensionIso (F : C ⥤ D) [F.IsDense] : + F.leftKanExtension F ≅ 𝟭 D := + Functor.leftKanExtensionUnique _ (F.leftKanExtensionUnit F) _ F.rightUnitor.inv + +@[reassoc (attr := simp)] +lemma IsDense.leftKanExtensionUnit_leftKanExtensionIso_hom (F : C ⥤ D) [F.IsDense] : + F.leftKanExtensionUnit F ≫ F.whiskerLeft (Functor.IsDense.leftKanExtensionIso F).hom = + F.rightUnitor.inv := by + simp [Functor.IsDense.leftKanExtensionIso] + +@[reassoc (attr := simp)] +lemma IsDense.leftKanExtensionUnit_leftKanExtensionIso_hom_app [F.IsDense] (X : C) : + (F.leftKanExtensionUnit F).app X ≫ (Functor.IsDense.leftKanExtensionIso F).hom.app (F.obj X) = + F.rightUnitor.inv.app _ := + congr($(Functor.IsDense.leftKanExtensionUnit_leftKanExtensionIso_hom _).app _) + end Functor +/-- `yoneda` is dense: Every `X : Cᵒᵖ ⥤ Type v₁` is the colimit over +`CostructuredArrow.proj yoneda X ⋙ yoneda`. -/ +def denseAtYoneda (X : Cᵒᵖ ⥤ Type v₁) : yoneda.DenseAt X := + Presheaf.isColimitTautologicalCocone X + +instance : (yoneda (C := C)).IsDense where + isDenseAt X := ⟨denseAtYoneda X⟩ + +/-- `uliftYoneda` is dense: Every `X : Cᵒᵖ ⥤ Type max w v₁` is the colimit over +`CostructuredArrow.proj uliftYoneda X ⋙ uliftYoneda`. -/ +def denseAtUliftYoneda (X : Cᵒᵖ ⥤ Type max w v₁) : uliftYoneda.DenseAt X := + Presheaf.isColimitTautologicalCocone' X + +instance : (uliftYoneda.{w} (C := C)).IsDense where + isDenseAt X := ⟨denseAtUliftYoneda X⟩ + end CategoryTheory diff --git a/Mathlib/CategoryTheory/Functor/KanExtension/DenseAt.lean b/Mathlib/CategoryTheory/Functor/KanExtension/DenseAt.lean index 4062be22fdf863..429c2591854376 100644 --- a/Mathlib/CategoryTheory/Functor/KanExtension/DenseAt.lean +++ b/Mathlib/CategoryTheory/Functor/KanExtension/DenseAt.lean @@ -97,6 +97,10 @@ noncomputable def DenseAt.postcompEquivalence IsColimit.ofWhiskerEquivalence (CostructuredArrow.post F G Y).asEquivalence (IsColimit.ofIsoColimit ((isColimitOfPreserves G hY)) (Cocone.ext (Iso.refl _))) +lemma DenseAt.hasPointwiseLeftKanExtensionAt (hf : F.DenseAt Y) : + F.HasPointwiseLeftKanExtensionAt F Y := + ⟨_, hf⟩ + variable (F) in /-- Given a functor `F : C ⥤ D`, this is the property of objects `Y : D` such that `F` is dense at `Y`. -/ diff --git a/Mathlib/CategoryTheory/Generator/Basic.lean b/Mathlib/CategoryTheory/Generator/Basic.lean index 87b4a82f2d1ebe..08357f85ffbd76 100644 --- a/Mathlib/CategoryTheory/Generator/Basic.lean +++ b/Mathlib/CategoryTheory/Generator/Basic.lean @@ -703,7 +703,7 @@ theorem isSeparator_sigma {β : Type w} (f : β → C) [HasCoproduct f] : theorem isSeparator_coprod (G H : C) [HasBinaryCoproduct G H] : IsSeparator (G ⨿ H) ↔ ObjectProperty.IsSeparating (.pair G H) := by refine (isSeparator_iff_of_isColimit_cofan (coprodIsCoprod G H)).trans ?_ - convert Iff.rfl + convert! Iff.rfl ext X simp only [ObjectProperty.pair_iff, ObjectProperty.ofObj_iff] constructor @@ -750,7 +750,7 @@ theorem isCoseparator_pi {β : Type w} (f : β → C) [HasProduct f] : theorem isCoseparator_prod (G H : C) [HasBinaryProduct G H] : IsCoseparator (G ⨯ H) ↔ ObjectProperty.IsCoseparating (.pair G H) := by refine (isCoseparator_iff_of_isLimit_fan (prodIsProd G H)).trans ?_ - convert Iff.rfl + convert! Iff.rfl ext X simp only [ObjectProperty.pair_iff, ObjectProperty.ofObj_iff] constructor diff --git a/Mathlib/CategoryTheory/GlueData.lean b/Mathlib/CategoryTheory/GlueData.lean index 36b36a3c217d35..1b82efaa98f426 100644 --- a/Mathlib/CategoryTheory/GlueData.lean +++ b/Mathlib/CategoryTheory/GlueData.lean @@ -398,7 +398,7 @@ instance (D : GlueData' C) (i j k : D.J) : infer_instance else have {X Y Z : C} (f : X ⟶ Y) (e : Z = X) : eqToHom e ≫ f ≍ f := by subst e; simp - convert D.f_hasPullback i j k hij hik <;> simp [GlueData'.f', hij, hik, this] + convert! D.f_hasPullback i j k hij hik <;> simp [GlueData'.f', hij, hik, this] open scoped Classical in /-- (Implementation detail) the constructed `GlueData.t'` from a `GlueData'`. -/ diff --git a/Mathlib/CategoryTheory/GradedObject/Monoidal.lean b/Mathlib/CategoryTheory/GradedObject/Monoidal.lean index 5fe1ad5ce46d3e..7021c3ee257170 100644 --- a/Mathlib/CategoryTheory/GradedObject/Monoidal.lean +++ b/Mathlib/CategoryTheory/GradedObject/Monoidal.lean @@ -558,8 +558,9 @@ variable [DecidableEq I] [HasInitial C] lemma triangle : (associator X₁ tensorUnit X₃).hom ≫ tensorHom (𝟙 X₁) (leftUnitor X₃).hom = tensorHom (rightUnitor X₁).hom (𝟙 X₃) := by - convert mapBifunctor_triangle (curriedAssociatorNatIso C) (𝟙_ C) - (rightUnitorNatIso C) (leftUnitorNatIso C) (triangleIndexData I) X₁ X₃ (by simp) + convert! + mapBifunctor_triangle (curriedAssociatorNatIso C) (𝟙_ C) (rightUnitorNatIso C) + (leftUnitorNatIso C) (triangleIndexData I) X₁ X₃ (by simp) all_goals assumption end Triangle diff --git a/Mathlib/CategoryTheory/Groupoid/FreeGroupoid.lean b/Mathlib/CategoryTheory/Groupoid/FreeGroupoid.lean index 2e08b0ab9c9dfc..4e1115b66d2287 100644 --- a/Mathlib/CategoryTheory/Groupoid/FreeGroupoid.lean +++ b/Mathlib/CategoryTheory/Groupoid/FreeGroupoid.lean @@ -170,7 +170,7 @@ theorem lift_unique (φ : V ⥤q V') (Φ : Quiver.FreeGroupoid V ⥤ V') change Φ.map (Groupoid.inv ((Quotient.functor redStep).toPrefunctor.map f.toPath)) = Groupoid.inv (Φ.map ((Quotient.functor redStep).toPrefunctor.map f.toPath)) have := Functor.map_inv Φ ((Quotient.functor redStep).toPrefunctor.map f.toPath) - convert this <;> simp only [Groupoid.inv_eq_inv] + convert! this <;> simp only [Groupoid.inv_eq_inv] end UniversalProperty diff --git a/Mathlib/CategoryTheory/Groupoid/Subgroupoid.lean b/Mathlib/CategoryTheory/Groupoid/Subgroupoid.lean index a50e4ef8887173..33fd840edbc5ca 100644 --- a/Mathlib/CategoryTheory/Groupoid/Subgroupoid.lean +++ b/Mathlib/CategoryTheory/Groupoid/Subgroupoid.lean @@ -117,7 +117,7 @@ theorem mem_objs_of_tgt {c d : C} {f : c ⟶ d} (h : f ∈ S.arrows c d) : d ∈ theorem id_mem_of_nonempty_isotropy (c : C) : c ∈ objs S → 𝟙 c ∈ S.arrows c c := by rintro ⟨γ, hγ⟩ - convert S.mul hγ (S.inv hγ) + convert! S.mul hγ (S.inv hγ) simp only [inv_eq_inv, IsIso.hom_inv_id] theorem id_mem_of_src {c d : C} {f : c ⟶ d} (h : f ∈ S.arrows c d) : 𝟙 c ∈ S.arrows c c := @@ -305,7 +305,7 @@ structure IsNormal : Prop extends IsWide S where theorem IsNormal.conj' {S : Subgroupoid C} (Sn : IsNormal S) : ∀ {c d} (p : d ⟶ c) {γ : c ⟶ c}, γ ∈ S.arrows c c → p ≫ γ ≫ Groupoid.inv p ∈ S.arrows d d := - fun p γ hs => by convert Sn.conj (Groupoid.inv p) hs; simp + fun p γ hs => by convert! Sn.conj (Groupoid.inv p) hs; simp theorem IsNormal.conjugation_bij (Sn : IsNormal S) {c d} (p : c ⟶ d) : Set.BijOn (fun γ : c ⟶ c => Groupoid.inv p ≫ γ ≫ p) (S.arrows c c) (S.arrows d d) := by @@ -481,7 +481,7 @@ theorem mem_map_objs_iff (hφ : Function.Injective φ.obj) (d : D) : @[simp] theorem map_objs_eq (hφ : Function.Injective φ.obj) : (map φ hφ S).objs = φ.obj '' S.objs := by - ext x; convert mem_map_objs_iff S φ hφ x + ext x; convert! mem_map_objs_iff S φ hφ x /-- The image of a functor injective on objects -/ def im (hφ : Function.Injective φ.obj) := @@ -491,7 +491,7 @@ theorem mem_im_iff (hφ : Function.Injective φ.obj) {c d : D} (f : c ⟶ d) : f ∈ (im φ hφ).arrows c d ↔ ∃ (a b : C) (g : a ⟶ b) (ha : φ.obj a = c) (hb : φ.obj b = d), f = eqToHom ha.symm ≫ φ.map g ≫ eqToHom hb := by - convert Map.arrows_iff φ hφ ⊤ f; simp only [Top.top, mem_univ, exists_true_left] + convert! Map.arrows_iff φ hφ ⊤ f; simp only [Top.top, mem_univ, exists_true_left] theorem mem_im_objs_iff (hφ : Function.Injective φ.obj) (d : D) : d ∈ (im φ hφ).objs ↔ ∃ c : C, φ.obj c = d := by diff --git a/Mathlib/CategoryTheory/Groupoid/VertexGroup.lean b/Mathlib/CategoryTheory/Groupoid/VertexGroup.lean index faa3f34b2a53ed..289facce1b9efe 100644 --- a/Mathlib/CategoryTheory/Groupoid/VertexGroup.lean +++ b/Mathlib/CategoryTheory/Groupoid/VertexGroup.lean @@ -77,12 +77,18 @@ def vertexGroupIsomOfPath {c d : C} (p : Quiver.Path c d) : (c ⟶ c) ≃* (d /-- A functor defines a morphism of vertex groups. -/ @[simps] -def CategoryTheory.Functor.mapVertexGroup {D : Type v} [Groupoid D] (φ : C ⥤ D) (c : C) : +def _root_.CategoryTheory.Functor.mapVertexGroup {D : Type v} [Groupoid D] (φ : C ⥤ D) (c : C) : (c ⟶ c) →* (φ.obj c ⟶ φ.obj c) where toFun := φ.map map_one' := φ.map_id c map_mul' := φ.map_comp +@[deprecated (since := "2026-05-24")] +alias CategoryTheory.Functor.mapVertexGroup := CategoryTheory.Functor.mapVertexGroup + +@[deprecated (since := "2026-05-24")] +alias CategoryTheory.Functor.mapVertexGroup_apply := CategoryTheory.Functor.mapVertexGroup_apply + end Groupoid end CategoryTheory diff --git a/Mathlib/CategoryTheory/Idempotents/Basic.lean b/Mathlib/CategoryTheory/Idempotents/Basic.lean index 406de0abd48412..2b9451e4caf30d 100644 --- a/Mathlib/CategoryTheory/Idempotents/Basic.lean +++ b/Mathlib/CategoryTheory/Idempotents/Basic.lean @@ -106,7 +106,7 @@ theorem isIdempotentComplete_iff_idempotents_have_kernels [Preadditive C] : constructor · intro h X p hp haveI : HasEqualizer (𝟙 X) (𝟙 X - p) := h X (𝟙 _ - p) (idem_of_id_sub_idem p hp) - convert hasKernel_of_hasEqualizer (𝟙 X) (𝟙 X - p) + convert! hasKernel_of_hasEqualizer (𝟙 X) (𝟙 X - p) rw [sub_sub_cancel] · intro h X p hp haveI : HasKernel (𝟙 _ - p) := h X (𝟙 _ - p) (idem_of_id_sub_idem p hp) diff --git a/Mathlib/CategoryTheory/Limits/ConeCategory.lean b/Mathlib/CategoryTheory/Limits/ConeCategory.lean index 4a9e2cb4b18545..bb46e976c3d0fa 100644 --- a/Mathlib/CategoryTheory/Limits/ConeCategory.lean +++ b/Mathlib/CategoryTheory/Limits/ConeCategory.lean @@ -139,7 +139,7 @@ def Cone.fromCostructuredArrow (F : J ⥤ C) : CostructuredArrow (const J) F ⥤ map f := { hom := f.left w := fun j => by - convert congr_fun (congr_arg NatTrans.app f.w) j + convert! congr_fun (congr_arg NatTrans.app f.w) j simp } /-- The category of cones on `F` is just the comma category `(Δ ↓ F)`, where `Δ` is the constant diff --git a/Mathlib/CategoryTheory/Limits/Constructions/BinaryProducts.lean b/Mathlib/CategoryTheory/Limits/Constructions/BinaryProducts.lean index a1289ba7fae7ec..5ce315db676969 100644 --- a/Mathlib/CategoryTheory/Limits/Constructions/BinaryProducts.lean +++ b/Mathlib/CategoryTheory/Limits/Constructions/BinaryProducts.lean @@ -64,9 +64,9 @@ def isPullbackOfIsTerminalIsProduct {W X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (h IsLimit (PullbackCone.mk _ _ (show h ≫ f = k ≫ g from H₁.hom_ext _ _)) := by apply PullbackCone.isLimitAux' intro s - use H₂.lift (BinaryFan.mk s.fst s.snd) - use H₂.fac (BinaryFan.mk s.fst s.snd) ⟨WalkingPair.left⟩ - use H₂.fac (BinaryFan.mk s.fst s.snd) ⟨WalkingPair.right⟩ + use BinaryFan.IsLimit.lift H₂ s.fst s.snd + use BinaryFan.IsLimit.lift_fst _ _ _ + use BinaryFan.IsLimit.lift_snd _ _ _ intro m h₁ h₂ apply H₂.hom_ext rintro ⟨⟨⟩⟩ @@ -171,9 +171,9 @@ def isPushoutOfIsInitialIsCoproduct {W X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (h IsColimit (PushoutCocone.mk _ _ (show h ≫ f = k ≫ g from H₁.hom_ext _ _)) := by apply PushoutCocone.isColimitAux' intro s - use H₂.desc (BinaryCofan.mk s.inl s.inr) - use H₂.fac (BinaryCofan.mk s.inl s.inr) ⟨WalkingPair.left⟩ - use H₂.fac (BinaryCofan.mk s.inl s.inr) ⟨WalkingPair.right⟩ + use BinaryCofan.IsColimit.desc H₂ s.inl s.inr + use BinaryCofan.IsColimit.inl_desc H₂ _ _ + use BinaryCofan.IsColimit.inr_desc H₂ _ _ intro m h₁ h₂ apply H₂.hom_ext rintro ⟨⟨⟩⟩ diff --git a/Mathlib/CategoryTheory/Limits/Constructions/Equalizers.lean b/Mathlib/CategoryTheory/Limits/Constructions/Equalizers.lean index 38c036ae6b4839..7cea64361478c4 100644 --- a/Mathlib/CategoryTheory/Limits/Constructions/Equalizers.lean +++ b/Mathlib/CategoryTheory/Limits/Constructions/Equalizers.lean @@ -50,7 +50,8 @@ abbrev pullbackFst (F : WalkingParallelPair ⥤ C) : set_option backward.isDefEq.respectTransparency false in theorem pullbackFst_eq_pullback_snd (F : WalkingParallelPair ⥤ C) : pullbackFst F = pullback.snd _ _ := by - convert (eq_whisker pullback.condition Limits.prod.fst : + convert! + (eq_whisker pullback.condition Limits.prod.fst : (_ : constructEqualizer F ⟶ F.obj WalkingParallelPair.zero) = _) <;> simp set_option backward.isDefEq.respectTransparency false in @@ -60,8 +61,10 @@ abbrev equalizerCone (F : WalkingParallelPair ⥤ C) : Cone F := (Fork.ofι (pullbackFst F) (by conv_rhs => rw [pullbackFst_eq_pullback_snd] - convert (eq_whisker pullback.condition Limits.prod.snd : - (_ : constructEqualizer F ⟶ F.obj WalkingParallelPair.one) = _) using 1 <;> simp)) + convert! + (eq_whisker pullback.condition Limits.prod.snd : + (_ : constructEqualizer F ⟶ F.obj WalkingParallelPair.one) = _) using + 1 <;> simp)) set_option backward.isDefEq.respectTransparency false in /-- Show the equalizing cone is a limit -/ @@ -144,8 +147,9 @@ abbrev pushoutInl (F : WalkingParallelPair ⥤ C) : set_option backward.isDefEq.respectTransparency false in theorem pushoutInl_eq_pushout_inr (F : WalkingParallelPair ⥤ C) : pushoutInl F = pushout.inr _ _ := by - convert (whisker_eq Limits.coprod.inl pushout.condition : - (_ : F.obj _ ⟶ constructCoequalizer _) = _) <;> simp + convert! + (whisker_eq Limits.coprod.inl pushout.condition : (_ : F.obj _ ⟶ constructCoequalizer _) = _) + <;> simp set_option backward.isDefEq.respectTransparency false in /-- Define the equalizing cocone -/ @@ -153,8 +157,10 @@ abbrev coequalizerCocone (F : WalkingParallelPair ⥤ C) : Cocone F := Cocone.ofCofork (Cofork.ofπ (pushoutInl F) (by conv_rhs => rw [pushoutInl_eq_pushout_inr] - convert (whisker_eq Limits.coprod.inr pushout.condition : - (_ : F.obj _ ⟶ constructCoequalizer _) = _) using 1 <;> simp)) + convert! + (whisker_eq Limits.coprod.inr pushout.condition : + (_ : F.obj _ ⟶ constructCoequalizer _) = _) using + 1 <;> simp)) set_option backward.isDefEq.respectTransparency false in /-- Show the equalizing cocone is a colimit -/ diff --git a/Mathlib/CategoryTheory/Limits/Constructions/Filtered.lean b/Mathlib/CategoryTheory/Limits/Constructions/Filtered.lean index b5c3cd57c5d2bd..41a5fd961958d7 100644 --- a/Mathlib/CategoryTheory/Limits/Constructions/Filtered.lean +++ b/Mathlib/CategoryTheory/Limits/Constructions/Filtered.lean @@ -71,7 +71,7 @@ def liftToFinsetColimitCocone [HasColimitsOfShape (Finset (Discrete α)) C] dsimp [liftToFinsetObj] apply colimit.hom_ext rintro ⟨⟨j, hj⟩⟩ - convert h j using 1 + convert! h j using 1 · simp [← colimit.w (liftToFinsetObj F) ⟨⟨Finset.singleton_subset_iff.2 hj⟩⟩] rfl · simp } @@ -106,8 +106,9 @@ def isColimitFiniteSubproductsCocone (f : α → C) [HasColimitsOfShape (Finset colimit.cocone_x, colimit.cocone_ι, finiteSubcoproductsCocone_ι_app] ext j rw [← Category.assoc] - convert IsColimit.comp_coconePointUniqueUpToIso_hom - (liftToFinsetColimitCocone (Discrete.functor f)).isColimit (colimit.isColimit _) j + convert! + IsColimit.comp_coconePointUniqueUpToIso_hom + (liftToFinsetColimitCocone (Discrete.functor f)).isColimit (colimit.isColimit _) j · simp [← colimit.w (liftToFinsetObj _) (homOfLE (x := {j.1}) (y := S) (by simp))] · simp)) @@ -211,7 +212,7 @@ def liftToFinsetLimitCone [HasLimitsOfShape (Finset (Discrete α))ᵒᵖ C] dsimp [liftToFinsetObj] apply limit.hom_ext rintro ⟨⟨j, hj⟩⟩ - convert h j using 1 + convert! h j using 1 · simp [← limit.w (liftToFinsetObj F) ⟨⟨⟨Finset.singleton_subset_iff.2 hj⟩⟩⟩] rfl · simp } diff --git a/Mathlib/CategoryTheory/Limits/Constructions/Over/Connected.lean b/Mathlib/CategoryTheory/Limits/Constructions/Over/Connected.lean index 36f438aa5207e2..582dd78de6d928 100644 --- a/Mathlib/CategoryTheory/Limits/Constructions/Over/Connected.lean +++ b/Mathlib/CategoryTheory/Limits/Constructions/Over/Connected.lean @@ -58,7 +58,7 @@ def raiseCone [IsConnected J] {B : D} {F : J ⥤ CostructuredArrow K B} let z : (Functor.const J).obj (K.obj c.pt) ⟶ _ := (CategoryTheory.Functor.constComp J c.pt K).inv ≫ Functor.whiskerRight c.π K ≫ natTransInCostructuredArrow F - convert (nat_trans_from_is_connected z j (Classical.arbitrary J)) <;> simp [z] + convert! (nat_trans_from_is_connected z j (Classical.arbitrary J)) <;> simp [z] π.naturality X Y f := by apply CommaMorphism.ext · simpa using (c.w f).symm diff --git a/Mathlib/CategoryTheory/Limits/FilteredColimitCommutesFiniteLimit.lean b/Mathlib/CategoryTheory/Limits/FilteredColimitCommutesFiniteLimit.lean index fe22d2d3cfa030..aabe63bf3de52c 100644 --- a/Mathlib/CategoryTheory/Limits/FilteredColimitCommutesFiniteLimit.lean +++ b/Mathlib/CategoryTheory/Limits/FilteredColimitCommutesFiniteLimit.lean @@ -217,7 +217,7 @@ theorem colimitLimitToLimitColimit_surjective : ((curry.obj F).obj j').map (gf f) (F.map (𝟙 j' ×ₘ g j') (y j')) = ((curry.obj F).obj j').map (hf f) (F.map (f ×ₘ g j) (y j)) := (w f).choose_spec.choose_spec.choose_spec - convert q using 1 + convert! q using 1 · simp [← comp_apply, -types_comp_apply] · simp [← comp_apply, -types_comp_apply, ← F.map_comp] clear_value kf gf hf diff --git a/Mathlib/CategoryTheory/Limits/Final.lean b/Mathlib/CategoryTheory/Limits/Final.lean index cf852bb62f3875..645d5405acbe7a 100644 --- a/Mathlib/CategoryTheory/Limits/Final.lean +++ b/Mathlib/CategoryTheory/Limits/Final.lean @@ -559,11 +559,11 @@ def induction {d : D} (Z : ∀ (X : C) (_ : F.obj X ⟶ d), Sort*) (CostructuredArrow.mk k₀) z · intro j₁ j₂ f a fapply h₁ _ _ _ _ f.left _ a - convert f.w + convert! f.w simp · intro j₁ j₂ f a fapply h₂ _ _ _ _ f.left _ a - convert f.w + convert! f.w simp variable {F G} @@ -1118,7 +1118,7 @@ private lemma Grothendieck.final_map_small {C : Type u₁} [SmallCategory C] {F intro H let i := (colimitFiberwiseColimitIso _).symm ≪≫ HasColimit.isoOfNatIso (fiberwiseColimitMapCompEquivalence α H) ≪≫ colimitFiberwiseColimitIso _ - convert Iso.isIso_hom i + convert! Iso.isIso_hom i apply colimit.hom_ext intro X simp [i, fiberwiseColimitMapCompEquivalence] diff --git a/Mathlib/CategoryTheory/Limits/FormalCoproducts/Basic.lean b/Mathlib/CategoryTheory/Limits/FormalCoproducts/Basic.lean index 848f13e9f727df..feb2b4622392d0 100644 --- a/Mathlib/CategoryTheory/Limits/FormalCoproducts/Basic.lean +++ b/Mathlib/CategoryTheory/Limits/FormalCoproducts/Basic.lean @@ -310,7 +310,7 @@ def isLimitPullbackCone : IsLimit (pullbackCone f g pb) := by (fun s ↦ congrArg (·.1.snd) ((homPullbackEquiv f g pb hpb s.pt).right_inv ⟨(s.fst, s.snd), s.condition⟩)) (fun s m h₁ h₂ ↦ ?_) - convert ((homPullbackEquiv f g pb hpb s.pt).left_inv m).symm using 3 + convert! ((homPullbackEquiv f g pb hpb s.pt).left_inv m).symm using 3 rw [← h₁, ← h₂]; rfl -- Arguments cannot be inferred. diff --git a/Mathlib/CategoryTheory/Limits/Fubini.lean b/Mathlib/CategoryTheory/Limits/Fubini.lean index 6ed237d8a0601b..803cdd2c16a2a1 100644 --- a/Mathlib/CategoryTheory/Limits/Fubini.lean +++ b/Mathlib/CategoryTheory/Limits/Fubini.lean @@ -725,7 +725,7 @@ theorem colimitCurrySwapCompColimIsoColimitCurryCompColim_ι_ι_inv {j} {k} : _ ⟶ colimit (curry.obj (Prod.swap K J ⋙ G) ⋙ colim)) := by dsimp [colimitCurrySwapCompColimIsoColimitCurryCompColim] slice_lhs 1 3 => simp only [] - rw [colimitIsoColimitCurryCompColim_ι_ι_inv, HasColimit.isoOfEquivalence_inv_π] + rw [colimitIsoColimitCurryCompColim_ι_ι_inv, HasColimit.ι_isoOfEquivalence_inv] dsimp [Equivalence.counitInv] rw [CategoryTheory.Bifunctor.map_id] simp diff --git a/Mathlib/CategoryTheory/Limits/HasLimits.lean b/Mathlib/CategoryTheory/Limits/HasLimits.lean index 6f68babdd27583..ab817fcd911dd2 100644 --- a/Mathlib/CategoryTheory/Limits/HasLimits.lean +++ b/Mathlib/CategoryTheory/Limits/HasLimits.lean @@ -342,7 +342,7 @@ def HasLimit.isoOfEquivalence {F : J ⥤ C} [HasLimit F] {G : K ⥤ C} [HasLimit IsLimit.conePointsIsoOfEquivalence (limit.isLimit F) (limit.isLimit G) e w set_option backward.isDefEq.respectTransparency false in -@[simp] +@[reassoc (attr := simp)] theorem HasLimit.isoOfEquivalence_hom_π {F : J ⥤ C} [HasLimit F] {G : K ⥤ C} [HasLimit G] (e : J ≌ K) (w : e.functor ⋙ G ≅ F) (k : K) : (HasLimit.isoOfEquivalence e w).hom ≫ limit.π G k = @@ -351,7 +351,7 @@ theorem HasLimit.isoOfEquivalence_hom_π {F : J ⥤ C} [HasLimit F] {G : K ⥤ C simp set_option backward.isDefEq.respectTransparency false in -@[simp] +@[reassoc (attr := simp)] theorem HasLimit.isoOfEquivalence_inv_π {F : J ⥤ C} [HasLimit F] {G : K ⥤ C} [HasLimit G] (e : J ≌ K) (w : e.functor ⋙ G ≅ F) (j : J) : (HasLimit.isoOfEquivalence e w).inv ≫ limit.π F j = @@ -909,21 +909,27 @@ def HasColimit.isoOfEquivalence {F : J ⥤ C} [HasColimit F] {G : K ⥤ C} [HasC IsColimit.coconePointsIsoOfEquivalence (colimit.isColimit F) (colimit.isColimit G) e w set_option backward.isDefEq.respectTransparency false in -@[simp] -theorem HasColimit.isoOfEquivalence_hom_π {F : J ⥤ C} [HasColimit F] {G : K ⥤ C} [HasColimit G] +@[reassoc (attr := simp)] +theorem HasColimit.ι_isoOfEquivalence_hom {F : J ⥤ C} [HasColimit F] {G : K ⥤ C} [HasColimit G] (e : J ≌ K) (w : e.functor ⋙ G ≅ F) (j : J) : colimit.ι F j ≫ (HasColimit.isoOfEquivalence e w).hom = F.map (e.unit.app j) ≫ w.inv.app _ ≫ colimit.ι G _ := by simp [HasColimit.isoOfEquivalence] set_option backward.isDefEq.respectTransparency false in -@[simp] -theorem HasColimit.isoOfEquivalence_inv_π {F : J ⥤ C} [HasColimit F] {G : K ⥤ C} [HasColimit G] +@[reassoc (attr := simp)] +theorem HasColimit.ι_isoOfEquivalence_inv {F : J ⥤ C} [HasColimit F] {G : K ⥤ C} [HasColimit G] (e : J ≌ K) (w : e.functor ⋙ G ≅ F) (k : K) : colimit.ι G k ≫ (HasColimit.isoOfEquivalence e w).inv = G.map (e.counitInv.app k) ≫ w.hom.app (e.inverse.obj k) ≫ colimit.ι F (e.inverse.obj k) := by simp [HasColimit.isoOfEquivalence, IsColimit.coconePointsIsoOfEquivalence_inv] +@[deprecated (since := "2026-05-25")] +alias HasColimit.isoOfEquivalence_hom_π := HasColimit.ι_isoOfEquivalence_hom + +@[deprecated (since := "2026-05-25")] +alias HasColimit.isoOfEquivalence_inv_π := HasColimit.ι_isoOfEquivalence_inv + section Pre variable (F) diff --git a/Mathlib/CategoryTheory/Limits/IsLimit.lean b/Mathlib/CategoryTheory/Limits/IsLimit.lean index adf3b35472cccf..cba5138452bf58 100644 --- a/Mathlib/CategoryTheory/Limits/IsLimit.lean +++ b/Mathlib/CategoryTheory/Limits/IsLimit.lean @@ -403,7 +403,7 @@ def homIso' (h : IsLimit t) (W : C) : { p : ∀ j, W ⟶ F.obj j // ∀ {j j'} (f : j ⟶ j'), p j ≫ F.map f = p j' } := h.homIso W ≪≫ { hom := ↾fun π => - ⟨fun j => π.app j, fun f => by convert ← (π.naturality f).symm; apply id_comp⟩ + ⟨fun j => π.app j, fun f => by convert! ← (π.naturality f).symm; apply id_comp⟩ inv := ↾fun p => { app := fun j => p.1 j naturality := fun j j' f => by dsimp; rw [id_comp]; exact (p.2 f).symm } } @@ -419,7 +419,7 @@ def ofFaithful {t : Cone F} {D : Type u₄} [Category.{v₄} D] (G : C ⥤ D) [G uniq := fun s m w => by apply G.map_injective; rw [h] refine ht.uniq (mapCone G s) _ fun j => ?_ - convert ← congrArg (fun f => G.map f) (w j) + convert! ← congrArg (fun f => G.map f) (w j) apply G.map_comp } /-- If `F` and `G` are naturally isomorphic, then `F.mapCone c` being a limit implies @@ -901,7 +901,7 @@ def homIso' (h : IsColimit t) (W : C) : { p : ∀ j, F.obj j ⟶ W // ∀ {j j' : J} (f : j ⟶ j'), F.map f ≫ p j' = p j } := h.homIso W ≪≫ { hom := ↾fun ι => - ⟨fun j => ι.app j, fun {j} {j'} f => by convert ← ι.naturality f; apply comp_id⟩ + ⟨fun j => ι.app j, fun {j} {j'} f => by convert! ← ι.naturality f; apply comp_id⟩ inv := ↾fun p => { app := fun j => p.1 j naturality := fun j j' f => by dsimp; rw [comp_id]; exact p.2 f } } @@ -918,7 +918,7 @@ def ofFaithful {t : Cocone F} {D : Type u₄} [Category.{v₄} D] (G : C ⥤ D) uniq := fun s m w => by apply G.map_injective; rw [h] refine ht.uniq (mapCocone G s) _ fun j => ?_ - convert ← congrArg (fun f => G.map f) (w j) + convert! ← congrArg (fun f => G.map f) (w j) apply G.map_comp } /-- If `F` and `G` are naturally isomorphic, then `F.mapCocone c` being a colimit implies diff --git a/Mathlib/CategoryTheory/Limits/Lattice.lean b/Mathlib/CategoryTheory/Limits/Lattice.lean index 3008f55307315a..324785f5ee4e52 100644 --- a/Mathlib/CategoryTheory/Limits/Lattice.lean +++ b/Mathlib/CategoryTheory/Limits/Lattice.lean @@ -74,7 +74,7 @@ theorem finite_colimit_eq_finset_univ_sup [SemilatticeSup α] [OrderBot α] (F : A finite product in the category of a `SemilatticeInf` with `OrderTop` is the same as the infimum. -/ theorem finite_product_eq_finset_inf [SemilatticeInf α] [OrderTop α] {ι : Type u} [Fintype ι] - (f : ι → α) : ∏ᶜ f = Fintype.elems.inf f := by + (f : ι → α) : ∏ᶜ f = Finset.univ.inf f := by trans · exact (IsLimit.conePointUniqueUpToIso (limit.isLimit _) @@ -87,7 +87,7 @@ theorem finite_product_eq_finset_inf [SemilatticeInf α] [OrderTop α] {ι : Typ supremum. -/ theorem finite_coproduct_eq_finset_sup [SemilatticeSup α] [OrderBot α] {ι : Type u} [Fintype ι] - (f : ι → α) : ∐ f = Fintype.elems.sup f := by + (f : ι → α) : ∐ f = Finset.univ.sup f := by trans · exact (IsColimit.coconePointUniqueUpToIso (colimit.isColimit _) diff --git a/Mathlib/CategoryTheory/Limits/MonoCoprod.lean b/Mathlib/CategoryTheory/Limits/MonoCoprod.lean index dd9a000ab27c10..3e4e935483680b 100644 --- a/Mathlib/CategoryTheory/Limits/MonoCoprod.lean +++ b/Mathlib/CategoryTheory/Limits/MonoCoprod.lean @@ -55,7 +55,7 @@ variable {C} instance (priority := 100) monoCoprodOfHasZeroMorphisms [HasZeroMorphisms C] : MonoCoprod C := ⟨fun A B c hc => by haveI : IsSplitMono c.inl := - IsSplitMono.mk' (SplitMono.mk (hc.desc (BinaryCofan.mk (𝟙 A) 0)) (IsColimit.fac _ _ _)) + IsSplitMono.mk' (SplitMono.mk (BinaryCofan.IsColimit.desc hc (𝟙 A) 0) (IsColimit.fac _ _ _)) infer_instance⟩ namespace MonoCoprod @@ -64,7 +64,8 @@ set_option backward.isDefEq.respectTransparency false in theorem binaryCofan_inr {A B : C} [MonoCoprod C] (c : BinaryCofan A B) (hc : IsColimit c) : Mono c.inr := by haveI hc' : IsColimit (BinaryCofan.mk c.inr c.inl) := - BinaryCofan.IsColimit.mk _ (fun f₁ f₂ => hc.desc (BinaryCofan.mk f₂ f₁)) + BinaryCofan.IsColimit.mk _ + (fun f₁ f₂ => BinaryCofan.IsColimit.desc (s := c) hc f₂ f₁) (by simp) (by simp) (fun f₁ f₂ m h₁ h₂ => BinaryCofan.IsColimit.hom_ext hc (by cat_disch) (by cat_disch)) exact binaryCofan_inl _ hc' @@ -199,7 +200,7 @@ set_option backward.isDefEq.respectTransparency false in lemma mono_map'_of_injective [HasCoproduct (X ∘ ι)] [HasCoproduct X] [HasCoproduct (fun (k : ((Set.range ι)ᶜ : Set I)) => X k.1)] : Mono (Sigma.map' ι (fun j => 𝟙 ((X ∘ ι) j))) := by - convert mono_of_injective' X ι hι + convert! mono_of_injective' X ι hι apply Sigma.hom_ext intro j rw [Sigma.ι_comp_map', id_comp, colimit.ι_desc] diff --git a/Mathlib/CategoryTheory/Limits/Preorder.lean b/Mathlib/CategoryTheory/Limits/Preorder.lean index d98872dc4a3f7f..2bbcb334ca57be 100644 --- a/Mathlib/CategoryTheory/Limits/Preorder.lean +++ b/Mathlib/CategoryTheory/Limits/Preorder.lean @@ -152,7 +152,7 @@ def semilatticeInfOfIsLimitBinaryFan inf X Y := (c X Y).pt inf_le_left X Y := leOfHom (c X Y).fst inf_le_right X Y := leOfHom (c X Y).snd - le_inf _ _ _ le_fst le_snd := leOfHom <| (h _ _).lift (BinaryFan.mk le_fst.hom le_snd.hom) + le_inf _ _ _ le_fst le_snd := leOfHom <| BinaryFan.IsLimit.lift (h _ _) le_fst.hom le_snd.hom variable (C) in /-- If a partial order has binary products, then it is an inf-semilattice -/ @@ -170,7 +170,7 @@ def semilatticeSupOfIsColimitBinaryCofan sup X Y := (c X Y).pt le_sup_left X Y := leOfHom (c X Y).inl le_sup_right X Y := leOfHom (c X Y).inr - sup_le _ _ _ le_inl le_inr := leOfHom <| (h _ _).desc (BinaryCofan.mk le_inl.hom le_inr.hom) + sup_le _ _ _ le_inl le_inr := leOfHom <| BinaryCofan.IsColimit.desc (h _ _) le_inl.hom le_inr.hom variable (C) in /-- If a partial order has binary coproducts, then it is a sup-semilattice -/ diff --git a/Mathlib/CategoryTheory/Limits/Preserves/Basic.lean b/Mathlib/CategoryTheory/Limits/Preserves/Basic.lean index 56a9626d38051d..9a502b8d9f82f7 100644 --- a/Mathlib/CategoryTheory/Limits/Preserves/Basic.lean +++ b/Mathlib/CategoryTheory/Limits/Preserves/Basic.lean @@ -231,6 +231,10 @@ lemma preservesLimit_of_iso_diagram {K₁ K₂ : J ⥤ C} (F : C ⥤ D) (h : K apply IsLimit.ofIsoLimit (isLimitOfPreserves F this) exact Cone.ext (Iso.refl _)⟩ +lemma preservesLimit_iff_of_iso_diagram {K₁ K₂ : J ⥤ C} (F : C ⥤ D) (h : K₁ ≅ K₂) : + PreservesLimit K₁ F ↔ PreservesLimit K₂ F := + ⟨fun _ ↦ preservesLimit_of_iso_diagram _ h, fun _ ↦ preservesLimit_of_iso_diagram _ h.symm⟩ + /-- Transfer preservation of a limit along a natural isomorphism in the functor. -/ lemma preservesLimit_of_natIso (K : J ⥤ C) {F G : C ⥤ D} (h : F ≅ G) [PreservesLimit K F] : PreservesLimit K G where @@ -307,6 +311,10 @@ lemma preservesColimit_of_iso_diagram {K₁ K₂ : J ⥤ C} (F : C ⥤ D) (h : K apply IsColimit.ofIsoColimit (isColimitOfPreserves F this) exact Cocone.ext (Iso.refl _)⟩ +lemma preservesColimit_iff_of_iso_diagram {K₁ K₂ : J ⥤ C} (F : C ⥤ D) (h : K₁ ≅ K₂) : + PreservesColimit K₁ F ↔ PreservesColimit K₂ F := + ⟨fun _ ↦ preservesColimit_of_iso_diagram _ h, fun _ ↦ preservesColimit_of_iso_diagram _ h.symm⟩ + /-- Transfer preservation of a colimit along a natural isomorphism in the functor. -/ lemma preservesColimit_of_natIso (K : J ⥤ C) {F G : C ⥤ D} (h : F ≅ G) [PreservesColimit K F] : PreservesColimit K G where @@ -761,7 +769,7 @@ lemma isIso_app_coconePt_of_preservesColimit IsIso (α.app c.pt) := by let e := IsColimit.coconePointsIsoOfNatIso (isColimitOfPreserves L hc) (isColimitOfPreserves L' hc) (asIso (whiskerLeft K α)) - convert (inferInstance : IsIso e.hom) + convert! (inferInstance : IsIso e.hom) apply (isColimitOfPreserves L hc).hom_ext fun j ↦ ?_ simp only [Functor.comp_obj, Functor.mapCocone_pt, Functor.const_obj_obj, Functor.mapCocone_ι_app, NatTrans.naturality, IsColimit.coconePointsIsoOfNatIso_hom, asIso_hom, e] diff --git a/Mathlib/CategoryTheory/Limits/Preserves/Grothendieck.lean b/Mathlib/CategoryTheory/Limits/Preserves/Grothendieck.lean index 8431c9a21037e6..51ee1f9e2c9de1 100644 --- a/Mathlib/CategoryTheory/Limits/Preserves/Grothendieck.lean +++ b/Mathlib/CategoryTheory/Limits/Preserves/Grothendieck.lean @@ -83,7 +83,7 @@ instance preservesLimitsOfShape_colim_grothendieck [HasColimitsOfShape C H] [Has HasLimit.isoOfNatIso (associator _ _ _ ≪≫ isoWhiskerLeft _ fiberwiseColimCompColimIso) haveI : IsIso (limit.post K colim) := by - convert Iso.isIso_hom i₂ + convert! Iso.isIso_hom i₂ ext simp only [colim_obj, Functor.comp_obj, limit.post_π, colim_map, Iso.trans_def, Iso.trans_assoc, Iso.trans_hom, Category.assoc, HasLimit.isoOfNatIso_hom_π, diff --git a/Mathlib/CategoryTheory/Limits/Preserves/Limits.lean b/Mathlib/CategoryTheory/Limits/Preserves/Limits.lean index fd9a21ee408df2..ee81f17d04b6e6 100644 --- a/Mathlib/CategoryTheory/Limits/Preserves/Limits.lean +++ b/Mathlib/CategoryTheory/Limits/Preserves/Limits.lean @@ -99,7 +99,7 @@ variable [HasLimit F] [HasLimit (F ⋙ G)] preserves limits of `F`. -/ lemma preservesLimit_of_isIso_post [IsIso (limit.post F G)] : PreservesLimit F G := preservesLimit_of_preserves_limit_cone (limit.isLimit F) (by - convert IsLimit.ofPointIso (limit.isLimit (F ⋙ G)) + convert! IsLimit.ofPointIso (limit.isLimit (F ⋙ G)) assumption) end @@ -172,7 +172,7 @@ variable [HasColimit F] [HasColimit (F ⋙ G)] preserves colimits of `F`. -/ lemma preservesColimit_of_isIso_post [IsIso (colimit.post F G)] : PreservesColimit F G := preservesColimit_of_preserves_colimit_cocone (colimit.isColimit F) (by - convert IsColimit.ofPointIso (colimit.isColimit (F ⋙ G)) + convert! IsColimit.ofPointIso (colimit.isColimit (F ⋙ G)) assumption) end diff --git a/Mathlib/CategoryTheory/Limits/Presheaf.lean b/Mathlib/CategoryTheory/Limits/Presheaf.lean index 8d8e7963efeeb0..2ff41881fb117c 100644 --- a/Mathlib/CategoryTheory/Limits/Presheaf.lean +++ b/Mathlib/CategoryTheory/Limits/Presheaf.lean @@ -396,7 +396,7 @@ instance (X : C) (Y : F.op.LeftExtension (yoneda.obj X)) : default := StructuredArrow.homMk (yonedaEquiv.symm (yonedaEquiv (F := F.op.comp Y.right) Y.hom)) (by ext Z f - convert (Y.hom.naturality_apply f.op _).symm + convert! (Y.hom.naturality_apply f.op _).symm simp) uniq φ := by ext1 diff --git a/Mathlib/CategoryTheory/Limits/Shapes/BinaryBiproducts.lean b/Mathlib/CategoryTheory/Limits/Shapes/BinaryBiproducts.lean index 32d422818dc4c5..bf12f48fd18bdb 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/BinaryBiproducts.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/BinaryBiproducts.lean @@ -533,12 +533,12 @@ theorem biprod.inr_snd {X Y : C} [HasBinaryBiproduct X Y] : /-- Given a pair of maps into the summands of a binary biproduct, we obtain a map into the binary biproduct. -/ abbrev biprod.lift {W X Y : C} [HasBinaryBiproduct X Y] (f : W ⟶ X) (g : W ⟶ Y) : W ⟶ X ⊞ Y := - (BinaryBiproduct.isLimit X Y).lift (BinaryFan.mk f g) + BinaryFan.IsLimit.lift (BinaryBiproduct.isLimit X Y) f g /-- Given a pair of maps out of the summands of a binary biproduct, we obtain a map out of the binary biproduct. -/ abbrev biprod.desc {W X Y : C} [HasBinaryBiproduct X Y] (f : X ⟶ W) (g : Y ⟶ W) : X ⊞ Y ⟶ W := - (BinaryBiproduct.isColimit X Y).desc (BinaryCofan.mk f g) + BinaryCofan.IsColimit.desc (BinaryBiproduct.isColimit X Y) f g @[reassoc (attr := simp)] theorem biprod.lift_fst {W X Y : C} [HasBinaryBiproduct X Y] (f : W ⟶ X) (g : W ⟶ Y) : diff --git a/Mathlib/CategoryTheory/Limits/Shapes/BinaryProducts.lean b/Mathlib/CategoryTheory/Limits/Shapes/BinaryProducts.lean index 935ed900005dd6..579a1f67e7e0ce 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/BinaryProducts.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/BinaryProducts.lean @@ -358,6 +358,25 @@ def BinaryCofan.isColimitMk {W : C} {inl : X ⟶ W} {inr : Y ⟶ W} exacts [fac_left s, fac_right s] uniq := fun s m w => uniq s m (w ⟨WalkingPair.left⟩) (w ⟨WalkingPair.right⟩) } +/-- If `s` is a limit binary fan over `X` and `Y`, then every pair of morphisms `f : W ⟶ X` and +`g : W ⟶ Y` induces a morphism `l : W ⟶ s.pt` satisfying `l ≫ s.fst = f` and `l ≫ s.snd = g`. +-/ +def BinaryFan.IsLimit.lift {W : C} {s : BinaryFan X Y} (h : IsLimit s) (f : W ⟶ X) (g : W ⟶ Y) : + W ⟶ s.pt := + h.lift (BinaryFan.mk f g) + +@[reassoc (attr := simp)] +lemma BinaryFan.IsLimit.lift_fst {W : C} {s : BinaryFan X Y} (h : IsLimit s) + (f : W ⟶ X) (g : W ⟶ Y) : + lift h f g ≫ s.fst = f := + h.fac (BinaryFan.mk f g) _ + +@[reassoc (attr := simp)] +lemma BinaryFan.IsLimit.lift_snd {W : C} {s : BinaryFan X Y} (h : IsLimit s) + (f : W ⟶ X) (g : W ⟶ Y) : + lift h f g ≫ s.snd = g := + h.fac (BinaryFan.mk f g) _ + /-- If `s` is a limit binary fan over `X` and `Y`, then every pair of morphisms `f : W ⟶ X` and `g : W ⟶ Y` induces a morphism `l : W ⟶ s.pt` satisfying `l ≫ s.fst = f` and `l ≫ s.snd = g`. -/ @@ -366,7 +385,27 @@ def BinaryFan.IsLimit.lift' {W X Y : C} {s : BinaryFan X Y} (h : IsLimit s) (f : (g : W ⟶ Y) : { l : W ⟶ s.pt // l ≫ s.fst = f ∧ l ≫ s.snd = g } := ⟨h.lift <| BinaryFan.mk f g, h.fac _ _, h.fac _ _⟩ -/-- If `s` is a colimit binary cofan over `X` and `Y`,, then every pair of morphisms `f : X ⟶ W` and +/-- If `s` is a colimit binary cofan over `X` and `Y`, then every pair of morphisms `f : X ⟶ W` and +`g : Y ⟶ W` induces a morphism `l : s.pt ⟶ W` satisfying `s.inl ≫ l = f` and `s.inr ≫ l = g`. +-/ +def BinaryCofan.IsColimit.desc {W : C} {s : BinaryCofan X Y} (h : IsColimit s) + (f : X ⟶ W) (g : Y ⟶ W) : + s.pt ⟶ W := + h.desc (BinaryCofan.mk f g) + +@[reassoc (attr := simp)] +lemma BinaryCofan.IsColimit.inl_desc {W : C} {s : BinaryCofan X Y} (h : IsColimit s) + (f : X ⟶ W) (g : Y ⟶ W) : + s.inl ≫ desc h f g = f := + h.fac (BinaryCofan.mk f g) _ + +@[reassoc (attr := simp)] +lemma BinaryCofan.IsColimit.inr_desc {W : C} {s : BinaryCofan X Y} (h : IsColimit s) + (f : X ⟶ W) (g : Y ⟶ W) : + s.inr ≫ desc h f g = g := + h.fac (BinaryCofan.mk f g) _ + +/-- If `s` is a colimit binary cofan over `X` and `Y`, then every pair of morphisms `f : X ⟶ W` and `g : Y ⟶ W` induces a morphism `l : s.pt ⟶ W` satisfying `s.inl ≫ l = f` and `s.inr ≫ l = g`. -/ @[simps] @@ -377,7 +416,7 @@ def BinaryCofan.IsColimit.desc' {W X Y : C} {s : BinaryCofan X Y} (h : IsColimit /-- Binary products are symmetric. -/ def BinaryFan.isLimitFlip {X Y : C} {c : BinaryFan X Y} (hc : IsLimit c) : IsLimit (BinaryFan.mk c.snd c.fst) := - BinaryFan.isLimitMk (fun s => hc.lift (BinaryFan.mk s.snd s.fst)) (fun _ => hc.fac _ _) + BinaryFan.isLimitMk (fun s => IsLimit.lift hc s.snd s.fst) (fun _ => hc.fac _ _) (fun _ => hc.fac _ _) fun s _ e₁ e₂ => BinaryFan.IsLimit.hom_ext hc (e₂.trans (hc.fac (BinaryFan.mk s.snd s.fst) ⟨WalkingPair.left⟩).symm) @@ -411,7 +450,7 @@ set_option backward.isDefEq.respectTransparency false in noncomputable def BinaryFan.isLimitCompLeftIso {X Y X' : C} (c : BinaryFan X Y) (f : X ⟶ X') [IsIso f] (h : IsLimit c) : IsLimit (BinaryFan.mk (c.fst ≫ f) c.snd) := by fapply BinaryFan.isLimitMk - · exact fun s => h.lift (BinaryFan.mk (s.fst ≫ inv f) s.snd) + · exact fun s => IsLimit.lift h (s.fst ≫ inv f) s.snd · simp · simp · intro s m e₁ e₂ @@ -427,7 +466,7 @@ noncomputable def BinaryFan.isLimitCompRightIso {X Y Y' : C} (c : BinaryFan X Y) /-- Binary coproducts are symmetric. -/ def BinaryCofan.isColimitFlip {X Y : C} {c : BinaryCofan X Y} (hc : IsColimit c) : IsColimit (BinaryCofan.mk c.inr c.inl) := - BinaryCofan.isColimitMk (fun s => hc.desc (BinaryCofan.mk s.inr s.inl)) (fun _ => hc.fac _ _) + BinaryCofan.isColimitMk (fun s => IsColimit.desc hc s.inr s.inl) (fun _ => hc.fac _ _) (fun _ => hc.fac _ _) fun s _ e₁ e₂ => BinaryCofan.IsColimit.hom_ext hc (e₂.trans (hc.fac (BinaryCofan.mk s.inr s.inl) ⟨WalkingPair.left⟩).symm) @@ -461,7 +500,7 @@ set_option backward.isDefEq.respectTransparency false in noncomputable def BinaryCofan.isColimitCompLeftIso {X Y X' : C} (c : BinaryCofan X Y) (f : X' ⟶ X) [IsIso f] (h : IsColimit c) : IsColimit (BinaryCofan.mk (f ≫ c.inl) c.inr) := by fapply BinaryCofan.isColimitMk - · exact fun s => h.desc (BinaryCofan.mk (inv f ≫ s.inl) s.inr) + · exact fun s => BinaryCofan.IsColimit.desc h (inv f ≫ s.inl) s.inr · simp · simp · intro s m e₁ e₂ @@ -1071,6 +1110,46 @@ def coprod.functorLeftComp (X Y : C) : end CoprodFunctor +section + +variable {C} {D : Type*} [Category* D] {F : C ⥤ D} + +variable (F) in +/-- The image of a binary fan by a functor. -/ +abbrev BinaryFan.map {X Y : C} (s : BinaryFan X Y) : BinaryFan (F.obj X) (F.obj Y) := + mk (F.map s.fst) (F.map s.snd) + +@[simp] +lemma BinaryFan.map_fst {X Y : C} (s : BinaryFan X Y) : (s.map F).fst = F.map s.fst := rfl + +@[simp] +lemma BinaryFan.map_snd {X Y : C} (s : BinaryFan X Y) : (s.map F).snd = F.map s.snd := rfl + +variable (F) in +/-- The image of a binary cofan by a functor. -/ +abbrev BinaryCofan.map {X Y : C} (s : BinaryCofan X Y) : BinaryCofan (F.obj X) (F.obj Y) := + mk (F.map s.inl) (F.map s.inr) + +@[simp] +lemma BinaryCofan.map_inl {X Y : C} (s : BinaryCofan X Y) : (s.map F).inl = F.map s.inl := rfl + +@[simp] +lemma BinaryCofan.map_inr {X Y : C} (s : BinaryCofan X Y) : (s.map F).inr = F.map s.inr := rfl + +/-- `F.mapCone s` being limiting is the same as the induced binary fan being limiting. -/ +def BinaryFan.isLimitMapConeEquiv {X Y : C} {s : BinaryFan X Y} : + IsLimit (F.mapCone s) ≃ IsLimit (s.map F) := + IsLimit.equivOfNatIsoOfIso (diagramIsoPair _) _ _ <| ext (Iso.refl _) + (by simp [fst]) (by simp [snd]) + +/-- `F.mapCocone s` being colimiting is the same as the induced binary cofan being colimiting. -/ +def BinaryCofan.isColimitMapConeEquiv {X Y : C} {s : BinaryCofan X Y} : + IsColimit (F.mapCocone s) ≃ IsColimit (s.map F) := + IsColimit.equivOfNatIsoOfIso (diagramIsoPair _) _ _ <| ext (Iso.refl _) + (by simp [inl]) (by simp [inr]) + +end + noncomputable section ProdComparison universe w w' u₃ @@ -1424,11 +1503,11 @@ if `sYZ` is a limit cone we can construct a binary fan over `sXY.X Z`. This is an ingredient of building the associator for a Cartesian category. -/ def BinaryFan.assocInv (P : IsLimit sXY) (s : BinaryFan X sYZ.pt) : BinaryFan sXY.pt Z := - BinaryFan.mk (P.lift (BinaryFan.mk s.fst (s.snd ≫ sYZ.fst))) (s.snd ≫ sYZ.snd) + BinaryFan.mk (IsLimit.lift P s.fst (s.snd ≫ sYZ.fst)) (s.snd ≫ sYZ.snd) @[simp] lemma BinaryFan.assocInv_fst (P : IsLimit sXY) (s : BinaryFan X sYZ.pt) : - (assocInv P s).fst = P.lift (mk s.fst (s.snd ≫ sYZ.fst)) := rfl + (assocInv P s).fst = IsLimit.lift P s.fst (s.snd ≫ sYZ.fst) := rfl @[simp] lemma BinaryFan.assocInv_snd (P : IsLimit sXY) (s : BinaryFan X sYZ.pt) : @@ -1452,10 +1531,10 @@ protected def IsLimit.assoc (P : IsLimit sXY) (Q : IsLimit sYZ) {s : BinaryFan s · apply P.hom_ext rintro ⟨⟨⟩⟩ · simpa using w ⟨.left⟩ - · replace w : m ≫ Q.lift (BinaryFan.mk (s.fst ≫ sXY.snd) s.snd) = t.π.app ⟨.right⟩ := by + · replace w : m ≫ BinaryFan.IsLimit.lift Q (s.fst ≫ sXY.snd) s.snd = t.π.app ⟨.right⟩ := by simpa using w ⟨.right⟩ simp [← w] - · replace w : m ≫ Q.lift (BinaryFan.mk (s.fst ≫ sXY.snd) s.snd) = t.π.app ⟨.right⟩ := by + · replace w : m ≫ BinaryFan.IsLimit.lift Q (s.fst ≫ sXY.snd) s.snd = t.π.app ⟨.right⟩ := by simpa using w ⟨.right⟩ simp [← w] diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Biproducts.lean b/Mathlib/CategoryTheory/Limits/Shapes/Biproducts.lean index b102163ffef8e9..acaad2c2669391 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Biproducts.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Biproducts.lean @@ -447,7 +447,7 @@ This means you may not be able to `simp` using this lemma unless you `open scope @[reassoc] theorem biproduct.ι_π [DecidableEq J] (f : J → C) [HasBiproduct f] (j j' : J) : biproduct.ι f j ≫ biproduct.π f j' = if h : j = j' then eqToHom (congr_arg f h) else 0 := by - convert (biproduct.bicone f).ι_π j j' + convert! (biproduct.bicone f).ι_π j j' @[reassoc] -- Not `simp` because `simp` can prove this theorem biproduct.ι_π_self (f : J → C) [HasBiproduct f] (j : J) : diff --git a/Mathlib/CategoryTheory/Limits/Shapes/DisjointCoproduct.lean b/Mathlib/CategoryTheory/Limits/Shapes/DisjointCoproduct.lean index b43755fdc4f0d6..806a00383a5065 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/DisjointCoproduct.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/DisjointCoproduct.lean @@ -240,7 +240,7 @@ attribute [instance 999] CoproductsOfShapeDisjoint.coproductDisjoint lemma BinaryCoproductsDisjoint.mk (H : ∀ (X Y : C), BinaryCoproductDisjoint X Y) : BinaryCoproductsDisjoint C where coproductDisjoint X := by - convert H (X .left) (X .right) using 2 + convert! H (X .left) (X .right) using 2 casesm WalkingPair <;> simp /-- If `C` has disjoint coproducts, any morphism out of initial is mono. Note it isn't true in diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean b/Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean index 1cdad676898b3c..216b2aed5ce5b9 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Equalizers.lean @@ -896,7 +896,7 @@ def idFork (h : f = g) : Fork f g := /-- The identity on `X` is an equalizer of `(f, g)`, if `f = g`. -/ def isLimitIdFork (h : f = g) : IsLimit (idFork h) := Fork.IsLimit.mk _ (fun s => Fork.ι s) (fun _ => Category.comp_id _) fun s m h => by - convert h + convert! h exact (Category.comp_id _).symm /-- Every equalizer of `(f, g)`, where `f = g`, is an isomorphism. -/ @@ -1114,7 +1114,7 @@ def idCofork (h : f = g) : Cofork f g := /-- The identity on `Y` is a coequalizer of `(f, g)`, where `f = g`. -/ def isColimitIdCofork (h : f = g) : IsColimit (idCofork h) := Cofork.IsColimit.mk _ (fun s => Cofork.π s) (fun _ => Category.id_comp _) fun s m h => by - convert h + convert! h exact (Category.id_comp _).symm /-- Every coequalizer of `(f, g)`, where `f = g`, is an isomorphism. -/ diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Images.lean b/Mathlib/CategoryTheory/Limits/Shapes/Images.lean index 3e2eeaa88d8103..eb8f75af4fa6c2 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Images.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Images.lean @@ -488,7 +488,7 @@ theorem image.ext [HasImage f] {W : C} {g h : image f ⟶ W} [HasLimit (parallel have t : v ≫ q = 𝟙 (image f) := (cancel_mono_id (image.ι f)).1 (by - convert t₀ using 1 + convert! t₀ using 1 rw [Category.assoc]) -- The proof from wikipedia next proves `q ≫ v = 𝟙 _`, -- and concludes that `equalizer g h ≅ image f`, diff --git a/Mathlib/CategoryTheory/Limits/Shapes/KernelPair.lean b/Mathlib/CategoryTheory/Limits/Shapes/KernelPair.lean index fc321c42ad0b46..ce65d956ac1222 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/KernelPair.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/KernelPair.lean @@ -219,7 +219,7 @@ theorem isIso_of_mono (h : IsKernelPair f a b) [Mono f] : IsIso a := by theorem of_isIso_of_mono [IsIso a] [Mono f] : IsKernelPair f a a := by change IsPullback _ _ _ _ - convert (IsPullback.of_horiz_isIso ⟨(rfl : a ≫ 𝟙 X = _ )⟩).paste_vert (IsKernelPair.id_of_mono f) + convert! (IsPullback.of_horiz_isIso ⟨(rfl : a ≫ 𝟙 X = _)⟩).paste_vert (IsKernelPair.id_of_mono f) all_goals { simp } /-- The kernel pair provided by `HasPullback f f` fits into an `IsKernelPair`. -/ diff --git a/Mathlib/CategoryTheory/Limits/Shapes/NormalMono/Basic.lean b/Mathlib/CategoryTheory/Limits/Shapes/NormalMono/Basic.lean index 92330068bb78c9..2c3305e06a5607 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/NormalMono/Basic.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/NormalMono/Basic.lean @@ -105,7 +105,7 @@ def normalOfIsPullbackSndOfNormal {P Q R S : C} {f : P ⟶ Q} {g : P ⟶ R} {h : isLimit := by letI gr := regularOfIsPullbackSndOfRegular hn.regularMono comm t have q := (HasZeroMorphisms.comp_zero k hn.Z).symm - convert gr.isLimit + convert! gr.isLimit /-- The first leg of a pullback cone is a normal monomorphism if the left component is too. @@ -224,7 +224,7 @@ def normalOfIsPushoutSndOfNormal {P Q R S : C} {f : P ⟶ Q} {g : P ⟶ R} {h : isColimit := by letI hn := regularOfIsPushoutSndOfRegular gn.regularEpi comm t have q := (@zero_comp _ _ _ gn.W _ _ f).symm - convert hn.isColimit + convert! hn.isColimit /-- The first leg of a pushout cocone is a normal epimorphism if the left component is too. diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Opposites/Products.lean b/Mathlib/CategoryTheory/Limits/Shapes/Opposites/Products.lean index 7de93693742bf8..c65f8d1d7ca20e 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Opposites/Products.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Opposites/Products.lean @@ -183,8 +183,9 @@ theorem desc_op_comp_opCoproductIsoProduct'_hom {c : Cofan Z} {f : Fan (op <| Z theorem desc_op_comp_opCoproductIsoProduct_hom [HasCoproduct Z] {X : C} (π : (a : α) → Z a ⟶ X) : (Sigma.desc π).op ≫ (opCoproductIsoProduct Z).hom = Pi.lift (fun a ↦ (π a).op) := by - convert desc_op_comp_opCoproductIsoProduct'_hom (coproductIsCoproduct Z) - (productIsProduct (op <| Z ·)) (Cofan.mk _ π) + convert! + desc_op_comp_opCoproductIsoProduct'_hom (coproductIsCoproduct Z) (productIsProduct (op <| Z ·)) + (Cofan.mk _ π) · simp [Sigma.desc, coproductIsCoproduct] · simp [Pi.lift, productIsProduct] @@ -279,8 +280,9 @@ theorem opProductIsoCoproduct'_inv_comp_lift {f : Fan Z} {c : Cofan (op <| Z ·) theorem opProductIsoCoproduct_inv_comp_lift [HasProduct Z] {X : C} (π : (a : α) → X ⟶ Z a) : (opProductIsoCoproduct Z).inv ≫ (Pi.lift π).op = Sigma.desc (fun a ↦ (π a).op) := by - convert opProductIsoCoproduct'_inv_comp_lift (productIsProduct Z) - (coproductIsCoproduct (op <| Z ·)) (Fan.mk _ π) + convert! + opProductIsoCoproduct'_inv_comp_lift (productIsProduct Z) (coproductIsCoproduct (op <| Z ·)) + (Fan.mk _ π) · simp [Pi.lift, productIsProduct] · simp [Sigma.desc, coproductIsCoproduct] @@ -293,7 +295,7 @@ variable {A B : C} [HasBinaryProduct A B] instance : HasBinaryCoproduct (op A) (op B) := by have : HasProduct fun x ↦ (WalkingPair.casesOn x A B : C) := ‹_› change HasCoproduct _ - convert (inferInstance : HasCoproduct fun x ↦ op (WalkingPair.casesOn x A B : C)) with x + convert! (inferInstance : HasCoproduct fun x ↦ op (WalkingPair.casesOn x A B : C)) with x cases x <;> rfl set_option backward.isDefEq.respectTransparency false in diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Products.lean b/Mathlib/CategoryTheory/Limits/Shapes/Products.lean index 2b72d3178df98d..0113e48d6b56e2 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Products.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Products.lean @@ -287,7 +287,7 @@ theorem Sigma.ι_desc {β : Type w} {f : β → C} [HasCoproduct f] {P : C} (p : set_option backward.isDefEq.respectTransparency false in instance {f : β → C} [HasCoproduct f] : IsIso (Sigma.desc (fun a ↦ Sigma.ι f a)) := by - convert IsIso.id _ + convert! IsIso.id _ ext simp @@ -908,7 +908,7 @@ set_option backward.isDefEq.respectTransparency false in theorem Sigma.ι_reindex_hom (b : β) : Sigma.ι (f ∘ ε) b ≫ (Sigma.reindex ε f).hom = Sigma.ι f (ε b) := by dsimp [Sigma.reindex] - simp only [HasColimit.isoOfEquivalence_hom_π, Functor.id_obj, Discrete.functor_obj, + simp only [HasColimit.ι_isoOfEquivalence_hom, Functor.id_obj, Discrete.functor_obj, Function.comp_apply, Discrete.equivalence_functor, Discrete.equivalence_inverse, Functor.comp_obj, Discrete.natIso_inv_app, Iso.refl_inv, Category.id_comp] have h := colimit.w (Discrete.functor f) (Discrete.eqToHom' (ε.apply_symm_apply (ε b))) diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Pullback/EquifiberedLimits.lean b/Mathlib/CategoryTheory/Limits/Shapes/Pullback/EquifiberedLimits.lean index 947467c7538ec8..1ea969cc8900a0 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Pullback/EquifiberedLimits.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Pullback/EquifiberedLimits.lean @@ -66,8 +66,8 @@ instance (F : C ⥤ D) [∀ a b : C, HasProductsOfShape (a ⟶ b) D] : hasColimitsOfShape_of_equivalence (Discrete.equivalence Quiver.Hom.opEquiv) let e : Over F.op ≌ (Under F)ᵒᵖ := (postEquiv _ (opUnopEquiv _ _)).symm.trans (opEquivOpUnder F) rw [isClosedUnderColimitsOfShape_iff_op, ← isClosedUnderLimitsOfShape_inverseImage_iff _ _ e] - convert (inferInstance : IsClosedUnderLimitsOfShape - (fun f : Over F.op ↦ f.hom.Equifibered) Jᵒᵖ) with f + convert! + (inferInstance : IsClosedUnderLimitsOfShape (fun f : Over F.op ↦ f.hom.Equifibered) Jᵒᵖ) with f simp [e, MorphismProperty.cancel_left_of_respectsIso, ← coequifibered_unop_iff] rfl diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Pullback/IsPullback/Basic.lean b/Mathlib/CategoryTheory/Limits/Shapes/Pullback/IsPullback/Basic.lean index 8beedc21db9c0d..6407f172ae432b 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Pullback/IsPullback/Basic.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Pullback/IsPullback/Basic.lean @@ -356,15 +356,8 @@ lemma of_isLimit_binaryFan_of_isTerminal {T : C} (hT : IsTerminal T) : IsPullback c.fst c.snd (hT.from _) (hT.from _) where isLimit' := ⟨PullbackCone.IsLimit.mk _ - (fun s ↦ hc.lift (BinaryFan.mk s.fst s.snd)) - (fun s ↦ hc.fac (BinaryFan.mk s.fst s.snd) ⟨.left⟩) - (fun s ↦ hc.fac (BinaryFan.mk s.fst s.snd) ⟨.right⟩) - (fun s m h₁ h₂ ↦ by - apply BinaryFan.IsLimit.hom_ext hc - · rw [h₁, hc.fac (BinaryFan.mk s.fst s.snd) ⟨.left⟩] - rfl - · rw [h₂, hc.fac (BinaryFan.mk s.fst s.snd) ⟨.right⟩] - rfl)⟩ + (fun s ↦ BinaryFan.IsLimit.lift hc s.fst s.snd) (by simp) (by simp) + (fun s m h₁ h₂ ↦ by apply BinaryFan.IsLimit.hom_ext hc <;> cat_disch)⟩ end lemma mk' {P X Y Z : C} {fst : P ⟶ X} {snd : P ⟶ Y} {f : X ⟶ Z} {g : Y ⟶ Z} @@ -744,15 +737,8 @@ lemma of_isColimit_binaryCofan_of_isInitial IsPushout (hI.to _) (hI.to _) c.inr c.inl where w := hI.hom_ext _ _ isColimit' := ⟨PushoutCocone.IsColimit.mk _ - (fun s ↦ hc.desc (BinaryCofan.mk s.inr s.inl)) - (fun s ↦ hc.fac (BinaryCofan.mk s.inr s.inl) ⟨.right⟩) - (fun s ↦ hc.fac (BinaryCofan.mk s.inr s.inl) ⟨.left⟩) - (fun s m h₁ h₂ ↦ by - apply BinaryCofan.IsColimit.hom_ext hc - · rw [h₂, hc.fac (BinaryCofan.mk s.inr s.inl) ⟨.left⟩] - rfl - · rw [h₁, hc.fac (BinaryCofan.mk s.inr s.inl) ⟨.right⟩] - rfl)⟩ + (fun s ↦ BinaryCofan.IsColimit.desc hc s.inr s.inl) (by simp) (by simp) + (fun s m h₁ h₂ ↦ by apply BinaryCofan.IsColimit.hom_ext hc <;> cat_disch)⟩ lemma mk' {Z X Y P : C} {f : Z ⟶ X} {g : Z ⟶ Y} {inl : X ⟶ P} {inr : Y ⟶ P} (w : f ≫ inl = g ≫ inr) diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Pullback/IsPullback/BicartesianSq.lean b/Mathlib/CategoryTheory/Limits/Shapes/Pullback/IsPullback/BicartesianSq.lean index 9fd133f613c86a..588cacb4f90c5c 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Pullback/IsPullback/BicartesianSq.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Pullback/IsPullback/BicartesianSq.lean @@ -66,7 +66,7 @@ variable {P X Y Z : C} {fst : P ⟶ X} {snd : P ⟶ Y} {f : X ⟶ Z} {g : Y ⟶ theorem of_hasBinaryProduct [HasBinaryProduct X Y] : IsPullback Limits.prod.fst Limits.prod.snd (0 : X ⟶ 0) (0 : Y ⟶ 0) := by - convert @of_is_product _ _ X Y 0 _ (limit.isLimit _) HasZeroObject.zeroIsTerminal + convert! @of_is_product _ _ X Y 0 _ (limit.isLimit _) HasZeroObject.zeroIsTerminal <;> subsingleton set_option backward.isDefEq.respectTransparency false in @@ -99,7 +99,7 @@ theorem zero_bot (X : C) : IsPullback (𝟙 X) (0 : X ⟶ 0) (0 : X ⟶ 0) (0 : theorem of_isBilimit {b : BinaryBicone X Y} (h : b.IsBilimit) : IsPullback b.fst b.snd (0 : X ⟶ 0) (0 : Y ⟶ 0) := by - convert IsPullback.of_is_product' h.isLimit HasZeroObject.zeroIsTerminal + convert! IsPullback.of_is_product' h.isLimit HasZeroObject.zeroIsTerminal <;> subsingleton @[simp] @@ -176,7 +176,7 @@ variable {Z X Y P : C} {f : Z ⟶ X} {g : Z ⟶ Y} {inl : X ⟶ P} {inr : Y ⟶ theorem of_hasBinaryCoproduct [HasBinaryCoproduct X Y] : IsPushout (0 : 0 ⟶ X) (0 : 0 ⟶ Y) coprod.inl coprod.inr := by - convert @of_is_coproduct _ _ 0 X Y _ (colimit.isColimit _) HasZeroObject.zeroIsInitial + convert! @of_is_coproduct _ _ 0 X Y _ (colimit.isColimit _) HasZeroObject.zeroIsInitial <;> subsingleton set_option backward.isDefEq.respectTransparency false in @@ -212,7 +212,7 @@ theorem zero_top (X : C) : IsPushout (0 : (0 : C) ⟶ 0) (0 : 0 ⟶ X) (0 : 0 theorem of_isBilimit {b : BinaryBicone X Y} (h : b.IsBilimit) : IsPushout (0 : 0 ⟶ X) (0 : 0 ⟶ Y) b.inl b.inr := by - convert IsPushout.of_is_coproduct' h.isColimit HasZeroObject.zeroIsInitial + convert! IsPushout.of_is_coproduct' h.isColimit HasZeroObject.zeroIsInitial <;> subsingleton @[simp] @@ -339,7 +339,7 @@ is a bi-Cartesian square. @[simp] theorem of_has_biproduct₁ [HasBinaryBiproduct X Y] : BicartesianSq biprod.fst biprod.snd (0 : X ⟶ 0) (0 : Y ⟶ 0) := by - convert of_is_biproduct₁ (BinaryBiproduct.isBilimit X Y) + convert! of_is_biproduct₁ (BinaryBiproduct.isBilimit X Y) /-- ``` 0 -----0---> X @@ -354,7 +354,7 @@ is a bi-Cartesian square. @[simp] theorem of_has_biproduct₂ [HasBinaryBiproduct X Y] : BicartesianSq (0 : 0 ⟶ X) (0 : 0 ⟶ Y) biprod.inl biprod.inr := by - convert of_is_biproduct₂ (BinaryBiproduct.isBilimit X Y) + convert! of_is_biproduct₂ (BinaryBiproduct.isBilimit X Y) end BicartesianSq end CategoryTheory diff --git a/Mathlib/CategoryTheory/Limits/Shapes/Pullback/Mono.lean b/Mathlib/CategoryTheory/Limits/Shapes/Pullback/Mono.lean index 3415ed43d1b1a8..705894aae5d3af 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/Pullback/Mono.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/Pullback/Mono.lean @@ -165,7 +165,7 @@ instance hasPullback_of_right_factors_mono : HasPullback i (f ≫ i) := by instance pullback_snd_iso_of_right_factors_mono : IsIso (pullback.snd i (f ≫ i)) := by have := limit.isoLimitCone_hom_π ⟨_, pullbackIsPullbackOfCompMono (𝟙 _) f i⟩ WalkingCospan.right - convert (congrArg IsIso (show _ ≫ pullback.snd (𝟙 Z) f = _ from this)).mp inferInstance + convert! (congrArg IsIso (show _ ≫ pullback.snd (𝟙 Z) f = _ from this)).mp inferInstance · exact (Category.id_comp _).symm · exact (Category.id_comp _).symm @@ -177,7 +177,7 @@ instance hasPullback_of_left_factors_mono : HasPullback (f ≫ i) i := by instance pullback_snd_iso_of_left_factors_mono : IsIso (pullback.fst (f ≫ i) i) := by have := limit.isoLimitCone_hom_π ⟨_, pullbackIsPullbackOfCompMono f (𝟙 _) i⟩ WalkingCospan.left - convert (congrArg IsIso (show _ ≫ pullback.fst f (𝟙 Z) = _ from this)).mp inferInstance + convert! (congrArg IsIso (show _ ≫ pullback.fst f (𝟙 Z) = _ from this)).mp inferInstance · exact (Category.id_comp _).symm · exact (Category.id_comp _).symm @@ -343,9 +343,12 @@ instance hasPushout_of_right_factors_epi : HasPushout h (h ≫ f) := by set_option backward.isDefEq.respectTransparency false in instance pushout_inr_iso_of_right_factors_epi : IsIso (pushout.inr _ _ : _ ⟶ pushout h (h ≫ f)) := by - convert (congrArg IsIso (show pushout.inr _ _ ≫ _ = _ from colimit.isoColimitCocone_ι_inv - ⟨_, pushoutIsPushoutOfEpiComp (𝟙 _) f h⟩ WalkingSpan.right)).mp - inferInstance + convert! + (congrArg IsIso + (show pushout.inr _ _ ≫ _ = _ from + colimit.isoColimitCocone_ι_inv ⟨_, pushoutIsPushoutOfEpiComp (𝟙 _) f h⟩ + WalkingSpan.right)).mp + inferInstance · apply (Category.comp_id _).symm · apply (Category.comp_id _).symm @@ -357,9 +360,12 @@ instance hasPushout_of_left_factors_epi (f : X ⟶ Y) : HasPushout (h ≫ f) h : set_option backward.isDefEq.respectTransparency false in instance pushout_inl_iso_of_left_factors_epi (f : X ⟶ Y) : IsIso (pushout.inl _ _ : _ ⟶ pushout (h ≫ f) h) := by - convert (congrArg IsIso (show pushout.inl _ _ ≫ _ = _ from colimit.isoColimitCocone_ι_inv - ⟨_, pushoutIsPushoutOfEpiComp f (𝟙 _) h⟩ WalkingSpan.left)).mp - inferInstance + convert! + (congrArg IsIso + (show pushout.inl _ _ ≫ _ = _ from + colimit.isoColimitCocone_ι_inv ⟨_, pushoutIsPushoutOfEpiComp f (𝟙 _) h⟩ + WalkingSpan.left)).mp + inferInstance · exact (Category.comp_id _).symm · exact (Category.comp_id _).symm diff --git a/Mathlib/CategoryTheory/Limits/Shapes/ZeroObjects.lean b/Mathlib/CategoryTheory/Limits/Shapes/ZeroObjects.lean index d4e98e703d840d..5ffb598b92c1c8 100644 --- a/Mathlib/CategoryTheory/Limits/Shapes/ZeroObjects.lean +++ b/Mathlib/CategoryTheory/Limits/Shapes/ZeroObjects.lean @@ -267,7 +267,7 @@ instance {X : C} (f : 0 ⟶ X) : Mono f where right_cancellation g h _ := by ext instance {X : C} (f : X ⟶ 0) : Epi f where left_cancellation g h _ := by ext instance zero_to_zero_isIso (f : (0 : C) ⟶ 0) : IsIso f := by - convert show IsIso (𝟙 (0 : C)) by infer_instance + convert! show IsIso (𝟙 (0 : C)) by infer_instance subsingleton /-- A zero object is in particular initial. -/ diff --git a/Mathlib/CategoryTheory/Limits/Types/Coequalizers.lean b/Mathlib/CategoryTheory/Limits/Types/Coequalizers.lean index 793fd0d4b47a4d..1fca1ad2404cdb 100644 --- a/Mathlib/CategoryTheory/Limits/Types/Coequalizers.lean +++ b/Mathlib/CategoryTheory/Limits/Types/Coequalizers.lean @@ -67,7 +67,7 @@ theorem coequalizer_preimage_image_eq_of_preimage_eq (π : Y ⟶ Z) (e : f ≫ inferInstance refine (eqv.eqvGen_iff.mp (Relation.EqvGen.mono lem (Quot.eqvGen_exact ?_))).mp hy apply e'' - convert e' + convert! e' · exact fun hx => ⟨_, hx, rfl⟩ /-- The categorical coequalizer in `Type u` is the quotient by `f g ~ g x`. -/ diff --git a/Mathlib/CategoryTheory/Limits/Types/ColimitType.lean b/Mathlib/CategoryTheory/Limits/Types/ColimitType.lean index 6a5fea5f00437d..81389e5f412d98 100644 --- a/Mathlib/CategoryTheory/Limits/Types/ColimitType.lean +++ b/Mathlib/CategoryTheory/Limits/Types/ColimitType.lean @@ -226,7 +226,7 @@ lemma fac_apply (c' : CoconeTypes.{w₂} F) (j : J) (x : F.obj j) : lemma of_equiv {c' : CoconeTypes.{w₂} F} (e : c.pt ≃ c'.pt) (he : ∀ j x, c'.ι j x = e (c.ι j x)) : c'.IsColimit where bijective := by - convert Function.Bijective.comp e.bijective hc.bijective + convert! Function.Bijective.comp e.bijective hc.bijective ext y obtain ⟨j, x, rfl⟩ := F.ιColimitType_jointly_surjective y simp_all @@ -237,7 +237,7 @@ lemma iff_bijective {c' : CoconeTypes.{w₂} F} refine ⟨fun hc' ↦ ?_, fun h ↦ hc.of_equiv (Equiv.ofBijective _ h) hf⟩ have h₁ := hc.bijective rw [← Function.Bijective.of_comp_iff _ hc.bijective] - convert hc'.bijective + convert! hc'.bijective ext x obtain ⟨j, x, rfl⟩ := F.ιColimitType_jointly_surjective x simp [hf] @@ -353,7 +353,7 @@ end CoconeTypes set_option backward.isDefEq.respectTransparency false in lemma isColimit_coconeTypes : F.coconeTypes.IsColimit where bijective := by - convert Function.bijective_id + convert! Function.bijective_id ext y obtain ⟨j, x, rfl⟩ := F.ιColimitType_jointly_surjective y rfl diff --git a/Mathlib/CategoryTheory/Limits/Types/Filtered.lean b/Mathlib/CategoryTheory/Limits/Types/Filtered.lean index 494d0160e8297f..f34079508815c2 100644 --- a/Mathlib/CategoryTheory/Limits/Types/Filtered.lean +++ b/Mathlib/CategoryTheory/Limits/Types/Filtered.lean @@ -131,7 +131,7 @@ theorem isColimit_eq_iff {t : Cocone F} (ht : IsColimit t) {i j : J} {xi : F.obj have : HasColimit F := ⟨_, ht⟩ refine Iff.trans ?_ (colimit_eq_iff_aux F) rw [← (IsColimit.coconePointUniqueUpToIso ht (colimitCoconeIsColimit F)).toEquiv.injective.eq_iff] - convert Iff.rfl + convert! Iff.rfl · exact (congr_hom (IsColimit.comp_coconePointUniqueUpToIso_hom ht (colimitCoconeIsColimit F) _) xi).symm · exact (congr_hom diff --git a/Mathlib/CategoryTheory/Limits/Types/Products.lean b/Mathlib/CategoryTheory/Limits/Types/Products.lean index 70c94aeeb66ba8..cf6bedc32dc1f9 100644 --- a/Mathlib/CategoryTheory/Limits/Types/Products.lean +++ b/Mathlib/CategoryTheory/Limits/Types/Products.lean @@ -163,8 +163,7 @@ def binaryProductFunctor : Type u ⥤ Type u ⥤ Type u where (BinaryFan.mk (↾_root_.Prod.fst) (↾_root_.Prod.snd ≫ f)) } map {X₁ X₂} f := { app := fun Y => - (binaryProductLimit X₂ Y).lift (BinaryFan.mk (↾_root_.Prod.fst ≫ f) - (↾_root_.Prod.snd)) } + BinaryFan.IsLimit.lift (binaryProductLimit X₂ Y) (↾_root_.Prod.fst ≫ f) (↾_root_.Prod.snd) } set_option backward.isDefEq.respectTransparency false in /-- The product functor given by the instance `HasBinaryProducts (Type u)` is isomorphic to the diff --git a/Mathlib/CategoryTheory/Limits/Types/Pushouts.lean b/Mathlib/CategoryTheory/Limits/Types/Pushouts.lean index 415d4bc0160478..3482815250efe2 100644 --- a/Mathlib/CategoryTheory/Limits/Types/Pushouts.lean +++ b/Mathlib/CategoryTheory/Limits/Types/Pushouts.lean @@ -210,7 +210,7 @@ variable {f g} lemma pushoutCocone_inl_eq_inr_imp_of_iso {c c' : PushoutCocone f g} (e : c ≅ c') (x₁ : X₁) (x₂ : X₂) (h : c.inl x₁ = c.inr x₂) : c'.inl x₁ = c'.inr x₂ := by - convert congr_arg e.hom.hom h + convert! congr_arg e.hom.hom h · exact ConcreteCategory.congr_hom (e.hom.w WalkingSpan.left).symm x₁ · exact ConcreteCategory.congr_hom (e.hom.w WalkingSpan.right).symm x₂ diff --git a/Mathlib/CategoryTheory/Limits/VanKampen.lean b/Mathlib/CategoryTheory/Limits/VanKampen.lean index dd3865fc49ffec..6b1024e023ff11 100644 --- a/Mathlib/CategoryTheory/Limits/VanKampen.lean +++ b/Mathlib/CategoryTheory/Limits/VanKampen.lean @@ -179,10 +179,11 @@ theorem IsUniversalColimit.whiskerEquivalence {K : Type*} [Category* K] (e : J {F : K ⥤ C} {c : Cocone F} (hc : IsUniversalColimit c) : IsUniversalColimit (c.whisker e.functor) := by intro F' c' α f e' hα H - convert hc (c'.whisker e.inverse) (whiskerLeft e.inverse α ≫ (e.invFunIdAssoc F).hom) f ?_ - ((hα.whiskerLeft _).comp (.of_isIso _)) ?_ using 1 + convert! + hc (c'.whisker e.inverse) (whiskerLeft e.inverse α ≫ (e.invFunIdAssoc F).hom) f ?_ + ((hα.whiskerLeft _).comp (.of_isIso _)) ?_ using 1 · exact (IsColimit.whiskerEquivalenceEquiv e.symm).nonempty_congr - · convert congr_arg (whiskerLeft e.inverse) e' + · convert! congr_arg (whiskerLeft e.inverse) e' ext simp · intro k @@ -201,8 +202,9 @@ theorem IsVanKampenColimit.whiskerEquivalence {K : Type*} [Category* K] (e : J {F : K ⥤ C} {c : Cocone F} (hc : IsVanKampenColimit c) : IsVanKampenColimit (c.whisker e.functor) := by intro F' c' α f e' hα - convert hc (c'.whisker e.inverse) (whiskerLeft e.inverse α ≫ (e.invFunIdAssoc F).hom) f ?_ - ((hα.whiskerLeft _).comp (.of_isIso _)) using 1 + convert! + hc (c'.whisker e.inverse) (whiskerLeft e.inverse α ≫ (e.invFunIdAssoc F).hom) f ?_ + ((hα.whiskerLeft _).comp (.of_isIso _)) using 1 · exact (IsColimit.whiskerEquivalenceEquiv e.symm).nonempty_congr · simp only [Functor.const_obj_obj, Functor.comp_obj, Cocone.whisker_pt, Cocone.whisker_ι, whiskerLeft_app, NatTrans.comp_app, Equivalence.invFunIdAssoc_hom_app, Functor.id_obj] @@ -379,8 +381,9 @@ theorem IsVanKampenColimit.map_reflective [HasColimitsOfShape J C] have : f = (hl.coconePointUniqueUpToIso hr).hom ≫ Gl.map (colimit.desc _ ⟨_, whiskerRight α' Gr ≫ c.2⟩) := by symm - convert @IsColimit.coconePointUniqueUpToIso_hom_desc _ _ _ _ ((F' ⋙ Gr) ⋙ Gl) - (Gl.mapCocone ⟨_, (whiskerRight α' Gr ≫ c.2 :)⟩) _ _ hl hr using 2 + convert! + @IsColimit.coconePointUniqueUpToIso_hom_desc _ _ _ _ ((F' ⋙ Gr) ⋙ Gl) + (Gl.mapCocone ⟨_, (whiskerRight α' Gr ≫ c.2 :)⟩) _ _ hl hr using 2 · apply hr.hom_ext intro j rw [hr.fac, Functor.mapCocone_ι_app, ← Gl.map_comp, colimit.cocone_ι, colimit.ι_desc] @@ -397,7 +400,7 @@ theorem IsVanKampenColimit.map_reflective [HasColimitsOfShape J C] have := ((H (colimit.cocone <| F' ⋙ Gr) (whiskerRight α' Gr) (colimit.desc _ ⟨_, whiskerRight α' Gr ≫ c.2⟩) ?_ (hα'.whiskerRight Gr)).mp ⟨(getColimitCocone <| F' ⋙ Gr).2⟩ j).map Gl - · convert IsPullback.paste_vert _ this + · convert! IsPullback.paste_vert _ this refine IsPullback.of_vert_isIso ⟨?_⟩ rw [← IsIso.inv_comp_eq, ← Category.assoc, NatIso.inv_inv_app] exact IsColimit.comp_coconePointUniqueUpToIso_hom hl hr _ @@ -704,7 +707,7 @@ theorem isPullback_initial_to_of_cofan_isVanKampen [HasInitial C] {ι : Type*} { clear_value f subst this have : ∀ i, Subsingleton (⊥_ C ⟶ (Discrete.functor f).obj i) := inferInstance - convert isPullback_of_cofan_isVanKampen hc i.as j.as + convert! isPullback_of_cofan_isVanKampen hc i.as j.as exact (if_neg (mt Discrete.ext hi.symm)).symm set_option backward.isDefEq.respectTransparency false in @@ -718,7 +721,7 @@ theorem mono_of_cofan_isVanKampen [HasInitial C] {ι : Type*} {F : Discrete ι subst this refine PullbackCone.mono_of_isLimitMkIdId _ (IsPullback.isLimit ?_) nth_rw 1 [← Category.id_comp (c.ι.app i)] - convert IsPullback.paste_vert _ (isPullback_of_cofan_isVanKampen hc i.as i.as) + convert! IsPullback.paste_vert _ (isPullback_of_cofan_isVanKampen hc i.as i.as) swap · exact (eqToHom (if_pos rfl).symm) · simp diff --git a/Mathlib/CategoryTheory/Limits/Yoneda.lean b/Mathlib/CategoryTheory/Limits/Yoneda.lean index 42d068ce0a77d1..cfb9d8386fbce8 100644 --- a/Mathlib/CategoryTheory/Limits/Yoneda.lean +++ b/Mathlib/CategoryTheory/Limits/Yoneda.lean @@ -204,6 +204,12 @@ instance uliftYonedaFunctor_preservesLimits : change PreservesLimitsOfSize.{t, w} (coyoneda.obj K ⋙ uliftFunctor.{w'}) infer_instance +instance : PreservesLimitsOfSize.{t, w} (uliftCoyoneda.{w'} : Cᵒᵖ ⥤ _) := by + apply preservesLimits_of_evaluation + intro K + change PreservesLimitsOfSize.{t, w} (yoneda.obj _ ⋙ uliftFunctor.{w'}) + infer_instance + instance [LocallySmall.{w'} C] : PreservesLimitsOfSize.{t, w} (shrinkYoneda.{w'} (C := C)) := preservesLimits_of_evaluation _ (fun K ↦ ⟨fun {J _} ↦ by @@ -215,35 +221,25 @@ namespace Functor section Representable -variable (F : Cᵒᵖ ⥤ Type v) [F.IsRepresentable] {J : Type*} [Category* J] - -instance representable_preservesLimit (G : J ⥤ Cᵒᵖ) : - PreservesLimit G F := - preservesLimit_of_natIso _ F.reprW +variable (F : Cᵒᵖ ⥤ Type w') [F.IsRepresentable] -variable (J) in -instance representable_preservesLimitsOfShape : - PreservesLimitsOfShape J F where - -instance representable_preservesLimits : - PreservesLimitsOfSize.{t, w} F where +instance : PreservesLimitsOfSize.{t, w} F := by + suffices PreservesLimitsOfSize (F ⋙ uliftFunctor.{v}) from + preservesLimits_of_reflects_of_preserves _ (uliftFunctor.{v}) + rw [preservesLimitsOfSize_iff_of_natIso (F ⋙ uliftFunctor.{v}).uliftYonedaReprXIso.symm] + exact inferInstanceAs <| PreservesLimitsOfSize (yoneda.obj _ ⋙ uliftFunctor) end Representable section Corepresentable -variable (F : C ⥤ Type v) [F.IsCorepresentable] {J : Type*} [Category* J] - -instance corepresentable_preservesLimit (G : J ⥤ C) : - PreservesLimit G F := - preservesLimit_of_natIso _ F.coreprW - -variable (J) in -instance corepresentable_preservesLimitsOfShape : - PreservesLimitsOfShape J F where +variable (F : C ⥤ Type*) [F.IsCorepresentable] -instance corepresentable_preservesLimits : - PreservesLimitsOfSize.{t, w} F where +instance : PreservesLimitsOfSize.{t, w} F := by + suffices PreservesLimitsOfSize (F ⋙ uliftFunctor.{v}) from + preservesLimits_of_reflects_of_preserves _ (uliftFunctor.{v}) + rw [preservesLimitsOfSize_iff_of_natIso (F ⋙ uliftFunctor.{v}).uliftCoyonedaCoreprXIso.symm] + exact inferInstanceAs <| PreservesLimitsOfSize (coyoneda.obj _ ⋙ uliftFunctor) end Corepresentable diff --git a/Mathlib/CategoryTheory/Localization/Bousfield.lean b/Mathlib/CategoryTheory/Localization/Bousfield.lean index 41bbb0279b0325..92f3b22c5a367b 100644 --- a/Mathlib/CategoryTheory/Localization/Bousfield.lean +++ b/Mathlib/CategoryTheory/Localization/Bousfield.lean @@ -162,17 +162,17 @@ lemma isoClosure_isColocal : P.isoClosure.isColocal = P.isColocal := by instance : P.isColocal.IsMultiplicative where id_mem _ _ _ := by simpa [id_comp] using Function.bijective_id comp_mem f g hf hg X hX := by - convert Function.Bijective.comp (hg X hX) (hf X hX) + convert! Function.Bijective.comp (hg X hX) (hf X hX) cat_disch instance : P.isColocal.HasTwoOutOfThreeProperty where of_postcomp f g hg hfg X hX := by rw [← Function.Bijective.of_comp_iff' (hg X hX)] - convert hfg X hX + convert! hfg X hX cat_disch of_precomp f g hf hfg X hX := by rw [← Function.Bijective.of_comp_iff _ (hf X hX)] - convert hfg X hX + convert! hfg X hX cat_disch lemma isColocal_of_isIso {X Y : C} (f : X ⟶ Y) [IsIso f] : P.isColocal f := fun Z _ => by @@ -215,8 +215,9 @@ include adj lemma isLocal_adj_unit_app (X : D) : isLocal (· ∈ Set.range F.obj) (adj.unit.app X) := by rintro _ ⟨Y, rfl⟩ - convert ((Functor.FullyFaithful.ofFullyFaithful F).homEquiv.symm.trans - (adj.homEquiv X Y)).bijective using 1 + convert! + ((Functor.FullyFaithful.ofFullyFaithful F).homEquiv.symm.trans + (adj.homEquiv X Y)).bijective using 1 dsimp [Adjunction.homEquiv] aesop @@ -249,8 +250,9 @@ include adj lemma isColocal_adj_counit_app (X : C) : isColocal (· ∈ Set.range G.obj) (adj.counit.app X) := by rintro _ ⟨Y, rfl⟩ - convert ((Functor.FullyFaithful.ofFullyFaithful G).homEquiv.symm.trans - (adj.homEquiv Y X).symm).bijective using 1 + convert! + ((Functor.FullyFaithful.ofFullyFaithful G).homEquiv.symm.trans + (adj.homEquiv Y X).symm).bijective using 1 dsimp [Adjunction.homEquiv] cat_disch diff --git a/Mathlib/CategoryTheory/Localization/DerivabilityStructure/OfLocalizedEquivalences.lean b/Mathlib/CategoryTheory/Localization/DerivabilityStructure/OfLocalizedEquivalences.lean index cb0d171a5c5e19..e0a0a88b47c3f9 100644 --- a/Mathlib/CategoryTheory/Localization/DerivabilityStructure/OfLocalizedEquivalences.lean +++ b/Mathlib/CategoryTheory/Localization/DerivabilityStructure/OfLocalizedEquivalences.lean @@ -75,8 +75,9 @@ lemma isLeftDerivabilityStructure_of_isLocalizedEquivalence letI : CatCommSq T.functor (L.functor ⋙ W₁'.Q) (R.functor ⋙ W₂'.Q) F := CatCommSq.vComp (H₂ := B.functor) _ _ _ _ _ _ have : (TwoSquare.hComp iso.inv e'.inv).GuitartExact := by - convert T.guitartExact_of_isLeftDerivabilityStructure' (L.functor ⋙ W₁'.Q) - (R.functor ⋙ W₂'.Q) F (CatCommSq.iso _ _ _ _) + convert! + T.guitartExact_of_isLeftDerivabilityStructure' (L.functor ⋙ W₁'.Q) (R.functor ⋙ W₂'.Q) F + (CatCommSq.iso _ _ _ _) ext simp [e', CatCommSq.iso, iso'] rw [B.isLeftDerivabilityStructure_iff W₁'.Q W₂'.Q F e'] diff --git a/Mathlib/CategoryTheory/Localization/Monoidal/Basic.lean b/Mathlib/CategoryTheory/Localization/Monoidal/Basic.lean index 00a1c9ebf884c0..2c3ea3a00dbeaf 100644 --- a/Mathlib/CategoryTheory/Localization/Monoidal/Basic.lean +++ b/Mathlib/CategoryTheory/Localization/Monoidal/Basic.lean @@ -432,7 +432,7 @@ lemma triangle (X Y : LocalizedMonoidal L W ε) : triangle_aux₁ _ _ _ e₁.symm ε.symm e₂.symm simp only [← this, Iso.symm_hom, Iso.symm_inv, assoc, ← id_tensorHom, ← tensor_comp, comp_id] - convert h₃ + convert! h₃ · exact triangle_aux₂ _ _ _ e₁ e₂ · exact triangle_aux₃ _ _ _ e₁ e₂ diff --git a/Mathlib/CategoryTheory/Localization/Opposite.lean b/Mathlib/CategoryTheory/Localization/Opposite.lean index efa7be661782f5..2f013c3161e766 100644 --- a/Mathlib/CategoryTheory/Localization/Opposite.lean +++ b/Mathlib/CategoryTheory/Localization/Opposite.lean @@ -37,7 +37,7 @@ def StrictUniversalPropertyFixedTarget.op {E : Type*} [Category* E] inverts := h.inverts.op lift F hF := (h.lift F.rightOp hF.rightOp).leftOp fac F hF := by - convert congr_arg Functor.leftOp (h.fac F.rightOp hF.rightOp) + convert! congr_arg Functor.leftOp (h.fac F.rightOp hF.rightOp) uniq F₁ F₂ eq := by suffices F₁.rightOp = F₂.rightOp by rw [← F₁.rightOp_leftOp_eq, ← F₂.rightOp_leftOp_eq, this] diff --git a/Mathlib/CategoryTheory/Localization/Predicate.lean b/Mathlib/CategoryTheory/Localization/Predicate.lean index c0a5e2f8ffc2a1..ca88ecb7e2851b 100644 --- a/Mathlib/CategoryTheory/Localization/Predicate.lean +++ b/Mathlib/CategoryTheory/Localization/Predicate.lean @@ -232,6 +232,7 @@ the composition with a localization functor `L : C ⥤ D` with respect to def functorEquivalence : D ⥤ E ≌ W.FunctorsInverting E := (whiskeringLeftFunctor L W E).asEquivalence +set_option linter.overlappingInstances false in /-- The functor `(D ⥤ E) ⥤ (C ⥤ E)` given by the composition with a localization functor `L : C ⥤ D` with respect to `W : MorphismProperty C`. -/ @[nolint unusedArguments] diff --git a/Mathlib/CategoryTheory/Localization/StructuredArrow.lean b/Mathlib/CategoryTheory/Localization/StructuredArrow.lean index 5f14cc4a57d957..7c41067c5f47bc 100644 --- a/Mathlib/CategoryTheory/Localization/StructuredArrow.lean +++ b/Mathlib/CategoryTheory/Localization/StructuredArrow.lean @@ -106,13 +106,13 @@ lemma induction_structuredArrow fun g ↦ P (structuredArrowEquiv W W.Q L g) rw [← (structuredArrowEquiv W W.Q L).apply_symm_apply g] apply induction_structuredArrow' W P' - · convert hP₀ + · convert! hP₀ simp · intro Y₁ Y₂ f φ hφ - convert hP₁ f (homEquiv W W.Q L φ) hφ + convert! hP₁ f (homEquiv W W.Q L φ) hφ simp [homEquiv_comp] · intro Y₁ Y₂ w hw φ hφ - convert hP₂ w hw (homEquiv W W.Q L φ) hφ + convert! hP₂ w hw (homEquiv W W.Q L φ) hφ simp [homEquiv_comp, homEquiv_isoOfHom_inv] end diff --git a/Mathlib/CategoryTheory/Monoidal/Braided/Basic.lean b/Mathlib/CategoryTheory/Monoidal/Braided/Basic.lean index a4a248c6f7b58e..7e7cbe96ea03b1 100644 --- a/Mathlib/CategoryTheory/Monoidal/Braided/Basic.lean +++ b/Mathlib/CategoryTheory/Monoidal/Braided/Basic.lean @@ -166,7 +166,7 @@ theorem yang_baxter' (X Y Z : C) : (β_ X Y).hom ▷ Z ⊗≫ Y ◁ (β_ X Z).hom ⊗≫ (β_ Y Z).hom ▷ X = 𝟙 _ ⊗≫ (X ◁ (β_ Y Z).hom ⊗≫ (β_ X Z).hom ▷ Y ⊗≫ Z ◁ (β_ X Y).hom) ⊗≫ 𝟙 _ := by rw [← cancel_epi (α_ X Y Z).inv, ← cancel_mono (α_ Z Y X).hom] - convert yang_baxter X Y Z using 1 + convert! yang_baxter X Y Z using 1 all_goals monoidal theorem yang_baxter_iso (X Y Z : C) : @@ -633,13 +633,13 @@ theorem tensorμ_natural {X₁ X₂ Y₁ Y₂ U₁ U₂ V₁ V₂ : C} (f₁ : X theorem tensorμ_natural_left {X₁ X₂ Y₁ Y₂ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) (Z₁ Z₂ : C) : (f₁ ⊗ₘ f₂) ▷ (Z₁ ⊗ Z₂) ≫ tensorμ Y₁ Y₂ Z₁ Z₂ = tensorμ X₁ X₂ Z₁ Z₂ ≫ (f₁ ▷ Z₁ ⊗ₘ f₂ ▷ Z₂) := by - convert tensorμ_natural f₁ f₂ (𝟙 Z₁) (𝟙 Z₂) using 1 <;> simp + convert! tensorμ_natural f₁ f₂ (𝟙 Z₁) (𝟙 Z₂) using 1 <;> simp @[reassoc] theorem tensorμ_natural_right (Z₁ Z₂ : C) {X₁ X₂ Y₁ Y₂ : C} (f₁ : X₁ ⟶ Y₁) (f₂ : X₂ ⟶ Y₂) : (Z₁ ⊗ Z₂) ◁ (f₁ ⊗ₘ f₂) ≫ tensorμ Z₁ Z₂ Y₁ Y₂ = tensorμ Z₁ Z₂ X₁ X₂ ≫ (Z₁ ◁ f₁ ⊗ₘ Z₂ ◁ f₂) := by - convert tensorμ_natural (𝟙 Z₁) (𝟙 Z₂) f₁ f₂ using 1 <;> simp + convert! tensorμ_natural (𝟙 Z₁) (𝟙 Z₂) f₁ f₂ using 1 <;> simp @[reassoc] theorem tensor_left_unitality (X₁ X₂ : C) : diff --git a/Mathlib/CategoryTheory/Monoidal/Closed/Cartesian.lean b/Mathlib/CategoryTheory/Monoidal/Closed/Cartesian.lean index 5fdd055d657958..02f96505e73e9e 100644 --- a/Mathlib/CategoryTheory/Monoidal/Closed/Cartesian.lean +++ b/Mathlib/CategoryTheory/Monoidal/Closed/Cartesian.lean @@ -98,6 +98,7 @@ def powZero [BraidedCategory C] {I : C} (t : IsInitial I) [MonoidalClosed C] : I rw [← curry_natural_left, curry_eq_iff, ← cancel_epi (mulZero t).inv] apply t.hom_ext +set_option linter.overlappingInstances false in set_option backward.isDefEq.respectTransparency false in -- TODO: Generalise the below to its commuted variants. -- TODO: Define a distributive category, so that zero_mul and friends can be derived from this. diff --git a/Mathlib/CategoryTheory/Monoidal/Closed/Functor.lean b/Mathlib/CategoryTheory/Monoidal/Closed/Functor.lean index 43c6c9aa4afb03..b77627d3050310 100644 --- a/Mathlib/CategoryTheory/Monoidal/Closed/Functor.lean +++ b/Mathlib/CategoryTheory/Monoidal/Closed/Functor.lean @@ -86,7 +86,7 @@ set_option backward.isDefEq.respectTransparency false in theorem expComparison_ev (A B : C) : F.obj A ◁ ((expComparison F A).natTrans.app B) ≫ (ihom.ev (F.obj A)).app (F.obj B) = inv (prodComparison F _ _) ≫ F.map ((ihom.ev _).app _) := by - convert mateEquiv_counit _ _ (prodComparisonNatIso F A).inv B using 2 + convert! mateEquiv_counit _ _ (prodComparisonNatIso F A).inv B using 2 apply IsIso.inv_eq_of_hom_inv_id -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): was `ext` simp only [prodComparisonNatTrans_app, prodComparisonNatIso_inv, NatIso.isIso_inv_app, IsIso.hom_inv_id] @@ -95,7 +95,7 @@ set_option backward.isDefEq.respectTransparency false in theorem coev_expComparison (A B : C) : F.map ((ihom.coev A).app B) ≫ (expComparison F A).natTrans.app (A ⊗ B) = (ihom.coev _).app (F.obj B) ≫ (ihom (F.obj A)).map (inv (prodComparison F A B)) := by - convert unit_mateEquiv _ _ (prodComparisonNatIso F A).inv B using 3 + convert! unit_mateEquiv _ _ (prodComparisonNatIso F A).inv B using 3 apply IsIso.inv_eq_of_hom_inv_id -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): was `ext` simp diff --git a/Mathlib/CategoryTheory/Monoidal/Free/Coherence.lean b/Mathlib/CategoryTheory/Monoidal/Free/Coherence.lean index 60505a12b403b0..61fea3451b6c82 100644 --- a/Mathlib/CategoryTheory/Monoidal/Free/Coherence.lean +++ b/Mathlib/CategoryTheory/Monoidal/Free/Coherence.lean @@ -134,6 +134,7 @@ section variable (C) +set_option backward.isDefEq.respectTransparency false in /-- Our normalization procedure works by first defining a functor `F C ⥤ (N C ⥤ N C)` (which turns out to be very easy), and then obtain a functor `F C ⥤ N C` by plugging in the normal object `𝟙_ C`. -/ @@ -274,7 +275,7 @@ def normalizeIso : tensorFunc C ≅ normalize' C := NatIso.ofComponents (normalizeIsoAux C) <| by intro X Y f ext ⟨n⟩ - convert normalize_naturality n f using 1 + convert! normalize_naturality n f using 1 any_goals dsimp; rw [normalizeIsoApp_eq] /-- The isomorphism between an object and its normal form is natural. -/ diff --git a/Mathlib/CategoryTheory/Monoidal/Grp.lean b/Mathlib/CategoryTheory/Monoidal/Grp.lean index 23c64ca9e1ef94..bac92072ab9b00 100644 --- a/Mathlib/CategoryTheory/Monoidal/Grp.lean +++ b/Mathlib/CategoryTheory/Monoidal/Grp.lean @@ -336,7 +336,7 @@ lemma toMonObj_injective {X : C} : suffices h₁.inv = h₂.inv by cases h₁; congr! apply lift_left_mul_ext (𝟙 _) rw [left_inv] - convert @left_inv _ _ _ _ h₁ using 2 + convert! @left_inv _ _ _ _ h₁ using 2 exacts [congr(($e.symm).mul), congr(($e.symm).one)] @[to_additive (attr := ext)] diff --git a/Mathlib/CategoryTheory/Monoidal/Internal/Module.lean b/Mathlib/CategoryTheory/Monoidal/Internal/Module.lean index b518401d7eee82..99fff9f427fd49 100644 --- a/Mathlib/CategoryTheory/Monoidal/Internal/Module.lean +++ b/Mathlib/CategoryTheory/Monoidal/Internal/Module.lean @@ -49,19 +49,19 @@ def MonObj.toRing (A : ModuleCat.{u} R) [MonObj A] : Ring A := one := η[A] (1 : R) mul := fun x y => μ[A] (x ⊗ₜ y) one_mul := fun x => by - convert LinearMap.congr_fun (ModuleCat.hom_ext_iff.mp (one_mul A)) ((1 : R) ⊗ₜ x) + convert! LinearMap.congr_fun (ModuleCat.hom_ext_iff.mp (one_mul A)) ((1 : R) ⊗ₜ x) rw [MonoidalCategory.leftUnitor_hom_apply, one_smul] mul_one := fun x => by - convert LinearMap.congr_fun (ModuleCat.hom_ext_iff.mp (mul_one A)) (x ⊗ₜ (1 : R)) + convert! LinearMap.congr_fun (ModuleCat.hom_ext_iff.mp (mul_one A)) (x ⊗ₜ (1 : R)) rw [MonoidalCategory.rightUnitor_hom_apply, one_smul] mul_assoc := fun x y z => by - convert LinearMap.congr_fun (ModuleCat.hom_ext_iff.mp (mul_assoc A)) (x ⊗ₜ y ⊗ₜ z) + convert! LinearMap.congr_fun (ModuleCat.hom_ext_iff.mp (mul_assoc A)) (x ⊗ₜ y ⊗ₜ z) left_distrib := fun x y z => by - convert μ[A].hom.map_add (x ⊗ₜ y) (x ⊗ₜ z) + convert! μ[A].hom.map_add (x ⊗ₜ y) (x ⊗ₜ z) rw [← TensorProduct.tmul_add] rfl right_distrib := fun x y z => by - convert μ[A].hom.map_add (x ⊗ₜ z) (y ⊗ₜ z) + convert! μ[A].hom.map_add (x ⊗ₜ z) (y ⊗ₜ z) rw [← TensorProduct.add_tmul] rfl zero_mul := fun x => show μ[A] _ = 0 by diff --git a/Mathlib/CategoryTheory/Monoidal/Internal/Types/Basic.lean b/Mathlib/CategoryTheory/Monoidal/Internal/Types/Basic.lean index 085cda682d289c..505dea9ab5d083 100644 --- a/Mathlib/CategoryTheory/Monoidal/Internal/Types/Basic.lean +++ b/Mathlib/CategoryTheory/Monoidal/Internal/Types/Basic.lean @@ -31,9 +31,9 @@ namespace MonTypeEquivalenceMon instance monMonoid (A : Type u) [MonObj A] : Monoid A where one := η[A] PUnit.unit mul x y := μ[A] (x, y) - one_mul x := by convert congr_hom (CC := fun X ↦ X) (one_mul A) (PUnit.unit, x) - mul_one x := by convert congr_hom (CC := fun X ↦ X) (mul_one A) (x, PUnit.unit) - mul_assoc x y z := by convert congr_hom (CC := fun X ↦ X) (mul_assoc A) ((x, y), z) + one_mul x := by convert! congr_hom (CC := fun X ↦ X) (one_mul A) (PUnit.unit, x) + mul_one x := by convert! congr_hom (CC := fun X ↦ X) (mul_one A) (x, PUnit.unit) + mul_assoc x y z := by convert! congr_hom (CC := fun X ↦ X) (mul_assoc A) ((x, y), z) /-- Converting a monoid object in `Type` to a bundled monoid. -/ @@ -97,7 +97,8 @@ namespace CommMonTypeEquivalenceCommMon instance commMonCommMonoid (A : Type u) [MonObj A] [IsCommMonObj A] : CommMonoid A := { MonTypeEquivalenceMon.monMonoid A with - mul_comm := fun x y => by convert congr_hom (CC := fun X ↦ X) (IsCommMonObj.mul_comm A) (y, x) } + mul_comm := fun x y => by + convert! congr_hom (CC := fun X ↦ X) (IsCommMonObj.mul_comm A) (y, x) } /-- Converting a commutative monoid object in `Type` to a bundled commutative monoid. -/ diff --git a/Mathlib/CategoryTheory/Monoidal/Internal/Types/CommGrp_.lean b/Mathlib/CategoryTheory/Monoidal/Internal/Types/CommGrp_.lean index cf56adf826a27c..46038c4c81e68c 100644 --- a/Mathlib/CategoryTheory/Monoidal/Internal/Types/CommGrp_.lean +++ b/Mathlib/CategoryTheory/Monoidal/Internal/Types/CommGrp_.lean @@ -29,7 +29,8 @@ namespace CommGrpTypeEquivalenceCommGrp instance commGrpCommGroup (A : Type u) [GrpObj A] [IsCommMonObj A] : CommGroup A := { GrpTypeEquivalenceGrp.grpGroup A with - mul_comm := fun x y => by convert congr_hom (CC := fun X ↦ X) (IsCommMonObj.mul_comm A) (y, x) } + mul_comm := fun x y => by + convert! congr_hom (CC := fun X ↦ X) (IsCommMonObj.mul_comm A) (y, x) } /-- Converting a commutative group object in `Type u` into a group. -/ noncomputable def functor : CommGrp (Type u) ⥤ CommGrpCat.{u} where diff --git a/Mathlib/CategoryTheory/Monoidal/Rigid/Basic.lean b/Mathlib/CategoryTheory/Monoidal/Rigid/Basic.lean index f99b0fd913ea54..06ca90b22a06e3 100644 --- a/Mathlib/CategoryTheory/Monoidal/Rigid/Basic.lean +++ b/Mathlib/CategoryTheory/Monoidal/Rigid/Basic.lean @@ -118,11 +118,11 @@ lemma evaluation_coevaluation : lemma coevaluation_evaluation'' : Y ◁ η_ X Y ⊗≫ ε_ X Y ▷ Y = ⊗𝟙.hom := by - convert coevaluation_evaluation X Y <;> simp [monoidalComp] + convert! coevaluation_evaluation X Y <;> simp [monoidalComp] lemma evaluation_coevaluation'' : η_ X Y ▷ X ⊗≫ X ◁ ε_ X Y = ⊗𝟙.hom := by - convert evaluation_coevaluation X Y <;> simp [monoidalComp] + convert! evaluation_coevaluation X Y <;> simp [monoidalComp] end ExactPairing diff --git a/Mathlib/CategoryTheory/Monoidal/Ring.lean b/Mathlib/CategoryTheory/Monoidal/Ring.lean index 0f88054ea58544..7c998064df7e86 100644 --- a/Mathlib/CategoryTheory/Monoidal/Ring.lean +++ b/Mathlib/CategoryTheory/Monoidal/Ring.lean @@ -47,7 +47,7 @@ lemma mul_add_iff (R : C) [MonObj R] [AddMonObj R] : cat_disch · replace h := h (fst R (R ⊗ R)) (snd _ _ ≫ fst _ _) (snd _ _ ≫ snd _ _) simp only [Hom.mul_def, Hom.add_def] at h - convert h using 2 + convert! h using 2 · cat_disch · ext · simp only [lift_fst] @@ -67,7 +67,7 @@ lemma add_mul_iff (R : C) [MonObj R] [AddMonObj R] : cat_disch · replace h := h (fst (R ⊗ R) R ≫ fst _ _) (fst _ _ ≫ snd _ _) (snd _ _) simp only [Hom.mul_def, Hom.add_def] at h - convert h using 2 + convert! h using 2 · cat_disch · ext · simp only [lift_fst] diff --git a/Mathlib/CategoryTheory/MorphismProperty/Concrete.lean b/Mathlib/CategoryTheory/MorphismProperty/Concrete.lean index 8a63916bbc0121..083328e2b51d15 100644 --- a/Mathlib/CategoryTheory/MorphismProperty/Concrete.lean +++ b/Mathlib/CategoryTheory/MorphismProperty/Concrete.lean @@ -52,7 +52,7 @@ theorem bijective_eq_sup : instance : (MorphismProperty.injective C).IsMultiplicative where id_mem X := by delta MorphismProperty.injective - convert injective_id + convert! injective_id aesop comp_mem f g hf hg := by delta MorphismProperty.injective @@ -62,7 +62,7 @@ instance : (MorphismProperty.injective C).IsMultiplicative where instance : (MorphismProperty.surjective C).IsMultiplicative where id_mem X := by delta MorphismProperty.surjective - convert surjective_id + convert! surjective_id aesop comp_mem f g hf hg := by delta MorphismProperty.surjective @@ -72,7 +72,7 @@ instance : (MorphismProperty.surjective C).IsMultiplicative where instance : (MorphismProperty.bijective C).IsMultiplicative where id_mem X := by delta MorphismProperty.bijective - convert bijective_id + convert! bijective_id aesop comp_mem f g hf hg := by delta MorphismProperty.bijective diff --git a/Mathlib/CategoryTheory/MorphismProperty/Descent.lean b/Mathlib/CategoryTheory/MorphismProperty/Descent.lean index 7c34987899f708..3a9a1dd63b87f1 100644 --- a/Mathlib/CategoryTheory/MorphismProperty/Descent.lean +++ b/Mathlib/CategoryTheory/MorphismProperty/Descent.lean @@ -137,7 +137,7 @@ lemma faithful_overPullback_of_isomorphisms_descendAlong refine ⟨fun {X} Y a b hab ↦ ?_⟩ ext apply P.eq_of_isomorphisms_descendsAlong (Over.w a) (Over.w b) f hf - convert congr($(hab).left) <;> ext <;> simp + convert! congr($(hab).left) <;> ext <;> simp end DescendsAlong diff --git a/Mathlib/CategoryTheory/MorphismProperty/Limits.lean b/Mathlib/CategoryTheory/MorphismProperty/Limits.lean index 9f5b8452764f34..2841e8b8930380 100644 --- a/Mathlib/CategoryTheory/MorphismProperty/Limits.lean +++ b/Mathlib/CategoryTheory/MorphismProperty/Limits.lean @@ -131,11 +131,17 @@ as `f`, the pullback of that morphism along `f` exists. -/ protected class HasPullbacksAlong {X Y : C} (f : X ⟶ Y) : Prop where hasPullback {W} (g : W ⟶ Y) : P g → HasPullback g f +instance {X Y : C} (f : X ⟶ Y) [HasPullbacksAlong f] : P.HasPullbacksAlong f where + hasPullback _ _ := inferInstance + /-- `P.HasPushoutsAlong f` states that for any morphism satisfying `P` with the same domain as `f`, the pushout of that morphism along `f` exists. -/ protected class HasPushoutsAlong {X Y : C} (f : X ⟶ Y) : Prop where hasPushout {W} (g : X ⟶ W) : P g → HasPushout g f +instance {X Y : C} (f : X ⟶ Y) [HasPushoutsAlong f] : P.HasPushoutsAlong f where + hasPushout _ _ := inferInstance + /-- `P.IsStableUnderBaseChangeAlong f` states that for any morphism satisfying `P` with the same codomain as `f`, any pullback of that morphism along `f` also satisfies `P`. -/ class IsStableUnderBaseChangeAlong {X Y : C} (f : X ⟶ Y) : Prop where diff --git a/Mathlib/CategoryTheory/MorphismProperty/OverAdjunction.lean b/Mathlib/CategoryTheory/MorphismProperty/OverAdjunction.lean index 5321ab771230cc..803ff254e3ee77 100644 --- a/Mathlib/CategoryTheory/MorphismProperty/OverAdjunction.lean +++ b/Mathlib/CategoryTheory/MorphismProperty/OverAdjunction.lean @@ -56,6 +56,7 @@ def Over.mapCongr [Q.RespectsIso] {X Y : T} {f g : X ⟶ Y} (hfg : f = g) (hf : Over.map Q hf ≅ Over.map (f := g) Q (by cat_disch) := NatIso.ofComponents (fun Y ↦ Over.isoMk (Iso.refl _)) +set_option linter.overlappingInstances false in /-- `Over.map` preserves identities. -/ @[simps!] def Over.mapId [P.IsMultiplicative] [Q.RespectsIso] (X : T) (f : X ⟶ X := 𝟙 X) @@ -157,6 +158,15 @@ noncomputable def Over.pullbackMapHomPullback [P.IsStableUnderComposition] Over.homMk (pullback.map _ _ _ _ (𝟙 A.left) f (𝟙 Z) (by simp) (by cat_disch)) (by simp) (Q.pullbackMap (Q.id_mem _) hQf (by simp) (by cat_disch)) +/-- `MorphismProperty.Over.pullback` commutes with `MorphismProperty.Over.forget`. -/ +@[simps!] +noncomputable +def Over.pullbackCompForgetIso {X Y : T} (f : X ⟶ Y) [HasPullbacksAlong f] + [P.IsStableUnderBaseChangeAlong f] [Q.IsStableUnderBaseChange] : + Over.pullback P Q f ⋙ Over.forget _ _ _ ≅ + Over.forget _ _ _ ⋙ CategoryTheory.Over.pullback f := + Iso.refl _ + end Pullback section Adjunction @@ -216,6 +226,7 @@ def Under.mapCongr [Q.RespectsIso] {X Y : T} {f g : X ⟶ Y} (hfg : f = g) (hf : Under.map Q hf ≅ Under.map (f := g) Q (by cat_disch) := NatIso.ofComponents (fun Y ↦ Under.isoMk (Iso.refl _)) +set_option linter.overlappingInstances false in /-- `Under.map` preserves identities. -/ @[simps!] def Under.mapId [P.IsMultiplicative] [Q.RespectsIso] (X : T) (f : X ⟶ X := 𝟙 X) @@ -297,6 +308,15 @@ lemma Under.pushoutCongr_hom_app_left_fst {f : X ⟶ Y} [P.HasPushoutsAlong f] { subst h simp [pushoutCongr] +/-- `MorphismProperty.Under.pushout` commutes with `MorphismProperty.Under.forget`. -/ +@[simps!] +noncomputable +def Under.pushoutCompForgetIso {X Y : T} (f : X ⟶ Y) [HasPushoutsAlong f] + [P.IsStableUnderCobaseChangeAlong f] [Q.IsStableUnderCobaseChange] : + Under.pushout P Q f ⋙ Under.forget _ _ _ ≅ + Under.forget _ _ _ ⋙ CategoryTheory.Under.pushout f := + Iso.refl _ + end Pushout section Adjunction diff --git a/Mathlib/CategoryTheory/MorphismProperty/TransfiniteComposition.lean b/Mathlib/CategoryTheory/MorphismProperty/TransfiniteComposition.lean index 72d8094b66b1d2..4fa14df20f1198 100644 --- a/Mathlib/CategoryTheory/MorphismProperty/TransfiniteComposition.lean +++ b/Mathlib/CategoryTheory/MorphismProperty/TransfiniteComposition.lean @@ -90,7 +90,7 @@ def ofOrderIso {J' : Type w'} [LinearOrder J'] [OrderBot J'] Arrow.mk (homOfLE (Order.le_succ (e j))) := Arrow.ext rfl (e.map_succ j) rfl replace eq := congr_arg h.F.mapArrow.obj eq - convert this using 1 + convert! this using 1 /-- If `f` is a transfinite composition of shape `J` of morphisms in `W.inverseImage F`, then `F` is a transfinite composition of shape `J` @@ -119,7 +119,7 @@ noncomputable def iic (j : J) : Arrow.mk (homOfLE (Order.le_succ i.1)) := Arrow.ext rfl (Set.Iic.coe_succ_of_not_isMax hi) rfl replace eq := congr_arg h.F.mapArrow.obj eq - convert this using 1 + convert! this using 1 /-- A transfinite composition of shape `J` of morphisms in `W` induces a transfinite composition of shape `Set.Ici j` (for any `j : J`). -/ @@ -133,7 +133,7 @@ noncomputable def ici (j : J) : Arrow.mk (homOfLE (Order.le_succ i.1)) := Arrow.ext rfl (coe_succ_of_mem (i.2.trans (Order.le_succ _))) rfl replace eq := congr_arg h.F.mapArrow.obj eq - convert this using 1 + convert! this using 1 end @@ -153,7 +153,7 @@ def ofComposableArrows {n : ℕ} (F : ComposableArrows C n) Arrow.mk (homOfLE j.castSucc_le_succ) := Arrow.ext rfl j.orderSucc_castSucc rfl replace eq := congr_arg F.mapArrow.obj eq - convert hF using 1 + convert! hF using 1 · rw [isMax_iff_eq_top] at hj exact (hj rfl).elim diff --git a/Mathlib/CategoryTheory/ObjectProperty/ColimitsOfShape.lean b/Mathlib/CategoryTheory/ObjectProperty/ColimitsOfShape.lean index 4dc38c510f5763..8a139de771dbf2 100644 --- a/Mathlib/CategoryTheory/ObjectProperty/ColimitsOfShape.lean +++ b/Mathlib/CategoryTheory/ObjectProperty/ColimitsOfShape.lean @@ -263,8 +263,9 @@ lemma isClosedUnderColimitsOfShape_inverseImage_iff (P : ObjectProperty D) (P.inverseImage e.functor).IsClosedUnderColimitsOfShape J ↔ P.IsClosedUnderColimitsOfShape J := by refine ⟨fun H ↦ ?_, fun _ ↦ inferInstance⟩ - convert (inferInstance : - ((P.inverseImage e.functor).inverseImage e.inverse).IsClosedUnderColimitsOfShape J) + convert! + (inferInstance : + ((P.inverseImage e.functor).inverseImage e.inverse).IsClosedUnderColimitsOfShape J) ext X simpa using P.prop_iff_of_iso (e.counitIso.app X).symm diff --git a/Mathlib/CategoryTheory/ObjectProperty/LimitsOfShape.lean b/Mathlib/CategoryTheory/ObjectProperty/LimitsOfShape.lean index c021be2476b31e..cdcf7de9067f26 100644 --- a/Mathlib/CategoryTheory/ObjectProperty/LimitsOfShape.lean +++ b/Mathlib/CategoryTheory/ObjectProperty/LimitsOfShape.lean @@ -264,8 +264,9 @@ lemma isClosedUnderLimitsOfShape_inverseImage_iff (P : ObjectProperty D) [P.IsClosedUnderIsomorphisms] (e : C ≌ D) : (P.inverseImage e.functor).IsClosedUnderLimitsOfShape J ↔ P.IsClosedUnderLimitsOfShape J := by refine ⟨fun H ↦ ?_, fun _ ↦ inferInstance⟩ - convert (inferInstance : - ((P.inverseImage e.functor).inverseImage e.inverse).IsClosedUnderLimitsOfShape J) + convert! + (inferInstance : + ((P.inverseImage e.functor).inverseImage e.inverse).IsClosedUnderLimitsOfShape J) ext X simpa using P.prop_iff_of_iso (e.counitIso.app X).symm diff --git a/Mathlib/CategoryTheory/ObjectProperty/Local.lean b/Mathlib/CategoryTheory/ObjectProperty/Local.lean index 183ec366220069..34c82050ac45eb 100644 --- a/Mathlib/CategoryTheory/ObjectProperty/Local.lean +++ b/Mathlib/CategoryTheory/ObjectProperty/Local.lean @@ -67,13 +67,13 @@ lemma isColocal_iff (X : C) : instance : W.isLocal.IsClosedUnderIsomorphisms where of_iso {Z Z'} e hZ X Y f hf := by rw [← Function.Bijective.of_comp_iff _ (Iso.homToEquiv e).bijective] - convert (Iso.homToEquiv e).bijective.comp (hZ f hf) using 1 + convert! (Iso.homToEquiv e).bijective.comp (hZ f hf) using 1 aesop instance : W.isColocal.IsClosedUnderIsomorphisms where of_iso {X X'} e hX Y Z g hg := by rw [← Function.Bijective.of_comp_iff _ (Iso.homFromEquiv e).bijective] - convert (Iso.homFromEquiv e).bijective.comp (hX g hg) using 1 + convert! (Iso.homFromEquiv e).bijective.comp (hX g hg) using 1 aesop set_option backward.isDefEq.respectTransparency false in diff --git a/Mathlib/CategoryTheory/PUnit.lean b/Mathlib/CategoryTheory/PUnit.lean index fdbd8e6e56b429..5f91f44fc34588 100644 --- a/Mathlib/CategoryTheory/PUnit.lean +++ b/Mathlib/CategoryTheory/PUnit.lean @@ -69,8 +69,8 @@ theorem equiv_punit_iff_unique : · rintro ⟨h⟩ refine ⟨⟨h.inverse.obj ⟨⟨⟩⟩⟩, fun x y => Nonempty.intro ?_⟩ let f : x ⟶ y := by - have hx : x ⟶ h.inverse.obj ⟨⟨⟩⟩ := by convert h.unit.app x - have hy : h.inverse.obj ⟨⟨⟩⟩ ⟶ y := by convert h.unitInv.app y + have hx : x ⟶ h.inverse.obj ⟨⟨⟩⟩ := by convert! h.unit.app x + have hy : h.inverse.obj ⟨⟨⟩⟩ ⟶ y := by convert! h.unitInv.app y exact hx ≫ hy suffices sub : Subsingleton (x ⟶ y) from uniqueOfSubsingleton f have : ∀ z, z = h.unit.app x ≫ (h.functor ⋙ h.inverse).map z ≫ h.unitInv.app y := by diff --git a/Mathlib/CategoryTheory/PathCategory/Basic.lean b/Mathlib/CategoryTheory/PathCategory/Basic.lean index 9549706993a4e5..cd04540ca251d6 100644 --- a/Mathlib/CategoryTheory/PathCategory/Basic.lean +++ b/Mathlib/CategoryTheory/PathCategory/Basic.lean @@ -164,7 +164,7 @@ theorem lift_unique {C} [Category* C] (φ : V ⥤q C) (Φ : Paths V ⥤ C) -- Porting note: Had to do substitute `p.cons f'` and `f'.toPath` by their fully qualified -- versions in this `have` clause (elsewhere too). have : Φ.map (Quiver.Path.cons p f') = Φ.map p ≫ Φ.map (Quiver.Hom.toPath f') := by - convert Functor.map_comp Φ p (Quiver.Hom.toPath f') + convert! Functor.map_comp Φ p (Quiver.Hom.toPath f') rw [this, ih] /-- Two functors out of a path category are equal when they agree on singleton paths. -/ diff --git a/Mathlib/CategoryTheory/Pi/Basic.lean b/Mathlib/CategoryTheory/Pi/Basic.lean index e606d46769205b..77c561baf3be22 100644 --- a/Mathlib/CategoryTheory/Pi/Basic.lean +++ b/Mathlib/CategoryTheory/Pi/Basic.lean @@ -102,6 +102,7 @@ def comapComp (f : K → J) (g : J → I) : comap C g ⋙ comap (C ∘ g) f ≅ { app := fun X b => 𝟙 (X (g (f b))) naturality := fun X Y f' => by simp only [comap, Function.comp]; funext; simp } +set_option backward.isDefEq.respectTransparency false in /-- The natural isomorphism between pulling back then evaluating, and just evaluating. -/ @[simps!] def comapEvalIsoEval (h : J → I) (j : J) : comap C h ⋙ eval (C ∘ h) j ≅ eval C (h j) := @@ -117,6 +118,7 @@ instance sumElimCategory : ∀ s : I ⊕ J, Category.{v₁} (Sum.elim C D s) | Sum.inl i => inferInstanceAs <| Category (C i) | Sum.inr j => inferInstanceAs <| Category (D j) +set_option backward.isDefEq.respectTransparency false in /-- The bifunctor combining an `I`-indexed family of objects with a `J`-indexed family of objects to obtain an `I ⊕ J`-indexed family of objects. -/ diff --git a/Mathlib/CategoryTheory/Preadditive/Biproducts.lean b/Mathlib/CategoryTheory/Preadditive/Biproducts.lean index 523285ff76c393..f4a9bf4669d344 100644 --- a/Mathlib/CategoryTheory/Preadditive/Biproducts.lean +++ b/Mathlib/CategoryTheory/Preadditive/Biproducts.lean @@ -347,15 +347,15 @@ def BinaryBicone.ofLimitCone {X Y : C} {t : Cone (pair X Y)} (ht : IsLimit t) : pt := t.pt fst := t.π.app ⟨WalkingPair.left⟩ snd := t.π.app ⟨WalkingPair.right⟩ - inl := ht.lift (BinaryFan.mk (𝟙 X) 0) - inr := ht.lift (BinaryFan.mk 0 (𝟙 Y)) + inl := BinaryFan.IsLimit.lift ht (𝟙 X) 0 + inr := BinaryFan.IsLimit.lift ht 0 (𝟙 Y) theorem inl_of_isLimit {X Y : C} {t : BinaryBicone X Y} (ht : IsLimit t.toCone) : - t.inl = ht.lift (BinaryFan.mk (𝟙 X) 0) := by + t.inl = BinaryFan.IsLimit.lift ht (𝟙 X) 0 := by apply ht.uniq (BinaryFan.mk (𝟙 X) 0); rintro ⟨⟨⟩⟩ <;> simp theorem inr_of_isLimit {X Y : C} {t : BinaryBicone X Y} (ht : IsLimit t.toCone) : - t.inr = ht.lift (BinaryFan.mk 0 (𝟙 Y)) := by + t.inr = BinaryFan.IsLimit.lift ht 0 (𝟙 Y) := by apply ht.uniq (BinaryFan.mk 0 (𝟙 Y)); rintro ⟨⟨⟩⟩ <;> simp /-- In a preadditive category, any binary bicone which is a limit cone is in fact a bilimit @@ -388,18 +388,18 @@ set_option backward.isDefEq.respectTransparency false in def BinaryBicone.ofColimitCocone {X Y : C} {t : Cocone (pair X Y)} (ht : IsColimit t) : BinaryBicone X Y where pt := t.pt - fst := ht.desc (BinaryCofan.mk (𝟙 X) 0) - snd := ht.desc (BinaryCofan.mk 0 (𝟙 Y)) + fst := BinaryCofan.IsColimit.desc ht (𝟙 X) 0 + snd := BinaryCofan.IsColimit.desc ht 0 (𝟙 Y) inl := t.ι.app ⟨WalkingPair.left⟩ inr := t.ι.app ⟨WalkingPair.right⟩ theorem fst_of_isColimit {X Y : C} {t : BinaryBicone X Y} (ht : IsColimit t.toCocone) : - t.fst = ht.desc (BinaryCofan.mk (𝟙 X) 0) := by + t.fst = BinaryCofan.IsColimit.desc ht (𝟙 X) 0 := by apply ht.uniq (BinaryCofan.mk (𝟙 X) 0) rintro ⟨⟨⟩⟩ <;> simp theorem snd_of_isColimit {X Y : C} {t : BinaryBicone X Y} (ht : IsColimit t.toCocone) : - t.snd = ht.desc (BinaryCofan.mk 0 (𝟙 Y)) := by + t.snd = BinaryCofan.IsColimit.desc ht 0 (𝟙 Y) := by apply ht.uniq (BinaryCofan.mk 0 (𝟙 Y)) rintro ⟨⟨⟩⟩ <;> simp @@ -659,9 +659,9 @@ instance subsingleton_preadditive_of_hasBinaryBiproducts {C : Type u} [Category. allEq := fun a b => by apply Preadditive.ext; funext X Y; apply AddCommGroup.ext; funext f g have h₁ := @biprod.add_eq_lift_id_desc _ _ a _ _ f g - (by convert (inferInstance : HasBinaryBiproduct X X); subsingleton) + (by convert! (inferInstance : HasBinaryBiproduct X X); subsingleton) have h₂ := @biprod.add_eq_lift_id_desc _ _ b _ _ f g - (by convert (inferInstance : HasBinaryBiproduct X X); subsingleton) + (by convert! (inferInstance : HasBinaryBiproduct X X); subsingleton) refine h₁.trans (Eq.trans ?_ h₂.symm) congr! 2 <;> subsingleton @@ -910,7 +910,7 @@ lemma preservesBiproduct_of_mono_biproductComparison {f : J → C} [HasBiproduct (F.mapIso (biproduct.isoProduct f)).inv ≫ biproductComparison F f ≫ (biproduct.isoProduct _).hom := by ext j - convert piComparison_comp_π F f j; simp [← Function.comp_def, ← Functor.map_comp] + convert! piComparison_comp_π F f j; simp [← Function.comp_def, ← Functor.map_comp] haveI : IsIso (biproductComparison F f) := isIso_of_mono_of_isSplitEpi _ haveI : IsIso (piComparison F f) := by rw [that] diff --git a/Mathlib/CategoryTheory/Preadditive/CommGrp_.lean b/Mathlib/CategoryTheory/Preadditive/CommGrp_.lean index 684b5656c52595..addf37572e4426 100644 --- a/Mathlib/CategoryTheory/Preadditive/CommGrp_.lean +++ b/Mathlib/CategoryTheory/Preadditive/CommGrp_.lean @@ -72,11 +72,11 @@ def commGrpEquivalenceAux : CommGrp.forget C ⋙ toCommGrp C ≅ mul_def, Iso.refl_hom, Category.comp_id, tensorHom_id, id_whiskerRight, Category.id_comp] apply monoidal_hom_ext · simp only [comp_add, lift_fst, lift_snd, add_zero] - convert (MonObj.lift_comp_one_right _ 0).symm + convert! (MonObj.lift_comp_one_right _ 0).symm · simp · infer_instance · simp only [comp_add, lift_fst, lift_snd, zero_add] - convert (MonObj.lift_comp_one_left 0 _).symm + convert! (MonObj.lift_comp_one_left 0 _).symm · simp · infer_instance · cat_disch diff --git a/Mathlib/CategoryTheory/Preadditive/HomOrthogonal.lean b/Mathlib/CategoryTheory/Preadditive/HomOrthogonal.lean index 1945741177ac21..71000d24f21c88 100644 --- a/Mathlib/CategoryTheory/Preadditive/HomOrthogonal.lean +++ b/Mathlib/CategoryTheory/Preadditive/HomOrthogonal.lean @@ -138,7 +138,7 @@ theorem matrixDecomposition_id (o : HomOrthogonal s) {α : Type} [Finite α] {f · cases h simp · simp only [Subtype.mk.injEq] at h - convert comp_zero + convert! comp_zero simpa using biproduct.ι_π_ne _ (Ne.symm h) set_option backward.isDefEq.respectTransparency false in @@ -159,10 +159,10 @@ theorem matrixDecomposition_comp (o : HomOrthogonal s) {α β γ : Type} [Finite · intro b nm simp only [Set.mem_preimage, Set.mem_singleton_iff] at nm simp only [Category.assoc] - convert comp_zero - convert comp_zero - convert comp_zero - convert comp_zero + convert! comp_zero + convert! comp_zero + convert! comp_zero + convert! comp_zero simp only [o.eq_zero nm] section diff --git a/Mathlib/CategoryTheory/Preadditive/Mat.lean b/Mathlib/CategoryTheory/Preadditive/Mat.lean index e4c1a473beddfa..1b98566b5d70f3 100644 --- a/Mathlib/CategoryTheory/Preadditive/Mat.lean +++ b/Mathlib/CategoryTheory/Preadditive/Mat.lean @@ -574,7 +574,7 @@ def equivalenceSingleObjInverse : Mat_ (SingleObj Rᵐᵒᵖ) ⥤ Mat R where -- Porting note: this proof was automatic in mathlib3 ext simp only [Mat_.comp_apply, comp_apply] - convert Finset.unop_sum _ _ + convert! Finset.unop_sum _ _ instance : (equivalenceSingleObjInverse R).Faithful where map_injective w := by diff --git a/Mathlib/CategoryTheory/Preadditive/Projective/Resolution.lean b/Mathlib/CategoryTheory/Preadditive/Projective/Resolution.lean index db340ddf0e3f82..16cb1774c87a96 100644 --- a/Mathlib/CategoryTheory/Preadditive/Projective/Resolution.lean +++ b/Mathlib/CategoryTheory/Preadditive/Projective/Resolution.lean @@ -137,7 +137,7 @@ noncomputable def self [Projective Z] : ProjectiveResolution Z where variable {Z} {Z' : C} (P' : ProjectiveResolution Z') -/-- Given injective resolutions `P` and `P'` of two objects `Z` and `Z'`, +/-- Given projective resolutions `P` and `P'` of two objects `Z` and `Z'`, and a morphism `f : Z ⟶ Z'`, this structure contains the data of a morphism `P.complex ⟶ P'.complex` which is compatible with `f` -/ structure Hom (f : Z ⟶ Z') where diff --git a/Mathlib/CategoryTheory/Quotient.lean b/Mathlib/CategoryTheory/Quotient.lean index 4ce992e4714346..4c91ae7339a494 100644 --- a/Mathlib/CategoryTheory/Quotient.lean +++ b/Mathlib/CategoryTheory/Quotient.lean @@ -237,7 +237,7 @@ theorem functor_homRel_eq_compClosure_eqvGen {X Y : C} (f g : X ⟶ Y) : theorem compClosure.congruence : Congruence fun X Y => Relation.EqvGen (@HomRel.CompClosure C _ r X Y) := by - convert (inferInstance : Congruence (functor r).homRel) + convert! (inferInstance : Congruence (functor r).homRel) ext rw [functor_homRel_eq_compClosure_eqvGen] diff --git a/Mathlib/CategoryTheory/Quotient/Preadditive.lean b/Mathlib/CategoryTheory/Quotient/Preadditive.lean index 647f39174bec0b..633b61c185ff24 100644 --- a/Mathlib/CategoryTheory/Quotient/Preadditive.lean +++ b/Mathlib/CategoryTheory/Quotient/Preadditive.lean @@ -51,7 +51,7 @@ def neg (hr : ∀ ⦃X Y : C⦄ (f₁ f₂ g₁ g₂ : X ⟶ Y) (_ : r f₁ f₂ simp only [HomRel.compClosure_iff_self] at hfg erw [functor_map_eq_iff] apply Congruence.equivalence.symm - convert hr f g _ _ hfg (Congruence.equivalence.refl (-f - g)) using 1 <;> abel) + convert! hr f g _ _ hfg (Congruence.equivalence.refl (-f - g)) using 1 <;> abel) end Preadditive diff --git a/Mathlib/CategoryTheory/RegularCategory/Basic.lean b/Mathlib/CategoryTheory/RegularCategory/Basic.lean index 62dc398e6be95e..d04cadd1890d83 100644 --- a/Mathlib/CategoryTheory/RegularCategory/Basic.lean +++ b/Mathlib/CategoryTheory/RegularCategory/Basic.lean @@ -129,7 +129,7 @@ instance : Mono (coequalizer.desc f pullback.condition) := by infer_instance -- We precompose with the epimorphism `g₁ ≫ pullback.snd e k₁`, and finish rw [← cancel_epi (g₁ ≫ pullback.snd e k₁)] - convert coequalizer.condition (pullback.fst f f) (pullback.snd f f) using 1 + convert! coequalizer.condition (pullback.fst f f) (pullback.snd f f) using 1 all_goals cat_disch set_option backward.isDefEq.respectTransparency false in diff --git a/Mathlib/CategoryTheory/RepresentedBy.lean b/Mathlib/CategoryTheory/RepresentedBy.lean index a7fc2eb6eac264..45e33521e77078 100644 --- a/Mathlib/CategoryTheory/RepresentedBy.lean +++ b/Mathlib/CategoryTheory/RepresentedBy.lean @@ -87,8 +87,9 @@ set_option backward.isDefEq.respectTransparency false in lemma RepresentableBy.isRepresentedBy (R : F.RepresentableBy X) : F.IsRepresentedBy (R.homEquiv (𝟙 X)) := by rw [IsRepresentedBy.iff_isIso_uliftYonedaEquiv] - convert (RepresentableBy.equivUliftYonedaIso _ _ <| - representableByUliftFunctorEquiv.{v}.symm R).isIso_hom + convert! + (RepresentableBy.equivUliftYonedaIso _ _ <| + representableByUliftFunctorEquiv.{v}.symm R).isIso_hom ext simpa [uliftYonedaEquiv] using (homEquiv_eq _ _).symm diff --git a/Mathlib/CategoryTheory/Shift/Adjunction.lean b/Mathlib/CategoryTheory/Shift/Adjunction.lean index 871f7c43efbc7f..1a8fb24c9cef7d 100644 --- a/Mathlib/CategoryTheory/Shift/Adjunction.lean +++ b/Mathlib/CategoryTheory/Shift/Adjunction.lean @@ -610,6 +610,7 @@ this constructs the unique compatible `CommShift` structure on `E.functor`. noncomputable def commShiftFunctor [E.inverse.CommShift A] : E.functor.CommShift A := E.symm.toAdjunction.rightAdjointCommShift A +set_option backward.isDefEq.respectTransparency false in lemma commShift_of_inverse [E.inverse.CommShift A] : letI := E.commShiftFunctor A E.CommShift A := by diff --git a/Mathlib/CategoryTheory/Shift/Basic.lean b/Mathlib/CategoryTheory/Shift/Basic.lean index 036efdbd74959b..4a3491159808c3 100644 --- a/Mathlib/CategoryTheory/Shift/Basic.lean +++ b/Mathlib/CategoryTheory/Shift/Basic.lean @@ -406,9 +406,11 @@ def shiftEquiv' (i j : A) (h : i + j = 0) : C ≌ C where counitIso := shiftFunctorCompIsoId C j i (by rw [← add_left_inj j, add_assoc, h, zero_add, add_zero]) functor_unitIso_comp X := by - convert (equivOfTensorIsoUnit (shiftMonoidalFunctor C A) ⟨i⟩ ⟨j⟩ (Discrete.eqToIso h) - (Discrete.eqToIso (by dsimp; rw [← add_left_inj j, add_assoc, h, zero_add, add_zero])) - (Subsingleton.elim _ _)).functor_unitIso_comp X + convert! + (equivOfTensorIsoUnit (shiftMonoidalFunctor C A) ⟨i⟩ ⟨j⟩ (Discrete.eqToIso h) + (Discrete.eqToIso (by dsimp; rw [← add_left_inj j, add_assoc, h, zero_add, add_zero])) + (Subsingleton.elim _ _)).functor_unitIso_comp + X all_goals ext X dsimp [shiftFunctorCompIsoId, unitOfTensorIsoUnit, diff --git a/Mathlib/CategoryTheory/Shift/Twist.lean b/Mathlib/CategoryTheory/Shift/Twist.lean index b76fea481b7617..e8a8b8707e01fb 100644 --- a/Mathlib/CategoryTheory/Shift/Twist.lean +++ b/Mathlib/CategoryTheory/Shift/Twist.lean @@ -92,6 +92,7 @@ identify to the shift functors on `C`. -/ noncomputable def shiftIso (m : A) : shiftFunctor t.Category m ≅ shiftFunctor C m := Iso.refl _ +set_option backward.isDefEq.respectTransparency false in lemma shiftFunctor_map {X Y : t.Category} (f : X ⟶ Y) (m : A) : (shiftFunctor t.Category m).map f = (t.shiftIso m).hom.app X ≫ (shiftFunctor C m).map f ≫ (t.shiftIso m).inv.app Y := by diff --git a/Mathlib/CategoryTheory/Sites/Adjunction.lean b/Mathlib/CategoryTheory/Sites/Adjunction.lean index abf7576039eb08..1cdfa9976d920a 100644 --- a/Mathlib/CategoryTheory/Sites/Adjunction.lean +++ b/Mathlib/CategoryTheory/Sites/Adjunction.lean @@ -90,8 +90,9 @@ lemma preservesSheafification_of_adjunction (adj : G ⊣ F) : dsimp intro R hR rw [← ((adj.whiskerRight Cᵒᵖ).homEquiv P R).comp_bijective] - convert (((adj.whiskerRight Cᵒᵖ).homEquiv Q R).trans - (hf.homEquiv (R ⋙ F) ((sheafCompose J F).obj ⟨R, hR⟩).property)).bijective + convert! + (((adj.whiskerRight Cᵒᵖ).homEquiv Q R).trans + (hf.homEquiv (R ⋙ F) ((sheafCompose J F).obj ⟨R, hR⟩).property)).bijective ext g X -- The rest of this proof was -- `dsimp [Adjunction.whiskerRight, Adjunction.mkOfUnitCounit]; simp` before https://github.com/leanprover-community/mathlib4/pull/16317. diff --git a/Mathlib/CategoryTheory/Sites/Coherent/CoherentSheaves.lean b/Mathlib/CategoryTheory/Sites/Coherent/CoherentSheaves.lean index 6469f299f6fe24..d277c096031618 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/CoherentSheaves.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/CoherentSheaves.lean @@ -57,7 +57,8 @@ theorem isSheaf_yoneda_obj (W : C) : Presieve.IsSheaf (coherentTopology C) (yone obtain ⟨t, t_amalg, t_uniq⟩ : ∃! t, x_ext.IsAmalgamation t := (Sieve.forallYonedaIsSheaf_iff_colimit S).mpr ⟨h_colim⟩ W x_ext hx_ext refine ⟨t, ?_, ?_⟩ - · convert Presieve.isAmalgamation_restrict (Sieve.le_generate (Presieve.ofArrows Y π)) _ _ t_amalg + · convert! + Presieve.isAmalgamation_restrict (Sieve.le_generate (Presieve.ofArrows Y π)) _ _ t_amalg exact (Presieve.restrict_extend hx).symm · exact fun y hy ↦ t_uniq y <| Presieve.isAmalgamation_sieveExtend x y hy diff --git a/Mathlib/CategoryTheory/Sites/Coherent/Comparison.lean b/Mathlib/CategoryTheory/Sites/Coherent/Comparison.lean index f31e4ef6792f4e..b09b1098ea1c02 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/Comparison.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/Comparison.lean @@ -95,7 +95,7 @@ theorem extensive_regular_generate_coherent [Preregular C] [FinitaryPreExtensive apply Coverage.saturate_of_superset _ this apply Coverage.Saturate.of refine Or.inl ⟨I, inferInstance, _, _, ⟨rfl, ?_⟩⟩ - convert IsIso.id _ + convert! IsIso.id _ aesop | top => apply Coverage.Saturate.top | transitive Y T => apply Coverage.Saturate.transitive Y T <;> [assumption; assumption] diff --git a/Mathlib/CategoryTheory/Sites/Coherent/LocallySurjective.lean b/Mathlib/CategoryTheory/Sites/Coherent/LocallySurjective.lean index 70e7d37f41602c..775708dad935c7 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/LocallySurjective.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/LocallySurjective.lean @@ -126,7 +126,7 @@ lemma regularTopology.isLocallySurjective_sheaf_of_types [Preregular C] [Finitar NatTrans.op_app, Cofan.mk_ι_app, Functor.mapIso_symm, Iso.trans_hom, Iso.symm_hom, Functor.mapIso_inv, comp_apply, ← f.naturality_apply (Sigma.ι Z a).op, i'] have : f.app ⟨Z a⟩ (x a) = G.map (π a).op y := (h' a).choose_spec - convert this + convert! this · rw [← Functor.map_comp_apply, opCoproductIsoProduct_inv_comp_ι, ← piComparison_comp_π] change ((PreservesProduct.iso F _).hom ≫ _) _ = _ have := Types.productIso_hom_comp_eval (fun a ↦ F.obj (op (Z a))) a diff --git a/Mathlib/CategoryTheory/Sites/Coherent/RegularSheaves.lean b/Mathlib/CategoryTheory/Sites/Coherent/RegularSheaves.lean index 46eb44cd86094a..9eefb4036d6d12 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/RegularSheaves.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/RegularSheaves.lean @@ -288,8 +288,9 @@ lemma isSheaf_yoneda_obj [Preregular C] (W : C) : obtain ⟨t, t_amalg, t_uniq⟩ := (Sieve.forallYonedaIsSheaf_iff_colimit S).mpr ⟨h_colim⟩ W x_ext hx_ext refine ⟨t, ?_, ?_⟩ - · convert Presieve.isAmalgamation_restrict (Sieve.le_generate - (Presieve.ofArrows (fun () ↦ Y) (fun () ↦ f))) _ _ t_amalg + · convert! + Presieve.isAmalgamation_restrict + (Sieve.le_generate (Presieve.ofArrows (fun () ↦ Y) (fun () ↦ f))) _ _ t_amalg exact (Presieve.restrict_extend hx).symm · exact fun y hy ↦ t_uniq y <| Presieve.isAmalgamation_sieveExtend x y hy diff --git a/Mathlib/CategoryTheory/Sites/Coherent/SheafComparison.lean b/Mathlib/CategoryTheory/Sites/Coherent/SheafComparison.lean index c40711182c9df2..a50fd96a21b479 100644 --- a/Mathlib/CategoryTheory/Sites/Coherent/SheafComparison.lean +++ b/Mathlib/CategoryTheory/Sites/Coherent/SheafComparison.lean @@ -79,7 +79,7 @@ theorem exists_effectiveEpiFamily_iff_mem_induced (X : C) (S : Sieve X) : simpa using this · obtain ⟨W, g₁, g₂, h₁, h₂⟩ := H₂ a rw [h₂] - convert S.downward_closed h₁ (F.preimage (g₀ a ≫ g₂)) + convert! S.downward_closed h₁ (F.preimage (g₀ a ≫ g₂)) exact F.map_injective (by simp) lemma eq_induced : haveI := F.reflects_precoherent @@ -179,7 +179,7 @@ theorem exists_effectiveEpi_iff_mem_induced (X : C) (S : Sieve X) : infer_instance · obtain ⟨W, g₁, g₂, h₁, h₂⟩ := H₂ rw [h₂] - convert S.downward_closed h₁ (F.preimage (g₀ ≫ g₂)) + convert! S.downward_closed h₁ (F.preimage (g₀ ≫ g₂)) exact F.map_injective (by simp) lemma eq_induced : haveI := F.reflects_preregular diff --git a/Mathlib/CategoryTheory/Sites/ConcreteSheafification.lean b/Mathlib/CategoryTheory/Sites/ConcreteSheafification.lean index cd68d28468c49d..dfa6d6b49424c5 100644 --- a/Mathlib/CategoryTheory/Sites/ConcreteSheafification.lean +++ b/Mathlib/CategoryTheory/Sites/ConcreteSheafification.lean @@ -218,7 +218,7 @@ theorem eq_mk_iff_exists {X : C} {P : Cᵒᵖ ⥤ D} {S T : J.Cover X} (x : Meq use W.unop, h1.unop, h2.unop ext I apply_fun Multiequalizer.ι (W.unop.index P) I at hh - convert hh + convert! hh all_goals dsimp [diagram] rw [← ConcreteCategory.comp_apply, Multiequalizer.lift_ι] @@ -230,7 +230,7 @@ theorem eq_mk_iff_exists {X : C} {P : Cᵒᵖ ⥤ D} {S T : J.Cover X} (x : Meq apply Concrete.multiequalizer_ext intro i apply_fun fun ee => ee i at e - convert e using 1 + convert! e using 1 all_goals dsimp [diagram] rw [← ConcreteCategory.comp_apply, Multiequalizer.lift_ι] @@ -279,7 +279,7 @@ theorem sep {X : C} (P : Cᵒᵖ ⥤ D) (S : J.Cover X) (x y : ToType ((J.plusOb specialize hh IS let IW : (W IS).Arrow := I.toMiddle apply_fun fun e => e IW at hh - convert hh using 1 + convert! hh using 1 · exact x.congr_apply I.middle_spec.symm _ · exact y.congr_apply I.middle_spec.symm _ diff --git a/Mathlib/CategoryTheory/Sites/Continuous.lean b/Mathlib/CategoryTheory/Sites/Continuous.lean index 6f5673e8b0fcb0..3600aca281ebf1 100644 --- a/Mathlib/CategoryTheory/Sites/Continuous.lean +++ b/Mathlib/CategoryTheory/Sites/Continuous.lean @@ -85,6 +85,58 @@ then `(E.map F).multifork P` is a limit iff `E.multifork (F.op ⋙ P)` is a limi def isLimitMapMultiforkEquiv {A : Type u} [Category.{t} A] (P : Dᵒᵖ ⥤ A) : IsLimit ((E.map F).multifork P) ≃ IsLimit (E.multifork (F.op ⋙ P)) := by rfl +section + +variable {E} {W : C} {i₁ i₂ : E.I₀} (p₁ : W ⟶ E.X i₁) (p₂ : W ⟶ E.X i₂) + +lemma functorPushforward_sieve₁_map_le : + Sieve.functorPushforward F (E.sieve₁ p₁ p₂) ≤ (E.map F).sieve₁ (F.map p₁) (F.map p₂) := by + rw [Sieve.functorPushforward_le_iff_le_functorPullback] + intro Y f ⟨k, u, hf₁, hf₂⟩ + exact ⟨k, F.map u, by simp [← Functor.map_comp, hf₁], by simp [← Functor.map_comp, hf₂]⟩ + +variable (i₁ i₂) in +set_option backward.isDefEq.respectTransparency false in +lemma functorPushforward_sieve₁'_of_preservesLimit [HasPullback (E.f i₁) (E.f i₂)] + [PreservesLimit (cospan (E.f i₁) (E.f i₂)) F] : + Sieve.functorPushforward F (E.sieve₁' i₁ i₂) = + (E.map F).sieve₁ (F.map <| pullback.fst _ _) (F.map <| pullback.snd _ _) := by + have : HasPullback ((E.map F).f i₁) ((E.map F).f i₂) := + hasPullback_of_preservesPullback F (E.f i₁) (E.f i₂) + refine le_antisymm ?_ ?_ + · rw [PreOneHypercover.sieve₁'_eq_sieve₁] + apply PreOneHypercover.functorPushforward_sieve₁_map_le + · rw [PreOneHypercover.sieve₁_eq_pullback_sieve₁' _ _ _ + (by simp [← Functor.map_comp, pullback.condition])] + rintro W f ⟨Z, u, v, ⟨k⟩, h⟩ + refine ⟨E.Y k, pullback.lift (E.p₁ k) (E.p₂ k) (E.w _), u, ?_, ?_⟩ + · use E.Y k, 𝟙 _, pullback.lift (E.p₁ k) (E.p₂ k) (E.w _), ⟨k⟩ + simp + · simp only [pullback.hom_ext_iff, Category.assoc, limit.lift_π, PullbackCone.mk_π_app] at h + apply IsPullback.hom_ext (IsPullback.map _ (.of_hasPullback _ _)) <;> + simp [← h.left, ← h.right, ← Functor.map_comp] + +set_option backward.isDefEq.respectTransparency false in +lemma functorPushforward_sieve₁_of_preservesPullbacks (h : p₁ ≫ E.f _ = p₂ ≫ E.f _) + [HasPullbacks C] [PreservesLimitsOfShape WalkingCospan F] : + Sieve.functorPushforward F (E.sieve₁ p₁ p₂) = (E.map F).sieve₁ (F.map p₁) (F.map p₂) := by + refine le_antisymm (PreOneHypercover.functorPushforward_sieve₁_map_le _ _ _) ?_ + have : HasPullback ((E.map F).f i₁) ((E.map F).f i₂) := + hasPullback_of_preservesPullback F (E.f i₁) (E.f i₂) + rintro T f ⟨k, u, hf₁, hf₂⟩ + let l : W ⟶ pullback (E.f i₁) (E.f i₂) := pullback.lift p₁ p₂ h + have hl₁ : l ≫ pullback.fst _ _ = p₁ := by simp [l] + have hl₂ : l ≫ pullback.snd _ _ = p₂ := by simp [l] + let r : E.Y k ⟶ pullback (E.f i₁) (E.f i₂) := pullback.lift (E.p₁ _) (E.p₂ _) (E.w _) + refine ⟨pullback l r, pullback.fst _ _, IsPullback.lift + (IsPullback.map _ (.of_hasPullback _ _)) f u ?_, ?_, ?_⟩ + · apply (IsPullback.map _ (.of_hasPullback _ _)).hom_ext <;> + simp [l, r, ← Functor.map_comp, hf₁, hf₂] + · refine ⟨k, pullback.snd _ _, ?_, ?_⟩ <;> simp [← hl₁, ← hl₂, pullback.condition_assoc, r] + · simp + +end + end PreOneHypercover namespace GrothendieckTopology diff --git a/Mathlib/CategoryTheory/Sites/CoproductSheafCondition.lean b/Mathlib/CategoryTheory/Sites/CoproductSheafCondition.lean index 8db9f661cb7a0d..c14a8f86eb0419 100644 --- a/Mathlib/CategoryTheory/Sites/CoproductSheafCondition.lean +++ b/Mathlib/CategoryTheory/Sites/CoproductSheafCondition.lean @@ -96,7 +96,7 @@ lemma Presieve.isSheafFor_sigmaDesc_iff {ι : Type*} {X : ι → C} (f : ∀ i, have : PreservesLimit (Discrete.functor fun i ↦ op (E.toPreOneHypercover.X i)) F := by dsimp [E]; infer_instance have : PreservesLimit (Discrete.functor fun i ↦ op (E.toPreOneHypercover.Y' i)) F := by - convert Functor.Initial.preservesLimit_of_comp (Discrete.equivalence <| .sigmaPUnit _).inverse + convert! Functor.Initial.preservesLimit_of_comp (Discrete.equivalence <| .sigmaPUnit _).inverse assumption let equiv := (E.isLimitSigmaOfIsColimitEquiv hc hc' F).nonempty_congr rwa [isLimit_toPreOneHypercover_type_iff, isLimit_toPreOneHypercover_type_iff, diff --git a/Mathlib/CategoryTheory/Sites/CoverPreserving.lean b/Mathlib/CategoryTheory/Sites/CoverPreserving.lean index 336500fee3d0b4..a1e180847d803e 100644 --- a/Mathlib/CategoryTheory/Sites/CoverPreserving.lean +++ b/Mathlib/CategoryTheory/Sites/CoverPreserving.lean @@ -168,4 +168,21 @@ lemma Functor.isContinuous_of_coverPreserving (hF₁ : CompatiblePreserving.{max rintro Y _ ⟨Z, g, h, hg, rfl⟩ simpa using congrArg _ ((hy₁ g hg).trans (hy₂ g hg).symm) +/-- If `C` has pullbacks and `F : C ⥤ D` preserves pullbacks, any cover preserving +functor preserves all `1`-hypercovers. -/ +lemma Functor.PreservesOneHypercovers.of_coverPreserving [HasPullbacks C] + [PreservesLimitsOfShape WalkingCospan F] (H : CoverPreserving J K F) : + Functor.PreservesOneHypercovers.{w} F J K := by + refine fun {U} E ↦ ⟨?_, fun i₁ i₂ W p₁ p₂ h ↦ ?_⟩ + · simp [PreZeroHypercover.sieve₀_map, H.cover_preserve E.mem₀] + · let P : C := pullback (E.f i₁) (E.f i₂) + have : HasPullback ((E.toPreOneHypercover.map F).f i₁) ((E.toPreOneHypercover.map F).f i₂) := + hasPullback_of_preservesPullback F (E.f i₁) (E.f i₂) + have := H.cover_preserve (E.mem₁ i₁ i₂ (pullback.fst (E.f i₁) (E.f i₂)) _ pullback.condition) + rw [PreOneHypercover.functorPushforward_sieve₁_of_preservesPullbacks _ _ _ + pullback.condition] at this + refine K.superset_covering ?_ + (K.pullback_stable (IsPullback.lift (.map _ (.of_hasPullback _ _)) p₁ p₂ h) this) + simp [PreOneHypercover.pullback_sieve₁] + end CategoryTheory diff --git a/Mathlib/CategoryTheory/Sites/DenseSubsite/Basic.lean b/Mathlib/CategoryTheory/Sites/DenseSubsite/Basic.lean index bbfc6cb11351f8..4e0eb417033bc2 100644 --- a/Mathlib/CategoryTheory/Sites/DenseSubsite/Basic.lean +++ b/Mathlib/CategoryTheory/Sites/DenseSubsite/Basic.lean @@ -475,7 +475,7 @@ lemma restrictHomEquivHom_naturality_left -/ theorem iso_of_restrict_iso {ℱ ℱ' : Sheaf K A} (α : ℱ ⟶ ℱ') (i : IsIso (whiskerLeft G.op α.hom)) : IsIso α := by - convert (sheafIso (asIso (whiskerLeft G.op α.hom))).isIso_hom using 1 + convert! (sheafIso (asIso (whiskerLeft G.op α.hom))).isIso_hom using 1 ext1 apply (sheafHom_eq _ _).symm diff --git a/Mathlib/CategoryTheory/Sites/DenseSubsite/InducedTopology.lean b/Mathlib/CategoryTheory/Sites/DenseSubsite/InducedTopology.lean index ba3659ce528019..742cbf547d080b 100644 --- a/Mathlib/CategoryTheory/Sites/DenseSubsite/InducedTopology.lean +++ b/Mathlib/CategoryTheory/Sites/DenseSubsite/InducedTopology.lean @@ -126,7 +126,7 @@ variable (J) instance over_forget_locallyCoverDense (X : C) : (Over.forget X).LocallyCoverDense J where functorPushforward_functorPullback_mem Y T := by - convert T.property + convert! T.property ext Z f constructor · rintro ⟨_, _, g', hg, rfl⟩ diff --git a/Mathlib/CategoryTheory/Sites/Descent/DescentData.lean b/Mathlib/CategoryTheory/Sites/Descent/DescentData.lean index 97a6bc2d606588..e27ddb8f9a7e09 100644 --- a/Mathlib/CategoryTheory/Sites/Descent/DescentData.lean +++ b/Mathlib/CategoryTheory/Sites/Descent/DescentData.lean @@ -549,7 +549,7 @@ lemma bijective_toDescentData_map_iff (M N : F.obj (.mk (op S))) : rw [Presieve.isSheafFor_ofArrows_iff_bijective_toCompabible, ← (DescentData.subtypeCompatibleHomEquiv F f).bijective.of_comp_iff', ← Function.Bijective.of_comp_iff _ (presheafHomObjHomEquiv F).bijective] - convert Iff.rfl + convert! Iff.rfl ext φ : 1 apply DescentData.subtypeCompatibleHomEquiv_toCompatible_presheafHomObjHomEquiv @@ -560,7 +560,7 @@ lemma isPrestackFor_iff_isSheafFor {S : C} (R : Sieve S) : rw [isPrestackFor_iff, Functor.FullyFaithful.nonempty_iff_map_bijective] refine forall_congr' (fun M ↦ forall_congr' (fun N ↦ ?_)) rw [bijective_toDescentData_map_iff] - convert Iff.rfl + convert! Iff.rfl refine le_antisymm ?_ ?_ · rintro X f (hf : R.arrows f.left) obtain ⟨X, g, rfl⟩ := Over.mk_surjective X @@ -578,7 +578,7 @@ lemma isPrestackFor_iff_isSheafFor' {S : C} (R : Sieve S) : rw [← Presieve.isSheafFor_iff_of_iso (F.overMapCompPresheafHomIso M N a), Presieve.isSheafFor_over_map_op_comp_iff (X' := Over.mk a) (e := Over.isoMk (Iso.refl _))] at h - convert h + convert! h refine le_antisymm ?_ ?_ · intro Y f hf exact ⟨Over.mk f.left, Over.homMk f.left, Over.homMk (𝟙 _) (by simpa using Over.w f), diff --git a/Mathlib/CategoryTheory/Sites/Descent/Precoverage.lean b/Mathlib/CategoryTheory/Sites/Descent/Precoverage.lean index 01c2efc9c41b9c..7dfbba7e30a9e2 100644 --- a/Mathlib/CategoryTheory/Sites/Descent/Precoverage.lean +++ b/Mathlib/CategoryTheory/Sites/Descent/Precoverage.lean @@ -203,7 +203,7 @@ noncomputable def familyOfElements (i : ι) : Presieve.FamilyOfElements (F.presheafHom (D₁.obj i) (D₂.obj i)) (sieve f f' i).arrows := fun Z q hq ↦ mor w φ _ _ (sieve.fac (f := f) (f' := f') (q := Z.hom) (by - convert hq + convert! hq ext simpa using (Over.w q).symm)) diff --git a/Mathlib/CategoryTheory/Sites/Equivalence.lean b/Mathlib/CategoryTheory/Sites/Equivalence.lean index b1a84418a95e38..d3e20a08f9dce9 100644 --- a/Mathlib/CategoryTheory/Sites/Equivalence.lean +++ b/Mathlib/CategoryTheory/Sites/Equivalence.lean @@ -55,7 +55,7 @@ namespace Equivalence instance (priority := 900) [G.IsEquivalence] : IsCoverDense G J where is_cover U := by let e := (asEquivalence G).symm - convert J.top_mem U + convert! J.top_mem U ext Y f simp only [Sieve.top_apply, iff_true] let g : e.inverse.obj _ ⟶ U := (e.unitInv.app Y) ≫ f diff --git a/Mathlib/CategoryTheory/Sites/Grothendieck.lean b/Mathlib/CategoryTheory/Sites/Grothendieck.lean index c990e6239237d3..c7caf6cf08eaa0 100644 --- a/Mathlib/CategoryTheory/Sites/Grothendieck.lean +++ b/Mathlib/CategoryTheory/Sites/Grothendieck.lean @@ -124,7 +124,7 @@ variable {J} in lemma pullback_mem_iff_of_isIso {i : X ⟶ Y} [IsIso i] {S : Sieve Y} : S.pullback i ∈ J _ ↔ S ∈ J _ := by refine ⟨fun H ↦ ?_, J.pullback_stable i⟩ - convert J.pullback_stable (inv i) H + convert! J.pullback_stable (inv i) H rw [← Sieve.pullback_comp, IsIso.inv_hom_id, Sieve.pullback_id] @[grind .] diff --git a/Mathlib/CategoryTheory/Sites/Hypercover/Homotopy.lean b/Mathlib/CategoryTheory/Sites/Hypercover/Homotopy.lean index 13625777680dab..fddd49f702b794 100644 --- a/Mathlib/CategoryTheory/Sites/Hypercover/Homotopy.lean +++ b/Mathlib/CategoryTheory/Sites/Hypercover/Homotopy.lean @@ -184,7 +184,7 @@ lemma sieve₁'_cylinder (i j : Σ (i : E.I₀), F.I₁ (f.s₀ i) (g.s₀ i)) : simp_rw [← pullbackSymmetry_inv_comp_fst] apply (((cylinder f g).sieve₁' i j)).downward_closed rw [sieve₁'] - convert Sieve.ofArrows_mk _ _ (ULift.up k) + convert! Sieve.ofArrows_mk _ _ (ULift.up k) simp [toPullback_cylinder f g ⟨k⟩] set_option backward.isDefEq.respectTransparency false in diff --git a/Mathlib/CategoryTheory/Sites/Hypercover/One.lean b/Mathlib/CategoryTheory/Sites/Hypercover/One.lean index cf59dca760ca51..231cb86e9b661c 100644 --- a/Mathlib/CategoryTheory/Sites/Hypercover/One.lean +++ b/Mathlib/CategoryTheory/Sites/Hypercover/One.lean @@ -71,6 +71,13 @@ def sieve₁ {i₁ i₂ : E.I₀} {W : C} (p₁ : W ⟶ E.X i₁) (p₂ : W ⟶ rintro Z Z' g ⟨j, h, fac₁, fac₂⟩ φ exact ⟨j, φ ≫ h, by simpa using φ ≫= fac₁, by simpa using φ ≫= fac₂⟩ +lemma pullback_sieve₁ {i₁ i₂ : E.I₀} {W : C} (p₁ : W ⟶ E.X i₁) (p₂ : W ⟶ E.X i₂) + {T : C} (f : T ⟶ W) : + Sieve.pullback f (E.sieve₁ p₁ p₂) = E.sieve₁ (f ≫ p₁) (f ≫ p₂) := by + refine le_antisymm ?_ ?_ <;> + · intro Z g ⟨k, u, hu₁, hu₂⟩ + cat_disch + section variable {i₁ i₂ : E.I₀} [HasPullback (E.f i₁) (E.f i₂)] @@ -79,6 +86,14 @@ variable {i₁ i₂ : E.I₀} [HasPullback (E.f i₁) (E.f i₂)] noncomputable abbrev toPullback (j : E.I₁ i₁ i₂) : E.Y j ⟶ pullback (E.f i₁) (E.f i₂) := pullback.lift (E.p₁ j) (E.p₂ j) (E.w j) +@[reassoc (attr := simp)] +lemma toPullback_fst (k : E.I₁ i₁ i₂) : E.toPullback k ≫ pullback.fst _ _ = E.p₁ k := by + rw [pullback.lift_fst] + +@[reassoc (attr := simp)] +lemma toPullback_snd (k : E.I₁ i₁ i₂) : E.toPullback k ≫ pullback.snd _ _ = E.p₂ k := by + rw [pullback.lift_snd] + variable (i₁ i₂) in /-- The sieve of `pullback (E.f i₁) (E.f i₂)` given by `E : PreOneHypercover S`. -/ noncomputable def sieve₁' : Sieve (pullback (E.f i₁) (E.f i₂)) := diff --git a/Mathlib/CategoryTheory/Sites/Hypercover/Zero.lean b/Mathlib/CategoryTheory/Sites/Hypercover/Zero.lean index 8bf2aae59fae77..343470a35f51fc 100644 --- a/Mathlib/CategoryTheory/Sites/Hypercover/Zero.lean +++ b/Mathlib/CategoryTheory/Sites/Hypercover/Zero.lean @@ -807,7 +807,7 @@ instance (E : ZeroHypercover.{w} J S) : ZeroHypercover.Small.{max u v} E where simp choose j h₁ h₂ using this refine ⟨ι, fun i ↦ j _ _ (.mk i), ?_⟩ - convert E.mem₀ + convert! E.mem₀ exact le_antisymm (fun Z g ⟨i⟩ ↦ ⟨_⟩) (h ▸ fun Z g ⟨i⟩ ↦ .mk' i (h₁ _ _ _) (h₂ _ _ _)) /-- Restrict a `w'`-small `0`-hypercover to a `w'`-`0`-hypercover. -/ @@ -871,7 +871,7 @@ lemma Small.inf {J K : Precoverage C} [Small.{w} J] instance [IsStableUnderBaseChange J] : RespectsIso J where of_iso {S E F} e h := by refine J.mem_coverings_of_isPullback (fun i ↦ E.f (e.inv.s₀ i)) ?_ (𝟙 S) _ (fun i ↦ ?_) ?_ - · convert h + · convert! h exact Presieve.ofArrows_comp_eq_of_surjective _ (fun i ↦ ⟨e.hom.s₀ i, by simp⟩) · exact e.inv.h₀ i · intro i diff --git a/Mathlib/CategoryTheory/Sites/IsSheafFor.lean b/Mathlib/CategoryTheory/Sites/IsSheafFor.lean index 6c481804ee1e28..2f2cbc9c647a57 100644 --- a/Mathlib/CategoryTheory/Sites/IsSheafFor.lean +++ b/Mathlib/CategoryTheory/Sites/IsSheafFor.lean @@ -478,7 +478,7 @@ noncomputable def shrinkFunctorHomEquiv [LocallySmall.{w} C] {F : Cᵒᵖ ⥤ Ty naturality Y Z g := by ext ⟨f, hf⟩ dsimp - convert t.2.to_sieveCompatible _ _ _ + convert! t.2.to_sieveCompatible _ _ _ simp only [Opposite.op_unop, shrinkYonedaObjObjEquiv_obj_map] rfl } left_inv t := by cat_disch @@ -501,7 +501,7 @@ lemma shrinkFunctor_ι_comp_eq_iff_isAmalgamation [LocallySmall.{w} C] (F : Cᵒ · rintro rfl Y f hf simp [shrinkYonedaEquiv_naturality, shrinkYonedaEquiv_comp, shrinkYonedaEquiv_shrinkYoneda_map] · ext Y ⟨u, hu⟩ - convert h (shrinkYonedaObjObjEquiv u) hu + convert! h (shrinkYonedaObjObjEquiv u) hu · rw [shrinkYonedaEquiv_naturality, shrinkYonedaEquiv_comp, shrinkYonedaEquiv_shrinkYoneda_map] simp · rw! [Equiv.symm_apply_apply] @@ -870,7 +870,7 @@ lemma isSheafFor_pullback_iff (P : Cᵒᵖ ⥤ Type w) {X : C} (R : Sieve X) simp only [this, ← isSheafFor_iff_generate, isSheafFor_ofArrows_iff_bijective_toCompabible, ← e.bijective.of_comp_iff', ← Function.Bijective.of_comp_iff _ (P.mapIso (asIso f).symm.op).toEquiv.bijective] - convert Iff.rfl using 2 + convert! Iff.rfl using 2 ext simp [e] @@ -895,7 +895,7 @@ lemma isSheafFor_over_map_op_comp_ofArrows_iff replace this := congr_arg (P.map φ.op) this dsimp at this simp only [← comp_apply, ← Functor.map_comp, ← op_comp] at this - convert this <;> cat_disch⟩ + convert! this <;> cat_disch⟩ invFun s := ⟨fun i ↦ s.val i, fun i₁ i₂ Z g₁ g₂ h ↦ s.property i₁ i₂ _ ((Over.map p).map g₁) ((Over.map p).map g₂) (by simp only [← Functor.map_comp, h])⟩ } @@ -912,7 +912,7 @@ lemma isSheafFor_over_map_op_comp_iff obtain ⟨ι, Z, g, rfl⟩ := R.exists_eq_ofArrows rw [← isSheafFor_iff_generate, isSheafFor_pullback_iff, isSheafFor_over_map_op_comp_ofArrows_iff, isSheafFor_iff_generate] - convert Iff.rfl + convert! Iff.rfl refine le_antisymm ?_ ?_ · rintro W _ ⟨T, _, a, ⟨_, b, _, ⟨i⟩, rfl⟩, rfl⟩ refine ⟨(Over.map p).obj (Z i), Over.homMk (a.left ≫ b.left) ?_, _, ⟨i⟩, ?_⟩ diff --git a/Mathlib/CategoryTheory/Sites/LeftExact.lean b/Mathlib/CategoryTheory/Sites/LeftExact.lean index 580d3ee2f5a27f..52112f6067c2f6 100644 --- a/Mathlib/CategoryTheory/Sites/LeftExact.lean +++ b/Mathlib/CategoryTheory/Sites/LeftExact.lean @@ -293,8 +293,9 @@ set_option backward.isDefEq.respectTransparency false in @[reassoc (attr := simp)] lemma toSheafify_plusPlusIsoSheafify_hom (P : Cᵒᵖ ⥤ D) : J.toSheafify P ≫ (plusPlusIsoSheafify J D P).hom = toSheafify J P := by - convert Adjunction.unit_leftAdjointUniq_hom_app - (plusPlusAdjunction J D) (sheafificationAdjunction J D) P + convert! + Adjunction.unit_leftAdjointUniq_hom_app (plusPlusAdjunction J D) (sheafificationAdjunction J D) + P ext1 P dsimp [GrothendieckTopology.toSheafify, plusPlusAdjunction] rw [Category.comp_id] diff --git a/Mathlib/CategoryTheory/Sites/LocallyInjective.lean b/Mathlib/CategoryTheory/Sites/LocallyInjective.lean index cebb13c630641a..ec494c3b2b2958 100644 --- a/Mathlib/CategoryTheory/Sites/LocallyInjective.lean +++ b/Mathlib/CategoryTheory/Sites/LocallyInjective.lean @@ -80,7 +80,7 @@ lemma equalizerSieve_mem [IsLocallyInjective J φ] lemma isLocallyInjective_of_injective (hφ : ∀ (X : Cᵒᵖ), Function.Injective (φ.app X)) : IsLocallyInjective J φ where equalizerSieve_mem {X} x y h := by - convert J.top_mem X.unop + convert! J.top_mem X.unop ext Y f simp only [equalizerSieve_apply, op_unop, Sieve.top_apply, iff_true] apply hφ diff --git a/Mathlib/CategoryTheory/Sites/LocallySurjective.lean b/Mathlib/CategoryTheory/Sites/LocallySurjective.lean index 196eeae075878b..2687f17910070b 100644 --- a/Mathlib/CategoryTheory/Sites/LocallySurjective.lean +++ b/Mathlib/CategoryTheory/Sites/LocallySurjective.lean @@ -426,7 +426,7 @@ lemma imageSieve_cofanIsColimitDesc_shrinkYoneda_map obtain ⟨a : V ⟶ X i, rfl⟩ := shrinkYonedaObjObjEquiv.symm.surjective a refine ⟨_, a, _, ⟨i⟩, shrinkYonedaObjObjEquiv.symm.injective ?_⟩ rw [← shrinkYoneda_map_app_shrinkYonedaObjObjEquiv_symm] - convert hw using 1 + convert! hw using 1 · exact (ConcreteCategory.congr_hom (NatTrans.congr_app ((Cofan.IsColimit.fac hc (fun i ↦ shrinkYoneda.{w}.map (f i))) i) (op V)) (shrinkYonedaObjObjEquiv.symm a)).symm diff --git a/Mathlib/CategoryTheory/Sites/Monoidal.lean b/Mathlib/CategoryTheory/Sites/Monoidal.lean index 2f7c84550b8f40..7dea1989f7d62d 100644 --- a/Mathlib/CategoryTheory/Sites/Monoidal.lean +++ b/Mathlib/CategoryTheory/Sites/Monoidal.lean @@ -136,7 +136,7 @@ lemma whiskerLeft {G₁ G₂ : Cᵒᵖ ⥤ A} {g : G₁ ⟶ G₂} (hg : J.W g) ( ((ihom.adjunction _).homEquiv _ _).bijective] rw [← Function.Bijective.of_comp_iff (g := MonoidalClosed.curry) _ ((ihom.adjunction _).homEquiv _ _).bijective] at this - convert this using 1 + convert! this using 1 ext α : 1 dsimp rw [curry_natural_left] diff --git a/Mathlib/CategoryTheory/Sites/Over.lean b/Mathlib/CategoryTheory/Sites/Over.lean index b82fef24c47312..78c1828f2090be 100644 --- a/Mathlib/CategoryTheory/Sites/Over.lean +++ b/Mathlib/CategoryTheory/Sites/Over.lean @@ -203,7 +203,7 @@ lemma overEquiv_functorPullback_post {D : Type*} [Category* D] (F : C ⥤ D) {X · intro Z g hg rw [Sieve.overEquiv_iff] dsimp [Presieve.functorPullback] - convert (Sieve.overEquiv_iff _ _).mp hg + convert! (Sieve.overEquiv_iff _ _).mp hg simp set_option backward.isDefEq.respectTransparency false in @@ -282,8 +282,9 @@ lemma over_map_compatiblePreserving {X Y : C} (f : X ⟶ Y) : (by simpa using (Over.forget _).congr_map h.symm =≫ Z.hom) let e : (Over.map f).obj W' ≅ W := Over.isoMk (Iso.refl _) (by simpa [W'] using (Over.w f₁).symm) - convert congr_arg (F.obj.map e.inv.op) - (hx g₁' g₂' hg₁ hg₂ (by ext; exact (Over.forget _).congr_map h)) using 1 + convert! + congr_arg (F.obj.map e.inv.op) + (hx g₁' g₂' hg₁ hg₂ (by ext; exact (Over.forget _).congr_map h)) using 1 all_goals dsimp [e, W', g₁', g₂'] rw [← Functor.map_comp_apply] diff --git a/Mathlib/CategoryTheory/Sites/Plus.lean b/Mathlib/CategoryTheory/Sites/Plus.lean index 8d06cb63682477..eedcef0bdc8507 100644 --- a/Mathlib/CategoryTheory/Sites/Plus.lean +++ b/Mathlib/CategoryTheory/Sites/Plus.lean @@ -116,7 +116,7 @@ def plusObj : Cᵒᵖ ⥤ D where let e := S.unop.pullbackId dsimp only [Functor.op, pullback_obj] rw [← colimit.w _ e.inv.op, ← Category.assoc] - convert Category.id_comp (colimit.ι (diagram J P (unop X)) S) + convert! Category.id_comp (colimit.ι (diagram J P (unop X)) S) refine Multiequalizer.hom_ext _ _ _ (fun I => ?_) dsimp simp only [Multiequalizer.lift_ι, Category.id_comp, Category.assoc] @@ -243,8 +243,9 @@ theorem plusMap_toPlus : J.plusMap (J.toPlus P) = J.toPlus (J.plusObj P) := by ← Category.assoc, ← Category.assoc] congr 1 refine Multiequalizer.hom_ext _ _ _ (fun II => ?_) - convert Multiequalizer.condition (S.unop.index P) - { fst := I, snd := II.base, r.Z := II.Y, r.g₁ := II.f, r.g₂ := 𝟙 II.Y } using 1 + convert! + Multiequalizer.condition (S.unop.index P) + { fst := I, snd := II.base, r.Z := II.Y, r.g₁ := II.f, r.g₂ := 𝟙 II.Y } using 1 all_goals simp set_option backward.isDefEq.respectTransparency false in diff --git a/Mathlib/CategoryTheory/Sites/Point/Skyscraper.lean b/Mathlib/CategoryTheory/Sites/Point/Skyscraper.lean index ddbe0afeb4b496..dfa2725d200c5f 100644 --- a/Mathlib/CategoryTheory/Sites/Point/Skyscraper.lean +++ b/Mathlib/CategoryTheory/Sites/Point/Skyscraper.lean @@ -252,7 +252,7 @@ lemma W_isInvertedBy_presheafFiber : rw [isIso_iff_coyoneda_map_bijective] intro M rw [← Function.Bijective.of_comp_iff' Φ.skyscraperPresheafHomEquiv.bijective] - convert (hf _ (Φ.isSheaf_skyscraperPresheaf M)).comp Φ.skyscraperPresheafHomEquiv.bijective + convert! (hf _ (Φ.isSheaf_skyscraperPresheaf M)).comp Φ.skyscraperPresheafHomEquiv.bijective ext g : 1 simp [skyscraperPresheafHomEquiv_naturality_left] diff --git a/Mathlib/CategoryTheory/Sites/Precoverage.lean b/Mathlib/CategoryTheory/Sites/Precoverage.lean index c0a15ddcefc338..b0273725c31be0 100644 --- a/Mathlib/CategoryTheory/Sites/Precoverage.lean +++ b/Mathlib/CategoryTheory/Sites/Precoverage.lean @@ -142,7 +142,7 @@ lemma mem_coverings_of_isPullback {J : Precoverage C} [IsStableUnderBaseChange J exact .mk' (Sum.inr ⟨⟨_, _⟩, hg⟩) (by cat_disch) (by cat_disch) · refine IsStableUnderBaseChange.mem_coverings_of_isPullback (fun i ↦ f (a i)) ?_ g _ (fun i ↦ p₂ (a i)) fun i ↦ h _ - convert hR + convert! hR refine le_antisymm (fun Z g ⟨i⟩ ↦ .mk _) fun Z g hg ↦ ?_ exact .mk' (Sum.inl ⟨⟨_, _⟩, hg⟩) (by cat_disch) (by cat_disch) @@ -170,10 +170,10 @@ lemma comp_mem_coverings {J : Precoverage C} [IsStableUnderComposition J] {ι : exact .mk' ⟨Sum.inr ⟨⟨_, _⟩, hu⟩, .inl ⟨⟩⟩ hu.obj_idx.symm hu.eq_eqToHom_comp_hom_idx · refine IsStableUnderComposition.comp_mem_coverings (f := fun i ↦ f (incl i)) (g := fun i j ↦ g (incl i) (fibincl i j)) ?_ fun i ↦ ?_ - · convert hf + · convert! hf refine le_antisymm (fun T u ⟨p⟩ ↦ .mk _) fun T u hu ↦ ?_ exact .mk' (Sum.inl ⟨⟨_, _⟩, hu⟩) (by cat_disch) (by cat_disch) - · convert hg (incl i) + · convert! hg (incl i) refine le_antisymm (fun T u ⟨p⟩ ↦ .mk _) fun T u hu ↦ ?_ match i with | .inl i => exact .mk' ⟨⟨_, _⟩, hu⟩ (by cat_disch) (by cat_disch) diff --git a/Mathlib/CategoryTheory/Sites/PreservesSheafification.lean b/Mathlib/CategoryTheory/Sites/PreservesSheafification.lean index 1138c568349a3b..5e6eb777a91206 100644 --- a/Mathlib/CategoryTheory/Sites/PreservesSheafification.lean +++ b/Mathlib/CategoryTheory/Sites/PreservesSheafification.lean @@ -277,7 +277,7 @@ lemma sheafToPresheaf_map_sheafComposeNatTrans_eq_sheafifyCompIso_inv (P : Cᵒ rw [this] rfl apply ((plusPlusAdjunction J E).homEquiv _ _).injective - convert sheafComposeNatTrans_fac J F (plusPlusAdjunction J D) (plusPlusAdjunction J E) P + convert! sheafComposeNatTrans_fac J F (plusPlusAdjunction J D) (plusPlusAdjunction J E) P dsimp [plusPlusAdjunction] simp diff --git a/Mathlib/CategoryTheory/Sites/Sheaf.lean b/Mathlib/CategoryTheory/Sites/Sheaf.lean index d4b5e8c540a34e..482a40dbc9a933 100644 --- a/Mathlib/CategoryTheory/Sites/Sheaf.lean +++ b/Mathlib/CategoryTheory/Sites/Sheaf.lean @@ -110,7 +110,7 @@ def conesEquivSieveCompatibleFamily : have := x.2 f.unop.1.hom g.unop.hom.left f.unop.2 dsimp at this ⊢ rw [id_comp, ← this] - convert rfl + convert! rfl simp only [Over.w] } variable {P S E} diff --git a/Mathlib/CategoryTheory/Sites/Sieves.lean b/Mathlib/CategoryTheory/Sites/Sieves.lean index 0c4c9d76e45d69..582319b11d823f 100644 --- a/Mathlib/CategoryTheory/Sites/Sieves.lean +++ b/Mathlib/CategoryTheory/Sites/Sieves.lean @@ -707,7 +707,7 @@ lemma generate_eq_bot_iff (R : Presieve X) : generate R = ⊥ ↔ R = ⊥ := by lemma comp_mem_iff (i : X ⟶ Y) (f : Y ⟶ Z) [IsIso i] (S : Sieve Z) : S (i ≫ f) ↔ S f := by refine ⟨fun H ↦ ?_, fun H ↦ S.downward_closed H _⟩ - convert S.downward_closed H (inv i) + convert! S.downward_closed H (inv i) simp section diff --git a/Mathlib/CategoryTheory/Sites/Subsheaf.lean b/Mathlib/CategoryTheory/Sites/Subsheaf.lean index 8191f45ebdbe1f..28abbe1c7137c2 100644 --- a/Mathlib/CategoryTheory/Sites/Subsheaf.lean +++ b/Mathlib/CategoryTheory/Sites/Subsheaf.lean @@ -68,7 +68,7 @@ def Subfunctor.sheafify : Subfunctor F where theorem Subfunctor.le_sheafify : G ≤ G.sheafify J := by intro U s hs change _ ∈ J _ - convert J.top_mem U.unop + convert! J.top_mem U.unop rw [eq_top_iff] rintro V i - exact G.map i.op hs @@ -201,13 +201,13 @@ alias Subpresheaf.to_sheafify_lift_unique := Subfunctor.to_sheafify_lift_unique theorem Subfunctor.sheafify_le (h : G ≤ G') (hF : Presieve.IsSheaf J F) (hG' : Presieve.IsSheaf J G'.toFunctor) : G.sheafify J ≤ G' := by intro U x hx - convert ((G.sheafifyLift (Subfunctor.homOfLe h) hG').app U ⟨x, hx⟩).2 + convert! ((G.sheafifyLift (Subfunctor.homOfLe h) hG').app U ⟨x, hx⟩).2 apply (hF _ hx).isSeparatedFor.ext intro V i hi have := congr_arg (fun f : G.toFunctor ⟶ G'.toFunctor => (NatTrans.app f (op V) ⟨_, hi⟩).1) (G.to_sheafifyLift (Subfunctor.homOfLe h) hG') - convert this.symm + convert! this.symm rw [← Subfunctor.nat_trans_naturality] rfl @@ -272,7 +272,7 @@ instance {F F' : Sheaf J (Type w)} (f : F ⟶ F') : Epi (Sheaf.toImage f) := by simp only [ObjectProperty.FullSubcategory.comp_hom, Sheaf.image_obj, Sheaf.toImage_hom, NatTrans.comp_app, Subfunctor.toFunctor_obj, comp_apply, op_unop, Subfunctor.toFunctor_map, ConcreteCategory.hom_ofHom, TypeCat.Fun.coe_mk, Subtype.ext_iff] at this E ⊢ - convert this <;> exact E.symm + convert! this <;> exact E.symm /-- The mono factorization given by `image_sheaf` for a morphism. -/ def imageMonoFactorization {F F' : Sheaf J (Type w)} (f : F ⟶ F') : diff --git a/Mathlib/CategoryTheory/Sites/Types.lean b/Mathlib/CategoryTheory/Sites/Types.lean index b06098d1e0e94f..a561d881fa36c4 100644 --- a/Mathlib/CategoryTheory/Sites/Types.lean +++ b/Mathlib/CategoryTheory/Sites/Types.lean @@ -56,10 +56,10 @@ theorem Presieve.isSheaf_yoneda' {α : Type u} : fun β _ hs x hx => ⟨↾fun y => (x _ (hs y)).hom PUnit.unit , fun γ f h => ConcreteCategory.hom_ext _ _ fun z => by - convert ConcreteCategory.congr_hom (hx (𝟙 _) (↾fun _ => z) - (hs <| f z) h rfl) PUnit.unit using 1, + convert! + ConcreteCategory.congr_hom (hx (𝟙 _) (↾fun _ => z) (hs <| f z) h rfl) PUnit.unit using 1, fun f hf => ConcreteCategory.hom_ext _ _ fun y => by - convert ConcreteCategory.congr_hom (hf _ (hs y)) PUnit.unit⟩ + convert! ConcreteCategory.congr_hom (hf _ (hs y)) PUnit.unit⟩ /-- The sheaf condition for `yoneda'`. -/ theorem Presheaf.isSheaf_yoneda' {α : Type u} : @@ -105,7 +105,7 @@ noncomputable def typesGlue (S : Type uᵒᵖ ⥤ Type u) theorem eval_typesGlue {S hs α} (f) : eval.{u} S α (typesGlue S hs α f) = f := by funext x apply (IsSheafFor.valid_glue _ _ _ <| ⟨PUnit.unit, fun _ => Subsingleton.elim _ _⟩).trans - convert ConcreteCategory.congr_hom (S.map_id _) _ + convert! ConcreteCategory.congr_hom (S.map_id _) _ theorem typesGlue_eval {S hs α} (s) : typesGlue.{u} S hs α (eval S α s) = s := by apply (hs.isSheafFor _ (generate_discretePresieve_mem α)).isSeparatedFor.ext diff --git a/Mathlib/CategoryTheory/SmallObject/WellOrderInductionData.lean b/Mathlib/CategoryTheory/SmallObject/WellOrderInductionData.lean index 19b9b5eb086aab..0a47e50c8fd0c6 100644 --- a/Mathlib/CategoryTheory/SmallObject/WellOrderInductionData.lean +++ b/Mathlib/CategoryTheory/SmallObject/WellOrderInductionData.lean @@ -221,10 +221,11 @@ def limit (j : J) (hj : Order.IsSuccLimit j) rw [d.map_lift _ _ _ _ (by simpa [bot_lt_iff_ne_bot] using hj.not_isMin)] simpa using (e ⊥ (by simpa [bot_lt_iff_ne_bot] using hj.not_isMin)).map_zero map_succ i hi := by - convert (e (Order.succ i) ((Order.IsSuccLimit.succ_lt_iff hj).mpr hi)).map_succ i - (by - simp only [Order.lt_succ_iff_not_isMax, not_isMax_iff] - exact ⟨_, hi⟩) using 1 + convert! + (e (Order.succ i) ((Order.IsSuccLimit.succ_lt_iff hj).mpr hi)).map_succ i + (by + simp only [Order.lt_succ_iff_not_isMax, not_isMax_iff] + exact ⟨_, hi⟩) using 1 · dsimp rw [map_id, id_apply, d.map_lift _ _ _ _ ((Order.IsSuccLimit.succ_lt_iff hj).mpr hi)] · congr 1 diff --git a/Mathlib/CategoryTheory/Subobject/Basic.lean b/Mathlib/CategoryTheory/Subobject/Basic.lean index 6cca33b4b3c688..4866442c96b7c9 100644 --- a/Mathlib/CategoryTheory/Subobject/Basic.lean +++ b/Mathlib/CategoryTheory/Subobject/Basic.lean @@ -245,7 +245,7 @@ theorem mk_arrow (P : Subobject X) : mk P.arrow = P := theorem le_of_comm {B : C} {X Y : Subobject B} (f : (X : C) ⟶ (Y : C)) (w : f ≫ Y.arrow = X.arrow) : X ≤ Y := by - convert mk_le_mk_of_comm _ w <;> simp + convert! mk_le_mk_of_comm _ w <;> simp theorem le_mk_of_comm {B A : C} {X : Subobject B} {f : A ⟶ B} [Mono f] (g : (X : C) ⟶ A) (w : g ≫ f = X.arrow) : X ≤ mk f := @@ -448,7 +448,7 @@ lemma mk_lt_mk_of_comm {X A₁ A₂ : C} {i₁ : A₁ ⟶ X} {i₂ : A₂ ⟶ X} · assumption · exfalso apply hf - convert (isoOfMkEqMk i₁ i₂ h).isIso_hom + convert! (isoOfMkEqMk i₁ i₂ h).isIso_hom rw [← cancel_mono i₂, isoOfMkEqMk_hom, ofMkLEMk_comp, fac] lemma mk_lt_mk_iff_of_comm {X A₁ A₂ : C} {i₁ : A₁ ⟶ X} {i₂ : A₂ ⟶ X} [Mono i₁] [Mono i₂] @@ -529,12 +529,12 @@ def lowerEquivalence {A : C} {B : D} (e : MonoOver A ≌ MonoOver B) : Subobject inverse := lower e.inverse unitIso := by apply eqToIso - convert ThinSkeleton.map_iso_eq e.unitIso + convert! ThinSkeleton.map_iso_eq e.unitIso · exact ThinSkeleton.map_id_eq.symm · exact (ThinSkeleton.map_comp_eq _ _).symm counitIso := by apply eqToIso - convert ThinSkeleton.map_iso_eq e.counitIso + convert! ThinSkeleton.map_iso_eq e.counitIso · exact (ThinSkeleton.map_comp_eq _ _).symm · exact ThinSkeleton.map_id_eq.symm diff --git a/Mathlib/CategoryTheory/Subobject/Classifier/Defs.lean b/Mathlib/CategoryTheory/Subobject/Classifier/Defs.lean index 1d3ce7a8a04d9b..acf37498a231df 100644 --- a/Mathlib/CategoryTheory/Subobject/Classifier/Defs.lean +++ b/Mathlib/CategoryTheory/Subobject/Classifier/Defs.lean @@ -321,7 +321,7 @@ alias _root_.CategoryTheory.Classifier.truth_as_subobject := truth_as_subobject lemma surjective_χ {X : C} (φ : X ⟶ 𝒞.Ω) : ∃ (Z : C) (i : Z ⟶ X) (_ : Mono i), φ = 𝒞.χ i := ⟨Limits.pullback φ 𝒞.truth, pullback.fst _ _, inferInstance, 𝒞.uniq _ (by - convert IsPullback.of_hasPullback φ 𝒞.truth)⟩ + convert! IsPullback.of_hasPullback φ 𝒞.truth)⟩ @[deprecated (since := "2026-03-06")] alias _root_.CategoryTheory.Classifier.surjective_χ := surjective_χ @@ -393,6 +393,8 @@ def Ω₀ : Subobject Ω := h.homEquiv (𝟙 Ω) @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.Ω₀ := Ω₀ +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.Ω₀ := Ω₀ /-- `h.homEquiv` acts like an "object comprehension" operator: it maps any characteristic map `f : X ⟶ Ω` to the associated subobject of `X`, obtained by pulling back `h.Ω₀` along `f`. -/ @@ -402,6 +404,8 @@ lemma homEquiv_eq {X : C} (f : X ⟶ Ω) : @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.homEquiv_eq := homEquiv_eq +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.homEquiv_eq := homEquiv_eq /-- For any subobject `x`, the pullback of `h.Ω₀` along the characteristic map of `x` given by `h.homEquiv` is `x` itself. -/ @@ -412,6 +416,9 @@ lemma pullback_homEquiv_symm_obj_Ω₀ {X : C} (x : Subobject X) : @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.pullback_homEquiv_symm_obj_Ω₀ := pullback_homEquiv_symm_obj_Ω₀ +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.pullback_homEquiv_symm_obj_Ω₀ := + pullback_homEquiv_symm_obj_Ω₀ section @@ -422,6 +429,8 @@ def χ : X ⟶ Ω := h.homEquiv.symm (Subobject.mk m) @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.χ := χ +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.χ := χ /-- `h.iso m` is the isomorphism between `m` and the pullback of `Ω₀` along the characteristic map of `m`. -/ @@ -432,6 +441,8 @@ noncomputable def iso : MonoOver.mk m ≅ @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.iso := iso +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.iso := iso /-- `h.π m` is the first projection in the following pullback square: @@ -449,6 +460,8 @@ noncomputable def π : U ⟶ Subobject.underlying.obj h.Ω₀ := @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.π := π +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.π := π set_option backward.isDefEq.respectTransparency false in @[reassoc (attr := simp)] @@ -456,11 +469,13 @@ lemma iso_inv_left_π : (h.iso m).inv.hom.left ≫ h.π m = Subobject.pullbackπ (h.χ m) h.Ω₀ := by dsimp only [π] rw [← Over.comp_left_assoc] - convert Category.id_comp _ using 2 + convert! Category.id_comp _ using 2 exact (MonoOver.forget _ ⋙ Over.forget _).congr_map (h.iso m).inv_hom_id @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.iso_inv_left_π := iso_inv_left_π +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.iso_inv_left_π := iso_inv_left_π @[reassoc (attr := simp)] lemma iso_inv_hom_left_comp : @@ -471,6 +486,9 @@ lemma iso_inv_hom_left_comp : @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.iso_inv_hom_left_comp := iso_inv_hom_left_comp +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.iso_inv_hom_left_comp := + iso_inv_hom_left_comp @[deprecated (since := "2025-12-18")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.iso_inv_left_comp := @@ -486,6 +504,8 @@ lemma isPullback {U X : C} (m : U ⟶ X) [Mono m] : @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.isPullback := isPullback +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.isPullback := isPullback variable {m} lemma uniq {χ' : X ⟶ Ω} {π : U ⟶ h.Ω₀} @@ -496,6 +516,8 @@ lemma uniq {χ' : X ⟶ Ω} {π : U ⟶ h.Ω₀} @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.uniq := uniq +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.uniq := uniq end @@ -511,18 +533,24 @@ noncomputable def isTerminalΩ₀ : IsTerminal (h.Ω₀ : C) := @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.isTerminalΩ₀ := isTerminalΩ₀ +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.isTerminalΩ₀ := isTerminalΩ₀ /-- The unique map to the terminal object. -/ noncomputable def χ₀ (U : C) : U ⟶ h.Ω₀ := h.isTerminalΩ₀.from U @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.χ₀ := χ₀ +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.χ₀ := χ₀ include h in lemma hasTerminal : HasTerminal C := h.isTerminalΩ₀.hasTerminal @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.hasTerminal := hasTerminal +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.hasTerminal := hasTerminal variable [HasTerminal C] @@ -532,6 +560,8 @@ noncomputable def isoΩ₀ : (h.Ω₀ : C) ≅ ⊤_ C := @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.isoΩ₀ := isoΩ₀ +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.isoΩ₀ := isoΩ₀ /-- Any representation `Ω` of `Subobject.presheaf C` gives a subobject classifier with truth values object `Ω`. -/ @@ -553,6 +583,8 @@ noncomputable def classifier : Subobject.Classifier C where @[deprecated (since := "2026-03-06")] alias _root.CategoryTheory.Classifier.SubobjectRepresentableBy.classifier := classifier +@[deprecated (since := "2026-03-06")] +alias _root_.CategoryTheory.Classifier.SubobjectRepresentableBy.classifier := classifier end SubobjectRepresentableBy end FromRepresentation diff --git a/Mathlib/CategoryTheory/Subobject/Lattice.lean b/Mathlib/CategoryTheory/Subobject/Lattice.lean index ee861db473397d..36a6cde1895a72 100644 --- a/Mathlib/CategoryTheory/Subobject/Lattice.lean +++ b/Mathlib/CategoryTheory/Subobject/Lattice.lean @@ -214,7 +214,7 @@ theorem top_eq_id (B : C) : (⊤ : Subobject B) = Subobject.mk (𝟙 B) := rfl theorem underlyingIso_top_hom {B : C} : (underlyingIso (𝟙 B)).hom = (⊤ : Subobject B).arrow := by - convert underlyingIso_hom_comp_eq_mk (𝟙 B) + convert! underlyingIso_hom_comp_eq_mk (𝟙 B) simp only [comp_id] instance top_arrow_isIso {B : C} : IsIso (⊤ : Subobject B).arrow := by @@ -443,7 +443,7 @@ theorem inf_eq_map_pullback' {A : C} (f₁ : MonoOver A) (f₂ : Subobject A) : theorem inf_eq_map_pullback {A : C} (f₁ : Subobject A) (f₂ : Subobject A) : (f₁ ⊓ f₂ : Subobject A) = (map f₁.arrow).obj ((pullback f₁.arrow).obj f₂) := by - convert inf_eq_map_pullback' (representative.obj f₁) f₂ + convert! inf_eq_map_pullback' (representative.obj f₁) f₂ ext1 nth_rw 1 [← thinSkeleton_mk_representative_eq_self f₁] congr @@ -611,7 +611,7 @@ theorem sInf_le {A : C} (s : Set (Subobject A)) (f) (hf : f ∈ s) : sInf s ≤ · dsimp [sInf] simp only [Category.assoc, ← underlyingIso_hom_comp_eq_mk, Iso.cancel_iso_hom_left] - convert limit.w (wideCospan s) (WidePullbackShape.Hom.term _) + convert! limit.w (wideCospan s) (WidePullbackShape.Hom.term _) simp set_option backward.isDefEq.respectTransparency false in diff --git a/Mathlib/CategoryTheory/Triangulated/Adjunction.lean b/Mathlib/CategoryTheory/Triangulated/Adjunction.lean index 1ee6bc76ed0c11..5552fffeb15d10 100644 --- a/Mathlib/CategoryTheory/Triangulated/Adjunction.lean +++ b/Mathlib/CategoryTheory/Triangulated/Adjunction.lean @@ -201,6 +201,7 @@ instance [h : E.inverse.IsTriangulated] : E.symm.functor.IsTriangulated := h lemma mk' (h : E.functor.IsTriangulated) : E.IsTriangulated where rightAdjoint_isTriangulated := E.toAdjunction.isTriangulated_rightAdjoint +set_option backward.isDefEq.respectTransparency false in /-- Constructor for `Equivalence.IsTriangulated`. -/ lemma mk'' (h : E.inverse.IsTriangulated) : E.IsTriangulated where leftAdjoint_isTriangulated := (mk' E.symm h).rightAdjoint_isTriangulated diff --git a/Mathlib/CategoryTheory/Triangulated/LocalizingSubcategory.lean b/Mathlib/CategoryTheory/Triangulated/LocalizingSubcategory.lean index 9c8d3d42ec0c5b..38dca9bf636293 100644 --- a/Mathlib/CategoryTheory/Triangulated/LocalizingSubcategory.lean +++ b/Mathlib/CategoryTheory/Triangulated/LocalizingSubcategory.lean @@ -303,8 +303,7 @@ example : ((A.triangulatedLocalizerMorphism B).localizedFunctor L₁ L₂).Full example : ((A.triangulatedLocalizerMorphism B).localizedFunctor L₁ L₂).Faithful := by infer_instance -instance [A.IsVerdierLeftLocalizing B] [Preadditive D₁] [Preadditive D₂] - [L₁.Additive] [L₂.Additive] : +instance [Preadditive D₁] [Preadditive D₂] [L₁.Additive] [L₂.Additive] : ((A.triangulatedLocalizerMorphism B).localizedFunctor L₁ L₂).Additive := by let F := (A.triangulatedLocalizerMorphism B).localizedFunctor L₁ L₂ rw [Localization.functor_additive_iff L₁ (B.inverseImage A.ι).trW] @@ -316,7 +315,7 @@ instance [A.IsVerdierLeftLocalizing B] [Preadditive D₁] [Preadditive D₂] then the induced functor between the localizations with respect to `(B.inverseImage A.ι).trW` and `B.trW` is fully faithful. -/ @[no_expose] -noncomputable def IsVerdierLeftLocalizing.fullyFaithful [A.IsVerdierLeftLocalizing B] +noncomputable def IsVerdierLeftLocalizing.fullyFaithful {L₁ : A.FullSubcategory ⥤ D₁} {L₂ : C ⥤ D₂} {F : D₁ ⥤ D₂} [L₁.IsLocalization (B.inverseImage A.ι).trW] [L₂.IsLocalization B.trW] (e : L₁ ⋙ F ≅ A.ι ⋙ L₂) : diff --git a/Mathlib/CategoryTheory/Triangulated/Opposite/Triangulated.lean b/Mathlib/CategoryTheory/Triangulated/Opposite/Triangulated.lean index 2d4267693fa464..db98c69fa84153 100644 --- a/Mathlib/CategoryTheory/Triangulated/Opposite/Triangulated.lean +++ b/Mathlib/CategoryTheory/Triangulated/Opposite/Triangulated.lean @@ -53,7 +53,7 @@ scoped instance [IsTriangulated C] : IsTriangulated Cᵒᵖ where exact congr($(Functor.map_injective _ congr($(eq₂).unop)).op).symm · have := op_distinguished _ o.mem dsimp at this - convert this using 2 + convert! this using 2 rw [Category.assoc, Functor.map_comp, Functor.map_comp, ← opShiftFunctorEquivalence_counitIso_hom_app_shift, ← opShiftFunctorEquivalence_counitIso_inv_naturality_assoc, Iso.inv_hom_id_app_assoc] diff --git a/Mathlib/CategoryTheory/Triangulated/Pretriangulated.lean b/Mathlib/CategoryTheory/Triangulated/Pretriangulated.lean index e08e2d2992feb9..30bedde4e50243 100644 --- a/Mathlib/CategoryTheory/Triangulated/Pretriangulated.lean +++ b/Mathlib/CategoryTheory/Triangulated/Pretriangulated.lean @@ -714,7 +714,7 @@ def isoTriangleOfIso₁₃ (T₁ T₂ : Triangle C) (hT₁ : T₁ ∈ distTriang have h₄ := (shiftFunctorCompIsoId C (-1 : ℤ) 1 (by simp)).inv.naturality e₃.hom dsimp at h₁ h₂ h₃ h₄ refine Triangle.isoMk _ _ e₁ (Triangle.π₃.mapIso e) e₃ ?_ ?_ comm - · convert e.hom.comm₂ using 2 + · convert! e.hom.comm₂ using 2 · simp [← cancel_mono ((shiftFunctorCompIsoId C (-1) 1 (neg_add_cancel 1)).inv.app T₂.obj₃), ← h₃, assoc, h₁, h₄] diff --git a/Mathlib/CategoryTheory/Triangulated/SpectralObject.lean b/Mathlib/CategoryTheory/Triangulated/SpectralObject.lean index 8e62b7853cf869..8a698d63feeb9b 100644 --- a/Mathlib/CategoryTheory/Triangulated/SpectralObject.lean +++ b/Mathlib/CategoryTheory/Triangulated/SpectralObject.lean @@ -111,7 +111,7 @@ def precomp : SpectralObject C ι' where dsimp at this ⊢ simp only [← Functor.map_comp_assoc, ← Functor.map_comp, Category.assoc, Iso.inv_hom_id, Functor.map_id, Category.comp_id] at this ⊢ - convert this using 3 + convert! this using 3 · cat_disch · congr 2; cat_disch distinguished' D := by @@ -133,7 +133,7 @@ def precomp : SpectralObject C ι' where rw [← cancel_epi (X.ω₁.map (F.mapComposableArrowsObjMk₁Iso _).inv)] simp only [← Functor.map_comp_assoc, ← Functor.map_comp, Category.assoc, Iso.inv_hom_id, Functor.map_id, Category.id_comp] at this ⊢ - convert this.symm using 3 + convert! this.symm using 3 · congr; cat_disch · cat_disch diff --git a/Mathlib/Combinatorics/Additive/AP/Three/Behrend.lean b/Mathlib/Combinatorics/Additive/AP/Three/Behrend.lean index b6f8bce6902ee3..06729290aae937 100644 --- a/Mathlib/Combinatorics/Additive/AP/Three/Behrend.lean +++ b/Mathlib/Combinatorics/Additive/AP/Three/Behrend.lean @@ -75,7 +75,7 @@ lemma threeAPFree_sphere {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] obtain rfl | hr := eq_or_ne r 0 · rw [sphere_zero] exact threeAPFree_singleton _ - · convert threeAPFree_frontier isClosed_closedBall (strictConvex_closedBall ℝ x r) + · convert! threeAPFree_frontier isClosed_closedBall (strictConvex_closedBall ℝ x r) exact (frontier_closedBall _ hr).symm namespace Behrend @@ -264,7 +264,7 @@ theorem bound_aux' (n d : ℕ) : ((d ^ n :) / (n * d ^ 2 :) : ℝ) ≤ rothNumbe theorem bound_aux (hd : d ≠ 0) (hn : 2 ≤ n) : (d ^ (n - 2 :) / n : ℝ) ≤ rothNumberNat ((2 * d - 1) ^ n) := by - convert bound_aux' n d using 1 + convert! bound_aux' n d using 1 rw [cast_mul, cast_pow, mul_comm, ← div_div, pow_sub₀ _ _ hn, ← div_eq_mul_inv, cast_pow] rwa [cast_ne_zero] diff --git a/Mathlib/Combinatorics/Additive/AP/Three/Defs.lean b/Mathlib/Combinatorics/Additive/AP/Three/Defs.lean index 0de18c194e9c72..5f0abedcd2d889 100644 --- a/Mathlib/Combinatorics/Additive/AP/Three/Defs.lean +++ b/Mathlib/Combinatorics/Additive/AP/Three/Defs.lean @@ -380,7 +380,7 @@ theorem mulRothNumber_map_mul_left : exact (threeGPFree_smul_set.1 hu).le_mulRothNumber hus · obtain ⟨u, hus, hcard, hu⟩ := mulRothNumber_spec s have h : ThreeGPFree (u.map <| mulLeftEmbedding a : Set α) := by rw [coe_map]; exact hu.smul_set - convert h.le_mulRothNumber (map_subset_map.2 hus) using 1 + convert! h.le_mulRothNumber (map_subset_map.2 hus) using 1 rw [card_map, hcard] @[to_additive (attr := simp)] @@ -438,9 +438,9 @@ theorem rothNumberNat_zero : rothNumberNat 0 = 0 := theorem addRothNumber_Ico (a b : ℕ) : addRothNumber (Ico a b) = rothNumberNat (b - a) := by obtain h | h := le_total b a · rw [Nat.sub_eq_zero_of_le h, Ico_eq_empty_of_le h, rothNumberNat_zero, addRothNumber_empty] - convert addRothNumber_map_add_left _ a + convert! addRothNumber_map_add_left _ a rw [range_eq_Ico, map_eq_image] - convert (image_add_left_Ico 0 (b - a) _).symm + convert! (image_add_left_Ico 0 (b - a) _).symm exact (add_tsub_cancel_of_le h).symm open Fin.NatCast in -- TODO: should this be refactored to avoid needing the coercion? diff --git a/Mathlib/Combinatorics/Additive/Corner/Roth.lean b/Mathlib/Combinatorics/Additive/Corner/Roth.lean index 4582bd977354ab..b012b8b6a77b39 100644 --- a/Mathlib/Combinatorics/Additive/Corner/Roth.lean +++ b/Mathlib/Combinatorics/Additive/Corner/Roth.lean @@ -92,7 +92,7 @@ theorem corners_theorem (ε : ℝ) (hε : 0 < ε) (hG : cornersTheoremBound ε classical have h₁ := (farFromTriangleFree_graph hAε).le_card_cliqueFinset rw [card_triangles, card_triangleIndices] at h₁ - convert h₁.trans (Nat.cast_le.2 <| card_le_univ _) using 1 <;> simp <;> ring + convert! h₁.trans (Nat.cast_le.2 <| card_le_univ _) using 1 <;> simp <;> ring open Fin.NatCast in -- TODO: refactor to avoid needing the coercion /-- The **corners theorem** for `ℕ`. diff --git a/Mathlib/Combinatorics/Additive/FreimanHom.lean b/Mathlib/Combinatorics/Additive/FreimanHom.lean index f03f52ab44c1af..8c79ce0b64639a 100644 --- a/Mathlib/Combinatorics/Additive/FreimanHom.lean +++ b/Mathlib/Combinatorics/Additive/FreimanHom.lean @@ -455,9 +455,9 @@ assuming there is no wrap-around. -/ lemma isAddFreimanIso_Iio (hm : m ≠ 0) (hkmn : m * k ≤ n) : IsAddFreimanIso m (Iio (k : Fin (n + 1))) (Iio k) val := by obtain _ | k := k - · simp [← bot_eq_zero] + · simp have hkmn' : m * k ≤ n := (Nat.mul_le_mul_left _ k.le_succ).trans hkmn - convert isAddFreimanIso_Iic hm hkmn' using 1 <;> ext x + convert! isAddFreimanIso_Iic hm hkmn' using 1 <;> ext x · simp only [Nat.cast_add, Nat.cast_one, mem_Iio, lt_def, mem_Iic, le_iff_val_le_val, val_natCast, aux hm hkmn', Nat.mod_eq_of_lt] simp_rw [← Nat.cast_add_one] diff --git a/Mathlib/Combinatorics/Additive/VerySmallDoubling.lean b/Mathlib/Combinatorics/Additive/VerySmallDoubling.lean index 070ac20a2ddf91..5bfc35e3788361 100644 --- a/Mathlib/Combinatorics/Additive/VerySmallDoubling.lean +++ b/Mathlib/Combinatorics/Additive/VerySmallDoubling.lean @@ -166,7 +166,7 @@ def invMulSubgroup (A : Finset G) (h : #(A * A) < (3 / 2 : ℚ) * #A) : Subgroup mul_mem' := by norm_cast have h₁ x (hx : x ∈ A) y (hy : y ∈ A) : (1 / 2 : ℚ) * #A < #(x • A ∩ y • A) := by - convert lt_card_smul_inter_smul (by simpa using Rat.cast_strictMono (K := ℝ) h) hx hy + convert! lt_card_smul_inter_smul (by simpa using Rat.cast_strictMono (K := ℝ) h) hx hy norm_num simp [← Rat.cast_lt (K := ℝ)] intro a c ha hc @@ -210,7 +210,7 @@ private lemma weak_invMulSubgroup_bound (h : #(A * A) < (3 / 2 : ℚ) * #A) : #(A⁻¹ * A) < 2 * #A := by have h₀ : A.Nonempty := nonempty_of_doubling h have h₁ a (ha : a ∈ A⁻¹ * A) : (1 / 2 : ℚ) * #A < #{xy ∈ A ×ˢ A | xy.1 * xy.2⁻¹ = a} := by - convert lt_card_mul_inv_eq (by simpa using Rat.cast_strictMono (K := ℝ) h) ha + convert! lt_card_mul_inv_eq (by simpa using Rat.cast_strictMono (K := ℝ) h) ha norm_num simp [← Rat.cast_lt (K := ℝ)] have h₂ : ∀ x ∈ A ×ˢ A, (fun ⟨x, y⟩ => x * y⁻¹) x ∈ A⁻¹ * A := by diff --git a/Mathlib/Combinatorics/Configuration.lean b/Mathlib/Combinatorics/Configuration.lean index a809cc259505d1..2b1f5a6ad5d985 100644 --- a/Mathlib/Combinatorics/Configuration.lean +++ b/Mathlib/Combinatorics/Configuration.lean @@ -450,7 +450,7 @@ theorem card_points [Fintype P] [Finite L] : Fintype.card P = order P L ^ 2 + or classical have h1 : Fintype.card { q // q ≠ p } + 1 = Fintype.card P := by apply (eq_tsub_iff_add_eq_of_le (Nat.succ_le_of_lt (Fintype.card_pos_iff.mpr ⟨p⟩))).mp - convert (Fintype.card_subtype_compl _).trans (congr_arg _ (Fintype.card_subtype_eq p)) + convert! (Fintype.card_subtype_compl _).trans (congr_arg _ (Fintype.card_subtype_eq p)) have h2 : ∀ l : { l : L // p ∈ l }, Fintype.card { q // q ∈ l.1 ∧ q ≠ p } = order P L := by intro l rw [← Fintype.card_congr (Equiv.subtypeSubtypeEquivSubtypeInter (· ∈ l.val) (· ≠ p)), diff --git a/Mathlib/Combinatorics/Enumerative/Bell.lean b/Mathlib/Combinatorics/Enumerative/Bell.lean index 51de56b170f4f0..00f5a2ddd4ba94 100644 --- a/Mathlib/Combinatorics/Enumerative/Bell.lean +++ b/Mathlib/Combinatorics/Enumerative/Bell.lean @@ -158,7 +158,7 @@ theorem uniformBell_one_right (m : ℕ) : uniformBell m 1 = 1 := by theorem uniformBell_mul_eq (m : ℕ) {n : ℕ} (hn : n ≠ 0) : uniformBell m n * n ! ^ m * m ! = (m * n)! := by - convert bell_mul_eq (replicate m n) + convert! bell_mul_eq (replicate m n) · simp only [map_replicate, prod_replicate] · simp only [toFinset_replicate] split_ifs with hm diff --git a/Mathlib/Combinatorics/Enumerative/Composition.lean b/Mathlib/Combinatorics/Enumerative/Composition.lean index 50787ee346fbb7..6c8de532b72c78 100644 --- a/Mathlib/Combinatorics/Enumerative/Composition.lean +++ b/Mathlib/Combinatorics/Enumerative/Composition.lean @@ -222,7 +222,7 @@ theorem sizeUpTo_zero : c.sizeUpTo 0 = 0 := by simp [sizeUpTo] theorem sizeUpTo_ofLength_le (i : ℕ) (h : c.length ≤ i) : c.sizeUpTo i = n := by dsimp [sizeUpTo] - convert c.blocks_sum + convert! c.blocks_sum exact take_of_length_le h @[simp] @@ -446,6 +446,11 @@ theorem sigma_eq_iff_blocks_eq {c : Σ n, Composition n} {c' : Σ n, Composition ext1 exact H +@[to_additive] +lemma prod_prod_apply_embedding {A : Type*} [CommMonoid A] (a : Fin n → A) (x : Composition n) : + ∏ i, ∏ j, a (x.embedding i j) = ∏ i, a i := by + simpa [Finset.prod_sigma', Finset.univ_sigma_univ] using x.blocksFinEquiv.prod_comp a + /-! ### The composition `Composition.ones` -/ @@ -667,7 +672,7 @@ def recOnAppendSingle {motive : ∀ n, Composition n → Sort*} {n : ℕ} (c : C motive (n + (k + 1)) (append c (single (k + 1) k.succ_pos))) : motive n c := reverse_reverse c ▸ c.reverse.recOnSingleAppend zero fun k n c ih ↦ by - convert append_single k n c.reverse ih using 1 + convert! append_single k n c.reverse ih using 1 · apply add_comm · rw [reverse_append, reverse_single] apply cast_heq @@ -826,7 +831,7 @@ def compositionAsSetEquiv (n : ℕ) : CompositionAsSet n ≃ Finset (Fin (n - 1) · rintro (rfl | rfl | ⟨j, hj1, hj2⟩) · exact c.zero_mem · exact c.getLast_mem - · convert hj1 + · convert! hj1 · simp only [or_iff_not_imp_left, ← ne_eq, ← Fin.exists_succ_eq] rintro i_mem ⟨j, rfl⟩ i_ne_last rcases Nat.exists_add_one_eq.mpr j.pos with ⟨n, rfl⟩ @@ -888,7 +893,7 @@ theorem boundary_zero : (c.boundary ⟨0, c.card_boundaries_pos⟩ : Fin (n + 1) @[simp] theorem boundary_length : c.boundary ⟨c.length, c.length_lt_card_boundaries⟩ = Fin.last n := by - convert Finset.orderEmbOfFin_last rfl c.card_boundaries_pos + convert! Finset.orderEmbOfFin_last rfl c.card_boundaries_pos exact le_antisymm (Finset.le_max' _ _ c.getLast_mem) (Fin.le_last _) /-- Size of the `i`-th block in a `CompositionAsSet`, seen as a function on `Fin c.length`. -/ @@ -931,7 +936,7 @@ theorem mem_boundaries_iff_exists_blocks_sum_take_eq {j : Fin (n + 1)} : rw [← hi, c.blocks_partial_sum i.2] rfl · rintro ⟨i, hi, H⟩ - convert (c.boundaries.orderIsoOfFin rfl ⟨i, hi⟩).2 + convert! (c.boundaries.orderIsoOfFin rfl ⟨i, hi⟩).2 have : c.boundary ⟨i, hi⟩ = j := by rwa [Fin.ext_iff, ← c.blocks_partial_sum hi] exact this.symm diff --git a/Mathlib/Combinatorics/Enumerative/DyckWord.lean b/Mathlib/Combinatorics/Enumerative/DyckWord.lean index fa5d2d4584f561..bfe4d869675eef 100644 --- a/Mathlib/Combinatorics/Enumerative/DyckWord.lean +++ b/Mathlib/Combinatorics/Enumerative/DyckWord.lean @@ -244,7 +244,7 @@ lemma semilength_eq_count_D : p.semilength = p.toList.count D := by @[simp] lemma two_mul_semilength_eq_length : 2 * p.semilength = p.toList.length := by nth_rw 1 [two_mul, semilength, p.count_U_eq_count_D, semilength] - convert (p.toList.length_eq_countP_add_countP (· == D)).symm + convert! (p.toList.length_eq_countP_add_countP (· == D)).symm rw [count]; congr!; rename_i s; cases s <;> tauto end Semilength @@ -365,7 +365,7 @@ lemma outsidePart_add : (p + q).outsidePart = p.outsidePart + q := by @[simp] lemma insidePart_nest : p.nest.insidePart = p := by simp_rw [insidePart, nest_ne_zero, dite_false, firstReturn_nest] - convert p.denest_nest; rw [DyckWord.ext_iff]; apply take_of_length_le + convert! p.denest_nest; rw [DyckWord.ext_iff]; apply take_of_length_le simp_rw [nest, length_append, length_singleton]; lia @[simp] @@ -545,7 +545,7 @@ instance {n : ℕ} : Fintype { p : DyckWord // p.semilength = n } := theorem card_dyckWord_semilength_eq_catalan (n : ℕ) : Fintype.card { p : DyckWord // p.semilength = n } = catalan n := by rw [← Fintype.ofEquiv_card (equivTreesOfNumNodesEq n), ← treesOfNumNodesEq_card_eq_catalan] - convert Fintype.card_coe _ + convert! Fintype.card_coe _ end Tree diff --git a/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean b/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean index 6431aeb4db4971..453228069c5c0a 100644 --- a/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean +++ b/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean @@ -575,7 +575,7 @@ set_option backward.isDefEq.respectTransparency false in O'Donnell. -/ lemma moebius_inversion_bot (f g : α → 𝕜) (h : ∀ x, g x = ∑ y ∈ Iic x, f y) (x : α) : f x = ∑ y ∈ Iic x, mu 𝕜 y x * g y := by - convert moebius_inversion_top (α := αᵒᵈ) f g h x using 3 + convert! moebius_inversion_top (α := αᵒᵈ) f g h x using 3 rw [← mu_toDual]; rfl end InversionBot diff --git a/Mathlib/Combinatorics/Enumerative/InclusionExclusion.lean b/Mathlib/Combinatorics/Enumerative/InclusionExclusion.lean index f7e31563ffc173..6758df6efd0420 100644 --- a/Mathlib/Combinatorics/Enumerative/InclusionExclusion.lean +++ b/Mathlib/Combinatorics/Enumerative/InclusionExclusion.lean @@ -105,7 +105,7 @@ variable [DecidableEq α] lemma prod_indicator_biUnion_finset_sub_indicator (hs : s.Nonempty) (S : ι → Finset α) (a : α) : ∏ i ∈ s, (Set.indicator (s.biUnion S) 1 a - Set.indicator (S i) 1 a) = (0 : ℤ) := by - convert prod_indicator_biUnion_sub_indicator hs (fun i ↦ S i) a + convert! prod_indicator_biUnion_sub_indicator hs (fun i ↦ S i) a simp /-- **Inclusion-exclusion principle** for the sum of a function over a union. diff --git a/Mathlib/Combinatorics/Enumerative/Partition/Basic.lean b/Mathlib/Combinatorics/Enumerative/Partition/Basic.lean index 6ce7063d65d58b..4bb7639e6fa7b9 100644 --- a/Mathlib/Combinatorics/Enumerative/Partition/Basic.lean +++ b/Mathlib/Combinatorics/Enumerative/Partition/Basic.lean @@ -154,7 +154,7 @@ theorem toFinsuppAntidiag_mem_finsuppAntidiag {n : ℕ} (p : Partition n) : have hp : p.parts.toFinset ⊆ Finset.Icc 1 n := by grind suffices ∑ m ∈ Finset.Icc 1 n, Multiset.count m p.parts * m = n by simpa [toFinsuppAntidiag, hp] - convert ← p.parts_sum + convert! ← p.parts_sum rw [Finset.sum_multiset_count] apply Finset.sum_subset hp suffices ∀ (x : ℕ), 1 ≤ x → x ≤ n → x ∉ p.parts → x ∉ p.parts ∨ x = 0 by simpa diff --git a/Mathlib/Combinatorics/Enumerative/Partition/Glaisher.lean b/Mathlib/Combinatorics/Enumerative/Partition/Glaisher.lean index 3337736c91f361..fbe261a305a3db 100644 --- a/Mathlib/Combinatorics/Enumerative/Partition/Glaisher.lean +++ b/Mathlib/Combinatorics/Enumerative/Partition/Glaisher.lean @@ -50,7 +50,7 @@ theorem hasProd_powerSeriesMk_card_restricted [IsTopologicalSemiring R] (p : ℕ → Prop) [DecidablePred p] : HasProd (fun i ↦ if p (i + 1) then ∑' j : ℕ, X ^ ((i + 1) * j) else 1) (PowerSeries.mk fun n ↦ (#(restricted n p) : R)) := by - convert hasProd_genFun (fun i c ↦ if p i then (1 : R) else 0) using 1 + convert! hasProd_genFun (fun i c ↦ if p i then (1 : R) else 0) using 1 · ext1 i split_ifs · rw [tsum_eq_zero_add' ?_] @@ -81,7 +81,7 @@ theorem hasProd_powerSeriesMk_card_countRestricted {m : ℕ} (hm : 0 < m) : HasProd (fun i ↦ ∑ j ∈ range m, X ^ ((i + 1) * j)) (PowerSeries.mk fun n ↦ (#(countRestricted n m) : R)) := by nontriviality R using Subsingleton.eq_one - convert hasProd_genFun (fun i c ↦ if c < m then (1 : R) else 0) using 1 + convert! hasProd_genFun (fun i c ↦ if c < m then (1 : R) else 0) using 1 · ext1 i rw [sum_range_eq_add_Ico _ hm, sum_Ico_eq_sum_range] congrm $(by simp) + ?_ diff --git a/Mathlib/Combinatorics/Graph/Basic.lean b/Mathlib/Combinatorics/Graph/Basic.lean index 08c8020b193b3e..ee688ac483754e 100644 --- a/Mathlib/Combinatorics/Graph/Basic.lean +++ b/Mathlib/Combinatorics/Graph/Basic.lean @@ -354,7 +354,7 @@ to the definition of `Graph`, so it doesn't require equality of the edge sets.) protected lemma ext {G₁ G₂ : Graph α β} (hV : V(G₁) = V(G₂)) (h : ∀ e x y, G₁.IsLink e x y ↔ G₂.IsLink e x y) : G₁ = G₂ := by rw [← G₁.mk_eq_self G₁.edge_mem_iff_exists_isLink, ← G₂.mk_eq_self G₂.edge_mem_iff_exists_isLink] - convert rfl using 2 + convert! rfl using 2 · exact hV.symm · simp [funext_iff, h] simp [edgeSet_eq_setOf_exists_isLink, h] diff --git a/Mathlib/Combinatorics/HalesJewett.lean b/Mathlib/Combinatorics/HalesJewett.lean index a897b271a1a7f4..bde1cc7b15b7d5 100644 --- a/Mathlib/Combinatorics/HalesJewett.lean +++ b/Mathlib/Combinatorics/HalesJewett.lean @@ -496,7 +496,7 @@ theorem exists_mono_in_high_dimension (α κ η) [Finite α] [Finite κ] [Finite refine ⟨ι × Shrink η, inferInstance, fun C ↦ ?_⟩ obtain ⟨l, hl⟩ := hι fun x ↦ C fun (i, e) ↦ x i e refine ⟨l.toSubspace.reindex (equivShrink.{0} η).symm (Equiv.refl _) (Equiv.refl _), ?_⟩ - convert hl.toSubspace.reindex + convert! hl.toSubspace.reindex simp /-- A variant of the **extended Hales-Jewett theorem** `exists_mono_in_high_dimension` where the diff --git a/Mathlib/Combinatorics/Hall/Basic.lean b/Mathlib/Combinatorics/Hall/Basic.lean index b9b392f5060a53..5d7cb118a5f2c8 100644 --- a/Mathlib/Combinatorics/Hall/Basic.lean +++ b/Mathlib/Combinatorics/Hall/Basic.lean @@ -77,7 +77,7 @@ theorem hallMatchingsOn.nonempty {ι : Type u} {α : Type v} [DecidableEq α] (t refine ⟨Classical.indefiniteDescription _ ?_⟩ apply (all_card_le_biUnion_card_iff_existsInjective' fun i : ι' => t i).mp intro s' - convert h (s'.image (↑)) using 1 + convert! h (s'.image (↑)) using 1 · simp only [card_image_of_injective s' Subtype.coe_injective] · rw [image_biUnion] diff --git a/Mathlib/Combinatorics/Hall/Finite.lean b/Mathlib/Combinatorics/Hall/Finite.lean index 9ca804a778207b..3bd50b4a414a08 100644 --- a/Mathlib/Combinatorics/Hall/Finite.lean +++ b/Mathlib/Combinatorics/Hall/Finite.lean @@ -59,7 +59,7 @@ theorem hall_cond_of_erase {x : ι} (a : α) rw [image_nonempty, Finset.card_image_of_injective s' Subtype.coe_injective] at ha by_cases! he : s'.Nonempty · have ha' : #s' < #(s'.biUnion fun x => t x) := by - convert ha he fun h => by simpa [← h] using mem_univ x using 2 + convert! ha he fun h => by simpa [← h] using mem_univ x using 2 ext x simp only [mem_image, mem_biUnion, SetCoe.exists, exists_and_right, exists_eq_right] @@ -126,7 +126,7 @@ theorem hall_cond_of_restrict {ι : Type u} {t : ι → Finset α} {s : Finset #s' ≤ #(s'.biUnion fun a' => t a') := by classical rw [← card_image_of_injective s' Subtype.coe_injective] - convert ht (s'.image fun z => z.1) using 1 + convert! ht (s'.image fun z => z.1) using 1 apply congr_arg ext y simp diff --git a/Mathlib/Combinatorics/Hindman.lean b/Mathlib/Combinatorics/Hindman.lean index 7b45cb3734a45f..b22fbe7516e534 100644 --- a/Mathlib/Combinatorics/Hindman.lean +++ b/Mathlib/Combinatorics/Hindman.lean @@ -146,7 +146,7 @@ theorem exists_idempotent_ultrafilter_le_FP {M} [Semigroup M] (a : Stream' M) : have h := exists_idempotent_in_compact_subsemigroup ?_ S ?_ ?_ ?_ · rcases h with ⟨U, hU, U_idem⟩ refine ⟨U, U_idem, ?_⟩ - convert Set.mem_iInter.mp hU 0 + convert! Set.mem_iInter.mp hU 0 · exact Ultrafilter.continuous_mul_left · apply IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed · intro n U hU @@ -250,7 +250,7 @@ theorem FP.mul_two {M} [Semigroup M] (a : Stream' M) (i j : ℕ) (ij : i < j) : rcases Nat.exists_eq_add_of_le (Nat.succ_le_of_lt ij) with ⟨d, hd⟩ have := FP.singleton (a.drop i).tail d rw [Stream'.tail_eq_drop, Stream'.get_drop, Stream'.get_drop] at this - convert this + convert! this lia @[to_additive] diff --git a/Mathlib/Combinatorics/Matroid/Basic.lean b/Mathlib/Combinatorics/Matroid/Basic.lean index 302fa328680035..d776d78b5dd7d7 100644 --- a/Mathlib/Combinatorics/Matroid/Basic.lean +++ b/Mathlib/Combinatorics/Matroid/Basic.lean @@ -827,7 +827,7 @@ theorem IsBasis.subset_ground (hI : M.IsBasis I X) : X ⊆ M.E := hI.2 theorem IsBasis.isBasis_inter_ground (hI : M.IsBasis I X) : M.IsBasis I (X ∩ M.E) := by - convert hI + convert! hI rw [inter_eq_self_of_subset_left hI.subset_ground] @[aesop unsafe 15% (rule_sets := [Matroid])] @@ -1003,7 +1003,7 @@ theorem IsBasis.iUnion_isBasis_iUnion {ι : Type _} (X I : ι → Set α) theorem IsBasis.isBasis_iUnion {ι : Type _} [Nonempty ι] (X : ι → Set α) (hI : ∀ i, M.IsBasis I (X i)) : M.IsBasis I (⋃ i, X i) := by - convert IsBasis.iUnion_isBasis_iUnion X (fun _ ↦ I) (fun i ↦ hI i) _ <;> rw [iUnion_const] + convert! IsBasis.iUnion_isBasis_iUnion X (fun _ ↦ I) (fun i ↦ hI i) _ <;> rw [iUnion_const] exact (hI (Classical.arbitrary ι)).indep theorem IsBasis.isBasis_sUnion {Xs : Set (Set α)} (hne : Xs.Nonempty) @@ -1028,11 +1028,11 @@ theorem IsBasis.union_isBasis_union (hIX : M.IsBasis I X) (hJY : M.IsBasis J Y) theorem IsBasis.isBasis_union (hIX : M.IsBasis I X) (hIY : M.IsBasis I Y) : M.IsBasis I (X ∪ Y) := by - convert hIX.union_isBasis_union hIY _ <;> rw [union_self]; exact hIX.indep + convert! hIX.union_isBasis_union hIY _ <;> rw [union_self]; exact hIX.indep theorem IsBasis.isBasis_union_of_subset (hI : M.IsBasis I X) (hJ : M.Indep J) (hIJ : I ⊆ J) : M.IsBasis J (J ∪ X) := by - convert hJ.isBasis_self.union_isBasis_union hI _ <;> + convert! hJ.isBasis_self.union_isBasis_union hI _ <;> rw [union_eq_self_of_subset_right hIJ] assumption diff --git a/Mathlib/Combinatorics/Matroid/Circuit.lean b/Mathlib/Combinatorics/Matroid/Circuit.lean index 4605ef5e10bf37..65f5e8634856d9 100644 --- a/Mathlib/Combinatorics/Matroid/Circuit.lean +++ b/Mathlib/Combinatorics/Matroid/Circuit.lean @@ -580,7 +580,7 @@ lemma isCocircuit_iff_minimal : /-- A cocircuit is a minimal set whose complement is nonspanning. -/ lemma isCocircuit_iff_minimal_compl_nonspanning : M.IsCocircuit K ↔ Minimal (fun X ↦ ¬ M.Spanning (M.E \ X)) K := by - convert isCocircuit_iff_minimal with K + convert! isCocircuit_iff_minimal with K rw [spanning_iff_exists_isBase_subset] simp_rw [not_exists, subset_diff, not_and, not_disjoint_iff_nonempty_inter, ← and_imp, and_iff_left_of_imp IsBase.subset_ground, inter_comm K] diff --git a/Mathlib/Combinatorics/Matroid/Closure.lean b/Mathlib/Combinatorics/Matroid/Closure.lean index f9ab0a7f0b2ace..994aa22251fe46 100644 --- a/Mathlib/Combinatorics/Matroid/Closure.lean +++ b/Mathlib/Combinatorics/Matroid/Closure.lean @@ -106,7 +106,7 @@ lemma IsFlat.iInter {ι : Type*} [Nonempty ι] {Fs : ι → Set α} (iInter_subset _ (Classical.arbitrary _)).trans (hFs _).subset_ground⟩ obtain ⟨J, hIJ, hJ⟩ := hI.indep.subset_isBasis_of_subset (hI.subset.trans (iInter_subset _ i)) refine subset_union_right.trans ((hFs i).1 (X := Fs i ∪ X) hIJ ?_) - convert hIJ.isBasis_union (hIX.isBasis_union_of_subset hIJ.indep hJ) using 1 + convert! hIJ.isBasis_union (hIX.isBasis_union_of_subset hIJ.indep hJ) using 1 rw [← union_assoc, union_eq_self_of_subset_right hIJ.subset] /-- The property of being a flat gives rise to a `ClosureOperator` on the subsets of `M.E`, @@ -118,7 +118,7 @@ def subtypeClosure (M : Matroid α) : ClosureOperator (Iic M.E) := obtain (rfl | hne) := s.eq_empty_or_nonempty · simp have _ := hne.coe_sort - convert IsFlat.iInter (M := M) (Fs := fun (F : s) ↦ F.1.1) (fun F ↦ hs F.1 F.2) + convert! IsFlat.iInter (M := M) (Fs := fun (F : s) ↦ F.1.1) (fun F ↦ hs F.1 F.2) ext aesop @@ -243,7 +243,7 @@ lemma mem_ground_of_mem_closure (he : e ∈ M.closure X) : e ∈ M.E := lemma closure_iUnion_closure_eq_closure_iUnion (M : Matroid α) (Xs : ι → Set α) : M.closure (⋃ i, M.closure (Xs i)) = M.closure (⋃ i, Xs i) := by simp_rw [closure_eq_subtypeClosure, iUnion_inter, Subtype.coe_inj] - convert M.subtypeClosure.closure_iSup_closure (fun i ↦ ⟨Xs i ∩ M.E, inter_subset_right⟩) <;> + convert! M.subtypeClosure.closure_iSup_closure (fun i ↦ ⟨Xs i ∩ M.E, inter_subset_right⟩) <;> simp [← iUnion_inter, subtypeClosure] lemma closure_iUnion_congr (Xs Ys : ι → Set α) (h : ∀ i, M.closure (Xs i) = M.closure (Ys i)) : @@ -489,8 +489,9 @@ lemma Indep.closure_sInter_eq_biInter_closure_of_forall_subset {Js : Set (Set α lemma closure_iInter_eq_iInter_closure_of_iUnion_indep [hι : Nonempty ι] (Is : ι → Set α) (h : M.Indep (⋃ i, Is i)) : M.closure (⋂ i, Is i) = (⋂ i, M.closure (Is i)) := by - convert h.closure_sInter_eq_biInter_closure_of_forall_subset (range_nonempty Is) - (by simp [subset_iUnion]) + convert! + h.closure_sInter_eq_biInter_closure_of_forall_subset (range_nonempty Is) + (by simp [subset_iUnion]) simp lemma closure_sInter_eq_biInter_closure_of_sUnion_indep (Is : Set (Set α)) (hIs : Is.Nonempty) @@ -501,7 +502,7 @@ lemma closure_biInter_eq_biInter_closure_of_biUnion_indep {ι : Type*} {A : Set {I : ι → Set α} (h : M.Indep (⋃ i ∈ A, I i)) : M.closure (⋂ i ∈ A, I i) = ⋂ i ∈ A, M.closure (I i) := by have := hA.coe_sort - convert closure_iInter_eq_iInter_closure_of_iUnion_indep (Is := fun i : A ↦ I i) (by simpa) <;> + convert! closure_iInter_eq_iInter_closure_of_iUnion_indep (Is := fun i : A ↦ I i) (by simpa) <;> simp lemma Indep.closure_iInter_eq_biInter_closure_of_forall_subset [Nonempty ι] {Js : ι → Set α} @@ -525,8 +526,9 @@ lemma Indep.inter_isBasis_biInter {ι : Type*} (hI : M.Indep I) {X : ι → Set lemma Indep.inter_isBasis_iInter [Nonempty ι] {X : ι → Set α} (hI : M.Indep I) (h : ∀ i, M.IsBasis ((X i) ∩ I) (X i)) : M.IsBasis ((⋂ i, X i) ∩ I) (⋂ i, X i) := by - convert hI.inter_isBasis_biInter (ι := PLift ι) univ_nonempty (X := fun i ↦ X i.down) - (by simpa using fun (i : PLift ι) ↦ h i.down) <;> + convert! + hI.inter_isBasis_biInter (ι := PLift ι) univ_nonempty (X := fun i ↦ X i.down) + (by simpa using fun (i : PLift ι) ↦ h i.down) <;> · simp only [mem_univ, iInter_true] exact (iInter_plift_down X).symm @@ -596,7 +598,7 @@ lemma indep_iff_forall_notMem_closure_diff (hI : I ⊆ M.E := by aesop_mat) : use fun h e heI he ↦ ((h.closure_inter_eq_self_of_subset diff_subset).subset ⟨he, heI⟩).2 rfl intro h obtain ⟨J, hJ⟩ := M.exists_isBasis I - convert hJ.indep + convert! hJ.indep refine hJ.subset.antisymm' (fun e he ↦ by_contra fun heJ ↦ h he ?_) exact mem_of_mem_of_subset (hJ.subset_closure he) (M.closure_subset_closure (subset_diff_singleton hJ.subset heJ)) diff --git a/Mathlib/Combinatorics/Matroid/Dual.lean b/Mathlib/Combinatorics/Matroid/Dual.lean index 4acdb3ebb8692e..fea37ed95c0f65 100644 --- a/Mathlib/Combinatorics/Matroid/Dual.lean +++ b/Mathlib/Combinatorics/Matroid/Dual.lean @@ -61,7 +61,7 @@ section dual rw [← compl_subset_compl, ← hIB.sdiff_eq_right, ← union_diff_distrib, diff_eq, compl_inter, compl_compl, union_subset_iff, compl_subset_compl] at hB''₂ have hssu := (subset_inter (hB''₂.2) hIE).ssubset_of_ne - (by { rintro rfl; apply hI; convert hB''; simp [hB''.subset_ground] }) + (by { rintro rfl; apply hI; convert! hB''; simp [hB''.subset_ground] }) obtain ⟨e, ⟨(heB'' : e ∉ _), heE⟩, heI⟩ := exists_of_ssubset hssu use e simp_rw [mem_diff, insert_subset_iff, and_iff_left heI, and_iff_right heE, and_iff_right hIE] diff --git a/Mathlib/Combinatorics/Matroid/Loop.lean b/Mathlib/Combinatorics/Matroid/Loop.lean index bd9db75e142659..97b1e55756a990 100644 --- a/Mathlib/Combinatorics/Matroid/Loop.lean +++ b/Mathlib/Combinatorics/Matroid/Loop.lean @@ -365,7 +365,7 @@ lemma IsNonloop.isNonloop_of_mem_closure (he : M.IsNonloop e) (hef : e ∈ M.clo M.IsNonloop f := by rw [isNonloop_iff, and_comm] by_contra! h; apply he.not_isLoop - rw [isLoop_iff] at *; convert hef using 1 + rw [isLoop_iff] at *; convert! hef using 1 obtain (hf | hf) := em (f ∈ M.E) · rw [← closure_loops, ← insert_eq_of_mem (h hf), closure_insert_congr_right M.closure_loops, insert_empty_eq] diff --git a/Mathlib/Combinatorics/Matroid/Sum.lean b/Mathlib/Combinatorics/Matroid/Sum.lean index b933c19b6905e5..02ed7cc23695e2 100644 --- a/Mathlib/Combinatorics/Matroid/Sum.lean +++ b/Mathlib/Combinatorics/Matroid/Sum.lean @@ -143,7 +143,7 @@ lemma Finitary.sigma (h : ∀ i, (M i).Finitary) : (Matroid.sigma M).Finitary := intro i apply indep_of_forall_finite_subset_indep intro J hJI hJ - convert hI (Sigma.mk i '' J) (by simpa) (hJ.image _) i + convert! hI (Sigma.mk i '' J) (by simpa) (hJ.image _) i rw [sigma_mk_preimage_image_eq_self] end Sigma @@ -160,7 +160,7 @@ protected def sum' (M : ι → Matroid α) : Matroid (ι × α) := @[simp] lemma sum'_indep_iff {I} : (Matroid.sum' M).Indep I ↔ ∀ i, (M i).Indep (Prod.mk i ⁻¹' I) := by simp only [Matroid.sum', mapEquiv_indep_iff, Equiv.sigmaEquivProd_symm_apply, sigma_indep_iff] - convert Iff.rfl + convert! Iff.rfl ext simp @@ -172,14 +172,14 @@ protected def sum' (M : ι → Matroid α) : Matroid (ι × α) := @[simp] lemma sum'_isBase_iff {B} : (Matroid.sum' M).IsBase B ↔ ∀ i, (M i).IsBase (Prod.mk i ⁻¹' B) := by simp only [Matroid.sum', mapEquiv_isBase_iff, Equiv.sigmaEquivProd_symm_apply, sigma_isBase_iff] - convert Iff.rfl + convert! Iff.rfl ext simp @[simp] lemma sum'_isBasis_iff {I X} : (Matroid.sum' M).IsBasis I X ↔ ∀ i, (M i).IsBasis (Prod.mk i ⁻¹' I) (Prod.mk i ⁻¹' X) := by simp only [Matroid.sum', mapEquiv_isBasis_iff, Equiv.sigmaEquivProd_symm_apply, sigma_isBasis_iff] - convert Iff.rfl <;> + convert! Iff.rfl <;> exact ext <| by simp lemma Finitary.sum' (h : ∀ i, (M i).Finitary) : (Matroid.sum' M).Finitary := by @@ -242,7 +242,7 @@ set_option backward.isDefEq.respectTransparency false in (M.sum N).Indep I ↔ M.Indep (.inl ⁻¹' I) ∧ N.Indep (.inr ⁻¹' I) := by simp only [Matroid.sum, mapEquiv_indep_iff, Equiv.sumCongr_symm, Equiv.sumCongr_apply, Equiv.symm_symm, sigma_indep_iff, Bool.forall_bool] - convert Iff.rfl <;> + convert! Iff.rfl <;> simp [Set.ext_iff, Equiv.ulift, Equiv.sumEquivSigmaBool] set_option backward.isDefEq.respectTransparency false in @@ -250,7 +250,7 @@ set_option backward.isDefEq.respectTransparency false in (M.sum N).IsBase B ↔ M.IsBase (.inl ⁻¹' B) ∧ N.IsBase (.inr ⁻¹' B) := by simp only [Matroid.sum, mapEquiv_isBase_iff, Equiv.sumCongr_symm, Equiv.sumCongr_apply, Equiv.symm_symm, sigma_isBase_iff, Bool.forall_bool] - convert Iff.rfl <;> + convert! Iff.rfl <;> simp [Set.ext_iff, Equiv.ulift, Equiv.sumEquivSigmaBool] set_option backward.isDefEq.respectTransparency false in @@ -260,7 +260,7 @@ set_option backward.isDefEq.respectTransparency false in simp only [Matroid.sum, mapEquiv_isBasis_iff, Equiv.sumCongr_symm, Equiv.sumCongr_apply, Equiv.symm_symm, sigma_isBasis_iff, Bool.forall_bool, Equiv.sumEquivSigmaBool, Equiv.coe_fn_mk, Equiv.ulift] - convert Iff.rfl <;> exact ext <| by simp + convert! Iff.rfl <;> exact ext <| by simp end Sum diff --git a/Mathlib/Combinatorics/Nullstellensatz.lean b/Mathlib/Combinatorics/Nullstellensatz.lean index 12ebec3ddbbb7c..ab6494d1647864 100644 --- a/Mathlib/Combinatorics/Nullstellensatz.lean +++ b/Mathlib/Combinatorics/Nullstellensatz.lean @@ -78,14 +78,14 @@ theorem eq_zero_of_eval_zero_at_prod_finset {σ : Type*} [Finite σ] [IsDomain R apply h _ (fun i ↦ S (e i)) · intro i classical - convert Hdeg (e i) + convert! Hdeg (e i) conv_lhs => rw [← e.symm_apply_apply i, degreeOf_rename_of_injective e.symm.injective] · intro x hx simp only [MvPolynomial.eval_rename] apply Heval intro s simp only [Function.comp_apply] - convert hx (e.symm s) + convert! hx (e.symm s) simp only [Equiv.apply_symm_apply] | h_empty => suffices P = C (constantCoeff P) by @@ -111,7 +111,7 @@ theorem eq_zero_of_eval_zero_at_prod_finset {σ : Type*} [Finite σ] [IsDomain R intro d hd simp only [hQ] rw [MvPolynomial.coeff_eval_eq_eval_coeff] - convert map_zero (MvPolynomial.eval x) + convert! map_zero (MvPolynomial.eval x) ext m simp only [coeff_zero] set n := (embDomain Function.Embedding.some m).update none d with hn @@ -121,7 +121,7 @@ theorem eq_zero_of_eval_zero_at_prod_finset {σ : Type*} [Finite σ] [IsDomain R apply not_le.mpr hd rw [MvPolynomial.degreeOf_eq_sup] rw [← ne_eq, ← MvPolynomial.mem_support_iff] at hm - convert Finset.le_sup hm + convert! Finset.le_sup hm exact hn.1.symm ext m d simp only [Polynomial.coeff_zero, coeff_zero] @@ -135,7 +135,7 @@ theorem eq_zero_of_eval_zero_at_prod_finset {σ : Type*} [Finite σ] [IsDomain R rw [eq_option_embedding_update_none_iff] at hn rw [hQ, ← hn.1, ← hn.2, optionEquivLeft_coeff_some_coeff_none, ← ne_eq, ← MvPolynomial.mem_support_iff] at he - convert Finset.le_sup he + convert! Finset.le_sup he rw [← hn.2, some_apply] · intro x hx specialize Heval' x hx @@ -185,7 +185,7 @@ private lemma Alon.of_mem_P_support {ι : Type*} (i : ι) (S : Finset R) (m : ι rw [← Alon.degree_P] apply MonomialOrder.le_degree rw [mem_support_iff] - convert he + convert! he · rw [← hm] ext j by_cases hj : j = i @@ -227,7 +227,7 @@ theorem combinatorial_nullstellensatz_exists_linearCombination linearCombination_apply, map_finsuppSum, Finsupp.sum, Finset.sum_eq_zero] intro i _ rw [smul_eq_mul, map_mul] - convert mul_zero _ + convert! mul_zero _ rw [Alon.P, _root_.map_prod] apply Finset.prod_eq_zero (hx i) simp diff --git a/Mathlib/Combinatorics/Optimization/ValuedCSP.lean b/Mathlib/Combinatorics/Optimization/ValuedCSP.lean index da549dbbd49756..851c04232349f7 100644 --- a/Mathlib/Combinatorics/Optimization/ValuedCSP.lean +++ b/Mathlib/Combinatorics/Optimization/ValuedCSP.lean @@ -147,7 +147,7 @@ lemma Function.HasMaxCutPropertyAt.rows_lt_aux {C : Type*} [PartialOrder C] apply asymm obtain ⟨o, in_omega, rfl⟩ := rin change o (fun j => ![![a, b], ![b, a]] j 0) = o (fun j => ![![a, b], ![b, a]] j 1) - convert symmega ![a, b] ![b, a] (by simp [List.Perm.swap]) o in_omega using 2 <;> + convert! symmega ![a, b] ![b, a] (by simp [List.Perm.swap]) o in_omega using 2 <;> simp [Matrix.const_fin1_eq] variable {C : Type*} [AddCommMonoid C] [PartialOrder C] [IsOrderedCancelAddMonoid C] @@ -177,7 +177,7 @@ lemma Function.HasMaxCutProperty.forbids_commutativeFractionalPolymorphism rw [two_nsmul, two_nsmul] exact add_lt_add half_sharp half_sharp have impos : 2 • (ω.map (fun _ => f ![a, b])).sum < ω.size • 2 • f ![a, b] := by - convert lt_of_lt_of_le sharp contr + convert! lt_of_lt_of_le sharp contr simp [FractionalOperation.tt, Multiset.map_map] have rhs_swap : ω.size • 2 • f ![a, b] = 2 • ω.size • f ![a, b] := nsmul_left_comm .. have distrib : (ω.map (fun _ => f ![a, b])).sum = ω.size • f ![a, b] := by simp diff --git a/Mathlib/Combinatorics/SetFamily/AhlswedeZhang.lean b/Mathlib/Combinatorics/SetFamily/AhlswedeZhang.lean index 37c2b8e97c20de..ac0a357e9bf3c3 100644 --- a/Mathlib/Combinatorics/SetFamily/AhlswedeZhang.lean +++ b/Mathlib/Combinatorics/SetFamily/AhlswedeZhang.lean @@ -96,7 +96,7 @@ private lemma Fintype.sum_div_mul_card_choose_card : rw [div_mul_cancel_right₀] exact cast_ne_zero.2 (choose_pos <| mem_range_succ_iff.1 hn).ne' simp only [Finset.sum_congr rfl this, mul_eq_mul_left_iff, cast_eq_zero] - convert Or.inl <| sum_range_reflect _ _ with a ha + convert! Or.inl <| sum_range_reflect _ _ with a ha rw [add_tsub_cancel_right, cast_sub (mem_range_succ_iff.mp ha)] end diff --git a/Mathlib/Combinatorics/SetFamily/Compression/UV.lean b/Mathlib/Combinatorics/SetFamily/Compression/UV.lean index 848a7b3c229c78..b7e413d1b0b399 100644 --- a/Mathlib/Combinatorics/SetFamily/Compression/UV.lean +++ b/Mathlib/Combinatorics/SetFamily/Compression/UV.lean @@ -349,7 +349,7 @@ theorem shadow_compression_subset_compression_shadow (u v : Finset α) rw [union_sdiff_distrib, ‹v \ u = v›] exact (erase_subset _ _).trans subset_union_right -- and then arguing that it's the same - convert this using 1 + convert! this using 1 rw [sdiff_union_erase_cancel (hus.trans subset_union_left) ‹x ∈ u›, erase_union_distrib, erase_insert ‹x ∉ s›, erase_eq_of_notMem ‹x ∉ v›, sdiff_erase (mem_union_right _ hyv), union_sdiff_cancel_right hsv] @@ -375,7 +375,7 @@ theorem shadow_compression_subset_compression_shadow (u v : Finset α) refine sup_sdiff_mem_of_mem_compression (by rwa [hxy.eq]) ((erase_subset _ _).trans ‹_›) ?_ rw [← sdiff_erase (mem_union_left _ <| hus hwu)] exact disjoint_sdiff - convert this using 1 + convert! this using 1 rw [insert_union_comm, insert_erase ‹w ∈ u›, sdiff_union_of_subset (hus.trans subset_union_left), sdiff_erase (mem_union_right _ ‹z ∈ v›), union_sdiff_cancel_right hsv] @@ -385,7 +385,7 @@ theorem shadow_compression_subset_compression_shadow (u v : Finset α) have : (insert w ((s ∪ v) \ u) ∪ u) \ v ∈ 𝒜 := sup_sdiff_mem_of_mem_compression ‹insert w ((s ∪ v) \ u) ∈ 𝒜'› ‹_› (disjoint_insert_right.2 ⟨‹_›, disjoint_sdiff⟩) - convert this using 1 + convert! this using 1 rw [insert_union, sdiff_union_of_subset (hus.trans subset_union_left), insert_sdiff_of_notMem _ (hwu ∘ hwB ∘ mem_union_right _), union_sdiff_cancel_right hsv] diff --git a/Mathlib/Combinatorics/SetFamily/KruskalKatona.lean b/Mathlib/Combinatorics/SetFamily/KruskalKatona.lean index f388fc0bfd201e..90c8e76eee6c17 100644 --- a/Mathlib/Combinatorics/SetFamily/KruskalKatona.lean +++ b/Mathlib/Combinatorics/SetFamily/KruskalKatona.lean @@ -290,7 +290,7 @@ theorem iterated_kk (h₁ : (𝒜 : Set (Finset (Fin n))).Sized r) (h₂ : #𝒞 | zero => simpa | succ _ ih => refine ih h₁.shadow (kruskal_katona h₁ h₂ h₃) ?_ - convert h₃.shadow + convert! h₃.shadow /-- The **Lovasz formulation of the Kruskal-Katona theorem**. @@ -350,7 +350,7 @@ theorem erdos_ko_rado {𝒜 : Finset (Finset (Fin n))} {r : ℕ} #𝒜 ≤ (n - 1).choose (r - 1) := by -- Take care of the r=0 case first: it's not very interesting. rcases Nat.eq_zero_or_pos r with b | h1r - · convert Nat.zero_le _ + · convert! Nat.zero_le _ rw [Finset.card_eq_zero, eq_empty_iff_forall_notMem] refine fun A HA ↦ h𝒜 HA HA ?_ rw [disjoint_self_iff_empty, ← Finset.card_eq_zero, ← b] @@ -377,15 +377,15 @@ theorem erdos_ko_rado {𝒜 : Finset (Finset (Fin n))} {r : ℕ} -- But this gives a contradiction: `n choose r < |𝒜| + |∂^[n-2k] 𝒜ᶜˢ|` have := calc n.choose r = (n - 1).choose (r - 1) + (n - 1).choose r := by - convert Nat.choose_succ_succ _ _ using 3 <;> rwa [Nat.sub_one, Nat.succ_pred_eq_of_pos] + convert! Nat.choose_succ_succ _ _ using 3 <;> rwa [Nat.sub_one, Nat.succ_pred_eq_of_pos] _ < #𝒜 + #(∂^[n - 2 * r] 𝒜ᶜˢ) := add_lt_add_of_lt_of_le size kk _ = #(𝒜 ∪ ∂^[n - 2 * r] 𝒜ᶜˢ) := by rw [card_union_of_disjoint ‹_›] apply this.not_ge - convert Set.Sized.card_le _ + convert! Set.Sized.card_le _ · rw [Fintype.card_fin] rw [coe_union, Set.sized_union] refine ⟨‹_›, ?_⟩ - convert h𝒜bar.shadow_iterate + convert! h𝒜bar.shadow_iterate lia end Finset diff --git a/Mathlib/Combinatorics/SetFamily/LYM.lean b/Mathlib/Combinatorics/SetFamily/LYM.lean index 0f52fe96b02566..86cefa4a22f52c 100644 --- a/Mathlib/Combinatorics/SetFamily/LYM.lean +++ b/Mathlib/Combinatorics/SetFamily/LYM.lean @@ -102,7 +102,7 @@ theorem local_lubell_yamamoto_meshalkin_inequality_div (hr : r ≠ 0) · exact (hr rfl).elim rw [tsub_add_eq_add_tsub hr', add_tsub_add_eq_tsub_right] at h𝒜 apply le_of_mul_le_mul_right _ (pos_iff_ne_zero.2 hr) - convert Nat.mul_le_mul_right ((Fintype.card α).choose r) h𝒜 using 1 + convert! Nat.mul_le_mul_right ((Fintype.card α).choose r) h𝒜 using 1 · simpa [mul_assoc, Nat.choose_succ_right_eq] using Or.inl (mul_comm _ _) · simp only [mul_assoc, choose_succ_right_eq, mul_eq_mul_left_iff] exact Or.inl (mul_comm _ _) diff --git a/Mathlib/Combinatorics/SimpleGraph/Acyclic.lean b/Mathlib/Combinatorics/SimpleGraph/Acyclic.lean index 8f7c72399e7c9a..e53b18581cdde3 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Acyclic.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Acyclic.lean @@ -412,7 +412,7 @@ theorem isAcyclic_sup_fromEdgeSet_iff {u v : V} : refine ⟨?_, fun ⟨hacyc, hreach⟩ ↦ hacyc.sup_edge_of_not_reachable <| by grind⟩ refine fun hacyc ↦ ⟨hacyc.anti le_sup_left, fun hreach ↦ False.elim ?_⟩ refine (isAcyclic_iff_forall_edge_isBridge.mp (e := s(u, v)) hacyc <| by simp [huv]).right ?_ - convert hreach + convert! hreach simpa [deleteEdges_sup] /-- diff --git a/Mathlib/Combinatorics/SimpleGraph/Clique.lean b/Mathlib/Combinatorics/SimpleGraph/Clique.lean index 6d5c164b94a8c6..34acf09b319b6f 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Clique.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Clique.lean @@ -483,7 +483,7 @@ protected theorem CliqueFree.replaceVertex [DecidableEq α] (h : G.CliqueFree n) refine Embedding.isContained ⟨φ.setValue x s, fun {a b} ↦ ?_⟩ simp only [Embedding.coeFn_mk, Embedding.setValue, not_exists.mp ms, ite_false] rw [apply_ite (G.Adj · _), apply_ite (G.Adj _ ·), apply_ite (G.Adj _ ·)] - convert @hφ a b <;> simp only [← φ.apply_eq_iff_eq, SimpleGraph.irrefl, hx] + convert! @hφ a b <;> simp only [← φ.apply_eq_iff_eq, SimpleGraph.irrefl, hx] · refine Embedding.isContained ⟨φ, ?_⟩ simp_rw [Set.mem_range, not_exists, ← ne_eq] at mt conv at hφ => enter [a, b]; rw [G.adj_replaceVertex_iff_of_ne _ (mt a) (mt b)] diff --git a/Mathlib/Combinatorics/SimpleGraph/Coloring/VertexColoring.lean b/Mathlib/Combinatorics/SimpleGraph/Coloring/VertexColoring.lean index d1588303b375c5..836573e2f08714 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Coloring/VertexColoring.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Coloring/VertexColoring.lean @@ -115,7 +115,7 @@ theorem Coloring.colorClasses_finite [Finite α] : C.colorClasses.Finite := theorem Coloring.card_colorClasses_le [Fintype α] [Fintype C.colorClasses] : Fintype.card C.colorClasses ≤ Fintype.card α := by simp only [colorClasses] - convert Setoid.card_classes_ker_le C + convert! Setoid.card_classes_ker_le C theorem Coloring.not_adj_of_mem_colorClass {c : α} {v w : V} (hv : v ∈ C.colorClass c) (hw : w ∈ C.colorClass c) : ¬G.Adj v w := fun h => C.valid h (Eq.trans hv (Eq.symm hw)) @@ -169,15 +169,18 @@ theorem Colorable.of_isEmpty [IsEmpty V] (n : ℕ) : G.Colorable n := ⟨.ofIsEm @[deprecated (since := "2026-01-03")] alias coloringOfIsEmpty := Coloring.ofIsEmpty @[deprecated (since := "2026-01-03")] alias colorableOfIsEmpty := Colorable.of_isEmpty -theorem isEmpty_of_colorable_zero (h : G.Colorable 0) : IsEmpty V := by - constructor - intro v - obtain ⟨i, hi⟩ := h.some v - exact Nat.not_lt_zero _ hi - @[simp] lemma colorable_zero_iff : G.Colorable 0 ↔ IsEmpty V := - ⟨isEmpty_of_colorable_zero, fun _ ↦ .of_isEmpty 0⟩ + ⟨fun ⟨C⟩ ↦ Function.isEmpty C, fun _ ↦ .of_isEmpty 0⟩ + +alias ⟨Colorable.isEmpty, _⟩ := colorable_zero_iff + +@[deprecated (since := "2026-04-24")] alias isEmpty_of_colorable_zero := Colorable.isEmpty + +@[simp] +theorem colorable_one_iff : G.Colorable 1 ↔ G = ⊥ := by + refine ⟨fun ⟨C⟩ ↦ eq_bot_iff_forall_not_adj.mpr fun u v h ↦ ?_, fun h ↦ h ▸ ⟨0, by simp⟩⟩ + exact C.map_rel h <| Subsingleton.elim .. /-- A coloring of a graph `G` is a homomorphism from it to the mapped graph. This is `Hom.map` spelled using colorings. The mapped graph `G.map f` can be thought of as taking @@ -383,14 +386,6 @@ theorem colorable_of_chromaticNumber_ne_top (h : G.chromaticNumber ≠ ⊤) : obtain ⟨n, hn⟩ := h exact colorable_chromaticNumber hn -theorem chromaticNumber_eq_zero_of_isEmpty [IsEmpty V] : G.chromaticNumber = 0 := by - rw [← nonpos_iff_eq_zero, ← Nat.cast_zero, chromaticNumber_le_iff_colorable]; exact .of_isEmpty _ - -theorem isEmpty_of_chromaticNumber_eq_zero (h : G.chromaticNumber = 0) : IsEmpty V := by - have := colorable_of_chromaticNumber_ne_top (h ▸ ENat.zero_ne_top) - rw [h] at this - exact G.isEmpty_of_colorable_zero this - theorem Colorable.mono_left {G' : SimpleGraph V} (h : G ≤ G') {n : ℕ} (hc : G'.Colorable n) : G.Colorable n := ⟨hc.some.comp (.ofLE h)⟩ @@ -442,9 +437,9 @@ lemma chromaticNumber_eq_iff_forall_surjective (hG : G.Colorable n) : G.chromaticNumber = n ↔ ∀ C : G.Coloring (Fin n), Surjective C := by rw [← hG.chromaticNumber_le.ge_iff_eq, le_chromaticNumber_iff_forall_surjective] -theorem chromaticNumber_bot [Nonempty V] : (⊥ : SimpleGraph V).chromaticNumber = 1 := by - have : (⊥ : SimpleGraph V).Colorable 1 := ⟨.mk 0 <| by simp⟩ - exact this.chromaticNumber_le.antisymm <| Order.one_le_iff_pos.2 <| chromaticNumber_pos this +theorem chromaticNumber_bot [Nonempty V] : (⊥ : SimpleGraph V).chromaticNumber = 1 := + have : (⊥ : SimpleGraph V).Colorable 1 := by simp + this.chromaticNumber_le.antisymm <| Order.one_le_iff_pos.2 <| chromaticNumber_pos this @[simp] theorem chromaticNumber_top [Fintype V] : (⊤ : SimpleGraph V).chromaticNumber = Fintype.card V := by @@ -453,6 +448,7 @@ theorem chromaticNumber_top [Fintype V] : (⊤ : SimpleGraph V).chromaticNumber rw [← Finite.injective_iff_surjective] exact Hom.injective_of_top_hom C +@[simp] theorem chromaticNumber_top_eq_top_of_infinite (V : Type*) [Infinite V] : (⊤ : SimpleGraph V).chromaticNumber = ⊤ := by by_contra hc @@ -460,6 +456,13 @@ theorem chromaticNumber_top_eq_top_of_infinite (V : Type*) [Infinite V] : obtain ⟨n, ⟨hn⟩⟩ := hc exact not_injective_infinite_finite _ hn.injective_of_top_hom +@[simp] +theorem chromaticNumber_top_eq_enat_card : (⊤ : SimpleGraph V).chromaticNumber = ENat.card V := by + cases finite_or_infinite V + · have := Fintype.ofFinite ‹_› + simp + · simp + theorem eq_top_of_chromaticNumber_eq_card [Fintype V] (h : G.chromaticNumber = Fintype.card V) : G = ⊤ := by classical @@ -487,17 +490,21 @@ theorem two_le_chromaticNumber_of_adj {u v : V} (hadj : G.Adj u v) : 2 ≤ G.chr obtain ⟨c⟩ := chromaticNumber_le_iff_colorable.mp (Order.le_of_lt_add_one h) exact c.valid hadj (Subsingleton.elim (c u) (c v)) +@[simp] +theorem chromaticNumber_eq_zero_iff : G.chromaticNumber = 0 ↔ IsEmpty V := + nonpos_iff_eq_zero.symm.trans <| chromaticNumber_le_iff_colorable.trans colorable_zero_iff + +@[simp] +theorem chromaticNumber_eq_zero_of_isEmpty [IsEmpty V] : G.chromaticNumber = 0 := by + simpa + +@[deprecated (since := "2026-04-24")] +alias ⟨isEmpty_of_chromaticNumber_eq_zero, _⟩ := chromaticNumber_eq_zero_iff + theorem chromaticNumber_eq_one_iff : G.chromaticNumber = 1 ↔ G = ⊥ ∧ Nonempty V := by - refine ⟨fun h ↦ ⟨?_, ?_⟩, fun ⟨h₁, _⟩ ↦ h₁ ▸ chromaticNumber_bot⟩ - · contrapose! h - obtain ⟨_, _, h⟩ := ne_bot_iff_exists_adj.mp h - have := two_le_chromaticNumber_of_adj h - contrapose! this - simp [this] - · refine not_isEmpty_iff.mp ?_ - contrapose! h - have := G.colorable_zero_iff.mpr h |>.chromaticNumber_le - simp_all + rw [eq_iff_le_not_lt, Order.lt_one_iff_nonpos, ← not_isEmpty_iff, ← Nat.cast_one, ← Nat.cast_zero, + chromaticNumber_le_iff_colorable, chromaticNumber_le_iff_colorable, colorable_one_iff, + colorable_zero_iff] theorem two_le_chromaticNumber_iff_ne_bot : 2 ≤ G.chromaticNumber ↔ G ≠ ⊥ := by refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ diff --git a/Mathlib/Combinatorics/SimpleGraph/Connectivity/Connected.lean b/Mathlib/Combinatorics/SimpleGraph/Connectivity/Connected.lean index d944916d38021b..f045486e9a2d6b 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Connectivity/Connected.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Connectivity/Connected.lean @@ -709,7 +709,7 @@ def homOfConnectedComponents (G : SimpleGraph V) {H : SimpleGraph V'} map_rel' := fun hab ↦ by have h : (G.connectedComponentMk _).toSimpleGraph.Adj ⟨_, rfl⟩ ⟨_, ((G.connectedComponentMk _).mem_supp_congr_adj hab).1 rfl⟩ := by simpa using hab - convert (C (G.connectedComponentMk _)).map_rel h using 3 <;> + convert! (C (G.connectedComponentMk _)).map_rel h using 3 <;> rw [ConnectedComponent.connectedComponentMk_eq_of_adj hab] -- TODO: Extract as lemma about general equivalence relation @@ -952,7 +952,7 @@ lemma Preconnected.induce_of_degree_eq_one (hG : G.Preconnected) {s : Set V} rintro ⟨u, hu⟩ ⟨v, hv⟩ obtain ⟨p, hp⟩ := hG.exists_isPath u v constructor - convert p.induce s _ + convert! p.induce s _ rintro w hwp by_contra hws exact hp.not_mem_support_of_subsingleton_neighborSet (by grind) (by grind) (hs _ hws) hwp diff --git a/Mathlib/Combinatorics/SimpleGraph/Connectivity/EdgeConnectivity.lean b/Mathlib/Combinatorics/SimpleGraph/Connectivity/EdgeConnectivity.lean index e97f55dc75df1f..d03befd0a5d472 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Connectivity/EdgeConnectivity.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Connectivity/EdgeConnectivity.lean @@ -68,7 +68,7 @@ protected lemma IsEdgeReachable.zero : G.IsEdgeReachable 0 u v := by simp [IsEdg @[simp] lemma isEdgeReachable_one : G.IsEdgeReachable 1 u v ↔ G.Reachable u v := by - simp [IsEdgeReachable, ENat.lt_one_iff_eq_zero] + simp [IsEdgeReachable, Order.lt_one_iff] @[simp] lemma isEdgeConnected_one : G.IsEdgeConnected 1 ↔ G.Preconnected := by @@ -96,8 +96,8 @@ lemma IsEdgeReachable.le_degree [Fintype (G.neighborSet u)] (h : G.IsEdgeReachab (huv : u ≠ v) : k ≤ G.degree u := by classical by_contra! hh - obtain ⟨w, _⟩ := - @h (G.incidenceSet u) (by simpa [← Set.coe_fintypeCard, ENat.coe_lt_coe]) |>.exists_isPath + rw [← card_incidenceSet_eq_degree, ← ENat.coe_lt_coe, Set.coe_fintypeCard] at hh + obtain ⟨w, _⟩ := h hh |>.exists_isPath simpa using w.adj_snd <| mt Walk.Nil.eq huv lemma IsEdgeConnected.le_degree [Fintype (G.neighborSet u)] [Nontrivial V] diff --git a/Mathlib/Combinatorics/SimpleGraph/Connectivity/Subgraph.lean b/Mathlib/Combinatorics/SimpleGraph/Connectivity/Subgraph.lean index 5cad961fe793a5..37ea26f7e1dd40 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Connectivity/Subgraph.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Connectivity/Subgraph.lean @@ -257,7 +257,7 @@ theorem finite_neighborSet_toSubgraph (p : G.Walk u v) : (p.toSubgraph.neighborS lemma toSubgraph_le_induce_support (p : G.Walk u v) : p.toSubgraph ≤ (⊤ : G.Subgraph).induce {v | v ∈ p.support} := by - convert Subgraph.le_induce_top_verts + convert! Subgraph.le_induce_top_verts exact p.verts_toSubgraph.symm theorem toSubgraph_adj_getVert {u v} (w : G.Walk u v) {i : ℕ} (hi : i < w.length) : @@ -505,7 +505,7 @@ lemma exists_mem_support_mem_erase_mem_support_takeUntil_eq_empty (s : Finset V) have := p.length_takeUntil_le hx lia obtain ⟨y, hys, hyp, h⟩ := ih _ this (s.erase x) h rfl - use y, mem_of_mem_erase hys, support_takeUntil_subset p hx hyp + use y, mem_of_mem_erase hys, support_takeUntil_subset_support p hx hyp rwa [takeUntil_takeUntil, erase_right_comm, filter_erase, erase_eq_of_notMem] at h simp only [mem_filter, mem_erase, ne_eq, not_and, and_imp] rintro hxy - diff --git a/Mathlib/Combinatorics/SimpleGraph/Copy.lean b/Mathlib/Combinatorics/SimpleGraph/Copy.lean index f3662614ba254e..1876ac6eec5a51 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Copy.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Copy.lean @@ -313,7 +313,8 @@ alias ⟨IsContained.exists_iso_subgraph, IsContained.of_exists_iso_subgraph⟩ theorem Copy.degree_le (f : Copy G H) (v : V) [Fintype <| G.neighborSet v] [Fintype <| H.neighborSet (f v)] : G.degree v ≤ H.degree (f v) := by - simpa using Fintype.card_le_of_injective _ (f.mapNeighborSet v).injective + simpa [card_neighborSet_eq_degree] using + Fintype.card_le_of_injective _ (f.mapNeighborSet v).injective theorem Copy.max_degree_le [Fintype V] [Fintype W] [DecidableRel G.Adj] [DecidableRel H.Adj] (f : Copy G H) : G.maxDegree ≤ H.maxDegree := by @@ -482,7 +483,7 @@ noncomputable def labelledCopyCount (G : SimpleGraph V) (H : SimpleGraph W) : @[simp] lemma labelledCopyCount_of_isEmpty [IsEmpty W] (G : SimpleGraph V) (H : SimpleGraph W) : G.labelledCopyCount H = 1 := by - convert Fintype.card_unique + convert! Fintype.card_unique exact { default := ⟨default, isEmptyElim⟩, uniq := fun _ ↦ Subsingleton.elim _ _ } @[simp] lemma labelledCopyCount_eq_zero : G.labelledCopyCount H = 0 ↔ H.Free G := by @@ -524,11 +525,12 @@ lemma copyCount_le_labelledCopyCount [Fintype W] : G.copyCount H ≤ G.labelledC @[simp] lemma copyCount_bot (G : SimpleGraph V) : copyCount G (⊥ : SimpleGraph V) = 1 := by classical rw [copyCount] - convert card_singleton (α := G.Subgraph) - { verts := .univ - Adj := ⊥ - adj_sub := False.elim - edge_vert := False.elim } + convert! + card_singleton (α := G.Subgraph) + { verts := .univ + Adj := ⊥ + adj_sub := False.elim + edge_vert := False.elim } simp only [eq_singleton_iff_unique_mem, mem_filter_univ, Nonempty.forall] refine ⟨⟨⟨(Equiv.Set.univ _).symm, by simp⟩⟩, fun H' e ↦ Subgraph.ext ((set_fintype_card_eq_univ_iff _).1 <| Fintype.card_congr e.toEquiv.symm) ?_⟩ diff --git a/Mathlib/Combinatorics/SimpleGraph/Dart.lean b/Mathlib/Combinatorics/SimpleGraph/Dart.lean index 96be6e8b7b3875..651455db64474c 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Dart.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Dart.lean @@ -130,7 +130,7 @@ theorem dartOfNeighborSet_injective (v : V) : Function.Injective (G.dartOfNeighb fun e₁ e₂ h => Subtype.ext <| by injection h with h' - convert congr_arg Prod.snd h' + convert! congr_arg Prod.snd h' instance nonempty_dart_top [Nontrivial V] : Nonempty (⊤ : SimpleGraph V).Dart := by obtain ⟨v, w, h⟩ := exists_pair_ne V diff --git a/Mathlib/Combinatorics/SimpleGraph/DegreeSum.lean b/Mathlib/Combinatorics/SimpleGraph/DegreeSum.lean index abfa2203d1a863..3b62bb027300c8 100644 --- a/Mathlib/Combinatorics/SimpleGraph/DegreeSum.lean +++ b/Mathlib/Combinatorics/SimpleGraph/DegreeSum.lean @@ -82,7 +82,7 @@ theorem dart_edge_fiber_card [DecidableEq V] (e : Sym2 V) (h : e ∈ G.edgeSet) #{d : G.Dart | d.edge = e} = 2 := by obtain ⟨v, w⟩ := e let d : G.Dart := ⟨(v, w), h⟩ - convert congr_arg card d.edge_fiber + convert! congr_arg card d.edge_fiber rw [card_insert_of_notMem, card_singleton] rw [mem_singleton] exact d.symm_ne.symm @@ -132,7 +132,7 @@ theorem even_card_odd_degree_vertices [Fintype V] [DecidableRel G.Adj] : rw [sum_congr (g := fun _v ↦ (1 : ZMod 2)) rfl] at h · simp only [mul_one, nsmul_eq_mul, sum_const, Ne] at h rw [← ZMod.natCast_eq_zero_iff_even] - convert h + convert! h exact ZMod.natCast_ne_zero_iff_odd.symm · intro v rw [mem_filter_univ, Ne, ZMod.natCast_eq_zero_iff_even, ZMod.natCast_eq_one_iff_odd, diff --git a/Mathlib/Combinatorics/SimpleGraph/Diam.lean b/Mathlib/Combinatorics/SimpleGraph/Diam.lean index 42542567655bda..d3a098ab90c523 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Diam.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Diam.lean @@ -114,7 +114,7 @@ lemma eccent_le_one_iff (u : α) : G.eccent u ≤ 1 ↔ ∀ v, u ≠ v → G.Adj lemma eccent_eq_one_iff [Nontrivial α] (u : α) : G.eccent u = 1 ↔ ∀ v, u ≠ v → G.Adj u v := by - have h : 1 ≤ G.eccent u := ENat.one_le_iff_ne_zero.mpr (eccent_ne_zero u) + have h : 1 ≤ G.eccent u := Order.one_le_iff_ne_zero.mpr (eccent_ne_zero u) rw [← h.ge_iff_eq'] exact eccent_le_one_iff u @@ -368,9 +368,9 @@ lemma radius_ne_top_iff [Nonempty α] [Finite α] : G.radius ≠ ⊤ ↔ G.Conne exact h u v lemma radius_ne_zero_of_nontrivial [Nontrivial α] : G.radius ≠ 0 := by - rw [← ENat.one_le_iff_ne_zero] + rw [← Order.one_le_iff_ne_zero] apply le_iInf - simp [ENat.one_le_iff_ne_zero, G.eccent_ne_zero] + simp [Order.one_le_iff_ne_zero, G.eccent_ne_zero] lemma radius_eq_zero_iff : G.radius = 0 ↔ Nonempty α ∧ Subsingleton α := by refine ⟨fun h ↦ ⟨?_, ?_⟩, fun ⟨_, _⟩ ↦ ?_⟩ diff --git a/Mathlib/Combinatorics/SimpleGraph/Extremal/Basic.lean b/Mathlib/Combinatorics/SimpleGraph/Extremal/Basic.lean index a7fcb5c636b9a2..2bca2d3849bbfc 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Extremal/Basic.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Extremal/Basic.lean @@ -52,7 +52,7 @@ theorem exists_isExtremal_iff_exists (p : SimpleGraph V → Prop) : apply exists_max_image { G | p G } (#·.edgeFinset) use G, by simpa using hp use G', inferInstanceAs (DecidableRel G'.Adj) - exact ⟨by simpa using hp', fun _ _ hp ↦ by convert h _ (by simpa using hp)⟩ + exact ⟨by simpa using hp', fun _ _ hp ↦ by convert! h _ (by simpa using hp)⟩ /-- If `H` has at least one edge, then there exists an extremal `H.Free` graph. -/ theorem exists_isExtremal_free {W : Type*} {H : SimpleGraph W} (h : H ≠ ⊥) : @@ -96,7 +96,7 @@ theorem extremalNumber_of_fintypeCard_eq [Fintype V] (hc : card V = n) : rw [mem_filter, ← free_congr .refl (.map e G)] simpa using h rw [Iso.card_edgeFinset_eq (.map e G)] - convert @le_sup _ _ _ _ { G | H.Free G } (#·.edgeFinset) G' h' + convert! @le_sup _ _ _ _ {G | H.Free G} (#·.edgeFinset) G' h' variable [Fintype V] [DecidableRel G.Adj] @@ -104,7 +104,7 @@ variable [Fintype V] [DecidableRel G.Adj] theorem card_edgeFinset_le_extremalNumber (h : H.Free G) : #G.edgeFinset ≤ extremalNumber (card V) H := by rw [extremalNumber_of_fintypeCard_eq rfl] - convert @le_sup _ _ _ _ { G | H.Free G } (#·.edgeFinset) G (by simpa using h) + convert! @le_sup _ _ _ _ {G | H.Free G} (#·.edgeFinset) G (by simpa using h) /-- If `G` has more than `extremalNumber (card V) H` edges, then `G` contains a copy of `H`. -/ theorem IsContained.of_extremalNumber_lt_card_edgeFinset @@ -118,7 +118,7 @@ theorem extremalNumber_le_iff (H : SimpleGraph W) (m : ℕ) : extremalNumber (card V) H ≤ m ↔ ∀ ⦃G : SimpleGraph V⦄ [DecidableRel G.Adj], H.Free G → #G.edgeFinset ≤ m := by simp_rw [extremalNumber_of_fintypeCard_eq rfl, Finset.sup_le_iff, mem_filter_univ] - exact ⟨fun h _ _ h' ↦ by convert h _ h', fun h _ h' ↦ by convert h h'⟩ + exact ⟨fun h _ _ h' ↦ by convert! h _ h', fun h _ h' ↦ by convert! h h'⟩ /-- `extremalNumber (card V) H` is greater than `x` if and only if there exists a `H`-free simple graph `G` with more than `x` edges. -/ @@ -126,7 +126,8 @@ theorem lt_extremalNumber_iff (H : SimpleGraph W) (m : ℕ) : m < extremalNumber (card V) H ↔ ∃ G : SimpleGraph V, ∃ _ : DecidableRel G.Adj, H.Free G ∧ m < #G.edgeFinset := by simp_rw [extremalNumber_of_fintypeCard_eq rfl, Finset.lt_sup_iff, mem_filter_univ] - exact ⟨fun ⟨_, h, h'⟩ ↦ ⟨_, _, h, h'⟩, fun ⟨_, _, h, h'⟩ ↦ ⟨_, h, by convert h'⟩⟩ + exact ⟨fun ⟨_, h, h'⟩ ↦ ⟨_, _, h, h'⟩, fun ⟨_, _, h, h'⟩ ↦ ⟨_, h, by convert! + h'⟩⟩ variable {R : Type*} [Semiring R] [LinearOrder R] [FloorSemiring R] diff --git a/Mathlib/Combinatorics/SimpleGraph/Extremal/Turan.lean b/Mathlib/Combinatorics/SimpleGraph/Extremal/Turan.lean index 3f74a28e62c4fa..5cd01c2801f5b7 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Extremal/Turan.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Extremal/Turan.lean @@ -190,7 +190,7 @@ lemma degree_eq_card_sub_part_card [DecidableEq V] : eq_tsub_of_add_eq (card_filter_add_card_filter_not _) _ = _ := by congr; ext; rw [mem_filter] - convert Finpartition.mem_part_ofSetoid_iff_rel.symm + convert! Finpartition.mem_part_ofSetoid_iff_rel.symm simp +instances [setoid] /-- The parts of a Turán-maximal graph form an equipartition. -/ @@ -243,8 +243,8 @@ theorem card_parts [DecidableEq V] : #h.finpartition.parts = min (card V) r := b exact exists_ne_map_eq_of_card_lt_of_maps_to (zc.symm ▸ l.2) fun a _ ↦ fp.part_mem.2 (mem_univ a) use G ⊔ edge x y, inferInstance, cf.sup_edge x y - convert Nat.lt_add_one #G.edgeFinset - convert G.card_edgeFinset_sup_edge _ hn + convert! Nat.lt_add_one #G.edgeFinset + convert! G.card_edgeFinset_sup_edge _ hn rwa [h.not_adj_iff_part_eq] /-- **Turán's theorem**, forward direction. @@ -344,6 +344,7 @@ private lemma sum_ne_add_mod_eq_sub_one {c : ℕ} : rw [Nat.add_mod_mod, ← add_assoc, ← one_add_mul, show 1 + (r - 1) = r by lia, Nat.mul_add_mod_self_left] +set_option backward.isDefEq.respectTransparency false in lemma card_edgeFinset_turanGraph_add : #(turanGraph (n + r) r).edgeFinset = #(turanGraph n r).edgeFinset + n * (r - 1) + r.choose 2 := by @@ -373,7 +374,7 @@ theorem card_edgeFinset_turanGraph {n r : ℕ} : rcases r.eq_zero_or_pos with rfl | hr · rw [Nat.mod_zero, tsub_self, zero_mul, Nat.zero_div, zero_add] have := card_edgeFinset_top_eq_card_choose_two (V := Fin n) - rw [Fintype.card_fin] at this; convert this; exact turanGraph_zero + rw [Fintype.card_fin] at this; convert! this; exact turanGraph_zero · have ring₁ (n) : (n ^ 2 - (n % r) ^ 2) * (r - 1) / (2 * r) = n % r * (n / r) * (r - 1) + r * (r - 1) * (n / r) ^ 2 / 2 := by nth_rw 1 [← Nat.mod_add_div n r, Nat.sq_sub_sq, add_tsub_cancel_left, @@ -383,7 +384,7 @@ theorem card_edgeFinset_turanGraph {n r : ℕ} : rcases lt_or_ge n r with h | h · rw [Nat.mod_eq_of_lt h, tsub_self, zero_mul, Nat.zero_div, zero_add] have := card_edgeFinset_top_eq_card_choose_two (V := Fin n) - rw [Fintype.card_fin] at this; convert this + rw [Fintype.card_fin] at this; convert! this rw [turanGraph_eq_top]; exact .inr h.le · let n' := n - r have n'r : n = n' + r := by lia @@ -425,7 +426,7 @@ theorem CliqueFree.card_edgeFinset_le (cf : G.CliqueFree (r + 1)) : simp_rw [zero_tsub, mul_zero, Nat.mod_zero, Nat.div_zero, zero_add] exact card_edgeFinset_le_card_choose_two · obtain ⟨H, _, maxH⟩ := exists_isTuranMaximal (V := V) hr - convert maxH.2 cf + convert! maxH.2 cf rw [((isTuranMaximal_iff_nonempty_iso_turanGraph hr).mp maxH).some.card_edgeFinset_eq, card_edgeFinset_turanGraph] diff --git a/Mathlib/Combinatorics/SimpleGraph/Finite.lean b/Mathlib/Combinatorics/SimpleGraph/Finite.lean index e67cc079450575..995f4e087a421e 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Finite.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Finite.lean @@ -121,12 +121,11 @@ lemma edgeFinset_nonempty : G.edgeFinset.Nonempty ↔ G ≠ ⊥ := by theorem edgeFinset_card : #G.edgeFinset = Fintype.card G.edgeSet := Set.toFinset_card _ -@[simp] theorem card_edgeSet : Fintype.card G.edgeSet = #G.edgeFinset := .symm <| Set.toFinset_card _ theorem edgeSet_univ_card : #(univ : Finset G.edgeSet) = #G.edgeFinset := by - simp + simp [card_edgeSet] variable [Fintype V] @@ -203,7 +202,6 @@ def degree : ℕ := #(G.neighborFinset v) @[simp] theorem card_neighborFinset_eq_degree : #(G.neighborFinset v) = G.degree v := rfl -@[simp] theorem card_neighborSet_eq_degree : Fintype.card (G.neighborSet v) = G.degree v := (Set.toFinset_card _).symm @@ -255,7 +253,8 @@ theorem degree_compl [Fintype (Gᶜ.neighborSet v)] [Fintype V] : Gᶜ.degree v = Fintype.card V - 1 - G.degree v := by classical rw [← card_neighborSet_union_compl_neighborSet G v, Set.toFinset_union] - simp [card_union_of_disjoint (Set.disjoint_toFinset.mpr (compl_neighborSet_disjoint G v))] + simp [card_union_of_disjoint (Set.disjoint_toFinset.mpr (compl_neighborSet_disjoint G v)), + card_neighborSet_eq_degree] instance incidenceSetFintype [DecidableEq V] : Fintype (G.incidenceSet v) := Fintype.ofEquiv (G.neighborSet v) (G.incidenceSetEquivNeighborSet v).symm @@ -264,11 +263,9 @@ instance incidenceSetFintype [DecidableEq V] : Fintype (G.incidenceSet v) := def incidenceFinset [DecidableEq V] : Finset (Sym2 V) := (G.incidenceSet v).toFinset -@[simp] theorem card_incidenceSet_eq_degree [DecidableEq V] : Fintype.card (G.incidenceSet v) = G.degree v := by - rw [Fintype.card_congr (G.incidenceSetEquivNeighborSet v)] - simp + rw [Fintype.card_congr (G.incidenceSetEquivNeighborSet v), card_neighborSet_eq_degree] @[simp, norm_cast] theorem coe_incidenceFinset [DecidableEq V] : diff --git a/Mathlib/Combinatorics/SimpleGraph/Hasse.lean b/Mathlib/Combinatorics/SimpleGraph/Hasse.lean index 031af4aeb45c7b..c4f86bf5e35577 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Hasse.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Hasse.lean @@ -61,6 +61,17 @@ theorem hasseDualIso_apply (a : αᵒᵈ) : hasseDualIso a = ofDual a := theorem hasseDualIso_symm_apply (a : α) : hasseDualIso.symm a = toDual a := rfl +/-- The Hasse diagram of a preorder is triangle-free. This is the graph-theoretic formulation of +`not_covBy_of_lt_of_lt`: if `a ⋖ b` and `b ⋖ c` then `¬a ⋖ c`. -/ +theorem cliqueFree_hasse_three : (hasse α).CliqueFree 3 := by + classical + intro s ⟨hc, hcard⟩ + obtain ⟨a, b, c, hab, hac, hbc, rfl⟩ := s.card_eq_three.mp hcard + have := hc (by simp) (by simp) hab + have := hc (by simp) (by simp) hbc + have := hc (by simp) (by simp) hac + grind [hasse_adj, CovBy] + end Preorder section PartialOrder diff --git a/Mathlib/Combinatorics/SimpleGraph/IncMatrix.lean b/Mathlib/Combinatorics/SimpleGraph/IncMatrix.lean index 7dce7be3752083..05fb44896d50fe 100644 --- a/Mathlib/Combinatorics/SimpleGraph/IncMatrix.lean +++ b/Mathlib/Combinatorics/SimpleGraph/IncMatrix.lean @@ -95,7 +95,7 @@ theorem incMatrix_apply_eq_zero_iff : G.incMatrix R a e = 0 ↔ e ∉ G.incidenc simp only [incMatrix_apply, Set.indicator_apply_eq_zero, Pi.one_apply, one_ne_zero] theorem incMatrix_apply_eq_one_iff : G.incMatrix R a e = 1 ↔ e ∈ G.incidenceSet a := by - convert one_ne_zero.ite_eq_left_iff + convert! one_ne_zero.ite_eq_left_iff infer_instance end MulZeroOneClass @@ -106,7 +106,7 @@ variable [NonAssocSemiring R] [DecidableEq α] [DecidableRel G.Adj] {a : α} {e theorem sum_incMatrix_apply [Fintype (Sym2 α)] [Fintype (neighborSet G a)] : ∑ e, G.incMatrix R a e = G.degree a := by - simp [incMatrix_apply', sum_boole, Set.filter_mem_univ_eq_toFinset] + simp [incMatrix_apply', sum_boole, Set.filter_mem_univ_eq_toFinset, card_incidenceSet_eq_degree] theorem incMatrix_mul_transpose_diag [Fintype (Sym2 α)] [Fintype (neighborSet G a)] : (G.incMatrix R * (G.incMatrix R)ᵀ) a a = G.degree a := by @@ -157,8 +157,8 @@ theorem incMatrix_mul_transpose_apply_of_adj (h : G.Adj a b) : (G.incMatrix R * (G.incMatrix R)ᵀ) a b = (1 : R) := by simp_rw [Matrix.mul_apply, Matrix.transpose_apply, incMatrix_apply_mul_incMatrix_apply, Set.indicator_apply, Pi.one_apply, sum_boole] - convert @Nat.cast_one R _ - convert card_singleton s(a, b) + convert! @Nat.cast_one R _ + convert! card_singleton s(a, b) rw [← coe_eq_singleton, coe_filter_univ] exact G.incidenceSet_inter_incidenceSet_of_adj h diff --git a/Mathlib/Combinatorics/SimpleGraph/Maps.lean b/Mathlib/Combinatorics/SimpleGraph/Maps.lean index ffc55e4671d0bc..7af785dbcc4cc5 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Maps.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Maps.lean @@ -652,12 +652,12 @@ def mapEdgeSet : G.edgeSet ≃ G'.edgeSet where left_inv := by rintro ⟨e, h⟩ simp only [Hom.mapEdgeSet, RelEmbedding.toRelHom, Sym2.map_map, comp_apply, Subtype.mk.injEq] - convert congr_fun Sym2.map_id e + convert! congr_fun Sym2.map_id e exact RelIso.symm_apply_apply _ _ right_inv := by rintro ⟨e, h⟩ simp only [Hom.mapEdgeSet, RelEmbedding.toRelHom, Sym2.map_map, comp_apply, Subtype.mk.injEq] - convert congr_fun Sym2.map_id e + convert! congr_fun Sym2.map_id e exact RelIso.apply_symm_apply _ _ /-- A graph isomorphism induces an equivalence of neighbor sets. -/ @@ -673,7 +673,7 @@ def mapNeighborSet (v : V) : G.neighborSet v ≃ G'.neighborSet (f v) where include f in theorem card_eq [Fintype V] [Fintype W] : Fintype.card V = Fintype.card W := by rw [← Fintype.ofEquiv_card f.toEquiv] - convert rfl + convert! rfl /-- Given a bijection, there is an embedding from the comapped graph into the original graph. -/ diff --git a/Mathlib/Combinatorics/SimpleGraph/Matching.lean b/Mathlib/Combinatorics/SimpleGraph/Matching.lean index 155e81cb76250d..c46984c916903b 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Matching.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Matching.lean @@ -334,9 +334,8 @@ lemma odd_matches_node_outside [Finite V] {u : Set V} apply Nat.not_even_iff_odd.2 c.prop haveI : Fintype ↑(Subgraph.induce M (Subtype.val '' supp c.val)).verts := Fintype.ofFinite _ classical - haveI : Fintype (c.val.supp) := Fintype.ofFinite _ - simpa [Subgraph.induce_verts, Subgraph.verts_top, Nat.card_eq_fintype_card, Set.toFinset_card, - Finset.card_image_of_injective, ← Nat.card_coe_set_eq] using hMmatch.even_card + haveI := Fintype.ofFinite c.val.supp + simpa [Finset.card_image_of_injective] using hMmatch.even_card end Finite end ConnectedComponent diff --git a/Mathlib/Combinatorics/SimpleGraph/Metric.lean b/Mathlib/Combinatorics/SimpleGraph/Metric.lean index 5edff51887e9b6..ec61b75d6f0b0b 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Metric.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Metric.lean @@ -157,8 +157,8 @@ lemma edist_eq_two_iff {u v : V} : rw [mem_commonNeighbors] at hw have := (Walk.cons hw.1 <| .cons hw.2.symm .nil).edist_le simp_all - · by_contra! hc - cases ENat.le_one_iff_eq_zero_or_eq_one.mp (Order.le_of_lt_succ hc) <;> simp_all + · by_contra + simp_all [Order.le_one_iff] lemma two_lt_edist_iff {u v : V} : 2 < G.edist u v ↔ u ≠ v ∧ ¬ G.Adj u v ∧ (G.commonNeighbors u v) = ∅ := by @@ -418,7 +418,7 @@ theorem ball_zero : G.ball c 0 = ∅ := by simp [ball] /-- The ball of radius one consists of just the center. -/ @[simp] theorem ball_one : G.ball c 1 = {c} := by - simp [ball, ENat.lt_one_iff_eq_zero] + simp [ball] /-- The ball of radius two consists of the center and its neighbors. -/ @[simp] diff --git a/Mathlib/Combinatorics/SimpleGraph/Paths.lean b/Mathlib/Combinatorics/SimpleGraph/Paths.lean index d9677005b6217c..222fad61c84c6c 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Paths.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Paths.lean @@ -147,7 +147,7 @@ theorem IsTrail.reverse {u v : V} (p : G.Walk u v) (h : p.IsTrail) : p.reverse.I theorem reverse_isTrail_iff {u v : V} (p : G.Walk u v) : p.reverse.IsTrail ↔ p.IsTrail := by constructor <;> · intro h - convert h.reverse _ + convert! h.reverse _ try rw [reverse_reverse] theorem IsTrail.of_append_left {u v w : V} {p : G.Walk u v} {q : G.Walk v w} @@ -204,7 +204,7 @@ theorem IsPath.reverse {u v : V} {p : G.Walk u v} (h : p.IsPath) : p.reverse.IsP @[simp] theorem isPath_reverse_iff {u v : V} (p : G.Walk u v) : p.reverse.IsPath ↔ p.IsPath := by - constructor <;> intro h <;> convert h.reverse; simp + constructor <;> intro h <;> convert! h.reverse; simp theorem IsPath.of_append_left {u v w : V} {p : G.Walk u v} {q : G.Walk v w} : (p.append q).IsPath → p.IsPath := by @@ -612,6 +612,30 @@ lemma endpoint_notMem_support_takeUntil {p : G.Walk u v} (hp : p.IsPath) (hw : w end WalkDecomp +theorem isPath_iff_isSubwalk_imp_nil {u v} {p : G.Walk u v} : + p.IsPath ↔ ∀ (v : V) (w : G.Walk v v), w.IsSubwalk p → w.Nil := by + refine ⟨fun hp v w hwp ↦ ?_, fun h ↦ .mk' ?_⟩ + · simp [w.isPath_iff_eq_nil.mp <| isPath_of_isSubwalk hwp hp] + · refine List.pairwise_iff_getElem.mpr fun i j _ _ _ _ ↦ ?_ + let p' := p.take j |>.drop i + have : ¬p'.Nil := by grind [nil_drop_iff, take_length] + have : p'.IsSubwalk p := isSubwalk_drop _ i |>.trans <| p.isSubwalk_take j + grind [take_getVert, getVert_eq_support_getElem] + +theorem IsTrail.isPath_iff_isSubwalk_imp_not_isCycle {u v} {p : G.Walk u v} (ht : p.IsTrail) : + p.IsPath ↔ ∀ (v : V) (w : G.Walk v v), w.IsSubwalk p → ¬w.IsCycle := by + refine ⟨by grind [isPath_iff_isSubwalk_imp_nil, IsCycle.not_nil], fun h ↦ ?_⟩ + classical + match p with + | .nil => simp + | .cons hadj p => + have hp := isPath_iff_isSubwalk_imp_not_isCycle ht.of_cons |>.mpr (h · · <| ·.cons hadj) + refine cons_isPath_iff .. |>.mpr ⟨hp, fun hup ↦ h u (p.takeUntil u hup |>.cons hadj) ?_ ?_⟩ + · rw [isSubwalk_iff_support_isInfix, support_cons, support_cons] + exact (List.prefix_cons_inj u |>.mpr <| p.support_takeUntil_prefix_support hup).isInfix + · refine cons_isCycle_iff .. |>.mpr ⟨hp.takeUntil hup, fun he ↦ ?_⟩ + exact ht.edges_nodup.notMem <| p.edges_takeUntil_subset hup he + end Walk /-! ### Type of paths -/ diff --git a/Mathlib/Combinatorics/SimpleGraph/Regularity/Chunk.lean b/Mathlib/Combinatorics/SimpleGraph/Regularity/Chunk.lean index a73a398d68dfec..a5757901105fa7 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Regularity/Chunk.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Regularity/Chunk.lean @@ -113,8 +113,8 @@ private theorem card_nonuniformWitness_sdiff_biUnion_star (hV : V ∈ P.parts) ( intro B hB unfold chunk split_ifs with h₁ - · convert card_parts_equitabilise_subset_le _ (card_aux₁ h₁) hB - · convert card_parts_equitabilise_subset_le _ (card_aux₂ hP hU h₁) hB + · convert! card_parts_equitabilise_subset_le _ (card_aux₁ h₁) hB + · convert! card_parts_equitabilise_subset_le _ (card_aux₂ hP hU h₁) hB grw [sum_const, smul_eq_mul, card_filter_atomise_le_two_pow (s := U) hX, Finpartition.card_nonuniformWitnesses_le, filter_subset] <;> simp @@ -364,12 +364,13 @@ private theorem abs_density_star_sub_density_le_eps (hPε : ↑100 ≤ ↑4 ^ #P (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUV' : U ≠ V) (hUV : ¬G.IsUniform ε U V) : |(G.edgeDensity ((star hP G ε hU V).biUnion id) ((star hP G ε hV U).biUnion id) : ℝ) - G.edgeDensity (G.nonuniformWitness ε U V) (G.nonuniformWitness ε V U)| ≤ ε / 5 := by - convert abs_edgeDensity_sub_edgeDensity_le_two_mul G.Adj - (biUnion_star_subset_nonuniformWitness hP G ε hU V) - (biUnion_star_subset_nonuniformWitness hP G ε hV U) (by sz_positivity) - (one_sub_eps_mul_card_nonuniformWitness_le_card_star hV hUV' hUV hPε hε₁) - (one_sub_eps_mul_card_nonuniformWitness_le_card_star hU hUV'.symm (fun hVU => hUV hVU.symm) - hPε hε₁) using 1 + convert! + abs_edgeDensity_sub_edgeDensity_le_two_mul G.Adj + (biUnion_star_subset_nonuniformWitness hP G ε hU V) + (biUnion_star_subset_nonuniformWitness hP G ε hV U) (by sz_positivity) + (one_sub_eps_mul_card_nonuniformWitness_le_card_star hV hUV' hUV hPε hε₁) + (one_sub_eps_mul_card_nonuniformWitness_le_card_star hU hUV'.symm (fun hVU => hUV hVU.symm) + hPε hε₁) using 1 linarith private theorem eps_le_card_star_div [Nonempty α] (hPα : #P.parts * 16 ^ #P.parts ≤ card α) @@ -511,6 +512,6 @@ theorem edgeDensity_chunk_uniform [Nonempty α] (hPα : #P.parts * 16 ^ #P.parts rw [card_product, cast_mul, card_chunk (m_pos hPα).ne', card_chunk (m_pos hPα).ne', ← cast_mul, ← mul_pow]; norm_cast simp_rw [key] - convert sum_div_card_sq_le_sum_sq_div_card (α := ℝ) + convert! sum_div_card_sq_le_sum_sq_div_card (α := ℝ) end SzemerediRegularity diff --git a/Mathlib/Combinatorics/SimpleGraph/Regularity/Uniform.lean b/Mathlib/Combinatorics/SimpleGraph/Regularity/Uniform.lean index ab98927d895395..6c603a42151d94 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Regularity/Uniform.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Regularity/Uniform.lean @@ -347,8 +347,8 @@ lemma IsEquipartition.card_biUnion_offDiag_le (hε : 0 < ε) (hP : P.IsEquiparti refine (mul_le_mul_of_nonneg_left this <| by positivity).trans ?_ suffices 1 ≤ ε / 4 * #P.parts by rw [mul_left_comm, ← sq] - convert mul_le_mul_of_nonneg_left this (mul_nonneg zero_le_two <| sq_nonneg (#A : 𝕜)) - using 1 <;> ring + convert! mul_le_mul_of_nonneg_left this (mul_nonneg zero_le_two <| sq_nonneg (#A : 𝕜)) using 1 + <;> ring rwa [← div_le_iff₀', one_div_div] positivity diff --git a/Mathlib/Combinatorics/SimpleGraph/StronglyRegular.lean b/Mathlib/Combinatorics/SimpleGraph/StronglyRegular.lean index 6e3ff1b129500f..540d7006005681 100644 --- a/Mathlib/Combinatorics/SimpleGraph/StronglyRegular.lean +++ b/Mathlib/Combinatorics/SimpleGraph/StronglyRegular.lean @@ -74,14 +74,10 @@ theorem IsSRGWith.ediam_eq_two [Nontrivial V] (h : G.IsSRGWith n k ℓ μ) (ht : by_contra! hc obtain ⟨hn, ha, he⟩ := two_lt_edist_iff.mp hc have h := h.of_not_adj hn ha - simp_rw [he, Fintype.card_eq_zero] at h - exact false_of_ne (h ▸ hm) - · by_contra! hc - cases ENat.le_one_iff_eq_zero_or_eq_one.mp (Order.le_of_lt_succ hc) with - | inl hc => - rw [ediam_eq_zero_iff_subsingleton] at hc - exact false_of_nontrivial_of_subsingleton V - | inr hc => exact ht.elim (ediam_eq_one.mp hc) + simp_all + · by_contra + have := not_subsingleton V + simp_all [Order.le_one_iff] /-- **Conway's 99-graph problem** (from https://oeis.org/A248380/a248380.pdf) can be reformulated as the existence of a strongly regular graph with params (99, 14, 1, 2). @@ -180,7 +176,7 @@ theorem IsSRGWith.param_eq letI := Classical.decEq V rw [← h.card, Fintype.card_pos_iff] at hn obtain ⟨v⟩ := hn - convert card_mul_eq_card_mul G.Adj (s := G.neighborFinset v) (t := Gᶜ.neighborFinset v) _ _ + convert! card_mul_eq_card_mul G.Adj (s := G.neighborFinset v) (t := Gᶜ.neighborFinset v) _ _ · simp [h.regular v] · simp [h.compl.regular v] · intro w hw diff --git a/Mathlib/Combinatorics/SimpleGraph/Subgraph.lean b/Mathlib/Combinatorics/SimpleGraph/Subgraph.lean index 0b71a3f1559e06..d40653ef36eb63 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Subgraph.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Subgraph.lean @@ -868,7 +868,6 @@ lemma adj_iff_of_neighborSet_equiv {v : V} {H : Subgraph G} end Subgraph -@[simp] theorem card_neighborSet_toSubgraph (G H : SimpleGraph V) (h : H ≤ G) (v : V) [Fintype ↑((toSubgraph H h).neighborSet v)] [Fintype ↑(H.neighborSet v)] : Fintype.card ↑((toSubgraph H h).neighborSet v) = H.degree v := by @@ -880,7 +879,7 @@ theorem card_neighborSet_toSubgraph (G H : SimpleGraph V) (h : H ≤ G) lemma degree_toSubgraph (G H : SimpleGraph V) (h : H ≤ G) {v : V} [Fintype ↑((toSubgraph H h).neighborSet v)] [Fintype ↑(H.neighborSet v)] : (toSubgraph H h).degree v = H.degree v := by - simp [Subgraph.degree] + simp [Subgraph.degree, card_neighborSet_toSubgraph] section MkProperties diff --git a/Mathlib/Combinatorics/SimpleGraph/Sum.lean b/Mathlib/Combinatorics/SimpleGraph/Sum.lean index 0f666058dad864..23a7317dc2db8b 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Sum.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Sum.lean @@ -28,8 +28,8 @@ both in `G` and adjacent in `G`, or they are both in `H` and adjacent in `H`. @[expose] public section namespace SimpleGraph -variable {V W U γ : Type*} {G : SimpleGraph V} {H : SimpleGraph W} {I : SimpleGraph U} - {v v' : V} {w w' : W} +variable {U U' V V' W W' γ : Type*} {G : SimpleGraph V} {H : SimpleGraph W} {I : SimpleGraph U} + {G' : SimpleGraph V'} {H' : SimpleGraph W'} {I' : SimpleGraph U'} {v v' : V} {w w' : W} /-- Disjoint sum of `G` and `H`. -/ @[simps!] @@ -71,6 +71,62 @@ def Embedding.sumInr : H ↪g G ⊕g H where inj' u v := by simp map_rel_iff' := by simp +/-- Given homomorphisms `f : G →g G'` and `g : H →g H'`, returns a homomorphism from `G ⊕g H` to +`G' ⊕g H'` that applies `f` to the left component and `g` to the right component. -/ +@[simps] +def Hom.sum (f : G →g G') (g : H →g H') : G ⊕g H →g G' ⊕g H' where + toFun := Sum.map f g + map_rel' {u v} := by cases u <;> cases v <;> simp_all [f.map_rel, g.map_rel] + +lemma Hom.sum_comp_sumComm (f : G →g G') (g : H →g H') : + comp (sum f g) Iso.sumComm.toHom = comp Iso.sumComm.toHom (sum g f) := by + ext (v | w) <;> simp + +lemma Hom.sum_sum_comp_sumAssoc (f : G →g G') (g : H →g H') (h : I →g I') : + comp (sum f (sum g h)) Iso.sumAssoc.toHom = comp Iso.sumAssoc.toHom (sum (sum f g) h) := by + ext ((v | w) | u) <;> simp + +/-- Given embeddings `f : G ↪g G'` and `g : H ↪g H'`, returns an embedding from `G ⊕g H` to +`G' ⊕g H'` that applies `f` to the left component and `g` to the right component. -/ +@[simps] +def Embedding.sum (f : G ↪g G') (g : H ↪g H') : G ⊕g H ↪g G' ⊕g H' where + toFun := Sum.map f g + inj' u v := by cases u <;> cases v <;> simp + map_rel_iff' {u v} := by cases u <;> cases v <;> simp + +lemma Embedding.toHom_sum (f : G ↪g G') (g : H ↪g H') : + (Embedding.sum f g).toHom = Hom.sum f.toHom g.toHom := rfl + +lemma Embedding.sum_comp_sumComm (f : G ↪g G') (g : H ↪g H') : + comp (sum g f) Iso.sumComm.toEmbedding = comp Iso.sumComm.toEmbedding (sum f g) := by + ext (v | w) <;> simp + +lemma Embedding.sum_sum_comp_sumAssoc (f : G ↪g G') (g : H ↪g H') (h : I ↪g I') : + comp (sum f (sum g h)) Iso.sumAssoc.toEmbedding = + comp Iso.sumAssoc.toEmbedding (sum (sum f g) h) := by + ext ((v | w) | u) <;> simp + +/-- Given isomorphisms `f : G ≃g G'` and `g : H ≃g H'`, returns an isomorphism from `G ⊕g H` to +`G' ⊕g H'` that applies `f` to the left component and `g` to the right component. -/ +@[simps!, simps toEquiv] +def Iso.sumCongr (f : G ≃g G') (g : H ≃g H') : G ⊕g H ≃g G' ⊕g H' where + toEquiv := f.toEquiv.sumCongr g.toEquiv + map_rel_iff' {u v} := by cases u <;> cases v <;> simp [f.map_rel_iff, g.map_rel_iff] + +lemma Iso.toHom_sumCongr (f : G ≃g G') (g : H ≃g H') : + (Iso.sumCongr f g).toHom = Hom.sum f.toHom g.toHom := rfl + +lemma Iso.toEmbedding_sumCongr (f : G ≃g G') (g : H ≃g H') : + (Iso.sumCongr f g).toEmbedding = Embedding.sum f.toEmbedding g.toEmbedding := rfl + +lemma Iso.sumComm_comp_sumCongr (f : G ≃g G') (g : H ≃g H') : + comp sumComm (sumCongr f g) = comp (sumCongr g f) sumComm := by + ext (v | w) <;> simp + +lemma Iso.sumAssoc_comp_sumCongr (f : G ≃g G') (g : H ≃g H') (h : I ≃g I') : + comp sumAssoc (sumCongr (sumCongr f g) h) = comp (sumCongr f (sumCongr g h)) sumAssoc := by + ext ((v | w) | u) <;> simp + lemma Reachable.sum_sup_edge (hv : G.Reachable v v') (hw : H.Reachable w w') : (G.sum H ⊔ edge (.inl v) (.inr w)).Reachable (.inl v') (.inr w') := ((hv.symm.map Embedding.sumInl.toHom).mono le_sup_left).trans <| .trans diff --git a/Mathlib/Combinatorics/SimpleGraph/Trails.lean b/Mathlib/Combinatorics/SimpleGraph/Trails.lean index 6082d7b851a461..303e89003e5a02 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Trails.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Trails.lean @@ -126,7 +126,7 @@ theorem IsEulerian.edgesFinset_eq [Fintype G.edgeSet] {u v : V} {p : G.Walk u v} theorem IsEulerian.even_degree_iff {x u v : V} {p : G.Walk u v} (ht : p.IsEulerian) [Fintype V] [DecidableRel G.Adj] : Even (G.degree x) ↔ u ≠ v → x ≠ u ∧ x ≠ v := by - convert ht.isTrail.even_countP_edges_iff x + convert! ht.isTrail.even_countP_edges_iff x rw [← Multiset.coe_countP, Multiset.countP_eq_card_filter, ← card_incidenceFinset_eq_degree] change Multiset.card _ = _ congr 1 diff --git a/Mathlib/Combinatorics/SimpleGraph/Triangle/Tripartite.lean b/Mathlib/Combinatorics/SimpleGraph/Triangle/Tripartite.lean index ad30c9ad618e3b..81537b99c29372 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Triangle/Tripartite.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Triangle/Tripartite.lean @@ -241,7 +241,7 @@ lemma locallyLinear [ExplicitDisjoint t] [NoAccidental t] : (graph t).LocallyLin classical refine ⟨?_, fun x y hxy ↦ ?_⟩ · unfold EdgeDisjointTriangles - convert map_toTriangle_disjoint t + convert! map_toTriangle_disjoint t rw [cliqueSet_eq_image, coe_map] · obtain ⟨z, hz, hxy⟩ := exists_mem_toTriangle hxy exact ⟨_, toTriangle_is3Clique hz, hxy⟩ diff --git a/Mathlib/Combinatorics/SimpleGraph/Walk/Basic.lean b/Mathlib/Combinatorics/SimpleGraph/Walk/Basic.lean index ad961bcaa36987..a5290219dd659e 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Walk/Basic.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Walk/Basic.lean @@ -270,7 +270,7 @@ theorem mem_darts_iff_infix_support {u' v'} {p : G.Walk u v} (h : G.Adj u' v') : exact ⟨i, by grind, fun j hj ↦ by grind [fst_darts_getElem, snd_darts_getElem]⟩ · have := h 0 have := h 1 - convert p.darts.getElem_mem (n := i) (by grind) + convert! p.darts.getElem_mem (n := i) (by grind) <;> grind [fst_darts_getElem, snd_darts_getElem] theorem mem_darts_iff_fst_snd_infix_support {p : G.Walk u v} {d : G.Dart} : diff --git a/Mathlib/Combinatorics/SimpleGraph/Walk/Decomp.lean b/Mathlib/Combinatorics/SimpleGraph/Walk/Decomp.lean index 2e2bd29e8df3ad..db3f99b494339a 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Walk/Decomp.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Walk/Decomp.lean @@ -185,11 +185,18 @@ theorem dropUntil_copy {u v w v' w'} (p : G.Walk v w) (hv : v = v') (hw : w = w' subst_vars rfl -theorem support_takeUntil_subset {u v w : V} (p : G.Walk v w) (h : u ∈ p.support) : +theorem support_takeUntil_prefix_support (p : G.Walk v w) (h : u ∈ p.support) : + (p.takeUntil u h).support <+: p.support := by + grw [takeUntil_eq_take, support_copy, take_support_eq_support_take_succ, List.take_prefix] + +theorem support_takeUntil_subset_support {u v w : V} (p : G.Walk v w) (h : u ∈ p.support) : (p.takeUntil u h).support ⊆ p.support := fun x hx => by rw [← take_spec p h, mem_support_append_iff] exact Or.inl hx +@[deprecated (since := "2026-05-25")] +alias support_takeUntil_subset := support_takeUntil_subset_support + theorem support_dropUntil_subset {u v w : V} (p : G.Walk v w) (h : u ∈ p.support) : (p.dropUntil u h).support ⊆ p.support := fun x hx => by rw [← take_spec p h, mem_support_append_iff] @@ -270,12 +277,13 @@ lemma length_takeUntil_lt {u v w : V} {p : G.Walk v w} (h : u ∈ p.support) (hu lemma takeUntil_takeUntil {w x : V} (p : G.Walk u v) (hw : w ∈ p.support) (hx : x ∈ (p.takeUntil w hw).support) : - (p.takeUntil w hw).takeUntil x hx = p.takeUntil x (p.support_takeUntil_subset hw hx) := by + (p.takeUntil w hw).takeUntil x hx = + p.takeUntil x (p.support_takeUntil_subset_support hw hx) := by simp_rw [← takeUntil_append_of_mem_left _ (p.dropUntil w hw) hx, take_spec] lemma notMem_support_takeUntil_support_takeUntil_subset {p : G.Walk u v} {w x : V} (h : x ≠ w) (hw : w ∈ p.support) (hx : x ∈ (p.takeUntil w hw).support) : - w ∉ (p.takeUntil x (p.support_takeUntil_subset hw hx)).support := by + w ∉ (p.takeUntil x (p.support_takeUntil_subset_support hw hx)).support := by rw [← takeUntil_takeUntil p hw hx] intro hw' have h1 : (((p.takeUntil w hw).takeUntil x hx).takeUntil w hw').length diff --git a/Mathlib/Combinatorics/SimpleGraph/Walk/Subwalks.lean b/Mathlib/Combinatorics/SimpleGraph/Walk/Subwalks.lean index 9fd767ed9609e5..2b066c87d08144 100644 --- a/Mathlib/Combinatorics/SimpleGraph/Walk/Subwalks.lean +++ b/Mathlib/Combinatorics/SimpleGraph/Walk/Subwalks.lean @@ -157,7 +157,7 @@ theorem isSubwalk_toWalk_iff_mem_edges {p : G.Walk u v} (h : G.Adj u' v') : have ⟨d, hd, h⟩ := h rw [Dart.edge, Sym2.eq, Sym2.rel_iff'] at h refine h.imp (fun h ↦ ?_) (fun h ↦ ?_) - <;> convert hd using 2 + <;> convert! hd using 2 <;> exact h.symm theorem infix_support_iff_mem_edges {p : G.Walk u v} : diff --git a/Mathlib/Combinatorics/Young/YoungDiagram.lean b/Mathlib/Combinatorics/Young/YoungDiagram.lean index 05f06844c2d4eb..df7fa4f351b824 100644 --- a/Mathlib/Combinatorics/Young/YoungDiagram.lean +++ b/Mathlib/Combinatorics/Young/YoungDiagram.lean @@ -220,7 +220,7 @@ protected theorem le_of_transpose_le {μ ν : YoungDiagram} (h_le : μ.transpose @[simp] theorem transpose_le_iff {μ ν : YoungDiagram} : μ.transpose ≤ ν.transpose ↔ μ ≤ ν := ⟨fun h => by - convert YoungDiagram.le_of_transpose_le h + convert! YoungDiagram.le_of_transpose_le h simp, fun h => by rw [← transpose_transpose μ] at h exact YoungDiagram.le_of_transpose_le h ⟩ @@ -313,7 +313,7 @@ theorem mem_col_iff {μ : YoungDiagram} {j : ℕ} {c : ℕ × ℕ} : c ∈ μ.co theorem mk_mem_col_iff {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ.col j ↔ (i, j) ∈ μ := by simp [col] protected theorem exists_notMem_col (μ : YoungDiagram) (j : ℕ) : ∃ i, (i, j) ∉ μ.cells := by - convert μ.transpose.exists_notMem_row j using 1 + convert! μ.transpose.exists_notMem_row j using 1 simp /-- Length of a column of a Young diagram -/ @@ -344,7 +344,7 @@ theorem colLen_eq_card (μ : YoungDiagram) {j : ℕ} : μ.colLen j = (μ.col j). @[gcongr, mono] theorem colLen_anti (μ : YoungDiagram) (j1 j2 : ℕ) (hj : j1 ≤ j2) : μ.colLen j2 ≤ μ.colLen j1 := by - convert μ.transpose.rowLen_anti j1 j2 hj using 1 <;> simp + convert! μ.transpose.rowLen_anti j1 j2 hj using 1 <;> simp end Columns diff --git a/Mathlib/Computability/Ackermann.lean b/Mathlib/Computability/Ackermann.lean index 0f467a8c10ef71..d100c4f3290f01 100644 --- a/Mathlib/Computability/Ackermann.lean +++ b/Mathlib/Computability/Ackermann.lean @@ -369,7 +369,7 @@ lemma eval_pappAck_step_succ (c : Code) (n) : lemma primrec_pappAck : Primrec pappAck := by suffices Primrec (Nat.rec Code.succ (fun _ c => pappAck.step c)) by - convert this using 2 with n; induction n <;> simp [pappAck, *] + convert! this using 2 with n; induction n <;> simp [pappAck, *] apply_rules [Primrec.nat_rec₁, primrec_pappAck_step.comp, Primrec.snd] @[simp] diff --git a/Mathlib/Computability/ContextFreeGrammar.lean b/Mathlib/Computability/ContextFreeGrammar.lean index f6142a08d7c695..d33ec96bc98206 100644 --- a/Mathlib/Computability/ContextFreeGrammar.lean +++ b/Mathlib/Computability/ContextFreeGrammar.lean @@ -316,7 +316,7 @@ protected lemma Derives.reverse (hg : g.Derives u v) : g.reverse.Derives u.rever | tail _ orig ih => exact ih.trans_produces orig.reverse lemma derives_reverse : g.reverse.Derives u.reverse v.reverse ↔ g.Derives u v := - ⟨fun h ↦ by convert h.reverse <;> simp, .reverse⟩ + ⟨fun h ↦ by convert! h.reverse <;> simp, .reverse⟩ @[simp] lemma derives_reverse_comm : g.reverse.Derives u v ↔ g.Derives u.reverse v.reverse := by rw [iff_comm, ← derives_reverse, List.reverse_reverse, List.reverse_reverse] diff --git a/Mathlib/Computability/Partrec.lean b/Mathlib/Computability/Partrec.lean index c8363e6f90b16b..4d7662008a38d4 100644 --- a/Mathlib/Computability/Partrec.lean +++ b/Mathlib/Computability/Partrec.lean @@ -578,7 +578,7 @@ theorem bind_decode_iff {f : α → β → Option σ} : theorem map_decode_iff {f : α → β → σ} : (Computable₂ fun a n => (decode (α := β) n).map (f a)) ↔ Computable₂ f := by - convert (bind_decode_iff (f := fun a => Option.some ∘ f a)).trans option_some_iff + convert! (bind_decode_iff (f := fun a => Option.some ∘ f a)).trans option_some_iff apply Option.map_eq_bind theorem nat_rec {f : α → ℕ} {g : α → σ} {h : α → ℕ × σ → σ} (hf : Computable f) (hg : Computable g) @@ -608,7 +608,7 @@ theorem option_bind {f : α → Option β} {g : α → β → Option σ} (hf : C theorem option_map {f : α → Option β} {g : α → β → σ} (hf : Computable f) (hg : Computable₂ g) : Computable fun a => (f a).map (g a) := by - convert option_bind hf (option_some.comp₂ hg) + convert! option_bind hf (option_some.comp₂ hg) apply Option.map_eq_bind theorem option_getD {f : α → Option β} {g : α → β} (hf : Computable f) (hg : Computable g) : diff --git a/Mathlib/Computability/Primrec/Basic.lean b/Mathlib/Computability/Primrec/Basic.lean index c1e2bc805b241a..83d9506be730ea 100644 --- a/Mathlib/Computability/Primrec/Basic.lean +++ b/Mathlib/Computability/Primrec/Basic.lean @@ -408,7 +408,7 @@ theorem Primrec₂.comp₂ {f : γ → δ → σ} {g : α → β → γ} {h : α protected lemma PrimrecPred.decide {p : α → Prop} [DecidablePred p] (hp : PrimrecPred p) : Primrec (fun a => decide (p a)) := by - convert hp.choose_spec + convert! hp.choose_spec lemma Primrec.primrecPred {p : α → Prop} [DecidablePred p] (hp : Primrec (fun a => decide (p a))) : PrimrecPred p := diff --git a/Mathlib/Computability/RE.lean b/Mathlib/Computability/RE.lean index f27d90fdeb867f..3e5602b92a5fc6 100644 --- a/Mathlib/Computability/RE.lean +++ b/Mathlib/Computability/RE.lean @@ -135,7 +135,7 @@ variable {α} [Primcodable α] protected lemma ComputablePred.decide {p : α → Prop} [DecidablePred p] (hp : ComputablePred p) : Computable (fun a => decide (p a)) := by - convert hp.choose_spec + convert! hp.choose_spec lemma Computable.computablePred {p : α → Prop} [DecidablePred p] (hp : Computable (fun a => decide (p a))) : ComputablePred p := diff --git a/Mathlib/Computability/Reduce.lean b/Mathlib/Computability/Reduce.lean index 475ab3a3e039e4..c7f16ff4f494d8 100644 --- a/Mathlib/Computability/Reduce.lean +++ b/Mathlib/Computability/Reduce.lean @@ -104,7 +104,7 @@ theorem OneOneReducible.of_equiv {α β} [Primcodable α] [Primcodable β] {e : theorem OneOneReducible.of_equiv_symm {α β} [Primcodable α] [Primcodable β] {e : α ≃ β} (q : β → Prop) (h : Computable e.symm) : q ≤₁ (q ∘ e) := by - convert OneOneReducible.of_equiv _ h; funext; simp + convert! OneOneReducible.of_equiv _ h; funext; simp instance stdRefl_oneOneReducible {α} [Primcodable α] : Std.Refl (@OneOneReducible α α _ _) where refl := oneOneReducible_refl diff --git a/Mathlib/Computability/RegularExpressions.lean b/Mathlib/Computability/RegularExpressions.lean index 4b3887a7e7eb32..27f759f5e87e2c 100644 --- a/Mathlib/Computability/RegularExpressions.lean +++ b/Mathlib/Computability/RegularExpressions.lean @@ -238,7 +238,7 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) : rw [List.cons_append, List.cons_eq_cons] at h refine ⟨t, u, h.2, ?_, hQ⟩ rw [rmatch] at hP - convert hP + convert! hP exact h.1 · rw [ih] constructor <;> rintro ⟨t, u, h, hP, hQ⟩ @@ -248,7 +248,7 @@ theorem mul_rmatch_iff (P Q : RegularExpression α) (x : List α) : · rw [List.cons_append, List.cons_eq_cons] at h refine ⟨t, u, h.2, ?_, hQ⟩ rw [rmatch] at hP - convert hP + convert! hP exact h.1 theorem star_rmatch_iff (P : RegularExpression α) : @@ -290,7 +290,7 @@ theorem star_rmatch_iff (P : RegularExpression α) : refine ⟨t, U.flatten, hsum.2, ?_, ?_⟩ · specialize helem (b :: t) (by simp) rw [rmatch] at helem - convert helem.2 + convert! helem.2 exact hsum.1 · grind termination_by t => (P, t.length) diff --git a/Mathlib/Computability/TuringMachine/PostTuringMachine.lean b/Mathlib/Computability/TuringMachine/PostTuringMachine.lean index 7654227c40a73c..d3aa8197fc4152 100644 --- a/Mathlib/Computability/TuringMachine/PostTuringMachine.lean +++ b/Mathlib/Computability/TuringMachine/PostTuringMachine.lean @@ -774,7 +774,7 @@ theorem trTape'_move_left (L R : ListBlank Γ) : | nil => cases e; rfl | cons b l₁ IH => simp only [List.length, iterate_succ_apply] - convert IH e + convert! IH e simp only [ListBlank.tail_cons, ListBlank.append, Tape.move_left_mk', ListBlank.head_cons] theorem trTape'_move_right (L R : ListBlank Γ) : diff --git a/Mathlib/Computability/TuringMachine/StackTuringMachine.lean b/Mathlib/Computability/TuringMachine/StackTuringMachine.lean index 77dcba24dc80da..4923358a8a6e32 100644 --- a/Mathlib/Computability/TuringMachine/StackTuringMachine.lean +++ b/Mathlib/Computability/TuringMachine/StackTuringMachine.lean @@ -366,7 +366,7 @@ set_option backward.isDefEq.respectTransparency false in theorem addBottom_map (L : ListBlank (∀ k, Option (Γ k))) : (addBottom L).map ⟨Prod.snd, by rfl⟩ = L := by simp only [addBottom, ListBlank.map_cons] - convert ListBlank.cons_head_tail L + convert! ListBlank.cons_head_tail L generalize ListBlank.tail L = L' refine L'.induction_on fun l ↦ ?_; simp diff --git a/Mathlib/Computability/TuringMachine/ToPartrec.lean b/Mathlib/Computability/TuringMachine/ToPartrec.lean index 53bb370df0bef6..161c480fb874ac 100644 --- a/Mathlib/Computability/TuringMachine/ToPartrec.lean +++ b/Mathlib/Computability/TuringMachine/ToPartrec.lean @@ -604,7 +604,7 @@ theorem move_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k₁ rw [e₃] at e cases e simp only [List.head?_cons, e₂, List.tail_cons, cond_false] - convert @IH _ (update (update S k₁ Sk) k₂ (a :: S k₂)) _ using 2 <;> + convert! @IH _ (update (update S k₁ Sk) k₂ (a :: S k₂)) _ using 2 <;> simp [Function.update_of_ne, h₁, h₁.symm, e₃, List.reverseAux] simp [Function.update_comm h₁.symm] @@ -621,14 +621,14 @@ theorem move₂_ok {p k₁ k₂ q s L₁ o L₂} {S : K' → List Γ'} (h₁ : k simp only [TM2.step, Option.mem_def, Option.elim] cases o <;> simp only <;> rw [tr] <;> simp only [id, TM2.stepAux, Option.isSome, cond_true, cond_false] - · convert move_ok h₁.2.1.symm (splitAtPred_false _) using 2 + · convert! move_ok h₁.2.1.symm (splitAtPred_false _) using 2 simp only [Function.update_comm h₁.1, Function.update_idem] rw [show update S rev [] = S by rw [← h₂, Function.update_eq_self]] simp only [Function.update_of_ne h₁.2.2.symm, Function.update_of_ne h₁.2.1, Function.update_of_ne h₁.1.symm, List.reverseAux_eq, h₂, Function.update_self, List.append_nil, List.reverse_reverse] · simp only [Option.getD_some] - convert move_ok h₁.2.1.symm (splitAtPred_false _) using 2 + convert! move_ok h₁.2.1.symm (splitAtPred_false _) using 2 simp only [h₂, Function.update_comm h₁.1, List.reverseAux_eq, Function.update_self, List.append_nil, Function.update_idem] rw [show update S rev [] = S by rw [← h₂, Function.update_eq_self]] @@ -661,7 +661,7 @@ theorem clear_ok {p k q s L₁ o L₂} {S : K' → List Γ'} (e : splitAtPred p rw [e₃] at e cases e simp only [List.head?_cons, e₂, List.tail_cons, cond_false] - convert @IH _ (update S k Sk) _ using 2 <;> simp [e₃] + convert! @IH _ (update S k Sk) _ using 2 <;> simp [e₃] theorem copy_ok (q s a b c d) : Reaches₁ (TM2.step tr) ⟨some (Λ'.copy q), s, K'.elim a b c d⟩ @@ -715,7 +715,7 @@ theorem head_main_ok {q s L} {c d : List Γ'} : rw [if_neg (show o ≠ some Γ'.consₗ by cases L <;> simp [o])] refine (clear_ok (splitAtPred_eq _ _ _ none [] ?_ ⟨rfl, rfl⟩)).trans ?_ · exact fun x h => Bool.decide_false (trList_ne_consₗ _ _ h) - convert unrev_ok using 2; simp [List.reverseAux_eq] + convert! unrev_ok using 2; simp [List.reverseAux_eq] theorem head_stack_ok {q s L₁ L₂ L₃} : Reaches₁ (TM2.step tr) @@ -731,7 +731,7 @@ theorem head_stack_ok {q s L₁ L₂ L₃} : simp only [TM2.step, Option.mem_def, TM2.stepAux, ite_true, id_eq, trList, List.nil_append, elim_update_stack, elim_rev, List.reverseAux_nil, elim_update_rev, Function.update_self, List.headI_nil, trNat_default] - convert unrev_ok using 2 + convert! unrev_ok using 2 simp · refine TransGen.trans @@ -748,7 +748,7 @@ theorem head_stack_ok {q s L₁ L₂ L₃} : (splitAtPred_eq _ _ (trList L₂) (some Γ'.consₗ) L₃ (fun x h => Bool.decide_false (trList_ne_consₗ _ _ h)) ⟨rfl, by simp⟩)) ?_ - convert unrev_ok using 2 + convert! unrev_ok using 2 simp [List.reverseAux_eq] theorem succ_ok {q s n} {c d : List Γ'} : @@ -758,7 +758,7 @@ theorem succ_ok {q s n} {c d : List Γ'} : rcases (n : Num) with - | a · refine TransGen.head rfl ?_ simp only [Option.mem_def] - convert unrev_ok using 1 + convert! unrev_ok using 1 simp only [elim_update_rev, elim_rev, elim_main, List.reverseAux_nil, elim_update_main] rfl simp only [trNum, Num.succ, Num.succ'] @@ -769,7 +769,7 @@ theorem succ_ok {q s n} {c d : List Γ'} : obtain ⟨l₁', l₂', s', e, h⟩ := this [] simp only [List.reverseAux] at e refine h.trans ?_ - convert unrev_ok using 2 + convert! unrev_ok using 2 simp [e, List.reverseAux_eq] induction a generalizing s with intro l₁ | one => @@ -803,7 +803,7 @@ theorem pred_ok (q₁ q₂ s v) (c d : List Γ') : ∃ s', · simp only [trPosNum, Num.succ', List.singleton_append, List.nil_append] refine TransGen.head rfl ?_ rw [tr]; simp only [pop', TM2.stepAux] - convert unrev_ok using 2 + convert! unrev_ok using 2 simp simp only [Num.succ'] suffices ∀ l₁, ∃ l₁' l₂' s', @@ -814,7 +814,7 @@ theorem pred_ok (q₁ q₂ s v) (c d : List Γ') : ∃ s', obtain ⟨l₁', l₂', s', e, h⟩ := this [] simp only [List.reverseAux] at e refine h.trans ?_ - convert unrev_ok using 2 + convert! unrev_ok using 2 simp [e, List.reverseAux_eq] induction a generalizing s with intro l₁ | one => @@ -843,7 +843,7 @@ theorem trNormal_respects (c k v s) : | succ => refine ⟨_, ⟨none, rfl⟩, head_main_ok.trans succ_ok⟩ | tail => let o : Option Γ' := List.casesOn v none fun _ _ => some Γ'.cons - refine ⟨_, ⟨o, rfl⟩, ?_⟩; convert clear_ok _ using 2 + refine ⟨_, ⟨o, rfl⟩, ?_⟩; convert! clear_ok _ using 2 · simp; rfl swap refine splitAtPred_eq _ _ (trNat v.headI) _ _ (trNat_natEnd _) ?_ @@ -854,7 +854,7 @@ theorem trNormal_respects (c k v s) : simp only [TM2.step, Option.mem_def, elim_stack, elim_update_stack, elim_update_main, elim_main, elim_rev, elim_update_rev] refine (copy_ok _ none [] (trList v).reverse _ _).trans ?_ - convert h₂ using 2 + convert! h₂ using 2 simp [List.reverseAux_eq, trContStack] | comp f _ _ IHg => exact IHg (Cont.comp f k) v s | case f g IHf IHg => @@ -918,9 +918,9 @@ theorem tr_ret_respects (k v s) : ∃ b₂, · obtain ⟨s', h₁, h₂⟩ := trNormal_respects f (Cont.fix f k) v.tail (some Γ'.cons) refine ⟨_, h₁, TransGen.head rfl <| TransGen.trans ?_ h₂⟩ rw [trCont, tr]; simp only [pop', TM2.stepAux, elim_main, this.1] - convert clear_ok (splitAtPred_eq _ _ (trNat v.headI).tail (some Γ'.cons) _ _ _) using 2 + convert! clear_ok (splitAtPred_eq _ _ (trNat v.headI).tail (some Γ'.cons) _ _ _) using 2 · simp - convert rfl + convert! rfl · exact fun x h => trNat_natEnd _ _ (List.tail_subset _ h) · exact ⟨rfl, this.2⟩ diff --git a/Mathlib/Condensed/Discrete/LocallyConstant.lean b/Mathlib/Condensed/Discrete/LocallyConstant.lean index 6ec60e11b2fc81..89820ffc889623 100644 --- a/Mathlib/Condensed/Discrete/LocallyConstant.lean +++ b/Mathlib/Condensed/Discrete/LocallyConstant.lean @@ -188,7 +188,7 @@ noncomputable def componentHom (a : Fiber (f.comap g.hom.hom)) : ConcreteCategory.ofHom { toFun x := ⟨g x.val, by simp only [Fiber.mk, Set.mem_preimage, Set.mem_singleton_iff] - convert map_eq_image _ _ x + convert! map_eq_image _ _ x exact map_preimage_eq_image_map _ _ a⟩ continuous_toFun := by -- term mode gives "unknown free variable" error. @@ -293,7 +293,7 @@ noncomputable def counit [HasExplicitFiniteCoproducts.{u} P] : haveI := CompHaus rw [this] apply congrArg symm - convert (b.preimage).prop + convert! (b.preimage).prop exact (mem_iff_eq_image (g.hom.app _ ∘ f) _ _).symm /-- diff --git a/Mathlib/Control/Applicative.lean b/Mathlib/Control/Applicative.lean index ff499c0eaf8c33..e2441e2eeb7c3d 100644 --- a/Mathlib/Control/Applicative.lean +++ b/Mathlib/Control/Applicative.lean @@ -40,6 +40,7 @@ theorem Applicative.map_seq_map (f : α → β → γ) (g : σ → β) (x : F α theorem Applicative.pure_seq_eq_map' (f : α → β) : ((pure f : F (α → β)) <*> ·) = (f <$> ·) := by simp [functor_norm] +set_option linter.overlappingInstances false in theorem Applicative.ext {F} : ∀ {A1 : Applicative F} {A2 : Applicative F} [@LawfulApplicative F A1] [@LawfulApplicative F A2], (∀ {α : Type u} (x : α), @Pure.pure _ A1.toPure _ x = @Pure.pure _ A2.toPure _ x) → diff --git a/Mathlib/Control/EquivFunctor.lean b/Mathlib/Control/EquivFunctor.lean index 9330cfa6896c78..2f8a214334db27 100644 --- a/Mathlib/Control/EquivFunctor.lean +++ b/Mathlib/Control/EquivFunctor.lean @@ -51,10 +51,10 @@ def mapEquiv : f α ≃ f β where toFun := EquivFunctor.map e invFun := EquivFunctor.map e.symm left_inv x := by - convert (congr_fun (EquivFunctor.map_trans' e e.symm) x).symm + convert! (congr_fun (EquivFunctor.map_trans' e e.symm) x).symm simp right_inv y := by - convert (congr_fun (EquivFunctor.map_trans' e.symm e) y).symm + convert! (congr_fun (EquivFunctor.map_trans' e.symm e) y).symm simp @[simp] diff --git a/Mathlib/Control/Functor.lean b/Mathlib/Control/Functor.lean index 37046a426e48de..f428d9e905aa0c 100644 --- a/Mathlib/Control/Functor.lean +++ b/Mathlib/Control/Functor.lean @@ -43,6 +43,7 @@ theorem Functor.map_comp_map (f : α → β) (g : β → γ) : ((g <$> ·) ∘ (f <$> ·) : F α → F γ) = ((g ∘ f) <$> ·) := funext fun _ => (comp_map _ _ _).symm +set_option linter.overlappingInstances false in theorem Functor.ext {F} : ∀ {F1 : Functor F} {F2 : Functor F} [@LawfulFunctor F F1] [@LawfulFunctor F F2], (∀ (α β) (f : α → β) (x : F α), @Functor.map _ F1 _ _ f x = @Functor.map _ F2 _ _ f x) → diff --git a/Mathlib/Data/Complex/Basic.lean b/Mathlib/Data/Complex/Basic.lean index 3ee3811181808a..36982101ed7b6e 100644 --- a/Mathlib/Data/Complex/Basic.lean +++ b/Mathlib/Data/Complex/Basic.lean @@ -347,6 +347,8 @@ instance instRatCast : RatCast ℂ where ratCast q := ofReal q @[simp, norm_cast] lemma ofReal_intCast (n : ℤ) : ofReal n = n := rfl @[simp, norm_cast] lemma ofReal_nnratCast (q : ℚ≥0) : ofReal q = q := rfl @[simp, norm_cast] lemma ofReal_ratCast (q : ℚ) : ofReal q = q := rfl +@[simp, norm_cast] lemma ofReal_ofScientific (m : ℕ) (s : Bool) (e : ℕ) : + ofReal (OfScientific.ofScientific m s e : ℝ) = OfScientific.ofScientific m s e := rfl @[simp] lemma re_ofNat (n : ℕ) [n.AtLeastTwo] : (ofNat(n) : ℂ).re = ofNat(n) := rfl @[simp] lemma im_ofNat (n : ℕ) [n.AtLeastTwo] : (ofNat(n) : ℂ).im = 0 := rfl @@ -358,6 +360,10 @@ instance instRatCast : RatCast ℂ where ratCast q := ofReal q @[simp, norm_cast] lemma im_nnratCast (q : ℚ≥0) : (q : ℂ).im = 0 := rfl @[simp, norm_cast] lemma ratCast_re (q : ℚ) : (q : ℂ).re = q := rfl @[simp, norm_cast] lemma ratCast_im (q : ℚ) : (q : ℂ).im = 0 := rfl +@[simp] lemma re_ofScientific (m : ℕ) (s : Bool) (e : ℕ) : + (OfScientific.ofScientific m s e : ℂ).re = OfScientific.ofScientific m s e := rfl +@[simp] lemma im_ofScientific (m : ℕ) (s : Bool) (e : ℕ) : + (OfScientific.ofScientific m s e : ℂ).im = 0 := rfl /-! ### Ring structure -/ @@ -785,7 +791,7 @@ lemma reProdIm_subset_iff {s s₁ t t₁ : Set ℝ} : s ×ℂ t ⊆ s₁ ×ℂ t /-- If `s ⊆ s₁ ⊆ ℝ` and `t ⊆ t₁ ⊆ ℝ`, then `s × t ⊆ s₁ × t₁` in `ℂ`. -/ lemma reProdIm_subset_iff' {s s₁ t t₁ : Set ℝ} : s ×ℂ t ⊆ s₁ ×ℂ t₁ ↔ s ⊆ s₁ ∧ t ⊆ t₁ ∨ s = ∅ ∨ t = ∅ := by - convert prod_subset_prod_iff + convert! prod_subset_prod_iff exact reProdIm_subset_iff variable {s t : Set ℝ} diff --git a/Mathlib/Data/DFinsupp/BigOperators.lean b/Mathlib/Data/DFinsupp/BigOperators.lean index 57f35c60c4e735..a155007e0af723 100644 --- a/Mathlib/Data/DFinsupp/BigOperators.lean +++ b/Mathlib/Data/DFinsupp/BigOperators.lean @@ -83,6 +83,35 @@ def prod [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] [CommMon (g : ∀ i, β i → γ) : γ := ∏ i ∈ f.support, g i (f i) +@[to_additive] +theorem prod_of_support_subset [∀ i, Zero (β i)] + [∀ (i) (x : β i), Decidable (x ≠ 0)] [CommMonoid γ] + {f : Π₀ i, β i} {g : (i : ι) → β i → γ} {s : Finset ι} + (hs : f.support ⊆ s) (map_zero : ∀ i ∈ s, g i 0 = 1) : + f.prod g = ∏ i ∈ s, g i (f i) := by + simp only [DFinsupp.prod] + apply Finset.prod_subset hs + intro i hi hi' + simp only [DFinsupp.mem_support_toFun, ne_eq, not_not] at hi' + rw [hi', map_zero] + exact hi + +/-- The product over two dfinsupps agree if the functions agree and are well-behaved within the +shared support. -/ +@[to_additive (attr := gcongr) +/-- The sum over two dfinsupps agree if the functions agree and are well-behaved within the +shared support. -/] +theorem prod_congr_of_eq_on_union + [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] [CommMonoid γ] + {f1 f2 : Π₀ i, β i} {g1 g2 : (i : ι) → β i → γ} + (h : ∀ x ∈ f1.support ∪ f2.support, g1 x (f1 x) = g2 x (f2 x)) + (h1 : ∀ x ∈ f1.support ∪ f2.support, g1 x 0 = 1) + (h2 : ∀ x ∈ f1.support ∪ f2.support, g2 x 0 = 1) : + f1.prod g1 = f2.prod g2 := by + rw [prod_of_support_subset Finset.subset_union_left h1, + prod_of_support_subset Finset.subset_union_right h2] + exact Finset.prod_congr rfl h + @[to_additive (attr := simp)] theorem _root_.map_dfinsuppProd {R S H : Type*} [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] @@ -238,14 +267,14 @@ def sumZeroHom [∀ i, Zero (β i)] [AddCommMonoid γ] (φ : ∀ i, ZeroHom (β · intro i H1 H2 rw [Finset.mem_inter] at H2 simp only [Multiset.mem_toFinset] at H1 H2 - convert map_zero (φ i) + convert! map_zero (φ i) exact (hy i).resolve_left (mt (And.intro H1) H2) · intro i _ rfl · intro i H1 H2 rw [Finset.mem_inter] at H2 simp only [Multiset.mem_toFinset] at H1 H2 - convert map_zero (φ i) + convert! map_zero (φ i) exact (hx i).resolve_left (mt (fun H3 => And.intro H3 H1) H2) map_zero' := by simp only [toFun_eq_coe, coe_zero, Pi.zero_apply, map_zero, Finset.sum_const_zero]; rfl @@ -316,7 +345,7 @@ theorem sumAddHom_single [∀ i, AddZeroClass (β i)] [AddCommMonoid γ] (φ : theorem sumAddHom_piSingle [∀ i, AddZeroClass (β i)] [AddCommMonoid γ] (i) (φ : β i →+ γ) : sumAddHom (Pi.single i φ) = φ.comp (evalAddMonoidHom i) := AddMonoidHom.toZeroHom_injective <| by - convert sumZeroHom_piSingle i φ.toZeroHom using 1 + convert! sumZeroHom_piSingle i φ.toZeroHom using 1 rw [DFinsupp.sumAddHom_toZeroHom] conv_lhs => enter [1, i] diff --git a/Mathlib/Data/DFinsupp/Defs.lean b/Mathlib/Data/DFinsupp/Defs.lean index dfc8cf7346c197..74c32fdb7b332e 100644 --- a/Mathlib/Data/DFinsupp/Defs.lean +++ b/Mathlib/Data/DFinsupp/Defs.lean @@ -1123,21 +1123,6 @@ def equivCongrLeft [∀ i, Zero (β i)] (h : ι ≃ κ) : (Π₀ i, β i) ≃ Π rw [comapDomain'_apply, mapRange_apply, comapDomain'_apply, Equiv.cast_eq_iff_heq, h.apply_symm_apply] -section SigmaCurry - -variable {α : ι → Type*} {δ : ∀ i, α i → Type v} - -instance hasAdd₂ [∀ i j, AddZeroClass (δ i j)] : Add (Π₀ (i : ι) (j : α i), δ i j) := - inferInstance - -instance addZeroClass₂ [∀ i j, AddZeroClass (δ i j)] : AddZeroClass (Π₀ (i : ι) (j : α i), δ i j) := - inferInstance - -instance addMonoid₂ [∀ i j, AddMonoid (δ i j)] : AddMonoid (Π₀ (i : ι) (j : α i), δ i j) := - inferInstance - -end SigmaCurry - variable {α : Option ι → Type v} /-- Adds a term to a dfinsupp, making a dfinsupp indexed by an `Option`. diff --git a/Mathlib/Data/DFinsupp/Interval.lean b/Mathlib/Data/DFinsupp/Interval.lean index 49a2401f5c65c6..fb5a449a44609f 100644 --- a/Mathlib/Data/DFinsupp/Interval.lean +++ b/Mathlib/Data/DFinsupp/Interval.lean @@ -37,7 +37,7 @@ def dfinsupp (s : Finset ι) (t : ∀ i, Finset (α i)) : Finset (Π₀ i, α i) ⟨fun f => DFinsupp.mk s fun i => f i i.2, by refine (mk_injective _).comp fun f g h => ?_ ext i hi - convert congr_fun h ⟨i, hi⟩⟩ + convert! congr_fun h ⟨i, hi⟩⟩ @[simp] theorem card_dfinsupp (s : Finset ι) (t : ∀ i, Finset (α i)) : #(s.dfinsupp t) = ∏ i ∈ s, #(t i) := @@ -50,7 +50,7 @@ theorem mem_dfinsupp_iff : f ∈ s.dfinsupp t ↔ f.support ⊆ s ∧ ∀ i ∈ · rintro ⟨f, hf, rfl⟩ rw [Function.Embedding.coeFn_mk] refine ⟨support_mk_subset, fun i hi => ?_⟩ - convert mem_pi.1 hf i hi + convert! mem_pi.1 hf i hi exact mk_of_mem hi · refine fun h => ⟨fun i _ => f i, mem_pi.2 h.2, ?_⟩ ext i diff --git a/Mathlib/Data/DFinsupp/WellFounded.lean b/Mathlib/Data/DFinsupp/WellFounded.lean index cfb1a360951f3b..9826cab5551827 100644 --- a/Mathlib/Data/DFinsupp/WellFounded.lean +++ b/Mathlib/Data/DFinsupp/WellFounded.lean @@ -105,9 +105,10 @@ theorem Lex.acc_of_single_erase [DecidableEq ι] {x : Π₀ i, α i} (i : ι) (hs : Acc (DFinsupp.Lex r s) <| single i (x i)) (hu : Acc (DFinsupp.Lex r s) <| x.erase i) : Acc (DFinsupp.Lex r s) x := by classical - convert ← @Acc.of_fibration _ _ _ _ _ (lex_fibration r s) ⟨{i}, _⟩ - (InvImage.accessible snd <| hs.prod_gameAdd hu) - convert piecewise_single_erase x i + convert! ← + @Acc.of_fibration _ _ _ _ _ (lex_fibration r s) ⟨{ i }, _⟩ + (InvImage.accessible snd <| hs.prod_gameAdd hu) + convert! piecewise_single_erase x i theorem Lex.acc_zero (hbot : ∀ ⦃i a⦄, ¬s i a 0) : Acc (DFinsupp.Lex r s) 0 := Acc.intro 0 fun _ ⟨_, _, h⟩ => (hbot h).elim @@ -187,7 +188,7 @@ variable (r : ι → ι → Prop) {s : ∀ i, α i → α i → Prop} theorem Pi.Lex.wellFounded [IsStrictTotalOrder ι r] [Finite ι] (hs : ∀ i, WellFounded (s i)) : WellFounded (Pi.Lex r (fun {i} ↦ s i)) := by obtain h | ⟨⟨x⟩⟩ := isEmpty_or_nonempty (∀ i, α i) - · convert emptyWf.wf + · convert! emptyWf.wf letI : ∀ i, Zero (α i) := fun i => ⟨(hs i).min ⊤ ⟨x i, trivial⟩⟩ haveI := Fintype.ofFinite ι refine InvImage.wf equivFunOnFintype.symm (Lex.wellFounded' (fun i a => ?_) hs ?_) @@ -244,7 +245,7 @@ instance Pi.wellFoundedLT [Finite ι] [∀ i, Preorder (α i)] [hw : ∀ i, Well WellFoundedLT (∀ i, α i) := ⟨by obtain h | ⟨⟨x⟩⟩ := isEmpty_or_nonempty (∀ i, α i) - · convert emptyWf.wf + · convert! emptyWf.wf letI : ∀ i, Zero (α i) := fun i => ⟨(hw i).wf.min ⊤ ⟨x i, trivial⟩⟩ haveI := Fintype.ofFinite ι refine InvImage.wf equivFunOnFintype.symm (DFinsupp.wellFoundedLT fun i a => ?_).wf diff --git a/Mathlib/Data/ENNReal/Operations.lean b/Mathlib/Data/ENNReal/Operations.lean index 929dd53e955b26..1e7988e8e0dce3 100644 --- a/Mathlib/Data/ENNReal/Operations.lean +++ b/Mathlib/Data/ENNReal/Operations.lean @@ -179,11 +179,11 @@ theorem add_ne_top : a + b ≠ ∞ ↔ a ≠ ∞ ∧ b ≠ ∞ := by simpa only protected lemma Finiteness.add_ne_top {a b : ℝ≥0∞} (ha : a ≠ ∞) (hb : b ≠ ∞) : a + b ≠ ∞ := ENNReal.add_ne_top.2 ⟨ha, hb⟩ -theorem mul_top' : a * ∞ = if a = 0 then 0 else ∞ := by convert WithTop.mul_top' a +theorem mul_top' : a * ∞ = if a = 0 then 0 else ∞ := by convert! WithTop.mul_top' a @[simp] theorem mul_top (h : a ≠ 0) : a * ∞ = ∞ := WithTop.mul_top h -theorem top_mul' : ∞ * a = if a = 0 then 0 else ∞ := by convert WithTop.top_mul' a +theorem top_mul' : ∞ * a = if a = 0 then 0 else ∞ := by convert! WithTop.top_mul' a @[simp] theorem top_mul (h : a ≠ 0) : ∞ * a = ∞ := WithTop.top_mul h @@ -239,7 +239,7 @@ lemma pow_lt_top (ha : a < ∞) : a ^ n < ∞ := WithTop.pow_lt_top ha end OperationsAndInfty -protected theorem add_lt_add (ac : a < c) (bd : b < d) : a + b < c + d := +@[gcongr] protected theorem add_lt_add (ac : a < c) (bd : b < d) : a + b < c + d := WithTop.add_lt_add ac bd section Cancel diff --git a/Mathlib/Data/ENat/Basic.lean b/Mathlib/Data/ENat/Basic.lean index 84b9bb9d649160..b6cd56e96969f9 100644 --- a/Mathlib/Data/ENat/Basic.lean +++ b/Mathlib/Data/ENat/Basic.lean @@ -126,9 +126,8 @@ def lift (x : ℕ∞) (h : x < ⊤) : ℕ := WithTop.untop x (WithTop.lt_top_iff instance canLift : CanLift ℕ∞ ℕ (↑) (· ≠ ⊤) := WithTop.canLift -instance : WellFoundedRelation ℕ∞ where - rel := (· < ·) - wf := IsWellFounded.wf +instance : WellFoundedRelation ℕ∞ := + WellFoundedLT.toWellFoundedRelation /-- Conversion of `ℕ∞` to `ℕ` sending `∞` to `0`. -/ def toNat : ℕ∞ → ℕ := WithTop.untopD 0 @@ -272,7 +271,7 @@ lemma toNat_le_of_le_coe {m : ℕ∞} {n : ℕ} (h : m ≤ n) : toNat m ≤ n := lemma toNat_le_toNat {m n : ℕ∞} (h : m ≤ n) (hn : n ≠ ⊤) : toNat m ≤ toNat n := toNat_le_of_le_coe <| h.trans_eq (coe_toNat hn).symm --- TODO: deprecate +@[deprecated Order.succ_eq_add_one (since := "2026-05-25")] theorem succ_def (m : ℕ∞) : Order.succ m = m + 1 := Order.succ_eq_add_one m @@ -284,21 +283,25 @@ theorem add_one_le_iff' (hn : n ≠ ⊤) : m + 1 ≤ n ↔ m < n := by · simpa · exact add_one_le_iff hm -theorem one_le_iff_ne_zero : 1 ≤ n ↔ n ≠ 0 := - Order.one_le_iff_pos.trans pos_iff_ne_zero +@[deprecated Order.one_le_iff_ne_zero (since := "2026-05-25")] +protected theorem one_le_iff_ne_zero : 1 ≤ n ↔ n ≠ 0 := + Order.one_le_iff_ne_zero +@[deprecated Order.lt_one_iff (since := "2026-05-25")] lemma lt_one_iff_eq_zero : n < 1 ↔ n = 0 := - not_le.symm.trans one_le_iff_ne_zero.not_left + Order.lt_one_iff -lemma le_one_iff_eq_zero_or_eq_one : n ≤ 1 ↔ n = 0 ∨ n = 1 := by - refine ⟨fun h ↦ ?_, fun h ↦ by cases h <;> simp_all⟩ - cases n - · simp at h - · rwa [← lt_one_iff_eq_zero, ← le_iff_lt_or_eq] +@[deprecated Order.le_one_iff (since := "2026-05-25")] +lemma le_one_iff_eq_zero_or_eq_one : n ≤ 1 ↔ n = 0 ∨ n = 1 := + Order.le_one_iff theorem lt_add_one_iff (hm : n ≠ ⊤) : m < n + 1 ↔ m ≤ n := Order.lt_add_one_iff_of_not_isMax (not_isMax_iff_ne_top.mpr hm) +@[simp] +theorem lt_two_iff : n < 2 ↔ n ≤ 1 := by + rw [← one_add_one_eq_two, lt_add_one_iff one_ne_top] + theorem add_le_add_iff_left {m n k : ENat} (h : k ≠ ⊤) : k + n ≤ k + m ↔ n ≤ m := WithTop.add_le_add_iff_left h @@ -337,8 +340,9 @@ theorem nat_induction {motive : ℕ∞ → Prop} (a : ℕ∞) (zero : motive 0) · exact top A · exact A _ +@[deprecated add_pos_of_right (since := "2026-05-25")] lemma add_one_pos : 0 < n + 1 := - succ_def n ▸ Order.bot_lt_succ n + add_pos_of_right zero_lt_one n lemma natCast_lt_succ {n : ℕ} : (n : ℕ∞) < (n : ℕ∞) + 1 := by @@ -438,7 +442,7 @@ lemma self_le_mul_right (a : ℕ∞) (hc : c ≠ 0) : a ≤ a * c := by · simp [top_mul hc] obtain rfl | h0 := eq_or_ne a 0 · simp - nth_rewrite 1 [← mul_one a, ENat.mul_le_mul_left_iff h0 hne, ENat.one_le_iff_ne_zero] + nth_rewrite 1 [← mul_one a, ENat.mul_le_mul_left_iff h0 hne, Order.one_le_iff_ne_zero] assumption lemma self_le_mul_left (a : ℕ∞) (hc : c ≠ 0) : a ≤ c * a := by diff --git a/Mathlib/Data/ENat/Lattice.lean b/Mathlib/Data/ENat/Lattice.lean index c47b8b5b05d7a9..41719f89c4c4ab 100644 --- a/Mathlib/Data/ENat/Lattice.lean +++ b/Mathlib/Data/ENat/Lattice.lean @@ -69,7 +69,7 @@ lemma iInf_toNat : (⨅ i, (f i : ℕ∞)).toNat = ⨅ i, f i := by · norm_cast @[simp] lemma iInf_eq_zero {f : ι → ℕ∞} : ⨅ i, f i = 0 ↔ ∃ i, f i = 0 := by - simpa [lt_one_iff_eq_zero] using iInf_lt_iff (α := ℕ∞) (a := 1) + simpa [Order.lt_one_iff] using iInf_lt_iff (α := ℕ∞) (a := 1) variable {f : ι → ℕ∞} {s : Set ℕ∞} @@ -77,8 +77,8 @@ lemma sSup_eq_zero : sSup s = 0 ↔ ∀ a ∈ s, a = 0 := sSup_eq_bot lemma sInf_eq_zero : sInf s = 0 ↔ 0 ∈ s := by - rw [← lt_one_iff_eq_zero] - simp only [sInf_lt_iff, lt_one_iff_eq_zero, exists_eq_right] + rw [← Order.lt_one_iff, sInf_lt_iff] + simp lemma sSup_eq_zero' : sSup s = 0 ↔ s = ∅ ∨ s = {0} := sSup_eq_bot' diff --git a/Mathlib/Data/ENat/Pow.lean b/Mathlib/Data/ENat/Pow.lean index 7c3eb694600feb..71e651332f409f 100644 --- a/Mathlib/Data/ENat/Pow.lean +++ b/Mathlib/Data/ENat/Pow.lean @@ -84,42 +84,45 @@ lemma epow_right_mono (h : x ≠ 0) : Monotone (fun y : ℕ∞ ↦ x ^ y) := by · rw [top_le_iff.1 y_z] induction z · rcases lt_trichotomy x 1 with x_0 | rfl | x_2 - · exact (h (lt_one_iff_eq_zero.1 x_0)).rec + · exact (h (Order.lt_one_iff.1 x_0)).rec · simp only [one_epow, le_refl] · simp only [epow_top x_2, le_top] - · exact pow_right_mono₀ (one_le_iff_ne_zero.2 h) (Nat.cast_le.1 y_z) + · exact pow_right_mono₀ (Order.one_le_iff_ne_zero.2 h) (Nat.cast_le.1 y_z) lemma one_le_epow (h : x ≠ 0) : 1 ≤ x ^ y := by simpa using epow_right_mono h zero_le +lemma epow_pos (h : x ≠ 0) : 0 < x ^ y := by + rw [← Order.one_le_iff_pos]; exact one_le_epow h + lemma epow_left_mono : Monotone (fun x : ℕ∞ ↦ x ^ y) := by intro x z x_z simp only induction y · rcases lt_trichotomy x 1 with x_0 | rfl | x_2 - · rw [lt_one_iff_eq_zero.1 x_0, zero_epow_top]; exact bot_le - · rw [one_epow]; exact one_le_epow (one_le_iff_ne_zero.1 x_z) + · rw [Order.lt_one_iff.1 x_0, zero_epow_top]; exact bot_le + · rw [one_epow]; exact one_le_epow (Order.one_le_iff_ne_zero.1 x_z) · rw [epow_top (x_2.trans_le x_z)]; exact le_top · simp only [epow_natCast, (pow_left_mono _) x_z] lemma epow_eq_zero_iff : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by refine ⟨fun h ↦ ⟨?_, fun y_0 ↦ ?_⟩, fun h ↦ h.1.symm ▸ zero_epow h.2⟩ - · by_contra x_0 - exact (one_le_iff_ne_zero.1 (one_le_epow (y := y) x_0) h).rec + · contrapose! h + exact (epow_pos h).ne' · rw [y_0, epow_zero] at h; contradiction lemma epow_eq_one_iff : x ^ y = 1 ↔ x = 1 ∨ y = 0 := by refine ⟨fun h ↦ or_iff_not_imp_right.2 fun y_0 ↦ ?_, fun h ↦ by rcases h with h | h <;> simp [h]⟩ rcases lt_trichotomy x 1 with x_0 | rfl | x_2 - · rw [lt_one_iff_eq_zero.1 x_0, zero_epow y_0] at h; contradiction + · rw [Order.lt_one_iff.1 x_0, zero_epow y_0] at h; contradiction · rfl - · have := epow_right_mono (one_le_iff_ne_zero.1 x_2.le) (one_le_iff_ne_zero.2 y_0) + · have := epow_right_mono x_2.ne_zero (Order.one_le_iff_ne_zero.2 y_0) simp only [epow_one, h] at this exact (not_lt_of_ge this x_2).rec lemma epow_add : x ^ (y + z) = x ^ y * x ^ z := by rcases lt_trichotomy x 1 with x_0 | rfl | x_2 - · rw [lt_one_iff_eq_zero.1 x_0] + · rw [Order.lt_one_iff.1 x_0] rcases eq_zero_or_pos y with rfl | y_0 · simp only [zero_add, epow_zero, one_mul] · rw [zero_epow y_0.ne.symm, zero_mul] @@ -127,20 +130,20 @@ lemma epow_add : x ^ (y + z) = x ^ y * x ^ z := by · simp only [one_epow, mul_one] · induction y · rw [top_add, epow_top x_2, top_mul] - exact one_le_iff_ne_zero.1 (one_le_epow (one_le_iff_ne_zero.1 x_2.le)) + exact (epow_pos x_2.ne_zero).ne' induction z · rw [add_top, epow_top x_2, mul_top] - exact one_le_iff_ne_zero.1 (one_le_epow (one_le_iff_ne_zero.1 x_2.le)) + exact (epow_pos x_2.ne_zero).ne' simp only [← Nat.cast_add, epow_natCast, pow_add x] set_option backward.isDefEq.respectTransparency false in lemma mul_epow : (x * y) ^ z = x ^ z * y ^ z := by induction z · rcases lt_trichotomy x 1 with x_0 | rfl | x_2 - · simp only [lt_one_iff_eq_zero.1 x_0, zero_mul, zero_epow_top] + · simp only [Order.lt_one_iff.1 x_0, zero_mul, zero_epow_top] · simp only [one_mul, one_epow] · rcases lt_trichotomy y 1 with y_0 | rfl | y_2 - · simp only [lt_one_iff_eq_zero.1 y_0, mul_zero, zero_epow_top] + · simp only [Order.lt_one_iff.1 y_0, mul_zero, zero_epow_top] · simp · rw [epow_top x_2, epow_top y_2, WithTop.top_mul_top] exact epow_top (one_lt_mul x_2.le y_2) @@ -152,15 +155,14 @@ lemma epow_mul : x ^ (y * z) = (x ^ y) ^ z := by rcases eq_or_ne z 0 with z_0 | z_0 · simp [z_0] rcases lt_trichotomy x 1 with x_0 | rfl | x_2 - · rw [lt_one_iff_eq_zero.1 x_0, zero_epow y_0, zero_epow z_0, zero_epow (mul_ne_zero y_0 z_0)] + · rw [Order.lt_one_iff.1 x_0, zero_epow y_0, zero_epow z_0, zero_epow (mul_ne_zero y_0 z_0)] · simp only [one_epow] · induction y · rw [top_mul z_0, epow_top x_2, top_epow z_0] induction z - · rw [mul_top y_0, epow_top x_2] - apply (epow_top _).symm - apply (epow_right_mono (one_le_iff_ne_zero.1 x_2.le) (one_le_iff_ne_zero.2 y_0)).trans_lt' - simp only [x_2, epow_one] + · rw [mul_top y_0, epow_top x_2, epow_top] + apply (epow_right_mono x_2.ne_zero (Order.one_le_iff_ne_zero.2 y_0)).trans_lt' + simp [x_2] · simp only [← Nat.cast_mul, epow_natCast, pow_mul x] end ENat diff --git a/Mathlib/Data/EReal/Operations.lean b/Mathlib/Data/EReal/Operations.lean index 2454d12fef8baf..d815387a89f3e8 100644 --- a/Mathlib/Data/EReal/Operations.lean +++ b/Mathlib/Data/EReal/Operations.lean @@ -811,7 +811,7 @@ lemma nsmul_eq_mul (n : ℕ) (x : EReal) : n • x = n * x := by | zero => rw [zero_smul, Nat.cast_zero, zero_mul] | succ n ih => rw [succ_nsmul, ih, Nat.cast_succ] - convert (EReal.right_distrib_of_nonneg _ _).symm <;> simp + convert! (EReal.right_distrib_of_nonneg _ _).symm <;> simp end EReal diff --git a/Mathlib/Data/Fin/SuccPred.lean b/Mathlib/Data/Fin/SuccPred.lean index c7560b79ad514a..99b76ec9f062f4 100644 --- a/Mathlib/Data/Fin/SuccPred.lean +++ b/Mathlib/Data/Fin/SuccPred.lean @@ -75,7 +75,7 @@ theorem succ_one_eq_two' [NeZero n] : Fin.succ (1 : Fin (n + 1)) = 2 := by The `Fin.le_zero_iff` in `Lean` only applies in `Fin (n+1)`. This one instead uses a `NeZero n` typeclass hypothesis. -/ -@[simp] +@[deprecated "use `nonpos_iff_eq_zero`" (since := "2026-05-11")] theorem le_zero_iff' {n : ℕ} [NeZero n] {k : Fin n} : k ≤ 0 ↔ k = 0 := ⟨fun h => Fin.ext <| by rw [Nat.eq_zero_of_le_zero h]; rfl, by rintro rfl; exact Nat.le_refl _⟩ diff --git a/Mathlib/Data/Fin/Tuple/Basic.lean b/Mathlib/Data/Fin/Tuple/Basic.lean index f83904d503e3aa..afa7f0ab0e7fc1 100644 --- a/Mathlib/Data/Fin/Tuple/Basic.lean +++ b/Mathlib/Data/Fin/Tuple/Basic.lean @@ -196,7 +196,7 @@ theorem consCases_cons {motive : (∀ i : Fin n.succ, α i) → Sort v} def consInduction {α : Sort*} {motive : ∀ {n : ℕ}, (Fin n → α) → Sort v} (elim0 : motive Fin.elim0) (cons : ∀ {n} (x₀) (x : Fin n → α), motive x → motive (Fin.cons x₀ x)) : ∀ {n : ℕ} (x : Fin n → α), motive x - | 0, x => by convert elim0 + | 0, x => by convert! elim0 | _ + 1, x => consCases (fun _ _ ↦ cons _ _ <| consInduction elim0 cons _) x theorem cons_injective_of_injective {α} {x₀ : α} {x : Fin n → α} (hx₀ : x₀ ∉ Set.range x) @@ -511,12 +511,12 @@ def snoc (p : ∀ i : Fin n, α i.castSucc) (x : α (last n)) (i : Fin (n + 1)) theorem init_snoc : init (snoc p x) = p := by ext i simp only [init, snoc, val_castSucc, is_lt, dite_true] - convert cast_eq rfl (p i) + convert! cast_eq rfl (p i) @[simp] theorem snoc_castSucc : snoc p x i.castSucc = p i := by simp only [snoc, val_castSucc, is_lt, dite_true] - convert cast_eq rfl (p i) + convert! cast_eq rfl (p i) @[simp] theorem snoc_apply_zero [NeZero n] : snoc p x 0 = p 0 := snoc_castSucc x p 0 @@ -729,7 +729,7 @@ def snocInduction {α : Sort*} (elim0 : motive Fin.elim0) (snoc : ∀ {n} (x : Fin n → α) (x₀), motive x → motive (Fin.snoc x x₀)) : ∀ {n : ℕ} (x : Fin n → α), motive x - | 0, x => by convert elim0 + | 0, x => by convert! elim0 | _ + 1, x => snocCases (fun _ _ ↦ snoc _ _ <| snocInduction elim0 snoc _) x theorem snoc_injective_of_injective {α} {x₀ : α} {x : Fin n → α} @@ -802,7 +802,7 @@ theorem forall_fin_add_pi {γ : Fin (m + n) → Sort*} {P : (∀ i, γ i) → Pr (∀ (vₘ : ∀ i, γ (castAdd n i)) (vₙ : ∀ j, γ (natAdd m j)), P (addCases vₘ vₙ)) where mp hv vm vn := hv (addCases vm vn) mpr h v := by - convert h (fun i => v (castAdd n i)) (fun j => v (natAdd m j)) + convert! h (fun i => v (castAdd n i)) (fun j => v (natAdd m j)) exact (addCases_castAdd_natAdd v).symm lemma exists_iff_castSucc {P : Fin (n + 1) → Prop} : @@ -926,7 +926,7 @@ theorem insertNth_zero (x : α 0) (p : ∀ j : Fin n, α (succAbove 0 j)) : cons x fun j ↦ _root_.cast (congr_arg α (congr_fun succAbove_zero j)) (p j) := by refine insertNth_eq_iff.2 ⟨by simp, ?_⟩ ext j - convert (cons_succ x p j).symm + convert! (cons_succ x p j).symm @[simp] theorem insertNth_zero' (x : β) (p : Fin n → β) : @insertNth _ (fun _ ↦ β) 0 x p = cons x p := by diff --git a/Mathlib/Data/Finite/Prod.lean b/Mathlib/Data/Finite/Prod.lean index ba49a9e0ede989..7b421a871790c3 100644 --- a/Mathlib/Data/Finite/Prod.lean +++ b/Mathlib/Data/Finite/Prod.lean @@ -62,7 +62,7 @@ instance Function.Embedding.finite {α β : Sort*} [Finite β] : Finite (α ↪ instance Equiv.finite_right {α β : Sort*} [Finite β] : Finite (α ≃ β) := Finite.of_injective Equiv.toEmbedding fun e₁ e₂ h => Equiv.ext <| by - convert DFunLike.congr_fun h using 0 + convert! DFunLike.congr_fun h using 0 instance Equiv.finite_left {α β : Sort*} [Finite α] : Finite (α ≃ β) := Finite.of_equiv _ ⟨Equiv.symm, Equiv.symm, Equiv.symm_symm, Equiv.symm_symm⟩ diff --git a/Mathlib/Data/Finset/Card.lean b/Mathlib/Data/Finset/Card.lean index 054f7932645968..a3527d4360bdf0 100644 --- a/Mathlib/Data/Finset/Card.lean +++ b/Mathlib/Data/Finset/Card.lean @@ -39,7 +39,7 @@ variable {α β R : Type*} namespace Finset -variable {s t : Finset α} {a b : α} +variable {s t : Finset α} {a b c : α} /-- `s.card` is the number of elements of `s`, aka its cardinality. @@ -135,8 +135,17 @@ theorem card_insert_eq_ite : #(insert a s) = if a ∈ s then #s else #s + 1 := b @[simp] theorem card_pair_eq_one_or_two : #{a, b} = 1 ∨ #{a, b} = 2 := by grind -theorem card_pair (h : a ≠ b) : #{a, b} = 2 := by - simp [h] +/-- A two-element finset `{a, b}` has cardinality `2` iff `a ≠ b`. The reverse direction is +`Finset.card_pair`. -/ +theorem card_pair_eq_two_iff : #{a, b} = 2 ↔ a ≠ b := by + aesop (add simp card_insert_eq_ite) + +alias ⟨_, card_pair⟩ := card_pair_eq_two_iff + +/-- A three-element finset `{a, b, c}` has cardinality `3` iff `a`, `b`, `c` are pairwise +distinct. -/ +theorem card_triple_eq_three_iff : #{a, b, c} = 3 ↔ a ≠ b ∧ a ≠ c ∧ b ≠ c := by + aesop (add simp card_insert_eq_ite) /-- $\#(s \setminus \{a\}) = \#s - 1$ if $a \in s$. -/ @[simp, grind =] diff --git a/Mathlib/Data/Finset/DenselyOrdered.lean b/Mathlib/Data/Finset/DenselyOrdered.lean index e6ecebf37a28c4..628be41a4d3098 100644 --- a/Mathlib/Data/Finset/DenselyOrdered.lean +++ b/Mathlib/Data/Finset/DenselyOrdered.lean @@ -22,7 +22,7 @@ variable {α : Type*} [LinearOrder α] [DenselyOrdered α] theorem Finset.exists_between {s t : Finset α} (hs : s.Nonempty) (ht : t.Nonempty) (H : ∀ x ∈ s, ∀ y ∈ t, x < y) : ∃ b, (∀ x ∈ s, x < b) ∧ (∀ y ∈ t, b < y) := by - convert _root_.exists_between (a₁ := s.max' hs) (a₂ := t.min' ht) (by simp_all) <;> simp + convert! _root_.exists_between (a₁ := s.max' hs) (a₂ := t.min' ht) (by simp_all) <;> simp theorem Finset.exists_between' (s t : Finset α) [NoMaxOrder α] [NoMinOrder α] [Nonempty α] (H : ∀ x ∈ s, ∀ y ∈ t, x < y) : ∃ b, (∀ x ∈ s, x < b) ∧ (∀ y ∈ t, b < y) := by @@ -35,10 +35,12 @@ theorem Finset.exists_between' (s t : Finset α) [NoMaxOrder α] [NoMinOrder α] theorem Set.Finite.exists_between {s t : Set α} (hsf : s.Finite) (hs : s.Nonempty) (htf : t.Finite) (ht : t.Nonempty) (H : ∀ x ∈ s, ∀ y ∈ t, x < y) : ∃ b, (∀ x ∈ s, x < b) ∧ (∀ y ∈ t, b < y) := by - convert Finset.exists_between (s := hsf.toFinset) (t := htf.toFinset) - (by simpa) (by simpa) (by simpa) using 1; simp + convert! + Finset.exists_between (s := hsf.toFinset) (t := htf.toFinset) (by simpa) (by simpa) + (by simpa) using + 1; simp theorem Set.Finite.exists_between' [NoMaxOrder α] [NoMinOrder α] [Nonempty α] {s t : Set α} (hs : s.Finite) (ht : t.Finite) (H : ∀ x ∈ s, ∀ y ∈ t, x < y) : ∃ b, (∀ x ∈ s, x < b) ∧ (∀ y ∈ t, b < y) := by - convert hs.toFinset.exists_between' ht.toFinset (by simpa) using 1; simp + convert! hs.toFinset.exists_between' ht.toFinset (by simpa) using 1; simp diff --git a/Mathlib/Data/Finset/Finsupp.lean b/Mathlib/Data/Finset/Finsupp.lean index 0eec0ed4dc5e78..0976494946549d 100644 --- a/Mathlib/Data/Finset/Finsupp.lean +++ b/Mathlib/Data/Finset/Finsupp.lean @@ -52,7 +52,7 @@ theorem mem_finsupp_iff {t : ι → Finset α} : refine mem_map.trans ⟨?_, ?_⟩ · rintro ⟨f, hf, rfl⟩ refine ⟨support_indicator_subset _ _, fun i hi => ?_⟩ - convert mem_pi.1 hf i hi + convert! mem_pi.1 hf i hi exact indicator_of_mem hi _ · refine fun h => ⟨fun i _ => f i, mem_pi.2 h.2, ?_⟩ ext i diff --git a/Mathlib/Data/Finset/Image.lean b/Mathlib/Data/Finset/Image.lean index be28b6058eaa6e..df3d91f5d0943f 100644 --- a/Mathlib/Data/Finset/Image.lean +++ b/Mathlib/Data/Finset/Image.lean @@ -397,6 +397,17 @@ theorem image_subset_image_iff {t : Finset α} (hf : Injective f) : s.image f ⊆ t.image f ↔ s ⊆ t := mod_cast Set.image_subset_image_iff hf (s := s) (t := t) +/-- Variant of `Finset.image_subset_image_iff` under an `InjOn` rather than `Injective` +hypothesis. -/ +theorem image_subset_image_iff_of_injOn {s₁ s₂ : Finset α} (ht : (s : Set α).InjOn f) + (h₁ : s₁ ⊆ s) (h₂ : s₂ ⊆ s) : s₁.image f ⊆ s₂.image f ↔ s₁ ⊆ s₂ := by + exact_mod_cast ht.image_subset_image_iff (mod_cast h₁) (mod_cast h₂) + +/-- Variant of `Finset.image_inj` under an `InjOn` rather than `Injective` hypothesis. -/ +theorem image_eq_image_iff_of_injOn {s₁ s₂ : Finset α} (ht : (s : Set α).InjOn f) + (h₁ : s₁ ⊆ s) (h₂ : s₂ ⊆ s) : s₁.image f = s₂.image f ↔ s₁ = s₂ := by + exact_mod_cast ht.image_eq_image_iff (mod_cast h₁) (mod_cast h₂) + lemma image_ssubset_image {t : Finset α} (hf : Injective f) : s.image f ⊂ t.image f ↔ s ⊂ t := by simp_rw [← lt_iff_ssubset] exact lt_iff_lt_of_le_iff_le' (image_subset_image_iff hf) (image_subset_image_iff hf) @@ -637,7 +648,7 @@ subtype. -/ theorem map_subtype_subset {t : Set α} (s : Finset t) : ↑(s.map (Embedding.subtype _)) ⊆ t := by intro a ha rw [mem_coe] at ha - convert property_of_mem_map_subtype s ha + convert! property_of_mem_map_subtype s ha end Subtype diff --git a/Mathlib/Data/Finset/NoncommProd.lean b/Mathlib/Data/Finset/NoncommProd.lean index 85415d966e9d41..6c245360b212f7 100644 --- a/Mathlib/Data/Finset/NoncommProd.lean +++ b/Mathlib/Data/Finset/NoncommProd.lean @@ -409,7 +409,7 @@ theorem noncommProd_mulSingle [Fintype ι] [DecidableEq ι] (x : ∀ i, M i) : case a => intro i _ j _ _ exact Pi.mulSingle_apply_commute x i j - convert (noncommProd_congr (insert_erase (mem_univ i)).symm _ _).trans _ + convert! (noncommProd_congr (insert_erase (mem_univ i)).symm _ _).trans _ · intro j exact Pi.mulSingle j (x j) i · intro j _; dsimp diff --git a/Mathlib/Data/Finset/PiInduction.lean b/Mathlib/Data/Finset/PiInduction.lean index 21650d0a599b94..42e846a75ec20e 100644 --- a/Mathlib/Data/Finset/PiInduction.lean +++ b/Mathlib/Data/Finset/PiInduction.lean @@ -48,7 +48,7 @@ theorem induction_on_pi_of_choice (r : ∀ i, α i → Finset (α i) → Prop) induction hs : univ.sigma f using Finset.strongInductionOn generalizing f with | _ s ihs subst s rcases eq_empty_or_nonempty (univ.sigma f) with he | hne - · convert h0 using 1 + · convert! h0 using 1 simpa [funext_iff] using he · rcases sigma_nonempty.1 hne with ⟨i, -, hi⟩ rcases H_ex i (f i) hi with ⟨x, x_mem, hr⟩ diff --git a/Mathlib/Data/Finset/Powerset.lean b/Mathlib/Data/Finset/Powerset.lean index 46a2f2aabcd2c2..4c49c337576199 100644 --- a/Mathlib/Data/Finset/Powerset.lean +++ b/Mathlib/Data/Finset/Powerset.lean @@ -78,6 +78,13 @@ theorem image_injOn_powerset_of_injOn {β : Type*} [DecidableEq β] {f : α → have {z a} (_ : z ⊆ s) (_ : a ∈ s) : a ∈ z ↔ f a ∈ z.image f := by grind [H.eq_iff] exact fun _ _ _ _ _ => by grind +/-- Variant of `Finset.image_injOn_powerset_of_injOn` for a family `S` of finsets whose +union supports an `InjOn` hypothesis, rather than the full powerset of a set. -/ +theorem injOn_image_of_biUnion_injOn {β : Type*} [DecidableEq α] [DecidableEq β] + {S : Finset (Finset α)} {f : α → β} (hf : (S.biUnion id : Set α).InjOn f) : + (S : Set (Finset α)).InjOn (·.image f) := + (image_injOn_powerset_of_injOn hf).mono (by aesop (add simp Set.subset_def)) + /-- `s.biUnion id ⊆ t` iff every member of `s` is a subset of `t`, i.e. `s ⊆ t.powerset`. -/ lemma biUnion_id_subset_iff_subset_powerset [DecidableEq α] {s : Finset (Finset α)} : s.biUnion id ⊆ t ↔ s ⊆ t.powerset := by diff --git a/Mathlib/Data/Finset/Slice.lean b/Mathlib/Data/Finset/Slice.lean index b7ae1c4a243669..8f693aee928be5 100644 --- a/Mathlib/Data/Finset/Slice.lean +++ b/Mathlib/Data/Finset/Slice.lean @@ -6,7 +6,6 @@ Authors: Bhavik Mehta, Alena Gusakov, Yaël Dillies module public import Mathlib.Data.Fintype.Powerset -public import Mathlib.Order.Antichain public import Mathlib.Order.Interval.Finset.Nat public import Mathlib.Algebra.BigOperators.Group.Finset.Basic diff --git a/Mathlib/Data/Finset/Sort.lean b/Mathlib/Data/Finset/Sort.lean index ddfc5d8329bb9e..6d84598bc9cd61 100644 --- a/Mathlib/Data/Finset/Sort.lean +++ b/Mathlib/Data/Finset/Sort.lean @@ -304,8 +304,8 @@ lemma orderEmbOfFin_compl_singleton {n : ℕ} {i : Fin (n + 1)} {k : ℕ} (Fin.succAboveOrderEmb i) := by apply DFunLike.coe_injective rw [eq_comm] - convert orderEmbOfFin_unique _ (fun x ↦ ?_) - ((Fin.strictMono_succAbove _).comp (Fin.cast_strictMono _)) + convert! + orderEmbOfFin_unique _ (fun x ↦ ?_) ((Fin.strictMono_succAbove _).comp (Fin.cast_strictMono _)) · simp · simp [← h, card_compl] diff --git a/Mathlib/Data/Finset/Sym.lean b/Mathlib/Data/Finset/Sym.lean index 8dd49cbdb52f53..07d6e1e91b2e75 100644 --- a/Mathlib/Data/Finset/Sym.lean +++ b/Mathlib/Data/Finset/Sym.lean @@ -206,7 +206,7 @@ lemma sym_map [DecidableEq β] {n : ℕ} (g : α ↪ β) (s : Finset α) : rw [← hi] exact (hd e he).choose_spec.1 · simp only [Sym.map_map, Function.comp_apply, g'] - convert Sym.attach_map_coe d with ⟨x, hx⟩ hx' + convert! Sym.attach_map_coe d with ⟨x, hx⟩ hx' exact (hd x hx).choose_spec.2 · rw [← hd', Sym.mem_map] at hd obtain ⟨a, ha, rfl⟩ := hd @@ -275,7 +275,7 @@ theorem sym_filterNe_mem {m : Sym α n} (a : α) (h : m ∈ s.sym n) : for `0 ≤ i ≤ n`. -/ @[simps] def symInsertEquiv (h : a ∉ s) : (insert a s).sym n ≃ Σ i : Fin (n + 1), s.sym (n - i) where - toFun m := ⟨_, (m.1.filterNe a).2, by convert sym_filterNe_mem a m.2; rw [erase_insert h]⟩ + toFun m := ⟨_, (m.1.filterNe a).2, by convert! sym_filterNe_mem a m.2; rw [erase_insert h]⟩ invFun m := ⟨m.2.1.fill a m.1, sym_fill_mem a m.2.2⟩ left_inv m := Subtype.ext <| m.1.fill_filterNe a right_inv := fun ⟨i, m, hm⟩ ↦ by diff --git a/Mathlib/Data/Finsupp/Basic.lean b/Mathlib/Data/Finsupp/Basic.lean index e46c8caa20f633..682adeef183b67 100644 --- a/Mathlib/Data/Finsupp/Basic.lean +++ b/Mathlib/Data/Finsupp/Basic.lean @@ -363,7 +363,7 @@ theorem mapDomain_apply' (S : Set α) {f : α → β} (x : α →₀ M) (hS : (x simp_rw [single_apply] by_cases hax : a ∈ x.support · rw [← Finset.add_sum_erase _ _ hax, if_pos rfl] - convert add_zero (x a) + convert! add_zero (x a) refine Finset.sum_eq_zero fun i hi => if_neg ?_ exact (hf.mono hS).ne (Finset.mem_of_mem_erase hi) hax (Finset.ne_of_mem_erase hi) · rw [notMem_support_iff.1 hax] @@ -1391,7 +1391,7 @@ end Sigma lemma mem_range_embDomain_iff [AddCommMonoid M] (f : α ↪ β) (x : β →₀ M) : x ∈ Set.range (embDomain f) ↔ ↑x.support ⊆ Set.range f := by - convert mem_range_mapDomain_iff _ f.injective _ + convert! mem_range_mapDomain_iff _ f.injective _ · ext; rw [embDomain_eq_mapDomain] · grind diff --git a/Mathlib/Data/Finsupp/BigOperators.lean b/Mathlib/Data/Finsupp/BigOperators.lean index 92c0d964d5863e..107461dea1c411 100644 --- a/Mathlib/Data/Finsupp/BigOperators.lean +++ b/Mathlib/Data/Finsupp/BigOperators.lean @@ -54,7 +54,7 @@ theorem Multiset.support_sum_subset [AddCommMonoid M] (s : Multiset (ι →₀ M theorem Finset.support_sum_subset [AddCommMonoid M] (s : Finset (ι →₀ M)) : (s.sum id).support ⊆ Finset.sup s Finsupp.support := by - classical convert Multiset.support_sum_subset s.1; simp + classical convert! Multiset.support_sum_subset s.1; simp theorem List.mem_foldr_sup_support_iff [Zero M] {l : List (ι →₀ M)} {x : ι} : x ∈ l.foldr (Finsupp.support · ⊔ ·) ∅ ↔ ∃ f ∈ l, x ∈ f.support := by @@ -101,7 +101,7 @@ theorem Multiset.support_sum_eq [AddCommMonoid M] (s : Multiset (ι →₀ M)) induction s using Quot.inductionOn with | _ a obtain ⟨l, hl, hd⟩ := hs suffices a.Pairwise (_root_.Disjoint on Finsupp.support) by - convert List.support_sum_eq a this + convert! List.support_sum_eq a this dsimp only [Function.comp_def] simp only [quot_mk_to_coe'', map_coe, sup_coe, Finset.sup_eq_union, Finset.bot_eq_empty, List.foldr_map] @@ -113,7 +113,7 @@ theorem Finset.support_sum_eq [AddCommMonoid M] (s : Finset (ι →₀ M)) (s.sum id).support = Finset.sup s Finsupp.support := by classical suffices s.1.Pairwise (_root_.Disjoint on Finsupp.support) by - convert Multiset.support_sum_eq s.1 this + convert! Multiset.support_sum_eq s.1 this exact (Finset.sum_val _).symm obtain ⟨l, hl, hn⟩ : ∃ l : List (ι →₀ M), l.toFinset = s ∧ l.Nodup := by refine ⟨s.toList, ?_, Finset.nodup_toList _⟩ diff --git a/Mathlib/Data/Finsupp/Defs.lean b/Mathlib/Data/Finsupp/Defs.lean index 9dd1af7cb0c80c..2b2ed3a0d43935 100644 --- a/Mathlib/Data/Finsupp/Defs.lean +++ b/Mathlib/Data/Finsupp/Defs.lean @@ -498,7 +498,7 @@ theorem zipWith_apply {f : M → N → O} {hf : f 0 0 = 0} {g₁ : α →₀ M} theorem support_zipWith [D : DecidableEq α] {f : M → N → O} {hf : f 0 0 = 0} {g₁ : α →₀ M} {g₂ : α →₀ N} : (zipWith f hf g₁ g₂).support ⊆ g₁.support ∪ g₂.support := by - convert support_onFinset_subset + convert! support_onFinset_subset end ZipWith diff --git a/Mathlib/Data/Fintype/Card.lean b/Mathlib/Data/Fintype/Card.lean index acca9b0f9856a7..92b0c19123219c 100644 --- a/Mathlib/Data/Fintype/Card.lean +++ b/Mathlib/Data/Fintype/Card.lean @@ -198,7 +198,6 @@ theorem Fintype.card_lex (α : Type*) [Fintype α] : Fintype.card (Lex α) = Fin -- Note: The extra hypothesis `h` is there so that the rewrite lemma applies, -- no matter what instance of `Fintype (Set.univ : Set α)` is used. -@[simp] theorem Fintype.card_setUniv [Fintype α] {h : Fintype (Set.univ : Set α)} : Fintype.card (Set.univ : Set α) = Fintype.card α := by apply Fintype.card_of_finset' diff --git a/Mathlib/Data/Fintype/List.lean b/Mathlib/Data/Fintype/List.lean index 579f66e96c1498..dfe147b8cfe811 100644 --- a/Mathlib/Data/Fintype/List.lean +++ b/Mathlib/Data/Fintype/List.lean @@ -67,7 +67,7 @@ instance fintypeNodupList [Fintype α] : Fintype { l : List α // l.Nodup } := b constructor · simp only [Finset.coe_toList] rfl - · convert Finset.nodup_toList (Finset.univ.powerset : Finset (Finset α)) + · convert! Finset.nodup_toList (Finset.univ.powerset : Finset (Finset α)) ext l unfold Nodup refine Pairwise.iff ?_ @@ -99,7 +99,7 @@ instance fintypeNodupList [Fintype α] : Fintype { l : List α // l.Nodup } := b constructor · intro h rcases h with ⟨f, hf⟩ - convert f.nodup + convert! f.nodup rw [hf] rfl · intro h diff --git a/Mathlib/Data/Fintype/Option.lean b/Mathlib/Data/Fintype/Option.lean index 9a1284c63aa876..8fc9cd0d1c2da6 100644 --- a/Mathlib/Data/Fintype/Option.lean +++ b/Mathlib/Data/Fintype/Option.lean @@ -92,11 +92,11 @@ theorem induction_empty_option {P : ∀ (α : Type u) [Fintype α], Prop} (h_empty : P PEmpty) (h_option : ∀ (α) [Fintype α], P α → P (Option α)) (α : Type u) [h_fintype : Fintype α] : P α := by obtain ⟨p⟩ := - let f_empty := fun i => by convert h_empty + let f_empty := fun i => by convert! h_empty let h_option : ∀ {α : Type u} [Fintype α] [DecidableEq α], (∀ (h : Fintype α), P α) → ∀ (h : Fintype (Option α)), P (Option α) := by rintro α hα - Pα hα' - convert h_option α (Pα _) + convert! h_option α (Pα _) @truncRecEmptyOption (fun α => ∀ h, @P α h) (@fun α β e hα hβ => @of_equiv α β hβ e (hα _)) f_empty h_option α _ (Classical.decEq α) exact p _ diff --git a/Mathlib/Data/Fintype/Order.lean b/Mathlib/Data/Fintype/Order.lean index e4a5f7b738f08f..616051ccc6ca7f 100644 --- a/Mathlib/Data/Fintype/Order.lean +++ b/Mathlib/Data/Fintype/Order.lean @@ -102,12 +102,12 @@ noncomputable abbrev toCompleteDistribLatticeMinimalAxioms [DistribLattice α] [ CompleteDistribLattice.MinimalAxioms α where __ := toCompleteLattice α iInf_sup_le_sup_sInf := fun a s => by - convert (Finset.inf_sup_distrib_left s.toFinset id a).ge using 1 + convert! (Finset.inf_sup_distrib_left s.toFinset id a).ge using 1 rw [Finset.inf_eq_iInf] simp_rw [Set.mem_toFinset] rfl inf_sSup_le_iSup_inf := fun a s => by - convert (Finset.sup_inf_distrib_left s.toFinset id a).le using 1 + convert! (Finset.sup_inf_distrib_left s.toFinset id a).le using 1 rw [Finset.sup_eq_iSup] simp_rw [Set.mem_toFinset] rfl @@ -187,7 +187,7 @@ variable {α : Type*} {r : α → α → Prop} [IsTrans α r] {β γ : Type*} [N theorem Directed.finite_set_le (D : Directed r f) {s : Set γ} (hs : s.Finite) : ∃ z, ∀ i ∈ s, r (f i) (f z) := by - convert D.finset_le hs.toFinset using 3; rw [Set.Finite.mem_toFinset] + convert! D.finset_le hs.toFinset using 3; rw [Set.Finite.mem_toFinset] lemma Directed.finite_le {ι κ : Sort*} [Nonempty ι] [Finite κ] {f : ι → α} (hf : Directed r f) (g : κ → ι) : ∃ z, ∀ i, r (f (g i)) (f z) := by diff --git a/Mathlib/Data/Fintype/Sets.lean b/Mathlib/Data/Fintype/Sets.lean index d87519b73b3f13..ff1de4545097ef 100644 --- a/Mathlib/Data/Fintype/Sets.lean +++ b/Mathlib/Data/Fintype/Sets.lean @@ -275,7 +275,7 @@ sets on a finite type are finite.) -/ noncomputable def finsetEquivSet : Finset α ≃ Set α where toFun := (↑) invFun := by classical exact fun s => s.toFinset - left_inv s := by convert Finset.toFinset_coe s + left_inv s := by convert! Finset.toFinset_coe s right_inv s := by classical exact s.coe_toFinset @[simp, norm_cast] lemma coe_finsetEquivSet : ⇑finsetEquivSet = ((↑) : Finset α → Set α) := rfl diff --git a/Mathlib/Data/Fintype/Sum.lean b/Mathlib/Data/Fintype/Sum.lean index 1e0154e21fe59d..13aa5d06ecb0d5 100644 --- a/Mathlib/Data/Fintype/Sum.lean +++ b/Mathlib/Data/Fintype/Sum.lean @@ -132,14 +132,14 @@ theorem Fintype.card_subtype_or (p q : α → Prop) [Fintype { x // p x }] [Fint [Fintype { x // p x ∨ q x }] : Fintype.card { x // p x ∨ q x } ≤ Fintype.card { x // p x } + Fintype.card { x // q x } := by classical - convert Fintype.card_le_of_embedding (subtypeOrLeftEmbedding p q) + convert! Fintype.card_le_of_embedding (subtypeOrLeftEmbedding p q) rw [Fintype.card_sum] theorem Fintype.card_subtype_or_disjoint (p q : α → Prop) (h : Disjoint p q) [Fintype { x // p x }] [Fintype { x // q x }] [Fintype { x // p x ∨ q x }] : Fintype.card { x // p x ∨ q x } = Fintype.card { x // p x } + Fintype.card { x // q x } := by classical - convert Fintype.card_congr (subtypeOrEquiv p q h) + convert! Fintype.card_congr (subtypeOrEquiv p q h) simp theorem Fintype.card_subtype_eq_or_eq_of_ne {α : Type*} [Fintype α] [DecidableEq α] {a b : α} diff --git a/Mathlib/Data/Int/Basic.lean b/Mathlib/Data/Int/Basic.lean index fe3824cdc1ec02..894581f3ab530a 100644 --- a/Mathlib/Data/Int/Basic.lean +++ b/Mathlib/Data/Int/Basic.lean @@ -58,7 +58,7 @@ lemma natAbs_surjective : natAbs.Surjective := fun n => ⟨n, natAbs_natCast n lemma pow_right_injective (h : 1 < a.natAbs) : ((a ^ ·) : ℕ → ℤ).Injective := by refine (?_ : (natAbs ∘ (a ^ · : ℕ → ℤ)).Injective).of_comp - convert Nat.pow_right_injective h using 2 + convert! Nat.pow_right_injective h using 2 rw [Function.comp_apply, natAbs_pow] /-! ### dvd -/ diff --git a/Mathlib/Data/Int/ConditionallyCompleteOrder.lean b/Mathlib/Data/Int/ConditionallyCompleteOrder.lean index 299035a95dfac5..80503f26eb3e2a 100644 --- a/Mathlib/Data/Int/ConditionallyCompleteOrder.lean +++ b/Mathlib/Data/Int/ConditionallyCompleteOrder.lean @@ -49,7 +49,7 @@ theorem csSup_eq_greatestOfBdd {s : Set ℤ} [DecidablePred (· ∈ s)] (b : ℤ (Hinh : ∃ z : ℤ, z ∈ s) : sSup s = greatestOfBdd b Hb Hinh := by have : s.Nonempty ∧ BddAbove s := ⟨Hinh, b, Hb⟩ simp only [sSup, dif_pos this] - convert (coe_greatestOfBdd_eq Hb (Classical.choose_spec (⟨b, Hb⟩ : BddAbove s)) Hinh).symm + convert! (coe_greatestOfBdd_eq Hb (Classical.choose_spec (⟨b, Hb⟩ : BddAbove s)) Hinh).symm @[deprecated (since := "2025-12-24")] alias csSup_eq_greatest_of_bdd := csSup_eq_greatestOfBdd @@ -66,7 +66,7 @@ theorem csInf_eq_leastOfBdd {s : Set ℤ} [DecidablePred (· ∈ s)] (b : ℤ) ( (Hinh : ∃ z : ℤ, z ∈ s) : sInf s = leastOfBdd b Hb Hinh := by have : s.Nonempty ∧ BddBelow s := ⟨Hinh, b, Hb⟩ simp only [sInf, dif_pos this] - convert (coe_leastOfBdd_eq Hb (Classical.choose_spec (⟨b, Hb⟩ : BddBelow s)) Hinh).symm + convert! (coe_leastOfBdd_eq Hb (Classical.choose_spec (⟨b, Hb⟩ : BddBelow s)) Hinh).symm @[deprecated (since := "2025-12-24")] alias csInf_eq_least_of_bdd := csInf_eq_leastOfBdd @@ -80,11 +80,11 @@ theorem csInf_of_not_bddBelow {s : Set ℤ} (h : ¬BddBelow s) : sInf s = 0 := @[deprecated (since := "2025-12-24")] alias csInf_of_not_bdd_below := csInf_of_not_bddBelow theorem csSup_mem {s : Set ℤ} (h1 : s.Nonempty) (h2 : BddAbove s) : sSup s ∈ s := by - convert (greatestOfBdd _ (Classical.choose_spec h2) h1).2.1 + convert! (greatestOfBdd _ (Classical.choose_spec h2) h1).2.1 exact dif_pos ⟨h1, h2⟩ theorem csInf_mem {s : Set ℤ} (h1 : s.Nonempty) (h2 : BddBelow s) : sInf s ∈ s := by - convert (leastOfBdd _ (Classical.choose_spec h2) h1).2.1 + convert! (leastOfBdd _ (Classical.choose_spec h2) h1).2.1 exact dif_pos ⟨h1, h2⟩ end Int diff --git a/Mathlib/Data/Int/Init.lean b/Mathlib/Data/Int/Init.lean index d06ffbf3645125..d71152ac6830cc 100644 --- a/Mathlib/Data/Int/Init.lean +++ b/Mathlib/Data/Int/Init.lean @@ -356,4 +356,7 @@ lemma natMod_lt {n : ℕ} (hn : n ≠ 0) : m.natMod n < n := @[simp] lemma gcd_negSucc_negSucc (m n : ℕ) : (negSucc m).gcd (negSucc n) = (m + 1).gcd (n + 1) := by simp [gcd] +theorem gcd_right_comm (a b c : ℤ) : gcd (gcd a b) c = gcd (gcd a c) b := by + rw [gcd_assoc, gcd_assoc, gcd_comm b c] + end Int diff --git a/Mathlib/Data/Int/ModEq.lean b/Mathlib/Data/Int/ModEq.lean index f4a2043b4d9c99..44132ff8bff28c 100644 --- a/Mathlib/Data/Int/ModEq.lean +++ b/Mathlib/Data/Int/ModEq.lean @@ -142,7 +142,7 @@ protected theorem mul_right' (h : a ≡ b [ZMOD n]) : a * c ≡ b * c [ZMOD n * @[gcongr] protected theorem add (h₁ : a ≡ b [ZMOD n]) (h₂ : c ≡ d [ZMOD n]) : a + c ≡ b + d [ZMOD n] := - modEq_iff_dvd.2 <| by convert Int.dvd_add h₁.dvd h₂.dvd using 1; lia + modEq_iff_dvd.2 <| by convert! Int.dvd_add h₁.dvd h₂.dvd using 1; lia protected theorem add_left (c : ℤ) (h : a ≡ b [ZMOD n]) : c + a ≡ c + b [ZMOD n] := ModEq.rfl.add h @@ -219,7 +219,7 @@ theorem cancel_left_div_gcd (hm : 0 < m) (h : c * a ≡ c * b [ZMOD m]) : a ≡ cancel_right_div_gcd hm <| by simpa [mul_comm] using h theorem of_div (h : a / c ≡ b / c [ZMOD m / c]) (ha : c ∣ a) (ha : c ∣ b) (ha : c ∣ m) : - a ≡ b [ZMOD m] := by convert h.mul_left' <;> rwa [Int.mul_ediv_cancel'] + a ≡ b [ZMOD m] := by convert! h.mul_left' <;> rwa [Int.mul_ediv_cancel'] /-- Cancel left multiplication on both sides of the `≡` and in the modulus. @@ -358,7 +358,7 @@ theorem modEq_and_modEq_iff_modEq_lcm {a b m n : ℤ} : theorem modEq_and_modEq_iff_modEq_mul {a b m n : ℤ} (hmn : m.natAbs.Coprime n.natAbs) : a ≡ b [ZMOD m] ∧ a ≡ b [ZMOD n] ↔ a ≡ b [ZMOD m * n] := by - convert ← modEq_and_modEq_iff_modEq_lcm using 1 + convert! ← modEq_and_modEq_iff_modEq_lcm using 1 rw [lcm_eq_mul_iff.mpr (.inr <| .inr hmn), ← natAbs_mul, modEq_natAbs] theorem gcd_a_modEq (a b : ℕ) : (a : ℤ) * Nat.gcdA a b ≡ Nat.gcd a b [ZMOD b] := by diff --git a/Mathlib/Data/List/AList.lean b/Mathlib/Data/List/AList.lean index 74630c14047305..69b8bcdd3809c6 100644 --- a/Mathlib/Data/List/AList.lean +++ b/Mathlib/Data/List/AList.lean @@ -352,7 +352,7 @@ theorem insertRec_insert {C : AList β → Sort*} (H0 : C ∅) IH c.1 c.2 ⟨l, hl⟩ h (@insertRec α β _ C H0 IH ⟨l, hl⟩) by cases c apply eq_of_heq - convert this <;> rw [insert_of_notMem h] + convert! this <;> rw [insert_of_notMem h] rw [insertRec] apply cast_heq diff --git a/Mathlib/Data/List/Basic.lean b/Mathlib/Data/List/Basic.lean index 433d9cb9364d19..b6f64d90dca234 100644 --- a/Mathlib/Data/List/Basic.lean +++ b/Mathlib/Data/List/Basic.lean @@ -665,7 +665,7 @@ theorem get_reverse' (l : List α) (n) (hn') : simp theorem eq_cons_of_length_one {l : List α} (h : l.length = 1) : l = [l.get ⟨0, by lia⟩] := by - refine ext_get (by convert h) (by grind) + refine ext_get (by convert! h) (by grind) end deprecated diff --git a/Mathlib/Data/List/Cycle.lean b/Mathlib/Data/List/Cycle.lean index f4b5d31effd0e0..05afb88727f8f8 100644 --- a/Mathlib/Data/List/Cycle.lean +++ b/Mathlib/Data/List/Cycle.lean @@ -388,7 +388,7 @@ theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) theorem next_reverse_eq_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) : next l.reverse x (mem_reverse.mpr hx) = prev l x hx := by - convert (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x (mem_reverse.mpr hx)).symm + convert! (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x (mem_reverse.mpr hx)).symm exact (reverse_reverse l).symm theorem isRotated_next_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) : diff --git a/Mathlib/Data/List/Infix.lean b/Mathlib/Data/List/Infix.lean index 74f4fa9e5dcb1b..7241a120eff011 100644 --- a/Mathlib/Data/List/Infix.lean +++ b/Mathlib/Data/List/Infix.lean @@ -116,7 +116,7 @@ theorem concat_get_prefix {x y : List α} (h : x <+: y) (hl : x.length < y.lengt x ++ [y.get ⟨x.length, hl⟩] <+: y := by use y.drop (x.length + 1) nth_rw 1 [List.prefix_iff_eq_take.mp h] - convert List.take_append_drop (x.length + 1) y using 2 + convert! List.take_append_drop (x.length + 1) y using 2 rw [← List.take_concat_get, List.concat_eq_append]; rfl theorem prefix_append_drop {l₁ l₂ : List α} (h : l₁ <+: l₂) : diff --git a/Mathlib/Data/List/Intervals.lean b/Mathlib/Data/List/Intervals.lean index 08abbc956649a2..01427527620c81 100644 --- a/Mathlib/Data/List/Intervals.lean +++ b/Mathlib/Data/List/Intervals.lean @@ -83,7 +83,7 @@ theorem eq_empty_iff {n m : ℕ} : Ico n m = [] ↔ m ≤ n := theorem append_consecutive {n m l : ℕ} (hnm : n ≤ m) (hml : m ≤ l) : Ico n m ++ Ico m l = Ico n l := by dsimp only [Ico] - convert range'_append using 2 + convert! range'_append using 2 · rw [Nat.one_mul, Nat.add_sub_cancel' hnm] · lia @@ -99,7 +99,7 @@ theorem inter_consecutive (n m l : ℕ) : Ico n m ∩ Ico m l = [] := by @[simp] theorem bagInter_consecutive (n m l : Nat) : @List.bagInter ℕ instBEqOfDecidableEq (Ico n m) (Ico m l) = [] := - (bagInter_nil_iff_inter_nil _ _).2 (by convert inter_consecutive n m l) + (bagInter_nil_iff_inter_nil _ _).2 (by convert! inter_consecutive n m l) @[simp] theorem succ_singleton {n : ℕ} : Ico n (n + 1) = [n] := by diff --git a/Mathlib/Data/List/Perm/Basic.lean b/Mathlib/Data/List/Perm/Basic.lean index 0e9e02f85c1429..c1bc8b988698fa 100644 --- a/Mathlib/Data/List/Perm/Basic.lean +++ b/Mathlib/Data/List/Perm/Basic.lean @@ -164,7 +164,7 @@ end Rel lemma count_eq_count_filter_add [DecidableEq α] (P : α → Prop) [DecidablePred P] (l : List α) (a : α) : count a l = count a (l.filter P) + count a (l.filter (¬ P ·)) := by - convert countP_eq_countP_filter_add l _ P + convert! countP_eq_countP_filter_add l _ P simp only [decide_not] theorem Perm.foldl_eq {f : β → α → β} {l₁ l₂ : List α} [rcomm : RightCommutative f] (p : l₁ ~ l₂) : diff --git a/Mathlib/Data/List/Sublists.lean b/Mathlib/Data/List/Sublists.lean index fc230ed022ea0b..e41e39c15a6b50 100644 --- a/Mathlib/Data/List/Sublists.lean +++ b/Mathlib/Data/List/Sublists.lean @@ -331,7 +331,7 @@ protected alias ⟨Nodup.of_sublists', _⟩ := nodup_sublists' theorem nodup_sublistsLen (n : ℕ) {l : List α} (h : Nodup l) : (sublistsLen n l).Nodup := by have : Pairwise (· ≠ ·) l.sublists' := Pairwise.imp - (fun h => Lex.to_ne (by convert h using 3; simp [eq_comm])) h.sublists' + (fun h => Lex.to_ne (by convert! h using 3; simp [eq_comm])) h.sublists' exact this.sublist (sublistsLen_sublist_sublists' _ _) theorem sublists_map (f : α → β) : ∀ (l : List α), diff --git a/Mathlib/Data/List/TakeWhile.lean b/Mathlib/Data/List/TakeWhile.lean index 8e1ed94d7de509..d5f37e4fa7f80c 100644 --- a/Mathlib/Data/List/TakeWhile.lean +++ b/Mathlib/Data/List/TakeWhile.lean @@ -114,7 +114,7 @@ lemma find?_eq_head?_dropWhile_not : lemma find?_not_eq_head?_dropWhile : l.find? (fun x ↦ !(p x)) = (l.dropWhile p).head? := by - convert l.find?_eq_head?_dropWhile_not ?_ + convert! l.find?_eq_head?_dropWhile_not ?_ simp variable {p} {l} @@ -125,7 +125,7 @@ lemma find?_eq_head_dropWhile_not (h : ∃ x ∈ l, p x) : lemma find?_not_eq_head_dropWhile (h : ∃ x ∈ l, ¬p x) : l.find? (fun x ↦ !(p x)) = some ((l.dropWhile p).head (by simpa using h)) := by - convert l.find?_eq_head_dropWhile_not ?_ + convert! l.find?_eq_head_dropWhile_not ?_ · simp · simpa using h diff --git a/Mathlib/Data/List/ToFinsupp.lean b/Mathlib/Data/List/ToFinsupp.lean index 5c6ee73ccf756d..d7499e9849650d 100644 --- a/Mathlib/Data/List/ToFinsupp.lean +++ b/Mathlib/Data/List/ToFinsupp.lean @@ -112,7 +112,7 @@ theorem toFinsupp_cons_eq_single_add_embDomain {R : Type*} [AddZeroClass R] (x : toFinsupp (x::xs) = Finsupp.single 0 x + (toFinsupp xs).embDomain (addRightEmbedding 1) := by classical - convert toFinsupp_append [x] xs using 3 + convert! toFinsupp_append [x] xs using 3 · exact (toFinsupp_singleton x).symm · ext n exact add_comm n 1 diff --git a/Mathlib/Data/Matrix/Invertible.lean b/Mathlib/Data/Matrix/Invertible.lean index 728b99934521fd..1ddc70e5caf5e9 100644 --- a/Mathlib/Data/Matrix/Invertible.lean +++ b/Mathlib/Data/Matrix/Invertible.lean @@ -112,7 +112,7 @@ instance invertibleTranspose [Invertible A] : Invertible Aᵀ where lemma transpose_invOf [Invertible A] [Invertible Aᵀ] : (⅟A)ᵀ = ⅟(Aᵀ) := by letI := invertibleTranspose A - convert (rfl : _ = ⅟(Aᵀ)) + convert! (rfl : _ = ⅟(Aᵀ)) /-- `Aᵀ` is invertible when `A` is. -/ @[implicit_reducible] @@ -199,7 +199,7 @@ See `Matrix.invOf_add_mul_mul'` for the Binomial Inverse Theorem. -/ theorem invOf_add_mul_mul [Invertible (A + U * C * V)] : ⅟(A + U * C * V) = ⅟A - ⅟A * U * ⅟(⅟C + V * ⅟A * U) * V * ⅟A := by letI := invertibleAddMulMul A U C V - convert (rfl : ⅟(A + U * C * V) = _) + convert! (rfl : ⅟(A + U * C * V) = _) end Woodbury @@ -243,7 +243,7 @@ See `Matrix.invOf_add_mul_mul` for the Woodbury identity. -/ theorem invOf_add_mul_mul' [Invertible (A + U * C * V)] : ⅟(A + U * C * V) = ⅟A - ⅟A * U * C * ⅟(C + C * V * ⅟A * U * C) * C * V * ⅟A := by letI := invertibleAddMulMul' A U C V - convert (rfl : ⅟(A + U * C * V) = _) + convert! (rfl : ⅟(A + U * C * V) = _) end BinomialInverseTheorem diff --git a/Mathlib/Data/Matrix/Mul.lean b/Mathlib/Data/Matrix/Mul.lean index f97ebaa6a7338e..5cdb2a47f5e0a5 100644 --- a/Mathlib/Data/Matrix/Mul.lean +++ b/Mathlib/Data/Matrix/Mul.lean @@ -164,34 +164,34 @@ variable [DecidableEq m] [NonUnitalNonAssocSemiring α] (u v w : m → α) theorem diagonal_dotProduct (i : m) : diagonal v i ⬝ᵥ w = v i * w i := by have : ∀ j ≠ i, diagonal v i j * w j = 0 := fun j hij => by simp [diagonal_apply_ne' _ hij] - convert Finset.sum_eq_single i (fun j _ => this j) _ using 1 <;> simp + convert! Finset.sum_eq_single i (fun j _ => this j) _ using 1 <;> simp @[simp] theorem dotProduct_diagonal (i : m) : v ⬝ᵥ diagonal w i = v i * w i := by have : ∀ j ≠ i, v j * diagonal w i j = 0 := fun j hij => by simp [diagonal_apply_ne' _ hij] - convert Finset.sum_eq_single i (fun j _ => this j) _ using 1 <;> simp + convert! Finset.sum_eq_single i (fun j _ => this j) _ using 1 <;> simp @[simp] theorem dotProduct_diagonal' (i : m) : (v ⬝ᵥ fun j => diagonal w j i) = v i * w i := by have : ∀ j ≠ i, v j * diagonal w j i = 0 := fun j hij => by simp [diagonal_apply_ne _ hij] - convert Finset.sum_eq_single i (fun j _ => this j) _ using 1 <;> simp + convert! Finset.sum_eq_single i (fun j _ => this j) _ using 1 <;> simp @[simp] theorem single_dotProduct (x : α) (i : m) : Pi.single i x ⬝ᵥ v = x * v i := by -- Porting note: added `(_ : m → α)` have : ∀ j ≠ i, (Pi.single i x : m → α) j * v j = 0 := fun j hij => by simp [Pi.single_eq_of_ne hij] - convert Finset.sum_eq_single i (fun j _ => this j) _ using 1 <;> simp + convert! Finset.sum_eq_single i (fun j _ => this j) _ using 1 <;> simp @[simp] theorem dotProduct_single (x : α) (i : m) : v ⬝ᵥ Pi.single i x = v i * x := by -- Porting note: added `(_ : m → α)` have : ∀ j ≠ i, v j * (Pi.single i x : m → α) j = 0 := fun j hij => by simp [Pi.single_eq_of_ne hij] - convert Finset.sum_eq_single i (fun j _ => this j) _ using 1 <;> simp + convert! Finset.sum_eq_single i (fun j _ => this j) _ using 1 <;> simp end NonUnitalNonAssocSemiringDecidable diff --git a/Mathlib/Data/Multiset/AddSub.lean b/Mathlib/Data/Multiset/AddSub.lean index 2e9155ac924f12..3f50a550897135 100644 --- a/Mathlib/Data/Multiset/AddSub.lean +++ b/Mathlib/Data/Multiset/AddSub.lean @@ -258,13 +258,13 @@ theorem card_erase_eq_ite {a : α} {s : Multiset α} : @[simp] theorem count_erase_self (a : α) (s : Multiset α) : count a (erase s a) = count a s - 1 := Quotient.inductionOn s fun l => by - convert List.count_erase_self (a := a) (l := l) <;> rw [← coe_count] <;> simp + convert! List.count_erase_self (a := a) (l := l) <;> rw [← coe_count] <;> simp @[simp] theorem count_erase_of_ne {a b : α} (ab : a ≠ b) (s : Multiset α) : count a (erase s b) = count a s := Quotient.inductionOn s fun l => by - convert List.count_erase_of_ne ab (l := l) <;> rw [← coe_count] <;> simp + convert! List.count_erase_of_ne ab (l := l) <;> rw [← coe_count] <;> simp end Erase diff --git a/Mathlib/Data/Multiset/Filter.lean b/Mathlib/Data/Multiset/Filter.lean index 111a922dbf9ec6..b94cfdfdf47f57 100644 --- a/Mathlib/Data/Multiset/Filter.lean +++ b/Mathlib/Data/Multiset/Filter.lean @@ -277,7 +277,7 @@ theorem countP_filter (q) [DecidablePred q] (s : Multiset α) : theorem countP_eq_countP_filter_add (s) (p q : α → Prop) [DecidablePred p] [DecidablePred q] : countP p s = (filter q s).countP p + (filter (fun a => ¬q a) s).countP p := Quot.inductionOn s fun l => by - convert l.countP_eq_countP_filter_add (p ·) (q ·) + convert! l.countP_eq_countP_filter_add (p ·) (q ·) simp theorem countP_map (f : α → β) (s : Multiset α) (p : β → Prop) [DecidablePred p] : diff --git a/Mathlib/Data/Multiset/Fintype.lean b/Mathlib/Data/Multiset/Fintype.lean index 850c5cb3141696..e447b437ff83b2 100644 --- a/Mathlib/Data/Multiset/Fintype.lean +++ b/Mathlib/Data/Multiset/Fintype.lean @@ -250,9 +250,9 @@ def consEquiv {v : α} : v ::ₘ m ≃ Option m where by_cases hv : x.1 = v · simp only [hv, true_and] at h ⊢ apply lt_of_le_of_ne (Nat.le_of_lt_add_one _) h - convert x.2.2 using 1 + convert! x.2.2 using 1 simp [hv] - · convert x.2.2 using 1 + · convert! x.2.2 using 1 exact (count_cons_of_ne hv _).symm ⟩⟩ invFun x := x.elim ⟨v, ⟨m.count v, by simp⟩⟩ (fun x ↦ ⟨x.1, x.2.castLE (count_le_count_cons ..)⟩) diff --git a/Mathlib/Data/Multiset/Replicate.lean b/Mathlib/Data/Multiset/Replicate.lean index 50e521eb2bea8f..2681e862857bad 100644 --- a/Mathlib/Data/Multiset/Replicate.lean +++ b/Mathlib/Data/Multiset/Replicate.lean @@ -113,11 +113,11 @@ variable [DecidableEq α] {s t u : Multiset α} @[simp] theorem count_replicate_self (a : α) (n : ℕ) : count a (replicate n a) = n := by - convert List.count_replicate_self (a := a) + convert! List.count_replicate_self (a := a) rw [← coe_count, coe_replicate] theorem count_replicate (a b : α) (n : ℕ) : count a (replicate n b) = if b = a then n else 0 := by - convert List.count_replicate (a := a) + convert! List.count_replicate (a := a) · rw [← coe_count, coe_replicate] · simp diff --git a/Mathlib/Data/NNRat/Lemmas.lean b/Mathlib/Data/NNRat/Lemmas.lean index df6aac7d808201..7c0c1d60f5aef0 100644 --- a/Mathlib/Data/NNRat/Lemmas.lean +++ b/Mathlib/Data/NNRat/Lemmas.lean @@ -66,23 +66,23 @@ protected def rec {α : ℚ≥0 → Sort*} (h : ∀ m n : ℕ, α (m / n)) (q : theorem mul_num (q₁ q₂ : ℚ≥0) : (q₁ * q₂).num = q₁.num * q₂.num / Nat.gcd (q₁.num * q₂.num) (q₁.den * q₂.den) := by zify - convert Rat.mul_num q₁ q₂ <;> norm_cast + convert! Rat.mul_num q₁ q₂ <;> norm_cast theorem mul_den (q₁ q₂ : ℚ≥0) : (q₁ * q₂).den = q₁.den * q₂.den / Nat.gcd (q₁.num * q₂.num) (q₁.den * q₂.den) := by - convert Rat.mul_den q₁ q₂ + convert! Rat.mul_den q₁ q₂ norm_cast /-- A version of `NNRat.mul_den` without division. -/ theorem den_mul_den_eq_den_mul_gcd (q₁ q₂ : ℚ≥0) : q₁.den * q₂.den = (q₁ * q₂).den * ((q₁.num * q₂.num).gcd (q₁.den * q₂.den)) := by - convert Rat.den_mul_den_eq_den_mul_gcd q₁ q₂ + convert! Rat.den_mul_den_eq_den_mul_gcd q₁ q₂ norm_cast /-- A version of `NNRat.mul_num` without division. -/ theorem num_mul_num_eq_num_mul_gcd (q₁ q₂ : ℚ≥0) : q₁.num * q₂.num = (q₁ * q₂).num * ((q₁.num * q₂.num).gcd (q₁.den * q₂.den)) := by zify - convert Rat.num_mul_num_eq_num_mul_gcd q₁ q₂ <;> norm_cast + convert! Rat.num_mul_num_eq_num_mul_gcd q₁ q₂ <;> norm_cast end NNRat diff --git a/Mathlib/Data/Nat/Bitwise.lean b/Mathlib/Data/Nat/Bitwise.lean index c5d09a3ba76a3c..4e490227eefbb8 100644 --- a/Mathlib/Data/Nat/Bitwise.lean +++ b/Mathlib/Data/Nat/Bitwise.lean @@ -204,14 +204,14 @@ theorem lt_of_testBit {n m : ℕ} (i : ℕ) (hn : testBit n i = false) (hm : tes · subst hi simp only [testBit_bit_zero] at hn hm have : n = m := - eq_of_testBit_eq fun i => by convert hnm (i + 1) (Nat.zero_lt_succ _) using 1 + eq_of_testBit_eq fun i => by convert! hnm (i + 1) (Nat.zero_lt_succ _) using 1 <;> rw [testBit_bit_succ] rw [hn, hm, this, bit_false, bit_true] exact Nat.lt_succ_self _ · obtain ⟨i', rfl⟩ := exists_eq_succ_of_ne_zero hi simp only [testBit_bit_succ] at hn hm have := hn' _ hn hm fun j hj => by - convert hnm j.succ (succ_lt_succ hj) using 1 <;> rw [testBit_bit_succ] + convert! hnm j.succ (succ_lt_succ hj) using 1 <;> rw [testBit_bit_succ] exact bit_lt_bit b b' this theorem bitwise_swap {f : Bool → Bool → Bool} : diff --git a/Mathlib/Data/Nat/Cast/Order/Basic.lean b/Mathlib/Data/Nat/Cast/Order/Basic.lean index fc0cd1ca6d5813..575cb7470728b0 100644 --- a/Mathlib/Data/Nat/Cast/Order/Basic.lean +++ b/Mathlib/Data/Nat/Cast/Order/Basic.lean @@ -52,7 +52,7 @@ variable [NeZero (1 : α)] theorem cast_add_one_pos (n : ℕ) : 0 < (n : α) + 1 := by apply zero_lt_one.trans_le - convert (@mono_cast α _).imp (?_ : 1 ≤ n + 1) + convert! (@mono_cast α _).imp (?_ : 1 ≤ n + 1) <;> simp /-- See also `Nat.cast_pos`, specialised for an `OrderedSemiring`. -/ diff --git a/Mathlib/Data/Nat/Choose/Multinomial.lean b/Mathlib/Data/Nat/Choose/Multinomial.lean index 4ab629a678e318..a9ed09a52cd00c 100644 --- a/Mathlib/Data/Nat/Choose/Multinomial.lean +++ b/Mathlib/Data/Nat/Choose/Multinomial.lean @@ -238,7 +238,7 @@ noncomputable def countPerms [DecidableEq α] (m : Multiset α) : ℕ := theorem countPerms_filter_ne [DecidableEq α] (a : α) (m : Multiset α) : m.countPerms = m.card.choose (m.count a) * (m.filter (a ≠ ·)).countPerms := by dsimp only [countPerms] - convert Finsupp.multinomial_update a _ + convert! Finsupp.multinomial_update a _ · rw [← Finsupp.card_toMultiset, m.toFinsupp_toMultiset] · ext1 a rw [toFinsupp_apply, count_filter, Finsupp.coe_update] @@ -322,8 +322,8 @@ theorem sum_pow_of_commute (x : α → R) (s : Finset α) · rw [_root_.pow_zero, Fintype.sum_subsingleton] swap · exact ⟨0, by simp [eq_iff_true_of_subsingleton]⟩ - convert (@one_mul R _ _).symm - convert @Nat.cast_one R _ + convert! (@one_mul R _ _).symm + convert! @Nat.cast_one R _ simp · rw [_root_.pow_succ, mul_zero] haveI : IsEmpty (Finset.sym (∅ : Finset α) n.succ) := Finset.instIsEmpty @@ -355,7 +355,7 @@ lemma sum_pow_eq_sum_piAntidiag (s : Finset α) (f : α → R) (n : ℕ) : theorem sum_pow (x : α → R) (n : ℕ) : s.sum x ^ n = ∑ k ∈ s.sym n, k.val.countPerms * (k.val.map x).prod := by conv_rhs => rw [← sum_coe_sort] - convert sum_pow_of_commute x s (fun _ _ _ _ _ ↦ Commute.all ..) n + convert! sum_pow_of_commute x s (fun _ _ _ _ _ ↦ Commute.all ..) n rw [Multiset.noncommProd_eq_prod] end CommSemiring diff --git a/Mathlib/Data/Nat/Choose/Sum.lean b/Mathlib/Data/Nat/Choose/Sum.lean index 9f2e202cc1f691..bd330feba8b9b3 100644 --- a/Mathlib/Data/Nat/Choose/Sum.lean +++ b/Mathlib/Data/Nat/Choose/Sum.lean @@ -147,7 +147,7 @@ we have to decompose the remaining interval `[0, i)` into `k + 1` intervals, hen lemma sum_range_add_choose (n k : ℕ) : ∑ i ∈ Finset.range (n + 1), (i + k).choose k = (n + k + 1).choose (k + 1) := by rw [← sum_Icc_choose, range_eq_Ico] - convert (sum_map _ (addRightEmbedding k) (·.choose k)).symm using 2 + convert! (sum_map _ (addRightEmbedding k) (·.choose k)).symm using 2 rw [map_add_right_Ico, zero_add, add_right_comm, Ico_add_one_right_eq_Icc] /-- Summing `i * (n.choose i)` for `i ∈ [0, n]` gives `n * 2 ^ (n - 1)`. -/ diff --git a/Mathlib/Data/Nat/Digits/Defs.lean b/Mathlib/Data/Nat/Digits/Defs.lean index ab040111a55c17..a8af782476861e 100644 --- a/Mathlib/Data/Nat/Digits/Defs.lean +++ b/Mathlib/Data/Nat/Digits/Defs.lean @@ -227,7 +227,7 @@ theorem digits_ofDigits (b : ℕ) (h : 1 < b) (L : List ℕ) (w₁ : ∀ l ∈ L exact List.mem_cons_of_mem _ m · intro h rw [List.getLast_cons h] at w₂ - convert w₂ + convert! w₂ · exact w₁ d List.mem_cons_self · by_cases h' : L = [] · rcases h' with rfl @@ -275,7 +275,7 @@ theorem digits_eq_nil_iff_eq_zero {b n : ℕ} : digits b n = [] ↔ n = 0 := by constructor · intro h have : ofDigits b (digits b n) = ofDigits b [] := by rw [h] - convert this + convert! this rw [ofDigits_digits] · rintro rfl simp @@ -383,7 +383,7 @@ theorem ofDigits_lt_base_pow_length {b : ℕ} {l : List ℕ} (hb : 1 < b) (hl : /-- Any number m is less than (b+2)^(number of digits in the base b + 2 representation of m) -/ theorem lt_base_pow_length_digits' {b m : ℕ} : m < (b + 2) ^ (digits (b + 2) m).length := by - convert @ofDigits_lt_base_pow_length' b (digits (b + 2) m) fun _ => digits_lt_base' + convert! @ofDigits_lt_base_pow_length' b (digits (b + 2) m) fun _ => digits_lt_base' rw [ofDigits_digits (b + 2) m] /-- Any number m is less than b^(number of digits in the base b representation of m) -/ @@ -455,8 +455,9 @@ lemma ofDigits_div_pow_eq_ofDigits_drop -/ lemma self_div_pow_eq_ofDigits_drop {p : ℕ} (i n : ℕ) (h : 2 ≤ p) : n / p ^ i = ofDigits p ((p.digits n).drop i) := by - convert ofDigits_div_pow_eq_ofDigits_drop i (zero_lt_of_lt h) (p.digits n) - (fun l hl ↦ digits_lt_base h hl) + convert! + ofDigits_div_pow_eq_ofDigits_drop i (zero_lt_of_lt h) (p.digits n) + (fun l hl ↦ digits_lt_base h hl) exact (ofDigits_digits p n).symm /-- Interpreting as a base `p` number and modulo `p^i` is the same as taking the first `i` digits. @@ -484,8 +485,9 @@ lemma ofDigits_mod_pow_eq_ofDigits_take -/ lemma self_mod_pow_eq_ofDigits_take {p : ℕ} (i n : ℕ) (h : 2 ≤ p) : n % p ^ i = ofDigits p ((p.digits n).take i) := by - convert ofDigits_mod_pow_eq_ofDigits_take i (zero_lt_of_lt h) (p.digits n) - (fun l hl ↦ digits_lt_base h hl) + convert! + ofDigits_mod_pow_eq_ofDigits_take i (zero_lt_of_lt h) (p.digits n) + (fun l hl ↦ digits_lt_base h hl) exact (ofDigits_digits p n).symm /-! ### `Nat.toDigits` length -/ diff --git a/Mathlib/Data/Nat/Digits/Lemmas.lean b/Mathlib/Data/Nat/Digits/Lemmas.lean index 54710594e597fd..4aae05517589dc 100644 --- a/Mathlib/Data/Nat/Digits/Lemmas.lean +++ b/Mathlib/Data/Nat/Digits/Lemmas.lean @@ -139,7 +139,7 @@ theorem pow_length_le_mul_ofDigits {b : ℕ} {l : List ℕ} (hl : l ≠ []) (hl2 apply Nat.mul_le_mul_left refine le_trans ?_ (Nat.le_add_left _ _) have : 0 < l.getLast hl := by rwa [pos_iff_ne_zero] - convert Nat.mul_le_mul_left ((b + 2) ^ (l.length - 1)) this using 1 + convert! Nat.mul_le_mul_left ((b + 2) ^ (l.length - 1)) this using 1 rw [Nat.mul_one] /-- Any non-zero natural number `m` is greater than @@ -148,8 +148,7 @@ theorem pow_length_le_mul_ofDigits {b : ℕ} {l : List ℕ} (hl : l ≠ []) (hl2 theorem base_pow_length_digits_le' (b m : ℕ) (hm : m ≠ 0) : (b + 2) ^ (digits (b + 2) m).length ≤ (b + 2) * m := by have : digits (b + 2) m ≠ [] := digits_ne_nil_iff_ne_zero.mpr hm - convert @pow_length_le_mul_ofDigits b (digits (b + 2) m) - this (getLast_digit_ne_zero _ hm) + convert! @pow_length_le_mul_ofDigits b (digits (b + 2) m) this (getLast_digit_ne_zero _ hm) rw [ofDigits_digits] /-- Any non-zero natural number `m` is greater than @@ -201,8 +200,9 @@ theorem sub_one_mul_sum_log_div_pow_eq_sub_sum_digits {p : ℕ} (n : ℕ) : obtain h | rfl | h : 1 < p ∨ 1 = p ∨ p < 1 := trichotomous 1 p · rcases eq_or_ne n 0 with rfl | hn · simp - · convert sub_one_mul_sum_div_pow_eq_sub_sum_digits (p.digits n) (getLast_digit_ne_zero p hn) <| - (fun l a ↦ digits_lt_base h a) + · convert! + sub_one_mul_sum_div_pow_eq_sub_sum_digits (p.digits n) (getLast_digit_ne_zero p hn) <| + (fun l a ↦ digits_lt_base h a) · refine (length_digits p n h hn).symm all_goals exact (ofDigits_digits p n).symm · simp @@ -288,7 +288,7 @@ theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits congr · skip · rw [← ofDigits_digits b' n] - convert ofDigits_modEq b' b (digits b' n) + convert! ofDigits_modEq b' b (digits b' n) exact h.symm theorem zmodeq_ofDigits_digits (b b' : ℕ) (c : ℤ) (h : b' ≡ c [ZMOD b]) (n : ℕ) : @@ -421,7 +421,7 @@ This spelling can be helpful for some proofs. theorem _root_.Nat.bijOn_ofDigits' {b : ℕ} (hb : 1 < b) (l : ℕ) : Set.BijOn (ofDigits b) (fixedLengthDigits hb l) (Finset.range (b ^ l)) := by rw [fixedLengthDigits, Set.coe_toFinset] - convert bijOn_ofDigits hb l + convert! bijOn_ofDigits hb l ext; simp /-- @@ -431,7 +431,7 @@ This spelling can be helpful for some proofs. theorem _root_.Nat.bijOn_digitsAppend' {b : ℕ} (hb : 1 < b) (l : ℕ) : Set.BijOn (digitsAppend b l) (Finset.range (b ^ l)) (fixedLengthDigits hb l) := by rw [fixedLengthDigits, Set.coe_toFinset] - convert bijOn_digitsAppend hb l + convert! bijOn_digitsAppend hb l ext; simp @[simp] diff --git a/Mathlib/Data/Nat/Factorization/Induction.lean b/Mathlib/Data/Nat/Factorization/Induction.lean index b4d7f97e8d9be3..cbae182d598614 100644 --- a/Mathlib/Data/Nat/Factorization/Induction.lean +++ b/Mathlib/Data/Nat/Factorization/Induction.lean @@ -37,7 +37,7 @@ def recOnPrimePow {motive : ℕ → Sort*} (zero : motive 0) (one : motive 1) letI t := (k + 2).factorization p haveI hpt : p ^ t ∣ k + 2 := ordProj_dvd _ _ haveI htp : 0 < t := hp.factorization_pos_of_dvd (k + 1).succ_ne_zero (k + 2).minFac_dvd - convert prime_pow_mul ((k + 2) / p ^ t) p t hp _ htp (hk _ (Nat.div_lt_of_lt_mul _)) using 1 + convert! prime_pow_mul ((k + 2) / p ^ t) p t hp _ htp (hk _ (Nat.div_lt_of_lt_mul _)) using 1 · rw [Nat.mul_div_cancel' hpt] · rw [Nat.dvd_div_iff_mul_dvd hpt, ← Nat.pow_succ] exact pow_succ_factorization_not_dvd (k + 1).succ_ne_zero hp diff --git a/Mathlib/Data/Nat/GCD/Basic.lean b/Mathlib/Data/Nat/GCD/Basic.lean index 26cceb810a4f00..f3db6e8c9de9d2 100644 --- a/Mathlib/Data/Nat/GCD/Basic.lean +++ b/Mathlib/Data/Nat/GCD/Basic.lean @@ -36,6 +36,9 @@ theorem gcd_greatest {a b d : ℕ} (hda : d ∣ a) (hdb : d ∣ b) (hd : ∀ e : d = a.gcd b := (dvd_antisymm (hd _ (gcd_dvd_left a b) (gcd_dvd_right a b)) (dvd_gcd hda hdb)).symm +theorem gcd_right_comm (a b c : ℕ) : gcd (gcd a b) c = gcd (gcd a c) b := by + rw [gcd_assoc, gcd_assoc, gcd_comm b c] + /-! Lemmas where one argument consists of addition of a multiple of the other -/ @[simp] @@ -206,7 +209,7 @@ theorem gcd_mul_of_coprime_of_dvd {a b c : ℕ} (hac : Coprime a c) (b_dvd_c : b gcd (a * b) c = b := by rcases exists_eq_mul_left_of_dvd b_dvd_c with ⟨d, rfl⟩ rw [gcd_mul_right] - convert one_mul b + convert! one_mul b exact Coprime.coprime_mul_right_right hac theorem Coprime.eq_of_mul_eq_zero {m n : ℕ} (h : m.Coprime n) (hmn : m * n = 0) : diff --git a/Mathlib/Data/Nat/Lattice.lean b/Mathlib/Data/Nat/Lattice.lean index f5483169011237..1c215c142aa6ef 100644 --- a/Mathlib/Data/Nat/Lattice.lean +++ b/Mathlib/Data/Nat/Lattice.lean @@ -168,7 +168,7 @@ theorem sInf_add {n : ℕ} {p : ℕ → Prop} (hn : n ≤ sInf { m | p m }) : theorem sInf_add' {n : ℕ} {p : ℕ → Prop} (h : 0 < sInf { m | p m }) : sInf { m | p m } + n = sInf { m | p (m - n) } := by suffices h₁ : n ≤ sInf {m | p (m - n)} by - convert sInf_add h₁ + convert! sInf_add h₁ simp_rw [Nat.add_sub_cancel_right] obtain ⟨m, hm⟩ := nonempty_of_pos_sInf h refine diff --git a/Mathlib/Data/Nat/ModEq.lean b/Mathlib/Data/Nat/ModEq.lean index cc8b1a9aed7540..22f5deb78a5c55 100644 --- a/Mathlib/Data/Nat/ModEq.lean +++ b/Mathlib/Data/Nat/ModEq.lean @@ -167,7 +167,7 @@ protected theorem add_left_cancel (h₁ : a ≡ b [MOD n]) (h₂ : a + c ≡ b + c ≡ d [MOD n] := by simp only [modEq_iff_dvd, Int.natCast_add] at * rw [add_sub_add_comm] at h₂ - convert Int.dvd_sub h₂ h₁ using 1 + convert! Int.dvd_sub h₂ h₁ using 1 rw [add_sub_cancel_left] protected theorem add_left_cancel' (c : ℕ) (h : c + a ≡ c + b [MOD n]) : a ≡ b [MOD n] := @@ -251,7 +251,7 @@ For cancelling right multiplication on both sides of the `≡`, see `nat.modeq.m lemma of_mul_right (m : ℕ) : a ≡ b [MOD n * m] → a ≡ b [MOD n] := mul_comm m n ▸ of_mul_left _ theorem of_div (h : a / c ≡ b / c [MOD m / c]) (ha : c ∣ a) (ha : c ∣ b) (ha : c ∣ m) : - a ≡ b [MOD m] := by convert h.mul_left' c <;> rwa [Nat.mul_div_cancel'] + a ≡ b [MOD m] := by convert! h.mul_left' c <;> rwa [Nat.mul_div_cancel'] end ModEq @@ -462,7 +462,7 @@ def chineseRemainder' (h : a ≡ b [MOD gcd n m]) : { k // k ≡ a [MOD n] ∧ k /-- The natural number less than `n*m` congruent to `a` mod `n` and `b` mod `m` -/ def chineseRemainder (co : n.Coprime m) (a b : ℕ) : { k // k ≡ a [MOD n] ∧ k ≡ b [MOD m] } := - chineseRemainder' (by convert @modEq_one a b) + chineseRemainder' (by convert! @modEq_one a b) theorem chineseRemainder'_lt_lcm (h : a ≡ b [MOD gcd n m]) (hn : n ≠ 0) (hm : m ≠ 0) : ↑(chineseRemainder' h) < lcm n m := by diff --git a/Mathlib/Data/Nat/Multiplicity.lean b/Mathlib/Data/Nat/Multiplicity.lean index 5ed0419e2691e5..f0e56408451f24 100644 --- a/Mathlib/Data/Nat/Multiplicity.lean +++ b/Mathlib/Data/Nat/Multiplicity.lean @@ -211,7 +211,7 @@ theorem emultiplicity_choose' {p n k b : ℕ} (hp : p.Prime) (hnb : log p (n + k theorem emultiplicity_choose {p n k b : ℕ} (hp : p.Prime) (hkn : k ≤ n) (hnb : log p n < b) : emultiplicity p (choose n k) = #{i ∈ Ico 1 b | p ^ i ≤ k % p ^ i + (n - k) % p ^ i} := by have := Nat.sub_add_cancel hkn - convert @emultiplicity_choose' p (n - k) k b hp _ + convert! @emultiplicity_choose' p (n - k) k b hp _ · rw [this] exact this.symm ▸ hnb diff --git a/Mathlib/Data/Nat/Nth.lean b/Mathlib/Data/Nat/Nth.lean index 71232827fc3f6a..0edf7e79df4707 100644 --- a/Mathlib/Data/Nat/Nth.lean +++ b/Mathlib/Data/Nat/Nth.lean @@ -236,7 +236,7 @@ theorem nth_zero : nth p 0 = sInf (setOf p) := by rw [nth_eq_sInf]; simp theorem nth_zero_of_zero (h : p 0) : nth p 0 = 0 := by simp [nth_zero, h] theorem nth_zero_of_exists [DecidablePred p] (h : ∃ n, p n) : nth p 0 = Nat.find h := by - rw [nth_zero]; convert Nat.sInf_def h + rw [nth_zero]; convert! Nat.sInf_def h theorem nth_eq_zero {n} : nth p n = 0 ↔ p 0 ∧ n = 0 ∨ ∃ hf : (setOf p).Finite, #hf.toFinset ≤ n := by @@ -351,9 +351,9 @@ lemma nth_comp_of_strictMono {n : ℕ} {f : ℕ → ℕ} (hf : StrictMono f) repeat nth_rw 1 [nth_eq_sInf] have h0' : ∀ k', (p k' ∧ ∀ k < n + 1, nth p k < k') → k' ∈ Set.range f := fun _ h ↦ h0 _ h.1 rw [← hs h0', ← hf.monotone.map_csInf] - · convert rfl using 8 with k m' hm + · convert! rfl using 8 with k m' hm nth_rw 2 [← hf.lt_iff_lt] - convert Iff.rfl using 2 + convert! Iff.rfl using 2 exact ih m' (Nat.lt_add_one_iff.mp hm) fun hfi ↦ hm.trans (h hfi) · rcases h0 _ (nth_mem _ h) with ⟨t, ht⟩ exact ⟨t, ht ▸ (nth_mem _ h), fun _ hk ↦ ht ▸ nth_lt_nth' hk h⟩ diff --git a/Mathlib/Data/Nat/Set.lean b/Mathlib/Data/Nat/Set.lean index f5fd105bc14585..950d1dbde02f5b 100644 --- a/Mathlib/Data/Nat/Set.lean +++ b/Mathlib/Data/Nat/Set.lean @@ -36,7 +36,7 @@ theorem range_of_succ (f : ℕ → α) : {f 0} ∪ range (f ∘ succ) = range f theorem range_rec {α : Type*} (x : α) (f : ℕ → α → α) : (Set.range fun n => Nat.rec x f n : Set α) = {x} ∪ Set.range fun n => Nat.rec (f 0 x) (f ∘ succ) n := by - convert (range_of_succ (fun n => Nat.rec x f n : ℕ → α)).symm using 4 + convert! (range_of_succ (fun n => Nat.rec x f n : ℕ → α)).symm using 4 dsimp rename_i n induction n with diff --git a/Mathlib/Data/Nat/Squarefree.lean b/Mathlib/Data/Nat/Squarefree.lean index 593cb5fb0d0634..f4fb20713370c4 100644 --- a/Mathlib/Data/Nat/Squarefree.lean +++ b/Mathlib/Data/Nat/Squarefree.lean @@ -322,9 +322,10 @@ theorem sq_mul_squarefree_of_pos {n : ℕ} (hn : 0 < n) : rw [Nat.isUnit_iff] by_contra hx refine Nat.lt_le_asymm ?_ (Finset.le_max' S ((b * x) ^ 2) ?_) - · convert lt_mul_of_one_lt_right hlts - (one_lt_pow two_ne_zero (one_lt_iff_ne_zero_and_ne_one.mpr ⟨fun h => by simp_all, hx⟩)) - using 1 + · convert! + lt_mul_of_one_lt_right hlts + (one_lt_pow two_ne_zero (one_lt_iff_ne_zero_and_ne_one.mpr ⟨fun h => by simp_all, hx⟩)) + using 1 rw [mul_pow] · simp_rw [S, hsa, Finset.mem_filter, Finset.mem_range] refine ⟨Nat.lt_succ_iff.mpr (le_of_dvd hn ?_), ?_, ⟨b * x, rfl⟩⟩ <;> use y <;> rw [hy] <;> ring diff --git a/Mathlib/Data/Nat/Totient.lean b/Mathlib/Data/Nat/Totient.lean index 82ed34fccf49ac..4a0b3dd32e0d8b 100644 --- a/Mathlib/Data/Nat/Totient.lean +++ b/Mathlib/Data/Nat/Totient.lean @@ -172,7 +172,7 @@ theorem sum_totient (n : ℕ) : n.divisors.sum φ = n := by exact sum_congr rfl fun x hx => totient_div_of_dvd (dvd_of_mem_divisors hx) theorem sum_totient' (n : ℕ) : ∑ m ∈ range n.succ with m ∣ n, φ m = n := by - convert sum_totient _ using 1 + convert! sum_totient _ using 1 simp only [Nat.divisors, sum_filter, range_eq_Ico] rw [sum_eq_sum_Ico_succ_bot] <;> simp diff --git a/Mathlib/Data/Num/Prime.lean b/Mathlib/Data/Num/Prime.lean index 8587208f30d454..05de04fe8517c3 100644 --- a/Mathlib/Data/Num/Prime.lean +++ b/Mathlib/Data/Num/Prime.lean @@ -52,7 +52,7 @@ theorem minFacAux_to_nat {fuel : ℕ} {n k : PosNum} (h : Nat.sqrt n < fuel + k. simp_rw [← mul_to_nat] simp only [cast_lt, dvd_to_nat] split_ifs <;> try rfl - rw [ih] <;> [congr; convert Nat.lt_succ_of_lt h using 1] <;> + rw [ih] <;> [congr; convert! Nat.lt_succ_of_lt h using 1] <;> simp only [cast_bit1, cast_succ, Nat.succ_eq_add_one, add_assoc, add_left_comm, ← one_add_one_eq_two] diff --git a/Mathlib/Data/PFun.lean b/Mathlib/Data/PFun.lean index 492e088a0f39df..ac172bc651d0b5 100644 --- a/Mathlib/Data/PFun.lean +++ b/Mathlib/Data/PFun.lean @@ -305,7 +305,7 @@ def fixInduction' {C : α → Sort*} {f : α →. β ⊕ α} {b : β} {a : α} refine fixInduction h fun a' h ih => ?_ rcases e : (f a').get (dom_of_mem_fix h) with b' | a'' <;> replace e : _ ∈ f a' := ⟨_, e⟩ · apply hbase - convert e + convert! e exact Part.mem_unique h (fix_stop e) · exact hind _ _ (fix_fwd h e) e (ih _ e) diff --git a/Mathlib/Data/Prod/Lex.lean b/Mathlib/Data/Prod/Lex.lean index 6eebf8dda44b85..36daf39da9ebf5 100644 --- a/Mathlib/Data/Prod/Lex.lean +++ b/Mathlib/Data/Prod/Lex.lean @@ -196,7 +196,7 @@ instance instLinearOrder (α β : Type*) [LinearOrder α] [LinearOrder β] : Lin have : Std.LawfulLTOrd (α ×ₗ β) := ⟨by simp [compare_def, compareLex, compareOn, Ordering.then_eq_lt, toLex_lt_toLex, compare_lt_iff_lt]⟩ - convert Std.LawfulLTCmp.eq_compareOfLessAndEq (cmp := compare) a b + convert! Std.LawfulLTCmp.eq_compareOfLessAndEq (cmp := compare) a b @[to_dual] instance orderBot [PartialOrder α] [Preorder β] [OrderBot α] [OrderBot β] : OrderBot (α ×ₗ β) where diff --git a/Mathlib/Data/QPF/Univariate/Basic.lean b/Mathlib/Data/QPF/Univariate/Basic.lean index cafb4578dd5c9b..c7ede75799d102 100644 --- a/Mathlib/Data/QPF/Univariate/Basic.lean +++ b/Mathlib/Data/QPF/Univariate/Basic.lean @@ -311,7 +311,7 @@ theorem Fix.ind (p : Fix F → Prop) (h : ∀ x : F (Fix F), Liftp p x → p (Fi apply h rw [liftp_iff] refine ⟨_, _, rfl, ?_⟩ - convert ih + convert! ih end QPF diff --git a/Mathlib/Data/Rat/Star.lean b/Mathlib/Data/Rat/Star.lean index 4654c29151d80e..0e10b183895b52 100644 --- a/Mathlib/Data/Rat/Star.lean +++ b/Mathlib/Data/Rat/Star.lean @@ -49,7 +49,7 @@ namespace Rat @[simp] lemma addSubmonoid_closure_range_pow {n : ℕ} (hn₀ : n ≠ 0) (hn : Even n) : closure (range fun x : ℚ ↦ x ^ n) = nonneg _ := by - convert (AddMonoidHom.map_mclosure NNRat.coeHom <| range fun x ↦ x ^ n).symm + convert! (AddMonoidHom.map_mclosure NNRat.coeHom <| range fun x ↦ x ^ n).symm · have (x : ℚ) : ∃ y : ℚ≥0, y ^ n = x ^ n := ⟨x.nnabs, by simp [hn.pow_abs]⟩ simp [subset_antisymm_iff, range_subset_iff, this] · ext diff --git a/Mathlib/Data/Real/Archimedean.lean b/Mathlib/Data/Real/Archimedean.lean index f3f1887b4ed9de..27eb96d5d109a8 100644 --- a/Mathlib/Data/Real/Archimedean.lean +++ b/Mathlib/Data/Real/Archimedean.lean @@ -176,7 +176,7 @@ theorem sInf_univ : sInf (@Set.univ ℝ) = 0 := by @[simp] lemma iSup_of_isEmpty [IsEmpty ι] (f : ι → ℝ) : ⨆ i, f i = 0 := by dsimp [iSup] - convert Real.sSup_empty + convert! Real.sSup_empty rw [Set.range_eq_empty_iff] infer_instance diff --git a/Mathlib/Data/Real/Basic.lean b/Mathlib/Data/Real/Basic.lean index 0962408a023fe2..2f5810c41fc767 100644 --- a/Mathlib/Data/Real/Basic.lean +++ b/Mathlib/Data/Real/Basic.lean @@ -349,7 +349,7 @@ theorem ratCast_lt {x y : ℚ} : (x : ℝ) < (y : ℝ) ↔ x < y := by exact const_lt protected theorem zero_lt_one : (0 : ℝ) < 1 := by - convert ratCast_lt.2 zero_lt_one <;> simp [← ofCauchy_ratCast, ofCauchy_one, ofCauchy_zero] + convert! ratCast_lt.2 zero_lt_one <;> simp [← ofCauchy_ratCast, ofCauchy_one, ofCauchy_zero] instance instNontrivial : Nontrivial ℝ where exists_pair_ne := ⟨0, 1, Real.zero_lt_one.ne⟩ diff --git a/Mathlib/Data/Real/ConjExponents.lean b/Mathlib/Data/Real/ConjExponents.lean index 06f66035c76433..e923a5955d86f6 100644 --- a/Mathlib/Data/Real/ConjExponents.lean +++ b/Mathlib/Data/Real/ConjExponents.lean @@ -152,7 +152,7 @@ theorem sub_one_pos : 0 < p - 1 := sub_pos.2 h.lt theorem sub_one_ne_zero : p - 1 ≠ 0 := h.sub_one_pos.ne' theorem conjugate_eq : q = p / (p - 1) := by - convert inv_inv q ▸ congr($(h.symm.inv_sub_inv_eq_inv.symm)⁻¹) using 1 + convert! inv_inv q ▸ congr($(h.symm.inv_sub_inv_eq_inv.symm)⁻¹) using 1 field [h.ne_zero] lemma conjExponent_eq : conjExponent p = q := h.conjugate_eq.symm diff --git a/Mathlib/Data/Real/Embedding.lean b/Mathlib/Data/Real/Embedding.lean index 38310ed8f8d397..51ff4fed81ba88 100644 --- a/Mathlib/Data/Real/Embedding.lean +++ b/Mathlib/Data/Real/Embedding.lean @@ -132,7 +132,7 @@ theorem ratLt_add (x y : M) : ratLt (x + y) = ratLt x + ratLt y := by · have hk' : 1 + (k • a.num • 1 - k • a.den • y) ≤ k • a.den • x - 1 := by rw [smul_add, smul_sub, smul_add, le_sub_iff_add_le, ← sub_le_iff_le_add] at hk rw [le_sub_iff_add_le] - convert hk using 1 + convert! hk using 1 abel have : k • a.num • 1 - k • a.den • y < m • 1 := lt_of_lt_of_le (lt_add_of_pos_left _ zero_lt_one) (by simpa using hk'.trans hm1) diff --git a/Mathlib/Data/Real/Sqrt.lean b/Mathlib/Data/Real/Sqrt.lean index 8bb4012dd2ea7d..1d7361a4aaa405 100644 --- a/Mathlib/Data/Real/Sqrt.lean +++ b/Mathlib/Data/Real/Sqrt.lean @@ -431,7 +431,7 @@ theorem sqrt_one_add_le (h : -1 ≤ x) : √(1 + x) ≤ 1 + x / 2 := by theorem sqrt_prod {ι : Type*} (s : Finset ι) {x : ι → ℝ} (hx : ∀ i ∈ s, 0 ≤ x i) : √(∏ i ∈ s, x i) = ∏ i ∈ s, √(x i) := by - convert congr_arg NNReal.toReal <| map_prod NNReal.sqrtHom (Real.toNNReal ∘ x) s <;> + convert! congr_arg NNReal.toReal <| map_prod NNReal.sqrtHom (Real.toNNReal ∘ x) s <;> simp +contextual [-map_prod, NNReal.sqrtHom, hx] end Real diff --git a/Mathlib/Data/Seq/Basic.lean b/Mathlib/Data/Seq/Basic.lean index 9c2de0390ff899..aaed2f9473b5cd 100644 --- a/Mathlib/Data/Seq/Basic.lean +++ b/Mathlib/Data/Seq/Basic.lean @@ -495,7 +495,7 @@ theorem drop_get? {n m : ℕ} {s : Seq α} : (s.drop n).get? m = s.get? (n + m) | zero => simp [drop] | succ k ih => simp only [drop, get?_tail] - convert ih using 2 + convert! ih using 2 lia theorem dropn_add (s : Seq α) (m) : ∀ n, drop s (m + n) = drop (drop s m) n @@ -535,7 +535,7 @@ theorem drop_length' {n : ℕ} {s : Seq α} : | nil => simp | cons x s => simp only [drop_succ_cons, length'_cons, Nat.cast_add, Nat.cast_one] - convert drop_length' using 1 + convert! drop_length' using 1 generalize s.length' = m enat_to_nat lia @@ -622,12 +622,12 @@ theorem zipWith_map (s₁ : Seq α) (s₂ : Seq β) (f₁ : α → α') (f₂ : theorem zipWith_map_left (s₁ : Seq α) (s₂ : Seq β) (f : α → α') (g : α' → β → γ) : zipWith g (s₁.map f) s₂ = zipWith (fun a b ↦ g (f a) b) s₁ s₂ := by - convert zipWith_map _ _ _ (@id β) _ + convert! zipWith_map _ _ _ (@id β) _ simp theorem zipWith_map_right (s₁ : Seq α) (s₂ : Seq β) (f : β → β') (g : α → β' → γ) : zipWith g s₁ (s₂.map f) = zipWith (fun a b ↦ g a (f b)) s₁ s₂ := by - convert zipWith_map _ _ (@id α) _ _ + convert! zipWith_map _ _ (@id α) _ _ simp theorem zip_map (s₁ : Seq α) (s₂ : Seq β) (f₁ : α → α') (f₂ : β → β') : @@ -638,12 +638,12 @@ theorem zip_map (s₁ : Seq α) (s₂ : Seq β) (f₁ : α → α') (f₂ : β theorem zip_map_left (s₁ : Seq α) (s₂ : Seq β) (f : α → α') : (s₁.map f).zip s₂ = (s₁.zip s₂).map (Prod.map f id) := by - convert zip_map _ _ _ _ + convert! zip_map _ _ _ _ simp theorem zip_map_right (s₁ : Seq α) (s₂ : Seq β) (f : β → β') : s₁.zip (s₂.map f) = (s₁.zip s₂).map (Prod.map id f) := by - convert zip_map _ _ _ _ + convert! zip_map _ _ _ _ simp end ZipWith diff --git a/Mathlib/Data/Set/Card.lean b/Mathlib/Data/Set/Card.lean index 59cc2f2713652b..0ca67610454cc5 100644 --- a/Mathlib/Data/Set/Card.lean +++ b/Mathlib/Data/Set/Card.lean @@ -86,7 +86,8 @@ theorem toENat_cardinalMk_subtype (P : α → Prop) : (Cardinal.mk {x // P x}).toENat = {x | P x}.encard := rfl -@[simp] theorem coe_fintypeCard (s : Set α) [Fintype s] : Fintype.card s = s.encard := by +variable (s) in +theorem coe_fintypeCard [Fintype s] : Fintype.card s = s.encard := by simp [encard_eq_coe_toFinset_card] @[simp, norm_cast] theorem encard_coe_eq_coe_finsetCard (s : Finset α) : @@ -203,9 +204,9 @@ theorem encard_diff (h : s ⊆ t) (hs : s.Finite) : exact (ENat.addLECancellable_of_ne_top <| encard_ne_top_iff.mpr hs).eq_tsub_of_add_eq rfl @[simp] theorem one_le_encard_iff_nonempty : 1 ≤ s.encard ↔ s.Nonempty := by - rw [nonempty_iff_ne_empty, Ne, ← encard_eq_zero, ENat.one_le_iff_ne_zero] + rw [nonempty_iff_ne_empty, Ne, ← encard_eq_zero, Order.one_le_iff_ne_zero] -@[simp] lemma encard_lt_one : s.encard < 1 ↔ s = ∅ := by simp [← not_le, not_nonempty_iff_eq_empty] +lemma encard_lt_one : s.encard < 1 ↔ s = ∅ := by simp theorem encard_diff_add_encard_inter (s t : Set α) : (s \ t).encard + (s ∩ t).encard = s.encard := by @@ -293,7 +294,7 @@ theorem encard_insert_le (s : Set α) (x : α) : (insert x s).encard ≤ s.encar rw [← union_singleton, ← encard_singleton x]; apply encard_union_le theorem one_le_encard_insert (s : Set α) : 1 ≤ (insert a s).encard := - ENat.one_le_iff_ne_zero.mpr <| encard_ne_zero_of_mem (mem_insert a s) + Order.one_le_iff_ne_zero.mpr <| encard_ne_zero_of_mem (mem_insert a s) theorem encard_singleton_inter (s : Set α) (x : α) : ({x} ∩ s).encard ≤ 1 := by grw [← encard_singleton x, inter_subset_left] @@ -355,7 +356,7 @@ theorem encard_eq_one : s.encard = 1 ↔ ∃ x, s = {x} := by exact ⟨x, ((finite_singleton x).eq_of_subset_of_encard_le (by simpa) (by simp [h])).symm⟩ theorem encard_le_one_iff_eq : s.encard ≤ 1 ↔ s = ∅ ∨ ∃ x, s = {x} := by - rw [le_iff_lt_or_eq, lt_iff_not_ge, ENat.one_le_iff_ne_zero, not_not, encard_eq_zero, + rw [le_iff_lt_or_eq, lt_iff_not_ge, Order.one_le_iff_ne_zero, not_not, encard_eq_zero, encard_eq_one] theorem encard_le_one_iff : s.encard ≤ 1 ↔ ∀ a b, a ∈ s → b ∈ s → a = b := by @@ -424,7 +425,7 @@ theorem encard_eq_four {α : Type u_1} {s : Set α} : encard_singleton] <;> grind theorem Nat.encard_range (k : ℕ) : {i | i < k}.encard = k := by - convert encard_coe_eq_coe_finsetCard (Finset.range k) using 1 + convert! encard_coe_eq_coe_finsetCard (Finset.range k) using 1 · rw [Finset.coe_range, Iio_def] rw [Finset.card_range] @@ -544,7 +545,7 @@ termination_by encard s theorem Finite.exists_bijOn_of_encard_eq [Nonempty β] (hs : s.Finite) (h : s.encard = t.encard) : ∃ (f : α → β), BijOn f s t := by obtain ⟨f, hf, hinj⟩ := hs.exists_injOn_of_encard_le h.le; use f - convert hinj.bijOn_image + convert! hinj.bijOn_image rw [(hs.image f).eq_of_subset_of_encard_le (image_subset_iff.mpr hf) (h.symm.trans hinj.encard_image.symm).le] @@ -590,6 +591,7 @@ theorem Finite.cast_ncard_eq (hs : s.Finite) : s.ncard = s.encard := by rwa [ncard, ENat.coe_toNat_eq_self, ne_eq, encard_eq_top_iff, Set.Infinite, not_not] variable (s) in +@[simp] theorem coe_ncard_eq_encard [Finite s] : s.ncard = s.encard := s.toFinite.cast_ncard_eq @@ -607,6 +609,7 @@ theorem ncard_eq_toFinset_card' (s : Set α) [Fintype s] : simp [← _root_.Nat.card_coe_set_eq, Nat.card_eq_fintype_card] variable (s) in +@[simp] theorem fintypeCard_eq_ncard [Fintype s] : Fintype.card s = s.ncard := by rw [ncard_eq_toFinset_card', toFinset_card] @@ -733,7 +736,7 @@ theorem ncard_diff_singleton_lt_of_mem {a : α} (h : a ∈ s) (hs : s.Finite := theorem ncard_diff_singleton_le (s : Set α) (a : α) : (s \ {a}).ncard ≤ s.ncard := by obtain hs | hs := s.finite_or_infinite · apply ncard_le_ncard diff_subset hs - convert Nat.zero_le _ + convert! Nat.zero_le _ exact (hs.diff (by simp)).ncard theorem pred_ncard_le_ncard_diff_singleton (s : Set α) (a : α) : s.ncard - 1 ≤ (s \ {a}).ncard := by @@ -800,7 +803,7 @@ theorem fiber_ncard_ne_zero_iff_mem_image {y : β} (hs : s.Finite := by toFinite @[simp] theorem ncard_subtype (P : α → Prop) (s : Set α) : { x : Subtype P | (x : α) ∈ s }.ncard = (s ∩ setOf P).ncard := by - convert (ncard_image_of_injective _ (@Subtype.coe_injective _ P)).symm + convert! (ncard_image_of_injective _ (@Subtype.coe_injective _ P)).symm ext x simp [← and_assoc, exists_eq_right] @@ -917,7 +920,7 @@ theorem surj_on_of_inj_on_of_ncard_le {t : Set β} (f : ∀ a ∈ s, β) (hf : have hft := ht.fintype have hft' := Fintype.ofInjective f' finj set f'' : ∀ a, a ∈ s.toFinset → β := fun a h ↦ f a (by simpa using h) - convert @Finset.surj_on_of_inj_on_of_card_le _ _ _ t.toFinset f'' _ _ _ _ (by simpa) using 1 + convert! @Finset.surj_on_of_inj_on_of_card_le _ _ _ t.toFinset f'' _ _ _ _ (by simpa) using 1 · simp [f''] · simp [f'', hf] · intro a₁ a₂ ha₁ ha₂ h @@ -1008,7 +1011,7 @@ theorem ncard_le_ncard_diff_add_ncard (s t : Set α) (ht : t.Finite := by toFini · to_encard_tac rw [ht.cast_ncard_eq, hs.cast_ncard_eq, hs.diff.cast_ncard_eq] apply encard_le_encard_diff_add_encard - convert Nat.zero_le _ + convert! Nat.zero_le _ rw [hs.ncard] theorem le_ncard_diff (s t : Set α) (hs : s.Finite := by toFinite_tac) : @@ -1159,7 +1162,7 @@ theorem exists_eq_insert_iff_ncard (hs : s.Finite := by toFinite_tac) : rcases t.finite_or_infinite with ht | ht · rw [ncard_eq_toFinset_card _ hs, ncard_eq_toFinset_card _ ht, ← @Finite.toFinset_subset_toFinset _ _ _ hs ht, ← Finset.exists_eq_insert_iff] - convert Iff.rfl using 2; simp only [Finite.mem_toFinset] + convert! Iff.rfl using 2; simp only [Finite.mem_toFinset] ext x simp [Finset.ext_iff, Set.ext_iff] simp only [ht.ncard, add_eq_zero, and_false, iff_false, not_exists, not_and, diff --git a/Mathlib/Data/Set/Countable.lean b/Mathlib/Data/Set/Countable.lean index 159b4c557c90d1..6b7123b0f8dc27 100644 --- a/Mathlib/Data/Set/Countable.lean +++ b/Mathlib/Data/Set/Countable.lean @@ -107,7 +107,7 @@ lemma range_enumerateCountable_of_mem {s : Set α} (h : s.Countable) {default : lemma enumerateCountable_mem {s : Set α} (h : s.Countable) {default : α} (h_mem : default ∈ s) (n : ℕ) : enumerateCountable h default n ∈ s := by - convert mem_range_self n + convert! mem_range_self n exact (range_enumerateCountable_of_mem h h_mem).symm end Enumerate diff --git a/Mathlib/Data/Set/Finite/Basic.lean b/Mathlib/Data/Set/Finite/Basic.lean index f21ac811686ff5..8aaf058fa7db8e 100644 --- a/Mathlib/Data/Set/Finite/Basic.lean +++ b/Mathlib/Data/Set/Finite/Basic.lean @@ -744,7 +744,7 @@ theorem seq_of_forall_finite_exists {γ : Type*} {P : γ → Set γ → Prop} set f : (n : ℕ) → (g : (m : ℕ) → m < n → γ) → γ := fun n g => c (range fun k : Iio n => g k.1 k.2) set u : ℕ → γ := fun n => Nat.strongRecOn' n f refine ⟨u, fun n => ?_⟩ - convert hc (u '' Iio n) ((finite_lt_nat _).image _) + convert! hc (u '' Iio n) ((finite_lt_nat _).image _) rw [image_eq_range] exact Nat.strongRecOn'_beta @@ -759,7 +759,6 @@ theorem card_fintypeInsertOfNotMem {a : α} (s : Set α) [Fintype s] (h : a ∉ @Fintype.card _ (fintypeInsertOfNotMem s h) = Fintype.card s + 1 := by simp [Fintype.card_ofFinset] -@[simp] theorem card_insert {a : α} (s : Set α) [Fintype s] (h : a ∉ s) {d : Fintype (insert a s : Set α)} : @Fintype.card _ d = Fintype.card s + 1 := by rw [← card_fintypeInsertOfNotMem s h]; congr! diff --git a/Mathlib/Data/Set/Finite/List.lean b/Mathlib/Data/Set/Finite/List.lean index be8fbccb43237d..2c876db304d957 100644 --- a/Mathlib/Data/Set/Finite/List.lean +++ b/Mathlib/Data/Set/Finite/List.lean @@ -29,7 +29,7 @@ variable (α : Type*) [Finite α] (n : ℕ) lemma finite_length_eq : {l : List α | l.length = n}.Finite := List.Vector.finite lemma finite_length_lt : {l : List α | l.length < n}.Finite := by - convert (Finset.range n).finite_toSet.biUnion fun i _ ↦ finite_length_eq α i; ext; simp + convert! (Finset.range n).finite_toSet.biUnion fun i _ ↦ finite_length_eq α i; ext; simp lemma finite_length_le : {l : List α | l.length ≤ n}.Finite := by simpa [Nat.lt_succ_iff] using finite_length_lt α (n + 1) diff --git a/Mathlib/Data/Set/Finite/Powerset.lean b/Mathlib/Data/Set/Finite/Powerset.lean index a8f20c26fecf65..e35e8dfbe343b6 100644 --- a/Mathlib/Data/Set/Finite/Powerset.lean +++ b/Mathlib/Data/Set/Finite/Powerset.lean @@ -46,7 +46,7 @@ section SetFiniteConstructors /-- There are finitely many subsets of a given finite set -/ theorem Finite.finite_subsets {α : Type u} {a : Set α} (h : a.Finite) : { b | b ⊆ a }.Finite := by - convert ((Finset.powerset h.toFinset).map Finset.coeEmb.1).finite_toSet + convert! ((Finset.powerset h.toFinset).map Finset.coeEmb.1).finite_toSet ext s simpa [← @exists_finite_iff_finset α fun t => t ⊆ a ∧ t = s, Finite.subset_toFinset, ← and_assoc, Finset.coeEmb] using h.subset diff --git a/Mathlib/Data/Set/FiniteExhaustion.lean b/Mathlib/Data/Set/FiniteExhaustion.lean index 6cfb3cfb31fd10..4b00a7caea82ec 100644 --- a/Mathlib/Data/Set/FiniteExhaustion.lean +++ b/Mathlib/Data/Set/FiniteExhaustion.lean @@ -74,12 +74,15 @@ noncomputable def _root_.Set.Countable.finiteExhaustion {s : Set α} (hs : s.Cou · refine ⟨fun _ ↦ ∅, by simp [Finite.to_subtype], fun n ↦ by simp, ?_⟩ simp [Set.not_nonempty_iff_eq_empty'.mp h] -lemma Set.nonempty_finiteExhaustion_iff {s : Set α} : +lemma _root_.Set.nonempty_finiteExhaustion_iff {s : Set α} : Nonempty s.FiniteExhaustion ↔ s.Countable := by refine ⟨fun ⟨K⟩ ↦ ?_, fun h ↦ ⟨h.finiteExhaustion⟩⟩ rw [← K.iUnion_eq] exact countable_iUnion <| fun i ↦ (K.finite i).countable +@[deprecated (since := "2026-05-24")] +alias Set.nonempty_finiteExhaustion_iff := Set.nonempty_finiteExhaustion_iff + section prod variable {β : Type*} {t : Set β} (K' : FiniteExhaustion t) diff --git a/Mathlib/Data/Set/Function.lean b/Mathlib/Data/Set/Function.lean index cd97f345ec3ab0..2547fd9e0627c1 100644 --- a/Mathlib/Data/Set/Function.lean +++ b/Mathlib/Data/Set/Function.lean @@ -776,7 +776,7 @@ theorem BijOn.insert (h₁ : BijOn f s t) (h₂ : f a ∉ t) : theorem BijOn.sdiff_singleton (h₁ : BijOn f s t) (h₂ : a ∈ s) : BijOn f (s \ {a}) (t \ {f a}) := by - convert h₁.subset_left diff_subset + convert! h₁.subset_left diff_subset simp [h₁.injOn.image_diff, h₁.image_eq, h₂, inter_eq_self_of_subset_right] end bijOn diff --git a/Mathlib/Data/Set/Functor.lean b/Mathlib/Data/Set/Functor.lean index 832006af446848..0f503b76ec6d22 100644 --- a/Mathlib/Data/Set/Functor.lean +++ b/Mathlib/Data/Set/Functor.lean @@ -122,10 +122,10 @@ theorem mem_coe_of_mem {a : α} (ha : a ∈ β) (ha' : ⟨a, ha⟩ ∈ γ) : a ⟨_, ⟨⟨_, rfl⟩, _, ⟨ha', rfl⟩, rfl⟩⟩ theorem coe_subset : (γ : Set α) ⊆ β := by - intro _ ⟨_, ⟨⟨⟨_, ha⟩, rfl⟩, _, ⟨_, rfl⟩, _⟩⟩; convert ha + intro _ ⟨_, ⟨⟨⟨_, ha⟩, rfl⟩, _, ⟨_, rfl⟩, _⟩⟩; convert! ha theorem mem_of_mem_coe {a : α} (ha : a ∈ (γ : Set α)) : ⟨a, coe_subset ha⟩ ∈ γ := by - rcases ha with ⟨_, ⟨_, rfl⟩, _, ⟨ha, rfl⟩, _⟩; convert ha + rcases ha with ⟨_, ⟨_, rfl⟩, _, ⟨ha, rfl⟩, _⟩; convert! ha theorem eq_univ_of_coe_eq (hγ : (γ : Set α) = β) : γ = univ := eq_univ_of_forall fun ⟨_, ha⟩ => mem_of_mem_coe <| hγ.symm ▸ ha diff --git a/Mathlib/Data/Set/Lattice.lean b/Mathlib/Data/Set/Lattice.lean index c6e4283cbf7e38..63d05b1804bd77 100644 --- a/Mathlib/Data/Set/Lattice.lean +++ b/Mathlib/Data/Set/Lattice.lean @@ -380,6 +380,37 @@ theorem diff_iUnion [Nonempty ι] (s : Set β) (t : ι → Set β) : (s \ ⋃ i, theorem diff_iInter (s : Set β) (t : ι → Set β) : (s \ ⋂ i, t i) = ⋃ i, s \ t i := by simp only [diff_eq, compl_iInter, inter_iUnion] +section SymmDiff + +open scoped symmDiff + +lemma iUnion_symmDiff_subset {s : Set α} [Nonempty ι] {f : ι → Set α} : + (⋃ n, f n) ∆ s ⊆ ⋃ n, f n ∆ s := + iSup_symmDiff_le + +lemma symmDiff_iUnion_subset {s : Set α} [Nonempty ι] {f : ι → Set α} : + s ∆ (⋃ n, f n) ⊆ ⋃ n, s ∆ f n := + symmDiff_iSup_le + +lemma iUnion_symmDiff_iUnion_subset {f g : ι → Set α} : + (⋃ n, f n) ∆ ⋃ n, g n ⊆ ⋃ n, f n ∆ g n := + iSup_symmDiff_iSup_le + +lemma sUnion_symmDiff_subset {s : Set α} {S : Set (Set α)} (hS : S.Nonempty) : + (⋃₀ S) ∆ s ⊆ ⋃₀ ((· ∆ s) '' S) := + sSup_symmDiff_le hS + +lemma symmDiff_sUnion_subset {s : Set α} {S : Set (Set α)} (hS : S.Nonempty) : + s ∆ (⋃₀ S) ⊆ ⋃₀ ((s ∆ ·) '' S) := + symmDiff_sSup_le hS + +lemma sUnion_symmDiff_sUnion_subset {S T : Set (Set α)} (hS : S.Nonempty) + (hT : T.Nonempty) : + (⋃₀ S) ∆ ⋃₀ T ⊆ ⋃₀ (image2 (· ∆ ·) S T) := + sSup_symmDiff_sSup_le hS hT + +end SymmDiff + theorem iUnion_inter_subset {ι α} {s t : ι → Set α} : ⋃ i, s i ∩ t i ⊆ (⋃ i, s i) ∩ ⋃ i, t i := le_iSup_inf_iSup s t diff --git a/Mathlib/Data/Set/Notation.lean b/Mathlib/Data/Set/Notation.lean index 44710b82b33a68..a911c23c8b904c 100644 --- a/Mathlib/Data/Set/Notation.lean +++ b/Mathlib/Data/Set/Notation.lean @@ -46,7 +46,7 @@ If the `Set.Notation` namespace is open, sets of a subtype coerced to the ambien represented with `↑`. -/ @[scoped delab app.Set.image] -meta def delab_set_image_subtype : Delab := whenPPOption getPPCoercions do +meta def delabSetImageSubtype : Delab := whenPPOption getPPCoercions do let #[α, _, f, _] := (← getExpr).getAppArgs | failure guard <| f.isAppOfArity ``Subtype.val 2 let some _ := α.coeTypeSet? | failure diff --git a/Mathlib/Data/Set/Pairwise/Lattice.lean b/Mathlib/Data/Set/Pairwise/Lattice.lean index 079baec834fe03..fbf4ab64e45cfb 100644 --- a/Mathlib/Data/Set/Pairwise/Lattice.lean +++ b/Mathlib/Data/Set/Pairwise/Lattice.lean @@ -103,11 +103,11 @@ theorem PairwiseDisjoint.prod_left {f : ι × ι' → α} rw [mem_prod] at hi hj obtain rfl | hij := eq_or_ne i j · refine (ht hi.2 hj.2 <| (Prod.mk_right_injective _).ne_iff.1 h).mono ?_ ?_ - · convert le_iSup₂ (α := α) i hi.1; rfl - · convert le_iSup₂ (α := α) i hj.1; rfl + · convert! le_iSup₂ (α := α) i hi.1; rfl + · convert! le_iSup₂ (α := α) i hj.1; rfl · refine (hs hi.1 hj.1 hij).mono ?_ ?_ - · convert le_iSup₂ (α := α) i' hi.2; rfl - · convert le_iSup₂ (α := α) j' hj.2; rfl + · convert! le_iSup₂ (α := α) i' hi.2; rfl + · convert! le_iSup₂ (α := α) j' hj.2; rfl end CompleteLattice diff --git a/Mathlib/Data/Set/Prod.lean b/Mathlib/Data/Set/Prod.lean index 161b9cca4c1660..7d149c0e225d7f 100644 --- a/Mathlib/Data/Set/Prod.lean +++ b/Mathlib/Data/Set/Prod.lean @@ -857,7 +857,7 @@ theorem update_preimage_pi [DecidableEq ι] {f : ∀ i, α i} (hi : i ∈ s) (hf : ∀ j ∈ s, j ≠ i → f j ∈ t j) : update f i ⁻¹' s.pi t = t i := by ext x refine ⟨fun h => ?_, fun hx j hj => ?_⟩ - · convert h i hi + · convert! h i hi simp · obtain rfl | h := eq_or_ne j i · simpa diff --git a/Mathlib/Data/Setoid/Partition.lean b/Mathlib/Data/Setoid/Partition.lean index cb76177a7c4601..bc60410dd6d3ee 100644 --- a/Mathlib/Data/Setoid/Partition.lean +++ b/Mathlib/Data/Setoid/Partition.lean @@ -127,7 +127,7 @@ theorem eqv_class_mem {c : Set (Set α)} (H : ∀ a, ∃! b ∈ c, a ∈ b) {y} theorem eqv_class_mem' {c : Set (Set α)} (H : ∀ a, ∃! b ∈ c, a ∈ b) {x} : { y : α | mkClasses c H x y } ∈ c := by - convert @Setoid.eqv_class_mem _ _ H x using 3 + convert! @Setoid.eqv_class_mem _ _ H x using 3 rw [Setoid.comm'] /-- Distinct elements of a set of sets partitioning α are disjoint. -/ diff --git a/Mathlib/Data/Sym/Basic.lean b/Mathlib/Data/Sym/Basic.lean index fc21fbc7ab78bd..df918acd8a60df 100644 --- a/Mathlib/Data/Sym/Basic.lean +++ b/Mathlib/Data/Sym/Basic.lean @@ -607,7 +607,7 @@ theorem decode_encode [DecidableEq α] (s : Sym (Option α) n.succ) : decode (en · simp [h] · simp only [decode, h, not_false_iff, encode_of_none_notMem, Embedding.some_apply, map_map, comp_apply, Option.some_get] - convert s.attach_map_coe + convert! s.attach_map_coe @[simp] theorem encode_decode [DecidableEq α] (s : Sym (Option α) n ⊕ Sym α n.succ) : diff --git a/Mathlib/Data/Sym/Card.lean b/Mathlib/Data/Sym/Card.lean index 8d5f7e0fb9eafb..d6146ac7399e49 100644 --- a/Mathlib/Data/Sym/Card.lean +++ b/Mathlib/Data/Sym/Card.lean @@ -144,7 +144,7 @@ theorem card_image_offDiag (s : Finset α) : Nat.div_eq_of_eq_mul_right Nat.zero_lt_two (two_mul_card_image_offDiag s).symm] theorem card_subtype_diag [Fintype α] : card { a : Sym2 α // a.IsDiag } = card α := by - convert card_image_diag (univ : Finset α) + convert! card_image_diag (univ : Finset α) rw [← filter_image_mk_isDiag, Fintype.card_of_subtype] rintro x rw [mem_filter, univ_product_univ, mem_image] @@ -153,7 +153,7 @@ theorem card_subtype_diag [Fintype α] : card { a : Sym2 α // a.IsDiag } = card theorem card_subtype_not_diag [Fintype α] : card { a : Sym2 α // ¬a.IsDiag } = (card α).choose 2 := by - convert card_image_offDiag (univ : Finset α) + convert! card_image_offDiag (univ : Finset α) rw [← filter_image_mk_not_isDiag, Fintype.card_of_subtype] rintro x rw [mem_filter, univ_product_univ, mem_image] diff --git a/Mathlib/Data/Sym/Sym2.lean b/Mathlib/Data/Sym/Sym2.lean index 9560031b3aadc4..ef739a2f795121 100644 --- a/Mathlib/Data/Sym/Sym2.lean +++ b/Mathlib/Data/Sym/Sym2.lean @@ -380,7 +380,7 @@ theorem other_spec {a : α} {z : Sym2 α} (h : a ∈ z) : s(a, Mem.other h) = z (Classical.choose_spec h).symm theorem other_mem {a : α} {z : Sym2 α} (h : a ∈ z) : Mem.other h ∈ z := by - convert mem_mk_right a <| Mem.other h + convert! mem_mk_right a <| Mem.other h rw [other_spec h] theorem mem_and_mem_iff {x y : α} {z : Sym2 α} (hne : x ≠ y) : x ∈ z ∧ y ∈ z ↔ z = s(x, y) := by @@ -900,7 +900,7 @@ theorem other_invol {a : α} {z : Sym2 α} (ha : a ∈ z) (hb : Mem.other ha ∈ Mem.other hb = a := by classical rw [other_eq_other'] at hb ⊢ - convert other_invol' ha hb using 2 + convert! other_invol' ha hb using 2 apply other_eq_other' theorem filter_image_mk_isDiag [DecidableEq α] (s : Finset α) : diff --git a/Mathlib/Data/ZMod/Aut.lean b/Mathlib/Data/ZMod/Aut.lean index 29299953a8ac16..6513919ba3f4a4 100644 --- a/Mathlib/Data/ZMod/Aut.lean +++ b/Mathlib/Data/ZMod/Aut.lean @@ -22,13 +22,14 @@ variable (n : ℕ) /-- The automorphism group of `ZMod n` is isomorphic to the group of units of `ZMod n`. -/ @[simps] -def AddAutEquivUnits : AddAut (ZMod n) ≃* (ZMod n)ˣ := +def AddAutEquivUnits : AddAut (ZMod n) ≃+ Additive (ZMod n)ˣ := have h (f : AddAut (ZMod n)) (x : ZMod n) : f 1 * x = f x := by rw [mul_comm, ← x.intCast_zmod_cast, ← zsmul_eq_mul, ← map_zsmul, zsmul_one] - { toFun := fun f ↦ Units.mkOfMulEqOne (f 1) (f⁻¹ 1) ((h f _).trans (f.apply_inv_self _ _)) - invFun := AddAut.mulLeft - left_inv := fun f ↦ by simp [DFunLike.ext_iff, Units.smul_def, h] - right_inv := fun x ↦ by simp [Units.ext_iff, Units.smul_def] - map_mul' := fun f g ↦ by simp [Units.ext_iff, h] } + { toFun f := .ofMul <| Units.mkOfMulEqOne (f 1) ((-f) 1) ((h f _).trans (f.apply_neg_self _ _)) + invFun x := AddAut.mulLeft x.toMul + left_inv g := by simp [DFunLike.ext_iff, Units.smul_def, h] + right_inv x := by simp [← Additive.toMul_symm_eq, Equiv.symm_apply_eq, + Units.ext_iff, Units.smul_def, -toMul_smul] + map_add' f g := by simp [← Additive.toMul_symm_eq, Equiv.symm_apply_eq, Units.ext_iff, h] } end ZMod diff --git a/Mathlib/Data/ZMod/Defs.lean b/Mathlib/Data/ZMod/Defs.lean index 70625d7130ba48..e1b9832a88d149 100644 --- a/Mathlib/Data/ZMod/Defs.lean +++ b/Mathlib/Data/ZMod/Defs.lean @@ -173,7 +173,7 @@ instance infinite : Infinite (ZMod 0) := theorem card (n : ℕ) [Fintype (ZMod n)] : Fintype.card (ZMod n) = n := by cases n with | zero => exact (not_finite (ZMod 0)).elim - | succ n => convert Fintype.card_fin (n + 1) using 2 + | succ n => convert! Fintype.card_fin (n + 1) using 2 open Fin.CommRing in /- We define each field by cases, to ensure that the eta-expanded `ZMod.commRing` is defeq to the diff --git a/Mathlib/Dynamics/Circle/RotationNumber/TranslationNumber.lean b/Mathlib/Dynamics/Circle/RotationNumber/TranslationNumber.lean index 19050a9344c7a5..211cc993c968d7 100644 --- a/Mathlib/Dynamics/Circle/RotationNumber/TranslationNumber.lean +++ b/Mathlib/Dynamics/Circle/RotationNumber/TranslationNumber.lean @@ -601,7 +601,7 @@ theorem tendsto_translationNumber_of_dist_bounded_aux (x : ℕ → ℝ) (C : ℝ · exact fun n => C / 2 ^ n · intro n have : 0 < (2 ^ n : ℝ) := pow_pos zero_lt_two _ - convert (div_le_div_iff_of_pos_right this).2 (H (2 ^ n)) using 1 + convert! (div_le_div_iff_of_pos_right this).2 (H (2 ^ n)) using 1 rw [transnumAuxSeq, Real.dist_eq, ← sub_div, abs_div, abs_of_pos this, Real.dist_eq] · exact mul_zero C ▸ tendsto_const_nhds.mul <| tendsto_inv_atTop_zero.comp <| tendsto_pow_atTop_atTop_of_one_lt one_lt_two diff --git a/Mathlib/Dynamics/Ergodic/AddCircle.lean b/Mathlib/Dynamics/Ergodic/AddCircle.lean index a28cf4365101ab..18cc7d4d865a22 100644 --- a/Mathlib/Dynamics/Ergodic/AddCircle.lean +++ b/Mathlib/Dynamics/Ergodic/AddCircle.lean @@ -77,7 +77,7 @@ theorem ae_empty_or_univ_of_forall_vadd_ae_eq_self {s : Set <| AddCircle T} refine tendsto_nhdsWithin_iff.mpr ⟨?_, hδ₀⟩ replace hu₂ : Tendsto (fun j => T⁻¹ * 2 * n j) l atTop := (tendsto_natCast_atTop_iff.mpr hu₂).const_mul_atTop (by positivity : 0 < T⁻¹ * 2) - convert hu₂.inv_tendsto_atTop + convert! hu₂.inv_tendsto_atTop ext j simp only [δ, Pi.inv_apply, mul_inv_rev, inv_inv, div_eq_inv_mul, ← mul_assoc] have hw : ∀ᶠ j in l, d ∈ closedBall d (1 * δ j) := hδ₀.mono fun j hj => by @@ -108,8 +108,8 @@ theorem ergodic_zsmul {n : ℤ} (hn : 1 < |n|) : Ergodic fun y : AddCircle T => let u : ℕ → AddCircle T := fun j => ↑((↑1 : ℝ) / ↑(n.natAbs ^ j) * T) replace hn : 1 < n.natAbs := by rwa [Int.abs_eq_natAbs, Nat.one_lt_cast] at hn have hu₀ : ∀ j, addOrderOf (u j) = n.natAbs ^ j := fun j => by - convert addOrderOf_div_of_gcd_eq_one (p := T) (m := 1) - (pow_pos (pos_of_gt hn) j) (gcd_one_left _) + convert! + addOrderOf_div_of_gcd_eq_one (p := T) (m := 1) (pow_pos (pos_of_gt hn) j) (gcd_one_left _) norm_cast have hnu : ∀ j, n ^ j • u j = 0 := fun j => by rw [← addOrderOf_dvd_iff_zsmul_eq_zero, hu₀, Int.natCast_pow, Int.natCast_natAbs, ← abs_pow, diff --git a/Mathlib/Dynamics/Ergodic/Conservative.lean b/Mathlib/Dynamics/Ergodic/Conservative.lean index 49f8e871799643..588beec67d972d 100644 --- a/Mathlib/Dynamics/Ergodic/Conservative.lean +++ b/Mathlib/Dynamics/Ergodic/Conservative.lean @@ -111,7 +111,7 @@ theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : NullMeas -- Let `N` be the maximal `n` such that `μ (t n) ≠ 0`. obtain ⟨N, hN, hmax⟩ : ∃ N, μ (t N) ≠ 0 ∧ ∀ n > N, μ (t n) = 0 := by rw [Nat.frequently_atTop_iff_infinite, not_infinite] at H - convert exists_max_image _ (·) H ⟨0, by simpa⟩ using 4 + convert! exists_max_image _ (·) H ⟨0, by simpa⟩ using 4 rw [gt_iff_lt, ← not_le, not_imp_comm, mem_setOf] have htm {n : ℕ} : NullMeasurableSet (t n) μ := hs.inter <| hs.preimage <| hf.toQuasiMeasurePreserving.iterate n diff --git a/Mathlib/Dynamics/Ergodic/Extreme.lean b/Mathlib/Dynamics/Ergodic/Extreme.lean index 2ee079eb31b078..179180aff42be7 100644 --- a/Mathlib/Dynamics/Ergodic/Extreme.lean +++ b/Mathlib/Dynamics/Ergodic/Extreme.lean @@ -33,7 +33,7 @@ theorem of_mem_extremePoints_measure_univ_eq {c : ℝ≥0∞} (hc : c ≠ ∞) (h : μ ∈ extremePoints ℝ≥0∞ {ν | MeasurePreserving f ν ν ∧ ν univ = c}) : Ergodic f μ := by have hf : MeasurePreserving f μ μ := h.1.1 rcases eq_or_ne c 0 with rfl | hc₀ - · convert zero_measure hf.measurable + · convert! zero_measure hf.measurable rw [← measure_univ_eq_zero, h.1.2] · refine ⟨hf, ⟨?_⟩⟩ have : IsFiniteMeasure μ := by @@ -43,7 +43,7 @@ theorem of_mem_extremePoints_measure_univ_eq {c : ℝ≥0∞} (hc : c ≠ ∞) have {s : Set X} (hsm : MeasurableSet s) (hfs : f ⁻¹' s = s) (hμs : μ s ≠ 0) : c • μ[|s] ∈ S := by refine ⟨.smul_measure (.smul_measure ?_ _) c, ?_⟩ - · convert hf.restrict_preimage hsm + · convert! hf.restrict_preimage hsm exact hfs.symm · rw [Measure.smul_apply, (cond_isProbabilityMeasure hμs).1, smul_eq_mul, mul_one] intro s hsm hfs diff --git a/Mathlib/Dynamics/Ergodic/MeasurePreserving.lean b/Mathlib/Dynamics/Ergodic/MeasurePreserving.lean index 9397ca23a5b51e..f032f13e6b867c 100644 --- a/Mathlib/Dynamics/Ergodic/MeasurePreserving.lean +++ b/Mathlib/Dynamics/Ergodic/MeasurePreserving.lean @@ -122,13 +122,13 @@ protected theorem trans {e : α ≃ᵐ β} {e' : β ≃ᵐ γ} protected theorem comp_left_iff {g : α → β} {e : β ≃ᵐ γ} (h : MeasurePreserving e μb μc) : MeasurePreserving (e ∘ g) μa μc ↔ MeasurePreserving g μa μb := by refine ⟨fun hg => ?_, fun hg => h.comp hg⟩ - convert (MeasurePreserving.symm e h).comp hg + convert! (MeasurePreserving.symm e h).comp hg simp [← Function.comp_assoc e.symm e g] protected theorem comp_right_iff {g : α → β} {e : γ ≃ᵐ α} (h : MeasurePreserving e μc μa) : MeasurePreserving (g ∘ e) μc μb ↔ MeasurePreserving g μa μb := by refine ⟨fun hg => ?_, fun hg => hg.comp h⟩ - convert hg.comp (MeasurePreserving.symm e h) + convert! hg.comp (MeasurePreserving.symm e h) simp [Function.comp_assoc g e e.symm] protected theorem sigmaFinite {f : α → β} (hf : MeasurePreserving f μa μb) [SigmaFinite μb] : diff --git a/Mathlib/Dynamics/Ergodic/RadonNikodym.lean b/Mathlib/Dynamics/Ergodic/RadonNikodym.lean index 80a8bc36ab3856..e5cd2061fb5d2a 100644 --- a/Mathlib/Dynamics/Ergodic/RadonNikodym.lean +++ b/Mathlib/Dynamics/Ergodic/RadonNikodym.lean @@ -39,7 +39,7 @@ protected theorem singularPart [SigmaFinite ν] {f : X → X} (hfμ : MeasurePreserving f μ μ) (hfν : MeasurePreserving f ν ν) : MeasurePreserving f (μ.singularPart ν) (μ.singularPart ν) := by rcases (μ.mutuallySingular_singularPart ν).symm with ⟨s, hsm, hνs, hμs⟩ - convert hfμ.restrict_preimage hsm using 1 + convert! hfμ.restrict_preimage hsm using 1 · refine singularPart_eq_restrict ?_ (hfν.preimage_null hνs) rw [← mem_ae_iff, ← Filter.eventuallyEq_univ, ae_eq_univ_iff_measure_eq (hfμ.measurable hsm).nullMeasurableSet] diff --git a/Mathlib/Dynamics/FixedPoints/Basic.lean b/Mathlib/Dynamics/FixedPoints/Basic.lean index 2a463bb4d6a351..b50d061d690b58 100644 --- a/Mathlib/Dynamics/FixedPoints/Basic.lean +++ b/Mathlib/Dynamics/FixedPoints/Basic.lean @@ -64,7 +64,7 @@ protected theorem map {x : α} (hx : IsFixedPt fa x) {g : α → β} (h : Semico fb (g x) = g (fa x) := (h.eq x).symm _ = g x := congr_arg g hx -protected theorem apply {x : α} (hx : IsFixedPt f x) : IsFixedPt f (f x) := by convert hx +protected theorem apply {x : α} (hx : IsFixedPt f x) : IsFixedPt f (f x) := by convert! hx theorem preimage_iterate {s : Set α} (h : IsFixedPt (Set.preimage f) s) (n : ℕ) : IsFixedPt (Set.preimage f^[n]) s := by diff --git a/Mathlib/Dynamics/Newton.lean b/Mathlib/Dynamics/Newton.lean index 54b4f7eec79b07..3a5a2f1eed579c 100644 --- a/Mathlib/Dynamics/Newton.lean +++ b/Mathlib/Dynamics/Newton.lean @@ -92,7 +92,7 @@ theorem aeval_pow_two_pow_dvd_aeval_iterate_newtonMap rw [eval_map_algebraMap, eval_map_algebraMap] at hd rw [iterate_succ', comp_apply, newtonMap_apply, sub_eq_add_neg, neg_mul_eq_neg_mul, hd] refine dvd_add ?_ (dvd_mul_of_dvd_right ?_ _) - · convert dvd_zero _ + · convert! dvd_zero _ have : IsUnit (aeval (P.newtonMap^[n] x) <| derivative P) := isUnit_aeval_of_isUnit_aeval_of_isNilpotent_sub h' <| isNilpotent_iterate_newtonMap_sub_of_isNilpotent h n diff --git a/Mathlib/Dynamics/PeriodicPts/Defs.lean b/Mathlib/Dynamics/PeriodicPts/Defs.lean index 53245e2d1fc261..b9f5bcfdb870af 100644 --- a/Mathlib/Dynamics/PeriodicPts/Defs.lean +++ b/Mathlib/Dynamics/PeriodicPts/Defs.lean @@ -219,7 +219,7 @@ theorem isPeriodicPt_of_mem_periodicPts_of_isPeriodicPt_iterate (hx : x ∈ peri rcases hx with ⟨r, hr, hr'⟩ suffices n ≤ (n / r + 1) * r by unfold IsPeriodicPt IsFixedPt - convert (hm.apply_iterate ((n / r + 1) * r - n)).eq <;> + convert! (hm.apply_iterate ((n / r + 1) * r - n)).eq <;> rw [← iterate_add_apply, Nat.sub_add_cancel this, iterate_mul, (hr'.iterate _).eq] rw [Nat.add_mul, one_mul] exact (Nat.lt_div_mul_add hr).le diff --git a/Mathlib/Dynamics/TopologicalEntropy/CoverEntropy.lean b/Mathlib/Dynamics/TopologicalEntropy/CoverEntropy.lean index 4275159343e796..50b7155cbdf265 100644 --- a/Mathlib/Dynamics/TopologicalEntropy/CoverEntropy.lean +++ b/Mathlib/Dynamics/TopologicalEntropy/CoverEntropy.lean @@ -250,7 +250,7 @@ lemma coverMincard_eq_zero_iff (T : X → X) (F : Set X) (U : SetRel X X) (n : lemma one_le_coverMincard_iff (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) : 1 ≤ coverMincard T F U n ↔ F.Nonempty := by - rw [ENat.one_le_iff_ne_zero, nonempty_iff_ne_empty, not_iff_not] + rw [Order.one_le_iff_ne_zero, nonempty_iff_ne_empty, not_iff_not] exact coverMincard_eq_zero_iff T F U n lemma coverMincard_zero (T : X → X) (h : F.Nonempty) (U : SetRel X X) : diff --git a/Mathlib/Dynamics/TopologicalEntropy/NetEntropy.lean b/Mathlib/Dynamics/TopologicalEntropy/NetEntropy.lean index 73e12847758ff1..ec703db6a05007 100644 --- a/Mathlib/Dynamics/TopologicalEntropy/NetEntropy.lean +++ b/Mathlib/Dynamics/TopologicalEntropy/NetEntropy.lean @@ -169,7 +169,7 @@ lemma netMaxcard_eq_zero_iff (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ lemma one_le_netMaxcard_iff (T : X → X) (F : Set X) (U : SetRel X X) (n : ℕ) : 1 ≤ netMaxcard T F U n ↔ F.Nonempty := by - rw [ENat.one_le_iff_ne_zero, nonempty_iff_ne_empty] + rw [Order.one_le_iff_ne_zero, nonempty_iff_ne_empty] exact not_iff_not.2 (netMaxcard_eq_zero_iff T F U n) lemma netMaxcard_zero (T : X → X) (h : F.Nonempty) (U : SetRel X X) : netMaxcard T F U 0 = 1 := by diff --git a/Mathlib/Dynamics/TopologicalEntropy/Semiconj.lean b/Mathlib/Dynamics/TopologicalEntropy/Semiconj.lean index b82e2581436e08..2dda7201c9e185 100644 --- a/Mathlib/Dynamics/TopologicalEntropy/Semiconj.lean +++ b/Mathlib/Dynamics/TopologicalEntropy/Semiconj.lean @@ -195,7 +195,7 @@ theorem coverEntropy_image_le_of_uniformContinuous [UniformSpace X] [UniformSpac {T : Y → Y} {φ : X → Y} (h : Semiconj φ S T) (h' : UniformContinuous φ) (F : Set X) : coverEntropy T (φ '' F) ≤ coverEntropy S F := by rw [coverEntropy_image_of_comap _ h F] - exact coverEntropy_antitone S F (uniformContinuous_iff.1 h') + exact coverEntropy_antitone S F (uniformContinuous_iff_le_comap.1 h') /-- The entropy of `φ '' F` is at most the entropy of `F` if `φ` is uniformly continuous. This version uses a `liminf`. -/ @@ -203,7 +203,7 @@ theorem coverEntropyInf_image_le_of_uniformContinuous [UniformSpace X] [UniformS {T : Y → Y} {φ : X → Y} (h : Semiconj φ S T) (h' : UniformContinuous φ) (F : Set X) : coverEntropyInf T (φ '' F) ≤ coverEntropyInf S F := by rw [coverEntropyInf_image_of_comap _ h F] - exact coverEntropyInf_antitone S F (uniformContinuous_iff.1 h') + exact coverEntropyInf_antitone S F (uniformContinuous_iff_le_comap.1 h') lemma coverEntropy_image_le_of_uniformContinuousOn_invariant [UniformSpace X] [UniformSpace Y] {S : X → X} {T : Y → Y} {φ : X → Y} (h : Semiconj φ S T) {F G : Set X} diff --git a/Mathlib/FieldTheory/AxGrothendieck.lean b/Mathlib/FieldTheory/AxGrothendieck.lean index 8e53ea1d5b9e54..94d369434cca0b 100644 --- a/Mathlib/FieldTheory/AxGrothendieck.lean +++ b/Mathlib/FieldTheory/AxGrothendieck.lean @@ -186,7 +186,7 @@ theorem ACF_models_genericPolyMapSurjOnOfInjOn_of_prime_or_zero rcases hp with hp | rfl · exact ACF_models_genericPolyMapSurjOnOfInjOn_of_prime hp φ mons · rw [ACF_zero_realize_iff_infinite_ACF_prime_realize] - convert Set.infinite_univ (α := Nat.Primes) + convert! Set.infinite_univ (α := Nat.Primes) rw [Set.eq_univ_iff_forall] intro ⟨p, hp⟩ exact ACF_models_genericPolyMapSurjOnOfInjOn_of_prime hp φ mons diff --git a/Mathlib/FieldTheory/ChevalleyWarning.lean b/Mathlib/FieldTheory/ChevalleyWarning.lean index d82b8e10bcac70..3c677a71b410d5 100644 --- a/Mathlib/FieldTheory/ChevalleyWarning.lean +++ b/Mathlib/FieldTheory/ChevalleyWarning.lean @@ -178,7 +178,7 @@ theorem char_dvd_card_solutions {f : MvPolynomial σ K} (h : f.totalDegree < Fin p ∣ Fintype.card { x : σ → K // eval x f = 0 } := by let F : Unit → MvPolynomial σ K := fun _ => f have : (∑ i : Unit, (F i).totalDegree) < Fintype.card σ := h - convert char_dvd_card_solutions_of_sum_lt p this + convert! char_dvd_card_solutions_of_sum_lt p this aesop /-- The **Chevalley–Warning theorem**, binary version. diff --git a/Mathlib/FieldTheory/Differential/Liouville.lean b/Mathlib/FieldTheory/Differential/Liouville.lean index 1dfde8c2da970b..cf3775cc229db0 100644 --- a/Mathlib/FieldTheory/Differential/Liouville.lean +++ b/Mathlib/FieldTheory/Differential/Liouville.lean @@ -187,7 +187,7 @@ private local instance isLiouville_of_finiteDimensional_galois [FiniteDimensiona · rcongr e apply_fun e at h simp only [AlgEquiv.commutes, map_add, map_sum, map_mul] at h - convert h using 2 + convert! h using 2 · rcongr x simp [logDeriv, algEquiv_deriv'] · rw [algEquiv_deriv'] diff --git a/Mathlib/FieldTheory/Extension.lean b/Mathlib/FieldTheory/Extension.lean index 644fc34de1f01e..7221fe4410be1e 100644 --- a/Mathlib/FieldTheory/Extension.lean +++ b/Mathlib/FieldTheory/Extension.lean @@ -244,7 +244,7 @@ private theorem exists_algHom_adjoin_of_splits'' {L : IntermediateField F E} have := φ.exists_lift_of_splits' (hK s h).1.tower_top ((hK s h).1.minpoly_splits_tower_top' ?_) · obtain ⟨y, h1, h2⟩ := this exact (hφ h1).1 h2 - · convert (hK s h).2; ext; apply hfφ.2 + · convert! (hK s h).2; ext; apply hfφ.2 variable {L : Type*} [Field L] [Algebra F L] [Algebra L E] [IsScalarTower F L E] (f : L →ₐ[F] K) (hK : ∀ s ∈ S, IsIntegral L s ∧ ((minpoly L s).map f.toRingHom).Splits) @@ -267,7 +267,7 @@ theorem exists_algHom_adjoin_of_splits' : letI : Algebra L L' := (AlgEquiv.ofInjectiveField _).toRingHom.toAlgebra have : IsScalarTower L L' E := IsScalarTower.of_algebraMap_eq' rfl refine ⟨(hK s hs).1.tower_top, (hK s hs).1.minpoly_splits_tower_top' ?_⟩ - convert (hK s hs).2 + convert! (hK s hs).2 ext simp only [AlgHom.toRingHom_eq_coe, RingHom.coe_comp, RingHom.coe_coe, AlgHom.coe_comp, Function.comp_apply, f'] diff --git a/Mathlib/FieldTheory/Finite/Basic.lean b/Mathlib/FieldTheory/Finite/Basic.lean index cce31993821d21..16f15d2c985534 100644 --- a/Mathlib/FieldTheory/Finite/Basic.lean +++ b/Mathlib/FieldTheory/Finite/Basic.lean @@ -456,7 +456,7 @@ theorem roots_X_pow_card_sub_X : roots (X ^ q - X : K[X]) = Finset.univ.val := b rw [← this, Multiset.toFinset_val, eq_comm, Multiset.dedup_eq_self] apply nodup_roots rw [separable_def] - convert isCoprime_one_right.neg_right (R := K[X]) using 1 + convert! isCoprime_one_right.neg_right (R := K[X]) using 1 rw [derivative_sub, derivative_X, derivative_X_pow, Nat.cast_card_eq_zero K, C_0, zero_mul, zero_sub] diff --git a/Mathlib/FieldTheory/Finite/Extension.lean b/Mathlib/FieldTheory/Finite/Extension.lean index 8e330e333d1170..299773369de76c 100644 --- a/Mathlib/FieldTheory/Finite/Extension.lean +++ b/Mathlib/FieldTheory/Finite/Extension.lean @@ -54,8 +54,9 @@ theorem finrank_zmod_extension [Algebra (ZMod p) k] : Module.finrank (ZMod p) (Extension k p n) = Module.finrank (ZMod p) k * n := by letI := ZMod.algebra k p unfold Extension - convert GaloisField.finrank p (n := Module.finrank (ZMod p) k * n) <| - mul_ne_zero Module.finrank_pos.ne' <| NeZero.ne n + convert! + GaloisField.finrank p (n := Module.finrank (ZMod p) k * n) <| + mul_ne_zero Module.finrank_pos.ne' <| NeZero.ne n subsingleton theorem nonempty_algHom_extension [Algebra (ZMod p) k] : @@ -83,7 +84,7 @@ theorem finrank_extension : Module.finrank k (Extension k p n) = n := by instance : IsSplittingField k (Extension k p n) (X ^ Nat.card k ^ n - X) := by have := Fintype.ofFinite (Extension k p n) - convert FiniteField.isSplittingField_sub (Extension k p n) k + convert! FiniteField.isSplittingField_sub (Extension k p n) k · rw [Fintype.card_eq_nat_card, natCard_extension] example : IsGalois k (Extension k p n) := diff --git a/Mathlib/FieldTheory/Finite/GaloisField.lean b/Mathlib/FieldTheory/Finite/GaloisField.lean index 5cc80830c0e2a2..a3cc93bce9b2e4 100644 --- a/Mathlib/FieldTheory/Finite/GaloisField.lean +++ b/Mathlib/FieldTheory/Finite/GaloisField.lean @@ -137,7 +137,7 @@ theorem card (h : n ≠ 0) : Nat.card (GaloisField p n) = p ^ n := by theorem splits_zmod_X_pow_sub_X : Splits (X ^ p - X : (ZMod p)[X]) := by have hp : 1 < p := h_prime.out.one_lt have h1 : roots (X ^ p - X : (ZMod p)[X]) = Finset.univ.val := by - convert FiniteField.roots_X_pow_card_sub_X (ZMod p) + convert! FiniteField.roots_X_pow_card_sub_X (ZMod p) exact (ZMod.card p).symm have h2 := FiniteField.X_pow_card_sub_X_natDegree_eq (ZMod p) hp -- We discharge the `p = 0` separately, to avoid typeclass issues on `ZMod p`. @@ -240,9 +240,12 @@ theorem unitsMap_norm_surjective : Function.Surjective (Units.map <| Algebra.nor simp_rw [Nat.card_units] classical have := Fintype.ofFinite K'ˣ - convert IsCyclic.card_pow_eq_one_le (α := K'ˣ) <| Nat.div_pos - (Nat.sub_le_sub_right (Nat.card_le_card_of_injective _ (algebraMap K K').injective) _) <| - Nat.sub_pos_of_lt Finite.one_lt_card + convert! + IsCyclic.card_pow_eq_one_le (α := K'ˣ) <| + Nat.div_pos + (Nat.sub_le_sub_right (Nat.card_le_card_of_injective _ (algebraMap K K').injective) + _) <| + Nat.sub_pos_of_lt Finite.one_lt_card rw [← Set.ncard_coe_finset, ← SetLike.coe_sort_coe, Nat.card_coe_set_eq]; congr 1; ext simp [Units.ext_iff, ← (algebraMap K K').injective.eq_iff, algebraMap_norm_eq_pow] diff --git a/Mathlib/FieldTheory/Galois/IsGaloisGroup.lean b/Mathlib/FieldTheory/Galois/IsGaloisGroup.lean index f75a19b0b7735f..54329fa3fe8621 100644 --- a/Mathlib/FieldTheory/Galois/IsGaloisGroup.lean +++ b/Mathlib/FieldTheory/Galois/IsGaloisGroup.lean @@ -289,7 +289,7 @@ theorem fixedPoints_of_isGaloisGroup [hGKL : IsGaloisGroup G K L] [hHFL : IsGalo theorem of_fixedPoints_eq [hGKL : IsGaloisGroup G K L] (hF : FixedPoints.intermediateField H = F) : IsGaloisGroup H F L := by rw [eq_comm] at hF - convert IsGaloisGroup.subgroup G K L H + convert! IsGaloisGroup.subgroup G K L H variable {G K L H F} in theorem subgroup_iff [hGKL : IsGaloisGroup G K L] : @@ -379,7 +379,7 @@ theorem fixingSubgroup_top : fixingSubgroup G ((⊤ : IntermediateField K L) : S @[simp] theorem fixedPoints_top : (FixedPoints.intermediateField (⊤ : Subgroup G) : IntermediateField K L) = ⊥ := by - convert IsGaloisGroup.fixedPoints_eq_bot G K L + convert! IsGaloisGroup.fixedPoints_eq_bot G K L ext; simp /-- The Galois correspondence from intermediate fields to subgroups. -/ diff --git a/Mathlib/FieldTheory/Galois/NormalBasis.lean b/Mathlib/FieldTheory/Galois/NormalBasis.lean index 7f280ac9f671a3..3cb4c04e24d157 100644 --- a/Mathlib/FieldTheory/Galois/NormalBasis.lean +++ b/Mathlib/FieldTheory/Galois/NormalBasis.lean @@ -44,7 +44,8 @@ theorem exists_linearIndependent_algEquiv_apply_of_finite [Finite L] : .ofBijective _ <| bijective_frobeniusAlgEquivOfAlgebraic_pow K L)] /- Therefore, `{Frⁱ | 0 ≤ i < [L : K]}` is linearly independent, which implies that `{Frⁱ(x) | 0 ≤ i < [L : K]}` is also linearly independent. -/ - convert (AdjoinRoot.powerBasis (X_pow_sub_C_ne_zero Module.finrank_pos 1)).basis.linearIndependent + convert! + (AdjoinRoot.powerBasis (X_pow_sub_C_ne_zero Module.finrank_pos 1)).basis.linearIndependent |>.map' ((AEval'.of _).symm.toLinearMap ∘ₗ (liftQ _ _ hx.le).restrictScalars K) <| by exact congr($(ker_liftQ_eq_bot' _ _ hx).restrictScalars K) ext i diff --git a/Mathlib/FieldTheory/Galois/Profinite.lean b/Mathlib/FieldTheory/Galois/Profinite.lean index 61caa2081870fb..303c5161560b10 100644 --- a/Mathlib/FieldTheory/Galois/Profinite.lean +++ b/Mathlib/FieldTheory/Galois/Profinite.lean @@ -169,7 +169,7 @@ set_option backward.isDefEq.respectTransparency false in lemma algEquivToLimit_continuous : Continuous (algEquivToLimit k K) := by rw [continuous_induced_rng] refine continuous_pi (fun L ↦ ?_) - convert restrictNormalHom_continuous L.unop.1 + convert! restrictNormalHom_continuous L.unop.1 exact (DiscreteTopology.eq_bot (α := L.unop ≃ₐ[k] L.unop)).symm /-- The projection map from `lim Gal(L/k)` to a specific `Gal(L/k)`. -/ diff --git a/Mathlib/FieldTheory/IntermediateField/Adjoin/Algebra.lean b/Mathlib/FieldTheory/IntermediateField/Adjoin/Algebra.lean index 037a6c723713d1..16ac66b953a997 100644 --- a/Mathlib/FieldTheory/IntermediateField/Adjoin/Algebra.lean +++ b/Mathlib/FieldTheory/IntermediateField/Adjoin/Algebra.lean @@ -334,7 +334,7 @@ theorem algHom_fieldRange_eq_of_comp_eq (h : RingHom.comp f (algebraMap A K) = ( f.fieldRange = IntermediateField.adjoin F g.range := by apply IntermediateField.toSubfield_injective simp_rw [AlgHom.fieldRange_toSubfield, IntermediateField.adjoin_toSubfield] - convert ringHom_fieldRange_eq_of_comp_eq h using 2 + convert! ringHom_fieldRange_eq_of_comp_eq h using 2 exact Set.union_eq_self_of_subset_left fun _ ⟨x, hx⟩ ↦ ⟨algebraMap F A x, by simp [← hx]⟩ /-- If `F` is a field, `A` is an `F`-algebra with fraction field `K`, `L` is a field, diff --git a/Mathlib/FieldTheory/IntermediateField/Adjoin/Basic.lean b/Mathlib/FieldTheory/IntermediateField/Adjoin/Basic.lean index 97988edea6e63c..3a118004d1cb36 100644 --- a/Mathlib/FieldTheory/IntermediateField/Adjoin/Basic.lean +++ b/Mathlib/FieldTheory/IntermediateField/Adjoin/Basic.lean @@ -387,7 +387,7 @@ theorem minpoly_gen (α : E) : theorem aeval_gen_minpoly (α : E) : aeval (AdjoinSimple.gen F α) (minpoly F α) = 0 := by ext - convert minpoly.aeval F α + convert! minpoly.aeval F α conv in aeval α => rw [← AdjoinSimple.algebraMap_gen F α] exact (aeval_algebraMap_apply E (AdjoinSimple.gen F α) _).symm @@ -504,8 +504,9 @@ theorem adjoin_minpoly_coeff_of_exists_primitive_element simp_all refine eq_of_le_of_finrank_le' hsub ?_ simp_rw [finrank_eq] - convert natDegree_le_of_dvd dvd_g - ((g.monic_toSubring _ _).mpr <| (minpoly.monic <| .of_finite K α).map _).ne_zero using 1 + convert! + natDegree_le_of_dvd dvd_g + ((g.monic_toSubring _ _).mpr <| (minpoly.monic <| .of_finite K α).map _).ne_zero using 1 rw [natDegree_toSubring, natDegree_map] instance : Module.Finite F (⊥ : IntermediateField F E) := Subalgebra.finite_bot diff --git a/Mathlib/FieldTheory/IntermediateField/Adjoin/Defs.lean b/Mathlib/FieldTheory/IntermediateField/Adjoin/Defs.lean index da6341a6aafb9a..a2f8d2f9e5c6ea 100644 --- a/Mathlib/FieldTheory/IntermediateField/Adjoin/Defs.lean +++ b/Mathlib/FieldTheory/IntermediateField/Adjoin/Defs.lean @@ -496,9 +496,9 @@ theorem adjoin_algHom_ext {s : Set E} ⦃φ₁ φ₂ : adjoin F s →ₐ[F] K⦄ (h : ∀ x hx, φ₁ ⟨x, subset_adjoin _ _ hx⟩ = φ₂ ⟨x, subset_adjoin _ _ hx⟩) : φ₁ = φ₂ := AlgHom.ext fun ⟨x, hx⟩ ↦ adjoin_induction _ h (fun _ ↦ φ₂.commutes _ ▸ φ₁.commutes _) - (fun _ _ _ _ h₁ h₂ ↦ by convert congr_arg₂ (· + ·) h₁ h₂ <;> rw [← map_add] <;> rfl) + (fun _ _ _ _ h₁ h₂ ↦ by convert! congr_arg₂ (· + ·) h₁ h₂ <;> rw [← map_add] <;> rfl) (fun _ _ ↦ eq_on_inv₀ _ _) - (fun _ _ _ _ h₁ h₂ ↦ by convert congr_arg₂ (· * ·) h₁ h₂ <;> rw [← map_mul] <;> rfl) + (fun _ _ _ _ h₁ h₂ ↦ by convert! congr_arg₂ (· * ·) h₁ h₂ <;> rw [← map_mul] <;> rfl) hx theorem algHom_ext_of_eq_adjoin {S : IntermediateField F E} {s : Set E} (hS : S = adjoin F s) diff --git a/Mathlib/FieldTheory/IsPerfectClosure.lean b/Mathlib/FieldTheory/IsPerfectClosure.lean index cfbb4f28cb72fd..6f8ac711154e33 100644 --- a/Mathlib/FieldTheory/IsPerfectClosure.lean +++ b/Mathlib/FieldTheory/IsPerfectClosure.lean @@ -167,7 +167,7 @@ theorem IsPRadical.comap_pNilradical [IsPRadical i p] : variable (K) in instance IsPRadical.of_id : IsPRadical (RingHom.id K) p where pow_mem' x := ⟨0, x, by simp⟩ - ker_le' x h := by convert Ideal.zero_mem _ + ker_le' x h := by convert! Ideal.zero_mem _ /-- Composition of `p`-radical ring homomorphisms is also `p`-radical. -/ theorem IsPRadical.trans [IsPRadical i p] [IsPRadical f p] : diff --git a/Mathlib/FieldTheory/JacobsonNoether.lean b/Mathlib/FieldTheory/JacobsonNoether.lean index 3704c1481f13e3..9bd233c32ef38a 100644 --- a/Mathlib/FieldTheory/JacobsonNoether.lean +++ b/Mathlib/FieldTheory/JacobsonNoether.lean @@ -130,7 +130,7 @@ theorem exists_separable_and_not_isCentral (H : k ≠ (⊤ : Subring D)) : refine ⟨Nat.find h_exist, ⟨(Nat.find_spec h_exist).1, ?_, (Nat.find_spec h_exist).2⟩⟩ set t := (Nat.find h_exist - 1 : ℕ) with ht by_cases! h_pos : 0 < t - · convert (ne_eq _ _) ▸ not_and.mp (Nat.find_min h_exist (m := t) (by lia)) h_pos + · convert! (ne_eq _ _) ▸ not_and.mp (Nat.find_min h_exist (m := t) (by lia)) h_pos lia · suffices h_find : Nat.find h_exist = 1 by rwa [h_find] diff --git a/Mathlib/FieldTheory/KrullTopology.lean b/Mathlib/FieldTheory/KrullTopology.lean index a353f904b654cc..2388afc6796f00 100644 --- a/Mathlib/FieldTheory/KrullTopology.lean +++ b/Mathlib/FieldTheory/KrullTopology.lean @@ -266,7 +266,7 @@ theorem stabilizer_isOpen_of_isIntegral [Algebra.IsIntegral K L] (x : L) : open IntermediateField in let E := adjoin K {x} have hL : FiniteDimensional K E := adjoin.finiteDimensional (Algebra.IsIntegral.isIntegral x) - convert fixingSubgroup_isOpen E + convert! fixingSubgroup_isOpen E ext g simpa using (forall_mem_adjoin_smul_eq_self_iff K (S := {x}) g).symm diff --git a/Mathlib/FieldTheory/LinearDisjoint.lean b/Mathlib/FieldTheory/LinearDisjoint.lean index 2f5378e57a22d1..031d1e1bc37f18 100644 --- a/Mathlib/FieldTheory/LinearDisjoint.lean +++ b/Mathlib/FieldTheory/LinearDisjoint.lean @@ -211,7 +211,7 @@ theorem map' (H : A.LinearDisjoint L) (K : Type*) [Field K] [Algebra F K] [Algeb rw [linearDisjoint_iff] at H ⊢ have := H.map (IsScalarTower.toAlgHom F E K) (RingHom.injective _) rw [← AlgHom.range_comp] at this - convert this + convert! this ext; exact IsScalarTower.algebraMap_apply L E K _ /-- Linear disjointness is preserved by algebra homomorphism. -/ @@ -225,7 +225,7 @@ theorem map'' {L' : Type*} [Field L'] [Algebra F L'] [Algebra L' E] [IsScalarTow have := H.map (IsScalarTower.toAlgHom F E K) (RingHom.injective _) simp_rw [AlgHom.fieldRange_toSubalgebra, ← AlgHom.range_comp] at this rw [AlgHom.fieldRange_toSubalgebra] - convert this <;> (ext; exact IsScalarTower.algebraMap_apply _ E K _) + convert! this <;> (ext; exact IsScalarTower.algebraMap_apply _ E K _) variable (A) in theorem self_right : A.LinearDisjoint F := Subalgebra.LinearDisjoint.bot_right _ @@ -370,7 +370,7 @@ theorem of_le_right' (H : A.LinearDisjoint L) (L' : Type*) [Field L'] [Algebra F L'] [Algebra L' L] [IsScalarTower F L' L] [Algebra L' E] [IsScalarTower F L' E] [IsScalarTower L' L E] : A.LinearDisjoint L' := by refine Subalgebra.LinearDisjoint.of_le_right_of_flat H ?_ - convert AlgHom.range_comp_le_range (IsScalarTower.toAlgHom F L' L) (IsScalarTower.toAlgHom F L E) + convert! AlgHom.range_comp_le_range (IsScalarTower.toAlgHom F L' L) (IsScalarTower.toAlgHom F L E) ext; exact IsScalarTower.algebraMap_apply L' L E _ /-- If `A` and `B` are linearly disjoint, `A'` and `B'` are contained in `A` and `B`, diff --git a/Mathlib/FieldTheory/Minpoly/Basic.lean b/Mathlib/FieldTheory/Minpoly/Basic.lean index ab71d551b86685..a1042606580fab 100644 --- a/Mathlib/FieldTheory/Minpoly/Basic.lean +++ b/Mathlib/FieldTheory/Minpoly/Basic.lean @@ -194,7 +194,7 @@ theorem natDegree_pos [Nontrivial B] (hx : IsIntegral A x) : 0 < natDegree (minp intro ndeg_eq_zero have eq_one : minpoly A x = 1 := by rw [eq_C_of_natDegree_eq_zero ndeg_eq_zero] - convert C_1 (R := A) + convert! C_1 (R := A) simpa only [ndeg_eq_zero.symm] using (monic hx).leadingCoeff simpa only [eq_one, map_one, one_ne_zero] using aeval A x diff --git a/Mathlib/FieldTheory/Minpoly/IsIntegrallyClosed.lean b/Mathlib/FieldTheory/Minpoly/IsIntegrallyClosed.lean index 0d61f1ce891028..98287a725d13c4 100644 --- a/Mathlib/FieldTheory/Minpoly/IsIntegrallyClosed.lean +++ b/Mathlib/FieldTheory/Minpoly/IsIntegrallyClosed.lean @@ -150,10 +150,10 @@ theorem IsIntegrallyClosed.isIntegral_iff_leadingCoeff_dvd {s : S} {p : R[X]} (h have ⟨q, hMul⟩ := isIntegrallyClosed_dvd hInt hp suffices q.degree ≤ 0 by simp [degree_le_zero_iff.mp this ▸ hMul, minpoly.monic hInt, mul_comm] apply WithBot.le_of_add_le_add_left <| Polynomial.degree_ne_bot.mpr <| minpoly.ne_zero hInt - convert pmin _ (minpoly.monic hInt) (minpoly.aeval ..) + convert! pmin _ (minpoly.monic hInt) (minpoly.aeval ..) · rw [hMul, degree_mul] · rw [add_zero] - · convert right_ne_zero_of_mul <| hMul ▸ h₀ + · convert! right_ne_zero_of_mul <| hMul ▸ h₀ refine IsIntegrallyClosed.minpoly.unique ?_ ?_ ?_ |>.symm · have := hMul ▸ leadingCoeff_mul .. |>.symm simp only [leadingCoeff_C, ne_eq, leadingCoeff_eq_zero, h₀, not_false_eq_true, mul_eq_left₀] diff --git a/Mathlib/FieldTheory/Normal/Basic.lean b/Mathlib/FieldTheory/Normal/Basic.lean index c3e5e6b526714e..f6d78c7749aae8 100644 --- a/Mathlib/FieldTheory/Normal/Basic.lean +++ b/Mathlib/FieldTheory/Normal/Basic.lean @@ -127,7 +127,7 @@ theorem splits_of_mem_adjoin {L} [Field L] [Algebra F L] {S : Set K} have : ∀ x ∈ S, ((minpoly F x).map (algebraMap F E)).Splits := fun x hx ↦ splits_of_splits (splits x hx).2 fun y hy ↦ (le_iSup _ ⟨x, hx⟩ : _ ≤ E) (subset_adjoin F _ <| by exact hy) obtain ⟨φ⟩ := nonempty_algHom_adjoin_of_splits fun x hx ↦ ⟨(splits x hx).1, this x hx⟩ - convert (normal.splits <| φ ⟨x, hx⟩).map E.val.toRingHom + convert! (normal.splits <| φ ⟨x, hx⟩).map E.val.toRingHom simp [minpoly.algHom_eq _ φ.injective, ← minpoly.algHom_eq _ (adjoin F S).val.injective, Polynomial.map_map] diff --git a/Mathlib/FieldTheory/Normal/Defs.lean b/Mathlib/FieldTheory/Normal/Defs.lean index ba83063b21b15c..89baf0c28c983a 100644 --- a/Mathlib/FieldTheory/Normal/Defs.lean +++ b/Mathlib/FieldTheory/Normal/Defs.lean @@ -90,9 +90,10 @@ theorem AlgEquiv.transfer_normal (f : E ≃ₐ[F] E') : Normal F E ↔ Normal F ⟨fun _ ↦ Normal.of_algEquiv f, fun _ ↦ Normal.of_algEquiv f.symm⟩ theorem Normal.of_equiv_equiv {M N : Type*} [Field N] [Field M] [Algebra M N] - [Algebra.IsAlgebraic F E] [h : Normal F E] {f : F ≃+* M} {g : E ≃+* N} + [h : Normal F E] {f : F ≃+* M} {g : E ≃+* N} (hcomp : (algebraMap M N).comp f = (g : E →+* N).comp (algebraMap F E)) : Normal M N := by + have := h rw [normal_iff] at h ⊢ intro x rw [← g.apply_symm_apply x] diff --git a/Mathlib/FieldTheory/Perfect.lean b/Mathlib/FieldTheory/Perfect.lean index 3e55bcb56a8448..dca92c53e8959b 100644 --- a/Mathlib/FieldTheory/Perfect.lean +++ b/Mathlib/FieldTheory/Perfect.lean @@ -362,14 +362,14 @@ theorem roots_expand_pow_map_iterateFrobenius_le : simp_rw [count_nsmul, count_roots, ← rootMultiplicity_expand_pow, ← count_roots, count_map, count_eq_card_filter_eq] exact card_le_card (monotone_filter_right _ fun _ h ↦ iterateFrobenius_inj R p n h) - convert Nat.zero_le _ + convert! Nat.zero_le _ simp_rw [count_map, card_eq_zero] exact ext' fun t ↦ count_zero t ▸ count_filter_of_neg fun h' ↦ h ⟨t, h'⟩ theorem roots_expand_map_frobenius_le : (expand R p f).roots.map (frobenius R p) ≤ p • f.roots := by rw [← iterateFrobenius_one] - convert ← roots_expand_pow_map_iterateFrobenius_le p 1 f <;> apply pow_one + convert! ← roots_expand_pow_map_iterateFrobenius_le p 1 f <;> apply pow_one theorem roots_expand_pow_image_iterateFrobenius_subset [DecidableEq R] : (expand R (p ^ n) f).roots.toFinset.image (iterateFrobenius R p n) ⊆ f.roots.toFinset := by @@ -380,7 +380,7 @@ theorem roots_expand_pow_image_iterateFrobenius_subset [DecidableEq R] : theorem roots_expand_image_frobenius_subset [DecidableEq R] : (expand R p f).roots.toFinset.image (frobenius R p) ⊆ f.roots.toFinset := by rw [← iterateFrobenius_one] - convert ← roots_expand_pow_image_iterateFrobenius_subset p 1 f + convert! ← roots_expand_pow_image_iterateFrobenius_subset p 1 f apply pow_one section PerfectRing diff --git a/Mathlib/FieldTheory/PrimitiveElement.lean b/Mathlib/FieldTheory/PrimitiveElement.lean index 70e72ba48b593d..7808f3e877d094 100644 --- a/Mathlib/FieldTheory/PrimitiveElement.lean +++ b/Mathlib/FieldTheory/PrimitiveElement.lean @@ -165,7 +165,7 @@ theorem primitive_element_inf_aux [Algebra.IsSeparable F E] : ∃ γ : E, F⟮α rw [← eq_X_sub_C_of_separable_of_root_eq h_sep h_root h_splits h_roots] trans EuclideanDomain.gcd (?_ : E[X]) (?_ : E[X]) · dsimp only [γ] - convert (gcd_map (algebraMap F⟮γ⟯ E)).symm + convert! (gcd_map (algebraMap F⟮γ⟯ E)).symm · simp only [map_comp, Polynomial.map_map, ← IsScalarTower.algebraMap_eq, Polynomial.map_sub, map_C, AdjoinSimple.algebraMap_gen, Polynomial.map_mul, map_X] congr @@ -190,7 +190,7 @@ private theorem primitive_element_inf_aux_of_finite_intermediateField replace β_in_K := smul_mem _ β_in_K (x := (x - y)⁻¹) rw [smul_smul, inv_mul_eq_div, div_self (sub_ne_zero.2 hneq), one_smul] at β_in_K have α_in_K : α ∈ F⟮α + x • β⟯ := by - convert ← sub_mem αxβ_in_K (smul_mem _ β_in_K) + convert! ← sub_mem αxβ_in_K (smul_mem _ β_in_K) apply add_sub_cancel_right rintro x (rfl | rfl) <;> assumption · rw [adjoin_simple_le_iff] @@ -320,7 +320,7 @@ theorem finite_intermediateField_of_exists_primitive_element [Algebra.IsAlgebrai -- which is a monic factor of `f` let g : IntermediateField F E → G := fun K ↦ ⟨(minpoly K α).map (algebraMap K E), (minpoly.monic <| .of_finite K α).map _, by - convert Polynomial.map_dvd (algebraMap K E) (minpoly.dvd_map_of_isScalarTower F K α) + convert! Polynomial.map_dvd (algebraMap K E) (minpoly.dvd_map_of_isScalarTower F K α) rw [Polynomial.map_map]; rfl⟩ -- The map `K ↦ g` is injective have hinj : Function.Injective g := fun K K' heq ↦ by diff --git a/Mathlib/FieldTheory/PurelyInseparable/PerfectClosure.lean b/Mathlib/FieldTheory/PurelyInseparable/PerfectClosure.lean index 7a3c681f45009c..41aa640ba2b9ff 100644 --- a/Mathlib/FieldTheory/PurelyInseparable/PerfectClosure.lean +++ b/Mathlib/FieldTheory/PurelyInseparable/PerfectClosure.lean @@ -337,7 +337,7 @@ private theorem LinearIndependent.map_pow_expChar_pow_of_fd_isSeparable (Field.span_map_pow_expChar_pow_eq_top_of_isSeparable q n b.span_eq).ge (Module.finrank_eq_card_basis b).symm let f (i : ι) : ι' := ⟨v i, h'.subset_extend _ ⟨i, rfl⟩⟩ - convert H.comp f fun _ _ heq ↦ h.injective (by simpa only [f, Subtype.mk.injEq] using heq) + convert! H.comp f fun _ _ heq ↦ h.injective (by simpa only [f, Subtype.mk.injEq] using heq) simp_rw [Function.comp_apply, b] rw [Basis.extend_apply_self] diff --git a/Mathlib/FieldTheory/PurelyInseparable/Tower.lean b/Mathlib/FieldTheory/PurelyInseparable/Tower.lean index 5a785770f2aeda..4c2702c2c0b301 100644 --- a/Mathlib/FieldTheory/PurelyInseparable/Tower.lean +++ b/Mathlib/FieldTheory/PurelyInseparable/Tower.lean @@ -73,7 +73,7 @@ theorem LinearIndependent.map_of_isPurelyInseparable_of_isSeparable [IsPurelyIns have := (expChar_pow_pos F q n).ne' replace hf (i : ι) : l i ^ q ^ n ∈ (algebraMap F E).range := by by_cases hs : i ∈ l.support - · convert pow_mem (hf i) (q ^ (n - f i)) using 1 + · convert! pow_mem (hf i) (q ^ (n - f i)) using 1 rw [← pow_mul, ← pow_add, Nat.add_sub_of_le (Finset.le_sup hs)] exact ⟨0, by rw [map_zero, Finsupp.notMem_support_iff.1 hs, zero_pow this]⟩ choose lF hlF using hf @@ -89,7 +89,7 @@ theorem LinearIndependent.map_of_isPurelyInseparable_of_isSeparable [IsPurelyIns refine Finset.sum_congr rfl fun i _ ↦ ?_ simp_rw [Algebra.smul_def, mul_pow, IsScalarTower.algebraMap_apply F E K, hlF, map_pow] refine eq_zero_of_pow_eq_zero ((hlF _).symm.trans ?_) - convert map_zero (algebraMap F E) + convert! map_zero (algebraMap F E) exact congr($h i) variable {F K} in @@ -148,7 +148,7 @@ It is a special case of `Field.lift_sepDegree_mul_lift_sepDegree_of_isAlgebraic` intermediate result used to prove it. -/ lemma sepDegree_eq_of_isPurelyInseparable [IsPurelyInseparable F E] : sepDegree F K = sepDegree E K := by - convert sepDegree_eq_of_isPurelyInseparable_of_isSeparable F E (separableClosure E K) + convert! sepDegree_eq_of_isPurelyInseparable_of_isSeparable F E (separableClosure E K) haveI : IsScalarTower F (separableClosure E K) K := IsScalarTower.of_algebraMap_eq (congrFun rfl) rw [sepDegree, ← separableClosure.map_eq_of_separableClosure_eq_bot F (separableClosure.separableClosure_eq_bot E K)] diff --git a/Mathlib/FieldTheory/RatFunc/AsPolynomial.lean b/Mathlib/FieldTheory/RatFunc/AsPolynomial.lean index 73d5d349456068..019416028599ef 100644 --- a/Mathlib/FieldTheory/RatFunc/AsPolynomial.lean +++ b/Mathlib/FieldTheory/RatFunc/AsPolynomial.lean @@ -327,7 +327,7 @@ lemma valuation_monomial_eq_valuation_X_pow (n : ℕ) {a : K} (ha : a ≠ 0) : Note: The condition `1 < v RatFunc.X` is typically satisfied by the valuation at infinity. -/ theorem valuation_eq_valuation_X_pow_natDegree_of_one_lt_valuation_X (hlt : 1 < v RatFunc.X) {p : K[X]} (hp : p ≠ 0) : v p = v RatFunc.X ^ p.natDegree := by - convert valuation_aeval_eq_valuation_X_pow_natDegree_of_one_lt_valuation_X .X hlt hp + convert! valuation_aeval_eq_valuation_X_pow_natDegree_of_one_lt_valuation_X .X hlt hp ext p nth_rw 1 [RatFunc.X, ← aeval_X_left_apply p (R := K)] exact (aeval_algebraMap_apply K⟮X⟯ X p).symm diff --git a/Mathlib/FieldTheory/RatFunc/Basic.lean b/Mathlib/FieldTheory/RatFunc/Basic.lean index 2b8eb8d1ead150..fb732adde49cc6 100644 --- a/Mathlib/FieldTheory/RatFunc/Basic.lean +++ b/Mathlib/FieldTheory/RatFunc/Basic.lean @@ -680,7 +680,7 @@ instance : IsFractionRing K[X] K⟮X⟯ where exact fun h ↦ IsLocalization.exists_of_eq ((toFractionRingRingEquiv K).symm.injective h) surj := by rintro ⟨z⟩ - convert IsLocalization.surj K[X]⁰ z + convert! IsLocalization.surj K[X]⁰ z simp only [← ofFractionRing_algebraMap, ← ofFractionRing_mul, ofFractionRing.injEq] @@ -899,7 +899,7 @@ private theorem num_div' (p : K[X]) {q : K[X]} (hq : q ≠ 0) : rw [num, numDenom_div _ hq] @[simp] -theorem num_zero : num (0 : K⟮X⟯) = 0 := by convert num_div' (0 : K[X]) one_ne_zero <;> simp +theorem num_zero : num (0 : K⟮X⟯) = 0 := by convert! num_div' (0 : K[X]) one_ne_zero <;> simp open scoped Classical in @[simp] @@ -911,10 +911,10 @@ theorem num_div (p q : K[X]) : · exact num_div' p hq @[simp] -theorem num_one : num (1 : K⟮X⟯) = 1 := by convert num_div (1 : K[X]) 1 <;> simp +theorem num_one : num (1 : K⟮X⟯) = 1 := by convert! num_div (1 : K[X]) 1 <;> simp @[simp] -theorem num_algebraMap (p : K[X]) : num (algebraMap _ _ p) = p := by convert num_div p 1 <;> simp +theorem num_algebraMap (p : K[X]) : num (algebraMap _ _ p) = p := by convert! num_div p 1 <;> simp theorem num_div_dvd (p : K[X]) {q : K[X]} (hq : q ≠ 0) : num (algebraMap _ _ p / algebraMap _ _ q) ∣ p := by @@ -953,15 +953,15 @@ theorem denom_ne_zero (x : K⟮X⟯) : denom x ≠ 0 := @[simp] theorem denom_zero : denom (0 : K⟮X⟯) = 1 := by - convert denom_div (0 : K[X]) one_ne_zero <;> simp + convert! denom_div (0 : K[X]) one_ne_zero <;> simp @[simp] theorem denom_one : denom (1 : K⟮X⟯) = 1 := by - convert denom_div (1 : K[X]) one_ne_zero <;> simp + convert! denom_div (1 : K[X]) one_ne_zero <;> simp @[simp] theorem denom_algebraMap (p : K[X]) : denom (algebraMap _ K⟮X⟯ p) = 1 := by - convert denom_div p one_ne_zero <;> simp + convert! denom_div p one_ne_zero <;> simp @[simp] theorem denom_div_dvd (p q : K[X]) : denom (algebraMap _ _ p / algebraMap _ _ q) ∣ q := by @@ -1085,12 +1085,12 @@ theorem denom_inv_dvd {x : K⟮X⟯} (hx : x ≠ 0) : denom x⁻¹ ∣ num x := theorem associated_num_inv {x : K⟮X⟯} (hx : x ≠ 0) : Associated (num x⁻¹) (denom x) := by apply associated_of_dvd_dvd (num_inv_dvd hx) - convert denom_inv_dvd (inv_ne_zero hx) + convert! denom_inv_dvd (inv_ne_zero hx) rw [inv_inv] theorem associated_denom_inv {x : K⟮X⟯} (hx : x ≠ 0) : Associated (denom x⁻¹) (num x) := by apply Associated.symm - convert associated_num_inv (inv_ne_zero hx) + convert! associated_num_inv (inv_ne_zero hx) rw [inv_inv] theorem map_denom_ne_zero {L F : Type*} [Zero L] [FunLike F K[X] L] [ZeroHomClass F K[X] L] diff --git a/Mathlib/FieldTheory/RatFunc/IntermediateField.lean b/Mathlib/FieldTheory/RatFunc/IntermediateField.lean index 1794002093a788..c91f95b5d33eab 100644 --- a/Mathlib/FieldTheory/RatFunc/IntermediateField.lean +++ b/Mathlib/FieldTheory/RatFunc/IntermediateField.lean @@ -141,8 +141,9 @@ theorem irreducible_minpolyX' (hf : ¬∃ c, f = C c) : Irreducible (f.minpolyX rw [mul_comm] rfl rw [this, MulEquiv.irreducible_iff] - convert irreducible_C_mul_X_add_C (neg_ne_zero.mpr f.denom_ne_zero) - ((IsCoprime.neg_right_iff _ _).mpr f.isCoprime_num_denom).symm.isRelPrime using 1 + convert! + irreducible_C_mul_X_add_C (neg_ne_zero.mpr f.denom_ne_zero) + ((IsCoprime.neg_right_iff _ _).mpr f.isCoprime_num_denom).symm.isRelPrime using 1 rw [add_comm, X_mul_C, map_neg, neg_mul] exact sub_eq_add_neg (Polynomial.C f.num) (Polynomial.C f.denom * Polynomial.X) diff --git a/Mathlib/FieldTheory/RatFunc/Luroth.lean b/Mathlib/FieldTheory/RatFunc/Luroth.lean index 50ecde4d76b852..90ef21134cda3e 100644 --- a/Mathlib/FieldTheory/RatFunc/Luroth.lean +++ b/Mathlib/FieldTheory/RatFunc/Luroth.lean @@ -329,7 +329,7 @@ lemma swap_θ : Bivariate.swap (θ E) = -(θ E) := by ring lemma θ_natDegree_le (h : E ≠ ⊥) : (θ E).natDegree ≤ m E := by - convert natDegree_sub_le _ _ using 3 + convert! natDegree_sub_le _ _ using 3 · rw [natDegree_mul (C_ne_zero.mpr (generator E).denom_ne_zero) (Polynomial.map_ne_zero (num_ne_zero (generator_ne_zero h))), natDegree_C, zero_add, natDegree_map] diff --git a/Mathlib/FieldTheory/Separable.lean b/Mathlib/FieldTheory/Separable.lean index 3acfdbdf55267b..3bdc564024be5b 100644 --- a/Mathlib/FieldTheory/Separable.lean +++ b/Mathlib/FieldTheory/Separable.lean @@ -161,7 +161,7 @@ theorem isUnit_of_self_mul_dvd_separable {p q : R[X]} (hp : p.Separable) (hq : q (q * (derivative q * p + derivative q * p + q * derivative p)) := by simp only [← mul_assoc, mul_add] dsimp only [Separable] at hp - convert hp using 1 + convert! hp using 1 rw [derivative_mul, derivative_mul] ring exact IsCoprime.of_mul_right_left (IsCoprime.of_mul_left_left this) diff --git a/Mathlib/FieldTheory/SeparableClosure.lean b/Mathlib/FieldTheory/SeparableClosure.lean index 6f019bf2a03a7d..abf1b13e81d948 100644 --- a/Mathlib/FieldTheory/SeparableClosure.lean +++ b/Mathlib/FieldTheory/SeparableClosure.lean @@ -395,7 +395,7 @@ lemma exists_finset_maximalFor_isTranscendenceBasis_separableClosure have : Module.Finite (adjoin F (s : Set E)) E := by apply +allowSynthFailures Algebra.finite_of_essFiniteType_of_isAlgebraic · exact .of_comp F _ _ - · convert hs.isAlgebraic_field <;> simp [s] + · convert! hs.isAlgebraic_field <;> simp [s] have : Module.Finite ((separableClosure (adjoin F (s : Set E)) E).restrictScalars F) E := inferInstanceAs <| Module.Finite (separableClosure (adjoin F (s : Set E)) E) E exact d.not_lt_argminOn _ ht (by apply finrank_lt_of_gt H) diff --git a/Mathlib/FieldTheory/SeparablyGenerated.lean b/Mathlib/FieldTheory/SeparablyGenerated.lean index 7709e744bdd61f..5cc5321ca4cdb9 100644 --- a/Mathlib/FieldTheory/SeparablyGenerated.lean +++ b/Mathlib/FieldTheory/SeparablyGenerated.lean @@ -70,9 +70,10 @@ theorem irreducible_toPolynomialAdjoinImageCompl {F : MvPolynomial ι k} (hF : I Irreducible (toPolynomialAdjoinImageCompl F a i) := by have : a '' {i}ᶜ = Set.range (fun x : {j | j ≠ i} ↦ a x) := by ext; simp delta toPolynomialAdjoinImageCompl - convert hF.map (renameEquiv k (Equiv.optionSubtypeNe i).symm) |>.map (optionEquivLeft k _) |>.map - (Polynomial.mapAlgEquiv (H.aevalEquiv.trans - (Subalgebra.equivOfEq _ _ congr(Algebra.adjoin k $this.symm)))) + convert! + hF.map (renameEquiv k (Equiv.optionSubtypeNe i).symm) |>.map (optionEquivLeft k _) |>.map + (Polynomial.mapAlgEquiv + (H.aevalEquiv.trans (Subalgebra.equivOfEq _ _ congr(Algebra.adjoin k $this.symm)))) rw [← AlgEquiv.coe_algHom] congr aesop @@ -208,7 +209,7 @@ lemma exists_isTranscendenceBasis_and_isSeparable_of_linearIndepOn_pow intro h refine h.transcendental_adjoin (i := n) (s := {n}ᶜ) (by simp) ?_ have : a '' {n}ᶜ = Set.range (ι := {i // i ≠ n}) (a ·) := by aesop - convert ha'.isAlgebraic.isAlgebraic _ + convert! ha'.isAlgebraic.isAlgebraic _ have hFirr : Irreducible F := irreducible_of_forall_totalDegree_le hFmin hF₀ hFa obtain ⟨i, σ, hσ, hi⟩ := exists_mem_support_not_dvd_of_forall_totalDegree_le p hp H hFmin hF₀ hFa have hσi : σ i ≠ 0 := by aesop @@ -247,7 +248,7 @@ lemma exists_isTranscendenceBasis_and_isSeparable_of_linearIndepOn_pow' let e₂ : {j // j ≠ i} ≃ ↥(insert n s \ {i.1}) := ⟨fun x ↦ ⟨x, x.1.2, fun h ↦ x.2 (Subtype.ext h)⟩, fun x ↦ ⟨⟨x, x.2.1⟩, fun h ↦ x.2.2 congr($h.1)⟩, fun _ ↦ rfl, fun _ ↦ rfl⟩ have : a '' (insert n s \ {i.1}) = (a ·.1) '' {i}ᶜ := by ext; aesop - refine ⟨i, hi.comp_equiv e₂.symm, by convert hi'⟩ + refine ⟨i, hi.comp_equiv e₂.symm, by convert! hi'⟩ /-- Suppose `k` has characteristic `p` and `K/k` is generated by `a₁,...,aₙ₊₁`, @@ -316,7 +317,7 @@ lemma exists_isTranscendenceBasis_and_isSeparable_of_perfectField obtain ⟨t, hts, ht⟩ := exists_isTranscendenceBasis_subset (R := k) (s : Set K) lift t to Finset K using s.finite_toSet.subset hts have : Algebra.IsAlgebraic (IntermediateField.adjoin k (t : Set K)) K := by - convert ht.isAlgebraic_field <;> simp + convert! ht.isAlgebraic_field <;> simp exact ⟨t, ht, inferInstance⟩ have : ExpChar k p := .prime hp.out have : CharP K p := .of_ringHom_of_ne_zero (algebraMap k K) p hp.out.ne_zero diff --git a/Mathlib/Geometry/Convex/Cone/Basic.lean b/Mathlib/Geometry/Convex/Cone/Basic.lean index be11e7599090af..95befafbc1df0f 100644 --- a/Mathlib/Geometry/Convex/Cone/Basic.lean +++ b/Mathlib/Geometry/Convex/Cone/Basic.lean @@ -740,7 +740,7 @@ set_option linter.deprecated false in @[deprecated "no replacement" (since := "2026-03-30")] theorem convexHull_toCone_isLeast (s : Set M) : IsLeast { t : ConvexCone 𝕜 M | s ⊆ t } ((convex_convexHull 𝕜 s).toCone _) := by - convert (convex_convexHull 𝕜 s).toCone_isLeast using 1 + convert! (convex_convexHull 𝕜 s).toCone_isLeast using 1 ext t exact ⟨fun h => convexHull_min h t.convex, (subset_convexHull 𝕜 s).trans⟩ diff --git a/Mathlib/Geometry/Convex/Cone/Pointed.lean b/Mathlib/Geometry/Convex/Cone/Pointed.lean index eb5f9d417e8bde..20cf10a6fe2f59 100644 --- a/Mathlib/Geometry/Convex/Cone/Pointed.lean +++ b/Mathlib/Geometry/Convex/Cone/Pointed.lean @@ -35,7 +35,7 @@ abbrev PointedCone (R E) namespace PointedCone -open Function Submodule +open Function Submodule Pointwise open scoped Pointwise @@ -51,11 +51,18 @@ instance : Coe (Submodule R E) (PointedCone R E) := ⟨ofSubmodule⟩ @[simp] lemma coe_ofSubmodule (S : Submodule R E) : (ofSubmodule S : Set E) = S := rfl -lemma mem_ofSubmodule_iff {S : Submodule R E} {x : E} : x ∈ (S : PointedCone R E) ↔ x ∈ S := by rfl +lemma mem_ofSubmodule_iff {S : Submodule R E} {x : E} : x ∈ (S : PointedCone R E) ↔ x ∈ S := .rfl lemma ofSubmodule_inj {S T : Submodule R E} : ofSubmodule S = ofSubmodule T ↔ S = T := restrictScalars_inj .. +lemma ofSubmodule_le_ofSubmodule {S T : Submodule R E} : ofSubmodule S ≤ ofSubmodule T ↔ S ≤ T := + .rfl + +lemma ofSubmodule_lt_ofSubmodule {S T : Submodule R E} : ofSubmodule S < ofSubmodule T ↔ S < T := + .rfl + +set_option backward.isDefEq.respectTransparency false in /-- Coercion from submodules to pointed cones as an order embedding. -/ abbrev ofSubmoduleEmbedding : Submodule R E ↪o PointedCone R E := restrictScalarsEmbedding .. @@ -85,7 +92,8 @@ lemma ofSubmodule_iSup (s : Set (Submodule R E)) : ⨆ S ∈ s, S = ⨆ S ∈ s, variable {R E : Type*} variable [Semiring R] [PartialOrder R] [IsOrderedRing R] [AddCommGroup E] [Module R E] -lemma neg_ofSubmodule (S : Submodule R E) : -(ofSubmodule S) = ofSubmodule (-S) := +set_option backward.isDefEq.respectTransparency false in +lemma neg_ofSubmodule (S : Submodule R E) : -(ofSubmodule S) = ofSubmodule (-S) := neg_restrictScalars S end Submodule @@ -131,10 +139,10 @@ def _root_.ConvexCone.toPointedCone (C : ConvexCone R E) (hC : C.Pointed) : Poin simp_rw [SetLike.mem_coe] rcases eq_or_lt_of_le hc with hzero | hpos · unfold ConvexCone.Pointed at hC - convert hC + convert! hC simp [← hzero] · apply ConvexCone.smul_mem - · convert hpos + · convert! hpos · exact hx @[simp] @@ -180,6 +188,10 @@ lemma subset_hull {s : Set E} : s ⊆ PointedCone.hull R s := subset_span @[deprecated "`PointedCone.span` was renamed to `PointedCone.hull`" (since := "2026-03-22")] alias subset_span := subset_hull +set_option backward.isDefEq.respectTransparency false in +variable (R) in +lemma hull_le_span (s : Set E) : hull R s ≤ span R s := span_le_restrictScalars R≥0 R s + /-- Elements of the cone hull are expressible as conical combination of elements from s. -/ lemma mem_hull_set {s : Set E} : x ∈ hull R s ↔ ∃ c : E →₀ R, ↑c.support ⊆ s ∧ (∀ y, 0 ≤ c y) ∧ c.sum (fun m r => r • m) = x := by @@ -321,17 +333,12 @@ def lineal (C : PointedCone R E) : Submodule R E where · simpa using And.intro (C.smul_mem hr hx.1) (C.smul_mem hr hx.2) · have hr := le_of_lt <| neg_pos_of_neg <| lt_of_not_ge hr simpa using And.intro (C.smul_mem hr hx.2) (C.smul_mem hr hx.1) -@[simp] -lemma ofSubmodule_lineal (C : PointedCone R E) : C.lineal = C ⊓ -C := - rfl -@[simp] -lemma mem_lineal {C : PointedCone R E} {x : E} : x ∈ C.lineal ↔ x ∈ C ∧ -x ∈ C := by - rfl +@[simp] lemma ofSubmodule_lineal (C : PointedCone R E) : C.lineal = C ⊓ -C := rfl -@[simp] -theorem support_eq {C : PointedCone R E} : C.support = C.lineal.toAddSubgroup := - rfl +@[simp] lemma mem_lineal {C : PointedCone R E} {x : E} : x ∈ C.lineal ↔ x ∈ C ∧ -x ∈ C := .rfl + +@[simp] theorem support_eq (C : PointedCone R E) : C.support = C.lineal.toAddSubgroup := rfl /-- The lineality space of a cone is the largest submodule contained in the cone. -/ theorem gc_ofSubmodule_lineal : @@ -346,6 +353,7 @@ theorem lineal_eq_sSup (C : PointedCone R E) : C.lineal = sSup {S : Submodule R end Lineal section Salient + variable [Semiring R] [PartialOrder R] [IsOrderedRing R] [AddCommGroup E] [Module R E] /-- A pointed cone is salient iff the intersection of the cone with its negative diff --git a/Mathlib/Geometry/Convex/Cone/TensorProduct.lean b/Mathlib/Geometry/Convex/Cone/TensorProduct.lean index 10aa65f02ed262..aa0498ba0f14f7 100644 --- a/Mathlib/Geometry/Convex/Cone/TensorProduct.lean +++ b/Mathlib/Geometry/Convex/Cone/TensorProduct.lean @@ -161,7 +161,7 @@ theorem maxTensorProduct_map_le (f : G →ₗ[R] G') (g : H →ₗ[R] H') have h_eq : ((dualDistrib R G' H') (φ ⊗ₜ[R] ψ)).comp (TensorProduct.map f g) = ((dualDistrib R G H) ((φ.comp f) ⊗ₜ[R] (ψ.comp g))) := TensorProduct.ext' fun x y ↦ by simp [map_tmul] - convert hw (φ.comp f) (fun x hx ↦ hφ ⟨x, hx, rfl⟩) (ψ.comp g) (fun y hy ↦ hψ ⟨y, hy, rfl⟩) + convert! hw (φ.comp f) (fun x hx ↦ hφ ⟨x, hx, rfl⟩) (ψ.comp g) (fun y hy ↦ hψ ⟨y, hy, rfl⟩) exact DFunLike.congr_fun h_eq w end PointedCone diff --git a/Mathlib/Geometry/Diffeology/Basic.lean b/Mathlib/Geometry/Diffeology/Basic.lean index 38ad8f49f06693..8262d574912185 100644 --- a/Mathlib/Geometry/Diffeology/Basic.lean +++ b/Mathlib/Geometry/Diffeology/Basic.lean @@ -336,7 +336,7 @@ def ofCorePlotsOn {X : Type*} (d : DiffeologicalSpace.CorePlotsOn X) : refine ⟨_, Metric.isOpen_ball, Metric.mem_ball_self hε, (d.isPlotOn_congr _ ?_).mp h'⟩ rw [Function.comp_assoc, ← OpenPartialHomeomorph.coe_trans] apply Set.EqOn.comp_left - convert (OpenPartialHomeomorph.symm_trans_self (OpenPartialHomeomorph.univBall x ε)).2 + convert! (OpenPartialHomeomorph.symm_trans_self (OpenPartialHomeomorph.univBall x ε)).2 simp [OpenPartialHomeomorph.univBall_target x hε] dTopology := d.dTopology isOpen_iff_preimages_plots := d.isOpen_iff_preimages_plots @@ -356,7 +356,7 @@ protected theorem DSmooth.continuous' {X Y : Type*} [TopologicalSpace X] [DiffeologicalSpace X] [IsDTopologyCompatible X] [TopologicalSpace Y] [DiffeologicalSpace Y] [IsDTopologyCompatible Y] {f : X → Y} (hf : DSmooth f) : Continuous f := by - convert hf.continuous + convert! hf.continuous · rw [IsDTopologyCompatible.dTop_eq X] · rw [IsDTopologyCompatible.dTop_eq Y] diff --git a/Mathlib/Geometry/Euclidean/Altitude.lean b/Mathlib/Geometry/Euclidean/Altitude.lean index 16665c397fb66d..bf6cf086d411e9 100644 --- a/Mathlib/Geometry/Euclidean/Altitude.lean +++ b/Mathlib/Geometry/Euclidean/Altitude.lean @@ -100,7 +100,7 @@ lemma altitude_map {n : ℕ} (s : Simplex ℝ P n) (f : P →ᵃⁱ[ℝ] P₂) ( haveI := Nonempty.map (AffineSubspace.inclusion hS) inferInstance ((s.restrict S hS).altitude i).map S.subtype = s.altitude i := by rw [eq_comm] - convert (s.restrict S hS).altitude_map S.subtypeₐᵢ i + convert! (s.restrict S hS).altitude_map S.subtypeₐᵢ i lemma altitude_restrict_eq_comap_subtype {n : ℕ} (s : Simplex ℝ P n) (S : AffineSubspace ℝ P) (hS : affineSpan ℝ (Set.range s.points) ≤ S) (i : Fin (n + 1)) : @@ -191,7 +191,7 @@ set_option backward.isDefEq.respectTransparency false in haveI := Nonempty.map (AffineSubspace.inclusion hS) inferInstance (s.restrict S hS).altitudeFoot i = s.altitudeFoot i := by rw [eq_comm] - convert (s.restrict S hS).altitudeFoot_map S.subtypeₐᵢ i + convert! (s.restrict S hS).altitudeFoot_map S.subtypeₐᵢ i @[simp] lemma ne_altitudeFoot {n : ℕ} [NeZero n] (s : Simplex ℝ P n) (i : Fin (n + 1)) : s.points i ≠ s.altitudeFoot i := by @@ -251,7 +251,7 @@ def height {n : ℕ} [NeZero n] (s : Simplex ℝ P n) (i : Fin (n + 1)) : ℝ := haveI := Nonempty.map (AffineSubspace.inclusion hS) inferInstance (s.restrict S hS).height i = s.height i := by rw [eq_comm] - convert (s.restrict S hS).height_map S.subtypeₐᵢ i + convert! (s.restrict S hS).height_map S.subtypeₐᵢ i @[simp] lemma height_pos {n : ℕ} [NeZero n] (s : Simplex ℝ P n) (i : Fin (n + 1)) : 0 < s.height i := by @@ -315,7 +315,7 @@ lemma abs_inner_vsub_altitudeFoot_lt_mul {i j : Fin (n + 1)} (hij : i ≠ j) : |⟪s.points i -ᵥ s.altitudeFoot i, s.points j -ᵥ s.altitudeFoot j⟫| < s.height i * s.height j := by apply lt_of_le_of_ne - · convert abs_real_inner_le_norm _ _ using 1 + · convert! abs_real_inner_le_norm _ _ using 1 simp only [dist_eq_norm_vsub, height] · simp_rw [height, dist_eq_norm_vsub] rw [← Real.norm_eq_abs, ne_eq, norm_inner_eq_norm_iff (by simp) (by simp)] @@ -348,7 +348,7 @@ lemma abs_inner_vsub_altitudeFoot_lt_mul {i j : Fin (n + 1)} (hij : i ≠ j) : simp_rw [← Set.image_univ, ← Set.compl_inter] rw [Set.inter_singleton_eq_empty.mpr ?_, Set.compl_empty] simpa using hij.symm - convert AffineSubspace.vectorSpan_union_of_mem_of_mem ℝ hki' hkj' + convert! AffineSubspace.vectorSpan_union_of_mem_of_mem ℝ hki' hkj' rw [hs, ← Submodule.inf_orthogonal, Submodule.mem_inf] refine ⟨?_, ?_⟩ · rw [h, ← direction_affineSpan] diff --git a/Mathlib/Geometry/Euclidean/Angle/Bisector.lean b/Mathlib/Geometry/Euclidean/Angle/Bisector.lean index 4e6d0a12b779df..a560ad1adffb1b 100644 --- a/Mathlib/Geometry/Euclidean/Angle/Bisector.lean +++ b/Mathlib/Geometry/Euclidean/Angle/Bisector.lean @@ -293,14 +293,14 @@ lemma two_zsmul_oangle_eq_of_dist_orthogonalProjection_line_eq {p p₁ p₂ p₃ · suffices p = p₁ by simp [this] have hs := orthogonalProjection_sup_of_orthogonalProjection_eq ho have hinf : line[ℝ, p₁, p₂] ⊓ line[ℝ, p₁, p₃] = affineSpan ℝ {p₁} := by - convert (ha.inf_affineSpan_eq_affineSpan_inter {0, 1} {0, 2}) + convert! (ha.inf_affineSpan_eq_affineSpan_inter {0, 1} {0, 2}) · simp [Set.image_insert_eq] · simp [Set.image_insert_eq] · suffices {p₁} = ![p₁, p₂, p₃] '' {0} by grind simp have hsup : line[ℝ, p₁, p₂] ⊔ line[ℝ, p₁, p₃] = ⊤ := by rw [← AffineSubspace.span_union] - convert ha.affineSpan_eq_top_iff_card_eq_finrank_add_one.2 ?_ + convert! ha.affineSpan_eq_top_iff_card_eq_finrank_add_one.2 ?_ · simp grind · simpa using Fact.out diff --git a/Mathlib/Geometry/Euclidean/Angle/Incenter.lean b/Mathlib/Geometry/Euclidean/Angle/Incenter.lean index e140e7869e6d33..b33f20eab32a56 100644 --- a/Mathlib/Geometry/Euclidean/Angle/Incenter.lean +++ b/Mathlib/Geometry/Euclidean/Angle/Incenter.lean @@ -90,9 +90,11 @@ lemma dist_orthogonalProjectionSpan_faceOpposite_eq_iff_two_zsmul_oangle_eq {p : dist p ((t.faceOpposite i₂).orthogonalProjectionSpan p) ↔ (2 : ℤ) • ∡ (t.points i₂) (t.points i₁) p = (2 : ℤ) • ∡ p (t.points i₁) (t.points i₃) := by have ha : AffineIndependent ℝ ![t.points i₁, t.points i₂, t.points i₃] := by - convert t.independent.comp_embedding ⟨![i₁, i₂, i₃], by - intro i j hij - fin_cases i <;> fin_cases j <;> simp_all⟩ + convert! + t.independent.comp_embedding + ⟨![i₁, i₂, i₃], by + intro i j hij + fin_cases i <;> fin_cases j <;> simp_all⟩ ext i fin_cases i <;> rfl rw [orthogonalProjectionSpan, orthogonalProjectionSpan, @@ -164,7 +166,7 @@ lemma eq_excenter_of_two_zsmul_oangle_eq {p : P} rw [← dist_orthogonalProjectionSpan_faceOpposite_eq_iff_two_zsmul_oangle_eq h₂₃ h₁₂.symm h₁₃.symm] at h₂ have hp : p ∈ affineSpan ℝ (Set.range t.points) := by - convert AffineSubspace.mem_top ℝ V p + convert! AffineSubspace.mem_top ℝ V p rw [t.independent.affineSpan_eq_top_iff_card_eq_finrank_add_one] simp [hd2.out] have hr : ∃ r : ℝ, ∀ i, dist p ((t.faceOpposite i).orthogonalProjectionSpan p) = r := by diff --git a/Mathlib/Geometry/Euclidean/Angle/Oriented/Affine.lean b/Mathlib/Geometry/Euclidean/Angle/Oriented/Affine.lean index c4fbdcceea09e5..6e11b9084bc6e6 100644 --- a/Mathlib/Geometry/Euclidean/Angle/Oriented/Affine.lean +++ b/Mathlib/Geometry/Euclidean/Angle/Oriented/Affine.lean @@ -197,7 +197,7 @@ theorem oangle_ne_zero_and_ne_pi_iff_affineIndependent {p₁ p₂ p₃ : P} : rw [oangle, o.oangle_ne_zero_and_ne_pi_iff_linearIndependent, affineIndependent_iff_linearIndependent_vsub ℝ _ (1 : Fin 3), ← linearIndependent_equiv (finSuccAboveEquiv (1 : Fin 3))] - convert Iff.rfl + convert! Iff.rfl ext i fin_cases i <;> rfl @@ -317,7 +317,7 @@ theorem oangle_eq_pi_sub_two_zsmul_oangle_of_dist_eq {p₁ p₂ p₃ : P} (hn : (h : dist p₁ p₂ = dist p₁ p₃) : ∡ p₃ p₁ p₂ = π - (2 : ℤ) • ∡ p₁ p₂ p₃ := by simp_rw [dist_eq_norm_vsub V] at h rw [oangle, oangle] - convert o.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq _ h using 1 + convert! o.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq _ h using 1 · rw [← neg_vsub_eq_vsub_rev p₁ p₃, ← neg_vsub_eq_vsub_rev p₁ p₂, o.oangle_neg_neg] · rw [← o.oangle_sub_eq_oangle_sub_rev_of_norm_eq h]; simp · simpa using hn @@ -356,7 +356,7 @@ theorem angle_eq_abs_oangle_toReal {p p₁ p₂ : P} (hp₁ : p₁ ≠ p) (hp₂ equals `p` or the unoriented angle is 0 or π. -/ theorem eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero {p p₁ p₂ : P} (h : (∡ p₁ p p₂).sign = 0) : p₁ = p ∨ p₂ = p ∨ ∠ p₁ p p₂ = 0 ∨ ∠ p₁ p p₂ = π := by - convert o.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero h <;> simp + convert! o.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero h <;> simp /-- If two unoriented angles are equal, and the signs of the corresponding oriented angles are equal, then the oriented angles are equal (even in degenerate cases). -/ @@ -748,7 +748,7 @@ theorem _root_.Collinear.oangle_sign_of_sameRay_vsub {p₁ p₂ p₃ p₄ : P} ( (Set.mem_insert_of_mem _ (Set.mem_insert_of_mem _ (Set.mem_insert _ _))) hp₁p₂⟩, p₄ -ᵥ p₃⟩, ⟨hr, vsub_ne_zero.2 hp₃p₄.symm⟩, ?_⟩ simp - convert Real.Angle.sign_eq_of_continuousOn hco hf hsp hp₃p₄s hp₁p₂s + convert! Real.Angle.sign_eq_of_continuousOn hco hf hsp hp₃p₄s hp₁p₂s /-- Given three points in strict order on the same line, and a fourth point, the angles at the fourth point between the first and second or second and third points have the same sign. -/ @@ -831,7 +831,7 @@ theorem _root_.AffineSubspace.SSameSide.oangle_sign_eq {s : AffineSubspace ℝ P have hp₃ : (p₁, p₃, p₂) ∈ sp := Set.mem_image_of_mem _ (sSameSide_self_iff.2 ⟨hp₃p₄.nonempty, hp₃p₄.2.1⟩) have hp₄ : (p₁, p₄, p₂) ∈ sp := Set.mem_image_of_mem _ hp₃p₄ - convert Real.Angle.sign_eq_of_continuousOn hc hf hsp hp₃ hp₄ + convert! Real.Angle.sign_eq_of_continuousOn hc hf hsp hp₃ hp₄ /-- Given two points in an affine subspace, the angles between those two points at two other points on opposite sides of that subspace have opposite signs. -/ diff --git a/Mathlib/Geometry/Euclidean/Angle/Oriented/Basic.lean b/Mathlib/Geometry/Euclidean/Angle/Oriented/Basic.lean index 8c58133a6f2806..f68acfd1fd5b5b 100644 --- a/Mathlib/Geometry/Euclidean/Angle/Oriented/Basic.lean +++ b/Mathlib/Geometry/Euclidean/Angle/Oriented/Basic.lean @@ -77,7 +77,7 @@ set_option backward.isDefEq.respectTransparency false in @[simp] theorem oangle_self (x : V) : o.oangle x x = 0 := by rw [oangle, kahler_apply_self, ← ofReal_pow] - convert QuotientAddGroup.mk_zero (AddSubgroup.zmultiples (2 * π)) + convert! QuotientAddGroup.mk_zero (AddSubgroup.zmultiples (2 * π)) apply arg_ofReal_of_nonneg positivity @@ -180,14 +180,14 @@ theorem oangle_add_oangle_rev (x y : V) : o.oangle x y + o.oangle y x = 0 := by theorem oangle_neg_left {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle (-x) y = o.oangle x y + π := by simp only [oangle, map_neg] - convert Complex.arg_neg_coe_angle _ + convert! Complex.arg_neg_coe_angle _ exact o.kahler_ne_zero hx hy /-- Negating the second vector passed to `oangle` adds `π` to the angle. -/ theorem oangle_neg_right {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle x (-y) = o.oangle x y + π := by simp only [oangle, map_neg] - convert Complex.arg_neg_coe_angle _ + convert! Complex.arg_neg_coe_angle _ exact o.kahler_ne_zero hx hy /-- Negating the first vector passed to `oangle` does not change twice the angle. -/ @@ -509,7 +509,7 @@ theorem oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq {x y : V} (hn : x ≠ y rw [norm_zero, norm_eq_zero] at h exact hn h have hx : x ≠ 0 := norm_ne_zero_iff.1 (h.symm ▸ norm_ne_zero_iff.2 hy) - convert o.oangle_add_cyc3_neg_right (neg_ne_zero.2 hy) hx (sub_ne_zero_of_ne hn.symm) using 1 + convert! o.oangle_add_cyc3_neg_right (neg_ne_zero.2 hy) hx (sub_ne_zero_of_ne hn.symm) using 1 simp /-- The angle between two vectors, with respect to an orientation given by `Orientation.map` @@ -715,7 +715,7 @@ theorem eq_zero_or_oangle_eq_iff_inner_eq_zero {x y : V} : rw [InnerProductGeometry.inner_eq_zero_iff_angle_eq_pi_div_two, or_iff_right hx, or_iff_right hy] refine ⟨fun h => ?_, fun h => ?_⟩ · rwa [o.angle_eq_abs_oangle_toReal hx hy, Real.Angle.abs_toReal_eq_pi_div_two_iff] - · convert o.oangle_eq_angle_or_eq_neg_angle hx hy using 2 <;> rw [h] + · convert! o.oangle_eq_angle_or_eq_neg_angle hx hy using 2 <;> rw [h] simp only [neg_div, Real.Angle.coe_neg] /-- If the oriented angle between two vectors is `π / 2`, the inner product of those vectors @@ -821,10 +821,10 @@ theorem oangle_sign_smul_add_right (x y : V) (r : ℝ) : · simpa [hz] using (h' r').1 have hs : ∀ z : V × V, z ∈ s → o.oangle z.1 z.2 ≠ 0 ∧ o.oangle z.1 z.2 ≠ π := by grind have hx : (x, y) ∈ s := by - convert Set.mem_image_of_mem (fun r' : ℝ => (x, r' • x + y)) (Set.mem_univ 0) + convert! Set.mem_image_of_mem (fun r' : ℝ => (x, r' • x + y)) (Set.mem_univ 0) simp have hy : (x, r • x + y) ∈ s := Set.mem_image_of_mem _ (Set.mem_univ _) - convert Real.Angle.sign_eq_of_continuousOn hc hf hs hx hy + convert! Real.Angle.sign_eq_of_continuousOn hc hf hs hx hy /-- Adding a multiple of the second vector passed to `oangle` to the first vector does not change the sign of the angle. -/ diff --git a/Mathlib/Geometry/Euclidean/Angle/Oriented/Rotation.lean b/Mathlib/Geometry/Euclidean/Angle/Oriented/Rotation.lean index 0def62e379b6aa..7e56474c341b6e 100644 --- a/Mathlib/Geometry/Euclidean/Angle/Oriented/Rotation.lean +++ b/Mathlib/Geometry/Euclidean/Angle/Oriented/Rotation.lean @@ -65,7 +65,7 @@ def rotation (θ : Real.Angle) : V ≃ₗᵢ[ℝ] V := Real.Angle.sin θ • (LinearIsometryEquiv.toLinearEquiv J).toLinearMap) (by ext x - convert congr_arg (fun t : ℝ => t • x) θ.cos_sq_add_sin_sq using 1 + convert! congr_arg (fun t : ℝ => t • x) θ.cos_sq_add_sin_sq using 1 · simp only [o.rightAngleRotation_rightAngleRotation, o.rotationAux_apply, Function.comp_apply, id, LinearEquiv.coe_coe, LinearIsometry.coe_toLinearMap, LinearIsometryEquiv.coe_toLinearEquiv, map_smul, map_sub, LinearMap.coe_comp, @@ -74,7 +74,7 @@ def rotation (θ : Real.Angle) : V ≃ₗᵢ[ℝ] V := · simp) (by ext x - convert congr_arg (fun t : ℝ => t • x) θ.cos_sq_add_sin_sq using 1 + convert! congr_arg (fun t : ℝ => t • x) θ.cos_sq_add_sin_sq using 1 · simp only [o.rightAngleRotation_rightAngleRotation, o.rotationAux_apply, Function.comp_apply, id, LinearEquiv.coe_coe, LinearIsometry.coe_toLinearMap, LinearIsometryEquiv.coe_toLinearEquiv, map_add, map_smul, LinearMap.coe_comp, diff --git a/Mathlib/Geometry/Euclidean/Angle/Sphere.lean b/Mathlib/Geometry/Euclidean/Angle/Sphere.lean index 34ba17744df3da..eb8f55b8d8c157 100644 --- a/Mathlib/Geometry/Euclidean/Angle/Sphere.lean +++ b/Mathlib/Geometry/Euclidean/Angle/Sphere.lean @@ -263,8 +263,8 @@ theorem inv_tan_div_two_smul_rotation_pi_div_two_vadd_midpoint_eq_center {s : Sp (hp₂p₃ : p₂ ≠ p₃) : ((Real.Angle.tan (∡ p₁ p₂ p₃))⁻¹ / 2) • o.rotation (π / 2 : ℝ) (p₃ -ᵥ p₁) +ᵥ midpoint ℝ p₁ p₃ = s.center := by - convert tan_div_two_smul_rotation_pi_div_two_vadd_midpoint_eq_center hp₁ hp₃ hp₁p₃ - convert (Real.Angle.tan_eq_inv_of_two_zsmul_add_two_zsmul_eq_pi _).symm + convert! tan_div_two_smul_rotation_pi_div_two_vadd_midpoint_eq_center hp₁ hp₃ hp₁p₃ + convert! (Real.Angle.tan_eq_inv_of_two_zsmul_add_two_zsmul_eq_pi _).symm rw [add_comm, two_zsmul_oangle_center_add_two_zsmul_oangle_eq_pi hp₁ hp₂ hp₃ hp₁p₂.symm hp₂p₃ hp₁p₃] @@ -307,7 +307,7 @@ at the third point (a version of the law of sines or sine rule). -/ theorem dist_div_sin_oangle_div_two_eq_radius {s : Sphere P} {p₁ p₂ p₃ : P} (hp₁ : p₁ ∈ s) (hp₂ : p₂ ∈ s) (hp₃ : p₃ ∈ s) (hp₁p₂ : p₁ ≠ p₂) (hp₁p₃ : p₁ ≠ p₃) (hp₂p₃ : p₂ ≠ p₃) : dist p₁ p₃ / |Real.Angle.sin (∡ p₁ p₂ p₃)| / 2 = s.radius := by - convert dist_div_cos_oangle_center_div_two_eq_radius hp₁ hp₃ hp₁p₃ + convert! dist_div_cos_oangle_center_div_two_eq_radius hp₁ hp₃ hp₁p₃ rw [← Real.Angle.abs_cos_eq_abs_sin_of_two_zsmul_add_two_zsmul_eq_pi (two_zsmul_oangle_center_add_two_zsmul_oangle_eq_pi hp₁ hp₂ hp₃ hp₁p₂.symm hp₂p₃ hp₁p₃), abs_of_nonneg (Real.Angle.cos_nonneg_iff_abs_toReal_le_pi_div_two.2 _)] @@ -438,7 +438,7 @@ theorem dist_div_sin_angle_div_two_eq_circumradius (t : Triangle ℝ P) {i₁ i simp⟩ have : Module.Oriented ℝ S.direction (Fin 2) := ⟨Basis.orientation (finBasisOfFinrankEq _ _ hf2.out)⟩ - convert t'.dist_div_sin_oangle_div_two_eq_circumradius h₁₂ h₁₃ h₂₃ using 3 + convert! t'.dist_div_sin_oangle_div_two_eq_circumradius h₁₂ h₁₃ h₂₃ using 3 · rw [← Real.Angle.sin_toReal, Real.abs_sin_eq_sin_abs_of_abs_le_pi (Real.Angle.abs_toReal_le_pi _), ← angle_eq_abs_oangle_toReal (t'.independent.injective.ne h₁₂) diff --git a/Mathlib/Geometry/Euclidean/Angle/Unoriented/Affine.lean b/Mathlib/Geometry/Euclidean/Angle/Unoriented/Affine.lean index 7e688026e00a92..45bf2de5808eef 100644 --- a/Mathlib/Geometry/Euclidean/Angle/Unoriented/Affine.lean +++ b/Mathlib/Geometry/Euclidean/Angle/Unoriented/Affine.lean @@ -167,7 +167,7 @@ theorem angle_eq_angle_of_angle_eq_pi (p₁ : P) {p₂ p₃ p₄ : P} (h : ∠ p unfold angle at * rcases angle_eq_pi_iff.1 h with ⟨_, ⟨r, ⟨hr, hpr⟩⟩⟩ rw [eq_comm] - convert angle_smul_right_of_pos (p₁ -ᵥ p₂) (p₃ -ᵥ p₂) (add_pos (neg_pos_of_neg hr) zero_lt_one) + convert! angle_smul_right_of_pos (p₁ -ᵥ p₂) (p₃ -ᵥ p₂) (add_pos (neg_pos_of_neg hr) zero_lt_one) rw [add_smul, ← neg_vsub_eq_vsub_rev p₂ p₃, smul_neg, neg_smul, ← hpr] simp @@ -288,7 +288,7 @@ theorem angle_eq_pi_iff_sbtw {p₁ p₂ p₃ : P} : ∠ p₁ p₂ p₃ = π ↔ · rw [← eq_vadd_iff_vsub_eq] at hp₃p₂ rw [AffineMap.lineMap_apply, hp₃p₂, vadd_vsub_assoc, ← neg_vsub_eq_vsub_rev p₂ p₁, smul_neg, ← neg_smul, smul_add, smul_smul, ← add_smul, eq_comm, eq_vadd_iff_vsub_eq] - convert (one_smul ℝ (p₂ -ᵥ p₁)).symm + convert! (one_smul ℝ (p₂ -ᵥ p₁)).symm field [(sub_pos.2 (hr.trans zero_lt_one)).ne.symm] · rw [ne_comm, ← @vsub_ne_zero V, hp₃p₂, smul_ne_zero_iff] exact ⟨hr.ne, hp₁p₂⟩ diff --git a/Mathlib/Geometry/Euclidean/Circumcenter.lean b/Mathlib/Geometry/Euclidean/Circumcenter.lean index b857463b403a24..21f56505cee09f 100644 --- a/Mathlib/Geometry/Euclidean/Circumcenter.lean +++ b/Mathlib/Geometry/Euclidean/Circumcenter.lean @@ -173,7 +173,7 @@ theorem _root_.AffineIndependent.existsUnique_dist_eq {ι : Type*} [hne : Nonemp simp [Classical.em] rw [hr, ← affineSpan_insert_affineSpan] refine existsUnique_dist_eq_of_insert (Set.range_nonempty _) (subset_affineSpan ℝ _) ?_ hm - convert ha.notMem_affineSpan_diff i Set.univ + convert! ha.notMem_affineSpan_diff i Set.univ change (Set.range fun i2 : { x | x ≠ i } => p i2) = _ rw [← Set.image_eq_range] congr 1 with j @@ -489,7 +489,7 @@ def pointWeightsWithCircumcenter {n : ℕ} (i : Fin (n + 1)) : PointsWithCircumc theorem sum_pointWeightsWithCircumcenter {n : ℕ} (i : Fin (n + 1)) : ∑ j, pointWeightsWithCircumcenter i j = 1 := by classical - convert sum_ite_eq' univ (pointIndex i) (Function.const _ (1 : ℝ)) with j + convert! sum_ite_eq' univ (pointIndex i) (Function.const _ (1 : ℝ)) with j · cases j <;> simp [pointWeightsWithCircumcenter] · simp @@ -550,7 +550,7 @@ def circumcenterWeightsWithCircumcenter (n : ℕ) : PointsWithCircumcenterIndex theorem sum_circumcenterWeightsWithCircumcenter (n : ℕ) : ∑ i, circumcenterWeightsWithCircumcenter n i = 1 := by classical - convert sum_ite_eq' univ circumcenterIndex (Function.const _ (1 : ℝ)) with j + convert! sum_ite_eq' univ circumcenterIndex (Function.const _ (1 : ℝ)) with j · cases j <;> simp [circumcenterWeightsWithCircumcenter] · simp @@ -606,7 +606,7 @@ theorem reflection_circumcenter_eq_affineCombination_of_pointsWithCircumcenter { centroidWeightsWithCircumcenter, circumcenterWeightsWithCircumcenter, reflectionCircumcenterWeightsWithCircumcenter, ite_smul, zero_smul, sub_zero, apply_ite₂ (· + ·), add_zero, ← add_smul, hc, zero_sub, neg_smul, sub_self, add_zero] - convert sum_const_zero + convert! sum_const_zero norm_num end Simplex diff --git a/Mathlib/Geometry/Euclidean/Incenter.lean b/Mathlib/Geometry/Euclidean/Incenter.lean index e1a96658ecfe25..2d2c443c690725 100644 --- a/Mathlib/Geometry/Euclidean/Incenter.lean +++ b/Mathlib/Geometry/Euclidean/Incenter.lean @@ -229,10 +229,10 @@ lemma sum_inv_height_sq_smul_vsub_eq_zero : intro i hi rw [← Finset.add_sum_erase _ _ (Finset.mem_univ 0), ← Finset.add_sum_erase _ _ (Finset.mem_erase.2 ⟨hi, Finset.mem_univ _⟩), ← add_assoc] - convert add_zero _ - · convert Finset.sum_const_zero with j hj + convert! add_zero _ + · convert! Finset.sum_const_zero with j hj rw [real_inner_smul_right] - convert mul_zero _ + convert! mul_zero _ rw [← Submodule.mem_orthogonal_singleton_iff_inner_right] refine SetLike.le_def.1 (Submodule.orthogonal_le ?_) (vsub_orthogonalProjection_mem_direction_orthogonal _ _) @@ -270,7 +270,7 @@ lemma inv_height_eq_sum_mul_inv_dist (i : Fin (n + 1)) : apply_fun fun v ↦ (s.height i)⁻¹ * ⟪s.points i -ᵥ s.altitudeFoot i, v⟫ at h rw [inner_sum, Finset.mul_sum] at h simp only [inner_zero_right, mul_zero, inner_smul_right, height] at h - convert h using 2 with j + convert! h using 2 with j ring /-- The inverse of the distance from one vertex to the opposite face is less than the sum of that @@ -296,7 +296,7 @@ lemma sum_excenterWeightsUnnorm_singleton_pos [Nat.AtLeastTwo n] (i : Fin (n + 1 rw [← Finset.sum_add_sum_compl {i}, Finset.sum_singleton] nth_rw 1 [excenterWeightsUnnorm] simp only [Finset.mem_singleton, ↓reduceIte, neg_mul, one_mul, lt_neg_add_iff_add_lt, add_zero] - convert s.inv_height_lt_sum_inv_height i using 2 with j h + convert! s.inv_height_lt_sum_inv_height i using 2 with j h · ext j simp · rw [Finset.mem_filter_univ] at h @@ -305,7 +305,7 @@ lemma sum_excenterWeightsUnnorm_singleton_pos [Nat.AtLeastTwo n] (i : Fin (n + 1 lemma sign_excenterWeights_singleton_neg [Nat.AtLeastTwo n] (i : Fin (n + 1)) : SignType.sign (s.excenterWeights {i} i) = -1 := by simp_rw [excenterWeights, Pi.smul_apply, smul_eq_mul, sign_mul] - convert one_mul _ + convert! one_mul _ · rw [sign_eq_one_iff, inv_pos] exact s.sum_excenterWeightsUnnorm_singleton_pos i · simp [excenterWeightsUnnorm] @@ -313,7 +313,7 @@ lemma sign_excenterWeights_singleton_neg [Nat.AtLeastTwo n] (i : Fin (n + 1)) : lemma sign_excenterWeights_singleton_pos [Nat.AtLeastTwo n] {i j : Fin (n + 1)} (h : i ≠ j) : SignType.sign (s.excenterWeights {i} j) = 1 := by simp_rw [excenterWeights, Pi.smul_apply, smul_eq_mul, sign_mul] - convert one_mul _ + convert! one_mul _ · rw [sign_eq_one_iff, inv_pos] exact s.sum_excenterWeightsUnnorm_singleton_pos i · simp [excenterWeightsUnnorm, h.symm] @@ -336,7 +336,7 @@ lemma excenterWeights_empty_lt_inv_two [n.AtLeastTwo] (i : Fin (n + 1)) : rwa [two_mul, sum_singleton] replace h : (s.height i)⁻¹ / ∑ i, (s.height i)⁻¹ < 2⁻¹ := by rwa [sum_add_sum_compl, ← lt_inv_mul_iff₀ zero_lt_two, ← div_lt_iff₀ (by positivity)] at h - convert h + convert! h simp [excenterWeights, excenterWeightsUnnorm, div_eq_inv_mul] /-- The exsphere with signs determined by the given set of indices (for the empty set, this is @@ -567,13 +567,13 @@ lemma ExcenterExists.sign_signedInfDist_excenter {signs : Finset (Fin (n + 1))} SignType.sign (s.excenterWeights signs i) := by rw [excenter_eq_affineCombination, signedInfDist_affineCombination _ _ h.sum_excenterWeights_eq_one, sign_mul] - convert mul_one _ + convert! mul_one _ rw [sign_eq_one_iff, ← dist_eq_norm_vsub] exact s.height_pos _ lemma sign_signedInfDist_incenter (i : Fin (n + 1)) : SignType.sign (s.signedInfDist i s.incenter) = 1 := by - convert s.excenterExists_empty.sign_signedInfDist_excenter i + convert! s.excenterExists_empty.sign_signedInfDist_excenter i simp variable {s} in @@ -639,7 +639,8 @@ lemma ExcenterExists.excenter_notMem_affineSpan_pair [Nat.AtLeastTwo n] · simp only [hij, Set.mem_singleton_iff, Set.insert_eq_of_mem, AffineSubspace.mem_affineSpan_singleton] exact h.excenter_ne_point j - · convert h.excenter_notMem_affineSpan_face (fs := {i, j}) (m := 1) (by simp_all) + · convert! + h.excenter_notMem_affineSpan_face (fs := { i, j }) (m := 1) (by simp_all) Nat.AtLeastTwo.ne_one.symm simp [Set.image_insert_eq] @@ -959,7 +960,7 @@ lemma exists_forall_signedInfDist_eq_iff_excenterExists_and_eq_excenter {p : P} lemma exists_forall_signedInfDist_eq_iff_eq_incenter {p : P} (hp : p ∈ affineSpan ℝ (Set.range s.points)) : (∃ r : ℝ, ∀ i, s.signedInfDist i p = r) ↔ p = s.incenter := by - convert s.exists_forall_signedInfDist_eq_iff_excenterExists_and_eq_excenter hp (signs := ∅) + convert! s.exists_forall_signedInfDist_eq_iff_excenterExists_and_eq_excenter hp (signs := ∅) · simp · simp [excenterExists_empty] @@ -991,7 +992,7 @@ lemma ExcenterExists.touchpoint_injective {signs : Finset (Fin (n + 1))} · subst hn1 rw [s.touchpoint_eq_point_rev signs i, s.touchpoint_eq_point_rev signs j] at hij apply s.independent.injective.ne hne - convert hij.symm <;> clear hij <;> decide +revert + convert! hij.symm <;> clear hij <;> decide +revert · suffices s.excenter signs -ᵥ s.touchpoint signs i ∈ (vectorSpan ℝ (Set.range s.points))ᗮ by have h' : s.excenter signs -ᵥ s.touchpoint signs i ∈ (vectorSpan ℝ (Set.range s.points)) := by rw [← direction_affineSpan] @@ -1007,7 +1008,7 @@ lemma ExcenterExists.touchpoint_injective {signs : Finset (Fin (n + 1))} have hu : Set.range s.points = Set.range (s.faceOpposite i).points ∪ Set.range (s.faceOpposite j).points := by simp only [range_faceOpposite_points, ← Set.image_union, ← Set.compl_inter] - convert Set.image_univ.symm + convert! Set.image_univ.symm simp [Ne.symm hne] rw [hu, range_faceOpposite_points, range_faceOpposite_points, AffineSubspace.vectorSpan_union_of_mem_of_mem ℝ (p := s.points k) @@ -1064,7 +1065,7 @@ lemma ExcenterExists.sign_signedInfDist_lineMap_excenter_touchpoint {signs : Fin exact ContinuousAffineMap.cont _ refine ((isConnected_Icc zero_le_one).image _ hc).isPreconnected.subsingleton (Set.mem_image_of_mem _ hr) ?_ - convert Set.mem_image_of_mem _ (Set.left_mem_Icc.2 (zero_le_one' ℝ)) + convert! Set.mem_image_of_mem _ (Set.left_mem_Icc.2 (zero_le_one' ℝ)) simp lemma sign_signedInfDist_lineMap_incenter_touchpoint {i j : Fin (n + 1)} (hne : i ≠ j) {r : ℝ} @@ -1156,7 +1157,7 @@ lemma ExcenterExists.sign_touchpointWeights {signs : Finset (Fin (n + 1))} rw [← s.affineCombination_touchpointWeights signs i, h.sign_signedInfDist_excenter, s.signedInfDist_affineCombination j (by simp)] at hs rw [← hs, sign_mul] - convert (mul_one _).symm + convert! (mul_one _).symm rw [sign_eq_one_iff, ← dist_eq_norm_vsub] exact s.height_pos _ @@ -1172,7 +1173,7 @@ variable {s} in (s.sum_touchpointWeights signs i) ?_ (Finset.mem_univ _) (Set.notMem_compl_iff.2 (Set.mem_singleton _)) rw [s.affineCombination_touchpointWeights] - convert s.touchpoint_mem_affineSpan _ _ + convert! s.touchpoint_mem_affineSpan _ _ simp lemma touchpointWeights_empty_pos {i j : Fin (n + 1)} (hne : i ≠ j) : @@ -1282,42 +1283,42 @@ lemma excenter_eq_incenter_or_excenter_singleton_of_ne (signs : Finset (Fin 3)) lemma sSameSide_affineSpan_pair_incenter_point {i₁ i₂ i₃ : Fin 3} (h₁₂ : i₁ ≠ i₂) (h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) : line[ℝ, t.points i₂, t.points i₃].SSameSide t.incenter (t.points i₁) := by - convert t.sSameSide_incenter_point i₁ + convert! t.sSameSide_incenter_point i₁ simp grind lemma sSameSide_affineSpan_pair_point_incenter {i₁ i₂ i₃ : Fin 3} (h₁₂ : i₁ ≠ i₂) (h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) : line[ℝ, t.points i₂, t.points i₃].SSameSide (t.points i₁) t.incenter := by - convert t.sSameSide_point_incenter i₁ + convert! t.sSameSide_point_incenter i₁ simp grind lemma sOppSide_affineSpan_pair_excenter_singleton_point {i₁ i₂ i₃ : Fin 3} (h₁₂ : i₁ ≠ i₂) (h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) : line[ℝ, t.points i₂, t.points i₃].SOppSide (t.excenter {i₁}) (t.points i₁) := by - convert t.sOppSide_excenter_singleton_point i₁ + convert! t.sOppSide_excenter_singleton_point i₁ simp grind lemma sOppSide_affineSpan_pair_point_excenter_singleton {i₁ i₂ i₃ : Fin 3} (h₁₂ : i₁ ≠ i₂) (h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) : line[ℝ, t.points i₂, t.points i₃].SOppSide (t.points i₁) (t.excenter {i₁}) := by - convert t.sOppSide_point_excenter_singleton i₁ + convert! t.sOppSide_point_excenter_singleton i₁ simp grind lemma sSameSide_affineSpan_pair_excenter_singleton_point {i₁ i₂ i₃ : Fin 3} (h₁₂ : i₁ ≠ i₂) (h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) : line[ℝ, t.points i₂, t.points i₃].SSameSide (t.excenter {i₂}) (t.points i₁) := by - convert t.sSameSide_excenter_singleton_point h₁₂ + convert! t.sSameSide_excenter_singleton_point h₁₂ simp grind lemma sSameSide_affineSpan_pair_point_excenter_singleton {i₁ i₂ i₃ : Fin 3} (h₁₂ : i₁ ≠ i₂) (h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) : line[ℝ, t.points i₂, t.points i₃].SSameSide (t.points i₁) (t.excenter {i₂}) := by - convert t.sSameSide_point_excenter_singleton h₁₂ + convert! t.sSameSide_point_excenter_singleton h₁₂ simp grind @@ -1325,7 +1326,7 @@ lemma affineSpan_pair_eq_orthRadius [Fact (Module.finrank ℝ V = 2)] (signs : F {i₁ i₂ i₃ : Fin 3} (h₁₂ : i₁ ≠ i₂) (h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) : line[ℝ, t.points i₂, t.points i₃] = (t.exsphere signs).orthRadius (t.touchpoint signs i₁) := by - convert (t.excenterExists signs).affineSpan_faceOpposite_eq_orthRadius i₁ + convert! (t.excenterExists signs).affineSpan_faceOpposite_eq_orthRadius i₁ have hc : {i₁}ᶜ = ({i₂, i₃} : Set (Fin 3)) := by grind simp [Simplex.range_faceOpposite_points, hc, Set.image_insert_eq] @@ -1337,17 +1338,17 @@ lemma affineSpan_pair_eq_orthRadius_insphere [Fact (Module.finrank ℝ V = 2)] lemma sbtw_touchpoint_empty {i₁ i₂ i₃ : Fin 3} (h₁₂ : i₁ ≠ i₂) (h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) : Sbtw ℝ (t.points i₁) (t.touchpoint ∅ i₂) (t.points i₃) := by rw [← t.mem_interior_face_iff_sbtw h₁₃] - convert t.touchpoint_empty_mem_interior_faceOpposite i₂ + convert! t.touchpoint_empty_mem_interior_faceOpposite i₂ rw [Affine.Simplex.faceOpposite] - convert rfl using 2 + convert! rfl using 2 decide +revert lemma sbtw_touchpoint_singleton {i₁ i₂ i₃ : Fin 3} (h₁₂ : i₁ ≠ i₂) (h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) : Sbtw ℝ (t.points i₁) (t.touchpoint {i₂} i₂) (t.points i₃) := by rw [← t.mem_interior_face_iff_sbtw h₁₃] - convert t.touchpoint_singleton_mem_interior_faceOpposite i₂ + convert! t.touchpoint_singleton_mem_interior_faceOpposite i₂ rw [Affine.Simplex.faceOpposite] - convert rfl using 2 + convert! rfl using 2 decide +revert lemma touchpoint_singleton_sbtw {i₁ i₂ i₃ : Fin 3} (h₁₂ : i₁ ≠ i₂) (h₁₃ : i₁ ≠ i₃) (h₂₃ : i₂ ≠ i₃) : diff --git a/Mathlib/Geometry/Euclidean/Inversion/Basic.lean b/Mathlib/Geometry/Euclidean/Inversion/Basic.lean index 4bbea59cb89e6a..257a3c57a22969 100644 --- a/Mathlib/Geometry/Euclidean/Inversion/Basic.lean +++ b/Mathlib/Geometry/Euclidean/Inversion/Basic.lean @@ -192,7 +192,7 @@ theorem mul_dist_le_mul_dist_add_mul_dist (a b c d : P) : dist_inversion_inversion hc hd, one_pow] at H rw [← dist_pos] at hb hc hd rw [← div_le_div_iff_of_pos_right (mul_pos hb (mul_pos hc hd))] - convert H using 1 <;> simp [field, dist_comm a]; ring + convert! H using 1 <;> simp [field, dist_comm a]; ring end EuclideanGeometry diff --git a/Mathlib/Geometry/Euclidean/MongePoint.lean b/Mathlib/Geometry/Euclidean/MongePoint.lean index 6a3f9b9a1b9e89..e75eae0305c8d2 100644 --- a/Mathlib/Geometry/Euclidean/MongePoint.lean +++ b/Mathlib/Geometry/Euclidean/MongePoint.lean @@ -91,7 +91,7 @@ theorem mongePoint_eq_smul_vsub_vadd_circumcenter {n : ℕ} (s : Simplex ℝ P n simp_rw [mongePoint, circumcenter_reindex, centroid_def, reindex] obtain rfl : n = m := by simpa using Fintype.card_eq.2 ⟨e⟩ congr 3 - convert Finset.univ.affineCombination_map e.toEmbedding _ _ <;> simp [Function.comp_assoc] + convert! Finset.univ.affineCombination_map e.toEmbedding _ _ <;> simp [Function.comp_assoc] @[simp] theorem mongePoint_map {V₂ P₂ : Type*} [NormedAddCommGroup V₂] [InnerProductSpace ℝ V₂] @@ -280,7 +280,7 @@ lemma mongePlane_reindex {m n : ℕ} (s : Simplex ℝ P (n + 2)) (e : Fin (n + 3 simp_rw [mongePlane, reindex_points, reindex_range_points, Function.comp_apply, centroid_def, reindex] congr 2 - convert Finset.affineCombination_map {e.symm i₁, e.symm i₂}ᶜ e.toEmbedding _ _ using 3 + convert! Finset.affineCombination_map {e.symm i₁, e.symm i₂}ᶜ e.toEmbedding _ _ using 3 · ext i simp · simp [Function.comp_assoc] @@ -614,7 +614,7 @@ theorem exists_dist_eq_circumradius_of_subset_insert_orthocenter {t : Triangle rcases hp₁ with ⟨i, rfl⟩ have h₁₂₃ := h₁₂₃ i repeat' rcases h₁₂₃ with h₁₂₃ | h₁₂₃ - · convert Triangle.dist_orthocenter_reflection_circumcenter t hj₂₃ + · convert! Triangle.dist_orthocenter_reflection_circumcenter t hj₂₃ · rw [← h₂, dist_reflection_eq_of_mem _ (mem_affineSpan ℝ (Set.mem_image_of_mem _ (Set.mem_insert _ _)))] exact t.dist_circumcenter_eq_circumradius _ @@ -695,7 +695,7 @@ theorem OrthocentricSystem.eq_insert_orthocenter {s : Set P} (ho : OrthocentricS (Triangle.orthocenter_replace_orthocenter_eq_point hj₁₂ hj₁₃ hj₂₃ h₁₂ h₁₃ h₂₃ h₁ h₂.symm h₃.symm).symm · rw [hs] - convert ht₀s using 2 + convert! ht₀s using 2 exact Triangle.orthocenter_eq_of_range_eq hs end EuclideanGeometry diff --git a/Mathlib/Geometry/Euclidean/NinePointCircle.lean b/Mathlib/Geometry/Euclidean/NinePointCircle.lean index f34245a633be17..3bd274ff36de7d 100644 --- a/Mathlib/Geometry/Euclidean/NinePointCircle.lean +++ b/Mathlib/Geometry/Euclidean/NinePointCircle.lean @@ -216,7 +216,7 @@ theorem eulerPoint_eq_midpoint (s : Triangle ℝ P) (i : Fin 3) : theorem altitudeFoot_mem_ninePointCircle (s : Triangle ℝ P) (i : Fin 3) : s.altitudeFoot i ∈ s.ninePointCircle := by - convert s.orthogonalProjectionSpan_eulerPoint_mem_ninePointCircle i + convert! s.orthogonalProjectionSpan_eulerPoint_mem_ninePointCircle i rw [Simplex.altitudeFoot] unfold Simplex.orthogonalProjectionSpan congr 1 diff --git a/Mathlib/Geometry/Euclidean/Projection.lean b/Mathlib/Geometry/Euclidean/Projection.lean index da214a27239471..19e26e3b6cfc28 100644 --- a/Mathlib/Geometry/Euclidean/Projection.lean +++ b/Mathlib/Geometry/Euclidean/Projection.lean @@ -495,7 +495,7 @@ theorem dist_reflection_eq_of_mem (s : AffineSubspace 𝕜 P) [Nonempty s] [s.direction.HasOrthogonalProjection] {p₁ : P} (hp₁ : p₁ ∈ s) (p₂ : P) : dist p₁ (reflection s p₂) = dist p₁ p₂ := by rw [← reflection_eq_self_iff p₁] at hp₁ - convert (reflection s).dist_map p₁ p₂ + convert! (reflection s).dist_map p₁ p₂ rw [hp₁] /-- The reflection of a point in a subspace is contained in any larger @@ -551,7 +551,7 @@ lemma orthogonalProjection_subtype (s : AffineSubspace 𝕜 P) [Nonempty s] (s' have : (s'.map s.subtypeₐᵢ.toAffineMap).direction.HasOrthogonalProjection := by rw [subtypeₐᵢ_toAffineMap] infer_instance - convert orthogonalProjection_map s' s.subtypeₐᵢ p + convert! orthogonalProjection_map s' s.subtypeₐᵢ p @[simp] lemma reflection_map (s : AffineSubspace 𝕜 P) [Nonempty s] [s.direction.HasOrthogonalProjection] (f : P →ᵃⁱ[𝕜] P₂) @@ -619,7 +619,7 @@ theorem dist_sq_eq_dist_orthogonalProjection_sq_add_dist_orthogonalProjection_sq lemma orthogonalProjectionSpan_eq_point (s : Simplex 𝕜 P 0) (p : P) : s.orthogonalProjectionSpan p = s.points 0 := by rw [orthogonalProjectionSpan] - convert orthogonalProjection_affineSpan_singleton _ _ + convert! orthogonalProjection_affineSpan_singleton _ _ simp [Fin.fin_one_eq_zero] lemma orthogonalProjectionSpan_faceOpposite_eq_point_rev (s : Simplex 𝕜 P 1) (i : Fin 2) @@ -632,7 +632,7 @@ lemma orthogonalProjectionSpan_map {n : ℕ} (s : Simplex 𝕜 P n) (f : P → (s.map f.toAffineMap f.injective).orthogonalProjectionSpan (f p) = f (s.orthogonalProjectionSpan p) := by simp_rw [orthogonalProjectionSpan] - convert orthogonalProjection_map (affineSpan 𝕜 (Set.range s.points)) f p + convert! orthogonalProjection_map (affineSpan 𝕜 (Set.range s.points)) f p simp [AffineSubspace.map_span, Set.range_comp] @[simp] lemma orthogonalProjectionSpan_restrict {n : ℕ} (s : Simplex 𝕜 P n) @@ -640,7 +640,7 @@ lemma orthogonalProjectionSpan_map {n : ℕ} (s : Simplex 𝕜 P n) (f : P → haveI := Nonempty.map (AffineSubspace.inclusion hS) inferInstance ((s.restrict S hS).orthogonalProjectionSpan p : P) = s.orthogonalProjectionSpan p := by rw [eq_comm] - convert (s.restrict S hS).orthogonalProjectionSpan_map S.subtypeₐᵢ p + convert! (s.restrict S hS).orthogonalProjectionSpan_map S.subtypeₐᵢ p end Simplex diff --git a/Mathlib/Geometry/Euclidean/SignedDist.lean b/Mathlib/Geometry/Euclidean/SignedDist.lean index 7b12d3a68e54d6..37621c1f735dee 100644 --- a/Mathlib/Geometry/Euclidean/SignedDist.lean +++ b/Mathlib/Geometry/Euclidean/SignedDist.lean @@ -338,7 +338,7 @@ lemma abs_signedInfDist_eq_dist_of_mem_affineSpan_range {p : P} orthogonalProjectionSpan] · simp_rw [range_faceOpposite_points] rw [affineSpan_insert_affineSpan] - convert h + convert! h exact Set.insert_image_compl_eq_range s.points i end Simplex diff --git a/Mathlib/Geometry/Euclidean/Simplex.lean b/Mathlib/Geometry/Euclidean/Simplex.lean index 01e862976979c4..7ccbcfba69441d 100644 --- a/Mathlib/Geometry/Euclidean/Simplex.lean +++ b/Mathlib/Geometry/Euclidean/Simplex.lean @@ -59,8 +59,8 @@ def AcuteAngled (s : Simplex ℝ P n) : Prop := @[simp] lemma acuteAngled_reindex_iff {s : Simplex ℝ P m} (e : Fin (m + 1) ≃ Fin (n + 1)) : (s.reindex e).AcuteAngled ↔ s.AcuteAngled := by refine ⟨fun h {i₁ i₂ i₃} h₁₂ h₁₃ h₂₃ ↦ ?_, fun h {i₁ i₂ i₃} h₁₂ h₁₃ h₂₃ ↦ ?_⟩ - · convert h (i₁ := e i₁) (i₂ := e i₂) (i₃ := e i₃) ?_ ?_ ?_ using 1 <;> simp [*] - · convert h (i₁ := e.symm i₁) (i₂ := e.symm i₂) (i₃ := e.symm i₃) ?_ ?_ ?_ using 1 <;> simp [*] + · convert! h (i₁ := e i₁) (i₂ := e i₂) (i₃ := e i₃) ?_ ?_ ?_ using 1 <;> simp [*] + · convert! h (i₁ := e.symm i₁) (i₂ := e.symm i₂) (i₃ := e.symm i₃) ?_ ?_ ?_ using 1 <;> simp [*] lemma Equilateral.acuteAngled {s : Simplex ℝ P n} (he : s.Equilateral) : s.AcuteAngled := by intro i₁ i₂ i₃ h₁₂ h₁₃ h₂₃ diff --git a/Mathlib/Geometry/Euclidean/Sphere/OrthRadius.lean b/Mathlib/Geometry/Euclidean/Sphere/OrthRadius.lean index 5634c5cb25300e..11c7b29162be66 100644 --- a/Mathlib/Geometry/Euclidean/Sphere/OrthRadius.lean +++ b/Mathlib/Geometry/Euclidean/Sphere/OrthRadius.lean @@ -119,14 +119,14 @@ lemma orthRadius_injective (s : Sphere P) : Injective s.orthRadius := lemma finrank_orthRadius [FiniteDimensional ℝ V] {s : Sphere P} {p : P} (hp : p ≠ s.center) : Module.finrank ℝ (s.orthRadius p).direction + 1 = Module.finrank ℝ V := by rw [orthRadius, add_comm, direction_mk'] - convert (ℝ ∙ (p -ᵥ s.center)).finrank_add_finrank_orthogonal + convert! (ℝ ∙ (p -ᵥ s.center)).finrank_add_finrank_orthogonal exact (finrank_span_singleton (vsub_ne_zero.2 hp)).symm lemma orthRadius_map {s : Sphere P} (p : P) {f : P ≃ᵃⁱ[ℝ] P} (h : f s.center = s.center) : (s.orthRadius p).map f.toAffineMap = s.orthRadius (f p) := by rw [orthRadius, map_mk', orthRadius] - convert rfl using 2 - convert (Submodule.map_orthogonal_equiv (ℝ ∙ (p -ᵥ s.center)) f.linearIsometryEquiv).symm + convert! rfl using 2 + convert! (Submodule.map_orthogonal_equiv (ℝ ∙ (p -ᵥ s.center)) f.linearIsometryEquiv).symm simp [Submodule.map_span, Set.image_singleton, h] lemma direction_orthRadius_le_iff {s : Sphere P} {p q : P} : @@ -350,8 +350,9 @@ lemma inter_orthRadius_eq_of_dist_le_radius [hf2 : Fact (Module.finrank ℝ V = (hv : v ∈ (ℝ ∙ (p -ᵥ s.center))ᗮ) (hv0 : v ≠ 0) : (s ∩ s.orthRadius p : Set P) = {(√(s.radius ^ 2 - (dist p s.center) ^ 2) / ‖v‖) • v +ᵥ p, -(√(s.radius ^ 2 - (dist p s.center) ^ 2) / ‖v‖) • v +ᵥ p} := by - convert inter_orthRadius_eq_of_dist_le_radius_of_norm_eq_one hp hpc (v := ‖v‖⁻¹ • v) - (Submodule.smul_mem _ _ hv) ?_ using 2 + convert! + inter_orthRadius_eq_of_dist_le_radius_of_norm_eq_one hp hpc (v := ‖v‖⁻¹ • v) + (Submodule.smul_mem _ _ hv) ?_ using 2 · simp [div_eq_mul_inv, smul_smul] · simp [div_eq_mul_inv, smul_smul] · simp [norm_smul, norm_ne_zero_iff.2 hv0] diff --git a/Mathlib/Geometry/Euclidean/Sphere/Power.lean b/Mathlib/Geometry/Euclidean/Sphere/Power.lean index 96899bc1fdbccd..c1fc4fbcd7aa5c 100644 --- a/Mathlib/Geometry/Euclidean/Sphere/Power.lean +++ b/Mathlib/Geometry/Euclidean/Sphere/Power.lean @@ -203,7 +203,7 @@ theorem cospherical_of_mul_dist_eq_mul_dist_of_angle_eq_pi {p₁ p₂ p₃ p₄ have hncol : ¬ Collinear ℝ {p₁', p', p₃'} := by rw [← affineIndependent_iff_not_collinear_set, ← s_isom.toAffineMap.affineIndependent_iff s_isom.injective] - convert hindep + convert! hindep ext i; fin_cases i <;> rfl exact cospherical_of_mul_dist_eq_mul_dist_of_angle_eq_pi_aux h_dist' hp₁'p₂' hp₃'p₄' hncol diff --git a/Mathlib/Geometry/Euclidean/Sphere/SecondInter.lean b/Mathlib/Geometry/Euclidean/Sphere/SecondInter.lean index 10fc2ecb820cfe..8b4dbdca401b76 100644 --- a/Mathlib/Geometry/Euclidean/Sphere/SecondInter.lean +++ b/Mathlib/Geometry/Euclidean/Sphere/SecondInter.lean @@ -110,8 +110,8 @@ theorem Sphere.eq_or_eq_secondInter_of_mem_mk'_span_singleton_iff_mem {s : Spher lemma Sphere.eq_or_eq_secondInter_iff_mem_of_mem_affineSpan_pair {s : Sphere P} {p q : P} (hp : p ∈ s) {p' : P} (hp' : p' ∈ line[ℝ, p, q]) : p' = p ∨ p' = s.secondInter p (q -ᵥ p) ↔ p' ∈ s := by - convert s.eq_or_eq_secondInter_of_mem_mk'_span_singleton_iff_mem hp ?_ - convert hp' + convert! s.eq_or_eq_secondInter_of_mem_mk'_span_singleton_iff_mem hp ?_ + convert! hp' rw [AffineSubspace.eq_iff_direction_eq_of_mem (AffineSubspace.self_mem_mk' p _) (left_mem_affineSpan_pair _ _ _)] simp [direction_affineSpan, vectorSpan_pair_rev] @@ -140,8 +140,8 @@ theorem Sphere.secondInter_secondInter (s : Sphere P) (p : P) (v : V) : simp only [Sphere.secondInter, vadd_vsub_assoc, vadd_vadd, inner_add_right, inner_smul_right, div_mul_cancel₀ _ hv'] rw [← @vsub_eq_zero_iff_eq V, vadd_vsub, ← add_smul, ← add_div] - convert zero_smul ℝ _ - convert zero_div (G₀ := ℝ) _ + convert! zero_smul ℝ _ + convert! zero_div (G₀ := ℝ) _ ring /-- If the vector passed to `secondInter` is given by a subtraction involving the point in diff --git a/Mathlib/Geometry/Euclidean/Sphere/Tangent.lean b/Mathlib/Geometry/Euclidean/Sphere/Tangent.lean index ba25a2110435cd..44141b8669e0c3 100644 --- a/Mathlib/Geometry/Euclidean/Sphere/Tangent.lean +++ b/Mathlib/Geometry/Euclidean/Sphere/Tangent.lean @@ -178,7 +178,7 @@ lemma IsTangent.infDist_eq_radius {s : Sphere P} {as : AffineSubspace ℝ P} (h Metric.infDist s.center as = s.radius := by obtain ⟨p, h⟩ := h refine le_antisymm ?_ ?_ - · convert Metric.infDist_le_dist_of_mem h.mem_space + · convert! Metric.infDist_le_dist_of_mem h.mem_space rw [mem_sphere'.1 h.mem_sphere] · rw [Metric.infDist_eq_iInf] have : Nonempty as := ⟨⟨p, h.mem_space⟩⟩ @@ -246,7 +246,7 @@ lemma IsTangent.eq_orthRadius_or_eq_orthRadius_pointReflection_of_parallel_orthR rcases eq_or_eq_neg_of_abs_eq hr' with rfl | rfl · simp_all · right - convert rfl + convert! rfl rw [← eq_vadd_iff_vsub_eq] at hr rw [hr] simp [Equiv.pointReflection_apply] diff --git a/Mathlib/Geometry/Euclidean/Triangle.lean b/Mathlib/Geometry/Euclidean/Triangle.lean index 6b989cbc41a5b0..bc6702b17b5361 100644 --- a/Mathlib/Geometry/Euclidean/Triangle.lean +++ b/Mathlib/Geometry/Euclidean/Triangle.lean @@ -244,8 +244,9 @@ theorem dist_sq_eq_dist_sq_add_dist_sq_sub_two_mul_dist_mul_dist_mul_cos_angle ( 2 * dist p₁ p₂ * dist p₃ p₂ * Real.cos (∠ p₁ p₂ p₃) := by rw [dist_eq_norm_vsub V p₁ p₃, dist_eq_norm_vsub V p₁ p₂, dist_eq_norm_vsub V p₃ p₂] unfold angle - convert norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle - (p₁ -ᵥ p₂ : V) (p₃ -ᵥ p₂ : V) + convert! + norm_sub_sq_eq_norm_sq_add_norm_sq_sub_two_mul_norm_mul_norm_mul_cos_angle (p₁ -ᵥ p₂ : V) + (p₃ -ᵥ p₂ : V) · exact (vsub_sub_vsub_cancel_right p₁ p₃ p₂).symm · exact (vsub_sub_vsub_cancel_right p₁ p₃ p₂).symm @@ -285,7 +286,7 @@ theorem angle_eq_angle_of_dist_eq {p₁ p₂ p₃ : P} (h : dist p₁ p₂ = dis ∠ p₁ p₂ p₃ = ∠ p₁ p₃ p₂ := by rw [dist_eq_norm_vsub V p₁ p₂, dist_eq_norm_vsub V p₁ p₃] at h unfold angle - convert angle_sub_eq_angle_sub_rev_of_norm_eq h + convert! angle_sub_eq_angle_sub_rev_of_norm_eq h · exact (vsub_sub_vsub_cancel_left p₃ p₂ p₁).symm · exact (vsub_sub_vsub_cancel_left p₂ p₃ p₁).symm @@ -302,15 +303,16 @@ theorem dist_eq_of_angle_eq_angle_of_angle_ne_pi {p₁ p₂ p₃ : P} (h : ∠ p theorem dist_eq_of_two_zsmul_oangle_eq [Module.Oriented ℝ V (Fin 2)] [Fact (Module.finrank ℝ V = 2)] {p₁ p₂ p₃ : P} (h : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₂ p₃ p₁) (h0 : ∡ p₃ p₁ p₂ ≠ 0) (hpi : ∡ p₃ p₁ p₂ ≠ π) : dist p₁ p₂ = dist p₁ p₃ := by - convert (Orientation.norm_eq_of_two_zsmul_oangle_sub_eq (x := p₃ -ᵥ p₁) (y := p₂ -ᵥ p₁) ?_ ?_ - h0 hpi).symm + convert! + (Orientation.norm_eq_of_two_zsmul_oangle_sub_eq (x := p₃ -ᵥ p₁) (y := p₂ -ᵥ p₁) ?_ ?_ h0 + hpi).symm · rw [dist_eq_norm_vsub'] · rw [dist_eq_norm_vsub'] · rw [eq_comm, o.oangle_rev, ← o.oangle_neg_neg] nth_rw 2 [o.oangle_rev, ← o.oangle_neg_neg] simp_rw [smul_neg, neg_inj] simp_rw [oangle] at h - convert h <;> simp + convert! h <;> simp /-- The **sum of the angles of a triangle** (possibly degenerate, where two given vertices are distinct), angle-at-point. -/ diff --git a/Mathlib/Geometry/Manifold/ChartedSpace.lean b/Mathlib/Geometry/Manifold/ChartedSpace.lean index 645371fd38bd5d..fedf3dbb18ef85 100644 --- a/Mathlib/Geometry/Manifold/ChartedSpace.lean +++ b/Mathlib/Geometry/Manifold/ChartedSpace.lean @@ -313,7 +313,7 @@ theorem ChartedSpace.discreteTopology [DiscreteTopology H] : DiscreteTopology M apply discreteTopology_iff_isOpen_singleton.2 (fun x ↦ ?_) have : IsOpen ((chartAt H x).source ∩ (chartAt H x) ⁻¹' {chartAt H x x}) := isOpen_inter_preimage _ (isOpen_discrete _) - convert this + convert! this refine Subset.antisymm (by simp) ?_ simp only [subset_singleton_iff, mem_inter_iff, mem_preimage, mem_singleton_iff, and_imp] intro y hy h'y @@ -644,8 +644,8 @@ protected def openPartialHomeomorph (e : PartialEquiv M H) (he : e ∈ c.atlas) @OpenPartialHomeomorph M H c.toTopologicalSpace _ := { __ := c.toTopologicalSpace __ := e - open_source := by convert c.open_source' he - open_target := by convert c.open_target he + open_source := by convert! c.open_source' he + open_target := by convert! c.open_target he continuousOn_toFun := by letI : TopologicalSpace M := c.toTopologicalSpace rw [continuousOn_open_iff (c.open_source' he)] diff --git a/Mathlib/Geometry/Manifold/Complex.lean b/Mathlib/Geometry/Manifold/Complex.lean index 3281bf3890f95c..09ab464a5fd039 100644 --- a/Mathlib/Geometry/Manifold/Complex.lean +++ b/Mathlib/Geometry/Manifold/Complex.lean @@ -73,7 +73,7 @@ theorem Complex.norm_eventually_eq_of_mdifferentiableAt_of_isLocalMax {f : M → rw [mdifferentiableAt_iff_of_mem_source hys hfy, hI, differentiableWithinAt_univ, e.right_inv hyt] at hy₂ exact hy₂.2 - convert norm_eventually_eq_of_isLocalMax hd _ + convert! norm_eventually_eq_of_isLocalMax hd _ · exact congr_arg f (extChartAt_to_inv _).symm · simpa only [e, IsLocalMax, IsMaxFilter, ← H₂, (· ∘ ·), extChartAt_to_inv] using hc diff --git a/Mathlib/Geometry/Manifold/ContMDiff/Atlas.lean b/Mathlib/Geometry/Manifold/ContMDiff/Atlas.lean index 6c32f1ec3ebd97..d27801c0c92d47 100644 --- a/Mathlib/Geometry/Manifold/ContMDiff/Atlas.lean +++ b/Mathlib/Geometry/Manifold/ContMDiff/Atlas.lean @@ -117,7 +117,7 @@ theorem contMDiffOn_extend_symm (he : e ∈ maximalAtlas I n M) : theorem contMDiffOn_extChartAt_symm (x : M) : ContMDiffOn 𝓘(𝕜, E) I n (extChartAt I x).symm (extChartAt I x).target := by - convert contMDiffOn_extend_symm (chart_mem_maximalAtlas (I := I) x) + convert! contMDiffOn_extend_symm (chart_mem_maximalAtlas (I := I) x) · rw [extChartAt_target, I.image_eq] · infer_instance · infer_instance @@ -143,7 +143,7 @@ theorem contMDiffWithinAt_extChartAt_symm_target_self (x : M) : apply ContinuousAt.comp _ I.continuousAt_symm exact (chartAt H x).symm.continuousAt (by simp) · apply contMDiffWithinAt_id.congr_of_mem (fun y hy ↦ ?_) (by simp) - convert PartialEquiv.right_inv (extChartAt I x) hy + convert! PartialEquiv.right_inv (extChartAt I x) hy simp omit [IsManifold I n M] in @@ -282,7 +282,7 @@ theorem isLocalStructomorphOn_contDiffGroupoid_iff (f : OpenPartialHomeomorph M have hy'' : f ((extChartAt I x).symm y) ∈ c'.source := by simp only [c, hy, mfld_simps] rw [contMDiffWithinAt_iff_of_mem_source hy' hy''] at H - convert H.2.mono _ + convert! H.2.mono _ · simp only [c, hy, mfld_simps] · dsimp [c, c']; mfld_set_tac · -- regularity of the candidate local structomorphism in the reverse direction @@ -297,7 +297,7 @@ theorem isLocalStructomorphOn_contDiffGroupoid_iff (f : OpenPartialHomeomorph M have hy'' : f.symm ((extChartAt I (f x)).symm y) ∈ c.source := by simp only [c', hy, mfld_simps] rw [contMDiffWithinAt_iff_of_mem_source hy' hy''] at H - convert H.2.mono _ + convert! H.2.mono _ · simp only [c', hy, mfld_simps] · dsimp [c, c']; mfld_set_tac -- now check the candidate local structomorphism agrees with `f` where it is supposed to diff --git a/Mathlib/Geometry/Manifold/ContMDiff/Constructions.lean b/Mathlib/Geometry/Manifold/ContMDiff/Constructions.lean index fe13581917f544..f991b3f1e20250 100644 --- a/Mathlib/Geometry/Manifold/ContMDiff/Constructions.lean +++ b/Mathlib/Geometry/Manifold/ContMDiff/Constructions.lean @@ -207,7 +207,7 @@ theorem contMDiffOn_prod_module_iff (f : M → F₁ × F₂) : theorem contMDiff_prod_iff (f : M → M' × N') : ContMDiff I (I'.prod J') n f ↔ ContMDiff I I' n (Prod.fst ∘ f) ∧ ContMDiff I J' n (Prod.snd ∘ f) := - ⟨fun h => ⟨h.fst, h.snd⟩, fun h => by convert h.1.prodMk h.2⟩ + ⟨fun h => ⟨h.fst, h.snd⟩, fun h => by convert! h.1.prodMk h.2⟩ theorem contMDiff_prod_module_iff (f : M → F₁ × F₂) : ContMDiff I 𝓘(𝕜, F₁ × F₂) n f ↔ diff --git a/Mathlib/Geometry/Manifold/ContMDiff/Defs.lean b/Mathlib/Geometry/Manifold/ContMDiff/Defs.lean index c6d9e419099402..224c9ebd3782a3 100644 --- a/Mathlib/Geometry/Manifold/ContMDiff/Defs.lean +++ b/Mathlib/Geometry/Manifold/ContMDiff/Defs.lean @@ -117,8 +117,7 @@ theorem contDiffWithinAt_localInvariantProp_of_le (n m : ℕ∞ω) (hmn : m ≤ rw [this] at h have : I (e x) ∈ I.symm ⁻¹' e.target ∩ range I := by simp only [hx, mfld_simps] have := (mem_groupoid_of_pregroupoid.2 he).2.contDiffWithinAt this - convert (h.comp_inter _ (this.of_le hmn)).mono_of_mem_nhdsWithin _ - using 1 + convert! (h.comp_inter _ (this.of_le hmn)).mono_of_mem_nhdsWithin _ using 1 · ext y; simp only [mfld_simps] refine mem_nhdsWithin.mpr ⟨I.symm ⁻¹' e.target, e.open_target.preimage I.continuous_symm, by @@ -135,7 +134,7 @@ theorem contDiffWithinAt_localInvariantProp_of_le (n m : ℕ∞ω) (hmn : m ≤ have A : (I' ∘ f ∘ I.symm) (I x) ∈ I'.symm ⁻¹' e'.source ∩ range I' := by simp only [hx, mfld_simps] have := (mem_groupoid_of_pregroupoid.2 he').1.contDiffWithinAt A - convert (this.of_le hmn).comp _ h _ + convert! (this.of_le hmn).comp _ h _ · ext y; simp only [mfld_simps] · intro y hy; simp only [mfld_simps] at hy; simpa only [hy, mfld_simps] using hs hy.1 @@ -491,14 +490,14 @@ theorem contMDiffOn_iff : specialize h w this have w1 : w ∈ (chartAt H x).source := by simp only [w, hz, mfld_simps] have w2 : f w ∈ (chartAt H' y).source := by simp only [w, hz, mfld_simps] - convert ((contMDiffWithinAt_iff_of_mem_source w1 w2).mp h).2.mono _ + convert! ((contMDiffWithinAt_iff_of_mem_source w1 w2).mp h).2.mono _ · simp only [w, hz, mfld_simps] · mfld_set_tac · rintro ⟨hcont, hdiff⟩ x hx refine (contDiffWithinAt_localInvariantProp n).liftPropWithinAt_iff.mpr ?_ refine ⟨hcont x hx, ?_⟩ dsimp [ContDiffWithinAtProp] - convert hdiff x (f x) (extChartAt I x x) (by simp only [hx, mfld_simps]) using 1 + convert! hdiff x (f x) (extChartAt I x x) (by simp only [hx, mfld_simps]) using 1 mfld_set_tac /-- zero-smoothness on a set is equivalent to continuity on this set. -/ @@ -530,7 +529,7 @@ theorem contMDiffOn_iff_target : constructor · refine fun h' y => ⟨?_, fun x _ => h' x y⟩ have h'' : ContinuousOn _ univ := (ModelWithCorners.continuous I').continuousOn - convert (h''.comp_inter (chartAt H' y).continuousOn_toFun).comp_inter h + convert! (h''.comp_inter (chartAt H' y).continuousOn_toFun).comp_inter h simp · exact fun h' x y => (h' y).2 x 0 diff --git a/Mathlib/Geometry/Manifold/ContMDiffMFDeriv.lean b/Mathlib/Geometry/Manifold/ContMDiffMFDeriv.lean index be9e7382dec0f6..126498eec36f50 100644 --- a/Mathlib/Geometry/Manifold/ContMDiffMFDeriv.lean +++ b/Mathlib/Geometry/Manifold/ContMDiffMFDeriv.lean @@ -127,7 +127,7 @@ protected theorem ContMDiffWithinAt.mfderivWithin {x₀ : N} {f : N → M → M' ∩ range J ×ˢ range I) := by apply inter_subset_inter_right exact Set.prod_mono_right (extChartAt_target_subset_range (g x₀)) - convert hf'.2.mono this + convert! hf'.2.mono this · ext y; simp; tauto · simp · exact hg'.2 @@ -167,7 +167,7 @@ protected theorem ContMDiffWithinAt.mfderivWithin {x₀ : N} {f : N → M → M' · exact mfderivWithin_eq_fderivWithin · exact mdifferentiableAt_extChartAt (by simpa using h'x) · apply MDifferentiableWithinAt.comp (I' := I) (u := u) _ _ _ inter_subset_right - · convert hx.mdifferentiableWithinAt one_ne_zero + · convert! hx.mdifferentiableWithinAt one_ne_zero exact PartialEquiv.left_inv (extChartAt I (g x₀)) h2 · apply (mdifferentiableWithinAt_extChartAt_symm _).mono · exact inter_subset_left.trans (extChartAt_target_subset_range (g x₀)) @@ -308,7 +308,7 @@ theorem ContMDiffOn.continuousOn_tangentMapWithin (hf : CMDiff[s] n f) (hmn : 1 theorem ContMDiff.contMDiff_tangentMap (hf : CMDiff n f) (hmn : m + 1 ≤ n) : CMDiff m (tangentMap I I' f) := by rw [← contMDiffOn_univ] at hf ⊢ - convert hf.contMDiffOn_tangentMapWithin hmn uniqueMDiffOn_univ + convert! hf.contMDiffOn_tangentMapWithin hmn uniqueMDiffOn_univ rw [tangentMapWithin_univ] /-- If a function is `C^n`, with `1 ≤ n`, then its bundled derivative is continuous. -/ @@ -316,7 +316,7 @@ theorem ContMDiff.continuous_tangentMap (hf : CMDiff n f) (hmn : 1 ≤ n) : Continuous (tangentMap I I' f) := by rw [← contMDiffOn_univ] at hf rw [← continuousOn_univ] - convert hf.continuousOn_tangentMapWithin hmn uniqueMDiffOn_univ + convert! hf.continuousOn_tangentMapWithin hmn uniqueMDiffOn_univ rw [tangentMapWithin_univ] end tangentMap diff --git a/Mathlib/Geometry/Manifold/Diffeomorph.lean b/Mathlib/Geometry/Manifold/Diffeomorph.lean index cd9fc59ede9a9a..0e6e6e8fc38027 100644 --- a/Mathlib/Geometry/Manifold/Diffeomorph.lean +++ b/Mathlib/Geometry/Manifold/Diffeomorph.lean @@ -339,7 +339,7 @@ theorem toOpenPartialHomeomorph_mdifferentiable (h : M ≃ₘ^n⟮I, J⟯ N) (hn theorem uniqueMDiffOn_image_aux (h : M ≃ₘ^n⟮I, J⟯ N) (hn : n ≠ 0) {s : Set M} (hs : UniqueMDiffOn I s) : UniqueMDiffOn J (h '' s) := by - convert hs.uniqueMDiffOn_preimage (h.toOpenPartialHomeomorph_mdifferentiable hn) + convert! hs.uniqueMDiffOn_preimage (h.toOpenPartialHomeomorph_mdifferentiable hn) simp [h.image_eq_preimage_symm] @[simp] diff --git a/Mathlib/Geometry/Manifold/GroupLieAlgebra.lean b/Mathlib/Geometry/Manifold/GroupLieAlgebra.lean index 70016c7a63bb7d..c41b803c69865a 100644 --- a/Mathlib/Geometry/Manifold/GroupLieAlgebra.lean +++ b/Mathlib/Geometry/Manifold/GroupLieAlgebra.lean @@ -176,7 +176,7 @@ theorem contMDiff_mulInvariantVectorField (v : GroupLieAlgebra I G) : rw [A] exact contMDiff_mul I (minSmoothness 𝕜 3) let S := (S₃.comp S₂).comp S₁ - convert S with g + convert! S with g · simp [F₁, F₂, F₃, fg, fv] · simp only [comp_apply, tangentMap, F₃, F₂, F₁, fg, fv] rw [mfderiv_prod_eq_add_apply ((contMDiff_mul I (minSmoothness 𝕜 3)).mdifferentiableAt M)] diff --git a/Mathlib/Geometry/Manifold/HasGroupoid.lean b/Mathlib/Geometry/Manifold/HasGroupoid.lean index 9b79a770952ead..3a379fc2555dab 100644 --- a/Mathlib/Geometry/Manifold/HasGroupoid.lean +++ b/Mathlib/Geometry/Manifold/HasGroupoid.lean @@ -282,7 +282,7 @@ of some chart on `M`. -/ lemma chart_eq {s : Opens M} (hs : Nonempty s) {e : OpenPartialHomeomorph s H} (he : e ∈ atlas H s) : ∃ x : s, e = (chartAt H (x : M)).subtypeRestr hs := by rcases he with ⟨xset, ⟨x, hx⟩, he⟩ - exact ⟨x, mem_singleton_iff.mp (by convert he)⟩ + exact ⟨x, mem_singleton_iff.mp (by convert! he)⟩ /-- If `t` is a non-empty open subset of `H`, every chart of `t` is the restriction of some chart on `H`. -/ @@ -468,7 +468,7 @@ def OpenPartialHomeomorph.toStructomorph {e : OpenPartialHomeomorph M H} (he : e fun c c' hc hc' ↦ G.compatible_of_mem_maximalAtlas (G.subset_maximalAtlas hc) (G.restriction_mem_maximalAtlas_subtype he h c' hc') } · have : IsEmpty t := isEmpty_coe_sort.mpr - (by convert e.image_source_eq_target ▸ image_eq_empty.mpr (isEmpty_coe_sort.mp h)) + (by convert! e.image_source_eq_target ▸ image_eq_empty.mpr (isEmpty_coe_sort.mp h)) exact { Homeomorph.empty with -- `c'` cannot exist: it would be the restriction of `chartAt H x` at some `x ∈ t`. mem_groupoid := fun _ c' _ ⟨_, ⟨x, _⟩, _⟩ ↦ (this.false x).elim } diff --git a/Mathlib/Geometry/Manifold/Instances/Icc.lean b/Mathlib/Geometry/Manifold/Instances/Icc.lean index c4a4d3a74709ce..ac1cf5c733ae4a 100644 --- a/Mathlib/Geometry/Manifold/Instances/Icc.lean +++ b/Mathlib/Geometry/Manifold/Instances/Icc.lean @@ -143,7 +143,7 @@ lemma contMDiffOn_projIcc : CMDiff[Icc x y] n (Set.projIcc x y h.out.le) := by lemma contMDiffOn_comp_projIcc_iff {f : Icc x y → M} : CMDiff[Icc x y] n (f ∘ (Set.projIcc x y h.out.le)) ↔ CMDiff n f := by refine ⟨fun hf ↦ ?_, fun hf ↦ hf.comp_contMDiffOn contMDiffOn_projIcc⟩ - convert hf.comp_contMDiff (contMDiff_subtype_coe_Icc (x := x) (y := y)) (fun z ↦ z.2) + convert! hf.comp_contMDiff (contMDiff_subtype_coe_Icc (x := x) (y := y)) (fun z ↦ z.2) ext z simp @@ -153,7 +153,7 @@ lemma contMDiffWithinAt_comp_projIcc_iff {f : Icc x y → M} {w : Icc x y} : fun hf ↦ hf.comp_contMDiffWithinAt_of_eq (contMDiffOn_projIcc w w.2) (by simp)⟩ have A := contMDiff_subtype_coe_Icc (x := x) (y := y) (n := n) w rw [← contMDiffWithinAt_univ] at A ⊢ - convert hf.comp _ A (fun z hz ↦ z.2) + convert! hf.comp _ A (fun z hz ↦ z.2) ext z simp @@ -162,7 +162,7 @@ lemma mdifferentiableWithinAt_comp_projIcc_iff {f : Icc x y → M} {w : Icc x y} refine ⟨fun hf ↦ ?_, fun hf ↦ ?_⟩ · have A := (contMDiff_subtype_coe_Icc (x := x) (y := y) w).mdifferentiableAt one_ne_zero rw [← mdifferentiableWithinAt_univ] at A ⊢ - convert hf.comp _ A (fun z hz ↦ z.2) + convert! hf.comp _ A (fun z hz ↦ z.2) ext z simp · have := (contMDiffOn_projIcc (x := x) (y := y) w w.2).mdifferentiableWithinAt one_ne_zero @@ -190,7 +190,7 @@ lemma mfderivWithin_comp_projIcc_one {f : Icc x y → M} {w : Icc x y} : have : w = projIcc x y h.out.le (w : ℝ) := by rw [projIcc_of_mem] rw [projIcc_of_mem _ w.2] congr 1 - convert mfderivWithin_projIcc_one w.2 + convert! mfderivWithin_projIcc_one w.2 lemma mfderiv_subtype_coe_Icc_one (z : Icc x y) : mfderiv (𝓡∂ 1) 𝓘(ℝ) (Subtype.val : Icc x y → ℝ) z 1 = 1 := by diff --git a/Mathlib/Geometry/Manifold/Instances/Sphere.lean b/Mathlib/Geometry/Manifold/Instances/Sphere.lean index 0d727ce4bc721d..e4a64c4977d88e 100644 --- a/Mathlib/Geometry/Manifold/Instances/Sphere.lean +++ b/Mathlib/Geometry/Manifold/Instances/Sphere.lean @@ -140,17 +140,18 @@ theorem stereoInvFunAux_mem (hv : ‖v‖ = 1) {w : E} (hw : w ∈ (ℝ ∙ v) theorem hasFDerivAt_stereoInvFunAux (v : E) : HasFDerivAt (stereoInvFunAux v) (ContinuousLinearMap.id ℝ E) 0 := by have h₀ : HasFDerivAt (fun w : E => ‖w‖ ^ 2) (0 : StrongDual ℝ E) 0 := by - convert (hasStrictFDerivAt_norm_sq (0 : E)).hasFDerivAt + convert! (hasStrictFDerivAt_norm_sq (0 : E)).hasFDerivAt simp only [map_zero, smul_zero] have h₁ : HasFDerivAt (fun w : E => (‖w‖ ^ 2 + 4)⁻¹) (0 : StrongDual ℝ E) 0 := by - convert (hasFDerivAt_inv _).comp _ (h₀.add (hasFDerivAt_const 4 0)) <;> simp + convert! (hasFDerivAt_inv _).comp _ (h₀.add (hasFDerivAt_const 4 0)) <;> simp have h₂ : HasFDerivAt (fun w => (4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v) ((4 : ℝ) • ContinuousLinearMap.id ℝ E) 0 := by - convert ((hasFDerivAt_const (4 : ℝ) 0).smul (hasFDerivAt_id 0)).add - ((h₀.sub (hasFDerivAt_const (4 : ℝ) 0)).smul (hasFDerivAt_const v 0)) using 1 + convert! + ((hasFDerivAt_const (4 : ℝ) 0).smul (hasFDerivAt_id 0)).add + ((h₀.sub (hasFDerivAt_const (4 : ℝ) 0)).smul (hasFDerivAt_const v 0)) using 1 ext w simp - convert h₁.smul h₂ using 1 + convert! h₁.smul h₂ using 1 ext w simp @@ -215,7 +216,7 @@ theorem stereo_left_inv (hv : ‖v‖ = 1) {x : sphere (0 : E) 1} (hx : (x : E) have hvy : ⟪v, y⟫_ℝ = 0 := Submodule.mem_orthogonal_singleton_iff_inner_right.mp y.2 have pythag : 1 = a ^ 2 + ‖y‖ ^ 2 := by have hvy' : ⟪a • v, y⟫_ℝ = 0 := by simp only [inner_smul_left, hvy, mul_zero] - convert norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero _ _ hvy' using 2 + convert! norm_add_sq_eq_norm_sq_add_norm_sq_of_inner_eq_zero _ _ hvy' using 2 · simp [← split] · simp [norm_smul, hv, ← sq, sq_abs] · exact sq _ @@ -287,7 +288,7 @@ theorem stereographic_apply_neg (v : sphere (0 : E) 1) : @[simp] theorem stereographic_neg_apply (v : sphere (0 : E) 1) : stereographic (norm_eq_of_mem_sphere (-v)) v = 0 := by - convert stereographic_apply_neg (-v) + convert! stereographic_apply_neg (-v) ext1 simp @@ -401,7 +402,9 @@ instance EuclideanSpace.instIsManifoldSphere -- Porting note: need to help with implicit variables again have H₂ := (contDiff_stereoInvFunAux (m := ω) (v := v.val) |>.comp (ℝ ∙ (v : E))ᗮ.subtypeL.contDiff).comp U.symm.contDiff - convert H₁.comp_inter (H₂.contDiffOn : ContDiffOn ℝ ω _ Set.univ) using 1 + convert! H₁.comp_inter (H₂.contDiffOn : ContDiffOn ℝ ω _ Set.univ) using 1 + -- -- squeezed from `ext, simp [sphere_ext_iff, stereographic'_symm_apply, real_inner_comm]` + -- -- squeezed from `ext, simp [sphere_ext_iff, stereographic'_symm_apply, real_inner_comm]` simp only [OpenPartialHomeomorph.trans_toPartialEquiv, OpenPartialHomeomorph.symm_toPartialEquiv, PartialEquiv.trans_source, @@ -450,7 +453,7 @@ theorem ContMDiff.codRestrict_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] {f have h : ContDiffOn ℝ ω _ Set.univ := U.contDiff.contDiffOn have H₁ := (h.comp_inter contDiffOn_stereoToFun).contMDiffOn have H₂ : CMDiff[Set.univ] m f := hf.contMDiffOn - convert (H₁.of_le le_top).comp' H₂ using 1 + convert! (H₁.of_le le_top).comp' H₂ using 1 ext x have hfxv : f x = -↑v ↔ ⟪f x, -↑v⟫_ℝ = 1 := by have hfx : ‖f x‖ = 1 := by simpa using hf' x @@ -491,16 +494,16 @@ theorem range_mfderiv_coe_sphere {n : ℕ} [Fact (finrank ℝ E = n + 1)] (v : s (ne_zero_of_mem_unit_sphere (-v))).repr suffices (fderiv ℝ ((stereoInvFunAux (-v : E) ∘ (↑)) ∘ U.symm) 0).range = (ℝ ∙ (v : E))ᗮ by - convert this using 4 + convert! this using 4 apply stereographic'_neg have : HasFDerivAt (stereoInvFunAux (-v : E) ∘ (Subtype.val : (ℝ ∙ (↑(-v) : E))ᗮ → E)) (ℝ ∙ (↑(-v) : E))ᗮ.subtypeL (U.symm 0) := by - convert hasFDerivAt_stereoInvFunAux_comp_coe (-v : E) + convert! hasFDerivAt_stereoInvFunAux_comp_coe (-v : E) simp - convert congr($((this.comp 0 U.symm.toContinuousLinearEquiv.hasFDerivAt).fderiv).range) + convert! congr($((this.comp 0 U.symm.toContinuousLinearEquiv.hasFDerivAt).fderiv).range) symm - convert + convert! (U.symm : EuclideanSpace ℝ (Fin n) ≃ₗᵢ[ℝ] (ℝ ∙ (↑(-v) : E))ᗮ).range_comp (ℝ ∙ (↑(-v) : E))ᗮ.subtype using 1 simp only [Submodule.range_subtype, coe_neg_sphere] @@ -524,11 +527,11 @@ theorem mfderiv_coe_sphere_injective {n : ℕ} [Fact (finrank ℝ E = n + 1)] (v let U := (OrthonormalBasis.fromOrthogonalSpanSingleton (𝕜 := ℝ) n (ne_zero_of_mem_unit_sphere (-v))).repr suffices Injective (fderiv ℝ ((stereoInvFunAux (-v : E) ∘ (↑)) ∘ U.symm) 0) by - convert this using 3 + convert! this using 3 apply stereographic'_neg have : HasFDerivAt (stereoInvFunAux (-v : E) ∘ (Subtype.val : (ℝ ∙ (↑(-v) : E))ᗮ → E)) (ℝ ∙ (↑(-v) : E))ᗮ.subtypeL (U.symm 0) := by - convert hasFDerivAt_stereoInvFunAux_comp_coe (-v : E) + convert! hasFDerivAt_stereoInvFunAux_comp_coe (-v : E) simp have := congr_arg DFunLike.coe <| (this.comp 0 U.symm.toContinuousLinearEquiv.hasFDerivAt).fderiv refine Eq.subst this.symm ?_ diff --git a/Mathlib/Geometry/Manifold/IntegralCurve/ExistUnique.lean b/Mathlib/Geometry/Manifold/IntegralCurve/ExistUnique.lean index e0146ddc00194e..14eb561fa4bdc6 100644 --- a/Mathlib/Geometry/Manifold/IntegralCurve/ExistUnique.lean +++ b/Mathlib/Geometry/Manifold/IntegralCurve/ExistUnique.lean @@ -57,6 +57,7 @@ variable {M : Type*} [TopologicalSpace M] [ChartedSpace H M] [IsManifold I 1 M] {γ γ' : ℝ → M} {v : (x : M) → TangentSpace I x} {s s' : Set ℝ} (t₀ : ℝ) {x₀ : M} +set_option backward.isDefEq.respectTransparency false in /-- Existence of local integral curves for a $C^1$ vector field at interior points of a `C^1` manifold. -/ theorem exists_isMIntegralCurveAt_of_contMDiffAt [CompleteSpace E] diff --git a/Mathlib/Geometry/Manifold/IntegralCurve/Transform.lean b/Mathlib/Geometry/Manifold/IntegralCurve/Transform.lean index b5401ab42f2c51..629c1472014882 100644 --- a/Mathlib/Geometry/Manifold/IntegralCurve/Transform.lean +++ b/Mathlib/Geometry/Manifold/IntegralCurve/Transform.lean @@ -50,7 +50,7 @@ lemma IsMIntegralCurveOn.comp_add (hγ : IsMIntegralCurveOn γ v s) (dt : ℝ) : lemma isMIntegralCurveOn_comp_add {dt : ℝ} : IsMIntegralCurveOn (γ ∘ (· + dt)) v { t | t + dt ∈ s } ↔ IsMIntegralCurveOn γ v s := by refine ⟨fun hγ ↦ ?_, fun hγ ↦ hγ.comp_add _⟩ - convert hγ.comp_add (-dt) + convert! hγ.comp_add (-dt) · ext t simp · simp @@ -64,14 +64,14 @@ lemma IsMIntegralCurveAt.comp_add (hγ : IsMIntegralCurveAt γ v t₀) (dt : ℝ rw [isMIntegralCurveAt_iff'] at * obtain ⟨ε, hε, h⟩ := hγ refine ⟨ε, hε, ?_⟩ - convert h.comp_add dt + convert! h.comp_add dt rw [Metric.ball] simp_rw [Metric.mem_ball, Real.dist_eq, ← sub_add, add_sub_right_comm] lemma isMIntegralCurveAt_comp_add {dt : ℝ} : IsMIntegralCurveAt (γ ∘ (· + dt)) v (t₀ - dt) ↔ IsMIntegralCurveAt γ v t₀ := by refine ⟨fun hγ ↦ ?_, fun hγ ↦ hγ.comp_add _⟩ - convert hγ.comp_add (-dt) + convert! hγ.comp_add (-dt) · ext t simp only [Function.comp_apply, neg_add_cancel_right] · simp only [sub_neg_eq_add, sub_add_cancel] @@ -88,7 +88,7 @@ lemma IsMIntegralCurve.comp_add (hγ : IsMIntegralCurve γ v) (dt : ℝ) : lemma isMIntegralCurve_comp_add {dt : ℝ} : IsMIntegralCurve (γ ∘ (· + dt)) v ↔ IsMIntegralCurve γ v := by refine ⟨fun hγ ↦ ?_, fun hγ ↦ hγ.comp_add _⟩ - convert hγ.comp_add (-dt) + convert! hγ.comp_add (-dt) ext t simp only [Function.comp_apply, neg_add_cancel_right] @@ -115,7 +115,7 @@ lemma IsMIntegralCurveOn.comp_mul (hγ : IsMIntegralCurveOn γ v s) (a : ℝ) : lemma isMIntegralCurveOn_comp_mul_ne_zero {a : ℝ} (ha : a ≠ 0) : IsMIntegralCurveOn (γ ∘ (· * a)) (a • v) { t | t * a ∈ s } ↔ IsMIntegralCurveOn γ v s := by refine ⟨fun hγ ↦ ?_, fun hγ ↦ hγ.comp_mul a⟩ - convert hγ.comp_mul a⁻¹ + convert! hγ.comp_mul a⁻¹ · ext t simp only [Function.comp_apply, mul_assoc, inv_mul_eq_div, div_self ha, mul_one] · simp only [smul_smul, inv_mul_eq_div, div_self ha, one_smul] @@ -126,7 +126,7 @@ lemma IsMIntegralCurveAt.comp_mul_ne_zero (hγ : IsMIntegralCurveAt γ v t₀) { rw [isMIntegralCurveAt_iff'] at * obtain ⟨ε, hε, h⟩ := hγ refine ⟨ε / |a|, by positivity, ?_⟩ - convert h.comp_mul a + convert! h.comp_mul a ext t rw [mem_setOf_eq, Metric.mem_ball, Metric.mem_ball, Real.dist_eq, Real.dist_eq, lt_div_iff₀ (abs_pos.mpr ha), ← abs_mul, sub_mul, div_mul_cancel₀ _ ha] @@ -134,7 +134,7 @@ lemma IsMIntegralCurveAt.comp_mul_ne_zero (hγ : IsMIntegralCurveAt γ v t₀) { lemma isMIntegralCurveAt_comp_mul_ne_zero {a : ℝ} (ha : a ≠ 0) : IsMIntegralCurveAt (γ ∘ (· * a)) (a • v) (t₀ / a) ↔ IsMIntegralCurveAt γ v t₀ := by refine ⟨fun hγ ↦ ?_, fun hγ ↦ hγ.comp_mul_ne_zero ha⟩ - convert hγ.comp_mul_ne_zero (inv_ne_zero ha) + convert! hγ.comp_mul_ne_zero (inv_ne_zero ha) · ext t simp only [Function.comp_apply, mul_assoc, inv_mul_eq_div, div_self ha, mul_one] · simp only [smul_smul, inv_mul_eq_div, div_self ha, one_smul] @@ -148,7 +148,7 @@ lemma IsMIntegralCurve.comp_mul (hγ : IsMIntegralCurve γ v) (a : ℝ) : lemma isMIntegralCurve_comp_mul_ne_zero {a : ℝ} (ha : a ≠ 0) : IsMIntegralCurve (γ ∘ (· * a)) (a • v) ↔ IsMIntegralCurve γ v := by refine ⟨fun hγ ↦ ?_, fun hγ ↦ hγ.comp_mul _⟩ - convert hγ.comp_mul a⁻¹ + convert! hγ.comp_mul a⁻¹ · ext t simp only [Function.comp_apply, mul_assoc, inv_mul_eq_div, div_self ha, mul_one] · simp only [smul_smul, inv_mul_eq_div, div_self ha, one_smul] diff --git a/Mathlib/Geometry/Manifold/IsManifold/Basic.lean b/Mathlib/Geometry/Manifold/IsManifold/Basic.lean index 06326309b3964c..b3a41ea3b8d56c 100644 --- a/Mathlib/Geometry/Manifold/IsManifold/Basic.lean +++ b/Mathlib/Geometry/Manifold/IsManifold/Basic.lean @@ -314,7 +314,7 @@ lemma _root_.Convex.convex_isRCLikeNormedField [NormedSpace ℝ E] [h : IsRCLike letI := NormedSpace.restrictScalars ℝ 𝕜 E simp only [Convex, StarConvex] at hs ⊢ intro u hu v hv a b ha hb hab - convert hs hu hv ha hb hab using 2 + convert! hs hu hv ha hb hab using 2 · rw [← @algebraMap_smul (R := ℝ) (A := 𝕜), ← @algebraMap_smul (R := ℝ) (A := 𝕜)] · rw [← @algebraMap_smul (R := ℝ) (A := 𝕜), ← @algebraMap_smul (R := ℝ) (A := 𝕜)] @@ -344,7 +344,7 @@ theorem convex_range [NormedSpace ℝ E] : Convex ℝ (range I) := by simp only [h, ↓reduceDIte, toPartialEquiv_coe] at W simp only [Convex, StarConvex] at W ⊢ intro u hu v hv a b ha hb hab - convert W hu hv ha hb hab using 2 + convert! W hu hv ha hb hab using 2 · rw [← @algebraMap_smul (R := ℝ) (A := 𝕜)] rfl · rw [← @algebraMap_smul (R := ℝ) (A := 𝕜)] diff --git a/Mathlib/Geometry/Manifold/IsManifold/ExtChartAt.lean b/Mathlib/Geometry/Manifold/IsManifold/ExtChartAt.lean index d8d869830ddd27..b2581f57d9c419 100644 --- a/Mathlib/Geometry/Manifold/IsManifold/ExtChartAt.lean +++ b/Mathlib/Geometry/Manifold/IsManifold/ExtChartAt.lean @@ -569,7 +569,7 @@ theorem isOpen_extChartAt_target [I.Boundaryless] (x : M) : IsOpen (extChartAt I /-- If we're boundaryless, `(extChartAt I x).target` is a neighborhood of the key point -/ theorem extChartAt_target_mem_nhds [I.Boundaryless] (x : M) : (extChartAt I x).target ∈ 𝓝 (extChartAt I x x) := by - convert extChartAt_target_mem_nhdsWithin x + convert! extChartAt_target_mem_nhdsWithin x simp only [I.range_eq_univ, nhdsWithin_univ] /-- If we're boundaryless, `(extChartAt I x).target` is a neighborhood of any of its points -/ diff --git a/Mathlib/Geometry/Manifold/LocalInvariantProperties.lean b/Mathlib/Geometry/Manifold/LocalInvariantProperties.lean index 4603690ac742ba..7549d6ab48b275 100644 --- a/Mathlib/Geometry/Manifold/LocalInvariantProperties.lean +++ b/Mathlib/Geometry/Manifold/LocalInvariantProperties.lean @@ -337,7 +337,7 @@ theorem liftPropOn_indep_chart [HasGroupoid M G] [HasGroupoid M' G'] (he : e ∈ (hf : f ∈ G'.maximalAtlas M') (h : LiftPropOn P g s) {y : H} (hy : y ∈ e.target ∩ e.symm ⁻¹' (s ∩ g ⁻¹' f.source)) : P (f ∘ g ∘ e.symm) (e.symm ⁻¹' s) y := by - convert ((hG.liftPropWithinAt_indep_chart he (e.symm_mapsTo hy.1) hf hy.2.2).1 (h _ hy.2.1)).2 + convert! ((hG.liftPropWithinAt_indep_chart he (e.symm_mapsTo hy.1) hf hy.2.2).1 (h _ hy.2.1)).2 rw [e.right_inv hy.1] theorem liftPropWithinAt_inter' (ht : t ∈ 𝓝[s] x) : diff --git a/Mathlib/Geometry/Manifold/MFDeriv/Atlas.lean b/Mathlib/Geometry/Manifold/MFDeriv/Atlas.lean index da0ee8ee88c2f2..513b957f83acff 100644 --- a/Mathlib/Geometry/Manifold/MFDeriv/Atlas.lean +++ b/Mathlib/Geometry/Manifold/MFDeriv/Atlas.lean @@ -293,7 +293,7 @@ lemma mfderiv_extChartAt_comp_mfderivWithin_extChartAt_symm' {x : M} (mfderiv% (extChartAt I x) y) ∘L (mfderiv[range I] (extChartAt I x).symm (extChartAt I x y)) = ContinuousLinearMap.id _ _ := by have : y = (extChartAt I x).symm (extChartAt I x y) := ((extChartAt I x).left_inv hy).symm - convert mfderiv_extChartAt_comp_mfderivWithin_extChartAt_symm ((extChartAt I x).map_source hy) + convert! mfderiv_extChartAt_comp_mfderivWithin_extChartAt_symm ((extChartAt I x).map_source hy) /-- The composition of the derivative of the inverse of `extChartAt` with the derivative of `extChartAt` gives the identity. @@ -335,7 +335,7 @@ lemma mfderivWithin_extChartAt_symm_comp_mfderiv_extChartAt' (mfderiv[range I] (extChartAt I x).symm (extChartAt I x y)) ∘L (mfderiv% (extChartAt I x) y) = ContinuousLinearMap.id _ _ := by have : y = (extChartAt I x).symm (extChartAt I x y) := ((extChartAt I x).left_inv hy).symm - convert mfderivWithin_extChartAt_symm_comp_mfderiv_extChartAt ((extChartAt I x).map_source hy) + convert! mfderivWithin_extChartAt_symm_comp_mfderiv_extChartAt ((extChartAt I x).map_source hy) lemma isInvertible_mfderivWithin_extChartAt_symm {y : E} (hy : y ∈ (extChartAt I x).target) : (mfderiv[range I] (extChartAt I x).symm y).IsInvertible := diff --git a/Mathlib/Geometry/Manifold/MFDeriv/Basic.lean b/Mathlib/Geometry/Manifold/MFDeriv/Basic.lean index d5975adcbf83fb..40e6c12f40a815 100644 --- a/Mathlib/Geometry/Manifold/MFDeriv/Basic.lean +++ b/Mathlib/Geometry/Manifold/MFDeriv/Basic.lean @@ -413,14 +413,14 @@ theorem mdifferentiableOn_iff : specialize h w this have w1 : w ∈ (chartAt H x).source := by simp only [w, hz, mfld_simps] have w2 : f w ∈ (chartAt H' y).source := by simp only [w, hz, mfld_simps] - convert ((mdifferentiableWithinAt_iff_of_mem_source w1 w2).mp h).2.mono _ + convert! ((mdifferentiableWithinAt_iff_of_mem_source w1 w2).mp h).2.mono _ · simp only [w, hz, mfld_simps] · mfld_set_tac · rintro ⟨hcont, hdiff⟩ x hx refine differentiableWithinAt_localInvariantProp.liftPropWithinAt_iff.mpr ?_ refine ⟨hcont x hx, ?_⟩ dsimp [DifferentiableWithinAtProp] - convert hdiff x (f x) (extChartAt I x x) (by simp only [hx, mfld_simps]) using 1 + convert! hdiff x (f x) (extChartAt I x x) (by simp only [hx, mfld_simps]) using 1 mfld_set_tac /-- One can reformulate smoothness on a set as continuity on this set, and smoothness in any @@ -437,7 +437,7 @@ theorem mdifferentiableOn_iff_target : constructor · refine fun h' y => ⟨?_, fun x _ => h' x y⟩ have h'' : ContinuousOn _ univ := (ModelWithCorners.continuous I').continuousOn - convert (h''.comp_inter (chartAt H' y).continuousOn_toFun).comp_inter h + convert! (h''.comp_inter (chartAt H' y).continuousOn_toFun).comp_inter h simp · exact fun h' x y => (h' y).2 x 0 @@ -514,6 +514,7 @@ theorem writtenInExtChartAt_comp (h : ContinuousWithinAt f s x) : variable {f' f₀' f₁' : TangentSpace I x →L[𝕜] TangentSpace I' (f x)} {g' : TangentSpace I' (f x) →L[𝕜] TangentSpace I'' (g (f x))} +set_option backward.isDefEq.respectTransparency false in /-- `UniqueMDiffWithinAt` achieves its goal: it implies the uniqueness of the derivative. -/ protected nonrec theorem UniqueMDiffWithinAt.eq (U : UniqueMDiffWithinAt I s x) (h : HasMFDerivWithinAt I I' f s x f') (h₁ : HasMFDerivWithinAt I I' f s x f₁') : f' = f₁' := by @@ -625,7 +626,7 @@ theorem HasMFDerivWithinAt.union (hs : HasMFDerivWithinAt I I' f s x f') (ht : HasMFDerivWithinAt I I' f t x f') : HasMFDerivWithinAt I I' f (s ∪ t) x f' := by constructor · exact ContinuousWithinAt.union hs.1 ht.1 - · convert HasFDerivWithinAt.union hs.2 ht.2 using 1 + · convert! HasFDerivWithinAt.union hs.2 ht.2 using 1 simp only [union_inter_distrib_right, preimage_union] theorem HasMFDerivWithinAt.mono_of_mem_nhdsWithin @@ -717,6 +718,7 @@ lemma mfderivWithin_of_isOpen (hs : IsOpen s) (hx : x ∈ s) : mfderivWithin I I' f s x = mfderiv I I' f x := mfderivWithin_of_mem_nhds (hs.mem_nhds hx) +set_option backward.isDefEq.respectTransparency false in theorem hasMFDerivWithinAt_insert {y : M} : HasMFDerivWithinAt I I' f (insert y s) x f' ↔ HasMFDerivWithinAt I I' f s x f' := by have : T1Space M := I.t1Space M @@ -1115,6 +1117,7 @@ theorem mfderiv_congr {f' : M → M'} (h : f = f') : variable (x) +set_option backward.isDefEq.respectTransparency false in theorem HasMFDerivWithinAt.comp (hg : HasMFDerivWithinAt I' I'' g u (f x) g') (hf : HasMFDerivWithinAt I I' f s x f') (hst : s ⊆ f ⁻¹' u) : HasMFDerivWithinAt I I'' (g ∘ f) s x (g'.comp f') := by diff --git a/Mathlib/Geometry/Manifold/MFDeriv/Defs.lean b/Mathlib/Geometry/Manifold/MFDeriv/Defs.lean index da0fe2816a112d..f7e08d8e323f6f 100644 --- a/Mathlib/Geometry/Manifold/MFDeriv/Defs.lean +++ b/Mathlib/Geometry/Manifold/MFDeriv/Defs.lean @@ -171,7 +171,7 @@ theorem differentiableWithinAt_localInvariantProp : rw [this] at h have : I (e x) ∈ I.symm ⁻¹' e.target ∩ Set.range I := by simp only [hx, mfld_simps] have := (mem_groupoid_of_pregroupoid.2 he).2.contDiffWithinAt this - convert (h.comp' _ (this.differentiableWithinAt one_ne_zero)).mono_of_mem_nhdsWithin _ + convert! (h.comp' _ (this.differentiableWithinAt one_ne_zero)).mono_of_mem_nhdsWithin _ using 1 · ext y; simp only [mfld_simps] refine @@ -192,7 +192,7 @@ theorem differentiableWithinAt_localInvariantProp : have A : (I' ∘ f ∘ I.symm) (I x) ∈ I'.symm ⁻¹' e'.source ∩ Set.range I' := by simp only [hx, mfld_simps] have := (mem_groupoid_of_pregroupoid.2 he').1.contDiffWithinAt A - convert (this.differentiableWithinAt one_ne_zero).comp _ h _ + convert! (this.differentiableWithinAt one_ne_zero).comp _ h _ · ext y; simp only [mfld_simps] · intro y hy; simp only [mfld_simps] at hy; simpa only [hy, mfld_simps] using hs hy.1 } diff --git a/Mathlib/Geometry/Manifold/MFDeriv/FDeriv.lean b/Mathlib/Geometry/Manifold/MFDeriv/FDeriv.lean index aab0e51152e1bb..453ec2e412a4a7 100644 --- a/Mathlib/Geometry/Manifold/MFDeriv/FDeriv.lean +++ b/Mathlib/Geometry/Manifold/MFDeriv/FDeriv.lean @@ -48,6 +48,7 @@ theorem ModelWithCorners.uniqueMDiffOn {H : Type*} [TopologicalSpace H] theorem writtenInExtChartAt_model_space : writtenInExtChartAt 𝓘(𝕜, E) 𝓘(𝕜, E') x f = f := rfl +set_option backward.isDefEq.respectTransparency false in theorem hasMFDerivWithinAt_iff_hasFDerivWithinAt {f'} : HasMFDerivWithinAt 𝓘(𝕜, E) 𝓘(𝕜, E') f s x f' ↔ HasFDerivWithinAt f f' s x := by simpa only [HasMFDerivWithinAt, and_iff_right_iff_imp, mfld_simps] using diff --git a/Mathlib/Geometry/Manifold/MFDeriv/NormedSpace.lean b/Mathlib/Geometry/Manifold/MFDeriv/NormedSpace.lean index 7e033b6ff09ecc..63c0f5952eda32 100644 --- a/Mathlib/Geometry/Manifold/MFDeriv/NormedSpace.lean +++ b/Mathlib/Geometry/Manifold/MFDeriv/NormedSpace.lean @@ -431,7 +431,7 @@ open Bundle PrettyPrinter Delaborator SubExpr -- There is no need to special-case any arguments which could use the T% s elaborator: -- the argument to `mvfderiv` is a vector-valued function, which a map to a total space -- can never be. -@[app_delab mvfderiv] meta def delab_mvfderiv : Delab := do +@[app_delab mvfderiv] meta def delabMVFDeriv : Delab := do whenPPOption getPPNotation do withOverApp 15 do let fs ← withAppArg delab diff --git a/Mathlib/Geometry/Manifold/MFDeriv/SpecificFunctions.lean b/Mathlib/Geometry/Manifold/MFDeriv/SpecificFunctions.lean index 7f4ad4775d421d..0695cec8e71f2c 100644 --- a/Mathlib/Geometry/Manifold/MFDeriv/SpecificFunctions.lean +++ b/Mathlib/Geometry/Manifold/MFDeriv/SpecificFunctions.lean @@ -435,7 +435,7 @@ theorem mdifferentiableOn_prod_module_iff (f : M → F₁ × F₂) : theorem mdifferentiable_prod_iff (f : M → M' × N') : MDiff f ↔ MDiff (Prod.fst ∘ f) ∧ MDiff (Prod.snd ∘ f) := - ⟨fun h ↦ ⟨h.fst, h.snd⟩, fun h ↦ by convert h.1.prodMk h.2⟩ + ⟨fun h ↦ ⟨h.fst, h.snd⟩, fun h ↦ by convert! h.1.prodMk h.2⟩ theorem mdifferentiable_prod_module_iff (f : M → F₁ × F₂) : MDifferentiable I 𝓘(𝕜, F₁ × F₂) f ↔ MDiff (Prod.fst ∘ f) ∧ MDiff (Prod.snd ∘ f) := by @@ -462,7 +462,7 @@ theorem MDifferentiableWithinAt.prodMap (hf : MDiffAt[s] f x) (hg : MDiffAt[r] g theorem MDifferentiableAt.prodMap (hf : MDiffAt f x) (hg : MDiffAt g y) : MDiffAt (Prod.map f g) (x, y) := by rw [← mdifferentiableWithinAt_univ] at * - convert hf.prodMap hg + convert! hf.prodMap hg exact univ_prod_univ.symm /-- Variant of `MDifferentiableAt.prod_map` in which the point in the product is given as `p` @@ -506,7 +506,7 @@ lemma HasMFDerivAt.prodMap {p : M × M'} {f : M → N} {g : M' → N'} HasMFDerivAt% (Prod.map f g) p ((mfderiv% f p.1).prodMap (mfderiv% g p.2)) := by simp_rw [← hasMFDerivWithinAt_univ, ← mfderivWithin_univ, ← univ_prod_univ] - convert hf.hasMFDerivWithinAt.prodMap hg.hasMFDerivWithinAt + convert! hf.hasMFDerivWithinAt.prodMap hg.hasMFDerivWithinAt · rw [mfderivWithin_univ]; exact hf.mfderiv · rw [mfderivWithin_univ]; exact hg.mfderiv @@ -587,7 +587,7 @@ theorem mfderiv_prod_eq_add {f : M × M' → M''} {p : M × M'} mdifferentiableAt_const.mfderiv_prod mdifferentiableAt_snd, mfderiv_fst, mfderiv_snd, mfderiv_const, mfderiv_const] symm - convert ContinuousLinearMap.comp_id <| mfderiv% f (p.1, p.2) + convert! ContinuousLinearMap.comp_id <| mfderiv% f (p.1, p.2) exact ContinuousLinearMap.coprod_inl_inr /-- The total derivative of a function in two variables is the sum of the partial derivatives. @@ -858,7 +858,7 @@ theorem HasMFDerivAt.neg (hf : HasMFDerivAt% f z f') : HasMFDerivAt% (-f) z (-f' ⟨hf.1.neg, hf.2.neg⟩ theorem hasMFDerivAt_neg : HasMFDerivAt% (-f) z (-f') ↔ HasMFDerivAt% f z f' := - ⟨fun hf ↦ by convert hf.neg <;> rw [neg_neg], fun hf ↦ hf.neg⟩ + ⟨fun hf ↦ by convert! hf.neg <;> rw [neg_neg], fun hf ↦ hf.neg⟩ theorem MDifferentiableWithinAt.neg {s : Set M} (hf : MDiffAt[s] f z) : MDiffAt[s] (-f) z := (hf.hasMFDerivWithinAt.neg).mdifferentiableWithinAt @@ -873,7 +873,7 @@ theorem mdifferentiableWithinAt_neg : MDiffAt[s] (-f) z ↔ MDiffAt[s] f z := ⟨fun hf ↦ by convert hf.neg; rw [neg_neg], fun hf ↦ hf.neg⟩ theorem mdifferentiableAt_neg : MDiffAt (-f) z ↔ MDiffAt f z := - ⟨fun hf ↦ by convert hf.neg; rw [neg_neg], fun hf ↦ hf.neg⟩ + ⟨fun hf ↦ by convert! hf.neg; rw [neg_neg], fun hf ↦ hf.neg⟩ theorem MDifferentiable.neg (hf : MDiff f) : MDiff (-f) := fun x ↦ (hf x).neg @@ -983,7 +983,7 @@ set_option backward.isDefEq.respectTransparency false in theorem HasMFDerivWithinAt.mul (hp : HasMFDerivWithinAt I 𝓘(𝕜, F') p s z p') (hq : HasMFDerivWithinAt I 𝓘(𝕜, F') q s z q') : HasMFDerivWithinAt I 𝓘(𝕜, F') (p * q) s z (p z • q' + q z • p' : E →L[𝕜] F') := by - convert hp.mul' hq; ext _; apply mul_comm + convert! hp.mul' hq; ext _; apply mul_comm theorem HasMFDerivAt.mul (hp : HasMFDerivAt I 𝓘(𝕜, F') p z p') (hq : HasMFDerivAt I 𝓘(𝕜, F') q z q') : @@ -1004,7 +1004,7 @@ lemma HasMFDerivWithinAt.prod [DecidableEq ι] | insert i t hi IH => rw [t.sum_insert hi, t.erase_insert hi, t.prod_insert hi, add_comm] rw [t.forall_mem_insert] at hf - convert hf.1.mul (IH hf.2) using 2 + convert! hf.1.mul (IH hf.2) using 2 · simp only [t.smul_sum, ← mul_smul] refine t.sum_congr rfl (fun j hj ↦ ?_) rw [t.erase_insert_of_ne (by grind), Finset.prod_insert (by grind)] @@ -1099,7 +1099,7 @@ variable {z : M} {F' : Type*} [NormedField F'] [NormedAlgebra 𝕜 F'] {p q : M lemma HasMFDerivWithinAt.inv (hp : HasMFDerivWithinAt I 𝓘(𝕜, F') p s z p') (hp_ne : p z ≠ 0) : HasMFDerivWithinAt I 𝓘(𝕜, F') (p⁻¹) s z (-(p z ^ 2)⁻¹ • p' : E →L[𝕜] F') := by - convert hp.inv' hp_ne + convert! hp.inv' hp_ne ext simp ring_nf @@ -1112,7 +1112,7 @@ lemma HasMFDerivWithinAt.div (hp : HasMFDerivWithinAt I 𝓘(𝕜, F') p s z p') (hq : HasMFDerivWithinAt I 𝓘(𝕜, F') q s z q') (hq_ne : q z ≠ 0) : HasMFDerivWithinAt I 𝓘(𝕜, F') (p / q) s z ((1 / q z) • p' - (p z / q z ^ 2) • q' : E →L[𝕜] F') := by - convert hp.mul (hq.inv hq_ne) using 1 + convert! hp.mul (hq.inv hq_ne) using 1 · simp [div_eq_mul_inv] · ext simp [div_eq_mul_inv] diff --git a/Mathlib/Geometry/Manifold/MFDeriv/UniqueDifferential.lean b/Mathlib/Geometry/Manifold/MFDeriv/UniqueDifferential.lean index d66c40bcd3c8d9..87483b86150d63 100644 --- a/Mathlib/Geometry/Manifold/MFDeriv/UniqueDifferential.lean +++ b/Mathlib/Geometry/Manifold/MFDeriv/UniqueDifferential.lean @@ -161,7 +161,7 @@ private lemma UniqueMDiffWithinAt.bundle_preimage_aux {p : TotalSpace F Z} ModelWithCorners.toPartialEquiv_coe_symm, PartialEquiv.refl_coe, OpenPartialHomeomorph.prod_symm, OpenPartialHomeomorph.refl_symm, OpenPartialHomeomorph.prod_apply, OpenPartialHomeomorph.refl_apply] - convert hz.1 + convert! hz.1 apply Trivialization.proj_symm_apply' exact h's hz.1 · rcases hz.2 with ⟨u, rfl⟩ diff --git a/Mathlib/Geometry/Manifold/Notation.lean b/Mathlib/Geometry/Manifold/Notation.lean index f98b3557131514..cc7ede9c610b4d 100644 --- a/Mathlib/Geometry/Manifold/Notation.lean +++ b/Mathlib/Geometry/Manifold/Notation.lean @@ -973,18 +973,20 @@ initialize registerTraceClass `Elab.DiffGeo.MDiff (inherited := true) end trace -section delaborators - /-! ### Delaborators -In this section we make sure the infoview also uses those notations. -Not all notations are supported yet. +In this section we make sure the infoview also uses the above notation. +Not all elaborators are supported yet. -/ +section delaborators + +namespace Manifold + open Bundle PrettyPrinter Delaborator SubExpr /-- Delaborator for `Bundle.TotalSpace.mk` using anonymous constructor notation. -/ -@[app_delab TotalSpace.mk] meta def delabTotalSpace_mk : Delab := do +@[app_delab TotalSpace.mk] meta def delabTotalSpaceMk : Delab := do whenPPOption getPPNotation do withOverApp 5 do let bd ← withNaryArg 3 <| delab @@ -992,7 +994,7 @@ open Bundle PrettyPrinter Delaborator SubExpr `(⟨$bd, $vd⟩) /-- Delaborator for `Bundle.TotalSpace.mk'` using anonymous constructor notation. -/ -@[app_delab Bundle.TotalSpace.mk'] meta def delabTotalSpace_mk' : Delab := do +@[app_delab Bundle.TotalSpace.mk'] meta def delabTotalSpaceMkPrime : Delab := do whenPPOption getPPNotation do withOverApp 5 do let bd ← withNaryArg 3 <| delab @@ -1001,7 +1003,7 @@ open Bundle PrettyPrinter Delaborator SubExpr /-- Delaborator for `mfderiv` using the custom elaborator, and special-casing arguments that can use the `T%` elaborator. -/ -@[app_delab mfderiv] meta def delab_mfderiv : Delab := do +@[app_delab mfderiv] meta def delabMFDeriv : Delab := do whenPPOption getPPNotation do withOverApp 21 do try @@ -1103,4 +1105,6 @@ arguments that can use the `T%` elaborator. -/ -- TODO: when adding more elaborators, also add the corresponding delaborators +end Manifold + end delaborators diff --git a/Mathlib/Geometry/Manifold/Riemannian/Basic.lean b/Mathlib/Geometry/Manifold/Riemannian/Basic.lean index 635fe49139f4cb..aac89e42f29fcd 100644 --- a/Mathlib/Geometry/Manifold/Riemannian/Basic.lean +++ b/Mathlib/Geometry/Manifold/Riemannian/Basic.lean @@ -119,7 +119,7 @@ noncomputable def riemannianMetricVectorSpace : contMDiff := by intro x rw [contMDiffAt_section] - convert contMDiffAt_const (c := innerSL ℝ) + convert! contMDiffAt_const (c := innerSL ℝ) ext v w simp [hom_trivializationAt_apply, ContinuousLinearMap.inCoordinates, TangentSpace] @@ -238,6 +238,7 @@ attribute [local instance] normedSpaceTangentSpaceVectorSpace variable (I) +set_option backward.isDefEq.respectTransparency false in lemma eventually_norm_mfderiv_extChartAt_lt (x : M) : ∃ C > 0, ∀ᶠ y in 𝓝 x, ‖mfderiv% (extChartAt I x) y‖ < C := by rcases eventually_norm_trivializationAt_lt E (fun (x : M) ↦ TangentSpace I x) x @@ -247,6 +248,7 @@ lemma eventually_norm_mfderiv_extChartAt_lt (x : M) : filter_upwards [hC, hx] with y hy h'y rwa [← TangentBundle.continuousLinearMapAt_trivializationAt h'y] +set_option backward.isDefEq.respectTransparency false in lemma eventually_enorm_mfderiv_extChartAt_lt (x : M) : ∃ C > (0 : ℝ≥0), ∀ᶠ y in 𝓝 x, ‖mfderiv% (extChartAt I x) y‖ₑ < C := by rcases eventually_norm_mfderiv_extChartAt_lt I x with ⟨C, C_pos, hC⟩ @@ -257,6 +259,7 @@ lemma eventually_enorm_mfderiv_extChartAt_lt (x : M) : simp only [enorm, nnnorm] exact_mod_cast hy +set_option backward.isDefEq.respectTransparency false in lemma eventually_norm_mfderivWithin_symm_extChartAt_comp_lt (x : M) : ∃ C > 0, ∀ᶠ y in 𝓝 x, ‖mfderiv[range I] (extChartAt I x).symm (extChartAt I x y)‖ < C := by rcases eventually_norm_symmL_trivializationAt_lt E (fun (x : M) ↦ TangentSpace I x) x @@ -267,8 +270,9 @@ lemma eventually_norm_mfderivWithin_symm_extChartAt_comp_lt (x : M) : rw [TangentBundle.symmL_trivializationAt h'y] at hy have A : (extChartAt I x).symm (extChartAt I x y) = y := (extChartAt I x).left_inv (by simpa using h'y) - convert hy using 3 <;> congr + convert! hy using 3 <;> congr +set_option backward.isDefEq.respectTransparency false in lemma eventually_norm_mfderivWithin_symm_extChartAt_lt (x : M) : ∃ C > 0, ∀ᶠ y in 𝓝[range I] (extChartAt I x x), ‖mfderiv[range I] (extChartAt I x).symm y‖ < C := by @@ -281,8 +285,9 @@ lemma eventually_norm_mfderivWithin_symm_extChartAt_lt (x : M) : extChartAt_target_mem_nhdsWithin x] with y hy h'y have : y = (extChartAt I x) ((extChartAt I x).symm y) := by simp [-extChartAt, h'y] simp only [preimage_setOf_eq, mem_setOf_eq] at hy - convert hy + convert! hy +set_option backward.isDefEq.respectTransparency false in lemma eventually_enorm_mfderivWithin_symm_extChartAt_lt (x : M) : ∃ C > (0 : ℝ≥0), ∀ᶠ y in 𝓝[range I] (extChartAt I x x), ‖mfderiv[range I] (extChartAt I x).symm y‖ₑ < C := by @@ -294,6 +299,7 @@ lemma eventually_enorm_mfderivWithin_symm_extChartAt_lt (x : M) : simp only [enorm, nnnorm] exact_mod_cast hy +set_option backward.isDefEq.respectTransparency false in /-- Around any point `x`, the Riemannian distance between two points is controlled by the distance in the extended chart. In other words, the extended chart is locally Lipschitz. -/ lemma eventually_riemannianEDist_le_edist_extChartAt (x : M) : @@ -378,6 +384,7 @@ lemma eventually_riemannianEDist_lt (x : M) {c : ℝ≥0∞} (hc : 0 < c) : · exact Or.inl (mod_cast C_pos.ne') · simp +set_option backward.isDefEq.respectTransparency false in /-- Any neighborhood of `x` contains all the points which are close enough to `x` for the Riemannian distance, `ℝ≥0` version. -/ lemma setOf_riemannianEDist_lt_subset_nhds [RegularSpace M] {x : M} {s : Set M} (hs : s ∈ 𝓝 x) : @@ -484,9 +491,9 @@ lemma setOf_riemannianEDist_lt_subset_nhds [RegularSpace M] {x : M} {s : Set M} have : γ' t₁ ∈ (extChartAt I x).symm ⁻¹' v := by apply hr rw [← Metric.eball_coe, Metric.mem_eball, edist_eq_enorm_sub] - convert this + convert! this simp [γ', hγx] - convert mem_preimage.1 this + convert! mem_preimage.1 this simp only [Function.comp_apply, γ', (extChartAt I x).left_inv <| uc <| t₁_mem (right_mem_Icc.mpr ht₁0)] diff --git a/Mathlib/Geometry/Manifold/Riemannian/PathELength.lean b/Mathlib/Geometry/Manifold/Riemannian/PathELength.lean index 07db9fb67a9f40..0d2359fcea513b 100644 --- a/Mathlib/Geometry/Manifold/Riemannian/PathELength.lean +++ b/Mathlib/Geometry/Manifold/Riemannian/PathELength.lean @@ -292,7 +292,7 @@ lemma exists_lt_locally_constant_of_riemannianEDist_lt fun_prop · intro t ht exact ⟨Real.smoothTransition.nonneg _, Real.smoothTransition.le_one _⟩ - · convert hγ using 1 + · convert! hγ using 1 rw [← A a haa', ← B b hb'b] apply pathELength_comp_of_monotoneOn hab.le · apply Monotone.monotoneOn @@ -331,7 +331,7 @@ lemma riemannianEDist_comm : riemannianEDist I x y = riemannianEDist I y x := by · exact differentiableOn_neg _ · exact h_smooth.contMDiffOn.mdifferentiableOn one_ne_zero apply this.trans_lt - convert hγ + convert! hγ ext t simp [η] @@ -355,11 +355,11 @@ lemma riemannianEDist_triangle : apply this.trans_lt (lt_trans ?_ huv) rw [← pathELength_add zero_le_one one_le_two] gcongr - · convert hγ₁ using 1 + · convert! hγ₁ using 1 apply pathELength_congr intro t ht simp [γ, ht.2] - · convert hγ₂ using 1 + · convert! hγ₂ using 1 apply pathELength_congr_Ioo intro t ht simp [γ, ht.1] diff --git a/Mathlib/Geometry/Manifold/Sheaf/Basic.lean b/Mathlib/Geometry/Manifold/Sheaf/Basic.lean index db74d6a484e841..81d13fd9a85cef 100644 --- a/Mathlib/Geometry/Manifold/Sheaf/Basic.lean +++ b/Mathlib/Geometry/Manifold/Sheaf/Basic.lean @@ -70,7 +70,7 @@ def StructureGroupoid.LocalInvariantProp.localPredicate (hG : LocalInvariantProp have : ChartedSpace.LiftPropAt P f (Opens.inclusion hUV x') := by rw [hG.liftPropAt_iff_comp_inclusion hUV] exact hU x' - convert this + convert! this /-- Let `P` be a `LocalInvariantProp` for functions between spaces with the groupoids `G`, `G'` and let `M`, `M'` be charted spaces modelled on the model spaces of those groupoids. Then there is diff --git a/Mathlib/Geometry/Manifold/Sheaf/LocallyRingedSpace.lean b/Mathlib/Geometry/Manifold/Sheaf/LocallyRingedSpace.lean index e79bf2999cef62..31a4874663c1bd 100644 --- a/Mathlib/Geometry/Manifold/Sheaf/LocallyRingedSpace.lean +++ b/Mathlib/Geometry/Manifold/Sheaf/LocallyRingedSpace.lean @@ -66,7 +66,7 @@ theorem smoothSheafCommRing.isUnit_stalk_iff {x : M} -- `x`, which is nonzero at `x` obtain ⟨U : Opens M, hxU, f : C^∞⟮IM, U; 𝓘(𝕜), 𝕜⟯, rfl⟩ := S.exists_germ_eq f have hf' : f ⟨x, hxU⟩ ≠ 0 := by - convert hf + convert! hf exact (smoothSheafCommRing.eval_germ U x hxU f).symm -- In fact, by continuity, `f` is nonzero on a neighbourhood `V` of `x` have H : ∀ᶠ (z : U) in 𝓝 ⟨x, hxU⟩, f z ≠ 0 := f.2.continuous.continuousAt.eventually_ne hf' @@ -75,7 +75,7 @@ theorem smoothSheafCommRing.isUnit_stalk_iff {x : M} let V : Opens M := ⟨Subtype.val '' V₀, U.2.isOpenMap_subtype_val V₀ hV₀⟩ have hUV : V ≤ U := Subtype.coe_image_subset (U : Set M) V₀ have hV : V₀ = Set.range (Set.inclusion hUV) := by - convert (Set.range_inclusion hUV).symm + convert! (Set.range_inclusion hUV).symm ext y change _ ↔ y ∈ Subtype.val ⁻¹' Subtype.val '' V₀ rw [Set.preimage_image_eq _ Subtype.coe_injective] @@ -83,7 +83,7 @@ theorem smoothSheafCommRing.isUnit_stalk_iff {x : M} subst hV have hxV : x ∈ (V : Set M) := by obtain ⟨x₀, hxx₀⟩ := hxV₀ - convert x₀.2 + convert! x₀.2 exact congr_arg Subtype.val hxx₀.symm have hVf : ∀ y : V, f (Set.inclusion hUV y) ≠ 0 := fun y ↦ hV₀f (Set.inclusion hUV y) (Set.mem_range_self y) @@ -94,14 +94,14 @@ theorem smoothSheafCommRing.isUnit_stalk_iff {x : M} ?_, ?_⟩, S.germ_res_apply hUV.hom x hxV f⟩ · rw [← map_mul] -- Qualified the name to avoid Lean not finding a `OneHomClass` https://github.com/leanprover-community/mathlib4/pull/8386 - convert RingHom.map_one _ + convert! RingHom.map_one _ apply Subtype.ext ext y apply mul_inv_cancel₀ exact hVf y · rw [← map_mul] -- Qualified the name to avoid Lean not finding a `OneHomClass` https://github.com/leanprover-community/mathlib4/pull/8386 - convert RingHom.map_one _ + convert! RingHom.map_one _ apply Subtype.ext ext y apply inv_mul_cancel₀ @@ -172,7 +172,7 @@ def ChartedSpace.locallyRingedSpaceMap (f : M → N) (hf : ContMDiff IM IN ∞ f prop x := by refine ⟨fun a ha ↦ ?_⟩ rw [smoothSheafCommRing.isUnit_stalk_iff, RingHom.mem_ker] at ha ⊢ - convert ha + convert! ha exact (congr($(stalkMap_locallyRingedSpaceMapAux f hf x) a)).symm @[reassoc (attr := simp)] @@ -213,7 +213,7 @@ instance (U : Opens M) : refine ⟨⟨g ∘ b.symm, ContMDiff.comp hg ?_⟩, Subtype.ext <| funext fun _ ↦ ?_⟩ · refine (ContMDiff.subtypeVal_comp_iff V' _).mp ?_ rw [← ContMDiff.subtypeVal_comp_iff] - convert contMDiff_subtype_val + convert! contMDiff_subtype_val ext x exact congr($(b.apply_symm_apply x).1) · change g _ = _ diff --git a/Mathlib/Geometry/Manifold/StructureGroupoid.lean b/Mathlib/Geometry/Manifold/StructureGroupoid.lean index ef946c8dbdbfd0..31f9f8ab53e866 100644 --- a/Mathlib/Geometry/Manifold/StructureGroupoid.lean +++ b/Mathlib/Geometry/Manifold/StructureGroupoid.lean @@ -303,7 +303,7 @@ def Pregroupoid.groupoid (PG : Pregroupoid H) : StructureGroupoid H where · refine PG.locality e.open_source fun x xu ↦ ?_ rcases he x xu with ⟨s, s_open, xs, hs⟩ refine ⟨s, s_open, xs, ?_⟩ - convert hs.1 using 1 + convert! hs.1 using 1 dsimp [OpenPartialHomeomorph.restr] rw [s_open.interior_eq] · refine PG.locality e.open_target fun x xu ↦ ?_ @@ -311,7 +311,7 @@ def Pregroupoid.groupoid (PG : Pregroupoid H) : StructureGroupoid H where refine ⟨e.target ∩ e.symm ⁻¹' s, ?_, ⟨xu, xs⟩, ?_⟩ · exact ContinuousOn.isOpen_inter_preimage e.continuousOn_invFun e.open_target s_open · rw [← inter_assoc, inter_self] - convert hs.2 using 1 + convert! hs.2 using 1 dsimp [OpenPartialHomeomorph.restr] rw [s_open.interior_eq] mem_of_eqOnSource' e e' he ee' := by @@ -320,7 +320,7 @@ def Pregroupoid.groupoid (PG : Pregroupoid H) : StructureGroupoid H where simp only [ee'.1, he.1] · have A := EqOnSource.symm' ee' apply PG.congr e'.symm.open_source A.2 - convert he.2 using 1 + convert! he.2 using 1 rw [A.1, symm_toPartialEquiv, PartialEquiv.symm_source] theorem mem_groupoid_of_pregroupoid {PG : Pregroupoid H} {e : OpenPartialHomeomorph H H} : @@ -434,7 +434,7 @@ theorem closedUnderRestriction_iff_id_le (G : StructureGroupoid H) : rw [StructureGroupoid.le_iff] rintro e ⟨s, hs, hes⟩ refine G.mem_of_eqOnSource ?_ hes - convert closedUnderRestriction' G.id_mem hs + convert! closedUnderRestriction' G.id_mem hs ext <;> simp [hs.interior_eq] · intro h constructor diff --git a/Mathlib/Geometry/Manifold/VectorBundle/LocalFrame.lean b/Mathlib/Geometry/Manifold/VectorBundle/LocalFrame.lean index ecff97d02c97fe..3983316d6b7853 100644 --- a/Mathlib/Geometry/Manifold/VectorBundle/LocalFrame.lean +++ b/Mathlib/Geometry/Manifold/VectorBundle/LocalFrame.lean @@ -367,11 +367,11 @@ lemma isLocalFrameOn_localFrame_baseSet : IsLocalFrameOn I F n (e.localFrame b) contMDiffOn i := e.contMDiffOn_localFrame_baseSet _ b i linearIndependent := by intro x hx - convert (e.basisAt b hx).linearIndependent + convert! (e.basisAt b hx).linearIndependent simp [hx, basisAt] generating := by intro x hx - convert (e.basisAt b hx).span_eq.ge + convert! (e.basisAt b hx).span_eq.ge simp [hx, basisAt] lemma _root_.contMDiffAt_localFrame_of_mem (i : ι) (hx : x ∈ e.baseSet) : diff --git a/Mathlib/Geometry/Manifold/VectorBundle/MDifferentiable.lean b/Mathlib/Geometry/Manifold/VectorBundle/MDifferentiable.lean index 2f1636e1a92737..a5e4beb9802d20 100644 --- a/Mathlib/Geometry/Manifold/VectorBundle/MDifferentiable.lean +++ b/Mathlib/Geometry/Manifold/VectorBundle/MDifferentiable.lean @@ -317,11 +317,13 @@ variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] (Z : M → Type*) [TopologicalSpace (TotalSpace F Z)] [∀ b, TopologicalSpace (Z b)] [FiberBundle F Z] [∀ b, AddCommMonoid (Z b)] [∀ b, Module 𝕜 (Z b)] [VectorBundle 𝕜 F Z] -theorem Bundle.Trivialization.mdifferentiable [ContMDiffVectorBundle 1 F Z I] +theorem mdifferentiable [ContMDiffVectorBundle 1 F Z I] (e : Trivialization F (π F Z)) [MemTrivializationAtlas e] : e.MDifferentiable (I.prod 𝓘(𝕜, F)) (I.prod 𝓘(𝕜, F)) := ⟨e.contMDiffOn.mdifferentiableOn one_ne_zero, e.contMDiffOn_symm.mdifferentiableOn one_ne_zero⟩ +@[deprecated (since := "2026-05-24")] alias Bundle.Trivialization.mdifferentiable := mdifferentiable + end end Bundle.Trivialization diff --git a/Mathlib/Geometry/Manifold/VectorBundle/Riemannian.lean b/Mathlib/Geometry/Manifold/VectorBundle/Riemannian.lean index 40e4f332dd4b50..02befed8d77f10 100644 --- a/Mathlib/Geometry/Manifold/VectorBundle/Riemannian.lean +++ b/Mathlib/Geometry/Manifold/VectorBundle/Riemannian.lean @@ -101,7 +101,7 @@ is a Riemannian bundle. -/ instance : IsContMDiffRiemannianBundle IB n F₁ (Bundle.Trivial B F₁) := by refine ⟨fun x ↦ innerSL ℝ, fun x ↦ ?_, fun x v w ↦ rfl⟩ simp only [contMDiffAt_section] - convert contMDiffAt_const (c := innerSL ℝ) + convert! contMDiffAt_const (c := innerSL ℝ) ext v w simp [hom_trivializationAt_apply, inCoordinates] diff --git a/Mathlib/Geometry/Manifold/VectorBundle/Tangent.lean b/Mathlib/Geometry/Manifold/VectorBundle/Tangent.lean index 2031dd86ca2713..b52f954aa8e8b2 100644 --- a/Mathlib/Geometry/Manifold/VectorBundle/Tangent.lean +++ b/Mathlib/Geometry/Manifold/VectorBundle/Tangent.lean @@ -170,7 +170,7 @@ lemma hasFDerivWithinAt_tangentCoordChange {x y z : M} lemma continuousOn_tangentCoordChange (x y : M) : ContinuousOn (tangentCoordChange I x y) ((extChartAt I x).source ∩ (extChartAt I y).source) := by - convert (tangentBundleCore I M).continuousOn_coordChange (achart H x) (achart H y) <;> + convert! (tangentBundleCore I M).continuousOn_coordChange (achart H x) (achart H y) <;> simp only [tangentBundleCore_baseSet, coe_achart, ← extChartAt_source I] end tangentCoordChange @@ -401,14 +401,14 @@ def tangentBundleModelSpaceHomeomorph : TangentBundle I H ≃ₜ ModelProd H E : let p : TangentBundle I H := ⟨I.symm (0 : E), (0 : E)⟩ have : Continuous (chartAt (ModelProd H E) p) := by rw [← continuousOn_univ] - convert (chartAt (ModelProd H E) p).continuousOn + convert! (chartAt (ModelProd H E) p).continuousOn simp only [mfld_simps] simpa only [mfld_simps] using this continuous_invFun := by let p : TangentBundle I H := ⟨I.symm (0 : E), (0 : E)⟩ have : Continuous (chartAt (ModelProd H E) p).symm := by rw [← continuousOn_univ] - convert (chartAt (ModelProd H E) p).symm.continuousOn + convert! (chartAt (ModelProd H E) p).symm.continuousOn simp only [mfld_simps] simpa only [mfld_simps] using this } @@ -454,7 +454,7 @@ lemma contMDiff_snd_tangentBundle_modelSpace : change ContMDiff I.tangent 𝓘(𝕜, E) n ((id Prod.snd : ModelProd H E → E) ∘ (tangentBundleModelSpaceHomeomorph I)) apply ContMDiff.comp (I' := I.prod 𝓘(𝕜, E)) - · convert contMDiff_snd + · convert! contMDiff_snd rw [chartedSpaceSelf_prod] rfl · exact contMDiff_tangentBundleModelSpaceHomeomorph @@ -469,7 +469,7 @@ lemma contMDiffWithinAt_vectorSpace_iff_contDiffWithinAt (contMDiff_snd_tangentBundle_modelSpace E 𝓘(𝕜, E)).contMDiffAt.comp_contMDiffWithinAt _ h · apply Bundle.contMDiffWithinAt_totalSpace.2 refine ⟨contMDiffWithinAt_id, ?_⟩ - convert h.contMDiffWithinAt with y + convert! h.contMDiffWithinAt with y simp /-- A vector field on a vector space is `C^n` in the manifold sense iff it is `C^n` in the vector diff --git a/Mathlib/Geometry/Manifold/VectorField/LieBracket.lean b/Mathlib/Geometry/Manifold/VectorField/LieBracket.lean index 2417b2491888a0..5bbb6dab7f2f62 100644 --- a/Mathlib/Geometry/Manifold/VectorField/LieBracket.lean +++ b/Mathlib/Geometry/Manifold/VectorField/LieBracket.lean @@ -207,6 +207,7 @@ theorem mlieBracketWithin_eventually_congr_set (h : s =ᶠ[𝓝 x] t) : mlieBracketWithin I V W s =ᶠ[𝓝 x] mlieBracketWithin I V W t := mlieBracketWithin_eventually_congr_set' x <| h.filter_mono inf_le_left +set_option backward.isDefEq.respectTransparency false in theorem _root_.Filter.EventuallyEq.mlieBracketWithin_vectorField_eq (hV : V₁ =ᶠ[𝓝[s] x] V) (hxV : V₁ x = V x) (hW : W₁ =ᶠ[𝓝[s] x] W) (hxW : W₁ x = W x) : mlieBracketWithin I V₁ W₁ s x = mlieBracketWithin I V W s x := by @@ -224,7 +225,7 @@ theorem _root_.Filter.EventuallyEq.mlieBracketWithin_vectorField_eq congr 1 · simp only [mpullbackWithin_apply] congr 1 - convert hxV <;> exact extChartAt_to_inv x + convert! hxV <;> exact extChartAt_to_inv x · apply nhdsWithin_mono _ inter_subset_left filter_upwards [(continuousAt_extChartAt_symm x).continuousWithinAt.preimage_mem_nhdsWithin'' hW (by simp)] with y hy @@ -232,7 +233,7 @@ theorem _root_.Filter.EventuallyEq.mlieBracketWithin_vectorField_eq congr 1 · simp only [mpullbackWithin_apply] congr 1 - convert hxW <;> exact extChartAt_to_inv x + convert! hxW <;> exact extChartAt_to_inv x theorem _root_.Filter.EventuallyEq.mlieBracketWithin_vectorField_eq_of_mem (hV : V₁ =ᶠ[𝓝[s] x] V) (hW : W₁ =ᶠ[𝓝[s] x] W) (hx : x ∈ s) : @@ -538,10 +539,12 @@ private lemma mpullbackWithin_mlieBracketWithin_aux [CompleteSpace E'] have : (mfderiv[range I] (extChartAt I x₀).symm (extChartAt I x₀ x₀)).inverse = mfderiv% (extChartAt I x₀) x₀ := by apply ContinuousLinearMap.inverse_eq - · convert mfderivWithin_extChartAt_symm_comp_mfderiv_extChartAt (I := I) (x := x₀) - (y := extChartAt I x₀ x₀) (by simp) - · convert mfderiv_extChartAt_comp_mfderivWithin_extChartAt_symm (I := I) (x := x₀) - (y := extChartAt I x₀ x₀) (by simp) + · convert! + mfderivWithin_extChartAt_symm_comp_mfderiv_extChartAt (I := I) (x := x₀) (y := + extChartAt I x₀ x₀) (by simp) + · convert! + mfderiv_extChartAt_comp_mfderivWithin_extChartAt_symm (I := I) (x := x₀) (y := + extChartAt I x₀ x₀) (by simp) rw [← this, ← ContinuousLinearMap.IsInvertible.inverse_comp_apply_of_right]; swap · exact isInvertible_mfderivWithin_extChartAt_symm (mem_extChartAt_target x₀) have : mfderiv[range I] (extChartAt I x₀).symm (extChartAt I x₀ x₀) = @@ -605,8 +608,8 @@ private lemma mpullbackWithin_mlieBracketWithin_aux [CompleteSpace E'] (extChartAt I' (f x₀) (f ((extChartAt I x₀).symm y)))) ∘L (mfderiv% (extChartAt I' (f x₀)) (f ((extChartAt I x₀).symm y))) = ContinuousLinearMap.id _ _ := by - convert mfderivWithin_extChartAt_symm_comp_mfderiv_extChartAt - ((PartialEquiv.map_source _ h'y)) + convert! + mfderivWithin_extChartAt_symm_comp_mfderiv_extChartAt ((PartialEquiv.map_source _ h'y)) simp only [← ContinuousLinearMap.comp_assoc, this, ContinuousLinearMap.id_comp] congr 1 exact ((mdifferentiableWithinAt_extChartAt_symm h'''y).mfderivWithin_mono huy @@ -637,7 +640,7 @@ private lemma mpullbackWithin_mlieBracketWithin_aux [CompleteSpace E'] · intro z hz simp only [comp_apply, mem_inter_iff, mem_preimage, mem_range, F] refine ⟨?_, mem_range_self _⟩ - convert hst hz.1 + convert! hst hz.1 exact PartialEquiv.left_inv (extChartAt I' (f x₀)) (ht (hst hz.1)) · rw [← nhdsWithin_eq_iff_eventuallyEq] apply le_antisymm diff --git a/Mathlib/Geometry/Manifold/VectorField/Pullback.lean b/Mathlib/Geometry/Manifold/VectorField/Pullback.lean index 650a2bab25910d..8194db30ba9664 100644 --- a/Mathlib/Geometry/Manifold/VectorField/Pullback.lean +++ b/Mathlib/Geometry/Manifold/VectorField/Pullback.lean @@ -514,7 +514,7 @@ protected lemma _root_.ContMDiffWithinAt.mpullbackWithin_vectorField' {u : Set M CMDiffAt[s] m (T% (mpullbackWithin I I' f V u)) x₀ := by have hn : 1 ≤ n := le_trans (by simp) hmn have hh : (mfderiv[s] f x₀).IsInvertible := by - convert hf' using 1 + convert! hf' using 1 exact (hf.mdifferentiableWithinAt <| by positivity).mfderivWithin_mono (hs _ hx₀) hu apply (hV.mpullbackWithin_vectorField_of_mem (hf.mono hu) hh hx₀ hs hmn hst).congr_of_eventuallyEq_of_mem _ hx₀ diff --git a/Mathlib/Geometry/Manifold/WhitneyEmbedding.lean b/Mathlib/Geometry/Manifold/WhitneyEmbedding.lean index c60acf0777322d..a1b2751b430118 100644 --- a/Mathlib/Geometry/Manifold/WhitneyEmbedding.lean +++ b/Mathlib/Geometry/Manifold/WhitneyEmbedding.lean @@ -89,7 +89,7 @@ theorem comp_embeddingPiTangent_mfderiv (x : M) (hx : x ∈ s) : (@ContinuousLinearMap.proj ℝ _ ι (fun _ => E × ℝ) _ _ (fun _ => inferInstance) (f.ind x hx)) have := L.hasMFDerivAt.comp x (f.embeddingPiTangent.contMDiff.mdifferentiableAt (by simp)).hasMFDerivAt - convert hasMFDerivAt_unique this _ + convert! hasMFDerivAt_unique this _ refine (hasMFDerivAt_extChartAt (f.mem_chartAt_ind_source x hx)).congr_of_eventuallyEq ?_ refine (f.eventuallyEq_one x hx).mono fun y hy => ?_ simp only [L, embeddingPiTangent_coe, ContinuousLinearMap.coe_comp', (· ∘ ·), diff --git a/Mathlib/Geometry/RingedSpace/Basic.lean b/Mathlib/Geometry/RingedSpace/Basic.lean index 1d5b76e45947d3..ce4c5879fe072e 100644 --- a/Mathlib/Geometry/RingedSpace/Basic.lean +++ b/Mathlib/Geometry/RingedSpace/Basic.lean @@ -136,7 +136,7 @@ def basicOpen {U : Opens X} (f : X.presheaf.obj (op U)) : Opens X where refine ⟨?_, V.2, hxV⟩ intro y hy use i.le hy - convert RingHom.isUnit_map (X.presheaf.germ _ y hy).hom hf + convert! RingHom.isUnit_map (X.presheaf.germ _ y hy).hom hf exact (X.presheaf.germ_res_apply i y hy f).symm theorem mem_basicOpen {U : Opens X} (f : X.presheaf.obj (op U)) (x : X) (hx : x ∈ U) : @@ -162,7 +162,7 @@ theorem isUnit_res_basicOpen {U : Opens X} (f : X.presheaf.obj (op U)) : IsUnit (X.presheaf.map (@homOfLE (Opens X) _ _ _ (X.basicOpen_le f)).op f) := by apply isUnit_of_isUnit_germ rintro x ⟨hxU, hx⟩ - convert hx + convert! hx exact X.presheaf.germ_res_apply _ _ _ _ @[simp] diff --git a/Mathlib/Geometry/RingedSpace/LocallyRingedSpace/HasColimits.lean b/Mathlib/Geometry/RingedSpace/LocallyRingedSpace/HasColimits.lean index 419c4f8cb04ae7..d48b644c04ed42 100644 --- a/Mathlib/Geometry/RingedSpace/LocallyRingedSpace/HasColimits.lean +++ b/Mathlib/Geometry/RingedSpace/LocallyRingedSpace/HasColimits.lean @@ -245,7 +245,8 @@ theorem coequalizer_π_stalk_isLocalHom (x : Y) : ← isUnit_map_iff (Y.presheaf.map (eqToHom hV').op).hom] -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11224): change `rw` to `erw` erw [← CommRingCat.comp_apply, ← CommRingCat.comp_apply, ← Y.presheaf.map_comp] - convert @RingedSpace.isUnit_res_basicOpen Y.toRingedSpace (unop _) + convert! + @RingedSpace.isUnit_res_basicOpen Y.toRingedSpace (unop _) (((coequalizer.π f.toShHom g.toShHom).hom.c.app (op U)) s) end HasCoequalizer diff --git a/Mathlib/Geometry/RingedSpace/OpenImmersion.lean b/Mathlib/Geometry/RingedSpace/OpenImmersion.lean index 1d2f27e67ad6cc..d0ce5b7ffb2aa8 100644 --- a/Mathlib/Geometry/RingedSpace/OpenImmersion.lean +++ b/Mathlib/Geometry/RingedSpace/OpenImmersion.lean @@ -283,7 +283,7 @@ theorem to_iso [h' : Epi f.base] : IsIso f := by dsimp only [Functor.op, Opens.map] congr exact (Set.image_preimage_eq _ ((TopCat.epi_iff_surjective _).mp h')).symm - convert H.c_iso (Opens.map f.base |>.obj <| unop U) + convert! H.c_iso (Opens.map f.base |>.obj <| unop U) have : IsIso f.c := NatIso.isIso_of_isIso_app _ apply +allowSynthFailures isIso_of_components let t : X ≃ₜ Y := H.base_open.isEmbedding.toHomeomorph.trans @@ -618,7 +618,7 @@ theorem isIso_of_subset {X Y : PresheafedSpace C} (f : X ⟶ Y) have : U = H.base_open.functor.obj ((Opens.map f.base).obj U) := by ext1 exact (Set.inter_eq_left.mpr hU).symm.trans Set.image_preimage_eq_inter_range.symm - convert H.c_iso ((Opens.map f.base).obj U) + convert! H.c_iso ((Opens.map f.base).obj U) end PresheafedSpace.IsOpenImmersion @@ -907,7 +907,7 @@ theorem image_preimage_is_empty (j : Discrete ι) (h : i ≠ j) (U : Opens (F.ob rw [ι_preservesColimitIso_hom_assoc, ι_preservesColimitIso_hom_assoc, HasColimit.isoOfNatIso_ι_hom_assoc, HasColimit.isoOfNatIso_ι_hom_assoc, TopCat.sigmaIsoSigma_hom_ι, TopCat.sigmaIsoSigma_hom_ι] at eq - convert h (congr_arg Discrete.mk (congr_arg Sigma.fst eq)) + convert! h (congr_arg Discrete.mk (congr_arg Sigma.fst eq)) set_option backward.isDefEq.respectTransparency false in instance sigma_ι_isOpenImmersion_aux [HasStrictTerminalObjects C] : @@ -924,11 +924,11 @@ instance sigma_ι_isOpenImmersion_aux [HasStrictTerminalObjects C] : (colimit.ι (F ⋙ SheafedSpace.forgetToPresheafedSpace) i ≫ (preservesColimitIso SheafedSpace.forgetToPresheafedSpace F).inv).base := by have := h₁.symm - convert sigma_ι_isOpenEmbedding F i + convert! sigma_ι_isOpenEmbedding F i suffices IsIso <| (colimit.ι (F ⋙ SheafedSpace.forgetToPresheafedSpace) i ≫ (preservesColimitIso SheafedSpace.forgetToPresheafedSpace F).inv).c.app <| op (H.functor.obj U) by - convert this + convert! this rw [PresheafedSpace.comp_c_app, ← PresheafedSpace.colimitPresheafObjIsoComponentwiseLimit_hom_π] -- Porting note: this instance created manually to make the `inferInstance` below work @@ -940,8 +940,8 @@ instance sigma_ι_isOpenImmersion_aux [HasStrictTerminalObjects C] : apply limit_π_isIso_of_is_strict_terminal rintro ⟨j⟩ hj dsimp - convert (F.obj j).sheaf.isTerminalOfEmpty using 3 - convert image_preimage_is_empty F i j (fun h => hj (congr_arg op h.symm)) U using 6 + convert! (F.obj j).sheaf.isTerminalOfEmpty using 3 + convert! image_preimage_is_empty F i j (fun h => hj (congr_arg op h.symm)) U using 6 exact congr_arg PresheafedSpace.Hom.base h₁ set_option backward.isDefEq.respectTransparency false in @@ -954,7 +954,7 @@ instance sigma_ι_isOpenImmersion {ι : Type w} [Small.{v} ι] have : colimit.ι F i = (colimit.ι F i ≫ (HasColimit.isoOfEquivalence f (Iso.refl _)).inv) ≫ (HasColimit.isoOfEquivalence f (Iso.refl _)).hom := by simp - rw [this, HasColimit.isoOfEquivalence_inv_π] + rw [this, HasColimit.ι_isoOfEquivalence_inv] infer_instance end Prod diff --git a/Mathlib/Geometry/RingedSpace/PresheafedSpace/Gluing.lean b/Mathlib/Geometry/RingedSpace/PresheafedSpace/Gluing.lean index 9ab7b6f40b6d4f..ccf902adb37af0 100644 --- a/Mathlib/Geometry/RingedSpace/PresheafedSpace/Gluing.lean +++ b/Mathlib/Geometry/RingedSpace/PresheafedSpace/Gluing.lean @@ -163,7 +163,7 @@ theorem f_invApp_f_app (i j k : D.J) (U : Opens (D.V (i, j)).carrier) : erw [(π₁ i, j, k).c.naturality_assoc, reassoc_of% this, ← Functor.map_comp_assoc, IsOpenImmersion.inv_naturality_assoc, IsOpenImmersion.app_invApp_assoc, ← (D.V (i, k)).presheaf.map_comp, ← (D.V (i, k)).presheaf.map_comp] - convert (Category.comp_id _).symm + convert! (Category.comp_id _).symm erw [(D.V (i, k)).presheaf.map_id] rfl @@ -395,7 +395,7 @@ theorem ιInvApp_π {i : D.J} (U : Opens (D.U i).carrier) : simp only [SetLike.mem_coe, unop_op, Set.mem_preimage, Set.mem_image] refine ⟨fun h => ⟨_, h, rfl⟩, ?_⟩ rintro ⟨y, h1, h2⟩ - convert h1 using 1 + convert! h1 using 1 delta ι Multicoequalizer.π at h2 apply_fun (D.ι _).base · exact h2.symm @@ -444,7 +444,7 @@ theorem π_ιInvApp_π (i j : D.J) (U : Opens (D.U i).carrier) : iterate 3 rw [← Functor.map_comp_assoc] rw [NatTrans.naturality_assoc] erw [← (D.V (i, j)).presheaf.map_comp] - convert + convert! limit.w (componentwiseDiagram 𝖣.diagram.multispan _) (Quiver.Hom.op (WalkingMultispan.Hom.fst (i, j))) · rw [Category.comp_id] diff --git a/Mathlib/GroupTheory/ArchimedeanDensely.lean b/Mathlib/GroupTheory/ArchimedeanDensely.lean index bb5164b750ff67..33f0079d4fc41e 100644 --- a/Mathlib/GroupTheory/ArchimedeanDensely.lean +++ b/Mathlib/GroupTheory/ArchimedeanDensely.lean @@ -166,7 +166,7 @@ lemma Subgroup.isLeast_of_closure_iff_eq_mabs {a b : G} : rcases key with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ <;> simp [this.right.le, this.right, mabs] · wlog ha : 1 ≤ a generalizing a - · convert @this (a⁻¹) ?_ (by simpa using le_of_not_ge ha) using 4 + · convert! @this (a⁻¹) ?_ (by simpa using le_of_not_ge ha) using 4 · simp · rwa [mabs_inv] rw [mabs, sup_eq_left.mpr ((inv_le_one'.mpr ha).trans ha)] at h diff --git a/Mathlib/GroupTheory/ClassEquation.lean b/Mathlib/GroupTheory/ClassEquation.lean index cde16a2e95a5de..6b69eb69ac92d2 100644 --- a/Mathlib/GroupTheory/ClassEquation.lean +++ b/Mathlib/GroupTheory/ClassEquation.lean @@ -42,8 +42,7 @@ theorem Group.sum_card_conj_classes_eq_card [Finite G] : ∑ᶠ x : ConjClasses G, x.carrier.ncard = Nat.card G := by classical cases nonempty_fintype G - rw [Nat.card_eq_fintype_card, ← sum_conjClasses_card_eq_card, finsum_eq_sum_of_fintype] - simp [Set.ncard_eq_toFinset_card'] + simp [← sum_conjClasses_card_eq_card, finsum_eq_sum_of_fintype] /-- The **class equation** for finite groups. The cardinality of a group is equal to the size of its center plus the sum of the size of all its nontrivial conjugacy classes. -/ @@ -56,7 +55,7 @@ theorem Group.nat_card_center_add_sum_card_noncenter_eq_card [Finite G] : simp only [Nat.card_eq_fintype_card, Set.toFinset_card] congr 1 swap - · convert finsum_cond_eq_sum_of_cond_iff _ _ + · convert! finsum_cond_eq_sum_of_cond_iff _ _ simp [Set.mem_toFinset] calc Fintype.card (Subgroup.center G) = Fintype.card ((noncenter G)ᶜ : Set _) := @@ -76,7 +75,7 @@ theorem Group.card_center_add_sum_card_noncenter_eq_card (G) [Group G] [∀ x : ConjClasses G, Fintype x.carrier] [Fintype G] [Fintype <| Subgroup.center G] [Fintype <| noncenter G] : Fintype.card (Subgroup.center G) + ∑ x ∈ (noncenter G).toFinset, x.carrier.toFinset.card = Fintype.card G := by - convert Group.nat_card_center_add_sum_card_noncenter_eq_card G using 2 + convert! Group.nat_card_center_add_sum_card_noncenter_eq_card G using 2 · simp · rw [← finsum_set_coe_eq_finsum_mem (noncenter G), finsum_eq_sum_of_fintype, ← Finset.sum_set_coe] diff --git a/Mathlib/GroupTheory/Commutator/Basic.lean b/Mathlib/GroupTheory/Commutator/Basic.lean index 7fcf19a1b0d8d9..a6d35672103bf4 100644 --- a/Mathlib/GroupTheory/Commutator/Basic.lean +++ b/Mathlib/GroupTheory/Commutator/Basic.lean @@ -70,6 +70,16 @@ theorem map_commutatorElement : (f ⁅g₁, g₂⁆ : G') = ⁅f g₁, f g₂⁆ theorem conjugate_commutatorElement : g₃ * ⁅g₁, g₂⁆ * g₃⁻¹ = ⁅g₃ * g₁ * g₃⁻¹, g₃ * g₂ * g₃⁻¹⁆ := by simp [mul_assoc, commutatorElement_def] +@[to_additive] +theorem commutatorElement_mul_left_eq_conj_mul (a b c : G) : + ⁅a * b, c⁆ = a * ⁅b, c⁆ * a⁻¹ * ⁅a, c⁆ := by + simp [mul_assoc, commutatorElement_def] + +@[to_additive] +theorem commutatorElement_mul_right_eq_mul_conj (a b c : G) : + ⁅a, b * c⁆ = ⁅a, b⁆ * b * ⁅a, c⁆ * b⁻¹ := by + simp [mul_assoc, commutatorElement_def] + namespace Subgroup /-- The commutator of two subgroups `H₁` and `H₂`. -/ @@ -82,7 +92,7 @@ theorem commutator_def (H₁ H₂ : Subgroup G) : ⁅H₁, H₂⁆ = closure { g | ∃ g₁ ∈ H₁, ∃ g₂ ∈ H₂, ⁅g₁, g₂⁆ = g } := rfl -variable {g₁ g₂ g₃} {H H₁ H₂ H₃ K₁ K₂ : Subgroup G} +variable {g₁ g₂ g₃} {H H₁ H₂ H₃ K K₁ K₂ : Subgroup G} @[to_additive] theorem commutator_mem_commutator (h₁ : g₁ ∈ H₁) (h₂ : g₂ ∈ H₂) : ⁅g₁, g₂⁆ ∈ ⁅H₁, H₂⁆ := @@ -165,6 +175,16 @@ theorem commutator_top_left_le_iff : ⁅(⊤ : Subgroup G), H⁆ ≤ H ↔ H.Nor theorem commutator_top_right_le_iff : ⁅H, ⊤⁆ ≤ H ↔ H.Normal := commutator_comm H ⊤ ▸ commutator_top_left_le_iff +@[to_additive] +theorem le_normalizer_iff_commutator_le_right : H ≤ normalizer K ↔ ⁅H, K⁆ ≤ K := by + refine le_normalizer_iff.trans ⟨fun hH ↦ ?_, fun hH h hh k hk ↦ ?_⟩ + · exact commutator_le.mpr fun h hh k hk ↦ mul_mem (hH h hh k hk) (inv_mem hk) + · exact (mul_mem_cancel_right <| inv_mem hk).mp <| hH <| commutator_mem_commutator hh hk + +@[to_additive] +theorem le_normalizer_iff_commutator_le_left : H ≤ normalizer K ↔ ⁅K, H⁆ ≤ K := + commutator_comm H K ▸ le_normalizer_iff_commutator_le_right + @[to_additive (attr := simp)] theorem commutator_bot_left : ⁅(⊥ : Subgroup G), H₁⁆ = ⊥ := le_bot_iff.mp (commutator_le_left ⊥ H₁) @@ -179,6 +199,28 @@ theorem commutator_le_inf [Normal H₁] [Normal H₂] : ⁅H₁, H₂⁆ ≤ H end Normal +@[to_additive] +theorem commutator_le_sup : ⁅H₁, H₂⁆ ≤ H₁ ⊔ H₂ := + commutator_le.mpr <| by grind [mul_assoc, mul_mem, mul_mem_sup, inv_mem] + +@[to_additive] +theorem normalizer_commutator_ge_left : H₁ ≤ normalizer (⁅H₁, H₂⁆ : Subgroup G) := by + apply le_normalizer_closure_iff.mpr + rintro g hg _ ⟨g₁, hg₁, g₂, hg₂, rfl⟩ + apply (mul_mem_cancel_right <| commutator_mem_commutator hg hg₂).mp + rw [← commutatorElement_mul_left_eq_conj_mul g g₁ g₂] + exact commutator_mem_commutator (mul_mem hg hg₁) hg₂ + +@[to_additive] +theorem normalizer_commutator_ge_right : H₂ ≤ normalizer (⁅H₁, H₂⁆ : Subgroup G) := by + rw [commutator_comm] + apply normalizer_commutator_ge_left + +@[to_additive] +instance normal_subgroupOf_commutator_sup : (⁅H₁, H₂⁆.subgroupOf <| H₁ ⊔ H₂).Normal := + normal_subgroupOf_of_le_normalizer <| sup_le + (normalizer_commutator_ge_left H₁ H₂) (normalizer_commutator_ge_right H₁ H₂) + @[to_additive] theorem map_commutator (f : G →* G') : map f ⁅H₁, H₂⁆ = ⁅map f H₁, map f H₂⁆ := by simp_rw [le_antisymm_iff, map_le_iff_le_comap, commutator_le, mem_comap, map_commutatorElement] diff --git a/Mathlib/GroupTheory/Complement.lean b/Mathlib/GroupTheory/Complement.lean index cc978efcf9a40c..1a64cb08eb93a1 100644 --- a/Mathlib/GroupTheory/Complement.lean +++ b/Mathlib/GroupTheory/Complement.lean @@ -196,7 +196,7 @@ theorem isComplement'_top_right : IsComplement' H ⊤ ↔ H = ⊥ := @[to_additive] lemma isComplement_iff_existsUnique_inv_mul_mem : IsComplement S T ↔ ∀ g, ∃! s : S, (s : G)⁻¹ * g ∈ T := by - convert isComplement_iff_existsUnique with g + convert! isComplement_iff_existsUnique with g constructor <;> rintro ⟨x, hx, hx'⟩ · exact ⟨(x, ⟨_, hx⟩), by simp, by aesop⟩ · exact ⟨x.1, by simp [← hx], fun y hy ↦ (Prod.ext_iff.1 <| by simpa using hx' (y, ⟨_, hy⟩)).1⟩ @@ -204,7 +204,7 @@ lemma isComplement_iff_existsUnique_inv_mul_mem : @[to_additive] lemma isComplement_iff_existsUnique_mul_inv_mem : IsComplement S T ↔ ∀ g, ∃! t : T, g * (t : G)⁻¹ ∈ S := by - convert isComplement_iff_existsUnique with g + convert! isComplement_iff_existsUnique with g constructor <;> rintro ⟨x, hx, hx'⟩ · exact ⟨(⟨_, hx⟩, x), by simp, by aesop⟩ · exact ⟨x.2, by simp [← hx], fun y hy ↦ (Prod.ext_iff.1 <| by simpa using hx' (⟨_, hy⟩, y)).2⟩ diff --git a/Mathlib/GroupTheory/Congruence/BigOperators.lean b/Mathlib/GroupTheory/Congruence/BigOperators.lean index f93b1cc3175b03..994b3f3536c1fa 100644 --- a/Mathlib/GroupTheory/Congruence/BigOperators.lean +++ b/Mathlib/GroupTheory/Congruence/BigOperators.lean @@ -7,8 +7,12 @@ module public import Mathlib.Algebra.BigOperators.Group.Multiset.Basic public import Mathlib.Algebra.BigOperators.Group.List.Lemmas -public import Mathlib.GroupTheory.Congruence.Defs public import Mathlib.Algebra.BigOperators.Group.Finset.Defs +public import Mathlib.Algebra.BigOperators.Finsupp.Basic +public import Mathlib.Data.DFinsupp.BigOperators +public import Mathlib.GroupTheory.Congruence.Defs + +import Mathlib.GroupTheory.Congruence.Basic /-! # Interactions between `∑, ∏` and `(Add)Con` @@ -45,6 +49,44 @@ protected theorem finsetProd {ι M : Type*} [CommMonoid M] (c : Con M) (s : Fins c (s.prod f) (s.prod g) := c.multiset_prod h +@[to_additive] +protected theorem finsuppProd {ι : Type*} {β : Type*} {M : Type*} + [CommMonoid M] [Zero β] + (c : Con M) (h : ι → β → M) (h' : ι → β → M) + {f g : ι →₀ β} (hf : ∀ i, c (h i 0) 1) (hf' : ∀ i, c (h' i 0) 1) + (H : ∀ i, c (h i (f i)) (h' i (g i))) : + c (f.prod h) (g.prod h') := by + refine Quotient.exact (show c.mk' _ = c.mk' _ from ?_) + rw [map_finsuppProd, map_finsuppProd] + classical + exact Finsupp.prod_congr_of_eq_on_union + (fun _ _ => Quotient.sound <| H _) + (fun _ _ => Quotient.sound <| hf _) (fun _ _ => Quotient.sound <| hf' _) + +@[to_additive] +protected theorem dfinsuppProd {ι : Type*} {β : ι → Type*} {M : Type*} + [DecidableEq ι] [CommMonoid M] [∀ i, Zero (β i)] [∀ i (y : β i), Decidable (y ≠ 0)] + (c : Con M) (h : (i : ι) → β i → M) (h' : (i : ι) → β i → M) + {f g : Π₀ i, β i} (hf : ∀ i, c (h i 0) 1) (hf' : ∀ i, c (h' i 0) 1) + (H : ∀ i, c (h i (f i)) (h' i (g i))) : + c (f.prod h) (g.prod h') := by + refine Quotient.exact (show c.mk' _ = c.mk' _ from ?_) + rw [map_dfinsuppProd, map_dfinsuppProd] + classical + exact DFinsupp.prod_congr_of_eq_on_union + (fun _ _ => Quotient.sound <| H _) + (fun _ _ => Quotient.sound <| hf _) (fun _ _ => Quotient.sound <| hf' _) + +protected theorem _root_.AddCon.dfinsuppSumAddHom {ι : Type*} {β : ι → Type*} {M : Type*} + [DecidableEq ι] [AddCommMonoid M] [∀ i, AddCommMonoid (β i)] + (c : AddCon M) (h : (i : ι) → β i →+ M) (h' : (i : ι) → β i →+ M) {f g : Π₀ i, β i} + (H : ∀ i, c (h i (f i)) (h' i (g i))) : + c (f.sumAddHom h) (g.sumAddHom h') := by + classical + simp_rw [DFinsupp.sumAddHom_apply] + exact c.dfinsuppSum _ _ + (bot_le (a := c) <| map_zero <| h ·) (bot_le (a := c) <| map_zero <| h' ·) H + @[deprecated (since := "2026-04-08")] protected alias _root_.AddCon.finset_sum := AddCon.finsetSum diff --git a/Mathlib/GroupTheory/Coset/Basic.lean b/Mathlib/GroupTheory/Coset/Basic.lean index 0437c2e2a3084d..fbfae8c16c679c 100644 --- a/Mathlib/GroupTheory/Coset/Basic.lean +++ b/Mathlib/GroupTheory/Coset/Basic.lean @@ -285,7 +285,7 @@ theorem strictMono_comap_prod_image : refine fun t₁ t₂ h ↦ ⟨⟨Subgroup.comap_mono h.1, Set.image_mono h.1⟩, mt (fun ⟨le1, le2⟩ a ha ↦ ?_) h.2⟩ obtain ⟨a', h', eq⟩ := le2 ⟨_, ha, rfl⟩ - convert ← t₁.mul_mem h' (@le1 ⟨_, QuotientGroup.eq.1 eq⟩ <| t₂.mul_mem (t₂.inv_mem <| h.1 h') ha) + convert! ← t₁.mul_mem h' (@le1 ⟨_, QuotientGroup.eq.1 eq⟩ <| t₂.mul_mem (t₂.inv_mem <| h.1 h') ha) apply mul_inv_cancel_left variable {s} {a b : α} diff --git a/Mathlib/GroupTheory/Coset/Card.lean b/Mathlib/GroupTheory/Coset/Card.lean index cc0791975027ad..56fd7b146f712a 100644 --- a/Mathlib/GroupTheory/Coset/Card.lean +++ b/Mathlib/GroupTheory/Coset/Card.lean @@ -60,7 +60,7 @@ lemma card_mul_eq_card_subgroup_mul_card_quotient (s : Subgroup α) (t : Set α) rw [← Nat.card_prod, Nat.card_congr] apply Equiv.trans _ (QuotientGroup.preimageMkEquivSubgroupProdSet _ _) rw [QuotientGroup.preimage_image_mk] - convert Equiv.refl ↑(t * s) + convert! Equiv.refl ↑(t * s) aesop (add simp [Set.mem_mul]) /-- **Lagrange's Theorem**: The order of a subgroup divides the order of its ambient group. -/ diff --git a/Mathlib/GroupTheory/Coxeter/Inversion.lean b/Mathlib/GroupTheory/Coxeter/Inversion.lean index 89718224b961a6..43ab142b541a9a 100644 --- a/Mathlib/GroupTheory/Coxeter/Inversion.lean +++ b/Mathlib/GroupTheory/Coxeter/Inversion.lean @@ -138,7 +138,7 @@ theorem isRightInversion_inv_iff {w t : W} : theorem isLeftInversion_inv_iff {w t : W} : cs.IsLeftInversion w⁻¹ t ↔ cs.IsRightInversion w t := by - convert cs.isRightInversion_inv_iff.symm + convert! cs.isRightInversion_inv_iff.symm simp namespace IsReflection diff --git a/Mathlib/GroupTheory/DivisibleHull.lean b/Mathlib/GroupTheory/DivisibleHull.lean index 21eaebe088f68c..478bdce543d11d 100644 --- a/Mathlib/GroupTheory/DivisibleHull.lean +++ b/Mathlib/GroupTheory/DivisibleHull.lean @@ -143,7 +143,7 @@ theorem nsmul_mk (a : ℕ) (m : M) (s : ℕ+) : a • mk m s = mk (a • m) s := theorem nnqsmul_mk (a : ℚ≥0) (m : M) (s : ℕ+) : a • mk m s = mk (a.num • m) (⟨a.den, a.den_pos⟩ * s) := by - convert LocalizedModule.mk'_smul_mk ℚ≥0 a.num m ⟨a.den, by simp⟩ (↑ⁿ s) + convert! LocalizedModule.mk'_smul_mk ℚ≥0 a.num m ⟨a.den, by simp⟩ (↑ⁿ s) simp [IsLocalization.eq_mk'_iff_mul_eq] section TorsionFree @@ -223,7 +223,7 @@ instance : Module ℚ (DivisibleHull M) where use 1 suffices ((a + b).num * a.den * b.den * (s * s)) • m = ((a.num * b.den + b.num * a.den) * (a + b).den * (s * s)) • m by - convert this using 1 + convert! this using 1 all_goals simp [← natCast_zsmul, smul_smul, ← add_smul] ring_nf @@ -233,7 +233,7 @@ instance : Module ℚ (DivisibleHull M) where simp_rw [qsmul_mk, mk_eq_mk] use 1 suffices ((a * b).num * a.den * b.den * s) • m = (a.num * b.num * (a * b).den * s) • m by - convert this using 1 + convert! this using 1 all_goals simp [← natCast_zsmul, smul_smul] ring_nf @@ -253,7 +253,7 @@ private theorem lift_aux (m n m' n' : M) (s t s' t' : ℕ+) (t.val • m ≤ s.val • n) = (t'.val • m' ≤ s'.val • n') := by rw [mk_eq_mk_iff_smul_eq_smul] at h h' rw [propext_iff, ← nsmul_le_nsmul_iff_right (mul_ne_zero s'.ne_zero t'.ne_zero)] - convert (nsmul_le_nsmul_iff_right (M := M) (mul_ne_zero s.ne_zero t.ne_zero)) using 2 + convert! (nsmul_le_nsmul_iff_right (M := M) (mul_ne_zero s.ne_zero t.ne_zero)) using 2 · simp_rw [smul_smul, mul_rotate s'.val, ← smul_smul, h, smul_smul] ring_nf · simp_rw [smul_smul, ← mul_rotate s'.val, ← smul_smul, ← h', smul_smul] @@ -310,7 +310,7 @@ instance : IsOrderedCancelAddMonoid (DivisibleHull M) := simp_rw [PNat.mul_coe, mul_smul, smul_add, smul_smul] have := add_lt_add_right (nsmul_lt_nsmul_right (sa * sa).ne_zero h) ((sa * sb * sc.val) • ma) simp_rw [PNat.mul_coe, smul_smul] at this - convert this using 3 <;> ring) + convert! this using 3 <;> ring) instance : IsStrictOrderedModule ℚ≥0 (DivisibleHull M) where smul_lt_smul_of_pos_left a ha b c h := by @@ -324,7 +324,7 @@ instance : IsStrictOrderedModule ℚ≥0 (DivisibleHull M) where induction a with | mk m s simp_rw [nnqsmul_mk, mk_lt_mk, smul_smul, PNat.mul_coe, PNat.mk_coe] refine smul_lt_smul_of_pos_right ?_ ?_ - · convert mul_lt_mul_of_pos_right (NNRat.lt_def.mp h) (show 0 < s.val by simp) using 1 <;> ring + · convert! mul_lt_mul_of_pos_right (NNRat.lt_def.mp h) (show 0 < s.val by simp) using 1 <;> ring · rw [← mk_zero 1, mk_lt_mk] at ha simpa using ha diff --git a/Mathlib/GroupTheory/Finiteness.lean b/Mathlib/GroupTheory/Finiteness.lean index 9d59e20a9f5827..b23c7420082cfc 100644 --- a/Mathlib/GroupTheory/Finiteness.lean +++ b/Mathlib/GroupTheory/Finiteness.lean @@ -75,7 +75,7 @@ theorem Submonoid.fg_iff_add_fg (P : Submonoid M) : P.FG ↔ P.toAddSubmonoid.FG theorem AddSubmonoid.fg_iff_mul_fg {M : Type*} [AddMonoid M] (P : AddSubmonoid M) : P.FG ↔ P.toSubmonoid.FG := by - convert (Submonoid.fg_iff_add_fg (toSubmonoid P)).symm + convert! (Submonoid.fg_iff_add_fg (toSubmonoid P)).symm @[to_additive] theorem Submonoid.FG.bot : FG (⊥ : Submonoid M) := diff --git a/Mathlib/GroupTheory/FreeAbelianGroup.lean b/Mathlib/GroupTheory/FreeAbelianGroup.lean index 86c2d955ee513e..fbbabf07e4941e 100644 --- a/Mathlib/GroupTheory/FreeAbelianGroup.lean +++ b/Mathlib/GroupTheory/FreeAbelianGroup.lean @@ -122,8 +122,7 @@ open FreeAbelianGroup -- Porting note: needed to add `(β := Multiplicative β)` @[simp] theorem lift_apply_of (x : α) : lift f (of x) = f x := by - convert Abelianization.lift_apply_of - (FreeGroup.lift f (β := Multiplicative β)) (FreeGroup.of x) + convert! Abelianization.lift_apply_of (FreeGroup.lift f (β := Multiplicative β)) (FreeGroup.of x) exact (FreeGroup.lift_apply_of (β := Multiplicative β)).symm theorem lift_unique (g : FreeAbelianGroup α →+ β) (hg : ∀ x, g (of x) = f x) {x} : diff --git a/Mathlib/GroupTheory/FreeGroup/NielsenSchreier.lean b/Mathlib/GroupTheory/FreeGroup/NielsenSchreier.lean index 23ac03c96b7442..9f238a21620d71 100644 --- a/Mathlib/GroupTheory/FreeGroup/NielsenSchreier.lean +++ b/Mathlib/GroupTheory/FreeGroup/NielsenSchreier.lean @@ -128,7 +128,7 @@ instance actionGroupoidIsFree {G A : Type u} [Group G] [IsFreeGroup G] [MulActio apply uF' intro e ext - · convert hE _ _ _ + · convert! hE _ _ _ rfl · rfl apply Functor.hext diff --git a/Mathlib/GroupTheory/Goursat.lean b/Mathlib/GroupTheory/Goursat.lean index 42bf3ae9057a16..1a630276856a2a 100644 --- a/Mathlib/GroupTheory/Goursat.lean +++ b/Mathlib/GroupTheory/Goursat.lean @@ -168,7 +168,7 @@ lemma goursat : rintro h₁ hgh₁ g₁ hg₁h g₂ h₂ hg₂h₂ hP hQ simp only [Subtype.ext_iff] at hP hQ rwa [← hP, ← hQ] - · convert goursatFst_prod_goursatSnd_le (P.prod Q).range + · convert! goursatFst_prod_goursatSnd_le (P.prod Q).range ext ⟨g, h⟩ simp_rw [G', H', MonoidHom.mem_ker, MonoidHom.coe_prodMap, Prod.map_apply, Subgroup.mem_prod, Prod.one_eq_mk, Prod.ext_iff, ← MonoidHom.mem_ker, QuotientGroup.ker_mk'] diff --git a/Mathlib/GroupTheory/GroupAction/Basic.lean b/Mathlib/GroupTheory/GroupAction/Basic.lean index f58d71f8745951..f1fc4983ff66de 100644 --- a/Mathlib/GroupTheory/GroupAction/Basic.lean +++ b/Mathlib/GroupTheory/GroupAction/Basic.lean @@ -248,6 +248,7 @@ lemma _root_.isCancelSMul_iff_stabilizer_eq_bot : simp [isCancelSMul_iff_eq_one_of_smul_eq, Subgroup.eq_bot_iff_forall, forall_comm (α := G)] /-- If the stabilizer of `a` is `S`, then the stabilizer of `g • a` is `gSg⁻¹`. -/ +@[to_additive /-- If the stabilizer of `a` is `S`, then the stabilizer of `g +ᵥ a` is `g+S-g`. -/] theorem stabilizer_smul_eq_stabilizer_map_conj (g : G) (a : α) : stabilizer G (g • a) = (stabilizer G a).map (MulAut.conj g).toMonoidHom := by ext h @@ -257,40 +258,48 @@ theorem stabilizer_smul_eq_stabilizer_map_conj (g : G) (a : α) : variable {g h k : G} {a b c : α} /-- The natural group equivalence between the stabilizers of two elements in the same orbit. -/ +@[to_additive /-- The isomorphism between the stabilizers of two elements in the same orbit. -/] def stabilizerEquivStabilizer (hg : b = g • a) : stabilizer G a ≃* stabilizer G b := ((MulAut.conj g).subgroupMap (stabilizer G a)).trans (MulEquiv.subgroupCongr (by rw [hg, stabilizer_smul_eq_stabilizer_map_conj g a, ← MulEquiv.toMonoidHom_eq_coe])) +@[to_additive] theorem stabilizerEquivStabilizer_apply (hg : b = g • a) (x : stabilizer G a) : stabilizerEquivStabilizer hg x = MulAut.conj g x := by simp [stabilizerEquivStabilizer] +@[to_additive] theorem stabilizerEquivStabilizer_symm_apply (hg : b = g • a) (x : stabilizer G b) : (stabilizerEquivStabilizer hg).symm x = MulAut.conj g⁻¹ x := by simp [stabilizerEquivStabilizer] +@[to_additive] theorem stabilizerEquivStabilizer_trans (hg : b = g • a) (hh : c = h • b) (hk : c = k • a) (H : k = h * g) : (stabilizerEquivStabilizer hg).trans (stabilizerEquivStabilizer hh) = stabilizerEquivStabilizer hk := by ext; simp [stabilizerEquivStabilizer_apply, H] +@[to_additive] theorem stabilizerEquivStabilizer_one : stabilizerEquivStabilizer (one_smul G a).symm = MulEquiv.refl (stabilizer G a) := by ext; simp [stabilizerEquivStabilizer_apply] +@[to_additive] theorem stabilizerEquivStabilizer_symm (hg : b = g • a) : (stabilizerEquivStabilizer hg).symm = stabilizerEquivStabilizer (eq_inv_smul_iff.mpr hg.symm) := by ext x; simp [stabilizerEquivStabilizer] +@[to_additive] theorem stabilizerEquivStabilizer_inv (hg : b = g⁻¹ • a) : stabilizerEquivStabilizer hg = (stabilizerEquivStabilizer (inv_smul_eq_iff.mp hg.symm)).symm := by ext; simp [stabilizerEquivStabilizer] -/-- A bijection between the stabilizers of two elements in the same orbit. -/ +/-- A isomorphism between the stabilizers of two elements in the same orbit. -/ +@[to_additive /-- A isomorphism between the stabilizers of two elements in the same orbit. -/] noncomputable def stabilizerEquivStabilizerOfOrbitRel (h : orbitRel G α a b) : stabilizer G a ≃* stabilizer G b := (stabilizerEquivStabilizer (Classical.choose_spec h).symm).symm @@ -300,66 +309,12 @@ end Stabilizer end MulAction namespace AddAction -variable {G α : Type*} [AddGroup G] [AddAction G α] - -variable {g h k : G} {a b c : α} -/-- If the stabilizer of `x` is `S`, then the stabilizer of `g +ᵥ x` is `g + S + (-g)`. -/ -theorem stabilizer_vadd_eq_stabilizer_map_conj (g : G) (a : α) : - stabilizer G (g +ᵥ a) = (stabilizer G a).map (AddAut.conj g).toMul.toAddMonoidHom := by - ext h - rw [mem_stabilizer_iff, ← vadd_left_cancel_iff (-g), vadd_vadd, vadd_vadd, vadd_vadd, - neg_add_cancel, zero_vadd, ← mem_stabilizer_iff, AddSubgroup.mem_map_equiv, - AddAut.conj_symm_apply] - -variable {g h k : G} {a b c : α} - -/-- The natural group equivalence between the stabilizers of two elements in the same orbit. -/ -def stabilizerEquivStabilizer (hg : b = g +ᵥ a) : stabilizer G a ≃+ stabilizer G b := - AddEquiv.trans ((AddAut.conj g).toMul.addSubgroupMap _) - (AddEquiv.addSubgroupCongr (by - rw [hg, stabilizer_vadd_eq_stabilizer_map_conj g a, ← AddEquiv.toAddMonoidHom_eq_coe])) - -theorem stabilizerEquivStabilizer_apply (hg : b = g +ᵥ a) (x : stabilizer G a) : - stabilizerEquivStabilizer hg x = (AddAut.conj g).toMul x := by - simp [stabilizerEquivStabilizer] -theorem stabilizerEquivStabilizer_symm_apply (hg : b = g +ᵥ b) (x : stabilizer G b) : - (stabilizerEquivStabilizer hg).symm x = (AddAut.conj (-g)).toMul x := by - simp [stabilizerEquivStabilizer] - -theorem stabilizerEquivStabilizer_trans - (hg : b = g +ᵥ a) (hh : c = h +ᵥ b) (hk : c = k +ᵥ a) (H : k = h + g) : - (stabilizerEquivStabilizer hg).trans (stabilizerEquivStabilizer hh) - = stabilizerEquivStabilizer hk := by - ext; simp [stabilizerEquivStabilizer_apply, H] - -theorem stabilizerEquivStabilizer_zero : - stabilizerEquivStabilizer (zero_vadd G a).symm = AddEquiv.refl (stabilizer G a) := by - ext; simp [stabilizerEquivStabilizer_apply] - -theorem stabilizerEquivStabilizer_symm (hg : b = g +ᵥ a) : - (stabilizerEquivStabilizer hg).symm = - stabilizerEquivStabilizer (eq_neg_vadd_iff.mpr hg.symm) := by - ext; simp [stabilizerEquivStabilizer] - -theorem stabilizerEquivStabilizer_neg (hg : b = -g +ᵥ a) : - stabilizerEquivStabilizer hg = - (stabilizerEquivStabilizer (neg_vadd_eq_iff.mp hg.symm)).symm := by - ext; simp [stabilizerEquivStabilizer] - -/-- A bijection between the stabilizers of two elements in the same orbit. -/ -noncomputable def stabilizerEquivStabilizerOfOrbitRel (h : orbitRel G α a b) : - stabilizer G a ≃+ stabilizer G b := - (stabilizerEquivStabilizer (Classical.choose_spec h).symm).symm +@[deprecated (since := "2026-05-26")] alias stabilizer_vadd_eq_stabilizer_map_conj := + stabilizer_vadd_eq_stabilizer_map_addConj end AddAction -attribute [to_additive existing] MulAction.stabilizerEquivStabilizer -attribute [to_additive existing] MulAction.stabilizerEquivStabilizer_trans -attribute [to_additive existing] MulAction.stabilizerEquivStabilizer_one -attribute [to_additive existing] MulAction.stabilizerEquivStabilizer_inv -attribute [to_additive existing] MulAction.stabilizerEquivStabilizerOfOrbitRel - theorem Equiv.swap_mem_stabilizer {α : Type*} [DecidableEq α] {S : Set α} {a b : α} : Equiv.swap a b ∈ MulAction.stabilizer (Equiv.Perm α) S ↔ (a ∈ S ↔ b ∈ S) := by rw [MulAction.mem_stabilizer_iff, Set.ext_iff, ← swap_inv] diff --git a/Mathlib/GroupTheory/GroupAction/Blocks.lean b/Mathlib/GroupTheory/GroupAction/Blocks.lean index a7927e318bb7bb..acb6b45fc25ac4 100644 --- a/Mathlib/GroupTheory/GroupAction/Blocks.lean +++ b/Mathlib/GroupTheory/GroupAction/Blocks.lean @@ -158,7 +158,7 @@ theorem IsTrivialBlock.smul_iff {B : Set α} (g : M) : IsTrivialBlock (g • B) ↔ IsTrivialBlock B := by constructor · intro H - convert IsTrivialBlock.smul H g⁻¹ + convert! IsTrivialBlock.smul H g⁻¹ simp only [inv_smul_smul] · intro H exact IsTrivialBlock.smul H g @@ -371,24 +371,7 @@ theorem isBlock_subtypeVal {C : SubMulAction G X} {B : Set C} : rw [← SubMulAction.inclusion.coe_eq, ← image_smul_set, ← image_smul_set, ne_eq, Set.image_eq_image C.inclusion_injective, disjoint_image_iff C.inclusion_injective] -theorem _root_.AddAction.IsBlock.of_addSubgroup_of_conjugate - {G : Type*} [AddGroup G] {X : Type*} [AddAction G X] {B : Set X} - {H : AddSubgroup G} (hB : AddAction.IsBlock H B) (g : G) : - AddAction.IsBlock (H.map (AddAut.conj g).toMul.toAddMonoidHom) (g +ᵥ B) := by - rw [AddAction.isBlock_iff_vadd_eq_or_disjoint] - intro h' - obtain ⟨h, hH, hh⟩ := AddSubgroup.mem_map.mp (SetLike.coe_mem h') - simp only [AddEquiv.coe_toAddMonoidHom, AddAut.conj_apply] at hh - suffices h' +ᵥ (g +ᵥ B) = g +ᵥ (h +ᵥ B) by - simp only [this] - apply (hB.vadd_eq_or_disjoint ⟨h, hH⟩).imp - · intro hB'; congr - · exact Set.disjoint_image_of_injective (AddAction.injective g) - suffices (h' : G) +ᵥ (g +ᵥ B) = g +ᵥ (h +ᵥ B) by - exact this - rw [← hh, vadd_vadd, vadd_vadd] - simp - +@[to_additive] theorem IsBlock.of_subgroup_of_conjugate {H : Subgroup G} (hB : IsBlock H B) (g : G) : IsBlock (H.map (MulAut.conj g).toMonoidHom) (g • B) := by rw [isBlock_iff_smul_eq_or_disjoint] @@ -405,18 +388,7 @@ theorem IsBlock.of_subgroup_of_conjugate {H : Subgroup G} (hB : IsBlock H B) (g rw [← hh, smul_smul (g * h * g⁻¹) g B, smul_smul g h B, inv_mul_cancel_right] /-- A translate of a block is a block -/ -theorem _root_.AddAction.IsBlock.translate - {G : Type*} [AddGroup G] {X : Type*} [AddAction G X] (B : Set X) - (g : G) (hB : AddAction.IsBlock G B) : - AddAction.IsBlock G (g +ᵥ B) := by - rw [← AddAction.isBlock_top] at hB ⊢ - rw [← AddSubgroup.map_comap_eq_self_of_surjective (G := G) ?_ ⊤] - · apply AddAction.IsBlock.of_addSubgroup_of_conjugate - rwa [AddSubgroup.comap_top] - · exact (AddAut.conj g).surjective - -/-- A translate of a block is a block -/ -@[to_additive existing] +@[to_additive] theorem IsBlock.translate (g : G) (hB : IsBlock G B) : IsBlock G (g • B) := by rw [← isBlock_top] at hB ⊢ diff --git a/Mathlib/GroupTheory/GroupAction/Defs.lean b/Mathlib/GroupTheory/GroupAction/Defs.lean index 99992783736e57..f3764ac6821cee 100644 --- a/Mathlib/GroupTheory/GroupAction/Defs.lean +++ b/Mathlib/GroupTheory/GroupAction/Defs.lean @@ -308,7 +308,7 @@ theorem quotient_preimage_image_eq_union_mul (U : Set α) : rw [Set.mem_preimage, Set.mem_image] refine ⟨g⁻¹ • a, ?_, by simp +instances [f, orbitRel, Quotient.eq']⟩ rw [← hu₂] - convert hu₁ + convert! hu₁ simp only [inv_smul_smul] @[to_additive] @@ -439,13 +439,13 @@ lemma orbitRel.Quotient.mem_subgroup_orbit_iff' {H : Subgroup G} {x : orbitRel.Q {a b : x.orbit} {c : α} (h : (⟦a⟧ : orbitRel.Quotient H x.orbit) = ⟦b⟧) : (a : α) ∈ MulAction.orbit H c ↔ (b : α) ∈ MulAction.orbit H c := by simp_rw [mem_orbit_symm (a₂ := c)] - convert Iff.rfl using 2 + convert! Iff.rfl using 2 rw [orbit_eq_iff] suffices hb : ↑b ∈ orbitRel.Quotient.orbit (⟦a⟧ : orbitRel.Quotient H x.orbit) by rw [orbitRel.Quotient.orbit_eq_orbit_out (⟦a⟧ : orbitRel.Quotient H x.orbit) Quotient.out_eq'] at hb rw [orbitRel.Quotient.mem_subgroup_orbit_iff] - convert hb using 1 + convert! hb using 1 rw [orbit_eq_iff, ← orbitRel_apply, ← Quotient.eq'', Quotient.out_eq', @Quotient.mk''_eq_mk] rw [orbitRel.Quotient.mem_orbit, h, @Quotient.mk''_eq_mk] diff --git a/Mathlib/GroupTheory/GroupAction/Hom.lean b/Mathlib/GroupTheory/GroupAction/Hom.lean index d65efcb17e25b3..e10c5e860767a4 100644 --- a/Mathlib/GroupTheory/GroupAction/Hom.lean +++ b/Mathlib/GroupTheory/GroupAction/Hom.lean @@ -555,6 +555,7 @@ variable (C : Type*) [Monoid C] [MulDistribMulAction P C] variable (A' : Type*) [Group A'] [MulDistribMulAction M A'] variable (B' : Type*) [Group B'] [MulDistribMulAction N B'] +set_option linter.translateOverwrite false in attribute [to_additive existing (dont_translate := M) DistribMulAction] MulDistribMulAction diff --git a/Mathlib/GroupTheory/GroupAction/Jordan.lean b/Mathlib/GroupTheory/GroupAction/Jordan.lean index d114e849b6d444..c22dcadf933ecf 100644 --- a/Mathlib/GroupTheory/GroupAction/Jordan.lean +++ b/Mathlib/GroupTheory/GroupAction/Jordan.lean @@ -414,7 +414,7 @@ theorem subgroup_eq_top_of_isPreprimitive_of_isSwap_mem · rw [hn]; apply Nat.lt_add_one have := isPretransitive_of_isCycle_mem h2g.isCycle hg apply IsPreprimitive.of_prime_card - convert Nat.prime_two + convert! Nat.prime_two rw [Nat.card_eq_fintype_card, Fintype.card_subtype, ← card_support_eq_two.mpr h2g] simp [SubMulAction.mem_ofFixingSubgroup_iff, support] @@ -451,7 +451,7 @@ theorem alternatingGroup_le_of_isPreprimitive_of_isThreeCycle_mem · grind have := isPretransitive_of_isCycle_mem h3g.isCycle hg apply IsPreprimitive.of_prime_card - convert Nat.prime_three + convert! Nat.prime_three rw [Nat.card_eq_fintype_card, Fintype.card_subtype, ← h3g.card_support] apply congr_arg ext x diff --git a/Mathlib/GroupTheory/GroupAction/MultipleTransitivity.lean b/Mathlib/GroupTheory/GroupAction/MultipleTransitivity.lean index 7f93eefe06c2ca..f7a6d09eefbdfd 100644 --- a/Mathlib/GroupTheory/GroupAction/MultipleTransitivity.lean +++ b/Mathlib/GroupTheory/GroupAction/MultipleTransitivity.lean @@ -358,7 +358,7 @@ theorem isMultiplyPretransitive [IsPretransitive G α] {n : ℕ} {a : α} : · obtain ⟨g, hgxy⟩ := exists_smul_eq G (ofStabilizer.snoc x) (ofStabilizer.snoc y) have hg : g ∈ stabilizer G a := by rw [DFunLike.ext_iff] at hgxy - convert hgxy (last n) + convert! hgxy (last n) simp [ofStabilizer.snoc_last] use ⟨g, hg⟩ ext i @@ -476,7 +476,7 @@ theorem IsMultiplyPretransitive.index_of_fixingSubgroup_mul have htcard : t.ncard = k := by rw [← Nat.succ_inj, Nat.succ_eq_add_one, Nat.succ_eq_add_one, ← hs, hat', eq_comm] suffices ¬ a ∈ (Subtype.val '' t) by - convert Set.ncard_insert_of_notMem this ?_ + convert! Set.ncard_insert_of_notMem this ?_ · rw [Set.ncard_image_of_injective _ Subtype.coe_injective] apply Set.toFinite intro h @@ -489,7 +489,7 @@ theorem IsMultiplyPretransitive.index_of_fixingSubgroup_mul rw [add_comm k, Nat.mul_right_comm, ← Nat.sub_sub, this, mul_comm, index_stabilizer_of_transitive G a] exact Nat.mul_factorial_pred (card_ne_zero.mpr ⟨⟨a⟩, inferInstance⟩) - convert hrec (ofStabilizer.isMultiplyPretransitive.mp Hk) htcard + convert! hrec (ofStabilizer.isMultiplyPretransitive.mp Hk) htcard all_goals { rw [nat_card_ofStabilizer_eq G a] } /-- For a multiply pretransitive action, diff --git a/Mathlib/GroupTheory/GroupAction/Quotient.lean b/Mathlib/GroupTheory/GroupAction/Quotient.lean index ebdc6fb14b39ed..083893be40f6ab 100644 --- a/Mathlib/GroupTheory/GroupAction/Quotient.lean +++ b/Mathlib/GroupTheory/GroupAction/Quotient.lean @@ -167,7 +167,7 @@ theorem injective_ofQuotientStabilizer : Function.Injective (ofQuotientStabilize noncomputable def orbitEquivQuotientStabilizer (b : β) : orbit α b ≃ α ⧸ stabilizer α b := Equiv.symm <| Equiv.ofBijective (fun g => ⟨ofQuotientStabilizer α b g, ofQuotientStabilizer_mem_orbit α b g⟩) - ⟨fun x y hxy => injective_ofQuotientStabilizer α b (by convert congr_arg Subtype.val hxy), + ⟨fun x y hxy => injective_ofQuotientStabilizer α b (by convert! congr_arg Subtype.val hxy), fun ⟨_, ⟨g, hgb⟩⟩ => ⟨g, Subtype.ext hgb⟩⟩ /-- Orbit-stabilizer theorem. -/ @@ -369,14 +369,14 @@ noncomputable def equivSubgroupOrbitsQuotientGroup [IsPretransitive α β] cases y using Quotient.inductionOn' simp only [Quotient.liftOn'_mk''] rw [← @Quotient.mk''_eq_mk, Quotient.eq'', orbitRel_apply] - convert mem_orbit_self _ + convert! mem_orbit_self _ rw [inv_smul_eq_iff, (exists_smul_eq α _ x).choose_spec] right_inv := fun g ↦ by cases g using Quotient.inductionOn' with | _ g simp only [Quotient.liftOn'_mk'', QuotientGroup.mk] rw [Quotient.eq'', leftRel_eq] simp only - convert one_mem H + convert! one_mem H rw [inv_mul_eq_one, eq_comm, ← inv_mul_eq_one, ← Subgroup.mem_bot, ← IsCancelSMul.stabilizer_eq_bot (g⁻¹ • x), mem_stabilizer_iff, mul_smul, (exists_smul_eq α (g⁻¹ • x) x).choose_spec] diff --git a/Mathlib/GroupTheory/GroupAction/SubMulAction/OfFixingSubgroup.lean b/Mathlib/GroupTheory/GroupAction/SubMulAction/OfFixingSubgroup.lean index 9e82fabfc2e903..e8ac492a9c042d 100644 --- a/Mathlib/GroupTheory/GroupAction/SubMulAction/OfFixingSubgroup.lean +++ b/Mathlib/GroupTheory/GroupAction/SubMulAction/OfFixingSubgroup.lean @@ -12,8 +12,6 @@ public import Mathlib.GroupTheory.GroupAction.Transitive public import Mathlib.GroupTheory.GroupAction.Primitive public import Mathlib.Tactic.Group -import all Mathlib.Algebra.Group.End -- TODO: needed for `to_additive` - /-! # SubMulActions on complements of invariant subsets @@ -213,13 +211,6 @@ section FixingSubgroupConj variable {s t : Set α} {g : M} -/- -FIXME: The use of `to_additive` in this section is a horrible mess. -It requires translating `MulAut.instGroup` to `AddAut.instAddGroup` instead of `AddAut.instGroup`, -and `MulAut.conj` shouldn't be able to translate to `AddAut.conj`, but somehow it works out. --/ -attribute [to_additive] MulAut.instGroup - @[to_additive] theorem _root_.Set.conj_mem_fixingSubgroup (hg : g • t = s) {k : M} (hk : k ∈ fixingSubgroup M t) : MulAut.conj g k ∈ fixingSubgroup M s := by diff --git a/Mathlib/GroupTheory/GroupAction/SubMulAction/OfStabilizer.lean b/Mathlib/GroupTheory/GroupAction/SubMulAction/OfStabilizer.lean index adb60ed349d257..f4ae4714f590e1 100644 --- a/Mathlib/GroupTheory/GroupAction/SubMulAction/OfStabilizer.lean +++ b/Mathlib/GroupTheory/GroupAction/SubMulAction/OfStabilizer.lean @@ -138,7 +138,7 @@ theorem _root_.AddAction.stabilizerEquivStabilizer_compTriple (AddAction.stabilizerEquivStabilizer hh) (AddAction.stabilizerEquivStabilizer hk) where comp_eq := by ext - simp [AddAction.stabilizerEquivStabilizer, H, AddAut.conj, ← add_assoc] + simp [AddAction.stabilizerEquivStabilizer, H, AddAut.addConj, ← add_assoc] set_option backward.isDefEq.respectTransparency false in variable {hg hh hk} in @@ -232,7 +232,7 @@ variable (G : Type*) [Group G] (α : Type*) [MulAction G α] instance _root_.SMul.ofStabilizer (s : Set α) : SMul (stabilizer G s) s where smul g x := ⟨g • ↑x, by - convert Set.smul_mem_smul_set x.prop + convert! Set.smul_mem_smul_set x.prop exact (mem_stabilizer_iff.mp g.prop).symm⟩ @[simp] diff --git a/Mathlib/GroupTheory/HNNExtension.lean b/Mathlib/GroupTheory/HNNExtension.lean index f6bcb03ab30f49..c9d218788c3fa2 100644 --- a/Mathlib/GroupTheory/HNNExtension.lean +++ b/Mathlib/GroupTheory/HNNExtension.lean @@ -160,7 +160,7 @@ and `toSubgroupEquiv` is the group isomorphism from `toSubgroup A B u` to `toSub It is defined to be `φ` when `u = 1` and `φ⁻¹` when `u = -1`. -/ def toSubgroupEquiv (u : ℤˣ) : toSubgroup A B u ≃* toSubgroup A B (-u) := if hu : u = 1 then hu ▸ φ else by - convert φ.symm <;> + convert! φ.symm <;> cases Int.units_eq_one_or u <;> simp_all @[simp] @@ -449,7 +449,7 @@ noncomputable def unitsSMulEquiv : NormalWord d ≃ NormalWord d := { toFun := unitsSMul φ 1 invFun := unitsSMul φ (-1), left_inv := fun _ => by rw [unitsSMul_neg] - right_inv := fun w => by convert unitsSMul_neg _ _ w; simp } + right_inv := fun w => by convert! unitsSMul_neg _ _ w; simp } set_option backward.isDefEq.respectTransparency false in theorem unitsSMul_one_group_smul (g : A) (w : NormalWord d) : diff --git a/Mathlib/GroupTheory/Index.lean b/Mathlib/GroupTheory/Index.lean index df318f9dc7fd78..a0bf0a289123cc 100644 --- a/Mathlib/GroupTheory/Index.lean +++ b/Mathlib/GroupTheory/Index.lean @@ -566,7 +566,7 @@ lemma exists_pow_mem_of_index_ne_zero (h : H.index ≠ 0) (a : G) : rw [eq_comm, QuotientGroup.eq, ← zpow_natCast, ← zpow_natCast, ← zpow_neg, ← zpow_add, add_comm] at he rw [← zpow_natCast] - convert he + convert! he lia suffices ∃ n₁ n₂, n₁ ≠ n₂ ∧ n₁ ≤ H.index ∧ n₂ ≤ H.index ∧ ((a ^ n₂ : G) : G ⧸ H) = ((a ^ n₁ : G) : G ⧸ H) by @@ -604,7 +604,7 @@ lemma pow_mem_of_index_ne_zero_of_dvd (h : H.index ≠ 0) (a : G) {n : ℕ} @[to_additive] lemma pow_mem_of_relIndex_ne_zero_of_dvd (h : H.relIndex K ≠ 0) {a : G} (ha : a ∈ K) {n : ℕ} (hn : ∀ m, 0 < m → m ≤ H.relIndex K → m ∣ n) : a ^ n ∈ H ⊓ K := by - convert pow_mem_of_index_ne_zero_of_dvd h ⟨a, ha⟩ hn + convert! pow_mem_of_index_ne_zero_of_dvd h ⟨a, ha⟩ hn simp [pow_mem ha, mem_subgroupOf] @[to_additive (attr := simp) index_prod] diff --git a/Mathlib/GroupTheory/IndexNormal.lean b/Mathlib/GroupTheory/IndexNormal.lean index 15d5a65affcf7e..ca0bb1d7e3db47 100644 --- a/Mathlib/GroupTheory/IndexNormal.lean +++ b/Mathlib/GroupTheory/IndexNormal.lean @@ -51,7 +51,7 @@ theorem normal_of_index_eq_minFac_card (hHp : H.index = (Nat.card G).minFac) : · rw [hG1, minFac_one] at hHp exact normal_of_index_eq_one hHp suffices H.normalCore.relIndex H = 1 by - convert H.normalCore_normal + convert! H.normalCore_normal exact le_antisymm (relIndex_eq_one.mp this) (normalCore_le H) have : Finite G := finite_of_card_ne_zero hG0 have index_ne_zero : H.index ≠ 0 := index_ne_zero_of_finite diff --git a/Mathlib/GroupTheory/MonoidLocalization/Basic.lean b/Mathlib/GroupTheory/MonoidLocalization/Basic.lean index 0b4b4875036959..240ed345434169 100644 --- a/Mathlib/GroupTheory/MonoidLocalization/Basic.lean +++ b/Mathlib/GroupTheory/MonoidLocalization/Basic.lean @@ -181,7 +181,7 @@ theorem r_eq_r' : r S = r' S := le_sInf fun b H ⟨p, q⟩ ⟨x, y⟩ ⟨t, ht⟩ ↦ by rw [← one_mul (p, q), ← one_mul (x, y)] refine b.trans (b.mul (H (t * y)) (b.refl _)) ?_ - convert b.symm (b.mul (H (t * q)) (b.refl (x, y))) using 1 + convert! b.symm (b.mul (H (t * q)) (b.refl (x, y))) using 1 dsimp only [Prod.mk_mul_mk, Submonoid.coe_mul] at ht ⊢ simp_rw [mul_assoc, ht, mul_comm y q] diff --git a/Mathlib/GroupTheory/MonoidLocalization/GrothendieckGroup.lean b/Mathlib/GroupTheory/MonoidLocalization/GrothendieckGroup.lean index 80dafe76c8b08b..4fe295b7bccc1a 100644 --- a/Mathlib/GroupTheory/MonoidLocalization/GrothendieckGroup.lean +++ b/Mathlib/GroupTheory/MonoidLocalization/GrothendieckGroup.lean @@ -65,7 +65,7 @@ instance instCommGroup : CommGroup (GrothendieckGroup M) where inv_mul_cancel a := by cases a using ind rw [inv_mk, mk_eq_monoidOf_mk', ← Submonoid.LocalizationMap.mk'_mul] - convert Submonoid.LocalizationMap.mk'_self' _ _ + convert! Submonoid.LocalizationMap.mk'_self' _ _ rw [mul_comm, Submonoid.coe_mul] @[to_additive (attr := simp)] diff --git a/Mathlib/GroupTheory/Nilpotent.lean b/Mathlib/GroupTheory/Nilpotent.lean index 1411471484b394..4d88e26165335c 100644 --- a/Mathlib/GroupTheory/Nilpotent.lean +++ b/Mathlib/GroupTheory/Nilpotent.lean @@ -98,7 +98,7 @@ def upperCentralSeriesStep : Subgroup G where carrier := { x : G | ∀ y : G, ⁅x, y⁆ ∈ H } one_mem' y := by simp mul_mem' {a b} ha hb y := by - convert Subgroup.mul_mem _ (ha (b * y * b⁻¹)) (hb y) using 1 + convert! Subgroup.mul_mem _ (ha (b * y * b⁻¹)) (hb y) using 1 group inv_mem' {x} hx y := by specialize hx y⁻¹ @@ -343,7 +343,7 @@ theorem is_descending_rev_series_of_is_ascending {H : ℕ → Subgroup G} {n : rw [commutatorElement_one_left] exact Subgroup.one_mem _ · apply hH - convert hx using 1 + convert! hx using 1 rw [tsub_add_eq_add_tsub (Nat.succ_le_of_lt hm), Nat.succ_eq_add_one, Nat.add_sub_add_right] @[to_additive] @@ -356,7 +356,7 @@ theorem is_ascending_rev_series_of_is_descending {H : ℕ → Subgroup G} {n : · have hnm : n - m = 0 := tsub_eq_zero_iff_le.mpr hm rw [hnm, h0] exact mem_top _ - · convert hH x _ hx g using 1 + · convert! hH x _ hx g using 1 rw [tsub_add_eq_add_tsub (Nat.succ_le_of_lt hm), Nat.succ_eq_add_one, Nat.add_sub_add_right] /-- A group `G` is nilpotent iff there exists a descending central series which reaches the @@ -1158,6 +1158,9 @@ theorem Group.isNilpotent_of_finite_tfae : | ⟨e⟩ => isNilpotent_of_product_of_sylow_group e tfae_finish +instance [IsNilpotent G] {p : ℕ} [Fact p.Prime] {P : Sylow p G} : P.Normal := + isNilpotent_of_finite_tfae.out 0 3 rfl rfl |>.mp ‹_› p ‹_› P + end WithFiniteGroup open Group diff --git a/Mathlib/GroupTheory/NoncommPiCoprod.lean b/Mathlib/GroupTheory/NoncommPiCoprod.lean index 54d36addcd1b4f..bf213e8c34802c 100644 --- a/Mathlib/GroupTheory/NoncommPiCoprod.lean +++ b/Mathlib/GroupTheory/NoncommPiCoprod.lean @@ -108,7 +108,7 @@ def noncommPiCoprod : (∀ i : ι, N i) →* M where simp map_mul' f g := by classical - convert @Finset.noncommProd_mul_distrib _ _ _ _ (fun i => ϕ i (f i)) (fun i => ϕ i (g i)) _ _ _ + convert! @Finset.noncommProd_mul_distrib _ _ _ _ (fun i => ϕ i (f i)) (fun i => ϕ i (g i)) _ _ _ · exact map_mul _ _ _ · rintro i - j - h exact hcomm h _ _ diff --git a/Mathlib/GroupTheory/OrderOfElement.lean b/Mathlib/GroupTheory/OrderOfElement.lean index b6f9f4d027381f..23bbec6f425dd4 100644 --- a/Mathlib/GroupTheory/OrderOfElement.lean +++ b/Mathlib/GroupTheory/OrderOfElement.lean @@ -198,7 +198,7 @@ protected lemma IsOfFinOrder.orderOf_pos (h : IsOfFinOrder x) : 0 < orderOf x := @[to_additive (attr := simp) addOrderOf_nsmul_eq_zero] theorem pow_orderOf_eq_one (x : G) : x ^ orderOf x = 1 := by - convert Eq.trans _ (isPeriodicPt_minimalPeriod (x * ·) 1) + convert! Eq.trans _ (isPeriodicPt_minimalPeriod (x * ·) 1) rw [orderOf, mul_left_iterate_apply_one] @[to_additive] diff --git a/Mathlib/GroupTheory/OreLocalization/Basic.lean b/Mathlib/GroupTheory/OreLocalization/Basic.lean index f6867fd3b5a6db..3510c03ad063e9 100644 --- a/Mathlib/GroupTheory/OreLocalization/Basic.lean +++ b/Mathlib/GroupTheory/OreLocalization/Basic.lean @@ -548,6 +548,7 @@ protected def hsmul (c : R) : rw [← mul_one (oreDenom (c • 1) s), ← oreDiv_smul_oreDiv, ← mul_one (oreDenom (c • 1) _), ← oreDiv_smul_oreDiv, ← OreLocalization.expand]) +set_option linter.overlappingInstances false in /- Warning: This gives a diamond on `SMul R[S⁻¹] M[S⁻¹][S⁻¹]`, but we will almost never localize at the same monoid twice. -/ /- Although the definition does not require `IsScalarTower R M X`, diff --git a/Mathlib/GroupTheory/OreLocalization/Cardinality.lean b/Mathlib/GroupTheory/OreLocalization/Cardinality.lean index 24ba3f64e12da4..92d6feb5aa44ce 100644 --- a/Mathlib/GroupTheory/OreLocalization/Cardinality.lean +++ b/Mathlib/GroupTheory/OreLocalization/Cardinality.lean @@ -75,14 +75,14 @@ theorem cardinalMk_le_max : #(OreLocalization S X) ≤ max (lift.{v} #S) (lift.{ · have := lift_mk_le_lift_mk_of_surjective (oreDiv_one_surjective_of_finite_left S X) rw [lift_umax.{v, u}, lift_id'] at this exact le_max_of_le_right this - convert ← mk_le_of_surjective (show Surjective fun x : X × S ↦ x.1 /ₒ x.2 from - Quotient.mk''_surjective) + convert! ← + mk_le_of_surjective (show Surjective fun x : X × S ↦ x.1 /ₒ x.2 from Quotient.mk''_surjective) rw [mk_prod, mul_comm] refine mul_eq_max ?_ ?_ <;> simp @[to_additive] theorem cardinalMk_le : #(OreLocalization S R) ≤ #R := by - convert ← cardinalMk_le_max S R + convert! ← cardinalMk_le_max S R simp_rw [lift_id, max_eq_right_iff, mk_subtype_le] -- TODO: remove the `Commute` assumption diff --git a/Mathlib/GroupTheory/Perm/Centralizer.lean b/Mathlib/GroupTheory/Perm/Centralizer.lean index 79bc10e7a6dc0d..170e2579f1fa8e 100644 --- a/Mathlib/GroupTheory/Perm/Centralizer.lean +++ b/Mathlib/GroupTheory/Perm/Centralizer.lean @@ -646,7 +646,7 @@ theorem card_isConj_mul_eq : classical rw [Nat.card_eq_fintype_card, ← nat_card_centralizer g] rw [Subgroup.nat_card_centralizer_nat_card_stabilizer, Nat.card_eq_fintype_card] - convert MulAction.card_orbit_mul_card_stabilizer_eq_card_group (ConjAct (Perm α)) g + convert! MulAction.card_orbit_mul_card_stabilizer_eq_card_group (ConjAct (Perm α)) g · ext h simp only [Set.mem_setOf_eq, ConjAct.mem_orbit_conjAct, isConj_comm] · rw [ConjAct.card, Fintype.card_perm] @@ -681,7 +681,7 @@ theorem card_of_cycleType_mul_eq (m : Multiset ℕ) : · -- nonempty case classical obtain ⟨g, rfl⟩ := (exists_with_cycleType_iff α).mpr hm - convert card_isConj_mul_eq g + convert! card_isConj_mul_eq g simp_rw [Set.coe_setOf, Nat.card_eq_fintype_card, ← Fintype.card_coe, Finset.mem_filter, Finset.mem_univ, true_and, ← isConj_iff_cycleType_eq, isConj_comm (g := g)] · -- empty case diff --git a/Mathlib/GroupTheory/Perm/Closure.lean b/Mathlib/GroupTheory/Perm/Closure.lean index 6ae430ba90da64..7d3158643c5ff5 100644 --- a/Mathlib/GroupTheory/Perm/Closure.lean +++ b/Mathlib/GroupTheory/Perm/Closure.lean @@ -53,14 +53,14 @@ theorem closure_cycle_adjacent_swap {σ : Perm α} (h1 : IsCycle σ) (h2 : σ.su induction n with | zero => exact subset_closure (Set.mem_insert_of_mem _ (Set.mem_singleton _)) | succ n ih => - convert H.mul_mem (H.mul_mem h3 ih) (H.inv_mem h3) + convert! H.mul_mem (H.mul_mem h3 ih) (H.inv_mem h3) simp_rw [mul_swap_eq_swap_mul, mul_inv_cancel_right, pow_succ', coe_mul, comp_apply] have step2 : ∀ n : ℕ, swap x ((σ ^ n) x) ∈ H := by intro n induction n with | zero => simp only [pow_zero, coe_one, id_eq, swap_self] - convert H.one_mem + convert! H.one_mem | succ n ih => by_cases h5 : x = (σ ^ n) x · rw [pow_succ', mul_apply, ← h5] diff --git a/Mathlib/GroupTheory/Perm/ClosureSwap.lean b/Mathlib/GroupTheory/Perm/ClosureSwap.lean index 295a60aefc331e..78204cfa163147 100644 --- a/Mathlib/GroupTheory/Perm/ClosureSwap.lean +++ b/Mathlib/GroupTheory/Perm/ClosureSwap.lean @@ -107,7 +107,7 @@ theorem mem_closure_isSwap {S : Set (Perm α)} (hS : ∀ f ∈ S, f.IsSwap) {f : suffices h : (fixedBy α f)ᶜ ⊆ supp → f ∈ closure S from h supp_eq.symm.subset clear_value supp; clear supp_eq; revert f apply fin.induction_on .. - · rintro f - emp; convert (closure S).one_mem; ext; by_contra h; exact emp h + · rintro f - emp; convert! (closure S).one_mem; ext; by_contra h; exact emp h rintro a s - - ih f hf supp_subset refine (mul_mem_cancel_left ((swap_mem_closure_isSwap hS).2 (hf a))).1 (ih (fun b ↦ ?_) fun b hb ↦ ?_) diff --git a/Mathlib/GroupTheory/Perm/Cycle/Basic.lean b/Mathlib/GroupTheory/Perm/Cycle/Basic.lean index 32d0ab199b8011..312d420e8cd10a 100644 --- a/Mathlib/GroupTheory/Perm/Cycle/Basic.lean +++ b/Mathlib/GroupTheory/Perm/Cycle/Basic.lean @@ -363,7 +363,7 @@ theorem IsCycle.zpowersEquivSupport_symm_apply {σ : Perm α} (hσ : IsCycle σ) protected theorem IsCycle.orderOf (hf : IsCycle f) : orderOf f = #f.support := by rw [← Fintype.card_zpowers, ← Fintype.card_coe] - convert Fintype.card_congr (IsCycle.zpowersEquivSupport hf) + convert! Fintype.card_congr (IsCycle.zpowersEquivSupport hf) theorem isCycle_swap_mul_aux₁ {α : Type*} [DecidableEq α] : ∀ (n : ℕ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b), @@ -398,7 +398,7 @@ theorem isCycle_swap_mul_aux₂ {α : Type*} [DecidableEq α] : obtain ⟨i, hi⟩ := isCycle_swap_mul_aux₁ n hb <| by rw [← mul_apply, ← pow_succ]; simpa [pow_succ', eq_symm_apply] using h refine ⟨-i, (swap x (f⁻¹ x) * f⁻¹).injective ?_⟩ - convert hi using 1 + convert! hi using 1 · rw [zpow_neg, ← inv_zpow, ← mul_apply, mul_inv_rev, swap_inv, mul_swap_eq_swap_mul] simp [swap_comm _ x, ← mul_apply, -coe_mul, ← inv_def, -coe_inv, ← inv_def, mul_assoc _ f⁻¹, ← mul_zpow_mul, mul_assoc _ _ f] @@ -688,7 +688,7 @@ alias ⟨IsCycleOn.of_inv, IsCycleOn.inv⟩ := isCycleOn_inv theorem IsCycleOn.conj (h : f.IsCycleOn s) : (g * f * g⁻¹).IsCycleOn ((g : Perm α) '' s) := ⟨(g.bijOn_image.comp h.1).comp g.bijOn_symm_image, fun x hx y hy => by rw [Equiv.image_eq_preimage_symm] at hx hy - convert Equiv.Perm.SameCycle.conj (h.2 hx hy) (g := g) <;> simp⟩ + convert! Equiv.Perm.SameCycle.conj (h.2 hx hy) (g := g) <;> simp⟩ theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} := ⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by @@ -736,7 +736,7 @@ protected theorem IsCycleOn.subtypePerm (hf : f.IsCycleOn s) : obtain hs | hs := s.subsingleton_or_nontrivial · haveI := hs.coe_sort exact isCycleOn_of_subsingleton _ _ - convert (hf.isCycle_subtypePerm hs).isCycleOn + convert! (hf.isCycle_subtypePerm hs).isCycleOn rw [eq_comm, Set.eq_univ_iff_forall] exact fun x => ne_of_apply_ne ((↑) : s → α) (hf.apply_ne hs x.2) @@ -855,7 +855,7 @@ theorem exists_cycleOn (s : Finset α) : ∃ f : Perm α, f.IsCycleOn s ∧ f.support ⊆ s := by refine ⟨s.toList.formPerm, ?_, fun x hx => by simpa using List.mem_of_formPerm_apply_ne (Perm.mem_support.1 hx)⟩ - convert s.nodup_toList.isCycleOn_formPerm + convert! s.nodup_toList.isCycleOn_formPerm simp end Finset @@ -870,14 +870,14 @@ theorem Countable.exists_cycleOn (hs : s.Countable) : obtain hs' | hs' := s.finite_or_infinite · refine ⟨hs'.toFinset.toList.formPerm, ?_, fun x hx => by simpa using List.mem_of_formPerm_apply_ne hx⟩ - convert hs'.toFinset.nodup_toList.isCycleOn_formPerm + convert! hs'.toFinset.nodup_toList.isCycleOn_formPerm simp · haveI := hs.to_subtype haveI := hs'.to_subtype obtain ⟨f⟩ : Nonempty (ℤ ≃ s) := inferInstance refine ⟨(Equiv.addRight 1).extendDomain f, ?_, fun x hx => of_not_not fun h => hx <| Perm.extendDomain_apply_not_subtype _ _ h⟩ - convert Int.addRight_one_isCycle.isCycleOn.extendDomain f + convert! Int.addRight_one_isCycle.isCycleOn.extendDomain f rw [Set.image_comp, Equiv.image_eq_preimage_symm] ext simp diff --git a/Mathlib/GroupTheory/Perm/Cycle/Factors.lean b/Mathlib/GroupTheory/Perm/Cycle/Factors.lean index 4f0a76b60ed3af..96cf6d1f99a917 100644 --- a/Mathlib/GroupTheory/Perm/Cycle/Factors.lean +++ b/Mathlib/GroupTheory/Perm/Cycle/Factors.lean @@ -101,12 +101,12 @@ theorem cycleOf_apply_apply_zpow_self (f : Perm α) [DecidableRel f.SameCycle] ( @[simp] theorem cycleOf_apply_apply_pow_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) (k : ℕ) : cycleOf f x ((f ^ k) x) = (f ^ (k + 1) : Perm α) x := by - convert cycleOf_apply_apply_zpow_self f x k using 1 + convert! cycleOf_apply_apply_zpow_self f x k using 1 @[simp] theorem cycleOf_apply_apply_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) : cycleOf f x (f x) = f (f x) := by - convert cycleOf_apply_apply_pow_self f x 1 using 1 + convert! cycleOf_apply_apply_pow_self f x 1 using 1 @[simp] theorem cycleOf_apply_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) : cycleOf f x x = f x := @@ -438,7 +438,7 @@ theorem mem_list_cycles_iff {α : Type*} [Finite α] {l : List (Perm α)} have key : ∀ x ∈ σ.support ∩ τ.support, σ x = τ x := by intro x hx rw [h x (mem_support.mp (mem_of_mem_inter_left hx)), hτl x (mem_of_mem_inter_right hx)] - convert hτ + convert! hτ refine h3.eq_on_support_inter_nonempty_congr (h1 _ hτ) key ?_ ha exact key a (mem_inter_of_mem ha hτa) diff --git a/Mathlib/GroupTheory/Perm/Cycle/Type.lean b/Mathlib/GroupTheory/Perm/Cycle/Type.lean index 5e459c0700bb44..58cf7430a724ec 100644 --- a/Mathlib/GroupTheory/Perm/Cycle/Type.lean +++ b/Mathlib/GroupTheory/Perm/Cycle/Type.lean @@ -530,7 +530,7 @@ theorem _root_.exists_prime_orderOf_dvd_card {G : Type*} [Group G] [Fintype G] ( order `p` in `G`. This is the additive version of Cauchy's theorem. -/ theorem _root_.exists_prime_addOrderOf_dvd_card {G : Type*} [AddGroup G] [Fintype G] (p : ℕ) [Fact p.Prime] (hdvd : p ∣ Fintype.card G) : ∃ x : G, addOrderOf x = p := - @exists_prime_orderOf_dvd_card (Multiplicative G) _ _ _ _ (by convert hdvd) + @exists_prime_orderOf_dvd_card (Multiplicative G) _ _ _ _ (by convert! hdvd) attribute [to_additive existing] exists_prime_orderOf_dvd_card diff --git a/Mathlib/GroupTheory/Perm/Fin.lean b/Mathlib/GroupTheory/Perm/Fin.lean index 7081d03fd025c0..e13b1af86ec985 100644 --- a/Mathlib/GroupTheory/Perm/Fin.lean +++ b/Mathlib/GroupTheory/Perm/Fin.lean @@ -490,7 +490,7 @@ theorem Equiv.Perm.sign_eq_prod_prod_Iio (σ : Equiv.Perm (Fin n)) : σ.sign = ∏ j, ∏ i ∈ Finset.Iio j, (if σ i < σ j then 1 else -1) := by suffices h : σ.sign = σ.signAux by rw [h, Finset.prod_sigma', Equiv.Perm.signAux] - convert rfl using 2 with x hx + convert! rfl using 2 with x hx · simp [Finset.ext_iff, Equiv.Perm.mem_finPairsLT] simp [← ite_not (p := _ ≤ _)] refine σ.swap_induction_on (by simp) fun π i j hne h_eq ↦ ?_ @@ -528,9 +528,9 @@ theorem Equiv.Perm.prod_Iio_comp_eq_sign_mul_prod {R : Type*} [CommRing R] theorem Equiv.Perm.prod_Ioi_comp_eq_sign_mul_prod {R : Type*} [CommRing R] (σ : Equiv.Perm (Fin n)) {f : Fin n → Fin n → R} (hf : ∀ i j, f i j = -f j i) : ∏ i, ∏ j ∈ Finset.Ioi i, f (σ i) (σ j) = σ.sign * ∏ i, ∏ j ∈ Finset.Ioi i, f i j := by - convert σ.prod_Iio_comp_eq_sign_mul_prod hf using 1 + convert! σ.prod_Iio_comp_eq_sign_mul_prod hf using 1 · apply Finset.prod_comm' (by simp) - convert rfl using 2 + convert! rfl using 2 apply Finset.prod_comm' (by simp) end Sign diff --git a/Mathlib/GroupTheory/Perm/List.lean b/Mathlib/GroupTheory/Perm/List.lean index b75975a38624e4..3fb752b7a901e8 100644 --- a/Mathlib/GroupTheory/Perm/List.lean +++ b/Mathlib/GroupTheory/Perm/List.lean @@ -211,7 +211,7 @@ theorem support_formPerm_of_nodup' (l : List α) (h : Nodup l) (h' : ∀ x : α, theorem support_formPerm_of_nodup [Fintype α] (l : List α) (h : Nodup l) (h' : ∀ x : α, l ≠ [x]) : support (formPerm l) = l.toFinset := by rw [← Finset.coe_inj] - convert support_formPerm_of_nodup' _ h h' + convert! support_formPerm_of_nodup' _ h h' simp [Set.ext_iff] theorem formPerm_rotate_one (l : List α) (h : Nodup l) : formPerm (l.rotate 1) = formPerm l := by @@ -263,7 +263,7 @@ theorem formPerm_pow_apply_getElem (l : List α) (w : Nodup l) (n : ℕ) (i : theorem formPerm_pow_apply_head (x : α) (l : List α) (h : Nodup (x :: l)) (n : ℕ) : (formPerm (x :: l) ^ n) x = (x :: l)[(n % (x :: l).length)]'(Nat.mod_lt _ (Nat.zero_lt_succ _)) := by - convert formPerm_pow_apply_getElem _ h n 0 (Nat.succ_pos _) + convert! formPerm_pow_apply_getElem _ h n 0 (Nat.succ_pos _) simp theorem formPerm_ext_iff {x y x' y' : α} {l l' : List α} (hd : Nodup (x :: y :: l)) diff --git a/Mathlib/GroupTheory/Perm/MaximalSubgroups.lean b/Mathlib/GroupTheory/Perm/MaximalSubgroups.lean index 171d6255bc18ac..3516919c0eb728 100644 --- a/Mathlib/GroupTheory/Perm/MaximalSubgroups.lean +++ b/Mathlib/GroupTheory/Perm/MaximalSubgroups.lean @@ -178,7 +178,7 @@ theorem has_swap_mem_of_lt_stabilizer [DecidableEq α] have hα : Set.encard (_root_.Set.univ : Set α) = 2 := by rw [← Set.encard_add_encard_compl s] have : (1 + 1 : ENat) = 2 := by norm_num - convert this <;> + convert! this <;> · apply le_antisymm · assumption rw [one_le_encard_iff_nonempty, Set.nonempty_iff_ne_empty] diff --git a/Mathlib/GroupTheory/Perm/Sign.lean b/Mathlib/GroupTheory/Perm/Sign.lean index 8bb003b5ee482a..8de73eddc5837f 100644 --- a/Mathlib/GroupTheory/Perm/Sign.lean +++ b/Mathlib/GroupTheory/Perm/Sign.lean @@ -243,7 +243,7 @@ private theorem signAux_swap_zero_one' (n : ℕ) : signAux (swap (0 : Fin (n + 2 show _ = ∏ x ∈ {(⟨1, 0⟩ : Σ _ : Fin (n + 2), Fin (n + 2))}, if (Equiv.swap 0 1) x.1 ≤ swap 0 1 x.2 then (-1 : ℤˣ) else 1 by refine Eq.symm (prod_subset (fun ⟨x₁, x₂⟩ => by - simp +contextual [mem_finPairsLT, Fin.zero_lt_one]) fun a ha₁ ha₂ => ?_) + simp +contextual [mem_finPairsLT]) fun a ha₁ ha₂ => ?_) rcases a with ⟨a₁, a₂⟩ replace ha₁ : a₂ < a₁ := mem_finPairsLT.1 ha₁ dsimp only diff --git a/Mathlib/GroupTheory/Perm/Support.lean b/Mathlib/GroupTheory/Perm/Support.lean index ed19e262463d4d..0f670d4667e4ac 100644 --- a/Mathlib/GroupTheory/Perm/Support.lean +++ b/Mathlib/GroupTheory/Perm/Support.lean @@ -95,7 +95,7 @@ theorem Disjoint.inv_right (h : Disjoint f g) : Disjoint f g⁻¹ := @[simp] theorem disjoint_inv_left_iff : Disjoint f⁻¹ g ↔ Disjoint f g := by refine ⟨fun h => ?_, Disjoint.inv_left⟩ - convert h.inv_left + convert! h.inv_left @[simp] theorem disjoint_inv_right_iff : Disjoint f g⁻¹ ↔ Disjoint f g := by @@ -451,7 +451,7 @@ theorem support_swap_mul_swap {x y z : α} (h : List.Nodup [x, y, z]) : and_self_iff, List.nodup_nil] at h push Not at h apply le_antisymm - · convert support_mul_le (swap x y) (swap y z) using 1 + · convert! support_mul_le (swap x y) (swap y z) using 1 rw [support_swap h.left.left, support_swap h.right.left] simp [-Finset.union_singleton] · intro diff --git a/Mathlib/GroupTheory/PresentedGroup.lean b/Mathlib/GroupTheory/PresentedGroup.lean index 360471515c65f5..f02de660f7931a 100644 --- a/Mathlib/GroupTheory/PresentedGroup.lean +++ b/Mathlib/GroupTheory/PresentedGroup.lean @@ -8,6 +8,7 @@ module public import Mathlib.Algebra.Group.Subgroup.Basic public import Mathlib.GroupTheory.FreeGroup.Basic public import Mathlib.GroupTheory.QuotientGroup.Defs +public import Mathlib.GroupTheory.Coprod.Basic /-! # Defining a group given by generators and relations @@ -31,7 +32,7 @@ generators, relations, group presentations @[expose] public section -variable {α : Type*} +variable {α β : Type*} /-- Given a set of relations, `rels`, over a type `α`, `PresentedGroup` constructs the group with generators `x : α` and relations `rels` as a quotient of `FreeGroup α`. -/ @@ -54,6 +55,18 @@ mapped to the equivalence class of the image of `x` in `FreeGroup α`. -/ def of {rels : Set (FreeGroup α)} (x : α) : PresentedGroup rels := mk rels (FreeGroup.of x) +open Subgroup in +/-- +`FreeGroup α →* FreeGroup β` induces a homomorphism +`PresentedGroup s →* PresentedGroup t` if the image of `s` is contained in `t`. +-/ +protected def map (f : FreeGroup α →* FreeGroup β) + {s : Set (FreeGroup α)} {t : Set (FreeGroup β)} (hst : s.MapsTo f t) : + PresentedGroup s →* PresentedGroup t := + QuotientGroup.map _ _ f + ((comap_normalClosure_image_ge s f).trans + (comap_mono (normalClosure_mono hst.image_subset))) + lemma mk_eq_one_iff {rels : Set (FreeGroup α)} {x : FreeGroup α} : mk rels x = 1 ↔ x ∈ Subgroup.normalClosure rels := QuotientGroup.eq_one_iff _ @@ -138,8 +151,6 @@ theorem ext {φ ψ : PresentedGroup rels →* G} (hx : ∀ (x : α), φ (.of x) ext apply hx -variable {β : Type*} - /-- Presented groups of isomorphic types are isomorphic. -/ def equivPresentedGroup (rels : Set (FreeGroup α)) (e : α ≃ β) : PresentedGroup rels ≃* PresentedGroup (FreeGroup.freeGroupCongr e '' rels) := @@ -161,4 +172,44 @@ end ToGroup instance (rels : Set (FreeGroup α)) : Inhabited (PresentedGroup rels) := ⟨1⟩ +section Coprod + +variable (rels₁ : Set (FreeGroup α)) (rels₂ : Set (FreeGroup β)) + +/-- +The canonical inclusion map from the disjoint union of types to the free product of the relations +-/ +def toCoprod : α ⊕ β → Monoid.Coprod (PresentedGroup rels₁) (PresentedGroup rels₂) := + Sum.elim (Monoid.Coprod.inl ∘ .of) (Monoid.Coprod.inr ∘ .of) + +@[simp] +lemma lift_toCoprod_inl_eq_inl_mk : (FreeGroup.lift (toCoprod rels₁ rels₂)).comp + (FreeGroup.map Sum.inl) = Monoid.Coprod.inl.comp (mk rels₁) := + FreeGroup.ext_hom _ _ fun _ ↦ rfl + +@[simp] +lemma lift_toCoprod_inr_eq_inr_mk : (FreeGroup.lift (toCoprod rels₁ rels₂)).comp + (FreeGroup.map Sum.inr) = Monoid.Coprod.inr.comp (mk rels₂) := + FreeGroup.ext_hom _ _ fun _ ↦ rfl + +lemma lift_toCoprod_eq_one (r : FreeGroup (α ⊕ β)) + (hr : r ∈ FreeGroup.map Sum.inl '' rels₁ ∪ FreeGroup.map Sum.inr '' rels₂) : + FreeGroup.lift (toCoprod rels₁ rels₂) r = 1 := by + obtain ⟨r, hr, rfl⟩ | ⟨r, hr, rfl⟩ := hr <;> simp [← MonoidHom.comp_apply, one_of_mem hr] + +/-- +The free product (Coproduct) of presentations is isomorphic to the presentation of the union over +the `FreeGroup (α ⊕ β)` +-/ +def coprodPresentations : + PresentedGroup (FreeGroup.map Sum.inl '' rels₁ ∪ FreeGroup.map Sum.inr '' rels₂) ≃* + Monoid.Coprod (PresentedGroup rels₁) (PresentedGroup rels₂) := + MonoidHom.toMulEquiv + (toGroup (lift_toCoprod_eq_one rels₁ rels₂)) + (Monoid.Coprod.lift + (PresentedGroup.map (FreeGroup.map Sum.inl) fun r hr ↦ .inl ⟨r, hr, rfl⟩) + (PresentedGroup.map (FreeGroup.map Sum.inr) fun r hr ↦ .inr ⟨r, hr, rfl⟩)) + (ext <| Sum.rec (fun _ ↦ rfl) (fun _ ↦ rfl)) + (Monoid.Coprod.hom_ext (ext fun _ ↦ rfl) (ext fun _ ↦ rfl)) +end Coprod end PresentedGroup diff --git a/Mathlib/GroupTheory/PushoutI.lean b/Mathlib/GroupTheory/PushoutI.lean index 0b298dd2b8a19f..31d04e07702548 100644 --- a/Mathlib/GroupTheory/PushoutI.lean +++ b/Mathlib/GroupTheory/PushoutI.lean @@ -496,14 +496,14 @@ noncomputable def consRecOn {motive : NormalWord d → Sort _} (w : NormalWord d (base : ∀ (h : H) (w : NormalWord d), w.head = 1 → motive w → motive (base φ h • w)) : motive w := by rcases w with ⟨w, head, h3⟩ - convert base head ⟨w, 1, h3⟩ rfl ?_ + convert! base head ⟨w, 1, h3⟩ rfl ?_ · simp [base_smul_def] · induction w using Word.consRecOn with | empty => exact empty | cons i g w h1 hg1 ih => - convert cons i g ⟨w, 1, fun _ _ h => h3 _ _ (List.mem_cons_of_mem _ h)⟩ - h1 (h3 _ _ List.mem_cons_self) ?_ rfl - (ih ?_) + convert! + cons i g ⟨w, 1, fun _ _ h => h3 _ _ (List.mem_cons_of_mem _ h)⟩ h1 + (h3 _ _ List.mem_cons_self) ?_ rfl (ih ?_) · simp only [Word.cons, NormalWord.cons, map_one, mul_one, (equiv_snd_eq_self_iff_mem (d.compl i) (one_mem _)).2 (h3 _ _ List.mem_cons_self)] diff --git a/Mathlib/GroupTheory/QuotientGroup/Basic.lean b/Mathlib/GroupTheory/QuotientGroup/Basic.lean index b4c561a927aedc..b269852a1222c1 100644 --- a/Mathlib/GroupTheory/QuotientGroup/Basic.lean +++ b/Mathlib/GroupTheory/QuotientGroup/Basic.lean @@ -8,7 +8,6 @@ module public import Mathlib.Algebra.Group.Subgroup.Pointwise public import Mathlib.Data.Int.Cast.Lemmas -public import Mathlib.GroupTheory.Congruence.Hom public import Mathlib.GroupTheory.Coset.Basic public import Mathlib.GroupTheory.QuotientGroup.Defs public import Mathlib.Algebra.BigOperators.Group.Finset.Defs diff --git a/Mathlib/GroupTheory/SpecificGroups/Alternating/Centralizer.lean b/Mathlib/GroupTheory/SpecificGroups/Alternating/Centralizer.lean index abecfd5f776ff1..0814180e5da1c6 100644 --- a/Mathlib/GroupTheory/SpecificGroups/Alternating/Centralizer.lean +++ b/Mathlib/GroupTheory/SpecificGroups/Alternating/Centralizer.lean @@ -177,7 +177,7 @@ theorem count_le_one_of_centralizer_le_alternating have hk_cT : k.val.cycleType = Multiset.replicate k.val.cycleType.card 2 := by rw [Multiset.eq_replicate_card, ← pow_prime_eq_one_iff, ← Subgroup.coe_pow, ← Subgroup.coe_one, Subtype.coe_inj, hk, ← map_pow] - convert MonoidHom.map_one _ + convert! MonoidHom.map_one _ rw [← Subtype.coe_inj] apply Equiv.swap_mul_self rw [sign_of_cycleType, hk_cT] @@ -228,12 +228,12 @@ theorem centralizer_le_alternating_iff : rw [← kerParam_range_eq_centralizer_of_count_le_one h_count] at hx obtain ⟨⟨y, uv⟩, rfl⟩ := MonoidHom.mem_range.mp hx rw [mem_alternatingGroup, sign_kerParam_apply_apply (g := g) y uv] - convert mul_one _ + convert! mul_one _ · apply Finset.prod_eq_one rintro ⟨c, hc⟩ _ obtain ⟨k, hk⟩ := (uv _).prop rw [← hk, map_zpow] - convert one_zpow k + convert! one_zpow k rw [IsCycle.sign, Odd.neg_one_pow, neg_neg] · apply h_odd rw [cycleType_def, Multiset.mem_map] diff --git a/Mathlib/GroupTheory/SpecificGroups/Alternating/KleinFour.lean b/Mathlib/GroupTheory/SpecificGroups/Alternating/KleinFour.lean index bb01d92291dbb8..38f32ea1732143 100644 --- a/Mathlib/GroupTheory/SpecificGroups/Alternating/KleinFour.lean +++ b/Mathlib/GroupTheory/SpecificGroups/Alternating/KleinFour.lean @@ -118,7 +118,7 @@ theorem coe_two_sylow_of_card_eq_four · -- inclusion S ⊆ {1} ∪ {g | cycleType g = { 2, 2 }} obtain ⟨n, hn⟩ := (IsPGroup.iff_orderOf.mp S.isPGroup') ⟨k, hk⟩ replace hn : (orderOf (k : Perm α)) = 2 ^ n := by simpa using hn - convert mem_kleinFour_of_order_two_pow hα4 k.2 hn.dvd + convert! mem_kleinFour_of_order_two_pow hα4 k.2 hn.dvd simp · -- card (kleinFour α) ≤ card S simp_rw [← Nat.card_eq_fintype_card] @@ -173,9 +173,9 @@ theorem exponent_kleinFour_of_card_eq_four (hα4 : Nat.card α = 4) : simp only [Subgroup.orderOf_mk, orderOf_dvd_iff_pow_eq_one] rw [← SetLike.mem_coe, coe_kleinFour_of_card_eq_four hα4] at hg' rcases hg' with hg' | hg' - · convert one_pow _ + · convert! one_pow _ simpa only [Set.mem_singleton_iff, Subgroup.mk_eq_one] using hg' - · convert pow_orderOf_eq_one g + · convert! pow_orderOf_eq_one g rw [← Equiv.Perm.lcm_cycleType, hg'] simp rw [Nat.dvd_prime Nat.prime_two] at this diff --git a/Mathlib/GroupTheory/SpecificGroups/Alternating/MaximalSubgroups.lean b/Mathlib/GroupTheory/SpecificGroups/Alternating/MaximalSubgroups.lean index a203be1f7287b8..f53c195d6d9c20 100644 --- a/Mathlib/GroupTheory/SpecificGroups/Alternating/MaximalSubgroups.lean +++ b/Mathlib/GroupTheory/SpecificGroups/Alternating/MaximalSubgroups.lean @@ -92,7 +92,7 @@ theorem stabilizer.surjective_toPerm {s : Set α} (hs : sᶜ.Nontrivial) : intro _ simp only [mem_smul_set] rintro ⟨x, hx, rfl⟩ - convert hx + convert! hx rw [Perm.smul_def, ← Perm.notMem_support] exact (Set.disjoint_left.mp hk_support) hx intro g diff --git a/Mathlib/GroupTheory/SpecificGroups/Alternating/Simple.lean b/Mathlib/GroupTheory/SpecificGroups/Alternating/Simple.lean index b9717035c55abd..47abda9765ffbc 100644 --- a/Mathlib/GroupTheory/SpecificGroups/Alternating/Simple.lean +++ b/Mathlib/GroupTheory/SpecificGroups/Alternating/Simple.lean @@ -75,7 +75,7 @@ def iwasawaStructure_two [∀ s : Set α, DecidablePred fun x ↦ x ∈ s] : have : IsMulCommutative (Perm s) := isMulCommutative_iff_card_le_two.mpr (by simp) infer_instance is_conj g s := by - convert (conj_smul_range_ofSubtype g s).symm + convert! (conj_smul_range_ofSubtype g s).symm is_generator := by rw [eq_top_iff, ← Equiv.Perm.closure_isSwap, Subgroup.closure_le] rintro g ⟨a, b, hab, rfl⟩ diff --git a/Mathlib/GroupTheory/SpecificGroups/Cyclic.lean b/Mathlib/GroupTheory/SpecificGroups/Cyclic.lean index cbfe2a12e7318c..167ef7b6a74d34 100644 --- a/Mathlib/GroupTheory/SpecificGroups/Cyclic.lean +++ b/Mathlib/GroupTheory/SpecificGroups/Cyclic.lean @@ -573,7 +573,8 @@ variable (G) in noncomputable def IsCyclic.mulAutMulEquiv [Group G] [h : IsCyclic G] : MulAut G ≃* (ZMod (Nat.card G))ˣ := ((MulAut.congr (zmodCyclicMulEquiv h)).symm.trans - (MulAutMultiplicative (ZMod (Nat.card G)))).trans (ZMod.AddAutEquivUnits (Nat.card G)) + (MulAutMultiplicative (ZMod (Nat.card G)))).trans + (ZMod.AddAutEquivUnits (Nat.card G)).toMultiplicative variable (G) in theorem IsCyclic.card_mulAut [Group G] [Finite G] [h : IsCyclic G] : diff --git a/Mathlib/GroupTheory/SpecificGroups/Cyclic/Basic.lean b/Mathlib/GroupTheory/SpecificGroups/Cyclic/Basic.lean index 585a96d9494533..cfd567da7754a6 100644 --- a/Mathlib/GroupTheory/SpecificGroups/Cyclic/Basic.lean +++ b/Mathlib/GroupTheory/SpecificGroups/Cyclic/Basic.lean @@ -220,7 +220,7 @@ theorem exists_pow_ne_one_of_isCyclic [G_cyclic : IsCyclic G] rcases G_cyclic with ⟨a, ha⟩ use a contrapose! k_lt_card_G - convert orderOf_le_of_pow_eq_one k_pos.bot_lt k_lt_card_G + convert! orderOf_le_of_pow_eq_one k_pos.bot_lt k_lt_card_G rw [← Nat.card_zpowers, eq_comm, card_eq_iff_eq_top, eq_top_iff] exact fun x _ ↦ ha x diff --git a/Mathlib/GroupTheory/SpecificGroups/Dihedral.lean b/Mathlib/GroupTheory/SpecificGroups/Dihedral.lean index 43572ba856ee1c..abea98a604b6d9 100644 --- a/Mathlib/GroupTheory/SpecificGroups/Dihedral.lean +++ b/Mathlib/GroupTheory/SpecificGroups/Dihedral.lean @@ -220,9 +220,9 @@ theorem exponent : Monoid.exponent (DihedralGroup n) = lcm n 2 := by · rw [← orderOf_dvd_iff_pow_eq_one, orderOf_sr] exact dvd_lcm_right n 2 · apply lcm_dvd - · convert Monoid.order_dvd_exponent (r (1 : ZMod n)) + · convert! Monoid.order_dvd_exponent (r (1 : ZMod n)) exact orderOf_r_one.symm - · convert Monoid.order_dvd_exponent (sr (0 : ZMod n)) + · convert! Monoid.order_dvd_exponent (sr (0 : ZMod n)) exact (orderOf_sr 0).symm lemma not_commutative : ∀ {n : ℕ}, n ≠ 1 → n ≠ 2 → ¬IsMulCommutative (DihedralGroup n) diff --git a/Mathlib/GroupTheory/SpecificGroups/Quaternion.lean b/Mathlib/GroupTheory/SpecificGroups/Quaternion.lean index 42b73e2c582a4a..cf44529992f105 100644 --- a/Mathlib/GroupTheory/SpecificGroups/Quaternion.lean +++ b/Mathlib/GroupTheory/SpecificGroups/Quaternion.lean @@ -262,9 +262,9 @@ theorem exponent : Monoid.exponent (QuaternionGroup n) = 2 * lcm n 2 := by · rw [← orderOf_dvd_iff_pow_eq_one, orderOf_xa] exact dvd_lcm_right (2 * n) 4 · apply lcm_dvd - · convert Monoid.order_dvd_exponent (a 1) + · convert! Monoid.order_dvd_exponent (a 1) exact orderOf_a_one.symm - · convert Monoid.order_dvd_exponent (xa (0 : ZMod (2 * n))) + · convert! Monoid.order_dvd_exponent (xa (0 : ZMod (2 * n))) exact (orderOf_xa 0).symm end QuaternionGroup diff --git a/Mathlib/GroupTheory/Subgroup/Centralizer.lean b/Mathlib/GroupTheory/Subgroup/Centralizer.lean index 64cf7478c6198c..dd2a87b9c066a8 100644 --- a/Mathlib/GroupTheory/Subgroup/Centralizer.lean +++ b/Mathlib/GroupTheory/Subgroup/Centralizer.lean @@ -157,7 +157,7 @@ instance instIsMulCommutative_closure {S : Type*} [SetLike S G] [MulMemClass S G theorem centralizer_le_normalizer (s : Set G) : centralizer s ≤ normalizer s := by refine fun g hg h ↦ ⟨fun hh ↦ ?_, fun hh ↦ ?_⟩ · simpa [← hg h hh] - · convert hh + · convert! hh simpa using hg _ hh @[to_additive] diff --git a/Mathlib/GroupTheory/Submonoid/Inverses.lean b/Mathlib/GroupTheory/Submonoid/Inverses.lean index a9fbba3d794619..847d5ddb31f104 100644 --- a/Mathlib/GroupTheory/Submonoid/Inverses.lean +++ b/Mathlib/GroupTheory/Submonoid/Inverses.lean @@ -47,13 +47,18 @@ noncomputable instance [Monoid M] : Group (IsUnit.submonoid M) := @[to_additive] noncomputable instance [CommMonoid M] : CommGroup (IsUnit.submonoid M) := { (inferInstance : Group (IsUnit.submonoid M)) with - mul_comm := fun a b ↦ by convert mul_comm a b } + mul_comm := fun a b ↦ by convert! mul_comm a b } @[to_additive] -theorem IsUnit.Submonoid.coe_inv [Monoid M] (x : IsUnit.submonoid M) : +theorem _root_.IsUnit.submonoid.coe_inv [Monoid M] (x : IsUnit.submonoid M) : ↑x⁻¹ = (↑x.prop.unit⁻¹ : M) := rfl +@[deprecated (since := "2026-05-24")] +alias _root_.AddSubmonoid.IsUnit.Submonoid.coe_neg := IsAddUnit.addSubmonoid.coe_neg +@[to_additive existing, deprecated (since := "2026-05-24")] +alias IsUnit.Submonoid.coe_inv := IsUnit.submonoid.coe_inv + section Monoid variable [Monoid M] (S : Submonoid M) @@ -70,7 +75,7 @@ def leftInv : Submonoid M where @[to_additive] theorem leftInv_leftInv_le : S.leftInv.leftInv ≤ S := by rintro x ⟨⟨y, z, h₁⟩, h₂ : x * y = 1⟩ - convert z.prop + convert! z.prop rw [← mul_one x, ← h₁, ← mul_assoc, h₂, one_mul] @[to_additive] @@ -168,12 +173,12 @@ theorem mul_leftInvEquiv (x : S.leftInv) : (x : M) * S.leftInvEquiv hS x = 1 := @[to_additive (attr := simp)] theorem leftInvEquiv_symm_mul (x : S) : ((S.leftInvEquiv hS).symm x : M) * x = 1 := by - convert S.mul_leftInvEquiv hS ((S.leftInvEquiv hS).symm x) + convert! S.mul_leftInvEquiv hS ((S.leftInvEquiv hS).symm x) simp @[to_additive (attr := simp)] theorem mul_leftInvEquiv_symm (x : S) : (x : M) * (S.leftInvEquiv hS).symm x = 1 := by - convert S.leftInvEquiv_mul hS ((S.leftInvEquiv hS).symm x) + convert! S.leftInvEquiv_mul hS ((S.leftInvEquiv hS).symm x) simp end CommMonoid diff --git a/Mathlib/GroupTheory/Sylow.lean b/Mathlib/GroupTheory/Sylow.lean index 2f705d30131a95..c726ff3cd679ee 100644 --- a/Mathlib/GroupTheory/Sylow.lean +++ b/Mathlib/GroupTheory/Sylow.lean @@ -522,7 +522,7 @@ theorem mem_fixedPoints_mul_left_cosets_iff_mem_normalizer {H : Subgroup G} [Fin have : (n⁻¹ * x)⁻¹ * x ∈ H := QuotientGroup.eq.1 (ha ⟨⟨n⁻¹, inv_mem hn⟩, rfl⟩) show _ ∈ H by rw [mul_inv_rev, inv_inv] at this - convert this + convert! this rw [inv_inv]), fun hx : ∀ n : G, n ∈ H ↔ x * n * x⁻¹ ∈ H => mem_fixedPoints'.2 fun y => @@ -614,7 +614,7 @@ theorem exists_subgroup_card_pow_succ [Finite G] {p : ℕ} {n : ℕ} [hp : Fact (comap (mk' (H.subgroupOf (normalizer H))) (Subgroup.zpowers x))) = p ^ (n + 1) suffices Nat.card (Subtype.val '' ((zpowers x).comap (mk' (H.subgroupOf (normalizer H))) : Set (normalizer H))) = p ^ (n + 1) - by convert this using 2 + by convert! this using 2 rw [Nat.card_image_of_injective Subtype.val_injective ((zpowers x).comap (mk' (H.subgroupOf (normalizer H))) : Set (normalizer (H : Set G))), pow_succ, ← hH, Nat.card_congr hequiv, ← hx, ← Nat.card_zpowers, ← Nat.card_prod] diff --git a/Mathlib/GroupTheory/Torsion.lean b/Mathlib/GroupTheory/Torsion.lean index d8b93cf5c1ef7a..123b45aeb5b047 100644 --- a/Mathlib/GroupTheory/Torsion.lean +++ b/Mathlib/GroupTheory/Torsion.lean @@ -56,10 +56,10 @@ def IsTorsion := ∀ g : G, IsOfFinOrder g /-- A monoid is not a torsion monoid if it has an element of infinite order. -/ -@[to_additive (attr := simp) /-- An additive monoid is not a torsion monoid if it - has an element of infinite order. -/] -theorem not_isTorsion_iff : ¬IsTorsion G ↔ ∃ g : G, ¬IsOfFinOrder g := by - rw [IsTorsion, not_forall] +@[to_additive (attr := simp) +/-- An additive monoid is not a torsion monoid if it has an element of infinite order. -/] +theorem not_isTorsion_iff : ¬IsTorsion G ↔ ∃ g : G, ¬IsOfFinOrder g := + not_forall end Monoid @@ -67,11 +67,11 @@ open Monoid /-- Torsion monoids are really groups. -/ @[to_additive (attr := implicit_reducible) - /-- Torsion additive monoids are really additive groups -/] +/-- Torsion additive monoids are really additive groups -/] noncomputable def IsTorsion.group [Monoid G] (tG : IsTorsion G) : Group G := { ‹Monoid G› with - inv := fun g => g ^ (orderOf g - 1) - inv_mul_cancel := fun g => by + inv g := g ^ (orderOf g - 1) + inv_mul_cancel g := by rw [← pow_succ, tsub_add_cancel_of_le, pow_orderOf_eq_one] exact (tG g).orderOf_pos } @@ -81,51 +81,50 @@ variable [Group G] {N : Subgroup G} [Group H] /-- Subgroups of torsion groups are torsion groups. -/ @[to_additive /-- Subgroups of additive torsion groups are additive torsion groups. -/] -theorem IsTorsion.subgroup (tG : IsTorsion G) (H : Subgroup G) : IsTorsion H := fun h => +theorem IsTorsion.subgroup (tG : IsTorsion G) (H : Subgroup G) : IsTorsion H := fun h ↦ Submonoid.isOfFinOrder_coe.1 <| tG h /-- The image of a surjective torsion group homomorphism is torsion. -/ @[to_additive AddIsTorsion.of_surjective - /-- The image of a surjective additive torsion group homomorphism is torsion. -/] +/-- The image of a surjective additive torsion group homomorphism is torsion. -/] theorem IsTorsion.of_surjective {f : G →* H} (hf : Function.Surjective f) (tG : IsTorsion G) : - IsTorsion H := fun h => by - obtain ⟨g, hg⟩ := hf h - rw [← hg] + IsTorsion H := fun h ↦ by + obtain ⟨g, rfl⟩ := hf h exact f.isOfFinOrder (tG g) /-- Torsion groups are closed under extensions. -/ @[to_additive AddIsTorsion.extension_closed /-- Additive torsion groups are closed under extensions. -/] theorem IsTorsion.extension_closed {f : G →* H} (hN : N = f.ker) (tH : IsTorsion H) - (tN : IsTorsion N) : IsTorsion G := fun g => by + (tN : IsTorsion N) : IsTorsion G := fun g ↦ by obtain ⟨ngn, ngnpos, hngn⟩ := (tH <| f g).exists_pow_eq_one have hmem := MonoidHom.mem_ker.mpr ((f.map_pow g ngn).trans hngn) lift g ^ ngn to N using hN.symm ▸ hmem with gn h obtain ⟨nn, nnpos, hnn⟩ := (tN gn).exists_pow_eq_one exact isOfFinOrder_iff_pow_eq_one.mpr <| ⟨ngn * nn, mul_pos ngnpos nnpos, by - rw [pow_mul, ← h, ← Subgroup.coe_pow, hnn, Subgroup.coe_one]⟩ + rw [pow_mul, ← h, ← Subgroup.coe_pow, hnn, Subgroup.coe_one]⟩ /-- The image of a quotient is torsion iff the group is torsion. -/ @[to_additive AddIsTorsion.quotient_iff - /-- The image of a quotient is additively torsion iff the group is torsion. -/] +/-- The image of a quotient is additively torsion iff the group is torsion. -/] theorem IsTorsion.quotient_iff {f : G →* H} (hf : Function.Surjective f) (hN : N = f.ker) (tN : IsTorsion N) : IsTorsion H ↔ IsTorsion G := - ⟨fun tH => IsTorsion.extension_closed hN tH tN, fun tG => IsTorsion.of_surjective hf tG⟩ + ⟨fun tH ↦ IsTorsion.extension_closed hN tH tN, fun tG ↦ IsTorsion.of_surjective hf tG⟩ /-- If a group exponent exists, the group is torsion. -/ @[to_additive ExponentExists.is_add_torsion - /-- If a group exponent exists, the group is additively torsion. -/] -theorem ExponentExists.isTorsion (h : ExponentExists G) : IsTorsion G := fun g => by +/-- If a group exponent exists, the group is additively torsion. -/] +theorem ExponentExists.isTorsion (h : ExponentExists G) : IsTorsion G := fun g ↦ by obtain ⟨n, npos, hn⟩ := h exact isOfFinOrder_iff_pow_eq_one.mpr ⟨n, npos, hn g⟩ /-- The group exponent exists for any bounded torsion group. -/ @[to_additive IsAddTorsion.exponentExists - /-- The group exponent exists for any bounded additive torsion group. -/] +/-- The group exponent exists for any bounded additive torsion group. -/] theorem IsTorsion.exponentExists (tG : IsTorsion G) - (bounded : (Set.range fun g : G => orderOf g).Finite) : ExponentExists G := + (bounded : (Set.range fun g : G ↦ orderOf g).Finite) : ExponentExists G := exponent_ne_zero.mp <| - (exponent_ne_zero_iff_range_orderOf_finite fun g => (tG g).orderOf_pos).mpr bounded + (exponent_ne_zero_iff_range_orderOf_finite fun g ↦ (tG g).orderOf_pos).mpr bounded /-- Finite groups are torsion groups. -/ @[to_additive is_add_torsion_of_finite /-- Finite additive groups are additive torsion groups. -/] @@ -158,8 +157,7 @@ namespace AddMonoid /-- A module whose scalars are additively torsion is additively torsion. -/ theorem IsTorsion.module_of_torsion [Semiring R] [Module R M] (tR : IsTorsion R) : IsTorsion M := - fun f => - isOfFinAddOrder_iff_nsmul_eq_zero.mpr <| by + fun f ↦ isOfFinAddOrder_iff_nsmul_eq_zero.mpr <| by obtain ⟨n, npos, hn⟩ := (tR 1).exists_nsmul_eq_zero exact ⟨n, npos, by simp only [← Nat.cast_smul_eq_nsmul R _ f, ← nsmul_one, hn, zero_smul]⟩ @@ -198,7 +196,7 @@ variable {G} /-- Torsion submonoids are torsion. -/ @[to_additive /-- Additive torsion submonoids are additively torsion. -/] -theorem torsion.isTorsion : IsTorsion <| torsion G := fun ⟨x, n, npos, hn⟩ => +theorem torsion.isTorsion : IsTorsion <| torsion G := fun ⟨x, n, npos, hn⟩ ↦ ⟨n, npos, Subtype.ext <| by dsimp @@ -207,44 +205,56 @@ theorem torsion.isTorsion : IsTorsion <| torsion G := fun ⟨x, n, npos, hn⟩ = rw [_root_.mul_one, SubmonoidClass.coe_pow, Subtype.coe_mk, (isPeriodicPt_mul_iff_pow_eq_one _).mp hn]⟩ -variable (G) (p : ℕ) [hp : Fact p.Prime] +variable (G) (p : ℕ) -/-- The `p`-primary component is the submonoid of elements with order prime-power of `p`. -/ -@[to_additive (attr := simps) - /-- The `p`-primary component is the submonoid of elements with additive - order prime-power of `p`. -/] +/-- The `p`-primary component is the submonoid of elements `g` such that `g ^ p ^ k = 1` +for some `k`. For prime `p`, these are exactly the elements of `p`-power order. -/ +@[to_additive +/-- The additive `p`-primary component is the submonoid of elements `g` such that +`p ^ k • g = 0` for some `k`. For prime `p`, these are exactly the elements of additive +`p`-power order. -/] def primaryComponent : Submonoid G where - carrier := { g | ∃ n : ℕ, orderOf g = p ^ n } - one_mem' := ⟨0, by rw [pow_zero, orderOf_one]⟩ - mul_mem' hg₁ hg₂ := - exists_orderOf_eq_prime_pow_iff.mpr <| by - obtain ⟨m, hm⟩ := exists_orderOf_eq_prime_pow_iff.mp hg₁ - obtain ⟨n, hn⟩ := exists_orderOf_eq_prime_pow_iff.mp hg₂ - exact - ⟨m + n, by - rw [mul_pow, pow_add, pow_mul, hm, one_pow, Monoid.one_mul, mul_comm, pow_mul, hn, - one_pow]⟩ + carrier := { g | ∃ k : ℕ, g ^ p ^ k = 1 } + one_mem' := ⟨0, by simp⟩ + mul_mem' := fun {a b} ⟨m, hm⟩ ⟨n, hn⟩ ↦ ⟨m + n, by + rw [mul_pow, pow_add, pow_mul, hm, one_pow, one_mul, mul_comm, pow_mul, hn, one_pow]⟩ variable {G} {p} +/-- `g` lies in the `p`-primary component iff `g ^ p ^ k = 1` for some `k`. -/ +@[to_additive (attr := simp) +/-- `g` lies in the additive `p`-primary component iff `p ^ k • g = 0` for some `k`. -/] +theorem mem_primaryComponent {g : G} : g ∈ primaryComponent G p ↔ ∃ k : ℕ, g ^ p ^ k = 1 := + .rfl + +/-- For prime `p`, `g` lies in the `p`-primary component iff its order is a power of `p`. -/ +@[to_additive +/-- For prime `p`, `g` lies in the additive `p`-primary component iff its additive +order is a power of `p`. -/] +theorem mem_primaryComponent_iff_orderOf [Fact p.Prime] {g : G} : + g ∈ primaryComponent G p ↔ ∃ n : ℕ, orderOf g = p ^ n := + exists_orderOf_eq_prime_pow_iff.symm + +variable [hp : Fact p.Prime] + /-- Elements of the `p`-primary component have order `p^n` for some `n`. -/ @[to_additive primaryComponent.exists_orderOf_eq_prime_nsmul - /-- Elements of the `p`-primary component have additive order `p^n` for some `n` -/] +/-- Elements of the `p`-primary component have additive order `p^n` for some `n`. -/] theorem primaryComponent.exists_orderOf_eq_prime_pow (g : CommMonoid.primaryComponent G p) : ∃ n : ℕ, orderOf g = p ^ n := by - obtain ⟨_, hn⟩ := g.property - rw [orderOf_submonoid g] at hn - exact ⟨_, hn⟩ + rw [← orderOf_submonoid, ← mem_primaryComponent_iff_orderOf] + exact g.property /-- The `p`- and `q`-primary components are disjoint for `p ≠ q`. -/ @[to_additive /-- The `p`- and `q`-primary components are disjoint for `p ≠ q`. -/] theorem primaryComponent.disjoint {p' : ℕ} [hp' : Fact p'.Prime] (hne : p ≠ p') : Disjoint (CommMonoid.primaryComponent G p) (CommMonoid.primaryComponent G p') := - Submonoid.disjoint_def.mpr <| by - rintro g ⟨_ | n, hn⟩ ⟨n', hn'⟩ + Submonoid.disjoint_def.mpr fun {g} hg hg' ↦ by + rw [mem_primaryComponent_iff_orderOf] at hg hg' + obtain ⟨_ | n, hn⟩ := hg · rwa [pow_zero, orderOf_eq_one_iff] at hn - · exact - absurd (eq_of_prime_pow_eq hp.out.prime hp'.out.prime n.succ_pos (hn.symm.trans hn')) hne + · obtain ⟨_, hn'⟩ := hg' + exact absurd (eq_of_prime_pow_eq hp.out.prime hp'.out.prime n.succ_pos (hn ▸ hn')) hne end CommMonoid @@ -278,8 +288,8 @@ end Monoid.IsTorsion /-- Torsion submonoids of a torsion submonoid are isomorphic to the submonoid. -/ @[to_additive (attr := simp) AddCommMonoid.Torsion.ofTorsion - /-- Additive torsion submonoids of an additive torsion submonoid are - isomorphic to the submonoid. -/] +/-- Additive torsion submonoids of an additive torsion submonoid are +isomorphic to the submonoid. -/] def Torsion.ofTorsion : torsion (torsion G) ≃* torsion G := Monoid.IsTorsion.torsionMulEquiv CommMonoid.torsion.isTorsion @@ -294,15 +304,17 @@ namespace CommGroup /-- The torsion subgroup of an abelian group. -/ @[to_additive /-- The torsion subgroup of an additive abelian group. -/] def torsion : Subgroup G := - { CommMonoid.torsion G with inv_mem' := fun hx => IsOfFinOrder.inv hx } + { CommMonoid.torsion G with inv_mem' := fun hx ↦ IsOfFinOrder.inv hx } /-- The torsion submonoid of an abelian group equals the torsion subgroup as a submonoid. -/ @[to_additive add_torsion_eq_add_torsion_submonoid - /-- The additive torsion submonoid of an abelian group equals the torsion - subgroup as a submonoid. -/] +/-- The additive torsion submonoid of an abelian group equals the torsion +subgroup as a submonoid. -/] theorem torsion_eq_torsion_submonoid : CommMonoid.torsion G = (torsion G).toSubmonoid := rfl +variable {G} + @[to_additive] theorem mem_torsion (g : G) : g ∈ torsion G ↔ IsOfFinOrder g := Iff.rfl @@ -315,10 +327,26 @@ lemma isMulTorsionFree_iff_torsion_eq_bot : IsMulTorsionFree G ↔ CommGroup.tor rw [isMulTorsionFree_iff_not_isOfFinOrder, eq_bot_iff, SetLike.le_def] simp [not_imp_not, CommGroup.mem_torsion] +@[to_additive] +lemma comap_torsion_of_injective {f : G →* H} (hf : Function.Injective f) : + (torsion H).comap f = torsion G := by + ext x + exact hf.isOfFinOrder_iff + +@[to_additive] +lemma _root_.MulEquiv.comap_torsion (e : G ≃* H) : (torsion H).comap e = torsion G := + comap_torsion_of_injective e.injective + +@[to_additive] +lemma _root_.MulEquiv.map_torsion (e : G ≃* H) : (torsion G).map e = torsion H := by + rw [Subgroup.map_equiv_eq_comap_symm, e.symm.comap_torsion] + @[to_additive] lemma torsion_prod : torsion (G × H) = (torsion G).prod (torsion H) := by simp [Subgroup.ext_iff, Subgroup.mem_prod, mem_torsion, IsOfFinOrder.prod_iff] +variable (G) + @[to_additive] lemma isTorsion_quotient_range_powMonoidHom {n : ℕ} (hn : n ≠ 0) : Monoid.IsTorsion (G ⧸ (powMonoidHom (α := G) n).range) := by @@ -327,22 +355,37 @@ lemma isTorsion_quotient_range_powMonoidHom {n : ℕ} (hn : n ≠ 0) : rw [← QuotientGroup.mk_pow, QuotientGroup.eq_one_iff] simp -variable (p : ℕ) [hp : Fact p.Prime] +variable (p : ℕ) -/-- The `p`-primary component is the subgroup of elements with order prime-power of `p`. -/ -@[to_additive (attr := simps!) - /-- The `p`-primary component is the subgroup of elements with additive order - prime-power of `p`. -/] +/-- The `p`-primary component is the subgroup of elements `g` such that `g ^ p ^ k = 1` +for some `k`. For prime `p`, these are exactly the elements of `p`-power order. -/ +@[to_additive +/-- The additive `p`-primary component is the subgroup of elements `g` such that +`p ^ k • g = 0` for some `k`. For prime `p`, these are exactly the elements of additive +`p`-power order. -/] def primaryComponent : Subgroup G := { CommMonoid.primaryComponent G p with - inv_mem' := fun {g} ⟨n, hn⟩ => ⟨n, (orderOf_inv g).trans hn⟩ } + inv_mem' := fun {g} ⟨k, hk⟩ ↦ ⟨k, by rw [inv_pow, hk, inv_one]⟩ } variable {G} {p} -/-- The `p`-primary component is a `p` group. -/ -theorem primaryComponent.isPGroup : IsPGroup p <| primaryComponent G p := fun g => - (propext exists_orderOf_eq_prime_pow_iff.symm).mpr - (CommMonoid.primaryComponent.exists_orderOf_eq_prime_pow g) +/-- `g` lies in the `p`-primary component iff `g ^ p ^ k = 1` for some `k`. -/ +@[to_additive (attr := simp) +/-- `g` lies in the additive `p`-primary component iff `p ^ k • g = 0` for some `k`. -/] +theorem mem_primaryComponent {g : G} : g ∈ primaryComponent G p ↔ ∃ k : ℕ, g ^ p ^ k = 1 := + .rfl + +/-- For prime `p`, `g` lies in the `p`-primary component iff its order is a power of `p`. -/ +@[to_additive +/-- For prime `p`, `g` lies in the additive `p`-primary component iff its additive +order is a power of `p`. -/] +theorem mem_primaryComponent_iff_orderOf [Fact p.Prime] {g : G} : + g ∈ primaryComponent G p ↔ ∃ n : ℕ, orderOf g = p ^ n := + exists_orderOf_eq_prime_pow_iff.symm + +/-- The `p`-primary component is a `p`-group. -/ +theorem primaryComponent.isPGroup : IsPGroup p (primaryComponent G p) := fun g ↦ + g.property.imp fun _ hk ↦ Subtype.ext <| by simpa using hk end CommGroup @@ -373,8 +416,8 @@ instance {R M : Type*} [Ring R] [AddCommGroup M] [Module R M] : let e : (M ⧸ AddCommGroup.torsion M) ≃+ (M ⧸ S) := QuotientAddGroup.congr _ _ (.refl _) (by simp [S]) -- So we can copy over scalar multiplication. - letI : SMul R (M ⧸ AddCommGroup.torsion M) := ⟨fun r m => e.symm (r • e m)⟩ - Function.Injective.module R e.toAddMonoidHom e.injective (fun _ _ => + letI : SMul R (M ⧸ AddCommGroup.torsion M) := ⟨fun r m ↦ e.symm (r • e m)⟩ + Function.Injective.module R e.toAddMonoidHom e.injective (fun _ _ ↦ e.symm.injective (e.symm_apply_apply _)) end AddCommGroup diff --git a/Mathlib/InformationTheory/KullbackLeibler/Basic.lean b/Mathlib/InformationTheory/KullbackLeibler/Basic.lean index e3318363356624..783b5d96721160 100644 --- a/Mathlib/InformationTheory/KullbackLeibler/Basic.lean +++ b/Mathlib/InformationTheory/KullbackLeibler/Basic.lean @@ -84,7 +84,7 @@ lemma klDiv_self (μ : Measure α) [SigmaFinite μ] : klDiv μ μ = 0 := by @[simp] lemma klDiv_zero_left [IsFiniteMeasure ν] : klDiv 0 ν = ν univ := by - convert klDiv_of_ac_of_integrable (Measure.AbsolutelyContinuous.zero _) integrable_zero_measure + convert! klDiv_of_ac_of_integrable (Measure.AbsolutelyContinuous.zero _) integrable_zero_measure simp @[simp] diff --git a/Mathlib/InformationTheory/KullbackLeibler/KLFun.lean b/Mathlib/InformationTheory/KullbackLeibler/KLFun.lean index 9cc926ea638db8..4f0487fc8c7be9 100644 --- a/Mathlib/InformationTheory/KullbackLeibler/KLFun.lean +++ b/Mathlib/InformationTheory/KullbackLeibler/KLFun.lean @@ -87,7 +87,7 @@ section Derivatives /-- The derivative of `klFun` at `x ≠ 0` is `log x`. -/ lemma hasDerivAt_klFun (hx : x ≠ 0) : HasDerivAt klFun (log x) x := by - convert ((hasDerivAt_mul_log hx).add (hasDerivAt_const x 1)).sub (hasDerivAt_id x) using 1 + convert! ((hasDerivAt_mul_log hx).add (hasDerivAt_const x 1)).sub (hasDerivAt_id x) using 1 ring lemma not_differentiableAt_klFun_zero : ¬ DifferentiableAt ℝ klFun 0 := by @@ -170,7 +170,7 @@ lemma integrable_klFun_rnDeriv_iff (hμν : μ ≪ ν) : Integrable (fun x ↦ klFun (μ.rnDeriv ν x).toReal) ν ↔ Integrable (llr μ ν) μ := by suffices Integrable (fun x ↦ (μ.rnDeriv ν x).toReal * log (μ.rnDeriv ν x).toReal + (1 - (μ.rnDeriv ν x).toReal)) ν ↔ Integrable (llr μ ν) μ by - convert this using 3 with x + convert! this using 3 with x rw [klFun, add_sub_assoc] rw [integrable_add_iff_integrable_left', integrable_rnDeriv_mul_log_iff hμν] fun_prop diff --git a/Mathlib/Init.lean b/Mathlib/Init.lean index d0760e71b0bf60..dab3e5140a5402 100644 --- a/Mathlib/Init.lean +++ b/Mathlib/Init.lean @@ -16,6 +16,7 @@ public import Mathlib.Tactic.Linter.Header public import Mathlib.Tactic.Linter.FlexibleLinter public import Mathlib.Tactic.Linter.Multigoal public import Mathlib.Tactic.Linter.OldObtain +public import Mathlib.Tactic.Linter.OverlappingInstances public import Mathlib.Tactic.Linter.PrivateModule public import Mathlib.Tactic.Linter.TacticDocumentation -- The following import contains the environment extension for the unused tactic linter. diff --git a/Mathlib/Lean/Elab/InfoTree.lean b/Mathlib/Lean/Elab/InfoTree.lean index a7350bfff60158..9755b678eea600 100644 --- a/Mathlib/Lean/Elab/InfoTree.lean +++ b/Mathlib/Lean/Elab/InfoTree.lean @@ -99,6 +99,17 @@ def onHighestNode? {α} (t : InfoTree) (ctx? : Option ContextInfo) (f : ContextInfo → Info → PersistentArray InfoTree → α) : Option α := t.findSome? (ctx? := ctx?) fun ctx i ch => some (f ctx i ch) +/-- +Returns the context and `info` on the outermost `.node info _` which has +context, having merged and updated contexts appropriately. + +If `ctx?` is `some ctx`, `ctx` is used as an initial context. A `ctx?` of `none` should **only** be +used when operating on the first node of the entire infotree. Otherwise, it is likely that no +context will be found. +-/ +def getHighestInfo? (t : InfoTree) (ctx? : Option ContextInfo) : Option (ContextInfo × Info) := + t.onHighestNode? ctx? fun ctx i _ => (ctx, i) + /-- Get the `parentDecl`s of every elaborated body. @@ -119,6 +130,22 @@ def getDeclsByBody (t : InfoTree) : List Name := else decls | _ => decls +/-- Gets the first child info of each `Lean.Elab.BodyInfo`, which should be the only child, and +should be a `TermInfo`, `PartialTermInfo`, or `TacticInfo`. `getDeclBodyInfos` does not validate +either of these conditions. -/ +def getDeclBodyInfos (t : InfoTree) : List (Syntax × ContextInfo × Info) := + t.foldInfoTree (init := []) fun ctx t acc => + match t with + | .node (.ofCustomInfo i) body => Id.run do + if i.value.typeName == ``Lean.Elab.Term.BodyInfo then + if h : 0 < body.size then + -- See through `.context`s instead of just matching on `.node`: + let result? := body[0].getHighestInfo? ctx + if let some result := result? then + return (i.stx, result) :: acc + return acc + | _ => acc + /-- Get the declarations elaborated in the infotree `t` which are theorems according to the environment. This includes e.g. `instance`s of `Prop` classes in addition to declarations declared @@ -127,4 +154,21 @@ using the keyword `theorem` directly. def getTheorems (t : InfoTree) (env : Environment) : List ConstantVal := t.getDeclsByBody.filterMap env.findTheoremConstVal? -end Lean.Elab.InfoTree +end InfoTree + +namespace Info + +/-- Gets the local context, and the expected type of the `Info`. +Handles `TacticInfo`s (looking at the first goal), `TermInfo`s, and `PartialTermInfo`s. +Does not get the metavariable context; assumes that the caller has accumulated an ambient +`ContextInfo` at this point which is sufficient. -/ +def getLCtx? : Info → Option (LocalContext × Option Expr) + | .ofTacticInfo i => do + let g ← i.goalsBefore.head? + let decl ← i.mctxBefore.findDecl? g + some (decl.lctx, decl.type) + | .ofTermInfo i + | .ofPartialTermInfo i => some (i.lctx, i.expectedType?) + | _ => none + +end Lean.Elab.Info diff --git a/Mathlib/LinearAlgebra/AffineSpace/AffineMap.lean b/Mathlib/LinearAlgebra/AffineSpace/AffineMap.lean index 63be48109f2d6d..1fc8959ff57ebb 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/AffineMap.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/AffineMap.lean @@ -804,7 +804,7 @@ note [partially-applied ext lemmas]. Analogous to `LinearMap.pi_ext'` -/ theorem pi_ext_nonempty' [Nonempty ι] (h : ∀ i, f.comp (LinearMap.single _ _ i).toAffineMap = g.comp (LinearMap.single _ _ i).toAffineMap) : f = g := by refine pi_ext_nonempty fun i x => ?_ - convert AffineMap.congr_fun (h i) x + convert! AffineMap.congr_fun (h i) x end Ext diff --git a/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Basic.lean b/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Basic.lean index 58bf073a40daab..57492f70f5b998 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Basic.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Basic.lean @@ -330,7 +330,8 @@ spans `P`. -/ theorem affineSpan_singleton_union_vadd_eq_top_of_span_eq_top {s : Set V} (p : P) (h : Submodule.span k (Set.range ((↑) : s → V)) = ⊤) : affineSpan k ({p} ∪ (fun v => v +ᵥ p) '' s) = ⊤ := by - convert ext_of_direction_eq _ + convert! + ext_of_direction_eq _ ⟨p, mem_affineSpan k (Set.mem_union_left _ (Set.mem_singleton _)), mem_top k V p⟩ rw [direction_affineSpan, direction_top, vectorSpan_eq_span_vsub_set_right k (Set.mem_union_left _ (Set.mem_singleton _) : p ∈ _), @@ -954,9 +955,9 @@ lemma affineSpan_pair_eq_of_mem_of_mem_of_ne {p₁ p₂ p₃ p₄ : P} (hp₁ : simp [sub_smul, hp₁, hp₂] rw [← eq_inv_smul_iff₀ hr₀] at hr refine affineSpan_pair_le_of_mem_of_mem ?_ ?_ - · convert smul_vsub_vadd_mem_affineSpan_pair (-r₁ * (r₂ - r₁)⁻¹) p₁ p₂ + · convert! smul_vsub_vadd_mem_affineSpan_pair (-r₁ * (r₂ - r₁)⁻¹) p₁ p₂ simp [mul_smul, ← hr, hp₁] - · convert smul_vsub_vadd_mem_affineSpan_pair ((1 - r₁) * (r₂ - r₁)⁻¹) p₁ p₂ + · convert! smul_vsub_vadd_mem_affineSpan_pair ((1 - r₁) * (r₂ - r₁)⁻¹) p₁ p₂ simp [mul_smul, ← hr, sub_smul, hp₁] /-- One line equals another differing in the first point if the first point of the first line is diff --git a/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Defs.lean b/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Defs.lean index b74ea673f23960..5d3837877fba84 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Defs.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Defs.lean @@ -206,7 +206,7 @@ def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Su rintro _ _ ⟨p₁, hp₁, p₂, hp₂, rfl⟩ ⟨p₃, hp₃, p₄, hp₄, rfl⟩ rw [← vadd_vsub_assoc] refine vsub_mem_vsub ?_ hp₄ - convert s.smul_vsub_vadd_mem 1 hp₁ hp₂ hp₃ + convert! s.smul_vsub_vadd_mem 1 hp₁ hp₂ hp₃ rw [one_smul] smul_mem' := by rintro c _ ⟨p₁, hp₁, p₂, hp₂, rfl⟩ @@ -241,7 +241,7 @@ theorem vadd_mem_of_mem_direction {s : AffineSubspace k P} {v : V} (hv : v ∈ s rw [mem_direction_iff_eq_vsub ⟨p, hp⟩] at hv rcases hv with ⟨p₁, hp₁, p₂, hp₂, hv⟩ rw [hv] - convert s.smul_vsub_vadd_mem 1 hp₁ hp₂ hp + convert! s.smul_vsub_vadd_mem 1 hp₁ hp₂ hp rw [one_smul] /-- Subtracting two points in the subspace produces a vector in the direction. -/ @@ -260,7 +260,7 @@ the original point is in the subspace. -/ theorem vadd_mem_iff_mem_of_mem_direction {s : AffineSubspace k P} {v : V} (hv : v ∈ s.direction) {p : P} : v +ᵥ p ∈ s ↔ p ∈ s := by refine ⟨fun h => ?_, fun h => vadd_mem_of_mem_direction hv h⟩ - convert vadd_mem_of_mem_direction (Submodule.neg_mem _ hv) h + convert! vadd_mem_of_mem_direction (Submodule.neg_mem _ hv) h simp /-- Given a point in an affine subspace, the set of vectors in its direction equals the set of diff --git a/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Shift.lean b/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Shift.lean new file mode 100644 index 00000000000000..7da2a0991a10c7 --- /dev/null +++ b/Mathlib/LinearAlgebra/AffineSpace/AffineSubspace/Shift.lean @@ -0,0 +1,132 @@ +/- +Copyright (c) 2026 Weiyi Wang. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Weiyi Wang +-/ +module + +public import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic + +/-! +# Shifting an affine subspace towards a point + +This file introduces a "shift" transformation of affine subspace, where the subspace is translated +relatively to a point `c`. This is equivalent to `AffineSubspace.map (AffineEquiv.constVAdd ..)`, +but hides the detail of arbitrarily choosing a point in the subspace. + +Shifting is controlled by a parameter `r`, indicating how far the output space is to `c`. We set +`r = 0` to mean the output space passes through `c` (See `AffineSubspace.shift_zero`), +while `r = 1` means not moving the input space at all (See `AffineSubspace.shift_one`). +With this convention, this transformation is also equivalent to `AffineSubspace.map (homothety c r)` +when `r` is a unit. + +## Main declarations +* `AffineSubspace.shift` defines the shift transformation. +* `AffineSubspace.shift_eq` shows the shift transformation is equivalent to translation. +* `AffineSubspace.shift_eq_map_homothety` shows the shift transformation is equivalent to homothety. +-/ + +public section + +open Module Submodule Finset AffineMap AffineSubspace + +variable {k V P : Type*} + +namespace AffineSubspace + +section Ring +variable [Ring k] [AddCommGroup V] [AddTorsor V P] [Module k V] + +open Classical in +/-- `AffineSubspace.shift s c r` is an affine subspace parallel to `s`, where an arbitrary point on +`s` is moved towards `c` with linear interpolation by `r`. When `r = 0`, that point is moved onto +`c`. When `r = 1`, that point stays at the original position. A different choice of the point will +not affect the output (See `AffineSubspace.shift_eq`). + +We define `AffineSubspace.shift ⊥ c r = ⊥` (See `AffineSubspace.shift_bot`). -/ +noncomputable +def shift (s : AffineSubspace k P) (c : P) (r : k) : AffineSubspace k P := + if h : Nonempty s then + s.map <| AffineEquiv.constVAdd k P ((1 - r) • (c -ᵥ h.some)) + else + ⊥ + +@[simp] +theorem direction_shift (s : AffineSubspace k P) (c : P) (r : k) : + (s.shift c r).direction = s.direction := by + rcases s.eq_bot_or_nonempty with h | h + · simp [shift, h] + have h : Nonempty s := by simpa using h + simp [shift, h] + +@[simp] +theorem shift_top (c : P) (r : k) : shift ⊤ c r = ⊤ := by + simp [shift, AffineEquiv.surjective] + +@[simp] +theorem shift_bot (c : P) (r : k) : shift ⊥ c r = ⊥ := by + simp [shift] + +/-- `AffineSubspace.shift s c r` can be represented by moving a point in the subspace +towards `c`. -/ +theorem shift_eq {s : AffineSubspace k P} (p : s) (c : P) (r : k) : + s.shift c r = s.map (AffineEquiv.constVAdd k P ((1 - r) • (c -ᵥ p))) := by + have h : Nonempty s := ⟨p⟩ + simp only [shift, h, ↓reduceDIte] + ext q + simp only [mem_map, AffineEquiv.coe_toAffineMap, AffineEquiv.constVAdd_apply] + constructor <;> intro ⟨x, hx, heq⟩ <;> rw [← heq] + · refine ⟨(1 - r) • (p.val -ᵥ h.some.val) +ᵥ x, ?_, ?_⟩ + · exact vadd_mem_of_mem_direction (smul_mem _ _ (vsub_mem_direction p.prop h.some.prop)) hx + · rw [vadd_vadd, ← smul_add, vsub_add_vsub_cancel] + · refine ⟨(1 - r) • (h.some.val -ᵥ p.val) +ᵥ x, ?_, ?_⟩ + · exact vadd_mem_of_mem_direction (smul_mem _ _ (vsub_mem_direction h.some.prop p.prop)) hx + · rw [vadd_vadd, ← smul_add, vsub_add_vsub_cancel] + +@[simp] +theorem shift_zero (s : AffineSubspace k P) [h : Nonempty s] (c : P) : + s.shift c 0 = mk' c s.direction := by + refine ext_of_direction_eq (by simp) ⟨c, ?_⟩ + suffices ∃ x ∈ s, (c -ᵥ h.some) +ᵥ x = c by simpa [shift, h] + exact ⟨h.some, by simp⟩ + +@[simp] +theorem shift_one (s : AffineSubspace k P) (c : P) : s.shift c 1 = s := by + rcases s.eq_bot_or_nonempty with h | h + · simp [h] + have h : Nonempty s := by simpa using h + simp [shift, h] + +end Ring + +section CommRing +variable [CommRing k] [AddCommGroup V] [AddTorsor V P] [Module k V] + +/-- For a unit parameter, shifting is the same as mapping by homothety. -/ +theorem shift_eq_map_homothety (s : AffineSubspace k P) (c : P) {r : k} (hr : IsUnit r) : + s.shift c r = s.map (homothety c r) := by + obtain ⟨t, ht⟩ := hr.exists_right_inv + rcases s.eq_bot_or_nonempty with h | h + · simp [h] + have h : Nonempty s := by simpa using h + rw [s.shift_eq h.some] + ext p + suffices (∃ y ∈ s, (1 - r) • (c -ᵥ h.some) +ᵥ y = p) ↔ ∃ y ∈ s, r • (y -ᵥ c) +ᵥ c = p by + simpa [homothety_def] + constructor <;> intro ⟨x, hmem, heq⟩ <;> rw [← heq] + · refine ⟨t • (x -ᵥ h.some.val) +ᵥ h.some.val, ?_, ?_⟩ + · refine vadd_mem_of_mem_direction ?_ h.some.prop + exact smul_mem _ _ <| vsub_mem_direction hmem h.some.prop + · rw [vadd_vsub_assoc, smul_add, smul_smul, ht, sub_eq_add_neg, add_smul, one_smul, one_smul, + neg_smul, ← smul_neg, neg_vsub_eq_vsub_rev] + simp_rw [add_comm _ (r • (h.some.val -ᵥ c)), ← vadd_vadd, vsub_vadd_comm x h.some.val c] + · refine ⟨r • (x -ᵥ h.some.val) +ᵥ h.some.val, ?_, ?_⟩ + · refine vadd_mem_of_mem_direction ?_ h.some.prop + exact smul_mem _ _ <| vsub_mem_direction hmem h.some.prop + · rw [sub_eq_add_neg, add_smul, one_smul, neg_smul, ← smul_neg, neg_vsub_eq_vsub_rev, + ← vadd_vadd, vadd_vadd _ _ h.some.val, ← smul_add, add_comm, vsub_add_vsub_cancel, + vadd_vadd, add_comm, ← vadd_vadd, vsub_vadd] + +end CommRing + +end AffineSubspace diff --git a/Mathlib/LinearAlgebra/AffineSpace/Basis.lean b/Mathlib/LinearAlgebra/AffineSpace/Basis.lean index 3b73839f1305da..5b78567a33ba69 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/Basis.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/Basis.lean @@ -219,7 +219,7 @@ theorem sum_coord_apply_eq_one [Fintype ι] (q : P) : ∑ i, b.coord i q = 1 := rw [b.tot] exact AffineSubspace.mem_top k V q obtain ⟨w, hw, rfl⟩ := eq_affineCombination_of_mem_affineSpan_of_fintype hq - convert hw + convert! hw exact b.coord_apply_combination_of_mem (Finset.mem_univ _) hw @[simp] diff --git a/Mathlib/LinearAlgebra/AffineSpace/Centroid.lean b/Mathlib/LinearAlgebra/AffineSpace/Centroid.lean index ecd3e30bc7f9cc..56fcb32ad7744f 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/Centroid.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/Centroid.lean @@ -113,7 +113,7 @@ as adding a vector to the first point. -/ theorem centroid_pair_fin [Invertible (2 : k)] (p : Fin 2 → P) : univ.centroid k p = (2⁻¹ : k) • (p 1 -ᵥ p 0) +ᵥ p 0 := by rw [univ_fin2] - convert centroid_pair k p 0 1 + convert! centroid_pair k p 0 1 /-- A centroid, over the image of an embedding, equals a centroid with the same points and weights over the original `Finset`. -/ diff --git a/Mathlib/LinearAlgebra/AffineSpace/Ceva.lean b/Mathlib/LinearAlgebra/AffineSpace/Ceva.lean index 47605d401651ae..535f636e0a744e 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/Ceva.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/Ceva.lean @@ -60,7 +60,7 @@ private lemma exists_affineCombination_eq_smul_eq_aux {p : ι → P} (hp : Affin by_cases hj : j = i · simp [hj] replace hind := congr_fun hind j - convert hind using 1 + convert! hind using 1 · simp [Set.indicator_apply, hj] · simp [Set.indicator_apply, hj, w', AffineMap.lineMap_apply_module] · simp [Finset.sum_add_distrib, ← Finset.mul_sum, hw, hfs] @@ -86,14 +86,14 @@ lemma exists_affineCombination_eq_smul_eq {p : ι → P} (hp : AffineIndependent by_cases hi : (i : ι) ∈ fs i <;> simpa [hi] using Finset.sum_congr rfl (by aesop) have hp'x : ∀ i : s, p' ∈ line[k, p i, (fsx i).affineCombination k p (wx i)] := by intro i - convert hp' i using 4 + convert! hp' i using 4 simp_rw [fsx, wx] exact (Finset.affineCombination_indicator_subset _ _ (by simp)).symm obtain ⟨w', fs', h⟩ := hp.exists_affineCombination_eq_smul_eq_aux hs hfsx hwx hp'x refine ⟨w', fs', h.1, h.2.1, fun i ↦ ?_⟩ obtain ⟨r, hr⟩ := h.2.2 i refine ⟨r, fun j ↦ ?_⟩ - convert hr j using 2 + convert! hr j using 2 simp only [Set.indicator_apply, Set.mem_diff, SetLike.mem_coe, Set.mem_singleton_iff, Finset.coe_insert, Set.insert_diff_of_mem, fsx, wx] grind @@ -119,7 +119,7 @@ lemma exists_affineCombination_eq_smul_eq_of_fintype [Fintype ι] {p : ι → P} · intro i obtain ⟨r, hr⟩ := hi i refine ⟨r, fun j ↦ ?_⟩ - convert hr j using 1 + convert! hr j using 1 · simp [Set.indicator_apply] · by_cases hj : j = (i : ι) <;> simp [Set.indicator_apply, hj] diff --git a/Mathlib/LinearAlgebra/AffineSpace/Combination.lean b/Mathlib/LinearAlgebra/AffineSpace/Combination.lean index a4e6ab208bc281..78843dcbb221d9 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/Combination.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/Combination.lean @@ -432,7 +432,7 @@ theorem affineCombination_of_eq_one_of_eq_zero (w : ι → k) (p : ι → P) {i have h1 : ∑ i ∈ s, w i = 1 := hwi ▸ sum_eq_single i hw0 fun h => False.elim (h his) rw [s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w p h1 (p i), weightedVSubOfPoint_apply] - convert zero_vadd V (p i) + convert! zero_vadd V (p i) refine sum_eq_zero ?_ intro i2 hi2 by_cases h : i2 = i @@ -588,8 +588,8 @@ lemma affineCombination_apply_eq_lineMap_sum [DecidableEq ι] (w : ι → k) (p rw [s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w p h p₁, weightedVSubOfPoint_apply, ← s.sum_inter_add_sum_diff s', AffineMap.lineMap_apply, vadd_right_cancel_iff, sum_smul] - convert add_zero _ with i hi - · convert Finset.sum_const_zero with i hi + convert! add_zero _ with i hi + · convert! Finset.sum_const_zero with i hi simp [hp₁ i hi] · exact (hp₂ i hi).symm @@ -906,7 +906,7 @@ lemma affineCombination_mem_affineSpan_image [Nontrivial k] {s : Finset ι} {w : simp only [Finset.mem_sdiff, Finset.mem_filter, not_and] at hi exact hs' i hi.1 (hi.2 hi.1) rw [← Finset.sum_subtype_eq_sum_filter] at h' - convert affineCombination_mem_affineSpan h' (fun x ↦ p x) + convert! affineCombination_mem_affineSpan h' (fun x ↦ p x) rw [Finset.affineCombination_subtype_eq_filter, Finset.affineCombination_indicator_subset w p (Finset.filter_subset _ _)] refine Finset.affineCombination_congr _ (fun i hi ↦ ?_) (fun _ _ ↦ rfl) diff --git a/Mathlib/LinearAlgebra/AffineSpace/FiniteDimensional.lean b/Mathlib/LinearAlgebra/AffineSpace/FiniteDimensional.lean index b118fc3ce80573..5890ae57f58b85 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/FiniteDimensional.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/FiniteDimensional.lean @@ -366,7 +366,7 @@ instance finiteDimensional_vectorSpan_insert (s : AffineSubspace k P) rcases (s : Set P).eq_empty_or_nonempty with (hs | ⟨p₀, hp₀⟩) · rw [coe_eq_bot_iff] at hs rw [hs, bot_coe, span_empty, bot_coe, direction_affineSpan] - convert finiteDimensional_bot k V <;> simp + convert! finiteDimensional_bot k V <;> simp · rw [affineSpan_coe, direction_affineSpan_insert hp₀] infer_instance @@ -666,7 +666,7 @@ theorem affineIndependent_iff_affineIndependent_collinear_ne {p₁ p₂ p₃ p : AffineIndependent k ![p₁, p₂, p] ↔ AffineIndependent k ![p₁, p₂, p₃] := by refine ⟨fun h ↦ affineIndependent_of_affineIndependent_collinear_ne h hcol hne2, fun h ↦ affineIndependent_of_affineIndependent_collinear_ne h ?_ hne1⟩ - convert hcol using 1 + convert! hcol using 1 aesop variable (k) in @@ -753,9 +753,9 @@ theorem finrank_vectorSpan_insert_le (s : AffineSubspace k P) (p : P) : · rw [coe_eq_bot_iff] at hs rw [hs, bot_coe, span_empty, bot_coe, direction_affineSpan, direction_bot, finrank_bot, zero_add] - convert zero_le_one' ℕ + convert! zero_le_one' ℕ rw [← finrank_bot k V] - convert rfl <;> simp + convert! rfl <;> simp · rw [affineSpan_coe, direction_affineSpan_insert hp₀, add_comm] refine (Submodule.finrank_add_le_finrank_add_finrank _ _).trans ?_ gcongr diff --git a/Mathlib/LinearAlgebra/AffineSpace/Independent.lean b/Mathlib/LinearAlgebra/AffineSpace/Independent.lean index cf95dacc26c436..0f6fc3f0c4e20a 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/Independent.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/Independent.lean @@ -130,7 +130,7 @@ theorem affineIndependent_iff_linearIndependent_vsub (p : ι → P) (i1 : ι) : let f : ι → V := fun i => w i • (p i -ᵥ p i1) have hs2 : (∑ i ∈ (s.erase i1).subtype fun i => i ≠ i1, f i) = 0 := by rw [← hs] - convert Finset.sum_subtype_of_mem f fun x => Finset.ne_of_mem_erase + convert! Finset.sum_subtype_of_mem f fun x => Finset.ne_of_mem_erase have h2 := h ((s.erase i1).subtype fun i => i ≠ i1) (fun x => w x) hs2 simp_rw [Finset.mem_subtype] at h2 have h2b : ∀ i ∈ s, i ≠ i1 → w i = 0 := fun i his hi => @@ -150,15 +150,16 @@ theorem affineIndependent_set_iff_linearIndependent_vsub {s : Set P} {p₁ : P} let f : (fun p : P => (p -ᵥ p₁ : V)) '' (s \ {p₁}) → { x : s // x ≠ ⟨p₁, hp₁⟩ } := fun x => ⟨⟨(x : V) +ᵥ p₁, Set.mem_of_mem_diff (hv x)⟩, fun hx => Set.notMem_of_mem_diff (hv x) (Subtype.ext_iff.1 hx)⟩ - convert h.comp f fun x1 x2 hx => + convert! + h.comp f fun x1 x2 hx => Subtype.ext (vadd_right_cancel p₁ (Subtype.ext_iff.1 (Subtype.ext_iff.1 hx))) ext v exact (vadd_vsub (v : V) p₁).symm · intro h let f : { x : s // x ≠ ⟨p₁, hp₁⟩ } → (fun p : P => (p -ᵥ p₁ : V)) '' (s \ {p₁}) := fun x => ⟨((x : s) : P) -ᵥ p₁, ⟨x, ⟨⟨(x : s).property, fun hx => x.property (Subtype.ext hx)⟩, rfl⟩⟩⟩ - convert h.comp f fun x1 x2 hx => - Subtype.ext (Subtype.ext (vsub_left_cancel (Subtype.ext_iff.1 hx))) + convert! + h.comp f fun x1 x2 hx => Subtype.ext (Subtype.ext (vsub_left_cancel (Subtype.ext_iff.1 hx))) /-- A set of nonzero vectors is linearly independent if and only if, given a point `p₁`, the vectors added to `p₁` and `p₁` itself are @@ -321,7 +322,7 @@ protected theorem AffineIndependent.range {p : ι → P} (ha : AffineIndependent let f : Set.range p → ι := fun x => x.property.choose have hf : ∀ x, p (f x) = x := fun x => x.property.choose_spec let fe : Set.range p ↪ ι := ⟨f, fun x₁ x₂ he => Subtype.ext (hf x₁ ▸ hf x₂ ▸ he ▸ rfl)⟩ - convert ha.comp_embedding fe + convert! ha.comp_embedding fe ext simp [fe, hf] @@ -339,7 +340,7 @@ theorem affineIndependent_equiv {ι' : Type*} (e : ι ≃ ι') {p : ι' → P} : theorem AffineIndependent.comm_left {p₁ p₂ p₃ : P} (h : AffineIndependent k ![p₁, p₂, p₃]) : AffineIndependent k ![p₂, p₁, p₃] := by rw [← affineIndependent_equiv (Equiv.swap 0 1)] - convert h using 1 + convert! h using 1 ext x fin_cases x <;> rfl @@ -347,7 +348,7 @@ theorem AffineIndependent.comm_left {p₁ p₂ p₃ : P} (h : AffineIndependent theorem AffineIndependent.comm_right {p₁ p₂ p₃ : P} (h : AffineIndependent k ![p₁, p₂, p₃]) : AffineIndependent k ![p₁, p₃, p₂] := by rw [← affineIndependent_equiv (Equiv.swap 1 2)] - convert h using 1 + convert! h using 1 ext x fin_cases x <;> rfl @@ -355,7 +356,7 @@ theorem AffineIndependent.comm_right {p₁ p₂ p₃ : P} (h : AffineIndependent theorem AffineIndependent.reverse_of_three {p₁ p₂ p₃ : P} (h : AffineIndependent k ![p₁, p₂, p₃]) : AffineIndependent k ![p₃, p₂, p₁] := by rw [← affineIndependent_equiv (Equiv.swap 0 2)] - convert h using 1 + convert! h using 1 ext x fin_cases x <;> rfl @@ -396,7 +397,7 @@ lemma AffineIndependent.indicator_extend_eq_of_affineCombination_comp_embedding_ rw [← hw₂e, ← affineCombination_map] at h refine (ha.indicator_eq_of_affineCombination_eq s₁ (s₂.map e) _ _ hw₁ ?_ h.symm).symm rw [sum_map] - convert hw₂ with i hi + convert! hw₂ with i hi exact e.injective.extend_apply _ _ _ lemma AffineIndependent.indicator_extend_eq_of_affineCombination_comp_embedding_eq_of_fintype @@ -470,7 +471,7 @@ lemma AffineIndependent.inf_affineSpan_eq_affineSpan_inter [Nontrivial k] {p : replace ha := ha fs₁ fs₂ w₁ w₂ hw₁ hw₂ hw₁₂ refine ⟨fs₁ ∩ fs₂, by grind, w₁, ?_, ?_⟩ · rw [← hw₁, ← fs₁.sum_inter_add_sum_diff fs₂, eq_comm] - convert add_zero _ + convert! add_zero _ refine Finset.sum_eq_zero ?_ intro i hi rw [← Set.indicator_of_mem (s := ↑fs₁) (by grind) w₁, ha, Set.indicator_of_notMem (by grind)] @@ -619,7 +620,7 @@ theorem exists_nontrivial_relation_sum_zero_of_not_affine_ind {t : Finset V} refine ⟨fun x => if hx : x ∈ t then f x hx else (0 : k), ?_, ?_, by use i; simp [f, hi]⟩ on_goal 1 => suffices (∑ e ∈ t, dite (e ∈ t) (fun hx => f e hx • e) fun _ => 0) = 0 by - convert this + convert! this rename V => x by_cases hx : x ∈ t <;> simp [hx] all_goals @@ -850,7 +851,7 @@ theorem affineIndependent_of_ne_of_mem_of_mem_of_notMem {s : AffineSubspace k P} AffineIndependent k ![p₁, p₂, p₃] := by have ha : AffineIndependent k fun x : { x : Fin 3 // x ≠ 2 } => ![p₁, p₂, p₃] x := by rw [← affineIndependent_equiv (finSuccAboveEquiv (2 : Fin 3))] - convert affineIndependent_of_ne k hp₁p₂ + convert! affineIndependent_of_ne k hp₁p₂ ext x fin_cases x <;> rfl refine ha.affineIndependent_of_notMem_span ?_ @@ -866,7 +867,7 @@ theorem affineIndependent_of_ne_of_mem_of_notMem_of_mem {s : AffineSubspace k P} (hp₁p₃ : p₁ ≠ p₃) (hp₁ : p₁ ∈ s) (hp₂ : p₂ ∉ s) (hp₃ : p₃ ∈ s) : AffineIndependent k ![p₁, p₂, p₃] := by rw [← affineIndependent_equiv (Equiv.swap (1 : Fin 3) 2)] - convert affineIndependent_of_ne_of_mem_of_mem_of_notMem hp₁p₃ hp₁ hp₃ hp₂ using 1 + convert! affineIndependent_of_ne_of_mem_of_mem_of_notMem hp₁p₃ hp₁ hp₃ hp₂ using 1 ext x fin_cases x <;> rfl @@ -876,7 +877,7 @@ theorem affineIndependent_of_ne_of_notMem_of_mem_of_mem {s : AffineSubspace k P} (hp₂p₃ : p₂ ≠ p₃) (hp₁ : p₁ ∉ s) (hp₂ : p₂ ∈ s) (hp₃ : p₃ ∈ s) : AffineIndependent k ![p₁, p₂, p₃] := by rw [← affineIndependent_equiv (Equiv.swap (0 : Fin 3) 2)] - convert affineIndependent_of_ne_of_mem_of_mem_of_notMem hp₂p₃.symm hp₃ hp₂ hp₁ using 1 + convert! affineIndependent_of_ne_of_mem_of_mem_of_notMem hp₂p₃.symm hp₃ hp₂ hp₁ using 1 ext x fin_cases x <;> rfl diff --git a/Mathlib/LinearAlgebra/AffineSpace/Simplex/Basic.lean b/Mathlib/LinearAlgebra/AffineSpace/Simplex/Basic.lean index 0f6150d39387b8..d7d4745575b921 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/Simplex/Basic.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/Simplex/Basic.lean @@ -551,8 +551,8 @@ lemma affineCombination_mem_setInterior_face_iff_mem (I : Set k) {n : ℕ} (s : (fun i hi ↦ hi0 _ (by simpa using hi)) (fun _ ↦ rfl), hw] have hw'01 (i) : w' i ∈ I := hii (fs.orderEmbOfFin h i) (by simp) rw [← (s.face h).affineCombination_mem_setInterior_iff hw'] at hw'01 - convert hw'01 - convert Finset.univ.affineCombination_map (fs.orderEmbOfFin h).toEmbedding w s.points using 1 + convert! hw'01 + convert! Finset.univ.affineCombination_map (fs.orderEmbOfFin h).toEmbedding w s.points using 1 simp only [map_orderEmbOfFin_univ, Finset.affineCombination_indicator_subset _ _ fs.subset_univ] congr grind [Set.indicator_eq_self, support_subset_iff] diff --git a/Mathlib/LinearAlgebra/AffineSpace/Simplex/Centroid.lean b/Mathlib/LinearAlgebra/AffineSpace/Simplex/Centroid.lean index 12f3b1bb8d5120..2856c6aba0432c 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/Simplex/Centroid.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/Simplex/Centroid.lean @@ -138,7 +138,7 @@ theorem eq_centroid_iff_sum_vsub_eq_zero [CharZero k] {s : Simplex k P n} {p : P the points. -/ theorem face_centroid_eq_centroid {n : ℕ} (s : Simplex k P n) {fs : Finset (Fin (n + 1))} {m : ℕ} (h : #fs = m + 1) : Finset.univ.centroid k (s.face h).points = fs.centroid k s.points := by - convert (Finset.univ.centroid_map k (fs.orderEmbOfFin h).toEmbedding s.points).symm + convert! (Finset.univ.centroid_map k (fs.orderEmbOfFin h).toEmbedding s.points).symm rw [← Finset.coe_inj, Finset.coe_map, Finset.coe_univ, Set.image_univ] simp @@ -213,7 +213,7 @@ theorem centroid_reindex {m n : ℕ} (s : Simplex k P m) simp only [reindex] have h_eq : m = n := by simpa using Fintype.card_eq.2 ⟨e⟩ subst h_eq - convert Finset.univ.affineCombination_map e.toEmbedding _ _ <;> simp [Function.comp_assoc] + convert! Finset.univ.affineCombination_map e.toEmbedding _ _ <;> simp [Function.comp_assoc] theorem centroid_restrict [CharZero k] {n : ℕ} (s : Simplex k P n) (S : AffineSubspace k P) (hS : affineSpan k (Set.range s.points) ≤ S) : @@ -515,7 +515,7 @@ theorem eq_centroid_of_forall_mem_median [CharZero k] (s : Simplex k P n) {hn : fun x => ⟨x.val, h x⟩ have f_inj : Function.Injective f := by intro x y hxy; grind have h2 := h1.comp f f_inj - convert h2 using 1 + convert! h2 using 1 grind only [mem_compl, Finset.notMem_singleton] have he : ∃ i j : s', i ≠ j := by simp only [ne_eq, Subtype.exists, Subtype.mk.injEq, exists_prop] @@ -539,7 +539,7 @@ def medial [CharZero k] (s : Simplex k P n) : Simplex k P n where obtain h := s.independent rw [affineIndependent_iff_linearIndependent_vsub k _ 0] at h ⊢ simp_rw [faceOppositeCentroid_vsub_faceOppositeCentroid] - convert h.units_smul fun _ ↦ Units.mk0 (-n)⁻¹ (by simpa using NeZero.ne n) with i + convert! h.units_smul fun _ ↦ Units.mk0 (-n)⁻¹ (by simpa using NeZero.ne n) with i simp [← smul_neg] theorem medial_points [CharZero k] (s : Simplex k P n) (i : Fin (n + 1)) : diff --git a/Mathlib/LinearAlgebra/AffineSpace/Slope.lean b/Mathlib/LinearAlgebra/AffineSpace/Slope.lean index ea43e7c24d3bb4..e000e52df3486c 100644 --- a/Mathlib/LinearAlgebra/AffineSpace/Slope.lean +++ b/Mathlib/LinearAlgebra/AffineSpace/Slope.lean @@ -127,7 +127,7 @@ theorem lineMap_slope_lineMap_slope_lineMap (f : k → PE) (a b r : k) : lineMap (slope f (lineMap a b r) b) (slope f a (lineMap a b r)) r = slope f a b := by obtain rfl | hab : a = b ∨ a ≠ b := Classical.em _; · simp rw [slope_comm _ a, slope_comm _ a, slope_comm _ _ b] - convert lineMap_slope_slope_sub_div_sub f b (lineMap a b r) a hab.symm using 2 + convert! lineMap_slope_slope_sub_div_sub f b (lineMap a b r) a hab.symm using 2 rw [lineMap_apply_ring, eq_div_iff (sub_ne_zero.2 hab), sub_mul, one_mul, mul_sub, ← sub_sub, sub_sub_cancel] diff --git a/Mathlib/LinearAlgebra/Alternating/Basic.lean b/Mathlib/LinearAlgebra/Alternating/Basic.lean index 0dd6c8d60bcf89..b94d11f9bc47a2 100644 --- a/Mathlib/LinearAlgebra/Alternating/Basic.lean +++ b/Mathlib/LinearAlgebra/Alternating/Basic.lean @@ -657,7 +657,7 @@ theorem map_update_update [DecidableEq ι] {i j : ι} (hij : i ≠ j) (m : M) : theorem map_swap_add [DecidableEq ι] {i j : ι} (hij : i ≠ j) : f (v ∘ Equiv.swap i j) + f v = 0 := by rw [Equiv.comp_swap_eq_update] - convert f.map_update_update v hij (v i + v j) + convert! f.map_update_update v hij (v i + v j) simp [f.map_update_self _ hij, f.map_update_self _ hij.symm, Function.update_comm hij (v i + v j) (v _) v, Function.update_comm hij.symm (v i) (v i) v] diff --git a/Mathlib/LinearAlgebra/Alternating/DomCoprod.lean b/Mathlib/LinearAlgebra/Alternating/DomCoprod.lean index 2475c505a79254..78db36d5a3094b 100644 --- a/Mathlib/LinearAlgebra/Alternating/DomCoprod.lean +++ b/Mathlib/LinearAlgebra/Alternating/DomCoprod.lean @@ -84,7 +84,7 @@ theorem domCoprod.summand_add_swap_smul_eq_zero (a : Mᵢ [⋀^ιa]→ₗ[R'] N simp only [one_mul, neg_mul, Function.comp_apply, Units.neg_smul, Perm.coe_mul, MultilinearMap.smul_apply, MultilinearMap.neg_apply, MultilinearMap.domDomCongr_apply, MultilinearMap.domCoprod_apply] - convert add_neg_cancel (G := N₁ ⊗[R'] N₂) _ using 6 <;> + convert! add_neg_cancel (G := N₁ ⊗[R'] N₂) _ using 6 <;> · ext k rw [Equiv.apply_swap_eq_self hv] diff --git a/Mathlib/LinearAlgebra/Basis/Submodule.lean b/Mathlib/LinearAlgebra/Basis/Submodule.lean index e627a3f168126f..aa9d6ba203ab18 100644 --- a/Mathlib/LinearAlgebra/Basis/Submodule.lean +++ b/Mathlib/LinearAlgebra/Basis/Submodule.lean @@ -66,7 +66,7 @@ theorem Basis.eq_bot_of_rank_eq_zero [IsDomain R] (b : Basis ι R M) (N : Submod rintro g sum_eq i simp only [Fin.default_eq_zero, Finset.univ_unique, Finset.sum_singleton] at sum_eq - convert (b.smul_eq_zero.mp sum_eq).resolve_right x_ne + convert! (b.smul_eq_zero.mp sum_eq).resolve_right x_ne end Module @@ -100,7 +100,7 @@ def Submodule.inductionOnRankAux (b : Basis ι R M) (P : Submodule R M → Sort* apply rank_ih intro m v hli refine Nat.succ_le_succ_iff.mp (rank_le (Fin.cons ⟨x, x_mem⟩ fun i => ⟨v i, N'_le (v i).2⟩) ?_) - convert hli.finCons' x _ ?_ + convert! hli.finCons' x _ ?_ · ext i refine Fin.cases ?_ ?_ i <;> simp · intro c y hy hc diff --git a/Mathlib/LinearAlgebra/Basis/VectorSpace.lean b/Mathlib/LinearAlgebra/Basis/VectorSpace.lean index b9e1cea57f2518..3f58c0a4c43c26 100644 --- a/Mathlib/LinearAlgebra/Basis/VectorSpace.lean +++ b/Mathlib/LinearAlgebra/Basis/VectorSpace.lean @@ -164,7 +164,7 @@ theorem coe_ofVectorSpace : ⇑(ofVectorSpace K V) = ((↑) : _ → _) := theorem ofVectorSpaceIndex.linearIndependent : LinearIndependent K ((↑) : ofVectorSpaceIndex K V → V) := by - convert (ofVectorSpace K V).linearIndependent + convert! (ofVectorSpace K V).linearIndependent ext x rw [ofVectorSpace_apply_self] diff --git a/Mathlib/LinearAlgebra/BilinearForm/DualLattice.lean b/Mathlib/LinearAlgebra/BilinearForm/DualLattice.lean index 495ad4187a5b99..628935e785ca77 100644 --- a/Mathlib/LinearAlgebra/BilinearForm/DualLattice.lean +++ b/Mathlib/LinearAlgebra/BilinearForm/DualLattice.lean @@ -39,7 +39,7 @@ def dualSubmodule (N : Submodule R M) : Submodule R M where add_mem' {a b} ha hb y hy := by simpa using add_mem (ha y hy) (hb y hy) zero_mem' y _ := by rw [B.zero_left]; exact zero_mem _ smul_mem' r a ha y hy := by - convert (1 : Submodule R S).smul_mem r (ha y hy) + convert! (1 : Submodule R S).smul_mem r (ha y hy) rw [← IsScalarTower.algebraMap_smul S r a] simp only [algebraMap_smul, map_smul_of_tower, LinearMap.smul_apply] diff --git a/Mathlib/LinearAlgebra/BilinearForm/Orthogonal.lean b/Mathlib/LinearAlgebra/BilinearForm/Orthogonal.lean index d7e51e5a7f0298..7372076997fa65 100644 --- a/Mathlib/LinearAlgebra/BilinearForm/Orthogonal.lean +++ b/Mathlib/LinearAlgebra/BilinearForm/Orthogonal.lean @@ -194,8 +194,8 @@ theorem iIsOrtho.not_isOrtho_basis_self_of_nondegenerate {n : Type w} [Nontrivia /-- Given an orthogonal basis with respect to a bilinear form, the bilinear form is nondegenerate iff the basis has no elements which are self-orthogonal. -/ -theorem iIsOrtho.nondegenerate_iff_not_isOrtho_basis_self {n : Type w} [Nontrivial R] - [IsDomain R] (B : BilinForm R M) (v : Basis n R M) (hO : B.iIsOrtho v) : +theorem iIsOrtho.nondegenerate_iff_not_isOrtho_basis_self {n : Type w} [IsDomain R] + (B : BilinForm R M) (v : Basis n R M) (hO : B.iIsOrtho v) : B.Nondegenerate ↔ ∀ i, ¬B.IsOrtho (v i) (v i) := ⟨hO.not_isOrtho_basis_self_of_nondegenerate, hO.nondegenerate_of_not_isOrtho_basis_self _⟩ diff --git a/Mathlib/LinearAlgebra/BilinearForm/Properties.lean b/Mathlib/LinearAlgebra/BilinearForm/Properties.lean index 444f35f423d906..5f791c917facf3 100644 --- a/Mathlib/LinearAlgebra/BilinearForm/Properties.lean +++ b/Mathlib/LinearAlgebra/BilinearForm/Properties.lean @@ -316,7 +316,7 @@ theorem Nondegenerate.congr {B : BilinForm R M} (e : M ≃ₗ[R] M') (h : B.Nond theorem nondegenerate_congr_iff {B : BilinForm R M} (e : M ≃ₗ[R] M') : (congr e B).Nondegenerate ↔ B.Nondegenerate := ⟨fun h => by - convert h.congr e.symm + convert! h.congr e.symm rw [congr_congr, e.self_trans_symm, congr_refl, LinearEquiv.refl_apply], Nondegenerate.congr e⟩ theorem Nondegenerate.ker_eq_bot {B : BilinForm R M} (h : B.Nondegenerate) : @@ -412,7 +412,7 @@ lemma dualBasis_flip_dualBasis (hB : B.Nondegenerate) (b : Basis ι K V) : lemma dualBasis_dualBasis (hB : B.Nondegenerate) (hB' : B.IsSymm) (b : Basis ι K V) : B.dualBasis hB (B.dualBasis hB b) = b := by - convert dualBasis_dualBasis_flip hB.flip b + convert! dualBasis_dualBasis_flip hB.flip b rwa [eq_comm, ← isSymm_iff_flip] lemma dualBasis_involutive (hB : B.Nondegenerate) (hB' : B.IsSymm) : diff --git a/Mathlib/LinearAlgebra/BilinearMap.lean b/Mathlib/LinearAlgebra/BilinearMap.lean index 1c69ebe4f2f03a..275e57109ee607 100644 --- a/Mathlib/LinearAlgebra/BilinearMap.lean +++ b/Mathlib/LinearAlgebra/BilinearMap.lean @@ -365,7 +365,7 @@ theorem compl₁₂_inj [SMulCommClass R₂ R₁ Pₗ] ext x y obtain ⟨x', rfl⟩ := hₗ x obtain ⟨y', rfl⟩ := hᵣ y - convert LinearMap.congr_fun₂ h x' y' using 0 + convert! LinearMap.congr_fun₂ h x' y' using 0 · -- B₁ = B₂ → B₁.comp l r = B₂.comp l r subst h; rfl diff --git a/Mathlib/LinearAlgebra/CliffordAlgebra/Basic.lean b/Mathlib/LinearAlgebra/CliffordAlgebra/Basic.lean index f9295fc40db4aa..51f80547faaf2a 100644 --- a/Mathlib/LinearAlgebra/CliffordAlgebra/Basic.lean +++ b/Mathlib/LinearAlgebra/CliffordAlgebra/Basic.lean @@ -155,7 +155,7 @@ theorem lift_ι_apply (f : M →ₗ[R] A) (cond : ∀ m, f m * f m = algebraMap @[simp] theorem lift_unique (f : M →ₗ[R] A) (cond : ∀ m : M, f m * f m = algebraMap _ _ (Q m)) (g : CliffordAlgebra Q →ₐ[R] A) : g.toLinearMap.comp (ι Q) = f ↔ g = lift Q ⟨f, cond⟩ := by - convert (lift Q : _ ≃ (CliffordAlgebra Q →ₐ[R] A)).symm_apply_eq + convert! (lift Q : _ ≃ (CliffordAlgebra Q →ₐ[R] A)).symm_apply_eq rw [lift_symm_apply, Subtype.mk_eq_mk] @[simp] @@ -367,11 +367,11 @@ equivalent. -/ def equivOfIsometry (e : Q₁.IsometryEquiv Q₂) : CliffordAlgebra Q₁ ≃ₐ[R] CliffordAlgebra Q₂ := AlgEquiv.ofAlgHom (map e.toIsometry) (map e.symm.toIsometry) ((map_comp_map _ _).trans <| by - convert map_id Q₂ using 2 + convert! map_id Q₂ using 2 ext m exact e.toLinearEquiv.apply_symm_apply m) ((map_comp_map _ _).trans <| by - convert map_id Q₁ using 2 + convert! map_id Q₁ using 2 ext m exact e.toLinearEquiv.symm_apply_apply m) diff --git a/Mathlib/LinearAlgebra/CliffordAlgebra/Inversion.lean b/Mathlib/LinearAlgebra/CliffordAlgebra/Inversion.lean index d32b0bd48cfd06..c9dfc7c666d345 100644 --- a/Mathlib/LinearAlgebra/CliffordAlgebra/Inversion.lean +++ b/Mathlib/LinearAlgebra/CliffordAlgebra/Inversion.lean @@ -35,7 +35,7 @@ def invertibleιOfInvertible (m : M) [Invertible (Q m)] : Invertible (ι Q m) wh theorem invOf_ι (m : M) [Invertible (Q m)] [Invertible (ι Q m)] : ⅟(ι Q m) = ι Q (⅟(Q m) • m) := by letI := invertibleιOfInvertible Q m - convert (rfl : ⅟(ι Q m) = _) + convert! (rfl : ⅟(ι Q m) = _) theorem isUnit_ι_of_isUnit {m : M} (h : IsUnit (Q m)) : IsUnit (ι Q m) := by cases h.nonempty_invertible diff --git a/Mathlib/LinearAlgebra/CliffordAlgebra/SpinGroup.lean b/Mathlib/LinearAlgebra/CliffordAlgebra/SpinGroup.lean index 9917233aedbacd..f5a2f3c2fffd58 100644 --- a/Mathlib/LinearAlgebra/CliffordAlgebra/SpinGroup.lean +++ b/Mathlib/LinearAlgebra/CliffordAlgebra/SpinGroup.lean @@ -226,7 +226,7 @@ See `star_mem` for only one direction. -/ theorem star_mem_iff {x : CliffordAlgebra Q} : star x ∈ pinGroup Q ↔ x ∈ pinGroup Q := by refine ⟨?_, star_mem⟩ intro hx - convert star_mem hx + convert! star_mem hx exact (star_star x).symm instance : Star (pinGroup Q) where @@ -357,7 +357,7 @@ See `star_mem` for only one direction. theorem star_mem_iff {x : CliffordAlgebra Q} : star x ∈ spinGroup Q ↔ x ∈ spinGroup Q := by refine ⟨?_, star_mem⟩ intro hx - convert star_mem hx + convert! star_mem hx exact (star_star x).symm instance : Star (spinGroup Q) where diff --git a/Mathlib/LinearAlgebra/Determinant.lean b/Mathlib/LinearAlgebra/Determinant.lean index 8b475bc7aed35c..4e0b7b9fb3ea2f 100644 --- a/Mathlib/LinearAlgebra/Determinant.lean +++ b/Mathlib/LinearAlgebra/Determinant.lean @@ -572,7 +572,7 @@ abbrev LinearMap.equivOfDetNeZero {𝕜 : Type*} [Field 𝕜] {M : Type*} [AddCo theorem LinearMap.associated_det_of_eq_comp (e : M ≃ₗ[R] M) (f f' : M →ₗ[R] M) (h : ∀ x, f x = f' (e x)) : Associated (LinearMap.det f) (LinearMap.det f') := by suffices Associated (LinearMap.det (f' ∘ₗ ↑e)) (LinearMap.det f') by - convert this using 2 + convert! this using 2 ext x exact h x rw [← mul_one (LinearMap.det f'), LinearMap.det_comp] @@ -630,7 +630,7 @@ theorem is_basis_iff_det {v : ι → M} : · rintro ⟨hli, hspan⟩ set v' := Basis.mk hli hspan.ge rw [e.det_apply] - convert LinearEquiv.isUnit_det (LinearEquiv.refl R M) v' e using 2 + convert! LinearEquiv.isUnit_det (LinearEquiv.refl R M) v' e using 2 ext i j simp [v'] · intro h @@ -763,7 +763,7 @@ theorem det_unitsSMul (e : Basis ι R M) (w : ι → Rˣ) : (Matrix.det fun i j => (e.unitsSMul w).repr (f j) i) = (↑(∏ i, w i)⁻¹ : R) • Matrix.det fun i j => e.repr (f j) i simp only [e.repr_unitsSMul] - convert Matrix.det_mul_column (fun i => (↑(w i)⁻¹ : R)) fun i j => e.repr (f j) i + convert! Matrix.det_mul_column (fun i => (↑(w i)⁻¹ : R)) fun i j => e.repr (f j) i simp [← Finset.prod_inv_distrib] /-- The determinant of a basis constructed by `unitsSMul` is the product of the given units. -/ diff --git a/Mathlib/LinearAlgebra/Dimension/Basic.lean b/Mathlib/LinearAlgebra/Dimension/Basic.lean index 645d360414038d..824dc4f9b01d3a 100644 --- a/Mathlib/LinearAlgebra/Dimension/Basic.lean +++ b/Mathlib/LinearAlgebra/Dimension/Basic.lean @@ -381,7 +381,7 @@ theorem lift_rank_range_le (f : M →ₗ[R] M') : Cardinal.lift.{v} · apply Cardinal.lift_le.mpr refine le_ciSup Cardinal.bddAbove_of_small ⟨rangeSplitting f '' s, ?_⟩ apply LinearIndependent.of_comp f.rangeRestrict - convert li.comp (Equiv.Set.rangeSplittingImageEquiv f s) (Equiv.injective _) using 1 + convert! li.comp (Equiv.Set.rangeSplittingImageEquiv f s) (Equiv.injective _) using 1 · exact (Cardinal.lift_mk_eq'.mpr ⟨Equiv.Set.rangeSplittingImageEquiv f s⟩).ge theorem rank_range_le (f : M →ₗ[R] M₁) : Module.rank R (LinearMap.range f) ≤ Module.rank R M := by diff --git a/Mathlib/LinearAlgebra/Dimension/Constructions.lean b/Mathlib/LinearAlgebra/Dimension/Constructions.lean index 3f20a79eaade79..46fa52812f084a 100644 --- a/Mathlib/LinearAlgebra/Dimension/Constructions.lean +++ b/Mathlib/LinearAlgebra/Dimension/Constructions.lean @@ -62,7 +62,7 @@ theorem LinearIndependent.sumElim_of_quotient theorem LinearIndepOn.union_of_quotient {s t : Set ι} {f : ι → M} (hs : LinearIndepOn R f s) (ht : LinearIndepOn R (mkQ (span R (f '' s)) ∘ f) t) : LinearIndepOn R f (s ∪ t) := by apply hs.union ht.of_comp - convert (Submodule.range_ker_disjoint ht).symm + convert! (Submodule.range_ker_disjoint ht).symm · simp aesop @@ -475,7 +475,7 @@ theorem finrank_span_set_eq_card {s : Set M} [Fintype s] (hs : LinearIndepOn R i theorem finrank_span_finset_eq_card {s : Finset M} (hs : LinearIndepOn R id (s : Set M)) : finrank R (span R (s : Set M)) = s.card := by - convert finrank_span_set_eq_card (s := (s : Set M)) hs + convert! finrank_span_set_eq_card (s := (s : Set M)) hs ext simp @@ -492,7 +492,7 @@ lemma finrank_le_of_span_eq_top {ι : Type*} [Fintype ι] {v : ι → M} (hv : Submodule.span R (Set.range v) = ⊤) : finrank R M ≤ Fintype.card ι := by classical rw [← finrank_top, ← hv] - exact (finrank_span_le_card _).trans (by convert Fintype.card_range_le v; rw [Set.toFinset_card]) + exact (finrank_span_le_card _).trans (by convert! Fintype.card_range_le v; rw [Set.toFinset_card]) @[simp] lemma Pi.dim_spanSubset [Finite ι] [Nontrivial R] {s : Set ι} : @@ -579,7 +579,7 @@ noncomputable def sumQuot : apply Basis.mk (v := b) · apply LinearIndependent.sumElim_of_quotient · exact bW.linearIndependent - · convert bQ.linearIndependent + · convert! bQ.linearIndependent · unfold b rw [Set.Sum.elim_range, Submodule.span_union, show Set.range (fun i ↦ (bW i : V)) = W.subtype '' (Set.range (fun i ↦ bW i)) by aesop, diff --git a/Mathlib/LinearAlgebra/Dimension/ErdosKaplansky.lean b/Mathlib/LinearAlgebra/Dimension/ErdosKaplansky.lean index bde5ae08d101b2..0f9db109afca68 100644 --- a/Mathlib/LinearAlgebra/Dimension/ErdosKaplansky.lean +++ b/Mathlib/LinearAlgebra/Dimension/ErdosKaplansky.lean @@ -136,10 +136,10 @@ theorem lift_rank_lt_rank_dual {K : Type u} {V : Type v} [Field K] [AddCommGroup theorem rank_lt_rank_dual' {V : Type u} [AddCommGroup V] [Module K V] (h : ℵ₀ ≤ Module.rank K V) : Module.rank K V < Module.rank Kᵐᵒᵖ (V →ₗ[K] K) := by - convert lift_rank_lt_rank_dual' h; rw [lift_id] + convert! lift_rank_lt_rank_dual' h; rw [lift_id] theorem rank_lt_rank_dual {K V : Type u} [Field K] [AddCommGroup V] [Module K V] (h : ℵ₀ ≤ Module.rank K V) : Module.rank K V < Module.rank K (V →ₗ[K] K) := by - convert lift_rank_lt_rank_dual h; rw [lift_id] + convert! lift_rank_lt_rank_dual h; rw [lift_id] end Cardinal diff --git a/Mathlib/LinearAlgebra/Dimension/Finite.lean b/Mathlib/LinearAlgebra/Dimension/Finite.lean index 0ffa7cd3a87e2c..d08c8e0cf7ff44 100644 --- a/Mathlib/LinearAlgebra/Dimension/Finite.lean +++ b/Mathlib/LinearAlgebra/Dimension/Finite.lean @@ -223,7 +223,7 @@ lemma exists_finset_linearIndependent_of_le_finrank {n : ℕ} (hn : n ≤ finran ∃ s : Finset M, s.card = n ∧ LinearIndependent R ((↑) : s → M) := by by_cases h : finrank R M = 0 · rw [le_zero_iff.mp (hn.trans_eq h)] - exact ⟨∅, rfl, by convert linearIndependent_empty R M using 2 <;> aesop⟩ + exact ⟨∅, rfl, by convert! linearIndependent_empty R M using 2 <;> aesop⟩ exact exists_finset_linearIndependent_of_le_rank ((Nat.cast_le.mpr hn).trans_eq (cast_toNat_of_lt_aleph0 (toNat_ne_zero.mp h).2)) @@ -301,7 +301,7 @@ theorem Module.exists_nontrivial_relation_of_finrank_lt_card {t : Finset M} obtain ⟨g, sum, z, nonzero⟩ := Fintype.not_linearIndependent_iff.mp (mt LinearIndependent.finset_card_le_finrank h.not_ge) refine ⟨Subtype.val.extend g 0, ?_, z, z.2, by rwa [Subtype.val_injective.extend_apply]⟩ - rw [← Finset.sum_finset_coe]; convert sum; apply Subtype.val_injective.extend_apply + rw [← Finset.sum_finset_coe]; convert! sum; apply Subtype.val_injective.extend_apply /-- If a finset has cardinality larger than `finrank + 1`, then there is a nontrivial linear relation amongst its elements, @@ -476,7 +476,7 @@ theorem finrank_eq_zero_of_basis_imp_false (h : ∀ s : Finset M, Basis.{v} (s : finrank_eq_zero_of_basis_imp_not_finite fun s b hs => h hs.toFinset (by - convert b + convert! b simp) theorem finrank_eq_zero_of_not_exists_basis diff --git a/Mathlib/LinearAlgebra/Dimension/Free.lean b/Mathlib/LinearAlgebra/Dimension/Free.lean index 1b4235a7c1a7f7..9a6ff3562f240a 100644 --- a/Mathlib/LinearAlgebra/Dimension/Free.lean +++ b/Mathlib/LinearAlgebra/Dimension/Free.lean @@ -58,7 +58,7 @@ This is a simpler version of `lift_rank_mul_lift_rank` with `K` and `A` in the s theorem rank_mul_rank (A : Type v) [AddCommMonoid A] [Module K A] [Module F A] [IsScalarTower F K A] [Module.Free K A] : Module.rank F K * Module.rank K A = Module.rank F A := by - convert lift_rank_mul_lift_rank F K A <;> rw [lift_id] + convert! lift_rank_mul_lift_rank F K A <;> rw [lift_id] /-- Tower law: if `A` is a `K`-module and `K` is an extension of `F` then $\operatorname{rank}_F(A) = \operatorname{rank}_F(K) * \operatorname{rank}_K(A)$. -/ diff --git a/Mathlib/LinearAlgebra/Dimension/FreeAndStrongRankCondition.lean b/Mathlib/LinearAlgebra/Dimension/FreeAndStrongRankCondition.lean index f2ad8180f7cbc6..8907719c5773e6 100644 --- a/Mathlib/LinearAlgebra/Dimension/FreeAndStrongRankCondition.lean +++ b/Mathlib/LinearAlgebra/Dimension/FreeAndStrongRankCondition.lean @@ -53,7 +53,7 @@ theorem le_rank_iff_exists_linearIndependent [Module.Free K V] {c : Cardinal} : obtain ⟨κ, t'⟩ := Module.Free.exists_basis (R := K) (M := V) let t := t'.reindexRange have : LinearIndepOn K id (Set.range t') := by - convert t.linearIndependent.linearIndepOn_id + convert! t.linearIndependent.linearIndepOn_id ext simp [t] rw [← t.mk_eq_rank'', le_mk_iff_exists_subset] at h diff --git a/Mathlib/LinearAlgebra/Dimension/LinearMap.lean b/Mathlib/LinearAlgebra/Dimension/LinearMap.lean index a1f49c0143aecd..4ab815f8bdfc0f 100644 --- a/Mathlib/LinearAlgebra/Dimension/LinearMap.lean +++ b/Mathlib/LinearAlgebra/Dimension/LinearMap.lean @@ -110,14 +110,14 @@ theorem le_rank_iff_exists_linearIndependent {c : Cardinal} {f : V →ₗ[K] V'} refine ⟨g '' s, Cardinal.mk_image_eq_lift _ _ fg.injective, ?_⟩ replace fg : ∀ x, f (g x) = x := by intro x - convert congr_arg Subtype.val (fg x) + convert! congr_arg Subtype.val (fg x) replace si : LinearIndepOn K (fun x => f (g x)) s := by simpa only [fg] using si.map' _ (ker_subtype _) exact si.image_of_comp · rintro ⟨s, hsc, si⟩ have : LinearIndepOn K f.rangeRestrict s := - LinearIndependent.of_comp (LinearMap.range f).subtype (by convert si) - convert this.id_image.cardinal_le_rank + LinearIndependent.of_comp (LinearMap.range f).subtype (by convert! si) + convert! this.id_image.cardinal_le_rank rw [← Cardinal.lift_inj, ← hsc, Cardinal.mk_image_eq_of_injOn_lift] exact injOn_iff_injective.2 this.injective diff --git a/Mathlib/LinearAlgebra/Dimension/StrongRankCondition.lean b/Mathlib/LinearAlgebra/Dimension/StrongRankCondition.lean index 1cd53f73f250a8..368c32cb3e9fed 100644 --- a/Mathlib/LinearAlgebra/Dimension/StrongRankCondition.lean +++ b/Mathlib/LinearAlgebra/Dimension/StrongRankCondition.lean @@ -147,7 +147,7 @@ theorem Module.Basis.le_span {J : Set M} (v : Basis ι R M) (hJ : span R J = ⊤ haveI := nontrivial_of_invariantBasisNumber R cases fintypeOrInfinite J · rw [← Cardinal.lift_le, Cardinal.mk_range_eq_of_injective v.injective, Cardinal.mk_fintype J] - convert Cardinal.lift_le.{v}.2 (basis_le_span' v hJ) + convert! Cardinal.lift_le.{v}.2 (basis_le_span' v hJ) simp · let S : J → Set ι := fun j => ↑(v.repr j).support let S' : J → Set M := fun j => v '' S j @@ -330,7 +330,7 @@ theorem Module.Basis.mk_eq_rank'' {ι : Type v} (v : Basis ι R M) : #ι = Modul exact ⟨Set.range v, by rw [LinearIndepOn] - convert v.reindexRange.linearIndependent + convert! v.reindexRange.linearIndependent simp⟩ · exact (Cardinal.mk_range_eq v v.injective).ge · apply ciSup_le' @@ -601,7 +601,7 @@ theorem strongRankCondition_iff_forall_rank_lt_aleph0 [Nontrivial R] : refine ⟨fun ⟨n, f, inj⟩ ↦ ⟨n, ?_⟩, fun ⟨n, le⟩ ↦ ⟨n, le_rank_iff_exists_linearMap.mp (natCast_le_aleph0.trans le)⟩⟩ have ⟨g, hg⟩ := f.exists_finsupp_nat_of_fin_fun_injective inj - convert (Finsupp.basisSingleOne.linearIndependent.map_injOn _ hg.injOn).cardinal_lift_le_rank + convert! (Finsupp.basisSingleOne.linearIndependent.map_injOn _ hg.injOn).cardinal_lift_le_rank simp theorem strongRankCondition_iff_forall_zero_lt_finrank [Nontrivial R] : diff --git a/Mathlib/LinearAlgebra/Dual/Basis.lean b/Mathlib/LinearAlgebra/Dual/Basis.lean index 96feeb0126d692..8c652b22e163be 100644 --- a/Mathlib/LinearAlgebra/Dual/Basis.lean +++ b/Mathlib/LinearAlgebra/Dual/Basis.lean @@ -135,7 +135,7 @@ def dualBasis : Basis ι R (Dual R M) := -- We use `j = i` to match `Basis.repr_self` theorem dualBasis_apply_self (i j : ι) : b.dualBasis i (b j) = if j = i then 1 else 0 := by - convert b.toDual_apply i j using 2 + convert! b.toDual_apply i j using 2 rw [@eq_comm _ j i] theorem linearCombination_dualBasis (f : ι →₀ R) (i : ι) : diff --git a/Mathlib/LinearAlgebra/Dual/Lemmas.lean b/Mathlib/LinearAlgebra/Dual/Lemmas.lean index 29c42d49de56d2..b7dee15231048a 100644 --- a/Mathlib/LinearAlgebra/Dual/Lemmas.lean +++ b/Mathlib/LinearAlgebra/Dual/Lemmas.lean @@ -295,7 +295,7 @@ instance instFiniteDimensionalOfIsReflexive (K V : Type*) exact lt_irrefl _ this have h₁ : lift (Module.rank K V) < Module.rank K (Dual K V) := lift_rank_lt_rank_dual contra have h₂ : Module.rank K (Dual K V) < Module.rank K (Dual K (Dual K V)) := by - convert lift_rank_lt_rank_dual <| le_trans (by simpa) h₁.le + convert! lift_rank_lt_rank_dual <| le_trans (by simpa) h₁.le rw [lift_id'] exact lt_trans h₁ h₂ @@ -383,7 +383,7 @@ theorem _root_.mem_span_of_iInf_ker_le_ker [Finite ι] {L : ι → E →ₗ[𝕜 conv_lhs => enter [2]; intro i; rw [← p.liftQ_mkQ (L i) (iInf_le _ i)] rw [← p.liftQ_mkQ K h] ext x - convert LinearMap.congr_fun hK' (p.mkQ x) + convert! LinearMap.congr_fun hK' (p.mkQ x) simp only [L', LinearMap.coe_sum, Finset.sum_apply, smul_apply, coe_comp, Function.comp_apply, smul_eq_mul] @@ -701,7 +701,7 @@ theorem range_dualMap_eq_dualAnnihilator_ker_of_subtype_range_surjective (f : M have rr_surj : Function.Surjective f.rangeRestrict := by rw [← range_eq_top, range_rangeRestrict] have := range_dualMap_eq_dualAnnihilator_ker_of_surjective f.rangeRestrict rr_surj - convert this using 1 + convert! this using 1 · calc _ = range ((range f).subtype.comp f.rangeRestrict).dualMap := by simp _ = _ := ?_ diff --git a/Mathlib/LinearAlgebra/Eigenspace/Basic.lean b/Mathlib/LinearAlgebra/Eigenspace/Basic.lean index ae75420493bb31..7dc1121ef6347e 100644 --- a/Mathlib/LinearAlgebra/Eigenspace/Basic.lean +++ b/Mathlib/LinearAlgebra/Eigenspace/Basic.lean @@ -280,7 +280,7 @@ lemma genEigenspace_top_eq_maxUnifEigenspaceIndex [IsNoetherian R M] (f : End R genEigenspace f μ ⊤ = f.genEigenspace μ (maxUnifEigenspaceIndex f μ) := by have := WellFoundedGT.iSup_eq_monotonicSequenceLimit <| (f.genEigenspace μ).comp <| WithTop.coeOrderHom.toOrderHom - convert this using 1 + convert! this using 1 simp only [genEigenspace, OrderHom.coe_mk, le_top, iSup_pos, OrderHom.comp_coe, Function.comp_def] rw [iSup_prod', iSup_subtype', ← sSup_range, ← sSup_range] diff --git a/Mathlib/LinearAlgebra/Eigenspace/Matrix.lean b/Mathlib/LinearAlgebra/Eigenspace/Matrix.lean index 4fe412fc1d32c1..595b618e461c91 100644 --- a/Mathlib/LinearAlgebra/Eigenspace/Matrix.lean +++ b/Mathlib/LinearAlgebra/Eigenspace/Matrix.lean @@ -41,6 +41,8 @@ lemma hasEigenvector_toLin'_diagonal (d : n → R) (i : n) : HasEigenvector (toLin' (diagonal d)) (d i) (Pi.basisFun R n i) := hasEigenvector_toLin_diagonal _ _ (Pi.basisFun R n) +set_option linter.overlappingInstances false + /-- Eigenvalues of a diagonal linear operator are the diagonal entries. -/ lemma hasEigenvalue_toLin_diagonal_iff (d : n → R) {μ : R} [IsDomain R] [IsTorsionFree R M] (b : Basis n R M) : HasEigenvalue (toLin b b (diagonal d)) μ ↔ ∃ i, d i = μ := by diff --git a/Mathlib/LinearAlgebra/Eigenspace/Minpoly.lean b/Mathlib/LinearAlgebra/Eigenspace/Minpoly.lean index 81d19c7a1eefb6..e3e6ed43a718f9 100644 --- a/Mathlib/LinearAlgebra/Eigenspace/Minpoly.lean +++ b/Mathlib/LinearAlgebra/Eigenspace/Minpoly.lean @@ -99,7 +99,7 @@ variable (f) lemma finite_hasEigenvalue : Set.Finite f.HasEigenvalue := by have h : minpoly R f ≠ 0 := minpoly.ne_zero (Algebra.IsIntegral.isIntegral (R := R) f) - convert (minpoly R f).rootSet_finite R + convert! (minpoly R f).rootSet_finite R ext μ change f.HasEigenvalue μ ↔ _ rw [hasEigenvalue_iff_isRoot, mem_rootSet_of_ne h, IsRoot, coe_aeval_eq_eval] @@ -140,7 +140,7 @@ section FiniteSpectrum theorem Module.End.finite_spectrum {K : Type v} {V : Type w} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] (f : Module.End K V) : Set.Finite (spectrum K f) := by - convert f.finite_hasEigenvalue + convert! f.finite_hasEigenvalue ext f x exact Module.End.hasEigenvalue_iff_mem_spectrum.symm diff --git a/Mathlib/LinearAlgebra/ExteriorAlgebra/Basic.lean b/Mathlib/LinearAlgebra/ExteriorAlgebra/Basic.lean index 1ebc16ae040f93..35dcdd716096a7 100644 --- a/Mathlib/LinearAlgebra/ExteriorAlgebra/Basic.lean +++ b/Mathlib/LinearAlgebra/ExteriorAlgebra/Basic.lean @@ -285,7 +285,7 @@ def ιMulti (n : ℕ) : M [⋀^Fin n]→ₗ[R] ExteriorAlgebra R M := rw [hfxy, ← Fin.succ_pred y (ne_of_lt h).symm] exact ι_mul_prod_list (f ∘ Fin.succ) _ -- ignore the left-most term and induct on the remaining ones, decrementing indices - · convert mul_zero (ι R (f 0)) + · convert! mul_zero (ι R (f 0)) refine hn (fun i => f <| Fin.succ i) (x.pred hx) diff --git a/Mathlib/LinearAlgebra/ExteriorPower/Basic.lean b/Mathlib/LinearAlgebra/ExteriorPower/Basic.lean index beb5809e99aa93..98aee3cf78eee7 100644 --- a/Mathlib/LinearAlgebra/ExteriorPower/Basic.lean +++ b/Mathlib/LinearAlgebra/ExteriorPower/Basic.lean @@ -160,14 +160,14 @@ noncomputable def relationsSolutionEquiv {ι : Type*} [DecidableEq ι] {M : Type rw [map_sub, map_add, Finsupp.linearCombination_single, one_smul, Finsupp.linearCombination_single, one_smul, Finsupp.linearCombination_single, one_smul, sub_eq_zero] at this - convert this.symm -- `convert` is necessary due to the implementation of `MultilinearMap` + convert! this.symm -- `convert` is necessary due to the implementation of `MultilinearMap` map_update_smul' := fun m i r x ↦ by have := s.linearCombination_var_relation (.smul m i r x) dsimp at this ⊢ rw [Finsupp.smul_single, smul_eq_mul, mul_one, map_sub, Finsupp.linearCombination_single, one_smul, Finsupp.linearCombination_single, sub_eq_zero] at this - convert this + convert! this map_eq_zero_of_eq' := fun v i j hm hij ↦ by simpa using s.linearCombination_var_relation (.alt v i j hm hij) } invFun f := diff --git a/Mathlib/LinearAlgebra/FiniteDimensional/Basic.lean b/Mathlib/LinearAlgebra/FiniteDimensional/Basic.lean index 6912716d9a0513..ee2d03392f3e52 100644 --- a/Mathlib/LinearAlgebra/FiniteDimensional/Basic.lean +++ b/Mathlib/LinearAlgebra/FiniteDimensional/Basic.lean @@ -53,6 +53,14 @@ section DivisionRing variable [DivisionRing K] [AddCommGroup V] [Module K V] {V₂ : Type v'} [AddCommGroup V₂] [Module K V₂] +theorem finrank_le_iff_rank_le [FiniteDimensional K V] {n : ℕ} : + finrank K V ≤ n ↔ Module.rank K V ≤ n := by + simp [← Cardinal.toNat_le_iff_le_of_lt_aleph0 (rank_lt_aleph0 K V), finrank] + +theorem finrank_lt_iff_rank_lt [FiniteDimensional K V] {n : ℕ} : + finrank K V < n ↔ Module.rank K V < n := by + simp [← Cardinal.toNat_lt_iff_lt_of_lt_aleph0 (rank_lt_aleph0 K V), finrank] + theorem _root_.LinearIndependent.lt_aleph0_of_finiteDimensional {ι : Type w} [FiniteDimensional K V] {v : ι → V} (h : LinearIndependent K v) : #ι < ℵ₀ := h.lt_aleph0_of_finite diff --git a/Mathlib/LinearAlgebra/FiniteDimensional/Lemmas.lean b/Mathlib/LinearAlgebra/FiniteDimensional/Lemmas.lean index 4f217eaa1ecfa2..8b507723c38860 100644 --- a/Mathlib/LinearAlgebra/FiniteDimensional/Lemmas.lean +++ b/Mathlib/LinearAlgebra/FiniteDimensional/Lemmas.lean @@ -78,7 +78,7 @@ theorem eq_top_of_disjoint [FiniteDimensional K V] (s t : Submodule K V) replace hdim : finrank K V = finrank K s + finrank K t := le_antisymm hdim (finrank_add_finrank_le_of_disjoint hdisjoint) rw [hdim] - convert s.finrank_sup_add_finrank_inf_eq t + convert! s.finrank_sup_add_finrank_inf_eq t rw [h_finrank_inf, add_zero] theorem isCompl_iff_disjoint [FiniteDimensional K V] (s t : Submodule K V) diff --git a/Mathlib/LinearAlgebra/Finsupp/Span.lean b/Mathlib/LinearAlgebra/Finsupp/Span.lean index 9b363336f7e7d6..42f2508aaa93a8 100644 --- a/Mathlib/LinearAlgebra/Finsupp/Span.lean +++ b/Mathlib/LinearAlgebra/Finsupp/Span.lean @@ -128,7 +128,7 @@ theorem mem_sSup_iff_exists_finset {S : Set (Submodule R M)} {m : M} : · simp · suffices m ∈ ⨆ (i) (hi : i ∈ S) (_ : ⟨i, hi⟩ ∈ s), i by simpa rwa [iSup_subtype'] - · have : ⨆ (i) (_ : i ∈ S ∧ i ∈ s), i = ⨆ (i) (_ : i ∈ s), i := by convert rfl; grind + · have : ⨆ (i) (_ : i ∈ S ∧ i ∈ s), i = ⨆ (i) (_ : i ∈ s), i := by convert! rfl; grind simpa only [Finset.mem_preimage, iSup_subtype, iSup_and', this] end Semiring diff --git a/Mathlib/LinearAlgebra/Finsupp/Supported.lean b/Mathlib/LinearAlgebra/Finsupp/Supported.lean index 2ffbe608c3fe4b..a774d2ba9954e7 100644 --- a/Mathlib/LinearAlgebra/Finsupp/Supported.lean +++ b/Mathlib/LinearAlgebra/Finsupp/Supported.lean @@ -204,7 +204,7 @@ lemma codisjoint_supported_supported_iff [Nontrivial M] {s t : Set α} : @[simp] theorem supportedEquivFinsupp_symm_apply_coe (s : Set α) [DecidablePred (· ∈ s)] (f : s →₀ M) : (supportedEquivFinsupp (R := R) s).symm f = f.extendDomain := by - convert restrictSupportEquiv_symm_apply_coe .. + convert! restrictSupportEquiv_symm_apply_coe .. @[simp] theorem supportedEquivFinsupp_symm_single (s : Set α) (i : s) (a : M) : ((supportedEquivFinsupp (R := R) s).symm (single i a) : α →₀ M) = single ↑i a := by diff --git a/Mathlib/LinearAlgebra/Finsupp/VectorSpace.lean b/Mathlib/LinearAlgebra/Finsupp/VectorSpace.lean index 03c4579274e72c..5193b3d60d253c 100644 --- a/Mathlib/LinearAlgebra/Finsupp/VectorSpace.lean +++ b/Mathlib/LinearAlgebra/Finsupp/VectorSpace.lean @@ -79,8 +79,9 @@ theorem linearIndependent_single {φ : ι → Type*} (f : ∀ i, φ i → M) (hf : ∀ i, LinearIndependent R (f i)) : LinearIndependent R fun ix : Σ i, φ i ↦ single ix.1 (f ix.1 ix.2) := by classical - convert (DFinsupp.linearIndependent_single _ hf).map_injOn - _ (finsuppLequivDFinsupp R).symm.injective.injOn + convert! + (DFinsupp.linearIndependent_single _ hf).map_injOn _ + (finsuppLequivDFinsupp R).symm.injective.injOn simp lemma linearIndependent_single_iff {φ : ι → Type*} {f : ∀ i, φ i → M} : diff --git a/Mathlib/LinearAlgebra/FreeModule/Finite/Matrix.lean b/Mathlib/LinearAlgebra/FreeModule/Finite/Matrix.lean index afbe5d1d20c242..faacd6dc147ce3 100644 --- a/Mathlib/LinearAlgebra/FreeModule/Finite/Matrix.lean +++ b/Mathlib/LinearAlgebra/FreeModule/Finite/Matrix.lean @@ -82,14 +82,14 @@ instance Finite.algHom : Finite (M →ₐ[K] L) := open Cardinal theorem cardinalMk_algHom_le_rank : #(M →ₐ[K] L) ≤ lift.{v} (Module.rank K M) := by - convert (linearIndependent_algHom_toLinearMap K M L).cardinal_lift_le_rank + convert! (linearIndependent_algHom_toLinearMap K M L).cardinal_lift_le_rank · rw [lift_id] · have := Module.nontrivial K L rw [lift_id, Module.rank_linearMap_self] @[stacks 09HS] theorem card_algHom_le_finrank : Nat.card (M →ₐ[K] L) ≤ finrank K M := by - convert toNat_le_toNat (cardinalMk_algHom_le_rank K M L) ?_ + convert! toNat_le_toNat (cardinalMk_algHom_le_rank K M L) ?_ · rw [toNat_lift, finrank] · rw [lift_lt_aleph0]; have := Module.nontrivial K L; apply Module.rank_lt_aleph0 diff --git a/Mathlib/LinearAlgebra/FreeModule/Int.lean b/Mathlib/LinearAlgebra/FreeModule/Int.lean index 5e3683fbf59b0a..f48d41c34c3581 100644 --- a/Mathlib/LinearAlgebra/FreeModule/Int.lean +++ b/Mathlib/LinearAlgebra/FreeModule/Int.lean @@ -49,7 +49,7 @@ lemma toAddSubgroup_index_eq_pow_mul_prod [Module R M] {N : Submodule R M} set e : (ι → R) ≃+ M := ↑bM.equivFun.symm with he let e' : (ι → R) →+ M := e have he' : Function.Surjective e' := e.surjective - convert (AddSubgroup.index_comap_of_surjective N.toAddSubgroup he').symm using 2 + convert! (AddSubgroup.index_comap_of_surjective N.toAddSubgroup he').symm using 2 rw [AddSubgroup.comap_equiv_eq_map_symm, he, hN', LinearEquiv.coe_toAddEquiv_symm, AddEquiv.symm_symm] exact Submodule.map_toAddSubgroup .. @@ -64,7 +64,7 @@ lemma toAddSubgroup_index_eq_pow_mul_prod [Module R M] {N : Submodule R M} intro i simp only [Finset.sum_apply, Pi.smul_apply, Pi.single_apply] split_ifs with h - · convert dvd_mul_left (a h.choose) (c h.choose) + · convert! dvd_mul_left (a h.choose) (c h.choose) calc ∑ x : Fin n, _ = c h.choose * if i = f h.choose then a h.choose else 0 := by refine Finset.sum_eq_single h.choose ?_ (by simp) rintro j - hj @@ -72,8 +72,8 @@ lemma toAddSubgroup_index_eq_pow_mul_prod [Module R M] {N : Submodule R M} rw [h.choose_spec] at hinj simp [hinj.symm] _ = c h.choose * a h.choose := by simp [h.choose_spec] - · convert dvd_refl (0 : R) - convert Finset.sum_const_zero with j + · convert! dvd_refl (0 : R) + convert! Finset.sum_const_zero with j rw [not_exists] at h specialize h j rw [eq_comm] at h @@ -86,7 +86,7 @@ lemma toAddSubgroup_index_eq_pow_mul_prod [Module R M] {N : Submodule R M} by_cases! hj : ∃ j, f j = i · calc ∑ x : Fin n, _ = if i = f hj.choose then (h (f hj.choose)).choose * a hj.choose else 0 := by - convert Finset.sum_eq_single (M := R) hj.choose ?_ ?_ + convert! Finset.sum_eq_single (M := R) hj.choose ?_ ?_ · simp · rintro j - h have hinj := f.injective.ne h @@ -102,21 +102,21 @@ lemma toAddSubgroup_index_eq_pow_mul_prod [Module R M] {N : Submodule R M} congr! · exact hj.choose_spec.symm · simp [hj] - · convert Finset.sum_const_zero with x + · convert! Finset.sum_const_zero with x · specialize hj x rw [ne_comm] at hj simp [hj] · rw [← zero_dvd_iff] - convert h i + convert! h i simp [hj] simp only [hN', AddSubgroup.index_pi, apply_dite, Finset.prod_dite, Set.singleton_zero, Ideal.span_zero, Submodule.bot_toAddSubgroup, AddSubgroup.index_pi, AddSubgroup.index_bot, Finset.prod_const, Finset.univ_eq_attach, Finset.card_attach] rw [mul_comm] congr - · convert Finset.card_compl {x | ∃ j, f j = x} using 2 + · convert! Finset.card_compl {x | ∃ j, f j = x} using 2 · exact (Finset.compl_filter _).symm - · convert (Finset.card_image_of_injective Finset.univ f.injective).symm <;> simp + · convert! (Finset.card_image_of_injective Finset.univ f.injective).symm <;> simp · rw [Finset.attach_eq_univ] let f' : Fin n → { x // x ∈ Finset.filter (fun x ↦ ∃ j, f j = x) Finset.univ } := fun i ↦ ⟨f i, by simp⟩ @@ -194,7 +194,7 @@ lemma submodule_toAddSubgroup_index_ne_zero_iff {N : Submodule ℤ (ι → ℤ)} lemma addSubgroup_index_ne_zero_iff {H : AddSubgroup (ι → ℤ)} : H.index ≠ 0 ↔ Nonempty (H ≃+ (ι → ℤ)) := by - convert submodule_toAddSubgroup_index_ne_zero_iff (N := AddSubgroup.toIntSubmodule H) using 1 + convert! submodule_toAddSubgroup_index_ne_zero_iff (N := AddSubgroup.toIntSubmodule H) using 1 exact ⟨fun ⟨e⟩ ↦ ⟨e.toIntLinearEquiv⟩, fun ⟨e⟩ ↦ ⟨e.toAddEquiv⟩⟩ set_option backward.isDefEq.respectTransparency false in diff --git a/Mathlib/LinearAlgebra/FreeProduct/Basic.lean b/Mathlib/LinearAlgebra/FreeProduct/Basic.lean index 59c4dca4926b09..e916dbecd9b492 100644 --- a/Mathlib/LinearAlgebra/FreeProduct/Basic.lean +++ b/Mathlib/LinearAlgebra/FreeProduct/Basic.lean @@ -189,7 +189,7 @@ the same `i` is just the injection of multiplication `aᵢ * aᵢ'` in `A i`. -/ theorem mul_injections (a₁ a₂ : A i) : ι' R A (DirectSum.lof R I A i a₁) * ι' R A (DirectSum.lof R I A i a₂) = ι' R A (DirectSum.lof R I A i (a₁ * a₂)) := by - convert RingQuot.mkAlgHom_rel R <| rel.prod + convert! RingQuot.mkAlgHom_rel R <| rel.prod simp /-- The `i`th canonical injection, from `A i` to the free product, as diff --git a/Mathlib/LinearAlgebra/Goursat.lean b/Mathlib/LinearAlgebra/Goursat.lean index b39c302ba97412..6c60553745f33d 100644 --- a/Mathlib/LinearAlgebra/Goursat.lean +++ b/Mathlib/LinearAlgebra/Goursat.lean @@ -90,7 +90,7 @@ lemma goursat_surjective : ∃ e : (M ⧸ L.goursatFst) ≃ₗ[R] N ⧸ L.goursa -- define the map as an R-linear equiv use { e with map_smul' := this } rw [← toAddSubgroup_injective.eq_iff] - convert he using 1 + convert! he using 1 ext v rw [mem_toAddSubgroup, mem_graph_iff, Eq.comm] rfl @@ -131,7 +131,7 @@ lemma goursat : ∃ (M' : Submodule R M) (N' : Submodule R N) (M'' : Submodule R Subtype.exists, Prod.exists, LinearMap.prodMap_apply, subtype_apply, Prod.mk.injEq, snd_apply, fst_apply, Subtype.ext_iff, submoduleMap_coe_apply] grind - · convert goursatFst_prod_goursatSnd_le (range <| P.prod Q) + · convert! goursatFst_prod_goursatSnd_le (range <| P.prod Q) simp only [ker_prodMap, ker_mkQ, Submodule.ext_iff] grind diff --git a/Mathlib/LinearAlgebra/Lagrange.lean b/Mathlib/LinearAlgebra/Lagrange.lean index 275b424e2e2ff3..0a7fcc873a46ba 100644 --- a/Mathlib/LinearAlgebra/Lagrange.lean +++ b/Mathlib/LinearAlgebra/Lagrange.lean @@ -244,7 +244,7 @@ theorem natDegree_basis (hvs : Set.InjOn v s) (hi : i ∈ s) : simp_rw [Ne, mem_erase, basisDivisor_eq_zero_iff] exact fun j ⟨hij₁, hj⟩ hij₂ => hij₁ (hvs hj hi hij₂.symm) rw [← card_erase_of_mem hi, card_eq_sum_ones] - convert natDegree_prod _ _ H using 1 + convert! natDegree_prod _ _ H using 1 refine sum_congr rfl fun j hj => (natDegree_basisDivisor_of_ne ?_).symm rw [Ne, ← basisDivisor_eq_zero_iff] exact H _ hj @@ -414,7 +414,8 @@ theorem interpolate_eq_sum_interpolate_insert_sdiff (hvt : Set.InjOn v t) (hs : Nat.succ_add_sub_one, zero_add] rw [degree_basis (Set.InjOn.mono hst hvt) hi, H, WithBot.coe_add, Nat.cast_withBot, WithBot.add_lt_add_iff_right (@WithBot.coe_ne_bot _ (#s - 1))] - convert degree_interpolate_lt _ + convert! + degree_interpolate_lt _ (hvt.mono (coe_subset.mpr (insert_subset_iff.mpr ⟨hst hi, sdiff_subset⟩))) rw [card_insert_of_notMem (notMem_sdiff_of_mem_right hi), card_sdiff_of_subset hst, add_comm] · simp_rw [eval_finsetSum, eval_mul] diff --git a/Mathlib/LinearAlgebra/LinearDisjoint.lean b/Mathlib/LinearAlgebra/LinearDisjoint.lean index 74b1ae128c5357..92b016cadf3c42 100644 --- a/Mathlib/LinearAlgebra/LinearDisjoint.lean +++ b/Mathlib/LinearAlgebra/LinearDisjoint.lean @@ -542,7 +542,7 @@ theorem rank_inf_le_one_of_commute_of_flat (hf : Module.Flat R M ∨ Module.Flat · simp [hab] at hij · simp [hab.symm] at hij · rfl - convert this + convert! this ext i fin_cases i <;> simp diff --git a/Mathlib/LinearAlgebra/LinearIndependent/Basic.lean b/Mathlib/LinearAlgebra/LinearIndependent/Basic.lean index ae6ab85be8021e..130045217cd615 100644 --- a/Mathlib/LinearAlgebra/LinearIndependent/Basic.lean +++ b/Mathlib/LinearAlgebra/LinearIndependent/Basic.lean @@ -161,7 +161,7 @@ theorem LinearIndepOn_iff_linearIndepOn_image_injOn [Nontrivial R] : theorem linearIndepOn_congr {w : ι → M} (h : EqOn v w s) : LinearIndepOn R v s ↔ LinearIndepOn R w s := by rw [LinearIndepOn, LinearIndepOn] - convert Iff.rfl using 2 + convert! Iff.rfl using 2 ext x exact h.symm x.2 @@ -184,7 +184,7 @@ theorem LinearIndependent.group_smul_iff {G : Type*} [hG : Group G] [MulAction G [MulAction G M] [IsScalarTower G R M] [SMulCommClass G R M] (v : ι → M) (w : ι → G) : LinearIndependent R (w • v) ↔ LinearIndependent R v := by refine ⟨fun h ↦ ?_, fun h ↦ h.group_smul w⟩ - convert h.group_smul (fun i ↦ (w i)⁻¹) + convert! h.group_smul (fun i ↦ (w i)⁻¹) simp [funext_iff] -- This lemma cannot be proved with `LinearIndependent.group_smul` since the action of @@ -202,7 +202,7 @@ theorem LinearIndependent.units_smul {v : ι → M} (hv : LinearIndependent R v) theorem LinearIndependent.units_smul_iff (v : ι → M) (w : ι → Rˣ) : LinearIndependent R (w • v) ↔ LinearIndependent R v := by refine ⟨fun h ↦ ?_, fun h ↦ h.units_smul w⟩ - convert h.units_smul (fun i ↦ (w i)⁻¹) + convert! h.units_smul (fun i ↦ (w i)⁻¹) simp [funext_iff] theorem linearIndependent_span (hs : LinearIndependent R v) : @@ -300,12 +300,12 @@ theorem eq_of_linearIndepOn_id_of_span_subtype [Nontrivial R] {s t : Set M} ⟨fun x => ⟨x.1, h x.2⟩, fun a b hab => Subtype.coe_injective (Subtype.mk.inj hab)⟩ have h_surj : Surjective f := by apply surjective_of_linearIndependent_of_span hs f _ - convert hst <;> simp [f, comp_def] + convert! hst <;> simp [f, comp_def] change s = t apply Subset.antisymm _ h intro x hx rcases h_surj ⟨x, hx⟩ with ⟨y, hy⟩ - convert y.mem + convert! y.mem rw [← Subtype.mk.inj hy] theorem le_of_span_le_span [Nontrivial R] {s t u : Set M} (hl : LinearIndepOn R id u) @@ -462,7 +462,7 @@ theorem LinearIndepOn.union {t : Set ι} (hs : LinearIndepOn R v s) (ht : Linear have hli := LinearIndependent.sum_type hs ht (by rwa [← image_eq_range, ← image_eq_range]) have hdj := (hdj.of_span₀ hs.zero_notMem_image).of_image rw [LinearIndepOn] - convert (hli.comp _ (Equiv.Set.union hdj).injective) with ⟨x, hx | hx⟩ + convert! (hli.comp _ (Equiv.Set.union hdj).injective) with ⟨x, hx | hx⟩ · rw [comp_apply, Equiv.Set.union_apply_left _ hx, Sum.elim_inl] rw [comp_apply, Equiv.Set.union_apply_right _ hx, Sum.elim_inr] @@ -475,7 +475,7 @@ theorem linearIndepOn_union_iff {t : Set ι} (hdj : Disjoint s t) : LinearIndepOn R v s ∧ LinearIndepOn R v t ∧ Disjoint (span R (v '' s)) (span R (v '' t)) := by refine ⟨fun h ↦ ⟨h.mono subset_union_left, h.mono subset_union_right, ?_⟩, fun h ↦ h.1.union h.2.1 h.2.2⟩ - convert h.disjoint_span_image (s := (↑) ⁻¹' s) (t := (↑) ⁻¹' t) (hdj.preimage _) <;> + convert! h.disjoint_span_image (s := (↑) ⁻¹' s) (t := (↑) ⁻¹' t) (hdj.preimage _) <;> aesop theorem linearIndepOn_id_union_iff {s t : Set M} (hdj : Disjoint s t) : diff --git a/Mathlib/LinearAlgebra/LinearIndependent/Defs.lean b/Mathlib/LinearAlgebra/LinearIndependent/Defs.lean index e25725c53462ab..65b96f0f5c5b3a 100644 --- a/Mathlib/LinearAlgebra/LinearIndependent/Defs.lean +++ b/Mathlib/LinearAlgebra/LinearIndependent/Defs.lean @@ -148,7 +148,7 @@ theorem LinearIndepOn.injOn [Nontrivial R] (hv : LinearIndepOn R v s) : InjOn v injOn_iff_injective.2 <| LinearIndependent.injective hv theorem LinearIndependent.smul_left_injective (hv : LinearIndependent R v) (i : ι) : - Injective fun r : R ↦ r • v i := by convert hv.comp (Finsupp.single_injective i); simp + Injective fun r : R ↦ r • v i := by convert! hv.comp (Finsupp.single_injective i); simp theorem LinearIndependent.ne_zero [Nontrivial R] (i : ι) (hv : LinearIndependent R v) : v i ≠ 0 := by @@ -251,7 +251,7 @@ theorem linearIndependent_iff''ₛ : exact linearIndependent_iff'ₛ.trans ⟨fun H s f g eq hv i ↦ if his : i ∈ s then H s f g hv i his else eq i his, fun H s f g eq i hi ↦ by - convert + convert! H s (fun j ↦ if j ∈ s then f j else 0) (fun j ↦ if j ∈ s then g j else 0) (fun j hj ↦ (if_neg hj).trans (if_neg hj).symm) (by simp_rw [ite_smul, zero_smul, Finset.sum_extend_by_zero, eq]) i <;> @@ -611,7 +611,7 @@ theorem linearIndependent_iffₒₛ : (a := ∑ i ∈ s with g i ≤ f i, g i • v i + ∑ i ∈ s with f i < g i, f i • v i)] conv_lhs => rw [← add_assoc, ← Finset.sum_add_distrib] conv_rhs => rw [add_left_comm, ← Finset.sum_add_distrib] - convert heq + convert! heq <;> simp_rw [← Finset.sum_filter_add_sum_filter_not s (fun i => g i ≤ f i), not_le] <;> congr! 2 with i hi <;> simp only [Finset.mem_filter] at hi @@ -648,7 +648,7 @@ nonrec theorem Fintype.linearIndependent_iffₒₛ [DecidableEq ι] [Fintype ι] · exact h.2 i (Finset.mem_compl.2 hi) · specialize h t₁ (fun i => if i ∈ t₁ ∨ i ∈ t₂ then f i else 0) ?_ · rw [← Finset.sum_subset ht₁t₂.le_compl_left] - · convert heq using 2 with i hi i hi <;> simp [hi] + · convert! heq using 2 with i hi i hi <;> simp [hi] · intro i hi hi' simp [Finset.mem_compl.1 hi, hi'] refine ⟨fun i hi => ?_, fun i hi => ?_⟩ <;> simpa [hi] using h i @@ -732,9 +732,9 @@ theorem linearIndependent_iff' : ∀ s : Finset ι, ∀ g : ι → R, ∑ i ∈ s, g i • v i = 0 → ∀ i ∈ s, g i = 0 := by rw [linearIndependent_iff'ₛ] refine ⟨fun h s f ↦ ?_, fun h s f g ↦ ?_⟩ - · convert h s f 0; simp_rw [Pi.zero_apply, zero_smul, Finset.sum_const_zero] + · convert! h s f 0; simp_rw [Pi.zero_apply, zero_smul, Finset.sum_const_zero] · rw [← sub_eq_zero, ← Finset.sum_sub_distrib] - convert h s (f - g) using 3; simp only [Pi.sub_apply, sub_smul, sub_eq_zero] + convert! h s (f - g) using 3; simp only [Pi.sub_apply, sub_smul, sub_eq_zero] /-- A version of `linearIndependent_iff` where the linear combination is a `Finset` sum of a function with support contained in the `Finset`. -/ @@ -744,7 +744,7 @@ theorem linearIndependent_iff'' : classical exact linearIndependent_iff'.trans ⟨fun H s g hg hv i => if his : i ∈ s then H s g hv i his else hg i his, fun H s g hg i hi => by - convert + convert! H s (fun j => if j ∈ s then g j else 0) (fun j hj => if_neg hj) (by simp_rw [ite_smul, zero_smul, Finset.sum_extend_by_zero, hg]) i exact (if_pos hi).symm⟩ diff --git a/Mathlib/LinearAlgebra/LinearIndependent/Lemmas.lean b/Mathlib/LinearAlgebra/LinearIndependent/Lemmas.lean index 0f28bcfd0bfb91..53b78e43f53c4a 100644 --- a/Mathlib/LinearAlgebra/LinearIndependent/Lemmas.lean +++ b/Mathlib/LinearAlgebra/LinearIndependent/Lemmas.lean @@ -155,7 +155,7 @@ variable (hv : LinearIndependent R v) /-- See also `iSupIndep_iff_linearIndependent_of_ne_zero`. -/ theorem LinearIndependent.iSupIndep_span_singleton (hv : LinearIndependent R v) : iSupIndep fun i => R ∙ v i := by - convert LinearMap.iSupIndep_map _ hv (iSupIndep_range_lsingle ι R R) + convert! LinearMap.iSupIndep_map _ hv (iSupIndep_range_lsingle ι R R) ext; simp [mem_span_singleton] end repr @@ -346,7 +346,7 @@ private lemma LinearIndependent.pair_add_smul_add_smul_iff_aux (h : a * d ≠ b refine ⟨fun h' ↦ ⟨?_, h⟩, fun ⟨h₁, h₂⟩ ↦ pair_add_smul_add_smul_iff_aux _ _ _ _ h₂ h₁⟩ suffices LinearIndependent R ![(a * d - b * c) • x, (a * d - b * c) • y] by rwa [pair_smul_iff (sub_ne_zero_of_ne h)] at this - convert pair_add_smul_add_smul_iff_aux d (-b) (-c) a (by simpa [mul_comm d a]) h' using 1 + convert! pair_add_smul_add_smul_iff_aux d (-b) (-c) a (by simpa [mul_comm d a]) h' using 1 ext i; fin_cases i <;> simp <;> module @[simp] lemma LinearIndependent.pair_add_smul_right_iff : @@ -631,7 +631,7 @@ theorem linearIndepOn_id_pair {x y : V} (hx : x ≠ 0) (hy : ∀ a : K, a • x theorem linearIndepOn_pair_iff {i j : ι} (v : ι → V) (hij : i ≠ j) (hi : v i ≠ 0) : LinearIndepOn K v {i, j} ↔ ∀ (c : K), c • v i ≠ v j := by rw [pair_comm] - convert linearIndepOn_insert (s := {i}) (a := j) hij.symm + convert! linearIndepOn_insert (s := { i }) (a := j) hij.symm simp [hi, mem_span_singleton] /-- Also see `LinearIndependent.pair_iff` for the version over arbitrary rings. -/ @@ -749,7 +749,7 @@ theorem exists_linearIndepOn_extension {s t : Set ι} (hs : LinearIndepOn K v s) theorem exists_linearIndepOn_id_extension (hs : LinearIndepOn K id s) (hst : s ⊆ t) : ∃ b ⊆ t, s ⊆ b ∧ t ⊆ span K b ∧ LinearIndepOn K id b := by - convert exists_linearIndepOn_extension hs hst <;> simp + convert! exists_linearIndepOn_extension hs hst <;> simp variable (K t) @@ -798,7 +798,7 @@ theorem LinearIndepOn.image_subset_span_image_extend (hs : LinearIndepOn K v s) theorem LinearIndepOn.subset_span_extend {s t : Set V} (hs : LinearIndepOn K id s) (hst : s ⊆ t) : t ⊆ span K (hs.extend hst) := by - convert hs.image_subset_span_image_extend hst <;> simp + convert! hs.image_subset_span_image_extend hst <;> simp theorem LinearIndepOn.span_image_extend_eq_span_image (hs : LinearIndepOn K v s) (hst : s ⊆ t) : span K (v '' hs.extend hst) = span K (v '' t) := diff --git a/Mathlib/LinearAlgebra/LinearPMap.lean b/Mathlib/LinearAlgebra/LinearPMap.lean index 7e4edd421241f3..236586e4664d36 100644 --- a/Mathlib/LinearAlgebra/LinearPMap.lean +++ b/Mathlib/LinearAlgebra/LinearPMap.lean @@ -870,7 +870,7 @@ theorem le_graph_of_le {f g : E →ₗ.[R] F} (h : f ≤ g) : f.graph ≤ g.grap obtain ⟨y, hx⟩ := hx use ⟨y, h.1 y.2⟩ simp only [hx, true_and] - convert hx.2 using 1 + convert! hx.2 using 1 refine (h.2 ?_).symm simp only [hx.1] @@ -897,11 +897,11 @@ theorem existsUnique_from_graph {g : Submodule R (E × F)} (hg : ∀ {x : E × F} (_hx : x ∈ g) (_hx' : x.fst = 0), x.snd = 0) {a : E} (ha : a ∈ g.map (LinearMap.fst R E F)) : ∃! b : F, (a, b) ∈ g := by refine existsUnique_of_exists_of_unique ?_ ?_ - · convert ha + · convert! ha simp intro y₁ y₂ hy₁ hy₂ have hy : ((0 : E), y₁ - y₂) ∈ g := by - convert g.sub_mem hy₁ hy₂ + convert! g.sub_mem hy₁ hy₂ exact (sub_self _).symm exact sub_eq_zero.mp (hg hy (by simp)) @@ -973,7 +973,7 @@ theorem toLinearPMap_graph_eq (g : Submodule R (E × F)) constructor <;> intro hx · rw [LinearPMap.mem_graph_iff] at hx rcases hx with ⟨y, hx1, hx2⟩ - convert g.mem_graph_toLinearPMap hg y using 1 + convert! g.mem_graph_toLinearPMap hg y using 1 exact Prod.ext hx1.symm hx2.symm rw [LinearPMap.mem_graph_iff] have hx_fst : x_fst ∈ g.map (LinearMap.fst R E F) := by diff --git a/Mathlib/LinearAlgebra/Matrix/Adjugate.lean b/Mathlib/LinearAlgebra/Matrix/Adjugate.lean index 47e1149b0f264a..a0eef4c45f79cf 100644 --- a/Mathlib/LinearAlgebra/Matrix/Adjugate.lean +++ b/Mathlib/LinearAlgebra/Matrix/Adjugate.lean @@ -114,13 +114,13 @@ theorem cramer_transpose_row_self (i : n) : Aᵀ.cramer (A i) = Pi.single i A.de theorem cramer_row_self (i : n) (h : ∀ j, b j = A j i) : A.cramer b = Pi.single i A.det := by rw [← transpose_transpose A, det_transpose] - convert cramer_transpose_row_self Aᵀ i + convert! cramer_transpose_row_self Aᵀ i exact funext h @[simp] theorem cramer_one : cramer (1 : Matrix n n α) = 1 := by ext i j - convert congr_fun (cramer_row_self (1 : Matrix n n α) (Pi.single i 1) i _) j + convert! congr_fun (cramer_row_self (1 : Matrix n n α) (Pi.single i 1) i _) j · simp · intro j rw [Matrix.one_eq_pi_single, Pi.single_comm] diff --git a/Mathlib/LinearAlgebra/Matrix/Block.lean b/Mathlib/LinearAlgebra/Matrix/Block.lean index 8d6f1d7e092528..33723314f1fcab 100644 --- a/Mathlib/LinearAlgebra/Matrix/Block.lean +++ b/Mathlib/LinearAlgebra/Matrix/Block.lean @@ -68,9 +68,9 @@ protected theorem BlockTriangular.submatrix {f : n → m} (h : M.BlockTriangular theorem blockTriangular_reindex_iff {b : n → α} {e : m ≃ n} : (reindex e e M).BlockTriangular b ↔ M.BlockTriangular (b ∘ e) := by refine ⟨fun h => ?_, fun h => ?_⟩ - · convert h.submatrix + · convert! h.submatrix simp only [reindex_apply, submatrix_submatrix, submatrix_id_id, Equiv.symm_comp_self] - · convert h.submatrix + · convert! h.submatrix simp only [comp_assoc b e e.symm, Equiv.self_comp_symm, comp_id] protected theorem BlockTriangular.transpose : @@ -238,7 +238,12 @@ variable [CommRing R] [DecidableEq m] [Fintype m] [DecidableEq n] [Fintype n] theorem equiv_block_det (M : Matrix m m R) {p q : m → Prop} [DecidablePred p] [DecidablePred q] (e : ∀ x, q x ↔ p x) : (toSquareBlockProp M p).det = (toSquareBlockProp M q).det := by - convert Matrix.det_reindex_self (Equiv.subtypeEquivRight e) (toSquareBlockProp M q) + convert! + Matrix.det_reindex_self (Equiv.subtypeEquivRight e) + (toSquareBlockProp M q) + -- Removed `@[simp]` attribute, + -- as the LHS simplifies already to `M.toSquareBlock id i ⟨i, ⋯⟩ ⟨i, ⋯⟩` + -- Removed `@[simp]` attribute, -- as the LHS simplifies already to `M.toSquareBlock id i ⟨i, ⋯⟩ ⟨i, ⋯⟩` @@ -263,7 +268,8 @@ theorem twoBlockTriangular_det (M : Matrix m m R) (p : m → Prop) [DecidablePre (h : ∀ i, ¬p i → ∀ j, p j → M i j = 0) : M.det = (toSquareBlockProp M p).det * (toSquareBlockProp M fun i => ¬p i).det := by rw [det_toBlock M p] - convert det_fromBlocks_zero₂₁ (toBlock M p p) (toBlock M p fun j => ¬p j) + convert! + det_fromBlocks_zero₂₁ (toBlock M p p) (toBlock M p fun j => ¬p j) (toBlock M (fun j => ¬p j) fun j => ¬p j) ext i j exact h (↑i) i.2 (↑j) j.2 @@ -295,7 +301,7 @@ protected theorem BlockTriangular.det [DecidableEq α] [LinearOrder α] (hM : Bl let b' := fun i : { a // b a ≠ k } => b ↑i have h' : BlockTriangular (M.toSquareBlockProp fun i => b i ≠ k) b' := hM.submatrix have hb' : image b' univ = (image b univ).erase k := by - convert image_subtype_ne_univ_eq_image_erase k b + convert! image_subtype_ne_univ_eq_image_erase k b rw [ih _ (max'_mem _ _) h' hb'] refine Finset.prod_congr rfl fun l hl => ?_ let he : { a // b' a = l } ≃ { a // b a = l } := @@ -338,7 +344,7 @@ theorem det_matrixOfPolynomials {n : ℕ} (p : Fin n → R[X]) (Matrix.of (fun (i j : Fin n) => (p j).coeff i)).det = 1 := by rw [Matrix.det_of_upperTriangular (Matrix.matrixOfPolynomials_blockTriangular p (fun i ↦ Nat.le_of_eq (h_deg i)))] - convert prod_const_one with x _ + convert! prod_const_one with x _ rw [Matrix.of_apply, ← h_deg, coeff_natDegree, (h_monic x).leadingCoeff] /-! ### Invertible -/ @@ -415,8 +421,8 @@ theorem blockTriangular_inv_of_blockTriangular [LinearOrder α] [Invertible M] haveI : Invertible A := hM.invertibleToBlock _ have hA : A.BlockTriangular b' := hM.submatrix have hb' : image b' univ ⊂ image b univ := by - convert image_subtype_univ_ssubset_image_univ k b _ (fun a => a < k) (lt_irrefl _) - convert max'_mem (α := α) _ _ + convert! image_subtype_univ_ssubset_image_univ k b _ (fun a => a < k) (lt_irrefl _) + convert! max'_mem (α := α) _ _ have hij' : b' ⟨j, hij.trans hi⟩ < b' ⟨i, hi⟩ := by simp_rw [b', hij] simp [A, hM.inv_toBlock k, (ih (image b' univ) hb' hA rfl hij').symm] diff --git a/Mathlib/LinearAlgebra/Matrix/Charpoly/Coeff.lean b/Mathlib/LinearAlgebra/Matrix/Charpoly/Coeff.lean index ed9025ce7ee7ef..7165bbd4490c99 100644 --- a/Mathlib/LinearAlgebra/Matrix/Charpoly/Coeff.lean +++ b/Mathlib/LinearAlgebra/Matrix/Charpoly/Coeff.lean @@ -180,7 +180,7 @@ lemma derivative_det_one_add_X_smul (M : Matrix n n R) : (derivative <| det (1 + (X : R[X]) • M.map C)).eval 0 = trace M := by let e := Matrix.reindexLinearEquiv R R (Fintype.equivFin n) (Fintype.equivFin n) rw [← Matrix.det_reindexLinearEquiv_self R[X] (Fintype.equivFin n)] - convert derivative_det_one_add_X_smul_aux (e M) + convert! derivative_det_one_add_X_smul_aux (e M) · ext; simp [map_add, e] · delta trace rw [← (Fintype.equivFin n).symm.sum_comp] @@ -197,7 +197,7 @@ lemma det_one_add_X_smul (M : Matrix n n R) : rw [Algebra.smul_def (trace M), ← C_eq_algebraMap, pow_two, ← mul_assoc, add_assoc, ← add_mul, ← coeff_det_one_add_X_smul_one, ← coeff_divX, add_comm (C _), divX_mul_X_add, add_comm (1 : R[X]), ← C.map_one] - convert (divX_mul_X_add _).symm + convert! (divX_mul_X_add _).symm rw [coeff_zero_eq_eval_zero, eval_det_add_X_smul, det_one, eval_one] /-- The first two terms of the Taylor expansion of `det (1 + r • M)` at `r = 0`. -/ @@ -340,7 +340,7 @@ lemma isUnit_charpolyRev_of_isNilpotent (hM : IsNilpotent M) : IsUnit M.charpolyRev := by obtain ⟨k, hk⟩ := hM replace hk : 1 - (X : R[X]) • M.map C ∣ 1 := by - convert one_sub_dvd_one_sub_pow ((X : R[X]) • M.map C) k + convert! one_sub_dvd_one_sub_pow ((X : R[X]) • M.map C) k rw [← C.mapMatrix_apply, smul_pow, ← map_pow, hk, map_zero, smul_zero, sub_zero] apply isUnit_of_dvd_one rw [← det_one (R := R[X]) (n := n)] diff --git a/Mathlib/LinearAlgebra/Matrix/Charpoly/Eigs.lean b/Mathlib/LinearAlgebra/Matrix/Charpoly/Eigs.lean index c9537890c1fd72..4b140e85ddb83d 100644 --- a/Mathlib/LinearAlgebra/Matrix/Charpoly/Eigs.lean +++ b/Mathlib/LinearAlgebra/Matrix/Charpoly/Eigs.lean @@ -63,32 +63,35 @@ open scoped Matrix namespace Matrix -/-- The roots of the characteristic polynomial are in the spectrum of the matrix. -/ -theorem mem_spectrum_of_isRoot_charpoly [Nontrivial R] - {r : R} (hr : IsRoot B.charpoly r) : r ∈ spectrum R B := by - simp_all [eval_charpoly, spectrum.mem_iff, isUnit_iff_isUnit_det, algebraMap_eq_diagonal, +theorem mem_spectrum_iff_not_isUnit_eval_charpoly {r : R} : + r ∈ spectrum R B ↔ ¬IsUnit (B.charpoly.eval r) := by + simp [eval_charpoly, spectrum.mem_iff, isUnit_iff_isUnit_det, algebraMap_eq_diagonal, Pi.algebraMap_def] +/-- The roots of the characteristic polynomial are in the spectrum of the matrix. -/ +theorem mem_spectrum_of_isRoot_charpoly [Nontrivial R] {r : R} (hr : IsRoot B.charpoly r) : + r ∈ spectrum R B := by + simp [mem_spectrum_iff_not_isUnit_eval_charpoly, hr.eq_zero] + /-- In fields, the roots of the characteristic polynomial are exactly the spectrum of the matrix. The weaker direction is true in nontrivial rings (see `Matrix.mem_spectrum_of_isRoot_charpoly`). -/ theorem mem_spectrum_iff_isRoot_charpoly {r : K} : r ∈ spectrum K A ↔ IsRoot A.charpoly r := by - simp [eval_charpoly, spectrum.mem_iff, isUnit_iff_isUnit_det, algebraMap_eq_diagonal, - Pi.algebraMap_def] + simp [mem_spectrum_iff_not_isUnit_eval_charpoly] -theorem det_eq_prod_roots_charpoly_of_splits (hAps : A.charpoly.Splits) : - A.det = (Matrix.charpoly A).roots.prod := by - rw [det_eq_sign_charpoly_coeff, ← charpoly_natDegree_eq_dim A, - hAps.coeff_zero_eq_prod_roots_of_monic A.charpoly_monic, ← mul_assoc, +theorem det_eq_prod_roots_charpoly_of_splits [IsDomain R] (hAps : B.charpoly.Splits) : + B.det = (Matrix.charpoly B).roots.prod := by + rw [det_eq_sign_charpoly_coeff, ← charpoly_natDegree_eq_dim B, + hAps.coeff_zero_eq_prod_roots_of_monic B.charpoly_monic, ← mul_assoc, ← pow_two, pow_right_comm, neg_one_sq, one_pow, one_mul] -theorem trace_eq_sum_roots_charpoly_of_splits (hAps : A.charpoly.Splits) : - A.trace = (Matrix.charpoly A).roots.sum := by +theorem trace_eq_sum_roots_charpoly_of_splits [IsDomain R] (hAps : B.charpoly.Splits) : + B.trace = (Matrix.charpoly B).roots.sum := by rcases isEmpty_or_nonempty n with h | _ · simp · rw [trace_eq_neg_charpoly_nextCoeff, neg_eq_iff_eq_neg, - ← hAps.nextCoeff_eq_neg_sum_roots_of_monic A.charpoly_monic] + ← hAps.nextCoeff_eq_neg_sum_roots_of_monic B.charpoly_monic] variable (A) diff --git a/Mathlib/LinearAlgebra/Matrix/Determinant/Basic.lean b/Mathlib/LinearAlgebra/Matrix/Determinant/Basic.lean index 66b6beb66750b7..358af6787acc2c 100644 --- a/Mathlib/LinearAlgebra/Matrix/Determinant/Basic.lean +++ b/Mathlib/LinearAlgebra/Matrix/Determinant/Basic.lean @@ -78,7 +78,7 @@ theorem det_diagonal {d : n → R} : det (diagonal d) = ∏ i, d i := by refine (Finset.sum_eq_single 1 ?_ ?_).trans ?_ · rintro σ - h2 obtain ⟨x, h3⟩ := not_forall.1 (mt Equiv.ext h2) - convert mul_zero (ε σ) + convert! mul_zero (ε σ) apply Finset.prod_eq_zero (mem_univ x) exact if_neg h3 · simp @@ -111,7 +111,7 @@ theorem det_unique {n : Type*} [Unique n] [DecidableEq n] [Fintype n] (A : Matri theorem det_eq_elem_of_subsingleton [Subsingleton n] (A : Matrix n n R) (k : n) : det A = A k k := by have := uniqueOfSubsingleton k - convert det_unique A + convert! det_unique A theorem det_eq_elem_of_card_eq_one {A : Matrix n n R} (h : Fintype.card n = 1) (k : n) : det A = A k k := @@ -426,7 +426,7 @@ theorem det_updateRow_sum_aux (M : Matrix n n R) {j : n} (s : Finset n) (hj : j multiplied by the coefficient of that row. -/ theorem det_updateRow_sum (A : Matrix n n R) (j : n) (c : n → R) : (A.updateRow j (∑ k, (c k) • A k)).det = (c j) • A.det := by - convert det_updateRow_sum_aux A (Finset.univ.erase j) (Finset.univ.notMem_erase j) c (c j) + convert! det_updateRow_sum_aux A (Finset.univ.erase j) (Finset.univ.notMem_erase j) c (c j) rw [← Finset.univ.add_sum_erase _ (Finset.mem_univ j)] /-- If we replace a column of a matrix by a linear combination of its columns, then the determinant @@ -434,7 +434,7 @@ is multiplied by the coefficient of that column. -/ theorem det_updateCol_sum (A : Matrix n n R) (j : n) (c : n → R) : (A.updateCol j (fun k ↦ ∑ i, (c i) • A k i)).det = (c j) • A.det := by rw [← det_transpose, ← updateRow_transpose, ← det_transpose A] - convert det_updateRow_sum A.transpose j c + convert! det_updateRow_sum A.transpose j c simp only [smul_eq_mul, Finset.sum_apply, Pi.smul_apply, transpose_apply] section DetEq @@ -674,8 +674,9 @@ theorem det_fromBlocks_zero₂₁ (A : Matrix m m R) (B : Matrix m n R) (D : Mat (Matrix.fromBlocks A B 0 D).det = A.det * D.det := by classical simp_rw [det_apply'] - convert Eq.symm <| - sum_subset (M := R) (subset_univ ((sumCongrHom m n).range : Set (Perm (m ⊕ n))).toFinset) ?_ + convert! + Eq.symm <| + sum_subset (M := R) (subset_univ ((sumCongrHom m n).range : Set (Perm (m ⊕ n))).toFinset) ?_ · simp_rw [sum_mul_sum, ← sum_product', univ_product_univ] refine sum_nbij (fun σ ↦ σ.fst.sumCongr σ.snd) ?_ ?_ ?_ ?_ · intro σ₁₂ _ diff --git a/Mathlib/LinearAlgebra/Matrix/GeneralLinearGroup/Card.lean b/Mathlib/LinearAlgebra/Matrix/GeneralLinearGroup/Card.lean index 64ef4382b6bf6c..cb2b6a3bc39145 100644 --- a/Mathlib/LinearAlgebra/Matrix/GeneralLinearGroup/Card.lean +++ b/Mathlib/LinearAlgebra/Matrix/GeneralLinearGroup/Card.lean @@ -55,7 +55,7 @@ theorem card_linearIndependent {k : ℕ} (hk : k ≤ n) : simp only [SetLike.coe_sort_coe, finrank_span_eq_card s.2, card_fin] rw [Module.card_eq_pow_finrank (K := K)] simp [card_congr (equiv_linearIndependent k), sum_congr _ _ this, ih (Nat.le_of_succ_le hk), - mul_comm, Fin.prod_univ_succAbove _ (Fin.last k)] + mul_comm, Fin.prod_univ_succAbove _ (Fin.last k), -Set.fintypeCard_eq_ncard] end LinearIndependent diff --git a/Mathlib/LinearAlgebra/Matrix/Hermitian.lean b/Mathlib/LinearAlgebra/Matrix/Hermitian.lean index 65230e1edd6eb0..3721c87c14eb76 100644 --- a/Mathlib/LinearAlgebra/Matrix/Hermitian.lean +++ b/Mathlib/LinearAlgebra/Matrix/Hermitian.lean @@ -396,7 +396,7 @@ theorem fromBlocks₂₂ [Fintype n] [DecidableEq n] (A : Matrix m m α) (B : Ma (Matrix.fromBlocks A B Bᴴ D).IsHermitian ↔ (A - B * D⁻¹ * Bᴴ).IsHermitian := by rw [← isHermitian_submatrix_equiv (Equiv.sumComm n m), Equiv.sumComm_apply, fromBlocks_submatrix_sum_swap_sum_swap] - convert IsHermitian.fromBlocks₁₁ _ _ hD <;> simp + convert! IsHermitian.fromBlocks₁₁ _ _ hD <;> simp end IsHermitian diff --git a/Mathlib/LinearAlgebra/Matrix/Ideal.lean b/Mathlib/LinearAlgebra/Matrix/Ideal.lean index bc2193310aff7d..913dd83e452c2e 100644 --- a/Mathlib/LinearAlgebra/Matrix/Ideal.lean +++ b/Mathlib/LinearAlgebra/Matrix/Ideal.lean @@ -96,7 +96,7 @@ theorem single_mem_jacobson_matrix (I : Ideal R) : obtain rfl | qj := eq_or_ne q j · by_cases iq : i = q · simp [iq, N, zMx, single, mul_apply, sum_apply, ite_and, sub_mul] - · convert I.mul_mem_left (-M i p * x) zMx + · convert! I.mul_mem_left (-M i p * x) zMx simp [iq, N, single, mul_apply, sum_apply, ite_and, sub_mul] simp [sub_add, mul_add, mul_sub, mul_assoc] · simp [N, qj, sum_apply, mul_apply] diff --git a/Mathlib/LinearAlgebra/Matrix/IsDiag.lean b/Mathlib/LinearAlgebra/Matrix/IsDiag.lean index 30b3efdc4a4040..e06d2a106c838a 100644 --- a/Mathlib/LinearAlgebra/Matrix/IsDiag.lean +++ b/Mathlib/LinearAlgebra/Matrix/IsDiag.lean @@ -116,7 +116,7 @@ theorem IsDiag.conjTranspose [NonUnitalNonAssocSemiring α] [StarRing α] {A : M theorem isDiag_conjTranspose_iff [NonUnitalNonAssocSemiring α] [StarRing α] {A : Matrix n n α} : Aᴴ.IsDiag ↔ A.IsDiag := ⟨fun ha => by - convert ha.conjTranspose + convert! ha.conjTranspose simp, IsDiag.conjTranspose⟩ theorem IsDiag.submatrix [Zero α] {A : Matrix n n α} (ha : A.IsDiag) {f : m → n} @@ -156,7 +156,7 @@ theorem isDiag_fromBlocks_iff [Zero α] {A : Matrix m m α} {B : Matrix m n α} · exact h Sum.inr_ne_inl · exact h (Sum.inr_injective.ne hij) · rintro ⟨ha, hb, hc, hd⟩ - convert IsDiag.fromBlocks ha hd + convert! IsDiag.fromBlocks ha hd /-- A symmetric block matrix `A.fromBlocks B C D` is diagonal if `A` and `D` are diagonal and `B` is `0`. -/ diff --git a/Mathlib/LinearAlgebra/Matrix/Nondegenerate.lean b/Mathlib/LinearAlgebra/Matrix/Nondegenerate.lean index b59f85df973763..b83592c1b37c2a 100644 --- a/Mathlib/LinearAlgebra/Matrix/Nondegenerate.lean +++ b/Mathlib/LinearAlgebra/Matrix/Nondegenerate.lean @@ -50,11 +50,11 @@ variable {m n R A : Type*} [CommRing R] [Fintype m] [Fintype n] [CommRing A] [Is lemma separatingRight_def : M.SeparatingRight ↔ (∀ w, (∀ v, v ⬝ᵥ M *ᵥ w = 0) → w = 0) := by refine forall_congr' fun w ↦ ⟨fun hM hw ↦ hM ?_, fun hM hw ↦ hM ?_⟩ <;> - convert hw + convert! hw lemma separatingLeft_def : M.SeparatingLeft ↔ (∀ v, (∀ w, v ⬝ᵥ M *ᵥ w = 0) → v = 0) := by refine forall_congr' fun v ↦ ⟨fun hM hv ↦ hM ?_, fun hM hv ↦ hM ?_⟩ <;> - convert hv + convert! hv lemma nondegenerate_def : M.Nondegenerate ↔ (∀ v, (∀ w, v ⬝ᵥ M *ᵥ w = 0) → v = 0) ∧ (∀ w, (∀ v, v ⬝ᵥ M *ᵥ w = 0) → w = 0) := by diff --git a/Mathlib/LinearAlgebra/Matrix/NonsingularInverse.lean b/Mathlib/LinearAlgebra/Matrix/NonsingularInverse.lean index a8ac58e14b0fe7..a87d7dce5146b7 100644 --- a/Mathlib/LinearAlgebra/Matrix/NonsingularInverse.lean +++ b/Mathlib/LinearAlgebra/Matrix/NonsingularInverse.lean @@ -85,7 +85,7 @@ def invertibleOfDetInvertible [Invertible A.det] : Invertible A where theorem invOf_eq [Invertible A.det] [Invertible A] : ⅟A = ⅟A.det • A.adjugate := by letI := invertibleOfDetInvertible A - convert (rfl : ⅟A = _) + convert! (rfl : ⅟A = _) /-- `A.det` is invertible if `A` has a left inverse. -/ @[implicit_reducible] @@ -108,7 +108,7 @@ def detInvertibleOfInvertible [Invertible A] : Invertible A.det := theorem det_invOf [Invertible A] [Invertible A.det] : (⅟A).det = ⅟A.det := by letI := detInvertibleOfInvertible A - convert (rfl : _ = ⅟A.det) + convert! (rfl : _ = ⅟A.det) /-- Together `Matrix.detInvertibleOfInvertible` and `Matrix.invertibleOfDetInvertible` form an equivalence, although both sides of the equiv are subsingleton anyway. -/ diff --git a/Mathlib/LinearAlgebra/Matrix/Permanent.lean b/Mathlib/LinearAlgebra/Matrix/Permanent.lean index e4ab202d2fd799..f83a309ee18f62 100644 --- a/Mathlib/LinearAlgebra/Matrix/Permanent.lean +++ b/Mathlib/LinearAlgebra/Matrix/Permanent.lean @@ -61,7 +61,7 @@ theorem permanent_unique {n : Type*} [Unique n] [DecidableEq n] [Fintype n] (A : theorem permanent_eq_elem_of_subsingleton [Subsingleton n] (A : Matrix n n R) (k : n) : permanent A = A k k := by have := uniqueOfSubsingleton k - convert permanent_unique A + convert! permanent_unique A theorem permanent_eq_elem_of_card_eq_one {A : Matrix n n R} (h : card n = 1) (k : n) : permanent A = A k k := diff --git a/Mathlib/LinearAlgebra/Matrix/Polynomial.lean b/Mathlib/LinearAlgebra/Matrix/Polynomial.lean index 31feb1f51db6cb..10d5c80ecfa7ae 100644 --- a/Mathlib/LinearAlgebra/Matrix/Polynomial.lean +++ b/Mathlib/LinearAlgebra/Matrix/Polynomial.lean @@ -64,7 +64,7 @@ theorem coeff_det_X_add_C_zero (A B : Matrix n n α) : rw [det_apply, finsetSum_coeff, det_apply] refine Finset.sum_congr rfl ?_ rintro g - - convert coeff_smul (R := α) (sign g) _ 0 + convert! coeff_smul (R := α) (sign g) _ 0 rw [coeff_zero_prod] refine Finset.prod_congr rfl ?_ simp @@ -75,9 +75,9 @@ theorem coeff_det_X_add_C_card (A B : Matrix n n α) : refine Finset.sum_congr rfl ?_ simp only [Finset.mem_univ, forall_true_left] intro g - convert coeff_smul (R := α) (sign g) _ _ + convert! coeff_smul (R := α) (sign g) _ _ rw [← mul_one (Fintype.card n)] - convert (coeff_prod_of_natDegree_le (R := α) _ _ _ _).symm + convert! (coeff_prod_of_natDegree_le (R := α) _ _ _ _).symm · simp [coeff_C] · rintro p - dsimp only [add_apply, smul_apply, map_apply, smul_eq_mul] diff --git a/Mathlib/LinearAlgebra/Matrix/PosDef.lean b/Mathlib/LinearAlgebra/Matrix/PosDef.lean index be0ab0acc9ca10..82b66009ab008c 100644 --- a/Mathlib/LinearAlgebra/Matrix/PosDef.lean +++ b/Mathlib/LinearAlgebra/Matrix/PosDef.lean @@ -568,7 +568,7 @@ theorem fromBlocks₂₂ [DecidableEq n] (A : Matrix m m R') (fromBlocks A B Bᴴ D).PosSemidef ↔ (A - B * D⁻¹ * Bᴴ).PosSemidef := by rw [← posSemidef_submatrix_equiv (Equiv.sumComm n m), Equiv.sumComm_apply, fromBlocks_submatrix_sum_swap_sum_swap] - convert fromBlocks₁₁ Bᴴ A hD <;> simp + convert! fromBlocks₁₁ Bᴴ A hD <;> simp end SchurComplement diff --git a/Mathlib/LinearAlgebra/Matrix/Rank.lean b/Mathlib/LinearAlgebra/Matrix/Rank.lean index 65cc0e496a4db4..5ea998e9342d3b 100644 --- a/Mathlib/LinearAlgebra/Matrix/Rank.lean +++ b/Mathlib/LinearAlgebra/Matrix/Rank.lean @@ -130,7 +130,7 @@ theorem rank_subsingleton [Subsingleton R] (A : Matrix m n R) : A.rank = 1 := theorem cRank_one [Nontrivial R] [DecidableEq m] : (cRank (1 : Matrix m m R)) = lift.{uR} #m := by have h : LinearIndependent R (1 : Matrix m m R)ᵀ := by - convert Pi.linearIndependent_single_one m R + convert! Pi.linearIndependent_single_one m R simp [funext_iff, Matrix.one_eq_pi_single] rw [cRank, rank_span h, ← lift_umax, ← Cardinal.mk_range_eq_of_injective h.injective, lift_id'] @@ -218,7 +218,7 @@ lemma rank_mul_eq_right_of_isUnit_det [Fintype m] [DecidableEq m] (A * B).rank = B.rank := by let b : Basis m R (m → R) := Pi.basisFun R m replace hA : IsUnit (LinearMap.toMatrix b b A.mulVecLin).det := by - convert hA; rw [← LinearEquiv.eq_symm_apply]; rfl + convert! hA; rw [← LinearEquiv.eq_symm_apply]; rfl have hAB : mulVecLin (A * B) = (LinearEquiv.ofIsUnitDet hA).comp (mulVecLin B) := by ext; simp rw [rank, rank, hAB, LinearMap.range_comp, LinearEquiv.finrank_map_eq] @@ -340,7 +340,7 @@ theorem cRank_diagonal [DecidableEq m] (w : m → R) : have h : LinearIndependent R w' := by have hli' := Pi.linearIndependent_single_of_ne_zero (R := R) (v := fun i : m ↦ if w i = 0 then (1 : R) else w i) (by simp [ite_eq_iff']) - convert hli'.comp Subtype.val Subtype.val_injective + convert! hli'.comp Subtype.val Subtype.val_injective ext ⟨j, hj⟩ k simp [w', diagonal, hj, Pi.single_apply, eq_comm] have hrw : insert 0 (range (diagonal w)ᵀ) = insert 0 (range w') := by diff --git a/Mathlib/LinearAlgebra/Matrix/SchurComplement.lean b/Mathlib/LinearAlgebra/Matrix/SchurComplement.lean index 8e12547a8067d1..6d108691f2d1be 100644 --- a/Mathlib/LinearAlgebra/Matrix/SchurComplement.lean +++ b/Mathlib/LinearAlgebra/Matrix/SchurComplement.lean @@ -97,13 +97,13 @@ theorem invOf_fromBlocks_zero₂₁_eq (A : Matrix m m α) (B : Matrix m n α) ( [Invertible A] [Invertible D] [Invertible (fromBlocks A B 0 D)] : ⅟(fromBlocks A B 0 D) = fromBlocks (⅟A) (-(⅟A * B * ⅟D)) 0 (⅟D) := by letI := fromBlocksZero₂₁Invertible A B D - convert (rfl : ⅟(fromBlocks A B 0 D) = _) + convert! (rfl : ⅟(fromBlocks A B 0 D) = _) theorem invOf_fromBlocks_zero₁₂_eq (A : Matrix m m α) (C : Matrix n m α) (D : Matrix n n α) [Invertible A] [Invertible D] [Invertible (fromBlocks A 0 C D)] : ⅟(fromBlocks A 0 C D) = fromBlocks (⅟A) 0 (-(⅟D * C * ⅟A)) (⅟D) := by letI := fromBlocksZero₁₂Invertible A C D - convert (rfl : ⅟(fromBlocks A 0 C D) = _) + convert! (rfl : ⅟(fromBlocks A 0 C D) = _) /-- Both diagonal entries of an invertible upper-block-triangular matrix are invertible (by reading off the diagonal entries of the inverse). -/ @@ -234,8 +234,10 @@ def fromBlocks₂₂Invertible (A : Matrix m m α) (B : Matrix m n α) (C : Matr (D : Matrix n n α) [Invertible D] [Invertible (A - B * ⅟D * C)] : Invertible (fromBlocks A B C D) := by -- factor `fromBlocks` via `fromBlocks_eq_of_invertible₂₂`, and state the inverse we expect - convert Invertible.copy' _ _ (fromBlocks (⅟(A - B * ⅟D * C)) (-(⅟(A - B * ⅟D * C) * B * ⅟D)) - (-(⅟D * C * ⅟(A - B * ⅟D * C))) (⅟D + ⅟D * C * ⅟(A - B * ⅟D * C) * B * ⅟D)) + convert! + Invertible.copy' _ _ + (fromBlocks (⅟(A - B * ⅟D * C)) (-(⅟(A - B * ⅟D * C) * B * ⅟D)) + (-(⅟D * C * ⅟(A - B * ⅟D * C))) (⅟D + ⅟D * C * ⅟(A - B * ⅟D * C) * B * ⅟D)) (fromBlocks_eq_of_invertible₂₂ _ _ _ _) _ · -- the product is invertible because all the factors are letI : Invertible (1 : Matrix n n α) := invertibleOne @@ -279,7 +281,7 @@ theorem invOf_fromBlocks₂₂_eq (A : Matrix m m α) (B : Matrix m n α) (C : M fromBlocks (⅟(A - B * ⅟D * C)) (-(⅟(A - B * ⅟D * C) * B * ⅟D)) (-(⅟D * C * ⅟(A - B * ⅟D * C))) (⅟D + ⅟D * C * ⅟(A - B * ⅟D * C) * B * ⅟D) := by letI := fromBlocks₂₂Invertible A B C D - convert (rfl : ⅟(fromBlocks A B C D) = _) + convert! (rfl : ⅟(fromBlocks A B C D) = _) theorem invOf_fromBlocks₁₁_eq (A : Matrix m m α) (B : Matrix m n α) (C : Matrix n m α) (D : Matrix n n α) [Invertible A] [Invertible (D - C * ⅟A * B)] @@ -288,7 +290,7 @@ theorem invOf_fromBlocks₁₁_eq (A : Matrix m m α) (B : Matrix m n α) (C : M fromBlocks (⅟A + ⅟A * B * ⅟(D - C * ⅟A * B) * C * ⅟A) (-(⅟A * B * ⅟(D - C * ⅟A * B))) (-(⅟(D - C * ⅟A * B) * C * ⅟A)) (⅟(D - C * ⅟A * B)) := by letI := fromBlocks₁₁Invertible A B C D - convert (rfl : ⅟(fromBlocks A B C D) = _) + convert! (rfl : ⅟(fromBlocks A B C D) = _) /-- If a block matrix is invertible and so is its bottom left element, then so is the corresponding Schur complement. -/ diff --git a/Mathlib/LinearAlgebra/Matrix/SesquilinearForm.lean b/Mathlib/LinearAlgebra/Matrix/SesquilinearForm.lean index 9c348863e0b51e..6d74085bad5fd2 100644 --- a/Mathlib/LinearAlgebra/Matrix/SesquilinearForm.lean +++ b/Mathlib/LinearAlgebra/Matrix/SesquilinearForm.lean @@ -608,7 +608,7 @@ theorem Matrix.isAdjointPair_equiv (P : Matrix n n R) (h : IsUnit P) : dsimp only [Matrix.IsAdjointPair] simp only [Matrix.transpose_mul] simp only [← mul_assoc, P.transpose_nonsing_inv] - convert this using 2 + convert! this using 2 · rw [mul_assoc, mul_assoc, ← mul_assoc J] rfl · rw [mul_assoc, mul_assoc, ← mul_assoc _ _ J] diff --git a/Mathlib/LinearAlgebra/Matrix/SpecialLinearGroup.lean b/Mathlib/LinearAlgebra/Matrix/SpecialLinearGroup.lean index b836d59d6f3d8e..4e3ba67f3014bf 100644 --- a/Mathlib/LinearAlgebra/Matrix/SpecialLinearGroup.lean +++ b/Mathlib/LinearAlgebra/Matrix/SpecialLinearGroup.lean @@ -6,6 +6,7 @@ Authors: Anne Baanen, Wen Yang module public import Mathlib.Data.Fintype.Parity +public import Mathlib.Data.Matrix.Action public import Mathlib.LinearAlgebra.Matrix.Adjugate public import Mathlib.LinearAlgebra.Matrix.ToLin public import Mathlib.LinearAlgebra.Matrix.Transvection @@ -385,7 +386,7 @@ theorem fin_two_induction (P : SL(2, R) → Prop) (h : ∀ (a b c d : R) (hdet : a * d - b * c = 1), P ⟨!![a, b; c, d], by rwa [det_fin_two_of]⟩) (g : SL(2, R)) : P g := by obtain ⟨m, hm⟩ := g - convert h (m 0 0) (m 0 1) (m 1 0) (m 1 1) (by rwa [det_fin_two] at hm) + convert! h (m 0 0) (m 0 1) (m 1 0) (m 1 1) (by rwa [det_fin_two] at hm) ext i j; fin_cases i <;> fin_cases j <;> rfl theorem fin_two_exists_eq_mk_of_apply_zero_one_eq_zero {R : Type*} [Field R] (g : SL(2, R)) @@ -461,6 +462,30 @@ lemma mulVecSL {v : Fin 2 → R} (hab : IsCoprime (v 0) (v 1)) (A : SL(2, R)) : end IsCoprime +namespace Matrix + +section Action + +variable {F : Type*} [CommRing F] {ι : Type*} [DecidableEq ι] [Fintype ι] + +instance : DistribMulAction (Matrix.SpecialLinearGroup ι F) (ι → F) where + smul m v := m.1 • v + smul_zero _ := smul_zero (M := Matrix ι ι F) _ + smul_add _ := smul_add (M := Matrix ι ι F) _ + one_smul _ := one_smul (M := Matrix ι ι F) _ + mul_smul _ _ _ := SemigroupAction.mul_smul (α := Matrix ι ι F) _ _ _ + +instance : SMulCommClass (Matrix.SpecialLinearGroup ι F) F (ι → F) where + smul_comm m k v := show m.1 • k • v = k • m.1 • v from smul_comm _ _ _ + +protected lemma SpecialLinearGroup.smul_def + (m : Matrix.SpecialLinearGroup ι F) (v : ι → F) : + m • v = m.1 • v := rfl + +end Action + +end Matrix + namespace ModularGroup open MatrixGroups diff --git a/Mathlib/LinearAlgebra/Matrix/ToLin.lean b/Mathlib/LinearAlgebra/Matrix/ToLin.lean index da15e467ea8cd9..6d0658bc198844 100644 --- a/Mathlib/LinearAlgebra/Matrix/ToLin.lean +++ b/Mathlib/LinearAlgebra/Matrix/ToLin.lean @@ -882,7 +882,7 @@ theorem LinearMap.toMatrixAlgEquiv_mul (f g : M₁ →ₗ[R] M₁) : theorem Matrix.toLinAlgEquiv_mul (A B : Matrix n n R) : Matrix.toLinAlgEquiv v₁ (A * B) = (Matrix.toLinAlgEquiv v₁ A).comp (Matrix.toLinAlgEquiv v₁ B) := by - convert Matrix.toLin_mul v₁ v₁ v₁ A B + convert! Matrix.toLin_mul v₁ v₁ v₁ A B @[simp] theorem LinearMap.isUnit_toMatrix_iff {f : M₁ →ₗ[R] M₁} : IsUnit (f.toMatrix v₁ v₁) ↔ IsUnit f := diff --git a/Mathlib/LinearAlgebra/Matrix/Transvection.lean b/Mathlib/LinearAlgebra/Matrix/Transvection.lean index 1f1dd3dc811b3f..0da7c4a92ddc50 100644 --- a/Mathlib/LinearAlgebra/Matrix/Transvection.lean +++ b/Mathlib/LinearAlgebra/Matrix/Transvection.lean @@ -230,7 +230,7 @@ theorem _root_.Matrix.mem_range_scalar_iff_commute_transvectionStruct {M : Matri refine ⟨fun h t => ?_, mem_range_scalar_of_commute_transvectionStruct⟩ rw [mem_range_scalar_iff_commute_single] at h refine (Commute.one_left M).add_left ?_ - convert (h _ _ t.hij).smul_left t.c using 1 + convert! (h _ _ t.hij).smul_left t.c using 1 rw [smul_single, smul_eq_mul, mul_one] end diff --git a/Mathlib/LinearAlgebra/Matrix/ZPow.lean b/Mathlib/LinearAlgebra/Matrix/ZPow.lean index 61805f4ef2bc90..14df76dae44d4f 100644 --- a/Mathlib/LinearAlgebra/Matrix/ZPow.lean +++ b/Mathlib/LinearAlgebra/Matrix/ZPow.lean @@ -97,7 +97,7 @@ theorem inv_zpow (A : M) : ∀ n : ℤ, A⁻¹ ^ n = (A ^ n)⁻¹ @[simp] theorem zpow_neg_one (A : M) : A ^ (-1 : ℤ) = A⁻¹ := by - convert DivInvMonoid.zpow_neg' 0 A + convert! DivInvMonoid.zpow_neg' 0 A simp only [zpow_one, Int.ofNat_zero, Int.natCast_succ, zpow_eq_pow, zero_add] @[simp] diff --git a/Mathlib/LinearAlgebra/Multilinear/Basic.lean b/Mathlib/LinearAlgebra/Multilinear/Basic.lean index 866b95e89382c1..a5c8f4832b0fef 100644 --- a/Mathlib/LinearAlgebra/Multilinear/Basic.lean +++ b/Mathlib/LinearAlgebra/Multilinear/Basic.lean @@ -121,8 +121,8 @@ def mk' [DecidableEq ι] (f : (∀ i, M₁ i) → M₂) f (update m i (c • x)) = c • f (update m i x) := by aesop) : MultilinearMap R M₁ M₂ where toFun := f - map_update_add' m i x y := by convert h₁ m i x y - map_update_smul' m i c x := by convert h₂ m i c x + map_update_add' m i x y := by convert! h₁ m i x y + map_update_smul' m i c x := by convert! h₂ m i c x @[simp] theorem toFun_eq_coe : f.toFun = ⇑f := @@ -1108,7 +1108,7 @@ sending a multilinear map `g` to `g (f₁ ⬝ , ..., fₙ ⬝ )` is linear in `g change (g fun j ↦ update f i (f₁ + f₂) j <| x j) = (g fun j ↦ update f i f₁ j <| x j) + g fun j ↦ update f i f₂ j (x j) let c : Π (i : ι), (M₁ i →ₗ[R] M₁' i) → M₁' i := fun i f ↦ f (x i) - convert g.map_update_add (fun j ↦ f j (x j)) i (f₁ (x i)) (f₂ (x i)) with j j j + convert! g.map_update_add (fun j ↦ f j (x j)) i (f₁ (x i)) (f₂ (x i)) with j j j · exact Function.apply_update c f i (f₁ + f₂) j · exact Function.apply_update c f i f₁ j · exact Function.apply_update c f i f₂ j @@ -1117,7 +1117,7 @@ sending a multilinear map `g` to `g (f₁ ⬝ , ..., fₙ ⬝ )` is linear in `g ext g x change (g fun j ↦ update f i (a • f₀) j <| x j) = a • g fun j ↦ update f i f₀ j (x j) let c : Π (i : ι), (M₁ i →ₗ[R] M₁' i) → M₁' i := fun i f ↦ f (x i) - convert g.map_update_smul (fun j ↦ f j (x j)) i a (f₀ (x i)) with j j j + convert! g.map_update_smul (fun j ↦ f j (x j)) i a (f₀ (x i)) with j j j · exact Function.apply_update c f i (a • f₀) j · exact Function.apply_update c f i f₀ j diff --git a/Mathlib/LinearAlgebra/Multilinear/DirectSum.lean b/Mathlib/LinearAlgebra/Multilinear/DirectSum.lean index 152d8a8ef0dc48..3215af10f7219b 100644 --- a/Mathlib/LinearAlgebra/Multilinear/DirectSum.lean +++ b/Mathlib/LinearAlgebra/Multilinear/DirectSum.lean @@ -59,7 +59,7 @@ theorem fromDirectSumEquiv_lof [Finite ι] [(i : ι) → DecidableEq (κ i)] fromDirectSumEquiv f (fun i => lof R _ _ _ (x i)) = f p x := by haveI : Fintype ι := Fintype.ofFinite ι rw [fromDirectSumEquiv, ← fromDFinsuppEquiv_single] - convert rfl + convert! rfl set_option backward.isDefEq.respectTransparency false in /-- Prefer using `fromDirectSumEquiv_lof` where possible. -/ @@ -70,7 +70,7 @@ theorem fromDirectSumEquiv_apply [Fintype ι] [(i : ι) → DecidableEq (κ i)] fromDirectSumEquiv f x = ∑ p ∈ Fintype.piFinset (fun i ↦ (x i).support), f p (fun i ↦ x i (p i)) := by rw [fromDirectSumEquiv, ← fromDFinsuppEquiv_apply] - convert rfl + convert! rfl set_option backward.isDefEq.respectTransparency false in @[simp] @@ -80,6 +80,6 @@ theorem fromDirectSumEquiv_symm_apply [Finite ι] [(i : ι) → DecidableEq (κ fromDirectSumEquiv.symm f p = f.compLinearMap (fun i ↦ DirectSum.lof _ _ _ (p i)) := by haveI : Fintype ι := Fintype.ofFinite ι simp_rw [fromDirectSumEquiv, DirectSum.lof, ← fromDFinsuppEquiv_symm_apply] - convert rfl + convert! rfl end MultilinearMap diff --git a/Mathlib/LinearAlgebra/Orientation.lean b/Mathlib/LinearAlgebra/Orientation.lean index e4cad6ec900673..197742e8649f8b 100644 --- a/Mathlib/LinearAlgebra/Orientation.lean +++ b/Mathlib/LinearAlgebra/Orientation.lean @@ -213,7 +213,7 @@ theorem eq_or_eq_neg_of_isEmpty [IsEmpty ι] (o : Orientation R M ι) : intro h set f : (M [⋀^ι]→ₗ[R] R) ≃ₗ[R] R := AlternatingMap.constLinearEquivOfIsEmpty.symm have H : LinearIndependent R ![f x, 1] := by - convert h.map' f.toLinearMap f.ker + convert! h.map' f.toLinearMap f.ker ext i fin_cases i <;> simp [f] rw [linearIndependent_iff'] at H diff --git a/Mathlib/LinearAlgebra/PerfectPairing/Basic.lean b/Mathlib/LinearAlgebra/PerfectPairing/Basic.lean index baa0a277f9aa37..7ba478a8c4f8f8 100644 --- a/Mathlib/LinearAlgebra/PerfectPairing/Basic.lean +++ b/Mathlib/LinearAlgebra/PerfectPairing/Basic.lean @@ -71,7 +71,7 @@ noncomputable def toPerfPair : M ≃ₗ[R] Dual R N := include p in lemma _root_.Module.IsReflexive.of_isPerfPair : IsReflexive R M where bijective_dual_eval' := by - convert (p.toPerfPair.trans p.flip.toPerfPair.dualMap.symm).bijective + convert! (p.toPerfPair.trans p.flip.toPerfPair.dualMap.symm).bijective ext x f simp diff --git a/Mathlib/LinearAlgebra/Pi.lean b/Mathlib/LinearAlgebra/Pi.lean index 71074f57f6e244..177c793ab94b68 100644 --- a/Mathlib/LinearAlgebra/Pi.lean +++ b/Mathlib/LinearAlgebra/Pi.lean @@ -216,7 +216,7 @@ theorem iSup_range_single_eq_iInf_ker_proj {I J : Set ι} (hd : Disjoint I J) theorem iSup_range_single [Finite ι] : ⨆ i, range (single R φ i) = ⊤ := by cases nonempty_fintype ι - convert top_unique (iInf_emptyset.ge.trans <| iInf_ker_proj_le_iSup_range_single R φ _) + convert! top_unique (iInf_emptyset.ge.trans <| iInf_ker_proj_le_iSup_range_single R φ _) · rename_i i exact ((@iSup_pos _ _ _ fun _ => range <| single R φ i) <| Finset.mem_univ i).symm · rw [Finset.coe_univ, Set.union_empty] @@ -286,7 +286,7 @@ note [partially-applied ext lemmas]. -/ @[ext] theorem pi_ext' (h : ∀ i, f.comp (single R φ i) = g.comp (single R φ i)) : f = g := by refine pi_ext fun i x => ?_ - convert LinearMap.congr_fun (h i) x + convert! LinearMap.congr_fun (h i) x end Ext @@ -341,7 +341,7 @@ variable (R φ) theorem single_eq_pi_diag (i : ι) : single R φ i = pi (diag i) := by ext x j - convert (update_apply 0 x i j _).symm + convert! (update_apply 0 x i j _).symm rfl theorem ker_single (i : ι) : ker (single R φ i) = ⊥ := diff --git a/Mathlib/LinearAlgebra/PiTensorProduct.lean b/Mathlib/LinearAlgebra/PiTensorProduct.lean index b5f7840fcb52b0..01f6e08a3a1838 100644 --- a/Mathlib/LinearAlgebra/PiTensorProduct.lean +++ b/Mathlib/LinearAlgebra/PiTensorProduct.lean @@ -199,7 +199,7 @@ protected theorem induction_on' {motive : (⨂[R] i, s i) → Prop} (z : ⨂[R] refine AddCon.induction_on z fun x ↦ FreeAddMonoid.recOn x C0 ?_ simp_rw [AddCon.coe_add] refine fun f y ih ↦ add _ _ ?_ ih - convert tprodCoeff f.1 f.2 + convert! tprodCoeff f.1 f.2 section DistribMulAction diff --git a/Mathlib/LinearAlgebra/PiTensorProduct/DirectSum.lean b/Mathlib/LinearAlgebra/PiTensorProduct/DirectSum.lean index 5144396ecb41c8..7741c57f651ac2 100644 --- a/Mathlib/LinearAlgebra/PiTensorProduct/DirectSum.lean +++ b/Mathlib/LinearAlgebra/PiTensorProduct/DirectSum.lean @@ -44,7 +44,7 @@ theorem ofDirectSumEquiv_tprod_lof [Fintype ι] [(i : ι) → DecidableEq (κ i) DirectSum.lof R _ _ p (⨂ₜ[R] i, x i) := by classical rw [ofDirectSumEquiv] - convert ofDFinsuppEquiv_tprod_single p x + convert! ofDFinsuppEquiv_tprod_single p x set_option backward.isDefEq.respectTransparency false in @[simp] @@ -54,13 +54,13 @@ theorem ofDirectSumEquiv_symm_lof_tprod [Fintype ι] [(i : ι) → DecidableEq ( (⨂ₜ[R] i, DirectSum.lof R _ _ (p i) (x i)) := by classical rw [ofDirectSumEquiv] - convert ofDFinsuppEquiv_symm_single_tprod p x + convert! ofDFinsuppEquiv_symm_single_tprod p x @[simp] theorem ofDirectSumEquiv_tprod_apply [Finite ι] (x : Π i, ⨁ j, M i j) (p : Π i, κ i) : ofDirectSumEquiv (tprod R x) p = ⨂ₜ[R] i, x i (p i) := by have : Fintype ι := Fintype.ofFinite ι - convert ofDFinsuppEquiv_tprod_apply _ _ + convert! ofDFinsuppEquiv_tprod_apply _ _ end PiTensorProduct diff --git a/Mathlib/LinearAlgebra/PiTensorProduct/Dual.lean b/Mathlib/LinearAlgebra/PiTensorProduct/Dual.lean index 29511070ae623a..817f50080c1b67 100644 --- a/Mathlib/LinearAlgebra/PiTensorProduct/Dual.lean +++ b/Mathlib/LinearAlgebra/PiTensorProduct/Dual.lean @@ -75,7 +75,7 @@ theorem dualDistribInvOfBasis_apply [Fintype ι] [∀ i, Fintype (κ i)] (b : Π simp only [dualDistribInvOfBasis, Basis.coe_dualBasis, ringLmapEquivSelf_symm_apply, coe_sum, coe_comp, coe_smulRight, End.one_apply, Finset.sum_apply, Function.comp_apply, applyₗ_apply_apply] - convert rfl + convert! rfl theorem dualDistrib_dualDistribInvOfBasis_left_inverse [Finite ι] [∀ i, Finite (κ i)] (b : Π i, Basis (κ i) R (M i)) : diff --git a/Mathlib/LinearAlgebra/Projection.lean b/Mathlib/LinearAlgebra/Projection.lean index d1ceefce5eb79a..0bde1432f96dad 100644 --- a/Mathlib/LinearAlgebra/Projection.lean +++ b/Mathlib/LinearAlgebra/Projection.lean @@ -645,7 +645,7 @@ open LinearMap in its range along its kernel. -/ theorem IsIdempotentElem.eq_projection {T : E →ₗ[R] E} (hT : IsIdempotentElem T) : T = T.range.projection T.ker hT.isCompl := by - convert ofIsCompl_subtype_zero_eq hT.isCompl + convert! ofIsCompl_subtype_zero_eq hT.isCompl exact ofIsCompl_eq _ (by simp [hT.isProj_range.map_id]) (by simp) |>.symm open LinearMap in diff --git a/Mathlib/LinearAlgebra/Projectivization/Action.lean b/Mathlib/LinearAlgebra/Projectivization/Action.lean index df4f85e820e325..d51fd56fb02048 100644 --- a/Mathlib/LinearAlgebra/Projectivization/Action.lean +++ b/Mathlib/LinearAlgebra/Projectivization/Action.lean @@ -50,6 +50,11 @@ lemma generalLinearGroup_smul_def (g : LinearMap.GeneralLinearGroup K V) (x : g • x = x.map g.toLinearEquiv.toLinearMap g.toLinearEquiv.injective := by rfl +lemma matrixSpecialLinearGroup_smul_def {ι F : Type*} [Fintype ι] [DecidableEq ι] [Field F] + (g : Matrix.SpecialLinearGroup ι F) (x : ℙ F (ι → F)) : + g • x = g.toLin'_equiv • x := by + rfl + @[simp] lemma smul_mk (g : G) {v : V} (hv : v ≠ 0) : g • mk K v hv = mk K (g • v) ((smul_ne_zero_iff_ne g).mpr hv) := @@ -165,6 +170,19 @@ instance specialLinearGroup_is_two_pretransitive : instance : IsPreprimitive (SpecialLinearGroup K V) (ℙ K V) := isPreprimitive_of_is_two_pretransitive inferInstance +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +instance : IsMultiplyPretransitive (Matrix.SpecialLinearGroup ι K) (ℙ K (ι → K)) 2 := + let φ : SpecialLinearGroup K (ι → K) →* Matrix.SpecialLinearGroup ι K := + Matrix.SpecialLinearGroup.toLin'_equiv.symm.toMonoidHom + let f : ℙ K (ι → K) →ₑ[φ] ℙ K (ι → K) := + { toFun := id + map_smul' g D := by simp [φ, matrixSpecialLinearGroup_smul_def]} + IsPretransitive.of_embedding (f := f) Function.surjective_id + +instance prePrimitive_SL : IsPreprimitive (Matrix.SpecialLinearGroup ι K) (ℙ K (ι → K)) := + isPreprimitive_of_is_two_pretransitive inferInstance + end Field end Projectivization diff --git a/Mathlib/LinearAlgebra/Projectivization/Collinear.lean b/Mathlib/LinearAlgebra/Projectivization/Collinear.lean new file mode 100644 index 00000000000000..37f75151578615 --- /dev/null +++ b/Mathlib/LinearAlgebra/Projectivization/Collinear.lean @@ -0,0 +1,121 @@ +/- +Copyright (c) 2026 Yunzhou Xie. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Edison Xie, Bhavik Mehta +-/ +module + +public import Mathlib.LinearAlgebra.Projectivization.Subspace +public import Mathlib.LinearAlgebra.Projectivization.Independence +public import Mathlib.LinearAlgebra.FiniteDimensional.Lemmas +public import Mathlib.LinearAlgebra.FiniteDimensional.Basic + +/-! + +# Collinearity in Projective Space + +This file defines collinearity of points in projective space and proves +the uniqueness of the line through two distinct points. + +## Main Results + +* `Projectivization.IsCollinear`: A family of points in projective space is collinear if there + exists a submodule of dimension at most 2 containing all points in the family. +* `Projectivization.line_unique`: Given two distinct points in projective space, there is a unique + line (submodule of dimension 2) containing both points. + +## Tags +Projective space, collinearity, projective geometry + +-/ + +@[expose] public section + +variable {K V : Type*} [DivisionRing K] [AddCommGroup V] [Module K V] + (M : Submodule K V) (S : Set (Projectivization K V)) + +namespace Projectivization + +/-- If there exists a submodule of dimension at most `2` containing all points in + `S`, then `S` is collinear. The finite-dimensionality is required so that this notion is + meaningful even when `V` is infinite-dimensional. -/ +def IsCollinear : Prop := ∃ (M : Subspace K V), Module.Finite K M.submodule ∧ + Module.finrank K M.submodule ≤ 2 ∧ S ⊆ M + +lemma IsCollinear_iff : IsCollinear S ↔ ∃ (M : Subspace K V), Module.Finite K M.submodule ∧ + Module.finrank K M.submodule ≤ 2 ∧ S ⊆ M := Iff.rfl + +lemma IsCollinear_iff_rank : + IsCollinear S ↔ + ∃ (M : Subspace K V), Module.rank K M.submodule ≤ 2 ∧ S ⊆ M := by + rw [IsCollinear_iff] + refine ⟨fun ⟨M, hM1, hM2, hM3⟩ ↦ ⟨M, ?_, hM3⟩, fun ⟨M, hM1, hM2⟩ ↦ ⟨M, ?_, ?_, hM2⟩⟩ + · exact FiniteDimensional.finrank_le_iff_rank_le (K := K) (V := M.submodule) (n := 2)|>.1 hM2 + · exact Module.rank_lt_aleph0_iff.1 (hM1.trans_lt (by norm_num)) + · exact Module.finrank_le_of_rank_le hM1 + +@[simp] +lemma isCollinear_empty : IsCollinear (∅ : Set (Projectivization K V)) := by + rw [IsCollinear_iff_rank] + use ⊥ + rw [map_bot] + simp + +open scoped LinearAlgebra.Projectivization + +lemma isCollinear_subset (s t : Set (ℙ K V)) (hst : s ⊆ t) (h : IsCollinear t) : IsCollinear s := by + obtain ⟨M, hMfin, hM1, hM2⟩ := h + exact ⟨M, hMfin, hM1, hst.trans hM2⟩ + +@[simp] +lemma isCollinear_singleton' (a : ℙ K V) : IsCollinear {a} := by + induction a using ind with | h v hv => + refine ⟨(Submodule.span K {v}).projectivization, ?_, ?_, ?_⟩ + · rw [Subspace.submodule.apply_symm_apply] + exact Module.Finite.span_of_finite _ (Set.toFinite _) + · rw [Subspace.submodule.apply_symm_apply, finrank_span_singleton hv] + omega + · simp [Submodule.mem_span_of_mem] + +lemma isCollinear_subsingleton (hS : S.Subsingleton) : + IsCollinear S := by + obtain hS' | ⟨x, hx⟩ := hS.eq_empty_or_singleton <;> simp_all + +lemma isCollinear_pair (a b : ℙ K V) : IsCollinear {a, b} := by + if h : a = b then simp [h] else + induction a using Projectivization.ind with | h v hv => + induction b using Projectivization.ind with | h w hw => + rw [← ne_eq, ← independent_pair_iff_ne, independent_mk_iff_LinearIndependent] at h + refine ⟨(Submodule.span K {v, w}).projectivization, ?_, ?_, fun s hs ↦ hs.casesOn ?_ ?_⟩ + · rw [Subspace.submodule.apply_symm_apply] + exact Module.Finite.span_of_finite _ (Set.toFinite _) + · rw [Subspace.submodule.apply_symm_apply, ← Matrix.range_cons_cons_empty v w ![]] + simp [finrank_span_eq_card h] + all_goals rintro rfl; simp [Submodule.mem_span_of_mem] + +lemma isCollinear_of_card_eq_two (hS : S.ncard = 2) : IsCollinear S := by + obtain ⟨x, y, _, rfl⟩ := Set.ncard_eq_two.1 hS + exact isCollinear_pair x y + +lemma line_unique' {u v : V} (hu : u ≠ 0) (hv : v ≠ 0) (huv : LinearIndependent K ![u, v]) + (p : Submodule K V) (hp1 : Module.finrank K p = 2) + (hp2 : mk K u hu ∈ p.projectivization) (hp3 : mk K v hv ∈ p.projectivization) : + p = Submodule.span K {u, v} := by + have h1 : Submodule.span K {u, v} ≤ p := by + refine Submodule.span_le.2 fun x hx ↦ ?_ + simp only [Submodule.mk_mem_projectivization_iff] at hp2 hp3 + refine hx.casesOn ?_ ?_ <;> simp_all + have : Module.Finite K p := Module.finite_of_finrank_eq_succ hp1 + refine Submodule.eq_of_le_of_finrank_eq h1 ?_ |>.symm + rw [hp1, ← Matrix.range_cons_cons_empty _ _ ![]] + simp [finrank_span_eq_card huv] + +lemma line_unique {x y : ℙ K V} (hxy : x ≠ y) (p q : Submodule K V) (hp1 : Module.finrank K p = 2) + (hq1 : Module.finrank K q = 2) (hp2 : x ∈ p.projectivization) (hp3 : y ∈ p.projectivization) + (hq2 : x ∈ q.projectivization) (hq3 : y ∈ q.projectivization) : p = q := by + induction x using ind with | h v hv => + induction y using ind with | h w hw => + rw [← independent_pair_iff_ne, independent_mk_iff_LinearIndependent] at hxy + rw [line_unique' hv hw hxy p hp1 hp2 hp3, line_unique' hv hw hxy q hq1 hq2 hq3] + +end Projectivization diff --git a/Mathlib/LinearAlgebra/Projectivization/Independence.lean b/Mathlib/LinearAlgebra/Projectivization/Independence.lean index 0515ae6526adf5..a1212e0f4ff69d 100644 --- a/Mathlib/LinearAlgebra/Projectivization/Independence.lean +++ b/Mathlib/LinearAlgebra/Projectivization/Independence.lean @@ -25,7 +25,6 @@ ambient vector space. Similarly for the definition of dependence. ## Future Work -- Define collinearity in projective space. - Prove the axioms of a projective geometry are satisfied by the dependence relation. - Define projective linear subspaces. -/ @@ -50,10 +49,10 @@ theorem independent_iff : Independent f ↔ LinearIndependent K (Projectivizatio refine ⟨?_, fun h => ?_⟩ · rintro ⟨ff, hff, hh⟩ choose a ha using fun i : ι => exists_smul_eq_mk_rep K (ff i) (hff i) - convert hh.units_smul a + convert! hh.units_smul a ext i exact (ha i).symm - · convert Independent.mk _ _ h + · convert! Independent.mk _ _ h · simp only [mk_rep, Function.comp_apply] · intro i apply rep_nonzero @@ -83,10 +82,10 @@ theorem dependent_iff : Dependent f ↔ ¬LinearIndependent K (Projectivization. · rintro ⟨ff, hff, hh1⟩ contrapose hh1 choose a ha using fun i : ι => exists_smul_eq_mk_rep K (ff i) (hff i) - convert hh1.units_smul a⁻¹ + convert! hh1.units_smul a⁻¹ ext i simp only [← ha, inv_smul_smul, Pi.smul_apply', Pi.inv_apply, Function.comp_apply] - · convert Dependent.mk _ _ h + · convert! Dependent.mk _ _ h · simp only [mk_rep, Function.comp_apply] · exact fun i => rep_nonzero (f i) @@ -112,4 +111,11 @@ theorem dependent_pair_iff_eq (u v : ℙ K V) : Dependent ![u, v] ↔ u = v := b theorem independent_pair_iff_ne (u v : ℙ K V) : Independent ![u, v] ↔ u ≠ v := by rw [independent_iff_not_dependent, dependent_pair_iff_eq u v] +/-- Two points are independent if and only if their underlying vectors are linearly independent. -/ +lemma independent_mk_iff_LinearIndependent {u v : V} (hu : u ≠ 0) (hv : v ≠ 0) : + Independent ![mk K u hu, mk K v hv] ↔ LinearIndependent K ![u, v] := by + rw [independent_pair_iff_ne, ne_eq, mk_eq_mk_iff' K u v hu hv, linearIndependent_fin2] + simp only [Matrix.cons_val_zero, Matrix.cons_val_one] + exact ⟨fun h ↦ ⟨hv, fun a ha ↦ h ⟨a, ha⟩⟩, fun ⟨_, h⟩ ⟨a, ha⟩ ↦ h a ha⟩ + end Projectivization diff --git a/Mathlib/LinearAlgebra/Projectivization/Subspace.lean b/Mathlib/LinearAlgebra/Projectivization/Subspace.lean index b3e3267f65148b..fd909bd9cdca8e 100644 --- a/Mathlib/LinearAlgebra/Projectivization/Subspace.lean +++ b/Mathlib/LinearAlgebra/Projectivization/Subspace.lean @@ -222,7 +222,7 @@ def submodule : Projectivization.Subspace K V ≃o Submodule K V where exact s.mem_add _ _ hx₂ hy₂ hxy (hx₁ hx₂) (hy₁ hy₂) zero_mem' h := h.irrefl.elim smul_mem' c x h₁ h₂ := by - convert h₁ (right_ne_zero_of_smul h₂) using 1 + convert! h₁ (right_ne_zero_of_smul h₂) using 1 rw [Projectivization.mk_eq_mk_iff'] exact ⟨c, rfl⟩ } invFun s := @@ -247,6 +247,13 @@ theorem mem_submodule_iff (s : Projectivization.Subspace K V) {v : V} (hv : v v ∈ submodule s ↔ Projectivization.mk K v hv ∈ s := ⟨fun h => h hv, fun h _ => h⟩ +@[simp] +lemma bot_coe : ((⊥ : Subspace K V) : Set (Projectivization K V)) = ∅ := by + ext x + simp only [SetLike.mem_coe, Set.mem_empty_iff_false, iff_false] + induction x using ind with | h v hv => + rwa [← Subspace.mem_submodule_iff _ hv, Subspace.submodule.map_bot, Submodule.mem_bot] + end Subspace end Projectivization diff --git a/Mathlib/LinearAlgebra/QuadraticForm/IsometryEquiv.lean b/Mathlib/LinearAlgebra/QuadraticForm/IsometryEquiv.lean index 0e1306c2675365..34157f8ca08d6e 100644 --- a/Mathlib/LinearAlgebra/QuadraticForm/IsometryEquiv.lean +++ b/Mathlib/LinearAlgebra/QuadraticForm/IsometryEquiv.lean @@ -154,7 +154,7 @@ noncomputable def isometryEquivWeightedSumSquares (Q : QuadraticForm K V) Q.IsometryEquiv (weightedSumSquares K fun i => Q (v i)) := by let iso := Q.isometryEquivBasisRepr v refine ⟨iso, fun m => ?_⟩ - convert iso.map_app m + convert! iso.map_app m rw [basisRepr_eq_of_iIsOrtho _ _ hv₁] variable [FiniteDimensional K V] diff --git a/Mathlib/LinearAlgebra/QuadraticForm/Prod.lean b/Mathlib/LinearAlgebra/QuadraticForm/Prod.lean index 6367b68e3220c3..e257a5ded7dcb9 100644 --- a/Mathlib/LinearAlgebra/QuadraticForm/Prod.lean +++ b/Mathlib/LinearAlgebra/QuadraticForm/Prod.lean @@ -325,7 +325,7 @@ theorem nonneg_pi_iff {P} [Fintype ι] [AddCommMonoid P] [PartialOrder P] [IsOrd -- TODO: does this generalize to a useful lemma independent of `QuadraticMap`? · intro h i x classical - convert h (Pi.single i x) using 1 + convert! h (Pi.single i x) using 1 rw [Finset.sum_eq_single_of_mem i (Finset.mem_univ _) fun j _ hji => ?_, Pi.single_eq_same] rw [Pi.single_eq_of_ne hji, map_zero] · rintro h x diff --git a/Mathlib/LinearAlgebra/QuadraticForm/Real.lean b/Mathlib/LinearAlgebra/QuadraticForm/Real.lean index 9cc35276c8a4d7..1b211eea5ed143 100644 --- a/Mathlib/LinearAlgebra/QuadraticForm/Real.lean +++ b/Mathlib/LinearAlgebra/QuadraticForm/Real.lean @@ -42,8 +42,9 @@ noncomputable def isometryEquivSignWeightedSumSquares (w : ι → ℝ) : by_cases hi : w i = 0 · simp [hi] · simp only [hi, ↓reduceDIte, Units.val_mk0, u]; field_simp; simp - convert QuadraticMap.isometryEquivBasisRepr (weightedSumSquares ℝ w) - ((Pi.basisFun ℝ ι).unitsSMul fun i => .mk0 _ (hu i)) + convert! + QuadraticMap.isometryEquivBasisRepr (weightedSumSquares ℝ w) + ((Pi.basisFun ℝ ι).unitsSMul fun i => .mk0 _ (hu i)) ext1 v classical suffices ∑ i, (w i / |(u i : ℝ)|) * v i ^ 2 = ∑ i, w i * (v i ^ 2 * |(u i : ℝ)|⁻¹) by diff --git a/Mathlib/LinearAlgebra/QuadraticForm/Signature.lean b/Mathlib/LinearAlgebra/QuadraticForm/Signature.lean index a853d78a5c77a3..9a26d36b877fdb 100644 --- a/Mathlib/LinearAlgebra/QuadraticForm/Signature.lean +++ b/Mathlib/LinearAlgebra/QuadraticForm/Signature.lean @@ -193,7 +193,7 @@ lemma sigPos_weightedSumSquares : let m : Set ι := {i | w i ≤ 0} convert_to sigPos _ = p.ncard have : p.ncard + m.ncard = Nat.card ι := by - convert Set.ncard_add_ncard_compl p + convert! Set.ncard_add_ncard_compl p ext grind have : p.ncard ≤ sigPos (weightedSumSquares 𝕜 w) := @@ -205,7 +205,7 @@ lemma sigPos_weightedSumSquares : lemma sigNeg_weightedSumSquares : sigNeg (weightedSumSquares 𝕜 w) = {i | w i < 0}.ncard := by simp only [sigNeg] - convert sigPos_weightedSumSquares (w := -w) using 2 + convert! sigPos_weightedSumSquares (w := -w) using 2 · ext; simp · simp @@ -235,7 +235,7 @@ lemma sigPos_add_sigNeg_add_radical [FiniteDimensional 𝕜 M] : have : Invertible (2 : 𝕜) := invertibleOfNonzero (NeZero.ne _) obtain ⟨w, e⟩ := Q.equivalent_weightedSumSquares rw [e.sigPos_eq, e.sigNeg_eq, e.rank_radical_eq] - convert QuadraticForm.sigPos_add_sigNeg_add_radical₁ (w := w) + convert! QuadraticForm.sigPos_add_sigNeg_add_radical₁ (w := w) exact Eq.symm (Nat.card_fin (Module.finrank 𝕜 M)) /-- Uniqueness part of **Sylvester's law of inertia** (positive part): diff --git a/Mathlib/LinearAlgebra/QuadraticForm/TensorProduct.lean b/Mathlib/LinearAlgebra/QuadraticForm/TensorProduct.lean index 0221d16b8f9460..e8a8255fb1cda8 100644 --- a/Mathlib/LinearAlgebra/QuadraticForm/TensorProduct.lean +++ b/Mathlib/LinearAlgebra/QuadraticForm/TensorProduct.lean @@ -75,8 +75,10 @@ theorem associated_tmul [Invertible (2 : A)] letI : Invertible (2 : A) := (Invertible.map (algebraMap R A) 2).copy 2 (map_ofNat _ _).symm rw [QuadraticMap.tmul, BilinMap.tmul] have : Subsingleton (Invertible (2 : A)) := inferInstance - convert associated_left_inverse A (LinearMap.BilinMap.tmul_isSymm - (QuadraticMap.associated_isSymm A Q₁) (QuadraticMap.associated_isSymm R Q₂)) + convert! + associated_left_inverse A + (LinearMap.BilinMap.tmul_isSymm (QuadraticMap.associated_isSymm A Q₁) + (QuadraticMap.associated_isSymm R Q₂)) end QuadraticMap diff --git a/Mathlib/LinearAlgebra/Ray.lean b/Mathlib/LinearAlgebra/Ray.lean index 49066eedb5baa7..e857c07e686827 100644 --- a/Mathlib/LinearAlgebra/Ray.lean +++ b/Mathlib/LinearAlgebra/Ray.lean @@ -50,8 +50,20 @@ set_option linter.unusedVariables false in def RayVector (R M : Type*) [Zero M] := { v : M // v ≠ 0 } +/-- Equivalence between `RayVector` and non-zero vectors. -/ +def RayVector.equiv (R M : Type*) [Zero M] : RayVector R M ≃ { v : M // v ≠ 0 } := + Equiv.refl _ + instance RayVector.coe {R M : Type*} [Zero M] : CoeOut (RayVector R M) M where - coe := Subtype.val + coe x := (equiv R M x).val + +@[simp] +theorem RayVector.coe_equiv_symm {R M : Type*} [Zero M] {v : M} (h : v ≠ 0) : + (RayVector.equiv R M).symm ⟨v, h⟩ = v := rfl + +@[ext] +theorem RayVector.ext {R M : Type*} [Zero M] {x y : RayVector R M} (h : (x : M) = (y : M)) : + x = y := Subtype.ext h instance {R M : Type*} [Zero M] [Nontrivial M] : Nonempty (RayVector R M) := ⟨Classical.indefiniteDescription _ <| exists_ne (0 : M)⟩ @@ -193,7 +205,7 @@ theorem add_left (hx : SameRay R x z) (hy : SameRay R y z) : SameRay R (x + y) z rcases hy.exists_pos hy₀ hz₀ with ⟨ry, rz₂, hry, hrz₂, Hy⟩ refine Or.inr (Or.inr ⟨rx * ry, ry * rz₁ + rx * rz₂, mul_pos hrx hry, ?_, ?_⟩) · positivity - · convert congr(ry • $Hx + rx • $Hy) using 1 <;> module + · convert! congr(ry • $Hx + rx • $Hy) using 1 <;> module /-- If `y` and `z` are on the same ray as `x`, then so is `y + z`. -/ theorem add_right (hy : SameRay R x y) (hz : SameRay R x z) : SameRay R x (y + z) := @@ -225,7 +237,7 @@ variable (R) /-- The ray given by a nonzero vector. -/ def rayOfNeZero (v : M) (h : v ≠ 0) : Module.Ray R M := - ⟦⟨v, h⟩⟧ + ⟦(RayVector.equiv R M).symm ⟨v, h⟩⟧ /-- An induction principle for `Module.Ray`, used as `induction x using Module.Ray.ind`. -/ theorem Module.Ray.ind {C : Module.Ray R M → Prop} (h : ∀ (v) (hv : v ≠ 0), C (rayOfNeZero R v hv)) @@ -371,17 +383,16 @@ namespace RayVector /-- Negating a nonzero vector. -/ instance {R : Type*} : Neg (RayVector R M) := - ⟨fun v => ⟨-v, neg_ne_zero.2 v.prop⟩⟩ + ⟨fun v => (equiv R M).symm ⟨-v, neg_ne_zero.2 v.prop⟩⟩ /-- Negating a nonzero vector commutes with coercion to the underlying module. -/ @[simp, norm_cast] theorem coe_neg {R : Type*} (v : RayVector R M) : ↑(-v) = -(v : M) := rfl -set_option backward.isDefEq.respectTransparency false in /-- Negating a nonzero vector twice produces the original vector. -/ instance {R : Type*} : InvolutiveNeg (RayVector R M) where - neg_neg v := by rw [Subtype.ext_iff, coe_neg, coe_neg, neg_neg] + neg_neg v := by rw [RayVector.ext_iff, coe_neg, coe_neg, neg_neg] /-- If two nonzero vectors are equivalent, so are their negations. -/ @[simp] diff --git a/Mathlib/LinearAlgebra/RootSystem/Base.lean b/Mathlib/LinearAlgebra/RootSystem/Base.lean index e3c8d35417f093..6d5f6cce995250 100644 --- a/Mathlib/LinearAlgebra/RootSystem/Base.lean +++ b/Mathlib/LinearAlgebra/RootSystem/Base.lean @@ -206,7 +206,7 @@ lemma pos_or_neg_of_sum_smul_root_mem (f : ι → ℤ) have hf' : f ≠ 0 := by rintro rfl; exact P.ne_zero k <| by simp [hk] rcases b.root_mem_or_neg_mem k with hk' | hk' <;> rw [hk] at hk' · left; exact this f hk' hf₀ hf' - · right; simpa using this (-f) (by convert hk'; simp) (by simpa only [support_neg]) (by simpa) + · right; simpa using this (-f) (by convert! hk'; simp) (by simpa only [support_neg]) (by simpa) intro f hf hf₀ hf' let f' : b.support → ℤ := fun i ↦ f i replace hf : ∑ j, f' j • P.root j ∈ AddSubmonoid.closure (P.root '' b.support) := by diff --git a/Mathlib/LinearAlgebra/RootSystem/BaseExists.lean b/Mathlib/LinearAlgebra/RootSystem/BaseExists.lean index 3c0810c9c02cd6..d367432da18e79 100644 --- a/Mathlib/LinearAlgebra/RootSystem/BaseExists.lean +++ b/Mathlib/LinearAlgebra/RootSystem/BaseExists.lean @@ -131,7 +131,7 @@ lemma linearIndepOn_root_baseOf (f : M →+ ℚ) (hf : ∀ i, f (P.root i) ≠ 0 suffices (P.rootSpanMem ℚ i : M) ∈ span ℚ (P.root '' baseOf P.root f) by rw [← (injective_subtype (P.rootSpan ℚ)).mem_set_image, ← map_coe, SetLike.mem_coe, map_span, ← image_univ, ← image_comp] - convert this + convert! this aesop rw [← span_span_of_tower ℤ, ← Submodule.coe_toAddSubgroup, span_int_eq_addSubgroupClosure, AddSubgroup.closure_image_isAddIndecomposable_baseOf P.root (by simp) f (by simpa)] diff --git a/Mathlib/LinearAlgebra/RootSystem/Defs.lean b/Mathlib/LinearAlgebra/RootSystem/Defs.lean index e897ffc8ff4e15..504b4fa64c632c 100644 --- a/Mathlib/LinearAlgebra/RootSystem/Defs.lean +++ b/Mathlib/LinearAlgebra/RootSystem/Defs.lean @@ -459,7 +459,7 @@ lemma smul_coroot_eq_of_root_eq_smul [Finite ι] [IsAddTorsionFree N] (i j : ι) refine Module.eq_of_mapsTo_reflection_of_mem (f := P.root' i) (g := P.root' i) (finite_range P.coroot) (by simp [hij]) (by simp) (by simp [hij]) (by simp) ?_ (P.mapsTo_coreflection_coroot i) (mem_range_self i) - convert P.mapsTo_coreflection_coroot j + convert! P.mapsTo_coreflection_coroot j ext x replace h : P.root' j = t • P.root' i := by ext; simp [h, root'] simp [Module.preReflection_apply, coreflection_apply, h, smul_comm _ t, mul_smul] diff --git a/Mathlib/LinearAlgebra/RootSystem/Finite/G2.lean b/Mathlib/LinearAlgebra/RootSystem/Finite/G2.lean index c0811e35ec06e8..e557a7f8d6b6e1 100644 --- a/Mathlib/LinearAlgebra/RootSystem/Finite/G2.lean +++ b/Mathlib/LinearAlgebra/RootSystem/Finite/G2.lean @@ -110,6 +110,7 @@ lemma not_isG2_iff_isNotG2 : · specialize h i j lia +set_option linter.overlappingInstances false in lemma IsG2.pairingIn_mem_zero_one_three [P.IsG2] (i j : ι) (h : P.root i ≠ P.root j) (h' : P.root i ≠ -P.root j) : P.pairingIn ℤ i j ∈ ({-3, -1, 0, 1, 3} : Set ℤ) := by diff --git a/Mathlib/LinearAlgebra/RootSystem/Finite/Nondegenerate.lean b/Mathlib/LinearAlgebra/RootSystem/Finite/Nondegenerate.lean index 3c02df1e6cf6c2..3c70e81f32884e 100644 --- a/Mathlib/LinearAlgebra/RootSystem/Finite/Nondegenerate.lean +++ b/Mathlib/LinearAlgebra/RootSystem/Finite/Nondegenerate.lean @@ -124,13 +124,13 @@ lemma smul_coroot_eq_of_root_add_root_eq [P.IsAnisotropic] [IsDomain R] [IsTorsi rw [h₂, h₃] at h₁ replace h₁ := congr_arg (fun n ↦ P.pairing j i • n) h₁ simp only [add_smul, smul_add, ← mul_smul, smul_eq_mul] at h₁ - convert h₁ using 1 + convert! h₁ using 1 · module · ring_nf simp only [h₄] at h₁ apply smul_right_injective _ (r := lsq j) (RootPairing.IsAnisotropic.rootForm_root_ne_zero j) simp only - convert h₁ using 1 + convert! h₁ using 1 · module · module @@ -281,7 +281,7 @@ lemma isCompl_rootSpan_ker_rootForm : rw [P.toPerfPair.finrank_eq, ← P.finrank_corootSpan_eq', Subspace.finrank_add_finrank_dualAnnihilator_eq (P.corootSpan R), Subspace.dual_finrank_eq] rw [aux, add_le_add_iff_left] - convert Submodule.finrank_mono P.corootSpan_dualAnnihilator_le_ker_rootForm + convert! Submodule.finrank_mono P.corootSpan_dualAnnihilator_le_ker_rootForm exact (LinearEquiv.finrank_map_eq _ _).symm lemma isCompl_corootSpan_ker_corootForm : diff --git a/Mathlib/LinearAlgebra/RootSystem/GeckConstruction/Lemmas.lean b/Mathlib/LinearAlgebra/RootSystem/GeckConstruction/Lemmas.lean index 78dcfd684d021f..f5504e6ef84b64 100644 --- a/Mathlib/LinearAlgebra/RootSystem/GeckConstruction/Lemmas.lean +++ b/Mathlib/LinearAlgebra/RootSystem/GeckConstruction/Lemmas.lean @@ -45,7 +45,7 @@ lemma root_sub_root_mem_of_mem_of_mem (hk : α k + α i - α j ∈ Φ) rw [add_comm, add_sub_assoc, left_eq_add, sub_eq_zero, P.root.injective.eq_iff] at hl exact hkj hl suffices 0 < P.pairingIn ℤ l i by - convert P.root_sub_root_mem_of_pairingIn_pos this hli using 1 + convert! P.root_sub_root_mem_of_pairingIn_pos this hli using 1 rw [hl] module have hkl : l ≠ k := by rintro rfl; exact hij <| by simpa [add_sub_assoc, sub_eq_zero] using hl @@ -74,7 +74,7 @@ lemma root_sub_root_mem_of_mem_of_mem (hk : α k + α i - α j ∈ Φ) have : P.pairingIn ℤ l i = 1 - P.pairingIn ℤ j i := by apply algebraMap_injective ℤ R simp only [algebraMap_pairingIn, map_sub, map_one, algebraMap_pairingIn] - convert (P.coroot' i : M →ₗ[R] R).congr_arg hl using 1 + convert! (P.coroot' i : M →ₗ[R] R).congr_arg hl using 1 simp only [map_sub, map_add, LinearMap.flip_apply, root_coroot_eq_pairing, hki, pairing_same, sub_left_inj] ring @@ -88,12 +88,13 @@ lemma root_add_root_mem_of_mem_of_mem (hk : α k + α i - α j ∈ Φ) let _i := P.indexNeg replace hk : α (-k) + α j - α i ∈ Φ := by rw [← neg_mem_range_root_iff] - convert hk using 1 + convert! hk using 1 simp only [indexNeg_neg, root_reflectionPerm, reflection_apply_self] module rw [← neg_mem_range_root_iff] - convert b.root_sub_root_mem_of_mem_of_mem j i (-k) hij.symm hj hi hk (by contrapose hkj; aesop) - (by convert P.neg_mem_range_root_iff.mpr hk' using 1; simp [neg_add_eq_sub]) using 1 + convert! + b.root_sub_root_mem_of_mem_of_mem j i (-k) hij.symm hj hi hk (by contrapose hkj; aesop) + (by convert! P.neg_mem_range_root_iff.mpr hk' using 1; simp [neg_add_eq_sub]) using 1 simp only [indexNeg_neg, root_reflectionPerm, reflection_apply_self] module @@ -110,6 +111,7 @@ section chainBotCoeff_mul_chainTopCoeff variable {b : P.Base} {i j k l m : ι} +set_option linter.overlappingInstances false in private lemma chainBotCoeff_mul_chainTopCoeff.aux_0 [P.IsNotG2] (hik_mem : P.root k + P.root i ∈ range P.root) : P.pairingIn ℤ k i = 0 ∨ (P.pairingIn ℤ k i < 0 ∧ P.chainBotCoeff i k = 0) := by @@ -170,25 +172,25 @@ lemma chainBotCoeff_mul_chainTopCoeff.isNotG2 : P.IsNotG2 := by ← two_nsmul, h₂] at h₃ exact P.nsmul_notMem_range_root ⟨_, h₃.symm⟩ replace h₁ : 2 * (x + 1) + A * y ∈ s := by - convert IsG2.pairingIn_mem_zero_one_three P l i hli hli' + convert! IsG2.pairingIn_mem_zero_one_three P l i hli hli' replace h₁ : P.root l = (x + 1) • P.root i + y • P.root j := by rw [← h₁, ← h₀]; module rw [pairingIn_eq_add_of_root_eq_smul_add_smul (S := ℤ) (j := i) h₁, pairingIn_same, Int.zsmul_eq_mul, Int.zsmul_eq_mul] ring replace h₂ : 2 * x + A * (y - 1) ∈ s := by - convert IsG2.pairingIn_mem_zero_one_three P m i hmi hmi' + convert! IsG2.pairingIn_mem_zero_one_three P m i hmi hmi' replace h₂ : P.root m = x • P.root i + (y - 1) • P.root j := by rw [← h₂, ← h₀]; module rw [pairingIn_eq_add_of_root_eq_smul_add_smul (S := ℤ) (j := i) h₂, pairingIn_same, Int.zsmul_eq_mul, Int.zsmul_eq_mul] ring replace h₃ : 2 * (x + 1) + A * (y - 1) ∈ s := by - convert IsG2.pairingIn_mem_zero_one_three P n i hni hni' + convert! IsG2.pairingIn_mem_zero_one_three P n i hni hni' replace h₃ : P.root n = (x + 1) • P.root i + (y - 1) • P.root j := by rw [h₃, ← h₀]; module rw [pairingIn_eq_add_of_root_eq_smul_add_smul (S := ℤ) (j := i) h₃, pairingIn_same, Int.zsmul_eq_mul, Int.zsmul_eq_mul] ring replace h₀ : 2 * x + A * y ∈ s := by - convert IsG2.pairingIn_mem_zero_one_three P k i hki hki' + convert! IsG2.pairingIn_mem_zero_one_three P k i hki hki' rw [pairingIn_eq_add_of_root_eq_smul_add_smul (j := i) h₀.symm, pairingIn_same, Int.zsmul_eq_mul, Int.zsmul_eq_mul] ring @@ -218,7 +220,7 @@ private lemma chainBotCoeff_mul_chainTopCoeff.aux_1 have hkj_ne : k ≠ j ∧ P.root k ≠ -P.root j := (IsReduced.linearIndependent_iff _).mp <| P.linearIndependent_of_sub_mem_range_root <| h₂ ▸ mem_range_self m have hnk_notMem : P.root n - P.root k ∉ range P.root := by - convert b.sub_notMem_range_root hi hj using 2; rw [hn]; module + convert! b.sub_notMem_range_root hi hj using 2; rw [hn]; module /- Calculate some auxiliary relationships between root pairings. -/ have aux₀ : P.pairingIn ℤ j i = - P.pairingIn ℤ m i := by suffices P.pairing j i = - P.pairing m i from @@ -340,12 +342,12 @@ lemma chainBotCoeff_mul_chainTopCoeff : suffices (P.chainBotCoeff i m + 1) * (P.chainBotCoeff j (-k) + 1) = (P.chainBotCoeff j (-l) + 1) * (P.chainBotCoeff i k + 1) by simpa /- Establish basic relationships about roots and their sums / differences. -/ - have him_mem : P.root i + P.root m ∈ range P.root := by rw [← h₂]; convert h₃ using 1; abel + have him_mem : P.root i + P.root m ∈ range P.root := by rw [← h₂]; convert! h₃ using 1; abel have hik_mem : P.root k + P.root i ∈ range P.root := h₁ ▸ mem_range_self l have hjk_mem : P.root j + P.root (-k) ∈ range P.root := by - convert mem_range_self (-m) using 1; simpa [sub_eq_add_neg] using congr(-$h₂) + convert! mem_range_self (-m) using 1; simpa [sub_eq_add_neg] using congr(-$h₂) have hjl_mem : P.root j + P.root (-l) ∈ range P.root := by - rw [h₁, ← neg_mem_range_root_iff] at h₃; convert h₃ using 1; simp [sub_eq_add_neg] + rw [h₁, ← neg_mem_range_root_iff] at h₃; convert! h₃ using 1; simp [sub_eq_add_neg] have h₁' : P.root (-k) - P.root i = P.root (-l) := by simp only [root_reflectionPerm, reflection_apply_self, indexNeg_neg]; rw [← h₁]; abel have h₂' : P.root (-k) + P.root j = P.root (-m) := by diff --git a/Mathlib/LinearAlgebra/RootSystem/GeckConstruction/Semisimple.lean b/Mathlib/LinearAlgebra/RootSystem/GeckConstruction/Semisimple.lean index e56ded4bca6605..0e63f34d9c13a4 100644 --- a/Mathlib/LinearAlgebra/RootSystem/GeckConstruction/Semisimple.lean +++ b/Mathlib/LinearAlgebra/RootSystem/GeckConstruction/Semisimple.lean @@ -129,7 +129,7 @@ lemma isNilpotent_e : apply IsReduced.linearIndependent P ?_ ?_ · rintro rfl apply P.nsmul_notMem_range_root (n := P.chainTopCoeff i i + 2) (i := i) - convert hk₁ using 1 + convert! hk₁ using 1 module · contrapose hij rw [root_eq_neg_iff] at hij diff --git a/Mathlib/LinearAlgebra/SesquilinearForm/Basic.lean b/Mathlib/LinearAlgebra/SesquilinearForm/Basic.lean index acea5ae533874c..f22bdb572a56e1 100644 --- a/Mathlib/LinearAlgebra/SesquilinearForm/Basic.lean +++ b/Mathlib/LinearAlgebra/SesquilinearForm/Basic.lean @@ -723,7 +723,7 @@ theorem Nondegenerate.congr (h : B.Nondegenerate) : theorem separatingLeft_congr_iff : (e₁.arrowCongr (e₂.arrowCongr (LinearEquiv.refl R M)) B).SeparatingLeft ↔ B.SeparatingLeft := ⟨fun h ↦ by - convert h.congr e₁.symm e₂.symm + convert! h.congr e₁.symm e₂.symm ext x y simp, SeparatingLeft.congr e₁ e₂⟩ @@ -1007,7 +1007,7 @@ lemma nondegenerate_restrict_iff_disjoint_ker (hs : ∀ x, 0 ≤ B x x) (hB : B. have key : x ∈ W ⊓ LinearMap.ker B := ⟨hx, h⟩ simpa [hW.eq_bot] using key -variable [IsDomain R] [IsTorsionFree R M] +variable [IsTorsionFree R M] /-- Strict **Cauchy-Schwarz** is equivalent to linear independence for positive definite forms. -/ lemma apply_mul_apply_lt_iff_linearIndependent (hp : ∀ x, x ≠ 0 → 0 < B x x) (x y : M) : diff --git a/Mathlib/LinearAlgebra/Span/Basic.lean b/Mathlib/LinearAlgebra/Span/Basic.lean index aaf8b9ca8ff941..8a8ce994c1f705 100644 --- a/Mathlib/LinearAlgebra/Span/Basic.lean +++ b/Mathlib/LinearAlgebra/Span/Basic.lean @@ -126,8 +126,9 @@ lemma linearMap_eq_iff_of_eq_span {V : Submodule R M} (f g : V →ₗ[R] N) lemma linearMap_eq_iff_of_span_eq_top (f g : M →ₗ[R] N) {S : Set M} (hM : span R S = ⊤) : f = g ↔ ∀ (s : S), f s = g s := by - convert linearMap_eq_iff_of_eq_span (f.comp (Submodule.subtype _)) - (g.comp (Submodule.subtype _)) hM.symm + convert! + linearMap_eq_iff_of_eq_span (f.comp (Submodule.subtype _)) (g.comp (Submodule.subtype _)) + hM.symm constructor · rintro rfl rfl @@ -152,7 +153,7 @@ end theorem span_smul_eq_of_isUnit (s : Set M) (r : R) (hr : IsUnit r) : span R (r • s) = span R s := by apply le_antisymm · apply span_smul_le - · convert span_smul_le (r • s) ((hr.unit⁻¹ :) : R) + · convert! span_smul_le (r • s) ((hr.unit⁻¹ :) : R) simp [smul_smul] /-- We can regard `coe_iSup_of_chain` as the statement that `(↑) : (Submodule R M) → Set M` is diff --git a/Mathlib/LinearAlgebra/Span/Defs.lean b/Mathlib/LinearAlgebra/Span/Defs.lean index e23492dfda9cb5..294fcbbaa076c9 100644 --- a/Mathlib/LinearAlgebra/Span/Defs.lean +++ b/Mathlib/LinearAlgebra/Span/Defs.lean @@ -488,7 +488,7 @@ theorem span_singleton_smul_le {S} [SMul S R] [SMul S M] [IsScalarTower S R M] theorem span_singleton_group_smul_eq {G} [Group G] [SMul G R] [MulAction G M] [IsScalarTower G R M] (g : G) (x : M) : R ∙ g • x = R ∙ x := by refine le_antisymm (span_singleton_smul_le R g x) ?_ - convert span_singleton_smul_le R g⁻¹ (g • x) + convert! span_singleton_smul_le R g⁻¹ (g • x) exact (inv_smul_smul g x).symm variable {R} diff --git a/Mathlib/LinearAlgebra/SpecialLinearGroup.lean b/Mathlib/LinearAlgebra/SpecialLinearGroup.lean index 21e37ff4747986..5c8c3afb9c550b 100644 --- a/Mathlib/LinearAlgebra/SpecialLinearGroup.lean +++ b/Mathlib/LinearAlgebra/SpecialLinearGroup.lean @@ -546,7 +546,7 @@ theorem centerCongr_toLin_equiv_trans_centerEquivRootsOfUnity_eq (g) : Matrix.SpecialLinearGroup.center_equiv_rootsOfUnity g := by nontriviality R by_cases hV : Subsingleton V - · convert Eq.refl (1 : Rˣ) <;> + · convert! Eq.refl (1 : Rˣ) <;> · apply rootsOfUnity.eq_one rw [← Module.finrank_eq_zero_iff_of_free (R := R)] at hV simp only [hV, sup_eq_right, zero_le_one, ← Module.finrank_eq_card_basis b] diff --git a/Mathlib/LinearAlgebra/StdBasis.lean b/Mathlib/LinearAlgebra/StdBasis.lean index 77cd82820b5c82..843555ee5da950 100644 --- a/Mathlib/LinearAlgebra/StdBasis.lean +++ b/Mathlib/LinearAlgebra/StdBasis.lean @@ -47,7 +47,7 @@ variable {η : Type*} {ιs : η → Type*} {Ms : η → Type*} theorem linearIndependent_single [Semiring R] [∀ i, AddCommMonoid (Ms i)] [∀ i, Module R (Ms i)] [DecidableEq η] (v : ∀ j, ιs j → Ms j) (hs : ∀ i, LinearIndependent R (v i)) : LinearIndependent R fun ji : Σ j, ιs j ↦ Pi.single ji.1 (v ji.1 ji.2) := by - convert (DFinsupp.linearIndependent_single _ hs).map_injOn _ DFinsupp.injective_pi_lapply.injOn + convert! (DFinsupp.linearIndependent_single _ hs).map_injOn _ DFinsupp.injective_pi_lapply.injOn theorem linearIndependent_single_one (ι R : Type*) [Semiring R] [DecidableEq ι] : LinearIndependent R (fun i : ι ↦ Pi.single i (1 : R)) := by @@ -165,7 +165,7 @@ lemma AlgHom.eq_piEvalAlgHom {k G : Type*} [CommSemiring k] [NoZeroDivisors k] [ have h2 : ∀ t ≠ s, φ (Pi.single t 1) = 0 := by refine fun _ _ ↦ (eq_zero_or_eq_zero_of_mul_eq_zero ?_).resolve_left hs rw [← map_mul] - convert map_zero φ + convert! map_zero φ ext u by_cases u = s <;> simp_all have h3 : φ (Pi.single s 1) = 1 := by diff --git a/Mathlib/LinearAlgebra/SymmetricAlgebra/Basic.lean b/Mathlib/LinearAlgebra/SymmetricAlgebra/Basic.lean index e724f4ba40fc73..7ccbac331f11e5 100644 --- a/Mathlib/LinearAlgebra/SymmetricAlgebra/Basic.lean +++ b/Mathlib/LinearAlgebra/SymmetricAlgebra/Basic.lean @@ -125,6 +125,8 @@ lemma lift_ι : lift (ι R M) = .id R (SymmetricAlgebra R M) := by def algebraMapInv : SymmetricAlgebra R M →ₐ[R] R := lift (0 : M →ₗ[R] R) +theorem algebraMapInv_ι (x : M) : algebraMapInv (ι R M x) = 0 := lift_ι_apply 0 x + variable (M) theorem algebraMap_leftInverse : diff --git a/Mathlib/LinearAlgebra/TensorAlgebra/Basic.lean b/Mathlib/LinearAlgebra/TensorAlgebra/Basic.lean index 26d2633edac6a8..a8e63217d9d82c 100644 --- a/Mathlib/LinearAlgebra/TensorAlgebra/Basic.lean +++ b/Mathlib/LinearAlgebra/TensorAlgebra/Basic.lean @@ -146,7 +146,7 @@ variable {R} @[simp] theorem ι_comp_lift {A : Type*} [Semiring A] [Algebra R A] (f : M →ₗ[R] A) : (lift R f).toLinearMap.comp (ι R) = f := by - convert (lift R).symm_apply_apply f + convert! (lift R).symm_apply_apply f @[simp] theorem lift_ι_apply {A : Type*} [Semiring A] [Algebra R A] (f : M →ₗ[R] A) (x) : diff --git a/Mathlib/LinearAlgebra/TensorPower/Symmetric.lean b/Mathlib/LinearAlgebra/TensorPower/Symmetric.lean index fd727321ca544b..3549e86257a213 100644 --- a/Mathlib/LinearAlgebra/TensorPower/Symmetric.lean +++ b/Mathlib/LinearAlgebra/TensorPower/Symmetric.lean @@ -72,11 +72,12 @@ lemma smul (r : R) (x y : ⨂[R] _, M) (h : addConGen (Rel R ι M) x y) : | of x y h => cases h with | perm e f => apply isEmpty_or_nonempty ι |>.elim <;> intro h - · convert addConGen (Rel R ι M) |>.refl _ + · convert! addConGen (Rel R ι M) |>.refl _ · let i := Nonempty.some h classical - convert AddConGen.Rel.of _ _ <| SymmetricPower.Rel.perm (R := R) (ι := ι) e - <| Function.update f i (r • f i) + convert! + AddConGen.Rel.of _ _ <| + SymmetricPower.Rel.perm (R := R) (ι := ι) e <| Function.update f i (r • f i) · rw [MultilinearMap.map_update_smul, Function.update_eq_self] · simp_rw [Function.update_apply_equiv_apply, MultilinearMap.map_update_smul, ← Function.update_comp_equiv, Function.update_eq_self]; rfl diff --git a/Mathlib/LinearAlgebra/TensorProduct/Basic.lean b/Mathlib/LinearAlgebra/TensorProduct/Basic.lean index c9949b11f603e9..7c45ceb0d837f2 100644 --- a/Mathlib/LinearAlgebra/TensorProduct/Basic.lean +++ b/Mathlib/LinearAlgebra/TensorProduct/Basic.lean @@ -380,7 +380,7 @@ instance neg : Neg (M ⊗[R] N) where protected theorem neg_add_cancel (x : M ⊗[R] N) : -x + x = 0 := x.induction_on (by rw [add_zero]; apply (Neg.aux R).map_zero) - (fun x y => by convert (add_tmul (R := R) (-x) x y).symm; rw [neg_add_cancel, zero_tmul]) + (fun x y => by convert! (add_tmul (R := R) (-x) x y).symm; rw [neg_add_cancel, zero_tmul]) fun x y hx hy => by suffices -x + x + (-y + y) = 0 by rw [← this] diff --git a/Mathlib/LinearAlgebra/TensorProduct/DirectLimit.lean b/Mathlib/LinearAlgebra/TensorProduct/DirectLimit.lean index fb860351f3ad63..5e43b9eb9e92b3 100644 --- a/Mathlib/LinearAlgebra/TensorProduct/DirectLimit.lean +++ b/Mathlib/LinearAlgebra/TensorProduct/DirectLimit.lean @@ -112,14 +112,14 @@ variable [DirectedSystem G (f · · ·)] instance : DirectedSystem (G · ⊗[R] M) (f ▷ M) where map_self i x := by - convert LinearMap.rTensor_id_apply M (G i) x; ext; apply DirectedSystem.map_self' + convert! LinearMap.rTensor_id_apply M (G i) x; ext; apply DirectedSystem.map_self' map_map _ _ _ _ _ x := by - convert ← (LinearMap.rTensor_comp_apply M _ _ x).symm; ext; apply DirectedSystem.map_map' f + convert! ← (LinearMap.rTensor_comp_apply M _ _ x).symm; ext; apply DirectedSystem.map_map' f instance : DirectedSystem (M ⊗[R] G ·) (M ◁ f) where map_self i x := by - convert LinearMap.lTensor_id_apply M _ x; ext; apply DirectedSystem.map_self' + convert! LinearMap.lTensor_id_apply M _ x; ext; apply DirectedSystem.map_self' map_map _ _ _ h₁ h₂ x := by - convert ← (LinearMap.lTensor_comp_apply M _ _ x).symm; ext; apply DirectedSystem.map_map' f + convert! ← (LinearMap.lTensor_comp_apply M _ _ x).symm; ext; apply DirectedSystem.map_map' f end TensorProduct diff --git a/Mathlib/LinearAlgebra/TensorProduct/Graded/Internal.lean b/Mathlib/LinearAlgebra/TensorProduct/Graded/Internal.lean index 72c3737ee2bc2d..4a8b903f686cc3 100644 --- a/Mathlib/LinearAlgebra/TensorProduct/Graded/Internal.lean +++ b/Mathlib/LinearAlgebra/TensorProduct/Graded/Internal.lean @@ -209,18 +209,19 @@ theorem tmul_coe_mul_zero_coe_tmul {j₁ : ι} (a₁ : A) (b₁ : ℬ j₁) (a theorem tmul_one_mul_coe_tmul {i₂ : ι} (a₁ : A) (a₂ : 𝒜 i₂) (b₂ : B) : (a₁ ᵍ⊗ₜ[R] (1 : B) * (a₂ : A) ᵍ⊗ₜ[R] b₂ : 𝒜 ᵍ⊗[R] ℬ) = (a₁ * a₂ : A) ᵍ⊗ₜ (b₂ : B) := by - convert tmul_zero_coe_mul_coe_tmul 𝒜 ℬ a₁ (@GradedMonoid.GOne.one _ (ℬ ·) _ _) a₂ b₂ + convert! tmul_zero_coe_mul_coe_tmul 𝒜 ℬ a₁ (@GradedMonoid.GOne.one _ (ℬ ·) _ _) a₂ b₂ rw [SetLike.coe_gOne, one_mul] theorem tmul_coe_mul_one_tmul {j₁ : ι} (a₁ : A) (b₁ : ℬ j₁) (b₂ : B) : (a₁ ᵍ⊗ₜ[R] (b₁ : B) * (1 : A) ᵍ⊗ₜ[R] b₂ : 𝒜 ᵍ⊗[R] ℬ) = (a₁ : A) ᵍ⊗ₜ (b₁ * b₂ : B) := by - convert tmul_coe_mul_zero_coe_tmul 𝒜 ℬ a₁ b₁ (@GradedMonoid.GOne.one _ (𝒜 ·) _ _) b₂ + convert! tmul_coe_mul_zero_coe_tmul 𝒜 ℬ a₁ b₁ (@GradedMonoid.GOne.one _ (𝒜 ·) _ _) b₂ rw [SetLike.coe_gOne, mul_one] theorem tmul_one_mul_one_tmul (a₁ : A) (b₂ : B) : (a₁ ᵍ⊗ₜ[R] (1 : B) * (1 : A) ᵍ⊗ₜ[R] b₂ : 𝒜 ᵍ⊗[R] ℬ) = (a₁ : A) ᵍ⊗ₜ (b₂ : B) := by - convert tmul_coe_mul_zero_coe_tmul 𝒜 ℬ - a₁ (GradedMonoid.GOne.one (A := (ℬ ·))) (GradedMonoid.GOne.one (A := (𝒜 ·))) b₂ + convert! + tmul_coe_mul_zero_coe_tmul 𝒜 ℬ a₁ (GradedMonoid.GOne.one (A := (ℬ ·))) + (GradedMonoid.GOne.one (A := (𝒜 ·))) b₂ · rw [SetLike.coe_gOne, mul_one] · rw [SetLike.coe_gOne, one_mul] diff --git a/Mathlib/LinearAlgebra/TensorProduct/RightExactness.lean b/Mathlib/LinearAlgebra/TensorProduct/RightExactness.lean index 0b303cc6c32f63..53349052145c1f 100644 --- a/Mathlib/LinearAlgebra/TensorProduct/RightExactness.lean +++ b/Mathlib/LinearAlgebra/TensorProduct/RightExactness.lean @@ -411,7 +411,7 @@ lemma LinearMap.ker_tensorProductMk {I : Ideal R} : ker (TensorProduct.mk R (R ⧸ I) Q 1) = I • ⊤ := by apply comap_injective_of_surjective (TensorProduct.lid R Q).surjective rw [← ker_comp] - convert rTensor_mkQ Q I + convert! rTensor_mkQ Q I · ext; simp rw [comap_equiv_eq_map_symm, map_symm_eq_iff, map_range_rTensor_subtype_lid] diff --git a/Mathlib/LinearAlgebra/TensorProduct/Tower.lean b/Mathlib/LinearAlgebra/TensorProduct/Tower.lean index 7607ff2d6e0b81..c71de9452136f5 100644 --- a/Mathlib/LinearAlgebra/TensorProduct/Tower.lean +++ b/Mathlib/LinearAlgebra/TensorProduct/Tower.lean @@ -176,6 +176,9 @@ nonrec def mk (A M N : Type*) [Semiring A] variable {R A B M N P Q} +/-- The heterobasic version of `mk` coincides with the regular version. -/ +lemma mk_eq : mk R R M N = TensorProduct.mk R M N := rfl + /-- Heterobasic version of `TensorProduct.map` -/ def map (f : M →ₗ[A] P) (g : N →ₗ[R] Q) : M ⊗[R] N →ₗ[A] P ⊗[R] Q := lift <| diff --git a/Mathlib/LinearAlgebra/TensorProduct/Vanishing.lean b/Mathlib/LinearAlgebra/TensorProduct/Vanishing.lean index 5d0421a6d01155..ebd9a892dc8712 100644 --- a/Mathlib/LinearAlgebra/TensorProduct/Vanishing.lean +++ b/Mathlib/LinearAlgebra/TensorProduct/Vanishing.lean @@ -164,7 +164,7 @@ theorem vanishesTrivially_of_sum_tmul_eq_zero (hm : Submodule.span R (Set.range Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte, rTensor_tmul, coe_subtype, Finsupp.sum_apply, Finsupp.sum_ite_eq', Finsupp.mem_support_iff, ne_eq, ite_not, en] at hkn simp only [Finset.univ_eq_attach, Finset.sum_attach ma (fun x ↦ (x.1 : ι →₀ R) i • x.2)] - convert hkn using 2 with x _ + convert! hkn using 2 with x _ split · next h'x => rw [h'x, zero_smul] · rfl @@ -203,8 +203,8 @@ theorem vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective simp only [m'_eq, map_sum, rTensor_tmul, coe_subtype, Subtype.coind_coe, map_zero, hmn] have : VanishesTrivially R m' n := vanishesTrivially_of_sum_tmul_eq_zero R hm' hm'n unfold VanishesTrivially at this ⊢ - convert this with κ _ a y j - convert (injective_iff_map_eq_zero' _).mp (injective_subtype (span R (Set.range m))) _ + convert! this with κ _ a y j + convert! (injective_iff_map_eq_zero' _).mp (injective_subtype (span R (Set.range m))) _ simp [m'_eq] /-- **Equational criterion for vanishing** @@ -239,9 +239,9 @@ theorem rTensor_injective_of_forall_vanishesTrivially have := hMN hx rw [← e.vanishesTrivially_comp] unfold VanishesTrivially at this ⊢ - convert this + convert! this symm - convert (injective_iff_map_eq_zero' _).mp (injective_subtype M') _ + convert! (injective_iff_map_eq_zero' _).mp (injective_subtype M') _ simp /-- Every expression $\sum_i m_i \otimes n_i$ which vanishes also vanishes trivially if and only if diff --git a/Mathlib/LinearAlgebra/Trace.lean b/Mathlib/LinearAlgebra/Trace.lean index 2bc42f62dc0c63..ee5b930430840d 100644 --- a/Mathlib/LinearAlgebra/Trace.lean +++ b/Mathlib/LinearAlgebra/Trace.lean @@ -336,6 +336,25 @@ theorem IsProj.trace {p : Submodule R M} {f : M →ₗ[R] M} (h : IsProj p f) [M trace R M f = (finrank R p : R) := by rw [h.eq_conj_prodMap, trace_conj', trace_prodMap', trace_id, map_zero, add_zero] +open LinearMap in +/-- An idempotent endomorphism of a module over a characteristic-zero commutative ring +with vanishing trace is the zero map, provided its range and kernel are finite and free. + +The `Module.Free` and `Module.Finite` instance arguments on `range e` and `ker e` are +automatic over a field, and more generally over any principal ideal domain `R` for which +`M` itself is finite and free (submodules of finite free modules over a PID are finite +and free). -/ +theorem IsIdempotentElem.trace_eq_zero_iff {R : Type*} [CommRing R] [CharZero R] + {M : Type*} [AddCommGroup M] [Module R M] + {e : M →ₗ[R] M} (he : IsIdempotentElem e) + [Module.Free R (range e)] [Module.Finite R (range e)] + [Module.Free R (ker e)] [Module.Finite R (ker e)] : + trace R M e = 0 ↔ e = 0 := by + rw [he.isProj_range.trace, Nat.cast_eq_zero, finrank_eq_zero_iff_of_free, + Submodule.subsingleton_iff_eq_bot, range_eq_bot] + +alias ⟨IsIdempotentElem.eq_zero_of_trace_eq_zero, _⟩ := IsIdempotentElem.trace_eq_zero_iff + lemma isNilpotent_trace_of_isNilpotent {f : M →ₗ[R] M} (hf : IsNilpotent f) : IsNilpotent (trace R M f) := by by_cases H : ∃ s : Finset M, Nonempty (Basis s R M) diff --git a/Mathlib/LinearAlgebra/Transvection/Basic.lean b/Mathlib/LinearAlgebra/Transvection/Basic.lean index add56dac91b8ed..02514b45847ed7 100644 --- a/Mathlib/LinearAlgebra/Transvection/Basic.lean +++ b/Mathlib/LinearAlgebra/Transvection/Basic.lean @@ -609,7 +609,7 @@ private theorem det_ofField [FiniteDimensional K V] (f : Dual K V) (v : V) : · simp [← hxy, hxi] · rw [Finsupp.single_eq_of_ne hxi]; simp [hxy] · rw [Finsupp.single_eq_of_ne hxy, zero_add, mul_assoc] - convert mul_zero _ + convert! mul_zero _ by_cases hxi : x = i · simp [← hxi, Finsupp.single_eq_of_ne hxy] · simp [Finsupp.single_eq_of_ne hxi] diff --git a/Mathlib/LinearAlgebra/Vandermonde.lean b/Mathlib/LinearAlgebra/Vandermonde.lean index 650931547fcca2..f206bd497007a8 100644 --- a/Mathlib/LinearAlgebra/Vandermonde.lean +++ b/Mathlib/LinearAlgebra/Vandermonde.lean @@ -211,7 +211,7 @@ theorem det_projVandermonde (v w : Fin n → R) : (projVandermonde v w).det = rw [projVandermonde_map, ← RingHom.map_det, IsFractionRing.coe_inj] at hdet apply_fun MvPolynomial.eval₂Hom (Int.castRingHom R) (fun x ↦ (if x.2 then v else w) x.1) at hdet rw [RingHom.map_det] at hdet - convert hdet <;> + convert! hdet <;> simp [← Matrix.ext_iff, projVandermonde_apply] /-- The formula for the determinant of a Vandermonde matrix. -/ @@ -300,7 +300,7 @@ private lemma of_eval_descPochhammer_eq_mul_of_choose {n : ℕ} (v : Fin n → (of fun i j : Fin n => (descPochhammer ℤ j).eval (v i : ℤ)).det = (∏ i : Fin n, Nat.factorial i) * (of fun i j : Fin n => (Nat.choose (v i) j : ℤ)).det := by - convert det_mul_row (fun (i : Fin n) => ((Nat.factorial (i : ℕ)) : ℤ)) _ + convert! det_mul_row (fun (i : Fin n) => ((Nat.factorial (i : ℕ)) : ℤ)) _ · rw [of_apply, descPochhammer_eval_eq_descFactorial ℤ _ _] congr exact Nat.descFactorial_eq_factorial_mul_choose _ _ diff --git a/Mathlib/Logic/Basic.lean b/Mathlib/Logic/Basic.lean index 74c7b6811593ef..482715df4ee0f9 100644 --- a/Mathlib/Logic/Basic.lean +++ b/Mathlib/Logic/Basic.lean @@ -1079,6 +1079,7 @@ theorem beq_ext {α : Type*} (inst1 : BEq α) (inst2 : BEq α) funext x y exact h x y +set_option linter.overlappingInstances false in theorem lawful_beq_subsingleton {α : Type*} (inst1 : BEq α) (inst2 : BEq α) [@LawfulBEq α inst1] [@LawfulBEq α inst2] : inst1 = inst2 := by diff --git a/Mathlib/Logic/Encodable/Lattice.lean b/Mathlib/Logic/Encodable/Lattice.lean index 5614535c2f0954..159951b6d7c8a0 100644 --- a/Mathlib/Logic/Encodable/Lattice.lean +++ b/Mathlib/Logic/Encodable/Lattice.lean @@ -45,7 +45,7 @@ theorem iUnion_decode₂_cases {f : β → Set α} {C : Set α → Prop} (H0 : C simp only [Option.mem_def, iUnion_of_empty, iUnion_empty, reduceCtorEq] apply H0 | some b => by - convert H1 b + convert! H1 b simp open scoped Function in -- required for scoped `on` notation diff --git a/Mathlib/Logic/Equiv/Fin/Basic.lean b/Mathlib/Logic/Equiv/Fin/Basic.lean index bdd4576d780967..341c95b6f54503 100644 --- a/Mathlib/Logic/Equiv/Fin/Basic.lean +++ b/Mathlib/Logic/Equiv/Fin/Basic.lean @@ -316,12 +316,12 @@ theorem finAddFlip_apply_natAdd (k : Fin n) (m : ℕ) : theorem finAddFlip_apply_mk_left {k : ℕ} (h : k < m) (hk : k < m + n := Nat.lt_add_right n h) (hnk : n + k < n + m := Nat.add_lt_add_left h n) : finAddFlip (⟨k, hk⟩ : Fin (m + n)) = ⟨n + k, hnk⟩ := by - convert finAddFlip_apply_castAdd ⟨k, h⟩ n + convert! finAddFlip_apply_castAdd ⟨k, h⟩ n @[simp] theorem finAddFlip_apply_mk_right {k : ℕ} (h₁ : m ≤ k) (h₂ : k < m + n) : finAddFlip (⟨k, h₂⟩ : Fin (m + n)) = ⟨k - m, by lia⟩ := by - convert @finAddFlip_apply_natAdd n ⟨k - m, by lia⟩ m + convert! @finAddFlip_apply_natAdd n ⟨k - m, by lia⟩ m simp [Nat.add_sub_cancel' h₁] /-- Equivalence between `Fin m × Fin n` and `Fin (m * n)` -/ diff --git a/Mathlib/Logic/Equiv/Fin/Rotate.lean b/Mathlib/Logic/Equiv/Fin/Rotate.lean index a8b3dfe63f4812..81a6d5d4778c7a 100644 --- a/Mathlib/Logic/Equiv/Fin/Rotate.lean +++ b/Mathlib/Logic/Equiv/Fin/Rotate.lean @@ -119,10 +119,9 @@ lemma coe_finRotate_symm_of_ne_zero [NeZero n] {i : Fin n} (hi : i ≠ 0) : theorem finRotate_symm_lt_iff_ne_zero [NeZero n] (i : Fin n) : (finRotate _).symm i < i ↔ i ≠ 0 := by obtain ⟨n, rfl⟩ := exists_eq_succ_of_ne_zero (NeZero.ne n) - refine ⟨fun hi hc ↦ ?_, fun hi ↦ ?_⟩ - · simp only [hc, Fin.not_lt_zero] at hi - · rw [Fin.lt_def, coe_finRotate_symm_of_ne_zero hi] - apply sub_lt (zero_lt_of_ne_zero <| Fin.val_ne_zero_iff.mpr hi) Nat.zero_lt_one + refine ⟨ne_zero_of_lt, fun hi ↦ ?_⟩ + rw [Fin.lt_def, coe_finRotate_symm_of_ne_zero hi] + exact sub_lt (zero_lt_of_ne_zero <| Fin.val_ne_zero_iff.mpr hi) zero_lt_one /-- The permutation on `Fin n` that adds `k` to each number. -/ @[simps] diff --git a/Mathlib/Logic/Equiv/Fintype.lean b/Mathlib/Logic/Equiv/Fintype.lean index f1f25b68f0a7cf..6005758b19ffc1 100644 --- a/Mathlib/Logic/Equiv/Fintype.lean +++ b/Mathlib/Logic/Equiv/Fintype.lean @@ -73,7 +73,7 @@ def Equiv.Perm.viaFintypeEmbedding : Equiv.Perm β := theorem Equiv.Perm.viaFintypeEmbedding_apply_image (a : α) : e.viaFintypeEmbedding f (f a) = f (e a) := by rw [Equiv.Perm.viaFintypeEmbedding] - convert Equiv.Perm.extendDomain_apply_image e (Function.Embedding.toEquivRange f) a + convert! Equiv.Perm.extendDomain_apply_image e (Function.Embedding.toEquivRange f) a theorem Equiv.Perm.viaFintypeEmbedding_apply_mem_range {b : β} (h : b ∈ Set.range f) : e.viaFintypeEmbedding f b = f (e (f.invOfMemRange ⟨b, h⟩)) := by @@ -102,7 +102,7 @@ noncomputable def setDiffEquiv {s t : Set α} [Fintype s] [Fintype t] have hst (x : α) : x ∈ fs \ ft ↔ x ∈ s \ t := by simp [hs, ht] have hts (x : α) : x ∈ ft \ fs ↔ x ∈ t \ s := by simp [hs, ht] have hc : fs.card = ft.card := by - rw [← Fintype.subtype_card fs hs, ← Fintype.subtype_card ft ht]; convert h + rw [← Fintype.subtype_card fs hs, ← Fintype.subtype_card ft ht]; convert! h replace hc := Finset.card_sdiff_comm hc rw [← Fintype.subtype_card (fs \ ft) hst, ← Fintype.subtype_card (ft \ fs) hts] at hc exact ((Fintype.card_eq (_F := (_)) (_G := (_))).mp hc).some diff --git a/Mathlib/Logic/Equiv/Set.lean b/Mathlib/Logic/Equiv/Set.lean index c230eb6af60f2f..aebc26f556dbeb 100644 --- a/Mathlib/Logic/Equiv/Set.lean +++ b/Mathlib/Logic/Equiv/Set.lean @@ -246,9 +246,11 @@ protected def singleton {α} (a : α) : ({a} : Set α) ≃ PUnit.{u} := subst x rfl, fun ⟨⟩ => rfl⟩ -lemma Equiv.strictMono_setCongr {α : Type*} [Preorder α] {S T : Set α} (h : S = T) : +lemma _root_.Equiv.strictMono_setCongr {α : Type*} [Preorder α] {S T : Set α} (h : S = T) : StrictMono (setCongr h) := fun _ _ ↦ id +@[deprecated (since := "2026-05-24")] alias Equiv.strictMono_setCongr := Equiv.strictMono_setCongr + /-- If `a ∉ s`, then `insert a s` is equivalent to `s ⊕ PUnit`. -/ protected def insert {α} {s : Set.{u} α} [DecidablePred (· ∈ s)] {a : α} (H : a ∉ s) : (insert a s : Set α) ≃ s ⊕ PUnit.{u + 1} := diff --git a/Mathlib/Logic/Function/Basic.lean b/Mathlib/Logic/Function/Basic.lean index e01b7d06369839..568591f9a55669 100644 --- a/Mathlib/Logic/Function/Basic.lean +++ b/Mathlib/Logic/Function/Basic.lean @@ -55,6 +55,12 @@ section onFun theorem onFun_apply (f : β → β → γ) (g : α → β) (a b : α) : onFun f g a b = f (g a) (g b) := rfl +theorem onFun_onFun_eq {δ : Sort*} (f : α → α → γ) (g : β → α) (h : δ → β) : + (f.onFun g).onFun h = f.onFun (g ∘ h) := rfl + +theorem onFun_comp_eq {δ : Sort*} (f : α → α → γ) (g : β → α) (h : δ → β) : + f.onFun (g ∘ h) = (f.onFun g).onFun h := rfl + variable (r : β → β → Prop) (f : α → β) instance [Std.Refl r] : Std.Refl (r on f) where diff --git a/Mathlib/Logic/Function/FiberPartition.lean b/Mathlib/Logic/Function/FiberPartition.lean index e52d0455afe115..f85ea3cb6bcf99 100644 --- a/Mathlib/Logic/Function/FiberPartition.lean +++ b/Mathlib/Logic/Function/FiberPartition.lean @@ -49,7 +49,7 @@ def mkSelf (f : Y → Z) (y : Y) : (mk f y).val := ⟨y, rfl⟩ lemma map_eq_image (f : Y → Z) (a : Fiber f) (x : a.1) : f x = a.image := by have := a.2.choose_spec rw [← Set.mem_singleton_iff, ← Set.mem_preimage] - convert x.prop + convert! x.prop lemma mk_image (f : Y → Z) (y : Y) : (Fiber.mk f y).image = f y := (map_eq_image (x := mkSelf f y)).symm diff --git a/Mathlib/Logic/Hydra.lean b/Mathlib/Logic/Hydra.lean index 2245132e3e1a99..0990defc7d53f0 100644 --- a/Mathlib/Logic/Hydra.lean +++ b/Mathlib/Logic/Hydra.lean @@ -84,7 +84,7 @@ theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) ↔ CutExpand exists₂_congr fun _ _ ↦ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff] lemma cutExpand_add_right {s' s} (t) : CutExpand r (s' + t) (s + t) ↔ CutExpand r s' s := by - convert cutExpand_add_left t using 2 <;> apply add_comm + convert! cutExpand_add_left t using 2 <;> apply add_comm theorem cutExpand_add_single {a' a : α} (s : Multiset α) (h : r a' a) : CutExpand r (s + {a'}) (s + {a}) := diff --git a/Mathlib/Logic/Lemmas.lean b/Mathlib/Logic/Lemmas.lean index df76040ca70913..0266bda809af21 100644 --- a/Mathlib/Logic/Lemmas.lean +++ b/Mathlib/Logic/Lemmas.lean @@ -66,5 +66,5 @@ lemma Prop.forall {f : Prop → Prop} : (∀ p, f p) ↔ f True ∧ f False := ⟨fun h ↦ ⟨h _, h _⟩, by rintro ⟨h₁, h₀⟩ p; by_cases hp : p <;> simp only [hp] <;> assumption⟩ lemma Prop.exists {f : Prop → Prop} : (∃ p, f p) ↔ f True ∨ f False := - ⟨fun ⟨p, h⟩ ↦ by refine (em p).imp ?_ ?_ <;> intro H <;> convert h <;> simp [H], + ⟨fun ⟨p, h⟩ ↦ by refine (em p).imp ?_ ?_ <;> intro H <;> convert! h <;> simp [H], by rintro (h | h) <;> exact ⟨_, h⟩⟩ diff --git a/Mathlib/MeasureTheory/Constructions/BorelSpace/Metric.lean b/Mathlib/MeasureTheory/Constructions/BorelSpace/Metric.lean index 928e78d8ca93b4..2a9879dab3d43c 100644 --- a/Mathlib/MeasureTheory/Constructions/BorelSpace/Metric.lean +++ b/Mathlib/MeasureTheory/Constructions/BorelSpace/Metric.lean @@ -141,7 +141,7 @@ theorem tendsto_measure_cthickening {μ : Measure α} {s : Set α} apply Tendsto.congr' _ tendsto_const_nhds filter_upwards [self_mem_nhdsWithin (α := ℝ)] with _ hr rw [cthickening_of_nonpos hr] - convert B.sup A + convert! B.sup A exact (nhdsLE_sup_nhdsGT 0).symm /-- If a closed set has a closed thickening with finite measure, then the measure of its closed @@ -149,7 +149,7 @@ theorem tendsto_measure_cthickening {μ : Measure α} {s : Set α} theorem tendsto_measure_cthickening_of_isClosed {μ : Measure α} {s : Set α} (hs : ∃ R > 0, μ (cthickening R s) ≠ ∞) (h's : IsClosed s) : Tendsto (fun r => μ (cthickening r s)) (𝓝 0) (𝓝 (μ s)) := by - convert tendsto_measure_cthickening hs + convert! tendsto_measure_cthickening hs exact h's.closure_eq.symm /-- If a set has a thickening with finite measure, then the measures of its `r`-thickenings @@ -166,7 +166,7 @@ theorem tendsto_measure_thickening {μ : Measure α} {s : Set α} theorem tendsto_measure_thickening_of_isClosed {μ : Measure α} {s : Set α} (hs : ∃ R > 0, μ (thickening R s) ≠ ∞) (h's : IsClosed s) : Tendsto (fun r => μ (thickening r s)) (𝓝[>] 0) (𝓝 (μ s)) := by - convert tendsto_measure_thickening hs + convert! tendsto_measure_thickening hs exact h's.closure_eq.symm variable [SecondCountableTopology α] diff --git a/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean b/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean index 73187d3cc152bd..1c5923dd759157 100644 --- a/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean +++ b/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean @@ -405,8 +405,8 @@ theorem Dense.borel_eq_generateFrom_Ioc_mem_aux {α : Type*} [TopologicalSpace [OrderTopology α] [SecondCountableTopology α] {s : Set α} (hd : Dense s) (hbot : ∀ x, IsTop x → x ∈ s) (hIoo : ∀ x y : α, x < y → Ioo x y = ∅ → x ∈ s) : borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ioc l u = S } := by - convert hd.orderDual.borel_eq_generateFrom_Ico_mem_aux hbot fun x y hlt he => hIoo y x hlt _ - using 2 + convert! + hd.orderDual.borel_eq_generateFrom_Ico_mem_aux hbot fun x y hlt he => hIoo y x hlt _ using 2 · ext s constructor <;> rintro ⟨l, hl, u, hu, hlt, rfl⟩ exacts [⟨u, hu, l, hl, hlt, Ico_toDual⟩, ⟨u, hu, l, hl, hlt, Ioc_toDual⟩] @@ -642,7 +642,7 @@ section LinearOrder variable [LinearOrder α] [OrderTopology α] [SecondCountableTopology α] theorem measurable_of_Iio {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Iio x)) : Measurable f := by - convert measurable_generateFrom (α := δ) _ + convert! measurable_generateFrom (α := δ) _ · exact BorelSpace.measurable_eq.trans (borel_eq_generateFrom_Iio _) · rintro _ ⟨x, rfl⟩; exact hf x @@ -651,7 +651,7 @@ theorem UpperSemicontinuous.measurable [TopologicalSpace δ] [OpensMeasurableSpa measurable_of_Iio fun y => (hf.isOpen_preimage y).measurableSet theorem measurable_of_Ioi {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Ioi x)) : Measurable f := by - convert measurable_generateFrom (α := δ) _ + convert! measurable_generateFrom (α := δ) _ · exact BorelSpace.measurable_eq.trans (borel_eq_generateFrom_Ioi _) · rintro _ ⟨x, rfl⟩; exact hf x @@ -717,7 +717,7 @@ theorem Measurable.isLUB_of_mem {ι} [Countable ι] {f : ι → δ → α} {g g' classical rcases isEmpty_or_nonempty ι with hι | ⟨⟨i⟩⟩ · rcases eq_empty_or_nonempty s with rfl | ⟨x, hx⟩ - · convert g'_meas + · convert! g'_meas rwa [compl_empty, eqOn_univ] at hg' · have A : ∀ b ∈ s, IsBot (g b) := by simpa using hg have B : ∀ b ∈ s, g b = g x := by diff --git a/Mathlib/MeasureTheory/Constructions/BorelSpace/Real.lean b/Mathlib/MeasureTheory/Constructions/BorelSpace/Real.lean index 43f5a1ebb40c3d..a1acd8232edb4e 100644 --- a/Mathlib/MeasureTheory/Constructions/BorelSpace/Real.lean +++ b/Mathlib/MeasureTheory/Constructions/BorelSpace/Real.lean @@ -87,27 +87,27 @@ theorem borel_eq_generateFrom_Ici_rat : borel ℝ = .generateFrom (⋃ a : ℚ, theorem isPiSystem_Ioo_rat : IsPiSystem (⋃ (a : ℚ) (b : ℚ) (_ : a < b), {Ioo (a : ℝ) (b : ℝ)}) := by - convert isPiSystem_Ioo ((↑) : ℚ → ℝ) ((↑) : ℚ → ℝ) + convert! isPiSystem_Ioo ((↑) : ℚ → ℝ) ((↑) : ℚ → ℝ) ext x simp [eq_comm] theorem isPiSystem_Iio_rat : IsPiSystem (⋃ a : ℚ, {Iio (a : ℝ)}) := by - convert isPiSystem_image_Iio (((↑) : ℚ → ℝ) '' univ) + convert! isPiSystem_image_Iio (((↑) : ℚ → ℝ) '' univ) ext x simp only [iUnion_singleton_eq_range, mem_range, image_univ, mem_image, exists_exists_eq_and] theorem isPiSystem_Ioi_rat : IsPiSystem (⋃ a : ℚ, {Ioi (a : ℝ)}) := by - convert isPiSystem_image_Ioi (((↑) : ℚ → ℝ) '' univ) + convert! isPiSystem_image_Ioi (((↑) : ℚ → ℝ) '' univ) ext x simp only [iUnion_singleton_eq_range, mem_range, image_univ, mem_image, exists_exists_eq_and] theorem isPiSystem_Iic_rat : IsPiSystem (⋃ a : ℚ, {Iic (a : ℝ)}) := by - convert isPiSystem_image_Iic (((↑) : ℚ → ℝ) '' univ) + convert! isPiSystem_image_Iic (((↑) : ℚ → ℝ) '' univ) ext x simp only [iUnion_singleton_eq_range, mem_range, image_univ, mem_image, exists_exists_eq_and] theorem isPiSystem_Ici_rat : IsPiSystem (⋃ a : ℚ, {Ici (a : ℝ)}) := by - convert isPiSystem_image_Ici (((↑) : ℚ → ℝ) '' univ) + convert! isPiSystem_image_Ici (((↑) : ℚ → ℝ) '' univ) ext x simp only [iUnion_singleton_eq_range, mem_range, image_univ, mem_image, exists_exists_eq_and] @@ -362,7 +362,7 @@ set_option linter.deprecated false in (since := "2026-04-30")] theorem Measurable.ennreal_tsum' {ι} [Countable ι] {f : ι → α → ℝ≥0∞} (h : ∀ i, Measurable (f i)) : Measurable (∑' i, f i) := by - convert Measurable.ennreal_tsum h with x + convert! Measurable.ennreal_tsum h with x exact tsum_apply (Pi.summable.2 fun _ => ENNReal.summable) set_option linter.deprecated false in diff --git a/Mathlib/MeasureTheory/Constructions/Cylinders.lean b/Mathlib/MeasureTheory/Constructions/Cylinders.lean index 694b449be7aca8..ab79a1f5f8f117 100644 --- a/Mathlib/MeasureTheory/Constructions/Cylinders.lean +++ b/Mathlib/MeasureTheory/Constructions/Cylinders.lean @@ -120,10 +120,10 @@ theorem comap_eval_le_generateFrom_squareCylinders_singleton simp only [mem_setOf_eq, mem_image, mem_univ_pi, forall_exists_index, and_imp] intro t ht h classical - refine ⟨fun j ↦ if hji : j = i then by convert t else univ, fun j ↦ ?_, ?_⟩ + refine ⟨fun j ↦ if hji : j = i then by convert! t else univ, fun j ↦ ?_, ?_⟩ · by_cases hji : j = i · simp only [hji, eq_mpr_eq_cast, dif_pos] - convert ht + convert! ht simp only [cast_heq] · simp only [hji, not_false_iff, dif_neg, MeasurableSet.univ] · #adaptation_note /-- Before https://github.com/leanprover/lean4/pull/13166 diff --git a/Mathlib/MeasureTheory/Constructions/Pi.lean b/Mathlib/MeasureTheory/Constructions/Pi.lean index 232c8330843009..0b0f4c5a3436c7 100644 --- a/Mathlib/MeasureTheory/Constructions/Pi.lean +++ b/Mathlib/MeasureTheory/Constructions/Pi.lean @@ -928,8 +928,9 @@ theorem measurePreserving_arrowCongr' {α₁ β₁ α₂ β₂ : Type*} [Fintype MeasurePreserving (MeasurableEquiv.arrowCongr' eα eβ) (Measure.pi fun i ↦ μ i) (Measure.pi fun i ↦ ν i) := by classical - convert (measurePreserving_piCongrLeft (fun i : α₂ ↦ ν i) eα).comp - (measurePreserving_pi μ (fun i : α₁ ↦ ν (eα i)) hm) + convert! + (measurePreserving_piCongrLeft (fun i : α₂ ↦ ν i) eα).comp + (measurePreserving_pi μ (fun i : α₁ ↦ ν (eα i)) hm) simp only [MeasurableEquiv.arrowCongr', Equiv.arrowCongr', Equiv.arrowCongr, EquivLike.coe_coe, comp_def, MeasurableEquiv.coe_mk, Equiv.coe_fn_mk, MeasurableEquiv.piCongrLeft, Equiv.piCongrLeft, Equiv.symm_symm, Equiv.piCongrLeft', eq_rec_constant, Equiv.coe_fn_symm_mk] diff --git a/Mathlib/MeasureTheory/Constructions/Polish/Basic.lean b/Mathlib/MeasureTheory/Constructions/Polish/Basic.lean index 7eee18429465a9..58e8299525bb86 100644 --- a/Mathlib/MeasureTheory/Constructions/Polish/Basic.lean +++ b/Mathlib/MeasureTheory/Constructions/Polish/Basic.lean @@ -319,7 +319,7 @@ theorem _root_.MeasurableSet.analyticSet {α : Type*} [t : TopologicalSpace α] ∃ t' : TopologicalSpace α, t' ≤ t ∧ @PolishSpace α t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s := hs.isClopenable have A := @IsClosed.analyticSet α t' t'_polish s s_closed - convert @AnalyticSet.image_of_continuous α t' α t s A id (continuous_id_of_le t't) + convert! @AnalyticSet.image_of_continuous α t' α t s A id (continuous_id_of_le t't) simp only [id, image_id'] /-- Given a Borel-measurable function from a Polish space to a second-countable space, there exists @@ -364,7 +364,7 @@ protected lemma AnalyticSet.preimage {X Y : Type*} [TopologicalSpace X] [Topolog AnalyticSet (f ⁻¹' s) := by rcases analyticSet_iff_exists_polishSpace_range.1 hs with ⟨Z, _, _, g, hg, rfl⟩ have : IsClosed {x : X × Z | f x.1 = g x.2} := isClosed_eq hf.fst' hg.snd' - convert this.analyticSet.image_of_continuous continuous_fst + convert! this.analyticSet.image_of_continuous continuous_fst ext x simp [eq_comm] @@ -462,7 +462,7 @@ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α] -- by design, the cylinders around these points have images which are not Borel-separable. have M : ∀ n, ¬MeasurablySeparable (f '' cylinder x n) (g '' cylinder y n) := by intro n - convert (p n).2 using 3 + convert! (p n).2 using 3 · rw [pn_fst, ← mem_cylinder_iff_eq, mem_cylinder_iff] intro i hi rw [hx] @@ -716,7 +716,7 @@ theorem MeasureTheory.measurableSet_range_of_continuous_injective {β : Type*} [ exact ball_mem_nhds _ (half_pos (u_pos n)) have diam_s : diam s ≤ u n := by apply (diam_mono hs isBounded_ball).trans - convert diam_ball (x := y) (half_pos (u_pos n)).le + convert! diam_ball (x := y) (half_pos (u_pos n)).le ring refine mem_iUnion.2 ⟨⟨s, sb⟩, ?_⟩ refine mem_iUnion.2 ⟨⟨isBounded_ball.subset hs, diam_s⟩, ?_⟩ @@ -888,7 +888,7 @@ theorem MeasureTheory.borel_eq_borel_of_le {t t' : TopologicalSpace γ} have e := @Continuous.measurableEmbedding _ _ (@borel _ t') t' _ _ (@BorelSpace.mk _ _ (borel γ) rfl) t _ (@borel _ t) (@BorelSpace.mk _ t (@borel _ t) rfl) (continuous_id_of_le hle) injective_id - convert e.measurableSet_image.2 hs + convert! e.measurableSet_image.2 hs simp only [id_eq, image_id'] /-- In a Polish space, a set is clopenable if and only if it is Borel-measurable. -/ diff --git a/Mathlib/MeasureTheory/Constructions/Polish/StronglyMeasurable.lean b/Mathlib/MeasureTheory/Constructions/Polish/StronglyMeasurable.lean index cad138632b2913..1676161053d094 100644 --- a/Mathlib/MeasureTheory/Constructions/Polish/StronglyMeasurable.lean +++ b/Mathlib/MeasureTheory/Constructions/Polish/StronglyMeasurable.lean @@ -45,7 +45,7 @@ theorem measurableSet_exists_tendsto [IsCompletelyPseudoMetrizableSpace E] have : IsCompletelyPseudoMetrizableSpace s := isClosed_closure.isCompletelyPseudoMetrizableSpace let g i x : s := ⟨f i x, subset_closure <| mem_iUnion.2 ⟨i, ⟨x, rfl⟩⟩⟩ have mg i : Measurable (g i) := (hf i).measurable.subtype_mk - convert MeasureTheory.measurableSet_exists_tendsto (l := l) mg with x + convert! MeasureTheory.measurableSet_exists_tendsto (l := l) mg with x refine ⟨fun ⟨c, hc⟩ ↦ ⟨⟨c, ?_⟩, tendsto_subtype_rng.2 hc⟩, fun ⟨c, hc⟩ ↦ ⟨c, tendsto_subtype_rng.1 hc⟩⟩ exact mem_closure_of_tendsto hc (Eventually.of_forall fun i ↦ mem_iUnion.2 ⟨i, ⟨x, rfl⟩⟩) diff --git a/Mathlib/MeasureTheory/Covering/Besicovitch.lean b/Mathlib/MeasureTheory/Covering/Besicovitch.lean index 0752545b875445..3b7041eede15f7 100644 --- a/Mathlib/MeasureTheory/Covering/Besicovitch.lean +++ b/Mathlib/MeasureTheory/Covering/Besicovitch.lean @@ -441,7 +441,7 @@ theorem color_lt {i : Ordinal.{u}} (hi : i < p.lastStep) {N : ℕ} have I : (a : ℕ) < N := ha have J : G (Fin.last N) = i := by dsimp; simp only [G, if_true] have K : G a = g a := by simp [G, I.ne] - convert dist_le_add_of_nonempty_closedBall_inter_closedBall (hg _ I).2.1 } + convert! dist_le_add_of_nonempty_closedBall_inter_closedBall (hg _ I).2.1 } -- this is a contradiction exact hN.false sc @@ -736,7 +736,7 @@ theorem exists_disjoint_closedBall_covering_ae_of_finiteMeasure_aux (μ : Measur · exact ht.2.2 p h'p · rcases Finset.mem_image.1 h'p with ⟨p', p'v, rfl⟩ exact (hr p' (vs' p'v)).1.1 - · convert hμv using 2 + · convert! hμv using 2 rw [Finset.set_biUnion_union, ← diff_diff, Finset.set_biUnion_finset_image] /- Define `F` associating to a finite good covering the above enlarged good covering, covering a proportion `1/(N+1)` of leftover points. Iterating `F`, one will get larger and larger good diff --git a/Mathlib/MeasureTheory/Covering/BesicovitchVectorSpace.lean b/Mathlib/MeasureTheory/Covering/BesicovitchVectorSpace.lean index 93ebccfc6e2d03..932bfe42ec0516 100644 --- a/Mathlib/MeasureTheory/Covering/BesicovitchVectorSpace.lean +++ b/Mathlib/MeasureTheory/Covering/BesicovitchVectorSpace.lean @@ -122,7 +122,7 @@ theorem card_le_of_separated (s : Finset E) (hs : ∀ c ∈ s, ‖c‖ ≤ 2) rintro c hc d hd hcd apply ball_disjoint_ball rw [dist_eq_norm] - convert h c hc d hd hcd + convert! h c hc d hd hcd norm_num have A_subset : A ⊆ ball (0 : E) ρ := by refine iUnion₂_subset fun x hx => ?_ @@ -410,7 +410,7 @@ theorem exists_normalized_aux3 {N : ℕ} {τ : ℝ} (a : SatelliteConfig E N τ) change i = last N at iN rw [iN, lastc, norm_zero] at hi exact lt_irrefl _ (zero_le_two.trans_lt hi) - convert (a.hlast i this).1 using 1 + convert! (a.hlast i this).1 using 1 rw [dist_eq_norm, lastc, sub_zero] have hj : 2 < ‖a.c j‖ := hi.trans_le hij set s := ‖a.c i‖ diff --git a/Mathlib/MeasureTheory/Covering/Differentiation.lean b/Mathlib/MeasureTheory/Covering/Differentiation.lean index f0de450ec0453b..e90d23eca85b0d 100644 --- a/Mathlib/MeasureTheory/Covering/Differentiation.lean +++ b/Mathlib/MeasureTheory/Covering/Differentiation.lean @@ -696,7 +696,7 @@ theorem ae_tendsto_rnDeriv : have C : ∀ᵐ x ∂μ, Tendsto (fun a => t a / μ a) (v.filterAt x) (𝓝 (t.rnDeriv μ x)) := v.ae_tendsto_rnDeriv_of_absolutelyContinuous (withDensity_absolutelyContinuous _ _) filter_upwards [A, B, C] with _ Ax Bx Cx - convert Ax.add Cx using 1 + convert! Ax.add Cx using 1 · ext1 a conv_lhs => rw [eq_add] simp only [Pi.add_apply, coe_add, ENNReal.add_div] @@ -756,12 +756,12 @@ theorem ae_tendsto_lintegral_div' {f : α → ℝ≥0∞} (hf : Measurable f) (h theorem ae_tendsto_lintegral_div {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (h'f : (∫⁻ y, f y ∂μ) ≠ ∞) : ∀ᵐ x ∂μ, Tendsto (fun a => (∫⁻ y in a, f y ∂μ) / μ a) (v.filterAt x) (𝓝 (f x)) := by have A : (∫⁻ y, hf.mk f y ∂μ) ≠ ∞ := by - convert h'f using 1 + convert! h'f using 1 apply lintegral_congr_ae exact hf.ae_eq_mk.symm filter_upwards [v.ae_tendsto_lintegral_div' hf.measurable_mk A, hf.ae_eq_mk] with x hx h'x rw [h'x] - convert hx using 1 + convert! hx using 1 ext1 a congr 1 apply lintegral_congr_ae diff --git a/Mathlib/MeasureTheory/Covering/LiminfLimsup.lean b/Mathlib/MeasureTheory/Covering/LiminfLimsup.lean index e36abca910d255..a645729572b49b 100644 --- a/Mathlib/MeasureTheory/Covering/LiminfLimsup.lean +++ b/Mathlib/MeasureTheory/Covering/LiminfLimsup.lean @@ -198,7 +198,7 @@ theorem blimsup_cthickening_mul_ae_eq (p : ℕ → Prop) (s : ℕ → Set α) {M (blimsup (fun i => cthickening (r i) (s i)) atTop p : Set α) := by clear p hr r; intro p r hr have hr' : Tendsto (fun i => M * r i) atTop (𝓝[>] 0) := by - convert TendstoNhdsWithinIoi.const_mul hM hr <;> simp only [mul_zero] + convert! TendstoNhdsWithinIoi.const_mul hM hr <;> simp only [mul_zero] refine eventuallyLE_antisymm_iff.mpr ⟨?_, ?_⟩ · exact blimsup_cthickening_ae_le_of_eventually_mul_le μ p (inv_pos.mpr hM) hr' (Eventually.of_forall fun i => by rw [inv_mul_cancel_left₀ hM.ne' (r i)]) @@ -247,7 +247,7 @@ theorem blimsup_thickening_mul_ae_eq_aux (p : ℕ → Prop) (s : ℕ → Set α) (blimsup (fun i => thickening (r i) (s i)) atTop p : Set α) := by have h₁ := blimsup_cthickening_ae_eq_blimsup_thickening (s := s) μ hr hr' have h₂ := blimsup_cthickening_mul_ae_eq μ p s hM r hr - replace hr : Tendsto (fun i => M * r i) atTop (𝓝 0) := by convert hr.const_mul M; simp + replace hr : Tendsto (fun i => M * r i) atTop (𝓝 0) := by convert! hr.const_mul M; simp replace hr' : ∀ᶠ i in atTop, p i → 0 < M * r i := hr'.mono fun i hi hip ↦ mul_pos hM (hi hip) have h₃ := blimsup_cthickening_ae_eq_blimsup_thickening (s := s) μ hr hr' exact h₃.symm.trans (h₂.trans h₁) diff --git a/Mathlib/MeasureTheory/Covering/Vitali.lean b/Mathlib/MeasureTheory/Covering/Vitali.lean index 1231404865d3c7..8c3e5c388fab3e 100644 --- a/Mathlib/MeasureTheory/Covering/Vitali.lean +++ b/Mathlib/MeasureTheory/Covering/Vitali.lean @@ -187,6 +187,43 @@ theorem exists_disjoint_subfamily_covering_enlargement_closedBall rcases A b ⟨rb.1, rb.2⟩ with ⟨c, cu, _⟩ exact ⟨c, cu, by simp only [closedBall_eq_empty.2 h'a, empty_subset]⟩ +/- Note: it seems easier to do the analogous proof again than to apply the previous one, because the +interior of a closed ball may not equal the open ball. -/ + +/-- Vitali covering theorem, open balls version: given a family `t` of balls, one can +extract a disjoint subfamily `u ⊆ t` so that all balls in `t` are covered by the τ-times +dilations of balls in `u`, for some `τ > 3`. -/ +theorem exists_disjoint_subfamily_covering_enlargement_ball + [PseudoMetricSpace α] (t : Set ι) + (x : ι → α) (r : ι → ℝ) (R : ℝ) (hr : ∀ a ∈ t, r a ≤ R) (τ : ℝ) (hτ : 3 < τ) : + ∃ u ⊆ t, + (u.PairwiseDisjoint fun a => ball (x a) (r a)) ∧ + ∀ a ∈ t, ∃ b ∈ u, ball (x a) (r a) ⊆ ball (x b) (τ * r b) := by + rcases eq_empty_or_nonempty t with (rfl | _) + · exact ⟨∅, Subset.refl _, pairwiseDisjoint_empty, by simp⟩ + by_cases! ht : ∀ a ∈ t, r a ≤ 0 + · exact ⟨t, Subset.rfl, fun a ha b _ _ => by + simp only [ball_eq_empty.2 (ht a ha), empty_disjoint, Function.onFun], + fun a ha => ⟨a, ha, by simp only [ball_eq_empty.2 (ht a ha), empty_subset]⟩⟩ + let t' := { a ∈ t | 0 < r a } + rcases exists_disjoint_subfamily_covering_enlargement (fun a => ball (x a) (r a)) t' r + ((τ - 1) / 2) (by linarith) (fun a ha => ha.2.le) R (fun a ha => hr a ha.1) fun a ha => + ⟨x a, mem_ball_self ha.2⟩ with + ⟨u, ut', u_disj, hu⟩ + have A : ∀ a ∈ t', ∃ b ∈ u, ball (x a) (r a) ⊆ ball (x b) (τ * r b) := by + intro a ha + rcases hu a ha with ⟨b, bu, hb, rb⟩ + refine ⟨b, bu, ?_⟩ + have : dist (x a) (x b) < r a + r b := dist_lt_add_of_nonempty_ball_inter_ball hb + apply ball_subset_ball' + linarith + refine ⟨u, ut'.trans fun a ha => ha.1, u_disj, fun a ha => ?_⟩ + rcases lt_or_ge 0 (r a) with (h'a | h'a) + · exact A a ⟨ha, h'a⟩ + · rcases ht with ⟨b, rb⟩ + rcases A b ⟨rb.1, rb.2⟩ with ⟨c, cu, _⟩ + exact ⟨c, cu, by simp only [ball_eq_empty.2 h'a, empty_subset]⟩ + /-- The measurable **Vitali covering theorem**. Assume one is given a family `t` of closed sets with nonempty interior, such that each `a ∈ t` is @@ -457,7 +494,7 @@ protected def vitaliFamily [PseudoMetricSpace α] [MeasurableSpace α] [OpensMea exact t'_disj hq hq' (ne_of_apply_ne _ hqq') · rintro - ⟨q, hq, rfl⟩ exact (t't hq).2.2.2.2.1 - · convert μt' using 3 + · convert! μt' using 3 rw [biUnion_image] end Vitali diff --git a/Mathlib/MeasureTheory/Function/AEMeasurableOrder.lean b/Mathlib/MeasureTheory/Function/AEMeasurableOrder.lean index 3cdb2645007327..6162320fd09227 100644 --- a/Mathlib/MeasureTheory/Function/AEMeasurableOrder.lean +++ b/Mathlib/MeasureTheory/Function/AEMeasurableOrder.lean @@ -75,7 +75,7 @@ theorem MeasureTheory.aemeasurable_of_exist_almost_disjoint_supersets {α : Type have : ∀ᵐ x ∂μ, x ∉ t := by have : μ t = 0 := le_antisymm μt bot_le change μ _ = 0 - convert this + convert! this ext y simp only [mem_setOf_eq, mem_compl_iff, not_notMem] filter_upwards [this] with x hx diff --git a/Mathlib/MeasureTheory/Function/AbsolutelyContinuous.lean b/Mathlib/MeasureTheory/Function/AbsolutelyContinuous.lean index df91f7a9ea0f7e..4c5921c67f0353 100644 --- a/Mathlib/MeasureTheory/Function/AbsolutelyContinuous.lean +++ b/Mathlib/MeasureTheory/Function/AbsolutelyContinuous.lean @@ -81,7 +81,7 @@ def totalLengthFilter : Filter (ℕ × (ℕ → X × X)) := Filter.comap lemma hasBasis_totalLengthFilter : totalLengthFilter.HasBasis (fun (ε : ℝ) => 0 < ε) (fun (ε : ℝ) => {E : ℕ × (ℕ → X × X) | ∑ i ∈ Finset.range E.1, dist (E.2 i).1 (E.2 i).2 < ε}) := by - convert Filter.HasBasis.comap (α := ℝ) _ (nhds_basis_Ioo_pos _) using 1 + convert! Filter.HasBasis.comap (α := ℝ) _ (nhds_basis_Ioo_pos _) using 1 ext ε E simp only [mem_setOf_eq, zero_sub, zero_add, mem_preimage, mem_Ioo, iff_and_self] suffices 0 ≤ ∑ i ∈ Finset.range E.1, dist (E.2 i).1 (E.2 i).2 by grind @@ -119,7 +119,7 @@ lemma tendsto_volume_totalLengthFilter_nhds_zero : totalLengthFilter (𝓝 0) := by apply tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds (h := fun E ↦ ENNReal.ofReal (∑ i ∈ Finset.range E.1, (dist (E.2 i).1 (E.2 i).2))) - · convert ENNReal.tendsto_ofReal (Filter.tendsto_comap) + · convert! ENNReal.tendsto_ofReal (Filter.tendsto_comap) simp · intro; simp · intro E @@ -220,7 +220,7 @@ theorem const_mul {f : ℝ → ℝ} (α : ℝ) (hf : AbsolutelyContinuousOnInter lemma uniformity_eq_comap_totalLengthFilter : uniformity X = comap (fun x ↦ (1, fun _ ↦ x)) totalLengthFilter := by refine Filter.HasBasis.eq_of_same_basis Metric.uniformity_basis_dist ?_ - convert hasBasis_totalLengthFilter.comap _ + convert! hasBasis_totalLengthFilter.comap _ simp /-- If `f` is absolutely continuous on `uIcc a b`, then `f` is uniformly continuous on `uIcc a b`. @@ -229,7 +229,7 @@ theorem uniformContinuousOn (hf : AbsolutelyContinuousOnInterval f a b) : UniformContinuousOn f (uIcc a b) := by simp only [UniformContinuousOn, Filter.tendsto_iff_comap, uniformity_eq_comap_totalLengthFilter] simp only [AbsolutelyContinuousOnInterval, Filter.tendsto_iff_comap] at hf - convert Filter.comap_mono hf + convert! Filter.comap_mono hf · simp only [comap_inf, comap_principal] congr ext p @@ -339,7 +339,7 @@ theorem boundedVariationOn (hf : AbsolutelyContinuousOnInterval f a b) : set δ' := (b - a) / (n + 1) have hδ₃ : δ' < δ := by dsimp only [δ'] - convert mul_lt_mul_of_pos_right hn hab₁ using 1 <;> field + convert! mul_lt_mul_of_pos_right hn hab₁ using 1 <;> field have h_mono : Monotone fun (i : ℕ) ↦ a + ↑i * δ' := by apply Monotone.const_add apply Monotone.mul_const Nat.mono_cast @@ -348,7 +348,7 @@ theorem boundedVariationOn (hf : AbsolutelyContinuousOnInterval f a b) : -- The variation of `f` on `[a, b]` is the sum of the variations on these subintervals. have v_sum : eVariationOn f (Icc a b) = ∑ i ∈ Finset.range (n + 1), eVariationOn f (Icc (a + i * δ') (a + (i + 1) * δ')) := by - convert eVariationOn.sum' f (I := fun i ↦ a + i * δ') h_mono |>.symm + convert! eVariationOn.sum' f (I := fun i ↦ a + i * δ') h_mono |>.symm · simp · simp only [Nat.cast_add, Nat.cast_one, δ']; field · norm_cast @@ -366,10 +366,10 @@ theorem boundedVariationOn (hf : AbsolutelyContinuousOnInterval f a b) : intro i hi constructor <;> exact this (hp₂ _) · rw [PairwiseDisjoint] - convert hp₁.pairwise_disjoint_on_Ioc_succ.set_pairwise (Finset.range p.1) using 3 + convert! hp₁.pairwise_disjoint_on_Ioc_succ.set_pairwise (Finset.range p.1) using 3 rw [uIoc_of_le (hp₁ (by lia)), Nat.succ_eq_succ] · suffices p.2.val p.1 - p.2.val 0 < δ by - convert this + convert! this rw [← Finset.sum_range_sub] congr; ext i rw [dist_comm, Real.dist_eq, abs_eq_self.mpr] @@ -383,7 +383,7 @@ theorem boundedVariationOn (hf : AbsolutelyContinuousOnInterval f a b) : have not_top : ∑ i ∈ Finset.range p.1, edist (f (p.2.val (i + 1))) (f (p.2.val i)) ≠ ⊤ := by simp [edist_ne_top] rw [← ENNReal.ofReal_toReal not_top] - convert ENNReal.ofReal_le_ofReal (veq.symm ▸ vf.le) + convert! ENNReal.ofReal_le_ofReal (veq.symm ▸ vf.le) simp -- Reduce to goal that the variation of `f` on each of these subintervals is finite. simp only [BoundedVariationOn, v_sum, ne_eq, ENNReal.sum_eq_top, Finset.mem_range, not_exists, @@ -394,10 +394,10 @@ theorem boundedVariationOn (hf : AbsolutelyContinuousOnInterval f a b) : fun hC ↦ by simp [hC] at this -- Verify that `[a + i * δ', a + (i + 1) * δ']` is indeed a subinterval of `[a, b]` apply v_each - · convert h_mono (show 0 ≤ i by lia); simp - · convert h_mono (show i ≤ i + 1 by lia); norm_cast + · convert! h_mono (show 0 ≤ i by lia); simp + · convert! h_mono (show i ≤ i + 1 by lia); norm_cast · rw [add_mul, ← add_assoc]; simpa - · convert h_mono (show i + 1 ≤ n + 1 by lia) + · convert! h_mono (show i + 1 ≤ n + 1 by lia) · norm_cast · simp only [Nat.cast_add, Nat.cast_one, δ']; field diff --git a/Mathlib/MeasureTheory/Function/ConditionalExpectation/Basic.lean b/Mathlib/MeasureTheory/Function/ConditionalExpectation/Basic.lean index 6b8b980c25c7f5..fe5c2e6d0b1168 100644 --- a/Mathlib/MeasureTheory/Function/ConditionalExpectation/Basic.lean +++ b/Mathlib/MeasureTheory/Function/ConditionalExpectation/Basic.lean @@ -82,7 +82,7 @@ variable {α β E 𝕜 : Type*} [RCLike 𝕜] {m m₀ : MeasurableSpace α} {μ {s : Set α} section NormedAddCommGroup -variable [NormedAddCommGroup E] [CompleteSpace E] +variable [NormedAddCommGroup E] section NormedSpace variable [NormedSpace ℝ E] @@ -144,7 +144,8 @@ theorem condExp_const (hm : m ≤ m₀) (c : E) [IsFiniteMeasure μ] : μ[fun _ : α ↦ c | m] = fun _ ↦ c := condExp_of_stronglyMeasurable hm stronglyMeasurable_const (integrable_const c) -theorem condExp_ae_eq_condExpL1 (hm : m ≤ m₀) [hμm : SigmaFinite (μ.trim hm)] (f : α → E) : +theorem condExp_ae_eq_condExpL1 [CompleteSpace E] + (hm : m ≤ m₀) [hμm : SigmaFinite (μ.trim hm)] (f : α → E) : μ[f | m] =ᵐ[μ] condExpL1 hm μ f := by rw [condExp_of_sigmaFinite hm] by_cases hfi : Integrable f μ @@ -157,7 +158,8 @@ theorem condExp_ae_eq_condExpL1 (hm : m ≤ m₀) [hμm : SigmaFinite (μ.trim h rw [if_neg hfi, condExpL1_undef hfi] exact (coeFn_zero _ _ _).symm -theorem condExp_ae_eq_condExpL1CLM (hm : m ≤ m₀) [SigmaFinite (μ.trim hm)] (hf : Integrable f μ) : +theorem condExp_ae_eq_condExpL1CLM [CompleteSpace E] + (hm : m ≤ m₀) [SigmaFinite (μ.trim hm)] (hf : Integrable f μ) : μ[f | m] =ᵐ[μ] condExpL1CLM E hm μ (hf.toL1 f) := by refine (condExp_ae_eq_condExpL1 hm f).trans (Eventually.of_forall fun x => ?_) rw [condExpL1_eq hf] @@ -189,6 +191,8 @@ theorem stronglyMeasurable_condExp : StronglyMeasurable[m] (μ[f | m]) := by · exact aestronglyMeasurable_condExpL1.stronglyMeasurable_mk · exact stronglyMeasurable_zero +variable [CompleteSpace E] + @[gcongr] theorem condExp_congr_ae (h : f =ᵐ[μ] g) : μ[f | m] =ᵐ[μ] μ[g | m] := by by_cases hm : m ≤ m₀ @@ -397,7 +401,7 @@ end RCLike end NormedSpace section Real -variable [InnerProductSpace ℝ E] +variable [InnerProductSpace ℝ E] [CompleteSpace E] -- TODO: Generalize via the conditional Jensen inequality lemma eLpNorm_condExp_le : eLpNorm (μ[f | m]) 2 μ ≤ eLpNorm f 2 μ := by @@ -436,7 +440,7 @@ lemma condExp_ofNat (n : ℕ) [n.AtLeastTwo] (f : α → R) : end NormedRing section NormedLatticeAddCommGroup -variable [NormedAddCommGroup E] [CompleteSpace E] [NormedSpace ℝ E] +variable [NormedAddCommGroup E] [NormedSpace ℝ E] /-- **Lebesgue dominated convergence theorem**: sufficient conditions under which almost everywhere convergence of a sequence of functions implies the convergence of their image by @@ -449,6 +453,8 @@ theorem tendsto_condExpL1_of_dominated_convergence (hm : m ≤ m₀) [SigmaFinit Tendsto (fun n => condExpL1 hm μ (fs n)) atTop (𝓝 (condExpL1 hm μ f)) := tendsto_setToFun_of_dominated_convergence _ bound_fs hfs_meas h_int_bound_fs hfs_bound hfs +variable [CompleteSpace E] + /-- If two sequences of functions have a.e. equal conditional expectations at each step, converge and verify dominated convergence hypotheses, then the conditional expectations of their limits are a.e. equal. -/ diff --git a/Mathlib/MeasureTheory/Function/ConditionalExpectation/CondexpL1.lean b/Mathlib/MeasureTheory/Function/ConditionalExpectation/CondexpL1.lean index 93c6d2e2923832..02e96a6e6284dd 100644 --- a/Mathlib/MeasureTheory/Function/ConditionalExpectation/CondexpL1.lean +++ b/Mathlib/MeasureTheory/Function/ConditionalExpectation/CondexpL1.lean @@ -5,6 +5,7 @@ Authors: Rémy Degenne -/ module +public import Mathlib.MeasureTheory.Function.LpSpace.CompleteOfCompleteLp public import Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL2 public import Mathlib.MeasureTheory.Measure.Real @@ -47,7 +48,7 @@ variable {α F F' G G' 𝕜 : Type*} [RCLike 𝕜] [NormedSpace 𝕜 F] -- F' for integrals on a Lp submodule [NormedAddCommGroup F'] - [NormedSpace 𝕜 F'] [NormedSpace ℝ F'] [CompleteSpace F'] + [NormedSpace 𝕜 F'] [NormedSpace ℝ F'] -- G for a Lp add_subgroup [NormedAddCommGroup G] -- G' for integrals on a Lp add_subgroup @@ -122,7 +123,7 @@ theorem norm_condExpIndL1Fin_le (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x refine lintegral_congr_ae ?_ filter_upwards [condExpIndL1Fin_ae_eq_condExpIndSMul hm hs hμs x] with z hz rw [hz] - rw [h_eq, ofReal_norm_eq_enorm] + rw [h_eq, ofReal_norm] exact lintegral_nnnorm_condExpIndSMul_le hm hs hμs x theorem condExpIndL1Fin_disjoint_union (hs : MeasurableSet s) (ht : MeasurableSet t) (hμs : μ s ≠ ∞) @@ -313,14 +314,18 @@ section CondexpL1 variable {m m0 : MeasurableSpace α} {μ : Measure α} {hm : m ≤ m0} [SigmaFinite (μ.trim hm)] {f g : α → F'} {s : Set α} +section CondExpL1CLM + variable (F') /-- Conditional expectation of a function as a linear map from `α →₁[μ] F'` to itself. -/ -def condExpL1CLM (hm : m ≤ m0) (μ : Measure α) [SigmaFinite (μ.trim hm)] : +def condExpL1CLM (hm : m ≤ m0) (μ : Measure α) [CompleteSpace ↑(Lp F' 1 μ)] + [SigmaFinite (μ.trim hm)] : (α →₁[μ] F') →L[ℝ] α →₁[μ] F' := L1.setToL1 (dominatedFinMeasAdditive_condExpInd F' hm μ) variable {F'} +variable [CompleteSpace F'] theorem condExpL1CLM_smul (c : 𝕜) (f : α →₁[μ] F') : condExpL1CLM F' hm μ (c • f) = c • condExpL1CLM F' hm μ f := by @@ -438,17 +443,20 @@ theorem condExpL1CLM_of_aestronglyMeasurable' (f : α →₁[μ] F') (hfm : AESt condExpL1CLM F' hm μ f = f := condExpL1CLM_lpMeas (⟨f, hfm⟩ : lpMeas F' ℝ m 1 μ) +end CondExpL1CLM + +set_option linter.overlappingInstances false in /-- Conditional expectation of a function, in L1. Its value is 0 if the function is not integrable. The function-valued `condExp` should be used instead in most cases. -/ -@[nolint unusedArguments] -- TODO: drop the completeness assumption in the definition, and fix -def condExpL1 [CompleteSpace F'] (hm : m ≤ m0) (μ : Measure α) [SigmaFinite (μ.trim hm)] +def condExpL1 (hm : m ≤ m0) (μ : Measure α) [SigmaFinite (μ.trim hm)] (f : α → F') : α →₁[μ] F' := setToFun μ (condExpInd F' hm μ) (dominatedFinMeasAdditive_condExpInd F' hm μ) f theorem condExpL1_undef (hf : ¬Integrable f μ) : condExpL1 hm μ f = 0 := setToFun_undef (dominatedFinMeasAdditive_condExpInd F' hm μ) hf -theorem condExpL1_eq (hf : Integrable f μ) : condExpL1 hm μ f = condExpL1CLM F' hm μ (hf.toL1 f) := +theorem condExpL1_eq [CompleteSpace F'] + (hf : Integrable f μ) : condExpL1 hm μ f = condExpL1CLM F' hm μ (hf.toL1 f) := setToFun_eq (dominatedFinMeasAdditive_condExpInd F' hm μ) hf @[simp] @@ -459,17 +467,31 @@ theorem condExpL1_zero : condExpL1 hm μ (0 : α → F') = 0 := theorem condExpL1_measure_zero (hm : m ≤ m0) : condExpL1 hm (0 : Measure α) f = 0 := setToFun_measure_zero _ rfl +theorem condExpL1_congr_ae (hm : m ≤ m0) (h : f =ᵐ[μ] g) : + condExpL1 hm μ f = condExpL1 hm μ g := + setToFun_congr_ae _ h + theorem aestronglyMeasurable_condExpL1 {f : α → F'} : AEStronglyMeasurable[m] (condExpL1 hm μ f) μ := by - by_cases hf : Integrable f μ - · rw [condExpL1_eq hf] - exact aestronglyMeasurable_condExpL1CLM _ + by_cases hF' : CompleteSpace (Lp F' 1 μ); swap + · simp only [condExpL1, setToFun, hF', ↓reduceDIte, ZeroMemClass.coe_zero] + apply stronglyMeasurable_zero.aestronglyMeasurable.congr + exact (coeFn_zero _ 1 _).symm + by_cases hf : Integrable f μ; swap · rw [condExpL1_undef hf] exact stronglyMeasurable_zero.aestronglyMeasurable.congr (coeFn_zero ..).symm - -theorem condExpL1_congr_ae (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (h : f =ᵐ[μ] g) : - condExpL1 hm μ f = condExpL1 hm μ g := - setToFun_congr_ae _ h + by_cases hf' : f =ᵐ[μ] 0 + · apply stronglyMeasurable_zero.aestronglyMeasurable.congr + simp only [condExpL1_congr_ae hm hf', condExpL1_zero, ZeroMemClass.coe_zero] + exact (coeFn_zero _ 1 _).symm + have : CompleteSpace F' := by + have : Nontrivial (Lp F' 1 μ) := by + apply nontrivial_of_ne (hf.toL1 f) 0 + grw [ne_eq, Lp.ext_iff, Integrable.coeFn_toL1, coeFn_zero] + exact hf' + exact completeSpace_of_completeSpace_Lp F' 1 μ + rw [condExpL1_eq hf] + exact aestronglyMeasurable_condExpL1CLM _ theorem integrable_condExpL1 (f : α → F') : Integrable (condExpL1 hm μ f) μ := L1.integrable_coeFn _ @@ -477,7 +499,7 @@ theorem integrable_condExpL1 (f : α → F') : Integrable (condExpL1 hm μ f) μ /-- The integral of the conditional expectation `condExpL1` over an `m`-measurable set is equal to the integral of `f` on that set. See also `setIntegral_condExp`, the similar statement for `condExp`. -/ -theorem setIntegral_condExpL1 (hf : Integrable f μ) (hs : MeasurableSet[m] s) : +theorem setIntegral_condExpL1 [CompleteSpace F'] (hf : Integrable f μ) (hs : MeasurableSet[m] s) : ∫ x in s, condExpL1 hm μ f x ∂μ = ∫ x in s, f x ∂μ := by simp_rw [condExpL1_eq hf] rw [setIntegral_condExpL1CLM (hf.toL1 f) hs] @@ -498,7 +520,7 @@ theorem condExpL1_sub (hf : Integrable f μ) (hg : Integrable g μ) : condExpL1 hm μ (f - g) = condExpL1 hm μ f - condExpL1 hm μ g := setToFun_sub _ hf hg -theorem condExpL1_of_aestronglyMeasurable' (hfm : AEStronglyMeasurable[m] f μ) +theorem condExpL1_of_aestronglyMeasurable' [CompleteSpace F'] (hfm : AEStronglyMeasurable[m] f μ) (hfi : Integrable f μ) : condExpL1 hm μ f =ᵐ[μ] f := by rw [condExpL1_eq hfi] refine EventuallyEq.trans ?_ (Integrable.coeFn_toL1 hfi) @@ -507,7 +529,7 @@ theorem condExpL1_of_aestronglyMeasurable' (hfm : AEStronglyMeasurable[m] f μ) theorem condExpL1_mono {E} [NormedAddCommGroup E] [PartialOrder E] [ClosedIciTopology E] [IsOrderedAddMonoid E] - [CompleteSpace E] [NormedSpace ℝ E] [IsOrderedModule ℝ E] {f g : α → E} (hf : Integrable f μ) + [NormedSpace ℝ E] [IsOrderedModule ℝ E] {f g : α → E} (hf : Integrable f μ) (hg : Integrable g μ) (hfg : f ≤ᵐ[μ] g) : condExpL1 hm μ f ≤ᵐ[μ] condExpL1 hm μ g := by rw [coeFn_le] diff --git a/Mathlib/MeasureTheory/Function/ConditionalExpectation/RadonNikodym.lean b/Mathlib/MeasureTheory/Function/ConditionalExpectation/RadonNikodym.lean index e526d90c26324f..14f9101d8a0118 100644 --- a/Mathlib/MeasureTheory/Function/ConditionalExpectation/RadonNikodym.lean +++ b/Mathlib/MeasureTheory/Function/ConditionalExpectation/RadonNikodym.lean @@ -139,7 +139,7 @@ lemma toReal_rnDeriv_trim (hm : m ≤ m𝓧) [IsFiniteMeasure μ] [hsf : SigmaFi have : SigmaFinite (@Measure.map _ _ m𝓧 m id ν) := by rwa [← trim_eq_map hm] have h := toReal_rnDeriv_map_ae_eq_trim hμν (measurable_id'' hm) simp_rw [MeasurableSpace.comap_id, id_def, trim_eq_map] at h - convert h <;> rw [MeasurableSpace.comap_id] + convert! h <;> rw [MeasurableSpace.comap_id] /-- The Radon-Nikodym derivative `∂(μ.trim hm)/∂(ν.trim hm)` of the trimmed measures (for `hm : m ≤ m0` stating that `m` is a sub-sigma-algebra of `m0`) is a.e.-equal to the diff --git a/Mathlib/MeasureTheory/Function/ConditionalExpectation/Real.lean b/Mathlib/MeasureTheory/Function/ConditionalExpectation/Real.lean index 3940c8db23ca6b..b509fb5b6cbecd 100644 --- a/Mathlib/MeasureTheory/Function/ConditionalExpectation/Real.lean +++ b/Mathlib/MeasureTheory/Function/ConditionalExpectation/Real.lean @@ -100,7 +100,7 @@ theorem integral_abs_condExp_le (f : α → ℝ) : ∫ x, |(μ[f | m]) x| ∂μ smul_eq_mul, mul_zero] positivity rw [integral_eq_lintegral_of_nonneg_ae, integral_eq_lintegral_of_nonneg_ae] - · apply ENNReal.toReal_mono <;> simp_rw [← Real.norm_eq_abs, ofReal_norm_eq_enorm] + · apply ENNReal.toReal_mono <;> simp_rw [← Real.norm_eq_abs, ofReal_norm] · exact hfint.2.ne · rw [← eLpNorm_one_eq_lintegral_enorm, ← eLpNorm_one_eq_lintegral_enorm] exact eLpNorm_one_condExp_le_eLpNorm _ @@ -195,8 +195,9 @@ theorem Integrable.uniformIntegrable_condExp {ι : Type*} [IsFiniteMeasure μ] { have : C ^ ENNReal.toReal 1 * μ {x | ENNReal.ofNNReal C ≤ ‖μ[g|ℱ n] x‖₊} ≤ eLpNorm μ[g | ℱ n] 1 μ ^ ENNReal.toReal 1 := by rw [ENNReal.toReal_one, ENNReal.rpow_one] - convert mul_meas_ge_le_pow_eLpNorm μ one_ne_zero ENNReal.one_ne_top - (stronglyMeasurable_condExp.mono (hℱ n)).aestronglyMeasurable C + convert! + mul_meas_ge_le_pow_eLpNorm μ one_ne_zero ENNReal.one_ne_top + (stronglyMeasurable_condExp.mono (hℱ n)).aestronglyMeasurable C · rw [ENNReal.toReal_one, ENNReal.rpow_one, enorm_eq_nnnorm] rw [ENNReal.toReal_one, ENNReal.rpow_one, mul_comm, ← ENNReal.le_div_iff_mul_le (Or.inl (ENNReal.coe_ne_zero.2 hCpos.ne')) diff --git a/Mathlib/MeasureTheory/Function/ConditionalLExpectation.lean b/Mathlib/MeasureTheory/Function/ConditionalLExpectation.lean index 22d78436867250..d2ffb8746fd924 100644 --- a/Mathlib/MeasureTheory/Function/ConditionalLExpectation.lean +++ b/Mathlib/MeasureTheory/Function/ConditionalLExpectation.lean @@ -336,7 +336,7 @@ theorem condLExp_tsum [Countable ι] {X : ι → Ω → ℝ≥0∞} theorem condLExp_finsetSum (s : Finset ι) {X : ι → Ω → ℝ≥0∞} (hX : ∀ i, AEMeasurable[mΩ₀] (X i) P) : P⁻[∑ i ∈ s, X i|mΩ] =ᵐ[P] ∑ i ∈ s, P⁻[X i|mΩ] := by - convert condLExp_tsum mΩ (fun i : s ↦ hX i) + convert! condLExp_tsum mΩ (fun i : s ↦ hX i) · simp [Finset.sum_attach] · simp [Finset.sum_attach _ (f := (P⁻[X ·|mΩ]))] diff --git a/Mathlib/MeasureTheory/Function/ContinuousMapDense.lean b/Mathlib/MeasureTheory/Function/ContinuousMapDense.lean index 3995e5cbafa6f1..f6d6346dc46161 100644 --- a/Mathlib/MeasureTheory/Function/ContinuousMapDense.lean +++ b/Mathlib/MeasureTheory/Function/ContinuousMapDense.lean @@ -173,7 +173,7 @@ theorem MemLp.exists_hasCompactSupport_eLpNorm_sub_le rcases exists_continuous_eLpNorm_sub_le_of_closed hp s_closed isOpen_interior sk hsμ.ne c δpos.ne' with ⟨f, f_cont, I2, _f_bound, f_support, f_mem⟩ have I3 : eLpNorm (f - t.indicator fun _y => c) p μ ≤ ε := by - convert + convert! (hδ _ _ (f_mem.aestronglyMeasurable.sub (aestronglyMeasurable_const.indicator s_closed.measurableSet)) @@ -270,7 +270,7 @@ theorem MemLp.exists_boundedContinuous_eLpNorm_sub_le [μ.WeaklyRegular] (hp : p δpos.ne' with ⟨f, f_cont, I2, f_bound, -, f_mem⟩ have I3 : eLpNorm (f - t.indicator fun _y => c) p μ ≤ ε := by - convert + convert! (hδ _ _ (f_mem.aestronglyMeasurable.sub (aestronglyMeasurable_const.indicator s_closed.measurableSet)) diff --git a/Mathlib/MeasureTheory/Function/ConvergenceInDistribution.lean b/Mathlib/MeasureTheory/Function/ConvergenceInDistribution.lean index 28b2401cbfa22e..687d86922ab32e 100644 --- a/Mathlib/MeasureTheory/Function/ConvergenceInDistribution.lean +++ b/Mathlib/MeasureTheory/Function/ConvergenceInDistribution.lean @@ -81,7 +81,7 @@ lemma tendstoInDistribution_of_identDistrib [OpensMeasurableSpace E] (i : ι) forall_aemeasurable j := (hX j).aemeasurable_snd aemeasurable_limit := hZ.aemeasurable_snd tendsto := by - convert tendsto_const_nhds with j + convert! tendsto_const_nhds with j exact (hX j).map_eq.symm.trans hZ.map_eq protected lemma TendstoInDistribution.congr [OpensMeasurableSpace E] {T : Ω' → E} @@ -90,7 +90,7 @@ protected lemma TendstoInDistribution.congr [OpensMeasurableSpace E] {T : Ω' forall_aemeasurable i := (h.forall_aemeasurable i).congr (hXY i) aemeasurable_limit := h.aemeasurable_limit.congr hZT tendsto := by - convert h.tendsto using 2 with n + convert! h.tendsto using 2 with n · simpa using Measure.map_congr (hXY n).symm · rw! [Measure.map_congr hZT] rfl @@ -122,7 +122,7 @@ theorem TendstoInDistribution.continuous_comp {F : Type*} [OpensMeasurableSpace forall_aemeasurable := fun n ↦ hg.measurable.comp_aemeasurable (h.forall_aemeasurable n) aemeasurable_limit := hg.measurable.comp_aemeasurable h.aemeasurable_limit tendsto := by - convert ProbabilityMeasure.tendsto_map_of_tendsto_of_continuous _ _ h.tendsto hg + convert! ProbabilityMeasure.tendsto_map_of_tendsto_of_continuous _ _ h.tendsto hg · simp only [ProbabilityMeasure.map, ProbabilityMeasure.coe_mk, Subtype.mk.injEq] rw [AEMeasurable.map_map_of_aemeasurable hg.aemeasurable (h.forall_aemeasurable _)] · simp only [ProbabilityMeasure.map, ProbabilityMeasure.coe_mk] @@ -167,7 +167,7 @@ lemma tendstoInDistribution_of_tendstoInMeasure_sub {X : ι → Ω'' → E} simp_rw [Metric.tendsto_nhds, Real.dist_eq] suffices ∀ ε > 0, ∀ᶠ n in l, |∫ ω, F ω ∂(μ''.map (Y n)) - ∫ ω, F ω ∂(μ'.map Z)| < L * ε by intro ε hε - convert this (ε / L) (by positivity) + convert! this (ε / L) (by positivity) field_simp intro ε hε -- We cut the difference into three pieces, two of which are small by the convergence assumptions @@ -215,7 +215,11 @@ lemma tendstoInDistribution_of_tendstoInMeasure_sub {X : ι → Ω'' → E} · exact fun x hx ↦ hF_lip.norm_sub_le_of_le hx.le · refine setIntegral_mono h_int_sub.integrableOn integrableOn_const fun a ↦ ?_ rw [← dist_eq_norm] - convert hF_bounded _ _ + convert! + hF_bounded _ + _ + -- The goal is now a simple computation + -- The goal is now a simple computation _ = L * (ε / 2) * μ''.real {x | ‖Y n x - X n x‖ < ε / 2} + M * μ''.real {ω | ε / 2 ≤ ‖Y n ω - X n ω‖} := by @@ -275,7 +279,7 @@ theorem TendstoInDistribution.prodMk_of_tendstoInMeasure_const (fun n ω ↦ (X n ω, Y n ω)) (fun ω ↦ (Z ω, c)) ?_ ?_ (fun i ↦ (hX i).prodMk (hY_meas i)) · exact hXZ.continuous_comp (g := fun x ↦ (x, c)) (by fun_prop) · suffices TendstoInMeasure μ'' (fun n ω ↦ ((0 : E), Y n ω - c)) l 0 by - convert this with n ω + convert! this with n ω simp simpa [tendstoInMeasure_iff_norm] using hY diff --git a/Mathlib/MeasureTheory/Function/ConvergenceInMeasure.lean b/Mathlib/MeasureTheory/Function/ConvergenceInMeasure.lean index 3c3374ac5983aa..f148a1ad721cb9 100644 --- a/Mathlib/MeasureTheory/Function/ConvergenceInMeasure.lean +++ b/Mathlib/MeasureTheory/Function/ConvergenceInMeasure.lean @@ -97,10 +97,10 @@ lemma tendstoInMeasure_iff_dist [PseudoMetricSpace E] {f : ι → α → E} {l : TendstoInMeasure μ f l g ↔ ∀ ε, 0 < ε → Tendsto (fun i => μ { x | ε ≤ dist (f i x) (g x) }) l (𝓝 0) := by refine ⟨fun h ε hε ↦ ?_, fun h ↦ ?_⟩ - · convert h (ENNReal.ofReal ε) (ENNReal.ofReal_pos.mpr hε) with i a + · convert! h (ENNReal.ofReal ε) (ENNReal.ofReal_pos.mpr hε) with i a rw [edist_dist, ENNReal.ofReal_le_ofReal_iff (by positivity)] · refine tendstoInMeasure_of_ne_top fun ε hε hε_top ↦ ?_ - convert h ε.toReal (ENNReal.toReal_pos hε.ne' hε_top) with i a + convert! h ε.toReal (ENNReal.toReal_pos hε.ne' hε_top) with i a rw [edist_dist, ENNReal.le_ofReal_iff_toReal_le hε_top (by positivity)] /-- `TendstoInMeasure` expressed with the real-valued measure of a set defined with a distance. @@ -421,8 +421,9 @@ theorem tendstoInMeasure_of_tendsto_eLpNorm_of_stronglyMeasurable [SeminormedAdd refine (hfg δ hδ).mono fun n hn => ?_ refine le_trans ?_ hn rw [one_div, ← ENNReal.inv_mul_le_iff, inv_inv] - · convert mul_meas_ge_le_pow_eLpNorm' μ hp_ne_zero hp_ne_top - ((hf n).sub hg).aestronglyMeasurable ε using 6 + · convert! + mul_meas_ge_le_pow_eLpNorm' μ hp_ne_zero hp_ne_top ((hf n).sub hg).aestronglyMeasurable ε + using 6 simp [edist_eq_enorm_sub] · simp [hε_top] · simp [hε.ne'] diff --git a/Mathlib/MeasureTheory/Function/Holder.lean b/Mathlib/MeasureTheory/Function/Holder.lean index ccb7fbb4daa228..28a09ce608dfff 100644 --- a/Mathlib/MeasureTheory/Function/Holder.lean +++ b/Mathlib/MeasureTheory/Function/Holder.lean @@ -216,7 +216,7 @@ variable (E q) in @[simp] protected lemma smul_zero (f : Lp 𝕜 p μ) : f • (0 : Lp E q μ) = (0 : Lp E r μ) := by - convert MemLp.zero (ε := E) |>.toLp_zero + convert! MemLp.zero (ε := E) |>.toLp_zero apply MemLp.toLp_congr _ _ ?_ filter_upwards [Lp.coeFn_zero E q μ] with x hx rw [Pi.smul_apply', hx] @@ -226,7 +226,7 @@ variable (𝕜 p) in @[simp] protected lemma zero_smul (f : Lp E q μ) : (0 : Lp 𝕜 p μ) • f = (0 : Lp E r μ) := by - convert MemLp.zero (ε := E) |>.toLp_zero + convert! MemLp.zero (ε := E) |>.toLp_zero apply MemLp.toLp_congr _ _ ?_ filter_upwards [Lp.coeFn_zero 𝕜 p μ] with x hx rw [Pi.smul_apply', hx] diff --git a/Mathlib/MeasureTheory/Function/Jacobian.lean b/Mathlib/MeasureTheory/Function/Jacobian.lean index 8e63936b49ceb7..ff39870cbab334 100644 --- a/Mathlib/MeasureTheory/Function/Jacobian.lean +++ b/Mathlib/MeasureTheory/Function/Jacobian.lean @@ -312,7 +312,7 @@ theorem addHaar_image_le_mul_of_det_lt (A : E →L[ℝ] E) {m : ℝ≥0} have L2 : Tendsto (fun ε => μ (closedBall 0 ε + A '' closedBall 0 1)) (𝓝[>] 0) (𝓝 (d * μ (closedBall 0 1))) := by - convert L1 + convert! L1 exact (addHaar_image_continuousLinearMap _ _ _).symm have I : d * μ (closedBall 0 1) < m * μ (closedBall 0 1) := by gcongr; exacts [(measure_closedBall_pos μ _ zero_lt_one).ne', measure_closedBall_lt_top.ne] @@ -447,7 +447,7 @@ theorem mul_le_addHaar_image_of_lt_det (A : E →L[ℝ] E) {m : ℝ≥0} -- let `δ` be small enough, and `f` approximated by `B` up to `δ`. filter_upwards [L1, L2] intro δ h1δ h2δ s f hf - have hf' : ApproximatesLinearOn f (B : E →L[ℝ] E) s δ := by convert hf + have hf' : ApproximatesLinearOn f (B : E →L[ℝ] E) s δ := by convert! hf let F := hf'.toPartialEquiv h1δ -- the condition to be checked can be reformulated in terms of the inverse maps suffices H : μ (F.symm '' F.target) ≤ (m⁻¹ : ℝ≥0) * μ F.target by diff --git a/Mathlib/MeasureTheory/Function/JacobianOneDim.lean b/Mathlib/MeasureTheory/Function/JacobianOneDim.lean index f5b5d41c319392..5264d529c5154c 100644 --- a/Mathlib/MeasureTheory/Function/JacobianOneDim.lean +++ b/Mathlib/MeasureTheory/Function/JacobianOneDim.lean @@ -371,7 +371,7 @@ theorem lintegral_image_eq_lintegral_deriv_mul_of_antitoneOn (hs : MeasurableSet (fun x hx ↦ hasDerivWithinAt_neg _ _) neg_injective.injOn _ simp only [abs_neg, abs_one, ENNReal.ofReal_one, one_mul] at B rw [A, ← image_comp] at B - convert B using 4 with x hx x <;> simp [n, e] + convert! B using 4 with x hx x <;> simp [n, e] /-- Change of variable formula for differentiable functions, set version: if a real function `f` is antitone and differentiable on a measurable set `s`, then the measure of `f '' s` is given by the @@ -399,7 +399,7 @@ theorem integrableOn_image_iff_integrableOn_deriv_smul_of_antitoneOn (hs : Measu (fun x hx ↦ hasDerivWithinAt_neg _ _) neg_injective.injOn _ simp only [abs_neg, abs_one, one_smul] at B rw [A, ← image_comp] at B - convert B using 3 with x hx x <;> simp [n, e] + convert! B using 3 with x hx x <;> simp [n, e] /-- Change of variable formula for differentiable functions: if a real function `f` is antitone and differentiable on a measurable set `s`, then the Bochner integral of a function @@ -417,7 +417,7 @@ theorem integral_image_eq_integral_deriv_smul_of_antitoneOn (hs : MeasurableSet (fun x hx ↦ hasDerivWithinAt_neg _ _) neg_injective.injOn _ simp only [abs_neg, abs_one, one_smul] at B rw [A, ← image_comp] at B - convert B using 3 with x hx x <;> simp [n, e] + convert! B using 3 with x hx x <;> simp [n, e] @[deprecated (since := "2026-03-19")] alias integral_image_eq_integral_deriv_smul_of_antitone := integral_image_eq_integral_deriv_smul_of_antitoneOn diff --git a/Mathlib/MeasureTheory/Function/L1Space/HasFiniteIntegral.lean b/Mathlib/MeasureTheory/Function/L1Space/HasFiniteIntegral.lean index ec8059a833779b..c1a07158170cfd 100644 --- a/Mathlib/MeasureTheory/Function/L1Space/HasFiniteIntegral.lean +++ b/Mathlib/MeasureTheory/Function/L1Space/HasFiniteIntegral.lean @@ -49,7 +49,7 @@ lemma lintegral_enorm_eq_lintegral_edist (f : α → β) : theorem lintegral_norm_eq_lintegral_edist (f : α → β) : ∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by - simp only [ofReal_norm_eq_enorm, edist_zero_right] + simp only [ofReal_norm, edist_zero_right] theorem lintegral_edist_triangle {f g h : α → β} (hf : AEStronglyMeasurable f μ) (hh : AEStronglyMeasurable h μ) : @@ -90,7 +90,7 @@ theorem hasFiniteIntegral_iff_enorm {f : α → ε} : HasFiniteIntegral f μ ↔ theorem hasFiniteIntegral_iff_norm (f : α → β) : HasFiniteIntegral f μ ↔ (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) < ∞ := by - simp only [hasFiniteIntegral_iff_enorm, ofReal_norm_eq_enorm] + simp only [hasFiniteIntegral_iff_enorm, ofReal_norm] theorem hasFiniteIntegral_iff_edist (f : α → β) : HasFiniteIntegral f μ ↔ (∫⁻ a, edist (f a) 0 ∂μ) < ∞ := by @@ -329,7 +329,7 @@ theorem ae_tendsto_enorm (h : ∀ᵐ a ∂μ, Tendsto (fun n ↦ F' n a) atTop < theorem ae_tendsto_ofReal_norm (h : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop <| 𝓝 <| f a) : ∀ᵐ a ∂μ, Tendsto (fun n => ENNReal.ofReal ‖F n a‖) atTop <| 𝓝 <| ENNReal.ofReal ‖f a‖ := by - convert ae_tendsto_enorm h <;> simp + convert! ae_tendsto_enorm h <;> simp @[deprecated (since := "2026-01-26")] alias all_ae_tendsto_ofReal_norm := ae_tendsto_ofReal_norm diff --git a/Mathlib/MeasureTheory/Function/L1Space/Integrable.lean b/Mathlib/MeasureTheory/Function/L1Space/Integrable.lean index 3dc82d61b0eb64..8c740a971237b9 100644 --- a/Mathlib/MeasureTheory/Function/L1Space/Integrable.lean +++ b/Mathlib/MeasureTheory/Function/L1Space/Integrable.lean @@ -676,7 +676,7 @@ theorem Integrable.measure_enorm_ge_lt_top {E : Type*} [TopologicalSpace E] [Con where `‖f x‖ ≥ ε` is finite for all positive `ε`. -/ theorem Integrable.measure_norm_ge_lt_top {f : α → β} (hf : Integrable f μ) {ε : ℝ} (hε : 0 < ε) : μ { x | ε ≤ ‖f x‖ } < ∞ := by - convert Integrable.measure_enorm_ge_lt_top hf (ofReal_pos.mpr hε) ofReal_ne_top with x + convert! Integrable.measure_enorm_ge_lt_top hf (ofReal_pos.mpr hε) ofReal_ne_top with x rw [← Real.enorm_of_nonneg hε.le, enorm_le_iff_norm_le, Real.norm_of_nonneg hε.le] /-- A non-quantitative version of Markov inequality for integrable functions: the measure of points diff --git a/Mathlib/MeasureTheory/Function/L2Space.lean b/Mathlib/MeasureTheory/Function/L2Space.lean index b50619bda4e7a9..c1d59c42b6e4c0 100644 --- a/Mathlib/MeasureTheory/Function/L2Space.lean +++ b/Mathlib/MeasureTheory/Function/L2Space.lean @@ -46,13 +46,13 @@ theorem MemLp.integrable_sq {f : α → ℝ} (h : MemLp f 2 μ) : Integrable (fu theorem memLp_two_iff_integrable_sq_norm {f : α → F} (hf : AEStronglyMeasurable f μ) : MemLp f 2 μ ↔ Integrable (fun x => ‖f x‖ ^ 2) μ := by rw [← memLp_one_iff_integrable] - convert (memLp_norm_rpow_iff hf two_ne_zero ENNReal.ofNat_ne_top).symm + convert! (memLp_norm_rpow_iff hf two_ne_zero ENNReal.ofNat_ne_top).symm · simp · rw [div_eq_mul_inv, ENNReal.mul_inv_cancel two_ne_zero ENNReal.ofNat_ne_top] theorem memLp_two_iff_integrable_sq {f : α → ℝ} (hf : AEStronglyMeasurable f μ) : MemLp f 2 μ ↔ Integrable (fun x => f x ^ 2) μ := by - convert memLp_two_iff_integrable_sq_norm hf using 3 + convert! memLp_two_iff_integrable_sq_norm hf using 3 simp end @@ -150,7 +150,7 @@ theorem integral_inner_eq_sq_eLpNorm (f : α →₂[μ] E) : ext1 x have h_two : (2 : ℝ) = ((2 : ℕ) : ℝ) := by simp rw [← Real.rpow_natCast _ 2, ← h_two, ← - ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) zero_le_two, ofReal_norm_eq_enorm] + ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) zero_le_two, ofReal_norm] norm_cast private theorem norm_sq_eq_re_inner (f : α →₂[μ] E) : ‖f‖ ^ 2 = RCLike.re ⟪f, f⟫ := by diff --git a/Mathlib/MeasureTheory/Function/LocallyIntegrable.lean b/Mathlib/MeasureTheory/Function/LocallyIntegrable.lean index 820f1f744a5fb7..14d1260b68cf3c 100644 --- a/Mathlib/MeasureTheory/Function/LocallyIntegrable.lean +++ b/Mathlib/MeasureTheory/Function/LocallyIntegrable.lean @@ -395,7 +395,7 @@ theorem locallyIntegrable_map_homeomorph [BorelSpace X] [BorelSpace Y] (e : X refine ⟨e.symm ⁻¹' U, e.symm.continuous.continuousAt.preimage_mem_nhds hU, ?_⟩ apply (integrableOn_map_equiv e.toMeasurableEquiv).2 simp only [Homeomorph.toMeasurableEquiv_coe] - convert h'U + convert! h'U ext x simp only [mem_preimage, Homeomorph.symm_apply_apply] diff --git a/Mathlib/MeasureTheory/Function/LpSeminorm/Basic.lean b/Mathlib/MeasureTheory/Function/LpSeminorm/Basic.lean index 264378743af347..96fc1608bff08b 100644 --- a/Mathlib/MeasureTheory/Function/LpSeminorm/Basic.lean +++ b/Mathlib/MeasureTheory/Function/LpSeminorm/Basic.lean @@ -451,7 +451,7 @@ lemma eLpNorm_ofReal (f : α → ℝ) (hf : ∀ᵐ x ∂μ, 0 ≤ f x) : theorem eLpNorm'_norm_rpow (f : α → F) (p q : ℝ) (hq_pos : 0 < q) : eLpNorm' (fun x => ‖f x‖ ^ q) p μ = eLpNorm' f (p * q) μ ^ q := by simp_rw [eLpNorm', ← ENNReal.rpow_mul, ← one_div_mul_one_div, one_div, - mul_assoc, inv_mul_cancel₀ hq_pos.ne.symm, mul_one, ← ofReal_norm_eq_enorm, + mul_assoc, inv_mul_cancel₀ hq_pos.ne.symm, mul_one, ← ofReal_norm, Real.norm_eq_abs, abs_eq_self.mpr (Real.rpow_nonneg (norm_nonneg _) _), mul_comm p, ← ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) hq_pos.le, ENNReal.rpow_mul] @@ -479,8 +479,8 @@ theorem eLpNorm_norm_rpow (f : α → F) (hq_pos : 0 < q) : eLpNorm (fun x => ‖f x‖ ^ q) p μ = eLpNorm f (p * ENNReal.ofReal q) μ ^ q := by rw [← eLpNorm_enorm_rpow f hq_pos] symm - convert eLpNorm_ofReal (fun x ↦ ‖f x‖ ^ q) (by filter_upwards with x using by positivity) - rw [Function.comp_apply, ← ofReal_norm_eq_enorm] + convert! eLpNorm_ofReal (fun x ↦ ‖f x‖ ^ q) (by filter_upwards with x using by positivity) + rw [Function.comp_apply, ← ofReal_norm] exact ENNReal.ofReal_rpow_of_nonneg (by positivity) (by positivity) theorem eLpNorm_congr_ae {f g : α → ε} (hfg : f =ᵐ[μ] g) : eLpNorm f p μ = eLpNorm g p μ := diff --git a/Mathlib/MeasureTheory/Function/LpSeminorm/ChebyshevMarkov.lean b/Mathlib/MeasureTheory/Function/LpSeminorm/ChebyshevMarkov.lean index 68a48e35d97618..47f427129e434b 100644 --- a/Mathlib/MeasureTheory/Function/LpSeminorm/ChebyshevMarkov.lean +++ b/Mathlib/MeasureTheory/Function/LpSeminorm/ChebyshevMarkov.lean @@ -45,7 +45,7 @@ theorem mul_meas_ge_le_pow_eLpNorm (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞ theorem mul_meas_ge_le_pow_eLpNorm' (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {f : α → ε'} (hf : AEStronglyMeasurable f μ) (ε : ℝ≥0∞) : ε ^ p.toReal * μ { x | ε ≤ ‖f x‖ₑ } ≤ eLpNorm f p μ ^ p.toReal := by - convert mul_meas_ge_le_pow_eLpNorm μ hp_ne_zero hp_ne_top hf (ε ^ p.toReal) using 4 + convert! mul_meas_ge_le_pow_eLpNorm μ hp_ne_zero hp_ne_top hf (ε ^ p.toReal) using 4 ext x rw [ENNReal.rpow_le_rpow_iff (ENNReal.toReal_pos hp_ne_zero hp_ne_top)] diff --git a/Mathlib/MeasureTheory/Function/LpSeminorm/CompareExp.lean b/Mathlib/MeasureTheory/Function/LpSeminorm/CompareExp.lean index 5ec76f65f1599f..5b7f2cad5a9a59 100644 --- a/Mathlib/MeasureTheory/Function/LpSeminorm/CompareExp.lean +++ b/Mathlib/MeasureTheory/Function/LpSeminorm/CompareExp.lean @@ -198,7 +198,7 @@ theorem eLpNorm_le_eLpNorm_mul_eLpNorm_top (p : ℝ≥0∞) {f : α → E} (hf : calc eLpNorm (fun x ↦ b (f x) (g x)) p μ ≤ c * eLpNorm g ∞ μ * eLpNorm f p μ := eLpNorm_le_eLpNorm_top_mul_eLpNorm p g hf (flip b) c <| by - convert h using 3 with x + convert! h using 3 with x simp only [mul_assoc, mul_comm ‖f x‖₊] _ = c * eLpNorm f p μ * eLpNorm g ∞ μ := by simp only [mul_assoc]; rw [mul_comm (eLpNorm _ _ _)] diff --git a/Mathlib/MeasureTheory/Function/LpSeminorm/Indicator.lean b/Mathlib/MeasureTheory/Function/LpSeminorm/Indicator.lean index d27f71f0255a4e..7a4da8882b40b4 100644 --- a/Mathlib/MeasureTheory/Function/LpSeminorm/Indicator.lean +++ b/Mathlib/MeasureTheory/Function/LpSeminorm/Indicator.lean @@ -192,7 +192,7 @@ theorem eLpNorm_indicator_sub_le_of_dist_bdd {β : Type*} [NormedAddCommGroup β Real.norm_eq_abs, abs_of_nonneg hc] exact hf x hx · simp [Set.indicator_of_notMem hx] - grw [eLpNorm_mono this, eLpNorm_indicator_const hs hp hp', ← ofReal_norm_eq_enorm, + grw [eLpNorm_mono this, eLpNorm_indicator_const hs hp hp', ← ofReal_norm, Real.norm_eq_abs, abs_of_nonneg hc] theorem eLpNorm_sub_le_of_dist_bdd {β : Type*} [NormedAddCommGroup β] diff --git a/Mathlib/MeasureTheory/Function/LpSeminorm/TriangleInequality.lean b/Mathlib/MeasureTheory/Function/LpSeminorm/TriangleInequality.lean index 719fd51155c75f..563f5f2398056d 100644 --- a/Mathlib/MeasureTheory/Function/LpSeminorm/TriangleInequality.lean +++ b/Mathlib/MeasureTheory/Function/LpSeminorm/TriangleInequality.lean @@ -67,7 +67,7 @@ theorem eLpNorm_add_le' (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasura · simp rcases lt_or_ge p 1 with (h'p | h'p) · simp only [eLpNorm_eq_eLpNorm' hp (h'p.trans ENNReal.one_lt_top).ne] - convert eLpNorm'_add_le_of_le_one hf ENNReal.toReal_nonneg _ + convert! eLpNorm'_add_le_of_le_one hf ENNReal.toReal_nonneg _ · have : p ∈ Set.Ioo (0 : ℝ≥0∞) 1 := ⟨hp.bot_lt, h'p⟩ simp only [LpAddConst, if_pos this] · simpa using ENNReal.toReal_mono ENNReal.one_ne_top h'p.le @@ -157,7 +157,7 @@ theorem memLp_finsetSum [ContinuousAdd ε'] theorem memLp_finsetSum' [ContinuousAdd ε'] {ι} (s : Finset ι) {f : ι → α → ε'} (hf : ∀ i ∈ s, MemLp (f i) p μ) : MemLp (∑ i ∈ s, f i) p μ := by - convert memLp_finsetSum s hf using 1 + convert! memLp_finsetSum s hf using 1 ext x simp diff --git a/Mathlib/MeasureTheory/Function/LpSpace/Basic.lean b/Mathlib/MeasureTheory/Function/LpSpace/Basic.lean index 147002bccaf105..ae90319baf780e 100644 --- a/Mathlib/MeasureTheory/Function/LpSpace/Basic.lean +++ b/Mathlib/MeasureTheory/Function/LpSpace/Basic.lean @@ -5,6 +5,7 @@ Authors: Rémy Degenne, Sébastien Gouëzel -/ module +public import Mathlib.Analysis.Normed.Operator.Bilinear public import Mathlib.Analysis.Normed.Operator.NNNorm public import Mathlib.MeasureTheory.Function.LpSeminorm.ChebyshevMarkov public import Mathlib.MeasureTheory.Function.LpSeminorm.CompareExp @@ -499,7 +500,7 @@ theorem memLp_enorm_rpow_iff {q : ℝ≥0∞} {f : α → ε} (hf : AEStronglyMe (q_top : q ≠ ∞) : MemLp (‖f ·‖ₑ ^ q.toReal) (p / q) μ ↔ MemLp f p μ := by refine ⟨fun h => ?_, fun h => h.enorm_rpow_div q⟩ apply (memLp_enorm_iff hf).1 - convert h.enorm_rpow_div q⁻¹ using 1 + convert! h.enorm_rpow_div q⁻¹ using 1 · ext x have : q.toReal * q.toReal⁻¹ = 1 := CommGroupWithZero.mul_inv_cancel q.toReal <| ENNReal.toReal_ne_zero.mpr ⟨q_zero, q_top⟩ @@ -511,7 +512,7 @@ theorem memLp_norm_rpow_iff {q : ℝ≥0∞} {f : α → E} (hf : AEStronglyMeas (q_top : q ≠ ∞) : MemLp (fun x : α => ‖f x‖ ^ q.toReal) (p / q) μ ↔ MemLp f p μ := by refine ⟨fun h => ?_, fun h => h.norm_rpow_div q⟩ apply (memLp_norm_iff hf).1 - convert h.norm_rpow_div q⁻¹ using 1 + convert! h.norm_rpow_div q⁻¹ using 1 · ext x rw [Real.norm_eq_abs, Real.abs_rpow_of_nonneg (norm_nonneg _), ← Real.rpow_mul (abs_nonneg _), ENNReal.toReal_inv, mul_inv_cancel₀, abs_of_nonneg (norm_nonneg _), Real.rpow_one] @@ -521,12 +522,12 @@ theorem memLp_norm_rpow_iff {q : ℝ≥0∞} {f : α → E} (hf : AEStronglyMeas theorem MemLp.enorm_rpow {f : α → ε} (hf : MemLp f p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : MemLp (fun x : α => ‖f x‖ₑ ^ p.toReal) 1 μ := by - convert hf.enorm_rpow_div p + convert! hf.enorm_rpow_div p rw [div_eq_mul_inv, ENNReal.mul_inv_cancel hp_ne_zero hp_ne_top] theorem MemLp.norm_rpow {f : α → E} (hf : MemLp f p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : MemLp (fun x : α => ‖f x‖ ^ p.toReal) 1 μ := by - convert hf.norm_rpow_div p + convert! hf.norm_rpow_div p rw [div_eq_mul_inv, ENNReal.mul_inv_cancel hp_ne_zero hp_ne_top] theorem AEEqFun.compMeasurePreserving_mem_Lp {β : Type*} [MeasurableSpace β] @@ -749,7 +750,7 @@ theorem _root_.MeasureTheory.memLp_re_im_iff {f : α → K} : MemLp f p μ := by refine ⟨?_, fun hf => ⟨hf.re, hf.im⟩⟩ rintro ⟨hre, him⟩ - convert MeasureTheory.MemLp.add (ε := K) hre.ofReal (him.ofReal.const_mul RCLike.I) + convert! MeasureTheory.MemLp.add (ε := K) hre.ofReal (him.ofReal.const_mul RCLike.I) ext1 x rw [Pi.add_apply, mul_comm, RCLike.re_add_im] @@ -774,7 +775,7 @@ theorem norm_compLp_le (L : E →SL[σ] F) (f : Lp E p μ) : ‖L.compLp f‖ variable (μ p) /-- Composing `f : Lp E p μ` with `L : E →L[𝕜] F`, seen as a `𝕜`-linear map on `Lp E p μ`. -/ -def compLpₗ (L : E →SL[σ] F) : Lp E p μ →ₛₗ[σ] Lp F p μ where +@[simps] def compLpₗ (L : E →SL[σ] F) : Lp E p μ →ₛₗ[σ] Lp F p μ where toFun f := L.compLp f map_add' f g := by ext1 @@ -815,6 +816,46 @@ theorem smul_compLpL [Fact (1 ≤ p)] {𝕜''} [NormedRing 𝕜''] [Module 𝕜' theorem norm_compLpL_le [Fact (1 ≤ p)] (L : E →SL[σ] F) : ‖L.compLpL p μ‖ ≤ ‖L‖ := LinearMap.mkContinuous_norm_le _ (norm_nonneg _) _ +section Bilinear + +variable {F G : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] + [NormedAddCommGroup G] [NormedSpace 𝕜 G] + +variable (μ p) in +/-- Given a continuous bilinear map `G → E → F`, construct the associated bilinear map +`G → Lp E p μ → Lp F p μ`. -/ +@[simps] def compLpₗ₂ (B : G →L[𝕜] E →L[𝕜] F) : G →ₗ[𝕜] Lp E p μ →ₗ[𝕜] Lp F p μ where + toFun g := (B g).compLpₗ p μ + map_add' g h := by + ext f + filter_upwards [(B (g + h)).coeFn_compLp f, (B g).coeFn_compLp f, (B h).coeFn_compLp f, + Lp.coeFn_add ((B g).compLp f) ((B h).compLp f)] with x hx hg hh hadd + simp only [compLpₗ_apply, LinearMap.add_apply, hx, hadd] + simp only [map_add, add_apply, Pi.add_apply, hg, hh] + map_smul' c g := by + ext f + filter_upwards [(c • B g).coeFn_compLp f, (B g).coeFn_compLp f, + Lp.coeFn_smul c ((B g).compLp f)] with x hx hg hsmul + simp [hx, hsmul, hg] + +variable (μ p) in +/-- Given a continuous bilinear map `G → E → F`, construct the associated continuous bilinear map +`G → Lp E p μ → Lp F p μ`. -/ +def compLpL₂ [Fact (1 ≤ p)] (B : G →L[𝕜] E →L[𝕜] F) : + G →L[𝕜] Lp E p μ →L[𝕜] Lp F p μ := + (B.compLpₗ₂ p μ).mkContinuous₂ ‖B‖ (fun c f ↦ by + simp only [compLpₗ₂_apply, compLpₗ_apply] + grw [norm_compLp_le, le_opNorm]) + +@[simp] theorem compLpL₂_apply_apply [Fact (1 ≤ p)] (B : G →L[𝕜] E →L[𝕜] F) (g : G) (f : Lp E p μ) : + compLpL₂ p μ B g f = (B g).compLp f := rfl + +theorem norm_compLpL₂_le [Fact (1 ≤ p)] (B : G →L[𝕜] E →L[𝕜] F) : + ‖B.compLpL₂ p μ‖ ≤ ‖B‖ := + LinearMap.mkContinuous₂_norm_le _ (norm_nonneg _) _ + +end Bilinear + end ContinuousLinearMap namespace MeasureTheory.Lp diff --git a/Mathlib/MeasureTheory/Function/LpSpace/Complete.lean b/Mathlib/MeasureTheory/Function/LpSpace/Complete.lean index 39ef2c2a3384e9..33c2b7b7b68859 100644 --- a/Mathlib/MeasureTheory/Function/LpSpace/Complete.lean +++ b/Mathlib/MeasureTheory/Function/LpSpace/Complete.lean @@ -218,7 +218,7 @@ private theorem lintegral_rpow_sum_enorm_sub_le_rpow_tsum (∑ i ∈ Finset.range (n + 1), ‖f (i + 1) a - f i a‖ₑ) ^ p := by ext1 a congr - simp_rw [← ofReal_norm_eq_enorm] + simp_rw [← ofReal_norm] rw [← ENNReal.ofReal_sum_of_nonneg] · rw [Real.norm_of_nonneg _] exact Finset.sum_nonneg fun x _ => norm_nonneg _ @@ -303,7 +303,7 @@ theorem ae_tendsto_of_cauchy_eLpNorm [CompleteSpace E] {f : ℕ → α → E} specialize hx N n m hnN hmN rw [_root_.dist_eq_norm, ← ENNReal.ofReal_le_iff_le_toReal (ENNReal.ne_top_of_tsum_ne_top hB N), - ofReal_norm_eq_enorm] + ofReal_norm] exact hx.le · rw [← ENNReal.toReal_zero] exact diff --git a/Mathlib/MeasureTheory/Function/LpSpace/CompleteOfCompleteLp.lean b/Mathlib/MeasureTheory/Function/LpSpace/CompleteOfCompleteLp.lean new file mode 100644 index 00000000000000..82649b61808f46 --- /dev/null +++ b/Mathlib/MeasureTheory/Function/LpSpace/CompleteOfCompleteLp.lean @@ -0,0 +1,125 @@ +/- +Copyright (c) 2026 Sébastien Gouëzel. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Sébastien Gouëzel +-/ +module + +public import Mathlib.Analysis.Normed.Operator.Mul +public import Mathlib.MeasureTheory.Function.ConvergenceInMeasure +public import Mathlib.MeasureTheory.Function.LpSpace.Complete +public import Mathlib.MeasureTheory.Function.StronglyMeasurable.Lp + +/-! +# If an `Lp` space is complete, so is the target space +-/ + +@[expose] public section + +open scoped ENNReal Topology +open Filter ContinuousLinearMap + +namespace MeasureTheory + +variable {α E : Type*} [NormedAddCommGroup E] {mα : MeasurableSpace α} {p : ℝ≥0∞} {μ : Measure α} + +lemma FinStronglyMeasurable.exists_measurableSet_measure_pos_lt_top {f : α → E} + (hf : FinStronglyMeasurable f μ) (h'f : ¬(f =ᵐ[μ] 0)) : + ∃ s, MeasurableSet s ∧ 0 < μ s ∧ μ s < ∞ := by + contrapose! h'f + rcases hf with ⟨fn, hfn, hfn_lim⟩ + have A n : μ (Function.support (fn n)) = 0 := by + by_contra! + have := h'f (Function.support (fn n)) (fn n).measurableSet_support (by positivity) + grind + have B : ∀ᵐ x ∂μ, ∀ n, fn n x = 0 := ae_all_iff.mpr A + filter_upwards [B] with x hx + apply tendsto_nhds_unique (hfn_lim x) + simp [hx] + +lemma AEFinStronglyMeasurable.exists_measurableSet_measure_pos_lt_top {f : α → E} + (hf : AEFinStronglyMeasurable f μ) (h'f : ¬(f =ᵐ[μ] 0)) : + ∃ s, MeasurableSet s ∧ 0 < μ s ∧ μ s < ∞ := by + apply hf.finStronglyMeasurable_mk.exists_measurableSet_measure_pos_lt_top + contrapose! h'f + exact hf.ae_eq_mk.trans h'f + +variable (E p μ) in +lemma nontrivial_Lp_real_of_nontrivial_Lp [Nontrivial (Lp E p μ)] : Nontrivial (Lp ℝ p μ) := by + obtain ⟨f, hf⟩ : ∃ f : Lp E p μ, f ≠ 0 := exists_ne 0 + have hfne : ¬ (f =ᵐ[μ] 0) := by + contrapose! hf + ext + grw [hf, Lp.coeFn_zero E p μ] + rcases eq_top_or_lt_top p with rfl | h'p + · apply nontrivial_of_ne ((memLp_top_const (1 : ℝ)).toLp _) 0 + contrapose! hfne + have := Lp.ext_iff.1 hfne + grw [Lp.coeFn_zero, MemLp.coeFn_toLp] at this + filter_upwards [this] with x hx using by simp at hx + rcases eq_or_ne p 0 with rfl | hp + · have : MemLp (fun (_ : α) ↦ (1 : ℝ)) 0 μ := by simpa using aestronglyMeasurable_const + apply nontrivial_of_ne (this.toLp _) 0 + contrapose! hfne + have := Lp.ext_iff.1 hfne + grw [Lp.coeFn_zero, MemLp.coeFn_toLp] at this + filter_upwards [this] with x hx using by simp at hx + · have h'f : AEFinStronglyMeasurable f μ := + MemLp.aefinStronglyMeasurable (Lp.memLp f) hp h'p.ne + obtain ⟨s, s_meas, s_pos, s_top⟩ : ∃ s, MeasurableSet s ∧ 0 < μ s ∧ μ s < ∞ := + h'f.exists_measurableSet_measure_pos_lt_top hfne + apply nontrivial_of_ne (indicatorConstLp p s_meas s_top.ne 1) 0 + intro hzero + have : ‖indicatorConstLp p s_meas s_top.ne (1 : ℝ)‖ = ‖(0 : Lp ℝ p μ)‖ := by rw [hzero] + simp only [norm_indicatorConstLp hp h'p.ne, norm_one, one_div, one_mul, Lp.norm_zero] at this + rw [Real.rpow_eq_zero (by positivity) (by simp [ENNReal.toReal_eq_zero_iff, hp, h'p.ne]), + measureReal_eq_zero_iff] at this + order + +variable [NormedSpace ℝ E] + +variable (E p μ) in +/-- If an `L^p` space is complete and nontrivial, then the target space is complete. -/ +lemma completeSpace_of_completeSpace_Lp [hp : Fact (1 ≤ p)] + [CompleteSpace (Lp E p μ)] [Nontrivial (Lp E p μ)] : CompleteSpace E := by + /- Consider a nonzero function `f : α → ℝ` in `L^p`. Given a Cauchy sequence `uₙ` in `E`, form + the Cauchy sequence `f • uₙ` in `L^p E`. By completeness, it converges. Consider a subsequence + which converges almost everywhere. As `f` is nonzero, we get some `x` such that `f x • uₙ` + converges along this subsequence and `f x ≠ 0`. Then `uₙ` converges along this subsequence, and + therefore along all indices as it is Cauchy. -/ + obtain ⟨f, hf⟩ : ∃ f : Lp ℝ p μ, f ≠ 0 := by + have : Nontrivial (Lp ℝ p μ) := nontrivial_Lp_real_of_nontrivial_Lp E p μ + exact exists_ne 0 + let m : E →L[ℝ] Lp E p μ := ((ContinuousLinearMap.lsmul ℝ ℝ).flip.compLpL₂ p μ).flip f + apply Metric.complete_of_cauchySeq_tendsto (fun u hu ↦ ?_) + obtain ⟨g, hg⟩ : ∃ g, Tendsto (m ∘ u) atTop (𝓝 g) := + cauchySeq_tendsto_of_complete (m.lipschitz.cauchySeq_comp hu) + let f' : ℕ → (α → E) := fun n ↦ (m ∘ u) n + obtain ⟨ns, hns, nslim⟩ : ∃ ns : ℕ → ℕ, StrictMono ns ∧ + ∀ᵐ x ∂μ, Tendsto (fun i ↦ f' (ns i) x) atTop (𝓝 (g x)) := + (tendstoInMeasure_of_tendsto_Lp hg).exists_seq_tendsto_ae + have : (ae (μ.restrict (Function.support f))).NeBot := by + apply ae_restrict_neBot.2 + apply μ.measure_support_eq_zero_iff.not.2 + contrapose! hf + ext + grw [Lp.coeFn_zero] + exact hf + have A : ∀ᵐ x ∂(μ.restrict (Function.support f)), + Tendsto (fun i ↦ f' (ns i) x) atTop (𝓝 (g x)) := ae_restrict_of_ae nslim + have B : ∀ᵐ x ∂(μ.restrict (Function.support f)), x ∈ Function.support f := + ae_restrict_mem (measurableSet_support (by fun_prop)) + have C : ∀ᵐ x ∂(μ.restrict (Function.support f)), ∀ n, m (u n) x = (f x) • u n := by + apply ae_restrict_of_ae + apply ae_all_iff.2 (fun n ↦ ?_) + filter_upwards [(toSpanSingleton ℝ (u n)).coeFn_compLp f] with x hx using by simp [m, hx] + obtain ⟨x, xlim, hx, hmx⟩ : ∃ x, Tendsto (fun i ↦ f' (ns i) x) atTop (𝓝 (g x)) + ∧ x ∈ Function.support f ∧ ∀ n, m (u n) x = (f x) • u n := (A.and (B.and C)).exists + simp only [Function.comp_apply, hmx, f'] at xlim + refine ⟨(f x)⁻¹ • g x, ?_⟩ + apply tendsto_nhds_of_cauchySeq_of_subseq hu hns.tendsto_atTop + convert xlim.const_smul (f x)⁻¹ with n + rw [smul_smul, inv_mul_cancel₀, one_smul, Function.comp] + exact hx + +end MeasureTheory diff --git a/Mathlib/MeasureTheory/Function/LpSpace/ContinuousCompMeasurePreserving.lean b/Mathlib/MeasureTheory/Function/LpSpace/ContinuousCompMeasurePreserving.lean index a7b7ce02d11820..1e39d75dd2318e 100644 --- a/Mathlib/MeasureTheory/Function/LpSpace/ContinuousCompMeasurePreserving.lean +++ b/Mathlib/MeasureTheory/Function/LpSpace/ContinuousCompMeasurePreserving.lean @@ -80,7 +80,7 @@ theorem Filter.Tendsto.compMeasurePreservingLp {α : Type*} {l : Filter α} replace hg : Tendsto (fun a ↦ ⟨g a, hgm a⟩ : α → {g : C(X, Y) // MeasurePreserving g μ ν}) l (𝓝 ⟨g₀, hgm₀⟩) := tendsto_subtype_rng.2 hg - convert this.comp (hf.prodMk_nhds hg) + convert! this.comp (hf.prodMk_nhds hg) variable {Z : Type*} [TopologicalSpace Z] {f : Z → Lp E p ν} {g : Z → C(X, Y)} {s : Set Z} {z : Z} diff --git a/Mathlib/MeasureTheory/Function/LpSpace/ContinuousFunctions.lean b/Mathlib/MeasureTheory/Function/LpSpace/ContinuousFunctions.lean index 90abd693575fbb..908bb9a40641d8 100644 --- a/Mathlib/MeasureTheory/Function/LpSpace/ContinuousFunctions.lean +++ b/Mathlib/MeasureTheory/Function/LpSpace/ContinuousFunctions.lean @@ -53,7 +53,7 @@ variable [IsFiniteMeasure μ] theorem mem_Lp (f : α →ᵇ E) : f.toContinuousMap.toAEEqFun μ ∈ Lp E p μ := by refine Lp.mem_Lp_of_ae_bound ‖f‖ ?_ filter_upwards [f.toContinuousMap.coeFn_toAEEqFun μ] with x _ - convert f.norm_coe_le_norm x using 2 + convert! f.norm_coe_le_norm x using 2 /-- The `Lp`-norm of a bounded continuous function is at most a constant (depending on the measure of the whole space) times its sup-norm. -/ @@ -64,7 +64,7 @@ theorem Lp_nnnorm_le (f : α →ᵇ E) : refine (f.toContinuousMap.coeFn_toAEEqFun μ).mono ?_ intro x hx rw [← NNReal.coe_le_coe, coe_nnnorm, coe_nnnorm] - convert f.norm_coe_le_norm x using 2 + convert! f.norm_coe_le_norm x using 2 /-- The `Lp`-norm of a bounded continuous function is at most a constant (depending on the measure of the whole space) times its sup-norm. -/ @@ -151,7 +151,7 @@ theorem range_toLp : MeasureTheory.Lp.boundedContinuousFunction E p μ := by refine SetLike.ext' ?_ have := (linearIsometryBoundedOfCompact α E 𝕜).surjective - convert Function.Surjective.range_comp this (BoundedContinuousFunction.toLp (E := E) p μ 𝕜) + convert! Function.Surjective.range_comp this (BoundedContinuousFunction.toLp (E := E) p μ 𝕜) rw [← BoundedContinuousFunction.range_toLp p μ (𝕜 := 𝕜), Submodule.coe_toAddSubgroup, LinearMap.coe_range, ContinuousLinearMap.coe_coe] @@ -191,7 +191,7 @@ then in fact `g n` converges uniformly to `h`. -/ theorem hasSum_of_hasSum_Lp {β : Type*} [μ.IsOpenPosMeasure] {g : β → C(α, E)} {f : C(α, E)} (hg : Summable g) (hg2 : HasSum (toLp (E := E) p μ 𝕜 ∘ g) (toLp (E := E) p μ 𝕜 f)) : HasSum g f := by - convert Summable.hasSum hg + convert! Summable.hasSum hg exact toLp_injective μ (hg2.unique ((toLp p μ 𝕜).hasSum <| Summable.hasSum hg)) variable (μ) {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] diff --git a/Mathlib/MeasureTheory/Function/LpSpace/Indicator.lean b/Mathlib/MeasureTheory/Function/LpSpace/Indicator.lean index d1cfeb32149697..a3afde2ca260c0 100644 --- a/Mathlib/MeasureTheory/Function/LpSpace/Indicator.lean +++ b/Mathlib/MeasureTheory/Function/LpSpace/Indicator.lean @@ -48,7 +48,7 @@ theorem exists_eLpNorm_indicator_le (hp : p ≠ ∞) (c : E) {ε : ℝ≥0∞} ( Filter.Tendsto (fun x : ℝ≥0 => ((‖c‖₊ * x ^ (1 / p.toReal) : ℝ≥0) : ℝ≥0∞)) (𝓝 0) (𝓝 (0 : ℝ≥0)) := by rw [ENNReal.tendsto_coe] - convert (NNReal.continuousAt_rpow_const (Or.inr hp₀')).tendsto.const_mul _ + convert! (NNReal.continuousAt_rpow_const (Or.inr hp₀')).tendsto.const_mul _ simp [hp₀''.ne'] have hε' : 0 < ε := hε.bot_lt obtain ⟨δ, hδ, hδε'⟩ := NNReal.nhds_zero_basis.eventually_iff.mp (this.eventually_le_const hε') @@ -180,8 +180,8 @@ theorem tendsto_indicatorConstLp_set [hp₁ : Fact (1 ≤ p)] {β : Type*} {l : rw [tendsto_iff_dist_tendsto_zero] have hp₀ : p ≠ 0 := (one_pos.trans_le hp₁.out).ne' simp only [dist_indicatorConstLp_eq_norm, norm_indicatorConstLp hp₀ hp] - convert tendsto_const_nhds.mul - (((ENNReal.tendsto_toReal ENNReal.zero_ne_top).comp h).rpow_const _) + convert! + tendsto_const_nhds.mul (((ENNReal.tendsto_toReal ENNReal.zero_ne_top).comp h).rpow_const _) · simp [ENNReal.toReal_eq_zero_iff, hp, hp₀] · simp diff --git a/Mathlib/MeasureTheory/Function/SimpleFunc.lean b/Mathlib/MeasureTheory/Function/SimpleFunc.lean index e7461fef837241..b77aae45ac6ad5 100644 --- a/Mathlib/MeasureTheory/Function/SimpleFunc.lean +++ b/Mathlib/MeasureTheory/Function/SimpleFunc.lean @@ -1259,7 +1259,7 @@ protected theorem induction {α γ} [MeasurableSpace α] [AddZeroClass γ] induction s using Finset.induction generalizing f with | empty => rw [Finset.coe_empty, diff_eq_empty, range_subset_singleton] at h - convert const 0 MeasurableSet.univ + convert! const 0 MeasurableSet.univ ext x simp [h] | insert x s hxs ih => @@ -1271,10 +1271,10 @@ protected theorem induction {α γ} [MeasurableSpace α] [AddZeroClass γ] rw [image_compl_preimage, union_diff_distrib, diff_diff_comm, h, Finset.coe_insert, insert_diff_self_of_notMem, diff_eq_empty.mpr, Set.empty_union] · rw [Set.image_subset_iff] - convert Set.subset_univ _ + convert! Set.subset_univ _ exact preimage_const_of_mem (mem_singleton _) · rwa [Finset.mem_coe] - convert add _ Pg (const x mx) + convert! add _ Pg (const x mx) · ext1 y by_cases hy : y ∈ f ⁻¹' {x} · simpa [g, hy] @@ -1301,7 +1301,7 @@ protected theorem induction' {α γ} [MeasurableSpace α] [Nonempty γ] {P : Sim induction s using Finset.induction generalizing f with | empty => rw [Finset.coe_empty, diff_eq_empty, range_subset_singleton] at h - convert const c + convert! const c ext x simp [h] | insert x s hxs ih => @@ -1313,10 +1313,10 @@ protected theorem induction' {α γ} [MeasurableSpace α] [Nonempty γ] {P : Sim rw [image_compl_preimage, union_diff_distrib, diff_diff_comm, h, Finset.coe_insert, insert_diff_self_of_notMem, diff_eq_empty.mpr, Set.empty_union] · rw [Set.image_subset_iff] - convert Set.subset_univ _ + convert! Set.subset_univ _ exact preimage_const_of_mem (mem_singleton _) · rwa [Finset.mem_coe] - convert pcw mx.compl Pg (const x) + convert! pcw mx.compl Pg (const x) · ext1 y by_cases hy : y ∈ f ⁻¹' {x} · simpa [g, hy] @@ -1360,7 +1360,7 @@ theorem Measurable.ennreal_induction {motive : (α → ℝ≥0∞) → Prop} (iSup : ∀ ⦃f : ℕ → α → ℝ≥0∞⦄, (∀ n, Measurable (f n)) → Monotone f → (∀ n, motive (f n)) → motive fun x => ⨆ n, f n x) ⦃f : α → ℝ≥0∞⦄ (hf : Measurable f) : motive f := by - convert iSup (fun n => (eapprox f n).measurable) (monotone_eapprox f) _ using 2 + convert! iSup (fun n => (eapprox f n).measurable) (monotone_eapprox f) _ using 2 · rw [iSup_eapprox_apply hf] · exact fun n => SimpleFunc.induction (fun c s hs => indicator c hs) @@ -1384,9 +1384,12 @@ lemma Measurable.ennreal_sigmaFinite_induction [SigmaFinite μ] {motive : (α (∀ n, motive (f n)) → motive fun x => ⨆ n, f n x) ⦃f : α → ℝ≥0∞⦄ (hf : Measurable f) : motive f := by refine Measurable.ennreal_induction (fun c s hs ↦ ?_) add iSup hf - convert iSup (f := fun n ↦ (s ∩ spanningSets μ n).indicator fun _ ↦ c) - (fun n ↦ measurable_const.indicator (hs.inter (measurableSet_spanningSets ..))) - (fun m n hmn a ↦ by dsimp; grw [hmn]) - (fun n ↦ indicator _ (hs.inter (measurableSet_spanningSets ..)) - (measure_inter_lt_top_of_right_ne_top (measure_spanningSets_lt_top ..).ne)) with a + convert! + iSup (f := fun n ↦ (s ∩ spanningSets μ n).indicator fun _ ↦ c) + (fun n ↦ measurable_const.indicator (hs.inter (measurableSet_spanningSets ..))) + (fun m n hmn a ↦ by dsimp; grw [hmn]) + (fun n ↦ + indicator _ (hs.inter (measurableSet_spanningSets ..)) + (measure_inter_lt_top_of_right_ne_top (measure_spanningSets_lt_top ..).ne)) with + a simp [← Set.indicator_iUnion_apply (M := ℝ≥0∞) rfl, ← Set.inter_iUnion] diff --git a/Mathlib/MeasureTheory/Function/SimpleFuncDenseLp.lean b/Mathlib/MeasureTheory/Function/SimpleFuncDenseLp.lean index 3ac718ef4842d6..4c7c2cefcbf398 100644 --- a/Mathlib/MeasureTheory/Function/SimpleFuncDenseLp.lean +++ b/Mathlib/MeasureTheory/Function/SimpleFuncDenseLp.lean @@ -96,7 +96,7 @@ theorem tendsto_approxOn_Lp_eLpNorm [OpensMeasurableSpace E] {f : β → E} (hf have hp : 0 < p.toReal := toReal_pos hp_zero hp_ne_top suffices Tendsto (fun n => ∫⁻ x, ‖approxOn f hf s y₀ h₀ n x - f x‖ₑ ^ p.toReal ∂μ) atTop (𝓝 0) by simp only [eLpNorm_eq_lintegral_rpow_enorm_toReal hp_zero hp_ne_top] - convert continuous_rpow_const.continuousAt.tendsto.comp this + convert! continuous_rpow_const.continuousAt.tendsto.comp this simp [zero_rpow_of_pos (_root_.inv_pos.mpr hp)] -- We simply check the conditions of the Dominated Convergence Theorem: -- (1) The function "`p`-th power of distance between `f` and the approximation" is measurable @@ -119,7 +119,7 @@ theorem tendsto_approxOn_Lp_eLpNorm [OpensMeasurableSpace E] {f : β → E} (hf filter_upwards [hμ] with a ha have : Tendsto (fun n => (approxOn f hf s y₀ h₀ n) a - f a) atTop (𝓝 (f a - f a)) := (tendsto_approxOn hf h₀ ha).sub tendsto_const_nhds - convert continuous_rpow_const.continuousAt.tendsto.comp (tendsto_coe.mpr this.nnnorm) + convert! continuous_rpow_const.continuousAt.tendsto.comp (tendsto_coe.mpr this.nnnorm) simp [zero_rpow_of_pos hp] -- Then we apply the Dominated Convergence Theorem simpa using tendsto_lintegral_of_dominated_convergence _ hF_meas h_bound h_fin h_lim @@ -131,7 +131,7 @@ theorem memLp_approxOn [BorelSpace E] {f : β → E} {μ : Measure β} (fmeas : suffices eLpNorm (fun x => approxOn f fmeas s y₀ h₀ n x - y₀) p μ < ⊤ by have : MemLp (fun x => approxOn f fmeas s y₀ h₀ n x - y₀) p μ := ⟨(approxOn f fmeas s y₀ h₀ n - const β y₀).aestronglyMeasurable, this⟩ - convert eLpNorm_add_lt_top this hi₀ + convert! eLpNorm_add_lt_top this hi₀ ext x simp have hf' : MemLp (fun x => ‖f x - y₀‖) p μ := by @@ -140,11 +140,11 @@ theorem memLp_approxOn [BorelSpace E] {f : β → E} {μ : Measure β} (fmeas : fun_prop refine ⟨h_meas.aemeasurable.aestronglyMeasurable, ?_⟩ rw [eLpNorm_norm] - convert eLpNorm_add_lt_top hf hi₀.neg with x + convert! eLpNorm_add_lt_top hf hi₀.neg with x simp [sub_eq_add_neg] have : ∀ᵐ x ∂μ, ‖approxOn f fmeas s y₀ h₀ n x - y₀‖ ≤ ‖‖f x - y₀‖ + ‖f x - y₀‖‖ := by filter_upwards with x - convert norm_approxOn_y₀_le fmeas h₀ x n using 1 + convert! norm_approxOn_y₀_le fmeas h₀ x n using 1 rw [Real.norm_eq_abs, abs_of_nonneg] positivity calc @@ -531,8 +531,7 @@ protected theorem aestronglyMeasurable (f : Lp.simpleFunc E p μ) : theorem toSimpleFunc_eq_toFun (f : Lp.simpleFunc E p μ) : toSimpleFunc f =ᵐ[μ] f := show ⇑(toSimpleFunc f) =ᵐ[μ] ⇑(f : α →ₘ[μ] E) by - convert (AEEqFun.coeFn_mk (toSimpleFunc f) - (toSimpleFunc f).aestronglyMeasurable).symm using 2 + convert! (AEEqFun.coeFn_mk (toSimpleFunc f) (toSimpleFunc f).aestronglyMeasurable).symm using 2 exact (Classical.choose_spec f.2).symm /-- `toSimpleFunc f` satisfies the predicate `MemLp`. -/ @@ -633,7 +632,7 @@ protected theorem induction (hp_pos : p ≠ 0) (hp_ne_top : p ≠ ∞) {P : Lp.s apply SimpleFunc.induction · intro c s hs hf by_cases hc : c = 0 - · convert indicatorConst 0 MeasurableSet.empty (by simp) using 1 + · convert! indicatorConst 0 MeasurableSet.empty (by simp) using 1 ext1 simp [hc] exact indicatorConst c hs @@ -673,7 +672,7 @@ lemma isDenseEmbedding (hp_ne_top : p ≠ ∞) : (SimpleFunc.approxOn f (Lp.stronglyMeasurable f).measurable (range f ∪ {0}) 0 _ n) (SimpleFunc.memLp_approxOn_range (Lp.stronglyMeasurable f).measurable hfi' n), fun n => mem_range_self _, ?_⟩ - convert SimpleFunc.tendsto_approxOn_range_Lp hp_ne_top (Lp.stronglyMeasurable f).measurable hfi' + convert! SimpleFunc.tendsto_approxOn_range_Lp hp_ne_top (Lp.stronglyMeasurable f).measurable hfi' rw [toLp_coeFn f (Lp.memLp f)] protected theorem isDenseInducing (hp_ne_top : p ≠ ∞) : @@ -838,7 +837,7 @@ theorem MemLp.induction [_i : Fact (1 ≤ p)] (hp_ne_top : p ≠ ∞) (motive : apply SimpleFunc.induction · intro c s hs h by_cases hc : c = 0 - · subst hc; convert indicator 0 MeasurableSet.empty (by simp) using 1; ext; simp + · subst hc; convert! indicator 0 MeasurableSet.empty (by simp) using 1; ext; simp have hp_pos : p ≠ 0 := (lt_of_lt_of_le zero_lt_one _i.elim).ne' exact indicator c hs (SimpleFunc.measure_lt_top_of_memLp_indicator hp_pos hp_ne_top hc hs h) · intro f g hfg hf hg int_fg @@ -874,7 +873,8 @@ theorem MemLp.induction_dense (hp_ne_top : p ≠ ∞) (P : (α → E) → Prop) rcases hf.exists_simpleFunc_eLpNorm_sub_lt hp_ne_top ηpos.ne' with ⟨f', hf', f'_mem⟩ rcases H f' η ηpos.ne' f'_mem with ⟨g, hg, Pg⟩ refine ⟨g, ?_, Pg⟩ - convert (hη _ _ (hf.aestronglyMeasurable.sub f'.aestronglyMeasurable) + convert! + (hη _ _ (hf.aestronglyMeasurable.sub f'.aestronglyMeasurable) (f'.aestronglyMeasurable.sub (h2P g Pg)) hf'.le hg).le using 2 simp only [sub_add_sub_cancel] apply SimpleFunc.induction @@ -884,7 +884,7 @@ theorem MemLp.induction_dense (hp_ne_top : p ≠ ∞) (P : (α → E) → Prop) εpos with ⟨g, hg, Pg⟩ rw [← eLpNorm_neg, neg_sub] at hg refine ⟨g, ?_, Pg⟩ - convert hg + convert! hg ext x simp · have : μ s < ∞ := SimpleFunc.measure_lt_top_of_memLp_indicator hp_pos hp_ne_top hc hs Hs @@ -898,8 +898,9 @@ theorem MemLp.induction_dense (hp_ne_top : p ≠ ∞) (P : (α → E) → Prop) rcases hf η ηpos.ne' int_ff'.1 with ⟨g, hg, Pg⟩ rcases hf' η ηpos.ne' int_ff'.2 with ⟨g', hg', Pg'⟩ refine ⟨g + g', ?_, h1P g g' Pg Pg'⟩ - convert (hη _ _ (f.aestronglyMeasurable.sub (h2P g Pg)) - (f'.aestronglyMeasurable.sub (h2P g' Pg')) hg hg').le using 2 + convert! + (hη _ _ (f.aestronglyMeasurable.sub (h2P g Pg)) (f'.aestronglyMeasurable.sub (h2P g' Pg')) hg + hg').le using 2 rw [SimpleFunc.coe_add] abel diff --git a/Mathlib/MeasureTheory/Function/SpecialFunctions/RCLike.lean b/Mathlib/MeasureTheory/Function/SpecialFunctions/RCLike.lean index b7d4dfea404dc2..c22984209c3549 100644 --- a/Mathlib/MeasureTheory/Function/SpecialFunctions/RCLike.lean +++ b/Mathlib/MeasureTheory/Function/SpecialFunctions/RCLike.lean @@ -65,13 +65,15 @@ theorem RCLike.measurable_ofReal : Measurable ((↑) : ℝ → 𝕜) := theorem measurable_of_re_im (hre : Measurable fun x => RCLike.re (f x)) (him : Measurable fun x => RCLike.im (f x)) : Measurable f := by - convert Measurable.add (M := 𝕜) (RCLike.measurable_ofReal.comp hre) + convert! + Measurable.add (M := 𝕜) (RCLike.measurable_ofReal.comp hre) ((RCLike.measurable_ofReal.comp him).mul_const RCLike.I) exact (RCLike.re_add_im _).symm theorem aemeasurable_of_re_im (hre : AEMeasurable (fun x => RCLike.re (f x)) μ) (him : AEMeasurable (fun x => RCLike.im (f x)) μ) : AEMeasurable f μ := by - convert AEMeasurable.add (M := 𝕜) (RCLike.measurable_ofReal.comp_aemeasurable hre) + convert! + AEMeasurable.add (M := 𝕜) (RCLike.measurable_ofReal.comp_aemeasurable hre) ((RCLike.measurable_ofReal.comp_aemeasurable him).mul_const RCLike.I) exact (RCLike.re_add_im _).symm diff --git a/Mathlib/MeasureTheory/Function/StronglyMeasurable/Basic.lean b/Mathlib/MeasureTheory/Function/StronglyMeasurable/Basic.lean index d0eb5710e8fbe5..027f07c90e84bf 100644 --- a/Mathlib/MeasureTheory/Function/StronglyMeasurable/Basic.lean +++ b/Mathlib/MeasureTheory/Function/StronglyMeasurable/Basic.lean @@ -115,7 +115,7 @@ This version works for functions between empty types. -/ theorem stronglyMeasurable_const' (hf : ∀ x y, f x = f y) : StronglyMeasurable f := by nontriviality α inhabit α - convert stronglyMeasurable_const (β := β) using 1 + convert! stronglyMeasurable_const (β := β) using 1 exact funext fun x => hf x default variable [MeasurableSingletonClass α] @@ -183,7 +183,7 @@ theorem tendsto_approxBounded_of_norm_le {β} {f : α → β} [NormedAddCommGrou · rw [norm_eq_zero] at hfx0 rw [hfx0] at h_tendsto ⊢ have h_tendsto_norm : Tendsto (fun n => ‖hf.approx n x‖) atTop (𝓝 0) := by - convert h_tendsto.norm + convert! h_tendsto.norm rw [norm_zero] refine squeeze_zero_norm (fun n => ?_) h_tendsto_norm calc @@ -1139,7 +1139,7 @@ protected theorem add [AddZeroClass β] [ContinuousAdd β] (hf : FinStronglyMeas protected theorem neg [SubtractionMonoid β] [ContinuousNeg β] (hf : FinStronglyMeasurable f μ) : FinStronglyMeasurable (-f) μ := by refine ⟨fun n ↦ -hf.approx n, fun n ↦ ?_, fun x ↦ (hf.tendsto_approx x).neg⟩ - suffices μ (Function.support fun x ↦ -(hf.approx n) x) < ∞ by convert this + suffices μ (Function.support fun x ↦ -(hf.approx n) x) < ∞ by convert! this rw [Function.support_fun_neg (hf.approx n)] exact hf.fin_support_approx n diff --git a/Mathlib/MeasureTheory/Function/UnifTight.lean b/Mathlib/MeasureTheory/Function/UnifTight.lean index 8f7f929b4aa6dc..da99d5069c6ba9 100644 --- a/Mathlib/MeasureTheory/Function/UnifTight.lean +++ b/Mathlib/MeasureTheory/Function/UnifTight.lean @@ -160,7 +160,7 @@ theorem unifTight_of_subsingleton [Subsingleton ι] (hp_top : p ≠ ∞) obtain ⟨i⟩ := hι obtain ⟨s, _, hμs, hfε⟩ := (hf i).exists_eLpNorm_indicator_compl_lt hp_top (coe_ne_zero.2 hε.ne') refine ⟨s, ne_of_lt hμs, fun j => ?_⟩ - convert hfε.le + convert! hfε.le /-- This lemma is less general than `MeasureTheory.unifTight_finite` which applies to all sequences indexed by a finite type. -/ diff --git a/Mathlib/MeasureTheory/Function/UniformIntegrable.lean b/Mathlib/MeasureTheory/Function/UniformIntegrable.lean index a53c3a3b783dea..dcab66cc8c31de 100644 --- a/Mathlib/MeasureTheory/Function/UniformIntegrable.lean +++ b/Mathlib/MeasureTheory/Function/UniformIntegrable.lean @@ -220,7 +220,7 @@ theorem MemLp.integral_indicator_norm_ge_le (hf : MemLp f 1 μ) (hmeas : Strongl obtain ⟨M, hM⟩ := this (ENNReal.ofReal ε) (ENNReal.ofReal_pos.2 hε) simp only [sub_zero] at hM refine ⟨M, ?_⟩ - convert hM M le_rfl + convert! hM M le_rfl simp only [coe_nnnorm, ENNReal.ofReal_eq_coe_nnreal (norm_nonneg _)] rfl @@ -286,7 +286,7 @@ theorem MemLp.eLpNorm_indicator_norm_ge_le (hf : MemLp f p μ) (hmeas : Strongly rw [ENNReal.rpow_mul] gcongr rw [ENNReal.ofReal_rpow_of_pos hε] - convert hM using 3 with x + convert! hM using 3 with x rw [enorm_indicator_eq_indicator_enorm, enorm_indicator_eq_indicator_enorm] have hiff : M ^ (1 / p.toReal) ≤ ‖f x‖₊ ↔ M ≤ ‖‖f x‖ ^ p.toReal‖₊ := by rw [coe_nnnorm, coe_nnnorm, Real.norm_rpow_of_nonneg (norm_nonneg _), norm_norm, @@ -397,7 +397,7 @@ theorem MemLp.eLpNorm_indicator_le (hp_one : 1 ≤ p) (hp_top : p ≠ ∞) (hf : obtain ⟨⟨f', hf', heq⟩, _⟩ := hf obtain ⟨δ, hδpos, hδ⟩ := (hℒp.ae_eq heq).eLpNorm_indicator_le_of_meas hp_one hp_top hf' hε refine ⟨δ, hδpos, fun s hs hμs => ?_⟩ - convert hδ s hs hμs using 1 + convert! hδ s hs hμs using 1 rw [eLpNorm_indicator_eq_eLpNorm_restrict hs, eLpNorm_indicator_eq_eLpNorm_restrict hs] exact eLpNorm_congr_ae heq.restrict @@ -416,7 +416,7 @@ theorem unifIntegrable_subsingleton [Subsingleton ι] (hp_one : 1 ≤ p) (hp_top · obtain ⟨i⟩ := hι obtain ⟨δ, hδpos, hδ⟩ := (hf i).eLpNorm_indicator_le hp_one hp_top hε refine ⟨δ, hδpos, fun j s hs hμs => ?_⟩ - convert hδ s hs hμs + convert! hδ s hs hμs · exact ⟨1, zero_lt_one, fun i => False.elim <| hι <| Nonempty.intro i⟩ /-- This lemma is less general than `MeasureTheory.unifIntegrable_finite` which applies to @@ -530,7 +530,7 @@ theorem tendsto_Lp_finite_of_tendsto_ae [IsFiniteMeasure μ] (hp : 1 ≤ p) (hp' exact fun n => (hf n).ae_eq_mk filter_upwards [hfg, h_ae_forall_eq, hg.1.ae_eq_mk] with x hx_tendsto hxf_eq hxg_eq rw [← hxg_eq] - convert hx_tendsto using 1 + convert! hx_tendsto using 1 ext1 n exact (hxf_eq n).symm @@ -917,7 +917,7 @@ theorem uniformIntegrable_average /-- The averaging of a uniformly integrable real-valued sequence is also uniformly integrable. -/ theorem uniformIntegrable_average_real (hp : 1 ≤ p) {f : ℕ → α → ℝ} (hf : UniformIntegrable f p μ) : UniformIntegrable (fun n => (∑ i ∈ Finset.range n, f i) / (n : α → ℝ)) p μ := by - convert uniformIntegrable_average hp hf using 2 with n + convert! uniformIntegrable_average hp hf using 2 with n ext x simp [div_eq_inv_mul] diff --git a/Mathlib/MeasureTheory/Group/Arithmetic.lean b/Mathlib/MeasureTheory/Group/Arithmetic.lean index d478081cf97664..d0e38d0e2b78e3 100644 --- a/Mathlib/MeasureTheory/Group/Arithmetic.lean +++ b/Mathlib/MeasureTheory/Group/Arithmetic.lean @@ -336,11 +336,11 @@ export MeasurableNeg (measurable_neg) instance (priority := 100) measurableDiv_of_mul_inv (G : Type*) [MeasurableSpace G] [DivInvMonoid G] [MeasurableMul G] [MeasurableInv G] : MeasurableDiv G where measurable_const_div c := by - convert measurable_inv.const_mul c using 1 + convert! measurable_inv.const_mul c using 1 ext1 apply div_eq_mul_inv measurable_div_const c := by - convert measurable_id.mul_const c⁻¹ using 1 + convert! measurable_id.mul_const c⁻¹ using 1 ext1 apply div_eq_mul_inv diff --git a/Mathlib/MeasureTheory/Group/FundamentalDomain.lean b/Mathlib/MeasureTheory/Group/FundamentalDomain.lean index 5858e90e8e10b6..dbdaa3f8f8bcc1 100644 --- a/Mathlib/MeasureTheory/Group/FundamentalDomain.lean +++ b/Mathlib/MeasureTheory/Group/FundamentalDomain.lean @@ -311,7 +311,7 @@ theorem measure_set_eq (hs : IsFundamentalDomain G s μ) (ht : IsFundamentalDoma (hA₀ : MeasurableSet A) (hA : ∀ g : G, (fun x => g • x) ⁻¹' A = A) : μ (A ∩ s) = μ (A ∩ t) := by have : ∫⁻ x in s, A.indicator 1 x ∂μ = ∫⁻ x in t, A.indicator 1 x ∂μ := by refine hs.setLIntegral_eq ht (Set.indicator A fun _ => 1) fun g x ↦ ?_ - convert (Set.indicator_comp_right (g • · : α → α) (g := fun _ ↦ (1 : ℝ≥0∞))).symm + convert! (Set.indicator_comp_right (g • · : α → α) (g := fun _ ↦ (1 : ℝ≥0∞))).symm rw [hA g] simpa [Measure.restrict_apply hA₀, lintegral_indicator hA₀] using this @@ -818,7 +818,7 @@ theorem IsFundamentalDomain.quotientMeasureEqMeasurePreimage_of_zero apply fund_dom_s.quotientMeasureEqMeasurePreimage ext U meas_U simp only [Measure.coe_zero, Pi.zero_apply] - convert (measure_inter_null_of_null_right (h := vol_s) (Quotient.mk α_mod_G ⁻¹' U)).symm + convert! (measure_inter_null_of_null_right (h := vol_s) (Quotient.mk α_mod_G ⁻¹' U)).symm rw [measure_map_restrict_apply (meas_U := meas_U)] /-- If a measure `μ` on a quotient satisfies `QuotientMeasureEqMeasurePreimage` with respect to a @@ -844,7 +844,7 @@ lemma QuotientMeasureEqMeasurePreimage.sigmaFiniteQuotient rw [fund_dom_s.measure_eq_tsum (A n)] exact measure_iUnion_le _ · rw [← image_iUnion, hA'] - refine image_univ_of_surjective (by convert Quotient.mk'_surjective) + refine image_univ_of_surjective (by convert! Quotient.mk'_surjective) /-- A measure `μ` on `α ⧸ G` satisfying `QuotientMeasureEqMeasurePreimage` and having finite covolume is a finite measure. -/ @@ -857,7 +857,7 @@ theorem QuotientMeasureEqMeasurePreimage.isFiniteMeasure_quotient rw [h𝓕.projection_respects_measure (μ := μ)] have : Fact (ν 𝓕 < ∞) := by apply Fact.mk - convert Ne.lt_top h + convert! Ne.lt_top h exact (h𝓕.covolume_eq_volume ν).symm infer_instance diff --git a/Mathlib/MeasureTheory/Group/Integral.lean b/Mathlib/MeasureTheory/Group/Integral.lean index 4355cfc14dadae..e1a4f711b47a4d 100644 --- a/Mathlib/MeasureTheory/Group/Integral.lean +++ b/Mathlib/MeasureTheory/Group/Integral.lean @@ -156,7 +156,7 @@ theorem Integrable.comp_div_left {f : G → F} [IsInvInvariant μ] [IsMulLeftInv theorem integrable_comp_div_left (f : G → F) [IsInvInvariant μ] [IsMulLeftInvariant μ] (g : G) : Integrable (fun t => f (g / t)) μ ↔ Integrable f μ := by refine ⟨fun h => ?_, fun h => h.comp_div_left g⟩ - convert h.comp_inv.comp_mul_left g⁻¹ + convert! h.comp_inv.comp_mul_left g⁻¹ simp_rw [div_inv_eq_mul, mul_inv_cancel_left] @[to_additive] diff --git a/Mathlib/MeasureTheory/Group/LIntegral.lean b/Mathlib/MeasureTheory/Group/LIntegral.lean index 2ec2a9425c6c62..76f023b666b4fe 100644 --- a/Mathlib/MeasureTheory/Group/LIntegral.lean +++ b/Mathlib/MeasureTheory/Group/LIntegral.lean @@ -52,7 +52,7 @@ with respect to a left-invariant measure. -/ respect to a left-invariant measure. -/] theorem lintegral_mul_left_eq_self [IsMulLeftInvariant μ] (f : G → ℝ≥0∞) (g : G) : (∫⁻ x, f (g * x) ∂μ) = ∫⁻ x, f x ∂μ := by - convert (lintegral_map_equiv f <| MeasurableEquiv.mulLeft g).symm + convert! (lintegral_map_equiv f <| MeasurableEquiv.mulLeft g).symm simp [map_mul_left_eq_self μ g] /-- Translating a function by right-multiplication does not change its Lebesgue integral @@ -62,7 +62,7 @@ with respect to a right-invariant measure. -/ respect to a right-invariant measure. -/] theorem lintegral_mul_right_eq_self [IsMulRightInvariant μ] (f : G → ℝ≥0∞) (g : G) : (∫⁻ x, f (x * g) ∂μ) = ∫⁻ x, f x ∂μ := by - convert (lintegral_map_equiv f <| MeasurableEquiv.mulRight g).symm using 1 + convert! (lintegral_map_equiv f <| MeasurableEquiv.mulRight g).symm using 1 simp [map_mul_right_eq_self μ g] @[to_additive] diff --git a/Mathlib/MeasureTheory/Group/Measure.lean b/Mathlib/MeasureTheory/Group/Measure.lean index 4003e5696d3968..af02ac7c38eb0b 100644 --- a/Mathlib/MeasureTheory/Group/Measure.lean +++ b/Mathlib/MeasureTheory/Group/Measure.lean @@ -102,7 +102,7 @@ theorem MeasurePreserving.mul_right (μ : Measure G) [IsMulRightInvariant μ] (g @[to_additive] instance Subgroup.smulInvariantMeasure {G α : Type*} [Group G] [MulAction G α] [MeasurableSpace α] {μ : Measure α} [SMulInvariantMeasure G α μ] (H : Subgroup G) : SMulInvariantMeasure H α μ := - ⟨fun y s hs => by convert SMulInvariantMeasure.measure_preimage_smul (μ := μ) (y : G) hs⟩ + ⟨fun y s hs => by convert! SMulInvariantMeasure.measure_preimage_smul (μ := μ) (y : G) hs⟩ /-- An alternative way to prove that `μ` is left invariant under multiplication. -/ @[to_additive /-- An alternative way to prove that `μ` is left invariant under addition. -/] @@ -775,7 +775,7 @@ variable [Group G] [TopologicalSpace G] (μ : Measure G) [IsHaarMeasure μ] @[to_additive (attr := simp)] theorem haar_singleton [ContinuousMul G] [BorelSpace G] (g : G) : μ {g} = μ {(1 : G)} := by - convert measure_preimage_mul μ g⁻¹ _ + convert! measure_preimage_mul μ g⁻¹ _ simp only [mul_one, preimage_mul_left_singleton, inv_inv] @[to_additive IsAddHaarMeasure.smul] diff --git a/Mathlib/MeasureTheory/Group/Prod.lean b/Mathlib/MeasureTheory/Group/Prod.lean index e023d84c5d03ab..beebced4fd664b 100644 --- a/Mathlib/MeasureTheory/Group/Prod.lean +++ b/Mathlib/MeasureTheory/Group/Prod.lean @@ -100,7 +100,7 @@ theorem measurable_measure_mul_right (hs : MeasurableSet s) : suffices Measurable fun y => μ ((fun x => (x, y)) ⁻¹' ((fun z : G × G => ((1 : G), z.1 * z.2)) ⁻¹' univ ×ˢ s)) - by convert this using 1; ext1 x; congr 1 with y : 1; simp + by convert! this using 1; ext1 x; congr 1 with y : 1; simp apply measurable_measure_prodMk_right apply measurable_const.prodMk measurable_mul (MeasurableSet.univ.prod hs) infer_instance @@ -134,8 +134,8 @@ where `S` is the map `(x, y) ↦ (x, xy)` and `R` is `Prod.swap`. -/ /-- The map `(x, y) ↦ (y + x, - x)` is measure-preserving. -/] theorem measurePreserving_mul_prod_inv [IsMulLeftInvariant ν] : MeasurePreserving (fun z : G × G => (z.2 * z.1, z.1⁻¹)) (μ.prod ν) (μ.prod ν) := by - convert (measurePreserving_prod_inv_mul_swap ν μ).comp (measurePreserving_prod_mul_swap μ ν) - using 1 + convert! + (measurePreserving_prod_inv_mul_swap ν μ).comp (measurePreserving_prod_mul_swap μ ν) using 1 ext1 ⟨x, y⟩ simp_rw [Function.comp_apply, mul_inv_rev, inv_mul_cancel_right] @@ -234,7 +234,7 @@ theorem measure_mul_lintegral_eq [IsMulLeftInvariant ν] (sm : MeasurableSet s) fun x => measurable_const.indicator (measurable_mul_const _ sm) have : ∀ x y, s.indicator (fun _ : G => (1 : ℝ≥0∞)) (y * x) = ((fun z => z * x) ⁻¹' s).indicator (fun b : G => 1) y := by - intro x y; symm; convert indicator_comp_right (M := ℝ≥0∞) fun y => y * x using 2; ext1; rfl + intro x y; symm; convert! indicator_comp_right (M := ℝ≥0∞) fun y => y * x using 2; ext1; rfl simp_rw [this, lintegral_mul_const _ (ms _), lintegral_indicator (measurable_mul_const _ sm), setLIntegral_one] @@ -388,8 +388,8 @@ theorem measurePreserving_div_prod [IsMulRightInvariant μ] : /-- The map `(x, y) ↦ (x + y, - x)` is measure-preserving. -/] theorem measurePreserving_mul_prod_inv_right [IsMulRightInvariant μ] [IsMulRightInvariant ν] : MeasurePreserving (fun z : G × G => (z.1 * z.2, z.1⁻¹)) (μ.prod ν) (μ.prod ν) := by - convert (measurePreserving_prod_div_swap ν μ).comp (measurePreserving_prod_mul_swap_right μ ν) - using 1 + convert! + (measurePreserving_prod_div_swap ν μ).comp (measurePreserving_prod_mul_swap_right μ ν) using 1 ext1 ⟨x, y⟩ simp_rw [Function.comp_apply, div_mul_eq_div_div_swap, div_self', one_div] diff --git a/Mathlib/MeasureTheory/Integral/Average.lean b/Mathlib/MeasureTheory/Integral/Average.lean index 9b00b672cd1b28..ca8f317c0a3bf5 100644 --- a/Mathlib/MeasureTheory/Integral/Average.lean +++ b/Mathlib/MeasureTheory/Integral/Average.lean @@ -446,7 +446,7 @@ theorem integral_sub_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → by_cases hf : Integrable f μ · rw [integral_sub hf (integrable_const _), integral_average, sub_self] refine integral_undef fun h => hf ?_ - convert h.add (integrable_const (⨍ a, f a ∂μ)) + convert! h.add (integrable_const (⨍ a, f a ∂μ)) exact (sub_add_cancel _ _).symm theorem setAverage_sub_setAverage (hs : μ s ≠ ∞) (f : α → E) : diff --git a/Mathlib/MeasureTheory/Integral/Bochner/Basic.lean b/Mathlib/MeasureTheory/Integral/Bochner/Basic.lean index f7d635f4f3f771..4b417083a88974 100644 --- a/Mathlib/MeasureTheory/Integral/Bochner/Basic.lean +++ b/Mathlib/MeasureTheory/Integral/Bochner/Basic.lean @@ -187,23 +187,25 @@ variable {f : α → E} {m : MeasurableSpace α} {μ : Measure α} section Basic -variable [hE : CompleteSpace E] - -theorem integral_eq (f : α → E) (hf : Integrable f μ) : ∫ a, f a ∂μ = L1.integral (hf.toL1 f) := by +theorem integral_eq [hE : CompleteSpace E] (f : α → E) (hf : Integrable f μ) : + ∫ a, f a ∂μ = L1.integral (hf.toL1 f) := by simp [integral, hE, hf] theorem integral_eq_setToFun (f : α → E) : ∫ a, f a ∂μ = setToFun μ (weightedSMul μ) (dominatedFinMeasAdditive_weightedSMul μ) f := by - simp only [integral, hE, ↓reduceDIte, L1.integral, setToFun]; rfl + by_cases hE : CompleteSpace E + · simp only [integral, hE, ↓reduceDIte, L1.integral, setToFun] + rfl + · simp [integral, hE, setToFun] -theorem L1.integral_eq_integral (f : α →₁[μ] E) : L1.integral f = ∫ a, f a ∂μ := by +theorem L1.integral_eq_integral [CompleteSpace E] (f : α →₁[μ] E) : + L1.integral f = ∫ a, f a ∂μ := by simp only [integral, L1.integral, integral_eq_setToFun] exact (L1.setToFun_eq_setToL1 (dominatedFinMeasAdditive_weightedSMul μ) f).symm theorem integral_undef {f : α → G} (h : ¬Integrable f μ) : ∫ a, f a ∂μ = 0 := by - by_cases hG : CompleteSpace G - · simp [integral, hG, h] - · simp [integral, hG] + simp only [integral_eq_setToFun] + exact setToFun_undef (dominatedFinMeasAdditive_weightedSMul μ) h theorem Integrable.of_integral_ne_zero {f : α → G} (h : ∫ a, f a ∂μ ≠ 0) : Integrable f μ := Not.imp_symm integral_undef h @@ -216,10 +218,8 @@ variable (α G) @[simp] theorem integral_zero : ∫ _ : α, (0 : G) ∂μ = 0 := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact setToFun_zero (dominatedFinMeasAdditive_weightedSMul μ) - · simp [integral, hG] + simp only [integral_eq_setToFun] + apply setToFun_zero @[simp] theorem integral_zero' : integral μ (0 : α → G) = 0 := @@ -236,10 +236,8 @@ theorem integrable_of_integral_eq_one {f : α → ℝ} (h : ∫ x, f x ∂μ = 1 theorem integral_add {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, f a + g a ∂μ = ∫ a, f a ∂μ + ∫ a, g a ∂μ := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact setToFun_add (dominatedFinMeasAdditive_weightedSMul μ) hf hg - · simp [integral, hG] + simp only [integral_eq_setToFun] + exact setToFun_add (dominatedFinMeasAdditive_weightedSMul μ) hf hg theorem integral_add' {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, (f + g) a ∂μ = ∫ a, f a ∂μ + ∫ a, g a ∂μ := @@ -247,29 +245,23 @@ theorem integral_add' {f g : α → G} (hf : Integrable f μ) (hg : Integrable g theorem integral_finsetSum {ι} (s : Finset ι) {f : ι → α → G} (hf : ∀ i ∈ s, Integrable (f i) μ) : ∫ a, ∑ i ∈ s, f i a ∂μ = ∑ i ∈ s, ∫ a, f i a ∂μ := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact setToFun_finsetSum (dominatedFinMeasAdditive_weightedSMul _) s hf - · simp [integral, hG] + simp only [integral_eq_setToFun] + exact setToFun_finsetSum (dominatedFinMeasAdditive_weightedSMul _) s hf @[deprecated (since := "2026-04-08")] alias integral_finset_sum := integral_finsetSum @[integral_simps] theorem integral_neg (f : α → G) : ∫ a, -f a ∂μ = -∫ a, f a ∂μ := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact setToFun_neg (dominatedFinMeasAdditive_weightedSMul μ) f - · simp [integral, hG] + simp only [integral_eq_setToFun] + exact setToFun_neg (dominatedFinMeasAdditive_weightedSMul μ) f theorem integral_neg' (f : α → G) : ∫ a, (-f) a ∂μ = -∫ a, f a ∂μ := integral_neg f theorem integral_sub {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, f a - g a ∂μ = ∫ a, f a ∂μ - ∫ a, g a ∂μ := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact setToFun_sub (dominatedFinMeasAdditive_weightedSMul μ) hf hg - · simp [integral, hG] + simp only [integral_eq_setToFun] + exact setToFun_sub (dominatedFinMeasAdditive_weightedSMul μ) hf hg theorem integral_sub' {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, (f - g) a ∂μ = ∫ a, f a ∂μ - ∫ a, g a ∂μ := @@ -282,10 +274,8 @@ statement for more general rings with an *a priori* integrability assumption on @[integral_simps] theorem integral_smul [Module 𝕜 G] [NormSMulClass 𝕜 G] [SMulCommClass ℝ 𝕜 G] (c : 𝕜) (f : α → G) : ∫ a, c • f a ∂μ = c • ∫ a, f a ∂μ := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact setToFun_smul (dominatedFinMeasAdditive_weightedSMul μ) weightedSMul_smul c f - · simp [integral, hG] + simp only [integral_eq_setToFun] + exact setToFun_smul (dominatedFinMeasAdditive_weightedSMul μ) weightedSMul_smul c f theorem Integrable.integral_smul {R : Type*} [NormedRing R] [Module R G] [IsBoundedSMul R G] [SMulCommClass ℝ R G] (c : R) @@ -307,10 +297,8 @@ theorem integral_div {L : Type*} [RCLike L] (r : L) (f : α → L) : simpa only [← div_eq_mul_inv] using integral_mul_const r⁻¹ f theorem integral_congr_ae {f g : α → G} (h : f =ᵐ[μ] g) : ∫ a, f a ∂μ = ∫ a, g a ∂μ := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact setToFun_congr_ae (dominatedFinMeasAdditive_weightedSMul μ) h - · simp [integral, hG] + simp only [integral_eq_setToFun] + exact setToFun_congr_ae (dominatedFinMeasAdditive_weightedSMul μ) h lemma integral_congr_ae₂ {β : Type*} {_ : MeasurableSpace β} {ν : Measure β} {f g : α → β → G} (h : ∀ᵐ a ∂μ, f a =ᵐ[ν] g a) : @@ -323,10 +311,8 @@ lemma integral_congr_ae₂ {β : Type*} {_ : MeasurableSpace β} {ν : Measure @[simp] theorem L1.integral_of_fun_eq_integral' {f : α → G} (hf : Integrable f μ) : ∫ a, (AEEqFun.mk f hf.aestronglyMeasurable) a ∂μ = ∫ a, f a ∂μ := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact setToFun_toL1 (dominatedFinMeasAdditive_weightedSMul μ) hf - · simp [MeasureTheory.integral, hG] + simp only [integral_eq_setToFun] + exact setToFun_toL1 (dominatedFinMeasAdditive_weightedSMul μ) hf theorem L1.integral_of_fun_eq_integral {f : α → G} (hf : Integrable f μ) : ∫ a, (hf.toL1 f) a ∂μ = ∫ a, f a ∂μ := by @@ -334,24 +320,17 @@ theorem L1.integral_of_fun_eq_integral {f : α → G} (hf : Integrable f μ) : @[continuity] theorem continuous_integral : Continuous fun f : α →₁[μ] G => ∫ a, f a ∂μ := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact continuous_setToFun (dominatedFinMeasAdditive_weightedSMul μ) - · simp [integral, hG, continuous_const] + simp only [integral_eq_setToFun] + exact continuous_setToFun (dominatedFinMeasAdditive_weightedSMul μ) theorem norm_integral_le_lintegral_norm (f : α → G) : ‖∫ a, f a ∂μ‖ ≤ ENNReal.toReal (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) := by - by_cases hG : CompleteSpace G - · by_cases hf : Integrable f μ - · rw [integral_eq f hf, ← Integrable.norm_toL1_eq_lintegral_norm f hf] - exact L1.norm_integral_le _ - · rw [integral_undef hf, norm_zero]; exact toReal_nonneg - · simp [integral, hG] + simp only [integral_eq_setToFun] + exact (norm_setToFun_le_toReal _ (by simp)).trans (by simp) theorem enorm_integral_le_lintegral_enorm (f : α → G) : ‖∫ a, f a ∂μ‖ₑ ≤ ∫⁻ a, ‖f a‖ₑ ∂μ := by - simp_rw [← ofReal_norm_eq_enorm] - apply ENNReal.ofReal_le_of_le_toReal - exact norm_integral_le_lintegral_norm f + simp only [integral_eq_setToFun] + exact (enorm_setToFun_le _ (by simp)).trans (by simp) theorem dist_integral_le_lintegral_edist {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : @@ -396,26 +375,24 @@ theorem Integrable.tendsto_setIntegral_nhds_zero {ι} {f : α → G} (hf : Integ hf.2.tendsto_setIntegral_nhds_zero hs /-- If `F i → f` in `L1`, then `∫ x, F i x ∂μ → ∫ x, f x ∂μ`. -/ -theorem tendsto_integral_of_L1 {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} - (hFi : ∀ᶠ i in l, Integrable (F i) μ) +theorem tendsto_integral_of_L1 {ι} (f : α → G) (hfi : AEStronglyMeasurable f μ) + {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i => ∫⁻ x, ‖F i x - f x‖ₑ ∂μ) l (𝓝 0)) : Tendsto (fun i => ∫ x, F i x ∂μ) l (𝓝 <| ∫ x, f x ∂μ) := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact tendsto_setToFun_of_L1 (dominatedFinMeasAdditive_weightedSMul μ) - f hfi.aestronglyMeasurable hFi hF - · simp [integral, hG, tendsto_const_nhds] + simp only [integral_eq_setToFun] + exact tendsto_setToFun_of_L1 (dominatedFinMeasAdditive_weightedSMul μ) f hfi hFi hF /-- If `F i → f` in `L1`, then `∫ x, F i x ∂μ → ∫ x, f x ∂μ`. -/ -lemma tendsto_integral_of_L1' {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} - (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i ↦ eLpNorm (F i - f) 1 μ) l (𝓝 0)) : +lemma tendsto_integral_of_L1' {ι} (f : α → G) (hfi : AEStronglyMeasurable f μ) + {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) + (hF : Tendsto (fun i ↦ eLpNorm (F i - f) 1 μ) l (𝓝 0)) : Tendsto (fun i ↦ ∫ x, F i x ∂μ) l (𝓝 (∫ x, f x ∂μ)) := by refine tendsto_integral_of_L1 f hfi hFi ?_ simp_rw [eLpNorm_one_eq_lintegral_enorm, Pi.sub_apply] at hF exact hF /-- If `F i → f` in `L1`, then `∫ x in s, F i x ∂μ → ∫ x in s, f x ∂μ`. -/ -lemma tendsto_setIntegral_of_L1 {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} +lemma tendsto_setIntegral_of_L1 {ι} (f : α → G) (hfi : AEStronglyMeasurable f μ) {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i ↦ ∫⁻ x, ‖F i x - f x‖ₑ ∂μ) l (𝓝 0)) (s : Set α) : @@ -427,10 +404,9 @@ lemma tendsto_setIntegral_of_L1 {ι} (f : α → G) (hfi : Integrable f μ) {F : (fun _ ↦ eLpNorm_mono_measure _ Measure.restrict_le_self) /-- If `F i → f` in `L1`, then `∫ x in s, F i x ∂μ → ∫ x in s, f x ∂μ`. -/ -lemma tendsto_setIntegral_of_L1' {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} - {l : Filter ι} - (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i ↦ eLpNorm (F i - f) 1 μ) l (𝓝 0)) - (s : Set α) : +lemma tendsto_setIntegral_of_L1' {ι} (f : α → G) (hfi : AEStronglyMeasurable f μ) {F : ι → α → G} + {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) + (hF : Tendsto (fun i ↦ eLpNorm (F i - f) 1 μ) l (𝓝 0)) (s : Set α) : Tendsto (fun i ↦ ∫ x in s, F i x ∂μ) l (𝓝 (∫ x in s, f x ∂μ)) := by refine tendsto_setIntegral_of_L1 f hfi hFi ?_ s simp_rw [eLpNorm_one_eq_lintegral_enorm, Pi.sub_apply] at hF @@ -443,43 +419,35 @@ theorem continuousWithinAt_of_dominated {F : X → α → G} {x₀ : X} {bound : (h_bound : ∀ᶠ x in 𝓝[s] x₀, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, ContinuousWithinAt (fun x => F x a) s x₀) : ContinuousWithinAt (fun x => ∫ a, F x a ∂μ) s x₀ := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact continuousWithinAt_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) - hF_meas h_bound bound_integrable h_cont - · simp [integral, hG, continuousWithinAt_const] + simp only [integral_eq_setToFun] + exact continuousWithinAt_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) + hF_meas h_bound bound_integrable h_cont theorem continuousAt_of_dominated {F : X → α → G} {x₀ : X} {bound : α → ℝ} (hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) μ) (h_bound : ∀ᶠ x in 𝓝 x₀, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, ContinuousAt (fun x => F x a) x₀) : ContinuousAt (fun x => ∫ a, F x a ∂μ) x₀ := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact continuousAt_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) - hF_meas h_bound bound_integrable h_cont - · simp [integral, hG, continuousAt_const] + simp only [integral_eq_setToFun] + exact continuousAt_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) + hF_meas h_bound bound_integrable h_cont theorem continuousOn_of_dominated {F : X → α → G} {bound : α → ℝ} {s : Set X} (hF_meas : ∀ x ∈ s, AEStronglyMeasurable (F x) μ) (h_bound : ∀ x ∈ s, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, ContinuousOn (fun x => F x a) s) : ContinuousOn (fun x => ∫ a, F x a ∂μ) s := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact continuousOn_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) - hF_meas h_bound bound_integrable h_cont - · simp [integral, hG, continuousOn_const] + simp only [integral_eq_setToFun] + exact continuousOn_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) + hF_meas h_bound bound_integrable h_cont theorem continuous_of_dominated {F : X → α → G} {bound : α → ℝ} (hF_meas : ∀ x, AEStronglyMeasurable (F x) μ) (h_bound : ∀ x, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, Continuous fun x => F x a) : Continuous fun x => ∫ a, F x a ∂μ := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact continuous_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) - hF_meas h_bound bound_integrable h_cont - · simp [integral, hG, continuous_const] + simp only [integral_eq_setToFun] + exact continuous_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) + hF_meas h_bound bound_integrable h_cont /-- The Bochner integral of a real-valued function `f : α → ℝ` is the difference between the integral of the positive part of `f` and the integral of the negative part of `f`. -/ @@ -537,7 +505,7 @@ theorem integral_eq_lintegral_of_nonneg_ae {f : α → ℝ} (hf : 0 ≤ᵐ[μ] f theorem integral_norm_eq_lintegral_enorm {P : Type*} [NormedAddCommGroup P] {f : α → P} (hf : AEStronglyMeasurable f μ) : ∫ x, ‖f x‖ ∂μ = (∫⁻ x, ‖f x‖ₑ ∂μ).toReal := by rw [integral_eq_lintegral_of_nonneg_ae _ hf.norm] - · simp_rw [ofReal_norm_eq_enorm] + · simp_rw [ofReal_norm] · filter_upwards; simp_rw [Pi.zero_apply, norm_nonneg, imp_true_iff] theorem ofReal_integral_norm_eq_lintegral_enorm {P : Type*} [NormedAddCommGroup P] {f : α → P} @@ -545,18 +513,18 @@ theorem ofReal_integral_norm_eq_lintegral_enorm {P : Type*} [NormedAddCommGroup rw [integral_norm_eq_lintegral_enorm hf.aestronglyMeasurable, ENNReal.ofReal_toReal] exact lt_top_iff_ne_top.mp (hasFiniteIntegral_iff_enorm.mpr hf.2) -theorem SimpleFunc.integral_eq_integral (f : α →ₛ E) (hfi : Integrable f μ) : +theorem SimpleFunc.integral_eq_integral [CompleteSpace E] (f : α →ₛ E) (hfi : Integrable f μ) : f.integral μ = ∫ x, f x ∂μ := by rw [MeasureTheory.integral_eq f hfi, ← L1.SimpleFunc.toLp_one_eq_toL1, L1.SimpleFunc.integral_L1_eq_integral, L1.SimpleFunc.integral_eq_integral] exact SimpleFunc.integral_congr hfi (Lp.simpleFunc.toSimpleFunc_toLp _ _).symm -theorem SimpleFunc.integral_eq_sum (f : α →ₛ E) (hfi : Integrable f μ) : +theorem SimpleFunc.integral_eq_sum [CompleteSpace E] (f : α →ₛ E) (hfi : Integrable f μ) : ∫ x, f x ∂μ = ∑ x ∈ f.range, μ.real (f ⁻¹' {x}) • x := by rw [← f.integral_eq_integral hfi, SimpleFunc.integral, ← SimpleFunc.integral_eq]; rfl -theorem tendsto_integral_approxOn_of_measurable [MeasurableSpace E] [BorelSpace E] {f : α → E} - {s : Set E} [SeparableSpace s] (hfi : Integrable f μ) (hfm : Measurable f) +theorem tendsto_integral_approxOn_of_measurable [CompleteSpace E] [MeasurableSpace E] [BorelSpace E] + {f : α → E} {s : Set E} [SeparableSpace s] (hfi : Integrable f μ) (hfm : Measurable f) (hs : ∀ᵐ x ∂μ, f x ∈ closure s) {y₀ : E} (h₀ : y₀ ∈ s) (h₀i : Integrable (fun _ => y₀) μ) : Tendsto (fun n => (SimpleFunc.approxOn f hfm s y₀ h₀ n).integral μ) atTop (𝓝 <| ∫ x, f x ∂μ) := by @@ -565,7 +533,8 @@ theorem tendsto_integral_approxOn_of_measurable [MeasurableSpace E] [BorelSpace exact tendsto_setToFun_approxOn_of_measurable (dominatedFinMeasAdditive_weightedSMul μ) hfi hfm hs h₀ h₀i -theorem tendsto_integral_approxOn_of_measurable_of_range_subset [MeasurableSpace E] [BorelSpace E] +theorem tendsto_integral_approxOn_of_measurable_of_range_subset + [CompleteSpace E] [MeasurableSpace E] [BorelSpace E] {f : α → E} (fmeas : Measurable f) (hf : Integrable f μ) (s : Set E) [SeparableSpace s] (hs : range f ∪ {0} ⊆ s) : Tendsto (fun n => (SimpleFunc.approxOn f fmeas s 0 (hs <| by simp) n).integral μ) atTop @@ -574,13 +543,13 @@ theorem tendsto_integral_approxOn_of_measurable_of_range_subset [MeasurableSpace exact Eventually.of_forall fun x => subset_closure (hs (Set.mem_union_left _ (mem_range_self _))) -- We redeclare `E` here to temporarily avoid --- the `[CompleteSpace E]` and `[NormedSpace ℝ E]` instances. +-- the `[NormedSpace ℝ E]` instance. theorem tendsto_integral_norm_approxOn_sub {E : Type*} [NormedAddCommGroup E] [MeasurableSpace E] [BorelSpace E] {f : α → E} (fmeas : Measurable f) (hf : Integrable f μ) [SeparableSpace (range f ∪ {0} : Set E)] : Tendsto (fun n ↦ ∫ x, ‖SimpleFunc.approxOn f fmeas (range f ∪ {0}) 0 (by simp) n x - f x‖ ∂μ) atTop (𝓝 0) := by - convert (tendsto_toReal zero_ne_top).comp (tendsto_approxOn_range_L1_enorm fmeas hf) with n + convert! (tendsto_toReal zero_ne_top).comp (tendsto_approxOn_range_L1_enorm fmeas hf) with n rw [integral_norm_eq_lintegral_enorm] · simp · apply (SimpleFunc.aestronglyMeasurable _).sub @@ -622,11 +591,9 @@ variable [ClosedIciTopology E] /-- The integral of a function which is nonnegative almost everywhere is nonnegative. -/ lemma integral_nonneg_of_ae {f : α → E} (hf : 0 ≤ᵐ[μ] f) : - 0 ≤ ∫ x, f x ∂μ := by - by_cases hE : CompleteSpace E - · exact integral_eq_setToFun f ▸ setToFun_nonneg (dominatedFinMeasAdditive_weightedSMul μ) - (fun s _ _ => weightedSMul_nonneg s) hf - · simp [integral, hE] + 0 ≤ ∫ x, f x ∂μ := + integral_eq_setToFun f ▸ setToFun_nonneg (dominatedFinMeasAdditive_weightedSMul μ) + (fun s _ _ => weightedSMul_nonneg s) hf lemma integral_nonneg {f : α → E} (hf : 0 ≤ f) : 0 ≤ ∫ x, f x ∂μ := @@ -722,7 +689,7 @@ theorem ofReal_integral_eq_lintegral_ofReal {f : α → ℝ} (hfi : Integrable f ENNReal.ofReal (∫ x, f x ∂μ) = ∫⁻ x, ENNReal.ofReal (f x) ∂μ := by have : f =ᵐ[μ] (‖f ·‖) := f_nn.mono fun _x hx ↦ (abs_of_nonneg hx).symm simp_rw [integral_congr_ae this, ofReal_integral_norm_eq_lintegral_enorm hfi, - ← ofReal_norm_eq_enorm] + ← ofReal_norm] exact lintegral_congr_ae (this.symm.fun_comp ENNReal.ofReal) theorem integral_toReal {f : α → ℝ≥0∞} (hfm : AEMeasurable f μ) (hf : ∀ᵐ x ∂μ, f x < ∞) : @@ -828,7 +795,7 @@ lemma integral_tendsto_of_tendsto_of_antitone {μ : Measure α} {f : ℕ → α suffices Tendsto (fun n ↦ ∫ x, -f n x ∂μ) atTop (𝓝 (∫ x, -F x ∂μ)) by suffices Tendsto (fun n ↦ ∫ x, - -f n x ∂μ) atTop (𝓝 (∫ x, - -F x ∂μ)) by simpa [neg_neg] using this - convert this.neg <;> rw [integral_neg] + convert! this.neg <;> rw [integral_neg] refine integral_tendsto_of_tendsto_of_monotone (fun n ↦ (hf n).neg) hF.neg ?_ ?_ · filter_upwards [h_mono] with x hx n m hnm using neg_le_neg_iff.mpr <| hx hnm · filter_upwards [h_tendsto] with x hx using hx.neg @@ -904,11 +871,11 @@ lemma tendsto_of_integral_tendsto_of_antitone {μ : Measure α} {f : ℕ → α let F' : α → ℝ := fun a ↦ - F a suffices ∀ᵐ a ∂μ, Tendsto (fun i ↦ f' i a) atTop (𝓝 (F' a)) by filter_upwards [this] with a ha_tendsto - convert ha_tendsto.neg + convert! ha_tendsto.neg · simp [f'] · simp [F'] refine tendsto_of_integral_tendsto_of_monotone (fun n ↦ (hf_int n).neg) hF_int.neg ?_ ?_ ?_ - · convert hf_tendsto.neg + · convert! hf_tendsto.neg · rw [integral_neg] · rw [integral_neg] · filter_upwards [hf_mono] with a ha i j hij @@ -940,7 +907,7 @@ theorem MemLp.eLpNorm_eq_integral_rpow_norm {f : α → H} {p : ℝ≥0∞} (hp1 (hf : MemLp f p μ) : eLpNorm f p μ = ENNReal.ofReal ((∫ a, ‖f a‖ ^ p.toReal ∂μ) ^ p.toReal⁻¹) := by have A : ∫⁻ a : α, ENNReal.ofReal (‖f a‖ ^ p.toReal) ∂μ = ∫⁻ a : α, ‖f a‖ₑ ^ p.toReal ∂μ := by - simp_rw [← ofReal_rpow_of_nonneg (norm_nonneg _) toReal_nonneg, ofReal_norm_eq_enorm] + simp_rw [← ofReal_rpow_of_nonneg (norm_nonneg _) toReal_nonneg, ofReal_norm] simp only [eLpNorm_eq_lintegral_rpow_enorm_toReal hp1 hp2, one_div] rw [integral_eq_lintegral_of_nonneg_ae]; rotate_left · exact ae_of_all _ fun x => by positivity @@ -992,31 +959,16 @@ variable {ν : Measure α} theorem integral_add_measure {f : α → G} (hμ : Integrable f μ) (hν : Integrable f ν) : ∫ x, f x ∂(μ + ν) = ∫ x, f x ∂μ + ∫ x, f x ∂ν := by - by_cases hG : CompleteSpace G; swap - · simp [integral, hG] - have hfi := hμ.add_measure hν - simp_rw [integral_eq_setToFun] - have hμ_dfma : DominatedFinMeasAdditive (μ + ν) (weightedSMul μ : Set α → G →L[ℝ] G) 1 := - DominatedFinMeasAdditive.add_measure_right μ ν (dominatedFinMeasAdditive_weightedSMul μ) - zero_le_one - have hν_dfma : DominatedFinMeasAdditive (μ + ν) (weightedSMul ν : Set α → G →L[ℝ] G) 1 := - DominatedFinMeasAdditive.add_measure_left μ ν (dominatedFinMeasAdditive_weightedSMul ν) - zero_le_one - rw [← setToFun_congr_measure_of_add_right hμ_dfma - (dominatedFinMeasAdditive_weightedSMul μ) f hfi, - ← setToFun_congr_measure_of_add_left hν_dfma (dominatedFinMeasAdditive_weightedSMul ν) f hfi] - refine setToFun_add_left' _ _ _ (fun s _ hμνs => ?_) f - rw [Measure.coe_add, Pi.add_apply, add_lt_top] at hμνs - rw [weightedSMul, weightedSMul, weightedSMul, ← add_smul, - measureReal_add_apply hμνs.1.ne hμνs.2.ne] + simp only [integral_eq_setToFun] + apply setToFun_add_left'' (fun s hs h's ↦ ?_) hμ hν le_rfl zero_le_one zero_le_one zero_le_one + simp only [Measure.coe_add, Pi.add_apply, add_lt_top] at h's + simp [weightedSMul, Measure.real, toReal_add, h's.1.ne, h's.2.ne, add_smul] @[simp] theorem integral_zero_measure {m : MeasurableSpace α} (f : α → G) : (∫ x, f x ∂(0 : Measure α)) = 0 := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact setToFun_measure_zero (dominatedFinMeasAdditive_weightedSMul _) rfl - · simp [integral, hG] + simp only [integral_eq_setToFun] + exact setToFun_measure_zero (dominatedFinMeasAdditive_weightedSMul _) rfl @[simp] theorem setIntegral_measure_zero (f : α → G) {μ : Measure α} {s : Set α} (hs : μ s = 0) : @@ -1047,8 +999,6 @@ theorem nndist_integral_add_measure_le_lintegral @[simp] theorem integral_smul_measure (f : α → G) (c : ℝ≥0∞) : ∫ x, f x ∂c • μ = c.toReal • ∫ x, f x ∂μ := by - by_cases hG : CompleteSpace G; swap - · simp [integral, hG] -- First we consider the “degenerate” case `c = ∞` rcases eq_or_ne c ∞ with (rfl | hc) · rw [ENNReal.toReal_top, zero_smul, integral_eq_setToFun, setToFun_top_smul_measure] @@ -1067,25 +1017,14 @@ theorem integral_smul_nnreal_measure (f : α → G) (c : ℝ≥0) : theorem integral_map_of_stronglyMeasurable {β} [MeasurableSpace β] {φ : α → β} (hφ : Measurable φ) {f : β → G} (hfm : StronglyMeasurable f) : ∫ y, f y ∂Measure.map φ μ = ∫ x, f (φ x) ∂μ := by - by_cases hG : CompleteSpace G; swap - · simp [integral, hG] by_cases hfi : Integrable f (Measure.map φ μ); swap · rw [integral_undef hfi, integral_undef] exact fun hfφ => hfi ((integrable_map_measure hfm.aestronglyMeasurable hφ.aemeasurable).2 hfφ) - borelize G - have : SeparableSpace (range f ∪ {0} : Set G) := hfm.separableSpace_range_union_singleton - refine tendsto_nhds_unique - (tendsto_integral_approxOn_of_measurable_of_range_subset hfm.measurable hfi _ Subset.rfl) ?_ - convert tendsto_integral_approxOn_of_measurable_of_range_subset (hfm.measurable.comp hφ) - ((integrable_map_measure hfm.aestronglyMeasurable hφ.aemeasurable).1 hfi) (range f ∪ {0}) - (union_subset_union_left {0} (range_comp_subset_range φ f)) using 1 - ext1 i - simp only [SimpleFunc.integral_eq, hφ, SimpleFunc.measurableSet_preimage, map_measureReal_apply, - ← preimage_comp] - refine (Finset.sum_subset (SimpleFunc.range_comp_subset_range _ hφ) fun y _ hy => ?_).symm - rw [SimpleFunc.mem_range, ← Set.preimage_singleton_eq_empty, SimpleFunc.coe_comp] at hy - rw [hy] - simp + simp only [integral_eq_setToFun] + apply setToFun_of_le_map_of_stronglyMeasurable _ _ + ((integrable_map_measure hfm.aestronglyMeasurable hφ.aemeasurable).1 hfi) hfm hφ le_rfl + intro s x hs + simp [weightedSMul_apply, map_measureReal_apply, hs, hφ] theorem integral_map {β} [MeasurableSpace β] {φ : α → β} (hφ : AEMeasurable φ μ) {f : β → G} (hfm : AEStronglyMeasurable f (Measure.map φ μ)) : @@ -1206,24 +1145,24 @@ theorem integral_mul_norm_le_Lp_mul_Lq {E} [NormedAddCommGroup E] {f g : α → -- replace norms by nnnorm have h_left : ∫⁻ a, ENNReal.ofReal (‖f a‖ * ‖g a‖) ∂μ = ∫⁻ a, ((‖f ·‖ₑ) * (‖g ·‖ₑ)) a ∂μ := by - simp_rw [Pi.mul_apply, ← ofReal_norm_eq_enorm, ENNReal.ofReal_mul (norm_nonneg _)] + simp_rw [Pi.mul_apply, ← ofReal_norm, ENNReal.ofReal_mul (norm_nonneg _)] have h_right_f : ∫⁻ a, .ofReal (‖f a‖ ^ p) ∂μ = ∫⁻ a, ‖f a‖ₑ ^ p ∂μ := by refine lintegral_congr fun x => ?_ - rw [← ofReal_norm_eq_enorm, ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) hpq.nonneg] + rw [← ofReal_norm, ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) hpq.nonneg] have h_right_g : ∫⁻ a, .ofReal (‖g a‖ ^ q) ∂μ = ∫⁻ a, ‖g a‖ₑ ^ q ∂μ := by refine lintegral_congr fun x => ?_ - rw [← ofReal_norm_eq_enorm, ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) hpq.symm.nonneg] + rw [← ofReal_norm, ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) hpq.symm.nonneg] rw [h_left, h_right_f, h_right_g] -- we can now apply `ENNReal.lintegral_mul_le_Lp_mul_Lq` (up to the `toReal` application) refine ENNReal.toReal_mono ?_ ?_ · refine ENNReal.mul_ne_top ?_ ?_ - · convert hf.eLpNorm_ne_top + · convert! hf.eLpNorm_ne_top rw [eLpNorm_eq_lintegral_rpow_enorm_toReal] · rw [ENNReal.toReal_ofReal hpq.nonneg] · rw [Ne, ENNReal.ofReal_eq_zero, not_le] exact hpq.pos · finiteness - · convert hg.eLpNorm_ne_top + · convert! hg.eLpNorm_ne_top rw [eLpNorm_eq_lintegral_rpow_enorm_toReal] · rw [ENNReal.toReal_ofReal hpq.symm.nonneg] · rw [Ne, ENNReal.ofReal_eq_zero, not_le] @@ -1327,11 +1266,11 @@ theorem integral_trim (hm : m ≤ m0) {f : β → G} (hf : StronglyMeasurable[m] have hf_seq_eq : ∀ n, ∫ x, f_seq n x ∂μ = ∫ x, f_seq n x ∂μ.trim hm := fun n => integral_trim_simpleFunc hm (f_seq n) (hf_seq_int n) have h_lim_1 : atTop.Tendsto (fun n => ∫ x, f_seq n x ∂μ) (𝓝 (∫ x, f x ∂μ)) := by - refine tendsto_integral_of_L1 f hf_int (Eventually.of_forall hf_seq_int) ?_ + refine tendsto_integral_of_L1 f hf_int.1 (Eventually.of_forall hf_seq_int) ?_ exact SimpleFunc.tendsto_approxOn_range_L1_enorm (hf.mono hm).measurable hf_int have h_lim_2 : atTop.Tendsto (fun n => ∫ x, f_seq n x ∂μ) (𝓝 (∫ x, f x ∂μ.trim hm)) := by simp_rw [hf_seq_eq] - refine @tendsto_integral_of_L1 β G _ _ m (μ.trim hm) _ f (hf_int.trim hm hf) _ _ + refine @tendsto_integral_of_L1 β G _ _ m (μ.trim hm) _ f (hf_int.trim hm hf).1 _ _ (Eventually.of_forall hf_seq_int_m) ?_ exact @SimpleFunc.tendsto_approxOn_range_L1_enorm β G m _ _ _ f _ _ hf.measurable (hf_int.trim hm hf) diff --git a/Mathlib/MeasureTheory/Integral/Bochner/ContinuousLinearMap.lean b/Mathlib/MeasureTheory/Integral/Bochner/ContinuousLinearMap.lean index 7db4535b5b5386..222cd4649f08e9 100644 --- a/Mathlib/MeasureTheory/Integral/Bochner/ContinuousLinearMap.lean +++ b/Mathlib/MeasureTheory/Integral/Bochner/ContinuousLinearMap.lean @@ -62,7 +62,7 @@ theorem integral_comp_commSL [CompleteSpace E] (hσ : ∀ (r : ℝ) (x : 𝕜), integral_add (μ := μ) (L.integrable_comp f_int) (L.integrable_comp g_int), hf, hg] · exact isClosed_eq L.continuous_integral_comp_L1 (L.continuous.comp continuous_integral) · intro f g hfg _ hf - convert hf using 1 <;> clear hf + convert! hf using 1 <;> clear hf · exact integral_congr_ae (hfg.fun_comp L).symm · rw [integral_congr_ae hfg.symm] @@ -279,7 +279,7 @@ theorem integral_withDensity_eq_integral_smul {f : X → ℝ≥0} (f_meas : Meas have C2 : Continuous fun u : Lp E 1 (μ.withDensity fun x => f x) => ∫ x, f x • u x ∂μ := by have : Continuous ((fun u : Lp E 1 μ => ∫ x, u x ∂μ) ∘ withDensitySMulLI (E := E) μ f_meas) := continuous_integral.comp (withDensitySMulLI (E := E) μ f_meas).continuous - convert this with u + convert! this with u simp only [Function.comp_apply, withDensitySMulLI_apply] exact integral_congr_ae (memL1_smul_of_L1_withDensity f_meas u).coeFn_toLp.symm exact isClosed_eq C1 C2 diff --git a/Mathlib/MeasureTheory/Integral/Bochner/L1.lean b/Mathlib/MeasureTheory/Integral/Bochner/L1.lean index 090ff83c850f09..007107e5c9cab4 100644 --- a/Mathlib/MeasureTheory/Integral/Bochner/L1.lean +++ b/Mathlib/MeasureTheory/Integral/Bochner/L1.lean @@ -468,7 +468,7 @@ theorem posPart_toSimpleFunc (f : α →₁ₛ[μ] ℝ) : have ae_eq : ∀ᵐ a ∂μ, toSimpleFunc (posPart f) a = max ((toSimpleFunc f) a) 0 := by filter_upwards [toSimpleFunc_eq_toFun (posPart f), Lp.coeFn_posPart (f : α →₁[μ] ℝ), toSimpleFunc_eq_toFun f] with _ _ h₂ h₃ - convert h₂ using 1 + convert! h₂ using 1 rw [h₃] refine ae_eq.mono fun a h => ?_ rw [h, eq] diff --git a/Mathlib/MeasureTheory/Integral/Bochner/Set.lean b/Mathlib/MeasureTheory/Integral/Bochner/Set.lean index 6b999846d27886..eb2412a769ea7c 100644 --- a/Mathlib/MeasureTheory/Integral/Bochner/Set.lean +++ b/Mathlib/MeasureTheory/Integral/Bochner/Set.lean @@ -128,7 +128,7 @@ theorem integral_biUnion_finset {ι : Type*} (t : Finset ι) {s : ι → Set X} theorem integral_iUnion_fintype {ι : Type*} [Fintype ι] {s : ι → Set X} (hs : ∀ i, MeasurableSet (s i)) (h's : Pairwise (Disjoint on s)) (hf : ∀ i, IntegrableOn f (s i) μ) : ∫ x in ⋃ i, s i, f x ∂μ = ∑ i, ∫ x in s i, f x ∂μ := by - convert integral_biUnion_finset Finset.univ (fun i _ => hs i) _ fun i _ => hf i + convert! integral_biUnion_finset Finset.univ (fun i _ => hs i) _ fun i _ => hf i · simp · simp [pairwise_univ, h's] @@ -214,7 +214,7 @@ theorem integral_biUnion_eq_sum_powerset {ι : Type*} {t : Finset ι} {s : ι rcases hu.2 with ⟨i, hi⟩ exact (hf i (hu.1 hi)).mono (biInter_subset_of_mem hi) le_rfl congr with x - convert Finset.indicator_biUnion_eq_sum_powerset t s f x with u hu + convert! Finset.indicator_biUnion_eq_sum_powerset t s f x with u hu rw [indicator_smul_apply] norm_cast @@ -298,7 +298,7 @@ theorem tendsto_setIntegral_of_antitone rcases hfi with ⟨i₀, hi₀⟩ suffices Tendsto (∫ x in s i₀, f x ∂μ - ∫ x in s i₀ \ s ·, f x ∂μ) atTop (𝓝 (∫ x in s i₀, f x ∂μ - ∫ x in ⋃ i, s i₀ \ s i, f x ∂μ)) by - convert this.congr' <| (eventually_ge_atTop i₀).mono fun i hi ↦ ?_ + convert! this.congr' <| (eventually_ge_atTop i₀).mono fun i hi ↦ ?_ · rw [← diff_iInter, setIntegral_diff _ hi₀ (iInter_subset _ _), sub_sub_cancel] exact .iInter_of_antitone h_anti hsm · rw [setIntegral_diff (hsm i) hi₀ (h_anti hi), sub_sub_cancel] @@ -885,7 +885,7 @@ theorem integrableOn_iUnion_of_summable_integral_norm {f : X → E} {s : ι → rw [← NNReal.summable_coe]; exact h have S'' := ENNReal.tsum_coe_eq S'.hasSum simp_rw [ENNReal.coe_nnreal_eq, NNReal.coe_mk, coe_nnnorm] at S'' - convert ENNReal.ofReal_lt_top + convert! ENNReal.ofReal_lt_top variable [TopologicalSpace X] [BorelSpace X] [T2Space X] [IsLocallyFiniteMeasure μ] @@ -1037,7 +1037,7 @@ theorem measure_le_lintegral_thickenedIndicatorAux (μ : Measure X) {E : Set X} theorem measure_le_lintegral_thickenedIndicator (μ : Measure X) {E : Set X} (E_mble : MeasurableSet E) {δ : ℝ} (δ_pos : 0 < δ) : μ E ≤ ∫⁻ x, (thickenedIndicator δ_pos E x : ℝ≥0∞) ∂μ := by - convert measure_le_lintegral_thickenedIndicatorAux μ E_mble δ + convert! measure_le_lintegral_thickenedIndicatorAux μ E_mble δ dsimp simp only [thickenedIndicatorAux_lt_top.ne, ENNReal.coe_toNNReal, Ne, not_false_iff] diff --git a/Mathlib/MeasureTheory/Integral/Bochner/SumMeasure.lean b/Mathlib/MeasureTheory/Integral/Bochner/SumMeasure.lean index bdd361605c7e20..0eac8863a5e104 100644 --- a/Mathlib/MeasureTheory/Integral/Bochner/SumMeasure.lean +++ b/Mathlib/MeasureTheory/Integral/Bochner/SumMeasure.lean @@ -57,15 +57,15 @@ lemma integrable_sum_measure Integrable f (Measure.sum μ) := by refine ⟨aestronglyMeasurable_sum_measure_iff.mpr fun i ↦ (hf i).aestronglyMeasurable, ?_⟩ · rw [HasFiniteIntegral, lintegral_sum_measure] - convert h.tsum_ofReal_lt_top with i + convert! h.tsum_ofReal_lt_top with i rw [ofReal_integral_eq_lintegral_ofReal (hf i).norm] - · simp_rw [ofReal_norm_eq_enorm] + · simp_rw [ofReal_norm] · exact ae_of_all _ fun _ ↦ by positivity omit [Countable ι] in lemma Integrable.summable_integral (hf : Integrable f (Measure.sum μ)) : Summable (fun i ↦ ∫ x, ‖f x‖ ∂μ i) := by - convert ENNReal.summable_toReal (f := fun i ↦ ∫⁻ x, ‖f x‖ₑ ∂μ i) ?_ with i + convert! ENNReal.summable_toReal (f := fun i ↦ ∫⁻ x, ‖f x‖ₑ ∂μ i) ?_ with i · rw [← integral_toReal ?_ (by simp)] · simp · exact (hf.aestronglyMeasurable.mono_measure (Measure.le_sum _ i)).enorm @@ -153,7 +153,7 @@ lemma integral_sum_dirac [FiniteDimensional ℝ E] (hc : ∀ i, c i ≠ ∞) : rw [integral_smul_measure, integral_dirac] · rw [integral_undef hf, tsum_eq_zero_of_not_summable] apply mt Summable.norm - convert mt (integrable_sum_dirac hc) hf + convert! mt (integrable_sum_dirac hc) hf simp [norm_smul] lemma hasSum_integral_sum_dirac [CompleteSpace E] (hc : ∀ i, c i ≠ ∞) diff --git a/Mathlib/MeasureTheory/Integral/Bochner/VitaliCaratheodory.lean b/Mathlib/MeasureTheory/Integral/Bochner/VitaliCaratheodory.lean index 3b0ff2458cebd0..135a554ad5a100 100644 --- a/Mathlib/MeasureTheory/Integral/Bochner/VitaliCaratheodory.lean +++ b/Mathlib/MeasureTheory/Integral/Bochner/VitaliCaratheodory.lean @@ -150,7 +150,7 @@ theorem SimpleFunc.exists_le_lowerSemicontinuous_lintegral_ge (f : α →ₛ ℝ simp only [SimpleFunc.coe_add, ENNReal.coe_add, Pi.add_apply] rw [lintegral_add_left f₁.measurable.coe_nnreal_ennreal, lintegral_add_left g₁cont.measurable.coe_nnreal_ennreal] - convert add_le_add g₁int g₂int using 1 + convert! add_le_add g₁int g₂int using 1 conv_lhs => rw [← ENNReal.add_halves ε] abel @@ -246,9 +246,9 @@ theorem exists_lt_lowerSemicontinuous_lintegral_ge_of_aemeasurable [SigmaFinite lintegral_add_left g0_cont.measurable _ _ ≤ (∫⁻ x, f x ∂μ) + ε / 2 + (0 + ε / 2) := by refine add_le_add ?_ ?_ - · convert g0_int using 2 + · convert! g0_int using 2 exact lintegral_congr_ae (fmeas.ae_eq_mk.fun_comp _) - · convert g1_int + · convert! g1_int simp only [smeas, μs, lintegral_const, Set.univ_inter, MeasurableSet.univ, lintegral_indicator, mul_zero, restrict_apply] _ = (∫⁻ x, f x ∂μ) + ε := by simp only [add_assoc, ENNReal.add_halves, zero_add] @@ -267,7 +267,7 @@ theorem exists_lt_lowerSemicontinuous_integral_gt_nnreal [SigmaFinite μ] (f : (∀ᵐ x ∂μ, g x < ⊤) ∧ Integrable (fun x => (g x).toReal) μ ∧ (∫ x, (g x).toReal ∂μ) < (∫ x, ↑(f x) ∂μ) + ε := by have fmeas : AEMeasurable f μ := by - convert fint.aestronglyMeasurable.real_toNNReal.aemeasurable + convert! fint.aestronglyMeasurable.real_toNNReal.aemeasurable simp only [Real.toNNReal_coe] lift ε to ℝ≥0 using εpos.le obtain ⟨δ, δpos, hδε⟩ : ∃ δ : ℝ≥0, 0 < δ ∧ δ < ε := exists_between εpos @@ -285,7 +285,7 @@ theorem exists_lt_lowerSemicontinuous_integral_gt_nnreal [SigmaFinite μ] (f : refine ⟨g, f_lt_g, gcont, g_lt_top, ?_, ?_⟩ · refine ⟨gcont.measurable.ennreal_toReal.aemeasurable.aestronglyMeasurable, ?_⟩ simp only [hasFiniteIntegral_iff_norm, Real.norm_eq_abs, abs_of_nonneg ENNReal.toReal_nonneg] - convert gint_ne.lt_top using 1 + convert! gint_ne.lt_top using 1 · rw [integral_eq_lintegral_of_nonneg_ae, integral_eq_lintegral_of_nonneg_ae] · calc ENNReal.toReal (∫⁻ a : α, ENNReal.ofReal (g a).toReal ∂μ) = @@ -351,7 +351,7 @@ theorem SimpleFunc.exists_upperSemicontinuous_le_lintegral_le (f : α →ₛ ℝ simp only [SimpleFunc.coe_add, ENNReal.coe_add, Pi.add_apply] rw [lintegral_add_left f₁.measurable.coe_nnreal_ennreal, lintegral_add_left g₁cont.measurable.coe_nnreal_ennreal] - convert add_le_add g₁int g₂int using 1 + convert! add_le_add g₁int g₂int using 1 conv_lhs => rw [← ENNReal.add_halves ε] abel @@ -371,7 +371,7 @@ theorem exists_upperSemicontinuous_le_lintegral_le (f : α → ℝ≥0) (int_f : simp only [lt_iSup_iff] at this rcases this with ⟨fs, fs_le_f, int_fs⟩ refine ⟨fs, fun x => by simpa only [ENNReal.coe_le_coe] using fs_le_f x, ?_⟩ - convert int_fs.le + convert! int_fs.le rw [← SimpleFunc.lintegral_eq_lintegral] simp only [SimpleFunc.coe_map, Function.comp_apply] have int_fs_lt_top : (∫⁻ x, fs x ∂μ) ≠ ∞ := by @@ -410,7 +410,7 @@ theorem exists_upperSemicontinuous_le_integral_le (f : α → ℝ≥0) exact Filter.Eventually.of_forall fun x => by simp [gf x] · rw [integral_eq_lintegral_of_nonneg_ae, integral_eq_lintegral_of_nonneg_ae] · rw [sub_le_iff_le_add] - convert ENNReal.toReal_mono _ gint + convert! ENNReal.toReal_mono _ gint · simp · rw [ENNReal.toReal_add Ig.ne ENNReal.coe_ne_top]; simp · simpa using Ig.ne @@ -450,7 +450,7 @@ theorem exists_lt_lowerSemicontinuous_integral_lt [SigmaFinite μ] (f : α → case int => show Integrable (fun x => EReal.toReal (g x)) μ rw [integrable_congr ae_g] - convert gp_integrable.sub gm_integrable + convert! gp_integrable.sub gm_integrable simp case intlt => show (∫ x : α, (g x).toReal ∂μ) < (∫ x : α, f x ∂μ) + ε @@ -463,7 +463,7 @@ theorem exists_lt_lowerSemicontinuous_integral_lt [SigmaFinite μ] (f : α → exact integral_sub gp_integrable gm_integrable _ < (∫ x : α, ↑(fp x) ∂μ) + ↑δ - ∫ x : α, ↑(gm x) ∂μ := by apply sub_lt_sub_right - convert gpint + convert! gpint simp only [EReal.toReal_coe_ennreal] _ ≤ (∫ x : α, ↑(fp x) ∂μ) + ↑δ - ((∫ x : α, ↑(fm x) ∂μ) - δ) := sub_le_sub_left gmint _ _ = (∫ x : α, f x ∂μ) + 2 * δ := by @@ -517,7 +517,7 @@ theorem exists_upperSemicontinuous_lt_integral_gt [SigmaFinite μ] (f : α → · exact continuous_neg.comp_lowerSemicontinuous_antitone gcont fun x y hxy => EReal.neg_le_neg_iff.2 hxy - · convert g_integrable.neg + · convert! g_integrable.neg simp · simpa [bot_lt_iff_ne_bot, lt_top_iff_ne_top] using g_lt_top · simp_rw [integral_neg, lt_neg_add_iff_add_lt] at gint diff --git a/Mathlib/MeasureTheory/Integral/BoundedContinuousFunction.lean b/Mathlib/MeasureTheory/Integral/BoundedContinuousFunction.lean index 64ea8fb026eedc..93eea6cfffa9d6 100644 --- a/Mathlib/MeasureTheory/Integral/BoundedContinuousFunction.lean +++ b/Mathlib/MeasureTheory/Integral/BoundedContinuousFunction.lean @@ -29,7 +29,7 @@ section NNRealValued lemma apply_le_nndist_zero {X : Type*} [TopologicalSpace X] (f : X →ᵇ ℝ≥0) (x : X) : f x ≤ nndist 0 f := by - convert nndist_coe_le_nndist x + convert! nndist_coe_le_nndist x simp only [coe_zero, Pi.zero_apply, NNReal.nndist_zero_eq_val] variable {X : Type*} [MeasurableSpace X] [TopologicalSpace X] @@ -111,7 +111,7 @@ lemma norm_integral_le_mul_norm [IsFiniteMeasure μ] (f : X →ᵇ E) : lemma norm_integral_le_norm [IsProbabilityMeasure μ] (f : X →ᵇ E) : ‖∫ x, f x ∂μ‖ ≤ ‖f‖ := by - convert f.norm_integral_le_mul_norm μ + convert! f.norm_integral_le_mul_norm μ simp lemma isBounded_range_integral diff --git a/Mathlib/MeasureTheory/Integral/CircleAverage.lean b/Mathlib/MeasureTheory/Integral/CircleAverage.lean index e9b95d5b59e2ee..73b84211699661 100644 --- a/Mathlib/MeasureTheory/Integral/CircleAverage.lean +++ b/Mathlib/MeasureTheory/Integral/CircleAverage.lean @@ -364,7 +364,7 @@ theorem circleAverage_sum {ι : Type*} {s : Finset ι} {f : ι → ℂ → E} theorem circleAverage_fun_sum {ι : Type*} {s : Finset ι} {f : ι → ℂ → E} (h : ∀ i ∈ s, CircleIntegrable (f i) c R) : circleAverage (fun z ↦ ∑ i ∈ s, f i z) c R = ∑ i ∈ s, circleAverage (f i) c R := by - convert circleAverage_sum h + convert! circleAverage_sum h simp /-- Circle averages commute with subtraction. -/ diff --git a/Mathlib/MeasureTheory/Integral/CircleIntegral.lean b/Mathlib/MeasureTheory/Integral/CircleIntegral.lean index 4fbb583658c89e..31aacc8c725e1c 100644 --- a/Mathlib/MeasureTheory/Integral/CircleIntegral.lean +++ b/Mathlib/MeasureTheory/Integral/CircleIntegral.lean @@ -214,7 +214,7 @@ protected theorem sum {ι : Type*} (s : Finset ι) {f : ι → ℂ → E} theorem fun_sum {c : ℂ} {R : ℝ} {ι : Type*} (s : Finset ι) {f : ι → ℂ → E} (h : ∀ i ∈ s, CircleIntegrable (f i) c R) : CircleIntegrable (fun z ↦ ∑ i ∈ s, f i z) c R := by - convert CircleIntegrable.sum s h + convert! CircleIntegrable.sum s h simp /-- `finsum`s of circle integrable functions are circle integrable. -/ @@ -571,8 +571,9 @@ theorem integral_sub_zpow_of_ne {n : ℤ} (hn : n ≠ -1) (c w : ℂ) (R : ℝ) have hd : ∀ z, z ≠ w ∨ -1 ≤ n → HasDerivAt (fun z => (z - w) ^ (n + 1) / (n + 1)) ((z - w) ^ n) z := by intro z hne - convert ((hasDerivAt_zpow (n + 1) _ (hne.imp _ _)).comp z - ((hasDerivAt_id z).sub_const w)).div_const _ using 1 + convert! + ((hasDerivAt_zpow (n + 1) _ (hne.imp _ _)).comp z ((hasDerivAt_id z).sub_const w)).div_const + _ using 1 · have hn' : (n + 1 : ℂ) ≠ 0 := by rwa [Ne, ← eq_neg_iff_add_eq_zero, ← Int.cast_one, ← Int.cast_neg, Int.cast_inj] simp [mul_div_cancel_left₀ _ hn'] @@ -660,7 +661,7 @@ theorem hasSum_two_pi_I_cauchyPowerSeries_integral {f : ℂ → E} {c : ℂ} {R simp only [smul_smul] refine HasSum.smul_const ?_ _ have : ‖w / (circleMap c R θ - c)‖ < 1 := by simpa [abs_of_pos hR] using hwR.2 - convert (hasSum_geometric_of_norm_lt_one this).mul_right _ using 1 + convert! (hasSum_geometric_of_norm_lt_one this).mul_right _ using 1 simp [← sub_sub, ← mul_inv, sub_mul, div_mul_cancel₀ _ (circleMap_ne_center hR.ne')] /-- For any circle integrable function `f`, the power series `cauchyPowerSeries f c R`, `R > 0`, diff --git a/Mathlib/MeasureTheory/Integral/CurveIntegral/Poincare.lean b/Mathlib/MeasureTheory/Integral/CurveIntegral/Poincare.lean index 405444b82178c8..62f2fc4d343778 100644 --- a/Mathlib/MeasureTheory/Integral/CurveIntegral/Poincare.lean +++ b/Mathlib/MeasureTheory/Integral/CurveIntegral/Poincare.lean @@ -309,7 +309,7 @@ theorem curveIntegral_segment_add_eq_of_hasFDerivWithinAt_symmetric (hs : Convex simp [φ, ha, hb, hc, hs.lineMap_mem] have := φ.curveIntegral_add_curveIntegral_eq_of_hasFDerivWithinAt (t := range φ) (ω := ω) (dω := dω) ?_ ?_ ?_ ?_ ?_ - · convert this using 2 + · convert! this using 2 · dsimp [φ] rw [← Path.cast_segment (lineMap_apply_one a b) (lineMap_apply_one a c), curveIntegral_cast] · dsimp [φ] diff --git a/Mathlib/MeasureTheory/Integral/DivergenceTheorem.lean b/Mathlib/MeasureTheory/Integral/DivergenceTheorem.lean index 89d8197593ca08..6ed8ecd44c52e5 100644 --- a/Mathlib/MeasureTheory/Integral/DivergenceTheorem.lean +++ b/Mathlib/MeasureTheory/Integral/DivergenceTheorem.lean @@ -455,8 +455,9 @@ theorem integral_divergence_prod_Icc_of_hasFDerivAt_off_countable_of_le (f g : ((∫ x in Icc a.1 b.1, g (x, b.2)) - ∫ x in Icc a.1 b.1, g (x, a.2)) := by have : ∀ (a b : ℝ¹) (f : ℝ¹ → E), ∫ x in Icc a b, f x = ∫ x in Icc (a 0) (b 0), f fun _ => x := fun a b f ↦ by - convert (((volume_preserving_funUnique (Fin 1) ℝ).symm _).setIntegral_preimage_emb - (MeasurableEquiv.measurableEmbedding _) f _).symm + convert! + (((volume_preserving_funUnique (Fin 1) ℝ).symm _).setIntegral_preimage_emb + (MeasurableEquiv.measurableEmbedding _) f _).symm exact ((OrderIso.funUnique (Fin 1) ℝ).symm.preimage_Icc a b).symm simp only [Fin.sum_univ_two, this] rfl diff --git a/Mathlib/MeasureTheory/Integral/DominatedConvergence.lean b/Mathlib/MeasureTheory/Integral/DominatedConvergence.lean index 2515789dde32af..2b9131108a61f4 100644 --- a/Mathlib/MeasureTheory/Integral/DominatedConvergence.lean +++ b/Mathlib/MeasureTheory/Integral/DominatedConvergence.lean @@ -60,11 +60,9 @@ theorem tendsto_integral_of_dominated_convergence {F : ℕ → α → G} {f : α (h_bound : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (f a))) : Tendsto (fun n => ∫ a, F n a ∂μ) atTop (𝓝 <| ∫ a, f a ∂μ) := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact tendsto_setToFun_of_dominated_convergence (dominatedFinMeasAdditive_weightedSMul μ) - bound F_measurable bound_integrable h_bound h_lim - · simp [integral, hG] + simp only [integral_eq_setToFun] + exact tendsto_setToFun_of_dominated_convergence (dominatedFinMeasAdditive_weightedSMul μ) + bound F_measurable bound_integrable h_bound h_lim /-- Lebesgue dominated convergence theorem for filters with a countable basis -/ theorem tendsto_integral_filter_of_dominated_convergence {ι} {l : Filter ι} [l.IsCountablyGenerated] @@ -72,11 +70,9 @@ theorem tendsto_integral_filter_of_dominated_convergence {ι} {l : Filter ι} [l (h_bound : ∀ᶠ n in l, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) l (𝓝 (f a))) : Tendsto (fun n => ∫ a, F n a ∂μ) l (𝓝 <| ∫ a, f a ∂μ) := by - by_cases hG : CompleteSpace G - · simp only [integral_eq_setToFun] - exact tendsto_setToFun_filter_of_dominated_convergence (dominatedFinMeasAdditive_weightedSMul μ) - bound hF_meas h_bound bound_integrable h_lim - · simp [integral, hG, tendsto_const_nhds] + simp only [integral_eq_setToFun] + exact tendsto_setToFun_filter_of_dominated_convergence (dominatedFinMeasAdditive_weightedSMul μ) + bound hF_meas h_bound bound_integrable h_lim /-- Lebesgue dominated convergence theorem for series. -/ theorem hasSum_integral_of_dominated_convergence {ι} [Countable ι] {F : ι → α → G} {f : α → G} @@ -118,15 +114,16 @@ theorem integral_tsum {ι} [Countable ι] {f : ι → α → G} (hf : ∀ i, AES intro x hx rw [← ENNReal.tsum_coe_ne_top_iff_summable_coe] exact hx.ne - convert (MeasureTheory.hasSum_integral_of_dominated_convergence (fun i a => ‖f i a‖₊) hf _ hhh - ⟨_, _⟩ _).tsum_eq.symm + convert! + (MeasureTheory.hasSum_integral_of_dominated_convergence (fun i a => ‖f i a‖₊) hf _ hhh ⟨_, _⟩ + _).tsum_eq.symm · intro n filter_upwards with x rfl · fun_prop · dsimp [HasFiniteIntegral] have : ∫⁻ a, ∑' n, ‖f n a‖ₑ ∂μ < ⊤ := by rwa [lintegral_tsum hf'', lt_top_iff_ne_top] - convert this using 1 + convert! this using 1 apply lintegral_congr_ae simp_rw [← coe_nnnorm, ← NNReal.coe_tsum, enorm_eq_nnnorm, NNReal.nnnorm_eq] filter_upwards [hhh] with a ha diff --git a/Mathlib/MeasureTheory/Integral/FinMeasAdditive.lean b/Mathlib/MeasureTheory/Integral/FinMeasAdditive.lean index e492295f3a9e7f..f59dfd6d9bf24e 100644 --- a/Mathlib/MeasureTheory/Integral/FinMeasAdditive.lean +++ b/Mathlib/MeasureTheory/Integral/FinMeasAdditive.lean @@ -58,15 +58,13 @@ def FinMeasAdditive {β} [AddMonoid β] {_ : MeasurableSpace α} (μ : Measure namespace FinMeasAdditive -variable {β : Type*} [AddCommMonoid β] {T T' : Set α → β} +variable {β : Type*} {T T' : Set α → β} -theorem zero : FinMeasAdditive μ (0 : Set α → β) := fun _ _ _ _ _ _ _ => by simp +section AddMonoid -theorem add (hT : FinMeasAdditive μ T) (hT' : FinMeasAdditive μ T') : - FinMeasAdditive μ (T + T') := by - intro s t hs ht hμs hμt hst - simp only [hT s t hs ht hμs hμt hst, hT' s t hs ht hμs hμt hst, Pi.add_apply] - abel +variable [AddMonoid β] + +theorem zero : FinMeasAdditive μ (0 : Set α → β) := fun _ _ _ _ _ _ _ => by simp theorem smul [DistribSMul 𝕜 β] (hT : FinMeasAdditive μ T) (c : 𝕜) : FinMeasAdditive μ fun s => c • T s := fun s t hs ht hμs hμt hst => by @@ -76,6 +74,16 @@ theorem of_eq_top_imp_eq_top {μ' : Measure α} (h : ∀ s, MeasurableSet s → (hT : FinMeasAdditive μ T) : FinMeasAdditive μ' T := fun s t hs ht hμ's hμ't hst => hT s t hs ht (mt (h s hs) hμ's) (mt (h t ht) hμ't) hst +theorem add_right_measure {ν : Measure α} (hT : FinMeasAdditive μ T) : + FinMeasAdditive (μ + ν) T := + hT.of_eq_top_imp_eq_top fun s _ hμs => + top_unique <| hμs.symm.trans_le (Measure.le_add_right le_rfl s) + +theorem add_left_measure {ν : Measure α} (hT : FinMeasAdditive μ T) : + FinMeasAdditive (ν + μ) T := + hT.of_eq_top_imp_eq_top fun s _ hμs => + top_unique <| hμs.symm.trans_le (Measure.le_add_left le_rfl s) + theorem of_smul_measure {c : ℝ≥0∞} (hc_ne_top : c ≠ ∞) (hT : FinMeasAdditive (c • μ) T) : FinMeasAdditive μ T := by refine of_eq_top_imp_eq_top (fun s _ hμs => ?_) hT @@ -102,6 +110,22 @@ theorem map_empty_eq_zero {β} [AddCancelMonoid β] {T : Set α → β} (hT : Fi nth_rw 1 [← add_zero (T ∅)] at hT exact (add_left_cancel hT).symm +end AddMonoid + +section AddCommMonoid + +variable [AddCommMonoid β] + +theorem add (hT : FinMeasAdditive μ T) (hT' : FinMeasAdditive μ T') : + FinMeasAdditive μ (T + T') := by + intro s t hs ht hμs hμt hst + simp only [hT s t hs ht hμs hμt hst, hT' s t hs ht hμs hμt hst, Pi.add_apply] + abel + +theorem add_measure {ν : Measure α} (hT : FinMeasAdditive μ T) (hT' : FinMeasAdditive ν T') : + FinMeasAdditive (μ + ν) (T + T') := + hT.add_right_measure.add (hT'.add_left_measure) + theorem map_iUnion_fin_meas_set_eq_sum (T : Set α → β) (T_empty : T ∅ = 0) (h_add : FinMeasAdditive μ T) {ι} (S : ι → Set α) (sι : Finset ι) (hS_meas : ∀ i, MeasurableSet (S i)) (hSp : ∀ i ∈ sι, μ (S i) ≠ ∞) @@ -121,7 +145,7 @@ theorem map_iUnion_fin_meas_set_eq_sum (T : Set α → β) (T_empty : T ∅ = 0) rw [← h_add (S a) (⋃ i ∈ s, S i) (hS_meas a) (measurableSet_biUnion _ fun i _ => hS_meas i) (hps a (Finset.mem_insert_self a s))] - · congr; convert Finset.iSup_insert a s S + · congr; convert! Finset.iSup_insert a s S · exact (measure_biUnion_lt_top s.finite_toSet fun i hi ↦ (hps i <| Finset.mem_insert_of_mem hi).lt_top).ne · simp_rw [Set.disjoint_iUnion_right] @@ -130,6 +154,19 @@ theorem map_iUnion_fin_meas_set_eq_sum (T : Set α → β) (T_empty : T ∅ = 0) rw [← hai] at hi exact has hi +end AddCommMonoid + +theorem neg [AddGroup β] (hT : FinMeasAdditive μ T) : + FinMeasAdditive μ (-T) := by + intro s t hs ht hμs hμt hst + have h_comm : T s + T t = T t + T s := by + rw [← hT s t hs ht hμs hμt hst, ← hT t s ht hs hμt hμs hst.symm, union_comm] + simp_all [hT s t hs ht hμs hμt hst, neg_add_rev] + +theorem sub [AddCommGroup β] (hT : FinMeasAdditive μ T) (hT' : FinMeasAdditive μ T') : + FinMeasAdditive μ (T - T') := + sub_eq_add_neg T T' ▸ hT.add hT'.neg + end FinMeasAdditive /-- A `FinMeasAdditive` set function whose norm on every set is less than the measure of the @@ -160,12 +197,20 @@ theorem eq_zero {β : Type*} [NormedAddCommGroup β] {T : Set α → β} {C : T s = 0 := eq_zero_of_measure_zero hT hs (by simp only [Measure.coe_zero, Pi.zero_apply]) +theorem of_le (hT : DominatedFinMeasAdditive μ T C) (hC : C ≤ C') : + DominatedFinMeasAdditive μ T C' := + ⟨hT.1, fun s hs hμs => (hT.2 s hs hμs).trans <| mul_le_mul_of_nonneg_right hC measureReal_nonneg⟩ + theorem add (hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C') : DominatedFinMeasAdditive μ (T + T') (C + C') := by refine ⟨hT.1.add hT'.1, fun s hs hμs => ?_⟩ rw [Pi.add_apply, add_mul] exact (norm_add_le _ _).trans (add_le_add (hT.2 s hs hμs) (hT'.2 s hs hμs)) +theorem neg (hT : DominatedFinMeasAdditive μ T C) : + DominatedFinMeasAdditive μ (-T) C := + ⟨hT.1.neg, fun s hs hμs => by simpa using hT.2 s hs hμs⟩ + theorem smul [SeminormedAddGroup 𝕜] [DistribSMul 𝕜 β] [IsBoundedSMul 𝕜 β] (hT : DominatedFinMeasAdditive μ T C) (c : 𝕜) : DominatedFinMeasAdditive μ (fun s => c • T s) (‖c‖ * C) := by @@ -185,6 +230,26 @@ theorem of_measure_le {μ' : Measure α} (h : μ ≤ μ') (hT : DominatedFinMeas gcongr exact hμ's.ne +theorem add_measure {C' : ℝ} (μ ν : Measure α) + (hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive ν T' C') : + DominatedFinMeasAdditive (μ + ν) (T + T') (max C C') := by + refine ⟨hT.1.add_measure hT'.1, fun s hs hsf ↦ ?_⟩ + have hμs : μ s < ∞ := (Measure.le_add_right le_rfl s).trans_lt hsf + have hνs : ν s < ∞ := (Measure.le_add_left le_rfl s).trans_lt hsf + rw [Pi.add_apply, measureReal_add_apply hμs.ne hνs.ne, mul_add] + calc + ‖T s + T' s‖ ≤ ‖T s‖ + ‖T' s‖ := norm_add_le _ _ + _ ≤ C * μ.real s + C' * ν.real s := add_le_add (hT.2 s hs hμs) (hT'.2 s hs hνs) + _ ≤ max C C' * μ.real s + max C C' * ν.real s := by + gcongr + · exact le_max_left C C' + · exact le_max_right C C' + +theorem sub_measure {C' : ℝ} (μ ν : Measure α) + (hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive ν T' C') : + DominatedFinMeasAdditive (μ + ν) (T - T') (max C C') := + sub_eq_add_neg T T' ▸ hT.add_measure μ ν hT'.neg + theorem add_measure_right {_ : MeasurableSpace α} (μ ν : Measure α) (hT : DominatedFinMeasAdditive μ T C) (hC : 0 ≤ C) : DominatedFinMeasAdditive (μ + ν) T C := of_measure_le (Measure.le_add_right le_rfl) hT hC @@ -193,6 +258,14 @@ theorem add_measure_left {_ : MeasurableSpace α} (μ ν : Measure α) (hT : DominatedFinMeasAdditive ν T C) (hC : 0 ≤ C) : DominatedFinMeasAdditive (μ + ν) T C := of_measure_le (Measure.le_add_left le_rfl) hT hC +theorem finsetSum_measure {ι} {s : Finset ι} (hs : s.Nonempty) (μ : ι → Measure α) + (T : ι → Set α → β) (C : ι → ℝ) (hT : ∀ i, DominatedFinMeasAdditive (μ i) (T i) (C i)) : + DominatedFinMeasAdditive (∑ i ∈ s, μ i) (∑ i ∈ s, T i) (s.sup' hs C) := by + induction hs using Finset.Nonempty.cons_induction with + | singleton i => simp_all + | @cons i s his hs' ih => + simpa [his, Finset.sup'_cons hs' C] using (hT i).add_measure (μ i) (∑ j ∈ s, μ j) ih + theorem of_smul_measure {c : ℝ≥0∞} (hc_ne_top : c ≠ ∞) (hT : DominatedFinMeasAdditive (c • μ) T C) : DominatedFinMeasAdditive μ T (c.toReal * C) := by have h : ∀ s, MeasurableSet s → c • μ s = ∞ → μ s = ∞ := by @@ -462,7 +535,7 @@ theorem setToSimpleFunc_nonneg' (T : Set α → G' →L[ℝ] G'') rw [mem_range] at hi obtain ⟨y, hy⟩ := Set.mem_range.mp hi rw [← hy] - convert hf y + convert! hf y theorem setToSimpleFunc_mono [IsOrderedAddMonoid G'] {T : Set α → G' →L[ℝ] G''} (h_add : FinMeasAdditive μ T) diff --git a/Mathlib/MeasureTheory/Integral/Gamma.lean b/Mathlib/MeasureTheory/Integral/Gamma.lean index 811127816954fa..4126186d275ec7 100644 --- a/Mathlib/MeasureTheory/Integral/Gamma.lean +++ b/Mathlib/MeasureTheory/Integral/Gamma.lean @@ -62,13 +62,13 @@ theorem integral_rpow_mul_exp_neg_mul_rpow {p q b : ℝ} (hp : 0 < p) (hq : -1 < theorem integral_exp_neg_rpow {p : ℝ} (hp : 0 < p) : ∫ x in Ioi (0 : ℝ), exp (-x ^ p) = Gamma (1 / p + 1) := by - convert (integral_rpow_mul_exp_neg_rpow hp neg_one_lt_zero) using 1 + convert! (integral_rpow_mul_exp_neg_rpow hp neg_one_lt_zero) using 1 · simp_rw [rpow_zero, one_mul] · rw [zero_add, Gamma_add_one (one_div_ne_zero (ne_of_gt hp))] theorem integral_exp_neg_mul_rpow {p b : ℝ} (hp : 0 < p) (hb : 0 < b) : ∫ x in Ioi (0 : ℝ), exp (-b * x ^ p) = b ^ (-1 / p) * Gamma (1 / p + 1) := by - convert (integral_rpow_mul_exp_neg_mul_rpow hp neg_one_lt_zero hb) using 1 + convert! (integral_rpow_mul_exp_neg_mul_rpow hp neg_one_lt_zero hb) using 1 · simp_rw [rpow_zero, one_mul] · rw [zero_add, Gamma_add_one (one_div_ne_zero (ne_of_gt hp)), mul_assoc] @@ -130,14 +130,14 @@ theorem Complex.integral_rpow_mul_exp_neg_mul_rpow {p q b : ℝ} (hp : 1 ≤ p) theorem Complex.integral_exp_neg_rpow {p : ℝ} (hp : 1 ≤ p) : ∫ x : ℂ, rexp (-‖x‖ ^ p) = π * Real.Gamma (2 / p + 1) := by - convert (integral_rpow_mul_exp_neg_rpow hp (by linarith : (-2 : ℝ) < 0)) using 1 + convert! (integral_rpow_mul_exp_neg_rpow hp (by linarith : (-2 : ℝ) < 0)) using 1 · simp_rw [rpow_zero, one_mul] · rw [zero_add, Real.Gamma_add_one (div_ne_zero two_ne_zero (by linarith))] ring theorem Complex.integral_exp_neg_mul_rpow {p b : ℝ} (hp : 1 ≤ p) (hb : 0 < b) : ∫ x : ℂ, rexp (-b * ‖x‖ ^ p) = π * b ^ (-2 / p) * Real.Gamma (2 / p + 1) := by - convert (integral_rpow_mul_exp_neg_mul_rpow hp (by linarith : (-2 : ℝ) < 0)) hb using 1 + convert! (integral_rpow_mul_exp_neg_mul_rpow hp (by linarith : (-2 : ℝ) < 0)) hb using 1 · simp_rw [rpow_zero, one_mul] · rw [zero_add, Real.Gamma_add_one (div_ne_zero two_ne_zero (by linarith))] ring diff --git a/Mathlib/MeasureTheory/Integral/IntegrableOn.lean b/Mathlib/MeasureTheory/Integral/IntegrableOn.lean index 65f7220c975804..36d51fedf392d0 100644 --- a/Mathlib/MeasureTheory/Integral/IntegrableOn.lean +++ b/Mathlib/MeasureTheory/Integral/IntegrableOn.lean @@ -560,7 +560,7 @@ protected theorem IntegrableAtFilter.neg {f : α → E} (hf : IntegrableAtFilter protected theorem integrableAtFilter_neg_iff {f : α → E} : IntegrableAtFilter (-f) l μ ↔ IntegrableAtFilter f l μ := by refine ⟨fun h ↦ ?_, fun h ↦ h.neg⟩ - convert h.neg; simp + convert! h.neg; simp protected theorem IntegrableAtFilter.sub {f g : α → E} (hf : IntegrableAtFilter f l μ) (hg : IntegrableAtFilter g l μ) : @@ -579,7 +579,7 @@ private theorem integrableAtFilter_smul_iff' {𝕜 : Type*} [NormedField 𝕜] [ {f : α → E} {c : 𝕜} (hc : c ≠ 0) : IntegrableAtFilter (c • f) l μ ↔ IntegrableAtFilter f l μ := by refine ⟨fun hf ↦ ?_, fun h ↦ h.smul c⟩ - convert hf.smul c⁻¹ + convert! hf.smul c⁻¹ simp [← smul_assoc, inv_mul_cancel₀ hc] theorem integrableAtFilter_smul_iff {𝕜 : Type*} [NormedField 𝕜] [NormedSpace 𝕜 E] diff --git a/Mathlib/MeasureTheory/Integral/IntegralEqImproper.lean b/Mathlib/MeasureTheory/Integral/IntegralEqImproper.lean index 1077560b9d9c1a..b62c43f212d74d 100644 --- a/Mathlib/MeasureTheory/Integral/IntegralEqImproper.lean +++ b/Mathlib/MeasureTheory/Integral/IntegralEqImproper.lean @@ -484,7 +484,7 @@ theorem AECover.integral_tendsto_of_countably_generated [l.IsCountablyGenerated] (hφ : AECover μ l φ) {f : α → E} (hfi : Integrable f μ) : Tendsto (fun i => ∫ x in φ i, f x ∂μ) l (𝓝 <| ∫ x, f x ∂μ) := suffices h : Tendsto (fun i => ∫ x : α, (φ i).indicator f x ∂μ) l (𝓝 (∫ x : α, f x ∂μ)) from by - convert h using 2; rw [integral_indicator (hφ.measurableSet _)] + convert! h using 2; rw [integral_indicator (hφ.measurableSet _)] tendsto_integral_filter_of_dominated_convergence (fun x => ‖f x‖) (Eventually.of_forall fun i => hfi.aestronglyMeasurable.indicator <| hφ.measurableSet i) (Eventually.of_forall fun _ => ae_of_all _ fun _ => norm_indicator_le_norm_self _ _) hfi.norm @@ -1036,7 +1036,7 @@ lemma _root_.HasCompactSupport.enorm_le_lintegral_Ici_deriv have : ‖f' x‖ₑ ≤ ∫⁻ y in Iic x, ‖deriv f' y‖ₑ := by rw [← HasCompactSupport.integral_Iic_deriv_eq hf' h'f' x] exact enorm_integral_le_lintegral_enorm _ - convert this with y + convert! this with y · simp [f', I, Completion.enorm_coe] · rw [fderiv_comp_deriv _ I.differentiableAt (hf.differentiable one_ne_zero _)] simp only [ContinuousLinearMap.fderiv] @@ -1156,7 +1156,7 @@ theorem integral_comp_rpow_Ioi (g : ℝ → E) {p : ℝ} (hp : p ≠ 0) : theorem integral_comp_rpow_Ioi_of_pos {g : ℝ → E} {p : ℝ} (hp : 0 < p) : (∫ x in Ioi 0, (p * x ^ (p - 1)) • g (x ^ p)) = ∫ y in Ioi 0, g y := by - convert integral_comp_rpow_Ioi g hp.ne' + convert! integral_comp_rpow_Ioi g hp.ne' rw [abs_of_nonneg hp.le] theorem integral_comp_mul_left_Ioi (g : ℝ → E) (a : ℝ) {b : ℝ} (hb : 0 < b) : @@ -1219,7 +1219,7 @@ theorem integrableOn_Ioi_comp_mul_left_iff (f : ℝ → E) (c : ℝ) {a : ℝ} ( IntegrableOn (fun x => f (a * x)) (Ioi c) ↔ IntegrableOn f (Ioi <| a * c) := by rw [← integrable_indicator_iff (measurableSet_Ioi : MeasurableSet <| Ioi c)] rw [← integrable_indicator_iff (measurableSet_Ioi : MeasurableSet <| Ioi <| a * c)] - convert integrable_comp_mul_left_iff ((Ioi (a * c)).indicator f) ha.ne' using 2 + convert! integrable_comp_mul_left_iff ((Ioi (a * c)).indicator f) ha.ne' using 2 ext1 x rw [← indicator_comp_right, preimage_const_mul_Ioi₀ _ ha, mul_comm a c, mul_div_cancel_right₀ _ ha.ne', Function.comp_def] diff --git a/Mathlib/MeasureTheory/Integral/IntervalIntegral/AbsolutelyContinuousFun.lean b/Mathlib/MeasureTheory/Integral/IntervalIntegral/AbsolutelyContinuousFun.lean index b07e47e869a726..c3ba8e3b8bd16a 100644 --- a/Mathlib/MeasureTheory/Integral/IntervalIntegral/AbsolutelyContinuousFun.lean +++ b/Mathlib/MeasureTheory/Integral/IntervalIntegral/AbsolutelyContinuousFun.lean @@ -87,9 +87,9 @@ lemma exists_dist_slope_lt_pairwiseDisjoint_hasSum {f f' : ℝ → F} {d b η : filter_upwards [hf, hu₄] with x hx₁ hx₂ grind have vol_sum : volume (⋃ z : u, Icc z.val.1 z.val.2) = ENNReal.ofReal (b - d) := by - convert Real.volume_Ioo ▸ - measure_eq_measure_of_null_diff (by simp only [iUnion_subset_iff]; grind) hu₄ - using 2 + convert! + Real.volume_Ioo ▸ + measure_eq_measure_of_null_diff (by simp only [iUnion_subset_iff]; grind) hu₄ using 2 simp rw [measure_iUnion this (by simp)] at vol_sum simp_rw [Real.volume_Icc] at vol_sum @@ -142,11 +142,11 @@ lemma AbsolutelyContinuousOnInterval.dist_le_of_pairwiseDisjoint_hasSum {f : ℝ replace hu₃ : Tendsto T atTop (totalLengthFilter ⊓ 𝓟 (disjWithin d b)) := by refine tendsto_inf.mpr ⟨?_, hT.tendsto.mono_left (by simp)⟩ simp only [totalLengthFilter, tendsto_comap_iff] - convert hu₃.const_sub (b - d) with s + convert! hu₃.const_sub (b - d) with s · simp only [comp_apply] rw [Finset.sum_congr rfl (g := fun i ↦ ((T s).2 i).2 - ((T s).2 i).1) (fun i hi ↦ by rw [dist_comm, Real.dist_eq, abs_of_nonneg (by grind)])] - convert (u_coe s).sum_intervalGapsWithin_eq_sub_sub_sum rfl id + convert! (u_coe s).sum_intervalGapsWithin_eq_sub_sub_sum rfl id exact u_coe_sum s fun x y ↦ y - x · abel rw [HasSum] at hu₄ @@ -234,7 +234,7 @@ theorem AbsolutelyContinuousOnInterval.integral_deriv_eq_sub {f : ℝ → ℝ} { have g_ae_deriv_zero : ∀ᵐ x, x ∈ uIcc a b → HasDerivAt g 0 x := by filter_upwards [hf.ae_differentiableAt, hf.intervalIntegrable_deriv.ae_hasDerivAt_integral] with x hx₁ hx₂ hx₃ - convert (hx₁ hx₃).hasDerivAt.sub (hx₂ hx₃ a (by simp)) + convert! (hx₁ hx₃).hasDerivAt.sub (hx₂ hx₃ a (by simp)) abel obtain ⟨C, hC⟩ := g_ac.const_of_ae_hasDerivAt_zero g_ae_deriv_zero have : f a = g a := by simp [g] diff --git a/Mathlib/MeasureTheory/Integral/IntervalIntegral/Basic.lean b/Mathlib/MeasureTheory/Integral/IntervalIntegral/Basic.lean index 0ad3a9f100f3c7..389f6c57e35e44 100644 --- a/Mathlib/MeasureTheory/Integral/IntervalIntegral/Basic.lean +++ b/Mathlib/MeasureTheory/Integral/IntervalIntegral/Basic.lean @@ -395,7 +395,7 @@ theorem comp_mul_left (hf : IntervalIntegrable f volume a b) {c : ℝ} rw [← Real.smul_map_volume_mul_right (inv_ne_zero hc), IntegrableOn, Measure.restrict_smul, integrable_smul_measure (by simpa : ENNReal.ofReal |c⁻¹| ≠ 0) ENNReal.ofReal_ne_top, ← IntegrableOn, MeasurableEmbedding.integrableOn_map_iff A] - convert hf using 1 + convert! hf using 1 · ext; simp only [comp_apply]; congr 1; field · rw [preimage_mul_const_uIcc (inv_ne_zero hc)]; field_simp @@ -429,7 +429,7 @@ theorem comp_add_right (hf : IntervalIntegrable f volume a b) (c : ℝ) have A : MeasurableEmbedding fun x => x + c := (Homeomorph.addRight c).isClosedEmbedding.measurableEmbedding rw [← map_add_right_eq_self volume c] at hf - convert (MeasurableEmbedding.integrableOn_map_iff A).mp hf using 1 + convert! (MeasurableEmbedding.integrableOn_map_iff A).mp hf using 1 rw [preimage_add_const_uIcc] theorem comp_add_right_iff {c : ℝ} (h : ‖f (min a b + c)‖ₑ ≠ ⊤ := by finiteness) : @@ -752,7 +752,7 @@ theorem norm_integral_le_of_norm_le {g : ℝ → ℝ} (hab : a ≤ b) theorem norm_integral_le_of_norm_le_const_ae {a b C : ℝ} {f : ℝ → E} (h : ∀ᵐ x, x ∈ Ι a b → ‖f x‖ ≤ C) : ‖∫ x in a..b, f x‖ ≤ C * |b - a| := by rw [norm_integral_eq_norm_integral_uIoc] - convert norm_setIntegral_le_of_norm_le_const_ae' _ h using 1 + convert! norm_setIntegral_le_of_norm_le_const_ae' _ h using 1 · rw [uIoc, Real.volume_real_Ioc_of_le inf_le_sup, max_sub_min_eq_abs] · simp [uIoc, Real.volume_Ioc] @@ -1185,13 +1185,13 @@ theorem integral_Ici_sub_Ici' [NoAtoms μ] (hf : IntegrableOn f (Ici a) μ) theorem integral_Iic_add_Ioi (h_left : IntegrableOn f (Iic b) μ) (h_right : IntegrableOn f (Ioi b) μ) : (∫ x in Iic b, f x ∂μ) + (∫ x in Ioi b, f x ∂μ) = ∫ (x : ℝ), f x ∂μ := by - convert (setIntegral_union (Iic_disjoint_Ioi <| Eq.le rfl) measurableSet_Ioi h_left h_right).symm + convert! (setIntegral_union (Iic_disjoint_Ioi <| Eq.le rfl) measurableSet_Ioi h_left h_right).symm rw [Iic_union_Ioi, Measure.restrict_univ] theorem integral_Iio_add_Ici (h_left : IntegrableOn f (Iio b) μ) (h_right : IntegrableOn f (Ici b) μ) : (∫ x in Iio b, f x ∂μ) + (∫ x in Ici b, f x ∂μ) = ∫ (x : ℝ), f x ∂μ := by - convert (setIntegral_union (Iio_disjoint_Ici <| Eq.le rfl) measurableSet_Ici h_left h_right).symm + convert! (setIntegral_union (Iio_disjoint_Ici <| Eq.le rfl) measurableSet_Ici h_left h_right).symm rw [Iio_union_Ici, Measure.restrict_univ] /-- If `μ` is a finite measure then `∫ x in a..b, c ∂μ = (μ (Iic b) - μ (Iic a)) • c`. -/ diff --git a/Mathlib/MeasureTheory/Integral/IntervalIntegral/DerivIntegrable.lean b/Mathlib/MeasureTheory/Integral/IntervalIntegral/DerivIntegrable.lean index feec94bf533f67..cece367a6eb62f 100644 --- a/Mathlib/MeasureTheory/Integral/IntervalIntegral/DerivIntegrable.lean +++ b/Mathlib/MeasureTheory/Integral/IntervalIntegral/DerivIntegrable.lean @@ -65,7 +65,7 @@ lemma MonotoneOn.exists_tendsto_deriv_liminf_lintegral_enorm_le rw [hfg (by grind [Icc_diff_both])] exact hx₁.hasDerivAt.tendsto_slope.comp <| tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ - (by convert tendsto_const_nhds.add (tendsto_inv_atTop_nhds_zero_nat (𝕜 := ℝ)); simp) + (by convert! tendsto_const_nhds.add (tendsto_inv_atTop_nhds_zero_nat (𝕜 := ℝ)); simp) (by simp [eventually_ne_atTop 0]) · calc _ = liminf (fun (n : ℕ) ↦ ENNReal.ofReal (∫ (x : ℝ) in Icc a b, (G (n : ℝ)⁻¹) x)) atTop := by @@ -78,8 +78,8 @@ lemma MonotoneOn.exists_tendsto_deriv_liminf_lintegral_enorm_le refine Filter.liminf_le_of_frequently_le' (Filter.Frequently.of_forall fun n ↦ ENNReal.ofReal_le_ofReal ?_) rw [integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le hab] - convert hg.monotoneOn (Icc a (b + (n : ℝ)⁻¹)) |>.intervalIntegral_slope_le hab (by simp) - using 2 + convert! + hg.monotoneOn (Icc a (b + (n : ℝ)⁻¹)) |>.intervalIntegral_slope_le hab (by simp) using 2 simp [g] _ = ENNReal.ofReal (f b - f a) := by grind @@ -136,7 +136,7 @@ theorem MonotoneOn.intervalIntegral_deriv_mem_uIcc {f : ℝ → ℝ} {a b : ℝ} ENNReal.ofReal_le_ofReal_iff (by linarith), integral_Icc_eq_integral_Ioc, ← intervalIntegral.integral_of_le hab] at ebound - convert ebound using 1 + convert! ebound using 1 refine intervalIntegral.integral_congr_ae ?_ rw [uIoc_of_le hab] filter_upwards [h₂] with x _ _ diff --git a/Mathlib/MeasureTheory/Integral/IntervalIntegral/DistLEIntegral.lean b/Mathlib/MeasureTheory/Integral/IntervalIntegral/DistLEIntegral.lean index 69c3d8daa36936..734ba83cf45c3e 100644 --- a/Mathlib/MeasureTheory/Integral/IntervalIntegral/DistLEIntegral.lean +++ b/Mathlib/MeasureTheory/Integral/IntervalIntegral/DistLEIntegral.lean @@ -136,7 +136,7 @@ lemma norm_sub_le_mul_volume_of_norm_lineDeriv_le have := (hfd t ht).hasLineDerivAt.scomp_of_eq (𝕜 := ℝ) t ((hasDerivAt_id t).sub_const t) simpa [g, lineMap_apply_module', Function.comp_def, sub_smul, add_comm _ a] using this suffices ‖g 1 - g 0‖ ≤ C * volume.real {t ∈ Ioo 0 1 | deriv g t ≠ 0} by - convert this using 1 + convert! this using 1 · simp [g] · congr 2 with t simp +contextual [(hdg _ _).deriv] diff --git a/Mathlib/MeasureTheory/Integral/IntervalIntegral/FundThmCalculus.lean b/Mathlib/MeasureTheory/Integral/IntervalIntegral/FundThmCalculus.lean index 8ff8a8dff342d0..66de604c14ee97 100644 --- a/Mathlib/MeasureTheory/Integral/IntervalIntegral/FundThmCalculus.lean +++ b/Mathlib/MeasureTheory/Integral/IntervalIntegral/FundThmCalculus.lean @@ -1057,7 +1057,7 @@ theorem sub_le_integral_of_hasDeriv_right_of_le_Ico (hab : a ≤ b) calc g b - g a ≤ ∫ y in a..b, (G' y).toReal := main (right_mem_Icc.2 hab) _ ≤ (∫ y in a..b, φ y) + ε := by - convert hG'.le <;> + convert! hG'.le <;> · rw [intervalIntegral.integral_of_le hab] simp only [integral_Icc_eq_integral_Ioc', Real.volume_singleton] @@ -1097,8 +1097,9 @@ theorem integral_le_sub_of_hasDeriv_right_of_le (hab : a ≤ b) (hcont : Continu (hderiv : ∀ x ∈ Ioo a b, HasDerivWithinAt g (g' x) (Ioi x) x) (φint : IntegrableOn φ (Icc a b)) (hφg : ∀ x ∈ Ioo a b, φ x ≤ g' x) : (∫ y in a..b, φ y) ≤ g b - g a := by rw [← neg_le_neg_iff] - convert sub_le_integral_of_hasDeriv_right_of_le hab hcont.neg (fun x hx => (hderiv x hx).neg) - φint.neg fun x hx => neg_le_neg (hφg x hx) using 1 + convert! + sub_le_integral_of_hasDeriv_right_of_le hab hcont.neg (fun x hx => (hderiv x hx).neg) φint.neg + fun x hx => neg_le_neg (hφg x hx) using 1 · abel · simp only [← integral_neg]; rfl @@ -1210,7 +1211,7 @@ lemma integral_unitInterval_deriv_eq_sub [RCLike 𝕜] [NormedSpace 𝕜 E] [IsS have hderiv' (t) (ht : t ∈ Set.uIcc (0 : ℝ) 1) : HasDerivAt (f ∘ γ) (z₁ • (f' ∘ γ) t) t := by refine (hderiv t <| (Set.uIcc_of_le (α := ℝ) zero_le_one).symm ▸ ht).scomp t <| .const_add _ ?_ simp [hasDerivAt_iff_isLittleO, sub_smul] - convert (integral_eq_sub_of_hasDerivAt hderiv' hint) using 1 + convert! (integral_eq_sub_of_hasDerivAt hderiv' hint) using 1 · simp_rw [← integral_smul, Function.comp_apply, γ] · simp only [γ, Function.comp_apply, one_smul, zero_smul, add_zero] @@ -1248,7 +1249,7 @@ theorem integrableOn_deriv_right_of_nonneg (hcont : ContinuousOn g (Icc a b)) rw [← integral_Ioc_eq_integral_Ioo, ← intervalIntegral.integral_of_le hab.le] refine integral_le_sub_of_hasDeriv_right_of_le hab.le hcont hderiv ?_ fun x hx => ?_ · rwa [integrableOn_Icc_iff_integrableOn_Ioo] - · convert NNReal.coe_le_coe.2 (fle x) + · convert! NNReal.coe_le_coe.2 (fle x) simp only [Real.norm_of_nonneg (g'pos x hx), coe_nnnorm] exact lt_irrefl _ (hf.trans_le (ENNReal.ofReal_le_ofReal B)) diff --git a/Mathlib/MeasureTheory/Integral/IntervalIntegral/Periodic.lean b/Mathlib/MeasureTheory/Integral/IntervalIntegral/Periodic.lean index 31a388bca768f7..0d1bfe992dd6fa 100644 --- a/Mathlib/MeasureTheory/Integral/IntervalIntegral/Periodic.lean +++ b/Mathlib/MeasureTheory/Integral/IntervalIntegral/Periodic.lean @@ -172,7 +172,7 @@ protected theorem lintegral_preimage (t : ℝ) (f : AddCircle T → ℝ≥0∞) simp only [measurableEquivIoc, equivIoc, QuotientAddGroup.equivIocMod, MeasurableEquiv.symm_mk, MeasurableEquiv.coe_mk, Equiv.coe_fn_symm_mk] at this rw [← (AddCircle.measurePreserving_mk T t).map_eq] - convert this.symm using 1 + convert! this.symm using 1 · rw [← map_comap_subtype_coe m _] exact MeasurableEmbedding.lintegral_map (MeasurableEmbedding.subtype_coe m) _ · congr 1 @@ -307,7 +307,7 @@ theorem intervalIntegrable {t : ℝ} (h₁f : Function.Periodic f T) apply IntervalIntegrable.trans_iterate -- Show integrability over a shifted period intro k hk - convert (IntervalIntegrable.comp_sub_right h₂f ((k - n₁) * T) (by aesop)) using 1 + convert! (IntervalIntegrable.comp_sub_right h₂f ((k - n₁) * T) (by aesop)) using 1 · funext x simpa using (h₁f.sub_int_mul_eq (k - n₁)).symm · simp [a, Nat.cast_add] diff --git a/Mathlib/MeasureTheory/Integral/IntervalIntegral/TrapezoidalRule.lean b/Mathlib/MeasureTheory/Integral/IntervalIntegral/TrapezoidalRule.lean index 7b9f1657ed9c6c..243d55e8c4436f 100644 --- a/Mathlib/MeasureTheory/Integral/IntervalIntegral/TrapezoidalRule.lean +++ b/Mathlib/MeasureTheory/Integral/IntervalIntegral/TrapezoidalRule.lean @@ -158,8 +158,9 @@ private lemma trapezoidal_error_le_of_lt' {f : ℝ → ℝ} {ζ : ℝ} {a b : ∀ t ∈ Icc a b, |φ t| ≤ c / (n + 1) * (t - a) ^ (n + 1) := by intro t ht have hB (x) : HasDerivAt (fun y ↦ c / (n + 1) * (y - a) ^ (n + 1)) (c * (x - a) ^ n) x := by - convert (hasDerivAt_const x (c / (n + 1))).mul - (((hasDerivAt_id x).sub (hasDerivAt_const x a)).pow (n + 1)) using 1 + convert! + (hasDerivAt_const x (c / (n + 1))).mul + (((hasDerivAt_id x).sub (hasDerivAt_const x a)).pow (n + 1)) using 1 simp [sub_eq_add_neg, field] simpa [Real.norm_eq_abs, h0] using image_norm_le_of_norm_deriv_right_le_deriv_boundary (fun x hx ↦ (h x hx).continuousWithinAt) diff --git a/Mathlib/MeasureTheory/Integral/Layercake.lean b/Mathlib/MeasureTheory/Integral/Layercake.lean index ba4b7c4ec100fb..1de6ce83f26a5c 100644 --- a/Mathlib/MeasureTheory/Integral/Layercake.lean +++ b/Mathlib/MeasureTheory/Integral/Layercake.lean @@ -310,7 +310,7 @@ theorem lintegral_comp_eq_lintegral_meas_le_mul_of_measurable (μ : Measure α) intro n have I : ν {a | f a ≤ M} = 0 := by rw [Measure.restrict_apply (measurableSet_le f_mble measurable_const)] - convert measure_empty (μ := μ) + convert! measure_empty (μ := μ) rw [← disjoint_iff_inter_eq_empty] exact disjoint_left.mpr (fun a ha ↦ by simpa using ha) have J : μ {a | u n < f a} < ∞ := by @@ -523,7 +523,7 @@ theorem Integrable.integral_eq_integral_meas_lt have rhs_finite : ∫⁻ (t : ℝ) in Set.Ioi 0, μ {a | t < f a} < ∞ := by simp only [← key, lhs_finite] have rhs_integrand_finite : ∀ (t : ℝ), t > 0 → μ {a | t < f a} < ∞ := fun t ht ↦ measure_gt_lt_top f_intble ht - convert (ENNReal.toReal_eq_toReal_iff' lhs_finite.ne rhs_finite.ne).mpr key + convert! (ENNReal.toReal_eq_toReal_iff' lhs_finite.ne rhs_finite.ne).mpr key · exact integral_eq_lintegral_of_nonneg_ae f_nn f_intble.aestronglyMeasurable · have aux := @integral_eq_lintegral_of_nonneg_ae _ _ ((volume : Measure ℝ).restrict (Set.Ioi 0)) (fun t ↦ μ.real {a : α | t < f a}) ?_ ?_ diff --git a/Mathlib/MeasureTheory/Integral/Lebesgue/Add.lean b/Mathlib/MeasureTheory/Integral/Lebesgue/Add.lean index e59a967062f5d4..743d2be2664ca1 100644 --- a/Mathlib/MeasureTheory/Integral/Lebesgue/Add.lean +++ b/Mathlib/MeasureTheory/Integral/Lebesgue/Add.lean @@ -189,7 +189,7 @@ theorem lintegral_iSup_directed [Countable β] {f : β → α → ℝ≥0∞} (h apply_rules [hz₁, hz₂] · simp only [aeSeq, hx, if_false] exact le_rfl - convert lintegral_iSup_directed_of_measurable (aeSeq.measurable hf p) h_ae_seq_directed using 1 + convert! lintegral_iSup_directed_of_measurable (aeSeq.measurable hf p) h_ae_seq_directed using 1 · simp_rw [← iSup_apply] rw [lintegral_congr_ae (aeSeq.iSup hf hp).symm] · congr 1 diff --git a/Mathlib/MeasureTheory/Integral/Lebesgue/Basic.lean b/Mathlib/MeasureTheory/Integral/Lebesgue/Basic.lean index 2174ec185b4d0c..d7c476b5600c03 100644 --- a/Mathlib/MeasureTheory/Integral/Lebesgue/Basic.lean +++ b/Mathlib/MeasureTheory/Integral/Lebesgue/Basic.lean @@ -201,7 +201,7 @@ theorem iSup_lintegral_le {ι : Sort*} (f : ι → α → ℝ≥0∞) : theorem iSup₂_lintegral_le {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) : ⨆ (i) (j), ∫⁻ a, f i j a ∂μ ≤ ∫⁻ a, ⨆ (i) (j), f i j a ∂μ := by - convert (monotone_lintegral μ).le_map_iSup₂ f with a + convert! (monotone_lintegral μ).le_map_iSup₂ f with a simp only [iSup_apply] theorem le_iInf_lintegral {ι : Sort*} (f : ι → α → ℝ≥0∞) : @@ -211,7 +211,7 @@ theorem le_iInf_lintegral {ι : Sort*} (f : ι → α → ℝ≥0∞) : theorem le_iInf₂_lintegral {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) : ∫⁻ a, ⨅ (i) (h : ι' i), f i h a ∂μ ≤ ⨅ (i) (h : ι' i), ∫⁻ a, f i h a ∂μ := by - convert (monotone_lintegral μ).map_iInf₂_le f with a + convert! (monotone_lintegral μ).map_iInf₂_le f with a simp only [iInf_apply] theorem lintegral_mono_ae {f g : α → ℝ≥0∞} (h : ∀ᵐ a ∂μ, f a ≤ g a) : @@ -453,7 +453,7 @@ theorem hasSum_lintegral_measure {ι} {_ : MeasurableSpace α} (f : α → ℝ theorem lintegral_of_isEmpty {α} [MeasurableSpace α] [IsEmpty α] (μ : Measure α) (f : α → ℝ≥0∞) : ∫⁻ x, f x ∂μ = 0 := by have : Subsingleton (Measure α) := inferInstance - convert lintegral_zero_measure f + convert! lintegral_zero_measure f theorem setLIntegral_empty (f : α → ℝ≥0∞) : ∫⁻ x in ∅, f x ∂μ = 0 := by rw [Measure.restrict_empty, lintegral_zero_measure] @@ -463,7 +463,7 @@ theorem setLIntegral_univ (f : α → ℝ≥0∞) : ∫⁻ x in univ, f x ∂μ theorem setLIntegral_measure_zero (s : Set α) (f : α → ℝ≥0∞) (hs' : μ s = 0) : ∫⁻ x in s, f x ∂μ = 0 := by - convert lintegral_zero_measure _ + convert! lintegral_zero_measure _ exact Measure.restrict_eq_zero.2 hs' -- TODO: Need a better way of rewriting inside of an integral diff --git a/Mathlib/MeasureTheory/Integral/Lebesgue/Countable.lean b/Mathlib/MeasureTheory/Integral/Lebesgue/Countable.lean index 5a8927334b5a16..c2f2922c833a09 100644 --- a/Mathlib/MeasureTheory/Integral/Lebesgue/Countable.lean +++ b/Mathlib/MeasureTheory/Integral/Lebesgue/Countable.lean @@ -110,7 +110,7 @@ theorem _root_.NNReal.count_const_le_le_of_tsum_le [MeasurableSingletonClass α] apply ENNReal.count_const_le_le_of_tsum_le (measurable_coe_nnreal_ennreal.comp a_mble) _ (mod_cast ε_ne_zero) (@ENNReal.coe_ne_top ε) - convert ENNReal.coe_le_coe.mpr tsum_le_c + convert! ENNReal.coe_le_coe.mpr tsum_le_c simp_rw [Function.comp_apply] rw [ENNReal.tsum_coe_eq a_summable.hasSum] @@ -344,7 +344,7 @@ theorem exists_lt_lintegral_simpleFunc_of_lt_lintegral {m : MeasurableSpace α} simp_rw [lintegral_eq_nnreal, lt_iSup_iff] at hL rcases hL with ⟨g₀, hg₀, g₀L⟩ have h'L : L < ∫⁻ x, g₀ x ∂μ := by - convert g₀L + convert! g₀L rw [← SimpleFunc.lintegral_eq_lintegral, SimpleFunc.coe_map] simp only [Function.comp_apply] rcases SimpleFunc.exists_lt_lintegral_simpleFunc_of_lt_lintegral h'L with ⟨g, hg, gL, gtop⟩ diff --git a/Mathlib/MeasureTheory/Integral/Lebesgue/DominatedConvergence.lean b/Mathlib/MeasureTheory/Integral/Lebesgue/DominatedConvergence.lean index 1fc71d17528bcc..808e09449c5376 100644 --- a/Mathlib/MeasureTheory/Integral/Lebesgue/DominatedConvergence.lean +++ b/Mathlib/MeasureTheory/Integral/Lebesgue/DominatedConvergence.lean @@ -76,10 +76,11 @@ theorem tendsto_lintegral_of_dominated_convergence' {F : ℕ → α → ℝ≥0 filter_upwards [h_bound n, (hF_meas n).ae_eq_mk] with a H H' rwa [H'] at H -/-- **Dominated convergence theorem** for filters with a countable basis. -/ -theorem tendsto_lintegral_filter_of_dominated_convergence {ι} {l : Filter ι} +/-- **Dominated convergence theorem** for filters with a countable basis and +AEMeasurable functions. -/ +theorem tendsto_lintegral_filter_of_dominated_convergence' {ι} {l : Filter ι} [l.IsCountablyGenerated] {F : ι → α → ℝ≥0∞} {f : α → ℝ≥0∞} (bound : α → ℝ≥0∞) - (hF_meas : ∀ᶠ n in l, Measurable (F n)) (h_bound : ∀ᶠ n in l, ∀ᵐ a ∂μ, F n a ≤ bound a) + (hF_meas : ∀ᶠ n in l, AEMeasurable (F n) μ) (h_bound : ∀ᶠ n in l, ∀ᵐ a ∂μ, F n a ≤ bound a) (h_fin : ∫⁻ a, bound a ∂μ ≠ ∞) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) l (𝓝 (f a))) : Tendsto (fun n => ∫⁻ a, F n a ∂μ) l (𝓝 <| ∫⁻ a, f a ∂μ) := by rw [tendsto_iff_seq_tendsto] @@ -91,7 +92,7 @@ theorem tendsto_lintegral_filter_of_dominated_convergence {ι} {l : Filter ι} replace h := hxl _ h rcases h with ⟨k, h⟩ rw [← tendsto_add_atTop_iff_nat k] - refine tendsto_lintegral_of_dominated_convergence ?_ ?_ ?_ ?_ ?_ + refine tendsto_lintegral_of_dominated_convergence' ?_ ?_ ?_ ?_ ?_ · exact bound · intro refine (h _ ?_).1 @@ -106,6 +107,15 @@ theorem tendsto_lintegral_filter_of_dominated_convergence {ι} {l : Filter ι} rw [tendsto_add_atTop_iff_nat] assumption +/-- **Dominated convergence theorem** for filters with a countable basis. -/ +theorem tendsto_lintegral_filter_of_dominated_convergence {ι} {l : Filter ι} + [l.IsCountablyGenerated] {F : ι → α → ℝ≥0∞} {f : α → ℝ≥0∞} (bound : α → ℝ≥0∞) + (hF_meas : ∀ᶠ n in l, Measurable (F n)) (h_bound : ∀ᶠ n in l, ∀ᵐ a ∂μ, F n a ≤ bound a) + (h_fin : ∫⁻ a, bound a ∂μ ≠ ∞) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) l (𝓝 (f a))) : + Tendsto (fun n => ∫⁻ a, F n a ∂μ) l (𝓝 <| ∫⁻ a, f a ∂μ) := by + refine tendsto_lintegral_filter_of_dominated_convergence' bound ?_ h_bound h_fin h_lim + filter_upwards [hF_meas] using by fun_prop + /-- If a monotone sequence of functions has an upper bound and the sequence of integrals of these functions tends to the integral of the upper bound, then the sequence of functions converges almost everywhere to the upper bound. Auxiliary version assuming moreover that the diff --git a/Mathlib/MeasureTheory/Integral/Lebesgue/Map.lean b/Mathlib/MeasureTheory/Integral/Lebesgue/Map.lean index 71390c0290ab17..251ec24fe6e155 100644 --- a/Mathlib/MeasureTheory/Integral/Lebesgue/Map.lean +++ b/Mathlib/MeasureTheory/Integral/Lebesgue/Map.lean @@ -30,7 +30,7 @@ theorem lintegral_map {f : β → ℝ≥0∞} {g : α → β} (hf : Measurable f simp only [← Function.comp_apply (f := f) (g := g)] rw [lintegral_eq_iSup_eapprox_lintegral (hf.comp hg)] congr with n : 1 - convert SimpleFunc.lintegral_map _ hg + convert! SimpleFunc.lintegral_map _ hg ext1 x; simp only [eapprox_comp hf hg, coe_comp] theorem lintegral_map' {f : β → ℝ≥0∞} {g : α → β} diff --git a/Mathlib/MeasureTheory/Integral/Lebesgue/Norm.lean b/Mathlib/MeasureTheory/Integral/Lebesgue/Norm.lean index 32d501b01c355a..4e92c7149a6ad4 100644 --- a/Mathlib/MeasureTheory/Integral/Lebesgue/Norm.lean +++ b/Mathlib/MeasureTheory/Integral/Lebesgue/Norm.lean @@ -20,7 +20,7 @@ variable {α : Type*} [MeasurableSpace α] {μ : Measure α} theorem lintegral_ofReal_le_lintegral_enorm (f : α → ℝ) : ∫⁻ x, ENNReal.ofReal (f x) ∂μ ≤ ∫⁻ x, ‖f x‖ₑ ∂μ := by - simp_rw [← ofReal_norm_eq_enorm] + simp_rw [← ofReal_norm] refine lintegral_mono fun x => ENNReal.ofReal_le_ofReal ?_ rw [Real.norm_eq_abs] exact le_abs_self (f x) diff --git a/Mathlib/MeasureTheory/Integral/PeakFunction.lean b/Mathlib/MeasureTheory/Integral/PeakFunction.lean index 304af2d3216ccf..8a0dd8259cb67d 100644 --- a/Mathlib/MeasureTheory/Integral/PeakFunction.lean +++ b/Mathlib/MeasureTheory/Integral/PeakFunction.lean @@ -84,7 +84,7 @@ theorem integrableOn_peak_smul_of_integrableOn_of_tendsto filter_upwards [self_mem_ae_restrict (hs.inter u_open.measurableSet)] with x hx rw [inter_comm] at hx exact (norm_lt_of_mem_ball (hu x hx)).le - convert A.union B + convert! A.union B simp only [diff_union_inter] /-- If a sequence of peak functions `φᵢ` converges uniformly to zero away from a point `x₀` and its @@ -335,7 +335,7 @@ theorem tendsto_setIntegral_pow_smul_of_unique_maximum_of_isCompact_of_measure_n exact tendsto_setIntegral_peak_smul_of_integrableOn_of_tendsto hs.measurableSet hs.measurableSet (Subset.rfl) (self_mem_nhdsWithin) hs.measure_lt_top.ne (Eventually.of_forall hnφ) A B C hmg hcg - convert this + convert! this simp_rw [φ, ← smul_smul, integral_smul] /-- If a continuous function `c` realizes its maximum at a unique point `x₀` in a compact set `s`, @@ -463,7 +463,7 @@ theorem tendsto_integral_comp_smul_smul_of_integrable' have A : ContinuousAt g (x₀ - 0) := by simpa using h'g exact A.comp <| by fun_prop simp only [f, sub_zero] at this - convert this using 2 with c + convert! this using 2 with c conv_rhs => rw [← integral_add_left_eq_self x₀ (μ := μ) (f := fun x ↦ (c ^ finrank ℝ F * φ (c • x)) • g (x₀ - x)), ← integral_neg_eq_self] simp [sub_eq_add_neg] diff --git a/Mathlib/MeasureTheory/Integral/Prod.lean b/Mathlib/MeasureTheory/Integral/Prod.lean index d30a559f11e351..52dbfc043a1053 100644 --- a/Mathlib/MeasureTheory/Integral/Prod.lean +++ b/Mathlib/MeasureTheory/Integral/Prod.lean @@ -153,7 +153,7 @@ theorem integrable_measure_prodMk_left {s : Set (α × β)} (hs : MeasurableSet (h2s : (μ.prod ν) s ≠ ∞) : Integrable (fun x => ν.real (Prod.mk x ⁻¹' s)) μ := by refine ⟨(measurable_measure_prodMk_left hs).ennreal_toReal.aemeasurable.aestronglyMeasurable, ?_⟩ simp_rw [hasFiniteIntegral_iff_enorm, measureReal_def, enorm_eq_ofReal toReal_nonneg] - convert h2s.lt_top using 1 + convert! h2s.lt_top using 1 rw [prod_apply hs] apply lintegral_congr_ae filter_upwards [ae_measure_lt_top hs h2s] with x hx @@ -248,7 +248,7 @@ theorem hasFiniteIntegral_prod_iff ⦃f : α × β → E⦄ (h1f : StronglyMeasu have (x : _) : ∀ᵐ y ∂ν, 0 ≤ ‖f (x, y)‖ := by filter_upwards with y using norm_nonneg _ simp_rw [integral_eq_lintegral_of_nonneg_ae (this _) (h1f.norm.comp_measurable measurable_prodMk_left).aestronglyMeasurable, - enorm_eq_ofReal toReal_nonneg, ofReal_norm_eq_enorm] + enorm_eq_ofReal toReal_nonneg, ofReal_norm] -- this fact is probably too specialized to be its own lemma have : ∀ {p q r : Prop} (_ : r → p), (r ↔ p ∧ q) ↔ p → (r ↔ q) := fun {p q r} h1 => by rw [← and_congr_right_iff, and_iff_right_of_imp h1] @@ -287,7 +287,7 @@ theorem integrable_prod_iff' [SFinite μ] ⦃f : α × β → E⦄ (h1f : AEStronglyMeasurable f (μ.prod ν)) : Integrable f (μ.prod ν) ↔ (∀ᵐ y ∂ν, Integrable (fun x => f (x, y)) μ) ∧ Integrable (fun y => ∫ x, ‖f (x, y)‖ ∂μ) ν := by - convert integrable_prod_iff h1f.prod_swap using 1 + convert! integrable_prod_iff h1f.prod_swap using 1 rw [funext fun _ => Function.comp_apply.symm, integrable_swap_iff] theorem Integrable.prod_left_ae [SFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) : @@ -472,7 +472,7 @@ theorem continuous_integral_integral : Continuous fun f : α × β →₁[μ.prod ν] E => ∫ x, ∫ y, f (x, y) ∂ν ∂μ := by rw [continuous_iff_continuousAt]; intro g refine - tendsto_integral_of_L1 _ (L1.integrable_coeFn g).integral_prod_left + tendsto_integral_of_L1 _ (L1.integrable_coeFn g).integral_prod_left.aestronglyMeasurable (Eventually.of_forall fun h => (L1.integrable_coeFn h).integral_prod_left) ?_ simp_rw [← lintegral_fn_integral_sub _ (L1.integrable_coeFn _) (L1.integrable_coeFn g)] apply tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds _ (fun i => zero_le) _ @@ -508,7 +508,7 @@ theorem integral_prod (f : α × β → E) (hf : Integrable f (μ.prod ν)) : · rintro f g - i_f i_g hf hg simp_rw [integral_add' i_f i_g, integral_integral_add' i_f i_g, hf, hg] · exact isClosed_eq continuous_integral continuous_integral_integral - · rintro f g hfg - hf; convert hf using 1 + · rintro f g hfg - hf; convert! hf using 1 · exact integral_congr_ae hfg.symm · apply integral_congr_ae filter_upwards [ae_ae_of_ae_prod hfg] with x hfgx using integral_congr_ae (ae_eq_symm hfgx) @@ -554,6 +554,20 @@ theorem setIntegral_prod (f : α × β → E) {s : Set α} {t : Set β} simp only [← Measure.prod_restrict s t, IntegrableOn] at hf ⊢ exact integral_prod f hf +theorem integral_prod_bilin {E F G 𝕜 : Type*} [RCLike 𝕜] + [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace 𝕜 E] [CompleteSpace E] + [NormedAddCommGroup F] [NormedSpace ℝ F] [NormedSpace 𝕜 F] [CompleteSpace F] + [NormedAddCommGroup G] [NormedSpace ℝ G] [NormedSpace 𝕜 G] [CompleteSpace G] + (B : E →L[𝕜] F →L[𝕜] G) {f : α → E} {g : β → F} + (hf : Integrable f μ) (hg : Integrable g ν) : + ∫ z, B (f z.1) (g z.2) ∂μ.prod ν = B (∫ x, f x ∂μ) (∫ y, g y ∂ν) := by + have : Integrable (fun z ↦ B (f z.1) (g z.2)) (μ.prod ν) := + hf.op_fst_snd (by fun_prop) ⟨‖B‖, B.le_opNorm₂⟩ hg + simp_rw [integral_prod _ this, ContinuousLinearMap.integral_comp_comm _ hg] + change ∫ x, B.flip (∫ y, g y ∂ν) (f x) ∂μ = _ + rw [ContinuousLinearMap.integral_comp_comm _ hf] + simp + theorem integral_prod_smul {𝕜 : Type*} [RCLike 𝕜] [NormedSpace 𝕜 E] (f : α → 𝕜) (g : β → E) : ∫ z, f z.1 • g z.2 ∂μ.prod ν = (∫ x, f x ∂μ) • ∫ y, g y ∂ν := by by_cases hE : CompleteSpace E; swap; · simp [integral, hE] diff --git a/Mathlib/MeasureTheory/Integral/RieszMarkovKakutani/Real.lean b/Mathlib/MeasureTheory/Integral/RieszMarkovKakutani/Real.lean index 58018d923fbe92..f7835beb238390 100644 --- a/Mathlib/MeasureTheory/Integral/RieszMarkovKakutani/Real.lean +++ b/Mathlib/MeasureTheory/Integral/RieszMarkovKakutani/Real.lean @@ -481,7 +481,7 @@ lemma _root_.MeasureTheory.Measure.exists_innerRegular_eq_of_isCompact by infer_instance, ?_, fun g ↦ ?_⟩ · rw [Measure.map_apply (by fun_prop) hK.measurableSet.compl] simp - convert hν' (g.compContinuous ⟨Subtype.val, by fun_prop⟩) + convert! hν' (g.compContinuous ⟨Subtype.val, by fun_prop⟩) · simp only [BoundedContinuousFunction.compContinuous_apply, ContinuousMap.coe_mk] rw [← integral_map (φ := Subtype.val) (by fun_prop) (by fun_prop)] simp only [map_comap_subtype_coe hK.measurableSet, μ', Measure.restrict_eq_self_of_ae_mem h] diff --git a/Mathlib/MeasureTheory/Integral/SetToL1.lean b/Mathlib/MeasureTheory/Integral/SetToL1.lean index ef5286cfbd74a0..97ec05d662dcba 100644 --- a/Mathlib/MeasureTheory/Integral/SetToL1.lean +++ b/Mathlib/MeasureTheory/Integral/SetToL1.lean @@ -92,7 +92,7 @@ theorem norm_eq_sum_mul (f : α →₁ₛ[μ] G) : rw [SimpleFunc.lintegral_eq_lintegral, SimpleFunc.map_lintegral, ENNReal.toReal_sum] · congr ext1 x - rw [ENNReal.toReal_mul, mul_comm, ← ofReal_norm_eq_enorm, + rw [ENNReal.toReal_mul, mul_comm, ← ofReal_norm, ENNReal.toReal_ofReal (norm_nonneg _)] · intro x _ by_cases hx0 : x = 0 @@ -754,7 +754,7 @@ theorem setToFun_finsetSum' (hT : DominatedFinMeasAdditive μ T C) {ι} (s : Fin simp only [his, Finset.sum_insert, not_false_iff] rw [setToFun_add hT (hf i (Finset.mem_insert_self i s)) _] · rw [ih fun i hi => hf i (Finset.mem_insert_of_mem hi)] - · convert integrable_finsetSum s fun i hi => hf i (Finset.mem_insert_of_mem hi) with x + · convert! integrable_finsetSum s fun i hi => hf i (Finset.mem_insert_of_mem hi) with x simp @[deprecated (since := "2026-04-08")] alias setToFun_finset_sum' := setToFun_finsetSum' @@ -762,7 +762,7 @@ theorem setToFun_finsetSum' (hT : DominatedFinMeasAdditive μ T C) {ι} (s : Fin theorem setToFun_finsetSum (hT : DominatedFinMeasAdditive μ T C) {ι} (s : Finset ι) {f : ι → α → E} (hf : ∀ i ∈ s, Integrable (f i) μ) : (setToFun μ T hT fun a => ∑ i ∈ s, f i a) = ∑ i ∈ s, setToFun μ T hT (f i) := by - convert setToFun_finsetSum' hT s hf with a; simp + convert! setToFun_finsetSum' hT s hf with a; simp @[deprecated (since := "2026-04-08")] alias setToFun_finset_sum := setToFun_finsetSum @@ -776,6 +776,10 @@ theorem setToFun_neg (hT : DominatedFinMeasAdditive μ T C) (f : α → E) : · rw [setToFun_undef hT hf, setToFun_undef hT, neg_zero] rwa [← integrable_neg_iff] at hf +theorem setToFun_neg' (hT : DominatedFinMeasAdditive μ T C) (f : α → E) : + setToFun μ (-T) hT.neg f = -setToFun μ T hT f := by + simpa using setToFun_smul_left' hT hT.neg (-1) (by simp) f + theorem setToFun_sub (hT : DominatedFinMeasAdditive μ T C) (hf : Integrable f μ) (hg : Integrable g μ) : setToFun μ T hT (f - g) = setToFun μ T hT f - setToFun μ T hT g := by rw [sub_eq_add_neg, sub_eq_add_neg, setToFun_add hT hf hg.neg, setToFun_neg hT g] @@ -1090,6 +1094,43 @@ theorem setToFun_congr_measure_of_add_left {μ' : Measure α} rw [one_smul] exact Measure.le_add_left le_rfl +theorem setToFun_add_measure {ν : Measure α} (hTμ : DominatedFinMeasAdditive μ T C) + (hTν : DominatedFinMeasAdditive ν T' C') (hμ : Integrable f μ) (hν : Integrable f ν) : + setToFun (μ + ν) (T + T') (hTμ.add_measure μ ν hTν) f = + setToFun μ T hTμ f + setToFun ν T' hTν f := + have hTμ_add : DominatedFinMeasAdditive (μ + ν) T (max C 0) := + (hTμ.of_le (le_max_left C 0)).add_measure_right μ ν (le_max_right C 0) + have hTν_add : DominatedFinMeasAdditive (μ + ν) T' (max C' 0) := + (hTν.of_le (le_max_left C' 0)).add_measure_left μ ν (le_max_right C' 0) + calc + setToFun (μ + ν) (T + T') (hTμ.add_measure μ ν hTν) f = + setToFun (μ + ν) T hTμ_add f + setToFun (μ + ν) T' hTν_add f := + setToFun_add_left hTμ_add hTν_add f + _ = setToFun μ T hTμ f + setToFun ν T' hTν f := by + rw [setToFun_congr_measure_of_add_right hTμ_add hTμ f (hμ.add_measure hν), + setToFun_congr_measure_of_add_left hTν_add hTν f (hμ.add_measure hν)] + +theorem setToFun_sub_measure {ν : Measure α} (hTμ : DominatedFinMeasAdditive μ T C) + (hTν : DominatedFinMeasAdditive ν T' C') (hμ : Integrable f μ) (hν : Integrable f ν) : + setToFun (μ + ν) (T - T') (hTμ.sub_measure μ ν hTν) f = + setToFun μ T hTμ f - setToFun ν T' hTν f := by + simp [sub_eq_add_neg, setToFun_add_measure hTμ hTν.neg hμ hν, setToFun_neg' hTν] + +theorem setToFun_finsetSum_measure {ι} {s : Finset ι} (hs : s.Nonempty) + {μ : ι → Measure α} {T : ι → Set α → E →L[ℝ] F} {C : ι → ℝ} + (hTs : ∀ i, DominatedFinMeasAdditive (μ i) (T i) (C i)) + (hf : ∀ i ∈ s, Integrable f (μ i)) : + setToFun (∑ i ∈ s, μ i) (∑ i ∈ s, T i) + (DominatedFinMeasAdditive.finsetSum_measure hs μ T C hTs) f = + ∑ i ∈ s, setToFun (μ i) (T i) (hTs i) f := by + induction hs using Finset.Nonempty.cons_induction with + | singleton i => simp + | @cons i s his hs' ih => + simpa [his, ih fun j hj => hf j (Finset.mem_cons_of_mem hj)] using + setToFun_add_measure (hTs i) (DominatedFinMeasAdditive.finsetSum_measure hs' μ T C hTs) + (hf i (Finset.mem_cons_self i s)) + (integrable_finsetSum_measure.2 fun j hj => hf j (Finset.mem_cons_of_mem hj)) + theorem setToFun_top_smul_measure (hT : DominatedFinMeasAdditive (∞ • μ) T C) (f : α → E) : setToFun (∞ • μ) T hT f = 0 := by refine setToFun_measure_zero' hT fun s _ hμs => ?_ @@ -1225,7 +1266,7 @@ theorem tendsto_setToFun_of_dominated_convergence (hT : DominatedFinMeasAdditive suffices Tendsto (fun n => L1.setToL1 hT ((fs_int n).toL1 (fs n))) atTop (𝓝 (L1.setToL1 hT (f_int.toL1 f))) by - convert this with n + convert! this with n · exact setToFun_eq hT (fs_int n) · exact setToFun_eq hT f_int -- the convergence of setToL1 follows from the convergence of the L1 functions @@ -1237,14 +1278,14 @@ theorem tendsto_setToFun_of_dominated_convergence (hT : DominatedFinMeasAdditive (tendsto_toReal zero_ne_top).comp (tendsto_lintegral_norm_of_dominated_convergence fs_measurable bound_integrable.hasFiniteIntegral h_bound h_lim) - convert lintegral_norm_tendsto_zero with n + convert! lintegral_norm_tendsto_zero with n rw [L1.norm_def] congr 1 refine lintegral_congr_ae ?_ rw [← Integrable.toL1_sub] refine ((fs_int n).sub f_int).coeFn_toL1.mono fun x hx => ?_ dsimp only - rw [hx, ofReal_norm_eq_enorm, Pi.sub_apply] + rw [hx, ofReal_norm, Pi.sub_apply] /-- Lebesgue dominated convergence theorem for filters with a countable basis -/ theorem tendsto_setToFun_filter_of_dominated_convergence (hT : DominatedFinMeasAdditive μ T C) {ι} diff --git a/Mathlib/MeasureTheory/MeasurableSpace/Basic.lean b/Mathlib/MeasureTheory/MeasurableSpace/Basic.lean index 3314bd93f84f19..fe1d878ffac013 100644 --- a/Mathlib/MeasureTheory/MeasurableSpace/Basic.lean +++ b/Mathlib/MeasureTheory/MeasurableSpace/Basic.lean @@ -254,7 +254,7 @@ for functions between empty types. -/ theorem measurable_const' {f : β → α} (hf : ∀ x y, f x = f y) : Measurable f := by nontriviality β inhabit β - convert @measurable_const α β _ _ (f default) using 2 + convert! @measurable_const α β _ _ (f default) using 2 apply hf @[fun_prop] @@ -315,7 +315,7 @@ which takes a constant value `b ≠ 0` on a set `A` and `0` elsewhere. -/ lemma measurable_indicator_const_iff [Zero β] [MeasurableSingletonClass β] (b : β) [NeZero b] : Measurable (s.indicator (fun (_ : α) ↦ b)) ↔ MeasurableSet s := by constructor <;> intro h - · convert h (MeasurableSet.singleton (0 : β)).compl + · convert! h (MeasurableSet.singleton (0 : β)).compl ext a simp [NeZero.ne b] · exact measurable_const.indicator h diff --git a/Mathlib/MeasureTheory/MeasurableSpace/Card.lean b/Mathlib/MeasureTheory/MeasurableSpace/Card.lean index a9717ac2de143d..4b72b2e6a457fb 100644 --- a/Mathlib/MeasureTheory/MeasurableSpace/Card.lean +++ b/Mathlib/MeasureTheory/MeasurableSpace/Card.lean @@ -77,7 +77,7 @@ theorem generateMeasurableRec_mono (s : Set (Set α)) : Monotone (generateMeasur intro i j h x hx rcases h.eq_or_lt with (rfl | h) · exact hx - · convert iUnion_mem_generateMeasurableRec fun _ => ⟨i, h, hx⟩ + · convert! iUnion_mem_generateMeasurableRec fun _ => ⟨i, h, hx⟩ exact (iUnion_const x).symm /-- An inductive principle for the elements of `generateMeasurableRec`. -/ diff --git a/Mathlib/MeasureTheory/MeasurableSpace/Constructions.lean b/Mathlib/MeasureTheory/MeasurableSpace/Constructions.lean index 99dceda0cffb8e..d776ff14272271 100644 --- a/Mathlib/MeasureTheory/MeasurableSpace/Constructions.lean +++ b/Mathlib/MeasureTheory/MeasurableSpace/Constructions.lean @@ -86,7 +86,7 @@ theorem measurable_to_nat {f : α → ℕ} : (∀ y, MeasurableSet (f ⁻¹' {f theorem measurable_to_bool {f : α → Bool} (h : MeasurableSet (f ⁻¹' {true})) : Measurable f := by apply measurable_to_countable' rintro (- | -) - · convert h.compl + · convert! h.compl rw [← preimage_compl, Bool.compl_singleton, Bool.not_true] exact h @@ -245,7 +245,7 @@ theorem MeasurableSet.image_inclusion' {s t : Set α} (h : s ⊆ t) {u : Set s} (hs : MeasurableSet (Subtype.val ⁻¹' s : Set t)) (hu : MeasurableSet u) : MeasurableSet (inclusion h '' u) := by rcases hu with ⟨u, hu, rfl⟩ - convert (measurable_subtype_coe hu).inter hs + convert! (measurable_subtype_coe hu).inter hs ext ⟨x, hx⟩ simpa [@and_comm _ (_ = x)] using and_comm @@ -257,7 +257,7 @@ theorem MeasurableSet.image_inclusion {s t : Set α} (h : s ⊆ t) {u : Set s} theorem MeasurableSet.of_union_cover {s t u : Set α} (hs : MeasurableSet s) (ht : MeasurableSet t) (h : univ ⊆ s ∪ t) (hsu : MeasurableSet (((↑) : s → α) ⁻¹' u)) (htu : MeasurableSet (((↑) : t → α) ⁻¹' u)) : MeasurableSet u := by - convert (hs.subtype_image hsu).union (ht.subtype_image htu) + convert! (hs.subtype_image hsu).union (ht.subtype_image htu) simp [image_preimage_eq_inter_range, ← inter_union_distrib_left, univ_subset_iff.1 h] theorem measurable_of_measurable_union_cover {f : α → β} (s t : Set α) (hs : MeasurableSet s) @@ -586,6 +586,12 @@ theorem measurable_pi_lambda (f : α → ∀ a, X a) (hf : ∀ a, Measurable fun Measurable f := measurable_pi_iff.mpr hf +lemma MeasurableSpace.comap_process_pi (X : (a : δ) → β → X a) : + MeasurableSpace.comap (fun b a ↦ X a b) inferInstance = + ⨆ a, MeasurableSpace.comap (X a) inferInstance := by + simp_rw [MeasurableSpace.pi, MeasurableSpace.comap_iSup, MeasurableSpace.comap_comp] + rfl + /-- The function `(f, x) ↦ update f a x : (Π a, X a) × X a → Π a, X a` is measurable. -/ @[fun_prop] theorem measurable_update' {a : δ} [DecidableEq δ] : @@ -707,7 +713,7 @@ theorem measurableSet_pi_of_nonempty {s : Set δ} {t : ∀ i, Set (X i)} (hs : s classical rcases h with ⟨f, hf⟩ refine ⟨fun hst i hi => ?_, MeasurableSet.pi hs⟩ - convert measurable_update f (a := i) hst + convert! measurable_update f (a := i) hst rw [update_preimage_pi hi] exact fun j hj _ => hf j hj diff --git a/Mathlib/MeasureTheory/MeasurableSpace/CountablyGenerated.lean b/Mathlib/MeasureTheory/MeasurableSpace/CountablyGenerated.lean index 0961470694952c..fa2ca1b8c85896 100644 --- a/Mathlib/MeasureTheory/MeasurableSpace/CountablyGenerated.lean +++ b/Mathlib/MeasureTheory/MeasurableSpace/CountablyGenerated.lean @@ -231,7 +231,7 @@ instance (priority := 50) MeasurableSingletonClass.of_separatesPoints [Measurabl [Countable α] [SeparatesPoints α] : MeasurableSingletonClass α where measurableSet_singleton x := by choose s hsm hxs hys using fun y (h : x ≠ y) ↦ exists_measurableSet_of_ne h - convert MeasurableSet.iInter fun y ↦ .iInter fun h ↦ hsm y h + convert! MeasurableSet.iInter fun y ↦ .iInter fun h ↦ hsm y h ext y rcases eq_or_ne x y with rfl | h · simpa @@ -251,7 +251,7 @@ instance countablySeparated_of_separatesPoints [MeasurableSpace α] rcases h with ⟨b, hbc, hb⟩ refine ⟨⟨b, hbc, fun t ht ↦ hb.symm ▸ .basic t ht, ?_⟩⟩ rw [hb] at ‹SeparatesPoints _› - convert separating_of_generateFrom b + convert! separating_of_generateFrom b simp variable (α) diff --git a/Mathlib/MeasureTheory/MeasurableSpace/Embedding.lean b/Mathlib/MeasureTheory/MeasurableSpace/Embedding.lean index b3ee9530748549..d2ea336fb442ce 100644 --- a/Mathlib/MeasureTheory/MeasurableSpace/Embedding.lean +++ b/Mathlib/MeasureTheory/MeasurableSpace/Embedding.lean @@ -142,15 +142,16 @@ variable {α₁ α₂ α₃ : Type*} {mα : MeasurableSpace α} {mβ : Measurabl lemma MeasurableSet.of_union_range_cover (hi₁ : MeasurableEmbedding i₁) (hi₂ : MeasurableEmbedding i₂) (h : univ ⊆ range i₁ ∪ range i₂) (hs₁ : MeasurableSet (i₁ ⁻¹' s)) (hs₂ : MeasurableSet (i₂ ⁻¹' s)) : MeasurableSet s := by - convert (hi₁.measurableSet_image' hs₁).union (hi₂.measurableSet_image' hs₂) + convert! (hi₁.measurableSet_image' hs₁).union (hi₂.measurableSet_image' hs₂) simp [image_preimage_eq_range_inter, ← union_inter_distrib_right, univ_subset_iff.1 h] lemma MeasurableSet.of_union₃_range_cover (hi₁ : MeasurableEmbedding i₁) (hi₂ : MeasurableEmbedding i₂) (hi₃ : MeasurableEmbedding i₃) (h : univ ⊆ range i₁ ∪ range i₂ ∪ range i₃) (hs₁ : MeasurableSet (i₁ ⁻¹' s)) (hs₂ : MeasurableSet (i₂ ⁻¹' s)) (hs₃ : MeasurableSet (i₃ ⁻¹' s)) : MeasurableSet s := by - convert (hi₁.measurableSet_image' hs₁).union (hi₂.measurableSet_image' hs₂) |>.union - (hi₃.measurableSet_image' hs₃) + convert! + (hi₁.measurableSet_image' hs₁).union (hi₂.measurableSet_image' hs₂) |>.union + (hi₃.measurableSet_image' hs₃) simp [image_preimage_eq_range_inter, ← union_inter_distrib_right, univ_subset_iff.1 h] lemma Measurable.of_union_range_cover (hi₁ : MeasurableEmbedding i₁) diff --git a/Mathlib/MeasureTheory/MeasurableSpace/Instances.lean b/Mathlib/MeasureTheory/MeasurableSpace/Instances.lean index 2d7013c9d3ec07..6c939e5717ea98 100644 --- a/Mathlib/MeasureTheory/MeasurableSpace/Instances.lean +++ b/Mathlib/MeasureTheory/MeasurableSpace/Instances.lean @@ -50,7 +50,7 @@ instance IterateMulAct.instDiscreteMeasurableSpace {α : Type*} {f : α → α} instance (priority := 100) Subsingleton.measurableSingletonClass {α} [MeasurableSpace α] [Subsingleton α] : MeasurableSingletonClass α := by refine ⟨fun i => ?_⟩ - convert MeasurableSet.univ + convert! MeasurableSet.univ simp [Set.eq_univ_iff_forall, eq_iff_true_of_subsingleton] instance Bool.instMeasurableSingletonClass : MeasurableSingletonClass Bool := ⟨fun _ => trivial⟩ diff --git a/Mathlib/MeasureTheory/MeasurableSpace/Prod.lean b/Mathlib/MeasureTheory/MeasurableSpace/Prod.lean index d007a5cd20a036..d12c7b09873ddd 100644 --- a/Mathlib/MeasureTheory/MeasurableSpace/Prod.lean +++ b/Mathlib/MeasureTheory/MeasurableSpace/Prod.lean @@ -110,7 +110,7 @@ lemma MeasurableEmbedding.prodMk_left {β γ : Type*} [MeasurableSingletonClass measurable := Measurable.prodMk measurable_const hf.measurable measurableSet_image' := by intro s hs - convert (MeasurableSet.singleton x).prod (hf.measurableSet_image.mpr hs) + convert! (MeasurableSet.singleton x).prod (hf.measurableSet_image.mpr hs) ext x simp [Prod.ext_iff, eq_comm, ← exists_and_left, and_left_comm] diff --git a/Mathlib/MeasureTheory/Measure/AEMeasurable.lean b/Mathlib/MeasureTheory/Measure/AEMeasurable.lean index c1246409e14512..3905185f5bf840 100644 --- a/Mathlib/MeasureTheory/Measure/AEMeasurable.lean +++ b/Mathlib/MeasureTheory/Measure/AEMeasurable.lean @@ -347,7 +347,7 @@ lemma aemeasurable_indicator_const_iff {s} [MeasurableSingletonClass β] (b : β AEMeasurable (s.indicator (fun _ ↦ b)) μ ↔ NullMeasurableSet s μ := by classical constructor <;> intro h - · convert h.nullMeasurable (MeasurableSet.singleton (0 : β)).compl + · convert! h.nullMeasurable (MeasurableSet.singleton (0 : β)).compl rw [indicator_const_preimage_eq_union s {0}ᶜ b] simp [NeZero.ne b] · exact (aemeasurable_indicator_iff₀ h).mpr aemeasurable_const @@ -404,7 +404,7 @@ lemma MeasureTheory.NullMeasurable.aemeasurable {f : α → β} · rw [restrict_piecewise_compl, restrict_eq] refine measurable_generateFrom fun s hs ↦ .of_subtype_image ?_ rw [preimage_comp, Subtype.image_preimage_coe] - convert (hTm s hs).diff hvm using 1 + convert! (hTm s hs).diff hvm using 1 rw [inter_comm] refine Set.ext fun x ↦ and_congr_left fun hxv ↦ ⟨fun hx ↦ ?_, fun hx ↦ hTf s hs hx⟩ exact by_contra fun hx' ↦ hxv <| mem_biUnion hs ⟨hUf s hs hx, hx'⟩ diff --git a/Mathlib/MeasureTheory/Measure/AddContent.lean b/Mathlib/MeasureTheory/Measure/AddContent.lean index 8e9deafbdd1e8a..be96ec8bd423ce 100644 --- a/Mathlib/MeasureTheory/Measure/AddContent.lean +++ b/Mathlib/MeasureTheory/Measure/AddContent.lean @@ -121,7 +121,7 @@ lemma addContent_biUnion {ι : Type*} {a : Finset ι} {f : ι → Set α} (hf : lemma addContent_iUnion {ι : Type*} [Fintype ι] {f : ι → Set α} (hf : ∀ i, f i ∈ C) (h_dis : Pairwise (Disjoint on f)) (h_mem : ⋃ i, f i ∈ C) : m (⋃ i, f i) = ∑ i, m (f i) := by - convert addContent_biUnion (a := Finset.univ) (f := f) (m := m) ?_ ?_ ?_ using 1 + convert! addContent_biUnion (a := Finset.univ) (f := f) (m := m) ?_ ?_ ?_ using 1 · simp · simpa · simpa [Set.PairwiseDisjoint, Set.pairwise_univ] using h_dis @@ -130,7 +130,7 @@ lemma addContent_iUnion {ι : Type*} [Fintype ι] {f : ι → Set α} (hf : ∀ lemma addContent_union' (hs : s ∈ C) (ht : t ∈ C) (hst : s ∪ t ∈ C) (h_dis : Disjoint s t) : m (s ∪ t) = m s + m t := by have A : s ∪ t = ⋃ i, ![s, t] i := by ext; simp - convert addContent_iUnion (f := ![s, t]) (m := m) (fun i ↦ ?_) (fun i j hij ↦ ?_) ?_ using 2 + convert! addContent_iUnion (f := ![s, t]) (m := m) (fun i ↦ ?_) (fun i j hij ↦ ?_) ?_ using 2 · simp [Fin.univ_castSuccEmb, add_comm] · fin_cases i <;> simpa · #adaptation_note /-- Before https://github.com/leanprover/lean4/pull/13166 @@ -257,7 +257,7 @@ private lemma AddContent.supClosureFun_apply_of_mem (hC : IsSetSemiring C) have := hI hs rwa [hC.mem_supClosure_iff] at this refine ⟨P.parts, PC, P.disjoint, ?_⟩ - convert P.sup_parts.symm + convert! P.sup_parts.symm simp [sUnion_eq_biUnion] choose! J hJC hJdisj hJs using A have H {a i} (hi : i ∈ I) (ha : a ∈ J i) : a ⊆ i := by diff --git a/Mathlib/MeasureTheory/Measure/CharacteristicFunction/TaylorExpansion.lean b/Mathlib/MeasureTheory/Measure/CharacteristicFunction/TaylorExpansion.lean index 01eca816954e13..bfb217a1a6f464 100644 --- a/Mathlib/MeasureTheory/Measure/CharacteristicFunction/TaylorExpansion.lean +++ b/Mathlib/MeasureTheory/Measure/CharacteristicFunction/TaylorExpansion.lean @@ -128,7 +128,7 @@ lemma taylorWithinEval_charFun_two_zero (hX : AEMeasurable X P) taylorWithinEval (charFun (P.map X)) 2 univ 0 t = 1 + (P[X] : ℝ) * t * I - (P[X ^ 2] : ℝ) * t ^ 2 / 2 := by have : IsProbabilityMeasure (P.map X) := Measure.isProbabilityMeasure_map hX - convert taylorWithinEval_charFun_zero hint t with x + convert! taylorWithinEval_charFun_zero hint t with x simp only [Pi.pow_apply, Nat.reduceAdd, Finset.sum_range_succ, Finset.range_one, Finset.sum_singleton, Nat.factorial_zero, Nat.cast_one, inv_one, pow_zero, mul_one, integral_const, probReal_univ, smul_eq_mul, ofReal_one, Nat.factorial_one, pow_one, one_mul, @@ -151,7 +151,7 @@ lemma taylorWithinEval_charFun_two_zero' (hX : AEMeasurable X P) lemma taylor_charFun_two (hX : AEMeasurable X P) (h0 : P[X] = 0) (h1 : P[X ^ 2] = 1) : (fun t ↦ charFun (P.map X) t - (1 - t ^ 2 / 2)) =o[𝓝 0] fun t ↦ t ^ 2 := by simp_rw [← taylorWithinEval_charFun_two_zero' (by fun_prop) h0 h1] - convert taylor_isLittleO_univ ?_ + convert! taylor_isLittleO_univ ?_ · simp refine contDiff_charFun <| (memLp_two_iff_integrable_sq (by fun_prop)).2 (.of_integral_ne_zero ?_) diff --git a/Mathlib/MeasureTheory/Measure/Content.lean b/Mathlib/MeasureTheory/Measure/Content.lean index 153a127c993edc..f542176289b271 100644 --- a/Mathlib/MeasureTheory/Measure/Content.lean +++ b/Mathlib/MeasureTheory/Measure/Content.lean @@ -173,7 +173,7 @@ theorem innerContent_iSup_nat [R1Space G] (U : ℕ → Opens G) : rcases K.isCompact.finite_compact_cover t (SetLike.coe ∘ U) (fun i _ => (U i).isOpen) ht with ⟨K', h1K', h2K', h3K'⟩ let L : ℕ → Compacts G := fun n => ⟨K' n, h1K' n⟩ - convert le_trans (h3 t L) _ + convert! le_trans (h3 t L) _ · ext1 rw [Compacts.coe_finset_sup, Finset.sup_eq_iSup] exact h3K' @@ -204,7 +204,7 @@ theorem is_mul_left_invariant_innerContent [Group G] [SeparatelyContinuousMul G] (h : ∀ (g : G) {K : Compacts G}, μ (K.map _ <| continuous_const_mul g) = μ K) (g : G) (U : Opens G) : μ.innerContent (Opens.comap (Homeomorph.mulLeft g) U) = μ.innerContent U := by - convert μ.innerContent_comap (Homeomorph.mulLeft g) (fun K => h g) U + convert! μ.innerContent_comap (Homeomorph.mulLeft g) (fun K => h g) U @[to_additive] theorem innerContent_pos_of_is_mul_left_invariant [Group G] [IsTopologicalGroup G] @@ -276,7 +276,7 @@ theorem outerMeasure_preimage (f : G ≃ₜ G) (h : ∀ ⦃K : Compacts G⦄, μ refine inducedOuterMeasure_preimage _ μ.innerContent_iUnion_nat μ.innerContent_mono _ (fun _ => f.isOpen_preimage) ?_ intro s hs - convert μ.innerContent_comap f h ⟨s, hs⟩ + convert! μ.innerContent_comap f h ⟨s, hs⟩ theorem outerMeasure_lt_top_of_isCompact [WeaklyLocallyCompactSpace G] {K : Set G} (hK : IsCompact K) : @@ -292,7 +292,7 @@ theorem outerMeasure_lt_top_of_isCompact [WeaklyLocallyCompactSpace G] theorem is_mul_left_invariant_outerMeasure [Group G] [SeparatelyContinuousMul G] (h : ∀ (g : G) {K : Compacts G}, μ (K.map _ <| continuous_const_mul g) = μ K) (g : G) (A : Set G) : μ.outerMeasure ((g * ·) ⁻¹' A) = μ.outerMeasure A := by - convert μ.outerMeasure_preimage (Homeomorph.mulLeft g) (fun K => h g) A + convert! μ.outerMeasure_preimage (Homeomorph.mulLeft g) (fun K => h g) A theorem outerMeasure_caratheodory (A : Set G) : MeasurableSet[μ.outerMeasure.caratheodory] A ↔ @@ -306,7 +306,7 @@ theorem outerMeasure_caratheodory (A : Set G) : theorem outerMeasure_pos_of_is_mul_left_invariant [Group G] [IsTopologicalGroup G] (h3 : ∀ (g : G) {K : Compacts G}, μ (K.map _ <| continuous_const_mul g) = μ K) (K : Compacts G) (hK : μ K ≠ 0) {U : Set G} (h1U : IsOpen U) (h2U : U.Nonempty) : 0 < μ.outerMeasure U := by - convert μ.innerContent_pos_of_is_mul_left_invariant h3 K hK ⟨U, h1U⟩ h2U + convert! μ.innerContent_pos_of_is_mul_left_invariant h3 K hK ⟨U, h1U⟩ h2U exact μ.outerMeasure_opens ⟨U, h1U⟩ variable [S : MeasurableSpace G] [BorelSpace G] diff --git a/Mathlib/MeasureTheory/Measure/Decomposition/IntegralRNDeriv.lean b/Mathlib/MeasureTheory/Measure/Decomposition/IntegralRNDeriv.lean index 840aa43436c9ae..1a0daa3c7fba7e 100644 --- a/Mathlib/MeasureTheory/Measure/Decomposition/IntegralRNDeriv.lean +++ b/Mathlib/MeasureTheory/Measure/Decomposition/IntegralRNDeriv.lean @@ -109,7 +109,7 @@ lemma mul_le_integral_rnDeriv_of_ac [IsFiniteMeasure μ] [IsFiniteMeasure ν] filter_upwards [h_rnDeriv_eq] with x hx rw [hx] rw [h_eq, mul_comm, ← div_le_iff₀, div_eq_inv_mul, inv_inv] at h - · convert h + · convert! h · simp only [div_eq_inv_mul, Measure.smul_apply, smul_eq_mul, ENNReal.toReal_mul, ENNReal.toReal_inv, μ', measureReal_def] · simp [ENNReal.toReal_pos_iff, hν, measureReal_def] diff --git a/Mathlib/MeasureTheory/Measure/Decomposition/Lebesgue.lean b/Mathlib/MeasureTheory/Measure/Decomposition/Lebesgue.lean index c837b44cfe44ff..aeb22b3bca062a 100644 --- a/Mathlib/MeasureTheory/Measure/Decomposition/Lebesgue.lean +++ b/Mathlib/MeasureTheory/Measure/Decomposition/Lebesgue.lean @@ -456,7 +456,7 @@ theorem singularPart_smul_right (μ ν : Measure α) (r : ℝ≥0) (hr : r ≠ 0 smul_absolutelyContinuous · rw [ENNReal.smul_def r, withDensity_smul_measure, ← withDensity_smul] swap; · exact (measurable_rnDeriv _ _).const_smul _ - convert haveLebesgueDecomposition_add μ ν + convert! haveLebesgueDecomposition_add μ ν ext x simp only [Pi.smul_apply] rw [← ENNReal.smul_def, smul_inv_smul₀ hr] @@ -812,7 +812,7 @@ theorem iSup_mem_measurableLE (f : ℕ → α → ℝ≥0∞) (hf : ∀ n, f n theorem iSup_mem_measurableLE' (f : ℕ → α → ℝ≥0∞) (hf : ∀ n, f n ∈ measurableLE μ ν) (n : ℕ) : (⨆ (k) (_ : k ≤ n), f k) ∈ measurableLE μ ν := by - convert iSup_mem_measurableLE f hf n + convert! iSup_mem_measurableLE f hf n simp section SuprLemmas @@ -863,19 +863,19 @@ theorem haveLebesgueDecomposition_of_finiteMeasure [IsFiniteMeasure μ] [IsFinit fun n ↦ ?_ · rw [← hf₂ n] apply lintegral_mono - convert iSup_le_le f n n le_rfl + convert! iSup_le_le f n n le_rfl simp only [iSup_apply] · exact le_sSup ⟨⨆ (k : ℕ) (_ : k ≤ n), f k, iSup_mem_measurableLE' _ hf₁ _, rfl⟩ · intro n refine Measurable.aemeasurable ?_ - convert (iSup_mem_measurableLE _ hf₁ n).1 + convert! (iSup_mem_measurableLE _ hf₁ n).1 simp · refine Filter.Eventually.of_forall fun a ↦ ?_ simp [iSup_monotone' f _] · refine Filter.Eventually.of_forall fun a ↦ ?_ simp [tendsto_atTop_iSup (iSup_monotone' f a)] have hξm : Measurable ξ := by - convert Measurable.iSup fun n ↦ (iSup_mem_measurableLE _ hf₁ n).1 + convert! Measurable.iSup fun n ↦ (iSup_mem_measurableLE _ hf₁ n).1 simp [hξ] -- we see that `ξ` has the largest integral among all functions in `measurableLE` have hξle A (hA : MeasurableSet A) : ∫⁻ a in A, ξ a ∂ν ≤ μ A := by diff --git a/Mathlib/MeasureTheory/Measure/Dirac.lean b/Mathlib/MeasureTheory/Measure/Dirac.lean index cb243e9b08f88c..bf1e8ebe5f210a 100644 --- a/Mathlib/MeasureTheory/Measure/Dirac.lean +++ b/Mathlib/MeasureTheory/Measure/Dirac.lean @@ -161,9 +161,9 @@ lemma exists_sum_smul_dirac [Countable α] (μ : Measure α) : · simp only [Pi.one_apply, mul_one] congr 1 refine (measurableAtom_eq_of_mem ?_).symm - convert h_points_mem _ + convert! h_points_mem _ simp - · convert h_points_mem _ + · convert! h_points_mem _ simp · simp only [ne_eq, mul_eq_zero, indicator_apply_eq_zero, Pi.one_apply, one_ne_zero, imp_false, Subtype.forall, Set.mem_range, Subtype.exists, Subtype.mk.injEq, forall_exists_index] @@ -177,7 +177,7 @@ lemma exists_sum_smul_dirac [Countable α] (μ : Measure α) : simp only at h_points_mem rw [← hz, ← hsy] refine measurableAtom_eq_of_mem ?_ - convert h_points_mem + convert! h_points_mem rw [← h2, h1] /-- Given that `α` is a countable, measurable space with all singleton sets measurable, @@ -365,7 +365,7 @@ lemma ae_mem_finset_iff : (∀ᵐ a ∂μ, a ∈ s) ↔ μ = ∑ a ∈ s, μ {a} lemma ae_eq_or_eq_iff_eq_dirac_add_dirac (ha : a₁ ≠ a₂) : (∀ᵐ a ∂μ, a = a₁ ∨ a = a₂) ↔ μ = μ {a₁} • .dirac a₁ + μ {a₂} • .dirac a₂ := by -- FIXME: Why does `simpa using ...` not work? - convert ae_mem_finset_iff (s := .cons a₁ {a₂} <| by simpa) <;> simp + convert! ae_mem_finset_iff (s := .cons a₁ { a₂ } <| by simpa) <;> simp lemma ae_mem_finset_iff_map_eq_sum_dirac {μ : Measure β} (hf : AEMeasurable f μ) : (∀ᵐ b ∂μ, f b ∈ s) ↔ μ.map f = ∑ a ∈ s, μ (f ⁻¹' {a}) • .dirac a := by @@ -377,6 +377,6 @@ lemma ae_eq_or_eq_iff_map_eq_dirac_add_dirac {μ : Measure β} (hf : AEMeasurabl (∀ᵐ b ∂μ, f b = a₁ ∨ f b = a₂) ↔ μ.map f = μ (f ⁻¹' {a₁}) • .dirac a₁ + μ (f ⁻¹' {a₂}) • .dirac a₂ := by -- FIXME: Why does `simpa using ...` not work? - convert ae_mem_finset_iff_map_eq_sum_dirac (s := .cons a₁ {a₂} <| by simpa) hf <;> simp + convert! ae_mem_finset_iff_map_eq_sum_dirac (s := .cons a₁ { a₂ } <| by simpa) hf <;> simp end MeasureTheory.Measure diff --git a/Mathlib/MeasureTheory/Measure/DiracProba.lean b/Mathlib/MeasureTheory/Measure/DiracProba.lean index 34922400c30591..a2189b3c2f9972 100644 --- a/Mathlib/MeasureTheory/Measure/DiracProba.lean +++ b/Mathlib/MeasureTheory/Measure/DiracProba.lean @@ -150,7 +150,7 @@ lemma tendsto_diracProbaEquivSymm_iff_tendsto [T0Space X] [CompletelyRegularSpac rw [← (diracProbaEquiv (X := X)).symm_comp_self, ← tendsto_map'_iff] at key simp only [tendsto_map'_iff, map_map, Equiv.self_comp_symm, map_id] at key simp only [← key, diracProba_comp_diracProbaEquiv_symm_eq_val] - convert tendsto_subtype_rng.symm + convert! tendsto_subtype_rng.symm exact apply_rangeSplitting (fun x ↦ diracProba x) μ /-- In a T0 topological space, `diracProbaEquiv` is continuous. -/ diff --git a/Mathlib/MeasureTheory/Measure/Doubling.lean b/Mathlib/MeasureTheory/Measure/Doubling.lean index 06ca589f864dad..bf9d8c7e21a59c 100644 --- a/Mathlib/MeasureTheory/Measure/Doubling.lean +++ b/Mathlib/MeasureTheory/Measure/Doubling.lean @@ -123,7 +123,7 @@ theorem eventually_measure_le_scaling_constant_mul (K : ℝ) : theorem eventually_measure_le_scaling_constant_mul' (K : ℝ) (hK : 0 < K) : ∀ᶠ r in 𝓝[>] 0, ∀ x, μ (closedBall x r) ≤ scalingConstantOf μ K⁻¹ * μ (closedBall x (K * r)) := by - convert eventually_nhdsGT_zero_mul_left hK (eventually_measure_le_scaling_constant_mul μ K⁻¹) + convert! eventually_nhdsGT_zero_mul_left hK (eventually_measure_le_scaling_constant_mul μ K⁻¹) simp [inv_mul_cancel_left₀ hK.ne'] /-- A scale below which the doubling measure `μ` satisfies good rescaling properties when one diff --git a/Mathlib/MeasureTheory/Measure/EverywherePos.lean b/Mathlib/MeasureTheory/Measure/EverywherePos.lean index 4b4b2a71a0b422..b98ed1f0691845 100644 --- a/Mathlib/MeasureTheory/Measure/EverywherePos.lean +++ b/Mathlib/MeasureTheory/Measure/EverywherePos.lean @@ -295,7 +295,7 @@ theorem innerRegularWRT_preimage_one_hasCompactSupport_measure_ne_top_of_group : exists_continuous_one_zero_of_isCompact_of_isGδ L_comp L_Gδ isClosed_empty (disjoint_empty L) exact ⟨f, f_cont, f_comp, Lf⟩ - · convert hr using 1 + · convert! hr using 1 apply measure_congr exact everywherePosSubset_ae_eq_of_measure_ne_top K_closed.measurableSet K_comp.measure_lt_top.ne diff --git a/Mathlib/MeasureTheory/Measure/FiniteMeasure.lean b/Mathlib/MeasureTheory/Measure/FiniteMeasure.lean index de2ae8045dd2a6..d754a8f67e6cdb 100644 --- a/Mathlib/MeasureTheory/Measure/FiniteMeasure.lean +++ b/Mathlib/MeasureTheory/Measure/FiniteMeasure.lean @@ -565,7 +565,7 @@ theorem tendsto_zero_of_tendsto_zero_mass {γ : Type*} {F : Filter γ} {μs : γ (mass_lim : Tendsto (fun i ↦ (μs i).mass) F (𝓝 0)) : Tendsto μs F (𝓝 0) := by rw [tendsto_iff_forall_testAgainstNN_tendsto] intro f - convert tendsto_zero_testAgainstNN_of_tendsto_zero_mass mass_lim f + convert! tendsto_zero_testAgainstNN_of_tendsto_zero_mass mass_lim f rw [zero_testAgainstNN_apply] /-- A characterization of weak convergence in terms of integrals of bounded continuous @@ -775,7 +775,7 @@ instance : ContinuousAdd (FiniteMeasure Ω) := by (𝓝 (∫⁻ x, g x ∂p.2)) := by rw [nhds_prod_eq] exact (tendsto_iff_forall_lintegral_tendsto.1 tendsto_id g).comp tendsto_snd - convert A.add B with q <;> simp + convert! A.add B with q <;> simp instance : ContinuousSMul ℝ≥0 (FiniteMeasure Ω) := by refine ⟨continuous_iff_continuousAt.2 (fun p ↦ ?_)⟩ @@ -787,7 +787,7 @@ instance : ContinuousSMul ℝ≥0 (FiniteMeasure Ω) := by (𝓝 (∫ x, g x ∂p.2)) := by rw [nhds_prod_eq] exact (tendsto_iff_forall_integral_tendsto.1 tendsto_id g).comp tendsto_snd - convert A.smul B with q <;> simp + convert! A.smul B with q <;> simp variable {X : Type*} [TopologicalSpace X] {μs : X → FiniteMeasure Ω} @@ -960,7 +960,7 @@ lemma tendsto_map_of_tendsto_of_continuous {ι : Type*} {L : Filter ι} Tendsto (fun i ↦ (νs i).map f) L (𝓝 (ν.map f)) := by rw [FiniteMeasure.tendsto_iff_forall_lintegral_tendsto] at lim ⊢ intro g - convert lim (g.compContinuous ⟨f, f_cont⟩) <;> + convert! lim (g.compContinuous ⟨f, f_cont⟩) <;> · simp only [map, compContinuous_apply, ContinuousMap.coe_mk] refine lintegral_map ?_ f_cont.measurable exact (ENNReal.continuous_coe.comp g.continuous).measurable diff --git a/Mathlib/MeasureTheory/Measure/Haar/Basic.lean b/Mathlib/MeasureTheory/Measure/Haar/Basic.lean index 00cfba26cd54c9..51ac4de88e7806 100644 --- a/Mathlib/MeasureTheory/Measure/Haar/Basic.lean +++ b/Mathlib/MeasureTheory/Measure/Haar/Basic.lean @@ -180,7 +180,7 @@ theorem index_pos (K : PositiveCompacts G) {V : Set G} (hV : (interior V).Nonemp · rintro ⟨t, h1t, h2t⟩; rw [Finset.card_eq_zero] at h2t; subst h2t obtain ⟨g, hg⟩ := K.interior_nonempty change g ∈ (∅ : Set G) - convert h1t (interior_subset hg); symm + convert! h1t (interior_subset hg); symm simp only [Finset.notMem_empty, iUnion_of_empty, iUnion_empty] · exact index_defined K.isCompact hV @@ -252,7 +252,7 @@ theorem mul_left_index_le {K : Set G} (hK : IsCompact K) {V : Set G} (hV : (inte theorem is_left_invariant_index {K : Set G} (hK : IsCompact K) (g : G) {V : Set G} (hV : (interior V).Nonempty) : index ((fun h => g * h) '' K) V = index K V := by refine le_antisymm (mul_left_index_le hK hV g) ?_ - convert mul_left_index_le (hK.image <| continuous_const_mul g) hV g⁻¹ + convert! mul_left_index_le (hK.image <| continuous_const_mul g) hV g⁻¹ rw [image_image] simp diff --git a/Mathlib/MeasureTheory/Measure/Haar/InnerProductSpace.lean b/Mathlib/MeasureTheory/Measure/Haar/InnerProductSpace.lean index e3d00126766a35..ded8c0bfb1516a 100644 --- a/Mathlib/MeasureTheory/Measure/Haar/InnerProductSpace.lean +++ b/Mathlib/MeasureTheory/Measure/Haar/InnerProductSpace.lean @@ -103,7 +103,7 @@ noncomputable def OrthonormalBasis.measurableEquiv (b : OrthonormalBasis ι ℝ /-- The measurable equivalence defined by an orthonormal basis is volume preserving. -/ theorem OrthonormalBasis.measurePreserving_measurableEquiv (b : OrthonormalBasis ι ℝ F) : MeasurePreserving b.measurableEquiv volume volume := by - convert (b.measurableEquiv.symm.measurable.measurePreserving _).symm + convert! (b.measurableEquiv.symm.measurable.measurePreserving _).symm rw [← (EuclideanSpace.basisFun ι ℝ).addHaar_eq_volume] erw [MeasurableEquiv.coe_toEquiv_symm, Basis.map_addHaar _ b.repr.symm.toContinuousLinearEquiv] exact b.addHaar_eq_volume.symm @@ -124,7 +124,7 @@ variable [Fintype ι] theorem EuclideanSpace.volume_preserving_symm_measurableEquiv_toLp : MeasurePreserving (MeasurableEquiv.toLp 2 (ι → ℝ)).symm := by suffices volume = map (MeasurableEquiv.toLp 2 (ι → ℝ)) volume by - convert ((MeasurableEquiv.toLp 2 (ι → ℝ)).measurable.measurePreserving _).symm + convert! ((MeasurableEquiv.toLp 2 (ι → ℝ)).measurable.measurePreserving _).symm rw [← addHaarMeasure_eq_volume_pi, ← Basis.parallelepiped_basisFun, ← Basis.addHaar_def, MeasurableEquiv.coe_toLp, ← PiLp.coe_symm_continuousLinearEquiv 2 ℝ, Basis.map_addHaar] exact (EuclideanSpace.basisFun _ _).addHaar_eq_volume.symm @@ -189,7 +189,7 @@ private noncomputable def volumePreservingSymmMeasurableEquivToLpProdAux : theorem WithLp.volume_preserving_symm_measurableEquiv_toLp_prod : MeasurePreserving (MeasurableEquiv.toLp 2 (U × V)).symm := by suffices MeasurePreserving (volumePreservingSymmMeasurableEquivToLpProdAux U V) by - convert this + convert! this ext uv <;> simp [volumePreservingSymmMeasurableEquivToLpProdAux, MeasurableEquiv.coe_sumPiEquivProdPi, LinearEquiv.prodCongr_symm, MeasurableEquiv.prodCongr] @@ -224,7 +224,7 @@ theorem MeasureTheory.volume_eq_of_finrank_eq_one (h : Module.finrank ℝ E = 1) let f : ℝ ≃ₗᵢ[ℝ] E := (LinearIsometryEquiv.toSpanUnitSingleton (‖v‖⁻¹ • v) (by simp [norm_smul, hv])).trans (LinearIsometryEquiv.ofTop E _ hv') rw [map_map (by fun_prop) (by fun_prop)] - convert f.measurePreserving.map_eq.symm + convert! f.measurePreserving.map_eq.symm ext x simp [f, mul_comm, smul_smul] _ = ‖v‖ₑ • (volume : Measure ℝ).map (· • v) := by diff --git a/Mathlib/MeasureTheory/Measure/Haar/NormedSpace.lean b/Mathlib/MeasureTheory/Measure/Haar/NormedSpace.lean index 164f7466ddbba5..c954fefea00122 100644 --- a/Mathlib/MeasureTheory/Measure/Haar/NormedSpace.lean +++ b/Mathlib/MeasureTheory/Measure/Haar/NormedSpace.lean @@ -178,7 +178,7 @@ theorem integrable_comp_smul_iff {E : Type*} [NormedAddCommGroup E] [NormedSpace suffices ∀ {g : E → F} (_ : Integrable g μ) {S : ℝ} (_ : S ≠ 0), Integrable (fun x => g (S • x)) μ by refine ⟨fun hf => ?_, fun hf => this hf hR⟩ - convert this hf (inv_ne_zero hR) + convert! this hf (inv_ne_zero hR) rw [← mul_smul, mul_inv_cancel₀ hR, one_smul] -- now prove intro g hg S hS diff --git a/Mathlib/MeasureTheory/Measure/Haar/OfBasis.lean b/Mathlib/MeasureTheory/Measure/Haar/OfBasis.lean index 9913bc5efcf083..7d99663857af69 100644 --- a/Mathlib/MeasureTheory/Measure/Haar/OfBasis.lean +++ b/Mathlib/MeasureTheory/Measure/Haar/OfBasis.lean @@ -99,7 +99,7 @@ theorem parallelepiped_orthonormalBasis_one_dim (b : OrthonormalBasis ι ℝ ℝ apply Fintype.equivFinOfCardEq simp only [← finrank_eq_card_basis b.toBasis, finrank_self] have B : parallelepiped (b.reindex e) = parallelepiped b := by - convert parallelepiped_comp_equiv b e.symm + convert! parallelepiped_comp_equiv b e.symm ext i simp only [OrthonormalBasis.coe_reindex] rw [← B] @@ -191,7 +191,7 @@ def parallelepiped (b : Basis ι ℝ E) : PositiveCompacts E where interior_nonempty' := by suffices H : Set.Nonempty (interior (b.equivFunL.symm.toHomeomorph '' Icc 0 1)) by dsimp only [_root_.parallelepiped] - convert H + convert! H exact (b.equivFun_symm_apply _).symm have A : Set.Nonempty (interior (Icc (0 : ι → ℝ) 1)) := by rw [← pi_univ_Icc, interior_pi_set (@finite_univ ι _)] diff --git a/Mathlib/MeasureTheory/Measure/Haar/Quotient.lean b/Mathlib/MeasureTheory/Measure/Haar/Quotient.lean index 32894df84231ee..3d3fd8c253abcf 100644 --- a/Mathlib/MeasureTheory/Measure/Haar/Quotient.lean +++ b/Mathlib/MeasureTheory/Measure/Haar/Quotient.lean @@ -133,7 +133,7 @@ lemma MeasureTheory.QuotientMeasureEqMeasurePreimage.mulInvariantMeasure_quotien map_mul_left_eq_self x := by ext A hA obtain ⟨x₁, h⟩ := @Quotient.exists_rep _ (QuotientGroup.leftRel Γ) x - convert measure_preimage_smul μ x₁ A using 1 + convert! measure_preimage_smul μ x₁ A using 1 · rw [← h, Measure.map_apply (measurable_const_mul _) hA] simp [← MulAction.Quotient.coe_smul_out, ← Quotient.mk''_eq_mk] exact smulInvariantMeasure_quotient ν @@ -175,7 +175,7 @@ theorem MeasureTheory.Measure.IsMulLeftInvariant.quotientMeasureEqMeasurePreimag symm suffices (μ' V / ν (QuotientGroup.mk ⁻¹' V ∩ s)) = 1 by rw [this, one_smul] rw [Measure.map_apply meas_π meas_V, Measure.restrict_apply] - · convert ENNReal.div_self .. + · convert! ENNReal.div_self .. · exact trans hV.symm neZeroV · exact trans hV.symm neTopV exact measurableSet_quotient.mp meas_V @@ -192,7 +192,7 @@ theorem MeasureTheory.leftInvariantIsQuotientMeasureEqMeasurePreimage [IsFiniteM have finiteCovol : μ univ < ⊤ := measure_lt_top μ univ rw [fund_dom_s.covolume_eq_volume] at h by_cases meas_s_ne_zero : ν s = 0 - · convert fund_dom_s.quotientMeasureEqMeasurePreimage_of_zero meas_s_ne_zero + · convert! fund_dom_s.quotientMeasureEqMeasurePreimage_of_zero meas_s_ne_zero rw [← @measure_univ_eq_zero, ← h, meas_s_ne_zero] apply IsMulLeftInvariant.quotientMeasureEqMeasurePreimage_of_set (fund_dom_s := fund_dom_s) (meas_V := MeasurableSet.univ) @@ -201,7 +201,7 @@ theorem MeasureTheory.leftInvariantIsQuotientMeasureEqMeasurePreimage [IsFiniteM · rw [← h] simp · rw [← h] - convert finiteCovol.ne + convert! finiteCovol.ne end mulInvariantMeasure @@ -364,7 +364,7 @@ lemma _root_.MeasureTheory.IsFundamentalDomain.absolutelyContinuous_map ext g rw [Set.mem_smul_set_iff_inv_smul_mem, mem_preimage, mem_preimage] congr! 1 - convert QuotientGroup.mk_mul_of_mem g (γ⁻¹).2 using 1 + convert! QuotientGroup.mk_mul_of_mem g (γ⁻¹).2 using 1 exact MeasurableSet.preimage s_meas meas_π attribute [-instance] Quotient.instMeasurableSpace diff --git a/Mathlib/MeasureTheory/Measure/Haar/Unique.lean b/Mathlib/MeasureTheory/Measure/Haar/Unique.lean index 10afcab099b9c8..f4c3ac89204cbb 100644 --- a/Mathlib/MeasureTheory/Measure/Haar/Unique.lean +++ b/Mathlib/MeasureTheory/Measure/Haar/Unique.lean @@ -505,7 +505,7 @@ lemma measure_preimage_isMulLeftInvariant_eq_smul_of_hasCompactSupport have T := tendsto_pi_nhds.1 (thickenedIndicator_tendsto_indicator_closure (fun n ↦ (u_mem n).1) u_lim ({1} : Set ℝ)) (f x) simp only [thickenedIndicator_apply, closure_singleton] at T - convert NNReal.tendsto_coe.2 T + convert! NNReal.tendsto_coe.2 T simp have M n : ∫ (x : G), v n (f x) ∂μ' = ∫ (x : G), v n (f x) ∂(haarScalarFactor μ' μ • μ) := by apply integral_isMulLeftInvariant_eq_smul_of_hasCompactSupport μ' μ (vf_cont n) @@ -556,7 +556,7 @@ lemma smul_measure_isMulInvariant_le_of_isCompact_closure [LocallyCompactSpace G obtain ⟨-, hf, ⟨f, f_cont, f_comp, rfl⟩, νf⟩ : ∃ K ⊆ s, (∃ f, Continuous f ∧ HasCompactSupport f ∧ K = f ⁻¹' {1}) ∧ r < ν K := innerRegularWRT_preimage_one_hasCompactSupport_measure_ne_top_of_group ⟨hs, this⟩ r - (by convert hr) + (by convert! hr) calc r < ν (f ⁻¹' {1}) := νf _ = μ' (f ⁻¹' {1}) := @@ -885,8 +885,7 @@ Given two left-invariant measures which are finite on compacts and regular, they coincide up to a multiplicative constant. -/ @[to_additive isAddLeftInvariant_eq_smul_of_regular] lemma isMulLeftInvariant_eq_smul_of_regular [LocallyCompactSpace G] - (μ' μ : Measure G) [IsHaarMeasure μ] [IsFiniteMeasureOnCompacts μ'] [IsMulLeftInvariant μ'] - [Regular μ] [Regular μ'] : + (μ' μ : Measure G) [IsHaarMeasure μ] [IsMulLeftInvariant μ'] [Regular μ] [Regular μ'] : μ' = haarScalarFactor μ' μ • μ := by have A : ∀ U, IsOpen U → μ' U = (haarScalarFactor μ' μ • μ) U := by intro U hU diff --git a/Mathlib/MeasureTheory/Measure/HasOuterApproxClosed.lean b/Mathlib/MeasureTheory/Measure/HasOuterApproxClosed.lean index b65527be4250b1..0f8e45df09884c 100644 --- a/Mathlib/MeasureTheory/Measure/HasOuterApproxClosed.lean +++ b/Mathlib/MeasureTheory/Measure/HasOuterApproxClosed.lean @@ -81,7 +81,7 @@ theorem measure_of_cont_bdd_of_tendsto_filter_indicator {ι : Type*} {L : Filter (fs_bdd : ∀ᶠ i in L, ∀ᵐ ω : Ω ∂μ, fs i ω ≤ c) (fs_lim : ∀ᵐ ω ∂μ, Tendsto (fun i ↦ fs i ω) L (𝓝 (indicator E (fun _ ↦ (1 : ℝ≥0)) ω))) : Tendsto (fun n ↦ lintegral μ fun ω ↦ fs n ω) L (𝓝 (μ E)) := by - convert tendsto_lintegral_nn_filter_of_le_const μ fs_bdd fs_lim + convert! tendsto_lintegral_nn_filter_of_le_const μ fs_bdd fs_lim have aux : ∀ ω, indicator E (fun _ ↦ (1 : ℝ≥0∞)) ω = ↑(indicator E (fun _ ↦ (1 : ℝ≥0)) ω) := fun ω ↦ by simp only [ENNReal.coe_indicator, ENNReal.coe_one] simp_rw [← aux, lintegral_indicator E_mble] diff --git a/Mathlib/MeasureTheory/Measure/HasOuterApproxClosedProd.lean b/Mathlib/MeasureTheory/Measure/HasOuterApproxClosedProd.lean index 18e0aca5126b8e..cd69af236c79ac 100644 --- a/Mathlib/MeasureTheory/Measure/HasOuterApproxClosedProd.lean +++ b/Mathlib/MeasureTheory/Measure/HasOuterApproxClosedProd.lean @@ -81,7 +81,7 @@ lemma ext_of_lintegral_prod_mul_prod_boundedContinuousFunction ∫⁻ p, (∏ i, f i (p.1 i)) * ∏ j, g j (p.2 j) ∂μ = ∫⁻ p, (∏ i, f i (p.1 i)) * ∏ j, g j (p.2 j) ∂ν) : μ = ν := by - have hμν : μ univ = ν univ := by convert h 1 1 <;> simp + have hμν : μ univ = ν univ := by convert! h 1 1 <;> simp have : IsFiniteMeasure ν := ⟨by simp [← hμν]⟩ let π : Set (Set ((Π i, X i) × (Π j, Y j))) := Set.image2 (fun s t ↦ s ×ˢ t) (Set.univ.pi '' (Set.univ.pi fun _ ↦ {s | IsClosed s})) @@ -150,7 +150,7 @@ lemma ext_of_lintegral_prod_mul_prod_boundedContinuousFunction · simp · exact fun j _ ↦ HasOuterApproxClosed.apprSeq_apply_le_one (ht j) _ _ · exact fun i _ ↦ HasOuterApproxClosed.apprSeq_apply_le_one (hs i) _ _ - convert tendsto_nhds_unique h1 h2 <;> + convert! tendsto_nhds_unique h1 h2 <;> simp [(MeasurableSet.univ_pi (fun i ↦ (hs i).measurableSet)).prod (.univ_pi (fun j ↦ (ht j).measurableSet))] @@ -180,13 +180,15 @@ lemma ext_of_integral_prod_mul_prod_boundedContinuousFunction simp_rw [this] exact h (fun i ↦ ⟨⟨fun x ↦ (f i x), by fun_prop⟩, (f i).map_bounded'⟩) (fun j ↦ ⟨⟨fun y ↦ (g j y), by fun_prop⟩, (g j).map_bounded'⟩) - · convert (lintegral_lt_top_of_nnreal μ - ((∏ i, (f i).compContinuous ⟨Function.eval i ∘ Prod.fst, by fun_prop⟩) * - (∏ j, (g j).compContinuous ⟨Function.eval j ∘ Prod.snd, by fun_prop⟩))).ne + · convert! + (lintegral_lt_top_of_nnreal μ + ((∏ i, (f i).compContinuous ⟨Function.eval i ∘ Prod.fst, by fun_prop⟩) * + (∏ j, (g j).compContinuous ⟨Function.eval j ∘ Prod.snd, by fun_prop⟩))).ne simp - · convert (lintegral_lt_top_of_nnreal ν - ((∏ i, (f i).compContinuous ⟨Function.eval i ∘ Prod.fst, by fun_prop⟩) * - (∏ j, (g j).compContinuous ⟨Function.eval j ∘ Prod.snd, by fun_prop⟩))).ne + · convert! + (lintegral_lt_top_of_nnreal ν + ((∏ i, (f i).compContinuous ⟨Function.eval i ∘ Prod.fst, by fun_prop⟩) * + (∏ j, (g j).compContinuous ⟨Function.eval j ∘ Prod.snd, by fun_prop⟩))).ne simp /-- The product of two finite measures `μ` and `ν` is the only finite measure `ξ` such that @@ -282,8 +284,9 @@ lemma ext_of_integral_prod_mul_prod_boundedContinuousFunction' μ = ν := by have := Fintype.ofFinite ι; have := Fintype.ofFinite κ refine ext_of_integral_prod_mul_prod_boundedContinuousFunction fun f g ↦ ?_ - convert h (∏ i, (f i).compContinuous ⟨Function.eval i, by fun_prop⟩) - (∏ j, (g j).compContinuous ⟨Function.eval j, by fun_prop⟩) <;> simp + convert! + h (∏ i, (f i).compContinuous ⟨Function.eval i, by fun_prop⟩) + (∏ j, (g j).compContinuous ⟨Function.eval j, by fun_prop⟩) <;> simp lemma eq_prod_of_integral_prod_mul_prod_boundedContinuousFunction' {μ : Measure (Π i, X i)} {ν : Measure (Π j, Y j)} {ξ : Measure ((Π i, X i) × (Π j, Y j))} @@ -300,7 +303,7 @@ lemma ext_of_integral_prod_mul_boundedContinuousFunction' {μ ν : Measure ((Π μ = ν := by have := Fintype.ofFinite ι refine ext_of_integral_prod_mul_boundedContinuousFunction fun f g ↦ ?_ - convert h (∏ i, (f i).compContinuous ⟨Function.eval i, by fun_prop⟩) g <;> simp + convert! h (∏ i, (f i).compContinuous ⟨Function.eval i, by fun_prop⟩) g <;> simp lemma eq_prod_of_integral_prod_mul_boundedContinuousFunction' {μ : Measure (Π i, X i)} {ν : Measure T} {ξ : Measure ((Π i, X i) × T)} @@ -316,7 +319,7 @@ lemma ext_of_integral_mul_prod_boundedContinuousFunction' {μ ν : Measure (Z × μ = ν := by have := Fintype.ofFinite κ refine ext_of_integral_mul_prod_boundedContinuousFunction fun f g ↦ ?_ - convert h f (∏ j, (g j).compContinuous ⟨Function.eval j, by fun_prop⟩) <;> simp + convert! h f (∏ j, (g j).compContinuous ⟨Function.eval j, by fun_prop⟩) <;> simp lemma eq_prod_of_integral_mul_prod_boundedContinuousFunction' {μ : Measure Z} {ν : Measure (Π j, Y j)} {ξ : Measure (Z × (Π j, Y j))} diff --git a/Mathlib/MeasureTheory/Measure/Hausdorff.lean b/Mathlib/MeasureTheory/Measure/Hausdorff.lean index a11ef8c5fd104f..68c834bf0221d7 100644 --- a/Mathlib/MeasureTheory/Measure/Hausdorff.lean +++ b/Mathlib/MeasureTheory/Measure/Hausdorff.lean @@ -347,7 +347,7 @@ theorem mkMetric_top : (mkMetric (fun _ => ∞ : ℝ≥0∞ → ℝ≥0∞) : Ou `mkMetric m₁ hm₁ ≤ mkMetric m₂ hm₂`. -/ theorem mkMetric_mono {m₁ m₂ : ℝ≥0∞ → ℝ≥0∞} (hle : m₁ ≤ᶠ[𝓝[≥] 0] m₂) : (mkMetric m₁ : OuterMeasure X) ≤ mkMetric m₂ := by - convert @mkMetric_mono_smul X _ _ m₂ _ ENNReal.one_ne_top one_ne_zero _ <;> simp [*] + convert! @mkMetric_mono_smul X _ _ m₂ _ ENNReal.one_ne_top one_ne_zero _ <;> simp [*] theorem isometry_comap_mkMetric (m : ℝ≥0∞ → ℝ≥0∞) {f : X → Y} (hf : Isometry f) (H : Monotone m ∨ Surjective f) : comap f (mkMetric m) = mkMetric m := by @@ -459,7 +459,7 @@ theorem mkMetric_top : (mkMetric (fun _ => ∞ : ℝ≥0∞ → ℝ≥0∞) : Me `mkMetric m₁ hm₁ ≤ mkMetric m₂ hm₂`. -/ theorem mkMetric_mono {m₁ m₂ : ℝ≥0∞ → ℝ≥0∞} (hle : m₁ ≤ᶠ[𝓝[≥] 0] m₂) : (mkMetric m₁ : Measure X) ≤ mkMetric m₂ := by - convert @mkMetric_mono_smul X _ _ _ _ m₂ _ ENNReal.one_ne_top one_ne_zero _ <;> simp [*] + convert! @mkMetric_mono_smul X _ _ _ _ m₂ _ ENNReal.one_ne_top one_ne_zero _ <;> simp [*] /-- A formula for `MeasureTheory.Measure.mkMetric`. -/ theorem mkMetric_apply (m : ℝ≥0∞ → ℝ≥0∞) (s : Set X) : @@ -624,7 +624,7 @@ theorem hausdorffMeasure_zero_singleton (x : X) : μH[0] ({x} : Set X) = 1 := by ⨅ (t : ℕ → Set X) (_ : {x} ⊆ ⋃ n, t n) (_ : ∀ n, ediam (t n) ≤ 1), ∑' n, ⨆ _ : (t n).Nonempty, ediam (t n) ^ (0 : ℝ) by apply le_trans this _ - convert le_iSup₂ (α := ℝ≥0∞) (1 : ℝ≥0∞) zero_lt_one + convert! le_iSup₂ (α := ℝ≥0∞) (1 : ℝ≥0∞) zero_lt_one rfl simp only [ENNReal.rpow_zero, le_iInf_iff] intro t hst _ diff --git a/Mathlib/MeasureTheory/Measure/IntegralCharFun.lean b/Mathlib/MeasureTheory/Measure/IntegralCharFun.lean index 0054b5b030e455..3bd1c948d35cb9 100644 --- a/Mathlib/MeasureTheory/Measure/IntegralCharFun.lean +++ b/Mathlib/MeasureTheory/Measure/IntegralCharFun.lean @@ -153,7 +153,7 @@ lemma measureReal_abs_dual_gt_le_integral_charFunDual {E : Type*} [NormedAddComm {μ : Measure E} [IsProbabilityMeasure μ] (L : StrongDual ℝ E) {r : ℝ} (hr : 0 < r) : μ.real {x | r < |L x|} ≤ 2⁻¹ * r * ‖∫ t in -2 * r⁻¹..2 * r⁻¹, 1 - charFunDual μ (t • L)‖ := by have : IsProbabilityMeasure (μ.map L) := Measure.isProbabilityMeasure_map (by fun_prop) - convert measureReal_abs_gt_le_integral_charFun (μ := μ.map L) hr with x + convert! measureReal_abs_gt_le_integral_charFun (μ := μ.map L) hr with x · rw [map_measureReal_apply (by fun_prop)] · simp · exact MeasurableSet.preimage measurableSet_Ioi (by fun_prop) @@ -167,7 +167,7 @@ lemma measureReal_abs_inner_gt_le_integral_charFun {E : Type*} [SeminormedAddCom μ.real {x | r < |⟪a, x⟫|} ≤ 2⁻¹ * r * ‖∫ t in -2 * r⁻¹..2 * r⁻¹, 1 - charFun μ (t • a)‖ := by have : IsProbabilityMeasure (μ.map (fun x ↦ ⟪a, x⟫)) := Measure.isProbabilityMeasure_map (by fun_prop) - convert measureReal_abs_gt_le_integral_charFun (μ := μ.map (fun x ↦ ⟪a, x⟫)) hr with x + convert! measureReal_abs_gt_le_integral_charFun (μ := μ.map (fun x ↦ ⟪a, x⟫)) hr with x · rw [map_measureReal_apply (by fun_prop)] · simp · exact MeasurableSet.preimage measurableSet_Ioi (by fun_prop) diff --git a/Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean b/Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean index eb313f7840861e..2dc9ea038c1f84 100644 --- a/Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean +++ b/Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean @@ -547,7 +547,7 @@ theorem volume_regionBetween_eq_lintegral [SFinite μ] (hf : AEMeasurable f (μ. (EventuallyEq.rfl.comp₂ _ <| quasiMeasurePreserving_fst.ae_eq_comp hg.ae_eq_mk) rw [lintegral_congr_ae h₁, ← volume_regionBetween_eq_lintegral' hf.measurable_mk hg.measurable_mk hs] - convert h₂ using 1 + convert! h₂ using 1 · rw [Measure.restrict_prod_eq_prod_univ] exact (Measure.restrict_eq_self _ (regionBetween_subset f g s)).symm · rw [Measure.restrict_prod_eq_prod_univ] diff --git a/Mathlib/MeasureTheory/Measure/Lebesgue/Complex.lean b/Mathlib/MeasureTheory/Measure/Lebesgue/Complex.lean index d1b0929c2746cd..318dd706e70c28 100644 --- a/Mathlib/MeasureTheory/Measure/Lebesgue/Complex.lean +++ b/Mathlib/MeasureTheory/Measure/Lebesgue/Complex.lean @@ -51,7 +51,7 @@ theorem measurableEquivRealProd_symm_apply (p : ℝ × ℝ) : measurableEquivRealProd.symm p = { re := p.1, im := p.2 } := rfl theorem volume_preserving_equiv_pi : MeasurePreserving measurableEquivPi := by - convert (measurableEquivPi.symm.measurable.measurePreserving volume).symm + convert! (measurableEquivPi.symm.measurable.measurePreserving volume).symm rw [← addHaarMeasure_eq_volume_pi, ← Basis.parallelepiped_basisFun, ← Basis.addHaar, measurableEquivPi, Homeomorph.toMeasurableEquiv_symm_coe, ContinuousLinearEquiv.coe_symm_toHomeomorph, Basis.map_addHaar, eq_comm] diff --git a/Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean b/Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean index 5f07bfb9acf284..e15b507c8f573c 100644 --- a/Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean +++ b/Mathlib/MeasureTheory/Measure/Lebesgue/EqHaar.lean @@ -78,7 +78,7 @@ theorem parallelepiped_basisFun (ι : Type*) [Fintype ι] : (Pi.basisFun ℝ ι).parallelepiped = TopologicalSpace.PositiveCompacts.piIcc01 ι := SetLike.coe_injective <| by refine Eq.trans ?_ ((uIcc_of_le ?_).trans (Set.pi_univ_Icc _ _).symm) - · classical convert parallelepiped_single (ι := ι) 1 + · classical convert! parallelepiped_single (ι := ι) 1 · exact zero_le_one /-- A parallelepiped can be expressed on the standard basis. -/ @@ -114,12 +114,12 @@ open Measure TopologicalSpace.PositiveCompacts Module /-- The Haar measure equals the Lebesgue measure on `ℝ`. -/ theorem addHaarMeasure_eq_volume : addHaarMeasure Icc01 = volume := by - convert (addHaarMeasure_unique volume Icc01).symm; simp [Icc01] + convert! (addHaarMeasure_unique volume Icc01).symm; simp [Icc01] /-- The Haar measure equals the Lebesgue measure on `ℝ^ι`. -/ theorem addHaarMeasure_eq_volume_pi (ι : Type*) [Fintype ι] : addHaarMeasure (piIcc01 ι) = volume := by - convert (addHaarMeasure_unique volume (piIcc01 ι)).symm + convert! (addHaarMeasure_unique volume (piIcc01 ι)).symm simp only [piIcc01, volume_pi_pi fun _ => Icc (0 : ℝ) 1, PositiveCompacts.coe_mk, Compacts.coe_mk, Finset.prod_const_one, ENNReal.ofReal_one, Real.volume_Icc, one_smul, sub_zero] @@ -189,12 +189,12 @@ theorem addHaar_submodule {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] SetLike.mem_coe] intro y hym hyn have A : (c ^ n - c ^ m) • x ∈ s := by - convert s.sub_mem hym hyn using 1 + convert! s.sub_mem hym hyn using 1 simp only [sub_smul, neg_sub_neg, add_sub_add_right_eq_sub] have H : c ^ n - c ^ m ≠ 0 := by simpa only [sub_eq_zero, Ne] using (pow_right_strictAnti₀ cpos cone).injective.ne hmn.symm have : x ∈ s := by - convert s.smul_mem (c ^ n - c ^ m)⁻¹ A + convert! s.smul_mem (c ^ n - c ^ m)⁻¹ A rw [smul_smul, inv_mul_cancel₀ H, one_smul] exact hx this @@ -284,7 +284,7 @@ equal to `μ s` times the absolute value of the inverse of the determinant of `f theorem addHaar_preimage_linearEquiv (f : E ≃ₗ[ℝ] E) (s : Set E) : μ (f ⁻¹' s) = ENNReal.ofReal |LinearMap.det (f.symm : E →ₗ[ℝ] E)| * μ s := by have A : LinearMap.det (f : E →ₗ[ℝ] E) ≠ 0 := (LinearEquiv.isUnit_det' f).ne_zero - convert addHaar_preimage_linearMap μ A s + convert! addHaar_preimage_linearMap μ A s simp only [LinearEquiv.det_coe_symm] /-- The preimage of a set `s` under a continuous linear equiv `f` has measure @@ -783,8 +783,9 @@ theorem tendsto_addHaar_inter_smul_one_of_density_one_aux (s : Set E) (hs : Meas apply B.congr' _ filter_upwards [self_mem_nhdsWithin] rintro r (rpos : 0 < r) - convert I (closedBall x r) sᶜ (measure_closedBall_pos μ _ rpos).ne' - measure_closedBall_lt_top.ne hs.compl + convert! + I (closedBall x r) sᶜ (measure_closedBall_pos μ _ rpos).ne' measure_closedBall_lt_top.ne + hs.compl rw [compl_compl] have L' : Tendsto (fun r : ℝ => μ (sᶜ ∩ ({x} + r • t)) / μ ({x} + r • t)) (𝓝[>] 0) (𝓝 0) := tendsto_addHaar_inter_smul_zero_of_density_zero μ sᶜ x L t ht h''t diff --git a/Mathlib/MeasureTheory/Measure/Lebesgue/VolumeOfBalls.lean b/Mathlib/MeasureTheory/Measure/Lebesgue/VolumeOfBalls.lean index 09c30c53a7e780..81fef1f10b6d72 100644 --- a/Mathlib/MeasureTheory/Measure/Lebesgue/VolumeOfBalls.lean +++ b/Mathlib/MeasureTheory/Measure/Lebesgue/VolumeOfBalls.lean @@ -94,7 +94,7 @@ theorem MeasureTheory.measure_lt_one_eq_integral_div_gamma {p : ℝ} (hp : 0 < p -- The measure `ν` is the measure on `F` defined by `μ` -- Since we have two different topologies, it is necessary to specify the topology of E let ν : Measure F := @Measure.map E F mE _ φ μ - convert (measure_unitBall_eq_integral_div_gamma ν hp) using 1 + convert! (measure_unitBall_eq_integral_div_gamma ν hp) using 1 · rw [@Measure.map_apply E F mE _ μ φ _ _ measurableSet_ball] · congr! simp_rw [Metric.ball, dist_zero_right] @@ -127,7 +127,7 @@ theorem MeasureTheory.measure_le_eq_lt [Nontrivial E] (r : ℝ) : -- The measure `ν` is the measure on `F` defined by `μ` -- Since we have two different topologies, it is necessary to specify the topology of E let ν : Measure F := @Measure.map E F mE _ φ μ - convert addHaar_closedBall_eq_addHaar_ball ν 0 r using 1 + convert! addHaar_closedBall_eq_addHaar_ball ν 0 r using 1 · rw [@Measure.map_apply E F mE _ μ φ _ _ measurableSet_closedBall] · congr! simp_rw [Metric.closedBall, dist_zero_right] @@ -171,9 +171,10 @@ theorem MeasureTheory.volume_sum_rpow_lt_one (hp : 1 ≤ p) : simp_rw [← toLp_neg, ← toLp_add, ← toLp_smul, eq_norm, norm_eq_abs] at eq_zero nm_zero nm_neg nm_add nm_smul -- We use `measure_lt_one_eq_integral_div_gamma` with `g` equals to the norm `L_p` - convert (measure_lt_one_eq_integral_div_gamma (volume : Measure (ι → ℝ)) - (g := fun x => (∑ i, |x i| ^ p) ^ (1 / p)) nm_zero nm_neg nm_add (eq_zero _).mp - (fun r x => nm_smul r x) (by linarith : 0 < p)) using 4 + convert! + (measure_lt_one_eq_integral_div_gamma (volume : Measure (ι → ℝ)) (g := fun x => + (∑ i, |x i| ^ p) ^ (1 / p)) nm_zero nm_neg nm_add (eq_zero _).mp (fun r x => nm_smul r x) + (by linarith : 0 < p)) using 4 · rw [rpow_lt_one_iff' _ (one_div_pos.mpr h₁)] exact Finset.sum_nonneg' (fun _ => rpow_nonneg (abs_nonneg _) _) · simp_rw [← rpow_mul (h₂ _), div_mul_cancel₀ _ (ne_of_gt h₁), Real.rpow_one, @@ -194,7 +195,7 @@ theorem MeasureTheory.volume_sum_rpow_lt [Nonempty ι] {p : ℝ} (hp : 1 ≤ p) exact not_le.mpr (lt_of_lt_of_le (Set.mem_setOf.mp hx) hr) (h₂ x) rw [this, measure_empty, ← zero_eq_ofReal.mpr hr, zero_pow Fin.pos'.ne', zero_mul] · rw [← volume_sum_rpow_lt_one _ hp, ← ofReal_pow (le_of_lt hr), ← finrank_pi ℝ] - convert addHaar_smul_of_nonneg volume (le_of_lt hr) {x : ι → ℝ | ∑ i, |x i| ^ p < 1} using 2 + convert! addHaar_smul_of_nonneg volume (le_of_lt hr) {x : ι → ℝ | ∑ i, |x i| ^ p < 1} using 2 simp_rw [← Set.preimage_smul_inv₀ (ne_of_gt hr), Set.preimage_setOf_eq, Pi.smul_apply, smul_eq_mul, abs_mul, mul_rpow (abs_nonneg _) (abs_nonneg _), abs_inv, inv_rpow (abs_nonneg _), ← Finset.mul_sum, abs_eq_self.mpr (le_of_lt hr), @@ -244,9 +245,10 @@ theorem Complex.volume_sum_rpow_lt_one {p : ℝ} (hp : 1 ≤ p) : norm_smul_le (β := PiLp (.ofReal p) (fun _ : ι => ℂ)) r (toLp (.ofReal p) x) simp_rw [← toLp_neg, ← toLp_add, ← toLp_smul, eq_norm] at eq_zero nm_zero nm_neg nm_add nm_smul -- We use `measure_lt_one_eq_integral_div_gamma` with `g` equals to the norm `L_p` - convert measure_lt_one_eq_integral_div_gamma (volume : Measure (ι → ℂ)) - (g := fun x => (∑ i, ‖x i‖ ^ p) ^ (1 / p)) nm_zero nm_neg nm_add (eq_zero _).mp - (fun r x => nm_smul r x) (by linarith : 0 < p) using 4 + convert! + measure_lt_one_eq_integral_div_gamma (volume : Measure (ι → ℂ)) (g := fun x => + (∑ i, ‖x i‖ ^ p) ^ (1 / p)) nm_zero nm_neg nm_add (eq_zero _).mp (fun r x => nm_smul r x) + (by linarith : 0 < p) using 4 · rw [rpow_lt_one_iff' _ (one_div_pos.mpr h₁)] exact Finset.sum_nonneg' (fun _ => rpow_nonneg (norm_nonneg _) _) · simp_rw [← rpow_mul (h₂ _), div_mul_cancel₀ _ (ne_of_gt h₁), Real.rpow_one, @@ -268,7 +270,7 @@ theorem Complex.volume_sum_rpow_lt [Nonempty ι] {p : ℝ} (hp : 1 ≤ p) (r : exact not_le.mpr (lt_of_lt_of_le (Set.mem_setOf.mp hx) hr) (h₂ x) rw [this, measure_empty, ← zero_eq_ofReal.mpr hr, zero_pow Fin.pos'.ne', zero_mul] · rw [← Complex.volume_sum_rpow_lt_one _ hp, ← ENNReal.ofReal_pow (le_of_lt hr)] - convert addHaar_smul_of_nonneg volume (le_of_lt hr) {x : ι → ℂ | ∑ i, ‖x i‖ ^ p < 1} using 2 + convert! addHaar_smul_of_nonneg volume (le_of_lt hr) {x : ι → ℂ | ∑ i, ‖x i‖ ^ p < 1} using 2 · simp_rw [← Set.preimage_smul_inv₀ (ne_of_gt hr), Set.preimage_setOf_eq, Pi.smul_apply, norm_smul, mul_rpow (norm_nonneg _) (norm_nonneg _), Real.norm_eq_abs, abs_inv, inv_rpow (abs_nonneg _), ← Finset.mul_sum, abs_eq_self.mpr (le_of_lt hr), inv_mul_lt_iff₀ @@ -318,7 +320,7 @@ theorem volume_ball (x : EuclideanSpace ℝ ι) (r : ℝ) : rw [← (PiLp.volume_preserving_toLp ι).measure_preimage measurableSet_ball.nullMeasurableSet] simp only [Set.preimage, ball_zero_eq _ zero_le_one, one_pow, Set.mem_setOf_eq] - convert volume_sum_rpow_lt_one ι one_le_two using 4 + convert! volume_sum_rpow_lt_one ι one_le_two using 4 · simp [sq_abs] · rw [Gamma_add_one (by simp), Gamma_one_half_eq, ← mul_assoc, mul_div_cancel₀ _ two_ne_zero, one_mul] @@ -350,7 +352,7 @@ theorem volume_ball (x : E) (r : ℝ) : have : Nonempty (Fin (finrank ℝ E)) := Fin.pos_iff_nonempty.mp finrank_pos have := EuclideanSpace.volume_ball (Fin (finrank ℝ E)) ((stdOrthonormalBasis ℝ E).repr x) r simp_rw [Fintype.card_fin] at this - convert this + convert! this simp only [LinearIsometryEquiv.preimage_ball, LinearIsometryEquiv.symm_symm] theorem volume_closedBall (x : E) (r : ℝ) : diff --git a/Mathlib/MeasureTheory/Measure/LevyConvergence.lean b/Mathlib/MeasureTheory/Measure/LevyConvergence.lean index 1abf40924cdce2..9d6a3d1213e098 100644 --- a/Mathlib/MeasureTheory/Measure/LevyConvergence.lean +++ b/Mathlib/MeasureTheory/Measure/LevyConvergence.lean @@ -165,7 +165,7 @@ lemma ProbabilityMeasure.tendsto_of_tight_of_separatesPoints (𝕜 : Type*) [RCL isCompact_closure_of_isTightMeasureSet (by simpa using h_tight) obtain ⟨μ', -, hμ' : Tendsto _ _ _⟩ := h_compact.ultrafilter_le_nhds (U.map μ) (.trans (by simp) (monotone_principal subset_closure)) - suffices (μ' : Measure E) = μ₀ by convert hμ'; ext; rw [this] + suffices (μ' : Measure E) = μ₀ by convert! hμ'; ext; rw [this] refine ext_of_forall_mem_subalgebra_integral_eq_of_pseudoEMetric_complete_countable hA fun g hg ↦ tendsto_nhds_unique ?_ ((hμ g hg).comp hU) rw [ProbabilityMeasure.tendsto_iff_forall_integral_rclike_tendsto 𝕜] at hμ' diff --git a/Mathlib/MeasureTheory/Measure/LevyProkhorovMetric.lean b/Mathlib/MeasureTheory/Measure/LevyProkhorovMetric.lean index a00d9467c09c39..89b493ffe35e45 100644 --- a/Mathlib/MeasureTheory/Measure/LevyProkhorovMetric.lean +++ b/Mathlib/MeasureTheory/Measure/LevyProkhorovMetric.lean @@ -180,7 +180,7 @@ lemma levyProkhorovDist_triangle [OpensMeasurableSpace Ω] (μ ν κ : Measure levyProkhorovDist μ κ ≤ levyProkhorovDist μ ν + levyProkhorovDist ν κ := by have dμν_finite := (levyProkhorovEDist_lt_top μ ν).ne have dνκ_finite := (levyProkhorovEDist_lt_top ν κ).ne - convert ENNReal.toReal_mono ?_ <| levyProkhorovEDist_triangle μ ν κ + convert! ENNReal.toReal_mono ?_ <| levyProkhorovEDist_triangle μ ν κ · simp only [levyProkhorovDist, ENNReal.toReal_add dμν_finite dνκ_finite] · exact ENNReal.add_ne_top.mpr ⟨dμν_finite, dνκ_finite⟩ @@ -250,7 +250,7 @@ lemma levyProkhorovDist_le_of_forall_le refine (ofReal_lt_ofReal_iff ?_).mp ?_ · exact ENNReal.toReal_pos ε_gt.bot_lt.ne' ε_lt_top.ne · simpa [ofReal_toReal_eq_iff.mpr ε_lt_top.ne] using ε_gt - convert h ε.toReal B ε_gt' B_mble + convert! h ε.toReal B ε_gt' B_mble exact (ENNReal.ofReal_toReal ε_lt_top.ne).symm /-! ### Equipping measures with the Lévy-Prokhorov metric -/ @@ -389,8 +389,10 @@ lemma BoundedContinuousFunction.integral_le_of_levyProkhorovEDist_lt (μ ν : Me ≤ (fun (t : ℝ) ↦ ν.real (thickening ε {a | t ≤ f a}) + ε) := by intro t simp only [measureReal_def] - convert ENNReal.toReal_mono ?_ <| left_measure_le_of_levyProkhorovEDist_lt hμν - (B := {a | t ≤ f a}) (f.continuous.measurable measurableSet_Ici) + convert! + ENNReal.toReal_mono ?_ <| + left_measure_le_of_levyProkhorovEDist_lt hμν (B := {a | t ≤ f a}) + (f.continuous.measurable measurableSet_Ici) · rw [ENNReal.toReal_add (measure_ne_top ν _) ofReal_ne_top, ENNReal.toReal_ofReal ε_pos.le] · exact ENNReal.add_ne_top.mpr ⟨measure_ne_top ν _, ofReal_ne_top⟩ have intble₁ : IntegrableOn (fun t ↦ μ.real {a | t ≤ f a}) (Ioc 0 ‖f‖) := by @@ -528,7 +530,7 @@ lemma ProbabilityMeasure.toMeasure_add_pos_gt_mem_nhds (P : ProbabilityMeasure filter_upwards [gt_mem_sets_of_limsInf_gt (α := ℝ≥0∞) isBounded_ge_of_bot (show P.toMeasure G - ε < limsInf ((𝓝 P).map (fun Q ↦ Q.toMeasure G)) from aux)] with Q hQ simp only [preimage_setOf_eq, mem_setOf_eq] at hQ - convert ENNReal.add_lt_add_right ε_top hQ + convert! ENNReal.add_lt_add_right ε_top hQ exact (tsub_add_cancel_of_le easy).symm variable [SeparableSpace Ω] @@ -555,10 +557,10 @@ lemma SeparableSpace.exists_measurable_partition_diam_le {ε : ℝ} (ε_pos : 0 · exact fun n ↦ Bornology.IsBounded.subset isBounded_ball <| disjointed_subset Bs n · intro n apply (diam_mono (disjointed_subset Bs n) isBounded_ball).trans - convert diam_ball half_ε_pos.le + convert! diam_ball half_ε_pos.le ring · have aux : ⋃ n, Bs n = univ := by - convert DenseRange.iUnion_uniformity_ball xs_dense <| Metric.dist_mem_uniformity half_ε_pos + convert! DenseRange.iUnion_uniformity_ball xs_dense <| Metric.dist_mem_uniformity half_ε_pos exact (ball_eq_ball' _ _).symm simpa only [← aux] using iUnion_disjointed · exact disjoint_disjointed Bs diff --git a/Mathlib/MeasureTheory/Measure/MeasureSpace.lean b/Mathlib/MeasureTheory/Measure/MeasureSpace.lean index dfdbb0f4299ba0..a01264c58a03f6 100644 --- a/Mathlib/MeasureTheory/Measure/MeasureSpace.lean +++ b/Mathlib/MeasureTheory/Measure/MeasureSpace.lean @@ -853,6 +853,7 @@ lemma apply_eq_zero_of_isEmpty [IsEmpty α] {_ : MeasurableSpace α} (μ : Measu instance instSubsingleton [IsEmpty α] {m : MeasurableSpace α} : Subsingleton (Measure α) := ⟨fun μ ν => by ext1 s _; rw [apply_eq_zero_of_isEmpty, apply_eq_zero_of_isEmpty]⟩ +@[nontriviality] theorem eq_zero_of_isEmpty [IsEmpty α] {_m : MeasurableSpace α} (μ : Measure α) : μ = 0 := Subsingleton.elim μ 0 diff --git a/Mathlib/MeasureTheory/Measure/MeasureSpaceDef.lean b/Mathlib/MeasureTheory/Measure/MeasureSpaceDef.lean index be40a58cb107f2..615cf047d4df96 100644 --- a/Mathlib/MeasureTheory/Measure/MeasureSpaceDef.lean +++ b/Mathlib/MeasureTheory/Measure/MeasureSpaceDef.lean @@ -224,7 +224,7 @@ theorem exists_measurable_superset_iff_measure_eq_zero : theorem measure_biUnion_lt_top {s : Set β} {f : β → Set α} (hs : s.Finite) (hfin : ∀ i ∈ s, μ (f i) < ∞) : μ (⋃ i ∈ s, f i) < ∞ := by - convert (measure_biUnion_finset_le (μ := μ) hs.toFinset f).trans_lt _ using 3 + convert! (measure_biUnion_finset_le (μ := μ) hs.toFinset f).trans_lt _ using 3 · ext rw [Finite.mem_toFinset] · simpa only [ENNReal.sum_lt_top, Finite.mem_toFinset] diff --git a/Mathlib/MeasureTheory/Measure/MutuallySingular.lean b/Mathlib/MeasureTheory/Measure/MutuallySingular.lean index 6674a829ce78d8..302749961949c7 100644 --- a/Mathlib/MeasureTheory/Measure/MutuallySingular.lean +++ b/Mathlib/MeasureTheory/Measure/MutuallySingular.lean @@ -203,8 +203,8 @@ lemma exists_null_set_measure_lt_of_disjoint (h : Disjoint μ ν) {ε : ℝ≥0} lemma mutuallySingular_of_disjoint (h : Disjoint μ ν) : μ ⟂ₘ ν := by have h' (n : ℕ) : ∃ s, μ s = 0 ∧ ν sᶜ ≤ (1 / 2) ^ n := by - convert exists_null_set_measure_lt_of_disjoint h (ε := (1 / 2) ^ (n + 1)) - <| pow_pos (by simp) (n + 1) + convert! + exists_null_set_measure_lt_of_disjoint h (ε := (1 / 2) ^ (n + 1)) <| pow_pos (by simp) (n + 1) conv => -- this tweak is needed due to the known issue of `norm_cast` with numeric fractions enter [1, 1] diff --git a/Mathlib/MeasureTheory/Measure/Portmanteau.lean b/Mathlib/MeasureTheory/Measure/Portmanteau.lean index 1aef701d6a14a0..d080e0073cee30 100644 --- a/Mathlib/MeasureTheory/Measure/Portmanteau.lean +++ b/Mathlib/MeasureTheory/Measure/Portmanteau.lean @@ -517,7 +517,7 @@ lemma integral_le_liminf_integral_of_forall_isOpen_measure_le_liminf_measure f.continuous f_nn h_opens rw [@integral_eq_lintegral_of_nonneg_ae Ω _ μ f (Eventually.of_forall f_nn) f.continuous.measurable.aestronglyMeasurable] - convert ENNReal.toReal_mono ?_ same + convert! ENNReal.toReal_mono ?_ same · simp only [fun i ↦ @integral_eq_lintegral_of_nonneg_ae Ω _ (μs i) f (Eventually.of_forall f_nn) f.continuous.measurable.aestronglyMeasurable] let g := BoundedContinuousFunction.comp _ Real.lipschitzWith_toNNReal f @@ -534,7 +534,7 @@ lemma integral_le_liminf_integral_of_forall_isOpen_measure_le_liminf_measure · intro x hx obtain ⟨i, hi⟩ := hx.exists apply le_trans hi - convert obs i with x + convert! obs i with x have aux := ENNReal.ofReal_eq_coe_nnreal (f_nn x) simp only [ContinuousMap.toFun_eq_coe, BoundedContinuousFunction.coe_toContinuousMap] at aux rw [aux] @@ -567,7 +567,7 @@ theorem tendsto_of_forall_isOpen_le_liminf_nat {μ : ProbabilityMeasure Ω} · exact ⟨0, by simp⟩ have obs := ENNReal.coe_mono h_opens simp only [ProbabilityMeasure.ennreal_coeFn_eq_coeFn_toMeasure, aux] at obs - convert obs + convert! obs simp only [Function.comp_apply, ProbabilityMeasure.ennreal_coeFn_eq_coeFn_toMeasure] /-- One implication of the portmanteau theorem: if for all open sets `G` we have the liminf @@ -628,7 +628,7 @@ lemma tendsto_of_forall_isClosed_limsup_le_nat {μs : ℕ → ProbabilityMeasure ⟨1, by simp⟩ ⟨0, by simp⟩ have obs := ENNReal.coe_mono h simp only [ProbabilityMeasure.ennreal_coeFn_eq_coeFn_toMeasure, aux] at obs - convert obs + convert! obs simp /-- One implication of the portmanteau theorem: if for all closed sets `F` we have the limsup @@ -790,7 +790,7 @@ lemma ProbabilityMeasure.exists_lt_measure_biUnion_of_isOpen rw [← G_eq] at this rcases ((tendsto_order.1 this).1 r hr).exists with ⟨n, hn⟩ refine ⟨(Finset.range (n + 1)).image f, by grind, ?_, ?_⟩ - · convert hn + · convert! hn simp [accumulate_def] · simpa [G_eq] using fun i _ ↦ subset_iUnion f i diff --git a/Mathlib/MeasureTheory/Measure/ProbabilityMeasure.lean b/Mathlib/MeasureTheory/Measure/ProbabilityMeasure.lean index a3db8bac502b3f..89b72124f705da 100644 --- a/Mathlib/MeasureTheory/Measure/ProbabilityMeasure.lean +++ b/Mathlib/MeasureTheory/Measure/ProbabilityMeasure.lean @@ -642,7 +642,7 @@ lemma tendsto_map_of_tendsto_of_continuous {ι : Type*} {L : Filter ι} (𝓝 (ν.map f_cont.measurable.aemeasurable)) := by rw [ProbabilityMeasure.tendsto_iff_forall_lintegral_tendsto] at lim ⊢ intro g - convert lim (g.compContinuous ⟨f, f_cont⟩) <;> + convert! lim (g.compContinuous ⟨f, f_cont⟩) <;> · simp only [map, compContinuous_apply, ContinuousMap.coe_mk] refine lintegral_map ?_ f_cont.measurable exact (ENNReal.continuous_coe.comp g.continuous).measurable diff --git a/Mathlib/MeasureTheory/Measure/Prod.lean b/Mathlib/MeasureTheory/Measure/Prod.lean index e14709c68ecd9c..e9f92b71955eb6 100644 --- a/Mathlib/MeasureTheory/Measure/Prod.lean +++ b/Mathlib/MeasureTheory/Measure/Prod.lean @@ -907,7 +907,8 @@ theorem prod_of_left {α β γ} [MeasurableSpace α] [MeasurableSpace β] [Measu (h2f : ∀ᵐ y ∂ν, QuasiMeasurePreserving (fun x => f (x, y)) μ τ) : QuasiMeasurePreserving f (μ.prod ν) τ := by rw [← prod_swap] - convert (QuasiMeasurePreserving.prod_of_right (hf.comp measurable_swap) h2f).comp + convert! + (QuasiMeasurePreserving.prod_of_right (hf.comp measurable_swap) h2f).comp ((measurable_swap.measurePreserving (ν.prod μ)).symm MeasurableEquiv.prodComm).quasiMeasurePreserving @@ -1038,7 +1039,7 @@ theorem setLIntegral_prod_symm [SFinite μ] {s : Set α} {t : Set β} (f : α × setLIntegral_prod] · rfl · refine AEMeasurable.comp_measurable ?_ measurable_swap - convert hf + convert! hf rw [← Measure.prod_restrict, Measure.prod_swap, Measure.prod_restrict] /-- The reversed version of **Tonelli's Theorem**. In this version `f` is in curried form, which diff --git a/Mathlib/MeasureTheory/Measure/Prokhorov.lean b/Mathlib/MeasureTheory/Measure/Prokhorov.lean index 3668103e9c3a36..42a8a0b8a738bc 100644 --- a/Mathlib/MeasureTheory/Measure/Prokhorov.lean +++ b/Mathlib/MeasureTheory/Measure/Prokhorov.lean @@ -106,14 +106,14 @@ theorem isCompact_setOf_finiteMeasure_le_of_compactSpace [CompactSpace E] (C : { toFun := Λ map_add' g g' := by have : Tendsto (fun (μ : FiniteMeasure E) ↦ ∫ x, g x + g' x ∂μ) f (𝓝 (Λ g + Λ g')) := by - convert (hΛ g).add (hΛ g') + convert! (hΛ g).add (hΛ g') rw [integral_add] · exact g.continuous.integrable_of_hasCompactSupport g.hasCompactSupport · exact g'.continuous.integrable_of_hasCompactSupport g'.hasCompactSupport exact tendsto_nhds_unique (hΛ (g + g')) this map_smul' c g := by have : Tendsto (fun (μ : FiniteMeasure E) ↦ ∫ x, c • g x ∂μ) f (𝓝 (c • Λ g)) := by - convert (hΛ g).const_smul c + convert! (hΛ g).const_smul c rw [integral_smul] exact tendsto_nhds_unique (hΛ (c • g)) this monotone' g g' hgg' := by @@ -142,7 +142,7 @@ theorem isCompact_setOf_finiteMeasure_le_of_compactSpace [CompactSpace E] (C : let g' : C_c(E, ℝ) := { toFun := g hasCompactSupport' := HasCompactSupport.of_compactSpace _ } - convert hΛ g' + convert! hΛ g' change ∫ (x : E), g' x ∂μlim' = Λ g' simp only [FiniteMeasure.toMeasure_mk, RealRMK.integral_rieszMeasure, μlim', μlim] rfl @@ -249,7 +249,7 @@ lemma isCompact_setOf_finiteMeasure_mass_le_compl_isCompact_le simp only [restrict_mass, restrict_measure_eq, Measure.restrict_apply (A n).measurableSet.compl] refine ⟨(apply_le_mass ρ _).trans hρ.1, ?_⟩ - convert measure_empty (μ := (ρ : Measure E)) + convert! measure_empty (μ := (ρ : Measure E)) apply disjoint_iff.1 apply disjoint_compl_left.mono_right exact le_trans sdiff_le (le_partialSups _ _) @@ -264,7 +264,7 @@ lemma isCompact_setOf_finiteMeasure_mass_le_compl_isCompact_le let μ : FiniteMeasure E := ⟨ν', ν'_fin⟩ refine ⟨μ, ν'_reg, by simp [μ, ν'K], ?_⟩ apply tendsto_of_forall_integral_tendsto (fun g ↦ ?_) - convert tendsto_iff_forall_integral_tendsto.1 ν_lim g using 2 + convert! tendsto_iff_forall_integral_tendsto.1 ν_lim g using 2 exact (hν' g).symm -- let `νₙ` be such nice limits on `disjointed K n`. choose! ν ν_reg νK hν using M @@ -281,7 +281,7 @@ lemma isCompact_setOf_finiteMeasure_mass_le_compl_isCompact_le = (∑ i ∈ Finset.range (n + 1), ν i).toMeasure univ := by simp rw [this] suffices (∑ i ∈ Finset.range (n + 1), ν i).mass ≤ C by - convert ENNReal.coe_le_coe.2 this + convert! ENNReal.coe_le_coe.2 this simp have : Tendsto (fun (μ : FiniteMeasure E) ↦ (∑ i ∈ Finset.range (n + 1), μ.restrict (disjointed K i)).mass) f @@ -417,7 +417,7 @@ lemma isCompact_setOf_finiteMeasure_mass_le_compl_isCompact_le -- `ρ.restricted (K m \ K n)` is bounded by `ρ (Kₙᶜ) ≤ uₙ`. suffices (μ : Measure E) (K n)ᶜ ≤ u n by apply ENNReal.coe_le_coe.1 - convert this + convert! this simp simp only [toMeasure_mk, (hK n).measurableSet.compl, Measure.sum_apply, μ] have : Tendsto (fun m ↦ ∑ i ∈ Finset.range (m + 1), (ν i : Measure E) (K n)ᶜ) atTop @@ -441,7 +441,7 @@ lemma isCompact_setOf_finiteMeasure_mass_le_compl_isCompact_le gcongr simp suffices (∑ i ∈ Finset.Ioc n m, ν i).mass ≤ u n by - convert ENNReal.coe_le_coe.2 this + convert! ENNReal.coe_le_coe.2 this simp have : Tendsto (fun (μ : FiniteMeasure E) ↦ (∑ i ∈ Finset.Ioc n m, μ.restrict (disjointed K i)).mass) f diff --git a/Mathlib/MeasureTheory/Measure/QuasiMeasurePreserving.lean b/Mathlib/MeasureTheory/Measure/QuasiMeasurePreserving.lean index 422a24f76b8021..b0cd4d56b46384 100644 --- a/Mathlib/MeasureTheory/Measure/QuasiMeasurePreserving.lean +++ b/Mathlib/MeasureTheory/Measure/QuasiMeasurePreserving.lean @@ -152,7 +152,7 @@ theorem image_zpow_ae_eq {s : Set α} {e : α ≃ α} (he : QuasiMeasurePreservi rwa [Equiv.Perm.iterate_eq_pow e⁻¹ k, inv_pow e k] at he' · rw [zpow_neg, zpow_natCast] replace hs : e ⁻¹' s =ᵐ[μ] s := by - convert he.preimage_ae_eq hs.symm + convert! he.preimage_ae_eq hs.symm rw [Equiv.preimage_image] replace he : (⇑e)^[k] ⁻¹' s =ᵐ[μ] s := he.preimage_iterate_ae_eq k hs rwa [Equiv.Perm.iterate_eq_pow e k] at he diff --git a/Mathlib/MeasureTheory/Measure/Real.lean b/Mathlib/MeasureTheory/Measure/Real.lean index 9e1c3f09c8fe3d..7178ed5b91de41 100644 --- a/Mathlib/MeasureTheory/Measure/Real.lean +++ b/Mathlib/MeasureTheory/Measure/Real.lean @@ -157,7 +157,7 @@ theorem measureReal_biUnion_finset_le (s : Finset β) (f : β → Set α) : theorem measureReal_iUnion_fintype_le [Fintype β] (f : β → Set α) : μ.real (⋃ b, f b) ≤ ∑ p, μ.real (f p) := by - convert measureReal_biUnion_finset_le Finset.univ f + convert! measureReal_biUnion_finset_le Finset.univ f simp theorem measureReal_iUnion_fintype [Fintype β] {f : β → Set α} (hn : Pairwise (Disjoint on f)) @@ -411,7 +411,7 @@ theorem exists_nonempty_inter_of_measureReal_univ_lt_sum_measureReal [IsFiniteMe (fun i mi ↦ (h i mi).nullMeasurableSet) simp only [Measure.real] at H apply (ENNReal.toReal_lt_toReal (by finiteness) _).1 - · convert H + · convert! H rw [ENNReal.toReal_sum (by finiteness)] · exact (ENNReal.sum_lt_top.mpr (fun i hi ↦ measure_lt_top ..)).ne diff --git a/Mathlib/MeasureTheory/Measure/Regular.lean b/Mathlib/MeasureTheory/Measure/Regular.lean index a21d3d03757b73..6fa51d2ce28994 100644 --- a/Mathlib/MeasureTheory/Measure/Regular.lean +++ b/Mathlib/MeasureTheory/Measure/Regular.lean @@ -745,7 +745,7 @@ protected theorem map_iff [BorelSpace α] [MeasurableSpace β] [TopologicalSpace [BorelSpace β] (f : α ≃ₜ β) : InnerRegular (Measure.map f μ) ↔ InnerRegular μ := by refine ⟨fun h ↦ ?_, fun h ↦ h.map f⟩ - convert h.map f.symm + convert! h.map f.symm rw [map_map f.symm.continuous.measurable f.continuous.measurable] simp @@ -881,7 +881,7 @@ instance restrict [h : InnerRegularCompactLTTop μ] (A : Set α) : instance (priority := 50) [h : InnerRegularCompactLTTop μ] [IsFiniteMeasure μ] : InnerRegular μ := by constructor - convert h.innerRegular with s + convert! h.innerRegular with s simp [measure_ne_top μ s] instance (priority := 50) [BorelSpace α] [R1Space α] [InnerRegularCompactLTTop μ] @@ -970,7 +970,7 @@ instance smul [h : InnerRegularCompactLTTop μ] (c : ℝ≥0∞) : InnerRegularC · simp [h's] at hr · simp [h'c, h's] at hs · constructor - convert InnerRegularWRT.smul h.innerRegular c using 2 with s + convert! InnerRegularWRT.smul h.innerRegular c using 2 with s have : (c • μ) s ≠ ∞ ↔ μ s ≠ ∞ := by simp [ENNReal.mul_eq_top, hc, h'c] simp only [this] @@ -1122,7 +1122,7 @@ protected theorem map_iff [BorelSpace α] [MeasurableSpace β] [TopologicalSpace [BorelSpace β] (f : α ≃ₜ β) : Regular (Measure.map f μ) ↔ Regular μ := by refine ⟨fun h ↦ ?_, fun h ↦ h.map f⟩ - convert h.map f.symm + convert! h.map f.symm rw [map_map f.symm.continuous.measurable f.continuous.measurable] simp diff --git a/Mathlib/MeasureTheory/Measure/RegularityCompacts.lean b/Mathlib/MeasureTheory/Measure/RegularityCompacts.lean index 189361037a6fd2..5f617b316ce066 100644 --- a/Mathlib/MeasureTheory/Measure/RegularityCompacts.lean +++ b/Mathlib/MeasureTheory/Measure/RegularityCompacts.lean @@ -208,7 +208,7 @@ theorem innerRegular_isCompact_isClosed_measurableSet_of_finite [TopologicalSpac P.InnerRegularWRT (fun s ↦ IsCompact s ∧ IsClosed s) MeasurableSet := by suffices P.InnerRegularWRT (fun s ↦ IsCompact s ∧ IsClosed s) fun s ↦ MeasurableSet s ∧ P s ≠ ∞ by - convert this + convert! this simp only [iff_self_and] exact fun _ ↦ measure_ne_top P _ refine Measure.InnerRegularWRT.measurableSet_of_isOpen ?_ ?_ diff --git a/Mathlib/MeasureTheory/Measure/ResolventTransform.lean b/Mathlib/MeasureTheory/Measure/ResolventTransform.lean new file mode 100644 index 00000000000000..6cf81e33017e89 --- /dev/null +++ b/Mathlib/MeasureTheory/Measure/ResolventTransform.lean @@ -0,0 +1,184 @@ +/- +Copyright (c) 2026 David Ledvinka. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: David Ledvinka +-/ +module + +public import Mathlib.Analysis.Calculus.ParametricIntegral +public import Mathlib.MeasureTheory.Measure.Support + +import Mathlib.Analysis.Normed.Algebra.GelfandFormula +import Mathlib.Analysis.Complex.CauchyIntegral + +/-! +# Resolvent Transform of a Measure + +Given a normed algebra `A` over a normed field `𝕜`, and `μ : Measure 𝕜`, we define the +resolvent transform of `μ` by the formula + +`resolventTransform μ a = ∫ x, resolvent a x ∂μ = ∫ x, (↑ₐ x - a)⁻¹ʳ ∂μ` + +This is not a standard notion in the literature, but specializes to a few standard notions, +namely the case `𝕜 = ℝ` and `A = ℂ` is the Stieltjes transform, and the case `𝕜 = A = ℂ` is the +Cauchy transform, given by the formulas: + +`∫ (x : ℝ), (↑x - a)⁻¹ ∂μ` and `∫ (x : ℂ), (↑x - a)⁻¹ ∂μ` respectively. + +## Main definitions + +* `resolventTransform μ a`: The resolvent transform of a measure `μ` at `a` + +## Main statements + +* `hasDerivAt_resolventTransform`: For any `a` not in the support of `μ`, + the `resolventTransform` has derivative `∫ x, resolvent a x ^ 2 ∂u` at `a`. +* `analyticOn_resolventTransform`: In the case `A = ℂ`, the `resolventTransform` + is holomorphic on the complement of `μ.support`. + +## Tags + +resolvent transform, Stieljes transform, Cauchy transform +-/ + +public section + +variable {𝕜 A : Type*} + +open MeasureTheory Measure Metric Complex spectrum + +open scoped Topology + +namespace MeasureTheory + +section resolvent + +variable [NontriviallyNormedField 𝕜] [MeasurableSpace 𝕜] + +@[fun_prop] +theorem measurable_resolvent {a : A} [OpensMeasurableSpace 𝕜] [NormedRing A] [NormedAlgebra 𝕜 A] + [CompleteSpace A] [MeasurableSpace A] [BorelSpace A] : + Measurable (resolvent (R := 𝕜) a) := by + classical + have h1 : ContinuousOn (resolvent (R := 𝕜) a) (resolventSet 𝕜 a) := + HasDerivAt.continuousOn (fun _ hx ↦ hasDerivAt_resolvent_const_left hx) + have h2 : ContinuousOn (resolvent (R := 𝕜) a) (resolventSet 𝕜 a)ᶜ := by + rw [continuousOn_iff_continuous_restrict] + convert continuous_const (y := (0 : A)) with x + simp + have h3 : MeasurableSet (resolventSet 𝕜 a) := (isOpen_resolventSet a).measurableSet + simpa using h1.measurable_piecewise h2 h3 + +variable [CompleteSpace 𝕜] [NormedDivisionRing A] [NormedAlgebra 𝕜 A] + +theorem norm_resolvent_le_inv_infDist_support {μ : Measure 𝕜} {a : A} + (hz : a ∉ algebraMap 𝕜 A '' μ.support) {x : 𝕜} (hx : x ∈ μ.support) : + ‖resolvent a x‖ ≤ (infDist a (algebraMap 𝕜 A '' μ.support))⁻¹ := by + have : 0 < infDist a (algebraMap 𝕜 A '' μ.support) := by + refine (IsClosed.notMem_iff_infDist_pos ?_ ((Set.nonempty_of_mem hx).image _)).mp hz + refine (Topology.IsClosedEmbedding.isClosed_iff_image_isClosed ?_).mp isClosed_support + exact (algebraMap_isometry 𝕜 A).isClosedEmbedding + have : infDist a (algebraMap 𝕜 A '' μ.support) ≤ ‖(algebraMap 𝕜 A) x - a‖ := by + grw [infDist_le_dist_of_mem (y := (algebraMap 𝕜 A) x), ← dist_eq_norm, dist_comm] + simp [hx] + grw [resolvent, Ring.inverse_eq_inv', norm_inv, inv_le_inv₀ (by linarith) (by positivity), this] + +theorem integrable_resolvent [HereditarilyLindelofSpace 𝕜] [OpensMeasurableSpace 𝕜] + [CompleteSpace A] [SecondCountableTopology A] [MeasurableSpace A] [BorelSpace A] + {μ : Measure 𝕜} [IsFiniteMeasure μ] {a : A} (hz : a ∉ algebraMap 𝕜 A '' μ.support) : + Integrable (resolvent a) μ := by + refine ⟨by fun_prop, ?_⟩ + apply HasFiniteIntegral.of_bounded + filter_upwards [support_mem_ae] with x hx using norm_resolvent_le_inv_infDist_support hz hx + +end resolvent + +section Definition + +variable [NormedField 𝕜] [NormedRing A] [NormedAlgebra ℝ A] [NormedAlgebra 𝕜 A] + {m𝕜 : MeasurableSpace 𝕜} + +/-- The resolvent transform of a measure. -/ +noncomputable +def resolventTransform (μ : Measure 𝕜) (a : A) := + ∫ x, resolvent a x ∂μ + +lemma resolventTransform_def (μ : Measure 𝕜) : + resolventTransform μ = fun (a : A) ↦ (∫ x, resolvent a x ∂μ) := by rfl + +lemma resolventTransform_apply (μ : Measure 𝕜) (a : A) : + resolventTransform μ a = ∫ x, resolvent a x ∂μ := by rfl + +@[simp] +lemma resolventTransform_zero_measure : resolventTransform (0 : Measure 𝕜) = (0 : A → A) := by + ext + simp [resolventTransform_def] + +@[simp] +lemma resolventTransform_dirac [MeasurableSingletonClass 𝕜] [CompleteSpace A] + (x : 𝕜) (a : A) : resolventTransform (.dirac x) a = resolvent a x := by + simp [resolventTransform_def] + +end Definition + +section Deriv + +variable [NontriviallyNormedField 𝕜] [HereditarilyLindelofSpace 𝕜] [CompleteSpace 𝕜] + [MeasurableSpace 𝕜] [BorelSpace 𝕜] + +theorem hasDerivAt_resolventTransform [RCLike A] [NormedAlgebra 𝕜 A] {μ : Measure 𝕜} + [IsFiniteMeasure μ] (a : A) (ha : a ∉ algebraMap 𝕜 A '' μ.support) : + HasDerivAt (resolventTransform μ) (∫ x, resolvent a x ^ 2 ∂μ) a := by + by_cases! h : μ.support.Nonempty; swap + · simp [support_eq_empty_iff.mp h] + rw [resolventTransform_def] + have : 0 < infDist a (algebraMap 𝕜 A '' μ.support) := by + refine (IsClosed.notMem_iff_infDist_pos ?_ (h.image _)).mp ha + refine (Topology.IsClosedEmbedding.isClosed_iff_image_isClosed ?_).mp isClosed_support + exact (algebraMap_isometry 𝕜 A).isClosedEmbedding + let s : Set A := ball a ((infDist a (algebraMap 𝕜 A '' μ.support)) / 2) + have hs_z : s ∈ 𝓝 a := ball_mem_nhds _ (by positivity) + have hs_μ : s ⊆ (algebraMap 𝕜 A '' μ.support)ᶜ := by + unfold s + grw [ball_subset_ball, ball_infDist_subset_compl] + grind + have resolvent_meas : ∀ᶠ w in nhds a, AEStronglyMeasurable (resolvent w) μ := by + filter_upwards with _ using by fun_prop + have resolvent'_bound : ∀ᵐ x ∂μ, ∀ w ∈ s, + ‖(resolvent w x) ^ 2‖ ≤ ((infDist a (algebraMap 𝕜 A '' μ.support)) / 2)⁻¹ ^ 2 := by + filter_upwards [support_mem_ae] with x hx w hw + grw [resolvent, Ring.inverse_eq_inv, norm_pow, norm_inv] + gcongr + calc infDist a (algebraMap 𝕜 A '' μ.support) / 2 + _ ≤ infDist a (algebraMap 𝕜 A '' μ.support) + - infDist a (algebraMap 𝕜 A '' μ.support) / 2 := by grind + _ ≤ ‖(algebraMap 𝕜 A) x - a‖ - ‖a - w‖ := by + gcongr + · grw [infDist_le_dist_of_mem (y := (algebraMap 𝕜 A) x) (by simp [hx]), dist_comm, + dist_eq_norm] + · apply le_of_lt + simpa [s, ← dist_eq_norm, dist_comm w a] using hw + _ ≤ ‖(algebraMap 𝕜 A) x - w‖ := by grw [norm_sub_le_norm_add]; grind + have h_deriv : ∀ᵐ x ∂μ, ∀ w ∈ s, HasDerivAt (fun w ↦ resolvent w x) (resolvent w x ^ 2) w := by + filter_upwards [support_mem_ae] with x hx w hw + apply hasDerivAt_resolvent_const_right + replace hw := hs_μ hw + contrapose! hw + rw [Set.notMem_compl_iff] + use x, hx + simpa [resolventSet, sub_eq_zero] using hw + exact hasDerivAt_integral_of_dominated_loc_of_deriv_le hs_z resolvent_meas + (integrable_resolvent (by simp [ha])) (by fun_prop) resolvent'_bound (by fun_prop) h_deriv |>.2 + +theorem analyticOn_resolventTransform [NormedAlgebra 𝕜 ℂ] {μ : Measure 𝕜} [IsFiniteMeasure μ] : + AnalyticOn ℂ (resolventTransform μ) (algebraMap 𝕜 ℂ '' μ.support)ᶜ := by + rw [analyticOn_iff_differentiableOn] + · intro z hz + exact (hasDerivAt_resolventTransform z hz).differentiableAt.differentiableWithinAt + apply isOpen_compl_iff.mpr + refine (Topology.IsClosedEmbedding.isClosed_iff_image_isClosed ?_).mp isClosed_support + exact (algebraMap_isometry 𝕜 ℂ).isClosedEmbedding + +end Deriv + +end MeasureTheory diff --git a/Mathlib/MeasureTheory/Measure/SeparableMeasure.lean b/Mathlib/MeasureTheory/Measure/SeparableMeasure.lean index f7b837b27f2372..b4b3fa530b1330 100644 --- a/Mathlib/MeasureTheory/Measure/SeparableMeasure.lean +++ b/Mathlib/MeasureTheory/Measure/SeparableMeasure.lean @@ -101,7 +101,7 @@ theorem Measure.MeasureDense.nonempty' (h𝒜 : μ.MeasureDense 𝒜) : {s | s ∈ 𝒜 ∧ μ s ≠ ∞}.Nonempty := by rcases h𝒜.approx ∅ MeasurableSet.empty (by simp) 1 (by simp) with ⟨t, ht, hμt⟩ refine ⟨t, ht, ?_⟩ - convert ne_top_of_lt hμt + convert! ne_top_of_lt hμt rw [← bot_eq_empty, bot_symmDiff] /-- The set of measurable sets is measure-dense. -/ @@ -115,7 +115,7 @@ theorem Measure.MeasureDense.completion (h𝒜 : μ.MeasureDense 𝒜) : μ.comp obtain ⟨t, ht, hμst⟩ := h𝒜.approx (toMeasurable μ s) (measurableSet_toMeasurable μ s) (by simpa) ε ε_pos refine ⟨t, ht, ?_⟩ - convert hμst using 1 + convert! hμst using 1 rw [completion_apply] exact measure_congr <| ae_eq_set_symmDiff (NullMeasurableSet.toMeasurable_ae_eq hs).symm Filter.EventuallyEq.rfl diff --git a/Mathlib/MeasureTheory/Measure/Support.lean b/Mathlib/MeasureTheory/Measure/Support.lean index 9eca30b7825d69..6a25a568568afd 100644 --- a/Mathlib/MeasureTheory/Measure/Support.lean +++ b/Mathlib/MeasureTheory/Measure/Support.lean @@ -130,7 +130,7 @@ lemma compl_support_eq_sUnion : μ.supportᶜ = ⋃₀ {t : Set X | IsOpen t ∧ nhds_basis_opens x |>.notMem_measureSupport, fun t ↦ and_comm (b := x ∈ t)] lemma support_eq_sInter : μ.support = ⋂₀ {t : Set X | IsClosed t ∧ μ tᶜ = 0} := by - convert congr($(compl_support_eq_sUnion (μ := μ))ᶜ) + convert! congr($(compl_support_eq_sUnion (μ := μ))ᶜ) all_goals simp [Set.compl_sUnion, compl_involutive.image_eq_preimage_symm] section Lindelof @@ -175,6 +175,10 @@ lemma nonempty_support_iff : μ.support.Nonempty ↔ μ ≠ 0 := ⟨fun h e ↦ (not_nonempty_iff_eq_empty.mpr <| congrArg Measure.support e |>.trans <| support_zero) h, fun h ↦ nonempty_support h⟩ +@[simp] +lemma support_eq_empty_iff : μ.support = ∅ ↔ μ = 0 := by + simp [← Set.not_nonempty_iff_eq_empty, not_congr nonempty_support_iff] + end Lindelof section Restrict @@ -202,7 +206,7 @@ lemma support_restrict_subset {s : Set X} : refine Set.subset_inter (support_subset_of_isClosed isClosed_closure ?_) (support_mono restrict_le_self) rw [mem_ae_iff, μ.restrict_apply isClosed_closure.isOpen_compl.measurableSet] - convert μ.empty + convert! μ.empty exact subset_closure.disjoint_compl_left.eq_bot end Restrict diff --git a/Mathlib/MeasureTheory/Measure/Tight.lean b/Mathlib/MeasureTheory/Measure/Tight.lean index 775f0a2a0f58dc..9677fe44253823 100644 --- a/Mathlib/MeasureTheory/Measure/Tight.lean +++ b/Mathlib/MeasureTheory/Measure/Tight.lean @@ -123,7 +123,7 @@ protected lemma subset (hT : IsTightMeasureSet T) (hST : S ⊆ T) : protected lemma union (hS : IsTightMeasureSet S) (hT : IsTightMeasureSet T) : IsTightMeasureSet (S ∪ T) := by rw [IsTightMeasureSet, iSup_union] - convert Tendsto.sup_nhds hS hT + convert! Tendsto.sup_nhds hS hT simp protected lemma inter (hS : IsTightMeasureSet S) (T : Set (Measure 𝓧)) : diff --git a/Mathlib/MeasureTheory/Measure/TightNormed.lean b/Mathlib/MeasureTheory/Measure/TightNormed.lean index a7d24a8dd62afc..a97cdfcb30e1fd 100644 --- a/Mathlib/MeasureTheory/Measure/TightNormed.lean +++ b/Mathlib/MeasureTheory/Measure/TightNormed.lean @@ -49,7 +49,7 @@ variable [PseudoMetricSpace E] lemma tendsto_measure_compl_closedBall_of_isTightMeasureSet (hS : IsTightMeasureSet S) (x : E) : Tendsto (fun r : ℝ ↦ ⨆ μ ∈ S, μ (Metric.closedBall x r)ᶜ) atTop (𝓝 0) := by suffices Tendsto ((⨆ μ ∈ S, μ) ∘ (fun r ↦ (Metric.closedBall x r)ᶜ)) atTop (𝓝 0) by - convert this with r + convert! this with r simp refine hS.comp <| .mono_right ?_ <| monotone_smallSets Metric.cobounded_le_cocompact exact (Metric.hasAntitoneBasis_cobounded_compl_closedBall _).tendsto_smallSets @@ -78,7 +78,7 @@ variable [NormedAddCommGroup E] lemma tendsto_measure_norm_gt_of_isTightMeasureSet (hS : IsTightMeasureSet S) : Tendsto (fun r : ℝ ↦ ⨆ μ ∈ S, μ {x | r < ‖x‖}) atTop (𝓝 0) := by have h := tendsto_measure_compl_closedBall_of_isTightMeasureSet hS 0 - convert h using 6 with r + convert! h using 6 with r ext simp @@ -86,7 +86,7 @@ lemma isTightMeasureSet_of_tendsto_measure_norm_gt [ProperSpace E] (h : Tendsto (fun r : ℝ ↦ ⨆ μ ∈ S, μ {x | r < ‖x‖}) atTop (𝓝 0)) : IsTightMeasureSet S := by refine isTightMeasureSet_of_tendsto_measure_compl_closedBall (x := 0) ?_ - convert h using 6 with r + convert! h using 6 with r ext simp @@ -139,7 +139,7 @@ lemma isTightMeasureSet_of_forall_basis_tendsto (b : OrthonormalBasis ι 𝕜 E) IsTightMeasureSet S := by rcases subsingleton_or_nontrivial E with hE | hE · simp only [IsTightMeasureSet, cocompact_eq_bot, smallSets_bot] - convert tendsto_pure_nhds (a := ∅) _ + convert! tendsto_pure_nhds (a := ∅) _ simp have h_rank : (0 : ℝ) < Fintype.card ι := by simpa [← Module.finrank_eq_card_basis b.toBasis, Module.finrank_pos_iff] @@ -252,7 +252,7 @@ lemma isTightMeasureSet_range_of_tendsto_limsup_inner_of_norm_eq_one · simp only [norm_smul, norm_inv, norm_algebraMap', Real.norm_eq_abs, abs_norm] rw [inv_mul_cancel₀ (by positivity)] exact h.comp <| (tendsto_const_mul_atTop_of_pos (by positivity)).mpr tendsto_id - convert h' using 7 with r n x + convert! h' using 7 with r n x rw [inner_smul_left] simp only [map_inv₀, RCLike.conj_ofReal, norm_mul, norm_inv, norm_algebraMap', norm_norm] rw [mul_lt_mul_iff_right₀] diff --git a/Mathlib/MeasureTheory/Measure/Typeclasses/Finite.lean b/Mathlib/MeasureTheory/Measure/Typeclasses/Finite.lean index 0332eb77689970..c0cfa8c614f9ee 100644 --- a/Mathlib/MeasureTheory/Measure/Typeclasses/Finite.lean +++ b/Mathlib/MeasureTheory/Measure/Typeclasses/Finite.lean @@ -198,7 +198,7 @@ lemma tendsto_measure_biUnion_Ici_zero_of_pairwise_disjoint have key := tendsto_measure_iInter_atTop (μ := μ) (fun n ↦ by measurability) decr ⟨0, measure_ne_top _ _⟩ simp only [nothing, measure_empty] at key - convert key + convert! key open scoped symmDiff @@ -210,7 +210,7 @@ theorem abs_measureReal_sub_le_measureReal_symmDiff' have hts : μ (t \ s) ≠ ∞ := (measure_lt_top_of_subset diff_subset ht').ne suffices (μ s).toReal - (μ t).toReal = (μ (s \ t)).toReal - (μ (t \ s)).toReal by rw [this, measure_symmDiff_eq hs ht, ENNReal.toReal_add hst hts] - convert abs_sub (μ (s \ t)).toReal (μ (t \ s)).toReal <;> simp + convert! abs_sub (μ (s \ t)).toReal (μ (t \ s)).toReal <;> simp rw [measure_diff' s ht ht', measure_diff' t hs hs', ENNReal.toReal_sub_of_le measure_le_measure_union_right (by finiteness), ENNReal.toReal_sub_of_le measure_le_measure_union_right (by finiteness), diff --git a/Mathlib/MeasureTheory/Measure/Typeclasses/Probability.lean b/Mathlib/MeasureTheory/Measure/Typeclasses/Probability.lean index 3a88d1c217cdc9..3a4ceaa9cb3082 100644 --- a/Mathlib/MeasureTheory/Measure/Typeclasses/Probability.lean +++ b/Mathlib/MeasureTheory/Measure/Typeclasses/Probability.lean @@ -228,7 +228,7 @@ lemma prob_compl_lt_one_sub_of_lt_prob {p : ℝ≥0∞} (hμs : p < μ s) (s_mbl · simp at hμs · rw [prob_compl_eq_one_sub s_mble] apply ENNReal.sub_lt_of_sub_lt prob_le_one (Or.inl one_ne_top) - convert hμs + convert! hμs exact ENNReal.sub_sub_cancel one_ne_top (lt_of_lt_of_le hμs prob_le_one).le lemma prob_compl_le_one_sub_of_le_prob {p : ℝ≥0∞} (hμs : p ≤ μ s) (s_mble : MeasurableSet s) : diff --git a/Mathlib/MeasureTheory/Measure/Typeclasses/SFinite.lean b/Mathlib/MeasureTheory/Measure/Typeclasses/SFinite.lean index 6a5e3cb27ebc1f..2ce2bafbdcad01 100644 --- a/Mathlib/MeasureTheory/Measure/Typeclasses/SFinite.lean +++ b/Mathlib/MeasureTheory/Measure/Typeclasses/SFinite.lean @@ -160,7 +160,7 @@ theorem preimage_spanningSetsIndex_singleton (μ : Measure α) [SigmaFinite μ] theorem spanningSetsIndex_eq_iff (μ : Measure α) [SigmaFinite μ] {x : α} {n : ℕ} : spanningSetsIndex μ x = n ↔ x ∈ disjointed (spanningSets μ) n := by - convert Set.ext_iff.1 (preimage_spanningSetsIndex_singleton μ n) x + convert! Set.ext_iff.1 (preimage_spanningSetsIndex_singleton μ n) x theorem mem_disjointed_spanningSetsIndex (μ : Measure α) [SigmaFinite μ] (x : α) : x ∈ disjointed (spanningSets μ) (spanningSetsIndex μ x) := diff --git a/Mathlib/MeasureTheory/Measure/WithDensity.lean b/Mathlib/MeasureTheory/Measure/WithDensity.lean index 06c802a4635846..c7202c88b472cb 100644 --- a/Mathlib/MeasureTheory/Measure/WithDensity.lean +++ b/Mathlib/MeasureTheory/Measure/WithDensity.lean @@ -252,7 +252,7 @@ theorem withDensity_apply_eq_zero' {f : α → ℝ≥0∞} {s : Set α} (hf : AE swap · simp only [measurableSet_toMeasurable, MeasurableSet.nullMeasurableSet] simp only [Pi.zero_apply] at A - convert A using 2 + convert! A using 2 ext x simp only [and_comm, exists_prop, mem_inter_iff, mem_setOf_eq, not_forall] diff --git a/Mathlib/MeasureTheory/Order/Lattice.lean b/Mathlib/MeasureTheory/Order/Lattice.lean index 04599857a97826..a699073554a52c 100644 --- a/Mathlib/MeasureTheory/Order/Lattice.lean +++ b/Mathlib/MeasureTheory/Order/Lattice.lean @@ -220,7 +220,7 @@ theorem Finset.measurable_range_sup' {f : ℕ → δ → α} {n : ℕ} (hf : ∀ @[fun_prop] theorem Finset.measurable_range_sup'' {f : ℕ → δ → α} {n : ℕ} (hf : ∀ k ≤ n, Measurable (f k)) : Measurable fun x => (range (n + 1)).sup' nonempty_range_add_one fun k => f k x := by - convert Finset.measurable_range_sup' hf using 1 + convert! Finset.measurable_range_sup' hf using 1 ext x simp diff --git a/Mathlib/MeasureTheory/OuterMeasure/AE.lean b/Mathlib/MeasureTheory/OuterMeasure/AE.lean index 50f628fe48cbf8..62350704d6900c 100644 --- a/Mathlib/MeasureTheory/OuterMeasure/AE.lean +++ b/Mathlib/MeasureTheory/OuterMeasure/AE.lean @@ -205,33 +205,33 @@ theorem union_ae_eq_univ_of_ae_eq_univ_left (h : s =ᵐ[μ] univ) : (s ∪ t : S (ae_eq_set_union h (ae_eq_refl t)).trans <| by rw [univ_union] theorem union_ae_eq_univ_of_ae_eq_univ_right (h : t =ᵐ[μ] univ) : (s ∪ t : Set α) =ᵐ[μ] univ := by - convert ae_eq_set_union (ae_eq_refl s) h + convert! ae_eq_set_union (ae_eq_refl s) h rw [union_univ] theorem union_ae_eq_right_of_ae_eq_empty (h : s =ᵐ[μ] (∅ : Set α)) : (s ∪ t : Set α) =ᵐ[μ] t := by - convert ae_eq_set_union h (ae_eq_refl t) + convert! ae_eq_set_union h (ae_eq_refl t) rw [empty_union] theorem union_ae_eq_left_of_ae_eq_empty (h : t =ᵐ[μ] (∅ : Set α)) : (s ∪ t : Set α) =ᵐ[μ] s := by - convert ae_eq_set_union (ae_eq_refl s) h + convert! ae_eq_set_union (ae_eq_refl s) h rw [union_empty] theorem inter_ae_eq_right_of_ae_eq_univ (h : s =ᵐ[μ] univ) : (s ∩ t : Set α) =ᵐ[μ] t := by - convert ae_eq_set_inter h (ae_eq_refl t) + convert! ae_eq_set_inter h (ae_eq_refl t) rw [univ_inter] theorem inter_ae_eq_left_of_ae_eq_univ (h : t =ᵐ[μ] univ) : (s ∩ t : Set α) =ᵐ[μ] s := by - convert ae_eq_set_inter (ae_eq_refl s) h + convert! ae_eq_set_inter (ae_eq_refl s) h rw [inter_univ] theorem inter_ae_eq_empty_of_ae_eq_empty_left (h : s =ᵐ[μ] (∅ : Set α)) : (s ∩ t : Set α) =ᵐ[μ] (∅ : Set α) := by - convert ae_eq_set_inter h (ae_eq_refl t) + convert! ae_eq_set_inter h (ae_eq_refl t) rw [empty_inter] theorem inter_ae_eq_empty_of_ae_eq_empty_right (h : t =ᵐ[μ] (∅ : Set α)) : (s ∩ t : Set α) =ᵐ[μ] (∅ : Set α) := by - convert ae_eq_set_inter (ae_eq_refl s) h + convert! ae_eq_set_inter (ae_eq_refl s) h rw [inter_empty] theorem ae_eq_set_biInter {s : Set β} (hs : s.Countable) {t t' : β → Set α} diff --git a/Mathlib/MeasureTheory/OuterMeasure/Caratheodory.lean b/Mathlib/MeasureTheory/OuterMeasure/Caratheodory.lean index 2c6cbf77bef644..e20d3217288305 100644 --- a/Mathlib/MeasureTheory/OuterMeasure/Caratheodory.lean +++ b/Mathlib/MeasureTheory/OuterMeasure/Caratheodory.lean @@ -136,7 +136,7 @@ theorem isCaratheodory_iUnion_of_disjoint {s : ℕ → Set α} (h : ∀ i, IsCar apply (isCaratheodory_iff_le' m).mpr intro t have hp : m (t ∩ ⋃ i, s i) ≤ ⨆ n, m (t ∩ ⋃ i < n, s i) := by - convert measure_iUnion_le (μ := m) fun i => t ∩ s i using 1 + convert! measure_iUnion_le (μ := m) fun i => t ∩ s i using 1 · simp [inter_iUnion] · simp [ENNReal.tsum_eq_iSup_nat, isCaratheodory_sum m h hd] grw [hp, ENNReal.iSup_add] @@ -214,7 +214,7 @@ theorem boundedBy_caratheodory {m : Set α → ℝ≥0∞} {s : Set α} apply ofFunction_caratheodory; intro t rcases t.eq_empty_or_nonempty with rfl | h · simp [Set.not_nonempty_empty] - · convert le_trans _ (hs t) + · convert! le_trans _ (hs t) · simp [h] exact add_le_add iSup_const_le iSup_const_le diff --git a/Mathlib/MeasureTheory/PiSystem.lean b/Mathlib/MeasureTheory/PiSystem.lean index df2010b2821d6a..1c6e968a10f640 100644 --- a/Mathlib/MeasureTheory/PiSystem.lean +++ b/Mathlib/MeasureTheory/PiSystem.lean @@ -591,7 +591,7 @@ inductive GenerateHas (s : Set (Set α)) : Set α → Prop theorem generateHas_compl {C : Set (Set α)} {s : Set α} : GenerateHas C sᶜ ↔ GenerateHas C s := by refine ⟨?_, GenerateHas.compl⟩ intro h - convert GenerateHas.compl h + convert! GenerateHas.compl h simp /-- The least Dynkin system containing a collection of basic sets. -/ diff --git a/Mathlib/MeasureTheory/SetSemiring.lean b/Mathlib/MeasureTheory/SetSemiring.lean index 3c9c34536d34d4..e024efd66574e6 100644 --- a/Mathlib/MeasureTheory/SetSemiring.lean +++ b/Mathlib/MeasureTheory/SetSemiring.lean @@ -270,7 +270,7 @@ lemma exists_disjoint_finset_diff_eq (hC : IsSetSemiring C) (hs : s ∈ C) (hI : refine hxy ?_ refine Subtype.ext ?_ exact h_dis.elim x.prop y.prop h_contra - convert hJu_disj' (x : Set α) (h_ss x.prop) y (h_ss y.prop) hxy_disj + convert! hJu_disj' (x : Set α) (h_ss x.prop) y (h_ss y.prop) hxy_disj · rw [sUnion_eq_biUnion] congr · rw [sUnion_eq_biUnion] diff --git a/Mathlib/MeasureTheory/VectorMeasure/AddContent.lean b/Mathlib/MeasureTheory/VectorMeasure/AddContent.lean index b296f2ba2d867e..1869bb1a95dc1f 100644 --- a/Mathlib/MeasureTheory/VectorMeasure/AddContent.lean +++ b/Mathlib/MeasureTheory/VectorMeasure/AddContent.lean @@ -83,7 +83,6 @@ def of_additive_of_le_measure open scoped ENNReal -set_option backward.isDefEq.respectTransparency false in /-- Consider an additive content on a dense ring of sets. Assume that it is dominated by a finite positive measure. Then it extends to a countably additive vector measure. -/ lemma exists_extension_of_isSetRing_of_le_measure_of_dense [IsFiniteMeasure μ] @@ -144,7 +143,7 @@ lemma exists_extension_of_isSetRing_of_le_measure_of_dense [IsFiniteMeasure μ] apply C'_dense.mono intro s hs simp only [Set.mem_setOf_eq] - convert hm s (C'C s hs) + convert! hm s (C'C s hs) exact C'_dense.extend_eq lip.continuous ⟨s, hs⟩ simpa only [Dense, IsClosed.closure_eq, Set.mem_setOf_eq] using this /- Most involved technical step: show that the extension `m₁` of `m₀` is still finitely diff --git a/Mathlib/MeasureTheory/VectorMeasure/Basic.lean b/Mathlib/MeasureTheory/VectorMeasure/Basic.lean index e45965e0dbc9f6..4974567cc92ada 100644 --- a/Mathlib/MeasureTheory/VectorMeasure/Basic.lean +++ b/Mathlib/MeasureTheory/VectorMeasure/Basic.lean @@ -129,7 +129,7 @@ theorem hasSum_of_disjoint_iUnion (hm : ∀ i, MeasurableSet (f i)) (hd : Pairwi HasSum (fun i => v (f i)) (v (⋃ i, f i)) := by rcases Countable.exists_injective_nat β with ⟨e, he⟩ rw [← hasSum_extend_zero he] - convert m_iUnion v (f := Function.extend e f fun _ ↦ ∅) _ _ + convert! m_iUnion v (f := Function.extend e f fun _ ↦ ∅) _ _ · simp only [Pi.zero_def, Function.apply_extend v, Function.comp_def, empty] · exact (iSup_extend_bot he _).symm · simp [Function.apply_extend MeasurableSet, Function.comp_def, hm] @@ -226,7 +226,7 @@ theorem tendsto_vectorMeasure_iUnion_atTop_nat have : HasSum (fun n ↦ v (t n)) (v (⋃ n, s n)) := by rw [← iUnion_disjointed] apply m_iUnion _ ht (disjoint_disjointed _) - convert (HasSum.tendsto_sum_nat this).comp (tendsto_add_atTop_nat 1) with n + convert! (HasSum.tendsto_sum_nat this).comp (tendsto_add_atTop_nat 1) with n dsimp rw [← of_biUnion_finset] · rw [biUnion_range_succ_disjointed, Monotone.partialSups_eq hm] @@ -282,6 +282,18 @@ instance instZero : Zero (VectorMeasure α M) := instance instInhabited : Inhabited (VectorMeasure α M) := ⟨0⟩ +@[nontriviality] +lemma apply_eq_zero_of_isEmpty [IsEmpty α] (μ : VectorMeasure α M) (s : Set α) : + μ s = 0 := by + simp [eq_empty_of_isEmpty s] + +instance [IsEmpty α] : Subsingleton (VectorMeasure α M) := + ⟨fun μ ν => by ext; rw [apply_eq_zero_of_isEmpty, apply_eq_zero_of_isEmpty]⟩ + +@[nontriviality] +theorem eq_zero_of_isEmpty [IsEmpty α] (μ : VectorMeasure α M) : μ = 0 := + Subsingleton.elim μ 0 + @[simp] theorem coe_zero : ⇑(0 : VectorMeasure α M) = 0 := rfl @@ -314,6 +326,10 @@ def coeFnAddMonoidHom : VectorMeasure α M →+ Set α → M where map_zero' := coe_zero map_add' := coe_add +@[simp] +theorem coe_finsetSum {ι} (I : Finset ι) (v : ι → VectorMeasure α M) : + ⇑(∑ i ∈ I, v i) = ∑ i ∈ I, ⇑(v i) := map_sum coeFnAddMonoidHom v I + end AddCommMonoid section AddCommGroup @@ -558,7 +574,7 @@ def map (v : VectorMeasure α M) (f : α → β) : VectorMeasure β M := not_measurable' := fun _ hi => if_neg hi m_iUnion' := by intro g hg₁ hg₂ - convert v.m_iUnion (fun i => hf (hg₁ i)) fun i j hij => (hg₂ hij).preimage _ + convert! v.m_iUnion (fun i => hf (hg₁ i)) fun i j hij => (hg₂ hij).preimage _ · rw [if_pos (hg₁ _)] · rw [Set.preimage_iUnion, if_pos (MeasurableSet.iUnion hg₁)] } else 0 @@ -656,7 +672,8 @@ def restrict (v : VectorMeasure α M) (i : Set α) : VectorMeasure α M := not_measurable' := fun _ hi => if_neg hi m_iUnion' := by intro f hf₁ hf₂ - convert v.m_iUnion (fun n => (hf₁ n).inter hi) + convert! + v.m_iUnion (fun n => (hf₁ n).inter hi) (hf₂.mono fun i j => Disjoint.mono inf_le_left inf_le_left) · rw [if_pos (hf₁ _)] · rw [Set.iUnion_inter, if_pos (MeasurableSet.iUnion hf₁)] } @@ -1199,7 +1216,7 @@ def trim {m n : MeasurableSpace α} (v : VectorMeasure α M) (hle : m ≤ n) : (fun f hf₁ hf₂ => by dsimp only have hf₁' : ∀ k, MeasurableSet[n] (f k) := fun k => hle _ (hf₁ k) - convert v.m_iUnion hf₁' hf₂ using 1 + convert! v.m_iUnion hf₁' hf₂ using 1 · ext n rw [if_pos (hf₁ n)] · rw [if_pos (@MeasurableSet.iUnion _ _ m _ _ hf₁)]) diff --git a/Mathlib/MeasureTheory/VectorMeasure/BoundedVariation.lean b/Mathlib/MeasureTheory/VectorMeasure/BoundedVariation.lean index 73cf1ce8eccf08..6cfb1d2441bbdf 100644 --- a/Mathlib/MeasureTheory/VectorMeasure/BoundedVariation.lean +++ b/Mathlib/MeasureTheory/VectorMeasure/BoundedVariation.lean @@ -96,7 +96,7 @@ private lemma exists_vectorMeasure_le_measureAux (hf : BoundedVariationOn f univ exact eVariationOn.edist_le _ (by grind) (by grind) have B : hα = generateFrom {s | ∃ u v, u ≤ v ∧ s = Ioc u v} := by borelize α - convert borel_eq_generateFrom_Ioc_le α using 2 + convert! borel_eq_generateFrom_Ioc_le α using 2 grind only rcases VectorMeasure.exists_extension_of_isSetSemiring_of_le_measure_of_generateFrom IsSetSemiring.Ioc A B with ⟨m', hm', h'm'⟩ @@ -164,7 +164,7 @@ lemma vectorMeasure_singleton (hf : BoundedVariationOn f univ) : apply tendsto_const_nhds.sub have : Tendsto u atTop (𝓝[<] a) := tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ u_lim (Eventually.of_forall u_lt_a) - convert (hf.rightLim.tendsto_leftLim a).comp this using 2 + convert! (hf.rightLim.tendsto_leftLim a).comp this using 2 have : (𝓝[<] a).NeBot := by rw [← mem_closure_iff_nhdsWithin_neBot, closure_Iio' ⟨b, hb⟩] exact self_mem_Iic diff --git a/Mathlib/MeasureTheory/VectorMeasure/Decomposition/Hahn.lean b/Mathlib/MeasureTheory/VectorMeasure/Decomposition/Hahn.lean index b6cc5b8d51d598..892b8e9556e0a2 100644 --- a/Mathlib/MeasureTheory/VectorMeasure/Decomposition/Hahn.lean +++ b/Mathlib/MeasureTheory/VectorMeasure/Decomposition/Hahn.lean @@ -111,7 +111,7 @@ private def findExistsOneDivLT (s : SignedMeasure α) (i : Set α) : ℕ := private theorem findExistsOneDivLT_spec (hi : ¬s ≤[i] 0) : ExistsOneDivLT s i (findExistsOneDivLT s i) := by rw [findExistsOneDivLT, dif_pos hi] - convert Nat.find_spec (existsNatOneDivLTMeasure_of_not_negative hi) + convert! Nat.find_spec (existsNatOneDivLTMeasure_of_not_negative hi) private theorem findExistsOneDivLT_min (hi : ¬s ≤[i] 0) {m : ℕ} (hm : m < findExistsOneDivLT s i) : ¬ExistsOneDivLT s i m := by @@ -196,7 +196,7 @@ private theorem measure_of_restrictNonposSeq (hi₂ : ¬s ≤[i] 0) (n : ℕ) rw [restrictNonposSeq_succ] have h₁ : ¬s ≤[i \ ⋃ (k : ℕ) (_ : k ≤ n), restrictNonposSeq s i k] 0 := by refine mt (restrict_le_zero_subset _ ?_ (by simp)) hn - convert measurable_of_not_restrict_le_zero _ hn using 3 + convert! measurable_of_not_restrict_le_zero _ hn using 3 exact funext fun x => by rw [Nat.lt_succ_iff] rcases someExistsOneDivLT_spec h₁ with ⟨_, _, h⟩ exact lt_trans Nat.one_div_pos_of_nat h @@ -250,11 +250,11 @@ private theorem exists_subset_restrict_nonpos' (hi₁ : MeasurableSet i) (hi₂ exact lt_of_lt_of_le hi₂ this refine tsum_nonneg ?_ intro l; by_cases h : l < k - · convert h₁ _ h + · convert! h₁ _ h ext x rw [Set.mem_iUnion, exists_prop, and_iff_right_iff_imp] exact fun _ => h - · convert le_of_eq s.empty.symm + · convert! le_of_eq s.empty.symm ext; simp only [exists_prop, Set.mem_empty_iff_false, Set.mem_iUnion, not_and, iff_false] exact fun h' => False.elim (h h') · intro; exact MeasurableSet.iUnion fun _ => restrictNonposSeq_measurableSet _ @@ -279,7 +279,7 @@ theorem exists_subset_restrict_nonpos (hi : s i < 0) : set bdd : ℕ → ℕ := fun n => findExistsOneDivLT s (i \ ⋃ k ≤ n, restrictNonposSeq s i k) have hn' : ∀ n : ℕ, ¬s ≤[i \ ⋃ l ≤ n, restrictNonposSeq s i l] 0 := by intro n - convert hn (n + 1) using 5 <;> + convert! hn (n + 1) using 5 <;> · ext l simp only [exists_prop, Set.mem_iUnion, and_congr_left_iff] exact fun _ => Nat.lt_succ_iff.symm @@ -304,7 +304,7 @@ theorem exists_subset_restrict_nonpos (hi : s i < 0) : simp only [one_div] at h₃' exact Summable.tendsto_atTop_of_pos h₃' fun n => Nat.cast_add_one_pos (bdd n) have h₄ : Tendsto (fun n => (bdd n : ℝ)) atTop atTop := by - convert atTop.tendsto_atTop_add_const_right (-1) h₃; simp + convert! atTop.tendsto_atTop_add_const_right (-1) h₃; simp have A_meas : MeasurableSet A := hi₁.diff (MeasurableSet.iUnion fun _ => restrictNonposSeq_measurableSet _) refine ⟨A, A_meas, Set.diff_subset, ?_, h₂.trans_lt hi⟩ @@ -327,7 +327,7 @@ theorem exists_subset_restrict_nonpos (hi : s i < 0) : refine findExistsOneDivLT_min (hn' k) (Nat.sub_lt hk₁ Nat.zero_lt_one) ⟨E, Set.Subset.trans hE₂ hA', hE₁, ?_⟩ - convert hk₂; norm_cast + convert! hk₂; norm_cast exact tsub_add_cancel_of_le hk₁ end ExistsSubsetRestrictNonpos diff --git a/Mathlib/MeasureTheory/VectorMeasure/Decomposition/Lebesgue.lean b/Mathlib/MeasureTheory/VectorMeasure/Decomposition/Lebesgue.lean index 70f8dbd0485241..e86f35d52639ce 100644 --- a/Mathlib/MeasureTheory/VectorMeasure/Decomposition/Lebesgue.lean +++ b/Mathlib/MeasureTheory/VectorMeasure/Decomposition/Lebesgue.lean @@ -196,7 +196,7 @@ theorem singularPart_add_withDensity_rnDeriv_eq [s.HaveLebesgueDecomposition μ] add_assoc (-(s.toJordanDecomposition.negPart.singularPart μ).toSignedMeasure), ← toSignedMeasure_add, add_comm, ← add_assoc, ← neg_add, ← toSignedMeasure_add, add_comm, ← sub_eq_add_neg] - · convert rfl + · convert! rfl -- `convert rfl` much faster than `congr` · exact s.toJordanDecomposition.posPart.haveLebesgueDecomposition_add μ · rw [add_comm] @@ -294,7 +294,7 @@ theorem eq_singularPart (t : SignedMeasure α) (f : α → ℝ) (htμ : t ⟂ᵥ (hadd : s = t + μ.withDensityᵥ f) : t = s.singularPart μ := by by_cases hfi : Integrable f μ · refine eq_singularPart' t hfi.1.measurable_mk (hfi.congr hfi.1.ae_eq_mk) htμ ?_ - convert hadd using 2 + convert! hadd using 2 exact WithDensityᵥEq.congr_ae hfi.1.ae_eq_mk.symm · rw [withDensityᵥ, dif_neg hfi, add_zero] at hadd refine eq_singularPart' t measurable_zero (integrable_zero _ _ μ) htμ ?_ @@ -362,7 +362,7 @@ theorem eq_rnDeriv (t : SignedMeasure α) (f : α → ℝ) (hfi : Integrable f f =ᵐ[μ] s.rnDeriv μ := by set f' := hfi.1.mk f have hadd' : s = t + μ.withDensityᵥ f' := by - convert hadd using 2 + convert! hadd using 2 exact WithDensityᵥEq.congr_ae hfi.1.ae_eq_mk.symm have := haveLebesgueDecomposition_mk μ hfi.1.measurable_mk htμ hadd' refine (Integrable.ae_eq_of_withDensityᵥ_eq (integrable_rnDeriv _ _) hfi ?_).symm diff --git a/Mathlib/MeasureTheory/VectorMeasure/Integral.lean b/Mathlib/MeasureTheory/VectorMeasure/Integral.lean index 201814264e89b9..0eeaf32ac5d4ee 100644 --- a/Mathlib/MeasureTheory/VectorMeasure/Integral.lean +++ b/Mathlib/MeasureTheory/VectorMeasure/Integral.lean @@ -1,7 +1,7 @@ /- Copyright (c) 2025 Yoh Tanimoto. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. -Authors: Yoh Tanimoto +Authors: Yoh Tanimoto, Yongxi Lin -/ module @@ -63,7 +63,7 @@ public section open Set MeasureTheory VectorMeasure ContinuousLinearMap -variable {X E F G : Type*} {mX : MeasurableSpace X} +variable {ι X E F G : Type*} {mX : MeasurableSpace X} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] [NormedAddCommGroup G] [NormedSpace ℝ G] @@ -134,61 +134,271 @@ noncomputable def integral (μ : VectorMeasure X F) (f : X → E) (B : E →L[ else 0 @[inherit_doc integral] -notation3 "∫ᵛ "(...)", "r:60:(scoped f => f)" ∂["B:70"; "μ:70"]" => integral μ r B +notation3 "∫ᵛ "(...)", "r:60:(scoped f => f)" ∂["B:65"; "μ:65"]" => integral μ r B /-- The special case of the pairing integral where the pairing is just the scalar multiplication by `ℝ` on `F` and `f` is real-valued. The resulting integral is `F`-valued.-/ notation3 "∫ᵛ "(...)", "r:60:(scoped f => f)" ∂•"μ:70 => integral μ r (lsmul ℝ ℝ) -variable {μ : VectorMeasure X F} {B : E →L[ℝ] F →L[ℝ] G} +variable {f g : X → E} {μ ν : VectorMeasure X F} {B C : E →L[ℝ] F →L[ℝ] G} -theorem integral_fun_add {f g : X → E} (hf : μ.Integrable f B) (hg : μ.Integrable g B) : +@[simp] +theorem transpose_zero_vectorMeasure (B : E →L[ℝ] F →L[ℝ] G) : + (0 : VectorMeasure X F).transpose B = 0 := by + simp [transpose] + +@[simp] +theorem transpose_zero_cbm (μ : VectorMeasure X F) : + μ.transpose (0 : E →L[ℝ] F →L[ℝ] G) = 0 := by + ext + simp [transpose] + +@[simp] +theorem transpose_add_vectorMeasure (μ ν : VectorMeasure X F) (B : E →L[ℝ] F →L[ℝ] G) : + (μ + ν).transpose B = μ.transpose B + ν.transpose B := by + simp [transpose] + +@[simp] +theorem transpose_add_cbm (μ : VectorMeasure X F) (B C : E →L[ℝ] F →L[ℝ] G) : + μ.transpose (B + C) = μ.transpose B + μ.transpose C := by + ext + simp [transpose] + +@[simp] +theorem transpose_finsetSum_vectorMeasure (μ : ι → VectorMeasure X F) (B : E →L[ℝ] F →L[ℝ] G) + (s : Finset ι) : + (∑ i ∈ s, μ i).transpose B = ∑ i ∈ s, (μ i).transpose B := by + classical + induction s using Finset.induction_on with + | empty => simp + | insert i s his ih => simp [Finset.sum_insert, his, ih] + +@[simp] +theorem transpose_finsetSum_cbm (μ : VectorMeasure X F) (B : ι → E →L[ℝ] F →L[ℝ] G) (s : Finset ι) : + μ.transpose (∑ i ∈ s, B i) = ∑ i ∈ s, μ.transpose (B i) := by + classical + induction s using Finset.induction_on with + | empty => simp + | insert i s his ih => simp [Finset.sum_insert, his, ih] + +@[simp] +theorem transpose_neg_vectorMeasure (μ : VectorMeasure X F) (B : E →L[ℝ] F →L[ℝ] G) : + (-μ).transpose B = - (μ.transpose B) := by + ext + simp [transpose] + +@[simp] +theorem transpose_neg_cbm (μ : VectorMeasure X F) (B : E →L[ℝ] F →L[ℝ] G) : + μ.transpose (-B) = - (μ.transpose B) := by + ext + simp [transpose] + +@[simp] +theorem transpose_sub_vectorMeasure (μ ν : VectorMeasure X F) (B : E →L[ℝ] F →L[ℝ] G) : + (μ - ν).transpose B = μ.transpose B - ν.transpose B := by + ext + simp [transpose] + +@[simp] +theorem transpose_sub_cbm (μ : VectorMeasure X F) (B C : E →L[ℝ] F →L[ℝ] G) : + μ.transpose (B - C) = μ.transpose B - μ.transpose C := by + ext + simp [transpose] + +section Function + +theorem integral_undef (h : ¬ μ.Integrable f B) : + ∫ᵛ x, f x ∂[B; μ] = 0 := by + by_cases hG : CompleteSpace G + · simp [integral, setToFun_undef _ h] + · simp [integral, hG] + +@[simp] +theorem integral_zero : ∫ᵛ _, 0 ∂[B; μ] = 0 := by + by_cases hG : CompleteSpace G + · simp only [integral, hG] + exact setToFun_zero (dominatedFinMeasAdditive_cbmApplyMeasure μ B) + · simp [integral, hG] + +theorem integral_congr_ae (h : f =ᵐ[(μ.transpose B).variation] g) : + ∫ᵛ x, f x ∂[B; μ] = ∫ᵛ x, g x ∂[B; μ] := by + by_cases hG : CompleteSpace G + · simp only [integral, hG] + exact setToFun_congr_ae (dominatedFinMeasAdditive_cbmApplyMeasure μ B) h + · simp [integral, hG] + +theorem integral_eq_zero_of_ae (hf : f =ᵐ[(μ.transpose B).variation] 0) : + ∫ᵛ x, f x ∂[B; μ] = 0 := by + simp [integral_congr_ae hf] + +theorem integral_fun_add (hf : μ.Integrable f B) (hg : μ.Integrable g B) : ∫ᵛ x, f x + g x ∂[B; μ] = ∫ᵛ x, f x ∂[B; μ] + ∫ᵛ x, g x ∂[B; μ] := by by_cases hG : CompleteSpace G · simp only [integral, hG] exact setToFun_add (dominatedFinMeasAdditive_cbmApplyMeasure μ B) hf hg · simp [integral, hG] -theorem integral_add {f g : X → E} (hf : μ.Integrable f B) (hg : μ.Integrable g B) : +theorem integral_add (hf : μ.Integrable f B) (hg : μ.Integrable g B) : ∫ᵛ x, (f + g) x ∂[B; μ] = ∫ᵛ x, f x ∂[B; μ] + ∫ᵛ x, g x ∂[B; μ] := integral_fun_add hf hg -variable (μ B) in +theorem integral_finsetSum (s : Finset ι) {f : ι → X → E} + (hf : ∀ i ∈ s, μ.Integrable (f i) B) : + ∫ᵛ x, ∑ i ∈ s, f i x ∂[B; μ] = ∑ i ∈ s, ∫ᵛ x, f i x ∂[B; μ] := by + by_cases hG : CompleteSpace G + · simp only [integral, hG] + exact setToFun_finsetSum (dominatedFinMeasAdditive_cbmApplyMeasure μ B) s hf + · simp [integral, hG] + +variable (f μ B) in @[integral_simps] -theorem integral_fun_neg (f : X → E) : +theorem integral_fun_neg : ∫ᵛ x, -f x ∂[B; μ]= -∫ᵛ x, f x ∂[B; μ] := by by_cases hG : CompleteSpace G · simp only [integral, hG, ↓reduceDIte, transpose_eq_cbmApplyMeasure] exact setToFun_neg (dominatedFinMeasAdditive_cbmApplyMeasure μ B) f · simp [integral, hG] -variable (μ B) in +variable (f μ B) in @[integral_simps] -theorem integral_neg (f : X → E) : - ∫ᵛ x, (-f) x ∂[B; μ] = -∫ᵛ x, f x ∂[B; μ] := integral_fun_neg μ B f +theorem integral_neg : + ∫ᵛ x, (-f) x ∂[B; μ] = -∫ᵛ x, f x ∂[B; μ] := integral_fun_neg f μ B -theorem integral_fun_sub {f g : X → E} (hf : μ.Integrable f B) (hg : μ.Integrable g B) : +theorem integral_fun_sub (hf : μ.Integrable f B) (hg : μ.Integrable g B) : ∫ᵛ x, f x - g x ∂[B; μ] = ∫ᵛ x, f x ∂[B; μ] - ∫ᵛ x, g x ∂[B; μ] := by by_cases hG : CompleteSpace G · simp only [integral, hG] exact setToFun_sub (dominatedFinMeasAdditive_cbmApplyMeasure μ B) hf hg · simp [integral, hG] -theorem integral_sub {f g : X → E} (hf : μ.Integrable f B) (hg : μ.Integrable g B) : +theorem integral_sub (hf : μ.Integrable f B) (hg : μ.Integrable g B) : ∫ᵛ x, (f - g) x ∂[B; μ] = ∫ᵛ x, f x ∂[B; μ] - ∫ᵛ x, g x ∂[B; μ] := integral_fun_sub hf hg -variable (μ B) in +variable (f μ B) in @[integral_simps] -theorem integral_fun_smul (c : ℝ) (f : X → E) : +theorem integral_fun_smul (c : ℝ) : ∫ᵛ x, c • f x ∂[B; μ] = c • ∫ᵛ x, f x ∂[B; μ] := by by_cases hG : CompleteSpace G · simp only [integral, hG] exact setToFun_smul (dominatedFinMeasAdditive_cbmApplyMeasure μ B) (by simp) c f · simp [integral, hG] -variable (μ B) in +variable (f μ B) in @[integral_simps] -theorem integral_smul (c : ℝ) (f : X → E) : - ∫ᵛ x, (c • f) x ∂[B; μ] = c • ∫ᵛ x, f x ∂[B; μ] := integral_fun_smul μ B c f +theorem integral_smul (c : ℝ) : + ∫ᵛ x, (c • f) x ∂[B; μ] = c • ∫ᵛ x, f x ∂[B; μ] := integral_fun_smul f μ B c + +end Function + +section VectorMeasure + +variable (f μ B) in +@[simp] +theorem integral_zero_vectorMeasure : + ∫ᵛ x, f x ∂[B; (0 : VectorMeasure X F)] = 0 := by simp [integral] + +lemma integral_of_isEmpty [IsEmpty X] : ∫ᵛ x, f x ∂[B; μ] = 0 := by simp [eq_zero_of_isEmpty] + +theorem integral_add_vectorMeasure (hμ : μ.Integrable f B) (hν : ν.Integrable f B) : + ∫ᵛ x, f x ∂[B; μ + ν] = ∫ᵛ x, f x ∂[B; μ] + ∫ᵛ x, f x ∂[B; ν] := by + by_cases hG : CompleteSpace G + · simp only [integral, hG, ↓reduceDIte, transpose_add_vectorMeasure, coe_add, + transpose_eq_cbmApplyMeasure, ← setToFun_add_measure + (dominatedFinMeasAdditive_cbmApplyMeasure μ B) + (dominatedFinMeasAdditive_cbmApplyMeasure ν B) hμ hν] + refine (setToFun_congr_measure_of_integrable 1 ENNReal.one_ne_top ?_ _ _ f ?_).symm + · simpa using variation_add_le + · exact hμ.add_measure hν + · simp [integral, hG] + +theorem integral_finsetSum_vectorMeasure {μ : ι → VectorMeasure X F} + {s : Finset ι} (hf : ∀ i ∈ s, (μ i).Integrable f B) : + ∫ᵛ x, f x ∂[B; ∑ i ∈ s, μ i] = ∑ i ∈ s, ∫ᵛ x, f x ∂[B; μ i] := by + by_cases hG : CompleteSpace G + · by_cases! hs : s.Nonempty + · simp only [integral, hG, ↓reduceDIte, transpose_finsetSum_vectorMeasure, coe_finsetSum, + transpose_eq_cbmApplyMeasure, ← setToFun_finsetSum_measure hs + (fun i ↦ dominatedFinMeasAdditive_cbmApplyMeasure (μ i) B) hf] + refine (setToFun_congr_measure_of_integrable 1 ENNReal.one_ne_top ?_ _ _ f ?_).symm + · simpa using variation_finsetSum_le s _ + · exact integrable_finsetSum_measure.2 hf + · simp_all + · simp [integral, hG] + +variable (f μ B) in +@[integral_simps] +theorem integral_neg_vectorMeasure : + ∫ᵛ x, f x ∂[B; -μ] = -∫ᵛ x, f x ∂[B; μ] := by + by_cases hG : CompleteSpace G + · simp [integral, hG, ← setToFun_neg'] + · simp [integral, hG] + +theorem integral_sub_vectorMeasure (hμ : μ.Integrable f B) (hν : ν.Integrable f B) : + ∫ᵛ x, f x ∂[B; μ - ν] = ∫ᵛ x, f x ∂[B; μ] - ∫ᵛ x, f x ∂[B; ν] := by + by_cases hG : CompleteSpace G + · simp only [integral, hG, ↓reduceDIte, transpose_sub_vectorMeasure, coe_sub, + transpose_eq_cbmApplyMeasure, ← setToFun_sub_measure + (dominatedFinMeasAdditive_cbmApplyMeasure μ B) + (dominatedFinMeasAdditive_cbmApplyMeasure ν B) hμ hν] + refine (setToFun_congr_measure_of_integrable 1 ENNReal.one_ne_top ?_ _ _ f ?_).symm + · simpa using variation_sub_le + · exact hμ.add_measure hν + · simp [integral, hG] + +end VectorMeasure + +section cbm + +variable (f μ) in +@[simp] +theorem integral_zero_cbm : + ∫ᵛ x, f x ∂[(0 : E →L[ℝ] F →L[ℝ] G); μ] = 0 := by + simp [integral] + +theorem integral_add_cbm (hB : μ.Integrable f B) (hC : μ.Integrable f C) : + ∫ᵛ x, f x ∂[B + C; μ] = ∫ᵛ x, f x ∂[B; μ] + ∫ᵛ x, f x ∂[C; μ] := by + by_cases hG : CompleteSpace G + · simp only [integral, hG, ↓reduceDIte, transpose_add_cbm, coe_add, transpose_eq_cbmApplyMeasure, + ← setToFun_add_measure (dominatedFinMeasAdditive_cbmApplyMeasure μ B) + (dominatedFinMeasAdditive_cbmApplyMeasure μ C) hB hC] + refine (setToFun_congr_measure_of_integrable 1 ENNReal.one_ne_top ?_ _ _ f ?_).symm + · simpa using variation_add_le + · exact hB.add_measure hC + · simp [integral, hG] + +theorem integral_finsetSum_cbm {B : ι → E →L[ℝ] F →L[ℝ] G} + {s : Finset ι} (hf : ∀ i ∈ s, μ.Integrable f (B i)) : + ∫ᵛ x, f x ∂[∑ i ∈ s, B i; μ] = ∑ i ∈ s, ∫ᵛ x, f x ∂[B i; μ] := by + by_cases hG : CompleteSpace G + · by_cases! hs : s.Nonempty + · simp only [integral, hG, ↓reduceDIte, transpose_finsetSum_cbm, coe_finsetSum, + transpose_eq_cbmApplyMeasure, ← setToFun_finsetSum_measure hs + (fun i ↦ dominatedFinMeasAdditive_cbmApplyMeasure μ (B i)) hf] + refine (setToFun_congr_measure_of_integrable 1 ENNReal.one_ne_top ?_ _ _ f ?_).symm + · simpa using variation_finsetSum_le s _ + · exact integrable_finsetSum_measure.2 hf + · simp_all + · simp [integral, hG] + +@[integral_simps] +theorem integral_neg_cbm : + ∫ᵛ x, f x ∂[-B; μ] = -∫ᵛ x, f x ∂[B; μ] := by + by_cases hG : CompleteSpace G + · simp [integral, hG, ← setToFun_neg'] + · simp [integral, hG] + +theorem integral_sub_cbm (hB : μ.Integrable f B) (hC : μ.Integrable f C) : + ∫ᵛ x, f x ∂[B - C; μ] = ∫ᵛ x, f x ∂[B; μ] - ∫ᵛ x, f x ∂[C; μ] := by + by_cases hG : CompleteSpace G + · simp only [integral, hG, ↓reduceDIte, transpose_sub_cbm, coe_sub, + transpose_eq_cbmApplyMeasure, ← setToFun_sub_measure + (dominatedFinMeasAdditive_cbmApplyMeasure μ B) + (dominatedFinMeasAdditive_cbmApplyMeasure μ C) hB hC] + refine (setToFun_congr_measure_of_integrable 1 ENNReal.one_ne_top ?_ _ _ f ?_).symm + · simpa using variation_sub_le + · exact hB.add_measure hC + · simp [integral, hG] + +end cbm end VectorMeasure diff --git a/Mathlib/MeasureTheory/VectorMeasure/WithDensity.lean b/Mathlib/MeasureTheory/VectorMeasure/WithDensity.lean index 6d4bca7b8207b9..88605419c9f9c4 100644 --- a/Mathlib/MeasureTheory/VectorMeasure/WithDensity.lean +++ b/Mathlib/MeasureTheory/VectorMeasure/WithDensity.lean @@ -48,7 +48,7 @@ def Measure.withDensityᵥ {m : MeasurableSpace α} (μ : Measure α) (f : α empty' := by simp not_measurable' := fun _ hs => if_neg hs m_iUnion' := fun s hs₁ hs₂ => by - convert hasSum_integral_iUnion hs₁ hs₂ hf.integrableOn with n + convert! hasSum_integral_iUnion hs₁ hs₂ hf.integrableOn with n · rw [if_pos (hs₁ n)] · rw [if_pos (MeasurableSet.iUnion hs₁)] } else 0 diff --git a/Mathlib/ModelTheory/Arithmetic/Presburger/Definability.lean b/Mathlib/ModelTheory/Arithmetic/Presburger/Definability.lean index 3e2b29a5a921d5..dbdb246371611b 100644 --- a/Mathlib/ModelTheory/Arithmetic/Presburger/Definability.lean +++ b/Mathlib/ModelTheory/Arithmetic/Presburger/Definability.lean @@ -116,17 +116,17 @@ lemma isSemilinearSet_boundedFormula_realize {n} (φ : presburger[[A]].BoundedFo | equal t₁ t₂ => rcases term_realize_eq_add_dotProduct t₁ with ⟨k₁, u₁, ht₁⟩ rcases term_realize_eq_add_dotProduct t₂ with ⟨k₂, u₂, ht₂⟩ - convert Nat.isSemilinearSet_setOf_mulVec_eq ![k₁] ![k₂] (.of ![u₁]) (.of ![u₂]) + convert! Nat.isSemilinearSet_setOf_mulVec_eq ![k₁] ![k₂] (.of ![u₁]) (.of ![u₂]) simp [ht₁, ht₂] | rel f => nomatch f | falsum => exact .empty | imp _ _ ih₁ ih₂ => - convert (ih₂.compl.inter ih₁).compl using 1 + convert! (ih₂.compl.inter ih₁).compl using 1 simp [setOf_inter_eq_sep, imp_iff_not_or, compl_setOf] | @all n φ ih => let e := (Equiv.sumAssoc α (Fin n) (Fin 1)).trans (Equiv.sumCongr (.refl α) finSumFinEquiv) rw [← isSemilinearSet_image_iff (LinearEquiv.funCongrLeft ℕ ℕ e)] at ih - convert ih.compl.proj.compl using 1 + convert! ih.compl.proj.compl using 1 simp_rw [compl_setOf, not_exists, Fin.forall_fin_succ_pi, Fin.forall_fin_zero_pi, mem_compl_iff, mem_image, not_not, ← LinearEquiv.eq_symm_apply, LinearEquiv.funCongrLeft_symm, exists_eq_right, mem_setOf, LinearEquiv.funCongrLeft_apply, LinearMap.funLeft, @@ -138,7 +138,7 @@ lemma isSemilinearSet_boundedFormula_realize {n} (φ : presburger[[A]].BoundedFo lemma isSemilinearSet_formula_realize_semilinear (φ : presburger[[A]].Formula α) : IsSemilinearSet (setOf φ.Realize : Set (α → ℕ)) := by let e := Equiv.sumEmpty α (Fin 0) - convert (isSemilinearSet_boundedFormula_realize φ).image (LinearMap.funLeft ℕ ℕ e.symm) + convert! (isSemilinearSet_boundedFormula_realize φ).image (LinearMap.funLeft ℕ ℕ e.symm) ext x simp only [mem_setOf_eq, mem_image] rw [(e.arrowCongr (.refl ℕ)).exists_congr_left] @@ -163,7 +163,7 @@ theorem mul_not_definable : ¬ A.Definable presburger {v : Fin 3 → ℕ | v 0 = intro hmul have hsqr : A.Definable₁ presburger {x * x | x : ℕ} := by rw [Definable₁] - convert (hmul.preimage_comp (β := Fin 2) ![0, 1, 1]).image_comp ![0] + convert! (hmul.preimage_comp (β := Fin 2) ![0, 1, 1]).image_comp ![0] ext simpa [funext_iff, Fin.exists_fin_succ_pi] using exists_congr fun _ => Eq.comm rw [definable₁_iff_ultimately_periodic] at hsqr diff --git a/Mathlib/ModelTheory/Arithmetic/Presburger/Semilinear/Basic.lean b/Mathlib/ModelTheory/Arithmetic/Presburger/Semilinear/Basic.lean index 10f0b5bcd9c80a..0759840f7cca0c 100644 --- a/Mathlib/ModelTheory/Arithmetic/Presburger/Semilinear/Basic.lean +++ b/Mathlib/ModelTheory/Arithmetic/Presburger/Semilinear/Basic.lean @@ -209,8 +209,9 @@ private lemma Nat.isSemilinearSet_preimage_of_isLinearSet [Finite ι] {F : Type* change IsSemilinearSet { x | f x ∈ _ } simp only [mem_vadd_set, mem_range, vadd_eq_add, exists_exists_eq_and] apply IsSemilinearSet.proj' - convert isSemilinearSet_setOf_eq a 0 (g.comp (LinearMap.funLeft ℕ ℕ Sum.inr).toAddMonoidHom) - ((f : (ι → ℕ) →+ M).comp (LinearMap.funLeft ℕ ℕ Sum.inl).toAddMonoidHom) + convert! + isSemilinearSet_setOf_eq a 0 (g.comp (LinearMap.funLeft ℕ ℕ Sum.inr).toAddMonoidHom) + ((f : (ι → ℕ) →+ M).comp (LinearMap.funLeft ℕ ℕ Sum.inl).toAddMonoidHom) simp [LinearMap.funLeft] private theorem Nat.isSemilinearSet_preimage [Finite ι] {F : Type*} @@ -275,8 +276,9 @@ private lemma Nat.isSemilinearSet_inter_of_isLinearSet [Finite ι] {s₁ s₂ : rcases hs₂ with ⟨v, m, B, rfl⟩ simp_rw [← setOf_and, exists_and_exists_comm] refine IsSemilinearSet.proj' (IsSemilinearSet.proj' ?_) - convert isSemilinearSet_setOf_mulVec_eq (κ := (ι ⊕ Fin n) ⊕ Fin m) (Sum.elim u v) 0 - (fromBlocks (fromCols 0 A) 0 0 B) (fromBlocks (fromCols 1 0) 0 (fromCols 1 0) 0) + convert! + isSemilinearSet_setOf_mulVec_eq (κ := (ι ⊕ Fin n) ⊕ Fin m) (Sum.elim u v) 0 + (fromBlocks (fromCols 0 A) 0 0 B) (fromBlocks (fromCols 1 0) 0 (fromCols 1 0) 0) simp [fromBlocks_mulVec, fromCols_mulVec, ← Sum.elim_add_add, Sum.elim_eq_iff] private theorem Nat.isSemilinearSet_inter [Finite ι] {s₁ s₂ : Set (ι → ℕ)} @@ -420,7 +422,7 @@ private theorem span_basisSet : span ℚ (toRatVec '' hs.basisSet) = ⊤ := by ← top_le_iff] apply (span_mono (image_mono subset_union_right)).trans' rw [top_le_iff] - convert (Pi.basisFun ℚ ι).span_eq + convert! (Pi.basisFun ℚ ι).span_eq ext simp only [mem_image, mem_range, exists_exists_eq_and] congr! @@ -584,7 +586,7 @@ private theorem mem_iff_fract_eq_and_floor_nonneg (x) : rw [Finset.sum_filter, ← hx₁] conv_rhs => rw [← add_zero x, ← Finset.sum_const_zero (ι := hs.basisSet) (s := Finset.univ)] - convert (hs.add_floor_neg_toNat_sum_eq x).symm using 3 with i _ i + convert! (hs.add_floor_neg_toNat_sum_eq x).symm using 3 with i _ i · split_ifs with hi · simp · simp [(hx₂ i).2 hi] @@ -619,9 +621,10 @@ private theorem isSemilinearSet_setOfFractNe : IsSemilinearSet hs.setOfFractNe : (.closure_of_finite hs.finite_basisSet) (LinearMap.funLeft ℕ ℕ Sum.inr) classical haveI := Fintype.ofFinite ι - convert Nat.isSemilinearSet_setOf_mulVec_eq (κ := (ι ⊕ ι) ⊕ ι) 0 i - (Matrix.fromCols (Matrix.fromCols 1 0) 1) (Matrix.fromCols (Matrix.fromCols 0 1) 0) - using 4 <;> simp [fromCols_mulVec] + convert! + Nat.isSemilinearSet_setOf_mulVec_eq (κ := (ι ⊕ ι) ⊕ ι) 0 i + (Matrix.fromCols (Matrix.fromCols 1 0) 1) (Matrix.fromCols (Matrix.fromCols 0 1) 0) using + 4 <;> simp [fromCols_mulVec] private noncomputable def setOfFloorNeg : Set (ι → ℕ) := { x | hs.fract x = hs.base ∧ ∃ i, hs.floor x i < 0 } @@ -680,9 +683,10 @@ private theorem isSemilinearSet_setOfFloorNeg : IsSemilinearSet hs.setOfFloorNeg apply Nat.isSemilinearSet_inter <| Nat.isSemilinearSet_preimage (.closure_of_finite hs.finite_basisSet.diff) (LinearMap.funLeft ℕ ℕ Sum.inr) haveI := Fintype.ofFinite ι - convert Nat.isSemilinearSet_setOf_mulVec_eq (κ := ((ι ⊕ ι) ⊕ ι) ⊕ ι) i.1 hs.base - (Matrix.fromCols (Matrix.fromCols (Matrix.fromCols 1 1) 0) 1) - (Matrix.fromCols (Matrix.fromCols (Matrix.fromCols 0 0) 1) 0) using 4 + convert! + Nat.isSemilinearSet_setOf_mulVec_eq (κ := ((ι ⊕ ι) ⊕ ι) ⊕ ι) i.1 hs.base + (Matrix.fromCols (Matrix.fromCols (Matrix.fromCols 1 1) 0) 1) + (Matrix.fromCols (Matrix.fromCols (Matrix.fromCols 0 0) 1) 0) using 4 <;> simp [add_comm _ i.1, add_assoc, fromCols_mulVec] private noncomputable def setOfFloorPos : Set (ι → ℕ) := @@ -740,7 +744,8 @@ private theorem isSemilinearSet_setOfFloorPos : IsSemilinearSet hs.setOfFloorPos apply Nat.isSemilinearSet_inter <| Nat.isSemilinearSet_preimage (.closure_of_finite hs.finite_basisSet.diff) (LinearMap.funLeft ℕ ℕ Sum.inr) haveI := Fintype.ofFinite ι - convert Nat.isSemilinearSet_setOf_mulVec_eq (κ := ((ι ⊕ ι) ⊕ ι) ⊕ ι) 0 (hs.base + i.1) + convert! + Nat.isSemilinearSet_setOf_mulVec_eq (κ := ((ι ⊕ ι) ⊕ ι) ⊕ ι) 0 (hs.base + i.1) (Matrix.fromCols (Matrix.fromCols (Matrix.fromCols 1 0) 0) 1) (Matrix.fromCols (Matrix.fromCols (Matrix.fromCols 0 1) 1) 0) using 4 <;> simp [add_assoc, fromCols_mulVec] @@ -749,8 +754,9 @@ end IsProperLinearSet private lemma Nat.isSemilinearSet_compl_of_isProperLinearSet [Finite ι] {s : Set (ι → ℕ)} (hs : IsProperLinearSet s) : IsSemilinearSet sᶜ := by - convert hs.isSemilinearSet_setOfFractNe.union <| hs.isSemilinearSet_setOfFloorNeg.union <| - hs.isSemilinearSet_setOfFloorPos using 1 + convert! + hs.isSemilinearSet_setOfFractNe.union <| + hs.isSemilinearSet_setOfFloorNeg.union <| hs.isSemilinearSet_setOfFloorPos using 1 ext simp only [mem_compl_iff, hs.mem_iff_fract_eq_and_floor_nonneg, IsProperLinearSet.setOfFractNe, IsProperLinearSet.setOfFloorNeg, IsProperLinearSet.setOfFloorPos, mem_union, mem_setOf_eq] diff --git a/Mathlib/ModelTheory/Arithmetic/Presburger/Semilinear/Defs.lean b/Mathlib/ModelTheory/Arithmetic/Presburger/Semilinear/Defs.lean index 5f5944cd3c0822..3cceccbb2e484a 100644 --- a/Mathlib/ModelTheory/Arithmetic/Presburger/Semilinear/Defs.lean +++ b/Mathlib/ModelTheory/Arithmetic/Presburger/Semilinear/Defs.lean @@ -203,7 +203,7 @@ theorem IsSemilinearSet.image (hs : IsSemilinearSet s) (f : F) : IsSemilinearSet theorem isSemilinearSet_image_iff {F : Type*} [EquivLike F M N] [AddEquivClass F M N] (f : F) : IsSemilinearSet (f '' s) ↔ IsSemilinearSet s := by constructor <;> intro h - · convert h.image (f : M ≃+ N).symm + · convert! h.image (f : M ≃+ N).symm simp [image_image] · exact h.image f @@ -211,7 +211,7 @@ theorem isSemilinearSet_image_iff {F : Type*} [EquivLike F M N] [AddEquivClass F the index). It is a special case of `IsSemilinearSet.image`. -/ theorem IsSemilinearSet.proj {s : Set (ι ⊕ κ → M)} (hs : IsSemilinearSet s) : IsSemilinearSet { x | ∃ y, Sum.elim x y ∈ s } := by - convert hs.image (LinearMap.funLeft ℕ M Sum.inl) + convert! hs.image (LinearMap.funLeft ℕ M Sum.inl) ext x constructor · intro ⟨y, hy⟩ @@ -227,7 +227,7 @@ theorem IsSemilinearSet.proj' {p : (ι → M) → (κ → M) → Prop} : protected lemma IsLinearSet.closure (hs : IsLinearSet s) : IsSemilinearSet (closure s : Set M) := by rcases hs with ⟨a, t, ht, rfl⟩ - convert (IsSemilinearSet.singleton 0).union (isSemilinearSet ⟨a, {a} ∪ t, by simp [ht], rfl⟩) + convert! (IsSemilinearSet.singleton 0).union (isSemilinearSet ⟨a, { a } ∪ t, by simp [ht], rfl⟩) ext x simp only [SetLike.mem_coe, singleton_union, mem_insert_iff, mem_vadd_set, vadd_eq_add] constructor @@ -356,7 +356,8 @@ lemma IsLinearSet.isProperSemilinearSet [IsCancelAdd M] (hs : IsLinearSet s) : induction hn : g i using Nat.strong_induction_on generalizing g with | _ n ih' subst hn by_cases! hfg : ∀ j ∈ t', f j ≤ g j - · convert ih' (g i - f i) (Nat.sub_lt_self hfi (hfg i hi)) + · convert! + ih' (g i - f i) (Nat.sub_lt_self hfi (hfg i hi)) (fun j => if j ∈ t' then g j - f j else g j + f j) (by simp [hi]) using 1 conv_lhs => rw [← Finset.union_sdiff_of_subset ht'] simp_rw [vadd_eq_add, add_left_cancel_iff, Finset.sum_union Finset.sdiff_disjoint.symm, @@ -435,7 +436,7 @@ theorem Nat.isSemilinearSet_iff_ultimately_periodic {s : Set ℕ} : have h₁ : {x ∈ s | x < k}.Finite := (Set.finite_lt_nat k).subset (sep_subset_setOf _ _) have h₂ : {x ∈ s | k ≤ x ∧ x < k + p}.Finite := (Set.finite_Ico k (k + p)).subset (sep_subset_setOf _ _) - convert (IsSemilinearSet.of_finite h₁).union (.add (.of_finite h₂) (.closure_finset {p})) + convert! (IsSemilinearSet.of_finite h₁).union (.add (.of_finite h₂) (.closure_finset { p })) ext x simp only [sep_and, Finset.coe_singleton, mem_union, mem_setOf_eq, mem_add, mem_inter_iff, SetLike.mem_coe, AddSubmonoid.mem_closure_singleton, smul_eq_mul, exists_exists_eq_and] diff --git a/Mathlib/ModelTheory/Basic.lean b/Mathlib/ModelTheory/Basic.lean index 2fbcc91b10a0c3..4d6a39769479f4 100644 --- a/Mathlib/ModelTheory/Basic.lean +++ b/Mathlib/ModelTheory/Basic.lean @@ -712,7 +712,7 @@ theorem comp_symm (f : M ≃[L] N) (g : N ≃[L] P) : (g.comp f).symm = f.symm.c theorem comp_right_injective (h : M ≃[L] N) : Function.Injective (fun f ↦ f.comp h : (N ≃[L] P) → (M ≃[L] P)) := by intro f g hfg - convert (congr_arg (fun r : (M ≃[L] P) ↦ r.comp h.symm) hfg) <;> + convert! (congr_arg (fun r : (M ≃[L] P) ↦ r.comp h.symm) hfg) <;> rw [comp_assoc, self_comp_symm, comp_refl] @[simp] diff --git a/Mathlib/ModelTheory/Definability.lean b/Mathlib/ModelTheory/Definability.lean index feeb69a8190509..11999fc7916854 100644 --- a/Mathlib/ModelTheory/Definability.lean +++ b/Mathlib/ModelTheory/Definability.lean @@ -150,13 +150,13 @@ theorem definable_biUnion_finset {ι : Type*} {f : ι → Set (α → M)} theorem definable_iInter_of_finite {ι : Type*} [Finite ι] {f : ι → Set (α → M)} (hf : ∀ i, A.Definable L (f i)) : A.Definable L (⋂ i, f i) := by haveI := Fintype.ofFinite ι - convert definable_finset_inf hf Finset.univ using 1 + convert! definable_finset_inf hf Finset.univ using 1 simp theorem definable_iUnion_of_finite {ι : Type*} [Finite ι] {f : ι → Set (α → M)} (hf : ∀ i, A.Definable L (f i)) : A.Definable L (⋃ i, f i) := by haveI := Fintype.ofFinite ι - convert definable_finset_sup hf Finset.univ using 1 + convert! definable_finset_sup hf Finset.univ using 1 simp @[simp] @@ -523,7 +523,7 @@ lemma _root_.Set.Definable.preimage_map (hF i).preimage_comp (fun | none => Sum.inr i | some j => Sum.inl j) have h_cyl : A.Definable L { w : α ⊕ β → M | w ∘ Sum.inr ∈ S } := hS.preimage_comp Sum.inr - convert Definable.exists_of_finite (Definable.inter h_graph h_cyl) using 1 + convert! Definable.exists_of_finite (Definable.inter h_graph h_cyl) using 1 ext v simp [← funext_iff] @@ -551,7 +551,7 @@ theorem DefinableFun.ite {p : (α → M) → Prop} {g} [DecidablePred p] let P : Set (Option α → M) := {w | p (w ∘ some)} have hP : A.Definable L P := hp.preimage_comp some simp only [DefinableFun] - convert (hP.inter hf).union (hP.compl.inter hg) + convert! (hP.inter hf).union (hP.compl.inter hg) ext w by_cases h : p (w ∘ some) <;> simp [tupleGraph, P, h] @@ -664,7 +664,7 @@ theorem TermDefinable₁.definable₂_graph {f : M → M} (h : A.TermDefinable obtain ⟨t, h⟩ := h.termDefinable.definable_tupleGraph A L use t.relabel (Option.elim · 1 (fun _ ↦ 0)) ext v - convert Set.ext_iff.1 h (v ∘ (Option.elim · 1 (fun _ ↦ 0))) + convert! Set.ext_iff.1 h (v ∘ (Option.elim · 1 (fun _ ↦ 0))) simp /-- The identity function is `TermDefinable₁` -/ diff --git a/Mathlib/ModelTheory/ElementarySubstructures.lean b/Mathlib/ModelTheory/ElementarySubstructures.lean index 8bd1396a441b9a..bebffda1987a1c 100644 --- a/Mathlib/ModelTheory/ElementarySubstructures.lean +++ b/Mathlib/ModelTheory/ElementarySubstructures.lean @@ -226,7 +226,7 @@ theorem meetsDefinable (S : L.ElementarySubstructure M) : L.MeetsDefinable (S : simp only [Formula.Realize, ← BoundedFormula.realize_constantsVarsEquiv, ← S.subtype.map_boundedFormula] at hv' simp only [Formula.Realize, ← BoundedFormula.realize_constantsVarsEquiv] - convert hv' using 1 + convert! hv' using 1 funext i cases i <;> rfl change (Subtype.val ∘ v') ∈ {x | x 0 ∈ D} diff --git a/Mathlib/ModelTheory/Order.lean b/Mathlib/ModelTheory/Order.lean index fc294f4a38219d..fc01bc4c2f53c7 100644 --- a/Mathlib/ModelTheory/Order.lean +++ b/Mathlib/ModelTheory/Order.lean @@ -485,9 +485,10 @@ lemma dlo_isExtensionPair let g' : ((Substructure.closure Language.order).toFun {m} ⊔ S : Language.order.Substructure M) ↪o N := ((OrderIso.setCongr _ _ (by - convert LowerAdjoint.closure_eq_self_of_mem_closed _ - (Substructure.mem_closed_of_isRelational Language.order - ((insert m hS.toFinset : Finset M) : Set M)) + convert! + LowerAdjoint.closure_eq_self_of_mem_closed _ + (Substructure.mem_closed_of_isRelational Language.order + ((insert m hS.toFinset : Finset M) : Set M)) simp only [Finset.coe_insert, Set.Finite.coe_toFinset, Substructure.closure_insert, Substructure.closure_eq])).toOrderEmbedding.trans g) use StrongHomClass.toEmbedding g' diff --git a/Mathlib/ModelTheory/PartialEquiv.lean b/Mathlib/ModelTheory/PartialEquiv.lean index d06d3e3da704f5..972b174ab5080c 100644 --- a/Mathlib/ModelTheory/PartialEquiv.lean +++ b/Mathlib/ModelTheory/PartialEquiv.lean @@ -152,7 +152,7 @@ private theorem le_antisymm (f g : M ≃ₚ[L] N) (le_fg : f ≤ g) (le_gf : g let ⟨dom_f, cod_f, equiv_f⟩ := f cases _root_.le_antisymm (dom_le_dom le_fg) (dom_le_dom le_gf) cases _root_.le_antisymm (cod_le_cod le_fg) (cod_le_cod le_gf) - convert rfl + convert! rfl exact Equiv.injective_toEmbedding ((subtype _).comp_injective (subtype_toEquiv_inclusion le_fg)) instance : PartialOrder (M ≃ₚ[L] N) where @@ -489,7 +489,7 @@ theorem embedding_from_cg (M_cg : Structure.CG L M) (g : L.FGEquiv M N) (le_partialEquivLimit S (Encodable.encode (⟨x, hx⟩ : X) + 1)) this have isTop : F.dom = ⊤ := by rwa [← top_le_iff, ← X_gen, Substructure.closure_le] exact ⟨toEmbeddingOfEqTop isTop, - by convert (le_partialEquivLimit S 0); apply Embedding.toPartialEquiv_toEmbedding⟩ + by convert! (le_partialEquivLimit S 0); apply Embedding.toPartialEquiv_toEmbedding⟩ /-- For two countably generated structure `M` and `N`, if any PartialEquiv between finitely generated substructures can be extended to any element in the domain and to @@ -524,7 +524,7 @@ theorem equiv_between_cg (M_cg : Structure.CG L M) (N_cg : Structure.CG L N) have dom_top : F.dom = ⊤ := by rwa [← top_le_iff, ← X_gen, Substructure.closure_le] have cod_top : F.cod = ⊤ := by rwa [← top_le_iff, ← Y_gen, Substructure.closure_le] refine ⟨toEquivOfEqTop dom_top cod_top, ?_⟩ - convert le_partialEquivLimit S 0 + convert! le_partialEquivLimit S 0 rw [toEquivOfEqTop_toEmbedding] apply Embedding.toPartialEquiv_toEmbedding diff --git a/Mathlib/ModelTheory/Ultraproducts.lean b/Mathlib/ModelTheory/Ultraproducts.lean index 98ed1cd4d6c9c0..e84d5b83c0aac8 100644 --- a/Mathlib/ModelTheory/Ultraproducts.lean +++ b/Mathlib/ModelTheory/Ultraproducts.lean @@ -82,7 +82,8 @@ theorem funMap_cast {n : ℕ} (f : L.Functions n) (x : Fin n → ∀ a, M a) : theorem term_realize_cast {β : Type*} (x : β → ∀ a, M a) (t : L.Term β) : (t.realize fun i => (x i : (u : Filter α).Product M)) = (fun a => t.realize fun i => x i a : (u : Filter α).Product M) := by - convert @Term.realize_quotient_mk' L _ ((u : Filter α).productSetoid M) + convert! + @Term.realize_quotient_mk' L _ ((u : Filter α).productSetoid M) (Ultraproduct.setoidPrestructure M u) _ t x using 2 ext a induction t with diff --git a/Mathlib/NumberTheory/AbelSummation.lean b/Mathlib/NumberTheory/AbelSummation.lean index b0743d015285f1..af5755b62443ac 100644 --- a/Mathlib/NumberTheory/AbelSummation.lean +++ b/Mathlib/NumberTheory/AbelSummation.lean @@ -178,7 +178,7 @@ theorem _root_.sum_mul_eq_sub_sub_integral_mul' {n m : ℕ} (h : n ≤ m) ∑ k ∈ Ioc n m, f k * c k = f m * (∑ k ∈ Icc 0 m, c k) - f n * (∑ k ∈ Icc 0 n, c k) - ∫ t in Set.Ioc (n : ℝ) m, deriv f t * ∑ k ∈ Icc 0 ⌊t⌋₊, c k := by - convert sum_mul_eq_sub_sub_integral_mul c n.cast_nonneg (Nat.cast_le.mpr h) hf_diff hf_int + convert! sum_mul_eq_sub_sub_integral_mul c n.cast_nonneg (Nat.cast_le.mpr h) hf_diff hf_int all_goals rw [Nat.floor_natCast] end abelSummationProof @@ -203,7 +203,7 @@ theorem sum_mul_eq_sub_integral_mul' (m : ℕ) ∑ k ∈ Icc 0 m, f k * c k = f m * (∑ k ∈ Icc 0 m, c k) - ∫ t in Set.Ioc (0 : ℝ) m, deriv f t * ∑ k ∈ Icc 0 ⌊t⌋₊, c k := by - convert sum_mul_eq_sub_integral_mul c m.cast_nonneg hf_diff hf_int + convert! sum_mul_eq_sub_integral_mul c m.cast_nonneg hf_diff hf_int all_goals rw [Nat.floor_natCast] /-- Specialized version of `sum_mul_eq_sub_integral_mul` when the first coefficient of the sequence @@ -232,7 +232,7 @@ theorem sum_mul_eq_sub_integral_mul₀' (hc : c 0 = 0) (m : ℕ) ∑ k ∈ Icc 0 m, f k * c k = f m * (∑ k ∈ Icc 0 m, c k) - ∫ t in Set.Ioc (1 : ℝ) m, deriv f t * ∑ k ∈ Icc 0 ⌊t⌋₊, c k := by - convert sum_mul_eq_sub_integral_mul₀ c hc m hf_diff hf_int + convert! sum_mul_eq_sub_integral_mul₀ c hc m hf_diff hf_int all_goals rw [Nat.floor_natCast] /-- Specialized version of `sum_mul_eq_sub_integral_mul` when `c 0 = c 1 = 0`. -/ diff --git a/Mathlib/NumberTheory/ArithmeticFunction/Misc.lean b/Mathlib/NumberTheory/ArithmeticFunction/Misc.lean index d65776f705c9d5..6b7c2d9b959adf 100644 --- a/Mathlib/NumberTheory/ArithmeticFunction/Misc.lean +++ b/Mathlib/NumberTheory/ArithmeticFunction/Misc.lean @@ -430,7 +430,7 @@ theorem sum_Ioc_mul_zeta_eq_sum (f : ArithmeticFunction R) (N : ℕ) : theorem sum_Ioc_sigma0_eq_sum_div (N : ℕ) : ∑ n ∈ Ioc 0 N, sigma 0 n = ∑ n ∈ Ioc 0 N, (N / n) := by rw [← zeta_mul_pow_eq_sigma, pow_zero_eq_zeta] - convert sum_Ioc_mul_zeta_eq_sum zeta N using 1 + convert! sum_Ioc_mul_zeta_eq_sum zeta N using 1 simpa using sum_congr rfl (by grind) end Sum diff --git a/Mathlib/NumberTheory/Bernoulli.lean b/Mathlib/NumberTheory/Bernoulli.lean index e89c502cc2c56d..feab7adab9a611 100644 --- a/Mathlib/NumberTheory/Bernoulli.lean +++ b/Mathlib/NumberTheory/Bernoulli.lean @@ -169,7 +169,7 @@ theorem bernoulli'PowerSeries_mul_exp_sub_one : simpa [map_sum, Nat.factorial] using congr_arg (algebraMap ℚ A) this apply eq_inv_of_mul_eq_one_left rw [sum_mul] - convert bernoulli'_spec' n using 1 + convert! bernoulli'_spec' n using 1 apply sum_congr rfl simp_rw [mem_antidiagonal] rintro ⟨i, j⟩ rfl @@ -259,7 +259,7 @@ theorem bernoulli_spec' (n : ℕ) : -- massage it to match the structure of the goal, then convert piece by piece rw [sum_eq_add_sum_diff_singleton_of_mem h₁] at H ⊢ apply add_eq_of_eq_sub' - convert eq_sub_of_add_eq' H using 1 + convert! eq_sub_of_add_eq' H using 1 · refine sum_congr rfl fun p h => ?_ obtain ⟨h', h''⟩ : p ∈ _ ∧ p ≠ _ := by rwa [mem_sdiff, mem_singleton] at h simp [bernoulli_eq_bernoulli'_of_ne_one ((not_congr (antidiagonal_congr h' h₁)).mp h'')] @@ -367,7 +367,8 @@ theorem sum_Ico_pow (n p : ℕ) : cases p with | zero => simp | succ p => let f i := bernoulli i * p.succ.succ.choose i * (n : ℚ) ^ (p.succ.succ - i) / p.succ.succ let f' i := bernoulli' i * p.succ.succ.choose i * (n : ℚ) ^ (p.succ.succ - i) / p.succ.succ - suffices (∑ k ∈ Ico 1 n.succ, (k : ℚ) ^ p.succ) = ∑ i ∈ range p.succ.succ, f' i by convert this + suffices (∑ k ∈ Ico 1 n.succ, (k : ℚ) ^ p.succ) = ∑ i ∈ range p.succ.succ, f' i by convert! + this -- prove some algebraic facts that will make things easier for us later on have hle := Nat.le_add_left 1 n have hne : (p + 1 + 1 : ℚ) ≠ 0 := by norm_cast diff --git a/Mathlib/NumberTheory/BernoulliPolynomials.lean b/Mathlib/NumberTheory/BernoulliPolynomials.lean index 179175af32983a..6adffaddb78dfa 100644 --- a/Mathlib/NumberTheory/BernoulliPolynomials.lean +++ b/Mathlib/NumberTheory/BernoulliPolynomials.lean @@ -63,7 +63,7 @@ theorem coeff_bernoulli (n i : ℕ) : (bernoulli n).coeff i = if i ≤ n then (_root_.bernoulli (n - i) * choose n i) else 0 := by simp only [bernoulli, finsetSum_coeff, coeff_monomial] split_ifs with h - · convert sum_ite_eq_of_mem (range (n + 1)) (n - i) _ (by grind) using 3 <;> grind [choose_symm] + · convert! sum_ite_eq_of_mem (range (n + 1)) (n - i) _ (by grind) using 3 <;> grind [choose_symm] · exact Finset.sum_eq_zero <| by grind /- diff --git a/Mathlib/NumberTheory/Bertrand.lean b/Mathlib/NumberTheory/Bertrand.lean index dc809c44a95dbf..89e05cf1c9edb1 100644 --- a/Mathlib/NumberTheory/Bertrand.lean +++ b/Mathlib/NumberTheory/Bertrand.lean @@ -82,8 +82,9 @@ theorem real_main_inequality {x : ℝ} (x_large : (512 : ℝ) ≤ x) : · apply ConcaveOn.add · exact strictConcaveOn_log_Ioi.concaveOn.subset (Set.Ioi_subset_Ioi (by norm_num)) (convex_Ioi 0.5) - convert ((strictConcaveOn_sqrt_mul_log_Ioi.concaveOn.comp_linearMap - ((2 : ℝ) • LinearMap.id))) using 1 + convert! + ((strictConcaveOn_sqrt_mul_log_Ioi.concaveOn.comp_linearMap ((2 : ℝ) • LinearMap.id))) + using 1 ext x simp only [Set.mem_Ioi, Set.mem_preimage, LinearMap.smul_apply, LinearMap.id_coe, id_eq, smul_eq_mul] diff --git a/Mathlib/NumberTheory/Chebyshev.lean b/Mathlib/NumberTheory/Chebyshev.lean index 52c778e18bf6ae..f1d3c6c36c98fe 100644 --- a/Mathlib/NumberTheory/Chebyshev.lean +++ b/Mathlib/NumberTheory/Chebyshev.lean @@ -107,7 +107,7 @@ theorem theta_eq_sum_primesLE_log (n : ℕ) : θ n = ∑ p ∈ primesLE n, log p theorem psi_eq_zero_of_lt_two {x : ℝ} (hx : x < 2) : ψ x = 0 := by apply sum_eq_zero fun n hn ↦ ?_ simp only [mem_Ioc] at hn - convert vonMangoldt_apply_one + convert! vonMangoldt_apply_one have := lt_of_le_of_lt (le_floor_iff' hn.1.ne' |>.mp hn.2) hx norm_cast at this linarith @@ -120,7 +120,7 @@ theorem psi_one : ψ 1 = 0 := psi_eq_zero_of_lt_two one_lt_two theorem theta_eq_zero_of_lt_two {x : ℝ} (hx : x < 2) : θ x = 0 := by apply sum_eq_zero fun n hn ↦ ?_ - convert log_one + convert! log_one simp only [mem_filter, mem_Ioc] at hn have := lt_of_le_of_lt (le_floor_iff' hn.1.1.ne' |>.mp hn.1.2) hx norm_cast at ⊢ this diff --git a/Mathlib/NumberTheory/ClassNumber/AdmissibleAbsoluteValue.lean b/Mathlib/NumberTheory/ClassNumber/AdmissibleAbsoluteValue.lean index 396b59116f50ac..681bb81828ef4f 100644 --- a/Mathlib/NumberTheory/ClassNumber/AdmissibleAbsoluteValue.lean +++ b/Mathlib/NumberTheory/ClassNumber/AdmissibleAbsoluteValue.lean @@ -62,8 +62,8 @@ theorem exists_partition {ι : Type*} [Finite ι] {ε : ℝ} (hε : 0 < ε) {b : rcases Finite.exists_equiv_fin ι with ⟨n, ⟨e⟩⟩ obtain ⟨t, ht⟩ := h.exists_partition' n hε hb (A ∘ e.symm) refine ⟨t ∘ e, fun i₀ i₁ h ↦ ?_⟩ - convert (config := { transparency := .default }) - ht (e i₀) (e i₁) h <;> simp only [e.symm_apply_apply] + convert! (config := { transparency := .default }) ht (e i₀) (e i₁) h <;> + simp only [e.symm_apply_apply] set_option backward.isDefEq.respectTransparency false in /-- Any large enough family of vectors in `R^n` has a pair of elements @@ -120,7 +120,7 @@ theorem exists_approx {ι : Type*} [Fintype ι] {ε : ℝ} (hε : 0 < ε) {b : R let e := Fintype.equivFin ι obtain ⟨i₀, i₁, ne, h⟩ := h.exists_approx_aux (Fintype.card ι) hε hb fun x y ↦ A x (e.symm y) refine ⟨i₀, i₁, ne, fun k ↦ ?_⟩ - convert h (e k) <;> simp only [e.symm_apply_apply] + convert! h (e k) <;> simp only [e.symm_apply_apply] end IsAdmissible diff --git a/Mathlib/NumberTheory/ClassNumber/AdmissibleCardPowDegree.lean b/Mathlib/NumberTheory/ClassNumber/AdmissibleCardPowDegree.lean index 9fbf101be27466..32f9a6ee24962e 100644 --- a/Mathlib/NumberTheory/ClassNumber/AdmissibleCardPowDegree.lean +++ b/Mathlib/NumberTheory/ClassNumber/AdmissibleCardPowDegree.lean @@ -92,7 +92,7 @@ theorem exists_approx_polynomial_aux [Ring Fq] {d : ℕ} {m : ℕ} (hm : Fintype rwa [tsub_lt_iff_tsub_lt hd hbj] at this have : j = b.natDegree - (natDegree b - j.succ).succ := by rw [← Nat.succ_sub hbj, Nat.succ_sub_succ, tsub_tsub_cancel_of_le hbj.le] - convert congr_fun i_eq.symm ⟨natDegree b - j.succ, hj⟩ + convert! congr_fun i_eq.symm ⟨natDegree b - j.succ, hj⟩ variable [Field Fq] @@ -136,7 +136,7 @@ theorem exists_approx_polynomial {b : Fq[X]} (hb : b ≠ 0) {ε : ℝ} (hε : 0 -- to turn the `-⌈-stuff⌉₊` into `+ stuff`. apply lt_of_lt_of_le (Nat.cast_lt.mpr (WithBot.coe_lt_coe.mp _)) _ swap - · convert deg_lt + · convert! deg_lt rw [degree_eq_natDegree h']; rfl rw [← sub_neg_eq_add, ← neg_div, Nat.cast_sub le_b.le] grw [← Nat.le_ceil] @@ -160,7 +160,7 @@ theorem cardPowDegree_anti_archimedean {x y z : Fq[X]} {a : ℤ} (hxy : cardPowD refine Or.imp (pow_le_pow_right₀ this) (pow_le_pow_right₀ this) ?_ rw [natDegree_le_iff_degree_le, natDegree_le_iff_degree_le, ← le_max_iff, ← degree_eq_natDegree hxy', ← degree_eq_natDegree hyz'] - convert degree_add_le (x - y) (y - z) using 2 + convert! degree_add_le (x - y) (y - z) using 2 exact (sub_add_sub_cancel _ _ _).symm /-- A slightly stronger version of `exists_partition` on which we perform induction on `n`: diff --git a/Mathlib/NumberTheory/ClassNumber/Finite.lean b/Mathlib/NumberTheory/ClassNumber/Finite.lean index bcd6c61e51b97d..9ececd2e0e3e3c 100644 --- a/Mathlib/NumberTheory/ClassNumber/Finite.lean +++ b/Mathlib/NumberTheory/ClassNumber/Finite.lean @@ -77,7 +77,7 @@ theorem norm_le (a : S) {y : ℤ} (hy : ∀ k, abv (bS.repr a k) ≤ y) : rw [Algebra.norm_apply, ← LinearMap.det_toMatrix bS] simp only [map_sum, map_smul, map_sum, map_smul, normBound, smul_mul_assoc, ← mul_pow] - convert Matrix.det_sum_smul_le Finset.univ _ hy using 3 + convert! Matrix.det_sum_smul_le Finset.univ _ hy using 3 · rw [Finset.card_univ, smul_mul_assoc, mul_comm] · intro i j k apply Finset.le_max' @@ -265,6 +265,8 @@ theorem ne_bot_of_prod_finsetApprox_mem (J : Ideal S) (h : algebraMap _ _ (∏ m ∈ finsetApprox bS adm, m) ∈ J) : J ≠ ⊥ := (Submodule.ne_bot_iff _).mpr ⟨_, h, prod_finsetApprox_ne_zero _ _⟩ +set_option linter.overlappingInstances false + /-- Each class in the class group contains an ideal `J` such that `M := Π m ∈ finsetApprox` is in `J`. -/ theorem exists_mk0_eq_mk0 [IsDedekindDomain S] [Algebra.IsAlgebraic R S] (I : (Ideal S)⁰) : diff --git a/Mathlib/NumberTheory/Cyclotomic/Basic.lean b/Mathlib/NumberTheory/Cyclotomic/Basic.lean index 64f9a5cb00b6d5..7d40aea828dbed 100644 --- a/Mathlib/NumberTheory/Cyclotomic/Basic.lean +++ b/Mathlib/NumberTheory/Cyclotomic/Basic.lean @@ -163,7 +163,7 @@ theorem subsingleton_iff [Subsingleton B] : · refine subset_pair_iff.mpr fun s hs ↦ or_iff_not_imp_left.mpr fun hs' ↦ ?_ obtain ⟨ζ, hζ⟩ := hprim hs hs' exact mod_cast hζ.unique (IsPrimitiveRoot.of_subsingleton ζ) - · refine ⟨fun {s} hs hs' ↦ ?_, fun x ↦ by convert (mem_top (R := A) : x ∈ ⊤)⟩ + · refine ⟨fun {s} hs hs' ↦ ?_, fun x ↦ by convert! (mem_top (R := A) : x ∈ ⊤)⟩ · have : s = 1 := (subset_pair_iff.mp hS s hs).resolve_left hs' exact ⟨0, this ▸ IsPrimitiveRoot.of_subsingleton 0⟩ @@ -195,7 +195,7 @@ theorem union_left [h : IsCyclotomicExtension T A B] (hS : S ⊆ T) : · obtain ⟨b, hb⟩ := ((isCyclotomicExtension_iff _ _ _).1 h).1 (hS hn) hn' refine ⟨⟨b, subset_adjoin ⟨n, hn, hn', hb.pow_eq_one⟩⟩, ?_⟩ rwa [← IsPrimitiveRoot.coe_submonoidClass_iff, Subtype.coe_mk] - · convert mem_top (R := A) (x := b) + · convert! mem_top (R := A) (x := b) rw [← adjoin_adjoin_coe_preimage, preimage_setOf_eq] norm_cast @@ -275,8 +275,8 @@ variable {A B} /-- If `(⊥ : SubAlgebra A B) = ⊤`, then `IsCyclotomicExtension {1} A B`. -/ theorem singleton_one_of_bot_eq_top (h : (⊥ : Subalgebra A B) = ⊤) : IsCyclotomicExtension {1} A B := by - convert eq_self_sdiff_zero _ A B ▸ - (iff_union_singleton_one _ A _).1 (singleton_zero_of_bot_eq_top h) + convert! + eq_self_sdiff_zero _ A B ▸ (iff_union_singleton_one _ A _).1 (singleton_zero_of_bot_eq_top h) simp /-- If `Function.Surjective (algebraMap A B)`, then `IsCyclotomicExtension {1} A B`. -/ @@ -580,7 +580,7 @@ theorem isGalois [IsCyclotomicExtension S K L] : IsGalois K L := by use n, hn, h1 rw [← map_pow, ← map_one f, h2] | algebraMap x => - convert IntermediateField.algebraMap_mem _ x + convert! IntermediateField.algebraMap_mem _ x exact AlgHom.commutes _ x | add x y hx hy ihx ihy => rw [map_add] diff --git a/Mathlib/NumberTheory/Cyclotomic/Discriminant.lean b/Mathlib/NumberTheory/Cyclotomic/Discriminant.lean index d2db272a7cfcb1..32a9e7294f057f 100644 --- a/Mathlib/NumberTheory/Cyclotomic/Discriminant.lean +++ b/Mathlib/NumberTheory/Cyclotomic/Discriminant.lean @@ -168,7 +168,7 @@ theorem discr_prime_pow [hcycl : IsCyclotomicExtension {p ^ k} K L] [hp : Fact p simp only [map_neg, map_one, Function.comp_apply, Fin.val_eq_zero, _root_.pow_zero] suffices (e.symm i : ℕ) = 0 by simp [this] rw [← Nat.lt_one_iff] - convert (e.symm i).2 + convert! (e.symm i).2 rw [this] · simp only [discr, traceMatrix_apply, Matrix.det_unique, Fin.default_eq_zero, Fin.val_zero, _root_.pow_zero, traceForm_apply, mul_one] @@ -198,7 +198,7 @@ theorem discr_odd_prime [IsCyclotomicExtension {p} K L] [hp : Fact p.Prime] rw [zero_add, pow_one] infer_instance have hζ' : IsPrimitiveRoot ζ (p ^ (0 + 1)) := by simpa using hζ - convert discr_prime_pow_ne_two hζ' (by simpa [hirr]) (by simp [hodd]) using 2 + convert! discr_prime_pow_ne_two hζ' (by simpa [hirr]) (by simp [hodd]) using 2 · rw [zero_add, pow_one, totient_prime hp.out] · rw [_root_.pow_zero, one_mul, zero_add, mul_one, Nat.sub_sub] diff --git a/Mathlib/NumberTheory/Cyclotomic/Gal.lean b/Mathlib/NumberTheory/Cyclotomic/Gal.lean index 19bba50aa22431..a1953f31cffa15 100644 --- a/Mathlib/NumberTheory/Cyclotomic/Gal.lean +++ b/Mathlib/NumberTheory/Cyclotomic/Gal.lean @@ -123,7 +123,7 @@ theorem fromZetaAut_spec : fromZetaAut hμ h (zeta n K L) = μ := by generalize_proofs hζ h _ hμ _ nth_rewrite 4 [← hζ.powerBasis_gen K] rw [PowerBasis.equivOfMinpoly_gen, hμ.powerBasis_gen K] - convert h.choose_spec.2 + convert! h.choose_spec.2 exact ZMod.val_cast_of_lt h.choose_spec.1 end IsCyclotomicExtension diff --git a/Mathlib/NumberTheory/Cyclotomic/PrimitiveRoots.lean b/Mathlib/NumberTheory/Cyclotomic/PrimitiveRoots.lean index 89702f2373b5ee..a797e5e244fc44 100644 --- a/Mathlib/NumberTheory/Cyclotomic/PrimitiveRoots.lean +++ b/Mathlib/NumberTheory/Cyclotomic/PrimitiveRoots.lean @@ -99,7 +99,7 @@ theorem aeval_zeta [IsDomain B] [NeZero (n : B)] : exact zeta_spec n A B theorem zeta_isRoot [IsDomain B] [NeZero (n : B)] : IsRoot (cyclotomic n B) (zeta n A B) := by - convert aeval_zeta n A B using 0 + convert! aeval_zeta n A B using 0 rw [IsRoot.def, aeval_def, eval₂_eq_eval_map, map_cyclotomic] theorem zeta_pow : zeta n A B ^ n = 1 := @@ -197,7 +197,7 @@ theorem _root_.IsPrimitiveRoot.lcm_totient_le_finrank [FiniteDimensional K L] {p let k := PNat.lcm ⟨p, hppos⟩ ⟨q, hqpos⟩ have : IsPrimitiveRoot z k := hx.pow_mul_pow_lcm hy hppos.ne' hqpos.ne' haveI := IsPrimitiveRoot.adjoin_isCyclotomicExtension K this - convert Submodule.finrank_le (Subalgebra.toSubmodule (adjoin K {z})) + convert! Submodule.finrank_le (Subalgebra.toSubmodule (adjoin K { z })) rw [show Nat.lcm p q = (k : ℕ) from rfl] at hirr simpa using (IsCyclotomicExtension.finrank (Algebra.adjoin K {z}) hirr).symm @@ -245,7 +245,7 @@ theorem exists_neg_pow_of_isOfFinOrder [IsCyclotomicExtension {n} ℚ K] (hno : Odd n) {ζ x : K} (hζ : IsPrimitiveRoot ζ n) (hx : IsOfFinOrder x) : ∃ r : ℕ, x = (-ζ) ^ r := by have hnegζ : IsPrimitiveRoot (-ζ) (2 * n) := by - convert IsPrimitiveRoot.orderOf (-ζ) + convert! IsPrimitiveRoot.orderOf (-ζ) rw [neg_eq_neg_one_mul, (Commute.all _ _).orderOf_mul_eq_mul_orderOf_of_coprime] · simp [hζ.eq_orderOf] · simp [← hζ.eq_orderOf, hno] @@ -413,11 +413,11 @@ theorem norm_pow_sub_one_of_prime_pow_ne_two {k s : ℕ} (hζ : IsPrimitiveRoot refine IsCyclotomicExtension.equiv _ _ _ (h := ?_) (.refl : K⟮η + 1⟯.toSubalgebra ≃ₐ[K] _) rw [H] have hη' : IsPrimitiveRoot (η + 1) (p ^ (k + 1 - s)) := by simpa using hη - convert hη'.adjoin_isCyclotomicExtension K using 1 + convert! hη'.adjoin_isCyclotomicExtension K using 1 rw [Nat.sub_add_comm hs] replace hη : IsPrimitiveRoot (η₁ + 1) (p ^ (k - s + 1)) := by apply coe_submonoidClass_iff.1 - convert hη using 1 + convert! hη using 1 rw [Nat.sub_add_comm hs] have := IsCyclotomicExtension.finiteDimensional {p ^ (k + 1)} K L have := IsCyclotomicExtension.isGalois {p ^ (k + 1)} K L diff --git a/Mathlib/NumberTheory/Dioph.lean b/Mathlib/NumberTheory/Dioph.lean index bdbe351279c914..585cda8b56ae2d 100644 --- a/Mathlib/NumberTheory/Dioph.lean +++ b/Mathlib/NumberTheory/Dioph.lean @@ -342,7 +342,7 @@ def DiophFn (f : (α → ℕ) → ℕ) : Prop := Dioph {v : Option α → ℕ | f (v ∘ some) = v none} theorem reindex_diophFn {f : (α → ℕ) → ℕ} (g : α → β) (d : DiophFn f) : - DiophFn fun v => f (v ∘ g) := by convert reindex_dioph (Option β) (Option.map g) d + DiophFn fun v => f (v ∘ g) := by convert! reindex_dioph (Option β) (Option.map g) d theorem ex_dioph {S : Set (α ⊕ β → ℕ)} : Dioph S → Dioph {v | ∃ x, v ⊗ x ∈ S} | ⟨γ, p, pe⟩ => diff --git a/Mathlib/NumberTheory/DiophantineApproximation/Basic.lean b/Mathlib/NumberTheory/DiophantineApproximation/Basic.lean index 36b537a3a39ba9..756967cd86db87 100644 --- a/Mathlib/NumberTheory/DiophantineApproximation/Basic.lean +++ b/Mathlib/NumberTheory/DiophantineApproximation/Basic.lean @@ -149,7 +149,7 @@ theorem exists_rat_abs_sub_le_and_den_le (ξ : ℝ) {n : ℕ} (n_pos : 0 < n) : obtain ⟨j, k, hk₀, hk₁, h⟩ := exists_int_int_abs_mul_sub_le ξ n_pos have hk₀' : (0 : ℝ) < k := Int.cast_pos.mpr hk₀ have hden : ((j / k : ℚ).den : ℤ) ≤ k := by - convert le_of_dvd hk₀ (Rat.den_dvd j k) + convert! le_of_dvd hk₀ (Rat.den_dvd j k) exact Rat.intCast_div_eq_divInt _ _ refine ⟨j / k, ?_, Nat.cast_le.mp (hden.trans hk₁)⟩ rw [← div_div, le_div_iff₀ (Nat.cast_pos.mpr <| Rat.pos _ : (0 : ℝ) < _)] @@ -280,7 +280,7 @@ theorem Real.infinite_rat_abs_sub_lt_one_div_den_sq_iff_irrational (ξ : ℝ) : ⟨fun h => (irrational_iff_ne_rational ξ).mpr fun a b _ => ?_, Real.infinite_rat_abs_sub_lt_one_div_den_sq_of_irrational⟩ contrapose! h - convert Rat.finite_rat_abs_sub_lt_one_div_den_sq ((a : ℚ) / b) with q + convert! Rat.finite_rat_abs_sub_lt_one_div_den_sq ((a : ℚ) / b) with q rw [h, (by (push_cast; rfl) : (1 : ℝ) / (q.den : ℝ) ^ 2 = (1 / (q.den : ℚ) ^ 2 : ℚ))] norm_cast @@ -502,7 +502,7 @@ theorem exists_rat_eq_convergent' {v : ℕ} (h : ContfracLegendre.Ass ξ u v) : rcases le_or_gt (u : ℝ) ξ with ht | ht · use 0 rw [convergent_zero, Rat.coe_int_inj, eq_comm, floor_eq_iff] - convert And.intro ht (sub_lt_iff_lt_add'.mp (abs_lt.mp h₂).2) <;> norm_num + convert! And.intro ht (sub_lt_iff_lt_add'.mp (abs_lt.mp h₂).2) <;> norm_num · replace h₁ := lt_sub_iff_add_lt'.mp (h₁ rfl) have hξ₁ : ⌊ξ⌋ = u - 1 := by rw [floor_eq_iff, cast_sub, cast_one, sub_add_cancel] @@ -515,7 +515,7 @@ theorem exists_rat_eq_convergent' {v : ℕ} (h : ContfracLegendre.Ass ξ u v) : one_add_one_eq_two, inv_lt_comm₀ (fract_pos.mpr Hξ) zero_lt_two] refine ⟨(fract_lt_one ξ).le, ?_⟩ rw [fract, hξ₁, cast_sub, cast_one, lt_sub_iff_add_lt', sub_add] - convert h₁ using 1 + convert! h₁ using 1 rw [sub_eq_add_neg] norm_num use 1 diff --git a/Mathlib/NumberTheory/DirichletCharacter/Basic.lean b/Mathlib/NumberTheory/DirichletCharacter/Basic.lean index bd09cdc1f18200..3bbe311ee2e576 100644 --- a/Mathlib/NumberTheory/DirichletCharacter/Basic.lean +++ b/Mathlib/NumberTheory/DirichletCharacter/Basic.lean @@ -301,7 +301,7 @@ theorem changeLevel_primitiveCharacter : lemma primitiveCharacter_isPrimitive : IsPrimitive (χ.primitiveCharacter) := by by_cases h : χ.conductor = 0 · rw [isPrimitive_def] - convert conductor_eq_zero_iff_level_eq_zero.mpr h + convert! conductor_eq_zero_iff_level_eq_zero.mpr h · exact le_antisymm (Nat.le_of_dvd (Nat.pos_of_ne_zero h) (conductor_dvd_level _)) <| conductor_le_conductor_mem_conductorSet <| conductor_mem_conductorSet χ @@ -421,7 +421,7 @@ def Odd : Prop := ψ (-1) = -1 def Even : Prop := ψ (-1) = 1 lemma even_or_odd [NoZeroDivisors S] : ψ.Even ∨ ψ.Odd := by - suffices ψ (-1) ^ 2 = 1 by convert sq_eq_one_iff.mp this + suffices ψ (-1) ^ 2 = 1 by convert! sq_eq_one_iff.mp this rw [← map_pow _, neg_one_sq, map_one] lemma not_even_and_odd [NeZero (2 : S)] : ¬(ψ.Even ∧ ψ.Odd) := by diff --git a/Mathlib/NumberTheory/DirichletCharacter/GaussSum.lean b/Mathlib/NumberTheory/DirichletCharacter/GaussSum.lean index 21e2cc6851f287..5e74d1a99a83d7 100644 --- a/Mathlib/NumberTheory/DirichletCharacter/GaussSum.lean +++ b/Mathlib/NumberTheory/DirichletCharacter/GaussSum.lean @@ -40,10 +40,8 @@ lemma factorsThrough_of_gaussSum_ne_zero [IsDomain R] {χ : DirichletCharacter R (hd : d ∣ N) (he : e.mulShift d = 1) (h_ne : gaussSum χ e ≠ 0) : χ.FactorsThrough d := by rw [DirichletCharacter.factorsThrough_iff_ker_unitsMap hd] - intro u hu - rw [MonoidHom.mem_ker, ← Units.val_inj, MulChar.coe_toUnitHom] - simpa only [Units.val_one, ne_eq, h_ne, not_false_eq_true, mul_eq_right₀] using - gaussSum_aux_of_mulShift e χ hd he hu + intro _ hu + simpa [← Units.val_inj, h_ne] using gaussSum_aux_of_mulShift e χ hd he hu /-- If `χ` is primitive, but `e` is not, then `gaussSum χ e = 0`. -/ lemma gaussSum_eq_zero_of_isPrimitive_of_not_isPrimitive [IsDomain R] @@ -60,7 +58,6 @@ lemma gaussSum_mulShift_of_isPrimitive [IsDomain R] {χ : DirichletCharacter R N (hχ : IsPrimitive χ) (a : ZMod N) : gaussSum χ (e.mulShift a) = χ⁻¹ a * gaussSum χ e := by by_cases ha : IsUnit a - · conv_rhs => rw [← gaussSum_mulShift χ e ha.unit] - rw [IsUnit.unit_spec, MulChar.inv_apply_eq_inv, Ring.inverse_mul_cancel_left _ _ (ha.map χ)] + · simpa [ha.unit_spec] using gaussSum_mulShift_eq χ e ha.unit · rw [MulChar.map_nonunit _ ha, zero_mul] exact gaussSum_eq_zero_of_isPrimitive_of_not_isPrimitive _ hχ (not_isPrimitive_mulShift e ha) diff --git a/Mathlib/NumberTheory/EulerProduct/DirichletLSeries.lean b/Mathlib/NumberTheory/EulerProduct/DirichletLSeries.lean index eead73829c8315..40581cddca34b2 100644 --- a/Mathlib/NumberTheory/EulerProduct/DirichletLSeries.lean +++ b/Mathlib/NumberTheory/EulerProduct/DirichletLSeries.lean @@ -57,7 +57,7 @@ def dirichletSummandHom {n : ℕ} (χ : DirichletCharacter ℂ n) (hs : s ≠ 0) lemma summable_riemannZetaSummand (hs : 1 < s.re) : Summable (fun n ↦ ‖riemannZetaSummandHom (ne_zero_of_one_lt_re hs) n‖) := by simp only [riemannZetaSummandHom, MonoidWithZeroHom.coe_mk, ZeroHom.coe_mk] - convert Real.summable_nat_rpow_inv.mpr hs with n + convert! Real.summable_nat_rpow_inv.mpr hs with n rw [← ofReal_natCast, norm_cpow_eq_rpow_re_of_nonneg (Nat.cast_nonneg n) <| re_neg_ne_zero_of_one_lt_re hs, neg_re, Real.rpow_neg <| Nat.cast_nonneg n] @@ -113,7 +113,7 @@ theorem DirichletCharacter.LSeries_eulerProduct_hasProd {N : ℕ} (χ : Dirichle (hs : 1 < s.re) : HasProd (fun p : Primes ↦ (1 - χ p * (p : ℂ) ^ (-s))⁻¹) (L ↗χ s) := by rw [← tsum_dirichletSummand χ hs] - convert eulerProduct_completely_multiplicative_hasProd <| summable_dirichletSummand χ hs + convert! eulerProduct_completely_multiplicative_hasProd <| summable_dirichletSummand χ hs /-- The Euler product for Dirichlet L-series, valid for `s.re > 1`. This version is stated in terms of `tprod`. -/ @@ -151,8 +151,9 @@ open DirichletCharacter /-- A variant of the Euler product for the L-series of `ζ`. -/ theorem ArithmeticFunction.LSeries_zeta_eulerProduct_exp_log {s : ℂ} (hs : 1 < s.re) : exp (∑' p : Nat.Primes, -Complex.log (1 - p ^ (-s))) = L 1 s := by - convert modOne_eq_one (R := ℂ) ▸ - DirichletCharacter.LSeries_eulerProduct_exp_log (1 : DirichletCharacter ℂ 1) hs using 7 + convert! + modOne_eq_one (R := ℂ) ▸ + DirichletCharacter.LSeries_eulerProduct_exp_log (1 : DirichletCharacter ℂ 1) hs using 7 rw [MulChar.one_apply <| isUnit_of_subsingleton _, one_mul] /-- A variant of the Euler product for the Riemann zeta function. -/ diff --git a/Mathlib/NumberTheory/FLT/MasonStothers.lean b/Mathlib/NumberTheory/FLT/MasonStothers.lean index c8cd330d73caf1..bce9515a2ceef1 100644 --- a/Mathlib/NumberTheory/FLT/MasonStothers.lean +++ b/Mathlib/NumberTheory/FLT/MasonStothers.lean @@ -63,13 +63,13 @@ protected theorem Polynomial.abc have hbc : IsCoprime b c := by rw [add_eq_zero_iff_neg_eq] at hsum rw [← hsum, IsCoprime.neg_right_iff] - convert IsCoprime.add_mul_left_right hab.symm 1 + convert! IsCoprime.add_mul_left_right hab.symm 1 rw [mul_one] have hsum' : b + c + a = 0 := by rwa [add_rotate] at hsum have hca : IsCoprime c a := by rw [add_eq_zero_iff_neg_eq] at hsum' rw [← hsum', IsCoprime.neg_right_iff] - convert IsCoprime.add_mul_left_right hbc.symm 1 + convert! IsCoprime.add_mul_left_right hbc.symm 1 rw [mul_one] have wbc : w = wronskian b c := wronskian_eq_of_sum_zero hsum have wca : w = wronskian c a := by diff --git a/Mathlib/NumberTheory/FLT/Polynomial.lean b/Mathlib/NumberTheory/FLT/Polynomial.lean index b0a8332e0e8335..ff0cd99f2cd69a 100644 --- a/Mathlib/NumberTheory/FLT/Polynomial.lean +++ b/Mathlib/NumberTheory/FLT/Polynomial.lean @@ -53,7 +53,7 @@ private lemma rot_coprime rw [add_eq_zero_iff_neg_eq] at heq rw [← IsCoprime.pow_iff hq.bot_lt hr.bot_lt, ← isCoprime_mul_units_left hCv hCw, ← heq, IsCoprime.neg_right_iff] - convert IsCoprime.add_mul_left_right hab.symm 1 using 2 + convert! IsCoprime.add_mul_left_right hab.symm 1 using 2 rw [mul_one] private lemma ineq_pqr_contradiction {p q r a b c : ℕ} @@ -266,7 +266,7 @@ theorem fermatLastTheoremWith'_polynomial {n : ℕ} (hn : 3 ≤ n) (chn : (n : k rw [← hc', C_ne_zero] at hc exact ⟨ha.right.isUnit_C, hb.right.isUnit_C, hc.right.isUnit_C⟩ apply flt hn chn ha.right hb.right hc.right _ heq - convert isCoprime_div_gcd_div_gcd _ + convert! isCoprime_div_gcd_div_gcd _ · exact EuclideanDomain.eq_div_of_mul_eq_left ha.left eq_a.symm · exact EuclideanDomain.eq_div_of_mul_eq_left ha.left eq_b.symm · rw [eq_b] diff --git a/Mathlib/NumberTheory/FLT/Three.lean b/Mathlib/NumberTheory/FLT/Three.lean index 3452cacc0e72dd..711bf57d10cf26 100644 --- a/Mathlib/NumberTheory/FLT/Three.lean +++ b/Mathlib/NumberTheory/FLT/Three.lean @@ -86,7 +86,7 @@ lemma three_dvd_b_of_dvd_a_of_gcd_eq_one_of_case2 {a b c : ℤ} (ha : a ≠ 0) refine IsCoprime.neg_neg ?_ rw [add_comm (a ^ 3), add_assoc, add_comm (a ^ 3), ← add_assoc] at HF refine isCoprime_of_gcd_eq_one_of_FLT ?_ HF - convert Hgcd using 2 + convert! Hgcd using 2 rw [Finset.pair_comm, Finset.insert_comm] by_contra! h3b by_cases h3c : 3 ∣ c @@ -433,7 +433,7 @@ lemma associated_of_dvd_a_add_b_of_dvd_a_add_eta_sq_mul_b {p : 𝓞 K} (hp : Pri rw [← one_mul S.a] at hpaηsqb have := dvd_mul_sub_mul_mul_gcd_of_dvd hpab hpaηsqb rw [one_mul, mul_one, IsUnit.dvd_mul_right <| (gcd_isUnit_iff _ _).2 S.coprime, ← dvd_neg] at this - convert dvd_mul_of_dvd_left this η using 1 + convert! dvd_mul_of_dvd_left this η using 1 rw [eta_sq, neg_sub, sub_mul, sub_mul, neg_mul, ← pow_two, eta_sq, coe_eta] ring @@ -446,7 +446,7 @@ lemma associated_of_dvd_a_add_eta_mul_b_of_dvd_a_add_eta_sq_mul_b {p : 𝓞 K} ( rw [← one_mul S.a] at hpaηsqb have := dvd_mul_sub_mul_mul_gcd_of_dvd hpaηb hpaηsqb rw [one_mul, mul_one, IsUnit.dvd_mul_right <| (gcd_isUnit_iff _ _).2 S.coprime] at this - convert (dvd_mul_of_dvd_left (dvd_mul_of_dvd_left this η) η) using 1 + convert! (dvd_mul_of_dvd_left (dvd_mul_of_dvd_left this η) η) using 1 symm calc _ = (-η.1 - 1 - η) * (-η - 1) := by rw [eta_sq, mul_assoc, ← pow_two, eta_sq] _ = 2 * η.1 ^ 2 + 3 * η + 1 := by ring @@ -557,7 +557,7 @@ lemma x_mul_y_mul_z_eq_u_mul_w_cube : S.x * S.y * S.z = S.u * S.w ^ 3 := by mul_assoc] at hh simp only [mul_eq_mul_left_iff, pow_eq_zero_iff', hζ.zeta_sub_one_prime'.ne_zero, ne_eq, mul_eq_zero, OfNat.ofNat_ne_zero, false_or, false_and, or_false] at hh - convert hh using 1 + convert! hh using 1 ring simp only [← x_spec, mul_assoc, ← y_spec, ← z_spec] rw [mul_comm 3, pow_mul, ← mul_pow, ← w_spec, ← S.H, a_cube_add_b_cube_eq_mul] diff --git a/Mathlib/NumberTheory/FermatPsp.lean b/Mathlib/NumberTheory/FermatPsp.lean index 35dd48f583eb42..dc610844384b41 100644 --- a/Mathlib/NumberTheory/FermatPsp.lean +++ b/Mathlib/NumberTheory/FermatPsp.lean @@ -149,7 +149,7 @@ private theorem AB_id_helper (b p : ℕ) (_ : 2 ≤ b) (hp : Odd p) : (b ^ p - 1) / (b - 1) * ((b ^ p + 1) / (b + 1)) = (b ^ (2 * p) - 1) / (b ^ 2 - 1) := by have q₁ : b - 1 ∣ b ^ p - 1 := by simpa only [one_pow] using Nat.sub_dvd_pow_sub_pow b 1 p have q₂ : b + 1 ∣ b ^ p + 1 := by simpa only [one_pow] using hp.nat_add_dvd_pow_add_pow b 1 - convert Nat.div_mul_div_comm q₁ q₂ using 2 <;> rw [mul_comm (_ - 1), ← Nat.sq_sub_sq] + convert! Nat.div_mul_div_comm q₁ q₂ using 2 <;> rw [mul_comm (_ - 1), ← Nat.sq_sub_sq] ring_nf /-- Used in the proof of `psp_from_prime_psp` diff --git a/Mathlib/NumberTheory/FrobeniusNumber.lean b/Mathlib/NumberTheory/FrobeniusNumber.lean index 1d979ed8c5e948..5af9915fceace7 100644 --- a/Mathlib/NumberTheory/FrobeniusNumber.lean +++ b/Mathlib/NumberTheory/FrobeniusNumber.lean @@ -152,9 +152,10 @@ theorem exists_mem_span_nat_finset_of_ge : obtain ⟨rx, hrx⟩ : setGcd s ∣ r := (dvd_mod_iff (setGcd_dvd_of_mem hxs)).mpr <| (Nat.dvd_add_right <| dvd_mul_of_dvd_right (Finset.dvd_sum fun i _ ↦ dvd_mul_of_dvd_right (setGcd_dvd_of_mem (hts i.2)) _) _).mp dvd - convert (sum_mem fun i _ ↦ mul_mem_left _ _ (subset_span i.2) : - -- an explicit ℕ-linear combination of elements of `t` that is equal to `r + n` - ∑ i : t, (if 0 ≤ a i then rx else x / setGcd s - rx) * (a i).natAbs * i ∈ span t) + convert! + (sum_mem fun i _ ↦ mul_mem_left _ _ (subset_span i.2) : + -- an explicit ℕ-linear combination of elements of `t` that is equal to `r + n` + ∑ i : t, (if 0 ≤ a i then rx else x / setGcd s - rx) * (a i).natAbs * i ∈ span t) simp_rw [← Int.natCast_inj, hrx, n, Finset.mul_sum, mul_comm _ rx, cast_add, cast_sum, cast_mul, ← eq, Finset.mul_sum, smul_eq_mul, ← mul_assoc, ← Finset.sum_add_distrib, ← add_mul] congr! 2 with i diff --git a/Mathlib/NumberTheory/FunctionField.lean b/Mathlib/NumberTheory/FunctionField.lean index 07f1fd03fff3ad..44f5f68e40d708 100644 --- a/Mathlib/NumberTheory/FunctionField.lean +++ b/Mathlib/NumberTheory/FunctionField.lean @@ -77,7 +77,7 @@ theorem functionField_iff (Ft : Type*) [Field Ft] [Algebra F[X] Ft] exact (b.mapCoeffs e this).finiteDimensional_of_finite · let b := Module.finBasis Ft K refine (b.mapCoeffs e.symm ?_).finiteDimensional_of_finite - intro c x; convert (this (e.symm c) x).symm; simp only [e.apply_symm_apply] + intro c x; convert! (this (e.symm c) x).symm; simp only [e.apply_symm_apply] namespace FunctionField diff --git a/Mathlib/NumberTheory/GaussSum.lean b/Mathlib/NumberTheory/GaussSum.lean index dfe725f1e1c7d2..9e25fe600131ee 100644 --- a/Mathlib/NumberTheory/GaussSum.lean +++ b/Mathlib/NumberTheory/GaussSum.lean @@ -9,6 +9,8 @@ public import Mathlib.NumberTheory.LegendreSymbol.AddCharacter public import Mathlib.NumberTheory.LegendreSymbol.ZModChar public import Mathlib.Algebra.CharP.CharAndCard +import Mathlib.NumberTheory.MulChar.Lemmas + /-! # Gauss sums @@ -77,6 +79,20 @@ theorem gaussSum_mulShift (χ : MulChar R R') (ψ : AddChar R R') (a : Rˣ) : simp_rw [← mul_assoc, ← map_mul] exact Fintype.sum_bijective _ a.mulLeft_bijective _ _ fun x ↦ rfl +/-- Replacing `ψ` by `mulShift ψ a` multiplies the Gauss sum by `χ⁻¹ a`. -/ +theorem gaussSum_mulShift_eq (χ : MulChar R R') (ψ : AddChar R R') (a : Rˣ) : + gaussSum χ (ψ.mulShift a) = χ⁻¹ a * gaussSum χ ψ := by + rw [← gaussSum_mulShift χ ψ a, inv_apply_eq_inv, + Ring.inverse_mul_cancel_left _ _ (a.isUnit.map χ)] + +/-- Taking complex conjugates of a Gauss sum inverts both characters. -/ +lemma star_gaussSum_eq (χ : MulChar R ℂ) (ψ : AddChar R ℂ) : + star (gaussSum χ ψ) = gaussSum χ⁻¹ ψ⁻¹ := + calc + _ = ∑ x, star (ψ x) * χ⁻¹ x := by simp [gaussSum, star_mul, MulChar.star_apply'] + _ = ∑ x, ψ⁻¹ x * χ⁻¹ x := by simp [← starRingEnd_apply, map_neg_eq_conj] + _ = _ := by simp [mul_comm, gaussSum] + end GaussSumDef /-! @@ -297,7 +313,7 @@ theorem FiniteField.two_pow_card {F : Type*} [Fintype F] [Field F] (hF : ringCha exact mt FFp.dvd_of_dvd_pow hFF -- there is a primitive additive character `ℤ/8ℤ → FF`, sending `a + 8ℤ ↦ τ^a` -- with a primitive eighth root of unity `τ` - let ψ₈ := primitiveZModChar 8 F (by convert hp2 3 using 1; norm_cast) + let ψ₈ := primitiveZModChar 8 F (by convert! hp2 3 using 1; norm_cast) -- We cast from `AddChar (ZMod (8 : ℕ+)) FF` to `AddChar (ZMod 8) FF` -- This is needed to make `simp_rw [← h₁]` below work. let ψ₈char : AddChar (ZMod 8) FF := ψ₈.char diff --git a/Mathlib/NumberTheory/Harmonic/Bounds.lean b/Mathlib/NumberTheory/Harmonic/Bounds.lean index 16f920c6c765f4..9bf769b83daeb5 100644 --- a/Mathlib/NumberTheory/Harmonic/Bounds.lean +++ b/Mathlib/NumberTheory/Harmonic/Bounds.lean @@ -48,10 +48,10 @@ theorem harmonic_le_one_add_log (n : ℕ) : · simp_rw [Nat.cast_add, Nat.cast_one, add_sub_cancel_right] · exact @AntitoneOn.sum_le_integral_Ico 2 (n + 1) (fun x : ℝ ↦ (x - 1)⁻¹) (by linarith [hn]) <| sub_inv_antitoneOn_Icc_right (by simp) - · convert intervalIntegral.integral_comp_sub_right _ 1 + · convert! intervalIntegral.integral_comp_sub_right _ 1 · norm_num · simp only [Nat.cast_add, Nat.cast_one, add_sub_cancel_right] - · convert integral_inv _ + · convert! integral_inv _ · rw [div_one] · simp only [Nat.one_le_cast, hn, Set.uIcc_of_le, Set.mem_Icc, Nat.cast_nonneg, and_true, not_le, zero_lt_one] diff --git a/Mathlib/NumberTheory/Harmonic/ZetaAsymp.lean b/Mathlib/NumberTheory/Harmonic/ZetaAsymp.lean index 92452a06dcedcc..bdb7faa128cd5e 100644 --- a/Mathlib/NumberTheory/Harmonic/ZetaAsymp.lean +++ b/Mathlib/NumberTheory/Harmonic/ZetaAsymp.lean @@ -377,7 +377,7 @@ lemma tendsto_riemannZeta_sub_one_div_Gammaℝ : (𝓝 ((γ - Complex.log (4 * ↑π)) / 2)) := by have := tendsto_riemannZeta_sub_one_div.add tendsto_Gamma_term_aux simp_rw [sub_add_sub_cancel] at this - convert this using 2 + convert! this using 2 ring_nf /-- Formula for `ζ 1`. Note that mathematically `ζ 1` is undefined, but our construction ascribes diff --git a/Mathlib/NumberTheory/Height/Basic.lean b/Mathlib/NumberTheory/Height/Basic.lean index 9f7c92337d7549..ccb65f86701f3c 100644 --- a/Mathlib/NumberTheory/Height/Basic.lean +++ b/Mathlib/NumberTheory/Height/Basic.lean @@ -314,7 +314,7 @@ private lemma hasFiniteMulSupport_iSup_nonarchAbsVal {x : ι → K} (hx : x ≠ (fun v : nonarchAbsVal ↦ ⨆ i, v.val (x i)).HasFiniteMulSupport := by have : Nonempty {j // x j ≠ 0} := nonempty_subtype.mpr <| ne_iff.mp hx suffices (fun v : nonarchAbsVal ↦ ⨆ i : {j // x j ≠ 0}, v.val (x i)).HasFiniteMulSupport by - convert this with v + convert! this with v obtain ⟨i, hi⟩ : ∃ j, x j ≠ 0 := Function.ne_iff.mp hx have : Nonempty ι := .intro i refine le_antisymm (ciSup_le fun j ↦ ?_) (ciSup_le fun ⟨j, hj⟩ ↦ Finite.le_ciSup_of_le j le_rfl) @@ -437,7 +437,7 @@ lemma mulHeight_eq_one_of_subsingleton {ι : Type*} [Subsingleton ι] (x : ι obtain ⟨i, hi⟩ := Function.ne_iff.mp hx have : Nonempty ι := .intro i rw [← mulHeight_smul_eq_mulHeight x (inv_ne_zero hi)] - convert mulHeight_one + convert! mulHeight_one ext1 j simpa [Subsingleton.elim j i] using inv_mul_cancel₀ hi diff --git a/Mathlib/NumberTheory/Height/MvPolynomial.lean b/Mathlib/NumberTheory/Height/MvPolynomial.lean index f495a646d1b2c8..0181f63aaff311 100644 --- a/Mathlib/NumberTheory/Height/MvPolynomial.lean +++ b/Mathlib/NumberTheory/Height/MvPolynomial.lean @@ -541,7 +541,7 @@ variable [AdmissibleAbsValues K] lemma mulHeight_mul_mulHeight {a b c d : K} (hab : ![a, b] ≠ 0) (hcd : ![c, d] ≠ 0) : mulHeight ![a, b] * mulHeight ![c, d] = mulHeight ![a * c, a * d, b * c, b * d] := by simp only [← mulHeight_fun_mul_eq hab hcd] - convert mulHeight_comp_equiv finProdFinEquiv _ with i + convert! mulHeight_comp_equiv finProdFinEquiv _ with i fin_cases i <;> simp [finProdFinEquiv] open MvPolynomial @@ -571,7 +571,7 @@ lemma mulHeight_sym2_le : grind rw [mul_assoc, mulHeight_mul_mulHeight hab hcd] grw [← le_max_left C 1] - convert hC _ with i + convert! hC _ with i fin_cases i <;> simp [p] lemma mulHeight_sym2_ge : @@ -586,7 +586,7 @@ lemma mulHeight_sym2_ge : simp only [pow_one] at hC refine ⟨C, hC₀, fun hab hcd ↦ ?_⟩ rw [mul_assoc, mulHeight_mul_mulHeight hab hcd] - convert hC p fun j ↦ ?H with i + convert! hC p fun j ↦ ?H with i case H => fin_cases j <;> simp [p, q, Fin.sum_univ_three] <;> ring fin_cases i <;> simp [p] diff --git a/Mathlib/NumberTheory/Height/NumberField.lean b/Mathlib/NumberTheory/Height/NumberField.lean index 208e01048630ac..2af31064d5d207 100644 --- a/Mathlib/NumberTheory/Height/NumberField.lean +++ b/Mathlib/NumberTheory/Height/NumberField.lean @@ -121,7 +121,7 @@ lemma mulHeight_eq {ι : Type*} {x : ι → K} (hx : x ≠ 0) : variable (K) in lemma totalWeight_eq_sum_mult : totalWeight K = ∑ v : InfinitePlace K, v.mult := by simp only [totalWeight] - convert sum_archAbsVal_eq (fun _ ↦ (1 : ℕ)) + convert! sum_archAbsVal_eq (fun _ ↦ (1 : ℕ)) · rw [← Multiset.sum_map_toList, ← Fin.sum_univ_fun_getElem, ← Multiset.length_toList, Fin.sum_const, Multiset.length_toList, smul_eq_mul, mul_one] · simp @@ -233,7 +233,7 @@ lemma mulHeight₁_eq_max (q : ℚ) : mulHeight₁ q = max q.num.natAbs q.den := have : (.univ : Finset (Fin 2)).gcd ![q.num, q.den] = 1 := by simpa [Finset.univ_fin2, Int.normalize_coe_nat, ← Int.coe_gcd q.num q.den] using Int.isCoprime_iff_gcd_eq_one.mp <| isCoprime_num_den q - convert mulHeight_eq_max_abs_of_gcd_eq_one this + convert! mulHeight_eq_max_abs_of_gcd_eq_one this · ext i; fin_cases i <;> simp · rw [← Int.cast_natCast, Int.cast_inj] push_cast diff --git a/Mathlib/NumberTheory/KummerDedekind.lean b/Mathlib/NumberTheory/KummerDedekind.lean index c94ea99c074d1f..e5a45bb93d2bd9 100644 --- a/Mathlib/NumberTheory/KummerDedekind.lean +++ b/Mathlib/NumberTheory/KummerDedekind.lean @@ -91,7 +91,7 @@ lemma quotMapEquivQuotQuotMap_symm_apply (hx : (conductor R x).comap (algebraMap RingEquiv.symm_symm, RingEquiv.coe_trans, Function.comp_apply, RingEquiv.symm_apply_apply, RingEquiv.symm_trans_apply, quotEquivOfEq_symm, quotEquivOfEq_mk] congr - convert (adjoin.powerBasis' hx').quotientEquivQuotientMinpolyMap_symm_apply_mk I Q + convert! (adjoin.powerBasis' hx').quotientEquivQuotientMinpolyMap_symm_apply_mk I Q apply (quotAdjoinEquivQuotMap hx (FaithfulSMul.algebraMap_injective ((adjoin R {x})) S)).injective simp only [RingEquiv.apply_symm_apply, adjoin.powerBasis'_gen, quotAdjoinEquivQuotMap_apply_mk, diff --git a/Mathlib/NumberTheory/LSeries/AbstractFuncEq.lean b/Mathlib/NumberTheory/LSeries/AbstractFuncEq.lean index c0b6901f6252c4..d8bb638dfc19be 100644 --- a/Mathlib/NumberTheory/LSeries/AbstractFuncEq.lean +++ b/Mathlib/NumberTheory/LSeries/AbstractFuncEq.lean @@ -107,7 +107,7 @@ section symmetry lemma WeakFEPair.h_feq' (P : WeakFEPair E) (x : ℝ) (hx : 0 < x) : P.g (1 / x) = (P.ε⁻¹ * ↑(x ^ P.k)) • P.f x := by rw [(div_div_cancel₀ (one_ne_zero' ℝ) ▸ P.h_feq (1 / x) (one_div_pos.mpr hx) :), ← mul_smul] - convert (one_smul ℂ (P.g (1 / x))).symm using 2 + convert! (one_smul ℂ (P.g (1 / x))).symm using 2 rw [one_div, inv_rpow hx.le, ofReal_inv] field [P.hε, (rpow_pos_of_pos hx _).ne'] @@ -156,7 +156,7 @@ lemma hf_zero (P : WeakFEPair E) (r : ℝ) : simp_rw [Function.comp_apply, ← one_div, P.h_feq' _ hx] at hC' rw [← ((mul_inv_cancel₀ h_nv).symm ▸ one_smul ℂ P.g₀ :), mul_smul _ _ P.g₀, ← smul_sub, norm_smul, ← le_div_iff₀' (lt_of_le_of_ne (norm_nonneg _) (norm_ne_zero_iff.mpr h_nv).symm)] at hC' - convert hC' using 1 + convert! hC' using 1 · congr 3 rw [rpow_neg hx.le] simp [field] diff --git a/Mathlib/NumberTheory/LSeries/Basic.lean b/Mathlib/NumberTheory/LSeries/Basic.lean index f4420b306c5be9..201842a7425e6d 100644 --- a/Mathlib/NumberTheory/LSeries/Basic.lean +++ b/Mathlib/NumberTheory/LSeries/Basic.lean @@ -333,7 +333,7 @@ lemma LSeriesSummable.isBigO_rpow {f : ℕ → ℂ} {s : ℂ} (h : LSeriesSummab f =O[atTop] fun n ↦ (n : ℝ) ^ s.re := by obtain ⟨C, hC⟩ := h.le_const_mul_rpow refine Asymptotics.IsBigO.of_bound C <| eventually_atTop.mpr ⟨1, fun n hn ↦ ?_⟩ - convert hC n (Nat.pos_iff_ne_zero.mp hn) using 2 + convert! hC n (Nat.pos_iff_ne_zero.mp hn) using 2 rw [Real.norm_eq_abs, Real.abs_rpow_of_nonneg n.cast_nonneg, abs_of_nonneg n.cast_nonneg] /-- If `f n` is bounded in absolute value by a constant times `n^(x-1)` and `re s > x`, diff --git a/Mathlib/NumberTheory/LSeries/DirichletContinuation.lean b/Mathlib/NumberTheory/LSeries/DirichletContinuation.lean index b9766e4837dcac..54977f1f924112 100644 --- a/Mathlib/NumberTheory/LSeries/DirichletContinuation.lean +++ b/Mathlib/NumberTheory/LSeries/DirichletContinuation.lean @@ -174,7 +174,7 @@ zeta function by multiplying with `∏ p ∈ N.primeFactors, (1 - (p : ℂ) ^ (- lemma LFunctionTrivChar_eq_mul_riemannZeta {s : ℂ} (hs : s ≠ 1) : LFunctionTrivChar N s = (∏ p ∈ N.primeFactors, (1 - (p : ℂ) ^ (-s))) * riemannZeta s := by rw [← LFunction_modOne_eq (χ := 1), LFunctionTrivChar, ← changeLevel_one N.one_dvd, mul_comm] - convert LFunction_changeLevel N.one_dvd 1 (.inr hs) using 4 with p + convert! LFunction_changeLevel N.one_dvd 1 (.inr hs) using 4 with p rw [MulChar.one_apply <| isUnit_of_subsingleton _, one_mul] /-- The L function of the trivial Dirichlet character mod `N` has a simple pole with diff --git a/Mathlib/NumberTheory/LSeries/HurwitzZeta.lean b/Mathlib/NumberTheory/LSeries/HurwitzZeta.lean index bdbae9c2a0199c..1fd05c4f234bb2 100644 --- a/Mathlib/NumberTheory/LSeries/HurwitzZeta.lean +++ b/Mathlib/NumberTheory/LSeries/HurwitzZeta.lean @@ -71,8 +71,9 @@ lemma differentiableAt_hurwitzZeta (a : UnitAddCircle) {s : ℂ} (hs : s ≠ 1) restrict to `a ∈ Icc 0 1` to simplify the statement. -/ lemma hasSum_hurwitzZeta_of_one_lt_re {a : ℝ} (ha : a ∈ Icc 0 1) {s : ℂ} (hs : 1 < re s) : HasSum (fun n : ℕ ↦ 1 / (n + a : ℂ) ^ s) (hurwitzZeta a s) := by - convert (hasSum_nat_hurwitzZetaEven_of_mem_Icc ha hs).add - (hasSum_nat_hurwitzZetaOdd_of_mem_Icc ha hs) using 1 + convert! + (hasSum_nat_hurwitzZetaEven_of_mem_Icc ha hs).add (hasSum_nat_hurwitzZetaOdd_of_mem_Icc ha hs) + using 1 ext1 n -- plain `ring_nf` works here, but the following is faster: apply show ∀ (x y : ℂ), x = (x + y) / 2 + (x - y) / 2 by intros; ring @@ -126,7 +127,7 @@ lemma sinZeta_eq (a : UnitAddCircle) (s : ℂ) : lemma hasSum_expZeta_of_one_lt_re (a : ℝ) {s : ℂ} (hs : 1 < re s) : HasSum (fun n : ℕ ↦ cexp (2 * π * I * a * n) / n ^ s) (expZeta a s) := by - convert (hasSum_nat_cosZeta a hs).add ((hasSum_nat_sinZeta a hs).mul_left I) using 1 + convert! (hasSum_nat_cosZeta a hs).add ((hasSum_nat_sinZeta a hs).mul_left I) using 1 ext1 n simp only [mul_right_comm _ I, ← cos_add_sin_I, push_cast] rw [add_div, mul_div, mul_comm _ I] @@ -172,7 +173,7 @@ lemma expZeta_one_sub (a : UnitAddCircle) {s : ℂ} (hs : ∀ (n : ℕ), s ≠ 1 expZeta a (1 - s) = (2 * π) ^ (-s) * Gamma s * (exp (π * I * s / 2) * hurwitzZeta a s + exp (-π * I * s / 2) * hurwitzZeta (-a) s) := by have hs' (n : ℕ) : s ≠ -↑n := by - convert hs (n + 1) using 1 + convert! hs (n + 1) using 1 push_cast ring rw [expZeta, cosZeta_one_sub a hs, sinZeta_one_sub a hs', hurwitzZeta, hurwitzZeta, diff --git a/Mathlib/NumberTheory/LSeries/HurwitzZetaEven.lean b/Mathlib/NumberTheory/LSeries/HurwitzZetaEven.lean index 6080dca219724c..3d7e9817422f7c 100644 --- a/Mathlib/NumberTheory/LSeries/HurwitzZetaEven.lean +++ b/Mathlib/NumberTheory/LSeries/HurwitzZetaEven.lean @@ -654,8 +654,10 @@ lemma differentiable_hurwitzZetaEven_sub_hurwitzZetaEven (a b : UnitAddCircle) : intro z rcases ne_or_eq z 1 with hz | rfl · exact (differentiableAt_hurwitzZetaEven a hz).sub (differentiableAt_hurwitzZetaEven b hz) - · convert (differentiableAt_hurwitzZetaEven_sub_one_div a).fun_sub - (differentiableAt_hurwitzZetaEven_sub_one_div b) using 2 with s + · convert! + (differentiableAt_hurwitzZetaEven_sub_one_div a).fun_sub + (differentiableAt_hurwitzZetaEven_sub_one_div b) using + 2 with s abel /-- diff --git a/Mathlib/NumberTheory/LSeries/HurwitzZetaValues.lean b/Mathlib/NumberTheory/LSeries/HurwitzZetaValues.lean index 13ae1c3b20b822..c07e995dd8a709 100644 --- a/Mathlib/NumberTheory/LSeries/HurwitzZetaValues.lean +++ b/Mathlib/NumberTheory/LSeries/HurwitzZetaValues.lean @@ -206,19 +206,19 @@ the functional equation). -/ theorem riemannZeta_two_mul_nat {k : ℕ} (hk : k ≠ 0) : riemannZeta (2 * k) = (-1) ^ (k + 1) * (2 : ℂ) ^ (2 * k - 1) * (π : ℂ) ^ (2 * k) * bernoulli (2 * k) / (2 * k)! := by - convert congr_arg ((↑) : ℝ → ℂ) (hasSum_zeta_nat hk).tsum_eq + convert! congr_arg ((↑) : ℝ → ℂ) (hasSum_zeta_nat hk).tsum_eq · rw [← Nat.cast_two, ← Nat.cast_mul, zeta_nat_eq_tsum_of_gt_one (by lia)] simp [push_cast] · norm_cast theorem riemannZeta_two : riemannZeta 2 = (π : ℂ) ^ 2 / 6 := by - convert congr_arg ((↑) : ℝ → ℂ) hasSum_zeta_two.tsum_eq + convert! congr_arg ((↑) : ℝ → ℂ) hasSum_zeta_two.tsum_eq · rw [← Nat.cast_two, zeta_nat_eq_tsum_of_gt_one one_lt_two] simp [push_cast] · norm_cast theorem riemannZeta_four : riemannZeta 4 = π ^ 4 / 90 := by - convert congr_arg ((↑) : ℝ → ℂ) hasSum_zeta_four.tsum_eq + convert! congr_arg ((↑) : ℝ → ℂ) hasSum_zeta_four.tsum_eq · rw [← Nat.cast_one, show (4 : ℂ) = (4 : ℕ) by simp, zeta_nat_eq_tsum_of_gt_one (by simp : 1 < 4)] simp only [push_cast] diff --git a/Mathlib/NumberTheory/LSeries/Injectivity.lean b/Mathlib/NumberTheory/LSeries/Injectivity.lean index c8fe047f96595e..24cf8a1930d8dd 100644 --- a/Mathlib/NumberTheory/LSeries/Injectivity.lean +++ b/Mathlib/NumberTheory/LSeries/Injectivity.lean @@ -127,7 +127,7 @@ lemma LSeries.tendsto_atTop {f : ℕ → ℂ} (ha : abscissaOfAbsConv f < ⊤) : have hF {n : ℕ} (hn : n ≠ 0) : F n = f n := if_neg hn have ha' : abscissaOfAbsConv F < ⊤ := (abscissaOfAbsConv_congr hF).symm ▸ ha simp_rw [← LSeries_congr hF] - convert LSeries.tendsto_cpow_mul_atTop (n := 0) (fun _ hm ↦ Nat.le_zero.mp hm ▸ hF₀) ha' using 1 + convert! LSeries.tendsto_cpow_mul_atTop (n := 0) (fun _ hm ↦ Nat.le_zero.mp hm ▸ hF₀) ha' using 1 simp lemma LSeries_eq_zero_of_abscissaOfAbsConv_eq_top {f : ℕ → ℂ} (h : abscissaOfAbsConv f = ⊤) : @@ -180,7 +180,7 @@ lemma LSeries_eq_zero_iff {f : ℕ → ℂ} (hf : f 0 = 0) : · simpa [h] using LSeries_eq_zero_of_abscissaOfAbsConv_eq_top h · simp only [h, or_false] refine ⟨fun H ↦ ?_, fun H ↦ H ▸ LSeries_zero⟩ - convert (LSeries_eventually_eq_zero_iff'.mp ?_).resolve_right h + convert! (LSeries_eventually_eq_zero_iff'.mp ?_).resolve_right h · refine ⟨fun H' _ _ ↦ by rw [H', Pi.zero_apply], fun H' ↦ ?_⟩ ext (- | m) · simp [hf] diff --git a/Mathlib/NumberTheory/LSeries/MellinEqDirichlet.lean b/Mathlib/NumberTheory/LSeries/MellinEqDirichlet.lean index c88c068bee4af7..1d6b46e9c172a1 100644 --- a/Mathlib/NumberTheory/LSeries/MellinEqDirichlet.lean +++ b/Mathlib/NumberTheory/LSeries/MellinEqDirichlet.lean @@ -28,8 +28,10 @@ lemma hasSum_mellin {a : ι → ℂ} {p : ι → ℝ} {F : ℝ → ℂ} {s : ℂ HasSum (fun i ↦ Gamma s * a i / p i ^ s) (mellin F s) := by simp_rw [mellin, smul_eq_mul, ← setIntegral_congr_fun measurableSet_Ioi (fun t ht ↦ congr_arg _ (hF t ht).tsum_eq), ← tsum_mul_left] - convert hasSum_integral_of_summable_integral_norm - (F := fun i t ↦ t ^ (s - 1) * (a i * rexp (-p i * t))) (fun i ↦ ?_) ?_ using 2 with i + convert! + hasSum_integral_of_summable_integral_norm (F := fun i t ↦ t ^ (s - 1) * (a i * rexp (-p i * t))) + (fun i ↦ ?_) ?_ using + 2 with i · simp_rw [← mul_assoc, mul_comm _ (a _), mul_assoc (a _), mul_div_assoc, integral_const_mul] rcases hp i with hai | hpi · rw [hai, zero_mul, zero_mul] @@ -50,7 +52,7 @@ lemma hasSum_mellin {a : ι → ℂ} {p : ι → ℝ} {F : ℝ → ℂ} {s : ℂ exact Or.inl (ofReal_ne_zero.mpr hpi.ne') · -- summability of integrals of norms apply Summable.of_norm - convert h_sum.mul_left (Real.Gamma s.re) using 2 with i + convert! h_sum.mul_left (Real.Gamma s.re) using 2 with i simp_rw [← mul_assoc, mul_comm _ (a i), mul_assoc, norm_mul (a i), integral_const_mul] rw [← mul_div_assoc, mul_comm (Real.Gamma _), mul_div_assoc, norm_mul ‖a i‖, norm_norm] rcases hp i with hai | hpi @@ -71,7 +73,7 @@ lemma hasSum_mellin_pi_mul {a : ι → ℂ} {q : ι → ℝ} {F : ℝ → ℂ} { (h_sum : Summable fun i ↦ ‖a i‖ / (q i) ^ s.re) : HasSum (fun i ↦ π ^ (-s) * Gamma s * a i / q i ^ s) (mellin F s) := by have hp i : a i = 0 ∨ 0 < π * q i := by rcases hq i with h | h <;> simp [h, pi_pos] - convert hasSum_mellin hp hs (by simpa using hF) ?_ using 2 with i + convert! hasSum_mellin hp hs (by simpa using hF) ?_ using 2 with i · have : a i / ↑(π * q i) ^ s = π ^ (-s) * a i / q i ^ s := by rcases hq i with h | h · simp [h] @@ -101,7 +103,7 @@ lemma hasSum_mellin_pi_mul₀ {a : ι → ℂ} {p : ι → ℝ} {F : ℝ → ℂ a' i * rexp (-π * p i * t) := by simp [a'] simp_rw [this] at hF - convert hasSum_mellin_pi_mul hp' hs hF ?_ using 2 with i + convert! hasSum_mellin_pi_mul hp' hs hF ?_ using 2 with i · rcases eq_or_ne (p i) 0 with h | h <;> simp [a', h, ofReal_zero, zero_cpow hs', div_zero] · refine h_sum.of_norm_bounded (fun i ↦ ?_) @@ -119,12 +121,12 @@ lemma hasSum_mellin_pi_mul_sq {a : ι → ℂ} {r : ι → ℝ} {F : ℝ → ℂ HasSum (fun i ↦ Gammaℝ s * a i / |r i| ^ s) (mellin F (s / 2)) := by have hs' : 0 < (s / 2).re := by rw [div_ofNat_re]; positivity simp_rw [← sq_eq_zero_iff (a := r _)] at hF - convert hasSum_mellin_pi_mul₀ (fun i ↦ sq_nonneg (r i)) hs' hF ?_ using 3 with i + convert! hasSum_mellin_pi_mul₀ (fun i ↦ sq_nonneg (r i)) hs' hF ?_ using 3 with i · rw [← neg_div, Gammaℝ_def] · rw [← sq_abs, ofReal_pow, ← cpow_nat_mul'] · ring_nf all_goals rw [arg_ofReal_of_nonneg (abs_nonneg _)]; linarith [pi_pos] - · convert h_sum using 3 with i + · convert! h_sum using 3 with i rw [← sq_abs, ← rpow_natCast_mul (abs_nonneg _), div_ofNat_re, Nat.cast_ofNat, mul_div_cancel₀ _ two_pos.ne'] @@ -141,14 +143,14 @@ lemma hasSum_mellin_pi_mul_sq' {a : ι → ℂ} {r : ι → ℝ} {F : ℝ → if r i = 0 then 0 else (a i * r i * rexp (-π * r i ^ 2 * t)) := by split_ifs with h <;> simp [h] conv at hF => enter [t, ht, 1, i]; rw [this] - convert hasSum_mellin_pi_mul_sq hs₂ hF ?_ using 2 with i + convert! hasSum_mellin_pi_mul_sq hs₂ hF ?_ using 2 with i · rcases eq_or_ne (r i) 0 with h | h · rw [h, abs_zero, ofReal_zero, zero_cpow hs₁, zero_cpow hs₃, div_zero, div_zero] · rw [cpow_add _ _ (ofReal_ne_zero.mpr <| abs_ne_zero.mpr h), cpow_one] conv_rhs => enter [1]; rw [← sign_mul_abs (r i), ofReal_mul, ← ofRealHom_eq_coe, SignType.map_cast] field [h] - · convert h_sum using 2 with i + · convert! h_sum using 2 with i rcases eq_or_ne (r i) 0 with h | h · rw [h, abs_zero, ofReal_zero, zero_rpow hs₂.ne', zero_rpow hs.ne', div_zero, div_zero] · rw [add_re, one_re, rpow_add (abs_pos.mpr h), rpow_one, norm_mul, norm_real, diff --git a/Mathlib/NumberTheory/LSeries/Nonvanishing.lean b/Mathlib/NumberTheory/LSeries/Nonvanishing.lean index 88103232edbfaf..37c682c89a9bb9 100644 --- a/Mathlib/NumberTheory/LSeries/Nonvanishing.lean +++ b/Mathlib/NumberTheory/LSeries/Nonvanishing.lean @@ -234,7 +234,7 @@ private lemma re_log_comb_nonneg' {a : ℝ} (ha₀ : 0 ≤ a) (ha₁ : a < 1) {z · simp only [← mul_div_assoc, ← add_div] refine div_nonneg ?_ n.cast_nonneg rw [← pow_mul, pow_mul', sq, mul_re, ← sq, ← sq, ← sq_norm_sub_sq_re, norm_pow, hz] - convert (show 0 ≤ 2 * a ^ n * ((z ^ n).re + 1) ^ 2 by positivity) using 1 + convert! (show 0 ≤ 2 * a ^ n * ((z ^ n).re + 1) ^ 2 by positivity) using 1 ring -- This is the version of the technical positivity lemma for logarithms of Euler factors. @@ -252,7 +252,7 @@ private lemma re_log_comb_nonneg {n : ℕ} (hn : 2 ≤ n) {x : ℝ} (hx : 1 < x) simp only [neg_re, mul_re, I_re, ofReal_re, zero_mul, I_im, ofReal_im, mul_zero, sub_self, neg_zero, Real.rpow_zero, one_mul] rw [MulChar.one_apply hn', one_mul] - convert re_log_comb_nonneg' (by positivity) hn hz using 6 + convert! re_log_comb_nonneg' (by positivity) hn hz using 6 · simp only [ofReal_cpow n.cast_nonneg (-x), ofReal_natCast, ofReal_neg] · congr 2 rw [neg_add, cpow_add _ _ <| mod_cast by lia, ← ofReal_neg, ofReal_cpow n.cast_nonneg (-x), @@ -317,7 +317,7 @@ lemma LFunctionTrivChar_isBigO_near_one_horizontal : have : (fun w : ℂ ↦ LFunctionTrivChar N (1 + w)) =O[𝓝[≠] 0] (1 / ·) := by have H : Tendsto (fun w ↦ w * LFunctionTrivChar N (1 + w)) (𝓝[≠] 0) (𝓝 <| ∏ p ∈ N.primeFactors, (1 - (p : ℂ)⁻¹)) := by - convert (LFunctionTrivChar_residue_one (N := N)).comp (f := fun w ↦ 1 + w) ?_ using 1 + convert! (LFunctionTrivChar_residue_one (N := N)).comp (f := fun w ↦ 1 + w) ?_ using 1 · simp only [Function.comp_def, add_sub_cancel_left] · simpa only [tendsto_iff_comap, Homeomorph.coe_addLeft, add_zero, map_le_iff_le_comap] using ((Homeomorph.addLeft (1 : ℂ)).map_punctured_nhds_eq 0).le diff --git a/Mathlib/NumberTheory/LSeries/PrimesInAP.lean b/Mathlib/NumberTheory/LSeries/PrimesInAP.lean index 83bb2032551436..49052a193032d6 100644 --- a/Mathlib/NumberTheory/LSeries/PrimesInAP.lean +++ b/Mathlib/NumberTheory/LSeries/PrimesInAP.lean @@ -148,7 +148,7 @@ lemma abscissaOfAbsConv_residueClass_le_one : refine abscissaOfAbsConv_le_of_forall_lt_LSeriesSummable fun y hy ↦ ?_ unfold LSeriesSummable have := LSeriesSummable_vonMangoldt <| show 1 < (y : ℂ).re by simp only [ofReal_re, hy] - convert this.indicator {n : ℕ | (n : ZMod q) = a} + convert! this.indicator {n : ℕ | (n : ZMod q) = a} ext1 n by_cases hn : (n : ZMod q) = a · simp +contextual only [term, Set.indicator, Set.mem_setOf_eq, hn, ↓reduceIte, apply_ite, @@ -424,7 +424,7 @@ lemma not_summable_residueClass_prime_div (ha : IsUnit a) : ¬ Summable fun n : ℕ ↦ (if n.Prime then residueClass a n else 0) / n := by intro H have key : Summable fun n : ℕ ↦ residueClass a n / n := by - convert (summable_residueClass_non_primes_div a).add H using 2 with n + convert! (summable_residueClass_non_primes_div a).add H using 2 with n simp only [← add_div, ite_add_ite, zero_add, add_zero, ite_self] let C := ∑' n, residueClass a n / n have H₁ {x : ℝ} (hx : 1 < x) : ∑' n, residueClass a n / (n : ℝ) ^ x ≤ C := by diff --git a/Mathlib/NumberTheory/LSeries/SumCoeff.lean b/Mathlib/NumberTheory/LSeries/SumCoeff.lean index 888336e0efc5ac..ca48f9fc96eca5 100644 --- a/Mathlib/NumberTheory/LSeries/SumCoeff.lean +++ b/Mathlib/NumberTheory/LSeries/SumCoeff.lean @@ -110,8 +110,9 @@ private theorem LSeries_eq_mul_integral_aux {f : ℕ → ℂ} (hf : f 0 = 0) {r rw [← integral_const_mul] refine tendsto_nhds_unique ((tendsto_add_atTop_iff_nat 1).mpr hS.hasSum.tendsto_sum_nat) ?_ simp_rw [Nat.range_succ_eq_Icc_zero, LSeries.term_def₀ hf, mul_comm (f _)] - convert tendsto_sum_mul_atTop_nhds_one_sub_integral₀ (f := fun x ↦ (x : ℂ) ^ (-s)) (l := 0) - ?_ hf h₃ ?_ ?_ ?_ (integrableAtFilter_rpow_atTop_iff.mpr h₁) + convert! + tendsto_sum_mul_atTop_nhds_one_sub_integral₀ (f := fun x ↦ (x : ℂ) ^ (-s)) (l := 0) ?_ hf h₃ ?_ + ?_ ?_ (integrableAtFilter_rpow_atTop_iff.mpr h₁) · rw [zero_sub, ← integral_neg] refine setIntegral_congr_fun measurableSet_Ioi fun t ht ↦ ?_ rw [deriv_ofReal_cpow_const (zero_lt_one.trans ht).ne', h₄] diff --git a/Mathlib/NumberTheory/LSeries/ZMod.lean b/Mathlib/NumberTheory/LSeries/ZMod.lean index b525973a837ba5..0c52b1eb0d493d 100644 --- a/Mathlib/NumberTheory/LSeries/ZMod.lean +++ b/Mathlib/NumberTheory/LSeries/ZMod.lean @@ -478,7 +478,7 @@ theorem completedLFunction_one_sub_even (hΦ : Φ.Even) (s : ℂ) apply Countable.union <;> split_ifs <;> simp only [countable_singleton, countable_empty] - convert (this.isConnected_compl_of_one_lt_rank ?_).isPreconnected using 1 + convert! (this.isConnected_compl_of_one_lt_rank ?_).isPreconnected using 1 · ext x by_cases h : Φ 0 = 0 <;> by_cases h' : ∑ j, Φ j = 0 <;> diff --git a/Mathlib/NumberTheory/LegendreSymbol/AddCharacter.lean b/Mathlib/NumberTheory/LegendreSymbol/AddCharacter.lean index 70752949df7f28..f4c640a472ffb8 100644 --- a/Mathlib/NumberTheory/LegendreSymbol/AddCharacter.lean +++ b/Mathlib/NumberTheory/LegendreSymbol/AddCharacter.lean @@ -9,7 +9,6 @@ public import Mathlib.NumberTheory.Cyclotomic.PrimitiveRoots public import Mathlib.FieldTheory.Finite.Trace public import Mathlib.Algebra.Group.AddChar public import Mathlib.Data.ZMod.Units -public import Mathlib.Analysis.Complex.Polynomial.Basic /-! # Additive characters of finite rings and fields @@ -40,6 +39,7 @@ additive character @[expose] public section +assert_not_exists MeasureTheory.integral universe u v @@ -291,25 +291,4 @@ lemma starComp_apply (hR : 0 < ringChar R) {φ : AddChar R ℂ} (a : R) : end Ring -section Field - -variable (F : Type*) [Field F] [Finite F] - -private lemma ringChar_ne : ringChar ℂ ≠ ringChar F := by - simpa only [ringChar.eq_zero] using (CharP.ringChar_ne_zero_of_finite F).symm - -/-- A primitive additive character on the finite field `F` with values in `ℂ`. -/ -noncomputable def FiniteField.primitiveChar_to_Complex : AddChar F ℂ := by - letI ch := primitiveChar F ℂ <| by exact ringChar_ne F - refine MonoidHom.compAddChar ?_ ch.char - exact (IsCyclotomicExtension.algEquiv {(ch.n : ℕ)} ℂ (CyclotomicField ch.n ℂ) ℂ).toMonoidHom - -lemma FiniteField.primitiveChar_to_Complex_isPrimitive : - (primitiveChar_to_Complex F).IsPrimitive := by - refine IsPrimitive.compMulHom_of_isPrimitive (PrimitiveAddChar.prim _) ?_ - let nn := (primitiveChar F ℂ <| ringChar_ne F).n - exact (IsCyclotomicExtension.algEquiv {(nn : ℕ)} ℂ (CyclotomicField nn ℂ) ℂ).injective - -end Field - end AddChar diff --git a/Mathlib/NumberTheory/LegendreSymbol/Basic.lean b/Mathlib/NumberTheory/LegendreSymbol/Basic.lean index c6abf66a4691d4..d7a0950ee86474 100644 --- a/Mathlib/NumberTheory/LegendreSymbol/Basic.lean +++ b/Mathlib/NumberTheory/LegendreSymbol/Basic.lean @@ -128,7 +128,7 @@ theorem eq_pow (a : ℤ) : (legendreSym p a : ZMod p) = (a : ZMod p) ^ (p / 2) : generalize (a : ZMod 2) = b; fin_cases b · tauto · simp - · convert quadraticChar_eq_pow_of_char_ne_two' hc (a : ZMod p) + · convert! quadraticChar_eq_pow_of_char_ne_two' hc (a : ZMod p) exact (card p).symm /-- If `p ∤ a`, then `legendreSym p a` is `1` or `-1`. -/ diff --git a/Mathlib/NumberTheory/LegendreSymbol/Complex.lean b/Mathlib/NumberTheory/LegendreSymbol/Complex.lean new file mode 100644 index 00000000000000..dbcd67af21572d --- /dev/null +++ b/Mathlib/NumberTheory/LegendreSymbol/Complex.lean @@ -0,0 +1,42 @@ +/- +Copyright (c) 2022 Michael Stoll. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Michael Stoll +-/ +module + +public import Mathlib.Analysis.Complex.Polynomial.Basic +public import Mathlib.NumberTheory.LegendreSymbol.AddCharacter + +/-! +# Additive characters on finite fields + +We construct a primitive additive character on a finite field `F` with values in `ℂ`. +This file is kept separate from `Mathlib.NumberTheory.LegendreSymbol.AddCharacter` to avoid +importing the fundamental theorem of algebra and Bochner integral into that file. +-/ + +namespace AddChar + +section Field + +variable (F : Type*) [Field F] [Finite F] + +lemma ringChar_ne : ringChar ℂ ≠ ringChar F := by + simpa only [ringChar.eq_zero] using (CharP.ringChar_ne_zero_of_finite F).symm + +/-- A primitive additive character on the finite field `F` with values in `ℂ`. -/ +public noncomputable def FiniteField.primitiveChar_to_Complex : AddChar F ℂ := by + letI ch := primitiveChar F ℂ <| by exact ringChar_ne F + refine MonoidHom.compAddChar ?_ ch.char + exact (IsCyclotomicExtension.algEquiv {(ch.n : ℕ)} ℂ (CyclotomicField ch.n ℂ) ℂ).toMonoidHom + +public lemma FiniteField.primitiveChar_to_Complex_isPrimitive : + (primitiveChar_to_Complex F).IsPrimitive := by + refine IsPrimitive.compMulHom_of_isPrimitive (PrimitiveAddChar.prim _) ?_ + let nn := (primitiveChar F ℂ <| ringChar_ne F).n + exact (IsCyclotomicExtension.algEquiv {(nn : ℕ)} ℂ (CyclotomicField nn ℂ) ℂ).injective + +end Field + +end AddChar diff --git a/Mathlib/NumberTheory/LegendreSymbol/JacobiSymbol.lean b/Mathlib/NumberTheory/LegendreSymbol/JacobiSymbol.lean index 1c08757e918b68..b466522103763e 100644 --- a/Mathlib/NumberTheory/LegendreSymbol/JacobiSymbol.lean +++ b/Mathlib/NumberTheory/LegendreSymbol/JacobiSymbol.lean @@ -408,7 +408,7 @@ theorem quadratic_reciprocity' {a b : ℕ} (ha : Odd a) (hb : Odd b) : -- define the right-hand side for fixed `a` as a `ℕ →* ℤ` let rhs : ℕ → ℕ →* ℤ := fun a => { toFun := fun x => qrSign x a * J(x | a) - map_one' := by convert ← mul_one (M := ℤ) _; (on_goal 1 => symm); all_goals apply one_left + map_one' := by convert! ← mul_one (M := ℤ) _; (on_goal 1 => symm); all_goals apply one_left map_mul' := fun x y => by simp_rw [qrSign.mul_left x y a, Nat.cast_mul, mul_left, mul_mul_mul_comm] } have rhs_apply : ∀ a b : ℕ, rhs a b = qrSign b a * J(b | a) := fun a b => rfl diff --git a/Mathlib/NumberTheory/LocalField/Basic.lean b/Mathlib/NumberTheory/LocalField/Basic.lean index 48bf6912f0d03c..dd9694d4d63bb9 100644 --- a/Mathlib/NumberTheory/LocalField/Basic.lean +++ b/Mathlib/NumberTheory/LocalField/Basic.lean @@ -88,8 +88,9 @@ lemma isCompact_closedBall (γ : ValueGroupWithZero K) : IsCompact { x | valuati dsimp at hx ⊢ exact hx.trans_lt (hr.trans_le hr1) simp_rw [← (valuation K).restrict_le_iff] at H ⊢ - convert (hs'.of_isClosed_subset (Valued.isClosed_closedBall K _) H).image - (Homeomorph.mulLeft₀ (γ / r) (by simp [hr, div_eq_zero_iff, hγ])).continuous using 1 + convert! + (hs'.of_isClosed_subset (Valued.isClosed_closedBall K _) H).image + (Homeomorph.mulLeft₀ (γ / r) (by simp [hr, div_eq_zero_iff, hγ])).continuous using 1 refine .trans ?_ (Equiv.image_eq_preimage_symm _ _).symm ext x simp only [Set.mem_setOf_eq, Homeomorph.coe_symm_toEquiv, Homeomorph.mulLeft₀_symm_apply, inv_div, diff --git a/Mathlib/NumberTheory/LucasLehmer.lean b/Mathlib/NumberTheory/LucasLehmer.lean index 84cc4da4548ac3..1294928b60e53c 100644 --- a/Mathlib/NumberTheory/LucasLehmer.lean +++ b/Mathlib/NumberTheory/LucasLehmer.lean @@ -391,7 +391,7 @@ lemma α_pow (i : ℕ) : (α : X q) ^ (2 * i + 1) = 3 ^ i * α := by instance : CharP (X q) q where cast_eq_zero_iff x := by - convert ZMod.natCast_eq_zero_iff _ _ + convert! ZMod.natCast_eq_zero_iff _ _ exact ⟨congr_arg Prod.fst, fun hx ↦ ext hx (by simp)⟩ instance : Coe (ZMod ↑q) (X q) where @@ -471,7 +471,7 @@ theorem card_eq : Fintype.card (X q) = q ^ 2 := by /-- There are strictly fewer than `q^2` units, since `0` is not a unit. -/ nonrec theorem card_units_lt (w : 1 < q) : Fintype.card (X q)ˣ < q ^ 2 := by have : Fact (1 < (q : ℕ)) := ⟨w⟩ - convert card_units_lt (X q) + convert! card_units_lt (X q) rw [card_eq] end X diff --git a/Mathlib/NumberTheory/Modular.lean b/Mathlib/NumberTheory/Modular.lean index 16b47375eac53a..8885ca638d2539 100644 --- a/Mathlib/NumberTheory/Modular.lean +++ b/Mathlib/NumberTheory/Modular.lean @@ -95,7 +95,7 @@ theorem bottom_row_surj {R : Type*} [CommRing R] : rintro cd ⟨b₀, a, gcd_eqn⟩ let A := of ![![a, -b₀], cd] have det_A_1 : det A = 1 := by - convert gcd_eqn + convert! gcd_eqn rw [det_fin_two] simp [A, (by ring : a * cd 1 + b₀ * cd 0 = b₀ * cd 0 + a * cd 1)] refine ⟨⟨A, det_A_1⟩, Set.mem_univ _, ?_⟩ @@ -152,7 +152,7 @@ theorem tendsto_normSq_coprime_pair : simp only [ofReal_im, ofReal_re, mul_im, zero_add, mul_zero] have hf' : IsClosedEmbedding f := f.isClosedEmbedding_of_injective hf have h₂ : Tendsto (fun p : Fin 2 → ℤ => ((↑) : ℤ → ℝ) ∘ p) cofinite (cocompact _) := by - convert Tendsto.pi_map_coprodᵢ fun _ => Int.tendsto_coe_cofinite + convert! Tendsto.pi_map_coprodᵢ fun _ => Int.tendsto_coe_cofinite · rw [coprodᵢ_cofinite] · rw [coprodᵢ_cocompact] exact tendsto_normSq_cocompact_atTop.comp (hf'.tendsto_cocompact.comp h₂) @@ -207,7 +207,7 @@ theorem tendsto_lcRow0 {cd : Fin 2 → ℤ} (hcd : IsCoprime (cd 0) (cd 1)) : cocompact_ℝ_to_cofinite_ℤ_matrix.comp Subtype.coe_injective.tendsto_cofinite have hf₂ : IsClosedEmbedding (lcRow0Extend hcd) := (lcRow0Extend hcd).toContinuousLinearEquiv.toHomeomorph.isClosedEmbedding - convert hf₂.tendsto_cocompact.comp (hf₁.comp Subtype.coe_injective.tendsto_cofinite) using 1 + convert! hf₂.tendsto_cocompact.comp (hf₁.comp Subtype.coe_injective.tendsto_cofinite) using 1 ext ⟨g, rfl⟩ i j : 3 fin_cases i <;> [fin_cases j; skip] -- the following are proved by `simp`, but it is replaced by `simp only` to avoid timeouts. @@ -217,7 +217,7 @@ theorem tendsto_lcRow0 {cd : Fin 2 → ℤ} (hcd : IsCoprime (cd 0) (cd 1)) : LinearMap.GeneralLinearGroup.coeFn_generalLinearEquiv, GeneralLinearGroup.coe_toLin, val_planeConformalMatrix, neg_neg, mulVecLin_apply, mulVec, dotProduct, Fin.sum_univ_two, cons_val_one, mB, f₁] - · convert congr_arg (fun n : ℤ => (-n : ℝ)) g.det_coe.symm using 1 + · convert! congr_arg (fun n : ℤ => (-n : ℝ)) g.det_coe.symm using 1 simp only [Fin.zero_eta, Function.comp_apply, lcRow0Extend_apply, cons_val_zero, LinearMap.GeneralLinearGroup.coeFn_generalLinearEquiv, GeneralLinearGroup.coe_toLin, mulVecLin_apply, mulVec, dotProduct, det_fin_two, f₁] @@ -239,7 +239,7 @@ theorem smul_eq_lcRow0_add {p : Fin 2 → ℤ} (hp : IsCoprime (p 0) (p 1)) (hg have nonZ2 : (p 0 : ℂ) * z + p 1 ≠ 0 := by simpa using linear_ne_zero z this subst hg rw [coe_specialLinearGroup_apply] - replace nonZ2 : z * (g 1 0 : ℂ) + g 1 1 ≠ 0 := by convert nonZ2 using 1; ring + replace nonZ2 : z * (g 1 0 : ℂ) + g 1 1 ≠ 0 := by convert! nonZ2 using 1; ring have H := congr(Int.cast (R := ℂ) $(det_fin_two g)) simp at H simp [field] @@ -259,7 +259,7 @@ theorem tendsto_abs_re_smul {p : Fin 2 → ℤ} (hp : IsCoprime (p 0) (p 1)) : let f := Homeomorph.mulRight₀ _ this let ff := Homeomorph.addRight (((p 1 : ℂ) * z - p 0) / (((p 0 : ℂ) ^ 2 + (p 1 : ℂ) ^ 2) * (p 0 * z + p 1))).re - convert (f.trans ff).isClosedEmbedding.tendsto_cocompact.comp (tendsto_lcRow0 hp) with _ _ g + convert! (f.trans ff).isClosedEmbedding.tendsto_cocompact.comp (tendsto_lcRow0 hp) with _ _ g change ((g : SL(2, ℤ)) • z).re = lcRow0 p ↑(↑g : SL(2, ℝ)) / ((p 0 : ℝ) ^ 2 + (p 1 : ℝ) ^ 2) + @@ -487,7 +487,7 @@ private lemma cases_c_zero (hz : z ∈ 𝒟) (hg : g • z ∈ 𝒟) (hc : g 1 0 wlog hd : 0 ≤ g 1 1 · specialize this hz (g := -g) (SL_neg_smul g z ▸ hg) (by simpa using hc) ?_ · simpa using (not_le.mp hd).le - convert this using 2 <;> simp [neg_eq_iff_eq_neg, or_comm] + convert! this using 2 <;> simp [neg_eq_iff_eq_neg, or_comm] have hd' : g 1 1 = 1 ∨ g 1 1 = -1 := by simpa [hc, isCoprime_zero_left, Int.isUnit_iff] using bottom_row_coprime g replace hd : g 1 1 = 1 := by grind @@ -523,7 +523,7 @@ private lemma cases_d_of_c_eq_one (hz : z ∈ 𝒟) (hg' : ‖denom g z‖ ≤ 1 rw [add_re, intCast_re, add_comm, coe_re] at this have := (abs_sub_abs_le_abs_add ..).trans this grw [sub_le_iff_le_add, hz.2, ← Int.cast_abs, ← Int.le_floor] at this - convert this + convert! this rw [eq_comm, Int.floor_eq_iff] norm_num @@ -616,7 +616,7 @@ private lemma case_c_one_d_neg_one (hz : z ∈ 𝒟) (hg : g • z ∈ 𝒟) (hg simp [this] ring_nf have hnorm : ‖(z : ℂ) - 1‖ ≤ 1 := by - convert hg' using 2 + convert! hg' using 2 simp [denom, hc, hd, sub_eq_add_neg] rw [norm_def, Real.sqrt_le_one] at hnorm have : normSq (z - 1) = normSq z + (-2 * z.re + 1) := by @@ -842,7 +842,7 @@ lemma isClosed_coe_fd : IsClosed ((↑) '' 𝒟 : Set ℂ) := by · exact isClosed_le continuous_const Complex.continuous_im · exact isClosed_le continuous_const continuous_norm · exact isClosed_le (continuous_abs.comp Complex.continuous_re) continuous_const - convert this using 1 + convert! this using 1 ext x refine ⟨fun ⟨him, hre, hnorm⟩ ↦ ⟨him.le, hre, hnorm⟩, fun ⟨him, hre, hnorm⟩ ↦ ⟨?_, hre, hnorm⟩⟩ exact him.lt_of_ne' <| by grind [abs_re_eq_norm] @@ -896,7 +896,7 @@ private lemma mem_closure_of_arc {x : ℍ} (hxnorm : ‖(x : ℂ)‖ = 1) (hxre refine mem_closure_of_one_lt_norm ?_ (by simpa using hxre) suffices 1 < ‖(x : ℂ)‖ ^ 2 + a ^ 2 + 2 * a * x.im by rw [← one_lt_normSq_iff] - convert this + convert! this simp [← normSq_eq_norm_sq, normSq_apply] ring rw [hxnorm, one_pow, add_assoc, lt_add_iff_pos_right] diff --git a/Mathlib/NumberTheory/ModularForms/ArithmeticSubgroups.lean b/Mathlib/NumberTheory/ModularForms/ArithmeticSubgroups.lean index 46cc5675389c54..eba88f2176e2fc 100644 --- a/Mathlib/NumberTheory/ModularForms/ArithmeticSubgroups.lean +++ b/Mathlib/NumberTheory/ModularForms/ArithmeticSubgroups.lean @@ -220,9 +220,9 @@ variable {R : Type*} [CommRing R] rintro g (hg | hg) · exact HasDetPlusMinusOne.det_eq hg · by_cases hn : Even (Fintype.card n) - · convert HasDetPlusMinusOne.det_eq hg using 1 <;> + · convert! HasDetPlusMinusOne.det_eq hg using 1 <;> simp [Units.ext_iff, det_neg, hn] - · convert (HasDetPlusMinusOne.det_eq hg).symm using 1 <;> + · convert! (HasDetPlusMinusOne.det_eq hg).symm using 1 <;> simp [Units.ext_iff, det_neg, Nat.not_even_iff_odd.mp hn, neg_eq_iff_eq_neg] lemma Subgroup.hasDetOne_adjoinNegOne_iff {𝒢 : Subgroup (GL n R)} (hn : Even (Fintype.card n)) : diff --git a/Mathlib/NumberTheory/ModularForms/Basic.lean b/Mathlib/NumberTheory/ModularForms/Basic.lean index c1ab072b3417d7..ec1d0eea35c943 100644 --- a/Mathlib/NumberTheory/ModularForms/Basic.lean +++ b/Mathlib/NumberTheory/ModularForms/Basic.lean @@ -565,6 +565,11 @@ def mcast {a b : ℤ} {Γ Γ' : Subgroup (GL (Fin 2) ℝ)} (h : a = b) (f : Modu holo' := f.holo' bdd_at_cusps' hc := h ▸ f.bdd_at_cusps' (hΓ ▸ hc) +@[simp] +lemma mcast_eq_zero_iff {a b : ℤ} {Γ Γ' : Subgroup (GL (Fin 2) ℝ)} (h : a = b) + (hΓ : Γ' = Γ) (f : ModularForm Γ a) : mcast h f hΓ = 0 ↔ f = 0 := by + simp [← coe_eq_zero_iff, ← coe_eq_zero_iff (f := f)] + @[ext (iff := false)] theorem gradedMonoid_eq_of_cast {Γ : Subgroup (GL (Fin 2) ℝ)} {a b : GradedMonoid (ModularForm Γ)} (h : a.fst = b.fst) (h2 : mcast h a.snd = b.snd) : a = b := by diff --git a/Mathlib/NumberTheory/ModularForms/CongruenceSubgroups.lean b/Mathlib/NumberTheory/ModularForms/CongruenceSubgroups.lean index cbf6289c785ee8..7fd1f98ac389c4 100644 --- a/Mathlib/NumberTheory/ModularForms/CongruenceSubgroups.lean +++ b/Mathlib/NumberTheory/ModularForms/CongruenceSubgroups.lean @@ -160,7 +160,7 @@ theorem Gamma1_mem (N : ℕ) (A : SL(2, ℤ)) : A ∈ Gamma1 N ↔ rw [Gamma1_to_Gamma0_mem] at hx simp only [Subgroup.mem_top, true_and] at hxx rw [← hxx] - convert hx + convert! hx · intro ha simp_rw [Gamma1, Subgroup.mem_map] have hA : A ∈ Gamma0 N := by simp [ha.right.right, Gamma0_mem] diff --git a/Mathlib/NumberTheory/ModularForms/CuspFormSubmodule.lean b/Mathlib/NumberTheory/ModularForms/CuspFormSubmodule.lean index dcd9a8cd6975d3..e2726fc0b67137 100644 --- a/Mathlib/NumberTheory/ModularForms/CuspFormSubmodule.lean +++ b/Mathlib/NumberTheory/ModularForms/CuspFormSubmodule.lean @@ -82,6 +82,11 @@ def CuspForm.equivCuspFormSubmodule (Γ : Subgroup (GL (Fin 2) ℝ)) (k : ℤ) [ CuspForm Γ k ≃ₗ[ℂ] cuspFormSubmodule Γ k := LinearEquiv.ofInjective CuspForm.toModularFormₗ CuspForm.toModularFormₗ_injective +/-- The underlying modular form (via `toModularFormₗ`) of a `CuspForm` is itself a cusp form. -/ +lemma CuspForm.isCuspForm_toModularFormₗ {Γ : Subgroup (GL (Fin 2) ℝ)} [Γ.HasDetOne] + (f : CuspForm Γ k) : ModularForm.IsCuspForm f.toModularFormₗ := by + simp [← mem_cuspFormSubmodule_iff, ModularForm.cuspFormSubmodule] + /-- A modular form is a cusp form if and only if it vanishes at every cusp. This is the general characterization valid for any subgroup. -/ lemma isCuspForm_iff [Γ.HasDetOne] (f : ModularForm Γ k) : diff --git a/Mathlib/NumberTheory/ModularForms/Cusps.lean b/Mathlib/NumberTheory/ModularForms/Cusps.lean index 6703ae93f68c74..102372815d0acd 100644 --- a/Mathlib/NumberTheory/ModularForms/Cusps.lean +++ b/Mathlib/NumberTheory/ModularForms/Cusps.lean @@ -68,7 +68,7 @@ lemma IsCusp.smul {c : OnePoint ℝ} {𝒢 : Subgroup (GL (Fin 2) ℝ)} (hc : Is lemma IsCusp.smul_of_mem {c : OnePoint ℝ} {𝒢 : Subgroup (GL (Fin 2) ℝ)} (hc : IsCusp c 𝒢) {g : GL (Fin 2) ℝ} (hg : g ∈ 𝒢) : IsCusp (g • c) 𝒢 := by - convert hc.smul g + convert! hc.smul g ext x rw [Subgroup.mem_pointwise_smul_iff_inv_smul_mem, ← ConjAct.toConjAct_inv, ConjAct.toConjAct_smul, inv_inv, Subgroup.mul_mem_cancel_right _ hg, diff --git a/Mathlib/NumberTheory/ModularForms/DedekindEta.lean b/Mathlib/NumberTheory/ModularForms/DedekindEta.lean index b8b69cf7e4c144..ca869fb317bc52 100644 --- a/Mathlib/NumberTheory/ModularForms/DedekindEta.lean +++ b/Mathlib/NumberTheory/ModularForms/DedekindEta.lean @@ -162,7 +162,7 @@ lemma logDeriv_qParam (h : ℝ) (z : ℂ) : logDeriv (𝕢 h) z = 2 * π * I / h lemma summable_logDeriv_one_sub_eta_q {z : ℂ} (hz : z ∈ ℍₒ) : Summable fun i ↦ logDeriv (1 - eta_q i ·) z := by have := summable_norm_pow_mul_geometric_div_one_sub 1 (norm_qParam_lt_one 1 ⟨z, hz⟩) - convert ((summable_nat_add_iff 1).mpr this).mul_left (-2 * π * I) using 1 with n + convert! ((summable_nat_add_iff 1).mpr this).mul_left (-2 * π * I) using 1 with n grind [one_sub_eta_logDeriv_eq] open EisensteinSeries in diff --git a/Mathlib/NumberTheory/ModularForms/Derivative.lean b/Mathlib/NumberTheory/ModularForms/Derivative.lean index b557c4adfb676e..e7f4df6c11143a 100644 --- a/Mathlib/NumberTheory/ModularForms/Derivative.lean +++ b/Mathlib/NumberTheory/ModularForms/Derivative.lean @@ -164,7 +164,7 @@ If `F : ℍ → ℂ` is MDifferentiable, then `serreDerivative k F` is also MDif theorem serreDerivative_mdifferentiable {F : ℍ → ℂ} (k : ℂ) (hF : MDiff F) : MDiff (serreDerivative k F) := by refine (normalizedDerivOfComplex_mdifferentiable hF).sub ?_ - convert + convert! (MDifferentiable.mul mdifferentiable_const (E2_mdifferentiable.mul hF) : MDiff (fun z ↦ (k * 12⁻¹) * (EisensteinSeries.E2 z * F z))) simp [Pi.mul_apply, mul_assoc, mul_left_comm, mul_comm] diff --git a/Mathlib/NumberTheory/ModularForms/Discriminant.lean b/Mathlib/NumberTheory/ModularForms/Discriminant.lean index 8a2a1636a7e81f..1e71c038af3f95 100644 --- a/Mathlib/NumberTheory/ModularForms/Discriminant.lean +++ b/Mathlib/NumberTheory/ModularForms/Discriminant.lean @@ -164,7 +164,7 @@ lemma tendsto_atImInfty_tprod_one_sub_eta_q_pow : exact pow_le_pow_left₀ (norm_nonneg _) (mem_ball_zero_iff.mp hq).le _ have := (htprod.comp (UpperHalfPlane.qParam_tendsto_atImInfty zero_lt_one)).pow 24 simp only [Periodic.qParam, ofReal_one, div_one, comp_apply, one_pow, eta_q] at * - convert this using 2 with τ + convert! this using 2 with τ rw [Multipliable.tprod_pow] apply (multipliableLocallyUniformlyOn_eta.multipliable τ.2).congr simp [eta_q, Periodic.qParam, ← exp_nat_mul] diff --git a/Mathlib/NumberTheory/ModularForms/EisensteinSeries/Defs.lean b/Mathlib/NumberTheory/ModularForms/EisensteinSeries/Defs.lean index 9e3b16905ff965..510b6f87e8faaa 100644 --- a/Mathlib/NumberTheory/ModularForms/EisensteinSeries/Defs.lean +++ b/Mathlib/NumberTheory/ModularForms/EisensteinSeries/Defs.lean @@ -191,7 +191,7 @@ theorem eisSummand_SL2_apply (k : ℤ) (i : (Fin 2 → ℤ)) (A : SL(2, ℤ)) (z simp only [eisSummand, vecMul, vec2_dotProduct, denom, UpperHalfPlane.specialLinearGroup_apply] have h (a b c d u v : ℂ) (hc : c * z + d ≠ 0) : (u * ((a * z + b) / (c * z + d)) + v) ^ (-k) = (c * z + d) ^ k * ((u * a + v * c) * z + (u * b + v * d)) ^ (-k) := by - replace hc : z * c + d ≠ 0 := by convert hc using 1; ring + replace hc : z * c + d ≠ 0 := by convert! hc using 1; ring field_simp simp [div_zpow] ring_nf diff --git a/Mathlib/NumberTheory/ModularForms/EisensteinSeries/E2/Summable.lean b/Mathlib/NumberTheory/ModularForms/EisensteinSeries/E2/Summable.lean index 1ed2d8d1bea48b..24a842b2385077 100644 --- a/Mathlib/NumberTheory/ModularForms/EisensteinSeries/E2/Summable.lean +++ b/Mathlib/NumberTheory/ModularForms/EisensteinSeries/E2/Summable.lean @@ -178,7 +178,7 @@ lemma tsum_symmetricIco_tsum_eq_S_act : private lemma telescope_aux (z : ℂ) (m : ℤ) (b : ℕ) : ∑ n ∈ Ico (-b : ℤ) b, (1 / ((m : ℂ) * z + n) - 1 / (m * z + n + 1)) = 1 / (m * z - b) - 1 / (m * z + b) := by - convert sum_Ico_int_sub b (fun n ↦ 1 / ((m : ℂ) * z + n)) using 2 <;> + convert! sum_Ico_int_sub b (fun n ↦ 1 / ((m : ℂ) * z + n)) using 2 <;> simp [add_assoc, sub_eq_add_neg] lemma tsum_symmetricIco_linear_sub_linear_add_one_eq_zero (m : ℤ) : @@ -272,7 +272,7 @@ lemma tsum_symmetricIco_tsum_sub_eq : lemma tsum_tsum_symmetricIco_sub_eq : ∑' m : ℤ, ∑'[symmetricIco ℤ] n : ℤ, (1 / ((m : ℂ) * z + n) - 1 / (m * z + n + 1)) = 0 := by - convert tsum_zero + convert! tsum_zero exact tsum_symmetricIco_linear_sub_linear_add_one_eq_zero z _ end Auxiliary diff --git a/Mathlib/NumberTheory/ModularForms/EisensteinSeries/MDifferentiable.lean b/Mathlib/NumberTheory/ModularForms/EisensteinSeries/MDifferentiable.lean index aefab5b501e602..d56d84dbb2c919 100644 --- a/Mathlib/NumberTheory/ModularForms/EisensteinSeries/MDifferentiable.lean +++ b/Mathlib/NumberTheory/ModularForms/EisensteinSeries/MDifferentiable.lean @@ -54,7 +54,8 @@ theorem eisensteinSeriesSIF_mdifferentiable {k : ℤ} {N : ℕ} (hk : 3 ≤ k) ( MDiff (eisensteinSeriesSIF a k) := by intro τ suffices DifferentiableAt ℂ (↑ₕeisensteinSeriesSIF a k) τ.1 by - convert MDifferentiableAt.comp τ (DifferentiableAt.mdifferentiableAt this) τ.mdifferentiable_coe + convert! + MDifferentiableAt.comp τ (DifferentiableAt.mdifferentiableAt this) τ.mdifferentiable_coe exact funext fun z ↦ (comp_ofComplex (eisensteinSeriesSIF a k) z).symm refine DifferentiableOn.differentiableAt ?_ (isOpen_upperHalfPlaneSet.mem_nhds τ.2) exact (eisensteinSeries_tendstoLocallyUniformlyOn hk a).differentiableOn diff --git a/Mathlib/NumberTheory/ModularForms/EisensteinSeries/QExpansion.lean b/Mathlib/NumberTheory/ModularForms/EisensteinSeries/QExpansion.lean index b6d65d4acfecab..00915ba0ddc93d 100644 --- a/Mathlib/NumberTheory/ModularForms/EisensteinSeries/QExpansion.lean +++ b/Mathlib/NumberTheory/ModularForms/EisensteinSeries/QExpansion.lean @@ -71,7 +71,7 @@ private lemma aux_IsBigO_mul (k l : ℕ) (p : ℝ) {f : ℕ → ℂ} simpa [h1] using isBigO_ofReal_right.mp (Asymptotics.isBigO_const_mul_self ((2 * π * I / p) ^ k) (fun (n : ℕ) ↦ (↑(n ^ k) : ℝ)) atTop) push_cast - convert hf.mul h0 + convert! hf.mul h0 ring open BoundedContinuousFunction in @@ -102,7 +102,7 @@ theorem summableLocallyUniformlyOn_iteratedDerivWithin_smul_cexp (k l : ℕ) {f norm_natCast, abs_norm, ge_iff_le, r, c] at * rw [← mul_assoc] gcongr - convert h0 + convert! h0 rw [← norm_pow, ← exp_nsmul'] /-- This is a version of `summableLocallyUniformlyOn_iteratedDerivWithin_smul_cexp` for level one @@ -299,7 +299,7 @@ private lemma eisensteinSeries_coeff_identity {k : ℕ} (hk2 : Even k) (hkn0 : k lemma EisensteinSeries.q_expansion_bernoulli {k : ℕ} (hk : 3 ≤ k) (hk2 : Even k) (z : ℍ) : E hk z = 1 - (2 * k / bernoulli k) * ∑' n : ℕ+, σ (k - 1) n * cexp (2 * π * I * z) ^ (n : ℤ) := by - convert q_expansion_riemannZeta hk hk2 z using 1 + convert! q_expansion_riemannZeta hk hk2 z using 1 rw [eisensteinSeries_coeff_identity hk2 (by grind), neg_mul, ← sub_eq_add_neg] section NonZero @@ -340,7 +340,7 @@ lemma EisensteinSeries.E_qExpansion_coeff {k : ℕ} (hk : 3 ≤ k) (hk2 : Even k rw [this, ← tsum_pnat_eq_tsum_succ (f := fun n ↦ (σ (k - 1) n : ℂ) * cexp (2 * π * I * τ) ^ n)] ring rw [hval] - convert (hS.mul_left β).hasSum using 1 + convert! (hS.mul_left β).hasSum using 1 · grind [Periodic.qParam, ofReal_one, div_one] · rw [tsum_mul_left] diff --git a/Mathlib/NumberTheory/ModularForms/JacobiTheta/Bounds.lean b/Mathlib/NumberTheory/ModularForms/JacobiTheta/Bounds.lean index 3013528e320515..ebe1e446cc64db 100644 --- a/Mathlib/NumberTheory/ModularForms/JacobiTheta/Bounds.lean +++ b/Mathlib/NumberTheory/ModularForms/JacobiTheta/Bounds.lean @@ -115,7 +115,7 @@ Here we use direct comparison with a geometric series. lemma F_nat_zero_le {a : ℝ} (ha : 0 ≤ a) {t : ℝ} (ht : 0 < t) : ‖F_nat 0 a t‖ ≤ rexp (-π * a ^ 2 * t) / (1 - rexp (-π * t)) := by refine tsum_of_norm_bounded ?_ (f_le_g_nat 0 ha ht) - convert (hasSum_geometric_of_lt_one (exp_pos _).le <| exp_lt_aux ht).mul_left _ using 1 + convert! (hasSum_geometric_of_lt_one (exp_pos _).le <| exp_lt_aux ht).mul_left _ using 1 ext1 n simp only [g_nat] rw [← Real.exp_nat_mul, ← Real.exp_add] @@ -123,7 +123,7 @@ lemma F_nat_zero_le {a : ℝ} (ha : 0 ≤ a) {t : ℝ} (ht : 0 < t) : lemma F_nat_zero_zero_sub_le {t : ℝ} (ht : 0 < t) : ‖F_nat 0 0 t - 1‖ ≤ rexp (-π * t) / (1 - rexp (-π * t)) := by - convert F_nat_zero_le zero_le_one ht using 2 + convert! F_nat_zero_le zero_le_one ht using 2 · rw [F_nat, (summable_f_nat 0 0 ht).tsum_eq_zero_add, f_nat, Nat.cast_zero, add_zero, pow_zero, one_mul, pow_two, mul_zero, mul_zero, zero_mul, exp_zero, add_comm, add_sub_cancel_right] simp_rw [F_nat, f_nat, Nat.cast_add, Nat.cast_one, add_zero] @@ -166,12 +166,12 @@ lemma F_nat_one_le {a : ℝ} (ha : 0 ≤ a) {t : ℝ} (ht : 0 < t) : apply HasSum.add · have h0' : ‖rexp (-π * t)‖ < 1 := by simpa only [norm_eq_abs, abs_exp] using exp_lt_aux ht - convert (hasSum_coe_mul_geometric_of_norm_lt_one h0').mul_left (exp (-π * a ^ 2 * t)) using 1 + convert! (hasSum_coe_mul_geometric_of_norm_lt_one h0').mul_left (exp (-π * a ^ 2 * t)) using 1 · ext1 n rw [mul_comm (exp _), ← Real.exp_nat_mul, mul_assoc (n : ℝ), ← Real.exp_add] ring_nf · rw [mul_add, add_mul, mul_one, exp_add, mul_div_assoc] - · convert (hasSum_geometric_of_lt_one (exp_pos _).le <| exp_lt_aux ht).mul_left _ using 1 + · convert! (hasSum_geometric_of_lt_one (exp_pos _).le <| exp_lt_aux ht).mul_left _ using 1 ext1 n rw [← Real.exp_nat_mul, mul_assoc _ (exp _), ← Real.exp_add] ring_nf @@ -239,8 +239,9 @@ def F_int (k : ℕ) (a : UnitAddCircle) (t : ℝ) : ℝ := lemma F_int_eq_of_mem_Icc (k : ℕ) {a : ℝ} (ha : a ∈ Icc 0 1) {t : ℝ} (ht : 0 < t) : F_int k a t = (F_nat k a t) + (F_nat k (1 - a) t) := by simp only [F_int, F_nat, Function.Periodic.lift_coe] - convert ((summable_f_nat k a ht).hasSum.int_rec (summable_f_nat k (1 - a) ht).hasSum).tsum_eq - using 3 with n + convert! + ((summable_f_nat k a ht).hasSum.int_rec (summable_f_nat k (1 - a) ht).hasSum).tsum_eq using + 3 with n cases n · rw [f_int_ofNat _ ha.1] · rw [f_int_negSucc _ ha.2] diff --git a/Mathlib/NumberTheory/ModularForms/JacobiTheta/OneVariable.lean b/Mathlib/NumberTheory/ModularForms/JacobiTheta/OneVariable.lean index 868715865e478b..71fbd1eab9241f 100644 --- a/Mathlib/NumberTheory/ModularForms/JacobiTheta/OneVariable.lean +++ b/Mathlib/NumberTheory/ModularForms/JacobiTheta/OneVariable.lean @@ -78,7 +78,7 @@ theorem hasSum_nat_jacobiTheta {τ : ℂ} (hτ : 0 < im τ) : Int.cast_zero, sq (0 : ℂ), mul_zero, zero_mul, neg_sq, ← mul_two, Complex.exp_zero, add_sub_assoc, (by norm_num : (1 : ℂ) - 1 * 2 = -1), ← sub_eq_add_neg, Nat.cast_add, Nat.cast_one] at this - convert this.div_const 2 using 1 + convert! this.div_const 2 using 1 simp_rw [mul_div_cancel_right₀ _ (two_ne_zero' ℂ)] theorem jacobiTheta_eq_tsum_nat {τ : ℂ} (hτ : 0 < im τ) : diff --git a/Mathlib/NumberTheory/ModularForms/LevelOne/DimensionFormula.lean b/Mathlib/NumberTheory/ModularForms/LevelOne/DimensionFormula.lean index 493714e6aa38f0..deda35af7c2702 100644 --- a/Mathlib/NumberTheory/ModularForms/LevelOne/DimensionFormula.lean +++ b/Mathlib/NumberTheory/ModularForms/LevelOne/DimensionFormula.lean @@ -11,10 +11,10 @@ public import Mathlib.NumberTheory.ModularForms.Discriminant import Mathlib.Algebra.Order.Floor.Semifield /-! -# Dimension formula for level 1 modular forms +# Dimension formula and Sturm bound for level 1 modular forms -This file proves the dimension formula for the space of modular forms for `𝒮ℒ` (= `SL(2, ℤ)`) -of even weight. +This file proves the dimension formula and the Sturm bound for the space of modular forms +for `𝒮ℒ` (= `SL(2, ℤ)`) of even weight. ## Main results @@ -23,6 +23,9 @@ of even weight. * `ModularForm.dimension_level_one`: the full dimension formula for all even `k : ℕ`. * `ModularForm.levelOne_odd_weight_rank_zero`: modular forms of odd weight are zero. * A `FiniteDimensional ℂ (ModularForm 𝒮ℒ k)` instance for every `k : ℤ`. +* `ModularForm.sturm_bound_levelOne`: a modular form `f : ModularForm 𝒮ℒ k` whose q-expansion + has order strictly greater than `k / 12` is identically zero. +* `ModularForm.sturm_bound_levelOne_nat`: convenience version for `k : ℕ`. -/ @[expose] public noncomputable section @@ -49,38 +52,33 @@ def ofMulDiscriminant (f : ModularForm 𝒮ℒ (k - 12)) : CuspForm 𝒮ℒ k := lemma ofMulDiscriminant_apply (f : ModularForm 𝒮ℒ (k - 12)) (z : ℍ) : (ofMulDiscriminant f) z = Δ z * f z := rfl -private lemma divByDiscriminant_slash_eq (f : CuspForm 𝒮ℒ k) (γ : SL(2, ℤ)) : +lemma divByDiscriminant_slash_eq (f : CuspForm 𝒮ℒ k) (γ : SL(2, ℤ)) : (fun z ↦ f z / Δ z) ∣[k - 12] γ = fun z ↦ f z / Δ z := by have hγ : (γ : GL (Fin 2) ℝ) ∈ 𝒮ℒ := ⟨γ, rfl⟩ change (⇑f / ⇑CuspForm.discriminant) ∣[k - 12] γ = ⇑f / ⇑CuspForm.discriminant simp_rw [div_slash_SL2, SL_slash, slash_action_eqn _ _ hγ] -/-- Divide a cusp form by the discriminant to get a modular form of weight `k - 12`. -/ -@[no_expose] def divDiscriminant (f : CuspForm 𝒮ℒ k) : ModularForm 𝒮ℒ (k - 12) where - toFun z := f z / Δ z - slash_action_eq' := fun _ ⟨γ, hγ⟩ ↦ hγ ▸ divByDiscriminant_slash_eq f γ - holo' := f.holo'.div CuspForm.discriminant.holo' discriminant_ne_zero - bdd_at_cusps' {c} hc := by - rw [Subgroup.IsArithmetic.isCusp_iff_isCusp_SL2Z] at hc - rw [isBoundedAt_iff_forall_SL2Z hc] - intro γ _ - rw [divByDiscriminant_slash_eq f γ, IsBoundedAtImInfty, BoundedAtFilter] - exact (div_isBoundedUnder_of_isBigO (exp_decay_isBigO_discriminant f)).isBigO_one ℝ - -@[simp] -lemma divDiscriminant_apply (f : CuspForm 𝒮ℒ k) (z : ℍ) : - (divDiscriminant f) z = f z / Δ z := (rfl) - /-- The linear equivalence between cusp forms of weight `k` and modular forms of weight `k - 12`, given by division by the discriminant. -/ def discriminantEquiv : CuspForm 𝒮ℒ k ≃ₗ[ℂ] ModularForm 𝒮ℒ (k - 12) where - toFun := divDiscriminant + toFun f := + { toFun z := f z / Δ z + slash_action_eq' := fun _ ⟨γ, hγ⟩ ↦ hγ ▸ divByDiscriminant_slash_eq f γ + holo' := f.holo'.div CuspForm.discriminant.holo' discriminant_ne_zero + bdd_at_cusps' {c} hc := by + rw [Subgroup.IsArithmetic.isCusp_iff_isCusp_SL2Z] at hc + rw [isBoundedAt_iff_forall_SL2Z hc] + intro γ _ + rw [divByDiscriminant_slash_eq f γ, IsBoundedAtImInfty, BoundedAtFilter] + exact (div_isBoundedUnder_of_isBigO (exp_decay_isBigO_discriminant f)).isBigO_one ℝ } map_add' a b := by ext z - simp [add_div] + change (a z + b z) / Δ z = a z / Δ z + b z / Δ z + rw [add_div] map_smul' c a := by ext z - simp [mul_div_assoc] + change (c * a z) / Δ z = c * (a z / Δ z) + rw [mul_div_assoc] invFun := ofMulDiscriminant left_inv f := by ext z @@ -89,8 +87,54 @@ def discriminantEquiv : CuspForm 𝒮ℒ k ≃ₗ[ℂ] ModularForm 𝒮ℒ (k - ext z exact mul_div_cancel_left₀ (f z) (discriminant_ne_zero z) +lemma discriminantEquiv_apply (f : CuspForm 𝒮ℒ k) (z : ℍ) : + (discriminantEquiv f) z = f z / Δ z := rfl + +/-- Divide a cusp form by the discriminant to get a modular form of weight `k - 12`. -/ +@[deprecated discriminantEquiv (since := "2026-05-18")] +def divDiscriminant (f : CuspForm 𝒮ℒ k) : ModularForm 𝒮ℒ (k - 12) := discriminantEquiv f + +set_option linter.deprecated false in +@[deprecated discriminantEquiv_apply (since := "2026-05-18")] +lemma divDiscriminant_apply (f : CuspForm 𝒮ℒ k) (z : ℍ) : + (divDiscriminant f) z = f z / Δ z := rfl + end CuspForm +namespace ModularForm + +@[simp] +lemma discriminant_mul_discriminantEquiv_apply (f : CuspForm 𝒮ℒ k) (z : ℍ) : + Δ z * (CuspForm.discriminantEquiv f) z = f z := by + rw [CuspForm.discriminantEquiv_apply, mul_div_cancel₀ _ (discriminant_ne_zero z)] + +@[simp] +lemma discriminant_mul_discriminantEquiv (f : CuspForm 𝒮ℒ k) : + Δ * (CuspForm.discriminantEquiv f : ℍ → ℂ) = f := by + grind [Pi.mul_apply, discriminant_mul_discriminantEquiv_apply] + +/-- The order of the q-expansion of the modular discriminant is 1: the zeroth coefficient +vanishes (Δ is a cusp form) and the first coefficient equals 1. -/ +lemma discriminant_qExpansion_order : (qExpansion 1 Δ).order = 1 := by + refine PowerSeries.order_eq_nat.mpr + ⟨discriminant_qExpansion_coeff_one ▸ one_ne_zero, fun i hi ↦ ?_⟩ + obtain rfl : i = 0 := by lia + simpa using CuspFormClass.qExpansion_coeff_zero CuspForm.discriminant one_pos + one_mem_strictPeriods_SL + +/-- The q-expansion of a level-1 modular form whose zeroth coefficient vanishes factors as +the q-expansion of `Δ` times the q-expansion of the corresponding form of weight `k - 12` +obtained via `discriminantEquiv`. -/ +lemma qExpansion_eq_qExpansion_discriminant_mul (f : ModularForm 𝒮ℒ k) + (hcusp : (qExpansion 1 f).coeff 0 = 0) : + qExpansion 1 f = qExpansion 1 discriminant * + qExpansion 1 (CuspForm.discriminantEquiv (toCuspForm f hcusp)) := by + rw [show (f : ℍ → ℂ) = discriminant * (toCuspForm f hcusp).discriminantEquiv from + (discriminant_mul_discriminantEquiv (toCuspForm f hcusp)).symm, ← CuspForm.coe_discriminant] + exact ModularForm.qExpansion_mul_coe one_pos one_mem_strictPeriods_SL _ _ + +end ModularForm + end DeltaIsomorphism section RankIdentity @@ -204,7 +248,7 @@ theorem levelOne_weight_two_rank_zero : Module.rank ℂ (ModularForm 𝒮ℒ 2) /-- The dimension formula for `𝒮ℒ` modular forms of even weight. -/ theorem dimension_level_one (k : ℕ) (hk2 : Even k) : Module.rank ℂ (ModularForm 𝒮ℒ k) = - if 12 ∣ (k : ℤ) - 2 then ⌊(k / 12 : ℚ)⌋₊ else ⌊(k / 12 : ℚ)⌋₊ + 1 := by + if k ≡ 2 [MOD 12] then k / 12 else k / 12 + 1 := by induction k using Nat.strong_induction_on with | h k ihn => have : k < 3 ∨ (3 ≤ k ∧ k < 12) ∨ 12 ≤ k := by grind rcases this with hk | hk | hk @@ -212,23 +256,19 @@ theorem dimension_level_one (k : ℕ) (hk2 : Even k) : interval_cases k · simpa using levelOne_weight_zero_rank_one · grind - · convert levelOne_weight_two_rank_zero - norm_num - · -- `3 ≤ k < 12`: the lemma `rank_eq_one_add_rank_cuspForm` applies - -- and the mod form space of weight `k - 12` is zero - rw [rank_eq_one_add_rank_cuspForm hk.1 hk2, CuspForm.discriminantEquiv.rank_eq] - apply (congrArg _ (levelOne_neg_weight_rank_zero (by lia))).trans + · simpa [Nat.ModEq] using levelOne_weight_two_rank_zero + · -- `3 ≤ k < 12`: rank decomposition + the weight `k - 12` space is zero + rw [rank_eq_one_add_rank_cuspForm hk.1 hk2, CuspForm.discriminantEquiv.rank_eq, + levelOne_neg_weight_rank_zero (by lia)] have : k ∈ (Finset.Icc 3 11).filter Even := by grind - fin_cases this <;> norm_num - · -- `12 ≤ k`: use `CuspForm.discriminantEquiv` and induction hypothesis - rw [rank_eq_one_add_rank_cuspForm (by lia) hk2, CuspForm.discriminantEquiv.rank_eq] - have hk12 : (k - 12 : ℕ) = (k - 12 : ℤ) := by grind - simp only [hk12 ▸ ihn (k - 12) (by lia) (by grind), - show ((k - 12 : ℕ) : ℚ) = k - 12 by norm_cast, sub_right_comm, dvd_sub_self_right] - have hfl : ⌊(k : ℚ) / 12⌋₊ = 1 + ⌊((k : ℚ) - 12) / 12⌋₊ := by - rw [Nat.floor_div_ofNat, Nat.floor_div_ofNat, Nat.floor_sub_ofNat, - Nat.div_eq_sub_div (by decide) (by simpa), add_comm, Nat.floor_natCast] - split_ifs <;> simp [hfl, add_assoc] + fin_cases this <;> simp [Nat.ModEq] + · -- `12 ≤ k`: rank decomposition + induction hypothesis at weight `k - 12` + rw [rank_eq_one_add_rank_cuspForm (by lia) hk2, CuspForm.discriminantEquiv.rank_eq, + show ((k : ℤ) - 12 : ℤ) = ((k - 12 : ℕ) : ℤ) by lia, + ihn (k - 12) (by lia) (by grind)] + simp only [Nat.ModEq, show k / 12 = (k - 12) / 12 + 1 by lia, + show (k - 12) % 12 = k % 12 by lia] + split_ifs <;> grind instance (k : ℤ) : FiniteDimensional ℂ (ModularForm 𝒮ℒ k) := by rw [FiniteDimensional, ← Module.rank_lt_aleph0_iff] @@ -242,6 +282,34 @@ instance (k : ℤ) : FiniteDimensional ℂ (ModularForm 𝒮ℒ k) := by · rw [levelOne_odd_weight_rank_zero hk_odd] exact Cardinal.aleph0_pos +/-- **Sturm bound for level-1 modular forms (natural weight).** If a modular form `f` of weight +`k : ℕ` has q-expansion of order strictly greater than `k / 12`, then `f` is identically zero. -/ +theorem sturm_bound_levelOne_nat {k : ℕ} {f : ModularForm 𝒮ℒ (k : ℤ)} + (h : (↑(k / 12) : ℕ∞) < (qExpansion 1 f).order) : f = 0 := by + induction k using Nat.strong_induction_on with | _ k ih => + have h0 : (qExpansion 1 f).coeff 0 = 0 := + PowerSeries.coeff_of_lt_order _ ((Nat.cast_nonneg _).trans_lt h) + suffices CuspForm.discriminantEquiv (toCuspForm f h0) = 0 by + simpa [CuspForm.discriminantEquiv.map_eq_zero_iff, DFunLike.ext_iff] + rcases lt_or_ge k 12 with hk12 | hk12 + · apply rank_zero_iff_forall_zero.mp (levelOne_neg_weight_rank_zero (by lia)) + · rw [← mcast_eq_zero_iff (b := ↑(k - 12)) (by lia) rfl] + refine ih (k - 12) (by lia) ?_ + have hsucc : k / 12 = (k - 12) / 12 + 1 := by lia + rw [qExpansion_eq_qExpansion_discriminant_mul f h0, PowerSeries.order_mul, + discriminant_qExpansion_order, add_comm, hsucc, Nat.cast_add, Nat.cast_one] at h + exact (ENat.add_lt_add_iff_right (ENat.coe_ne_top 1)).mp h + +/-- **Sturm bound for level-1 modular forms.** If a modular form `f` of weight `k` for `SL(2, ℤ)` +has q-expansion of order strictly greater than `k / 12`, then `f` is identically zero. +Corollary of the natural-weight version `sturm_bound_levelOne_nat`. -/ +theorem sturm_bound_levelOne {k : ℤ} {f : ModularForm 𝒮ℒ k} + (h : (↑(k.toNat / 12) : ℕ∞) < (qExpansion 1 f).order) : f = 0 := by + rcases lt_or_ge k 0 with hk | hk + · exact rank_zero_iff_forall_zero.mp (levelOne_neg_weight_rank_zero hk) f + · lift k to ℕ using hk + exact sturm_bound_levelOne_nat (mod_cast h) + end ModularForm end DimensionFormula diff --git a/Mathlib/NumberTheory/ModularForms/QExpansion.lean b/Mathlib/NumberTheory/ModularForms/QExpansion.lean index cd17cb79e09172..65b18c0f43a17f 100644 --- a/Mathlib/NumberTheory/ModularForms/QExpansion.lean +++ b/Mathlib/NumberTheory/ModularForms/QExpansion.lean @@ -123,7 +123,7 @@ theorem periodic_comp_ofComplex [SlashInvariantFormClass F Γ k] (hΓ : h ∈ Γ by_cases! hw : 0 < im w · have : 0 < im (w + h) := by simp [hw] simp only [comp_apply, ofComplex_apply_of_im_pos this, ofComplex_apply_of_im_pos hw] - convert SlashInvariantForm.vAdd_apply_of_mem_strictPeriods f ⟨w, hw⟩ hΓ using 2 + convert! SlashInvariantForm.vAdd_apply_of_mem_strictPeriods f ⟨w, hw⟩ hΓ using 2 ext simp [add_comm] · have : im (w + h) ≤ 0 := by simpa using hw @@ -180,8 +180,10 @@ lemma hasSum_qExpansion_of_norm_lt {f : ℍ → ℂ} (hh : 0 < h) (hfper : Periodic (f ∘ ofComplex) h) (hfhol : MDiff f) (hfbdd : IsBoundedAtImInfty f) {q : ℂ} (hq : ‖q‖ < 1) : HasSum (fun m : ℕ ↦ (qExpansion h f).coeff m • q ^ m) (cuspFunction h f q) := by - convert hasSum_taylorSeries_on_ball (differentiableOn_cuspFunction_ball hh hfper hfhol hfbdd) - (by simpa using hq) using 2 with m + convert! + hasSum_taylorSeries_on_ball (differentiableOn_cuspFunction_ball hh hfper hfhol hfbdd) + (by simpa using hq) using + 2 with m grind [qExpansion_coeff, sub_zero, smul_eq_mul] lemma hasSum_qExpansion {f : ℍ → ℂ} (hh : 0 < h) @@ -327,10 +329,12 @@ theorem exp_decay_sub_atImInfty {f : ℍ → ℂ} (hh : 0 < h) (hfper : Periodic (f ∘ ofComplex) h) (hfhol : MDiff f) (hfbdd : IsBoundedAtImInfty f) : (fun τ ↦ f τ - valueAtInfty f) =O[atImInfty] fun τ ↦ Real.exp (-2 * π * τ.im / h) := by have := hfbdd.comp_tendsto tendsto_comap_im_ofComplex - convert (hfper.exp_decay_sub_of_bounded_at_inf hh - (eventually_of_mem (preimage_mem_comap (Ioi_mem_atTop 0)) - fun z hz ↦ by simpa using (UpperHalfPlane.mdifferentiableAt_iff.mp <| hfhol ⟨z, hz⟩)) - this).comp_tendsto tendsto_coe_atImInfty + convert! + (hfper.exp_decay_sub_of_bounded_at_inf hh + (eventually_of_mem (preimage_mem_comap (Ioi_mem_atTop 0)) fun z hz ↦ by + simpa using (UpperHalfPlane.mdifferentiableAt_iff.mp <| hfhol ⟨z, hz⟩)) + this).comp_tendsto + tendsto_coe_atImInfty simpa [cuspFunction] using (cuspFunction_apply_zero hh (analyticAt_cuspFunction_zero hh hfper hfhol hfbdd) hfper).symm @@ -374,8 +378,8 @@ theorem exp_decay_sub_atImInfty' [ModularFormClass F Γ k] [Γ.HasDetPlusMinusOn have hh : 0 < Γ.strictWidthInfty := Γ.strictWidthInfty_pos_iff.mpr Fact.out have hΓ : Γ.strictWidthInfty ∈ Γ.strictPeriods := Γ.strictWidthInfty_mem_strictPeriods refine ⟨2 * π / Γ.strictWidthInfty, div_pos Real.two_pi_pos hh, ?_⟩ - convert exp_decay_sub_atImInfty hh (periodic_comp_ofComplex f hΓ) (holo f) - (bdd_at_infty f) using 3 with τ + convert! exp_decay_sub_atImInfty hh (periodic_comp_ofComplex f hΓ) (holo f) (bdd_at_infty f) using + 3 with τ ring_nf /-- Version of `exp_decay_atImInfty` stating a less precise result but easier to apply in practice @@ -404,6 +408,11 @@ theorem cuspFunction_apply_zero (hh : 0 < h) (hΓ : h ∈ Γ.strictPeriods) : have : Fact (IsCusp OnePoint.infty Γ) := ⟨Γ.isCusp_of_mem_strictPeriods hh hΓ⟩ (CuspFormClass.zero_at_infty f).cuspFunction_apply_zero hh +/-- The zeroth coefficient of the `q`-expansion of a cusp form vanishes. -/ +theorem qExpansion_coeff_zero (hh : 0 < h) (hΓ : h ∈ Γ.strictPeriods) : + (qExpansion h f).coeff 0 = 0 := by + simp [qExpansion_coeff, cuspFunction_apply_zero f hh hΓ] + theorem exp_decay_atImInfty (hh : 0 < h) (hΓ : h ∈ Γ.strictPeriods) : f =O[atImInfty] fun τ ↦ Real.exp (-2 * π * τ.im / h) := have : Fact (IsCusp OnePoint.infty Γ) := ⟨Γ.isCusp_of_mem_strictPeriods hh hΓ⟩ @@ -568,11 +577,18 @@ protected lemma qExpansion_sub {G : Type*} [FunLike G ℍ ℂ] (hh : 0 < h) qExpansion_sub (ModularFormClass.analyticAt_cuspFunction_zero f hh hΓ) (ModularFormClass.analyticAt_cuspFunction_zero g hh hΓ) +/-- The q-expansion of a pointwise product of two modular-form-class objects is the product of +their q-expansions. Works for any `ModularFormClass` (e.g. a `CuspForm` times a `ModularForm`). -/ +protected lemma qExpansion_mul_coe {G : Type*} [FunLike G ℍ ℂ] (hh : 0 < h) + (hΓ : h ∈ Γ.strictPeriods) {a b : ℤ} (f : F) [ModularFormClass F Γ a] (g : G) + [ModularFormClass G Γ b] : qExpansion h ((⇑f * ⇑g : ℍ → ℂ)) = qExpansion h f * qExpansion h g := + qExpansion_mul (ModularFormClass.analyticAt_cuspFunction_zero f hh hΓ) + (ModularFormClass.analyticAt_cuspFunction_zero g hh hΓ) + protected lemma qExpansion_mul [Γ.HasDetPlusMinusOne] (hh : 0 < h) (hΓ : h ∈ Γ.strictPeriods) {a b : ℤ} (f : ModularForm Γ a) (g : ModularForm Γ b) : qExpansion h (f.mul g) = qExpansion h f * qExpansion h g := - qExpansion_mul (ModularFormClass.analyticAt_cuspFunction_zero f hh hΓ) - (ModularFormClass.analyticAt_cuspFunction_zero g hh hΓ) + ModularForm.qExpansion_mul_coe hh hΓ f g protected lemma qExpansion_eq_zero_iff (hh : 0 < h) (hΓ : h ∈ Γ.strictPeriods) {k : ℤ} (f : ModularForm Γ k) : qExpansion h f = 0 ↔ f = 0 := by @@ -583,6 +599,11 @@ protected lemma qExpansion_one [Γ.HasDetPlusMinusOne] : qExpansion h (1 : ModularForm Γ 0) = 1 := by simp [qExpansion_one] +@[simp] +protected lemma qExpansion_mcast {a b : ℤ} {Γ' : Subgroup (GL (Fin 2) ℝ)} + (heq : a = b) (hΓ : Γ' = Γ) (f : ModularForm Γ a) : + qExpansion h (ModularForm.mcast heq f hΓ) = qExpansion h f := rfl + protected lemma qExpansion_pow [Γ.HasDetPlusMinusOne] (hh : 0 < h) (hΓ : h ∈ Γ.strictPeriods) (f : ModularForm Γ k) (n : ℕ) : qExpansion h (f.pow n) = (qExpansion h f) ^ n := by diff --git a/Mathlib/NumberTheory/ModularForms/SlashActions.lean b/Mathlib/NumberTheory/ModularForms/SlashActions.lean index cc5ea689cef059..f857faba9a4e9e 100644 --- a/Mathlib/NumberTheory/ModularForms/SlashActions.lean +++ b/Mathlib/NumberTheory/ModularForms/SlashActions.lean @@ -190,7 +190,7 @@ theorem is_invariant_one' (A : SL(2, ℤ)) : (1 : ℍ → ℂ) ∣[(0 : ℤ)] (A theorem slash_action_eq'_iff (k : ℤ) (f : ℍ → ℂ) (γ : SL(2, ℤ)) (z : ℍ) : (f ∣[k] γ) z = f z ↔ f (γ • z) = ((γ 1 0 : ℂ) * z + (γ 1 1 : ℂ)) ^ k * f z := by simp only [SL_slash_apply] - convert inv_mul_eq_iff_eq_mul₀ (G₀ := ℂ) _ using 2 + convert! inv_mul_eq_iff_eq_mul₀ (G₀ := ℂ) _ using 2 · simp only [mul_comm (f _), denom, zpow_neg] rfl · exact zpow_ne_zero k (denom_ne_zero γ z) diff --git a/Mathlib/NumberTheory/Multiplicity.lean b/Mathlib/NumberTheory/Multiplicity.lean index 560e050d58115f..24ddc415029939 100644 --- a/Mathlib/NumberTheory/Multiplicity.lean +++ b/Mathlib/NumberTheory/Multiplicity.lean @@ -58,7 +58,7 @@ theorem sq_dvd_add_pow_sub_sub (p x : R) (n : ℕ) : Nat.cast_succ, tsub_self, pow_zero, mul_one, Nat.choose_self, Nat.cast_zero, zero_add, Nat.succ_sub_succ_eq_sub, Nat.sub_zero] suffices p ^ 2 ∣ ∑ i ∈ range n, x ^ i * p ^ (n + 1 - i) * ↑((n + 1).choose i) by - convert this; abel + convert! this; abel apply Finset.dvd_sum intro y hy calc @@ -318,7 +318,7 @@ theorem Int.two_pow_sub_pow {x y : ℤ} {n : ℕ} (hxy : 2 ∣ x - y) (hx : ¬2 have hy : Odd y := by rw [← even_iff_two_dvd, Int.not_even_iff_odd] at hx replace hxy := (@even_neg _ _ (x - y)).mpr (even_iff_two_dvd.mpr hxy) - convert Even.add_odd hxy hx + convert! Even.add_odd hxy hx abel obtain ⟨d, rfl⟩ := hn simp only [← two_mul, pow_mul] @@ -347,7 +347,7 @@ theorem Nat.two_pow_sub_pow {x y : ℕ} (hxy : 2 ∣ x - y) (hx : ¬2 ∣ x) {n Int.natCast_pow] rw [← Int.natCast_dvd_natCast] at hx rw [← Int.natCast_dvd_natCast, Int.ofNat_sub hyx] at hxy - convert Int.two_pow_sub_pow hxy hx hn using 2 + convert! Int.two_pow_sub_pow hxy hx hn using 2 rw [← Int.natCast_emultiplicity] rfl · simp only [Nat.sub_eq_zero_iff_le.mpr hyx, diff --git a/Mathlib/NumberTheory/Niven.lean b/Mathlib/NumberTheory/Niven.lean index dc805dc12cc65a..68444271f6f6ac 100644 --- a/Mathlib/NumberTheory/Niven.lean +++ b/Mathlib/NumberTheory/Niven.lean @@ -139,7 +139,7 @@ theorem niven (hθ : ∃ r : ℚ, θ = r * π) (hcos : ∃ q : ℚ, cos θ = q) /-- Niven's theorem, but stated for `sin` instead of `cos`. -/ theorem niven_sin (hθ : ∃ r : ℚ, θ = r * π) (hcos : ∃ q : ℚ, sin θ = q) : sin θ ∈ ({-1, -1 / 2, 0, 1 / 2, 1} : Set ℝ) := by - convert ← niven (θ := θ - π / 2) ?_ ?_ using 1 + convert! ← niven (θ := θ - π / 2) ?_ ?_ using 1 · exact cos_sub_pi_div_two θ · exact hθ.imp' (· - 1 / 2) (by intros; push_cast; linarith) · simpa [cos_sub_pi_div_two] diff --git a/Mathlib/NumberTheory/NumberField/Basic.lean b/Mathlib/NumberTheory/NumberField/Basic.lean index f3db9fc17bbe68..14a4d13f5d746f 100644 --- a/Mathlib/NumberTheory/NumberField/Basic.lean +++ b/Mathlib/NumberTheory/NumberField/Basic.lean @@ -441,6 +441,6 @@ namespace AdjoinRoot is a number field. -/ instance {f : Polynomial ℚ} [hf : Fact (Irreducible f)] : NumberField (AdjoinRoot f) where to_charZero := charZero_of_injective_algebraMap (algebraMap ℚ _).injective - to_finiteDimensional := by convert (AdjoinRoot.powerBasis hf.out.ne_zero).finite + to_finiteDimensional := by convert! (AdjoinRoot.powerBasis hf.out.ne_zero).finite end AdjoinRoot diff --git a/Mathlib/NumberTheory/NumberField/CMField.lean b/Mathlib/NumberTheory/NumberField/CMField.lean index 63d3e447624c0b..14aaff8f1d6ca1 100644 --- a/Mathlib/NumberTheory/NumberField/CMField.lean +++ b/Mathlib/NumberTheory/NumberField/CMField.lean @@ -198,7 +198,7 @@ An element of `K` is fixed by the complex conjugation iff it lies in `K⁺`. @[simp] theorem complexConj_eq_self_iff (x : K) : complexConj K x = x ↔ x ∈ K⁺ := by - convert (IntermediateField.mem_fixedField_iff (⊤ : Subgroup (K ≃ₐ[K⁺] K)) x).symm using 1 + convert! (IntermediateField.mem_fixedField_iff (⊤ : Subgroup (K ≃ₐ[K⁺] K)) x).symm using 1 · rw [← zpowers_complexConj_eq_top, Subgroup.forall_mem_zpowers] exact (MulAction.mem_fixedBy_zpowers_iff_mem_fixedBy (g := (complexConj K))).symm · rw [IsGalois.fixedField_top, IntermediateField.mem_bot] @@ -361,7 +361,7 @@ noncomputable abbrev indexRealUnits : ℕ := (realUnits K ⊔ torsion K).index theorem indexRealUnits_mul_eq : indexRealUnits K * (unitsMulComplexConjInv K).range.index = 2 := by rw [indexRealUnits, sup_comm] - convert (Subgroup.index_map (torsion K) (unitsMulComplexConjInv K)).symm + convert! (Subgroup.index_map (torsion K) (unitsMulComplexConjInv K)).symm · rw [unitsMulComplexConjInv_ker] · rw [map_unitsMulComplexConjInv_torsion, IsCyclic.index_powMonoidHom_range, Nat.gcd_eq_right] rw [Nat.card_eq_fintype_card] @@ -554,9 +554,6 @@ instance of_isAbelianGalois [IsAbelianGalois ℚ K] : exact hσ₁.comp _ exact IsCMField.of_forall_isConj K hσ₂ -@[deprecated (since := "2025-11-19")] alias NumberField.CMExtension.of_isMulCommutative := - NumberField.IsCMField.of_isAbelianGalois - end NumberField.IsCMField namespace IsCyclotomicExtension.Rat diff --git a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean index 28955e324bc829..fca12cda01748c 100644 --- a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean +++ b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/Basic.lean @@ -101,7 +101,7 @@ theorem integerLattice.inter_ball_finite [NumberField K] (r : ℝ) : · have heq : ∀ x, canonicalEmbedding K x ∈ Metric.closedBall 0 r ↔ ∀ φ : K →+* ℂ, ‖φ x‖ ≤ r := by intro x; rw [← norm_le_iff, mem_closedBall_zero_iff] - convert (Embeddings.finite_of_norm_le K ℂ r).image (canonicalEmbedding K) + convert! (Embeddings.finite_of_norm_le K ℂ r).image (canonicalEmbedding K) ext; constructor · rintro ⟨⟨_, ⟨x, rfl⟩, rfl⟩, hx⟩ exact ⟨x, ⟨SetLike.coe_mem x, fun φ => (heq _).mp hx φ⟩, rfl⟩ @@ -128,8 +128,9 @@ noncomputable def latticeBasis [NumberField K] : RingHom.equivRatAlgHom rw [show M = N.transpose by { ext : 2; rfl }] rw [Matrix.det_transpose, ← pow_ne_zero_iff two_ne_zero] - convert (map_ne_zero_iff _ (algebraMap ℚ ℂ).injective).mpr - (Algebra.discr_not_zero_of_basis ℚ (integralBasis K)) + convert! + (map_ne_zero_iff _ (algebraMap ℚ ℂ).injective).mpr + (Algebra.discr_not_zero_of_basis ℚ (integralBasis K)) rw [← Algebra.discr_reindex ℚ (integralBasis K) e.symm] exact (Algebra.discr_eq_det_embeddingsMatrixReindex_pow_two ℚ ℂ (fun i => integralBasis K (e i)) RingHom.equivRatAlgHom).symm @@ -247,7 +248,7 @@ theorem volume_eq_zero (w : {w // IsReal w}) : volume ({x : mixedSpace K | x.1 w = 0}) = 0 := by let A : AffineSubspace ℝ (mixedSpace K) := Submodule.toAffineSubspace (Submodule.mk ⟨⟨{x | x.1 w = 0}, by simp_all⟩, rfl⟩ (by simp_all)) - convert Measure.addHaar_affineSubspace volume A fun h ↦ ?_ + convert! Measure.addHaar_affineSubspace volume A fun h ↦ ?_ simpa [A] using (h ▸ Set.mem_univ _ : 1 ∈ A) end Measure @@ -1107,7 +1108,7 @@ theorem realSpace.volume_eq_zero [NumberField K] (w : InfinitePlace K) : volume ({x : realSpace K | x w = 0}) = 0 := by let A : AffineSubspace ℝ (realSpace K) := Submodule.toAffineSubspace (Submodule.mk ⟨⟨{x | x w = 0}, by simp_all⟩, rfl⟩ (by simp_all)) - convert Measure.addHaar_affineSubspace volume A fun h ↦ ?_ + convert! Measure.addHaar_affineSubspace volume A fun h ↦ ?_ simpa [A] using (h ▸ Set.mem_univ _ : 1 ∈ A) /-- diff --git a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean index f6f2c0eeb62df3..aafac0226dbf57 100644 --- a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean +++ b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/ConvexBody.lean @@ -176,7 +176,7 @@ theorem convexBodyLT'_neg_mem (x : mixedSpace K) (hx : x ∈ convexBodyLT' K f w -x ∈ convexBodyLT' K f w₀ := by simp only [Set.mem_prod, Set.mem_pi, Set.mem_univ, mem_ball, dist_zero_right, Real.norm_eq_abs, true_implies, Subtype.forall, Prod.fst_neg, Pi.neg_apply, norm_neg, Prod.snd_neg] at hx ⊢ - convert hx using 3 + convert! hx using 3 split_ifs <;> simp theorem convexBodyLT'_convex : Convex ℝ (convexBodyLT' K f w₀) := by @@ -340,7 +340,7 @@ theorem convexBodySum_neg_mem {x : mixedSpace K} (hx : x ∈ (convexBodySum K B) theorem convexBodySum_convex : Convex ℝ (convexBodySum K B) := by refine Convex_subadditive_le (fun _ _ => convexBodySumFun_add_le _ _) (fun c x h => ?_) B - convert le_of_eq (convexBodySumFun_smul c x) + convert! le_of_eq (convexBodySumFun_smul c x) exact (abs_eq_self.mpr h).symm theorem convexBodySum_isBounded : Bornology.IsBounded (convexBodySum K B) := by @@ -355,7 +355,7 @@ theorem convexBodySum_compact : IsCompact (convexBodySum K B) := by classical rw [Metric.isCompact_iff_isClosed_bounded] refine ⟨?_, convexBodySum_isBounded K B⟩ - convert IsClosed.preimage (convexBodySumFun_continuous K) (isClosed_Icc : IsClosed (Set.Icc 0 B)) + convert! IsClosed.preimage (convexBodySumFun_continuous K) (isClosed_Icc : IsClosed (Set.Icc 0 B)) ext simp [convexBodySumFun_nonneg] @@ -377,7 +377,7 @@ theorem convexBodySum_volume : exact finrank_pos.ne' · suffices volume (convexBodySum K 1) = (convexBodySumFactor K) by rw [mul_comm] - convert addHaar_smul volume B (convexBodySum K 1) + convert! addHaar_smul volume B (convexBodySum K 1) · simp_rw [← Set.preimage_smul_inv₀ (ne_of_gt hB), Set.preimage_setOf_eq, convexBodySumFun, normAtPlace_smul, abs_inv, abs_eq_self.mpr (le_of_lt hB), ← mul_assoc, mul_comm, mul_assoc, ← Finset.mul_sum, inv_mul_le_iff₀ hB, mul_one] @@ -536,7 +536,7 @@ theorem exists_primitive_element_lt_of_isReal {w₀ : InfinitePlace K} (hw₀ : obtain ⟨a, h_nz, h_le⟩ := exists_ne_zero_mem_ringOfIntegers_lt K this refine ⟨a, ?_, fun w ↦ lt_of_lt_of_le (h_le w) ?_⟩ · exact is_primitive_element_of_infinitePlace_lt h_nz - (fun w h_ne ↦ by convert (if_neg h_ne) ▸ h_le w) (Or.inl hw₀) + (fun w h_ne ↦ by convert! (if_neg h_ne) ▸ h_le w) (Or.inl hw₀) · split_ifs <;> simp theorem exists_primitive_element_lt_of_isComplex {w₀ : InfinitePlace K} (hw₀ : IsComplex w₀) @@ -555,7 +555,7 @@ theorem exists_primitive_element_lt_of_isComplex {w₀ : InfinitePlace K} (hw₀ obtain ⟨a, h_nz, h_le, h_le₀⟩ := exists_ne_zero_mem_ringOfIntegers_lt' K ⟨w₀, hw₀⟩ this refine ⟨a, ?_, fun w ↦ ?_⟩ · exact is_primitive_element_of_infinitePlace_lt h_nz - (fun w h_ne ↦ by convert if_neg h_ne ▸ h_le w h_ne) (Or.inr h_le₀.1) + (fun w h_ne ↦ by convert! if_neg h_ne ▸ h_le w h_ne) (Or.inr h_le₀.1) · by_cases h_eq : w = w₀ · rw [if_pos rfl] at h_le₀ dsimp only at h_le₀ diff --git a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/FundamentalCone.lean b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/FundamentalCone.lean index 173447bdf6699d..bea0228933450b 100644 --- a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/FundamentalCone.lean +++ b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/FundamentalCone.lean @@ -223,7 +223,7 @@ theorem smul_mem_of_mem (hx : x ∈ fundamentalCone K) (hc : c ≠ 0) : theorem smul_mem_iff_mem (hc : c ≠ 0) : c • x ∈ fundamentalCone K ↔ x ∈ fundamentalCone K := by refine ⟨fun h ↦ ?_, fun h ↦ smul_mem_of_mem h hc⟩ - convert smul_mem_of_mem h (inv_ne_zero hc) + convert! smul_mem_of_mem h (inv_ne_zero hc) rw [eq_inv_smul_iff₀ hc] theorem exists_unit_smul_mem (hx : mixedEmbedding.norm x ≠ 0) : @@ -543,7 +543,7 @@ def idealSetEquivNorm (n : ℕ) : calc _ ≃ {a : {a : integerSet K // (preimageOfMemIntegerSet a).1 ∈ J.1} // mixedEmbedding.norm a.1.1 = n} := by - convert (Equiv.subtypeEquivOfSubtype (idealSetEquiv K J).symm).symm using 3 + convert! (Equiv.subtypeEquivOfSubtype (idealSetEquiv K J).symm).symm using 3 rw [idealSetEquiv_symm_apply] _ ≃ {a : integerSet K // (preimageOfMemIntegerSet a).1 ∈ J.1 ∧ mixedEmbedding.norm a.1 = n} := Equiv.subtypeSubtypeEquivSubtypeInter @@ -556,7 +556,7 @@ def idealSetEquivNorm (n : ℕ) : (Equiv.subtypeEquivRight (fun _ ↦ by simp [and_comm]))).symm _ ≃ {I : {I : (Ideal (𝓞 K))⁰ // IsPrincipal I.1 ∧ absNorm I.1 = n} × (torsion K) // J.1 ∣ I.1.1} := by - convert Equiv.subtypeEquivOfSubtype (p := fun I ↦ J.1 ∣ I.1) (integerSetEquivNorm K n) + convert! Equiv.subtypeEquivOfSubtype (p := fun I ↦ J.1 ∣ I.1) (integerSetEquivNorm K n) rw [integerSetEquivNorm_apply_fst, dvd_span_singleton] _ ≃ {I : {I : (Ideal (𝓞 K))⁰ // IsPrincipal I.1 ∧ absNorm I.1 = n} // J.1 ∣ I.1} × (torsion K) := Equiv.prodSubtypeFstEquivSubtypeProd diff --git a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/NormLeOne.lean b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/NormLeOne.lean index 0a68997e52752f..393d75f502a4f1 100644 --- a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/NormLeOne.lean +++ b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/NormLeOne.lean @@ -395,7 +395,7 @@ theorem linearIndependent_completeFamily : have h₁ : LinearIndependent ℝ (fun w : {w // w ≠ w₀} ↦ completeFamily K w.1) := by refine LinearIndependent.of_comp realSpaceToLogSpace ?_ simp_rw [Function.comp_def, realSpaceToLogSpace_completeFamily_of_ne] - convert (((basisUnitLattice K).ofZLatticeBasis ℝ _).reindex equivFinRank).linearIndependent + convert! (((basisUnitLattice K).ofZLatticeBasis ℝ _).reindex equivFinRank).linearIndependent simp have h₂ : completeFamily K w₀ ∉ Submodule.span ℝ (Set.range (fun w : {w // w ≠ w₀} ↦ completeFamily K w.1)) := by diff --git a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/PolarCoord.lean b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/PolarCoord.lean index 11cef1f786bc7a..a01452ffe40947 100644 --- a/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/PolarCoord.lean +++ b/Mathlib/NumberTheory/NumberField/CanonicalEmbedding/PolarCoord.lean @@ -401,7 +401,7 @@ theorem volume_eq_two_pi_pow_mul_integral [NumberField K] ← two_mul, Finset.prod_const, Finset.card_univ, ← Set.indicator_const_mul, ← Set.indicator_comp_right, Function.comp_def, Pi.one_apply, mul_one] rw [lintegral_mul_const' _ _ (ne_of_beq_false rfl).symm, mul_comm] - erw [setLIntegral_indicator (by convert hm.preimage mixedSpaceOfRealSpace.measurable)] + erw [setLIntegral_indicator (by convert! hm.preimage mixedSpaceOfRealSpace.measurable)] rw [hA, volume_eq_two_pi_pow_mul_integral_aux hA] congr 1 refine setLIntegral_congr (ae_eq_set_inter (by rfl) (Measure.ae_eq_set_pi fun w _ ↦ ?_)) diff --git a/Mathlib/NumberTheory/NumberField/Completion/FinitePlace.lean b/Mathlib/NumberTheory/NumberField/Completion/FinitePlace.lean index cdcc1a5d021acc..a9df5a2c6bf8e4 100644 --- a/Mathlib/NumberTheory/NumberField/Completion/FinitePlace.lean +++ b/Mathlib/NumberTheory/NumberField/Completion/FinitePlace.lean @@ -177,30 +177,60 @@ theorem adicAbv_intCast_le_one (n : ℤ) : adicAbv K v n ≤ 1 := @[deprecated (since := "2026-03-11")] alias NumberField.RingOfIntegers.HeightOneSpectrum.one_lt_absNorm := one_lt_absNorm @[deprecated (since := "2026-03-11")] +alias _root_.NumberField.RingOfIntegers.HeightOneSpectrum.one_lt_absNorm := one_lt_absNorm +@[deprecated (since := "2026-03-11")] alias NumberField.RingOfIntegers.HeightOneSpectrum.one_lt_absNorm_nnreal := one_lt_absNorm_nnreal @[deprecated (since := "2026-03-11")] +alias _root_.NumberField.RingOfIntegers.HeightOneSpectrum.one_lt_absNorm_nnreal := + one_lt_absNorm_nnreal +@[deprecated (since := "2026-03-11")] alias NumberField.RingOfIntegers.HeightOneSpectrum.absNorm_ne_zero := absNorm_ne_zero @[deprecated (since := "2026-03-11")] +alias _root_.NumberField.RingOfIntegers.HeightOneSpectrum.absNorm_ne_zero := absNorm_ne_zero +@[deprecated (since := "2026-03-11")] alias NumberField.RingOfIntegers.HeightOneSpectrum.adicAbv := adicAbv @[deprecated (since := "2026-03-11")] +alias _root_.NumberField.RingOfIntegers.HeightOneSpectrum.adicAbv := adicAbv +@[deprecated (since := "2026-03-11")] alias NumberField.RingOfIntegers.HeightOneSpectrum.adicAbv_def := adicAbv_def @[deprecated (since := "2026-03-11")] +alias _root_.NumberField.RingOfIntegers.HeightOneSpectrum.adicAbv_def := adicAbv_def +@[deprecated (since := "2026-03-11")] alias NumberField.RingOfIntegers.HeightOneSpectrum.isNonarchimedean_adicAbv := isNonarchimedean_adicAbv @[deprecated (since := "2026-03-11")] +alias _root_.NumberField.RingOfIntegers.HeightOneSpectrum.isNonarchimedean_adicAbv := + isNonarchimedean_adicAbv +@[deprecated (since := "2026-03-11")] alias NumberField.instRankOneAdicCompletion := instRankOneAdicCompletion @[deprecated (since := "2026-03-11")] +alias _root_.NumberField.instRankOneAdicCompletion := instRankOneAdicCompletion +@[deprecated (since := "2026-03-11")] alias NumberField.instNormedFieldValuedAdicCompletion := instNormedFieldValuedAdicCompletion @[deprecated (since := "2026-03-11")] +alias _root_.NumberField.instNormedFieldValuedAdicCompletion := instNormedFieldValuedAdicCompletion +@[deprecated (since := "2026-03-11")] alias NumberField.rankOne_hom'_def := rankOne_hom'_def @[deprecated (since := "2026-03-11")] +alias _root_.NumberField.rankOne_hom'_def := rankOne_hom'_def +@[deprecated (since := "2026-03-11")] alias NumberField.toNNReal_valued_eq_adicAbv := toNNReal_valued_eq_adicAbv @[deprecated (since := "2026-03-11")] +alias _root_.NumberField.toNNReal_valued_eq_adicAbv := toNNReal_valued_eq_adicAbv +@[deprecated (since := "2026-03-11")] alias NumberField.RingOfIntegers.HeightOneSpectrum.adicAbv_add_le_max := adicAbv_add_le_max @[deprecated (since := "2026-03-11")] +alias _root_.NumberField.RingOfIntegers.HeightOneSpectrum.adicAbv_add_le_max := adicAbv_add_le_max +@[deprecated (since := "2026-03-11")] alias NumberField.RingOfIntegers.HeightOneSpectrum.adicAbv_natCast_le_one := adicAbv_natCast_le_one @[deprecated (since := "2026-03-11")] +alias _root_.NumberField.RingOfIntegers.HeightOneSpectrum.adicAbv_natCast_le_one := + adicAbv_natCast_le_one +@[deprecated (since := "2026-03-11")] alias NumberField.RingOfIntegers.HeightOneSpectrum.adicAbv_intCast_le_one := adicAbv_intCast_le_one +@[deprecated (since := "2026-03-11")] +alias _root_.NumberField.RingOfIntegers.HeightOneSpectrum.adicAbv_intCast_le_one := + adicAbv_intCast_le_one end HeightOneSpectrum @@ -210,7 +240,7 @@ open HeightOneSpectrum Valuation.IsRankOneDiscrete for the equality involving `‖embedding v x‖` on the LHS. -/ theorem FinitePlace.norm_def (x : v.adicCompletion K) : ‖x‖ = toNNReal (absNorm_ne_zero v) (Valued.v x) := by - simp [Valued.toNormedField.norm_def, Valuation.RankOne.hom, rankOne_hom'_def, + simp [Valued.toNormedField.norm_def, Valuation.RankOne.hom, HeightOneSpectrum.rankOne_hom'_def, valueGroup₀_equiv_withZeroMulInt_restrict_apply_of_surjective (valuedAdicCompletion_surjective K v)] @@ -352,6 +382,7 @@ theorem maximalIdeal_mk (v : HeightOneSpectrum (𝓞 K)) : maximalIdeal (mk v) = rw [← mk_eq_iff, mk_maximalIdeal] /-- The equivalence between finite places and maximal ideals. -/ +@[simps apply] noncomputable def equivHeightOneSpectrum : FinitePlace K ≃ HeightOneSpectrum (𝓞 K) where toFun := maximalIdeal @@ -393,6 +424,13 @@ theorem hasFiniteMulSupport {x : K} (h_x_nezero : x ≠ 0) : @[deprecated (since := "2026-03-03")] alias mulSupport_finite := hasFiniteMulSupport +lemma hasFiniteMulSupport_fun_pow_multiplicity {M : Type*} [CommMonoid M] {I : Ideal (𝓞 K)} + (hI : I ≠ ⊥) (f : Ideal (𝓞 K) → M) : + (fun v : FinitePlace K ↦ + f v.maximalIdeal.asIdeal ^ multiplicity v.maximalIdeal.asIdeal I).HasFiniteMulSupport := + UniqueFactorizationMonoid.hasFiniteMulSupport_fun_pow_multiplicity _ + (asIdeal_injective.comp maximalIdeal_injective) (fun v ↦ v.maximalIdeal.irreducible) hI + protected lemma add_le (v : FinitePlace K) (x y : K) : v (x + y) ≤ max (v x) (v y) := by @@ -414,6 +452,17 @@ alias IsDedekindDomain.HeightOneSpectrum.equivHeightOneSpectrum_symm_apply := @[deprecated (since := "2026-03-11")] alias IsDedekindDomain.HeightOneSpectrum.embedding_mul_absNorm := embedding_mul_absNorm +lemma finprod_finitePlace_pow_multiplicity {I : Ideal (𝓞 K)} (hI : I ≠ ⊥) : + ∏ᶠ v : FinitePlace K, v.maximalIdeal.asIdeal ^ multiplicity v.maximalIdeal.asIdeal I = I := by + conv_rhs => rw [← finprod_heightOneSpectrum_pow_multiplicity hI] + simp only [← finprod_comp_equiv (equivHeightOneSpectrum (K := K)), equivHeightOneSpectrum_apply] + +lemma apply_mul_absNorm_pow_eq_one (v : FinitePlace K) {x : 𝓞 K} (hx : x ≠ 0) : + v x * v.maximalIdeal.asIdeal.absNorm ^ multiplicity v.maximalIdeal.asIdeal (span {x}) = 1 := by + have hnz : span {x} ≠ ⊥ := mt Submodule.span_singleton_eq_bot.mp hx + rw [← norm_embedding_eq v x, ← Nat.cast_pow, ← map_pow, ← maxPowDividing_eq_pow_multiplicity hnz] + exact HeightOneSpectrum.embedding_mul_absNorm K v.maximalIdeal hx + end FinitePlace section LiesOver diff --git a/Mathlib/NumberTheory/NumberField/Cyclotomic/Basic.lean b/Mathlib/NumberTheory/NumberField/Cyclotomic/Basic.lean index 6018628ba7f466..c72ea87b94cd38 100644 --- a/Mathlib/NumberTheory/NumberField/Cyclotomic/Basic.lean +++ b/Mathlib/NumberTheory/NumberField/Cyclotomic/Basic.lean @@ -236,7 +236,7 @@ noncomputable def subOneIntegralPowerBasisOfPrimePow [IsCyclotomicExtension {p ^ PowerBasis.ofAdjoinEqTop' (RingOfIntegers.isIntegral ⟨ζ- 1, (hζ.isIntegral (NeZero.pos _)).sub isIntegral_one⟩) (by refine hζ.integralPowerBasisOfPrimePow.adjoin_eq_top_of_gen_mem_adjoin ?_ - convert Subalgebra.add_mem _ (self_mem_adjoin_singleton ℤ _) (Subalgebra.one_mem _) + convert! Subalgebra.add_mem _ (self_mem_adjoin_singleton ℤ _) (Subalgebra.one_mem _) simp [RingOfIntegers.ext_iff, integralPowerBasisOfPrimePow_gen, toInteger]) @[simp] @@ -258,7 +258,7 @@ theorem zeta_sub_one_prime_of_ne_two [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] simpa using congrArg (algebraMap _ K) h rw [Nat.irreducible_iff_prime, Ideal.absNorm_span_singleton, ← Nat.prime_iff, ← Int.prime_iff_natAbs_prime] - convert Nat.prime_iff_prime_int.1 hp.out + convert! Nat.prime_iff_prime_int.1 hp.out apply RingHom.injective_int (algebraMap ℤ ℚ) rw [← Algebra.norm_localization (Sₘ := K) ℤ (nonZeroDivisors ℤ)] simp only [algebraMap_int_eq, map_natCast] @@ -277,7 +277,7 @@ theorem zeta_sub_one_prime_of_two_pow [IsCyclotomicExtension {2 ^ (k + 1)} ℚ K rw [Nat.irreducible_iff_prime, Ideal.absNorm_span_singleton, ← Nat.prime_iff, ← Int.prime_iff_natAbs_prime] cases k - · convert Prime.neg Int.prime_two + · convert! Prime.neg Int.prime_two apply RingHom.injective_int (algebraMap ℤ ℚ) rw [← Algebra.norm_localization (Sₘ := K) ℤ (nonZeroDivisors ℤ)] simp only [algebraMap_int_eq, map_neg, map_ofNat] @@ -285,7 +285,7 @@ theorem zeta_sub_one_prime_of_two_pow [IsCyclotomicExtension {2 ^ (k + 1)} ℚ K pow_zero] using hζ.norm_pow_sub_one_two (cyclotomic.irreducible_rat (by simp only [zero_add, pow_one, Nat.ofNat_pos])) - convert Int.prime_two + convert! Int.prime_two apply RingHom.injective_int (algebraMap ℤ ℚ) rw [← Algebra.norm_localization (Sₘ := K) ℤ (nonZeroDivisors ℤ), algebraMap_int_eq] exact hζ.norm_sub_one_two Nat.AtLeastTwo.prop (cyclotomic.irreducible_rat (by simp)) @@ -301,7 +301,7 @@ theorem zeta_sub_one_prime [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] /-- `ζ - 1` is prime if `ζ` is a primitive `p`-th root of unity. -/ theorem zeta_sub_one_prime' [h : IsCyclotomicExtension {p} ℚ K] (hζ : IsPrimitiveRoot ζ p) : Prime ((hζ.toInteger - 1)) := by - convert zeta_sub_one_prime (k := 0) (by simpa only [zero_add, pow_one]) + convert! zeta_sub_one_prime (k := 0) (by simpa only [zero_add, pow_one]) simpa only [zero_add, pow_one] theorem subOneIntegralPowerBasisOfPrimePow_gen_prime [IsCyclotomicExtension {p ^ (k + 1)} ℚ K] @@ -612,8 +612,8 @@ theorem discr_prime_pow [IsCyclotomicExtension {p ^ k} ℚ K] : let pB₁ := integralPowerBasisOfPrimePow hζ apply (algebraMap ℤ ℚ).injective_int rw [← NumberField.discr_eq_discr _ pB₁.basis, ← Algebra.discr_localizationLocalization ℤ ℤ⁰ K] - convert IsCyclotomicExtension.discr_prime_pow hζ - (cyclotomic.irreducible_rat (NeZero.pos _)) using 1 + convert! + IsCyclotomicExtension.discr_prime_pow hζ (cyclotomic.irreducible_rat (NeZero.pos _)) using 1 · have : pB₁.dim = (IsPrimitiveRoot.powerBasis ℚ hζ).dim := by rw [← PowerBasis.finrank, ← PowerBasis.finrank] exact RingOfIntegers.rank K @@ -622,7 +622,7 @@ theorem discr_prime_pow [IsCyclotomicExtension {p ^ k} ℚ K] : ext i simp_rw [Function.comp_apply, Module.Basis.localizationLocalization_apply, powerBasis_dim, PowerBasis.coe_basis, pB₁, integralPowerBasisOfPrimePow_gen] - convert ← ((IsPrimitiveRoot.powerBasis ℚ hζ).basis_eq_pow i).symm using 1 + convert! ← ((IsPrimitiveRoot.powerBasis ℚ hζ).basis_eq_pow i).symm using 1 · simp_rw [algebraMap_int_eq, map_mul, map_pow, map_neg, map_one, map_natCast] @[deprecated (since := "2025-11-24")] alias absdiscr_prime_pow := discr_prime_pow @@ -868,7 +868,7 @@ noncomputable def subOneIntegralPowerBasis [IsCyclotomicExtension {n} ℚ K] PowerBasis.ofAdjoinEqTop' (RingOfIntegers.isIntegral ⟨ζ- 1, (hζ.isIntegral (NeZero.pos _)).sub isIntegral_one⟩) (by refine hζ.integralPowerBasis.adjoin_eq_top_of_gen_mem_adjoin ?_ - convert Subalgebra.add_mem _ (self_mem_adjoin_singleton ℤ _) (Subalgebra.one_mem _) + convert! Subalgebra.add_mem _ (self_mem_adjoin_singleton ℤ _) (Subalgebra.one_mem _) simp [RingOfIntegers.ext_iff, integralPowerBasis_gen, toInteger]) @[simp] @@ -903,10 +903,10 @@ theorem NumberField.Units.dvd_torsionOrder_of_isPrimitiveRoot [NeZero n] [Number (hζ : IsPrimitiveRoot ζ n) : n ∣ torsionOrder K := by rw [torsionOrder, Fintype.card_eq_nat_card] replace hζ := (hζ.toInteger_isPrimitiveRoot).isUnit_unit (NeZero.ne n) - convert orderOf_dvd_natCard (⟨(hζ.isUnit (NeZero.ne n)).unit, ?_⟩ : torsion K) + convert! orderOf_dvd_natCard (⟨(hζ.isUnit (NeZero.ne n)).unit, ?_⟩ : torsion K) · rw [Subgroup.orderOf_mk] exact hζ.eq_orderOf - · refine (CommGroup.mem_torsion _ _).mpr ⟨n, NeZero.pos n, ?_⟩ + · refine (CommGroup.mem_torsion _).mpr ⟨n, NeZero.pos n, ?_⟩ rw [isPeriodicPt_mul_iff_pow_eq_one] exact hζ.pow_eq_one diff --git a/Mathlib/NumberTheory/NumberField/Cyclotomic/Embeddings.lean b/Mathlib/NumberTheory/NumberField/Cyclotomic/Embeddings.lean index 50e9330959db0f..da237c16e2618c 100644 --- a/Mathlib/NumberTheory/NumberField/Cyclotomic/Embeddings.lean +++ b/Mathlib/NumberTheory/NumberField/Cyclotomic/Embeddings.lean @@ -58,9 +58,9 @@ theorem nrComplexPlaces_eq_totient_div_two [h : IsCyclotomicExtension {n} ℚ K] simp [hk, key, ← two_mul] · have : φ n = 1 := by by_cases h1 : 1 < n - · convert totient_two + · convert! totient_two exact (eq_of_le_of_not_lt (succ_le_of_lt h1) hn).symm - · convert totient_one + · convert! totient_one exact eq_of_le_of_not_lt (not_lt.mp h1) (by simp [NeZero.ne _]) rw [this] apply nrComplexPlaces_eq_zero_of_finrank_eq_one diff --git a/Mathlib/NumberTheory/NumberField/Cyclotomic/Ideal.lean b/Mathlib/NumberTheory/NumberField/Cyclotomic/Ideal.lean index 1b4f30d93b418a..6a23ec72c2d291 100644 --- a/Mathlib/NumberTheory/NumberField/Cyclotomic/Ideal.lean +++ b/Mathlib/NumberTheory/NumberField/Cyclotomic/Ideal.lean @@ -77,7 +77,7 @@ theorem absNorm_span_zeta_sub_one : absNorm (span {hζ.toInteger - 1}) = p := by span_singleton_eq_span_singleton.mpr <| associated_norm_zeta_sub_one p k hζ theorem p_mem_span_zeta_sub_one : (p : 𝓞 K) ∈ span {hζ.toInteger - 1} := by - convert Ideal.absNorm_mem _ + convert! Ideal.absNorm_mem _ exact (absNorm_span_zeta_sub_one ..).symm theorem span_zeta_sub_one_ne_bot : span {hζ.toInteger - 1} ≠ ⊥ := diff --git a/Mathlib/NumberTheory/NumberField/Cyclotomic/Three.lean b/Mathlib/NumberTheory/NumberField/Cyclotomic/Three.lean index f21a211715a384..c352aef3079703 100644 --- a/Mathlib/NumberTheory/NumberField/Cyclotomic/Three.lean +++ b/Mathlib/NumberTheory/NumberField/Cyclotomic/Three.lean @@ -62,10 +62,10 @@ theorem Units.mem [NumberField K] [IsCyclotomicExtension {3} ℚ K] : congr rw [Finset.univ_eq_empty_iff, hrank] infer_instance - obtain ⟨n, hnpos, hn⟩ := isOfFinOrder_iff_pow_eq_one.1 <| (CommGroup.mem_torsion _ _).1 x.2 + obtain ⟨n, hnpos, hn⟩ := isOfFinOrder_iff_pow_eq_one.1 <| (CommGroup.mem_torsion _).1 x.2 replace hn : (↑u : K) ^ ((⟨n, hnpos⟩ : ℕ+) : ℕ) = 1 := by rw [← map_pow] - convert map_one (algebraMap (𝓞 K) K) + convert! map_one (algebraMap (𝓞 K) K) rw_mod_cast [hxu, hn] simp obtain ⟨r, hr3, hru⟩ := hζ.exists_pow_or_neg_mul_pow_of_isOfFinOrder (by decide) @@ -187,9 +187,9 @@ lemma lambda_pow_four_dvd_cube_sub_one_of_dvd_sub_one {x : 𝓞 K} (h : λ ∣ x lemma lambda_pow_four_dvd_cube_add_one_of_dvd_add_one {x : 𝓞 K} (h : λ ∣ x + 1) : λ ^ 4 ∣ x ^ 3 + 1 := by replace h : λ ∣ -x - 1 := by - convert h.neg_right using 1 + convert! h.neg_right using 1 exact (neg_add' x 1).symm - convert (lambda_pow_four_dvd_cube_sub_one_of_dvd_sub_one hζ h).neg_right using 1 + convert! (lambda_pow_four_dvd_cube_sub_one_of_dvd_sub_one hζ h).neg_right using 1 ring /-- If `λ` does not divide `x`, then `λ ^ 4` divides `x ^ 3 - 1` or `x ^ 3 + 1`. -/ diff --git a/Mathlib/NumberTheory/NumberField/Discriminant/Basic.lean b/Mathlib/NumberTheory/NumberField/Discriminant/Basic.lean index 78257f2feb9537..d144b529ff71ee 100644 --- a/Mathlib/NumberTheory/NumberField/Discriminant/Basic.lean +++ b/Mathlib/NumberTheory/NumberField/Discriminant/Basic.lean @@ -157,7 +157,7 @@ theorem exists_ne_zero_mem_ideal_of_norm_le_mul_sqrt_discr (I : (FractionalIdeal mul_one] · exact mul_ne_top (ne_of_lt (minkowskiBound_lt_top K I)) coe_ne_top · exact (Nat.cast_ne_zero.mpr (ne_of_gt finrank_pos)) - convert exists_ne_zero_mem_ideal_of_norm_le K I h_le + convert! exists_ne_zero_mem_ideal_of_norm_le K I h_le rw [div_pow B, ← Real.rpow_natCast B, ← Real.rpow_mul (by positivity), div_mul_cancel₀ _ (Nat.cast_ne_zero.mpr <| ne_of_gt finrank_pos), Real.rpow_one, mul_comm_div, mul_div_assoc'] congr 1 @@ -264,7 +264,7 @@ theorem abs_discr_ge (h : 1 < finrank ℚ K) : simp [field, div_pow] ring · rw [_root_.le_div_iff₀ (by positivity), pow_succ] - convert (mul_le_mul h_m this (by positivity) (by positivity)) using 1 + convert! (mul_le_mul h_m this (by positivity) (by positivity)) using 1 field refine le_trans (le_of_eq (by simp [field]; norm_num)) (one_add_mul_le_pow ?_ (2 * m)) exact le_trans (by norm_num : (-2 : ℝ) ≤ 0) (by positivity) @@ -322,7 +322,7 @@ theorem finite_of_finite_generating_set {p : IntermediateField ℚ A → Prop} refine Set.finite_coe_iff.mp <| Finite.of_injective (fun ⟨F, hF⟩ ↦ (⟨(h F hF).choose, (h F hF).choose_spec.1⟩ : T)) (fun _ _ h_eq ↦ ?_) rw [Subtype.ext_iff, Subtype.ext_iff] - convert congr_arg (ℚ⟮·⟯) (Subtype.mk_eq_mk.mp h_eq) + convert! congr_arg (ℚ⟮·⟯) (Subtype.mk_eq_mk.mp h_eq) all_goals exact (h _ (Subtype.mem _)).choose_spec.2 variable (N : ℕ) @@ -433,7 +433,7 @@ theorem finite_of_discr_bdd_of_isReal : · refine mem_rootSet.mpr ⟨minpoly.ne_zero hx, ?_⟩ exact (aeval_algebraMap_eq_zero_iff A (x : K) _).mpr (minpoly.aeval ℤ (x : K)) · rw [← (IntermediateField.lift_injective _).eq_iff, eq_comm] at hx₁ - convert hx₁ + convert! hx₁ · simp only [IntermediateField.lift_top] · simp only [IntermediateField.lift_adjoin, Set.image_singleton] calc @@ -483,7 +483,7 @@ theorem finite_of_discr_bdd_of_isComplex : · refine mem_rootSet.mpr ⟨minpoly.ne_zero hx, ?_⟩ exact (aeval_algebraMap_eq_zero_iff A (x : K) _).mpr (minpoly.aeval ℤ (x : K)) · rw [← (IntermediateField.lift_injective _).eq_iff, eq_comm] at hx₁ - convert hx₁ + convert! hx₁ · simp only [IntermediateField.lift_top] · simp only [IntermediateField.lift_adjoin, Set.image_singleton] calc diff --git a/Mathlib/NumberTheory/NumberField/Discriminant/Defs.lean b/Mathlib/NumberTheory/NumberField/Discriminant/Defs.lean index a04ad7fb371ba6..89170f562592ec 100644 --- a/Mathlib/NumberTheory/NumberField/Discriminant/Defs.lean +++ b/Mathlib/NumberTheory/NumberField/Discriminant/Defs.lean @@ -79,7 +79,7 @@ theorem numberField_discr : discr ℚ = 1 := by let b : Basis (Fin 1) ℤ (𝓞 ℚ) := Basis.map (Basis.singleton (Fin 1) ℤ) ringOfIntegersEquiv.toAddEquiv.toIntLinearEquiv.symm calc NumberField.discr ℚ - _ = Algebra.discr ℤ b := by convert (discr_eq_discr ℚ b).symm + _ = Algebra.discr ℤ b := by convert! (discr_eq_discr ℚ b).symm _ = Algebra.trace ℤ (𝓞 ℚ) (b default * b default) := by rw [Algebra.discr_def, Matrix.det_unique, Algebra.traceMatrix_apply, Algebra.traceForm_apply] _ = Algebra.trace ℤ (𝓞 ℚ) 1 := by @@ -103,7 +103,7 @@ theorem Algebra.discr_eq_discr_of_toMatrix_coeff_isIntegral [NumberField K] (h' : ∀ i j, IsIntegral ℤ (b'.toMatrix b i j)) : discr ℚ b = discr ℚ b' := by replace h' : ∀ i j, IsIntegral ℤ (b'.toMatrix (b.reindex (b.indexEquiv b')) i j) := by intro i j - convert h' i ((b.indexEquiv b').symm j) + convert! h' i ((b.indexEquiv b').symm j) simp [Basis.toMatrix_apply] classical rw [← (b.reindex (b.indexEquiv b')).toMatrix_map_vecMul b', discr_of_matrix_vecMul, diff --git a/Mathlib/NumberTheory/NumberField/EquivReindex.lean b/Mathlib/NumberTheory/NumberField/EquivReindex.lean index ff300249c4bdb5..c2ac127cc3b9b0 100644 --- a/Mathlib/NumberTheory/NumberField/EquivReindex.lean +++ b/Mathlib/NumberTheory/NumberField/EquivReindex.lean @@ -53,8 +53,9 @@ theorem conj_basisMatrix : theorem det_of_basisMatrix_non_zero [DecidableEq (K →+* ℂ)] : (basisMatrix K).det ≠ 0 := by rw [basisMatrix_eq_embeddingsMatrixReindex, ← pow_ne_zero_iff two_ne_zero] - convert (map_ne_zero_iff _ (algebraMap ℚ ℂ).injective).mpr - (Algebra.discr_not_zero_of_basis ℚ (integralBasis K)) + convert! + (map_ne_zero_iff _ (algebraMap ℚ ℂ).injective).mpr + (Algebra.discr_not_zero_of_basis ℚ (integralBasis K)) rw [← Algebra.discr_reindex ℚ (integralBasis K) (equivReindex K).symm] exact (Algebra.discr_eq_det_embeddingsMatrixReindex_pow_two ℚ ℂ (integralBasis K ∘ (equivReindex K)) RingHom.equivRatAlgHom).symm diff --git a/Mathlib/NumberTheory/NumberField/House.lean b/Mathlib/NumberTheory/NumberField/House.lean index cdeb09cbcaaed2..403ac21e762d0f 100644 --- a/Mathlib/NumberTheory/NumberField/House.lean +++ b/Mathlib/NumberTheory/NumberField/House.lean @@ -319,7 +319,7 @@ private theorem house_le_bound : ∀ l, house (ξ K x l).1 ≤ (c₁ K) * _ ≤ h * (c₂ K) * ((q * c₁ K * A) ^ ((p : ℝ) / (q - p))) := ?_ _ ≤ c₁ K * ((c₁ K * ↑q * A) ^ ((p : ℝ) / (q - p))) := ?_ · simp_rw [← map_mul, map_sum]; apply house_sum_le_sum_house - · gcongr with r _; convert house_mul_le .. + · gcongr with r _; convert! house_mul_le .. simp only [map_intCast, house_intCast, Int.cast_abs, Int.norm_eq_abs] · unfold supOfBasis gcongr with r _ diff --git a/Mathlib/NumberTheory/NumberField/Ideal/Asymptotics.lean b/Mathlib/NumberTheory/NumberField/Ideal/Asymptotics.lean index c6b0a1338f5ee9..9a9c6ecfa906f7 100644 --- a/Mathlib/NumberTheory/NumberField/Ideal/Asymptotics.lean +++ b/Mathlib/NumberTheory/NumberField/Ideal/Asymptotics.lean @@ -87,15 +87,16 @@ theorem tendsto_norm_le_and_mk_eq_div_atTop : have h₂ : {x | x ∈ fundamentalCone K ∧ mixedEmbedding.norm x ≤ 1} = normLeOne K := by ext; simp obtain ⟨J, hJ⟩ := ClassGroup.mk0_surjective C⁻¹ have h₃ : (absNorm J.1 : ℝ) ≠ 0 := (Nat.cast_ne_zero.mpr (absNorm_ne_zero_of_nonZeroDivisors J)) - convert ((ZLattice.covolume.tendsto_card_le_div' - (ZLattice.comap ℝ (mixedEmbedding.idealLattice K (FractionalIdeal.mk0 K J)) - (toMixed K).toLinearMap) - (F := fun x ↦ mixedEmbedding.norm (toMixed K x)) - (X := (toMixed K) ⁻¹' (fundamentalCone K)) (fun _ _ _ h ↦ ?_) (fun _ _ h ↦ ?_) - ((toMixed K).antilipschitz.isBounded_preimage (isBounded_normLeOne K)) ?_ ?_).mul - (tendsto_const_nhds (x := (absNorm (J : Ideal (𝓞 K)) : ℝ) * (torsionOrder K : ℝ)⁻¹))).comp - (tendsto_id.atTop_mul_const' <| Nat.cast_pos.mpr (absNorm_pos_of_nonZeroDivisors J)) - using 2 with s + convert! + ((ZLattice.covolume.tendsto_card_le_div' + (ZLattice.comap ℝ (mixedEmbedding.idealLattice K (FractionalIdeal.mk0 K J)) + (toMixed K).toLinearMap) + (F := fun x ↦ mixedEmbedding.norm (toMixed K x)) (X := + (toMixed K) ⁻¹' (fundamentalCone K)) (fun _ _ _ h ↦ ?_) (fun _ _ h ↦ ?_) + ((toMixed K).antilipschitz.isBounded_preimage (isBounded_normLeOne K)) ?_ ?_).mul + (tendsto_const_nhds (x := (absNorm (J : Ideal (𝓞 K)) : ℝ) * (torsionOrder K : ℝ)⁻¹))).comp + (tendsto_id.atTop_mul_const' <| Nat.cast_pos.mpr (absNorm_pos_of_nonZeroDivisors J)) using + 2 with s · simp_rw [Ideal.tendsto_norm_le_and_mk_eq_div_atTop_aux₁ K hJ, id_eq, Nat.card_congr (Ideal.tendsto_norm_le_and_mk_eq_div_atTop_aux₂ K), ← card_isPrincipal_dvd_norm_le, Function.comp_def, Nat.cast_mul, div_eq_mul_inv, mul_inv, @@ -128,8 +129,9 @@ theorem tendsto_norm_le_div_atTop₀ : (𝓝 ((2 ^ nrRealPlaces K * (2 * π) ^ nrComplexPlaces K * regulator K * classNumber K) / (torsionOrder K * Real.sqrt |discr K|))) := by classical - convert Filter.Tendsto.congr' ?_ - (tendsto_finsetSum Finset.univ (fun C _ ↦ tendsto_norm_le_and_mk_eq_div_atTop K C)) + convert! + Filter.Tendsto.congr' ?_ + (tendsto_finsetSum Finset.univ (fun C _ ↦ tendsto_norm_le_and_mk_eq_div_atTop K C)) · rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, classNumber] ring · filter_upwards [eventually_ge_atTop 0] with s hs diff --git a/Mathlib/NumberTheory/NumberField/InfinitePlace/Basic.lean b/Mathlib/NumberTheory/NumberField/InfinitePlace/Basic.lean index 4498f40aff6de5..8a5ba37de10e61 100644 --- a/Mathlib/NumberTheory/NumberField/InfinitePlace/Basic.lean +++ b/Mathlib/NumberTheory/NumberField/InfinitePlace/Basic.lean @@ -306,9 +306,12 @@ theorem card_filter_mk_eq [NumberField K] (w : InfinitePlace K) : #{φ | mk φ = rwa [Ne, eq_comm, ← ComplexEmbedding.isReal_iff, ← isReal_iff] open scoped Classical in -noncomputable instance NumberField.InfinitePlace.fintype [NumberField K] : +protected noncomputable instance fintype [NumberField K] : Fintype (InfinitePlace K) := Set.fintypeRange _ +@[deprecated (since := "2026-05-24")] +alias NumberField.InfinitePlace.fintype := InfinitePlace.fintype + open scoped Classical in @[to_additive] theorem prod_eq_prod_mul_prod {α : Type*} [CommMonoid α] [NumberField K] (f : InfinitePlace K → α) : @@ -353,7 +356,7 @@ variable [NumberField K] theorem prod_eq_abs_norm (x : K) : ∏ w : InfinitePlace K, w x ^ mult w = abs (Algebra.norm ℚ x) := by classical - convert (congr_arg (‖·‖) (Algebra.norm_eq_prod_embeddings ℚ ℂ x)).symm + convert! (congr_arg (‖·‖) (Algebra.norm_eq_prod_embeddings ℚ ℂ x)).symm · rw [norm_prod, ← Fintype.prod_equiv RingHom.equivRatAlgHom (fun f => ‖f x‖) (fun φ => ‖φ x‖) fun _ => by simp [RingHom.equivRatAlgHom_apply]] rw [← Finset.prod_fiberwise Finset.univ mk (fun φ => ‖φ x‖)] @@ -430,8 +433,9 @@ theorem card_real_embeddings : theorem card_eq_nrRealPlaces_add_nrComplexPlaces : Fintype.card (InfinitePlace K) = nrRealPlaces K + nrComplexPlaces K := by classical - convert Fintype.card_subtype_or_disjoint (IsReal (K := K)) (IsComplex (K := K)) - (disjoint_isReal_isComplex K) using 1 + convert! + Fintype.card_subtype_or_disjoint (IsReal (K := K)) (IsComplex (K := K)) + (disjoint_isReal_isComplex K) using 1 exact (Fintype.card_of_subtype _ (fun w ↦ ⟨fun _ ↦ isReal_or_isComplex w, fun _ ↦ by simp⟩)).symm open scoped Classical in @@ -443,7 +447,7 @@ theorem card_complex_embeddings : simp_rw [Finset.sum_const, this, smul_eq_mul, mul_one, Fintype.card, Finset.card_eq_sum_ones, Finset.mul_sum, Finset.sum_const, smul_eq_mul, mul_one] rintro ⟨w, hw⟩ - convert card_filter_mk_eq w + convert! card_filter_mk_eq w · rw [← Fintype.card_subtype, ← Fintype.card_subtype] refine Fintype.card_congr (Equiv.ofBijective ?_ ⟨fun _ _ h => ?_, fun ⟨φ, hφ⟩ => ?_⟩) · exact fun ⟨φ, hφ⟩ => ⟨φ.val, by rwa [Subtype.ext_iff] at hφ⟩ diff --git a/Mathlib/NumberTheory/NumberField/InfinitePlace/Embeddings.lean b/Mathlib/NumberTheory/NumberField/InfinitePlace/Embeddings.lean index ea6a83b45f797e..d1a5dafc52a651 100644 --- a/Mathlib/NumberTheory/NumberField/InfinitePlace/Embeddings.lean +++ b/Mathlib/NumberTheory/NumberField/InfinitePlace/Embeddings.lean @@ -78,7 +78,7 @@ The images of `x` by the embeddings of `K` in `A` are exactly the roots in `A` o the minimal polynomial of `x` over `ℚ`. -/ theorem range_eval_eq_rootSet_minpoly : (range fun φ : K →+* A => φ x) = (minpoly ℚ x).rootSet A := by - convert (NumberField.isAlgebraic K).range_eval_eq_rootSet_minpoly A x using 1 + convert! (NumberField.isAlgebraic K).range_eval_eq_rootSet_minpoly A x using 1 ext a exact ⟨fun ⟨φ, hφ⟩ => ⟨φ.toRatAlgHom, hφ⟩, fun ⟨φ, hφ⟩ => ⟨φ.toRingHom, hφ⟩⟩ @@ -148,7 +148,7 @@ end NumberField.Embeddings section Place -variable {K : Type*} [Field K] {A : Type*} [NormedDivisionRing A] [Nontrivial A] (φ : K →+* A) +variable {K : Type*} [Field K] {A : Type*} [NormedDivisionRing A] (φ : K →+* A) /-- An embedding into a normed division ring defines a place of `K` -/ def NumberField.place : AbsoluteValue K ℝ := @@ -238,7 +238,7 @@ lemma IsReal.comp (f : k →+* K) {φ : K →+* ℂ} (hφ : IsReal φ) : lemma isReal_comp_iff {f : k ≃+* K} {φ : K →+* ℂ} : IsReal (φ.comp (f : k →+* K)) ↔ IsReal φ := - ⟨fun H ↦ by convert H.comp f.symm.toRingHom; ext1; simp, IsReal.comp _⟩ + ⟨fun H ↦ by convert! H.comp f.symm.toRingHom; ext1; simp, IsReal.comp _⟩ lemma exists_comp_symm_eq_of_comp_eq [Algebra k K] [IsGalois k K] (φ ψ : K →+* ℂ) (h : φ.comp (algebraMap k K) = ψ.comp (algebraMap k K)) : diff --git a/Mathlib/NumberTheory/NumberField/InfinitePlace/Ramification.lean b/Mathlib/NumberTheory/NumberField/InfinitePlace/Ramification.lean index a9ba9a5f4335cf..895e14943b6c9d 100644 --- a/Mathlib/NumberTheory/NumberField/InfinitePlace/Ramification.lean +++ b/Mathlib/NumberTheory/NumberField/InfinitePlace/Ramification.lean @@ -418,7 +418,7 @@ lemma even_nat_card_aut_of_not_isUnramified [IsGalois k K] (hw : ¬ IsUnramified · cases nonempty_fintype Gal(K/k) rw [even_iff_two_dvd, ← not_isUnramified_iff_card_stabilizer_eq_two.mp hw] exact Subgroup.card_subgroup_dvd_card (Stab w) - · convert Even.zero + · convert! Even.zero by_contra e exact H (Nat.finite_of_card_ne_zero e) diff --git a/Mathlib/NumberTheory/NumberField/Units/Basic.lean b/Mathlib/NumberTheory/NumberField/Units/Basic.lean index 2a16846f0e3ff0..6a5ddcb0ad9a36 100644 --- a/Mathlib/NumberTheory/NumberField/Units/Basic.lean +++ b/Mathlib/NumberTheory/NumberField/Units/Basic.lean @@ -58,7 +58,7 @@ variable {K} theorem NumberField.isUnit_iff_norm [NumberField K] {x : 𝓞 K} : IsUnit x ↔ |(RingOfIntegers.norm ℚ x : ℚ)| = 1 := by - convert (RingOfIntegers.isUnit_norm ℚ (F := K)).symm + convert! (RingOfIntegers.isUnit_norm ℚ (F := K)).symm rw [← abs_one, abs_eq_abs, ← Rat.RingOfIntegers.isUnit_iff] end IsUnit @@ -238,7 +238,7 @@ theorem torsion_eq_one_or_neg_one_of_odd_finrank linarith [IsPrimitiveRoot.nrRealPlaces_eq_zero_of_two_lt hc (IsPrimitiveRoot.orderOf (x.1 : K)), NumberField.InfinitePlace.nrRealPlaces_pos_of_odd_finrank h] · interval_cases hi : orderOf (x : (𝓞 K)ˣ) - · linarith [orderOf_pos_iff.2 ((CommGroup.mem_torsion _ x.1).1 x.2)] + · linarith [orderOf_pos_iff.2 ((CommGroup.mem_torsion x.1).1 x.2)] · exact Or.intro_left _ (orderOf_eq_one_iff.1 hi) · rw [← orderOf_units, CharP.orderOf_eq_two_iff 0 (by decide)] at hi simp [← Units.val_inj, ← Units.val_inj, Units.val_neg, Units.val_one, hi] diff --git a/Mathlib/NumberTheory/NumberField/Units/DirichletTheorem.lean b/Mathlib/NumberTheory/NumberField/Units/DirichletTheorem.lean index ec4f090dfea07d..0fa198ba66bf59 100644 --- a/Mathlib/NumberTheory/NumberField/Units/DirichletTheorem.lean +++ b/Mathlib/NumberTheory/NumberField/Units/DirichletTheorem.lean @@ -176,7 +176,7 @@ open scoped Classical in theorem unitLattice_inter_ball_finite (r : ℝ) : ((unitLattice K : Set (logSpace K)) ∩ Metric.closedBall 0 r).Finite := by obtain hr | hr := lt_or_ge r 0 - · convert Set.finite_empty + · convert! Set.finite_empty rw [Metric.closedBall_eq_empty.mpr hr] exact Set.inter_empty _ · suffices {x : (𝓞 K)ˣ | IsIntegral ℤ (x : K) ∧ @@ -226,7 +226,7 @@ theorem seq_next {x : 𝓞 K} (hx : x ≠ 0) : suffices ∀ w, w ≠ w₁ → f w ≠ 0 by obtain ⟨g, h_geqf, h_gprod⟩ := adjust_f K B this obtain ⟨y, h_ynz, h_yle⟩ := exists_ne_zero_mem_ringOfIntegers_lt K (f := g) - (by rw [convexBodyLT_volume]; convert hB; exact congr_arg ((↑) : NNReal → ENNReal) h_gprod) + (by rw [convexBodyLT_volume]; convert! hB; exact congr_arg ((↑) : NNReal → ENNReal) h_gprod) refine ⟨y, h_ynz, fun w hw ↦ (h_geqf w hw ▸ h_yle w).trans ?_, ?_⟩ · rw [← Rat.cast_le (K := ℝ), Rat.cast_natCast] calc @@ -360,7 +360,7 @@ instance instDiscrete_unitLattice : DiscreteTopology (unitLattice K) := by refine isOpen_singleton_of_finite_mem_nhds 0 (s := Metric.closedBall 0 1) ?_ ?_ · exact Metric.closedBall_mem_nhds _ (by simp) · refine Set.Finite.of_finite_image ?_ (Set.injOn_of_injective Subtype.val_injective) - convert unitLattice_inter_ball_finite K 1 + convert! unitLattice_inter_ball_finite K 1 ext x refine ⟨?_, fun ⟨hx1, hx2⟩ ↦ ⟨⟨x, hx1⟩, hx2, rfl⟩⟩ rintro ⟨x, hx, rfl⟩ diff --git a/Mathlib/NumberTheory/NumberField/Units/Regulator.lean b/Mathlib/NumberTheory/NumberField/Units/Regulator.lean index 806dd2712f16fa..cc03550c708700 100644 --- a/Mathlib/NumberTheory/NumberField/Units/Regulator.lean +++ b/Mathlib/NumberTheory/NumberField/Units/Regulator.lean @@ -204,7 +204,7 @@ theorem abs_det_eq_abs_det (u : Fin (rank K) → (𝓞 K)ˣ) (of fun i w ↦ (mult (f w) : ℝ) * ((f w) (u i)).log) ?_ 0 (f.symm w₂) · rw [← det_reindex_self e₁, ← det_reindex_self g] · rw [Units.smul_def, abs_zsmul, Int.abs_negOnePow, one_smul] at h - convert h + convert! h · ext; simp only [ne_eq, reindex_apply, submatrix_apply, of_apply, Equiv.apply_symm_apply, Equiv.trans_apply, Fin.succAbove_zero, id_eq, finSuccEquiv_succ, Equiv.optionSubtype_symm_apply_apply_coe, f] @@ -268,7 +268,7 @@ def regulator : ℝ := ZLattice.covolume (unitLattice K) theorem isMaxRank_fundSystem : IsMaxRank (fundSystem K) := by classical - convert ((basisUnitLattice K).ofZLatticeBasis ℝ (unitLattice K)).linearIndependent + convert! ((basisUnitLattice K).ofZLatticeBasis ℝ (unitLattice K)).linearIndependent rw [logEmbedding_fundSystem, Basis.ofZLatticeBasis_apply] open scoped Classical in diff --git a/Mathlib/NumberTheory/Padics/Hensel.lean b/Mathlib/NumberTheory/Padics/Hensel.lean index 970b05c8b30a6a..98571de58969ce 100644 --- a/Mathlib/NumberTheory/Padics/Hensel.lean +++ b/Mathlib/NumberTheory/Padics/Hensel.lean @@ -74,7 +74,7 @@ include ncs_der_val private theorem ncs_tendsto_const : Tendsto (fun i => ‖F.derivative.aeval (ncs i)‖) atTop (𝓝 ‖F.derivative.aeval a‖) := by - convert @tendsto_const_nhds ℝ _ ℕ _ _; rw [ncs_der_val] + convert! @tendsto_const_nhds ℝ _ ℕ _ _; rw [ncs_der_val] private theorem norm_deriv_eq : ‖F.derivative.aeval ncs.lim‖ = ‖F.derivative.aeval a‖ := tendsto_nhds_unique ncs_tendsto_lim (ncs_tendsto_const ncs_der_val) diff --git a/Mathlib/NumberTheory/Padics/MahlerBasis.lean b/Mathlib/NumberTheory/Padics/MahlerBasis.lean index a0916015af130c..a6a125ff8d4a35 100644 --- a/Mathlib/NumberTheory/Padics/MahlerBasis.lean +++ b/Mathlib/NumberTheory/Padics/MahlerBasis.lean @@ -342,7 +342,7 @@ lemma hasSum_mahler (f : C(ℤ_[p], E)) : HasSum (fun n ↦ mahlerTerm (Δ_[1]^[ (mahlerSeries (Δ_[1]^[·] f 0) : C(ℤ_[p], E)) := hasSum_mahlerSeries (fwdDiff_tendsto_zero f) -- Now show that the sum of the Mahler terms must equal `f` on a dense set, so it is actually `f`. - convert this using 1 + convert! this using 1 refine ContinuousMap.coe_injective (denseRange_natCast.equalizer (map_continuous f) (map_continuous _) (funext fun n ↦ ?_)) simpa [mahlerSeries_apply_nat (fwdDiff_tendsto_zero f) le_rfl] diff --git a/Mathlib/NumberTheory/Padics/PadicIntegers.lean b/Mathlib/NumberTheory/Padics/PadicIntegers.lean index bb26b5291c7eab..a1ff8136d77779 100644 --- a/Mathlib/NumberTheory/Padics/PadicIntegers.lean +++ b/Mathlib/NumberTheory/Padics/PadicIntegers.lean @@ -265,7 +265,7 @@ theorem exists_pow_neg_lt {ε : ℝ} (hε : 0 < ε) : ∃ k : ℕ, (p : ℝ) ^ ( apply lt_of_lt_of_le hk norm_cast apply le_of_lt - convert Nat.lt_pow_self _ using 1 + convert! Nat.lt_pow_self _ using 1 exact hp.1.one_lt · exact mod_cast hp.1.pos diff --git a/Mathlib/NumberTheory/Padics/PadicVal/Basic.lean b/Mathlib/NumberTheory/Padics/PadicVal/Basic.lean index 2d99b6821f97c2..18333fad51b625 100644 --- a/Mathlib/NumberTheory/Padics/PadicVal/Basic.lean +++ b/Mathlib/NumberTheory/Padics/PadicVal/Basic.lean @@ -647,7 +647,7 @@ digits of `k` plus the sum of the digits of `n - k` minus the sum of digits of ` theorem sub_one_mul_padicValNat_choose_eq_sub_sum_digits {k n : ℕ} [hp : Fact p.Prime] (h : k ≤ n) : (p - 1) * padicValNat p (choose n k) = (p.digits k).sum + (p.digits (n - k)).sum - (p.digits n).sum := by - convert @sub_one_mul_padicValNat_choose_eq_sub_sum_digits' _ _ _ ‹_› + convert! @sub_one_mul_padicValNat_choose_eq_sub_sum_digits' _ _ _ ‹_› all_goals lia end padicValNat diff --git a/Mathlib/NumberTheory/Padics/RingHoms.lean b/Mathlib/NumberTheory/Padics/RingHoms.lean index 126f17140c5ddf..7a27105295d93f 100644 --- a/Mathlib/NumberTheory/Padics/RingHoms.lean +++ b/Mathlib/NumberTheory/Padics/RingHoms.lean @@ -73,7 +73,7 @@ def modPart : ℤ := variable {p} theorem modPart_lt_p : modPart p r < p := by - convert Int.emod_lt_abs _ _ + convert! Int.emod_lt_abs _ _ · simp · exact mod_cast hp_prime.1.ne_zero @@ -103,7 +103,7 @@ theorem norm_sub_modPart (h : ‖(r : ℚ_[p])‖ ≤ 1) : ‖(⟨r, h⟩ - modP let n := modPart p r rw [norm_lt_one_iff_dvd, ← (isUnit_den r h).dvd_mul_right] suffices ↑p ∣ r.num - n * r.den by - convert (map_dvd (Int.castRingHom ℤ_[p])) this + convert! (map_dvd (Int.castRingHom ℤ_[p])) this simp only [n, sub_mul, Int.cast_natCast, eq_intCast, Int.cast_mul, sub_left_inj, Int.cast_sub] apply Subtype.coe_injective @@ -252,7 +252,7 @@ lemma zmodRepr_natCast_of_lt {n : ℕ} (hn : n < p) : lemma zmodRepr_natCast_ofNat {n : ℕ} (hn : ofNat(n) < p) : zmodRepr (ofNat(n) : ℤ_[p]) = ofNat(n) := by - convert zmodRepr_natCast_of_lt hn + convert! zmodRepr_natCast_of_lt hn rcases n with _ | _ | n <;> simp lemma zmodRepr_units_ne_zero (x : ℤ_[p]ˣ) : x.val.zmodRepr ≠ 0 := by @@ -280,7 +280,7 @@ def toZModHom (v : ℕ) (f : ℤ_[p] → ℕ) (f_spec : ∀ x, x - f x ∈ (Idea intro x y rw [f_congr (x + y) _ (f x + f y), cast_add] · exact f_spec _ - · convert Ideal.add_mem _ (f_spec x) (f_spec y) using 1 + · convert! Ideal.add_mem _ (f_spec x) (f_spec y) using 1 rw [cast_add] ring map_mul' := by @@ -288,7 +288,7 @@ def toZModHom (v : ℕ) (f : ℤ_[p] → ℕ) (f_spec : ∀ x, x - f x ∈ (Idea rw [f_congr (x * y) _ (f x * f y), cast_mul] · exact f_spec _ · let I : Ideal ℤ_[p] := Ideal.span {↑v} - convert I.add_mem (I.mul_mem_left x (f_spec y)) (I.mul_mem_right ↑(f y) (f_spec x)) using 1 + convert! I.add_mem (I.mul_mem_left x (f_spec y)) (I.mul_mem_right ↑(f y) (f_spec x)) using 1 rw [cast_mul] ring @@ -314,7 +314,7 @@ This coercion is only a ring homomorphism if it coerces into a ring whose charac `p`. While this is not the case here we can still make use of the coercion. -/ theorem toZMod_spec : x - (ZMod.cast (toZMod x) : ℤ_[p]) ∈ maximalIdeal ℤ_[p] := by - convert sub_zmodRepr_mem x using 2 + convert! sub_zmodRepr_mem x using 2 dsimp [toZMod, toZModHom] rcases Nat.exists_eq_add_of_lt hp_prime.1.pos with ⟨p', rfl⟩ change ↑((_ : ZMod (0 + p' + 1)).val) = (_ : ℤ_[0 + p' + 1]) @@ -331,7 +331,7 @@ theorem ker_toZMod : RingHom.ker (toZMod : ℤ_[p] →+* ZMod p) = maximalIdeal · intro h rw [← sub_zero x] at h dsimp [toZMod, toZModHom] - convert zmod_congr_of_sub_mem_max_ideal x _ 0 _ h + convert! zmod_congr_of_sub_mem_max_ideal x _ 0 _ h · norm_cast · apply sub_zmodRepr_mem @@ -461,7 +461,7 @@ theorem ker_toZModPow (n : ℕ) : constructor · intro h suffices x.appr n = 0 by - convert appr_spec n x + convert! appr_spec n x simp only [this, sub_zero, cast_zero] dsimp [toZModPow, toZModHom] at h rw [ZMod.natCast_eq_zero_iff] at h @@ -668,7 +668,7 @@ theorem lift_sub_val_mem_span (r : R) (n : ℕ) : rw [sub_eq_sub_add_sub (limNthHom f_compat r) _ ↑(nthHom f r (max n k))] apply Ideal.add_mem _ _ this rw [Ideal.mem_span_singleton] - convert + convert! map_dvd (Int.castRingHom ℤ_[p]) (pow_dvd_nthHom_sub f_compat r n (max n k) (le_max_left _ _)) · simp · simp [nthHom] diff --git a/Mathlib/NumberTheory/Pell.lean b/Mathlib/NumberTheory/Pell.lean index d12baab84524cc..b5df88679627e2 100644 --- a/Mathlib/NumberTheory/Pell.lean +++ b/Mathlib/NumberTheory/Pell.lean @@ -575,7 +575,7 @@ theorem mul_inv_x_lt_x {a₁ : Solution₁ d} (h : IsFundamental a₁) {a : Solu _ = a.x * a₁.y * a₁.x := by ring _ ≤ a.y * a₁.x * a₁.x := by have := h.1; have := x_mul_y_le_y_mul_x h hax hay; gcongr rw [mul_assoc, ← sq, a₁.prop_x, ← sub_neg] - suffices a.y - a.x * a₁.y < 0 by convert this using 1; ring + suffices a.y - a.x * a₁.y < 0 by convert! this using 1; ring rw [sub_neg, ← abs_of_pos hay, ← abs_of_pos h.2.1, ← abs_of_pos <| zero_lt_one.trans hax, ← abs_mul, ← sq_lt_sq, mul_pow, a.prop_x] calc diff --git a/Mathlib/NumberTheory/PrimeCounting.lean b/Mathlib/NumberTheory/PrimeCounting.lean index 17a41190196bc0..b88f94d8aa0873 100644 --- a/Mathlib/NumberTheory/PrimeCounting.lean +++ b/Mathlib/NumberTheory/PrimeCounting.lean @@ -88,7 +88,7 @@ theorem surjective_primeCounting' : Function.Surjective π' := theorem surjective_primeCounting : Function.Surjective π := by suffices Function.Surjective (π ∘ fun n => n - 1) from this.of_comp - convert surjective_primeCounting' + convert! surjective_primeCounting' ext exact primeCounting_sub_one _ @@ -266,7 +266,7 @@ theorem primeCounting'_add_le {a k : ℕ} (h0 : a ≠ 0) (h1 : a < k) (n : ℕ) theorem primeCounting_add_le {a k : ℕ} (h0 : a ≠ 0) (h1 : a ≤ k) (n : ℕ) : π (k + n) ≤ π k + totient a * (n / a + 1) := by rw [primeCounting_eq_primeCounting'_succ] - convert primeCounting'_add_le h0 (Order.lt_add_one_iff.mpr h1) n using 2 + convert! primeCounting'_add_le h0 (Order.lt_add_one_iff.mpr h1) n using 2 omega end Nat diff --git a/Mathlib/NumberTheory/PythagoreanTriples.lean b/Mathlib/NumberTheory/PythagoreanTriples.lean index 4b01469bd7a972..062bb6e1941f47 100644 --- a/Mathlib/NumberTheory/PythagoreanTriples.lean +++ b/Mathlib/NumberTheory/PythagoreanTriples.lean @@ -80,7 +80,7 @@ theorem mul_iff (k : ℤ) (hk : k ≠ 0) : simp only [PythagoreanTriple] intro h rw [← mul_left_inj' (mul_ne_zero hk hk)] - convert h using 1 <;> ring + convert! h using 1 <;> ring /-- A Pythagorean triple `x, y, z` is “classified” if there exist integers `k, m, n` such that either @@ -181,8 +181,9 @@ theorem isClassified_of_isPrimitiveClassified (hp : h.IsPrimitiveClassified) : h theorem isClassified_of_normalize_isPrimitiveClassified (hc : h.normalize.IsPrimitiveClassified) : h.IsClassified := by - convert h.normalize.mul_isClassified (Int.gcd x y) - (isClassified_of_isPrimitiveClassified h.normalize hc) <;> + convert! + h.normalize.mul_isClassified (Int.gcd x y) + (isClassified_of_isPrimitiveClassified h.normalize hc) <;> rw [Int.mul_ediv_cancel'] · exact Int.gcd_dvd_left .. · exact Int.gcd_dvd_right .. @@ -252,7 +253,7 @@ def circleEquivGen (hk : ∀ x : K, 1 + x ^ 2 ≠ 0) : left_inv x := by have h2 : (1 + 1 : K) = 2 := by norm_num have h3 : (2 : K) ≠ 0 := by - convert hk 1 + convert! hk 1 rw [one_pow 2, h2] simp [field, hk x, h2, add_assoc, add_comm, add_sub_cancel, mul_comm] right_inv := fun ⟨⟨x, y⟩, hxy, hy⟩ => by @@ -262,7 +263,7 @@ def circleEquivGen (hk : ∀ x : K, 1 + x ^ 2 ≠ 0) : rw [(add_neg_eq_iff_eq_add.mpr hxy.symm).symm] ring have h4 : (2 : K) ≠ 0 := by - convert hk 1 + convert! hk 1 rw [one_pow 2] ring simp only [Prod.mk_inj, Subtype.mk_eq_mk] @@ -291,10 +292,10 @@ private theorem coprime_sq_sub_sq_add_of_even_odd {m n : ℤ} (h : Int.gcd m n = obtain ⟨p, hp, hp1, hp2⟩ := Nat.Prime.not_coprime_iff_dvd.mp H rw [← Int.natCast_dvd] at hp1 hp2 have h2m : (p : ℤ) ∣ 2 * m ^ 2 := by - convert dvd_add hp2 hp1 using 1 + convert! dvd_add hp2 hp1 using 1 ring have h2n : (p : ℤ) ∣ 2 * n ^ 2 := by - convert dvd_sub hp2 hp1 using 1 + convert! dvd_sub hp2 hp1 using 1 ring have hmc : p = 2 ∨ p ∣ Int.natAbs m := prime_two_or_dvd_of_dvd_two_mul_pow_self_two hp h2m have hnc : p = 2 ∨ p ∣ Int.natAbs n := prime_two_or_dvd_of_dvd_two_mul_pow_self_two hp h2n @@ -388,10 +389,10 @@ private theorem coprime_sq_sub_sq_sum_of_odd_odd {m n : ℤ} (h : Int.gcd m n = rw [← Int.natCast_dvd] at hp1 hp2 apply Nat.dvd_gcd · apply Int.Prime.dvd_natAbs_of_coe_dvd_sq hp - convert dvd_add hp1 hp2 + convert! dvd_add hp1 hp2 ring · apply Int.Prime.dvd_natAbs_of_coe_dvd_sq hp - convert dvd_sub hp2 hp1 + convert! dvd_sub hp2 hp1 ring namespace PythagoreanTriple diff --git a/Mathlib/NumberTheory/RamificationInertia/Basic.lean b/Mathlib/NumberTheory/RamificationInertia/Basic.lean index 05e2ed79846948..7a88c4a6d1dee8 100644 --- a/Mathlib/NumberTheory/RamificationInertia/Basic.lean +++ b/Mathlib/NumberTheory/RamificationInertia/Basic.lean @@ -260,7 +260,8 @@ theorem finrank_quotient_map [IsDomain S] [IsDedekindDomain R] [Algebra K L] Submodule.Quotient.eq] at y_eq exact add_mem (Submodule.mem_sup_left y_mem) (neg_mem <| Submodule.mem_sup_right y_eq) · have := b.linearIndependent; rw [b_eq_b'] at this - convert FinrankQuotientMap.linearIndependent_of_nontrivial K _ + convert! + FinrankQuotientMap.linearIndependent_of_nontrivial K _ ((Algebra.linearMap S L).restrictScalars R) _ ((Submodule.mkQ _).restrictScalars R) this · rw [Quotient.algebraMap_eq, Ideal.mk_ker] exact hp.ne_top diff --git a/Mathlib/NumberTheory/RamificationInertia/Galois.lean b/Mathlib/NumberTheory/RamificationInertia/Galois.lean index 29bb40aa13df0c..c1c03b98160bcd 100644 --- a/Mathlib/NumberTheory/RamificationInertia/Galois.lean +++ b/Mathlib/NumberTheory/RamificationInertia/Galois.lean @@ -198,6 +198,8 @@ theorem inertiaDegIn_mul_inertiaDegIn [p.IsMaximal] [P.IsMaximal] : rw [inertiaDegIn_eq_inertiaDeg p P G, inertiaDegIn_eq_inertiaDeg p Q GAC, inertiaDegIn_eq_inertiaDeg P Q GBC, inertiaDeg_algebra_tower p P Q] +set_option linter.overlappingInstances false + variable {p} in include G GAC GBC in theorem ramificationIdxIn_mul_ramificationIdxIn [IsDedekindDomain B] [IsDedekindDomain C] diff --git a/Mathlib/NumberTheory/RamificationInertia/Ramification.lean b/Mathlib/NumberTheory/RamificationInertia/Ramification.lean index 7f2015f426cce7..7013facf35c31a 100644 --- a/Mathlib/NumberTheory/RamificationInertia/Ramification.lean +++ b/Mathlib/NumberTheory/RamificationInertia/Ramification.lean @@ -71,7 +71,7 @@ variable {p P} theorem ramificationIdx_eq_find [DecidablePred fun n ↦ ∀ (k : ℕ), map f p ≤ P ^ k → k ≤ n] (h : ∃ n, ∀ k, map f p ≤ P ^ k → k ≤ n) : ramificationIdx p P = Nat.find h := by - convert Nat.sSup_def h + convert! Nat.sSup_def h theorem ramificationIdx_eq_zero (h : ∀ n : ℕ, ∃ k, map f p ≤ P ^ k ∧ n < k) : ramificationIdx p P = 0 := @@ -270,7 +270,7 @@ lemma ramificationIdx_eq_one_iff have ha' : ¬ a ≤ P := fun h ↦ H₁ (ha.trans_le (Ideal.mul_mono_right h)) rw [IsScalarTower.algebraMap_eq _ S, ← Ideal.map_map, ha, Ideal.map_mul, Localization.AtPrime.map_eq_maximalIdeal] - convert Ideal.mul_top _ + convert! Ideal.mul_top _ on_goal 2 => infer_instance rw [← not_ne_iff, IsLocalization.map_algebraMap_ne_top_iff_disjoint P.primeCompl] simpa [primeCompl, Set.disjoint_compl_left_iff_subset] diff --git a/Mathlib/NumberTheory/Real/GoldenRatio.lean b/Mathlib/NumberTheory/Real/GoldenRatio.lean index 81d8de91d46b21..2b6c97d2d59bdf 100644 --- a/Mathlib/NumberTheory/Real/GoldenRatio.lean +++ b/Mathlib/NumberTheory/Real/GoldenRatio.lean @@ -120,7 +120,7 @@ theorem neg_one_lt_goldenConj : -1 < ψ := by theorem goldenRatio_irrational : Irrational φ := by have := Nat.Prime.irrational_sqrt (show Nat.Prime 5 by norm_num) have := this.ratCast_add 1 - convert this.ratCast_mul (show (0.5 : ℚ) ≠ 0 by norm_num) + convert! this.ratCast_mul (show (0.5 : ℚ) ≠ 0 by norm_num) simp ring @@ -128,7 +128,7 @@ theorem goldenRatio_irrational : Irrational φ := by theorem goldenConj_irrational : Irrational ψ := by have := Nat.Prime.irrational_sqrt (show Nat.Prime 5 by norm_num) have := this.ratCast_sub 1 - convert this.ratCast_mul (show (0.5 : ℚ) ≠ 0 by norm_num) + convert! this.ratCast_mul (show (0.5 : ℚ) ≠ 0 by norm_num) simp ring @@ -187,7 +187,7 @@ theorem coe_fib_eq' : · exact fib_isSol_fibRec · suffices LinearRecurrence.IsSolution fibRec ((fun n ↦ (√5)⁻¹ * φ ^ n) - (fun n ↦ (√5)⁻¹ * ψ ^ n)) by - convert this + convert! this rw [Pi.sub_apply] ring apply (@fibRec ℝ _).solSpace.sub_mem diff --git a/Mathlib/NumberTheory/SmoothNumbers.lean b/Mathlib/NumberTheory/SmoothNumbers.lean index 56d8ee820b5e11..68e8e8966278fd 100644 --- a/Mathlib/NumberTheory/SmoothNumbers.lean +++ b/Mathlib/NumberTheory/SmoothNumbers.lean @@ -200,32 +200,22 @@ def equivProdNatFactoredNumbers {s : Finset ℕ} {p : ℕ} (hp : p.Prime) (hs : ⟨(m.primeFactorsList.filter (· ∈ s)).prod, prod_mem_factoredNumbers ..⟩) left_inv := by rintro ⟨e, m, hm₀, hm⟩ - simp (etaStruct := .all) only [Prod.mk.injEq, Subtype.mk.injEq] + have hpm : ¬ p ∣ m := by grind [mem_primeFactorsList] + simp only [Prod.mk.injEq, Subtype.mk.injEq] constructor - · rw [factorization_mul (pos_iff_ne_zero.mp <| Nat.pow_pos hp.pos) hm₀] - simp only [factorization_pow, Finsupp.coe_add, Finsupp.coe_smul, nsmul_eq_mul, - Pi.natCast_def, cast_id, Pi.add_apply, Pi.mul_apply, hp.factorization_self, - mul_one, add_eq_left] - rw [← primeFactorsList_count_eq, count_eq_zero] - exact fun H ↦ hs (hm p H) - · nth_rewrite 2 [← prod_primeFactorsList hm₀] + · rw [factorization_mul (pow_ne_zero e hp.ne_zero) hm₀, Finsupp.add_apply, + factorization_pow_self hp, factorization_eq_zero_of_not_dvd hpm, add_zero] + · conv_rhs => rw [← prod_primeFactorsList hm₀] refine prod_eq <| (filter _ <| perm_primeFactorsList_mul (pow_ne_zero e hp.ne_zero) hm₀).trans ?_ - rw [filter_append, hp.primeFactorsList_pow, - filter_eq_nil_iff.mpr fun q hq ↦ by rw [mem_replicate] at hq; simp [hq.2, hs], - nil_append, filter_eq_self.mpr fun q hq ↦ by simp only [hm q hq, decide_true]] + rw [filter_append, hp.primeFactorsList_pow, filter_eq_nil_iff.mpr <| by grind, nil_append, + filter_eq_self.mpr <| by grind] right_inv := by rintro ⟨m, hm₀, hm⟩ - simp only [Subtype.mk.injEq] - rw [← primeFactorsList_count_eq, ← prod_replicate, ← prod_append] - nth_rewrite 3 [← prod_primeFactorsList hm₀] - have : m.primeFactorsList.filter (· = p) = m.primeFactorsList.filter (· ∉ s) := by - refine (filter_congr fun q hq ↦ ?_).symm - simp only [decide_not] - rcases Finset.mem_insert.mp <| hm _ hq with h | h - · simp only [h, hs, decide_false, Bool.not_false, decide_true] - · simp only [h, decide_true, Bool.not_true, false_eq_decide_iff] - exact fun H ↦ hs <| H ▸ h + rw [Subtype.mk.injEq, ← primeFactorsList_count_eq, ← prod_replicate, ← prod_append] + conv_rhs => rw [← prod_primeFactorsList hm₀] + have : m.primeFactorsList.filter (· = p) = m.primeFactorsList.filter (· ∉ s) := + filter_congr <| by grind refine prod_eq <| (filter_eq p).symm ▸ this ▸ perm_append_comm.trans ?_ simp only [decide_not] exact filter_append_perm (· ∈ s) (primeFactorsList m) @@ -461,8 +451,7 @@ lemma smoothNumbersUpTo_subset_image (N k : ℕ) : /-- The cardinality of the set of `k`-smooth numbers `≤ N` is bounded by `2^π(k-1) * √N`. -/ lemma smoothNumbersUpTo_card_le (N k : ℕ) : #(smoothNumbersUpTo N k) ≤ 2 ^ #k.primesBelow * N.sqrt := by - convert (Finset.card_le_card <| smoothNumbersUpTo_subset_image N k).trans <| - Finset.card_image_le + convert! (Finset.card_le_card <| smoothNumbersUpTo_subset_image N k).trans <| Finset.card_image_le simp only [Finset.card_product, Finset.card_powerset, Finset.mem_range, zero_lt_succ, Finset.card_erase_of_mem, Finset.card_range, succ_sub_succ_eq_sub, Nat.sub_zero] diff --git a/Mathlib/NumberTheory/SumPrimeReciprocals.lean b/Mathlib/NumberTheory/SumPrimeReciprocals.lean index 94e4d257368527..5811222e1cb395 100644 --- a/Mathlib/NumberTheory/SumPrimeReciprocals.lean +++ b/Mathlib/NumberTheory/SumPrimeReciprocals.lean @@ -49,7 +49,7 @@ lemma one_half_le_sum_primes_ge_one_div (k : ℕ) : set N₀ : ℕ := 2 * m ^ 2 with hN₀ let S : ℝ := ((2 * N₀).succ.primesBelow \ k.primesBelow).sum (fun p ↦ (1 / p : ℝ)) suffices 1 / 2 ≤ S by - convert this using 5 + convert! this using 5 rw [show 4 = 2 ^ 2 by simp, pow_right_comm] ring suffices 2 * N₀ ≤ m * (2 * N₀).sqrt + 2 * N₀ * S by @@ -72,11 +72,13 @@ theorem not_summable_one_div_on_primes : specialize hk ({p | Nat.Prime p} ∩ {p | k ≤ p}) inter_subset_right rw [tsum_subtype, indicator_indicator, inter_eq_left.mpr fun n hn ↦ hn.1, mem_Iio] at hk have h' : Summable (indicator ({p | Nat.Prime p} ∩ {p | k ≤ p}) fun n ↦ (1 : ℝ) / n) := by - convert h.indicator {n : ℕ | k ≤ n} using 1 + convert! h.indicator {n : ℕ | k ≤ n} using 1 simp only [indicator_indicator, inter_comm] refine ((one_half_le_sum_primes_ge_one_div k).trans_lt <| LE.le.trans_lt ?_ hk).false - convert Summable.sum_le_tsum (primesBelow ((4 ^ (k.primesBelow.card + 1)).succ) \ primesBelow k) - (fun n _ ↦ indicator_nonneg (fun p _ ↦ by positivity) _) h' using 2 with p hp + convert! + Summable.sum_le_tsum (primesBelow ((4 ^ (k.primesBelow.card + 1)).succ) \ primesBelow k) + (fun n _ ↦ indicator_nonneg (fun p _ ↦ by positivity) _) h' using + 2 with p hp obtain ⟨hp₁, hp₂⟩ := mem_setOf_eq ▸ Finset.mem_sdiff.mp hp have hpp := prime_of_mem_primesBelow hp₁ refine (indicator_of_mem ?_ fun n : ℕ ↦ (1 / n : ℝ)).symm @@ -85,7 +87,7 @@ theorem not_summable_one_div_on_primes : set_option backward.isDefEq.respectTransparency false in /-- The sum over the reciprocals of the primes diverges. -/ theorem Nat.Primes.not_summable_one_div : ¬ Summable (fun p : Nat.Primes ↦ (1 / p : ℝ)) := by - convert summable_subtype_iff_indicator.mp.mt not_summable_one_div_on_primes + convert! summable_subtype_iff_indicator.mp.mt not_summable_one_div_on_primes /-- The series over `p^r` for primes `p` converges if and only if `r < -1`. -/ theorem Nat.Primes.summable_rpow {r : ℝ} : diff --git a/Mathlib/NumberTheory/Transcendental/Lindemann/AnalyticalPart.lean b/Mathlib/NumberTheory/Transcendental/Lindemann/AnalyticalPart.lean index 2cf8a8492ee505..f25063e0c90276 100644 --- a/Mathlib/NumberTheory/Transcendental/Lindemann/AnalyticalPart.lean +++ b/Mathlib/NumberTheory/Transcendental/Lindemann/AnalyticalPart.lean @@ -31,7 +31,7 @@ theorem hasDerivAt_cexp_mul_sumIDeriv (p : ℂ[X]) (s : ℂ) (x : ℝ) : have h₀ := (hasDerivAt_id' x).smul_const s have h₁ := h₀.fun_neg.cexp have h₂ := ((sumIDeriv p).hasDerivAt (x • s)).comp x h₀ - convert (h₁.mul h₂).fun_neg using 1 + convert! (h₁.mul h₂).fun_neg using 1 nth_rw 1 [sumIDeriv_eq_self_add p] simp only [one_smul, eval_add, Function.comp_apply] ring @@ -72,7 +72,7 @@ private theorem P_le_aux (f : ℕ → ℂ[X]) (s : ℂ) (c : ℝ) rw [P_eq_integral_exp_mul_eval (f p) s, mul_comm s, norm_mul, norm_mul, norm_exp] gcongr rw [intervalIntegral.integral_of_le zero_le_one, ← mul_one (_ * _)] - convert MeasureTheory.norm_setIntegral_le_of_norm_le_const _ _ + convert! MeasureTheory.norm_setIntegral_le_of_norm_le_const _ _ · rw [Real.volume_real_Ioc_of_le zero_le_one, sub_zero] · rw [Real.volume_Ioc, sub_zero]; exact ENNReal.ofReal_lt_top intro x hx diff --git a/Mathlib/NumberTheory/Transcendental/Liouville/LiouvilleNumber.lean b/Mathlib/NumberTheory/Transcendental/Liouville/LiouvilleNumber.lean index 42ffe3c7473802..2242416cd8e260 100644 --- a/Mathlib/NumberTheory/Transcendental/Liouville/LiouvilleNumber.lean +++ b/Mathlib/NumberTheory/Transcendental/Liouville/LiouvilleNumber.lean @@ -81,7 +81,7 @@ protected theorem summable {m : ℝ} (hm : 1 < m) : Summable fun i : ℕ => 1 / theorem remainder_summable {m : ℝ} (hm : 1 < m) (k : ℕ) : Summable fun i : ℕ => 1 / m ^ (i + (k + 1))! := by - convert (summable_nat_add_iff (k + 1)).2 (LiouvilleNumber.summable hm) + convert! (summable_nat_add_iff (k + 1)).2 (LiouvilleNumber.summable hm) theorem remainder_pos {m : ℝ} (hm : 1 < m) (k : ℕ) : 0 < remainder m k := (remainder_summable hm k).tsum_pos (fun _ => by positivity) 0 (by positivity) diff --git a/Mathlib/NumberTheory/Transcendental/Liouville/LiouvilleWith.lean b/Mathlib/NumberTheory/Transcendental/Liouville/LiouvilleWith.lean index 9c603876f5cce2..682e83ab6f38d2 100644 --- a/Mathlib/NumberTheory/Transcendental/Liouville/LiouvilleWith.lean +++ b/Mathlib/NumberTheory/Transcendental/Liouville/LiouvilleWith.lean @@ -219,7 +219,7 @@ protected theorem neg (h : LiouvilleWith p x) : LiouvilleWith p (-x) := by refine ⟨C, hC.mono ?_⟩ rintro n ⟨m, hne, hlt⟩ refine ⟨-m, by simp [neg_div, hne], ?_⟩ - convert hlt using 1 + convert! hlt using 1 rw [abs_sub_comm] congr! 1; push_cast; ring diff --git a/Mathlib/NumberTheory/Transcendental/Liouville/Residual.lean b/Mathlib/NumberTheory/Transcendental/Liouville/Residual.lean index 970a8e420ede92..c3d05833f12589 100644 --- a/Mathlib/NumberTheory/Transcendental/Liouville/Residual.lean +++ b/Mathlib/NumberTheory/Transcendental/Liouville/Residual.lean @@ -63,7 +63,7 @@ theorem eventually_residual_liouville : ∀ᶠ x in residual ℝ, Liouville x := simp only [mem_iInter, mem_iUnion] refine fun n => ⟨r.num * 2, r.den * 2, ?_, ?_⟩ · have := r.pos; lia - · convert @mem_ball_self ℝ _ (r : ℝ) _ _ + · convert! @mem_ball_self ℝ _ (r : ℝ) _ _ · push_cast -- Workaround for https://github.com/leanprover/lean4/pull/6438; this eliminates an -- `Expr.mdata` that would cause `norm_cast` to skip a numeral. diff --git a/Mathlib/NumberTheory/WellApproximable.lean b/Mathlib/NumberTheory/WellApproximable.lean index 0d6bafe84f0dd4..51f2d6e1ac8f88 100644 --- a/Mathlib/NumberTheory/WellApproximable.lean +++ b/Mathlib/NumberTheory/WellApproximable.lean @@ -106,7 +106,7 @@ theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.Coprime m) : replace hb : b ^ m ∈ {u : A | orderOf u = n} := by rw [← hb] at hmn ⊢; exact hmn.orderOf_pow apply ball_subset_thickening hb ((m : ℝ) • δ) - convert pow_mem_ball hm hab using 1 + convert! pow_mem_ball hm hab using 1 simp only [nsmul_eq_mul, smul_eq_mul] @[to_additive] @@ -117,7 +117,7 @@ theorem image_pow_subset (n : ℕ) (hm : 0 < m) : replace hb : b ^ m ∈ {y : A | orderOf y = n} := by rw [mem_setOf_eq, orderOf_pow' b hm.ne', hb, Nat.gcd_mul_left_left, n.mul_div_cancel hm] apply ball_subset_thickening hb (m * δ) - convert pow_mem_ball hm hab using 1 + convert! pow_mem_ball hm hab using 1 simp only [nsmul_eq_mul] @[to_additive] @@ -285,7 +285,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto specialize this (approxAddOrderOf.image_nsmul_subset (δ n) (n / p) hp.pos) simp only [h_div] at this ⊢ refine this.trans ?_ - convert approxAddOrderOf.vadd_subset_of_coprime (p * δ n) h_cop + convert! approxAddOrderOf.vadd_subset_of_coprime (p * δ n) h_cop rw [hu₀, Subtype.coe_mk, mul_comm p, h_div] change (∀ᵐ x, x ∉ E) ∨ E ∈ ae volume rw [← eventuallyEq_empty, ← eventuallyEq_univ] diff --git a/Mathlib/NumberTheory/ZetaValues.lean b/Mathlib/NumberTheory/ZetaValues.lean index 7cc9d44990bfcd..40bb5b8d8cd850 100644 --- a/Mathlib/NumberTheory/ZetaValues.lean +++ b/Mathlib/NumberTheory/ZetaValues.lean @@ -85,7 +85,7 @@ section Calculus theorem hasDerivAt_bernoulliFun (k : ℕ) (x : ℝ) : HasDerivAt (bernoulliFun k) (k * bernoulliFun (k - 1) x) x := by - convert ((Polynomial.bernoulli k).map <| algebraMap ℚ ℝ).hasDerivAt x using 1 + convert! ((Polynomial.bernoulli k).map <| algebraMap ℚ ℝ).hasDerivAt x using 1 simp only [bernoulliFun, Polynomial.derivative_map, Polynomial.derivative_bernoulli k, Polynomial.map_mul, Polynomial.map_natCast, Polynomial.eval_mul, Polynomial.eval_natCast] @@ -109,7 +109,7 @@ theorem deriv_bernoulliFun : theorem antideriv_bernoulliFun (k : ℕ) (x : ℝ) : HasDerivAt (fun x => bernoulliFun (k + 1) x / (k + 1)) (bernoulliFun k x) x := by - convert (hasDerivAt_bernoulliFun (k + 1) x).div_const _ using 1 + convert! (hasDerivAt_bernoulliFun (k + 1) x).div_const _ using 1 simp [Nat.cast_add_one_ne_zero k] theorem integral_bernoulliFun : ∫ x : ℝ in 0..1, bernoulliFun k x = if k = 0 then 1 else 0 := by @@ -309,7 +309,7 @@ theorem hasSum_one_div_pow_mul_fourier_mul_bernoulliFun {k : ℕ} (hk : 2 ≤ k) rw [← Ico_insert_right (zero_le_one' ℝ), mem_insert_iff, or_comm] at hx rcases hx with (hx | rfl) · exact this hx - · convert this (left_mem_Ico.mpr zero_lt_one) using 1 + · convert! this (left_mem_Ico.mpr zero_lt_one) using 1 · rw [AddCircle.coe_period, QuotientAddGroup.mk_zero] · rw [bernoulliFun_endpoints_eq_of_ne_one (by lia : k ≠ 1)] intro y hy @@ -322,7 +322,7 @@ theorem hasSum_one_div_pow_mul_fourier_mul_bernoulliFun {k : ℕ} (hk : 2 ≤ k) has_pointwise_sum_fourier_series_of_summable ((summable_bernoulli_fourier hk).congr fun n => (step1 n).symm) y simp_rw [step1] at step2 - convert step2.mul_left (-(2 * ↑π * I) ^ k / (k ! : ℂ)) using 2 with n + convert! step2.mul_left (-(2 * ↑π * I) ^ k / (k ! : ℂ)) using 2 with n · rw [smul_eq_mul, ← mul_assoc, mul_div, mul_neg, div_mul_cancel₀, neg_neg, mul_pow _ (n : ℂ), ← div_div, div_self] · rw [Ne, pow_eq_zero_iff', not_and_or] @@ -341,7 +341,7 @@ theorem hasSum_one_div_nat_pow_mul_fourier {k : ℕ} (hk : 2 ≤ k) {x : ℝ} (h (fun n : ℕ => (1 : ℂ) / (n : ℂ) ^ k * (fourier n (x : 𝕌) + (-1 : ℂ) ^ k * fourier (-n) (x : 𝕌))) (-(2 * π * I) ^ k / k ! * bernoulliFun k x) := by - convert (hasSum_one_div_pow_mul_fourier_mul_bernoulliFun hk hx).nat_add_neg using 1 + convert! (hasSum_one_div_pow_mul_fourier_mul_bernoulliFun hk hx).nat_add_neg using 1 · ext1 n rw [Int.cast_neg, mul_add, ← mul_assoc] conv_rhs => rw [neg_eq_neg_one_mul, mul_pow, ← div_div] @@ -359,9 +359,7 @@ theorem hasSum_one_div_nat_pow_mul_cos {k : ℕ} (hk : k ≠ 0) {x : ℝ} (hx : have : HasSum (fun n : ℕ => 1 / (n : ℂ) ^ (2 * k) * (fourier n (x : 𝕌) + fourier (-n) (x : 𝕌))) ((-1 : ℂ) ^ (k + 1) * (2 * (π : ℂ)) ^ (2 * k) / (2 * k)! * bernoulliFun (2 * k) x) := by - convert - hasSum_one_div_nat_pow_mul_fourier (by lia : 2 ≤ 2 * k) - hx using 3 + convert! hasSum_one_div_nat_pow_mul_fourier (by lia : 2 ≤ 2 * k) hx using 3 · rw [pow_mul (-1 : ℂ), neg_one_sq, one_pow, one_mul] · rw [pow_add, pow_one] conv_rhs => @@ -372,8 +370,8 @@ theorem hasSum_one_div_nat_pow_mul_cos {k : ℕ} (hk : k ≠ 0) {x : ℝ} (hx : · rw [pow_mul, I_sq] ring have ofReal_two : ((2 : ℝ) : ℂ) = 2 := by norm_cast - convert ((hasSum_iff _ _).mp (this.div_const 2)).1 with n - · convert (ofReal_re _).symm + convert! ((hasSum_iff _ _).mp (this.div_const 2)).1 with n + · convert! (ofReal_re _).symm rw [ofReal_mul]; rw [← mul_div]; congr · rw [ofReal_div, ofReal_one, ofReal_pow]; rfl · rw [ofReal_cos, ofReal_mul, fourier_coe_apply, fourier_coe_apply, cos, ofReal_one, div_one, @@ -382,7 +380,7 @@ theorem hasSum_one_div_nat_pow_mul_cos {k : ℕ} (hk : k ≠ 0) {x : ℝ} (hx : congr 3 · ring · ring - · convert (ofReal_re _).symm + · convert! (ofReal_re _).symm rw [ofReal_mul, ofReal_div, ofReal_div, ofReal_mul, ofReal_pow, ofReal_pow, ofReal_neg, ofReal_natCast, ofReal_mul, ofReal_two, ofReal_one] rw [bernoulliFun] @@ -396,9 +394,7 @@ theorem hasSum_one_div_nat_pow_mul_sin {k : ℕ} (hk : k ≠ 0) {x : ℝ} (hx : HasSum (fun n : ℕ => 1 / (n : ℂ) ^ (2 * k + 1) * (fourier n (x : 𝕌) - fourier (-n) (x : 𝕌))) ((-1 : ℂ) ^ (k + 1) * I * (2 * π : ℂ) ^ (2 * k + 1) / (2 * k + 1)! * bernoulliFun (2 * k + 1) x) := by - convert - hasSum_one_div_nat_pow_mul_fourier - (by lia : 2 ≤ 2 * k + 1) hx using 1 + convert! hasSum_one_div_nat_pow_mul_fourier (by lia : 2 ≤ 2 * k + 1) hx using 1 · ext1 n rw [pow_add (-1 : ℂ), pow_mul (-1 : ℂ), neg_one_sq, one_pow, one_mul, pow_one, ← neg_eq_neg_one_mul, ← sub_eq_add_neg] @@ -412,8 +408,8 @@ theorem hasSum_one_div_nat_pow_mul_sin {k : ℕ} (hk : k ≠ 0) {x : ℝ} (hx : · rw [pow_add, pow_one, pow_mul, I_sq] ring have ofReal_two : ((2 : ℝ) : ℂ) = 2 := by norm_cast - convert ((hasSum_iff _ _).mp (this.div_const (2 * I))).1 - · convert (ofReal_re _).symm + convert! ((hasSum_iff _ _).mp (this.div_const (2 * I))).1 + · convert! (ofReal_re _).symm rw [ofReal_mul]; rw [← mul_div]; congr · rw [ofReal_div, ofReal_one, ofReal_pow]; rfl · rw [ofReal_sin, ofReal_mul, fourier_coe_apply, fourier_coe_apply, sin, ofReal_one, div_one, @@ -422,7 +418,7 @@ theorem hasSum_one_div_nat_pow_mul_sin {k : ℕ} (hk : k ≠ 0) {x : ℝ} (hx : congr 4 · ring · ring - · convert (ofReal_re _).symm + · convert! (ofReal_re _).symm rw [ofReal_mul, ofReal_div, ofReal_div, ofReal_mul, ofReal_pow, ofReal_pow, ofReal_neg, ofReal_natCast, ofReal_mul, ofReal_two, ofReal_one, ← div_div, div_I, div_mul_eq_mul_div₀] @@ -435,7 +431,7 @@ theorem hasSum_zeta_nat {k : ℕ} (hk : k ≠ 0) : HasSum (fun n : ℕ => 1 / (n : ℝ) ^ (2 * k)) ((-1 : ℝ) ^ (k + 1) * (2 : ℝ) ^ (2 * k - 1) * π ^ (2 * k) * bernoulli (2 * k) / (2 * k)!) := by - convert hasSum_one_div_nat_pow_mul_cos hk (left_mem_Icc.mpr zero_le_one) using 1 + convert! hasSum_one_div_nat_pow_mul_cos hk (left_mem_Icc.mpr zero_le_one) using 1 · ext1 n; rw [mul_zero, Real.cos_zero, mul_one] rw [Polynomial.eval_zero_map, Polynomial.bernoulli_eval_zero, eq_ratCast] have : (2 : ℝ) ^ (2 * k - 1) = (2 : ℝ) ^ (2 * k) / 2 := by @@ -454,12 +450,12 @@ end Cleanup section Examples theorem hasSum_zeta_two : HasSum (fun n : ℕ => (1 : ℝ) / (n : ℝ) ^ 2) (π ^ 2 / 6) := by - convert hasSum_zeta_nat one_ne_zero using 1; rw [mul_one] + convert! hasSum_zeta_nat one_ne_zero using 1; rw [mul_one] rw [bernoulli_eq_bernoulli'_of_ne_one (by decide : 2 ≠ 1), bernoulli'_two] simp [Nat.factorial]; ring theorem hasSum_zeta_four : HasSum (fun n : ℕ => (1 : ℝ) / (n : ℝ) ^ 4) (π ^ 4 / 90) := by - convert hasSum_zeta_nat two_ne_zero using 1 + convert! hasSum_zeta_nat two_ne_zero using 1 simp only [Nat.reduceAdd, Nat.reduceMul, Nat.add_one_sub_one] rw [bernoulli_eq_bernoulli'_of_ne_one, bernoulli'_four] · simp [Nat.factorial]; ring diff --git a/Mathlib/NumberTheory/Zsqrtd/Basic.lean b/Mathlib/NumberTheory/Zsqrtd/Basic.lean index 25a68986289d3b..1250002e986ee9 100644 --- a/Mathlib/NumberTheory/Zsqrtd/Basic.lean +++ b/Mathlib/NumberTheory/Zsqrtd/Basic.lean @@ -381,7 +381,7 @@ theorem sqLe_mul {d x y z w : ℕ} : Int.mul_nonneg (sub_nonneg_of_le (Int.ofNat_le_ofNat_of_le xy)) (sub_nonneg_of_le (Int.ofNat_le_ofNat_of_le zw)) refine Int.le_of_ofNat_le_ofNat (le_of_sub_nonneg ?_) - convert this using 1 + convert! this using 1 simp only [one_mul, Int.natCast_add, Int.natCast_mul] ring diff --git a/Mathlib/Order/Antisymmetrization.lean b/Mathlib/Order/Antisymmetrization.lean index 5dec6e53ca0e48..b978a8279572cb 100644 --- a/Mathlib/Order/Antisymmetrization.lean +++ b/Mathlib/Order/Antisymmetrization.lean @@ -294,7 +294,7 @@ set_option backward.isDefEq.respectTransparency false in theorem wellFoundedGT_antisymmetrization_iff : WellFoundedGT (Antisymmetrization α (· ≤ ·)) ↔ WellFoundedGT α := by simp_rw [isWellFounded_iff] - convert wellFounded_liftOn₂'_iff with ⟨_⟩ ⟨_⟩ + convert! wellFounded_liftOn₂'_iff with ⟨_⟩ ⟨_⟩ exact fun _ _ _ _ h₁ h₂ ↦ propext ⟨fun h ↦ (h₂.2.trans_lt h).trans_le h₁.1, fun h ↦ (h₂.1.trans_lt h).trans_le h₁.2⟩ diff --git a/Mathlib/Order/Atoms.lean b/Mathlib/Order/Atoms.lean index 7ec8aa336b79cb..aec6767d9b4053 100644 --- a/Mathlib/Order/Atoms.lean +++ b/Mathlib/Order/Atoms.lean @@ -1179,7 +1179,7 @@ theorem ComplementedLattice.isStronglyAtomic [IsAtomic α] : IsStronglyAtomic α · obtain rfl : a = b := by simpa [codisjoint_bot, ← Subtype.coe_inj] using ha'.codisjoint exact False.elim <| hab.ne rfl refine ⟨d ⊔ a, IsUpperModularLattice.covBy_sup_of_inf_covBy ?_, sup_le (hd.2.trans ha'b) hab.le⟩ - convert hd.1.bot_covBy + convert! hd.1.bot_covBy rw [← le_bot_iff, ← show a ⊓ a' = ⊥ by simpa using Subtype.coe_inj.2 ha'.inf_eq_bot, inf_comm] exact inf_le_inf_left _ hd.2 diff --git a/Mathlib/Order/Basic.lean b/Mathlib/Order/Basic.lean index 3c46756ef31e9f..171497e5c919fe 100644 --- a/Mathlib/Order/Basic.lean +++ b/Mathlib/Order/Basic.lean @@ -13,6 +13,7 @@ public import Mathlib.Tactic.Convert public import Mathlib.Tactic.Inhabit public import Mathlib.Tactic.SimpRw public import Mathlib.Tactic.GCongr.Core +public import Mathlib.Tactic.FastInstance /-! # Basic definitions about `≤` and `<` @@ -527,7 +528,7 @@ theorem compl_gt [LinearOrder α] : (· > · : α → α → _)ᶜ = (· ≤ ·) theorem compl_ge [LinearOrder α] : (· ≥ · : α → α → _)ᶜ = (· < ·) := by simp [compl] instance Ne.instIsEquiv_compl : IsEquiv α (· ≠ ·)ᶜ := by - convert eq_isEquiv α + convert! eq_isEquiv α simp [compl] /-! ### Order instances on the function space -/ @@ -834,10 +835,10 @@ theorem coe_lt_coe [LT α] {p : α → Prop} {x y : Subtype p} : (x : α) < y Iff.rfl instance preorder [Preorder α] (p : α → Prop) : Preorder (Subtype p) := - Preorder.lift (fun (a : Subtype p) ↦ (a : α)) + fast_instance% Preorder.lift (fun (a : Subtype p) ↦ (a : α)) instance partialOrder [PartialOrder α] (p : α → Prop) : PartialOrder (Subtype p) := - PartialOrder.lift (fun (a : Subtype p) ↦ (a : α)) Subtype.coe_injective + fast_instance% PartialOrder.lift (fun (a : Subtype p) ↦ (a : α)) Subtype.coe_injective instance decidableLE [Preorder α] [h : DecidableLE α] {p : α → Prop} : DecidableLE (Subtype p) := fun a b ↦ h a b @@ -849,7 +850,7 @@ instance decidableLT [Preorder α] [h : DecidableLT α] {p : α → Prop} : equality and decidable order in order to ensure the decidability instances are all definitionally equal. -/ instance instLinearOrder [LinearOrder α] (p : α → Prop) : LinearOrder (Subtype p) := - @LinearOrder.lift (Subtype p) _ _ ⟨fun x y ↦ ⟨max x y, max_rec' _ x.2 y.2⟩⟩ + fast_instance% @LinearOrder.lift (Subtype p) _ _ ⟨fun x y ↦ ⟨max x y, max_rec' _ x.2 y.2⟩⟩ ⟨fun x y ↦ ⟨min x y, min_rec' _ x.2 y.2⟩⟩ (fun (a : Subtype p) ↦ (a : α)) Subtype.coe_injective (fun _ _ ↦ rfl) fun _ _ ↦ rfl diff --git a/Mathlib/Order/Bounded.lean b/Mathlib/Order/Bounded.lean index dddc3d771498da..6e767eb5a7a504 100644 --- a/Mathlib/Order/Bounded.lean +++ b/Mathlib/Order/Bounded.lean @@ -285,7 +285,7 @@ theorem bounded_le_inter_lt [LinearOrder α] (a : α) : theorem unbounded_le_inter_lt [LinearOrder α] (a : α) : Unbounded (· ≤ ·) (s ∩ { b | a < b }) ↔ Unbounded (· ≤ ·) s := by - convert @unbounded_le_inter_not_le _ s _ a + convert! @unbounded_le_inter_not_le _ s _ a exact lt_iff_not_ge theorem bounded_le_inter_le [LinearOrder α] (a : α) : @@ -313,12 +313,12 @@ theorem unbounded_lt_inter_not_lt [SemilatticeSup α] (a : α) : theorem bounded_lt_inter_le [LinearOrder α] (a : α) : Bounded (· < ·) (s ∩ { b | a ≤ b }) ↔ Bounded (· < ·) s := by - convert @bounded_lt_inter_not_lt _ s _ a + convert! @bounded_lt_inter_not_lt _ s _ a exact not_lt.symm theorem unbounded_lt_inter_le [LinearOrder α] (a : α) : Unbounded (· < ·) (s ∩ { b | a ≤ b }) ↔ Unbounded (· < ·) s := by - convert @unbounded_lt_inter_not_lt _ s _ a + convert! @unbounded_lt_inter_not_lt _ s _ a exact not_lt.symm theorem bounded_lt_inter_lt [LinearOrder α] [NoMaxOrder α] (a : α) : diff --git a/Mathlib/Order/BoundedOrder/Basic.lean b/Mathlib/Order/BoundedOrder/Basic.lean index 2d82c7360e5202..cfd324ab8f9b91 100644 --- a/Mathlib/Order/BoundedOrder/Basic.lean +++ b/Mathlib/Order/BoundedOrder/Basic.lean @@ -317,6 +317,14 @@ end Pi section Subsingleton +/-- A type with a single element is a bounded order. -/ +@[implicit_reducible] +def BoundedOrder.ofUnique (α : Type*) [Preorder α] [Unique α] : BoundedOrder α where + bot := default + top := default + le_top := by simp + bot_le := by simp + variable [PartialOrder α] [BoundedOrder α] @[to_dual] diff --git a/Mathlib/Order/Cofinal.lean b/Mathlib/Order/Cofinal.lean index 0e8b480d90627f..ce94954545c4d6 100644 --- a/Mathlib/Order/Cofinal.lean +++ b/Mathlib/Order/Cofinal.lean @@ -17,11 +17,10 @@ import Mathlib.Data.Set.Lattice A set `s` in an ordered type `α` is cofinal when for every `a : α` there exists an element of `s` greater or equal to it. This file provides a basic API for the `IsCofinal` predicate. -For the cofinality of a set as a cardinal, see `Mathlib/SetTheory/Cardinal/Cofinality.lean`. +For the cofinality of a set as a cardinal, see `Mathlib/SetTheory/Cardinal/Cofinality/Basic.lean`. ## TODO -- Define `Order.cof` in terms of `Cofinal`. - Deprecate `Order.Cofinal` in favor of this predicate. -/ diff --git a/Mathlib/Order/CompleteBooleanAlgebra.lean b/Mathlib/Order/CompleteBooleanAlgebra.lean index a6a490826bb5aa..e27eaa794629f0 100644 --- a/Mathlib/Order/CompleteBooleanAlgebra.lean +++ b/Mathlib/Order/CompleteBooleanAlgebra.lean @@ -657,20 +657,45 @@ theorem compl_sInf' : (sInf s)ᶜ = sSup (Compl.compl '' s) := theorem compl_sSup' : (sSup s)ᶜ = sInf (Compl.compl '' s) := compl_sSup.trans sInf_image.symm -open scoped symmDiff in +section symmDiff + +open scoped symmDiff + /-- The symmetric difference of two `iSup`s is at most the `iSup` of the symmetric differences. -/ theorem iSup_symmDiff_iSup_le {g : ι → α} : (⨆ i, f i) ∆ (⨆ i, g i) ≤ ⨆ i, ((f i) ∆ (g i)) := by simp_rw [symmDiff_le_iff, ← iSup_sup_eq] exact ⟨iSup_mono fun i ↦ sup_comm (g i) _ ▸ le_symmDiff_sup_right .., iSup_mono fun i ↦ sup_comm (f i) _ ▸ symmDiff_comm (f i) _ ▸ le_symmDiff_sup_right ..⟩ -open scoped symmDiff in +theorem iSup_symmDiff_le [Nonempty ι] {a : α} : (⨆ i, f i) ∆ a ≤ ⨆ i, f i ∆ a := by + simpa [iSup_const] using iSup_symmDiff_iSup_le (g := fun _ : ι ↦ a) + +theorem symmDiff_iSup_le [Nonempty ι] {a : α} : a ∆ (⨆ i, f i) ≤ ⨆ i, a ∆ f i := by + simpa [symmDiff_comm] using iSup_symmDiff_le (a := a) + +theorem sSup_symmDiff_le (hs : s.Nonempty) {a : α} : sSup s ∆ a ≤ sSup ((· ∆ a) '' s) := by + rw [sSup_image', sSup_eq_iSup'] + have : Nonempty s := Set.nonempty_coe_sort.mpr hs + exact iSup_symmDiff_le + +theorem symmDiff_sSup_le (hs : s.Nonempty) {a : α} : a ∆ sSup s ≤ sSup ((a ∆ ·) '' s) := by + simpa [symmDiff_comm] using sSup_symmDiff_le (a := a) hs + +theorem sSup_symmDiff_sSup_le {s t : Set α} (hs : s.Nonempty) (ht : t.Nonempty) : + sSup s ∆ sSup t ≤ sSup (image2 (· ∆ ·) s t) := by + rw [sSup_image2] + calc + _ ≤ ⨆ a ∈ s, a ∆ sSup t := by simpa [sSup_image] using sSup_symmDiff_le hs + _ ≤ _ := iSup_mono fun a ↦ iSup_mono fun _ ↦ by simpa [sSup_image] using symmDiff_sSup_le ht + /-- A `biSup` version of `iSup_symmDiff_iSup_le`. -/ theorem biSup_symmDiff_biSup_le {p : ι → Prop} {f g : (i : ι) → p i → α} : (⨆ i, ⨆ (h : p i), f i h) ∆ (⨆ i, ⨆ (h : p i), g i h) ≤ ⨆ i, ⨆ (h : p i), ((f i h) ∆ (g i h)) := le_trans iSup_symmDiff_iSup_le <| iSup_mono fun _ ↦ iSup_symmDiff_iSup_le +end symmDiff + end CompleteBooleanAlgebra /-- diff --git a/Mathlib/Order/CompleteLattice/Basic.lean b/Mathlib/Order/CompleteLattice/Basic.lean index 3d52bcf1010ffc..b517fcbc73ac36 100644 --- a/Mathlib/Order/CompleteLattice/Basic.lean +++ b/Mathlib/Order/CompleteLattice/Basic.lean @@ -186,7 +186,7 @@ theorem Equiv.iSup_comp {g : ι' → α} (e : ι ≃ ι') : ⨆ x, g (e x) = ⨆ @[to_dual] protected theorem Function.Surjective.iSup_congr {g : ι' → α} (h : ι → ι') (h1 : Surjective h) (h2 : ∀ x, g (h x) = f x) : ⨆ x, f x = ⨆ y, g y := by - convert h1.iSup_comp g + convert! h1.iSup_comp g exact (h2 _).symm @[to_dual] @@ -661,7 +661,7 @@ theorem iSup_split (f : β → α) (p : β → Prop) : @[to_dual] theorem iSup_split_single (f : β → α) (i₀ : β) : ⨆ i, f i = f i₀ ⊔ ⨆ (i) (_ : i ≠ i₀), f i := by - convert iSup_split f (fun i => i = i₀) + convert! iSup_split f (fun i => i = i₀) simp @[to_dual] diff --git a/Mathlib/Order/ConditionallyCompleteLattice/Indexed.lean b/Mathlib/Order/ConditionallyCompleteLattice/Indexed.lean index 8842e00b5713c9..a6924bdcf33a1c 100644 --- a/Mathlib/Order/ConditionallyCompleteLattice/Indexed.lean +++ b/Mathlib/Order/ConditionallyCompleteLattice/Indexed.lean @@ -347,12 +347,12 @@ theorem csInf_image {s : Set β} {f : β → α} theorem cbiSup_id {s : Set α} (hs : BddAbove s) (h : sSup ∅ ≤ sSup s) : ⨆ i ∈ s, i = sSup s := by rw [← csSup_image (Subtype.range_coe ▸ hs), Set.image_id'] - · convert h + · convert! h rw [← sSup_range, Subtype.range_coe] theorem cbiInf_id {s : Set α} (hs : BddBelow s) (h : sInf s ≤ sInf ∅) : ⨅ i ∈ s, i = sInf s := by rw [← csInf_image (Subtype.range_coe ▸ hs), Set.image_id'] - · convert h + · convert! h rw [← sInf_range, Subtype.range_coe] lemma ciSup_image {ι ι' : Type*} {s : Set ι} {f : ι → ι'} {g : ι' → α} diff --git a/Mathlib/Order/Cover.lean b/Mathlib/Order/Cover.lean index b028c0d19d901e..181fc3bf111482 100644 --- a/Mathlib/Order/Cover.lean +++ b/Mathlib/Order/Cover.lean @@ -466,7 +466,7 @@ variable {s t : Set α} {a : α} @[simp] lemma sdiff_singleton_wcovBy (s : Set α) (a : α) : s \ {a} ⩿ s := by by_cases ha : a ∈ s - · convert wcovBy_insert a _ + · convert! wcovBy_insert a _ ext simp [ha] · simp [ha] diff --git a/Mathlib/Order/Filter/AtTopBot/Defs.lean b/Mathlib/Order/Filter/AtTopBot/Defs.lean index e3c5c9422c1d28..bd4d65103d96bd 100644 --- a/Mathlib/Order/Filter/AtTopBot/Defs.lean +++ b/Mathlib/Order/Filter/AtTopBot/Defs.lean @@ -122,6 +122,6 @@ theorem Antitone.piecewise_eventually_eq_iInter {β : α → Type*} [Preorder ι (hs : Antitone s) (f g : (a : α) → β a) (a : α) : ∀ᶠ i in atTop, (s i).piecewise f g a = (⋂ i, s i).piecewise f g a := by classical - convert ← (compl_anti.comp hs).piecewise_eventually_eq_iUnion g f a using 3 - · convert congr_fun (Set.piecewise_compl (s _) g f) a + convert! ← (compl_anti.comp hs).piecewise_eventually_eq_iUnion g f a using 3 + · convert! congr_fun (Set.piecewise_compl (s _) g f) a · simp only [(· ∘ ·), ← compl_iInter, Set.piecewise_compl] diff --git a/Mathlib/Order/Filter/AtTopBot/Finset.lean b/Mathlib/Order/Filter/AtTopBot/Finset.lean index c4d6aec14a2584..5391b68de4f9c2 100644 --- a/Mathlib/Order/Filter/AtTopBot/Finset.lean +++ b/Mathlib/Order/Filter/AtTopBot/Finset.lean @@ -6,6 +6,7 @@ Authors: Johannes Hölzl, Jeremy Avigad, Yury Kudryashov, Patrick Massot module public import Mathlib.Data.Finset.Order +public import Mathlib.Data.Fintype.EquivFin public import Mathlib.Order.Filter.AtTopBot.Basic public import Mathlib.Order.Filter.Finite public import Mathlib.Order.Interval.Finset.Defs @@ -89,4 +90,56 @@ theorem tendsto_finset_Ici_atBot_atTop [Preorder α] [LocallyFiniteOrderTop α] Tendsto (Finset.Ici (α := α)) atBot atTop := tendsto_finset_Iic_atTop_atTop (α := αᵒᵈ) +section Card + +/-- Every finset is eventually a subset of `s` along `atTop`. -/ +lemma eventually_finset_atTop_subset (i : Finset α) : ∀ᶠ s : Finset α in atTop, i ⊆ s := + eventually_ge_atTop _ + +/-- Every element of `α` is eventually a member of `s` along `atTop` on `Finset α`. -/ +lemma eventually_finset_mem_atTop (i : α) : ∀ᶠ s : Finset α in atTop, i ∈ s := by + simpa using eventually_finset_atTop_subset {i} + +/-- The pushforward of `atTop` on `Finset α` along `Finset.card` is `atTop` on `ℕ`, when `α` is +infinite. -/ +lemma map_card_atTop [Infinite α] : + map (Finset.card (α := α)) atTop = atTop := by + rw [map_atTop_eq, atTop] + refine Function.Surjective.iInf_congr Finset.card Finset.exists_card_eq fun s ↦ congr(𝓟 $(?_)) + ext + refine ⟨Infinite.exists_superset_card_eq _ _, ?_⟩ + aesop (add safe apply Finset.card_le_card) + +/-- The pushforward of `atTop` on `Finset α` along `Finset.card` is `pure (Fintype.card α)`, when +`α` is finite. -/ +lemma map_card_atTop_of_fintype [Fintype α] : + map (Finset.card : Finset α → ℕ) atTop = pure (Fintype.card α) := by + simp [OrderTop.atTop_eq] + +/-- `Finset.card` tends to `atTop` along `atTop` on `Finset α`, when `α` is infinite. -/ +lemma tendsto_card_atTop_atTop [Infinite α] : + Tendsto (Finset.card (α := α)) atTop atTop := by + rw [Tendsto, map_card_atTop] + +/-- `Finset.card` tends to `pure (Fintype.card α)`, when `α` is finite. -/ +lemma tendsto_card_atTop_pure_of_fintype [Fintype α] : + Tendsto (Finset.card : Finset α → ℕ) atTop (pure (Fintype.card α)) := by + rw [Tendsto, map_card_atTop_of_fintype] + +/-- `Tendsto` along `atTop` for a function precomposed with `Finset.card` reduces to `Tendsto` along +`atTop` on `ℕ`, when `α` is infinite. -/ +lemma tendsto_comp_card_atTop_iff [Infinite α] {f : ℕ → β} {l : Filter β} : + Tendsto (fun s : Finset α ↦ f s.card) atTop l ↔ Tendsto f atTop l := by + rw [← map_card_atTop (α := α), tendsto_map'_iff] + rfl + +/-- `Tendsto` along `atTop` for a function precomposed with `Finset.card` reduces to `Tendsto` along +`pure (Fintype.card α)`, when `α` is finite. -/ +lemma tendsto_comp_card_atTop_iff_of_fintype [Fintype α] {f : ℕ → β} {l : Filter β} : + Tendsto (fun s : Finset α ↦ f s.card) atTop l ↔ Tendsto f (pure (Fintype.card α)) l := by + rw [← map_card_atTop_of_fintype, tendsto_map'_iff] + rfl + +end Card + end Filter diff --git a/Mathlib/Order/Filter/Bases/Basic.lean b/Mathlib/Order/Filter/Bases/Basic.lean index 1e4c67fe5ea543..e1eebb40d3032b 100644 --- a/Mathlib/Order/Filter/Bases/Basic.lean +++ b/Mathlib/Order/Filter/Bases/Basic.lean @@ -768,7 +768,7 @@ theorem map_sigma_mk_comap {π : α → Type*} {π' : β → Type*} {f : α → (hf : Function.Injective f) (g : ∀ a, π a → π' (f a)) (a : α) (l : Filter (π' (f a))) : map (Sigma.mk a) (comap (g a) l) = comap (Sigma.map f g) (map (Sigma.mk (f a)) l) := by refine (((basis_sets _).comap _).map _).eq_of_same_basis ?_ - convert ((basis_sets l).map (Sigma.mk (f a))).comap (Sigma.map f g) + convert! ((basis_sets l).map (Sigma.mk (f a))).comap (Sigma.map f g) apply image_sigmaMk_preimage_sigmaMap hf end Filter diff --git a/Mathlib/Order/Filter/CountablyGenerated.lean b/Mathlib/Order/Filter/CountablyGenerated.lean index 5edae09f216ec0..acc28986485df4 100644 --- a/Mathlib/Order/Filter/CountablyGenerated.lean +++ b/Mathlib/Order/Filter/CountablyGenerated.lean @@ -128,7 +128,7 @@ theorem HasBasis.exists_antitone_subbasis {f : Filter α} [h : f.IsCountablyGene exacts [hs.set_index_subset _, (hs.set_index_subset _).trans inter_subset_left] refine ⟨fun i => (x i).1, fun i => (x i).2, ?_⟩ have : (⨅ i, 𝓟 (s (x i).1)).HasAntitoneBasis fun i => s (x i).1 := .iInf_principal x_anti - convert this + convert! this exact le_antisymm (le_iInf fun i => le_principal_iff.2 <| by cases i <;> apply hs.set_index_mem) (hx'.symm ▸ diff --git a/Mathlib/Order/Filter/ENNReal.lean b/Mathlib/Order/Filter/ENNReal.lean index ef750e24b29954..63cb8665190c29 100644 --- a/Mathlib/Order/Filter/ENNReal.lean +++ b/Mathlib/Order/Filter/ENNReal.lean @@ -30,7 +30,7 @@ lemma limsSup_of_not_isCobounded {f : Filter ℝ} (hf : ¬ f.IsCobounded (· ≤ @[simp] lemma limsSup_of_not_isBounded {f : Filter ℝ} (hf : ¬ f.IsBounded (· ≤ ·)) : limsSup f = 0 := by rw [limsSup] - convert sInf_empty + convert! sInf_empty simpa [Set.eq_empty_iff_forall_notMem, IsBounded] using hf @[simp] @@ -40,7 +40,7 @@ lemma limsInf_of_not_isCobounded {f : Filter ℝ} (hf : ¬ f.IsCobounded (· ≥ @[simp] lemma limsInf_of_not_isBounded {f : Filter ℝ} (hf : ¬ f.IsBounded (· ≥ ·)) : limsInf f = 0 := by rw [limsInf] - convert sSup_empty + convert! sSup_empty simpa [Set.eq_empty_iff_forall_notMem, IsBounded] using hf @[simp] @@ -108,7 +108,7 @@ variable {ι : Type*} {f : Filter ι} {u : ι → ℝ≥0} @[simp] lemma limsSup_of_not_isBounded {f : Filter ℝ≥0} (hf : ¬ f.IsBounded (· ≤ ·)) : limsSup f = 0 := by rw [limsSup, ← bot_eq_zero] - convert sInf_empty + convert! sInf_empty simpa [Set.eq_empty_iff_forall_notMem, IsBounded] using hf @[simp] diff --git a/Mathlib/Order/Filter/Finite.lean b/Mathlib/Order/Filter/Finite.lean index 39e96ab7da3997..9a83bbff60523e 100644 --- a/Mathlib/Order/Filter/Finite.lean +++ b/Mathlib/Order/Filter/Finite.lean @@ -227,6 +227,18 @@ theorem iInf_principal_finite {ι : Type w} {s : Set ι} (hs : s.Finite) (f : ι lift s to Finset ι using hs exact mod_cast iInf_principal_finset s f +/-- If a filter has finitely many sets, then it is principal. -/ +theorem eq_principal_of_finite_sets (hf : f.sets.Finite) : ∃ s, f = 𝓟 s := by + use ⋂₀ f.sets + exact Filter.ext fun B ↦ ⟨sInter_subset_of_mem, mem_of_superset ((sInter_mem hf).2 (by simp))⟩ + +/-- Any filter on a finite type is principal. -/ +theorem eq_principal_of_finite [Finite α] (f : Filter α) : ∃ s, f = 𝓟 s := + eq_principal_of_finite_sets (finite_univ.powerset.subset (by simp)) + +theorem principal_surjective [Finite α] : Surjective (𝓟 : Set α → Filter α) := + fun f ↦ (eq_principal_of_finite f).imp fun _ ↦ .symm + end Lattice /-! ### Eventually and Frequently -/ diff --git a/Mathlib/Order/Filter/Germ/Basic.lean b/Mathlib/Order/Filter/Germ/Basic.lean index f9557801ceccda..7390a26c100c7e 100644 --- a/Mathlib/Order/Filter/Germ/Basic.lean +++ b/Mathlib/Order/Filter/Germ/Basic.lean @@ -252,10 +252,12 @@ theorem compTendsto'_coe (f : Germ l β) {lc : Filter γ} {g : γ → α} (hg : f.compTendsto' _ hg.germ_tendsto = f.compTendsto g hg := rfl -theorem Filter.Tendsto.congr_germ {f g : β → γ} {l : Filter α} {l' : Filter β} (h : f =ᶠ[l'] g) - {φ : α → β} (hφ : Tendsto φ l l') : (f ∘ φ : Germ l γ) = g ∘ φ := +theorem _root_.Filter.Tendsto.congr_germ {f g : β → γ} {l : Filter α} {l' : Filter β} + (h : f =ᶠ[l'] g) {φ : α → β} (hφ : Tendsto φ l l') : (f ∘ φ : Germ l γ) = g ∘ φ := EventuallyEq.germ_eq (h.comp_tendsto hφ) +@[deprecated (since := "2026-05-24")] alias Filter.Tendsto.congr_germ := Filter.Tendsto.congr_germ + lemma isConstant_comp_tendsto {lc : Filter γ} {g : γ → α} (hf : (f : Germ l β).IsConstant) (hg : Tendsto g lc l) : IsConstant (f ∘ g : Germ lc β) := by rcases hf with ⟨b, hb⟩ diff --git a/Mathlib/Order/Filter/Partial.lean b/Mathlib/Order/Filter/Partial.lean index a6fa69affb6448..1b50ff84afc531 100644 --- a/Mathlib/Order/Filter/Partial.lean +++ b/Mathlib/Order/Filter/Partial.lean @@ -64,7 +64,7 @@ def rmap (r : SetRel α β) (l : Filter α) : Filter β where sets_of_superset hs st := mem_of_superset hs (SetRel.core_mono st) inter_sets hs ht := by simp only [Set.mem_setOf_eq] - convert inter_mem hs ht + convert! inter_mem hs ht rw [← SetRel.core_inter] theorem rmap_sets (r : SetRel α β) (l : Filter α) : (l.rmap r).sets = r.core ⁻¹' l.sets := diff --git a/Mathlib/Order/Filter/Pointwise.lean b/Mathlib/Order/Filter/Pointwise.lean index 8d16d89bd46af0..bfe4f7a6c88cfa 100644 --- a/Mathlib/Order/Filter/Pointwise.lean +++ b/Mathlib/Order/Filter/Pointwise.lean @@ -1134,7 +1134,7 @@ theorem NeBot.zero_smul_nonneg (hg : g.NeBot) : 0 ≤ (0 : Filter α) • g := theorem zero_smul_filter_nonpos : (0 : α) • g ≤ 0 := by refine fun s hs => mem_smul_filter.2 ?_ - convert @univ_mem _ g + convert! @univ_mem _ g refine eq_univ_iff_forall.2 fun a => ?_ rwa [mem_preimage, zero_smul] diff --git a/Mathlib/Order/Filter/Prod.lean b/Mathlib/Order/Filter/Prod.lean index 36251aa68c6603..e068ba7e67dc21 100644 --- a/Mathlib/Order/Filter/Prod.lean +++ b/Mathlib/Order/Filter/Prod.lean @@ -501,7 +501,8 @@ theorem map_prodMap_coprod_le.{u, v, w, x} {α₁ : Type u} {α₂ : Type v} {β intro s simp only [mem_map, mem_coprod_iff] rintro ⟨⟨u₁, hu₁, h₁⟩, u₂, hu₂, h₂⟩ - refine ⟨⟨m₁ ⁻¹' u₁, hu₁, fun _ hx => h₁ ?_⟩, ⟨m₂ ⁻¹' u₂, hu₂, fun _ hx => h₂ ?_⟩⟩ <;> convert hx + refine ⟨⟨m₁ ⁻¹' u₁, hu₁, fun _ hx => h₁ ?_⟩, ⟨m₂ ⁻¹' u₂, hu₂, fun _ hx => h₂ ?_⟩⟩ <;> convert! + hx /-- Characterization of the coproduct of the `Filter.map`s of two principal filters `𝓟 {a}` and `𝓟 {i}`, the first under the constant function `fun a => b` and the second under the identity diff --git a/Mathlib/Order/Filter/SmallSets.lean b/Mathlib/Order/Filter/SmallSets.lean index 1af9ebe8b506cb..41b1ae5bc04991 100644 --- a/Mathlib/Order/Filter/SmallSets.lean +++ b/Mathlib/Order/Filter/SmallSets.lean @@ -104,7 +104,7 @@ theorem frequently_smallSets_mem (l : Filter α) : ∃ᶠ s in l.smallSets, s theorem frequently_smallSets' {α : Type*} {l : Filter α} {p : Set α → Prop} (hp : ∀ ⦃s t : Set α⦄, s ⊆ t → p s → p t) : (∃ᶠ s in l.smallSets, p s) ↔ ∀ t ∈ l, p t := by - convert not_iff_not.mpr <| l.eventually_smallSets' (p := (¬ p ·)) (by tauto) + convert! not_iff_not.mpr <| l.eventually_smallSets' (p := (¬p ·)) (by tauto) simp theorem HasBasis.frequently_smallSets {α : Type*} {ι : Sort*} {p : ι → Prop} {l : Filter α} diff --git a/Mathlib/Order/Filter/Ultrafilter/Basic.lean b/Mathlib/Order/Filter/Ultrafilter/Basic.lean index 14a988bb639b12..43971b62f5fbe5 100644 --- a/Mathlib/Order/Filter/Ultrafilter/Basic.lean +++ b/Mathlib/Order/Filter/Ultrafilter/Basic.lean @@ -42,7 +42,7 @@ theorem finite_biUnion_mem_iff {is : Set β} {s : β → Set α} (his : is.Finit lemma eventually_exists_mem_iff {is : Set β} {P : β → α → Prop} (his : is.Finite) : (∀ᶠ i in f, ∃ a ∈ is, P a i) ↔ ∃ a ∈ is, ∀ᶠ i in f, P a i := by simp only [Filter.Eventually, Ultrafilter.mem_coe] - convert f.finite_biUnion_mem_iff his (s := P) with i + convert! f.finite_biUnion_mem_iff his (s := P) with i aesop lemma eventually_exists_iff [Finite β] {P : β → α → Prop} : diff --git a/Mathlib/Order/Filter/ZeroAndBoundedAtFilter.lean b/Mathlib/Order/Filter/ZeroAndBoundedAtFilter.lean index bd4c16d95c3ae6..1ead326c8e6afe 100644 --- a/Mathlib/Order/Filter/ZeroAndBoundedAtFilter.lean +++ b/Mathlib/Order/Filter/ZeroAndBoundedAtFilter.lean @@ -101,7 +101,7 @@ theorem BoundedAtFilter.smul nonrec theorem BoundedAtFilter.mul [SeminormedRing β] {l : Filter α} {f g : α → β} (hf : BoundedAtFilter l f) (hg : BoundedAtFilter l g) : BoundedAtFilter l (f * g) := by refine (hf.mul hg).trans ?_ - convert Asymptotics.isBigO_refl (E := ℝ) _ l + convert! Asymptotics.isBigO_refl (E := ℝ) _ l simp theorem ZeroAtFilter.mul_boundedAtFilter [SeminormedRing β] {l : Filter α} diff --git a/Mathlib/Order/Fin/Basic.lean b/Mathlib/Order/Fin/Basic.lean index d948b85721966c..84f14489c0d9eb 100644 --- a/Mathlib/Order/Fin/Basic.lean +++ b/Mathlib/Order/Fin/Basic.lean @@ -5,6 +5,7 @@ Authors: Robert Y. Lewis, Keeley Hoek -/ module +public import Mathlib.Algebra.Order.IsBotOne public import Mathlib.Data.Fin.Embedding public import Mathlib.Data.Fin.Rev public import Mathlib.Order.Hom.Basic @@ -70,7 +71,6 @@ instance instBoundedOrder [NeZero n] : BoundedOrder (Fin n) where instance instBiheytingAlgebra [NeZero n] : BiheytingAlgebra (Fin n) := LinearOrder.toBiheytingAlgebra (Fin n) - /- There is a slight asymmetry here, in the sense that `0` is of type `Fin n` when we have `[NeZero n]` whereas `last n` is of type `Fin (n + 1)`. To address this properly would require a change to std4, defining `NeZero n` and thus re-defining `last n` @@ -90,9 +90,13 @@ instance instCoheytingAlgebra [NeZero n] : CoheytingAlgebra (Fin n) := inferInst /-! ### Miscellaneous lemmas -/ -lemma top_eq_last (n : ℕ) : ⊤ = Fin.last n := rfl +instance [NeZero n] : IsBotZeroClass (Fin n) where + isBot_zero := isBot_bot -lemma bot_eq_zero (n : ℕ) [NeZero n] : ⊥ = (0 : Fin n) := rfl +@[deprecated _root_.bot_eq_zero (since := "2026-05-07")] +protected lemma bot_eq_zero (n : ℕ) [NeZero n] : ⊥ = (0 : Fin n) := _root_.bot_eq_zero + +lemma top_eq_last (n : ℕ) : ⊤ = Fin.last n := rfl @[simp] theorem rev_bot [NeZero n] : rev (⊥ : Fin n) = ⊤ := rfl @[simp] theorem rev_top [NeZero n] : rev (⊤ : Fin n) = ⊥ := rev_rev _ diff --git a/Mathlib/Order/Grade.lean b/Mathlib/Order/Grade.lean index 77331441610402..7a44f911207101 100644 --- a/Mathlib/Order/Grade.lean +++ b/Mathlib/Order/Grade.lean @@ -312,7 +312,7 @@ abbrev GradeMinOrder.finToNat (n : ℕ) [GradeMinOrder (Fin n) α] : GradeMinOrd (GradeMinOrder.liftLeft (_ : Fin n → ℕ) Fin.val_strictMono fun _ _ => CovBy.coe_fin) fun a h => by cases n · exact a.elim0 - rw [h.eq_bot, Fin.bot_eq_zero] + rw [h.eq_bot, bot_eq_zero] exact isMin_bot instance GradeOrder.natToInt [GradeOrder ℕ α] : GradeOrder ℤ α := diff --git a/Mathlib/Order/Height.lean b/Mathlib/Order/Height.lean index 761d8bcca47cd9..0436ec08dcce35 100644 --- a/Mathlib/Order/Height.lean +++ b/Mathlib/Order/Height.lean @@ -120,7 +120,7 @@ theorem one_le_chainHeight_iff : 1 ≤ s.chainHeight r ↔ s.Nonempty := by all_goals · intros by_contra! hh - simp_all [lt_one_iff_eq_zero] + simp_all @[simp] theorem chainHeight_of_isEmpty [IsEmpty α] : s.chainHeight r = 0 := diff --git a/Mathlib/Order/Hom/Basic.lean b/Mathlib/Order/Hom/Basic.lean index ee9ea3256f292b..e2b2ed52abb9a1 100644 --- a/Mathlib/Order/Hom/Basic.lean +++ b/Mathlib/Order/Hom/Basic.lean @@ -189,7 +189,7 @@ variable [LE α] [LE β] [EquivLike F α β] [OrderIsoClass F α β] @[to_dual (attr := simp) le_map_inv_iff] theorem map_inv_le_iff (f : F) {a : α} {b : β} : EquivLike.inv f b ≤ a ↔ b ≤ f a := by - convert (map_le_map_iff f).symm + convert! (map_le_map_iff f).symm exact (EquivLike.right_inv f _).symm @[to_dual self] @@ -1068,7 +1068,7 @@ def ofCmpEqCmp {α β} [LinearOrder α] [LinearOrder β] (f : α → β) (g : β map_rel_iff' := by intro a b apply le_iff_le_of_cmp_eq_cmp - convert (h a (f b)).symm + convert! (h a (f b)).symm apply gf } /-- To show that `f : α →o β` and `g : β →o α` make up an order isomorphism it is enough to show diff --git a/Mathlib/Order/Interval/Finset/Defs.lean b/Mathlib/Order/Interval/Finset/Defs.lean index 911b7a147d1a6b..6a0024141b5cd5 100644 --- a/Mathlib/Order/Interval/Finset/Defs.lean +++ b/Mathlib/Order/Interval/Finset/Defs.lean @@ -330,17 +330,17 @@ theorem coe_Ico (a b : α) : (Ico a b : Set α) = Set.Ico a b := theorem coe_Ioo (a b : α) : (Ioo a b : Set α) = Set.Ioo a b := Set.ext fun _ => mem_Ioo -@[simp, to_dual self] +@[to_dual self] theorem _root_.Fintype.card_Icc (a b : α) [Fintype (Set.Icc a b)] : Fintype.card (Set.Icc a b) = #(Icc a b) := Fintype.card_of_finset' _ fun _ ↦ by simp -@[to_dual (reorder := a b) (attr := simp)] +@[to_dual (reorder := a b)] theorem _root_.Fintype.card_Ico (a b : α) [Fintype (Set.Ico a b)] : Fintype.card (Set.Ico a b) = #(Ico a b) := Fintype.card_of_finset' _ fun _ ↦ by simp -@[simp, to_dual self] +@[to_dual self] theorem _root_.Fintype.card_Ioo (a b : α) [Fintype (Set.Ioo a b)] : Fintype.card (Set.Ioo a b) = #(Ioo a b) := Fintype.card_of_finset' _ fun _ ↦ by simp @@ -379,12 +379,12 @@ theorem coe_Ici (a : α) : (Ici a : Set α) = Set.Ici a := theorem coe_Ioi (a : α) : (Ioi a : Set α) = Set.Ioi a := Set.ext fun _ => mem_Ioi -@[to_dual (attr := simp)] +@[to_dual] theorem _root_.Fintype.card_Ici (a : α) [Fintype (Set.Ici a)] : Fintype.card (Set.Ici a) = #(Ici a) := Fintype.card_of_finset' _ fun _ ↦ by simp -@[to_dual (attr := simp)] +@[to_dual] theorem _root_.Fintype.card_Ioi (a : α) [Fintype (Set.Ioi a)] : Fintype.card (Set.Ioi a) = #(Ioi a) := Fintype.card_of_finset' _ fun _ ↦ by simp @@ -437,7 +437,6 @@ theorem mem_uIcc : x ∈ uIcc a b ↔ a ⊓ b ≤ x ∧ x ≤ a ⊔ b := theorem coe_uIcc (a b : α) : (Finset.uIcc a b : Set α) = Set.uIcc a b := coe_Icc _ _ -@[simp] theorem _root_.Fintype.card_uIcc (a b : α) [Fintype (Set.uIcc a b)] : Fintype.card (Set.uIcc a b) = #(uIcc a b) := Fintype.card_of_finset' _ fun _ ↦ by simp [Set.uIcc] diff --git a/Mathlib/Order/Interval/Finset/Gaps.lean b/Mathlib/Order/Interval/Finset/Gaps.lean index 822123c9bad279..921d06491ca0b7 100644 --- a/Mathlib/Order/Interval/Finset/Gaps.lean +++ b/Mathlib/Order/Interval/Finset/Gaps.lean @@ -78,7 +78,7 @@ theorem intervalGapsWithin_succ_fst_of_lt (hj : j < k) : theorem intervalGapsWithin_fst_of_lt_lt (hj₁ : 0 < j) (hj₂ : j - 1 < k) : (F.intervalGapsWithin h a b j).1 = (F.orderEmbOfFin (α := α ×ₗ α) h ⟨j - 1, hj₂⟩).2 := by - convert F.intervalGapsWithin_succ_fst_of_lt h a b (j - 1) hj₂ + convert! F.intervalGapsWithin_succ_fst_of_lt h a b (j - 1) hj₂ omega @[simp] @@ -101,7 +101,7 @@ theorem intervalGapsWithin_mapsTo : (Set.Iio k).MapsTo rw [mem_Iio] at hj simp only [intervalGapsWithin_snd_of_lt, intervalGapsWithin_succ_fst_of_lt, Prod.mk.eta, SetLike.mem_coe, hj] - convert F.orderEmbOfFin_mem h ⟨j, hj⟩ using 1 + convert! F.orderEmbOfFin_mem h ⟨j, hj⟩ using 1 theorem intervalGapsWithin_injOn : (Set.Iio k).InjOn (fun (j : ℕ) ↦ ((F.intervalGapsWithin h a b j).2, (F.intervalGapsWithin h a b j.succ).1)) := by @@ -147,7 +147,7 @@ theorem intervalGapsWithin_fst_le_snd {a b : α} (hab : a ≤ b) (hF : (SetLike.coe F).PairwiseDisjoint (fun z ↦ Set.Icc z.1 z.2)) : (F.intervalGapsWithin h a b j).1 ≤ (F.intervalGapsWithin h a b j).2 := by wlog hj : j < k + 1 generalizing j - · convert this (j : Fin (k + 1)) (by grind) using 3 <;> grind [cast_val_eq_self] + · convert! this (j : Fin (k + 1)) (by grind) using 3 <;> grind [cast_val_eq_self] by_cases hj₁ : j = 0 · simp only [hj₁] by_cases hk : 0 = k @@ -157,8 +157,7 @@ theorem intervalGapsWithin_fst_le_snd {a b : α} (hab : a ≤ b) have hk : k - 1 + 1 = k := by omega by_cases hj₂ : j = k · simp only [hj₂, natCast_eq_last, intervalGapsWithin_last_snd, ge_iff_le] - convert hFab (F.intervalGapsWithin_mapsTo h a b (x := j - 1) (by grind)) |>.right.right - using 1 + convert! hFab (F.intervalGapsWithin_mapsTo h a b (x := j - 1) (by grind)) |>.right.right using 1 simp [hj₂, hk] rw [intervalGapsWithin_fst_of_lt_lt (hj₁ := by omega) (hj₂ := by omega), intervalGapsWithin_snd_of_lt (hj := by omega)] diff --git a/Mathlib/Order/Interval/Finset/Nat.lean b/Mathlib/Order/Interval/Finset/Nat.lean index ae335b6fc60d68..1430402996192c 100644 --- a/Mathlib/Order/Interval/Finset/Nat.lean +++ b/Mathlib/Order/Interval/Finset/Nat.lean @@ -197,7 +197,7 @@ open Multiset theorem multiset_Ico_map_mod (n a : ℕ) : (Multiset.Ico n (n + a)).map (· % a) = Multiset.range a := by - convert congr_arg Finset.val (image_Ico_mod n a) + convert! congr_arg Finset.val (image_Ico_mod n a) refine ((nodup_map_iff_inj_on (Finset.Ico _ _).nodup).2 <| ?_).dedup.symm exact mod_injOn_Ico _ _ @@ -232,7 +232,7 @@ theorem range_image_pred_top_sub (n : ℕ) : theorem range_add_eq_union : range (a + b) = range a ∪ (range b).map (addLeftEmbedding a) := by simp_rw [Finset.range_eq_Ico, map_eq_image] - convert (Ico_union_Ico_eq_Ico a.zero_le (a.le_add_right b)).symm + convert! (Ico_union_Ico_eq_Ico a.zero_le (a.le_add_right b)).symm ext x simp only [Ico_zero_eq_range, mem_image, mem_range, addLeftEmbedding_apply, mem_Ico] constructor @@ -284,7 +284,7 @@ theorem Nat.cauchy_induction_mul (h : ∀ (n : ℕ), P (n + 1) → P n) (k seed (hs : P seed.succ) (hm : ∀ x, seed < x → P x → P (k * x)) (n : ℕ) : P n := by apply Nat.cauchy_induction h _ hs (k * ·) fun x hl hP => ⟨_, hm x hl hP⟩ intro _ hl _ - convert (Nat.mul_lt_mul_right <| seed.succ_pos.trans_le hl).2 hk + convert! (Nat.mul_lt_mul_right <| seed.succ_pos.trans_le hl).2 hk rw [one_mul] theorem Nat.cauchy_induction_two_mul (h : ∀ n, P (n + 1) → P n) (seed : ℕ) (hs : P seed.succ) diff --git a/Mathlib/Order/Interval/Set/Basic.lean b/Mathlib/Order/Interval/Set/Basic.lean index 98c6874023d414..fb6b4ec90b2c7c 100644 --- a/Mathlib/Order/Interval/Set/Basic.lean +++ b/Mathlib/Order/Interval/Set/Basic.lean @@ -188,9 +188,13 @@ theorem nonempty_Ioc_subtype (h : a < b) : Nonempty (Ioc a b) := theorem nonempty_Ioo_subtype [DenselyOrdered α] (h : a < b) : Nonempty (Ioo a b) := Nonempty.to_subtype (nonempty_Ioo.mpr h) +@[to_additive (attr := simp)] +theorem Iio_one_eq_empty [One α] [IsBotOneClass α] : Set.Iio (1 : α) = ∅ := by + ext; simp + @[to_additive] -instance isEmpty_Iio_one [One α] [IsBotOneClass α] : IsEmpty (Set.Iio (1 : α)) := - ⟨fun a ↦ not_lt_one a.2⟩ +instance isEmpty_Iio_one [One α] [IsBotOneClass α] : IsEmpty (Set.Iio (1 : α)) := by + simp @[to_dual] instance [NoMinOrder α] : NoMinOrder (Iio a) := diff --git a/Mathlib/Order/Interval/Set/LinearOrder.lean b/Mathlib/Order/Interval/Set/LinearOrder.lean index fb80627759f72c..8f3a7deda88e1f 100644 --- a/Mathlib/Order/Interval/Set/LinearOrder.lean +++ b/Mathlib/Order/Interval/Set/LinearOrder.lean @@ -67,7 +67,7 @@ theorem Ico_subset_Ico_iff (h₁ : a₁ < b₁) : Ico a₁ b₁ ⊆ Ico a₂ b fun ⟨h₁, h₂⟩ => Ico_subset_Ico h₁ h₂⟩ theorem Ioc_subset_Ioc_iff (h₁ : a₁ < b₁) : Ioc a₁ b₁ ⊆ Ioc a₂ b₂ ↔ b₁ ≤ b₂ ∧ a₂ ≤ a₁ := by - convert @Ico_subset_Ico_iff αᵒᵈ _ b₁ b₂ a₁ a₂ h₁ using 2 <;> exact (@Ico_toDual α _ _ _).symm + convert! @Ico_subset_Ico_iff αᵒᵈ _ b₁ b₂ a₁ a₂ h₁ using 2 <;> exact (@Ico_toDual α _ _ _).symm theorem Ico_eq_Ico_iff (h : a < b ∨ c < d) : Ico a b = Ico c d ↔ a = c ∧ b = d := by refine ⟨fun h ↦ ?_, by grind⟩ diff --git a/Mathlib/Order/IsNormal.lean b/Mathlib/Order/IsNormal.lean index df523f0f92b52c..c690cd0d653863 100644 --- a/Mathlib/Order/IsNormal.lean +++ b/Mathlib/Order/IsNormal.lean @@ -128,7 +128,7 @@ theorem map_sSup (hf : IsNormal f) {s : Set α} (hs : s.Nonempty) (hs' : BddAbov theorem map_iSup {ι} [Nonempty ι] {g : ι → α} (hf : IsNormal f) (hg : BddAbove (range g)) : f (⨆ i, g i) = ⨆ i, f (g i) := by unfold iSup - convert map_sSup hf (range_nonempty g) hg + convert! map_sSup hf (range_nonempty g) hg ext simp @@ -174,7 +174,7 @@ variable [ConditionallyCompleteLinearOrderBot α] [ConditionallyCompleteLinearOr theorem apply_of_isSuccLimit (hf : IsNormal f) (ha : IsSuccLimit a) : f a = ⨆ b : Iio a, f b := by - convert map_iSup hf _ + convert! map_iSup hf _ · exact ha.iSup_Iio.symm · exact ⟨⊥, ha.bot_lt⟩ · use a @@ -214,7 +214,7 @@ theorem ext_iff [OrderBot α] {g : α → β} (hf : IsNormal f) (hg : IsNormal g | succ a ha IH => exact H₂ a IH | isSuccLimit a ha IH => apply (hf.isLUB_image_Iio_of_isSuccLimit ha).unique - convert hg.isLUB_image_Iio_of_isSuccLimit ha using 1 + convert! hg.isLUB_image_Iio_of_isSuccLimit ha using 1 aesop @[deprecated (since := "2026-03-22")] protected alias ext := IsNormal.ext_iff diff --git a/Mathlib/Order/JordanHolder.lean b/Mathlib/Order/JordanHolder.lean index 386ead23f835e6..68e4129d5e103f 100644 --- a/Mathlib/Order/JordanHolder.lean +++ b/Mathlib/Order/JordanHolder.lean @@ -225,7 +225,7 @@ theorem isMaximal_eraseLast_last {s : CompositionSeries X} (h : 0 < s.length) : rw [last_eraseLast, last] have := s.step ⟨s.length - 1, by lia⟩ simp only [Fin.castSucc_mk, Fin.succ_mk, mem_setOf_eq] at this - convert this using 3 + convert! this using 3 exact (tsub_add_cancel_of_le h).symm theorem eq_snoc_eraseLast {s : CompositionSeries X} (h : 0 < s.length) : diff --git a/Mathlib/Order/KonigLemma.lean b/Mathlib/Order/KonigLemma.lean index 92715e3acab857..a3817edf8f0d0b 100644 --- a/Mathlib/Order/KonigLemma.lean +++ b/Mathlib/Order/KonigLemma.lean @@ -149,7 +149,7 @@ theorem exists_seq_forall_proj_of_forall_finite {α : ℕ → Type*} [Finite (α have hr : ∀ i, (f i).1 = i := Nat.rec (by rw [hf0, ha₀]) (fun i ih ↦ by rw [← (hcovby.1 (hf i)).2, ih]) refine ⟨fun i ↦ by rw [← hr i]; exact (f i).2, fun i j hij ↦ ?_⟩ - convert (f.monotone hij).2 <;> + convert! (f.monotone hij).2 <;> simp [hr] end Graded diff --git a/Mathlib/Order/KrullDimension.lean b/Mathlib/Order/KrullDimension.lean index 18591ad64e251a..f30bd8ba15a6d6 100644 --- a/Mathlib/Order/KrullDimension.lean +++ b/Mathlib/Order/KrullDimension.lean @@ -198,13 +198,13 @@ lemma length_le_height {p : LTSeries α} {x : α} (hlast : p.last ≤ x) : · let p' := p.eraseLast.snoc x (by apply lt_of_lt_of_le · apply p.step ⟨p.length - 1, by lia⟩ - · convert hlast + · convert! hlast simp only [Fin.succ_mk, RelSeries.last, Fin.last] congr; lia) suffices p'.length ≤ height x by simp only [RelSeries.snoc_length, RelSeries.eraseLast_length, Nat.cast_add, ENat.coe_sub, Nat.cast_one, p'] at this - convert this + convert! this norm_cast lia refine le_iSup₂_of_le p' ?_ le_rfl @@ -456,7 +456,7 @@ element. -/ lemma coheight_eq_top_iff {x : α} : coheight x = ⊤ ↔ ∀ n, ∃ p : LTSeries α, p.head = x ∧ p.length = n := by - convert height_eq_top_iff (α := αᵒᵈ) (x := x) using 2 with n + convert! height_eq_top_iff (α := αᵒᵈ) (x := x) using 2 with n constructor <;> (intro ⟨p, hp, hl⟩; use p.reverse; constructor <;> simpa) /-- The elements of height zero are the minimal elements. -/ diff --git a/Mathlib/Order/Minimal.lean b/Mathlib/Order/Minimal.lean index 29808e0fb325f4..7257dc28c52193 100644 --- a/Mathlib/Order/Minimal.lean +++ b/Mathlib/Order/Minimal.lean @@ -514,7 +514,7 @@ namespace OrderIso @[to_dual] theorem image_setOf_minimal (f : α ≃o β) (P : α → Prop) : f '' {x | Minimal P x} = {x | Minimal (fun x ↦ P (f.symm x)) x} := by - convert _root_.image_monotone_setOf_minimal (f := f) (by simp [f.le_iff_le]) + convert! _root_.image_monotone_setOf_minimal (f := f) (by simp [f.le_iff_le]) aesop @[to_dual] diff --git a/Mathlib/Order/Monotone/MonovaryOrder.lean b/Mathlib/Order/Monotone/MonovaryOrder.lean index 415231ef56917d..9f5841320901e2 100644 --- a/Mathlib/Order/Monotone/MonovaryOrder.lean +++ b/Mathlib/Order/Monotone/MonovaryOrder.lean @@ -32,7 +32,7 @@ def MonovaryOrder (i j : ι) : Prop := instance : IsStrictTotalOrder ι (MonovaryOrder f g) where toTrichotomous := Std.trichotomous_of_rel_or_eq_or_rel_swap fun {a b} ↦ by - convert trichotomous_of (Prod.Lex (· < ·) <| Prod.Lex (· < ·) WellOrderingRel) _ _ + convert! trichotomous_of (Prod.Lex (· < ·) <| Prod.Lex (· < ·) WellOrderingRel) _ _ · simp only [Prod.ext_iff, ← and_assoc, imp_and, iff_and_self] exact ⟨congr_arg _, congr_arg _⟩ · infer_instance diff --git a/Mathlib/Order/OmegaCompletePartialOrder.lean b/Mathlib/Order/OmegaCompletePartialOrder.lean index 223e7b02ac66c9..6ce92605a5d426 100644 --- a/Mathlib/Order/OmegaCompletePartialOrder.lean +++ b/Mathlib/Order/OmegaCompletePartialOrder.lean @@ -286,7 +286,7 @@ lemma ωScottContinuous_iff_monotone_map_ωSup : ωScottContinuous f ↔ ∃ hf : Monotone f, ∀ c : Chain α, f (ωSup c) = ωSup (c.map ⟨f, hf⟩) := by refine ⟨fun hf ↦ ⟨hf.monotone, hf.map_ωSup⟩, ?_⟩ intro hf _ ⟨c, hc⟩ _ _ _ hda - convert isLUB_range_ωSup (c.map { toFun := f, monotone' := hf.1 }) + convert! isLUB_range_ωSup (c.map { toFun := f, monotone' := hf.1 }) · simp [← hc, ← (Set.range_comp f ⇑c)] · rw [← hc] at hda rw [← hf.2 c, ωSup_eq_of_isLUB hda] diff --git a/Mathlib/Order/OrderDual.lean b/Mathlib/Order/OrderDual.lean index 6262bd76540bff..5526530a62c3c4 100644 --- a/Mathlib/Order/OrderDual.lean +++ b/Mathlib/Order/OrderDual.lean @@ -187,7 +187,7 @@ instance OrderDual.denselyOrdered (α : Type*) [LT α] [h : DenselyOrdered α] : @[simp] theorem denselyOrdered_orderDual [LT α] : DenselyOrdered αᵒᵈ ↔ DenselyOrdered α := - ⟨by convert @OrderDual.denselyOrdered αᵒᵈ _, @OrderDual.denselyOrdered α _⟩ + ⟨by convert! @OrderDual.denselyOrdered αᵒᵈ _, @OrderDual.denselyOrdered α _⟩ /-! ### Pushing order definitions through `Equiv` -/ diff --git a/Mathlib/Order/OrderIsoNat.lean b/Mathlib/Order/OrderIsoNat.lean index a8112739cb289f..aeb157c2b355e4 100644 --- a/Mathlib/Order/OrderIsoNat.lean +++ b/Mathlib/Order/OrderIsoNat.lean @@ -166,7 +166,7 @@ theorem exists_increasing_or_nonincreasing_subseq' (r : α → α → Prop) (f : simp only [bad, exists_prop, not_not, Set.mem_setOf_eq, not_forall] at h obtain ⟨n', hn1, hn2⟩ := h refine ⟨n + n' - n - m, by lia, ?_⟩ - convert hn2 + convert! hn2 lia let g' : ℕ → ℕ := @Nat.rec (fun _ => ℕ) m fun n gn => Nat.find (h gn) exact diff --git a/Mathlib/Order/PartialSups.lean b/Mathlib/Order/PartialSups.lean index bc7425cb3c2e2d..a004355c112736 100644 --- a/Mathlib/Order/PartialSups.lean +++ b/Mathlib/Order/PartialSups.lean @@ -119,10 +119,10 @@ lemma partialSups_monotone (f : ι → α) : def partialSups.gi : GaloisInsertion (partialSups : (ι → α) → ι →o α) (↑) where choice f h := - ⟨f, by convert (partialSups f).monotone using 1; exact (le_partialSups f).antisymm h⟩ + ⟨f, by convert! (partialSups f).monotone using 1; exact (le_partialSups f).antisymm h⟩ gc f g := by refine ⟨(le_partialSups f).trans, fun h ↦ ?_⟩ - convert partialSups_mono h + convert! partialSups_mono h exact OrderHom.ext _ _ g.monotone.partialSups_eq.symm le_l_u f := le_partialSups f choice_eq f h := OrderHom.ext _ _ ((le_partialSups f).antisymm h) diff --git a/Mathlib/Order/Partition/Finpartition.lean b/Mathlib/Order/Partition/Finpartition.lean index 467bb5a44a75b6..0fc8a2a365f444 100644 --- a/Mathlib/Order/Partition/Finpartition.lean +++ b/Mathlib/Order/Partition/Finpartition.lean @@ -141,13 +141,13 @@ def map {β : Type*} [Lattice β] [OrderBot β] {a : α} (e : α ≃o β) (P : F have := P.supIndep hu hb (by simp [hbu]) (map_rel e.symm hx) ?_ · rw [← e.symm.map_bot] at this exact e.symm.map_rel_iff.mp this - · convert e.symm.map_rel_iff.mpr hxu + · convert! e.symm.map_rel_iff.mpr hxu rw [map_finset_sup, sup_map] rfl sup_parts := by simp [← P.sup_parts] bot_notMem := by rw [mem_map_equiv] - convert P.bot_notMem + convert! P.bot_notMem exact e.symm.map_bot @[simp] @@ -739,7 +739,7 @@ lemma exists_enumeration : ∃ f : s ≃ Σ t : P.parts, Fin #t.1, simp [equivSigmaParts, Equiv.sigmaCongr, Equiv.sigmaCongrLeft] theorem sum_card_parts : ∑ i ∈ P.parts, #i = #s := by - convert congr_arg Finset.card P.biUnion_parts + convert! congr_arg Finset.card P.biUnion_parts rw [card_biUnion P.supIndep.pairwiseDisjoint] rfl diff --git a/Mathlib/Order/RelSeries.lean b/Mathlib/Order/RelSeries.lean index 14132caa579bd6..9bb0aaf8eac96b 100644 --- a/Mathlib/Order/RelSeries.lean +++ b/Mathlib/Order/RelSeries.lean @@ -108,7 +108,7 @@ lemma toList_singleton (x : α) : (singleton r x).toList = [x] := by simp [toLis lemma isChain_toList (x : RelSeries r) : x.toList.IsChain (· ~[r] ·) := by simp_rw [List.isChain_iff_getElem, length_toList, add_lt_add_iff_right] intro i h - convert x.step ⟨i, by simpa [toList] using h⟩ <;> apply List.get_ofFn + convert! x.step ⟨i, by simpa [toList] using h⟩ <;> apply List.get_ofFn lemma toList_ne_nil (x : RelSeries r) : x.toList ≠ [] := fun m => List.eq_nil_iff_forall_not_mem.mp m (x 0) <| List.mem_ofFn.mpr ⟨_, rfl⟩ @@ -210,7 +210,7 @@ theorem length_ne_zero [r.IsIrrefl] : s.length ≠ 0 ↔ {x | x ∈ s}.Nontrivia refine ⟨fun h ↦ ⟨s 0, by simp [mem_def], s 1, by simp [mem_def], fun rid ↦ r.irrefl (s 0) ?_⟩, length_ne_zero_of_nontrivial⟩ nth_rw 2 [rid] - convert s.step ⟨0, by lia⟩ + convert! s.step ⟨0, by lia⟩ ext simpa [Nat.pos_iff_ne_zero] @@ -296,10 +296,10 @@ def append (p q : RelSeries r) (connect : p.last ~[r] q.head) : RelSeries r wher step i := by obtain hi | rfl | hi := lt_trichotomy i (Fin.castLE (by lia) (Fin.last _ : Fin (p.length + 1))) - · convert p.step ⟨i.1, hi⟩ <;> convert Fin.append_left p q _ <;> rfl - · convert connect - · convert Fin.append_left p q _ - · convert Fin.append_right p q _; rfl + · convert! p.step ⟨i.1, hi⟩ <;> convert! Fin.append_left p q _ <;> rfl + · convert! connect + · convert! Fin.append_left p q _ + · convert! Fin.append_right p q _; rfl · set x := _; set y := _ change Fin.append p q x ~[r] Fin.append p q y have hx : x = Fin.natAdd _ ⟨i - (p.length + 1), Nat.sub_lt_left_of_lt_add hi <| @@ -313,7 +313,7 @@ def append (p q : RelSeries r) (connect : p.last ~[r] q.head) : RelSeries r wher Nat.add_sub_cancel' <| le_of_lt (show p.length < i.1 from hi), add_comm] rfl rw [hx, Fin.append_right, hy, Fin.append_right] - convert q.step ⟨i - (p.length + 1), Nat.sub_lt_left_of_lt_add hi <| by lia⟩ + convert! q.step ⟨i - (p.length + 1), Nat.sub_lt_left_of_lt_add hi <| by lia⟩ rw [Fin.succ_mk, Nat.sub_eq_iff_eq_add (le_of_lt hi : p.length ≤ i), Nat.add_assoc _ 1, add_comm 1, Nat.sub_add_cancel] exact hi @@ -325,7 +325,7 @@ lemma append_apply_left (p q : RelSeries r) (connect : p.last ~[r] q.head) = p i := by delta append simp only [Function.comp_apply] - convert Fin.append_left _ _ _ + convert! Fin.append_left _ _ _ lemma append_apply_right (p q : RelSeries r) (connect : p.last ~[r] q.head) (i : Fin (q.length + 1)) : @@ -341,7 +341,7 @@ lemma append_apply_right (p q : RelSeries r) (connect : p.last ~[r] q.head) @[simp] lemma last_append (p q : RelSeries r) (connect : p.last ~[r] q.head) : (p.append q connect).last = q.last := by delta last - convert append_apply_right p q connect (Fin.last _) + convert! append_apply_right p q connect (Fin.last _) ext1 dsimp lia @@ -391,7 +391,7 @@ def insertNth (p : RelSeries r) (i : Fin p.length) (a : α) step m := by set x := _; set y := _; change x ~[r] y obtain hm | hm | hm := lt_trichotomy m.1 i.1 - · convert p.step ⟨m, hm.trans i.2⟩ + · convert! p.step ⟨m, hm.trans i.2⟩ · change Fin.insertNth _ _ _ _ = _ rw [Fin.insertNth_apply_below] pick_goal 2 @@ -407,14 +407,14 @@ def insertNth (p : RelSeries r) (i : Fin p.length) (a : α) pick_goal 2 · change m.1 < i.1 + 1; exact hm ▸ lt_add_one _ simp] - convert prev_connect + convert! prev_connect · ext; exact hm · change Fin.insertNth _ _ _ _ = _ rw [show m.succ = i.succ.castSucc by ext; change _ + 1 = _ + 1; rw [hm], Fin.insertNth_apply_same] · rw [Nat.lt_iff_add_one_le, le_iff_lt_or_eq] at hm obtain hm | hm := hm - · convert p.step ⟨m.1 - 1, Nat.sub_lt_right_of_lt_add (by lia) m.2⟩ + · convert! p.step ⟨m.1 - 1, Nat.sub_lt_right_of_lt_add (by lia) m.2⟩ · change Fin.insertNth _ _ _ _ = _ rw [Fin.insertNth_apply_above (h := hm)] aesop @@ -425,7 +425,7 @@ def insertNth (p : RelSeries r) (i : Fin p.length) (a : α) simp only [Fin.pred_succ, eq_rec_constant, Fin.succ_mk] congr exact Fin.ext <| Eq.symm <| Nat.succ_pred_eq_of_pos (lt_trans (Nat.zero_lt_succ _) hm) - · convert connect_next + · convert! connect_next · change Fin.insertNth _ _ _ _ = _ rw [show m.castSucc = i.succ.castSucc from Fin.ext hm.symm, Fin.insertNth_apply_same] · change Fin.insertNth _ _ _ _ = _ @@ -446,7 +446,7 @@ def reverse (p : RelSeries r) : RelSeries r.inv where step i := by rw [Function.comp_apply, Function.comp_apply, SetRel.mem_inv] have hi : i.1 + 1 ≤ p.length := by lia - convert p.step ⟨p.length - (i.1 + 1), Nat.sub_lt_self (by lia) hi⟩ + convert! p.step ⟨p.length - (i.1 + 1), Nat.sub_lt_self (by lia) hi⟩ · ext; simp · ext simp only [Fin.val_rev, Fin.val_castSucc, Fin.val_succ] @@ -610,15 +610,16 @@ def inductionOn (motive : RelSeries r → Sort*) let this {n : ℕ} (heq : p.length = n) : motive p := by induction n generalizing p with | zero => - convert singleton p.head + convert! singleton p.head ext n · exact heq simp [show n = 0 by lia, apply_zero] | succ d hd => have lq := p.tail_length (heq ▸ d.zero_ne_add_one.symm) nth_rw 3 [heq] at lq - convert cons (p.tail (heq ▸ d.zero_ne_add_one.symm)) p.head - (p.3 ⟨0, heq ▸ d.zero_lt_succ⟩) (hd _ lq) + convert! + cons (p.tail (heq ▸ d.zero_ne_add_one.symm)) p.head (p.3 ⟨0, heq ▸ d.zero_lt_succ⟩) + (hd _ lq) exact (p.cons_self_tail (heq ▸ d.zero_ne_add_one.symm)).symm exact this rfl @@ -645,7 +646,7 @@ def eraseLast (p : RelSeries r) : RelSeries r where lemma eraseLast_last_rel_last (p : RelSeries r) (h : p.length ≠ 0) : p.eraseLast.last ~[r] p.last := by simp only [last, Fin.last, eraseLast_length, eraseLast_toFun] - convert p.step ⟨p.length - 1, by lia⟩ + convert! p.step ⟨p.length - 1, by lia⟩ simp only [Fin.succ_mk]; lia @[simp] @@ -674,15 +675,14 @@ def inductionOn' (motive : RelSeries r → Sort*) let this {n : ℕ} (heq : p.length = n) : motive p := by induction n generalizing p with | zero => - convert singleton p.head + convert! singleton p.head ext n · exact heq · simp [show n = 0 by lia, apply_zero] | succ d hd => have ne0 : p.length ≠ 0 := by simp [heq] have len : p.eraseLast.length = d := by simp [heq] - convert snoc p.eraseLast p.last (p.eraseLast_last_rel_last ne0) - (hd _ len) + convert! snoc p.eraseLast p.last (p.eraseLast_last_rel_last ne0) (hd _ len) exact (p.snoc_self_eraseLast ne0).symm exact this rfl @@ -697,7 +697,7 @@ def smash (p q : RelSeries r) (connect : p.last = q.head) : RelSeries r where step := by apply Fin.addCases <;> intro i · simp_rw [Fin.castSucc_castAdd, Fin.addCases_left, Fin.succ_castAdd] - convert p.step i + convert! p.step i split_ifs with h · rw [Fin.addCases_right, h, ← last, connect, head] · apply Fin.addCases_left @@ -760,7 +760,7 @@ def drop (p : RelSeries r) (i : Fin (p.length + 1)) : RelSeries r where length := p.length - i toFun := fun ⟨j, h⟩ => p.toFun ⟨j+i, by lia⟩ step := fun ⟨j, h⟩ => by - convert p.step ⟨j+i.1, by lia⟩ + convert! p.step ⟨j + i.1, by lia⟩ simp only [Fin.succ_mk]; lia @[simp] @@ -987,8 +987,8 @@ theorem exists_relSeries_covBy obtain rfl : m = 0 := by simpa [t₃] using (congr_arg Fin.val eq).trans_lt (i j).2 cases (h (.last _)).ne' (h₂.symm.trans h₁) · refine funext (Fin.lastCases ?_ fun j ↦ ?_) - · convert h₂; simpa using RelSeries.last_smash .. - convert congr_fun ht j using 1 + · convert! h₂; simpa using RelSeries.last_smash .. + convert! congr_fun ht j using 1 simp [RelSeries.smash_castLE] all_goals simp [Fin.snoc, Fin.castPred_zero, hi₁] diff --git a/Mathlib/Order/ScottContinuity/Prod.lean b/Mathlib/Order/ScottContinuity/Prod.lean index bcafe902695ff0..9cf6a2830551bc 100644 --- a/Mathlib/Order/ScottContinuity/Prod.lean +++ b/Mathlib/Order/ScottContinuity/Prod.lean @@ -39,9 +39,9 @@ lemma ScottContinuousOn.fromProd [Preorder α] [Preorder β] [Preorder γ] rw [singleton_prod, image_image f (fun b ↦ (a, b))] exact h₁ _ (mem_image_of_mem (fun d ↦ Prod.snd '' d) hX) (Nonempty.image Prod.snd hd₁) (DirectedOn.snd hd₂) (isLUB_prod.mp hdp).2) _, Set.range] - convert (h₂ _ - (mem_image_of_mem (fun d ↦ Prod.fst '' d) hX) (Nonempty.image Prod.fst hd₁) (DirectedOn.fst hd₂) - (isLUB_prod.mp hdp).1) + convert! + (h₂ _ (mem_image_of_mem (fun d ↦ Prod.fst '' d) hX) (Nonempty.image Prod.fst hd₁) + (DirectedOn.fst hd₂) (isLUB_prod.mp hdp).1) ext : 1 simp_all only [Subtype.exists, mem_image, Prod.exists, exists_and_right, exists_eq_right, exists_prop, mem_setOf_eq] diff --git a/Mathlib/Order/SuccPred/Archimedean.lean b/Mathlib/Order/SuccPred/Archimedean.lean index d02c7abb73e983..c7d5e1091979b0 100644 --- a/Mathlib/Order/SuccPred/Archimedean.lean +++ b/Mathlib/Order/SuccPred/Archimedean.lean @@ -46,11 +46,11 @@ variable [Preorder α] -- `to_dual` cannot yet reorder arguments of arguments instance [SuccOrder α] [IsSuccArchimedean α] : IsPredArchimedean αᵒᵈ := - ⟨fun {a b} h => by convert exists_succ_iterate_of_le h.ofDual⟩ + ⟨fun {a b} h => by convert! exists_succ_iterate_of_le h.ofDual⟩ @[to_dual existing] instance [PredOrder α] [IsPredArchimedean α] : IsSuccArchimedean αᵒᵈ := - ⟨fun {a b} h => by convert exists_pred_iterate_of_le h.ofDual⟩ + ⟨fun {a b} h => by convert! exists_pred_iterate_of_le h.ofDual⟩ section SuccOrder diff --git a/Mathlib/Order/SupIndep.lean b/Mathlib/Order/SupIndep.lean index babe5b8e4aac5d..df95ae3e376f92 100644 --- a/Mathlib/Order/SupIndep.lean +++ b/Mathlib/Order/SupIndep.lean @@ -303,9 +303,9 @@ theorem sSupIndep_pair {a b : α} (hab : a ≠ b) : · intro h exact h.pairwiseDisjoint (mem_insert _ _) (mem_insert_of_mem _ (mem_singleton _)) hab · rintro h c ((rfl : c = a) | (rfl : c = b)) - · convert h using 1 + · convert! h using 1 simp [hab, sSup_singleton] - · convert h.symm using 1 + · convert! h.symm using 1 simp [hab, sSup_singleton] include hs in @@ -390,7 +390,7 @@ theorem iSupIndep_ne_bot : cases eq_or_ne (t i) ⊥ with | inl hi => simp [hi] | inr hi => ?_ - convert h ⟨i, hi⟩ + convert! h ⟨i, hi⟩ have : ∀ j, ⨆ (_ : t j = ⊥), t j = ⊥ := fun j ↦ by simp only [iSup_eq_bot, imp_self] rw [iSup_split _ (fun j ↦ t j = ⊥), iSup_subtype] simp only [iSup_comm (ι' := _ ≠ i), this, ne_eq, sup_of_le_right, Subtype.mk.injEq, iSup_bot, diff --git a/Mathlib/Order/SymmDiff.lean b/Mathlib/Order/SymmDiff.lean index ab24456c535fd1..63d6ff5603f02b 100644 --- a/Mathlib/Order/SymmDiff.lean +++ b/Mathlib/Order/SymmDiff.lean @@ -190,7 +190,7 @@ theorem symmDiff_triangle : a ∆ c ≤ a ∆ b ⊔ b ∆ c := by rw [sup_comm (c \ b), sup_sup_sup_comm, symmDiff, symmDiff] theorem le_symmDiff_sup_right (a b : α) : a ≤ (a ∆ b) ⊔ b := by - convert symmDiff_triangle a b ⊥ <;> rw [symmDiff_bot] + convert! symmDiff_triangle a b ⊥ <;> rw [symmDiff_bot] theorem le_symmDiff_sup_left (a b : α) : b ≤ (a ∆ b) ⊔ a := symmDiff_comm a b ▸ le_symmDiff_sup_right .. diff --git a/Mathlib/Order/UpperLower/Basic.lean b/Mathlib/Order/UpperLower/Basic.lean index 40edd3362a2d80..48c4788f45302f 100644 --- a/Mathlib/Order/UpperLower/Basic.lean +++ b/Mathlib/Order/UpperLower/Basic.lean @@ -47,7 +47,7 @@ theorem IsUpperSet.compl (hs : IsUpperSet s) : IsLowerSet sᶜ := fun _a _b h hb @[to_dual (attr := simp)] theorem isUpperSet_compl : IsUpperSet sᶜ ↔ IsLowerSet s := ⟨fun h => by - convert h.compl + convert! h.compl rw [compl_compl], IsLowerSet.compl⟩ @[to_dual] diff --git a/Mathlib/Order/WellFoundedSet.lean b/Mathlib/Order/WellFoundedSet.lean index a6494a349adfe4..62b5383d8a0248 100644 --- a/Mathlib/Order/WellFoundedSet.lean +++ b/Mathlib/Order/WellFoundedSet.lean @@ -559,6 +559,12 @@ lemma WellFoundedOn.mapsTo {α β : Type*} {r : α → α → Prop} (f : β → t.WellFoundedOn (r on f) := by exact InvImage.wf (fun x : t ↦ ⟨f x, h x.prop⟩) hw +@[to_dual] +theorem WellFoundedOn.exists_minimal {α : Type*} [Preorder α] {s : Set α} + (h : s.WellFoundedOn (· < ·)) (nonempty : s.Nonempty) : ∃ a, Minimal (· ∈ s) a := + have ⟨m, hm⟩ := WellFoundedLT.exists_minimal ⟨h⟩ univ <| nonempty.elim (⟨⟨·, ·⟩, trivial⟩) + ⟨m, m.property, fun y hy ↦ hm.right (y := ⟨y, hy⟩) trivial⟩ + end WellFoundedOn section LinearOrder @@ -788,7 +794,7 @@ noncomputable def minBadSeqOfBadSeq (r : α → α → Prop) (rk : α → ℕ) ( have h : ∃ (k : ℕ) (g : ℕ → α), (∀ m, m < n → f m = g m) ∧ IsBadSeq r s g ∧ rk (g n) = k := ⟨_, f, fun _ _ => rfl, hf, rfl⟩ obtain ⟨h1, h2, h3⟩ := Classical.choose_spec (Nat.find_spec h) - refine ⟨Classical.choose (Nat.find_spec h), h1, by convert h2, fun g hg1 hg2 con => ?_⟩ + refine ⟨Classical.choose (Nat.find_spec h), h1, by convert! h2, fun g hg1 hg2 con => ?_⟩ refine Nat.find_min h ?_ ⟨g, fun m mn => (h1 m mn).trans (hg1 m mn), con, rfl⟩ rwa [← h3] @@ -932,7 +938,7 @@ theorem WellFounded.prod_lex_of_wellFoundedOn_fiber (hα : WellFounded (rα on f obtain h' | h' := Prod.lex_iff.1 h · exact PSigma.Lex.left _ _ h' · dsimp only [InvImage, (· on ·)] at h' ⊢ - convert PSigma.Lex.right (⟨_, c', rfl⟩ : range f) _ using 1; swap + convert! PSigma.Lex.right (⟨_, c', rfl⟩ : range f) _ using 1; swap exacts [⟨c, h'.1⟩, PSigma.subtype_ext (Subtype.ext h'.1) rfl, h'.2] theorem Set.WellFoundedOn.prod_lex_of_wellFoundedOn_fiber (hα : s.WellFoundedOn (rα on f)) @@ -957,7 +963,7 @@ theorem WellFounded.sigma_lex_of_wellFoundedOn_fiber (hι : WellFounded (rι on obtain h' | ⟨h', h''⟩ := Sigma.lex_iff.1 h · exact PSigma.Lex.left _ _ h' · dsimp only [InvImage, (· on ·)] at h' ⊢ - convert PSigma.Lex.right (⟨_, c', rfl⟩ : range f) _ using 1; swap + convert! PSigma.Lex.right (⟨_, c', rfl⟩ : range f) _ using 1; swap · exact ⟨c, h'⟩ · exact PSigma.subtype_ext (Subtype.ext h') rfl · dsimp only [Subtype.coe_mk, Subrel, Order.Preimage] at * diff --git a/Mathlib/Probability/CentralLimitTheorem.lean b/Mathlib/Probability/CentralLimitTheorem.lean index d191006467b698..312e75db6e0570 100644 --- a/Mathlib/Probability/CentralLimitTheorem.lean +++ b/Mathlib/Probability/CentralLimitTheorem.lean @@ -61,12 +61,12 @@ lemma tendsto_charFun_inv_sqrt_mul_pow {X : Ω → ℝ} have aux : (fun (n : ℕ) ↦ ‖(1 / n : ℂ)‖) = fun (n : ℕ) ↦ ‖(1 / n : ℝ)‖ := by simp rw [← Asymptotics.isLittleO_norm_right, aux, Asymptotics.isLittleO_norm_right] refine .of_const_mul_right (c := t ^ 2) ?_ - convert this using 4 with n <;> norm_cast <;> simp [field] + convert! this using 4 with n <;> norm_cast <;> simp [field] have : Tendsto (fun (n : ℕ) ↦ (√n)⁻¹ * t) atTop (𝓝 0) := by rw [← zero_mul t] exact .mul_const t (tendsto_inv_atTop_zero.comp <| Real.tendsto_sqrt_atTop.comp <| tendsto_natCast_atTop_atTop) - convert (taylor_charFun_two hX h0 h1).comp_tendsto this using 2 + convert! (taylor_charFun_two hX h0 h1).comp_tendsto this using 2 simp ring @@ -108,13 +108,13 @@ private theorem tendstoInDistribution_inv_sqrt_mul_var_mul_sum_sub rw [← Finset.sum_div, Finset.sum_sub_distrib] simp [field] simp_rw [this] - convert tendstoInDistribution_inv_sqrt_mul_sum hY ?_ ?_ ?_ ?_ + convert! tendstoInDistribution_inv_sqrt_mul_sum hY ?_ ?_ ?_ ?_ · rw [integral_div, integral_sub intX0 (by simp)] simp · simp only [Pi.pow_apply, div_pow] rw [integral_div, ← variance_eq_integral mX0, Real.sq_sqrt (variance_nonneg _ _), div_self hX] · exact hindep.comp (fun _ x ↦ (x - P[X 0]) / √Var[X 0; P]) (by fun_prop) - · convert fun n ↦ (hident n).comp (u := fun x ↦ (x - P[X 0]) / √Var[X 0; P]) (by fun_prop) + · convert! fun n ↦ (hident n).comp (u := fun x ↦ (x - P[X 0]) / √Var[X 0; P]) (by fun_prop) /-- **Central Limit Theorem:** Given a sequence of random variables `X : ℕ → Ω → ℝ` that are independent, identically distributed with mean `μ` and variance `v`, and a random variable @@ -130,7 +130,7 @@ theorem tendstoInDistribution_inv_sqrt_mul_sum_sub obtain h | h := eq_or_ne Var[X 0; P] 0 · have : ∀ᵐ ω ∂P, ∀ n, X n ω = P[X 0] := by refine ae_all_iff.2 fun n ↦ ?_ - convert (ae_eq_integral_of_variance_eq_zero ((hident n).memLp_iff.2 hX)) ?_ using 3 + convert! (ae_eq_integral_of_variance_eq_zero ((hident n).memLp_iff.2 hX)) ?_ using 3 · rw [(hident n).integral_eq] · rwa [(hident n).variance_eq] have mX (n : ℕ) := (hident n).aemeasurable_fst @@ -140,11 +140,12 @@ theorem tendstoInDistribution_inv_sqrt_mul_sum_sub simp [hω] · exact ⟨by fun_prop, by fun_prop, by simp [hY.map_eq, h]⟩ have : HasLaw (fun ω ↦ Y ω / √Var[X 0; P]) (gaussianReal 0 1) P' := by - convert gaussianReal_div_const hY _ + convert! gaussianReal_div_const hY _ · simp · ext; simp [h] - convert (tendstoInDistribution_inv_sqrt_mul_var_mul_sum_sub this h hindep hident).continuous_comp - (g := (√Var[X 0; P] * ·)) (by fun_prop) + convert! + (tendstoInDistribution_inv_sqrt_mul_var_mul_sum_sub this h hindep hident).continuous_comp (g := + (√Var[X 0; P] * ·)) (by fun_prop) · simp [field] -- simp [field, hX] triggers the unused simp arguments linter field_simp [h] · ext diff --git a/Mathlib/Probability/ConditionalProbability.lean b/Mathlib/Probability/ConditionalProbability.lean index a61d9e565115e8..434db885ddda22 100644 --- a/Mathlib/Probability/ConditionalProbability.lean +++ b/Mathlib/Probability/ConditionalProbability.lean @@ -228,7 +228,7 @@ theorem cond_inter_self (hms : MeasurableSet s) (t : Set Ω) (μ : Measure Ω) : theorem inter_pos_of_cond_ne_zero (hms : MeasurableSet s) (hcst : μ[t | s] ≠ 0) : 0 < μ (s ∩ t) := by refine pos_iff_ne_zero.mpr (right_ne_zero_of_mul (a := (μ s)⁻¹) ?_) - convert hcst + convert! hcst simp [hms, Set.inter_comm, cond] lemma cond_pos_of_inter_ne_zero [IsFiniteMeasure μ] (hms : MeasurableSet s) (hci : μ (s ∩ t) ≠ 0) : diff --git a/Mathlib/Probability/Distributions/Beta.lean b/Mathlib/Probability/Distributions/Beta.lean index 6af08ef5c80c9a..04cc8de4a49590 100644 --- a/Mathlib/Probability/Distributions/Beta.lean +++ b/Mathlib/Probability/Distributions/Beta.lean @@ -118,10 +118,10 @@ lemma lintegral_betaPDF_eq_one {α β : ℝ} (hα : 0 < α) (hβ : 0 < β) : rw [← Complex.ofReal_cpow, ← Complex.ofReal_cpow, RCLike.re_to_complex, Complex.re_mul_ofReal, Complex.ofReal_re] all_goals linarith - convert betaIntegral_convergent (u := α) (v := β) (by simpa) (by simpa) + convert! betaIntegral_convergent (u := α) (v := β) (by simpa) (by simpa) rw [intervalIntegrable_iff_integrableOn_Ioc_of_le (by simp), IntegrableOn] · refine ae_restrict_of_forall_mem measurableSet_Ioo (fun x hx ↦ ?_) - convert betaPDFReal_pos hx.1 hx.2 hα hβ |>.le using 1 + convert! betaPDFReal_pos hx.1 hx.2 hα hβ |>.le using 1 rw [betaPDFReal, if_pos ⟨hx.1, hx.2⟩] · exact Measurable.aestronglyMeasurable (by fun_prop) diff --git a/Mathlib/Probability/Distributions/Exponential.lean b/Mathlib/Probability/Distributions/Exponential.lean index 904ca9b965e767..5f03844c8318b2 100644 --- a/Mathlib/Probability/Distributions/Exponential.lean +++ b/Mathlib/Probability/Distributions/Exponential.lean @@ -110,7 +110,7 @@ open Topology lemma hasDerivAt_neg_exp_mul_exp {r x : ℝ} : HasDerivAt (fun a ↦ -exp (-(r * a))) (r * exp (-(r * x))) x := by - convert (((hasDerivAt_id x).const_mul (-r)).exp.const_mul (-1)) using 1 + convert! (((hasDerivAt_id x).const_mul (-r)).exp.const_mul (-1)) using 1 · simp only [one_mul, id_eq, neg_mul] simp only [id_eq, neg_mul, mul_one, mul_neg, one_mul, neg_neg, mul_comm] diff --git a/Mathlib/Probability/Distributions/Fernique.lean b/Mathlib/Probability/Distributions/Fernique.lean index d27dc8a53cbf22..1169d3975a23d1 100644 --- a/Mathlib/Probability/Distributions/Fernique.lean +++ b/Mathlib/Probability/Distributions/Fernique.lean @@ -180,7 +180,7 @@ lemma measure_le_mul_measure_gt_normThreshold_le_of_map_rotation_eq_self [SFinit (h_rot : (μ.prod μ).map (ContinuousLinearMap.rotation (-(π / 4))) = μ.prod μ) (a : ℝ) (n : ℕ) : μ {x | ‖x‖ ≤ a} * μ {x | normThreshold a (n + 1) < ‖x‖} ≤ μ {x | normThreshold a n < ‖x‖} ^ 2 := by - convert measure_le_mul_measure_gt_le_of_map_rotation_eq_self h_rot _ _ + convert! measure_le_mul_measure_gt_le_of_map_rotation_eq_self h_rot _ _ simp [normThreshold_add_one] lemma lt_normThreshold_zero (ha_pos : 0 < a) : a / (1 - √2) < normThreshold a 0 := by @@ -364,7 +364,7 @@ lemma lintegral_closedBall_diff_exp_logRatio_mul_sq_le [IsProbabilityMeasure μ] _ ≤ .ofReal (rexp (2⁻¹ * Real.log (c.toReal / (1 - c).toReal) * 2 ^ n)) * c * .ofReal (rexp (-Real.log (c / (1 - c)).toReal * 2 ^ n)) := by gcongr ENNReal.ofReal (rexp ?_) * _ * _ - convert logRatio_mul_normThreshold_add_one_le ha_gt ha_lt n (a := a) using 1 + convert! logRatio_mul_normThreshold_add_one_le ha_gt ha_lt n (a := a) using 1 ring _ = c * .ofReal (rexp (-2⁻¹ * Real.log (c / (1 - c)).toReal * 2 ^ n)) := by rw [mul_comm _ c, mul_assoc, ← ENNReal.ofReal_mul (by positivity), ← Real.exp_add] @@ -527,7 +527,7 @@ lemma exists_integrable_exp_sq_of_map_rotation_eq_self' [IsProbabilityMeasure μ rwa [inv_eq_one_div, ENNReal.div_lt_iff (by simp) (by simp), mul_comm] at ha_gt have h_pos : 0 < logRatio c * a⁻¹ ^ 2 := mul_pos (logRatio_pos ha_gt hc_lt) (by positivity) refine ⟨logRatio c * a⁻¹ ^ 2, h_pos, ⟨by fun_prop, ?_⟩⟩ - simp only [HasFiniteIntegral, ← ofReal_norm_eq_enorm, Real.norm_eq_abs, Real.abs_exp] + simp only [HasFiniteIntegral, ← ofReal_norm, Real.norm_eq_abs, Real.abs_exp] -- `⊢ ∫⁻ x, ENNReal.ofReal (rexp (logRatio c * a⁻¹ ^ 2 * ‖x‖ ^ 2)) ∂μ < ∞` refine (lintegral_exp_mul_sq_norm_le_of_map_rotation_eq_self h_rot le_rfl ha_gt).trans_lt ?_ refine ENNReal.add_lt_top.mpr ⟨ENNReal.ofReal_lt_top, ?_⟩ diff --git a/Mathlib/Probability/Distributions/Gaussian/Basic.lean b/Mathlib/Probability/Distributions/Gaussian/Basic.lean index f810a25cb0141b..19eef22c3763a6 100644 --- a/Mathlib/Probability/Distributions/Gaussian/Basic.lean +++ b/Mathlib/Probability/Distributions/Gaussian/Basic.lean @@ -113,7 +113,7 @@ instance {x : E} : IsGaussian (Measure.dirac x) where omit [IsGaussian μ] in lemma IsGaussian.of_subsingleton [Subsingleton E] [IsProbabilityMeasure μ] : IsGaussian μ := by - convert instIsGaussianDirac (x := (0 : E)) + convert! instIsGaussianDirac (x := (0 : E)) ext s - apply Subsingleton.set_cases (p := fun s ↦ μ s = _) all_goals simp @@ -123,7 +123,7 @@ lemma IsGaussian.memLp_dual (μ : Measure E) [IsGaussian μ] (L : StrongDual ℝ MemLp L p μ := by suffices MemLp (id ∘ L) p μ from this rw [← memLp_map_measure_iff (by fun_prop) (by fun_prop), IsGaussian.map_eq_gaussianReal L] - convert memLp_id_gaussianReal p.toNNReal + convert! memLp_id_gaussianReal p.toNNReal simp [hp] @[fun_prop] diff --git a/Mathlib/Probability/Distributions/Gaussian/Fernique.lean b/Mathlib/Probability/Distributions/Gaussian/Fernique.lean index f387a7b9ef5330..f14bad7f0a10d5 100644 --- a/Mathlib/Probability/Distributions/Gaussian/Fernique.lean +++ b/Mathlib/Probability/Distributions/Gaussian/Fernique.lean @@ -127,7 +127,7 @@ lemma integrable_exp_sq_of_conv_neg (μ : Measure E) [IsGaussian μ] {C C' : ℝ simp only [ContinuousLinearEquiv.coe_neg] at hC filter_upwards [hC] with y hy rw [integrable_map_measure (by fun_prop) (by fun_prop)] at hy - convert hy with x + convert! hy with x simp only [Function.comp_apply, Pi.neg_apply, id_eq, Real.exp_eq_exp, mul_eq_mul_left_iff, norm_nonneg, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true, pow_left_inj₀] left @@ -188,7 +188,7 @@ lemma memLp_id (μ : Measure E) [IsGaussian μ] (p : ℝ≥0∞) (hp : p ≠ ∞ rw [← memLp_norm_rpow_iff (q := 2) (by fun_prop) (by simp) (by simp)] simpa using this lift p to ℝ≥0 using hp - convert memLp_of_mem_interior_integrableExpSet ?_ (p / 2) + convert! memLp_of_mem_interior_integrableExpSet ?_ (p / 2) · simp obtain ⟨C, hC_pos, hC⟩ := exists_integrable_exp_sq μ have hC_neg : Integrable (fun x ↦ rexp (-C * ‖x‖ ^ 2)) μ := by -- `-C` could be any negative diff --git a/Mathlib/Probability/Distributions/Gaussian/HasGaussianLaw/Basic.lean b/Mathlib/Probability/Distributions/Gaussian/HasGaussianLaw/Basic.lean index 3902cefe9c2f61..8558e8e9a5ee16 100644 --- a/Mathlib/Probability/Distributions/Gaussian/HasGaussianLaw/Basic.lean +++ b/Mathlib/Probability/Distributions/Gaussian/HasGaussianLaw/Basic.lean @@ -229,14 +229,14 @@ lemma sum {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpac [BorelSpace E] [SecondCountableTopology E] {X : ι → Ω → E} (hX : HasGaussianLaw (fun ω ↦ (X · ω)) P) : HasGaussianLaw (∑ i, X i) P := by - convert hX.map (∑ i, .proj i) + convert! hX.map (∑ i, .proj i) ext; simp lemma fun_sum {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E] [BorelSpace E] [SecondCountableTopology E] {X : ι → Ω → E} (hX : HasGaussianLaw (fun ω ↦ (X · ω)) P) : HasGaussianLaw (fun ω ↦ ∑ i, X i ω) P := by - convert hX.sum + convert! hX.sum simp end Pi diff --git a/Mathlib/Probability/Distributions/Gaussian/IsGaussianProcess/Basic.lean b/Mathlib/Probability/Distributions/Gaussian/IsGaussianProcess/Basic.lean index 45cf789c90ac0a..55cfc2bf51df6b 100644 --- a/Mathlib/Probability/Distributions/Gaussian/IsGaussianProcess/Basic.lean +++ b/Mathlib/Probability/Distributions/Gaussian/IsGaussianProcess/Basic.lean @@ -96,12 +96,12 @@ lemma hasGaussianLaw_fun_sub (hX : IsGaussianProcess X P) {s t : T} : lemma hasGaussianLaw_sum (hX : IsGaussianProcess X P) {I : Finset T} : HasGaussianLaw (∑ i ∈ I, X i) P := by - convert (hX.hasGaussianLaw I).sum + convert! (hX.hasGaussianLaw I).sum simp [I.sum_attach X] lemma hasGaussianLaw_fun_sum (hX : IsGaussianProcess X P) {I : Finset T} : HasGaussianLaw (fun ω ↦ ∑ i ∈ I, X i ω) P := by - convert hX.hasGaussianLaw_sum (I := I) + convert! hX.hasGaussianLaw_sum (I := I) simp /-- The increments of a Gaussian process are Gaussian. -/ diff --git a/Mathlib/Probability/Distributions/Gaussian/Real.lean b/Mathlib/Probability/Distributions/Gaussian/Real.lean index 820ced3733d57d..7852741f031426 100644 --- a/Mathlib/Probability/Distributions/Gaussian/Real.lean +++ b/Mathlib/Probability/Distributions/Gaussian/Real.lean @@ -334,7 +334,7 @@ lemma gaussianReal_map_neg : (gaussianReal μ v).map (fun x ↦ -x) = gaussianRe lemma gaussianReal_map_div_const (c : ℝ) : (gaussianReal μ v).map (· / c) = gaussianReal (μ / c) (v / .mk (c ^ 2) (sq_nonneg _)) := by simp_rw [div_eq_mul_inv] - convert gaussianReal_map_mul_const c⁻¹ using 2 <;> rw [mul_comm] + convert! gaussianReal_map_mul_const c⁻¹ using 2 <;> rw [mul_comm] ext; simp lemma gaussianReal_map_sub_const (y : ℝ) : diff --git a/Mathlib/Probability/Distributions/Geometric.lean b/Mathlib/Probability/Distributions/Geometric.lean index 822c5b5a228caa..8d1e609040c6cc 100644 --- a/Mathlib/Probability/Distributions/Geometric.lean +++ b/Mathlib/Probability/Distributions/Geometric.lean @@ -84,7 +84,7 @@ lemma geometricMeasure_real_singleton_pos (h1 : p ≠ 0) (h2 : p ≠ 1) n : lemma hasSum_one_geometricMeasure (hp : p ≠ 0) : HasSum (fun n ↦ (1 - p : ℝ) ^ n * p) 1 := by - convert (hasSum_geometric_of_lt_one (r := 1 - p) (by grind) (by grind)).mul_right (p : ℝ) + convert! (hasSum_geometric_of_lt_one (r := 1 - p) (by grind) (by grind)).mul_right (p : ℝ) grind instance isProbabilityMeasure_geometricMeasure : @@ -115,7 +115,7 @@ lemma hasSum_integral_geometricMeasure [CompleteSpace E] ext n; rw [ENNReal.toReal_ofReal (geometricMeasure_nonneg p n)] rw [this, geometricMeasure_eq hp] apply hasSum_integral_sum_dirac (by simp) - convert (integrable_geometricMeasure_iff hp).1 hf with n + convert! (integrable_geometricMeasure_iff hp).1 hf with n rw [ENNReal.toReal_ofReal (geometricMeasure_nonneg p n)] /-- If a function is integrable with respect to `geometricMeasure p`, then its integral diff --git a/Mathlib/Probability/Distributions/Poisson/Basic.lean b/Mathlib/Probability/Distributions/Poisson/Basic.lean index 3bb71bb7b127cc..5d26d72566199c 100644 --- a/Mathlib/Probability/Distributions/Poisson/Basic.lean +++ b/Mathlib/Probability/Distributions/Poisson/Basic.lean @@ -1,15 +1,15 @@ /- Copyright (c) 2024 Josha Dekker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. -Authors: Josha Dekker, Etienne Marion +Authors: Josha Dekker, Etienne Marion, Hanzhang Cheng -/ module -public import Mathlib.MeasureTheory.Integral.Bochner.Basic +public import Mathlib.MeasureTheory.Measure.CharacteristicFunction.Basic +public import Mathlib.Probability.HasLaw public import Mathlib.Probability.ProbabilityMassFunction.Basic -import Mathlib.Analysis.SpecialFunctions.Exponential -import Mathlib.MeasureTheory.Integral.Bochner.SumMeasure +import Mathlib.LinearAlgebra.Complex.FiniteDimensional /-! # Poisson distributions over ℕ @@ -19,6 +19,12 @@ measure which to `{n}` associates `exp (-r) * r ^ n / (n)!`. ## Main definition * `poissonMeasure r`: a Poisson measure on `ℕ`, parametrized by its rate `r : ℝ≥0`. + +## Main results + +* `poissonMeasure_conv_poissonMeasure`: `Poisson(r₁) ∗ Poisson(r₂) = Poisson(r₁ + r₂)`. +* `IndepFun.hasLaw_add_poissonMeasure`: the sum of two independent Poisson random variables + is again Poisson. -/ @[expose] public section @@ -33,60 +39,82 @@ noncomputable def poissonMeasure (r : ℝ≥0) : Measure ℕ := Measure.sum (fun n ↦ ENNReal.ofReal (exp (-r) * r ^ n / (n)!) • (.dirac n)) +/-- The Poisson probability distribution with rate `r`. -/ +scoped notation3 "Po(" r ")" => poissonMeasure r + +/-- The Poisson probability distribution with rate `r` valued in the `AddMonoidWithOne` `R`. -/ +scoped notation3 "Po(" R ", " r ")" => (poissonMeasure r).map (Nat.cast : ℕ → R) + lemma poissonMeasure_singleton (r : ℝ≥0) (n : ℕ) : - (poissonMeasure r) {n} = ENNReal.ofReal (exp (-r) * r ^ n / (n)!) := by + Po(r) {n} = ENNReal.ofReal (exp (-r) * r ^ n / (n)!) := by rw [poissonMeasure, Measure.sum_smul_dirac_singleton] lemma poissonMeasure_real_singleton (r : ℝ≥0) (n : ℕ) : - (poissonMeasure r).real {n} = exp (-r) * r ^ n / (n)! := by + Po(r).real {n} = exp (-r) * r ^ n / (n)! := by rw [measureReal_def, poissonMeasure_singleton, ENNReal.toReal_ofReal (by positivity)] lemma poissonMeasure_real_singleton_pos {r : ℝ≥0} (n : ℕ) (hr : 0 < r) : - 0 < (poissonMeasure r).real {n} := by + 0 < Po(r).real {n} := by rw [poissonMeasure_real_singleton] positivity lemma hasSum_one_poissonMeasure (r : ℝ≥0) : HasSum (fun n ↦ exp (-r) * r ^ n / (n)!) 1 := by - convert (NormedSpace.expSeries_div_hasSum_exp (r : ℝ)).mul_left (exp (-r)) using 1 + convert! (NormedSpace.expSeries_div_hasSum_exp (r : ℝ)).mul_left (exp (-r)) using 1 · simp_rw [mul_div_assoc] · simp [← exp_eq_exp_ℝ, ← exp_add] -instance isProbabilityMeasure_poissonMeasure (r : ℝ≥0) : - IsProbabilityMeasure (poissonMeasure r) := +instance (r : ℝ≥0) : IsProbabilityMeasure Po(r) := (hasSum_one_poissonMeasure r).isProbabilityMeasure_sum_dirac (fun _ ↦ by positivity) +instance (r : ℝ≥0) {R : Type*} [NatCast R] [MeasurableSpace R] : + IsProbabilityMeasure Po(R, r) := + Measure.isProbabilityMeasure_map .of_discrete + section Integral variable {E : Type*} [NormedAddCommGroup E] +variable {R : Type*} [NatCast R] [MeasurableSpace R] lemma integrable_poissonMeasure_iff {r : ℝ≥0} {f : ℕ → E} : - Integrable f (poissonMeasure r) ↔ Summable (fun n ↦ exp (-r) * r ^ n / (n)! * ‖f n‖) := by + Integrable f Po(r) ↔ Summable (fun n ↦ exp (-r) * r ^ n / (n)! * ‖f n‖) := by rw [poissonMeasure, integrable_sum_dirac_iff (by simp)] congrm Summable (fun n ↦ ?_ * _) rw [ENNReal.toReal_ofReal (by positivity)] +lemma integrable_map_cast_poissonMeasure_iff {r : ℝ≥0} [Countable R] [MeasurableSingletonClass R] + {f : R → E} : Integrable f Po(R, r) ↔ Integrable (f ∘ Nat.cast) Po(r) := + integrable_map_measure .of_discrete .of_discrete + variable [NormedSpace ℝ E] lemma hasSum_integral_poissonMeasure [CompleteSpace E] {r : ℝ≥0} {f : ℕ → E} - (hf : Integrable f (poissonMeasure r)) : - HasSum (fun n ↦ (exp (-r) * r ^ n / (n)!) • f n) (∫ n, f n ∂poissonMeasure r) := by + (hf : Integrable f Po(r)) : + HasSum (fun n ↦ (exp (-r) * r ^ n / (n)!) • f n) (∫ n, f n ∂Po(r)) := by have : (fun n ↦ (exp (-r) * r ^ n / (n)!) • f n) = fun n ↦ (ENNReal.ofReal (exp (-r) * r ^ n / (n)!)).toReal • f n := by ext; rw [ENNReal.toReal_ofReal (by positivity)] rw [this] apply hasSum_integral_sum_dirac (by simp) - convert integrable_poissonMeasure_iff.1 hf + convert! integrable_poissonMeasure_iff.1 hf rw [ENNReal.toReal_ofReal (by positivity)] + /-- If a function is integrable with respect to `poissonMeasure r`, then its integral against this measure is given by its sum weighted by `exp (-r) * r ^ n / n!`. See `integral_poissonMeasure` for a version where the codomain is finite-dimensional and does not require the integrability hypothesis. -/ lemma integral_poissonMeasure' [CompleteSpace E] {r : ℝ≥0} {f : ℕ → E} - (hf : Integrable f (poissonMeasure r)) : - ∫ n, f n ∂poissonMeasure r = ∑' n, (exp (-r) * r ^ n / (n)!) • f n := + (hf : Integrable f Po(r)) : + ∫ n, f n ∂Po(r) = ∑' n, (exp (-r) * r ^ n / (n)!) • f n := (hasSum_integral_poissonMeasure hf).tsum_eq.symm +lemma integral_map_cast_poissonMeasure' [CompleteSpace E] [Countable R] [MeasurableSingletonClass R] + {r : ℝ≥0} {f : R → E} (hf : Integrable f Po(R, r)) : + ∫ x, f x ∂Po(R, r) = ∑' n, (exp (-r) * r ^ n / (n)!) • f n := by + rw [integral_map .of_discrete .of_discrete] + rw [integrable_map_cast_poissonMeasure_iff] at hf + exact integral_poissonMeasure' hf + /-- The integral of a function taking values in a finite-dimensional space against `poissonMeasure r` is given by its sum weighted by `exp (-r) * r ^ n / n!`. This version does not require integrability, as the integral exists if and only if the sum exists, and otherwise @@ -94,13 +122,88 @@ they are both defined to be zero. See `integral_poissonMeasure'` with a general codomain which assumes integrability. -/ lemma integral_poissonMeasure [FiniteDimensional ℝ E] (r : ℝ≥0) (f : ℕ → E) : - ∫ n, f n ∂poissonMeasure r = ∑' n, (exp (-r) * r ^ n / (n)!) • f n := by + ∫ n, f n ∂Po(r) = ∑' n, (exp (-r) * r ^ n / (n)!) • f n := by rw [poissonMeasure, integral_sum_dirac (by simp)] congr with n rw [ENNReal.toReal_ofReal (by positivity)] +lemma integral_map_cast_poissonMeasure [FiniteDimensional ℝ E] (r : ℝ≥0) [Countable R] + [MeasurableSingletonClass R] (f : R → E) : + ∫ x, f x ∂Po(R, r) = ∑' n, (exp (-r) * r ^ n / (n)!) • f n := by + rw [integral_map .of_discrete .of_discrete, integral_poissonMeasure] + end Integral +section CharFun + +open Complex + +/-- The characteristic function of the Poisson distribution with rate `r` is +`t ↦ exp(r(exp(it) - 1))`. -/ +lemma charFun_map_cast_poissonMeasure (r : ℝ≥0) (t : ℝ) : + charFun Po(ℝ, r) t = cexp (r * (cexp (t * I) - 1)) := by + rw [charFun_apply, integral_map .of_discrete (by fun_prop), integral_poissonMeasure r] + simp_rw [Real.inner_apply] + calc ∑' a, (rexp (-r) * r ^ a / a ! : ℝ) * cexp ((a * t : ℝ) * I) + _ = ∑' a, (rexp (-r)) * ((r * cexp (t * I)) ^ a / a !) := by + congr with a + push_cast + rw [mul_pow, ← Complex.exp_nat_mul] + ring_nf + _ = (rexp (-r)) * ∑' a, ((r * cexp (t * I)) ^ a / a !) := tsum_mul_left + _ = (rexp (-r)) * cexp (r * cexp (t * I)) := by + rw [(NormedSpace.expSeries_div_hasSum_exp (r * cexp (t * I))).tsum_eq, exp_eq_exp_ℂ] + _ = cexp (r * (cexp (t * I) - 1)) := by + rw [ofReal_exp, ← Complex.exp_add] + push_cast + ring_nf + +end CharFun + +/-! ### Convolution of Poisson measures -/ + +section Convolution + +variable {R : Type*} [AddMonoidWithOne R] {mR : MeasurableSpace R} + +private theorem map_cast_poissonMeasure_conv_real (r₁ r₂ : ℝ≥0) : + Po(ℝ, r₁) ∗ Po(ℝ, r₂) = Po(ℝ, r₁ + r₂) := by + apply Measure.ext_of_charFun + ext t + simp only [charFun_conv, charFun_map_cast_poissonMeasure, ← Complex.exp_add] + congr; push_cast; ring + +theorem poissonMeasure_conv_poissonMeasure (r₁ r₂ : ℝ≥0) : + Po(r₁) ∗ Po(r₂) = Po(r₁ + r₂) := by + apply (MeasurableEmbedding.natCast (α := ℝ)).map_injective + rw [← Nat.coe_castAddMonoidHom, Measure.map_conv_addMonoidHom _ (by fun_prop)] + exact map_cast_poissonMeasure_conv_real _ _ + +theorem map_cast_poissonMeasure_conv [MeasurableAdd₂ R] (r₁ r₂ : ℝ≥0) : + Po(R, r₁) ∗ Po(R, r₂) = Po(R, r₁ + r₂) := by + rw [← Nat.coe_castAddMonoidHom, ← Measure.map_conv_addMonoidHom _ (by fun_prop), + poissonMeasure_conv_poissonMeasure] + +/-- The sum of two independent Poisson random variables with rates `r₁, r₂` is a Poisson +random variable with rate `r₁ + r₂`. -/ +theorem IndepFun.hasLaw_add_poissonMeasure {Ω : Type*} {mΩ : MeasurableSpace Ω} + {P : Measure Ω} {r₁ r₂ : ℝ≥0} {X Y : Ω → ℕ} + (hXY : IndepFun X Y P) (hX : HasLaw X Po(r₁) P) (hY : HasLaw Y Po(r₂) P) : + HasLaw (X + Y) Po(r₁ + r₂) P := by + rw [← poissonMeasure_conv_poissonMeasure] + exact hXY.hasLaw_add hX hY + +/-- The sum of two independent Poisson random variables with rates `r₁, r₂` taking values in `R` +is a Poisson random variable with rate `r₁ + r₂`. -/ +theorem IndepFun.hasLaw_add_map_cast_poissonMeasure {Ω : Type*} {mΩ : MeasurableSpace Ω} + {P : Measure Ω} [MeasurableAdd₂ R] {r₁ r₂ : ℝ≥0} {X Y : Ω → R} + (hXY : IndepFun X Y P) (hX : HasLaw X Po(R, r₁) P) (hY : HasLaw Y Po(R, r₂) P) : + HasLaw (X + Y) Po(R, r₁ + r₂) P := by + rw [← map_cast_poissonMeasure_conv] + exact hXY.hasLaw_add hX hY + +end Convolution + section PoissonPMF /-- The pmf of the Poisson distribution depending on its rate, as a function to ℝ -/ diff --git a/Mathlib/Probability/HasLaw.lean b/Mathlib/Probability/HasLaw.lean index a077697f9bcd0b..40071c7e15ac76 100644 --- a/Mathlib/Probability/HasLaw.lean +++ b/Mathlib/Probability/HasLaw.lean @@ -188,7 +188,7 @@ lemma indepFun_iff_hasLaw_prodMk_prod [IsFiniteMeasure P] {𝓨 : Type*} {m𝓨 X ⟂ᵢ[P] Y ↔ HasLaw (fun ω ↦ (X ω, Y ω)) (μ.prod ν) P where mp h := { map_eq := by - rw [(indepFun_iff_map_prod_eq_prod_map_map (by fun_prop) (by fun_prop)).1 h, hX.map_eq, + rw [h.map_prod_eq_prod_map_map (by fun_prop) (by fun_prop), hX.map_eq, hY.map_eq] } mpr h := by rw [indepFun_iff_map_prod_eq_prod_map_map (by fun_prop) (by fun_prop), @@ -201,8 +201,7 @@ lemma iIndepFun.hasLaw_pi {ι : Type*} [Fintype ι] {𝓧 : ι → Type*} {m𝓧 (h : iIndepFun X P) : HasLaw (fun ω i ↦ X i ω) (Measure.pi μ) P where map_eq := by - have := h.isProbabilityMeasure - rw [(iIndepFun_iff_map_fun_eq_pi_map (by fun_prop)).1 h] + rw [h.map_fun_eq_pi_map (by fun_prop)] simp_rw [fun i ↦ (hX i).map_eq] lemma iIndepFun_iff_hasLaw_pi_pi [IsProbabilityMeasure P] {ι : Type*} [Fintype ι] {𝓧 : ι → Type*} diff --git a/Mathlib/Probability/IdentDistrib.lean b/Mathlib/Probability/IdentDistrib.lean index b054385fd16aab..3a290b509a42ae 100644 --- a/Mathlib/Probability/IdentDistrib.lean +++ b/Mathlib/Probability/IdentDistrib.lean @@ -281,7 +281,7 @@ lemma inv [Inv γ] [MeasurableInv γ] (h : IdentDistrib f g μ ν) : theorem evariance_eq {f : α → ℝ} {g : β → ℝ} (h : IdentDistrib f g μ ν) : evariance f μ = evariance g ν := by - convert (h.sub_const (∫ x, f x ∂μ)).nnnorm.coe_nnreal_ennreal.sq.lintegral_eq + convert! (h.sub_const (∫ x, f x ∂μ)).nnnorm.coe_nnreal_ennreal.sq.lintegral_eq rw [h.integral_eq] rfl @@ -348,8 +348,7 @@ lemma indepFun_of_identDistrib_pair {X : γ → α} {X' : δ → α} {Y : γ → β} {Y' : δ → β} (h_indep : X ⟂ᵢ[μ] Y) (h_ident : IdentDistrib (fun ω ↦ (X ω, Y ω)) (fun ω ↦ (X' ω, Y' ω)) μ μ') : X' ⟂ᵢ[μ'] Y' := by - rw [indepFun_iff_map_prod_eq_prod_map_map _ _, ← h_ident.map_eq, - (indepFun_iff_map_prod_eq_prod_map_map _ _).1 h_indep] + rw [indepFun_iff_map_prod_eq_prod_map_map, ← h_ident.map_eq, h_indep.map_prod_eq_prod_map_map] · exact congr (congrArg Measure.prod <| (h_ident.comp measurable_fst).map_eq) (h_ident.comp measurable_snd).map_eq · exact measurable_fst.aemeasurable.comp_aemeasurable h_ident.aemeasurable_fst diff --git a/Mathlib/Probability/IdentDistribIndep.lean b/Mathlib/Probability/IdentDistribIndep.lean index 3b2ac74124047c..2061131f785209 100644 --- a/Mathlib/Probability/IdentDistribIndep.lean +++ b/Mathlib/Probability/IdentDistribIndep.lean @@ -47,8 +47,8 @@ lemma IdentDistrib.prodMk [IsFiniteMeasure μ] have : IsFiniteMeasure ν := by have : IsFiniteMeasure (ν.map Z) := by rw [← hXZ.map_eq]; infer_instance exact Measure.isFiniteMeasure_of_map hXZ.aemeasurable_snd - rw [(indepFun_iff_map_prod_eq_prod_map_map hXZ.aemeasurable_fst hYW.aemeasurable_fst).mp hXY, - (indepFun_iff_map_prod_eq_prod_map_map hXZ.aemeasurable_snd hYW.aemeasurable_snd).mp hZW, + rw [hXY.map_prod_eq_prod_map_map hXZ.aemeasurable_fst hYW.aemeasurable_fst, + hZW.map_prod_eq_prod_map_map hXZ.aemeasurable_snd hYW.aemeasurable_snd, hXZ.map_eq, hYW.map_eq] /-- If `(X i)` and `(Y i)` are families of independent random variables indexed by a countable diff --git a/Mathlib/Probability/Independence/Basic.lean b/Mathlib/Probability/Independence/Basic.lean index c4e3c2827fa78c..5d738a7df45802 100644 --- a/Mathlib/Probability/Independence/Basic.lean +++ b/Mathlib/Probability/Independence/Basic.lean @@ -337,7 +337,7 @@ end Definition_lemmas section Indep -variable {m₁ m₂ m₃ : MeasurableSpace Ω} (m' : MeasurableSpace Ω) +variable {m₁ m₂ m₃ m₄ : MeasurableSpace Ω} (m' : MeasurableSpace Ω) {_mΩ : MeasurableSpace Ω} {μ : Measure Ω} @[symm] @@ -376,6 +376,10 @@ theorem indep_of_indep_of_le_right (h_indep : Indep m₁ m₂ μ) (h32 : m₃ Indep m₁ m₃ μ := Kernel.indep_of_indep_of_le_right h_indep h32 +theorem indep_of_indep_of_le (h_indep : Indep m₁ m₂ μ) (h31 : m₃ ≤ m₁) (h42 : m₄ ≤ m₂) : + Indep m₃ m₄ μ := + Kernel.indep_of_indep_of_le h_indep h31 h42 + theorem iIndep_of_iIndep_of_le {m₁ m₂ : ι → MeasurableSpace Ω} (h_indep : iIndep m₂ μ) (h_le : ∀ i, m₁ i ≤ m₂ i) : iIndep m₁ μ := Kernel.iIndep_of_iIndep_of_le h_indep h_le @@ -701,33 +705,7 @@ theorem indepFun_iff_map_prod_eq_prod_map_map {mβ : MeasurableSpace β} {mβ' : f ⟂ᵢ[μ] g ↔ μ.map (fun ω ↦ (f ω, g ω)) = (μ.map f).prod (μ.map g) := by apply indepFun_iff_map_prod_eq_prod_map_map' hf hg <;> apply IsFiniteMeasure.toSigmaFinite -theorem iIndepFun_iff_map_fun_eq_pi_map [Fintype ι] {β : ι → Type*} - {m : ∀ i, MeasurableSpace (β i)} {f : Π i, Ω → β i} [IsProbabilityMeasure μ] - (hf : ∀ i, AEMeasurable (f i) μ) : - iIndepFun f μ ↔ μ.map (fun ω i ↦ f i ω) = Measure.pi (fun i ↦ μ.map (f i)) := by - classical - rw [iIndepFun_iff_measure_inter_preimage_eq_mul] - have h₀ {s : ∀ i, Set (β i)} (hm : ∀ (i : ι), MeasurableSet (s i)) : - ∏ i : ι, μ (f i ⁻¹' s i) = ∏ i : ι, μ.map (f i) (s i) ∧ - μ (⋂ i : ι, (f i ⁻¹' s i)) = μ.map (fun ω i ↦ f i ω) (univ.pi s) := by - constructor - · congr with x - rw [Measure.map_apply_of_aemeasurable (hf x) (hm x)] - · rw [Measure.map_apply_of_aemeasurable (aemeasurable_pi_lambda _ fun x ↦ hf x) - (.univ_pi hm)] - congr with x - simp - constructor - · refine fun hS ↦ (Measure.pi_eq fun h hm ↦ ?_).symm - rw [← (h₀ hm).1, ← (h₀ hm).2] - simpa [hm] using hS Finset.univ (sets := h) - · intro h S s hs - specialize h₀ (s := fun i ↦ if i ∈ S then s i else univ) - fun i ↦ by beta_reduce; split_ifs with hiS <;> simp [hiS, hs] - simp only [apply_ite, preimage_univ, measure_univ, Finset.prod_ite_mem, Finset.univ_inter, - Finset.prod_ite, Finset.filter_univ_mem, iInter_ite, iInter_univ, inter_univ, h, - Measure.pi_pi] at h₀ - rw [h₀.2, ← h₀.1] +alias ⟨IndepFun.map_prod_eq_prod_map_map, _⟩ := indepFun_iff_map_prod_eq_prod_map_map @[symm] nonrec theorem IndepFun.symm {_ : MeasurableSpace β} {_ : MeasurableSpace β'} @@ -749,7 +727,7 @@ variables defined on the product space `Ω × Ω'`. -/ lemma indepFun_prod (mX : Measurable X) (mY : Measurable Y) : (fun ω ↦ X ω.1) ⟂ᵢ[μ.prod ν] (fun ω ↦ Y ω.2) := by refine indepFun_iff_map_prod_eq_prod_map_map (by fun_prop) (by fun_prop) |>.2 ?_ - convert Measure.map_prod_map μ ν mX mY |>.symm + convert! Measure.map_prod_map μ ν mX mY |>.symm · rw [← Function.comp_def, ← Measure.map_map mX measurable_fst, Measure.map_fst_prod, measure_univ, one_smul] · rw [← Function.comp_def, ← Measure.map_map mY measurable_snd, Measure.map_snd_prod, @@ -773,25 +751,6 @@ lemma indepFun_prod₀ (mX : AEMeasurable X μ) (mY : AEMeasurable Y ν) : · rw [measurePreserving_snd.map_eq] exact (AEMeasurable.ae_eq_mk mY).symm -variable {ι : Type*} [Fintype ι] {Ω : ι → Type*} {mΩ : ∀ i, MeasurableSpace (Ω i)} - {μ : (i : ι) → Measure (Ω i)} [∀ i, IsProbabilityMeasure (μ i)] - {𝓧 : ι → Type*} [∀ i, MeasurableSpace (𝓧 i)] {X : (i : ι) → Ω i → 𝓧 i} - -/-- Given random variables `X i : Ω i → 𝓧 i`, they are independent when viewed as random -variables defined on the product space `Π i, Ω i`. -/ -lemma iIndepFun_pi (mX : ∀ i, AEMeasurable (X i) (μ i)) : - iIndepFun (fun i ω ↦ X i (ω i)) (Measure.pi μ) := by - refine iIndepFun_iff_map_fun_eq_pi_map ?_ |>.2 ?_ - · exact fun i ↦ (mX i).comp_quasiMeasurePreserving (Measure.quasiMeasurePreserving_eval _ i) - rw [Measure.pi_map_pi mX] - congr - ext i : 1 - rw [← (measurePreserving_eval μ i).map_eq, AEMeasurable.map_map_of_aemeasurable, - Function.comp_def] - · rw [(measurePreserving_eval μ i).map_eq] - exact mX i - · exact (measurable_pi_apply i).aemeasurable - end Prod theorem IndepFun.comp {_mβ : MeasurableSpace β} {_mβ' : MeasurableSpace β'} @@ -878,6 +837,71 @@ lemma iIndepFun_iff_finset : iIndepFun f μ ↔ ∀ s : Finset ι, iIndepFun (s. alias ⟨iIndepFun.restrict, _⟩ := iIndepFun_iff_finset +theorem iIndepFun.map_fun_eq_pi_map [Fintype ι] {β : ι → Type*} + {m : ∀ i, MeasurableSpace (β i)} {f : Π i, Ω → β i} + (hf : ∀ i, AEMeasurable (f i) μ) (h : iIndepFun f μ) : + μ.map (fun ω i ↦ f i ω) = Measure.pi (fun i ↦ μ.map (f i)) := by + classical + have := h.isProbabilityMeasure + rw [iIndepFun_iff_measure_inter_preimage_eq_mul] at h + have h₀ {s : ∀ i, Set (β i)} (hm : ∀ (i : ι), MeasurableSet (s i)) : + ∏ i : ι, μ (f i ⁻¹' s i) = ∏ i : ι, μ.map (f i) (s i) ∧ + μ (⋂ i : ι, (f i ⁻¹' s i)) = μ.map (fun ω i ↦ f i ω) (univ.pi s) := by + constructor + · congr with x + rw [Measure.map_apply_of_aemeasurable (hf x) (hm x)] + · rw [Measure.map_apply_of_aemeasurable (aemeasurable_pi_lambda _ fun x ↦ hf x) + (.univ_pi hm)] + congr with x + simp + refine (Measure.pi_eq fun h' hm ↦ ?_).symm + rw [← (h₀ hm).1, ← (h₀ hm).2] + simpa [hm] using h Finset.univ (sets := h') + +theorem iIndepFun_iff_map_fun_eq_pi_map [Fintype ι] {β : ι → Type*} + {m : ∀ i, MeasurableSpace (β i)} {f : Π i, Ω → β i} [IsProbabilityMeasure μ] + (hf : ∀ i, AEMeasurable (f i) μ) : + iIndepFun f μ ↔ μ.map (fun ω i ↦ f i ω) = Measure.pi (fun i ↦ μ.map (f i)) := by + refine ⟨iIndepFun.map_fun_eq_pi_map hf, ?_⟩ + classical + rw [iIndepFun_iff_measure_inter_preimage_eq_mul] + have h₀ {s : ∀ i, Set (β i)} (hm : ∀ (i : ι), MeasurableSet (s i)) : + ∏ i : ι, μ (f i ⁻¹' s i) = ∏ i : ι, μ.map (f i) (s i) ∧ + μ (⋂ i : ι, (f i ⁻¹' s i)) = μ.map (fun ω i ↦ f i ω) (univ.pi s) := by + constructor + · congr with x + rw [Measure.map_apply_of_aemeasurable (hf x) (hm x)] + · rw [Measure.map_apply_of_aemeasurable (aemeasurable_pi_lambda _ fun x ↦ hf x) + (.univ_pi hm)] + congr with x + simp + intro h S s hs + specialize h₀ (s := fun i ↦ if i ∈ S then s i else univ) + fun i ↦ by beta_reduce; split_ifs with hiS <;> simp [hiS, hs] + simp only [apply_ite, preimage_univ, measure_univ, Finset.prod_ite_mem, Finset.univ_inter, + Finset.prod_ite, Finset.filter_univ_mem, iInter_ite, iInter_univ, inter_univ, h, + Measure.pi_pi] at h₀ + rw [h₀.2, ← h₀.1] + +variable {ι : Type*} [Fintype ι] {Ω : ι → Type*} {mΩ : ∀ i, MeasurableSpace (Ω i)} + {μ : (i : ι) → Measure (Ω i)} [∀ i, IsProbabilityMeasure (μ i)] + {𝓧 : ι → Type*} [∀ i, MeasurableSpace (𝓧 i)] {X : (i : ι) → Ω i → 𝓧 i} + +/-- Given random variables `X i : Ω i → 𝓧 i`, they are independent when viewed as random +variables defined on the product space `Π i, Ω i`. -/ +lemma iIndepFun_pi (mX : ∀ i, AEMeasurable (X i) (μ i)) : + iIndepFun (fun i ω ↦ X i (ω i)) (Measure.pi μ) := by + refine iIndepFun_iff_map_fun_eq_pi_map ?_ |>.2 ?_ + · exact fun i ↦ (mX i).comp_quasiMeasurePreserving (Measure.quasiMeasurePreserving_eval _ i) + rw [Measure.pi_map_pi mX] + congr + ext i : 1 + rw [← (measurePreserving_eval μ i).map_eq, AEMeasurable.map_map_of_aemeasurable, + Function.comp_def] + · rw [(measurePreserving_eval μ i).map_eq] + exact mX i + · exact (measurable_pi_apply i).aemeasurable + end iIndepFun section Mul @@ -1011,6 +1035,12 @@ theorem iIndepSet.iIndepFun_indicator [Zero β] [One β] {m : MeasurableSpace β iIndepFun (fun n => (s n).indicator fun _ω => (1 : β)) μ := Kernel.iIndepSet.iIndepFun_indicator hs +lemma Indep.indicator_indepFun {m : MeasurableSpace Ω} {M 𝓧 : Type*} + [Zero M] [MeasurableSpace M] (c : M) [NeZero c] {m𝓧 : MeasurableSpace 𝓧} {A : Set Ω} + {X : Ω → 𝓧} (hA : MeasurableSet[m] A) (h : Indep m (m𝓧.comap X) μ) : + (A.indicator (fun _ ↦ c)) ⟂ᵢ[μ] X := + Kernel.Indep.indicator_const_indepFun c hA h + end IndepFun variable {ι Ω α β : Type*} {mΩ : MeasurableSpace Ω} {mα : MeasurableSpace α} @@ -1065,7 +1095,7 @@ lemma iIndepFun.cond [Finite ι] (hY : ∀ i, Measurable (Y i)) iIndepFun X μ[|⋂ i, Y i ⁻¹' t i] := by rw [iIndepFun_iff] intro s f hf - convert cond_iInter hY hindep hf (fun i _ ↦ hy _) ht using 2 with i hi + convert! cond_iInter hY hindep hf (fun i _ ↦ hy _) ht using 2 with i hi simpa using cond_iInter hY hindep (fun j hj ↦ hf _ <| Finset.mem_singleton.1 hj ▸ hi) (fun i _ ↦ hy _) ht diff --git a/Mathlib/Probability/Independence/BoundedContinuousFunction.lean b/Mathlib/Probability/Independence/BoundedContinuousFunction.lean index ee5a8244a1c172..31b91fcdda347a 100644 --- a/Mathlib/Probability/Independence/BoundedContinuousFunction.lean +++ b/Mathlib/Probability/Independence/BoundedContinuousFunction.lean @@ -107,7 +107,7 @@ lemma pi_indepFun_pi_of_prod_bcf (mX : ∀ s, AEMeasurable (X s) P) (aemeasurable_pi_lambda _ mY)] refine eq_prod_of_integral_prod_mul_prod_boundedContinuousFunction fun f g ↦ ?_ rw [integral_map, integral_map, integral_map] - · convert h f g <;> simp + · convert! h f g <;> simp any_goals fun_prop all_goals exact Measurable.aestronglyMeasurable (by fun_prop) @@ -122,8 +122,9 @@ lemma pi_indepFun_pi_of_bcf (mX : ∀ s, AEMeasurable (X s) P) IndepFun (fun ω s ↦ X s ω) (fun ω t ↦ Y t ω) P := by have := Fintype.ofFinite S; have := Fintype.ofFinite T refine pi_indepFun_pi_of_prod_bcf mX mY fun f g ↦ ?_ - convert h (∏ s, (f s).compContinuous ⟨Function.eval s, by fun_prop⟩) - (∏ t, (g t).compContinuous ⟨Function.eval t, by fun_prop⟩) <;> simp + convert! + h (∏ s, (f s).compContinuous ⟨Function.eval s, by fun_prop⟩) + (∏ t, (g t).compContinuous ⟨Function.eval t, by fun_prop⟩) <;> simp lemma indepFun_pi_of_prod_bcf (mZ : AEMeasurable Z P) (mY : ∀ t, AEMeasurable (Y t) P) @@ -133,7 +134,7 @@ lemma indepFun_pi_of_prod_bcf (mZ : AEMeasurable Z P) rw [indepFun_iff_map_prod_eq_prod_map_map mZ (aemeasurable_pi_lambda _ mY)] refine eq_prod_of_integral_mul_prod_boundedContinuousFunction fun f g ↦ ?_ rw [integral_map, integral_map, integral_map] - · convert h f g <;> simp + · convert! h f g <;> simp any_goals fun_prop all_goals exact Measurable.aestronglyMeasurable (by fun_prop) @@ -145,7 +146,7 @@ lemma indepFun_pi_of_bcf (mZ : AEMeasurable Z P) IndepFun Z (fun ω t ↦ Y t ω) P := by have := Fintype.ofFinite T refine indepFun_pi_of_prod_bcf mZ mY fun f g ↦ ?_ - convert h f (∏ t, (g t).compContinuous ⟨Function.eval t, by fun_prop⟩) <;> simp + convert! h f (∏ t, (g t).compContinuous ⟨Function.eval t, by fun_prop⟩) <;> simp lemma pi_indepFun_of_prod_bcf (mX : ∀ s, AEMeasurable (X s) P) (mU : AEMeasurable U P) @@ -155,7 +156,7 @@ lemma pi_indepFun_of_prod_bcf (mX : ∀ s, AEMeasurable (X s) P) rw [indepFun_iff_map_prod_eq_prod_map_map (aemeasurable_pi_lambda _ mX) mU] refine eq_prod_of_integral_prod_mul_boundedContinuousFunction fun f g ↦ ?_ rw [integral_map, integral_map, integral_map] - · convert h f g <;> simp + · convert! h f g <;> simp any_goals fun_prop all_goals exact Measurable.aestronglyMeasurable (by fun_prop) @@ -167,7 +168,7 @@ lemma pi_indepFun_of_bcf (mX : ∀ s, AEMeasurable (X s) P) IndepFun (fun ω s ↦ X s ω) U P := by have := Fintype.ofFinite S refine pi_indepFun_of_prod_bcf mX mU fun f g ↦ ?_ - convert h (∏ s, (f s).compContinuous ⟨Function.eval s, by fun_prop⟩) g <;> simp + convert! h (∏ s, (f s).compContinuous ⟨Function.eval s, by fun_prop⟩) g <;> simp /-- Two random variables $X$ and $Y$ are independent if for all real bounded continuous functions $f$ and $g$, @@ -236,7 +237,7 @@ lemma indicator_indepFun_pi_of_bcf (A.indicator (1 : Ω → ℝ)) ⟂ᵢ[P] (fun ω s ↦ X s ω) := by have := Fintype.ofFinite S refine indicator_indepFun_pi_of_prod_bcf mA mX fun f ↦ ?_ - convert h (∏ s, (f s).compContinuous ⟨Function.eval s, by fun_prop⟩) <;> simp + convert! h (∏ s, (f s).compContinuous ⟨Function.eval s, by fun_prop⟩) <;> simp /-- The indicator of a set $A$ and a random variable $X$ are independent if for all real bounded continuous function $f$, @@ -248,7 +249,7 @@ lemma indicator_indepFun_of_bcf suffices (A.indicator (1 : Ω → ℝ)) ⟂ᵢ[P] (fun ω (_ : Unit) ↦ Z ω) from this.comp (measurable_id) (measurable_pi_apply ()) refine indicator_indepFun_pi_of_prod_bcf mA (fun _ ↦ mZ) fun f ↦ ?_ - convert h (f ()) <;> simp + convert! h (f ()) <;> simp end Indicator diff --git a/Mathlib/Probability/Independence/CharacteristicFunction.lean b/Mathlib/Probability/Independence/CharacteristicFunction.lean index c4a4ccd7d5f623..0bc434ae17109c 100644 --- a/Mathlib/Probability/Independence/CharacteristicFunction.lean +++ b/Mathlib/Probability/Independence/CharacteristicFunction.lean @@ -145,11 +145,12 @@ lemma iIndepFun.charFunDual_map_finsetSum_eq_prod [NormedSpace ℝ E] · exact mX i (mem_insert_self i s) · exact Finset.aemeasurable_sum s (fun i hi ↦ (mX i (mem_insert_of_mem hi))) symm - convert iIndepFun.indepFun_finsetSum_of_notMem₀ (i := ⟨i, mem_insert_self i s⟩) - (f := fun (x : (insert i s : Finset ι)) ↦ X x.1) (s := {x | x.1 ∈ s}) hX - (fun i ↦ (mX i.1 i.2)) (by simpa) + convert! + iIndepFun.indepFun_finsetSum_of_notMem₀ (i := ⟨i, mem_insert_self i s⟩) (f := + fun (x : (insert i s : Finset ι)) ↦ X x.1) (s := {x | x.1 ∈ s}) hX (fun i ↦ (mX i.1 i.2)) + (by simpa) let e : ((insert i s) : Finset ι) → ι := Subtype.val - convert (Finset.sum_of_injOn Subtype.val ?_ ?_ ?_ ?_).symm + convert! (Finset.sum_of_injOn Subtype.val ?_ ?_ ?_ ?_).symm · simp · intro _ _; grind · simp; grind @@ -166,7 +167,7 @@ lemma iIndepFun.charFunDual_map_sum_eq_prod [Fintype ι] [NormedSpace ℝ E] lemma iIndepFun.charFunDual_map_fun_finsetSum_eq_prod [NormedSpace ℝ E] (mX : ∀ i ∈ s, AEMeasurable (X i) P) (hX : iIndepFun (s.restrict X) P) : charFunDual (P.map (fun ω ↦ ∑ i ∈ s, X i ω)) = ∏ i ∈ s, charFunDual (P.map (X i)) := by - convert hX.charFunDual_map_finsetSum_eq_prod mX + convert! hX.charFunDual_map_finsetSum_eq_prod mX simp @[deprecated (since := "2026-04-08")] @@ -204,7 +205,7 @@ lemma iIndepFun.charFun_map_sum_eq_prod [Fintype ι] [InnerProductSpace ℝ E] lemma iIndepFun.charFun_map_fun_finsetSum_eq_prod [InnerProductSpace ℝ E] (mX : ∀ i ∈ s, AEMeasurable (X i) P) (hX : iIndepFun (s.restrict X) P) : charFun (P.map (fun ω ↦ ∑ i ∈ s, X i ω)) = ∏ i ∈ s, charFun (P.map (X i)) := by - convert hX.charFun_map_finsetSum_eq_prod mX + convert! hX.charFun_map_finsetSum_eq_prod mX simp @[deprecated (since := "2026-04-08")] diff --git a/Mathlib/Probability/Independence/Conditional.lean b/Mathlib/Probability/Independence/Conditional.lean index d908d4bfb01301..5200e504eb8cb3 100644 --- a/Mathlib/Probability/Independence/Conditional.lean +++ b/Mathlib/Probability/Independence/Conditional.lean @@ -688,7 +688,7 @@ theorem iCondIndepFun_iff_condExp_inter_preimage_eq_mul {β : ι → Type*} intro i hi rw [(h_sets i hi).choose_spec.2.symm] simp only [g, dif_pos hi] - convert h with i hi i hi <;> exact hg i hi + convert! h with i hi i hi <;> exact hg i hi theorem condIndepFun_iff_condIndepSet_preimage {mβ : MeasurableSpace β} {mβ' : MeasurableSpace β'} (hf : Measurable f) (hg : Measurable g) : @@ -851,11 +851,11 @@ theorem condIndepFun_iff_map_prod_eq_prod_condDistrib_prod_condDistrib rw [@Measure.dirac_apply' _ (mγ.comap k) _ _ (hk_meas hs)] congr refine ⟨fun h s t u hs ht hu ↦ ?_, fun h ↦ ?_⟩ - · convert h (hk_meas hs) ht hu + · convert! h (hk_meas hs) ht hu · exact h_left hs ht hu · exact h_right hs ht hu · rintro - t u ⟨s, hs, rfl⟩ ht hu - convert h hs ht hu + convert! h hs ht hu · exact (h_left hs ht hu).symm · exact (h_right hs ht hu).symm diff --git a/Mathlib/Probability/Independence/InfinitePi.lean b/Mathlib/Probability/Independence/InfinitePi.lean index d46ba8f6b66b9b..6eab9497a77b1d 100644 --- a/Mathlib/Probability/Independence/InfinitePi.lean +++ b/Mathlib/Probability/Independence/InfinitePi.lean @@ -33,29 +33,39 @@ open MeasureTheory Measure ProbabilityTheory namespace ProbabilityTheory -variable {ι Ω : Type*} {mΩ : MeasurableSpace Ω} {P : Measure Ω} [IsProbabilityMeasure P] +variable {ι Ω : Type*} {mΩ : MeasurableSpace Ω} {P : Measure Ω} {𝓧 : ι → Type*} {m𝓧 : ∀ i, MeasurableSpace (𝓧 i)} {X : Π i, Ω → 𝓧 i} +/-- If random variables are independent then their joint distribution is the product measure. This +is a version where the random variable `ω ↦ (Xᵢ(ω))ᵢ` is almost everywhere measurable. +See `iIndepFun.map_fun_eq_infinitePi_map₀'` for a version which only assumes that +each `Xᵢ` is almost everywhere measurable and that `ι` is countable. -/ +lemma iIndepFun.map_fun_eq_infinitePi_map₀ (mX : AEMeasurable (fun ω i ↦ X i ω) P) + (h : iIndepFun X P) : + P.map (fun ω i ↦ X i ω) = infinitePi (fun i ↦ P.map (X i)) := by + have := h.isProbabilityMeasure + have _ i := isProbabilityMeasure_map (mX.eval i) + refine eq_infinitePi _ fun s t ht ↦ ?_ + rw [iIndepFun_iff_finset] at h + have : (s : Set ι).pi t = s.restrict ⁻¹' (Set.univ.pi fun i ↦ t i) := by ext; simp + rw [this, ← map_apply, AEMeasurable.map_map_of_aemeasurable] + · have : s.restrict ∘ (fun ω i ↦ X i ω) = fun ω i ↦ s.restrict X i ω := by ext; simp + rw [this, (h s).map_fun_eq_pi_map, pi_pi] + · simp only [Finset.restrict] + rw [s.prod_coe_sort fun i ↦ P.map (X i) (t i)] + exact fun i ↦ mX.eval i + any_goals fun_prop + · exact mX + · exact .univ_pi fun i ↦ ht i + /-- Random variables are independent iff their joint distribution is the product measure. This is a version where the random variable `ω ↦ (Xᵢ(ω))ᵢ` is almost everywhere measurable. See `iIndepFun_iff_map_fun_eq_infinitePi_map₀'` for a version which only assumes that each `Xᵢ` is almost everywhere measurable and that `ι` is countable. -/ -lemma iIndepFun_iff_map_fun_eq_infinitePi_map₀ (mX : AEMeasurable (fun ω i ↦ X i ω) P) : +lemma iIndepFun_iff_map_fun_eq_infinitePi_map₀ [IsProbabilityMeasure P] + (mX : AEMeasurable (fun ω i ↦ X i ω) P) : iIndepFun X P ↔ P.map (fun ω i ↦ X i ω) = infinitePi (fun i ↦ P.map (X i)) where - mp h := by - have _ i := isProbabilityMeasure_map (mX.eval i) - refine eq_infinitePi _ fun s t ht ↦ ?_ - rw [iIndepFun_iff_finset] at h - have : (s : Set ι).pi t = s.restrict ⁻¹' (Set.univ.pi fun i ↦ t i) := by ext; simp - rw [this, ← map_apply, AEMeasurable.map_map_of_aemeasurable] - · have : s.restrict ∘ (fun ω i ↦ X i ω) = fun ω i ↦ s.restrict X i ω := by ext; simp - rw [this, (iIndepFun_iff_map_fun_eq_pi_map ?_).1 (h s), pi_pi] - · simp only [Finset.restrict] - rw [s.prod_coe_sort fun i ↦ P.map (X i) (t i)] - exact fun i ↦ mX.eval i - any_goals fun_prop - · exact mX - · exact .univ_pi fun i ↦ ht i + mp h := h.map_fun_eq_infinitePi_map₀ mX mpr h := by have _ i := isProbabilityMeasure_map (mX.eval i) rw [iIndepFun_iff_finset] @@ -68,19 +78,33 @@ lemma iIndepFun_iff_map_fun_eq_infinitePi_map₀ (mX : AEMeasurable (fun ω i exact mX exact fun i ↦ mX.eval i +/-- If random variables are independent then their joint distribution is the product measure. This +is an `AEMeasurable` version of `iIndepFun.map_fun_eq_infinitePi_map`, which is why it requires +`ι` to be countable. -/ +lemma iIndepFun.map_fun_eq_infinitePi_map₀' [Countable ι] (mX : ∀ i, AEMeasurable (X i) P) + (h : iIndepFun X P) : + P.map (fun ω i ↦ X i ω) = infinitePi (fun i ↦ P.map (X i)) := + h.map_fun_eq_infinitePi_map₀ <| aemeasurable_pi_iff.2 mX + /-- Random variables are independent iff their joint distribution is the product measure. This is an `AEMeasurable` version of `iIndepFun_iff_map_fun_eq_infinitePi_map`, which is why it requires `ι` to be countable. -/ -lemma iIndepFun_iff_map_fun_eq_infinitePi_map₀' [Countable ι] (mX : ∀ i, AEMeasurable (X i) P) : +lemma iIndepFun_iff_map_fun_eq_infinitePi_map₀' [IsProbabilityMeasure P] [Countable ι] + (mX : ∀ i, AEMeasurable (X i) P) : iIndepFun X P ↔ P.map (fun ω i ↦ X i ω) = infinitePi (fun i ↦ P.map (X i)) := iIndepFun_iff_map_fun_eq_infinitePi_map₀ <| aemeasurable_pi_iff.2 mX +/-- If random variables are independent then their joint distribution is the product measure. -/ +lemma iIndepFun.map_fun_eq_infinitePi_map (mX : ∀ i, Measurable (X i)) (h : iIndepFun X P) : + P.map (fun ω i ↦ X i ω) = infinitePi (fun i ↦ P.map (X i)) := + h.map_fun_eq_infinitePi_map₀ <| measurable_pi_iff.2 mX |>.aemeasurable + /-- Random variables are independent iff their joint distribution is the product measure. -/ -lemma iIndepFun_iff_map_fun_eq_infinitePi_map (mX : ∀ i, Measurable (X i)) : +lemma iIndepFun_iff_map_fun_eq_infinitePi_map [IsProbabilityMeasure P] + (mX : ∀ i, Measurable (X i)) : iIndepFun X P ↔ P.map (fun ω i ↦ X i ω) = infinitePi (fun i ↦ P.map (X i)) := iIndepFun_iff_map_fun_eq_infinitePi_map₀ <| measurable_pi_iff.2 mX |>.aemeasurable -omit [IsProbabilityMeasure P] in lemma iIndepFun.hasLaw_infinitePi {μ : (i : ι) → Measure (𝓧 i)} (hX : ∀ i, HasLaw (X i) (μ i) P) (h1 : iIndepFun X P) (h2 : AEMeasurable (fun ω i ↦ X i ω) P) : HasLaw (fun ω i ↦ X i ω) (infinitePi μ) P where @@ -90,7 +114,7 @@ lemma iIndepFun.hasLaw_infinitePi {μ : (i : ι) → Measure (𝓧 i)} (hX : ∀ rw [(iIndepFun_iff_map_fun_eq_infinitePi_map₀ h2).1 h1] simp_rw [fun i ↦ (hX i).map_eq] -lemma iIndepFun_iff_hasLaw_Pi_infinitePi {μ : (i : ι) → Measure (𝓧 i)} +lemma iIndepFun_iff_hasLaw_Pi_infinitePi [IsProbabilityMeasure P] {μ : (i : ι) → Measure (𝓧 i)} (hX : ∀ i, HasLaw (X i) (μ i) P) (hm : AEMeasurable (fun ω i ↦ X i ω) P) : iIndepFun X P ↔ HasLaw (fun ω i ↦ X i ω) (infinitePi μ) P where mp h := h.hasLaw_infinitePi hX hm @@ -108,9 +132,15 @@ lemma iIndepFun_infinitePi {Ω : ι → Type*} {mΩ : ∀ i, MeasurableSpace (Ω congrm infinitePi fun i ↦ ?_ rw [← infinitePi_map_eval P i, map_map (mX i) (by fun_prop), Function.comp_def] -section curry +lemma _root_.MeasureTheory.Measure.map_infinitePi_infinitePi_of_inj {α : Type*} {Ω : ι → Type*} + {mΩ : ∀ i, MeasurableSpace (Ω i)} {P : ∀ i, Measure (Ω i)} + [∀ i, IsProbabilityMeasure (P i)] {f : α → ι} (hf : Function.Injective f) : + (infinitePi P).map (fun ω i ↦ ω (f i)) = infinitePi (fun i ↦ P (f i)) := by + rw [(iIndepFun_iff_map_fun_eq_infinitePi_map <| by fun_prop).mp ?_] + · simp [infinitePi_map_eval] + exact .precomp hf <| iIndepFun_infinitePi (X := fun x ω ↦ ω) <| by fun_prop -omit [IsProbabilityMeasure P] +section curry section dependent diff --git a/Mathlib/Probability/Independence/Integration.lean b/Mathlib/Probability/Independence/Integration.lean index d493832fe3cd9d..b3e84ccd379466 100644 --- a/Mathlib/Probability/Independence/Integration.lean +++ b/Mathlib/Probability/Independence/Integration.lean @@ -32,9 +32,9 @@ example [M1 : MeasurableSpace Ω] {M2 : MeasurableSpace Ω} {μ : Measure Ω} : public section -open Set MeasureTheory +open Set MeasureTheory ENNReal -open scoped ENNReal MeasureTheory +open scoped NNReal MeasureTheory variable {Ω 𝕜 : Type*} [RCLike 𝕜] {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {f g : Ω → ℝ≥0∞} {X Y : Ω → 𝕜} @@ -68,8 +68,8 @@ theorem lintegral_mul_indicator_eq_lintegral_mul_lintegral_indicator {Mf mΩ : M right_distrib, h_ind_f', h_ind_g] · intro f h_meas_f h_mono_f h_ind_f have h_measM_f : ∀ n, Measurable (f n) := fun n => (h_meas_f n).mono hMf le_rfl - simp_rw [ENNReal.iSup_mul] - rw [lintegral_iSup h_measM_f h_mono_f, lintegral_iSup, ENNReal.iSup_mul] + simp_rw [iSup_mul] + rw [lintegral_iSup h_measM_f h_mono_f, lintegral_iSup, iSup_mul] · simp_rw [← h_ind_f] · exact fun n => h_mul_indicator _ (h_measM_f n) · exact fun m n h_le a => mul_le_mul_left (h_mono_f h_le a) _ @@ -99,8 +99,8 @@ theorem lintegral_mul_eq_lintegral_mul_lintegral_of_independent_measurableSpace h_ind_f', h_ind_g'] · intro f' h_meas_f' h_mono_f' h_ind_f' have h_measM_f' : ∀ n, Measurable (f' n) := fun n => (h_meas_f' n).mono hMg le_rfl - simp_rw [ENNReal.mul_iSup] - rw [lintegral_iSup, lintegral_iSup h_measM_f' h_mono_f', ENNReal.mul_iSup] + simp_rw [mul_iSup] + rw [lintegral_iSup, lintegral_iSup h_measM_f' h_mono_f', mul_iSup] · simp_rw [← h_ind_f'] · exact fun n => h_measM_f.mul (h_measM_f' n) · exact fun n m (h_le : n ≤ m) a => mul_le_mul_right (h_mono_f' h_le a) _ @@ -146,27 +146,58 @@ theorem lintegral_prod_eq_prod_lintegral_of_indepFun {ι : Type*} · exact s.aemeasurable_prod (fun i _ ↦ (x_mea i).aemeasurable) · exact (iIndepFun.indepFun_finsetProd_of_notMem hX x_mea hj).symm -/-- The product of two independent, integrable, real-valued random variables is integrable. -/ -theorem IndepFun.integrable_mul {β : Type*} [MeasurableSpace β] {X Y : Ω → β} - [NormedDivisionRing β] [BorelSpace β] (hXY : X ⟂ᵢ[μ] Y) (hX : Integrable X μ) - (hY : Integrable Y μ) : Integrable (X * Y) μ := by - let nX : Ω → ℝ≥0∞ := fun a => ‖X a‖ₑ - let nY : Ω → ℝ≥0∞ := fun a => ‖Y a‖ₑ - have hXY' : nX ⟂ᵢ[μ] nY := hXY.comp measurable_enorm measurable_enorm - have hnX : AEMeasurable nX μ := hX.1.aemeasurable.enorm - have hnY : AEMeasurable nY μ := hY.1.aemeasurable.enorm - have hmul : ∫⁻ a, nX a * nY a ∂μ = (∫⁻ a, nX a ∂μ) * ∫⁻ a, nY a ∂μ := - lintegral_mul_eq_lintegral_mul_lintegral_of_indepFun' hnX hnY hXY' - refine ⟨hX.1.mul hY.1, ?_⟩ - simp only [nX, nY] at hmul - simp_rw [hasFiniteIntegral_iff_enorm, Pi.mul_apply, enorm_mul, hmul] - exact ENNReal.mul_lt_top hX.2 hY.2 - -/-- If the product of two independent real-valued random variables is integrable and -the second one is not almost everywhere zero, then the first one is integrable. -/ -theorem IndepFun.integrable_left_of_integrable_mul {β : Type*} [MeasurableSpace β] {X Y : Ω → β} - [NormedDivisionRing β] [OpensMeasurableSpace β] - (hXY : X ⟂ᵢ[μ] Y) (h'XY : Integrable (X * Y) μ) +section Integral + +variable {𝓧 𝓨 E F G : Type*} [MeasurableSpace 𝓧] [MeasurableSpace 𝓨] + +/-- If `X` and `Y` are two independent and integrable random variables, and `B` is a function of +two variables such that `‖B x y‖ₑ ≤ C * ‖x‖ₑ * ‖y‖ₑ`, then `B X Y` is integrable. + +This is useful in particular if `B` is a continuous bilinear map. -/ +theorem IndepFun.integrable_op + [TopologicalSpace E] [ContinuousENorm E] [MeasurableSpace E] [OpensMeasurableSpace E] + [TopologicalSpace F] [ContinuousENorm F] [MeasurableSpace F] [OpensMeasurableSpace F] + [TopologicalSpace G] [ContinuousENorm G] + {X : Ω → E} {Y : Ω → F} (hXY : X ⟂ᵢ[μ] Y) (hX : Integrable X μ) (hY : Integrable Y μ) + (B : E → F → G) (cB : Continuous B.uncurry) (C : ℝ≥0) (hB : ∀ x y, ‖B x y‖ₑ ≤ C * ‖x‖ₑ * ‖y‖ₑ) : + Integrable (fun ω ↦ B (X ω) (Y ω)) μ := by + refine ⟨cB.comp_aestronglyMeasurable₂ hX.1 hY.1, ?_⟩ + unfold HasFiniteIntegral + calc + _ ≤ C * ∫⁻ ω, ‖X ω‖ₑ * ‖Y ω‖ₑ ∂μ := by + rw [← lintegral_const_mul'' _ (by fun_prop)] + gcongr with ω + simp [← mul_assoc, hB] + _ = C * ((∫⁻ ω, ‖X ω‖ₑ ∂μ) * (∫⁻ ω, ‖Y ω‖ₑ ∂μ)) := by + rw [lintegral_mul_eq_lintegral_mul_lintegral_of_indepFun'' hX.1.enorm hY.1.enorm + (hXY.comp measurable_enorm measurable_enorm)] + _ < ∞ := mul_lt_top (by finiteness) (mul_lt_top hX.2 hY.2) + +/-- A continuous bilinear map applied to two independent and integrable random variables +is integrable. -/ +theorem IndepFun.integrable_bilin {𝕜 : Type*} [NontriviallyNormedField 𝕜] + [SeminormedAddCommGroup E] [NormedSpace 𝕜 E] [MeasurableSpace E] [OpensMeasurableSpace E] + [SeminormedAddCommGroup F] [NormedSpace 𝕜 F] [MeasurableSpace F] [OpensMeasurableSpace F] + [SeminormedAddCommGroup G] [NormedSpace 𝕜 G] + {X : Ω → E} {Y : Ω → F} (hXY : X ⟂ᵢ[μ] Y) (hX : Integrable X μ) (hY : Integrable Y μ) + (B : E →L[𝕜] F →L[𝕜] G) : + Integrable (fun ω ↦ B (X ω) (Y ω)) μ := by + refine hXY.integrable_op hX hY (B · ·) (by fun_prop) ‖B‖₊ (fun x y ↦ ?_) + rw [← toReal_le_toReal (by finiteness) (by finiteness)] + simp [B.le_opNorm₂] + +/-- If `X` and `Y` are two independent random variables, `B X Y` is integrable, `Y` is not +almost-surely `0` and `c * ‖x‖ₑ * ‖y‖ₑ ≤ ‖B x y‖ₑ`, then `X` is integrable. + +This is useful for the case where `B` is scalar multiplication, as it will allow to drop +integrability hypotheses. -/ +theorem IndepFun.integrable_left_of_integrable_op + [TopologicalSpace E] [ContinuousENorm E] [MeasurableSpace E] [OpensMeasurableSpace E] + [NormedAddGroup F] [MeasurableSpace F] [OpensMeasurableSpace F] + [TopologicalSpace G] [ContinuousENorm G] + {X : Ω → E} {Y : Ω → F} (hXY : X ⟂ᵢ[μ] Y) + (B : E → F → G) (c : ℝ≥0) (hc : c ≠ 0) (hB : ∀ x y, c * ‖x‖ₑ * ‖y‖ₑ ≤ ‖B x y‖ₑ) + (h'XY : Integrable (fun ω ↦ B (X ω) (Y ω)) μ) (hX : AEStronglyMeasurable X μ) (hY : AEStronglyMeasurable Y μ) (h'Y : ¬Y =ᵐ[μ] 0) : Integrable X μ := by refine ⟨hX, ?_⟩ @@ -177,83 +208,224 @@ theorem IndepFun.integrable_left_of_integrable_mul {β : Type*} [MeasurableSpace simpa using hω refine hasFiniteIntegral_iff_enorm.mpr <| lt_top_iff_ne_top.2 fun H => ?_ have J : (‖X ·‖ₑ) ⟂ᵢ[μ] (‖Y ·‖ₑ) := hXY.comp measurable_enorm measurable_enorm - have A : ∫⁻ ω, ‖X ω * Y ω‖ₑ ∂μ < ∞ := h'XY.2 - simp only [enorm_mul] at A - rw [lintegral_mul_eq_lintegral_mul_lintegral_of_indepFun'' hX.enorm hY.enorm J, H] at A - simp only [ENNReal.top_mul I, lt_self_iff_false] at A - -/-- If the product of two independent real-valued random variables is integrable and the -first one is not almost everywhere zero, then the second one is integrable. -/ -theorem IndepFun.integrable_right_of_integrable_mul {β : Type*} [MeasurableSpace β] {X Y : Ω → β} - [NormedDivisionRing β] [OpensMeasurableSpace β] - (hXY : X ⟂ᵢ[μ] Y) (h'XY : Integrable (X * Y) μ) + have : ∞ < ∞ := calc + ∞ = c * ((∫⁻ ω, ‖X ω‖ₑ ∂μ) * (∫⁻ ω, ‖Y ω‖ₑ ∂μ)) := by + rw [H, top_mul I, mul_top (by simpa)] + _ ≤ ∫⁻ ω, ‖B (X ω) (Y ω)‖ₑ ∂μ := by + rw [← lintegral_mul_eq_lintegral_mul_lintegral_of_indepFun'' hX.enorm hY.enorm J, + ← lintegral_const_mul'' _ (by fun_prop)] + gcongr with ω + simp [hB, ← mul_assoc] + _ < ∞ := h'XY.2 + contradiction + +/-- If `X` and `Y` are two independent random variables, `B X Y` is integrable, `X` is not +almost-surely `0` and `c * ‖x‖ₑ * ‖y‖ₑ ≤ ‖B x y‖ₑ`, then `Y` is integrable. + +This is useful for the case where `B` is scalar multiplication, as it will allow to drop +integrability hypotheses. -/ +theorem IndepFun.integrable_right_of_integrable_op + [NormedAddGroup E] [MeasurableSpace E] [OpensMeasurableSpace E] + [TopologicalSpace F] [ContinuousENorm F] [MeasurableSpace F] [OpensMeasurableSpace F] + [TopologicalSpace G] [ContinuousENorm G] + {X : Ω → E} {Y : Ω → F} (hXY : X ⟂ᵢ[μ] Y) + (B : E → F → G) (c : ℝ≥0) (hc : c ≠ 0) (hB : ∀ x y, c * ‖x‖ₑ * ‖y‖ₑ ≤ ‖B x y‖ₑ) + (h'XY : Integrable (fun ω ↦ B (X ω) (Y ω)) μ) (hX : AEStronglyMeasurable X μ) (hY : AEStronglyMeasurable Y μ) (h'X : ¬X =ᵐ[μ] 0) : Integrable Y μ := by - refine ⟨hY, ?_⟩ - have I : ∫⁻ ω, ‖X ω‖ₑ ∂μ ≠ 0 := fun H ↦ by - have I : ((‖X ·‖ₑ) : Ω → ℝ≥0∞) =ᵐ[μ] 0 := (lintegral_eq_zero_iff' hX.enorm).1 H - apply h'X - filter_upwards [I] with ω hω - simpa using hω - refine lt_top_iff_ne_top.2 fun H => ?_ - have J : (fun ω => ‖X ω‖ₑ : Ω → ℝ≥0∞) ⟂ᵢ[μ] (fun ω => ‖Y ω‖ₑ : Ω → ℝ≥0∞) := - IndepFun.comp hXY measurable_enorm measurable_enorm - have A : ∫⁻ ω, ‖X ω * Y ω‖ₑ ∂μ < ∞ := h'XY.2 - simp only [enorm_mul] at A - rw [lintegral_mul_eq_lintegral_mul_lintegral_of_indepFun'' hX.enorm hY.enorm J, H] at A - simp only [ENNReal.mul_top I, lt_self_iff_false] at A - -lemma IndepFun.integral_fun_comp_mul_comp {𝓧 𝓨 : Type*} {m𝓧 : MeasurableSpace 𝓧} - {m𝓨 : MeasurableSpace 𝓨} {X : Ω → 𝓧} {Y : Ω → 𝓨} {f : 𝓧 → 𝕜} {g : 𝓨 → 𝕜} - (hXY : X ⟂ᵢ[μ] Y) (hX : AEMeasurable X μ) (hY : AEMeasurable Y μ) - (hf : AEStronglyMeasurable f (μ.map X)) (hg : AEStronglyMeasurable g (μ.map Y)) : - ∫ ω, f (X ω) * g (Y ω) ∂μ = (∫ ω, f (X ω) ∂μ) * ∫ ω, g (Y ω) ∂μ := by + refine hXY.symm.integrable_left_of_integrable_op (Function.swap B) c hc (fun y x ↦ ?_) + h'XY hY hX h'X + grw [mul_right_comm, hB] + +/-- If `X` and `Y` are independent random variables such that `f(X)` and `g(Y)` are integrable +and `B` is a continuous bilinear map, then +`∫ ω, B (f (X ω)) (g (Y ω)) ∂μ = B (∫ ω, f (X ω) ∂μ) (∫ ω, g (Y ω) ∂μ).` -/ +theorem IndepFun.integral_bilin_comp_comp + [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace 𝕜 E] [CompleteSpace E] + [NormedAddCommGroup F] [NormedSpace ℝ F] [NormedSpace 𝕜 F] [CompleteSpace F] + [NormedAddCommGroup G] [NormedSpace ℝ G] [NormedSpace 𝕜 G] [CompleteSpace G] + {X : Ω → 𝓧} {Y : Ω → 𝓨} {f : 𝓧 → E} {g : 𝓨 → F} (hXY : X ⟂ᵢ[μ] Y) + (hX : AEMeasurable X μ) (hY : AEMeasurable Y μ) + (hf : Integrable f (μ.map X)) (hg : Integrable g (μ.map Y)) (B : E →L[𝕜] F →L[𝕜] G) : + ∫ ω, B (f (X ω)) (g (Y ω)) ∂μ = B (∫ ω, f (X ω) ∂μ) (∫ ω, g (Y ω) ∂μ) := by + by_cases h : ∀ᵐ ω ∂μ, f (X ω) = 0 + · have h1 : ∀ᵐ ω ∂μ, B (f (X ω)) (g (Y ω)) = 0 := by + filter_upwards [h] with ω hω + simp [hω] + simp [integral_congr_ae h1, integral_congr_ae h] + borelize E F + have : IsProbabilityMeasure μ := + (hf.comp_aemeasurable hX).isProbabilityMeasure_of_indepFun (f ∘ X) (g ∘ Y) h + (hXY.comp₀ hX hY hf.1.aemeasurable hg.1.aemeasurable) + rw [← integral_map (f := fun z ↦ B (f z.1) (g z.2)) (φ := fun ω ↦ (X ω, Y ω)) (by fun_prop), + hXY.map_prod_eq_prod_map_map hX hY, integral_prod_bilin _ hf hg, integral_map hX hf.1, + integral_map hY hg.1] + rw [hXY.map_prod_eq_prod_map_map hX hY] + exact Continuous.comp_aestronglyMeasurable₂ (g := (B · ·)) (by fun_prop) + hf.1.comp_fst hg.1.comp_snd + +/-- If `X` and `Y` are random variables and `B` is a continuous bilinear map +such that `∀ x y, c * ‖x‖ * ‖y‖ ≤ ‖B x y‖`, then +`∫ ω, B (f (X ω)) (g (Y ω)) ∂μ = B (∫ ω, f (X ω) ∂μ) (∫ ω, g (Y ω) ∂μ).` + +The assumption on `B` allows to drop the integrability condition in +`IndepFun.integral_bilin_comp_comp`, which is useful for the versions where `B` is the scalar +multiplication or the multiplication. -/ +theorem IndepFun.integral_bilin_comp_comp' + [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace 𝕜 E] [CompleteSpace E] + [NormedAddCommGroup F] [NormedSpace ℝ F] [NormedSpace 𝕜 F] [CompleteSpace F] + [NormedAddCommGroup G] [NormedSpace ℝ G] [NormedSpace 𝕜 G] [CompleteSpace G] + {X : Ω → 𝓧} {Y : Ω → 𝓨} {f : 𝓧 → E} {g : 𝓨 → F} (hXY : X ⟂ᵢ[μ] Y) + (hX : AEMeasurable X μ) (hY : AEMeasurable Y μ) + (hf : AEStronglyMeasurable f (μ.map X)) (hg : AEStronglyMeasurable g (μ.map Y)) + (B : E →L[𝕜] F →L[𝕜] G) (c : ℝ≥0) (hc : c ≠ 0) (hB : ∀ x y, c * ‖x‖ * ‖y‖ ≤ ‖B x y‖) : + ∫ ω, B (f (X ω)) (g (Y ω)) ∂μ = B (∫ ω, f (X ω) ∂μ) (∫ ω, g (Y ω) ∂μ) := by + borelize E F have hfXgY := (hXY.comp₀ hX hY hf.aemeasurable hg.aemeasurable) have hfX := (hf.comp_aemeasurable hX) have hgY := (hg.comp_aemeasurable hY) by_cases h'X : ∀ᵐ ω ∂μ, f (X ω) = 0 - · have h' : ∀ᵐ ω ∂μ, f (X ω) * g (Y ω) = 0 := by + · have h' : ∀ᵐ ω ∂μ, B (f (X ω)) (g (Y ω)) = 0 := by filter_upwards [h'X] with ω hω simp [hω] simp [integral_congr_ae h'X, integral_congr_ae h'] by_cases h'Y : ∀ᵐ ω ∂μ, g (Y ω) = 0 - · have h' : ∀ᵐ ω ∂μ, f (X ω) * g (Y ω) = 0 := by + · have h' : ∀ᵐ ω ∂μ, B (f (X ω)) (g (Y ω)) = 0 := by filter_upwards [h'Y] with ω hω simp [hω] simp [integral_congr_ae h'Y, integral_congr_ae h'] - by_cases h : Integrable (fun ω ↦ f (X ω) * g (Y ω)) μ - · have := - (hfXgY.integrable_left_of_integrable_mul h hfX hgY h'Y).isProbabilityMeasure_of_indepFun - _ _ h'X hfXgY - change ∫ ω, (fun x ↦ f x.1 * g x.2) (X ω, Y ω) ∂μ = _ - rw [← integral_map (f := fun x ↦ f x.1 * g x.2) (φ := fun ω ↦ (X ω, Y ω)), - (indepFun_iff_map_prod_eq_prod_map_map hX hY).1 hXY, integral_prod_mul, integral_map, - integral_map] - any_goals fun_prop - rw [(indepFun_iff_map_prod_eq_prod_map_map hX hY).1 hXY] - exact hf.comp_fst.mul hg.comp_snd + have hB x y : c * ‖x‖ₑ * ‖y‖ₑ ≤ ‖B x y‖ₑ := by + rw [← toReal_le_toReal] + · simpa using hB x y + all_goals finiteness + by_cases h : Integrable (fun ω ↦ B (f (X ω)) (g (Y ω))) μ + · have h1 : Integrable f (μ.map X) := (integrable_map_measure hf hX).2 <| + hfXgY.integrable_left_of_integrable_op (B · ·) c hc hB h hfX hgY h'Y + have h2 : Integrable g (μ.map Y) := (integrable_map_measure hg hY).2 <| + hfXgY.integrable_right_of_integrable_op (B · ·) c hc hB h hfX hgY h'X + exact hXY.integral_bilin_comp_comp hX hY h1 h2 B · rw [integral_undef h] obtain h | h : ¬(Integrable (fun ω ↦ f (X ω)) μ) ∨ ¬(Integrable (fun ω ↦ g (Y ω)) μ) := - not_and_or.1 fun ⟨HX, HY⟩ ↦ h (hfXgY.integrable_mul HX HY) + not_and_or.1 fun ⟨HX, HY⟩ ↦ h (hfXgY.integrable_bilin HX HY B) all_goals simp [integral_undef h] -lemma IndepFun.integral_comp_mul_comp {𝓧 𝓨 : Type*} {m𝓧 : MeasurableSpace 𝓧} - {m𝓨 : MeasurableSpace 𝓨} {X : Ω → 𝓧} {Y : Ω → 𝓨} {f : 𝓧 → 𝕜} {g : 𝓨 → 𝕜} +/-- If `X` and `Y` are independent and integrable random variables and `B` +is a continuous bilinear map, then `∫ ω, B (X ω) (Y ω) ∂μ = B μ[X] μ[Y].` -/ +theorem IndepFun.integral_bilin + [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace 𝕜 E] [CompleteSpace E] + [MeasurableSpace E] [BorelSpace E] + [NormedAddCommGroup F] [NormedSpace ℝ F] [NormedSpace 𝕜 F] [CompleteSpace F] + [MeasurableSpace F] [BorelSpace F] + [NormedAddCommGroup G] [NormedSpace ℝ G] [NormedSpace 𝕜 G] [CompleteSpace G] + {X : Ω → E} {Y : Ω → F} (hXY : X ⟂ᵢ[μ] Y) (hX : Integrable X μ) (hY : Integrable Y μ) + (B : E →L[ℝ] F →L[ℝ] G) : + ∫ ω, B (X ω) (Y ω) ∂μ = B μ[X] μ[Y] := + hXY.integral_bilin_comp_comp hX.aemeasurable hY.aemeasurable + ((integrable_map_measure hX.aestronglyMeasurable.aestronglyMeasurable_id_map hX.aemeasurable).2 + hX) + ((integrable_map_measure hY.aestronglyMeasurable.aestronglyMeasurable_id_map hY.aemeasurable).2 + hY) B + +/-- If `X` and `Y` are random variables and `B` is a continuous bilinear map +such that `∀ x y, c * ‖x‖ * ‖y‖ ≤ ‖B x y‖`, then `∫ ω, B (X ω) (Y ω) ∂μ = B μ[X] μ[Y].` + +The assumption on `B` allows to drop the integrability condition in +`IndepFun.integral_bilin'`, which is useful for the versions where `B` is the scalar +multiplication or the multiplication. -/ +theorem IndepFun.integral_bilin' + [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace 𝕜 E] [CompleteSpace E] + [MeasurableSpace E] [BorelSpace E] + [NormedAddCommGroup F] [NormedSpace ℝ F] [NormedSpace 𝕜 F] [CompleteSpace F] + [MeasurableSpace F] [BorelSpace F] + [NormedAddCommGroup G] [NormedSpace ℝ G] [NormedSpace 𝕜 G] [CompleteSpace G] + {X : Ω → E} {Y : Ω → F} (hXY : X ⟂ᵢ[μ] Y) (hX : AEStronglyMeasurable X μ) + (hY : AEStronglyMeasurable Y μ) + (B : E →L[ℝ] F →L[ℝ] G) (c : ℝ≥0) (hc : c ≠ 0) (hB : ∀ x y, c * ‖x‖ * ‖y‖ ≤ ‖B x y‖) : + ∫ ω, B (X ω) (Y ω) ∂μ = B μ[X] μ[Y] := + hXY.integral_bilin_comp_comp' hX.aemeasurable hY.aemeasurable + hX.aestronglyMeasurable_id_map hY.aestronglyMeasurable_id_map B c hc hB + +/-- The scalar product of two independent and integrable random variables is integrable. -/ +theorem IndepFun.integrable_smul + [TopologicalSpace E] [ContinuousENorm E] [MeasurableSpace E] [OpensMeasurableSpace E] + [TopologicalSpace F] [ContinuousENorm F] [MeasurableSpace F] [OpensMeasurableSpace F] + [SMul E F] [ContinuousSMul E F] [ENormSMulClass E F] + {X : Ω → E} {Y : Ω → F} (hXY : X ⟂ᵢ[μ] Y) (hX : Integrable X μ) (hY : Integrable Y μ) : + Integrable (fun ω ↦ (X ω) • (Y ω)) μ := + hXY.integrable_op hX hY (· • ·) (by fun_prop) 1 (by simp [enorm_smul]) + +/-- The product of two independent and integrable random variables is integrable. -/ +theorem IndepFun.integrable_mul + [TopologicalSpace E] [ContinuousENorm E] [Mul E] [ContinuousMul E] [ENormSMulClass E E] + [MeasurableSpace E] [OpensMeasurableSpace E] + {X Y : Ω → E} (hXY : X ⟂ᵢ[μ] Y) (hX : Integrable X μ) (hY : Integrable Y μ) : + Integrable (X * Y) μ := hXY.integrable_smul hX hY + +@[deprecated (since := "2026-04-30")] alias IndepFun.integrable_left_of_integrable_mul := + IndepFun.integrable_left_of_integrable_op + +@[deprecated (since := "2026-04-30")] alias IndepFun.integrable_right_of_integrable_mul := + IndepFun.integrable_right_of_integrable_op + +lemma IndepFun.integral_fun_comp_smul_comp + [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace 𝕜 E] + {X : Ω → 𝓧} {Y : Ω → 𝓨} {f : 𝓧 → 𝕜} {g : 𝓨 → E} + (hXY : X ⟂ᵢ[μ] Y) (hX : AEMeasurable X μ) (hY : AEMeasurable Y μ) + (hf : AEStronglyMeasurable f (μ.map X)) (hg : AEStronglyMeasurable g (μ.map Y)) : + ∫ ω, f (X ω) • g (Y ω) ∂μ = (∫ ω, f (X ω) ∂μ) • (∫ ω, g (Y ω) ∂μ) := by + by_cases hE : CompleteSpace E + · exact hXY.integral_bilin_comp_comp' hX hY hf hg (.lsmul ℝ 𝕜) 1 (by simp) (by simp [norm_smul]) + · simp [integral, hE] + +lemma IndepFun.integral_fun_comp_mul_comp + {X : Ω → 𝓧} {Y : Ω → 𝓨} {f : 𝓧 → 𝕜} {g : 𝓨 → 𝕜} + (hXY : X ⟂ᵢ[μ] Y) (hX : AEMeasurable X μ) (hY : AEMeasurable Y μ) + (hf : AEStronglyMeasurable f (μ.map X)) (hg : AEStronglyMeasurable g (μ.map Y)) : + ∫ ω, f (X ω) * g (Y ω) ∂μ = (∫ ω, f (X ω) ∂μ) * (∫ ω, g (Y ω) ∂μ) := + hXY.integral_fun_comp_smul_comp hX hY hf hg + +lemma IndepFun.integral_comp_smul_comp + [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace 𝕜 E] + {X : Ω → 𝓧} {Y : Ω → 𝓨} {f : 𝓧 → 𝕜} {g : 𝓨 → E} + (hXY : X ⟂ᵢ[μ] Y) (hX : AEMeasurable X μ) (hY : AEMeasurable Y μ) + (hf : AEStronglyMeasurable f (μ.map X)) (hg : AEStronglyMeasurable g (μ.map Y)) : + μ[(f ∘ X) • (g ∘ Y)] = μ[f ∘ X] • μ[g ∘ Y] := + hXY.integral_fun_comp_smul_comp hX hY hf hg + +lemma IndepFun.integral_comp_mul_comp + {X : Ω → 𝓧} {Y : Ω → 𝓨} {f : 𝓧 → 𝕜} {g : 𝓨 → 𝕜} (hXY : X ⟂ᵢ[μ] Y) (hX : AEMeasurable X μ) (hY : AEMeasurable Y μ) (hf : AEStronglyMeasurable f (μ.map X)) (hg : AEStronglyMeasurable g (μ.map Y)) : μ[(f ∘ X) * (g ∘ Y)] = μ[f ∘ X] * μ[g ∘ Y] := hXY.integral_fun_comp_mul_comp hX hY hf hg +lemma IndepFun.integral_smul_eq_smul_integral + [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace 𝕜 E] [MeasurableSpace E] [BorelSpace E] + {X : Ω → 𝕜} {Y : Ω → E} (hXY : X ⟂ᵢ[μ] Y) + (hX : AEStronglyMeasurable X μ) (hY : AEStronglyMeasurable Y μ) : + μ[X • Y] = μ[X] • μ[Y] := by + by_cases hE : CompleteSpace E + · exact hXY.integral_bilin' (𝕜 := 𝕜) hX hY (.lsmul ℝ 𝕜) 1 (by simp) (by simp [norm_smul]) + · simp [integral, hE] + lemma IndepFun.integral_mul_eq_mul_integral (hXY : X ⟂ᵢ[μ] Y) (hX : AEStronglyMeasurable X μ) (hY : AEStronglyMeasurable Y μ) : μ[X * Y] = μ[X] * μ[Y] := - hXY.integral_comp_mul_comp hX.aemeasurable hY.aemeasurable - aestronglyMeasurable_id aestronglyMeasurable_id + hXY.integral_smul_eq_smul_integral hX hY + +lemma IndepFun.integral_fun_smul_eq_smul_integral + [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace 𝕜 E] [MeasurableSpace E] [BorelSpace E] + {X : Ω → 𝕜} {Y : Ω → E} (hXY : X ⟂ᵢ[μ] Y) + (hX : AEStronglyMeasurable X μ) (hY : AEStronglyMeasurable Y μ) : + ∫ ω, X ω • Y ω ∂μ = (∫ ω, X ω ∂μ) • ∫ ω, Y ω ∂μ := + hXY.integral_smul_eq_smul_integral hX hY lemma IndepFun.integral_fun_mul_eq_mul_integral (hXY : X ⟂ᵢ[μ] Y) (hX : AEStronglyMeasurable X μ) (hY : AEStronglyMeasurable Y μ) : ∫ ω, X ω * Y ω ∂μ = μ[X] * μ[Y] := - hXY.integral_mul_eq_mul_integral hX hY + hXY.integral_fun_smul_eq_smul_integral hX hY + +end Integral /-- Independence of functions `f` and `g` into arbitrary types is characterized by the relation `E[(φ ∘ f) * (ψ ∘ g)] = E[φ ∘ f] * E[ψ ∘ g]` for all measurable `φ` and `ψ` with values in `ℝ` @@ -271,10 +443,10 @@ theorem indepFun_iff_integral_comp_mul [IsFiniteMeasure μ] {β β' : Type*} {m h (measurable_one.indicator hA) (measurable_one.indicator hB) ((integrable_const 1).indicator (hfm.comp measurable_id hA)) ((integrable_const 1).indicator (hgm.comp measurable_id hB)) - rwa [← ENNReal.toReal_eq_toReal_iff' (measure_ne_top μ _), ENNReal.toReal_mul, ← measureReal_def, + rwa [← toReal_eq_toReal_iff' (measure_ne_top μ _), toReal_mul, ← measureReal_def, ← measureReal_def, ← measureReal_def, ← integral_indicator_one ((hfm hA).inter (hgm hB)), ← integral_indicator_one (hfm hA), ← integral_indicator_one (hgm hB), Set.inter_indicator_one] - exact ENNReal.mul_ne_top (measure_ne_top μ _) (measure_ne_top μ _) + exact mul_ne_top (measure_ne_top μ _) (measure_ne_top μ _) variable {ι : Type*} [Fintype ι] {𝓧 : ι → Type*} {m𝓧 : ∀ i, MeasurableSpace (𝓧 i)} {X : (i : ι) → Ω → 𝓧 i} {f : (i : ι) → 𝓧 i → 𝕜} @@ -285,18 +457,18 @@ lemma iIndepFun.integral_fun_prod_comp (hX : iIndepFun X μ) have := hX.isProbabilityMeasure change ∫ ω, (fun x ↦ ∏ i, f i (x i)) (X · ω) ∂μ = _ rw [← integral_map (f := fun x ↦ ∏ i, f i (x i)) (φ := fun ω ↦ (X · ω)), - (iIndepFun_iff_map_fun_eq_pi_map mX).1 hX, integral_fintype_prod_eq_prod] + hX.map_fun_eq_pi_map mX, integral_fintype_prod_eq_prod] · congr with i rw [integral_map (mX i) (hf i)] · fun_prop - rw [(iIndepFun_iff_map_fun_eq_pi_map mX).1 hX] + rw [hX.map_fun_eq_pi_map mX] exact Finset.aestronglyMeasurable_fun_prod Finset.univ fun i _ ↦ (hf i).comp_quasiMeasurePreserving (Measure.quasiMeasurePreserving_eval _ i) lemma iIndepFun.integral_prod_comp (hX : iIndepFun X μ) (mX : ∀ i, AEMeasurable (X i) μ) (hf : ∀ i, AEStronglyMeasurable (f i) (μ.map (X i))) : μ[∏ i, (f i) ∘ (X i)] = ∏ i, μ[(f i) ∘ (X i)] := by - convert hX.integral_fun_prod_comp mX hf + convert! hX.integral_fun_prod_comp mX hf simp variable {X : (i : ι) → Ω → 𝕜} diff --git a/Mathlib/Probability/Independence/Kernel/Indep.lean b/Mathlib/Probability/Independence/Kernel/Indep.lean index 1ba152009dbc17..405d16226bb0bd 100644 --- a/Mathlib/Probability/Independence/Kernel/Indep.lean +++ b/Mathlib/Probability/Independence/Kernel/Indep.lean @@ -224,7 +224,7 @@ lemma iIndepSets.precomp (hg : Function.Injective g) (h : iIndepSets π κ μ) : lemma iIndepSets.of_precomp (hg : Function.Surjective g) (h : iIndepSets (π ∘ g) κ μ) : iIndepSets π κ μ := by obtain ⟨g', hg'⟩ := hg.hasRightInverse - convert h.precomp hg'.injective + convert! h.precomp hg'.injective rw [Function.comp_assoc, hg'.comp_eq_id, Function.comp_id] lemma iIndepSets_precomp_of_bijective (hg : Function.Bijective g) : @@ -322,6 +322,12 @@ theorem indep_of_indep_of_le_right {m₁ m₂ m₃ : MeasurableSpace Ω} {_mΩ : Indep m₁ m₃ κ μ := fun t1 t2 ht1 ht2 => h_indep t1 t2 ht1 (h32 _ ht2) +theorem indep_of_indep_of_le {m₁ m₂ m₃ m₄ : MeasurableSpace Ω} {_mΩ : MeasurableSpace Ω} + {κ : Kernel α Ω} {μ : Measure α} (h_indep : Indep m₁ m₂ κ μ) + (h31 : m₃ ≤ m₁) (h42 : m₄ ≤ m₂) : + Indep m₃ m₄ κ μ := + indep_of_indep_of_le_left (indep_of_indep_of_le_right h_indep h42) h31 + theorem iIndep_of_iIndep_of_le {m₁ m₂ : ι → MeasurableSpace Ω} {_mΩ : MeasurableSpace Ω} {κ : Kernel α Ω} {μ : Measure α} (h_indep : iIndep m₂ κ μ) (h_le : ∀ i, m₁ i ≤ m₂ i) : iIndep m₁ κ μ := @@ -640,14 +646,16 @@ theorem indep_iSup_of_directed_le {Ω} {m : ι → MeasurableSpace Ω} {m' m0 : theorem iIndepSet.indep_generateFrom_lt [Preorder ι] {s : ι → Set Ω} (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s κ μ) (i : ι) : Indep (generateFrom {s i}) (generateFrom { t | ∃ j < i, s j = t }) κ μ := by - convert iIndepSet.indep_generateFrom_of_disjoint hsm hs {i} { j | j < i } - (Set.disjoint_singleton_left.mpr (lt_irrefl _)) using 1 + convert! + iIndepSet.indep_generateFrom_of_disjoint hsm hs { i } {j | j < i} + (Set.disjoint_singleton_left.mpr (lt_irrefl _)) using 1 simp only [Set.mem_singleton_iff, exists_eq_left, Set.setOf_eq_eq_singleton'] theorem iIndepSet.indep_generateFrom_le [Preorder ι] {s : ι → Set Ω} (hsm : ∀ n, MeasurableSet (s n)) (hs : iIndepSet s κ μ) (i : ι) {k : ι} (hk : i < k) : Indep (generateFrom {s k}) (generateFrom { t | ∃ j ≤ i, s j = t }) κ μ := by - convert iIndepSet.indep_generateFrom_of_disjoint hsm hs {k} { j | j ≤ i } + convert! + iIndepSet.indep_generateFrom_of_disjoint hsm hs { k } {j | j ≤ i} (Set.disjoint_singleton_left.mpr hk.not_ge) using 1 simp only [Set.mem_singleton_iff, exists_eq_left, Set.setOf_eq_eq_singleton'] diff --git a/Mathlib/Probability/Independence/Kernel/IndepFun.lean b/Mathlib/Probability/Independence/Kernel/IndepFun.lean index f856c5c9599c00..957fd84de29e9b 100644 --- a/Mathlib/Probability/Independence/Kernel/IndepFun.lean +++ b/Mathlib/Probability/Independence/Kernel/IndepFun.lean @@ -183,7 +183,7 @@ theorem iIndepFun.congr' {β : ι → Type*} {mβ : ∀ i, MeasurableSpace (β i filter_upwards [(ae_ball_iff (Finset.countable_toSet S)).2 ha] with ω hω change (ω ∈ ⋂ i ∈ S, g i ⁻¹' sets i) = (ω ∈ ⋂ i ∈ S, f i ⁻¹' sets i) simp +contextual [hω] - convert h'a using 2 with i hi + convert! h'a using 2 with i hi exact A i hi theorem iIndepFun_congr' {β : ι → Type*} {mβ : ∀ i, MeasurableSpace (β i)} @@ -317,7 +317,7 @@ theorem indepFun_iff_compProd_map_prod_eq_compProd_prod_map_map specialize h hu hs ht rw [Measure.compProd_apply_prod hu (hs.prod ht), Measure.compProd_apply_prod hu (hs.prod ht)] at h - convert h with ω ω + convert! h with ω ω · rw [map_apply' _ (by fun_prop) _ (hs.prod ht), mk_preimage_prod] · rw [prod_apply_prod, map_apply' _ (by fun_prop) _ hs, map_apply' _ (by fun_prop) _ ht] @@ -694,6 +694,12 @@ theorem iIndepSet.iIndepFun_indicator [Zero β] [One β] {m : MeasurableSpace β · exact @MeasurableSet.empty _ (generateFrom {s i}) · exact @MeasurableSet.empty _ (generateFrom {s i}) +lemma Indep.indicator_const_indepFun {m : MeasurableSpace Ω} {M 𝓧 : Type*} + [Zero M] [MeasurableSpace M] (c : M) [NeZero c] {m𝓧 : MeasurableSpace 𝓧} {A : Set Ω} + {X : Ω → 𝓧} (hA : MeasurableSet[m] A) (h : Indep m (m𝓧.comap X) κ μ) : + IndepFun (A.indicator (fun _ ↦ c)) X κ μ := + indep_of_indep_of_le_left h (measurable_const.indicator hA).comap_le + variable {mβ : MeasurableSpace β} {X : ι → Ω → α} {Y : ι → Ω → β} {f : _ → Set Ω} {t : ι → Set β} {s : Finset ι} diff --git a/Mathlib/Probability/Independence/Process/HasIndepIncrements/Basic.lean b/Mathlib/Probability/Independence/Process/HasIndepIncrements/Basic.lean index b62be7fb5b6801..5f84de13731fdf 100644 --- a/Mathlib/Probability/Independence/Process/HasIndepIncrements/Basic.lean +++ b/Mathlib/Probability/Independence/Process/HasIndepIncrements/Basic.lean @@ -76,7 +76,7 @@ protected lemma HasIndepIncrements.of_nat HasIndepIncrements X P := by intro n t ht let t' k := t ⟨min n k, by grind⟩ - convert (h t' ?_ ?_).precomp Fin.val_injective with i ω + convert! (h t' ?_ ?_).precomp Fin.val_injective with i ω · grind · grind · exact fun a b hab ↦ ht (by grind) diff --git a/Mathlib/Probability/Independence/ZeroOne.lean b/Mathlib/Probability/Independence/ZeroOne.lean index 898f585e473f4e..5b53aa6fbd10fd 100644 --- a/Mathlib/Probability/Independence/ZeroOne.lean +++ b/Mathlib/Probability/Independence/ZeroOne.lean @@ -61,11 +61,22 @@ theorem Kernel.measure_eq_zero_or_one_of_indepSet_self [h : ∀ a, IsFiniteMeasu ∀ᵐ a ∂μα, κ a t = 0 ∨ κ a t = 1 := Kernel.measure_eq_zero_or_one_of_indepSet_self' (ae_of_all μα h) h_indep +lemma Kernel.measure_eq_zero_or_one_of_indep_self [h : ∀ a, IsFiniteMeasure (κ a)] + (hm : Indep m m κ μα) {t : Set Ω} (ht : MeasurableSet[m] t) : + ∀ᵐ a ∂μα, κ a t = 0 ∨ κ a t = 1 := + measure_eq_zero_or_one_of_indepSet_self + (indep_of_indep_of_le hm (generateFrom_singleton_le ht) (generateFrom_singleton_le ht)) + theorem measure_eq_zero_or_one_of_indepSet_self [IsFiniteMeasure μ] {t : Set Ω} (h_indep : IndepSet t t μ) : μ t = 0 ∨ μ t = 1 := by simpa only [ae_dirac_eq, Filter.eventually_pure] using Kernel.measure_eq_zero_or_one_of_indepSet_self h_indep +lemma measure_eq_zero_or_one_of_indep_self [IsFiniteMeasure μ] (hm : Indep m m μ) + {t : Set Ω} (ht : MeasurableSet[m] t) : + μ t = 0 ∨ μ t = 1 := by + simpa using Kernel.measure_eq_zero_or_one_of_indep_self hm ht + theorem condExp_eq_zero_or_one_of_condIndepSet_self [StandardBorelSpace Ω] (hm : m ≤ m0) [hμ : IsFiniteMeasure μ] {t : Set Ω} (ht : MeasurableSet t) diff --git a/Mathlib/Probability/Kernel/Composition/CompProd.lean b/Mathlib/Probability/Kernel/Composition/CompProd.lean index 8e71864be34c07..f26a30e6b6084e 100644 --- a/Mathlib/Probability/Kernel/Composition/CompProd.lean +++ b/Mathlib/Probability/Kernel/Composition/CompProd.lean @@ -203,7 +203,7 @@ lemma compProd_deterministic_apply [MeasurableSingletonClass γ] {f : α × β let t := {b | (b, f (x, b)) ∈ s} have ht : MeasurableSet t := (measurable_id.prodMk (hf.comp measurable_prodMk_left)) hs rw [← lintegral_add_compl _ ht] - convert add_zero _ + convert! add_zero _ · suffices ∀ b ∈ tᶜ, (if f (x, b) ∈ Prod.mk b ⁻¹' s then (1 : ℝ≥0∞) else 0) = 0 by rw [setLIntegral_congr_fun ht.compl this, lintegral_zero] intro b hb diff --git a/Mathlib/Probability/Kernel/Composition/IntegralCompProd.lean b/Mathlib/Probability/Kernel/Composition/IntegralCompProd.lean index 6395d12eaccb7b..10da44a776915b 100644 --- a/Mathlib/Probability/Kernel/Composition/IntegralCompProd.lean +++ b/Mathlib/Probability/Kernel/Composition/IntegralCompProd.lean @@ -108,7 +108,7 @@ theorem hasFiniteIntegral_compProd_iff ⦃f : β × γ → E⦄ (h1f : StronglyM have : ∀ x, ∀ᵐ y ∂η (a, x), 0 ≤ ‖f (x, y)‖ := fun x => Eventually.of_forall fun y => norm_nonneg _ simp_rw [integral_eq_lintegral_of_nonneg_ae (this _) (h1f.norm.comp_measurable measurable_prodMk_left).aestronglyMeasurable, - enorm_eq_ofReal toReal_nonneg, ofReal_norm_eq_enorm] + enorm_eq_ofReal toReal_nonneg, ofReal_norm] have : ∀ {p q r : Prop} (_ : r → p), (r ↔ p ∧ q) ↔ p → (r ↔ q) := fun {p q r} h1 => by rw [← and_congr_right_iff, and_iff_right_of_imp h1] rw [this] @@ -216,7 +216,7 @@ theorem Kernel.continuous_integral_integral : Continuous fun f : β × γ →₁[(κ ⊗ₖ η) a] E => ∫ x, ∫ y, f (x, y) ∂η (a, x) ∂κ a := by rw [continuous_iff_continuousAt]; intro g refine - tendsto_integral_of_L1 _ (L1.integrable_coeFn g).integral_compProd + tendsto_integral_of_L1 _ (L1.integrable_coeFn g).integral_compProd.aestronglyMeasurable (Eventually.of_forall fun h => (L1.integrable_coeFn h).integral_compProd) ?_ simp_rw [← lintegral_fn_integral_sub (‖·‖ₑ) (L1.integrable_coeFn _) (L1.integrable_coeFn g)] apply tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds _ (fun i => zero_le) _ @@ -254,7 +254,7 @@ theorem integral_compProd : simp_rw [integral_add' i_f i_g, Kernel.integral_integral_add' i_f i_g, hf, hg] · exact isClosed_eq continuous_integral Kernel.continuous_integral_integral · intro f g hfg _ hf - convert hf using 1 + convert! hf using 1 · exact integral_congr_ae hfg.symm · apply integral_congr_ae filter_upwards [ae_ae_of_ae_compProd hfg] with x hfgx using @@ -303,7 +303,7 @@ theorem hasFiniteIntegral_comp_iff ⦃f : γ → E⦄ (hf : StronglyMeasurable f (∀ᵐ x ∂κ a, HasFiniteIntegral f (η x)) ∧ HasFiniteIntegral (fun x ↦ ∫ y, ‖f y‖ ∂η x) (κ a) := by simp_rw [hasFiniteIntegral_iff_enorm, lintegral_comp _ _ _ hf.enorm] simp_rw [integral_eq_lintegral_of_nonneg_ae (ae_of_all _ fun y ↦ norm_nonneg _) - hf.norm.aestronglyMeasurable, enorm_eq_ofReal toReal_nonneg, ofReal_norm_eq_enorm] + hf.norm.aestronglyMeasurable, enorm_eq_ofReal toReal_nonneg, ofReal_norm] have : ∀ {p q r : Prop} (_ : r → p), (r ↔ p ∧ q) ↔ p → (r ↔ q) := fun h ↦ by rw [← and_congr_right_iff, and_iff_right_of_imp h] rw [this] @@ -401,7 +401,7 @@ theorem integral_integral_sub'_comp ⦃f g : γ → E⦄ (hf : Integrable f ((η theorem continuous_integral_integral_comp : Continuous fun f : γ →₁[(η ∘ₖ κ) a] E ↦ ∫ x, ∫ y, f y ∂η x ∂κ a := by refine continuous_iff_continuousAt.2 fun g ↦ ?_ - refine tendsto_integral_of_L1 _ (L1.integrable_coeFn g).integral_comp + refine tendsto_integral_of_L1 _ (L1.integrable_coeFn g).integral_comp.aestronglyMeasurable (Eventually.of_forall fun h ↦ (L1.integrable_coeFn h).integral_comp) ?_ simp_rw [← lintegral_fn_integral_sub_comp (‖·‖ₑ) (L1.integrable_coeFn _) (L1.integrable_coeFn g)] refine tendsto_of_tendsto_of_tendsto_of_le_of_le @@ -429,7 +429,7 @@ theorem integral_comp : ∀ {f : γ → E} (_ : Integrable f ((η ∘ₖ κ) a)) simp_rw [integral_add' i_f i_g, integral_integral_add'_comp i_f i_g, hf, hg] · exact isClosed_eq continuous_integral Kernel.continuous_integral_integral_comp · rintro f g hfg - hf - convert hf using 1 + convert! hf using 1 · exact integral_congr_ae hfg.symm · apply integral_congr_ae filter_upwards [ae_ae_of_ae_comp hfg] with x hfgx using integral_congr_ae (ae_eq_symm hfgx) diff --git a/Mathlib/Probability/Kernel/Composition/MeasureCompProd.lean b/Mathlib/Probability/Kernel/Composition/MeasureCompProd.lean index cd7d039fbe6cc8..cccee8bacd55fe 100644 --- a/Mathlib/Probability/Kernel/Composition/MeasureCompProd.lean +++ b/Mathlib/Probability/Kernel/Composition/MeasureCompProd.lean @@ -118,7 +118,7 @@ lemma ae_compProd_of_ae_ae {p : α × β → Prop} lemma ae_ae_of_ae_compProd [SFinite μ] [IsSFiniteKernel κ] {p : α × β → Prop} (h : ∀ᵐ x ∂(μ ⊗ₘ κ), p x) : ∀ᵐ a ∂μ, ∀ᵐ b ∂κ a, p (a, b) := by - convert Kernel.ae_ae_of_ae_compProd h -- Much faster with `convert` + convert! Kernel.ae_ae_of_ae_compProd h -- Much faster with `convert` lemma ae_compProd_iff [SFinite μ] [IsSFiniteKernel κ] {p : α × β → Prop} (hp : MeasurableSet {x | p x}) : diff --git a/Mathlib/Probability/Kernel/CondDistrib.lean b/Mathlib/Probability/Kernel/CondDistrib.lean index 4f72713b65caa0..d6d06dde390bee 100644 --- a/Mathlib/Probability/Kernel/CondDistrib.lean +++ b/Mathlib/Probability/Kernel/CondDistrib.lean @@ -155,7 +155,7 @@ theorem condDistrib_ae_eq_of_measure_eq_compProd_of_measurable rw [heq, condDistrib] symm refine eq_condKernel_of_measure_eq_compProd _ ?_ - convert hκ + convert! hκ exact heq.symm /-- `condDistrib` is a.e. uniquely defined as the kernel satisfying the defining property of diff --git a/Mathlib/Probability/Kernel/Condexp.lean b/Mathlib/Probability/Kernel/Condexp.lean index f33d0180280056..092f097a758ffa 100644 --- a/Mathlib/Probability/Kernel/Condexp.lean +++ b/Mathlib/Probability/Kernel/Condexp.lean @@ -168,35 +168,35 @@ theorem _root_.MeasureTheory.Integrable.condExpKernel_ae (hf_int : Integrable f ∀ᵐ ω ∂μ, Integrable f (condExpKernel μ m ω) := by nontriviality Ω rw [condExpKernel_eq] - convert Integrable.condDistrib_ae - (aemeasurable_id'' μ (inf_le_right : m ⊓ mΩ ≤ mΩ)) aemeasurable_id - hf_int.comp_snd_map_prod_id using 1 + convert! + Integrable.condDistrib_ae (aemeasurable_id'' μ (inf_le_right : m ⊓ mΩ ≤ mΩ)) aemeasurable_id + hf_int.comp_snd_map_prod_id using 1 theorem _root_.MeasureTheory.Integrable.integral_norm_condExpKernel (hf_int : Integrable f μ) : Integrable (fun ω => ∫ y, ‖f y‖ ∂condExpKernel μ m ω) μ := by nontriviality Ω rw [condExpKernel_eq] - convert Integrable.integral_norm_condDistrib - (aemeasurable_id'' μ (inf_le_right : m ⊓ mΩ ≤ mΩ)) aemeasurable_id - hf_int.comp_snd_map_prod_id using 1 + convert! + Integrable.integral_norm_condDistrib (aemeasurable_id'' μ (inf_le_right : m ⊓ mΩ ≤ mΩ)) + aemeasurable_id hf_int.comp_snd_map_prod_id using 1 theorem _root_.MeasureTheory.Integrable.norm_integral_condExpKernel [NormedSpace ℝ F] (hf_int : Integrable f μ) : Integrable (fun ω => ‖∫ y, f y ∂condExpKernel μ m ω‖) μ := by nontriviality Ω rw [condExpKernel_eq] - convert Integrable.norm_integral_condDistrib - (aemeasurable_id'' μ (inf_le_right : m ⊓ mΩ ≤ mΩ)) aemeasurable_id - hf_int.comp_snd_map_prod_id using 1 + convert! + Integrable.norm_integral_condDistrib (aemeasurable_id'' μ (inf_le_right : m ⊓ mΩ ≤ mΩ)) + aemeasurable_id hf_int.comp_snd_map_prod_id using 1 theorem _root_.MeasureTheory.Integrable.integral_condExpKernel [NormedSpace ℝ F] (hf_int : Integrable f μ) : Integrable (fun ω => ∫ y, f y ∂condExpKernel μ m ω) μ := by nontriviality Ω rw [condExpKernel_eq] - convert Integrable.integral_condDistrib - (aemeasurable_id'' μ (inf_le_right : m ⊓ mΩ ≤ mΩ)) aemeasurable_id - hf_int.comp_snd_map_prod_id using 1 + convert! + Integrable.integral_condDistrib (aemeasurable_id'' μ (inf_le_right : m ⊓ mΩ ≤ mΩ)) + aemeasurable_id hf_int.comp_snd_map_prod_id using 1 theorem integrable_toReal_condExpKernel {s : Set Ω} (hs : MeasurableSet s) : Integrable (fun ω => (condExpKernel μ m ω).real s) μ := by diff --git a/Mathlib/Probability/Kernel/Disintegration/Basic.lean b/Mathlib/Probability/Kernel/Disintegration/Basic.lean index d6f44c2f014e5c..b8342df3429a1a 100644 --- a/Mathlib/Probability/Kernel/Disintegration/Basic.lean +++ b/Mathlib/Probability/Kernel/Disintegration/Basic.lean @@ -140,7 +140,7 @@ lemma IsCondKernel.isProbabilityMeasure_ae [IsFiniteKernel κ.fst] [κ.IsCondKer by_cases h_sfin : IsSFiniteKernel κCond swap; · rw [Kernel.compProd_of_not_isSFiniteKernel_right _ _ h_sfin] at h; simp [h.symm] suffices ∀ᵐ b ∂(κ.fst a), κCond (a, b) Set.univ = 1 by - convert this with b + convert! this with b exact ⟨fun _ ↦ measure_univ, fun h ↦ ⟨h⟩⟩ suffices (∀ᵐ b ∂(κ.fst a), κCond (a, b) Set.univ ≤ 1) ∧ (∀ᵐ b ∂(κ.fst a), 1 ≤ κCond (a, b) Set.univ) by diff --git a/Mathlib/Probability/Kernel/Disintegration/CondCDF.lean b/Mathlib/Probability/Kernel/Disintegration/CondCDF.lean index 98014ab2edbba8..d97e716fd4583f 100644 --- a/Mathlib/Probability/Kernel/Disintegration/CondCDF.lean +++ b/Mathlib/Probability/Kernel/Disintegration/CondCDF.lean @@ -194,7 +194,7 @@ lemma integrable_preCDF (ρ : Measure (α × ℝ)) [IsFiniteMeasure ρ] (x : ℚ Integrable (fun a ↦ (preCDF ρ x a).toReal) ρ.fst := by refine integrable_of_forall_fin_meas_le _ (measure_lt_top ρ.fst univ) ?_ fun t _ _ ↦ ?_ · exact measurable_preCDF.ennreal_toReal.aestronglyMeasurable - · simp_rw [← ofReal_norm_eq_enorm, Real.norm_of_nonneg ENNReal.toReal_nonneg] + · simp_rw [← ofReal_norm, Real.norm_of_nonneg ENNReal.toReal_nonneg] rw [← lintegral_one] refine (setLIntegral_le_lintegral _ _).trans (lintegral_mono_ae ?_) filter_upwards [preCDF_le_one ρ] with a ha using ENNReal.ofReal_toReal_le.trans (ha _) diff --git a/Mathlib/Probability/Kernel/Disintegration/Density.lean b/Mathlib/Probability/Kernel/Disintegration/Density.lean index 2f18ebc7c8f1a6..fef71b6257be3a 100644 --- a/Mathlib/Probability/Kernel/Disintegration/Density.lean +++ b/Mathlib/Probability/Kernel/Disintegration/Density.lean @@ -499,7 +499,8 @@ lemma tendsto_setIntegral_densityProcess (hκν : fst κ ≤ ν) Tendsto (fun i ↦ ∫ x in A, densityProcess κ ν i a x s ∂(ν a)) atTop (𝓝 (∫ x in A, density κ ν a x s ∂(ν a))) := by refine tendsto_setIntegral_of_L1' (μ := ν a) (fun x ↦ density κ ν a x s) - (integrable_density hκν a hs) (F := fun i x ↦ densityProcess κ ν i a x s) (l := atTop) + (integrable_density hκν a hs).aestronglyMeasurable + (F := fun i x ↦ densityProcess κ ν i a x s) (l := atTop) (Eventually.of_forall (fun n ↦ integrable_densityProcess hκν _ _ hs)) ?_ A refine (tendsto_congr fun n ↦ ?_).mp (tendsto_eLpNorm_one_densityProcess_limitProcess hκν a hs) refine eLpNorm_congr_ae ?_ @@ -600,7 +601,7 @@ lemma tendsto_integral_density_of_monotone (hκν : fst κ ≤ ν) [IsFiniteKern · simp only [mem_Iio] exact ENNReal.lt_add_right (measure_ne_top _ _) one_ne_zero refine h_cont.tendsto.comp ?_ - convert tendsto_measure_iUnion_atTop (monotone_const.set_prod hseq) + convert! tendsto_measure_iUnion_atTop (monotone_const.set_prod hseq) rw [← prod_iUnion, hseq_iUnion, univ_prod_univ] lemma tendsto_integral_density_of_antitone (hκν : fst κ ≤ ν) [IsFiniteKernel ν] (a : α) @@ -703,14 +704,14 @@ lemma tendsto_densityProcess_fst_atTop_univ_of_monotone (κ : Kernel α (γ × simp only [this, h0, ENNReal.zero_div, tendsto_const_nhds_iff] suffices κ a (countablePartitionSet n x ×ˢ univ) = 0 by simp only [this, ENNReal.zero_div] - convert h0 + convert! h0 ext x simp only [mem_prod, mem_univ, and_true, mem_setOf_eq] refine fun m ↦ measure_mono_null (fun x ↦ ?_) h0 simp only [mem_prod, mem_setOf_eq, and_imp] exact fun h _ ↦ h refine ENNReal.Tendsto.div_const ?_ ?_ - · convert tendsto_measure_iUnion_atTop (monotone_const.set_prod hseq) + · convert! tendsto_measure_iUnion_atTop (monotone_const.set_prod hseq) rw [← prod_iUnion, hseq_iUnion] · exact Or.inr h0 @@ -735,7 +736,7 @@ lemma tendsto_density_fst_atTop_ae_of_monotone [IsFiniteKernel κ] refine tendsto_of_integral_tendsto_of_monotone ?_ (integrable_const _) ?_ ?_ ?_ · exact fun m ↦ integrable_density le_rfl _ (hseq_meas m) · rw [MeasureTheory.integral_const, smul_eq_mul, mul_one] - convert tendsto_integral_density_of_monotone (κ := κ) le_rfl a seq hseq hseq_iUnion hseq_meas + convert! tendsto_integral_density_of_monotone (κ := κ) le_rfl a seq hseq hseq_iUnion hseq_meas simp only [measureReal_def] rw [fst_apply' _ _ MeasurableSet.univ] simp only [mem_univ, setOf_true] diff --git a/Mathlib/Probability/Kernel/Disintegration/MeasurableStieltjes.lean b/Mathlib/Probability/Kernel/Disintegration/MeasurableStieltjes.lean index 59fbab81c264ca..9f51f0ecb5e416 100644 --- a/Mathlib/Probability/Kernel/Disintegration/MeasurableStieltjes.lean +++ b/Mathlib/Probability/Kernel/Disintegration/MeasurableStieltjes.lean @@ -325,7 +325,7 @@ lemma IsMeasurableRatCDF.monotone_stieltjesFunctionAux (a : α) : lemma IsMeasurableRatCDF.continuousWithinAt_stieltjesFunctionAux_Ici (a : α) (x : ℝ) : ContinuousWithinAt (IsMeasurableRatCDF.stieltjesFunctionAux f a) (Ici x) x := by rw [← continuousWithinAt_Ioi_iff_Ici] - convert Monotone.tendsto_nhdsGT (monotone_stieltjesFunctionAux hf a) x + convert! Monotone.tendsto_nhdsGT (monotone_stieltjesFunctionAux hf a) x rw [sInf_image'] have h' : ⨅ r : Ioi x, stieltjesFunctionAux f a r = ⨅ r : { r' : ℚ // x < r' }, stieltjesFunctionAux f a r := by diff --git a/Mathlib/Probability/Kernel/IonescuTulcea/Maps.lean b/Mathlib/Probability/Kernel/IonescuTulcea/Maps.lean index 1c308f46a8283f..83efa31050eeba 100644 --- a/Mathlib/Probability/Kernel/IonescuTulcea/Maps.lean +++ b/Mathlib/Probability/Kernel/IonescuTulcea/Maps.lean @@ -180,9 +180,9 @@ lemma _root_.IicProdIoc_preimage {a b : ι} (hab : a ≤ b) (s : (i : Iic b) → simp only [Set.mem_preimage, Set.mem_pi, Set.mem_univ, IicProdIoc_def, forall_const, Subtype.forall, mem_Iic, Set.mem_prod, frestrictLe₂_apply, restrict₂, mem_Ioc] refine ⟨fun h ↦ ⟨fun i hi ↦ ?_, fun i ⟨hi1, hi2⟩ ↦ ?_⟩, fun ⟨h1, h2⟩ i hi ↦ ?_⟩ - · convert h i (hi.trans hab) + · convert! h i (hi.trans hab) rw [dif_pos hi] - · convert h i hi2 + · convert! h i hi2 rw [dif_neg (not_le.2 hi1)] · split_ifs with hi3 · exact h1 i hi3 diff --git a/Mathlib/Probability/Kernel/IonescuTulcea/Traj.lean b/Mathlib/Probability/Kernel/IonescuTulcea/Traj.lean index e0a5e01c262f80..e5c7bf015a6e5e 100644 --- a/Mathlib/Probability/Kernel/IonescuTulcea/Traj.lean +++ b/Mathlib/Probability/Kernel/IonescuTulcea/Traj.lean @@ -329,7 +329,7 @@ theorem le_lmarginalPartialTraj_succ {f : ℕ → (Π n, X n) → ℝ≥0∞} {a have := le_trans hx ((anti _).le_of_tendsto (tendstoF _) n) -- This part below is just to say that this is true for any `x : (i : ι) → X i`, -- as `Fₙ` technically depends on all the variables, but really depends only on the first `k + 1`. - convert this using 1 + convert! this using 1 refine (hcte n).dependsOn_lmarginalPartialTraj _ (mf n) fun i hi ↦ ?_ simp only [update, updateFinset, mem_Iic] split_ifs with h1 h2 <;> try rfl @@ -426,7 +426,7 @@ theorem trajContent_tendsto_zero {A : ℕ → Set (Π n, X n)} | base => exact fun x n ↦ by simpa [z, frestrictLe_iterateInduction] using hpos x n | succ k hn h => intro x n - convert hind k (fun i ↦ z i.1) h x n + convert! hind k (fun i ↦ z i.1) h x n ext i simp only [updateFinset, mem_Iic, frestrictLe_apply, dite_eq_ite, update, z] split_ifs with h1 h2 h3 h4 h5 @@ -441,7 +441,7 @@ theorem trajContent_tendsto_zero {A : ℕ → Set (Π n, X n)} nth_rw 1 [← frestrictLe_updateFinset x x₀] exact trajContent_eq_lmarginalPartialTraj (mS n) .. simp_rw [aux z] - convert hl p _ + convert! hl p _ rw [hε] -- Which means that we want to prove that `ε = 0`. But if `ε > 0`, then for any `n`, -- choosing `k > aₙ` we get `ε ≤ χₙ(z₀, ..., z_{aₙ})` and therefore `z ∈ Aₙ`. @@ -613,7 +613,7 @@ theorem lintegral_traj₀ {a : ℕ} (x₀ : Π i : Iic a, X i) {f : (Π n, X n) (mf : AEMeasurable f (traj κ a x₀)) : ∫⁻ x, f x ∂traj κ a x₀ = ∫⁻ x, f (updateFinset x (Iic a) x₀) ∂traj κ a x₀ := by nth_rw 1 [← traj_map_updateFinset, MeasureTheory.lintegral_map'] - · convert mf + · convert! mf exact traj_map_updateFinset x₀ · exact measurable_updateFinset_left.aemeasurable @@ -630,7 +630,7 @@ theorem integrable_traj {a b : ℕ} (hab : a ≤ b) {f : (Π n, X n) → E} rw [← traj_comp_partialTraj hab, integrable_comp_iff] at i_f · apply ae_of_ae_map (p := fun x ↦ Integrable f (traj κ b x)) · fun_prop - · convert i_f.1 + · convert! i_f.1 rw [← traj_map_frestrictLe, Kernel.map_apply _ (measurable_frestrictLe _)] · exact i_f.aestronglyMeasurable @@ -649,7 +649,7 @@ theorem integral_traj {a : ℕ} (x₀ : Π i : Iic a, X i) {f : (Π n, X n) → ∫ x, f x ∂traj κ a x₀ = ∫ x, f (updateFinset x (Iic a) x₀) ∂traj κ a x₀ := by nth_rw 1 [← traj_map_updateFinset, integral_map] · exact measurable_updateFinset_left.aemeasurable - · convert mf + · convert! mf rw [traj_map_updateFinset] lemma partialTraj_compProd_traj {a b : ℕ} (hab : a ≤ b) (u : Π i : Iic a, X i) : @@ -699,7 +699,7 @@ theorem setIntegral_traj_partialTraj' {a b : ℕ} (hab : a ≤ b) {u : (Π i : I rw [← integral_integral_indicator _ _ _ hA, integral_traj_partialTraj' hab] · simp_rw [← Set.indicator_comp_right, ← integral_indicator (measurable_frestrictLe b hA)] rfl - convert hf.indicator (hA.prod .univ) + convert! hf.indicator (hA.prod .univ) ext ⟨x, y⟩ by_cases hx : x ∈ A <;> simp [uncurry_def, hx] diff --git a/Mathlib/Probability/Kernel/Posterior.lean b/Mathlib/Probability/Kernel/Posterior.lean index a3ea8f8586d04f..693ef7d21089ae 100644 --- a/Mathlib/Probability/Kernel/Posterior.lean +++ b/Mathlib/Probability/Kernel/Posterior.lean @@ -268,7 +268,10 @@ lemma rnDeriv_posterior_ae_prod (h_ac : ∀ᵐ ω ∂μ, κ ω ≪ κ ∘ₘ μ) lemma rnDeriv_posterior (h_ac : ∀ᵐ ω ∂μ, κ ω ≪ κ ∘ₘ μ) : ∀ᵐ ω ∂μ, ∀ᵐ x ∂(κ ∘ₘ μ), (κ†μ).rnDeriv (Kernel.const _ μ) x ω = κ.rnDeriv (Kernel.const _ (κ ∘ₘ μ)) ω x := by - convert Measure.ae_ae_of_ae_prod (rnDeriv_posterior_ae_prod h_ac) -- much faster than `exact` + convert! + Measure.ae_ae_of_ae_prod + (rnDeriv_posterior_ae_prod h_ac) -- much faster than `exact` + -- much faster than `exact` lemma rnDeriv_posterior_symm (h_ac : ∀ᵐ ω ∂μ, κ ω ≪ κ ∘ₘ μ) : ∀ᵐ x ∂(κ ∘ₘ μ), ∀ᵐ ω ∂μ, diff --git a/Mathlib/Probability/Martingale/Basic.lean b/Mathlib/Probability/Martingale/Basic.lean index a30e56290b0fcd..f7b8ad3773599f 100644 --- a/Mathlib/Probability/Martingale/Basic.lean +++ b/Mathlib/Probability/Martingale/Basic.lean @@ -46,7 +46,7 @@ open scoped NNReal ENNReal MeasureTheory ProbabilityTheory namespace MeasureTheory variable {Ω E ι : Type*} [Preorder ι] {m0 : MeasurableSpace Ω} {μ : Measure Ω} - [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] {f g : ι → Ω → E} {ℱ : Filtration ι m0} + [NormedAddCommGroup E] [NormedSpace ℝ E] {f g : ι → Ω → E} {ℱ : Filtration ι m0} /-- A family of functions `f : ι → Ω → E` is a martingale with respect to a filtration `ℱ` if `f` is strongly adapted with respect to `ℱ` and for all `i ≤ j`, `μ[f j | ℱ i] =ᵐ[μ] f i`. -/ @@ -92,6 +92,8 @@ protected theorem stronglyMeasurable (hf : Martingale f ℱ μ) (i : ι) : theorem condExp_ae_eq (hf : Martingale f ℱ μ) {i j : ι} (hij : i ≤ j) : μ[f j | ℱ i] =ᵐ[μ] f i := hf.2 i j hij +variable [CompleteSpace E] + protected theorem integrable (hf : Martingale f ℱ μ) (i : ι) : Integrable (f i) μ := integrable_condExp.congr (hf.condExp_ae_eq (le_refl i)) @@ -131,12 +133,12 @@ theorem submartingale [Preorder E] (hf : Martingale f ℱ μ) : Submartingale f end Martingale -theorem martingale_iff [PartialOrder E] : +theorem martingale_iff [CompleteSpace E] [PartialOrder E] : Martingale f ℱ μ ↔ Supermartingale f ℱ μ ∧ Submartingale f ℱ μ := ⟨fun hf => ⟨hf.supermartingale, hf.submartingale⟩, fun ⟨hf₁, hf₂⟩ => ⟨hf₁.1, fun i j hij => (hf₁.2.1 i j hij).antisymm (hf₂.2.1 i j hij)⟩⟩ -theorem martingale_condExp (f : Ω → E) (ℱ : Filtration ι m0) (μ : Measure Ω) +theorem martingale_condExp [CompleteSpace E] (f : Ω → E) (ℱ : Filtration ι m0) (μ : Measure Ω) [SigmaFiniteFiltration μ ℱ] : Martingale (fun i => μ[f | ℱ i]) ℱ μ := ⟨fun _ => stronglyMeasurable_condExp, fun _ j hij => condExp_condExp_of_le (ℱ.mono hij) (ℱ.le j)⟩ @@ -156,6 +158,8 @@ theorem condExp_ae_le [LE E] (hf : Supermartingale f ℱ μ) {i j : ι} (hij : i μ[f j | ℱ i] ≤ᵐ[μ] f i := hf.2.1 i j hij +variable [CompleteSpace E] + theorem setIntegral_le [PartialOrder E] [IsOrderedAddMonoid E] [IsOrderedModule ℝ E] [ClosedIciTopology E] [SigmaFiniteFiltration μ ℱ] {f : ι → Ω → E} (hf : Supermartingale f ℱ μ) {i j : ι} (hij : i ≤ j) {s : Set Ω} (hs : MeasurableSet[ℱ i] s) : @@ -208,6 +212,8 @@ theorem ae_le_condExp [LE E] (hf : Submartingale f ℱ μ) {i j : ι} (hij : i f i ≤ᵐ[μ] μ[f j | ℱ i] := hf.2.1 i j hij +variable [CompleteSpace E] + lemma congr [LE E] (hf : Submartingale f ℱ μ) (hg : StronglyAdapted ℱ g) (h_eq : ∀ t, f t =ᵐ[μ] g t) : Submartingale g ℱ μ := by @@ -290,6 +296,8 @@ theorem submartingale_of_setIntegral_le [SigmaFiniteFiltration μ ℱ] integral_sub' integrable_condExp.integrableOn (hint i).integrableOn, sub_nonneg, setIntegral_condExp (ℱ.le i) (hint j) hs] +variable [CompleteSpace E] + theorem submartingale_of_condExp_sub_nonneg [PartialOrder E] [IsOrderedAddMonoid E] [SigmaFiniteFiltration μ ℱ] {f : ι → Ω → E} (hadp : StronglyAdapted ℱ f) (hint : ∀ i, Integrable (f i) μ) (hf : ∀ i j, i ≤ j → 0 ≤ᵐ[μ] μ[f j - f i | ℱ i]) : @@ -319,11 +327,11 @@ end Submartingale namespace Supermartingale -theorem sub_submartingale [Preorder E] [AddLeftMono E] +theorem sub_submartingale [CompleteSpace E] [Preorder E] [AddLeftMono E] (hf : Supermartingale f ℱ μ) (hg : Submartingale g ℱ μ) : Supermartingale (f - g) ℱ μ := by rw [sub_eq_add_neg]; exact hf.add hg.neg -theorem sub_martingale [Preorder E] [AddLeftMono E] +theorem sub_martingale [CompleteSpace E] [Preorder E] [AddLeftMono E] (hf : Supermartingale f ℱ μ) (hg : Martingale g ℱ μ) : Supermartingale (f - g) ℱ μ := hf.sub_submartingale hg.submartingale @@ -398,7 +406,8 @@ end OfSetIntegral section OfSucc -variable [PartialOrder E] [IsOrderedAddMonoid E] [ClosedIciTopology E] [IsOrderedModule ℝ E] +variable [CompleteSpace E] [PartialOrder E] [IsOrderedAddMonoid E] [ClosedIciTopology E] + [IsOrderedModule ℝ E] theorem submartingale_nat [IsFiniteMeasure μ] {f : ℕ → Ω → E} (hadp : StronglyAdapted 𝒢 f) (hint : ∀ i, Integrable (f i) μ) (hf : ∀ i, f i ≤ᵐ[μ] μ[f (i + 1) | 𝒢 i]) : @@ -467,7 +476,8 @@ end Preorder end SubSuper -theorem martingale_nat [IsFiniteMeasure μ] {f : ℕ → Ω → E} (hadp : StronglyAdapted 𝒢 f) +theorem martingale_nat [CompleteSpace E] [IsFiniteMeasure μ] + {f : ℕ → Ω → E} (hadp : StronglyAdapted 𝒢 f) (hint : ∀ i, Integrable (f i) μ) (hf : ∀ i, f i =ᵐ[μ] μ[f (i + 1) | 𝒢 i]) : Martingale f 𝒢 μ := by refine ⟨hadp, fun i j hij ↦ ?_⟩ @@ -480,7 +490,7 @@ theorem martingale_nat [IsFiniteMeasure μ] {f : ℕ → Ω → E} (hadp : Stron with ω hω1 hω2 hω3 rw [← hω1, hω2, hω3] -theorem martingale_of_setIntegral_eq_succ [IsFiniteMeasure μ] {f : ℕ → Ω → E} +theorem martingale_of_setIntegral_eq_succ [CompleteSpace E] [IsFiniteMeasure μ] {f : ℕ → Ω → E} (hadp : StronglyAdapted 𝒢 f) (hint : ∀ i, Integrable (f i) μ) (hf : ∀ i, ∀ s : Set Ω, MeasurableSet[𝒢 i] s → ∫ ω in s, f i ω ∂μ = ∫ ω in s, f (i + 1) ω ∂μ) : Martingale f 𝒢 μ := by @@ -491,7 +501,7 @@ theorem martingale_of_setIntegral_eq_succ [IsFiniteMeasure μ] {f : ℕ → Ω ← setIntegral_trim (𝒢.le n) stronglyMeasurable_condExp ms, setIntegral_condExp (𝒢.le n) (hint (n + 1)) ms, hf n s ms] -theorem martingale_of_condExp_sub_eq_zero_nat [IsFiniteMeasure μ] {f : ℕ → Ω → E} +theorem martingale_of_condExp_sub_eq_zero_nat [CompleteSpace E] [IsFiniteMeasure μ] {f : ℕ → Ω → E} (hadp : StronglyAdapted 𝒢 f) (hint : ∀ i, Integrable (f i) μ) (hf : ∀ i, μ[f (i + 1) - f i | 𝒢 i] =ᵐ[μ] 0) : Martingale f 𝒢 μ := by refine martingale_nat hadp hint fun i ↦ ?_ @@ -500,7 +510,8 @@ theorem martingale_of_condExp_sub_eq_zero_nat [IsFiniteMeasure μ] {f : ℕ → exact EventuallyEq.trans (condExp_sub (hint _) (hint _) _).symm (hf i) /-- A predictable martingale is a.e. equal to its initial state. -/ -theorem Martingale.eq_zero_of_predictable [SigmaFiniteFiltration μ 𝒢] {f : ℕ → Ω → E} +theorem Martingale.eq_zero_of_predictable [CompleteSpace E] [SigmaFiniteFiltration μ 𝒢] + {f : ℕ → Ω → E} (hfmgle : Martingale f 𝒢 μ) (hfadp : StronglyAdapted 𝒢 fun n => f (n + 1)) (n : ℕ) : f n =ᵐ[μ] f 0 := by induction n with @@ -511,7 +522,7 @@ theorem Martingale.eq_zero_of_predictable [SigmaFiniteFiltration μ 𝒢] {f : section IsStronglyPredictable -variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] /-- A predictable submartingale is a.e. greater than or equal to its initial state. -/ theorem Submartingale.zero_le_of_predictable' [Preorder E] [SigmaFiniteFiltration μ 𝒢] @@ -526,7 +537,8 @@ theorem Supermartingale.le_zero_of_predictable' [Preorder E] [SigmaFiniteFiltrat le_zero_of_predictable hfmgle hfadp.measurable_add_one n /-- A predictable martingale is a.e. equal to its initial state. -/ -theorem Martingale.eq_zero_of_predictable' [SigmaFiniteFiltration μ 𝒢] {f : ℕ → Ω → E} +theorem Martingale.eq_zero_of_predictable' [CompleteSpace E] [SigmaFiniteFiltration μ 𝒢] + {f : ℕ → Ω → E} (hfmgle : Martingale f 𝒢 μ) (hfadp : IsStronglyPredictable 𝒢 f) (n : ℕ) : f n =ᵐ[μ] f 0 := eq_zero_of_predictable hfmgle hfadp.measurable_add_one n @@ -543,9 +555,11 @@ end Submartingale section SumSMul -variable [PartialOrder E] [IsOrderedModule ℝ E] [ClosedIciTopology E] [IsOrderedAddMonoid E] +variable [CompleteSpace E] [PartialOrder E] [IsOrderedModule ℝ E] [ClosedIciTopology E] + [IsOrderedAddMonoid E] -theorem Submartingale.sum_smul_sub [IsFiniteMeasure μ] {R : ℝ} {f : ℕ → Ω → E} {ξ : ℕ → Ω → ℝ} +theorem Submartingale.sum_smul_sub [IsFiniteMeasure μ] {R : ℝ} + {f : ℕ → Ω → E} {ξ : ℕ → Ω → ℝ} (hf : Submartingale f 𝒢 μ) (hξ : StronglyAdapted 𝒢 ξ) (hbdd : ∀ n ω, ξ n ω ≤ R) (hnonneg : ∀ n ω, 0 ≤ ξ n ω) : Submartingale (fun n => ∑ k ∈ Finset.range n, ξ k • (f (k + 1) - f k)) 𝒢 μ := by diff --git a/Mathlib/Probability/Martingale/BorelCantelli.lean b/Mathlib/Probability/Martingale/BorelCantelli.lean index e0fe69747c9bc9..ef5a464411616d 100644 --- a/Mathlib/Probability/Martingale/BorelCantelli.lean +++ b/Mathlib/Probability/Martingale/BorelCantelli.lean @@ -155,7 +155,7 @@ theorem Submartingale.bddAbove_iff_exists_tendsto [IsFiniteMeasure μ] (hf : Sub have hgbdd : ∀ᵐ ω ∂μ, ∀ i : ℕ, |g (i + 1) ω - g i ω| ≤ ↑R := by simpa only [g, sub_sub_sub_cancel_right] filter_upwards [hg.bddAbove_iff_exists_tendsto_aux hg0 hgbdd] with ω hω - convert hω using 1 + convert! hω using 1 · refine ⟨fun h => ?_, fun h => ?_⟩ <;> obtain ⟨b, hb⟩ := h <;> refine ⟨b + |f 0 ω|, fun y hy => ?_⟩ <;> obtain ⟨n, rfl⟩ := hy · simp_rw [g, sub_eq_add_neg] @@ -205,7 +205,7 @@ theorem Martingale.bddAbove_range_iff_bddBelow_range [IsFiniteMeasure μ] (hf : constructor <;> rintro ⟨c, hc⟩ · exact ⟨-c, hc.neg⟩ · refine ⟨-c, ?_⟩ - convert hc.neg + convert! hc.neg simp only [neg_neg, Pi.neg_apply] rw [hω₁, this, ← hω₂] constructor <;> rintro ⟨c, hc⟩ <;> refine ⟨-c, fun ω hω => ?_⟩ diff --git a/Mathlib/Probability/Martingale/Centering.lean b/Mathlib/Probability/Martingale/Centering.lean index 9ad67533694f11..4fdfd483e7f7a0 100644 --- a/Mathlib/Probability/Martingale/Centering.lean +++ b/Mathlib/Probability/Martingale/Centering.lean @@ -41,7 +41,7 @@ open scoped NNReal ENNReal MeasureTheory ProbabilityTheory namespace MeasureTheory variable {Ω E : Type*} {m0 : MeasurableSpace Ω} {μ : Measure Ω} [NormedAddCommGroup E] - [NormedSpace ℝ E] [CompleteSpace E] {f g : ℕ → Ω → E} {ℱ : Filtration ℕ m0} + [NormedSpace ℝ E] {f g : ℕ → Ω → E} {ℱ : Filtration ℕ m0} /-- Any `ℕ`-indexed stochastic process can be written as the sum of a martingale and a predictable process. This is the predictable process. See `martingalePart` for the martingale. -/ @@ -57,13 +57,13 @@ lemma predictablePart_add_one (n : ℕ) : predictablePart f ℱ μ n + μ[f (n + 1) - f n | ℱ n] := by simp [predictablePart, Finset.sum_range_add] -lemma predictablePart_smul (c : ℝ) (n : ℕ) : +lemma predictablePart_smul [CompleteSpace E] (c : ℝ) (n : ℕ) : predictablePart (c • f) ℱ μ n =ᵐ[μ] c • predictablePart f ℱ μ n := by simp only [predictablePart, Finset.smul_sum] refine eventuallyEq_sum fun i hi => ?_ simp [← smul_sub, condExp_smul] -lemma predictablePart_add (hfint : ∀ n, Integrable (f n) μ) +lemma predictablePart_add [CompleteSpace E] (hfint : ∀ n, Integrable (f n) μ) (hgint : ∀ n, Integrable (g n) μ) (n : ℕ) : predictablePart (f + g) ℱ μ n =ᵐ[μ] predictablePart f ℱ μ n + predictablePart g ℱ μ n := by simp only [predictablePart, ← Finset.sum_add_distrib] @@ -72,7 +72,7 @@ lemma predictablePart_add (hfint : ∀ n, Integrable (f n) μ) _ =ᵐ[μ] μ[(f (i + 1) - f i) + (g (i + 1) - g i) | ℱ i] := by simp; abel_nf; rfl _ =ᵐ[μ] _ := by apply condExp_add ((hfint (i + 1)).sub (hfint i)) ((hgint (i + 1)).sub (hgint i)) -lemma Martingale.predictablePart_eq_zero (hf : Martingale f ℱ μ) (n : ℕ) : +lemma Martingale.predictablePart_eq_zero [CompleteSpace E] (hf : Martingale f ℱ μ) (n : ℕ) : predictablePart f ℱ μ n =ᵐ[μ] 0 := by rw [predictablePart, ← Finset.sum_const_zero (s := Finset.range n)] refine eventuallyEq_sum fun i hi => ?_ @@ -82,7 +82,8 @@ lemma Martingale.predictablePart_eq_zero (hf : Martingale f ℱ μ) (n : ℕ) : _ =ᵐ[μ] f i - f i := (hf.condExp_ae_eq (Nat.le_succ i)).sub (hf.condExp_ae_eq le_rfl) _ =ᵐ[μ] 0 := by simp -lemma Submartingale.monotone_predictablePart [PartialOrder E] [IsOrderedAddMonoid E] +lemma Submartingale.monotone_predictablePart + [CompleteSpace E] [PartialOrder E] [IsOrderedAddMonoid E] (hf : Submartingale f ℱ μ) : ∀ᵐ ω ∂μ, Monotone (predictablePart f ℱ μ · ω) := by have := ae_all_iff.2 <| fun n : ℕ ↦ hf.condExp_sub_nonneg n.le_succ @@ -91,7 +92,8 @@ lemma Submartingale.monotone_predictablePart [PartialOrder E] [IsOrderedAddMonoi refine monotone_nat_of_le_succ fun n ↦ (?_ : _ ≥ _) grw [predictablePart_add_one, Pi.add_apply, h n, add_zero] -lemma Submartingale.predictablePart_nonneg [PartialOrder E] [IsOrderedAddMonoid E] +lemma Submartingale.predictablePart_nonneg + [CompleteSpace E] [PartialOrder E] [IsOrderedAddMonoid E] (hf : Submartingale f ℱ μ) : ∀ᵐ ω ∂μ, ∀ n, 0 ≤ predictablePart f ℱ μ n ω := by filter_upwards [hf.monotone_predictablePart] with ω hω n @@ -129,19 +131,19 @@ noncomputable def martingalePart {m0 : MeasurableSpace Ω} (f : ℕ → Ω → E lemma martingalePart_zero : martingalePart f ℱ μ 0 = f 0 := by simp [martingalePart] -lemma martingalePart_smul (c : ℝ) (n : ℕ) : +lemma martingalePart_smul [CompleteSpace E] (c : ℝ) (n : ℕ) : martingalePart (c • f) ℱ μ n =ᵐ[μ] c • martingalePart f ℱ μ n := by filter_upwards [predictablePart_smul (f := f) c n] with ω hω simpa [martingalePart, smul_sub] -lemma martingalePart_add (hfint : ∀ n, Integrable (f n) μ) +lemma martingalePart_add [CompleteSpace E] (hfint : ∀ n, Integrable (f n) μ) (hgint : ∀ n, Integrable (g n) μ) (n : ℕ) : martingalePart (f + g) ℱ μ n =ᵐ[μ] martingalePart f ℱ μ n + martingalePart g ℱ μ n := by filter_upwards [predictablePart_add (ℱ := ℱ) hfint hgint n] with ω hω simp_all [martingalePart] abel -lemma Martingale.martingalePart_eq (hf : Martingale f ℱ μ) (n : ℕ) : +lemma Martingale.martingalePart_eq [CompleteSpace E] (hf : Martingale f ℱ μ) (n : ℕ) : martingalePart f ℱ μ n =ᵐ[μ] f n := by filter_upwards [hf.predictablePart_eq_zero n] with ω hω simp [martingalePart, hω] @@ -166,12 +168,13 @@ theorem martingalePart_eq_sum : martingalePart f ℱ μ = fun n => theorem stronglyAdapted_martingalePart (hf : StronglyAdapted ℱ f) : StronglyAdapted ℱ (martingalePart f ℱ μ) := hf.sub stronglyAdapted_predictablePart' -theorem integrable_martingalePart (hf_int : ∀ n, Integrable (f n) μ) (n : ℕ) : +theorem integrable_martingalePart [CompleteSpace E] (hf_int : ∀ n, Integrable (f n) μ) (n : ℕ) : Integrable (martingalePart f ℱ μ n) μ := by rw [martingalePart_eq_sum] fun_prop -theorem martingale_martingalePart (hf : StronglyAdapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ) +theorem martingale_martingalePart [CompleteSpace E] + (hf : StronglyAdapted ℱ f) (hf_int : ∀ n, Integrable (f n) μ) [SigmaFiniteFiltration μ ℱ] : Martingale (martingalePart f ℱ μ) ℱ μ := by refine ⟨stronglyAdapted_martingalePart hf, fun i j hij => ?_⟩ -- ⊢ μ[martingalePart f ℱ μ j | ℱ i] =ᵐ[μ] martingalePart f ℱ μ i @@ -212,7 +215,7 @@ theorem martingale_martingalePart (hf : StronglyAdapted ℱ f) (hf_int : ∀ n, rfl -- The following two lemmas demonstrate the essential uniqueness of the decomposition -theorem martingalePart_add_ae_eq [SigmaFiniteFiltration μ ℱ] {f g : ℕ → Ω → E} +theorem martingalePart_add_ae_eq [CompleteSpace E] [SigmaFiniteFiltration μ ℱ] {f g : ℕ → Ω → E} (hf : Martingale f ℱ μ) (hg : StronglyAdapted ℱ fun n => g (n + 1)) (hg0 : g 0 = 0) (hgint : ∀ n, Integrable (g n) μ) (n : ℕ) : martingalePart (f + g) ℱ μ n =ᵐ[μ] f n := by set h := f - martingalePart (f + g) ℱ μ with hhdef @@ -232,7 +235,7 @@ theorem martingalePart_add_ae_eq [SigmaFiniteFiltration μ ℱ] {f g : ℕ → rw [hω, Pi.sub_apply, martingalePart] simp [hg0] -theorem predictablePart_add_ae_eq [SigmaFiniteFiltration μ ℱ] {f g : ℕ → Ω → E} +theorem predictablePart_add_ae_eq [CompleteSpace E] [SigmaFiniteFiltration μ ℱ] {f g : ℕ → Ω → E} (hf : Martingale f ℱ μ) (hg : StronglyAdapted ℱ fun n => g (n + 1)) (hg0 : g 0 = 0) (hgint : ∀ n, Integrable (g n) μ) (n : ℕ) : predictablePart (f + g) ℱ μ n =ᵐ[μ] g n := by filter_upwards [martingalePart_add_ae_eq hf hg hg0 hgint n] with ω hω diff --git a/Mathlib/Probability/Martingale/OptionalStopping.lean b/Mathlib/Probability/Martingale/OptionalStopping.lean index bf516f6ea7ef55..ffd7a0c4fa5013 100644 --- a/Mathlib/Probability/Martingale/OptionalStopping.lean +++ b/Mathlib/Probability/Martingale/OptionalStopping.lean @@ -50,7 +50,7 @@ theorem Submartingale.expected_stoppedValue_mono {E : Type*} [NormedAddCommGroup have : ∀ i, MeasurableSet[𝒢 i] {ω : Ω | τ ω ≤ i ∧ i < π ω} := by intro i refine (hτ i).inter ?_ - convert (hπ i).compl using 1 + convert! (hπ i).compl using 1 ext x simp; rfl rw [integral_finsetSum] @@ -169,7 +169,7 @@ theorem maximal_ineq [IsFiniteMeasure μ] (hsub : Submartingale f 𝒢 μ) (hnon f n ω ∂μ) := by rw [← ENNReal.ofReal_add, ← setIntegral_union] · rw [← setIntegral_univ] - convert rfl + convert! rfl ext ω change (ε : ℝ) ≤ _ ∨ _ < (ε : ℝ) ↔ _ simp only [le_or_gt, Set.mem_univ] @@ -207,7 +207,7 @@ theorem maximal_ineq [IsFiniteMeasure μ] (hsub : Submartingale f 𝒢 μ) (hnon (∫ ω, stoppedValue f (fun ω ↦ (hittingBtwn f {y : ℝ | ε ≤ y} 0 n ω : ℕ)) ω ∂μ) := by rw [← ENNReal.ofReal_add, ← setIntegral_union] · rw [← setIntegral_univ (μ := μ)] - convert rfl + convert! rfl ext ω change _ ↔ (ε : ℝ) ≤ _ ∨ _ < (ε : ℝ) simp only [le_or_gt, Set.mem_univ] diff --git a/Mathlib/Probability/Martingale/Upcrossing.lean b/Mathlib/Probability/Martingale/Upcrossing.lean index 44c3143edc0e77..7e02bbb1a86c04 100644 --- a/Mathlib/Probability/Martingale/Upcrossing.lean +++ b/Mathlib/Probability/Martingale/Upcrossing.lean @@ -302,8 +302,8 @@ theorem upperCrossingTime_bound_eq (f : ℕ → Ω → ℝ) (N : ℕ) (ω : Ω) (Set.Iic (Nat.find (exists_upperCrossingTime_eq f N ω hab)).pred) := by refine strictMonoOn_Iic_of_lt_succ fun m hm => upperCrossingTime_lt_succ hab ?_ rw [Nat.lt_pred_iff] at hm - convert Nat.find_min _ hm - convert StrictMonoOn.Iic_id_le hmono N (Nat.le_sub_one_of_lt hN') + convert! Nat.find_min _ hm + convert! StrictMonoOn.Iic_id_le hmono N (Nat.le_sub_one_of_lt hN') · rw [not_lt] at hN' exact upperCrossingTime_stabilize hN' (Nat.find_spec (exists_upperCrossingTime_eq f N ω hab)) @@ -414,7 +414,7 @@ theorem Submartingale.sum_mul_upcrossingStrat_le [IsFiniteMeasure μ] (hf : Subm Pi.mul_apply] refine integral_sub (Integrable.sub (integrable_finsetSum _ fun i _ => hf.integrable _) (integrable_finsetSum _ fun i _ => hf.integrable _)) ?_ - convert (hf.sum_upcrossingStrat_mul a b N).integrable n using 1 + convert! (hf.sum_upcrossingStrat_mul a b N).integrable n using 1 ext; simp rw [h₂, sub_nonneg] at h₁ refine le_trans h₁ ?_ @@ -445,7 +445,7 @@ theorem upperCrossingTime_lt_of_le_upcrossingsBefore (hN : 0 < N) (hab : a < b) theorem upperCrossingTime_eq_of_upcrossingsBefore_lt (hab : a < b) (hn : upcrossingsBefore a b f N ω < n) : upperCrossingTime a b f N n ω = N := by refine le_antisymm upperCrossingTime_le (not_lt.1 ?_) - convert notMem_of_csSup_lt hn (upperCrossingTime_lt_bddAbove hab) using 1 + convert! notMem_of_csSup_lt hn (upperCrossingTime_lt_bddAbove hab) using 1 theorem upcrossingsBefore_le (f : ℕ → Ω → ℝ) (ω : Ω) (hab : a < b) : upcrossingsBefore a b f N ω ≤ N := by diff --git a/Mathlib/Probability/Moments/ComplexMGF.lean b/Mathlib/Probability/Moments/ComplexMGF.lean index 4f643782527476..90eaf77896a72e 100644 --- a/Mathlib/Probability/Moments/ComplexMGF.lean +++ b/Mathlib/Probability/Moments/ComplexMGF.lean @@ -162,14 +162,14 @@ lemma hasDerivAt_integral_pow_mul_exp (hz : z.re ∈ interior (integrableExpSet simp_rw [pow_succ, mul_assoc] refine HasDerivAt.const_mul _ ?_ simp_rw [← smul_eq_mul, Complex.exp_eq_exp_ℂ] - convert hasDerivAt_exp_smul_const (X ω : ℂ) ε using 1 + convert! hasDerivAt_exp_smul_const (X ω : ℂ) ε using 1 rw [smul_eq_mul, mul_comm] /-- For all `z : ℂ` with `z.re ∈ interior (integrableExpSet X μ)`, `complexMGF X μ` is differentiable at `z` with derivative `μ[X * exp (z * X)]`. -/ theorem hasDerivAt_complexMGF (hz : z.re ∈ interior (integrableExpSet X μ)) : HasDerivAt (complexMGF X μ) μ[fun ω ↦ X ω * cexp (z * X ω)] z := by - convert hasDerivAt_integral_pow_mul_exp hz 0 + convert! hasDerivAt_integral_pow_mul_exp hz 0 · simp [complexMGF] · simp diff --git a/Mathlib/Probability/Moments/Covariance.lean b/Mathlib/Probability/Moments/Covariance.lean index 81f31c1cdb7704..03971b7964bb57 100644 --- a/Mathlib/Probability/Moments/Covariance.lean +++ b/Mathlib/Probability/Moments/Covariance.lean @@ -236,12 +236,12 @@ lemma covariance_sum_left [Fintype ι] (hX : ∀ i, MemLp (X i) 2 μ) (hY : MemL lemma covariance_fun_sum_left' (hX : ∀ i ∈ s, MemLp (X i) 2 μ) (hY : MemLp Y 2 μ) : cov[fun ω ↦ ∑ i ∈ s, X i ω, Y; μ] = ∑ i ∈ s, cov[X i, Y; μ] := by - convert covariance_sum_left' hX hY + convert! covariance_sum_left' hX hY simp lemma covariance_fun_sum_left [Fintype ι] (hX : ∀ i, MemLp (X i) 2 μ) (hY : MemLp Y 2 μ) : cov[fun ω ↦ ∑ i, X i ω, Y; μ] = ∑ i, cov[X i, Y; μ] := by - convert covariance_sum_left hX hY + convert! covariance_sum_left hX hY simp lemma covariance_sum_right' (hX : ∀ i ∈ s, MemLp (X i) 2 μ) (hY : MemLp Y 2 μ) : @@ -255,7 +255,7 @@ lemma covariance_sum_right [Fintype ι] (hX : ∀ i, MemLp (X i) 2 μ) (hY : Mem lemma covariance_fun_sum_right' (hX : ∀ i ∈ s, MemLp (X i) 2 μ) (hY : MemLp Y 2 μ) : cov[Y, fun ω ↦ ∑ i ∈ s, X i ω; μ] = ∑ i ∈ s, cov[Y, X i; μ] := by - convert covariance_sum_right' hX hY + convert! covariance_sum_right' hX hY simp lemma covariance_fun_sum_right [Fintype ι] (hX : ∀ i, MemLp (X i) 2 μ) (hY : MemLp Y 2 μ) : @@ -278,7 +278,7 @@ lemma covariance_fun_sum_fun_sum' {ι' : Type*} {Y : ι' → Ω → ℝ} {t : Fi (hX : ∀ i ∈ s, MemLp (X i) 2 μ) (hY : ∀ i ∈ t, MemLp (Y i) 2 μ) : cov[fun ω ↦ ∑ i ∈ s, X i ω, fun ω ↦ ∑ j ∈ t, Y j ω; μ] = ∑ i ∈ s, ∑ j ∈ t, cov[X i, Y j; μ] := by - convert covariance_sum_sum' hX hY + convert! covariance_sum_sum' hX hY all_goals simp lemma covariance_fun_sum_fun_sum [Fintype ι] {ι' : Type*} [Fintype ι'] {Y : ι' → Ω → ℝ} diff --git a/Mathlib/Probability/Moments/CovarianceBilin.lean b/Mathlib/Probability/Moments/CovarianceBilin.lean index 6147c411d926fc..96ba36fdb87bff 100644 --- a/Mathlib/Probability/Moments/CovarianceBilin.lean +++ b/Mathlib/Probability/Moments/CovarianceBilin.lean @@ -136,7 +136,7 @@ lemma covarianceBilin_map_const_add [CompleteSpace E] [IsProbabilityMeasure μ] rw [covarianceBilin_of_not_memLp, covarianceBilin_of_not_memLp h] rw [(measurableEmbedding_addLeft _).memLp_map_measure_iff.not] contrapose h - convert (memLp_const (-c)).add h + convert! (memLp_const (-c)).add h ext; simp lemma covarianceBilin_apply_basisFun {ι Ω : Type*} [Fintype ι] {mΩ : MeasurableSpace Ω} diff --git a/Mathlib/Probability/Moments/IntegrableExpMul.lean b/Mathlib/Probability/Moments/IntegrableExpMul.lean index 9c6245b16ba8da..922dc2bf731375 100644 --- a/Mathlib/Probability/Moments/IntegrableExpMul.lean +++ b/Mathlib/Probability/Moments/IntegrableExpMul.lean @@ -223,7 +223,7 @@ lemma rpow_abs_le_mul_max_exp_of_pos (x : ℝ) {t p : ℝ} (hp : 0 ≤ p) (ht : calc |x| ^ p _ ≤ ((t / p)⁻¹ * max (exp (t / p * x)) (exp (-t / p * x))) ^ p := by gcongr - convert h_abs_le (t / p) (div_pos ht (hp.lt_of_ne' hp_zero)) using 5 + convert! h_abs_le (t / p) (div_pos ht (hp.lt_of_ne' hp_zero)) using 5 rw [neg_div] _ = (p / t) ^ p * max (exp (t * x)) (exp (-t * x)) := by rw [mul_rpow (by positivity) (by positivity)] @@ -237,7 +237,7 @@ lemma rpow_abs_le_mul_max_exp (x : ℝ) {t p : ℝ} (hp : 0 ≤ p) (ht : t ≠ 0 |x| ^ p ≤ (p / |t|) ^ p * max (exp (t * x)) (exp (-t * x)) := by rcases lt_or_gt_of_ne ht with ht_neg | ht_pos · rw [abs_of_nonpos ht_neg.le, sup_comm] - convert rpow_abs_le_mul_max_exp_of_pos x hp (t := -t) (by simp [ht_neg]) + convert! rpow_abs_le_mul_max_exp_of_pos x hp (t := -t) (by simp [ht_neg]) simp · rw [abs_of_nonneg ht_pos.le] exact rpow_abs_le_mul_max_exp_of_pos x hp ht_pos @@ -279,7 +279,7 @@ lemma integrable_rpow_abs_mul_exp_add_of_integrable_exp_mul {x : ℝ} nth_rw 2 [this] rw [add_mul, exp_add, ← mul_assoc] gcongr ?_ * _ - convert rpow_abs_le_mul_exp_abs (X a) hp (t := |t| - x) _ using 4 + convert! rpow_abs_le_mul_exp_abs (X a) hp (t := |t| - x) _ using 4 · nth_rw 2 [abs_of_nonneg] simp [hx.le] · nth_rw 2 [abs_of_nonneg] @@ -308,8 +308,9 @@ lemma integrable_pow_abs_mul_exp_add_of_integrable_exp_mul {x : ℝ} (h_int_neg : Integrable (fun ω ↦ exp ((v - t) * X ω)) μ) (h_nonneg : 0 ≤ x) (hx : x < |t|) (n : ℕ) : Integrable (fun a ↦ |X a| ^ n * exp (v * X a + x * |X a|)) μ := by - convert integrable_rpow_abs_mul_exp_add_of_integrable_exp_mul h_int_pos h_int_neg h_nonneg hx - n.cast_nonneg + convert! + integrable_rpow_abs_mul_exp_add_of_integrable_exp_mul h_int_pos h_int_neg h_nonneg hx + n.cast_nonneg simp /-- If `exp ((v + t) * X)` and `exp ((v - t) * X)` are integrable @@ -318,8 +319,8 @@ lemma integrable_rpow_abs_mul_exp_of_integrable_exp_mul (ht : t ≠ 0) (ht_int_pos : Integrable (fun ω ↦ exp ((v + t) * X ω)) μ) (ht_int_neg : Integrable (fun ω ↦ exp ((v - t) * X ω)) μ) {p : ℝ} (hp : 0 ≤ p) : Integrable (fun ω ↦ |X ω| ^ p * exp (v * X ω)) μ := by - convert integrable_rpow_abs_mul_exp_add_of_integrable_exp_mul ht_int_pos ht_int_neg le_rfl _ hp - using 4 + convert! + integrable_rpow_abs_mul_exp_add_of_integrable_exp_mul ht_int_pos ht_int_neg le_rfl _ hp using 4 · simp · simp [ht] @@ -329,8 +330,10 @@ lemma integrable_pow_abs_mul_exp_of_integrable_exp_mul (ht : t ≠ 0) (ht_int_pos : Integrable (fun ω ↦ exp ((v + t) * X ω)) μ) (ht_int_neg : Integrable (fun ω ↦ exp ((v - t) * X ω)) μ) (n : ℕ) : Integrable (fun ω ↦ |X ω| ^ n * exp (v * X ω)) μ := by - convert integrable_rpow_abs_mul_exp_of_integrable_exp_mul ht ht_int_pos ht_int_neg - (by positivity : 0 ≤ (n : ℝ)) with ω + convert! + integrable_rpow_abs_mul_exp_of_integrable_exp_mul ht ht_int_pos ht_int_neg + (by positivity : 0 ≤ (n : ℝ)) with + ω simp /-- If `exp ((v + t) * X)` and `exp ((v - t) * X)` are integrable, then for all nonnegative `p : ℝ`, @@ -358,8 +361,10 @@ lemma integrable_pow_mul_exp_of_integrable_exp_mul (ht : t ≠ 0) (ht_int_pos : Integrable (fun ω ↦ exp ((v + t) * X ω)) μ) (ht_int_neg : Integrable (fun ω ↦ exp ((v - t) * X ω)) μ) (n : ℕ) : Integrable (fun ω ↦ X ω ^ n * exp (v * X ω)) μ := by - convert integrable_rpow_mul_exp_of_integrable_exp_mul ht ht_int_pos ht_int_neg - (by positivity : 0 ≤ (n : ℝ)) with ω + convert! + integrable_rpow_mul_exp_of_integrable_exp_mul ht ht_int_pos ht_int_neg + (by positivity : 0 ≤ (n : ℝ)) with + ω simp /-- If `ω ↦ exp (t * X ω)` is integrable at `t` and `-t` for `t ≠ 0`, then `ω ↦ |X ω| ^ p` is @@ -379,8 +384,10 @@ lemma integrable_pow_abs_of_integrable_exp_mul (ht : t ≠ 0) (ht_int_pos : Integrable (fun ω ↦ exp (t * X ω)) μ) (ht_int_neg : Integrable (fun ω ↦ exp (-t * X ω)) μ) (n : ℕ) : Integrable (fun ω ↦ |X ω| ^ n) μ := by - convert integrable_rpow_abs_of_integrable_exp_mul ht ht_int_pos ht_int_neg - (by positivity : 0 ≤ (n : ℝ)) with ω + convert! + integrable_rpow_abs_of_integrable_exp_mul ht ht_int_pos ht_int_neg + (by positivity : 0 ≤ (n : ℝ)) with + ω simp /-- If `ω ↦ exp (t * X ω)` is integrable at `t` and `-t` for `t ≠ 0`, then `ω ↦ X ω ^ p` is @@ -400,8 +407,10 @@ lemma integrable_pow_of_integrable_exp_mul (ht : t ≠ 0) (ht_int_pos : Integrable (fun ω ↦ exp (t * X ω)) μ) (ht_int_neg : Integrable (fun ω ↦ exp (-t * X ω)) μ) (n : ℕ) : Integrable (fun ω ↦ X ω ^ n) μ := by - convert integrable_rpow_of_integrable_exp_mul ht ht_int_pos ht_int_neg - (by positivity : 0 ≤ (n : ℝ)) with ω + convert! + integrable_rpow_of_integrable_exp_mul ht ht_int_pos ht_int_neg + (by positivity : 0 ≤ (n : ℝ)) with + ω simp section IntegrableExpSet @@ -468,8 +477,10 @@ then `|X| ^ n * exp (v * X)` is integrable for all `n : ℕ`. -/ lemma integrable_pow_abs_mul_exp_of_mem_interior_integrableExpSet (hv : v ∈ interior (integrableExpSet X μ)) (n : ℕ) : Integrable (fun ω ↦ |X ω| ^ n * exp (v * X ω)) μ := by - convert integrable_rpow_abs_mul_exp_of_mem_interior_integrableExpSet hv - (by positivity : 0 ≤ (n : ℝ)) with ω + convert! + integrable_rpow_abs_mul_exp_of_mem_interior_integrableExpSet hv + (by positivity : 0 ≤ (n : ℝ)) with + ω simp /-- If `v` belongs to the interior of the interval `integrableExpSet X μ`, @@ -491,8 +502,8 @@ then `X ^ n * exp (v * X)` is integrable for all `n : ℕ`. -/ lemma integrable_pow_mul_exp_of_mem_interior_integrableExpSet (hv : v ∈ interior (integrableExpSet X μ)) (n : ℕ) : Integrable (fun ω ↦ X ω ^ n * exp (v * X ω)) μ := by - convert integrable_rpow_mul_exp_of_mem_interior_integrableExpSet hv - (by positivity : 0 ≤ (n : ℝ)) with ω + convert! + integrable_rpow_mul_exp_of_mem_interior_integrableExpSet hv (by positivity : 0 ≤ (n : ℝ)) with ω simp /-- If 0 belongs to the interior of the interval `integrableExpSet X μ`, @@ -500,7 +511,7 @@ then `|X| ^ n` is integrable for all nonnegative `p : ℝ`. -/ lemma integrable_rpow_abs_of_mem_interior_integrableExpSet (h : 0 ∈ interior (integrableExpSet X μ)) {p : ℝ} (hp : 0 ≤ p) : Integrable (fun ω ↦ |X ω| ^ p) μ := by - convert integrable_rpow_abs_mul_exp_of_mem_interior_integrableExpSet h hp using 1 + convert! integrable_rpow_abs_mul_exp_of_mem_interior_integrableExpSet h hp using 1 simp /-- If 0 belongs to the interior of the interval `integrableExpSet X μ`, @@ -508,7 +519,7 @@ then `|X| ^ n` is integrable for all `n : ℕ`. -/ lemma integrable_pow_abs_of_mem_interior_integrableExpSet (h : 0 ∈ interior (integrableExpSet X μ)) (n : ℕ) : Integrable (fun ω ↦ |X ω| ^ n) μ := by - convert integrable_pow_abs_mul_exp_of_mem_interior_integrableExpSet h n + convert! integrable_pow_abs_mul_exp_of_mem_interior_integrableExpSet h n simp /-- If 0 belongs to the interior of the interval `integrableExpSet X μ`, @@ -516,7 +527,7 @@ then `X ^ n` is integrable for all nonnegative `p : ℝ`. -/ lemma integrable_rpow_of_mem_interior_integrableExpSet (h : 0 ∈ interior (integrableExpSet X μ)) {p : ℝ} (hp : 0 ≤ p) : Integrable (fun ω ↦ X ω ^ p) μ := by - convert integrable_rpow_mul_exp_of_mem_interior_integrableExpSet h hp using 1 + convert! integrable_rpow_mul_exp_of_mem_interior_integrableExpSet h hp using 1 simp /-- If 0 belongs to the interior of the interval `integrableExpSet X μ`, @@ -524,7 +535,7 @@ then `X ^ n` is integrable for all `n : ℕ`. -/ lemma integrable_pow_of_mem_interior_integrableExpSet (h : 0 ∈ interior (integrableExpSet X μ)) (n : ℕ) : Integrable (fun ω ↦ X ω ^ n) μ := by - convert integrable_pow_mul_exp_of_mem_interior_integrableExpSet h n + convert! integrable_pow_mul_exp_of_mem_interior_integrableExpSet h n simp /-- If 0 belongs to the interior of `integrableExpSet X μ`, then `X` is in `ℒp` for all @@ -575,7 +586,7 @@ lemma integrable_rpow_abs_mul_cexp_of_re_mem_interior_integrableExpSet lemma integrable_pow_abs_mul_cexp_of_re_mem_interior_integrableExpSet (hz : z.re ∈ interior (integrableExpSet X μ)) (n : ℕ) : Integrable (fun ω ↦ |X ω| ^ n * cexp (z * X ω)) μ := by - convert integrable_rpow_abs_mul_cexp_of_re_mem_interior_integrableExpSet hz (Nat.cast_nonneg n) + convert! integrable_rpow_abs_mul_cexp_of_re_mem_interior_integrableExpSet hz (Nat.cast_nonneg n) simp lemma integrable_rpow_mul_cexp_of_re_mem_interior_integrableExpSet @@ -596,7 +607,7 @@ lemma integrable_rpow_mul_cexp_of_re_mem_interior_integrableExpSet lemma integrable_pow_mul_cexp_of_re_mem_interior_integrableExpSet (hz : z.re ∈ interior (integrableExpSet X μ)) (n : ℕ) : Integrable (fun ω ↦ X ω ^ n * cexp (z * X ω)) μ := by - convert integrable_rpow_mul_cexp_of_re_mem_interior_integrableExpSet hz (Nat.cast_nonneg n) + convert! integrable_rpow_mul_cexp_of_re_mem_interior_integrableExpSet hz (Nat.cast_nonneg n) simp end Complex diff --git a/Mathlib/Probability/Moments/MGFAnalytic.lean b/Mathlib/Probability/Moments/MGFAnalytic.lean index b3972043489349..ad059254382fdf 100644 --- a/Mathlib/Probability/Moments/MGFAnalytic.lean +++ b/Mathlib/Probability/Moments/MGFAnalytic.lean @@ -60,7 +60,7 @@ section DerivMGF `μ[X * exp (t * X)]`. -/ lemma hasDerivAt_mgf (h : t ∈ interior (integrableExpSet X μ)) : HasDerivAt (mgf X μ) (μ[fun ω ↦ X ω * exp (t * X ω)]) t := by - convert hasDerivAt_integral_pow_mul_exp_real h 0 + convert! hasDerivAt_integral_pow_mul_exp_real h 0 · simp [mgf] · simp @@ -124,7 +124,7 @@ lemma hasFPowerSeriesAt_mgf (hv : v ∈ interior (integrableExpSet X μ)) : HasFPowerSeriesAt (mgf X μ) (FormalMultilinearSeries.ofScalars ℝ (fun n ↦ (μ[fun ω ↦ X ω ^ n * exp (v * X ω)] : ℝ) / n !)) v := by - convert (analyticAt_mgf hv).hasFPowerSeriesAt + convert! (analyticAt_mgf hv).hasFPowerSeriesAt rw [iteratedDeriv_mgf hv] lemma differentiableAt_mgf (ht : t ∈ interior (integrableExpSet X μ)) : @@ -140,7 +140,7 @@ lemma continuousOn_mgf : ContinuousOn (mgf X μ) (interior (integrableExpSet X lemma continuous_mgf (h : ∀ t, Integrable (fun ω ↦ exp (t * X ω)) μ) : Continuous (mgf X μ) := by rw [← continuousOn_univ] - convert continuousOn_mgf + convert! continuousOn_mgf symm rw [interior_eq_univ] ext t @@ -233,7 +233,7 @@ lemma iteratedDeriv_two_cgf (h : v ∈ interior (integrableExpSet X μ)) : ring _ = (∫ ω, (X ω) ^ 2 * exp (v * X ω) ∂μ) / mgf X μ v - deriv (cgf X μ) v ^ 2 := by congr - convert (hasDerivAt_integral_pow_mul_exp_real h 1).deriv using 1 + convert! (hasDerivAt_integral_pow_mul_exp_real h 1).deriv using 1 simp lemma iteratedDeriv_two_cgf_eq_integral (h : v ∈ interior (integrableExpSet X μ)) : @@ -259,7 +259,7 @@ lemma iteratedDeriv_two_cgf_eq_integral (h : v ∈ interior (integrableExpSet X refine Integrable.const_mul ?_ _ simp_rw [← mul_assoc] refine Integrable.mul_const ?_ _ - convert integrable_pow_mul_exp_of_mem_interior_integrableExpSet h 1 + convert! integrable_pow_mul_exp_of_mem_interior_integrableExpSet h 1 simp rw [integral_add] rotate_left @@ -282,9 +282,9 @@ lemma exists_cgf_eq_iteratedDeriv_two_cgf_mul [IsZeroOrProbabilityMeasure μ] (h rw [← sub_zero (cgf X μ t)] nth_rw 3 [← sub_zero t] rw [← Set.uIoo_of_lt ht] - convert taylor_mean_remainder_lagrange_iteratedDeriv ht.ne ?_ + convert! taylor_mean_remainder_lagrange_iteratedDeriv ht.ne ?_ · have hd : derivWithin (cgf X μ) (Set.Icc 0 t) 0 = 0 := by - convert (analyticAt_cgf (hs ⟨le_refl 0, le_of_lt ht⟩)).differentiableAt.derivWithin _ + convert! (analyticAt_cgf (hs ⟨le_refl 0, le_of_lt ht⟩)).differentiableAt.derivWithin _ · simpa [hc] using (deriv_cgf_zero (hs ⟨le_refl 0, le_of_lt ht⟩)).symm · exact hu 0 ⟨le_refl 0, le_of_lt ht⟩ simp [hd, Set.uIcc_of_lt ht] diff --git a/Mathlib/Probability/Moments/SubGaussian.lean b/Mathlib/Probability/Moments/SubGaussian.lean index 92f50261b235b4..f7ed8fd38929a4 100644 --- a/Mathlib/Probability/Moments/SubGaussian.lean +++ b/Mathlib/Probability/Moments/SubGaussian.lean @@ -181,7 +181,7 @@ lemma ae_forall_memLp_exp_mul (h : HasSubgaussianMGF X c κ ν) (p : ℝ≥0) : rw [eLpNorm_lt_top_iff_lintegral_rpow_enorm_lt_top (mod_cast hp) (by simp), ENNReal.coe_toReal] have hf := (hi (p * t)).lintegral_lt_top - convert hf using 3 with ω + convert! hf using 3 with ω rw [enorm_eq_ofReal (by positivity), ENNReal.ofReal_rpow_of_nonneg (by positivity), ← exp_mul, mul_comm, ← mul_assoc] positivity @@ -196,7 +196,7 @@ lemma memLp_exp_mul (h : HasSubgaussianMGF X c κ ν) (t : ℝ) (p : ℝ≥0) : simp only [ENNReal.coe_toReal] have h' := (h.integrable_exp_mul (p * t)).2 rw [hasFiniteIntegral_def] at h' - convert h' using 3 with ω + convert! h' using 3 with ω rw [enorm_eq_ofReal (by positivity), enorm_eq_ofReal (by positivity), ENNReal.ofReal_rpow_of_nonneg (by positivity), ← exp_mul, mul_comm, ← mul_assoc] positivity @@ -289,10 +289,10 @@ lemma of_map {Ω'' : Type*} {mΩ'' : MeasurableSpace Ω''} {κ : Kernel Ω' Ω'' at h1 mgf_le := by filter_upwards [h.ae_forall_integrable_exp_mul, h.mgf_le] with ω' h_int h_mgf t - convert h_mgf t + convert! h_mgf t ext t rw [map_apply _ hY, mgf_map hY.aemeasurable] - convert (h_int t).1 + convert! (h_int t).1 rw [map_apply _ hY] lemma id_map_iff (hX : Measurable X) : @@ -418,7 +418,7 @@ lemma add {Y : Ω → ℝ} {cX cY : ℝ≥0} (hX : HasSubgaussianMGF X cX κ ν) exact { integrable_exp_mul t := by simp_rw [mul_add, exp_add] - convert MemLp.integrable_mul (hX.memLp_exp_mul t 2) (hY.memLp_exp_mul t 2) + convert! MemLp.integrable_mul (hX.memLp_exp_mul t 2) (hY.memLp_exp_mul t 2) norm_cast infer_instance mgf_le := by @@ -653,7 +653,7 @@ lemma of_map {Ω' : Type*} {mΩ' : MeasurableSpace Ω'} {μ : Measure Ω'} have h1 := h.integrable_exp_mul t rwa [integrable_map_measure h1.aestronglyMeasurable (by fun_prop)] at h1 mgf_le t := by - convert h.mgf_le t using 1 + convert! h.mgf_le t using 1 rw [mgf_map hY (h.integrable_exp_mul t).1] lemma id_map_iff (hX : AEMeasurable X μ) : @@ -728,7 +728,7 @@ lemma add_of_indepFun {Y : Ω → ℝ} {cX cY : ℝ≥0} (hX : HasSubgaussianMGF HasSubgaussianMGF (fun ω ↦ X ω + Y ω) (cX + cY) μ where integrable_exp_mul t := by simp_rw [mul_add, exp_add] - convert MemLp.integrable_mul (hX.memLp_exp_mul t 2) (hY.memLp_exp_mul t 2) + convert! MemLp.integrable_mul (hX.memLp_exp_mul t 2) (hY.memLp_exp_mul t 2) norm_cast infer_instance mgf_le t := by @@ -762,7 +762,7 @@ private lemma sum_of_iIndepFun_of_forall_aemeasurable have h_indep' := (h_indep.indepFun_finsetSum_of_notMem₀ h_meas his).symm refine add_of_indepFun (h_subG _ (Finset.mem_insert_self _ _)) (h ?_) ?_ · exact fun i hi ↦ h_subG _ (Finset.mem_insert_of_mem hi) - · convert h_indep' + · convert! h_indep' rw [Finset.sum_apply] lemma sum_of_iIndepFun {ι : Type*} {X : ι → Ω → ℝ} (h_indep : iIndepFun X μ) {c : ι → ℝ≥0} @@ -831,7 +831,7 @@ protected lemma mgf_le_of_mem_Icc_of_integral_eq_zero [IsProbabilityMeasure μ] _ = Var[X; μ.tilted (u * X ·)] := by rw [← variance_tilted_mul (hs (Set.mem_Icc_of_Ioo h1))] _ ≤ ((b - a) / 2) ^ 2 := by - convert variance_le_sq_of_bounded ((tilted_absolutelyContinuous μ (u * X ·)) hb) _ + convert! variance_le_sq_of_bounded ((tilted_absolutelyContinuous μ (u * X ·)) hb) _ · exact isProbabilityMeasure_tilted (hi u) · exact hm.mono_ac (tilted_absolutelyContinuous μ (u * X ·)) _ = (‖b - a‖₊ / 2) ^ 2 := by simp [field] @@ -891,7 +891,7 @@ lemma HasSubgaussianMGF.add_of_hasCondSubgaussianMGF [IsFiniteMeasure μ] rw [HasSubgaussianMGF_iff_kernel] at hX ⊢ have hY' : Kernel.HasSubgaussianMGF Y cY (condExpKernel μ m) (Kernel.const Unit (μ.trim hm) ∘ₘ Measure.dirac ()) := by simpa - convert hX.add_comp hY' + convert! hX.add_comp hY' ext rw [Kernel.const_apply, ← Measure.compProd, compProd_trim_condExpKernel] diff --git a/Mathlib/Probability/Moments/Tilted.lean b/Mathlib/Probability/Moments/Tilted.lean index 4acd5730f3ba77..6c558c4b530af4 100644 --- a/Mathlib/Probability/Moments/Tilted.lean +++ b/Mathlib/Probability/Moments/Tilted.lean @@ -147,7 +147,7 @@ lemma memLp_tilted_mul (ht : t ∈ interior (integrableExpSet X μ)) (p : ℝ≥ rotate_left · simp [hp] · simp - simp_rw [ENNReal.coe_toReal, ← ofReal_norm_eq_enorm, norm_eq_abs, + simp_rw [ENNReal.coe_toReal, ← ofReal_norm, norm_eq_abs, ENNReal.ofReal_rpow_of_nonneg (x := |X _|) (p := p) (abs_nonneg (X _)) p.2] refine Integrable.lintegral_lt_top ?_ simp_rw [integrable_tilted_iff (interior_subset (s := integrableExpSet X μ) ht), diff --git a/Mathlib/Probability/Moments/Variance.lean b/Mathlib/Probability/Moments/Variance.lean index 490b1a67102d56..fe52ac300a94a8 100644 --- a/Mathlib/Probability/Moments/Variance.lean +++ b/Mathlib/Probability/Moments/Variance.lean @@ -116,7 +116,7 @@ theorem evariance_eq_top [IsFiniteMeasure μ] (hXm : AEStronglyMeasurable X μ) simp only [ENNReal.toReal_ofNat, ENNReal.rpow_two] exact ENNReal.rpow_lt_top_of_nonneg (by linarith) h.ne refine hX ?_ - convert this.add (memLp_const μ[X]) + convert! this.add (memLp_const μ[X]) ext ω rw [Pi.add_apply, sub_add_cancel] @@ -218,7 +218,7 @@ theorem variance_smul (c : ℝ) (X : Ω → ℝ) (μ : Measure Ω) : theorem variance_smul' {A : Type*} [CommSemiring A] [Algebra A ℝ] (c : A) (X : Ω → ℝ) (μ : Measure Ω) : variance (c • X) μ = c ^ 2 • variance X μ := by - convert variance_smul (algebraMap A ℝ c) X μ using 1 + convert! variance_smul (algebraMap A ℝ c) X μ using 1 · simp only [algebraMap_smul] · simp only [Algebra.smul_def, map_pow] @@ -244,7 +244,7 @@ lemma variance_const_add [IsProbabilityMeasure μ] (hX : AEStronglyMeasurable X simp_rw [add_comm c, variance_add_const hX c] lemma variance_fun_neg : Var[fun ω ↦ -X ω; μ] = Var[X; μ] := by - convert variance_const_mul (-1) X μ + convert! variance_const_mul (-1) X μ · ext; ring · simp @@ -297,12 +297,12 @@ lemma variance_sum [IsFiniteMeasure μ] [Fintype ι] (hX : ∀ i, MemLp (X i) 2 lemma variance_fun_sum' [IsFiniteMeasure μ] (hX : ∀ i ∈ s, MemLp (X i) 2 μ) : Var[fun ω ↦ ∑ i ∈ s, X i ω; μ] = ∑ i ∈ s, ∑ j ∈ s, cov[X i, X j; μ] := by - convert variance_sum' hX + convert! variance_sum' hX simp lemma variance_fun_sum [IsFiniteMeasure μ] [Fintype ι] (hX : ∀ i, MemLp (X i) 2 μ) : Var[fun ω ↦ ∑ i, X i ω; μ] = ∑ i, ∑ j, cov[X i, X j; μ] := by - convert variance_sum hX + convert! variance_sum hX simp variable {X : Ω → ℝ} @@ -353,7 +353,7 @@ theorem variance_le_expectation_sq [IsProbabilityMeasure μ] {X : Ω → ℝ} (memLp_two_iff_integrable_sq (by fun_prop)).2 h have B : MemLp (fun _ : Ω => μ[X]) 2 μ := memLp_const _ apply hX - convert A.add B + convert! A.add B simp · exact Eventually.of_forall fun x => sq_nonneg _ · exact (AEMeasurable.pow_const (hm.aemeasurable.sub_const _) _).aestronglyMeasurable @@ -382,8 +382,9 @@ theorem meas_ge_le_evariance_div_sq {X : Ω → ℝ} (hX : AEStronglyMeasurable (hc : c ≠ 0) : μ {ω | ↑c ≤ |X ω - μ[X]|} ≤ evariance X μ / c ^ 2 := by have A : (c : ℝ≥0∞) ≠ 0 := by rwa [Ne, ENNReal.coe_eq_zero] have B : AEStronglyMeasurable (fun _ : Ω => μ[X]) μ := aestronglyMeasurable_const - convert meas_ge_le_mul_pow_eLpNorm_enorm μ two_ne_zero ENNReal.ofNat_ne_top - (hX.sub B) A (by simp) using 1 + convert! + meas_ge_le_mul_pow_eLpNorm_enorm μ two_ne_zero ENNReal.ofNat_ne_top (hX.sub B) A (by simp) + using 1 · norm_cast rw [eLpNorm_eq_lintegral_rpow_enorm_toReal two_ne_zero ENNReal.ofNat_ne_top] simp only [ENNReal.toReal_ofNat, one_div, Pi.sub_apply] @@ -397,7 +398,7 @@ from its expectation in terms of the variance. -/ theorem meas_ge_le_variance_div_sq [IsFiniteMeasure μ] {X : Ω → ℝ} (hX : MemLp X 2 μ) {c : ℝ} (hc : 0 < c) : μ {ω | c ≤ |X ω - μ[X]|} ≤ ENNReal.ofReal (variance X μ / c ^ 2) := by rw [ENNReal.ofReal_div_of_pos (sq_pos_of_ne_zero hc.ne.symm), hX.ofReal_variance_eq] - convert @meas_ge_le_evariance_div_sq _ _ _ _ hX.1 c.toNNReal (by simp [hc]) using 1 + convert! @meas_ge_le_evariance_div_sq _ _ _ _ hX.1 c.toNNReal (by simp [hc]) using 1 · simp · rw [ENNReal.ofReal_pow hc.le] rfl diff --git a/Mathlib/Probability/ProbabilityMassFunction/Binomial.lean b/Mathlib/Probability/ProbabilityMassFunction/Binomial.lean index a8b9b9d3bd1805..e1563766b878ff 100644 --- a/Mathlib/Probability/ProbabilityMassFunction/Binomial.lean +++ b/Mathlib/Probability/ProbabilityMassFunction/Binomial.lean @@ -31,7 +31,7 @@ def binomial (p : ℝ≥0) (h : p ≤ 1) (n : ℕ) : PMF (Fin (n + 1)) := ↑(p ^ (i : ℕ) * (1 - p) ^ ((Fin.last n - i) : ℕ) * (n.choose i : ℕ))) (by dsimp only norm_cast - convert (add_pow p (1 - p) n).symm + convert! (add_pow p (1 - p) n).symm · rw [Finset.sum_fin_eq_sum_range] apply Finset.sum_congr rfl intro i hi diff --git a/Mathlib/Probability/Process/Adapted.lean b/Mathlib/Probability/Process/Adapted.lean index 698a269f58a097..4b0473c6c2ada0 100644 --- a/Mathlib/Probability/Process/Adapted.lean +++ b/Mathlib/Probability/Process/Adapted.lean @@ -311,7 +311,7 @@ protected alias finset_prod' := MeasureTheory.IsStronglyProgressive.finsetProd' protected theorem finsetProd {γ} [CommMonoid β] [ContinuousMul β] {U : γ → ι → Ω → β} {s : Finset γ} (h : ∀ c ∈ s, IsStronglyProgressive f (U c)) : IsStronglyProgressive f fun i a => ∏ c ∈ s, U c i a := by - convert IsStronglyProgressive.finsetProd' h using 1; ext (i a); simp only [Finset.prod_apply] + convert! IsStronglyProgressive.finsetProd' h using 1; ext (i a); simp only [Finset.prod_apply] @[deprecated (since := "2026-04-08")] protected alias finset_sum := MeasureTheory.IsStronglyProgressive.finsetSum diff --git a/Mathlib/Probability/Process/Filtration.lean b/Mathlib/Probability/Process/Filtration.lean index 0a2d61a3547b4a..0ad8aa6fb16ea3 100644 --- a/Mathlib/Probability/Process/Filtration.lean +++ b/Mathlib/Probability/Process/Filtration.lean @@ -399,6 +399,11 @@ def natural (u : (i : ι) → Ω → β i) (hum : ∀ i, StronglyMeasurable (u i rintro j _ s ⟨t, ht, rfl⟩ exact (hum j).measurable ht +lemma natural_eq_comap (u : (i : ι) → Ω → β i) (hum : ∀ (i : ι), StronglyMeasurable (u i)) (i : ι) : + natural u hum i = .comap (fun ω (j : Set.Iic i) ↦ u j ω) inferInstance := by + simp_rw [natural, MeasurableSpace.comap_process_pi, iSup_subtype'] + rfl + section open MeasurableSpace diff --git a/Mathlib/Probability/Process/Kolmogorov.lean b/Mathlib/Probability/Process/Kolmogorov.lean index 74d32fb5c4d8e3..33a3de483a7edc 100644 --- a/Mathlib/Probability/Process/Kolmogorov.lean +++ b/Mathlib/Probability/Process/Kolmogorov.lean @@ -82,7 +82,7 @@ lemma ae_eq_mk (h : IsAEKolmogorovProcess X P p q M) : ∀ t, X t =ᵐ[P] h.mk X lemma kolmogorovCondition (hX : IsAEKolmogorovProcess X P p q M) (s t : T) : ∫⁻ ω, edist (X s ω) (X t ω) ^ p ∂P ≤ M * edist s t ^ q := by - convert hX.IsKolmogorovProcess_mk.kolmogorovCondition s t using 1 + convert! hX.IsKolmogorovProcess_mk.kolmogorovCondition s t using 1 refine lintegral_congr_ae ?_ filter_upwards [hX.ae_eq_mk s, hX.ae_eq_mk t] with ω hω₁ hω₂ simp_rw [hω₁, hω₂] diff --git a/Mathlib/Probability/Process/LocalProperty.lean b/Mathlib/Probability/Process/LocalProperty.lean index 375633b3c1065e..4078759db74a29 100644 --- a/Mathlib/Probability/Process/LocalProperty.lean +++ b/Mathlib/Probability/Process/LocalProperty.lean @@ -170,8 +170,9 @@ lemma IsStable.locally_and_iff (hp : IsStable 𝓕 p) (hq : IsStable 𝓕 q) : simp_rw [inf_comm hpX.localSeq] exact this q p hq hp hqX hpX intro p q hp hq hpX hqX - convert hp _ (hpX.stoppedProcess_localSeq n) _ <| - hqX.isLocalizingSequence_localSeq.isStoppingTime n using 1 + convert! + hp _ (hpX.stoppedProcess_localSeq n) _ <| + hqX.isLocalizingSequence_localSeq.isStoppingTime n using 1 ext i ω simp_rw [stoppedProcess_indicator_comm, Pi.inf_apply, lt_inf_iff, inf_comm (hpX.localSeq n)] rw [← stoppedProcess_stoppedProcess, ← stoppedProcess_indicator_comm, Set.setOf_and, @@ -214,8 +215,8 @@ lemma IsStable.locally_of_isPreLocalizingSequence rw [stoppedProcess_indicator_comm', ← stoppedProcess_stoppedProcess_of_le_right (τ := fun ω ↦ τ n ω) (fun _ ↦ (iInf_le _ n).trans <| iInf_le _ le_rfl), ← stoppedProcess_indicator_comm'] - convert hp _ (hpτ n) (fun ω ↦ ⨅ j ≥ n, τ j ω) <| - hτ.isLocalizingSequence_biInf.isStoppingTime n using 2 + convert! + hp _ (hpτ n) (fun ω ↦ ⨅ j ≥ n, τ j ω) <| hτ.isLocalizingSequence_biInf.isStoppingTime n using 2 ext i ω rw [stoppedProcess_indicator_comm', Set.indicator_indicator] congr with ω @@ -310,7 +311,7 @@ lemma IsStable.locally_locally_iff [IsRightContinuous 𝓕] (hp : IsStable 𝓕 obtain ⟨nk, hnk, hpre⟩ := hL.isLocalizingSequence_localSeq.isPrelocalizingSequence_inf_extraction hτ₁ refine locally_of_isPreLocalizingSequence hp hpre <| fun n ↦ ?_ - convert hτ₂ n (nk n) using 1 with + convert! hτ₂ n (nk n) using 1 with ext i ω rw [stoppedProcess_indicator_comm', stoppedProcess_indicator_comm', stoppedProcess_stoppedProcess, stoppedProcess_indicator_comm'] diff --git a/Mathlib/Probability/Process/PartitionFiltration.lean b/Mathlib/Probability/Process/PartitionFiltration.lean index 9edb2ab461038e..1f100fc7eda116 100644 --- a/Mathlib/Probability/Process/PartitionFiltration.lean +++ b/Mathlib/Probability/Process/PartitionFiltration.lean @@ -73,7 +73,7 @@ lemma measurable_memPartitionSet_subtype (ht : ∀ n, MeasurableSet (t n)) (n : (partitionFiltration ht n) _ (fun s ↦ ?_) rcases s with ⟨s, hs⟩ suffices MeasurableSet[partitionFiltration ht n] {x | memPartitionSet t n x = s} by - convert this + convert! this ext x simp simp_rw [memPartitionSet_eq_iff _ hs] diff --git a/Mathlib/Probability/Process/Stopping.lean b/Mathlib/Probability/Process/Stopping.lean index 749ed011ec5f4a..672b3a57cd6f9c 100644 --- a/Mathlib/Probability/Process/Stopping.lean +++ b/Mathlib/Probability/Process/Stopping.lean @@ -387,7 +387,7 @@ protected lemma iInf [ConditionallyCompleteLinearOrderBot ι] [TopologicalSpace {κ : Type*} [Countable κ] {f : Filtration ι m} {τ : κ → Ω → WithTop ι} [f.IsRightContinuous] (hτ : ∀ n, IsStoppingTime f (τ n)) : IsStoppingTime f (fun ω ↦ ⨅ n, τ n ω) := by - convert IsStoppingTime.biInf (κ := κ) Set.countable_univ (fun n _ => hτ n) using 2 + convert! IsStoppingTime.biInf (κ := κ) Set.countable_univ (fun n _ => hτ n) using 2 simp theorem add_const [AddGroup ι] [Preorder ι] [AddRightMono ι] @@ -762,7 +762,7 @@ theorem measurableSet_eq_stopping_time_min [TopologicalSpace ι] ext; simp only [Set.mem_setOf_eq, le_antisymm_iff, Set.mem_inter_iff] rw [this] refine MeasurableSet.inter (measurableSet_stopping_time_le_min hτ hπ) ?_ - convert (measurableSet_stopping_time_le_min hπ hτ) using 3 + convert! (measurableSet_stopping_time_le_min hπ hτ) using 3 rw [min_comm] theorem measurableSet_eq_stopping_time [TopologicalSpace ι] [OrderTopology ι] @@ -917,7 +917,7 @@ theorem isStronglyProgressive_min_stopping_time [PseudoMetrizableSpace ι] · lift τ (ω : Set.Iic i × Ω).2 to ι using h with t ht norm_cast refine hx_fst_le.trans (le_of_lt ?_) - convert ω.prop + convert! ω.prop simp only [sc, s, not_le, Set.mem_compl_iff, Set.mem_setOf_eq, ← ht] norm_cast @@ -1157,7 +1157,7 @@ theorem memLp_stoppedProcess_of_mem_finset (hτ : IsStoppingTime ℱ τ) (hu : refine MemLp.add ?_ ?_ · exact MemLp.indicator (ℱ.le n {a : Ω | n ≤ τ a} (hτ.measurableSet_ge n)) (hu n) · suffices MemLp (fun ω => ∑ i ∈ s with i < n, {a : Ω | τ a = i}.indicator (u i) ω) p μ by - convert this using 1; ext1 ω; simp only [Finset.sum_apply] + convert! this using 1; ext1 ω; simp only [Finset.sum_apply] refine memLp_finsetSum _ fun i _ => MemLp.indicator ?_ (hu i) exact ℱ.le i {a : Ω | τ a = i} (hτ.measurableSet_eq i) diff --git a/Mathlib/Probability/ProductMeasure.lean b/Mathlib/Probability/ProductMeasure.lean index 49333de91686c9..58ab7130e5ee7d 100644 --- a/Mathlib/Probability/ProductMeasure.lean +++ b/Mathlib/Probability/ProductMeasure.lean @@ -321,16 +321,16 @@ theorem piContent_tendsto_zero {A : ℕ → Set (Π i, X i)} (A_mem : ∀ n, A n obtain u_fin | u_inf := finite_or_infinite u · let _ := Fintype.ofFinite u simp_rw [fun n ↦ piContent_eq_measure_pi (fun i : u ↦ μ i) (mB n)] - convert tendsto_measure_iInter_atTop (fun n ↦ (mB n).nullMeasurableSet) B_anti - ⟨0, measure_ne_top _ _⟩ + convert! + tendsto_measure_iInter_atTop (fun n ↦ (mB n).nullMeasurableSet) B_anti ⟨0, measure_ne_top _ _⟩ · rw [B_inter, measure_empty] · infer_instance · -- If `u` is infinite, then we have an equivalence with `ℕ` so we can apply `secondLemma`. have count_u : Countable u := Set.countable_iUnion (fun n ↦ (s n).countable_toSet) obtain ⟨φ, -⟩ := Classical.exists_true_of_nonempty (α := ℕ ≃ u) nonempty_equiv_of_countable conv => enter [1]; ext n; rw [← infinitePiNat_map_piCongrLeft _ φ (B_mem n)] - convert tendsto_measure_iInter_atTop (fun n ↦ (mB n).nullMeasurableSet) B_anti - ⟨0, measure_ne_top _ _⟩ + convert! + tendsto_measure_iInter_atTop (fun n ↦ (mB n).nullMeasurableSet) B_anti ⟨0, measure_ne_top _ _⟩ · rw [B_inter, measure_empty] · infer_instance @@ -551,7 +551,7 @@ lemma infinitePi_map_curry_symm : (MeasurableEquiv.curry ι κ X).symm = ⇑(MeasurableEquiv.piCurry (fun _ _ ↦ X)).symm := by ext; simp [piCongrLeft, Equiv.piCongrLeft, Sigma.uncurry] rw [this, infinitePi_map_piCurry_symm] - convert infinitePi_map_piCongrLeft (fun p ↦ μ p.1 p.2) (Equiv.sigmaEquivProd ι κ).symm |>.symm + convert! infinitePi_map_piCongrLeft (fun p ↦ μ p.1 p.2) (Equiv.sigmaEquivProd ι κ).symm |>.symm all_goals fun_prop lemma infinitePi_map_curry : diff --git a/Mathlib/Probability/StrongLaw.lean b/Mathlib/Probability/StrongLaw.lean index 6253ae7727ce17..53c6b47a496a70 100644 --- a/Mathlib/Probability/StrongLaw.lean +++ b/Mathlib/Probability/StrongLaw.lean @@ -431,7 +431,7 @@ theorem strong_law_aux1 {c : ℝ} (c_one : 1 < c) {ε : ℝ} (εpos : 0 < ε) : · simp only [Nat.cast_zero] simp only [Y, Nat.cast_zero, truncation_zero, variance_zero, mul_zero, le_rfl] apply mul_le_mul_of_nonneg_right _ (variance_nonneg _ _) - convert sum_div_nat_floor_pow_sq_le_div_sq N (Nat.cast_pos.2 hj) c_one using 2 + convert! sum_div_nat_floor_pow_sq_le_div_sq N (Nat.cast_pos.2 hj) c_one using 2 · simp only [u, Nat.cast_lt] · simp only [u, one_div] _ = c ^ 5 * (c - 1)⁻¹ ^ 3 * ∑ j ∈ range (u (N - 1)), ((j : ℝ) ^ 2)⁻¹ * Var[Y j] := by @@ -468,7 +468,7 @@ theorem strong_law_aux1 {c : ℝ} (c_one : 1 < c) {ε : ℝ} (εpos : 0 < ε) : ENNReal.ofReal_lt_top filter_upwards [ae_eventually_notMem I4.ne] with ω hω simp_rw [S, not_le, mul_comm, sum_apply] at hω - convert hω; simp only [Y, u, sum_apply] + convert! hω; simp only [Y, u, sum_apply] include hint hindep hident hnonneg in /-- The truncation of `Xᵢ` up to `i` satisfies the strong law of large numbers @@ -494,10 +494,10 @@ expectation. This follows from convergence and Cesàro averaging. -/ theorem strong_law_aux3 : (fun n => 𝔼[∑ i ∈ range n, truncation (X i) i] - n * 𝔼[X 0]) =o[atTop] ((↑) : ℕ → ℝ) := by have A : Tendsto (fun i => 𝔼[truncation (X i) i]) atTop (𝓝 𝔼[X 0]) := by - convert (tendsto_integral_truncation hint).comp tendsto_natCast_atTop_atTop using 1 + convert! (tendsto_integral_truncation hint).comp tendsto_natCast_atTop_atTop using 1 ext i exact (hident i).truncation.integral_eq - convert Asymptotics.isLittleO_sum_range_of_tendsto_zero (tendsto_sub_nhds_zero_iff.2 A) using 1 + convert! Asymptotics.isLittleO_sum_range_of_tendsto_zero (tendsto_sub_nhds_zero_iff.2 A) using 1 ext1 n simp only [sum_sub_distrib, sum_const, card_range, nsmul_eq_mul, sum_apply, sub_left_inj] rw [integral_finsetSum _ fun i _ => ?_] @@ -514,7 +514,7 @@ theorem strong_law_aux4 {c : ℝ} (c_one : 1 < c) : filter_upwards [strong_law_aux2 X hint hindep hident hnonneg c_one] with ω hω have A : Tendsto (fun n : ℕ => ⌊c ^ n⌋₊) atTop atTop := tendsto_nat_floor_atTop.comp (tendsto_pow_atTop_atTop_of_one_lt c_one) - convert hω.add ((strong_law_aux3 X hint hident).comp_tendsto A) using 1 + convert! hω.add ((strong_law_aux3 X hint hident).comp_tendsto A) using 1 ext1 n simp @@ -526,7 +526,7 @@ theorem strong_law_aux5 : ∀ᵐ ω, (fun n : ℕ => ∑ i ∈ range n, truncation (X i) i ω - ∑ i ∈ range n, X i ω) =o[atTop] fun n : ℕ => (n : ℝ) := by have A : (∑' j : ℕ, ℙ {ω | X j ω ∈ Set.Ioi (j : ℝ)}) < ∞ := by - convert tsum_prob_mem_Ioi_lt_top hint (hnonneg 0) using 2 + convert! tsum_prob_mem_Ioi_lt_top hint (hnonneg 0) using 2 ext1 j exact (hident j).measure_mem_eq measurableSet_Ioi have B : ∀ᵐ ω, Tendsto (fun n : ℕ => truncation (X n) n ω - X n ω) atTop (𝓝 0) := by @@ -542,7 +542,7 @@ theorem strong_law_aux5 : simp only [this, true_and, not_le] at h exact (hn h).elim filter_upwards [B] with ω hω - convert isLittleO_sum_range_of_tendsto_zero hω using 1 + convert! isLittleO_sum_range_of_tendsto_zero hω using 1 ext n rw [sum_sub_distrib] @@ -563,10 +563,10 @@ theorem strong_law_aux6 {c : ℝ} (c_one : 1 < c) : (⌊c ^ n⌋₊ : ℝ) := by have A : Tendsto (fun n : ℕ => ⌊c ^ n⌋₊) atTop atTop := tendsto_nat_floor_atTop.comp (tendsto_pow_atTop_atTop_of_one_lt c_one) - convert hω.sub (h'ω.comp_tendsto A) using 1 + convert! hω.sub (h'ω.comp_tendsto A) using 1 ext1 n simp only [Function.comp_apply, sub_sub_sub_cancel_left] - convert L.mul_isBigO (isBigO_refl (fun n : ℕ => (⌊c ^ n⌋₊ : ℝ)⁻¹) atTop) using 1 <;> + convert! L.mul_isBigO (isBigO_refl (fun n : ℕ => (⌊c ^ n⌋₊ : ℝ)⁻¹) atTop) using 1 <;> (ext1 n; field [(H n).ne']) include hint hindep hident hnonneg in @@ -624,7 +624,7 @@ theorem strong_law_ae_real {Ω : Type*} {m : MeasurableSpace Ω} {μ : Measure strong_law_aux7 _ hint.neg_part (fun i j hij => (hindep hij).comp negm negm) (fun i => (hident i).comp negm) fun i ω => le_max_right _ _ filter_upwards [A, B] with ω hωpos hωneg - convert hωpos.sub hωneg using 2 + convert! hωpos.sub hωneg using 2 · simp only [pos, neg, ← sub_div, ← sum_sub_distrib, max_zero_sub_max_neg_zero_eq_self, Function.comp_apply] · simp +instances only [pos, neg, ← integral_sub hint.pos_part hint.neg_part, @@ -676,11 +676,11 @@ lemma strong_law_ae_simpleFunc_comp (X : ℕ → Ω → E) (h' : Measurable (X 0 ext simp simp only [I, integral_smul_const] - convert Tendsto.smul_const hω c using 1 + convert! Tendsto.smul_const hω c using 1 simp [F, Y, ← sum_smul, smul_smul] · rintro φ ψ - hφ hψ filter_upwards [hφ, hψ] with ω hωφ hωψ - convert hωφ.add hωψ using 1 + convert! hωφ.add hωψ using 1 · simp [sum_add_distrib] · congr 1 rw [← integral_add] diff --git a/Mathlib/RepresentationTheory/Action.lean b/Mathlib/RepresentationTheory/Action.lean index 9bdb1eb56558d9..23a83f8787f1c5 100644 --- a/Mathlib/RepresentationTheory/Action.lean +++ b/Mathlib/RepresentationTheory/Action.lean @@ -154,7 +154,7 @@ lemma μ_comp_assoc : ((linearizeMap (α_ X Y Z).hom).comp TensorProduct.assoc_tmul, LinearMap.lTensor_tmul, toLinearMap_apply] -- after fixing the defeq problems in `Action` and in the monoidal category structure of `types` -- this line should close the goal so this is left as an indicator. - with_reducible convert dsimp% linearizeMap_single (α_ X Y Z).hom ((x, y), z) (1 : k) + with_reducible convert! dsimp% linearizeMap_single (α_ X Y Z).hom ((x, y), z) (1 : k) all_goals with_reducible simp variable (X) in diff --git a/Mathlib/RepresentationTheory/Character.lean b/Mathlib/RepresentationTheory/Character.lean index d9173aa051e474..5b1acb384378ab 100644 --- a/Mathlib/RepresentationTheory/Character.lean +++ b/Mathlib/RepresentationTheory/Character.lean @@ -64,7 +64,7 @@ theorem char_one (V : FDRep k G) : V.character 1 = Module.finrank k V := by /-- The character is multiplicative under the tensor product. -/ @[simp] theorem char_tensor (V W : FDRep k G) : (V ⊗ W).character = V.character * W.character := by - ext g; convert trace_tensorProduct' (V.ρ g) (W.ρ g) + ext g; convert! trace_tensorProduct' (V.ρ g) (W.ρ g) /-- The character of isomorphic representations is the same. -/ theorem char_iso {V W : FDRep k G} (i : V ≅ W) : V.character = W.character := by @@ -163,7 +163,7 @@ theorem char_one (ρ : Representation k G V) : ρ.character 1 = Module.finrank k /-- The character is multiplicative under the tensor product. -/ @[simp] theorem char_tensor : (tprod ρ σ).character = ρ.character * σ.character := by - ext g; convert trace_tensorProduct' (ρ g) (σ g) + ext g; convert! trace_tensorProduct' (ρ g) (σ g) omit [FiniteDimensional k V] [FiniteDimensional k W] in variable {ρ σ} in diff --git a/Mathlib/RepresentationTheory/Homological/GroupHomology/Functoriality.lean b/Mathlib/RepresentationTheory/Homological/GroupHomology/Functoriality.lean index 9e0abfbb54948a..130e3cd83743ac 100644 --- a/Mathlib/RepresentationTheory/Homological/GroupHomology/Functoriality.lean +++ b/Mathlib/RepresentationTheory/Homological/GroupHomology/Functoriality.lean @@ -424,7 +424,7 @@ noncomputable def H1CoresCoinfOfTrivial : instance map₁_quotientGroupMk'_epi : Epi (map (QuotientGroup.mk' S) (resOfQuotientIso A S).inv 1) := by - convert epi_of_epi (H1π A) _ + convert! epi_of_epi (H1π A) _ rw [H1π_comp_map] exact @epi_comp _ _ _ _ _ _ (mapCycles₁_quotientGroupMk'_epi A S) (H1π _) inferInstance diff --git a/Mathlib/RepresentationTheory/Submodule.lean b/Mathlib/RepresentationTheory/Submodule.lean index 709eeb26d00866..dae58013ec3545 100644 --- a/Mathlib/RepresentationTheory/Submodule.lean +++ b/Mathlib/RepresentationTheory/Submodule.lean @@ -79,7 +79,7 @@ noncomputable def mapSubmodule : ρ.invtSubmodule ≃o Submodule k[G] ρ.asModul rw [invtSubmodule, Sublattice.mem_iInf] intro g v hv simp only [Submodule.orderIsoMapComap_symm_apply, Submodule.mem_comap] at hv ⊢ - convert q.smul_mem (MonoidAlgebra.of k G g) hv using 1 + convert! q.smul_mem (MonoidAlgebra.of k G g) hv using 1 rw [LinearEquiv.coe_coe, ← asModuleEquiv_symm_map_rho]⟩ left_inv p := by ext; simp right_inv q := by ext; aesop diff --git a/Mathlib/RingTheory/AdicCompletion/Basic.lean b/Mathlib/RingTheory/AdicCompletion/Basic.lean index b328fb7d5d1e15..031a570bed7988 100644 --- a/Mathlib/RingTheory/AdicCompletion/Basic.lean +++ b/Mathlib/RingTheory/AdicCompletion/Basic.lean @@ -888,7 +888,7 @@ theorem le_jacobson_bot [IsAdicComplete I R] : I ≤ (⊥ : Ideal R).jacobson := rw [SModEq.sub_mem, smul_eq_mul, Ideal.mul_top] at hL ⊢ rw [sub_zero] suffices (1 - x * y) * f n - 1 ∈ I ^ n by - convert Ideal.sub_mem _ this (Ideal.mul_mem_left _ (1 + -(x * y)) hL) using 1 + convert! Ideal.sub_mem _ this (Ideal.mul_mem_left _ (1 + -(x * y)) hL) using 1 ring cases n · simp only [Ideal.one_eq_top, pow_zero, mem_top] diff --git a/Mathlib/RingTheory/Adjoin/Polynomial/Basic.lean b/Mathlib/RingTheory/Adjoin/Polynomial/Basic.lean index a33335e1598d4c..fdf11077faaad4 100644 --- a/Mathlib/RingTheory/Adjoin/Polynomial/Basic.lean +++ b/Mathlib/RingTheory/Adjoin/Polynomial/Basic.lean @@ -57,6 +57,10 @@ theorem adjoin_singleton_eq_range_aeval (x : A) : theorem _root_.Polynomial.aeval_mem_adjoin_singleton : aeval x p ∈ adjoin R {x} := by simp [adjoin_singleton_eq_range_aeval] +instance {A B : Type*} [CommSemiring A] [Semiring B] [Algebra A B] (x : B) (p : Polynomial A) : + CoeDep B (p.aeval x) (Algebra.adjoin A {x}) where + coe := ⟨p.aeval x, aeval_mem_adjoin_singleton A x⟩ + theorem adjoin_mem_exists_aeval {a : A} (h : a ∈ R[x]) : ∃ p : R[X], aeval x p = a := by rw [Algebra.adjoin_singleton_eq_range_aeval] at h @@ -74,9 +78,7 @@ Proving a fact about `a : adjoin R {x}` is the same as proving it for `aeval x p` where `p`is an arbitrary polynomial. -/ @[elab_as_elim] theorem adjoin_singleton_induction {M : (adjoin R {x}) → Prop} - (a : adjoin R {x}) (f : ∀ (p : Polynomial R), - M (⟨aeval x p, aeval_mem_adjoin_singleton R x⟩ : adjoin R {x})) : - M a := by + (a : adjoin R {x}) (f : ∀ (p : Polynomial R), M (aeval x p : adjoin R {x})) : M a := by obtain ⟨p, hp⟩ := Algebra.adjoin_eq_exists_aeval _ x a grind diff --git a/Mathlib/RingTheory/Adjoin/PowerBasis.lean b/Mathlib/RingTheory/Adjoin/PowerBasis.lean index d75794aca16099..22eea1d4c8c47c 100644 --- a/Mathlib/RingTheory/Adjoin/PowerBasis.lean +++ b/Mathlib/RingTheory/Adjoin/PowerBasis.lean @@ -32,7 +32,7 @@ noncomputable def adjoin.powerBasisAux {x : S} (hx : IsIntegral K x) : have hx' : IsIntegral K (⟨x, subset_adjoin (Set.mem_singleton x)⟩ : K[(x : S)]) := by apply (isIntegral_algebraMap_iff hST).mp - convert hx + convert! hx apply Basis.mk (v := fun i : Fin _ ↦ ⟨x, subset_adjoin (Set.mem_singleton x)⟩ ^ (i : ℕ)) · have : LinearIndependent K _ := linearIndependent_pow (⟨x, self_mem_adjoin_singleton _ _⟩ : K[x]) diff --git a/Mathlib/RingTheory/Adjoin/Tower.lean b/Mathlib/RingTheory/Adjoin/Tower.lean index 7a1082197337f9..585ddd6c46ce98 100644 --- a/Mathlib/RingTheory/Adjoin/Tower.lean +++ b/Mathlib/RingTheory/Adjoin/Tower.lean @@ -122,7 +122,7 @@ theorem exists_subalgebra_of_fg (hAC : (⊤ : Subalgebra A C).FG) (hBC : (⊤ : mem_image₂_of_mem (mem_union_right _ <| mul_mem_mul hyi hyj) hyk⟩ (subset_span <| Set.mem_insert_of_mem _ hyk : yk ∈ _)) refine ⟨Algebra.adjoin A (↑s : Set B), Subalgebra.fg_adjoin_finset _, insert 1 y, ?_⟩ - convert restrictScalars_injective A (Algebra.adjoin A (s : Set B)) C _ + convert! restrictScalars_injective A (Algebra.adjoin A (s : Set B)) C _ rw [restrictScalars_top, eq_top_iff, ← Algebra.top_toSubmodule, ← hx, Algebra.adjoin_eq_span, span_le] refine fun r hr => diff --git a/Mathlib/RingTheory/AdjoinRoot.lean b/Mathlib/RingTheory/AdjoinRoot.lean index 307287e3d544fa..c8423bc7357438 100644 --- a/Mathlib/RingTheory/AdjoinRoot.lean +++ b/Mathlib/RingTheory/AdjoinRoot.lean @@ -344,7 +344,7 @@ section AdjoinInv @[simp] theorem root_isInv (r : R) : of _ r * root (C r * X - 1) = 1 := by - convert sub_eq_zero.1 ((eval₂_sub _).symm.trans <| eval₂_root <| C r * X - 1) <;> + convert! sub_eq_zero.1 ((eval₂_sub _).symm.trans <| eval₂_root <| C r * X - 1) <;> simp only [eval₂_mul, eval₂_C, eval₂_X, eval₂_one] theorem algHom_subsingleton {S : Type*} [CommRing S] [Algebra R S] {r : R} : diff --git a/Mathlib/RingTheory/Algebraic/Basic.lean b/Mathlib/RingTheory/Algebraic/Basic.lean index d8786723e0bf6c..d1fefdb9b42f5a 100644 --- a/Mathlib/RingTheory/Algebraic/Basic.lean +++ b/Mathlib/RingTheory/Algebraic/Basic.lean @@ -115,7 +115,7 @@ theorem transcendental_iff_ker_eq_bot {x : A} : theorem Algebra.isAlgebraic_of_not_injective (h : ¬ Function.Injective (algebraMap R A)) : Algebra.IsAlgebraic R A where isAlgebraic a := isAlgebraic_iff_not_injective.mpr - fun inj ↦ h <| by convert inj.comp C_injective; ext; simp + fun inj ↦ h <| by convert! inj.comp C_injective; ext; simp theorem Algebra.injective_of_transcendental [h : Algebra.Transcendental R A] : Function.Injective (algebraMap R A) := by @@ -659,11 +659,12 @@ theorem inv_eq_of_aeval_divX_ne_zero {x : L} {p : K[X]} (aeval_ne : aeval x (div theorem inv_eq_of_root_of_coeff_zero_ne_zero {x : L} {p : K[X]} (aeval_eq : aeval x p = 0) (coeff_zero_ne : p.coeff 0 ≠ 0) : x⁻¹ = -(aeval x (divX p) / algebraMap _ _ (p.coeff 0)) := by - convert inv_eq_of_aeval_divX_ne_zero (p := p) (L := L) - (mt (fun h => (algebraMap K L).injective ?_) coeff_zero_ne) using 1 + convert! + inv_eq_of_aeval_divX_ne_zero (p := p) (L := L) + (mt (fun h => (algebraMap K L).injective ?_) coeff_zero_ne) using 1 · rw [aeval_eq, zero_sub, div_neg] rw [RingHom.map_zero] - convert aeval_eq + convert! aeval_eq conv_rhs => rw [← divX_mul_X_add p] rw [map_add, map_mul, h, zero_mul, zero_add, aeval_C] diff --git a/Mathlib/RingTheory/Algebraic/Integral.lean b/Mathlib/RingTheory/Algebraic/Integral.lean index 894cfd69ab8dfa..0a565895b79aeb 100644 --- a/Mathlib/RingTheory/Algebraic/Integral.lean +++ b/Mathlib/RingTheory/Algebraic/Integral.lean @@ -192,6 +192,32 @@ theorem iff_exists_smul_integral [IsReduced R] : ⟨(exists_integral_multiple ·), fun ⟨_, hy, int⟩ ↦ of_smul_isIntegral (by rwa [isNilpotent_iff_eq_zero]) int⟩ +section integralClosure + +variable {K : Type*} [CommRing K] [Algebra S K] [Algebra R K] [IsIntegralClosure S R K] + +variable (S) + +omit [Algebra R S] in +/-- If `x : K` is algebraic over some ring `R`, then a nonzero `R`-multiple of it is contained +in the integral closure of `R` in `K`. -/ +lemma exists_smul_eq {x : K} (hx : IsAlgebraic R x) : + ∃ (r : R) (s : S), r ≠ 0 ∧ r • x = algebraMap S K s := by + obtain ⟨r, hr, h⟩ := hx.exists_integral_multiple + obtain ⟨s, hs⟩ := IsIntegralClosure.isIntegral_iff (A := S) |>.mp h + exact ⟨r, s, hr, hs.symm⟩ + +/-- If `x : K` is algebraic over `ℤ`, then a nonzero `ℕ`-multiple of it is contained in the +integral closure of `ℤ` in `K`. -/ +lemma exists_nsmul_eq [IsIntegralClosure S ℤ K] {x : K} (hx : IsAlgebraic ℤ x) : + ∃ (m : ℕ) (s : S), m ≠ 0 ∧ m • x = algebraMap S K s := by + obtain ⟨a, s, ha, h⟩ := hx.exists_smul_eq S + obtain ⟨n, rfl | rfl⟩ := a.eq_nat_or_neg + · exact ⟨n, s, mod_cast ha, mod_cast h⟩ + · exact ⟨n, -s, by simpa using ha, by simp [← h]⟩ + +end integralClosure + section restrictScalars variable (R) [NoZeroDivisors S] diff --git a/Mathlib/RingTheory/AlgebraicIndependent/Basic.lean b/Mathlib/RingTheory/AlgebraicIndependent/Basic.lean index a916bfe1192369..94856a80f5a219 100644 --- a/Mathlib/RingTheory/AlgebraicIndependent/Basic.lean +++ b/Mathlib/RingTheory/AlgebraicIndependent/Basic.lean @@ -241,7 +241,7 @@ theorem algebraicIndependent_finset_map_embedding_subtype (s : Set A) rw [Finset.mem_map] at h obtain ⟨a, _, rfl⟩ := h simp only [Subtype.coe_prop, Embedding.coe_subtype]⟩ - convert AlgebraicIndependent.comp li f _ + convert! AlgebraicIndependent.comp li f _ rintro ⟨x, hx⟩ ⟨y, hy⟩ rw [Finset.mem_map] at hx hy obtain ⟨a, _, rfl⟩ := hx @@ -311,11 +311,11 @@ lemma IsTranscendenceBasis.of_comp_algebraMap [Algebra A A'] [IsScalarTower R A for the composition with an algebraic extension. -/ theorem AlgEquiv.isTranscendenceBasis (e : A ≃ₐ[R] A') (hx : IsTranscendenceBasis R x) : IsTranscendenceBasis R (e ∘ x) := - .of_comp e.symm.toAlgHom e.symm.injective (by convert hx; ext; simp) + .of_comp e.symm.toAlgHom e.symm.injective (by convert! hx; ext; simp) theorem AlgEquiv.isTranscendenceBasis_iff (e : A ≃ₐ[R] A') : IsTranscendenceBasis R (e ∘ x) ↔ IsTranscendenceBasis R x := - ⟨fun hx ↦ by convert e.symm.isTranscendenceBasis hx; ext; simp, e.isTranscendenceBasis⟩ + ⟨fun hx ↦ by convert! e.symm.isTranscendenceBasis hx; ext; simp, e.isTranscendenceBasis⟩ section trdeg @@ -346,7 +346,7 @@ theorem lift_trdeg_le_of_surjective (f : A →ₐ[R] A') (hf : Surjective f) : rw [trdeg, lift_iSup bddAbove_of_small] refine ciSup_le' fun i ↦ (lift_cardinalMk_le_trdeg (x := fun a : i.1 ↦ (⇑f).invFun a) <| of_comp f ?_) - convert i.2; simp [invFun_eq (hf _)] + convert! i.2; simp [invFun_eq (hf _)] theorem trdeg_le_of_surjective {A' : Type v} [CommRing A'] [Algebra R A'] (f : A →ₐ[R] A') (hf : Surjective f) : trdeg R A' ≤ trdeg R A := by @@ -399,7 +399,7 @@ theorem AlgebraicIndependent.image_of_comp {ι ι'} (s : Set ι) (f : ι → ι' theorem AlgebraicIndependent.image {ι} {s : Set ι} {f : ι → A} (hs : AlgebraicIndependent R fun x : s => f x) : AlgebraicIndependent R fun x : f '' s => (x : A) := by - convert AlgebraicIndependent.image_of_comp s f id hs + convert! AlgebraicIndependent.image_of_comp s f id hs theorem algebraicIndependent_iUnion_of_directed {η : Type*} [Nonempty η] {s : η → Set A} (hs : Directed (· ⊆ ·) s) (h : ∀ i, AlgebraicIndependent R ((↑) : s i → A)) : diff --git a/Mathlib/RingTheory/AlgebraicIndependent/TranscendenceBasis.lean b/Mathlib/RingTheory/AlgebraicIndependent/TranscendenceBasis.lean index 1b261c9e579b6f..95ed4ca9810e96 100644 --- a/Mathlib/RingTheory/AlgebraicIndependent/TranscendenceBasis.lean +++ b/Mathlib/RingTheory/AlgebraicIndependent/TranscendenceBasis.lean @@ -185,7 +185,7 @@ theorem IsTranscendenceBasis.polynomial [Nonempty ι] [Subsingleton ι] : have := (nonempty_unique ι).some refine (isTranscendenceBasis_equiv (Equiv.equivPUnit.{_, 1} _).symm).mp <| (MvPolynomial.uniqueAlgEquiv R PUnit).symm.isTranscendenceBasis_iff.mp ?_ - convert IsTranscendenceBasis.mvPolynomial PUnit R + convert! IsTranscendenceBasis.mvPolynomial PUnit R ext; simp variable {ι R} @@ -575,8 +575,12 @@ lemma of_isAlgebraic_adjoin_insert_diff (hj : j ∈ insert i s) rwa [insert_eq_of_mem hi] at H₂ obtain eq | ne := eq_or_ne (v i) (v j) · classical - convert H₁.comp_equiv <| .symm <| ((Equiv.swap j i).image s).trans <| - .setCongr <| Equiv.image_swap_of_mem_of_notMem hj hi with ⟨x, rfl | hxi, hxj⟩ + convert! + H₁.comp_equiv <| + .symm <| + ((Equiv.swap j i).image s).trans <| + .setCongr <| Equiv.image_swap_of_mem_of_notMem hj hi with + ⟨x, rfl | hxi, hxj⟩ · simp [eq] · simp [Equiv.swap_apply_of_ne_of_ne hxj (ne_of_mem_of_not_mem hxi hi)] have hi' : v i ∉ v '' s := fun his ↦ Hj <| by diff --git a/Mathlib/RingTheory/AlgebraicIndependent/Transcendental.lean b/Mathlib/RingTheory/AlgebraicIndependent/Transcendental.lean index b0136e12d0851f..9266cdcd630040 100644 --- a/Mathlib/RingTheory/AlgebraicIndependent/Transcendental.lean +++ b/Mathlib/RingTheory/AlgebraicIndependent/Transcendental.lean @@ -118,7 +118,7 @@ theorem AlgebraicIndepOn.insert_iff {s : Set ι} {i : ι} (h : i ∉ s) : AlgebraicIndepOn R x s ∧ Transcendental (adjoin R (x '' s)) (x i) := by classical simp_rw [← algebraicIndependent_equiv (subtypeInsertEquivOption h).symm, AlgebraicIndepOn] - convert option_iff (x := fun i : s ↦ x i) (a := x i) using 2 + convert! option_iff (x := fun i : s ↦ x i) (a := x i) using 2 · ext (_ | _) <;> rfl · rw [Set.image_eq_range] @@ -141,10 +141,13 @@ theorem algebraicIndependent_of_set_of_finite (s : Set ι) refine hfin.diff.induction_on_subset _ (ind.comp (inclusion <| by simp) (inclusion_injective _)) fun {a u} ha hu ha' h ↦ ?_ have : a ∉ t ∩ s ∪ u := (·.elim (ha.2 ·.2) ha') - convert (((image_eq_range .. ▸ h.option_iff_transcendental <| x a).2 <| H _ (hfin.subset - (union_subset inter_subset_left <| hu.trans diff_subset)) h a ha.2 this).comp _ - (subtypeInsertEquivOption this).injective).comp - (Equiv.setCongr union_insert) (Equiv.injective _) with x + convert! + (((image_eq_range .. ▸ h.option_iff_transcendental <| x a).2 <| + H _ (hfin.subset (union_subset inter_subset_left <| hu.trans diff_subset)) h a ha.2 + this).comp + _ (subtypeInsertEquivOption this).injective).comp + (Equiv.setCongr union_insert) (Equiv.injective _) with + x by_cases h : ↑x = a <;> simp [h, Set.subtypeInsertEquivOption] /-- Variant of `algebraicIndependent_of_finite_type` using `Transcendental`. -/ @@ -181,14 +184,14 @@ theorem iff_adjoin_image (s : Set ι) : AlgebraicIndependent R x ↔ AlgebraicIndependent R (fun i : s ↦ x i) ∧ AlgebraicIndepOn (adjoin R (x '' s)) x sᶜ := by rw [show x '' s = range fun i : s ↦ x i by ext; simp] - convert ← sumElim_iff + convert! ← sumElim_iff classical apply algebraicIndependent_equiv' ((Equiv.sumComm ..).trans (Equiv.Set.sumCompl ..)) ext (_ | _) <;> rfl theorem iff_adjoin_image_compl (s : Set ι) : AlgebraicIndependent R x ↔ AlgebraicIndependent R (fun i : ↥sᶜ ↦ x i) ∧ AlgebraicIndepOn (adjoin R (x '' sᶜ)) x s := by - convert ← iff_adjoin_image _; apply compl_compl + convert! ← iff_adjoin_image _; apply compl_compl theorem iff_transcendental_adjoin_image (i : ι) : AlgebraicIndependent R x ↔ AlgebraicIndependent R (fun j : {j // j ≠ i} ↦ x j) ∧ @@ -232,13 +235,13 @@ theorem adjoin_iff_disjoint [Nontrivial A] {s t : Set ι} : theorem transcendental_adjoin {s : Set ι} {i : ι} (hi : i ∉ s) : Transcendental (adjoin R (x '' s)) (x i) := by - convert ← hx.adjoin_of_disjoint (Set.disjoint_singleton_right.mpr hi) + convert! ← hx.adjoin_of_disjoint (Set.disjoint_singleton_right.mpr hi) rw [algebraicIndependent_singleton_iff ⟨i, rfl⟩] theorem transcendental_adjoin_iff [Nontrivial A] {s : Set ι} {i : ι} : Transcendental (adjoin R (x '' s)) (x i) ↔ i ∉ s := by rw [← Set.disjoint_singleton_right] - convert ← hx.adjoin_iff_disjoint (t := {i}) + convert! ← hx.adjoin_iff_disjoint (t := { i }) rw [algebraicIndependent_singleton_iff ⟨i, rfl⟩] end AlgebraicIndependent @@ -282,6 +285,6 @@ theorem AlgebraicIndependent.polynomial_aeval_of_transcendental (hx : AlgebraicIndependent R x) {f : ι → Polynomial R} (hf : ∀ i, Transcendental R (f i)) : AlgebraicIndependent R fun i ↦ Polynomial.aeval (x i) (f i) := by - convert aeval_of_algebraicIndependent hx (algebraicIndependent_polynomial_aeval_X _ hf) + convert! aeval_of_algebraicIndependent hx (algebraicIndependent_polynomial_aeval_X _ hf) rw [← AlgHom.comp_apply] congr 1; ext1; simp diff --git a/Mathlib/RingTheory/Artinian/Module.lean b/Mathlib/RingTheory/Artinian/Module.lean index 5d6fecae1db8e7..47f74093b6d109 100644 --- a/Mathlib/RingTheory/Artinian/Module.lean +++ b/Mathlib/RingTheory/Artinian/Module.lean @@ -536,7 +536,7 @@ lemma isField_of_isDomain [IsDomain R] : IsField R := by obtain ⟨n, y, hy⟩ := IsArtinian.exists_pow_succ_smul_dvd x (1 : R) replace hy : x ^ n * (x * y - 1) = 0 := by rw [mul_sub, sub_eq_zero] - convert hy using 1 + convert! hy using 1 simp [Nat.succ_eq_add_one, pow_add, mul_assoc] rw [mul_eq_zero, sub_eq_zero] at hy exact ⟨_, hy.resolve_left <| pow_ne_zero _ hx⟩ diff --git a/Mathlib/RingTheory/Bialgebra/Convolution.lean b/Mathlib/RingTheory/Bialgebra/Convolution.lean new file mode 100644 index 00000000000000..008da3aa3cef4d --- /dev/null +++ b/Mathlib/RingTheory/Bialgebra/Convolution.lean @@ -0,0 +1,162 @@ +/- +Copyright (c) 2025 Yaël Dillies, Michał Mrugała. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Yaël Dillies, Michał Mrugała +-/ +module + +public import Mathlib.RingTheory.Bialgebra.TensorProduct +public import Mathlib.RingTheory.Coalgebra.Convolution + +/-! +# Convolution product on bialgebra homs + +This file constructs the ring structure on algebra homs `C → A` where `C` is a bialgebra and `A` an +algebra, and also the ring structure on bialgebra homs `C → A` where `C` and `A` are bialgebras. +Both multiplications are given by +``` + | + μ +| | / \ +f * g = f g +| | \ / + δ + | +``` +diagrammatically, where `μ` stands for multiplication and `δ` for comultiplication. +-/ + +public section + +suppress_compilation + +open Algebra Coalgebra Bialgebra TensorProduct WithConv + +variable {R A B C : Type*} [CommSemiring R] + +namespace AlgHom +variable [CommSemiring A] [CommSemiring B] [Semiring C] [Bialgebra R C] [Algebra R A] + +instance : One (WithConv <| C →ₐ[R] A) where + one := toConv <| (Algebra.ofId R A).comp <| counitAlgHom R C + +instance : Mul (WithConv <| C →ₐ[R] A) where + mul f g := toConv <| .comp (lmul' R) <| .comp (map f.ofConv g.ofConv) <| comulAlgHom R C + +instance : Pow (WithConv <| C →ₐ[R] A) ℕ := ⟨fun f n ↦ npowRec n f⟩ + +lemma convOne_def : 1 = toConv ((Algebra.ofId R A).comp (counitAlgHom R C)) := rfl + +lemma convMul_def (f g : WithConv <| C →ₐ[R] A) : + f * g = toConv (.comp (lmul' R) <| .comp (map f.ofConv g.ofConv) <| comulAlgHom R C) := rfl + +private lemma convPow_succ (f : WithConv <| C →ₐ[R] A) (n : ℕ) : f ^ (n + 1) = (f ^ n) * f := rfl + +@[simp] +lemma convOne_apply (c : C) : (1 : WithConv <| C →ₐ[R] A) c = algebraMap R A (counit c) := rfl + +lemma convMul_apply (f g : WithConv <| C →ₐ[R] A) (c : C) : + (f * g) c = lift f.ofConv g.ofConv (fun _ _ ↦ .all ..) (comul c) := by + simp only [convMul_def, coe_comp, Function.comp_apply, Bialgebra.comulAlgHom_apply] + rw [← comp_apply] + congr 1 + ext <;> simp + +@[simp] +lemma toLinearMap_convOne : toConv (1 : WithConv <| C →ₐ[R] A).ofConv.toLinearMap = 1 := rfl + +@[simp] +lemma toLinearMap_convMul (f g : WithConv <| C →ₐ[R] A) : + toConv (f * g).ofConv.toLinearMap = toConv f.ofConv.toLinearMap * toConv g.ofConv.toLinearMap := + rfl + +@[simp] +lemma toLinearMap_convPow (f : WithConv <| C →ₐ[R] A) : + ∀ n : ℕ, toConv (f ^ n).ofConv.toLinearMap = toConv f.ofConv.toLinearMap ^ n + | 0 => rfl + | n + 1 => by simp only [convPow_succ, toLinearMap_convMul, toLinearMap_convPow, pow_succ] + +lemma convMul_comp_bialgHom_distrib [Bialgebra R B] (f g : WithConv <| C →ₐ[R] A) (h : B →ₐc[R] C) : + AlgHom.comp (f * g).ofConv (h : B →ₐ[R] C) = + ofConv (toConv (f.ofConv.comp h) * toConv (g.ofConv.comp h)) := by + simp [convMul_def, comp_assoc, Algebra.TensorProduct.map_comp] + +lemma comp_convMul_distrib [Algebra R B] (h : A →ₐ[R] B) (f g : WithConv <| C →ₐ[R] A) : + h.comp (f * g).ofConv = ofConv (toConv (h.comp f.ofConv) * toConv (h.comp g.ofConv)) := by + apply toLinearMap_injective + apply WithConv.toConv_injective + rw [AlgHom.comp_toLinearMap, ← ofConv_toConv (f * g).ofConv.toLinearMap, toLinearMap_convMul] + simp [LinearMap.algHom_comp_convMul_distrib, toLinearMap_convMul] + +instance : Monoid (WithConv <| C →ₐ[R] A) := fast_instance% + (toConv_injective.comp <| toLinearMap_injective.comp ofConv_injective).monoid _ + toLinearMap_convOne toLinearMap_convMul toLinearMap_convPow + +variable [IsCocomm R C] + +instance : CommMonoid (WithConv <| C →ₐ[R] A) := fast_instance% + (toConv_injective.comp <| toLinearMap_injective.comp ofConv_injective).commMonoid _ + toLinearMap_convOne toLinearMap_convMul toLinearMap_convPow + +end AlgHom + +namespace BialgHom +variable [CommSemiring A] [Semiring C] [Bialgebra R A] [Bialgebra R C] + +instance : One (WithConv <| C →ₐc[R] A) where + one := toConv <| (unitBialgHom R A).comp <| counitBialgHom R C + +lemma convOne_def : 1 = toConv ((unitBialgHom R A).comp (counitBialgHom R C)) := rfl + +@[simp] +lemma convOne_apply (c : C) : (1 : WithConv <| C →ₐc[R] A) c = algebraMap R A (counit c) := rfl + +@[simp] +lemma toLinearMap_convOne : + toConv (SemilinearMapClass.semilinearMap (1 : WithConv <| C →ₐc[R] A).ofConv) = 1 := rfl + +@[simp] lemma toAlgHom_convOne : toConv (1 : WithConv <| C →ₐc[R] A).ofConv.toAlgHom = 1 := rfl + +variable [IsCocomm R C] + +instance : Mul (WithConv <| C →ₐc[R] A) where + mul f g := toConv <| .comp (mulBialgHom R A) <| .comp (map f.ofConv g.ofConv) <| comulBialgHom R C + +instance : Pow (WithConv <| C →ₐc[R] A) ℕ := ⟨fun f n ↦ npowRec n f⟩ + +lemma convMul_def (f g : WithConv <| C →ₐc[R] A) : + f * g = + toConv (.comp (mulBialgHom R A) <| .comp (map f.ofConv g.ofConv) <| comulBialgHom R C) := + rfl + +private lemma convPow_succ (f : WithConv <| C →ₐc[R] A) (n : ℕ) : f ^ (n + 1) = (f ^ n) * f := rfl + +-- TODO: Make simp once `SemilinearMapClass.semilinearMap` is not simp nf anymore. +-- @[simp] +lemma toLinearMap_convMul (f g : WithConv <| C →ₐc[R] A) : + toConv (f * g).ofConv.toLinearMap = toConv f.ofConv.toLinearMap * toConv g.ofConv.toLinearMap := + rfl + +@[simp] +lemma toAlgHom_convMul (f g : WithConv <| C →ₐc[R] A) : + toConv (f * g).ofConv.toAlgHom = toConv f.ofConv.toAlgHom * toConv g.ofConv.toAlgHom := + rfl + +-- TODO: Make simp once `SemilinearMapClass.semilinearMap` is not simp nf anymore. +-- @[simp] +lemma toLinearMap_convPow (f : WithConv <| C →ₐc[R] A) : + ∀ n, toConv (f ^ n).ofConv.toLinearMap = toConv f.ofConv.toLinearMap ^ n + | 0 => rfl + | n + 1 => by simp only [convPow_succ, pow_succ, toLinearMap_convMul, toLinearMap_convPow] + +@[simp] +lemma toAlgHom_convPow (f : WithConv <| C →ₐc[R] A) : + ∀ n, toConv (f ^ n).ofConv.toAlgHom = toConv f.ofConv.toAlgHom ^ n + | 0 => rfl + | n + 1 => by simp only [convPow_succ, pow_succ, toAlgHom_convMul, toAlgHom_convPow] + +instance : CommMonoid (WithConv <| C →ₐc[R] A) := fast_instance% + (toConv_injective.comp <| coe_linearMap_injective.comp ofConv_injective).commMonoid _ + toLinearMap_convOne toLinearMap_convMul toLinearMap_convPow + +end BialgHom diff --git a/Mathlib/RingTheory/Bialgebra/Hom.lean b/Mathlib/RingTheory/Bialgebra/Hom.lean index 045b85d69eec87..1c65b1dafdaf2d 100644 --- a/Mathlib/RingTheory/Bialgebra/Hom.lean +++ b/Mathlib/RingTheory/Bialgebra/Hom.lean @@ -133,7 +133,7 @@ def Simps.apply {R α β : Type*} [CommSemiring R] [Algebra R β] [CoalgebraStruct R α] [CoalgebraStruct R β] (f : α →ₐc[R] β) : α → β := f -initialize_simps_projections BialgHom (toFun → apply) +initialize_simps_projections BialgHom (toFun → apply, as_prefix toCoalgHom) @[simp] protected theorem coe_coe {F : Type*} [FunLike F A B] [BialgHomClass F R A B] (f : F) : diff --git a/Mathlib/RingTheory/Bialgebra/SymmetricAlgebra.lean b/Mathlib/RingTheory/Bialgebra/SymmetricAlgebra.lean new file mode 100644 index 00000000000000..5b5b292e2508b7 --- /dev/null +++ b/Mathlib/RingTheory/Bialgebra/SymmetricAlgebra.lean @@ -0,0 +1,63 @@ +/- +Copyright (c) 2026 Robert Hawkins. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Robert Hawkins +-/ +module + +public import Mathlib.LinearAlgebra.SymmetricAlgebra.Basic +public import Mathlib.RingTheory.Bialgebra.Basic +public import Mathlib.RingTheory.TensorProduct.Maps + +/-! +# Bialgebra structure on `SymmetricAlgebra R M` + +`SymmetricAlgebra R M` is the cocommutative commutative `R`-bialgebra on `M` +in which each generator `ι x` is primitive: `Δ(ι x) = ι x ⊗ 1 + 1 ⊗ ι x` and +`ε(ι x) = 0`. +-/ + +public noncomputable section + +namespace SymmetricAlgebra + +variable (R : Type*) [CommSemiring R] (M : Type*) [AddCommMonoid M] [Module R M] + +open scoped TensorProduct + +instance instBialgebra : Bialgebra R (SymmetricAlgebra R M) := + .ofAlgHom + (lift <| (TensorProduct.mk R _ _).flip 1 ∘ₗ ι R M + TensorProduct.mk R _ _ 1 ∘ₗ ι R M) + algebraMapInv + (by + ext x + simp [Algebra.TensorProduct.one_def, TensorProduct.add_tmul, TensorProduct.tmul_add] + abel) + (by ext x; simp [algebraMapInv_ι]) + (by ext x; simp [algebraMapInv_ι]) + +@[simp] +theorem comul_ι (x : M) : + Coalgebra.comul (R := R) (ι R M x) = ι R M x ⊗ₜ[R] 1 + 1 ⊗ₜ[R] ι R M x := + lift_ι_apply _ x + +@[simp] +theorem counit_ι (x : M) : + Coalgebra.counit (R := R) (ι R M x) = 0 := + algebraMapInv_ι x + +instance instIsCocomm : Coalgebra.IsCocomm R (SymmetricAlgebra R M) where + comm_comp_comul := by + have h : (Algebra.TensorProduct.comm R (SymmetricAlgebra R M) + (SymmetricAlgebra R M)).toAlgHom.comp (Bialgebra.comulAlgHom R _) = + Bialgebra.comulAlgHom R (SymmetricAlgebra R M) := by + ext x + simp + abel + exact congr(($h).toLinearMap) + +@[simp] +theorem counitAlgHom_eq : + Bialgebra.counitAlgHom R (SymmetricAlgebra R M) = algebraMapInv := rfl + +end SymmetricAlgebra diff --git a/Mathlib/RingTheory/Bialgebra/TensorProduct.lean b/Mathlib/RingTheory/Bialgebra/TensorProduct.lean index 35a0ccd93d0ef1..abbce09ebb6f32 100644 --- a/Mathlib/RingTheory/Bialgebra/TensorProduct.lean +++ b/Mathlib/RingTheory/Bialgebra/TensorProduct.lean @@ -196,8 +196,12 @@ abbrev rTensor (f : B →ₐc[R] C) : B ⊗[R] A →ₐc[R] C ⊗[R] A := end BialgHom namespace Bialgebra -variable (R A : Type*) [CommSemiring R] [Semiring A] [Bialgebra R A] +variable {R A : Type*} [CommSemiring R] +section Semiring +variable [Semiring A] [Bialgebra R A] + +variable (R A) in /-- Comultiplication as a bialgebra hom. -/ @[expose] def comulBialgHom [IsCocomm R A] : A →ₐc[R] A ⊗[R] A where __ := comulAlgHom R A @@ -207,4 +211,39 @@ lemma comm_comp_comulBialgHom [IsCocomm R A] : (TensorProduct.comm R A A).toBialgHom.comp (comulBialgHom R A) = comulBialgHom R A := by ext; exact comm_comul _ _ +variable (R A) in +/-- Multiplication on a bialgebra as a coalgebra hom. -/ +@[expose] +def mulCoalgHom : A ⊗[R] A →ₗc[R] A where + toLinearMap := .mul' R A + counit_comp := by ext; simp [mul_comm] + map_comp_comul := by + ext a b + simp [← (ℛ R a).eq, ← (ℛ R b).eq, TensorProduct.sum_tmul] + simp [TensorProduct.tmul_sum, Finset.sum_mul_sum] + +-- TODO: Generate this using `simps` once the coercion from `LinearMapClass` is gone. +@[simp] +lemma toLinearMap_mulCoalgHom : mulCoalgHom R A = LinearMap.mul' R A := rfl + +@[simp] lemma coe_mulCoalgHom : ⇑(mulCoalgHom R A) = LinearMap.mul' R A := rfl + +end Semiring + +section CommSemiring +variable [CommSemiring A] [Bialgebra R A] + +variable (R A) in +/-- Multiplication on a commutative bialgebra as a bialgebra hom. -/ +@[expose, simps toCoalgHom] +def mulBialgHom : A ⊗[R] A →ₐc[R] A where + toCoalgHom := mulCoalgHom R A + __ := Algebra.TensorProduct.lmul' R + +@[simp] +lemma mulBialgHom_toAlgHom : (mulBialgHom R A).toAlgHom = Algebra.TensorProduct.lmul' R := rfl + +@[simp] lemma coe_mulBialgHom : ⇑(mulBialgHom R A) = LinearMap.mul' R A := rfl + +end CommSemiring end Bialgebra diff --git a/Mathlib/RingTheory/ChainOfDivisors.lean b/Mathlib/RingTheory/ChainOfDivisors.lean index 5030ac217e7549..2567220b66644d 100644 --- a/Mathlib/RingTheory/ChainOfDivisors.lean +++ b/Mathlib/RingTheory/ChainOfDivisors.lean @@ -91,7 +91,7 @@ theorem element_of_chain_not_isUnit_of_index_ne_zero {n : ℕ} {i : Fin (n + 1)} theorem first_of_chain_isUnit {q : Associates M} {n : ℕ} {c : Fin (n + 1) → Associates M} (h₁ : StrictMono c) (h₂ : ∀ {r}, r ≤ q ↔ ∃ i, r = c i) : IsUnit (c 0) := by - obtain ⟨i, hr⟩ := h₂.mp Associates.one_le + obtain ⟨i, hr⟩ := h₂.mp one_le rw [Associates.isUnit_iff_eq_one, ← Associates.le_one_iff, hr] exact h₁.monotone (Fin.zero_le i) @@ -101,7 +101,7 @@ theorem second_of_chain_is_irreducible {q : Associates M} {n : ℕ} (hn : n ≠ (hq : q ≠ 0) : Irreducible (c 1) := by rcases n with - | n; · contradiction refine (Associates.isAtom_iff (ne_zero_of_dvd_ne_zero hq (h₂.2 ⟨1, rfl⟩))).mp ⟨?_, fun b hb => ?_⟩ - · exact ne_bot_of_gt (h₁ (show (0 : Fin (n + 2)) < 1 from Fin.zero_lt_one)) + · exact ne_bot_of_gt (h₁ zero_lt_one) obtain ⟨⟨i, hi⟩, rfl⟩ := h₂.1 (hb.le.trans (h₂.2 ⟨1, rfl⟩)) cases i · exact (Associates.isUnit_iff_eq_one _).mp (first_of_chain_isUnit h₁ @h₂) @@ -186,7 +186,7 @@ theorem eq_pow_second_of_chain_of_has_chain {q : Associates M} {n : ℕ} (hn : n (h₂ : ∀ {r : Associates M}, r ≤ q ↔ ∃ i, r = c i) (hq : q ≠ 0) : q = c 1 ^ n := by classical obtain ⟨i, hi'⟩ := element_of_chain_eq_pow_second_of_chain hn h₁ (@fun r => h₂) (dvd_refl q) hq - convert hi' + convert! hi' refine (Nat.lt_succ_iff.1 i.prop).antisymm' (Nat.le_of_succ_le_succ ?_) calc n + 1 = (Finset.univ : Finset (Fin (n + 1))).card := (Finset.card_fin _).symm @@ -244,6 +244,8 @@ variable [UniqueFactorizationMonoid N] [UniqueFactorizationMonoid M] open DivisorChain +set_option linter.overlappingInstances false + theorem pow_image_of_prime_by_factor_orderIso_dvd {m p : Associates M} {n : Associates N} (hn : n ≠ 0) (hp : p ∈ normalizedFactors m) (d : Set.Iic m ≃o Set.Iic n) {s : ℕ} (hs' : p ^ s ≤ m) : @@ -376,6 +378,8 @@ def mkFactorOrderIsoOfFactorDvdEquiv [IsCancelMulZero N] variable [UniqueFactorizationMonoid M] [UniqueFactorizationMonoid N] +set_option linter.overlappingInstances false + theorem mem_normalizedFactors_factor_dvd_iso_of_mem_normalizedFactors {m p : M} {n : N} (hm : m ≠ 0) (hn : n ≠ 0) (hp : p ∈ normalizedFactors m) {d : { l : M // l ∣ m } ≃ { l : N // l ∣ n }} (hd : ∀ l l', (d l : N) ∣ d l' ↔ (l : M) ∣ (l' : M)) : @@ -387,7 +391,7 @@ theorem mem_normalizedFactors_factor_dvd_iso_of_mem_normalizedFactors {m p : M} associatesEquivOfUniqueUnits_symm_apply] at this obtain ⟨q, hq, hq'⟩ := exists_mem_normalizedFactors_of_dvd hn this.irreducible - (d ⟨p, by apply dvd_of_mem_normalizedFactors; convert hp⟩).prop + (d ⟨p, by apply dvd_of_mem_normalizedFactors; convert! hp⟩).prop rwa [associated_iff_eq.mp hq'] have : Associates.mk @@ -404,7 +408,7 @@ theorem mem_normalizedFactors_factor_dvd_iso_of_mem_normalizedFactors {m p : M} refine map_prime_of_factor_orderIso (mk_ne_zero.mpr hn) ?_ _ obtain ⟨q, hq, hq'⟩ := exists_mem_normalizedFactors_of_dvd (mk_ne_zero.mpr hm) - (prime_mk.mpr (prime_of_normalized_factor p (by convert hp))).irreducible + (prime_mk.mpr (prime_of_normalized_factor p (by convert! hp))).irreducible (mk_le_mk_of_dvd (dvd_of_mem_normalizedFactors hp)) simpa only [associated_iff_eq.mp hq', associatesEquivOfUniqueUnits_symm_apply] using hq diff --git a/Mathlib/RingTheory/ClassGroup.lean b/Mathlib/RingTheory/ClassGroup.lean index 9e8cfdfac63933..53c4d81062fa4d 100644 --- a/Mathlib/RingTheory/ClassGroup.lean +++ b/Mathlib/RingTheory/ClassGroup.lean @@ -140,7 +140,7 @@ theorem ClassGroup.mk_eq_mk_of_coe_ideal {I J : (FractionalIdeal R⁰ <| Fractio simpa only [isUnit_iff_ne_zero, ne_eq, mk'_eq_zero_iff_eq_zero] using hx refine ⟨this.unit, ?_⟩ rw [mul_comm, ← Units.val_inj, Units.val_mul, coe_toPrincipalIdeal] - convert + convert! (mk'_mul_coeIdeal_eq_coeIdeal (FractionRing R) <| mem_nonZeroDivisors_of_ne_zero hy).2 h theorem ClassGroup.mk_eq_one_of_coe_ideal {I : (FractionalIdeal R⁰ <| FractionRing R)ˣ} @@ -222,6 +222,8 @@ theorem ClassGroup.mk_canonicalEquiv (K' : Type*) [Field K'] [Algebra R K'] [IsF ← Units.map_comp, ← RingEquiv.coe_monoidHom_trans, FractionalIdeal.canonicalEquiv_trans_canonicalEquiv] +set_option linter.overlappingInstances false + /-- Send a nonzero integral ideal to an invertible fractional ideal. -/ def FractionalIdeal.mk0 [IsDedekindDomain R] : (Ideal R)⁰ →* (FractionalIdeal R⁰ K)ˣ where @@ -408,7 +410,7 @@ theorem card_classGroup_eq_one [IsPrincipalIdealRing R] : Fintype.card (ClassGro /-- The class number is `1` iff the ring of integers is a principal ideal domain. -/ theorem card_classGroup_eq_one_iff [IsDedekindDomain R] [Fintype (ClassGroup R)] : Fintype.card (ClassGroup R) = 1 ↔ IsPrincipalIdealRing R := by - constructor; swap; · intros; convert card_classGroup_eq_one (R := R) + constructor; swap; · intros; convert! card_classGroup_eq_one (R := R) rw [Fintype.card_eq_one_iff] rintro ⟨I, hI⟩ have eq_one : ∀ J : ClassGroup R, J = 1 := fun J => (hI J).trans (hI 1).symm diff --git a/Mathlib/RingTheory/Coalgebra/TensorProduct.lean b/Mathlib/RingTheory/Coalgebra/TensorProduct.lean index 177af1a91e0a1e..e5847a6f5d5664 100644 --- a/Mathlib/RingTheory/Coalgebra/TensorProduct.lean +++ b/Mathlib/RingTheory/Coalgebra/TensorProduct.lean @@ -107,7 +107,7 @@ private lemma coassoc : A ⊗[R] B ⊗[S] (A ⊗[R] B ⊗[S] (A ⊗[R] B)) := TensorProduct.mapOfCompatibleSMul .. ∘ₗ TensorProduct.map .id (TensorProduct.mapOfCompatibleSMul ..) ∘ₗ F.toLinearMap - convert congr(F ($(Coalgebra.coassoc_apply x) ⊗ₜ[R] $(Coalgebra.coassoc_apply y))) using 1 + convert! congr(F ($(Coalgebra.coassoc_apply x) ⊗ₜ[R] $(Coalgebra.coassoc_apply y))) using 1 · dsimp hopf_tensor_induction comul (R := S) x with x₁ x₂ hopf_tensor_induction comul (R := R) y with y₁ y₂ @@ -130,9 +130,10 @@ instance instCoalgebra : Coalgebra S (A ⊗[R] B) where coassoc := coassoc (R := R) rTensor_counit_comp_comul := by ext x y - convert congr((TensorProduct.lid S _).symm - (TensorProduct.lid _ _ $(rTensor_counit_comul (R := S) x) ⊗ₜ[R] - TensorProduct.lid _ _ $(rTensor_counit_comul (R := R) y))) + convert! + congr((TensorProduct.lid S _).symm + (TensorProduct.lid _ _ $(rTensor_counit_comul (R := S) x) ⊗ₜ[R] + TensorProduct.lid _ _ $(rTensor_counit_comul (R := R) y))) · dsimp hopf_tensor_induction comul (R := S) x with x₁ x₂ hopf_tensor_induction comul (R := R) y with y₁ y₂ @@ -143,9 +144,10 @@ instance instCoalgebra : Coalgebra S (A ⊗[R] B) where simp only [one_smul] lTensor_counit_comp_comul := by ext x y - convert congr((TensorProduct.rid S _).symm - (TensorProduct.rid _ _ $(lTensor_counit_comul (R := S) x) ⊗ₜ[R] - TensorProduct.rid _ _ $(lTensor_counit_comul (R := R) y))) + convert! + congr((TensorProduct.rid S _).symm + (TensorProduct.rid _ _ $(lTensor_counit_comul (R := S) x) ⊗ₜ[R] + TensorProduct.rid _ _ $(lTensor_counit_comul (R := R) y))) · dsimp hopf_tensor_induction comul (R := S) x with x₁ x₂ hopf_tensor_induction comul (R := R) y with y₁ y₂ diff --git a/Mathlib/RingTheory/Congruence/BigOperators.lean b/Mathlib/RingTheory/Congruence/BigOperators.lean index 3f334aa4532387..d883c7a8dd68a5 100644 --- a/Mathlib/RingTheory/Congruence/BigOperators.lean +++ b/Mathlib/RingTheory/Congruence/BigOperators.lean @@ -17,22 +17,79 @@ public section namespace RingCon +/-- Congruence relation of a ring preserves finite product indexed by a list. -/ +protected lemma listProd {ι S : Type*} [Add S] [Monoid S] + (t : RingCon S) (l : List ι) {f g : ι → S} (h : ∀ i ∈ l, t (f i) (g i)) : + t (l.map f).prod (l.map g).prod := + t.toCon.list_prod h + /-- Congruence relation of a ring preserves finite sum indexed by a list. -/ protected lemma listSum {ι S : Type*} [AddMonoid S] [Mul S] (t : RingCon S) (l : List ι) {f g : ι → S} (h : ∀ i ∈ l, t (f i) (g i)) : t (l.map f).sum (l.map g).sum := t.toAddCon.list_sum h +/-- Congruence relation of a ring preserves finite product indexed by a multiset. -/ +protected lemma multisetProd {ι S : Type*} [Add S] [CommMonoid S] (t : RingCon S) + (s : Multiset ι) {f g : ι → S} (h : ∀ i ∈ s, t (f i) (g i)) : + t (s.map f).prod (s.map g).prod := + t.toCon.multiset_prod h + /-- Congruence relation of a ring preserves finite sum indexed by a multiset. -/ protected lemma multisetSum {ι S : Type*} [AddCommMonoid S] [Mul S] (t : RingCon S) (s : Multiset ι) {f g : ι → S} (h : ∀ i ∈ s, t (f i) (g i)) : t (s.map f).sum (s.map g).sum := t.toAddCon.multiset_sum h +/-- Congruence relation of a ring preserves finite product. -/ +protected lemma finsetProd {ι S : Type*} [Add S] [CommMonoid S] (t : RingCon S) (s : Finset ι) + {f g : ι → S} (h : ∀ i ∈ s, t (f i) (g i)) : + t (s.prod f) (s.prod g) := + t.toCon.finsetProd s h + /-- Congruence relation of a ring preserves finite sum. -/ protected lemma finsetSum {ι S : Type*} [AddCommMonoid S] [Mul S] (t : RingCon S) (s : Finset ι) {f g : ι → S} (h : ∀ i ∈ s, t (f i) (g i)) : t (s.sum f) (s.sum g) := t.toAddCon.finsetSum s h +protected lemma finsuppProd {ι : Type*} {β : Type*} {M : Type*} + [Add M] [CommMonoid M] [Zero β] + (c : RingCon M) (h : ι → β → M) (h' : ι → β → M) + {f g : ι →₀ β} (hf : ∀ i, c (h i 0) 1) (hf' : ∀ i, c (h' i 0) 1) + (H : ∀ i, c (h i (f i)) (h' i (g i))) : + c (f.prod h) (g.prod h') := + c.toCon.finsuppProd h h' hf hf' H + +protected lemma finsuppSum {ι : Type*} {β : Type*} {M : Type*} + [AddCommMonoid M] [Mul M] [Zero β] + (c : RingCon M) (h : ι → β → M) (h' : ι → β → M) + {f g : ι →₀ β} (hf : ∀ i, c (h i 0) 0) (hf' : ∀ i, c (h' i 0) 0) + (H : ∀ i, c (h i (f i)) (h' i (g i))) : + c (f.sum h) (g.sum h') := + c.toAddCon.finsuppSum h h' hf hf' H + +protected lemma dfinsuppProd {ι : Type*} {β : ι → Type*} {M : Type*} + [DecidableEq ι] [Add M] [CommMonoid M] [∀ i, Zero (β i)] [∀ i (y : β i), Decidable (y ≠ 0)] + (c : RingCon M) (h : (i : ι) → β i → M) (h' : (i : ι) → β i → M) + {f g : Π₀ i, β i} (hf : ∀ i, c (h i 0) 1) (hf' : ∀ i, c (h' i 0) 1) + (H : ∀ i, c (h i (f i)) (h' i (g i))) : + c (f.prod h) (g.prod h') := + c.toCon.dfinsuppProd h h' hf hf' H + +protected lemma dfinsuppSum {ι : Type*} {β : ι → Type*} {M : Type*} + [DecidableEq ι] [AddCommMonoid M] [Mul M] [∀ i, Zero (β i)] [∀ i (y : β i), Decidable (y ≠ 0)] + (c : RingCon M) (h : (i : ι) → β i → M) (h' : (i : ι) → β i → M) + {f g : Π₀ i, β i} (hf : ∀ i, c (h i 0) 0) (hf' : ∀ i, c (h' i 0) 0) + (H : ∀ i, c (h i (f i)) (h' i (g i))) : + c (f.sum h) (g.sum h') := + c.toAddCon.dfinsuppSum h h' hf hf' H + +protected lemma dfinsuppSumAddHom {ι : Type*} {β : ι → Type*} {M : Type*} + [DecidableEq ι] [AddCommMonoid M] [Mul M] [∀ i, AddCommMonoid (β i)] + (c : RingCon M) (h : (i : ι) → β i →+ M) (h' : (i : ι) → β i →+ M) {f g : Π₀ i, β i} + (H : ∀ i, c (h i (f i)) (h' i (g i))) : + c (f.sumAddHom h) (g.sumAddHom h') := + c.toAddCon.dfinsuppSumAddHom h h' H + end RingCon diff --git a/Mathlib/RingTheory/Congruence/Hom.lean b/Mathlib/RingTheory/Congruence/Hom.lean index c57e8351325866..24730a89106c74 100644 --- a/Mathlib/RingTheory/Congruence/Hom.lean +++ b/Mathlib/RingTheory/Congruence/Hom.lean @@ -340,7 +340,7 @@ noncomputable def comapQuotientEquivOfSurj @[simp] lemma comapQuotientEquivOfSurj_symm_mk' (c : RingCon M) (f : N ≃+* M) {d : RingCon N} (hcd : d = c.comap f) (x : N) : (comapQuotientEquivOfSurj c (f : N →+* M) f.surjective hcd).symm ⟦f x⟧ = ↑x := by - convert RingEquiv.symm_apply_apply _ _ + convert! RingEquiv.symm_apply_apply _ _ rw [comapQuotientEquivOfSurj_mk, RingEquiv.coe_toRingHom] rfl diff --git a/Mathlib/RingTheory/Coprime/Ideal.lean b/Mathlib/RingTheory/Coprime/Ideal.lean index b82965f124b6b9..a33ce013e1590b 100644 --- a/Mathlib/RingTheory/Coprime/Ideal.lean +++ b/Mathlib/RingTheory/Coprime/Ideal.lean @@ -67,7 +67,7 @@ theorem iSup_iInf_eq_top_iff_pairwise {t : Finset ι} (h : t.Nonempty) (I : ι case a3 => rw [← @if_pos _ _ h.choose_spec R (μ a) 0, ← Finset.sum_pi_single', ← Finset.sum_add_distrib] at hμ - convert hμ + convert! hμ rename_i i _ rw [Pi.add_apply, Submodule.coe_add, Submodule.coe_mk] by_cases hi : i = h.choose diff --git a/Mathlib/RingTheory/Coprime/Lemmas.lean b/Mathlib/RingTheory/Coprime/Lemmas.lean index 9c65eddd26194f..d5c4654c6cf11b 100644 --- a/Mathlib/RingTheory/Coprime/Lemmas.lean +++ b/Mathlib/RingTheory/Coprime/Lemmas.lean @@ -141,11 +141,11 @@ theorem exists_sum_eq_one_iff_pairwise_coprime [DecidableEq I] (h : t.Nonempty) @if_pos _ _ h.choose_spec R (_ * _) 0, ← sum_pi_single', ← sum_add_distrib] at hμ rw [← hμ, sum_congr rfl] intro x hx - convert add_mul (R := R) _ _ _ using 2 + convert! add_mul (R := R) _ _ _ using 2 · by_cases hx : x = h.choose · rw [hx, Pi.single_eq_same, Pi.single_eq_same] · rw [Pi.single_eq_of_ne hx, Pi.single_eq_of_ne hx, zero_mul] - · convert (mul_assoc _ _ _).symm + · convert! (mul_assoc _ _ _).symm rw [prod_eq_prod_diff_singleton_mul (mem x hx), mul_comm, sdiff_sdiff_comm, sdiff_singleton_eq_erase a, erase_insert hat] · have : IsCoprime (s b) (s a) := @@ -177,7 +177,7 @@ theorem exists_sum_eq_one_iff_pairwise_coprime [DecidableEq I] (h : t.Nonempty) theorem exists_sum_eq_one_iff_pairwise_coprime' [Fintype I] [Nonempty I] [DecidableEq I] : (∃ μ : I → R, (∑ i : I, μ i * ∏ j ∈ {i}ᶜ, s j) = 1) ↔ Pairwise (IsCoprime on s) := by - convert exists_sum_eq_one_iff_pairwise_coprime Finset.univ_nonempty (s := s) using 1 + convert! exists_sum_eq_one_iff_pairwise_coprime Finset.univ_nonempty (s := s) using 1 simp only [pairwise_subtype_iff_pairwise_finset', coe_univ, Set.pairwise_univ] theorem pairwise_coprime_iff_coprime_prod [DecidableEq I] : diff --git a/Mathlib/RingTheory/DedekindDomain/AdicValuation.lean b/Mathlib/RingTheory/DedekindDomain/AdicValuation.lean index acedc29b14dc74..41a036799faf36 100644 --- a/Mathlib/RingTheory/DedekindDomain/AdicValuation.lean +++ b/Mathlib/RingTheory/DedekindDomain/AdicValuation.lean @@ -182,12 +182,21 @@ theorem intValuation_def {r : R} : exp (-(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {r} : Ideal R)).factors : ℤ) := rfl -open scoped Classical in theorem intValuation_if_neg {r : R} (hr : r ≠ 0) : v.intValuation r = exp (-(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {r} : Ideal R)).factors : ℤ) := intValuationDef_if_neg _ hr +theorem intValuation_eq_exp_neg_multiplicity {r : R} (hr : r ≠ 0) : + v.intValuation r = exp (-multiplicity v.asIdeal (Ideal.span {r}) : ℤ) := by + have hsr : Ideal.span {r} ≠ 0 := Submodule.span_singleton_eq_bot.mp.mt hr + have hfm : FiniteMultiplicity v.asIdeal (Ideal.span {r}) := + FiniteMultiplicity.of_prime_left v.prime hsr + rw [v.intValuation_if_neg hr, exp_inj, neg_inj, Int.natCast_inj, ← ENat.coe_inj, + ← FiniteMultiplicity.emultiplicity_eq_multiplicity hfm, + UniqueFactorizationMonoid.emultiplicity_eq_count_normalizedFactors (irreducible v) hsr, + normalize_eq, Ideal.count_associates_factors_eq hsr v.isPrime v.ne_bot] + /-- Nonzero elements have nonzero adic valuation. -/ theorem intValuation_ne_zero (x : R) (hx : x ≠ 0) : v.intValuation x ≠ 0 := by rw [v.intValuation_if_neg hx] @@ -249,6 +258,19 @@ theorem intValuation_le_pow_iff_mem (r : R) (n : ℕ) : v.intValuation r ≤ exp (-(n : ℤ)) ↔ r ∈ v.asIdeal ^ n := by rw [intValuation_le_pow_iff_dvd, Ideal.dvd_span_singleton] +theorem intValuation_le_exp_iff_le_emultiplicity {r : R} {n : ℕ} : + v.intValuation r ≤ exp (-(n : ℤ)) ↔ n ≤ emultiplicity v.asIdeal (Ideal.span {r}) := by + rw [intValuation_le_pow_iff_dvd, pow_dvd_iff_le_emultiplicity] + +theorem exp_le_intValuation_iff_emultiplicity_le {r : R} {n : ℕ} : + exp (-(n : ℤ)) ≤ v.intValuation r ↔ emultiplicity v.asIdeal (Ideal.span {r}) ≤ n := by + rw [← ENat.lt_coe_add_one_iff, ← ENat.coe_one, ← ENat.coe_add, emultiplicity_lt_iff_not_dvd, + ← intValuation_le_pow_iff_dvd, not_le, Nat.cast_add, Nat.cast_one, neg_add, exp_add, + exp_neg 1, mul_inv_lt_iff₀ (by simp)] + by_cases hv : v.intValuation r = 0 + · simp [hv] + · rw [lt_mul_exp_iff_le hv] + /-- There exists `π : R` with `v`-adic valuation `WithZero.exp (-1)`. -/ theorem intValuation_exists_uniformizer : ∃ π : R, v.intValuation π = WithZero.exp (-1 : ℤ) := by @@ -470,6 +492,11 @@ instance : IsDedekindDomain (valuationSubringAtPrime K v) := instance : Ring.KrullDimLE 1 (valuationSubringAtPrime K v) := Ring.KrullDimLE.mk₁' (fun _ a _ ↦ IsPrime.to_maximal_ideal a) +instance : IsLocalization (v.asIdeal.primeCompl) (valuationSubringAtPrime K v) := + Localization.subalgebra.isLocalization_ofField K (v.asIdeal.primeCompl) _ + +end Localization + /-- Given `v : HeightOneSpectrum R`, the valuation associated to `v` has the localization of `R` at `v` as valuation subring. -/ theorem valuationSubringAtPrime_eq_valuationSubring : @@ -477,23 +504,14 @@ theorem valuationSubringAtPrime_eq_valuationSubring : ValuationSubring.eq_of_le_of_ne_top _ (valuationSubringAtPrime_le_valuation v) (by simp only [ne_eq, Valuation.valuationSubring_eq_top_iff, not_not]; infer_instance) -end Localization - -set_option backward.isDefEq.respectTransparency false in /-- All `x : K` can be written as `n / d` or `d / n` with `n : R` and `d ∈ v.asIdealᶜ`. -/ lemma exists_primeCompl_mul_eq_or_mul_eq (x : K) : ∃ (n : R) (d : v.asIdeal.primeCompl), x * (algebraMap R K d) = (algebraMap R K n) ∨ x * (algebraMap R K n) = (algebraMap R K d) := by - -- `K` is an algebra over the localization of `R` at `v`. - letI : Algebra (Localization v.asIdeal.primeCompl) K := - RingHom.toAlgebra <| Localization.mapToFractionRing K v.asIdeal.primeCompl - (Localization v.asIdeal.primeCompl) (Ideal.primeCompl_le_nonZeroDivisors v.asIdeal) - have : IsFractionRing (Localization v.asIdeal.primeCompl) K := by - apply IsFractionRing.isFractionRing_of_isDomain_of_isLocalization v.asIdeal.primeCompl -- It's already known that the localization of `R` at `v` is a (discrete) valuation ring, so -- write `x` or `x⁻¹` as `n / d` with `d ∈ vᶜ`. obtain (⟨r, hr⟩ | ⟨r, hr⟩) := - ValuationRing.isInteger_or_isInteger (Localization v.asIdeal.primeCompl) x + ValuationRing.isInteger_or_isInteger (valuationSubringAtPrime K v) x <;> obtain ⟨⟨n, d⟩, hnd⟩ := IsLocalization.surj v.asIdeal.primeCompl r <;> use n, d <;> apply_fun algebraMap _ K at hnd @@ -510,6 +528,49 @@ theorem exists_primeCompl_mul_eq_of_integer (x : K) (hv : v.valuation K x ≤ 1) rw [← (v.intValuation_eq_one_iff_mem_primeCompl d).mpr d.prop, ← valuation_of_algebraMap (K := K), ← valuation_of_algebraMap (K := K), ← map_mul, hnd] +/-- Given `a, b ∈ A` and `v b ≤ v a` we can find `y : A` such that `y * a` is close to `b` by +the valuation `v`. -/ +theorem exists_intValuation_mul_sub_lt {a b : R} (hv : v.intValuation b ≤ v.intValuation a) + (γ : Multiplicative ℤ) : ∃ y, v.intValuation (b - y * a) < γ := by + -- If `a = 0`, then `b = 0`, so we can take `y = 0`. + by_cases ha: a = 0 + · subst ha + rw [map_zero, le_zero_iff] at hv + exact ⟨0, by simp [hv]⟩ + · have hvaz := intValuation_ne_zero v a ha + have hγz : WithZero.coe γ ≠ 0 := WithZero.coe_ne_zero + -- Otherwise, find `n : ℕ` such that `exp (-n) < γ` and `exp(-n) < v a`. + obtain ⟨n, hna, hnγ⟩ := exists_exp_neg_natCast_lt_and_lt hvaz hγz + apply Exists.imp (fun _ h ↦ lt_of_le_of_lt h hnγ) + -- `v b ≤ v a`, so `b ∈ v.asIdeal ^ -log (v a)`. + -- From `irreducible_pow_sup_of_ge` we know that + -- `v.asIdeal ^ -log (v a) = v.asIdeal ^ n ⊔ Ideal.span {a}`. + -- So, `∃ z ∈ v.asIdeal ^ n, ∃ (y: R), b = z + y * a`. This gives `z` and `y` such that + -- `b - y * a = z` and `v z ≤ exp (-n)`, as required. + have hvn : emultiplicity v.asIdeal (Ideal.span {a}) ≤ n := by + grw [← exp_le_intValuation_iff_emultiplicity_le, hna] + have hb : b ∈ v.asIdeal ^ multiplicity v.asIdeal (Ideal.span {a}) := by + rwa [← intValuation_le_pow_iff_mem, ← v.intValuation_eq_exp_neg_multiplicity ha] + have hnz : Ideal.span {a} ≠ ⊥ := by rwa [ne_eq, Ideal.span_singleton_eq_bot] + simpa [← Ideal.irreducible_pow_sup_of_ge hnz v.irreducible n hvn, Submodule.mem_sup, + ← eq_sub_iff_add_eq, ← intValuation_le_pow_iff_mem, Ideal.mem_span_singleton'] using hb + +/-- Given `x ∈ 𝒪[K]` we can find `a : A` such that `a` is close to `x` by the valuation `v`. -/ +theorem exists_valuation_sub_lt_of_integer {x : K} (hv : v.valuation K x ≤ 1) + (γ : (ℤᵐ⁰)ˣ) : ∃a, v.valuation K (algebraMap R K a - x) < γ := by + -- Write `x = n / d`, with `v d = 1`. + obtain ⟨n, ⟨d, hd⟩, hnd⟩ := exists_primeCompl_mul_eq_of_integer v x hv + rw [← intValuation_eq_one_iff_mem_primeCompl] at hd + have hd' : v.intValuation n ≤ v.intValuation d := by grw [v.intValuation_le_one n, hd] + -- Get `a` such that `v (n - a * d) < γ` from the previous theorem. + obtain ⟨a, hval⟩ := exists_intValuation_mul_sub_lt v hd' (WithZero.unitsWithZeroEquiv γ) + rw [unitsWithZeroEquiv_apply, coe_unzero] at hval + use a + -- `v d = 1`, so `v (a - x) = v (x - a) = v (x - a) * v d = v (n - a * d) < γ`. + suffices h : v.valuation K (algebraMap R K a - x) = v.intValuation (n - a * d) by rwa [h] + rw [← valuation_of_algebraMap (K := K), Algebra.cast, map_sub _ n, map_mul, ← hnd, ← sub_mul, + map_mul, valuation_of_algebraMap, hd, mul_one, Valuation.map_sub_swap] + /-! ### Completions with respect to adic valuations Given a Dedekind domain `R` with field of fractions `K` and a maximal ideal `v` of `R`, we define @@ -732,7 +793,7 @@ theorem adicCompletionIntegers.mem_units_iff_valued_eq_one {a : (v.adicCompletio a ∈ (v.adicCompletionIntegers K).units ↔ Valued.v a.1 = 1 := by refine ⟨fun h ↦ ?_, fun h ↦ ⟨h.le, by simp [mem_adicCompletionIntegers, inv_le_one_iff₀, h.symm.le]⟩⟩ - convert isUnit_iff_valued_eq_one.1 (Submonoid.unitsEquivIsUnitSubmonoid _ ⟨_, h⟩).2 + convert! isUnit_iff_valued_eq_one.1 (Submonoid.unitsEquivIsUnitSubmonoid _ ⟨_, h⟩).2 section AbsoluteValue diff --git a/Mathlib/RingTheory/DedekindDomain/Different.lean b/Mathlib/RingTheory/DedekindDomain/Different.lean index 1e25be883fcef2..e0189143a01d15 100644 --- a/Mathlib/RingTheory/DedekindDomain/Different.lean +++ b/Mathlib/RingTheory/DedekindDomain/Different.lean @@ -129,7 +129,7 @@ variable [IsDomain A] [IsFractionRing A K] [FiniteDimensional K L] [Algebra.IsSe lemma traceDual_top [Decidable (IsField A)] : (⊤ : Submodule B L)ᵛ = if IsField A then ⊤ else ⊥ := by - convert traceDual_top' + convert! traceDual_top' rw [← IsFractionRing.surjective_iff_isField (R := A) (K := K), LinearMap.range_eq_top.mpr (Algebra.trace_surjective K L), ← RingHom.range_eq_top, _root_.eq_top_iff] @@ -240,7 +240,7 @@ def dual (I : FractionalIdeal B⁰ L) : · rw [← (IsIntegralClosure.algebraMap_injective B A L).ne_iff, hy, map_zero, ← (algebraMap K L).map_zero, (algebraMap K L).injective.ne_iff] exact discr_not_zero_of_basis K b - · convert isIntegral_discr_mul_of_mem_traceDual I hb hx' hz using 1 + · convert! isIntegral_discr_mul_of_mem_traceDual I hb hx' hz using 1 · ext w; exact (IsIntegralClosure.isIntegral_iff (A := B)).symm · rw [Algebra.smul_def, map_mul, hy, ← Algebra.smul_def]⟩ @@ -297,7 +297,7 @@ lemma dual_ne_zero (hI : I ≠ 0) : apply IsIntegrallyClosed.isIntegral_iff.mp apply isIntegral_trace dsimp - convert hb' a ha using 1 + convert! hb' a ha using 1 · ext w exact IsIntegralClosure.isIntegral_iff (A := B) · exact (Algebra.smul_def _ _).symm @@ -560,6 +560,8 @@ lemma differentialIdeal_le_iff {I : Ideal B} (hI : I ≠ ⊥) : variable (A K B L) +set_option linter.overlappingInstances false + open FractionalIdeal in /-- Transitivity of the different ideal. -/ theorem differentIdeal_eq_differentIdeal_mul_differentIdeal (C : Type*) [IsDomain B] [CommRing C] @@ -683,6 +685,8 @@ variable (L) variable [IsFractionRing B L] [IsDedekindDomain A] [IsDedekindDomain B] [IsTorsionFree A B] [Module.Finite A B] +set_option linter.overlappingInstances false + include K L in lemma pow_sub_one_dvd_differentIdeal_aux {p : Ideal A} [p.IsMaximal] (P : Ideal B) {e : ℕ} (he : e ≠ 0) (hp : p ≠ ⊥) @@ -913,8 +917,9 @@ theorem not_dvd_differentIdeal_iff let K := FractionRing A let L := FractionRing B have : IsLocalization B⁰ (Localization.AtPrime (⊥ : Ideal B)) := by - convert (inferInstance : - IsLocalization (⊥ : Ideal B).primeCompl (Localization.AtPrime (⊥ : Ideal B))) + convert! + (inferInstance : + IsLocalization (⊥ : Ideal B).primeCompl (Localization.AtPrime (⊥ : Ideal B))) ext; simp [Ideal.primeCompl] refine (Algebra.FormallyUnramified.iff_of_equiv (A := L) ((IsLocalization.algEquiv B⁰ _ _).restrictScalars A)).mp ?_ diff --git a/Mathlib/RingTheory/DedekindDomain/Dvr.lean b/Mathlib/RingTheory/DedekindDomain/Dvr.lean index 84bfe92c8fa629..148e5ee14fe445 100644 --- a/Mathlib/RingTheory/DedekindDomain/Dvr.lean +++ b/Mathlib/RingTheory/DedekindDomain/Dvr.lean @@ -75,6 +75,8 @@ theorem Ring.DimensionLEOne.localization {R : Type*} (Rₘ : Type*) [CommRing R] refine h.not_lt_lt ⊥ (p.under R) (P.under R) ⟨?_, hpP'⟩ exact IsLocalization.bot_lt_under_prime _ _ hM _ hp0⟩ +set_option linter.overlappingInstances false + /-- The localization of a Dedekind domain is a Dedekind domain. -/ theorem IsLocalization.isDedekindDomain [IsDedekindDomain A] {M : Submonoid A} (hM : M ≤ A⁰) (Aₘ : Type*) [CommRing Aₘ] [IsDomain Aₘ] [Algebra A Aₘ] [IsLocalization M Aₘ] : diff --git a/Mathlib/RingTheory/DedekindDomain/Factorization.lean b/Mathlib/RingTheory/DedekindDomain/Factorization.lean index ab246fc4d92ba2..bcbafee9cef0a0 100644 --- a/Mathlib/RingTheory/DedekindDomain/Factorization.lean +++ b/Mathlib/RingTheory/DedekindDomain/Factorization.lean @@ -533,7 +533,7 @@ theorem count_finprod (exps : HeightOneSpectrum R → ℤ) (h_exps : ∀ᶠ v : HeightOneSpectrum R in Filter.cofinite, exps v = 0) : count K v (∏ᶠ v : HeightOneSpectrum R, (v.asIdeal : FractionalIdeal R⁰ K) ^ exps v) = exps v := by - convert count_finsuppProd K v (Finsupp.mk h_exps.toFinset exps (fun _ ↦ h_exps.mem_toFinset)) + convert! count_finsuppProd K v (Finsupp.mk h_exps.toFinset exps (fun _ ↦ h_exps.mem_toFinset)) rw [finprod_eq_finsetProd_of_mulSupport_subset (s := h_exps.toFinset), Finsupp.prod] · rfl · rw [Finite.coe_toFinset] @@ -610,7 +610,7 @@ theorem finite_factors (I : FractionalIdeal R⁰ K) : by_cases hI : I = 0 · simp only [hI, count_zero, Filter.eventually_cofinite, not_true_eq_false, setOf_false, finite_empty] - · convert finite_factors' hI (choose_spec (choose_spec (exists_eq_spanSingleton_mul I))).2 + · convert! finite_factors' hI (choose_spec (choose_spec (exists_eq_spanSingleton_mul I))).2 rw [count_ne_zero K _ hI] end FractionalIdeal @@ -665,7 +665,7 @@ lemma IsDedekindDomain.exists_sup_span_eq {I J : Ideal R} (hIJ : I ≤ J) (hI : rintro ⟨q, hq⟩ by_cases hqp : q = p' · subst hqp - convert sub_mem H₁ H₂ + convert! sub_mem H₁ H₂ rw [Finset.sum_eq_add_sum_diff_singleton_of_mem hp's, add_sub_cancel_right] · refine Ideal.mul_mono_right ?_ (ha p' hp's) exact Ideal.prod_le_inf.trans (Finset.inf_le (b := q) (by simpa [hq] using hqp)) @@ -786,7 +786,7 @@ def quotientEquiv (I J I' J' : FractionalIdeal R⁰ K) refine inf_le_inf ?_ le_rfl intro x hx rw [spanSingleton_inv] - convert mul_mem_mul (mem_spanSingleton_self _ _) hx + convert! mul_mem_mul (mem_spanSingleton_self _ _) hx simp [H'] · have H : Submodule.map (Algebra.lsmul R R K (I'.divMod I J')) ↑I = (spanSingleton R⁰ (I'.divMod I J') * I) := by diff --git a/Mathlib/RingTheory/DedekindDomain/Ideal/Basic.lean b/Mathlib/RingTheory/DedekindDomain/Ideal/Basic.lean index 78cf95c4ea7e67..497e84753a0c09 100644 --- a/Mathlib/RingTheory/DedekindDomain/Ideal/Basic.lean +++ b/Mathlib/RingTheory/DedekindDomain/Ideal/Basic.lean @@ -89,7 +89,7 @@ theorem FractionalIdeal.adjoinIntegral_eq_one_of_isUnit [Algebra A K] [IsFractio apply coeToSubmodule_injective simp only [coe_mul, adjoinIntegral_coe, I] rw [(Algebra.adjoin A {x}).isIdempotentElem_toSubmodule] - convert congr_arg (· * I⁻¹) mul_self <;> + convert! congr_arg (· * I⁻¹) mul_self <;> simp only [(mul_inv_cancel_iff_isUnit K).mpr hI, mul_assoc, mul_one] namespace IsDedekindDomainInv @@ -218,7 +218,7 @@ theorem PrimeSpectrum.exists_multiset_prod_cons_le_and_prod_not_le [IsDedekindDo subst hPM' -- By minimality of `Z`, erasing `P` from `Z` is exactly what we need. refine ⟨Z.erase P, ?_, ?_⟩ - · convert hZI + · convert! hZI rw [this, Multiset.cons_erase hPZ'] · refine fun h => h_eraseZ (Z.erase P) ⟨h, ?_⟩ (Multiset.erase_lt.mpr hPZ) exact hZP0 @@ -425,7 +425,7 @@ theorem Ideal.dvdNotUnit_iff_lt {I J : Ideal A} : DvdNotUnit I J ↔ J < I := instance : WfDvdMonoid (Ideal A) where wf := by have : WellFoundedGT (Ideal A) := inferInstance - convert this.wf using 3 + convert! this.wf using 3 exact Ideal.dvdNotUnit_iff_lt instance Ideal.uniqueFactorizationMonoid : UniqueFactorizationMonoid (Ideal A) := diff --git a/Mathlib/RingTheory/DedekindDomain/Ideal/Lemmas.lean b/Mathlib/RingTheory/DedekindDomain/Ideal/Lemmas.lean index 261fc6880813c5..d401bea183103f 100644 --- a/Mathlib/RingTheory/DedekindDomain/Ideal/Lemmas.lean +++ b/Mathlib/RingTheory/DedekindDomain/Ideal/Lemmas.lean @@ -168,7 +168,7 @@ theorem pow_right_strictAnti (I : Ideal A) (hI0 : I ≠ ⊥) (hI1 : I ≠ ⊤) : theorem pow_lt_self (I : Ideal A) (hI0 : I ≠ ⊥) (hI1 : I ≠ ⊤) (e : ℕ) (he : 2 ≤ e) : I ^ e < I := by - convert I.pow_right_strictAnti hI0 hI1 he + convert! I.pow_right_strictAnti hI0 hI1 he dsimp only rw [pow_one] @@ -370,7 +370,7 @@ lemma FractionalIdeal.sup_mul_inf (I J : FractionalIdeal A⁰ K) : rw [mul_left_comm, ← mul_add, ← mul_add, ← mul_inf₀ (FractionalIdeal.zero_le _), ← mul_inf₀ (FractionalIdeal.zero_le _)] at this simp only [FractionalIdeal.sup_eq_add, _root_.map_mul, ← spanSingleton_mul_spanSingleton] - convert this using 1 <;> ring + convert! this using 1 <;> ring end Gcd @@ -510,6 +510,12 @@ theorem prime : Prime v.asIdeal := Ideal.prime_of_isPrime v.ne_bot v.isPrime instance : Coe (HeightOneSpectrum R) (Ideal R) where coe P := P.asIdeal +omit [IsDedekindDomain R] in +lemma asIdeal_injective : (HeightOneSpectrum.asIdeal (R := R)).Injective := + fun ⦃_ _⦄ h ↦ HeightOneSpectrum.ext h + +alias asIdeal_inj := HeightOneSpectrum.ext + /-- The (nonzero) prime elements of the monoid with zero `Ideal R` correspond to an element of type `HeightOneSpectrum R`. @@ -1180,6 +1186,7 @@ alias _root_.mem_primesOverFinset_iff := mem_primesOverFinset_iff end IsDedekindDomain +set_option linter.overlappingInstances false in variable {R} (A) in theorem IsLocalRing.primesOverFinset_eq [IsLocalRing A] [IsDedekindDomain A] [Algebra R A] [FaithfulSMul R A] [Module.Finite R A] {p : Ideal R} [p.IsMaximal] (hp0 : p ≠ ⊥) : diff --git a/Mathlib/RingTheory/DedekindDomain/Instances.lean b/Mathlib/RingTheory/DedekindDomain/Instances.lean index 86f51ed0f6f8fe..982a7cf3602f09 100644 --- a/Mathlib/RingTheory/DedekindDomain/Instances.lean +++ b/Mathlib/RingTheory/DedekindDomain/Instances.lean @@ -144,10 +144,12 @@ instance : IsScalarTower Rₚ Sₚ L := by RingHom.comp_assoc, ← IsScalarTower.algebraMap_eq, ← IsScalarTower.algebraMap_eq, ← IsScalarTower.algebraMap_eq] +set_option linter.overlappingInstances false in instance [IsDedekindDomain S] : IsDedekindDomain Sₚ := isDedekindDomain S (algebraMapSubmonoid_le_nonZeroDivisors_of_faithfulSMul _ P.primeCompl_le_nonZeroDivisors) _ +set_option linter.overlappingInstances false in instance [IsDedekindDomain R] [IsDedekindDomain S] [Module.Finite R S] [hP : NeZero P] : IsPrincipalIdealRing Sₚ := IsDedekindDomain.isPrincipalIdealRing_localization_over_prime S P (fun h ↦ hP.1 h) diff --git a/Mathlib/RingTheory/DedekindDomain/IntegralClosure.lean b/Mathlib/RingTheory/DedekindDomain/IntegralClosure.lean index 37151e22f7df1e..7e8ffa3eefa9d3 100644 --- a/Mathlib/RingTheory/DedekindDomain/IntegralClosure.lean +++ b/Mathlib/RingTheory/DedekindDomain/IntegralClosure.lean @@ -208,6 +208,8 @@ theorem integralClosure.isNoetherianRing [IsIntegrallyClosed A] [IsNoetherianRin variable (A K) [IsDomain C] +set_option linter.overlappingInstances false + /-- If `L` is a finite separable extension of `K = Frac(A)`, where `A` is a Dedekind domain, the integral closure `C` of `A` in `L` is a Dedekind domain. diff --git a/Mathlib/RingTheory/DedekindDomain/LinearDisjoint.lean b/Mathlib/RingTheory/DedekindDomain/LinearDisjoint.lean index 16a70a0fded7bb..d504e598dc6aab 100644 --- a/Mathlib/RingTheory/DedekindDomain/LinearDisjoint.lean +++ b/Mathlib/RingTheory/DedekindDomain/LinearDisjoint.lean @@ -76,6 +76,8 @@ variable [IsDomain A] [IsDedekindDomain B] [IsDedekindDomain R₁] [IsDedekindDo [IsFractionRing B L] [IsFractionRing R₁ F₁] [IsFractionRing R₂ F₂] [IsIntegrallyClosed A] [IsIntegralClosure B R₁ L] [IsTorsionFree R₁ B] [IsTorsionFree R₂ B] +set_option linter.overlappingInstances false + namespace IsDedekindDomain theorem differentIdeal_dvd_map_differentIdeal [Algebra.IsIntegral R₂ B] @@ -228,8 +230,9 @@ noncomputable def ofIsCoprimeDifferentIdeal (h₁ : F₁.LinearDisjoint F₂) apply map_injective_of_injective (f := (IsScalarTower.toAlgHom R₁ B L).toLinearMap) (FaithfulSMul.algebraMap_injective B L) rw [map_span, ← Set.range_comp] - convert Module.Basis.ofIsCoprimeDifferentIdeal_aux A B R₁ R₂ h₁ h₂ h₃ b₂ - (b.localizationLocalization_span K A⁰ F₂) + convert! + Module.Basis.ofIsCoprimeDifferentIdeal_aux A B R₁ R₂ h₁ h₂ h₃ b₂ + (b.localizationLocalization_span K A⁰ F₂) · ext simp [b₂, v, ← IsScalarTower.algebraMap_apply] · ext; simp diff --git a/Mathlib/RingTheory/Derivation/MapCoeffs.lean b/Mathlib/RingTheory/Derivation/MapCoeffs.lean index ec0737106fd727..b237b66fdd3274 100644 --- a/Mathlib/RingTheory/Derivation/MapCoeffs.lean +++ b/Mathlib/RingTheory/Derivation/MapCoeffs.lean @@ -99,7 +99,7 @@ theorem apply_aeval_eq [IsScalarTower R A B] [IsScalarTower A B M'] (d : Derivat (x : B) (p : A[X]) : d (aeval x p) = PolynomialModule.eval x ((d.compAlgebraMap A).mapCoeffs p) + aeval x (derivative p) • d x := by - convert apply_aeval_eq' (d.compAlgebraMap A) d LinearMap.id _ x p + convert! apply_aeval_eq' (d.compAlgebraMap A) d LinearMap.id _ x p · apply Finsupp.ext intro x rfl @@ -144,7 +144,7 @@ variable {R : Type*} [CommRing R] [Differential R] [Algebra A R] [DifferentialAl theorem deriv_aeval_eq (x : R) (p : A[X]) : (aeval x p)′ = aeval x (mapCoeffs p) + aeval x (derivative p) * x′ := by - convert Derivation.apply_aeval_eq' Differential.deriv _ (Algebra.linearMap A R) .. + convert! Derivation.apply_aeval_eq' Differential.deriv _ (Algebra.linearMap A R) .. · simp [mapCoeffs] · simp [deriv_algebraMap] diff --git a/Mathlib/RingTheory/Derivation/ToSquareZero.lean b/Mathlib/RingTheory/Derivation/ToSquareZero.lean index 3710e74867ed53..a49ac0ff2b1f1f 100644 --- a/Mathlib/RingTheory/Derivation/ToSquareZero.lean +++ b/Mathlib/RingTheory/Derivation/ToSquareZero.lean @@ -58,7 +58,7 @@ def derivationToSquareZeroOfLift [IsScalarTower R A B] (hI : I ^ 2 = ⊥) (f : A let F := diffToIdealOfQuotientCompEq I f (IsScalarTower.toAlgHom R A B) (by rw [e]; ext; rfl) have : (f x - algebraMap A B x) * (f y - algebraMap A B y) = 0 := by rw [← Ideal.mem_bot, ← hI, pow_two] - convert Ideal.mul_mem_mul (F x).2 (F y).2 using 1 + convert! Ideal.mul_mem_mul (F x).2 (F y).2 using 1 ext dsimp only [Submodule.coe_add, Submodule.coe_mk, LinearMap.coe_mk, diffToIdealOfQuotientCompEq_apply, Submodule.coe_smul_of_tower, IsScalarTower.coe_toAlgHom', @@ -88,7 +88,7 @@ def liftOfDerivationToSquareZero [IsScalarTower R A B] (hI : I ^ 2 = ⊥) (f : D map_mul' := fun x y => by have : (f x : B) * f y = 0 := by rw [← Ideal.mem_bot, ← hI, pow_two] - convert Ideal.mul_mem_mul (f x).2 (f y).2 using 1 + convert! Ideal.mul_mem_mul (f x).2 (f y).2 using 1 simp only [map_mul, f.leibniz, add_mul, mul_add, Submodule.coe_add, Submodule.coe_smul_of_tower, Algebra.smul_def, this] ring diff --git a/Mathlib/RingTheory/DiscreteValuationRing/TFAE.lean b/Mathlib/RingTheory/DiscreteValuationRing/TFAE.lean index 78364d2f2209ef..f1a75c850f1310 100644 --- a/Mathlib/RingTheory/DiscreteValuationRing/TFAE.lean +++ b/Mathlib/RingTheory/DiscreteValuationRing/TFAE.lean @@ -92,8 +92,8 @@ theorem exists_maximalIdeal_pow_eq_of_principal [IsNoetherianRing R] [IsLocalRin · rw [hx, Ideal.span_singleton_pow, Ideal.span_le, Set.singleton_subset_iff] exact Nat.find_spec this -theorem maximalIdeal_isPrincipal_of_isDedekindDomain [IsLocalRing R] [IsDomain R] - [IsDedekindDomain R] : (maximalIdeal R).IsPrincipal := by +theorem maximalIdeal_isPrincipal_of_isDedekindDomain [IsLocalRing R] [IsDedekindDomain R] : + (maximalIdeal R).IsPrincipal := by classical by_cases ne_bot : maximalIdeal R = ⊥ · rw [ne_bot]; infer_instance @@ -219,7 +219,7 @@ theorem IsDiscreteValuationRing.TFAE [IsNoetherianRing R] [IsLocalRing R] [IsDom simp [Nat.le_one_iff_eq_zero_or_eq_one, finrank_cotangentSpace_eq_zero_iff, h] rw [this] have : maximalIdeal R ≠ ⊥ := isField_iff_maximalIdeal_eq.not.mp h - convert tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain R + convert! tfae_of_isNoetherianRing_of_isLocalRing_of_isDomain R · exact ⟨fun _ ↦ inferInstance, fun h ↦ { h with not_a_field' := this }⟩ · exact ⟨fun h P h₁ h₂ ↦ h.unique ⟨h₁, h₂⟩ ⟨this, inferInstance⟩, fun H ↦ ⟨_, ⟨this, inferInstance⟩, fun P hP ↦ H P hP.1 hP.2⟩⟩ diff --git a/Mathlib/RingTheory/Discriminant.lean b/Mathlib/RingTheory/Discriminant.lean index cb304cbad648b4..d1a54cd687e0ef 100644 --- a/Mathlib/RingTheory/Discriminant.lean +++ b/Mathlib/RingTheory/Discriminant.lean @@ -299,7 +299,7 @@ section Int /-- Two (finite) ℤ-bases have the same discriminant. -/ theorem discr_eq_discr (b : Basis ι ℤ A) (b' : Basis ι ℤ A) : Algebra.discr ℤ b = Algebra.discr ℤ b' := by - convert Algebra.discr_of_matrix_vecMul b' (b'.toMatrix b) + convert! Algebra.discr_of_matrix_vecMul b' (b'.toMatrix b) · rw [Basis.toMatrix_map_vecMul] · suffices IsUnit (b'.toMatrix b).det by rw [Int.isUnit_iff, ← sq_eq_one_iff] at this diff --git a/Mathlib/RingTheory/DividedPowerAlgebra/Init.lean b/Mathlib/RingTheory/DividedPowerAlgebra/Init.lean index 4332663e273c86..1fb73707b3541a 100644 --- a/Mathlib/RingTheory/DividedPowerAlgebra/Init.lean +++ b/Mathlib/RingTheory/DividedPowerAlgebra/Init.lean @@ -125,7 +125,7 @@ protected theorem induction_on' {P : DividedPowerAlgebra R M → Prop} (f : Divi rw [← hf] induction F using MvPolynomial.induction_on generalizing f with | C a => - convert h_C a using 1 + convert! h_C a using 1 rw [mkAlgHom, AlgHom.coe_mk] | add g1 g2 hg1 hg2 => rw [map_add] diff --git a/Mathlib/RingTheory/DividedPowers/Basic.lean b/Mathlib/RingTheory/DividedPowers/Basic.lean index 33f9b232d19512..2bf5f7e6a79e5a 100644 --- a/Mathlib/RingTheory/DividedPowers/Basic.lean +++ b/Mathlib/RingTheory/DividedPowers/Basic.lean @@ -320,7 +320,7 @@ theorem dpow_sum' {M : Type*} [AddCommMonoid M] {I : AddSubmonoid M} (dpow : ℕ conv_lhs => rw [← m.fill_filterNe a] exact Sym.count_coe_fill_of_ne (ne_of_mem_of_not_mem hi ha) · intro m hm - convert sym_filterNe_mem a hm + convert! sym_filterNe_mem a hm rw [erase_insert ha] variable {ι : Type*} [DecidableEq ι] diff --git a/Mathlib/RingTheory/Etale/Kaehler.lean b/Mathlib/RingTheory/Etale/Kaehler.lean index f548898ec50c78..5aabf14d3d3bbf 100644 --- a/Mathlib/RingTheory/Etale/Kaehler.lean +++ b/Mathlib/RingTheory/Etale/Kaehler.lean @@ -53,7 +53,7 @@ lemma KaehlerDifferential.tensorKaehlerEquivOfFormallyEtale_symm_D_algebraMap lemma KaehlerDifferential.isBaseChange_of_formallyEtale [Algebra.FormallyEtale S T] : IsBaseChange T (map R R S T) := by change Function.Bijective _ - convert (tensorKaehlerEquivOfFormallyEtale R S T).bijective using 1 + convert! (tensorKaehlerEquivOfFormallyEtale R S T).bijective using 1 change _ = ((tensorKaehlerEquivOfFormallyEtale R S T).toLinearMap.restrictScalars S : T ⊗[S] Ω[S⁄R] → _) congr! @@ -68,8 +68,9 @@ instance KaehlerDifferential.isLocalizedModule_map (M : Submonoid S) [IsLocaliza lemma KaehlerDifferential.span_range_map_derivation_of_isLocalization (M : Submonoid S) [IsLocalization M T] : Submodule.span T (Set.range <| map R R S T ∘ D R S) = ⊤ := by - convert span_eq_top_of_isLocalizedModule T M (map R R S T) (v := Set.range <| D R S) - (span_range_derivation R S) + convert! + span_eq_top_of_isLocalizedModule T M (map R R S T) (v := Set.range <| D R S) + (span_range_derivation R S) rw [← Set.range_comp, Function.comp_def] namespace Algebra.Extension @@ -306,7 +307,7 @@ def tensorH1CotangentOfIsLocalization (M : Submonoid S) [IsLocalization M T] : .of_algebraMap_eq fun r ↦ (f.algebraMap_toRingHom r).symm haveI : IsLocalizedModule M' (IsScalarTower.toAlgHom P.Ring S T).toLinearMap := by rw [isLocalizedModule_iff_isLocalization] - convert ‹IsLocalization M T› using 1 + convert! ‹IsLocalization M T› using 1 exact Submonoid.map_comap_eq_of_surjective P.algebraMap_surjective _ refine Extension.tensorH1CotangentOfFormallyEtale f rfl ?_ ?_ ≪≫ₗ Extension.equivH1CotangentOfFormallySmooth _ diff --git a/Mathlib/RingTheory/Etale/QuasiFinite.lean b/Mathlib/RingTheory/Etale/QuasiFinite.lean index c2b5ef8531246b..f2b347843c95ab 100644 --- a/Mathlib/RingTheory/Etale/QuasiFinite.lean +++ b/Mathlib/RingTheory/Etale/QuasiFinite.lean @@ -129,7 +129,7 @@ lemma Localization.exists_finite_awayMapₐ_of_surjective_awayMapₐ simp_rw [← hs, map_pow, AlgHom.commutes, ← pow_mul] at this refine ⟨s ^ m * b, (n + m' * m), 0, this ▸ ?_⟩ simp [pow_add, mul_assoc] - convert h₁.trans _ _ (RingHom.IsIntegral.of_finite (.of_surjective _ h₂)) using 1 + convert! h₁.trans _ _ (RingHom.IsIntegral.of_finite (.of_surjective _ h₂)) using 1 refine IsLocalization.ringHom_ext (.powers r) (RingHom.ext fun x ↦ ?_) simp [Localization.awayMap, IsLocalization.Away.map, ← IsScalarTower.algebraMap_apply R T] · algebraize [(Localization.awayMapₐ (Algebra.ofId R T) r).toRingHom] @@ -359,7 +359,7 @@ lemma Algebra.exists_etale_isIdempotentElem_forall_liesOver_eq_aux₂ (Localization.Away (φ e)) (Localization.Away (Algebra.ofId R' (Localization.Away e) f)) refine RingHom.finite_algebraMap.mp ?_ - convert equiv.symm.toRingEquiv.finite.comp hf + convert! equiv.symm.toRingEquiv.finite.comp hf apply IsLocalization.ringHom_ext (.powers f) dsimp [-AlgEquiv.symm_toRingEquiv, ← AlgEquiv.toAlgHom_toRingHom, -AlgHomClass.toRingHom_toAlgHom] @@ -426,7 +426,7 @@ lemma Algebra.exists_etale_isIdempotentElem_forall_liesOver_eq rwa [← P'f.over_def P'] · suffices Function.Bijective ⇑(Ideal.ResidueField.mapₐ P Pf (IsScalarTower.toAlgHom R R' (Localization.Away f)) (Pf.over_def P)) by - convert this.comp hpP; rw [← AlgHom.coe_comp]; congr; ext + convert! this.comp hpP; rw [← AlgHom.coe_comp]; congr; ext exact (RingHom.surjectiveOnStalks_of_isLocalization (.powers f) _).residueFieldMap_bijective _ _ _ · intro P'' _ _ hP'' diff --git a/Mathlib/RingTheory/EuclideanDomain.lean b/Mathlib/RingTheory/EuclideanDomain.lean index 175a23a7a3cce8..4a4886ca992141 100644 --- a/Mathlib/RingTheory/EuclideanDomain.lean +++ b/Mathlib/RingTheory/EuclideanDomain.lean @@ -76,7 +76,7 @@ def gcdMonoid (R) [EuclideanDomain R] [DecidableEq R] : GCDMonoid R where gcd_dvd_left := gcd_dvd_left gcd_dvd_right := gcd_dvd_right dvd_gcd := dvd_gcd - gcd_mul_lcm a b := by rw [EuclideanDomain.gcd_mul_lcm] + gcd_mul_lcm a b := by rw [EuclideanDomain.gcd_mul_lcm]; rfl lcm_zero_left := lcm_zero_left lcm_zero_right := lcm_zero_right diff --git a/Mathlib/RingTheory/Extension/Basic.lean b/Mathlib/RingTheory/Extension/Basic.lean index b71de23caf2efe..eefde687aba817 100644 --- a/Mathlib/RingTheory/Extension/Basic.lean +++ b/Mathlib/RingTheory/Extension/Basic.lean @@ -517,7 +517,7 @@ noncomputable def cotangentEquiv : S ⊗[P.Ring] P.ker ≃ₗ[S] P.Cotangent := · rw [smul_tmul]; rfl · simp_all [Algebra.smul_def] · intro a ha b hb ha' hb' - convert congr($ha' + $hb') + convert! congr($ha' + $hb') rw [← tmul_add] rfl · intro x diff --git a/Mathlib/RingTheory/Extension/Cotangent/BaseChange.lean b/Mathlib/RingTheory/Extension/Cotangent/BaseChange.lean index 04fd2e26e6b62c..18941666d8d90e 100644 --- a/Mathlib/RingTheory/Extension/Cotangent/BaseChange.lean +++ b/Mathlib/RingTheory/Extension/Cotangent/BaseChange.lean @@ -57,7 +57,7 @@ def tensorCotangentSpace (P : Extension.{u} R S) (T : Type*) [CommRing T] [Algeb rfl letI PT : Extension T (T ⊗[R] S) := P.baseChange haveI : IsPushout R T P.Ring PT.Ring := by - convert TensorProduct.isPushout (R := R) (T := P.Ring) (S := T) + convert! TensorProduct.isPushout (R := R) (T := P.Ring) (S := T) exact Algebra.algebra_ext _ _ fun _ ↦ rfl haveI : IsScalarTower P.Ring PT.Ring (T ⊗[R] S) := .of_algebraMap_eq' rfl (IsTensorProduct.assocOfMapSMul (TensorProduct.mk R T S) (isTensorProduct _ _ _) diff --git a/Mathlib/RingTheory/Extension/Cotangent/Basic.lean b/Mathlib/RingTheory/Extension/Cotangent/Basic.lean index 9b1e8c7ecf9d6c..48280df50545d6 100644 --- a/Mathlib/RingTheory/Extension/Cotangent/Basic.lean +++ b/Mathlib/RingTheory/Extension/Cotangent/Basic.lean @@ -223,7 +223,7 @@ lemma Hom.sub_aux (f g : Hom P P') (x y) : Function.comp_apply, ker, RingHom.mem_ker, map_sub, algebraMap_toRingHom, algebraMap_σ, sub_self, toAlgHom_apply] - convert this using 1 + convert! this using 1 simp only [map_mul] ring diff --git a/Mathlib/RingTheory/Extension/Cotangent/Basis.lean b/Mathlib/RingTheory/Extension/Cotangent/Basis.lean index 57be2b7a9908e7..1e7ce2133a4172 100644 --- a/Mathlib/RingTheory/Extension/Cotangent/Basis.lean +++ b/Mathlib/RingTheory/Extension/Cotangent/Basis.lean @@ -90,7 +90,7 @@ set_option backward.isDefEq.respectTransparency false in instance : IsLocalization.Away D.gbar S := by refine .of_surjective_of_isScalarTower (n := 1) ?_ ?_ _ ?_ (by simpa using D.hg) · refine .of_comp (g := algebraMap P.Ring D.T) ?_ - convert P.algebraMap_surjective + convert! P.algebraMap_surjective ext x exact (IsScalarTower.algebraMap_apply _ D.T S x).symm · simp [T, Ideal.Quotient.mk_surjective] @@ -297,7 +297,7 @@ public lemma exists_presentation_of_basis_cotangent [Algebra.FinitePresentation have hJfg : P.ker.FG := by rw [P.ker_eq_ker_aeval_val] apply FinitePresentation.ker_fG_of_surjective - convert P.algebraMap_surjective + convert! P.algebraMap_surjective simp [P.algebraMap_eq] have hJ : J ≤ P.ker := by simp [J, Ideal.span_le, Set.range_subset_iff] suffices hJ : P.ker ≤ J ⊔ P.ker • P.ker by @@ -318,7 +318,7 @@ public lemma exists_presentation_of_basis_cotangent [Algebra.FinitePresentation Function.comp_def, ← Submodule.restrictScalars_span P.Ring S P.algebraMap_surjective] refine le_trans le_top (top_le_iff.mpr ?_) rw [Submodule.restrictScalars_eq_top_iff] - convert b₀.span_eq + convert! b₀.span_eq exact hf _ open PresentationOfFreeCotangent in diff --git a/Mathlib/RingTheory/Extension/Generators.lean b/Mathlib/RingTheory/Extension/Generators.lean index 5ea6b2b1bdedfd..ba7a0b85a80012 100644 --- a/Mathlib/RingTheory/Extension/Generators.lean +++ b/Mathlib/RingTheory/Extension/Generators.lean @@ -18,10 +18,10 @@ public import Mathlib.RingTheory.Extension.Basic ## Main definition - `Algebra.Generators`: A family of generators of an `R`-algebra `S` consists of - 1. `vars`: The type of variables. - 2. `val : vars → S`: The assignment of each variable to a value. + 1. `ι`: The type of variables. + 2. `val : ι → S`: The assignment of each variable to a value. 3. `σ`: A set-theoretic section of the induced `R`-algebra homomorphism `R[X] → S`, where we - write `R[X]` for `R[vars]`. + write `R[X]` for `R[ι]`. - `Algebra.Generators.Hom`: Given a commuting square ``` @@ -35,13 +35,16 @@ public import Mathlib.RingTheory.Extension.Basic - `Algebra.Generators.Cotangent`: The cotangent space w.r.t. `P = R[X] → S`, i.e. the space `I/I²` with `I` being the kernel of the presentation. +- `Algebra.Generators.mvPolynomial`: The canonical `R`-generators of the polynomial algebra + `MvPolynomial ι R`, indexed by `ι` via the variables `X`. + ## TODOs -Currently, Lean does not see through the `vars` field of terms of `Generators R S` obtained +Currently, Lean does not see through the `ι` field of terms of `Generators R S` obtained from constructions, e.g. composition. This causes fragile and cumbersome proofs, because `simp` and `rw` often don't work properly. `Generators R S` (and `Presentation R S`, etc.) should be refactored in a way that makes these equalities reducibly def-eq, for example -by unbundling the `vars` field or making the field globally reducible in constructions using +by unbundling the `ι` field or making the field globally reducible in constructions using unification hints. -/ @@ -55,8 +58,8 @@ open TensorProduct MvPolynomial variable (R : Type u) (S : Type v) (ι : Type w) [CommRing R] [CommRing S] [Algebra R S] /-- A family of generators of an `R`-algebra `S` consists of -1. `vars`: The type of variables. -2. `val : vars → S`: The assignment of each variable to a value in `S`. +1. `ι`: The type of variables. +2. `val : ι → S`: The assignment of each variable to a value in `S`. 3. `σ`: A section of `R[X] → S`. -/ structure Algebra.Generators where /-- The assignment of each variable to a value in `S`. -/ @@ -139,6 +142,15 @@ noncomputable def id : Generators R R PEmpty.{w + 1} := ofSurjectiveAlgebraMap < rw [algebraMap_self] exact RingHomSurjective.is_surjective +variable (R ι) in +/-- The canonical `R`-generators of the polynomial algebra `MvPolynomial ι R`, +indexed by `ι` via the variables `X`. -/ +@[simps σ, simps -fullyApplied val] +noncomputable def mvPolynomial : Generators R (MvPolynomial ι R) ι where + val := X + σ' f := f + aeval_val_σ' := aeval_X_left_apply + /-- Construct `Generators` from an assignment `I → S` such that `R[X] → S` is surjective. -/ noncomputable def ofAlgHom {I : Type*} (f : MvPolynomial I R →ₐ[R] S) (h : Function.Surjective f) : @@ -315,7 +327,7 @@ lemma extend_val_inl (P : Generators R S ι) (b : ι' → S) (i : ι) : lemma extend_val_inr (P : Generators R S ι) (b : ι' → S) (i : ι') : (P.extend b).val (.inr i) = b i := rfl -/-- Given generators `P` and an equivalence `ι ≃ P.vars`, these +/-- Given generators `P` with variable type `ι'` and an equivalence `ι ≃ ι'`, these are the induced generators indexed by `ι`. -/ noncomputable def reindex (P : Generators R S ι') (e : ι ≃ ι') : Generators R S ι where @@ -531,7 +543,7 @@ lemma ofComp_toAlgHom_monomial_sumElim (Q : Generators S T ι') (P : Generators lemma toComp_toAlgHom_monomial (Q : Generators S T ι') (P : Generators R S ι) (j a) : (Q.toComp P).toAlgHom (monomial j a) = monomial (Finsupp.sumElim 0 j) a := by - convert rename_monomial _ _ _ + convert! rename_monomial _ _ _ ext f (i₁ | i₂) <;> simp [Finsupp.mapDomain_notin_range, Finsupp.mapDomain_apply Sum.inr_injective] @@ -606,6 +618,9 @@ lemma ker_eq_ker_aeval_val : P.ker = RingHom.ker (aeval P.val) := by simp only [ker, Extension.ker, toExtension_Ring, algebraMap_eq] rfl +lemma ker_mvPolynomial : (mvPolynomial R ι).ker = ⊥ := by + simp [ker_eq_ker_aeval_val, SetLike.ext_iff, aeval_X_left] + variable {P} in lemma aeval_val_eq_zero {x} (hx : x ∈ P.ker) : aeval P.val x = 0 := by rwa [← algebraMap_apply] @@ -700,9 +715,9 @@ lemma map_toComp_ker (Q : Generators S T ι') (P : Generators R S ι) : simp only [coeff_add, map_add, ite_add_zero] rw [finsum_add_distrib, hp, hq] · refine (((support p).map e).finite_toSet.subset ?_) - convert this p + convert! this p · refine (((support q).map e).finite_toSet.subset ?_) - convert this q + convert! this q /-- Given `R[X] → S` and `S[Y] → T`, this is the lift of an element in `ker(S[Y] → T)` @@ -713,7 +728,7 @@ def kerCompPreimage (Q : Generators S T ι') (P : Generators R S ι) (x : Q.ker) (Q.comp P).ker := by refine ⟨x.1.sum fun n r ↦ ?_, ?_⟩ · -- The use of `refine` is intentional to control the elaboration order - -- so that the term has type `(Q.comp P).Ring` and not `MvPolynomial (Q.vars ⊕ P.vars) R` + -- so that the term has type `(Q.comp P).Ring` and not `MvPolynomial (Q.ι ⊕ P.ι) R` refine rename ?_ (P.σ r) * monomial ?_ 1 exacts [Sum.inr, n.mapDomain Sum.inl] · simp only [ker_eq_ker_aeval_val, RingHom.mem_ker] diff --git a/Mathlib/RingTheory/Extension/Presentation/Basic.lean b/Mathlib/RingTheory/Extension/Presentation/Basic.lean index 6aba6035755878..20b88f8700f9c0 100644 --- a/Mathlib/RingTheory/Extension/Presentation/Basic.lean +++ b/Mathlib/RingTheory/Extension/Presentation/Basic.lean @@ -133,7 +133,7 @@ lemma exists_presentation_fin [FinitePresentation R S] : let v : Fin m → MvPolynomial (Fin n) R := H'.choose_spec.choose have hv : Ideal.span (Set.range v) = RingHom.ker f := H'.choose_spec.choose_spec ⟨n, m, - ⟨{__ := Generators.ofSurjective (fun x ↦ f (.X x)) (by convert hf; ext; simp) + ⟨{__ := Generators.ofSurjective (fun x ↦ f (.X x)) (by convert! hf; ext; simp) relation := v span_range_relation_eq_ker := hv.trans (by congr; ext; simp) }⟩⟩ @@ -285,7 +285,7 @@ lemma span_range_relation_eq_ker_baseChange : Ideal.comap_symm, ← Ideal.map_coe, ← Ideal.map_coe _ (Ideal.span _), Ideal.map_map, Ideal.map_span, ← Set.range_comp, AlgEquiv.toRingEquiv_toRingHom, RingHom.coe_comp, RingHom.coe_coe] at H' - convert H' + convert! H' simp [e] /-- If `P` is a presentation of `S` over `R` and `T` is an `R`-algebra, we diff --git a/Mathlib/RingTheory/Extension/Presentation/Core.lean b/Mathlib/RingTheory/Extension/Presentation/Core.lean index 3f588b2ad6ca8c..0e3a5b9dd35491 100644 --- a/Mathlib/RingTheory/Extension/Presentation/Core.lean +++ b/Mathlib/RingTheory/Extension/Presentation/Core.lean @@ -246,7 +246,7 @@ lemma jacobianRelations_spec [DecidableEq σ] [Fintype σ] : ∑ i, P.jacobianRelations i * P.relation i = P.jacobiMatrix.det * P.σ ↑(P.jacobian_isUnit.unit⁻¹) - 1 := by delta jacobianRelations - convert P.exists_sum_eq_σ_jacobian_mul_σ_jacobian_inv_sub_one.choose_spec + convert! P.exists_sum_eq_σ_jacobian_mul_σ_jacobian_inv_sub_one.choose_spec /-- The set of coefficients that is enough to descend a submersive presentation `P`. -/ def coeffs : Set R := @@ -352,7 +352,7 @@ def ofHasCoeffs [FaithfulSMul R₀ R] : $(P.sum_jacobianRelationsOfHasCoeffs_mul_relationOfHasCoeffs R₀)) simp only [map_sum, map_mul, Ideal.Quotient.mk_span_range, mul_zero, Finset.sum_const_zero, map_sub, map_one, @eq_comm (P.ModelOfHasCoeffs R₀) 0, sub_eq_zero] at this - convert IsUnit.of_mul_eq_one _ this + convert! IsUnit.of_mul_eq_one _ this rw [PreSubmersivePresentation.jacobian_eq_jacobiMatrix_det] simp [jacobianOfHasCoeffs] diff --git a/Mathlib/RingTheory/Extension/Presentation/Submersive.lean b/Mathlib/RingTheory/Extension/Presentation/Submersive.lean index 715b28ed3779e1..98b855e0765b18 100644 --- a/Mathlib/RingTheory/Extension/Presentation/Submersive.lean +++ b/Mathlib/RingTheory/Extension/Presentation/Submersive.lean @@ -171,7 +171,7 @@ lemma isUnit_jacobian_of_linearIndependent_of_span_eq_top classical rw [isUnit_jacobian_iff_aevalDifferential_bijective] exact LinearMap.bijective_of_linearIndependent_of_span_eq_top (Pi.basisFun _ _).span_eq - (by convert hli; simp) (by convert hsp; simp) + (by convert! hli; simp) (by convert! hsp; simp) end @@ -380,8 +380,9 @@ lemma comp_jacobian_eq_jacobian_smul_jacobian [Finite σ] [Finite σ'] : (aeval (Q.comp P).val) (Q.comp P).jacobiMatrix.toBlocks₂₂.det = P.jacobian • Q.jacobian · simp only [Generators.algebraMap_apply, ← map_mul] congr - convert Matrix.det_fromBlocks_zero₁₂ (Q.comp P).jacobiMatrix.toBlocks₁₁ - (Q.comp P).jacobiMatrix.toBlocks₂₁ (Q.comp P).jacobiMatrix.toBlocks₂₂ + convert! + Matrix.det_fromBlocks_zero₁₂ (Q.comp P).jacobiMatrix.toBlocks₁₁ + (Q.comp P).jacobiMatrix.toBlocks₂₁ (Q.comp P).jacobiMatrix.toBlocks₂₂ · rw [jacobiMatrix_comp_₁₁_det, jacobiMatrix_comp_₂₂_det, mul_comm, Algebra.smul_def] end Composition @@ -607,7 +608,7 @@ noncomputable def aevalDifferentialEquiv (P : SubmersivePresentation R S ι σ) haveI : Fintype σ := Fintype.ofFinite σ have : IsUnit (LinearMap.toMatrix (Pi.basisFun S σ) (Pi.basisFun S σ) P.aevalDifferential).det := by - convert P.jacobian_isUnit + convert! P.jacobian_isUnit rw [LinearMap.toMatrix_eq_toMatrix', jacobian_eq_jacobiMatrix_det, aevalDifferential_toMatrix'_eq_mapMatrix_jacobiMatrix, P.algebraMap_eq] simp [RingHom.map_det] diff --git a/Mathlib/RingTheory/Filtration.lean b/Mathlib/RingTheory/Filtration.lean index a1c518f401a09e..37b4837f7daaca 100644 --- a/Mathlib/RingTheory/Filtration.lean +++ b/Mathlib/RingTheory/Filtration.lean @@ -202,7 +202,7 @@ theorem Stable.exists_pow_smul_eq_of_ge (h : F.Stable) : obtain ⟨n₀, hn₀⟩ := h.exists_pow_smul_eq use n₀ intro n hn - convert hn₀ (n - n₀) + convert! hn₀ (n - n₀) rw [add_comm, tsub_add_cancel_of_le hn] theorem stable_iff_exists_pow_smul_eq_of_ge : @@ -430,7 +430,7 @@ theorem Ideal.iInf_pow_smul_eq_bot_of_isLocalRing [IsNoetherianRing R] [IsLocalR /-- **Krull's intersection theorem** for Noetherian local rings. -/ theorem Ideal.iInf_pow_eq_bot_of_isLocalRing [IsNoetherianRing R] [IsLocalRing R] (h : I ≠ ⊤) : ⨅ i : ℕ, I ^ i = ⊥ := by - convert I.iInf_pow_smul_eq_bot_of_isLocalRing (M := R) h + convert! I.iInf_pow_smul_eq_bot_of_isLocalRing (M := R) h ext i rw [smul_eq_mul, ← Ideal.one_eq_top, mul_one] @@ -466,5 +466,5 @@ alias Ideal.iInf_pow_smul_eq_bot_of_noZeroSMulDivisors := /-- **Krull's intersection theorem** for Noetherian domains. -/ theorem Ideal.iInf_pow_eq_bot_of_isDomain [IsNoetherianRing R] [IsDomain R] (h : I ≠ ⊤) : ⨅ i : ℕ, I ^ i = ⊥ := by - convert I.iInf_pow_smul_eq_bot_of_isTorsionFree (M := R) h + convert! I.iInf_pow_smul_eq_bot_of_isTorsionFree (M := R) h simp diff --git a/Mathlib/RingTheory/FinitePresentation.lean b/Mathlib/RingTheory/FinitePresentation.lean index 9c26929a9b247e..d80c56569c5154 100644 --- a/Mathlib/RingTheory/FinitePresentation.lean +++ b/Mathlib/RingTheory/FinitePresentation.lean @@ -373,7 +373,7 @@ theorem ker_fg_of_mvPolynomial {n : ℕ} (f : MvPolynomial (Fin n) R →ₐ[R] A theorem ker_fG_of_surjective (f : A →ₐ[R] B) (hf : Function.Surjective f) [FinitePresentation R A] [FinitePresentation R B] : (RingHom.ker f.toRingHom).FG := by obtain ⟨n, g, hg, _⟩ := FinitePresentation.out (R := R) (A := A) - convert (ker_fg_of_mvPolynomial (f.comp g) (hf.comp hg)).map g.toRingHom + convert! (ker_fg_of_mvPolynomial (f.comp g) (hf.comp hg)).map g.toRingHom simp_rw [RingHom.ker_eq_comap_bot, AlgHom.toRingHom_eq_coe, AlgHom.comp_toRingHom] rw [← Ideal.comap_comap, Ideal.map_comap_of_surjective (g : MvPolynomial (Fin n) R →+* A) hg] @@ -488,7 +488,7 @@ lemma polynomial_induction | zero => refine fg_ker _ _ _ (hg.comp (MvPolynomial.C_surjective (Fin 0))) ?_ rw [← comap_ker] - convert hg'.map (MvPolynomial.isEmptyRingEquiv R (Fin 0)).toRingHom using 1 + convert! hg'.map (MvPolynomial.isEmptyRingEquiv R (Fin 0)).toRingHom using 1 simp only [RingEquiv.toRingHom_eq_coe] exact Ideal.comap_symm (MvPolynomial.isEmptyRingEquiv R (Fin 0)) | succ n IH => @@ -496,10 +496,10 @@ lemma polynomial_induction (MvPolynomial.renameEquiv R (finSuccEquiv n)).trans (MvPolynomial.optionEquivRight R (Fin n)) have he : (ker (g'.comp <| RingHomClass.toRingHom e.symm)).FG := by rw [← RingHom.comap_ker] - convert hg'.map e.toAlgHom.toRingHom using 1 + convert! hg'.map e.toAlgHom.toRingHom using 1 exact Ideal.comap_symm e.toRingEquiv have := IH (R := R[X]) (S := S) (g'.comp e.symm) (hg.comp e.symm.surjective) he - convert comp _ _ _ _ _ (polynomial _) this using 1 + convert! comp _ _ _ _ _ (polynomial _) this using 1 rw [comp_assoc, comp_assoc] congr 1 with r simp [e] @@ -544,7 +544,7 @@ theorem comp_surjective {f : A →ₐ[R] B} {g : B →ₐ[R] C} (hf : f.FinitePr theorem of_surjective (f : A →ₐ[R] B) (hf : Surjective f) (hker : (RingHom.ker f.toRingHom).FG) : f.FinitePresentation := by -- Porting note: added `convert` - convert RingHom.FinitePresentation.of_surjective f hf hker + convert! RingHom.FinitePresentation.of_surjective f hf hker theorem of_finiteType [IsNoetherianRing A] {f : A →ₐ[R] B} : f.FiniteType ↔ f.FinitePresentation := RingHom.FinitePresentation.of_finiteType diff --git a/Mathlib/RingTheory/FiniteType.lean b/Mathlib/RingTheory/FiniteType.lean index 6b3368b754c46e..58734998b2a1fb 100644 --- a/Mathlib/RingTheory/FiniteType.lean +++ b/Mathlib/RingTheory/FiniteType.lean @@ -85,7 +85,7 @@ variable {R S A B} theorem of_surjective [FiniteType R A] (f : A →ₐ[R] B) (hf : Surjective f) : FiniteType R B := ⟨by - convert ‹FiniteType R A›.1.map f + convert! ‹FiniteType R A›.1.map f simpa only [map_top f, @eq_comm _ ⊤, eq_top_iff, AlgHom.mem_range] using hf⟩ theorem equiv (hRA : FiniteType R A) (e : A ≃ₐ[R] B) : FiniteType R B := diff --git a/Mathlib/RingTheory/Finiteness/Defs.lean b/Mathlib/RingTheory/Finiteness/Defs.lean index 8a0762d17ac8a0..0ef614fce85e26 100644 --- a/Mathlib/RingTheory/Finiteness/Defs.lean +++ b/Mathlib/RingTheory/Finiteness/Defs.lean @@ -75,7 +75,7 @@ lemma fg_iff_exists_finite_generating_family {A : Type u} [Semiring A] {M : Type · intro hN obtain ⟨n, f, h⟩ := fg_iff_exists_fin_generating_family.mp hN refine ⟨ULift (Fin n), inferInstance, f ∘ ULift.down, ?_⟩ - convert h + convert! h ext simp · rintro ⟨G, _, g, hg⟩ diff --git a/Mathlib/RingTheory/Finiteness/FinitePresentationLocal.lean b/Mathlib/RingTheory/Finiteness/FinitePresentationLocal.lean index 3c286be52d0f2f..0b759d65bcc3dc 100644 --- a/Mathlib/RingTheory/Finiteness/FinitePresentationLocal.lean +++ b/Mathlib/RingTheory/Finiteness/FinitePresentationLocal.lean @@ -112,7 +112,7 @@ lemma of_span_eq_top_target (s : Set S) (hs : Ideal.span (s : Set S) = ⊤) have Ht (g : t) : Algebra.FinitePresentation R (Localization.Away (f' g)) := by have : ∃ (a : S) (hb : a ∈ s), (Ideal.Quotient.mk I) (g' ⟨a, hb⟩) = g.val := by obtain ⟨g, hg⟩ := g - convert hg + convert! hg simp [A, t] obtain ⟨r, hr, hrr⟩ := this simp only [f'] diff --git a/Mathlib/RingTheory/Finiteness/FiniteTypeLocal.lean b/Mathlib/RingTheory/Finiteness/FiniteTypeLocal.lean index adebc0a54bd6e3..f41af9b621f778 100644 --- a/Mathlib/RingTheory/Finiteness/FiniteTypeLocal.lean +++ b/Mathlib/RingTheory/Finiteness/FiniteTypeLocal.lean @@ -55,7 +55,7 @@ theorem IsLocalization.exists_smul_mem_of_mem_adjoin [Algebra R S'] rw [Algebra.smul_def, ← map_mul] at hx'' obtain ⟨a, ha₂⟩ := (IsLocalization.eq_iff_exists M S').mp hx'' use a * y ^ n - convert A.mul_mem hx' (hA₂ a.prop) using 1 + convert! A.mul_mem hx' (hA₂ a.prop) using 1 rw [Submonoid.smul_def, smul_eq_mul, Submonoid.coe_mul, SubmonoidClass.coe_pow, mul_assoc, ← ha₂, mul_comm] @@ -145,7 +145,7 @@ lemma Algebra.FiniteType.of_span_eq_top_source (s : Set R) (hs : Ideal.span (s : choose s₁ s₂ using H let sf := fun x : s => IsLocalization.finsetIntegerMultiple (Submonoid.powers (f x)) (s₁ x) use s.attach.biUnion sf - convert (Algebra.adjoin_attach_biUnion (R := R) sf).trans _ + convert! (Algebra.adjoin_attach_biUnion (R := R) sf).trans _ rw [eq_top_iff] rintro x - apply (⨆ x : s, Algebra.adjoin R (sf x : Set S)).toSubmodule.mem_of_span_eq_top_of_smul_pow_mem diff --git a/Mathlib/RingTheory/Finiteness/NilpotentKer.lean b/Mathlib/RingTheory/Finiteness/NilpotentKer.lean index 07d454680f56ca..e33b8a92bd02e4 100644 --- a/Mathlib/RingTheory/Finiteness/NilpotentKer.lean +++ b/Mathlib/RingTheory/Finiteness/NilpotentKer.lean @@ -55,7 +55,7 @@ lemma Module.finite_of_surjective_of_ker_le_nilradical rw [LinearMap.ker_comp, ← Submodule.map_le_map_iff_of_injective (I ^ n).subtype_injective, Submodule.map_smul'', Submodule.map_comap_eq] simpa [pow_succ'] using Ideal.mul_le_left (I := I) (J := I ^ n) - convert Module.Finite.fg_top.map (ψ.restrictScalars R) using 1 + convert! Module.Finite.fg_top.map (ψ.restrictScalars R) using 1 suffices LinearMap.ker φ.toLinearMap = Submodule.map (I ^ (n + 1)).mkQ (I ^ n) by simpa [LinearMap.range_restrictScalars, ψ, LinearMap.range_comp, Submodule.range_liftQ] apply Submodule.comap_injective_of_surjective (I ^ (n + 1)).mkQ_surjective diff --git a/Mathlib/RingTheory/Fintype.lean b/Mathlib/RingTheory/Fintype.lean index 2c5ef98aab5853..b33e82d29cdd25 100644 --- a/Mathlib/RingTheory/Fintype.lean +++ b/Mathlib/RingTheory/Fintype.lean @@ -26,7 +26,7 @@ lemma Finset.univ_of_card_le_two (h : Fintype.card R ≤ 2) : rcases subsingleton_or_nontrivial R · exact le_antisymm (fun a _ ↦ by simp [Subsingleton.elim a 0]) (Finset.subset_univ _) · refine (eq_of_subset_of_card_le (subset_univ _) ?_).symm - convert h + convert! h simp lemma Finset.univ_of_card_le_three (h : Fintype.card R ≤ 3) : diff --git a/Mathlib/RingTheory/Flat/Basic.lean b/Mathlib/RingTheory/Flat/Basic.lean index 7fe3ea31c77c8e..14a10a5b7b5e5a 100644 --- a/Mathlib/RingTheory/Flat/Basic.lean +++ b/Mathlib/RingTheory/Flat/Basic.lean @@ -165,7 +165,7 @@ instance instSubalgebraToSubmodule {S : Type v} [Semiring S] [Algebra R S] instance self : Flat R R where out _ _ _ _ I _ := by rw [← (TensorProduct.rid R I).symm.injective_comp, ← (TensorProduct.rid R _).comp_injective] - convert Subtype.coe_injective using 1 + convert! Subtype.coe_injective using 1 ext; simp /-- A retract of a flat `R`-module is flat. -/ @@ -409,14 +409,16 @@ namespace Algebra.TensorProduct theorem includeLeft_injective [Module.Flat R A] (hb : Function.Injective (algebraMap R B)) : Function.Injective (includeLeft : A →ₐ[S] A ⊗[R] B) := by - convert Module.Flat.lTensor_preserves_injective_linearMap (M := A) (Algebra.linearMap R B) hb - |>.comp (_root_.TensorProduct.rid R A).symm.injective + convert! + Module.Flat.lTensor_preserves_injective_linearMap (M := A) (Algebra.linearMap R B) hb |>.comp + (_root_.TensorProduct.rid R A).symm.injective ext; simp theorem includeRight_injective [Module.Flat R B] (ha : Function.Injective (algebraMap R A)) : Function.Injective (includeRight : B →ₐ[R] A ⊗[R] B) := by - convert Module.Flat.rTensor_preserves_injective_linearMap (M := B) (Algebra.linearMap R A) ha - |>.comp (_root_.TensorProduct.lid R B).symm.injective + convert! + Module.Flat.rTensor_preserves_injective_linearMap (M := B) (Algebra.linearMap R A) ha |>.comp + (_root_.TensorProduct.lid R B).symm.injective ext; simp end Algebra.TensorProduct @@ -501,8 +503,9 @@ See `LinearIndependent.tmul_of_isDomain`. -/ lemma _root_.LinearIndependent.tmul_of_flat_left [Module.Flat R M] (hv : LinearIndependent R v) (hw : LinearIndependent R w) : LinearIndependent R fun i : ι × κ ↦ v i.1 ⊗ₜ[R] w i.2 := by rw [LinearIndependent] - convert (TensorProduct.map_injective_of_flat_flat _ _ hv hw).comp - (finsuppTensorFinsupp' _ _ _).symm.injective + convert! + (TensorProduct.map_injective_of_flat_flat _ _ hv hw).comp + (finsuppTensorFinsupp' _ _ _).symm.injective rw [← LinearEquiv.coe_toLinearMap, ← LinearMap.coe_comp] congr! ext i diff --git a/Mathlib/RingTheory/Flat/Domain.lean b/Mathlib/RingTheory/Flat/Domain.lean index 2e299f80c8e651..102ee114547d10 100644 --- a/Mathlib/RingTheory/Flat/Domain.lean +++ b/Mathlib/RingTheory/Flat/Domain.lean @@ -44,7 +44,7 @@ lemma TensorProduct.map_injective_of_flat_flat_of_isDomain have H₆ := Module.Flat.rTensor_preserves_injective_linearMap (M := P ⊗[R] Q) (Algebra.linearMap R K) (FaithfulSMul.algebraMap_injective R K) have H₇ := (TensorProduct.lid R (P ⊗[R] Q)).symm.injective - convert H₅.comp <| H₃.comp <| H₁.comp <| H₂.comp <| H₄.comp <| H₆.comp <| H₇ + convert! H₅.comp <| H₃.comp <| H₁.comp <| H₂.comp <| H₄.comp <| H₆.comp <| H₇ dsimp only [← LinearMap.coe_comp, ← LinearEquiv.coe_toLinearMap, ← @LinearMap.coe_restrictScalars R K] congr! 1 @@ -62,8 +62,9 @@ See `LinearIndependent.tmul_of_flat_left`. -/ lemma LinearIndependent.tmul_of_isDomain (hv : LinearIndependent R v) (hw : LinearIndependent R w) : LinearIndependent R fun i : ι × κ ↦ v i.1 ⊗ₜ[R] w i.2 := by rw [LinearIndependent] - convert (TensorProduct.map_injective_of_flat_flat_of_isDomain _ _ hv hw).comp - (finsuppTensorFinsupp' _ _ _).symm.injective + convert! + (TensorProduct.map_injective_of_flat_flat_of_isDomain _ _ hv hw).comp + (finsuppTensorFinsupp' _ _ _).symm.injective rw [← LinearEquiv.coe_toLinearMap, ← LinearMap.coe_comp] congr! ext i diff --git a/Mathlib/RingTheory/Flat/Equalizer.lean b/Mathlib/RingTheory/Flat/Equalizer.lean index f1a3e6ebe49781..07fbc4cd1d5ead 100644 --- a/Mathlib/RingTheory/Flat/Equalizer.lean +++ b/Mathlib/RingTheory/Flat/Equalizer.lean @@ -351,3 +351,18 @@ lemma Algebra.kerTensorProductMapIdToAlgHomEquiv_symm_apply [Module.Flat R T] x ⊗ₜ (y * z.1) := rfl end Algebra + +namespace RingHom + +/-- +A property `P` of ring homomorphisms is said to have stable equalizers, if the equalizer +of algebra maps between algebras with structure morphisms satisfying `P`, is preserved by +arbitrary base change. +-/ +def HasStableEqualizers (P : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop) : Prop := + ∀ {R S A B : Type u} [CommRing R] [CommRing S] [CommRing A] [CommRing B] + [Algebra R A] [Algebra R S] [Algebra R B] + (f g : A →ₐ[R] B), P (algebraMap R A) → P (algebraMap R B) → + Function.Bijective (f.tensorEqualizer R S g) + +end RingHom diff --git a/Mathlib/RingTheory/Flat/EquationalCriterion.lean b/Mathlib/RingTheory/Flat/EquationalCriterion.lean index ef55e75c7709ac..da60d25b5d101c 100644 --- a/Mathlib/RingTheory/Flat/EquationalCriterion.lean +++ b/Mathlib/RingTheory/Flat/EquationalCriterion.lean @@ -44,7 +44,7 @@ that $x = y \circ a$ and $a \circ f = 0$. We recover the usual equational criter $K = R$ and $N = R^l$. This is used in the proof of Lazard's theorem. We conclude that every linear map from a finitely presented module to a flat module factors -through a finite free module (`Module.Flat.exists_factorization_of_isFinitelyPresented`), and +through a finite free module (`Module.Flat.exists_factorization_of_finitePresentation`), and every finitely presented flat module is projective (`Module.Flat.projective_of_finitePresentation`). ## References @@ -245,7 +245,7 @@ private theorem exists_factorization_of_comp_eq_zero_of_free_aux [Flat R M] {K : use k₂, a₂ ∘ₗ a₁, y₂ simp_rw [comp_assoc] exact ⟨trivial, sup_le (ha₁.trans (ker_le_ker_comp _ _)) ha₂⟩ - convert this ⊤ Finite.fg_top + convert! this ⊤ Finite.fg_top simp only [top_le_iff, ker_eq_top] /-- Let $M$ be a flat module. Let $K$ and $N$ be finite $R$-modules with $N$ @@ -268,9 +268,9 @@ theorem exists_factorization_of_comp_eq_zero_of_free [Flat R M] {K N : Type*} [A /-- Every homomorphism from a finitely presented module to a flat module factors through a finite free module. -/ @[stacks 058E "only if"] -theorem exists_factorization_of_isFinitelyPresented [Flat R M] {P : Type*} [AddCommGroup P] +theorem exists_factorization_of_finitePresentation [Flat R M] {P : Type*} [AddCommGroup P] [Module R P] [FinitePresentation R P] (h₁ : P →ₗ[R] M) : - ∃ (k : ℕ) (h₂ : P →ₗ[R] (Fin k →₀ R)) (h₃ : (Fin k →₀ R) →ₗ[R] M), h₁ = h₃ ∘ₗ h₂ := by + ∃ (k : ℕ) (h₂ : P →ₗ[R] (Fin k →₀ R)) (h₃ : (Fin k →₀ R) →ₗ[R] M), h₁ = h₃ ∘ₗ h₂ := by have ⟨_, K, ϕ, hK⟩ := FinitePresentation.exists_fin R P haveI : Module.Finite R K := .of_fg hK have : (h₁ ∘ₗ ϕ.symm ∘ₗ K.mkQ) ∘ₗ K.subtype = 0 := by @@ -281,9 +281,12 @@ theorem exists_factorization_of_isFinitelyPresented [Flat R M] {P : Type*} [AddC apply (cancel_right K.mkQ_surjective).mp simpa [comp_assoc] +@[deprecated (since := "2026-05-23")] +alias exists_factorization_of_isFinitelyPresented := exists_factorization_of_finitePresentation + @[stacks 00NX "(1) → (2)"] theorem projective_of_finitePresentation [Flat R M] [FinitePresentation R M] : Projective R M := - have ⟨_, f, g, eq⟩ := exists_factorization_of_isFinitelyPresented (.id (R := R) (M := M)) + have ⟨_, f, g, eq⟩ := exists_factorization_of_finitePresentation (.id (R := R) (M := M)) .of_split f g eq.symm end Module.Flat diff --git a/Mathlib/RingTheory/Flat/TorsionFree.lean b/Mathlib/RingTheory/Flat/TorsionFree.lean index 4ee77069223be0..9cb449c7699f52 100644 --- a/Mathlib/RingTheory/Flat/TorsionFree.lean +++ b/Mathlib/RingTheory/Flat/TorsionFree.lean @@ -116,7 +116,7 @@ theorem flat_iff_torsion_eq_bot_of_isBezout [IsBezout R] [IsDomain R] : rw [← Submodule.isTorsionFree_iff_torsion_eq_bot] at htors refine Function.Injective.comp (LinearMap.lsmul_injective this) ?_ rw [← Equiv.injective_comp (TensorProduct.lid R M).symm.toEquiv] - convert Function.injective_id + convert! Function.injective_id ext simp diff --git a/Mathlib/RingTheory/FractionalIdeal/Basic.lean b/Mathlib/RingTheory/FractionalIdeal/Basic.lean index 0ccda531d73680..7da7550e129b2f 100644 --- a/Mathlib/RingTheory/FractionalIdeal/Basic.lean +++ b/Mathlib/RingTheory/FractionalIdeal/Basic.lean @@ -195,7 +195,7 @@ theorem ext {I J : FractionalIdeal S P} : (∀ x, x ∈ I ↔ x ∈ J) → I = J Useful to fix definitional equalities. -/ protected def copy (p : FractionalIdeal S P) (s : Set P) (hs : s = ↑p) : FractionalIdeal S P := ⟨Submodule.copy p s hs, by - convert p.isFractional + convert! p.isFractional ext simp only [hs] rfl⟩ @@ -419,7 +419,7 @@ theorem coe_le_coe {I J : FractionalIdeal S P} : theorem zero_le (I : FractionalIdeal S P) : 0 ≤ I := by intro x hx - convert zero_mem I + convert! zero_mem I rw [(mem_zero_iff _).mp hx] instance orderBot : OrderBot (FractionalIdeal S P) where @@ -506,7 +506,7 @@ theorem _root_.IsFractional.nsmul {I : Submodule R P} : ∀ n : ℕ, IsFractional S I → IsFractional S (n • I : Submodule R P) | 0, _ => by rw [zero_smul] - convert ((0 : Ideal R) : FractionalIdeal S P).isFractional + convert! ((0 : Ideal R) : FractionalIdeal S P).isFractional simp | n + 1, h => by rw [succ_nsmul] diff --git a/Mathlib/RingTheory/FractionalIdeal/Extended.lean b/Mathlib/RingTheory/FractionalIdeal/Extended.lean index ccea9938b35ee0..ee07c0d90eb66e 100644 --- a/Mathlib/RingTheory/FractionalIdeal/Extended.lean +++ b/Mathlib/RingTheory/FractionalIdeal/Extended.lean @@ -244,6 +244,8 @@ theorem extendedHom_le_one_iff [IsIntegrallyClosed A] [IsIntegrallyClosed B] : section IsDedekindDomain +set_option linter.overlappingInstances false + variable [IsDedekindDomain A] [IsDedekindDomain B] theorem one_le_extendedHom_iff (hI : I ≠ 0) : 1 ≤ extendedHom L B I ↔ 1 ≤ I := by diff --git a/Mathlib/RingTheory/FractionalIdeal/Norm.lean b/Mathlib/RingTheory/FractionalIdeal/Norm.lean index 306957c34f719b..7ad462af5eec8b 100644 --- a/Mathlib/RingTheory/FractionalIdeal/Norm.lean +++ b/Mathlib/RingTheory/FractionalIdeal/Norm.lean @@ -88,7 +88,7 @@ theorem absNorm_nonneg (I : FractionalIdeal R⁰ K) : 0 ≤ absNorm I := by dsim theorem absNorm_bot : absNorm (⊥ : FractionalIdeal R⁰ K) = 0 := absNorm.map_zero' -theorem absNorm_one : absNorm (1 : FractionalIdeal R⁰ K) = 1 := by convert absNorm.map_one' +theorem absNorm_one : absNorm (1 : FractionalIdeal R⁰ K) = 1 := by convert! absNorm.map_one' theorem absNorm_eq_zero_iff [IsDomain K] {I : FractionalIdeal R⁰ K} : absNorm I = 0 ↔ I = 0 := by diff --git a/Mathlib/RingTheory/FractionalIdeal/Operations.lean b/Mathlib/RingTheory/FractionalIdeal/Operations.lean index 74119c26b13972..e40d786a0f1ebd 100644 --- a/Mathlib/RingTheory/FractionalIdeal/Operations.lean +++ b/Mathlib/RingTheory/FractionalIdeal/Operations.lean @@ -263,7 +263,7 @@ theorem canonicalEquiv_coeIdeal (I : Ideal R) : canonicalEquiv S P P' I = I := b @[simp] theorem canonicalEquiv_self : canonicalEquiv S P P = RingEquiv.refl _ := by rw [← canonicalEquiv_trans_canonicalEquiv S P P] - convert (canonicalEquiv S P P).symm_trans_self + convert! (canonicalEquiv S P P).symm_trans_self exact (canonicalEquiv_symm S P P).symm end @@ -358,7 +358,7 @@ instance : Nontrivial (FractionalIdeal R₁⁰ K) := theorem ne_zero_of_mul_eq_one (I J : FractionalIdeal R₁⁰ K) (h : I * J = 1) : I ≠ 0 := fun hI => zero_ne_one' (FractionalIdeal R₁⁰ K) (by - convert h + convert! h simp [hI]) variable [IsFractionRing R₁ K] [IsDomain R₁] @@ -382,7 +382,7 @@ theorem _root_.IsFractional.div_of_nonzero {I J : Submodule R₁ K} : apply notMem_zero simpa intro b hb - convert hI _ (hb _ (Submodule.smul_mem _ aJ mem_J)) using 1 + convert! hI _ (hb _ (Submodule.smul_mem _ aJ mem_J)) using 1 rw [← hy', mul_comm b, ← Algebra.smul_def, mul_smul] theorem isFractional_div_of_ne_zero {I J : FractionalIdeal R₁⁰ K} (h : J ≠ 0) : @@ -447,7 +447,7 @@ theorem div_one {I : FractionalIdeal R₁⁰ K} : I / 1 = I := by · simpa using mem_div_iff_forall_mul_mem.mp h 1 ((algebraMap R₁ K).map_one ▸ coe_mem_one R₁⁰ 1) · apply mem_div_iff_forall_mul_mem.mpr rintro y ⟨y', _, rfl⟩ - convert Submodule.smul_mem _ y' h using 1 + convert! Submodule.smul_mem _ y' h using 1 rw [mul_comm, Algebra.linearMap_apply, ← Algebra.smul_def] theorem eq_one_div_of_mul_eq_one_right (I J : FractionalIdeal R₁⁰ K) (h : I * J = 1) : @@ -587,7 +587,7 @@ theorem den_mul_self_eq_num' (I : FractionalIdeal S P) : apply coeToSubmodule_injective dsimp only rw [coe_mul, ← smul_eq_mul, coe_spanSingleton, smul_eq_mul, Submodule.span_singleton_mul] - convert I.den_mul_self_eq_num using 1 + convert! I.den_mul_self_eq_num using 1 ext rw [mem_smul_pointwise_iff_exists, mem_smul_pointwise_iff_exists] simp [smul_eq_mul, Algebra.smul_def, Submonoid.smul_def] @@ -960,12 +960,12 @@ noncomputable def ringEquivOfRingEquiv : left_inv I := by simp only [RingEquiv.symm_symm, val_eq_coe, ← Submodule.map_comp, LinearEquiv.comp_coe, coe_ext_iff, coe_mk] - convert Submodule.map_id _ + convert! Submodule.map_id _ ext; simp [semilinearEquivOfRingEquiv, IsLocalization.map_map] right_inv I := by simp only [RingEquiv.symm_symm, val_eq_coe, ← Submodule.map_comp, LinearEquiv.comp_coe, coe_ext_iff, coe_mk] - convert Submodule.map_id _ + convert! Submodule.map_id _ ext; simp [semilinearEquivOfRingEquiv, IsLocalization.map_map]} lemma ringEquivOfRingEquiv_apply (f : R ≃+* S) (I : FractionalIdeal (nonZeroDivisors R) K) : diff --git a/Mathlib/RingTheory/Frobenius.lean b/Mathlib/RingTheory/Frobenius.lean index 14696d429510d0..e0b10ae2bb310e 100644 --- a/Mathlib/RingTheory/Frobenius.lean +++ b/Mathlib/RingTheory/Frobenius.lean @@ -272,8 +272,9 @@ lemma _root_.isConj_arithFrobAt (H : Q.under R = Q'.under R) : IsConj (arithFrobAt R G Q) (arithFrobAt R G Q') := by obtain ⟨P, hP, h₁, h₂⟩ : ∃ P : Ideal R, P.IsPrime ∧ P = Q.under R ∧ P = Q'.under R := ⟨Q.under R, inferInstance, rfl, H⟩ - convert (exists_primesOver_isConj S G P - ⟨⟨Q, ‹_›, ⟨h₁⟩⟩, ‹Finite (S ⧸ Q)›⟩).choose_spec.2 ⟨Q, ‹_›, ⟨h₁⟩⟩ ⟨Q', ‹_›, ⟨h₂⟩⟩ + convert! + (exists_primesOver_isConj S G P ⟨⟨Q, ‹_›, ⟨h₁⟩⟩, ‹Finite (S ⧸ Q)›⟩).choose_spec.2 ⟨Q, ‹_›, ⟨h₁⟩⟩ + ⟨Q', ‹_›, ⟨h₂⟩⟩ · subst h₁; rfl · subst h₂; rfl diff --git a/Mathlib/RingTheory/GradedAlgebra/Homogeneous/Ideal.lean b/Mathlib/RingTheory/GradedAlgebra/Homogeneous/Ideal.lean index e031f8a0496af7..6bb4bfed265a05 100644 --- a/Mathlib/RingTheory/GradedAlgebra/Homogeneous/Ideal.lean +++ b/Mathlib/RingTheory/GradedAlgebra/Homogeneous/Ideal.lean @@ -202,7 +202,7 @@ theorem Ideal.IsHomogeneous.toIdeal_homogeneousCore_eq_self (h : I.IsHomogeneous theorem HomogeneousIdeal.toIdeal_homogeneousCore_eq_self (I : HomogeneousIdeal 𝒜) : I.toIdeal.homogeneousCore 𝒜 = I := by ext1 - convert Ideal.IsHomogeneous.toIdeal_homogeneousCore_eq_self I.isHomogeneous + convert! Ideal.IsHomogeneous.toIdeal_homogeneousCore_eq_self I.isHomogeneous variable (𝒜 I) @@ -454,7 +454,7 @@ theorem Ideal.homogeneousCore'_eq_sSup : refine (IsLUB.sSup_eq ?_).symm apply IsGreatest.isLUB have coe_mono : Monotone (toIdeal : HomogeneousIdeal 𝒜 → Ideal A) := fun x y => id - convert coe_mono.map_isGreatest (Ideal.homogeneousCore.gc 𝒜).isGreatest_u using 1 + convert! coe_mono.map_isGreatest (Ideal.homogeneousCore.gc 𝒜).isGreatest_u using 1 ext x rw [mem_image, mem_setOf_eq] refine ⟨fun hI => ⟨⟨x, hI.1⟩, ⟨hI.2, rfl⟩⟩, ?_⟩ diff --git a/Mathlib/RingTheory/GradedAlgebra/HomogeneousLocalization.lean b/Mathlib/RingTheory/GradedAlgebra/HomogeneousLocalization.lean index 79c0709e5040d1..3a02d3896d7e81 100644 --- a/Mathlib/RingTheory/GradedAlgebra/HomogeneousLocalization.lean +++ b/Mathlib/RingTheory/GradedAlgebra/HomogeneousLocalization.lean @@ -327,7 +327,7 @@ instance : SMul α (HomogeneousLocalization 𝒜 x) where smul m := Quotient.map' (m • ·) fun c1 c2 (h : Localization.mk _ _ = Localization.mk _ _) => by change Localization.mk _ _ = Localization.mk _ _ simp only [num_smul, den_smul] - convert congr_arg (fun z : at x => m • z) h <;> rw [Localization.smul_mk] + convert! congr_arg (fun z : at x => m • z) h <;> rw [Localization.smul_mk] @[simp] lemma mk_smul (i : NumDenSameDeg 𝒜 x) (m : α) : mk (m • i) = m • mk i := rfl @@ -386,7 +386,7 @@ instance hasPow : Pow (HomogeneousLocalization 𝒜 x) ℕ where (Quotient.map' (· ^ n) fun c1 c2 (h : Localization.mk _ _ = Localization.mk _ _) => by change Localization.mk _ _ = Localization.mk _ _ simp only [num_pow, den_pow] - convert congr_arg (fun z : at x => z ^ n) h <;> rw [Localization.mk_pow] <;> rfl : + convert! congr_arg (fun z : at x => z ^ n) h <;> rw [Localization.mk_pow] <;> rfl : HomogeneousLocalization 𝒜 x → HomogeneousLocalization 𝒜 x) z @@ -399,7 +399,7 @@ instance : Add (HomogeneousLocalization 𝒜 x) where (h' : Localization.mk _ _ = Localization.mk _ _) => by change Localization.mk _ _ = Localization.mk _ _ simp only [num_add, den_add] - convert congr_arg₂ (· + ·) h h' <;> rw [Localization.add_mk] <;> rfl + convert! congr_arg₂ (· + ·) h h' <;> rw [Localization.add_mk] <;> rfl @[simp] lemma mk_add (i j : NumDenSameDeg 𝒜 x) : mk (i + j) = mk i + mk j := rfl @@ -412,7 +412,7 @@ instance : Mul (HomogeneousLocalization 𝒜 x) where (h' : Localization.mk _ _ = Localization.mk _ _) => by change Localization.mk _ _ = Localization.mk _ _ simp only [num_mul, den_mul] - convert congr_arg₂ (· * ·) h h' <;> rw [Localization.mk_mul] <;> rfl + convert! congr_arg₂ (· * ·) h h' <;> rw [Localization.mk_mul] <;> rfl @[simp] lemma mk_mul (i j : NumDenSameDeg 𝒜 x) : mk (i * j) = mk i * mk j := rfl @@ -844,7 +844,7 @@ lemma awayMap_fromZeroRingHom (a) : ext simp only [fromZeroRingHom, RingHom.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk, val_awayMap, val_mk] - convert IsLocalization.lift_eq _ _ + convert! IsLocalization.lift_eq _ _ lemma val_awayMap_mk (n a i hi) : (awayMap 𝒜 hg hx (mk ⟨n, a, ⟨f ^ i, hi⟩, ⟨i, rfl⟩⟩)).val = Localization.mk (a * g ^ i) ⟨x ^ i, (Submonoid.mem_powers_iff _ _).mpr ⟨i, rfl⟩⟩ := by @@ -875,7 +875,7 @@ variable {e d : ℕ} {f : A} (hf : f ∈ 𝒜 d) {g : A} (hg : g ∈ 𝒜 e) /-- The element `t := g ^ d / f ^ e` such that `A_{(fg)} = A_{(f)}[1/t]`. -/ abbrev Away.isLocalizationElem : Away 𝒜 f := - Away.mk 𝒜 hf e (g ^ d) (by convert SetLike.pow_mem_graded d hg using 2; exact mul_comm _ _) + Away.mk 𝒜 hf e (g ^ d) (by convert! SetLike.pow_mem_graded d hg using 2; exact mul_comm _ _) variable {x : A} (hx : x = f * g) @@ -889,8 +889,9 @@ theorem Away.isLocalization_mul (hd : d ≠ 0) : rw [map_pow, RingHom.algebraMap_toAlgebra] let z : Away 𝒜 x := Away.mk 𝒜 (hx ▸ SetLike.mul_mem_graded hf hg) (d + e) (g ^ e * f ^ (2 * e + d)) <| by - convert SetLike.mul_mem_graded (SetLike.pow_mem_graded e hg) - (SetLike.pow_mem_graded (2 * e + d) hf) using 2 + convert! + SetLike.mul_mem_graded (SetLike.pow_mem_graded e hg) + (SetLike.pow_mem_graded (2 * e + d) hf) using 2 ring refine (isUnit_iff_exists_inv.mpr ⟨z, ?_⟩).pow _ ext @@ -904,7 +905,7 @@ theorem Away.isLocalization_mul (hd : d ≠ 0) : rcases d with - | d · contradiction let t : Away 𝒜 f := Away.mk 𝒜 hf (n * (e + 1)) (s * g ^ (n * d)) <| by - convert SetLike.mul_mem_graded hs (SetLike.pow_mem_graded _ hg) using 2; simp; ring + convert! SetLike.mul_mem_graded hs (SetLike.pow_mem_graded _ hg) using 2; simp; ring refine ⟨⟨t, ⟨_, ⟨n, rfl⟩⟩⟩, ?_⟩ ext simp only [RingHom.algebraMap_toAlgebra, map_pow, awayMap_mk, val_mul, val_mk, val_pow, @@ -927,7 +928,7 @@ theorem Away.isLocalization_mul (hd : d ≠ 0) : rcases d with - | d · contradiction subst hx - convert congr(f ^ (e * (k + m + n)) * g ^ (d * (k + m + n)) * $hc) using 1 <;> ring + convert! congr(f ^ (e * (k + m + n)) * g ^ (d * (k + m + n)) * $hc) using 1 <;> ring end isLocalization @@ -973,20 +974,20 @@ theorem Away.span_mk_prod_pow_eq_top {f : A} {d : ι} (hf : f ∈ 𝒜 d) congr refine (DirectSum.decompose_of_mem_same _ ?_).symm exact H ▸ SetLike.prod_pow_mem_graded _ _ _ _ fun i _ ↦ hxd i - · convert zero_mem (Submodule.span (𝒜 0) _) + · convert! zero_mem (Submodule.span (𝒜 0) _) ext have : (DirectSum.decompose 𝒜 (∏ i : ι', v i ^ ai i) n).1 = 0 := by refine DirectSum.decompose_of_mem_ne _ ?_ H exact SetLike.prod_pow_mem_graded _ _ _ _ fun i _ ↦ hxd i simp [this, Localization.mk_zero] | zero => - convert zero_mem (Submodule.span (𝒜 0) _) + convert! zero_mem (Submodule.span (𝒜 0) _) ext; simp [Localization.mk_zero] | add s t hs ht hs' ht' => - convert add_mem hs' ht' + convert! add_mem hs' ht' ext; simp [← Localization.add_mk_self] | smul r x hx hx' => - convert Submodule.smul_mem _ r hx' + convert! Submodule.smul_mem _ r hx' ext simp [Algebra.smul_def, algebraMap_eq, fromZeroRingHom, Localization.mk_mul, -decompose_mul, coe_decompose_mul_of_left_mem_zero 𝒜 r.2] @@ -1102,14 +1103,14 @@ lemma Away.finiteType (f : A) (d : ℕ) (hf : f ∈ 𝒜 d) : rintro _ ⟨a, ai, hai, hai', rfl⟩ obtain rfl : ai = 0 := funext <| by simpa [hd, hdx] using hai simp only [Finset.univ_eq_attach, Pi.zero_apply, pow_zero, Finset.prod_const_one, mem_coe] - convert pow_mem (Algebra.self_mem_adjoin_singleton (𝒜 0) f') a using 1 + convert! pow_mem (Algebra.self_mem_adjoin_singleton (𝒜 0) f') a using 1 ext simp [f', Localization.mk_pow] refine ⟨_, ?_, le_rfl⟩ let b := ∑ i, dx i let s' : Set ((Fin (b + 1)) × (s → Fin (d + 1))) := { ai | ∑ i, (ai.2 i).1 * dx i = ai.1 * d } let F : s' → Away 𝒜 f := fun ai ↦ Away.mk 𝒜 hf ai.1.1.1 (∏ i, i ^ (ai.1.2 i).1) - (by convert SetLike.prod_pow_mem_graded _ _ _ _ fun i _ ↦ hxd i; exact ai.2.symm) + (by convert! SetLike.prod_pow_mem_graded _ _ _ _ fun i _ ↦ hxd i; exact ai.2.symm) apply (Set.finite_range F).subset rintro _ ⟨a, ai, hai, hai', rfl⟩ refine ⟨⟨⟨⟨a, ?_⟩, fun i ↦ ⟨ai i, (hai' i).trans_lt d.lt_succ_self⟩⟩, hai⟩, rfl⟩ diff --git a/Mathlib/RingTheory/GradedAlgebra/Radical.lean b/Mathlib/RingTheory/GradedAlgebra/Radical.lean index 59f7e908baf1fd..bbdea52c8b271b 100644 --- a/Mathlib/RingTheory/GradedAlgebra/Radical.lean +++ b/Mathlib/RingTheory/GradedAlgebra/Radical.lean @@ -104,7 +104,7 @@ theorem Ideal.IsHomogeneous.isPrime_of_homogeneous_mem_or_mem {I : Ideal A} (hI simp only [antidiag, mem_erase, Prod.mk_inj, Ne, mem_filter, mem_product] at H rcases H with ⟨H₁, ⟨H₂, H₃⟩, H₄⟩ have max_lt : max₁ < i ∨ max₂ < j := by - convert le_or_lt_of_add_le_add H₄.ge using 1 + convert! le_or_lt_of_add_le_add H₄.ge using 1 rw [Ne.le_iff_lt] rintro rfl cases H₁ ⟨rfl, add_left_cancel H₄⟩ diff --git a/Mathlib/RingTheory/HahnSeries/Addition.lean b/Mathlib/RingTheory/HahnSeries/Addition.lean index 0bc3b8db2b6d1e..3980046d3b6e78 100644 --- a/Mathlib/RingTheory/HahnSeries/Addition.lean +++ b/Mathlib/RingTheory/HahnSeries/Addition.lean @@ -135,8 +135,8 @@ and the additive opposite of Hahn series over `Γ` with coefficients `R`. -/ @[simps -isSimp] def addOppositeEquiv : Rᵃᵒᵖ⟦Γ⟧ ≃+ R⟦Γ⟧ᵃᵒᵖ where - toFun x := .op ⟨fun a ↦ (x.coeff a).unop, by convert x.isPWO_support; ext; simp⟩ - invFun x := ⟨fun a ↦ .op (x.unop.coeff a), by convert x.unop.isPWO_support; ext; simp⟩ + toFun x := .op ⟨fun a ↦ (x.coeff a).unop, by convert! x.isPWO_support; ext; simp⟩ + invFun x := ⟨fun a ↦ .op (x.unop.coeff a), by convert! x.unop.isPWO_support; ext; simp⟩ left_inv x := by simp right_inv x := by apply AddOpposite.unop_injective diff --git a/Mathlib/RingTheory/HahnSeries/Lex.lean b/Mathlib/RingTheory/HahnSeries/Lex.lean index 24fc842b4477a6..d7ed4861f1fcb7 100644 --- a/Mathlib/RingTheory/HahnSeries/Lex.lean +++ b/Mathlib/RingTheory/HahnSeries/Lex.lean @@ -201,7 +201,7 @@ theorem archimedeanClassMk_le_archimedeanClassMk_iff_of_orderTop_ofLex {x y : Le · -- impossible case: `x` and `y` differ before their leading coefficients have hjlt' : j < (ofLex |y|).orderTop := h'.symm ▸ hjlt simp [coeff_eq_zero_of_lt_orderTop hjlt, coeff_eq_zero_of_lt_orderTop hjlt'] at hi - · convert hi.le <;> exact (WithTop.untop_eq_iff _).mpr hjeq.symm + · convert! hi.le <;> exact (WithTop.untop_eq_iff _).mpr hjeq.symm · exact (hj _ ((WithTop.untop_lt_iff _).mpr hjgt)).le · -- `mk x.leadingCoeff ≤ mk y.leadingCoeff → mk x ≤ mk y` intro ⟨n, hn⟩ @@ -221,7 +221,7 @@ theorem archimedeanClassMk_le_archimedeanClassMk_iff_of_orderTop_ofLex {x y : Le simp_rw [← leadingCoeff_abs] at this rw [leadingCoeff_of_ne_zero (by simpa using hy), leadingCoeff_of_ne_zero (by simpa using hx)] at this - convert this using 3 <;> simp [h] + convert! this using 3 <;> simp [h] refine lt_of_le_of_lt hn <| nsmul_lt_nsmul_left ?_ (by simp) rwa [abs_pos, leadingCoeff_ne_zero] @@ -389,7 +389,7 @@ instance [IsOrderedRing R] [NoZeroDivisors R] : IsOrderedRing (Lex R⟦Γ⟧) wh · rwa [leadingCoeff_nonneg_iff] · simpa -instance [IsDomain R] [IsStrictOrderedRing R] : IsStrictOrderedRing (Lex R⟦Γ⟧) where +instance [IsStrictOrderedRing R] : IsStrictOrderedRing (Lex R⟦Γ⟧) where end OrderedRing diff --git a/Mathlib/RingTheory/HahnSeries/PowerSeries.lean b/Mathlib/RingTheory/HahnSeries/PowerSeries.lean index 7c20a709677b15..98a1946698c521 100644 --- a/Mathlib/RingTheory/HahnSeries/PowerSeries.lean +++ b/Mathlib/RingTheory/HahnSeries/PowerSeries.lean @@ -117,7 +117,7 @@ theorem ofPowerSeries_C (r : R) : ofPowerSeries Γ R (PowerSeries.C r) = HahnSer coeff_single] split_ifs with hn · subst hn - convert embDomain_coeff (a := 0) <;> simp + convert! embDomain_coeff (a := 0) <;> simp · rw [embDomain_notin_image_support] simp only [not_exists, Set.mem_image, toPowerSeries_symm_apply_coeff, mem_support, PowerSeries.coeff_C] @@ -130,7 +130,7 @@ theorem ofPowerSeries_X : ofPowerSeries Γ R PowerSeries.X = single 1 1 := by simp only [coeff_single, ofPowerSeries_apply] split_ifs with hn · rw [hn] - convert embDomain_coeff (a := 1) <;> simp + convert! embDomain_coeff (a := 1) <;> simp · rw [embDomain_notin_image_support] simp only [not_exists, Set.mem_image, toPowerSeries_symm_apply_coeff, mem_support, PowerSeries.coeff_X] diff --git a/Mathlib/RingTheory/Henselian.lean b/Mathlib/RingTheory/Henselian.lean index dd077f36e3b45a..bbafc12bf78162 100644 --- a/Mathlib/RingTheory/Henselian.lean +++ b/Mathlib/RingTheory/Henselian.lean @@ -200,7 +200,7 @@ instance (priority := 100) IsAdicComplete.henselianRing (R : Type*) [CommRing R] intro n haveI := isLocalHom_of_le_jacobson_bot I (IsAdicComplete.le_jacobson_bot I) apply IsUnit.of_map (Ideal.Quotient.mk I) - convert h₂ using 1 + convert! h₂ using 1 exact SModEq.def.mp ((hc_mod n).eval _) have hfcI : ∀ n, f.eval (c n) ∈ I ^ (n + 1) := by intro n diff --git a/Mathlib/RingTheory/HopfAlgebra/TensorProduct.lean b/Mathlib/RingTheory/HopfAlgebra/TensorProduct.lean index 62706afae60a13..5f9d1d798b714d 100644 --- a/Mathlib/RingTheory/HopfAlgebra/TensorProduct.lean +++ b/Mathlib/RingTheory/HopfAlgebra/TensorProduct.lean @@ -49,7 +49,7 @@ instance : HopfAlgebra S (B ⊗[R] A) where antipode := AlgebraTensorModule.map (HopfAlgebra.antipode S) (HopfAlgebra.antipode R) mul_antipode_rTensor_comul := by ext x y - convert congr($(mul_antipode_rTensor_comul_apply (R := S) x) ⊗ₜ[R] + convert! congr($(mul_antipode_rTensor_comul_apply (R := S) x) ⊗ₜ[R] $(mul_antipode_rTensor_comul_apply (R := R) y)) using 1 · dsimp hopf_tensor_induction comul (R := S) x with x₁ x₂ @@ -59,7 +59,7 @@ instance : HopfAlgebra S (B ⊗[R] A) where simp [Algebra.algebraMap_eq_smul_one, smul_tmul'] mul_antipode_lTensor_comul := by ext x y - convert congr($(mul_antipode_lTensor_comul_apply (R := S) x) ⊗ₜ[R] + convert! congr($(mul_antipode_lTensor_comul_apply (R := S) x) ⊗ₜ[R] $(mul_antipode_lTensor_comul_apply (R := R) y)) using 1 · dsimp [Algebra.TensorProduct.one_def] hopf_tensor_induction comul (R := S) x with x₁ x₂ diff --git a/Mathlib/RingTheory/Ideal/AssociatedPrime/Finiteness.lean b/Mathlib/RingTheory/Ideal/AssociatedPrime/Finiteness.lean index 1aa49162e112ce..6ac47fae8b3425 100644 --- a/Mathlib/RingTheory/Ideal/AssociatedPrime/Finiteness.lean +++ b/Mathlib/RingTheory/Ideal/AssociatedPrime/Finiteness.lean @@ -63,7 +63,7 @@ theorem Submodule.isQuotientEquivQuotientPrime_iff {N₁ N₂ : Submodule A M} : · obtain ⟨⟨x, hx⟩, hx'⟩ := Submodule.mkQ_surjective _ (e.symm 1) have hx'' : N₁.mkQ x = f (e.symm 1) := by simp [f, ← hx'] refine ⟨x, ?_, ?_⟩ - · convert p.2 + · convert! p.2 ext r simp [hx'', ← map_smul, Algebra.smul_def, show f _ = 0 ↔ _ from congr(_ ∈ $hf₁), Ideal.Quotient.eq_zero_iff_mem] diff --git a/Mathlib/RingTheory/Ideal/Cotangent.lean b/Mathlib/RingTheory/Ideal/Cotangent.lean index dd460bf7ed8760..6083d133137ba5 100644 --- a/Mathlib/RingTheory/Ideal/Cotangent.lean +++ b/Mathlib/RingTheory/Ideal/Cotangent.lean @@ -213,8 +213,9 @@ def mapCotangent (I₁ : Ideal A) (I₂ : Ideal B) (f : A →ₐ[R] B) (h : I₁ refine Submodule.smul_induction_on hx ?_ (fun _ _ ↦ add_mem) rintro a ha ⟨b, hb⟩ - simp only [SetLike.mk_smul_mk, smul_eq_mul, Submodule.mem_comap, Submodule.restrictScalars_mem] - convert (Submodule.smul_mem_smul (M := I₂) (r := f a) - (n := ⟨f b, h hb⟩) (h ha) (Submodule.mem_top)) using 1 + convert! + (Submodule.smul_mem_smul (M := I₂) (r := f a) (n := ⟨f b, h hb⟩) (h ha) + (Submodule.mem_top)) using 1 ext exact map_mul f a b @@ -389,5 +390,5 @@ lemma Ideal.mapCotangent_ker_of_surjective (surj : Function.Surjective (algebraM · rw [Submodule.map_le_iff_le_comap, ← LinearMap.ker_comp] intro x hx simp only [LinearMap.mem_ker, LinearMap.comp_apply, Ideal.mapCotangent_toCotangent] - convert map_zero I.toCotangent + convert! map_zero I.toCotangent exact (Ideal.mem_inf.mp hx).1 diff --git a/Mathlib/RingTheory/Ideal/GoingUp.lean b/Mathlib/RingTheory/Ideal/GoingUp.lean index f4a2a90dffae96..3d31f778aeae30 100644 --- a/Mathlib/RingTheory/Ideal/GoingUp.lean +++ b/Mathlib/RingTheory/Ideal/GoingUp.lean @@ -139,7 +139,7 @@ theorem exists_coeff_mem_comap_sdiff_comap_of_root_mem_sdiff [IsPrime I] (hIJ : (p.map (Ideal.Quotient.mk (I.comap f))).eval₂ (Quotient.lift (I.comap f) _ quotient_f) (Ideal.Quotient.mk I r) = 0 := by - convert Quotient.eq_zero_iff_mem.mpr hpI + convert! Quotient.eq_zero_iff_mem.mpr hpI exact _root_.trans (eval₂_map _ _ _) (hom_eval₂ p f (Ideal.Quotient.mk I) r).symm obtain ⟨i, ne_zero, mem⟩ := exists_coeff_ne_zero_mem_comap_of_root_mem rbar_ne_zero rbar_mem_J p_ne_zero rbar_root @@ -162,7 +162,7 @@ theorem comap_lt_comap_of_integral_mem_sdiff [Algebra R S] [hI : I.IsPrime] (hIJ I.comap (algebraMap R S) < J.comap (algebraMap R S) := by obtain ⟨p, p_monic, hpx⟩ := integral refine comap_lt_comap_of_root_mem_sdiff hIJ mem (map_monic_ne_zero p_monic) ?_ - convert I.zero_mem + convert! I.zero_mem theorem comap_ne_bot_of_root_mem [IsDomain S] {r : S} (r_ne_zero : r ≠ 0) (hr : r ∈ I) {p : R[X]} (p_ne_zero : p ≠ 0) (hp : p.eval₂ f r = 0) : I.comap f ≠ ⊥ := fun h => @@ -288,7 +288,7 @@ theorem exists_ideal_over_prime_of_isIntegral_of_isDomain [Algebra.IsIntegral R have Qₚ_max : IsMaximal (comap _ Qₚ) := isMaximal_comap_of_isIntegral_of_isMaximal (R := Rₚ) (S := Sₚ) Qₚ refine ⟨comap (algebraMap S Sₚ) Qₚ, ⟨comap_isPrime _ Qₚ, ?_⟩⟩ - convert Localization.AtPrime.under_maximalIdeal (I := P) + convert! Localization.AtPrime.under_maximalIdeal (I := P) rw [comap_comap, ← IsLocalRing.eq_maximalIdeal Qₚ_max, ← IsLocalization.map_comp (P := S) (Q := Sₚ) (g := algebraMap R S) (M := P.primeCompl) (T := Algebra.algebraMapSubmonoid S P.primeCompl) (S := Rₚ) diff --git a/Mathlib/RingTheory/Ideal/Height.lean b/Mathlib/RingTheory/Ideal/Height.lean index 15d71475c438d0..457a89a3fc05a2 100644 --- a/Mathlib/RingTheory/Ideal/Height.lean +++ b/Mathlib/RingTheory/Ideal/Height.lean @@ -17,16 +17,12 @@ In this file, we define the height of a prime ideal and the height of an ideal. ## Main definitions -* `Ideal.primeHeight` : The height of a prime ideal $\mathfrak{p}$. We define it as the supremum of - the lengths of strictly decreasing chains of prime ideals below it. This definition is implemented - via `Order.height`. - * `Ideal.height` : The height of an ideal. We defined it as the infimum of the `primeHeight` of the minimal prime ideals of I. -/ -@[expose] public section +public section variable {R : Type*} [CommRing R] (I : Ideal R) @@ -34,7 +30,7 @@ open Ideal /-- The height of a prime ideal is defined as the supremum of the lengths of strictly decreasing chains of prime ideals below it. -/ -noncomputable def Ideal.primeHeight [hI : I.IsPrime] : ℕ∞ := +private noncomputable def Ideal.primeHeight [hI : I.IsPrime] : ℕ∞ := Order.height (⟨I, hI⟩ : PrimeSpectrum R) /-- The height of an ideal is defined as the infimum of the heights of its minimal prime ideals. -/ @@ -42,10 +38,17 @@ noncomputable def Ideal.height : ℕ∞ := ⨅ J ∈ I.minimalPrimes, @Ideal.primeHeight _ _ J ‹J ∈ I.minimalPrimes›.isPrime /-- For a prime ideal, its height equals its prime height. -/ -lemma Ideal.height_eq_primeHeight [I.IsPrime] : I.height = I.primeHeight := by - unfold height primeHeight - simp_rw [Ideal.minimalPrimes_eq_subsingleton_self] - simp +private lemma Ideal.height_eq_primeHeight [I.IsPrime] : I.height = I.primeHeight := by + simp [height, primeHeight, Ideal.minimalPrimes_eq_subsingleton_self] + +lemma PrimeSpectrum.height_eq_orderHeight (p : PrimeSpectrum R) : + p.asIdeal.height = Order.height p := + p.asIdeal.height_eq_primeHeight + +lemma Ideal.height_eq_inf_minimalPrimes : I.height = ⨅ J ∈ I.minimalPrimes, J.height := by + apply iInf_congr (fun p ↦ iInf_congr fun hp ↦ ?_) + have := hp.isPrime + exact (Ideal.height_eq_primeHeight _).symm /-- An ideal has finite height if it is either the unit ideal or its height is finite. We include the unit ideal in order to have the instance `IsNoetherianRing R → FiniteHeight I`. -/ @@ -65,12 +68,22 @@ lemma Ideal.height_lt_top {I : Ideal R} (hI : I ≠ ⊤) [I.FiniteHeight] : I.height < ⊤ := (Ideal.height_ne_top hI).lt_top -lemma Ideal.primeHeight_ne_top (I : Ideal R) [I.FiniteHeight] [I.IsPrime] : +lemma Ideal.height_ne_top_of_isPrime {I : Ideal R} [I.FiniteHeight] [I.IsPrime] : + I.height ≠ ⊤ := + Ideal.height_ne_top ‹I.IsPrime›.ne_top + +@[deprecated "Use `Ideal.height_ne_top_of_isPrime` instead." (since := "2026-04-04")] +private lemma Ideal.primeHeight_ne_top (I : Ideal R) [I.FiniteHeight] [I.IsPrime] : I.primeHeight ≠ ⊤ := by rw [← I.height_eq_primeHeight] exact Ideal.height_ne_top ‹I.IsPrime›.ne_top -lemma Ideal.primeHeight_lt_top (I : Ideal R) [I.FiniteHeight] [I.IsPrime] : +lemma Ideal.height_lt_top_of_isPrime {I : Ideal R} [I.FiniteHeight] [I.IsPrime] : + I.height < ⊤ := + Ideal.height_lt_top ‹I.IsPrime›.ne_top + +@[deprecated "Use `Ideal.height_lt_top_of_isPrime` instead." (since := "2026-04-04")] +private lemma Ideal.primeHeight_lt_top (I : Ideal R) [I.FiniteHeight] [I.IsPrime] : I.primeHeight < ⊤ := by rw [← I.height_eq_primeHeight] exact Ideal.height_lt_top ‹I.IsPrime›.ne_top @@ -85,69 +98,88 @@ lemma Ideal.exists_ltSeries_length_eq_height (p : Ideal R) [p.IsPrime] [p.Finite rw [hn] exact ⟨l, last, by rw [len, WithTop.some_eq_coe, ENat.some_eq_coe]⟩ -@[gcongr] -lemma Ideal.primeHeight_mono {I J : Ideal R} [I.IsPrime] [J.IsPrime] (h : I ≤ J) : - I.primeHeight ≤ J.primeHeight := by - unfold primeHeight +private lemma Ideal.height_mono_of_isPrime {I J : Ideal R} [I.IsPrime] [J.IsPrime] (h : I ≤ J) : + I.height ≤ J.height := by + simp only [Ideal.height_eq_primeHeight, Ideal.primeHeight] gcongr exact h -lemma Ideal.primeHeight_add_one_le_of_lt {I J : Ideal R} [I.IsPrime] [J.IsPrime] (h : I < J) : - I.primeHeight + 1 ≤ J.primeHeight := by - unfold primeHeight +@[deprecated "Use `Ideal.height_mono_of_isPrime` instead." (since := "2026-04-04")] +private lemma Ideal.primeHeight_mono {I J : Ideal R} [I.IsPrime] [J.IsPrime] (h : I ≤ J) : + I.primeHeight ≤ J.primeHeight := by + simpa [Ideal.height_eq_primeHeight] using Ideal.height_mono_of_isPrime h + +lemma Ideal.height_add_one_le_of_lt_of_isPrime {I J : Ideal R} [I.IsPrime] [J.IsPrime] (h : I < J) : + I.height + 1 ≤ J.height := by + simp only [Ideal.height_eq_primeHeight, Ideal.primeHeight] exact Order.height_add_one_le h +@[deprecated "Use `Ideal.height_add_one_le_of_lt_of_isPrime` instead." (since := "2026-04-04")] +private lemma Ideal.primeHeight_add_one_le_of_lt {I J : Ideal R} [I.IsPrime] [J.IsPrime] + (h : I < J) : I.primeHeight + 1 ≤ J.primeHeight := by + simpa [Ideal.height_eq_primeHeight] using Ideal.height_add_one_le_of_lt_of_isPrime h + @[simp] theorem Ideal.height_top : (⊤ : Ideal R).height = ⊤ := by simp [height, minimalPrimes_top] -@[gcongr] -lemma Ideal.primeHeight_strict_mono {I J : Ideal R} [I.IsPrime] [J.IsPrime] - (h : I < J) [J.FiniteHeight] : - I.primeHeight < J.primeHeight := by - rw [primeHeight] - have : I.FiniteHeight := by - rw [Ideal.finiteHeight_iff, ← lt_top_iff_ne_top, Ideal.height_eq_primeHeight] - right - exact lt_of_le_of_lt (Ideal.primeHeight_mono h.le) (Ideal.primeHeight_lt_top J) - exact Order.height_strictMono h (Ideal.primeHeight_lt_top _) - @[gcongr] theorem Ideal.height_mono {I J : Ideal R} (h : I ≤ J) : I.height ≤ J.height := by - simp only [height] + simp only [I.height_eq_inf_minimalPrimes, J.height_eq_inf_minimalPrimes] refine le_iInf₂ (fun p hp ↦ ?_) have := hp.isPrime obtain ⟨q, hq, e⟩ := Ideal.exists_minimalPrimes_le (h.trans hp.le) - haveI := hq.isPrime - exact (iInf₂_le q hq).trans (Ideal.primeHeight_mono e) + have := hq.isPrime + exact (iInf₂_le q hq).trans (Ideal.height_mono_of_isPrime e) @[gcongr] -lemma Ideal.height_strict_mono_of_is_prime {I J : Ideal R} [I.IsPrime] +lemma Ideal.height_strict_mono_of_isPrime {I J : Ideal R} [I.IsPrime] (h : I < J) [I.FiniteHeight] : I.height < J.height := by - rw [Ideal.height_eq_primeHeight I] by_cases hJ : J = ⊤ - · rw [hJ, height_top] - exact I.primeHeight_lt_top - · rw [← ENat.add_one_le_iff I.primeHeight_ne_top, Ideal.height] + · grw [hJ, height_top] + exact I.height_lt_top IsPrime.ne_top' + · rw [← ENat.add_one_le_iff (I.height_ne_top IsPrime.ne_top'), J.height_eq_inf_minimalPrimes] refine le_iInf₂ (fun K hK ↦ ?_) have := hK.isPrime - exact Ideal.primeHeight_add_one_le_of_lt (lt_of_lt_of_le h hK.le) + have : I < K := lt_of_lt_of_le h hK.le + exact Ideal.height_add_one_le_of_lt_of_isPrime this + +lemma Ideal.height_strict_mono_of_isPrime_of_isPrime {I J : Ideal R} [I.IsPrime] [J.IsPrime] + (h : I < J) [J.FiniteHeight] : I.height < J.height := by + have : I.FiniteHeight := I.finiteHeight_iff.mpr + (Or.inr (lt_of_le_of_lt (Ideal.height_mono h.le) (J.height_lt_top IsPrime.ne_top')).ne) + exact Ideal.height_strict_mono_of_isPrime h + +@[deprecated (since := "2026-04-02")] +alias Ideal.height_strict_mono_of_isPrime_of_is_prime := + Ideal.height_strict_mono_of_isPrime_of_isPrime + +@[deprecated "Use `Ideal.height_strict_mono_of_isPrime_of_isPrime` instead." + (since := "2026-04-02")] +private lemma Ideal.primeHeight_strict_mono {I J : Ideal R} [I.IsPrime] [J.IsPrime] (h : I < J) + [J.FiniteHeight] : I.primeHeight < J.primeHeight := by + simpa [← Ideal.height_eq_primeHeight] using Ideal.height_strict_mono_of_isPrime_of_isPrime h + +lemma Ideal.height_le_ringKrullDim_of_isPrime {I : Ideal R} [I.IsPrime] : + I.height ≤ ringKrullDim R := by + rw [Ideal.height_eq_primeHeight, Ideal.primeHeight] + exact Order.height_le_krullDim _ /-- A prime ideal of finite height is equal to any ideal that contains it with no greater height. -/ lemma Ideal.eq_of_le_of_height_le [I.IsPrime] [I.FiniteHeight] {J : Ideal R} (h : I ≤ J) (h_height : J.height ≤ I.height) : I = J := - eq_of_le_of_not_lt h fun hlt => not_le.mpr (Ideal.height_strict_mono_of_is_prime hlt) h_height + eq_of_le_of_not_lt h fun hlt => not_le.mpr (Ideal.height_strict_mono_of_isPrime hlt) h_height -lemma Ideal.primeHeight_le_ringKrullDim {I : Ideal R} [I.IsPrime] : +@[deprecated "Use `Ideal.height_le_ringKrullDim_of_isPrime` instead." (since := "2026-04-04")] +private lemma Ideal.primeHeight_le_ringKrullDim {I : Ideal R} [I.IsPrime] : I.primeHeight ≤ ringKrullDim R := Order.height_le_krullDim _ lemma Ideal.height_le_ringKrullDim_of_ne_top {I : Ideal R} (h : I ≠ ⊤) : I.height ≤ ringKrullDim R := by - rw [Ideal.height] obtain ⟨P, hP⟩ : Nonempty (I.minimalPrimes) := Ideal.nonempty_minimalPrimes h + rw [I.height_eq_inf_minimalPrimes] have := hP.isPrime - refine le_trans ?_ (Ideal.primeHeight_le_ringKrullDim (I := P)) - simpa using iInf₂_le _ hP + refine (WithBot.coe_le_coe.mpr (iInf₂_le _ hP)).trans P.height_le_ringKrullDim_of_isPrime /-- If `R` has finite Krull dimension, there exists a maximal ideal `m` with `ht m = dim R`. -/ lemma Ideal.exists_isMaximal_height [FiniteRingKrullDim R] : @@ -164,48 +196,46 @@ lemma Ideal.exists_isMaximal_height [FiniteRingKrullDim R] : instance (priority := 900) Ideal.finiteHeight_of_finiteRingKrullDim {I : Ideal R} [FiniteRingKrullDim R] : I.FiniteHeight := by rw [finiteHeight_iff, or_iff_not_imp_left, ← lt_top_iff_ne_top, ← WithBot.coe_lt_coe] - intro h - have h1 := ringKrullDim_lt_top (R := R) - have h2 := Ideal.height_le_ringKrullDim_of_ne_top h - exact lt_of_le_of_lt h2 h1 + exact fun h ↦ lt_of_le_of_lt (Ideal.height_le_ringKrullDim_of_ne_top h) ringKrullDim_lt_top /-- If J has finite height and I ≤ J, then I has finite height -/ lemma Ideal.finiteHeight_of_le {I J : Ideal R} (e : I ≤ J) (hJ : J ≠ ⊤) [FiniteHeight J] : FiniteHeight I where - eq_top_or_height_ne_top := Or.inr <| by - rw [← lt_top_iff_ne_top] - exact (height_mono e).trans_lt (height_lt_top hJ) + eq_top_or_height_ne_top := Or.inr <| + lt_top_iff_ne_top.mp ((height_mono e).trans_lt (height_lt_top hJ)) /-- If J is a prime ideal containing I, and its height is less than or equal to the height of I, then J is a minimal prime over I -/ lemma Ideal.mem_minimalPrimes_of_height_eq {I J : Ideal R} (e : I ≤ J) [J.IsPrime] [FiniteHeight J] (e' : J.height ≤ I.height) : J ∈ I.minimalPrimes := by obtain ⟨p, h₁, h₂⟩ := Ideal.exists_minimalPrimes_le e - convert h₁ + convert! h₁ refine (eq_of_le_of_not_lt h₂ fun h₃ ↦ ?_).symm have := h₁.isPrime have := finiteHeight_of_le h₂ IsPrime.ne_top' - exact lt_irrefl _ ((height_strict_mono_of_is_prime h₃).trans_le (e'.trans <| height_mono h₁.le)) + exact lt_irrefl _ ((height_strict_mono_of_isPrime h₃).trans_le + (e'.trans <| height_mono h₁.le)) /-- A prime ideal has height zero if and only if it is minimal -/ -lemma Ideal.primeHeight_eq_zero_iff {I : Ideal R} [I.IsPrime] : +lemma Ideal.height_eq_zero_iff {I : Ideal R} [I.IsPrime] : height I = 0 ↔ I ∈ minimalPrimes R := by + rw [Ideal.height_eq_primeHeight, Ideal.primeHeight, Order.height_eq_zero, + minimalPrimes_eq_minimals] + refine ⟨fun h ↦ ⟨‹_›, ?_⟩, fun ⟨hI, hI'⟩ b hb ↦ hI' b.isPrime hb⟩ + by_contra! ⟨P, ⟨hP₁, ⟨hP₂, hP₃⟩⟩⟩ + exact hP₃ (h (b := ⟨P, hP₁⟩) hP₂) + +@[deprecated "Use `Ideal.height_eq_zero_iff` instead." (since := "2026-04-02")] +private lemma Ideal.primeHeight_eq_zero_iff {I : Ideal R} [I.IsPrime] : primeHeight I = 0 ↔ I ∈ minimalPrimes R := by - rw [Ideal.primeHeight, Order.height_eq_zero, minimalPrimes_eq_minimals] - constructor - · intro h - refine ⟨inferInstance, ?_⟩ - by_contra! ⟨P, ⟨hP₁, ⟨hP₂, hP₃⟩⟩⟩ - exact hP₃ (h (b := ⟨P, hP₁⟩) hP₂) - · rintro ⟨hI, hI'⟩ b hb - exact hI' (y := b.asIdeal) b.isPrime hb + rw [← Ideal.height_eq_primeHeight, Ideal.height_eq_zero_iff] /-- If `x` is a non-zero-divisor, then `span {x}` has height at least 1. -/ lemma Ideal.one_le_height_span_singleton_of_mem_nonZeroDivisors {x : R} (hx : x ∈ nonZeroDivisors R) : 1 ≤ (span {x}).height := by - dsimp [Ideal.height] + rw [Ideal.height_eq_inf_minimalPrimes] refine le_iInf₂ fun q hq => ?_ have : q.IsPrime := hq.isPrime - rw [ENat.one_le_iff_ne_zero, Ne, primeHeight_eq_zero_iff] + rw [Order.one_le_iff_ne_zero, Ne, height_eq_zero_iff] intro hmin exact absurd hx <| notMem_nonZeroDivisors_of_mem_mem_minimalPrimes (hq.1.2 <| Ideal.mem_span_singleton.mpr <| dvd_refl x) hmin @@ -213,49 +243,58 @@ lemma Ideal.one_le_height_span_singleton_of_mem_nonZeroDivisors @[simp] lemma Ideal.height_bot [Nontrivial R] : (⊥ : Ideal R).height = 0 := by obtain ⟨p, hp⟩ := Ideal.nonempty_minimalPrimes (R := R) (I := ⊥) top_ne_bot.symm - simp only [Ideal.height, ENat.iInf_eq_zero] - exact ⟨p, hp, haveI := hp.isPrime; primeHeight_eq_zero_iff.mpr hp⟩ + rw [Ideal.height_eq_inf_minimalPrimes] + simp only [ENat.iInf_eq_zero] + refine ⟨p, hp, haveI := hp.isPrime; height_eq_zero_iff.mpr hp⟩ /-- In a trivial commutative ring, the height of any ideal is `∞`. -/ @[simp, nontriviality] lemma Ideal.height_of_subsingleton [Subsingleton R] : I.height = ⊤ := by rw [Subsingleton.elim I ⊤, Ideal.height_top] -theorem Ideal.isMaximal_of_primeHeight_eq_ringKrullDim {I : Ideal R} [I.IsPrime] - [FiniteRingKrullDim R] (e : I.primeHeight = ringKrullDim R) : I.IsMaximal := by - have h : I ≠ ⊤ := by - intro h - simp only [h, ← Ideal.height_eq_primeHeight, Ideal.height_top, WithBot.coe_top] at e - exact ringKrullDim_ne_top e.symm +theorem Ideal.isMaximal_of_height_eq_ringKrullDim {I : Ideal R} [I.IsPrime] + [FiniteRingKrullDim R] (e : I.height = ringKrullDim R) : I.IsMaximal := by + have h : I ≠ ⊤ := Ideal.IsPrime.ne_top' obtain ⟨M, hM, hM'⟩ := Ideal.exists_le_maximal I h rcases lt_or_eq_of_le hM' with (hM' | hM') - · have h1 := Ideal.primeHeight_strict_mono hM' - have h2 := e ▸ M.primeHeight_le_ringKrullDim + · have h1 := Ideal.height_strict_mono_of_isPrime hM' + have h2 := e ▸ M.height_le_ringKrullDim_of_ne_top hM.ne_top simp [← not_lt, h1] at h2 · exact hM' ▸ hM -/-- The prime height of the maximal ideal equals the Krull dimension in a local ring -/ -@[simp] -theorem IsLocalRing.maximalIdeal_primeHeight_eq_ringKrullDim [IsLocalRing R] : - (IsLocalRing.maximalIdeal R).primeHeight = ringKrullDim R := by - rw [ringKrullDim, Ideal.primeHeight, ← Order.height_top_eq_krullDim] - rfl +@[deprecated "Use `Ideal.isMaximal_of_height_eq_ringKrullDim` instead." (since := "2026-04-02")] +private theorem Ideal.isMaximal_of_primeHeight_eq_ringKrullDim {I : Ideal R} [I.IsPrime] + [FiniteRingKrullDim R] (e : I.primeHeight = ringKrullDim R) : I.IsMaximal := + Ideal.isMaximal_of_height_eq_ringKrullDim (by simpa [Ideal.height_eq_primeHeight]) /-- The height of the maximal ideal equals the Krull dimension in a local ring. -/ @[simp] theorem IsLocalRing.maximalIdeal_height_eq_ringKrullDim [IsLocalRing R] : (IsLocalRing.maximalIdeal R).height = ringKrullDim R := by - rw [Ideal.height_eq_primeHeight, IsLocalRing.maximalIdeal_primeHeight_eq_ringKrullDim] + rw [Ideal.height_eq_primeHeight, Ideal.primeHeight] + exact Order.height_top_eq_krullDim + +@[deprecated "Use `IsLocalRing.maximalIdeal_height_eq_ringKrullDim` instead." + (since := "2026-04-04")] +private theorem IsLocalRing.maximalIdeal_primeHeight_eq_ringKrullDim [IsLocalRing R] : + (IsLocalRing.maximalIdeal R).primeHeight = ringKrullDim R := by + simp [← Ideal.height_eq_primeHeight] /-- For a local ring with finite Krull dimension, a prime ideal has height equal to the Krull dimension if and only if it is the maximal ideal. -/ -theorem Ideal.primeHeight_eq_ringKrullDim_iff [FiniteRingKrullDim R] [IsLocalRing R] {I : Ideal R} - [I.IsPrime] : Ideal.primeHeight I = ringKrullDim R ↔ I = IsLocalRing.maximalIdeal R := by +theorem Ideal.height_eq_ringKrullDim_iff [FiniteRingKrullDim R] [IsLocalRing R] {I : Ideal R} + [I.IsPrime] : I.height = ringKrullDim R ↔ I = IsLocalRing.maximalIdeal R := by constructor · intro h - exact IsLocalRing.eq_maximalIdeal (Ideal.isMaximal_of_primeHeight_eq_ringKrullDim h) + exact IsLocalRing.eq_maximalIdeal (Ideal.isMaximal_of_height_eq_ringKrullDim h) · rintro rfl - exact IsLocalRing.maximalIdeal_primeHeight_eq_ringKrullDim + exact IsLocalRing.maximalIdeal_height_eq_ringKrullDim + +@[deprecated "Use `Ideal.height_eq_ringKrullDim_iff` instead." (since := "2026-04-02")] +private theorem Ideal.primeHeight_eq_ringKrullDim_iff [FiniteRingKrullDim R] [IsLocalRing R] + {I : Ideal R} [I.IsPrime] : + Ideal.primeHeight I = ringKrullDim R ↔ I = IsLocalRing.maximalIdeal R := by + rw [← Ideal.height_eq_primeHeight, Ideal.height_eq_ringKrullDim_iff] lemma Ideal.height_le_iff {p : Ideal R} {n : ℕ} [p.IsPrime] : p.height ≤ n ↔ ∀ q : Ideal R, q.IsPrime → q < p → q.height < n := by @@ -323,11 +362,12 @@ lemma ringKrullDim_le_iff_isMaximal_height_le {R : Type*} [CommRing R] (n : With norm_cast exact Ideal.height_mono hle -theorem IsLocalization.primeHeight_under (S : Submonoid R) {A : Type*} [CommRing A] [Algebra R A] - [IsLocalization S A] (J : Ideal A) [J.IsPrime] : - (J.under R).primeHeight = J.primeHeight := by - rw [eq_comm, Ideal.primeHeight, Ideal.primeHeight, ← WithBot.coe_inj, - Order.height_eq_krullDim_Iic, Order.height_eq_krullDim_Iic] +private theorem IsLocalization.height_under_eq_of_isPrime (S : Submonoid R) {A : Type*} [CommRing A] + [Algebra R A] [IsLocalization S A] (J : Ideal A) [J.IsPrime] : + (J.comap (algebraMap R A)).height = J.height := by + rw [eq_comm, Ideal.height_eq_primeHeight, Ideal.height_eq_primeHeight, Ideal.primeHeight, + Ideal.primeHeight, ← WithBot.coe_inj, Order.height_eq_krullDim_Iic, + Order.height_eq_krullDim_Iic] let e := IsLocalization.orderIsoOfPrime S A have H (p : Ideal R) (hp : p ≤ J.comap (algebraMap R A)) : Disjoint (S : Set R) p := Set.disjoint_of_subset_right hp (e ⟨_, ‹J.IsPrime›⟩).2.2 @@ -340,14 +380,19 @@ theorem IsLocalization.primeHeight_under (S : Submonoid R) {A : Type*} [CommRing congrArg (fun I ↦ I.1) (e.right_inv ⟨_, I.1.2, H _ I.2⟩) map_rel_iff' {I₁ I₂} := @RelIso.map_rel_iff _ _ _ _ e ⟨_, I₁.1.2⟩ ⟨_, I₂.1.2⟩ } -@[deprecated (since := "2026-04-09")] alias IsLocalization.primeHeight_comap := - IsLocalization.primeHeight_under +@[deprecated "Use `Ideal.height_ne_top_of_isPrime` instead." (since := "2026-04-04")] +private theorem IsLocalization.primeHeight_comap (S : Submonoid R) {A : Type*} [CommRing A] + [Algebra R A] [IsLocalization S A] (J : Ideal A) [J.IsPrime] : + (J.comap (algebraMap R A)).primeHeight = J.primeHeight := by + simpa [Ideal.height_eq_primeHeight] using IsLocalization.height_under_eq_of_isPrime S J theorem IsLocalization.height_under (S : Submonoid R) {A : Type*} [CommRing A] [Algebra R A] [IsLocalization S A] (J : Ideal A) : (J.under R).height = J.height := by - rw [Ideal.height, Ideal.height] - simp_rw [← IsLocalization.primeHeight_under S, IsLocalization.minimalPrimes_comap S A, - ← Ideal.height_eq_primeHeight, iInf_image] + rw [(J.comap _).height_eq_inf_minimalPrimes, J.height_eq_inf_minimalPrimes] + simp only [IsLocalization.minimalPrimes_comap S A, iInf_image] + apply iInf_congr (fun p ↦ iInf_congr fun hp ↦ ?_) + have := hp.isPrime + exact IsLocalization.height_under_eq_of_isPrime S _ @[deprecated (since := "2026-04-09")] alias IsLocalization.height_comap := IsLocalization.height_under @@ -356,10 +401,9 @@ theorem IsLocalization.AtPrime.ringKrullDim_eq_height (I : Ideal R) [I.IsPrime] [CommRing A] [Algebra R A] [IsLocalization.AtPrime A I] : ringKrullDim A = I.height := by have := IsLocalization.AtPrime.isLocalRing A I - rw [← IsLocalRing.maximalIdeal_primeHeight_eq_ringKrullDim, - ← IsLocalization.primeHeight_under I.primeCompl, - ← IsLocalization.AtPrime.under_maximalIdeal A I, - Ideal.height_eq_primeHeight] + rw [← IsLocalRing.maximalIdeal_height_eq_ringKrullDim, + ← IsLocalization.height_under I.primeCompl, + ← IsLocalization.AtPrime.under_maximalIdeal A I] lemma IsLocalization.height_map_of_disjoint {S : Type*} [CommRing S] [Algebra R S] (M : Submonoid R) [IsLocalization M S] (p : Ideal R) [p.IsPrime] (h : Disjoint (M : Set R) (p : Set R)) : @@ -373,7 +417,8 @@ lemma IsLocalization.height_map_of_disjoint {S : Type*} [CommRing S] [Algebra R rw [AtPrime.ringKrullDim_eq_height P, AtPrime.ringKrullDim_eq_height p] at this exact WithBot.coe_eq_coe.mp this -lemma mem_minimalPrimes_of_primeHeight_eq_height {I J : Ideal R} [J.IsPrime] (e : I ≤ J) +@[deprecated "Use `mem_minimalPrimes_of_height_eq` instead." (since := "2026-04-02")] +private lemma mem_minimalPrimes_of_primeHeight_eq_height {I J : Ideal R} [J.IsPrime] (e : I ≤ J) (e' : J.primeHeight = I.height) [J.FiniteHeight] : J ∈ I.minimalPrimes := by rw [← J.height_eq_primeHeight] at e' exact mem_minimalPrimes_of_height_eq e (e' ▸ le_refl _) @@ -408,25 +453,18 @@ lemma exists_spanRank_le_and_le_height_of_le_height [IsNoetherianRing R] (I : Id exact add_le_add h₂ ((Submodule.spanRank_span_le_card _).trans (by simp)) · refine le_iInf₂ (fun p hp ↦ ?_) have := hp.isPrime + rw [← p.height_eq_primeHeight] by_cases h : p.height = ⊤ - · rw [← p.height_eq_primeHeight, h] - exact le_top + · exact le_of_le_of_eq le_top h.symm have : p.FiniteHeight := ⟨Or.inr h⟩ - have := Ideal.height_mono (le_sup_left.trans hp.1.2) - suffices h : (r : ℕ∞) ≠ p.primeHeight by - push_cast - have := h₃.trans this - rw [Ideal.height_eq_primeHeight] at this - exact Order.add_one_le_of_lt (lt_of_le_of_ne this h) + have := Ideal.height_mono (le_sup_left.trans hp.le) + suffices h : (r : ℕ∞) ≠ p.height by + exact Order.add_one_le_of_lt (lt_of_le_of_ne (h₃.trans this) h) intro e apply hx₂ p - · have : J.height = p.primeHeight := by - apply le_antisymm - · rwa [← p.height_eq_primeHeight] - · rwa [← e] - refine ⟨mem_minimalPrimes_of_primeHeight_eq_height (le_sup_left.trans hp.le) this.symm, ?_⟩ - rwa [p.height_eq_primeHeight, eq_comm] - · exact hp.le <| Ideal.mem_sup_right <| mem_span_singleton_self x + · refine ⟨mem_minimalPrimes_of_height_eq (le_sup_left.trans hp.le) (e.symm.trans_le h₃), + e.symm⟩ + · apply hp.le <| Ideal.mem_sup_right <| mem_span_singleton_self x /-- In a nontrivial commutative ring `R`, the supremum of heights of all ideals is equal to the Krull dimension of `R`. -/ @@ -447,33 +485,43 @@ lemma Ideal.sup_height_eq_ringKrullDim [Nontrivial R] : · exact le_iSup_of_le p.last.isPrime.ne_top' le_rfl · exact le_iSup (fun I => ⨆ _, I.height) p.last.asIdeal -/-- In a nontrivial commutative ring `R`, the supremum of prime heights of all prime ideals is +/-- In a nontrivial commutative ring `R`, the supremum of heights of all prime ideals is equal to the Krull dimension of `R`. -/ -lemma Ideal.sup_primeHeight_eq_ringKrullDim [Nontrivial R] : - ↑(⨆ (I : Ideal R) (_ : I.IsPrime), I.primeHeight) = ringKrullDim R := by +lemma Ideal.sup_isPrime_height_eq_ringKrullDim [Nontrivial R] : + ↑(⨆ (I : Ideal R) (_ : I.IsPrime), I.height) = ringKrullDim R := by rw [← sup_height_eq_ringKrullDim, WithBot.coe_inj] apply le_antisymm - · exact iSup_mono fun I => iSup_mono' fun hI => ⟨hI.ne_top, by rw [← height_eq_primeHeight]⟩ + · exact iSup_mono fun I => iSup_mono' fun hI => ⟨hI.ne_top, le_refl _⟩ · refine iSup_mono' fun I => ?_ by_cases I_top : I = ⊤ · exact ⟨⊥, by simp [I_top]⟩ - · obtain ⟨P, hP⟩ : I.minimalPrimes.Nonempty := - Set.nonempty_coe_sort.mp (nonempty_minimalPrimes I_top) + · obtain ⟨P, hP⟩ := Set.nonempty_coe_sort.mp (nonempty_minimalPrimes I_top) refine ⟨P, iSup_pos (α := ℕ∞) I_top ▸ le_iSup_of_le (hP.left.left) ?_⟩ - exact iInf_le_of_le P (iInf_le_of_le hP le_rfl) + have := hP.isPrime + exact iInf_le_of_le P (iInf_le_of_le hP (ge_of_eq (Ideal.height_eq_primeHeight P))) + +@[deprecated "Use `Ideal.sup_height_isPrime_eq_ringKrullDim` instead." (since := "2026-04-02")] +private lemma Ideal.sup_primeHeight_eq_ringKrullDim [Nontrivial R] : + ↑(⨆ (I : Ideal R) (_ : I.IsPrime), I.primeHeight) = ringKrullDim R := by + simp [← Ideal.height_eq_primeHeight, Ideal.sup_isPrime_height_eq_ringKrullDim] -/-- In a nontrivial commutative ring `R`, the supremum of prime heights of all maximal ideals is +/-- In a nontrivial commutative ring `R`, the supremum of heights of all maximal ideals is equal to the Krull dimension of `R`. -/ -lemma Ideal.sup_primeHeight_of_maximal_eq_ringKrullDim [Nontrivial R] : - ↑(⨆ (I : Ideal R) (_ : I.IsMaximal), I.primeHeight) = ringKrullDim R := by - rw [← Ideal.sup_primeHeight_eq_ringKrullDim, WithBot.coe_inj] +lemma Ideal.sup_isMaximal_height_eq_ringKrullDim [Nontrivial R] : + ↑(⨆ (I : Ideal R) (_ : I.IsMaximal), I.height) = ringKrullDim R := by + rw [← Ideal.sup_height_eq_ringKrullDim, WithBot.coe_inj] apply le_antisymm - · exact iSup_mono fun I => iSup_mono' fun hI => ⟨IsMaximal.isPrime hI, le_rfl⟩ + · exact iSup_mono fun I => iSup_mono' fun hI => ⟨hI.isPrime.ne_top , le_rfl⟩ · refine iSup_mono' fun I => ?_ obtain rfl | I_top := eq_or_ne I ⊤ · exact ⟨⊥, by grind [iSup_le_iff, Ideal.IsPrime.ne_top]⟩ · obtain ⟨M, hM, hIM⟩ := exists_le_maximal I I_top - exact ⟨M, iSup_mono' (fun hI ↦ ⟨hM, primeHeight_mono hIM⟩)⟩ + exact ⟨M, iSup_mono' (fun hI ↦ ⟨hM, height_mono hIM⟩)⟩ + +@[deprecated "Use `Ideal.sup_height_of_maximal_eq_ringKrullDim` instead." (since := "2026-04-02")] +private lemma Ideal.sup_primeHeight_of_maximal_eq_ringKrullDim [Nontrivial R] : + ↑(⨆ (I : Ideal R) (_ : I.IsMaximal), I.primeHeight) = ringKrullDim R := by + simp_rw [← Ideal.height_eq_primeHeight, Ideal.sup_isMaximal_height_eq_ringKrullDim] section isLocalization @@ -488,10 +536,9 @@ lemma Ring.krullDimLE_of_isLocalization_maximal {n : ℕ} Ring.KrullDimLE n R := by simp_rw [Ring.krullDimLE_iff] at h ⊢ nontriviality R - rw [← Ideal.sup_primeHeight_of_maximal_eq_ringKrullDim] + rw [← Ideal.sup_isMaximal_height_eq_ringKrullDim] refine (WithBot.coe_le_coe).mpr (iSup₂_le_iff.mpr fun P hP ↦ ?_) - rw [← Ideal.height_eq_primeHeight, ← WithBot.coe_le_coe] - rw [← IsLocalization.AtPrime.ringKrullDim_eq_height P (Rₚ P)] + rw [← WithBot.coe_le_coe, ← IsLocalization.AtPrime.ringKrullDim_eq_height P (Rₚ P)] exact h P end isLocalization diff --git a/Mathlib/RingTheory/Ideal/KrullsHeightTheorem.lean b/Mathlib/RingTheory/Ideal/KrullsHeightTheorem.lean index 86c33519dd60d2..a03040a6daaa96 100644 --- a/Mathlib/RingTheory/Ideal/KrullsHeightTheorem.lean +++ b/Mathlib/RingTheory/Ideal/KrullsHeightTheorem.lean @@ -50,7 +50,7 @@ lemma IsLocalRing.quotient_artinian_of_mem_minimalPrimes_of_isLocalRing IsArtinianRing (R ⧸ I) := have : Ring.KrullDimLE 0 (R ⧸ I) := Ring.krullDimLE_zero_iff.mpr fun J prime ↦ Ideal.isMaximal_of_isIntegral_of_isMaximal_comap _ <| by - convert IsLocalRing.maximalIdeal.isMaximal R + convert! IsLocalRing.maximalIdeal.isMaximal R rw [Ideal.minimalPrimes, Set.mem_setOf] at hp have := prime.comap (Ideal.Quotient.mk I) exact hp.eq_of_le ⟨this, .trans (by simp) (Ideal.ker_le_comap _)⟩ (le_maximalIdeal this.1) @@ -160,9 +160,8 @@ theorem Ideal.mem_minimalPrimes_span_of_mem_minimalPrimes_span_insert {q p : Ide sup_eq_left.mpr hI'q, sup_eq_left.mpr hI'p] using comap_mono (f := f) e have : (q.map f).IsPrime := map_isPrime_of_surjective hf (by rwa [mk_ker]) have : (p.map f).FiniteHeight := ⟨Or.inr (h.trans_lt (WithTop.coe_lt_top 1)).ne⟩ - rw [height_eq_primeHeight] at h - have := (primeHeight_strict_mono h_lt).trans_le h - rw [ENat.lt_one_iff_eq_zero, primeHeight_eq_zero_iff] at this + have := (height_strict_mono_of_isPrime_of_isPrime h_lt).trans_le h + rw [Order.lt_one_iff, height_eq_zero_iff] at this have := minimalPrimes_comap_of_surjective hf this rwa [comap_map_of_surjective f hf, ← RingHom.ker_eq_comap_bot, mk_ker, sup_eq_left.mpr hI'q] at this @@ -194,8 +193,7 @@ nonrec lemma Ideal.height_le_spanRank_toENat_of_mem_minimalPrimes have := hp.isPrime cases n with | zero => - rw [ENat.coe_zero, nonpos_iff_eq_zero, height_eq_primeHeight p, - primeHeight_eq_zero_iff, minimalPrimes] + rw [ENat.coe_zero, nonpos_iff_eq_zero, height_eq_zero_iff, minimalPrimes] simp_all | succ n => wlog hR : ∃ (_ : IsLocalRing R), p = maximalIdeal R @@ -229,7 +227,7 @@ nonrec lemma Ideal.height_le_spanRank_toENat_of_mem_minimalPrimes simpa using Finset.card_lt_card (Finset.ssubset_insert hxs')).trans_le hn) (H _ (tcard.trans_lt n.lt_succ_self) q t hq rfl).trans (by norm_cast) rw [Finset.coe_insert] at hp - convert mem_minimalPrimes_span_of_mem_minimalPrimes_span_insert hpq _ _ hp _ ht ?_ + convert! mem_minimalPrimes_span_of_mem_minimalPrimes_span_insert hpq _ _ hp _ ht ?_ · simp [t] refine hspan.trans <| radical_mono ?_ rw [← Set.union_singleton, span_union] @@ -255,9 +253,8 @@ than or equal to the minimum number of generators for this ideal. -/ lemma Ideal.height_le_spanRank_toENat (I : Ideal R) (hI : I ≠ ⊤) : I.height ≤ I.spanRank.toENat := by obtain ⟨J, hJ⟩ := nonempty_minimalPrimes hI - refine (iInf₂_le J hJ).trans ?_ - convert (I.height_le_spanRank_toENat_of_mem_minimalPrimes J hJ) - exact (@height_eq_primeHeight _ _ J hJ.1.1).symm + rw [I.height_eq_inf_minimalPrimes] + exact (iInf₂_le J hJ).trans (I.height_le_spanRank_toENat_of_mem_minimalPrimes J hJ) lemma Ideal.height_le_spanFinrank (I : Ideal R) (hI : I ≠ ⊤) : I.height ≤ I.spanFinrank := by @@ -292,7 +289,7 @@ lemma Ideal.exists_spanRank_eq_and_height_eq (I : Ideal R) (hI : I ≠ ⊤) : rw [ENat.coe_toNat_eq_self.mpr (Ideal.height_ne_top hI)] at hJ₃ refine ⟨J, hJ₁, le_antisymm ?_ (le_trans ?_ (J.height_le_spanRank ?_)), le_antisymm (Ideal.height_mono hJ₁) hJ₃⟩ - · convert hJ₂ + · convert! hJ₂ exact Cardinal.ofENat_eq_nat.mpr (ENat.coe_toNat (I.height_ne_top hI)).symm · exact Cardinal.ofENat_le_ofENat_of_le hJ₃ · rintro rfl @@ -355,7 +352,7 @@ lemma Ideal.height_le_height_add_spanFinrank_of_le {I p : Ideal R} [p.IsPrime] ( rw [Finset.coe_union, Set.Finite.coe_toFinset, span_union, sup_comm, span, Submodule.span_generators] refine Ideal.mem_minimalPrimes_sup hrp ?_ - convert hps + convert! hps simp [Ideal.map_span, ← himgo] lemma height_le_ringKrullDim_quotient_add_spanFinrank {p I : Ideal R} [p.IsPrime] (h : I ≤ p) : @@ -393,12 +390,12 @@ lemma Ideal.height_le_ringKrullDim_quotient_add_encard {p : Ideal R} [p.IsPrime] lemma Ideal.height_le_height_add_one_of_mem {r : R} {p : Ideal R} [p.IsPrime] (hrm : r ∈ p) : p.height ≤ (p.map (Quotient.mk (span {r}))).height + 1 := by - convert height_le_height_add_encard_of_subset {r} (p := p) (by simpa) + convert! height_le_height_add_encard_of_subset { r } (p := p) (by simpa) simp lemma Ideal.height_le_ringKrullDim_quotient_add_one {r : R} {p : Ideal R} [p.IsPrime] (hrp : r ∈ p) : p.height ≤ ringKrullDim (R ⧸ span {r}) + 1 := by - convert Ideal.height_le_ringKrullDim_quotient_add_encard {r} (by simpa) + convert! Ideal.height_le_ringKrullDim_quotient_add_encard { r } (by simpa) simp lemma ringKrullDim_le_ringKrullDim_quotient_add_encard (s : Set R) (hs : s ⊆ Ring.jacobson R) : @@ -410,7 +407,7 @@ lemma ringKrullDim_le_ringKrullDim_quotient_add_encard (s : Set R) (hs : s ⊆ R lemma ringKrullDim_le_ringKrullDim_quotient_add_card (s : Finset R) (hs : (s : Set R) ⊆ Ring.jacobson R) : ringKrullDim R ≤ ringKrullDim (R ⧸ Ideal.span (s : Set R)) + s.card := by - convert ringKrullDim_le_ringKrullDim_quotient_add_encard s hs + convert! ringKrullDim_le_ringKrullDim_quotient_add_encard s hs norm_cast section Algebra @@ -452,7 +449,7 @@ lemma Ideal.height_le_height_add_of_liesOver [IsNoetherianRing S] (p : Ideal R) have : Ideal.span t = Ideal.map (algebraMap R S) (.span s) ⊔ .span o := by simp [t, Ideal.map_span] refine this ▸ map_sup_mem_minimalPrimes_of_map_quotientMk_mem_minimalPrimes hp (span_le.mpr ho) ?_ - convert hP' + convert! hP' simp [Ideal.map_span, ← himgo] /-- @@ -483,7 +480,7 @@ lemma Ideal.height_eq_height_add_of_liesOver_of_hasGoingDown [IsNoetherianRing S simp [hlq, map_le_iff_le_comap, LiesOver.over (p := p) (P := P)] obtain ⟨lp', hlp'len, hlp', _⟩ := exists_ltSeries_of_hasGoingDown lp l'.head.asIdeal have : (lp'.smash l' hlp').length = lp.length + lq.length := by simp [hlp'len, l'] - rw [← hlenp, ← hlenq, ← Nat.cast_add, ← this, height_eq_primeHeight] + rw [← hlenp, ← hlenq, ← Nat.cast_add, ← this, (⟨P, ‹_›⟩ : PrimeSpectrum S).height_eq_orderHeight] apply Order.length_le_height simp [hlq, l', ← PrimeSpectrum.asIdeal_le_asIdeal, map_le_iff_le_comap, LiesOver.over (p := p) (P := P)] diff --git a/Mathlib/RingTheory/Ideal/Maps.lean b/Mathlib/RingTheory/Ideal/Maps.lean index 96e4372dc96fc2..e3e1f1f1c04543 100644 --- a/Mathlib/RingTheory/Ideal/Maps.lean +++ b/Mathlib/RingTheory/Ideal/Maps.lean @@ -376,8 +376,9 @@ theorem IsMaximal.comap_piEvalRingHom {ι : Type*} {R : ι → Type*} [∀ i, Se refine isMaximal_iff.mpr ⟨I.ne_top_iff_one.mp h.ne_top, fun J x le hxI hxJ ↦ ?_⟩ have ⟨r, y, hy, eq⟩ := h.exists_inv hxI classical - convert J.add_mem (J.mul_mem_left (update 0 i r) hxJ) - (b := update 1 i y) (le <| by apply update_self i y 1 ▸ hy) + convert! + J.add_mem (J.mul_mem_left (update 0 i r) hxJ) (b := update 1 i y) + (le <| by apply update_self i y 1 ▸ hy) ext j obtain rfl | ne := eq_or_ne j i · simpa [eq_comm] using eq @@ -842,6 +843,10 @@ def Module.annihilator : Ideal R := RingHom.ker (Module.toAddMonoidEnd R M) theorem Module.mem_annihilator {r} : r ∈ Module.annihilator R M ↔ ∀ m : M, r • m = 0 := ⟨fun h ↦ (congr($h ·)), (AddMonoidHom.ext ·)⟩ +lemma Module.mem_annihilator_iff_lsmul_eq_zero {R : Type*} [CommSemiring R] + [Module R M] {r : R} : r ∈ Module.annihilator R M ↔ LinearMap.lsmul R M r = 0 := by + simp [Module.mem_annihilator, LinearMap.ext_iff] + instance (priority := low) : (Module.annihilator R M).IsTwoSided := inferInstanceAs (RingHom.ker _).IsTwoSided @@ -1087,7 +1092,7 @@ theorem map_isPrime_of_surjective {f : F} (hf : Function.Surjective f) {I : Idea rcases hxy with ⟨c, hc, hc'⟩ rw [← sub_eq_zero, ← map_sub] at hc' have : a * b ∈ I := by - convert I.sub_mem hc (hk (hc' : c - a * b ∈ RingHom.ker f)) using 1 + convert! I.sub_mem hc (hk (hc' : c - a * b ∈ RingHom.ker f)) using 1 abel exact (H.mem_or_mem this).imp (fun h => ha ▸ mem_map_of_mem f h) fun h => hb ▸ mem_map_of_mem f h @@ -1118,7 +1123,7 @@ theorem map_radical_of_surjective {f : R →+* S} (hf : Function.Surjective f) { (h : RingHom.ker f ≤ I) : map f I.radical = (map f I).radical := by rw [radical_eq_sInf, radical_eq_sInf] have : ∀ J ∈ {J : Ideal R | I ≤ J ∧ J.IsPrime}, RingHom.ker f ≤ J := fun J hJ => h.trans hJ.left - convert map_sInf hf this + convert! map_sInf hf this ext j constructor · rintro ⟨hj, hj'⟩ diff --git a/Mathlib/RingTheory/Ideal/MinimalPrime/Basic.lean b/Mathlib/RingTheory/Ideal/MinimalPrime/Basic.lean index 1d4dea8b6ad45e..23e037a198388a 100644 --- a/Mathlib/RingTheory/Ideal/MinimalPrime/Basic.lean +++ b/Mathlib/RingTheory/Ideal/MinimalPrime/Basic.lean @@ -205,7 +205,7 @@ lemma Ideal.map_sup_mem_minimalPrimes_of_map_quotientMk_mem_minimalPrimes have h1 : p.map (algebraMap R S) ≤ q := by rw [Ideal.map_le_iff_le_comap] refine hI.2 ⟨inferInstance, le_trans Ideal.le_comap_map (Ideal.comap_mono hleq.1)⟩ ?_ - convert Ideal.comap_mono hqle + convert! Ideal.comap_mono hqle exact Ideal.LiesOver.over have h2 : P.map (Ideal.Quotient.mk (p.map (algebraMap R S))) ≤ q.map (Ideal.Quotient.mk (p.map (algebraMap R S))) := diff --git a/Mathlib/RingTheory/Ideal/Nonunits.lean b/Mathlib/RingTheory/Ideal/Nonunits.lean index e1608235a69950..0c2acbd0278c37 100644 --- a/Mathlib/RingTheory/Ideal/Nonunits.lean +++ b/Mathlib/RingTheory/Ideal/Nonunits.lean @@ -72,7 +72,7 @@ variable {C : Type*} [SetLike C α] theorem inv_mem_of_isUnit [DivisionMonoid α] [SubmonoidClass C α] {S : C} {a : S} (ha : IsUnit a) : (a : α)⁻¹ ∈ S := by obtain ⟨u, rfl⟩ := ha - convert u⁻¹.1.2 + convert! u⁻¹.1.2 exact (map_inv ((subtype <| ofClass S).comp <| Units.coeHom S) u).symm section Group diff --git a/Mathlib/RingTheory/Ideal/Norm/AbsNorm.lean b/Mathlib/RingTheory/Ideal/Norm/AbsNorm.lean index a091dae00c491b..a8f308649071e7 100644 --- a/Mathlib/RingTheory/Ideal/Norm/AbsNorm.lean +++ b/Mathlib/RingTheory/Ideal/Norm/AbsNorm.lean @@ -105,7 +105,7 @@ theorem Ideal.mul_add_mem_pow_succ_inj (P : Ideal S) {i : ℕ} (a d d' e e' : S) have : a * d - a * d' ∈ P ^ (i + 1) := by simp only [← mul_sub] exact Ideal.mul_mem_mul a_mem h - convert Ideal.add_mem _ this (Ideal.sub_mem _ e_mem e'_mem) using 1 + convert! Ideal.add_mem _ this (Ideal.sub_mem _ e_mem e'_mem) using 1 ring section PPrime @@ -144,7 +144,7 @@ theorem Ideal.mul_add_mem_pow_succ_unique [IsDedekindDomain S] (hP : P ≠ ⊥) (a_notMem : a ∉ P ^ (i + 1)) (e_mem : e ∈ P ^ (i + 1)) (e'_mem : e' ∈ P ^ (i + 1)) (h : a * d + e - (a * d' + e') ∈ P ^ (i + 1)) : d - d' ∈ P := by have h' : a * (d - d') ∈ P ^ (i + 1) := by - convert Ideal.add_mem _ h (Ideal.sub_mem _ e'_mem e_mem) using 1 + convert! Ideal.add_mem _ h (Ideal.sub_mem _ e'_mem e_mem) using 1 ring exact Ideal.mem_prime_of_mul_mem_pow hP a_notMem h' @@ -198,7 +198,7 @@ theorem cardQuot_mul [IsDedekindDomain S] [Module.Free ℤ S] (I J : Ideal S) : (hIJ (Ideal.dvd_iff_le.mpr le_sup_left) (Ideal.dvd_iff_le.mpr le_sup_right))) /-- The absolute norm of the ideal `I : Ideal R` is the cardinality of the quotient `R ⧸ I`. -/ -noncomputable def Ideal.absNorm [Nontrivial S] [IsDedekindDomain S] [Module.Free ℤ S] : +noncomputable def Ideal.absNorm [IsDedekindDomain S] [Module.Free ℤ S] : Ideal S →*₀ ℕ where toFun := Submodule.cardQuot map_mul' I J := by rw [cardQuot_mul] @@ -209,7 +209,7 @@ noncomputable def Ideal.absNorm [Nontrivial S] [IsDedekindDomain S] [Module.Free namespace Ideal -variable [Nontrivial S] [IsDedekindDomain S] [Module.Free ℤ S] +variable [IsDedekindDomain S] [Module.Free ℤ S] theorem absNorm_apply (I : Ideal S) : absNorm I = cardQuot I := rfl diff --git a/Mathlib/RingTheory/Ideal/Norm/RelNorm.lean b/Mathlib/RingTheory/Ideal/Norm/RelNorm.lean index 3244a3ca908c0a..74b68815f1914c 100644 --- a/Mathlib/RingTheory/Ideal/Norm/RelNorm.lean +++ b/Mathlib/RingTheory/Ideal/Norm/RelNorm.lean @@ -192,6 +192,8 @@ theorem spanNorm_le_comap (I : Ideal S) : spanNorm R I ≤ comap (algebraMap R S | add _ _ _ _ hx hy => exact Submodule.add_mem _ hx hy | smul _ _ _ hx => exact Submodule.smul_mem _ _ hx +set_option linter.overlappingInstances false + /-- Multiplicativity of `Ideal.spanNorm`. simp-normal form is `map_mul (Ideal.relNorm R)`. -/ theorem spanNorm_mul [IsDedekindDomain R] [IsDedekindDomain S] (I J : Ideal S) : spanNorm R (I * J) = spanNorm R I * spanNorm R J := by @@ -320,7 +322,7 @@ theorem relNorm_map_algEquiv {T : Type*} [CommRing T] [IsDedekindDomain T] [IsIn [Algebra R T] [Module.Finite R T] [IsTorsionFree R T] (σ : S ≃ₐ[R] T) (I : Ideal S) : relNorm R (I.map σ) = relNorm R I := by refine le_antisymm (relNorm_map_algEquiv_aux σ I) ?_ - convert relNorm_map_algEquiv_aux σ.symm (I.map σ) + convert! relNorm_map_algEquiv_aux σ.symm (I.map σ) change I = map σ.symm.toAlgHom (map σ.toAlgHom I) simp [map_mapₐ] diff --git a/Mathlib/RingTheory/Ideal/Quotient/ChineseRemainder.lean b/Mathlib/RingTheory/Ideal/Quotient/ChineseRemainder.lean index d0647fb45356b0..c7f4f9fd5cc482 100644 --- a/Mathlib/RingTheory/Ideal/Quotient/ChineseRemainder.lean +++ b/Mathlib/RingTheory/Ideal/Quotient/ChineseRemainder.lean @@ -50,7 +50,7 @@ theorem ker_tensorProductMk_quotient : (⨅ i, I i) • (⊤ : Submodule R M) := by have := rTensor_exact M (exact_subtype_ker_map _) (pi_mkQ_surjective hI) rw [← (TensorProduct.lid R M).conj_exact_iff_exact, exact_iff] at this - convert this + convert! this · classical simp [pi_mkQ_rTensor, LinearMap.comp_assoc] refine le_antisymm (Submodule.smul_le.mpr fun r hr m _ ↦ ⟨⟨r, ?_⟩ ⊗ₜ m, rfl⟩) ?_ · simpa only [ker_pi, Submodule.ker_mkQ] diff --git a/Mathlib/RingTheory/Ideal/Quotient/Operations.lean b/Mathlib/RingTheory/Ideal/Quotient/Operations.lean index 23d93bd29f0403..8a5d73d16743ff 100644 --- a/Mathlib/RingTheory/Ideal/Quotient/Operations.lean +++ b/Mathlib/RingTheory/Ideal/Quotient/Operations.lean @@ -577,7 +577,7 @@ lemma _root_.AlgHom.liftOfSurjective_comp (f : A →ₐ[R] B) (hf : Function.Sur lemma _root_.AlgHom.liftOfSurjective_surjective (f : A →ₐ[R] B) (hf : Function.Surjective f) (g : A →ₐ[R] C) (H : RingHom.ker f.toRingHom ≤ RingHom.ker g.toRingHom) (hg : Function.Surjective g) : Function.Surjective (AlgHom.liftOfSurjective f hf g H) := - .of_comp (g := f) (by convert hg; ext; simp) + .of_comp (g := f) (by convert! hg; ext; simp) end liftOfSurjective diff --git a/Mathlib/RingTheory/IntegralClosure/IntegralRestrict.lean b/Mathlib/RingTheory/IntegralClosure/IntegralRestrict.lean index 2d61bab942f57d..4632e56e931129 100644 --- a/Mathlib/RingTheory/IntegralClosure/IntegralRestrict.lean +++ b/Mathlib/RingTheory/IntegralClosure/IntegralRestrict.lean @@ -519,7 +519,7 @@ lemma Algebra.algebraMap_intNorm_of_isGalois [IsGalois (FractionRing A) (Fractio haveI : FiniteDimensional (FractionRing A) (FractionRing B) := .of_isLocalization A B A⁰ rw [← (galRestrict A (FractionRing A) (FractionRing B) B).toEquiv.prod_comp] simp only [MulEquiv.toEquiv_eq_coe, EquivLike.coe_coe] - convert (prod_galRestrict_eq_norm A (FractionRing A) (FractionRing B) B x).symm + convert! (prod_galRestrict_eq_norm A (FractionRing A) (FractionRing B) B x).symm open Polynomial IsScalarTower in theorem Algebra.dvd_algebraMap_intNorm_self (x : B) : x ∣ algebraMap A B (intNorm A B x) := by diff --git a/Mathlib/RingTheory/IntegralClosure/IntegrallyClosed.lean b/Mathlib/RingTheory/IntegralClosure/IntegrallyClosed.lean index 3004ea70521c57..1d3a91951ec546 100644 --- a/Mathlib/RingTheory/IntegralClosure/IntegrallyClosed.lean +++ b/Mathlib/RingTheory/IntegralClosure/IntegrallyClosed.lean @@ -83,7 +83,7 @@ theorem AlgHom.isIntegrallyClosedIn (f : A →ₐ[R] B) (hf : Function.Injective IsIntegrallyClosedIn R B → IsIntegrallyClosedIn R A := by rintro ⟨inj, cl⟩ refine ⟨Function.Injective.of_comp (f := f) ?_, fun hx => ?_, ?_⟩ - · convert inj + · convert! inj aesop · obtain ⟨y, fx_eq⟩ := cl.mp ((isIntegral_algHom_iff f hf).mpr hx) aesop @@ -282,7 +282,7 @@ lemma of_isIntegrallyClosedIn (FaithfulSMul.algebraMap_injective R K) rw [isIntegrallyClosed_iff (K := FractionRing R)] intro x hx - convert (IsIntegralClosure.isIntegral_iff (A := R)).mp (hx.map f) + convert! (IsIntegralClosure.isIntegral_iff (A := R)).mp (hx.map f) simp [← f.toRingHom.injective.eq_iff] lemma _root_.IsIntegralClosure.of_isIntegralClosure_of_isIntegrallyClosedIn diff --git a/Mathlib/RingTheory/IntegralClosure/IsIntegralClosure/Basic.lean b/Mathlib/RingTheory/IntegralClosure/IsIntegralClosure/Basic.lean index 1d6ef074373620..62098ee34b1a3e 100644 --- a/Mathlib/RingTheory/IntegralClosure/IsIntegralClosure/Basic.lean +++ b/Mathlib/RingTheory/IntegralClosure/IsIntegralClosure/Basic.lean @@ -202,7 +202,7 @@ theorem IsIntegral.of_mul_unit {x y : B} {r : R} (hr : algebraMap R B r * y = 1) (hx : IsIntegral R (x * y)) : IsIntegral R x := by obtain ⟨p, p_monic, hp⟩ := hx refine ⟨scaleRoots p r, (monic_scaleRoots_iff r).2 p_monic, ?_⟩ - convert scaleRoots_aeval_eq_zero hp + convert! scaleRoots_aeval_eq_zero hp rw [Algebra.commutes] at hr ⊢ rw [mul_assoc, hr, mul_one]; rfl @@ -485,7 +485,7 @@ theorem isIntegral_trans [Algebra.IsIntegral R A] (x : B) (hx : IsIntegral A x) let p' : S[X] := p.toSubring S.toSubring subset_adjoin have hSx : IsIntegral S x := ⟨p', (p.monic_toSubring _ _).mpr pmonic, by rw [IsScalarTower.algebraMap_eq S A B, ← eval₂_map] - convert hp; apply p.map_toSubring S.toSubring⟩ + convert! hp; apply p.map_toSubring S.toSubring⟩ let Sx := Subalgebra.toSubmodule (S[x]) let MSx : Module S Sx := SMulMemClass.toModule _ -- the next line times out without this have : Module.Finite S Sx := .of_fg hSx.fg_adjoin_singleton diff --git a/Mathlib/RingTheory/IsAdjoinRoot.lean b/Mathlib/RingTheory/IsAdjoinRoot.lean index 855071079c8f79..eb6034e89f1241 100644 --- a/Mathlib/RingTheory/IsAdjoinRoot.lean +++ b/Mathlib/RingTheory/IsAdjoinRoot.lean @@ -639,7 +639,7 @@ theorem minpoly_eq [IsDomain R] [IsDomain S] [IsTorsionFree R S] [IsIntegrallyCl let ⟨q, hq⟩ := minpoly.isIntegrallyClosed_dvd h.isIntegral_root h.aeval_root_self symm <| eq_of_monic_of_associated h.monic (minpoly.monic h.isIntegral_root) <| by - convert + convert! Associated.mul_left (minpoly R h.root) <| associated_one_iff_isUnit.2 <| (hirr.isUnit_or_isUnit hq).resolve_left <| minpoly.not_isUnit R h.root diff --git a/Mathlib/RingTheory/IsTensorProduct.lean b/Mathlib/RingTheory/IsTensorProduct.lean index beac6cdd2c57b5..17ca73745966cc 100644 --- a/Mathlib/RingTheory/IsTensorProduct.lean +++ b/Mathlib/RingTheory/IsTensorProduct.lean @@ -350,7 +350,7 @@ noncomputable nonrec def IsBaseChange.lift (g : M →ₗ[R] Q) : N →ₗ[S] Q : nonrec theorem IsBaseChange.lift_eq (g : M →ₗ[R] Q) (x : M) : h.lift g (f x) = g x := by have hF : ∀ (s : S) (m : M), h.lift g (s • f m) = s • g m := h.lift_eq _ - convert hF 1 x <;> rw [one_smul] + convert! hF 1 x <;> rw [one_smul] theorem IsBaseChange.lift_comp (g : M →ₗ[R] Q) : ((h.lift g).restrictScalars R).comp f = g := LinearMap.ext (h.lift_eq g) @@ -386,7 +386,7 @@ variable (R M N S) theorem TensorProduct.isBaseChange : IsBaseChange S (TensorProduct.mk R S M 1) := by delta IsBaseChange - convert TensorProduct.isTensorProduct R S M using 1 + convert! TensorProduct.isTensorProduct R S M using 1 ext s x change s • (1 : S) ⊗ₜ[R] x = s ⊗ₜ[R] x rw [TensorProduct.smul_tmul'] @@ -434,11 +434,11 @@ lemma IsBaseChange.iff_of_equiv_comm (eM : M ≃ₗ[R] P) (eN : N ≃ₗ[S] Q) simp only [IsBaseChange] have (m : M) : f' (eM m) = eN (f m) := LinearMap.congr_fun comm m refine ⟨fun ist ↦ ?_, fun ist ↦ ?_⟩ - · convert (ist.compl₂_linearEquiv eM.symm).compr₂_linearEquiv (eN.restrictScalars R) + · convert! (ist.compl₂_linearEquiv eM.symm).compr₂_linearEquiv (eN.restrictScalars R) ext s m' obtain ⟨m, rfl⟩ := eM.surjective m' simp [this] - · convert (ist.compl₂_linearEquiv eM).compr₂_linearEquiv (eN.symm.restrictScalars R) + · convert! (ist.compl₂_linearEquiv eM).compr₂_linearEquiv (eN.symm.restrictScalars R) ext s m simp [this] @@ -687,7 +687,7 @@ lemma Algebra.IsPushout.tensorProduct_tensorProduct Algebra.TensorProduct.includeRight.toRingHom) : Algebra.IsPushout A B (A ⊗[R] S) (B ⊗[R] S) := by constructor - convert isBaseChange_tensorProduct_map (R := R) (P := S) _ (IsBaseChange.linearMap A B) + convert! isBaseChange_tensorProduct_map (R := R) (P := S) _ (IsBaseChange.linearMap A B) ext s simpa using congr($H s) diff --git a/Mathlib/RingTheory/Jacobson/Ideal.lean b/Mathlib/RingTheory/Jacobson/Ideal.lean index d05460530f1dab..0004ab71fe433a 100644 --- a/Mathlib/RingTheory/Jacobson/Ideal.lean +++ b/Mathlib/RingTheory/Jacobson/Ideal.lean @@ -127,7 +127,7 @@ theorem exists_mul_add_sub_mem_of_mem_jacobson {I : Ideal R} (r : R) (h : r ∈ theorem exists_mul_sub_mem_of_sub_one_mem_jacobson {I : Ideal R} (r : R) (h : r - 1 ∈ jacobson I) : ∃ s, s * r - 1 ∈ I := by - convert exists_mul_add_sub_mem_of_mem_jacobson _ h + convert! exists_mul_add_sub_mem_of_mem_jacobson _ h simp /-- An ideal equals its Jacobson radical iff it is the intersection of a set of maximal ideals. diff --git a/Mathlib/RingTheory/Jacobson/Radical.lean b/Mathlib/RingTheory/Jacobson/Radical.lean index 8bb3956f69910c..cea9cb8d9c956f 100644 --- a/Mathlib/RingTheory/Jacobson/Radical.lean +++ b/Mathlib/RingTheory/Jacobson/Radical.lean @@ -196,7 +196,7 @@ theorem FG.jacobson_smul_lt {N : Submodule R M} (ne_bot : N ≠ ⊥) (fg : N.FG) Ring.jacobson R • N < N := by rw [← Module.Finite.iff_fg] at fg rw [← nontrivial_iff_ne_bot] at ne_bot - convert map_strictMono_of_injective N.injective_subtype (jacobson_smul_lt_top ⊤) + convert! map_strictMono_of_injective N.injective_subtype (jacobson_smul_lt_top ⊤) on_goal 1 => rw [map_smul''] all_goals rw [Submodule.map_top, range_subtype] diff --git a/Mathlib/RingTheory/Jacobson/Ring.lean b/Mathlib/RingTheory/Jacobson/Ring.lean index 545f932032e2ff..6ebd25e6b2312f 100644 --- a/Mathlib/RingTheory/Jacobson/Ring.lean +++ b/Mathlib/RingTheory/Jacobson/Ring.lean @@ -173,7 +173,7 @@ theorem IsLocalization.isMaximal_iff_isMaximal_disjoint [H : IsJacobsonRing R] ( rw [← H.out hJ.left.isRadical, jacobson, Submodule.mem_toAddSubmonoid, Ideal.mem_sInf] at this push Not at this rcases this with ⟨I, ⟨hJI, hIm⟩, hI'⟩ - convert hIm + convert! hIm by_cases hJ : J = I.map (algebraMap R S) · rw [hJ, under_map_of_isPrime_disjoint (powers y) S hIm.isPrime] rwa [disjoint_powers_iff_notMem_of_isPrime] @@ -657,7 +657,7 @@ theorem comp_C_integral_of_surjective_of_isJacobsonRing {R : Type*} [CommRing R] rw [← hfg, coe_comp] at hf' exact Function.Surjective.of_comp hf' rw [RingHom.comp_assoc] at this - convert this + convert! this refine RingHom.ext fun x => ?_ exact ((renameEquiv R e).commutes' x).symm diff --git a/Mathlib/RingTheory/Kaehler/Basic.lean b/Mathlib/RingTheory/Kaehler/Basic.lean index f8825c1c4efed4..d2f1097820f797 100644 --- a/Mathlib/RingTheory/Kaehler/Basic.lean +++ b/Mathlib/RingTheory/Kaehler/Basic.lean @@ -206,8 +206,9 @@ def KaehlerDifferential.D : Derivation R S Ω[S⁄R] := rw [← LinearMap.map_smul_of_tower (ideal R S).toCotangent, ← LinearMap.map_smul_of_tower (ideal R S).toCotangent, ← map_add (ideal R S).toCotangent, Ideal.toCotangent_eq, pow_two] - convert Submodule.mul_mem_mul (KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R a :) - (KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R b :) using 1 + convert! + Submodule.mul_mem_mul (KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R a :) + (KaehlerDifferential.one_smul_sub_smul_one_mem_ideal R b :) using 1 simp only [Submodule.coe_add, TensorProduct.tmul_mul_tmul, mul_sub, sub_mul, mul_comm b, Submodule.coe_smul_of_tower, smul_sub, TensorProduct.smul_tmul', smul_eq_mul, mul_one] @@ -572,7 +573,7 @@ theorem KaehlerDifferential.quotKerTotalEquiv_symm_comp_D : (KaehlerDifferential.quotKerTotalEquiv R S).symm.toLinearMap.compDer (KaehlerDifferential.D R S) = KaehlerDifferential.derivationQuotKerTotal R S := by - convert (KaehlerDifferential.derivationQuotKerTotal R S).liftKaehlerDifferential_comp + convert! (KaehlerDifferential.derivationQuotKerTotal R S).liftKaehlerDifferential_comp end Presentation @@ -691,7 +692,7 @@ lemma KaehlerDifferential.ker_map_of_surjective (h : Function.Surjective (algebr Submodule.map_sup, ← kerTotal_eq, ← Submodule.comap_bot, Submodule.map_comap_eq_of_surjective (linearCombination_surjective _ _), bot_sup_eq, Submodule.map_span, ← Set.range_comp] - convert bot_sup_eq _ + convert! bot_sup_eq _ rw [Submodule.span_eq_bot]; simp open IsScalarTower (toAlgHom) @@ -740,7 +741,7 @@ lemma KaehlerDifferential.range_mapBaseChange : · convert_to (kerTotal A B).map (Finsupp.linearCombination B (D R B)) ≤ _ · rw [KaehlerDifferential.ker_map] congr 1 - convert Submodule.comap_id _ + convert! Submodule.comap_id _ · ext; simp rw [Submodule.map_le_iff_le_comap, kerTotal, Submodule.span_le] rintro f ((⟨⟨x, y⟩, rfl⟩ | ⟨⟨x, y⟩, rfl⟩) | ⟨x, rfl⟩) @@ -829,7 +830,7 @@ theorem KaehlerDifferential.range_kerCotangentToTensor rw [← TensorProduct.smul_tmul, ← Algebra.algebraMap_eq_smul_one, RingHom.mem_ker.mp this, TensorProduct.zero_tmul] · have : x i ≠ 0 ∧ algebraMap A B i = c := by - convert i.prop + convert! i.prop simp_rw [Finset.mem_filter, Finsupp.mem_support_iff] simp [RingHom.mem_ker, ha, this.2] diff --git a/Mathlib/RingTheory/Kaehler/JacobiZariski.lean b/Mathlib/RingTheory/Kaehler/JacobiZariski.lean index 8b1a760ee522bb..05ca6273a6ebc8 100644 --- a/Mathlib/RingTheory/Kaehler/JacobiZariski.lean +++ b/Mathlib/RingTheory/Kaehler/JacobiZariski.lean @@ -82,7 +82,7 @@ lemma Cotangent.exact : ext x obtain ⟨⟨x, hx⟩, rfl⟩ := Extension.Cotangent.mk_surjective x simp only [map_mk, val_mk, LinearMap.zero_apply, val_zero] - convert Q.ker.toCotangent.map_zero + convert! Q.ker.toCotangent.map_zero trans ((IsScalarTower.toAlgHom R _ _).comp (IsScalarTower.toAlgHom R P.Ring S)) x · congr refine MvPolynomial.algHom_ext fun i ↦ ?_ diff --git a/Mathlib/RingTheory/Kaehler/TensorProduct.lean b/Mathlib/RingTheory/Kaehler/TensorProduct.lean index 5b0145398db1a4..cdd675e28d7d12 100644 --- a/Mathlib/RingTheory/Kaehler/TensorProduct.lean +++ b/Mathlib/RingTheory/Kaehler/TensorProduct.lean @@ -224,8 +224,9 @@ then `Ω[B⁄S]` is the base change of `Ω[A⁄R]` along `R → S`. -/ lemma isBaseChange [h : Algebra.IsPushout R S A B] : IsBaseChange S ((map R S A B).restrictScalars R) := by - convert (TensorProduct.isBaseChange R Ω[A⁄R] S).comp - (IsBaseChange.ofEquiv (tensorKaehlerEquivBase R S A B)) + convert! + (TensorProduct.isBaseChange R Ω[A⁄R] S).comp + (IsBaseChange.ofEquiv (tensorKaehlerEquivBase R S A B)) refine LinearMap.ext fun x ↦ ?_ simp only [LinearMap.coe_restrictScalars, LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, mk_apply, tensorKaehlerEquivBase_tmul, one_smul] diff --git a/Mathlib/RingTheory/KrullDimension/NonZeroDivisors.lean b/Mathlib/RingTheory/KrullDimension/NonZeroDivisors.lean index d9b38899130523..f9485349cf4bc1 100644 --- a/Mathlib/RingTheory/KrullDimension/NonZeroDivisors.lean +++ b/Mathlib/RingTheory/KrullDimension/NonZeroDivisors.lean @@ -81,7 +81,7 @@ lemma ringKrullDim_add_natCard_le_ringKrullDim_mvPolynomial (σ : Type*) [Finite ringKrullDim R + Nat.card σ ≤ ringKrullDim (MvPolynomial σ R) := by induction σ using Finite.induction_empty_option with | of_equiv e H => - convert ← H using 1 + convert! ← H using 1 · rw [Nat.card_congr e] · exact ringKrullDim_eq_of_ringEquiv (renameEquiv _ e).toRingEquiv | h_empty => simp diff --git a/Mathlib/RingTheory/KrullDimension/PID.lean b/Mathlib/RingTheory/KrullDimension/PID.lean index 74c56d4b0bde82..370302852f63ef 100644 --- a/Mathlib/RingTheory/KrullDimension/PID.lean +++ b/Mathlib/RingTheory/KrullDimension/PID.lean @@ -51,5 +51,5 @@ lemma IsPrincipalIdealRing.height_eq_one_of_isMaximal {R : Type*} [CommRing R] [ · suffices h : (m.height : WithBot ℕ∞) ≤ 1 by norm_cast at h rw [← IsPrincipalIdealRing.ringKrullDim_eq_one _ h] exact Ideal.height_le_ringKrullDim_of_ne_top Ideal.IsPrime.ne_top' - · rw [Order.one_le_iff_pos, Ideal.height_eq_primeHeight, Ideal.primeHeight, Order.height_pos] - exact not_isMin_of_lt (b := ⊥) (Ideal.bot_lt_of_maximal m h) + · apply le_of_eq_of_le _ (Ideal.height_add_one_le_of_lt_of_isPrime (Ideal.bot_lt_of_maximal m h)) + simp diff --git a/Mathlib/RingTheory/KrullDimension/Polynomial.lean b/Mathlib/RingTheory/KrullDimension/Polynomial.lean index c51a9d6e6540a5..e7a74a3b40a9b9 100644 --- a/Mathlib/RingTheory/KrullDimension/Polynomial.lean +++ b/Mathlib/RingTheory/KrullDimension/Polynomial.lean @@ -120,7 +120,7 @@ lemma MvPolynomial.ringKrullDim_of_isNoetherianRing {ι : Type*} [Finite ι] : ringKrullDim (MvPolynomial ι R) = ringKrullDim R + Nat.card ι := by induction ι using Finite.induction_empty_option with | of_equiv e H => - convert ← H using 1 + convert! ← H using 1 · exact ringKrullDim_eq_of_ringEquiv (renameEquiv _ e).toRingEquiv · rw [Nat.card_congr e] | h_empty => simp diff --git a/Mathlib/RingTheory/LaurentSeries.lean b/Mathlib/RingTheory/LaurentSeries.lean index d016489916f2a9..9805e9fddab378 100644 --- a/Mathlib/RingTheory/LaurentSeries.lean +++ b/Mathlib/RingTheory/LaurentSeries.lean @@ -441,7 +441,7 @@ theorem intValuation_eq_of_coe (P : K[X]) : rw [Ideal.count_associates_factors_eq span_ne_zero.1 (Ideal.span_singleton_prime Polynomial.X_ne_zero |>.mpr prime_X) span_ne_zero.2, Ideal.count_associates_factors_eq] - on_goal 1 => convert (normalized_count_X_eq_of_coe hP).symm + on_goal 1 => convert! (normalized_count_X_eq_of_coe hP).symm exacts [Ideal.count_span_normalizedFactors_eq_of_normUnit hP Polynomial.normUnit_X prime_X, Ideal.count_span_normalizedFactors_eq_of_normUnit (by simp [hP]) normUnit_X X_prime, span_ne_zero'.1, (idealX K).isPrime, span_ne_zero'.2] @@ -469,8 +469,9 @@ theorem valuation_eq_LaurentSeries_valuation (P : K⟮X⟯) : refine RatFunc.induction_on' P ?_ intro f g h rw [Polynomial.valuation_of_mk K f h, RatFunc.mk_eq_mk' f h, Eq.comm] - convert @valuation_of_mk' K⟦X⟧ _ _ K⸨X⸩ _ _ _ (PowerSeries.idealX K) f - ⟨g, mem_nonZeroDivisors_iff_ne_zero.2 <| (by simp [h])⟩ + convert! + @valuation_of_mk' K⟦X⟧ _ _ K⸨X⸩ _ _ _ (PowerSeries.idealX K) f + ⟨g, mem_nonZeroDivisors_iff_ne_zero.2 <| (by simp [h])⟩ · simp [← IsScalarTower.algebraMap_apply K[X] K⟮X⟯ K⸨X⸩] exacts [intValuation_eq_of_coe _, intValuation_eq_of_coe _] @@ -769,7 +770,7 @@ theorem Cauchy.coeff_eventually_equal {ℱ : Filter K⸨X⸩} (hℱ : Cauchy ℱ constructor · have := (exists_lb_coeff_ne hℱ).choose_spec rw [Filter.eventually_iff] at this - convert this + convert! this ext simp only [Set.mem_iInter, Set.mem_setOf_eq]; rfl · rw [biInter_mem (Set.finite_Icc ℓ N)] diff --git a/Mathlib/RingTheory/LinearDisjoint.lean b/Mathlib/RingTheory/LinearDisjoint.lean index 817a5c486804c3..9eff591bf9b898 100644 --- a/Mathlib/RingTheory/LinearDisjoint.lean +++ b/Mathlib/RingTheory/LinearDisjoint.lean @@ -651,7 +651,7 @@ theorem _root_.Algebra.TensorProduct.not_isField_of_transcendental refine ⟨⟨a, by simp [fa]⟩, ⟨b, hf ?_⟩⟩ simp_rw [fb, Algebra.TensorProduct.includeRight_apply, f, Algebra.TensorProduct.mapOfCompatibleSMul_tmul] - convert ← (TensorProduct.smul_tmul (R := R[X]) (R' := R[X]) (M := A) (N := B) X 1 1).symm <;> + convert! ← (TensorProduct.smul_tmul (R := R[X]) (R' := R[X]) (M := A) (N := B) X 1 1).symm <;> (simp_rw [Algebra.smul_def, mul_one]; exact aeval_X _) have key3 := (Subalgebra.inclusion key2).comp (AlgEquiv.ofInjective gab htab).toAlgHom |>.toLinearMap.lift_rank_le_of_injective diff --git a/Mathlib/RingTheory/LittleWedderburn.lean b/Mathlib/RingTheory/LittleWedderburn.lean index 588558be698a30..20425e0914f877 100644 --- a/Mathlib/RingTheory/LittleWedderburn.lean +++ b/Mathlib/RingTheory/LittleWedderburn.lean @@ -92,7 +92,7 @@ private theorem center_eq_top [Finite D] (hD : InductionHyp D) : Subring.center rw [eval_sub, eval_X_pow, eval_one, ← key, Int.dvd_add_left this] at contra refine (Nat.le_of_dvd ?_ ?_).not_gt (sub_one_lt_natAbs_cyclotomic_eval (n := n) ?_ hq.ne') · exact tsub_pos_of_lt hq - · convert Int.natAbs_dvd_natAbs.mpr contra + · convert! Int.natAbs_dvd_natAbs.mpr contra clear_value q simp only [eq_comm, Int.natAbs_eq_iff, Nat.cast_sub hq.le, Nat.cast_one, neg_sub, true_or] · by_contra! h @@ -153,7 +153,7 @@ private theorem center_eq_top [Finite D] : Subring.center D = ⊤ := by rw [IH (Fintype.card R) _ R inferInstance rfl] · trivial rw [← hn, ← Subring.card_top D] - convert Set.card_lt_card hR + convert! Set.card_lt_card hR end LittleWedderburn diff --git a/Mathlib/RingTheory/LocalProperties/Basic.lean b/Mathlib/RingTheory/LocalProperties/Basic.lean index e332b43d3356e7..93684cdd70eae3 100644 --- a/Mathlib/RingTheory/LocalProperties/Basic.lean +++ b/Mathlib/RingTheory/LocalProperties/Basic.lean @@ -317,7 +317,7 @@ lemma RingHom.LocalizationAwayPreserves.respectsIso IsLocalization.away_of_isUnit_of_bijective _ isUnit_one (Equiv.refl _).bijective have : IsLocalization.Away (f 1) T := IsLocalization.away_of_isUnit_of_bijective _ (by simp) e.bijective - convert hP f 1 R T hf + convert! hP f 1 R T hf trans (IsLocalization.Away.map R T f 1).comp (algebraMap R R) · rw [IsLocalization.Away.map, IsLocalization.map_comp]; rfl · rfl @@ -327,7 +327,7 @@ lemma RingHom.LocalizationAwayPreserves.respectsIso IsLocalization.away_of_isUnit_of_bijective _ isUnit_one e.symm.bijective have : IsLocalization.Away (f 1) T := IsLocalization.away_of_isUnit_of_bijective _ (by simp) (Equiv.refl _).bijective - convert hP f 1 R T hf + convert! hP f 1 R T hf have : RingHomInvPair (e : R →+* S) e.symm := RingHomInvPair.of_ringEquiv _ have : (IsLocalization.Away.map R T f 1).comp e.symm.toRingHom = f := IsLocalization.map_comp .. @@ -431,8 +431,7 @@ lemma RingHom.OfLocalizationSpanTarget.ofIsLocalization apply hP _ s hs intro r obtain ⟨T, _, _, _, hT⟩ := hT r - convert hP'.1 _ - (Localization.algEquiv (R := S) (Submonoid.powers (r : S)) T).symm.toRingEquiv hT + convert! hP'.1 _ (Localization.algEquiv (R := S) (Submonoid.powers (r : S)) T).symm.toRingEquiv hT rw [← RingHom.comp_assoc, RingEquiv.toRingHom_eq_coe, AlgEquiv.toRingEquiv_toRingHom, Localization.coe_algEquiv_symm, IsLocalization.map_comp, RingHom.comp_id] diff --git a/Mathlib/RingTheory/LocalProperties/FinitePresentation.lean b/Mathlib/RingTheory/LocalProperties/FinitePresentation.lean new file mode 100644 index 00000000000000..38e4fd960fae26 --- /dev/null +++ b/Mathlib/RingTheory/LocalProperties/FinitePresentation.lean @@ -0,0 +1,51 @@ +/- +Copyright (c) 2026 Sihan Su. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Sihan Su, Yongle Hu, Yi Song +-/ +module + +public import Mathlib.Algebra.Module.FinitePresentation +public import Mathlib.RingTheory.Localization.Finiteness + +/-! +# `Module.FinitePresentation` is a local property + +In this file, we prove that `Module.FinitePresentation` is a local property. + +## Main results +* `Module.FinitePresentation.of_localizationSpan` : If there exists a set `{ r }` of `R` that + generates the unit ideal and such that `Mᵣ` is a finitely presented `Rᵣ`-module for each `r`, + then `M` is a finitely presented `R`-module. +-/ + +public section + +variable {R : Type*} [CommRing R] {M : Type*} [AddCommGroup M] [Module R M] (s : Set R) + +theorem Module.FinitePresentation.of_localizationSpan' (hs : Ideal.span s = ⊤) + {Mₚ : ∀ (_ : s), Type*} [∀ (g : s), AddCommGroup (Mₚ g)] [∀ (g : s), Module R (Mₚ g)] + {Rₚ : ∀ (_ : s), Type*} [∀ (g : s), CommRing (Rₚ g)] [∀ (g : s), Algebra R (Rₚ g)] + [∀ (g : s), IsLocalization.Away g.val (Rₚ g)] + [∀ (g : s), Module (Rₚ g) (Mₚ g)] [∀ (g : s), IsScalarTower R (Rₚ g) (Mₚ g)] + (ϕ : ∀ (g : s), M →ₗ[R] Mₚ g) [∀ (g : s), IsLocalizedModule (Submonoid.powers g.val) (ϕ g)] + (h : ∀ (g : s), Module.FinitePresentation (Rₚ g) (Mₚ g)) : + Module.FinitePresentation R M := by + have : Module.Finite R M := + Module.Finite.of_localizationSpan' (Rₚ := Rₚ) s hs ϕ (fun _ ↦ inferInstance) + obtain ⟨n, f, fsurj⟩ := Module.Finite.exists_fin' R M + rw [← Module.FinitePresentation.fg_ker_iff f fsurj] + refine f.ker.of_localizationSpan' s hs (Rₚ := Rₚ) + (fun g ↦ TensorProduct.mk R (Rₚ g) (Fin n → R) 1) (fun g ↦ ?_) + rw [LinearMap.localized'_ker_eq_ker_localizedMap (Rₚ g) (Submonoid.powers g.1) _ (ϕ g) f] + apply Module.FinitePresentation.fg_ker + rw [← LinearMap.range_eq_top] at fsurj ⊢ + simp [← LinearMap.localized'_range_eq_range_localizedMap (Rₚ g) (Submonoid.powers g.1), fsurj] + +/-- If there exists a set `{ r }` of `R` that generates the unit ideal and such that + `Mᵣ` is a finitely presented `Rᵣ`-module for each `r`, then `M` is a finitely presented + `R`-module. -/ +theorem Module.FinitePresentation.of_localizationSpan (hs : Ideal.span s = ⊤) + (h : ∀ g : s, Module.FinitePresentation (Localization.Away g.1) (LocalizedModule.Away g.1 M)) : + Module.FinitePresentation R M := + of_localizationSpan' s hs (fun g ↦ LocalizedModule.mkLinearMap (Submonoid.powers g.1) M) h diff --git a/Mathlib/RingTheory/LocalProperties/IntegrallyClosed.lean b/Mathlib/RingTheory/LocalProperties/IntegrallyClosed.lean index 3c879444d5d9d8..fa70ddb50a5a32 100644 --- a/Mathlib/RingTheory/LocalProperties/IntegrallyClosed.lean +++ b/Mathlib/RingTheory/LocalProperties/IntegrallyClosed.lean @@ -75,7 +75,7 @@ theorem IsIntegrallyClosed.of_localization_maximal [IsDomain R] · rintro ⟨p, rfl⟩ exact h p.asIdeal (Ring.ne_bot_of_isMaximal_of_not_isField p.isMaximal hf) · rw [iInf_range] - convert MaximalSpectrum.iInf_localization_eq_bot R (FractionRing R) + convert! MaximalSpectrum.iInf_localization_eq_bot R (FractionRing R) rw [subalgebra.ofField_eq, MaximalSpectrum.toPrimeSpectrum] theorem isIntegrallyClosed_ofLocalizationMaximal : diff --git a/Mathlib/RingTheory/LocalProperties/Projective.lean b/Mathlib/RingTheory/LocalProperties/Projective.lean index 2396844623e0ce..dd21844f8b3c84 100644 --- a/Mathlib/RingTheory/LocalProperties/Projective.lean +++ b/Mathlib/RingTheory/LocalProperties/Projective.lean @@ -56,7 +56,7 @@ theorem Module.lift_rank_of_isLocalizedModule_of_free have := (IsLocalizedModule.isBaseChange S Rₛ f).equiv.lift_rank_eq.symm simp only [rank_tensorProduct, rank_self, Cardinal.lift_one, one_mul, Cardinal.lift_lift] at this ⊢ - convert this + convert! this exact Cardinal.lift_umax theorem Module.finrank_of_isLocalizedModule_of_free @@ -92,7 +92,7 @@ theorem LinearMap.split_surjective_of_localization_maximal rw [LocalizedModule.map_id] have : LinearMap.id ∈ LinearMap.range (LinearMap.llcomp _ (LocalizedModule I.primeCompl N) _ _ (LocalizedModule.map I.primeCompl f)) := H I hI - convert this + convert! this · ext f constructor · intro hf @@ -137,7 +137,7 @@ theorem Module.projective_of_localization_maximal (H : ∀ (I : Ideal R) (_ : I. let f : N →ₗ[R] M := Finsupp.linearCombination R (Subtype.val : s → M) have hf : Function.Surjective f := by rw [← LinearMap.range_eq_top, Finsupp.range_linearCombination, Subtype.range_val] - convert hs + convert! hs have (I : Ideal R) (hI : I.IsMaximal) := letI := H I hI Module.projective_lifting_property (LocalizedModule.map I.primeCompl f) LinearMap.id diff --git a/Mathlib/RingTheory/LocalRing/Module.lean b/Mathlib/RingTheory/LocalRing/Module.lean index 14d5b3f5a407fc..a9f3caf4ab23f4 100644 --- a/Mathlib/RingTheory/LocalRing/Module.lean +++ b/Mathlib/RingTheory/LocalRing/Module.lean @@ -271,11 +271,11 @@ theorem IsLocalRing.linearIndependent_of_flat [Flat R M] {ι : Type u} (v : ι have a_eq i : a i j = a' i.1 := by simp_rw [a', dif_pos i.2] have hfn : f n = -(∑ i ∈ s, f i * a' i) * hj.unit⁻¹ := by rw [← hj.mul_left_inj, mul_assoc, hj.val_inv_mul, mul_one, eq_neg_iff_add_eq_zero] - convert hfa j + convert! hfa j simp_rw [a_eq, Finset.sum_coe_sort _ (fun i ↦ f i * a' i), s.sum_insert hn, n_def] let c (i : ι) : R := -(if i = n then 0 else a' i) * hj.unit⁻¹ specialize ih (v + (c · • v n)) ?_ ?_ - · convert (linearIndependent_add_smul_iff (c := Ideal.Quotient.mk _ ∘ c) (i := n.1) ?_).mpr h + · convert! (linearIndependent_add_smul_iff (c := Ideal.Quotient.mk _ ∘ c) (i := n.1) ?_).mpr h · ext; simp [tmul_add]; rfl simp_rw [Function.comp_def, c, if_pos, neg_zero, zero_mul, map_zero] · rw [Finset.sum_coe_sort _ (fun i ↦ f i • v i), s.sum_insert hn, add_comm, hfn] at hfv @@ -413,7 +413,7 @@ at every maximal ideal, then `M` is free of rank `n`. -/ apply IsLocalRing.linearCombination_bijective_of_flat rw [← (AlgebraTensorModule.cancelBaseChange _ _ P.ResidueField ..).comp_bijective, ← (AlgebraTensorModule.cancelBaseChange R (R ⧸ P) P.ResidueField ..).symm.comp_bijective] - convert ((b' ⟨P, ‹_›⟩).repr.lTensor _ ≪≫ₗ finsuppScalarRight _ _ P.ResidueField _).symm.bijective + convert! ((b' ⟨P, ‹_›⟩).repr.lTensor _ ≪≫ₗ finsuppScalarRight _ _ P.ResidueField _).symm.bijective refine funext fun r ↦ Finsupp.induction_linear r (by simp) (by simp +contextual) fun _ _ ↦ ?_ simp [smul_tmul', ← funext_iff.mp (hb _)] diff --git a/Mathlib/RingTheory/LocalRing/ResidueField/Fiber.lean b/Mathlib/RingTheory/LocalRing/ResidueField/Fiber.lean index dae55a28f2e1c8..321686cea80d76 100644 --- a/Mathlib/RingTheory/LocalRing/ResidueField/Fiber.lean +++ b/Mathlib/RingTheory/LocalRing/ResidueField/Fiber.lean @@ -64,9 +64,15 @@ and the actual set-theoretic fiber of `PrimeSpectrum S → PrimeSpectrum R` at ` abbrev Ideal.Fiber (p : Ideal R) [p.IsPrime] (S : Type*) [AddCommGroup S] [Module R S] : Type _ := p.ResidueField ⊗[R] S -instance (p : Ideal R) [p.IsPrime] (q : Ideal (p.Fiber S)) [q.IsPrime] : q.LiesOver p := +instance (q : Ideal (p.Fiber S)) [q.IsPrime] : q.LiesOver p := .trans _ (⊥ : Ideal p.ResidueField) _ +/-- If `q` is a prime ideal of `p.Fiber S`, then the localization `(p.Fiber S)_q` is an algebra +over the localization `R_p` since `p.Fiber S` is already an `R_p`-algebra. This `R_p`-algebra +structure on `(p.Fiber S)_q` agrees with the one coming from the fact that `q` lies over `p`. -/ +instance (q : Ideal (p.Fiber S)) [q.IsPrime] : Localization.AtPrime.IsLiesOverAlgebra p q where + algebraMap_eq := (Localization.localRingHom_unique p q _ (Ideal.over_def q p) fun _ ↦ rfl).symm + lemma Ideal.Fiber.exists_smul_eq_one_tmul (x : p.Fiber S) : ∃ r ∉ p, ∃ s, r • x = 1 ⊗ₜ[R] s := by obtain ⟨r, hr, s, e⟩ := Ideal.ResidueField.exists_smul_eq_tmul_one _ (Algebra.TensorProduct.comm _ _ _ x) @@ -111,7 +117,7 @@ noncomputable def PrimeSpectrum.preimageEquivFiber (p : PrimeSpectrum R) : ← Ideal.IsPrime.mul_mem_left_iff (x := algebraMap _ _ r), ← Algebra.smul_def, e] · simp · rw [← Ideal.mem_comap, ← PrimeSpectrum.comap_asIdeal] - convert hr + convert! hr exact (residueField_comap _).le ⟨q.comap (algebraMap _ _), rfl⟩ · simpa [-Algebra.algebraMap_self, -AlgHom.commutes, -AlgHom.map_algebraMap, -Ideal.ResidueField.map_algebraMap] @@ -165,8 +171,8 @@ noncomputable def PrimeSpectrum.preimageHomeomorphFiber (R S : Type*) [CommRing exact { __ := preimageOrderIsoFiber R S p continuous_toFun := by - convert (H.toHomeomorphOfSurjective - (preimageOrderIsoFiber R S p).symm.surjective).symm.continuous + convert! + (H.toHomeomorphOfSurjective (preimageOrderIsoFiber R S p).symm.surjective).symm.continuous ext1 x obtain ⟨x, rfl⟩ := (H.toHomeomorphOfSurjective (preimageOrderIsoFiber R S p).symm.surjective).surjective x diff --git a/Mathlib/RingTheory/LocalRing/ResidueField/Ideal.lean b/Mathlib/RingTheory/LocalRing/ResidueField/Ideal.lean index 4c497a043e39fc..fd4f6027c0ad69 100644 --- a/Mathlib/RingTheory/LocalRing/ResidueField/Ideal.lean +++ b/Mathlib/RingTheory/LocalRing/ResidueField/Ideal.lean @@ -140,6 +140,19 @@ lemma Ideal.algebraMap_residueField_surjective (I : Ideal R) [I.IsMaximal] : instance (I : Ideal R) [I.IsMaximal] : Module.Finite R I.ResidueField := .of_surjective (Algebra.linearMap _ _) I.algebraMap_residueField_surjective +/-- The equivalence between a field and the residue field of its prime ideal, +induced by the algebra map. -/ +noncomputable def Ideal.algEquivResidueFieldOfField {k : Type*} [Field k] + (p : Ideal k) [p.IsPrime] : k ≃ₐ[k] p.ResidueField := + AlgEquiv.ofBijective (Algebra.ofId k _) ⟨RingHom.injective _, + haveI : p.IsMaximal := by simpa [p.eq_bot_of_prime] using Ideal.bot_isMaximal + p.algebraMap_residueField_surjective⟩ + +@[simp] +lemma Ideal.algEquivResidueFieldOfField_apply {k : Type*} [Field k] (p : Ideal k) [p.IsPrime] + (x : k) : p.algEquivResidueFieldOfField x = algebraMap k p.ResidueField x := + rfl + lemma Ideal.surjectiveOnStalks_residueField (I : Ideal R) [I.IsPrime] : (algebraMap R I.ResidueField).SurjectiveOnStalks := (RingHom.surjectiveOnStalks_of_surjective Ideal.Quotient.mk_surjective).comp diff --git a/Mathlib/RingTheory/LocalRing/ResidueField/Instances.lean b/Mathlib/RingTheory/LocalRing/ResidueField/Instances.lean index 6e26c40fe75874..f3c37bcdb40462 100644 --- a/Mathlib/RingTheory/LocalRing/ResidueField/Instances.lean +++ b/Mathlib/RingTheory/LocalRing/ResidueField/Instances.lean @@ -35,7 +35,7 @@ instance [Algebra.IsSeparable (A ⧸ p) (B ⧸ q)] : ext x simp [RingHom.algebraMap_toAlgebra, ← IsScalarTower.algebraMap_apply] -instance [p.IsMaximal] [q.IsMaximal] [Algebra.IsSeparable p.ResidueField q.ResidueField] : +instance [Algebra.IsSeparable p.ResidueField q.ResidueField] : Algebra.IsSeparable (A ⧸ p) (B ⧸ q) := by refine Algebra.IsSeparable.of_equiv_equiv (.symm <| .ofBijective _ p.bijective_algebraMap_quotient_residueField) diff --git a/Mathlib/RingTheory/Localization/AsSubring.lean b/Mathlib/RingTheory/Localization/AsSubring.lean index ea364019aa7163..9cb5fec4087df7 100644 --- a/Mathlib/RingTheory/Localization/AsSubring.lean +++ b/Mathlib/RingTheory/Localization/AsSubring.lean @@ -112,7 +112,7 @@ theorem mem_range_mapToFractionRing_iff_ofField (B : Type*) [CommRing B] [Algebr x ∈ (mapToFractionRing K S B hS).range ↔ ∃ (a s : A) (_ : s ∈ S), x = algebraMap A K a * (algebraMap A K s)⁻¹ := by rw [mem_range_mapToFractionRing_iff] - convert Iff.rfl + convert! Iff.rfl congr rw [Units.val_inv_eq_inv_val] rfl diff --git a/Mathlib/RingTheory/Localization/AtPrime/Basic.lean b/Mathlib/RingTheory/Localization/AtPrime/Basic.lean index bf561bdba02b0e..1aa90ef816f916 100644 --- a/Mathlib/RingTheory/Localization/AtPrime/Basic.lean +++ b/Mathlib/RingTheory/Localization/AtPrime/Basic.lean @@ -209,7 +209,7 @@ it is the unique maximal ideal given by the local ring structure `AtPrime.isLoca theorem AtPrime.map_eq_maximalIdeal : Ideal.map (algebraMap R (Localization.AtPrime I)) I = IsLocalRing.maximalIdeal (Localization I.primeCompl) := by - convert congr_arg (Ideal.map _) AtPrime.under_maximalIdeal.symm + convert! congr_arg (Ideal.map _) AtPrime.under_maximalIdeal.symm rw [map_under I.primeCompl] lemma AtPrime.eq_maximalIdeal_iff_under_eq {J : Ideal (Localization.AtPrime I)} : @@ -483,7 +483,7 @@ theorem isPrime_map_of_liesOver [P.IsPrime] [P.LiesOver p] : (P.map (algebraMap isPrime_of_isPrime_disjoint _ _ _ inferInstance (Ideal.disjoint_primeCompl_of_liesOver P p) theorem map_eq_maximalIdeal : p.map (algebraMap R Rₚ) = maximalIdeal Rₚ := by - convert congr_arg (Ideal.map (algebraMap R Rₚ)) (under_maximalIdeal Rₚ p).symm + convert! congr_arg (Ideal.map (algebraMap R Rₚ)) (under_maximalIdeal Rₚ p).symm rw [map_under p.primeCompl] instance isMaximal_map : (p.map (algebraMap R Rₚ)).IsMaximal := by diff --git a/Mathlib/RingTheory/Localization/Away/Basic.lean b/Mathlib/RingTheory/Localization/Away/Basic.lean index 6a7eadfbfdecb7..a4ee8db93c0331 100644 --- a/Mathlib/RingTheory/Localization/Away/Basic.lean +++ b/Mathlib/RingTheory/Localization/Away/Basic.lean @@ -60,7 +60,7 @@ noncomputable def invSelf : S := @[simp] theorem mul_invSelf : algebraMap R S x * invSelf x = 1 := by - convert IsLocalization.mk'_mul_mk'_eq_one (M := Submonoid.powers x) (S := S) _ 1 + convert! IsLocalization.mk'_mul_mk'_eq_one (M := Submonoid.powers x) (S := S) _ 1 symm apply IsLocalization.mk'_one @@ -306,7 +306,7 @@ lemma commutes {R : Type*} [CommSemiring R] (S₁ S₂ T : Type*) [CommSemiring [IsLocalization.Away x S₁] [IsLocalization.Away y S₂] [IsLocalization.Away (algebraMap R S₂ x) T] : IsLocalization.Away (algebraMap R S₁ y) T := by - convert IsLocalization.commutes S₁ S₂ T (Submonoid.powers x) (Submonoid.powers y) + convert! IsLocalization.commutes S₁ S₂ T (Submonoid.powers x) (Submonoid.powers y) ext x simp diff --git a/Mathlib/RingTheory/Localization/BaseChange.lean b/Mathlib/RingTheory/Localization/BaseChange.lean index fd34209bf88d48..1ee7a99f5f08af 100644 --- a/Mathlib/RingTheory/Localization/BaseChange.lean +++ b/Mathlib/RingTheory/Localization/BaseChange.lean @@ -49,7 +49,7 @@ theorem isLocalizedModule_iff_isBaseChange : IsLocalizedModule S f ↔ IsBaseCha letI : Module A (LocalizedModule S M) := LocalizedModule.moduleOfIsLocalization .. have : IsBaseChange A (LocalizedModule.mkLinearMap S M) := IsLocalizedModule.isBaseChange S A _ let e := (this.equiv.symm.trans h.equiv).restrictScalars R - convert IsLocalizedModule.of_linearEquiv S (LocalizedModule.mkLinearMap S M) e + convert! IsLocalizedModule.of_linearEquiv S (LocalizedModule.mkLinearMap S M) e ext rw [LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply, LinearEquiv.restrictScalars_apply, LinearEquiv.trans_apply, IsBaseChange.equiv_symm_apply, @@ -117,9 +117,10 @@ instance (N N') [AddCommMonoid N] [Module R N] [AddCommMonoid N'] [Module R N'] IsLocalizedModule S (TensorProduct.map f g) := by let eM := IsLocalizedModule.linearEquiv S f (TensorProduct.mk R (Localization S) M 1) let eN := IsLocalizedModule.linearEquiv S g (TensorProduct.mk R (Localization S) N 1) - convert IsLocalizedModule.of_linearEquiv S (TensorProduct.mk R (Localization S) (M ⊗[R] N) 1) <| - (AlgebraTensorModule.distribBaseChange R (Localization S) ..).restrictScalars R ≪≫ₗ - (congr eM eN ≪≫ₗ TensorProduct.equivOfCompatibleSMul ..).symm + convert! + IsLocalizedModule.of_linearEquiv S (TensorProduct.mk R (Localization S) (M ⊗[R] N) 1) <| + (AlgebraTensorModule.distribBaseChange R (Localization S) ..).restrictScalars R ≪≫ₗ + (congr eM eN ≪≫ₗ TensorProduct.equivOfCompatibleSMul ..).symm ext; congrm (?_ ⊗ₜ ?_) <;> simp [LinearEquiv.eq_symm_apply, eM, eN] /-- If `A` is a localization of `R`, tensoring two `A`-modules over `A` is the same as @@ -206,11 +207,11 @@ instance {α} [IsLocalizedModule S f] : let e' : Localization S ⊗[R] (α →₀ M) ≃ₗ[R] (α →₀ M') := finsuppRight R R (Localization S) M α ≪≫ₗ Finsupp.mapRange.linearEquiv e suffices IsLocalizedModule S (e'.symm.toLinearMap ∘ₗ Finsupp.mapRange.linearMap f) by - convert this.of_linearEquiv (e := e') + convert! this.of_linearEquiv (e := e') ext simp rw [isLocalizedModule_iff_isBaseChange S (Localization S)] - convert TensorProduct.isBaseChange R (α →₀ M) (Localization S) using 1 + convert! TensorProduct.isBaseChange R (α →₀ M) (Localization S) using 1 ext a m apply (finsuppRight R R (Localization S) M α).injective ext b diff --git a/Mathlib/RingTheory/Localization/Basic.lean b/Mathlib/RingTheory/Localization/Basic.lean index cc570c4196e4cb..40fc2f722e7d2b 100644 --- a/Mathlib/RingTheory/Localization/Basic.lean +++ b/Mathlib/RingTheory/Localization/Basic.lean @@ -327,7 +327,7 @@ theorem isLocalization_of_algEquiv [Algebra R P] [IsLocalization M S] (h : S ≃ IsLocalization M P := by constructor; constructor · intro y - convert (IsLocalization.map_units S y).map h.toAlgHom.toRingHom.toMonoidHom + convert! (IsLocalization.map_units S y).map h.toAlgHom.toRingHom.toMonoidHom exact (h.commutes y).symm · intro y obtain ⟨⟨x, s⟩, e⟩ := IsLocalization.surj M (h.symm y) diff --git a/Mathlib/RingTheory/Localization/Defs.lean b/Mathlib/RingTheory/Localization/Defs.lean index d044fb59df3cc2..592c4ebd1f3d1f 100644 --- a/Mathlib/RingTheory/Localization/Defs.lean +++ b/Mathlib/RingTheory/Localization/Defs.lean @@ -739,14 +739,14 @@ theorem isLocalization_of_base_ringEquiv [IsLocalization M S] (h : R ≃+* P) : letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra constructor; constructor · rintro ⟨_, ⟨y, hy, rfl⟩⟩ - convert IsLocalization.map_units S ⟨y, hy⟩ + convert! IsLocalization.map_units S ⟨y, hy⟩ dsimp only [RingHom.algebraMap_toAlgebra, RingHom.comp_apply] exact congr_arg _ (h.symm_apply_apply _) · intro y obtain ⟨⟨x, s⟩, e⟩ := IsLocalization.surj M y refine ⟨⟨h x, _, _, s.prop, rfl⟩, ?_⟩ dsimp only [RingHom.algebraMap_toAlgebra, RingHom.comp_apply] at e ⊢ - convert e <;> exact h.symm_apply_apply _ + convert! e <;> exact h.symm_apply_apply _ · intro x y rw [RingHom.algebraMap_toAlgebra, RingHom.comp_apply, RingHom.comp_apply, IsLocalization.eq_iff_exists M S] @@ -759,7 +759,7 @@ theorem isLocalization_iff_of_base_ringEquiv (h : R ≃+* P) : letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra refine ⟨fun _ => isLocalization_of_base_ringEquiv M S h, ?_⟩ intro (H : IsLocalization (Submonoid.map (h : R ≃* P) M) S) - convert isLocalization_of_base_ringEquiv (Submonoid.map (h : R ≃* P) M) S h.symm + convert! isLocalization_of_base_ringEquiv (Submonoid.map (h : R ≃* P) M) S h.symm · rw [← Submonoid.map_coe_toMulEquiv, RingEquiv.coe_toMulEquiv_symm, ← Submonoid.comap_equiv_eq_map_symm, Submonoid.comap_map_eq_of_injective] exact h.toEquiv.injective @@ -774,7 +774,7 @@ theorem of_ringEquiv_left {S : Type*} [CommSemiring S] {K : Type*} [CommSemiring (hM : M₂.map e = M₁) (h : ∀ x, algebraMap R K x = algebraMap S K (e x)) [IsLocalization M₁ K] : IsLocalization M₂ K := by rw [IsLocalization.isLocalization_iff_of_base_ringEquiv _ _ e, hM] - convert (inferInstance : IsLocalization M₁ K) + convert! (inferInstance : IsLocalization M₁ K) exact Algebra.algebra_ext _ _ (by simp [RingHom.algebraMap_toAlgebra, h]) end diff --git a/Mathlib/RingTheory/Localization/Finiteness.lean b/Mathlib/RingTheory/Localization/Finiteness.lean index 84ac4fc6d6822d..47bb4f0edf9e92 100644 --- a/Mathlib/RingTheory/Localization/Finiteness.lean +++ b/Mathlib/RingTheory/Localization/Finiteness.lean @@ -6,6 +6,7 @@ Authors: Christian Merten module public import Mathlib.Algebra.Module.LocalizedModule.Int +public import Mathlib.Algebra.Module.LocalizedModule.Submodule public import Mathlib.RingTheory.Localization.Algebra public import Mathlib.RingTheory.Localization.AtPrime.Basic @@ -25,6 +26,11 @@ In this file we establish behaviour of `Module.Finite` under localizations. and `{ r }` is a finite set generating the unit ideal such that `Mᵣ` is a finite `Rᵣ`-module for each `r`, then `M` is a finite `R`-module. +## TODO + +* Move the results that `Module.Finite` over a semilocal ring is a local property from + `Mathlib/RingTheory/LocalProperties/Semilocal.lean` to this file. + -/ @[expose] public section @@ -74,10 +80,12 @@ theorem IsLocalization.smul_mem_finsetIntegerMultiple_span [Algebra R S] [Algebr obtain ⟨⟨_, a, ha₁, rfl⟩, ha₂⟩ := (IsLocalization.eq_iff_exists (M.map (algebraMap R S)) S').mp hx'' use (⟨a, ha₁⟩ : M) * (⟨y', hy'⟩ : M) - convert (Submodule.span R - (IsLocalization.finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s : Set S)).smul_mem + convert! + (Submodule.span R + (IsLocalization.finsetIntegerMultiple (Submonoid.map (algebraMap R S) M) s : + Set S)).smul_mem a hx' using 1 - convert ha₂.symm using 1 + convert! ha₂.symm using 1 · rw [Subtype.coe_mk, Submonoid.smul_def, Submonoid.coe_mul, ← smul_smul] exact Algebra.smul_def _ _ · exact Algebra.smul_def _ _ @@ -172,8 +180,8 @@ end variable {R : Type u} [CommSemiring R] {M : Type w} [AddCommMonoid M] [Module R M] /-- -If there exists a finite set `{ r }` of `R` such that `Mᵣ` is `Rᵣ`-finite for each `r`, -then `M` is a finite `R`-module. +If there exists a finite set `{ r }` of `R` that generates the unit ideal and such that `Mᵣ` is +`Rᵣ`-finite for each `r`, then `M` is a finite `R`-module. General version for any modules `Mᵣ` and rings `Rᵣ` satisfying the correct universal properties. See `Module.Finite.of_localizationSpan_finite` for the specialized version. @@ -210,8 +218,8 @@ theorem of_localizationSpan_finite' (t : Finset R) (ht : Ideal.span (t : Set R) exact hn₂ /-- -If there exists a set `{ r }` of `R` such that `Mᵣ` is `Rᵣ`-finite for each `r`, -then `M` is a finite `R`-module. +If there exists a set `{ r }` of `R` that generates the unit ideal and such that `Mᵣ` is `Rᵣ`-finite +for each `r`, then `M` is a finite `R`-module. General version for any modules `Mᵣ` and rings `Rᵣ` satisfying the correct universal properties. See `Module.Finite.of_localizationSpan_finite` for the specialized version. @@ -234,8 +242,8 @@ theorem of_localizationSpan' (t : Set R) (ht : Ideal.span t = ⊤) (fun g ↦ H ⟨g.val, hc g.property⟩) /-- -If there exists a finite set `{ r }` of `R` such that `Mᵣ` is `Rᵣ`-finite for each `r`, -then `M` is a finite `R`-module. +If there exists a finite set `{ r }` of `R` that generates the unit ideal and such that `Mᵣ` is +`Rᵣ`-finite for each `r`, then `M` is a finite `R`-module. See `of_localizationSpan` for a version without the finite set assumption. -/ @@ -247,8 +255,8 @@ theorem of_localizationSpan_finite (t : Finset R) (ht : Ideal.span (t : Set R) = LocalizedModule.mkLinearMap (Submonoid.powers g.val) M of_localizationSpan_finite' t ht f H -/-- If there exists a set `{ r }` of `R` such that `Mᵣ` is `Rᵣ`-finite for each `r`, -then `M` is a finite `R`-module. -/ +/-- If there exists a set `{ r }` of `R` that generates the unit ideal and such that `Mᵣ` is +`Rᵣ`-finite for each `r`, then `M` is a finite `R`-module. -/ theorem of_localizationSpan (t : Set R) (ht : Ideal.span t = ⊤) (H : ∀ (g : t), Module.Finite (Localization.Away g.val) (LocalizedModule.Away g.val M)) : @@ -261,12 +269,46 @@ end Finite end Module +namespace Submodule + +variable {R : Type u} [CommSemiring R] {M : Type v} [AddCommMonoid M] [Module R M] + {N : Submodule R M} + +lemma of_localizationSpan' (s : Set R) (hs : Ideal.span (s : Set R) = ⊤) + {Mₚ : ∀ (_ : s), Type*} [∀ (g : s), AddCommMonoid (Mₚ g)] [∀ (g : s), Module R (Mₚ g)] + {Rₚ : ∀ (_ : s), Type*} [∀ (g : s), CommSemiring (Rₚ g)] [∀ (g : s), Algebra R (Rₚ g)] + [∀ (g : s), IsLocalization.Away g.val (Rₚ g)] + [∀ (g : s), Module (Rₚ g) (Mₚ g)] [∀ (g : s), IsScalarTower R (Rₚ g) (Mₚ g)] + (ϕ : ∀ (g : s), M →ₗ[R] Mₚ g) [∀ (g : s), IsLocalizedModule (Submonoid.powers g.val) (ϕ g)] + (H : ∀ (g : s), (N.localized' (Rₚ g) (Submonoid.powers g.1) (ϕ g)).FG) : + N.FG := by + simp [← Module.Finite.iff_fg, Module.Finite.of_localizationSpan' s hs + (fun g ↦ N.toLocalized' (Rₚ g) (Submonoid.powers g.1) (ϕ g)) + (fun g ↦ Module.Finite.iff_fg.mpr (H g))] + +lemma of_localizationSpan (s : Set R) (hs : Ideal.span (s : Set R) = ⊤) + (H : ∀ (g : s), (localized (Submonoid.powers g.1) N).FG) : N.FG := + N.of_localizationSpan' s hs (fun g ↦ LocalizedModule.mkLinearMap (Submonoid.powers g.1) M) H + +variable (R' : Type*) [CommSemiring R'] [Algebra R R'] + {M' : Type*} [AddCommMonoid M'] [Module R M'] [Module R' M'] [IsScalarTower R R' M'] + (S : Submonoid R) [IsLocalization S R'] (f : M →ₗ[R] M') [IsLocalizedModule S f] + +lemma localized'_fg (h : N.FG) : (N.localized' R' S f).FG := by + rw [fg_def] at h ⊢ + rcases h with ⟨s, hfin, hspan⟩ + exact ⟨f '' s, hfin.image f, by rw [← hspan, localized'_span]⟩ + +lemma localized_fg (h : N.FG) : (N.localized S).FG := localized'_fg _ S _ h + +end Submodule + namespace Ideal variable {R : Type u} [CommSemiring R] -/-- If `I` is an ideal such that there exists a set `{ r }` of `R` such -that the image of `I` in `Rᵣ` is finitely generated for each `r`, then `I` is finitely +/-- If `I` is an ideal such that there exists a set `{ r }` of `R` that generates the unit ideal +and such that the image of `I` in `Rᵣ` is finitely generated for each `r`, then `I` is finitely generated. -/ lemma fg_of_localizationSpan {I : Ideal R} (t : Set R) (ht : Ideal.span t = ⊤) (H : ∀ (g : t), (I.map (algebraMap R (Localization.Away g.val))).FG) : I.FG := by diff --git a/Mathlib/RingTheory/Localization/FractionRing.lean b/Mathlib/RingTheory/Localization/FractionRing.lean index de83899e98af91..da773812892e92 100644 --- a/Mathlib/RingTheory/Localization/FractionRing.lean +++ b/Mathlib/RingTheory/Localization/FractionRing.lean @@ -600,7 +600,7 @@ theorem isFractionRing_iff_of_base_ringEquiv (h : R ≃+* P) : IsFractionRing R S ↔ @IsFractionRing P _ S _ ((algebraMap R S).comp h.symm.toRingHom).toAlgebra := by delta IsFractionRing - convert isLocalization_iff_of_base_ringEquiv (nonZeroDivisors R) S h + convert! isLocalization_iff_of_base_ringEquiv (nonZeroDivisors R) S h exact (MulEquivClass.map_nonZeroDivisors h).symm variable (R S : Type*) [CommSemiring R] [CommSemiring S] [Algebra R S] [h : IsFractionRing R S] diff --git a/Mathlib/RingTheory/Localization/Ideal.lean b/Mathlib/RingTheory/Localization/Ideal.lean index f23b9fe931088b..f2cb0211365cf5 100644 --- a/Mathlib/RingTheory/Localization/Ideal.lean +++ b/Mathlib/RingTheory/Localization/Ideal.lean @@ -265,7 +265,7 @@ lemma map_radical (I : Ideal R) : obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq M x simp only [← IsLocalization.mk'_pow, IsLocalization.mk'_mem_map_algebraMap_iff M] at hn ⊢ obtain ⟨s, hs, h⟩ := hn - refine ⟨s, hs, n + 1, by convert I.mul_mem_left (s ^ n * x) h; ring⟩ + refine ⟨s, hs, n + 1, by convert! I.mul_mem_left (s ^ n * x) h; ring⟩ theorem ideal_eq_iInf_under_map_away {S : Finset R} (hS : Ideal.span (α := R) S = ⊤) (I : Ideal R) : I = ⨅ f ∈ S, (I.map (algebraMap R (Localization.Away f))).under R := by @@ -317,7 +317,7 @@ theorem surjective_quotientMap_of_maximal_of_localization {I : Ideal S} [I.IsPri · have : I = ⊤ := by rw [Ideal.eq_top_iff_one] rw [Ideal.Quotient.eq_zero_iff_mem, Ideal.mem_comap] at hM - convert I.mul_mem_right (mk' S (1 : R) ⟨m, hm⟩) hM + convert! I.mul_mem_right (mk' S (1 : R) ⟨m, hm⟩) hM rw [← mk'_eq_mul_mk'_one, mk'_self] exact ⟨0, eq_comm.1 (by simp [Ideal.Quotient.eq_zero_iff_mem, this])⟩ · rw [Ideal.Quotient.maximal_ideal_iff_isField_quotient] at hI @@ -346,8 +346,9 @@ theorem bot_lt_under_prime [IsDomain R] (hM : M ≤ R⁰) (p : Ideal S) [hpp : p (hp0 : p ≠ ⊥) : ⊥ < p.under R := by haveI : IsDomain S := isDomain_of_le_nonZeroDivisors _ hM rw [← Ideal.comap_bot_of_injective (algebraMap R S) (IsLocalization.injective _ hM)] - convert (orderIsoOfPrime M S).lt_iff_lt.mpr (show (⟨⊥, Ideal.isPrime_bot⟩ : - { p : Ideal S // p.IsPrime }) < ⟨p, hpp⟩ from hp0.bot_lt) + convert! + (orderIsoOfPrime M S).lt_iff_lt.mpr + (show (⟨⊥, Ideal.isPrime_bot⟩ : { p : Ideal S // p.IsPrime }) < ⟨p, hpp⟩ from hp0.bot_lt) @[deprecated (since := "2026-04-09")] alias bot_lt_comap_prime := bot_lt_under_prime diff --git a/Mathlib/RingTheory/Localization/Integral.lean b/Mathlib/RingTheory/Localization/Integral.lean index 790fa6bfc3a36f..b275d814e3f4c3 100644 --- a/Mathlib/RingTheory/Localization/Integral.lean +++ b/Mathlib/RingTheory/Localization/Integral.lean @@ -312,7 +312,7 @@ lemma IsLocalization.Away.exists_isIntegral_mul_of_isIntegral_mk' (hx : IsIntegral R (IsLocalization.mk' Sₘ x a)) : ∃ n, IsIntegral R (r ^ n * x) := by refine IsLocalization.Away.exists_isIntegral_mul_of_isIntegral_algebraMap (Sₘ := Sₘ) hr ?_ obtain ⟨_, ⟨n, rfl⟩⟩ := a - convert (hr.pow n).algebraMap.mul hx + convert! (hr.pow n).algebraMap.mul hx exact (mk'_spec'_mk ..).symm /-- If `t` is integral over `R[1/t]`, then it is integral over `R`. -/ @@ -449,7 +449,8 @@ protected lemma IsLocalization.integralClosure (integralClosure Rf Sf) := by refine ⟨⟨?_, ?_, ?_⟩⟩ · rintro ⟨_, f, hf, rfl⟩ - convert (IsLocalization.map_units (S := Rf) ⟨f, hf⟩).map (algebraMap Rf (integralClosure Rf Sf)) + convert! + (IsLocalization.map_units (S := Rf) ⟨f, hf⟩).map (algebraMap Rf (integralClosure Rf Sf)) simp [← IsScalarTower.algebraMap_apply] · rintro ⟨s, hs⟩ obtain ⟨⟨x, _, m₁, hm₁, rfl⟩, e⟩ := IsLocalization.surj (Algebra.algebraMapSubmonoid S M) s @@ -481,7 +482,7 @@ protected lemma IsLocalization.Away.integralClosure [IsScalarTower (integralClosure R S) (integralClosure Rf Sf) Sf] [IsScalarTower R (integralClosure R S) (integralClosure Rf Sf)] : IsLocalization.Away (algebraMap R (integralClosure R S) f) (integralClosure Rf Sf) := by - convert IsLocalization.integralClosure (S := S) (Rf := Rf) (Sf := Sf) (.powers f) + convert! IsLocalization.integralClosure (S := S) (Rf := Rf) (Sf := Sf) (.powers f) simp end diff --git a/Mathlib/RingTheory/Localization/InvSubmonoid.lean b/Mathlib/RingTheory/Localization/InvSubmonoid.lean index 69e4627ebe4c72..d6b42c75f9d9ff 100644 --- a/Mathlib/RingTheory/Localization/InvSubmonoid.lean +++ b/Mathlib/RingTheory/Localization/InvSubmonoid.lean @@ -70,7 +70,7 @@ theorem mul_toInvSubmonoid (m : M) : algebraMap R S m * (toInvSubmonoid M S m : @[simp] theorem smul_toInvSubmonoid (m : M) : m • (toInvSubmonoid M S m : S) = 1 := by - convert mul_toInvSubmonoid M S m + convert! mul_toInvSubmonoid M S m ext rw [← Algebra.smul_def] rfl diff --git a/Mathlib/RingTheory/Localization/LocalizationLocalization.lean b/Mathlib/RingTheory/Localization/LocalizationLocalization.lean index bc9e49824819de..cb74f3db46f621 100644 --- a/Mathlib/RingTheory/Localization/LocalizationLocalization.lean +++ b/Mathlib/RingTheory/Localization/LocalizationLocalization.lean @@ -120,7 +120,7 @@ localization is a localization. -/ theorem localization_localization_isLocalization_of_has_all_units [IsLocalization N T] (H : ∀ x : S, IsUnit x → x ∈ N) : IsLocalization (N.comap (algebraMap R S)) T := by - convert localization_localization_isLocalization M N T using 1 + convert! localization_localization_isLocalization M N T using 1 dsimp [localizationLocalizationSubmodule] congr symm @@ -196,7 +196,7 @@ theorem isLocalization_of_submonoid_le (M N : Submonoid R) (h : M ≤ N) [IsLoca IsLocalization (N.map (algebraMap R S)) T where map_units := by rintro ⟨_, ⟨y, hy, rfl⟩⟩ - convert IsLocalization.map_units T ⟨y, hy⟩ + convert! IsLocalization.map_units T ⟨y, hy⟩ exact (IsScalarTower.algebraMap_apply _ _ _ _).symm surj y := by obtain ⟨⟨x, s⟩, e⟩ := IsLocalization.surj N y @@ -223,7 +223,7 @@ theorem isLocalization_of_submonoid_le (M N : Submonoid R) (h : M ≤ N) [IsLoca simpa only [mul_comm] using this simp_rw [IsLocalization.eq_iff_exists N T, IsLocalization.eq_iff_exists M S] intro ⟨a, e⟩ - exact ⟨a, 1, by convert e using 1 <;> simp⟩ + exact ⟨a, 1, by convert! e using 1 <;> simp⟩ /-- If `M ≤ N` are submonoids of `R` such that `∀ x : N, ∃ m : R, m * x ∈ M`, then the localization at `N` is equal to the localization of `M`. -/ diff --git a/Mathlib/RingTheory/MatrixAlgebra.lean b/Mathlib/RingTheory/MatrixAlgebra.lean index 53dc48fde3a691..6b41a99a0d7c73 100644 --- a/Mathlib/RingTheory/MatrixAlgebra.lean +++ b/Mathlib/RingTheory/MatrixAlgebra.lean @@ -175,11 +175,11 @@ theorem invFun_algebraMap (M : Matrix n n R) : invFun n R A (M.map (algebraMap R simp only [Algebra.algebraMap_eq_smul_one, smul_tmul, ← tmul_sum] congr conv_rhs => rw [matrix_eq_sum_single M] - convert Finset.sum_product (β := Matrix n n R) ..; simp + convert! Finset.sum_product (β := Matrix n n R) ..; simp theorem right_inv (M : Matrix n n A) : (toFunAlgHom n R A) (invFun n R A M) = M := by simp only [invFun, map_sum, toFunAlgHom_apply] - convert Finset.sum_product (β := Matrix n n A) .. + convert! Finset.sum_product (β := Matrix n n A) .. conv_lhs => rw [matrix_eq_sum_single M] simp diff --git a/Mathlib/RingTheory/MvPolynomial/EulerIdentity.lean b/Mathlib/RingTheory/MvPolynomial/EulerIdentity.lean index 6659601fbf3955..8bc83d1e7b65e8 100644 --- a/Mathlib/RingTheory/MvPolynomial/EulerIdentity.lean +++ b/Mathlib/RingTheory/MvPolynomial/EulerIdentity.lean @@ -39,7 +39,7 @@ protected lemma IsWeightedHomogeneous.pderiv [AddCancelCommMonoid M] {w : σ → simp_rw [single_eq_monomial, pderiv_monomial, one_mul] by_cases hi : m i = 0 · rw [hi, Nat.cast_zero, monomial_zero]; apply isWeightedHomogeneous_zero - convert isWeightedHomogeneous_monomial .. + convert! isWeightedHomogeneous_monomial .. rw [← add_right_cancel_iff (a := w i), h', ← hm, weight_sub_single_add hi] · rw [map_zero]; apply isWeightedHomogeneous_zero · rw [map_add]; exact hp.add hq diff --git a/Mathlib/RingTheory/MvPolynomial/Groebner.lean b/Mathlib/RingTheory/MvPolynomial/Groebner.lean index d377151ef834f4..ed9074f1d22a98 100644 --- a/Mathlib/RingTheory/MvPolynomial/Groebner.lean +++ b/Mathlib/RingTheory/MvPolynomial/Groebner.lean @@ -198,7 +198,7 @@ theorem div {ι : Type*} {b : ι → MvPolynomial σ R} · intro c hc i by_cases hc' : c ∈ r'.support · exact H'.2.2 c hc' i - · convert hf i + · convert! hf i classical have := MvPolynomial.support_add hc rw [Finset.mem_union, Classical.or_iff_not_imp_left] at this diff --git a/Mathlib/RingTheory/MvPolynomial/Homogeneous.lean b/Mathlib/RingTheory/MvPolynomial/Homogeneous.lean index 5d870524ddfc12..a8da1a458de839 100644 --- a/Mathlib/RingTheory/MvPolynomial/Homogeneous.lean +++ b/Mathlib/RingTheory/MvPolynomial/Homogeneous.lean @@ -209,7 +209,7 @@ lemma homogeneousSubmodule_one_pow (n : ℕ) : | zero => simp | add p q _ _ hp hq => exact Submodule.add_mem _ hp hq | monomial d r hr => - convert monomial_mem_homogeneousSubmodule_pow_degree _ _ + convert! monomial_mem_homogeneousSubmodule_pow_degree _ _ rw [Finsupp.degree_eq_weight_one, ← Pi.one_def, ← hr] end @@ -277,7 +277,7 @@ lemma eval₂ (hφ : φ.IsHomogeneous m) (f : R →+* MvPolynomial τ S) (g : σ intro i hi rw [← zero_add (n * m)] apply IsHomogeneous.mul (hf _) _ - convert IsHomogeneous.prod _ _ (fun k ↦ n * i k) _ + convert! IsHomogeneous.prod _ _ (fun k ↦ n * i k) _ · rw [Finsupp.mem_support_iff] at hi rw [← Finset.mul_sum, ← hφ hi, weight_apply] simp_rw [smul_eq_mul, Finsupp.sum, Pi.one_apply, mul_one] @@ -339,13 +339,13 @@ theorem rename_isHomogeneous {f : σ → τ} (h : φ.IsHomogeneous n) : apply IsHomogeneous.sum _ _ _ fun d hd ↦ isHomogeneous_monomial _ _ intro d hd apply (Finsupp.sum_mapDomain_index_addMonoidHom fun _ ↦ .id ℕ).trans - convert h (mem_support_iff.mp hd) + convert! h (mem_support_iff.mp hd) simp only [weight_apply, AddMonoidHom.id_apply, Pi.one_apply, smul_eq_mul, mul_one] theorem rename_isHomogeneous_iff {f : σ → τ} (hf : f.Injective) : (rename f φ).IsHomogeneous n ↔ φ.IsHomogeneous n := by refine ⟨fun h d hd ↦ ?_, rename_isHomogeneous⟩ - convert ← @h (d.mapDomain f) _ + convert! ← @h (d.mapDomain f) _ · simp only [weight_apply, Pi.one_apply, smul_eq_mul, mul_one] exact Finsupp.sum_mapDomain_index_inj (h := fun _ ↦ id) hf · rwa [coeff_rename_mapDomain f hf] @@ -375,7 +375,7 @@ lemma coeff_isHomogeneous_of_optionEquivLeft_symm have hφ : φ.IsHomogeneous n := hp.rename_isHomogeneous suffices IsHomogeneous (F (p.coeff i)) j by rwa [← (IsHomogeneous.rename_isHomogeneous_iff e.injective)] - convert hφ.finSuccEquiv_coeff_isHomogeneous i j h using 1 + convert! hφ.finSuccEquiv_coeff_isHomogeneous i j h using 1 dsimp only [φ, F', F, renameEquiv_apply] rw [finSuccEquiv_rename_finSuccEquiv, AlgEquiv.apply_symm_apply] simp @@ -534,12 +534,12 @@ theorem homogeneousComponent_mem : theorem coeff_homogeneousComponent (d : σ →₀ ℕ) : coeff d (homogeneousComponent n φ) = if d.degree = n then coeff d φ else 0 := by rw [degree_eq_weight_one] - convert coeff_weightedHomogeneousComponent n φ d + convert! coeff_weightedHomogeneousComponent n φ d theorem homogeneousComponent_apply : homogeneousComponent n φ = ∑ d ∈ φ.support with d.degree = n, monomial d (coeff d φ) := by simp_rw [degree_eq_weight_one] - convert weightedHomogeneousComponent_apply n φ + convert! weightedHomogeneousComponent_apply n φ theorem homogeneousComponent_isHomogeneous : (homogeneousComponent n φ).IsHomogeneous n := weightedHomogeneousComponent_isWeightedHomogeneous n φ diff --git a/Mathlib/RingTheory/MvPolynomial/Ideal.lean b/Mathlib/RingTheory/MvPolynomial/Ideal.lean index d799ff1235311a..48aec1bdae1c52 100644 --- a/Mathlib/RingTheory/MvPolynomial/Ideal.lean +++ b/Mathlib/RingTheory/MvPolynomial/Ideal.lean @@ -167,8 +167,9 @@ lemma span_leadingTerm_eq_span_monomial {B : Set (MvPolynomial σ R)} · rw [Set.mem_preimage, SetLike.mem_coe, ← C_mul_leadingCoeff_monomial_degree] exact Ideal.mul_mem_left _ _ (Ideal.subset_span ⟨_, hp, rfl⟩) · rw [Set.mem_preimage, SetLike.mem_coe] - convert (span <| m.leadingTerm '' B).mul_mem_left - (MvPolynomial.C (hB p hp).unit⁻¹.val) <| subset_span ⟨p, hp, rfl⟩ + convert! + (span <| m.leadingTerm '' B).mul_mem_left (MvPolynomial.C (hB p hp).unit⁻¹.val) <| + subset_span ⟨p, hp, rfl⟩ rw [← C_mul_leadingCoeff_monomial_degree, ← mul_assoc, ← map_mul, IsUnit.val_inv_mul, MvPolynomial.C_1, one_mul] diff --git a/Mathlib/RingTheory/MvPolynomial/Symmetric/FundamentalTheorem.lean b/Mathlib/RingTheory/MvPolynomial/Symmetric/FundamentalTheorem.lean index d42b8982aeae50..a20511d3dcb445 100644 --- a/Mathlib/RingTheory/MvPolynomial/Symmetric/FundamentalTheorem.lean +++ b/Mathlib/RingTheory/MvPolynomial/Symmetric/FundamentalTheorem.lean @@ -75,7 +75,7 @@ def invAccumulate (n m : ℕ) (s : Fin m → ℕ) (i : Fin n) : ℕ := lemma accumulate_rec {i n m : ℕ} (hin : i < n) (him : i + 1 < m) (t : Fin n → ℕ) : accumulate n m t ⟨i, Nat.lt_of_succ_lt him⟩ = t ⟨i, hin⟩ + accumulate n m t ⟨i + 1, him⟩ := by simp_rw [accumulate_apply] - convert (add_sum_erase _ _ _).symm + convert! (add_sum_erase _ _ _).symm · ext rw [mem_erase] simp_rw [mem_filter_univ, i.succ_le_iff, lt_iff_le_and_ne] @@ -305,11 +305,11 @@ lemma esymmAlgHom_fin_bijective (n : ℕ) : · exact accumulate_invAccumulate le_rfl hp.antitone_supDegree · rwa [Ne, leadingCoeff_eq_zero toLex.injective] obtain he | hne := eq_or_ne p (esymmAlgHomMonomial _ t <| p.leadingCoeff toLex) - · convert AlgHom.mem_range_self _ (monomial t <| p.leadingCoeff toLex) + · convert! AlgHom.mem_range_self _ (monomial t <| p.leadingCoeff toLex) have := (supDegree_sub_lt_of_leadingCoeff_eq toLex.injective hd.symm ?_).resolve_right hne · specialize ih _ this _ (Subalgebra.sub_mem _ hp <| isSymmetric_esymmAlgHomMonomial _ _) _ rfl · rwa [sub_ne_zero] - convert ← Subalgebra.add_mem _ ih ⟨monomial t (p.leadingCoeff toLex), rfl⟩ + convert! ← Subalgebra.add_mem _ ih ⟨monomial t (p.leadingCoeff toLex), rfl⟩ apply sub_add_cancel p · rw [leadingCoeff_esymmAlgHomMonomial t le_rfl] diff --git a/Mathlib/RingTheory/MvPolynomial/Tower.lean b/Mathlib/RingTheory/MvPolynomial/Tower.lean index cb4914cb023fac..2e1db24e749498 100644 --- a/Mathlib/RingTheory/MvPolynomial/Tower.lean +++ b/Mathlib/RingTheory/MvPolynomial/Tower.lean @@ -80,7 +80,7 @@ variable {R A} [CommSemiring R] [CommSemiring A] [Algebra R A] @[simp] theorem mvPolynomial_aeval_coe (S : Subalgebra R A) (x : σ → S) (p : MvPolynomial σ R) : - aeval (fun i => (x i : A)) p = aeval x p := by convert aeval_algebraMap_apply A x p + aeval (fun i => (x i : A)) p = aeval x p := by convert! aeval_algebraMap_apply A x p end CommSemiring diff --git a/Mathlib/RingTheory/MvPolynomial/WeightedHomogeneous.lean b/Mathlib/RingTheory/MvPolynomial/WeightedHomogeneous.lean index e9b69b061fa3cc..70d87eb2d9c186 100644 --- a/Mathlib/RingTheory/MvPolynomial/WeightedHomogeneous.lean +++ b/Mathlib/RingTheory/MvPolynomial/WeightedHomogeneous.lean @@ -350,14 +350,14 @@ theorem coeff_weightedHomogeneousComponent [DecidableEq M] (d : σ →₀ ℕ) : coeff d (weightedHomogeneousComponent w n φ) = if weight w d = n then coeff d φ else 0 := letI := Classical.decEq M - Finsupp.filter_apply (fun d : σ →₀ ℕ => weight w d = n) φ d |>.trans <| by convert rfl + Finsupp.filter_apply (fun d : σ →₀ ℕ => weight w d = n) φ d |>.trans <| by convert! rfl set_option backward.isDefEq.respectTransparency false in theorem weightedHomogeneousComponent_apply [DecidableEq M] : weightedHomogeneousComponent w n φ = ∑ d ∈ φ.support with weight w d = n, monomial d (coeff d φ) := letI := Classical.decEq M - Finsupp.filter_eq_sum (fun d : σ →₀ ℕ => weight w d = n) φ |>.trans <| by convert rfl + Finsupp.filter_eq_sum (fun d : σ →₀ ℕ => weight w d = n) φ |>.trans <| by convert! rfl /-- The `n` weighted homogeneous component of a polynomial is weighted homogeneous of weighted degree `n`. -/ @@ -507,7 +507,7 @@ theorem weightedHomogeneousComponent_directSum [DecidableEq M] ((DirectSum.coeLinearMap fun i : M => weightedHomogeneousSubmodule R w i) x) = x m := by classical rw [DirectSum.coeLinearMap_eq_dfinsuppSum, DFinsupp.sum, map_sum] - convert @Finset.sum_eq_single M (MvPolynomial σ R) _ (DFinsupp.support x) _ m _ _ + convert! @Finset.sum_eq_single M (MvPolynomial σ R) _ (DFinsupp.support x) _ m _ _ · rw [IsWeightedHomogeneous.weightedHomogeneousComponent_same (x m).prop] · intro n _ hmn exact IsWeightedHomogeneous.weightedHomogeneousComponent_ne m (x n).prop hmn.symm diff --git a/Mathlib/RingTheory/MvPowerSeries/Basic.lean b/Mathlib/RingTheory/MvPowerSeries/Basic.lean index bf39107c81059c..9b66b8e47090d6 100644 --- a/Mathlib/RingTheory/MvPowerSeries/Basic.lean +++ b/Mathlib/RingTheory/MvPowerSeries/Basic.lean @@ -154,7 +154,7 @@ theorem monomial_def [DecidableEq σ] (n : σ →₀ ℕ) : monomial n = LinearMap.single R (fun _ ↦ R) n := by rw [monomial] -- unify the `Decidable` arguments - convert rfl + convert! rfl set_option backward.isDefEq.respectTransparency false in theorem coeff_monomial [DecidableEq σ] (m n : σ →₀ ℕ) (a : R) : @@ -747,7 +747,7 @@ theorem coeff_eq_zero_of_constantCoeff_nilpotent {f : MvPowerSeries σ R} {m : simp only [add_comm m, Nat.add_le_add_iff_right, ← hk.1, ← sum_sdiff (hs), sum_eq_zero (s := s) hs'', add_zero] rw [← hs_def] - convert Finset.card_nsmul_le_sum (range n \ s) (fun x ↦ degree (k x)) 1 _ + convert! Finset.card_nsmul_le_sum (range n \ s) (fun x ↦ degree (k x)) 1 _ · simp only [smul_eq_mul, mul_one] · simp only [degree_eq_weight_one, map_sum] · simp only [hs_def, mem_filter, mem_sdiff, mem_range, not_and, and_imp] diff --git a/Mathlib/RingTheory/MvPowerSeries/Equiv.lean b/Mathlib/RingTheory/MvPowerSeries/Equiv.lean index 663c688cc3fb81..f507df622ee2a3 100644 --- a/Mathlib/RingTheory/MvPowerSeries/Equiv.lean +++ b/Mathlib/RingTheory/MvPowerSeries/Equiv.lean @@ -1,7 +1,7 @@ /- Copyright (c) 2026 Bingyu Xia. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. -Authors: Bingyu Xia +Authors: Bingyu Xia, Wenrong Zou -/ module @@ -9,6 +9,8 @@ public import Mathlib.Algebra.Lie.OfAssociative public import Mathlib.RingTheory.AdicCompletion.Algebra public import Mathlib.RingTheory.MvPolynomial.Ideal public import Mathlib.RingTheory.MvPowerSeries.Trunc +public import Mathlib.RingTheory.MvPowerSeries.Rename +public import Mathlib.RingTheory.PowerSeries.Substitution /-! # Equivalences related to power series rings @@ -129,7 +131,7 @@ theorem mk_truncTotal_toAdicCompletionInv {n : ℕ} ← smul_eq_mul, ← Ideal.Quotient.eq] simp only [Submodule.mapQ_eq_factor, Submodule.factor_eq_factor, Ideal.Quotient.mk_out] rw [← AdicCompletion.transitionMap_ideal_mk _ (Nat.lt_iff_add_one_le.mp h), eq_comm] - convert f.prop h; simp + convert! f.prop h; simp simp /-- The isomorphism from multivariate power series to the adic completion of @@ -157,3 +159,82 @@ lemma toAdicCompletionAlgEquiv_symm_apply end toAdicCompletion end MvPowerSeries + +section toMvPowerSeries + +variable {R σ τ : Type*} [CommSemiring R] {f : PowerSeries R} (i : σ) (r : R) + +open Function PowerSeries Filter Finsupp +namespace PowerSeries + +/-- Given a power series `p : R⟦X⟧` and an index `i`, we may view it as a +multivariate power series `toMvPowerSeries i p : MvPowerSeries σ R`. -/ +noncomputable +def toMvPowerSeries : PowerSeries R →ₐ[R] MvPowerSeries σ R := + MvPowerSeries.rename (fun _ ↦ i) + +theorem toMvPowerSeries_apply : f.toMvPowerSeries i = f.rename (fun _ ↦ i) := rfl + +@[simp] +theorem toMvPowerSeries_C : (C r).toMvPowerSeries i = MvPowerSeries.C r := by + rw [toMvPowerSeries_apply, C_apply, MvPowerSeries.rename_C] + +@[simp] +theorem toMvPowerSeries_X : X.toMvPowerSeries i = MvPowerSeries.X i (R := R) := by + rw [toMvPowerSeries_apply, X_apply, MvPowerSeries.rename_X] + +theorem toMvPowerSeries_injective (i : σ) : Function.Injective (toMvPowerSeries (R := R) i) := + MvPowerSeries.rename_injective (Embedding.punit i) + +theorem toMvPowerSeries_inj (i : σ) {p q : R⟦X⟧} : + p.toMvPowerSeries i = q.toMvPowerSeries i ↔ p = q := + (toMvPowerSeries_injective i).eq_iff + +section CommRing + +variable {R : Type*} [CommRing R] {f : R⟦X⟧} {i : σ} + +theorem toMvPowerSeries_eq_subst : f.toMvPowerSeries i = f.subst (MvPowerSeries.X i) := by + rw [toMvPowerSeries_apply, MvPowerSeries.rename_eq_subst, comp_def, subst] + +theorem subst_toMvPowerSeries {a : σ → MvPowerSeries τ R} (ha : MvPowerSeries.HasSubst a) : + (f.toMvPowerSeries i).subst a = f.subst (a i) := by + rw [toMvPowerSeries_eq_subst, subst, MvPowerSeries.subst_comp_subst_apply + (HasSubst.const (HasSubst.X _)) ha, MvPowerSeries.subst_X ha, subst] + +lemma toMvPowerSeries_coeff_eq_zero {d : σ →₀ ℕ} (hd : d i = 0) (hf : f.constantCoeff = 0) : + (f.toMvPowerSeries i).coeff d = 0 := by classical + rw [toMvPowerSeries_apply, MvPowerSeries.rename_eq_subst, subst_X_comp_const, + coeff_subst (HasSubst.X _), finsum_eq_zero_of_forall_eq_zero] + simp only [MvPowerSeries.X_pow_eq, MvPowerSeries.coeff_monomial, smul_eq_mul, mul_ite, mul_one, + mul_zero, ite_eq_right_iff] + intro _ a + subst a + simp_all + +theorem _root_.MvPowerSeries.HasSubst.toMvPowerSeries (hf : f.constantCoeff = 0) : + MvPowerSeries.HasSubst (f.toMvPowerSeries · (σ := σ)) (S := R) where + const_coeff := by simp_all [constantCoeff, toMvPowerSeries_apply] + coeff_zero d := Set.Finite.subset (Finite.of_fintype d.support) fun s => by + contrapose + simpa using fun hd ↦ toMvPowerSeries_coeff_eq_zero hd hf + +end CommRing + +end PowerSeries + +variable (f : σ → τ) [TendstoCofinite f] (a : σ) (p : R⟦X⟧) + +@[simp] +lemma MvPowerSeries.rename_comp_toMvPowerSeries : + (rename (R := R) f).comp (PowerSeries.toMvPowerSeries a) = + PowerSeries.toMvPowerSeries (f a) := by + ext + simp [toMvPowerSeries_apply, comp_def] + +@[simp] +lemma MvPowerSeries.rename_toMvPowerSeries : + (p.toMvPowerSeries a).rename f = p.toMvPowerSeries (f a) := + DFunLike.congr_fun (rename_comp_toMvPowerSeries ..) p + +end toMvPowerSeries diff --git a/Mathlib/RingTheory/MvPowerSeries/Evaluation.lean b/Mathlib/RingTheory/MvPowerSeries/Evaluation.lean index b6271b491a475c..e8d9e970f0c47b 100644 --- a/Mathlib/RingTheory/MvPowerSeries/Evaluation.lean +++ b/Mathlib/RingTheory/MvPowerSeries/Evaluation.lean @@ -270,7 +270,7 @@ theorem hasSum_eval₂ (hφ : Continuous φ) (ha : HasEval a) (f : MvPowerSeries (fun (d : σ →₀ ℕ) ↦ φ (coeff d f) * (d.prod fun s e => (a s) ^ e)) (MvPowerSeries.eval₂ φ a f) := by rw [← coe_eval₂Hom hφ ha, eval₂Hom_eq_extend hφ ha] - convert (hasSum_of_monomials_self f).map (eval₂Hom hφ ha) (?_) with d + convert! (hasSum_of_monomials_self f).map (eval₂Hom hφ ha) (?_) with d · simp only [Function.comp_apply, coe_eval₂Hom, ← MvPolynomial.coe_monomial, eval₂_coe, eval₂_monomial] · rw [coe_eval₂Hom]; exact continuous_eval₂ hφ ha diff --git a/Mathlib/RingTheory/MvPowerSeries/GaussNorm.lean b/Mathlib/RingTheory/MvPowerSeries/GaussNorm.lean index 20a9f26c05d19b..3cc3772f52a838 100644 --- a/Mathlib/RingTheory/MvPowerSeries/GaussNorm.lean +++ b/Mathlib/RingTheory/MvPowerSeries/GaussNorm.lean @@ -61,7 +61,7 @@ lemma gaussNorm_nonneg (vNonneg : ∀ a, v a ≥ 0) : 0 ≤ gaussNorm v c f := b by_cases h : HasGaussNorm v c f · trans v (constantCoeff f) · simp [vNonneg] - · convert (le_gaussNorm v c f h 0) + · convert! (le_gaussNorm v c f h 0) simp · simp [h] diff --git a/Mathlib/RingTheory/MvPowerSeries/Inverse.lean b/Mathlib/RingTheory/MvPowerSeries/Inverse.lean index a9083a5b70b841..ef53346a2f3738 100644 --- a/Mathlib/RingTheory/MvPowerSeries/Inverse.lean +++ b/Mathlib/RingTheory/MvPowerSeries/Inverse.lean @@ -93,7 +93,7 @@ theorem coeff_invOfUnit [DecidableEq σ] (n : σ →₀ ℕ) (φ : MvPowerSeries -↑u⁻¹ * ∑ x ∈ antidiagonal n, if x.2 < n then coeff x.1 φ * coeff x.2 (invOfUnit φ u) else 0 := by - convert coeff_inv_aux n (↑u⁻¹) φ + convert! coeff_inv_aux n (↑u⁻¹) φ @[simp] theorem constantCoeff_invOfUnit (φ : MvPowerSeries σ R) (u : Rˣ) : diff --git a/Mathlib/RingTheory/MvPowerSeries/LinearTopology.lean b/Mathlib/RingTheory/MvPowerSeries/LinearTopology.lean index 468dd004e88803..449d92e4eab269 100644 --- a/Mathlib/RingTheory/MvPowerSeries/LinearTopology.lean +++ b/Mathlib/RingTheory/MvPowerSeries/LinearTopology.lean @@ -125,7 +125,7 @@ lemma hasBasis_nhds_zero [IsLinearTopology R R] [IsLinearTopology Rᵐᵒᵖ R] · intro ⟨D, I⟩ ⟨hD, hI⟩ refine ⟨⟨I, Finset.sup hD.toFinset id⟩, hI, fun f hf d hd ↦ ?_⟩ rw [SetLike.mem_coe, mem_basis_iff] at hf - convert hf _ <| Finset.le_sup (hD.mem_toFinset.mpr hd) + convert! hf _ <| Finset.le_sup (hD.mem_toFinset.mpr hd) · intro ⟨I, d⟩ hI refine ⟨⟨Iic d, I⟩, ⟨finite_Iic d, hI⟩, ?_⟩ simpa [basis, coeff_apply, Iic, Set.pi] using subset_rfl diff --git a/Mathlib/RingTheory/MvPowerSeries/NoZeroDivisors.lean b/Mathlib/RingTheory/MvPowerSeries/NoZeroDivisors.lean index 4bc05deee716f2..92710c44b43b68 100644 --- a/Mathlib/RingTheory/MvPowerSeries/NoZeroDivisors.lean +++ b/Mathlib/RingTheory/MvPowerSeries/NoZeroDivisors.lean @@ -61,7 +61,7 @@ theorem mem_nonZeroDivisorsRight_of_constantCoeff {φ : MvPowerSeries σ R} intro e he rw [map_zero, ← mul_right_mem_nonZeroDivisorsRight_eq_zero_iff hφ, ← map_zero (f := coeff e), ← hx] - convert (coeff_mul e x φ).symm + convert! (coeff_mul e x φ).symm rw [Finset.sum_eq_single (e, 0), coeff_zero_eq_constantCoeff] · rintro ⟨u, _⟩ huv _ suffices u < e by simp only [he u this, zero_mul, map_zero] @@ -82,7 +82,7 @@ theorem mem_nonZeroDivisorsLeft_of_constantCoeff {φ : MvPowerSeries σ R} intro e he rw [map_zero, ← mul_left_mem_nonZeroDivisorsLeft_eq_zero_iff hφ, ← map_zero (f := coeff e), ← hx] - convert (coeff_mul e φ x).symm + convert! (coeff_mul e φ x).symm rw [Finset.sum_eq_single (0, e), coeff_zero_eq_constantCoeff] · rintro ⟨_, u⟩ huv _ suffices u < e by simp only [he u this, mul_zero, map_zero] diff --git a/Mathlib/RingTheory/MvPowerSeries/Order.lean b/Mathlib/RingTheory/MvPowerSeries/Order.lean index c97000f1046738..bf7d747a7d0cea 100644 --- a/Mathlib/RingTheory/MvPowerSeries/Order.lean +++ b/Mathlib/RingTheory/MvPowerSeries/Order.lean @@ -491,7 +491,7 @@ theorem one_le_order_iff_constCoeff_eq_zero : theorem order_ne_zero_iff_constCoeff_eq_zero : f.order ≠ 0 ↔ f.constantCoeff = 0 := by - rw [← ENat.one_le_iff_ne_zero, one_le_order_iff_constCoeff_eq_zero] + rw [← Order.one_le_iff_ne_zero, one_le_order_iff_constCoeff_eq_zero] theorem le_order_pow_of_constantCoeff_eq_zero (n : ℕ) (hf : f.constantCoeff = 0) : n ≤ (f ^ n).order := by diff --git a/Mathlib/RingTheory/MvPowerSeries/Substitution.lean b/Mathlib/RingTheory/MvPowerSeries/Substitution.lean index b9a86ed1598f08..d9f8f02c1413cc 100644 --- a/Mathlib/RingTheory/MvPowerSeries/Substitution.lean +++ b/Mathlib/RingTheory/MvPowerSeries/Substitution.lean @@ -134,7 +134,7 @@ protected theorem HasSubst.map {a : σ → MvPowerSeries τ R} (ha : HasSubst a) theorem HasSubst.smul_X (a : σ → R) : HasSubst (a • X : σ → MvPowerSeries σ R) := by - convert HasSubst.X.mul_left (fun s ↦ algebraMap R (MvPowerSeries σ R) (a s)) + convert! HasSubst.X.mul_left (fun s ↦ algebraMap R (MvPowerSeries σ R) (a s)) simp [funext_iff, algebra_compatible_smul (MvPowerSeries σ R)] /-- Families of `MvPowerSeries` that can be substituted, as an `Ideal` -/ @@ -207,7 +207,7 @@ theorem substAlgHom_eq_aeval (ha : HasSubst a) : (substAlgHom ha : MvPowerSeries σ R → MvPowerSeries τ S) = MvPowerSeries.aeval ha.hasEval := by simp only [substAlgHom, coe_aeval ha.hasEval] - convert coe_aeval (R := R) (hasSubst_iff_hasEval_of_discreteTopology.mp ha) <;> + convert! coe_aeval (R := R) (hasSubst_iff_hasEval_of_discreteTopology.mp ha) <;> exact DiscreteUniformity.eq_bot.symm @[simp] @@ -552,7 +552,7 @@ theorem rescale_zero : split_ifs with h · simp [h, coeff_apply, ← @coeff_zero_eq_constantCoeff_apply, coeff_apply] · simp only [coeff_apply] - convert zero_mul _ + convert! zero_mul _ simp only [DFunLike.ext_iff, not_forall, Finsupp.coe_zero, Pi.zero_apply] at h obtain ⟨s, h⟩ := h simp only [Finsupp.prod] @@ -638,4 +638,20 @@ end CommRing end rescale +section + +variable {x : ℕ → MvPowerSeries σ R} + [UniformSpace R] [DiscreteUniformity R] [UniformSpace S] [DiscreteUniformity S] + +lemma subst_tsum (hx : Summable x) (ha : HasSubst a) : + (∑' i, x i).subst a = ∑' i, ((x i).subst a) := by + rw [← coe_substAlgHom ha, substAlgHom_eq_aeval ha, hx.map_tsum _ <| continuous_aeval _] + +lemma summable_subst (hx : Summable x) (ha : HasSubst a) : + Summable fun i => (x i).subst a := by + rw [← coe_substAlgHom ha, substAlgHom_eq_aeval ha] + exact hx.map _ <| continuous_aeval ha.hasEval + +end + end MvPowerSeries diff --git a/Mathlib/RingTheory/Nilpotent/GeometricallyReduced.lean b/Mathlib/RingTheory/Nilpotent/GeometricallyReduced.lean index 6fc19d4f8192ee..2b91723957bb42 100644 --- a/Mathlib/RingTheory/Nilpotent/GeometricallyReduced.lean +++ b/Mathlib/RingTheory/Nilpotent/GeometricallyReduced.lean @@ -7,15 +7,22 @@ module public import Mathlib.FieldTheory.IsAlgClosed.AlgebraicClosure public import Mathlib.RingTheory.Flat.Basic +public import Mathlib.RingTheory.LocalRing.ResidueField.Ideal /-! # Geometrically reduced algebras In this file we introduce geometrically reduced algebras. -For a field `k`, we say that a `k`-algebra `A` is geometrically reduced (`IsGeometricallyReduced`) -if the tensor product `AlgebraicClosure k ⊗[k] A` is reduced. +For a commutative ring `R` and an `R`-algebra `A`, we say that `A` is geometrically reduced +(`IsGeometricallyReduced`) if for every prime ideal `p` of `R`, the base change of `A` +to an algebraic closure of `κ(p)` is reduced. +In the case of `R = k` a field, this is equivalent to `AlgebraicClosure k ⊗[k] A` being reduced. ## Main results + +- `Algebra.isGeometricallyReduced_field_iff` : for a field `k` and a commutative `k`-algebra `A`, + `A` is geometrically reduced iff `AlgebraicClosure k ⊗[k] A` is reduced. + - `IsGeometricallyReduced.of_forall_fg`: for a field `k` and a commutative `k`-algebra `A`, if all finitely generated subalgebras `B` of `A` are geometrically reduced, then `A` is geometrically reduced. @@ -26,8 +33,8 @@ if the tensor product `AlgebraicClosure k ⊗[k] A` is reduced. equivalent (see TODO). ## TODO -- Prove that if `A` is a geometrically reduced `k`-algebra, then for every field extension `K` of - `k` the `K`-algebra `K ⊗[k] A` is reduced. +- Prove that if `A` is a geometrically reduced `R`-algebra, then for every `R`-algebra `K` that is + a field, the tensor product `K ⊗[R] A` is reduced. (@Thmoas-Guan) -/ @@ -41,30 +48,44 @@ namespace Algebra variable {k A : Type*} [Field k] [Ring A] [Algebra k A] -/-- The `k`-algebra `A` is geometrically reduced iff its base change to `AlgebraicClosure k` is - reduced. -/ +/-- An `R`-algebra `A` is geometrically reduced iff for every prime ideal `p` of R` + the base change to `AlgebraicClosure p.ResidueField` is reduced. -/ @[mk_iff] -class IsGeometricallyReduced (k A : Type*) [Field k] [Ring A] [Algebra k A] : Prop where - isReduced_algebraicClosure_tensorProduct : IsReduced (AlgebraicClosure k ⊗[k] A) +class IsGeometricallyReduced (R A : Type*) [CommRing R] [Ring A] [Algebra R A] : Prop where + isReduced_algebraicClosure_tensorProduct (p : Ideal R) [p.IsPrime] : + IsReduced (AlgebraicClosure p.ResidueField ⊗[R] A) attribute [instance] IsGeometricallyReduced.isReduced_algebraicClosure_tensorProduct +section Field + +lemma isGeometricallyReduced_field_iff (k A : Type*) [Field k] [Ring A] [Algebra k A] : + IsGeometricallyReduced k A ↔ IsReduced (AlgebraicClosure k ⊗[k] A) := by + let e (p : Ideal k) [p.IsPrime] : AlgebraicClosure k ≃ₐ[k] AlgebraicClosure p.ResidueField := + have := p.algEquivResidueFieldOfField.isAlgebraic + IsAlgClosure.equiv k _ _ + refine ⟨fun ⟨h⟩ ↦ ?_, fun h ↦ ⟨fun p hp ↦ ?_⟩⟩ + · exact isReduced_of_injective _ (Algebra.TensorProduct.congr (e ⊥) AlgEquiv.refl).injective + · exact isReduced_of_injective _ (Algebra.TensorProduct.congr (e p).symm AlgEquiv.refl).injective + instance (k A K : Type*) [Field k] [Ring A] [Algebra k A] [Field K] [Algebra k K] - [Algebra.IsAlgebraic k K] [IsGeometricallyReduced k A] : IsReduced (K ⊗[k] A) := - isReduced_of_injective + [Algebra.IsAlgebraic k K] [IsGeometricallyReduced k A] : IsReduced (K ⊗[k] A) := by + have := (isGeometricallyReduced_field_iff k A).mp ‹_› + exact isReduced_of_injective (Algebra.TensorProduct.map ((IsAlgClosed.lift : K →ₐ[k] AlgebraicClosure k)) 1) (Module.Flat.rTensor_preserves_injective_linearMap _ (RingHom.injective _)) lemma IsGeometricallyReduced.of_injective {B : Type*} [Ring B] [Algebra k B] (f : A →ₐ[k] B) - (hf : Function.Injective f) [IsGeometricallyReduced k B] : IsGeometricallyReduced k A := - ⟨isReduced_of_injective (Algebra.TensorProduct.map 1 f) - (Module.Flat.lTensor_preserves_injective_linearMap _ hf)⟩ + (hf : Function.Injective f) [IsGeometricallyReduced k B] : IsGeometricallyReduced k A := by + rw [isGeometricallyReduced_field_iff] + exact isReduced_of_injective (Algebra.TensorProduct.map 1 f) + (Module.Flat.lTensor_preserves_injective_linearMap _ hf) variable (k) in theorem isReduced_of_isGeometricallyReduced [IsGeometricallyReduced k A] : IsReduced A := isReduced_of_injective (Algebra.TensorProduct.includeRight : A →ₐ[k] (AlgebraicClosure k) ⊗[k] A) - (Algebra.TensorProduct.includeRight_injective <| FaithfulSMul.algebraMap_injective _ _) + (Algebra.TensorProduct.includeRight_injective (RingHom.injective _)) /-- If all finitely generated subalgebras of `A` are geometrically reduced, then `A` is geometrically reduced. -/ @@ -72,7 +93,9 @@ theorem isReduced_of_isGeometricallyReduced [IsGeometricallyReduced k A] : IsRed theorem IsGeometricallyReduced.of_forall_fg (h : ∀ B : Subalgebra k A, B.FG → IsGeometricallyReduced k B) : IsGeometricallyReduced k A := by - simp_rw [isGeometricallyReduced_iff] at h - exact ⟨IsReduced.tensorProduct_of_flat_of_forall_fg h⟩ + simp_rw [isGeometricallyReduced_field_iff] at h ⊢ + exact IsReduced.tensorProduct_of_flat_of_forall_fg h + +end Field end Algebra diff --git a/Mathlib/RingTheory/Noetherian/Basic.lean b/Mathlib/RingTheory/Noetherian/Basic.lean index a2667bc87c203e..8e31fb6142f586 100644 --- a/Mathlib/RingTheory/Noetherian/Basic.lean +++ b/Mathlib/RingTheory/Noetherian/Basic.lean @@ -75,6 +75,10 @@ theorem isNoetherian_of_surjective {σ : R →+* S} [RingHomSurjective σ] (f : have : (s.comap f).map f = s := Submodule.map_comap_eq_self <| hf.symm ▸ le_top this ▸ (IsNoetherian.noetherian _).map _⟩ +instance isNoetherian_map {σ : R →+* S} [RingHomSurjective σ] {s : Submodule R M} + (f : M →ₛₗ[σ] P) [IsNoetherian R s] : IsNoetherian S (Submodule.map f s) := + isNoetherian_of_surjective (f.submoduleMap s) (by simp [LinearMap.submoduleMap]) + instance isNoetherian_range {σ : R →+* S} [RingHomSurjective σ] (f : M →ₛₗ[σ] P) [IsNoetherian R M] : IsNoetherian S (LinearMap.range f) := isNoetherian_of_surjective _ f.range_rangeRestrict diff --git a/Mathlib/RingTheory/Noetherian/Defs.lean b/Mathlib/RingTheory/Noetherian/Defs.lean index 66ddf1f73601e7..70d1d93cd80724 100644 --- a/Mathlib/RingTheory/Noetherian/Defs.lean +++ b/Mathlib/RingTheory/Noetherian/Defs.lean @@ -140,7 +140,7 @@ theorem isNoetherian_iff_fg_wellFounded : intro N obtain ⟨⟨N₀, h₁⟩, e : N₀ ≤ N, h₂⟩ := WellFounded.has_min H.wf { N' : α | N'.1 ≤ N } ⟨⟨⊥, Submodule.fg_bot⟩, @bot_le _ _ _ N⟩ - convert h₁ + convert! h₁ refine (e.antisymm ?_).symm by_contra h₃ obtain ⟨x, hx₁ : x ∈ N, hx₂ : x ∉ N₀⟩ := Set.not_subset.mp h₃ diff --git a/Mathlib/RingTheory/NonUnitalSubsemiring/Basic.lean b/Mathlib/RingTheory/NonUnitalSubsemiring/Basic.lean index aa2d134443da6e..4d9b88ed2cf504 100644 --- a/Mathlib/RingTheory/NonUnitalSubsemiring/Basic.lean +++ b/Mathlib/RingTheory/NonUnitalSubsemiring/Basic.lean @@ -392,7 +392,7 @@ variable [NonUnitalNonAssocSemiring S] theorem mem_map_equiv {f : R ≃+* S} {K : NonUnitalSubsemiring R} {x : S} : x ∈ K.map (f : R →ₙ+* S) ↔ f.symm x ∈ K := by - convert @Set.mem_image_equiv _ _ (↑K) f.toEquiv x + convert! @Set.mem_image_equiv _ _ (↑K) f.toEquiv x theorem map_equiv_eq_comap_symm (f : R ≃+* S) (K : NonUnitalSubsemiring R) : K.map (f : R →ₙ+* S) = K.comap f.symm := diff --git a/Mathlib/RingTheory/Norm/Transitivity.lean b/Mathlib/RingTheory/Norm/Transitivity.lean index d573878929c064..298a5e942acb68 100644 --- a/Mathlib/RingTheory/Norm/Transitivity.lean +++ b/Mathlib/RingTheory/Norm/Transitivity.lean @@ -96,7 +96,7 @@ lemma det_mul_corner_pow : pow_one, det_one, smul_eq_mul, mul_one] -- `Decidable (P = Q)` diamond induced by `Prop.linearOrder`, which is classical, when `P` and `Q` -- are themselves decidable. - convert rfl + convert! rfl /-- A matrix with X added to the corner. -/ noncomputable def cornerAddX : Matrix m m S[X] := diff --git a/Mathlib/RingTheory/NormalClosure.lean b/Mathlib/RingTheory/NormalClosure.lean index e412603b1c5bab..03624140bf835a 100644 --- a/Mathlib/RingTheory/NormalClosure.lean +++ b/Mathlib/RingTheory/NormalClosure.lean @@ -126,6 +126,8 @@ instance : IsGalois K (FractionRing T) := by variable [IsDedekindDomain S] +set_option linter.overlappingInstances false + instance : Module.Finite S T := IsIntegralClosure.finite S L E T diff --git a/Mathlib/RingTheory/Nullstellensatz.lean b/Mathlib/RingTheory/Nullstellensatz.lean index 7022004ad776e4..104ec198650cdd 100644 --- a/Mathlib/RingTheory/Nullstellensatz.lean +++ b/Mathlib/RingTheory/Nullstellensatz.lean @@ -102,11 +102,11 @@ theorem mem_vanishingIdeal_singleton_iff (x : σ → K) (p : MvPolynomial σ k) ⟨fun h => h x rfl, fun hpx _ hy => hy.symm ▸ hpx⟩ instance {x : σ → K} : (vanishingIdeal k {x} : Ideal (MvPolynomial σ k)).IsPrime := by - convert RingHom.ker_isPrime (aeval (R := k) x) + convert! RingHom.ker_isPrime (aeval (R := k) x) ext; simp instance {x : σ → K} : (vanishingIdeal K {x} : Ideal (MvPolynomial σ K)).IsMaximal := by - convert RingHom.ker_isMaximal_of_surjective (aeval (R := K) x) ?_ + convert! RingHom.ker_isMaximal_of_surjective (aeval (R := K) x) ?_ · ext; simp · intro z; use C z; simp diff --git a/Mathlib/RingTheory/PicardGroup.lean b/Mathlib/RingTheory/PicardGroup.lean index 0163b5490400ea..a6898ada1bd52f 100644 --- a/Mathlib/RingTheory/PicardGroup.lean +++ b/Mathlib/RingTheory/PicardGroup.lean @@ -683,8 +683,9 @@ set_option backward.privateInPublic.warn false in `I ⊗[R] J` to `I * J` induced by multiplication is an isomorphism. -/ noncomputable def tensorEquivMul : I ⊗[R] J ≃ₗ[R] I * J := by refine .ofBijective _ ⟨.of_comp (f := Submodule.subtype _) ?_, mulMap'_surjective _ _⟩ - convert (projective_units_and_mul'_comp_lTensor_bijective J).2.1.comp - (Flat.rTensor_preserves_injective_linearMap _ I.1.subtype_injective) + convert! + (projective_units_and_mul'_comp_lTensor_bijective J).2.1.comp + (Flat.rTensor_preserves_injective_linearMap _ I.1.subtype_injective) simp_rw [← LinearMap.coe_comp] congr 1; ext; rfl @@ -774,7 +775,7 @@ instance [Module.Invertible R M] : Module.Invertible R (submoduleAlgebra e) := the multiplication map induces an isomorphism `A ⊗[R] M ≃ₗ[A] A`. -/ noncomputable def tensorSubmoduleAlgebraEquiv : A ⊗[R] submoduleAlgebra e ≃ₗ[A] A := .ofBijective (.mul'' R A ∘ₗ AlgebraTensorModule.lTensor A A (Submodule.subtype _)) <| by - convert (AlgebraTensorModule.congr (.refl ..) (submoduleAlgebraEquiv e) ≪≫ₗ e).bijective + convert! (AlgebraTensorModule.congr (.refl ..) (submoduleAlgebraEquiv e) ≪≫ₗ e).bijective ext x refine x.induction_on (by simp) ?_ (by simp +contextual) intro a x @@ -785,7 +786,8 @@ noncomputable def tensorSubmoduleAlgebraEquiv : A ⊗[R] submoduleAlgebra e ≃ theorem top_mul_submoduleAlgebra : ⊤ * submoduleAlgebra e = ⊤ := by rw [← Submodule.mulMap_range] - convert (Submodule.topEquiv.rTensor _ ≪≫ₗ (tensorSubmoduleAlgebraEquiv e).restrictScalars R).range + convert! + (Submodule.topEquiv.rTensor _ ≪≫ₗ (tensorSubmoduleAlgebraEquiv e).restrictScalars R).range ext; rfl /-- When a flat `R`-module `M` is embedded as a submodule of a faithful `R`-algebra `A`, @@ -793,8 +795,9 @@ we have `I ⊗[R] M ≃ₗ[R] I * M` for any `R`-submodule `I` of `A`. -/ noncomputable def tensorSubmoduleAlgebraEquivMul (I : Submodule R A) : I ⊗[R] submoduleAlgebra e ≃ₗ[R] I * submoduleAlgebra e := by refine .ofBijective _ ⟨.of_comp (f := Submodule.subtype _) ?_, Submodule.mulMap'_surjective _ _⟩ - convert ((tensorSubmoduleAlgebraEquiv e).restrictScalars R).injective.comp - (Flat.rTensor_preserves_injective_linearMap _ I.subtype_injective) + convert! + ((tensorSubmoduleAlgebraEquiv e).restrictScalars R).injective.comp + (Flat.rTensor_preserves_injective_linearMap _ I.subtype_injective) simp_rw [← LinearEquiv.coe_toLinearMap, ← LinearMap.coe_comp] congr 1; ext; rfl @@ -900,7 +903,7 @@ theorem Ideal.eq_top_of_mk_tensor_eq_one [IsFractionRing R R] (I J : Ideal R) have : IsUnit (e 1 : R) := IsFractionRing.self_iff_nonZeroDivisors_le_isUnit.mp ‹_› <| IsRegular.mem_nonZeroDivisors <| isRightRegular_iff_isRegular.mp <| by rw [IsRightRegular] - convert Subtype.val_injective.comp e.injective using 2 + convert! Subtype.val_injective.comp e.injective using 2 rw [← smul_eq_mul, ← Submodule.coe_smul, ← map_smul, smul_eq_mul, mul_one, Function.comp_apply] constructor <;> refine eq_top_of_isUnit_mem _ ?_ this exacts [mul_le_right (e 1).2, mul_le_left (e 1).2] diff --git a/Mathlib/RingTheory/Polynomial/Basic.lean b/Mathlib/RingTheory/Polynomial/Basic.lean index acce808e31fc35..976ebdac86a394 100644 --- a/Mathlib/RingTheory/Polynomial/Basic.lean +++ b/Mathlib/RingTheory/Polynomial/Basic.lean @@ -575,7 +575,7 @@ theorem eq_zero_of_constant_mem_of_maximal (hR : IsField R) (I : Ideal R[X]) [hI (x : R) (hx : C x ∈ I) : x = 0 := by refine Classical.by_contradiction fun hx0 => hI.ne_top ((eq_top_iff_one I).2 ?_) obtain ⟨y, hy⟩ := hR.mul_inv_cancel hx0 - convert I.mul_mem_left (C y) hx + convert! I.mul_mem_left (C y) hx rw [← C.map_mul, hR.mul_comm y x, hy, map_one] end Ring @@ -593,7 +593,7 @@ theorem isPrime_map_C_iff_isPrime (P : Ideal R) : constructor · intro H have := comap_isPrime C (map C P) - convert this using 1 + convert! this using 1 ext x simp only [mem_comap, mem_map_C_iff] constructor @@ -683,7 +683,7 @@ theorem mem_span_C_coeff : f ∈ Ideal.span { g : R[X] | ∃ i : ℕ, g = C (coe rw [mem_setOf_eq] use n have : monomial n (1 : R) • C (coeff f n) ∈ p := p.smul_mem _ this - convert this using 1 + convert! this using 1 simp only [monomial_mul_C, one_mul, smul_eq_mul] rw [← C_mul_X_pow_eq_monomial] @@ -727,7 +727,7 @@ private theorem prime_C_iff_of_fintype {R : Type u} (σ : Type v) {r : R} [CommR · induction Fintype.card σ with | zero => exact MulEquiv.prime_iff (isEmptyAlgEquiv R (Fin 0)).symm (p := r) | succ d hd => - convert MulEquiv.prime_iff (finSuccEquiv R d).symm (p := Polynomial.C (C r)) + convert! MulEquiv.prime_iff (finSuccEquiv R d).symm (p := Polynomial.C (C r)) · simp [← finSuccEquiv_comp_C_eq_C] · simp [← hd, Polynomial.prime_C_iff] @@ -744,7 +744,7 @@ theorem prime_C_iff : Prime (C r : MvPolynomial σ R) ↔ Prime r := obtain ⟨s, a', b', rfl, rfl⟩ := exists_finset_rename₂ a b rw [← algebraMap_eq] at hd have : algebraMap R _ r ∣ a' * b' := by - convert _root_.map_dvd (killCompl Subtype.val_injective) hd + convert! _root_.map_dvd (killCompl Subtype.val_injective) hd · simp · simp rw [← rename_C ((↑) : s → σ)] @@ -848,7 +848,7 @@ protected theorem Polynomial.isNoetherianRing [inst : IsNoetherianRing R] : IsNo have := Polynomial.degree_sub_lt h1 hp0 h2 rw [Polynomial.degree_eq_natDegree hp0] at this rw [← sub_add_cancel p (q * Polynomial.X ^ (k - q.natDegree))] - convert (Ideal.span ↑s).add_mem _ ((Ideal.span (s : Set R[X])).mul_mem_right _ _) + convert! (Ideal.span ↑s).add_mem _ ((Ideal.span (s : Set R[X])).mul_mem_right _ _) · by_cases hpq : p - q * Polynomial.X ^ (k - q.natDegree) = 0 · rw [hpq] exact Ideal.zero_mem _ diff --git a/Mathlib/RingTheory/Polynomial/Bernstein.lean b/Mathlib/RingTheory/Polynomial/Bernstein.lean index afae82d695653c..21d772e327d470 100644 --- a/Mathlib/RingTheory/Polynomial/Bernstein.lean +++ b/Mathlib/RingTheory/Polynomial/Bernstein.lean @@ -120,8 +120,8 @@ theorem derivative_succ_aux (n ν : ℕ) : rw [mul_comm, ← mul_assoc, ← mul_assoc]; congr 1 norm_cast congr 1 - convert (Nat.choose_mul_succ_eq n (ν + 1)).symm using 1 - · convert mul_comm _ _ using 2 + convert! (Nat.choose_mul_succ_eq n (ν + 1)).symm using 1 + · convert! mul_comm _ _ using 2 simp · apply mul_comm @@ -150,7 +150,7 @@ theorem iterate_derivative_at_0_eq_zero_of_lt (n : ℕ) {ν k : ℕ} : intro h apply mul_eq_zero_of_right rw [ih _ _ (Nat.le_of_succ_le h), sub_zero] - convert ih _ _ (Nat.pred_le_pred h) + convert! ih _ _ (Nat.pred_le_pred h) exact (Nat.succ_pred_eq_of_pos (k.succ_pos.trans_le h)).symm @[simp] diff --git a/Mathlib/RingTheory/Polynomial/Chebyshev.lean b/Mathlib/RingTheory/Polynomial/Chebyshev.lean index 6b7d48f52085da..76249e0a59852d 100644 --- a/Mathlib/RingTheory/Polynomial/Chebyshev.lean +++ b/Mathlib/RingTheory/Polynomial/Chebyshev.lean @@ -96,13 +96,13 @@ protected theorem induct' (motive : ℤ → Prop) ∀ (a : ℤ), motive a := by refine Chebyshev.induct motive zero one add_two ?_ have neg' (n : ℤ) (h : motive (-n)) : motive n := by - convert neg (-n) h; rw [neg_neg] + convert! neg (-n) h; rw [neg_neg] intro n h₀ h₁ cases n with | zero => exact neg 1 h₁ | succ n => apply neg (n + 2) (add_two n (neg' _ h₀) (neg' n ?_)) - convert h₁ using 1; omega + convert! h₁ using 1; omega @[simp] theorem T_add_two : ∀ n, T R (n + 2) = 2 * X * T R (n + 1) - T R n @@ -876,7 +876,7 @@ theorem T_derivative_mem_span_T (n : ℕ) : · simp [hn] rw [T_derivative_eq_U, ← smul_eq_mul]; norm_cast refine Submodule.smul_of_tower_mem _ n ?_ - convert U_mem_span_T R (n - 1) using 2 <;> grind + convert! U_mem_span_T R (n - 1) using 2 <;> grind theorem T_iterate_derivative_mem_span_T (n k : ℕ) : derivative^[k] (T R n) ∈ Submodule.span ℕ ((fun m : ℕ => T R m) '' Set.Icc 0 (n - k)) := by @@ -889,7 +889,7 @@ theorem T_iterate_derivative_mem_span_T (n k : ℕ) : suffices Submodule.span ℕ ((fun m : ℕ => derivative (T R m)) '' Set.Icc 0 (n - k)) ≤ Submodule.span ℕ ((fun m : ℕ => T R m) '' Set.Icc 0 (n - (k + 1))) by apply this - convert Submodule.apply_mem_span_image_of_mem_span (derivative.restrictScalars ℕ) ih using 2 + convert! Submodule.apply_mem_span_image_of_mem_span (derivative.restrictScalars ℕ) ih using 2 simp [Set.image] refine Submodule.span_le.mpr (fun x hx => ?_) obtain ⟨m, hm, rfl⟩ := hx diff --git a/Mathlib/RingTheory/Polynomial/Cyclotomic/Basic.lean b/Mathlib/RingTheory/Polynomial/Cyclotomic/Basic.lean index 96b6cd1aac64ce..aa330d8e13e4ea 100644 --- a/Mathlib/RingTheory/Polynomial/Cyclotomic/Basic.lean +++ b/Mathlib/RingTheory/Polynomial/Cyclotomic/Basic.lean @@ -616,9 +616,9 @@ private theorem _root_.IsPrimitiveRoot.pow_sub_pow_eq_prod_sub_mul_field {K : Ty · simp only [hy, zero_pow (Nat.ne_zero_of_lt hpos), sub_zero, mul_zero, prod_const] congr rw [h.card_nthRootsFinset] - convert congr_arg (eval (x / y) · * y ^ card (nthRootsFinset n (1 : K))) - <| X_pow_sub_one_eq_prod hpos h - using 1 + convert! + congr_arg (eval (x / y) · * y ^ card (nthRootsFinset n (1 : K))) <| + X_pow_sub_one_eq_prod hpos h using 1 · simp [sub_mul, div_pow, hy, h.card_nthRootsFinset] · simp [eval_prod, prod_mul_pow_card, sub_mul, hy] diff --git a/Mathlib/RingTheory/Polynomial/Cyclotomic/Eval.lean b/Mathlib/RingTheory/Polynomial/Cyclotomic/Eval.lean index f95d087ecf9c20..6214c9b651a270 100644 --- a/Mathlib/RingTheory/Polynomial/Cyclotomic/Eval.lean +++ b/Mathlib/RingTheory/Polynomial/Cyclotomic/Eval.lean @@ -174,7 +174,7 @@ theorem sub_one_pow_totient_lt_cyclotomic_eval {n : ℕ} {q : ℝ} (hn' : 2 ≤ have hfor : ∀ ζ' ∈ primitiveRoots n ℂ, q - 1 ≤ ‖↑q - ζ'‖ := by intro ζ' hζ' rw [mem_primitiveRoots hn] at hζ' - convert norm_sub_norm_le (↑q) ζ' + convert! norm_sub_norm_le (↑q) ζ' · rw [Complex.norm_real, Real.norm_of_nonneg hq.le] · rw [hζ'.norm'_eq_one hn.ne'] let ζ := Complex.exp (2 * ↑Real.pi * Complex.I / ↑n) @@ -182,7 +182,7 @@ theorem sub_one_pow_totient_lt_cyclotomic_eval {n : ℕ} {q : ℝ} (hn' : 2 ≤ have hex : ∃ ζ' ∈ primitiveRoots n ℂ, q - 1 < ‖↑q - ζ'‖ := by refine ⟨ζ, (mem_primitiveRoots hn).mpr hζ, ?_⟩ suffices ¬SameRay ℝ (q : ℂ) ζ by - convert lt_norm_sub_of_not_sameRay this <;> + convert! lt_norm_sub_of_not_sameRay this <;> simp only [hζ.norm'_eq_one hn.ne', Real.norm_of_nonneg hq.le, Complex.norm_real] rw [Complex.sameRay_iff] push Not @@ -196,12 +196,12 @@ theorem sub_one_pow_totient_lt_cyclotomic_eval {n : ℕ} {q : ℝ} (hn' : 2 ≤ Units.mk0 ‖(cyclotomic n ℂ).eval ↑q‖₊ (by simp_all) by simp only [← Units.val_lt_val, Units.val_pow_eq_pow_val, Units.val_mk0, ← NNReal.coe_lt_coe, hq'.le, coe_nnnorm, NNReal.coe_pow, Real.coe_toNNReal', sub_nonneg, sup_of_le_left] at this - convert this + convert! this rw [eq_comm] simp [cyclotomic_nonneg n hq'.le] simp only [cyclotomic_eq_prod_X_sub_primitiveRoots hζ, eval_prod, eval_C, eval_X, eval_sub, nnnorm_prod, Units.mk0_prod] - convert Finset.prod_lt_prod' (M := NNRealˣ) _ _ + convert! Finset.prod_lt_prod' (M := NNRealˣ) _ _ swap; · exact fun _ => Units.mk0 (Real.toNNReal (q - 1)) (by simp [hq']) · simp only [Complex.card_primitiveRoots, prod_const, card_attach] · simp only [Finset.mem_attach, forall_true_left, Subtype.forall, ← @@ -226,7 +226,7 @@ theorem cyclotomic_eval_lt_add_one_pow_totient {n : ℕ} {q : ℝ} (hn' : 3 ≤ have hfor : ∀ ζ' ∈ primitiveRoots n ℂ, ‖↑q - ζ'‖ ≤ q + 1 := by intro ζ' hζ' rw [mem_primitiveRoots hn] at hζ' - convert norm_sub_le (↑q) ζ' + convert! norm_sub_le (↑q) ζ' · rw [Complex.norm_real, Real.norm_of_nonneg (zero_le_one.trans_lt hq').le] · rw [hζ'.norm'_eq_one hn.ne'] let ζ := Complex.exp (2 * ↑Real.pi * Complex.I / ↑n) @@ -234,7 +234,7 @@ theorem cyclotomic_eval_lt_add_one_pow_totient {n : ℕ} {q : ℝ} (hn' : 3 ≤ have hex : ∃ ζ' ∈ primitiveRoots n ℂ, ‖↑q - ζ'‖ < q + 1 := by refine ⟨ζ, (mem_primitiveRoots hn).mpr hζ, ?_⟩ suffices ¬SameRay ℝ (q : ℂ) (-ζ) by - convert norm_add_lt_of_not_sameRay this using 2 + convert! norm_add_lt_of_not_sameRay this using 2 · rw [Complex.norm_real] symm exact abs_eq_self.mpr hq.le @@ -261,14 +261,14 @@ theorem cyclotomic_eval_lt_add_one_pow_totient {n : ℕ} {q : ℝ} (hn' : 3 ≤ simp only [← Units.val_lt_val, Units.val_pow_eq_pow_val, Units.val_mk0, ← NNReal.coe_lt_coe, coe_nnnorm, NNReal.coe_pow, Real.coe_toNNReal'] at this - convert this using 2 + convert! this using 2 · rw [eq_comm] simp [cyclotomic_nonneg n hq'.le] rw [eq_comm, max_eq_left_iff] linarith simp only [cyclotomic_eq_prod_X_sub_primitiveRoots hζ, eval_prod, eval_C, eval_X, eval_sub, nnnorm_prod, Units.mk0_prod] - convert Finset.prod_lt_prod' (M := NNRealˣ) _ _ + convert! Finset.prod_lt_prod' (M := NNRealˣ) _ _ swap; · exact fun _ => Units.mk0 (Real.toNNReal (q + 1)) (by positivity) · simp [Complex.card_primitiveRoots] · simp only [Finset.mem_attach, forall_true_left, Subtype.forall, ← @@ -297,7 +297,7 @@ theorem sub_one_pow_totient_lt_natAbs_cyclotomic_eval {n : ℕ} {q : ℕ} (hn' : exact one_ne_zero rw [← @Nat.cast_lt ℝ, Nat.cast_pow, Nat.cast_sub hq'.le, Nat.cast_one, Nat.cast_natAbs] refine (sub_one_pow_totient_lt_cyclotomic_eval hn' (Nat.one_lt_cast.2 hq')).trans_le ?_ - convert (cyclotomic.eval_apply (q : ℤ) n (algebraMap ℤ ℝ)).trans_le (le_abs_self _) + convert! (cyclotomic.eval_apply (q : ℤ) n (algebraMap ℤ ℝ)).trans_le (le_abs_self _) simp theorem sub_one_lt_natAbs_cyclotomic_eval {n : ℕ} {q : ℕ} (hn' : 1 < n) (hq : q ≠ 1) : diff --git a/Mathlib/RingTheory/Polynomial/Cyclotomic/Expand.lean b/Mathlib/RingTheory/Polynomial/Cyclotomic/Expand.lean index 0b8592fad60c6f..01a6f5ec86d5b5 100644 --- a/Mathlib/RingTheory/Polynomial/Cyclotomic/Expand.lean +++ b/Mathlib/RingTheory/Polynomial/Cyclotomic/Expand.lean @@ -59,7 +59,7 @@ theorem cyclotomic_expand_eq_cyclotomic_mul {p n : ℕ} (hp : Nat.Prime p) (hdiv refine minpoly.dvd ℚ _ ?_ rw [← eval_map_algebraMap, map_expand, map_cyclotomic, expand_eval, ← IsRoot.def, @isRoot_cyclotomic_iff] - convert IsPrimitiveRoot.pow_of_dvd hprim hp.ne_zero (dvd_mul_left p n) + convert! IsPrimitiveRoot.pow_of_dvd hprim hp.ne_zero (dvd_mul_left p n) rw [Nat.mul_div_cancel _ (Nat.Prime.pos hp)] · have hprim := Complex.isPrimitiveRoot_exp _ hnpos.ne.symm rw [cyclotomic_eq_minpoly_rat hprim hnpos] @@ -100,7 +100,7 @@ theorem cyclotomic_expand_eq_cyclotomic {p n : ℕ} (hp : Nat.Prime p) (hdiv : p refine minpoly.isIntegrallyClosed_dvd (hprim.isIntegral hpos) ?_ rw [← eval_map_algebraMap, map_expand, map_cyclotomic, expand_eval, ← IsRoot.def, @isRoot_cyclotomic_iff] - convert IsPrimitiveRoot.pow_of_dvd hprim hp.ne_zero (dvd_mul_left p n) + convert! IsPrimitiveRoot.pow_of_dvd hprim hp.ne_zero (dvd_mul_left p n) rw [Nat.mul_div_cancel _ hp.pos] · rw [natDegree_expand, natDegree_cyclotomic, natDegree_cyclotomic, mul_comm n, Nat.totient_mul_of_prime_of_dvd hp hdiv, mul_comm] diff --git a/Mathlib/RingTheory/Polynomial/Cyclotomic/Roots.lean b/Mathlib/RingTheory/Polynomial/Cyclotomic/Roots.lean index 56167494b56579..34cec1230f631d 100644 --- a/Mathlib/RingTheory/Polynomial/Cyclotomic/Roots.lean +++ b/Mathlib/RingTheory/Polynomial/Cyclotomic/Roots.lean @@ -45,8 +45,8 @@ theorem isRoot_of_unity_of_root_cyclotomic {ζ : R} {i : ℕ} (hi : i ∈ n.divi · exact pow_zero _ have := congr_arg (eval ζ) (prod_cyclotomic_eq_X_pow_sub_one hn R).symm rw [eval_sub, eval_X_pow, eval_one] at this - convert eq_add_of_sub_eq' this - convert (add_zero (M := R) _).symm + convert! eq_add_of_sub_eq' this + convert! (add_zero (M := R) _).symm apply eval_eq_zero_of_dvd_of_eval_eq_zero _ h exact Finset.dvd_prod_of_mem _ hi diff --git a/Mathlib/RingTheory/Polynomial/Dickson.lean b/Mathlib/RingTheory/Polynomial/Dickson.lean index ad1e6ab658618c..99c6d0c632f322 100644 --- a/Mathlib/RingTheory/Polynomial/Dickson.lean +++ b/Mathlib/RingTheory/Polynomial/Dickson.lean @@ -245,7 +245,7 @@ theorem dickson_one_one_zmod_p (p : ℕ) [Fact p.Prime] : dickson 1 (1 : ZMod p) simpa [φ, eval_X, eval_one, eval_pow, eval_sub, sub_zero, eval_add, eval_mul, mul_zero, sq, zero_add, one_ne_zero] classical - convert (φ.roots ∪ {0}).toFinset.finite_toSet using 1 + convert! (φ.roots ∪ {0}).toFinset.finite_toSet using 1 ext1 y simp only [φ, Multiset.mem_toFinset, Set.mem_setOf_eq, Finset.mem_coe, Multiset.mem_union, mem_roots hφ, IsRoot, eval_add, eval_sub, eval_pow, eval_mul, eval_X, eval_C, eval_one, diff --git a/Mathlib/RingTheory/Polynomial/Eisenstein/Criterion.lean b/Mathlib/RingTheory/Polynomial/Eisenstein/Criterion.lean index 5e29efdb448645..a59d1730a5c866 100644 --- a/Mathlib/RingTheory/Polynomial/Eisenstein/Criterion.lean +++ b/Mathlib/RingTheory/Polynomial/Eisenstein/Criterion.lean @@ -202,7 +202,7 @@ theorem irreducible_of_eisenstein_criterion {f : R[X]} {P : Ideal R} (hP : P.IsP · simp [Nat.lt_iff_le_and_ne, ← Nat.not_lt, hn', Ne.symm hn] · rw [modByMonic_X, map_C, ne_eq, C_eq_zero, Ideal.Quotient.eq_zero_iff_mem, ← coeff_zero_eq_eval_zero] - convert h0 + convert! h0 · rw [IsScalarTower.algebraMap_eq R (R ⧸ P) (FractionRing (R ⧸ P))] rw [ker_comp_of_injective] · ext a; simp diff --git a/Mathlib/RingTheory/Polynomial/Eisenstein/IsIntegral.lean b/Mathlib/RingTheory/Polynomial/Eisenstein/IsIntegral.lean index ccd9a5514f97b8..e48868808090f5 100644 --- a/Mathlib/RingTheory/Polynomial/Eisenstein/IsIntegral.lean +++ b/Mathlib/RingTheory/Polynomial/Eisenstein/IsIntegral.lean @@ -156,7 +156,7 @@ theorem dvd_coeff_zero_of_aeval_eq_prime_smul_of_minpoly_isEisensteinAt {B : Pow have hndiv : ¬p ^ 2 ∣ (minpoly R B.gen).coeff 0 := fun h => hei.notMem ((span_singleton_pow p 2).symm ▸ Ideal.mem_span_singleton.2 h) refine hp.dvd_of_pow_dvd_pow_mul_pow_of_square_not_dvd (n := n) (?_ : _ ∣ _) hndiv - convert (IsUnit.dvd_mul_right ⟨(-1) ^ (n.succ * n), rfl⟩).mpr this using 1 + convert! (IsUnit.dvd_mul_right ⟨(-1) ^ (n.succ * n), rfl⟩).mpr this using 1 push_cast ring_nf simp @@ -263,7 +263,7 @@ theorem mem_adjoin_of_smul_prime_smul_of_minpoly_isEisensteinAt {B : PowerBasis exact dvd_coeff_zero_of_aeval_eq_prime_smul_of_minpoly_isEisensteinAt hp hBint hQ hzint hei | hi j hind => intro hj - convert hp.dvd_of_pow_dvd_pow_mul_pow_of_square_not_dvd (n := n) _ hndiv + convert! hp.dvd_of_pow_dvd_pow_mul_pow_of_square_not_dvd (n := n) _ hndiv -- Two technical results we will need about `P.natDegree` and `Q.natDegree`. have H := degree_modByMonic_lt Q₁ (minpoly.monic hBint) rw [← hQ₁, ← hP] at H @@ -309,7 +309,7 @@ theorem mem_adjoin_of_smul_prime_smul_of_minpoly_isEisensteinAt {B : PowerBasis suffices p ^ n.succ ∣ Q.coeff (succ j) ^ n.succ * (minpoly R B.gen).coeff 0 ^ (succ j + (P.natDegree - (j + 2))) by - convert this + convert! this rw [Nat.succ_eq_add_one, add_assoc, ← Nat.add_sub_assoc H, add_comm (j + 1), Nat.add_sub_add_left, ← Nat.add_sub_assoc, Nat.add_sub_add_left, hP, ← (minpoly.monic hBint).natDegree_map (algebraMap R K), ← diff --git a/Mathlib/RingTheory/Polynomial/GaussNorm.lean b/Mathlib/RingTheory/Polynomial/GaussNorm.lean index 973e8cc85dd8f6..6a58cfb1633d34 100644 --- a/Mathlib/RingTheory/Polynomial/GaussNorm.lean +++ b/Mathlib/RingTheory/Polynomial/GaussNorm.lean @@ -125,8 +125,9 @@ only if the polynomial is zero. -/ theorem gaussNorm_eq_zero_iff (h_eq_zero : ∀ x : R, v x = 0 → x = 0) (hc : 0 < c) : p.gaussNorm v c = 0 ↔ p = 0 := by rw [← gaussNorm_coe_powerSeries _ _ (le_of_lt hc)] - convert PowerSeries.gaussNorm_eq_zero_iff v c p (by grind) (by simp) h_eq_zero hc - (by simpa [PowerSeries.HasGaussNorm] using aux_bdd v p) + convert! + PowerSeries.gaussNorm_eq_zero_iff v c p (by grind) (by simp) h_eq_zero hc + (by simpa [PowerSeries.HasGaussNorm] using aux_bdd v p) exact Iff.symm coe_eq_zero_iff omit [ZeroHomClass F R ℝ] in diff --git a/Mathlib/RingTheory/Polynomial/Hermite/Basic.lean b/Mathlib/RingTheory/Polynomial/Hermite/Basic.lean index 82dc6c0255decc..ebc7dd98babcdf 100644 --- a/Mathlib/RingTheory/Polynomial/Hermite/Basic.lean +++ b/Mathlib/RingTheory/Polynomial/Hermite/Basic.lean @@ -143,7 +143,7 @@ theorem coeff_hermite_explicit : ∀ n k : ℕ, coeff (hermite (2 * n + k)) k = (-1) ^ n * (2 * n - 1)‼ * Nat.choose (2 * n + k) k | 0, _ => by simp | n + 1, 0 => by - convert coeff_hermite_succ_zero (2 * n + 1) using 1 + convert! coeff_hermite_succ_zero (2 * n + 1) using 1 rw [coeff_hermite_explicit n 1, (by grind : 2 * (n + 1) - 1 = 2 * n + 1), Nat.doubleFactorial_add_one, Nat.choose_zero_right, Nat.choose_one_right, pow_succ] diff --git a/Mathlib/RingTheory/Polynomial/IsIntegral.lean b/Mathlib/RingTheory/Polynomial/IsIntegral.lean index cbf2125c6bc6a3..a70f4023da5ff5 100644 --- a/Mathlib/RingTheory/Polynomial/IsIntegral.lean +++ b/Mathlib/RingTheory/Polynomial/IsIntegral.lean @@ -199,7 +199,7 @@ theorem MvPolynomial.isIntegral_iff_isIntegral_coeff.{w} {σ : Type w} {f : MvPo simp_rw [monomial_eq] refine IsIntegral.sum _ fun n _ ↦ .mul ((H n).map (Algebra.ofId _ _)).tower_top (.prod _ fun i _ ↦ .pow ?_ _) - convert isIntegral_algebraMap (x := MvPolynomial.X i) + convert! isIntegral_algebraMap (x := MvPolynomial.X i) simp only [algebraMap_def, map_X] unfold IsIntegral at H wlog hσ : Finite σ generalizing σ @@ -212,8 +212,10 @@ theorem MvPolynomial.isIntegral_iff_isIntegral_coeff.{w} {σ : Type w} {f : MvPo (g := (rename ((↑) : f.vars → σ)).toRingHom) (rename_injective _ Subtype.val_injective) (.of_comp (f := (killCompl (f := ((↑) : f.vars → σ)) Subtype.val_injective).toRingHom) <| by simp only [AlgHom.toRingHom_eq_coe, algebraMap_def, RingHom.coe_coe, hg] - convert H.map ((rename Subtype.val).comp - (killCompl (f := ((↑) : f.vars → σ)) Subtype.val_injective)).toRingHom + convert! + H.map + ((rename Subtype.val).comp + (killCompl (f := ((↑) : f.vars → σ)) Subtype.val_injective)).toRingHom · exact RingHom.ext (by simp [MvPolynomial.killCompl_map]) · nth_rw 1 12 [← hg]; simp)) n (.of_fintype _) · rw [← hg, coeff_rename_eq_zero _ _ _ (by grind)] @@ -223,13 +225,13 @@ theorem MvPolynomial.isIntegral_iff_isIntegral_coeff.{w} {σ : Type w} {f : MvPo · intro α β e IH f H n have := @IH (rename e.symm f) (.of_map (g := (rename e).toRingHom) (rename_injective _ e.injective) <| .of_comp (f := (rename e.symm).toRingHom) - (by convert H <;> aesop)) (n.embDomain e.symm) + (by convert! H <;> aesop)) (n.embDomain e.symm) simpa [Finsupp.embDomain_eq_mapDomain, coeff_rename_mapDomain _ e.symm.injective] using this · intro f H n refine .of_map (g := (isEmptyAlgEquiv _ PEmpty).symm.toRingHom) (isEmptyAlgEquiv _ PEmpty).symm.injective (.of_comp (f := (isEmptyAlgEquiv _ PEmpty).toRingHom) ?_) - convert H + convert! H · aesop (add simp MvPolynomial.isEmptyAlgEquiv) · obtain rfl := Subsingleton.elim n 0 have : constantCoeff = (isEmptyAlgEquiv S PEmpty).toRingHom := by aesop @@ -240,7 +242,7 @@ theorem MvPolynomial.isIntegral_iff_isIntegral_coeff.{w} {σ : Type w} {f : MvPo (p := optionEquivLeft _ _ f) (.of_map (g := (optionEquivLeft _ _).symm.toRingHom) (optionEquivLeft _ _).symm.injective (.of_comp (f := (optionEquivLeft _ _).toRingHom) (by - convert H + convert! H · ext i m · aesop · cases i <;> aesop diff --git a/Mathlib/RingTheory/Polynomial/Pochhammer.lean b/Mathlib/RingTheory/Polynomial/Pochhammer.lean index 63a53ac347d62c..ae098f694678e6 100644 --- a/Mathlib/RingTheory/Polynomial/Pochhammer.lean +++ b/Mathlib/RingTheory/Polynomial/Pochhammer.lean @@ -445,7 +445,7 @@ theorem ascPochhammer_eval_eq_zero_iff [IsDomain R] | inr h => exact ⟨n, lt_add_one n, eq_neg_of_add_eq_zero_right h⟩ · obtain ⟨rn, hrn, rnn⟩ := hrn - convert ascPochhammer_eval_neg_coe_nat_of_lt hrn + convert! ascPochhammer_eval_neg_coe_nat_of_lt hrn simp [rnn] /-- `descPochhammer R n` is `0` for `0, 1, …, n-1`. -/ diff --git a/Mathlib/RingTheory/Polynomial/RationalRoot.lean b/Mathlib/RingTheory/Polynomial/RationalRoot.lean index afc52ba5da0012..aac878274cb055 100644 --- a/Mathlib/RingTheory/Polynomial/RationalRoot.lean +++ b/Mathlib/RingTheory/Polynomial/RationalRoot.lean @@ -41,7 +41,7 @@ open Finsupp IsFractionRing IsLocalization Polynomial theorem scaleRoots_aeval_eq_zero_of_aeval_mk'_eq_zero {p : A[X]} {r : A} {s : M} (hr : aeval (mk' S r s) p = 0) : aeval (algebraMap A S r) (scaleRoots p s) = 0 := by - convert scaleRoots_eval₂_eq_zero (algebraMap A S) hr + convert! scaleRoots_eval₂_eq_zero (algebraMap A S) hr funext rw [aeval_def, mk'_spec' _ r s] @@ -76,11 +76,11 @@ theorem num_dvd_of_is_root {p : A[X]} {r : K} (hr : aeval r p = 0) : num A r ∣ intro q dvd_num dvd_denom_pow hq apply hq.not_unit exact num_den_reduced A r dvd_num (hq.dvd_of_dvd_pow dvd_denom_pow) - convert dvd_term_of_isRoot_of_dvd_terms 0 (num_isRoot_scaleRoots_of_aeval_eq_zero hr) _ + convert! dvd_term_of_isRoot_of_dvd_terms 0 (num_isRoot_scaleRoots_of_aeval_eq_zero hr) _ · rw [pow_zero, mul_one] intro j hj apply dvd_mul_of_dvd_right - convert pow_dvd_pow (num A r) (Nat.succ_le_of_lt (bot_lt_iff_ne_bot.mpr hj)) + convert! pow_dvd_pow (num A r) (Nat.succ_le_of_lt (bot_lt_iff_ne_bot.mpr hj)) exact (pow_one _).symm /-- Rational root theorem part 2: @@ -101,7 +101,7 @@ theorem den_dvd_of_is_root {p : A[X]} {r : K} (hr : aeval r p = 0) : by_cases! h : j < p.natDegree · rw [coeff_scaleRoots] refine (dvd_mul_of_dvd_right ?_ _).mul_right _ - convert pow_dvd_pow (den A r : A) (Nat.succ_le_iff.mpr (lt_tsub_iff_left.mpr _)) + convert! pow_dvd_pow (den A r : A) (Nat.succ_le_iff.mpr (lt_tsub_iff_left.mpr _)) · exact (pow_one _).symm simpa using h rw [← natDegree_scaleRoots p (den A r)] at * diff --git a/Mathlib/RingTheory/Polynomial/Resultant/Basic.lean b/Mathlib/RingTheory/Polynomial/Resultant/Basic.lean index 35f779049a94ad..c5db3b78562be0 100644 --- a/Mathlib/RingTheory/Polynomial/Resultant/Basic.lean +++ b/Mathlib/RingTheory/Polynomial/Resultant/Basic.lean @@ -659,17 +659,17 @@ lemma resultant_prod_right {ι : Type*} (s : Finset ι) (f : R[X]) (g : ι → R @[simp] lemma resultant_pow_left (hf : f.leadingCoeff ^ m ≠ 0) (hn : g.natDegree ≤ n) : (f ^ m).resultant g (f ^ m).natDegree n = (f.resultant g f.natDegree n) ^ m := by - convert resultant_prod_left (Finset.range m) (fun _ ↦ f) g n (by simpa) hn <;> simp + convert! resultant_prod_left (Finset.range m) (fun _ ↦ f) g n (by simpa) hn <;> simp @[simp] lemma resultant_pow_right (hm : f.natDegree ≤ m) (hg : g.leadingCoeff ^ n ≠ 0) : f.resultant (g ^ n) m (g ^ n).natDegree = (f.resultant g m g.natDegree) ^ n := by - convert resultant_prod_right (Finset.range n) f (fun _ ↦ g) m hm (by simpa) <;> simp + convert! resultant_prod_right (Finset.range n) f (fun _ ↦ g) m hm (by simpa) <;> simp lemma resultant_X_sub_C_pow_left (r : R) (g : R[X]) (m n : ℕ) (hn : g.natDegree ≤ n) : ((X - C r) ^ m).resultant g m n = eval r g ^ m := by nontriviality R - convert resultant_pow_left _ _ _ _ _ _ <;> simp [natDegree_pow', hn] + convert! resultant_pow_left _ _ _ _ _ _ <;> simp [natDegree_pow', hn] lemma resultant_X_sub_C_pow_right (f : R[X]) (r : R) (m n : ℕ) (hm : f.natDegree ≤ m) : f.resultant ((X - C r) ^ n) m n = (-1) ^ (m * n) * eval r f ^ n := by @@ -677,11 +677,11 @@ lemma resultant_X_sub_C_pow_right (f : R[X]) (r : R) (m n : ℕ) (hm : f.natDegr lemma resultant_X_pow_left (g : R[X]) (m n : ℕ) (hn : g.natDegree ≤ n) : (X ^ m).resultant g m n = g.coeff 0 ^ m := by - convert resultant_X_sub_C_pow_left 0 g m n hn <;> simp [coeff_zero_eq_eval_zero] + convert! resultant_X_sub_C_pow_left 0 g m n hn <;> simp [coeff_zero_eq_eval_zero] lemma resultant_X_pow_right (f : R[X]) (m n : ℕ) (hm : f.natDegree ≤ m) : f.resultant (X ^ n) m n = (-1) ^ (m * n) * f.coeff 0 ^ n := by - convert resultant_X_sub_C_pow_right f 0 m n hm <;> simp [coeff_zero_eq_eval_zero] + convert! resultant_X_sub_C_pow_right f 0 m n hm <;> simp [coeff_zero_eq_eval_zero] nonrec lemma resultant_scaleRoots (f g : R[X]) (r : R) : resultant (f.scaleRoots r) (g.scaleRoots r) = @@ -975,7 +975,7 @@ lemma resultant_deriv {f : R[X]} (hf : 0 < f.degree) : rw [resultant_comm, resultant, ← sylvesterDeriv_updateRow f hf, Matrix.det_updateRow_smul, Matrix.updateRow_eq_self, discr, mul_comm f.natDegree] ring_nf - rw [Nat.div_mul_cancel (by convert Nat.two_dvd_mul_add_one (f.natDegree - 1) using 2; lia)] + rw [Nat.div_mul_cancel (by convert! Nat.two_dvd_mul_add_one (f.natDegree - 1) using 2; lia)] set_option linter.style.whitespace false in -- manual alignment is not recognised private lemma sylvesterDeriv_of_natDegree_eq_three {f : R[X]} (hf : f.natDegree = 3) : diff --git a/Mathlib/RingTheory/Polynomial/ScaleRoots.lean b/Mathlib/RingTheory/Polynomial/ScaleRoots.lean index cf3db2ec59b8fc..1ba2255c027ed2 100644 --- a/Mathlib/RingTheory/Polynomial/ScaleRoots.lean +++ b/Mathlib/RingTheory/Polynomial/ScaleRoots.lean @@ -169,7 +169,7 @@ theorem scaleRoots_eval₂_eq_zero_of_eval₂_div_eq_zero {p : S[X]} {f : S →+ (hs : s ∈ nonZeroDivisors S) : eval₂ f (f r) (scaleRoots p s) = 0 := by -- if we don't specify the type with `(_ : S)`, the proof is much slower nontriviality S using Subsingleton.eq_zero (_ : S) - convert @scaleRoots_eval₂_eq_zero _ _ _ _ p f _ s hr + convert! @scaleRoots_eval₂_eq_zero _ _ _ _ p f _ s hr rw [← mul_div_assoc, mul_comm, mul_div_cancel_right₀] exact map_ne_zero_of_mem_nonZeroDivisors _ hf hs diff --git a/Mathlib/RingTheory/Polynomial/SmallDegreeVieta.lean b/Mathlib/RingTheory/Polynomial/SmallDegreeVieta.lean index 77fedfa207edad..6840b590e4ab53 100644 --- a/Mathlib/RingTheory/Polynomial/SmallDegreeVieta.lean +++ b/Mathlib/RingTheory/Polynomial/SmallDegreeVieta.lean @@ -32,7 +32,7 @@ lemma eq_neg_mul_add_of_roots_quadratic_eq_pair [CommRing R] [IsDomain R] {a b c b = -a * (x1 + x2) := by let p : R[X] := C a * X ^ 2 + C b * X + C c have hp_natDegree : p.natDegree = 2 := le_antisymm natDegree_quadratic_le - (by convert p.card_roots'; rw [hroots, Multiset.card_pair]) + (by convert! p.card_roots'; rw [hroots, Multiset.card_pair]) have hp_roots_card : p.roots.card = p.natDegree := by rw [hp_natDegree, hroots, Multiset.card_pair] simpa [leadingCoeff, hp_natDegree, p, hroots, mul_assoc, add_comm x1] using @@ -44,7 +44,7 @@ lemma eq_mul_mul_of_roots_quadratic_eq_pair [CommRing R] [IsDomain R] {a b c x1 c = a * x1 * x2 := by let p : R[X] := C a * X ^ 2 + C b * X + C c have hp_natDegree : p.natDegree = 2 := le_antisymm natDegree_quadratic_le - (by convert p.card_roots'; rw [hroots, Multiset.card_pair]) + (by convert! p.card_roots'; rw [hroots, Multiset.card_pair]) have hp_roots_card : p.roots.card = p.natDegree := by rw [hp_natDegree, hroots, Multiset.card_pair] simpa [leadingCoeff, hp_natDegree, p, hroots, mul_assoc, add_comm x1] using diff --git a/Mathlib/RingTheory/Polynomial/UniversalFactorizationRing.lean b/Mathlib/RingTheory/Polynomial/UniversalFactorizationRing.lean index a3a9e4b4f8cf49..b3936dabc82f22 100644 --- a/Mathlib/RingTheory/Polynomial/UniversalFactorizationRing.lean +++ b/Mathlib/RingTheory/Polynomial/UniversalFactorizationRing.lean @@ -587,7 +587,7 @@ def UniversalCoprimeFactorizationRing.homEquiv : toFun f := letI q := UniversalFactorizationRing.homEquiv S m k hn p (f.comp (IsScalarTower.toAlgHom _ _ _)) ⟨q.1, q.2, by - convert (isCoprime_factor₁_factor₂ m k hn p).map (Polynomial.mapRingHom f.toRingHom) <;> + convert! (isCoprime_factor₁_factor₂ m k hn p).map (Polynomial.mapRingHom f.toRingHom) <;> simp [q, UniversalFactorizationRing.homEquiv, AlgHom.comp_toRingHom, ← Polynomial.map_map] <;> rfl⟩ invFun q := by @@ -614,7 +614,7 @@ def UniversalCoprimeFactorizationRing.homEquiv : ext; simp right_inv q := by apply Subtype.ext - convert congr($((UniversalFactorizationRing.homEquiv S m k hn p).apply_symm_apply + convert! congr($((UniversalFactorizationRing.homEquiv S m k hn p).apply_symm_apply ⟨_, q.2.1⟩).1) using 1 dsimp congr 2 diff --git a/Mathlib/RingTheory/Polynomial/Vieta.lean b/Mathlib/RingTheory/Polynomial/Vieta.lean index 1a77f5434ad737..11cccb8d2bdc21 100644 --- a/Mathlib/RingTheory/Polynomial/Vieta.lean +++ b/Mathlib/RingTheory/Polynomial/Vieta.lean @@ -55,7 +55,7 @@ theorem prod_X_add_C_eq_sum_esymm (s : Multiset R) : through a multiset `s` : the `k`th coefficient is the symmetric function `esymm (card s - k) s`. -/ theorem prod_X_add_C_coeff (s : Multiset R) {k : ℕ} (h : k ≤ Multiset.card s) : (s.map fun r => X + C r).prod.coeff k = s.esymm (Multiset.card s - k) := by - convert Polynomial.ext_iff.mp (prod_X_add_C_eq_sum_esymm s) k using 1 + convert! Polynomial.ext_iff.mp (prod_X_add_C_eq_sum_esymm s) k using 1 simp_rw [finsetSum_coeff, coeff_C_mul_X_pow] rw [Finset.sum_eq_single_of_mem (Multiset.card s - k) _] <;> grind @@ -94,7 +94,7 @@ theorem prod_X_sub_X_eq_sum_esymm (s : Multiset R) : ext x rw [sub_eq_add_neg] rw [← map_neg C x] - convert prod_X_add_C_eq_sum_esymm (map (fun t => -t) s) using 1 + convert! prod_X_add_C_eq_sum_esymm (map (fun t => -t) s) using 1 · rw [map_map]; rfl · simp only [esymm_neg, card_map, mul_assoc, map_mul, map_pow, map_neg, map_one] @@ -108,7 +108,7 @@ theorem prod_X_sub_C_coeff (s : Multiset R) {k : ℕ} (h : k ≤ Multiset.card s ext x rw [sub_eq_add_neg] rw [← map_neg C x] - convert prod_X_add_C_coeff (map (fun t => -t) s) _ using 1 + convert! prod_X_add_C_coeff (map (fun t => -t) s) _ using 1 · rw [map_map]; rfl · rw [esymm_neg, card_map] · rwa [card_map] @@ -121,7 +121,7 @@ theorem _root_.Polynomial.coeff_eq_esymm_roots_of_card [IsDomain R] {p : R[X]} conv_lhs => rw [← C_leadingCoeff_mul_prod_multiset_X_sub_C hroots] rw [coeff_C_mul, mul_assoc]; congr have : k ≤ card (roots p) := by rw [hroots]; exact h - convert p.roots.prod_X_sub_C_coeff this using 3 <;> rw [hroots] + convert! p.roots.prod_X_sub_C_coeff this using 3 <;> rw [hroots] /-- Vieta's formula for split polynomials over a field. -/ theorem _root_.Polynomial.coeff_eq_esymm_roots_of_splits {F} [Field F] {p : F[X]} @@ -150,7 +150,7 @@ theorem MvPolynomial.prod_C_add_X_eq_sum_esymm : have : Fintype.card σ = Multiset.card s := by rw [Multiset.card_map, ← Finset.card_univ, Finset.card_def] simp_rw [this, MvPolynomial.esymm_eq_multiset_esymm σ R, Finset.prod_eq_multiset_prod] - convert Multiset.prod_X_add_C_eq_sum_esymm s + convert! Multiset.prod_X_add_C_eq_sum_esymm s simp_rw [s, Multiset.map_map, Function.comp_apply] theorem MvPolynomial.prod_X_add_C_coeff (k : ℕ) (h : k ≤ card σ) : @@ -161,7 +161,7 @@ theorem MvPolynomial.prod_X_add_C_coeff (k : ℕ) (h : k ≤ card σ) : rw [Multiset.card_map, ← Finset.card_univ, Finset.card_def] rw [this] at h ⊢ rw [MvPolynomial.esymm_eq_multiset_esymm σ R, Finset.prod_eq_multiset_prod] - convert Multiset.prod_X_add_C_coeff s h + convert! Multiset.prod_X_add_C_coeff s h dsimp simp_rw [s, Multiset.map_map, Function.comp_apply] diff --git a/Mathlib/RingTheory/Polynomial/Wronskian.lean b/Mathlib/RingTheory/Polynomial/Wronskian.lean index 2d59bba59302fb..591114a63e9ff7 100644 --- a/Mathlib/RingTheory/Polynomial/Wronskian.lean +++ b/Mathlib/RingTheory/Polynomial/Wronskian.lean @@ -113,7 +113,7 @@ theorem natDegree_wronskian_lt_add {a b : R[X]} (hw : wronskian a b ≠ 0) : have ha : a ≠ 0 := by intro h; subst h; rw [wronskian_zero_left] at hw; exact hw rfl have hb : b ≠ 0 := by intro h; subst h; rw [wronskian_zero_right] at hw; exact hw rfl rw [← WithBot.coe_lt_coe, WithBot.coe_add] - convert ← degree_wronskian_lt_add ha hb + convert! ← degree_wronskian_lt_add ha hb · exact Polynomial.degree_eq_natDegree hw · exact Polynomial.degree_eq_natDegree ha · exact Polynomial.degree_eq_natDegree hb diff --git a/Mathlib/RingTheory/PolynomialLaw/Basic.lean b/Mathlib/RingTheory/PolynomialLaw/Basic.lean index 428aacc7598da8..b2e6bc8fe2651c 100644 --- a/Mathlib/RingTheory/PolynomialLaw/Basic.lean +++ b/Mathlib/RingTheory/PolynomialLaw/Basic.lean @@ -235,7 +235,7 @@ instance : CoeFun (M →ₚₗ[R] N) (fun _ ↦ M → N) where theorem one_tmul_ground_apply' {S : Type u} [CommSemiring S] [Algebra R S] (x : M) : 1 ⊗ₜ (f.ground x) = (f.toFun' S) (1 ⊗ₜ x) := by rw [ground_apply] - convert f.isCompat_apply' (Algebra.algHom R R S) (1 ⊗ₜ[R] x) + convert! f.isCompat_apply' (Algebra.algHom R R S) (1 ⊗ₜ[R] x) · simp only [includeRight_lid] · rw [rTensor_tmul, toLinearMap_apply, map_one] @@ -584,7 +584,7 @@ variable {R : Type u} [CommSemiring R] theorem one_tmul_ground (x : M) : 1 ⊗ₜ f.ground x = f.toFun S (1 ⊗ₜ x) := by simp only [ground, toFun'_eq_toFun] - convert f.isCompat_apply (Algebra.ofId R S) (1 ⊗ₜ[R] x) + convert! f.isCompat_apply (Algebra.ofId R S) (1 ⊗ₜ[R] x) · simp only [Function.comp_apply, TensorProduct.lid_symm_apply, TensorProduct.includeRight_lid] congr · rw [rTensor_tmul, toLinearMap_apply, _root_.map_one] diff --git a/Mathlib/RingTheory/PowerBasis.lean b/Mathlib/RingTheory/PowerBasis.lean index 53f0a417575ed6..28e97065e03cd6 100644 --- a/Mathlib/RingTheory/PowerBasis.lean +++ b/Mathlib/RingTheory/PowerBasis.lean @@ -235,7 +235,7 @@ protected theorem leftMulMatrix (pb : PowerBasis A S) : Algebra.leftMulMatrix pb apply (pow_succ' _ _).symm.trans split_ifs with h · simp_rw [h, neg_smul, Finset.sum_neg_distrib, eq_neg_iff_add_eq_zero] - convert pb.aeval_minpolyGen + convert! pb.aeval_minpolyGen rw [add_comm, aeval_eq_sum_range, Finset.sum_range_succ, ← leadingCoeff, pb.minpolyGen_monic.leadingCoeff, one_smul, natDegree_minpolyGen, Finset.sum_range] · rw [Fintype.sum_eq_single (⟨(k : ℕ) + 1, lt_of_le_of_ne k.2 h⟩ : Fin pb.dim), if_pos, one_smul] @@ -270,11 +270,11 @@ theorem constr_pow_aeval (pb : PowerBasis A S) {y : S'} (hy : aeval y (minpoly A theorem constr_pow_gen (pb : PowerBasis A S) {y : S'} (hy : aeval y (minpoly A pb.gen) = 0) : pb.basis.constr A (fun i => y ^ (i : ℕ)) pb.gen = y := by - convert pb.constr_pow_aeval hy X <;> rw [aeval_X] + convert! pb.constr_pow_aeval hy X <;> rw [aeval_X] theorem constr_pow_algebraMap (pb : PowerBasis A S) {y : S'} (hy : aeval y (minpoly A pb.gen) = 0) (x : A) : pb.basis.constr A (fun i => y ^ (i : ℕ)) (algebraMap A S x) = algebraMap A S' x := by - convert pb.constr_pow_aeval hy (C x) <;> rw [aeval_C] + convert! pb.constr_pow_aeval hy (C x) <;> rw [aeval_C] theorem constr_pow_mul (pb : PowerBasis A S) {y : S'} (hy : aeval y (minpoly A pb.gen) = 0) (x x' : S) : pb.basis.constr A (fun i => y ^ (i : ℕ)) (x * x') = @@ -291,8 +291,8 @@ See `PowerBasis.liftEquiv` for a bundled equiv sending `⟨y, hy⟩` to the alge noncomputable def lift (pb : PowerBasis A S) (y : S') (hy : aeval y (minpoly A pb.gen) = 0) : S →ₐ[A] S' := { pb.basis.constr A fun i => y ^ (i : ℕ) with - map_one' := by convert pb.constr_pow_algebraMap hy 1 using 2 <;> rw [map_one] - map_zero' := by convert pb.constr_pow_algebraMap hy 0 using 2 <;> rw [map_zero] + map_one' := by convert! pb.constr_pow_algebraMap hy 1 using 2 <;> rw [map_one] + map_zero' := by convert! pb.constr_pow_algebraMap hy 0 using 2 <;> rw [map_zero] map_mul' := pb.constr_pow_mul hy commutes' := pb.constr_pow_algebraMap hy } diff --git a/Mathlib/RingTheory/PowerSeries/Basic.lean b/Mathlib/RingTheory/PowerSeries/Basic.lean index 881c5dbbeeab85..64e628af1b5ad8 100644 --- a/Mathlib/RingTheory/PowerSeries/Basic.lean +++ b/Mathlib/RingTheory/PowerSeries/Basic.lean @@ -144,12 +144,16 @@ theorem constantCoeff_eq (f : R⟦X⟧) : def C : R →+* R⟦X⟧ := MvPowerSeries.C +lemma C_apply {r : R} : C r = MvPowerSeries.C r := rfl + @[simp] lemma algebraMap_eq {R : Type*} [CommSemiring R] : algebraMap R R⟦X⟧ = C := rfl /-- The variable of the formal power series ring. -/ def X : R⟦X⟧ := MvPowerSeries.X () +lemma X_apply : X (R := R) = MvPowerSeries.X () := rfl + theorem commute_X (φ : R⟦X⟧) : Commute φ X := MvPowerSeries.commute_X _ _ @@ -268,13 +272,13 @@ theorem smul_eq_C_mul (f : R⟦X⟧) (a : R) : a • f = C a * f := by @[simp] theorem coeff_succ_mul_X (n : ℕ) (φ : R⟦X⟧) : coeff (n + 1) (φ * X) = coeff n φ := by simp only [coeff, Finsupp.single_add] - convert φ.coeff_add_mul_monomial (single () n) (single () 1) _ + convert! φ.coeff_add_mul_monomial (single () n) (single () 1) _ rw [mul_one] @[simp] theorem coeff_succ_X_mul (n : ℕ) (φ : R⟦X⟧) : coeff (n + 1) (X * φ) = coeff n φ := by simp only [coeff, Finsupp.single_add, add_comm n 1] - convert φ.coeff_add_monomial_mul (single () 1) (single () n) _ + convert! φ.coeff_add_monomial_mul (single () 1) (single () n) _ rw [one_mul] theorem mul_X_cancel {φ ψ : R⟦X⟧} (h : φ * X = ψ * X) : φ = ψ := by @@ -485,10 +489,10 @@ theorem map_eq_zero {R S : Type*} [DivisionSemiring R] [Semiring S] [Nontrivial theorem X_pow_dvd_iff {n : ℕ} {φ : R⟦X⟧} : (X : R⟦X⟧) ^ n ∣ φ ↔ ∀ m, m < n → coeff m φ = 0 := by - convert @MvPowerSeries.X_pow_dvd_iff Unit R _ () n φ + convert! @MvPowerSeries.X_pow_dvd_iff Unit R _ () n φ constructor <;> intro h m hm · rw [Finsupp.unique_single m] - convert h _ hm + convert! h _ hm · apply h simpa only [Finsupp.single_eq_same] using hm @@ -595,7 +599,7 @@ theorem rescale_map {S : Type*} [CommSemiring S] (φ : R →+* S) (r : R) (f : R theorem rescale_algebraMap_map {A S : Type*} [CommSemiring A] [Algebra A R] [CommSemiring S] [Algebra A S] (φ : R →ₐ[A] S) (a : A) (f : R⟦X⟧) : rescale (algebraMap A S a) (f.map φ) = (rescale (algebraMap A R a) f).map φ := by - convert rescale_map (φ : R →+* S) _ _ + convert! rescale_map (φ : R →+* S) _ _ simp end CommSemiring diff --git a/Mathlib/RingTheory/PowerSeries/Evaluation.lean b/Mathlib/RingTheory/PowerSeries/Evaluation.lean index e2289d15a40ff7..c09f9380cc32d7 100644 --- a/Mathlib/RingTheory/PowerSeries/Evaluation.lean +++ b/Mathlib/RingTheory/PowerSeries/Evaluation.lean @@ -179,7 +179,7 @@ theorem hasSum_eval₂ (hφ : Continuous φ) (ha : HasEval a) (f : PowerSeries R have := MvPowerSeries.hasSum_eval₂ hφ (hasEval ha) f simp only [PowerSeries.eval₂] rw [← (Finsupp.single_injective ()).hasSum_iff] at this - · convert this; simp; congr + · convert! this; simp; congr · intro d hd exact False.elim (hd ⟨d (), by ext; simp⟩) diff --git a/Mathlib/RingTheory/PowerSeries/Exp.lean b/Mathlib/RingTheory/PowerSeries/Exp.lean index 1905c64609d6eb..f884c6491322a4 100644 --- a/Mathlib/RingTheory/PowerSeries/Exp.lean +++ b/Mathlib/RingTheory/PowerSeries/Exp.lean @@ -130,7 +130,7 @@ theorem exp_mul_exp_eq_exp_add [Algebra ℚ A] (a b : A) : a ^ x * b ^ (n - x) * (algebraMap ℚ A (1 / ↑x.factorial) * algebraMap ℚ A (1 / ↑(n - x).factorial)) = a ^ x * b ^ (n - x) * (↑(n.choose x) * (algebraMap ℚ A) (1 / ↑n.factorial)) - by convert this using 1 <;> ring + by convert! this using 1 <;> ring congr 1 rw [← map_natCast (algebraMap ℚ A) (n.choose x), ← map_mul, ← map_mul] refine RingHom.congr_arg _ ?_ @@ -147,7 +147,7 @@ theorem exp_mul_exp_eq_exp_add [Algebra ℚ A] (a b : A) : /-- Shows that $e^{x} * e^{-x} = 1$ -/ theorem exp_mul_exp_neg_eq_one [Algebra ℚ A] : exp A * evalNegHom (exp A) = 1 := by - convert exp_mul_exp_eq_exp_add (1 : A) (-1) <;> simp + convert! exp_mul_exp_eq_exp_add (1 : A) (-1) <;> simp /-- Shows that $(e^{X})^k = e^{kX}$. -/ theorem exp_pow_eq_rescale_exp [Algebra ℚ A] (k : ℕ) : exp A ^ k = rescale (k : A) (exp A) := by diff --git a/Mathlib/RingTheory/PowerSeries/Order.lean b/Mathlib/RingTheory/PowerSeries/Order.lean index 3081c69304e383..d8969aeb38ff6e 100644 --- a/Mathlib/RingTheory/PowerSeries/Order.lean +++ b/Mathlib/RingTheory/PowerSeries/Order.lean @@ -116,7 +116,7 @@ theorem le_order (φ : R⟦X⟧) (n : ℕ∞) (h : ∀ i : ℕ, ↑i < n → coe cases n with | top => simpa using ext (by simpa using h) | coe n => - convert nat_le_order φ n _ + convert! nat_le_order φ n _ simpa using h /-- The order of a formal power series is exactly `n` if the `n`th coefficient is nonzero, @@ -226,7 +226,7 @@ theorem one_le_order_iff_constCoeff_eq_zero : theorem order_ne_zero_iff_constCoeff_eq_zero {φ : R⟦X⟧} : φ.order ≠ 0 ↔ φ.constantCoeff = 0 := by - rw [← ENat.one_le_iff_ne_zero, one_le_order_iff_constCoeff_eq_zero] + rw [← Order.one_le_iff_ne_zero, one_le_order_iff_constCoeff_eq_zero] theorem le_order_pow_of_constantCoeff_eq_zero (n : ℕ) (hf : φ.constantCoeff = 0) : n ≤ (φ ^ n).order := by diff --git a/Mathlib/RingTheory/PowerSeries/Substitution.lean b/Mathlib/RingTheory/PowerSeries/Substitution.lean index b84d6cc55554e6..b061bdbedb480b 100644 --- a/Mathlib/RingTheory/PowerSeries/Substitution.lean +++ b/Mathlib/RingTheory/PowerSeries/Substitution.lean @@ -162,6 +162,9 @@ noncomputable def subst (a : MvPowerSeries τ S) (f : PowerSeries R) : lemma subst_def (a : MvPowerSeries τ S) (f : PowerSeries R) : subst a f = MvPowerSeries.subst (fun _ ↦ a) f := rfl +lemma subst_X_comp_const {f : R⟦X⟧} {i : τ} : + .subst (.X (R := R) ∘ fun _ ↦ i) f = f.subst (.X i) := rfl + variable {a : MvPowerSeries τ S} {b : S⟦X⟧} /-- Substitution of power series into a power series, as an `AlgHom`. -/ @@ -326,7 +329,7 @@ theorem le_weightedOrder_subst (w : τ → ℕ) (ha : HasSubst a) (f : PowerSeri simp only [ne_eq, Function.comp_const, le_iInf_iff] intro i hi trans i () * MvPowerSeries.weightedOrder w a - · exact mul_le_mul_left (f.order_le (i ()) (by delta PowerSeries.coeff; convert hi; aesop)) _ + · exact mul_le_mul_left (f.order_le (i ()) (by delta PowerSeries.coeff; convert! hi; aesop)) _ · simp [Finsupp.weight_apply, Finsupp.sum_fintype] theorem le_order_subst (a : MvPowerSeries τ S) (ha : HasSubst a) (f : PowerSeries R) : @@ -586,6 +589,25 @@ end IsUnit end substInv +section + +attribute [local instance] DiscreteTopology.instContinuousSMul + +variable {x : ℕ → PowerSeries R} {a : MvPowerSeries τ S} + [UniformSpace R] [DiscreteUniformity R] [UniformSpace S] [DiscreteUniformity S] + +lemma subst_tsum (hx : Summable x) (ha : HasSubst a) : + (∑' i, x i).subst a = ∑' i, ((x i).subst a) := by + rw [← coe_substAlgHom ha, substAlgHom_eq_aeval ha, hx.map_tsum _] + exact continuous_aeval _ + +lemma summable_subst (hx : Summable x) (ha : HasSubst a) : + Summable fun i ↦ (x i).subst a := by + rw [← coe_substAlgHom ha, substAlgHom_eq_aeval ha] + exact hx.map _ (continuous_aeval _) + +end + section Bivariate open Finset Finsupp Nat diff --git a/Mathlib/RingTheory/PowerSeries/WeierstrassPreparation.lean b/Mathlib/RingTheory/PowerSeries/WeierstrassPreparation.lean index 1c410073241183..a0dc12fa468ee4 100644 --- a/Mathlib/RingTheory/PowerSeries/WeierstrassPreparation.lean +++ b/Mathlib/RingTheory/PowerSeries/WeierstrassPreparation.lean @@ -478,8 +478,9 @@ noncomputable def _root_.Polynomial.IsDistinguishedAt.algEquivQuotient : rw [Eq.comm, Ideal.Quotient.mk_eq_mk_iff_sub_mem, Ideal.mem_span_singleton'] exact ⟨f /ₘ g, by rw [Polynomial.modByMonic_eq_sub_mul_div]; ring⟩ have h1 : g.degree = ((g : A⟦X⟧).map (Ideal.Quotient.mk I)).order.toNat := by - convert H.degree_eq_coe_lift_order_map g 1 - (by rwa [constantCoeff_one, ← Ideal.ne_top_iff_one]) (by simp) + convert! + H.degree_eq_coe_lift_order_map g 1 (by rwa [constantCoeff_one, ← Ideal.ne_top_iff_one]) + (by simp) exact (ENat.lift_eq_toNat_of_lt_top _).symm dsimp rw [Ideal.Quotient.mk_eq_mk_iff_sub_mem, Ideal.mem_span_singleton'] diff --git a/Mathlib/RingTheory/PrincipalIdealDomain.lean b/Mathlib/RingTheory/PrincipalIdealDomain.lean index a34f34d6643154..f9191cf7a05d5e 100644 --- a/Mathlib/RingTheory/PrincipalIdealDomain.lean +++ b/Mathlib/RingTheory/PrincipalIdealDomain.lean @@ -94,7 +94,7 @@ theorem _root_.Ideal.span_singleton_generator (I : Ideal R) [I.IsPrincipal] : @[simp] theorem generator_mem (S : Submodule R M) [S.IsPrincipal] : generator S ∈ S := by have : generator S ∈ span R {generator S} := subset_span (mem_singleton _) - convert this + convert! this exact span_singleton_generator S |>.symm theorem mem_iff_eq_smul_generator (S : Submodule R M) [S.IsPrincipal] {x : M} : diff --git a/Mathlib/RingTheory/QuasiFinite/Basic.lean b/Mathlib/RingTheory/QuasiFinite/Basic.lean index 2dac2ef4953060..f66fbd78218bcc 100644 --- a/Mathlib/RingTheory/QuasiFinite/Basic.lean +++ b/Mathlib/RingTheory/QuasiFinite/Basic.lean @@ -85,7 +85,7 @@ lemma finite_primesOver [QuasiFinite R S] (I : Ideal R) : (I.primesOver S).Finit by_cases h : I.IsPrime · refine ((finite_comap_preimage_singleton ⟨I, h⟩).image PrimeSpectrum.asIdeal).subset ?_ exact fun J hJ ↦ ⟨⟨_, hJ.1⟩, PrimeSpectrum.ext hJ.2.1.symm, rfl⟩ - · convert Set.finite_empty + · convert! Set.finite_empty by_contra! obtain ⟨J, h₁, ⟨rfl⟩⟩ := this exact h inferInstance @@ -326,7 +326,7 @@ lemma of_isIntegral_of_finiteType [Algebra.IsIntegral R S] [Algebra.FiniteType R obtain ⟨x, ⟨_, n, rfl⟩, rfl⟩ := IsLocalization.exists_mk'_eq (.powers s) x have : _root_.IsIntegral (Localization.Away sA) (algebraMap S T x) := (Algebra.IsIntegral.isIntegral (R := R) x).algebraMap.tower_top - convert this.smul (Localization.Away.invSelf sA ^ n) + convert! this.smul (Localization.Away.invSelf sA ^ n) rw [IsLocalization.mk'_eq_iff_eq_mul] simp only [map_pow, Algebra.smul_mul_assoc] trans (sA • Localization.Away.invSelf sA) ^ n • (algebraMap S T x) @@ -417,7 +417,7 @@ lemma QuasiFiniteAt.eq_of_le_of_under_eq {P Q : Ideal S} [P.IsPrime] [Q.IsPrime] have H := QuasiFinite.eq_of_le_of_under_eq (R := R) (Ideal.map (algebraMap S (Localization.AtPrime Q)) P) _ (IsLocalRing.le_maximalIdeal_of_isPrime _) (by - convert h₂ <;> rw [← Ideal.under_under (B := S)] + convert! h₂ <;> rw [← Ideal.under_under (B := S)] · rw [IsLocalization.under_map_of_isPrime_disjoint Q.primeCompl _ ‹P.IsPrime› this] · rw [Localization.AtPrime.under_maximalIdeal]) rw [← Localization.AtPrime.under_maximalIdeal (I := Q), ← H, @@ -564,7 +564,7 @@ lemma _root_.Ideal.Fiber.lift_residueField_surjective [Algebra.FiniteType R S] refine .of_comp_left ?_ (p.surjectiveOnStalks_residueField.baseChange'.residueFieldMap_bijective q q' hq').1 rw [← AlgHom.coe_toRingHom, ← RingHom.coe_comp] - convert q'.algebraMap_residueField_surjective + convert! q'.algebraMap_residueField_surjective ext <;> simp [IsScalarTower.algebraMap_apply R S q.ResidueField] end QuasiFiniteAt diff --git a/Mathlib/RingTheory/Radical/NatInt.lean b/Mathlib/RingTheory/Radical/NatInt.lean index f57ac5eb13fe41..bb14afc78a1ea0 100644 --- a/Mathlib/RingTheory/Radical/NatInt.lean +++ b/Mathlib/RingTheory/Radical/NatInt.lean @@ -42,7 +42,7 @@ lemma UniqueFactorizationMonoid.primeFactors_eq_natPrimeFactors : ext n : 1 rw [primeFactors, Nat.factors_eq, Nat.primeFactors] -- this convert is necessary because of the different DecidableEq instances - convert List.toFinset_coe _ + convert! List.toFinset_coe _ namespace Nat diff --git a/Mathlib/RingTheory/RamificationInertia/Inertia.lean b/Mathlib/RingTheory/RamificationInertia/Inertia.lean index ed00c8c3da8511..1832e595f5e45e 100644 --- a/Mathlib/RingTheory/RamificationInertia/Inertia.lean +++ b/Mathlib/RingTheory/RamificationInertia/Inertia.lean @@ -49,7 +49,7 @@ theorem inertiaDeg'_def [hq : q.IsPrime] [Algebra (Localization.AtPrime (q.under R)) (Localization.AtPrime q)] [Localization.AtPrime.IsLiesOverAlgebra (q.under R) q] : q.inertiaDeg' R = Module.finrank (q.under R).ResidueField q.ResidueField := by - convert dif_pos hq + convert! dif_pos hq simp [Algebra.algebra_ext_iff, Localization.AtPrime.IsLiesOverAlgebra.algebraMap_eq] theorem inertiaDeg'_of_not_isPrime (hq : ¬ q.IsPrime) : q.inertiaDeg' R = 0 := diff --git a/Mathlib/RingTheory/Regular/IsSMulRegular.lean b/Mathlib/RingTheory/Regular/IsSMulRegular.lean index 14f7f6c78e1681..ce1fd7f8a89024 100644 --- a/Mathlib/RingTheory/Regular/IsSMulRegular.lean +++ b/Mathlib/RingTheory/Regular/IsSMulRegular.lean @@ -164,7 +164,7 @@ lemma isSMulRegular_of_ker_lsmul_eq_bot variable {N} in lemma smul_top_inf_eq_smul_of_isSMulRegular_on_quot : IsSMulRegular (M ⧸ N) r → r • ⊤ ⊓ N ≤ r • N := by - convert map_mono ∘ (isSMulRegular_on_quot_iff_lsmul_comap_le N r).mp using 2 + convert! map_mono ∘ (isSMulRegular_on_quot_iff_lsmul_comap_le N r).mp using 2 exact Eq.trans (congrArg (· ⊓ N) (map_top _)) (map_comap_eq _ _).symm -- Who knew this didn't rely on exactness at the right!? diff --git a/Mathlib/RingTheory/Regular/LinearMap.lean b/Mathlib/RingTheory/Regular/LinearMap.lean index 0bcb3f8785655a..9835b42022974a 100644 --- a/Mathlib/RingTheory/Regular/LinearMap.lean +++ b/Mathlib/RingTheory/Regular/LinearMap.lean @@ -81,7 +81,7 @@ lemma subsingleton_linearMap_iff [IsNoetherianRing R] [Module.Finite R M] [Modul __ := g map_smul' r x := by simp only [AddHom.toFun_eq_coe, coe_toAddHom, RingHom.id_apply] - convert g.map_smul (Ideal.Quotient.mk _ r) x } + convert! g.map_smul (Ideal.Quotient.mk _ r) x } let to_res : Nₚ →ₗ[Rₚ] p.ResidueField := to_res'.comp ((maximalIdeal (Localization.AtPrime p)) • (⊤ : Submodule Rₚ Nₚ)).mkQ replace hx : maximalIdeal (Localization.AtPrime p) = (toSpanSingleton _ _ x).ker := diff --git a/Mathlib/RingTheory/Regular/RegularSequence.lean b/Mathlib/RingTheory/Regular/RegularSequence.lean index 5b687feb3037a5..8b2559f6416cda 100644 --- a/Mathlib/RingTheory/Regular/RegularSequence.lean +++ b/Mathlib/RingTheory/Regular/RegularSequence.lean @@ -162,7 +162,7 @@ private lemma _root_.AddHom.map_smul_top_toAddSubgroup_of_surjective (Ideal.ofList bs • ⊤ : Submodule S M₂).toAddSubgroup := by induction h with | nil => - convert AddSubgroup.map_bot f using 1 <;> + convert! AddSubgroup.map_bot f using 1 <;> rw [Ideal.ofList_nil, bot_smul, bot_toAddSubgroup] | @cons r s _ _ h _ ih => conv => congr <;> rw [Ideal.ofList_cons, sup_smul, sup_toAddSubgroup, diff --git a/Mathlib/RingTheory/RingHom/FinitePresentation.lean b/Mathlib/RingTheory/RingHom/FinitePresentation.lean index 1e9b47c4270c24..a4e234ce2cce70 100644 --- a/Mathlib/RingTheory/RingHom/FinitePresentation.lean +++ b/Mathlib/RingTheory/RingHom/FinitePresentation.lean @@ -60,7 +60,7 @@ theorem finitePresentation_ofLocalizationSpanTarget : introv R hs H algebraize [f] replace H : ∀ r ∈ s, Algebra.FinitePresentation R (Localization.Away (r : S)) := by - intro r hr; simp_rw [RingHom.FinitePresentation] at H; convert H ⟨r, hr⟩; ext + intro r hr; simp_rw [RingHom.FinitePresentation] at H; convert! H ⟨r, hr⟩; ext simp_rw [Algebra.smul_def]; rfl exact Algebra.FinitePresentation.of_span_eq_top_target s hs H diff --git a/Mathlib/RingTheory/RingHom/FiniteType.lean b/Mathlib/RingTheory/RingHom/FiniteType.lean index b5f30344a7e5a5..2b94ddb5958f73 100644 --- a/Mathlib/RingTheory/RingHom/FiniteType.lean +++ b/Mathlib/RingTheory/RingHom/FiniteType.lean @@ -81,7 +81,7 @@ theorem finiteType_ofLocalizationSpanTarget : OfLocalizationSpanTarget @FiniteTy introv R hs H algebraize [f] replace H : ∀ r ∈ s, Algebra.FiniteType R (Localization.Away (r : S)) := by - intro r hr; simp_rw [RingHom.FiniteType] at H; convert H ⟨r, hr⟩; ext + intro r hr; simp_rw [RingHom.FiniteType] at H; convert! H ⟨r, hr⟩; ext simp_rw [Algebra.smul_def]; rfl exact Algebra.FiniteType.of_span_eq_top_target s hs H diff --git a/Mathlib/RingTheory/RingHom/Flat.lean b/Mathlib/RingTheory/RingHom/Flat.lean index a74bcf4c5242fd..721195176b5a4a 100644 --- a/Mathlib/RingTheory/RingHom/Flat.lean +++ b/Mathlib/RingTheory/RingHom/Flat.lean @@ -78,7 +78,7 @@ lemma ofLocalizationSpanTarget : OfLocalizationSpanTarget Flat := by refine Module.flat_of_isLocalized_span _ _ s hsp _ (fun r ↦ Algebra.linearMap S <| Localization.Away r.1) ?_ dsimp only [RingHom.Flat] at h - convert h; ext + convert! h; ext apply Algebra.smul_def /-- Flat is a local property of ring homomorphisms. -/ diff --git a/Mathlib/RingTheory/RingHom/Locally.lean b/Mathlib/RingTheory/RingHom/Locally.lean index 60858fbbabb640..cc1a4f61fe5336 100644 --- a/Mathlib/RingTheory/RingHom/Locally.lean +++ b/Mathlib/RingTheory/RingHom/Locally.lean @@ -317,7 +317,7 @@ lemma locally_localizationAwayPreserves (hPl : LocalizationAwayPreserves P) : inferInstanceAs (IsLocalization.Away (rₐ a) (Sₐ a)) haveI (a : s) : IsLocalization (Algebra.algebraMapSubmonoid (Localization.Away a.val) (Submonoid.map f (Submonoid.powers r))) (Sₐ a) := by - convert (inferInstance : IsLocalization.Away (rₐ a) (Sₐ a)) + convert! (inferInstance : IsLocalization.Away (rₐ a) (Sₐ a)) simp [rₐ, Algebra.algebraMapSubmonoid] have H (a : s) : Submonoid.powers (f r) ≤ (Submonoid.powers (rₐ a)).comap (algebraMap S (Localization.Away a.val)) := by @@ -329,8 +329,9 @@ lemma locally_localizationAwayPreserves (hPl : LocalizationAwayPreserves P) : refine ⟨s, fun a ↦ algebraMap S S' a.val, ?_, Sₐ, inferInstance, inferInstance, fun a ↦ ?_, fun a ↦ ?_⟩ · rw [← Set.image_eq_range, ← Ideal.map_span, hsone, Ideal.map_top] - · convert IsLocalization.commutes (T := Sₐ a) (M₁ := (Submonoid.powers r).map f) (S₁ := S') - (S₂ := Localization.Away a.val) (M₂ := Submonoid.powers a.val) + · convert! + IsLocalization.commutes (T := Sₐ a) (M₁ := (Submonoid.powers r).map f) (S₁ := S') (S₂ := + Localization.Away a.val) (M₂ := Submonoid.powers a.val) simp [Algebra.algebraMapSubmonoid] · rw [algebraMap_toAlgebra, IsLocalization.Away.map, IsLocalization.map_comp_map] exact hPl ((algebraMap _ (Localization.Away a.val)).comp f) r R' (Sₐ a) (hs _ a.2) @@ -361,8 +362,9 @@ lemma locally_localizationPreserves (hPl : LocalizationPreserves P) : refine ⟨s, fun a ↦ algebraMap S S' a.val, ?_, Sₐ, inferInstance, inferInstance, fun a ↦ ?_, fun a ↦ ?_⟩ · rw [← Set.image_eq_range, ← Ideal.map_span, hsone, Ideal.map_top] - · convert IsLocalization.commutes (T := Sₐ a) (M₁ := M.map f) (S₁ := S') - (S₂ := Localization.Away a.val) (M₂ := Submonoid.powers a.val) + · convert! + IsLocalization.commutes (T := Sₐ a) (M₁ := M.map f) (S₁ := S') (S₂ := Localization.Away a.val) + (M₂ := Submonoid.powers a.val) simp [Algebra.algebraMapSubmonoid] · rw [algebraMap_toAlgebra, IsLocalization.map_comp_map] apply hPl diff --git a/Mathlib/RingTheory/RingHom/Smooth.lean b/Mathlib/RingTheory/RingHom/Smooth.lean index 0ec5488e17835b..ca757ab5bba703 100644 --- a/Mathlib/RingTheory/RingHom/Smooth.lean +++ b/Mathlib/RingTheory/RingHom/Smooth.lean @@ -108,8 +108,9 @@ lemma stableUnderComposition : StableUnderComposition Smooth := fun _ _ _ _ _ _ _ _ ↦ RingHom.Smooth.comp lemma isStableUnderBaseChange : IsStableUnderBaseChange Smooth := by - convert RingHom.FormallySmooth.isStableUnderBaseChange.and - RingHom.finitePresentation_isStableUnderBaseChange + convert! + RingHom.FormallySmooth.isStableUnderBaseChange.and + RingHom.finitePresentation_isStableUnderBaseChange rw [smooth_def] lemma holdsForLocalizationAway : HoldsForLocalizationAway Smooth := by diff --git a/Mathlib/RingTheory/RingHom/StandardSmooth.lean b/Mathlib/RingTheory/RingHom/StandardSmooth.lean index ec9fe9abc85930..72713dee616133 100644 --- a/Mathlib/RingTheory/RingHom/StandardSmooth.lean +++ b/Mathlib/RingTheory/RingHom/StandardSmooth.lean @@ -130,9 +130,9 @@ lemma isStandardSmooth_isStableUnderBaseChange : · exact isStandardSmooth_respectsIso · introv h replace h : Algebra.IsStandardSmooth R T := by - rw [RingHom.IsStandardSmooth] at h; convert h; ext; simp_rw [Algebra.smul_def]; rfl + rw [RingHom.IsStandardSmooth] at h; convert! h; ext; simp_rw [Algebra.smul_def]; rfl suffices Algebra.IsStandardSmooth S (S ⊗[R] T) by - rw [RingHom.IsStandardSmooth]; convert this; ext; simp_rw [Algebra.smul_def]; rfl + rw [RingHom.IsStandardSmooth]; convert! this; ext; simp_rw [Algebra.smul_def]; rfl infer_instance variable (n) @@ -144,10 +144,10 @@ lemma isStandardSmoothOfRelativeDimension_isStableUnderBaseChange : · introv h replace h : Algebra.IsStandardSmoothOfRelativeDimension n R T := by rw [RingHom.IsStandardSmoothOfRelativeDimension] at h - convert h; ext; simp_rw [Algebra.smul_def]; rfl + convert! h; ext; simp_rw [Algebra.smul_def]; rfl suffices Algebra.IsStandardSmoothOfRelativeDimension n S (S ⊗[R] T) by rw [RingHom.IsStandardSmoothOfRelativeDimension] - convert this; ext; simp_rw [Algebra.smul_def]; rfl + convert! this; ext; simp_rw [Algebra.smul_def]; rfl infer_instance lemma IsStandardSmoothOfRelativeDimension.algebraMap_isLocalizationAway {Rᵣ : Type*} [CommRing Rᵣ] @@ -223,7 +223,7 @@ theorem _root_.Algebra.IsStandardSmoothOfRelativeDimension.exists_etale_mvPolyno · simp [e] let P' : Algebra.PreSubmersivePresentation (MvPolynomial (Fin n) R) S σ σ := { toGenerators := .ofSurjective (algebraMap _ _ <| e <| .X ·) <| by - convert P.algebraMap_surjective.comp e.surjective + convert! P.algebraMap_surjective.comp e.surjective exact congr($H) relation := e.symm ∘ P.relation span_range_relation_eq_ker := by @@ -235,7 +235,7 @@ theorem _root_.Algebra.IsStandardSmoothOfRelativeDimension.exists_etale_mvPolyno let P' : Algebra.SubmersivePresentation (MvPolynomial (Fin n) R) S σ σ := { __ := P' jacobian_isUnit := by - convert P.jacobian_isUnit using 1 + convert! P.jacobian_isUnit using 1 simp_rw [Algebra.PreSubmersivePresentation.jacobian_eq_jacobiMatrix_det, map_det] congr 1 ext i j diff --git a/Mathlib/RingTheory/RingHom/Unramified.lean b/Mathlib/RingTheory/RingHom/Unramified.lean index 04b7e5a16f158a..bd73f63ea5d797 100644 --- a/Mathlib/RingTheory/RingHom/Unramified.lean +++ b/Mathlib/RingTheory/RingHom/Unramified.lean @@ -101,7 +101,7 @@ lemma ofLocalizationSpanTarget : simpa using (PrimeSpectrum.iSup_basicOpen_eq_top_iff'.mpr hs).ge (TopologicalSpace.Opens.mem_top x) refine Algebra.basicOpen_subset_unramifiedLocus_iff.mpr ?_ hrx - convert H ⟨r, hr⟩ + convert! H ⟨r, hr⟩ dsimp rw [← algebraMap_toAlgebra f, ← IsScalarTower.algebraMap_eq, formallyUnramified_algebraMap] diff --git a/Mathlib/RingTheory/RingHomProperties.lean b/Mathlib/RingTheory/RingHomProperties.lean index a5e6389153210b..ab50e47104778e 100644 --- a/Mathlib/RingTheory/RingHomProperties.lean +++ b/Mathlib/RingTheory/RingHomProperties.lean @@ -50,13 +50,13 @@ def RespectsIso : Prop := theorem RespectsIso.cancel_left_isIso (hP : RespectsIso @P) {R S T : CommRingCat} (f : R ⟶ S) (g : S ⟶ T) [IsIso f] : P (g.hom.comp f.hom) ↔ P g.hom := ⟨fun H => by - convert hP.2 (f ≫ g).hom (asIso f).symm.commRingCatIsoToRingEquiv H + convert! hP.2 (f ≫ g).hom (asIso f).symm.commRingCatIsoToRingEquiv H simp [← CommRingCat.hom_comp], hP.2 g.hom (asIso f).commRingCatIsoToRingEquiv⟩ theorem RespectsIso.cancel_right_isIso (hP : RespectsIso @P) {R S T : CommRingCat} (f : R ⟶ S) (g : S ⟶ T) [IsIso g] : P (g.hom.comp f.hom) ↔ P f.hom := ⟨fun H => by - convert hP.1 (f ≫ g).hom (asIso g).symm.commRingCatIsoToRingEquiv H + convert! hP.1 (f ≫ g).hom (asIso g).symm.commRingCatIsoToRingEquiv H simp [← CommRingCat.hom_comp], hP.1 f.hom (asIso g).commRingCatIsoToRingEquiv⟩ @@ -82,7 +82,7 @@ theorem RespectsIso.isLocalization_away_iff (hP : RingHom.RespectsIso @P) {R S : (Submonoid.powers (f r)))) : Localization.Away r →+* Localization.Away (f r)).comp (e₁ : R' →+* Localization.Away r)) suffices e = IsLocalization.Away.map R' S' f r by - convert this + convert! this apply IsLocalization.ringHom_ext (Submonoid.powers r) _ ext1 x dsimp [e, e₁, e₂, IsLocalization.Away.map] @@ -148,7 +148,7 @@ theorem IsStableUnderBaseChange.mk (h₁ : RespectsIso @P) suffices e.toLinearMap.restrictScalars R = f'.toLinearMap from congr($this x) exact ext' fun x y ↦ by simp [e, f', IsBaseChange.equiv_tmul, Algebra.smul_def] have hemul (x y : _) : e (x * y) = e x * e y := by simp_rw [hef, map_mul] - convert h₁.1 _ { e with map_mul' := hemul } (h₂ H) + convert! h₁.1 _ { e with map_mul' := hemul } (h₂ H) ext x simp [e, h.symm.1.equiv_tmul, Algebra.smul_def] diff --git a/Mathlib/RingTheory/RootsOfUnity/Complex.lean b/Mathlib/RingTheory/RootsOfUnity/Complex.lean index b05a9d9b16e444..04e26b62c9db2b 100644 --- a/Mathlib/RingTheory/RootsOfUnity/Complex.lean +++ b/Mathlib/RingTheory/RootsOfUnity/Complex.lean @@ -54,26 +54,26 @@ theorem isPrimitiveRoot_exp_of_coprime (i n : ℕ) (h0 : n ≠ 0) (hi : i.Coprim isPrimitiveRoot_exp_of_isCoprime _ _ h0 hi.isCoprime theorem isPrimitiveRoot_exp_rat (q : ℚ) : IsPrimitiveRoot (exp (2 * π * I * q)) q.den := by - convert isPrimitiveRoot_exp_of_isCoprime _ _ q.den_nz <| - Int.isCoprime_iff_nat_coprime.mpr q.reduced + convert! + isPrimitiveRoot_exp_of_isCoprime _ _ q.den_nz <| Int.isCoprime_iff_nat_coprime.mpr q.reduced nth_rw 1 [← Rat.num_div_den q] simp theorem isPrimitiveRoot_exp_rat_of_even_num (q : ℚ) (h : Even q.num) : IsPrimitiveRoot (exp (π * I * q)) q.den := by have ⟨n, hn⟩ := even_iff_exists_two_nsmul _ |>.mp h - convert isPrimitiveRoot_exp_rat (n / q.den) using 1 + convert! isPrimitiveRoot_exp_rat (n / q.den) using 1 · nth_rw 1 [← q.num_div_den, hn, Int.nsmul_eq_mul] push_cast ring_nf · rw [← Int.cast_natCast, ← Rat.divInt_eq_div, ← Rat.mk_eq_divInt (nz := by simp)] apply Nat.Coprime.coprime_mul_left (k := 2) - convert q.reduced + convert! q.reduced grind theorem isPrimitiveRoot_exp_rat_of_odd_num (q : ℚ) (h : Odd q.num) : IsPrimitiveRoot (exp (π * I * q)) (2 * q.den) := by - convert isPrimitiveRoot_exp_rat (q / 2) using 1 + convert! isPrimitiveRoot_exp_rat (q / 2) using 1 · push_cast ring_nf · nth_rw 2 [← q.num_div_den] @@ -163,10 +163,10 @@ theorem IsPrimitiveRoot.arg {n : ℕ} {ζ : ℂ} (h : IsPrimitiveRoot ζ n) (hn replace hin := Nat.isCoprime_iff_coprime.mpr hin split_ifs · exact hin - · convert hin.add_mul_left_left (-1) using 1 + · convert! hin.add_mul_left_left (-1) using 1 rw [mul_neg_one, sub_eq_add_neg] split_ifs with h₂ - · convert Complex.arg_cos_add_sin_mul_I _ + · convert! Complex.arg_cos_add_sin_mul_I _ · push_cast; rfl · push_cast; rfl simp only [Int.cast_natCast, Set.mem_Ioc] @@ -178,7 +178,7 @@ theorem IsPrimitiveRoot.arg {n : ℕ} {ζ : ℂ} (h : IsPrimitiveRoot ζ n) (hn exact mul_le_of_le_one_right Real.pi_pos.le ((div_le_iff₀' <| mod_cast pos_of_gt h).mpr <| mod_cast h₂) rw [← Complex.cos_sub_two_pi, ← Complex.sin_sub_two_pi] - convert Complex.arg_cos_add_sin_mul_I _ + convert! Complex.arg_cos_add_sin_mul_I _ · push_cast rw [← sub_one_mul, sub_div, div_self] exact mod_cast hn diff --git a/Mathlib/RingTheory/RootsOfUnity/CyclotomicUnits.lean b/Mathlib/RingTheory/RootsOfUnity/CyclotomicUnits.lean index 930b1dc7a3d7b9..04235887b02e7e 100644 --- a/Mathlib/RingTheory/RootsOfUnity/CyclotomicUnits.lean +++ b/Mathlib/RingTheory/RootsOfUnity/CyclotomicUnits.lean @@ -86,7 +86,7 @@ theorem associated_map_sub_one_map_sub_one {n : ℕ} [NeZero n] (hζ : IsPrimiti theorem geom_sum_isUnit (hζ : IsPrimitiveRoot ζ n) (hn : 2 ≤ n) (hj : j.Coprime n) : IsUnit (∑ i ∈ range j, ζ ^ i) := by obtain ⟨u, hu⟩ := hζ.associated_pow_sub_one_pow_of_coprime hj (coprime_one_left n) - convert u.isUnit + convert! u.isUnit apply mul_right_injective₀ (show 1 - ζ ≠ 0 by grind [sub_one_ne_zero]) grind [mul_neg_geom_sum] diff --git a/Mathlib/RingTheory/RootsOfUnity/Minpoly.lean b/Mathlib/RingTheory/RootsOfUnity/Minpoly.lean index 66ac9aecc4f7ed..cee6484f6fc28b 100644 --- a/Mathlib/RingTheory/RootsOfUnity/Minpoly.lean +++ b/Mathlib/RingTheory/RootsOfUnity/Minpoly.lean @@ -61,8 +61,7 @@ theorem minpoly_dvd_x_pow_sub_one : minpoly ℤ μ ∣ X ^ n - 1 := by theorem separable_minpoly_mod {p : ℕ} [Fact p.Prime] (hdiv : ¬p ∣ n) : Separable (map (Int.castRingHom (ZMod p)) (minpoly ℤ μ)) := by have hdvd : map (Int.castRingHom (ZMod p)) (minpoly ℤ μ) ∣ X ^ n - 1 := by - convert _root_.map_dvd (mapRingHom (Int.castRingHom (ZMod p))) - (minpoly_dvd_x_pow_sub_one h) + convert! _root_.map_dvd (mapRingHom (Int.castRingHom (ZMod p))) (minpoly_dvd_x_pow_sub_one h) simp only [map_sub, map_pow, coe_mapRingHom, map_X, map_one] refine Separable.of_dvd (separable_X_pow_sub_C 1 ?_ one_ne_zero) hdvd by_contra hzero @@ -199,7 +198,7 @@ theorem is_roots_of_minpoly [DecidableEq K] : intro x hx obtain ⟨m, _, hcop, rfl⟩ := (isPrimitiveRoot_iff h).1 ((mem_primitiveRoots hpos).1 hx) simp only [Multiset.mem_toFinset] - convert pow_isRoot_minpoly h hcop using 0 + convert! pow_isRoot_minpoly h hcop using 0 rw [← mem_roots] exact map_monic_ne_zero <| minpoly.monic <| isIntegral h hpos diff --git a/Mathlib/RingTheory/RootsOfUnity/PrimitiveRoots.lean b/Mathlib/RingTheory/RootsOfUnity/PrimitiveRoots.lean index 86ea593086cd71..590ce35e936184 100644 --- a/Mathlib/RingTheory/RootsOfUnity/PrimitiveRoots.lean +++ b/Mathlib/RingTheory/RootsOfUnity/PrimitiveRoots.lean @@ -228,9 +228,10 @@ theorem pow_mul_pow_lcm {ζ' : M} {k' : ℕ} (hζ : IsPrimitiveRoot ζ k) (hζ' IsPrimitiveRoot (ζ ^ (k / Nat.factorizationLCMLeft k k') * ζ' ^ (k' / Nat.factorizationLCMRight k k')) (Nat.lcm k k') := by - convert IsPrimitiveRoot.orderOf _ - convert ((Commute.all ζ ζ').orderOf_mul_pow_eq_lcm - (by simpa [← hζ.eq_orderOf]) (by simpa [← hζ'.eq_orderOf])).symm using 2 + convert! IsPrimitiveRoot.orderOf _ + convert! + ((Commute.all ζ ζ').orderOf_mul_pow_eq_lcm (by simpa [← hζ.eq_orderOf]) + (by simpa [← hζ'.eq_orderOf])).symm using 2 all_goals simp [hζ.eq_orderOf, hζ'.eq_orderOf] theorem pow_of_dvd (h : IsPrimitiveRoot ζ k) {p : ℕ} (hp : p ≠ 0) (hdiv : p ∣ k) : @@ -422,7 +423,7 @@ theorem eq_neg_one_of_two_right [NoZeroDivisors R] {ζ : R} (h : IsPrimitiveRoot theorem neg_one (p : ℕ) [Nontrivial R] [h : CharP R p] (hp : p ≠ 2) : IsPrimitiveRoot (-1 : R) 2 := by - convert IsPrimitiveRoot.orderOf (-1 : R) + convert! IsPrimitiveRoot.orderOf (-1 : R) rw [orderOf_neg_one, if_neg <| by rwa [ringChar.eq_iff.mpr h]] /-- If `1 < k` then `(∑ i ∈ range k, ζ ^ i) = 0`. -/ @@ -790,7 +791,7 @@ noncomputable def autToPow [NeZero n] : (S ≃ₐ[R] S) →* (ZMod n)ˣ := replace h : μ' = μ' ^ h1.choose := rootsOfUnity.coe_injective (by simpa only [rootsOfUnity.coe_pow] using h) nth_rw 1 [← pow_one μ'] at h - convert ho ▸ (ZMod.natCast_eq_natCast_iff ..).mpr (pow_eq_pow_iff_modEq.mp h).symm + convert! ho ▸ (ZMod.natCast_eq_natCast_iff ..).mpr (pow_eq_pow_iff_modEq.mp h).symm exact Nat.cast_one.symm map_mul' := by intro x y @@ -804,7 +805,7 @@ noncomputable def autToPow [NeZero n] : (S ≃ₐ[R] S) →* (ZMod n)ˣ := rw [← pow_mul] at hxy replace hxy : μ' ^ (hx'.choose * hy'.choose) = μ' ^ hxy'.choose := rootsOfUnity.coe_injective (by simpa only [rootsOfUnity.coe_pow] using hxy) - convert ho ▸ (ZMod.natCast_eq_natCast_iff ..).mpr (pow_eq_pow_iff_modEq.mp hxy).symm + convert! ho ▸ (ZMod.natCast_eq_natCast_iff ..).mpr (pow_eq_pow_iff_modEq.mp hxy).symm exact (Nat.cast_mul ..).symm } -- We are not using @[simps] in `autToPow` to avoid a timeout. diff --git a/Mathlib/RingTheory/SimpleModule/Basic.lean b/Mathlib/RingTheory/SimpleModule/Basic.lean index 60aa65e964980a..9105cda93b03cf 100644 --- a/Mathlib/RingTheory/SimpleModule/Basic.lean +++ b/Mathlib/RingTheory/SimpleModule/Basic.lean @@ -170,7 +170,7 @@ theorem isSimpleModule_iff_quot_maximal : have ⟨m, hm⟩ := exists_ne (0 : M) exact ⟨_, ker_toSpanSingleton_isMaximal R hm, ⟨(LinearMap.quotKerEquivOfSurjective _ <| toSpanSingleton_surjective R hm).symm⟩⟩ - · convert congr equiv; rwa [isSimpleModule_iff_isCoatom] + · convert! congr equiv; rwa [isSimpleModule_iff_isCoatom] /-- In general, the annihilator of a simple module is called a primitive ideal, and it is always a two-sided prime ideal, but mathlib's `Ideal.IsPrime` is not the correct definition diff --git a/Mathlib/RingTheory/SimpleModule/Isotypic.lean b/Mathlib/RingTheory/SimpleModule/Isotypic.lean index 66edd46678ae71..de62cf0c6ed01a 100644 --- a/Mathlib/RingTheory/SimpleModule/Isotypic.lean +++ b/Mathlib/RingTheory/SimpleModule/Isotypic.lean @@ -469,7 +469,7 @@ theorem isFullyInvariant_iff_sSup_isotypicComponents {m : Submodule R M} : m.IsFullyInvariant ↔ ∃ s ⊆ isotypicComponents R M, m = sSup s := by refine ⟨fun h ↦ ⟨OrderIso.setIsotypicComponents.symm ⟨m, h⟩, ⟨?_, ?_⟩⟩, ?_⟩ · rintro _ ⟨c, _, rfl⟩; exact c.2 - · convert Subtype.ext_iff.mp (OrderIso.setIsotypicComponents.right_inv ⟨m, h⟩).symm + · convert! Subtype.ext_iff.mp (OrderIso.setIsotypicComponents.right_inv ⟨m, h⟩).symm simp [sSup_image, OrderIso.setIsotypicComponents, OrderIso.symm] · rintro ⟨_, hs, rfl⟩ exact (fullyInvariantSubmodule R M).sSupClosed fun _ h ↦ .of_mem_isotypicComponents (hs h) diff --git a/Mathlib/RingTheory/Smooth/Basic.lean b/Mathlib/RingTheory/Smooth/Basic.lean index c3fbf0a1423383..69677416cea5cc 100644 --- a/Mathlib/RingTheory/Smooth/Basic.lean +++ b/Mathlib/RingTheory/Smooth/Basic.lean @@ -107,17 +107,16 @@ lemma FormallySmooth.comp_surjective [FormallySmooth R A] (I : Ideal B) (hI : I simpa using (Function.surjInv_eq _ _).symm exact ⟨l.comp g, by rw [← AlgHom.comp_assoc, ← this, AlgHom.comp_assoc, hg, AlgHom.comp_id]⟩ -set_option backward.isDefEq.respectTransparency false in -instance mvPolynomial (σ : Type*) : FormallySmooth R (MvPolynomial σ R) := by - let P : Generators R (MvPolynomial σ R) σ := - .ofSurjective X (by simp [aeval_X_left, Function.Surjective]) +instance instFormallySmoothMvPolynomial (σ : Type*) : FormallySmooth R (MvPolynomial σ R) := by + let P := Generators.mvPolynomial R σ have : Subsingleton ↥P.toExtension.ker := - Submodule.subsingleton_iff_eq_bot.mpr <| by - simp [SetLike.ext_iff, P, Generators.ofSurjective, aeval_X_left] + Submodule.subsingleton_iff_eq_bot.mpr Generators.ker_mvPolynomial have : Subsingleton P.toExtension.Cotangent := Cotangent.mk_surjective.subsingleton have := P.toExtension.h1Cotangentι_injective.subsingleton exact ⟨inferInstance, P.equivH1Cotangent.symm.subsingleton⟩ +@[deprecated (since := "2026-05-22")] alias mvPolynomial := instFormallySmoothMvPolynomial + end namespace FormallySmooth @@ -293,8 +292,10 @@ theorem iff_split_injection rw [formallySmooth_iff, and_comm, Module.Projective.iff_split_of_projective (KaehlerDifferential.mapBaseChange R P A) (mapBaseChange_surjective R P A hf), ← kerCotangentToTensor_injective_iff hf] - convert (((exact_kerCotangentToTensor_mapBaseChange R _ _ hf).split_tfae' - (g := (KaehlerDifferential.mapBaseChange R P A).restrictScalars P)).out 0 1) using 2 + convert! + (((exact_kerCotangentToTensor_mapBaseChange R _ _ hf).split_tfae' (g := + (KaehlerDifferential.mapBaseChange R P A).restrictScalars P)).out + 0 1) using 2 · rw [← (LinearMap.extendScalarsOfSurjectiveEquiv hf).exists_congr_right] simp [LinearMap.ext_iff] · rw [and_iff_right (by exact mapBaseChange_surjective R P A hf)] @@ -480,7 +481,7 @@ theorem of_isLocalization : FormallySmooth R Rₘ := by have : ∀ x : M, IsUnit (algebraMap R Q x) := by intro x apply (IsNilpotent.isUnit_quotient_mk_iff ⟨2, e⟩).mp - convert (IsLocalization.map_units Rₘ x).map f + convert! (IsLocalization.map_units Rₘ x).map f simp only [Ideal.Quotient.mk_algebraMap, AlgHom.commutes] let this : Rₘ →ₐ[R] Q := { IsLocalization.lift this with commutes' := IsLocalization.lift_eq this } diff --git a/Mathlib/RingTheory/Smooth/Fiber.lean b/Mathlib/RingTheory/Smooth/Fiber.lean index d4ed4b2294e485..32fd91aa0ed1d4 100644 --- a/Mathlib/RingTheory/Smooth/Fiber.lean +++ b/Mathlib/RingTheory/Smooth/Fiber.lean @@ -125,7 +125,7 @@ private lemma FormallySmooth.of_formallySmooth_residueField_tensor_aux (AlgebraTensorModule.congr (.refl 𝓀[S] 𝓀[S]) e₁).restrictScalars S ≪≫ₗ (AlgebraTensorModule.cancelBaseChange P Pp Sp 𝓀[S] _).restrictScalars S -- It remains to check that the two maps are equal under the identifications above. - convert (eᵣ.injective.comp this).comp eₗ.symm.injective + convert! (eᵣ.injective.comp this).comp eₗ.symm.injective ext x dsimp induction x with @@ -169,7 +169,7 @@ lemma FormallySmooth.of_formallySmooth_residueField_tensor (M : Submonoid P) simp [fP, IsLocalization.lift_mk', Units.mul_inv_eq_iff_eq_mul, IsUnit.liftRight] have hfP : (RingHom.ker fP).FG := by have := Algebra.FinitePresentation.ker_fG_of_surjective _ hf₀ - convert this.map (algebraMap _ P') + convert! this.map (algebraMap _ P') refine le_antisymm ?_ (Ideal.map_le_iff_le_comap.mpr fun x hx ↦ by simp_all [fP]) intro x hx obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq M' x diff --git a/Mathlib/RingTheory/Smooth/Field.lean b/Mathlib/RingTheory/Smooth/Field.lean index 2142daca169313..ca760870af23e6 100644 --- a/Mathlib/RingTheory/Smooth/Field.lean +++ b/Mathlib/RingTheory/Smooth/Field.lean @@ -54,5 +54,5 @@ instance (priority := low) Algebra.FormallySmooth.of_perfectField [PerfectField K] [Algebra.EssFiniteType K L] : Algebra.FormallySmooth K L := by obtain ⟨s, hs, H⟩ := exists_isTranscendenceBasis_and_isSeparable_of_perfectField K L have : Algebra.IsSeparable (↥(IntermediateField.adjoin K (Set.range ((↑) : s → L)))) L := by - convert H <;> simp + convert! H <;> simp exact .of_algebraicIndependent_of_isSeparable hs.1 diff --git a/Mathlib/RingTheory/Smooth/IntegralClosure.lean b/Mathlib/RingTheory/Smooth/IntegralClosure.lean index e9b7e0852c36d9..667ceaa54a7970 100644 --- a/Mathlib/RingTheory/Smooth/IntegralClosure.lean +++ b/Mathlib/RingTheory/Smooth/IntegralClosure.lean @@ -44,8 +44,8 @@ def TensorProduct.toIntegralClosure | zero => simp | add x y _ _ => rw [map_add]; exact add_mem ‹_› ‹_› | tmul x y => - convert ((y.2.map (Algebra.TensorProduct.includeRight - (R := R) (A := S))).tower_top (A := S)).smul x + convert! + ((y.2.map (Algebra.TensorProduct.includeRight (R := R) (A := S))).tower_top (A := S)).smul x simp [smul_tmul'] lemma TensorProduct.toIntegralClosure_injective_of_flat [Module.Flat R S] : @@ -65,7 +65,7 @@ lemma TensorProduct.toIntegralClosure_bijective_of_tower (Algebra.TensorProduct.congr (.refl (R := T) (A₁ := T)) (.ofBijective _ H)).trans <| (AlgEquiv.ofBijective _ H').trans <| (AlgEquiv.mapIntegralClosure (Algebra.TensorProduct.cancelBaseChange ..)) - convert e.bijective + convert! e.bijective rw [← e.coe_algHom] congr 1 ext; simp [e, toIntegralClosure] @@ -109,8 +109,9 @@ lemma TensorProduct.toIntegralClosure_bijective_of_isLocalizationAway (fun r ↦ (Algebra.TensorProduct.map (Algebra.ofId _ _) (.id _ _)).toLinearMap) (fun r ↦ integralClosure (Sᵣ r) ((Sᵣ r) ⊗[R] B)) (fun r ↦ (φ r).toLinearMap) fun r ↦ ?_ - convert show Function.Bijective ((toIntegralClosure R (Sᵣ r) B).toLinearMap.restrictScalars S) - from H r using 1 + convert! + show Function.Bijective ((toIntegralClosure R (Sᵣ r) B).toLinearMap.restrictScalars S) from + H r using 1 congr! refine IsLocalizedModule.ext (.powers r.1) (Algebra.TensorProduct.map (Algebra.ofId S (Sᵣ r)) (AlgHom.id R (integralClosure R B))).toLinearMap @@ -162,16 +163,18 @@ lemma TensorProduct.toIntegralClosure_bijective_of_isLocalization AlgHom.codRestrict (Algebra.TensorProduct.includeRight.comp (integralClosure R B).val) ((integralClosure S (S ⊗[R] B)).restrictScalars R) fun ⟨x, hx⟩ ↦ by refine .of_comp (f := algebraMap R S) ?_ - convert RingHom.IsIntegralElem.map hx - (Algebra.TensorProduct.includeRight : B →ₐ[R] S ⊗[R] B).toRingHom + convert! + RingHom.IsIntegralElem.map hx + (Algebra.TensorProduct.includeRight : B →ₐ[R] S ⊗[R] B).toRingHom simp [← IsScalarTower.algebraMap_eq] let := φ.toAlgebra have := IsScalarTower.of_algebraMap_eq' φ.comp_algebraMap.symm have : IsScalarTower (integralClosure R B) (integralClosure S (S ⊗[R] B)) (S ⊗[R] B) := .of_algebraMap_eq' rfl have := IsLocalization.integralClosure (S := B) M (Rf := S) (Sf := S ⊗[R] B) - convert (IsLocalization.algEquiv (Algebra.algebraMapSubmonoid (integralClosure R B) M) - (S ⊗[R] integralClosure R B) (integralClosure S (S ⊗[R] B))).bijective + convert! + (IsLocalization.algEquiv (Algebra.algebraMapSubmonoid (integralClosure R B) M) + (S ⊗[R] integralClosure R B) (integralClosure S (S ⊗[R] B))).bijective rw [← AlgHom.coe_restrictScalars' R, ← AlgEquiv.coe_restrictScalars' R, ← AlgEquiv.coe_algHom] congr 1 ext1 @@ -308,7 +311,7 @@ theorem mem_adjoin_map_integralClosure_of_isStandardEtale [Algebra.IsStandardEta have := 𝓟.monic_f.finite_adjoinRoot let e : AdjoinRoot 𝓟.f →ₐ[R] AdjoinRoot 𝓟'.f := AdjoinRoot.mapAlgHom (Algebra.ofId _ _) _ _ (dvd_refl _) - convert (Algebra.IsIntegral.isIntegral (R := R) (AdjoinRoot.mk 𝓟.f 𝓟.g)).map e + convert! (Algebra.IsIntegral.isIntegral (R := R) (AdjoinRoot.mk 𝓟.f 𝓟.g)).map e have : (AdjoinRoot.mk 𝓟'.f).comp (mapRingHom (algebraMap R B)) = e.toRingHom.comp (AdjoinRoot.mk _) := by ext <;> simp [e] exact congr($this 𝓟.g) @@ -323,7 +326,7 @@ theorem mem_adjoin_map_integralClosure_of_isStandardEtale [Algebra.IsStandardEta -- And `gᵏ • a` is still `R`-integral for `k` large enough. obtain ⟨k, hk⟩ : ∃ k, IsIntegral R (AdjoinRoot.mk 𝓟'.f 𝓟'.g ^ k * a) := by have H : ∀ k, e (1 ⊗ₜ (aeval 𝓟.x 𝓟.g ^ k)) = algebraMap _ _ (AdjoinRoot.mk 𝓟'.f 𝓟'.g ^ k) := by - intro k; convert congr($(heg 𝓟.g) ^ k) <;> + intro k; convert! congr($(heg 𝓟.g) ^ k) <;> simp [← map_pow, 𝓟', StandardEtalePresentation.baseChange] have := ((hx m).map (Algebra.TensorProduct.comm _ _ _).symm).map e simp only [Algebra.smul_def, Algebra.TensorProduct.algebraMap_apply, Algebra.algebraMap_self, @@ -331,7 +334,7 @@ theorem mem_adjoin_map_integralClosure_of_isStandardEtale [Algebra.IsStandardEta AlgEquiv.apply_symm_apply] at this rw [H, pow_add, map_mul, mul_assoc, IsLocalization.mk'_spec'_mk, ← map_mul] at this obtain ⟨k, hk⟩ := IsLocalization.Away.exists_isIntegral_mul_of_isIntegral_algebraMap hfg this - refine ⟨k + n, by convert hk using 1; ring_nf⟩ + refine ⟨k + n, by convert! hk using 1; ring_nf⟩ -- We now use the key lemma `exists_derivative_mul_eq_and_isIntegral_coeff` to get a `y : B[X]` -- with `R`-integral coefficients such that `f' * gᵏ * a = y` in `S ⊗[R] B`. obtain ⟨y, hy, hRy⟩ := exists_derivative_mul_eq_and_isIntegral_coeff @@ -343,7 +346,7 @@ theorem mem_adjoin_map_integralClosure_of_isStandardEtale [Algebra.IsStandardEta rw [← Subalgebra.mem_toSubmodule, ← Submodule.smul_mem_iff_of_isUnit _ (𝓟.hasMap.isUnit_derivative_f.mul <| (𝓟.hasMap.2.pow k).mul (𝓟.hasMap.2.pow m))] convert_to eval₂ Algebra.TensorProduct.includeRight.toRingHom (𝓟.x ⊗ₜ[R] 1) y ∈ _ using 1 - · convert congr(Algebra.TensorProduct.comm _ _ _ <| e.symm (algebraMap _ _ $hy)) + · convert! congr(Algebra.TensorProduct.comm _ _ _ <| e.symm (algebraMap _ _ $hy)) · apply (Algebra.TensorProduct.comm R B S).symm.injective apply e.injective simp only [Algebra.smul_def, Algebra.TensorProduct.algebraMap_apply, Algebra.algebraMap_self, diff --git a/Mathlib/RingTheory/Smooth/NoetherianDescent.lean b/Mathlib/RingTheory/Smooth/NoetherianDescent.lean index fadae704bac92d..864beb323b18d2 100644 --- a/Mathlib/RingTheory/Smooth/NoetherianDescent.lean +++ b/Mathlib/RingTheory/Smooth/NoetherianDescent.lean @@ -211,7 +211,7 @@ public theorem exists_subalgebra_fg [Smooth A B] : algHom_ext (by simp [hh]) have (j : _) : Ideal.Quotient.mk (RingHom.ker f ^ 2) (aeval h (P.relation j)) = 0 := by suffices ho : σ (aeval P.val (P.relation j)) = 0 by - convert ho + convert! ho exact congr($hdiag _) simp simp_rw [Ideal.Quotient.eq_zero_iff_mem, hkerf, diff --git a/Mathlib/RingTheory/Smooth/Pi.lean b/Mathlib/RingTheory/Smooth/Pi.lean index abec27b5624ac3..a9154eef777ce2 100644 --- a/Mathlib/RingTheory/Smooth/Pi.lean +++ b/Mathlib/RingTheory/Smooth/Pi.lean @@ -37,7 +37,7 @@ theorem of_pi [FormallySmooth R (Π i, A i)] (i) : Ideal.Quotient.eq_zero_iff_mem] have : Pi.single i 1 - 1 ∈ RingHom.ker (Pi.evalAlgHom R A i).toRingHom := by simp [RingHom.mem_ker] - convert neg_mem (Ideal.pow_mem_pow this 2) using 1 + convert! neg_mem (Ideal.pow_mem_pow this 2) using 1 simp [pow_two, sub_mul, mul_sub, ← Pi.single_mul] · intro x y change Ideal.Quotient.mk _ _ = Ideal.Quotient.mk _ _ * Ideal.Quotient.mk _ _ diff --git a/Mathlib/RingTheory/Smooth/Quotient.lean b/Mathlib/RingTheory/Smooth/Quotient.lean index 039c9fdb9e1a5d..1ec859b7b3ccc9 100644 --- a/Mathlib/RingTheory/Smooth/Quotient.lean +++ b/Mathlib/RingTheory/Smooth/Quotient.lean @@ -104,14 +104,14 @@ lemma Algebra.FormallySmooth.of_surjective_of_ker_eq_map_of_flat [Module.Flat R (sq0 : (RingHom.ker (algebraMap R R')) ^ 2 = ⊥) (smoothq : Algebra.FormallySmooth R' S') : Algebra.FormallySmooth R S := by let P := (Algebra.Generators.self R S).toExtension - let : Algebra.FormallySmooth R P.Ring := Algebra.mvPolynomial S + let : Algebra.FormallySmooth R P.Ring := instFormallySmoothMvPolynomial S let IP := (RingHom.ker (algebraMap R R')).map (algebraMap R P.Ring) let Gen : Algebra.Generators R' S' S := { val := algebraMap S S' σ' := fun s' ↦ MvPolynomial.X (Classical.choose (surjS s')) aeval_val_σ' s' := by simp [Classical.choose_spec (surjS s')] } let P' := Gen.toExtension - let : Algebra.FormallySmooth R' P'.Ring := Algebra.mvPolynomial S + let : Algebra.FormallySmooth R' P'.Ring := instFormallySmoothMvPolynomial S let : Algebra P.Ring P'.Ring := MvPolynomial.algebraMvPolynomial let : IsScalarTower R P.Ring P'.Ring := IsScalarTower.of_algebraMap_eq (fun x ↦ (MvPolynomial.map_C _ x).symm) diff --git a/Mathlib/RingTheory/Smooth/StandardSmoothCotangent.lean b/Mathlib/RingTheory/Smooth/StandardSmoothCotangent.lean index 826a96cb9a3f91..874d32b540b894 100644 --- a/Mathlib/RingTheory/Smooth/StandardSmoothCotangent.lean +++ b/Mathlib/RingTheory/Smooth/StandardSmoothCotangent.lean @@ -204,7 +204,7 @@ noncomputable def basisKaehlerOfIsCompl {κ : Type*} {f : κ → ι} simp [← hcompl.compl_eq] · simp only [sectionCotangent, LinearMap.coe_comp, Function.comp_assoc, LinearEquiv.coe_coe] apply LinearIndependent.map' _ _ P.cotangentEquiv.symm.ker - convert (Pi.basisFun S σ).linearIndependent + convert! (Pi.basisFun S σ).linearIndependent classical ext i j simp only [Function.comp_apply, Basis.repr_self, Finsupp.linearEquivFunOnFinite_apply, @@ -325,7 +325,7 @@ lemma IsStandardSmoothOfRelativeDimension.iff_of_isStandardSmooth [Nontrivial S] apply Nat.cast_injective (R := Cardinal) rwa [← P.rank_kaehlerDifferential] -instance IsStandardSmoothOfRelationDimension.subsingleton_kaehlerDifferential +instance IsStandardSmoothOfRelativeDimension.subsingleton_kaehlerDifferential [IsStandardSmoothOfRelativeDimension 0 R S] : Subsingleton Ω[S⁄R] := by cases subsingleton_or_nontrivial S · exact Module.subsingleton S _ @@ -333,6 +333,10 @@ instance IsStandardSmoothOfRelationDimension.subsingleton_kaehlerDifferential exact Module.subsingleton_of_rank_zero (IsStandardSmoothOfRelativeDimension.rank_kaehlerDifferential 0) +@[deprecated (since := "2026-05-22")] +alias IsStandardSmoothOfRelationDimension.subsingleton_kaehlerDifferential := + IsStandardSmoothOfRelativeDimension.subsingleton_kaehlerDifferential + end instance (priority := 900) [IsStandardSmooth R S] : Smooth R S where diff --git a/Mathlib/RingTheory/Spectrum/Prime/Chevalley.lean b/Mathlib/RingTheory/Spectrum/Prime/Chevalley.lean index bb6bfeb6a899f5..9297286dbe9a34 100644 --- a/Mathlib/RingTheory/Spectrum/Prime/Chevalley.lean +++ b/Mathlib/RingTheory/Spectrum/Prime/Chevalley.lean @@ -80,8 +80,9 @@ theorem isOpenMap_comap_algebraMap_tensorProduct_of_field obtain ⟨B', hB, f, rfl⟩ := exists_fg_and_mem_baseChange f have : Algebra.FinitePresentation K B' := Algebra.FinitePresentation.of_finiteType.mp ⟨B'.fg_top.mpr hB⟩ - convert isOpenMap_comap_of_hasGoingDown_of_finitePresentation (R := A) (S := A ⊗[K] B') _ - (basicOpen f).isOpen using 1 + convert! + isOpenMap_comap_of_hasGoingDown_of_finitePresentation (R := A) (S := A ⊗[K] B') _ + (basicOpen f).isOpen using 1 ext x rw [PrimeSpectrum.mem_image_comap_basicOpen, PrimeSpectrum.mem_image_comap_basicOpen, not_iff_not] diff --git a/Mathlib/RingTheory/Spectrum/Prime/ChevalleyComplexity.lean b/Mathlib/RingTheory/Spectrum/Prime/ChevalleyComplexity.lean index 72ba82d2dbecce..7dea7041a84cfa 100644 --- a/Mathlib/RingTheory/Spectrum/Prime/ChevalleyComplexity.lean +++ b/Mathlib/RingTheory/Spectrum/Prime/ChevalleyComplexity.lean @@ -203,7 +203,7 @@ private lemma induction_structure (n : ℕ) by_cases he0 : e = ⟨0⟩ · exact he0 ▸ hP₁ R cases subsingleton_or_nontrivial R - · convert hP₁ R; ext; exact Subsingleton.elim _ _ + · convert! hP₁ R; ext; exact Subsingleton.elim _ _ simp only [InductionObj.ext_iff, funext_iff, Pi.zero_apply, not_forall] at he0 -- Case I : The `e i ≠ 0` with minimal degree has invertible leading coefficient by_cases H : (∃ i, (e.1 i).Monic ∧ ∀ j, e.1 j ≠ 0 → (e.1 i).degree ≤ (e.1 j).degree) @@ -357,7 +357,7 @@ private lemma induction_aux (R : Type*) [CommRing R] [Algebra R₀ R] _ = ⋃ C ∈ S₁ ∪ S₂, C.toSet := by simpa using (Set.biUnion_union (SetLike.coe S₁) S₂ _).symm congr 1 - · convert congr(comap q₁.toRingHom '' $hT₁) + · convert! congr(comap q₁.toRingHom '' $hT₁) · dsimp only [e₁] rw [Set.preimage_diff, preimage_comap_zeroLocus, preimage_comap_zeroLocus, Set.image_singleton, Pi.smul_def, ← Set.smul_set_range, Set.range_comp] @@ -384,7 +384,7 @@ private lemma induction_aux (R : Type*) [CommRing R] [Algebra R₀ R] ← pow_succ'] simp only [← smul_eq_mul, ← Set.smul_set_range, ← Set.smul_set_singleton, zeroLocus_smul_of_isUnit ((isUnit_of_invertible (q₁ c)).pow _)] - · convert congr(comap q₂.toRingHom '' $hT₂) + · convert! congr(comap q₂.toRingHom '' $hT₂) · rw [Set.preimage_diff, preimage_comap_zeroLocus, preimage_comap_zeroLocus, Set.image_singleton, Set.range_comp, AlgHom.toRingHom_eq_coe] · rw [ConstructibleSetData.toSet, Set.image_iUnion₂] @@ -436,7 +436,7 @@ private lemma statement : ∀ S : InductionObj R n, Statement R₀ R n S := by apply induction_structure · intro R _ R₀ _ _ f refine ⟨(Finset.range (f.natDegree + 2)).image fun j ↦ ⟨f.coeff j, 0, 0⟩, ?_, ?_⟩ - · convert image_comap_C_basicOpen f + · convert! image_comap_C_basicOpen f · simp only [basicOpen_eq_zeroLocus_compl, Set.compl_eq_univ_diff] congr 1 rw [← Set.univ_subset_iff] @@ -535,7 +535,8 @@ private lemma statement : ∀ S : InductionObj R n, Statement R₀ R n S := by · intro l m rw [update_apply] split_ifs with hlj - · convert coeff_modByMonic_mem_pow_natDegree_mul _ _ _ (fun _ ↦ coeff_mem_coeffSubmodule) + · convert! + coeff_modByMonic_mem_pow_natDegree_mul _ _ _ (fun _ ↦ coeff_mem_coeffSubmodule) one_mem_coeffSubmodule _ (fun _ ↦ coeff_mem_coeffSubmodule) one_mem_coeffSubmodule _ rw [← pow_succ, Polynomial.degree_eq_natDegree, WithBot.succ_natCast, Nat.cast_id] intro e diff --git a/Mathlib/RingTheory/Spectrum/Prime/FreeLocus.lean b/Mathlib/RingTheory/Spectrum/Prime/FreeLocus.lean index 0e2381c60c53ba..83c797ec9e1c5a 100644 --- a/Mathlib/RingTheory/Spectrum/Prime/FreeLocus.lean +++ b/Mathlib/RingTheory/Spectrum/Prime/FreeLocus.lean @@ -229,7 +229,7 @@ lemma isLocallyConstant_rankAtStalk [Module.FinitePresentation R M] [Module.Flat IsLocallyConstant (rankAtStalk (R := R) M) := by let e : freeLocus R M ≃ₜ PrimeSpectrum R := (Homeomorph.setCongr freeLocus_eq_univ).trans (Homeomorph.Set.univ (PrimeSpectrum R)) - convert isLocallyConstant_rankAtStalk_freeLocus.comp_continuous e.symm.continuous + convert! isLocallyConstant_rankAtStalk_freeLocus.comp_continuous e.symm.continuous @[simp] lemma rankAtStalk_eq_zero_of_subsingleton [Subsingleton M] : diff --git a/Mathlib/RingTheory/Spectrum/Prime/Homeomorph.lean b/Mathlib/RingTheory/Spectrum/Prime/Homeomorph.lean index a29c94296b7765..40f4e96484d595 100644 --- a/Mathlib/RingTheory/Spectrum/Prime/Homeomorph.lean +++ b/Mathlib/RingTheory/Spectrum/Prime/Homeomorph.lean @@ -66,7 +66,7 @@ lemma PrimeSpectrum.isHomeomorph_comap_of_isPurelyInseparable [IsPurelyInseparab IsHomeomorph (comap <| algebraMap R (R ⊗[k] K)) := by let q := ringExpChar k refine isHomeomorph_comap _ (IsPurelyInseparable.exists_pow_mem_range_tensorProduct) ?_ - convert bot_le + convert! bot_le rw [← RingHom.injective_iff_ker_eq_bot] exact Algebra.TensorProduct.includeLeft_injective (S := R) (algebraMap k K).injective diff --git a/Mathlib/RingTheory/Spectrum/Prime/RingHom.lean b/Mathlib/RingTheory/Spectrum/Prime/RingHom.lean index acb9925c1b1633..3592cf2015d84b 100644 --- a/Mathlib/RingTheory/Spectrum/Prime/RingHom.lean +++ b/Mathlib/RingTheory/Spectrum/Prime/RingHom.lean @@ -192,7 +192,7 @@ lemma exists_comap_evalRingHom_eq let h₁ : Function.Surjective (Pi.evalRingHom R i) := RingHomSurjective.is_surjective have h₂ : RingHom.ker (Pi.evalRingHom R i) ≤ p.asIdeal := by intro x hx - convert p.asIdeal.mul_mem_left x hi + convert! p.asIdeal.mul_mem_left x hi ext j by_cases hj : i = j · subst hj; simpa [e] @@ -258,7 +258,7 @@ alias image_specComap_zeroLocus_eq_zeroLocus_comap := image_comap_zeroLocus_eq_z theorem range_comap_of_surjective (hf : Surjective f) : Set.range (comap f) = zeroLocus (ker f) := by rw [← Set.image_univ] - convert image_comap_zeroLocus_eq_zeroLocus_comap _ _ hf _ + convert! image_comap_zeroLocus_eq_zeroLocus_comap _ _ hf _ rw [zeroLocus_bot] @[deprecated (since := "2025-12-10")] diff --git a/Mathlib/RingTheory/Spectrum/Prime/Topology.lean b/Mathlib/RingTheory/Spectrum/Prime/Topology.lean index 49a274abcc0296..55ca991f27bf7e 100644 --- a/Mathlib/RingTheory/Spectrum/Prime/Topology.lean +++ b/Mathlib/RingTheory/Spectrum/Prime/Topology.lean @@ -196,7 +196,7 @@ theorem vanishingIdeal_anti_mono_iff {s t : Set (PrimeSpectrum R)} (ht : IsClose s ⊆ t ↔ vanishingIdeal t ≤ vanishingIdeal s := ⟨vanishingIdeal_anti_mono, fun h => by rw [← ht.closure_subset_iff, ← ht.closure_eq] - convert ← zeroLocus_anti_mono_ideal h <;> apply zeroLocus_vanishingIdeal_eq_closure⟩ + convert! ← zeroLocus_anti_mono_ideal h <;> apply zeroLocus_vanishingIdeal_eq_closure⟩ theorem vanishingIdeal_strict_anti_mono_iff {s t : Set (PrimeSpectrum R)} (hs : IsClosed s) (ht : IsClosed t) : s ⊂ t ↔ vanishingIdeal t < vanishingIdeal s := by @@ -586,7 +586,7 @@ theorem eq_biUnion_of_isOpen {s : Set (PrimeSpectrum R)} (hs : IsOpen s) : theorem isBasis_basic_opens : TopologicalSpace.Opens.IsBasis (Set.range (@basicOpen R _)) := by unfold TopologicalSpace.Opens.IsBasis - convert isTopologicalBasis_basic_opens (R := R) + convert! isTopologicalBasis_basic_opens (R := R) rw [← Set.range_comp] rfl @@ -925,7 +925,7 @@ lemma isQuotientMap_of_generalizingMap (h₂ : GeneralizingMap (comap f)) : fun hsc ↦ Set.image_preimage_eq s h₁ ▸ ?_⟩⟩ apply isClosed_image_of_stableUnderSpecialization _ _ hsc rw [Set.image_preimage_eq s h₁, ← stableUnderGeneralization_compl_iff] - convert h₂.stableUnderGeneralization_image hsc.isOpen_compl.stableUnderGeneralization + convert! h₂.stableUnderGeneralization_image hsc.isOpen_compl.stableUnderGeneralization rw [← Set.preimage_compl, Set.image_preimage_eq _ h₁] end IsQuotientMap @@ -959,7 +959,7 @@ lemma denseRange_comap_iff_minimalPrimes : have : I ∈ (RingHom.ker f).minimalPrimes := by rw [denseRange_comap_iff_ker_le_nilRadical] at H simp only [Set.mem_setOf, Ideal.IsMinimalPrime] at hI ⊢ - convert hI using 2 with p + convert! hI using 2 with p exact ⟨fun h ↦ ⟨h.1, bot_le⟩, fun h ↦ ⟨h.1, H.trans (h.1.radical_le_iff.mpr bot_le)⟩⟩ obtain ⟨p, hp, _, rfl⟩ := Ideal.exists_comap_eq_of_mem_minimalPrimes f (I := ⊥) I this exact ⟨⟨p, hp⟩, rfl⟩ diff --git a/Mathlib/RingTheory/SurjectiveOnStalks.lean b/Mathlib/RingTheory/SurjectiveOnStalks.lean index 8467d695ce4e59..7c1ee5de1a3fbb 100644 --- a/Mathlib/RingTheory/SurjectiveOnStalks.lean +++ b/Mathlib/RingTheory/SurjectiveOnStalks.lean @@ -62,7 +62,7 @@ lemma surjective_localRingHom_iff (P : Ideal S) [P.IsPrime] : IsLocalization.mk'_eq_iff_eq, IsLocalization.eq_iff_exists P.primeCompl] refine ⟨⟨yc, hyc⟩ * ⟨yt, hyt⟩, ?_⟩ simp only [Submonoid.coe_mul] - convert congr($(ey.symm) * $(et)) using 1 <;> ring + convert! congr($(ey.symm) * $(et)) using 1 <;> ring lemma surjectiveOnStalks_iff_forall_ideal : f.SurjectiveOnStalks ↔ @@ -189,8 +189,11 @@ lemma SurjectiveOnStalks.baseChange lemma SurjectiveOnStalks.baseChange' [Algebra R T] [Algebra R S] (hf : (algebraMap R S).SurjectiveOnStalks) : (Algebra.TensorProduct.includeRight (R := R) (A := S) (B := T)).SurjectiveOnStalks := by - convert (surjectiveOnStalks_of_surjective (Algebra.TensorProduct.comm R T S).surjective).comp - (hf.baseChange (S := T)) + convert! + (surjectiveOnStalks_of_surjective (Algebra.TensorProduct.comm R T S).surjective).comp + (hf.baseChange (S := T)) + -- Subsumed by `RingHom.SurjectiveOnStalks.tensorProductMap`. + -- Subsumed by `RingHom.SurjectiveOnStalks.tensorProductMap`. private lemma SurjectiveOnStalks.tensorProductMap_id @@ -211,10 +214,11 @@ lemma SurjectiveOnStalks.tensorProductMap [Algebra R S] [Algebra R T] [Algebra R S'] [Algebra R T'] {f : S →ₐ[R] S'} (Hf : f.SurjectiveOnStalks) {g : T →ₐ[R] T'} (Hg : g.SurjectiveOnStalks) : (Algebra.TensorProduct.map f g).SurjectiveOnStalks := by - convert RingHom.SurjectiveOnStalks.tensorProductMap_id (T := T') Hf |>.comp <| - (Algebra.TensorProduct.comm _ _ _).toRingEquiv.surjectiveOnStalks |>.comp <| - RingHom.SurjectiveOnStalks.tensorProductMap_id (T := S) Hg |>.comp <| - (Algebra.TensorProduct.comm _ _ _).toRingEquiv.surjectiveOnStalks + convert! + RingHom.SurjectiveOnStalks.tensorProductMap_id (T := T') Hf |>.comp <| + (Algebra.TensorProduct.comm _ _ _).toRingEquiv.surjectiveOnStalks |>.comp <| + RingHom.SurjectiveOnStalks.tensorProductMap_id (T := S) Hg |>.comp <| + (Algebra.TensorProduct.comm _ _ _).toRingEquiv.surjectiveOnStalks simp only [AlgHom.toRingHom_eq_coe, RingEquiv.toRingHom_eq_coe, AlgEquiv.toRingEquiv_toRingHom, ← AlgEquiv.toAlgHom_toRingHom, ← AlgHom.comp_toRingHom] congr diff --git a/Mathlib/RingTheory/TensorProduct/Basic.lean b/Mathlib/RingTheory/TensorProduct/Basic.lean index e7ec44de33ee7f..0f1d5cc41adee0 100644 --- a/Mathlib/RingTheory/TensorProduct/Basic.lean +++ b/Mathlib/RingTheory/TensorProduct/Basic.lean @@ -269,11 +269,9 @@ theorem tmul_pow (a : A) (b : B) (k : ℕ) : a ⊗ₜ[R] b ^ k = (a ^ k) ⊗ₜ[ | succ k ih => simp [pow_succ, ih] /-- The ring morphism `A →+* A ⊗[R] B` sending `a` to `a ⊗ₜ 1`. -/ -@[simps] +@[simps!] def includeLeftRingHom : A →+* A ⊗[R] B where - toFun a := a ⊗ₜ 1 - map_zero' := by simp - map_add' := by simp [add_tmul] + __ := (AlgebraTensorModule.mk R R A B).flip 1 |>.toAddMonoidHom map_one' := rfl map_mul' := by simp @@ -317,19 +315,23 @@ theorem includeLeft_apply [SMulCommClass R S A] (a : A) : (includeLeft : A →ₐ[S] A ⊗[R] B) a = a ⊗ₜ 1 := rfl +@[simp] theorem toLinearMap_includeLeft [SMulCommClass R S A] : + (includeLeft : A →ₐ[S] A ⊗[R] B).toLinearMap = (AlgebraTensorModule.mk R S A B).flip 1 := rfl + /-- The algebra morphism `B →ₐ[R] A ⊗[R] B` sending `b` to `1 ⊗ₜ b`. -/ def includeRight : B →ₐ[R] A ⊗[R] B where - toFun b := 1 ⊗ₜ b - map_zero' := by simp - map_add' := by simp [tmul_add] + __ := AlgebraTensorModule.mk R R A B 1 |>.toAddMonoidHom map_one' := rfl map_mul' := by simp - commutes' r := by simp only [algebraMap_apply'] + commutes' r := by simp [algebraMap_eq_smul_one', smul_tmul] @[simp] theorem includeRight_apply (b : B) : (includeRight : B →ₐ[R] A ⊗[R] B) b = 1 ⊗ₜ b := rfl +@[simp] theorem toLinearMap_includeRight : + (includeRight : B →ₐ[R] A ⊗[R] B).toLinearMap = AlgebraTensorModule.mk R R A B 1 := rfl + theorem includeLeftRingHom_comp_algebraMap : (includeLeftRingHom.comp (algebraMap R A) : R →+* A ⊗[R] B) = includeRight.toRingHom.comp (algebraMap R B) := by diff --git a/Mathlib/RingTheory/TensorProduct/Finite.lean b/Mathlib/RingTheory/TensorProduct/Finite.lean index 5af22a0009c55b..9a44ca5362dbec 100644 --- a/Mathlib/RingTheory/TensorProduct/Finite.lean +++ b/Mathlib/RingTheory/TensorProduct/Finite.lean @@ -176,10 +176,11 @@ lemma RingHom.Finite.tensorProductMap [Algebra R S] [Algebra R T] [Algebra R S'] [Algebra R T'] {f : S →ₐ[R] S'} (Hf : f.Finite) {g : T →ₐ[R] T'} (Hg : g.Finite) : (Algebra.TensorProduct.map f g).toRingHom.Finite := by - convert RingHom.Finite.tensorProductMap_id (T := T') Hf |>.comp <| - (Algebra.TensorProduct.comm _ _ _).toRingEquiv.finite |>.comp <| - RingHom.Finite.tensorProductMap_id (T := S) Hg |>.comp <| - (Algebra.TensorProduct.comm _ _ _).toRingEquiv.finite + convert! + RingHom.Finite.tensorProductMap_id (T := T') Hf |>.comp <| + (Algebra.TensorProduct.comm _ _ _).toRingEquiv.finite |>.comp <| + RingHom.Finite.tensorProductMap_id (T := S) Hg |>.comp <| + (Algebra.TensorProduct.comm _ _ _).toRingEquiv.finite simp only [AlgHom.toRingHom_eq_coe, RingEquiv.toRingHom_eq_coe, AlgEquiv.toRingEquiv_toRingHom, ← AlgEquiv.toAlgHom_toRingHom, ← AlgHom.comp_toRingHom] congr diff --git a/Mathlib/RingTheory/TensorProduct/IncludeLeftSubRight.lean b/Mathlib/RingTheory/TensorProduct/IncludeLeftSubRight.lean index a4ca029c1952f5..781cd5e014c7d1 100644 --- a/Mathlib/RingTheory/TensorProduct/IncludeLeftSubRight.lean +++ b/Mathlib/RingTheory/TensorProduct/IncludeLeftSubRight.lean @@ -54,7 +54,7 @@ lemma includeLeftSubRight_apply (s : S) : includeLeftSubRight R S s = s ⊗ₜ[R lemma includeLeftSubRight_zero_of_mem_range {s : S} (hs : s ∈ Set.range ⇑(algebraMap R S)) : includeLeftSubRight R S s = 0 := by obtain ⟨_, hr⟩ := Set.mem_range.mp hs - simp [includeLeftSubRight, ← hr] + simp [← hr, algebraMap_eq_smul_one] /-- `includeLeftSubRight R S` vanishes at `algebraMap R S r`. -/ lemma includeLeftSubRight_algebraMap_zero (r : R) : diff --git a/Mathlib/RingTheory/TensorProduct/Maps.lean b/Mathlib/RingTheory/TensorProduct/Maps.lean index 042ea6b6a237d7..9fb02871569cc5 100644 --- a/Mathlib/RingTheory/TensorProduct/Maps.lean +++ b/Mathlib/RingTheory/TensorProduct/Maps.lean @@ -410,9 +410,12 @@ lemma commRight_tmul (s : S) (a : A) : commRight R S A (s ⊗ₜ a) = a ⊗ₜ s variable {S A} in attribute [local instance] Algebra.TensorProduct.rightAlgebra in @[simp] -lemma Algebra.TensorProduct.commRight_symm_tmul (s : S) (a : A) : +lemma commRight_symm_tmul (s : S) (a : A) : (commRight R S A).symm (a ⊗ₜ[R] s) = s ⊗ₜ a := rfl +@[deprecated (since := "2026-05-24")] +alias Algebra.TensorProduct.commRight_symm_tmul := commRight_symm_tmul + end end diff --git a/Mathlib/RingTheory/Trace/Defs.lean b/Mathlib/RingTheory/Trace/Defs.lean index b0df6d1c0df6fd..20bbbbb9f42612 100644 --- a/Mathlib/RingTheory/Trace/Defs.lean +++ b/Mathlib/RingTheory/Trace/Defs.lean @@ -93,7 +93,7 @@ theorem trace_algebraMap_of_basis (b : Basis ι R S) (x : R) : trace R S (algebraMap R S x) = Fintype.card ι • x := by haveI := Classical.decEq ι rw [trace_apply, LinearMap.trace_eq_matrix_trace R b, Matrix.trace] - convert Finset.sum_const x + convert! Finset.sum_const x simp [-coe_lmul_eq_mul] diff --git a/Mathlib/RingTheory/TwoSidedIdeal/Basic.lean b/Mathlib/RingTheory/TwoSidedIdeal/Basic.lean index 76662f764e151d..8419925a8c28a2 100644 --- a/Mathlib/RingTheory/TwoSidedIdeal/Basic.lean +++ b/Mathlib/RingTheory/TwoSidedIdeal/Basic.lean @@ -61,10 +61,10 @@ instance setLike : SetLike (TwoSidedIdeal R) R where refine RingCon.ext fun a b ↦ ⟨fun H ↦ ?_, fun H ↦ ?_⟩ · have H' : a - b ∈ {x | t₁ x 0} := sub_self b ▸ t₁.sub H (t₁.refl b) rw [h] at H' - convert t₂.add H' (t₂.refl b) using 1 <;> abel + convert! t₂.add H' (t₂.refl b) using 1 <;> abel · have H' : a - b ∈ {x | t₂ x 0} := sub_self b ▸ t₂.sub H (t₂.refl b) rw [← h] at H' - convert t₁.add H' (t₁.refl b) using 1 <;> abel + convert! t₁.add H' (t₁.refl b) using 1 <;> abel instance : PartialOrder (TwoSidedIdeal R) := .ofSetLike (TwoSidedIdeal R) R @@ -79,8 +79,8 @@ lemma coe_mk {c : RingCon R} : (mk c : Set R) = {x | c x 0} := rfl lemma rel_iff (x y : R) : I.ringCon x y ↔ x - y ∈ I := by rw [mem_iff] constructor - · intro h; convert I.ringCon.sub h (I.ringCon.refl y); abel - · intro h; convert I.ringCon.add h (I.ringCon.refl y) <;> abel + · intro h; convert! I.ringCon.sub h (I.ringCon.refl y); abel + · intro h; convert! I.ringCon.add h (I.ringCon.refl y) <;> abel /-- the coercion from two-sided-ideals to sets is an order embedding diff --git a/Mathlib/RingTheory/TwoSidedIdeal/BigOperators.lean b/Mathlib/RingTheory/TwoSidedIdeal/BigOperators.lean index 02a7e8303cb7df..1fc23328611068 100644 --- a/Mathlib/RingTheory/TwoSidedIdeal/BigOperators.lean +++ b/Mathlib/RingTheory/TwoSidedIdeal/BigOperators.lean @@ -36,6 +36,17 @@ lemma finsetSum_mem {ι : Type*} (s : Finset ι) (f : ι → R) (hs : ∀ x ∈ rw [mem_iff, ← Finset.sum_const_zero] exact I.ringCon.finsetSum s hs +lemma finsuppSum_mem {ι : Type*} {β : Type*} [Zero β] + {f : ι →₀ β} (g : ι → β → R) (h : ∀ i ∈ f.support, g i (f i) ∈ I) : + f.sum g ∈ I := + finsetSum_mem _ _ _ h + +lemma dfinsuppSum_mem {ι : Type*} {β : ι → Type*} + [DecidableEq ι] [∀ i, Zero (β i)] [(i : ι) → (x : β i) → Decidable (x ≠ 0)] + {f : Π₀ i, β i} (g : (i : ι) → β i → R) (h : ∀ i ∈ f.support, g i (f i) ∈ I) : + f.sum g ∈ I := + finsetSum_mem _ _ _ h + end sum section prod @@ -70,6 +81,18 @@ lemma finsetProd_mem {ι : Type*} (s : Finset ι) (f : ι → R) (hs : ∃ x ∈ rcases s simpa using multiSetProd_mem (hs := hs) +lemma finsuppProd_mem {ι : Type*} {β : Type*} {M : Type*} + [Add M] [CommMonoid M] [Zero β] + (h : ι → β → R) {f : ι →₀ β} (H : ∃ i ∈ f.support, h i (f i) ∈ I) : + f.prod h ∈ I := + finsetProd_mem _ _ _ H + +lemma dfinsuppProd_mem {ι : Type*} {β : ι → Type*} + [DecidableEq ι] [∀ i, Zero (β i)] [(i : ι) → (x : β i) → Decidable (x ≠ 0)] + {f : Π₀ i, β i} (g : (i : ι) → β i → R) (h : ∃ i ∈ f.support, g i (f i) ∈ I) : + f.prod g ∈ I := + finsetProd_mem _ _ _ h + end commRing end prod diff --git a/Mathlib/RingTheory/TwoSidedIdeal/Lattice.lean b/Mathlib/RingTheory/TwoSidedIdeal/Lattice.lean index 92c59e730f9879..11406844dcf195 100644 --- a/Mathlib/RingTheory/TwoSidedIdeal/Lattice.lean +++ b/Mathlib/RingTheory/TwoSidedIdeal/Lattice.lean @@ -52,7 +52,7 @@ lemma mem_sup {I J : TwoSidedIdeal R} {x : R} : (by rintro r _ ⟨x, ⟨hx, ⟨y, ⟨hy, rfl⟩⟩⟩⟩ exact ⟨_, ⟨mul_mem_right _ _ _ hx, ⟨_, ⟨mul_mem_right _ _ _ hy, add_mul _ _ _ |>.symm⟩⟩⟩⟩) suffices (I.ringCon ⊔ J.ringCon) ≤ s.ringCon by - intro h; convert this h; rw [rel_iff, sub_zero, mem_mk']; rfl + intro h; convert! this h; rw [rel_iff, sub_zero, mem_mk']; rfl refine sup_le (fun x y h => ?_) (fun x y h => ?_) <;> rw [rel_iff] at h ⊢ <;> rw [mem_mk'] exacts [⟨_, ⟨h, ⟨0, ⟨zero_mem _, add_zero _⟩⟩⟩⟩, ⟨0, ⟨zero_mem _, ⟨_, ⟨h, zero_add _⟩⟩⟩⟩] · rintro ⟨y, ⟨hy, ⟨z, ⟨hz, rfl⟩⟩⟩⟩; exact add_mem _ (mem_sup_left hy) (mem_sup_right hz) diff --git a/Mathlib/RingTheory/UniqueFactorizationDomain/Basic.lean b/Mathlib/RingTheory/UniqueFactorizationDomain/Basic.lean index 87469bc1bb6ccb..a1ad2b43565bc1 100644 --- a/Mathlib/RingTheory/UniqueFactorizationDomain/Basic.lean +++ b/Mathlib/RingTheory/UniqueFactorizationDomain/Basic.lean @@ -58,7 +58,7 @@ theorem WfDvdMonoid.of_wellFoundedLT_associates [CommMonoidWithZero α] [IsCance (h : WellFoundedLT (Associates α)) : WfDvdMonoid α := WfDvdMonoid.of_wfDvdMonoid_associates ⟨by - convert h.wf + convert! h.wf ext exact Associates.dvdNotUnit_iff_lt⟩ @@ -345,7 +345,7 @@ theorem WfDvdMonoid.of_exists_prime_factors : WfDvdMonoid α := _ = Multiset.card (Classical.choose (pf b h)) := Multiset.card_eq_card_of_rel (prime_factors_unique ?_ (Classical.choose_spec (pf _ h)).1 ?_) - · convert (Classical.choose_spec (pf c cne0)).2.symm + · convert! (Classical.choose_spec (pf c cne0)).2.symm rw [con, Multiset.prod_zero] · intro x hadd rw [Multiset.mem_add] at hadd @@ -390,7 +390,7 @@ theorem MulEquiv.uniqueFactorizationMonoid (e : α ≃* β) (hα : UniqueFactori obtain ⟨w, hp, u, h⟩ := hα (e.symm a) fun h => ha <| by - convert ← map_zero e + convert! ← map_zero e simp [← h] exact ⟨w.map e, fun b hb => @@ -418,7 +418,7 @@ theorem of_existsUnique_irreducible_factors [CommMonoidWithZero α] [IsCancelMul UniqueFactorizationMonoid α := UniqueFactorizationMonoid.of_exists_prime_factors (by - convert eif using 7 + convert! eif using 7 simp_rw [irreducible_iff_prime_of_existsUnique_irreducible_factors eif uif]) variable {R : Type*} [CommMonoidWithZero R] [UniqueFactorizationMonoid R] diff --git a/Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean b/Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean index e1a9d462999c1f..ee203370d34d5e 100644 --- a/Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean +++ b/Mathlib/RingTheory/UniqueFactorizationDomain/FactorSet.lean @@ -244,7 +244,7 @@ theorem prod_factors [Nontrivial α] (s : FactorSet α) : s.prod.factors = s := @[nontriviality] theorem factors_subsingleton [Subsingleton α] {a : Associates α} : a.factors = ⊤ := by have : Subsingleton (Associates α) := inferInstance - convert factors_zero + convert! factors_zero theorem factors_eq_top_iff_zero {a : Associates α} : a.factors = ⊤ ↔ a = 0 := by nontriviality α @@ -581,7 +581,7 @@ theorem eq_pow_count_factors_of_dvd_pow {p a : Associates α} apply eq_of_eq_counts ha (pow_ne_zero _ hp.ne_zero) have eq_zero_of_ne : ∀ q : Associates α, Irreducible q → q ≠ p → _ = 0 := fun q hq h' => Nat.eq_zero_of_le_zero <| by - convert count_le_count_of_le hph hq h + convert! count_le_count_of_le hph hq h symm rw [count_pow hp.ne_zero hq, count_eq_zero_of_ne hq hp h', mul_zero] intro q hq @@ -601,7 +601,7 @@ theorem count_factors_eq_find_of_dvd_pow {a p : Associates α} · have hph := pow_ne_zero (@Nat.find (fun n => a ∣ p ^ n) _ ⟨n, h⟩) hp.ne_zero rcases subsingleton_or_nontrivial α with hα | hα · simp [eq_iff_true_of_subsingleton] at hph - convert count_le_count_of_le hph hp (@Nat.find_spec (fun n => a ∣ p ^ n) _ ⟨n, h⟩) + convert! count_le_count_of_le hph hp (@Nat.find_spec (fun n => a ∣ p ^ n) _ ⟨n, h⟩) rw [count_pow hp.ne_zero hp, count_self hp, mul_one] end count diff --git a/Mathlib/RingTheory/UniqueFactorizationDomain/Ideal.lean b/Mathlib/RingTheory/UniqueFactorizationDomain/Ideal.lean index 3fdc18c86c5d45..4a392091aa3b51 100644 --- a/Mathlib/RingTheory/UniqueFactorizationDomain/Ideal.lean +++ b/Mathlib/RingTheory/UniqueFactorizationDomain/Ideal.lean @@ -44,7 +44,7 @@ lemma Ideal.setOf_isPrincipal_wellFoundedOn_gt [CommSemiring α] [WfDvdMonoid α ext simp [Submodule.isPrincipal_iff, eq_comm] rw [this, Set.wellFoundedOn_image, Set.wellFoundedOn_univ] - convert wellFounded_dvdNotUnit (α := α) + convert! wellFounded_dvdNotUnit (α := α) ext exact Ideal.span_singleton_lt_span_singleton @@ -55,7 +55,7 @@ lemma WfDvdMonoid.of_setOf_isPrincipal_wellFoundedOn_gt [CommSemiring α] [IsDom WfDvdMonoid α := by have : WellFounded (α := {I : Ideal α // I.IsPrincipal}) (· > ·) := h constructor - convert InvImage.wf (fun a => ⟨Ideal.span ({a} : Set α), _, rfl⟩) this + convert! InvImage.wf (fun a => ⟨Ideal.span ({ a } : Set α), _, rfl⟩) this ext exact Ideal.span_singleton_lt_span_singleton.symm diff --git a/Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicative.lean b/Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicative.lean index e1510b203ba187..19dca9ea9ba773 100644 --- a/Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicative.lean +++ b/Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicative.lean @@ -45,7 +45,7 @@ theorem prime_pow_coprime_prod_of_coprime_insert [DecidableEq α] {s : Finset α obtain ⟨q, q_mem, rfl⟩ := Multiset.mem_map.mp q_mem' replace hdq := hd.dvd_of_dvd_pow hdq have : p ∣ q := dvd_trans (hd.irreducible.dvd_symm hp.irreducible hdp) hdq - convert q_mem using 0 + convert! q_mem using 0 rw [Finset.mem_val, is_coprime _ (Finset.mem_insert_self p s) _ (Finset.mem_insert_of_mem q_mem) this] diff --git a/Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicity.lean b/Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicity.lean index ce1f6523fc9704..e0f095c0f440fe 100644 --- a/Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicity.lean +++ b/Mathlib/RingTheory/UniqueFactorizationDomain/Multiplicity.lean @@ -9,6 +9,8 @@ public import Mathlib.Algebra.BigOperators.Finprod public import Mathlib.RingTheory.Multiplicity public import Mathlib.RingTheory.UniqueFactorizationDomain.NormalizedFactors +import Mathlib.Algebra.FiniteSupport.Basic + /-! # Unique factorization and multiplicity @@ -118,7 +120,7 @@ theorem count_normalizedFactors_eq {p x : R} (hp : Irreducible p) (hnorm : norma by_cases hx0 : x = 0 · simp [hx0] at hlt apply Nat.cast_injective (R := ℕ∞) - convert (emultiplicity_eq_count_normalizedFactors hp hx0).symm + convert! (emultiplicity_eq_count_normalizedFactors hp hx0).symm · exact hnorm.symm exact (emultiplicity_eq_coe.mpr ⟨hle, hlt⟩).symm @@ -176,4 +178,12 @@ lemma pow_dvd_pow_iff_dvd {a b : R} {n : ℕ} (hn : n ≠ 0) : a ^ n ∣ b ^ n rwa [emultiplicity_pow hp, emultiplicity_pow hp, ENat.mul_le_mul_left_iff (by exact_mod_cast hn) (ENat.coe_ne_top _)] at this +@[fun_prop] +lemma hasFiniteMulSupport_fun_pow_multiplicity {α M : Type*} [CommMonoid M] [Subsingleton Rˣ] + (f : α → M) {g : α → R} (hgi : g.Injective) (hg : ∀ s, Irreducible (g s)) {r : R} (hr : r ≠ 0) : + (fun s : α ↦ f s ^ multiplicity (g s) r).HasFiniteMulSupport := by + classical + simp only [multiplicity_eq_count_normalizedFactors (hg _) hr, normalize_eq] + fun_prop + end UniqueFactorizationMonoid diff --git a/Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean b/Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean index 0cfdef04a98dd6..d02f959aebbcb2 100644 --- a/Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean +++ b/Mathlib/RingTheory/UniqueFactorizationDomain/NormalizedFactors.lean @@ -41,7 +41,7 @@ if `M` has a trivial group of units. -/ theorem factors_eq_normalizedFactors {M : Type*} [CommMonoidWithZero M] [UniqueFactorizationMonoid M] [Subsingleton Mˣ] (x : M) : factors x = normalizedFactors x := by unfold normalizedFactors - convert (Multiset.map_id (factors x)).symm + convert! (Multiset.map_id (factors x)).symm ext p exact normalize_eq p @@ -87,15 +87,16 @@ theorem normalizedFactors_irreducible {a : α} (ha : Irreducible a) : have p_mem : p ∈ normalizedFactors a := by rw [hp] exact Multiset.mem_singleton_self _ - convert hp + convert! hp rwa [← normalize_normalized_factor p p_mem, normalize_eq_normalize_iff, dvd_dvd_iff_associated] theorem normalizedFactors_eq_of_dvd (a : α) : ∀ᵉ (p ∈ normalizedFactors a) (q ∈ normalizedFactors a), p ∣ q → p = q := by intro p hp q hq hdvd - convert normalize_eq_normalize hdvd - ((prime_of_normalized_factor _ hp).irreducible.dvd_symm - (prime_of_normalized_factor _ hq).irreducible hdvd) <;> + convert! + normalize_eq_normalize hdvd + ((prime_of_normalized_factor _ hp).irreducible.dvd_symm + (prime_of_normalized_factor _ hq).irreducible hdvd) <;> apply (normalize_normalized_factor _ ‹_›).symm theorem exists_mem_normalizedFactors_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) : @@ -325,7 +326,7 @@ theorem normalizedFactors_multiset_prod (s : Multiset α) (hs : 0 ∉ s) : · obtain rfl : s = 0 := by apply Multiset.eq_zero_of_forall_notMem intro _ - convert hs + convert! hs simp induction s using Multiset.induction with | empty => simp diff --git a/Mathlib/RingTheory/Unramified/LocalStructure.lean b/Mathlib/RingTheory/Unramified/LocalStructure.lean index 4cacf107d92c77..18a73ec56aae7e 100644 --- a/Mathlib/RingTheory/Unramified/LocalStructure.lean +++ b/Mathlib/RingTheory/Unramified/LocalStructure.lean @@ -90,7 +90,7 @@ private theorem exists_hasStandardEtaleSurjectionOn_of_exists_adjoin_singleton_e P.ResidueField[X] ⧸ I.map (mapRingHom (algebraMap _ P.ResidueField)) := Polynomial.fiberEquivQuotient (aeval (R := R) x) hx' _ rw [← RingHom.ker_comp_of_injective _ (f := e.toRingHom) e.injective] - convert Ideal.mk_ker.symm + convert! Ideal.mk_ker.symm ext a · dsimp [-TensorProduct.algebraMap_apply] rw [aeval_C, AlgEquiv.commutes] @@ -119,7 +119,7 @@ private theorem exists_hasStandardEtaleSurjectionOn_of_exists_adjoin_singleton_e have : Function.Surjective (aeval (R := P.ResidueField) ((1 : P.ResidueField) ⊗ₜ[R] x)) := by rw [← AlgHom.range_eq_top, ← adjoin_singleton_eq_range_aeval] simpa using TensorProduct.adjoin_one_tmul_image_eq_top (A := P.ResidueField) _ hp₂ - convert IsUnramifiedAt.not_minpoly_sq_dvd (A := P.Fiber S) Q' (1 ⊗ₜ x) _ hp₁ this + convert! IsUnramifiedAt.not_minpoly_sq_dvd (A := P.Fiber S) Q' (1 ⊗ₜ x) _ hp₁ this rw [← minpoly.algHom_eq _ (IsScalarTower.toAlgHom P.ResidueField Q.ResidueField Q'.ResidueField).injective] congr 1 @@ -233,7 +233,7 @@ lemma exists_notMem_forall_ne_mem_and_adjoin_eq_top have : Ideal.ResidueField.mapₐ p Q (ofId R S) (Ideal.over_def Q p) = AlgHom.restrictScalars R (ofId p.ResidueField Q.ResidueField) := by ext rw [← AlgHom.restrictScalars_apply R, Algebra.TensorProduct.restrictScalars_lift] - convert hrQ + convert! hrQ rw [← SetLike.mem_coe, PrimeSpectrum.coe_primesOverOrderIsoFiber_apply_asIdeal] simp [this] have hsQ' : algebraMap R Q.ResidueField s ≠ 0 := by diff --git a/Mathlib/RingTheory/Unramified/Pi.lean b/Mathlib/RingTheory/Unramified/Pi.lean index 02866761f98d13..0dcaf171bbf480 100644 --- a/Mathlib/RingTheory/Unramified/Pi.lean +++ b/Mathlib/RingTheory/Unramified/Pi.lean @@ -48,12 +48,12 @@ theorem pi_iff : have h₁ : (f₁ e) * (1 - f₂ e) = 0 := by rw [← Ideal.mem_bot, ← hJ, ← ((he.map f₁).mul (he.map f₂).one_sub).eq, ← pow_two] apply Ideal.pow_mem_pow - convert Ideal.mul_mem_left _ (f₁ e) (hf e) using 1 + convert! Ideal.mul_mem_left _ (f₁ e) (hf e) using 1 rw [mul_sub, mul_sub, mul_one, (he.map f₁).eq] have h₂ : (f₂ e) * (1 - f₁ e) = 0 := by rw [← Ideal.mem_bot, ← hJ, ← ((he.map f₂).mul (he.map f₁).one_sub).eq, ← pow_two] apply Ideal.pow_mem_pow - convert Ideal.mul_mem_left _ (-f₂ e) (hf e) using 1 + convert! Ideal.mul_mem_left _ (-f₂ e) (hf e) using 1 rw [neg_mul, mul_sub, mul_sub, mul_one, neg_sub, (he.map f₂).eq] have H : f₁ e = f₂ e := by trans f₁ e * f₂ e diff --git a/Mathlib/RingTheory/Valuation/Basic.lean b/Mathlib/RingTheory/Valuation/Basic.lean index 034cc67b75f7e8..26570c1f8394cc 100644 --- a/Mathlib/RingTheory/Valuation/Basic.lean +++ b/Mathlib/RingTheory/Valuation/Basic.lean @@ -889,7 +889,7 @@ theorem orderMonoidIso_spec (h : v.IsEquiv w) (a : R) : · rw [← restrict₀_eq_zero_iff] at ha rwa [restrict_def, ha, map_zero, Eq.comm, ← h_res.eq_zero] · rw [(v.restrict_eq_mk ha)] - convert valueGroup₀Fun_spec (h := h) (hs := ha) (r := 1) (by simp) + convert! valueGroup₀Fun_spec (h := h) (hs := ha) (r := 1) (by simp) exact w.restrict_eq_mk ((eq_zero h.symm).ne.mpr ha) theorem orderMonoidIso_symm (h : v.IsEquiv w) (h' : w.IsEquiv v) : diff --git a/Mathlib/RingTheory/Valuation/ExtendToLocalization.lean b/Mathlib/RingTheory/Valuation/ExtendToLocalization.lean index 904eae8ec5c268..4c6b5fe08c4708 100644 --- a/Mathlib/RingTheory/Valuation/ExtendToLocalization.lean +++ b/Mathlib/RingTheory/Valuation/ExtendToLocalization.lean @@ -31,7 +31,7 @@ noncomputable def Valuation.extendToLocalization : Valuation B Γ := let f := IsLocalization.toLocalizationMap S B let h : ∀ s : S, IsUnit (v.1.toMonoidHom s) := fun s => isUnit_iff_ne_zero.2 (hS s.2) { f.lift h with - map_zero' := by convert f.lift_eq (P := Γ) _ 0 <;> simp [f] + map_zero' := by convert! f.lift_eq (P := Γ) _ 0 <;> simp [f] map_add_le_max' := fun x y => by obtain ⟨a, b, s, rfl, rfl⟩ : ∃ (a b : A) (s : S), f.mk' a s = x ∧ f.mk' b s = y := by obtain ⟨a, s, rfl⟩ := f.mk'_surjective x diff --git a/Mathlib/RingTheory/Valuation/Integers.lean b/Mathlib/RingTheory/Valuation/Integers.lean index 6672e0b355fe44..de9982a5402457 100644 --- a/Mathlib/RingTheory/Valuation/Integers.lean +++ b/Mathlib/RingTheory/Valuation/Integers.lean @@ -433,7 +433,7 @@ lemma leIdeal_v_le_of_mem {K : Type*} [Field K] (v : Valuation K Γ₀) · simp intro y hy have : v ((y : K) / x) ≤ 1 := by simpa using div_le_one_of_le₀ hy zero_le' - convert I.smul_mem ⟨_, this⟩ hx using 1 + convert! I.smul_mem ⟨_, this⟩ hx using 1 simp [Subtype.ext_iff, div_mul_cancel₀ _ (ZeroMemClass.coe_eq_zero.not.mpr hx0)] lemma ltIdeal_v_le_of_mem {K : Type*} [Field K] {v : Valuation K Γ₀} diff --git a/Mathlib/RingTheory/Valuation/LocalSubring.lean b/Mathlib/RingTheory/Valuation/LocalSubring.lean index 68a9ac5adf29e6..4d5dcc292ac35c 100644 --- a/Mathlib/RingTheory/Valuation/LocalSubring.lean +++ b/Mathlib/RingTheory/Valuation/LocalSubring.lean @@ -224,7 +224,7 @@ lemma bijective_rangeRestrict_comp_of_valuationRing [IsDomain R] [ValuationRing (f : R →+* S) (g : S →+* K) (h : g.comp f = algebraMap R K) [IsLocalHom f] : Function.Bijective (g.rangeRestrict.comp f) := by refine ⟨?_, ?_⟩ - · exact .of_comp (f := Subtype.val) (by convert (IsFractionRing.injective R K); rw [← h]; rfl) + · exact .of_comp (f := Subtype.val) (by convert! (IsFractionRing.injective R K); rw [← h]; rfl) · let V : ValuationSubring K := ⟨(algebraMap R K).range, ValuationRing.isInteger_or_isInteger R⟩ suffices LocalSubring.range g ≤ V.toLocalSubring by @@ -238,7 +238,7 @@ lemma bijective_rangeRestrict_comp_of_valuationRing [IsDomain R] [ValuationRing suffices IsUnit a from this.map (algebraMap R K).rangeRestrict apply IsUnit.of_map f apply (IsLocalHom.of_surjective g.rangeRestrict g.rangeRestrict_surjective).1 - convert ha + convert! ha simp [← h] lemma IsLocalRing.exists_factor_valuationRing [IsLocalRing R] (f : R →+* K) : diff --git a/Mathlib/RingTheory/Valuation/RankOne.lean b/Mathlib/RingTheory/Valuation/RankOne.lean index 33263f3ff6c1b1..1316d30f2bb7e2 100644 --- a/Mathlib/RingTheory/Valuation/RankOne.lean +++ b/Mathlib/RingTheory/Valuation/RankOne.lean @@ -131,7 +131,7 @@ instance : IsNontrivial v where section Restrict -instance isNontrivial_restrict [v.IsNontrivial] : (v.restrict).IsNontrivial where +instance isNontrivial_restrict : (v.restrict).IsNontrivial where exists_val_nontrivial := by obtain ⟨x, ⟨hx0, hx1⟩⟩ := IsNontrivial.exists_val_nontrivial (v := v) exact ⟨x, by simp [hx0], by grind [restrict_eq_one_iff]⟩ @@ -158,7 +158,7 @@ theorem exists_val_lt {γ : ℝ≥0} (hγ : γ ≠ 0) : ∃ x ≠ 0, RankOne.hom by_contra h0 rw [dif_pos (by rw [dif_pos ((zero_iff v).mpr h0)]), eq_comm] at hk simp at hk - · convert h + · convert! h simp only [restrict_RankOne_hom_eq, coe_comp, Function.comp_apply, ← hk] congr 1 exact (embedding_restrict₀ k).symm diff --git a/Mathlib/RingTheory/Valuation/ValuationRing.lean b/Mathlib/RingTheory/Valuation/ValuationRing.lean index 721dcf75bdf8bb..bc71ae1e143939 100644 --- a/Mathlib/RingTheory/Valuation/ValuationRing.lean +++ b/Mathlib/RingTheory/Valuation/ValuationRing.lean @@ -398,7 +398,7 @@ instance (priority := 100) [IsLocalRing R] [IsBezout R] : ValuationRing R := by rcases eq_or_ne g 0 with h | h · simp [h] have : x * a + y * b = 1 := by - apply mul_left_injective₀ h; convert e' using 1 <;> ring + apply mul_left_injective₀ h; convert! e' using 1 <;> ring rcases IsLocalRing.isUnit_or_isUnit_of_add_one this with h' | h' <;> [left; right] all_goals exact mul_dvd_mul_right (isUnit_iff_forall_dvd.mp (isUnit_of_mul_isUnit_right h') _) _ diff --git a/Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean b/Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean index 86c75c364db366..3645bd7fcad779 100644 --- a/Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean +++ b/Mathlib/RingTheory/Valuation/ValuativeRel/Basic.lean @@ -1147,7 +1147,7 @@ where the first row is the map `v` factored through its image group (with zero) @[simp] lemma embed_valuation_eq_restrict₀ [v.Compatible] (x : R) : embed v (valuation R x) = ValueGroup₀.restrict₀ v x := by - convert embed_mk v x 1 + convert! embed_mk v x 1 simp /-- diff --git a/Mathlib/RingTheory/Valuation/ValuativeRel/Trivial.lean b/Mathlib/RingTheory/Valuation/ValuativeRel/Trivial.lean index a1ac9361766878..d1923deefbe89f 100644 --- a/Mathlib/RingTheory/Valuation/ValuativeRel/Trivial.lean +++ b/Mathlib/RingTheory/Valuation/ValuativeRel/Trivial.lean @@ -53,7 +53,7 @@ lemma eq_trivialRel_of_compatible_one [h : ValuativeRel R] lemma trivialRel_eq_ofValuation_one : trivialRel = ValuativeRel.ofValuation (1 : Valuation R Γ) := by - convert (eq_trivialRel_of_compatible_one (Γ := Γ)).symm + convert! (eq_trivialRel_of_compatible_one (Γ := Γ)).symm exact Valuation.Compatible.ofValuation 1 variable (R Γ) in diff --git a/Mathlib/RingTheory/WittVector/DiscreteValuationRing.lean b/Mathlib/RingTheory/WittVector/DiscreteValuationRing.lean index ef571e47200128..8ea43e8cd2eebd 100644 --- a/Mathlib/RingTheory/WittVector/DiscreteValuationRing.lean +++ b/Mathlib/RingTheory/WittVector/DiscreteValuationRing.lean @@ -127,7 +127,7 @@ theorem exists_eq_pow_p_mul (a : 𝕎 k) (ha : a ≠ 0) : · contrapose hc simp [hc, zero_pow <| pow_ne_zero _ hp.out.ne_zero] · simp_rw [← mul_left_iterate (p : 𝕎 k) m] - convert hcm using 2 + convert! hcm using 2 ext1 x rw [mul_comm, ← WittVector.verschiebung_frobenius x]; rfl diff --git a/Mathlib/RingTheory/WittVector/FrobeniusFractionField.lean b/Mathlib/RingTheory/WittVector/FrobeniusFractionField.lean index 7341fdcf59e801..25380ba5a64305 100644 --- a/Mathlib/RingTheory/WittVector/FrobeniusFractionField.lean +++ b/Mathlib/RingTheory/WittVector/FrobeniusFractionField.lean @@ -131,7 +131,7 @@ theorem succNthVal_spec' (n : ℕ) (a₁ a₂ : 𝕎 k) (bs : Fin (n + 1) → k) Polynomial.eval_pow, succNthDefiningPoly, Polynomial.eval_mul, Polynomial.eval_add, Polynomial.eval_sub, Polynomial.IsRoot.def] at this - convert this using 1 + convert! this using 1 ring end IsAlgClosed @@ -207,7 +207,7 @@ theorem frobenius_frobeniusRotation {a₁ a₂ : 𝕎 k} (ha₁ : a₁.coeff 0 succNthVal_spec' p n a₁ a₂ (fun i : Fin (n + 1) => frobeniusRotationCoeff p ha₁ ha₂ i.val) ha₁ ha₂ simp only [frobeniusRotationCoeff, Fin.val_zero] at this - convert this using 3; clear this + convert! this using 3; clear this apply TruncatedWittVector.ext intro i simp only [WittVector.coeff_truncateFun, WittVector.coeff_frobenius_charP] @@ -236,7 +236,7 @@ theorem exists_frobenius_solution_fractionRing_aux (m n : ℕ) (r' q' : 𝕎 k) (IsFractionRing.injective (𝕎 k) (FractionRing (𝕎 k))).ne hq''' rw [zpow_sub₀ (FractionRing.p_nonzero p k)] simp [field, FractionRing.p_nonzero p k] - convert congr_arg (fun x => algebraMap (𝕎 k) (FractionRing (𝕎 k)) x) key using 1 + convert! congr_arg (fun x => algebraMap (𝕎 k) (FractionRing (𝕎 k)) x) key using 1 · simp only [map_mul] · simp only [map_mul] diff --git a/Mathlib/RingTheory/WittVector/Identities.lean b/Mathlib/RingTheory/WittVector/Identities.lean index 5bef05ead1f40b..9ba6ce06ae5bc2 100644 --- a/Mathlib/RingTheory/WittVector/Identities.lean +++ b/Mathlib/RingTheory/WittVector/Identities.lean @@ -214,7 +214,7 @@ theorem iterate_verschiebung_mul_coeff (x y : 𝕎 R) (i j : ℕ) : _ = (frobenius^[j] x).coeff 0 * (frobenius^[i] y).coeff 0 := ?_ _ = _ := ?_ · rw [iterate_verschiebung_mul] - · convert iterate_verschiebung_coeff (p := p) (R := R) _ _ _ using 2 + · convert! iterate_verschiebung_coeff (p := p) (R := R) _ _ _ using 2 rw [zero_add] · apply mul_coeff_zero · simp only [iterate_frobenius_coeff] diff --git a/Mathlib/RingTheory/WittVector/IsPoly.lean b/Mathlib/RingTheory/WittVector/IsPoly.lean index 18db959d3218d4..902cfc16d982c3 100644 --- a/Mathlib/RingTheory/WittVector/IsPoly.lean +++ b/Mathlib/RingTheory/WittVector/IsPoly.lean @@ -184,7 +184,7 @@ theorem ext [Fact p.Prime] {f g} (hf : IsPoly p f) (hg : IsPoly p g) simp only [ghostComponent_apply, aeval_eq_eval₂Hom] at h apply (ULift.ringEquiv.symm : ℤ ≃+* _).injective simp only [← RingEquiv.coe_toRingHom, map_eval₂Hom] - convert h using 1 + convert! h using 1 all_goals simp only [hf, hg, MvPolynomial.eval, map_eval₂Hom] apply eval₂Hom_congr (RingHom.ext_int _ _) _ rfl @@ -344,7 +344,7 @@ theorem ext [Fact p.Prime] {f g} (hf : IsPoly₂ p f) (hg : IsPoly₂ p g) simp only [ghostComponent_apply, aeval_eq_eval₂Hom] at h apply (ULift.ringEquiv.symm : ℤ ≃+* _).injective simp only [← RingEquiv.coe_toRingHom, map_eval₂Hom] - convert h using 1 + convert! h using 1 all_goals simp only [hf, hg, MvPolynomial.eval, map_eval₂Hom] apply eval₂Hom_congr (RingHom.ext_int _ _) _ rfl diff --git a/Mathlib/RingTheory/WittVector/Isocrystal.lean b/Mathlib/RingTheory/WittVector/Isocrystal.lean index 65c3c23f8203ec..a91b60b777cdcc 100644 --- a/Mathlib/RingTheory/WittVector/Isocrystal.lean +++ b/Mathlib/RingTheory/WittVector/Isocrystal.lean @@ -191,7 +191,7 @@ theorem isocrystal_classification (k : Type*) [Field k] [IsAlgClosed k] [CharP k apply this simp only [← ha, ha', zero_smul] obtain ⟨b, hb, m, hmb⟩ := WittVector.exists_frobenius_solution_fractionRing p ha - replace hmb : φ(p, k) b * a = (p : K(p, k)) ^ m * b := by convert hmb + replace hmb : φ(p, k) b * a = (p : K(p, k)) ^ m * b := by convert! hmb use m let F₀ : StandardOneDimIsocrystal p k m →ₗ[K(p, k)] V := LinearMap.toSpanSingleton K(p, k) V x let F : StandardOneDimIsocrystal p k m ≃ₗ[K(p, k)] V := by diff --git a/Mathlib/RingTheory/WittVector/MulCoeff.lean b/Mathlib/RingTheory/WittVector/MulCoeff.lean index af5114c453fd08..741a27a70778d5 100644 --- a/Mathlib/RingTheory/WittVector/MulCoeff.lean +++ b/Mathlib/RingTheory/WittVector/MulCoeff.lean @@ -113,7 +113,7 @@ def polyOfInterest (n : ℕ) : 𝕄 := theorem mul_polyOfInterest_aux1 (n : ℕ) : ∑ i ∈ range (n + 1), (p : 𝕄) ^ i * wittMul p i ^ p ^ (n - i) = wittPolyProd p n := by simp only [wittPolyProd] - convert wittStructureInt_prop p (X (0 : Fin 2) * X 1) n using 1 + convert! wittStructureInt_prop p (X (0 : Fin 2) * X 1) n using 1 · simp only [wittPolynomial, wittMul] rw [map_sum] congr 1 with i @@ -128,7 +128,7 @@ theorem mul_polyOfInterest_aux1 (n : ℕ) : theorem mul_polyOfInterest_aux2 (n : ℕ) : (p : 𝕄) ^ n * wittMul p n + wittPolyProdRemainder p n = wittPolyProd p n := by - convert mul_polyOfInterest_aux1 p n + convert! mul_polyOfInterest_aux1 p n rw [sum_range_succ, add_comm, Nat.sub_self, pow_zero, pow_one] rfl diff --git a/Mathlib/RingTheory/WittVector/StructurePolynomial.lean b/Mathlib/RingTheory/WittVector/StructurePolynomial.lean index dbe3ac979f9098..c75019e2c4122c 100644 --- a/Mathlib/RingTheory/WittVector/StructurePolynomial.lean +++ b/Mathlib/RingTheory/WittVector/StructurePolynomial.lean @@ -322,7 +322,7 @@ theorem wittStructureInt_existsUnique (Φ : MvPolynomial idx ℤ) : theorem witt_structure_prop (Φ : MvPolynomial idx ℤ) (n) : aeval (fun i => map (Int.castRingHom R) (wittStructureInt p Φ i)) (wittPolynomial p ℤ n) = aeval (fun i => rename (Prod.mk i) (W n)) Φ := by - convert congr_arg (map (Int.castRingHom R)) (wittStructureInt_prop p Φ n) using 1 <;> + convert! congr_arg (map (Int.castRingHom R)) (wittStructureInt_prop p Φ n) using 1 <;> rw [hom_bind₁] <;> apply eval₂Hom_congr (RingHom.ext_int _ _) _ rfl · rfl diff --git a/Mathlib/RingTheory/ZMod/UnitsCyclic.lean b/Mathlib/RingTheory/ZMod/UnitsCyclic.lean index 79e5082f07e949..140332f7e2e47d 100644 --- a/Mathlib/RingTheory/ZMod/UnitsCyclic.lean +++ b/Mathlib/RingTheory/ZMod/UnitsCyclic.lean @@ -181,13 +181,13 @@ theorem orderOf_one_add_mul_prime_pow {p : ℕ} (hp : p.Prime) (m : ℕ) (hm0 : theorem orderOf_one_add_mul_prime {p : ℕ} (hp : p.Prime) (hp2 : p ≠ 2) (a : ℤ) (ha : ¬ (p : ℤ) ∣ a) (n : ℕ) : orderOf (1 + p * a : ZMod (p ^ (n + 1))) = p ^ n := by - convert orderOf_one_add_mul_prime_pow hp 1 one_ne_zero _ a ha n using 1 + convert! orderOf_one_add_mul_prime_pow hp 1 one_ne_zero _ a ha n using 1 · rw [pow_one] · have := hp.two_le; lia theorem orderOf_one_add_prime {p : ℕ} (hp : p.Prime) (hp2 : p ≠ 2) (n : ℕ) : orderOf (1 + p : ZMod (p ^ (n + 1))) = p ^ n := by - convert orderOf_one_add_mul_prime hp hp2 1 _ n + convert! orderOf_one_add_mul_prime hp hp2 1 _ n · simp · intro H apply hp.ne_one @@ -242,13 +242,13 @@ theorem isCyclic_units_two_pow_iff (n : ℕ) : lemma orderOf_one_add_four_mul (a : ℤ) (ha : Odd a) (n : ℕ) : orderOf (1 + 4 * a : ZMod (2 ^ (n + 2))) = 2 ^ n := by - convert orderOf_one_add_mul_prime_pow Nat.prime_two 2 two_ne_zero le_rfl a ?_ n using 1 + convert! orderOf_one_add_mul_prime_pow Nat.prime_two 2 two_ne_zero le_rfl a ?_ n using 1 · norm_num · rwa [← Int.not_even_iff_odd, even_iff_two_dvd] at ha theorem orderOf_five (n : ℕ) : orderOf (5 : ZMod (2 ^ (n + 2))) = 2 ^ n := by - convert orderOf_one_add_four_mul 1 (by simp) n + convert! orderOf_one_add_four_mul 1 (by simp) n norm_num end PrimePow diff --git a/Mathlib/RingTheory/ZariskisMainTheorem.lean b/Mathlib/RingTheory/ZariskisMainTheorem.lean index e8f3322e52d1d9..12cf49175b301e 100644 --- a/Mathlib/RingTheory/ZariskisMainTheorem.lean +++ b/Mathlib/RingTheory/ZariskisMainTheorem.lean @@ -224,7 +224,7 @@ lemma exists_isIntegral_leadingCoeff_pow_smul_sub_of_isIntegralElem_of_mul_mem_r simp only [Algebra.smul_def, Submonoid.smul_def, algebraMap_apply R S S', ← map_mul] at hm obtain ⟨_, ⟨k, rfl⟩, hk⟩ := IsLocalization.exists_isIntegral_smul_of_isIntegral_map (.powers a) hm refine ⟨C a ^ (k + m) * q', k + m + n, ?_⟩ - convert hk using 1 + convert! hk using 1 simp only [Algebra.smul_def, map_pow, ← Polynomial.algebraMap_eq, map_mul, AlgHom.commutes] ring @@ -239,7 +239,7 @@ lemma exists_leadingCoeff_pow_smul_mem_conductor have : φ p * t * x ∈ φ.range := by simpa [← AlgHom.map_adjoin_singleton] using hp x obtain ⟨q, n, hn⟩ := exists_isIntegral_leadingCoeff_pow_smul_sub_of_isIntegralElem_of_mul_mem_range φ _ p - (hφ.to_isIntegral (t * x)) (by convert this using 1; ring) + (hφ.to_isIntegral (t * x)) (by convert! this using 1; ring) obtain ⟨r, hr : algebraMap _ _ r = _⟩ := hRS.le hn exact ⟨n, (C r + q), by simp [← Polynomial.algebraMap_eq, - Polynomial.algebraMap_apply, hr]⟩ choose n hn using this @@ -384,16 +384,18 @@ private lemma not_isStronglyTranscendental_of_weaklyQuasiFiniteAt_of_isDomain_au rw [show algebraMap S' L (f x) = algebraMap _ _ x from congr($hf₂ x)] exact ((hx.of_isLocalization S⁰).of_isLocalization_left R⁰).restrictScalars (S := K) have H₂ : (aeval (R := R') (f x)).toRingHom.Finite := by - convert ((RingHom.Finite.of_surjective g.toRingHom hf₁).comp - (RingHom.Finite.tensorProductMap (f := AlgHom.id R R') (RingEquiv.refl _).finite hx')).comp - (polyEquivTensor R R').toRingEquiv.finite using 1 + convert! + ((RingHom.Finite.of_surjective g.toRingHom hf₁).comp + (RingHom.Finite.tensorProductMap (f := AlgHom.id R R') (RingEquiv.refl _).finite + hx')).comp + (polyEquivTensor R R').toRingEquiv.finite using 1 ext <;> simp [g] obtain ⟨⟨Q, _⟩, hQ⟩ := hf₄.comap_surjective hf₃ ⟨P, ‹_›⟩ suffices WeaklyQuasiFiniteAt R' Q from not_isStronglyTranscendental_of_weaklyQuasiFiniteAt_of_isIntegrallyClosed H₂ Q H₁ have : Algebra.WeaklyQuasiFiniteAt R' (Q.comap g.toRingHom) := .baseChange P _ <| by rw [Ideal.comap_comap] - convert congr(($hQ.symm).1) + convert! congr(($hQ.symm).1) ext; simp [g] exact .of_surjectiveOnStalks (Q.comap g.toRingHom) _ g (RingHom.surjectiveOnStalks_of_surjective hf₁) rfl @@ -420,7 +422,7 @@ nonrec lemma not_isStronglyTranscendental_of_weaklyQuasiFiniteAt [IsReduced S] ((isStronglyTranscendental_mk_of_mem_minimalPrimes hx p hp).of_surjective_left Ideal.Quotient.mk_surjective) refine RingHom.Finite.of_comp_finite (f := mapRingHom (Ideal.Quotient.mk _)) ?_ - convert (RingHom.Finite.of_surjective _ (Ideal.Quotient.mk_surjective (I := p))).comp hx' + convert! (RingHom.Finite.of_surjective _ (Ideal.Quotient.mk_surjective (I := p))).comp hx' ext <;> simp cases hS have : IsDomain R := (FaithfulSMul.algebraMap_injective R S).isDomain @@ -493,7 +495,7 @@ private lemma ZariskisMainProperty.of_adjoin_eq_top simpa [eraseLead_coeff, show n ≠ f.natDegree by rintro rfl; exact hfn (by simpa)] rwa [Ideal.add_mem_iff_left] split_ifs - · convert p.mul_mem_right x Hfp + · convert! p.mul_mem_right x Hfp simpa [Algebra.smul_def] using ha · simp · refine zariskisMainProperty_iff_exists_saturation_eq_top.mpr ⟨_, Hfp, isIntegral_algebraMap, ?_⟩ @@ -512,7 +514,7 @@ private lemma ZariskisMainProperty.of_algHom_polynomial .of_restrictScalars R (integralClosure R S) _ refine .restrictScalars (this p (aeval (f X)) ?_ (integralClosure_idem (R := R))) refine RingHom.Finite.of_comp_finite (f := mapRingHom (algebraMap R _)) ?_ - convert (show f.toRingHom.Finite from hf) + convert! (show f.toRingHom.Finite from hf) ext <;> simp [show ∀ x, f (C x) = algebraMap _ _ x from f.commutes] replace hf : ¬ conductor R (f X) ≤ p := by intro hp @@ -528,8 +530,9 @@ private lemma ZariskisMainProperty.of_algHom_polynomial ((Ideal.comap_map_of_surjective _ Ideal.Quotient.mk_surjective p).trans ?_).symm simpa [← RingHom.ker_eq_comap_bot] refine not_isStronglyTranscendental_of_weaklyQuasiFiniteAt ?_ (p.map (Ideal.Quotient.mk J)) - (isStronglyTranscendental_mk_radical_conductor H (f X) (by convert hf; ext; simp)) - convert (RingHom.Finite.of_surjective _ (Ideal.Quotient.mk_surjective (I := J))).comp hf using 1 + (isStronglyTranscendental_mk_radical_conductor H (f X) (by convert! hf; ext; simp)) + convert! (RingHom.Finite.of_surjective _ (Ideal.Quotient.mk_surjective (I := J))).comp hf + using 1 ext <;> simp [show ∀ x, f (C x) = algebraMap _ _ x from f.commutes, J] obtain ⟨x, hx, hxp⟩ := SetLike.not_le_iff_exists.mp hf replace hx (a : _) : x * a ∈ f.range := by simpa [← AlgHom.map_adjoin_singleton f] using hx a @@ -557,7 +560,7 @@ private lemma ZariskisMainProperty.of_algHom_mvPolynomial | zero => have : Module.Finite R S := by rw [← RingHom.finite_algebraMap] - convert RingHom.Finite.comp hf (RingHom.Finite.of_surjective _ (MvPolynomial.C_surjective _)) + convert! RingHom.Finite.comp hf (RingHom.Finite.of_surjective _ (MvPolynomial.C_surjective _)) exact f.comp_algebraMap.symm exact .of_isIntegral _ | succ n IH => @@ -610,7 +613,7 @@ private lemma ZariskisMainProperty.of_algHom_mvPolynomial ← isIntegral_algebraMap_iff (FaithfulSMul.algebraMap_injective R' S), forall_and, hr, or_imp, Finset.mem_smul_finset] refine ⟨fun i ↦ ?_, fun a has ↦ ?_⟩ - · convert isIntegral_algebraMap (x := MvPolynomial.X i) + · convert! isIntegral_algebraMap (x := MvPolynomial.X i) simp [RingHom.algebraMap_toAlgebra, f', MvPolynomial.finSuccEquiv, MvPolynomial.optionEquivLeft] · rw [← Nat.sub_add_cancel (s.le_sup has), pow_add, mul_assoc] diff --git a/Mathlib/SetTheory/Cardinal/Aleph.lean b/Mathlib/SetTheory/Cardinal/Aleph.lean index 5d077051de1e5a..8f0f500a9347b2 100644 --- a/Mathlib/SetTheory/Cardinal/Aleph.lean +++ b/Mathlib/SetTheory/Cardinal/Aleph.lean @@ -6,6 +6,7 @@ Authors: Johannes Hölzl, Mario Carneiro, Floris van Doorn, Violeta Hernández P module public import Mathlib.Algebra.Order.Monoid.Basic +public import Mathlib.SetTheory.Cardinal.Cofinality.Enum public import Mathlib.SetTheory.Cardinal.ToNat public import Mathlib.SetTheory.Cardinal.ENat public import Mathlib.SetTheory.Ordinal.Enum @@ -310,6 +311,11 @@ theorem _root_.Ordinal.type_lt_cardinal : typeLT Cardinal = Ordinal.univ.{u, u + theorem mk_cardinal : #Cardinal = univ.{u, u + 1} := by simpa only [card_type, card_univ] using congr_arg card type_lt_cardinal +theorem _root_.Order.cof_cardinal : Order.cof Cardinal.{u} = Cardinal.univ.{u, u + 1} := by + simpa using preAleph.cof_congr.symm + +instance : IsRegularCardinalOrder Cardinal := ⟨by simp [Order.cof_cardinal]⟩ + theorem preAleph_lt_preAleph {o₁ o₂ : Ordinal} : preAleph o₁ < preAleph o₂ ↔ o₁ < o₂ := preAleph.lt_iff_lt @@ -336,13 +342,31 @@ theorem preAleph_succ (o : Ordinal) : preAleph (succ o) = succ (preAleph o) := preAleph.map_succ o @[simp] -theorem preAleph_nat (n : ℕ) : preAleph n = n := by +theorem preAleph_natCast (n : ℕ) : preAleph n = n := by rw [← card_preOmega, preOmega_natCast, card_nat] +@[simp] +theorem preAleph_ofNat (n : ℕ) [n.AtLeastTwo] : preAleph ofNat(n) = ofNat(n) := + preAleph_natCast n + +@[simp] +theorem preAleph_symm_natCast (n : ℕ) : preAleph.symm n = n := by + simp [OrderIso.symm_apply_eq] + +@[simp] +theorem preAleph_symm_ofNat (n : ℕ) [n.AtLeastTwo] : preAleph.symm ofNat(n) = ofNat(n) := + preAleph_symm_natCast n + +@[deprecated (since := "2026-05-22")] alias preAleph_nat := preAleph_natCast + @[simp] theorem preAleph_omega0 : preAleph ω = ℵ₀ := by rw [← card_preOmega, preOmega_omega0, card_omega0] +@[simp] +theorem preAleph_symm_aleph0 : preAleph.symm ℵ₀ = ω := by + simp [OrderIso.symm_apply_eq] + @[simp] theorem preAleph_pos {o : Ordinal} : 0 < preAleph o ↔ 0 < o := by rw [← preAleph_zero, preAleph_lt_preAleph] @@ -391,7 +415,7 @@ theorem preAleph_le_of_strictMono {f : Ordinal → Cardinal} (hf : StrictMono f) For a version including finite cardinals, see `Cardinal.preAleph`. -/ def aleph : Ordinal ↪o Cardinal := - (OrderEmbedding.addLeft ω).trans preAleph.toOrderEmbedding + (OrderEmbedding.addLeft ω).trans preAleph @[inherit_doc] scoped notation "ℵ_ " => aleph recommended_spelling "aleph" for "ℵ_" in [aleph, «termℵ_»] @@ -407,6 +431,10 @@ theorem aleph_eq_preAleph (o : Ordinal) : ℵ_ o = preAleph (ω + o) := theorem _root_.Ordinal.card_omega (o : Ordinal) : (ω_ o).card = ℵ_ o := rfl +@[simp] +theorem preAleph_symm_aleph (o : Ordinal) : preAleph.symm (ℵ_ o) = ω + o := + preAleph.symm_apply_apply _ + @[simp] theorem ord_aleph (o : Ordinal) : (ℵ_ o).ord = ω_ o := ord_preAleph _ @@ -580,7 +608,7 @@ theorem preBeth_add_one (o : Ordinal) : preBeth (o + 1) = 2 ^ preBeth o := by rw [preBeth, ← succ_eq_add_one, Iio_succ] exact ciSup_Iic o fun x y h ↦ power_le_power_left two_ne_zero (preBeth_mono h) --- TODO: deprecate +@[deprecated preBeth_add_one (since := "2026-05-26")] theorem preBeth_succ (o : Ordinal) : preBeth (succ o) = 2 ^ preBeth o := preBeth_add_one o @@ -590,7 +618,7 @@ theorem preBeth_limit {o : Ordinal} (ho : IsSuccPrelimit o) : apply (ciSup_mono bddAbove_of_small fun _ ↦ (cantor _).le).antisymm' rw [ciSup_le_iff' bddAbove_of_small] intro a - rw [← preBeth_succ] + rw [← preBeth_add_one] exact le_ciSup bddAbove_of_small (⟨_, ho.succ_lt a.2⟩ : Iio o) theorem isNormal_preBeth : Order.IsNormal preBeth := by @@ -664,8 +692,8 @@ theorem lift_preBeth (o : Ordinal) : lift.{v} (preBeth o) = preBeth (Ordinal.lif rw [mem_Iio, Ordinal.lift_lt] at hi exact ⟨⟨i, hi⟩, IH _ hi⟩ -/-- The Beth function is defined so that `beth 0 = ℵ₀'`, `beth (succ o) = 2 ^ beth o`, and that for -a limit ordinal `o`, `beth o` is the supremum of `beth a` for `a < o`. +/-- The Beth function is defined so that `beth 0 = ℵ₀`, `beth (succ o) = 2 ^ beth o`, and that for a +limit ordinal `o`, `beth o` is the supremum of `beth a` for `a < o`. Assuming the generalized continuum hypothesis, which is undecidable in ZFC, we have `ℶ_ o = ℵ_ o` for all ordinals. diff --git a/Mathlib/SetTheory/Cardinal/Arithmetic.lean b/Mathlib/SetTheory/Cardinal/Arithmetic.lean index 5056b45cf12646..c11b1336a233ff 100644 --- a/Mathlib/SetTheory/Cardinal/Arithmetic.lean +++ b/Mathlib/SetTheory/Cardinal/Arithmetic.lean @@ -121,7 +121,7 @@ theorem mul_lt_of_lt {a b c : Cardinal} (hc : ℵ₀ ≤ c) (ha : a < c) (hb : b exact max_lt ha hb theorem mul_le_max_of_aleph0_le_left {a b : Cardinal} (h : ℵ₀ ≤ a) : a * b ≤ max a b := by - convert mul_le_mul' (le_max_left a b) (le_max_right a b) using 1 + convert! mul_le_mul' (le_max_left a b) (le_max_right a b) using 1 rw [mul_eq_self] exact h.trans (le_max_left a b) @@ -132,7 +132,7 @@ theorem mul_eq_max_of_aleph0_le_left {a b : Cardinal} (h : ℵ₀ ≤ a) (h' : b refine (mul_le_max_of_aleph0_le_left h).antisymm ?_ have : b ≤ a := hb.le.trans h rw [max_eq_left this] - convert mul_le_mul_right (Cardinal.one_le_iff_ne_zero.mpr h') a + convert! mul_le_mul_right (Cardinal.one_le_iff_ne_zero.mpr h') a rw [mul_one] theorem mul_le_max_of_aleph0_le_right {a b : Cardinal} (h : ℵ₀ ≤ b) : a * b ≤ max a b := by @@ -166,7 +166,7 @@ theorem mul_eq_right {a b : Cardinal} (hb : ℵ₀ ≤ b) (ha : a ≤ b) (ha' : rw [mul_comm, mul_eq_left hb ha ha'] theorem le_mul_left {a b : Cardinal} (h : b ≠ 0) : a ≤ b * a := by - convert mul_le_mul_left (Cardinal.one_le_iff_ne_zero.mpr h) a + convert! mul_le_mul_left (Cardinal.one_le_iff_ne_zero.mpr h) a rw [one_mul] theorem le_mul_right {a b : Cardinal} (h : b ≠ 0) : a ≤ a * b := by @@ -428,7 +428,7 @@ theorem sum_eq_lift_iSup_of_lift_mk_le_lift_iSup [Small.{v} ι] {f : ι → Card (h : lift.{v} #ι ≤ lift.{u} (⨆ i, f i)) : sum f = lift (⨆ i, f i) := by rw [lift_iSup bddAbove_of_small] at h apply (lift_iSup_le_sum f).antisymm' - convert sum_le_lift_mk_mul_iSup_lift f + convert! sum_le_lift_mk_mul_iSup_lift f rw [mul_eq_max (aleph0_le_lift.mpr hι) ((aleph0_le_lift.mpr hι).trans h), max_eq_right h, lift_iSup bddAbove_of_small] @@ -598,7 +598,7 @@ theorem powerlt_aleph0 {c : Cardinal} (h : ℵ₀ ≤ c) : c ^< ℵ₀ = c := by apply le_antisymm · rw [powerlt_le] exact fun _ a ↦ pow_le h a - convert le_powerlt c one_lt_aleph0; rw [power_one] + convert! le_powerlt c one_lt_aleph0; rw [power_one] theorem powerlt_aleph0_le (c : Cardinal) : c ^< ℵ₀ ≤ max c ℵ₀ := by rcases le_or_gt ℵ₀ c with h | h diff --git a/Mathlib/SetTheory/Cardinal/Basic.lean b/Mathlib/SetTheory/Cardinal/Basic.lean index b45d98e570313b..a487a36c7b89d4 100644 --- a/Mathlib/SetTheory/Cardinal/Basic.lean +++ b/Mathlib/SetTheory/Cardinal/Basic.lean @@ -133,7 +133,7 @@ theorem lift_sInf (s : Set Cardinal) : lift.{u, v} (sInf s) = sInf (lift.{u, v} @[simp] theorem lift_iInf {ι} (f : ι → Cardinal) : lift.{u, v} (iInf f) = ⨅ i, lift.{u, v} (f i) := by unfold iInf - convert lift_sInf (range f) + convert! lift_sInf (range f) simp_rw [← comp_apply (f := lift), range_comp] end Cardinal @@ -285,7 +285,7 @@ lemma lt_natCast_add_one_iff {n : ℕ} {c : Cardinal} : c < n + 1 ↔ c ≤ n := rw [← Order.lt_succ_iff, succ_natCast] lemma two_le_iff_one_lt {c : Cardinal} : 2 ≤ c ↔ 1 < c := by - convert natCast_add_one_le_iff + convert! natCast_add_one_le_iff norm_cast @[simp] @@ -919,7 +919,7 @@ theorem mk_preimage_of_injective_of_subset_range_lift {β : Type v} (f : α → theorem mk_preimage_of_injective_of_subset_range (f : α → β) (s : Set β) (h : Injective f) (h2 : s ⊆ range f) : #(f ⁻¹' s) = #s := by - convert mk_preimage_of_injective_of_subset_range_lift.{u, u} f s h h2 using 1 <;> rw [lift_id] + convert! mk_preimage_of_injective_of_subset_range_lift.{u, u} f s h h2 using 1 <;> rw [lift_id] @[simp] theorem mk_preimage_equiv_lift {β : Type v} (f : α ≃ β) (s : Set β) : @@ -945,14 +945,14 @@ theorem mk_preimage_of_subset_range (f : α → β) (s : Set β) (h : s ⊆ rang theorem mk_subset_ge_of_subset_image_lift {α : Type u} {β : Type v} (f : α → β) {s : Set α} {t : Set β} (h : t ⊆ f '' s) : lift.{u} #t ≤ lift.{v} #({ x ∈ s | f x ∈ t } : Set α) := by rw [image_eq_range] at h - convert mk_preimage_of_subset_range_lift _ _ h using 1 + convert! mk_preimage_of_subset_range_lift _ _ h using 1 rw [mk_sep] rfl theorem mk_subset_ge_of_subset_image (f : α → β) {s : Set α} {t : Set β} (h : t ⊆ f '' s) : #t ≤ #({ x ∈ s | f x ∈ t } : Set α) := by rw [image_eq_range] at h - convert mk_preimage_of_subset_range _ _ h using 1 + convert! mk_preimage_of_subset_range _ _ h using 1 rw [mk_sep] rfl @@ -1053,7 +1053,7 @@ theorem zero_powerlt {a : Cardinal} (h : a ≠ 0) : 0 ^< a = 1 := by @[simp] theorem powerlt_zero {a : Cardinal} : a ^< 0 = 0 := by - convert Cardinal.iSup_of_empty _ + convert! Cardinal.iSup_of_empty _ exact Subtype.isEmpty_of_false fun x => mem_Iio.not.mpr not_lt_zero /-- The cardinality of a set is an upper-bound for the amount of elements before the set's mex diff --git a/Mathlib/SetTheory/Cardinal/Cofinality/Basic.lean b/Mathlib/SetTheory/Cardinal/Cofinality/Basic.lean index ff288badfea0f4..4cbeee18f776f1 100644 --- a/Mathlib/SetTheory/Cardinal/Cofinality/Basic.lean +++ b/Mathlib/SetTheory/Cardinal/Cofinality/Basic.lean @@ -48,17 +48,19 @@ theorem le_cof_iff {c : Cardinal} : c ≤ cof α ↔ ∀ s : Set α, IsCofinal s @[deprecated (since := "2026-02-18")] alias le_cof := le_cof_iff variable (α) in -theorem cof_eq : ∃ s : Set α, IsCofinal s ∧ #s = cof α := by +theorem exists_cof_eq : ∃ s : Set α, IsCofinal s ∧ #s = cof α := by obtain ⟨s, hs⟩ := ciInf_mem fun s : {s : Set α // IsCofinal s} ↦ #s exact ⟨s.1, s.2, hs⟩ +@[deprecated (since := "2026-05-25")] alias cof_eq := exists_cof_eq + variable (α) in theorem cof_le_cardinalMk : cof α ≤ #α := cof_le .univ |>.trans_eq mk_univ theorem cof_eq_zero_iff : cof α = 0 ↔ IsEmpty α := by refine ⟨fun _ ↦ ?_, fun _ ↦ by simp [cof]⟩ - obtain ⟨s, hs, hs'⟩ := cof_eq α + obtain ⟨s, hs, hs'⟩ := exists_cof_eq α simp_all [mk_eq_zero_iff, isCofinal_empty_iff] @[simp] @@ -74,7 +76,7 @@ theorem cof_ne_zero [h : Nonempty α] : cof α ≠ 0 := theorem cof_eq_one_iff : cof α = 1 ↔ ∃ x : α, IsTop x := by refine ⟨fun h ↦ ?_, fun ⟨t, ht⟩ ↦ ?_⟩ - · obtain ⟨s, hs, hs'⟩ := cof_eq α + · obtain ⟨s, hs, hs'⟩ := exists_cof_eq α rw [h, mk_set_eq_one_iff] at hs' obtain ⟨t, rfl⟩ := hs' use t @@ -132,9 +134,9 @@ theorem cof_congr_of_strictMono {f : α → γ} (hf : StrictMono f) (hf' : IsCof simpa using lift_cof_congr_of_strictMono hf hf' @[simp] -theorem cof_lt_aleph0_iff : Order.cof α < ℵ₀ ↔ Order.cof α ≤ 1 := by +theorem cof_lt_aleph0_iff : cof α < ℵ₀ ↔ cof α ≤ 1 := by refine ⟨fun h ↦ ?_, (lt_of_le_of_lt · one_lt_aleph0)⟩ - obtain ⟨s, hs, hs'⟩ := Order.cof_eq α + obtain ⟨s, hs, hs'⟩ := exists_cof_eq α have hf : s.Finite := by rw [Set.Finite, ← mk_lt_aleph0_iff] exact hs'.trans_lt h @@ -143,7 +145,7 @@ theorem cof_lt_aleph0_iff : Order.cof α < ℵ₀ ↔ Order.cof α ≤ 1 := by simpa @[simp] -theorem aleph0_le_cof_iff : ℵ₀ ≤ Order.cof α ↔ 1 < Order.cof α := by +theorem aleph0_le_cof_iff : ℵ₀ ≤ cof α ↔ 1 < cof α := by simp [← not_lt] theorem aleph0_le_cof [Nonempty α] [NoMaxOrder α] : ℵ₀ ≤ cof α := by diff --git a/Mathlib/SetTheory/Cardinal/Cofinality/Club.lean b/Mathlib/SetTheory/Cardinal/Cofinality/Club.lean index 58671ac506a2db..7aa88a68cc09b1 100644 --- a/Mathlib/SetTheory/Cardinal/Cofinality/Club.lean +++ b/Mathlib/SetTheory/Cardinal/Cofinality/Club.lean @@ -38,46 +38,48 @@ structure IsClub {α : Type*} [LinearOrder α] (s : Set α) where See `not_bddAbove_iff_isCofinal`. -/ isCofinal : IsCofinal s +namespace IsClub + variable {α : Type v} {s t : Set α} {x : α} [LinearOrder α] @[simp] -theorem IsClub.of_isEmpty [IsEmpty α] {s : Set α} : IsClub s := +theorem of_isEmpty [IsEmpty α] {s : Set α} : IsClub s := ⟨.of_isEmpty, .of_isEmpty⟩ @[simp] -theorem IsClub.univ : IsClub (α := α) .univ := +protected theorem univ : IsClub (α := α) .univ := ⟨.univ, .univ⟩ -theorem IsClub.union (hs : IsClub s) (ht : IsClub t) : IsClub (s ∪ t) := +protected theorem union (hs : IsClub s) (ht : IsClub t) : IsClub (s ∪ t) := ⟨hs.dirSupClosed.union ht.dirSupClosed, hs.isCofinal.mono Set.subset_union_left⟩ -theorem IsClub.isLUB_mem (hs : IsClub s) (ht : t ⊆ s) (ht₀ : t.Nonempty) (hx : IsLUB t x) : x ∈ s := +theorem isLUB_mem (hs : IsClub s) (ht : t ⊆ s) (ht₀ : t.Nonempty) (hx : IsLUB t x) : x ∈ s := hs.dirSupClosed ht ht₀ (.of_linearOrder _) hx -theorem IsClub.csSup_mem {α} [ConditionallyCompleteLinearOrder α] {s t : Set α} +theorem csSup_mem {α} [ConditionallyCompleteLinearOrder α] {s t : Set α} (hs : IsClub s) (ht : t ⊆ s) (ht₀ : t.Nonempty) (ht₁ : BddAbove t) : sSup t ∈ s := hs.isLUB_mem ht ht₀ (isLUB_csSup ht₀ ht₁) -theorem IsClub.sInter_of_orderTop {s : Set (Set α)} [OrderTop α] - (hs : ∀ x ∈ s, IsClub x) : IsClub (⋂₀ s) := by +theorem sInter_of_orderTop {s : Set (Set α)} [OrderTop α] (hs : ∀ x ∈ s, IsClub x) : + IsClub (⋂₀ s) := by refine ⟨.sInter fun x hx ↦ (hs x hx).dirSupClosed, ?_⟩ rw [isCofinal_iff_top_mem, Set.mem_sInter] exact fun x hx ↦ (hs x hx).isCofinal.top_mem -theorem IsClub.iInter_of_orderTop {ι : Type*} {f : ι → Set α} [OrderTop α] - (hs : ∀ i, IsClub (f i)) : IsClub (⋂ i, f i) := by +theorem iInter_of_orderTop {ι : Type*} {f : ι → Set α} [OrderTop α] (hs : ∀ i, IsClub (f i)) : + IsClub (⋂ i, f i) := by rw [← Set.sInter_range] exact .sInter_of_orderTop (by simpa) -theorem IsClub.sInter_of_cof_le_one {s : Set (Set α)} (hα : cof α ≤ 1) - (hs : ∀ x ∈ s, IsClub x) : IsClub (⋂₀ s) := by +theorem sInter_of_cof_le_one {s : Set (Set α)} (hα : cof α ≤ 1) (hs : ∀ x ∈ s, IsClub x) : + IsClub (⋂₀ s) := by cases isEmpty_or_nonempty α; · simp cases topOrderOrNoTopOrder α · exact .sInter_of_orderTop hs · cases one_lt_cof.not_ge hα -theorem IsClub.iInter_of_cof_le_one {ι : Type*} {f : ι → Set α} (hα : cof α ≤ 1) - (hs : ∀ i, IsClub (f i)) : IsClub (⋂ i, f i) := by +theorem iInter_of_cof_le_one {ι : Type*} {f : ι → Set α} (hα : cof α ≤ 1) (hs : ∀ i, IsClub (f i)) : + IsClub (⋂ i, f i) := by rw [← Set.sInter_range] exact .sInter_of_cof_le_one hα (by simpa) @@ -88,7 +90,7 @@ variable [WellFoundedLT α] attribute [local instance] WellFoundedLT.toOrderBot WellFoundedLT.conditionallyCompleteLinearOrderBot -theorem IsClub.sInter {s : Set (Set α)} (hα : cof α ≠ ℵ₀) (hsα : #s < cof α) +protected theorem sInter {s : Set (Set α)} (hα : cof α ≠ ℵ₀) (hsα : #s < cof α) (hs : ∀ x ∈ s, IsClub x) : IsClub (⋂₀ s) := by cases isEmpty_or_nonempty α; · simp obtain hα | hα := hα.lt_or_gt @@ -108,7 +110,7 @@ theorem IsClub.sInter {s : Set (Set α)} (hα : cof α ≠ ℵ₀) (hsα : #s < · exact (hf ⟨t, ht⟩ _).2.trans <| hb ⟨_, rfl⟩ · grind -theorem IsClub.iInter {ι : Type u} {f : ι → Set α} (hα : cof α ≠ ℵ₀) +protected theorem iInter {ι : Type u} {f : ι → Set α} (hα : cof α ≠ ℵ₀) (hι : Cardinal.lift.{v} #ι < Cardinal.lift.{u} (cof α)) (hf : ∀ i, IsClub (f i)) : IsClub (⋂ i, f i) := by rw [← Set.sInter_range] @@ -116,7 +118,7 @@ theorem IsClub.iInter {ι : Type u} {f : ι → Set α} (hα : cof α ≠ ℵ₀ rw [← Cardinal.lift_lt] exact mk_range_le_lift.trans_lt hι -theorem IsClub.inter {s t : Set α} (hα : cof α ≠ ℵ₀) (hs : IsClub s) (ht : IsClub t) : +protected theorem inter {s t : Set α} (hα : cof α ≠ ℵ₀) (hs : IsClub s) (ht : IsClub t) : IsClub (s ∩ t) := by rw [← Set.sInter_pair] have H : ∀ x ∈ ({s, t} : Set _), IsClub x := by simpa [hs] @@ -125,10 +127,10 @@ theorem IsClub.inter {s t : Set α} (hα : cof α ≠ ℵ₀) (hs : IsClub s) (h exact .sInter_of_cof_le_one hα H · exact .sInter hα (hα'.trans_le' <| by simp) H -theorem Order.IsNormal.isClub_range {f : α → α} (hf : IsNormal f) : IsClub (.range f) := +theorem _root_.Order.IsNormal.isClub_range {f : α → α} (hf : IsNormal f) : IsClub (.range f) := ⟨hf.dirSupClosed_range, fun x ↦ ⟨_, ⟨x, rfl⟩, hf.strictMono.le_apply⟩⟩ -theorem Order.IsNormal.isClub_fixedPoints {f : α → α} (hα : cof α ≠ ℵ₀) (hf : IsNormal f) : +theorem _root_.Order.IsNormal.isClub_fixedPoints {f : α → α} (hα : cof α ≠ ℵ₀) (hf : IsNormal f) : IsClub f.fixedPoints := by cases isEmpty_or_nonempty α; · simp refine ⟨fun s hs hs₀ _ a ha ↦ (hf.map_isLUB ha hs₀).unique ?_, fun a ↦ ?_⟩ @@ -144,3 +146,4 @@ theorem Order.IsNormal.isClub_fixedPoints {f : α → α} (hα : cof α ≠ ℵ simpa using mk_range_le_lift (f := fun n : ℕ ↦ f^[n] a) end WellFoundedLT +end IsClub diff --git a/Mathlib/SetTheory/Cardinal/Cofinality/Enum.lean b/Mathlib/SetTheory/Cardinal/Cofinality/Enum.lean new file mode 100644 index 00000000000000..2c4170c98d118d --- /dev/null +++ b/Mathlib/SetTheory/Cardinal/Cofinality/Enum.lean @@ -0,0 +1,112 @@ +/- +Copyright (c) 2026 Violeta Hernández Palacios. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Violeta Hernández Palacios +-/ +module + +public import Mathlib.SetTheory.Cardinal.Cofinality.Basic +public import Mathlib.SetTheory.Ordinal.Family +public import Mathlib.SetTheory.Ordinal.Univ + +/-! +# Enumerating a cofinal set + +We define a typeclass `IsRegularCardinalOrder` for well-ordered types, whose order type equals (the +initial ordinal of) their cofinality. This notion does not appear in the literature, but intends to +generalize the properties of intervals `Iio c.ord`, wherever `c` is a regular cardinal. Other +instances of this typeclass include `ℕ`, `Ordinal`, and `Cardinal`. + +If `s` is a cofinal subset of a regular cardinal order `α`, there exists a unique order isomorphism +`α ≃o s`, which we call `Order.enum`. When `α = Ordinal`, this is referred to as the enumerator +function of the set. Note that if `α = ℕ`, then this definition matches `Nat.nth`. + +## TODO + +- Deprecate `Ordinal.enumOrd` in favor of `Order.enum`. +- Prove that `Order.enum` on the naturals coincides with `Nat.nth`. +-/ + +public section + +universe u + +open Cardinal Order Ordinal Set + +variable {α : Type*} + +/-- A typeclass which expresses that the order type of a well-order equals (the initial ordinal of) +its cofinality. + +If `α` is infinite, this implies that `α` is order isomorphic to `Iio c.ord` for some regular +cardinal `c`. In the informal literature, one often says that `α` is a regular cardinal, by abuse +of notation. -/ +class IsRegularCardinalOrder (α : Type*) [LinearOrder α] [WellFoundedLT α] where + type_lt_le_ord_cof : typeLT α ≤ (cof α).ord + +instance : IsRegularCardinalOrder ℕ := ⟨by simp⟩ + +instance (priority := low) [LinearOrder α] [WellFoundedLT α] [Subsingleton α] : + IsRegularCardinalOrder α where + type_lt_le_ord_cof := by + cases isEmpty_or_nonempty α + · simpa + · cases nonempty_unique α + have := BoundedOrder.ofUnique α + simp + +instance : IsRegularCardinalOrder Ordinal where + type_lt_le_ord_cof := by + rw [type_lt_ordinal, ← ord_univ, ord_le_ord, le_cof_iff] + intro s hs + contrapose! hs + rw [← Cardinal.lift_id (#s), ← small_iff_lift_mk_lt_univ] at hs + rw [not_isCofinal_iff_bddAbove] + exact Ordinal.bddAbove_of_small + +namespace Order +variable [LinearOrder α] [WellFoundedLT α] [IsRegularCardinalOrder α] + +theorem ord_cof_eq_type_lt : (cof α).ord = typeLT α := by + apply IsRegularCardinalOrder.type_lt_le_ord_cof.antisymm' + rw [ord_le, card_type] + exact cof_le_cardinalMk α + +@[simp] +theorem cof_eq_cardinalMk : cof α = #α := by + rw [← card_type LT.lt, ← ord_cof_eq_type_lt, card_ord] + +@[simp] +theorem _root_.Cardinal.ord_cardinalMk : ord #α = typeLT α := by + rw [← ord_cof_eq_type_lt, cof_eq_cardinalMk] + +theorem cof_ordinal : cof Ordinal.{u} = Cardinal.univ.{u, u + 1} := by + simp + +theorem type_eq_of_isCofinal {s : Set α} (hs : IsCofinal s) : typeLT s = typeLT α := by + apply (RelEmbedding.ofMonotone Subtype.val (by simp)).ordinal_type_le.antisymm + rw [← ord_cardinalMk, ord_le, card_type, ← cof_eq_cardinalMk] + exact cof_le hs + +/-- Enumerate the elements of a cofinal subset of `α` by `α` itself. This is a generalization of +`Nat.nth`. -/ +noncomputable def enum (s : Set α) (hs : IsCofinal s) : α ≃o s := + .ofRelIsoLT (type_eq.1 (type_eq_of_isCofinal hs).symm).some + +theorem enum_le_of_forall_lt {a o : α} {s : Set α} {hs : IsCofinal s} (ho : o ∈ s) + (H : ∀ b < a, enum s hs b < o) : enum s hs a ≤ o := by + rw [← Subtype.coe_mk o ho, Subtype.coe_le_coe, ← OrderIso.le_symm_apply] + apply le_of_forall_lt + simpa [OrderIso.lt_symm_apply] + +theorem enum_succ_le_of_lt [SuccOrder α] {a o : α} {s : Set α} {hs : IsCofinal s} (ha : o ∈ s) + (H : enum s hs a < o) : enum s hs (succ a) ≤ o := by + refine enum_le_of_forall_lt ha fun b hb ↦ H.trans_le' ?_ + simpa using le_of_lt_succ hb + +@[simp] +theorem enum_univ (x : α) : enum univ .univ x = ⟨x, mem_univ x⟩ := by + rw [← Subsingleton.allEq OrderIso.Set.univ.symm (enum univ .univ)] + rfl + +end Order diff --git a/Mathlib/SetTheory/Cardinal/Cofinality/Ordinal.lean b/Mathlib/SetTheory/Cardinal/Cofinality/Ordinal.lean index a3fbe3edf236a9..19beb23372c63a 100644 --- a/Mathlib/SetTheory/Cardinal/Cofinality/Ordinal.lean +++ b/Mathlib/SetTheory/Cardinal/Cofinality/Ordinal.lean @@ -118,7 +118,7 @@ theorem cof_add_one (o) : cof (o + 1) = 1 := theorem cof_one : cof 1 = 1 := by simpa using cof_add_one 0 --- TODO: deprecate in favor of `cof_add_one` +@[deprecated cof_add_one (since := "2026-05-25")] theorem cof_succ (o) : cof (succ o) = 1 := cof_add_one o @@ -151,9 +151,9 @@ theorem cof_omega0 : cof ω = ℵ₀ := @[deprecated (since := "2026-02-18")] alias cof_eq_one_iff_is_succ := cof_eq_one_iff -theorem ord_cof_eq (α : Type*) [LinearOrder α] [WellFoundedLT α] : +theorem exists_ord_cof_eq (α : Type*) [LinearOrder α] [WellFoundedLT α] : ∃ s : Set α, IsCofinal s ∧ typeLT s = (Order.cof α).ord := by - obtain ⟨s, hs, hs'⟩ := Order.cof_eq α + obtain ⟨s, hs, hs'⟩ := exists_cof_eq α obtain ⟨r, hr, hr'⟩ := exists_ord_eq s have ht := hs.trans (isCofinal_setOf_imp_lt r) refine ⟨_, ht, (ord_le.2 (cof_le ht)).antisymm' ?_⟩ @@ -166,10 +166,12 @@ theorem ord_cof_eq (α : Type*) [LinearOrder α] [WellFoundedLT α] : · obtain ⟨x, z, hz, rfl⟩ := x exact (hz _ hxy').asymm hxy +@[deprecated (since := "2026-05-25")] alias ord_cof_eq := exists_ord_cof_eq + @[simp] theorem _root_.Order.cof_ord_cof (α : Type*) [LinearOrder α] [WellFoundedLT α] : (Order.cof α).ord.cof = Order.cof α := by - obtain ⟨s, hs, hs'⟩ := ord_cof_eq α + obtain ⟨s, hs, hs'⟩ := exists_ord_cof_eq α rw [← hs', cof_type] apply le_antisymm · rw [← card_ord (Order.cof α), ← hs', card_type] @@ -235,12 +237,12 @@ alias cof_eq_of_isNormal := cof_map_of_isNormal alias IsNormal.cof_eq := cof_eq_of_isNormal theorem le_cof_map_of_isNormal {f} (hf : IsNormal f) (a) : cof a ≤ cof (f a) := by - rcases zero_or_succ_or_isSuccLimit a with (rfl | ⟨b, rfl⟩ | ha) - · rw [cof_zero] - exact zero_le - · rw [cof_succ, Cardinal.one_le_iff_ne_zero, cof_eq_zero.ne] - exact (hf.strictMono (lt_succ b)).ne_zero - · rw [cof_map_of_isNormal hf ha] + cases a using limitRecOn with + | zero => simp + | add_one a => + rw [cof_add_one, Cardinal.one_le_iff_ne_zero, cof_eq_zero.ne] + exact (hf.strictMono (lt_succ a)).ne_zero + | limit a ha => rw [cof_map_of_isNormal hf ha] @[deprecated (since := "2026-03-19")] alias cof_le_of_isNormal := le_cof_map_of_isNormal @@ -255,7 +257,7 @@ theorem sSup_add_one_lt_of_lt_cof {s : Set Ordinal.{u}} {a : Ordinal.{u}} refine small_of_injective (β := Iio a) (f := fun x ↦ ⟨f x, hs _ (f x).2⟩) fun _ ↦ ?_ simp [Subtype.val_inj] have : range (fun i ↦ (f i).1 + 1) = (· + 1) '' s := by - convert range_comp (· + 1) (fun i ↦ (f i).1) + convert! range_comp (· + 1) (fun i ↦ (f i).1) rw [range_comp', f.range_eq] simp rw [← this, sSup_range] @@ -547,7 +549,7 @@ theorem cof_eq' (r : α → α → Prop) [H : IsWellOrder α r] (h : IsSuccLimit let := linearOrderOfSTO r have : WellFoundedLT α := H.toIsWellFounded have : NoMaxOrder α := isSuccPrelimit_type_lt_iff.1 h.isSuccPrelimit - obtain ⟨s, hs, hs'⟩ := Order.cof_eq α + obtain ⟨s, hs, hs'⟩ := exists_cof_eq α refine ⟨s, ?_, hs'⟩ rwa [← not_bddAbove_iff_isCofinal, not_bddAbove_iff] at hs @@ -558,17 +560,6 @@ theorem cof_univ : cof univ.{u, v} = Cardinal.univ.{u, v} := by ← not_bddAbove_iff_isCofinal] exact fun s hs ↦ mk_le_of_injective (enumOrdOrderIso s hs).injective -@[simp] -theorem _root_.Order.cof_ordinal : Order.cof Ordinal.{u} = Cardinal.univ.{u, u + 1} := by - have := (OrderIso.ofRelIsoLT liftPrincipalSeg.subrelIso.{u, u + 1}).lift_cof_congr - rw [Cardinal.lift_id'.{_, u + 2}] at this - change Order.cof (Iio univ) = _ at this - rwa [cof_Iio, ← lift_cof, Cardinal.lift_inj, cof_univ, eq_comm] at this - -@[simp] -theorem _root_.Order.cof_cardinal : Order.cof Cardinal.{u} = Cardinal.univ.{u, u + 1} := by - rw [← preAleph.cof_congr, cof_ordinal] - end Ordinal namespace Cardinal @@ -642,7 +633,7 @@ theorem lt_power_cof_ord {c : Cardinal} (hc : ℵ₀ ≤ c) : c < c ^ c.ord.cof have : NoMaxOrder α := by rw [← isSuccPrelimit_type_lt_iff, ← hα] exact (isSuccLimit_ord hc).isSuccPrelimit - obtain ⟨s, hs, hs'⟩ := ord_cof_eq α + obtain ⟨s, hs, hs'⟩ := exists_ord_cof_eq α rw [hα, cof_type, ← card_ord (Order.cof _), ← hs', card_type, ← prod_const'] refine (mk_iUnion_le_sum_mk.trans' ?_).trans_lt (sum_lt_prod _ _ fun i ↦ mk_Iio_lt i.1 hα) rw [← mk_univ, ← isCofinal_iff_iUnion_Iio_eq_univ.1 hs, iUnion_coe_set] diff --git a/Mathlib/SetTheory/Cardinal/CountableCover.lean b/Mathlib/SetTheory/Cardinal/CountableCover.lean index d9700f654ffc97..5d850d5e75e65c 100644 --- a/Mathlib/SetTheory/Cardinal/CountableCover.lean +++ b/Mathlib/SetTheory/Cardinal/CountableCover.lean @@ -51,7 +51,7 @@ lemma mk_subtype_le_of_countable_eventually_mem_aux {α ι : Type u} {a : Cardin have : s ⊆ u := fun x hx ↦ by simpa only [u, Set.mem_toFinset] using hi x hx exact Finset.card_le_card this have I2 : (u.card : Cardinal) ≤ n := by - convert h'f i; simp only [u, Set.toFinset_card, mk_fintype] + convert! h'f i; simp only [u, Set.toFinset_card, mk_fintype] exact I1.trans (Nat.cast_le.1 I2) -- case `a` infinite: · have : t ⊆ ⋃ i, f i := by diff --git a/Mathlib/SetTheory/Cardinal/ENat.lean b/Mathlib/SetTheory/Cardinal/ENat.lean index 30cd819322942a..94adf0d8755a77 100644 --- a/Mathlib/SetTheory/Cardinal/ENat.lean +++ b/Mathlib/SetTheory/Cardinal/ENat.lean @@ -274,7 +274,6 @@ lemma toENat_eq_iff_of_le_aleph0 (hc : c ≤ ℵ₀) (hc' : c' ≤ ℵ₀) : toE natCast_le_toENat @[simp] lemma toENat_lt_natCast : toENat c < n ↔ c < n := by simp [← not_le] -@[simp] lemma toENat_lt_one : toENat c < 1 ↔ c < 1 := toENat_lt_natCast @[simp] lemma toENat_lt_ofNat [n.AtLeastTwo] : toENat c < ofNat(n) ↔ c < ofNat(n) := toENat_lt_natCast @@ -289,6 +288,9 @@ lemma toENat_eq_iff_of_le_aleph0 (hc : c ≤ ℵ₀) (hc' : c' ≤ ℵ₀) : toE @[simp] lemma toENat_eq_ofNat [n.AtLeastTwo] : toENat c = ofNat(n) ↔ c = ofNat(n) := toENat_eq_natCast +@[deprecated toENat_eq_zero (since := "2026-05-25")] +lemma toENat_lt_one : toENat c < 1 ↔ c < 1 := by simp + @[deprecated (since := "2026-01-13")] alias toENat_eq_nat := toENat_eq_natCast @[simp] lemma natCast_eq_toENat : n = toENat c ↔ n = c := by simp [eq_comm (a := Nat.cast _)] diff --git a/Mathlib/SetTheory/Cardinal/Finite.lean b/Mathlib/SetTheory/Cardinal/Finite.lean index 9a618a494b8171..83ee0406c47800 100644 --- a/Mathlib/SetTheory/Cardinal/Finite.lean +++ b/Mathlib/SetTheory/Cardinal/Finite.lean @@ -350,15 +350,15 @@ theorem card_eq_zero_iff_empty (α : Type*) : card α = 0 ↔ IsEmpty α := by theorem card_ne_zero_iff_nonempty (α : Type*) : card α ≠ 0 ↔ Nonempty α := by simp [card_eq_zero_iff_empty] +theorem card_pos_iff_nonempty (α : Type*) : 0 < card α ↔ Nonempty α := by + rw [pos_iff_ne_zero, card_ne_zero_iff_nonempty] + theorem one_le_card_iff_nonempty (α : Type*) : 1 ≤ card α ↔ Nonempty α := by - simp [one_le_iff_ne_zero, card_eq_zero_iff_empty] + simp [Order.one_le_iff_ne_zero, card_eq_zero_iff_empty] @[simp] lemma card_pos [Nonempty α] : 0 < card α := by simpa [pos_iff_ne_zero, card_ne_zero_iff_nonempty] -lemma card_pos_iff_nonempty : 0 < ENat.card α ↔ Nonempty α := by - simp [pos_iff_ne_zero, card_ne_zero_iff_nonempty] - theorem card_le_one_iff_subsingleton (α : Type*) : card α ≤ 1 ↔ Subsingleton α := by rw [← le_one_iff_subsingleton] simp [card] @@ -385,7 +385,7 @@ theorem card_prod (α β : Type*) : card (α × β) = card α * card β := by simp [ENat.card] @[simp] -lemma card_fun {α β : Type*} : card (α → β) = (card β) ^ card α := by +lemma card_fun {α β : Type*} : card (α → β) = card β ^ card α := by classical rcases isEmpty_or_nonempty α with α_emp | α_emp · simp [(card_eq_zero_iff_empty α).2 α_emp] @@ -395,10 +395,11 @@ lemma card_fun {α β : Type*} : card (α → β) = (card β) ^ card α := by letI := Fintype.ofFinite β simp · simp only [card_eq_top_of_infinite] - exact (top_epow (one_le_iff_ne_zero.1 ((one_le_card_iff_nonempty α).2 α_emp))).symm + rw [top_epow] + rwa [card_ne_zero_iff_nonempty] · rw [card_eq_top_of_infinite (α := α)] rcases lt_trichotomy (card β) 1 with b_0 | b_1 | b_2 - · rw [lt_one_iff_eq_zero, card_eq_zero_iff_empty] at b_0 + · rw [Order.lt_one_iff, card_eq_zero_iff_empty] at b_0 rw [(card_eq_zero_iff_empty β).2 b_0, zero_epow_top, card_eq_zero_iff_empty] simp [b_0] · rw [b_1, one_epow] diff --git a/Mathlib/SetTheory/Cardinal/HasCardinalLT.lean b/Mathlib/SetTheory/Cardinal/HasCardinalLT.lean index 3ca5cefec78842..99db04260f81fc 100644 --- a/Mathlib/SetTheory/Cardinal/HasCardinalLT.lean +++ b/Mathlib/SetTheory/Cardinal/HasCardinalLT.lean @@ -172,7 +172,7 @@ lemma hasCardinalLT_iUnion {ι : Type*} {X : Type*} (S : ι → Set X) {κ : Cardinal} [Fact κ.IsRegular] (hι : HasCardinalLT ι κ) (hS : ∀ i, HasCardinalLT (S i) κ) : HasCardinalLT (⋃ i, S i) κ := by - convert show HasCardinalLT (setOf ((⨆ i, S i))) κ from hasCardinalLT_subtype_iSup S hι hS + convert! show HasCardinalLT (setOf ((⨆ i, S i))) κ from hasCardinalLT_subtype_iSup S hι hS aesop /-- The particular case of `hasCardinalLT_prod` when all the inputs are in the diff --git a/Mathlib/SetTheory/Cardinal/Order.lean b/Mathlib/SetTheory/Cardinal/Order.lean index fa292d6f22482c..7852ac1273b299 100644 --- a/Mathlib/SetTheory/Cardinal/Order.lean +++ b/Mathlib/SetTheory/Cardinal/Order.lean @@ -330,7 +330,7 @@ theorem power_le_power_left : ∀ {a b c : Cardinal}, a ≠ 0 → b ≤ c → a theorem self_le_power (a : Cardinal) {b : Cardinal} (hb : 1 ≤ b) : a ≤ a ^ b := by rcases eq_or_ne a 0 with (rfl | ha) · exact zero_le - · convert power_le_power_left ha hb + · convert! power_le_power_left ha hb exact (power_one a).symm /-- **Cantor's theorem** -/ diff --git a/Mathlib/SetTheory/Cardinal/Ordinal.lean b/Mathlib/SetTheory/Cardinal/Ordinal.lean index 4f6ace67a5b457..eb9fe0c8b127b4 100644 --- a/Mathlib/SetTheory/Cardinal/Ordinal.lean +++ b/Mathlib/SetTheory/Cardinal/Ordinal.lean @@ -79,7 +79,7 @@ theorem card_iSup_Iio_le_sum_card {o : Ordinal.{u}} (f : Iio o → Ordinal.{max theorem card_iSup_Iio_le_card_mul_iSup {o : Ordinal.{u}} (f : Iio o → Ordinal.{max u v}) : (⨆ a : Iio o, f a).card ≤ Cardinal.lift.{v} o.card * ⨆ a : Iio o, (f a).card := by apply (card_iSup_Iio_le_sum_card f).trans - convert ← sum_le_lift_mk_mul_iSup _ + convert! ← sum_le_lift_mk_mul_iSup _ · exact mk_toType o · exact ToType.mk.symm.iSup_comp (g := fun x ↦ (f x).card) diff --git a/Mathlib/SetTheory/Cardinal/Regular.lean b/Mathlib/SetTheory/Cardinal/Regular.lean index a1fe9f5349e00d..a21d9ad252adc2 100644 --- a/Mathlib/SetTheory/Cardinal/Regular.lean +++ b/Mathlib/SetTheory/Cardinal/Regular.lean @@ -431,6 +431,9 @@ theorem IsInaccessible.preAleph_ord (hc : IsInaccessible c) : preAleph c.ord = c ((preAleph_le_preBeth _).trans hc.preBeth_ord.le).antisymm (preAleph.strictMono.comp ord_strictMono).le_apply +theorem IsInaccessible.preAleph_symm_eq_ord (hc : IsInaccessible c) : preAleph.symm c = c.ord := by + rw [OrderIso.symm_apply_eq, hc.preAleph_ord] + theorem IsInaccessible.aleph_ord (hc : IsInaccessible c) : ℵ_ c.ord = c := ((aleph_le_beth _).trans hc.beth_ord.le).antisymm (aleph.strictMono.comp ord_strictMono).le_apply @@ -452,6 +455,10 @@ theorem beth_univ : ℶ_ Ordinal.univ.{u, v} = univ.{u, v} := by theorem preAleph_univ : preAleph Ordinal.univ.{u, v} = univ.{u, v} := by simpa using IsInaccessible.univ.preAleph_ord +@[simp] +theorem preAleph_symm_univ : preAleph.symm univ.{u, v} = Ordinal.univ.{u, v} := by + simp [OrderIso.symm_apply_eq] + @[simp] theorem aleph_univ : ℵ_ Ordinal.univ.{u, v} = univ.{u, v} := by simpa using IsInaccessible.univ.aleph_ord diff --git a/Mathlib/SetTheory/Cardinal/Subfield.lean b/Mathlib/SetTheory/Cardinal/Subfield.lean index 695fc393a77e41..cbaec6024adf50 100644 --- a/Mathlib/SetTheory/Cardinal/Subfield.lean +++ b/Mathlib/SetTheory/Cardinal/Subfield.lean @@ -72,7 +72,7 @@ open Cardinal lemma cardinalMk_closure_le_max : #(closure s) ≤ max #s ℵ₀ := (Cardinal.mk_le_of_surjective <| surjective_ofWType s).trans <| by - convert WType.cardinalMk_le_max_aleph0_of_finite' using 1 + convert! WType.cardinalMk_le_max_aleph0_of_finite' using 1 · rw [lift_uzero, mk_sum, lift_uzero] have : lift.{u, 0} #(Fin 6) < ℵ₀ := lift_lt_aleph0.mpr (lt_aleph0_of_finite _) obtain h | h := lt_or_ge #s ℵ₀ diff --git a/Mathlib/SetTheory/Ordinal/Arithmetic.lean b/Mathlib/SetTheory/Ordinal/Arithmetic.lean index d04d39abb922cf..13b50f9694c4cf 100644 --- a/Mathlib/SetTheory/Ordinal/Arithmetic.lean +++ b/Mathlib/SetTheory/Ordinal/Arithmetic.lean @@ -233,7 +233,7 @@ theorem enum_succ_eq_top {o : Ordinal} : theorem has_succ_of_type_succ_lt {α} {r : α → α → Prop} [wo : IsWellOrder α r] (h : ∀ a < type r, succ a < type r) (x : α) : ∃ y, r x y := by use enum r ⟨succ (typein r x), h _ (typein_lt_type r x)⟩ - convert enum_lt_enum.mpr _ + convert! enum_lt_enum.mpr _ · rw [enum_typein] · rw [Subtype.mk_lt_mk, lt_succ_iff] @@ -261,7 +261,7 @@ def pred (o : Ordinal) : Ordinal := theorem pred_add_one (o) : pred (o + 1) = o := isSuccPrelimitRecOn_succ .. --- TODO: deprecate +@[deprecated pred_add_one (since := "2026-05-25")] theorem pred_succ (o) : pred (succ o) = o := pred_add_one o @@ -592,11 +592,11 @@ instance mulRightMono : MulRightMono Ordinal.{u} := · exact Prod.Lex.right _ (f.toRelEmbedding.map_rel_iff.2 h')⟩ theorem le_mul_left (a : Ordinal) {b : Ordinal} (hb : 0 < b) : a ≤ a * b := by - convert mul_le_mul_right (one_le_iff_pos.2 hb) a + convert! mul_le_mul_right (one_le_iff_pos.2 hb) a rw [mul_one a] theorem le_mul_right (a : Ordinal) {b : Ordinal} (hb : 0 < b) : a ≤ b * a := by - convert mul_le_mul_left (one_le_iff_pos.2 hb) a + convert! mul_le_mul_left (one_le_iff_pos.2 hb) a rw [one_mul a] private theorem mul_le_of_limit_aux {α β r s} [IsWellOrder α r] [IsWellOrder β s] {c} @@ -796,7 +796,7 @@ theorem mul_add_div_mul {a c : Ordinal} (hc : c < a) (b d : Ordinal) : · grw [← mul_le_iff_le_div H, mul_assoc, mul_div_le b d, ← le_self_add] theorem mul_div_mul_cancel {a : Ordinal} (ha : a ≠ 0) (b c) : a * b / (a * c) = b / c := by - convert mul_add_div_mul (pos_iff_ne_zero.2 ha) b c using 1 + convert! mul_add_div_mul (pos_iff_ne_zero.2 ha) b c using 1 rw [add_zero] theorem div_eq {a b c : Ordinal} (hle : b * c ≤ a) (hlt : a < b * (c + 1)) : a / b = c := by @@ -938,7 +938,7 @@ theorem mul_add_mod_mul {w x : Ordinal} (hw : w < x) (y z : Ordinal) : theorem mul_mod_mul (x y z : Ordinal) : (x * y) % (x * z) = x * (y % z) := by obtain rfl | hx := eq_zero_or_pos x · simp - · convert mul_add_mod_mul hx y z using 1 <;> + · convert! mul_add_mod_mul hx y z using 1 <;> rw [add_zero] theorem mod_mod_of_dvd (a : Ordinal) {b c : Ordinal} (h : c ∣ b) : a % b % c = a % c := by diff --git a/Mathlib/SetTheory/Ordinal/Basic.lean b/Mathlib/SetTheory/Ordinal/Basic.lean index 3ae32b127dfa6e..1b47dfba3da250 100644 --- a/Mathlib/SetTheory/Ordinal/Basic.lean +++ b/Mathlib/SetTheory/Ordinal/Basic.lean @@ -370,6 +370,17 @@ theorem type_lt_iff {α β} {r : α → α → Prop} {s : β → β → Prop} [I [IsWellOrder β s] : type r < type s ↔ Nonempty (r ≺i s) := Iff.rfl +theorem type_set_le [LinearOrder α] [WellFoundedLT α] (s : Set α) : typeLT s ≤ typeLT α := by + rw [type_le_iff'] + refine ⟨⟨Embedding.subtype _, ?_⟩⟩ + simp + +theorem type_mono [LinearOrder α] [WellFoundedLT α] {s t : Set α} (h : s ⊆ t) : + typeLT s ≤ typeLT t := by + rw [type_le_iff'] + refine ⟨⟨embeddingOfSubset _ _ h, ?_⟩⟩ + aesop + /-- Given two ordinals `α ≤ β`, then `initialSegToType α β` is the initial segment embedding of `α.ToType` into `β.ToType`. -/ @[deprecated type_le_iff (since := "2026-04-12")] diff --git a/Mathlib/SetTheory/Ordinal/Exponential.lean b/Mathlib/SetTheory/Ordinal/Exponential.lean index f43661c24a209a..d33e3d383cfecf 100644 --- a/Mathlib/SetTheory/Ordinal/Exponential.lean +++ b/Mathlib/SetTheory/Ordinal/Exponential.lean @@ -301,7 +301,7 @@ theorem log_zero_right (b : Ordinal) : log b 0 = 0 := by obtain rfl | hb := eq_or_ne b 0 · exact log_zero_left 0 · rw [log] - convert csSup_empty + convert! csSup_empty aesop /-- `opow b` and `log b` (almost) form a Galois connection. @@ -445,7 +445,7 @@ theorem log_opow_mul {b v : Ordinal} (hb : 1 < b) (u : Ordinal) (hv : v ≠ 0) : simpa using log_opow_mul_add hb hv (opow_pos u (bot_lt_of_lt hb)) theorem log_opow {b : Ordinal} (hb : 1 < b) (x : Ordinal) : log b (b ^ x) = x := by - convert log_opow_mul hb x zero_ne_one.symm using 1 + convert! log_opow_mul hb x zero_ne_one.symm using 1 · rw [mul_one] · rw [log_one_right, add_zero] @@ -465,7 +465,7 @@ theorem div_two_opow_log {o : Ordinal} (ho : o ≠ 0) : o / 2 ^ log 2 o = 1 := b · simpa [one_le_iff_ne_zero, pos_iff_ne_zero] using div_opow_log_pos 2 ho theorem two_opow_log_add {o : Ordinal} (ho : o ≠ 0) : 2 ^ log 2 o + o % 2 ^ log 2 o = o := by - convert div_add_mod .. using 2 + convert! div_add_mod .. using 2 rw [div_two_opow_log ho, mul_one] theorem add_log_le_log_mul {x y : Ordinal} (b : Ordinal) (hx : x ≠ 0) (hy : y ≠ 0) : diff --git a/Mathlib/SetTheory/Ordinal/Family.lean b/Mathlib/SetTheory/Ordinal/Family.lean index 28865f56d343f8..748e7cda02fe64 100644 --- a/Mathlib/SetTheory/Ordinal/Family.lean +++ b/Mathlib/SetTheory/Ordinal/Family.lean @@ -665,7 +665,7 @@ set_option linter.deprecated false in @[deprecated "lsub is deprecated" (since := "2026-03-27")] theorem lsub_le_of_range_subset {ι ι'} {f : ι → Ordinal} {g : ι' → Ordinal} (h : Set.range f ⊆ Set.range g) : lsub.{u, max v w} f ≤ lsub.{v, max u w} g := - csSup_le_csSup' bddAbove_of_small (by convert Set.image_mono h <;> apply Set.range_comp) + csSup_le_csSup' bddAbove_of_small (by convert! Set.image_mono h <;> apply Set.range_comp) set_option linter.deprecated false in @[deprecated "lsub is deprecated" (since := "2026-03-27")] @@ -782,7 +782,7 @@ set_option linter.deprecated false in @[deprecated "blsub is deprecated" (since := "2026-03-23")] theorem blsub_le_iff {o : Ordinal.{u}} {f : ∀ a < o, Ordinal.{max u v}} {a} : blsub.{_, v} o f ≤ a ↔ ∀ i h, f i h < a := by - convert bsup_le_iff.{_, v} (f := fun a ha => succ (f a ha)) (a := a) using 2 + convert! bsup_le_iff.{_, v} (f := fun a ha => succ (f a ha)) (a := a) using 2 simp_rw [succ_le_iff] set_option linter.deprecated false in diff --git a/Mathlib/SetTheory/Ordinal/FixedPoint.lean b/Mathlib/SetTheory/Ordinal/FixedPoint.lean index b5f91a07c49ef1..2baa6623a71731 100644 --- a/Mathlib/SetTheory/Ordinal/FixedPoint.lean +++ b/Mathlib/SetTheory/Ordinal/FixedPoint.lean @@ -328,7 +328,7 @@ theorem nfp_eq_self {a} (h : f a = a) : nfp f a = a := /-- The fixed point lemma for normal functions: any normal function has an unbounded set of fixed points. -/ theorem not_bddAbove_fp (H : IsNormal f) : ¬ BddAbove (Function.fixedPoints f) := by - convert not_bddAbove_fp_family fun _ : Unit => H + convert! not_bddAbove_fp_family fun _ : Unit => H exact (Set.iInter_const _).symm /-- The derivative of a normal function `f` is the sequence of fixed points of `f`. @@ -379,7 +379,7 @@ theorem mem_range_deriv (H : IsNormal f) {a} : a ∈ Set.range (deriv f) ↔ f a /-- `Ordinal.deriv` enumerates the fixed points of a normal function. -/ theorem deriv_eq_enumOrd (H : IsNormal f) : deriv f = enumOrd (Function.fixedPoints f) := by - convert derivFamily_eq_enumOrd fun _ : Unit => H + convert! derivFamily_eq_enumOrd fun _ : Unit => H exact (Set.iInter_const _).symm @[deprecated "do not depend on the junk values of `nfp`" (since := "2026-05-13")] diff --git a/Mathlib/SetTheory/Ordinal/FundamentalSequence.lean b/Mathlib/SetTheory/Ordinal/FundamentalSequence.lean index c2247285cf7f62..52271dff07f178 100644 --- a/Mathlib/SetTheory/Ordinal/FundamentalSequence.lean +++ b/Mathlib/SetTheory/Ordinal/FundamentalSequence.lean @@ -111,7 +111,7 @@ end IsFundamentalSeq /-- Every ordinal has a fundamental sequence. -/ theorem exists_isFundamentalSeq (ha : o.cof.ord = a) : ∃ f : Iio a → Iio o, IsFundamentalSeq f := by subst ha - obtain ⟨s, hs, hs'⟩ := ord_cof_eq o.ToType + obtain ⟨s, hs, hs'⟩ := exists_ord_cof_eq o.ToType rw [cof_toType] at hs' let g := (OrderIso.setCongr _ _ (congrArg _ hs'.symm)).trans <| .ofRelIsoLT (enum (α := s) (· < ·)) diff --git a/Mathlib/SetTheory/Ordinal/Principal.lean b/Mathlib/SetTheory/Ordinal/Principal.lean index 7ee3e2edd64876..225bacaf8298d3 100644 --- a/Mathlib/SetTheory/Ordinal/Principal.lean +++ b/Mathlib/SetTheory/Ordinal/Principal.lean @@ -385,7 +385,7 @@ theorem isPrincipal_mul_iff_mul_left_eq : IsPrincipal (· * ·) o ↔ ∀ a, 0 < a → a < o → a * o = o := by refine ⟨fun h a ha₀ hao => ?_, fun h a b hao hbo => ?_⟩ · rcases le_or_gt o 2 with ho | ho - · convert one_mul o + · convert! one_mul o apply le_antisymm · rw [← lt_add_one_iff, one_add_one_eq_two] exact hao.trans_le ho diff --git a/Mathlib/SetTheory/Ordinal/Veblen.lean b/Mathlib/SetTheory/Ordinal/Veblen.lean index 5f3115ba14f3cd..8d6a66f96a7009 100644 --- a/Mathlib/SetTheory/Ordinal/Veblen.lean +++ b/Mathlib/SetTheory/Ordinal/Veblen.lean @@ -510,7 +510,7 @@ theorem invVeblen₂_lt (x : Ordinal) : invVeblen₂ x < ω ^ x := by theorem invVeblen₂_le (x : Ordinal) : invVeblen₂ x ≤ x := by obtain h | h := eq_zero_or_pos (invVeblen₁ x) · rw [invVeblen₂_le_iff, h, veblen_zero] - · convert (invVeblen₂_lt x).le + · convert! (invVeblen₂_lt x).le rw [← veblen_zero_apply, veblen_eq_of_lt_invVeblen₁ h] theorem invVeblen₂_of_lt_opow (h : a < ω ^ a) : invVeblen₂ a = a := by @@ -536,7 +536,7 @@ theorem veblen_eq_opow_iff (h : a < veblen o a) : · rw [← veblen_veblen_of_lt ho, veblen_zero_apply, opow_right_inj one_lt_omega0] rintro rfl simp [invVeblen₁_veblen h, invVeblen₂_veblen ho.ne' h] - · convert ← veblen_invVeblen₁_invVeblen₂ x + · convert! ← veblen_invVeblen₁_invVeblen₂ x /-! ### Epsilon function -/ diff --git a/Mathlib/SetTheory/ZFC/Cardinal.lean b/Mathlib/SetTheory/ZFC/Cardinal.lean index 79322c59496a21..5f95e3b55cae00 100644 --- a/Mathlib/SetTheory/ZFC/Cardinal.lean +++ b/Mathlib/SetTheory/ZFC/Cardinal.lean @@ -57,7 +57,7 @@ theorem card_singleton : card {x} = 1 := by simpa [notMem_singleton] using card_insert (notMem_empty x) theorem card_pair_of_ne (h : x ≠ y) : card {x, y} = 2 := by - convert card_insert (notMem_singleton.2 h) + convert! card_insert (notMem_singleton.2 h) rw [card_singleton, one_add_one_eq_two] theorem card_union_le : card (x ∪ y) ≤ card x + card y := by diff --git a/Mathlib/SetTheory/ZFC/Ordinal.lean b/Mathlib/SetTheory/ZFC/Ordinal.lean index d88a4c560ec4a5..00ccaf89956172 100644 --- a/Mathlib/SetTheory/ZFC/Ordinal.lean +++ b/Mathlib/SetTheory/ZFC/Ordinal.lean @@ -296,7 +296,7 @@ theorem mem_toPSet_iff {o : Ordinal} {x : PSet} : x ∈ o.toPSet ↔ ∃ a < o, theorem rank_toPSet (o : Ordinal) : o.toPSet.rank = o := by rw [toPSet, PSet.rank] conv_rhs => rw [← _root_.iSup_succ o] - convert ToType.mk.symm.iSup_comp (g := fun x ↦ Order.succ x.1.toPSet.rank) + convert! ToType.mk.symm.iSup_comp (g := fun x ↦ Order.succ x.1.toPSet.rank) rw [rank_toPSet] termination_by o decreasing_by rename_i x; exact x.2 diff --git a/Mathlib/SetTheory/ZFC/VonNeumann.lean b/Mathlib/SetTheory/ZFC/VonNeumann.lean index cc09a00eefcb0d..f73eb3413548a4 100644 --- a/Mathlib/SetTheory/ZFC/VonNeumann.lean +++ b/Mathlib/SetTheory/ZFC/VonNeumann.lean @@ -120,7 +120,7 @@ theorem vonNeumann_zero : V_ 0 = ∅ := theorem vonNeumann_add_one (o : Ordinal) : V_ (o + 1) = powerset (V_ o) := ext fun z ↦ by rw [mem_vonNeumann, mem_powerset, subset_vonNeumann, lt_add_one_iff] --- TODO: deprecate +@[deprecated vonNeumann_add_one (since := "2026-05-25")] theorem vonNeumann_succ (o : Ordinal) : V_ (succ o) = powerset (V_ o) := vonNeumann_add_one o @@ -155,7 +155,7 @@ theorem card_vonNeumann (o : Ordinal.{u}) : card (V_ o) = preBeth o := by by_contra! h refine (⨆ i : Set.Iio o, (V_ ↑i).card).card_ord.not_lt <| (Ordinal.card_le_card_vonNeumann _).trans_lt <| (cantor _).trans_le ?_ - rw [← card_powerset, ← vonNeumann_succ] + rw [← card_powerset, ← vonNeumann_add_one] refine le_ciSup bddAbove_of_small (⟨_, ho.succ_lt ?_⟩ : Set.Iio o) exact (ord_card_le _).trans_lt' (ord_strictMono h) diff --git a/Mathlib/Tactic.lean b/Mathlib/Tactic.lean index f127f12741db40..bf34ec4f9fd6bb 100644 --- a/Mathlib/Tactic.lean +++ b/Mathlib/Tactic.lean @@ -178,6 +178,7 @@ public import Mathlib.Tactic.Linter.Lint public import Mathlib.Tactic.Linter.MinImports public import Mathlib.Tactic.Linter.Multigoal public import Mathlib.Tactic.Linter.OldObtain +public import Mathlib.Tactic.Linter.OverlappingInstances public import Mathlib.Tactic.Linter.PPRoundtrip public import Mathlib.Tactic.Linter.PrivateModule public import Mathlib.Tactic.Linter.Style diff --git a/Mathlib/Tactic/ComputeAsymptotics/Lemmas.lean b/Mathlib/Tactic/ComputeAsymptotics/Lemmas.lean index 5fafd73e902048..48065c7c5d6236 100644 --- a/Mathlib/Tactic/ComputeAsymptotics/Lemmas.lean +++ b/Mathlib/Tactic/ComputeAsymptotics/Lemmas.lean @@ -61,7 +61,7 @@ theorem tendsto_nhdsNE_of_tendsto_atTop_nhds_of_eq [TopologicalSpace α] {a b : (h_pos : Tendsto (fun x ↦ f (c + x⁻¹)) atTop (𝓝 b)) (h_eq : a = b) : Tendsto f (𝓝[≠] c) (𝓝 a) := by apply tendsto_nhdsNE_of_tendsto_atTop _ _ h_neg - convert h_pos + convert! h_pos theorem isBigOWith_of_tendsto_top {C : ℝ} {f g : ℝ → ℝ} {l : Filter ℝ} (h : Tendsto (fun x ↦ g x / f x) l atTop) (hC : 0 < C) : diff --git a/Mathlib/Tactic/ComputeAsymptotics/Multiseries/Corecursion.lean b/Mathlib/Tactic/ComputeAsymptotics/Multiseries/Corecursion.lean index dfde0e05295698..3ef27c26e30b22 100644 --- a/Mathlib/Tactic/ComputeAsymptotics/Multiseries/Corecursion.lean +++ b/Mathlib/Tactic/ComputeAsymptotics/Multiseries/Corecursion.lean @@ -135,7 +135,7 @@ theorem dist_cons_cons (x : α) (s t : Seq α) : dist (cons x s) (cons x t) = 2 · contrapose! h' apply_fun Subtype.val using Subtype.val_injective simpa - · convert Nat.find_comp_succ _ _ _ + · convert! Nat.find_comp_succ _ _ _ simp [Stream'.cons] theorem dist_eq_half_of_head {s t : Seq α} (h : s.head = t.head) : @@ -145,7 +145,7 @@ theorem dist_eq_half_of_head {s t : Seq α} (h : s.head = t.head) : set_option backward.isDefEq.respectTransparency false in theorem dist_eq_one_of_head {s t : Seq α} (h : s.head ≠ t.head) : dist s t = 1 := by rw [Subtype.dist_eq, PiNat.dist_eq_of_ne] - · convert pow_zero _ + · convert! pow_zero _ simp only [PiNat.firstDiff, ne_eq, Classical.dite_not, dite_eq_left_iff, Nat.find_eq_zero] intro h' @@ -197,7 +197,7 @@ theorem FriendlyOperation.comp {op op' : Seq α → Seq α} (h : FriendlyOperation op) (h' : FriendlyOperation op') : FriendlyOperation (op ∘ op') := by rw [FriendlyOperation] at h h' ⊢ - convert h.comp h' + convert! h.comp h' simp theorem FriendlyOperation.const {s : Seq α} : FriendlyOperation (fun _ ↦ s) := by diff --git a/Mathlib/Tactic/ComputeAsymptotics/Multiseries/Majorized.lean b/Mathlib/Tactic/ComputeAsymptotics/Multiseries/Majorized.lean index 1df2b486954207..e8f42bca27387e 100644 --- a/Mathlib/Tactic/ComputeAsymptotics/Multiseries/Majorized.lean +++ b/Mathlib/Tactic/ComputeAsymptotics/Multiseries/Majorized.lean @@ -119,7 +119,7 @@ theorem mul_bounded {f g basis_hd : ℝ → ℝ} {exp : ℝ} (hf : Majorized f b (hg : g =O[atTop] (fun _ ↦ (1 : ℝ))) : Majorized (f * g) basis_hd exp := by intro exp h_exp - convert IsLittleO.mul_isBigO (hf _ h_exp) hg using 1 + convert! IsLittleO.mul_isBigO (hf _ h_exp) hg using 1 simp rfl diff --git a/Mathlib/Tactic/Convert.lean b/Mathlib/Tactic/Convert.lean index fef60377422c9a..9d3cf8b7982e5e 100644 --- a/Mathlib/Tactic/Convert.lean +++ b/Mathlib/Tactic/Convert.lean @@ -132,6 +132,8 @@ pattern-matched, like `rintro` would, using the `with` keyword. See also `convert_to t`, where `t` specifies the expected type, instead of a proof term of type `t`. In other words, `convert_to t` works like `convert (?_ : t)`. Both tactics use the same options. +* `convert! e` uses default transparency when solving side goals. This is currently the same + behaviour as `convert`, but `convert` will use reducible transparency in the future. * `convert ← e` creates equality goals in the opposite direction (with the goal type on the right). * `convert e using n`, where `n` is a positive numeral, controls the depth with which congruence is applied. For example, if the main goal is `⊢ Prime (n + n + 1)` and `e : Prime (2 * n + 1)`, then @@ -170,8 +172,16 @@ example (p q : Nat → Prop) (h : ∀ ε > 0, p ε) : sorry ``` -/ -syntax (name := convert) "convert" Lean.Parser.Tactic.optConfig " ←"? ppSpace term (" using " num)? - (" with" (ppSpace colGt rintroPat)*)? : tactic +syntax (name := convert) "convert" "!"? Lean.Parser.Tactic.optConfig " ←"? ppSpace term + (" using " num)? (" with" (ppSpace colGt rintroPat)*)? : tactic + +@[tactic_alt convert] +syntax (name := convert!) "convert!" Lean.Parser.Tactic.optConfig " ←"? ppSpace term + (" using " num)? (" with" (ppSpace colGt rintroPat)*)? : tactic + +macro_rules +| `(tactic| convert! $cfg $[←%$l]? $t $[using $n]? $[with $[$w]*]?) => + `(tactic| convert ! $cfg $[←%$l]? $t:term $[using $n]? $[with $[$w]*]?) /-- Elaborates `term` ensuring the expected type, allowing stuck metavariables. @@ -190,7 +200,7 @@ def elabTermForConvert (term : Syntax) (expectedType? : Option Expr) : return t elab_rules : tactic -| `(tactic| convert $cfg $[←%$sym]? $term $[using $n]? $[with $ps?*]?) => +| `(tactic| convert $[!]? $cfg $[←%$sym]? $term $[using $n]? $[with $ps?*]?) => withMainContext do let config ← Congr!.elabConfig (mkOptionalNode cfg) let patterns := (ps?.getD #[]).toList @@ -211,6 +221,8 @@ pattern-matched, like `rintro` would, using the `with` keyword. `convert e`, where `e` is a term of type `t`, uses `e` to close the new main goal. In other words, `convert e` works like `convert_to t; refine e`. Both tactics use the same options. +* `convert_to! t` uses default transparency when solving side goals. This is currently the same + behaviour as `convert_to`, but `convert_to` will use reducible transparency in the future. * `convert_to ty at h` changes the type of the local hypothesis `h` to `ty`. If later local hypotheses or the goal depend on `h`, then `convert_to t at h` may leave a copy of `h`. * `convert_to ← t` creates equality goals in the opposite direction (with the original goal type on @@ -226,14 +238,22 @@ pattern-matched, like `rintro` would, using the `with` keyword. * `convert_to (config := cfg) t` uses the configuration options in `cfg` to control the congruence rules (see `Congr!.Config`). -/ -syntax (name := convertTo) "convert_to" (Parser.Tactic.config)? " ←"? ppSpace term (" using " num)? - (" with" (ppSpace colGt rintroPat)*)? (Parser.Tactic.location)? : tactic +syntax (name := convertTo) "convert_to" Lean.Parser.Tactic.optConfig " ←"? ppSpace term + (" using " num)? (" with" (ppSpace colGt rintroPat)*)? (Parser.Tactic.location)? : tactic + +@[tactic_alt convertTo] +syntax (name := convert_to!) "convert_to!" Lean.Parser.Tactic.optConfig " ←"? ppSpace term + (" using " num)? (" with" (ppSpace colGt rintroPat)*)? (Parser.Tactic.location)? : tactic + +macro_rules +| `(tactic| convert_to! $cfg $[←%$l]? $t $[using $n]? $[with $w]? $[$loc]?) => + `(tactic| convert_to $cfg $[←%$l]? $t:term $[using $n]? $[with $w]? $[$loc]?) elab_rules : tactic -| `(tactic| convert_to $[$cfg:config]? $[←%$sym]? $newType $[using $n]? +| `(tactic| convert_to $cfg $[←%$sym]? $newType $[using $n]? $[with $ps?*]? $[$loc?:location]?) => do let n : ℕ := n |>.map (·.getNat) |>.getD 1 - let config ← Congr!.elabConfig (mkOptionalNode cfg) + let config ← Congr!.elabConfig cfg let patterns := (ps?.getD #[]).toList withLocation (expandOptLocation (mkOptionalNode loc?)) (atLocal := fun fvarId ↦ do @@ -259,6 +279,8 @@ into new goals, using the hole's name, if any, as the goal case name. Like `congr!`, `convert_to` introduces variables while applying congruence rules. These can be pattern-matched, like `rintro` would, using the `with` keyword. +* `ac_change! t` uses default transparency when solving side goals. This is currently the same + behaviour as `ac_change`, but `ac_change` will use reducible transparency in the future. * `ac_change t using n`, where `n` is a positive numeral, controls the depth with which congruence is applied. For example, if the main goal is `⊢ Prime ((a * b + 1) + c)`, then `ac_change Prime ((1 + a * b) + c) using 2` solves the side goals, and @@ -274,8 +296,14 @@ example (a b c d e f g N : ℕ) : (a + b) + (c + d) + (e + f) + g ≤ N := by ``` -/ syntax (name := acChange) "ac_change " term (" using " num)? : tactic +@[tactic_alt acChange] +syntax (name := acChange!) "ac_change! " term (" using " num)? : tactic macro_rules -| `(tactic| ac_change $t $[using $n]?) => `(tactic| convert_to $t:term $[using $n]? <;> try ac_rfl) +| `(tactic| ac_change $t $[using $n]?) => + `(tactic| convert_to $t:term $[using $n]? <;> try ac_rfl) +| `(tactic| ac_change! $t $[using $n]?) => + `(tactic| convert_to! $t:term $[using $n]? <;> try ac_rfl) + end Mathlib.Tactic diff --git a/Mathlib/Tactic/Linter/DirectoryDependency.lean b/Mathlib/Tactic/Linter/DirectoryDependency.lean index c3e7f66e5c96bf..39d6bd05085bbe 100644 --- a/Mathlib/Tactic/Linter/DirectoryDependency.lean +++ b/Mathlib/Tactic/Linter/DirectoryDependency.lean @@ -224,6 +224,8 @@ def allowedImportDirs : NamePrefixRel := .ofArray #[ -- For more fine-grained exceptions of the next two imports, one needs to rename that file. (`Mathlib.Tactic.Linter, `ImportGraph), (`Mathlib.Tactic.Linter, `Mathlib.Tactic.MinImports), + (`Mathlib.Tactic.Linter.OverlappingInstances, `Mathlib.Lean.ContextInfo), + (`Mathlib.Tactic.Linter.OverlappingInstances, `Mathlib.Lean.Elab.Tactic.Meta), (`Mathlib.Tactic.Linter.TextBased, `Mathlib.Data.Nat.Notation), (`Mathlib.Tactic.Linter.UnusedInstancesInType, `Mathlib.Lean.Expr.Basic), (`Mathlib.Tactic.Linter.UnusedInstancesInType, `Mathlib.Lean.Environment), diff --git a/Mathlib/Tactic/Linter/OverlappingInstances.lean b/Mathlib/Tactic/Linter/OverlappingInstances.lean new file mode 100644 index 00000000000000..4bfd16a8ee01df --- /dev/null +++ b/Mathlib/Tactic/Linter/OverlappingInstances.lean @@ -0,0 +1,236 @@ +/- +Copyright (c) 2026 Jovan Gerbscheid. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Jovan Gerbscheid, Thomas R. Murrills +-/ +module + +public meta import Lean.Elab.Command +public meta import Mathlib.Lean.ContextInfo +public meta import Batteries.Lean.Position +public meta import Mathlib.Tactic.Linter.UnusedInstancesInType + +/-! +# A linter for declarations with local instances that overlap + +If the same data can be obtained from two different instances, we risk having +non-defeq versions of that data. This situation is known as an "instance diamond". +This linter warns against instance diamonds in local contexts. + +This is a syntax linter. It is run on partially and fully elaborated declarations. + +To find diamonds, we compute the parent classes of each local instance. +For classes that aren't structures, this is just the class itself. +If any of these parent classes is duplicated, we throw a warning. + +This linter also warns on redundant proposition classes, i.e. those that can be synthesized from +the other instances in the local context. (Note: we do *not* warn on proposition classes that +merely overlap.) Even though redundant proposition classes cause no meaningful issue, they are +still undesirable. + +A common case where this linter may fire is if the same type class assumption is given in both a +`variable` statement and a declaration. This kind of variable shadowing does not actually produce +declarations with duplicate type class assumptions, but it is still not desirable. + + +## TODO + +Support declarations without bodies (`structure`s/`class`es/`inductive`s etc.) + +-/ + +open Lean Meta Elab Command + +meta section + +namespace Mathlib.Linter.OverlappingInstances + +/-- Clear the instances from the given application. +This is used to deal with classes that have instance parameters. +For example, if you have a local instance of `ContinuousAdd α` and `IsTopologicalAddGroup α`, +then the two `ContinuousAdd α` instances may have slightly different `[Add α]` arguments. -/ +def eraseInstances (e : Expr) : MetaM Expr := do + e.withApp fun f args ↦ do + let finfo ← getFunInfo f + let mut args := args + for param in finfo.paramInfo, i in *...args.size do + if param.binderInfo.isInstImplicit then + args := args.set! i default + return mkAppN f args + +/-- Compute the parent classes of `cls`, excluding parent classes that have a parent themselves. +The reason to exclude such classes is that if there is a duplication in such a class, +then there will necessarily also be a duplication in its parent. +If `cls` carries data, then only consider parents that carry data. +If `cls` is a non-structure class, this simply returns `#[cls]`. + +The resulting expressions contain bound variables that correspond to the parameters of `cls`. +The universe levels and bound variables need to be instantiated to get concrete data projections. -/ +partial def getAbstractProjections (cls : Name) : CoreM (Array Expr) := do + let cinfo ← getConstInfo cls + MetaM.run' <| forallTelescope cinfo.type fun xs type ↦ do + withLocalDeclD `self (mkAppN (.const cls (cinfo.levelParams.map .param)) xs) fun inst ↦ do + go cls inst #[] xs type.isProp |>.run' {} +where + go (cls : Name) (inst : Expr) (acc : Array Expr) (xs : Array Expr) (isProp : Bool) : + StateRefT NameSet MetaM (Array Expr) := do + let type ← whnf (← inferType inst) + let mut acc := acc + let mut anyParent := false + if let some info := getStructureInfo? (← getEnv) cls then + let .const _ us := type.getAppFn | panic! s!"`{inst} is not an instance" + for info in info.parentInfo do + let parent := info.structName + if (← get).contains parent then continue + modify (·.insert parent) + unless ← isInstance info.projFn do continue + let isProp' := (← getConstInfo parent).type.getForallBody.isProp + let proj := Expr.app (mkAppN (.const info.projFn us) type.getAppArgs) inst + acc ← go parent proj acc xs isProp' + -- When projecting from a data-carrying class to a `Prop` class, + -- we record the data-carrying class. This helps with determining which overlaps have data. + unless !isProp && isProp' do + anyParent := true + if !anyParent then + acc := acc.push (← eraseInstances (type.abstract xs)) + return acc + +/-- A cache for the result of `getAbstractDataProjections`. -/ +initialize classProjectionsCache : IO.Ref (NameMap (Array Expr)) ← IO.mkRef {} + +/-- Return the result of `getAbstractDataProjections`, using a global cache. +To ensure soundness, the cache is only used for imported declarations. -/ +def getAbstractProjectionsCached (cls : Name) : CoreM (Array Expr) := do + if (← getEnv).isImportedConst cls then + if let some result := (← classProjectionsCache.get).find? cls then + return result + let result ← getAbstractProjections cls + classProjectionsCache.modify (·.insert cls result) + return result + else + getAbstractProjections cls + +/-- Find classes for which multiple different instances can be synthesized in the local context. +The result maps classes to the (at least 2) local instances that generate them. -/ +partial def findOverlappingInstances : MetaM (ExprMap (Array FVarId)) := do + -- Maps a class to the collection of local instances that overlap on it. + -- This only includes overlaps of at least 2 local instances. + let mut overlaps : ExprMap (Array FVarId) := {} + -- Maps a class to the first local instance that produces an instance of it. + let mut encountered : ExprMap FVarId := {} + for decl in ← getLCtx do + if decl.binderInfo.isInstImplicit then + let type ← instantiateMVars decl.type + let projClasses ← forallTelescopeReducing (whnfType := true) type fun xs type ↦ do + type.withApp fun f args ↦ do + let .const cls us := f | + return #[] -- This can happen when using `set_option checkBinderAnnotations false` + let levelParams := (← getConstInfo cls).levelParams + let projs ← getAbstractProjectionsCached cls + projs.mapM fun proj ↦ + mkForallFVars xs <| (proj.instantiateLevelParams levelParams us).instantiateRev args + for projCls in projClasses do + if let some fvarId' := encountered[projCls]? then + overlaps := overlaps.alter projCls (·.getD #[fvarId'] |>.push decl.fvarId) + else + encountered := encountered.insert projCls decl.fvarId + return overlaps + +/-- Lints against overlaps between instances in the local contexts of declarations. -/ +register_option linter.overlappingInstances : Bool := { + defValue := true + descr := "enable the overlapping instances linter." +} + +/-- Report a warning message if there are any overlapping instances in the local context. +For `Prop` instances, only report local instances that are redundant. -/ +def runLinter (ctx : ContextInfo) (lctx : LocalContext) (expectedType? : Option Expr) : + IO (Option MessageData) := do + ctx.runMetaM lctx do + -- Add the hypotheses of the expected type to the local context, as it may have more instances. + expectedType?.elim id (forallTelescope · fun _ _ => ·) do + let overlaps ← findOverlappingInstances + if overlaps.isEmpty then + return none + -- Sort the suggestions in a (somewhat) deterministic way. + let overlaps := overlaps.toArray.qsort (·.1.lt ·.1) + let sortedOverlaps : Std.HashMap (Array FVarId) (Array Expr) := + overlaps.foldl (init := {}) fun s (overlap, fvars) ↦ s.alter fvars (·.getD #[] |>.push overlap) + let sortedOverlaps := sortedOverlaps.toArray.qsort (Array.lex ·.2 ·.2 Expr.lt) + let mut msgs := #[] + let mut needsDiamondMsg := false + for (fvars, overlaps) in sortedOverlaps do + let fvarTypes ← fvars.mapM (do instantiateMVars <| ← ·.getType) + -- If the overlapping instances are the same, use a simple message. + if fvarTypes.all (· == fvarTypes[0]!) then + msgs := msgs.push <| + m!"There are {fvarTypes.size} `{.sbracket fvarTypes[0]!}` instances; one is sufficient." + else + let propOverlap ← overlaps.allM isProp + unless propOverlap do + needsDiamondMsg := true + -- Ignore `Prop` overlaps when data conflicts are present. + let overlaps ← if propOverlap then pure overlaps else overlaps.filterM (notM <| isProp ·) + let localInsts := (← getLCtx).decls.toList.reduceOption + -- Otherwise, figure out which instances can be synthesized from the other instances + let mut redundant := #[] + for fvar in fvars, type in fvarTypes do + let localInsts := localInsts.filter (·.fvarId != fvar) + if (← withLocalInstances localInsts (trySynthInstance type)) matches .some _ then + redundant := redundant.push type + -- For `Prop` overlaps, only warn if there is an instance that can be removed. + if propOverlap && redundant.isEmpty then + continue + let fvarTypes := .andList <| fvarTypes.toList.map (m!"`{.sbracket ·}`") + let overlaps := .andList <| overlaps.toList.map (m!"`{.sbracket ·}`") + let mut msg := + m!"{fvarTypes} {if propOverlap then "each imply" else + "can be used to infer conflicting versions of"} {overlaps}." + unless redundant.isEmpty do + let redundant' := .andList <| redundant.toList.map (m!"`{.sbracket ·}`") + msg := m!"{msg}\n💡️ Of these, {redundant'} may be removed." + msgs := msgs.push msg + if msgs.isEmpty then + return none + let inDecl ← if let some decl := ctx.parentDecl? then + pure m!" in `{← addMessageContextPartial (.ofConstName decl)}`" else pure "" + let mut msg := m!"Overlapping instance parameters{inDecl}:\n" + for overlapMsg in msgs do + msg := msg ++ m!"\n⚠️ {overlapMsg}" + if needsDiamondMsg then + msg := msg ++ m!"\n\n\ + When a data-carrying type class has multiple potential instances coming from different \ + instance parameters, then these potential instances are incompatible. This is an example of \ + an \"instance diamond\", which leads to unexpected unification failures.\ + \n\n\ + Delete or combine some of your instance parameters to avoid this." + addMessageContextFull msg + +initialize registerTraceClass `overlappingInstances + +open Linter in +/-- +Lints against data-carrying overlaps between instances in the local contexts of declarations. +-/ +def overlappingInstances : Linter where + run := UnusedInstancesInType.withSetBoolOptionIn fun cmd => do + unless getLinterValue linter.overlappingInstances (← getLinterOptions) do + return + -- Note: we don't break on errors; we want to lint even on partial declarations + profileitM Exception "overlappingInstancesLinter" (← getOptions) do + for t in ← getInfoTrees do + for (ref, ctx, info) in t.getDeclBodyInfos do + let some (lctx, expectedType?) := info.getLCtx? | pure () + withTraceNode `overlappingInstances + (fun _ ↦ return m!"linting `{.ofConstName <| ctx.parentDecl?.getD .anonymous}`") do + let some msg ← runLinter ctx lctx expectedType? | pure () + /- Log the warning from the declaration's selection range (usually the declaration name, + or `instance`) to the body if possible. This underlines the hypotheses and type, + and makes the warning visible in the infoview when the cursor is within the body. -/ + let declRange? ← ctx.parentDecl?.bindM findDeclarationSyntaxRange? + let ref := declRange?.elim ref (mkNullNode #[.ofRange ·, ref]) + logLint linter.overlappingInstances ref msg + +initialize addLinter overlappingInstances + +end Mathlib.Linter.OverlappingInstances diff --git a/Mathlib/Tactic/Linter/Style.lean b/Mathlib/Tactic/Linter/Style.lean index 28e1aeff5fc333..4c2c6c8f776b88 100644 --- a/Mathlib/Tactic/Linter/Style.lean +++ b/Mathlib/Tactic/Linter/Style.lean @@ -529,7 +529,7 @@ by the `defsWithUnderscore` linter. Namely, we do not lint * names containing guillemets `«»` (these tend to be `term` declarations, i.e. internal names for notation, not user-facing commands), * names with a component starting with `term` (e.g. `Nat.term_!`) -* names starting with `Mathlib.Tactic`, `Mathlib.Parser` or containing a `Simps` component +* names starting with `Mathlib.Tactic`, `Parser` or containing a `Simps` component (these are probably custom simps projections, i.e. affect how `simps` names its auto-generated lemmas: we usually prefer a generated name `coe_support` over `coeSupport`, which requires a projection named `coe_support`) @@ -543,7 +543,7 @@ public def isBadNameWithUnderscore (name : Name) : Bool := Id.run do if last.endsWith '_' || s.contains '«' || declName.components.any (·.toString.startsWith "term") || (`LibraryNote).isPrefixOf declName || - (`Mathlib.Tactic).isPrefixOf declName || (`Mathlib.Parser).isPrefixOf declName || + (`Mathlib.Tactic).isPrefixOf declName || (`Parser).isPrefixOf declName || declName.components.any (· == `Simps) || last.endsWith "_1" || last.endsWith "_2" || last.endsWith "_mathlib" || declName.components.any (·.toString.endsWith '_') then diff --git a/Mathlib/Tactic/Linter/TextBased.lean b/Mathlib/Tactic/Linter/TextBased.lean index 1e98722a0e0929..56ffb83a679f78 100644 --- a/Mathlib/Tactic/Linter/TextBased.lean +++ b/Mathlib/Tactic/Linter/TextBased.lean @@ -361,11 +361,13 @@ def findBadUnicodeAux (s : String) (pos : s.Pos) (c : Char) if ! isAllowedCharacter c then -- bad: character not allowed. findBadUnicodeAux s posₙ cₙ (err.push (.unwantedUnicode c)) - else if cₙ == UnicodeVariant.emoji && !(emojis.contains c) then + else if cₙ == UnicodeVariant.emoji && !(emojis.contains c) && !(unrestricted.contains c) then -- bad: unwanted emoji variant selector. let errₙ := err.push (.unicodeVariant (String.ofList [c, cₙ]) none) findBadUnicodeAux s posₙ cₙ errₙ - else if cₙ == UnicodeVariant.text && !(nonEmojis.contains c) then + else if + cₙ == UnicodeVariant.text && !(nonEmojis.contains c) && !(unrestricted.contains c) + then -- bad: unwanted text variant selector. let errₙ := err.push (.unicodeVariant (String.ofList [c, cₙ]) none) findBadUnicodeAux s posₙ cₙ errₙ diff --git a/Mathlib/Tactic/Linter/TextBased/UnicodeLinter.lean b/Mathlib/Tactic/Linter/TextBased/UnicodeLinter.lean index b4b7a8b9e8c9e3..560c29f09cb792 100644 --- a/Mathlib/Tactic/Linter/TextBased/UnicodeLinter.lean +++ b/Mathlib/Tactic/Linter/TextBased/UnicodeLinter.lean @@ -186,10 +186,19 @@ public def emojis : Array Char := #[ /-- Unicode symbols in mathlib that should always be followed by the text variant selector. -/ public def nonEmojis : Array Char := #[] +/-- Unicode symbols in mathlib that have no restrictions on whether they are followed by a selector +or which selector they are followed by. -/ +public def unrestricted : Array Char := #[ + '⚠' -- ⚠️, ⚠. Lake output uses '⚠' and does not include the text selector. +] + /-- If `false`, the character is not allowed in Mathlib. Implemented using an allowlist consisting of: - certain ASCII characters +- certain emojis (`emojis`) +- certain non-emoji variants of emojifiable characters (`nonEmojis`) +- certain characters with no selector restrictions (`unrestricted`) - characters with abbreviations in the VSCode extension (`withVSCodeAbbrev`) - "the rest" (`othersInMathlib`) @@ -202,6 +211,7 @@ public def isAllowedCharacter (c : Char) : Bool := || othersInMathlib.contains c || emojis.contains c || nonEmojis.contains c + || unrestricted.contains c || c == UnicodeVariant.emoji || c == UnicodeVariant.text diff --git a/Mathlib/Tactic/Linter/UnusedInstancesInType.lean b/Mathlib/Tactic/Linter/UnusedInstancesInType.lean index 2f260cdd2459de..72e03512cdafc3 100644 --- a/Mathlib/Tactic/Linter/UnusedInstancesInType.lean +++ b/Mathlib/Tactic/Linter/UnusedInstancesInType.lean @@ -285,7 +285,7 @@ def isDecidableVariant (type : Expr) : Bool := /-- `withSetOptionIn` currently breaks infotree searches, so we simply set `Bool` options until this is fixed in [lean4#11313](https://github.com/leanprover/lean4/pull/11313). -/ -partial def withSetBoolOptionIn (x : CommandElab) : CommandElab +public partial def withSetBoolOptionIn (x : CommandElab) : CommandElab | `(command| set_option $opt:ident $val in $cmd:command) => do match val.raw with | Syntax.atom _ "true" => diff --git a/Mathlib/Tactic/NormNum/Ineq.lean b/Mathlib/Tactic/NormNum/Ineq.lean index 99571399a7cec0..74518ce20e9761 100644 --- a/Mathlib/Tactic/NormNum/Ineq.lean +++ b/Mathlib/Tactic/NormNum/Ineq.lean @@ -89,7 +89,7 @@ theorem isNNRat_le_true [Semiring α] [LinearOrder α] [IsStrictOrderedRing α] simp only [Nat.mul_eq, Nat.cast_mul, mul_invOf_cancel_right'] at h rwa [Nat.commute_cast] at h -theorem isNNRat_lt_true [Semiring α] [LinearOrder α] [IsStrictOrderedRing α] [Nontrivial α] : +theorem isNNRat_lt_true [Semiring α] [LinearOrder α] [IsStrictOrderedRing α] : {a b : α} → {na nb : ℕ} → {da db : ℕ} → IsNNRat a na da → IsNNRat b nb db → decide (na * db < nb * da) → a < b | _, _, _, _, da, db, ⟨_, rfl⟩, ⟨_, rfl⟩, h => by @@ -101,7 +101,7 @@ theorem isNNRat_lt_true [Semiring α] [LinearOrder α] [IsStrictOrderedRing α] simp? at h says simp only [Nat.cast_mul, mul_invOf_cancel_right'] at h rwa [Nat.commute_cast] at h -theorem isNNRat_le_false [Semiring α] [LinearOrder α] [IsStrictOrderedRing α] [Nontrivial α] +theorem isNNRat_le_false [Semiring α] [LinearOrder α] [IsStrictOrderedRing α] {a b : α} {na nb : ℕ} {da db : ℕ} (ha : IsNNRat a na da) (hb : IsNNRat b nb db) (h : decide (nb * da < na * db)) : ¬a ≤ b := not_le_of_gt (isNNRat_lt_true hb ha h) @@ -125,7 +125,7 @@ theorem isRat_le_true [Ring α] [LinearOrder α] [IsStrictOrderedRing α] : mul_invOf_cancel_right'] at h rwa [Int.commute_cast] at h -theorem isRat_lt_true [Ring α] [LinearOrder α] [IsStrictOrderedRing α] [Nontrivial α] : +theorem isRat_lt_true [Ring α] [LinearOrder α] [IsStrictOrderedRing α] : {a b : α} → {na nb : ℤ} → {da db : ℕ} → IsRat a na da → IsRat b nb db → decide (na * db < nb * da) → a < b | _, _, _, _, da, db, ⟨_, rfl⟩, ⟨_, rfl⟩, h => by @@ -137,7 +137,7 @@ theorem isRat_lt_true [Ring α] [LinearOrder α] [IsStrictOrderedRing α] [Nontr simp? at h says simp only [Int.cast_mul, Int.cast_natCast, mul_invOf_cancel_right'] at h rwa [Int.commute_cast] at h -theorem isRat_le_false [Ring α] [LinearOrder α] [IsStrictOrderedRing α] [Nontrivial α] +theorem isRat_le_false [Ring α] [LinearOrder α] [IsStrictOrderedRing α] {a b : α} {na nb : ℤ} {da db : ℕ} (ha : IsRat a na da) (hb : IsRat b nb db) (h : decide (nb * da < na * db)) : ¬a ≤ b := not_le_of_gt (isRat_lt_true hb ha h) diff --git a/Mathlib/Tactic/NormNum/NatFactorial.lean b/Mathlib/Tactic/NormNum/NatFactorial.lean index d0cbe76f5eb0ef..e7bb3afd199ae7 100644 --- a/Mathlib/Tactic/NormNum/NatFactorial.lean +++ b/Mathlib/Tactic/NormNum/NatFactorial.lean @@ -55,7 +55,7 @@ partial def proveAscFactorial (n l : ℕ) (en el : Q(ℕ)) : let ⟨b, eb, b_prf⟩ := proveAscFactorial (n + m) r enm er have eab : Q(ℕ) := mkRawNatLit (a * b) have : $eab =Q $ea * $eb := ⟨⟩ - ⟨a * b, eab, q(by convert asc_factorial_aux $en $em $er $ea $eb $a_prf $b_prf)⟩ + ⟨a * b, eab, q(by convert! asc_factorial_aux «$en» «$em» «$er» «$ea» «$eb» «$a_prf» «$b_prf»)⟩ lemma isNat_factorial {n x : ℕ} (h₁ : IsNat n x) (a : ℕ) (h₂ : (1).ascFactorial x = a) : IsNat (n !) a := by diff --git a/Mathlib/Tactic/Order.lean b/Mathlib/Tactic/Order.lean index d1e345e9d657aa..13c651aa8dc57f 100644 --- a/Mathlib/Tactic/Order.lean +++ b/Mathlib/Tactic/Order.lean @@ -5,6 +5,7 @@ Authors: Vasilii Nesterov -/ module +public meta import Lean.Elab.Tactic.Omega public meta import Mathlib.Tactic.Order.CollectFacts public meta import Mathlib.Tactic.Order.Graph.Basic public import Mathlib.Tactic.ByContra diff --git a/Mathlib/Tactic/Ring/Basic.lean b/Mathlib/Tactic/Ring/Basic.lean index 6ec66234017a0c..2cb699521c625b 100644 --- a/Mathlib/Tactic/Ring/Basic.lean +++ b/Mathlib/Tactic/Ring/Basic.lean @@ -357,8 +357,7 @@ theorem Nat.smul_eq_mul {n n' : ℕ} {r : R} (hr : n = r) (hn : n' = n) (a : R) subst_vars simp only [nsmul_eq_mul] -omit [CommSemiring R] in -theorem Int.smul_eq_mul {n n' : ℤ} {r : R} [CommRing R] (hr : n = r) (hn : n' = n) (a : R) : +theorem Int.smul_eq_mul {R} {n n' : ℤ} {r : R} [CommRing R] (hr : n = r) (hn : n' = n) (a : R) : n' • a = r * a := by subst_vars simp only [zsmul_eq_mul] diff --git a/Mathlib/Topology/Algebra/Algebra.lean b/Mathlib/Topology/Algebra/Algebra.lean index 9ace4389aa5b0f..d735a9f8763010 100644 --- a/Mathlib/Topology/Algebra/Algebra.lean +++ b/Mathlib/Topology/Algebra/Algebra.lean @@ -609,7 +609,7 @@ theorem Subalgebra.le_topologicalClosure (s : Subalgebra R A) : s ≤ s.topologi subset_closure theorem Subalgebra.isClosed_topologicalClosure (s : Subalgebra R A) : - IsClosed (s.topologicalClosure : Set A) := by convert @isClosed_closure A _ s + IsClosed (s.topologicalClosure : Set A) := by convert! @isClosed_closure A _ s theorem Subalgebra.topologicalClosure_minimal {s t : Subalgebra R A} (h : s ≤ t) (ht : IsClosed (t : Set A)) : s.topologicalClosure ≤ t := diff --git a/Mathlib/Topology/Algebra/Category/ProfiniteGrp/Limits.lean b/Mathlib/Topology/Algebra/Category/ProfiniteGrp/Limits.lean index eb5eeed67da128..8c314bc61cabf3 100644 --- a/Mathlib/Topology/Algebra/Category/ProfiniteGrp/Limits.lean +++ b/Mathlib/Topology/Algebra/Category/ProfiniteGrp/Limits.lean @@ -73,7 +73,7 @@ lemma toLimitFun_continuous (P : ProfiniteGrp.{u}) : Continuous (toLimitFun P) : intro s _ rw [← (Set.biUnion_preimage_singleton QuotientGroup.mk s)] refine isOpen_iUnion (fun i ↦ isOpen_iUnion (fun _ ↦ ?_)) - convert IsOpen.leftCoset H.toOpenSubgroup.isOpen' (Quotient.out i) + convert! IsOpen.leftCoset H.toOpenSubgroup.isOpen' (Quotient.out i) ext x simp only [Set.mem_preimage, Set.mem_singleton_iff] nth_rw 1 [← QuotientGroup.out_eq' i, eq_comm, QuotientGroup.eq] diff --git a/Mathlib/Topology/Algebra/ConstMulAction.lean b/Mathlib/Topology/Algebra/ConstMulAction.lean index 72020ad7c9d75f..0ebae3e977eda3 100644 --- a/Mathlib/Topology/Algebra/ConstMulAction.lean +++ b/Mathlib/Topology/Algebra/ConstMulAction.lean @@ -470,7 +470,7 @@ nonrec theorem smul_mem_nhds_smul_iff (hc : IsUnit c) {s : Set α} {a : α} : theorem isQuotientMap_smul {S β} [SMul S M] [SMul S α] [IsScalarTower S M α] [SMul S β] (f : α →[S] β) [TopologicalSpace β] (hf : IsQuotientMap f) (c : S) (hc : IsUnit (c • 1 : M)) : IsQuotientMap (c • · : β → β) := - hf.of_comp_isQuotientMap <| by convert hf.comp hc.isHomeomorph_smul.isQuotientMap; ext; simp + hf.of_comp_isQuotientMap <| by convert! hf.comp hc.isHomeomorph_smul.isQuotientMap; ext; simp theorem isQuotientMap_nsmul {M β} [Semiring M] [AddCommMonoid α] [Module M α] [ContinuousConstSMul M α] [AddMonoid β] (f : α →+ β) [TopologicalSpace β] @@ -542,7 +542,7 @@ variable [T2Space T] [LocallyCompactSpace T] [ContinuousConstSMul Γ T] (x : T) @[to_additive] lemma ProperlyDiscontinuousSMul.exists_nhds_disjoint_image : ∃ U ∈ 𝓝 x, ∀ γ : Γ, γ • x ≠ x → Disjoint ((γ • ·) '' U) U := by - convert exists_nhds_image_smul_eq_self Γ x using 4 + convert! exists_nhds_image_smul_eq_self Γ x using 4 rw [← not_imp_not] simp [Set.not_disjoint_iff_nonempty_inter] diff --git a/Mathlib/Topology/Algebra/ContinuousMonoidHom.lean b/Mathlib/Topology/Algebra/ContinuousMonoidHom.lean index a7d19908ba5858..19e62997f3e074 100644 --- a/Mathlib/Topology/Algebra/ContinuousMonoidHom.lean +++ b/Mathlib/Topology/Algebra/ContinuousMonoidHom.lean @@ -141,11 +141,11 @@ theorem ext {f g : A →ₜ* B} (h : ∀ x, f x = g x) : f = g := @[to_additive] theorem toContinuousMap_injective : Injective (toContinuousMap : _ → C(A, B)) := fun f g h => - ext <| by convert DFunLike.ext_iff.1 h + ext <| by convert! DFunLike.ext_iff.1 h @[to_additive] theorem toMonoidHom_injective : Injective (toMonoidHom : _ → A →* B) := fun f g h => - ext <| by convert DFunLike.ext_iff.1 h + ext <| by convert! DFunLike.ext_iff.1 h /-- Composition of two continuous homomorphisms. -/ @[to_additive (attr := simps!) /-- Composition of two continuous homomorphisms. -/] @@ -524,8 +524,8 @@ variable {L : Type*} [Mul L] [TopologicalSpace L] @[to_additive /-- The composition of two ContinuousAddEquiv. -/] def trans (cme1 : M ≃ₜ* N) (cme2 : N ≃ₜ* L) : M ≃ₜ* L where __ := cme1.toMulEquiv.trans cme2.toMulEquiv - continuous_toFun := by convert Continuous.comp cme2.continuous_toFun cme1.continuous_toFun - continuous_invFun := by convert Continuous.comp cme1.continuous_invFun cme2.continuous_invFun + continuous_toFun := by convert! Continuous.comp cme2.continuous_toFun cme1.continuous_toFun + continuous_invFun := by convert! Continuous.comp cme1.continuous_invFun cme2.continuous_invFun @[to_additive (attr := simp)] theorem coe_trans (e₁ : M ≃ₜ* N) (e₂ : N ≃ₜ* L) : ↑(e₁.trans e₂) = e₂ ∘ e₁ := rfl @@ -594,7 +594,7 @@ lemma toMulEquiv_toContinuousMulEquiv : (e.toContinuousMulEquiv he : G ≃* H) = @[to_additive] lemma symm_toContinuousMulEquiv : (e.toContinuousMulEquiv he).symm = e.symm.toContinuousMulEquiv - (fun s ↦ by convert (he _).symm; exact (e.preimage_symm_preimage s).symm) := + (fun s ↦ by convert! (he _).symm; exact (e.preimage_symm_preimage s).symm) := rfl end MulEquiv diff --git a/Mathlib/Topology/Algebra/Group/Basic.lean b/Mathlib/Topology/Algebra/Group/Basic.lean index 9348c7d88a3bf6..6b132b67820f16 100644 --- a/Mathlib/Topology/Algebra/Group/Basic.lean +++ b/Mathlib/Topology/Algebra/Group/Basic.lean @@ -96,7 +96,7 @@ theorem IsClosed.leftCoset {U : Set G} (h : IsClosed U) (x : G) : IsClosed (x @[to_additive (attr := simp)] theorem Filter.map_mul_left_nhdsNE {c a : G} : map (c * ·) (𝓝[≠] a) = (𝓝[≠] (c * a)) := by - convert (Homeomorph.mulLeft c).isEmbedding.map_nhdsWithin_eq .. using 2 + convert! (Homeomorph.mulLeft c).isEmbedding.map_nhdsWithin_eq .. using 2 simp /-- Multiplication from the right in a topological group as a homeomorphism. -/ @@ -132,7 +132,7 @@ theorem IsClosed.rightCoset {U : Set G} (h : IsClosed U) (x : G) : IsClosed (op @[to_additive (attr := simp)] theorem Filter.map_mul_right_nhdsNE {c a : G} : map (· * c) (𝓝[≠] a) = (𝓝[≠] (a * c)) := by - convert (Homeomorph.mulRight c).isEmbedding.map_nhdsWithin_eq .. using 2 + convert! (Homeomorph.mulRight c).isEmbedding.map_nhdsWithin_eq .. using 2 simp @[to_additive] @@ -159,13 +159,13 @@ theorem totallyDisconnectedSpace_iff_connectedComponent_one : lemma Filter.tendsto_mul_const_iff (b : G) {c : G} {f : α → G} {l : Filter α} : Tendsto (f · * b) l (𝓝 (c * b)) ↔ Tendsto f l (𝓝 c) := by refine ⟨?_, Tendsto.mul_const b⟩ - convert Tendsto.mul_const b⁻¹ using 3 <;> rw [mul_inv_cancel_right] + convert! Tendsto.mul_const b⁻¹ using 3 <;> rw [mul_inv_cancel_right] @[to_additive] lemma Filter.tendsto_const_mul_iff (b : G) {c : G} {f : α → G} {l : Filter α} : Tendsto (b * f ·) l (𝓝 (b * c)) ↔ Tendsto f l (𝓝 c) := by refine ⟨?_, Tendsto.const_mul b⟩ - convert Tendsto.const_mul b⁻¹ using 3 <;> rw [inv_mul_cancel_left] + convert! Tendsto.const_mul b⁻¹ using 3 <;> rw [inv_mul_cancel_left] end ContinuousMulGroup @@ -374,7 +374,7 @@ lemma continuousOn_inv_iff : ContinuousOn f⁻¹ s ↔ ContinuousOn f s := @[to_additive (attr := simp)] theorem Filter.inv_nhdsNE {a : G} : (𝓝[≠] a)⁻¹ = (𝓝[≠] (a⁻¹)) := by - convert (Homeomorph.inv G).isEmbedding.map_nhdsWithin_eq .. using 2 + convert! (Homeomorph.inv G).isEmbedding.map_nhdsWithin_eq .. using 2 simp end ContinuousInvolutiveInv @@ -518,22 +518,22 @@ variable [ContinuousMul H] @[to_additive (attr := simp)] theorem Filter.map_mul_left_nhdsGT {c a : H} : map (c * ·) (𝓝[>] a) = (𝓝[>] (c * a)) := by - convert (Homeomorph.mulLeft c).isEmbedding.map_nhdsWithin_eq .. using 2 + convert! (Homeomorph.mulLeft c).isEmbedding.map_nhdsWithin_eq .. using 2 simp [mul_comm] @[to_additive (attr := simp)] theorem Filter.map_mul_left_nhdsLT {c a : H} : map (c * ·) (𝓝[<] a) = (𝓝[<] (c * a)) := by - convert (Homeomorph.mulLeft c).isEmbedding.map_nhdsWithin_eq .. using 2 + convert! (Homeomorph.mulLeft c).isEmbedding.map_nhdsWithin_eq .. using 2 simp [mul_comm] @[to_additive (attr := simp)] theorem Filter.map_mul_right_nhdsGT {c a : H} : map (· * c) (𝓝[>] a) = (𝓝[>] (a * c)) := by - convert (Homeomorph.mulRight c).isEmbedding.map_nhdsWithin_eq .. using 2 + convert! (Homeomorph.mulRight c).isEmbedding.map_nhdsWithin_eq .. using 2 simp @[to_additive (attr := simp)] theorem Filter.map_mul_right_nhdsLT {c a : H} : map (· * c) (𝓝[<] a) = (𝓝[<] (a * c)) := by - convert (Homeomorph.mulRight c).isEmbedding.map_nhdsWithin_eq .. using 2 + convert! (Homeomorph.mulRight c).isEmbedding.map_nhdsWithin_eq .. using 2 simp end mul @@ -544,12 +544,12 @@ variable [ContinuousInv H] @[to_additive (attr := simp)] theorem Filter.inv_nhdsGT {a : H} : (𝓝[>] a)⁻¹ = (𝓝[<] (a⁻¹)) := by - convert (Homeomorph.inv H).isEmbedding.map_nhdsWithin_eq .. using 2 + convert! (Homeomorph.inv H).isEmbedding.map_nhdsWithin_eq .. using 2 simp @[to_additive (attr := simp)] theorem Filter.inv_nhdsLT {a : H} : (𝓝[<] a)⁻¹ = (𝓝[>] (a⁻¹)) := by - convert (Homeomorph.inv H).isEmbedding.map_nhdsWithin_eq .. using 2 + convert! (Homeomorph.inv H).isEmbedding.map_nhdsWithin_eq .. using 2 simp @[to_additive] @@ -1013,7 +1013,7 @@ lemma Filter.tendsto_div_const_iff {G : Type*} {b : G} (hb : b ≠ 0) {c : G} {f : α → G} {l : Filter α} : Tendsto (f · / b) l (𝓝 (c / b)) ↔ Tendsto f l (𝓝 c) := by refine ⟨fun h ↦ ?_, fun h ↦ Filter.Tendsto.div_const' h b⟩ - convert h.div_const' b⁻¹ with k <;> rw [← div_mul_eq_div_div_swap, inv_mul_cancel₀ hb, div_one] + convert! h.div_const' b⁻¹ with k <;> rw [← div_mul_eq_div_div_swap, inv_mul_cancel₀ hb, div_one] @[to_additive tendsto_sub_const_iff] lemma Filter.tendsto_div_const_iff' {G : Type*} @@ -1021,7 +1021,7 @@ lemma Filter.tendsto_div_const_iff' {G : Type*} (b : G) {c : G} {f : α → G} {l : Filter α} : Tendsto (f · / b) l (𝓝 (c / b)) ↔ Tendsto f l (𝓝 c) := by refine ⟨fun h ↦ ?_, fun h ↦ Filter.Tendsto.div_const' h b⟩ - convert h.div_const' b⁻¹ with k <;> rw [← div_mul_eq_div_div_swap, inv_mul_cancel, div_one] + convert! h.div_const' b⁻¹ with k <;> rw [← div_mul_eq_div_div_swap, inv_mul_cancel, div_one] @[to_additive const_sub] theorem Filter.Tendsto.const_div' (b : G) {c : G} {f : α → G} {l : Filter α} @@ -1044,7 +1044,7 @@ variable [Group G] [TopologicalSpace G] [IsTopologicalGroup G] lemma Filter.tendsto_const_div_iff' (b : G) {c : G} {f : α → G} {l : Filter α} : Tendsto (fun k : α ↦ b / f k) l (𝓝 (b / c)) ↔ Tendsto f l (𝓝 c) := by refine ⟨fun h ↦ ?_, Filter.Tendsto.const_div' b⟩ - convert h.inv.mul_const b with k <;> rw [inv_div, div_mul_cancel] + convert! h.inv.mul_const b with k <;> rw [inv_div, div_mul_cancel] @[deprecated (since := "2026-02-03")] alias Filter.tendsto_const_div_iff := Filter.tendsto_const_div_iff' @@ -1119,7 +1119,7 @@ theorem Subgroup.properlyDiscontinuousSMul_of_tendsto_cofinite (S : Subgroup G) intro K L hK hL have H : Set.Finite _ := hS ((hL.prod hK).image continuous_div').compl_mem_cocompact rw [preimage_compl, compl_compl] at H - convert H + convert! H ext x simp only [image_smul, mem_setOf_eq, coe_subtype, mem_preimage, mem_image, Prod.exists] exact Set.smul_inter_nonempty_iff' } @@ -1146,7 +1146,7 @@ theorem Subgroup.properlyDiscontinuousSMul_opposite_of_tendsto_cofinite (S : Sub hS ((hK.prod hL).image (continuous_mul.comp this)).compl_mem_cocompact simp only [preimage_compl, compl_compl, coe_subtype, comp_apply] at H apply Finite.of_preimage _ (equivOp S).surjective - convert H using 1 + convert! H using 1 ext x simp only [image_smul, mem_setOf_eq, mem_preimage, mem_image, Prod.exists] exact Set.op_smul_inter_nonempty_iff } diff --git a/Mathlib/Topology/Algebra/Group/ClosedSubgroup.lean b/Mathlib/Topology/Algebra/Group/ClosedSubgroup.lean index fb683cedd07a04..e0ae8b75fbc4c4 100644 --- a/Mathlib/Topology/Algebra/Group/ClosedSubgroup.lean +++ b/Mathlib/Topology/Algebra/Group/ClosedSubgroup.lean @@ -102,7 +102,7 @@ lemma normalCore_isClosed (H : Subgroup G) (h : IsClosed (H : Set G)) : push_cast apply isClosed_iInter intro g - convert IsClosed.preimage (IsTopologicalGroup.continuous_conj (ConjAct.ofConjAct g⁻¹)) h using 1 + convert! IsClosed.preimage (IsTopologicalGroup.continuous_conj (ConjAct.ofConjAct g⁻¹)) h using 1 exact Set.ext (fun t ↦ Set.mem_smul_set_iff_inv_smul_mem) @[to_additive] diff --git a/Mathlib/Topology/Algebra/Group/DiscontinuousSubgroup.lean b/Mathlib/Topology/Algebra/Group/DiscontinuousSubgroup.lean index 8b4093b9da32dc..9299ba695f52ea 100644 --- a/Mathlib/Topology/Algebra/Group/DiscontinuousSubgroup.lean +++ b/Mathlib/Topology/Algebra/Group/DiscontinuousSubgroup.lean @@ -26,7 +26,7 @@ protected lemma Subgroup.properlyDiscontinuousSMul_iff IsCompact K → IsCompact L → {g : Γ | g ∈ S ∧ (g • K ∩ L).Nonempty}.Finite := by rw [properlyDiscontinuousSMul_iff] congr! with K L hK hL - convert injOn_subtype_val (s := {m : S | (m • K ∩ L).Nonempty}) |>.bijOn_image.finite_iff_finite + convert! injOn_subtype_val (s := {m : S | (m • K ∩ L).Nonempty}) |>.bijOn_image.finite_iff_finite ext g simp [Set.subtype_smul_set, and_comm] diff --git a/Mathlib/Topology/Algebra/Group/Pointwise.lean b/Mathlib/Topology/Algebra/Group/Pointwise.lean index 505e63bcab00ef..0052f83df123fa 100644 --- a/Mathlib/Topology/Algebra/Group/Pointwise.lean +++ b/Mathlib/Topology/Algebra/Group/Pointwise.lean @@ -83,7 +83,7 @@ theorem MulAction.isClosedMap_quotient [CompactSpace α] : intro t ht rw [← isQuotientMap_quotient_mk'.isClosed_preimage, MulAction.quotient_preimage_image_eq_union_mul] - convert ht.smul_left_of_isCompact (isCompact_univ (X := α)) + convert! ht.smul_left_of_isCompact (isCompact_univ (X := α)) rw [← biUnion_univ, ← iUnion_smul_left_image] simp only [image_smul] diff --git a/Mathlib/Topology/Algebra/InfiniteSum/Basic.lean b/Mathlib/Topology/Algebra/InfiniteSum/Basic.lean index c680957af672d5..917957abae71b0 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/Basic.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/Basic.lean @@ -44,11 +44,11 @@ theorem hasProd_one : HasProd (fun _ ↦ 1 : β → α) 1 L := by simp [HasProd, @[to_additive (attr := simp)] theorem hasProd_empty [IsEmpty β] : HasProd f 1 L := by - convert hasProd_one + convert! hasProd_one @[to_additive (attr := nontriviality)] theorem HasProd.of_subsingleton_cod [Subsingleton α] : HasProd f 1 L := by - convert hasProd_one + convert! hasProd_one @[to_additive (attr := simp)] theorem multipliable_one : Multipliable (fun _ ↦ 1 : β → α) L := @@ -169,7 +169,7 @@ lemma hasProd_singleton (m : β) (f : β → α) : HasProd (({m} : Set β).restr @[to_additive] theorem hasProd_ite_eq (b : β) [DecidablePred (· = b)] (a : α) (L := unconditional β) [L.LeAtTop] : HasProd (fun b' ↦ if b' = b then a else 1) a L := by - convert hasProd_single b (hf := fun b' hb' ↦ if_neg hb') (L := L) + convert! hasProd_single b (hf := fun b' hb' ↦ if_neg hb') (L := L) exact (if_pos rfl).symm @[to_additive] @@ -418,7 +418,7 @@ theorem eq_mul_of_hasProd_ite [L.LeAtTop] [L.NeBot] {α : Type*} [TopologicalSpa [T2Space α] [ContinuousMul α] [DecidableEq β] {f : β → α} {a : α} (hf : HasProd f a L) (b : β) (a' : α) (hf' : HasProd (fun n ↦ ite (n = b) 1 (f n)) a' L) : a = a' * f b := by refine (mul_one a).symm.trans (hf.update' b 1 ?_) - convert hf' + convert! hf' apply update_apply end HasProd @@ -459,7 +459,7 @@ theorem tprod_one : ∏'[L] _, (1 : α) = 1 := by @[to_additive (attr := simp)] theorem tprod_empty [IsEmpty β] : ∏'[L] b, f b = 1 := by - convert tprod_one (L := L) + convert! tprod_one (L := L) @[to_additive] theorem tprod_congr {f g : β → α} diff --git a/Mathlib/Topology/Algebra/InfiniteSum/ConditionalInt.lean b/Mathlib/Topology/Algebra/InfiniteSum/ConditionalInt.lean index 2332fbcb5f4897..df3018e330b7be 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/ConditionalInt.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/ConditionalInt.lean @@ -118,7 +118,7 @@ lemma symmetricIcc_eq_symmetricIoo_int : symmetricIcc ℤ = symmetricIoo ℤ := simp only [← Nat.map_cast_int_atTop, Filter.map_map, Filter.mem_map, mem_atTop_sets, ge_iff_le, Set.mem_preimage, comp_apply] refine ⟨fun ⟨a, ha⟩ ↦ ⟨a + 1, fun b hb ↦ ?_⟩, fun ⟨a, ha⟩ ↦ ⟨a - 1, fun b hb ↦ ?_⟩⟩ <;> - [convert ha (b - 1) (by grind) using 1; convert ha (b + 1) (by grind) using 1] <;> + [convert! ha (b - 1) (by grind) using 1; convert! ha (b + 1) (by grind) using 1] <;> simp [Finset.ext_iff] <;> grind @[to_additive] @@ -182,7 +182,7 @@ lemma _root_.Summable.tendsto_zero_of_even_summable_symmetricIcc {F : Type*} [No filter_upwards [eventually_ge_atTop 1] with x hx have : Finset.Icc (-x) x = Icc (-(x - 1)) (x - 1) ∪ {-x, x} := by lift x to ℕ using by positivity - convert Finset.Icc_succ_succ (x - 1) (x - 1) <;> grind + convert! Finset.Icc_succ_succ (x - 1) (x - 1) <;> grind rw [this, Finset.sum_union, Finset.sum_insert, Finset.sum_singleton, hs x, add_comm, add_sub_cancel_right, ← two_zsmul, norm_smul, Int.norm_eq_abs, Int.cast_two, abs_two, inv_mul_cancel_left₀ two_ne_zero] <;> diff --git a/Mathlib/Topology/Algebra/InfiniteSum/Constructions.lean b/Mathlib/Topology/Algebra/InfiniteSum/Constructions.lean index 0f29cf7e430d4e..96a5615e2aa861 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/Constructions.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/Constructions.lean @@ -36,7 +36,7 @@ variable [CommMonoid α] [TopologicalSpace α] @[to_additive] theorem hasProd_pi_single [DecidableEq β] (b : β) (a : α) : HasProd (Pi.mulSingle b a) a := by - convert hasProd_ite_eq (L := .unconditional β) b a + convert! hasProd_ite_eq (L := .unconditional β) b a simp [Pi.mulSingle_apply] @[to_additive (attr := simp)] @@ -85,7 +85,7 @@ lemma HasProd.sum {α β M : Type*} [CommMonoid M] [TopologicalSpace M] [Continu (h₁ : HasProd (f ∘ Sum.inl) a) (h₂ : HasProd (f ∘ Sum.inr) b) : HasProd f (a * b) := by have : Tendsto ((∏ b ∈ ·, f b) ∘ sumEquiv.symm) (atTop.map sumEquiv) (nhds (a * b)) := by rw [Finset.sumEquiv.map_atTop, ← prod_atTop_atTop_eq] - convert (tendsto_mul.comp (nhds_prod_eq (x := a) (y := b) ▸ Tendsto.prodMap h₁ h₂)) + convert! (tendsto_mul.comp (nhds_prod_eq (x := a) (y := b) ▸ Tendsto.prodMap h₁ h₂)) ext s simp simpa [Tendsto, ← Filter.map_map] using this diff --git a/Mathlib/Topology/Algebra/InfiniteSum/Defs.lean b/Mathlib/Topology/Algebra/InfiniteSum/Defs.lean index 4f54a5f41226d2..01c9ccbcfcd3fa 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/Defs.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/Defs.lean @@ -309,7 +309,7 @@ theorem Multipliable.hasProd (ha : Multipliable f L) : HasProd f (∏'[L] b, f b classical rw [tprod_def, dif_pos ha] split_ifs with h h' - · convert hasProd_prod_support_of_ne_finset_one (s := h.2.toFinset) (L := L) _ using 2 + · convert! hasProd_prod_support_of_ne_finset_one (s := h.2.toFinset) (L := L) _ using 2 · simp only [Set.inter_eq_left.mpr (show ↑h.2.toFinset ⊆ L.support by simp)] simp only [Set.Finite.coe_toFinset, Finset.toFinset_coe] rw [finprod_eq_prod_of_mulSupport_subset (s := h.2.toFinset)] diff --git a/Mathlib/Topology/Algebra/InfiniteSum/ENNReal.lean b/Mathlib/Topology/Algebra/InfiniteSum/ENNReal.lean index 75b5aae84a67ad..6d23b702f40b31 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/ENNReal.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/ENNReal.lean @@ -234,7 +234,7 @@ space. This does not need a summability assumption, as otherwise all sums are ze theorem tendsto_tsum_compl_atTop_zero {α : Type*} {f : α → ℝ≥0∞} (hf : ∑' x, f x ≠ ∞) : Tendsto (fun s : Finset α => ∑' b : { x // x ∉ s }, f b) atTop (𝓝 0) := by lift f to α → ℝ≥0 using ENNReal.ne_top_of_tsum_ne_top hf - convert ENNReal.tendsto_coe.2 (NNReal.tendsto_tsum_compl_atTop_zero f) + convert! ENNReal.tendsto_coe.2 (NNReal.tendsto_tsum_compl_atTop_zero f) rw [ENNReal.coe_tsum] exact NNReal.summable_comp_injective (tsum_coe_ne_top_iff_summable.1 hf) Subtype.coe_injective @@ -444,7 +444,7 @@ open Finset assumption on `f`, as otherwise all sums are zero. -/ theorem tendsto_sum_nat_add (f : ℕ → ℝ≥0) : Tendsto (fun i => ∑' k, f (k + i)) atTop (𝓝 0) := by rw [← tendsto_coe] - convert _root_.tendsto_sum_nat_add fun i => (f i : ℝ) + convert! _root_.tendsto_sum_nat_add fun i => (f i : ℝ) norm_cast nonrec theorem hasSum_lt {f g : α → ℝ≥0} {sf sg : ℝ≥0} {i : α} (h : ∀ a : α, f a ≤ g a) diff --git a/Mathlib/Topology/Algebra/InfiniteSum/Group.lean b/Mathlib/Topology/Algebra/InfiniteSum/Group.lean index e28f041c119434..067c2f87f3925a 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/Group.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/Group.lean @@ -73,7 +73,7 @@ theorem multipliable_iff_of_multipliable_div (hfg : Multipliable (fun b ↦ f b @[to_additive] theorem HasProd.update [L.LeAtTop] (hf : HasProd f a₁ L) (b : β) [DecidableEq β] (a : α) : HasProd (update f b a) (a / f b * a₁) L := by - convert (hasProd_ite_eq b (a / f b) (L := L)).mul hf with b' + convert! (hasProd_ite_eq b (a / f b) (L := L)).mul hf with b' by_cases h : b' = b · rw [h, update_self] simp @@ -126,7 +126,7 @@ theorem Set.Finite.multipliable_compl_iff {s : Set β} (hs : s.Finite) : @[to_additive] theorem hasProd_ite_div_hasProd [L.LeAtTop] [DecidableEq β] (hf : HasProd f a L) (b : β) : HasProd (fun n ↦ ite (n = b) 1 (f n)) (a / f b) L := by - convert hf.update b 1 using 1 + convert! hf.update b 1 using 1 · ext n rw [Function.update_apply] · rw [div_mul_eq_mul_div, one_mul] diff --git a/Mathlib/Topology/Algebra/InfiniteSum/Module.lean b/Mathlib/Topology/Algebra/InfiniteSum/Module.lean index f032067ed1cf50..93ddd5f754cb60 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/Module.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/Module.lean @@ -192,7 +192,7 @@ noncomputable def MulAction.automorphize [Group α] [MulAction α β] (f : β intro b₁ b₂ ⟨a, (ha : a • b₂ = b₁)⟩ simp only rw [← ha] - convert (Equiv.mulRight a).tsum_eq (fun a' ↦ f (a' • b₂)) using 1 + convert! (Equiv.mulRight a).tsum_eq (fun a' ↦ f (a' • b₂)) using 1 simp only [Equiv.coe_mulRight] congr ext diff --git a/Mathlib/Topology/Algebra/InfiniteSum/NatInt.lean b/Mathlib/Topology/Algebra/InfiniteSum/NatInt.lean index dc52aef2bbd369..e0dbc3df77b3fe 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/NatInt.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/NatInt.lean @@ -173,7 +173,7 @@ theorem rel_iSup_prod [CompleteLattice α] (m : α → M) (m0 : m ⊥ = 1) (R : theorem rel_sup_mul [CompleteLattice α] (m : α → M) (m0 : m ⊥ = 1) (R : M → M → Prop) (m_iSup : ∀ s : ℕ → α, R (m (⨆ i, s i)) (∏' i, m (s i))) (s₁ s₂ : α) : R (m (s₁ ⊔ s₂)) (m s₁ * m s₂) := by - convert rel_iSup_tprod m m0 R m_iSup fun b ↦ cond b s₁ s₂ + convert! rel_iSup_tprod m m0 R m_iSup fun b ↦ cond b s₁ s₂ · simp only [iSup_bool_eq, cond] · rw [tprod_fintype, Fintype.prod_bool, cond, cond] diff --git a/Mathlib/Topology/Algebra/InfiniteSum/Ring.lean b/Mathlib/Topology/Algebra/InfiniteSum/Ring.lean index a81c1ec803c300..455aed759941ee 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/Ring.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/Ring.lean @@ -317,10 +317,10 @@ theorem tprod_one_add [T2Space α] (h : Summable (∏ i ∈ ·, f i)) : HasProd.tprod_eq <| hasProd_one_add_of_hasSum_prod h.hasSum section Ordered -variable [LinearOrder ι] [LocallyFiniteOrderBot ι] [T2Space α] +variable [LinearOrder ι] [LocallyFiniteOrderBot ι] /-- The infinite version of `Finset.prod_one_add_ordered`. -/ -theorem tprod_one_add_ordered [ContinuousAdd α] +theorem tprod_one_add_ordered [T2Space α] [ContinuousAdd α] (hsum : Summable fun i ↦ f i * ∏ j ∈ Iio i, (1 + f j)) (hprod : Multipliable (1 + f ·)) : ∏' i, (1 + f i) = 1 + ∑' i, f i * ∏ j ∈ Iio i, (1 + f j) := by @@ -328,20 +328,20 @@ theorem tprod_one_add_ordered [ContinuousAdd α] · simp obtain ⟨x, hx⟩ := hprod obtain ⟨a, ha⟩ := hsum - convert hx.tprod_eq + convert! hx.tprod_eq unfold HasProd at hx conv at hx in fun _ ↦ _ => ext _; rw [prod_one_add_ordered] -- simp_rw would cause loop rw [ha.tsum_eq] refine (tendsto_nhds_unique (hx.comp tendsto_finset_Iic_atTop_atTop) ?_).symm apply Tendsto.const_add - convert ha.comp tendsto_finset_Iic_atTop_atTop using 2 with s + convert! ha.comp tendsto_finset_Iic_atTop_atTop using 2 with s refine sum_congr rfl (fun i hi ↦ ?_) congr grind -omit [CommSemiring α] in /-- The infinite version of `Finset.prod_one_sub_ordered`. -/ -theorem tprod_one_sub_ordered [CommRing α] [IsTopologicalAddGroup α] +theorem tprod_one_sub_ordered {α : Type*} {f : ι → α} + [CommRing α] [TopologicalSpace α] [T2Space α] [IsTopologicalAddGroup α] (hsum : Summable fun i ↦ f i * ∏ j ∈ Iio i, (1 - f j)) (hprod : Multipliable (1 - f ·)) : ∏' i, (1 - f i) = 1 - ∑' i, f i * ∏ j ∈ Iio i, (1 - f j) := by diff --git a/Mathlib/Topology/Algebra/InfiniteSum/SummationFilter.lean b/Mathlib/Topology/Algebra/InfiniteSum/SummationFilter.lean index 49f3f3912dcf63..3d23c163809747 100644 --- a/Mathlib/Topology/Algebra/InfiniteSum/SummationFilter.lean +++ b/Mathlib/Topology/Algebra/InfiniteSum/SummationFilter.lean @@ -252,7 +252,7 @@ lemma conditional_filter_eq_map_range : (conditional ℕ).filter = atTop.map Fin simp only [tendsto_atTop', mem_map, mem_atTop_sets, mem_preimage] <;> rintro s ⟨a, ha⟩ · exact ⟨a + 1, fun b hb ↦ ha (b + 1) (by lia)⟩ - · exact ⟨a + 1, fun b hb ↦ by convert ha (b - 1) (by lia); lia⟩ + · exact ⟨a + 1, fun b hb ↦ by convert! ha (b - 1) (by lia); lia⟩ end conditionalTop diff --git a/Mathlib/Topology/Algebra/IsOpenUnits.lean b/Mathlib/Topology/Algebra/IsOpenUnits.lean index c8e91978ce8452..9c84f5cb5ec4cc 100644 --- a/Mathlib/Topology/Algebra/IsOpenUnits.lean +++ b/Mathlib/Topology/Algebra/IsOpenUnits.lean @@ -54,7 +54,7 @@ instance (priority := 900) {M : Type*} [GroupWithZero M] [TopologicalSpace M] [ContinuousInv₀ M] [T1Space M] : IsOpenUnits M where isOpenEmbedding_unitsVal := by refine ⟨Units.isEmbedding_val₀, ?_⟩ - convert (isClosed_singleton (X := M) (x := 0)).isOpen_compl + convert! (isClosed_singleton (X := M) (x := 0)).isOpen_compl ext simp only [Set.mem_range, Set.mem_compl_iff, Set.mem_singleton_iff] exact isUnit_iff_ne_zero diff --git a/Mathlib/Topology/Algebra/IsUniformGroup/Basic.lean b/Mathlib/Topology/Algebra/IsUniformGroup/Basic.lean index d1152d6b71e53a..455156e1b1096e 100644 --- a/Mathlib/Topology/Algebra/IsUniformGroup/Basic.lean +++ b/Mathlib/Topology/Algebra/IsUniformGroup/Basic.lean @@ -138,7 +138,7 @@ theorem totallyBounded_iff_subset_finite_iUnion_nhds_one {s : Set α} : @[to_additive] theorem totallyBounded_inv {s : Set α} (hs : TotallyBounded s) : TotallyBounded (s⁻¹) := by - convert TotallyBounded.image hs uniformContinuous_inv + convert! TotallyBounded.image hs uniformContinuous_inv aesop section UniformConvergence @@ -338,8 +338,8 @@ def opUniformEquivRight letI : UniformSpace G := IsTopologicalGroup.rightUniformSpace G letI : UniformSpace Gᵐᵒᵖ := IsTopologicalGroup.leftUniformSpace Gᵐᵒᵖ refine ⟨MulOpposite.opEquiv, ?_, ?_⟩ - · simp [uniformContinuous_iff, ← comap_op_leftUniformSpace] - · simp [uniformContinuous_iff, ← comap_op_leftUniformSpace, ← UniformSpace.comap_comap] + · simp [uniformContinuous_iff_le_comap, ← comap_op_leftUniformSpace] + · simp [uniformContinuous_iff_le_comap, ← comap_op_leftUniformSpace, ← UniformSpace.comap_comap] /-- The equivalence between a topological group `G` and `Gᵐᵒᵖ` as a uniform equivalence when `G` is equipped with the left uniformity and `Gᵐᵒᵖ` with the right uniformity. -/ @@ -352,8 +352,8 @@ def opUniformEquivLeft letI : UniformSpace G := IsTopologicalGroup.leftUniformSpace G letI : UniformSpace Gᵐᵒᵖ := IsTopologicalGroup.rightUniformSpace Gᵐᵒᵖ refine ⟨MulOpposite.opEquiv, ?_, ?_⟩ - · simp [uniformContinuous_iff, ← comap_op_rightUniformSpace] - · simp [uniformContinuous_iff, ← comap_op_rightUniformSpace, ← UniformSpace.comap_comap] + · simp [uniformContinuous_iff_le_comap, ← comap_op_rightUniformSpace] + · simp [uniformContinuous_iff_le_comap, ← comap_op_rightUniformSpace, ← UniformSpace.comap_comap] end MulOpposite @@ -381,11 +381,11 @@ def UniformEquiv.inv : @UniformEquiv G G (IsTopologicalGroup.rightUniformSpace G (IsTopologicalGroup.leftUniformSpace G) := by have A : @UniformContinuous G G (IsTopologicalGroup.rightUniformSpace G) (IsTopologicalGroup.leftUniformSpace G) (Equiv.inv G) := by - apply uniformContinuous_iff.2 + apply uniformContinuous_iff_le_comap.2 rw [← comap_inv_leftUniformSpace] have B : @UniformContinuous G G (IsTopologicalGroup.leftUniformSpace G) (IsTopologicalGroup.rightUniformSpace G) (Equiv.inv G) := by - apply uniformContinuous_iff.2 + apply uniformContinuous_iff_le_comap.2 rw [← comap_inv_leftUniformSpace, ← UniformSpace.comap_comap] simp exact @UniformEquiv.mk G G (IsTopologicalGroup.rightUniformSpace G) @@ -697,7 +697,7 @@ instance QuotientGroup.completeSpace_right' (G : Type u) [Group G] [TopologicalS ⟨↑x₀, tendsto_nhds_of_cauchySeq_of_subseq hx (strictMono_nat_of_lt_succ fun n => (hφ (n + 1)).1).tendsto_atTop ?_⟩ - convert ((continuous_coinduced_rng : Continuous ((↑) : G → G ⧸ N)).tendsto x₀).comp hx₀ + convert! ((continuous_coinduced_rng : Continuous ((↑) : G → G ⧸ N)).tendsto x₀).comp hx₀ exact funext fun n => (x' n).snd /-- The quotient `G ⧸ N` of a complete first countable uniform group `G` by a normal subgroup diff --git a/Mathlib/Topology/Algebra/IsUniformGroup/Defs.lean b/Mathlib/Topology/Algebra/IsUniformGroup/Defs.lean index 9e592b3779255f..a8318593f8ef4d 100644 --- a/Mathlib/Topology/Algebra/IsUniformGroup/Defs.lean +++ b/Mathlib/Topology/Algebra/IsUniformGroup/Defs.lean @@ -456,7 +456,7 @@ theorem Filter.Tendsto.conj_nhds_one {ι : Type*} {l : Filter ι} {x : ι → β have : Tendsto (fun i ↦ (g i, x i)) l (comap Prod.snd (𝓝 1)) := by rwa [tendsto_comap_iff] -- `exact` works but is quite slow... - convert tendsto_conj_nhds_one.comp this + convert! tendsto_conj_nhds_one.comp this theorem IsUniformGroup.of_left_right : IsUniformGroup β where uniformContinuous_div := by diff --git a/Mathlib/Topology/Algebra/Module/Alternating/Basic.lean b/Mathlib/Topology/Algebra/Module/Alternating/Basic.lean index 2fe0ff95b01983..3d10a520a2569e 100644 --- a/Mathlib/Topology/Algebra/Module/Alternating/Basic.lean +++ b/Mathlib/Topology/Algebra/Module/Alternating/Basic.lean @@ -101,7 +101,7 @@ theorem ext {f g : M [⋀^ι]→L[R] N} (H : ∀ x, f x = g x) : f = g := theorem toAlternatingMap_injective : Injective (toAlternatingMap : (M [⋀^ι]→L[R] N) → (M [⋀^ι]→ₗ[R] N)) := fun f g h => - DFunLike.ext' <| by convert DFunLike.ext'_iff.1 h + DFunLike.ext' <| by convert! DFunLike.ext'_iff.1 h @[simp] theorem range_toAlternatingMap : diff --git a/Mathlib/Topology/Algebra/Module/Basic.lean b/Mathlib/Topology/Algebra/Module/Basic.lean index ef874d64733656..e2cd9a9f25d672 100644 --- a/Mathlib/Topology/Algebra/Module/Basic.lean +++ b/Mathlib/Topology/Algebra/Module/Basic.lean @@ -90,7 +90,7 @@ theorem Module.punctured_nhds_neBot [Nontrivial M] [NeBot (𝓝[≠] (0 : R))] [ rcases exists_ne (0 : M) with ⟨y, hy⟩ suffices Tendsto (fun c : R => x + c • y) (𝓝[≠] 0) (𝓝[≠] x) from this.neBot refine Tendsto.inf ?_ (tendsto_principal_principal.2 <| ?_) - · convert tendsto_const_nhds.add ((@tendsto_id R _).smul_const y) + · convert! tendsto_const_nhds.add ((@tendsto_id R _).smul_const y) rw [zero_smul, add_zero] · intro c hc simpa [hy] using hc diff --git a/Mathlib/Topology/Algebra/Module/Equiv.lean b/Mathlib/Topology/Algebra/Module/Equiv.lean index c33c0c379f411f..48fdce2ae6cfc5 100644 --- a/Mathlib/Topology/Algebra/Module/Equiv.lean +++ b/Mathlib/Topology/Algebra/Module/Equiv.lean @@ -35,8 +35,8 @@ structure ContinuousLinearEquiv {R : Type*} {S : Type*} [Semiring R] [Semiring S {σ' : S →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] (M : Type*) [TopologicalSpace M] [AddCommMonoid M] (M₂ : Type*) [TopologicalSpace M₂] [AddCommMonoid M₂] [Module R M] [Module S M₂] extends M ≃ₛₗ[σ] M₂ where - continuous_toFun : Continuous toFun := by first | fun_prop | dsimp; fun_prop - continuous_invFun : Continuous invFun := by first | fun_prop | dsimp; fun_prop + continuous_toFun : Continuous toFun := by first | fun_prop | eta_expand; dsimp; fun_prop | skip + continuous_invFun : Continuous invFun := by first | fun_prop | eta_expand; dsimp; fun_prop | skip attribute [inherit_doc ContinuousLinearEquiv] ContinuousLinearEquiv.continuous_toFun ContinuousLinearEquiv.continuous_invFun @@ -288,10 +288,8 @@ variable (R₁ M₁) /-- The identity map as a continuous linear equivalence. -/ @[refl] -protected def refl : M₁ ≃L[R₁] M₁ := - { LinearEquiv.refl R₁ M₁ with - continuous_toFun := continuous_id - continuous_invFun := continuous_id } +protected def refl : M₁ ≃L[R₁] M₁ where + __ := LinearEquiv.refl R₁ M₁ @[simp] theorem refl_apply (x : M₁) : @@ -346,10 +344,8 @@ theorem symm_map_nhds_eq (e : M₁ ≃SL[σ₁₂] M₂) (x : M₁) : map e.symm /-- The composition of two continuous linear equivalences as a continuous linear equivalence. -/ @[trans] -protected def trans (e₁ : M₁ ≃SL[σ₁₂] M₂) (e₂ : M₂ ≃SL[σ₂₃] M₃) : M₁ ≃SL[σ₁₃] M₃ := - { e₁.toLinearEquiv.trans e₂.toLinearEquiv with - continuous_toFun := e₂.continuous_toFun.comp e₁.continuous_toFun - continuous_invFun := e₁.continuous_invFun.comp e₂.continuous_invFun } +protected def trans (e₁ : M₁ ≃SL[σ₁₂] M₂) (e₂ : M₂ ≃SL[σ₂₃] M₃) : M₁ ≃SL[σ₁₃] M₃ where + __ := e₁.toLinearEquiv.trans e₂.toLinearEquiv @[simp] theorem trans_toLinearEquiv (e₁ : M₁ ≃SL[σ₁₂] M₂) (e₂ : M₂ ≃SL[σ₂₃] M₃) : @@ -383,10 +379,8 @@ variable (R₁ M₁ M₂) /-- Product of modules is commutative up to continuous linear isomorphism. -/ @[simps! apply toLinearEquiv] -def prodComm [Module R₁ M₂] : (M₁ × M₂) ≃L[R₁] M₂ × M₁ := - { LinearEquiv.prodComm R₁ M₁ M₂ with - continuous_toFun := continuous_swap - continuous_invFun := continuous_swap } +def prodComm [Module R₁ M₂] : (M₁ × M₂) ≃L[R₁] M₂ × M₁ where + __ := LinearEquiv.prodComm R₁ M₁ M₂ @[simp] lemma prodComm_symm [Module R₁ M₂] : (prodComm R₁ M₁ M₂).symm = prodComm R₁ M₂ M₁ := rfl @@ -434,8 +428,6 @@ variable (R M₁ M₂ M₃ M₄ : Type*) [Semiring R] This is `LinearEquiv.prodProdProdComm` prodAssoc as a continuous linear equivalence. -/ def prodProdProdComm : ((M₁ × M₂) × M₃ × M₄) ≃L[R] (M₁ × M₃) × M₂ × M₄ where toLinearEquiv := LinearEquiv.prodProdProdComm R M₁ M₂ M₃ M₄ - continuous_toFun := by fun_prop - continuous_invFun := by fun_prop @[simp] theorem prodProdProdComm_symm : @@ -468,12 +460,6 @@ variable (R M N : Type*) [Semiring R] This is `Equiv.prodUnique` as a continuous linear equivalence. -/ def prodUnique : (M × N) ≃L[R] M where toLinearEquiv := LinearEquiv.prodUnique - continuous_toFun := by - change Continuous (Equiv.prodUnique M N) - dsimp; fun_prop - continuous_invFun := by - change Continuous fun x ↦ (x, default) - fun_prop @[simp] lemma coe_prodUnique : (prodUnique R M N).toEquiv = Equiv.prodUnique M N := rfl @@ -488,12 +474,6 @@ lemma prodUnique_symm_apply (x : M) : (prodUnique R M N).symm x = (x, default) : This is `Equiv.uniqueProd` as a continuous linear equivalence. -/ def uniqueProd : (N × M) ≃L[R] M where toLinearEquiv := LinearEquiv.uniqueProd - continuous_toFun := by - change Continuous (Equiv.uniqueProd M N) - dsimp; fun_prop - continuous_invFun := by - change Continuous fun x ↦ (default, x) - fun_prop @[simp] lemma coe_uniqueProd : (uniqueProd R M N).toEquiv = Equiv.uniqueProd M N := rfl @@ -632,9 +612,7 @@ inverse of each other. See also `equivOfInverse'`. -/ def equivOfInverse (f₁ : M₁ →SL[σ₁₂] M₂) (f₂ : M₂ →SL[σ₂₁] M₁) (h₁ : Function.LeftInverse f₂ f₁) (h₂ : Function.RightInverse f₂ f₁) : M₁ ≃SL[σ₁₂] M₂ := { f₁ with - continuous_toFun := f₁.continuous invFun := f₂ - continuous_invFun := f₂.continuous left_inv := h₁ right_inv := h₂ } @@ -700,10 +678,8 @@ variable {M₁} {R₄ : Type*} [Semiring R₄] [Module R₄ M₄] {σ₃₄ : R /-- The continuous linear equivalence between `ULift M₁` and `M₁`. This is a continuous version of `ULift.moduleEquiv`. -/ -def ulift : ULift M₁ ≃L[R₁] M₁ := - { ULift.moduleEquiv with - continuous_toFun := continuous_uliftDown - continuous_invFun := continuous_uliftUp } +def ulift : ULift M₁ ≃L[R₁] M₁ where + __ := ULift.moduleEquiv /-- A pair of continuous (semi)linear equivalences generates an equivalence between the spaces of continuous linear maps. See also `ContinuousLinearEquiv.arrowCongr`. -/ @@ -777,12 +753,8 @@ variable {ι : Type*} {M : ι → Type*} [∀ i, TopologicalSpace (M i)] [∀ i, /-- Combine a family of continuous linear equivalences into a continuous linear equivalence of pi-types. -/ -def piCongrRight : ((i : ι) → M i) ≃L[R₁] (i : ι) → N i := - { LinearEquiv.piCongrRight fun i ↦ f i with - continuous_toFun := by - exact continuous_pi fun i ↦ (f i).continuous_toFun.comp (continuous_apply i) - continuous_invFun := by - exact continuous_pi fun i => (f i).continuous_invFun.comp (continuous_apply i) } +def piCongrRight : ((i : ι) → M i) ≃L[R₁] (i : ι) → N i where + __ := LinearEquiv.piCongrRight fun i ↦ (f i).toLinearEquiv @[simp] theorem piCongrRight_apply (m : (i : ι) → M i) (i : ι) : @@ -837,8 +809,6 @@ def ofUnit (f : (M →L[R] M)ˣ) : M ≃L[R] M where show (f.val * f.inv) x = x by rw [f.val_inv] simp } - continuous_toFun := f.val.continuous - continuous_invFun := f.inv.continuous /-- A continuous equivalence from `M` to itself determines an invertible continuous linear map. -/ def toUnit (f : M ≃L[R] M) : (M →L[R] M)ˣ where @@ -946,8 +916,6 @@ variable (R M) in @[simps!] def _root_.Fin.consEquivL : (M 0 × Π i, M (Fin.succ i)) ≃L[R] (Π i, M i) where __ := Fin.consLinearEquiv R M - continuous_toFun := continuous_id.fst.finCons continuous_id.snd - continuous_invFun := .prodMk (continuous_apply 0) (by fun_prop) /-- `Fin.cons` in the codomain of continuous linear maps. -/ abbrev _root_.ContinuousLinearMap.finCons @@ -971,15 +939,8 @@ variable [IsTopologicalAddGroup M₄] /-- Equivalence given by a block lower diagonal matrix. `e` and `e'` are diagonal square blocks, and `f` is a rectangular block below the diagonal. -/ -def skewProd (e : M ≃L[R] M₂) (e' : M₃ ≃L[R] M₄) (f : M →L[R] M₄) : (M × M₃) ≃L[R] M₂ × M₄ := - { e.toLinearEquiv.skewProd e'.toLinearEquiv ↑f with - continuous_toFun := - (e.continuous_toFun.comp continuous_fst).prodMk - ((e'.continuous_toFun.comp continuous_snd).add <| f.continuous.comp continuous_fst) - continuous_invFun := - (e.continuous_invFun.comp continuous_fst).prodMk - (e'.continuous_invFun.comp <| - continuous_snd.sub <| f.continuous.comp <| e.continuous_invFun.comp continuous_fst) } +def skewProd (e : M ≃L[R] M₂) (e' : M₃ ≃L[R] M₄) (f : M →L[R] M₄) : (M × M₃) ≃L[R] M₂ × M₄ where + __ := e.toLinearEquiv.skewProd e'.toLinearEquiv ↑f @[simp] theorem skewProd_apply (e : M ≃L[R] M₂) (e' : M₃ ≃L[R] M₄) (f : M →L[R] M₄) (x) : @@ -994,10 +955,8 @@ theorem skewProd_symm_apply (e : M ≃L[R] M₂) (e' : M₃ ≃L[R] M₄) (f : M variable (R) in /-- The negation map as a continuous linear equivalence. -/ def neg [ContinuousNeg M] : - M ≃L[R] M := - { LinearEquiv.neg R with - continuous_toFun := continuous_neg - continuous_invFun := continuous_neg } + M ≃L[R] M where + __ := LinearEquiv.neg R @[simp] theorem coe_neg [ContinuousNeg M] : @@ -1065,8 +1024,6 @@ def restrictScalars (R : Type*) {S : Type*} {M : Type*} [Semiring R] [Semiring S] [AddCommMonoid M] [Module R M] [Module S M] [TopologicalSpace M] [LinearMap.CompatibleSMul M M R S] (f : M ≃L[S] M) : M ≃L[R] M where toLinearEquiv := f.toLinearEquiv.restrictScalars R - continuous_invFun := f.continuous_invFun - continuous_toFun := f.continuous_toFun end RestrictScalars @@ -1215,7 +1172,7 @@ lemma IsInvertible.inverse_comp_apply_of_right {g : M₂ →L[R] M₃} {f : M @[simp] theorem ringInverse_equiv (e : M ≃L[R] M) : (↑e)⁻¹ʳ = inverse (e : M →L[R] M) := by suffices ((ContinuousLinearEquiv.unitsEquiv _ _).symm e : M →L[R] M)⁻¹ʳ = inverse ↑e by - convert this + convert! this simp rfl diff --git a/Mathlib/Topology/Algebra/Module/Multilinear/Topology.lean b/Mathlib/Topology/Algebra/Module/Multilinear/Topology.lean index cae0a409413142..114712b3724e5e 100644 --- a/Mathlib/Topology/Algebra/Module/Multilinear/Topology.lean +++ b/Mathlib/Topology/Algebra/Module/Multilinear/Topology.lean @@ -53,7 +53,7 @@ lemma range_toUniformOnFun [DecidableEq ι] [TopologicalSpace F] : · rintro ⟨f, rfl⟩ exact ⟨f.cont, f.map_update_add, f.map_update_smul⟩ · rintro ⟨hcont, hadd, hsmul⟩ - exact ⟨⟨⟨f, by intro; convert hadd, by intro; convert hsmul⟩, hcont⟩, rfl⟩ + exact ⟨⟨⟨f, by intro; convert! hadd, by intro; convert! hsmul⟩, hcont⟩, rfl⟩ @[simp] lemma toUniformOnFun_toFun [TopologicalSpace F] (f : ContinuousMultilinearMap 𝕜 E F) : @@ -161,7 +161,7 @@ theorem isUniformEmbedding_restrictScalars : letI : NontriviallyNormedField 𝕜 := ⟨let ⟨x, hx⟩ := @NontriviallyNormedField.non_trivial 𝕜' _; ⟨algebraMap 𝕜' 𝕜 x, by simpa⟩⟩ rw [← isUniformEmbedding_toUniformOnFun.of_comp_iff] - convert isUniformEmbedding_toUniformOnFun using 4 with s + convert! isUniformEmbedding_toUniformOnFun using 4 with s exact ⟨fun h ↦ h.extend_scalars _, fun h ↦ h.restrict_scalars _⟩ theorem uniformContinuous_restrictScalars : @@ -259,6 +259,11 @@ def compContinuousLinearMapL (f : ∀ i, E i →L[𝕜] E₁ i) : set φ : (∀ i, E i) →L[𝕜] (∀ i, E₁ i) := .piMap f exact ⟨(φ '' U, V), ⟨hU.image φ, hV⟩, fun g hg ↦ hg.comp (mapsTo_image _ _)⟩ } +@[fun_prop] +theorem continuous_precomp (f : ∀ i, E i →L[𝕜] E₁ i) : + Continuous fun g : ContinuousMultilinearMap 𝕜 E₁ F ↦ g.compContinuousLinearMap f := + map_continuous (compContinuousLinearMapL f) + end CompContinuousLinearMap variable [∀ i, ContinuousSMul 𝕜 (E i)] @@ -386,6 +391,11 @@ theorem compContinuousMultilinearMapL_apply (g : F →L[𝕜] G) (f : Continuous compContinuousMultilinearMapL 𝕜 E F G g f = g.compContinuousMultilinearMap f := rfl +@[fun_prop] +theorem _root_.ContinuousLinearMap.continuous_postcomp_continuousMultilinearMap (g : F →L[𝕜] G) : + Continuous (g.compContinuousMultilinearMap (M₁ := E)) := + map_continuous (compContinuousMultilinearMapL 𝕜 E F G g) + end ContinuousLinearMap namespace ContinuousLinearEquiv diff --git a/Mathlib/Topology/Algebra/Module/Spaces/ContinuousLinearMap.lean b/Mathlib/Topology/Algebra/Module/Spaces/ContinuousLinearMap.lean index efeec28683bac1..f0a3681fab4122 100644 --- a/Mathlib/Topology/Algebra/Module/Spaces/ContinuousLinearMap.lean +++ b/Mathlib/Topology/Algebra/Module/Spaces/ContinuousLinearMap.lean @@ -383,7 +383,7 @@ set_option backward.isDefEq.respectTransparency false in theorem isUniformEmbedding_restrictScalars : IsUniformEmbedding (restrictScalars 𝕜' : (E →L[𝕜] F) → (E →L[𝕜'] F)) := by rw [← isUniformEmbedding_toUniformOnFun.of_comp_iff] - convert isUniformEmbedding_toUniformOnFun using 4 with s + convert! isUniformEmbedding_toUniformOnFun using 4 with s exact ⟨fun h ↦ h.extend_scalars _, fun h ↦ h.restrict_scalars _⟩ theorem uniformContinuous_restrictScalars : diff --git a/Mathlib/Topology/Algebra/Module/Spaces/UniformConvergenceCLM.lean b/Mathlib/Topology/Algebra/Module/Spaces/UniformConvergenceCLM.lean index 4036f922576c8c..8dc08ebe38c81e 100644 --- a/Mathlib/Topology/Algebra/Module/Spaces/UniformConvergenceCLM.lean +++ b/Mathlib/Topology/Algebra/Module/Spaces/UniformConvergenceCLM.lean @@ -5,11 +5,15 @@ Authors: Anatole Dedecker, Yury Kudryashov -/ module +public import Mathlib.Analysis.LocallyConvex.Bounded +public import Mathlib.Analysis.Normed.Field.Basic public import Mathlib.Topology.Algebra.Algebra.Equiv -public import Mathlib.Topology.Algebra.Module.Equiv -public import Mathlib.Topology.Algebra.Module.UniformConvergence -public import Mathlib.Topology.Algebra.SeparationQuotient.Section public import Mathlib.Topology.Hom.ContinuousEvalConst +public import Mathlib.Topology.UniformSpace.UniformConvergenceTopology + +import Mathlib.Topology.Algebra.Module.Equiv +import Mathlib.Topology.Algebra.SeparationQuotient.Section +import Mathlib.Topology.Algebra.Module.UniformConvergence /-! # Topologies of uniform convergence on the space of continuous linear maps @@ -374,8 +378,10 @@ theorem completeSpace [UniformSpace F] [IsUniformAddGroup F] [ContinuousSMul apply IsClosed.isComplete have H₁ : IsClosed {f : E →ᵤ[𝔖] F | Continuous ((UniformOnFun.toFun 𝔖) f)} := UniformOnFun.isClosed_setOf_continuous h𝔖 - convert H₁.inter <| (LinearMap.isClosed_range_coe E F σ).preimage - (UniformOnFun.uniformContinuous_toFun h𝔖U).continuous + convert! + H₁.inter <| + (LinearMap.isClosed_range_coe E F σ).preimage + (UniformOnFun.uniformContinuous_toFun h𝔖U).continuous exact ContinuousLinearMap.range_coeFn_eq variable {𝔖₁ 𝔖₂ : Set (Set E)} diff --git a/Mathlib/Topology/Algebra/Monoid.lean b/Mathlib/Topology/Algebra/Monoid.lean index 5f381c40f0b7d6..81929aa3d61b25 100644 --- a/Mathlib/Topology/Algebra/Monoid.lean +++ b/Mathlib/Topology/Algebra/Monoid.lean @@ -731,7 +731,7 @@ inverse images of compact sets are compact. -/ theorem Filter.tendsto_cocompact_mul_left {a b : M} (ha : b * a = 1) : Filter.Tendsto (fun x : M => a * x) (Filter.cocompact M) (Filter.cocompact M) := by refine Filter.Tendsto.of_tendsto_comp ?_ (Filter.comap_cocompact_le (continuous_const_mul b)) - convert Filter.tendsto_id + convert! Filter.tendsto_id ext x simp [← mul_assoc, ha] diff --git a/Mathlib/Topology/Algebra/MulAction.lean b/Mathlib/Topology/Algebra/MulAction.lean index d2149b7e268771..09789bd4d954c9 100644 --- a/Mathlib/Topology/Algebra/MulAction.lean +++ b/Mathlib/Topology/Algebra/MulAction.lean @@ -257,7 +257,7 @@ theorem continuousSMul_iff_stabilizer_isOpen [DiscreteTopology X] : have hU : IsOpen U := by by_cases hU' : U ≠ ∅ · obtain ⟨m, (hm : m • y = x)⟩ := Set.nonempty_iff_empty_ne.mpr hU'.symm - convert (h x).preimage (by fun_prop : Continuous fun m' : M ↦ m' * m⁻¹) + convert! (h x).preimage (by fun_prop : Continuous fun m' : M ↦ m' * m⁻¹) ext; simp [← smul_smul, U, eq_inv_smul_iff.mpr hm] simp_all simpa using hU @@ -330,6 +330,7 @@ theorem continuousSMul_iInf {ts' : ι → TopologicalSpace X} (h : ∀ i, @ContinuousSMul M X _ _ (ts' i)) : @ContinuousSMul M X _ _ (⨅ i, ts' i) := continuousSMul_sInf <| Set.forall_mem_range.mpr h +set_option linter.overlappingInstances false in @[to_additive] theorem continuousSMul_inf {t₁ t₂ : TopologicalSpace X} [@ContinuousSMul M X _ _ t₁] [@ContinuousSMul M X _ _ t₂] : @ContinuousSMul M X _ _ (t₁ ⊓ t₂) := by @@ -349,7 +350,7 @@ include G in it loops for a group as a torsor over itself. -/ protected theorem AddTorsor.connectedSpace : ConnectedSpace P := { isPreconnected_univ := by - convert + convert! isPreconnected_univ.image (Equiv.vaddConst (Classical.arbitrary P) : G → P) (continuous_id.vadd continuous_const).continuousOn rw [Set.image_univ, Equiv.range_eq_univ] diff --git a/Mathlib/Topology/Algebra/Nonarchimedean/AdicTopology.lean b/Mathlib/Topology/Algebra/Nonarchimedean/AdicTopology.lean index a80cf958305cf2..37e7a4839ce8a7 100644 --- a/Mathlib/Topology/Algebra/Nonarchimedean/AdicTopology.lean +++ b/Mathlib/Topology/Algebra/Nonarchimedean/AdicTopology.lean @@ -143,7 +143,7 @@ on an `R`-module `M`, seen as open additive subgroups of `M`. -/ def openAddSubgroup (n : ℕ) : @OpenAddSubgroup R _ I.adicTopology := by letI := I.adicTopology refine ⟨(I ^ n).toAddSubgroup, ?_⟩ - convert (I.adic_basis.toRing_subgroups_basis.openAddSubgroup n).isOpen + convert! (I.adic_basis.toRing_subgroups_basis.openAddSubgroup n).isOpen change (↑(I ^ n) : Set R) = ↑(I ^ n • (⊤ : Ideal R)) simp diff --git a/Mathlib/Topology/Algebra/Nonarchimedean/Completion.lean b/Mathlib/Topology/Algebra/Nonarchimedean/Completion.lean index d84352703a98a9..e1461995043d87 100644 --- a/Mathlib/Topology/Algebra/Nonarchimedean/Completion.lean +++ b/Mathlib/Topology/Algebra/Nonarchimedean/Completion.lean @@ -64,7 +64,6 @@ instance {G : Type*} [AddGroup G] [UniformSpace G] [IsUniformAddGroup G] exact closure_minimal (Set.image_subset_iff.mpr hCW) C_closed /-- The completion of a nonarchimedean ring is a nonarchimedean ring. -/ -instance {R : Type*} [Ring R] [UniformSpace R] [IsTopologicalRing R] [IsUniformAddGroup R] - [NonarchimedeanRing R] : +instance {R : Type*} [Ring R] [UniformSpace R] [IsUniformAddGroup R] [NonarchimedeanRing R] : NonarchimedeanRing (Completion R) where is_nonarchimedean := NonarchimedeanAddGroup.is_nonarchimedean diff --git a/Mathlib/Topology/Algebra/Order/Field.lean b/Mathlib/Topology/Algebra/Order/Field.lean index e5924455049a57..6d6f2c656bd3ec 100644 --- a/Mathlib/Topology/Algebra/Order/Field.lean +++ b/Mathlib/Topology/Algebra/Order/Field.lean @@ -68,7 +68,7 @@ theorem tendsto_inv_atTop_nhdsGT_zero : Tendsto (fun r : 𝕜 => r⁻¹) atTop ( theorem tendsto_nhdsGT_zero_of_comp_inv_tendsto_atTop {f : 𝕜 → α} (h : Tendsto (fun x ↦ f x⁻¹) atTop l) : Tendsto f (𝓝[>] 0) l := by - convert h.comp tendsto_inv_nhdsGT_zero + convert! h.comp tendsto_inv_nhdsGT_zero grind [inv_inv] theorem tendsto_inv_atTop_zero : Tendsto (fun r : 𝕜 => r⁻¹) atTop (𝓝 0) := @@ -199,7 +199,7 @@ theorem tendsto_inv_nhdsLT_zero : Tendsto (fun x : 𝕜 => x⁻¹) (𝓝[<] (0 : theorem tendsto_nhdsLT_zero_of_comp_inv_tendsto_atBot {f : 𝕜 → α} (h : Tendsto (fun x ↦ f x⁻¹) atBot l) : Tendsto f (𝓝[<] 0) l := by - convert h.comp tendsto_inv_nhdsLT_zero + convert! h.comp tendsto_inv_nhdsLT_zero grind /-- The function `r ↦ r⁻¹` tends to `0` on the left as `r → -∞`. -/ @@ -239,7 +239,7 @@ theorem bdd_le_mul_tendsto_zero' {f g : α → 𝕜} (C : 𝕜) (hf : ∀ᶠ x i (hg : Tendsto g l (𝓝 0)) : Tendsto (fun x ↦ f x * g x) l (𝓝 0) := by rw [tendsto_zero_iff_abs_tendsto_zero] have hC : Tendsto (fun x ↦ |C * g x|) l (𝓝 0) := by - convert (hg.const_mul C).abs + convert! (hg.const_mul C).abs simp_rw [mul_zero, abs_zero] apply tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_const_nhds hC · filter_upwards [hf] with x _ using abs_nonneg _ diff --git a/Mathlib/Topology/Algebra/Order/Floor.lean b/Mathlib/Topology/Algebra/Order/Floor.lean index 32f79177081880..fca55d68eb8cb1 100644 --- a/Mathlib/Topology/Algebra/Order/Floor.lean +++ b/Mathlib/Topology/Algebra/Order/Floor.lean @@ -53,7 +53,7 @@ theorem tendsto_mul_pow_div_factorial_sub_atTop (a c : K) (d : ℕ) : theorem tendsto_pow_div_factorial_atTop (c : K) : Tendsto (fun n ↦ c ^ n / n !) atTop (𝓝 0) := by - convert tendsto_mul_pow_div_factorial_sub_atTop 1 c 0 + convert! tendsto_mul_pow_div_factorial_sub_atTop 1 c 0 rw [one_mul] end FloorSemiring diff --git a/Mathlib/Topology/Algebra/ProperAction/Basic.lean b/Mathlib/Topology/Algebra/ProperAction/Basic.lean index 5760e5f9441d43..494afe211b3fb6 100644 --- a/Mathlib/Topology/Algebra/ProperAction/Basic.lean +++ b/Mathlib/Topology/Algebra/ProperAction/Basic.lean @@ -119,7 +119,7 @@ instance t2Space_quotient_mulAction_of_properSMul [ProperSMul G X] : have : IsOpenQuotientMap (Prod.map π π) := MulAction.isOpenQuotientMap_quotientMk.prodMap MulAction.isOpenQuotientMap_quotientMk rw [← this.isQuotientMap.isClosed_preimage] - convert ProperSMul.isProperMap_smul_pair.isClosedMap.isClosed_range + convert! ProperSMul.isProperMap_smul_pair.isClosedMap.isClosed_range · ext ⟨x₁, x₂⟩ simp only [mem_preimage, map_apply, mem_diagonal_iff, mem_range, Prod.mk.injEq, Prod.exists, exists_eq_right] @@ -271,8 +271,9 @@ lemma ProperSMul.isCompact_setOf_inter_nonempty {G : Type*} [Group G] [MulAction G X] [TopologicalSpace G] [ProperSMul G X] {U V : Set X} (hU : IsCompact U) (hV : IsCompact V) : IsCompact {g : G | (g • U ∩ V).Nonempty} := by - convert ((ProperSMul.isProperMap_smul_pair (G := G)).isCompact_preimage - (hV.prod hU)).image continuous_fst + convert! + ((ProperSMul.isProperMap_smul_pair (G := G)).isCompact_preimage (hV.prod hU)).image + continuous_fst ext g suffices (∃ v, v ∈ g • U ∧ v ∈ V) ↔ ∃ u, g • u ∈ V ∧ u ∈ U by simpa rw [← (MulAction.toPerm g).exists_congr_right] diff --git a/Mathlib/Topology/Algebra/RestrictedProduct/TopologicalSpace.lean b/Mathlib/Topology/Algebra/RestrictedProduct/TopologicalSpace.lean index bda5e04f0ef950..47b0e8187ea3cc 100644 --- a/Mathlib/Topology/Algebra/RestrictedProduct/TopologicalSpace.lean +++ b/Mathlib/Topology/Algebra/RestrictedProduct/TopologicalSpace.lean @@ -344,7 +344,8 @@ include hAopen in theorem isOpen_forall_imp_mem_of_principal {S : Set ι} (hS : cofinite ≤ 𝓟 S) {p : ι → Prop} : IsOpen {f : Πʳ i, [R i, A i]_[𝓟 S] | ∀ i, p i → f.1 i ∈ A i} := by rw [le_principal_iff] at hS - convert isOpen_set_pi (hS.inter_of_left {i | p i}) (fun i _ ↦ hAopen i) |>.preimage continuous_coe + convert! + isOpen_set_pi (hS.inter_of_left {i | p i}) (fun i _ ↦ hAopen i) |>.preimage continuous_coe ext f refine ⟨fun H i hi ↦ H i hi.2, fun H i hiT ↦ ?_⟩ by_cases hiS : i ∈ S @@ -354,7 +355,7 @@ theorem isOpen_forall_imp_mem_of_principal {S : Set ι} (hS : cofinite ≤ 𝓟 include hAopen in theorem isOpen_forall_mem_of_principal {S : Set ι} (hS : cofinite ≤ 𝓟 S) : IsOpen {f : Πʳ i, [R i, A i]_[𝓟 S] | ∀ i, f.1 i ∈ A i} := by - convert isOpen_forall_imp_mem_of_principal hAopen hS (p := fun _ ↦ True) + convert! isOpen_forall_imp_mem_of_principal hAopen hS (p := fun _ ↦ True) simp include hAopen in diff --git a/Mathlib/Topology/Algebra/Semigroup.lean b/Mathlib/Topology/Algebra/Semigroup.lean index 0aaa3d7c90a1bd..98f129280c3c51 100644 --- a/Mathlib/Topology/Algebra/Semigroup.lean +++ b/Mathlib/Topology/Algebra/Semigroup.lean @@ -63,7 +63,7 @@ theorem exists_idempotent_of_compact_t2_of_continuous_mul_left {M} [Nonempty M] · obtain rfl | hcnemp := c.eq_empty_or_nonempty · rw [Set.sInter_empty] apply Set.univ_nonempty - convert + convert! @IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed _ _ _ hcnemp.coe_sort ((↑) : c → Set M) ?_ ?_ ?_ ?_ · exact Set.sInter_eq_iInter diff --git a/Mathlib/Topology/Algebra/StarSubalgebra.lean b/Mathlib/Topology/Algebra/StarSubalgebra.lean index a1df756c6cb8d1..577713e2e042a2 100644 --- a/Mathlib/Topology/Algebra/StarSubalgebra.lean +++ b/Mathlib/Topology/Algebra/StarSubalgebra.lean @@ -52,7 +52,7 @@ theorem isClosedEmbedding_inclusion {S₁ S₂ : StarSubalgebra R A} (h : S₁ { IsEmbedding.inclusion h with isClosed_range := isClosed_induced_iff.2 ⟨S₁, hS₁, by - convert (Set.range_subtype_map id _).symm + convert! (Set.range_subtype_map id _).symm · rw [Set.image_id]; rfl · intro _ h' apply h h' ⟩ } diff --git a/Mathlib/Topology/Algebra/UniformConvergence.lean b/Mathlib/Topology/Algebra/UniformConvergence.lean index 74bc74023f6069..3b3a3eb462d10d 100644 --- a/Mathlib/Topology/Algebra/UniformConvergence.lean +++ b/Mathlib/Topology/Algebra/UniformConvergence.lean @@ -223,7 +223,7 @@ instance : IsUniformGroup (α →ᵤ G) := protected theorem UniformFun.hasBasis_nhds_one_of_basis {p : ι → Prop} {b : ι → Set G} (h : (𝓝 1 : Filter G).HasBasis p b) : (𝓝 1 : Filter (α →ᵤ G)).HasBasis p fun i => { f : α →ᵤ G | ∀ x, toFun f x ∈ b i } := by - convert UniformFun.hasBasis_nhds_of_basis α _ (1 : α →ᵤ G) h.uniformity_of_nhds_one + convert! UniformFun.hasBasis_nhds_of_basis α _ (1 : α →ᵤ G) h.uniformity_of_nhds_one simp @[to_additive] @@ -251,8 +251,9 @@ protected theorem UniformOnFun.hasBasis_nhds_one_of_basis (𝔖 : Set <| Set α) (h : (𝓝 1 : Filter G).HasBasis p b) : (𝓝 1 : Filter (α →ᵤ[𝔖] G)).HasBasis (fun Si : Set α × ι => Si.1 ∈ 𝔖 ∧ p Si.2) fun Si => { f : α →ᵤ[𝔖] G | ∀ x ∈ Si.1, toFun 𝔖 f x ∈ b Si.2 } := by - convert UniformOnFun.hasBasis_nhds_of_basis α _ 𝔖 (1 : α →ᵤ[𝔖] G) h𝔖₁ h𝔖₂ <| - h.uniformity_of_nhds_one_swapped + convert! + UniformOnFun.hasBasis_nhds_of_basis α _ 𝔖 (1 : α →ᵤ[𝔖] G) h𝔖₁ h𝔖₂ <| + h.uniformity_of_nhds_one_swapped simp [UniformOnFun.gen] @[to_additive] diff --git a/Mathlib/Topology/Algebra/UniformRing.lean b/Mathlib/Topology/Algebra/UniformRing.lean index b5bec753989c7f..4457f3024d4e62 100644 --- a/Mathlib/Topology/Algebra/UniformRing.lean +++ b/Mathlib/Topology/Algebra/UniformRing.lean @@ -271,10 +271,10 @@ noncomputable def IsDenseInducing.extendRingHom {i : α →+* β} {f : α →+* (ue : IsUniformInducing i) (dr : DenseRange i) (hf : UniformContinuous f) : β →+* γ where toFun := (ue.isDenseInducing dr).extend f map_one' := by - convert IsDenseInducing.extend_eq (ue.isDenseInducing dr) hf.continuous 1 + convert! IsDenseInducing.extend_eq (ue.isDenseInducing dr) hf.continuous 1 exacts [i.map_one.symm, f.map_one.symm] map_zero' := by - convert IsDenseInducing.extend_eq (ue.isDenseInducing dr) hf.continuous 0 <;> + convert! IsDenseInducing.extend_eq (ue.isDenseInducing dr) hf.continuous 0 <;> simp only [map_zero] map_add' := by have h := (uniformContinuous_uniformly_extend ue dr hf).continuous diff --git a/Mathlib/Topology/Algebra/ValuativeRel/ValuativeTopology.lean b/Mathlib/Topology/Algebra/ValuativeRel/ValuativeTopology.lean index 546119a05d24e6..4f98bf5ca7c270 100644 --- a/Mathlib/Topology/Algebra/ValuativeRel/ValuativeTopology.lean +++ b/Mathlib/Topology/Algebra/ValuativeRel/ValuativeTopology.lean @@ -48,7 +48,7 @@ lemma Valuation.exists_setOf_restrict_le_iff {Γ₀ : Type*} [LinearOrderedCommG ∃ γ : (ValueGroupWithZero R)ˣ, {a | valuation R (a - x) < γ} ⊆ s := by refine ⟨fun ⟨r, hr⟩ ↦ ⟨r.mapEquiv (orderMonoidIso v).symm, ?_⟩, fun ⟨r, hr⟩ ↦ ⟨r.mapEquiv (orderMonoidIso v), ?_⟩⟩ - all_goals convert hr; simp + all_goals convert! hr; simp /-- We say that a topology on `R` is valuative if the neighborhoods of `0` in `R` are determined by the valuative relation `· ≤ᵥ ·`. -/ @@ -97,7 +97,7 @@ namespace IsValuativeTopology /-- A variant of `IsValuativeTopology.mem_nhds_iff` using subtraction. -/ lemma mem_nhds_iff' {s : Set R} {x : R} : s ∈ 𝓝 x ↔ ∃ γ : (ValueGroupWithZero R)ˣ, { z | valuation R (z - x) < γ } ⊆ s := by - convert mem_nhds_iff (s := s) using 4 + convert! mem_nhds_iff (s := s) using 4 simp [neg_add_eq_sub] lemma mem_nhds_zero_iff (s : Set R) : @@ -119,7 +119,7 @@ variable (R) in theorem hasBasis_nhds_zero : (𝓝 0).HasBasis (fun _ ↦ True) fun γ : (ValueGroupWithZero R)ˣ ↦ { x | valuation R x < γ } := by - convert hasBasis_nhds (0 : R) + convert! hasBasis_nhds (0 : R) rw [sub_zero] variable (R) in @@ -137,7 +137,7 @@ namespace Valuation lemma mem_nhds_iff {s : Set R} {x : R} : s ∈ 𝓝 x ↔ ∃ γ : (MonoidWithZeroHom.ValueGroup₀ v)ˣ, { z | v.restrict (z - x) < γ.val } ⊆ s := by - convert IsValuativeTopology.mem_nhds_iff (s := s) using 4 + convert! IsValuativeTopology.mem_nhds_iff (s := s) using 4 simpa [neg_add_eq_sub] using v.exists_setOf_restrict_le_iff _ _ lemma mem_nhds_zero_iff (s : Set R) : s ∈ 𝓝 0 ↔ @@ -207,7 +207,7 @@ theorem hasBasis_uniformity : (𝓤 R).HasBasis (fun _ ↦ True) theorem toUniformSpace_eq : _u = @IsTopologicalAddGroup.rightUniformSpace R _ v.subgroups_basis.topology _ := by refine UniformSpace.ext (v.hasBasis_uniformity.eq_of_same_basis ?_) - convert v.subgroups_basis.hasBasis_nhds_zero.comap _ + convert! v.subgroups_basis.hasBasis_nhds_zero.comap _ simp [restrict_lt_iff_lt_embedding, sub_eq_add_neg] theorem cauchy_iff {F : Filter R} : Cauchy F ↔ @@ -238,7 +238,7 @@ theorem toTopologicalSpace_eq : exact congrArg (fun u ↦ @UniformSpace.toTopologicalSpace R u) v.toUniformSpace_eq instance (priority := low) _root_.IsValuativeTopology.isTopologicalRing : IsTopologicalRing R := by - convert (ValuativeRel.nonarchimedeanRing R).toIsTopologicalRing + convert! (ValuativeRel.nonarchimedeanRing R).toIsTopologicalRing exact toTopologicalSpace_eq _ section Discrete @@ -336,7 +336,7 @@ theorem isOpen_sphere {r : ValueGroup₀ v} (hr : r ≠ 0) : around zero `{x | v.restrict x = r}` is closed in the valuative topology. -/ theorem isClosed_sphere (r : ValueGroup₀ v) : IsClosed (X := R) {x | v.restrict x = r} := by rcases eq_or_ne r 0 with rfl | hr - · convert v.isClosed_closedBall 0 using 3 + · convert! v.isClosed_closedBall 0 using 3 exact (le_zero_iff (α := ValueGroup₀ v)).symm exact isClopen_sphere hr |>.isClosed diff --git a/Mathlib/Topology/Algebra/Valued/LocallyCompact.lean b/Mathlib/Topology/Algebra/Valued/LocallyCompact.lean index 9a5e8a36c19b7e..2898d75d54ac16 100644 --- a/Mathlib/Topology/Algebra/Valued/LocallyCompact.lean +++ b/Mathlib/Topology/Algebra/Valued/LocallyCompact.lean @@ -144,7 +144,11 @@ lemma totallyBounded_iff_finite_residueField [(Valued.v : Valuation K Γ₀).Ran simp only [Submodule.Quotient.quot_mk_eq_mk, Ideal.Quotient.mk_eq_mk, Set.mem_univ, IsLocalRing.residue, Set.mem_image, true_implies] refine ⟨y, hy, ?_⟩ - convert (Ideal.Quotient.mk_eq_mk_iff_sub_mem (I := 𝓂[K]) y x).mpr _ + convert! + (Ideal.Quotient.mk_eq_mk_iff_sub_mem (I := 𝓂[K]) y x).mpr + _ + -- TODO: make Valued.maximalIdeal abbreviations instead of def + -- TODO: make Valued.maximalIdeal abbreviations instead of def rw [Valued.maximalIdeal, hp.maximalIdeal_eq, ← SetLike.mem_coe, (Valuation.integer.integers _).coe_span_singleton_eq_setOf_le_v_algebraMap] diff --git a/Mathlib/Topology/Algebra/Valued/ValuationTopology.lean b/Mathlib/Topology/Algebra/Valued/ValuationTopology.lean index ff7ee313d70d76..1d6fa7bce51937 100644 --- a/Mathlib/Topology/Algebra/Valued/ValuationTopology.lean +++ b/Mathlib/Topology/Algebra/Valued/ValuationTopology.lean @@ -167,7 +167,7 @@ theorem hasBasis_uniformity : (𝓤 R).HasBasis (fun _ ↦ True) theorem toUniformSpace_eq : toUniformSpace = @IsTopologicalAddGroup.rightUniformSpace R _ v.subgroups_basis.topology _ := by refine UniformSpace.ext ((hasBasis_uniformity R Γ₀).eq_of_same_basis ?_) - convert v.subgroups_basis.hasBasis_nhds_zero.comap _ + convert! v.subgroups_basis.hasBasis_nhds_zero.comap _ simp_rw [restrict_lt_iff_lt_embedding, sub_eq_add_neg] simp diff --git a/Mathlib/Topology/Algebra/Valued/ValuativeRel.lean b/Mathlib/Topology/Algebra/Valued/ValuativeRel.lean index 57ff65b5a27e0e..6dd6eb229c9ea1 100644 --- a/Mathlib/Topology/Algebra/Valued/ValuativeRel.lean +++ b/Mathlib/Topology/Algebra/Valued/ValuativeRel.lean @@ -57,7 +57,7 @@ instance (priority := low) {R : Type*} [CommRing R] [ValuativeRel R] [UniformSpa «v» := valuation R is_topological_valuation := by simp_rw [Valuation.restrict_lt_iff_lt_embedding] - convert mem_nhds_zero_iff (R := R) + convert! mem_nhds_zero_iff (R := R) simpa [← Valuation.restrict_lt_iff_lt_embedding] using (valuation R).exists_setOf_restrict_le_iff 0 _ diff --git a/Mathlib/Topology/Algebra/Valued/ValuedField.lean b/Mathlib/Topology/Algebra/Valued/ValuedField.lean index dcfb36ad592e1c..6cd1e903fbc472 100644 --- a/Mathlib/Topology/Algebra/Valued/ValuedField.lean +++ b/Mathlib/Topology/Algebra/Valued/ValuedField.lean @@ -242,7 +242,7 @@ theorem continuous_extension : Continuous (Valued.extension : hat K → ValueGro have : (v (1 : K) : Γ₀) ≠ 0 := by rw [Valuation.map_one] exact zero_ne_one.symm - convert Valued.locally_const this + convert! Valued.locally_const this ext x rw [Valuation.map_one, mem_preimage, mem_singleton_iff, mem_setOf_eq] obtain ⟨V, V_in, hV⟩ : ∃ V ∈ 𝓝 (1 : hat K), ∀ x : K, (x : hat K) ∈ V → (v x : Γ₀) = 1 := by @@ -258,7 +258,7 @@ theorem continuous_extension : Continuous (Valued.extension : hat K → ValueGro rw [← one_mul (1 : hat K)] refine Tendsto.mul continuous_fst.continuousAt (Tendsto.comp ?_ continuous_snd.continuousAt) - convert (continuousAt_inv₀ (zero_ne_one.symm : 1 ≠ (0 : hat K))).tendsto + convert! (continuousAt_inv₀ (zero_ne_one.symm : 1 ≠ (0 : hat K))).tendsto exact inv_one.symm rcases tendsto_prod_self_iff.mp this V V_in with ⟨U, U_in, hU⟩ let hatKstar := ({0}ᶜ : Set <| hat K) @@ -370,7 +370,7 @@ lemma exists_coe_eq_v (x : hat K) : ∃ r : K, extensionValuation x = v r := by have h (a b : ValueGroup₀ hv.v) : ValueGroup₀.embedding a = ValueGroup₀.embedding b ↔ a = b := by rw [embedding_strictMono.injective.eq_iff] simp_rw [← hr, ← Valuation.restrict_def, h] - convert valuation_isClosedMap.isClosed_range.preimage (continuous_extension (hv := hv)) + convert! valuation_isClosedMap.isClosed_range.preimage (continuous_extension (hv := hv)) simp_rw [eq_comm (a := extension _)] #adaptation_note /-- Before https://github.com/leanprover/lean4/pull/13166 (replacing grind's canonicalizer with a type-directed normalizer), `grind` closed this @@ -416,7 +416,7 @@ theorem closure_coe_completion_v_mul_v_lt {r s : K} (hr : r ≠ 0) (hs : s ≠ 0 closure ((↑) '' { x : K | v x * v r < v s }) = { x : hat K | extensionValuation x * v r < v s } := by have hrs : v s / v r ≠ 0 := by simp [hr, hs] - convert closure_coe_completion_v_lt (γ := .mk0 _ hrs) using 3 + convert! closure_coe_completion_v_lt (γ := .mk0 _ hrs) using 3 all_goals simp [← lt_div_iff₀, zero_lt_iff, hr] set_option backward.isDefEq.respectTransparency false in @@ -561,14 +561,14 @@ noncomputable instance valuedCompletion : Valued (hat K) Γ₀ where simp refine ⟨fun ⟨γ, h⟩ ↦ ?_, fun ⟨γ, h⟩ ↦ ?_⟩ · use Units.map valueGroup₀_equiv_extensionValuation.toMonoidHom γ - convert h + convert! h apply this · use Units.map valueGroup₀_equiv_extensionValuation.symm.toMonoidHom γ - convert h + convert! h rw [← this] simp [Valuation.restrict_def, restrict₀_apply] simp_rw [← closure_coe_completion_v_lt, Units.coe_map] - convert (hasBasis_nhds_zero K Γ₀).hasBasis_of_isDenseInducing Completion.isDenseInducing_coe + convert! (hasBasis_nhds_zero K Γ₀).hasBasis_of_isDenseInducing Completion.isDenseInducing_coe rw [Valuation.restrict_lt_iff_lt_embedding]; rfl @[simp] @@ -590,7 +590,7 @@ lemma valuedCompletion_surjective_iff : erw [ne_eq, ← embedding_strictMono.injective.eq_iff, embedding_restrict₀ r, hr, map_zero] exact hγ - convert isClosed_univ.sdiff (isOpen_sphere (hat K) hr') using 1 + convert! isClosed_univ.sdiff (isOpen_sphere (hat K) hr') using 1 ext x simp only [← hr, mem_setOf_eq, mem_diff, mem_univ, true_and, ← v.restrict_def, v.restrict_inj] diff --git a/Mathlib/Topology/Algebra/Valued/WithVal.lean b/Mathlib/Topology/Algebra/Valued/WithVal.lean index 8279da9be3bb9d..cb380f7a1a397b 100644 --- a/Mathlib/Topology/Algebra/Valued/WithVal.lean +++ b/Mathlib/Topology/Algebra/Valued/WithVal.lean @@ -62,14 +62,6 @@ section Ring variable [Ring R] (v : Valuation R Γ₀) -instance : Ring (WithVal v) := fast_instance% Equiv.ring { toFun := ofVal, invFun := toVal v } -instance : Inhabited (WithVal v) := ⟨0⟩ -instance : Preorder (WithVal v) := .lift (v ∘ ofVal) - -theorem le_def {v : Valuation R Γ₀} {a b : WithVal v} : a ≤ b ↔ v a.ofVal ≤ v b.ofVal := .rfl - -theorem lt_def {v : Valuation R Γ₀} {a b : WithVal v} : a < b ↔ v a.ofVal < v b.ofVal := .rfl - lemma ofVal_toVal (x : R) : ofVal (toVal v x) = x := rfl @[simp] lemma toVal_ofVal (x : WithVal v) : toVal v (ofVal x) = x := rfl @@ -91,6 +83,18 @@ lemma ofVal_bijective : Function.Bijective (ofVal (v := v)) := lemma toVal_bijective : Function.Bijective (toVal v) := ⟨toVal_injective v, toVal_surjective v⟩ + +instance : Zero (WithVal v) where zero := toVal _ 0 +instance : One (WithVal v) where one := toVal _ 1 +instance : Add (WithVal v) where add x y := toVal _ (x.ofVal + y.ofVal) +instance : Sub (WithVal v) where sub x y := toVal _ (x.ofVal - y.ofVal) +instance : Neg (WithVal v) where neg x := toVal _ (-x.ofVal) +instance : Mul (WithVal v) where mul x y := toVal _ (x.ofVal * y.ofVal) +instance {S} [SMul S R] : SMul S (WithVal v) where smul s x := toVal _ (s • x.ofVal) +instance : Pow (WithVal v) ℕ where pow x n := toVal _ (x.ofVal ^ n) +instance : NatCast (WithVal v) where natCast n := toVal _ n +instance : IntCast (WithVal v) where intCast z := toVal _ z + @[simp] lemma toVal_zero : toVal v 0 = 0 := rfl @[simp] lemma ofVal_zero : ofVal (0 : WithVal v) = 0 := rfl @@ -119,6 +123,11 @@ lemma toVal_bijective : Function.Bijective (toVal v) := @[simp] lemma ofVal_pow (x : WithVal v) (n : ℕ) : ofVal (x ^ n) = (ofVal x) ^ n := rfl +@[simp] theorem toVal_smul {S} [SMul S R] (s : S) (r : R) : toVal v (s • r) = s • toVal v r := rfl + +@[simp] theorem ofVal_smul {S} [SMul S R] (s : S) (x : WithVal v) : ofVal (s • x) = s • ofVal x := + rfl + @[simp] lemma toVal_natCast (n : ℕ) : toVal v n = n := rfl @[simp] lemma ofVal_natCast (n : ℕ) : ofVal (n : WithVal v) = n := rfl @@ -127,9 +136,16 @@ lemma toVal_bijective : Function.Bijective (toVal v) := @[simp] lemma ofVal_intCast (z : ℤ) : ofVal (z : WithVal v) = z := rfl -@[simp] lemma toVal_ofNat (n : ℕ) [n.AtLeastTwo] : toVal v ofNat(n) = ofNat(n) := rfl +instance : Ring (WithVal v) := fast_instance% ofVal_injective v |>.ring _ + (ofVal_zero _) (ofVal_one _) (ofVal_add _) (ofVal_mul _) (ofVal_neg _) (ofVal_sub _) + (ofVal_smul _) (ofVal_smul _) (ofVal_pow _) (ofVal_natCast _) (ofVal_intCast _) + +instance : Inhabited (WithVal v) := ⟨0⟩ +instance : Preorder (WithVal v) := .lift (v ∘ ofVal) -@[simp] lemma ofVal_ofNat (n : ℕ) [n.AtLeastTwo] : ofVal (ofNat(n) : WithVal v) = ofNat(n) := rfl +theorem le_def {v : Valuation R Γ₀} {a b : WithVal v} : a ≤ b ↔ v a.ofVal ≤ v b.ofVal := .rfl + +theorem lt_def {v : Valuation R Γ₀} {a b : WithVal v} : a < b ↔ v a.ofVal < v b.ofVal := .rfl @[simp] lemma toVal_eq_zero (x : R) : toVal v x = 0 ↔ x = 0 := (toVal_injective v).eq_iff @@ -220,8 +236,6 @@ theorem smul_left_def [SMul R S] (x : WithVal v) (s : S) : x • s = ofVal x • instance [SMul R S] [FaithfulSMul R S] : FaithfulSMul (WithVal v) S where eq_of_smul_eq_smul h := ofVal_injective v <| FaithfulSMul.eq_of_smul_eq_smul h -instance [SMul S R] : SMul S (WithVal v) := (equiv v).smul S - theorem smul_right_def [SMul S R] (s : S) (x : WithVal v) : s • x = toVal v (s • ofVal x) := rfl instance [SMul S R] [FaithfulSMul S R] : FaithfulSMul S (WithVal v) where @@ -239,7 +253,7 @@ instance {P : Type*} [Ring S] [SMul P S] [SMul R S] [SMul P R] instance {P : Type*} [Ring S] [SMul P R] [SMul S R] [SMul P S] [IsScalarTower P S R] (v : Valuation S Γ₀) : IsScalarTower P (WithVal v) R where - smul_assoc := by simp [smul_right_def, smul_left_def] + smul_assoc := by simp [smul_right_def, smul_left_def, - toVal_smul] instance [AddCommMonoid S] [Module R S] : Module (WithVal v) S := .compHom S (equiv v).toRingHom @@ -251,10 +265,6 @@ instance [AddCommMonoid S] [Module R S] [Module.Finite R S] : instance [Semiring S] [Module S R] : Module S (WithVal v) := fast_instance% (equiv v).module S -@[simp] theorem toVal_smul [SMul S R] (s : S) (r : R) : toVal v (s • r) = s • toVal v r := rfl - -@[simp] theorem ofVal_smul [SMul S R] (s : S) (x : WithVal v) : ofVal (s • x) = s • ofVal x := rfl - variable [Ring S] [Module R S] (v : Valuation S Γ₀) variable (R) in @@ -327,9 +337,11 @@ section Field variable [Field R] (v : Valuation R Γ₀) -instance : Field (WithVal v) := fast_instance% (equiv v).field - -instance [NumberField R] : NumberField (WithVal v) where +instance : Div (WithVal v) where div x y := toVal _ (x.ofVal / y.ofVal) +instance : Inv (WithVal v) where inv x := toVal _ x.ofVal⁻¹ +instance : Pow (WithVal v) ℤ where pow x z := toVal _ (x.ofVal ^ z) +instance : NNRatCast (WithVal v) where nnratCast q := toVal _ q +instance : RatCast (WithVal v) where ratCast q := toVal _ q @[simp] lemma toVal_div (x y : R) : toVal v (x / y) = toVal v x / toVal v y := rfl @@ -351,6 +363,14 @@ instance [NumberField R] : NumberField (WithVal v) where @[simp] lemma ofVal_ratCast (q : ℚ) : ofVal (q : WithVal v) = q := rfl +instance : Field (WithVal v) := fast_instance% ofVal_injective v |>.field _ + (ofVal_zero _) (ofVal_one _) (ofVal_add _) (ofVal_mul _) (ofVal_neg _) (ofVal_sub _) + (ofVal_inv _) (ofVal_div _) + (ofVal_smul _) (ofVal_smul _) (ofVal_smul _) (ofVal_smul _) (ofVal_pow _) (ofVal_zpow _) + (ofVal_natCast _) (ofVal_intCast _) (ofVal_nnratCast _) (ofVal_ratCast _) + +instance [NumberField R] : NumberField (WithVal v) where + end Field section Ring @@ -615,8 +635,9 @@ theorem IsEquiv.valuedCompletion_le_one_iff {K : Type*} [Field K] {v : Valuation have h1 (x : UniformSpace.Completion (WithVal v)) : Valued.v x ≤ 1 ↔ Valued.v.restrict x ≤ 1 := by rw [restrict_le_one_iff] simp_rw [h1] - convert (mapEquiv h.uniformEquiv).toHomeomorph.isClosed_setOf_iff - (Valued.isClopen_closedBall _ one_ne_zero) (Valued.isClopen_closedBall _ one_ne_zero) + convert! + (mapEquiv h.uniformEquiv).toHomeomorph.isClosed_setOf_iff + (Valued.isClopen_closedBall _ one_ne_zero) (Valued.isClopen_closedBall _ one_ne_zero) rw [restrict_le_one_iff] rfl | ih a => diff --git a/Mathlib/Topology/Baire/LocallyCompactRegular.lean b/Mathlib/Topology/Baire/LocallyCompactRegular.lean index f6a4948b0702f3..b186ca315b7fff 100644 --- a/Mathlib/Topology/Baire/LocallyCompactRegular.lean +++ b/Mathlib/Topology/Baire/LocallyCompactRegular.lean @@ -61,7 +61,7 @@ instance (priority := 100) BaireSpace.of_t2Space_locallyCompactSpace : BaireSpac /-- A Gδ subset of a locally compact R₁ space is Baire. -/ theorem IsGδ.of_t2Space_locallyCompactSpace (hG : IsGδ s) : BaireSpace s := by have : BaireSpace (closure s) := by - convert BaireSpace.of_t2Space_locallyCompactSpace using 1 + convert! BaireSpace.of_t2Space_locallyCompactSpace using 1 · infer_instance · exact isClosed_closure.locallyCompactSpace have : BaireSpace ((↑) ⁻¹' s : Set (closure s)) := diff --git a/Mathlib/Topology/Bases.lean b/Mathlib/Topology/Bases.lean index f451752d9ede71..d46e549da524a9 100644 --- a/Mathlib/Topology/Bases.lean +++ b/Mathlib/Topology/Bases.lean @@ -95,7 +95,7 @@ theorem isTopologicalBasis_of_subbasis {s : Set (Set α)} (hs : t = generateFrom theorem isTopologicalBasis_of_subbasis_of_finiteInter {s : Set (Set α)} (hsg : t = generateFrom s) (hsi : FiniteInter s) : IsTopologicalBasis s := by - convert isTopologicalBasis_of_subbasis hsg + convert! isTopologicalBasis_of_subbasis hsg refine le_antisymm (fun t ht ↦ ⟨{t}, by simpa using ht⟩) ?_ rintro _ ⟨g, ⟨hg, hgs⟩, rfl⟩ lift g to Finset (Set α) using hg @@ -248,7 +248,7 @@ theorem isTopologicalBasis_opens : IsTopologicalBasis { U : Set α | IsOpen U } protected lemma IsTopologicalBasis.isInducing [TopologicalSpace β] {f : α → β} {T : Set (Set β)} (hf : IsInducing f) (h : IsTopologicalBasis T) : IsTopologicalBasis ((preimage f) '' T) := .of_hasBasis_nhds fun a ↦ by - convert (hf.basis_nhds (h.nhds_hasBasis (a := f a))).to_image_id with s + convert! (hf.basis_nhds (h.nhds_hasBasis (a := f a))).to_image_id with s aesop protected theorem IsTopologicalBasis.induced {α} [s : TopologicalSpace β] (f : α → β) @@ -261,7 +261,7 @@ protected theorem IsTopologicalBasis.inf {t₁ t₂ : TopologicalSpace β} {B₁ IsTopologicalBasis (t := t₁ ⊓ t₂) (image2 (· ∩ ·) B₁ B₂) := by refine .of_hasBasis_nhds (t := ?_) fun a ↦ ?_ rw [nhds_inf (t₁ := t₁)] - convert ((h₁.nhds_hasBasis (t := t₁)).inf (h₂.nhds_hasBasis (t := t₂))).to_image_id + convert! ((h₁.nhds_hasBasis (t := t₁)).inf (h₂.nhds_hasBasis (t := t₂))).to_image_id aesop theorem IsTopologicalBasis.inf_induced {γ} [s : TopologicalSpace β] {B₁ : Set (Set α)} @@ -606,7 +606,7 @@ theorem IsTopologicalBasis.iInf_induced {β : Type*} {ι : Type*} {X : ι → Ty IsTopologicalBasis (t := ⨅ i, induced (f i) (t i)) { S | ∃ (U : ∀ i, Set (X i)) (F : Finset ι), (∀ i, i ∈ F → U i ∈ T i) ∧ S = ⋂ (i) (_ : i ∈ F), f i ⁻¹' U i } := by - convert IsTopologicalBasis.iInf (fun i ↦ (cond i).induced (f i)) with S + convert! IsTopologicalBasis.iInf (fun i ↦ (cond i).induced (f i)) with S constructor <;> rintro ⟨U, F, hUT, hSU⟩ · exact ⟨fun i ↦ (f i) ⁻¹' (U i), F, fun i hi ↦ mem_image_of_mem _ (hUT i hi), hSU⟩ · choose! U' hU' hUU' using hUT @@ -991,7 +991,7 @@ lemma IsTopologicalBasis.exists_countable obtain ⟨u, u_mem, xu, uv⟩ : ∃ u ∈ countableBasis α, x ∈ u ∧ u ⊆ v := (isBasis_countableBasis α).isOpen_iff.1 hv _ hx have : x ∈ ⋃ a ∈ s u, a := by - convert xu + convert! xu exact (hs u u_mem).symm obtain ⟨w, ws, xw⟩ : ∃ w ∈ s u, x ∈ w := by simpa using this refine ⟨w, ⟨u, u_mem, ws⟩, xw, ?_⟩ @@ -1045,7 +1045,7 @@ theorem IsTopologicalBasis.sigma {s : ∀ i : ι, Set (Set (E i))} IsTopologicalBasis (⋃ i : ι, (fun u => (Sigma.mk i '' u : Set (Σ i, E i))) '' s i) := by refine .of_hasBasis_nhds fun a ↦ ?_ rw [Sigma.nhds_eq] - convert (((hs a.1).nhds_hasBasis).map _).to_image_id + convert! (((hs a.1).nhds_hasBasis).map _).to_image_id aesop /-- A countable disjoint union of second countable spaces is second countable. -/ diff --git a/Mathlib/Topology/Bornology/BoundedOperation.lean b/Mathlib/Topology/Bornology/BoundedOperation.lean index e7d163c2dcbb38..1d43bfb49c720f 100644 --- a/Mathlib/Topology/Bornology/BoundedOperation.lean +++ b/Mathlib/Topology/Bornology/BoundedOperation.lean @@ -65,7 +65,7 @@ lemma boundedSub_of_lipschitzWith_sub [PseudoMetricSpace R] [Sub R] {K : NNReal} BoundedSub R where isBounded_sub {s t} s_bdd t_bdd := by have bdd : Bornology.IsBounded (s ×ˢ t) := Bornology.IsBounded.prod s_bdd t_bdd - convert lip.isBounded_image bdd + convert! lip.isBounded_image bdd simp end bounded_sub @@ -137,7 +137,7 @@ instance [PseudoMetricSpace R] [Monoid R] [LipschitzMul R] : BoundedMul R where isBounded_mul {s t} s_bdd t_bdd := by have bdd : Bornology.IsBounded (s ×ˢ t) := Bornology.IsBounded.prod s_bdd t_bdd obtain ⟨C, mul_lip⟩ := ‹LipschitzMul R›.lipschitz_mul - convert mul_lip.isBounded_image bdd + convert! mul_lip.isBounded_image bdd ext p simp only [Set.mem_image, Set.mem_prod, Prod.exists] constructor @@ -157,7 +157,7 @@ variable {R : Type*} [SeminormedAddCommGroup R] lemma SeminormedAddCommGroup.lipschitzWith_sub : LipschitzWith 2 (fun (p : R × R) ↦ p.1 - p.2) := by - convert LipschitzWith.prod_fst.sub LipschitzWith.prod_snd + convert! LipschitzWith.prod_fst.sub LipschitzWith.prod_snd norm_num instance : BoundedSub R := boundedSub_of_lipschitzWith_sub SeminormedAddCommGroup.lipschitzWith_sub @@ -177,7 +177,7 @@ lemma tendsto_add_const_cobounded (x : R) : rw [mem_map] rw [← isCobounded_def, ← isBounded_compl_iff] at hs ⊢ rw [← Set.preimage_compl] - convert isBounded_sub hs (t := {x}) isBounded_singleton using 1 + convert! isBounded_sub hs (t := { x }) isBounded_singleton using 1 ext y simp [sub_eq_iff_eq_add] @@ -188,7 +188,7 @@ lemma tendsto_const_add_cobounded (x : R) : rw [mem_map] rw [← isCobounded_def, ← isBounded_compl_iff] at hs ⊢ rw [← Set.preimage_compl] - convert isBounded_add isBounded_singleton (s := {-x}) hs using 1 + convert! isBounded_add isBounded_singleton (s := {-x}) hs using 1 ext y simp diff --git a/Mathlib/Topology/CWComplex/Classical/Finite.lean b/Mathlib/Topology/CWComplex/Classical/Finite.lean index 81fb550da38fa2..b4c1d87a7f7862 100644 --- a/Mathlib/Topology/CWComplex/Classical/Finite.lean +++ b/Mathlib/Topology/CWComplex/Classical/Finite.lean @@ -215,7 +215,7 @@ def RelCWComplex.mkFinite.{u} {X : Type u} [TopologicalSpace X] (C : Set X) simp_rw [Filter.eventually_atTop, ge_iff_le] at eventually_isEmpty_cell obtain ⟨N, hN⟩ := eventually_isEmpty_cell suffices IsClosed (A ∩ (D ∪ ⋃ (n : {n : ℕ // n < N}), ⋃ j, ↑(map n j) '' closedBall 0 1)) by - convert this using 2 + convert! this using 2 rw [← union', iUnion_subtype] congrm D ∪ ⋃ n, ?_ refine subset_antisymm ?_ (iUnion_subset (fun i ↦ by rfl)) diff --git a/Mathlib/Topology/Category/CompHaus/Projective.lean b/Mathlib/Topology/Category/CompHaus/Projective.lean index 01a01dee8e3e4f..7e0935185e3be8 100644 --- a/Mathlib/Topology/Category/CompHaus/Projective.lean +++ b/Mathlib/Topology/Category/CompHaus/Projective.lean @@ -48,7 +48,11 @@ instance projective_ultrafilter (X : Type*) : Projective (of <| Ultrafilter X) w use CompHausLike.ofHom _ ⟨h, hh⟩ apply ConcreteCategory.coe_ext have : g.hom ∘ g' = id := hg'.comp_eq_id - convert denseRange_pure.equalizer (g.hom.hom.continuous.comp hh) f.hom.hom.continuous _ + convert! + denseRange_pure.equalizer (g.hom.hom.continuous.comp hh) f.hom.hom.continuous + _ + -- This used to be `rw`, but we need `rw; rfl` after https://github.com/leanprover/lean4/pull/2644 + -- This used to be `rw`, but we need `rw; rfl` after https://github.com/leanprover/lean4/pull/2644 rw [comp_assoc, ultrafilter_extend_extends, ← comp_assoc, this, id_comp] rfl diff --git a/Mathlib/Topology/Category/CompHausLike/Limits.lean b/Mathlib/Topology/Category/CompHausLike/Limits.lean index d816f67ee06f81..b35aa2b4442b12 100644 --- a/Mathlib/Topology/Category/CompHausLike/Limits.lean +++ b/Mathlib/Topology/Category/CompHausLike/Limits.lean @@ -162,7 +162,7 @@ lemma Sigma.isOpenEmbedding_ι (a : α) : IsOpenEmbedding (Sigma.ι X a) := by refine IsOpenEmbedding.of_comp _ (homeoOfIso ((colimit.isColimit _).coconePointUniqueUpToIso (finiteCoproduct.isColimit X))).isOpenEmbedding ?_ - convert finiteCoproduct.isOpenEmbedding_ι X a + convert! finiteCoproduct.isOpenEmbedding_ι X a ext x change (Sigma.ι X a ≫ _) x = _ simp diff --git a/Mathlib/Topology/Category/LightProfinite/Injective.lean b/Mathlib/Topology/Category/LightProfinite/Injective.lean index 8d5ba576412a97..061b1b2f7108a1 100644 --- a/Mathlib/Topology/Category/LightProfinite/Injective.lean +++ b/Mathlib/Topology/Category/LightProfinite/Injective.lean @@ -104,7 +104,7 @@ lemma exists_lift_of_finite_of_injective_of_surjective {X Y S T : Type*} refine ⟨liftCover C (fun i _ ↦ i) h_glue C_cover_univ, IsLocallyConstant.continuous ?_, ?_, ?_⟩ · rw [IsLocallyConstant.iff_isOpen_fiber] intro s - convert (C_clopen s).2 + convert! (C_clopen s).2 ext y simp [preimage_liftCover] · ext y diff --git a/Mathlib/Topology/Category/Profinite/CofilteredLimit.lean b/Mathlib/Topology/Category/Profinite/CofilteredLimit.lean index 9b09b85cd308de..eaf75ca1a848ba 100644 --- a/Mathlib/Topology/Category/Profinite/CofilteredLimit.lean +++ b/Mathlib/Topology/Category/Profinite/CofilteredLimit.lean @@ -195,7 +195,7 @@ theorem exists_locallyConstant {α : Type*} (hC : IsLimit C) (f : LocallyConstan · suffices ∃ j, IsEmpty (F.obj j) by refine this.imp fun j hj => ?_ refine ⟨⟨hj.elim, fun A => ?_⟩, ?_⟩ - · convert isOpen_empty + · convert! isOpen_empty ext x exact hj.elim x · ext x diff --git a/Mathlib/Topology/Category/Profinite/Nobeling/Basic.lean b/Mathlib/Topology/Category/Profinite/Nobeling/Basic.lean index c60fd18e70b1c2..93873c0c7c3ada 100644 --- a/Mathlib/Topology/Category/Profinite/Nobeling/Basic.lean +++ b/Mathlib/Topology/Category/Profinite/Nobeling/Basic.lean @@ -392,7 +392,7 @@ theorem eval_eq (l : Products I) (x : C) : exact if_pos (h i hi) · simp only [List.map_map, List.prod_eq_zero_iff, List.mem_map, Function.comp_apply] push Not at h - convert h with i + convert! h with i dsimp [LocallyConstant.evalMonoidHom, e] simp only [ite_eq_right_iff, one_ne_zero] diff --git a/Mathlib/Topology/Category/Profinite/Nobeling/Induction.lean b/Mathlib/Topology/Category/Profinite/Nobeling/Induction.lean index 65843652742314..4289fc17787723 100644 --- a/Mathlib/Topology/Category/Profinite/Nobeling/Induction.lean +++ b/Mathlib/Topology/Category/Profinite/Nobeling/Induction.lean @@ -130,11 +130,11 @@ theorem Nobeling.isClosedEmbedding : IsClosedEmbedding (Nobeling.ι S) := by refine ((IsLocallyConstant.tfae _).out 0 3).mpr ?_ rintro ⟨⟩ · refine IsClopen.isOpen (isClopen_compl_iff.mp ?_) - convert C.2 + convert! C.2 ext x simp · refine IsClopen.isOpen ?_ - convert C.2 + convert! C.2 ext x simp only [Set.mem_preimage, Set.mem_singleton_iff, decide_eq_true_eq] · intro a b h diff --git a/Mathlib/Topology/Category/Profinite/Nobeling/Successor.lean b/Mathlib/Topology/Category/Profinite/Nobeling/Successor.lean index e1de02ccb8ae70..42ddb5eeda8e98 100644 --- a/Mathlib/Topology/Category/Profinite/Nobeling/Successor.lean +++ b/Mathlib/Topology/Category/Profinite/Nobeling/Successor.lean @@ -150,7 +150,7 @@ include hsC in theorem swapTrue_mem_C1 (f : π (C1 C ho) (ord I · < o)) : SwapTrue o f.val ∈ C1 C ho := by obtain ⟨f, g, hg, rfl⟩ := f - convert hg + convert! hg dsimp +unfoldPartialApp [SwapTrue] ext i split_ifs with h diff --git a/Mathlib/Topology/Category/Profinite/Projective.lean b/Mathlib/Topology/Category/Profinite/Projective.lean index 22d548d5a59ecb..4a0091b41978cc 100644 --- a/Mathlib/Topology/Category/Profinite/Projective.lean +++ b/Mathlib/Topology/Category/Profinite/Projective.lean @@ -46,7 +46,7 @@ instance projective_ultrafilter (X : Type u) : Projective (of <| Ultrafilter X) use CompHausLike.ofHom _ ⟨h, hh⟩ apply ConcreteCategory.coe_ext simp only [h] - convert denseRange_pure.equalizer (g.hom.hom.continuous.comp hh) f.hom.hom.continuous _ + convert! denseRange_pure.equalizer (g.hom.hom.continuous.comp hh) f.hom.hom.continuous _ have : g.hom ∘ g' = id := hg'.comp_eq_id rw [comp_assoc, ultrafilter_extend_extends, ← comp_assoc, this, id_comp] rfl diff --git a/Mathlib/Topology/Category/TopCat/Basic.lean b/Mathlib/Topology/Category/TopCat/Basic.lean index b13caf15fff8d6..5e6e87949bf89a 100644 --- a/Mathlib/Topology/Category/TopCat/Basic.lean +++ b/Mathlib/Topology/Category/TopCat/Basic.lean @@ -250,7 +250,7 @@ theorem isOpenEmbedding_iff_isIso_comp {X Y Z : TopCat.{u}} (f : X ⟶ Y) (g : Y IsOpenEmbedding (f ≫ g) ↔ IsOpenEmbedding g := by constructor · intro h - convert h.comp (TopCat.homeoOfIso (asIso f).symm).isOpenEmbedding + convert! h.comp (TopCat.homeoOfIso (asIso f).symm).isOpenEmbedding exact congr_arg (DFunLike.coe ∘ ConcreteCategory.hom) (IsIso.inv_hom_id_assoc f g).symm · exact fun h => h.comp (TopCat.homeoOfIso (asIso f)).isOpenEmbedding diff --git a/Mathlib/Topology/Category/TopCat/Limits/Basic.lean b/Mathlib/Topology/Category/TopCat/Limits/Basic.lean index 4c489941c12fbf..69dc595eac1c48 100644 --- a/Mathlib/Topology/Category/TopCat/Limits/Basic.lean +++ b/Mathlib/Topology/Category/TopCat/Limits/Basic.lean @@ -111,7 +111,7 @@ def isLimitConeOfForget (c : Cone (F ⋙ forget)) (hc : IsLimit c) : rw [le_iInf_iff] intro j rw [coinduced_le_iff_le_induced, induced_compose] - convert continuous_iff_le_induced.1 (s.π.app j).hom.continuous + convert! continuous_iff_le_induced.1 (s.π.app j).hom.continuous ext x exact ConcreteCategory.hom_ext_iff.mp (hc.fac ((forget).mapCone s) j) x @@ -224,7 +224,7 @@ def isColimitCoconeOfForget (c : Cocone (F ⋙ forget)) (hc : IsColimit c) : rw [iSup_le_iff] intro j rw [coinduced_le_iff_le_induced, induced_compose] - convert continuous_iff_le_induced.1 (s.ι.app j).hom.continuous + convert! continuous_iff_le_induced.1 (s.ι.app j).hom.continuous ext x exact ConcreteCategory.hom_ext_iff.mp (hc.fac ((forget).mapCocone s) j) x diff --git a/Mathlib/Topology/Category/TopCat/Limits/Cofiltered.lean b/Mathlib/Topology/Category/TopCat/Limits/Cofiltered.lean index 764fdb83bce6d3..a45dbd86b2fd49 100644 --- a/Mathlib/Topology/Category/TopCat/Limits/Cofiltered.lean +++ b/Mathlib/Topology/Category/TopCat/Limits/Cofiltered.lean @@ -47,7 +47,7 @@ theorem isTopologicalBasis_cofiltered_limit (hC : IsLimit C) (T : ∀ j, Set (Se IsTopologicalBasis {U : Set C.pt | ∃ (j : _) (V : Set (F.obj j)), V ∈ T j ∧ U = C.π.app j ⁻¹' V} := by classical - convert IsTopologicalBasis.iInf_induced hT fun j (x : C.pt) => C.π.app j x using 1 + convert! IsTopologicalBasis.iInf_induced hT fun j (x : C.pt) => C.π.app j x using 1 · exact induced_of_isLimit C hC ext U0 constructor diff --git a/Mathlib/Topology/Category/TopCat/Limits/Pullbacks.lean b/Mathlib/Topology/Category/TopCat/Limits/Pullbacks.lean index 49881b17a94fe2..f555405a1f9fe6 100644 --- a/Mathlib/Topology/Category/TopCat/Limits/Pullbacks.lean +++ b/Mathlib/Topology/Category/TopCat/Limits/Pullbacks.lean @@ -156,13 +156,13 @@ def pullbackHomeoPreimage intro x ext <;> dsimp apply hg.injective - convert x.prop + convert! x.prop exact Exists.choose_spec (p := fun y ↦ g y = f (↑x : X × Y).1) _ continuous_toFun := by fun_prop continuous_invFun := by apply Continuous.subtype_mk refine continuous_subtype_val.prodMk <| hg.isInducing.continuous_iff.mpr ?_ - convert hf.comp continuous_subtype_val + convert! hf.comp continuous_subtype_val ext x exact Exists.choose_spec x.2 @@ -280,29 +280,32 @@ theorem pullback_map_isOpenEmbedding {W X Y Z S T : TopCat.{u}} (f₁ : W ⟶ S) set_option backward.isDefEq.respectTransparency false in lemma snd_isEmbedding_of_left {X Y S : TopCat.{u}} {f : X ⟶ S} (H : IsEmbedding f) (g : Y ⟶ S) : IsEmbedding <| ⇑(pullback.snd f g) := by - convert (homeoOfIso (asIso (pullback.snd (𝟙 S) g))).isEmbedding.comp - (pullback_map_isEmbedding (i₂ := 𝟙 Y) - f g (𝟙 S) g H (homeoOfIso (Iso.refl _)).isEmbedding (𝟙 _) rfl (by simp)) + convert! + (homeoOfIso (asIso (pullback.snd (𝟙 S) g))).isEmbedding.comp + (pullback_map_isEmbedding (i₂ := 𝟙 Y) f g (𝟙 S) g H (homeoOfIso (Iso.refl _)).isEmbedding + (𝟙 _) rfl (by simp)) simp [homeoOfIso, ← coe_comp] set_option backward.isDefEq.respectTransparency false in theorem fst_isEmbedding_of_right {X Y S : TopCat.{u}} (f : X ⟶ S) {g : Y ⟶ S} (H : IsEmbedding g) : IsEmbedding <| ⇑(pullback.fst f g) := by - convert (homeoOfIso (asIso (pullback.fst f (𝟙 S)))).isEmbedding.comp - (pullback_map_isEmbedding (i₁ := 𝟙 X) - f g f (𝟙 _) (homeoOfIso (Iso.refl _)).isEmbedding H (𝟙 _) rfl (by simp)) + convert! + (homeoOfIso (asIso (pullback.fst f (𝟙 S)))).isEmbedding.comp + (pullback_map_isEmbedding (i₁ := 𝟙 X) f g f (𝟙 _) (homeoOfIso (Iso.refl _)).isEmbedding H + (𝟙 _) rfl (by simp)) simp [homeoOfIso, ← coe_comp] theorem isEmbedding_of_pullback {X Y S : TopCat.{u}} {f : X ⟶ S} {g : Y ⟶ S} (H₁ : IsEmbedding f) (H₂ : IsEmbedding g) : IsEmbedding (limit.π (cospan f g) WalkingCospan.one) := by - convert H₂.comp (snd_isEmbedding_of_left H₁ g) + convert! H₂.comp (snd_isEmbedding_of_left H₁ g) rw [← coe_comp, ← limit.w _ WalkingCospan.Hom.inr] rfl set_option backward.isDefEq.respectTransparency false in theorem snd_isOpenEmbedding_of_left {X Y S : TopCat.{u}} {f : X ⟶ S} (H : IsOpenEmbedding f) (g : Y ⟶ S) : IsOpenEmbedding <| ⇑(pullback.snd f g) := by - convert (homeoOfIso (asIso (pullback.snd (𝟙 S) g))).isOpenEmbedding.comp + convert! + (homeoOfIso (asIso (pullback.snd (𝟙 S) g))).isOpenEmbedding.comp (pullback_map_isOpenEmbedding (i₂ := 𝟙 Y) f g (𝟙 _) g H (homeoOfIso (Iso.refl _)).isOpenEmbedding (𝟙 _) rfl (by simp)) simp [homeoOfIso, ← coe_comp] @@ -310,7 +313,8 @@ theorem snd_isOpenEmbedding_of_left {X Y S : TopCat.{u}} {f : X ⟶ S} (H : IsOp set_option backward.isDefEq.respectTransparency false in theorem fst_isOpenEmbedding_of_right {X Y S : TopCat.{u}} (f : X ⟶ S) {g : Y ⟶ S} (H : IsOpenEmbedding g) : IsOpenEmbedding <| ⇑(pullback.fst f g) := by - convert (homeoOfIso (asIso (pullback.fst f (𝟙 S)))).isOpenEmbedding.comp + convert! + (homeoOfIso (asIso (pullback.fst f (𝟙 S)))).isOpenEmbedding.comp (pullback_map_isOpenEmbedding (i₁ := 𝟙 X) f g f (𝟙 _) (homeoOfIso (Iso.refl _)).isOpenEmbedding H (𝟙 _) rfl (by simp)) simp [homeoOfIso, ← coe_comp] @@ -319,7 +323,7 @@ theorem fst_isOpenEmbedding_of_right {X Y S : TopCat.{u}} (f : X ⟶ S) {g : Y theorem isOpenEmbedding_of_pullback {X Y S : TopCat.{u}} {f : X ⟶ S} {g : Y ⟶ S} (H₁ : IsOpenEmbedding f) (H₂ : IsOpenEmbedding g) : IsOpenEmbedding (limit.π (cospan f g) WalkingCospan.one) := by - convert H₂.comp (snd_isOpenEmbedding_of_left H₁ g) + convert! H₂.comp (snd_isOpenEmbedding_of_left H₁ g) rw [← coe_comp, ← limit.w _ WalkingCospan.Hom.inr] rfl @@ -333,7 +337,7 @@ theorem fst_iso_of_right_embedding_range_subset {X Y S : TopCat.{u}} (f : X ⟶ ⟨x, by rw [pullback_fst_range] exact ⟨_, (H (Set.mem_range_self x)).choose_spec.symm⟩⟩ } - convert (isoOfHomeo esto).isIso_hom + convert! (isoOfHomeo esto).isIso_hom theorem snd_iso_of_left_embedding_range_subset {X Y S : TopCat.{u}} {f : X ⟶ S} (hf : IsEmbedding f) (g : Y ⟶ S) (H : Set.range g ⊆ Set.range f) : IsIso (pullback.snd f g) := by @@ -344,7 +348,7 @@ theorem snd_iso_of_left_embedding_range_subset {X Y S : TopCat.{u}} {f : X ⟶ S ⟨x, by rw [pullback_snd_range] exact ⟨_, (H (Set.mem_range_self x)).choose_spec⟩⟩ } - convert (isoOfHomeo esto).isIso_hom + convert! (isoOfHomeo esto).isIso_hom theorem pullback_snd_image_fst_preimage (f : X ⟶ Z) (g : Y ⟶ Z) (U : Set X) : (pullback.snd f g) '' (pullback.fst f g) ⁻¹' U = @@ -359,7 +363,7 @@ theorem pullback_snd_image_fst_preimage (f : X ⟶ Z) (g : Y ⟶ Z) (U : Set X) -- `exact ⟨(TopCat.pullbackIsoProdSubtype f g).inv ⟨⟨_, _⟩, eq⟩, by simpa, by simp⟩` before https://github.com/leanprover-community/mathlib4/pull/13170 refine ⟨(TopCat.pullbackIsoProdSubtype f g).inv ⟨⟨_, _⟩, eq⟩, ?_, ?_⟩ · simp only [coe_of, Set.mem_preimage] - convert hy + convert! hy rw [pullbackIsoProdSubtype_inv_fst_apply] · rw [pullbackIsoProdSubtype_inv_snd_apply] @@ -378,7 +382,7 @@ theorem pullback_fst_image_snd_preimage (f : X ⟶ Z) (g : Y ⟶ Z) (U : Set Y) -- before https://github.com/leanprover-community/mathlib4/pull/13170 refine ⟨(TopCat.pullbackIsoProdSubtype f g).inv ⟨⟨_, _⟩, eq.symm⟩, ?_, ?_⟩ · simp only [coe_of, Set.mem_preimage] - convert hy + convert! hy rw [pullbackIsoProdSubtype_inv_snd_apply] · rw [pullbackIsoProdSubtype_inv_fst_apply] diff --git a/Mathlib/Topology/Category/TopCat/Sphere.lean b/Mathlib/Topology/Category/TopCat/Sphere.lean index 5edecbd2bee763..05a0ef143b1efb 100644 --- a/Mathlib/Topology/Category/TopCat/Sphere.lean +++ b/Mathlib/Topology/Category/TopCat/Sphere.lean @@ -83,11 +83,11 @@ instance {n : ℕ} : Mono (ballInclusion n) := TopCat.mono_iff_injective _ |>.mp congr instance (n : ℕ) : CompactSpace (𝔻 n) := by - convert Homeomorph.compactSpace Homeomorph.ulift.symm + convert! Homeomorph.compactSpace Homeomorph.ulift.symm infer_instance instance (n : ℕ) : CompactSpace (∂𝔻 n) := by - convert Homeomorph.compactSpace Homeomorph.ulift.symm + convert! Homeomorph.compactSpace Homeomorph.ulift.symm infer_instance end TopCat diff --git a/Mathlib/Topology/Clopen.lean b/Mathlib/Topology/Clopen.lean index d1c6a65fa37f1a..0d21251cbe4fe1 100644 --- a/Mathlib/Topology/Clopen.lean +++ b/Mathlib/Topology/Clopen.lean @@ -101,7 +101,7 @@ theorem isClopen_inter_of_disjoint_cover_clopen {s a b : Set X} (h : IsClopen s) (ha : IsOpen a) (hb : IsOpen b) (hab : Disjoint a b) : IsClopen (s ∩ a) := by refine ⟨?_, IsOpen.inter h.2 ha⟩ have : IsClosed (s ∩ bᶜ) := IsClosed.inter h.1 (isClosed_compl_iff.2 hb) - convert this using 1 + convert! this using 1 refine (inter_subset_inter_right s hab.subset_compl_right).antisymm ?_ rintro x ⟨hx₁, hx₂⟩ exact ⟨hx₁, by simpa [notMem_of_mem_compl hx₂] using cover hx₁⟩ diff --git a/Mathlib/Topology/CompactOpen.lean b/Mathlib/Topology/CompactOpen.lean index 05eae8f49e1193..e470152c297db6 100644 --- a/Mathlib/Topology/CompactOpen.lean +++ b/Mathlib/Topology/CompactOpen.lean @@ -339,7 +339,7 @@ theorem compactOpen_eq_iInf_induced : refine le_antisymm (le_iInf₂ fun s _ ↦ compactOpen_le_induced s) ?_ refine le_generateFrom <| forall_mem_image2.2 fun K (hK : IsCompact K) U hU ↦ ?_ refine TopologicalSpace.le_def.1 (iInf₂_le K hK) _ ?_ - convert isOpen_induced (isOpen_setOf_mapsTo (isCompact_iff_isCompact_univ.1 hK) hU) + convert! isOpen_induced (isOpen_setOf_mapsTo (isCompact_iff_isCompact_univ.1 hK) hU) simp [Subtype.forall, MapsTo] theorem nhds_compactOpen_eq_iInf_nhds_induced (f : C(X, Y)) : diff --git a/Mathlib/Topology/Compactification/StoneCech.lean b/Mathlib/Topology/Compactification/StoneCech.lean index 48a69aa742890c..d2e261792e3636 100644 --- a/Mathlib/Topology/Compactification/StoneCech.lean +++ b/Mathlib/Topology/Compactification/StoneCech.lean @@ -74,7 +74,7 @@ theorem ultrafilter_isOpen_basic (s : Set α) : IsOpen { u : Ultrafilter α | s /-- The basic open sets for the topology on ultrafilters are also closed. -/ theorem ultrafilter_isClosed_basic (s : Set α) : IsClosed { u : Ultrafilter α | s ∈ u } := by rw [← isOpen_compl_iff] - convert ultrafilter_isOpen_basic sᶜ using 1 + convert! ultrafilter_isOpen_basic sᶜ using 1 ext u exact Ultrafilter.compl_mem_iff_notMem.symm @@ -252,7 +252,7 @@ theorem continuous_preStoneCechUnit : Continuous (preStoneCechUnit : α → PreS rfl have : (map preStoneCechUnit g : Filter (PreStoneCech α)) ≤ 𝓝 (Quot.mk _ g) := (map_mono this).trans (continuous_quot_mk.tendsto _) - convert this + convert! this exact Quot.sound ⟨x, pure_le_nhds x, gx⟩ theorem denseRange_preStoneCechUnit : DenseRange (preStoneCechUnit : α → PreStoneCech α) := diff --git a/Mathlib/Topology/Compactness/Compact.lean b/Mathlib/Topology/Compactness/Compact.lean index e92f082402486e..b9f0f85f820727 100644 --- a/Mathlib/Topology/Compactness/Compact.lean +++ b/Mathlib/Topology/Compactness/Compact.lean @@ -113,7 +113,7 @@ theorem IsCompact.image_of_continuousOn {f : X → Y} (hs : IsCompact s) (hf : C haveI := hx.neBot use f x, mem_image_of_mem f hxs have : Tendsto f (𝓝 x ⊓ (comap f l ⊓ 𝓟 s)) (𝓝 (f x) ⊓ l) := by - convert (hf x hxs).inf (@tendsto_comap _ _ f l) using 1 + convert! (hf x hxs).inf (@tendsto_comap _ _ f l) using 1 rw [nhdsWithin] ac_rfl exact this.neBot @@ -1155,7 +1155,7 @@ theorem isCompact_pi_infinite {s : ∀ i, Set (X i)} : /-- **Tychonoff's theorem** formulated using `Set.pi`: product of compact sets is compact. -/ theorem isCompact_univ_pi {s : ∀ i, Set (X i)} (h : ∀ i, IsCompact (s i)) : IsCompact (pi univ s) := by - convert isCompact_pi_infinite h + convert! isCompact_pi_infinite h simp only [← mem_univ_pi, setOf_mem_eq] instance Pi.compactSpace [∀ i, CompactSpace (X i)] : CompactSpace (∀ i, X i) := diff --git a/Mathlib/Topology/Compactness/CompactSystem.lean b/Mathlib/Topology/Compactness/CompactSystem.lean index a7dccf8b717d84..11e01cc117c7a1 100644 --- a/Mathlib/Topology/Compactness/CompactSystem.lean +++ b/Mathlib/Topology/Compactness/CompactSystem.lean @@ -172,7 +172,7 @@ theorem isCompactSystem_isCompact_isClosed (α : Type*) [TopologicalSpace α] : /-- In a `T2Space` the set of compact sets is a compact system. -/ theorem isCompactSystem_isCompact (α : Type*) [TopologicalSpace α] [T2Space α] : IsCompactSystem {s : Set α | IsCompact s} := by - convert isCompactSystem_isCompact_isClosed α with s + convert! isCompactSystem_isCompact_isClosed α with s simpa using IsCompact.isClosed /-- The set of sets which are either compact and closed, or `univ`, is a compact system. -/ diff --git a/Mathlib/Topology/Compactness/Lindelof.lean b/Mathlib/Topology/Compactness/Lindelof.lean index f2d29cca699945..78b8fdaf7ef8b7 100644 --- a/Mathlib/Topology/Compactness/Lindelof.lean +++ b/Mathlib/Topology/Compactness/Lindelof.lean @@ -108,7 +108,7 @@ theorem IsLindelof.image_of_continuousOn {f : X → Y} (hs : IsLindelof s) (hf : haveI := hx.neBot use f x, mem_image_of_mem f hxs have : Tendsto f (𝓝 x ⊓ (comap f l ⊓ 𝓟 s)) (𝓝 (f x) ⊓ l) := by - convert (hf x hxs).inf (@tendsto_comap _ _ f l) using 1 + convert! (hf x hxs).inf (@tendsto_comap _ _ f l) using 1 rw [nhdsWithin] ac_rfl exact this.neBot diff --git a/Mathlib/Topology/Connected/CardComponents.lean b/Mathlib/Topology/Connected/CardComponents.lean index 34224be42638e1..19185b97ebdb50 100644 --- a/Mathlib/Topology/Connected/CardComponents.lean +++ b/Mathlib/Topology/Connected/CardComponents.lean @@ -64,7 +64,7 @@ lemma IsOpenMap.enatCard_connectedComponents_le_encard_preimage_singleton [Conne · simp · rw [finsum_eq_sum_of_fintype] refine Fintype.sum_mono fun i ↦ Set.one_le_encard_iff_nonempty.mpr (show y ∈ f '' (U i) from ?_) - convert Set.mem_univ y + convert! Set.mem_univ y exact IsClopen.eq_univ ⟨hf₂ _ (hU1 i).1, hf₁ _ (hU1 i).2⟩ ((hU2 i).image f) lemma IsOpenMap.finite_connectedComponents_of_finite_preimage_singleton_of_connectedSpace @@ -93,7 +93,7 @@ lemma IsOpenMap.finite_connectedComponents_of_finite_preimage_singleton (hf₁.restrictPreimage (connectedComponent y)) (hf₂.restrictPreimage (connectedComponent y)) (y := ⟨y, mem_connectedComponent⟩) ?_ rw [← Set.finite_image_iff Subtype.val_injective.injOn] - convert h y + convert! h y aesop (add safe mem_connectedComponent) end diff --git a/Mathlib/Topology/Connected/PathConnected.lean b/Mathlib/Topology/Connected/PathConnected.lean index 46e8b52415fa8e..4f062ef7f1aec4 100644 --- a/Mathlib/Topology/Connected/PathConnected.lean +++ b/Mathlib/Topology/Connected/PathConnected.lean @@ -565,7 +565,7 @@ variable [PathConnectedSpace X] def somePath (x y : X) : Path x y := Nonempty.some (joined x y) -instance [PathConnectedSpace X] : Subsingleton (ZerothHomotopy X) := +instance : Subsingleton (ZerothHomotopy X) := (pathConnectedSpace_iff_zerothHomotopy.1 inferInstance).2 end PathConnectedSpace diff --git a/Mathlib/Topology/Connected/TotallyDisconnected.lean b/Mathlib/Topology/Connected/TotallyDisconnected.lean index f6fba4876114c5..d3db5708dc348c 100644 --- a/Mathlib/Topology/Connected/TotallyDisconnected.lean +++ b/Mathlib/Topology/Connected/TotallyDisconnected.lean @@ -258,7 +258,7 @@ def Continuous.connectedComponentsLift (h : Continuous f) : ConnectedComponents @[continuity] theorem Continuous.connectedComponentsLift_continuous (h : Continuous f) : Continuous h.connectedComponentsLift := - h.quotient_liftOn' <| by convert h.image_eq_of_connectedComponent_eq + h.quotient_liftOn' <| by convert! h.image_eq_of_connectedComponent_eq @[simp] theorem Continuous.connectedComponentsLift_apply_coe (h : Continuous f) (x : α) : diff --git a/Mathlib/Topology/Constructible.lean b/Mathlib/Topology/Constructible.lean index e8fe3c95171a0c..ba2cb248d539fb 100644 --- a/Mathlib/Topology/Constructible.lean +++ b/Mathlib/Topology/Constructible.lean @@ -304,8 +304,10 @@ lemma _root_.QuasiSeparatedSpace.of_isOpenCover {ι : Type*} {U : ι → Opens X QuasiSeparatedSpace X where inter_isCompact V₁ V₂ ho₁ hc₁ ho₂ hc₂ := by obtain ⟨t, ht⟩ := hc₁.elim_finite_subcover _ (fun i ↦ (U i).2) (by simp [hU.iSup_set_eq_univ]) - convert t.isCompact_biUnion fun i _ ↦ h₂ i _ _ Set.inter_subset_left ((U i).2.inter ho₁) - (h₁ i hc₁ ho₁) Set.inter_subset_left ((U i).2.inter ho₂) (h₁ i hc₂ ho₂) + convert! + t.isCompact_biUnion fun i _ ↦ + h₂ i _ _ Set.inter_subset_left ((U i).2.inter ho₁) (h₁ i hc₁ ho₁) Set.inter_subset_left + ((U i).2.inter ho₂) (h₁ i hc₂ ho₂) apply subset_antisymm · rintro x ⟨hx₁, hx₂⟩ obtain ⟨i, hi, hxi⟩ := Set.mem_iUnion₂.mp (ht hx₁) @@ -477,7 +479,7 @@ lemma IsLocallyConstructible.isConstructible_of_subset_of_isCompact ⟨V, hV₁, hV₂, hxV, this⟩ choose U hU hU' hxU hUs using this obtain ⟨σ, hσ, htσ⟩ := ht.elim_nhds_subcover U (fun x _ ↦ (hU x).mem_nhds (hxU x)) - convert IsConstructible.biUnion σ.finite_toSet (fun x _ ↦ hUs x) + convert! IsConstructible.biUnion σ.finite_toSet (fun x _ ↦ hUs x) apply subset_antisymm · rw [← Set.iUnion₂_inter, Set.subset_inter_iff] exact ⟨hst.trans htσ, subset_rfl⟩ @@ -509,7 +511,7 @@ lemma IsLocallyConstructible.of_isOpenCover let e : V ≃ₜ Subtype.val '' V := (Equiv.Set.image _ V Subtype.val_injective).toHomeomorphOfIsInducing ((U i).2.isOpenEmbedding_subtypeVal.restrict (by simp [MapsTo]) hV).isInducing - convert hV'.preimage_of_isOpenEmbedding e.symm.isOpenEmbedding + convert! hV'.preimage_of_isOpenEmbedding e.symm.isOpenEmbedding ext ⟨_, x, hx, rfl⟩ simp [e, Equiv.toHomeomorphOfIsInducing] diff --git a/Mathlib/Topology/Constructions.lean b/Mathlib/Topology/Constructions.lean index 6c2daa06e4a9dc..03c4a57177fd18 100644 --- a/Mathlib/Topology/Constructions.lean +++ b/Mathlib/Topology/Constructions.lean @@ -415,12 +415,12 @@ theorem Continuous.subtype_mk {f : Y → X} (h : Continuous f) (hp : ∀ x, p (f theorem IsOpenMap.subtype_mk {f : Y → X} (hf : IsOpenMap f) (hp : ∀ x, p (f x)) : IsOpenMap fun x ↦ (⟨f x, hp x⟩ : Subtype p) := fun u hu ↦ by - convert (hf u hu).preimage continuous_subtype_val + convert! (hf u hu).preimage continuous_subtype_val exact Set.ext fun _ ↦ exists_congr fun _ ↦ and_congr_right' Subtype.ext_iff theorem IsClosedMap.subtype_mk {f : Y → X} (hf : IsClosedMap f) (hp : ∀ x, p (f x)) : IsClosedMap fun x ↦ (⟨f x, hp x⟩ : Subtype p) := fun u hu ↦ by - convert (hf u hu).preimage continuous_subtype_val + convert! (hf u hu).preimage continuous_subtype_val exact Set.ext fun _ ↦ exists_congr fun _ ↦ and_congr_right' Subtype.ext_iff @[fun_prop] diff --git a/Mathlib/Topology/Constructions/SumProd.lean b/Mathlib/Topology/Constructions/SumProd.lean index d311151fb14adf..47f5604db505be 100644 --- a/Mathlib/Topology/Constructions/SumProd.lean +++ b/Mathlib/Topology/Constructions/SumProd.lean @@ -812,7 +812,7 @@ theorem isClosedMap_sum {f : X ⊕ Y → Z} : exact ⟨h.comp IsClosedEmbedding.inl.isClosedMap, h.comp IsClosedEmbedding.inr.isClosedMap⟩ · rintro h Z hZ rw [isClosed_sum_iff] at hZ - convert (h.1 _ hZ.1).union (h.2 _ hZ.2) + convert! (h.1 _ hZ.1).union (h.2 _ hZ.2) ext simp only [mem_image, Sum.exists, mem_union, mem_preimage] @@ -951,7 +951,7 @@ theorem Topology.IsInducing.sumElim (hf : IsInducing f) (hg : IsInducing g) obtain x | x := x <;> simp only [comap_sumElim_eq, nhds_inl, nhds_inr, elim_inl, elim_inr, ← hf.nhds_eq_comap, ← hg.nhds_eq_comap, sup_le_iff, le_rfl, true_and, and_true] <;> - convert bot_le (α := Filter (X ⊕ Y)) <;> + convert! bot_le (α := Filter (X ⊕ Y)) <;> rw [map_eq_bot_iff, comap_eq_bot_iff_compl_range] · rw [← disjoint_principal_right] exact hfG.mono_left (nhds_le_nhdsSet (mem_range_self x)) diff --git a/Mathlib/Topology/ContinuousMap/Basic.lean b/Mathlib/Topology/ContinuousMap/Basic.lean index f9aee2b0b3522a..876e093cb0da1c 100644 --- a/Mathlib/Topology/ContinuousMap/Basic.lean +++ b/Mathlib/Topology/ContinuousMap/Basic.lean @@ -442,7 +442,7 @@ noncomputable def homeomorph (hf : IsQuotientMap f) : Quotient (Setoid.ker f) continuous_toFun := isQuotientMap_quot_mk.continuous_iff.mpr hf.continuous continuous_invFun := by rw [hf.continuous_iff] - convert continuous_quotient_mk' + convert! continuous_quotient_mk' ext simp only [Equiv.invFun_as_coe, Function.comp_apply, (Setoid.quotientKerEquivOfSurjective f hf.surjective).symm_apply_eq] diff --git a/Mathlib/Topology/ContinuousMap/Bounded/Basic.lean b/Mathlib/Topology/ContinuousMap/Bounded/Basic.lean index db450514f732aa..08c2ea4fe0598d 100644 --- a/Mathlib/Topology/ContinuousMap/Bounded/Basic.lean +++ b/Mathlib/Topology/ContinuousMap/Bounded/Basic.lean @@ -179,7 +179,7 @@ theorem dist_lt_iff_of_compact [CompactSpace α] (C0 : (0 : ℝ) < C) : · by_cases h : Nonempty α · exact dist_lt_of_nonempty_compact · rintro - - convert C0 + convert! C0 apply le_antisymm _ dist_nonneg' rw [dist_eq] exact csInf_le ⟨0, fun C => And.left⟩ ⟨le_rfl, fun x => False.elim (h (Nonempty.intro x))⟩ diff --git a/Mathlib/Topology/ContinuousMap/Ideals.lean b/Mathlib/Topology/ContinuousMap/Ideals.lean index 57a7446e8ad7ac..459d6dee6c7e11 100644 --- a/Mathlib/Topology/ContinuousMap/Ideals.lean +++ b/Mathlib/Topology/ContinuousMap/Ideals.lean @@ -102,7 +102,7 @@ variable {R} theorem mem_idealOfSet {s : Set X} {f : C(X, R)} : f ∈ idealOfSet R s ↔ ∀ ⦃x : X⦄, x ∈ sᶜ → f x = 0 := by - convert Iff.rfl + convert! Iff.rfl theorem notMem_idealOfSet {s : Set X} {f : C(X, R)} : f ∉ idealOfSet R s ↔ ∃ x ∈ sᶜ, f x ≠ 0 := by simp_rw [mem_idealOfSet]; push Not; rfl @@ -244,13 +244,13 @@ theorem idealOfSet_ofIdeal_eq_closure (I : Ideal C(X, 𝕜)) : have : ∃ g' : C(X, ℝ≥0), (algebraMapCLM ℝ≥0 𝕜 : C(ℝ≥0, 𝕜)).comp g' ∈ I ∧ ∀ x ∈ t, 0 < g' x := by refine ht.isCompact.induction_on ?_ ?_ ?_ ?_ · refine ⟨0, ?_, fun x hx => False.elim hx⟩ - convert I.zero_mem + convert! I.zero_mem ext simp only [comp_apply, zero_apply, ContinuousMap.coe_coe, map_zero] · rintro s₁ s₂ hs ⟨g, hI, hgt⟩; exact ⟨g, hI, fun x hx => hgt x (hs hx)⟩ · rintro s₁ s₂ ⟨g₁, hI₁, hgt₁⟩ ⟨g₂, hI₂, hgt₂⟩ refine ⟨g₁ + g₂, ?_, fun x hx => ?_⟩ - · convert I.add_mem hI₁ hI₂ + · convert! I.add_mem hI₁ hI₂ ext y simp · rcases hx with (hx | hx) @@ -266,7 +266,7 @@ theorem idealOfSet_ofIdeal_eq_closure (I : Ideal C(X, 𝕜)) : mem_nhdsWithin_iff_exists_mem_nhds_inter.mpr ⟨_, this, Set.Subset.rfl⟩, ⟨⟨fun x => ‖g x‖₊ ^ 2, (map_continuous g).nnnorm.pow 2⟩, ?_, fun x hx => pow_pos (norm_pos_iff.mpr hx.1) 2⟩⟩ - convert I.mul_mem_left (star g) hI + convert! I.mul_mem_left (star g) hI ext simp only [comp_apply, ContinuousMap.coe_coe, coe_mk, algebraMapCLM_apply, map_pow, mul_apply, star_apply, star_def] @@ -283,7 +283,7 @@ theorem idealOfSet_ofIdeal_eq_closure (I : Ideal C(X, 𝕜)) : ⟨g' x, hgt' x hx, hx'⟩ obtain ⟨g, hg, hgc⟩ := exists_mul_le_one_eqOn_ge g' hc refine ⟨g * g', ?_, hg, hgc.mono hgc'⟩ - convert I.mul_mem_left ((algebraMapCLM ℝ≥0 𝕜 : C(ℝ≥0, 𝕜)).comp g) hI' + convert! I.mul_mem_left ((algebraMapCLM ℝ≥0 𝕜 : C(ℝ≥0, 𝕜)).comp g) hI' ext simp only [coe_algebraMapCLM, comp_apply, mul_apply, ContinuousMap.coe_coe, map_mul] diff --git a/Mathlib/Topology/ContinuousMap/Periodic.lean b/Mathlib/Topology/ContinuousMap/Periodic.lean index 345c409eefe8e1..d06265a3841a15 100644 --- a/Mathlib/Topology/ContinuousMap/Periodic.lean +++ b/Mathlib/Topology/ContinuousMap/Periodic.lean @@ -32,7 +32,9 @@ theorem periodic_tsum_comp_add_zsmul [AddCommGroup X] [ContinuousAdd X] [AddComm Function.Periodic (⇑(∑' n : ℤ, f.comp (ContinuousMap.addRight (n • p)))) p := by intro x by_cases h : Summable fun n : ℤ => f.comp (ContinuousMap.addRight (n • p)) - · convert congr_arg (fun f : C(X, Y) => f x) ((Equiv.addRight (1 : ℤ)).tsum_eq _) using 1 + · convert! congr_arg (fun f : C(X, Y) => f x) ((Equiv.addRight (1 : ℤ)).tsum_eq _) using 1 + -- This `have` unfolds the function composition in `Equiv.summable_iff`. + -- This `have` unfolds the function composition in `Equiv.summable_iff`. have : Summable fun (c : ℤ) => f.comp (ContinuousMap.addRight (Equiv.addRight 1 c • p)) := (Equiv.addRight (1 : ℤ)).summable_iff.mpr h diff --git a/Mathlib/Topology/ContinuousMap/Polynomial.lean b/Mathlib/Topology/ContinuousMap/Polynomial.lean index 5be1a5f611d5b5..cd74e882e79f05 100644 --- a/Mathlib/Topology/ContinuousMap/Polynomial.lean +++ b/Mathlib/Topology/ContinuousMap/Polynomial.lean @@ -184,7 +184,7 @@ theorem polynomialFunctions.comap_compRightAlgHom_iccHomeoI (a b : ℝ) (h : a < smul_eq_mul, Polynomial.eval_mul, Polynomial.eval_add, Polynomial.eval_comp, Polynomial.toContinuousMapOnAlgHom_apply, Polynomial.toContinuousMapOn_apply, Polynomial.toContinuousMap_apply] - convert w ⟨_, _⟩ + convert! w ⟨_, _⟩ · ext simp only [iccHomeoI_symm_apply_coe] replace h : b - a ≠ 0 := sub_ne_zero_of_ne h.ne.symm diff --git a/Mathlib/Topology/ContinuousMap/StoneWeierstrass.lean b/Mathlib/Topology/ContinuousMap/StoneWeierstrass.lean index 4c5edb995054cf..c311a9ddb11d85 100644 --- a/Mathlib/Topology/ContinuousMap/StoneWeierstrass.lean +++ b/Mathlib/Topology/ContinuousMap/StoneWeierstrass.lean @@ -134,7 +134,7 @@ theorem inf_mem_subalgebra_closure (A : Subalgebra ℝ C(X, ℝ)) (f g : A) : theorem inf_mem_closed_subalgebra (A : Subalgebra ℝ C(X, ℝ)) (h : IsClosed (A : Set C(X, ℝ))) (f g : A) : (f : C(X, ℝ)) ⊓ (g : C(X, ℝ)) ∈ A := by - convert inf_mem_subalgebra_closure A f g + convert! inf_mem_subalgebra_closure A f g apply SetLike.ext' symm rw [Subalgebra.topologicalClosure_coe, closure_eq_iff_isClosed] @@ -154,7 +154,7 @@ theorem sup_mem_subalgebra_closure (A : Subalgebra ℝ C(X, ℝ)) (f g : A) : theorem sup_mem_closed_subalgebra (A : Subalgebra ℝ C(X, ℝ)) (h : IsClosed (A : Set C(X, ℝ))) (f g : A) : (f : C(X, ℝ)) ⊔ (g : C(X, ℝ)) ∈ A := by - convert sup_mem_subalgebra_closure A f g + convert! sup_mem_subalgebra_closure A f g apply SetLike.ext' simp @@ -270,7 +270,7 @@ theorem subalgebra_topologicalClosure_eq_top_of_separatesPoints (A : Subalgebra apply SetLike.ext' let L := A.topologicalClosure have n : Set.Nonempty (L : Set C(X, ℝ)) := ⟨(1 : C(X, ℝ)), A.le_topologicalClosure A.one_mem⟩ - convert + convert! sublattice_closure_eq_top (L : Set C(X, ℝ)) n (fun f fm g gm => inf_mem_closed_subalgebra L A.isClosed_topologicalClosure ⟨f, fm⟩ ⟨g, gm⟩) (fun f fm g gm => sup_mem_closed_subalgebra L A.isClosed_topologicalClosure ⟨f, fm⟩ ⟨g, gm⟩) @@ -385,7 +385,7 @@ theorem Subalgebra.SeparatesPoints.rclike_to_real {A : StarSubalgebra 𝕜 C(X, refine ⟨_, ⟨⟨(‖F ·‖ ^ 2), by fun_prop⟩, ?_, rfl⟩, ?_⟩ · -- This is also an element of the subalgebra, and takes only real values rw [SetLike.mem_coe, Subalgebra.mem_comap] - convert (A.restrictScalars ℝ).mul_mem hFA (star_mem hFA : star F ∈ A) + convert! (A.restrictScalars ℝ).mul_mem hFA (star_mem hFA : star F ∈ A) ext1 simp [← RCLike.mul_conj] · -- And it also separates the points `x₁`, `x₂` @@ -428,7 +428,7 @@ theorem ContinuousMap.starSubalgebra_topologicalClosure_eq_top_of_separatesPoint -- So `f_re + I • f_im` is in the closure of `A` have := A.topologicalClosure.add_mem h_f_re (A.topologicalClosure.smul_mem h_f_im RCLike.I) rw [StarSubalgebra.mem_toSubalgebra] at this - convert this + convert! this -- And this, of course, is just `f` ext apply Eq.symm @@ -613,7 +613,7 @@ lemma ker_evalStarAlgHom_eq_closure_adjoin_id (s : Set 𝕜) (h0 : 0 ∈ s) [Com closure (adjoin 𝕜 {(restrict s (.id 𝕜))}) := by rw [← ker_evalStarAlgHom_inter_adjoin_id s h0, AlgHom.closure_ker_inter (φ := evalStarAlgHom 𝕜 𝕜 (X := s) ⟨0, h0⟩) (continuous_eval_const _) _] - convert (Set.univ_inter _).symm + convert! (Set.univ_inter _).symm rw [← Polynomial.toContinuousMapOn_X_eq_restrict_id, ← Polynomial.toContinuousMapOnAlgHom_apply, ← polynomialFunctions.starClosure_eq_adjoin_X s] congrm (($(polynomialFunctions.starClosure_topologicalClosure s) : Set C(s, 𝕜))) diff --git a/Mathlib/Topology/ContinuousMap/T0Sierpinski.lean b/Mathlib/Topology/ContinuousMap/T0Sierpinski.lean index 3271ee7a3bf687..77c27b073bb658 100644 --- a/Mathlib/Topology/ContinuousMap/T0Sierpinski.lean +++ b/Mathlib/Topology/ContinuousMap/T0Sierpinski.lean @@ -49,7 +49,7 @@ def productOfMemOpens : C(X, Opens X → Prop) where continuous_toFun := continuous_pi_iff.2 fun u => continuous_Prop.2 u.isOpen theorem productOfMemOpens_isInducing : IsInducing (productOfMemOpens X) := by - convert inducing_iInf_to_pi fun (u : Opens X) (x : X) => x ∈ u + convert! inducing_iInf_to_pi fun (u : Opens X) (x : X) => x ∈ u apply eq_induced_by_maps_to_sierpinski theorem productOfMemOpens_injective [T0Space X] : Function.Injective (productOfMemOpens X) := by diff --git a/Mathlib/Topology/ContinuousOn.lean b/Mathlib/Topology/ContinuousOn.lean index f1a9f9c1334284..01fc94ed52bc8a 100644 --- a/Mathlib/Topology/ContinuousOn.lean +++ b/Mathlib/Topology/ContinuousOn.lean @@ -183,7 +183,7 @@ theorem ContinuousOn.isOpen_inter_preimage {t : Set β} theorem ContinuousOn.isOpen_preimage {t : Set β} (h : ContinuousOn f s) (hs : IsOpen s) (hp : f ⁻¹' t ⊆ s) (ht : IsOpen t) : IsOpen (f ⁻¹' t) := by - convert (continuousOn_open_iff hs).mp h t ht + convert! (continuousOn_open_iff hs).mp h t ht rw [inter_comm, inter_eq_self_of_subset_left hp] theorem ContinuousOn.preimage_isClosed_of_isClosed {t : Set β} diff --git a/Mathlib/Topology/Convenient/OpenClosed.lean b/Mathlib/Topology/Convenient/OpenClosed.lean index 747461c4ad0076..cf54c8355aa24f 100644 --- a/Mathlib/Topology/Convenient/OpenClosed.lean +++ b/Mathlib/Topology/Convenient/OpenClosed.lean @@ -47,7 +47,7 @@ lemma IsOpen.isGeneratedBy [IsGeneratedBy X Y] {U : Set Y} (hU : IsOpen U) : refine continuous_subtype_val.isOpen_preimage _ ?_ rw [IsGeneratedBy.isOpen_iff X] intro i f - convert (W ⟨i, f⟩).isOpen.isOpenMap_subtype_val _ (hV ⟨i, f⟩) + convert! (W ⟨i, f⟩).isOpen.isOpenMap_subtype_val _ (hV ⟨i, f⟩) aesop lemma Topology.IsOpenEmbedding.isGeneratedBy [IsGeneratedBy X Y] @@ -80,7 +80,7 @@ lemma IsClosed.isGeneratedBy [IsGeneratedBy X Y] {F : Set Y} (hF : IsClosed F) : refine IsClosed.preimage continuous_subtype_val ?_ rw [IsGeneratedBy.isClosed_iff X] intro i f - convert (W ⟨i, f⟩).isClosed.isClosedMap_subtype_val _ (hV ⟨i, f⟩) + convert! (W ⟨i, f⟩).isClosed.isClosedMap_subtype_val _ (hV ⟨i, f⟩) aesop lemma Topology.IsClosedEmbedding.isGeneratedBy [IsGeneratedBy X Y] diff --git a/Mathlib/Topology/Covering/AddCircle.lean b/Mathlib/Topology/Covering/AddCircle.lean index 735711e09f6c02..300abb208c1e92 100644 --- a/Mathlib/Topology/Covering/AddCircle.lean +++ b/Mathlib/Topology/Covering/AddCircle.lean @@ -62,20 +62,20 @@ theorem isAddQuotientCoveringMap_zsmul {n : ℤ} (hn : IsUnit (n : 𝕜)) : theorem isAddQuotientCoveringMap_nsmul {n : ℕ} (hn : IsUnit (n : 𝕜)) : IsAddQuotientCoveringMap (n • · : AddCircle p → _) (nsmulAddMonoidHom (α := AddCircle p) n).ker := by - convert isAddQuotientCoveringMap_zsmul p (n := n) (mod_cast hn) + convert! isAddQuotientCoveringMap_zsmul p (n := n) (mod_cast hn) all_goals ext; simp theorem isAddQuotientCoveringMap_zsmul_of_ne_zero [Algebra ℚ 𝕜] (n : ℤ) [NeZero n] : IsAddQuotientCoveringMap (n • · : AddCircle p → _) (zsmulAddGroupHom (α := AddCircle p) n).ker := isAddQuotientCoveringMap_zsmul p (n := n) <| by - convert (Int.cast_ne_zero.mpr <| NeZero.ne n).isUnit.map (algebraMap ℚ 𝕜); simp + convert! (Int.cast_ne_zero.mpr <| NeZero.ne n).isUnit.map (algebraMap ℚ 𝕜); simp theorem isAddQuotientCoveringMap_nsmul_of_ne_zero [Algebra ℚ 𝕜] (n : ℕ) [NeZero n] : IsAddQuotientCoveringMap (n • · : AddCircle p → _) (nsmulAddMonoidHom (α := AddCircle p) n).ker := isAddQuotientCoveringMap_nsmul p (n := n) <| by - convert (Nat.cast_ne_zero.mpr <| NeZero.ne n).isUnit.map (algebraMap ℚ 𝕜); simp + convert! (Nat.cast_ne_zero.mpr <| NeZero.ne n).isUnit.map (algebraMap ℚ 𝕜); simp end Field diff --git a/Mathlib/Topology/Covering/Basic.lean b/Mathlib/Topology/Covering/Basic.lean index 6b8d5c739538e6..f920a421ae0246 100644 --- a/Mathlib/Topology/Covering/Basic.lean +++ b/Mathlib/Topology/Covering/Basic.lean @@ -161,11 +161,11 @@ theorem comp_subtypeVal (hs : IsOpen s) (hfs : IsOpen (f ⁻¹' s)) {x : X} (hx (isEmpty_or_nonempty I).elim (fun _ ↦ .of_preimage_eq_empty _ ((hs.inter hU).mem_nhds ⟨hx, hxU⟩) <| Set.not_nonempty_iff_eq_empty.mp fun ⟨e, he⟩ ↦ isEmptyElim (H ⟨⟨e, he.1⟩, he.2⟩).2) fun _ ↦ have hUs : U ⊆ s := fun y hy ↦ by - convert Set.mem_preimage.mp (H.symm (⟨y, hy⟩, Classical.arbitrary I)).1.2; simp [← hH] + convert! Set.mem_preimage.mp (H.symm (⟨y, hy⟩, Classical.arbitrary I)).1.2; simp [← hH] have : Subtype.val '' (fun e : f ⁻¹' s ↦ f e) ⁻¹' U = f ⁻¹' U := by ext; simpa using @hUs _ ⟨inst, U, hxU, hU, this ▸ hfs.isOpenMap_subtype_val _ hfU, .trans (.symm <| .trans (IsEmbedding.subtypeVal.homeomorphImage _) <| .setCongr this) H, fun x ↦ by - dsimp; convert hH ⟨⟨x, hUs x.2⟩, x.2⟩ using 4; rw [Homeomorph.symm_apply_eq]; rfl⟩ + dsimp; convert! hH ⟨⟨x, hUs x.2⟩, x.2⟩ using 4; rw [Homeomorph.symm_apply_eq]; rfl⟩ theorem comp_homeomorph {x : X} (h : IsEvenlyCovered f x I) {E'} [TopologicalSpace E'] (g : E' ≃ₜ E) : IsEvenlyCovered (f ∘ g) x I := @@ -175,7 +175,7 @@ theorem comp_homeomorph {x : X} (h : IsEvenlyCovered f x I) {E'} [TopologicalSpa @[simp] theorem comp_homeomorph_iff {x : X} {E'} [TopologicalSpace E'] (g : E' ≃ₜ E) : IsEvenlyCovered (f ∘ g) x I ↔ IsEvenlyCovered f x I where - mp h := by convert h.comp_homeomorph g.symm; ext; simp + mp h := by convert! h.comp_homeomorph g.symm; ext; simp mpr h := h.comp_homeomorph g theorem homeomorph_comp {x : X} (h : IsEvenlyCovered f x I) {Y} [TopologicalSpace Y] (g : X ≃ₜ Y) : @@ -187,7 +187,7 @@ theorem homeomorph_comp {x : X} (h : IsEvenlyCovered f x I) {Y} [TopologicalSpac @[simp] theorem homeomorph_comp_iff {x : X} {Y} [TopologicalSpace Y] (g : X ≃ₜ Y) : IsEvenlyCovered (g ∘ f) (g x) I ↔ IsEvenlyCovered f x I where - mp h := by convert h.homeomorph_comp g.symm <;> ((try ext); simp) + mp h := by convert! h.homeomorph_comp g.symm <;> ((try ext); simp) mpr h := h.homeomorph_comp g end IsEvenlyCovered @@ -268,7 +268,7 @@ theorem comp_homeomorph (hf : IsCoveringMapOn f s) {E'} [TopologicalSpace E'] (g @[simp] theorem comp_homeomorph_iff {E'} [TopologicalSpace E'] (g : E' ≃ₜ E) : IsCoveringMapOn (f ∘ g) s ↔ IsCoveringMapOn f s where - mp h := by convert h.comp_homeomorph g.symm; ext; simp + mp h := by convert! h.comp_homeomorph g.symm; ext; simp mpr h := h.comp_homeomorph g theorem homeomorph_comp (hf : IsCoveringMapOn f s) {Y} [TopologicalSpace Y] (g : X ≃ₜ Y) : @@ -277,7 +277,7 @@ theorem homeomorph_comp (hf : IsCoveringMapOn f s) {Y} [TopologicalSpace Y] (g : @[simp] theorem homeomorph_comp_iff {Y} [TopologicalSpace Y] (g : X ≃ₜ Y) : IsCoveringMapOn (g ∘ f) (g.symm ⁻¹' s) ↔ IsCoveringMapOn f s where - mp h := by convert h.homeomorph_comp g.symm <;> (ext; simp) + mp h := by convert! h.homeomorph_comp g.symm <;> (ext; simp) mpr h := h.homeomorph_comp g end IsCoveringMapOn @@ -397,12 +397,12 @@ omit hf theorem comp_homeomorph_iff {E'} [TopologicalSpace E'] (g : E' ≃ₜ E) : IsCoveringMap (f ∘ g) ↔ IsCoveringMap f where - mp h := by convert h.comp_homeomorph g.symm; ext; simp + mp h := by convert! h.comp_homeomorph g.symm; ext; simp mpr h := h.comp_homeomorph g theorem homeomorph_comp_iff {Y} [TopologicalSpace Y] (g : X ≃ₜ Y) : IsCoveringMap (g ∘ f) ↔ IsCoveringMap f where - mp h := by convert h.homeomorph_comp g.symm; ext; simp + mp h := by convert! h.homeomorph_comp g.symm; ext; simp mpr h := h.homeomorph_comp g end IsCoveringMap @@ -462,7 +462,7 @@ Then `f` admits a `Bundle.Trivialization` over the base set `V`. -/ rw [dif_pos ((f_inv _ hx.1).symm ▸ hx.1)] by_contra h; exact (disjoint h).le_bot ⟨idx_U .., inv_U _ _⟩ } have open_preim {W} (hWV : W ⊆ V) (open_W : IsOpen W) : IsOpen (f ⁻¹' W) := by - convert isOpen_iUnion (fun i ↦ (open_iff i hWV).mp open_W) + convert! isOpen_iUnion (fun i ↦ (open_iff i hWV).mp open_W) rw [← Set.inter_iUnion, eq_comm, Set.inter_eq_left] exact (Set.preimage_mono hWV).trans exhaustive' have open_source : IsOpen F.source := open_preim subset_rfl open_V @@ -487,7 +487,7 @@ Then `f` admits a `Bundle.Trivialization` over the base set `V`. -/ · simp_rw [F, Set.prodMk_mem_set_prod_eq, Set.mem_univ, and_true] refine (continuousOn_open_iff open_V).mpr fun W open_W ↦ ?_ rw [open_iff i Set.inter_subset_left] - convert ((open_iff i subset_rfl).mp open_V).inter open_W using 1 + convert! ((open_iff i subset_rfl).mp open_V).inter open_W using 1 refine Set.ext fun e ↦ and_right_comm.trans (and_congr_right fun ⟨hV, hU⟩ ↦ ?_) rw [Set.mem_preimage, dif_pos hV, inj i (inv_U i _) hU (f_inv i _)] @@ -531,7 +531,7 @@ theorem IsClosedMap.isEvenlyCovered_of_openPartialHomeomorph [T2Space E] {x : X} let U' := U ∩ ⋂ e : f ⁻¹' {x}, f '' (V' e) have : Finite (f ⁻¹' {x}) := fin have hU' : IsOpen U' := hU.inter <| isOpen_iInter_of_finite fun e ↦ by - convert ← (φ e).isOpen_image_of_subset_source (hV' _) inter_subset_right; exact (hφ e).2 + convert! ← (φ e).isOpen_image_of_subset_source (hV' _) inter_subset_right; exact (hφ e).2 have hUV e : U' ⊆ f '' V' e := inter_subset_right.trans (iInter_subset ..) have : Nonempty E := ⟨Classical.arbitrary (f ⁻¹' {x})⟩ refine .of_trivialization (t := hU'.trivializationDiscrete _ _ @@ -540,17 +540,17 @@ theorem IsClosedMap.isEvenlyCovered_of_openPartialHomeomorph [T2Space E] {x : X} (pairwise_disjoint_mono disj.subtype fun e ↦ inter_subset_left) ((preimage_mono (inter_subset_left.trans hUW)).trans hWV)) ⟨hxU, Set.mem_iInter.mpr fun e ↦ ⟨e, ⟨(hV e).1, (hφ e).1⟩, e.2⟩⟩ - · convert ((φ e).isOpen_inter_preimage h).inter (hV e).2 using 1 + · convert! ((φ e).isOpen_inter_preimage h).inter (hV e).2 using 1 simp_rw [(hφ e).2, V']; ac_rfl · have : s ⊆ (φ e).target := hs.trans <| (hUV e).trans <| by rw [← (φ e).image_source_eq_target, (hφ e).2]; exact image_mono inter_subset_right rw [← (φ e).isOpen_symm_image_iff_of_subset_target this, (φ e).symm_image_eq_source_inter_preimage this, (hφ e).2, inter_comm] - convert h using 1 + convert! h using 1 refine inter_eq_inter_iff_left.mpr ⟨fun e' h ↦ h.2.2, fun e' h ↦ ⟨?_ , h.2⟩⟩ have ⟨e'', ⟨_, mem⟩, eq⟩ := mem_iInter.mp (hs h.1).2 e rwa [← (φ e).injOn mem h.2 (by rwa [(hφ e).2])] - · convert ← (φ e).injOn.mono inter_subset_right; exact (hφ e).2 + · convert! ← (φ e).injOn.mono inter_subset_right; exact (hφ e).2 /-- If `f : E → X` is a closed map between topological spaces with `E` Hausdorff, and `s` is a subset of `X` on which `f` has finite fibers, such that `f` restricts to a homeomorphism on diff --git a/Mathlib/Topology/Covering/Quotient.lean b/Mathlib/Topology/Covering/Quotient.lean index 3aafe45fc9009e..18ec7fc50a48f7 100644 --- a/Mathlib/Topology/Covering/Quotient.lean +++ b/Mathlib/Topology/Covering/Quotient.lean @@ -64,7 +64,7 @@ variable {f G} @[to_additive (attr := simp)] theorem homeomorph_comp_iff {Y} [TopologicalSpace Y] (φ : X ≃ₜ Y) : IsQuotientCoveringMap (φ ∘ f) G ↔ IsQuotientCoveringMap f G where - mp h := by convert h.homeomorph_comp φ.symm; ext; simp + mp h := by convert! h.homeomorph_comp φ.symm; ext; simp mpr h := h.homeomorph_comp φ end IsQuotientCoveringMap @@ -105,7 +105,7 @@ noncomputable def trivializationOfSMulDisjoint [TopologicalSpace G] [DiscreteTop mul_inv_eq_one.mp (disjoint _ ⟨_, ⟨_, h₂, ?_⟩, h₁⟩)) preim_im.subset · rw [← hf.isOpen_preimage, preim_im] exact isOpen_iUnion fun g ↦ open_U.preimage (continuous_const_smul g) - · convert isOpen_iUnion fun g : G ↦ isOpen.preimage (continuous_const_smul g) + · convert! isOpen_iUnion fun g : G ↦ isOpen.preimage (continuous_const_smul g) ext e; refine ⟨fun hW ↦ ?_, ?_⟩ · have ⟨e', he', hfe⟩ := hWU hW obtain ⟨g', rfl⟩ := hfG.mp hfe @@ -214,7 +214,7 @@ namespace IsQuotientCoveringMap IsCoveringMap f := isCoveringMap_iff_isCoveringMapOn_univ.mpr <| by have := h.toContinuousConstSMul - convert ← h.isCoveringMapOn_of_smul_disjoint h.apply_eq_iff_mem_orbit fun e ↦ ?_ + convert! ← h.isCoveringMapOn_of_smul_disjoint h.apply_eq_iff_mem_orbit fun e ↦ ?_ · refine Set.eq_univ_of_forall fun x ↦ ?_ obtain ⟨e, rfl⟩ := h.surjective x have ⟨U, hU, hGU⟩ := h.disjoint e diff --git a/Mathlib/Topology/DerivedSet.lean b/Mathlib/Topology/DerivedSet.lean index 357a6aded0fa6f..d185432f3964d6 100644 --- a/Mathlib/Topology/DerivedSet.lean +++ b/Mathlib/Topology/DerivedSet.lean @@ -52,7 +52,7 @@ theorem Continuous.image_derivedSet {β : Type*} [TopologicalSpace β] {A : Set intro x hx simp only [Set.mem_image, mem_derivedSet] at hx obtain ⟨y, hy1, rfl⟩ := hx - convert hy1.map hf1.continuousAt hf2 + convert! hy1.map hf1.continuousAt hf2 simp lemma derivedSet_subset_closure (A : Set X) : derivedSet A ⊆ closure A := diff --git a/Mathlib/Topology/DiscreteQuotient.lean b/Mathlib/Topology/DiscreteQuotient.lean index b3b5c8bb442f66..a690f782ef8391 100644 --- a/Mathlib/Topology/DiscreteQuotient.lean +++ b/Mathlib/Topology/DiscreteQuotient.lean @@ -229,7 +229,7 @@ instance [LocallyConnectedSpace X] : OrderBot (DiscreteQuotient X) where bot := { toSetoid := connectedComponentSetoid X isOpen_setOf_rel := fun x => by - convert isOpen_connectedComponent (x := x) + convert! isOpen_connectedComponent (x := x) ext y simpa only [connectedComponentSetoid, ← connectedComponent_eq_iff_mem] using eq_comm } bot_le S := fun x y (h : connectedComponent x = connectedComponent y) => diff --git a/Mathlib/Topology/DiscreteSubset.lean b/Mathlib/Topology/DiscreteSubset.lean index f3f647aa95548f..f7e90319229267 100644 --- a/Mathlib/Topology/DiscreteSubset.lean +++ b/Mathlib/Topology/DiscreteSubset.lean @@ -164,7 +164,7 @@ lemma Continuous.discrete_of_tendsto_cofinite_cocompact [T1Space X] [WeaklyLocal lemma tendsto_cofinite_cocompact_of_discrete [DiscreteTopology X] (hf : Tendsto f (cocompact _) (cocompact _)) : Tendsto f cofinite (cocompact _) := by - convert hf + convert! hf rw [cocompact_eq_cofinite X] lemma IsClosed.tendsto_coe_cofinite_of_isDiscrete @@ -365,6 +365,10 @@ lemma mem_codiscrete_subtype_iff_mem_codiscreteWithin {S : Set X} {U : Set S} : U ∈ codiscrete S ↔ (↑) '' U ∈ codiscreteWithin S := by simp [← Topology.IsEmbedding.subtypeVal.image_mem_codiscreteWithin_range] +@[simp] +theorem codiscreteWithin_eq_bot_iff {S : Set X} : codiscreteWithin S = ⊥ ↔ IsDiscrete S := by + simp [isDiscrete_iff_nhdsNE, codiscreteWithin, ← nhdsWithin_inter', Set.diff_eq, inter_comm] + section T1Space variable [T1Space X] diff --git a/Mathlib/Topology/EMetricSpace/BoundedVariation.lean b/Mathlib/Topology/EMetricSpace/BoundedVariation.lean index 5f253e2f0386ef..ac16ca16607048 100644 --- a/Mathlib/Topology/EMetricSpace/BoundedVariation.lean +++ b/Mathlib/Topology/EMetricSpace/BoundedVariation.lean @@ -358,8 +358,9 @@ theorem add_le_union (f : α → E) {s t : Set α} (h : ∀ x ∈ s, ∀ y ∈ t ∑ i ∈ Finset.Ico (n + 1) (n + 1 + m), edist (f (w (i + 1))) (f (w i)) := by congr 1 rw [Finset.range_eq_Ico] - convert Finset.sum_Ico_add (fun i : ℕ => edist (f (w (i + 1))) (f (w i))) 0 m (n + 1) - using 3 <;> abel + convert! + Finset.sum_Ico_add (fun i : ℕ => edist (f (w (i + 1))) (f (w i))) 0 m (n + 1) using 3 <;> + abel _ ≤ ∑ i ∈ Finset.range (n + 1 + m), edist (f (w (i + 1))) (f (w i)) := by rw [← Finset.sum_union] · gcongr; grind @@ -406,8 +407,10 @@ theorem sum (f : α → E) {s : Set α} {E : ℕ → α} (hE : Monotone E) {n : theorem sum' (f : α → E) {I : ℕ → α} (hI : Monotone I) {n : ℕ} : ∑ i ∈ Finset.range n, eVariationOn f (Icc (I i) (I (i + 1))) = eVariationOn f (Icc (I 0) (I n)) := by - convert sum f hI (s := Icc (I 0) (I n)) (n := n) - (hn := by intros; rw [mem_Icc]; constructor <;> (apply hI; lia)) with i hi + convert! + sum f hI (s := Icc (I 0) (I n)) (n := n) + (hn := by intros; rw [mem_Icc]; constructor <;> (apply hI; lia)) + with i hi · simp only [right_eq_inter] gcongr <;> (apply hI; rw [Finset.mem_range] at hi; lia) · simp @@ -454,7 +457,7 @@ theorem comp_inter_Icc_eq_of_monotoneOn (f : α → E) {t : Set β} (φ : β → {x y : β} (hx : x ∈ t) (hy : y ∈ t) : eVariationOn (f ∘ φ) (t ∩ Icc x y) = eVariationOn f (φ '' t ∩ Icc (φ x) (φ y)) := by rcases le_total x y with (h | h) - · convert comp_eq_of_monotoneOn f φ (hφ.mono Set.inter_subset_left) + · convert! comp_eq_of_monotoneOn f φ (hφ.mono Set.inter_subset_left) apply le_antisymm · rintro _ ⟨⟨u, us, rfl⟩, vφx, vφy⟩ rcases le_total x u with (xu | ux) @@ -487,7 +490,7 @@ open OrderDual @[simp] theorem comp_ofDual (f : α → E) (s : Set α) : eVariationOn (f ∘ ofDual) (ofDual ⁻¹' s) = eVariationOn f s := by - convert comp_eq_of_antitoneOn f ofDual fun _ _ _ _ => id + convert! comp_eq_of_antitoneOn f ofDual fun _ _ _ _ => id simp only [Equiv.image_preimage] lemma _root_.BoundedVariationOn.ofDual {f : α → E} {s : Set α} (hf : BoundedVariationOn f s) : @@ -699,7 +702,7 @@ theorem _root_.BoundedVariationOn.tendsto_eVariationOn_Icc_zero_left grind [Set.Subsingleton] have W := eVariationOn_inter_Iio_eq_inter_Iic_of_continuousWithinAt (f := f) (s := s ∩ Icc y x) (a := x) ?_ ?_ - · convert W using 2 <;> grind + · convert! W using 2 <;> grind · rwa [show s ∩ Icc y x ∩ Iio x = (s ∩ Iio x) ∩ Ici y by grind, nhdsWithin_inter_of_mem'] apply mem_nhdsWithin_of_mem_nhds exact Ici_mem_nhds hy @@ -739,7 +742,7 @@ theorem _root_.BoundedVariationOn.tendsto_leftLim [CompleteSpace E] [Topological [OrderTopology α] {f : α → E} (hf : BoundedVariationOn f univ) (x : α) : Tendsto f (𝓝[<] x) (𝓝 (f.leftLim x)) := by apply tendsto_leftLim_of_tendsto - convert hf.exists_tendsto_left x + convert! hf.exists_tendsto_left x simp /-- A bounded variation function tends to its right-limit on its right. -/ diff --git a/Mathlib/Topology/EMetricSpace/Lipschitz.lean b/Mathlib/Topology/EMetricSpace/Lipschitz.lean index 8e37ed75fa5d38..1dc507e1e1b54c 100644 --- a/Mathlib/Topology/EMetricSpace/Lipschitz.lean +++ b/Mathlib/Topology/EMetricSpace/Lipschitz.lean @@ -218,7 +218,7 @@ theorem subtype_mk (hf : LipschitzWith K f) {p : β → Prop} (hp : ∀ x, p (f protected theorem eval {α : ι → Type u} [∀ i, PseudoEMetricSpace (α i)] [Fintype ι] (i : ι) : LipschitzWith 1 (Function.eval i : (∀ i, α i) → α i) := - LipschitzWith.of_edist_le fun f g => by convert edist_le_pi_edist f g i + LipschitzWith.of_edist_le fun f g => by convert! edist_le_pi_edist f g i /-- The restriction of a `K`-Lipschitz function is `K`-Lipschitz. -/ protected theorem restrict (hf : LipschitzWith K f) (s : Set α) : LipschitzWith K (s.restrict f) := diff --git a/Mathlib/Topology/FiberBundle/Basic.lean b/Mathlib/Topology/FiberBundle/Basic.lean index d5553f516df768..81c8a34b2ded66 100644 --- a/Mathlib/Topology/FiberBundle/Basic.lean +++ b/Mathlib/Topology/FiberBundle/Basic.lean @@ -597,7 +597,7 @@ def localTriv (i : ι) : Trivialization F Z.proj where rw [PartialEquiv.EqOnSource.source_inter_preimage_eq (Z.localTrivAsPartialEquiv_trans i j)] exact (continuousOn_open_iff (Z.trivChange i j).open_source).1 (Z.trivChange i j).continuousOn _ s_open - convert this using 1 + convert! this using 1 dsimp [f, PartialEquiv.trans_source] rw [← preimage_comp, inter_assoc] toPartialEquiv := Z.localTrivAsPartialEquiv i diff --git a/Mathlib/Topology/FiberBundle/Constructions.lean b/Mathlib/Topology/FiberBundle/Constructions.lean index 554752cb6da4d5..cb6efb03ba94e4 100644 --- a/Mathlib/Topology/FiberBundle/Constructions.lean +++ b/Mathlib/Topology/FiberBundle/Constructions.lean @@ -201,7 +201,8 @@ noncomputable def prod : Trivialization (F₁ × F₂) (π (F₁ × F₂) (E₁ left_inv' _ := Prod.left_inv right_inv' _ := Prod.right_inv open_source := by - convert (e₁.open_source.prod e₂.open_source).preimage + convert! + (e₁.open_source.prod e₂.open_source).preimage (FiberBundle.Prod.isInducing_diag F₁ E₁ F₂ E₂).continuous ext x simp only [Trivialization.source_eq, mfld_simps] diff --git a/Mathlib/Topology/FiberBundle/Trivialization.lean b/Mathlib/Topology/FiberBundle/Trivialization.lean index c7f8285dbe84bc..d4135d9f75bf2f 100644 --- a/Mathlib/Topology/FiberBundle/Trivialization.lean +++ b/Mathlib/Topology/FiberBundle/Trivialization.lean @@ -289,7 +289,7 @@ noncomputable def restrictPreimage' (e : Pretrivialization F proj) (s : Set B) right_inv' x hx := Subtype.val_injective.prodMap injective_id <| by simp only [mem_preimage, (Prod.map_apply), id_eq] at hx simp_rw [Prod.map_apply]; rw [dif_pos hx] - convert ← e.right_inv' hx; exact e.proj_toFun _ (e.map_target' hx) + convert! ← e.right_inv' hx; exact e.proj_toFun _ (e.map_target' hx) open_target := e.open_target.preimage <| by fun_prop baseSet := Subtype.val ⁻¹' e.baseSet open_baseSet := e.open_baseSet.preimage continuous_subtype_val @@ -835,11 +835,11 @@ noncomputable def domExtend {s : Set B} (hps : IsOpen (proj ⁻¹' s)) __ := e.toPretrivialization.domExtend open_source := hps.isOpenMap_subtype_val _ e.open_source continuousOn_toFun := Topology.IsInducing.subtypeVal.continuousOn_image_iff.mpr <| by - convert e.continuousOn_toFun + convert! e.continuousOn_toFun ext1 ⟨x, (hx : proj x ∈ s)⟩ simpa [Pretrivialization.domExtend] using dif_pos hx continuousOn_invFun := continuous_subtype_val.comp_continuousOn <| by - convert e.continuousOn_invFun + convert! e.continuousOn_invFun /-- Extend the base of a trivialization from a set to the whole space. -/ @[simps! apply source target baseSet] @@ -850,7 +850,7 @@ noncomputable def codExtend' {s : Set B} (hs : IsOpen s) {proj : Z → s} (e : T continuousOn_toFun := (continuous_subtype_val.prodMap continuous_id).comp_continuousOn e.continuousOn_toFun continuousOn_invFun := (Topology.IsInducing.subtypeVal.prodMap .id).continuousOn_image_iff.2 <| by - convert e.continuousOn_invFun; ext; simp [Pretrivialization.codExtend']; rfl + convert! e.continuousOn_invFun; ext; simp [Pretrivialization.codExtend']; rfl /-- Extend the base of a pretrivialization from a nonempty set to the whole space. -/ @[simps! apply source target baseSet] diff --git a/Mathlib/Topology/Germ.lean b/Mathlib/Topology/Germ.lean index 3fb0da89414ea7..1d9a1d13eb4d42 100644 --- a/Mathlib/Topology/Germ.lean +++ b/Mathlib/Topology/Germ.lean @@ -107,7 +107,7 @@ theorem Filter.Eventually.germ_congr_set intro x hx apply ((hf x hx).and (h x hx).eventually_nhds).mono intro y hy - convert hy.1 using 1 + convert! hy.1 using 1 exact Germ.coe_eq.mpr hy.2 theorem restrictGermPredicate_congr {P : ∀ x : X, Germ (𝓝 x) Y → Prop} diff --git a/Mathlib/Topology/Gluing.lean b/Mathlib/Topology/Gluing.lean index a7f51505bc0f98..7ef34eddab6686 100644 --- a/Mathlib/Topology/Gluing.lean +++ b/Mathlib/Topology/Gluing.lean @@ -245,7 +245,7 @@ theorem preimage_image_eq_image (i j : D.J) (U : Set (𝖣.U i)) : theorem preimage_image_eq_image' (i j : D.J) (U : Set (𝖣.U i)) : 𝖣.ι j ⁻¹' 𝖣.ι i '' U = (D.t i j ≫ D.f _ _) '' D.f _ _ ⁻¹' U := by - convert D.preimage_image_eq_image i j U using 1 + convert! D.preimage_image_eq_image i j U using 1 rw [coe_comp, coe_comp, Set.image_comp] congr! 1 rw [← Set.eq_preimage_iff_image_eq, Set.preimage_preimage] @@ -299,7 +299,7 @@ structure MkCore where theorem MkCore.t_inv (h : MkCore) (i j : h.J) (x : h.V j i) : h.t i j ((h.t j i) x) = x := by have := h.cocycle j i j x ?_ · rw [h.t_id] at this - · convert Subtype.ext this + · convert! Subtype.ext this rw [h.V_id] trivial @@ -347,7 +347,7 @@ def mk' (h : MkCore.{u}) : TopCat.GlueData where dsimp only [Opens.coe_inclusion', hom_comp, hom_ofHom, ContinuousMap.comp_assoc, ContinuousMap.comp_apply, ContinuousMap.coe_mk, hom_id, ContinuousMap.id_apply] rw [Subtype.mk_eq_mk, Prod.mk_inj, Subtype.mk_eq_mk, Subtype.ext_iff, and_self_iff] - convert congr_arg Subtype.val (h.t_inv k i ⟨x, hx'⟩) using 3 + convert! congr_arg Subtype.val (h.t_inv k i ⟨x, hx'⟩) using 3 refine Subtype.ext ?_ exact h.cocycle i j k ⟨x, hx⟩ hx' f_mono _ _ := (TopCat.mono_iff_injective _).mpr fun _ _ h => Subtype.ext h @@ -400,7 +400,7 @@ theorem fromOpenSubsetsGlue_isOpenMap : IsOpenMap (fromOpenSubsetsGlue U) := by constructor · rw [← Set.image_preimage_eq_inter_range] apply (Opens.isOpenEmbedding (X := TopCat.of α) (U i)).isOpenMap - convert hs i using 1 + convert! hs i using 1 rw [← ι_fromOpenSubsetsGlue, coe_comp, Set.preimage_comp] congr! 1 exact Set.preimage_image_eq _ (fromOpenSubsetsGlue_injective U) diff --git a/Mathlib/Topology/Homeomorph/Defs.lean b/Mathlib/Topology/Homeomorph/Defs.lean index bc16027728b168..124d3015d5faf9 100644 --- a/Mathlib/Topology/Homeomorph/Defs.lean +++ b/Mathlib/Topology/Homeomorph/Defs.lean @@ -44,10 +44,10 @@ structure Homeomorph (X : Type*) (Y : Type*) [TopologicalSpace X] [TopologicalSp extends X ≃ Y where /-- The forward map of a homeomorphism is a continuous function. -/ continuous_toFun : Continuous toFun := by - first | fun_prop | eta_expand; dsimp -failIfUnchanged; fun_prop + first | fun_prop | eta_expand; dsimp; fun_prop | skip /-- The inverse map of a homeomorphism is a continuous function. -/ continuous_invFun : Continuous invFun := by - first | fun_prop | eta_expand; dsimp -failIfUnchanged; fun_prop + first | fun_prop | eta_expand; dsimp; fun_prop | skip @[inherit_doc] infixl:25 " ≃ₜ " => Homeomorph @@ -196,10 +196,10 @@ def changeInv (f : X ≃ₜ Y) (g : Y → X) (hg : Function.RightInverse g f) : haveI : g = f.symm := (f.left_inv.eq_rightInverse hg).symm { toFun := f invFun := g - left_inv := by convert f.left_inv - right_inv := by convert f.right_inv using 1 + left_inv := by convert! f.left_inv + right_inv := by convert! f.right_inv using 1 continuous_toFun := f.continuous - continuous_invFun := by convert f.symm.continuous } + continuous_invFun := by convert! f.symm.continuous } @[simp] theorem symm_comp_self (h : X ≃ₜ Y) : h.symm ∘ h = id := @@ -386,7 +386,7 @@ lemma toHomeomorph_apply (e : X ≃ Y) (he) (x : X) : e.toHomeomorph he x = e x (Equiv.refl X).toHomeomorph (fun _s ↦ Iff.rfl) = Homeomorph.refl _ := rfl @[simp] lemma symm_toHomeomorph (e : X ≃ Y) (he) : - (e.toHomeomorph he).symm = e.symm.toHomeomorph fun s ↦ by convert (he _).symm; simp := rfl + (e.toHomeomorph he).symm = e.symm.toHomeomorph fun s ↦ by convert! (he _).symm; simp := rfl lemma toHomeomorph_trans (e : X ≃ Y) (f : Y ≃ Z) (he hf) : (e.trans f).toHomeomorph (fun _s ↦ (he _).trans (hf _)) = diff --git a/Mathlib/Topology/Homeomorph/Lemmas.lean b/Mathlib/Topology/Homeomorph/Lemmas.lean index 163185ec7be34e..4e9b582d4d0f87 100644 --- a/Mathlib/Topology/Homeomorph/Lemmas.lean +++ b/Mathlib/Topology/Homeomorph/Lemmas.lean @@ -114,7 +114,7 @@ protected lemma totallyDisconnectedSpace (h : X ≃ₜ Y) [tdc : TotallyDisconne @[simp] theorem map_punctured_nhds_eq (h : X ≃ₜ Y) (x : X) : map h (𝓝[≠] x) = 𝓝[≠] (h x) := by - convert h.isEmbedding.map_nhdsWithin_eq ({x}ᶜ) x + convert! h.isEmbedding.map_nhdsWithin_eq ({ x }ᶜ) x rw [h.image_compl, Set.image_singleton] @[simp] diff --git a/Mathlib/Topology/Homeomorph/TransferInstance.lean b/Mathlib/Topology/Homeomorph/TransferInstance.lean index b0c85e9df29062..565e9c1044c042 100644 --- a/Mathlib/Topology/Homeomorph/TransferInstance.lean +++ b/Mathlib/Topology/Homeomorph/TransferInstance.lean @@ -36,7 +36,7 @@ def homeomorph [TopologicalSpace β] (e : α ≃ β) : continuous_toFun := continuous_induced_dom continuous_invFun := by simp only [Equiv.invFun_as_coe] - convert continuous_coinduced_rng + convert! continuous_coinduced_rng rw [e.coinduced_symm] } end Equiv diff --git a/Mathlib/Topology/Homotopy/Contractible.lean b/Mathlib/Topology/Homotopy/Contractible.lean index 2a6800f7c6a11d..6870928f9ab5ae 100644 --- a/Mathlib/Topology/Homotopy/Contractible.lean +++ b/Mathlib/Topology/Homotopy/Contractible.lean @@ -57,7 +57,7 @@ theorem id_nullhomotopic (X : Type*) [TopologicalSpace X] [ContractibleSpace X] (ContinuousMap.id X).Nullhomotopic := by obtain ⟨hv⟩ := ContractibleSpace.hequiv_unit X use hv.invFun () - convert hv.left_inv.symm + convert! hv.left_inv.symm theorem contractible_iff_id_nullhomotopic (Y : Type*) [TopologicalSpace Y] : ContractibleSpace Y ↔ (ContinuousMap.id Y).Nullhomotopic := by @@ -72,7 +72,7 @@ theorem contractible_iff_id_nullhomotopic (Y : Type*) [TopologicalSpace Y] : left_inv := ?_ right_inv := ?_ }⟩ } · exact h.symm - · convert Homotopic.refl (ContinuousMap.id Unit) + · convert! Homotopic.refl (ContinuousMap.id Unit) variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] diff --git a/Mathlib/Topology/Homotopy/HomotopyGroup.lean b/Mathlib/Topology/Homotopy/HomotopyGroup.lean index b79a0e8ef3b57e..c2ed2c6f3659f8 100644 --- a/Mathlib/Topology/Homotopy/HomotopyGroup.lean +++ b/Mathlib/Topology/Homotopy/HomotopyGroup.lean @@ -127,7 +127,7 @@ instance instContinuousEvalConst : ContinuousEvalConst (Ω^ N X x) (I^N) X := in /-- Copy of a `GenLoop` with a new map from the unit cube equal to the old one. Useful to fix definitional equalities. -/ def copy (f : Ω^ N X x) (g : (I^N) → X) (h : g = f) : Ω^ N X x := - ⟨⟨g, h.symm ▸ f.1.2⟩, by convert f.2⟩ + ⟨⟨g, h.symm ▸ f.1.2⟩, by convert! f.2⟩ theorem coe_copy (f : Ω^ N X x) {g : (I^N) → X} (h : g = f) : ⇑(copy f g h) = g := rfl diff --git a/Mathlib/Topology/Homotopy/Lifting.lean b/Mathlib/Topology/Homotopy/Lifting.lean index d129476e075f9b..6af4b7979c1d54 100644 --- a/Mathlib/Topology/Homotopy/Lifting.lean +++ b/Mathlib/Topology/Homotopy/Lifting.lean @@ -64,7 +64,7 @@ theorem exists_lift_nhds {f : C(I × A, X)} {g : I × A → E} (g_lifts : p ∘ p ∘ g' = f ∧ (∀ a, g' (0, a) = g (0, a)) ∧ ∀ t' ≤ t n, g' (t', a) = g (t', a) by obtain ⟨N, haN, N_open, hN⟩ := this n_max simp_rw [h_max _ le_rfl] at hN - refine ⟨N, N_open.mem_nhds haN, ?_⟩; convert hN + refine ⟨N, N_open.mem_nhds haN, ?_⟩; convert! hN · rw [eq_comm, Set.eq_univ_iff_forall]; exact fun t ↦ ⟨bot_le, le_top⟩ · rw [imp_iff_right]; exact le_top refine Nat.rec ⟨_, Set.mem_univ a, isOpen_univ, g, ?_, g_lifts, fun a ↦ rfl, fun _ _ ↦ rfl⟩ @@ -224,7 +224,7 @@ theorem exists_path_lifts : ∃ Γ : C(I, E), p ∘ Γ = γ ∧ Γ 0 = e := by obtain ⟨Γ, cont, eqOn, Γ_0⟩ := this n_max rw [h_max _ le_rfl] at cont eqOn exact ⟨⟨Γ, continuousOn_univ.mp - (by convert cont; rw [eq_comm, Set.eq_univ_iff_forall]; exact fun t ↦ ⟨bot_le, le_top⟩)⟩, + (by convert! cont; rw [eq_comm, Set.eq_univ_iff_forall]; exact fun t ↦ ⟨bot_le, le_top⟩)⟩, funext fun _ ↦ eqOn ⟨bot_le, le_top⟩, Γ_0⟩ intro n induction n with @@ -299,7 +299,7 @@ variable (H : C(I × A, X)) (f : C(A, E)) (H_0 : ∀ a, H (0, a) = p (f a)) (f ta.2) (H_0 ta.2) ta.1 continuous_toFun := cov.isLocalHomeomorph.continuous_lift cov.isSeparatedMap H (by ext ⟨t, a⟩; exact congr_fun (cov.liftPath_lifts ..) t) - (by convert f.continuous with a; exact cov.liftPath_zero ..) + (by convert! f.continuous with a; exact cov.liftPath_zero ..) fun a ↦ by dsimp only; exact (cov.liftPath (γ_0 := by simp [*])).2 lemma liftHomotopy_lifts : p ∘ cov.liftHomotopy H f H_0 = H := @@ -426,8 +426,11 @@ theorem existsUnique_continuousMap_lifts [SimplyConnectedSpace A] [LocPathConnec · simpa [and_comm] using cov.exists_path_lifts (f.comp γ) e₀ (by simp [γ_0, he]) let pγ : Path a₀ (γ 1) := ⟨γ, γ_0, rfl⟩ let pγ' : Path a₀ (γ 1) := ⟨γ', γ'_0, γγ'1.symm⟩ - convert cov.liftPath_apply_one_eq_of_homotopicRel (ContinuousMap.HomotopicRel.comp_continuousMap - (SimplyConnectedSpace.paths_homotopic pγ pγ') f) e₀ (by simp [he]) (by simp [he]) <;> + convert! + cov.liftPath_apply_one_eq_of_homotopicRel + (ContinuousMap.HomotopicRel.comp_continuousMap (SimplyConnectedSpace.paths_homotopic pγ pγ') + f) + e₀ (by simp [he]) (by simp [he]) <;> rw [eq_liftPath_iff'] exacts [⟨Γ_lifts, Γ_0⟩, ⟨Γ'_lifts, Γ'_0⟩] diff --git a/Mathlib/Topology/Homotopy/LocallyContractible.lean b/Mathlib/Topology/Homotopy/LocallyContractible.lean index dc6be96d51b7c8..746ef1a8a3ea24 100644 --- a/Mathlib/Topology/Homotopy/LocallyContractible.lean +++ b/Mathlib/Topology/Homotopy/LocallyContractible.lean @@ -179,7 +179,7 @@ theorem StronglyLocallyContractibleSpace.locallyContractible [StronglyLocallyCon obtain ⟨v₀, hid⟩ := id_nullhomotopic V -- The inclusion V ↪ U is homotopic to the constant map at (inclusion v₀) refine ⟨ContinuousMap.inclusion hVU v₀, ?_⟩ - convert Homotopic.comp (.refl _) hid + convert! Homotopic.comp (.refl _) hid ext simp diff --git a/Mathlib/Topology/Homotopy/Path.lean b/Mathlib/Topology/Homotopy/Path.lean index b5ca7d3fa45b71..1055835b65e55b 100644 --- a/Mathlib/Topology/Homotopy/Path.lean +++ b/Mathlib/Topology/Homotopy/Path.lean @@ -404,8 +404,8 @@ end Quotient -- Porting note: we didn't previously need the `α := ...` and `β := ...` hints. theorem hpath_hext {p₁ : Path x₀ x₁} {p₂ : Path x₂ x₃} (hp : ∀ t, p₁ t = p₂ t) : HEq (α := Path.Homotopic.Quotient _ _) ⟦p₁⟧ (β := Path.Homotopic.Quotient _ _) ⟦p₂⟧ := by - obtain rfl : x₀ = x₂ := by convert hp 0 <;> simp - obtain rfl : x₁ = x₃ := by convert hp 1 <;> simp + obtain rfl : x₀ = x₂ := by convert! hp 0 <;> simp + obtain rfl : x₁ = x₃ := by convert! hp 1 <;> simp rw [heq_iff_eq]; congr; ext t; exact hp t end Homotopic diff --git a/Mathlib/Topology/IndicatorConstPointwise.lean b/Mathlib/Topology/IndicatorConstPointwise.lean index 867f40d4fdbc93..df11b94be10a5e 100644 --- a/Mathlib/Topology/IndicatorConstPointwise.lean +++ b/Mathlib/Topology/IndicatorConstPointwise.lean @@ -76,7 +76,7 @@ lemma tendsto_indicator_const_apply_iff_eventually' (b : β) classical have heart := @tendsto_ite ι L β (fun i ↦ x ∈ As i) _ (x ∈ A) _ b 0 (𝓝 b) (𝓝 (0 : β)) nhds_o nhds_b ?_ ?_ - · convert heart + · convert! heart by_cases hxA : x ∈ A <;> simp [hxA] · simp only [principal_singleton, le_def, mem_pure] exact fun s s_nhds ↦ mem_of_mem_nhds s_nhds diff --git a/Mathlib/Topology/Instances/AddCircle/Defs.lean b/Mathlib/Topology/Instances/AddCircle/Defs.lean index 1bf98657de1de1..19d0f23e4a5ce7 100644 --- a/Mathlib/Topology/Instances/AddCircle/Defs.lean +++ b/Mathlib/Topology/Instances/AddCircle/Defs.lean @@ -137,7 +137,7 @@ theorem eventuallyEq_toIcoDiv_nhds (hx : ¬x ≡ a [PMOD p]) : toIcoDiv hp a =ᶠ[𝓝 x] fun _ ↦ toIcoDiv hp a x := by rw [← nhdsLT_sup_nhdsGE, Filter.EventuallyEq, Filter.eventually_sup] refine ⟨?_, eventuallyEq_toIcoDiv_nhdsGE hp a x⟩ - convert (eventuallyEq_toIcoDiv_nhdsLT hp a x).eventually using 3 + convert! (eventuallyEq_toIcoDiv_nhdsLT hp a x).eventually using 3 rwa [← not_modEq_iff_toIcoDiv_eq_toIocDiv, AddCommGroup.modEq_comm] /-- If `x` is not congruent to `a` modulo `p`, then `toIcoDiv` is continuous at `x`. @@ -156,7 +156,7 @@ theorem eventuallyEq_toIocDiv_nhds (hx : ¬x ≡ a [PMOD p]) : toIocDiv hp a =ᶠ[𝓝 x] fun _ ↦ toIocDiv hp a x := by rw [← nhdsLE_sup_nhdsGT, Filter.EventuallyEq, Filter.eventually_sup] refine ⟨eventuallyEq_toIocDiv_nhdsLE hp a x, ?_⟩ - convert (eventuallyEq_toIocDiv_nhdsGT hp a x).eventually using 3 + convert! (eventuallyEq_toIocDiv_nhdsGT hp a x).eventually using 3 rwa [eq_comm, ← not_modEq_iff_toIcoDiv_eq_toIocDiv, AddCommGroup.modEq_comm] /-- If `x` is not congruent to `a` modulo `p`, then `toIocDiv` is continuous at `x`. @@ -266,8 +266,9 @@ theorem finite_torsion_of_isSMulRegular (n : ℕ) (hn : IsSMulRegular 𝕜 n) : theorem card_torsion_le_of_isSMulRegular_int (n : ℤ) (h0 : n ≠ 0) (hn : IsSMulRegular 𝕜 n) : {x : AddCircle p | n • x = 0}.encard ≤ n.natAbs := by - convert card_torsion_le_of_isSMulRegular p _ - (Int.natAbs_ne_zero.mpr h0) (IsSMulRegular.natAbs_iff.mpr hn) using 1 + convert! + card_torsion_le_of_isSMulRegular p _ (Int.natAbs_ne_zero.mpr h0) + (IsSMulRegular.natAbs_iff.mpr hn) using 1 simp theorem finite_torsion_of_isSMulRegular_int (n : ℤ) (hn : IsSMulRegular 𝕜 n) : @@ -590,7 +591,7 @@ theorem gcd_mul_addOrderOf_div_eq {n : ℕ} (m : ℕ) (hn : 0 < n) : theorem addOrderOf_div_of_gcd_eq_one {m n : ℕ} (hn : 0 < n) (h : m.gcd n = 1) : addOrderOf (↑(↑m / ↑n * p) : AddCircle p) = n := by - convert gcd_mul_addOrderOf_div_eq p m hn + convert! gcd_mul_addOrderOf_div_eq p m hn rw [h, one_mul] theorem addOrderOf_div_of_gcd_eq_one' {m : ℤ} {n : ℕ} (hn : 0 < n) (h : m.natAbs.gcd n = 1) : @@ -635,7 +636,7 @@ theorem addOrderOf_eq_pos_iff {u : AddCircle p} {n : ℕ} (h : 0 < n) : obtain ⟨m, hm, hk⟩ := (AddCircle.nsmul_eq_zero_iff h).mp (addOrderOf_nsmul_eq_zero (k : AddCircle p)) refine ⟨m, hm, mul_right_cancel₀ h.ne' ?_, hk⟩ - convert gcd_mul_addOrderOf_div_eq p m h using 1 + convert! gcd_mul_addOrderOf_div_eq p m h using 1 · rw [hk] · apply one_mul diff --git a/Mathlib/Topology/Instances/Complex.lean b/Mathlib/Topology/Instances/Complex.lean index ae025ce2d675d0..ca6270fc0f245a 100644 --- a/Mathlib/Topology/Instances/Complex.lean +++ b/Mathlib/Topology/Instances/Complex.lean @@ -83,7 +83,7 @@ theorem Complex.uniformContinuous_ringHom_eq_id_or_conj (K : Subfield ℂ) {ψ : -- We could add a `@[simp]` lemma fixing this, but it breaks later steps of the proof. erw [hr] at this rw [RingEquiv.toRingHom_eq_coe] at this - convert this using 1 + convert! this using 1 · exact (IsDenseInducing.extend_eq di hc.continuous _).symm · rw [← ofRealHom.coe_rangeRestrict, hr] rfl @@ -101,24 +101,25 @@ theorem Complex.uniformContinuous_ringHom_eq_id_or_conj (K : Subfield ℂ) {ψ : rcases ringHom_eq_id_or_conj_of_continuous hψ₁ with h | h · left ext1 z - convert RingHom.congr_fun h z using 1 + convert! RingHom.congr_fun h z using 1 exact (IsDenseInducing.extend_eq di hc.continuous z).symm · right ext1 z - convert RingHom.congr_fun h z using 1 + convert! RingHom.congr_fun h z using 1 exact (IsDenseInducing.extend_eq di hc.continuous z).symm · let j : { x // x ∈ closure (id '' K) } → (K.topologicalClosure : Set ℂ) := fun x => ⟨x, by - convert x.prop + convert! x.prop simp only [id, Set.image_id'] rfl ⟩ - convert DenseRange.comp (Function.Surjective.denseRange _) - (IsDenseEmbedding.id.subtype (· ∈ K)).dense (by fun_prop : Continuous j) + convert! + DenseRange.comp (Function.Surjective.denseRange _) (IsDenseEmbedding.id.subtype (· ∈ K)).dense + (by fun_prop : Continuous j) rintro ⟨y, hy⟩ use ⟨y, by - convert hy + convert! hy simp only [id, Set.image_id'] rfl ⟩ diff --git a/Mathlib/Topology/Instances/EReal/Lemmas.lean b/Mathlib/Topology/Instances/EReal/Lemmas.lean index 1ca43ae39c84e5..2fae51424907ce 100644 --- a/Mathlib/Topology/Instances/EReal/Lemmas.lean +++ b/Mathlib/Topology/Instances/EReal/Lemmas.lean @@ -460,7 +460,7 @@ much as possible the symmetries of the multiplication. -/ private lemma continuousAt_mul_swap {a b : EReal} (h : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (a, b)) : ContinuousAt (fun p : EReal × EReal ↦ p.1 * p.2) (b, a) := by - convert h.comp continuous_swap.continuousAt (x := (b, a)) + convert! h.comp continuous_swap.continuousAt (x := (b, a)) simp [mul_comm] private lemma continuousAt_mul_symm1 {a b : EReal} diff --git a/Mathlib/Topology/Instances/Real/Lemmas.lean b/Mathlib/Topology/Instances/Real/Lemmas.lean index c1947cdd896f7d..1603147677df83 100644 --- a/Mathlib/Topology/Instances/Real/Lemmas.lean +++ b/Mathlib/Topology/Instances/Real/Lemmas.lean @@ -110,7 +110,7 @@ theorem closure_ordConnected_inter_rat {s : Set ℝ} (conn : s.OrdConnected) (nt theorem closure_of_rat_image_lt {q : ℚ} : closure (((↑) : ℚ → ℝ) '' { x | q < x }) = { r | ↑q ≤ r } := by - convert closure_ordConnected_inter_rat (ordConnected_Ioi (a := (q : ℝ))) _ using 1 + convert! closure_ordConnected_inter_rat (ordConnected_Ioi (a := (q : ℝ))) _ using 1 · congr!; aesop · exact (closure_Ioi _).symm · exact ⟨q + 1, show (q : ℝ) < _ by linarith, q + 2, show (q : ℝ) < _ by linarith, by simp⟩ diff --git a/Mathlib/Topology/JacobsonSpace.lean b/Mathlib/Topology/JacobsonSpace.lean index 582242e789be61..9723f4d810ef80 100644 --- a/Mathlib/Topology/JacobsonSpace.lean +++ b/Mathlib/Topology/JacobsonSpace.lean @@ -46,7 +46,7 @@ lemma preimage_closedPoints_subset (hf : Function.Injective f) (hf' : Continuous f ⁻¹' closedPoints Y ⊆ closedPoints X := by intro x hx rw [mem_closedPoints_iff] - convert continuous_iff_isClosed.mp hf' _ hx + convert! continuous_iff_isClosed.mp hf' _ hx rw [← Set.image_singleton, Set.preimage_image_eq _ hf] lemma Topology.IsClosedEmbedding.preimage_closedPoints (hf : IsClosedEmbedding f) : @@ -60,7 +60,7 @@ lemma closedPoints_eq_univ [T1Space X] : lemma Set.Finite.isDiscrete_of_subset_closedPoints {s : Set X} (hs : s.Finite) (hs' : s ⊆ closedPoints X) : IsDiscrete s := by - have : T1Space s := ⟨fun x ↦ by convert (hs' x.2).preimage continuous_subtype_val; aesop⟩ + have : T1Space s := ⟨fun x ↦ by convert! (hs' x.2).preimage continuous_subtype_val; aesop⟩ have : Finite s := hs exact ⟨inferInstance⟩ @@ -182,12 +182,13 @@ lemma TopologicalSpace.IsOpenCover.jacobsonSpace_iff {ι : Type*} {U : ι → Op · convert_to IsClosed {(⟨y, h⟩ : U j)} · ext; simp [← Subtype.coe_inj] apply isClosed_singleton_of_isLocallyClosed_singleton - convert (hy'.isLocallyClosed.image IsEmbedding.subtypeVal.isInducing - (U i).2.isOpenEmbedding_subtypeVal.isOpen_range.isLocallyClosed).preimage - continuous_subtype_val + convert! + (hy'.isLocallyClosed.image IsEmbedding.subtypeVal.isInducing + (U i).2.isOpenEmbedding_subtypeVal.isOpen_range.isLocallyClosed).preimage + continuous_subtype_val ext simp [← Subtype.coe_inj] - · convert isClosed_empty + · convert! isClosed_empty rw [Set.eq_empty_iff_forall_notMem] intro z (hz : z.1 = y.1) exact h (hz ▸ z.2) diff --git a/Mathlib/Topology/LocalAtTarget.lean b/Mathlib/Topology/LocalAtTarget.lean index adba5129b27f71..6bb1eb268b78e7 100644 --- a/Mathlib/Topology/LocalAtTarget.lean +++ b/Mathlib/Topology/LocalAtTarget.lean @@ -132,7 +132,7 @@ theorem isOpenMap_iff_restrictPreimage : refine ⟨fun h i ↦ h.restrictPreimage _, fun H s hs ↦ ?_⟩ rw [hU.isOpen_iff_coe_preimage] intro i - convert H i _ (hs.preimage continuous_subtype_val) + convert! H i _ (hs.preimage continuous_subtype_val) ext ⟨x, hx⟩ suffices (∃ y, y ∈ s ∧ f y = x) ↔ ∃ y, y ∈ s ∧ f y ∈ U i ∧ f y = x by simpa [← Subtype.coe_inj] exact ⟨fun ⟨a, b, c⟩ ↦ ⟨a, b, c.symm ▸ hx, c⟩, by tauto⟩ @@ -142,7 +142,7 @@ theorem isClosedMap_iff_restrictPreimage : refine ⟨fun h i => h.restrictPreimage _, fun H s hs ↦ ?_⟩ rw [hU.isClosed_iff_coe_preimage] intro i - convert H i _ ⟨⟨_, hs.1, eq_compl_comm.mpr rfl⟩⟩ + convert! H i _ ⟨⟨_, hs.1, eq_compl_comm.mpr rfl⟩⟩ ext ⟨x, hx⟩ suffices (∃ y, y ∈ s ∧ f y = x) ↔ ∃ y, y ∈ s ∧ f y ∈ U i ∧ f y = x by simpa [← Subtype.coe_inj] exact ⟨fun ⟨a, b, c⟩ => ⟨a, b, c.symm ▸ hx, c⟩, by tauto⟩ @@ -218,7 +218,7 @@ include hU lemma isOpenMap_iff_comp : IsOpenMap f ↔ ∀ i, IsOpenMap (f ∘ ((↑) : U i → α)) := by refine ⟨fun hf ↦ fun i ↦ hf.comp (U i).isOpenEmbedding'.isOpenMap, fun hf ↦ ?_⟩ intro V hV - convert isOpen_iUnion (fun i ↦ hf i _ <| isOpen_induced hV) + convert! isOpen_iUnion (fun i ↦ hf i _ <| isOpen_induced hV) simp_rw [Set.image_comp, Set.image_preimage_eq_inter_range, ← Set.image_iUnion, Subtype.range_coe_subtype, SetLike.setOf_mem_eq, hU.iUnion_inter] @@ -274,7 +274,7 @@ theorem isEmbedding_of_iSup_eq_top_of_preimage_subset_range simpa [f', Set.range_comp, Set.range_restrictPreimage] using hV i let e := this.toHomeomorph.trans (Homeomorph.setCongr hf') refine IsEmbedding.of_comp (by fun_prop) continuous_subtype_val ?_ - convert ((hV' i).comp IsEmbedding.subtypeVal).comp e.symm.isEmbedding + convert! ((hV' i).comp IsEmbedding.subtypeVal).comp e.symm.isEmbedding ext x obtain ⟨x, rfl⟩ := e.surjective x simp diff --git a/Mathlib/Topology/LocallyClosed.lean b/Mathlib/Topology/LocallyClosed.lean index 79e32cd48efdc5..7869c01614701d 100644 --- a/Mathlib/Topology/LocallyClosed.lean +++ b/Mathlib/Topology/LocallyClosed.lean @@ -180,8 +180,9 @@ lemma isLocallyClosed_tfae (s : Set X) : · exact (subset_iUnion₂ _ _ <| hxU x ·) tfae_have 5 → 1 | H => by - convert H.isLocallyClosed.image IsInducing.subtypeVal - (by simpa using isClosed_closure.isLocallyClosed) + convert! + H.isLocallyClosed.image IsInducing.subtypeVal + (by simpa using isClosed_closure.isLocallyClosed) simpa using subset_closure tfae_finish diff --git a/Mathlib/Topology/LocallyConstant/Basic.lean b/Mathlib/Topology/LocallyConstant/Basic.lean index 3ed81a9bfdb292..6d585bf8b7e870 100644 --- a/Mathlib/Topology/LocallyConstant/Basic.lean +++ b/Mathlib/Topology/LocallyConstant/Basic.lean @@ -289,13 +289,13 @@ def ofIsClopen {X : Type*} [TopologicalSpace X] {U : Set X} [∀ x, Decidable (x toFun x := if x ∈ U then 0 else 1 isLocallyConstant := by refine IsLocallyConstant.iff_isOpen_fiber.2 <| Fin.forall_fin_two.2 ⟨?_, ?_⟩ - · convert hU.2 using 1 + · convert! hU.2 using 1 ext simp only [mem_singleton_iff, Fin.one_eq_zero_iff, mem_preimage, ite_eq_left_iff, Nat.succ_succ_ne_one] tauto · rw [← isClosed_compl_iff] - convert hU.1 + convert! hU.1 ext simp @@ -534,7 +534,7 @@ def piecewise {C₁ C₂ : Set X} (h₁ : IsClosed C₁) (h₂ : IsClosed C₂) refine (locallyFinite_of_finite _).continuous h (fun i ↦ ?_) (fun i ↦ ?_) · cases i <;> [exact h₂; exact h₁] · cases i <;> rw [continuousOn_iff_continuous_restrict] - · convert hg + · convert! hg ext x simp only [cond_false, restrict_apply, Subtype.coe_eta, dite_eq_right_iff] exact fun hx ↦ hfg x ⟨hx, x.prop⟩ diff --git a/Mathlib/Topology/LocallyFinsupp.lean b/Mathlib/Topology/LocallyFinsupp.lean index 80612fc9ca39a6..c3eac2f6669606 100644 --- a/Mathlib/Topology/LocallyFinsupp.lean +++ b/Mathlib/Topology/LocallyFinsupp.lean @@ -229,8 +229,11 @@ support within `U` is also closed. theorem closedSupport [T1Space X] [Zero Y] (D : locallyFinsuppWithin U Y) (hU : IsClosed U) : IsClosed D.support := by - convert isClosed_sdiff_of_codiscreteWithin ((supportDiscreteWithin_iff_locallyFiniteWithin - D.supportWithinDomain).2 D.supportLocallyFiniteWithinDomain) hU + convert! + isClosed_sdiff_of_codiscreteWithin + ((supportDiscreteWithin_iff_locallyFiniteWithin D.supportWithinDomain).2 + D.supportLocallyFiniteWithinDomain) + hU ext x constructor <;> intro hx · simp_all [D.supportWithinDomain hx] diff --git a/Mathlib/Topology/Maps/Basic.lean b/Mathlib/Topology/Maps/Basic.lean index afbe2e24db61b9..95ca6b0a625fdb 100644 --- a/Mathlib/Topology/Maps/Basic.lean +++ b/Mathlib/Topology/Maps/Basic.lean @@ -706,7 +706,9 @@ theorem IsOpenEmbedding.map_nhds_eq (hf : IsOpenEmbedding f) (x : X) : lemma IsOpenEmbedding.isOpen_iff_image_isOpen (hf : IsOpenEmbedding f) {s : Set X} : IsOpen s ↔ IsOpen (f '' s) where mp := hf.isOpenMap s - mpr h := by convert ← h.preimage hf.isEmbedding.continuous; apply preimage_image_eq _ hf.injective + mpr h := by + convert! ← h.preimage hf.isEmbedding.continuous + apply preimage_image_eq _ hf.injective theorem IsOpenEmbedding.tendsto_nhds_iff [TopologicalSpace Z] {f : ι → Y} {l : Filter ι} {y : Y} (hg : IsOpenEmbedding g) : Tendsto f l (𝓝 y) ↔ Tendsto (g ∘ f) l (𝓝 (g y)) := @@ -857,7 +859,7 @@ protected lemma of_comp (hg : IsEmbedding g) (hgf : IsClosedEmbedding (g ∘ f)) IsClosedEmbedding f where __ := hg.of_comp_iff.mp hgf.isEmbedding isClosed_range := by - convert hg.isClosed_preimage _ hgf.isClosed_range + convert! hg.isClosed_preimage _ hgf.isClosed_range rw [range_comp, hg.injective.preimage_image] theorem closure_image_eq (hf : IsClosedEmbedding f) (s : Set X) : diff --git a/Mathlib/Topology/Maps/Proper/CompactlyGenerated.lean b/Mathlib/Topology/Maps/Proper/CompactlyGenerated.lean index 1d8957bc71ffdc..e822be9ffaacd4 100644 --- a/Mathlib/Topology/Maps/Proper/CompactlyGenerated.lean +++ b/Mathlib/Topology/Maps/Proper/CompactlyGenerated.lean @@ -34,7 +34,7 @@ theorem isProperMap_iff_isCompact_preimage : mp hf := ⟨hf.continuous, fun _ ↦ hf.isCompact_preimage⟩ mpr := fun ⟨hf, h⟩ ↦ isProperMap_iff_isClosedMap_and_compact_fibers.2 ⟨hf, fun s hs ↦ (CompactlyCoherentSpace.isClosed_iff _).mpr fun K hK ↦ by - convert (((h hK).inter_left hs).image hf).isClosed.preimage continuous_subtype_val using 1 + convert! (((h hK).inter_left hs).image hf).isClosed.preimage continuous_subtype_val using 1 aesop, fun _ ↦ h isCompact_singleton⟩ /-- Version of `isProperMap_iff_isCompact_preimage` in terms of `cocompact`. diff --git a/Mathlib/Topology/MetricSpace/Algebra.lean b/Mathlib/Topology/MetricSpace/Algebra.lean index dae2966c7fed05..d308dc570b83eb 100644 --- a/Mathlib/Topology/MetricSpace/Algebra.lean +++ b/Mathlib/Topology/MetricSpace/Algebra.lean @@ -79,7 +79,7 @@ instance (priority := 100) LipschitzMul.continuousMul : ContinuousMul β := instance Submonoid.lipschitzMul (s : Submonoid β) : LipschitzMul s where lipschitz_mul := ⟨LipschitzMul.C β, by rintro ⟨x₁, x₂⟩ ⟨y₁, y₂⟩ - convert lipschitzWith_lipschitz_const_mul_edist ⟨(x₁ : β), x₂⟩ ⟨y₁, y₂⟩ using 1⟩ + convert! lipschitzWith_lipschitz_const_mul_edist ⟨(x₁ : β), x₂⟩ ⟨y₁, y₂⟩ using 1⟩ @[to_additive] instance MulOpposite.lipschitzMul : LipschitzMul βᵐᵒᵖ where @@ -256,8 +256,8 @@ instance Real.isBoundedSMul : IsBoundedSMul ℝ ℝ where dist_pair_smul' x₁ x₂ y := by simpa [Real.dist_eq, sub_mul] using (abs_mul (x₁ - x₂) y).le instance NNReal.isBoundedSMul : IsBoundedSMul ℝ≥0 ℝ≥0 where - dist_smul_pair' x y₁ y₂ := by convert dist_smul_pair (x : ℝ) (y₁ : ℝ) y₂ using 1 - dist_pair_smul' x₁ x₂ y := by convert dist_pair_smul (x₁ : ℝ) x₂ (y : ℝ) using 1 + dist_smul_pair' x y₁ y₂ := by convert! dist_smul_pair (x : ℝ) (y₁ : ℝ) y₂ using 1 + dist_pair_smul' x₁ x₂ y := by convert! dist_pair_smul (x₁ : ℝ) x₂ (y : ℝ) using 1 /-- If a scalar is central, then its right action is bounded when its left action is. -/ instance IsBoundedSMul.op [SMul αᵐᵒᵖ β] [IsCentralScalar α β] : IsBoundedSMul αᵐᵒᵖ β where diff --git a/Mathlib/Topology/MetricSpace/Antilipschitz.lean b/Mathlib/Topology/MetricSpace/Antilipschitz.lean index e140ce8310d24e..58c0a94a57fa0d 100644 --- a/Mathlib/Topology/MetricSpace/Antilipschitz.lean +++ b/Mathlib/Topology/MetricSpace/Antilipschitz.lean @@ -227,7 +227,7 @@ protected theorem properSpace {α : Type*} [MetricSpace α] {K : ℝ≥0} {f : have A : IsClosed K := isClosed_closedBall.preimage f_cont have B : IsBounded K := hK.isBounded_preimage isBounded_closedBall have : IsCompact K := isCompact_iff_isClosed_bounded.2 ⟨A, B⟩ - convert this.image f_cont + convert! this.image f_cont exact (hf.image_preimage _).symm theorem isBounded_of_image2_left (f : α → β → γ) {K₁ : ℝ≥0} diff --git a/Mathlib/Topology/MetricSpace/Bounded.lean b/Mathlib/Topology/MetricSpace/Bounded.lean index 0872efa8d57104..26419b89790cfd 100644 --- a/Mathlib/Topology/MetricSpace/Bounded.lean +++ b/Mathlib/Topology/MetricSpace/Bounded.lean @@ -382,12 +382,12 @@ variable {α : Type*} [AddCommGroup α] [LinearOrder α] [IsOrderedAddMonoid α] [CompactIccSpace α] lemma isBounded_of_abs_le (C : α) : Bornology.IsBounded {x : α | |x| ≤ C} := by - convert Metric.isBounded_Icc (-C) C + convert! Metric.isBounded_Icc (-C) C ext1 x simp [abs_le] lemma isBounded_of_abs_lt (C : α) : Bornology.IsBounded {x : α | |x| < C} := by - convert Metric.isBounded_Ioo (-C) C + convert! Metric.isBounded_Ioo (-C) C ext1 x simp [abs_lt] diff --git a/Mathlib/Topology/MetricSpace/Contracting.lean b/Mathlib/Topology/MetricSpace/Contracting.lean index 280fe0b089915f..89c82e3676563f 100644 --- a/Mathlib/Topology/MetricSpace/Contracting.lean +++ b/Mathlib/Topology/MetricSpace/Contracting.lean @@ -125,7 +125,7 @@ theorem apriori_edist_iterate_efixedPoint_le (hf : ContractingWith K f) {x : α} theorem edist_efixedPoint_le (hf : ContractingWith K f) {x : α} (hx : edist x (f x) ≠ ∞) : edist x (efixedPoint f hf x hx) ≤ edist x (f x) / (1 - K) := by - convert hf.apriori_edist_iterate_efixedPoint_le hx 0 + convert! hf.apriori_edist_iterate_efixedPoint_le hx 0 simp only [pow_zero, mul_one] theorem edist_efixedPoint_lt_top (hf : ContractingWith K f) {x : α} (hx : edist x (f x) ≠ ∞) : @@ -155,9 +155,9 @@ theorem exists_fixedPoint' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s haveI := hsc.completeSpace_coe rcases hf.exists_fixedPoint ⟨x, hxs⟩ hx with ⟨y, hfy, h_tendsto, hle⟩ refine ⟨y, y.2, Subtype.ext_iff.1 hfy, ?_, fun n ↦ ?_⟩ - · convert (continuous_subtype_val.tendsto _).comp h_tendsto + · convert! (continuous_subtype_val.tendsto _).comp h_tendsto simp only [(· ∘ ·), MapsTo.iterate_restrict, MapsTo.val_restrict_apply] - · convert hle n + · convert! hle n rw [MapsTo.iterate_restrict] rfl @@ -196,7 +196,7 @@ theorem apriori_edist_iterate_efixedPoint_le' {s : Set α} (hsc : IsComplete s) theorem edist_efixedPoint_le' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s) (hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) : edist x (efixedPoint' f hsc hsf hf x hxs hx) ≤ edist x (f x) / (1 - K) := by - convert hf.apriori_edist_iterate_efixedPoint_le' hsc hsf hxs hx 0 + convert! hf.apriori_edist_iterate_efixedPoint_le' hsc hsf hxs hx 0 rw [pow_zero, mul_one] theorem edist_efixedPoint_lt_top' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s) @@ -298,7 +298,7 @@ theorem apriori_dist_iterate_fixedPoint_le (x n) : theorem tendsto_iterate_fixedPoint (x) : Tendsto (fun n ↦ f^[n] x) atTop (𝓝 <| fixedPoint f hf) := by - convert tendsto_iterate_efixedPoint hf (edist_ne_top x _) + convert! tendsto_iterate_efixedPoint hf (edist_ne_top x _) refine (fixedPoint_unique _ ?_).symm apply efixedPoint_isFixedPt diff --git a/Mathlib/Topology/MetricSpace/Gluing.lean b/Mathlib/Topology/MetricSpace/Gluing.lean index 843aeb1d0dc9ef..26c5c470426f76 100644 --- a/Mathlib/Topology/MetricSpace/Gluing.lean +++ b/Mathlib/Topology/MetricSpace/Gluing.lean @@ -452,7 +452,7 @@ protected theorem completeSpace [∀ i, CompleteSpace (E i)] : CompleteSpace (Σ have hd : ∀ (i j), ∀ x ∈ s i, ∀ y ∈ s j, (x, y) ∈ U → i = j := fun i j x hx y hy hxy => (Eq.symm hx).trans ((fst_eq_of_dist_lt_one _ _ hxy).trans hy) refine completeSpace_of_isComplete_univ ?_ - convert isComplete_iUnion_separated hc (dist_mem_uniformity zero_lt_one) hd + convert! isComplete_iUnion_separated hc (dist_mem_uniformity zero_lt_one) hd simp only [s, ← preimage_iUnion, iUnion_of_singleton, preimage_univ] end Sigma diff --git a/Mathlib/Topology/MetricSpace/GromovHausdorff.lean b/Mathlib/Topology/MetricSpace/GromovHausdorff.lean index aae27911017575..70934af7912b61 100644 --- a/Mathlib/Topology/MetricSpace/GromovHausdorff.lean +++ b/Mathlib/Topology/MetricSpace/GromovHausdorff.lean @@ -1007,7 +1007,7 @@ instance : CompleteSpace GHSpace := by rw [Function.comp_apply, NonemptyCompacts.toGHSpace, ← (u n).toGHSpace_rep, toGHSpace_eq_toGHSpace_iff_isometryEquiv] constructor - convert (isom n).isometryEquivOnRange.symm + convert! (isom n).isometryEquivOnRange.symm -- the images of `X3 n` in the Gromov-Hausdorff space converge to the image of `L` -- so the images of `u n` converge to the image of `L` as well use L.toGHSpace diff --git a/Mathlib/Topology/MetricSpace/HausdorffDistance.lean b/Mathlib/Topology/MetricSpace/HausdorffDistance.lean index 8e76472a7aa26c..bc5626fe15264c 100644 --- a/Mathlib/Topology/MetricSpace/HausdorffDistance.lean +++ b/Mathlib/Topology/MetricSpace/HausdorffDistance.lean @@ -431,7 +431,7 @@ theorem hausdorffEDist_iUnion_le {ι : Sort*} {s t : ι → Set α} : theorem hausdorffEDist_union_le {s₁ s₂ t₁ t₂ : Set α} : hausdorffEDist (s₁ ∪ s₂) (t₁ ∪ t₂) ≤ max (hausdorffEDist s₁ t₁) (hausdorffEDist s₂ t₂) := by simp_rw [union_eq_iUnion, sup_eq_iSup] - convert hausdorffEDist_iUnion_le with (_ | _) + convert! hausdorffEDist_iUnion_le with (_ | _) theorem hausdorffEDist_prod_le {s₁ t₁ : Set α} {s₂ t₂ : Set β} : hausdorffEDist (s₁ ×ˢ s₂) (t₁ ×ˢ t₂) ≤ max (hausdorffEDist s₁ t₁) (hausdorffEDist s₂ t₂) := by diff --git a/Mathlib/Topology/MetricSpace/Holder.lean b/Mathlib/Topology/MetricSpace/Holder.lean index 48f17d61e15830..11d9e8bf780056 100644 --- a/Mathlib/Topology/MetricSpace/Holder.lean +++ b/Mathlib/Topology/MetricSpace/Holder.lean @@ -217,7 +217,7 @@ then it is `(C, r * t₁ + s * t₂)`-Hölder for all `t₁ t₂ : ℝ≥0` such lemma interpolate_const {C s t₁ t₂ : ℝ≥0} {A : Set X} (hf₁ : HolderOnWith C r f A) (hf₂ : HolderOnWith C s f A) (ht : t₁ + t₂ = 1) : HolderOnWith C (r * t₁ + s * t₂) f A := by - convert hf₁.interpolate hf₂ ht + convert! hf₁.interpolate hf₂ ht simp [← NNReal.rpow_add_of_nonneg, ← NNReal.coe_add, ht] variable (f) in diff --git a/Mathlib/Topology/MetricSpace/Infsep.lean b/Mathlib/Topology/MetricSpace/Infsep.lean index 83692fb4366851..1432be6a0ca356 100644 --- a/Mathlib/Topology/MetricSpace/Infsep.lean +++ b/Mathlib/Topology/MetricSpace/Infsep.lean @@ -178,7 +178,7 @@ variable [PseudoEMetricSpace α] {x y z : α} {s : Set α} theorem einfsep_pair (hxy : x ≠ y) : ({x, y} : Set α).einfsep = edist x y := by nth_rw 1 [← min_self (edist x y)] - convert einfsep_pair_eq_inf hxy using 2 + convert! einfsep_pair_eq_inf hxy using 2 rw [edist_comm] theorem einfsep_insert : einfsep (insert x s) = diff --git a/Mathlib/Topology/MetricSpace/Kuratowski.lean b/Mathlib/Topology/MetricSpace/Kuratowski.lean index 5a4d750043a78a..b09bddacde1d24 100644 --- a/Mathlib/Topology/MetricSpace/Kuratowski.lean +++ b/Mathlib/Topology/MetricSpace/Kuratowski.lean @@ -53,7 +53,7 @@ theorem embeddingOfSubset_dist_le (a b : α) : rw [dist_eq_norm] refine lp.norm_le_of_forall_le dist_nonneg fun n => ?_ simp only [lp.coeFn_sub, Pi.sub_apply, embeddingOfSubset_coe] - convert abs_dist_sub_le a b (x n) using 2 + convert! abs_dist_sub_le a b (x n) using 2 ring /-- When the reference set is dense, the embedding map is an isometry on its image. -/ diff --git a/Mathlib/Topology/MetricSpace/Perfect.lean b/Mathlib/Topology/MetricSpace/Perfect.lean index 676fdf3eda2b24..b128c20a2c79d9 100644 --- a/Mathlib/Topology/MetricSpace/Perfect.lean +++ b/Mathlib/Topology/MetricSpace/Perfect.lean @@ -52,7 +52,7 @@ private theorem Perfect.small_diam_aux (hC : Perfect C) (ε_pos : 0 < ε) {x : apply inter_subset_right rw [Metric.ediam_closure] apply le_trans (Metric.ediam_mono inter_subset_left) - convert Metric.ediam_eball_le (x := x) + convert! Metric.ediam_eball_le (x := x) rw [mul_comm, ENNReal.div_mul_cancel] <;> norm_num /-- A refinement of `Perfect.splitting` for metric spaces, where we also control @@ -109,9 +109,9 @@ theorem Perfect.exists_nat_bool_injection rcases Nat.exists_eq_succ_of_ne_zero hm with ⟨n, rfl⟩ dsimp cases x n - · convert (h0 _ _ _).2.2.2 + · convert! (h0 _ _ _).2.2.2 rw [PiNat.res_length] - convert (h1 _ _ _).2.2.2 + convert! (h1 _ _ _).2.2.2 rw [PiNat.res_length] have hdisj' : CantorScheme.Disjoint D := by rintro l (a | a) (b | b) hab <;> try contradiction diff --git a/Mathlib/Topology/MetricSpace/PiNat.lean b/Mathlib/Topology/MetricSpace/PiNat.lean index 4d4ee1dd17ef55..b5a8e220cd71af 100644 --- a/Mathlib/Topology/MetricSpace/PiNat.lean +++ b/Mathlib/Topology/MetricSpace/PiNat.lean @@ -1121,7 +1121,7 @@ lemma continuous_distDenseSeq (n : ℕ) : Continuous (distDenseSeq X n) := by cases isEmpty_or_nonempty X · exact continuous_of_discreteTopology refine continuous_projIcc.comp <| Continuous.dist continuous_id' ?_ - convert continuous_const (y := denseSeq X n) + convert! continuous_const (y := denseSeq X n) lemma separation {x : X} {C : Set X} (hxC : C ∈ 𝓝 x) : ∃ (n : ℕ), C ∈ (𝓝 (distDenseSeq X n x)).comap (distDenseSeq X n) := by diff --git a/Mathlib/Topology/MetricSpace/ProperSpace/Lemmas.lean b/Mathlib/Topology/MetricSpace/ProperSpace/Lemmas.lean index c9fe60566ad5d4..ecac5545dbd00e 100644 --- a/Mathlib/Topology/MetricSpace/ProperSpace/Lemmas.lean +++ b/Mathlib/Topology/MetricSpace/ProperSpace/Lemmas.lean @@ -68,7 +68,7 @@ lemma isProperMap_dist (x : α) : IsProperMap (dist x) := omit [ProperSpace α] in lemma properSpace_iff_isProperMap_dist : ProperSpace α ↔ ∀ x : α, IsProperMap (dist x) := by refine ⟨fun _ ↦ isProperMap_dist, fun H ↦ ⟨fun x r ↦ ?_⟩⟩ - convert (H x).isCompact_preimage (isCompact_closedBall 0 r) + convert! (H x).isCompact_preimage (isCompact_closedBall 0 r) ext simp [dist_comm, Real.dist_eq] diff --git a/Mathlib/Topology/MetricSpace/Pseudo/Constructions.lean b/Mathlib/Topology/MetricSpace/Pseudo/Constructions.lean index 5e3283018fd154..b8c6b9bf74083b 100644 --- a/Mathlib/Topology/MetricSpace/Pseudo/Constructions.lean +++ b/Mathlib/Topology/MetricSpace/Pseudo/Constructions.lean @@ -139,7 +139,7 @@ lemma NNReal.ball_zero_eq_Ico' (c : ℝ≥0) : lemma NNReal.ball_zero_eq_Ico (c : ℝ) : Metric.ball (0 : ℝ≥0) c = Set.Ico 0 c.toNNReal := by by_cases! c_pos : 0 < c - · convert NNReal.ball_zero_eq_Ico' (NNReal.mk c c_pos.le) + · convert! NNReal.ball_zero_eq_Ico' (NNReal.mk c c_pos.le) simp [Real.toNNReal, c_pos.le] simp [c_pos] @@ -148,7 +148,7 @@ lemma NNReal.closedBall_zero_eq_Icc' (c : ℝ≥0) : lemma NNReal.closedBall_zero_eq_Icc {c : ℝ} (c_nn : 0 ≤ c) : Metric.closedBall (0 : ℝ≥0) c = Set.Icc 0 c.toNNReal := by - convert NNReal.closedBall_zero_eq_Icc' (NNReal.mk c c_nn) + convert! NNReal.closedBall_zero_eq_Icc' (NNReal.mk c c_nn) simp [Real.toNNReal, c_nn] end NNReal diff --git a/Mathlib/Topology/MetricSpace/UniformConvergence.lean b/Mathlib/Topology/MetricSpace/UniformConvergence.lean index 24b4a7b5548da0..c63df0f2087219 100644 --- a/Mathlib/Topology/MetricSpace/UniformConvergence.lean +++ b/Mathlib/Topology/MetricSpace/UniformConvergence.lean @@ -303,7 +303,7 @@ noncomputable instance [BoundedSpace β] : PseudoMetricSpace (α →ᵤ[𝔖] β noncomputable instance [BoundedSpace β] : BoundedSpace (α →ᵤ[𝔖] β) where bounded_univ := by - convert lipschitzWith_one_ofFun_toFun (𝔖 := 𝔖) (β := β) |>.isBounded_image (.all Set.univ) + convert! lipschitzWith_one_ofFun_toFun (𝔖 := 𝔖) (β := β) |>.isBounded_image (.all Set.univ) ext f simp only [Set.mem_univ, Function.comp_apply, Set.image_univ, Set.mem_range, true_iff] exact ⟨UniformFun.ofFun (toFun 𝔖 f), by simp⟩ diff --git a/Mathlib/Topology/Metrizable/CompletelyMetrizable.lean b/Mathlib/Topology/Metrizable/CompletelyMetrizable.lean index 2cd4cbb2d45069..e03365274cc588 100644 --- a/Mathlib/Topology/Metrizable/CompletelyMetrizable.lean +++ b/Mathlib/Topology/Metrizable/CompletelyMetrizable.lean @@ -82,7 +82,7 @@ noncomputable def completelyPseudoMetrizableMetric (X : Type*) [TopologicalSpace theorem complete_completelyPseudoMetrizableMetric (X : Type*) [ht : TopologicalSpace X] [h : IsCompletelyPseudoMetrizableSpace X] : @CompleteSpace X (completelyPseudoMetrizableMetric X).toUniformSpace := by - convert h.complete.choose_spec.2 + convert! h.complete.choose_spec.2 exact PseudoMetricSpace.replaceTopology_eq _ _ /-- This definition endows a completely pseudometrizable space with a complete pseudometric. @@ -195,7 +195,7 @@ noncomputable def completelyMetrizableMetric (X : Type*) [TopologicalSpace X] theorem complete_completelyMetrizableMetric (X : Type*) [ht : TopologicalSpace X] [h : IsCompletelyMetrizableSpace X] : @CompleteSpace X (completelyMetrizableMetric X).toUniformSpace := by - convert h.complete.choose_spec.2 + convert! h.complete.choose_spec.2 exact MetricSpace.replaceTopology_eq _ _ /-- This definition endows a completely metrizable space with a complete metric. Use it as: @@ -273,7 +273,7 @@ instance (priority := 50) discrete [TopologicalSpace X] [DiscreteTopology X] : refine ⟨m, ?_, ?_⟩ · rw [DiscreteTopology.eq_bot (α := X)] refine eq_bot_of_singletons_open fun x ↦ ?_ - convert @Metric.isOpen_ball _ _ x 1 + convert! @Metric.isOpen_ball _ _ x 1 refine subset_antisymm (singleton_subset_iff.2 (Metric.mem_ball_self (by simp))) fun y hy ↦ ?_ simp only [Metric.mem_ball, mem_singleton_iff] at * diff --git a/Mathlib/Topology/Metrizable/Uniformity.lean b/Mathlib/Topology/Metrizable/Uniformity.lean index 7f668fb099985d..be1e4a773f8837 100644 --- a/Mathlib/Topology/Metrizable/Uniformity.lean +++ b/Mathlib/Topology/Metrizable/Uniformity.lean @@ -156,7 +156,7 @@ theorem le_two_mul_dist_ofPreNNDist (d : X → X → ℝ≥0) (dist_self : ∀ x rw [Nat.succ_le_iff] at hMl have hMl' : length (take M l) = M := length_take.trans (min_eq_left hMl.le) refine (ihn _ hMl _ _ _ hMl').trans ?_ - convert hMs.1.out + convert! hMs.1.out rw [take_zipWith, take, take_add_one, getElem?_append_left hMl, getElem?_eq_getElem hMl, ← Option.coe_def, Option.toList_some, take_append_of_le_length hMl.le, getElem_cons_succ] · exact single_le_sum (fun x _ => zero_le) _ (mem_iff_get.2 ⟨⟨M, hM_lt⟩, getElem_zipWith⟩) @@ -171,7 +171,7 @@ theorem le_two_mul_dist_ofPreNNDist (d : X → X → ℝ≥0) (dist_self : ∀ x not_lt.1 fun h => (hMs.2 h.le).not_gt M.lt_succ_self rw [← sum_take_add_sum_drop L (M + 1), two_mul, add_le_add_iff_left, ← add_le_add_iff_right, sum_take_add_sum_drop, ← two_mul] at hMs' - convert hMs' + convert! hMs' rwa [drop_zipWith, drop, drop_append_of_le_length] end PseudoMetricSpace diff --git a/Mathlib/Topology/Neighborhoods.lean b/Mathlib/Topology/Neighborhoods.lean index ce567742a17afb..67f7e7387f7058 100644 --- a/Mathlib/Topology/Neighborhoods.lean +++ b/Mathlib/Topology/Neighborhoods.lean @@ -104,7 +104,7 @@ theorem IsOpen.eventually_mem (hs : IsOpen s) (hx : x ∈ s) : for a variant using open sets around `x` instead. -/ theorem nhds_basis_opens' (x : X) : (𝓝 x).HasBasis (fun s : Set X => s ∈ 𝓝 x ∧ IsOpen s) fun x => x := by - convert nhds_basis_opens x using 2 + convert! nhds_basis_opens x using 2 exact and_congr_left_iff.2 IsOpen.mem_nhds_iff /-- If `U` is a neighborhood of each point of a set `s` then it is a neighborhood of `s`: diff --git a/Mathlib/Topology/OmegaCompletePartialOrder.lean b/Mathlib/Topology/OmegaCompletePartialOrder.lean index b05a8c57b1ca27..009eb1cfc0a39f 100644 --- a/Mathlib/Topology/OmegaCompletePartialOrder.lean +++ b/Mathlib/Topology/OmegaCompletePartialOrder.lean @@ -58,7 +58,7 @@ theorem IsOpen.inter (s t : Set α) : IsOpen α s → IsOpen α t → IsOpen α theorem isOpen_sUnion (s : Set (Set α)) (hs : ∀ t ∈ s, IsOpen α t) : IsOpen α (⋃₀ s) := by simp only [IsOpen] at hs ⊢ - convert CompleteLattice.ωScottContinuous.sSup hs + convert! CompleteLattice.ωScottContinuous.sSup hs aesop theorem IsOpen.isUpperSet {s : Set α} (hs : IsOpen α s) : IsUpperSet s := hs.monotone diff --git a/Mathlib/Topology/Order.lean b/Mathlib/Topology/Order.lean index 1bc9ade51c5cef..f87c4a05190af6 100644 --- a/Mathlib/Topology/Order.lean +++ b/Mathlib/Topology/Order.lean @@ -576,7 +576,10 @@ instance : DiscreteTopology ℤ := ⟨rfl⟩ instance {n} : TopologicalSpace (Fin n) := ⊥ instance {n} : DiscreteTopology (Fin n) := ⟨rfl⟩ -instance : DiscreteTopology (WithTopology α ⊥) where +/-- A copy of a type equipped with the discrete topology. -/ +abbrev WithDiscreteTopology (α : Type*) := WithTopology α ⊥ + +instance : DiscreteTopology (WithDiscreteTopology α) where eq_bot := coinduced_bot instance : IndiscreteTopology (WithTopology α ⊤) where diff --git a/Mathlib/Topology/Order/Compact.lean b/Mathlib/Topology/Order/Compact.lean index 19efa166d31f8a..8f328aaa190157 100644 --- a/Mathlib/Topology/Order/Compact.lean +++ b/Mathlib/Topology/Order/Compact.lean @@ -70,7 +70,7 @@ lemma CompactIccSpace.mk'' [TopologicalSpace α] [PartialOrder α] instance [TopologicalSpace α] [Preorder α] [CompactIccSpace α] : CompactIccSpace (αᵒᵈ) where isCompact_Icc := by intro a b - convert isCompact_Icc (α := α) (a := b) (b := a) using 1 + convert! isCompact_Icc (α := α) (a := b) (b := a) using 1 exact Icc_toDual (α := α) /-- A closed interval in a conditionally complete linear order is compact. -/ @@ -194,7 +194,7 @@ theorem atBot_le_cocompact [NoMinOrder α] [ClosedIicTopology α] : obtain ⟨t, ht, hts⟩ := mem_cocompact.mp hs refine (Set.eq_empty_or_nonempty t).casesOn (fun h_empty ↦ ?_) (fun h_nonempty ↦ ?_) · rewrite [compl_univ_iff.mpr h_empty, univ_subset_iff] at hts - convert univ_mem + convert! univ_mem · haveI := h_nonempty.nonempty obtain ⟨a, ha⟩ := ht.exists_isLeast h_nonempty obtain ⟨b, hb⟩ := exists_lt a diff --git a/Mathlib/Topology/Order/DenselyOrdered.lean b/Mathlib/Topology/Order/DenselyOrdered.lean index 38ad363199b29f..8e93066c807ced 100644 --- a/Mathlib/Topology/Order/DenselyOrdered.lean +++ b/Mathlib/Topology/Order/DenselyOrdered.lean @@ -263,9 +263,8 @@ lemma DenselyOrdered.subsingleton_of_discreteTopology [DiscreteTopology α] : Su suffices ∀ a b : α, b ≤ a from ⟨fun a b ↦ le_antisymm (this b a) (this a b)⟩ intro a b by_contra! contra - suffices b ∈ Ioo a b by grind - rw [← (isClosed_discrete (Ioo a b)).closure_eq, closure_Ioo contra.ne] - grind + have : Ioo a b = Icc a b := by rw [← closure_discrete (Ioo a b), closure_Ioo contra.ne] + grind => have : b ∈ Ioo a b; finish /-- Let `s` be a dense set in a nontrivial dense linear order `α`. If `s` is a separable space (e.g., if `α` has a second countable topology), then there exists a countable diff --git a/Mathlib/Topology/Order/HullKernel.lean b/Mathlib/Topology/Order/HullKernel.lean index 6212b91015284c..9929a2596d6b7d 100644 --- a/Mathlib/Topology/Order/HullKernel.lean +++ b/Mathlib/Topology/Order/HullKernel.lean @@ -111,7 +111,7 @@ Lower topology. -/ lemma isTopologicalBasis_relativeLower (hT : ∀ p ∈ T, InfPrime p) : IsTopologicalBasis { S : Set T | ∃ (a : α), (hull T a)ᶜ = S } := by - convert isTopologicalBasis_subtype Topology.IsLower.isTopologicalBasis (· ∈ T) + convert! isTopologicalBasis_subtype Topology.IsLower.isTopologicalBasis (· ∈ T) ext R simp only [preimage_compl, mem_setOf_eq, IsLower.lowerBasis, mem_image, exists_exists_and_eq_and] constructor <;> intro ha diff --git a/Mathlib/Topology/Order/LawsonTopology.lean b/Mathlib/Topology/Order/LawsonTopology.lean index d932803400d32a..778406eacc043c 100644 --- a/Mathlib/Topology/Order/LawsonTopology.lean +++ b/Mathlib/Topology/Order/LawsonTopology.lean @@ -95,9 +95,9 @@ protected theorem isTopologicalBasis : TopologicalSpace.IsTopologicalBasis (laws simp_rw [diff_eq_compl_inter] aesop rw [lawsonBasis_image2] - convert IsTopologicalBasis.inf_induced IsLower.isTopologicalBasis - (isTopologicalBasis_opens (α := WithScott α)) - WithLower.toLower WithScott.toScott + convert! + IsTopologicalBasis.inf_induced IsLower.isTopologicalBasis + (isTopologicalBasis_opens (α := WithScott α)) WithLower.toLower WithScott.toScott rw [@topology_eq_lawson α _ _ _, lawson] apply (congrArg₂ min _) _ · letI _ := lower α diff --git a/Mathlib/Topology/Order/LeftRightNhds.lean b/Mathlib/Topology/Order/LeftRightNhds.lean index 6fbcd3ffa6b139..042bfe6bb0fe20 100644 --- a/Mathlib/Topology/Order/LeftRightNhds.lean +++ b/Mathlib/Topology/Order/LeftRightNhds.lean @@ -211,8 +211,8 @@ theorem nhdsLT_basis [NoMinOrder α] (a : α) : (𝓝[<] a).HasBasis (· < a) (I nhdsLT_basis_of_exists_lt <| exists_lt a theorem nhdsLT_eq_bot_iff {a : α} : 𝓝[<] a = ⊥ ↔ IsBot a ∨ ∃ b, b ⋖ a := by - convert (config := { preTransparency := .default }) nhdsGT_eq_bot_iff (a := OrderDual.toDual a) - using 4 + convert! (config := { preTransparency := .default }) + nhdsGT_eq_bot_iff (a := OrderDual.toDual a) using 4 exact ofDual_covBy_ofDual_iff open List in @@ -405,7 +405,7 @@ theorem nhds_basis_mabs_div_lt [NoMaxOrder α] (a : α) : @[to_additive] theorem nhds_basis_Ioo_one_lt [NoMaxOrder α] (a : α) : (𝓝 a).HasBasis (fun ε : α => (1 : α) < ε) fun ε => Ioo (a / ε) (a * ε) := by - convert nhds_basis_mabs_div_lt a + convert! nhds_basis_mabs_div_lt a simp only [Ioo, mabs_lt, ← div_lt_iff_lt_mul, inv_lt_div_iff_lt_mul, div_lt_comm] @[to_additive] diff --git a/Mathlib/Topology/Order/LowerUpperTopology.lean b/Mathlib/Topology/Order/LowerUpperTopology.lean index 9865873195a3d2..dea040dc9c0ff3 100644 --- a/Mathlib/Topology/Order/LowerUpperTopology.lean +++ b/Mathlib/Topology/Order/LowerUpperTopology.lean @@ -279,7 +279,7 @@ theorem closure_singleton (a : α) : closure {a} = Ici a := (isUpperSet_of_isClosed isClosed_closure).Ici_subset <| subset_closure rfl protected theorem isTopologicalBasis : IsTopologicalBasis (lowerBasis α) := by - convert isTopologicalBasis_of_subbasis (topology_eq α) + convert! isTopologicalBasis_of_subbasis (topology_eq α) simp_rw [lowerBasis, coe_upperClosure, compl_iUnion] ext s constructor @@ -341,7 +341,7 @@ lemma isTopologicalSpace_basis (U : Set α) : IsOpen U ↔ U = univ ∨ ∃ a, ( refine ⟨?_, isTopologicalBasis_insert_univ_subbasis.isOpen⟩ intro hO apply Or.inr - convert IsTopologicalBasis.open_eq_sUnion isTopologicalBasis_insert_univ_subbasis hO + convert! IsTopologicalBasis.open_eq_sUnion isTopologicalBasis_insert_univ_subbasis hO constructor · intro ⟨a, ha⟩ use {U} @@ -511,7 +511,7 @@ variable [CompleteLattice α] [CompleteLattice β] [TopologicalSpace α] [IsLowe protected lemma _root_.sInfHom.continuous (f : sInfHom α β) : Continuous f := by refine IsLower.continuous_iff_Ici.2 fun b => ?_ - convert isClosed_Ici (a := sInf <| f ⁻¹' Ici b) + convert! isClosed_Ici (a := sInf <| f ⁻¹' Ici b) refine Subset.antisymm (fun a => sInf_le) fun a ha => le_trans ?_ <| OrderHomClass.mono (f : α →o β) ha refine LE.le.trans ?_ (map_sInf f _).ge diff --git a/Mathlib/Topology/Order/MonotoneConvergence.lean b/Mathlib/Topology/Order/MonotoneConvergence.lean index ba8a0274862b43..525b8006cece8f 100644 --- a/Mathlib/Topology/Order/MonotoneConvergence.lean +++ b/Mathlib/Topology/Order/MonotoneConvergence.lean @@ -93,7 +93,7 @@ theorem tendsto_atTop_isLUB (h_mono : Monotone f) (ha : IsLUB (Set.range f) a) : exact h_mono.rangeFactorization.tendsto_atTop_atTop fun b => b.2.imp fun a ha => ha.ge theorem tendsto_atBot_isLUB (h_anti : Antitone f) (ha : IsLUB (Set.range f) a) : - Tendsto f atBot (𝓝 a) := by convert tendsto_atTop_isLUB h_anti.dual_left ha using 1 + Tendsto f atBot (𝓝 a) := by convert! tendsto_atTop_isLUB h_anti.dual_left ha using 1 end IsLUB @@ -102,10 +102,10 @@ section IsGLB variable [Preorder α] [InfConvergenceClass α] {f : ι → α} {a : α} theorem tendsto_atBot_isGLB (h_mono : Monotone f) (ha : IsGLB (Set.range f) a) : - Tendsto f atBot (𝓝 a) := by convert tendsto_atTop_isLUB h_mono.dual ha.dual using 1 + Tendsto f atBot (𝓝 a) := by convert! tendsto_atTop_isLUB h_mono.dual ha.dual using 1 theorem tendsto_atTop_isGLB (h_anti : Antitone f) (ha : IsGLB (Set.range f) a) : - Tendsto f atTop (𝓝 a) := by convert tendsto_atBot_isLUB h_anti.dual ha.dual using 1 + Tendsto f atTop (𝓝 a) := by convert! tendsto_atBot_isLUB h_anti.dual ha.dual using 1 end IsGLB @@ -122,7 +122,7 @@ theorem tendsto_atTop_ciSup (h_mono : Monotone f) (hbdd : BddAbove <| range f) : h_mono.directed_le.directedOn_range.isLUB_csSup (Set.range_nonempty f) hbdd theorem tendsto_atBot_ciSup (h_anti : Antitone f) (hbdd : BddAbove <| range f) : - Tendsto f atBot (𝓝 (⨆ i, f i)) := by convert tendsto_atTop_ciSup h_anti.dual hbdd.dual using 1 + Tendsto f atBot (𝓝 (⨆ i, f i)) := by convert! tendsto_atTop_ciSup h_anti.dual hbdd.dual using 1 end CiSup @@ -131,10 +131,10 @@ section CiInf variable [ConditionallyCompletePartialOrderInf α] [InfConvergenceClass α] {f : ι → α} theorem tendsto_atBot_ciInf (h_mono : Monotone f) (hbdd : BddBelow <| range f) : - Tendsto f atBot (𝓝 (⨅ i, f i)) := by convert tendsto_atTop_ciSup h_mono.dual hbdd.dual using 1 + Tendsto f atBot (𝓝 (⨅ i, f i)) := by convert! tendsto_atTop_ciSup h_mono.dual hbdd.dual using 1 theorem tendsto_atTop_ciInf (h_anti : Antitone f) (hbdd : BddBelow <| range f) : - Tendsto f atTop (𝓝 (⨅ i, f i)) := by convert tendsto_atBot_ciSup h_anti.dual hbdd.dual using 1 + Tendsto f atTop (𝓝 (⨅ i, f i)) := by convert! tendsto_atBot_ciSup h_anti.dual hbdd.dual using 1 end CiInf diff --git a/Mathlib/Topology/Order/OrderClosed.lean b/Mathlib/Topology/Order/OrderClosed.lean index 9fb4490dc6837e..4ebda2231a68ca 100644 --- a/Mathlib/Topology/Order/OrderClosed.lean +++ b/Mathlib/Topology/Order/OrderClosed.lean @@ -621,7 +621,7 @@ theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine le_antisymm hb₁ (closure_lt_subset_le hg hf ?_) - convert hb₂ using 2; simp only [not_le.symm]; rfl + convert! hb₂ using 2; simp only [not_le.symm]; rfl @[to_dual] theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := diff --git a/Mathlib/Topology/Order/ScottTopology.lean b/Mathlib/Topology/Order/ScottTopology.lean index 8e996159cb0c82..8896519e0aa8e9 100644 --- a/Mathlib/Topology/Order/ScottTopology.lean +++ b/Mathlib/Topology/Order/ScottTopology.lean @@ -216,7 +216,7 @@ lemma dirSupClosed_of_isClosed [IsScott α univ] : IsClosed s → DirSupClosed s (isClosed_iff_isLowerSet_and_dirSupClosed.mp h).right lemma lowerClosure_subset_closure [IsScott α univ] : ↑(lowerClosure s) ⊆ closure s := by - convert closure.mono (@upperSet_le_scott α _) + convert! closure.mono (@upperSet_le_scott α _) · rw [@IsUpperSet.closure_eq_lowerClosure α _ (upperSet α) ?_ s] infer_instance · exact topology_eq α univ diff --git a/Mathlib/Topology/Order/SuccPred.lean b/Mathlib/Topology/Order/SuccPred.lean index e029b17eb4f49b..7428499593dcb1 100644 --- a/Mathlib/Topology/Order/SuccPred.lean +++ b/Mathlib/Topology/Order/SuccPred.lean @@ -29,10 +29,10 @@ variable [SuccOrder α] theorem isOpen_singleton_of_not_isSuccPrelimit (ha : ¬ IsSuccPrelimit a) : IsOpen {a} := by obtain ⟨b, hb⟩ := not_isSuccPrelimit_iff.1 ha by_cases ha' : IsMax a - · convert isOpen_Ioi (a := b) using 1 + · convert! isOpen_Ioi (a := b) using 1 rw [hb.Ioi_eq] grind [IsMax] - · convert isOpen_Ioo (a := b) (b := Order.succ a) using 1 + · convert! isOpen_Ioo (a := b) (b := Order.succ a) using 1 simp [(covBy_succ_of_not_isMax ha').Ioo_eq_Ioc, hb.Ioc_eq] variable [NoMaxOrder α] @@ -48,7 +48,7 @@ theorem isOpen_singleton_iff : IsOpen {a} ↔ ¬ IsSuccLimit a := by simp only [Set.mem_Ioo, Set.subset_singleton_iff] at h₁ h₂ exact h₂ _ ⟨lt_succ l, h₁.1.succ_le.trans_lt h₁.2⟩ · obtain (ha | ha) := not_isSuccLimit_iff.mp ha - · convert isOpen_Iio (a := Order.succ a) using 1 + · convert! isOpen_Iio (a := Order.succ a) using 1 simp [ha.Iic_eq] · exact isOpen_singleton_of_not_isSuccPrelimit ha diff --git a/Mathlib/Topology/PartitionOfUnity.lean b/Mathlib/Topology/PartitionOfUnity.lean index cc9187a2d979f3..3fee10d94b7a40 100644 --- a/Mathlib/Topology/PartitionOfUnity.lean +++ b/Mathlib/Topology/PartitionOfUnity.lean @@ -526,7 +526,7 @@ theorem sum_toPOUFun_eq (x : X) : ∑ᶠ i, f.toPOUFun i x = 1 - ∏ᶠ i, (1 - rw [finsum_eq_sum_of_support_subset _ A, finprod_eq_prod_of_mulSupport_subset _ B, Finset.prod_one_sub_ordered, sub_sub_cancel] refine Finset.sum_congr rfl fun i _ => ?_ - convert f.toPOUFun_eq_mul_prod _ _ _ fun j _ hj => _ + convert! f.toPOUFun_eq_mul_prod _ _ _ fun j _ hj => _ rwa [Finite.mem_toFinset] open Classical in diff --git a/Mathlib/Topology/Path.lean b/Mathlib/Topology/Path.lean index 9a457721244ada..13bbc3699273fe 100644 --- a/Mathlib/Topology/Path.lean +++ b/Mathlib/Topology/Path.lean @@ -585,11 +585,11 @@ theorem truncate_self {a b : X} (γ : Path a b) (t : ℝ) : theorem truncate_zero_zero {a b : X} (γ : Path a b) : γ.truncate 0 0 = (Path.refl a).cast (by rw [min_self, γ.extend_zero]) γ.extend_zero := by - convert γ.truncate_self 0 + convert! γ.truncate_self 0 theorem truncate_one_one {a b : X} (γ : Path a b) : γ.truncate 1 1 = (Path.refl b).cast (by rw [min_self, γ.extend_one]) γ.extend_one := by - convert γ.truncate_self 1 + convert! γ.truncate_self 1 @[simp] theorem truncate_zero_one {a b : X} (γ : Path a b) : diff --git a/Mathlib/Topology/Piecewise.lean b/Mathlib/Topology/Piecewise.lean index ff26e0bd9b815d..240b950c285f02 100644 --- a/Mathlib/Topology/Piecewise.lean +++ b/Mathlib/Topology/Piecewise.lean @@ -134,7 +134,7 @@ theorem IsOpen.ite' (hs : IsOpen s) (hs' : IsOpen s') (ht : ∀ x ∈ frontier t, x ∈ s ↔ x ∈ s') : IsOpen (t.ite s s') := by classical simp only [isOpen_iff_continuous_mem, Set.ite] at * - convert + convert! continuous_piecewise (fun x hx => propext (ht x hx)) hs.continuousOn hs'.continuousOn using 2 rename_i x by_cases hx : x ∈ t <;> simp [hx] diff --git a/Mathlib/Topology/QuasiSeparated.lean b/Mathlib/Topology/QuasiSeparated.lean index 31975c6d0330cf..40bdc80392322c 100644 --- a/Mathlib/Topology/QuasiSeparated.lean +++ b/Mathlib/Topology/QuasiSeparated.lean @@ -61,9 +61,9 @@ theorem isQuasiSeparated_univ {α : Type*} [TopologicalSpace α] [QuasiSeparated theorem IsQuasiSeparated.image_of_isEmbedding {s : Set α} (H : IsQuasiSeparated s) (h : IsEmbedding f) : IsQuasiSeparated (f '' s) := by intro U V hU hU' hU'' hV hV' hV'' - convert - (H (f ⁻¹' U) (f ⁻¹' V) - ?_ (h.continuous.1 _ hU') ?_ ?_ (h.continuous.1 _ hV') ?_).image h.continuous + convert! + (H (f ⁻¹' U) (f ⁻¹' V) ?_ (h.continuous.1 _ hU') ?_ ?_ (h.continuous.1 _ hV') ?_).image + h.continuous · symm rw [← Set.preimage_inter, Set.image_preimage_eq_inter_range, Set.inter_eq_left] exact Set.inter_subset_left.trans (hU.trans (Set.image_subset_range _ _)) @@ -71,14 +71,14 @@ theorem IsQuasiSeparated.image_of_isEmbedding {s : Set α} (H : IsQuasiSeparated rw [← h.injective.injOn.mem_image_iff (Set.subset_univ _) trivial] exact hU hx · rw [h.isCompact_iff] - convert hU'' + convert! hU'' rw [Set.image_preimage_eq_inter_range, Set.inter_eq_left] exact hU.trans (Set.image_subset_range _ _) · intro x hx rw [← h.injective.injOn.mem_image_iff (Set.subset_univ _) trivial] exact hV hx · rw [h.isCompact_iff] - convert hV'' + convert! hV'' rw [Set.image_preimage_eq_inter_range, Set.inter_eq_left] exact hV.trans (Set.image_subset_range _ _) @@ -104,7 +104,7 @@ lemma Topology.IsOpenEmbedding.quasiSeparatedSpace [QuasiSeparatedSpace β] (h : theorem isQuasiSeparated_iff_quasiSeparatedSpace (s : Set α) (hs : IsOpen s) : IsQuasiSeparated s ↔ QuasiSeparatedSpace s := by rw [← isQuasiSeparated_univ_iff] - convert (hs.isOpenEmbedding_subtypeVal.isQuasiSeparated_iff (s := Set.univ)).symm + convert! (hs.isOpenEmbedding_subtypeVal.isQuasiSeparated_iff (s := Set.univ)).symm simp instance (priority := 100) T2Space.to_quasiSeparatedSpace [T2Space α] : QuasiSeparatedSpace α := diff --git a/Mathlib/Topology/SeparatedMap.lean b/Mathlib/Topology/SeparatedMap.lean index 76a3040390a779..fa21f476ac921a 100644 --- a/Mathlib/Topology/SeparatedMap.lean +++ b/Mathlib/Topology/SeparatedMap.lean @@ -161,7 +161,7 @@ theorem discreteTopology_iff_locallyInjective (y : Y) : DiscreteTopology X ↔ IsLocallyInjective fun _ : X ↦ y := by rw [discreteTopology_iff_singleton_mem_nhds, isLocallyInjective_iff_nhds] refine forall_congr' fun x ↦ ⟨fun h ↦ ⟨{x}, h, Set.injOn_singleton _ _⟩, fun ⟨U, hU, inj⟩ ↦ ?_⟩ - convert hU; ext x'; refine ⟨?_, fun h ↦ inj h (mem_of_mem_nhds hU) rfl⟩ + convert! hU; ext x'; refine ⟨?_, fun h ↦ inj h (mem_of_mem_nhds hU) rfl⟩ rintro rfl; exact mem_of_mem_nhds hU theorem IsLocallyInjective.comp_left {A} {f : X → Y} (hf : IsLocallyInjective f) {g : Y → A} diff --git a/Mathlib/Topology/Separation/Basic.lean b/Mathlib/Topology/Separation/Basic.lean index e7938a01e7c8d0..83376d6bad82c8 100644 --- a/Mathlib/Topology/Separation/Basic.lean +++ b/Mathlib/Topology/Separation/Basic.lean @@ -125,7 +125,7 @@ theorem TopologicalSpace.IsTopologicalBasis.inseparable_iff {b : Set (Set X)} (hb : IsTopologicalBasis b) {x y : X} : Inseparable x y ↔ ∀ s ∈ b, (x ∈ s ↔ y ∈ s) := ⟨fun h _ hs ↦ inseparable_iff_forall_isOpen.1 h _ (hb.isOpen hs), fun h ↦ hb.nhds_hasBasis.eq_of_same_basis <| by - convert hb.nhds_hasBasis using 2 + convert! hb.nhds_hasBasis using 2 exact and_congr_right (h _)⟩ theorem TopologicalSpace.IsTopologicalBasis.eq_iff [T0Space X] {b : Set (Set X)} @@ -670,7 +670,7 @@ theorem Dense.diff_finset [T1Space X] [∀ x : X, NeBot (𝓝[≠] x)] {s : Set obtains a dense set. -/ theorem Dense.diff_finite [T1Space X] [∀ x : X, NeBot (𝓝[≠] x)] {s : Set X} (hs : Dense s) {t : Set X} (ht : t.Finite) : Dense (s \ t) := by - convert hs.diff_finset ht.toFinset + convert! hs.diff_finset ht.toFinset exact (Finite.coe_toFinset _).symm /-- If a function to a `T1Space` tends to some limit `y` at some point `x`, then necessarily diff --git a/Mathlib/Topology/Separation/DisjointCover.lean b/Mathlib/Topology/Separation/DisjointCover.lean index 04ab4742a8d1d7..447423c54ab6be 100644 --- a/Mathlib/Topology/Separation/DisjointCover.lean +++ b/Mathlib/Topology/Separation/DisjointCover.lean @@ -150,7 +150,7 @@ lemma exists_finite_approximation_of_mem_nhds_diagonal (hS : S ∈ nhdsSet (diag simpa [← SetLike.coe_set_eq, ← nonempty_iff_ne_empty] using hEne i choose r hr using h_ex -- for each `i`, choose an `r i ∈ E i` refine ⟨n, g, f ∘ r, continuous_discrete_rng.mpr fun j ↦ ?_, fun x ↦ (hES _) _ (hg _) _ (hr _)⟩ - convert (E j).isOpen + convert! (E j).isOpen exact Set.ext fun x ↦ ⟨fun hj ↦ hj ▸ hg x, fun hx ↦ (hg' _ _ hx).symm⟩ /-- @@ -170,7 +170,7 @@ lemma exists_finite_sum_const_mulIndicator_approximation_of_mem_nhds_diagonal [C ∀ x, (f x, ∏ n, mulIndicator (U n) (fun _ ↦ v n) x) ∈ S := by obtain ⟨n, g, h, hg, hgh⟩ := exists_finite_approximation_of_mem_nhds_diagonal f hS refine ⟨n, fun i ↦ ⟨_, (isClopen_discrete {i}).preimage hg⟩, h, fun x ↦ ?_⟩ - convert hgh x + convert! hgh x exact (Fintype.prod_eq_single _ fun i hi ↦ mulIndicator_of_notMem hi.symm _).trans (mulIndicator_of_mem rfl _) diff --git a/Mathlib/Topology/Separation/Hausdorff.lean b/Mathlib/Topology/Separation/Hausdorff.lean index 0b3c1cd2be2717..03e84f278b8fa2 100644 --- a/Mathlib/Topology/Separation/Hausdorff.lean +++ b/Mathlib/Topology/Separation/Hausdorff.lean @@ -173,7 +173,7 @@ theorem t2Space_iff_of_isOpenQuotientMap [TopologicalSpace Y] {π : X → Y} replace h := IsOpenQuotientMap.prodMap h h refine ⟨fun H ↦ H.preimage h.continuous, fun H ↦ ?_⟩ simp_rw [← isOpen_compl_iff] at H ⊢ - convert h.isOpenMap _ H + convert! h.isOpenMap _ H exact (h.surjective.image_preimage _).symm theorem tendsto_nhds_unique [T2Space X] {f : Y → X} {l : Filter Y} {a b : X} [NeBot l] diff --git a/Mathlib/Topology/Sets/CompactOpenCovered.lean b/Mathlib/Topology/Sets/CompactOpenCovered.lean index 047f37915ffcfc..9fde3074afc7f4 100644 --- a/Mathlib/Topology/Sets/CompactOpenCovered.lean +++ b/Mathlib/Topology/Sets/CompactOpenCovered.lean @@ -85,7 +85,7 @@ lemma of_iUnion_eq_of_finite {κ : Type*} [Finite κ] (s : κ → Set S) (hs : (H : ∀ i, IsCompactOpenCovered f (s i)) : IsCompactOpenCovered f U := by rw [iff_isCompactOpenCovered_sigmaMk, iff_of_unique] have (i : κ) : ∃ (V : Opens (Σ i, X i)), IsCompact V.1 ∧ (f _ ·.snd) '' V.1 = s i := by - convert H i; rw [iff_isCompactOpenCovered_sigmaMk, iff_of_unique] + convert! H i; rw [iff_isCompactOpenCovered_sigmaMk, iff_of_unique] choose V hVeq hVc using this exact ⟨⨆ i, V i, by simpa using isCompact_iUnion hVeq, by simp_all [Set.image_iUnion, ← hs]⟩ diff --git a/Mathlib/Topology/Sets/Opens.lean b/Mathlib/Topology/Sets/Opens.lean index 019b93e6be6b43..6111c84201394f 100644 --- a/Mathlib/Topology/Sets/Opens.lean +++ b/Mathlib/Topology/Sets/Opens.lean @@ -329,7 +329,7 @@ theorem IsBasis.isCompact_open_iff_eq_finite_iUnion {ι : Type*} (b : ι → Ope (hb : IsBasis (Set.range b)) (hb' : ∀ i, IsCompact (b i : Set α)) (U : Set α) : IsCompact U ∧ IsOpen U ↔ ∃ s : Set ι, s.Finite ∧ U = ⋃ i ∈ s, b i := by apply isCompact_open_iff_eq_finite_iUnion_of_isTopologicalBasis fun i : ι => (b i).1 - · convert (config := { transparency := .default }) hb + · convert! (config := { transparency := .default }) hb ext simp · exact hb' @@ -351,14 +351,14 @@ lemma IsBasis.le_iff {α} {t₁ t₂ : TopologicalSpace α} lemma isBasis_sigma {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {B : ∀ i, Set (Opens (α i))} (hB : ∀ i, IsBasis (B i)) : IsBasis (⋃ i : ι, (fun U ↦ ⟨Sigma.mk i '' U.1, isOpenMap_sigmaMk _ U.2⟩) '' B i) := by - convert TopologicalSpace.IsTopologicalBasis.sigma hB + convert! TopologicalSpace.IsTopologicalBasis.sigma hB simp only [IsBasis, Set.image_iUnion, ← Set.image_comp] simp lemma IsBasis.of_isInducing {B : Set (Opens β)} (H : IsBasis B) {f : α → β} (h : IsInducing f) : IsBasis { ⟨f ⁻¹' U, U.2.preimage h.continuous⟩ | U ∈ B } := by simp only [IsBasis] at H ⊢ - convert H.isInducing h + convert! H.isInducing h ext; simp @[simp] diff --git a/Mathlib/Topology/Sets/VietorisTopology.lean b/Mathlib/Topology/Sets/VietorisTopology.lean index 5f6df6e1a31ecb..0eaa904aa1b3e1 100644 --- a/Mathlib/Topology/Sets/VietorisTopology.lean +++ b/Mathlib/Topology/Sets/VietorisTopology.lean @@ -351,7 +351,7 @@ theorem isClosed_inter_nonempty_of_isClosed {F : Set α} (h : IsClosed F) : exact (isOpen_subsets_of_isOpen h.isOpen_compl).isClosed_compl theorem isClopen_singleton_bot : IsClopen {(⊥ : Compacts α)} := by - convert vietoris.isClopen_singleton_empty.preimage continuous_coe + convert! vietoris.isClopen_singleton_empty.preimage continuous_coe rw [← coe_bot, ← image_singleton (f := SetLike.coe), SetLike.coe_injective.preimage_image] /-- Given a basis `B` on a topological space `α`, the topology of `Compacts α` has a basis @@ -468,9 +468,10 @@ theorem _root_.Topology.IsClosedEmbedding.compacts_map (hf : IsClosedEmbedding f instance [DiscreteTopology α] : DiscreteTopology (Compacts α) := by rw [discreteTopology_iff_isOpen_singleton] intro K - convert (isOpen_subsets_of_isOpen (isOpen_discrete (K : Set α))).inter - (K.isCompact.finite_of_discrete.isOpen_biInter fun x hx => - isOpen_inter_nonempty_of_isOpen (isOpen_discrete {x})) + convert! + (isOpen_subsets_of_isOpen (isOpen_discrete (K : Set α))).inter + (K.isCompact.finite_of_discrete.isOpen_biInter fun x hx => + isOpen_inter_nonempty_of_isOpen (isOpen_discrete { x })) simp_rw [← setOf_forall, inter_singleton_nonempty, ← Set.subset_def, ← setOf_and, ← subset_antisymm_iff, SetLike.coe_set_eq, setOf_eq_eq_singleton] @@ -554,7 +555,7 @@ theorem isCompact_biUnion_coe_of_isCompact {S : Set (Compacts α)} (hS : IsCompa @[simp] theorem compactSpace_iff : CompactSpace (Compacts α) ↔ CompactSpace α := by refine ⟨fun h => ⟨?_⟩, fun _ => inferInstance⟩ - convert isCompact_biUnion_coe_of_isCompact (α := α) isCompact_univ + convert! isCompact_biUnion_coe_of_isCompact (α := α) isCompact_univ symm simp_rw [biUnion_univ, eq_univ_iff_forall, mem_iUnion] exact fun x => ⟨{x}, Set.mem_singleton x⟩ @@ -779,13 +780,13 @@ theorem isCompact_subsets_of_isCompact {K : Set α} (hK : IsCompact K) : theorem isCompact_biUnion_coe_of_isCompact {S : Set (NonemptyCompacts α)} (hs : IsCompact S) : IsCompact (⋃ K ∈ S, (K : Set α)) := by - convert Compacts.isCompact_biUnion_coe_of_isCompact (hs.image continuous_toCompacts) + convert! Compacts.isCompact_biUnion_coe_of_isCompact (hs.image continuous_toCompacts) simp_rw [biUnion_image, coe_toCompacts] @[simp] theorem compactSpace_iff : CompactSpace (NonemptyCompacts α) ↔ CompactSpace α := by refine ⟨fun h => ⟨?_⟩, fun _ => inferInstance⟩ - convert isCompact_biUnion_coe_of_isCompact (α := α) isCompact_univ + convert! isCompact_biUnion_coe_of_isCompact (α := α) isCompact_univ symm simp_rw [biUnion_univ, eq_univ_iff_forall, mem_iUnion] exact fun x => ⟨{x}, Set.mem_singleton x⟩ diff --git a/Mathlib/Topology/Sheaves/EtaleSpace.lean b/Mathlib/Topology/Sheaves/EtaleSpace.lean new file mode 100644 index 00000000000000..a097299154aab9 --- /dev/null +++ b/Mathlib/Topology/Sheaves/EtaleSpace.lean @@ -0,0 +1,163 @@ +/- +Copyright (c) 2026 Yury Kudryashov. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Yury Kudryashov +-/ +module + +public import Mathlib.Topology.Covering.Basic +public import Mathlib.Topology.Sheaves.Stalks + +/-! +# Etale space of a presheaf + +Given a presheaf `F` on a topological space `X`, +its *etale space* is the space of pairs `(base, germ)`, +where `base` is a point of `X`, and `germ` is an element of the stalk of `F` at `base`. + +This space is equipped with the following topology. +For each open set `U` and a section `s` of `F` over `U`, +the set of germs of `s` at points `x ∈ U` is an open set in the etale space. + +## Main results + +- `TopCat.Presheaf.EtaleSpace.eventually_nhds`. If `s` is a section of `F` over `U` + with germ at `g.base` equal to `g.germ`, + then a neighborhood of `g` consists of germs of `s` at points `x ∈ U`. + +- `TopCat.Presheaf.EtaleSpace.isCoveringMap_base`. + Let `F` be a presheaf with the following property. + + For each `x`, there exists an open neighborhood `U ∋ x` such that for each `y ∈ U`, + the map `Presheaf.germ F U y hyU` from sections of `F` over `U` to the stalk at `y` + is bijective. + + Then the projection from the etale space of `F` to the base is a covering map. +-/ + +public section + +open Function Set CategoryTheory TopologicalSpace Opposite Filter +open scoped Topology + +namespace TopCat.Presheaf + +universe v u w +variable {X : TopCat.{v}} {C : Type u} [Category.{v} C] {CC : C → Type v} {FC : C → C → Type w} + [∀ X Y, FunLike (FC X Y) (CC X) (CC Y)] [ConcreteCategory C FC] [Limits.HasColimits.{v} C] + +/-- Etale space of a presheaf. -/ +structure EtaleSpace (F : Presheaf C X) where + /-- The base point. -/ + base : X + /-- A germ at `base` (formally, an element of the stalk of `F` at `base`). -/ + germ : ToType (F.stalk base) + +namespace EtaleSpace + +instance (F : Presheaf C X) : TopologicalSpace F.EtaleSpace := + .generateFrom + {{g | ∃ h, g.germ = F.germ U g.base h f} | (U : Opens X) (f : ToType (F.obj <| op U))} + +variable {F : Presheaf C X} + +/-- If `s` is a section of a presheaf `F` over `U` with germ at `g.base` equal to `g.germ`, +then a neighborhood of `g` consists of germs of `s` at points `x ∈ U`. -/ +protected theorem eventually_nhds (g : EtaleSpace F) {U : Opens X} (h : g.base ∈ U) + (s : ToType (F.obj (op U))) (hs : F.germ U g.base h s = g.germ) : + ∀ᶠ g' : EtaleSpace F in 𝓝 g, ∃ hgU : g'.base ∈ U, g'.germ = F.germ U g'.base hgU s := by + simp only [nhds_generateFrom, Filter.Eventually, mem_setOf_eq, iInf_and, iInf_exists] + refine mem_iInf_of_mem _ <| mem_iInf_of_mem ?_ <| mem_iInf_of_mem U <| mem_iInf_of_mem s <| + mem_iInf_of_mem rfl <| mem_principal_self _ + simp [*] + +variable [Limits.PreservesFilteredColimits (forget C)] + +variable (F) in +@[fun_prop] +theorem continuous_base : Continuous (base (F := F)) := by + rw [continuous_iff_continuousAt] + intro x + rw [ContinuousAt, (nhds_basis_opens _).tendsto_right_iff] + rintro U ⟨hxU, hUo⟩ + lift U to Opens X using hUo + rcases F.exists_le_germ_eq x.germ hxU with ⟨V, hVU, hxV, f, hf⟩ + refine x.eventually_nhds hxV f hf |>.mono ?_ + aesop + +theorem exists_section_of_tendsto {α : Type*} {l : Filter α} {g : α → F.EtaleSpace} + {g₀ : F.EtaleSpace} (h : Tendsto g l (𝓝 g₀)) : + ∃ (U : Opens X), g₀.base ∈ U ∧ ∃ (f : ToType (F.obj (op U))), + ∀ᶠ a in l, ∃ ha : (g a).base ∈ U, (g a).germ = F.germ U (g a).base ha f := by + rcases F.exists_germ_eq g₀.germ with ⟨U, hU, s, hs⟩ + use U, hU, s + exact h.eventually <| g₀.eventually_nhds hU s hs + +/-- Let `F` be a `C`-valued presheaf on `X`. +Let `U` be an open set on `X` such that for each `x ∈ U`, the `germ` map is bijective, i.e., +every germ can be extended to a unique section over `U`. + +Then for each `x ∈ U`, the preimage of `U` under `EtaleSpace.base` +is homeomorphic to the product of `U` and the stalk of `F` at `x` with discrete topology. +-/ +@[expose, simps apply_fst] +noncomputable def homeomorph (U : Opens X) + (hF_bij : ∀ (x : X) (hx : x ∈ U), Bijective (F.germ U x hx)) + (x : X) (hx : x ∈ U) : + (base (F := F) ⁻¹' U) ≃ₜ U × WithDiscreteTopology (ToType (F.stalk x)) where + toFun s := (⟨s.1.base, s.2⟩, + .toTopology ⊥ <| F.germ U x hx <| surjInv (hF_bij s.1.base s.2).surjective s.1.germ) + invFun + | (⟨y, hy⟩, .toTopology _ g) => ⟨⟨y, F.germ U y hy <| surjInv (hF_bij x hx).surjective g⟩, hy⟩ + left_inv := by + rintro ⟨⟨base, s⟩, hs⟩ + simp only + congr 2 + rw [leftInverse_surjInv (hF_bij _ _), surjInv_eq (hF_bij _ _).surjective] + right_inv := by + rintro ⟨⟨y, hy⟩, ⟨g⟩⟩ + simp only + congr + rw [leftInverse_surjInv (hF_bij _ _), surjInv_eq (hF_bij _ _).surjective] + continuous_toFun := by + refine .prodMk (by fun_prop) ?_ + simp_rw [continuous_iff_continuousAt, ContinuousAt, nhds_discrete, tendsto_pure, nhds_subtype, + eventually_comap] + rintro ⟨g, hg⟩ + rcases hF_bij _ hg |>.surjective g.germ with ⟨f, hf⟩ + filter_upwards [g.eventually_nhds hg f hf] + rintro _ ⟨hgU, hgf⟩ g' rfl + congr 1 + rw [hgf, ← hf, leftInverse_surjInv (hF_bij _ _), leftInverse_surjInv (hF_bij _ _)] + continuous_invFun := by + simp_rw [continuous_iff_continuousAt, continuousAt_prod_of_discrete_right] + rintro ⟨y, ⟨g⟩⟩ + simp only [ContinuousAt, nhds_subtype_eq_comap, tendsto_comap_iff, comp_def, + nhds_generateFrom, tendsto_iInf, mem_setOf_eq, tendsto_principal] + rintro _ ⟨hmem, V, f, rfl⟩ + simp only [mem_setOf_eq] at hmem + rcases hmem with ⟨hyV, hgf⟩ + rcases F.germ_eq _ _ _ _ _ hgf with ⟨W, hyW, ιWU, ιWV, hW⟩ + filter_upwards [W.isOpen.preimage continuous_subtype_val |>.mem_nhds hyW] with z hz + use ιWV.le hz + rw [← F.germ_res_apply ιWU z hz, hW, F.germ_res_apply] + +/-- Let `F` be a presheaf with the following property. + +For each `x`, there exists an open neighborhood `U ∋ x` such that for each `y ∈ U`, +the map `Presheaf.germ F U y hyU` from sections of `F` over `U` to the stalk at `y` +is bijective. + +Then the projection from the etale space of `F` to the base is a covering map. -/ +theorem isCoveringMap_base + (hF_bij : ∀ x, ∃ (U : Opens X), x ∈ U ∧ ∀ y (hyU : y ∈ U), Bijective (F.germ U y hyU)) : + IsCoveringMap (base (F := F)) := by + refine fun x ↦ .to_isEvenlyCovered_preimage (I := WithDiscreteTopology (ToType (F.stalk x))) ?_ + use inferInstance + rcases hF_bij x with ⟨U, hxU, hU_bij⟩ + use U, hxU, U.isOpen, U.isOpen.preimage (continuous_base F), homeomorph U hU_bij x hxU + simp + +end EtaleSpace + +end TopCat.Presheaf diff --git a/Mathlib/Topology/Sheaves/LocalPredicate.lean b/Mathlib/Topology/Sheaves/LocalPredicate.lean index 3b5f28bb6a914b..4e30ef071016f1 100644 --- a/Mathlib/Topology/Sheaves/LocalPredicate.lean +++ b/Mathlib/Topology/Sheaves/LocalPredicate.lean @@ -160,7 +160,7 @@ namespace PrelocalPredicate theorem sheafifyOf {T : X → Type*} {P : PrelocalPredicate T} {U : Opens X} {f : ∀ x : U, T x} (h : P.pred f) : P.sheafify.pred f := fun x ↦ - ⟨U, x.2, 𝟙 _, by convert h⟩ + ⟨U, x.2, 𝟙 _, by convert! h⟩ /-- For a unary operation (e.g. `x ↦ -x`) defined at each stalk, if a prelocal predicate is closed under the operation on each open set (possibly by refinement), then the sheafified predicate is @@ -264,7 +264,7 @@ theorem isSheaf (P : LocalPredicate T) : (subpresheafToTypes P.toPrelocalPredica -- We claim that the predicate holds in `U i` use U i, hi, Opens.leSupr U i -- This follows, since our original family `sf` satisfies the predicate - convert (sf i).property using 1 + convert! (sf i).property using 1 exact gl_spec i -- It remains to show that the chosen lift is really a gluing for the subsheaf and -- that it is unique. Both of which follow immediately from the corresponding facts diff --git a/Mathlib/Topology/Sheaves/LocallySurjective.lean b/Mathlib/Topology/Sheaves/LocallySurjective.lean index bf7b87fee2acee..691f46d117301d 100644 --- a/Mathlib/Topology/Sheaves/LocallySurjective.lean +++ b/Mathlib/Topology/Sheaves/LocallySurjective.lean @@ -108,12 +108,12 @@ theorem locally_surjective_iff_surjective_on_stalks (T : ℱ ⟶ 𝒢) : obtain ⟨V, hxV, s, rfl⟩ := ℱ.exists_germ_eq s_x -- rfl : ℱ.germ x s = s_x have key_W := 𝒢.germ_eq x hxV hxU (T.app _ s) t <| by - convert hs_x using 1 + convert! hs_x using 1 symm - convert stalkFunctor_map_germ_apply _ _ _ _ s + convert! stalkFunctor_map_germ_apply _ _ _ _ s obtain ⟨W, hxW, hWV, hWU, h_eq⟩ := key_W refine ⟨W, hWU, ⟨ℱ.map hWV.op s, ?_⟩, hxW⟩ - convert h_eq using 1 + convert! h_eq using 1 simp only [← ConcreteCategory.comp_apply, T.naturality] end SurjectiveOnStalks diff --git a/Mathlib/Topology/Sheaves/PUnit.lean b/Mathlib/Topology/Sheaves/PUnit.lean index 38c225801bf182..7b181a0b513cb2 100644 --- a/Mathlib/Topology/Sheaves/PUnit.lean +++ b/Mathlib/Topology/Sheaves/PUnit.lean @@ -33,7 +33,7 @@ theorem isSheaf_of_isTerminal_of_indiscrete {X : TopCat.{w}} (hind : X.str = ⊤ · refine ⟨it.from _, fun U hU hs => IsTerminal.hom_ext ?_ _ _⟩ rwa [le_bot_iff.1 hU.le] · apply it.hom_ext - · convert Presieve.isSheafFor_top (F ⋙ coyoneda.obj (@op C c)) + · convert! Presieve.isSheafFor_top (F ⋙ coyoneda.obj (@op C c)) rw [Sieve.arrows_eq_top_iff, ← Sieve.id_mem_iff_eq_top] have := U.eq_bot_or_top.resolve_left hne subst this @@ -42,7 +42,7 @@ theorem isSheaf_of_isTerminal_of_indiscrete {X : TopCat.{w}} (hind : X.str = ⊤ obtain ⟨U, f, hf, hm⟩ := hs x _root_.trivial obtain rfl | rfl := U.eq_bot_or_top · cases hm - · convert hf + · convert! hf theorem isSheaf_iff_isTerminal_of_indiscrete {X : TopCat.{w}} (hind : X.str = ⊤) (F : Presheaf C X) : F.IsSheaf ↔ Nonempty (IsTerminal <| F.obj <| op ⊥) := diff --git a/Mathlib/Topology/Sheaves/SheafCondition/OpensLeCover.lean b/Mathlib/Topology/Sheaves/SheafCondition/OpensLeCover.lean index e3a169dcbfdd42..629aa8690e6946 100644 --- a/Mathlib/Topology/Sheaves/SheafCondition/OpensLeCover.lean +++ b/Mathlib/Topology/Sheaves/SheafCondition/OpensLeCover.lean @@ -196,7 +196,8 @@ def isLimitOpensLeEquivGenerate₂ (R : Presieve Y) (hR : Sieve.generate R ∈ Opens.grothendieckTopology X Y) : IsLimit (F.mapCone (opensLeCoverCocone (coveringOfPresieve Y R)).op) ≃ IsLimit (F.mapCone (Sieve.generate R).arrows.cocone.op) := by - convert isLimitOpensLeEquivGenerate₁ F (coveringOfPresieve Y R) + convert! + isLimitOpensLeEquivGenerate₁ F (coveringOfPresieve Y R) (coveringOfPresieve.iSup_eq_of_mem_grothendieck Y R hR).symm using 1 rw [covering_presieve_eq_self R] diff --git a/Mathlib/Topology/Sheaves/SheafCondition/PairwiseIntersections.lean b/Mathlib/Topology/Sheaves/SheafCondition/PairwiseIntersections.lean index ca6c8e5d071c37..8d953d3657996d 100644 --- a/Mathlib/Topology/Sheaves/SheafCondition/PairwiseIntersections.lean +++ b/Mathlib/Topology/Sheaves/SheafCondition/PairwiseIntersections.lean @@ -407,9 +407,9 @@ def isLimitPullbackCone : IsLimit (interUnionPullbackCone F U V) := by apply (F.presheaf.isSheaf_iff_isSheafPairwiseIntersections.mp F.2 ι).some.hom_ext rintro ((_ | _) | (_ | _)) <;> rw [Category.assoc, Category.assoc, Functor.mapCone_π_app, ← F.1.map_comp] - · convert h₁ + · convert! h₁ apply interUnionPullbackConeLift_left - · convert h₂ + · convert! h₂ apply interUnionPullbackConeLift_right all_goals dsimp only [Functor.op, Pairwise.cocone_ι_app, Functor.mapCone_π_app, Cocone.op, @@ -417,9 +417,9 @@ def isLimitPullbackCone : IsLimit (interUnionPullbackCone F U V) := by simp_rw [F.1.map_comp, ← Category.assoc] congr 1 simp_rw [Category.assoc, ← F.1.map_comp] - · convert h₁ + · convert! h₁ apply interUnionPullbackConeLift_left - · convert h₂ + · convert! h₂ apply interUnionPullbackConeLift_right /-- If `U, V` are disjoint, then `F(U ⊔ V) = F(U) × F(V)`. -/ diff --git a/Mathlib/Topology/Sheaves/SheafCondition/Sites.lean b/Mathlib/Topology/Sheaves/SheafCondition/Sites.lean index 1c6c808733c1ff..d7528b2f93fbcd 100644 --- a/Mathlib/Topology/Sheaves/SheafCondition/Sites.lean +++ b/Mathlib/Topology/Sheaves/SheafCondition/Sites.lean @@ -222,7 +222,7 @@ def isTerminalOfEmpty (F : Sheaf C X) : Limits.IsTerminal (F.obj.obj (op ⊥)) : /-- A variant of `isTerminalOfEmpty` that is easier to `apply`. -/ def isTerminalOfEqEmpty (F : X.Sheaf C) {U : Opens X} (h : U = ⊥) : Limits.IsTerminal (F.obj.obj (op U)) := by - convert F.isTerminalOfEmpty + convert! F.isTerminalOfEmpty /-- If a family `B` of open sets forms a basis of the topology on `X`, and if `F'` is a sheaf on `X`, then a homomorphism between a presheaf `F` on `X` and `F'` diff --git a/Mathlib/Topology/Sheaves/SheafCondition/UniqueGluing.lean b/Mathlib/Topology/Sheaves/SheafCondition/UniqueGluing.lean index 5f3595c54a0fad..351db260af4098 100644 --- a/Mathlib/Topology/Sheaves/SheafCondition/UniqueGluing.lean +++ b/Mathlib/Topology/Sheaves/SheafCondition/UniqueGluing.lean @@ -129,7 +129,7 @@ theorem isSheaf_iff_isSheafUniqueGluing_types : F.IsSheaf ↔ F.IsSheafUniqueGlu · exact h _ cpt.sectionPairwise.prop · specialize h (fun i ↦ s <| op <| Pairwise.single i) fun i j ↦ (hs <| op <| Pairwise.Hom.left i j).trans (hs <| op <| Pairwise.Hom.right i j).symm - convert h; ext (i | ⟨i, j⟩) + convert! h; ext (i | ⟨i, j⟩) · rfl · exact (hs <| op <| Pairwise.Hom.left i j).symm @@ -195,7 +195,7 @@ theorem existsUnique_gluing' (V : Opens X) (iUV : ∀ i : ι, U i ⟶ V) (hcover rw [← ConcreteCategory.comp_apply, ← F.1.map_comp] exact gl_spec i · intro gl' gl'_spec - convert congr_arg _ (gl_uniq (F.1.map (eqToHom V_eq_supr_U.symm).op gl') fun i => _) <;> + convert! congr_arg _ (gl_uniq (F.1.map (eqToHom V_eq_supr_U.symm).op gl') fun i => _) <;> rw [← ConcreteCategory.comp_apply, ← F.1.map_comp] · simp · exact gl'_spec i @@ -226,7 +226,7 @@ theorem eq_of_locally_eq' (V : Opens X) (iUV : ∀ i : ι, U i ⟶ V) (hcover : s = t := by have V_eq_supr_U : V = iSup U := le_antisymm hcover (iSup_le fun i => (iUV i).le) suffices F.1.map (eqToHom V_eq_supr_U.symm).op s = F.1.map (eqToHom V_eq_supr_U.symm).op t by - convert congr_arg (F.1.map (eqToHom V_eq_supr_U).op) this <;> + convert! congr_arg (F.1.map (eqToHom V_eq_supr_U).op) this <;> rw [← ConcreteCategory.comp_apply, ← F.1.map_comp, eqToHom_op, eqToHom_op, eqToHom_trans, eqToHom_refl, F.1.map_id, ConcreteCategory.id_apply] apply eq_of_locally_eq diff --git a/Mathlib/Topology/Sheaves/Stalks.lean b/Mathlib/Topology/Sheaves/Stalks.lean index c9ee0dee12bb3b..41cf82dd8e08df 100644 --- a/Mathlib/Topology/Sheaves/Stalks.lean +++ b/Mathlib/Topology/Sheaves/Stalks.lean @@ -216,7 +216,8 @@ theorem comp (ℱ : X.Presheaf C) (f : X ⟶ Y) (g : Y ⟶ Z) (x : X) : theorem stalkPushforward_iso_of_isInducing {f : X ⟶ Y} (hf : IsInducing f) (F : X.Presheaf C) (x : X) : IsIso (F.stalkPushforward _ f x) := by haveI := Functor.initial_of_adjunction (hf.adjunctionNhds x) - convert (Functor.Final.colimitIso (OpenNhds.map f x).op ((OpenNhds.inclusion x).op ⋙ F)).isIso_hom + convert! + (Functor.Final.colimitIso (OpenNhds.map f x).op ((OpenNhds.inclusion x).op ⋙ F)).isIso_hom refine stalk_hom_ext _ fun U hU ↦ (stalkPushforward_germ _ f F _ x hU).trans ?_ symm exact colimit.ι_pre ((OpenNhds.inclusion x).op ⋙ F) (OpenNhds.map f x).op _ @@ -452,7 +453,7 @@ theorem stalkFunctor_map_injective_of_app_injective {F G : Presheaf C X} {f : F rw [← ConcreteCategory.comp_apply, ← ConcreteCategory.comp_apply, ← f.naturality, ← f.naturality, ConcreteCategory.comp_apply, ConcreteCategory.comp_apply] at heq replace heq := h W heq - convert congr_arg (F.germ _ x hxW) heq using 1 + convert! congr_arg (F.germ _ x hxW) heq using 1 exacts [(F.germ_res_apply iWU₁ x hxW s).symm, (F.germ_res_apply iWU₂ x hxW t).symm] section IsBasis diff --git a/Mathlib/Topology/Sion.lean b/Mathlib/Topology/Sion.lean index d9abac39346f70..7357c61de05382 100644 --- a/Mathlib/Topology/Sion.lean +++ b/Mathlib/Topology/Sion.lean @@ -503,13 +503,13 @@ public theorem DMCompletion.exists_isSaddlePointOn : let φ : E → F → γ := fun x y ↦ ι (f x y) -- suffices : ∃ a ∈ X, ∃ b ∈ Y, IsSaddlePointOn X Y φ a b have hφx (x) (hx : x ∈ X) : UpperSemicontinuousOn (fun y ↦ φ x y) Y := by - convert Continuous.comp_upperSemicontinuousOn hι (hfx x hx) ι.monotone + convert! Continuous.comp_upperSemicontinuousOn hι (hfx x hx) ι.monotone have hφx' (x) (hx : x ∈ X) : QuasiconcaveOn ℝ Y fun y ↦ φ x y := by - convert (hfx' x hx).monotone_comp ι.monotone + convert! (hfx' x hx).monotone_comp ι.monotone have hφy (y) (hy : y ∈ Y) : LowerSemicontinuousOn (fun x ↦ φ x y) X := by - convert Continuous.comp_lowerSemicontinuousOn hι (hfy y hy) ι.monotone + convert! Continuous.comp_lowerSemicontinuousOn hι (hfy y hy) ι.monotone have hφy' (y) (hy : y ∈ Y) : QuasiconvexOn ℝ X fun x ↦ φ x y := by - convert (hfy' y hy).monotone_comp ι.monotone + convert! (hfy' y hy).monotone_comp ι.monotone obtain ⟨a, ha, b, hb, hab⟩ := exists_isSaddlePointOn' ne_X kX hφy hφy' cY kY hφx hφx' cX ne_Y use a, ha, b, hb diff --git a/Mathlib/Topology/Sober.lean b/Mathlib/Topology/Sober.lean index 06321a5d6a8df4..ce6450b5990f04 100644 --- a/Mathlib/Topology/Sober.lean +++ b/Mathlib/Topology/Sober.lean @@ -122,7 +122,7 @@ theorem IsIrreducible.isGenericPoint_genericPoint_closure theorem IsIrreducible.isGenericPoint_genericPoint [QuasiSober α] {S : Set α} (hS : IsIrreducible S) (hS' : IsClosed S) : IsGenericPoint hS.genericPoint S := by - convert hS.isGenericPoint_genericPoint_closure; exact hS'.closure_eq.symm + convert! hS.isGenericPoint_genericPoint_closure; exact hS'.closure_eq.symm @[simp] theorem IsIrreducible.genericPoint_closure_eq [QuasiSober α] {S : Set α} (hS : IsIrreducible S) : diff --git a/Mathlib/Topology/Spectral/Prespectral.lean b/Mathlib/Topology/Spectral/Prespectral.lean index ae29626e43db41..c259887f6e8c49 100644 --- a/Mathlib/Topology/Spectral/Prespectral.lean +++ b/Mathlib/Topology/Spectral/Prespectral.lean @@ -103,7 +103,7 @@ variable (X) in lemma PrespectralSpace.isBasis_opens [PrespectralSpace X] : TopologicalSpace.Opens.IsBasis { U : Opens X | IsCompact (U : Set X) } := by dsimp only [TopologicalSpace.Opens.IsBasis] - convert isTopologicalBasis (X := X) + convert! isTopologicalBasis (X := X) ext s exact ⟨fun ⟨V, hV, heq⟩ ↦ heq ▸ ⟨V.2, hV⟩, fun h ↦ ⟨⟨s, h.1⟩, h.2, rfl⟩⟩ diff --git a/Mathlib/Topology/Subpath.lean b/Mathlib/Topology/Subpath.lean index 2c48773ad40568..00687690175054 100644 --- a/Mathlib/Topology/Subpath.lean +++ b/Mathlib/Topology/Subpath.lean @@ -166,7 +166,7 @@ theorem concat_refl (n : ℕ) (x : X) : | zero => rw [concat_zero] | succ _ _ => rw [concat_succ] - convert refl_trans_refl + convert! refl_trans_refl namespace Homotopy diff --git a/Mathlib/Topology/TietzeExtension.lean b/Mathlib/Topology/TietzeExtension.lean index 9de9a7a007a2e1..d2af841d53e837 100644 --- a/Mathlib/Topology/TietzeExtension.lean +++ b/Mathlib/Topology/TietzeExtension.lean @@ -485,7 +485,7 @@ theorem exists_extension_forall_mem_of_isClosedEmbedding (f : C(X, ℝ)) {t : Se h.toEquiv.symm_apply_eq.trans Subtype.ext_iff refine ⟨g, fun y => ?_, ?_⟩ · rcases hG y with ⟨a, ha, hay⟩ - convert ha + convert! ha exact hgG.2 hay.symm · ext x exact hgG.2 (congr_fun hGF _) diff --git a/Mathlib/Topology/UniformSpace/Basic.lean b/Mathlib/Topology/UniformSpace/Basic.lean index 890f5efd1ed61d..d0cc87e0dec70c 100644 --- a/Mathlib/Topology/UniformSpace/Basic.lean +++ b/Mathlib/Topology/UniformSpace/Basic.lean @@ -454,13 +454,16 @@ theorem UniformSpace.comap_mono {α γ} {f : α → γ} : Monotone fun u : UniformSpace γ => u.comap f := fun _ _ hu => Filter.comap_mono hu -theorem uniformContinuous_iff {α β} {uα : UniformSpace α} {uβ : UniformSpace β} {f : α → β} : - UniformContinuous f ↔ uα ≤ uβ.comap f := +theorem uniformContinuous_iff_le_comap {α β} {uα : UniformSpace α} {uβ : UniformSpace β} + {f : α → β} : UniformContinuous f ↔ uα ≤ uβ.comap f := Filter.map_le_iff_le_comap +@[deprecated (since := "2026-05-23")] +alias uniformContinuous_iff := uniformContinuous_iff_le_comap + theorem le_iff_uniformContinuous_id {u v : UniformSpace α} : u ≤ v ↔ @UniformContinuous _ _ u v id := by - rw [uniformContinuous_iff, uniformSpace_comap_id, id] + rw [uniformContinuous_iff_le_comap, uniformSpace_comap_id, id] theorem uniformContinuous_comap {f : α → β} [u : UniformSpace β] : @UniformContinuous α β (UniformSpace.comap f u) u f := @@ -520,7 +523,7 @@ variable [UniformSpace α] [UniformSpace β] [UniformSpace γ] {f : α → β} { theorem UniformContinuous.continuous (hf : UniformContinuous f) : Continuous f := continuous_iff_le_induced.mpr <| UniformSpace.toTopologicalSpace_mono <| - uniformContinuous_iff.1 hf + uniformContinuous_iff_le_comap.1 hf lemma UniformContinuous.uniformContinuousOn (hf : UniformContinuous f) : UniformContinuousOn f s := diff --git a/Mathlib/Topology/UniformSpace/Cauchy.lean b/Mathlib/Topology/UniformSpace/Cauchy.lean index 78e14554c036cd..b9ac8cec007ce9 100644 --- a/Mathlib/Topology/UniformSpace/Cauchy.lean +++ b/Mathlib/Topology/UniformSpace/Cauchy.lean @@ -287,7 +287,7 @@ theorem cauchySeq_shift {u : ℕ → α} (k : ℕ) : CauchySeq (fun n ↦ u (n + obtain ⟨N, h⟩ := h V mV use N + k intro a ha b hb - convert h (a - k) (Nat.le_sub_of_add_le ha) (b - k) (Nat.le_sub_of_add_le hb) <;> lia + convert! h (a - k) (Nat.le_sub_of_add_le ha) (b - k) (Nat.le_sub_of_add_le hb) <;> lia · exact h.comp_tendsto (tendsto_add_atTop_nat k) theorem Filter.HasBasis.cauchySeq_iff {γ} [Nonempty β] [SemilatticeSup β] {u : β → α} {p : γ → Prop} diff --git a/Mathlib/Topology/UniformSpace/Closeds.lean b/Mathlib/Topology/UniformSpace/Closeds.lean index 7f1289b7ac8bbc..9306374ea70f17 100644 --- a/Mathlib/Topology/UniformSpace/Closeds.lean +++ b/Mathlib/Topology/UniformSpace/Closeds.lean @@ -247,7 +247,7 @@ theorem isClosed_setOf_totallyBounded : IsClosed {s : Set α | TotallyBounded s} instance [DiscreteUniformity α] : DiscreteUniformity (Set α) := by rw [discreteUniformity_iff_setRelId_mem_uniformity] - convert Filter.mem_lift' (DiscreteUniformity.relId_mem_uniformity α) + convert! Filter.mem_lift' (DiscreteUniformity.relId_mem_uniformity α) rw [hausdorffEntourage_id] end UniformSpace.hausdorff @@ -372,8 +372,7 @@ theorem isClosed_subsets_of_isClosed {s : Set α} (hs : IsClosed s) : isClosed_induced hs.powerset_hausdorff theorem isClopen_singleton_bot : IsClopen {(⊥ : Closeds α)} := by - convert UniformSpace.hausdorff.isClopen_singleton_empty.preimage - uniformContinuous_coe.continuous + convert! UniformSpace.hausdorff.isClopen_singleton_empty.preimage uniformContinuous_coe.continuous ext; simp theorem totallyBounded_subsets_of_totallyBounded {t : Set α} (ht : TotallyBounded t) : @@ -536,7 +535,7 @@ theorem isClosedEmbedding_toCloseds [T2Space α] [CompleteSpace α] : IsClosedEmbedding (toCloseds (α := α)) where __ := isEmbedding_toCloseds isClosed_range := by - convert Closeds.isClosed_setOf_totallyBounded + convert! Closeds.isClosed_setOf_totallyBounded exact subset_antisymm (Set.range_subset_iff.mpr fun K => K.isCompact.totallyBounded) (fun K hK => ⟨⟨K, hK.isCompact_of_isClosed K.isClosed⟩, rfl⟩) diff --git a/Mathlib/Topology/UniformSpace/Defs.lean b/Mathlib/Topology/UniformSpace/Defs.lean index 44edfa0e02df9f..f23cfccc9011c6 100644 --- a/Mathlib/Topology/UniformSpace/Defs.lean +++ b/Mathlib/Topology/UniformSpace/Defs.lean @@ -233,7 +233,7 @@ abbrev UniformSpace.toCore (u : UniformSpace α) : UniformSpace.Core α where have : Prod.mk x ⁻¹' U ∈ 𝓝 x := by rw [UniformSpace.nhds_eq_comap_uniformity] exact preimage_mem_comap hU - convert mem_of_mem_nhds this + convert! mem_of_mem_nhds this theorem UniformSpace.toCore_toTopologicalSpace (u : UniformSpace α) : u.toCore.toTopologicalSpace = u.toTopologicalSpace := diff --git a/Mathlib/Topology/UniformSpace/DiscreteUniformity.lean b/Mathlib/Topology/UniformSpace/DiscreteUniformity.lean index a7c38fef30a554..e9e3813a70882c 100644 --- a/Mathlib/Topology/UniformSpace/DiscreteUniformity.lean +++ b/Mathlib/Topology/UniformSpace/DiscreteUniformity.lean @@ -84,6 +84,6 @@ variable {x} in /-- On a space with a discrete uniformity, any function is uniformly continuous. -/ theorem uniformContinuous {Y : Type*} [UniformSpace Y] (f : X → Y) : UniformContinuous f := by - simp only [uniformContinuous_iff, DiscreteUniformity.eq_bot, bot_le] + simp only [uniformContinuous_iff_le_comap, DiscreteUniformity.eq_bot, bot_le] end DiscreteUniformity diff --git a/Mathlib/Topology/UniformSpace/Equiv.lean b/Mathlib/Topology/UniformSpace/Equiv.lean index 0ae62e96c881eb..a9ebab6a8e1bae 100644 --- a/Mathlib/Topology/UniformSpace/Equiv.lean +++ b/Mathlib/Topology/UniformSpace/Equiv.lean @@ -167,10 +167,10 @@ def changeInv (f : α ≃ᵤ β) (g : β → α) (hg : Function.RightInverse g f _ = f.symm x := by rw [hg x] { toFun := f invFun := g - left_inv := by convert f.left_inv - right_inv := by convert f.right_inv using 1 + left_inv := by convert! f.left_inv + right_inv := by convert! f.right_inv using 1 uniformContinuous_toFun := f.uniformContinuous - uniformContinuous_invFun := by convert f.symm.uniformContinuous } + uniformContinuous_invFun := by convert! f.symm.uniformContinuous } @[simp] theorem symm_comp_self (h : α ≃ᵤ β) : (h.symm : β → α) ∘ h = id := diff --git a/Mathlib/Topology/UniformSpace/ProdApproximation.lean b/Mathlib/Topology/UniformSpace/ProdApproximation.lean index b347bae7450eac..9975b76d1389d5 100644 --- a/Mathlib/Topology/UniformSpace/ProdApproximation.lean +++ b/Mathlib/Topology/UniformSpace/ProdApproximation.lean @@ -47,7 +47,7 @@ lemma exists_finite_sum_smul_approximation_of_mem_uniformity [TopologicalSpace R f.curry (nhdsSet_diagonal_le_uniformity hS') refine ⟨n, fun i ↦ ⟨_, (U i).isClopen.continuous_indicator <| continuous_const (y := 1)⟩, v, fun x y ↦ ?_⟩ - convert hv x y using 2 + convert! hv x y using 2 simp only [sum_apply] congr 1 with i by_cases hi : x ∈ U i <;> simp [hi] diff --git a/Mathlib/Topology/UniformSpace/UniformConvergenceTopology.lean b/Mathlib/Topology/UniformSpace/UniformConvergenceTopology.lean index dc707f93247aa6..b5e7ffb01774e7 100644 --- a/Mathlib/Topology/UniformSpace/UniformConvergenceTopology.lean +++ b/Mathlib/Topology/UniformSpace/UniformConvergenceTopology.lean @@ -404,10 +404,10 @@ protected theorem postcomp_uniformContinuous [UniformSpace γ] {f : γ → β} (hf : UniformContinuous f) : UniformContinuous (ofFun ∘ (f ∘ ·) ∘ toFun : (α →ᵤ γ) → α →ᵤ β) := by -- This is a direct consequence of `UniformFun.comap_eq` - refine uniformContinuous_iff.mpr ?_ + refine uniformContinuous_iff_le_comap.mpr ?_ calc 𝒰(α, γ, _) ≤ 𝒰(α, γ, ‹UniformSpace β›.comap f) := - UniformFun.mono (uniformContinuous_iff.mp hf) + UniformFun.mono (uniformContinuous_iff_le_comap.mp hf) _ = 𝒰(α, β, _).comap (f ∘ ·) := by exact UniformFun.comap_eq /-- Turn a uniform isomorphism `γ ≃ᵤ β` into a uniform isomorphism `(α →ᵤ γ) ≃ᵤ (α →ᵤ β)` by @@ -892,8 +892,9 @@ More precisely, if `f : γ → β` is uniformly continuous, then protected theorem postcomp_uniformContinuous [UniformSpace γ] {f : γ → β} (hf : UniformContinuous f) : UniformContinuous (ofFun 𝔖 ∘ (f ∘ ·) ∘ toFun 𝔖) := by -- This is a direct consequence of `UniformOnFun.comap_eq` - rw [uniformContinuous_iff] - exact (UniformOnFun.mono (uniformContinuous_iff.mp hf) subset_rfl).trans_eq UniformOnFun.comap_eq + rw [uniformContinuous_iff_le_comap] + exact (UniformOnFun.mono (uniformContinuous_iff_le_comap.mp hf) + subset_rfl).trans_eq UniformOnFun.comap_eq /-- Post-composition by a uniform inducing is a uniform inducing for the uniform structures of `𝔖`-convergence. @@ -1062,7 +1063,7 @@ protected def uniformEquivProdArrow [UniformSpace γ] : have H := @UniformOnFun.inf_eq α (β × γ) 𝔖 (UniformSpace.comap Prod.fst ‹_›) (UniformSpace.comap Prod.snd ‹_›) apply_fun (fun u ↦ @uniformity (α →ᵤ[𝔖] β × γ) u) at H - convert H.symm using 1 + convert! H.symm using 1 rw [UniformOnFun.comap_eq, UniformOnFun.comap_eq] erw [inf_uniformity] rw [uniformity_comap, uniformity_comap] @@ -1120,9 +1121,9 @@ theorem uniformSpace_eq_inf_precomp_of_cover {δ₁ δ₂ : Type*} (φ₁ : δ simpa only [← univ_subset_iff, ψ₁, ψ₂, range_restrictPreimage, ← preimage_union, ← image_subset_iff, image_univ, Subtype.range_val] using h_cover S hS refine le_antisymm (le_inf ?_ ?_) (le_iInf₂ fun S hS ↦ ?_) - · rw [← uniformContinuous_iff] + · rw [← uniformContinuous_iff_le_comap] exact UniformOnFun.precomp_uniformContinuous h_image₁ - · rw [← uniformContinuous_iff] + · rw [← uniformContinuous_iff_le_comap] exact UniformOnFun.precomp_uniformContinuous h_image₂ · simp_rw [this S hS, uniformSpace, UniformSpace.comap_iInf, UniformSpace.comap_inf, ← UniformSpace.comap_comap] @@ -1145,7 +1146,7 @@ theorem uniformSpace_eq_iInf_precomp_of_cover {δ : ι → Type*} (φ : Π i, δ -- With a better theory of ideals we may be able to simplify the following by replacing `𝔗 i` -- by `(φ i ⁻¹' ·) '' 𝔖`. refine le_antisymm (le_iInf fun i ↦ ?_) (le_iInf₂ fun S hS ↦ ?_) - · rw [← uniformContinuous_iff] + · rw [← uniformContinuous_iff_le_comap] exact UniformOnFun.precomp_uniformContinuous (h_image i) · simp_rw [this S hS, uniformSpace, UniformSpace.comap_iInf, ← UniformSpace.comap_comap] exact iInf_mono fun i ↦ iInf₂_le_of_le _ (h_preimage i hS) le_rfl diff --git a/Mathlib/Topology/VectorBundle/ContinuousAlternatingMap.lean b/Mathlib/Topology/VectorBundle/ContinuousAlternatingMap.lean index f627a7ac332e8e..8a1fb98ff57e10 100644 --- a/Mathlib/Topology/VectorBundle/ContinuousAlternatingMap.lean +++ b/Mathlib/Topology/VectorBundle/ContinuousAlternatingMap.lean @@ -275,7 +275,7 @@ def vectorPrebundle : let L₂ : E₂ b ≃L[𝕜] F₂ := (trivializationAt F₂ E₂ b).continuousLinearEquivAt 𝕜 b (mem_baseSet_trivializationAt _ _ _) - convert (L₁.continuousAlternatingMapCongr L₂).toHomeomorph.isInducing + convert! (L₁.continuousAlternatingMapCongr L₂).toHomeomorph.isInducing ext f simp [Trivialization.linearMapAt_def_of_mem _ (mem_baseSet_trivializationAt _ _ _), L₁, L₂] diff --git a/Mathlib/Topology/VectorBundle/Hom.lean b/Mathlib/Topology/VectorBundle/Hom.lean index 6ece0639b5037c..7daddac92db7b0 100644 --- a/Mathlib/Topology/VectorBundle/Hom.lean +++ b/Mathlib/Topology/VectorBundle/Hom.lean @@ -203,7 +203,7 @@ def Bundle.ContinuousLinearMap.vectorPrebundle : (mem_baseSet_trivializationAt _ _ _) let φ : (E₁ b →SL[σ] E₂ b) ≃L[𝕜₂] F₁ →SL[σ] F₂ := L₁.arrowCongrSL L₂ have : IsInducing fun x ↦ (b, φ x) := isInducing_const_prod.mpr φ.toHomeomorph.isInducing - convert this + convert! this ext f dsimp [Pretrivialization.continuousLinearMap_apply] rw [Trivialization.linearMapAt_def_of_mem _ (mem_baseSet_trivializationAt _ _ _)] diff --git a/Mathlib/Topology/VectorBundle/Riemannian.lean b/Mathlib/Topology/VectorBundle/Riemannian.lean index ce32b6145ac055..084a49871a5ddc 100644 --- a/Mathlib/Topology/VectorBundle/Riemannian.lean +++ b/Mathlib/Topology/VectorBundle/Riemannian.lean @@ -78,7 +78,7 @@ instance : IsContinuousRiemannianBundle F₁ (Bundle.Trivial B F₁) := by intro x rw [FiberBundle.continuousAt_totalSpace] refine ⟨continuousAt_id, ?_⟩ - convert continuousAt_const (y := innerSL ℝ) + convert! continuousAt_const (y := innerSL ℝ) ext v w simp [hom_trivializationAt_apply, inCoordinates] @@ -188,7 +188,7 @@ lemma eventually_norm_symmL_trivializationAt_self_comp_lt (x : B) {r : ℝ} (hr rw [inCoordinates_apply_eq₂ h'y h'y (Set.mem_univ _)] have A : ((trivializationAt F E x).symm y) ((trivializationAt F E x).linearMapAt ℝ y v) = v := by - convert ((trivializationAt F E x).continuousLinearEquivAt ℝ _ h'y).symm_apply_apply v + convert! ((trivializationAt F E x).continuousLinearEquivAt ℝ _ h'y).symm_apply_apply v simp [Trivialization.coe_continuousLinearEquivAt_eq _ h'y] simp [A, w] have hgx : g x ((trivializationAt F E x).symm x w) ((trivializationAt F E x).symm x w) = @@ -230,7 +230,7 @@ lemma eventually_norm_trivializationAt_lt (x : B) : have h'x : x ∈ (trivializationAt F E x).baseSet := FiberBundle.mem_baseSet_trivializationAt' x simp only [coe_comp', Trivialization.continuousLinearMapAt_apply, Trivialization.symmL_apply, Function.comp_apply, coe_id', id_eq] - convert ((trivializationAt F E x).continuousLinearEquivAt ℝ _ h'x).apply_symm_apply v + convert! ((trivializationAt F E x).continuousLinearEquivAt ℝ _ h'x).apply_symm_apply v simp [Trivialization.coe_continuousLinearEquivAt_eq _ h'x] have : (trivializationAt F E x).continuousLinearMapAt ℝ y = (ContinuousLinearMap.id _ _) ∘L ((trivializationAt F E x).continuousLinearMapAt ℝ y) := by simp @@ -291,7 +291,7 @@ lemma eventually_norm_symmL_trivializationAt_comp_self_lt (x : B) {r : ℝ} (hr rw [inCoordinates_apply_eq₂ h'x h'x (Set.mem_univ _)] have A : ((trivializationAt F E x).symm x) ((trivializationAt F E x).linearMapAt ℝ x v) = v := by - convert ((trivializationAt F E x).continuousLinearEquivAt ℝ _ h'x).symm_apply_apply v + convert! ((trivializationAt F E x).continuousLinearEquivAt ℝ _ h'x).symm_apply_apply v simp [Trivialization.coe_continuousLinearEquivAt_eq _ h'x] simp [A, w] have hgy : g y ((trivializationAt F E x).symm y w) ((trivializationAt F E x).symm y w) @@ -335,7 +335,7 @@ lemma eventually_norm_symmL_trivializationAt_lt (x : B) : have h'x : x ∈ (trivializationAt F E x).baseSet := FiberBundle.mem_baseSet_trivializationAt' x simp only [coe_comp', Trivialization.continuousLinearMapAt_apply, Trivialization.symmL_apply, Function.comp_apply, coe_id', id_eq] - convert ((trivializationAt F E x).continuousLinearEquivAt ℝ _ h'x).apply_symm_apply v + convert! ((trivializationAt F E x).continuousLinearEquivAt ℝ _ h'x).apply_symm_apply v simp [Trivialization.coe_continuousLinearEquivAt_eq _ h'x] have : (trivializationAt F E x).symmL ℝ y = ((trivializationAt F E x).symmL ℝ y) ∘L (ContinuousLinearMap.id _ _) := by simp diff --git a/Mathlib/Util/Delaborators.lean b/Mathlib/Util/Delaborators.lean index 80a6a0984b177f..2a6c2567120c5c 100644 --- a/Mathlib/Util/Delaborators.lean +++ b/Mathlib/Util/Delaborators.lean @@ -171,7 +171,7 @@ end existential open Lean Lean.PrettyPrinter.Delaborator /-- Delaborator for `∉`. -/ -@[app_delab Not] def delab_not_in := whenPPOption Lean.getPPNotation do +@[app_delab Not] def delabNotIn := whenPPOption Lean.getPPNotation do let #[f] := (← SubExpr.getExpr).getAppArgs | failure guard <| f.isAppOfArity ``Membership.mem 5 let stx₁ ← SubExpr.withAppArg <| SubExpr.withNaryArg 3 delab diff --git a/MathlibTest/Polynomial.lean b/MathlibTest/Algebra/Polynomial.lean similarity index 100% rename from MathlibTest/Polynomial.lean rename to MathlibTest/Algebra/Polynomial.lean diff --git a/MathlibTest/toAdditive.lean b/MathlibTest/Attribute/ToAdditive/Basic.lean similarity index 100% rename from MathlibTest/toAdditive.lean rename to MathlibTest/Attribute/ToAdditive/Basic.lean diff --git a/MathlibTest/toAdditiveIrredDef.lean b/MathlibTest/Attribute/ToAdditive/IrredDef.lean similarity index 100% rename from MathlibTest/toAdditiveIrredDef.lean rename to MathlibTest/Attribute/ToAdditive/IrredDef.lean diff --git a/MathlibTest/ToDual.lean b/MathlibTest/Attribute/ToDual.lean similarity index 100% rename from MathlibTest/ToDual.lean rename to MathlibTest/Attribute/ToDual.lean diff --git a/MathlibTest/DFinsuppMultiLinear.lean b/MathlibTest/Data/DFinsupp/DFinsuppMultiLinear.lean similarity index 100% rename from MathlibTest/DFinsuppMultiLinear.lean rename to MathlibTest/Data/DFinsupp/DFinsuppMultiLinear.lean diff --git a/MathlibTest/dfinsupp_notation.lean b/MathlibTest/Data/DFinsupp/Notation.lean similarity index 100% rename from MathlibTest/dfinsupp_notation.lean rename to MathlibTest/Data/DFinsupp/Notation.lean diff --git a/MathlibTest/vec_notation.lean b/MathlibTest/Data/Fin/VecNotation.lean similarity index 100% rename from MathlibTest/vec_notation.lean rename to MathlibTest/Data/Fin/VecNotation.lean diff --git a/MathlibTest/FunLike.lean b/MathlibTest/Data/FunLike.lean similarity index 100% rename from MathlibTest/FunLike.lean rename to MathlibTest/Data/FunLike.lean diff --git a/MathlibTest/Real.lean b/MathlibTest/Data/Real.lean similarity index 100% rename from MathlibTest/Real.lean rename to MathlibTest/Data/Real.lean diff --git a/MathlibTest/zmod.lean b/MathlibTest/Data/ZMod.lean similarity index 100% rename from MathlibTest/zmod.lean rename to MathlibTest/Data/ZMod.lean diff --git a/MathlibTest/DeprecatedModuleTest.lean b/MathlibTest/DeprecatedModuleTest.lean deleted file mode 100644 index fb31c735926bcb..00000000000000 --- a/MathlibTest/DeprecatedModuleTest.lean +++ /dev/null @@ -1,25 +0,0 @@ -import MathlibTest.DeprecatedModule - -/-- -warning: We can also give more details about the deprecation -'MathlibTest.DeprecatedModule' has been deprecated: please replace this import by - -import Mathlib.Tactic.Linter.DocPrime -import Mathlib.Tactic.Linter.DocString - - -Note: This linter can be disabled with `set_option linter.deprecated.module false` ---- -warning: -'MathlibTest.DeprecatedModule' has been deprecated: please replace this import by - -import Mathlib.Tactic.Linter.DocPrime -import Mathlib.Tactic.Linter.DocString - - -Note: This linter can be disabled with `set_option linter.deprecated.module false` --/ -#guard_msgs in -/-! -This file imports a deprecated module. --/ diff --git a/MathlibTest/deriving_countable.lean b/MathlibTest/DeriveCountable.lean similarity index 100% rename from MathlibTest/deriving_countable.lean rename to MathlibTest/DeriveCountable.lean diff --git a/MathlibTest/deriving_countable_module.lean b/MathlibTest/DeriveCountableModule.lean similarity index 100% rename from MathlibTest/deriving_countable_module.lean rename to MathlibTest/DeriveCountableModule.lean diff --git a/MathlibTest/derive_encodable.lean b/MathlibTest/DeriveEncodable.lean similarity index 100% rename from MathlibTest/derive_encodable.lean rename to MathlibTest/DeriveEncodable.lean diff --git a/MathlibTest/eval_elab.lean b/MathlibTest/EvalElab.lean similarity index 100% rename from MathlibTest/eval_elab.lean rename to MathlibTest/EvalElab.lean diff --git a/MathlibTest/fast_instance.lean b/MathlibTest/FastInstance.lean similarity index 100% rename from MathlibTest/fast_instance.lean rename to MathlibTest/FastInstance.lean diff --git a/MathlibTest/finset_builder.lean b/MathlibTest/FinsetBuilder.lean similarity index 100% rename from MathlibTest/finset_builder.lean rename to MathlibTest/FinsetBuilder.lean diff --git a/MathlibTest/finset_repr.lean b/MathlibTest/FinsetRepr.lean similarity index 100% rename from MathlibTest/finset_repr.lean rename to MathlibTest/FinsetRepr.lean diff --git a/MathlibTest/finsupp_notation.lean b/MathlibTest/FinsuppNotation.lean similarity index 100% rename from MathlibTest/finsupp_notation.lean rename to MathlibTest/FinsuppNotation.lean diff --git a/MathlibTest/format_table.lean b/MathlibTest/FormatTable.lean similarity index 100% rename from MathlibTest/format_table.lean rename to MathlibTest/FormatTable.lean diff --git a/MathlibTest/import_all.lean b/MathlibTest/ImportAll.lean similarity index 100% rename from MathlibTest/import_all.lean rename to MathlibTest/ImportAll.lean diff --git a/MathlibTest/instance_diamonds.lean b/MathlibTest/InstanceDiamonds.lean similarity index 100% rename from MathlibTest/instance_diamonds.lean rename to MathlibTest/InstanceDiamonds.lean diff --git a/MathlibTest/instance_diamonds/algebra_rat.lean b/MathlibTest/InstanceDiamonds/Algebra/Algebra/Rat.lean similarity index 100% rename from MathlibTest/instance_diamonds/algebra_rat.lean rename to MathlibTest/InstanceDiamonds/Algebra/Algebra/Rat.lean diff --git a/MathlibTest/instance_diamonds/Analysis/Normed/Field/WithAbs.lean b/MathlibTest/InstanceDiamonds/Analysis/Normed/Field/WithAbs.lean similarity index 100% rename from MathlibTest/instance_diamonds/Analysis/Normed/Field/WithAbs.lean rename to MathlibTest/InstanceDiamonds/Analysis/Normed/Field/WithAbs.lean diff --git a/MathlibTest/instance_diamonds/Data/Complex/Module.lean b/MathlibTest/InstanceDiamonds/Data/Complex/Module.lean similarity index 100% rename from MathlibTest/instance_diamonds/Data/Complex/Module.lean rename to MathlibTest/InstanceDiamonds/Data/Complex/Module.lean diff --git a/MathlibTest/instance_diamonds/FieldTheory/IsAlgClosed/AlgebraicClosure.lean b/MathlibTest/InstanceDiamonds/FieldTheory/IsAlgClosed/AlgebraicClosure.lean similarity index 100% rename from MathlibTest/instance_diamonds/FieldTheory/IsAlgClosed/AlgebraicClosure.lean rename to MathlibTest/InstanceDiamonds/FieldTheory/IsAlgClosed/AlgebraicClosure.lean diff --git a/MathlibTest/instance_diamonds/FieldTheory/SplittingField/Construction.lean b/MathlibTest/InstanceDiamonds/FieldTheory/SplittingField/Construction.lean similarity index 100% rename from MathlibTest/instance_diamonds/FieldTheory/SplittingField/Construction.lean rename to MathlibTest/InstanceDiamonds/FieldTheory/SplittingField/Construction.lean diff --git a/MathlibTest/instance_diamonds/normed.lean b/MathlibTest/InstanceDiamonds/Normed.lean similarity index 100% rename from MathlibTest/instance_diamonds/normed.lean rename to MathlibTest/InstanceDiamonds/Normed.lean diff --git a/MathlibTest/instances/CommRing_integralClosure.lean b/MathlibTest/Instances/CommRingIntegralClosure.lean similarity index 100% rename from MathlibTest/instances/CommRing_integralClosure.lean rename to MathlibTest/Instances/CommRingIntegralClosure.lean diff --git a/MathlibTest/instances/LawfulOfScientific.lean b/MathlibTest/Instances/LawfulOfScientific.lean similarity index 100% rename from MathlibTest/instances/LawfulOfScientific.lean rename to MathlibTest/Instances/LawfulOfScientific.lean diff --git a/MathlibTest/instances/Ring_finiteness.lean b/MathlibTest/Instances/RingFiniteness.lean similarity index 100% rename from MathlibTest/instances/Ring_finiteness.lean rename to MathlibTest/Instances/RingFiniteness.lean diff --git a/MathlibTest/jacobiSym.lean b/MathlibTest/JacobiSymbol.lean similarity index 100% rename from MathlibTest/jacobiSym.lean rename to MathlibTest/JacobiSymbol.lean diff --git a/MathlibTest/DeprecatedModule.lean b/MathlibTest/Linter/DeprecatedModule/Basic.lean similarity index 82% rename from MathlibTest/DeprecatedModule.lean rename to MathlibTest/Linter/DeprecatedModule/Basic.lean index 5b6ac0cc708ff3..0c9c7828e5af5c 100644 --- a/MathlibTest/DeprecatedModule.lean +++ b/MathlibTest/Linter/DeprecatedModule/Basic.lean @@ -7,7 +7,7 @@ deprecated_module (since := "2025-04-10") /-- info: Deprecated modules -'MathlibTest.DeprecatedModule' deprecates to +'MathlibTest.Linter.DeprecatedModule.Basic' deprecates to #[Mathlib.Tactic.Linter.DocPrime, Mathlib.Tactic.Linter.DocString] with no message -/ @@ -20,13 +20,13 @@ deprecated_module "We can also give more details about the deprecation" (since : /-- info: Deprecated modules -'MathlibTest.DeprecatedModule' deprecates to +'MathlibTest.Linter.DeprecatedModule.Basic' deprecates to #[Mathlib.Tactic.Linter.DocPrime, Mathlib.Tactic.Linter.DocString] -with message 'We can also give more details about the deprecation' +with no message -'MathlibTest.DeprecatedModule' deprecates to +'MathlibTest.Linter.DeprecatedModule.Basic' deprecates to #[Mathlib.Tactic.Linter.DocPrime, Mathlib.Tactic.Linter.DocString] -with no message +with message 'We can also give more details about the deprecation' -/ #guard_msgs in #show_deprecated_modules @@ -42,13 +42,13 @@ deprecated_module "Text" (since := "2025-02-31") /-- info: Deprecated modules -'MathlibTest.DeprecatedModule' deprecates to +'MathlibTest.Linter.DeprecatedModule.Basic' deprecates to #[Mathlib.Tactic.Linter.DocPrime, Mathlib.Tactic.Linter.DocString] -with message 'We can also give more details about the deprecation' +with no message -'MathlibTest.DeprecatedModule' deprecates to +'MathlibTest.Linter.DeprecatedModule.Basic' deprecates to #[Mathlib.Tactic.Linter.DocPrime, Mathlib.Tactic.Linter.DocString] -with no message +with message 'We can also give more details about the deprecation' -/ #guard_msgs in #show_deprecated_modules diff --git a/MathlibTest/DeprecatedModuleAllTest.lean b/MathlibTest/Linter/DeprecatedModule/ImportAsAll.lean similarity index 65% rename from MathlibTest/DeprecatedModuleAllTest.lean rename to MathlibTest/Linter/DeprecatedModule/ImportAsAll.lean index 4ab233da8e38e1..1b3a73a4be5da5 100644 --- a/MathlibTest/DeprecatedModuleAllTest.lean +++ b/MathlibTest/Linter/DeprecatedModule/ImportAsAll.lean @@ -1,10 +1,10 @@ module -import all MathlibTest.DeprecatedModuleNew +import all MathlibTest.Linter.DeprecatedModule.ImportBase /-- warning: Testing public import deprecation -'MathlibTest.DeprecatedModuleNew' has been deprecated: please replace this import by +'MathlibTest.Linter.DeprecatedModule.ImportBase' has been deprecated: please replace this import by import Mathlib.Tactic.Linter.DocPrime import Mathlib.Tactic.Linter.DocString diff --git a/MathlibTest/DeprecatedModuleMetaTest.lean b/MathlibTest/Linter/DeprecatedModule/ImportAsMeta.lean similarity index 65% rename from MathlibTest/DeprecatedModuleMetaTest.lean rename to MathlibTest/Linter/DeprecatedModule/ImportAsMeta.lean index db09101cf2281f..f645c7352613c8 100644 --- a/MathlibTest/DeprecatedModuleMetaTest.lean +++ b/MathlibTest/Linter/DeprecatedModule/ImportAsMeta.lean @@ -1,10 +1,10 @@ module -meta import MathlibTest.DeprecatedModuleNew +meta import MathlibTest.Linter.DeprecatedModule.ImportBase /-- warning: Testing public import deprecation -'MathlibTest.DeprecatedModuleNew' has been deprecated: please replace this import by +'MathlibTest.Linter.DeprecatedModule.ImportBase' has been deprecated: please replace this import by import Mathlib.Tactic.Linter.DocPrime import Mathlib.Tactic.Linter.DocString diff --git a/MathlibTest/Linter/DeprecatedModule/ImportAsPlain.lean b/MathlibTest/Linter/DeprecatedModule/ImportAsPlain.lean new file mode 100644 index 00000000000000..04624921b56905 --- /dev/null +++ b/MathlibTest/Linter/DeprecatedModule/ImportAsPlain.lean @@ -0,0 +1,16 @@ +import MathlibTest.Linter.DeprecatedModule.ImportBase + +/-- +warning: Testing public import deprecation +'MathlibTest.Linter.DeprecatedModule.ImportBase' has been deprecated: please replace this import by + +import Mathlib.Tactic.Linter.DocPrime +import Mathlib.Tactic.Linter.DocString + + +Note: This linter can be disabled with `set_option linter.deprecated.module false` +-/ +#guard_msgs in +/-! +This file imports a deprecated module. +-/ diff --git a/MathlibTest/DeprecatedModulePublicTest.lean b/MathlibTest/Linter/DeprecatedModule/ImportAsPublic.lean similarity index 65% rename from MathlibTest/DeprecatedModulePublicTest.lean rename to MathlibTest/Linter/DeprecatedModule/ImportAsPublic.lean index 60720201168acf..794e43121a5c8f 100644 --- a/MathlibTest/DeprecatedModulePublicTest.lean +++ b/MathlibTest/Linter/DeprecatedModule/ImportAsPublic.lean @@ -1,10 +1,11 @@ module -public import MathlibTest.DeprecatedModuleNew +public import MathlibTest.Linter.DeprecatedModule.ImportBase + /-- warning: Testing public import deprecation -'MathlibTest.DeprecatedModuleNew' has been deprecated: please replace this import by +'MathlibTest.Linter.DeprecatedModule.ImportBase' has been deprecated: please replace this import by import Mathlib.Tactic.Linter.DocPrime import Mathlib.Tactic.Linter.DocString diff --git a/MathlibTest/DeprecatedModuleNew.lean b/MathlibTest/Linter/DeprecatedModule/ImportBase.lean similarity index 100% rename from MathlibTest/DeprecatedModuleNew.lean rename to MathlibTest/Linter/DeprecatedModule/ImportBase.lean diff --git a/MathlibTest/DeprecatedModulePublicMetaTest.lean b/MathlibTest/Linter/DeprecatedModule/ImportsAsPublicMeta.lean similarity index 65% rename from MathlibTest/DeprecatedModulePublicMetaTest.lean rename to MathlibTest/Linter/DeprecatedModule/ImportsAsPublicMeta.lean index ae499955019231..010082a6b7d94d 100644 --- a/MathlibTest/DeprecatedModulePublicMetaTest.lean +++ b/MathlibTest/Linter/DeprecatedModule/ImportsAsPublicMeta.lean @@ -1,10 +1,10 @@ module -public meta import MathlibTest.DeprecatedModuleNew +public meta import MathlibTest.Linter.DeprecatedModule.ImportBase /-- warning: Testing public import deprecation -'MathlibTest.DeprecatedModuleNew' has been deprecated: please replace this import by +'MathlibTest.Linter.DeprecatedModule.ImportBase' has been deprecated: please replace this import by import Mathlib.Tactic.Linter.DocPrime import Mathlib.Tactic.Linter.DocString diff --git a/MathlibTest/DeprecatedSyntaxLinter.lean b/MathlibTest/Linter/DeprecatedSyntax.lean similarity index 100% rename from MathlibTest/DeprecatedSyntaxLinter.lean rename to MathlibTest/Linter/DeprecatedSyntax.lean diff --git a/MathlibTest/DocPrime.lean b/MathlibTest/Linter/DocPrime.lean similarity index 100% rename from MathlibTest/DocPrime.lean rename to MathlibTest/Linter/DocPrime.lean diff --git a/MathlibTest/DocString.lean b/MathlibTest/Linter/DocString.lean similarity index 100% rename from MathlibTest/DocString.lean rename to MathlibTest/Linter/DocString.lean diff --git a/MathlibTest/EmptyLine.lean b/MathlibTest/Linter/EmptyLine.lean similarity index 100% rename from MathlibTest/EmptyLine.lean rename to MathlibTest/Linter/EmptyLine.lean diff --git a/MathlibTest/FlexibleLinter.lean b/MathlibTest/Linter/Flexible/Basic.lean similarity index 100% rename from MathlibTest/FlexibleLinter.lean rename to MathlibTest/Linter/Flexible/Basic.lean diff --git a/MathlibTest/ImportHeavyFlexibleLinter.lean b/MathlibTest/Linter/Flexible/ImportHeavy.lean similarity index 100% rename from MathlibTest/ImportHeavyFlexibleLinter.lean rename to MathlibTest/Linter/Flexible/ImportHeavy.lean diff --git a/MathlibTest/ForbiddenModuleNames.lean b/MathlibTest/Linter/ForbiddenModuleNames.lean similarity index 100% rename from MathlibTest/ForbiddenModuleNames.lean rename to MathlibTest/Linter/ForbiddenModuleNames.lean diff --git a/MathlibTest/ModuleCasing.lean b/MathlibTest/Linter/ModuleCasing.lean similarity index 100% rename from MathlibTest/ModuleCasing.lean rename to MathlibTest/Linter/ModuleCasing.lean diff --git a/MathlibTest/oldObtain.lean b/MathlibTest/Linter/OldObtain.lean similarity index 100% rename from MathlibTest/oldObtain.lean rename to MathlibTest/Linter/OldObtain.lean diff --git a/MathlibTest/PrivateModuleLinter/hasOnlyPrivate.lean b/MathlibTest/Linter/PrivateModule/HasOnlyPrivate.lean similarity index 100% rename from MathlibTest/PrivateModuleLinter/hasOnlyPrivate.lean rename to MathlibTest/Linter/PrivateModule/HasOnlyPrivate.lean diff --git a/MathlibTest/PrivateModuleLinter/hasPublic.lean b/MathlibTest/Linter/PrivateModule/HasPublic.lean similarity index 100% rename from MathlibTest/PrivateModuleLinter/hasPublic.lean rename to MathlibTest/Linter/PrivateModule/HasPublic.lean diff --git a/MathlibTest/PrivateModuleLinter/importOnly.lean b/MathlibTest/Linter/PrivateModule/ImportOnly.lean similarity index 100% rename from MathlibTest/PrivateModuleLinter/importOnly.lean rename to MathlibTest/Linter/PrivateModule/ImportOnly.lean diff --git a/MathlibTest/PrivateModuleLinter/initialize.lean b/MathlibTest/Linter/PrivateModule/Initialize.lean similarity index 100% rename from MathlibTest/PrivateModuleLinter/initialize.lean rename to MathlibTest/Linter/PrivateModule/Initialize.lean diff --git a/MathlibTest/PrivateModuleLinter/nonModule.lean b/MathlibTest/Linter/PrivateModule/NonModule.lean similarity index 100% rename from MathlibTest/PrivateModuleLinter/nonModule.lean rename to MathlibTest/Linter/PrivateModule/NonModule.lean diff --git a/MathlibTest/PrivateModuleLinter/notation3.lean b/MathlibTest/Linter/PrivateModule/Notation3.lean similarity index 60% rename from MathlibTest/PrivateModuleLinter/notation3.lean rename to MathlibTest/Linter/PrivateModule/Notation3.lean index 016a383f94c014..3c0f5898d3c683 100644 --- a/MathlibTest/PrivateModuleLinter/notation3.lean +++ b/MathlibTest/Linter/PrivateModule/Notation3.lean @@ -10,10 +10,10 @@ local notation3 "MyList[" (x", "* => foldr (a b => List.cons a b) List.nil) "]" /- Check that we have indeed created declarations, and aren't not linting just due to being an empty file: -/ /-- -info: [_private.MathlibTest.PrivateModuleLinter.notation3.0.«_aux_MathlibTest_PrivateModuleLinter_notation3___delab_app__private_MathlibTest_PrivateModuleLinter_notation3_0_termMyList[_,]_2», - _private.MathlibTest.PrivateModuleLinter.notation3.0.«termMyList[_,]», - _private.MathlibTest.PrivateModuleLinter.notation3.0.«_aux_MathlibTest_PrivateModuleLinter_notation3___delab_app__private_MathlibTest_PrivateModuleLinter_notation3_0_termMyList[_,]_1», - _private.MathlibTest.PrivateModuleLinter.notation3.0.«_aux_MathlibTest_PrivateModuleLinter_notation3___macroRules__private_MathlibTest_PrivateModuleLinter_notation3_0_termMyList[_,]_1»] +info: [_private.MathlibTest.Linter.PrivateModule.Notation3.0.«termMyList[_,]», + _private.MathlibTest.Linter.PrivateModule.Notation3.0.«_aux_MathlibTest_Linter_PrivateModule_Notation3___macroRules__private_MathlibTest_Linter_PrivateModule_Notation3_0_termMyList[_,]_1», + _private.MathlibTest.Linter.PrivateModule.Notation3.0.«_aux_MathlibTest_Linter_PrivateModule_Notation3___delab_app__private_MathlibTest_Linter_PrivateModule_Notation3_0_termMyList[_,]_2», + _private.MathlibTest.Linter.PrivateModule.Notation3.0.«_aux_MathlibTest_Linter_PrivateModule_Notation3___delab_app__private_MathlibTest_Linter_PrivateModule_Notation3_0_termMyList[_,]_1»] -/ #guard_msgs in run_cmd do diff --git a/MathlibTest/PrivateModuleLinter/reservedName1.lean b/MathlibTest/Linter/PrivateModule/ReservedName1.lean similarity index 100% rename from MathlibTest/PrivateModuleLinter/reservedName1.lean rename to MathlibTest/Linter/PrivateModule/ReservedName1.lean diff --git a/MathlibTest/PrivateModuleLinter/reservedName2.lean b/MathlibTest/Linter/PrivateModule/ReservedName2.lean similarity index 95% rename from MathlibTest/PrivateModuleLinter/reservedName2.lean rename to MathlibTest/Linter/PrivateModule/ReservedName2.lean index 492bcf48104306..bbeb0651b5e663 100644 --- a/MathlibTest/PrivateModuleLinter/reservedName2.lean +++ b/MathlibTest/Linter/PrivateModule/ReservedName2.lean @@ -2,7 +2,7 @@ module import Mathlib.Init import all Mathlib.Tactic.Linter.PrivateModule -public import MathlibTest.PrivateModuleLinter.reservedName1 +public import MathlibTest.Linter.PrivateModule.ReservedName1 open Lean diff --git a/MathlibTest/LintStyle.lean b/MathlibTest/Linter/TextBased.lean similarity index 98% rename from MathlibTest/LintStyle.lean rename to MathlibTest/Linter/TextBased.lean index 1f3b696f653e86..a7db13f0217b7d 100644 --- a/MathlibTest/LintStyle.lean +++ b/MathlibTest/Linter/TextBased.lean @@ -459,9 +459,10 @@ open Mathlib.Linter.Style.nameCheck #guard isBadNameWithUnderscore `_fooFoo == true #guard isBadNameWithUnderscore `Foo._bar == true -- A namespace `Mathlib` in the middle does not silence the linter: we only test for a *prefix* --- `Mathlib`, `Mathlib.Parser` or `Mathlib.Tactic`. +-- `Mathlib`, `Parser` or `Mathlib.Tactic`. #guard isBadNameWithUnderscore `Nat.Mathlib.foo_bar == true -#guard isBadNameWithUnderscore `Mathlib.Parser.foo_bar == false +#guard isBadNameWithUnderscore `Parser.foo_bar == false +#guard isBadNameWithUnderscore `Parser.Attr.coassoc_simps == false #guard isBadNameWithUnderscore `Mathlib.Tactic.foo_bar == false #guard isBadNameWithUnderscore `AlgebraicGeometry.Scheme.IdealSheafData.Simps.coe_support == false @@ -665,14 +666,21 @@ open Mathlib.Linter.TextBased.UnicodeLinter /- A character either does or doesn't have an abbreviation in the VSCode extension. -/ #guard withVSCodeAbbrev.toList ∩ othersInMathlib.toList = ∅ -/- A character either is or isn't an emoji. -/ +/- No character is both an emoji and not an emoji. -/ #guard emojis.toList ∩ nonEmojis.toList = ∅ +/- No character is both an emoji and unrestricted. -/ +#guard emojis.toList ∩ unrestricted.toList = ∅ + +/- No character is both a non-emoji and unrestricted. -/ +#guard nonEmojis.toList ∩ unrestricted.toList = ∅ + def allLinterDefinedCharacterLists : List (List Char) := [ withVSCodeAbbrev, othersInMathlib, emojis, - nonEmojis + nonEmojis, + unrestricted ].map Array.toList /- Ensure none of the lists contain duplicates -/ diff --git a/MathlibTest/norm_cast.lean b/MathlibTest/NormCast.lean similarity index 100% rename from MathlibTest/norm_cast.lean rename to MathlibTest/NormCast.lean diff --git a/MathlibTest/OverlappingInstances.lean b/MathlibTest/OverlappingInstances.lean new file mode 100644 index 00000000000000..5e9019262dbb55 --- /dev/null +++ b/MathlibTest/OverlappingInstances.lean @@ -0,0 +1,391 @@ +module + +import Mathlib.Tactic.Linter.OverlappingInstances +import Mathlib.Init + +public section + +class SubBar (α : Type) where + a' : α + +class Bar (α : Type) extends SubBar α where + a : α + +class Baz (α : Type) where + b : α + +class Baq (α : Type) where + b : α + +class FooBarBaz (α) extends Bar α, Baz α + +class FooBarBaz' (α) extends Bar α, Baz α + +class FooBarBaq (α) extends Bar α, Baq α + +/-- +error: unsolved goals +inst✝¹ inst✝ : Add Nat +⊢ [Add Nat] → [Add Nat] → Bool +--- +warning: Overlapping instance parameters in `foo`: + +⚠️ There are 4 `[Add Nat]` instances; one is sufficient. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +def foo [Add Nat] [Add Nat] : [Add Nat] → [Add Nat] → Bool := by + skip + +/-- +@ +3:21...+4:12 +warning: Overlapping instance parameters in `foo₁`: + +⚠️ `[FooBarBaz Nat]` and `[FooBarBaq Nat]` can be used to infer conflicting versions of `[SubBar Nat]`. + +When a data-carrying type class has multiple potential instances coming from different instance parameters, then these potential instances are incompatible. This is an example of an "instance diamond", which leads to unexpected unification failures. + +Delete or combine some of your instance parameters to avoid this. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs (positions := true) in +set_option linter.overlappingInstances true in +/-- A docstring! -/ +@[expose] public def foo₁ [FooBarBaz Nat] [FooBarBaq Nat] : Bool := by + exact true + +/-- +warning: Overlapping instance parameters in `foo₂`: + +⚠️ There are 2 `[FooBarBaz Nat]` instances; one is sufficient. +⚠️ `[FooBarBaz + Nat]`, `[FooBarBaz Nat]`, and `[FooBarBaq Nat]` can be used to infer conflicting versions of `[SubBar Nat]`. +💡️ Of these, `[FooBarBaz Nat]` and `[FooBarBaz Nat]` may be removed. + +When a data-carrying type class has multiple potential instances coming from different instance parameters, then these potential instances are incompatible. This is an example of an "instance diamond", which leads to unexpected unification failures. + +Delete or combine some of your instance parameters to avoid this. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +def foo₂ [FooBarBaz Nat] [FooBarBaz Nat] [FooBarBaq Nat] : Bool := true + +/-- +warning: Overlapping instance parameters in `foo₃`: + +⚠️ There are 2 `[FooBarBaz Nat]` instances; one is sufficient. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +def foo₃ [FooBarBaz Nat] [FooBarBaz Nat] : Bool := true + +/-- +warning: Overlapping instance parameters in `foo₄`: + +⚠️ There are 2 `[FooBarBaz Nat]` instances; one is sufficient. +⚠️ `[FooBarBaz Nat]`, `[FooBarBaz Nat]`, and `[Bar Nat]` can be used to infer conflicting versions of `[SubBar Nat]`. +💡️ Of these, `[FooBarBaz Nat]`, `[FooBarBaz Nat]`, and `[Bar Nat]` may be removed. + +When a data-carrying type class has multiple potential instances coming from different instance parameters, then these potential instances are incompatible. This is an example of an "instance diamond", which leads to unexpected unification failures. + +Delete or combine some of your instance parameters to avoid this. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +theorem foo₄ [FooBarBaz Nat] [FooBarBaz Nat] [Bar Nat] : True := trivial + +/-- +warning: Overlapping instance parameters in `foo₅`: + +⚠️ `[FooBarBaz Nat]` and `[FooBarBaz' Nat]` can be used to infer conflicting versions of `[Baz Nat]` and `[SubBar Nat]`. + +When a data-carrying type class has multiple potential instances coming from different instance parameters, then these potential instances are incompatible. This is an example of an "instance diamond", which leads to unexpected unification failures. + +Delete or combine some of your instance parameters to avoid this. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +lemma foo₅ [FooBarBaz Nat] [FooBarBaz' Nat] : True := trivial + +/-- +warning: Overlapping instance parameters in `foo₆`: + +⚠️ `[FooBarBaz Nat]` and `[FooBarBaz' Nat]` can be used to infer conflicting versions of `[Baz Nat]`. +⚠️ `[FooBarBaz + Nat]`, `[FooBarBaz' Nat]`, and `[FooBarBaq Nat]` can be used to infer conflicting versions of `[SubBar Nat]`. + +When a data-carrying type class has multiple potential instances coming from different instance parameters, then these potential instances are incompatible. This is an example of an "instance diamond", which leads to unexpected unification failures. + +Delete or combine some of your instance parameters to avoid this. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +lemma foo₆ [FooBarBaz Nat] [FooBarBaz' Nat] [FooBarBaq Nat] : True := trivial + +namespace Foo + +/-! Test unresolving name (`foo`, not `Foo.foo` or `_private...foo`) -/ + +/-- +warning: Overlapping instance parameters in `foo`: + +⚠️ There are 2 `[Add Nat]` instances; one is sufficient. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +private def foo [Add Nat] [Add Nat] : Bool := true + +end Foo + +namespace prop + +class IsFoo : Prop + +class IsBar : Prop extends IsFoo + +class IsBaz : Prop extends IsBar + +/-- +warning: Overlapping instance parameters in `_example`: + +⚠️ `[IsBar]` and `[IsBaz]` each imply `[IsFoo]`. +💡️ Of these, `[IsBar]` may be removed. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +example [IsBar] [IsBaz] : True := trivial + +class Bar : Type extends IsFoo +class Baz : Type extends IsFoo +class Baz1 : Type extends Baz +class Baz2 : Type extends Baz + +/-- +warning: Overlapping instance parameters in `_example`: + +⚠️ `[IsFoo]` and `[Bar]` each imply `[IsFoo]`. +💡️ Of these, `[IsFoo]` may be removed. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +example [IsFoo] [Bar] : True := trivial + +example [IsBar] [Bar] : True := trivial + +example [Bar] [Baz] : True := trivial + +/-- +warning: Overlapping instance parameters in `_example`: + +⚠️ There are 2 `[Baz]` instances; one is sufficient. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +example [Baz] [Baz] : True := trivial + +/-- +warning: Overlapping instance parameters in `_example`: + +⚠️ `[Baz]` and `[Baz1]` can be used to infer conflicting versions of `[Baz]`. +💡️ Of these, `[Baz]` may be removed. + +When a data-carrying type class has multiple potential instances coming from different instance parameters, then these potential instances are incompatible. This is an example of an "instance diamond", which leads to unexpected unification failures. + +Delete or combine some of your instance parameters to avoid this. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +example [Baz] [Baz1] : True := trivial + +/-- +warning: Overlapping instance parameters in `_example`: + +⚠️ `[Baz1]` and `[Baz2]` can be used to infer conflicting versions of `[Baz]`. + +When a data-carrying type class has multiple potential instances coming from different instance parameters, then these potential instances are incompatible. This is an example of an "instance diamond", which leads to unexpected unification failures. + +Delete or combine some of your instance parameters to avoid this. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +example [Baz1] [Baz2] : True := trivial + +end prop + +section duplicates + +/-! Make sure we warn on duplicate inductive classes and duplicate `Prop` classes. -/ + +class inductive IndFoo where +| mk₁ (n : Nat) | mk₂ (b : Bool) + +/-- +warning: Overlapping instance parameters in `indFoo`: + +⚠️ There are 2 `[IndFoo]` instances; one is sufficient. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +def indFoo [IndFoo] [IndFoo] : Bool := true + +class inductive IndFooProp : Prop where +| mk₁ (n : Nat) | mk₂ (b : Bool) + +/-- +warning: Overlapping instance parameters in `indFooProp`: + +⚠️ There are 2 `[IndFooProp]` instances; one is sufficient. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +def indFooProp [IndFooProp] [IndFooProp] : Bool := true + +end duplicates + +section instantiateMVars + +variable {α : Type*} [Repr α] + +/-- +warning: Overlapping instance parameters in `needsInstantiateMVars`: + +⚠️ There are 2 `[Repr α]` instances; one is sufficient. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +def needsInstantiateMVars [Repr α] : Bool := true + +end instantiateMVars + +section setOptionIn + +set_option linter.overlappingInstances false in +def fooNothing [Add Nat] [Add Nat] : [Add Nat] → [Add Nat] → Bool := true + +set_option linter.overlappingInstances false + +/-- +warning: Overlapping instance parameters in `fooSomething`: + +⚠️ There are 4 `[Add Nat]` instances; one is sufficient. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +set_option linter.overlappingInstances true in +def fooSomething [Add Nat] [Add Nat] : [Add Nat] → [Add Nat] → Bool := true + +end setOptionIn + +namespace universes + +/-! Test a projection that goes from `Type*` to `Sort*`. -/ + +class A (α : Sort u) where + +class B (α : Type u) extends A α + +/-- +warning: Overlapping instance parameters in `_example`: + +⚠️ `[B α]` and `[A α]` can be used to infer conflicting versions of `[A α]`. +💡️ Of these, `[A α]` may be removed. + +When a data-carrying type class has multiple potential instances coming from different instance parameters, then these potential instances are incompatible. This is an example of an "instance diamond", which leads to unexpected unification failures. + +Delete or combine some of your instance parameters to avoid this. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +example (α : Type 4) [B α] [A α] : True := trivial + +end universes + +namespace parameters + +/-! Test a projection that changes the instance parameters. (This needs `eraseInstances`) -/ + +class A (α : Type*) where +class A' (α : Type*) extends A α where + +class B (α β : Type*) [A α] where +class B' (α β : Type*) [A' α] extends B α β where + +instance {α} : A α where + +/-- +warning: Overlapping instance parameters in `_example`: + +⚠️ `[B α β]` and `[B' α β]` can be used to infer conflicting versions of `[B α β]`. +💡️ Of these, `[B α β]` may be removed. + +When a data-carrying type class has multiple potential instances coming from different instance parameters, then these potential instances are incompatible. This is an example of an "instance diamond", which leads to unexpected unification failures. + +Delete or combine some of your instance parameters to avoid this. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +example {α β} [B α β] [A' α] [B' α β] : True := trivial + +end parameters + +/-! Test a `where` clause. -/ + +/-- +warning: Overlapping instance parameters in `List.lt'.go`: + +⚠️ There are 2 `[DecidableEq α]` instances; one is sufficient. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +def List.lt' {α} [DecidableEq α] (a b : List α) : Bool := + go a b +where + go [DecidableEq α] (_ _ : List α) : Bool := false + +-- Sadly, the linter does not work when the declaration doesn't have a body: + +class FooClass (α : Type) [Add α] [Add α] where + +/-! Test classes that extend a non-class -/ + +structure NotAClass where +class IsAClass1 extends NotAClass +class IsAClass1' extends NotAClass +class IsAClass2 extends IsAClass1 + +example [IsAClass1] [IsAClass1'] : True := trivial + +/-- +warning: Overlapping instance parameters in `_example`: + +⚠️ `[IsAClass1]` and `[IsAClass2]` can be used to infer conflicting versions of `[IsAClass1]`. +💡️ Of these, `[IsAClass1]` may be removed. + +When a data-carrying type class has multiple potential instances coming from different instance parameters, then these potential instances are incompatible. This is an example of an "instance diamond", which leads to unexpected unification failures. + +Delete or combine some of your instance parameters to avoid this. + +Note: This linter can be disabled with `set_option linter.overlappingInstances false` +-/ +#guard_msgs in +example [IsAClass1] [IsAClass2] : True := trivial diff --git a/MathlibTest/register_try_tactic.lean b/MathlibTest/RegisterTryTactic.lean similarity index 100% rename from MathlibTest/register_try_tactic.lean rename to MathlibTest/RegisterTryTactic.lean diff --git a/MathlibTest/right_actions.lean b/MathlibTest/RightActions.lean similarity index 100% rename from MathlibTest/right_actions.lean rename to MathlibTest/RightActions.lean diff --git a/MathlibTest/set_like.lean b/MathlibTest/SetLike.lean similarity index 100% rename from MathlibTest/set_like.lean rename to MathlibTest/SetLike.lean diff --git a/MathlibTest/simp_confluence.lean b/MathlibTest/SimpConfluence.lean similarity index 100% rename from MathlibTest/simp_confluence.lean rename to MathlibTest/SimpConfluence.lean diff --git a/MathlibTest/slim_check.lean b/MathlibTest/SlimCheck.lean similarity index 100% rename from MathlibTest/slim_check.lean rename to MathlibTest/SlimCheck.lean diff --git a/MathlibTest/slow_instances.lean b/MathlibTest/SlowInstances.lean similarity index 100% rename from MathlibTest/slow_instances.lean rename to MathlibTest/SlowInstances.lean diff --git a/MathlibTest/slow_simp.lean b/MathlibTest/SlowSimp.lean similarity index 100% rename from MathlibTest/slow_simp.lean rename to MathlibTest/SlowSimp.lean diff --git a/MathlibTest/spread.lean b/MathlibTest/Spread.lean similarity index 100% rename from MathlibTest/spread.lean rename to MathlibTest/Spread.lean diff --git a/MathlibTest/Subsingleton.lean b/MathlibTest/Subsingleton.lean index 6b5fd394eacca6..f139fe25b410b0 100644 --- a/MathlibTest/Subsingleton.lean +++ b/MathlibTest/Subsingleton.lean @@ -56,6 +56,7 @@ end AvoidSurprise /-! Handles `BEq` instances if there are `LawfulBEq` instances for each. -/ +set_option linter.overlappingInstances false in example (α : Type) (inst1 inst2 : BEq α) [@LawfulBEq α inst1] [@LawfulBEq α inst2] : inst1 = inst2 := by subsingleton diff --git a/MathlibTest/aesop_cat.lean b/MathlibTest/Tactic/AesopCat.lean similarity index 100% rename from MathlibTest/aesop_cat.lean rename to MathlibTest/Tactic/AesopCat.lean diff --git a/MathlibTest/apply_congr.lean b/MathlibTest/Tactic/ApplyCongr.lean similarity index 100% rename from MathlibTest/apply_congr.lean rename to MathlibTest/Tactic/ApplyCongr.lean diff --git a/MathlibTest/apply_fun.lean b/MathlibTest/Tactic/ApplyFun.lean similarity index 100% rename from MathlibTest/apply_fun.lean rename to MathlibTest/Tactic/ApplyFun.lean diff --git a/MathlibTest/apply_rules.lean b/MathlibTest/Tactic/ApplyRules.lean similarity index 100% rename from MathlibTest/apply_rules.lean rename to MathlibTest/Tactic/ApplyRules.lean diff --git a/MathlibTest/apply_with.lean b/MathlibTest/Tactic/ApplyWith.lean similarity index 100% rename from MathlibTest/apply_with.lean rename to MathlibTest/Tactic/ApplyWith.lean diff --git a/MathlibTest/Bound/attribute.lean b/MathlibTest/Tactic/Bound/Attribute.lean similarity index 100% rename from MathlibTest/Bound/attribute.lean rename to MathlibTest/Tactic/Bound/Attribute.lean diff --git a/MathlibTest/Bound/bound.lean b/MathlibTest/Tactic/Bound/Basic.lean similarity index 100% rename from MathlibTest/Bound/bound.lean rename to MathlibTest/Tactic/Bound/Basic.lean diff --git a/MathlibTest/cancel_denoms.lean b/MathlibTest/Tactic/CancelDenoms.lean similarity index 100% rename from MathlibTest/cancel_denoms.lean rename to MathlibTest/Tactic/CancelDenoms.lean diff --git a/MathlibTest/cases.lean b/MathlibTest/Tactic/Cases.lean similarity index 100% rename from MathlibTest/cases.lean rename to MathlibTest/Tactic/Cases.lean diff --git a/MathlibTest/casesm.lean b/MathlibTest/Tactic/CasesM.lean similarity index 100% rename from MathlibTest/casesm.lean rename to MathlibTest/Tactic/CasesM.lean diff --git a/MathlibTest/Change.lean b/MathlibTest/Tactic/Change.lean similarity index 100% rename from MathlibTest/Change.lean rename to MathlibTest/Tactic/Change.lean diff --git a/MathlibTest/Check.lean b/MathlibTest/Tactic/Check.lean similarity index 100% rename from MathlibTest/Check.lean rename to MathlibTest/Tactic/Check.lean diff --git a/MathlibTest/choose.lean b/MathlibTest/Tactic/Choose/Basic.lean similarity index 100% rename from MathlibTest/choose.lean rename to MathlibTest/Tactic/Choose/Basic.lean diff --git a/MathlibTest/choose_reduction.lean b/MathlibTest/Tactic/Choose/Reduction.lean similarity index 100% rename from MathlibTest/choose_reduction.lean rename to MathlibTest/Tactic/Choose/Reduction.lean diff --git a/MathlibTest/ClearExcept.lean b/MathlibTest/Tactic/ClearExcept.lean similarity index 100% rename from MathlibTest/ClearExcept.lean rename to MathlibTest/Tactic/ClearExcept.lean diff --git a/MathlibTest/ClearExclamation.lean b/MathlibTest/Tactic/ClearExclamation.lean similarity index 100% rename from MathlibTest/ClearExclamation.lean rename to MathlibTest/Tactic/ClearExclamation.lean diff --git a/MathlibTest/Clear_.lean b/MathlibTest/Tactic/Clear_.lean similarity index 100% rename from MathlibTest/Clear_.lean rename to MathlibTest/Tactic/Clear_.lean diff --git a/MathlibTest/congrm.lean b/MathlibTest/Tactic/CongrM.lean similarity index 100% rename from MathlibTest/congrm.lean rename to MathlibTest/Tactic/CongrM.lean diff --git a/MathlibTest/Constructor.lean b/MathlibTest/Tactic/Constructor.lean similarity index 100% rename from MathlibTest/Constructor.lean rename to MathlibTest/Tactic/Constructor.lean diff --git a/MathlibTest/Contrapose.lean b/MathlibTest/Tactic/Contrapose.lean similarity index 100% rename from MathlibTest/Contrapose.lean rename to MathlibTest/Tactic/Contrapose.lean diff --git a/MathlibTest/conv.lean b/MathlibTest/Tactic/Conv.lean similarity index 100% rename from MathlibTest/conv.lean rename to MathlibTest/Tactic/Conv.lean diff --git a/MathlibTest/convert.lean b/MathlibTest/Tactic/Convert/Basic.lean similarity index 100% rename from MathlibTest/convert.lean rename to MathlibTest/Tactic/Convert/Basic.lean diff --git a/MathlibTest/convert2.lean b/MathlibTest/Tactic/Convert/Bugfix7945.lean similarity index 100% rename from MathlibTest/convert2.lean rename to MathlibTest/Tactic/Convert/Bugfix7945.lean diff --git a/MathlibTest/enat_to_nat.lean b/MathlibTest/Tactic/ENatToNat.lean similarity index 100% rename from MathlibTest/enat_to_nat.lean rename to MathlibTest/Tactic/ENatToNat.lean diff --git a/MathlibTest/ErwQuestion.lean b/MathlibTest/Tactic/ErwQuestion.lean similarity index 100% rename from MathlibTest/ErwQuestion.lean rename to MathlibTest/Tactic/ErwQuestion.lean diff --git a/MathlibTest/ExistsI.lean b/MathlibTest/Tactic/ExistsI.lean similarity index 100% rename from MathlibTest/ExistsI.lean rename to MathlibTest/Tactic/ExistsI.lean diff --git a/MathlibTest/ExtractGoal.lean b/MathlibTest/Tactic/ExtractGoal.lean similarity index 100% rename from MathlibTest/ExtractGoal.lean rename to MathlibTest/Tactic/ExtractGoal.lean diff --git a/MathlibTest/fail_if_no_progress.lean b/MathlibTest/Tactic/FailIfNoProgress.lean similarity index 100% rename from MathlibTest/fail_if_no_progress.lean rename to MathlibTest/Tactic/FailIfNoProgress.lean diff --git a/MathlibTest/FieldSimp.lean b/MathlibTest/Tactic/FieldSimp.lean similarity index 100% rename from MathlibTest/FieldSimp.lean rename to MathlibTest/Tactic/FieldSimp.lean diff --git a/MathlibTest/fin_cases.lean b/MathlibTest/Tactic/FinCases.lean similarity index 100% rename from MathlibTest/fin_cases.lean rename to MathlibTest/Tactic/FinCases.lean diff --git a/MathlibTest/finiteness.lean b/MathlibTest/Tactic/Finiteness.lean similarity index 100% rename from MathlibTest/finiteness.lean rename to MathlibTest/Tactic/Finiteness.lean diff --git a/MathlibTest/GCongr/GCongr.lean b/MathlibTest/Tactic/GCongr/Basic.lean similarity index 100% rename from MathlibTest/GCongr/GCongr.lean rename to MathlibTest/Tactic/GCongr/Basic.lean diff --git a/MathlibTest/GCongr/Core.lean b/MathlibTest/Tactic/GCongr/Core.lean similarity index 100% rename from MathlibTest/GCongr/Core.lean rename to MathlibTest/Tactic/GCongr/Core.lean diff --git a/MathlibTest/GCongr/implications.lean b/MathlibTest/Tactic/GCongr/Implications.lean similarity index 100% rename from MathlibTest/GCongr/implications.lean rename to MathlibTest/Tactic/GCongr/Implications.lean diff --git a/MathlibTest/GCongr/inequalities.lean b/MathlibTest/Tactic/GCongr/Inequalities.lean similarity index 100% rename from MathlibTest/GCongr/inequalities.lean rename to MathlibTest/Tactic/GCongr/Inequalities.lean diff --git a/MathlibTest/GCongr/mod.lean b/MathlibTest/Tactic/GCongr/Mod.lean similarity index 100% rename from MathlibTest/GCongr/mod.lean rename to MathlibTest/Tactic/GCongr/Mod.lean diff --git a/MathlibTest/grind/ac.lean b/MathlibTest/Tactic/Grind/AC.lean similarity index 100% rename from MathlibTest/grind/ac.lean rename to MathlibTest/Tactic/Grind/AC.lean diff --git a/MathlibTest/grind/cc.lean b/MathlibTest/Tactic/Grind/CC.lean similarity index 100% rename from MathlibTest/grind/cc.lean rename to MathlibTest/Tactic/Grind/CC.lean diff --git a/MathlibTest/grind/field.lean b/MathlibTest/Tactic/Grind/Field.lean similarity index 100% rename from MathlibTest/grind/field.lean rename to MathlibTest/Tactic/Grind/Field.lean diff --git a/MathlibTest/grind/field_instance.lean b/MathlibTest/Tactic/Grind/FieldInstance.lean similarity index 100% rename from MathlibTest/grind/field_instance.lean rename to MathlibTest/Tactic/Grind/FieldInstance.lean diff --git a/MathlibTest/grind/grobner.lean b/MathlibTest/Tactic/Grind/Grobner.lean similarity index 100% rename from MathlibTest/grind/grobner.lean rename to MathlibTest/Tactic/Grind/Grobner.lean diff --git a/MathlibTest/grind/linarith.lean b/MathlibTest/Tactic/Grind/Linarith.lean similarity index 100% rename from MathlibTest/grind/linarith.lean rename to MathlibTest/Tactic/Grind/Linarith.lean diff --git a/MathlibTest/grind/lint.lean b/MathlibTest/Tactic/Grind/Lint.lean similarity index 100% rename from MathlibTest/grind/lint.lean rename to MathlibTest/Tactic/Grind/Lint.lean diff --git a/MathlibTest/grind/natCast_instance.lean b/MathlibTest/Tactic/Grind/NatCastInstance.lean similarity index 100% rename from MathlibTest/grind/natCast_instance.lean rename to MathlibTest/Tactic/Grind/NatCastInstance.lean diff --git a/MathlibTest/grind/ordered_ring.lean b/MathlibTest/Tactic/Grind/OrderedRing.lean similarity index 100% rename from MathlibTest/grind/ordered_ring.lean rename to MathlibTest/Tactic/Grind/OrderedRing.lean diff --git a/MathlibTest/grind/pairwise_disjoint.lean b/MathlibTest/Tactic/Grind/PairwiseDisjoint.lean similarity index 100% rename from MathlibTest/grind/pairwise_disjoint.lean rename to MathlibTest/Tactic/Grind/PairwiseDisjoint.lean diff --git a/MathlibTest/grind/panic.lean b/MathlibTest/Tactic/Grind/Panic.lean similarity index 100% rename from MathlibTest/grind/panic.lean rename to MathlibTest/Tactic/Grind/Panic.lean diff --git a/MathlibTest/grind/ring.lean b/MathlibTest/Tactic/Grind/Ring.lean similarity index 100% rename from MathlibTest/grind/ring.lean rename to MathlibTest/Tactic/Grind/Ring.lean diff --git a/MathlibTest/grind/set.lean b/MathlibTest/Tactic/Grind/Set.lean similarity index 100% rename from MathlibTest/grind/set.lean rename to MathlibTest/Tactic/Grind/Set.lean diff --git a/MathlibTest/grind/trig.lean b/MathlibTest/Tactic/Grind/Trig.lean similarity index 100% rename from MathlibTest/grind/trig.lean rename to MathlibTest/Tactic/Grind/Trig.lean diff --git a/MathlibTest/Group.lean b/MathlibTest/Tactic/Group.lean similarity index 100% rename from MathlibTest/Group.lean rename to MathlibTest/Tactic/Group.lean diff --git a/MathlibTest/GuardGoalNums.lean b/MathlibTest/Tactic/GuardGoalNums.lean similarity index 100% rename from MathlibTest/GuardGoalNums.lean rename to MathlibTest/Tactic/GuardGoalNums.lean diff --git a/MathlibTest/GuardHypNums.lean b/MathlibTest/Tactic/GuardHypNums.lean similarity index 100% rename from MathlibTest/GuardHypNums.lean rename to MathlibTest/Tactic/GuardHypNums.lean diff --git a/MathlibTest/Have.lean b/MathlibTest/Tactic/Have.lean similarity index 100% rename from MathlibTest/Have.lean rename to MathlibTest/Tactic/Have.lean diff --git a/MathlibTest/hintAll.lean b/MathlibTest/Tactic/Hint/All.lean similarity index 98% rename from MathlibTest/hintAll.lean rename to MathlibTest/Tactic/Hint/All.lean index 3f9f5c2e26112b..ff3556b9bdcc55 100644 --- a/MathlibTest/hintAll.lean +++ b/MathlibTest/Tactic/Hint/All.lean @@ -203,9 +203,6 @@ info: Try these: [apply] norm_num Remaining subgoals: ⊢ a /ₚ u₁ + b /ₚ u₁ = (a + b) /ₚ u₁ - [apply] ring_nf - Remaining subgoals: - ⊢ a /ₚ u₁ + b /ₚ u₁ = (a + b) /ₚ u₁ [apply] abel_nf Remaining subgoals: ⊢ a /ₚ u₁ + b /ₚ u₁ = (a + b) /ₚ u₁ diff --git a/MathlibTest/hint.lean b/MathlibTest/Tactic/Hint/Basic.lean similarity index 100% rename from MathlibTest/hint.lean rename to MathlibTest/Tactic/Hint/Basic.lean diff --git a/MathlibTest/Inhabit.lean b/MathlibTest/Tactic/Inhabit.lean similarity index 100% rename from MathlibTest/Inhabit.lean rename to MathlibTest/Tactic/Inhabit.lean diff --git a/MathlibTest/interval_cases.lean b/MathlibTest/Tactic/IntervalCases.lean similarity index 100% rename from MathlibTest/interval_cases.lean rename to MathlibTest/Tactic/IntervalCases.lean diff --git a/MathlibTest/Linarith/Basic.lean b/MathlibTest/Tactic/Linarith/Basic.lean similarity index 100% rename from MathlibTest/Linarith/Basic.lean rename to MathlibTest/Tactic/Linarith/Basic.lean diff --git a/MathlibTest/Linarith/NNReal.lean b/MathlibTest/Tactic/Linarith/NNReal.lean similarity index 100% rename from MathlibTest/Linarith/NNReal.lean rename to MathlibTest/Tactic/Linarith/NNReal.lean diff --git a/MathlibTest/linear_combination.lean b/MathlibTest/Tactic/LinearCombination.lean similarity index 100% rename from MathlibTest/linear_combination.lean rename to MathlibTest/Tactic/LinearCombination.lean diff --git a/MathlibTest/linear_combination_prime.lean b/MathlibTest/Tactic/LinearCombinationPrime.lean similarity index 100% rename from MathlibTest/linear_combination_prime.lean rename to MathlibTest/Tactic/LinearCombinationPrime.lean diff --git a/MathlibTest/mod_cases.lean b/MathlibTest/Tactic/ModCases.lean similarity index 100% rename from MathlibTest/mod_cases.lean rename to MathlibTest/Tactic/ModCases.lean diff --git a/MathlibTest/Monotonicity.lean b/MathlibTest/Tactic/Monotonicity.lean similarity index 100% rename from MathlibTest/Monotonicity.lean rename to MathlibTest/Tactic/Monotonicity.lean diff --git a/MathlibTest/MoveAdd.lean b/MathlibTest/Tactic/MoveAdd.lean similarity index 100% rename from MathlibTest/MoveAdd.lean rename to MathlibTest/Tactic/MoveAdd.lean diff --git a/MathlibTest/NoncommRing.lean b/MathlibTest/Tactic/NoncommRing.lean similarity index 100% rename from MathlibTest/NoncommRing.lean rename to MathlibTest/Tactic/NoncommRing.lean diff --git a/MathlibTest/norm_num_abs.lean b/MathlibTest/Tactic/NormNum/Abs.lean similarity index 100% rename from MathlibTest/norm_num_abs.lean rename to MathlibTest/Tactic/NormNum/Abs.lean diff --git a/MathlibTest/norm_num.lean b/MathlibTest/Tactic/NormNum/Basic.lean similarity index 99% rename from MathlibTest/norm_num.lean rename to MathlibTest/Tactic/NormNum/Basic.lean index 9dcfce2cf50b70..e7ec5ae0f5bdc6 100644 --- a/MathlibTest/norm_num.lean +++ b/MathlibTest/Tactic/NormNum/Basic.lean @@ -333,7 +333,7 @@ end LinearOrderedRing section Rat -variable [Field α] [LinearOrder α] [IsStrictOrderedRing α] [Nontrivial α] +variable [Field α] [LinearOrder α] [IsStrictOrderedRing α] -- Normalize to True example : (1 : ℚ) ≤ 1 := by norm_num1 diff --git a/MathlibTest/norm_num_ext.lean b/MathlibTest/Tactic/NormNum/Ext.lean similarity index 100% rename from MathlibTest/norm_num_ext.lean rename to MathlibTest/Tactic/NormNum/Ext.lean diff --git a/MathlibTest/norm_num_flt.lean b/MathlibTest/Tactic/NormNum/FLT.lean similarity index 100% rename from MathlibTest/norm_num_flt.lean rename to MathlibTest/Tactic/NormNum/FLT.lean diff --git a/MathlibTest/norm_num_ordinal.lean b/MathlibTest/Tactic/NormNum/Ordinal.lean similarity index 100% rename from MathlibTest/norm_num_ordinal.lean rename to MathlibTest/Tactic/NormNum/Ordinal.lean diff --git a/MathlibTest/norm_num_rpow.lean b/MathlibTest/Tactic/NormNum/RPow.lean similarity index 100% rename from MathlibTest/norm_num_rpow.lean rename to MathlibTest/Tactic/NormNum/RPow.lean diff --git a/MathlibTest/observe.lean b/MathlibTest/Tactic/Observe.lean similarity index 100% rename from MathlibTest/observe.lean rename to MathlibTest/Tactic/Observe.lean diff --git a/MathlibTest/order.lean b/MathlibTest/Tactic/Order.lean similarity index 100% rename from MathlibTest/order.lean rename to MathlibTest/Tactic/Order.lean diff --git a/MathlibTest/pnat_to_nat.lean b/MathlibTest/Tactic/PNatToNat.lean similarity index 100% rename from MathlibTest/pnat_to_nat.lean rename to MathlibTest/Tactic/PNatToNat.lean diff --git a/MathlibTest/Tactic/Push.lean b/MathlibTest/Tactic/Push/Basic.lean similarity index 100% rename from MathlibTest/Tactic/Push.lean rename to MathlibTest/Tactic/Push/Basic.lean diff --git a/MathlibTest/push_neg.lean b/MathlibTest/Tactic/Push/PushNeg.lean similarity index 100% rename from MathlibTest/push_neg.lean rename to MathlibTest/Tactic/Push/PushNeg.lean diff --git a/MathlibTest/Tactic/Recall.lean b/MathlibTest/Tactic/Recall/Basic.lean similarity index 100% rename from MathlibTest/Tactic/Recall.lean rename to MathlibTest/Tactic/Recall/Basic.lean diff --git a/MathlibTest/RecallModule.lean b/MathlibTest/Tactic/Recall/Module.lean similarity index 100% rename from MathlibTest/RecallModule.lean rename to MathlibTest/Tactic/Recall/Module.lean diff --git a/MathlibTest/recover.lean b/MathlibTest/Tactic/Recover.lean similarity index 100% rename from MathlibTest/recover.lean rename to MathlibTest/Tactic/Recover.lean diff --git a/MathlibTest/reduce_mod_char.lean b/MathlibTest/Tactic/ReduceModChar.lean similarity index 100% rename from MathlibTest/reduce_mod_char.lean rename to MathlibTest/Tactic/ReduceModChar.lean diff --git a/MathlibTest/ring_compare.lean b/MathlibTest/Tactic/Ring/Compare.lean similarity index 100% rename from MathlibTest/ring_compare.lean rename to MathlibTest/Tactic/Ring/Compare.lean diff --git a/MathlibTest/Tactic/Ring.lean b/MathlibTest/Tactic/Ring/Ring.lean similarity index 100% rename from MathlibTest/Tactic/Ring.lean rename to MathlibTest/Tactic/Ring/Ring.lean diff --git a/MathlibTest/rewrites.lean b/MathlibTest/Tactic/RwQuestionMark.lean similarity index 100% rename from MathlibTest/rewrites.lean rename to MathlibTest/Tactic/RwQuestionMark.lean diff --git a/MathlibTest/Tactic/Says.lean b/MathlibTest/Tactic/Says/Basic.lean similarity index 100% rename from MathlibTest/Tactic/Says.lean rename to MathlibTest/Tactic/Says/Basic.lean diff --git a/MathlibTest/says_whitespace.lean b/MathlibTest/Tactic/Says/Whitespace.lean similarity index 100% rename from MathlibTest/says_whitespace.lean rename to MathlibTest/Tactic/Says/Whitespace.lean diff --git a/MathlibTest/simp_intro.lean b/MathlibTest/Tactic/SimpIntro.lean similarity index 100% rename from MathlibTest/simp_intro.lean rename to MathlibTest/Tactic/SimpIntro.lean diff --git a/MathlibTest/solve_by_elim/basic.lean b/MathlibTest/Tactic/SolveByElim/Basic.lean similarity index 99% rename from MathlibTest/solve_by_elim/basic.lean rename to MathlibTest/Tactic/SolveByElim/Basic.lean index cf6f9e117e5d50..5e4e98bfbcea59 100644 --- a/MathlibTest/solve_by_elim/basic.lean +++ b/MathlibTest/Tactic/SolveByElim/Basic.lean @@ -6,7 +6,7 @@ Authors: Kim Morrison import Lean.Meta.Tactic.SolveByElim import Mathlib.Tactic.Constructor import Batteries.Tactic.PermuteGoals -import MathlibTest.solve_by_elim.dummy_label_attr +import MathlibTest.Tactic.SolveByElim.DummyLabelAttr example (h : Nat) : Nat := by solve_by_elim diff --git a/MathlibTest/solve_by_elim/dummy_label_attr.lean b/MathlibTest/Tactic/SolveByElim/DummyLabelAttr.lean similarity index 100% rename from MathlibTest/solve_by_elim/dummy_label_attr.lean rename to MathlibTest/Tactic/SolveByElim/DummyLabelAttr.lean diff --git a/MathlibTest/solve_by_elim/instances.lean b/MathlibTest/Tactic/SolveByElim/Instances.lean similarity index 100% rename from MathlibTest/solve_by_elim/instances.lean rename to MathlibTest/Tactic/SolveByElim/Instances.lean diff --git a/MathlibTest/success_if_fail_with_msg.lean b/MathlibTest/Tactic/SuccessIfFailWithMsg.lean similarity index 100% rename from MathlibTest/success_if_fail_with_msg.lean rename to MathlibTest/Tactic/SuccessIfFailWithMsg.lean diff --git a/MathlibTest/SwapVar.lean b/MathlibTest/Tactic/SwapVar.lean similarity index 100% rename from MathlibTest/SwapVar.lean rename to MathlibTest/Tactic/SwapVar.lean diff --git a/MathlibTest/tactic_timeout.lean b/MathlibTest/TacticTimeout.lean similarity index 100% rename from MathlibTest/tactic_timeout.lean rename to MathlibTest/TacticTimeout.lean diff --git a/MathlibTest/CompileInductive.lean b/MathlibTest/Util/CompileInductive.lean similarity index 100% rename from MathlibTest/CompileInductive.lean rename to MathlibTest/Util/CompileInductive.lean diff --git a/MathlibTest/CountHeartbeats.lean b/MathlibTest/Util/CountHeartbeats.lean similarity index 100% rename from MathlibTest/CountHeartbeats.lean rename to MathlibTest/Util/CountHeartbeats.lean diff --git a/MathlibTest/notation3.lean b/MathlibTest/Util/Notation3.lean similarity index 100% rename from MathlibTest/notation3.lean rename to MathlibTest/Util/Notation3.lean diff --git a/MathlibTest/Variable.lean b/MathlibTest/Variable.lean index 3c921952a845aa..de4174b1179fc9 100644 --- a/MathlibTest/Variable.lean +++ b/MathlibTest/Variable.lean @@ -194,6 +194,8 @@ info: Try this: -/ #guard_msgs in variable? [VectorSpace k V] [Algebra k V] + +set_option linter.overlappingInstances false example : Field k := inferInstance example : AddCommGroup V := inferInstance example : Module k V := inferInstance diff --git a/MathlibTest/WhitespaceLinter.lean b/MathlibTest/WhitespaceLinter.lean index d80cbd5576ee0a..664907eedb41e0 100644 --- a/MathlibTest/WhitespaceLinter.lean +++ b/MathlibTest/WhitespaceLinter.lean @@ -315,6 +315,7 @@ omit [h : Add Nat] [Add Nat] -- Include statements are not linted. include h +set_option linter.overlappingInstances false in /-- warning: extra space in the source diff --git a/MathlibTest/CalcQuestionMark.lean b/MathlibTest/Widget/CalcQuestionMark.lean similarity index 100% rename from MathlibTest/CalcQuestionMark.lean rename to MathlibTest/Widget/CalcQuestionMark.lean diff --git a/MathlibTest/CommDiag.lean b/MathlibTest/Widget/CommDiag.lean similarity index 100% rename from MathlibTest/CommDiag.lean rename to MathlibTest/Widget/CommDiag.lean diff --git a/MathlibTest/conv_widget.lean b/MathlibTest/Widget/Conv.lean similarity index 100% rename from MathlibTest/conv_widget.lean rename to MathlibTest/Widget/Conv.lean diff --git a/MathlibTest/congr.lean b/MathlibTest/congr.lean index 6059cfc331d35a..37a8d68ede7332 100644 --- a/MathlibTest/congr.lean +++ b/MathlibTest/congr.lean @@ -326,10 +326,12 @@ example {α} [AddCommMonoid α] [PartialOrder α] {a b c d e f g : α} : Lawful BEq instances are "subsingletons". -/ +set_option linter.overlappingInstances false in example (inst1 : BEq α) [LawfulBEq α] (inst2 : BEq α) [LawfulBEq α] (xs : List α) (x : α) : @List.erase _ inst1 xs x = @List.erase _ inst2 xs x := by congr! +set_option linter.overlappingInstances false in /-- error: unsolved goals case h.e'_2 diff --git a/docs/1000.yaml b/docs/1000.yaml index 4c8a11315342bd..55f54757b9fe15 100644 --- a/docs/1000.yaml +++ b/docs/1000.yaml @@ -803,6 +803,9 @@ Q737892: Q739403: title: Stewart's theorem + decl: EuclideanGeometry.dist_sq_mul_dist_add_dist_sq_mul_dist + authors: Manuel Candales + date: 2021 Q740093: title: Peano existence theorem @@ -1013,6 +1016,9 @@ Q872088: Q877489: title: Apollonius's theorem + decl: EuclideanGeometry.dist_sq_add_dist_sq_eq_two_mul_dist_midpoint_sq_add_half_dist_sq + authors: Manuel Candales + date: 2021 Q890875: title: Bohr–van Leeuwen theorem diff --git a/docs/references.bib b/docs/references.bib index d989ba3a502458..bf9b2fbb1e98e4 100644 --- a/docs/references.bib +++ b/docs/references.bib @@ -1992,6 +1992,21 @@ @Article{ Fields1971 doi = {10.1090/S0002-9939-1971-0271100-6} } +@Article{ fjellbo-rognes-2022, + author = {Fjellbo, Vegard and Rognes, John}, + title = {Exponentials of non-singular simplicial sets}, + journal = {Homology Homotopy Appl.}, + fjournal = {Homology, Homotopy and Applications}, + volume = {24}, + year = {2022}, + number = {2}, + pages = {307--314}, + issn = {1532-0073,1532-0081}, + mrclass = {18D15 (18N50 55U10)}, + mrnumber = {4478133}, + doi = {10.4310/hha.2022.v24.n2.a15} +} + @InProceedings{ flypitch_cpp, doi = {10.1145/3372885.3373826}, url = {https://doi.org/10.1145/3372885.3373826}, @@ -5892,6 +5907,15 @@ @Misc{ welzl_garter url = {https://ti.inf.ethz.ch/ew/lehre/ApproxSDP09/notes/conelp.pdf} } +@Book{ widder1941, + author = {Widder, David Vernon}, + title = {The {L}aplace Transform}, + year = {1941}, + publisher = {Princeton University Press}, + series = {Princeton Mathematical Series}, + volume = {6} +} + @Book{ Wielandt-1964, title = {Finite Permutation Groups}, author = {Wielandt, Helmut}, diff --git a/lake-manifest.json b/lake-manifest.json index 397149ff920690..12d0a94002391e 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -5,7 +5,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "293af9b2a383eed4d04d66b898d608d0a44b750f", + "rev": "a456461b368b71d2accd95234832cd9c174b5437", "name": "plausible", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -25,7 +25,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "fd70b40073aeca8fa60fe0fb492f189d3b12c0ef", + "rev": "515cf9d0c00ece5e661f6de4326a53dedc1e8ea1", "name": "importGraph", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -35,37 +35,37 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "2db6054a44326f8c0230ee0570e2ddb894816511", + "rev": "a84b3e2475d5c5ab979567b1ad8aea21b764bcf8", "name": "proofwidgets", "manifestFile": "lake-manifest.json", - "inputRev": "v0.0.98", + "inputRev": "v0.0.99", "inherited": false, "configFile": "lakefile.lean"}, {"url": "https://github.com/leanprover-community/aesop", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "f0c6e183ea26531e82773feb4b73ab6595ca17a5", + "rev": "558915ae105bfd8074e22d597613d1961822adc2", "name": "aesop", "manifestFile": "lake-manifest.json", - "inputRev": "v4.30.0-rc2", + "inputRev": "v4.30.0", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover-community/quote4", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "1cc7e819b9b9bc1e87c9edcccb62e0269e00a809", + "rev": "a6e6c34c4ef182f83b219a3a5a385f51f44bdc4c", "name": "Qq", "manifestFile": "lake-manifest.json", - "inputRev": "v4.30.0-rc2", + "inputRev": "v4.30.0", "inherited": false, "configFile": "lakefile.toml"}, {"url": "https://github.com/leanprover-community/batteries", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "4ee56e687ce2b9b51b097bfa65947a499da0c453", + "rev": "32dc18cde3684679f3c003de608743b57498c56f", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -75,10 +75,10 @@ "type": "git", "subDir": null, "scope": "leanprover", - "rev": "13567aed1ac4f12aea9484178e07e51f8c9f7658", + "rev": "6b907cf12b2e445ccb7c24bc208ef04a1f39e84c", "name": "Cli", "manifestFile": "lake-manifest.json", - "inputRev": "v4.30.0-rc2", + "inputRev": "v4.30.0", "inherited": true, "configFile": "lakefile.toml"}], "name": "mathlib", diff --git a/lakefile.lean b/lakefile.lean index 418510db45368e..7f78c3e9a8482a 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -7,9 +7,9 @@ open Lake DSL -/ require "leanprover-community" / "batteries" @ git "main" -require "leanprover-community" / "Qq" @ git "v4.30.0-rc2" -require "leanprover-community" / "aesop" @ git "v4.30.0-rc2" -require "leanprover-community" / "proofwidgets" @ git "v0.0.98" +require "leanprover-community" / "Qq" @ git "v4.30.0" +require "leanprover-community" / "aesop" @ git "v4.30.0" +require "leanprover-community" / "proofwidgets" @ git "v0.0.99" with NameMap.empty.insert `errorOnBuild "ProofWidgets failed to reuse pre-built JS code. \ Please report this issue on the Lean Zulip." diff --git a/lean-toolchain b/lean-toolchain index 6c7e31fffe3e03..af9e5d339aeb37 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:v4.30.0-rc2 +leanprover/lean4:v4.30.0 diff --git a/scripts/nolints.json b/scripts/nolints.json index 1ee789ade4a2c2..552ee8a5d8bad0 100644 --- a/scripts/nolints.json +++ b/scripts/nolints.json @@ -4,10 +4,6 @@ ["defsWithUnderscore", "cfcₙHom_of_cfcHom"], ["defsWithUnderscore", "commandSuppress_compilation"], ["defsWithUnderscore", "decidableEq_of_subsingleton"], - ["defsWithUnderscore", "delabTotalSpace_mk"], - ["defsWithUnderscore", "delabTotalSpace_mk'"], - ["defsWithUnderscore", "delab_mfderiv"], - ["defsWithUnderscore", "delab_not_in"], ["defsWithUnderscore", "equiv_linearIndependent"], ["defsWithUnderscore", "exists_delab"], ["defsWithUnderscore", "finiteness_nonterminal"], @@ -144,7 +140,6 @@ ["defsWithUnderscore", "Finite.divisionRing_to_field"], ["defsWithUnderscore", "Finset.instGradeMinOrder_multiset"], ["defsWithUnderscore", "Finset.instGradeMinOrder_nat"], - ["defsWithUnderscore", "Finsupp.onFinset_support"], ["defsWithUnderscore", "FixedDetMatrices.reduce_rec"], ["defsWithUnderscore", "FractionRing.mulSemiringAction_of_isGaloisGroup"], ["defsWithUnderscore", "Function.fromTypes_cons_equiv"], @@ -187,7 +182,6 @@ ["defsWithUnderscore", "List.lex_chains"], ["defsWithUnderscore", "List.maximum_of_length_pos"], ["defsWithUnderscore", "List.minimum_of_length_pos"], - ["defsWithUnderscore", "Manifold.delab_mvfderiv"], ["defsWithUnderscore", "Matrix.cons_val"], ["defsWithUnderscore", "Matrix.equiv_GL_linearindependent"], ["defsWithUnderscore", "Matroid.aesop_mat"], @@ -414,45 +408,6 @@ ["defsWithUnderscore", "NumberField.InfinitePlace.embedding_of_isReal"], ["defsWithUnderscore", "NumberField.RingOfIntegers.restrict_addMonoidHom"], ["defsWithUnderscore", "NumberField.RingOfIntegers.restrict_monoidHom"], - ["defsWithUnderscore", "Parser.Attr.coassoc_simps"], - ["defsWithUnderscore", "Parser.Attr.coassoc_simps_proc"], - ["defsWithUnderscore", "Parser.Attr.enat_to_nat_coe"], - ["defsWithUnderscore", "Parser.Attr.enat_to_nat_coe_proc"], - ["defsWithUnderscore", "Parser.Attr.enat_to_nat_top"], - ["defsWithUnderscore", "Parser.Attr.enat_to_nat_top_proc"], - ["defsWithUnderscore", "Parser.Attr.fin_omega"], - ["defsWithUnderscore", "Parser.Attr.fin_omega_proc"], - ["defsWithUnderscore", "Parser.Attr.functor_norm"], - ["defsWithUnderscore", "Parser.Attr.functor_norm_proc"], - ["defsWithUnderscore", "Parser.Attr.ghost_simps"], - ["defsWithUnderscore", "Parser.Attr.ghost_simps_proc"], - ["defsWithUnderscore", "Parser.Attr.integral_simps"], - ["defsWithUnderscore", "Parser.Attr.integral_simps_proc"], - ["defsWithUnderscore", "Parser.Attr.is_poly"], - ["defsWithUnderscore", "Parser.Attr.mfld_simps"], - ["defsWithUnderscore", "Parser.Attr.mfld_simps_proc"], - ["defsWithUnderscore", "Parser.Attr.mon_tauto"], - ["defsWithUnderscore", "Parser.Attr.mon_tauto_proc"], - ["defsWithUnderscore", "Parser.Attr.monad_norm"], - ["defsWithUnderscore", "Parser.Attr.monad_norm_proc"], - ["defsWithUnderscore", "Parser.Attr.nontriviality_proc"], - ["defsWithUnderscore", "Parser.Attr.parity_simps"], - ["defsWithUnderscore", "Parser.Attr.parity_simps_proc"], - ["defsWithUnderscore", "Parser.Attr.pnat_to_nat_coe"], - ["defsWithUnderscore", "Parser.Attr.pnat_to_nat_coe_proc"], - ["defsWithUnderscore", "Parser.Attr.pull_end"], - ["defsWithUnderscore", "Parser.Attr.pull_end_proc"], - ["defsWithUnderscore", "Parser.Attr.push_end"], - ["defsWithUnderscore", "Parser.Attr.push_end_proc"], - ["defsWithUnderscore", "Parser.Attr.qify_simps"], - ["defsWithUnderscore", "Parser.Attr.qify_simps_proc"], - ["defsWithUnderscore", "Parser.Attr.rclike_simps"], - ["defsWithUnderscore", "Parser.Attr.rclike_simps_proc"], - ["defsWithUnderscore", "Parser.Attr.rify_simps"], - ["defsWithUnderscore", "Parser.Attr.rify_simps_proc"], - ["defsWithUnderscore", "Parser.Attr.typevec_proc"], - ["defsWithUnderscore", "Parser.Attr.zify_simps"], - ["defsWithUnderscore", "Parser.Attr.zify_simps_proc"], ["defsWithUnderscore", "Profinite.IndexFunctor.π_app"], ["defsWithUnderscore", "Profinite.NobelingProof.Linear_CC'"], ["defsWithUnderscore", "Profinite.NobelingProof.Linear_CC'₀"], @@ -463,7 +418,6 @@ ["defsWithUnderscore", "Set.Icc.convexComb_assoc_coeff₁'"], ["defsWithUnderscore", "Set.Icc.convexComb_assoc_coeff₂"], ["defsWithUnderscore", "Set.Icc.convexComb_assoc_coeff₂'"], - ["defsWithUnderscore", "Set.Notation.delab_set_image_subtype"], ["defsWithUnderscore", "Set.powersetCard.addActionHom_of_embedding"], ["defsWithUnderscore", "Set.powersetCard.addActionHom_singleton"], ["defsWithUnderscore", "Set.powersetCard.mulActionHom_compl"], diff --git a/scripts/nolints_prime_decls.txt b/scripts/nolints_prime_decls.txt index b51046ee800d8a..71a8f047125211 100644 --- a/scripts/nolints_prime_decls.txt +++ b/scripts/nolints_prime_decls.txt @@ -3228,7 +3228,6 @@ Num.of_to_nat' Num.succ_ofInt' odd_add_one_self' odd_add_self_one' -ofReal_norm_eq_enorm' OmegaCompletePartialOrder.ContinuousHom.forall_forall_merge' OmegaCompletePartialOrder.ScottContinuous.continuous' one_le_div'