@@ -15,11 +15,6 @@ def is_unit [monoid α] (a : α) : Prop := ∃u:units α, a = u
15
15
@[simp] theorem not_is_unit_zero [nonzero_comm_ring α] : ¬ is_unit (0 : α)
16
16
| ⟨⟨a, b, hab, hba⟩, rfl⟩ := have 0 * b = 1 , from hab, by simpa using this
17
17
18
- @[simp] theorem is_unit_nat {n : ℕ} : is_unit n ↔ n = 1 :=
19
- iff.intro
20
- (assume ⟨u, hu⟩, match n, u, hu, nat.units_eq_one u with _, _, rfl, rfl := rfl end )
21
- (assume h, h.symm ▸ ⟨1 , rfl⟩)
22
-
23
18
@[simp] theorem is_unit_one [monoid α] : is_unit (1 :α) := ⟨1 , rfl⟩
24
19
25
20
theorem units.is_unit_of_mul_one [comm_monoid α] (a b : α) (h : a * b = 1 ) : is_unit a :=
@@ -32,12 +27,29 @@ iff.intro
32
27
by rwa [mul_assoc, units.mul_inv, mul_one] at this )
33
28
(assume ⟨v, hv⟩, hv.symm ▸ ⟨v * u, (units.mul_coe v u).symm⟩)
34
29
30
+ theorem is_unit_iff_dvd_one {α} [comm_semiring α] {x : α} : is_unit x ↔ x ∣ 1 :=
31
+ ⟨by rintro ⟨u, rfl⟩; exact ⟨_, u.mul_inv.symm⟩,
32
+ λ ⟨y, h⟩, ⟨⟨x, y, h.symm, by rw [h, mul_comm]⟩, rfl⟩⟩
33
+
34
+ theorem is_unit_iff_forall_dvd {α} [comm_semiring α] {x : α} :
35
+ is_unit x ↔ ∀ y, x ∣ y :=
36
+ is_unit_iff_dvd_one.trans ⟨λ h y, dvd.trans h (one_dvd _), λ h, h _⟩
37
+
38
+ theorem is_unit_of_dvd_unit {α} [comm_semiring α] {x y : α}
39
+ (xy : x ∣ y) (hu : is_unit y) : is_unit x :=
40
+ is_unit_iff_dvd_one.2 $ dvd_trans xy $ is_unit_iff_dvd_one.1 hu
41
+
42
+ @[simp] theorem is_unit_nat {n : ℕ} : is_unit n ↔ n = 1 :=
43
+ iff.intro
44
+ (assume ⟨u, hu⟩, match n, u, hu, nat.units_eq_one u with _, _, rfl, rfl := rfl end )
45
+ (assume h, h.symm ▸ ⟨1 , rfl⟩)
46
+
35
47
/-- `irreducible p` states that `p` is non-unit and only factors into units.
36
48
37
49
We explicitly avoid stating that `p` is non-zero, this would require a semiring. Assuming only a
38
50
monoid allows us to reuse irreducible for associated elements.
39
51
-/
40
- def irreducible [monoid α] (p : α) : Prop :=
52
+ @[class] def irreducible [monoid α] (p : α) : Prop :=
41
53
¬ is_unit p ∧ ∀a b, p = a * b → is_unit a ∨ is_unit b
42
54
43
55
@[simp] theorem not_irreducible_one [monoid α] : ¬ irreducible (1 : α) :=
@@ -47,6 +59,21 @@ by simp [irreducible]
47
59
| ⟨hn0, h⟩ := have is_unit (0 :α) ∨ is_unit (0 :α), from h 0 0 ((mul_zero 0 ).symm),
48
60
this.elim hn0 hn0
49
61
62
+ theorem of_irreducible_mul {α} [monoid α] {x y : α} :
63
+ irreducible (x * y) → is_unit x ∨ is_unit y
64
+ | ⟨_, h⟩ := h _ _ rfl
65
+
66
+ theorem irreducible_or_factor {α} [monoid α] (x : α) (h : ¬ is_unit x) :
67
+ irreducible x ∨ ∃ a b, ¬ is_unit a ∧ ¬ is_unit b ∧ a * b = x :=
68
+ begin
69
+ haveI := classical.dec,
70
+ refine or_iff_not_imp_right.2 (λ H, _),
71
+ simp [h, irreducible] at H ⊢,
72
+ refine λ a b h, classical.by_contradiction $ λ o, _,
73
+ simp [not_or_distrib] at o,
74
+ exact H _ o.1 _ o.2 h.symm
75
+ end
76
+
50
77
theorem irreducible_iff_nat_prime : ∀(a : ℕ), irreducible a ↔ nat.prime a
51
78
| 0 := by simp [nat.not_prime_zero]
52
79
| 1 := by simp [nat.prime, one_lt_two]
0 commit comments