@@ -69,12 +69,16 @@ namespace commute
69
69
variables [monoid M] {a b : M}
70
70
71
71
@[simp] theorem pow_right (h : commute a b) (n : ℕ) : commute a (b ^ n) := h.pow_right n
72
+
72
73
@[simp] theorem pow_left (h : commute a b) (n : ℕ) : commute (a ^ n) b := (h.symm.pow_right n).symm
74
+
73
75
@[simp] theorem pow_pow (h : commute a b) (m n : ℕ) : commute (a ^ m) (b ^ n) :=
74
76
(h.pow_left m).pow_right n
75
77
76
78
@[simp] theorem self_pow (a : M) (n : ℕ) : commute a (a ^ n) := (commute.refl a).pow_right n
79
+
77
80
@[simp] theorem pow_self (a : M) (n : ℕ) : commute (a ^ n) a := (commute.refl a).pow_left n
81
+
78
82
@[simp] theorem pow_pow_self (a : M) (m n : ℕ) : commute (a ^ m) (a ^ n) :=
79
83
(commute.refl a).pow_pow m n
80
84
@@ -87,12 +91,15 @@ section monoid
87
91
variables [monoid M] [monoid N] [add_monoid A] [add_monoid B]
88
92
89
93
@[simp] theorem pow_zero (a : M) : a^0 = 1 := rfl
94
+
90
95
@[simp] theorem zero_nsmul (a : A) : 0 •ℕ a = 0 := rfl
91
96
92
97
theorem pow_succ (a : M) (n : ℕ) : a^(n+1 ) = a * a^n := rfl
98
+
93
99
theorem succ_nsmul (a : A) (n : ℕ) : (n+1 ) •ℕ a = a + n •ℕ a := rfl
94
100
95
101
@[simp] theorem pow_one (a : M) : a^1 = a := mul_one _
102
+
96
103
@[simp] theorem one_nsmul (a : A) : 1 •ℕ a = a := add_zero _
97
104
98
105
@[simp] lemma pow_ite (P : Prop ) [decidable P] (a : M) (b c : ℕ) :
@@ -108,55 +115,77 @@ by split_ifs; refl
108
115
by simp
109
116
110
117
theorem pow_mul_comm' (a : M) (n : ℕ) : a^n * a = a * a^n := commute.pow_self a n
118
+
111
119
theorem nsmul_add_comm' : ∀ (a : A) (n : ℕ), n •ℕ a + a = a + n •ℕ a :=
112
120
@pow_mul_comm' (multiplicative A) _
113
121
114
122
theorem pow_succ' (a : M) (n : ℕ) : a^(n+1 ) = a^n * a :=
115
123
by rw [pow_succ, pow_mul_comm']
124
+
116
125
theorem succ_nsmul' (a : A) (n : ℕ) : (n+1 ) •ℕ a = n •ℕ a + a :=
117
126
@pow_succ' (multiplicative A) _ _ _
118
127
119
128
theorem pow_two (a : M) : a^2 = a * a :=
120
129
show a*(a*1 )=a*a, by rw mul_one
130
+
121
131
theorem two_nsmul (a : A) : 2 •ℕ a = a + a :=
122
132
@pow_two (multiplicative A) _ a
123
133
124
134
theorem pow_add (a : M) (m n : ℕ) : a^(m + n) = a^m * a^n :=
125
135
by induction n with n ih; [rw [add_zero, pow_zero, mul_one],
126
136
rw [pow_succ', ← mul_assoc, ← ih, ← pow_succ', add_assoc]]
137
+
127
138
theorem add_nsmul : ∀ (a : A) (m n : ℕ), (m + n) •ℕ a = m •ℕ a + n •ℕ a :=
128
139
@pow_add (multiplicative A) _
129
140
130
141
@[simp] theorem one_pow (n : ℕ) : (1 : M)^n = 1 :=
131
142
by induction n with n ih; [refl, rw [pow_succ, ih, one_mul]]
143
+
132
144
@[simp] theorem nsmul_zero (n : ℕ) : n •ℕ (0 : A) = 0 :=
133
145
by induction n with n ih; [refl, rw [succ_nsmul, ih, zero_add]]
134
146
135
147
theorem pow_mul (a : M) (m n : ℕ) : a^(m * n) = (a^m)^n :=
136
148
by induction n with n ih; [rw mul_zero, rw [nat.mul_succ, pow_add, pow_succ', ih]]; refl
149
+
137
150
theorem mul_nsmul' : ∀ (a : A) (m n : ℕ), m * n •ℕ a = n •ℕ (m •ℕ a) :=
138
151
@pow_mul (multiplicative A) _
139
152
140
153
theorem pow_mul' (a : M) (m n : ℕ) : a^(m * n) = (a^n)^m :=
141
154
by rw [mul_comm, pow_mul]
155
+
142
156
theorem mul_nsmul (a : A) (m n : ℕ) : m * n •ℕ a = m •ℕ (n •ℕ a) :=
143
157
@pow_mul' (multiplicative A) _ a m n
144
158
159
+ theorem pow_mul_pow_sub (a : M) {m n : ℕ} (h : m ≤ n) : a ^ m * a ^ (n - m) = a ^ n :=
160
+ by rw [←pow_add, nat.add_sub_cancel' h]
161
+
162
+ theorem nsmul_add_sub_nsmul (a : A) {m n : ℕ} (h : m ≤ n) : (m •ℕ a) + ((n - m) •ℕ a) = n •ℕ a :=
163
+ @pow_mul_pow_sub (multiplicative A) _ _ _ _ h
164
+
165
+ theorem pow_sub_mul_pow (a : M) {m n : ℕ} (h : m ≤ n) : a ^ (n - m) * a ^ m = a ^ n :=
166
+ by rw [←pow_add, nat.sub_add_cancel h]
167
+
168
+ theorem sub_nsmul_nsmul_add (a : A) {m n : ℕ} (h : m ≤ n) : ((n - m) •ℕ a) + (m •ℕ a) = n •ℕ a :=
169
+ @pow_sub_mul_pow (multiplicative A) _ _ _ _ h
170
+
145
171
@[simp] theorem nsmul_one [has_one A] : ∀ n : ℕ, n •ℕ (1 : A) = n :=
146
172
add_monoid_hom.eq_nat_cast
147
173
⟨λ n, n •ℕ (1 : A), zero_nsmul _, λ _ _, add_nsmul _ _ _⟩
148
174
(one_nsmul _)
149
175
150
176
theorem pow_bit0 (a : M) (n : ℕ) : a ^ bit0 n = a^n * a^n := pow_add _ _ _
177
+
151
178
theorem bit0_nsmul (a : A) (n : ℕ) : bit0 n •ℕ a = n •ℕ a + n •ℕ a := add_nsmul _ _ _
152
179
153
180
theorem pow_bit1 (a : M) (n : ℕ) : a ^ bit1 n = a^n * a^n * a :=
154
181
by rw [bit1, pow_succ', pow_bit0]
182
+
155
183
theorem bit1_nsmul : ∀ (a : A) (n : ℕ), bit1 n •ℕ a = n •ℕ a + n •ℕ a + a :=
156
184
@pow_bit1 (multiplicative A) _
157
185
158
186
theorem pow_mul_comm (a : M) (m n : ℕ) : a^m * a^n = a^n * a^m :=
159
187
commute.pow_pow_self a m n
188
+
160
189
theorem nsmul_add_comm : ∀ (a : A) (m n : ℕ), m •ℕ a + n •ℕ a = n •ℕ a + m •ℕ a :=
161
190
@pow_mul_comm (multiplicative A) _
162
191
@@ -167,6 +196,7 @@ begin
167
196
{ refl },
168
197
{ rw [list.repeat_succ, list.prod_cons, ih], refl, }
169
198
end
199
+
170
200
@[simp, priority 500 ]
171
201
theorem list.sum_repeat : ∀ (a : A) (n : ℕ), (list.repeat a n).sum = n •ℕ a :=
172
202
@list.prod_repeat (multiplicative A) _
@@ -215,6 +245,7 @@ variables [comm_monoid M] [add_comm_monoid A]
215
245
216
246
theorem mul_pow (a b : M) (n : ℕ) : (a * b)^n = a^n * b^n :=
217
247
(commute.all a b).mul_pow n
248
+
218
249
theorem nsmul_add : ∀ (a b : A) (n : ℕ), n •ℕ (a + b) = n •ℕ a + n •ℕ b :=
219
250
@mul_pow (multiplicative A) _
220
251
@@ -239,18 +270,21 @@ section nat
239
270
@[simp] theorem inv_pow (a : G) (n : ℕ) : (a⁻¹)^n = (a^n)⁻¹ :=
240
271
by induction n with n ih; [exact one_inv.symm,
241
272
rw [pow_succ', pow_succ, ih, mul_inv_rev]]
273
+
242
274
@[simp] theorem neg_nsmul : ∀ (a : A) (n : ℕ), n •ℕ (-a) = -(n •ℕ a) :=
243
275
@inv_pow (multiplicative A) _
244
276
245
277
theorem pow_sub (a : G) {m n : ℕ} (h : n ≤ m) : a^(m - n) = a^m * (a^n)⁻¹ :=
246
278
have h1 : m - n + n = m, from nat.sub_add_cancel h,
247
279
have h2 : a^(m - n) * a^n = a^m, by rw [←pow_add, h1],
248
280
eq_mul_inv_of_mul_eq h2
281
+
249
282
theorem nsmul_sub : ∀ (a : A) {m n : ℕ}, n ≤ m → (m - n) •ℕ a = m •ℕ a - n •ℕ a :=
250
283
@pow_sub (multiplicative A) _
251
284
252
285
theorem pow_inv_comm (a : G) (m n : ℕ) : (a⁻¹)^m * a^n = a^n * (a⁻¹)^m :=
253
286
(commute.refl a).inv_left.pow_pow m n
287
+
254
288
theorem nsmul_neg_comm : ∀ (a : A) (m n : ℕ), m •ℕ (-a) + n •ℕ a = n •ℕ a + m •ℕ (-a) :=
255
289
@pow_inv_comm (multiplicative A) _
256
290
end nat
@@ -278,26 +312,32 @@ def gsmul (n : ℤ) (a : A) : A :=
278
312
infix ` •ℤ `:70 := gsmul
279
313
280
314
@[simp] theorem gpow_coe_nat (a : G) (n : ℕ) : a ^ (n:ℤ) = a ^ n := rfl
315
+
281
316
@[simp] theorem gsmul_coe_nat (a : A) (n : ℕ) : n •ℤ a = n •ℕ a := rfl
282
317
283
318
theorem gpow_of_nat (a : G) (n : ℕ) : a ^ of_nat n = a ^ n := rfl
319
+
284
320
theorem gsmul_of_nat (a : A) (n : ℕ) : of_nat n •ℤ a = n •ℕ a := rfl
285
321
286
322
@[simp] theorem gpow_neg_succ_of_nat (a : G) (n : ℕ) : a ^ -[1 +n] = (a ^ n.succ)⁻¹ := rfl
323
+
287
324
@[simp] theorem gsmul_neg_succ_of_nat (a : A) (n : ℕ) : -[1 +n] •ℤ a = - (n.succ •ℕ a) := rfl
288
325
289
326
local attribute [ematch] le_of_lt
290
327
open nat
291
328
292
329
@[simp] theorem gpow_zero (a : G) : a ^ (0 :ℤ) = 1 := rfl
330
+
293
331
@[simp] theorem zero_gsmul (a : A) : (0 :ℤ) •ℤ a = 0 := rfl
294
332
295
333
@[simp] theorem gpow_one (a : G) : a ^ (1 :ℤ) = a := pow_one a
334
+
296
335
@[simp] theorem one_gsmul (a : A) : (1 :ℤ) •ℤ a = a := add_zero _
297
336
298
337
@[simp] theorem one_gpow : ∀ (n : ℤ), (1 : G) ^ n = 1
299
338
| (n : ℕ) := one_pow _
300
339
| -[1 + n] := show _⁻¹=(1 :G), by rw [_root_.one_pow, one_inv]
340
+
301
341
@[simp] theorem gsmul_zero : ∀ (n : ℤ), n •ℤ (0 : A) = 0 :=
302
342
@one_gpow (multiplicative A) _
303
343
@@ -313,6 +353,7 @@ by simp only [mul_inv_rev, gpow_one, gpow_neg]
313
353
@gpow_neg (multiplicative A) _
314
354
315
355
theorem gpow_neg_one (x : G) : x ^ (-1 :ℤ) = x⁻¹ := congr_arg has_inv.inv $ pow_one x
356
+
316
357
theorem neg_one_gsmul (x : A) : (-1 :ℤ) •ℤ x = -x := congr_arg has_neg.neg $ one_nsmul x
317
358
318
359
theorem gsmul_one [has_one A] (n : ℤ) : n •ℤ (1 : A) = n :=
@@ -321,6 +362,7 @@ by cases n; simp
321
362
theorem inv_gpow (a : G) : ∀n:ℤ, a⁻¹ ^ n = (a ^ n)⁻¹
322
363
| (n : ℕ) := inv_pow a n
323
364
| -[1 + n] := congr_arg has_inv.inv $ inv_pow a (n+1 )
365
+
324
366
theorem gsmul_neg (a : A) (n : ℤ) : gsmul n (- a) = - gsmul n a :=
325
367
@inv_gpow (multiplicative A) _ a n
326
368
@@ -363,11 +405,13 @@ lemma sub_gsmul (m n : ℤ) (a : A) : (m - n) •ℤ a = m •ℤ a - n •ℤ a
363
405
364
406
theorem gpow_one_add (a : G) (i : ℤ) : a ^ (1 + i) = a * a ^ i :=
365
407
by rw [gpow_add, gpow_one]
408
+
366
409
theorem one_add_gsmul : ∀ (a : A) (i : ℤ), (1 + i) •ℤ a = a + i •ℤ a :=
367
410
@gpow_one_add (multiplicative A) _
368
411
369
412
theorem gpow_mul_comm (a : G) (i j : ℤ) : a ^ i * a ^ j = a ^ j * a ^ i :=
370
413
by rw [← gpow_add, ← gpow_add, add_comm]
414
+
371
415
theorem gsmul_add_comm : ∀ (a : A) (i j), i •ℤ a + j •ℤ a = j •ℤ a + i •ℤ a :=
372
416
@gpow_mul_comm (multiplicative A) _
373
417
@@ -380,14 +424,17 @@ theorem gsmul_mul' : ∀ (a : A) (m n : ℤ), m * n •ℤ a = n •ℤ (m •
380
424
381
425
theorem gpow_mul' (a : G) (m n : ℤ) : a ^ (m * n) = (a ^ n) ^ m :=
382
426
by rw [mul_comm, gpow_mul]
427
+
383
428
theorem gsmul_mul (a : A) (m n : ℤ) : m * n •ℤ a = m •ℤ (n •ℤ a) :=
384
429
by rw [mul_comm, gsmul_mul']
385
430
386
431
theorem gpow_bit0 (a : G) (n : ℤ) : a ^ bit0 n = a ^ n * a ^ n := gpow_add _ _ _
432
+
387
433
theorem bit0_gsmul (a : A) (n : ℤ) : bit0 n •ℤ a = n •ℤ a + n •ℤ a := gpow_add _ _ _
388
434
389
435
theorem gpow_bit1 (a : G) (n : ℤ) : a ^ bit1 n = a ^ n * a ^ n * a :=
390
436
by rw [bit1, gpow_add]; simp [gpow_bit0]
437
+
391
438
theorem bit1_gsmul : ∀ (a : A) (n : ℤ), bit1 n •ℤ a = n •ℤ a + n •ℤ a + a :=
392
439
@gpow_bit1 (multiplicative A) _
393
440
0 commit comments