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

Commit 6179707

Browse files
committed
feat(ring_theory/unique_factorization_domain): add count_self (#12074)
1 parent 6f1d90d commit 6179707

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/data/multiset/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1605,7 +1605,7 @@ theorem count_cons (a b : α) (s : multiset α) :
16051605
count a (b ::ₘ s) = count a s + (if a = b then 1 else 0) :=
16061606
by by_cases h : a = b; simp [h]
16071607

1608-
theorem count_singleton_self (a : α) : count a ({a} : multiset α) = 1 :=
1608+
@[simp] theorem count_singleton_self (a : α) : count a ({a} : multiset α) = 1 :=
16091609
by simp only [count_cons_self, singleton_eq_cons, eq_self_iff_true, count_zero]
16101610

16111611
theorem count_singleton (a b : α) : count a ({b} : multiset α) = if a = b then 1 else 0 :=

src/ring_theory/unique_factorization_domain.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,11 @@ end
11521152

11531153
omit dec_irr
11541154

1155+
theorem factors_self [nontrivial α] {p : associates α} (hp : irreducible p) :
1156+
p.factors = some ({⟨p, hp⟩}) :=
1157+
eq_of_prod_eq_prod (by rw [factors_prod, factor_set.prod, map_singleton, prod_singleton,
1158+
subtype.coe_mk])
1159+
11551160
theorem factors_prime_pow [nontrivial α] {p : associates α} (hp : irreducible p)
11561161
(k : ℕ) : factors (p ^ k) = some (multiset.repeat ⟨p, hp⟩ k) :=
11571162
eq_of_prod_eq_prod (by rw [associates.factors_prod, factor_set.prod, multiset.map_repeat,
@@ -1190,6 +1195,10 @@ begin
11901195
exact (zero_lt_one.trans_le h).ne' }
11911196
end
11921197

1198+
theorem count_self [nontrivial α] {p : associates α} (hp : irreducible p) :
1199+
p.count p.factors = 1 :=
1200+
by simp [factors_self hp, associates.count_some hp]
1201+
11931202
theorem count_mul [nontrivial α] {a : associates α} (ha : a ≠ 0) {b : associates α} (hb : b ≠ 0)
11941203
{p : associates α} (hp : irreducible p) :
11951204
count p (factors (a * b)) = count p a.factors + count p b.factors :=

0 commit comments

Comments
 (0)