|
| 1 | +/- |
| 2 | +Copyright (c) 2022 Eric Rodriguez. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Eric Rodriguez |
| 5 | +-/ |
| 6 | + |
| 7 | +import set_theory.cardinal_ordinal |
| 8 | +import algebra.is_prime_pow |
| 9 | + |
| 10 | +/-! |
| 11 | +# Cardinal Divisibility |
| 12 | +
|
| 13 | +We show basic results about divisibility in the cardinal numbers. This relation can be characterised |
| 14 | +in the following simple way: if `a` and `b` are both less than `ω`, then `a ∣ b` iff they are |
| 15 | +divisible as natural numbers. If `b` is greater than `ω`, then `a ∣ b` iff `a ≤ b`. This furthermore |
| 16 | +shows that all infinite cardinals are prime; recall that `a * b = max a b` if `ω ≤ a * b`; therefore |
| 17 | +`a ∣ b * c = a ∣ max b c` and therefore clearly either `a ∣ b` or `a ∣ c`. Note furthermore that |
| 18 | +no infinite cardinal is irreducible (`cardinal.not_irreducible_of_omega_le`), showing that the |
| 19 | +cardinal numbers do not form a `comm_cancel_monoid_with_zero`. |
| 20 | +
|
| 21 | +## Main results |
| 22 | +
|
| 23 | +* `cardinal.prime_of_omega_le`: a `cardinal` is prime if it is infinite. |
| 24 | +* `cardinal.is_prime_iff`: a `cardinal` is prime iff it is infinite or a prime natural number. |
| 25 | +* `cardinal.is_prime_pow_iff`: a `cardinal` is a prime power iff it is infinite or a natural number |
| 26 | + which is itself a prime power. |
| 27 | +
|
| 28 | +-/ |
| 29 | + |
| 30 | +namespace cardinal |
| 31 | + |
| 32 | +open_locale cardinal |
| 33 | + |
| 34 | +universe u |
| 35 | +variables {a b : cardinal.{u}} {n m : ℕ} |
| 36 | + |
| 37 | +@[simp] lemma is_unit_iff : is_unit a ↔ a = 1 := |
| 38 | +begin |
| 39 | + refine ⟨λ h, _, by { rintro rfl, exact is_unit_one }⟩, |
| 40 | + rcases eq_or_ne a 0 with rfl | ha, |
| 41 | + { exact (not_is_unit_zero h).elim }, |
| 42 | + rw is_unit_iff_forall_dvd at h, |
| 43 | + cases h 1 with t ht, |
| 44 | + rw [eq_comm, mul_eq_one_iff'] at ht, |
| 45 | + { exact ht.1 }, |
| 46 | + all_goals { rwa one_le_iff_ne_zero }, |
| 47 | + { rintro rfl, |
| 48 | + rw mul_zero at ht, |
| 49 | + exact zero_ne_one ht } |
| 50 | +end |
| 51 | + |
| 52 | +theorem le_of_dvd : ∀ {a b : cardinal}, b ≠ 0 → a ∣ b → a ≤ b |
| 53 | +| a _ b0 ⟨b, rfl⟩ := by simpa only [mul_one] using mul_le_mul_left' |
| 54 | + (one_le_iff_ne_zero.2 (λ h : b = 0, by simpa only [h, mul_zero] using b0)) a |
| 55 | + |
| 56 | +lemma dvd_of_le_of_omega_le (ha : a ≠ 0) (h : a ≤ b) (hb : ω ≤ b) : a ∣ b := |
| 57 | +⟨b, (mul_eq_right hb h ha).symm⟩ |
| 58 | + |
| 59 | +@[simp] lemma prime_of_omega_le (ha : ω ≤ a) : prime a := |
| 60 | +begin |
| 61 | + refine ⟨(omega_pos.trans_le ha).ne', _, λ b c hbc, _⟩, |
| 62 | + { rw is_unit_iff, |
| 63 | + exact (one_lt_omega.trans_le ha).ne' }, |
| 64 | + cases eq_or_ne (b * c) 0 with hz hz, |
| 65 | + { rcases mul_eq_zero.mp hz with rfl | rfl; simp }, |
| 66 | + wlog h : c ≤ b, |
| 67 | + left, |
| 68 | + have habc := le_of_dvd hz hbc, |
| 69 | + rwa [mul_eq_max' $ ha.trans $ habc, max_def, if_pos h] at hbc |
| 70 | +end |
| 71 | + |
| 72 | +lemma not_irreducible_of_omega_le (ha : ω ≤ a) : ¬irreducible a := |
| 73 | +begin |
| 74 | + rw [irreducible_iff, not_and_distrib], |
| 75 | + refine or.inr (λ h, _), |
| 76 | + simpa [mul_omega_eq ha, is_unit_iff, (one_lt_omega.trans_le ha).ne', one_lt_omega.ne'] using h a ω |
| 77 | +end |
| 78 | + |
| 79 | +@[simp, norm_cast] lemma nat_coe_dvd_iff : (n : cardinal) ∣ m ↔ n ∣ m := |
| 80 | +begin |
| 81 | + refine ⟨_, λ ⟨h, ht⟩, ⟨h, by exact_mod_cast ht⟩⟩, |
| 82 | + rintro ⟨k, hk⟩, |
| 83 | + have : ↑m < ω := nat_lt_omega m, |
| 84 | + rw [hk, mul_lt_omega_iff] at this, |
| 85 | + rcases this with h | h | ⟨-, hk'⟩, |
| 86 | + iterate 2 { simp only [h, mul_zero, zero_mul, nat.cast_eq_zero] at hk, simp [hk] }, |
| 87 | + lift k to ℕ using hk', |
| 88 | + exact ⟨k, by exact_mod_cast hk⟩ |
| 89 | +end |
| 90 | + |
| 91 | +@[simp] lemma nat_is_prime_iff : prime (n : cardinal) ↔ n.prime := |
| 92 | +begin |
| 93 | + simp only [prime, nat.prime_iff], |
| 94 | + refine and_congr (by simp) (and_congr _ ⟨λ h b c hbc, _, λ h b c hbc, _⟩), |
| 95 | + { simp only [is_unit_iff, nat.is_unit_iff], |
| 96 | + exact_mod_cast iff.rfl }, |
| 97 | + { exact_mod_cast h b c (by exact_mod_cast hbc) }, |
| 98 | + cases lt_or_le (b * c) ω with h' h', |
| 99 | + { rcases mul_lt_omega_iff.mp h' with rfl | rfl | ⟨hb, hc⟩, |
| 100 | + { simp }, |
| 101 | + { simp }, |
| 102 | + lift b to ℕ using hb, |
| 103 | + lift c to ℕ using hc, |
| 104 | + exact_mod_cast h b c (by exact_mod_cast hbc) }, |
| 105 | + rcases omega_le_mul_iff.mp h' with ⟨hb, hc, hω⟩, |
| 106 | + have hn : (n : cardinal) ≠ 0, |
| 107 | + { intro h, |
| 108 | + rw [h, zero_dvd_iff, mul_eq_zero] at hbc, |
| 109 | + cases hbc; contradiction }, |
| 110 | + wlog hω : ω ≤ b := hω using [b c], |
| 111 | + exact or.inl (dvd_of_le_of_omega_le hn ((nat_lt_omega n).le.trans hω) hω), |
| 112 | +end |
| 113 | + |
| 114 | +lemma is_prime_iff {a : cardinal} : prime a ↔ ω ≤ a ∨ ∃ p : ℕ, a = p ∧ p.prime := |
| 115 | +begin |
| 116 | + cases le_or_lt ω a with h h, |
| 117 | + { simp [h] }, |
| 118 | + lift a to ℕ using id h, |
| 119 | + simp [not_le.mpr h] |
| 120 | +end |
| 121 | + |
| 122 | +lemma is_prime_pow_iff {a : cardinal} : is_prime_pow a ↔ ω ≤ a ∨ ∃ n : ℕ, a = n ∧ is_prime_pow n := |
| 123 | +begin |
| 124 | + by_cases h : ω ≤ a, |
| 125 | + { simp [h, (prime_of_omega_le h).is_prime_pow] }, |
| 126 | + lift a to ℕ using not_le.mp h, |
| 127 | + simp only [h, nat.cast_inj, exists_eq_left', false_or, is_prime_pow_nat_iff], |
| 128 | + rw is_prime_pow_def, |
| 129 | + split, |
| 130 | + swap, |
| 131 | + { rintro ⟨p, k, hp, hk, rfl⟩, |
| 132 | + exact ⟨p, k, nat_is_prime_iff.mpr hp, by exact_mod_cast hk, by norm_cast⟩ }, |
| 133 | + rintro ⟨p, k, hp, hk, hpk⟩, |
| 134 | + have key : _ ≤ p ^ k := |
| 135 | + power_le_power_left hp.ne_zero (show (1 : cardinal) ≤ k, by exact_mod_cast hk), |
| 136 | + rw [power_one, hpk] at key, |
| 137 | + lift p to ℕ using key.trans_lt (nat_lt_omega a), |
| 138 | + exact ⟨p, k, nat_is_prime_iff.mp hp, hk, by exact_mod_cast hpk⟩ |
| 139 | +end |
| 140 | + |
| 141 | +end cardinal |
0 commit comments