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

Commit 03374ee

Browse files
committed
feat(algebra/order/field): Linearly ordered semifields (#15027)
Define `linear_ordered_semifield` and generalize lemmas within `algebra.order.field`.
1 parent 55ec65a commit 03374ee

File tree

6 files changed

+427
-418
lines changed

6 files changed

+427
-418
lines changed

src/algebra/field_power.lean

Lines changed: 82 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,57 @@ This file collects basic facts about the operation of raising an element of a `d
1414
integer power. More specialised results are provided in the case of a linearly ordered field.
1515
-/
1616

17-
universe u
17+
open function int
1818

19-
@[simp] lemma ring_hom.map_zpow {K L : Type*} [division_ring K] [division_ring L] (f : K →+* L) :
20-
∀ (a : K) (n : ℤ), f (a ^ n) = f a ^ n :=
19+
variables {α β : Type*}
20+
21+
section division_ring
22+
variables [division_ring α] [division_ring β]
23+
24+
@[simp] lemma ring_hom.map_zpow (f : α →+* β) : ∀ (a : α) (n : ℤ), f (a ^ n) = f a ^ n :=
2125
f.to_monoid_with_zero_hom.map_zpow
2226

23-
@[simp] lemma ring_equiv.map_zpow {K L : Type*} [division_ring K] [division_ring L] (f : K ≃+* L) :
24-
∀ (a : K) (n : ℤ), f (a ^ n) = f a ^ n :=
27+
@[simp] lemma ring_equiv.map_zpow (f : α ≃+* β) : ∀ (a : α) (n : ℤ), f (a ^ n) = f a ^ n :=
2528
f.to_ring_hom.map_zpow
2629

27-
@[simp] lemma zpow_bit1_neg {K : Type*} [division_ring K] (x : K) (n : ℤ) :
28-
(-x) ^ (bit1 n) = - x ^ bit1 n :=
30+
@[simp] lemma zpow_bit1_neg (x : α) (n : ℤ) : (-x) ^ bit1 n = - x ^ bit1 n :=
2931
by rw [zpow_bit1', zpow_bit1', neg_mul_neg, neg_mul_eq_mul_neg]
3032

31-
section ordered_field_power
32-
open int
33+
@[simp, norm_cast] lemma rat.cast_zpow [char_zero α] (q : ℚ) (n : ℤ) : ((q ^ n : ℚ) : α) = q ^ n :=
34+
(rat.cast_hom α).map_zpow q n
3335

34-
variables {K : Type u} [linear_ordered_field K] {a : K} {n : ℤ}
36+
end division_ring
3537

36-
lemma zpow_nonneg {a : K} (ha : 0 ≤ a) : ∀ (z : ℤ), 0 ≤ a ^ z
38+
section linear_ordered_semifield
39+
variables [linear_ordered_semifield α] {a b x : α} {m n : ℤ}
40+
41+
lemma zpow_nonneg (ha : 0 ≤ a) : ∀ (z : ℤ), 0 ≤ a ^ z
3742
| (n : ℕ) := by { rw zpow_coe_nat, exact pow_nonneg ha _ }
3843
| -[1+n] := by { rw zpow_neg_succ_of_nat, exact inv_nonneg.2 (pow_nonneg ha _) }
3944

40-
lemma zpow_pos_of_pos {a : K} (ha : 0 < a) : ∀ (z : ℤ), 0 < a ^ z
45+
lemma zpow_pos_of_pos (ha : 0 < a) : ∀ (z : ℤ), 0 < a ^ z
4146
| (n : ℕ) := by { rw zpow_coe_nat, exact pow_pos ha _ }
4247
| -[1+n] := by { rw zpow_neg_succ_of_nat, exact inv_pos.2 (pow_pos ha _) }
4348

44-
lemma zpow_le_of_le {x : K} (hx : 1x) {a b : ℤ} (h : ab) : x ^ ax ^ b :=
49+
lemma zpow_le_of_le (ha : 1a) (h : mn) : a ^ ma ^ n :=
4550
begin
46-
induction a with a a; induction b with b b,
51+
induction m with m m; induction n with n n,
4752
{ simp only [of_nat_eq_coe, zpow_coe_nat],
48-
apply pow_le_pow hx,
49-
apply le_of_coe_nat_le_coe_nat h },
50-
{ apply absurd h,
51-
apply not_le_of_gt,
52-
exact lt_of_lt_of_le (neg_succ_lt_zero _) (of_nat_nonneg _) },
53+
exact pow_le_pow ha (le_of_coe_nat_le_coe_nat h) },
54+
{ cases h.not_lt ((neg_succ_lt_zero _).trans_le $ of_nat_nonneg _) },
5355
{ simp only [zpow_neg_succ_of_nat, one_div, of_nat_eq_coe, zpow_coe_nat],
54-
apply le_trans (inv_le_one _); apply one_le_pow_of_one_le hx },
56+
apply le_trans (inv_le_one _); apply one_le_pow_of_one_le ha },
5557
{ simp only [zpow_neg_succ_of_nat],
5658
apply (inv_le_inv _ _).2,
57-
{ apply pow_le_pow hx,
58-
have : -(↑(a+1) : ℤ) ≤ -(↑(b+1) : ℤ), from h,
59+
{ apply pow_le_pow ha,
60+
have : -(↑(m+1) : ℤ) ≤ -(↑(n+1) : ℤ), from h,
5961
have h' := le_of_neg_le_neg this,
6062
apply le_of_coe_nat_le_coe_nat h' },
61-
repeat { apply pow_pos (lt_of_lt_of_le zero_lt_one hx) } }
63+
repeat { apply pow_pos (zero_lt_one.trans_le ha) } }
6264
end
6365

64-
lemma pow_le_max_of_min_le {x : K} (hx : 1 ≤ x) {a b c : ℤ} (h : min a b ≤ c) :
65-
x ^ (-c) ≤ max (x ^ (-a)) (x ^ (-b)) :=
66+
lemma pow_le_max_of_min_le (hx : 1 ≤ x) {a b c : ℤ} (h : min a b ≤ c) :
67+
x ^ (-c) ≤ max (x ^ (-a)) (x ^ (-b)) :=
6668
begin
6769
wlog hle : a ≤ b,
6870
have hnle : -b ≤ -a, from neg_le_neg hle,
@@ -73,104 +75,54 @@ begin
7375
simpa only [max_eq_left hfle]
7476
end
7577

76-
lemma zpow_le_one_of_nonpos {p : K} (hp : 1 ≤ p) {z : ℤ} (hz : z ≤ 0) : p ^ z ≤ 1 :=
77-
calc p ^ z ≤ p ^ 0 : zpow_le_of_le hp hz
78-
... = 1 : by simp
79-
80-
lemma one_le_zpow_of_nonneg {p : K} (hp : 1 ≤ p) {z : ℤ} (hz : 0 ≤ z) : 1 ≤ p ^ z :=
81-
calc p ^ z ≥ p ^ 0 : zpow_le_of_le hp hz
82-
... = 1 : by simp
83-
84-
theorem zpow_bit0_nonneg (a : K) (n : ℤ) : 0 ≤ a ^ bit0 n :=
85-
by { rw zpow_bit0, exact mul_self_nonneg _ }
86-
87-
theorem zpow_two_nonneg (a : K) : 0 ≤ a ^ (2 : ℤ) :=
88-
zpow_bit0_nonneg a 1
89-
90-
theorem zpow_bit0_pos {a : K} (h : a ≠ 0) (n : ℤ) : 0 < a ^ bit0 n :=
91-
(zpow_bit0_nonneg a n).lt_of_ne (zpow_ne_zero _ h).symm
92-
93-
theorem zpow_two_pos_of_ne_zero (a : K) (h : a ≠ 0) : 0 < a ^ (2 : ℤ) :=
94-
zpow_bit0_pos h 1
95-
96-
@[simp] theorem zpow_bit1_neg_iff : a ^ bit1 n < 0 ↔ a < 0 :=
97-
⟨λ h, not_le.1 $ λ h', not_le.2 h $ zpow_nonneg h' _,
98-
λ h, by rw [bit1, zpow_add_one₀ h.ne]; exact mul_neg_of_pos_of_neg (zpow_bit0_pos h.ne _) h⟩
78+
lemma zpow_le_one_of_nonpos (ha : 1 ≤ a) (hn : n ≤ 0) : a ^ n ≤ 1 :=
79+
(zpow_le_of_le ha hn).trans_eq $ zpow_zero _
9980

100-
@[simp] theorem zpow_bit1_nonneg_iff : 0 ≤ a ^ bit1 n ↔ 0 ≤ a :=
101-
le_iff_le_iff_lt_iff_lt.2 zpow_bit1_neg_iff
81+
lemma one_le_zpow_of_nonneg (ha : 1 ≤ a) (hn : 0 ≤ n) : 1 ≤ a ^ n :=
82+
(zpow_zero _).symm.trans_le $ zpow_le_of_le ha hn
10283

103-
@[simp] theorem zpow_bit1_nonpos_iff : a ^ bit1 n ≤ 0 ↔ a ≤ 0 :=
104-
begin
105-
rw [le_iff_lt_or_eq, zpow_bit1_neg_iff],
106-
split,
107-
{ rintro (h | h),
108-
{ exact h.le },
109-
{ exact (zpow_eq_zero h).le } },
110-
{ intro h,
111-
rcases eq_or_lt_of_le h with rfl|h,
112-
{ exact or.inr (zero_zpow _ (bit1_ne_zero n)) },
113-
{ exact or.inl h } }
114-
end
115-
116-
@[simp] theorem zpow_bit1_pos_iff : 0 < a ^ bit1 n ↔ 0 < a :=
117-
lt_iff_lt_of_le_iff_le zpow_bit1_nonpos_iff
84+
protected lemma nat.zpow_pos_of_pos {a : ℕ} (h : 0 < a) (n : ℤ) : 0 < (a : α)^n :=
85+
by { apply zpow_pos_of_pos, exact_mod_cast h }
11886

119-
end ordered_field_power
87+
lemma nat.zpow_ne_zero_of_pos {a : ℕ} (h : 0 < a) (n : ℤ) : (a : α)^n ≠ 0 :=
88+
(nat.zpow_pos_of_pos h n).ne'
12089

121-
lemma one_lt_zpow {K} [linear_ordered_field K] {p : K} (hp : 1 < p) :
122-
∀ z : ℤ, 0 < z → 1 < p ^ z
123-
| (n : ℕ) h := (zpow_coe_nat p n).symm.subst (one_lt_pow hp $ int.coe_nat_ne_zero.mp h.ne')
90+
lemma one_lt_zpow (ha : 1 < a) : ∀ n : ℤ, 0 < n → 1 < a ^ n
91+
| (n : ℕ) h := (zpow_coe_nat _ _).symm.subst (one_lt_pow ha $ int.coe_nat_ne_zero.mp h.ne')
12492
| -[1+ n] h := ((int.neg_succ_not_pos _).mp h).elim
12593

126-
section ordered
127-
variables {K : Type*} [linear_ordered_field K]
128-
129-
lemma nat.zpow_pos_of_pos {p : ℕ} (h : 0 < p) (n:ℤ) : 0 < (p:K)^n :=
130-
by { apply zpow_pos_of_pos, exact_mod_cast h }
131-
132-
lemma nat.zpow_ne_zero_of_pos {p : ℕ} (h : 0 < p) (n:ℤ) : (p:K)^n ≠ 0 :=
133-
ne_of_gt (nat.zpow_pos_of_pos h n)
134-
135-
lemma zpow_strict_mono {x : K} (hx : 1 < x) :
136-
strict_mono (λ n:ℤ, x ^ n) :=
94+
lemma zpow_strict_mono (hx : 1 < x) : strict_mono ((^) x : ℤ → α) :=
13795
strict_mono_int_of_lt_succ $ λ n,
13896
have xpos : 0 < x, from zero_lt_one.trans hx,
13997
calc x ^ n < x ^ n * x : lt_mul_of_one_lt_right (zpow_pos_of_pos xpos _) hx
14098
... = x ^ (n + 1) : (zpow_add_one₀ xpos.ne' _).symm
14199

142-
lemma zpow_strict_anti {x : K} (h₀ : 0 < x) (h₁ : x < 1) : strict_anti (λ n : ℤ, x ^ n) :=
100+
lemma zpow_strict_anti (h₀ : 0 < x) (h₁ : x < 1) : strict_anti ((^) x : ℤ → α) :=
143101
strict_anti_int_of_succ_lt $ λ n,
144102
calc x ^ (n + 1) = x ^ n * x : zpow_add_one₀ h₀.ne' _
145103
... < x ^ n * 1 : (mul_lt_mul_left $ zpow_pos_of_pos h₀ _).2 h₁
146104
... = x ^ n : mul_one _
147105

148-
@[simp] lemma zpow_lt_iff_lt {x : K} (hx : 1 < x) {m n : ℤ} :
149-
x ^ m < x ^ n ↔ m < n :=
150-
(zpow_strict_mono hx).lt_iff_lt
106+
@[simp] lemma zpow_lt_iff_lt (hx : 1 < x) : x ^ m < x ^ n ↔ m < n := (zpow_strict_mono hx).lt_iff_lt
107+
@[simp] lemma zpow_le_iff_le (hx : 1 < x) : x ^ m ≤ x ^ n ↔ m ≤ n := (zpow_strict_mono hx).le_iff_le
151108

152-
@[simp] lemma zpow_le_iff_le {x : K} (hx : 1 < x) {m n : ℤ} :
153-
x ^ m ≤ x ^ n ↔ m ≤ n :=
154-
(zpow_strict_mono hx).le_iff_le
155-
156-
lemma min_le_of_zpow_le_max {x : K} (hx : 1 < x) {a b c : ℤ}
157-
(h_max : x ^ (-c) ≤ max (x ^ (-a)) (x ^ (-b)) ) : min a b ≤ c :=
109+
lemma min_le_of_zpow_le_max (hx : 1 < x) {a b c : ℤ}
110+
(h_max : x ^ (-c) ≤ max (x ^ (-a)) (x ^ (-b))) : min a b ≤ c :=
158111
begin
159112
rw min_le_iff,
160113
refine or.imp (λ h, _) (λ h, _) (le_max_iff.mp h_max);
161114
rwa [zpow_le_iff_le hx, neg_le_neg_iff] at h
162115
end
163116

164-
@[simp] lemma pos_div_pow_pos {a b : K} (ha : 0 < a) (hb : 0 < b) (k : ℕ) : 0 < a/b^k :=
117+
@[simp] lemma pos_div_pow_pos (ha : 0 < a) (hb : 0 < b) (k : ℕ) : 0 < a/b^k :=
165118
div_pos ha (pow_pos hb k)
166119

167-
@[simp] lemma div_pow_le {a b : K} (ha : 0 < a) (hb : 1 ≤ b) (k : ℕ) : a/b^k ≤ a :=
120+
@[simp] lemma div_pow_le (ha : 0 < a) (hb : 1 ≤ b) (k : ℕ) : a/b^k ≤ a :=
168121
(div_le_iff $ pow_pos (lt_of_lt_of_le zero_lt_one hb) k).mpr
169122
(calc a = a * 1 : (mul_one a).symm
170123
... ≤ a*b^k : (mul_le_mul_left ha).mpr $ one_le_pow_of_one_le hb _)
171124

172-
lemma zpow_injective {x : K} (h₀ : 0 < x) (h₁ : x ≠ 1) :
173-
function.injective ((^) x : ℤ → K) :=
125+
lemma zpow_injective (h₀ : 0 < x) (h₁ : x ≠ 1) : injective ((^) x : ℤ → α) :=
174126
begin
175127
intros m n h,
176128
rcases h₁.lt_or_lt with H|H,
@@ -181,17 +133,45 @@ begin
181133
{ exact (zpow_strict_mono H).injective h, },
182134
end
183135

184-
@[simp] lemma zpow_inj {x : K} (h₀ : 0 < x) (h₁ : x ≠ 1) {m n : ℤ} :
185-
x ^ m = x ^ n ↔ m = n :=
136+
@[simp] lemma zpow_inj (h₀ : 0 < x) (h₁ : x ≠ 1) : x ^ m = x ^ n ↔ m = n :=
186137
(zpow_injective h₀ h₁).eq_iff
187138

188-
end ordered
139+
end linear_ordered_semifield
140+
141+
section linear_ordered_field
142+
variables [linear_ordered_field α] {a x : α} {m n : ℤ}
143+
144+
lemma zpow_bit0_nonneg (a : α) (n : ℤ) : 0 ≤ a ^ bit0 n :=
145+
(mul_self_nonneg _).trans_eq $ (zpow_bit0 _ _).symm
146+
147+
lemma zpow_two_nonneg (a : α) : 0 ≤ a ^ (2 : ℤ) := zpow_bit0_nonneg _ _
189148

190-
section
191-
variables {K : Type*} [division_ring K]
149+
lemma zpow_bit0_pos (h : a ≠ 0) (n : ℤ) : 0 < a ^ bit0 n :=
150+
(zpow_bit0_nonneg a n).lt_of_ne (zpow_ne_zero _ h).symm
151+
152+
lemma zpow_two_pos_of_ne_zero (h : a ≠ 0) : 0 < a ^ (2 : ℤ) := zpow_bit0_pos h _
153+
154+
@[simp] theorem zpow_bit1_neg_iff : a ^ bit1 n < 0 ↔ a < 0 :=
155+
⟨λ h, not_le.1 $ λ h', not_le.2 h $ zpow_nonneg h' _,
156+
λ h, by rw [bit1, zpow_add_one₀ h.ne]; exact mul_neg_of_pos_of_neg (zpow_bit0_pos h.ne _) h⟩
192157

193-
@[simp, norm_cast] theorem rat.cast_zpow [char_zero K] (q : ℚ) (n : ℤ) :
194-
((q ^ n : ℚ) : K) = q ^ n :=
195-
(rat.cast_hom K).map_zpow q n
158+
@[simp] theorem zpow_bit1_nonneg_iff : 0 ≤ a ^ bit1 n ↔ 0 ≤ a :=
159+
le_iff_le_iff_lt_iff_lt.2 zpow_bit1_neg_iff
196160

161+
@[simp] theorem zpow_bit1_nonpos_iff : a ^ bit1 n ≤ 0 ↔ a ≤ 0 :=
162+
begin
163+
rw [le_iff_lt_or_eq, zpow_bit1_neg_iff],
164+
split,
165+
{ rintro (h | h),
166+
{ exact h.le },
167+
{ exact (zpow_eq_zero h).le } },
168+
{ intro h,
169+
rcases eq_or_lt_of_le h with rfl|h,
170+
{ exact or.inr (zero_zpow _ (bit1_ne_zero n)) },
171+
{ exact or.inl h } }
197172
end
173+
174+
@[simp] theorem zpow_bit1_pos_iff : 0 < a ^ bit1 n ↔ 0 < a :=
175+
lt_iff_lt_of_le_iff_le zpow_bit1_nonpos_iff
176+
177+
end linear_ordered_field

0 commit comments

Comments
 (0)