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

Commit 201d2c6

Browse files
committed
refactor(data/nat/enat): rename enat to part_enat (#15235)
* find+replace `enat` with `part_enat`; * reflow long lines * add a sentence to the module docstring of `data.nat.enat`. I'm going to define `enat := with_top nat` and use it as the default implementation of "nat with top".
1 parent 44905df commit 201d2c6

File tree

25 files changed

+328
-317
lines changed

25 files changed

+328
-317
lines changed

archive/imo/imo2019_q4.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ begin
3434
{ exact prime_iff_prime_int.mp prime_two },
3535
have h2 : n * (n - 1) / 2 < k,
3636
{ suffices : multiplicity 2 (k! : ℤ) = (n * (n - 1) / 2 : ℕ),
37-
{ rw [← enat.coe_lt_coe, ← this], change multiplicity ((2 : ℕ) : ℤ) _ < _,
37+
{ rw [← part_enat.coe_lt_coe, ← this], change multiplicity ((2 : ℕ) : ℤ) _ < _,
3838
simp_rw [int.coe_nat_multiplicity, multiplicity_two_factorial_lt hk.lt.ne.symm] },
3939
rw [h, multiplicity.finset.prod prime_2, ← sum_range_id, ← sum_nat_coe_enat],
4040
apply sum_congr rfl, intros i hi,
4141
rw [multiplicity_sub_of_gt, multiplicity_pow_self_of_prime prime_2],
4242
rwa [multiplicity_pow_self_of_prime prime_2, multiplicity_pow_self_of_prime prime_2,
43-
enat.coe_lt_coe, ←mem_range] },
43+
part_enat.coe_lt_coe, ←mem_range] },
4444
rw [←not_le], intro hn,
4545
apply ne_of_lt _ h.symm,
4646
suffices : (∏ i in range n, 2 ^ n : ℤ) < ↑k!,

src/algebra/big_operators/enat.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import algebra.big_operators.basic
77
import data.nat.enat
88

99
/-!
10-
# Big operators in `enat`
10+
# Big operators in `part_enat`
1111
12-
A simple lemma about sums in `enat`.
12+
A simple lemma about sums in `part_enat`.
1313
-/
1414
open_locale big_operators
1515
variables {α : Type*}
1616

1717
namespace finset
1818
lemma sum_nat_coe_enat (s : finset α) (f : α → ℕ) :
19-
(∑ x in s, (f x : enat)) = (∑ x in s, f x : ℕ) :=
20-
(enat.coe_hom.map_sum _ _).symm
19+
(∑ x in s, (f x : part_enat)) = (∑ x in s, f x : ℕ) :=
20+
(part_enat.coe_hom.map_sum _ _).symm
2121

2222
end finset

src/algebra/order/sub.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This file proves lemmas relating (truncated) subtraction with an order. We provi
1111
`has_ordered_sub` stating that `a - b ≤ c ↔ a ≤ c + b`.
1212
1313
The subtraction discussed here could both be normal subtraction in an additive group or truncated
14-
subtraction on a canonically ordered monoid (`ℕ`, `multiset`, `enat`, `ennreal`, ...)
14+
subtraction on a canonically ordered monoid (`ℕ`, `multiset`, `part_enat`, `ennreal`, ...)
1515
1616
## Implementation details
1717

src/algebra/squarefree.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ lemma squarefree_iff_multiplicity_le_one (r : R) :
9393
begin
9494
refine forall_congr (λ a, _),
9595
rw [← sq, pow_dvd_iff_le_multiplicity, or_iff_not_imp_left, not_le, imp_congr _ iff.rfl],
96-
simpa using enat.add_one_le_iff_lt (enat.coe_ne_top 1)
96+
simpa using part_enat.add_one_le_iff_lt (part_enat.coe_ne_top 1)
9797
end
9898

9999
end comm_monoid
@@ -110,10 +110,10 @@ begin
110110
refine wf_dvd_monoid.induction_on_irreducible b (by contradiction) (λ u hu hu', _)
111111
(λ b p hb hp ih hpb, _),
112112
{ rw [multiplicity.finite_iff_dom, multiplicity.is_unit_right ha.not_unit hu],
113-
exact enat.dom_coe 0, },
113+
exact part_enat.dom_coe 0, },
114114
{ refine multiplicity.finite_mul ha
115-
(multiplicity.finite_iff_dom.mpr (enat.dom_of_le_coe (show multiplicity a p ≤ ↑1, from _)))
116-
(ih hb),
115+
(multiplicity.finite_iff_dom.mpr
116+
(part_enat.dom_of_le_coe (show multiplicity a p ≤ ↑1, from _))) (ih hb),
117117
norm_cast,
118118
exact (((multiplicity.squarefree_iff_multiplicity_le_one p).mp hp.squarefree a)
119119
.resolve_right ha.not_unit) }

src/data/nat/choose/factorization.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ begin
3939
have hp : p.prime := not.imp_symm (choose n k).factorization_eq_zero_of_non_prime h,
4040
have hkn : k ≤ n, { refine le_of_not_lt (λ hnk, h _), simp [choose_eq_zero_of_lt hnk] },
4141
rw [←@padic_val_nat_eq_factorization p _ ⟨hp⟩, @padic_val_nat_def _ ⟨hp⟩ _ (choose_pos hkn)],
42-
simp only [hp.multiplicity_choose hkn (lt_add_one _), enat.get_coe],
42+
simp only [hp.multiplicity_choose hkn (lt_add_one _), part_enat.get_coe],
4343
refine (finset.card_filter_le _ _).trans (le_of_eq (nat.card_Ico _ _)),
4444
end
4545

@@ -74,7 +74,7 @@ begin
7474
cases lt_or_le n k with hnk hkn,
7575
{ simp [choose_eq_zero_of_lt hnk] },
7676
rw [←@padic_val_nat_eq_factorization p _ ⟨hp⟩, @padic_val_nat_def _ ⟨hp⟩ _ (choose_pos hkn)],
77-
simp only [hp.multiplicity_choose hkn (lt_add_one _), enat.get_coe,
77+
simp only [hp.multiplicity_choose hkn (lt_add_one _), part_enat.get_coe,
7878
finset.card_eq_zero, finset.filter_eq_empty_iff, not_le],
7979
intros i hi,
8080
rcases eq_or_lt_of_le (finset.mem_Ico.mp hi).1 with rfl | hi,

0 commit comments

Comments
 (0)