number_theory.well_approximableMathlib.NumberTheory.WellApproximable

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -285,7 +285,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
     refine' funext fun n => propext <| iff_self_and.mpr fun hn => _
     -- `tauto` can finish from here but unfortunately it's very slow.
     simp only [(em (p ∣ n)).symm, (em (p * p ∣ n)).symm, or_and_left, or_true_iff, true_and_iff,
-      or_assoc']
+      or_assoc]
   have hE₂ : ∀ p : Nat.Primes, A p =ᵐ[μ] (∅ : Set 𝕊) ∧ B p =ᵐ[μ] (∅ : Set 𝕊) → E =ᵐ[μ] C p :=
     by
     rintro p ⟨hA, hB⟩
Diff
@@ -164,8 +164,8 @@ theorem smul_eq_of_mul_dvd (hn : 0 < n) (han : orderOf a ^ 2 ∣ n) :
     smul_ball'', smul_eq_mul, mem_set_of_eq]
   replace han : ∀ {b : A}, orderOf b = n → orderOf (a * b) = n
   · intro b hb
-    rw [← hb] at han hn 
-    rw [sq] at han 
+    rw [← hb] at han hn
+    rw [sq] at han
     rwa [(Commute.all a b).orderOf_mul_eq_right_of_forall_prime_mul_dvd (order_of_pos_iff.mp hn)
         fun p hp hp' => dvd_trans (mul_dvd_mul_right hp' <| orderOf a) han]
   let f : {b : A | orderOf b = n} → {b : A | orderOf b = n} := fun b => ⟨a * b, han b.property⟩
@@ -357,7 +357,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
       rw [hC]
     exact ae_empty_or_univ_of_forall_vadd_ae_eq_self hE₀ h hu
   · right
-    simp only [Classical.not_forall, not_and_or] at h 
+    simp only [Classical.not_forall, not_and_or] at h
     obtain ⟨p, hp⟩ := h
     rw [hE₁ p]
     cases hp
Diff
@@ -114,7 +114,8 @@ theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.Coprime m) :
   by
   rintro - ⟨a, ha, rfl⟩
   obtain ⟨b, hb, hab⟩ := mem_approx_order_of_iff.mp ha
-  replace hb : b ^ m ∈ {u : A | orderOf u = n}; · rw [← hb] at hmn ⊢; exact orderOf_pow_coprime hmn
+  replace hb : b ^ m ∈ {u : A | orderOf u = n};
+  · rw [← hb] at hmn ⊢; exact Nat.Coprime.orderOf_pow hmn
   apply ball_subset_thickening hb ((m : ℝ) • δ)
   convert pow_mem_ball hm hab using 1
   simp only [nsmul_eq_mul, Algebra.id.smul_eq_mul]
Diff
@@ -356,7 +356,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
       rw [hC]
     exact ae_empty_or_univ_of_forall_vadd_ae_eq_self hE₀ h hu
   · right
-    simp only [not_forall, not_and_or] at h 
+    simp only [Classical.not_forall, not_and_or] at h 
     obtain ⟨p, hp⟩ := h
     rw [hE₁ p]
     cases hp
Diff
@@ -3,8 +3,8 @@ Copyright (c) 2022 Oliver Nash. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Oliver Nash
 -/
-import Mathbin.Dynamics.Ergodic.AddCircle
-import Mathbin.MeasureTheory.Covering.LiminfLimsup
+import Dynamics.Ergodic.AddCircle
+import MeasureTheory.Covering.LiminfLimsup
 
 #align_import number_theory.well_approximable from "leanprover-community/mathlib"@"f2ad3645af9effcdb587637dc28a6074edc813f9"
 
Diff
@@ -109,7 +109,7 @@ variable {A : Type _} [SeminormedCommGroup A] {a : A} {m n : ℕ} (δ : ℝ)
 
 #print approxOrderOf.image_pow_subset_of_coprime /-
 @[to_additive]
-theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.coprime m) :
+theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.Coprime m) :
     (fun y => y ^ m) '' approxOrderOf A n δ ⊆ approxOrderOf A n (m * δ) :=
   by
   rintro - ⟨a, ha, rfl⟩
@@ -140,7 +140,7 @@ theorem image_pow_subset (n : ℕ) (hm : 0 < m) :
 
 #print approxOrderOf.smul_subset_of_coprime /-
 @[to_additive]
