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

Commit 6fe0c3b

Browse files
committed
refactor(algebra/group/to_additive + files containing even/odd): move many lemmas involving even/odd to the same file (#12882)
This is the first step in refactoring the definition of `even` to be the `to_additive` of `square`. This PR simply gathers together many (though not all) lemmas that involve `even` or `odd` in their assumptions. The choice of which lemmas to migrate to the file `algebra.parity` was dictated mostly by whether importing `algebra.parity` in the current home would create a cyclic import. The only change that is not a simple shift from a file to another one is the addition in `to_additive` for support to change `square` in a multiplicative name to `even` in an additive name. The change to the test file `test.ring` is due to the fact that the definition of `odd` was no longer imported by the file.
1 parent 958f6b0 commit 6fe0c3b

File tree

9 files changed

+185
-157
lines changed

9 files changed

+185
-157
lines changed

src/algebra/field_power.lean

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ f.to_ring_hom.map_zpow
2828
(-x) ^ (bit0 n) = x ^ bit0 n :=
2929
by rw [zpow_bit0', zpow_bit0', neg_mul_neg]
3030

31-
lemma even.zpow_neg {K : Type*} [division_ring K] {n : ℤ} (h : even n) (a : K) :
32-
(-a) ^ n = a ^ n :=
33-
begin
34-
obtain ⟨k, rfl⟩ := h,
35-
rw [←bit0_eq_two_mul, zpow_bit0_neg],
36-
end
37-
3831
@[simp] lemma zpow_bit1_neg {K : Type*} [division_ring K] (x : K) (n : ℤ) :
3932
(-x) ^ (bit1 n) = - x ^ bit1 n :=
4033
by rw [zpow_bit1', zpow_bit1', neg_mul_neg, neg_mul_eq_mul_neg]
@@ -135,48 +128,6 @@ end
135128
@[simp] theorem zpow_bit1_pos_iff : 0 < a ^ bit1 n ↔ 0 < a :=
136129
lt_iff_lt_of_le_iff_le zpow_bit1_nonpos_iff
137130

138-
lemma even.zpow_nonneg {n : ℤ} (hn : even n) (a : K) :
139-
0 ≤ a ^ n :=
140-
begin
141-
cases le_or_lt 0 a with h h,
142-
{ exact zpow_nonneg h _ },
143-
{ exact (hn.zpow_neg a).subst (zpow_nonneg (neg_nonneg_of_nonpos h.le) _) }
144-
end
145-
146-
theorem even.zpow_pos (hn : even n) (ha : a ≠ 0) : 0 < a ^ n :=
147-
by cases hn with k hk; simpa only [hk, two_mul] using zpow_bit0_pos ha k
148-
149-
theorem odd.zpow_nonneg (hn : odd n) (ha : 0 ≤ a) : 0 ≤ a ^ n :=
150-
by cases hn with k hk; simpa only [hk, two_mul] using zpow_bit1_nonneg_iff.mpr ha
151-
152-
theorem odd.zpow_pos (hn : odd n) (ha : 0 < a) : 0 < a ^ n :=
153-
by cases hn with k hk; simpa only [hk, two_mul] using zpow_bit1_pos_iff.mpr ha
154-
155-
theorem odd.zpow_nonpos (hn : odd n) (ha : a ≤ 0) : a ^ n ≤ 0:=
156-
by cases hn with k hk; simpa only [hk, two_mul] using zpow_bit1_nonpos_iff.mpr ha
157-
158-
theorem odd.zpow_neg (hn : odd n) (ha : a < 0) : a ^ n < 0:=
159-
by cases hn with k hk; simpa only [hk, two_mul] using zpow_bit1_neg_iff.mpr ha
160-
161-
lemma even.zpow_abs {p : ℤ} (hp : even p) (a : K) : |a| ^ p = a ^ p :=
162-
begin
163-
cases abs_choice a with h h;
164-
simp only [h, hp.zpow_neg _],
165-
end
166-
167-
@[simp] lemma zpow_bit0_abs (a : K) (p : ℤ) : |a| ^ bit0 p = a ^ bit0 p :=
168-
(even_bit0 _).zpow_abs _
169-
170-
lemma even.abs_zpow {p : ℤ} (hp : even p) (a : K) : |a ^ p| = a ^ p :=
171-
begin
172-
rw [abs_eq_self],
173-
exact hp.zpow_nonneg _
174-
end
175-
176-
@[simp] lemma abs_zpow_bit0 (a : K) (p : ℤ) :
177-
|a ^ bit0 p| = a ^ bit0 p :=
178-
(even_bit0 _).abs_zpow _
179-
180131
end ordered_field_power
181132

182133
lemma one_lt_zpow {K} [linear_ordered_field K] {p : K} (hp : 1 < p) :

src/algebra/group/to_additive.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ meta def tr : bool → list string → list string
217217
| is_comm ("pow" :: s) := add_comm_prefix is_comm "nsmul" :: tr ff s
218218
| is_comm ("npow" :: s) := add_comm_prefix is_comm "nsmul" :: tr ff s
219219
| is_comm ("zpow" :: s) := add_comm_prefix is_comm "zsmul" :: tr ff s
220+
| is_comm ("is" :: "square" :: s) := add_comm_prefix is_comm "even" :: tr ff s
220221
| is_comm ("monoid" :: s) := ("add_" ++ add_comm_prefix is_comm "monoid") :: tr ff s
221222
| is_comm ("submonoid" :: s) := ("add_" ++ add_comm_prefix is_comm "submonoid") :: tr ff s
222223
| is_comm ("group" :: s) := ("add_" ++ add_comm_prefix is_comm "group") :: tr ff s

src/algebra/group_power/lemmas.lean

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -497,41 +497,6 @@ by simp only [le_iff_lt_or_eq, pow_bit1_neg_iff, pow_eq_zero_iff (bit1_pos (zero
497497
@[simp] theorem pow_bit1_pos_iff : 0 < a ^ bit1 n ↔ 0 < a :=
498498
lt_iff_lt_of_le_iff_le pow_bit1_nonpos_iff
499499

500-
lemma even.pow_nonneg (hn : even n) (a : R) : 0 ≤ a ^ n :=
501-
by cases hn with k hk; simpa only [hk, two_mul] using pow_bit0_nonneg a k
502-
503-
lemma even.pow_pos (hn : even n) (ha : a ≠ 0) : 0 < a ^ n :=
504-
by cases hn with k hk; simpa only [hk, two_mul] using pow_bit0_pos ha k
505-
506-
lemma odd.pow_nonpos (hn : odd n) (ha : a ≤ 0) : a ^ n ≤ 0:=
507-
by cases hn with k hk; simpa only [hk, two_mul] using pow_bit1_nonpos_iff.mpr ha
508-
509-
lemma odd.pow_neg (hn : odd n) (ha : a < 0) : a ^ n < 0:=
510-
by cases hn with k hk; simpa only [hk, two_mul] using pow_bit1_neg_iff.mpr ha
511-
512-
lemma odd.pow_nonneg_iff (hn : odd n) : 0 ≤ a ^ n ↔ 0 ≤ a :=
513-
⟨λ h, le_of_not_lt (λ ha, h.not_lt $ hn.pow_neg ha), λ ha, pow_nonneg ha n⟩
514-
515-
lemma odd.pow_nonpos_iff (hn : odd n) : a ^ n ≤ 0 ↔ a ≤ 0 :=
516-
⟨λ h, le_of_not_lt (λ ha, h.not_lt $ pow_pos ha _), hn.pow_nonpos⟩
517-
518-
lemma odd.pow_pos_iff (hn : odd n) : 0 < a ^ n ↔ 0 < a :=
519-
⟨λ h, lt_of_not_ge' (λ ha, h.not_le $ hn.pow_nonpos ha), λ ha, pow_pos ha n⟩
520-
521-
lemma odd.pow_neg_iff (hn : odd n) : a ^ n < 0 ↔ a < 0 :=
522-
⟨λ h, lt_of_not_ge' (λ ha, h.not_le $ pow_nonneg ha _), hn.pow_neg⟩
523-
524-
lemma even.pow_pos_iff (hn : even n) (h₀ : 0 < n) : 0 < a ^ n ↔ a ≠ 0 :=
525-
⟨λ h ha, by { rw [ha, zero_pow h₀] at h, exact lt_irrefl 0 h }, hn.pow_pos⟩
526-
527-
lemma even.pow_abs {p : ℕ} (hp : even p) (a : R) : |a| ^ p = a ^ p :=
528-
begin
529-
rw [←abs_pow, abs_eq_self],
530-
exact hp.pow_nonneg _
531-
end
532-
533-
@[simp] lemma pow_bit0_abs (a : R) (p : ℕ) : |a| ^ bit0 p = a ^ bit0 p := (even_bit0 _).pow_abs _
534-
535500
lemma strict_mono_pow_bit1 (n : ℕ) : strict_mono (λ a : R, a ^ bit1 n) :=
536501
begin
537502
intros a b hab,
@@ -543,9 +508,6 @@ begin
543508
{ exact pow_lt_pow_of_lt_left hab ha (bit1_pos (zero_le n)) }
544509
end
545510

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

src/algebra/order/ring.lean

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,12 +1317,6 @@ lemma self_dvd_abs (a : α) : a ∣ |a| :=
13171317
lemma abs_dvd_abs (a b : α) : |a| ∣ |b| ↔ a ∣ b :=
13181318
(abs_dvd _ _).trans (dvd_abs _ _)
13191319

1320-
lemma even_abs {a : α} : even (|a|) ↔ even a :=
1321-
dvd_abs _ _
1322-
1323-
lemma odd_abs {a : α} : odd (abs a) ↔ odd a :=
1324-
by { cases abs_choice a with h h; simp only [h, odd_neg] }
1325-
13261320
end
13271321

13281322
section linear_ordered_comm_ring

0 commit comments

Comments
 (0)