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

Commit 584ae9d

Browse files
committed
chore(data/{lists,multiset}/*): More dot notation (#12876)
Rename many `list` and `multiset` lemmas to make them eligible to dot notation. Also add a few aliases to `↔` lemmas for even more dot notation. Renames
1 parent e620519 commit 584ae9d

36 files changed

+288
-346
lines changed

src/algebra/squarefree.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ lemma divisors_filter_squarefree {n : ℕ} (h0 : n ≠ 0) :
349349
(unique_factorization_monoid.normalized_factors n).to_finset.powerset.val.map
350350
(λ x, x.val.prod) :=
351351
begin
352-
rw multiset.nodup_ext (finset.nodup _) (multiset.nodup_map_on _ (finset.nodup _)),
352+
rw (finset.nodup _).ext ((finset.nodup _).map_on _),
353353
{ intro a,
354354
simp only [multiset.mem_filter, id.def, multiset.mem_map, finset.filter_val, ← finset.mem_def,
355355
mem_divisors],

src/combinatorics/simple_graph/connectivity.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ by split; intro h; convert h.reverse; simp
487487

488488
lemma is_path.of_append_left {u v w : V} {p : G.walk u v} {q : G.walk v w} :
489489
(p.append q).is_path → p.is_path :=
490-
by { simp only [is_path_def, support_append], exact list.nodup_of_nodup_append_left }
490+
by { simp only [is_path_def, support_append], exact list.nodup.of_append_left }
491491

492492
lemma is_path.of_append_right {u v w : V} {p : G.walk u v} {q : G.walk v w}
493493
(h : (p.append q).is_path) : q.is_path :=

src/data/equiv/list.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ lemma raise_lower : ∀ {l n}, list.sorted (≤) (n :: l) → raise (lower l n)
236236
| [] n h := rfl
237237
| (m :: l) n h :=
238238
have n ≤ m, from list.rel_of_sorted_cons h _ (l.mem_cons_self _),
239-
by simp [raise, lower, tsub_add_cancel_of_le this,
240-
raise_lower (list.sorted_of_sorted_cons h)]
239+
by simp [raise, lower, tsub_add_cancel_of_le this, raise_lower h.of_cons]
241240

242241
lemma raise_chain : ∀ l n, list.chain (≤) n (raise l n)
243242
| [] n := list.chain.nil
@@ -284,7 +283,7 @@ lemma raise_lower' : ∀ {l n}, (∀ m ∈ l, n ≤ m) → list.sorted (<) l →
284283
| (m :: l) n h₁ h₂ :=
285284
have n ≤ m, from h₁ _ (l.mem_cons_self _),
286285
by simp [raise', lower', tsub_add_cancel_of_le this, raise_lower'
287-
(list.rel_of_sorted_cons h₂ : ∀ a ∈ l, m < a) (list.sorted_of_sorted_cons h₂)]
286+
(list.rel_of_sorted_cons h₂ : ∀ a ∈ l, m < a) h₂.of_cons]
288287

289288
lemma raise'_chain : ∀ l {m n}, m < n → list.chain (<) m (raise' l n)
290289
| [] m n h := list.chain.nil

src/data/fin_enum.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ open function
5959
by simp [to_list]; existsi equiv α x; simp
6060

6161
@[simp] lemma nodup_to_list [fin_enum α] : list.nodup (to_list α) :=
62-
by simp [to_list]; apply list.nodup_map; [apply equiv.injective, apply list.nodup_fin_range]
62+
by simp [to_list]; apply list.nodup.map; [apply equiv.injective, apply list.nodup_fin_range]
6363

6464
/-- create a `fin_enum` instance using a surjection -/
6565
def of_surjective {β} (f : β → α) [decidable_eq α] [fin_enum β] (h : surjective f) : fin_enum α :=

src/data/finset/basic.lean

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ instance decidable_mem' [decidable_eq α] (a : α) (s : finset α) :
186186

187187
/-! ### extensionality -/
188188
theorem ext_iff {s₁ s₂ : finset α} : s₁ = s₂ ↔ ∀ a, a ∈ s₁ ↔ a ∈ s₂ :=
189-
val_inj.symm.trans $ nodup_ext s₁.2 s₂.2
189+
val_inj.symm.trans $ s₁.nodup.ext s₂.nodup
190190

191191
@[ext]
192192
theorem ext {s₁ s₂ : finset α} : (∀ a, a ∈ s₁ ↔ a ∈ s₂) → s₁ = s₂ :=
@@ -548,9 +548,9 @@ section decidable_eq
548548
variables [decidable_eq α] {s t u v : finset α} {a b : α}
549549

550550
/-- `insert a s` is the set `{a} ∪ s` containing `a` and the elements of `s`. -/
551-
instance : has_insert α (finset α) := ⟨λ a s, ⟨_, nodup_ndinsert a s.2⟩⟩
551+
instance : has_insert α (finset α) := ⟨λ a s, ⟨_, s.2.ndinsert a⟩⟩
552552

553-
theorem insert_def (a : α) (s : finset α) : insert a s = ⟨_, nodup_ndinsert a s.2⟩ := rfl
553+
lemma insert_def (a : α) (s : finset α) : insert a s = ⟨_, s.2.ndinsert a⟩ := rfl
554554

555555
@[simp] theorem insert_val (a : α) (s : finset α) : (insert a s).1 = ndinsert a s.1 := rfl
556556

@@ -715,10 +715,10 @@ end
715715
/-! ### Lattice structure -/
716716

717717
/-- `s ∪ t` is the set such that `a ∈ s ∪ t` iff `a ∈ s` or `a ∈ t`. -/
718-
instance : has_union (finset α) := ⟨λ s t, ⟨_, nodup_ndunion s.1 t.2⟩⟩
718+
instance : has_union (finset α) := ⟨λ s t, ⟨_, t.2.ndunion s.1⟩⟩
719719

720720
/-- `s ∩ t` is the set such that `a ∈ s ∩ t` iff `a ∈ s` and `a ∈ t`. -/
721-
instance : has_inter (finset α) := ⟨λ s t, ⟨_, nodup_ndinter t.1 s.2⟩⟩
721+
instance : has_inter (finset α) := ⟨λ s t, ⟨_, s.2.ndinter t.1⟩⟩
722722

723723
instance : lattice (finset α) :=
724724
{ sup := (∪),
@@ -993,14 +993,14 @@ lemma inter_subset_ite (s s' : finset α) (P : Prop) [decidable P] :
993993

994994
/-- `erase s a` is the set `s - {a}`, that is, the elements of `s` which are
995995
not equal to `a`. -/
996-
def erase (s : finset α) (a : α) : finset α := ⟨_, nodup_erase_of_nodup a s.2
996+
def erase (s : finset α) (a : α) : finset α := ⟨_, s.2.erase a
997997

998998
@[simp] theorem erase_val (s : finset α) (a : α) : (erase s a).1 = s.1.erase a := rfl
999999

10001000
@[simp] theorem mem_erase {a b : α} {s : finset α} : a ∈ erase s b ↔ a ≠ b ∧ a ∈ s :=
1001-
mem_erase_iff_of_nodup s.2
1001+
s.2.mem_erase_iff
10021002

1003-
theorem not_mem_erase (a : α) (s : finset α) : a ∉ erase s a := mem_erase_of_nodup s.2
1003+
lemma not_mem_erase (a : α) (s : finset α) : a ∉ erase s a := s.2.not_mem_erase
10041004

10051005
-- While this can be solved by `simp`, this lemma is eligible for `dsimp`
10061006
@[nolint simp_nf, simp] theorem erase_empty (a : α) : erase ∅ a = ∅ := rfl
@@ -1395,8 +1395,7 @@ section filter
13951395
variables (p q : α → Prop) [decidable_pred p] [decidable_pred q]
13961396

13971397
/-- `filter p s` is the set of elements of `s` that satisfy `p`. -/
1398-
def filter (s : finset α) : finset α :=
1399-
⟨_, nodup_filter p s.2
1398+
def filter (s : finset α) : finset α := ⟨_, s.2.filter p⟩
14001399

14011400
@[simp] theorem filter_val (s : finset α) : (filter p s).1 = s.1.filter p := rfl
14021401

@@ -1817,8 +1816,7 @@ open function
18171816

18181817
/-- When `f` is an embedding of `α` in `β` and `s` is a finset in `α`, then `s.map f` is the image
18191818
finset in `β`. The embedding condition guarantees that there are no duplicates in the image. -/
1820-
def map (f : α ↪ β) (s : finset α) : finset β :=
1821-
⟨s.1.map f, nodup_map f.2 s.2
1819+
def map (f : α ↪ β) (s : finset α) : finset β := ⟨s.1.map f, s.2.map f.2
18221820

18231821
@[simp] theorem map_val (f : α ↪ β) (s : finset α) : (map f s).1 = s.1.map f := rfl
18241822

@@ -1977,8 +1975,7 @@ instance [can_lift β α] : can_lift (finset β) (finset α) :=
19771975
begin
19781976
rintro ⟨⟨l⟩, hd : l.nodup⟩ hl,
19791977
lift l to list α using hl,
1980-
refine ⟨⟨l, list.nodup_of_nodup_map _ hd⟩, ext $ λ a, _⟩,
1981-
simp
1978+
exact ⟨⟨l, hd.of_map _⟩, ext $ λ a, by simp⟩,
19821979
end }
19831980

19841981
lemma image_congr (h : (s : set α).eq_on f g) : finset.image f s = finset.image g s :=
@@ -2014,8 +2011,7 @@ theorem image_to_finset [decidable_eq α] {s : multiset α} :
20142011
s.to_finset.image f = (s.map f).to_finset :=
20152012
ext $ λ _, by simp only [mem_image, multiset.mem_to_finset, exists_prop, multiset.mem_map]
20162013

2017-
theorem image_val_of_inj_on (H : set.inj_on f s) : (image f s).1 = s.1.map f :=
2018-
(nodup_map_on H s.2).dedup
2014+
lemma image_val_of_inj_on (H : set.inj_on f s) : (image f s).1 = s.1.map f := (s.2.map_on H).dedup
20192015

20202016
@[simp] lemma image_id [decidable_eq α] : s.image id = s :=
20212017
ext $ λ _, by simp only [mem_image, exists_prop, id, exists_eq_right]

src/data/finset/fin.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ set.eq_univ_of_forall mem_fin_range
3535
/-- Given a finset `s` of `ℕ` contained in `{0,..., n-1}`, the corresponding finset in `fin n`
3636
is `s.attach_fin h` where `h` is a proof that all elements of `s` are less than `n`. -/
3737
def attach_fin (s : finset ℕ) {n : ℕ} (h : ∀ m ∈ s, m < n) : finset (fin n) :=
38-
⟨s.1.pmap (λ a ha, ⟨a, ha⟩) h, multiset.nodup_pmap (λ _ _ _ _, fin.veq_of_eq) s.2
38+
⟨s.1.pmap (λ a ha, ⟨a, ha⟩) h, s.nodup.pmap $ λ _ _ _ _, fin.veq_of_eq⟩
3939

4040
@[simp] lemma mem_attach_fin {n : ℕ} {s : finset ℕ} (h : ∀ m ∈ s, m < n) {a : fin n} :
4141
a ∈ s.attach_fin h ↔ (a : ℕ) ∈ s :=

src/data/finset/noncomm_prod.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ begin
318318
obtain ⟨tl, tl', rfl⟩ := exists_list_nodup_eq t,
319319
rw list.disjoint_to_finset_iff_disjoint at h,
320320
simp [sl', tl', noncomm_prod_to_finset, ←list.prod_append, ←list.to_finset_append,
321-
list.nodup_append_of_nodup sl' tl' h]
321+
sl'.append tl' h]
322322
end
323323

324324
@[protected, to_additive]

src/data/finset/option.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ order_embedding.of_map_le_iff (λ s, cons none (s.map embedding.some) $ by simp)
5454
cons_subset_cons.trans map_subset_map
5555

5656
/-⟨none ::ₘ s.1.map some, multiset.nodup_cons.2
57-
⟨by simp, multiset.nodup_map (λ a b, option.some.inj) s.2⟩⟩-/
57+
⟨by simp, s.nodup.map $ λ a b, option.some.inj⟩⟩-/
5858

5959
@[simp] theorem mem_insert_none {s : finset α} : ∀ {o : option α},
6060
o ∈ s.insert_none ↔ ∀ a ∈ o, a ∈ s

src/data/finset/pi.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ variables {δ : α → Type*} [decidable_eq α]
2828
finset `s.pi t` of all functions defined on elements of `s` taking values in `t a` for `a ∈ s`.
2929
Note that the elements of `s.pi t` are only partially defined, on `s`. -/
3030
def pi (s : finset α) (t : Πa, finset (δ a)) : finset (Πa∈s, δ a) :=
31-
⟨s.1.pi (λ a, (t a).1), nodup_pi s.2 (λ a _, (t a).2)
31+
⟨s.1.pi (λ a, (t a).1), s.nodup.pi $ λ a _, (t a).nodup
3232

3333
@[simp] lemma pi_val (s : finset α) (t : Πa, finset (δ a)) :
3434
(s.pi t).1 = s.1.pi (λ a, (t a).1) := rfl
@@ -80,8 +80,7 @@ begin
8080
λ f a' h', multiset.pi.cons s.1 a b f a' (h ▸ h')))) _ (insert_val_of_not_mem ha),
8181
subst s', rw pi_cons,
8282
congr, funext b,
83-
rw multiset.nodup.dedup,
84-
exact multiset.nodup_map (multiset.pi_cons_injective ha) (pi s t).2,
83+
exact ((pi s t).nodup.map $ multiset.pi_cons_injective ha).dedup.symm,
8584
end
8685

8786
lemma pi_singletons {β : Type*} (s : finset α) (f : α → β) :

src/data/finset/powerset.lean

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ section powerset
1919

2020
/-- When `s` is a finset, `s.powerset` is the finset of all subsets of `s` (seen as finsets). -/
2121
def powerset (s : finset α) : finset (finset α) :=
22-
⟨s.1.powerset.pmap finset.mk
23-
(λ t h, nodup_of_le (mem_powerset.1 h) s.2),
24-
nodup_pmap (λ a ha b hb, congr_arg finset.val)
25-
(nodup_powerset.2 s.2)⟩
22+
⟨s.1.powerset.pmap finset.mk $ λ t h, nodup_of_le (mem_powerset.1 h) s.nodup,
23+
s.nodup.powerset.pmap $ λ a ha b hb, congr_arg finset.val⟩
2624

2725
@[simp] theorem mem_powerset {s t : finset α} : s ∈ powerset t ↔ s ⊆ t :=
2826
by cases s; simp only [powerset, mem_mk, mem_pmap, mem_powerset, exists_prop, exists_eq_right];
@@ -138,10 +136,8 @@ section powerset_len
138136
/-- Given an integer `n` and a finset `s`, then `powerset_len n s` is the finset of subsets of `s`
139137
of cardinality `n`. -/
140138
def powerset_len (n : ℕ) (s : finset α) : finset (finset α) :=
141-
⟨(s.1.powerset_len n).pmap finset.mk
142-
(λ t h, nodup_of_le (mem_powerset_len.1 h).1 s.2),
143-
nodup_pmap (λ a ha b hb, congr_arg finset.val)
144-
(nodup_powerset_len s.2)⟩
139+
⟨(s.1.powerset_len n).pmap finset.mk $ λ t h, nodup_of_le (mem_powerset_len.1 h).1 s.2,
140+
s.2.powerset_len.pmap $ λ a ha b hb, congr_arg finset.val⟩
145141

146142
/-- **Formula for the Number of Combinations** -/
147143
theorem mem_powerset_len {n} {s t : finset α} :

0 commit comments

Comments
 (0)