-theorem smul_subset_of_coprime (han : (orderOf a).coprime n) :
+theorem smul_subset_of_coprime (han : (orderOf a).Coprime n) :
     a • approxOrderOf A n δ ⊆ approxOrderOf A (orderOf a * n) δ :=
   by
   simp_rw [approxOrderOf, thickening_eq_bUnion_ball, ← image_smul, image_Union₂, image_smul,
@@ -320,7 +320,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
           (nat.cast_pos.mpr hp.pos) _ hδ
     refine' (sSupHom.setImage f).apply_blimsup_le.trans (mono_blimsup _)
     rintro n ⟨hn, h_div, h_ndiv⟩
-    have h_cop : (addOrderOf x).coprime (n / p) :=
+    have h_cop : (addOrderOf x).Coprime (n / p) :=
       by
       obtain ⟨q, rfl⟩ := h_div
       rw [hu₀, Subtype.coe_mk, hp.coprime_iff_not_dvd, q.mul_div_cancel_left hp.pos]
Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2022 Oliver Nash. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Oliver Nash
-
-! This file was ported from Lean 3 source module number_theory.well_approximable
-! leanprover-community/mathlib commit f2ad3645af9effcdb587637dc28a6074edc813f9
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Dynamics.Ergodic.AddCircle
 import Mathbin.MeasureTheory.Covering.LiminfLimsup
 
+#align_import number_theory.well_approximable from "leanprover-community/mathlib"@"f2ad3645af9effcdb587637dc28a6074edc813f9"
+
 /-!
 # Well-approximable numbers and Gallagher's ergodic theorem
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Oliver Nash
 
 ! This file was ported from Lean 3 source module number_theory.well_approximable
-! leanprover-community/mathlib commit f0c8bf9245297a541f468be517f1bde6195105e9
+! leanprover-community/mathlib commit f2ad3645af9effcdb587637dc28a6074edc813f9
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -14,6 +14,9 @@ import Mathbin.MeasureTheory.Covering.LiminfLimsup
 /-!
 # Well-approximable numbers and Gallagher's ergodic theorem
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 Gallagher's ergodic theorem is a result in metric number theory. It thus belongs to that branch of
 mathematics concerning arithmetic properties of real numbers which hold almost eveywhere with
 respect to the Lebesgue measure.
Diff
@@ -61,6 +61,7 @@ open Set Filter Function Metric MeasureTheory
 
 open scoped MeasureTheory Topology Pointwise
 
+#print approxOrderOf /-
 /-- In a seminormed group `A`, given `n : ℕ` and `δ : ℝ`, `approx_order_of A n δ` is the set of
 elements within a distance `δ` of a point of order `n`. -/
 @[to_additive approxAddOrderOf
@@ -69,14 +70,18 @@ def approxOrderOf (A : Type _) [SeminormedGroup A] (n : ℕ) (δ : ℝ) : Set A
   thickening δ {y | orderOf y = n}
 #align approx_order_of approxOrderOf
 #align approx_add_order_of approxAddOrderOf
+-/
 
+#print mem_approxOrderOf_iff /-
 @[to_additive mem_approx_add_orderOf_iff]
 theorem mem_approxOrderOf_iff {A : Type _} [SeminormedGroup A] {n : ℕ} {δ : ℝ} {a : A} :
     a ∈ approxOrderOf A n δ ↔ ∃ b : A, orderOf b = n ∧ a ∈ ball b δ := by
   simp only [approxOrderOf, thickening_eq_bUnion_ball, mem_Union₂, mem_set_of_eq, exists_prop]
 #align mem_approx_order_of_iff mem_approxOrderOf_iff
 #align mem_approx_add_order_of_iff mem_approx_add_orderOf_iff
+-/
 
+#print wellApproximable /-
 /-- In a seminormed group `A`, given a sequence of distances `δ₁, δ₂, ...`, `well_approximable A δ`
 is the limsup as `n → ∞` of the sets `approx_order_of A n δₙ`. Thus, it is the set of points that
 lie in infinitely many of the sets `approx_order_of A n δₙ`. -/
@@ -86,7 +91,9 @@ def wellApproximable (A : Type _) [SeminormedGroup A] (δ : ℕ → ℝ) : Set A
   blimsup (fun n => approxOrderOf A n (δ n)) atTop fun n => 0 < n
 #align well_approximable wellApproximable
 #align add_well_approximable addWellApproximable
+-/
 
+#print mem_wellApproximable_iff /-
 @[to_additive mem_add_wellApproximable_iff]
 theorem mem_wellApproximable_iff {A : Type _} [SeminormedGroup A] {δ : ℕ → ℝ} {a : A} :
     a ∈ wellApproximable A δ ↔
@@ -94,11 +101,13 @@ theorem mem_wellApproximable_iff {A : Type _} [SeminormedGroup A] {δ : ℕ →
   Iff.rfl
 #align mem_well_approximable_iff mem_wellApproximable_iff
 #align mem_add_well_approximable_iff mem_add_wellApproximable_iff
+-/
 
 namespace approxOrderOf
 
 variable {A : Type _} [SeminormedCommGroup A] {a : A} {m n : ℕ} (δ : ℝ)
 
+#print approxOrderOf.image_pow_subset_of_coprime /-
 @[to_additive]
 theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.coprime m) :
     (fun y => y ^ m) '' approxOrderOf A n δ ⊆ approxOrderOf A n (m * δ) :=
@@ -111,7 +120,9 @@ theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.coprime m) :
   simp only [nsmul_eq_mul, Algebra.id.smul_eq_mul]
 #align approx_order_of.image_pow_subset_of_coprime approxOrderOf.image_pow_subset_of_coprime
 #align approx_add_order_of.image_nsmul_subset_of_coprime approxAddOrderOf.image_nsmul_subset_of_coprime
+-/
 
+#print approxOrderOf.image_pow_subset /-
 @[to_additive]
 theorem image_pow_subset (n : ℕ) (hm : 0 < m) :
     (fun y => y ^ m) '' approxOrderOf A (n * m) δ ⊆ approxOrderOf A n (m * δ) :=
@@ -125,7 +136,9 @@ theorem image_pow_subset (n : ℕ) (hm : 0 < m) :
   simp only [nsmul_eq_mul]
 #align approx_order_of.image_pow_subset approxOrderOf.image_pow_subset
 #align approx_add_order_of.image_nsmul_subset approxAddOrderOf.image_nsmul_subset
+-/
 
+#print approxOrderOf.smul_subset_of_coprime /-
 @[to_additive]
 theorem smul_subset_of_coprime (han : (orderOf a).coprime n) :
     a • approxOrderOf A n δ ⊆ approxOrderOf A (orderOf a * n) δ :=
@@ -139,7 +152,9 @@ theorem smul_subset_of_coprime (han : (orderOf a).coprime n) :
   exact (Commute.all a b).orderOf_mul_eq_mul_orderOf_of_coprime han
 #align approx_order_of.smul_subset_of_coprime approxOrderOf.smul_subset_of_coprime
 #align approx_add_order_of.vadd_subset_of_coprime approxAddOrderOf.vadd_subset_of_coprime
+-/
 
+#print approxOrderOf.smul_eq_of_mul_dvd /-
 @[to_additive vadd_eq_of_mul_dvd]
 theorem smul_eq_of_mul_dvd (hn : 0 < n) (han : orderOf a ^ 2 ∣ n) :
     a • approxOrderOf A n δ = approxOrderOf A n δ :=
@@ -164,11 +179,13 @@ theorem smul_eq_of_mul_dvd (hn : 0 < n) (han : orderOf a ^ 2 ∣ n) :
     hf.Union_comp fun b => ball (b : A) δ
 #align approx_order_of.smul_eq_of_mul_dvd approxOrderOf.smul_eq_of_mul_dvd
 #align approx_add_order_of.vadd_eq_of_mul_dvd approxAddOrderOf.vadd_eq_of_mul_dvd
+-/
 
 end approxOrderOf
 
 namespace UnitAddCircle
 
+#print UnitAddCircle.mem_approxAddOrderOf_iff /-
 theorem mem_approxAddOrderOf_iff {δ : ℝ} {x : UnitAddCircle} {n : ℕ} (hn : 0 < n) :
     x ∈ approxAddOrderOf UnitAddCircle n δ ↔ ∃ m < n, gcd m n = 1 ∧ ‖x - ↑((m : ℝ) / n)‖ < δ :=
   by
@@ -179,7 +196,9 @@ theorem mem_approxAddOrderOf_iff {δ : ℝ} {x : UnitAddCircle} {n : ℕ} (hn :
   · rintro ⟨y, ⟨m, hm₁, hm₂, rfl⟩, hx⟩; exact ⟨m, hm₁, hm₂, hx⟩
   · rintro ⟨m, hm₁, hm₂, hx⟩; exact ⟨↑((m : ℝ) / n), ⟨m, hm₁, hm₂, rfl⟩, hx⟩
 #align unit_add_circle.mem_approx_add_order_of_iff UnitAddCircle.mem_approxAddOrderOf_iff
+-/
 
+#print UnitAddCircle.mem_addWellApproximable_iff /-
 theorem mem_addWellApproximable_iff (δ : ℕ → ℝ) (x : UnitAddCircle) :
     x ∈ addWellApproximable UnitAddCircle δ ↔
       {n : ℕ | ∃ m < n, gcd m n = 1 ∧ ‖x - ↑((m : ℝ) / n)‖ < δ n}.Infinite :=
@@ -191,6 +210,7 @@ theorem mem_addWellApproximable_iff (δ : ℕ → ℝ) (x : UnitAddCircle) :
   · have h : 0 < n := by obtain ⟨m, hm₁, hm₂, hm₃⟩ := hn; exact pos_of_gt hm₁
     exact ⟨h, (mem_approx_add_orderOf_iff h).mpr hn⟩
 #align unit_add_circle.mem_add_well_approximable_iff UnitAddCircle.mem_addWellApproximable_iff
+-/
 
 end UnitAddCircle
 
@@ -204,6 +224,7 @@ local notation a "∣∣" b => a ∣ b ∧ (a * a)∤b
 
 local notation "𝕊" => AddCircle T
 
+#print AddCircle.addWellApproximable_ae_empty_or_univ /-
 /-- *Gallagher's ergodic theorem* on Diophantine approximation. -/
 theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto δ atTop (𝓝 0)) :
     (∀ᵐ x, ¬addWellApproximable 𝕊 δ x) ∨ ∀ᵐ x, addWellApproximable 𝕊 δ x :=
@@ -344,6 +365,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
     · cases hB p; · contradiction
       simp only [h, union_ae_eq_univ_of_ae_eq_univ_left, union_ae_eq_univ_of_ae_eq_univ_right]
 #align add_circle.add_well_approximable_ae_empty_or_univ AddCircle.addWellApproximable_ae_empty_or_univ
+-/
 
 end AddCircle
 
Diff
@@ -198,15 +198,10 @@ namespace AddCircle
 
 variable {T : ℝ} [hT : Fact (0 < T)]
 
-include hT
-
--- mathport name: «expr ∤ »
 local notation a "∤" b => ¬a ∣ b
 
--- mathport name: «expr ∣∣ »
 local notation a "∣∣" b => a ∣ b ∧ (a * a)∤b
 
--- mathport name: expr𝕊
 local notation "𝕊" => AddCircle T
 
 /-- *Gallagher's ergodic theorem* on Diophantine approximation. -/
Diff
@@ -66,7 +66,7 @@ elements within a distance `δ` of a point of order `n`. -/
 @[to_additive approxAddOrderOf
       "In a seminormed additive group `A`, given `n : ℕ` and `δ : ℝ`,\n`approx_add_order_of A n δ` is the set of elements within a distance `δ` of a point of order `n`."]
 def approxOrderOf (A : Type _) [SeminormedGroup A] (n : ℕ) (δ : ℝ) : Set A :=
-  thickening δ { y | orderOf y = n }
+  thickening δ {y | orderOf y = n}
 #align approx_order_of approxOrderOf
 #align approx_add_order_of approxAddOrderOf
 
@@ -105,8 +105,7 @@ theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.coprime m) :
   by
   rintro - ⟨a, ha, rfl⟩
   obtain ⟨b, hb, hab⟩ := mem_approx_order_of_iff.mp ha
-  replace hb : b ^ m ∈ { u : A | orderOf u = n };
-  · rw [← hb] at hmn ⊢; exact orderOf_pow_coprime hmn
+  replace hb : b ^ m ∈ {u : A | orderOf u = n}; · rw [← hb] at hmn ⊢; exact orderOf_pow_coprime hmn
   apply ball_subset_thickening hb ((m : ℝ) • δ)
   convert pow_mem_ball hm hab using 1
   simp only [nsmul_eq_mul, Algebra.id.smul_eq_mul]
@@ -119,7 +118,7 @@ theorem image_pow_subset (n : ℕ) (hm : 0 < m) :
   by
   rintro - ⟨a, ha, rfl⟩
   obtain ⟨b, hb : orderOf b = n * m, hab : a ∈ ball b δ⟩ := mem_approx_order_of_iff.mp ha
