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

Commit 2c4e66f

Browse files
committed
split(data/finset/*): Split data.finset.card and data.finset.fin off data.finset.basic (#10796)
This moves stuff from `data.finset.basic` in two new files: * Stuff about `finset.card` goes into `data.finset.card` * Stuff about `finset.fin_range` and `finset.attach_fin` goes into `data.finset.fin`. I expect this file to be shortlived as I'm planning on killing `fin_range`. I reordered lemmas thematically and it appeared that there were two pairs of duplicated lemmas: * `finset.one_lt_card`, `finset.one_lt_card_iff`. They differ only for binder order. * `finset.card_union_eq`, `finset.card_disjoint_union`. They are literally the same. All are used so I will clean up in a later PR. I'm crediting: * Microsoft Corporation, Leonardo, Jeremy for 8dbee5b * Chris Hughes for #231 * Scott for #3319
1 parent fa46ef1 commit 2c4e66f

File tree

9 files changed

+565
-538
lines changed

9 files changed

+565
-538
lines changed

src/combinatorics/set_family/compression/uv.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright (c) 2021 Bhavik Mehta. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Yaël Dillies, Bhavik Mehta
55
-/
6-
import data.finset.basic
6+
import data.finset.card
77

88
/-!
99
# UV-compressions

src/data/finset/basic.lean

Lines changed: 4 additions & 534 deletions
Large diffs are not rendered by default.

src/data/finset/card.lean

Lines changed: 506 additions & 0 deletions
Large diffs are not rendered by default.

src/data/finset/fin.lean

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/-
2+
Copyright (c) 2018 Chris Hughes. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Chris Hughes, Scott Morrison, Johan Commelin
5+
-/
6+
import data.finset.card
7+
8+
/-!
9+
# Finsets in `fin n`
10+
11+
A few constructions for finsets in `fin n`.
12+
13+
## Main declarations
14+
15+
* `finset.fin_range`: `{0, 1, ..., n - 1}` as a `finset (fin n)`.
16+
* `finset.attach_fin`: Turns a finset of naturals strictly less than `n` into a `finset (fin n)`.
17+
-/
18+
19+
variables {n : ℕ}
20+
21+
namespace finset
22+
23+
/-- `finset.fin_range n` is the finset `{0, 1, ..., n - 1}`, as a `finset (fin n)`. -/
24+
def fin_range (n : ℕ) : finset (fin n) := ⟨list.fin_range n, list.nodup_fin_range n⟩
25+
26+
@[simp]
27+
lemma fin_range_card : (fin_range n).card = n := by simp [fin_range]
28+
29+
@[simp]
30+
lemma mem_fin_range (m : fin n) : m ∈ fin_range n := list.mem_fin_range m
31+
32+
@[simp] lemma coe_fin_range (n : ℕ) : (fin_range n : set (fin n)) = set.univ :=
33+
set.eq_univ_of_forall mem_fin_range
34+
35+
/-- Given a finset `s` of `ℕ` contained in `{0,..., n-1}`, the corresponding finset in `fin n`
36+
is `s.attach_fin h` where `h` is a proof that all elements of `s` are less than `n`. -/
37+
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
39+
40+
@[simp] lemma mem_attach_fin {n : ℕ} {s : finset ℕ} (h : ∀ m ∈ s, m < n) {a : fin n} :
41+
a ∈ s.attach_fin h ↔ (a : ℕ) ∈ s :=
42+
⟨λ h, let ⟨b, hb₁, hb₂⟩ := multiset.mem_pmap.1 h in hb₂ ▸ hb₁,
43+
λ h, multiset.mem_pmap.2 ⟨a, h, fin.eta _ _⟩⟩
44+
45+
@[simp] lemma card_attach_fin {n : ℕ} (s : finset ℕ) (h : ∀ m ∈ s, m < n) :
46+
(s.attach_fin h).card = s.card :=
47+
multiset.card_pmap _ _ _
48+
49+
end finset

src/data/finset/nat_antidiagonal.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright (c) 2019 Johan Commelin. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johan Commelin
55
-/
6-
import data.finset.basic
6+
import data.finset.card
77
import data.multiset.nat_antidiagonal
88

99
/-!

src/data/finset/option.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright (c) 2021 Yury Kudryashov. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Yury Kudryashov, Mario Carneiro, Sean Leather
55
-/
6-
import data.finset.basic
6+
import data.finset.card
77
import order.hom.basic
88

99
/-!

src/data/finset/prod.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright (c) 2017 Microsoft Corporation. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johannes Hölzl, Mario Carneiro, Oliver Nash
55
-/
6-
import data.finset.basic
6+
import data.finset.card
77

88
/-!
99
# Finsets in product types

src/data/fintype/basic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Mario Carneiro
55
-/
66
import data.array.lemmas
7+
import data.finset.fin
78
import data.finset.option
89
import data.finset.pi
910
import data.finset.powerset

src/group_theory/perm/support.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Copyright (c) 2018 Chris Hughes. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Chris Hughes, Aaron Anderson, Yakov Pechersky
55
-/
6+
import data.finset.card
67
import data.fintype.basic
78
import group_theory.perm.basic
89

0 commit comments

Comments
 (0)