Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 9228ff9

Browse files
committed
feat(algebra/ordered_group): abs_sub (#7850)
- rename `abs_sub` to `abs_sub_comm` - prove `abs_sub`
1 parent 4bfe8e8 commit 9228ff9

File tree

11 files changed

+24
-19
lines changed

11 files changed

+24
-19
lines changed

src/algebra/continued_fractions/computation/approximation_corollaries.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ local attribute [instance] preorder.topology
138138

139139
theorem of_convergence [order_topology K] :
140140
filter.tendsto ((gcf.of v).convergents) filter.at_top $ nhds v :=
141-
by simpa [linear_ordered_add_comm_group.tendsto_nhds, abs_sub] using (of_convergence_epsilon v)
141+
by simpa [linear_ordered_add_comm_group.tendsto_nhds, abs_sub_comm] using (of_convergence_epsilon v)
142142

143143
end convergence
144144

src/algebra/ordered_group.lean

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ lemma abs_pos_of_pos (h : 0 < a) : 0 < abs a := abs_pos.2 h.ne.symm
765765

766766
lemma abs_pos_of_neg (h : a < 0) : 0 < abs a := abs_pos.2 h.ne
767767

768-
lemma abs_sub (a b : α) : abs (a - b) = abs (b - a) :=
768+
lemma abs_sub_comm (a b : α) : abs (a - b) = abs (b - a) :=
769769
by rw [← neg_sub, abs_neg]
770770

771771
lemma abs_le' : abs a ≤ b ↔ a ≤ b ∧ -a ≤ b := max_le_iff
@@ -815,13 +815,17 @@ begin
815815
end
816816

817817
lemma max_sub_min_eq_abs (a b : α) : max a b - min a b = abs (b - a) :=
818-
by { rw [abs_sub], exact max_sub_min_eq_abs' _ _ }
818+
by { rw abs_sub_comm, exact max_sub_min_eq_abs' _ _ }
819819

820820
lemma abs_add (a b : α) : abs (a + b) ≤ abs a + abs b :=
821821
abs_le.2 ⟨(neg_add (abs a) (abs b)).symm ▸
822822
add_le_add (neg_le.2 $ neg_le_abs_self _) (neg_le.2 $ neg_le_abs_self _),
823823
add_le_add (le_abs_self _) (le_abs_self _)⟩
824824

825+
theorem abs_sub (a b : α) :
826+
abs (a - b) ≤ abs a + abs b :=
827+
by { rw [sub_eq_add_neg, ←abs_neg b], exact abs_add a _ }
828+
825829
lemma abs_sub_le_iff : abs (a - b) ≤ c ↔ a - b ≤ c ∧ b - a ≤ c :=
826830
by rw [abs_le, neg_le_sub_iff_le_add, @sub_le_iff_le_add' _ _ b, and_comm]
827831

@@ -832,21 +836,21 @@ lemma sub_le_of_abs_sub_le_left (h : abs (a - b) ≤ c) : b - c ≤ a :=
832836
sub_le.1 $ (abs_sub_le_iff.1 h).2
833837

834838
lemma sub_le_of_abs_sub_le_right (h : abs (a - b) ≤ c) : a - c ≤ b :=
835-
sub_le_of_abs_sub_le_left (abs_sub a b ▸ h)
839+
sub_le_of_abs_sub_le_left (abs_sub_comm a b ▸ h)
836840

837841
lemma sub_lt_of_abs_sub_lt_left (h : abs (a - b) < c) : b - c < a :=
838842
sub_lt.1 $ (abs_sub_lt_iff.1 h).2
839843

840844
lemma sub_lt_of_abs_sub_lt_right (h : abs (a - b) < c) : a - c < b :=
841-
sub_lt_of_abs_sub_lt_left (abs_sub a b ▸ h)
845+
sub_lt_of_abs_sub_lt_left (abs_sub_comm a b ▸ h)
842846

843847
lemma abs_sub_abs_le_abs_sub (a b : α) : abs a - abs b ≤ abs (a - b) :=
844848
sub_le_iff_le_add.2 $
845849
calc abs a = abs (a - b + b) : by rw [sub_add_cancel]
846850
... ≤ abs (a - b) + abs b : abs_add _ _
847851

848852
lemma abs_abs_sub_abs_le_abs_sub (a b : α) : abs (abs a - abs b) ≤ abs (a - b) :=
849-
abs_sub_le_iff.2 ⟨abs_sub_abs_le_abs_sub _ _, by rw abs_sub; apply abs_sub_abs_le_abs_sub⟩
853+
abs_sub_le_iff.2 ⟨abs_sub_abs_le_abs_sub _ _, by rw abs_sub_comm; apply abs_sub_abs_le_abs_sub⟩
850854

851855
lemma eq_or_eq_neg_of_abs_eq (h : abs a = b) : a = b ∨ a = -b :=
852856
by simpa only [← h, eq_comm, eq_neg_iff_eq_neg] using abs_choice a

src/data/complex/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ _root_.abs_of_nonneg (abs_nonneg _)
467467

468468
@[simp] lemma abs_pos {z : ℂ} : 0 < abs z ↔ z ≠ 0 := abv_pos abs
469469
@[simp] lemma abs_neg : ∀ z, abs (-z) = abs z := abv_neg abs
470-
lemma abs_sub : ∀ z w, abs (z - w) = abs (w - z) := abv_sub abs
470+
lemma abs_sub_comm : ∀ z w, abs (z - w) = abs (w - z) := abv_sub abs
471471
lemma abs_sub_le : ∀ a b c, abs (a - c) ≤ abs (a - b) + abs (b - c) := abv_sub_le abs
472472
@[simp] theorem abs_inv : ∀ z, abs z⁻¹ = (abs z)⁻¹ := abv_inv abs
473473
@[simp] theorem abs_div : ∀ z w, abs (z / w) = abs z / abs w := abv_div abs

src/data/complex/exponential.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ begin
9999
have sub_le := abs_sub_le (∑ k in range j, g k) (∑ k in range i, g k)
100100
(∑ k in range (max n i), g k),
101101
have := add_lt_add hi₁ hi₂,
102-
rw [abs_sub (∑ k in range (max n i), g k), add_halves ε] at this,
102+
rw [abs_sub_comm (∑ k in range (max n i), g k), add_halves ε] at this,
103103
refine lt_of_le_of_lt (le_trans (le_trans _ (le_abs_self _)) sub_le) this,
104104
generalize hk : j - max n i = k,
105105
clear this hi₂ hi₁ hi ε0 ε hg sub_le,

src/data/complex/exponential_bounds.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ begin
6464
have z := real.abs_log_sub_add_sum_range_le (show abs' (2⁻¹ : ℝ) < 1, by { rw t, norm_num }) 34,
6565
rw t at z,
6666
norm_num1 at z,
67-
rw [one_div (2:ℝ), log_inv, ←sub_eq_add_neg, _root_.abs_sub] at z,
67+
rw [one_div (2:ℝ), log_inv, ←sub_eq_add_neg, _root_.abs_sub_comm] at z,
6868
apply le_trans (_root_.abs_sub_le _ _ _) (add_le_add z _),
6969
simp_rw [sum_range_succ],
7070
norm_num,

src/dynamics/circle/rotation_number/translation_number.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ lemma dist_map_zero_lt_of_semiconj {f g₁ g₂ : circle_deg1_lift} (h : functio
412412
dist (g₁ 0) (g₂ 0) < 2 :=
413413
calc dist (g₁ 0) (g₂ 0) ≤ dist (g₁ 0) (f (g₁ 0) - f 0) + dist _ (g₂ 0) : dist_triangle _ _ _
414414
... = dist (f 0 + g₁ 0) (f (g₁ 0)) + dist (g₂ 0 + f 0) (g₂ (f 0)) :
415-
by simp only [h.eq, real.dist_eq, sub_sub, add_comm (f 0), sub_sub_assoc_swap, abs_sub (g₂ (f 0))]
415+
by simp only [h.eq, real.dist_eq, sub_sub, add_comm (f 0), sub_sub_assoc_swap, abs_sub_comm
416+
(g₂ (f 0))]
416417
... < 2 : add_lt_add (f.dist_map_map_zero_lt g₁) (g₂.dist_map_map_zero_lt f)
417418

418419
lemma dist_map_zero_lt_of_semiconj_by {f g₁ g₂ : circle_deg1_lift} (h : semiconj_by f g₁ g₂) :

src/geometry/euclidean/sphere.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ begin
6161
... = abs (r ^ 2 * ∥y∥ ^ 2 - ∥y∥ ^ 2) : by ring_nf
6262
... = abs (∥x∥ ^ 2 - ∥y∥ ^ 2) : by simp [hxy, norm_smul, mul_pow, norm_eq_abs, sq_abs]
6363
... = abs (∥z + y∥ ^ 2 - ∥z - x∥ ^ 2) : by simp [norm_add_sq_real, norm_sub_sq_real,
64-
hzy, hzx, abs_sub],
64+
hzy, hzx, abs_sub_comm],
6565
end
6666

6767
end inner_product_geometry

src/topology/algebra/ordered/basic.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,11 +1517,11 @@ end
15171517

15181518
lemma linear_ordered_add_comm_group.tendsto_nhds {x : filter β} {a : α} :
15191519
tendsto f x (𝓝 a) ↔ ∀ ε > (0 : α), ∀ᶠ b in x, |f b - a| < ε :=
1520-
by simp [nhds_eq_infi_abs_sub, abs_sub a]
1520+
by simp [nhds_eq_infi_abs_sub, abs_sub_comm a]
15211521

15221522
lemma eventually_abs_sub_lt (a : α) {ε : α} (hε : 0 < ε) : ∀ᶠ x in 𝓝 a, |x - a| < ε :=
15231523
(nhds_eq_infi_abs_sub a).symm ▸ mem_infi_sets ε
1524-
(mem_infi_sets hε $ by simp only [abs_sub, mem_principal_self])
1524+
(mem_infi_sets hε $ by simp only [abs_sub_comm, mem_principal_self])
15251525

15261526
@[priority 100] -- see Note [lower instance priority]
15271527
instance linear_ordered_add_comm_group.topological_add_group : topological_add_group α :=
@@ -1550,7 +1550,7 @@ instance linear_ordered_add_comm_group.topological_add_group : topological_add_g
15501550
end,
15511551
continuous_neg := continuous_iff_continuous_at.2 $ λ a,
15521552
linear_ordered_add_comm_group.tendsto_nhds.2 $ λ ε ε0,
1553-
(eventually_abs_sub_lt a ε0).mono $ λ x hx, by rwa [neg_sub_neg, abs_sub] }
1553+
(eventually_abs_sub_lt a ε0).mono $ λ x hx, by rwa [neg_sub_neg, abs_sub_comm] }
15541554

15551555
@[continuity]
15561556
lemma continuous_abs : continuous (abs : α → α) := continuous_id.max continuous_neg

src/topology/instances/real.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ begin
292292
push_neg at H',
293293
intros x,
294294
suffices : ∀ ε > (0 : ℝ), ∃ g ∈ G, abs (x - g) < ε,
295-
by simpa only [real.mem_closure_iff, abs_sub],
295+
by simpa only [real.mem_closure_iff, abs_sub_comm],
296296
intros ε ε_pos,
297297
obtain ⟨g₁, g₁_in, g₁_pos⟩ : ∃ g₁ : ℝ, g₁ ∈ G ∧ 0 < g₁,
298298
{ cases lt_or_gt_of_ne g₀_ne with Hg₀ Hg₀,

src/topology/metric_space/basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ section real
858858
instance real.pseudo_metric_space : pseudo_metric_space ℝ :=
859859
{ dist := λx y, abs (x - y),
860860
dist_self := by simp [abs_zero],
861-
dist_comm := assume x y, abs_sub _ _,
861+
dist_comm := assume x y, abs_sub_comm _ _,
862862
dist_triangle := assume x y z, abs_sub_le _ _ _ }
863863

864864
theorem real.dist_eq (x y : ℝ) : dist x y = abs (x - y) := rfl
@@ -888,7 +888,7 @@ by simpa [real.dist_eq] using real.dist_le_of_mem_Icc hx hy
888888

889889
instance : order_topology ℝ :=
890890
order_topology_of_nhds_abs $ λ x,
891-
by simp only [nhds_basis_ball.eq_binfi, ball, real.dist_eq, abs_sub]
891+
by simp only [nhds_basis_ball.eq_binfi, ball, real.dist_eq, abs_sub_comm]
892892

893893
lemma closed_ball_Icc {x r : ℝ} : closed_ball x r = Icc (x-r) (x+r) :=
894894
by ext y; rw [mem_closed_ball, dist_comm, real.dist_eq,

0 commit comments

Comments
 (0)