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

Commit d9083bc

Browse files
urkudkim-emmergify[bot]
authored
chore(algebra/ordered_field): merge inv_pos / zero_lt_inv with inv_pos' / inv_neg (#2226)
* chore(algebra/ordered_field): merge `inv_pos` / `zero_lt_inv` with `inv_pos'` / `inv_neg` Also move some lemmas to `linear_ordered_field` * Update src/data/real/hyperreal.lean * Fix compile * Actually fix compile of `data/real/hyperreal` Co-authored-by: Scott Morrison <scott@tqft.net> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 24b82c9 commit d9083bc

File tree

16 files changed

+77
-78
lines changed

16 files changed

+77
-78
lines changed

src/algebra/archimedean.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ by classical; exact
8181
let ⟨N, hN⟩ := pow_unbounded_of_one_lt x⁻¹ hy in
8282
have he: ∃ m : ℤ, y ^ m ≤ x, from
8383
⟨-N, le_of_lt (by rw [(fpow_neg y (↑N)), one_div_eq_inv];
84-
exact (inv_lt hx (lt_trans (inv_pos hx) hN)).1 hN)⟩,
84+
exact (inv_lt hx (lt_trans (inv_pos.2 hx) hN)).1 hN)⟩,
8585
let ⟨M, hM⟩ := pow_unbounded_of_one_lt x hy in
8686
have hb: ∃ b : ℤ, ∀ m, y ^ m ≤ x → m ≤ b, from
8787
⟨M, λ m hm, le_of_not_lt (λ hlt, not_lt_of_ge
@@ -95,7 +95,7 @@ but with ≤ and < the other way around. -/
9595
lemma exists_int_pow_near' [discrete_linear_ordered_field α] [archimedean α]
9696
{x : α} {y : α} (hx : 0 < x) (hy : 1 < y) :
9797
∃ n : ℤ, y ^ n < x ∧ x ≤ y ^ (n + 1) :=
98-
let ⟨m, hle, hlt⟩ := exists_int_pow_near (inv_pos hx) hy in
98+
let ⟨m, hle, hlt⟩ := exists_int_pow_near (inv_pos.2 hx) hy in
9999
have hyp : 0 < y, from lt_trans (discrete_linear_ordered_field.zero_lt_one α) hy,
100100
⟨-(m+1),
101101
by rwa [fpow_neg, one_div_eq_inv, inv_lt (fpow_pos_of_pos hyp _) hx],
@@ -180,7 +180,7 @@ begin
180180
cases exists_nat_gt (y - x)⁻¹ with n nh,
181181
cases exists_floor (x * n) with z zh,
182182
refine ⟨(z + 1 : ℤ) / n, _⟩,
183-
have n0 := nat.cast_pos.1 (lt_trans (inv_pos (sub_pos.2 h)) nh),
183+
have n0 := nat.cast_pos.1 (lt_trans (inv_pos.2 (sub_pos.2 h)) nh),
184184
have n0' := (@nat.cast_pos α _ _).2 n0,
185185
rw [rat.cast_div_of_ne_zero, rat.cast_coe_nat, rat.cast_coe_int, div_lt_iff n0'],
186186
refine ⟨(lt_div_iff n0').2 $

src/algebra/ordered_field.lean

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,21 @@ variables {α : Type*} [linear_ordered_field α] {a b c d : α}
1010

1111
lemma div_pos : 0 < a → 0 < b → 0 < a / b := div_pos_of_pos_of_pos
1212

13-
lemma inv_pos {a : α} : 0 < a → 0 < a⁻¹ :=
14-
by rw [inv_eq_one_div]; exact div_pos zero_lt_one
13+
@[simp] lemma inv_pos : ∀ {a : α}, 0 < a⁻¹ ↔ 0 < a :=
14+
suffices ∀ a : α, 0 < a → 0 < a⁻¹,
15+
from λ a, ⟨λ h, inv_inv'' a ▸ this _ h, this a⟩,
16+
λ a, one_div_eq_inv a ▸ one_div_pos_of_pos
1517

16-
lemma inv_lt_zero {a : α} : a < 0 → a⁻¹ < 0 :=
17-
by rw [inv_eq_one_div]; exact div_neg_of_pos_of_neg zero_lt_one
18+
@[simp] lemma inv_lt_zero : ∀ {a : α}, a⁻¹ < 0 ↔ a < 0 :=
19+
suffices ∀ a : α, a < 0 → a⁻¹ < 0,
20+
from λ a, ⟨λ h, inv_inv'' a ▸ this _ h, this a⟩,
21+
λ a, one_div_eq_inv a ▸ one_div_neg_of_neg
22+
23+
@[simp] lemma inv_nonneg {a : α} : 0 ≤ a⁻¹ ↔ 0 ≤ a :=
24+
le_iff_le_iff_lt_iff_lt.2 inv_lt_zero
25+
26+
@[simp] lemma inv_nonpos {a : α} : a⁻¹ ≤ 0 ↔ a ≤ 0 :=
27+
le_iff_le_iff_lt_iff_lt.2 inv_pos
1828

1929
lemma one_le_div_iff_le (hb : 0 < b) : 1 ≤ a / b ↔ b ≤ a :=
2030
⟨le_of_one_le_div a hb, one_le_div_of_le a hb⟩
@@ -67,10 +77,10 @@ by rw [inv_eq_one_div, div_le_iff ha,
6777
← div_eq_inv_mul, one_le_div_iff_le hb]
6878

6979
lemma inv_le (ha : 0 < a) (hb : 0 < b) : a⁻¹ ≤ b ↔ b⁻¹ ≤ a :=
70-
by rw [← inv_le_inv hb (inv_pos ha), inv_inv']
80+
by rw [← inv_le_inv hb (inv_pos.2 ha), inv_inv']
7181

7282
lemma le_inv (ha : 0 < a) (hb : 0 < b) : a ≤ b⁻¹ ↔ b ≤ a⁻¹ :=
73-
by rw [← inv_le_inv (inv_pos hb) ha, inv_inv']
83+
by rw [← inv_le_inv (inv_pos.2 hb) ha, inv_inv']
7484

7585
lemma one_div_le_one_div (ha : 0 < a) (hb : 0 < b) : 1 / a ≤ 1 / b ↔ b ≤ a :=
7686
by simpa [one_div_eq_inv] using inv_le_inv ha hb
@@ -174,14 +184,31 @@ by haveI := classical.dec_eq α; exact
174184
if ha0 : a = 0 then by simp [ha0]
175185
else (div_le_div_left (lt_of_le_of_ne ha (ne.symm ha0)) (lt_of_lt_of_le hc h) hc).2 h
176186

187+
lemma inv_neg : (-a)⁻¹ = -(a⁻¹) :=
188+
by rwa [inv_eq_one_div, inv_eq_one_div, div_neg_eq_neg_div]
189+
190+
lemma inv_le_inv_of_le {a b : α} (hb : 0 < b) (h : b ≤ a) : a⁻¹ ≤ b⁻¹ :=
191+
begin
192+
rw [inv_eq_one_div, inv_eq_one_div],
193+
exact one_div_le_one_div_of_le hb h
194+
end
195+
196+
lemma div_nonneg' {a b : α} (ha : 0 ≤ a) (hb : 0 ≤ b) : 0 ≤ a / b :=
197+
(lt_or_eq_of_le hb).elim (div_nonneg ha) (λ h, by simp [h.symm])
198+
199+
lemma div_le_div_of_le_of_nonneg {a b c : α} (hab : a ≤ b) (hc : 0 ≤ c) :
200+
a / c ≤ b / c :=
201+
mul_le_mul_of_nonneg_right hab (inv_nonneg.2 hc)
202+
203+
177204
end linear_ordered_field
178205

179206
namespace nat
180207

181208
variables {α : Type*} [linear_ordered_field α]
182209

183210
lemma inv_pos_of_nat {n : ℕ} : 0 < ((n : α) + 1)⁻¹ :=
184-
inv_pos $ add_pos_of_nonneg_of_pos n.cast_nonneg zero_lt_one
211+
inv_pos.2 $ add_pos_of_nonneg_of_pos n.cast_nonneg zero_lt_one
185212

186213
lemma one_div_pos_of_nat {n : ℕ} : 0 < 1 / ((n : α) + 1) :=
187214
by { rw one_div_eq_inv, exact inv_pos_of_nat }
@@ -197,37 +224,9 @@ end nat
197224
section
198225
variables {α : Type*} [discrete_linear_ordered_field α] (a b c : α)
199226

200-
@[simp] lemma inv_pos' {a : α} : 0 < a⁻¹ ↔ 0 < a :=
201-
by rw [inv_eq_one_div]; exact pos_of_one_div_pos, inv_pos⟩
202-
203-
@[simp] lemma inv_neg' {a : α} : a⁻¹ < 0 ↔ a < 0 :=
204-
by rw [inv_eq_one_div]; exact neg_of_one_div_neg, inv_lt_zero⟩
205-
206-
@[simp] lemma inv_nonneg {a : α} : 0 ≤ a⁻¹ ↔ 0 ≤ a :=
207-
le_iff_le_iff_lt_iff_lt.2 inv_neg'
208-
209-
@[simp] lemma inv_nonpos {a : α} : a⁻¹ ≤ 0 ↔ a ≤ 0 :=
210-
le_iff_le_iff_lt_iff_lt.2 inv_pos'
211-
212227
lemma abs_inv : abs a⁻¹ = (abs a)⁻¹ :=
213228
have h : abs (1 / a) = 1 / abs a,
214229
begin rw [abs_div, abs_of_nonneg], exact zero_le_one end,
215230
by simp [*] at *
216231

217-
lemma inv_neg : (-a)⁻¹ = -(a⁻¹) :=
218-
by rwa [inv_eq_one_div, inv_eq_one_div, div_neg_eq_neg_div]
219-
220-
lemma inv_le_inv_of_le {a b : α} (hb : 0 < b) (h : b ≤ a) : a⁻¹ ≤ b⁻¹ :=
221-
begin
222-
rw [inv_eq_one_div, inv_eq_one_div],
223-
exact one_div_le_one_div_of_le hb h
224-
end
225-
226-
lemma div_nonneg' {a b : α} (ha : 0 ≤ a) (hb : 0 ≤ b) : 0 ≤ a / b :=
227-
(lt_or_eq_of_le hb).elim (div_nonneg ha) (λ h, by simp [h.symm])
228-
229-
lemma div_le_div_of_le_of_nonneg {a b c : α} (hab : a ≤ b) (hc : 0 ≤ c) :
230-
a / c ≤ b / c :=
231-
mul_le_mul_of_nonneg_right hab (inv_nonneg.2 hc)
232-
233232
end

src/analysis/calculus/mean_value.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ begin
115115
(Ioc_mem_nhds_within_Ioi ⟨le_refl _, hy⟩)).exists,
116116
have := le_of_lt (lt_trans hfz hzB),
117117
refine ⟨z, _, hz⟩,
118-
rw [mul_le_mul_left (inv_pos $ sub_pos.2 hz.1), hxB, sub_le_sub_iff_right] at this,
118+
rw [mul_le_mul_left (inv_pos.2 $ sub_pos.2 hz.1), hxB, sub_le_sub_iff_right] at this,
119119
exact this }
120120
end
121121

src/analysis/calculus/tangent_cone.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ begin
157157
rw [← mul_assoc, mul_inv_cancel, one_mul],
158158
exact ne_of_gt c_pos
159159
end },
160-
{ apply mul_pos (inv_pos c_pos) (pow_pos _ _),
160+
{ apply mul_pos (inv_pos.2 c_pos) (pow_pos _ _),
161161
norm_num } },
162162
choose d' hd' using this,
163163
refine ⟨c, λn, (d n, d' n), _, hc, _⟩,
@@ -197,7 +197,7 @@ begin
197197
rw [← mul_assoc, mul_inv_cancel, one_mul],
198198
exact ne_of_gt c_pos
199199
end },
200-
{ apply mul_pos (inv_pos c_pos) (pow_pos _ _),
200+
{ apply mul_pos (inv_pos.2 c_pos) (pow_pos _ _),
201201
norm_num } },
202202
choose d' hd' using this,
203203
refine ⟨c, λn, (d' n, d n), _, hc, _⟩,

src/analysis/complex/exponential.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,13 @@ continuous_iff_continuous_at.2 $ λ x,
342342
begin
343343
rw continuous_at,
344344
let f₁ := λ h:{h:ℝ // 0 < h}, log (x.1 * h.1),
345-
let f₂ := λ y:{y:ℝ // 0 < y}, subtype.mk (x.1 ⁻¹ * y.1) (mul_pos (inv_pos x.2) y.2),
345+
let f₂ := λ y:{y:ℝ // 0 < y}, subtype.mk (x.1 ⁻¹ * y.1) (mul_pos (inv_pos.2 x.2) y.2),
346346
have H1 : tendsto f₁ (𝓝 ⟨1, zero_lt_one⟩) (𝓝 (log (x.1*1))),
347347
have : f₁ = λ h:{h:ℝ // 0 < h}, log x.1 + log h.1,
348348
ext h, rw ← log_mul x.2 h.2,
349349
simp only [this, log_mul x.2 zero_lt_one, log_one],
350350
exact tendsto_const_nhds.add (tendsto.comp tendsto_log_one_zero continuous_at_subtype_val),
351-
have H2 : tendsto f₂ (𝓝 x) (𝓝 ⟨x.1⁻¹ * x.1, mul_pos (inv_pos x.2) x.2⟩),
351+
have H2 : tendsto f₂ (𝓝 x) (𝓝 ⟨x.1⁻¹ * x.1, mul_pos (inv_pos.2 x.2) x.2⟩),
352352
rw tendsto_subtype_rng, exact tendsto_const_nhds.mul continuous_at_subtype_val,
353353
suffices h : tendsto (f₁ ∘ f₂) (𝓝 x) (𝓝 (log x.1)),
354354
begin

src/analysis/convex/basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ lemma convex_iff_div:
162162
begin
163163
assume h x y hx hy a b ha hb hab,
164164
apply h hx hy,
165-
have ha', from mul_le_mul_of_nonneg_left ha (le_of_lt (inv_pos hab)),
165+
have ha', from mul_le_mul_of_nonneg_left ha (le_of_lt (inv_pos.2 hab)),
166166
rwa [mul_zero, ←div_eq_inv_mul] at ha',
167-
have hb', from mul_le_mul_of_nonneg_left hb (le_of_lt (inv_pos hab)),
167+
have hb', from mul_le_mul_of_nonneg_left hb (le_of_lt (inv_pos.2 hab)),
168168
rwa [mul_zero, ←div_eq_inv_mul] at hb',
169169
rw [←add_div],
170170
exact div_self (ne_of_lt hab).symm

src/analysis/convex/cone.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ lemma add_mem ⦃x⦄ (hx : x ∈ S) ⦃y⦄ (hy : y ∈ S) : x + y ∈ S := S.a
100100
lemma smul_mem_iff {c : ℝ} (hc : 0 < c) {x : E} :
101101
c • x ∈ S ↔ x ∈ S :=
102102
⟨λ h, by simpa only [smul_smul, inv_mul_cancel (ne_of_gt hc), one_smul]
103-
using S.smul_mem (inv_pos hc) h, λ h, S.smul_mem hc h⟩
103+
using S.smul_mem (inv_pos.2 hc) h, λ h, S.smul_mem hc h⟩
104104

105105
lemma convex : convex (S : set E) :=
106106
convex_iff_forall_pos.2 $ λ x y hx hy a b ha hb hab,
@@ -217,9 +217,9 @@ lemma mem_to_cone' : x ∈ hs.to_cone s ↔ ∃ c > 0, (c : ℝ) • x ∈ s :=
217217
begin
218218
refine hs.mem_to_cone.trans ⟨_, _⟩,
219219
{ rintros ⟨c, hc, y, hy, rfl⟩,
220-
exact ⟨c⁻¹, inv_pos hc, by rwa [smul_smul, inv_mul_cancel (ne_of_gt hc), one_smul]⟩ },
220+
exact ⟨c⁻¹, inv_pos.2 hc, by rwa [smul_smul, inv_mul_cancel (ne_of_gt hc), one_smul]⟩ },
221221
{ rintros ⟨c, hc, hcx⟩,
222-
exact ⟨c⁻¹, inv_pos hc, _, hcx, by rw [smul_smul, inv_mul_cancel (ne_of_gt hc), one_smul]⟩ }
222+
exact ⟨c⁻¹, inv_pos.2 hc, _, hcx, by rw [smul_smul, inv_mul_cancel (ne_of_gt hc), one_smul]⟩ }
223223
end
224224

225225
lemma subset_to_cone : s ⊆ hs.to_cone s :=

src/analysis/normed_space/multilinear.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ begin
105105
set C := (1 + ∥f 0∥) * univ.prod (λ(i : ι), δ⁻¹ * ∥c∥),
106106
have C_pos : 0 < C :=
107107
mul_pos (lt_of_lt_of_le zero_lt_one (by simp))
108-
(prod_pos (λi hi, mul_pos (inv_pos δ_pos) (lt_of_le_of_lt zero_le_one hc))),
108+
(prod_pos (λi hi, mul_pos (inv_pos.2 δ_pos) (lt_of_le_of_lt zero_le_one hc))),
109109
refine ⟨C, C_pos, λm, _⟩,
110110
/- Given a general point `m`, rescale each coordinate to bring it to `[δ/∥c∥, δ]` by multiplication
111111
by a power of a scalar `c` with norm `∥c∥ > 1`.-/

src/analysis/normed_space/operator_norm.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ begin
155155
exact lt_of_le_of_lt ha (half_lt_self ε_pos) },
156156
simpa using this },
157157
rcases normed_field.exists_one_lt_norm 𝕜 with ⟨c, hc⟩,
158-
refine ⟨δ⁻¹ * ∥c∥, mul_pos (inv_pos δ_pos) (lt_trans zero_lt_one hc), (λx, _)⟩,
158+
refine ⟨δ⁻¹ * ∥c∥, mul_pos (inv_pos.2 δ_pos) (lt_trans zero_lt_one hc), (λx, _)⟩,
159159
by_cases h : x = 0,
160160
{ simp only [h, norm_zero, mul_zero, linear_map.map_zero] },
161161
{ rcases rescale_to_shell hc δ_pos h with ⟨d, hd, dxle, ledx, dinv⟩,

src/analysis/specific_limits.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ constant also tends to infinity. -/
8282
lemma tendsto_at_top_div [linear_ordered_field α]
8383
{l : filter β} {r : α} (hr : 0 < r) {f : β → α} (hf : tendsto f l at_top) :
8484
tendsto (λx, f x / r) l at_top :=
85-
tendsto_at_top_mul_right' (inv_pos hr) hf
85+
tendsto_at_top_mul_right' (inv_pos.2 hr) hf
8686

8787
/-- The function `x ↦ x⁻¹` tends to `+∞` on the right of `0`. -/
8888
lemma tendsto_inv_zero_at_top [discrete_linear_ordered_field α] [topological_space α]
@@ -106,8 +106,8 @@ begin
106106
rcases hs with ⟨C, C0, hC⟩,
107107
change 0 < C at C0,
108108
refine filter.mem_map.2 (mem_sets_of_superset (mem_at_top C⁻¹) (λ x hx, hC _)),
109-
have : 0 < x, from lt_of_lt_of_le (inv_pos C0) hx,
110-
exact ⟨inv_pos this, (inv_le C0 this).1 hx⟩
109+
have : 0 < x, from lt_of_lt_of_le (inv_pos.2 C0) hx,
110+
exact ⟨inv_pos.2 this, (inv_le C0 this).1 hx⟩
111111
end
112112

113113
lemma tendsto_inv_at_top_zero [discrete_linear_ordered_field α] [topological_space α]

0 commit comments

Comments
 (0)