|
| 1 | +import Mathlib.Tactic |
| 2 | +-- import Mathlib.Data.Finset.Basic |
| 3 | +-- import Mathlib.Algebra.BigOperators.Basic |
| 4 | + |
| 5 | +-- open BigOperators |
| 6 | +-- open Finset |
| 7 | + |
| 8 | +-- Based on matt parker's video: https://www.youtube.com/watch?v=MhJN9sByRS0 |
| 9 | + |
| 10 | +-- #check Nat.dvd_sub |
| 11 | + |
| 12 | + |
| 13 | +abbrev VideoStatement : Prop := ∀ (b n : Nat), b - 1 ∣ b^n - 1 |
| 14 | + |
| 15 | +example : VideoStatement := by |
| 16 | + intro b n |
| 17 | + induction n generalizing b with |
| 18 | + | zero => norm_num |
| 19 | + | succ n hn => |
| 20 | + rw [pow_succ] |
| 21 | + cases b with |
| 22 | + | zero => grind only |
| 23 | + | succ b => |
| 24 | + specialize hn (b + 1) |
| 25 | + rw [Nat.add_one_sub_one] |
| 26 | + rw [mul_add] |
| 27 | + rw [mul_one] |
| 28 | + -- rw [mul_comm] |
| 29 | + rw [Nat.add_sub_assoc (Nat.one_le_pow' _ _)] |
| 30 | + grind [ |
| 31 | + = mul_add, = mul_one, = mul_comm, |
| 32 | + <- Nat.one_le_pow', |
| 33 | + = Nat.add_sub_assoc, |
| 34 | + ← Nat.dvd_add, ← Nat.dvd_mul_right |
| 35 | + ] |
| 36 | + |
| 37 | +theorem video_theorem3 : VideoStatement := by |
| 38 | + intro b n |
| 39 | + induction n with |
| 40 | + | zero => norm_num |
| 41 | + | succ n hn => |
| 42 | + rw [pow_succ] |
| 43 | + cases b with |
| 44 | + | zero => grind only |
| 45 | + | succ b => |
| 46 | + rw [Nat.add_one_sub_one, mul_add, mul_one, mul_comm] |
| 47 | + rw [Nat.add_sub_assoc (Nat.one_le_pow' _ _)] |
| 48 | + exact Nat.dvd_add (Nat.dvd_mul_right _ _) hn |
| 49 | + |
| 50 | +theorem video_theorem {b n : Nat} : b - 1 ∣ b^n - 1 := by |
| 51 | + induction' n with n hn |
| 52 | + · norm_num |
| 53 | + rw [pow_succ] |
| 54 | + cases' b with bs |
| 55 | + · norm_num |
| 56 | + rw [Nat.add_one_sub_one, mul_add, mul_one, mul_comm, Nat.add_sub_assoc (Nat.one_le_pow' _ _)] |
| 57 | + exact Nat.dvd_add (Nat.dvd_mul_right _ _) hn |
| 58 | + |
| 59 | +-- theorem video_theorem2 {b n : Nat} : x - 1 ∣ x^n - 1 := by |
| 60 | +-- use ∑ m in range n, x^m |
| 61 | +-- symm |
| 62 | +-- calc (x - 1) * ∑ m ∈ range n, x ^ m |
| 63 | +-- _ = ∑ m ∈ range n, x ^ m * (x - 1) := by rw [mul_comm, sum_mul] |
| 64 | +-- _ = ∑ m ∈ range n, (x^(m+1) - x^m) := by sorry |
| 65 | +-- _ = ∑ m ∈ range n, x^(m+1) - ∑ m ∈ range n, x^m := by sorry |
| 66 | +-- _ = x^n - 1 := by sorry |
| 67 | + |
| 68 | +#check sub_one_dvd_pow_sub_one |
0 commit comments