@@ -110,22 +110,47 @@ lemma dvd_and_not_dvd_iff [integral_domain α] {x y : α} :
110
110
λ ⟨hx0, d, hdu, hdx⟩, ⟨⟨d, hdx⟩, λ ⟨e, he⟩, hdu (is_unit_of_dvd_one _
111
111
⟨e, (domain.mul_left_inj hx0).1 $ by conv {to_lhs, rw [he, hdx]};simp [mul_assoc]⟩)⟩⟩
112
112
113
+ lemma pow_dvd_pow_iff [integral_domain α] {x : α} {n m : ℕ} (h0 : x ≠ 0 ) (h1 : ¬ is_unit x) :
114
+ x ^ n ∣ x ^ m ↔ n ≤ m :=
115
+ begin
116
+ split,
117
+ { intro h, rw [← not_lt], intro hmn, apply h1,
118
+ have : x * x ^ m ∣ 1 * x ^ m,
119
+ { rw [← pow_succ, one_mul], exact dvd_trans (pow_dvd_pow _ (nat.succ_le_of_lt hmn)) h },
120
+ rwa [mul_dvd_mul_iff_right, ← is_unit_iff_dvd_one] at this , apply pow_ne_zero m h0 },
121
+ { apply pow_dvd_pow }
122
+ end
123
+
113
124
/-- prime element of a semiring -/
114
125
def prime [comm_semiring α] (p : α) : Prop :=
115
126
p ≠ 0 ∧ ¬ is_unit p ∧ (∀a b, p ∣ a * b → p ∣ a ∨ p ∣ b)
116
127
117
- @[simp] lemma not_prime_zero [integral_domain α] : ¬ prime (0 : α)
118
- | ⟨h, _⟩ := h rfl
128
+ namespace prime
129
+
130
+ lemma ne_zero [comm_semiring α] {p : α} (hp : prime p) : p ≠ 0 :=
131
+ hp.1
132
+
133
+ lemma not_unit [comm_semiring α] {p : α} (hp : prime p) : ¬ is_unit p :=
134
+ hp.2 .1
135
+
136
+ lemma div_or_div [comm_semiring α] {p : α} (hp : prime p) {a b : α} (h : p ∣ a * b) :
137
+ p ∣ a ∨ p ∣ b :=
138
+ hp.2 .2 a b h
139
+
140
+ end prime
141
+
142
+ @[simp] lemma not_prime_zero [comm_semiring α] : ¬ prime (0 : α) :=
143
+ λ h, h.ne_zero rfl
119
144
120
145
@[simp] lemma not_prime_one [comm_semiring α] : ¬ prime (1 : α) :=
121
- λ h, h.2 . 1 is_unit_one
146
+ λ h, h.not_unit is_unit_one
122
147
123
148
lemma exists_mem_multiset_dvd_of_prime [comm_semiring α] {s : multiset α} {p : α} (hp : prime p) :
124
149
p ∣ s.prod → ∃a∈s, p ∣ a :=
125
- multiset.induction_on s (assume h, (hp.2 . 1 $ is_unit_of_dvd_one _ h).elim) $
150
+ multiset.induction_on s (assume h, (hp.not_unit $ is_unit_of_dvd_one _ h).elim) $
126
151
assume a s ih h,
127
152
have p ∣ a * s.prod, by simpa using h,
128
- match hp.2 . 2 a s.prod this with
153
+ match hp.div_or_div this with
129
154
| or.inl h := ⟨a, multiset.mem_cons_self a s, h⟩
130
155
| or.inr h := let ⟨a, has, h⟩ := ih h in ⟨a, multiset.mem_cons_of_mem has, h⟩
131
156
end
@@ -138,14 +163,25 @@ monoid allows us to reuse irreducible for associated elements.
138
163
@[class] def irreducible [monoid α] (p : α) : Prop :=
139
164
¬ is_unit p ∧ ∀a b, p = a * b → is_unit a ∨ is_unit b
140
165
166
+ namespace irreducible
167
+
168
+ lemma not_unit [monoid α] {p : α} (hp : irreducible p) : ¬ is_unit p :=
169
+ hp.1
170
+
171
+ lemma is_unit_or_is_unit [monoid α] {p : α} (hp : irreducible p) {a b : α} (h : p = a * b) :
172
+ is_unit a ∨ is_unit b :=
173
+ hp.2 a b h
174
+
175
+ end irreducible
176
+
141
177
@[simp] theorem not_irreducible_one [monoid α] : ¬ irreducible (1 : α) :=
142
178
by simp [irreducible]
143
179
144
180
@[simp] theorem not_irreducible_zero [semiring α] : ¬ irreducible (0 : α)
145
181
| ⟨hn0, h⟩ := have is_unit (0 :α) ∨ is_unit (0 :α), from h 0 0 ((mul_zero 0 ).symm),
146
182
this.elim hn0 hn0
147
183
148
- theorem ne_zero_of_irreducible [semiring α] : ∀ {p:α}, irreducible p → p ≠ 0
184
+ theorem irreducible.ne_zero [semiring α] : ∀ {p:α}, irreducible p → p ≠ 0
149
185
| _ hp rfl := not_irreducible_zero hp
150
186
151
187
theorem of_irreducible_mul {α} [monoid α] {x y : α} :
@@ -164,8 +200,8 @@ begin
164
200
end
165
201
166
202
lemma irreducible_of_prime [integral_domain α] {p : α} (hp : prime p) : irreducible p :=
167
- ⟨hp.2 . 1 , λ a b hab,
168
- (show a * b ∣ a ∨ a * b ∣ b, from hab ▸ hp.2 . 2 a b (hab ▸ (dvd_refl _))).elim
203
+ ⟨hp.not_unit , λ a b hab,
204
+ (show a * b ∣ a ∨ a * b ∣ b, from hab ▸ hp.div_or_div (hab ▸ (dvd_refl _))).elim
169
205
(λ ⟨x, hx⟩, or.inr (is_unit_iff_dvd_one.2
170
206
⟨x, (domain.mul_left_inj (show a ≠ 0 , from λ h, by simp [*, prime] at *)).1
171
207
$ by conv {to_lhs, rw hx}; simp [mul_comm, mul_assoc, mul_left_comm]⟩))
@@ -179,9 +215,9 @@ lemma succ_dvd_or_succ_dvd_of_succ_sum_dvd_mul [integral_domain α] {p : α} (hp
179
215
λ ⟨x, hx⟩ ⟨y, hy⟩ ⟨z, hz⟩,
180
216
have h : p ^ (k + l) * (x * y) = p ^ (k + l) * (p * z),
181
217
by simpa [mul_comm, _root_.pow_add, hx, hy, mul_assoc, mul_left_comm] using hz,
182
- have hp0: p ^ (k + l) ≠ 0 , from pow_ne_zero _ hp.1 ,
218
+ have hp0: p ^ (k + l) ≠ 0 , from pow_ne_zero _ hp.ne_zero ,
183
219
have hpd : p ∣ x * y, from ⟨z, by rwa [domain.mul_left_inj hp0] at h⟩,
184
- (hp.2 . 2 x y hpd).elim
220
+ (hp.div_or_div hpd).elim
185
221
(λ ⟨d, hd⟩, or.inl ⟨d, by simp [*, _root_.pow_succ, mul_comm, mul_left_comm, mul_assoc]⟩)
186
222
(λ ⟨d, hd⟩, or.inr ⟨d, by simp [*, _root_.pow_succ, mul_comm, mul_left_comm, mul_assoc]⟩)
187
223
@@ -244,14 +280,14 @@ end
244
280
245
281
lemma exists_associated_mem_of_dvd_prod [integral_domain α] {p : α}
246
282
(hp : prime p) {s : multiset α} : (∀ r ∈ s, prime r) → p ∣ s.prod → ∃ q ∈ s, p ~ᵤ q :=
247
- multiset.induction_on s (by simp [mt is_unit_iff_dvd_one.2 hp.2 . 1 ])
283
+ multiset.induction_on s (by simp [mt is_unit_iff_dvd_one.2 hp.not_unit ])
248
284
(λ a s ih hs hps, begin
249
285
rw [multiset.prod_cons] at hps,
250
- cases hp.2 . 2 _ _ hps with h h,
286
+ cases hp.div_or_div hps with h h,
251
287
{ use [a, by simp],
252
288
cases h with u hu,
253
289
cases ((irreducible_of_prime (hs a (multiset.mem_cons.2
254
- (or.inl rfl)))).2 p u hu).resolve_left hp.2 . 1 with v hv,
290
+ (or.inl rfl)))).2 p u hu).resolve_left hp.not_unit with v hv,
255
291
exact ⟨v, by simp [hu, hv]⟩ },
256
292
{ rcases ih (λ r hr, hs _ (multiset.mem_cons.2 (or.inr hr))) h with ⟨q, hq₁, hq₂⟩,
257
293
exact ⟨q, multiset.mem_cons.2 (or.inr hq₁), hq₂⟩ }
@@ -275,10 +311,10 @@ lemma ne_zero_iff_of_associated [comm_semiring α] {a b : α} (h : a ~ᵤ b) : a
275
311
by haveI := classical.dec; exact not_iff_not.2 (eq_zero_iff_of_associated h)
276
312
277
313
lemma prime_of_associated [comm_semiring α] {p q : α} (h : p ~ᵤ q) (hp : prime p) : prime q :=
278
- ⟨(ne_zero_iff_of_associated h).1 hp.1 ,
314
+ ⟨(ne_zero_iff_of_associated h).1 hp.ne_zero ,
279
315
let ⟨u, hu⟩ := h in
280
- ⟨λ ⟨v, hv⟩, hp.2 . 1 ⟨v * u⁻¹, by simp [hv.symm, hu.symm]⟩,
281
- hu ▸ by simp [mul_unit_dvd_iff]; exact hp.2 . 2 ⟩⟩
316
+ ⟨λ ⟨v, hv⟩, hp.not_unit ⟨v * u⁻¹, by simp [hv.symm, hu.symm]⟩,
317
+ hu ▸ by { simp [mul_unit_dvd_iff], intros a b, exact hp.div_or_div } ⟩⟩
282
318
283
319
lemma prime_iff_of_associated [comm_semiring α] {p q : α}
284
320
(h : p ~ᵤ q) : prime p ↔ prime q :=
@@ -477,13 +513,23 @@ iff.intro dvd_of_mk_le_mk mk_le_mk_of_dvd
477
513
478
514
def prime (p : associates α) : Prop := p ≠ 0 ∧ p ≠ 1 ∧ (∀a b, p ≤ a * b → p ≤ a ∨ p ≤ b)
479
515
516
+ lemma prime.ne_zero {p : associates α} (hp : prime p) : p ≠ 0 :=
517
+ hp.1
518
+
519
+ lemma prime.ne_one {p : associates α} (hp : prime p) : p ≠ 1 :=
520
+ hp.2 .1
521
+
522
+ lemma prime.le_or_le {p : associates α} (hp : prime p) {a b : associates α} (h : p ≤ a * b) :
523
+ p ≤ a ∨ p ≤ b :=
524
+ hp.2 .2 a b h
525
+
480
526
lemma exists_mem_multiset_le_of_prime {s : multiset (associates α)} {p : associates α}
481
527
(hp : prime p) :
482
528
p ≤ s.prod → ∃a∈s, p ≤ a :=
483
- multiset.induction_on s (assume ⟨d, eq⟩, (hp.2 . 1 (mul_eq_one_iff.1 eq).1 ).elim) $
529
+ multiset.induction_on s (assume ⟨d, eq⟩, (hp.ne_one (mul_eq_one_iff.1 eq).1 ).elim) $
484
530
assume a s ih h,
485
531
have p ≤ a * s.prod, by simpa using h,
486
- match hp.2 . 2 a s.prod this with
532
+ match hp.le_or_le this with
487
533
| or.inl h := ⟨a, multiset.mem_cons_self a s, h⟩
488
534
| or.inr h := let ⟨a, has, h⟩ := ih h in ⟨a, multiset.mem_cons_of_mem has, h⟩
489
535
end
0 commit comments