-  replace hb : b ^ m ∈ { y : A | orderOf y = n }
+  replace hb : b ^ m ∈ {y : A | orderOf y = n}
   · rw [mem_set_of_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
@@ -153,7 +152,7 @@ theorem smul_eq_of_mul_dvd (hn : 0 < n) (han : orderOf a ^ 2 ∣ n) :
     rw [sq] at han 
     rwa [(Commute.all a b).orderOf_mul_eq_right_of_forall_prime_mul_dvd (order_of_pos_iff.mp hn)
         fun p hp hp' => dvd_trans (mul_dvd_mul_right hp' <| orderOf a) han]
-  let f : { b : A | orderOf b = n } → { b : A | orderOf b = n } := fun b => ⟨a * b, han b.property⟩
+  let f : {b : A | orderOf b = n} → {b : A | orderOf b = n} := fun b => ⟨a * b, han b.property⟩
   have hf : surjective f := by
     rintro ⟨b, hb⟩
     refine' ⟨⟨a⁻¹ * b, _⟩, _⟩
@@ -183,7 +182,7 @@ theorem mem_approxAddOrderOf_iff {δ : ℝ} {x : UnitAddCircle} {n : ℕ} (hn :
 
 theorem mem_addWellApproximable_iff (δ : ℕ → ℝ) (x : UnitAddCircle) :
     x ∈ addWellApproximable UnitAddCircle δ ↔
-      { n : ℕ | ∃ m < n, gcd m n = 1 ∧ ‖x - ↑((m : ℝ) / n)‖ < δ n }.Infinite :=
+      {n : ℕ | ∃ m < n, gcd m n = 1 ∧ ‖x - ↑((m : ℝ) / n)‖ < δ n}.Infinite :=
   by
   simp only [mem_add_wellApproximable_iff, ← Nat.cofinite_eq_atTop, cofinite.blimsup_set_eq,
     mem_set_of_eq]
@@ -285,7 +284,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
       apply (ergodic_nsmul hp.one_lt).ae_empty_or_univ_of_image_ae_le (hA₀ p)
       apply (HasSubset.Subset.eventuallyLE this).congr eventually_eq.rfl
       exact
-        blimsup_thickening_mul_ae_eq μ (fun n => 0 < n ∧ p∤n) (fun n => { y | addOrderOf y = n })
+        blimsup_thickening_mul_ae_eq μ (fun n => 0 < n ∧ p∤n) (fun n => {y | addOrderOf y = n})
           (nat.cast_pos.mpr hp.pos) _ hδ
     refine' (sSupHom.setImage f).apply_blimsup_le.trans (mono_blimsup fun n hn => _)
     replace hn := nat.coprime_comm.mp (hp.coprime_iff_not_dvd.2 hn.2)
@@ -301,7 +300,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
       apply (ergodic_nsmul_add x hp.one_lt).ae_empty_or_univ_of_image_ae_le (hB₀ p)
       apply (HasSubset.Subset.eventuallyLE this).congr eventually_eq.rfl
       exact
-        blimsup_thickening_mul_ae_eq μ (fun n => 0 < n ∧ p∣∣n) (fun n => { y | addOrderOf y = n })
+        blimsup_thickening_mul_ae_eq μ (fun n => 0 < n ∧ p∣∣n) (fun n => {y | addOrderOf y = n})
           (nat.cast_pos.mpr hp.pos) _ hδ
     refine' (sSupHom.setImage f).apply_blimsup_le.trans (mono_blimsup _)
     rintro n ⟨hn, h_div, h_ndiv⟩
Diff
@@ -105,7 +105,8 @@ theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.coprime m) :
   by
   rintro - ⟨a, ha, rfl⟩
   obtain ⟨b, hb, hab⟩ := mem_approx_order_of_iff.mp ha
-  replace hb : b ^ m ∈ { u : A | orderOf u = n }; · rw [← hb] at hmn⊢; exact orderOf_pow_coprime hmn
+  replace hb : b ^ m ∈ { u : A | orderOf u = n };
+  · rw [← hb] at hmn ⊢; exact orderOf_pow_coprime hmn
   apply ball_subset_thickening hb ((m : ℝ) • δ)
   convert pow_mem_ball hm hab using 1
   simp only [nsmul_eq_mul, Algebra.id.smul_eq_mul]
@@ -135,7 +136,7 @@ theorem smul_subset_of_coprime (han : (orderOf a).coprime n) :
   refine' Union₂_subset_iff.mpr fun b hb c hc => _
   simp only [mem_Union, exists_prop]
   refine' ⟨a * b, _, hc⟩
-  rw [← hb] at han⊢
+  rw [← hb] at han ⊢
   exact (Commute.all a b).orderOf_mul_eq_mul_orderOf_of_coprime han
 #align approx_order_of.smul_subset_of_coprime approxOrderOf.smul_subset_of_coprime
 #align approx_add_order_of.vadd_subset_of_coprime approxAddOrderOf.vadd_subset_of_coprime
@@ -148,8 +149,8 @@ theorem smul_eq_of_mul_dvd (hn : 0 < n) (han : orderOf a ^ 2 ∣ n) :
     smul_ball'', smul_eq_mul, mem_set_of_eq]
   replace han : ∀ {b : A}, orderOf b = n → orderOf (a * b) = n
   · intro b hb
-    rw [← hb] at han hn
-    rw [sq] at han
+    rw [← hb] at han hn 
+    rw [sq] at han 
     rwa [(Commute.all a b).orderOf_mul_eq_right_of_forall_prime_mul_dvd (order_of_pos_iff.mp hn)
         fun p hp hp' => dvd_trans (mul_dvd_mul_right hp' <| orderOf a) han]
   let f : { b : A | orderOf b = n } → { b : A | orderOf b = n } := fun b => ⟨a * b, han b.property⟩
@@ -315,7 +316,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
     rw [le_eq_subset, sSupHom.setImage_to_fun, hf, image_comp]
     have := @monotone_image 𝕊 𝕊 fun y => x + y
     specialize this (approxAddOrderOf.image_nsmul_subset (δ n) (n / p) hp.pos)
-    simp only [h_div] at this⊢
+    simp only [h_div] at this ⊢
     refine' this.trans _
     convert approxAddOrderOf.vadd_subset_of_coprime (p * δ n) h_cop
     simp only [hu₀, Subtype.coe_mk, h_div, mul_comm p]
@@ -340,7 +341,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
       rw [hC]
     exact ae_empty_or_univ_of_forall_vadd_ae_eq_self hE₀ h hu
   · right
-    simp only [not_forall, not_and_or] at h
+    simp only [not_forall, not_and_or] at h 
     obtain ⟨p, hp⟩ := h
     rw [hE₁ p]
     cases hp
Diff
@@ -59,7 +59,7 @@ An elementary (non-measure-theoretic) argument shows that if `¬ hδ` holds then
 
 open Set Filter Function Metric MeasureTheory
 
-open MeasureTheory Topology Pointwise
+open scoped MeasureTheory Topology Pointwise
 
 /-- In a seminormed group `A`, given `n : ℕ` and `δ : ℝ`, `approx_order_of A n δ` is the set of
 elements within a distance `δ` of a point of order `n`. -/
Diff
@@ -105,9 +105,7 @@ theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.coprime m) :
   by
   rintro - ⟨a, ha, rfl⟩
   obtain ⟨b, hb, hab⟩ := mem_approx_order_of_iff.mp ha
-  replace hb : b ^ m ∈ { u : A | orderOf u = n };
-  · rw [← hb] at hmn⊢
-    exact orderOf_pow_coprime hmn
+  replace hb : b ^ m ∈ { u : A | orderOf u = n }; · rw [← hb] at hmn⊢; exact orderOf_pow_coprime hmn
   apply ball_subset_thickening hb ((m : ℝ) • δ)
   convert pow_mem_ball hm hab using 1
   simp only [nsmul_eq_mul, Algebra.id.smul_eq_mul]
@@ -178,10 +176,8 @@ theorem mem_approxAddOrderOf_iff {δ : ℝ} {x : UnitAddCircle} {n : ℕ} (hn :
   simp only [mem_approx_add_orderOf_iff, mem_set_of_eq, ball, exists_prop, dist_eq_norm,
     AddCircle.addOrderOf_eq_pos_iff hn, mul_one]
   constructor
-  · rintro ⟨y, ⟨m, hm₁, hm₂, rfl⟩, hx⟩
-    exact ⟨m, hm₁, hm₂, hx⟩
-  · rintro ⟨m, hm₁, hm₂, hx⟩
-    exact ⟨↑((m : ℝ) / n), ⟨m, hm₁, hm₂, rfl⟩, hx⟩
+  · rintro ⟨y, ⟨m, hm₁, hm₂, rfl⟩, hx⟩; exact ⟨m, hm₁, hm₂, hx⟩
+  · rintro ⟨m, hm₁, hm₂, hx⟩; exact ⟨↑((m : ℝ) / n), ⟨m, hm₁, hm₂, rfl⟩, hx⟩
 #align unit_add_circle.mem_approx_add_order_of_iff UnitAddCircle.mem_approxAddOrderOf_iff
 
 theorem mem_addWellApproximable_iff (δ : ℕ → ℝ) (x : UnitAddCircle) :
@@ -192,9 +188,7 @@ theorem mem_addWellApproximable_iff (δ : ℕ → ℝ) (x : UnitAddCircle) :
     mem_set_of_eq]
   refine' iff_of_eq (congr_arg Set.Infinite <| ext fun n => ⟨fun hn => _, fun hn => _⟩)
   · exact (mem_approx_add_orderOf_iff hn.1).mp hn.2
