Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit c44f19f

Browse files
committed
feat(algebra/associated): simple lemmas and dot notation (#8770)
Introduce * `prime.exists_mem_finset_dvd` * `prime.not_dvd_one` Rename * `exists_mem_multiset_dvd_of_prime` -> `prime.exists_mem_multiset_dvd` * `left_dvd_or_dvd_right_of_dvd_prime_mul ` ->`prime.left_dvd_or_dvd_right_of_dvd_mul`
1 parent 57e127a commit c44f19f

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

archive/imo/imo2001_q6.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ begin
3939
... = (a * c + b * d) * (b ^ 2 + b * d + d ^ 2) : by ring, },
4040
-- since `a*b + c*d` is prime (by assumption), it must divide `a*c + b*d` or `a*d + b*c`
4141
obtain (h1 : a*b + c*d ∣ a*c + b*d) | (h2 : a*c + b*d ∣ a*d + b*c) :=
42-
left_dvd_or_dvd_right_of_dvd_prime_mul h0 dvd_mul,
42+
h0.left_dvd_or_dvd_right_of_dvd_mul dvd_mul,
4343
-- in both cases, we derive a contradiction
4444
{ have aux : 0 < a*c + b*d, { nlinarith only [ha, hb, hc, hd] },
4545
have : a*b + c*d ≤ a*c + b*d, { from int.le_of_dvd aux h1 },

src/algebra/associated.lean

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright (c) 2018 Johannes Hölzl. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johannes Hölzl, Jens Wagemaker
55
-/
6-
import data.multiset.basic
6+
import algebra.big_operators.basic
77
import algebra.divisibility
88
import algebra.invertible
99

@@ -56,14 +56,18 @@ p ≠ 0 ∧ ¬ is_unit p ∧ (∀a b, p ∣ a * b → p ∣ a ∨ p ∣ b)
5656

5757
namespace prime
5858
variables {p : α} (hp : prime p)
59+
include hp
5960

60-
lemma ne_zero (hp : prime p) : p ≠ 0 :=
61+
lemma ne_zero : p ≠ 0 :=
6162
hp.1
6263

63-
lemma not_unit (hp : prime p) : ¬ is_unit p :=
64+
lemma not_unit : ¬ is_unit p :=
6465
hp.2.1
6566

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 :=
6771
λ h, hp.2.1 (h.symm ▸ is_unit_one)
6872

6973
lemma dvd_or_dvd (hp : prime p) {a b : α} (h : p ∣ a * b) :
@@ -84,6 +88,25 @@ begin
8488
exact ih dvd_pow
8589
end
8690

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+
87110
end prime
88111

89112
@[simp] lemma not_prime_zero : ¬ prime (0 : α) :=
@@ -92,22 +115,12 @@ end prime
92115
@[simp] lemma not_prime_one : ¬ prime (1 : α) :=
93116
λ h, h.not_unit is_unit_one
94117

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-
105118
end prime
106119

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 :=
109122
begin
110-
rintros b p hp ⟨c, hc⟩,
123+
rintro ⟨c, hc⟩,
111124
rcases hp.2.2 a c (hc ▸ dvd_mul_right _ _) with h | ⟨x, rfl⟩,
112125
{ exact or.inl h },
113126
{ rw [mul_left_comm, mul_right_inj' hp.ne_zero] at hc,

src/ring_theory/unique_factorization_domain.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ begin
548548
{ intros c p hc hp ih no_factors a_dvd_bpc,
549549
apply ih (λ q dvd_a dvd_c hq, no_factors dvd_a (dvd_mul_of_dvd_right dvd_c _) hq),
550550
rw mul_left_comm at a_dvd_bpc,
551-
refine or.resolve_left (left_dvd_or_dvd_right_of_dvd_prime_mul hp a_dvd_bpc) (λ h, _),
551+
refine or.resolve_left (hp.left_dvd_or_dvd_right_of_dvd_mul a_dvd_bpc) (λ h, _),
552552
exact no_factors h (dvd_mul_right p c) hp }
553553
end
554554

@@ -583,7 +583,7 @@ begin
583583
{ obtain ⟨a', b', c', coprime, rfl, rfl⟩ := ih_a a_ne_zero b,
584584
refine ⟨p * a', b', c', _, mul_left_comm _ _ _, rfl⟩,
585585
intros q q_dvd_pa' q_dvd_b',
586-
cases left_dvd_or_dvd_right_of_dvd_prime_mul p_prime q_dvd_pa' with p_dvd_q q_dvd_a',
586+
cases p_prime.left_dvd_or_dvd_right_of_dvd_mul q_dvd_pa' with p_dvd_q q_dvd_a',
587587
{ have : p ∣ c' * b' := dvd_mul_of_dvd_right (p_dvd_q.trans q_dvd_b') _,
588588
contradiction },
589589
exact coprime q_dvd_a' q_dvd_b' } }

0 commit comments

Comments
 (0)