@@ -3,7 +3,7 @@ Copyright (c) 2018 Johannes Hölzl. All rights reserved.
3
3
Released under Apache 2.0 license as described in the file LICENSE.
4
4
Authors: Johannes Hölzl, Jens Wagemaker
5
5
-/
6
- import data.multiset .basic
6
+ import algebra.big_operators .basic
7
7
import algebra.divisibility
8
8
import algebra.invertible
9
9
@@ -56,14 +56,18 @@ p ≠ 0 ∧ ¬ is_unit p ∧ (∀a b, p ∣ a * b → p ∣ a ∨ p ∣ b)
56
56
57
57
namespace prime
58
58
variables {p : α} (hp : prime p)
59
+ include hp
59
60
60
- lemma ne_zero (hp : prime p) : p ≠ 0 :=
61
+ lemma ne_zero : p ≠ 0 :=
61
62
hp.1
62
63
63
- lemma not_unit (hp : prime p) : ¬ is_unit p :=
64
+ lemma not_unit : ¬ is_unit p :=
64
65
hp.2 .1
65
66
66
- lemma ne_one (hp : prime p) : p ≠ 1 :=
67
+ lemma not_dvd_one : ¬ p ∣ 1 :=
68
+ mt (is_unit_of_dvd_one _) hp.not_unit
69
+
70
+ lemma ne_one : p ≠ 1 :=
67
71
λ h, hp.2 .1 (h.symm ▸ is_unit_one)
68
72
69
73
lemma dvd_or_dvd (hp : prime p) {a b : α} (h : p ∣ a * b) :
84
88
exact ih dvd_pow
85
89
end
86
90
91
+ lemma exists_mem_multiset_dvd {s : multiset α} :
92
+ p ∣ s.prod → ∃ a ∈ s, p ∣ a :=
93
+ multiset.induction_on s (λ h, (hp.not_dvd_one h).elim) $
94
+ λ a s ih h,
95
+ have p ∣ a * s.prod, by simpa using h,
96
+ match hp.dvd_or_dvd this with
97
+ | or.inl h := ⟨a, multiset.mem_cons_self a s, h⟩
98
+ | or.inr h := let ⟨a, has, h⟩ := ih h in ⟨a, multiset.mem_cons_of_mem has, h⟩
99
+ end
100
+
101
+ lemma exists_mem_multiset_map_dvd {s : multiset β} {f : β → α} :
102
+ p ∣ (s.map f).prod → ∃ a ∈ s, p ∣ f a :=
103
+ λ h, by simpa only [exists_prop, multiset.mem_map, exists_exists_and_eq_and]
104
+ using hp.exists_mem_multiset_dvd h
105
+
106
+ lemma exists_mem_finset_dvd {s : finset β} {f : β → α} :
107
+ p ∣ s.prod f → ∃ i ∈ s, p ∣ f i :=
108
+ hp.exists_mem_multiset_map_dvd
109
+
87
110
end prime
88
111
89
112
@[simp] lemma not_prime_zero : ¬ prime (0 : α) :=
@@ -92,22 +115,12 @@ end prime
92
115
@[simp] lemma not_prime_one : ¬ prime (1 : α) :=
93
116
λ h, h.not_unit is_unit_one
94
117
95
- lemma exists_mem_multiset_dvd_of_prime {s : multiset α} {p : α} (hp : prime p) :
96
- p ∣ s.prod → ∃a∈s, p ∣ a :=
97
- multiset.induction_on s (assume h, (hp.not_unit $ is_unit_of_dvd_one _ h).elim) $
98
- assume a s ih h,
99
- have p ∣ a * s.prod, by simpa using h,
100
- match hp.dvd_or_dvd this with
101
- | or.inl h := ⟨a, multiset.mem_cons_self a s, h⟩
102
- | or.inr h := let ⟨a, has, h⟩ := ih h in ⟨a, multiset.mem_cons_of_mem has, h⟩
103
- end
104
-
105
118
end prime
106
119
107
- lemma left_dvd_or_dvd_right_of_dvd_prime_mul [comm_cancel_monoid_with_zero α] {a : α} :
108
- ∀ {b p : α}, prime p → a ∣ p * b → p ∣ a ∨ a ∣ b :=
120
+ lemma prime.left_dvd_or_dvd_right_of_dvd_mul [comm_cancel_monoid_with_zero α] {p : α}
121
+ (hp : prime p) {a b : α} : a ∣ p * b → p ∣ a ∨ a ∣ b :=
109
122
begin
110
- rintros b p hp ⟨c, hc⟩,
123
+ rintro ⟨c, hc⟩,
111
124
rcases hp.2 .2 a c (hc ▸ dvd_mul_right _ _) with h | ⟨x, rfl⟩,
112
125
{ exact or.inl h },
113
126
{ rw [mul_left_comm, mul_right_inj' hp.ne_zero] at hc,
0 commit comments