@@ -3,7 +3,8 @@ Copyright (c) 2015 Jeremy Avigad. All rights reserved.
3
3
Released under Apache 2.0 license as described in the file LICENSE.
4
4
Authors: Jeremy Avigad, Robert Y. Lewis
5
5
-/
6
- import algebra.hom.ring
6
+ import algebra.divisibility
7
+ import algebra.group.commute
7
8
import data.nat.basic
8
9
9
10
/-!
@@ -281,219 +282,13 @@ by rw [pow_sub a⁻¹ h, inv_pow, inv_pow, inv_inv]
281
282
282
283
end group
283
284
284
- lemma zero_pow [monoid_with_zero R] : ∀ {n : ℕ}, 0 < n → (0 : R) ^ n = 0
285
- | (n+1 ) _ := by rw [pow_succ, zero_mul]
286
-
287
- lemma zero_pow_eq [monoid_with_zero R] (n : ℕ) : (0 : R)^n = if n = 0 then 1 else 0 :=
288
- begin
289
- split_ifs with h,
290
- { rw [h, pow_zero], },
291
- { rw [zero_pow (nat.pos_of_ne_zero h)] },
292
- end
293
-
294
- lemma pow_eq_zero_of_le [monoid_with_zero M] {x : M} {n m : ℕ}
295
- (hn : n ≤ m) (hx : x^n = 0 ) : x^m = 0 :=
296
- by rw [← tsub_add_cancel_of_le hn, pow_add, hx, mul_zero]
297
-
298
- namespace ring_hom
299
-
300
- variables [semiring R] [semiring S]
301
-
302
- protected lemma map_pow (f : R →+* S) (a) :
303
- ∀ n : ℕ, f (a ^ n) = (f a) ^ n :=
304
- map_pow f a
305
-
306
- end ring_hom
307
-
308
- section pow_monoid_with_zero_hom
309
-
310
- variables [comm_monoid_with_zero M] {n : ℕ} (hn : 0 < n)
311
- include M hn
312
-
313
- /-- We define `x ↦ x^n` (for positive `n : ℕ`) as a `monoid_with_zero_hom` -/
314
- def pow_monoid_with_zero_hom : M →*₀ M :=
315
- { map_zero' := zero_pow hn,
316
- ..pow_monoid_hom n }
317
-
318
- @[simp]
319
- lemma coe_pow_monoid_with_zero_hom : (pow_monoid_with_zero_hom hn : M → M) = (^ n) := rfl
320
-
321
- @[simp]
322
- lemma pow_monoid_with_zero_hom_apply (a : M) : pow_monoid_with_zero_hom hn a = a ^ n := rfl
323
-
324
- end pow_monoid_with_zero_hom
325
-
326
285
lemma pow_dvd_pow [monoid R] (a : R) {m n : ℕ} (h : m ≤ n) :
327
286
a ^ m ∣ a ^ n := ⟨a ^ (n - m), by rw [← pow_add, nat.add_comm, tsub_add_cancel_of_le h]⟩
328
287
329
288
theorem pow_dvd_pow_of_dvd [comm_monoid R] {a b : R} (h : a ∣ b) : ∀ n : ℕ, a ^ n ∣ b ^ n
330
289
| 0 := by rw [pow_zero, pow_zero]
331
290
| (n+1 ) := by { rw [pow_succ, pow_succ], exact mul_dvd_mul h (pow_dvd_pow_of_dvd n) }
332
291
333
- theorem pow_eq_zero [monoid_with_zero R] [no_zero_divisors R] {x : R} {n : ℕ} (H : x^n = 0 ) :
334
- x = 0 :=
335
- begin
336
- induction n with n ih,
337
- { rw pow_zero at H,
338
- rw [← mul_one x, H, mul_zero] },
339
- { rw pow_succ at H,
340
- exact or.cases_on (mul_eq_zero.1 H) id ih }
341
- end
342
-
343
- @[simp] lemma pow_eq_zero_iff [monoid_with_zero R] [no_zero_divisors R]
344
- {a : R} {n : ℕ} (hn : 0 < n) :
345
- a ^ n = 0 ↔ a = 0 :=
346
- begin
347
- refine ⟨pow_eq_zero, _⟩,
348
- rintros rfl,
349
- exact zero_pow hn,
350
- end
351
-
352
- lemma pow_eq_zero_iff' [monoid_with_zero R] [no_zero_divisors R] [nontrivial R]
353
- {a : R} {n : ℕ} :
354
- a ^ n = 0 ↔ a = 0 ∧ n ≠ 0 :=
355
- by cases (zero_le n).eq_or_gt; simp [*, ne_of_gt]
356
-
357
- lemma pow_ne_zero_iff [monoid_with_zero R] [no_zero_divisors R] {a : R} {n : ℕ} (hn : 0 < n) :
358
- a ^ n ≠ 0 ↔ a ≠ 0 :=
359
- (pow_eq_zero_iff hn).not
360
-
361
- @[field_simps] theorem pow_ne_zero [monoid_with_zero R] [no_zero_divisors R]
362
- {a : R} (n : ℕ) (h : a ≠ 0 ) : a ^ n ≠ 0 :=
363
- mt pow_eq_zero h
364
-
365
- theorem sq_eq_zero_iff [monoid_with_zero R] [no_zero_divisors R] {a : R} : a ^ 2 = 0 ↔ a = 0 :=
366
- pow_eq_zero_iff two_pos
367
-
368
- lemma pow_dvd_pow_iff [cancel_comm_monoid_with_zero R]
369
- {x : R} {n m : ℕ} (h0 : x ≠ 0 ) (h1 : ¬ is_unit x) :
370
- x ^ n ∣ x ^ m ↔ n ≤ m :=
371
- begin
372
- split,
373
- { intro h, rw [← not_lt], intro hmn, apply h1,
374
- have : x ^ m * x ∣ x ^ m * 1 ,
375
- { rw [← pow_succ', mul_one], exact (pow_dvd_pow _ (nat.succ_le_of_lt hmn)).trans h },
376
- rwa [mul_dvd_mul_iff_left, ← is_unit_iff_dvd_one] at this , apply pow_ne_zero m h0 },
377
- { apply pow_dvd_pow }
378
- end
379
-
380
- section semiring
381
- variables [semiring R]
382
-
383
- lemma min_pow_dvd_add {n m : ℕ} {a b c : R} (ha : c ^ n ∣ a) (hb : c ^ m ∣ b) :
384
- c ^ (min n m) ∣ a + b :=
385
- begin
386
- replace ha := (pow_dvd_pow c (min_le_left n m)).trans ha,
387
- replace hb := (pow_dvd_pow c (min_le_right n m)).trans hb,
388
- exact dvd_add ha hb
389
- end
390
-
391
- end semiring
392
-
393
- section comm_semiring
394
- variables [comm_semiring R]
395
-
396
- lemma add_sq (a b : R) : (a + b) ^ 2 = a ^ 2 + 2 * a * b + b ^ 2 :=
397
- by simp only [sq, add_mul_self_eq]
398
-
399
- lemma add_sq' (a b : R) : (a + b) ^ 2 = a ^ 2 + b ^ 2 + 2 * a * b :=
400
- by rw [add_sq, add_assoc, add_comm _ (b ^ 2 ), add_assoc]
401
-
402
- alias add_sq ← add_pow_two
403
-
404
- end comm_semiring
405
-
406
- section has_distrib_neg
407
- variables [monoid R] [has_distrib_neg R]
408
-
409
- variables (R)
410
- theorem neg_one_pow_eq_or : ∀ n : ℕ, (-1 : R)^n = 1 ∨ (-1 : R)^n = -1
411
- | 0 := or.inl (pow_zero _)
412
- | (n+1 ) := (neg_one_pow_eq_or n).swap.imp
413
- (λ h, by rw [pow_succ, h, neg_one_mul, neg_neg])
414
- (λ h, by rw [pow_succ, h, mul_one])
415
- variables {R}
416
-
417
- theorem neg_pow (a : R) (n : ℕ) : (- a) ^ n = (-1 ) ^ n * a ^ n :=
418
- (neg_one_mul a) ▸ (commute.neg_one_left a).mul_pow n
419
-
420
- @[simp] theorem neg_pow_bit0 (a : R) (n : ℕ) : (- a) ^ (bit0 n) = a ^ (bit0 n) :=
421
- by rw [pow_bit0', neg_mul_neg, pow_bit0']
422
-
423
- @[simp] theorem neg_pow_bit1 (a : R) (n : ℕ) : (- a) ^ (bit1 n) = - a ^ (bit1 n) :=
424
- by simp only [bit1, pow_succ, neg_pow_bit0, neg_mul_eq_neg_mul]
425
-
426
- @[simp] lemma neg_sq (a : R) : (-a) ^ 2 = a ^ 2 := by simp [sq]
427
- @[simp] lemma neg_one_sq : (-1 : R) ^ 2 = 1 := by rw [neg_sq, one_pow]
428
-
429
- alias neg_sq ← neg_pow_two
430
- alias neg_one_sq ← neg_one_pow_two
431
-
432
- end has_distrib_neg
433
-
434
- section ring
435
- variables [ring R] {a b : R}
436
-
437
- protected lemma commute.sq_sub_sq (h : commute a b) : a ^ 2 - b ^ 2 = (a + b) * (a - b) :=
438
- by rw [sq, sq, h.mul_self_sub_mul_self_eq]
439
-
440
- @[simp]
441
- lemma neg_one_pow_mul_eq_zero_iff {n : ℕ} {r : R} : (-1 )^n * r = 0 ↔ r = 0 :=
442
- by rcases neg_one_pow_eq_or R n; simp [h]
443
-
444
- @[simp]
445
- lemma mul_neg_one_pow_eq_zero_iff {n : ℕ} {r : R} : r * (-1 )^n = 0 ↔ r = 0 :=
446
- by rcases neg_one_pow_eq_or R n; simp [h]
447
-
448
- variables [no_zero_divisors R]
449
-
450
- protected lemma commute.sq_eq_sq_iff_eq_or_eq_neg (h : commute a b) :
451
- a ^ 2 = b ^ 2 ↔ a = b ∨ a = -b :=
452
- by rw [←sub_eq_zero, h.sq_sub_sq, mul_eq_zero, add_eq_zero_iff_eq_neg, sub_eq_zero, or_comm]
453
-
454
- @[simp] lemma sq_eq_one_iff : a^2 = 1 ↔ a = 1 ∨ a = -1 :=
455
- by rw [←(commute.one_right a).sq_eq_sq_iff_eq_or_eq_neg, one_pow]
456
-
457
- lemma sq_ne_one_iff : a^2 ≠ 1 ↔ a ≠ 1 ∧ a ≠ -1 := sq_eq_one_iff.not.trans not_or_distrib
458
-
459
- end ring
460
-
461
- section comm_ring
462
- variables [comm_ring R]
463
-
464
- lemma sq_sub_sq (a b : R) : a ^ 2 - b ^ 2 = (a + b) * (a - b) := (commute.all a b).sq_sub_sq
465
-
466
- alias sq_sub_sq ← pow_two_sub_pow_two
467
-
468
- lemma sub_sq (a b : R) : (a - b) ^ 2 = a ^ 2 - 2 * a * b + b ^ 2 :=
469
- by rw [sub_eq_add_neg, add_sq, neg_sq, mul_neg, ← sub_eq_add_neg]
470
-
471
- alias sub_sq ← sub_pow_two
472
-
473
- lemma sub_sq' (a b : R) : (a - b) ^ 2 = a ^ 2 + b ^ 2 - 2 * a * b :=
474
- by rw [sub_eq_add_neg, add_sq', neg_sq, mul_neg, ← sub_eq_add_neg]
475
-
476
- variables [no_zero_divisors R] {a b : R}
477
-
478
- lemma sq_eq_sq_iff_eq_or_eq_neg : a ^ 2 = b ^ 2 ↔ a = b ∨ a = -b :=
479
- (commute.all a b).sq_eq_sq_iff_eq_or_eq_neg
480
-
481
- lemma eq_or_eq_neg_of_sq_eq_sq (a b : R) : a ^ 2 = b ^ 2 → a = b ∨ a = -b :=
482
- sq_eq_sq_iff_eq_or_eq_neg.1
483
-
484
- /- Copies of the above comm_ring lemmas for `units R`. -/
485
- namespace units
486
-
487
- protected lemma sq_eq_sq_iff_eq_or_eq_neg {a b : Rˣ} : a ^ 2 = b ^ 2 ↔ a = b ∨ a = -b :=
488
- by simp_rw [ext_iff, coe_pow, sq_eq_sq_iff_eq_or_eq_neg, units.coe_neg]
489
-
490
- protected lemma eq_or_eq_neg_of_sq_eq_sq (a b : Rˣ) (h : a ^ 2 = b ^ 2 ) : a = b ∨ a = -b :=
491
- units.sq_eq_sq_iff_eq_or_eq_neg.1 h
492
-
493
- end units
494
-
495
- end comm_ring
496
-
497
292
lemma of_add_nsmul [add_monoid A] (x : A) (n : ℕ) :
498
293
multiplicative.of_add (n • x) = (multiplicative.of_add x)^n := rfl
499
294
0 commit comments