-  · have h : 0 < n := by
-      obtain ⟨m, hm₁, hm₂, hm₃⟩ := hn
-      exact pos_of_gt hm₁
+  · have h : 0 < n := by obtain ⟨m, hm₁, hm₂, hm₃⟩ := hn; exact pos_of_gt hm₁
     exact ⟨h, (mem_approx_add_orderOf_iff h).mpr hn⟩
 #align unit_add_circle.mem_add_well_approximable_iff UnitAddCircle.mem_addWellApproximable_iff
 
@@ -244,9 +238,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
   letI : SemilatticeSup Nat.Primes := Nat.Subtype.semilatticeSup _
   set μ : Measure 𝕊 := volume
   set u : Nat.Primes → 𝕊 := fun p => ↑((↑(1 : ℕ) : ℝ) / p * T)
-  have hu₀ : ∀ p : Nat.Primes, addOrderOf (u p) = (p : ℕ) :=
-    by
-    rintro ⟨p, hp⟩
+  have hu₀ : ∀ p : Nat.Primes, addOrderOf (u p) = (p : ℕ) := by rintro ⟨p, hp⟩;
     exact add_order_of_div_of_gcd_eq_one hp.pos (gcd_one_left p)
   have hu : tendsto (addOrderOf ∘ u) at_top at_top :=
     by
@@ -318,10 +310,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
       rw [hu₀, Subtype.coe_mk, hp.coprime_iff_not_dvd, q.mul_div_cancel_left hp.pos]
       exact fun contra => h_ndiv (mul_dvd_mul_left p contra)
     replace h_div : n / p * p = n := Nat.div_mul_cancel h_div
-    have hf : f = (fun y => x + y) ∘ fun y => p • y :=
-      by
-      ext
-      simp [add_comm x]
+    have hf : f = (fun y => x + y) ∘ fun y => p • y := by ext; simp [add_comm x]
     simp_rw [comp_app]
     rw [le_eq_subset, sSupHom.setImage_to_fun, hf, image_comp]
     have := @monotone_image 𝕊 𝕊 fun y => x + y
@@ -355,11 +344,9 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
     obtain ⟨p, hp⟩ := h
     rw [hE₁ p]
     cases hp
-    · cases hA p
-      · contradiction
+    · cases hA p; · contradiction
       simp only [h, union_ae_eq_univ_of_ae_eq_univ_left]
-    · cases hB p
-      · contradiction
+    · cases hB p; · contradiction
       simp only [h, union_ae_eq_univ_of_ae_eq_univ_left, union_ae_eq_univ_of_ae_eq_univ_right]
 #align add_circle.add_well_approximable_ae_empty_or_univ AddCircle.addWellApproximable_ae_empty_or_univ
 
Diff
@@ -294,7 +294,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
       exact
         blimsup_thickening_mul_ae_eq μ (fun n => 0 < n ∧ p∤n) (fun n => { y | addOrderOf y = n })
           (nat.cast_pos.mpr hp.pos) _ hδ
-    refine' (SupₛHom.setImage f).apply_blimsup_le.trans (mono_blimsup fun n hn => _)
+    refine' (sSupHom.setImage f).apply_blimsup_le.trans (mono_blimsup fun n hn => _)
     replace hn := nat.coprime_comm.mp (hp.coprime_iff_not_dvd.2 hn.2)
     exact approxAddOrderOf.image_nsmul_subset_of_coprime (δ n) hp.pos hn
   have hB : ∀ p : Nat.Primes, B p =ᵐ[μ] (∅ : Set 𝕊) ∨ B p =ᵐ[μ] univ :=
@@ -310,7 +310,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
       exact
         blimsup_thickening_mul_ae_eq μ (fun n => 0 < n ∧ p∣∣n) (fun n => { y | addOrderOf y = n })
           (nat.cast_pos.mpr hp.pos) _ hδ
-    refine' (SupₛHom.setImage f).apply_blimsup_le.trans (mono_blimsup _)
+    refine' (sSupHom.setImage f).apply_blimsup_le.trans (mono_blimsup _)
     rintro n ⟨hn, h_div, h_ndiv⟩
     have h_cop : (addOrderOf x).coprime (n / p) :=
       by
@@ -323,7 +323,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
       ext
       simp [add_comm x]
     simp_rw [comp_app]
-    rw [le_eq_subset, SupₛHom.setImage_to_fun, hf, image_comp]
+    rw [le_eq_subset, sSupHom.setImage_to_fun, hf, image_comp]
     have := @monotone_image 𝕊 𝕊 fun y => x + y
     specialize this (approxAddOrderOf.image_nsmul_subset (δ n) (n / p) hp.pos)
     simp only [h_div] at this⊢
Diff
@@ -4,13 +4,12 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Oliver Nash
 
 ! This file was ported from Lean 3 source module number_theory.well_approximable
-! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982
+! leanprover-community/mathlib commit f0c8bf9245297a541f468be517f1bde6195105e9
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
 import Mathbin.Dynamics.Ergodic.AddCircle
 import Mathbin.MeasureTheory.Covering.LiminfLimsup
-import Mathbin.Data.Nat.Totient
 
 /-!
 # Well-approximable numbers and Gallagher's ergodic theorem
Diff
@@ -291,7 +291,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
       f '' A p ⊆ blimsup (fun n => approxAddOrderOf 𝕊 n (p * δ n)) at_top fun n => 0 < n ∧ p∤n
       by
       apply (ergodic_nsmul hp.one_lt).ae_empty_or_univ_of_image_ae_le (hA₀ p)
-      apply (HasSubset.Subset.eventuallyLe this).congr eventually_eq.rfl
+      apply (HasSubset.Subset.eventuallyLE this).congr eventually_eq.rfl
       exact
         blimsup_thickening_mul_ae_eq μ (fun n => 0 < n ∧ p∤n) (fun n => { y | addOrderOf y = n })
           (nat.cast_pos.mpr hp.pos) _ hδ
@@ -307,7 +307,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
       f '' B p ⊆ blimsup (fun n => approxAddOrderOf 𝕊 n (p * δ n)) at_top fun n => 0 < n ∧ p∣∣n
       by
       apply (ergodic_nsmul_add x hp.one_lt).ae_empty_or_univ_of_image_ae_le (hB₀ p)
-      apply (HasSubset.Subset.eventuallyLe this).congr eventually_eq.rfl
+      apply (HasSubset.Subset.eventuallyLE this).congr eventually_eq.rfl
       exact
         blimsup_thickening_mul_ae_eq μ (fun n => 0 < n ∧ p∣∣n) (fun n => { y | addOrderOf y = n })
           (nat.cast_pos.mpr hp.pos) _ hδ

Changes in mathlib4

