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

Commit 8658f40

Browse files
committed
feat(algebra/group_power/order): Sign of an odd/even power without linearity (#10122)
This proves that `a < 0 → 0 < a ^ bit0 n` and `a < 0 → a ^ bit1 n < 0` in an `ordered_semiring`.
1 parent 4770a6a commit 8658f40

File tree

2 files changed

+50
-29
lines changed

2 files changed

+50
-29
lines changed

src/algebra/group_power/lemmas.lean

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import data.equiv.mul_add
1515
# Lemmas about power operations on monoids and groups
1616
1717
This file contains lemmas about `monoid.pow`, `group.pow`, `nsmul`, `zsmul`
18-
which require additional imports besides those available in `.basic`.
18+
which require additional imports besides those available in `algebra.group_power.basic`.
1919
-/
2020

2121
universes u v w x y z u₁ u₂
@@ -418,11 +418,11 @@ lemma neg_one_pow_eq_pow_mod_two [ring R] {n : ℕ} : (-1 : R) ^ n = (-1) ^ (n %
418418
by rw [← nat.mod_add_div n 2, pow_add, pow_mul]; simp [sq]
419419

420420
section ordered_semiring
421-
variable [ordered_semiring R]
421+
variables [ordered_semiring R] {a : R}
422422

423423
/-- Bernoulli's inequality. This version works for semirings but requires
424424
additional hypotheses `0 ≤ a * a` and `0 ≤ (1 + a) * (1 + a)`. -/
425-
theorem one_add_mul_le_pow' {a : R} (Hsq : 0 ≤ a * a) (Hsq' : 0 ≤ (1 + a) * (1 + a))
425+
theorem one_add_mul_le_pow' (Hsq : 0 ≤ a * a) (Hsq' : 0 ≤ (1 + a) * (1 + a))
426426
(H : 02 + a) :
427427
∀ (n : ℕ), 1 + (n : R) * a ≤ (1 + a) ^ n
428428
| 0 := by simp
@@ -439,7 +439,7 @@ calc 1 + (↑(n + 2) : R) * a ≤ 1 + ↑(n + 2) * a + (n * (a * a * (2 + a)) +
439439
mul_le_mul_of_nonneg_left (one_add_mul_le_pow' n) Hsq'
440440
... = (1 + a)^(n + 2) : by simp only [pow_succ, mul_assoc]
441441

442-
private lemma pow_lt_pow_of_lt_one_aux {a : R} (h : 0 < a) (ha : a < 1) (i : ℕ) :
442+
private lemma pow_lt_pow_of_lt_one_aux (h : 0 < a) (ha : a < 1) (i : ℕ) :
443443
∀ k : ℕ, a ^ (i + k + 1) < a ^ i
444444
| 0 :=
445445
begin
@@ -454,33 +454,33 @@ private lemma pow_lt_pow_of_lt_one_aux {a : R} (h : 0 < a) (ha : a < 1) (i : ℕ
454454
{ show 0 < a ^ (i + (k + 1) + 0), apply pow_pos h }
455455
end
456456

457-
private lemma pow_le_pow_of_le_one_aux {a : R} (h : 0 ≤ a) (ha : a ≤ 1) (i : ℕ) :
457+
private lemma pow_le_pow_of_le_one_aux (h : 0 ≤ a) (ha : a ≤ 1) (i : ℕ) :
458458
∀ k : ℕ, a ^ (i + k) ≤ a ^ i
459459
| 0 := by simp
460460
| (k+1) := by { rw [←add_assoc, ←one_mul (a^i), pow_succ],
461461
exact mul_le_mul ha (pow_le_pow_of_le_one_aux _) (pow_nonneg h _) zero_le_one }
462462

463-
lemma pow_lt_pow_of_lt_one {a : R} (h : 0 < a) (ha : a < 1)
463+
lemma pow_lt_pow_of_lt_one (h : 0 < a) (ha : a < 1)
464464
{i j : ℕ} (hij : i < j) : a ^ j < a ^ i :=
465465
let ⟨k, hk⟩ := nat.exists_eq_add_of_lt hij in
466466
by rw hk; exact pow_lt_pow_of_lt_one_aux h ha _ _
467467

468-
lemma pow_lt_pow_iff_of_lt_one {a : R} {n m : ℕ} (hpos : 0 < a) (h : a < 1) :
468+
lemma pow_lt_pow_iff_of_lt_one {n m : ℕ} (hpos : 0 < a) (h : a < 1) :
469469
a ^ m < a ^ n ↔ n < m :=
470470
begin
471471
have : strict_mono (λ (n : order_dual ℕ), a ^ (id n : ℕ)) := λ m n, pow_lt_pow_of_lt_one hpos h,
472472
exact this.lt_iff_lt
473473
end
474474

475-
lemma pow_le_pow_of_le_one {a : R} (h : 0 ≤ a) (ha : a ≤ 1) {i j : ℕ} (hij : i ≤ j) :
475+
lemma pow_le_pow_of_le_one (h : 0 ≤ a) (ha : a ≤ 1) {i j : ℕ} (hij : i ≤ j) :
476476
a ^ j ≤ a ^ i :=
477477
let ⟨k, hk⟩ := nat.exists_eq_add_of_le hij in
478478
by rw hk; exact pow_le_pow_of_le_one_aux h ha _ _
479479

480-
lemma pow_le_of_le_one {a : R} (h₀ : 0 ≤ a) (h₁ : a ≤ 1) {n : ℕ} (hn : n ≠ 0) : a ^ n ≤ a :=
480+
lemma pow_le_of_le_one (h₀ : 0 ≤ a) (h₁ : a ≤ 1) {n : ℕ} (hn : n ≠ 0) : a ^ n ≤ a :=
481481
(pow_one a).subst (pow_le_pow_of_le_one h₀ h₁ (nat.pos_of_ne_zero hn))
482482

483-
lemma sq_le {a : R} (h₀ : 0 ≤ a) (h₁ : a ≤ 1) : a ^ 2 ≤ a := pow_le_of_le_one h₀ h₁ two_ne_zero
483+
lemma sq_le (h₀ : 0 ≤ a) (h₁ : a ≤ 1) : a ^ 2 ≤ a := pow_le_of_le_one h₀ h₁ two_ne_zero
484484

485485
end ordered_semiring
486486

@@ -507,8 +507,7 @@ variables [linear_ordered_ring R] {a : R} {n : ℕ}
507507
(pow_abs a n).symm
508508

509509
@[simp] theorem pow_bit1_neg_iff : a ^ bit1 n < 0 ↔ a < 0 :=
510-
⟨λ h, not_le.1 $ λ h', not_le.2 h $ pow_nonneg h' _,
511-
λ h, by { rw [bit1, pow_succ], exact mul_neg_of_neg_of_pos h (pow_bit0_pos h.ne _)}⟩
510+
⟨λ h, not_le.1 $ λ h', not_le.2 h $ pow_nonneg h' _, λ ha, pow_bit1_neg ha n⟩
512511

513512
@[simp] theorem pow_bit1_nonneg_iff : 0 ≤ a ^ bit1 n ↔ 0 ≤ a :=
514513
le_iff_le_iff_lt_iff_lt.2 pow_bit1_neg_iff
@@ -565,6 +564,9 @@ begin
565564
{ exact pow_lt_pow_of_lt_left hab ha (bit1_pos (zero_le n)) }
566565
end
567566

567+
lemma odd.strict_mono_pow (hn : odd n) : strict_mono (λ a : R, a ^ n) :=
568+
by cases hn with k hk; simpa only [hk, two_mul] using strict_mono_pow_bit1 _
569+
568570
/-- Bernoulli's inequality for `n : ℕ`, `-2 ≤ a`. -/
569571
theorem one_add_mul_le_pow (H : -2 ≤ a) (n : ℕ) : 1 + (n : R) * a ≤ (1 + a) ^ n :=
570572
one_add_mul_le_pow' (mul_self_nonneg _) (mul_self_nonneg _) (neg_le_iff_add_nonneg'.1 H) _

src/algebra/group_power/order.lean

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,17 @@ pos_iff_ne_zero.2 $ pow_ne_zero _ H.ne'
124124
end canonically_ordered_comm_semiring
125125

126126
section ordered_semiring
127-
variable [ordered_semiring R]
127+
variables [ordered_semiring R] {a x y : R} {n m : ℕ}
128128

129-
@[simp] theorem pow_pos {a : R} (H : 0 < a) : ∀ (n : ℕ), 0 < a ^ n
129+
@[simp] theorem pow_pos (H : 0 < a) : ∀ (n : ℕ), 0 < a ^ n
130130
| 0 := by { nontriviality, rw pow_zero, exact zero_lt_one }
131131
| (n+1) := by { rw pow_succ, exact mul_pos H (pow_pos _) }
132132

133-
@[simp] theorem pow_nonneg {a : R} (H : 0 ≤ a) : ∀ (n : ℕ), 0 ≤ a ^ n
133+
@[simp] theorem pow_nonneg (H : 0 ≤ a) : ∀ (n : ℕ), 0 ≤ a ^ n
134134
| 0 := by { rw pow_zero, exact zero_le_one}
135135
| (n+1) := by { rw pow_succ, exact mul_nonneg H (pow_nonneg _) }
136136

137-
theorem pow_add_pow_le {x y : R} {n : ℕ} (hx : 0 ≤ x) (hy : 0 ≤ y) (hn : n ≠ 0) :
138-
x ^ n + y ^ n ≤ (x + y) ^ n :=
137+
theorem pow_add_pow_le (hx : 0 ≤ x) (hy : 0 ≤ y) (hn : n ≠ 0) : x ^ n + y ^ n ≤ (x + y) ^ n :=
139138
begin
140139
rcases nat.exists_eq_succ_of_ne_zero hn with ⟨k, rfl⟩,
141140
induction k with k ih, { simp only [pow_one] },
@@ -152,7 +151,7 @@ begin
152151
by { rw [pow_succ _ n], exact mul_le_mul_of_nonneg_left (ih (nat.succ_ne_zero k)) h2 }
153152
end
154153

155-
theorem pow_lt_pow_of_lt_left {x y : R} {n : ℕ} (Hxy : x < y) (Hxpos : 0 ≤ x) (Hnpos : 0 < n) :
154+
theorem pow_lt_pow_of_lt_left (Hxy : x < y) (Hxpos : 0 ≤ x) (Hnpos : 0 < n) :
156155
x ^ n < y ^ n :=
157156
begin
158157
cases lt_or_eq_of_le Hxpos,
@@ -163,42 +162,41 @@ begin
163162
{ rw [←h, zero_pow Hnpos], apply pow_pos (by rwa ←h at Hxy : 0 < y),}
164163
end
165164

166-
lemma pow_lt_one {a : R} (h₀ : 0 ≤ a) (h₁ : a < 1) {n : ℕ} (hn : n ≠ 0) : a ^ n < 1 :=
165+
lemma pow_lt_one (h₀ : 0 ≤ a) (h₁ : a < 1) {n : ℕ} (hn : n ≠ 0) : a ^ n < 1 :=
167166
(one_pow n).subst (pow_lt_pow_of_lt_left h₁ h₀ (nat.pos_of_ne_zero hn))
168167

169-
theorem strict_mono_on_pow {n : ℕ} (hn : 0 < n) :
170-
strict_mono_on (λ x : R, x ^ n) (set.Ici 0) :=
168+
theorem strict_mono_on_pow (hn : 0 < n) : strict_mono_on (λ x : R, x ^ n) (set.Ici 0) :=
171169
λ x hx y hy h, pow_lt_pow_of_lt_left h hx hn
172170

173-
theorem one_le_pow_of_one_le {a : R} (H : 1 ≤ a) : ∀ (n : ℕ), 1 ≤ a ^ n
171+
theorem one_le_pow_of_one_le (H : 1 ≤ a) : ∀ (n : ℕ), 1 ≤ a ^ n
174172
| 0 := by rw [pow_zero]
175173
| (n+1) := by { rw pow_succ, simpa only [mul_one] using mul_le_mul H (one_le_pow_of_one_le n)
176174
zero_le_one (le_trans zero_le_one H) }
177175

178-
lemma pow_mono {a : R} (h : 1 ≤ a) : monotone (λ n : ℕ, a ^ n) :=
176+
lemma pow_mono (h : 1 ≤ a) : monotone (λ n : ℕ, a ^ n) :=
179177
monotone_nat_of_le_succ $ λ n,
180178
by { rw pow_succ, exact le_mul_of_one_le_left (pow_nonneg (zero_le_one.trans h) _) h }
181179

182-
theorem pow_le_pow {a : R} {n m : ℕ} (ha : 1 ≤ a) (h : n ≤ m) : a ^ n ≤ a ^ m :=
180+
theorem pow_le_pow (ha : 1 ≤ a) (h : n ≤ m) : a ^ n ≤ a ^ m :=
183181
pow_mono ha h
184182

185-
lemma strict_mono_pow {a : R} (h : 1 < a) : strict_mono (λ n : ℕ, a ^ n) :=
183+
lemma strict_mono_pow (h : 1 < a) : strict_mono (λ n : ℕ, a ^ n) :=
186184
have 0 < a := zero_le_one.trans_lt h,
187185
strict_mono_nat_of_lt_succ $ λ n, by simpa only [one_mul, pow_succ]
188186
using mul_lt_mul h (le_refl (a ^ n)) (pow_pos this _) this.le
189187

190-
lemma pow_lt_pow {a : R} {n m : ℕ} (h : 1 < a) (h2 : n < m) : a ^ n < a ^ m :=
188+
lemma pow_lt_pow (h : 1 < a) (h2 : n < m) : a ^ n < a ^ m :=
191189
strict_mono_pow h h2
192190

193-
lemma pow_lt_pow_iff {a : R} {n m : ℕ} (h : 1 < a) : a ^ n < a ^ m ↔ n < m :=
191+
lemma pow_lt_pow_iff (h : 1 < a) : a ^ n < a ^ m ↔ n < m :=
194192
(strict_mono_pow h).lt_iff_lt
195193

196194
@[mono] lemma pow_le_pow_of_le_left {a b : R} (ha : 0 ≤ a) (hab : a ≤ b) : ∀ i : ℕ, a^i ≤ b^i
197195
| 0 := by simp
198196
| (k+1) := by { rw [pow_succ, pow_succ],
199197
exact mul_le_mul hab (pow_le_pow_of_le_left _) (pow_nonneg ha _) (le_trans ha hab) }
200198

201-
lemma one_lt_pow {a : R} (ha : 1 < a) : ∀ {n : ℕ}, n ≠ 01 < a ^ n
199+
lemma one_lt_pow (ha : 1 < a) : ∀ {n : ℕ}, n ≠ 01 < a ^ n
202200
| 0 h := (h rfl).elim
203201
| 1 h := (pow_one a).symm.subst ha
204202
| (n + 2) h :=
@@ -208,12 +206,33 @@ lemma one_lt_pow {a : R} (ha : 1 < a) : ∀ {n : ℕ}, n ≠ 0 → 1 < a ^ n
208206
exact mul_lt_mul ha (one_lt_pow (nat.succ_ne_zero _)).le zero_lt_one (zero_lt_one.trans ha).le,
209207
end
210208

211-
lemma pow_le_one {a : R} : ∀ (n : ℕ) (h₀ : 0 ≤ a) (h₁ : a ≤ 1), a ^ n ≤ 1
209+
lemma pow_le_one : ∀ (n : ℕ) (h₀ : 0 ≤ a) (h₁ : a ≤ 1), a ^ n ≤ 1
212210
| 0 h₀ h₁ := (pow_zero a).le
213211
| (n + 1) h₀ h₁ := (pow_succ' a n).le.trans (mul_le_one (pow_le_one n h₀ h₁) h₀ h₁)
214212

213+
lemma sq_pos_of_pos (ha : 0 < a) : 0 < a ^ 2 := by { rw sq, exact mul_pos ha ha }
214+
215215
end ordered_semiring
216216

217+
section ordered_ring
218+
variables [ordered_ring R] {a : R}
219+
220+
lemma sq_pos_of_neg (ha : a < 0) : 0 < a ^ 2 := by { rw sq, exact mul_pos_of_neg_of_neg ha ha }
221+
222+
lemma pow_bit0_pos_of_neg (ha : a < 0) (n : ℕ) : 0 < a ^ bit0 n :=
223+
begin
224+
rw pow_bit0',
225+
exact pow_pos (mul_pos_of_neg_of_neg ha ha) _,
226+
end
227+
228+
lemma pow_bit1_neg (ha : a < 0) (n : ℕ) : a ^ bit1 n < 0 :=
229+
begin
230+
rw [bit1, pow_succ],
231+
exact mul_neg_of_neg_of_pos ha (pow_bit0_pos_of_neg ha n),
232+
end
233+
234+
end ordered_ring
235+
217236
section linear_ordered_semiring
218237
variable [linear_ordered_semiring R]
219238

0 commit comments

Comments
 (0)