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

Commit 18bd614

Browse files
kbuzzarddigama0
authored andcommitted
feat(algebra/group_power): adding various cast power lemmas for nat and int (#230)
1 parent cf0bf2a commit 18bd614

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

algebra/group_power.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,12 @@ by rw [add_monoid.smul_eq_mul', add_monoid.smul_eq_mul', mul_assoc]
308308
theorem add_monoid.mul_smul_assoc [semiring α] (a b : α) (n : ℕ) : n • (a * b) = n • a * b :=
309309
by rw [add_monoid.smul_eq_mul, add_monoid.smul_eq_mul, mul_assoc]
310310

311+
@[simp] theorem nat.cast_pow [semiring α] (n m : ℕ) : (↑(n ^ m) : α) = ↑n ^ m :=
312+
by induction m; simp [*, nat.succ_eq_add_one, nat.pow_add, pow_add]
313+
314+
@[simp] theorem int.coe_nat_pow (n m : ℕ) : ((n ^ m : ℕ) : ℤ) = n ^ m :=
315+
by induction m; simp [*, pow_succ', nat.pow_succ]
316+
311317
theorem neg_one_pow_eq_or {R} [ring R] : ∀ n : ℕ, (-1 : R)^n = 1 ∨ (-1 : R)^n = -1
312318
| 0 := by simp
313319
| (n+1) := by cases neg_one_pow_eq_or n; simp [pow_succ, h]
@@ -325,6 +331,9 @@ by rw [gsmul_eq_mul', gsmul_eq_mul', mul_assoc]
325331
theorem mul_gsmul_assoc [ring α] (a b : α) (n : ℤ) : n •ℤ (a * b) = n •ℤ a * b :=
326332
by rw [gsmul_eq_mul, gsmul_eq_mul, mul_assoc]
327333

334+
@[simp] theorem int.cast_pow [ring α] (n : ℤ) (m : ℕ) : (↑(n ^ m) : α) = ↑n ^ m :=
335+
by induction m; simp [*, nat.succ_eq_add_one,pow_add]
336+
328337
theorem pow_ne_zero [domain α] {a : α} (n : ℕ) (h : a ≠ 0) : a ^ n ≠ 0 :=
329338
by induction n with n ih; simp [pow_succ, mul_eq_zero, *]
330339

data/nat/basic.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ protected theorem eq_mul_of_div_eq_left {a b c : ℕ} (H1 : b ∣ a) (H2 : a / b
180180
a = c * b :=
181181
by rw [mul_comm, nat.eq_mul_of_div_eq_right H1 H2]
182182

183+
protected theorem mul_div_cancel_left' {a b : ℕ} (Hd : a ∣ b) : a * (b / a) = b :=
184+
by rw [mul_comm,nat.div_mul_cancel Hd]
185+
183186
protected theorem div_mod_unique {n k m d : ℕ} (h : 0 < k) :
184187
n / k = d ∧ n % k = m ↔ m + k * d = n ∧ m < k :=
185188
⟨λ ⟨e₁, e₂⟩, e₁ ▸ e₂ ▸ ⟨mod_add_div _ _, mod_lt _ h⟩,
@@ -372,6 +375,8 @@ by induction k; simp [*, add_succ, bind_assoc]
372375
theorem pow_add (a m n : ℕ) : a^(m + n) = a^m * a^n :=
373376
by induction n; simp [*, pow_succ, mul_assoc]
374377

378+
theorem pow_two (a : ℕ) : a ^ 2 = a * a := show (1 * a) * a = _, by rw one_mul
379+
375380
theorem pow_dvd_pow (a : ℕ) {m n : ℕ} (h : m ≤ n) : a^m ∣ a^n :=
376381
by rw [← nat.add_sub_cancel' h, pow_add]; apply dvd_mul_right
377382

@@ -382,6 +387,9 @@ theorem pow_dvd_pow_of_dvd {a b : ℕ} (h : a ∣ b) : ∀ n:ℕ, a^n ∣ b^n
382387
theorem mul_pow (a b n : ℕ) : (a * b) ^ n = a ^ n * b ^ n :=
383388
by induction n; simp [*, nat.pow_succ, mul_comm, mul_assoc, mul_left_comm]
384389

390+
protected theorem pow_mul (a b n : ℕ) : n ^ (a * b) = (n ^ a) ^ b :=
391+
by induction b; simp [*, nat.succ_eq_add_one, nat.pow_add, mul_add, mul_comm]
392+
385393
@[simp] theorem bodd_div2_eq (n : ℕ) : bodd_div2 n = (bodd n, div2 n) :=
386394
by unfold bodd div2; cases bodd_div2 n; refl
387395

0 commit comments

Comments
 (0)