mathlib3
mathlib4
feat(NumberTheory/ModularForms): Asymptotics of Jacobi theta functions (#12020)

This is a (rather boring) technical step in developing the theory of Hurwitz zeta functions: one needs to show that certain sums related to Jacobi theta series decay exponentially for large t.

Diff
@@ -173,7 +173,6 @@ namespace UnitAddCircle
 
 theorem mem_approxAddOrderOf_iff {δ : ℝ} {x : UnitAddCircle} {n : ℕ} (hn : 0 < n) :
     x ∈ approxAddOrderOf UnitAddCircle n δ ↔ ∃ m < n, gcd m n = 1 ∧ ‖x - ↑((m : ℝ) / n)‖ < δ := by
-  haveI := Real.fact_zero_lt_one
   simp only [mem_approx_add_orderOf_iff, mem_setOf_eq, ball, exists_prop, dist_eq_norm,
     AddCircle.addOrderOf_eq_pos_iff hn, mul_one]
   constructor
chore: Rename mul-div cancellation lemmas (#11530)

Lemma names around cancellation of multiplication and division are a mess.

This PR renames a handful of them according to the following table (each big row contains the multiplicative statement, then the three rows contain the GroupWithZero lemma name, the Group lemma, the AddGroup lemma name).

| Statement | New name | Old name | |

Diff
@@ -377,7 +377,7 @@ lemma exists_norm_nsmul_le (ξ : 𝕊) {n : ℕ} (hn : 0 < n) :
     ∃ j ∈ Icc 1 n, ‖j • ξ‖ ≤ T / ↑(n + 1) := by
   apply NormedAddCommGroup.exists_norm_nsmul_le (μ := volume) ξ hn
   rw [AddCircle.measure_univ, volume_closedBall, ← ENNReal.ofReal_nsmul,
-    mul_div_cancel' _ two_ne_zero, min_eq_right (div_le_self hT.out.le <| by simp), nsmul_eq_mul,
-    mul_div_cancel' _ (Nat.cast_ne_zero.mpr n.succ_ne_zero)]
+    mul_div_cancel₀ _ two_ne_zero, min_eq_right (div_le_self hT.out.le <| by simp), nsmul_eq_mul,
+    mul_div_cancel₀ _ (Nat.cast_ne_zero.mpr n.succ_ne_zero)]
 
 end AddCircle
chore: move Mathlib to v4.7.0-rc1 (#11162)

This is a very large PR, but it has been reviewed piecemeal already in PRs to the bump/v4.7.0 branch as we update to intermediate nightlies.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Kyle Miller <kmill31415@gmail.com> Co-authored-by: damiano <adomani@gmail.com>

Diff
@@ -161,7 +161,7 @@ theorem smul_eq_of_mul_dvd (hn : 0 < n) (han : orderOf a ^ 2 ∣ n) :
     · rw [mem_setOf_eq, ← orderOf_inv, mul_inv_rev, inv_inv, mul_comm]
       apply han
       simpa
-    · simp only [Subtype.mk_eq_mk, Subtype.coe_mk, mul_inv_cancel_left]
+    · simp only [f, Subtype.mk_eq_mk, Subtype.coe_mk, mul_inv_cancel_left]
   simpa only [mem_setOf_eq, Subtype.coe_mk, iUnion_coe_set] using
     hf.iUnion_comp fun b => ball (b : A) δ
 #align approx_order_of.smul_eq_of_mul_dvd approxOrderOf.smul_eq_of_mul_dvd
@@ -255,7 +255,8 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
     exact isOpen_thickening
   have hE₁ : ∀ p, E = A p ∪ B p ∪ C p := by
     intro p
-    simp only [addWellApproximable, ← blimsup_or_eq_sup, ← and_or_left, ← sup_eq_union, sq]
+    simp only [E, A, B, C, addWellApproximable, ← blimsup_or_eq_sup, ← and_or_left, ← sup_eq_union,
+      sq]
     congr
     ext n
     tauto
@@ -292,7 +293,8 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
       rw [hu₀, Subtype.coe_mk, hp.coprime_iff_not_dvd, q.mul_div_cancel_left hp.pos]
       exact fun contra => h_ndiv (mul_dvd_mul_left p contra)
     replace h_div : n / p * p = n := Nat.div_mul_cancel h_div
-    have hf : f = (fun y => x + y) ∘ fun y => p • y := by ext; simp [add_comm x]; ac_rfl
+    have hf : f = (fun y => x + y) ∘ fun y => p • y := by
+      ext; simp [add_comm x]
     simp only at hf
     simp_rw [Function.comp_apply, le_eq_subset]
     rw [sSupHom.setImage_toFun, hf, image_comp]
chore: remove stream-of-consciousness uses of have, replace and suffices (#10640)

No changes to tactic file, it's just boring fixes throughout the library.

This follows on from #6964.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -122,8 +122,8 @@ theorem image_pow_subset (n : ℕ) (hm : 0 < m) :
     (fun (y : A) => y ^ m) '' approxOrderOf A (n * m) δ ⊆ approxOrderOf A n (m * δ) := by
   rintro - ⟨a, ha, rfl⟩
   obtain ⟨b, hb : orderOf b = n * m, hab : a ∈ ball b δ⟩ := mem_approxOrderOf_iff.mp ha
-  replace hb : b ^ m ∈ {y : A | orderOf y = n}
-  · rw [mem_setOf_eq, orderOf_pow' b hm.ne', hb, Nat.gcd_mul_left_left, n.mul_div_cancel hm]
+  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
   simp only [nsmul_eq_mul]
@@ -148,8 +148,8 @@ theorem smul_eq_of_mul_dvd (hn : 0 < n) (han : orderOf a ^ 2 ∣ n) :
     a • approxOrderOf A n δ = approxOrderOf A n δ := by
   simp_rw [approxOrderOf, thickening_eq_biUnion_ball, ← image_smul, image_iUnion₂, image_smul,
     smul_ball'', smul_eq_mul, mem_setOf_eq]
-  replace han : ∀ {b : A}, orderOf b = n → orderOf (a * b) = n
-  · intro b hb
+  replace han : ∀ {b : A}, orderOf b = n → orderOf (a * b) = n := by
+    intro b hb
     rw [← hb] at han hn
     rw [sq] at han
     rwa [(Commute.all a b).orderOf_mul_eq_right_of_forall_prime_mul_dvd (orderOf_pos_iff.mp hn)
@@ -312,8 +312,8 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
     exact blimsup_congr (eventually_of_forall fun n hn =>
       approxAddOrderOf.vadd_eq_of_mul_dvd (δ n) hn.1 hn.2)
   by_cases h : ∀ p : Nat.Primes, A p =ᵐ[μ] (∅ : Set 𝕊) ∧ B p =ᵐ[μ] (∅ : Set 𝕊)
-  · replace h : ∀ p : Nat.Primes, (u p +ᵥ E : Set _) =ᵐ[μ] E
-    · intro p
+  · replace h : ∀ p : Nat.Primes, (u p +ᵥ E : Set _) =ᵐ[μ] E := by
+      intro p
       replace hE₂ : E =ᵐ[μ] C p := hE₂ p (h p)
       have h_qmp : Measure.QuasiMeasurePreserving (-u p +ᵥ ·) μ μ :=
         (measurePreserving_vadd _ μ).quasiMeasurePreserving
@@ -342,8 +342,8 @@ lemma _root_.NormedAddCommGroup.exists_norm_nsmul_le {A : Type*}
   have : IsFiniteMeasure μ := CompactSpace.isFiniteMeasure
   let B : Icc 0 n → Set A := fun j ↦ closedBall ((j : ℕ) • ξ) (δ/2)
   have hB : ∀ j, IsClosed (B j) := fun j ↦ isClosed_ball
-  suffices : ¬ Pairwise (Disjoint on B)
-  · obtain ⟨i, j, hij, x, hx⟩ := exists_lt_mem_inter_of_not_pairwise_disjoint this
+  suffices ¬ Pairwise (Disjoint on B) by
+    obtain ⟨i, j, hij, x, hx⟩ := exists_lt_mem_inter_of_not_pairwise_disjoint this
     refine' ⟨j - i, ⟨le_tsub_of_add_le_left hij, _⟩, _⟩
     · simpa only [tsub_le_iff_right] using j.property.2.trans le_self_add
     · rw [sub_nsmul _ (Subtype.coe_le_coe.mpr hij.le), ← sub_eq_add_neg, ← dist_eq_norm]
@@ -360,8 +360,8 @@ lemma _root_.NormedAddCommGroup.exists_norm_nsmul_le {A : Type*}
     exact hδ
   replace hδ : 0 ≤ δ/2 := by
     by_contra contra
-    suffices : μ (closedBall 0 (δ/2)) = 0
-    · apply isOpen_univ.measure_ne_zero μ univ_nonempty <| le_zero_iff.mp <| le_trans hδ _
+    suffices μ (closedBall 0 (δ/2)) = 0 by
+      apply isOpen_univ.measure_ne_zero μ univ_nonempty <| le_zero_iff.mp <| le_trans hδ _
       simp [this]
     rw [not_le, ← closedBall_eq_empty (x := (0 : A))] at contra
     simp [contra]
chore: remove porting note after simp fix (#9974)
Diff
@@ -326,14 +326,9 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
     rw [hE₁ p]
     cases hp
     · cases' hA p with _ h; · contradiction
-      -- Porting note: was `simp only [h, union_ae_eq_univ_of_ae_eq_univ_left]`
-      have := union_ae_eq_univ_of_ae_eq_univ_left (t := B ↑p) h
-      exact union_ae_eq_univ_of_ae_eq_univ_left (t := C ↑p) this
+      simp only [h, union_ae_eq_univ_of_ae_eq_univ_left]
     · cases' hB p with _ h; · contradiction
-      -- Porting note: was
-      -- `simp only [h, union_ae_eq_univ_of_ae_eq_univ_left, union_ae_eq_univ_of_ae_eq_univ_right]`
-      have := union_ae_eq_univ_of_ae_eq_univ_right (s := A ↑p) h
-      exact union_ae_eq_univ_of_ae_eq_univ_left (t := C ↑p) this
+      simp only [h, union_ae_eq_univ_of_ae_eq_univ_left, union_ae_eq_univ_of_ae_eq_univ_right]
 #align add_circle.add_well_approximable_ae_empty_or_univ AddCircle.addWellApproximable_ae_empty_or_univ
 
 /-- A general version of **Dirichlet's approximation theorem**.
chore(*): replace $ with <| (#9319)

See Zulip thread for the discussion.

Diff
@@ -366,7 +366,7 @@ lemma _root_.NormedAddCommGroup.exists_norm_nsmul_le {A : Type*}
   replace hδ : 0 ≤ δ/2 := by
     by_contra contra
     suffices : μ (closedBall 0 (δ/2)) = 0
-    · apply isOpen_univ.measure_ne_zero μ univ_nonempty $ le_zero_iff.mp $ le_trans hδ _
+    · apply isOpen_univ.measure_ne_zero μ univ_nonempty <| le_zero_iff.mp <| le_trans hδ _
       simp [this]
     rw [not_le, ← closedBall_eq_empty (x := (0 : A))] at contra
     simp [contra]
@@ -380,7 +380,7 @@ lemma exists_norm_nsmul_le (ξ : 𝕊) {n : ℕ} (hn : 0 < n) :
     ∃ j ∈ Icc 1 n, ‖j • ξ‖ ≤ T / ↑(n + 1) := by
   apply NormedAddCommGroup.exists_norm_nsmul_le (μ := volume) ξ hn
   rw [AddCircle.measure_univ, volume_closedBall, ← ENNReal.ofReal_nsmul,
-    mul_div_cancel' _ two_ne_zero, min_eq_right (div_le_self hT.out.le $ by simp), nsmul_eq_mul,
+    mul_div_cancel' _ two_ne_zero, min_eq_right (div_le_self hT.out.le <| by simp), nsmul_eq_mul,
     mul_div_cancel' _ (Nat.cast_ne_zero.mpr n.succ_ne_zero)]
 
 end AddCircle
chore: Replace (· op ·) a by (a op ·) (#8843)

I used the regex \(\(· (.) ·\) (.)\), replacing with ($2 $1 ·).

Diff
@@ -315,7 +315,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
   · replace h : ∀ p : Nat.Primes, (u p +ᵥ E : Set _) =ᵐ[μ] E
     · intro p
       replace hE₂ : E =ᵐ[μ] C p := hE₂ p (h p)
-      have h_qmp : MeasureTheory.Measure.QuasiMeasurePreserving ((· +ᵥ ·) (-u p)) μ μ :=
+      have h_qmp : Measure.QuasiMeasurePreserving (-u p +ᵥ ·) μ μ :=
         (measurePreserving_vadd _ μ).quasiMeasurePreserving
       refine' (h_qmp.vadd_ae_eq_of_ae_eq (u p) hE₂).trans (ae_eq_trans _ hE₂.symm)
       rw [hC]
chore: Generalise lemmas from finite groups to torsion elements (#8342)

Many lemmas in GroupTheory.OrderOfElement were stated for elements of finite groups even though they work more generally for torsion elements of possibly infinite groups. This PR generalises those lemmas (and leaves convenience lemmas stated for finite groups), and fixes a bunch of names to use dot notation.

Renames

  • Function.eq_of_lt_minimalPeriod_of_iterate_eqFunction.iterate_injOn_Iio_minimalPeriod
  • Function.eq_iff_lt_minimalPeriod_of_iterate_eqFunction.iterate_eq_iterate_iff_of_lt_minimalPeriod
  • isOfFinOrder_iff_coeSubmonoid.isOfFinOrder_coe
  • orderOf_pos'IsOfFinOrder.orderOf_pos
  • pow_eq_mod_orderOfpow_mod_orderOf (and turned around)
  • pow_injective_of_lt_orderOfpow_injOn_Iio_orderOf
  • mem_powers_iff_mem_range_order_of'IsOfFinOrder.mem_powers_iff_mem_range_orderOf
  • orderOf_pow''IsOfFinOrder.orderOf_pow
  • orderOf_pow_coprimeNat.Coprime.orderOf_pow
  • zpow_eq_mod_orderOfzpow_mod_orderOf (and turned around)
  • exists_pow_eq_oneisOfFinOrder_of_finite
  • pow_apply_eq_pow_mod_orderOf_cycleOf_applypow_mod_orderOf_cycleOf_apply

New lemmas

  • IsOfFinOrder.powers_eq_image_range_orderOf
  • IsOfFinOrder.natCard_powers_le_orderOf
  • IsOfFinOrder.finite_powers
  • finite_powers
  • infinite_powers
  • Nat.card_submonoidPowers
  • IsOfFinOrder.mem_powers_iff_mem_zpowers
  • IsOfFinOrder.powers_eq_zpowers
  • IsOfFinOrder.mem_zpowers_iff_mem_range_orderOf
  • IsOfFinOrder.exists_pow_eq_one

Other changes

  • Move decidableMemPowers/fintypePowers to GroupTheory.Submonoid.Membership and decidableMemZpowers/fintypeZpowers to GroupTheory.Subgroup.ZPowers.
  • finEquivPowers, finEquivZpowers, powersEquivPowers and zpowersEquivZpowers now assume IsOfFinTorsion x instead of Finite G.
  • isOfFinOrder_iff_pow_eq_one now takes one less explicit argument.
  • Delete Equiv.Perm.IsCycle.exists_pow_eq_one since it was saying that a permutation over a finite type is torsion, but this is trivial since the group of permutation is itself finite, so we can use isOfFinOrder_of_finite instead.
Diff
@@ -110,7 +110,7 @@ theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.Coprime m) :
   rintro - ⟨a, ha, rfl⟩
   obtain ⟨b, hb, hab⟩ := mem_approxOrderOf_iff.mp ha
   replace hb : b ^ m ∈ {u : A | orderOf u = n} := by
-    rw [← hb] at hmn ⊢; exact orderOf_pow_coprime hmn
+    rw [← hb] at hmn ⊢; exact hmn.orderOf_pow
   apply ball_subset_thickening hb ((m : ℝ) • δ)
   convert pow_mem_ball hm hab using 1
   simp only [nsmul_eq_mul, Algebra.id.smul_eq_mul]
chore: bump to v4.1.0-rc1 (2nd attempt) (#7216)

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -105,7 +105,7 @@ namespace approxOrderOf
 variable {A : Type*} [SeminormedCommGroup A] {a : A} {m n : ℕ} (δ : ℝ)
 
 @[to_additive]
-theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.coprime m) :
+theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.Coprime m) :
     (fun (y : A) => y ^ m) '' approxOrderOf A n δ ⊆ approxOrderOf A n (m * δ) := by
   rintro - ⟨a, ha, rfl⟩
   obtain ⟨b, hb, hab⟩ := mem_approxOrderOf_iff.mp ha
@@ -131,7 +131,7 @@ theorem image_pow_subset (n : ℕ) (hm : 0 < m) :
 #align approx_add_order_of.image_nsmul_subset approxAddOrderOf.image_nsmul_subset
 
 @[to_additive]
-theorem smul_subset_of_coprime (han : (orderOf a).coprime n) :
+theorem smul_subset_of_coprime (han : (orderOf a).Coprime n) :
     a • approxOrderOf A n δ ⊆ approxOrderOf A (orderOf a * n) δ := by
   simp_rw [approxOrderOf, thickening_eq_biUnion_ball, ← image_smul, image_iUnion₂, image_smul,
     smul_ball'', smul_eq_mul, mem_setOf_eq]
@@ -287,7 +287,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
         (Nat.cast_pos.mpr hp.pos) _ hδ
     refine' (SupHom.apply_blimsup_le (sSupHom.setImage f)).trans (mono_blimsup _)
     rintro n ⟨hn, h_div, h_ndiv⟩
-    have h_cop : (addOrderOf x).coprime (n / p) := by
+    have h_cop : (addOrderOf x).Coprime (n / p) := by
       obtain ⟨q, rfl⟩ := h_div
       rw [hu₀, Subtype.coe_mk, hp.coprime_iff_not_dvd, q.mul_div_cancel_left hp.pos]
       exact fun contra => h_ndiv (mul_dvd_mul_left p contra)
Revert "chore: bump to v4.1.0-rc1 (#7174)" (#7198)

This reverts commit 6f8e8104. Unfortunately this bump was not linted correctly, as CI did not run runLinter Mathlib.

We can unrevert once that's fixed.

Diff
@@ -105,7 +105,7 @@ namespace approxOrderOf
 variable {A : Type*} [SeminormedCommGroup A] {a : A} {m n : ℕ} (δ : ℝ)
 
 @[to_additive]
-theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.Coprime m) :
+theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.coprime m) :
     (fun (y : A) => y ^ m) '' approxOrderOf A n δ ⊆ approxOrderOf A n (m * δ) := by
   rintro - ⟨a, ha, rfl⟩
   obtain ⟨b, hb, hab⟩ := mem_approxOrderOf_iff.mp ha
@@ -131,7 +131,7 @@ theorem image_pow_subset (n : ℕ) (hm : 0 < m) :
 #align approx_add_order_of.image_nsmul_subset approxAddOrderOf.image_nsmul_subset
 
 @[to_additive]
-theorem smul_subset_of_coprime (han : (orderOf a).Coprime n) :
+theorem smul_subset_of_coprime (han : (orderOf a).coprime n) :
     a • approxOrderOf A n δ ⊆ approxOrderOf A (orderOf a * n) δ := by
   simp_rw [approxOrderOf, thickening_eq_biUnion_ball, ← image_smul, image_iUnion₂, image_smul,
     smul_ball'', smul_eq_mul, mem_setOf_eq]
@@ -287,7 +287,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
         (Nat.cast_pos.mpr hp.pos) _ hδ
     refine' (SupHom.apply_blimsup_le (sSupHom.setImage f)).trans (mono_blimsup _)
     rintro n ⟨hn, h_div, h_ndiv⟩
-    have h_cop : (addOrderOf x).Coprime (n / p) := by
+    have h_cop : (addOrderOf x).coprime (n / p) := by
       obtain ⟨q, rfl⟩ := h_div
       rw [hu₀, Subtype.coe_mk, hp.coprime_iff_not_dvd, q.mul_div_cancel_left hp.pos]
       exact fun contra => h_ndiv (mul_dvd_mul_left p contra)
chore: bump to v4.1.0-rc1 (#7174)

Some changes have already been review and delegated in #6910 and #7148.

The diff that needs looking at is https://github.com/leanprover-community/mathlib4/pull/7174/commits/64d6d07ee18163627c8f517eb31455411921c5ac

The std bump PR was insta-merged already!

Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -105,7 +105,7 @@ namespace approxOrderOf
 variable {A : Type*} [SeminormedCommGroup A] {a : A} {m n : ℕ} (δ : ℝ)
 
 @[to_additive]
-theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.coprime m) :
+theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.Coprime m) :
     (fun (y : A) => y ^ m) '' approxOrderOf A n δ ⊆ approxOrderOf A n (m * δ) := by
   rintro - ⟨a, ha, rfl⟩
   obtain ⟨b, hb, hab⟩ := mem_approxOrderOf_iff.mp ha
@@ -131,7 +131,7 @@ theorem image_pow_subset (n : ℕ) (hm : 0 < m) :
 #align approx_add_order_of.image_nsmul_subset approxAddOrderOf.image_nsmul_subset
 
 @[to_additive]
-theorem smul_subset_of_coprime (han : (orderOf a).coprime n) :
+theorem smul_subset_of_coprime (han : (orderOf a).Coprime n) :
     a • approxOrderOf A n δ ⊆ approxOrderOf A (orderOf a * n) δ := by
   simp_rw [approxOrderOf, thickening_eq_biUnion_ball, ← image_smul, image_iUnion₂, image_smul,
     smul_ball'', smul_eq_mul, mem_setOf_eq]
@@ -287,7 +287,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
         (Nat.cast_pos.mpr hp.pos) _ hδ
     refine' (SupHom.apply_blimsup_le (sSupHom.setImage f)).trans (mono_blimsup _)
     rintro n ⟨hn, h_div, h_ndiv⟩
-    have h_cop : (addOrderOf x).coprime (n / p) := by
+    have h_cop : (addOrderOf x).Coprime (n / p) := by
       obtain ⟨q, rfl⟩ := h_div
       rw [hu₀, Subtype.coe_mk, hp.coprime_iff_not_dvd, q.mul_div_cancel_left hp.pos]
       exact fun contra => h_ndiv (mul_dvd_mul_left p contra)
feat: Alexandrov-discrete spaces (#6962)

We define Alexandrov-discrete spaces as topological spaces where the intersection of a family of open sets is open.

This PR only gives a minimal API because the goal is to ensure that lemma names like isOpen_sInter are free to use for AlexandrovDiscrete. The existing lemmas are getting prefixed by Set.Finite or suffixed by _of_finite.

Diff
@@ -357,7 +357,7 @@ lemma _root_.NormedAddCommGroup.exists_norm_nsmul_le {A : Type*}
   by_contra h
   apply hn.ne'
   have h' : ⋃ j, B j = univ := by
-    rw [← (isClosed_iUnion hB).measure_eq_univ_iff_eq (μ := μ)]
+    rw [← (isClosed_iUnion_of_finite hB).measure_eq_univ_iff_eq (μ := μ)]
     refine' le_antisymm (μ.mono (subset_univ _)) _
     simp_rw [measure_iUnion h (fun _ ↦ measurableSet_closedBall), tsum_fintype,
       μ.addHaar_closedBall_center, Finset.sum_const, Finset.card_univ, Nat.card_fintypeIcc,
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -68,13 +68,13 @@ open scoped MeasureTheory Topology Pointwise
 elements within a distance `δ` of a point of order `n`. -/
 @[to_additive "In a seminormed additive group `A`, given `n : ℕ` and `δ : ℝ`,
 `approxAddOrderOf A n δ` is the set of elements within a distance `δ` of a point of order `n`."]
-def approxOrderOf (A : Type _) [SeminormedGroup A] (n : ℕ) (δ : ℝ) : Set A :=
+def approxOrderOf (A : Type*) [SeminormedGroup A] (n : ℕ) (δ : ℝ) : Set A :=
   thickening δ {y | orderOf y = n}
 #align approx_order_of approxOrderOf
 #align approx_add_order_of approxAddOrderOf
 
 @[to_additive mem_approx_add_orderOf_iff]
-theorem mem_approxOrderOf_iff {A : Type _} [SeminormedGroup A] {n : ℕ} {δ : ℝ} {a : A} :
+theorem mem_approxOrderOf_iff {A : Type*} [SeminormedGroup A] {n : ℕ} {δ : ℝ} {a : A} :
     a ∈ approxOrderOf A n δ ↔ ∃ b : A, orderOf b = n ∧ a ∈ ball b δ := by
   simp only [approxOrderOf, thickening_eq_biUnion_ball, mem_iUnion₂, mem_setOf_eq, exists_prop]
 #align mem_approx_order_of_iff mem_approxOrderOf_iff
@@ -87,13 +87,13 @@ lie in infinitely many of the sets `approxOrderOf A n δₙ`. -/
 distances `δ₁, δ₂, ...`, `addWellApproximable A δ` is the limsup as `n → ∞` of the sets
 `approxAddOrderOf A n δₙ`. Thus, it is the set of points that lie in infinitely many of the sets
 `approxAddOrderOf A n δₙ`."]
-def wellApproximable (A : Type _) [SeminormedGroup A] (δ : ℕ → ℝ) : Set A :=
+def wellApproximable (A : Type*) [SeminormedGroup A] (δ : ℕ → ℝ) : Set A :=
   blimsup (fun n => approxOrderOf A n (δ n)) atTop fun n => 0 < n
 #align well_approximable wellApproximable
 #align add_well_approximable addWellApproximable
 
 @[to_additive mem_add_wellApproximable_iff]
-theorem mem_wellApproximable_iff {A : Type _} [SeminormedGroup A] {δ : ℕ → ℝ} {a : A} :
+theorem mem_wellApproximable_iff {A : Type*} [SeminormedGroup A] {δ : ℕ → ℝ} {a : A} :
     a ∈ wellApproximable A δ ↔
       a ∈ blimsup (fun n => approxOrderOf A n (δ n)) atTop fun n => 0 < n :=
   Iff.rfl
@@ -102,7 +102,7 @@ theorem mem_wellApproximable_iff {A : Type _} [SeminormedGroup A] {δ : ℕ →
 
 namespace approxOrderOf
 
-variable {A : Type _} [SeminormedCommGroup A] {a : A} {m n : ℕ} (δ : ℝ)
+variable {A : Type*} [SeminormedCommGroup A] {a : A} {m n : ℕ} (δ : ℝ)
 
 @[to_additive]
 theorem image_pow_subset_of_coprime (hm : 0 < m) (hmn : n.coprime m) :
@@ -339,7 +339,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
 /-- A general version of **Dirichlet's approximation theorem**.
 
 See also `AddCircle.exists_norm_nsmul_le`. -/
-lemma _root_.NormedAddCommGroup.exists_norm_nsmul_le {A : Type _}
+lemma _root_.NormedAddCommGroup.exists_norm_nsmul_le {A : Type*}
     [NormedAddCommGroup A] [CompactSpace A] [ConnectedSpace A]
     [MeasurableSpace A] [BorelSpace A] {μ : Measure A} [μ.IsAddHaarMeasure]
     (ξ : A) {n : ℕ} (hn : 0 < n) (δ : ℝ) (hδ : μ univ ≤ (n + 1) • μ (closedBall (0 : A) (δ/2))) :
feat: add a generalisation of Dirichlet's approximation theorem (#6033)
Diff
@@ -45,12 +45,18 @@ We do *not* include a formalisation of the Koukoulopoulos-Maynard result here.
  * `AddCircle.addWellApproximable_ae_empty_or_univ`: *Gallagher's ergodic theorem* says that for
    the (additive) circle `𝕊`, for any sequence of distances `δ`, the set
    `addWellApproximable 𝕊 δ` is almost empty or almost full.
+ * `NormedAddCommGroup.exists_norm_nsmul_le`: a general version of Dirichlet's approximation theorem
+ * `AddCircle.exists_norm_nsmul_le`: Dirichlet's approximation theorem
 
 ## TODO:
 
 The hypothesis `hδ` in `AddCircle.addWellApproximable_ae_empty_or_univ` can be dropped.
 An elementary (non-measure-theoretic) argument shows that if `¬ hδ` holds then
 `addWellApproximable 𝕊 δ = univ` (provided `δ` is non-negative).
+
+Use `AddCircle.exists_norm_nsmul_le` to prove:
+`addWellApproximable 𝕊 (fun n ↦ 1 / n^2) = { ξ | ¬ IsOfFinAddOrder ξ }`
+(which is equivalent to `Real.infinite_rat_abs_sub_lt_one_div_den_sq_iff_irrational`).
 -/
 
 
@@ -330,4 +336,51 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
       exact union_ae_eq_univ_of_ae_eq_univ_left (t := C ↑p) this
 #align add_circle.add_well_approximable_ae_empty_or_univ AddCircle.addWellApproximable_ae_empty_or_univ
 
+/-- A general version of **Dirichlet's approximation theorem**.
+
+See also `AddCircle.exists_norm_nsmul_le`. -/
+lemma _root_.NormedAddCommGroup.exists_norm_nsmul_le {A : Type _}
+    [NormedAddCommGroup A] [CompactSpace A] [ConnectedSpace A]
+    [MeasurableSpace A] [BorelSpace A] {μ : Measure A} [μ.IsAddHaarMeasure]
+    (ξ : A) {n : ℕ} (hn : 0 < n) (δ : ℝ) (hδ : μ univ ≤ (n + 1) • μ (closedBall (0 : A) (δ/2))) :
+    ∃ j ∈ Icc 1 n, ‖j • ξ‖ ≤ δ := by
+  have : IsFiniteMeasure μ := CompactSpace.isFiniteMeasure
+  let B : Icc 0 n → Set A := fun j ↦ closedBall ((j : ℕ) • ξ) (δ/2)
+  have hB : ∀ j, IsClosed (B j) := fun j ↦ isClosed_ball
+  suffices : ¬ Pairwise (Disjoint on B)
+  · obtain ⟨i, j, hij, x, hx⟩ := exists_lt_mem_inter_of_not_pairwise_disjoint this
+    refine' ⟨j - i, ⟨le_tsub_of_add_le_left hij, _⟩, _⟩
+    · simpa only [tsub_le_iff_right] using j.property.2.trans le_self_add
+    · rw [sub_nsmul _ (Subtype.coe_le_coe.mpr hij.le), ← sub_eq_add_neg, ← dist_eq_norm]
+      refine' (dist_triangle (↑j • ξ) x (↑i • ξ)).trans _
+      linarith [mem_closedBall.mp hx.1, mem_closedBall'.mp hx.2]
+  by_contra h
+  apply hn.ne'
+  have h' : ⋃ j, B j = univ := by
+    rw [← (isClosed_iUnion hB).measure_eq_univ_iff_eq (μ := μ)]
+    refine' le_antisymm (μ.mono (subset_univ _)) _
+    simp_rw [measure_iUnion h (fun _ ↦ measurableSet_closedBall), tsum_fintype,
+      μ.addHaar_closedBall_center, Finset.sum_const, Finset.card_univ, Nat.card_fintypeIcc,
+      tsub_zero]
+    exact hδ
+  replace hδ : 0 ≤ δ/2 := by
+    by_contra contra
+    suffices : μ (closedBall 0 (δ/2)) = 0
+    · apply isOpen_univ.measure_ne_zero μ univ_nonempty $ le_zero_iff.mp $ le_trans hδ _
+      simp [this]
+    rw [not_le, ← closedBall_eq_empty (x := (0 : A))] at contra
+    simp [contra]
+  have h'' : ∀ j, (B j).Nonempty := by intro j; rwa [nonempty_closedBall]
+  simpa using subsingleton_of_disjoint_isClosed_iUnion_eq_univ h'' h hB h'
+
+/-- **Dirichlet's approximation theorem**
+
+See also `Real.exists_rat_abs_sub_le_and_den_le`. -/
+lemma exists_norm_nsmul_le (ξ : 𝕊) {n : ℕ} (hn : 0 < n) :
+    ∃ j ∈ Icc 1 n, ‖j • ξ‖ ≤ T / ↑(n + 1) := by
+  apply NormedAddCommGroup.exists_norm_nsmul_le (μ := volume) ξ hn
+  rw [AddCircle.measure_univ, volume_closedBall, ← ENNReal.ofReal_nsmul,
+    mul_div_cancel' _ two_ne_zero, min_eq_right (div_le_self hT.out.le $ by simp), nsmul_eq_mul,
+    mul_div_cancel' _ (Nat.cast_ne_zero.mpr n.succ_ne_zero)]
+
 end AddCircle
chore: fix grammar mistakes (#6121)
Diff
@@ -43,7 +43,7 @@ We do *not* include a formalisation of the Koukoulopoulos-Maynard result here.
    `wellApproximable A δ` is the limsup as `n → ∞` of the sets `approxOrderOf A n δₙ`. Thus, it
    is the set of points that lie in infinitely many of the sets `approxOrderOf A n δₙ`.
  * `AddCircle.addWellApproximable_ae_empty_or_univ`: *Gallagher's ergodic theorem* says that for
-   for the (additive) circle `𝕊`, for any sequence of distances `δ`, the set
+   the (additive) circle `𝕊`, for any sequence of distances `δ`, the set
    `addWellApproximable 𝕊 δ` is almost empty or almost full.
 
 ## TODO:
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2022 Oliver Nash. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Oliver Nash
-
-! This file was ported from Lean 3 source module number_theory.well_approximable
-! leanprover-community/mathlib commit f0c8bf9245297a541f468be517f1bde6195105e9
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Dynamics.Ergodic.AddCircle
 import Mathlib.MeasureTheory.Covering.LiminfLimsup
 
+#align_import number_theory.well_approximable from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
+
 /-!
 # Well-approximable numbers and Gallagher's ergodic theorem
 
chore(NumberTheory/WellApproximable): golf proof using tauto (#5263)

Two independent changes are being proposed here:

  1. Using tauto: this was annoyingly slow in Lean 3 but is not in Lean 4,
  2. Changing p to ((p : ℕ) : ℝ): this is because Lean 4 is unfortunately much worse at coercing from Nat.Primes to Real and will waste about 5 seconds working on this via typeclass inference of CoeT searches without this change.

Some discussion here on Zulip.

Diff
@@ -228,7 +228,7 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
     `AddCircle.ae_empty_or_univ_of_forall_vadd_ae_eq_self`. -/
   letI : SemilatticeSup Nat.Primes := Nat.Subtype.semilatticeSup _
   set μ : Measure 𝕊 := volume
-  set u : Nat.Primes → 𝕊 := fun p => ↑((↑(1 : ℕ) : ℝ) / p * T)
+  set u : Nat.Primes → 𝕊 := fun p => ↑((↑(1 : ℕ) : ℝ) / ((p : ℕ) : ℝ) * T)
   have hu₀ : ∀ p : Nat.Primes, addOrderOf (u p) = (p : ℕ) := by
     rintro ⟨p, hp⟩; exact addOrderOf_div_of_gcd_eq_one hp.pos (gcd_one_left p)
   have hu : Tendsto (addOrderOf ∘ u) atTop atTop := by
@@ -254,10 +254,8 @@ theorem addWellApproximable_ae_empty_or_univ (δ : ℕ → ℝ) (hδ : Tendsto 
     intro p
     simp only [addWellApproximable, ← blimsup_or_eq_sup, ← and_or_left, ← sup_eq_union, sq]
     congr
-    refine' funext fun n => propext <| iff_self_and.mpr fun _ => _
-    -- `tauto` can finish from here but unfortunately it's very slow.
-    simp only [(em (p ∣ n)).symm, (em (p * p ∣ n)).symm, or_and_left, or_true_iff, true_and_iff,
-      or_assoc]
+    ext n
+    tauto
   have hE₂ : ∀ p : Nat.Primes, A p =ᵐ[μ] (∅ : Set 𝕊) ∧ B p =ᵐ[μ] (∅ : Set 𝕊) → E =ᵐ[μ] C p := by
     rintro p ⟨hA, hB⟩
     rw [hE₁ p]
feat: port NumberTheory.WellApproximable (#5255)

Dependencies 12 + 1040

1041 files ported (98.9%)
473987 lines ported (98.8%)
Show graph

The unported dependencies are

The following 1 dependencies have changed in mathlib3 since they were ported, which may complicate porting this file