@@ -4,14 +4,12 @@ Released under Apache 2.0 license as described in the file LICENSE.
4
4
Authors: Kenny Lau, Joey van Langen, Casper Putz
5
5
6
6
! This file was ported from Lean 3 source module algebra.char_p.basic
7
- ! leanprover-community/mathlib commit 05a78c9451101108e638a0f213fb1bed82483545
7
+ ! leanprover-community/mathlib commit ceb887ddf3344dab425292e497fa2af91498437c
8
8
! Please do not edit these lines, except to modify the commit id
9
9
! if you have ported upstream changes.
10
10
-/
11
- import Mathlib.Algebra.Hom.Iterate
12
11
import Mathlib.Data.Int.ModEq
13
- import Mathlib.Data.Nat.Choose.Dvd
14
- import Mathlib.Data.Nat.Choose.Sum
12
+ import Mathlib.Data.Nat.Multiplicity
15
13
import Mathlib.GroupTheory.OrderOfElement
16
14
import Mathlib.RingTheory.Nilpotent
17
15
@@ -22,7 +20,79 @@ import Mathlib.RingTheory.Nilpotent
22
20
23
21
universe u v
24
22
25
- variable (R : Type u)
23
+ open Finset
24
+
25
+ open BigOperators
26
+
27
+ variable {R : Type _}
28
+
29
+ namespace Commute
30
+
31
+ variable [Semiring R] {p : ℕ} {x y : R}
32
+
33
+ protected theorem add_pow_prime_pow_eq (hp : p.Prime) (h : Commute x y) (n : ℕ) :
34
+ (x + y) ^ p ^ n =
35
+ x ^ p ^ n + y ^ p ^ n +
36
+ p * ∑ k in Ioo 0 (p ^ n), x ^ k * y ^ (p ^ n - k) * ↑((p ^ n).choose k / p) := by
37
+ trans x ^ p ^ n + y ^ p ^ n + ∑ k in Ioo 0 (p ^ n), x ^ k * y ^ (p ^ n - k) * (p ^ n).choose k
38
+ · simp_rw [h.add_pow, ← Nat.Ico_zero_eq_range, Nat.Ico_succ_right, Icc_eq_cons_Ico (zero_le _),
39
+ Finset.sum_cons, Ico_eq_cons_Ioo (pow_pos hp.pos _), Finset.sum_cons, tsub_self, tsub_zero,
40
+ pow_zero, Nat.choose_zero_right, Nat.choose_self, Nat.cast_one, mul_one, one_mul, ← add_assoc]
41
+ · congr 1
42
+ simp_rw [Finset.mul_sum, Nat.cast_comm, mul_assoc _ _ (p : R), ← Nat.cast_mul]
43
+ refine' Finset.sum_congr rfl fun i hi => _
44
+ rw [mem_Ioo] at hi
45
+ rw [Nat.div_mul_cancel (hp.dvd_choose_pow hi.1 .ne' hi.2 .ne)]
46
+ #align commute.add_pow_prime_pow_eq Commute.add_pow_prime_pow_eq
47
+
48
+ protected theorem add_pow_prime_eq (hp : p.Prime) (h : Commute x y) :
49
+ (x + y) ^ p =
50
+ x ^ p + y ^ p + p * ∑ k in Finset.Ioo 0 p, x ^ k * y ^ (p - k) * ↑(p.choose k / p) :=
51
+ by simpa using h.add_pow_prime_pow_eq hp 1
52
+ #align commute.add_pow_prime_eq Commute.add_pow_prime_eq
53
+
54
+ protected theorem exists_add_pow_prime_pow_eq (hp : p.Prime) (h : Commute x y) (n : ℕ) :
55
+ ∃ r, (x + y) ^ p ^ n = x ^ p ^ n + y ^ p ^ n + p * r :=
56
+ ⟨_, h.add_pow_prime_pow_eq hp n⟩
57
+ #align commute.exists_add_pow_prime_pow_eq Commute.exists_add_pow_prime_pow_eq
58
+
59
+ protected theorem exists_add_pow_prime_eq (hp : p.Prime) (h : Commute x y) :
60
+ ∃ r, (x + y) ^ p = x ^ p + y ^ p + p * r :=
61
+ ⟨_, h.add_pow_prime_eq hp⟩
62
+ #align commute.exists_add_pow_prime_eq Commute.exists_add_pow_prime_eq
63
+
64
+ end Commute
65
+
66
+ section CommSemiring
67
+
68
+ variable [CommSemiring R] {p : ℕ} {x y : R}
69
+
70
+ theorem add_pow_prime_pow_eq (hp : p.Prime) (x y : R) (n : ℕ) :
71
+ (x + y) ^ p ^ n =
72
+ x ^ p ^ n + y ^ p ^ n +
73
+ p * ∑ k in Finset.Ioo 0 (p ^ n), x ^ k * y ^ (p ^ n - k) * ↑((p ^ n).choose k / p) :=
74
+ (Commute.all x y).add_pow_prime_pow_eq hp n
75
+ #align add_pow_prime_pow_eq add_pow_prime_pow_eq
76
+
77
+ theorem add_pow_prime_eq (hp : p.Prime) (x y : R) :
78
+ (x + y) ^ p =
79
+ x ^ p + y ^ p + p * ∑ k in Finset.Ioo 0 p, x ^ k * y ^ (p - k) * ↑(p.choose k / p) :=
80
+ (Commute.all x y).add_pow_prime_eq hp
81
+ #align add_pow_prime_eq add_pow_prime_eq
82
+
83
+ theorem exists_add_pow_prime_pow_eq (hp : p.Prime) (x y : R) (n : ℕ) :
84
+ ∃ r, (x + y) ^ p ^ n = x ^ p ^ n + y ^ p ^ n + p * r :=
85
+ (Commute.all x y).exists_add_pow_prime_pow_eq hp n
86
+ #align exists_add_pow_prime_pow_eq exists_add_pow_prime_pow_eq
87
+
88
+ theorem exists_add_pow_prime_eq (hp : p.Prime) (x y : R) :
89
+ ∃ r, (x + y) ^ p = x ^ p + y ^ p + p * r :=
90
+ (Commute.all x y).exists_add_pow_prime_eq hp
91
+ #align exists_add_pow_prime_eq exists_add_pow_prime_eq
92
+
93
+ end CommSemiring
94
+
95
+ variable (R)
26
96
27
97
/-- The generator of the kernel of the unique homomorphism ℕ → R for a semiring R.
28
98
@@ -46,6 +116,7 @@ theorem CharP.cast_eq_zero_iff (R : Type u) [AddMonoidWithOne R] (p : ℕ) [Char
46
116
(x : R) = 0 ↔ p ∣ x :=
47
117
CharP.cast_eq_zero_iff' (R := R) (p := p) x
48
118
119
+ @[simp]
49
120
theorem CharP.cast_eq_zero [AddMonoidWithOne R] (p : ℕ) [CharP R p] : (p : R) = 0 :=
50
121
(CharP.cast_eq_zero_iff R p p).2 (dvd_refl p)
51
122
#align char_p.cast_eq_zero CharP.cast_eq_zero
@@ -162,39 +233,22 @@ theorem eq_zero [CharZero R] : ringChar R = 0 :=
162
233
eq R 0
163
234
#align ring_char.eq_zero ringChar.eq_zero
164
235
165
- @[simp]
236
+ -- @[ simp ] -- Porting note: simp can prove this
166
237
theorem Nat.cast_ringChar : (ringChar R : R) = 0 := by rw [ringChar.spec]
167
238
#align ring_char.nat.cast_ring_char ringChar.Nat.cast_ringChar
168
239
169
240
end ringChar
170
241
171
- theorem add_pow_char_of_commute [Semiring R] {p : ℕ} [Fact p.Prime] [CharP R p] (x y : R)
242
+ theorem add_pow_char_of_commute [Semiring R] {p : ℕ} [hp : Fact p.Prime] [CharP R p] (x y : R)
172
243
(h : Commute x y) : (x + y) ^ p = x ^ p + y ^ p := by
173
- rw [Commute.add_pow h, Finset.sum_range_succ_comm, tsub_self, pow_zero, Nat.choose_self]
174
- rw [Nat.cast_one, mul_one, mul_one]; congr 1
175
- convert Finset.sum_eq_single (f := fun (x_1 : ℕ) => x ^ x_1 * y ^ (p - x_1) * (Nat.choose p x_1))
176
- (s := Finset.range p) 0
177
- (by
178
- intro b h1 h2
179
- suffices (p.choose b : R) = 0 by
180
- simp [this]
181
- rw [CharP.cast_eq_zero_iff R p]
182
- exact Nat.Prime.dvd_choose_self Fact.out h2 (Finset.mem_range.1 h1))
183
- (by
184
- intro h1
185
- contrapose! h1
186
- rw [Finset.mem_range]
187
- exact Nat.Prime.pos Fact.out)
188
- simp only [mul_one, one_mul, Nat.choose_zero_right, tsub_zero, Nat.cast_one, pow_zero]
244
+ let ⟨r, hr⟩ := h.exists_add_pow_prime_eq hp.out
245
+ simp [hr]
189
246
#align add_pow_char_of_commute add_pow_char_of_commute
190
247
191
- theorem add_pow_char_pow_of_commute [Semiring R] {p : ℕ} [Fact p.Prime] [CharP R p] {n : ℕ}
248
+ theorem add_pow_char_pow_of_commute [Semiring R] {p n : ℕ} [hp : Fact p.Prime] [CharP R p]
192
249
(x y : R) (h : Commute x y) : (x + y) ^ p ^ n = x ^ p ^ n + y ^ p ^ n := by
193
- induction n with
194
- | zero => simp
195
- | succ n n_ih =>
196
- rw [pow_succ', pow_mul, pow_mul, pow_mul, n_ih]
197
- apply add_pow_char_of_commute; apply Commute.pow_pow h
250
+ let ⟨r, hr⟩ := h.exists_add_pow_prime_pow_eq hp.out n
251
+ simp [hr]
198
252
#align add_pow_char_pow_of_commute add_pow_char_pow_of_commute
199
253
200
254
theorem sub_pow_char_of_commute [Ring R] {p : ℕ} [Fact p.Prime] [CharP R p] (x y : R)
@@ -509,7 +563,7 @@ end Semiring
509
563
section Ring
510
564
511
565
variable [Ring R] [NoZeroDivisors R] [Nontrivial R] [Finite R]
512
- -- porting note: redundant binder annotation update
566
+ -- porting note: removed redundant binder annotation update `(R)`
513
567
514
568
theorem char_is_prime (p : ℕ) [CharP R p] : p.Prime :=
515
569
Or.resolve_right (char_is_prime_or_zero R p) (char_ne_zero_of_finite R p)
@@ -589,12 +643,11 @@ end
589
643
section
590
644
591
645
variable [NonAssocRing R] [Fintype R] (n : ℕ)
592
- -- porting note: redundant binder annotation update
646
+ -- porting note: removed redundant binder annotation update `(R)`
593
647
594
648
theorem charP_of_ne_zero (hn : Fintype.card R = n) (hR : ∀ i < n, (i : R) = 0 → i = 0 ) :
595
649
CharP R n :=
596
- { cast_eq_zero_iff' :=
597
- by
650
+ { cast_eq_zero_iff' := by
598
651
have H : (n : R) = 0 := by rw [← hn, CharP.cast_card_eq_zero]
599
652
intro k
600
653
constructor
@@ -660,8 +713,7 @@ theorem Int.cast_injOn_of_ringChar_ne_two {R : Type _} [NonAssocRing R] [Nontriv
660
713
by_contra hf
661
714
replace ha : a = 0 ∨ a = 1 ∨ a = -1 := ha
662
715
replace hb : b = 0 ∨ b = 1 ∨ b = -1 := hb
663
- have hh : a - b = 1 ∨ b - a = 1 ∨ a - b = 2 ∨ b - a = 2 :=
664
- by
716
+ have hh : a - b = 1 ∨ b - a = 1 ∨ a - b = 2 ∨ b - a = 2 := by
665
717
rcases ha with (ha | ha | ha) <;> rcases hb with (hb | hb | hb)
666
718
pick_goal 5
667
719
pick_goal 9
687
739
namespace NeZero
688
740
689
741
variable [AddMonoidWithOne R] {r : R} {n p : ℕ} {a : ℕ+}
690
- -- porting note: redundant binder annotation update
742
+ -- porting note: removed redundant binder annotation update `(R)`
691
743
692
744
theorem of_not_dvd [CharP R p] (h : ¬p ∣ n) : NeZero (n : R) :=
693
745
⟨(CharP.cast_eq_zero_iff R p n).not.mpr h⟩
0 commit comments