data.finset.powerset
⟷
Mathlib.Data.Finset.Powerset
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -139,7 +139,7 @@ theorem powerset_insert [DecidableEq α] (s : Finset α) (a : α) :
#align finset.powerset_insert Finset.powerset_insert
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (t «expr ⊆ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (t «expr ⊆ » s) -/
#print Finset.decidableExistsOfDecidableSubsets /-
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for any subset. -/
instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
@@ -149,7 +149,7 @@ instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t
#align finset.decidable_exists_of_decidable_subsets Finset.decidableExistsOfDecidableSubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (t «expr ⊆ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (t «expr ⊆ » s) -/
#print Finset.decidableForallOfDecidableSubsets /-
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for every subset. -/
instance decidableForallOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
@@ -203,7 +203,7 @@ theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets
#align finset.empty_mem_ssubsets Finset.empty_mem_ssubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (t «expr ⊂ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (t «expr ⊂ » s) -/
#print Finset.decidableExistsOfDecidableSSubsets /-
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for any ssubset. -/
instance decidableExistsOfDecidableSSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
@@ -213,7 +213,7 @@ instance decidableExistsOfDecidableSSubsets {s : Finset α} {p : ∀ (t) (_ : t
#align finset.decidable_exists_of_decidable_ssubsets Finset.decidableExistsOfDecidableSSubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (t «expr ⊂ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (t «expr ⊂ » s) -/
#print Finset.decidableForallOfDecidableSSubsets /-
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for every ssubset. -/
instance decidableForallOfDecidableSSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -321,12 +321,12 @@ theorem powersetCard_nonempty {n : ℕ} {s : Finset α} (h : n ≤ s.card) :
(powersetCard n s).Nonempty := by
classical
induction' s using Finset.induction_on with x s hx IH generalizing n
- · rw [card_empty, le_zero_iff] at h
+ · rw [card_empty, le_zero_iff] at h
rw [h, powerset_len_zero]
exact Finset.singleton_nonempty _
· cases n
· simp
- · rw [card_insert_of_not_mem hx, Nat.succ_le_succ_iff] at h
+ · rw [card_insert_of_not_mem hx, Nat.succ_le_succ_iff] at h
rw [powerset_len_succ_insert hx]
refine' nonempty.mono _ ((IH h).image (insert x))
convert subset_union_right _ _
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -318,7 +318,18 @@ theorem powersetCard_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h :
#print Finset.powersetCard_nonempty /-
theorem powersetCard_nonempty {n : ℕ} {s : Finset α} (h : n ≤ s.card) :
- (powersetCard n s).Nonempty := by classical
+ (powersetCard n s).Nonempty := by
+ classical
+ induction' s using Finset.induction_on with x s hx IH generalizing n
+ · rw [card_empty, le_zero_iff] at h
+ rw [h, powerset_len_zero]
+ exact Finset.singleton_nonempty _
+ · cases n
+ · simp
+ · rw [card_insert_of_not_mem hx, Nat.succ_le_succ_iff] at h
+ rw [powerset_len_succ_insert hx]
+ refine' nonempty.mono _ ((IH h).image (insert x))
+ convert subset_union_right _ _
#align finset.powerset_len_nonempty Finset.powersetCard_nonempty
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -318,18 +318,7 @@ theorem powersetCard_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h :
#print Finset.powersetCard_nonempty /-
theorem powersetCard_nonempty {n : ℕ} {s : Finset α} (h : n ≤ s.card) :
- (powersetCard n s).Nonempty := by
- classical
- induction' s using Finset.induction_on with x s hx IH generalizing n
- · rw [card_empty, le_zero_iff] at h
- rw [h, powerset_len_zero]
- exact Finset.singleton_nonempty _
- · cases n
- · simp
- · rw [card_insert_of_not_mem hx, Nat.succ_le_succ_iff] at h
- rw [powerset_len_succ_insert hx]
- refine' nonempty.mono _ ((IH h).image (insert x))
- convert subset_union_right _ _
+ (powersetCard n s).Nonempty := by classical
#align finset.powerset_len_nonempty Finset.powersetCard_nonempty
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -312,7 +312,7 @@ theorem powersetCard_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h :
simp only [mem_powerset, mem_filter, Function.comp_apply, and_congr_right_iff]
intro ht
have : x ∉ t := fun H => h (ht H)
- simp [card_insert_of_not_mem this, Nat.succ_inj']
+ simp [card_insert_of_not_mem this, Nat.succ_inj]
#align finset.powerset_len_succ_insert Finset.powersetCard_succ_insert
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -286,11 +286,11 @@ theorem powersetCard_zero (s : Finset α) : Finset.powersetCard 0 s = {∅} :=
#align finset.powerset_len_zero Finset.powersetCard_zero
-/
-#print Finset.powersetCard_empty /-
+#print Finset.powersetCard_eq_empty /-
@[simp]
-theorem powersetCard_empty (n : ℕ) {s : Finset α} (h : s.card < n) : powersetCard n s = ∅ :=
+theorem powersetCard_eq_empty (n : ℕ) {s : Finset α} (h : s.card < n) : powersetCard n s = ∅ :=
Finset.card_eq_zero.mp (by rw [card_powerset_len, Nat.choose_eq_zero_of_lt h])
-#align finset.powerset_len_empty Finset.powersetCard_empty
+#align finset.powerset_len_empty Finset.powersetCard_eq_empty
-/
#print Finset.powersetCard_eq_filter /-
@@ -403,7 +403,7 @@ theorem powersetCard_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.
@[simp]
theorem powersetCard_card_add (s : Finset α) {i : ℕ} (hi : 0 < i) :
s.powersetCard (s.card + i) = ∅ :=
- Finset.powersetCard_empty _ (lt_add_of_pos_right (Finset.card s) hi)
+ Finset.powersetCard_eq_empty _ (lt_add_of_pos_right (Finset.card s) hi)
#align finset.powerset_len_card_add Finset.powersetCard_card_add
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/b1abe23ae96fef89ad30d9f4362c307f72a55010
@@ -245,62 +245,64 @@ end Ssubsets
section PowersetLen
-#print Finset.powersetLen /-
+#print Finset.powersetCard /-
/-- Given an integer `n` and a finset `s`, then `powerset_len n s` is the finset of subsets of `s`
of cardinality `n`. -/
-def powersetLen (n : ℕ) (s : Finset α) : Finset (Finset α) :=
- ⟨(s.1.powersetLen n).pmap Finset.mk fun t h => nodup_of_le (mem_powersetLen.1 h).1 s.2,
- s.2.powersetLen.pmap fun a ha b hb => congr_arg Finset.val⟩
-#align finset.powerset_len Finset.powersetLen
+def powersetCard (n : ℕ) (s : Finset α) : Finset (Finset α) :=
+ ⟨(s.1.powersetCard n).pmap Finset.mk fun t h => nodup_of_le (mem_powersetCard.1 h).1 s.2,
+ s.2.powersetCard.pmap fun a ha b hb => congr_arg Finset.val⟩
+#align finset.powerset_len Finset.powersetCard
-/
-#print Finset.mem_powersetLen /-
+#print Finset.mem_powersetCard /-
/-- **Formula for the Number of Combinations** -/
-theorem mem_powersetLen {n} {s t : Finset α} : s ∈ powersetLen n t ↔ s ⊆ t ∧ card s = n := by
+theorem mem_powersetCard {n} {s t : Finset α} : s ∈ powersetCard n t ↔ s ⊆ t ∧ card s = n := by
cases s <;> simp [powerset_len, val_le_iff.symm] <;> rfl
-#align finset.mem_powerset_len Finset.mem_powersetLen
+#align finset.mem_powerset_len Finset.mem_powersetCard
-/
-#print Finset.powersetLen_mono /-
+#print Finset.powersetCard_mono /-
@[simp]
-theorem powersetLen_mono {n} {s t : Finset α} (h : s ⊆ t) : powersetLen n s ⊆ powersetLen n t :=
- fun u h' => mem_powersetLen.2 <| And.imp (fun h₂ => Subset.trans h₂ h) id (mem_powersetLen.1 h')
-#align finset.powerset_len_mono Finset.powersetLen_mono
+theorem powersetCard_mono {n} {s t : Finset α} (h : s ⊆ t) : powersetCard n s ⊆ powersetCard n t :=
+ fun u h' => mem_powersetCard.2 <| And.imp (fun h₂ => Subset.trans h₂ h) id (mem_powersetCard.1 h')
+#align finset.powerset_len_mono Finset.powersetCard_mono
-/
-#print Finset.card_powersetLen /-
+#print Finset.card_powersetCard /-
/-- **Formula for the Number of Combinations** -/
@[simp]
-theorem card_powersetLen (n : ℕ) (s : Finset α) : card (powersetLen n s) = Nat.choose (card s) n :=
- (card_pmap _ _ _).trans (card_powersetLen n s.1)
-#align finset.card_powerset_len Finset.card_powersetLen
+theorem card_powersetCard (n : ℕ) (s : Finset α) :
+ card (powersetCard n s) = Nat.choose (card s) n :=
+ (card_pmap _ _ _).trans (card_powersetCard n s.1)
+#align finset.card_powerset_len Finset.card_powersetCard
-/
-#print Finset.powersetLen_zero /-
+#print Finset.powersetCard_zero /-
@[simp]
-theorem powersetLen_zero (s : Finset α) : Finset.powersetLen 0 s = {∅} :=
+theorem powersetCard_zero (s : Finset α) : Finset.powersetCard 0 s = {∅} :=
by
ext; rw [mem_powerset_len, mem_singleton, card_eq_zero]
refine' ⟨fun h => h.2, fun h => by rw [h]; exact ⟨empty_subset s, rfl⟩⟩
-#align finset.powerset_len_zero Finset.powersetLen_zero
+#align finset.powerset_len_zero Finset.powersetCard_zero
-/
-#print Finset.powersetLen_empty /-
+#print Finset.powersetCard_empty /-
@[simp]
-theorem powersetLen_empty (n : ℕ) {s : Finset α} (h : s.card < n) : powersetLen n s = ∅ :=
+theorem powersetCard_empty (n : ℕ) {s : Finset α} (h : s.card < n) : powersetCard n s = ∅ :=
Finset.card_eq_zero.mp (by rw [card_powerset_len, Nat.choose_eq_zero_of_lt h])
-#align finset.powerset_len_empty Finset.powersetLen_empty
+#align finset.powerset_len_empty Finset.powersetCard_empty
-/
-#print Finset.powersetLen_eq_filter /-
-theorem powersetLen_eq_filter {n} {s : Finset α} :
- powersetLen n s = (powerset s).filterₓ fun x => x.card = n := by ext; simp [mem_powerset_len]
-#align finset.powerset_len_eq_filter Finset.powersetLen_eq_filter
+#print Finset.powersetCard_eq_filter /-
+theorem powersetCard_eq_filter {n} {s : Finset α} :
+ powersetCard n s = (powerset s).filterₓ fun x => x.card = n := by ext; simp [mem_powerset_len]
+#align finset.powerset_len_eq_filter Finset.powersetCard_eq_filter
-/
-#print Finset.powersetLen_succ_insert /-
-theorem powersetLen_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h : x ∉ s) (n : ℕ) :
- powersetLen n.succ (insert x s) = powersetLen n.succ s ∪ (powersetLen n s).image (insert x) :=
+#print Finset.powersetCard_succ_insert /-
+theorem powersetCard_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h : x ∉ s) (n : ℕ) :
+ powersetCard n.succ (insert x s) =
+ powersetCard n.succ s ∪ (powersetCard n s).image (insert x) :=
by
rw [powerset_len_eq_filter, powerset_insert, filter_union, ← powerset_len_eq_filter]
congr
@@ -311,12 +313,12 @@ theorem powersetLen_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h : x
intro ht
have : x ∉ t := fun H => h (ht H)
simp [card_insert_of_not_mem this, Nat.succ_inj']
-#align finset.powerset_len_succ_insert Finset.powersetLen_succ_insert
+#align finset.powerset_len_succ_insert Finset.powersetCard_succ_insert
-/
-#print Finset.powersetLen_nonempty /-
-theorem powersetLen_nonempty {n : ℕ} {s : Finset α} (h : n ≤ s.card) : (powersetLen n s).Nonempty :=
- by
+#print Finset.powersetCard_nonempty /-
+theorem powersetCard_nonempty {n : ℕ} {s : Finset α} (h : n ≤ s.card) :
+ (powersetCard n s).Nonempty := by
classical
induction' s using Finset.induction_on with x s hx IH generalizing n
· rw [card_empty, le_zero_iff] at h
@@ -328,12 +330,12 @@ theorem powersetLen_nonempty {n : ℕ} {s : Finset α} (h : n ≤ s.card) : (pow
rw [powerset_len_succ_insert hx]
refine' nonempty.mono _ ((IH h).image (insert x))
convert subset_union_right _ _
-#align finset.powerset_len_nonempty Finset.powersetLen_nonempty
+#align finset.powerset_len_nonempty Finset.powersetCard_nonempty
-/
-#print Finset.powersetLen_self /-
+#print Finset.powersetCard_self /-
@[simp]
-theorem powersetLen_self (s : Finset α) : powersetLen s.card s = {s} :=
+theorem powersetCard_self (s : Finset α) : powersetCard s.card s = {s} :=
by
ext
rw [mem_powerset_len, mem_singleton]
@@ -341,22 +343,22 @@ theorem powersetLen_self (s : Finset α) : powersetLen s.card s = {s} :=
· exact fun ⟨hs, hc⟩ => eq_of_subset_of_card_le hs hc.ge
· rintro rfl
simp
-#align finset.powerset_len_self Finset.powersetLen_self
+#align finset.powerset_len_self Finset.powersetCard_self
-/
-#print Finset.pairwise_disjoint_powersetLen /-
-theorem pairwise_disjoint_powersetLen (s : Finset α) :
- Pairwise fun i j => Disjoint (s.powersetLen i) (s.powersetLen j) := fun i j hij =>
+#print Finset.pairwise_disjoint_powersetCard /-
+theorem pairwise_disjoint_powersetCard (s : Finset α) :
+ Pairwise fun i j => Disjoint (s.powersetCard i) (s.powersetCard j) := fun i j hij =>
Finset.disjoint_left.mpr fun x hi hj =>
- hij <| (mem_powersetLen.mp hi).2.symm.trans (mem_powersetLen.mp hj).2
-#align finset.pairwise_disjoint_powerset_len Finset.pairwise_disjoint_powersetLen
+ hij <| (mem_powersetCard.mp hi).2.symm.trans (mem_powersetCard.mp hj).2
+#align finset.pairwise_disjoint_powerset_len Finset.pairwise_disjoint_powersetCard
-/
#print Finset.powerset_card_disjiUnion /-
theorem powerset_card_disjiUnion (s : Finset α) :
Finset.powerset s =
- (range (s.card + 1)).disjUnionₓ (fun i => powersetLen i s)
- (s.pairwise_disjoint_powersetLen.set_pairwise _) :=
+ (range (s.card + 1)).disjUnionₓ (fun i => powersetCard i s)
+ (s.pairwise_disjoint_powersetCard.set_pairwise _) :=
by
refine' ext fun a => ⟨fun ha => _, fun ha => _⟩
· rw [mem_disj_Union]
@@ -370,14 +372,15 @@ theorem powerset_card_disjiUnion (s : Finset α) :
#print Finset.powerset_card_biUnion /-
theorem powerset_card_biUnion [DecidableEq (Finset α)] (s : Finset α) :
- Finset.powerset s = (range (s.card + 1)).biUnion fun i => powersetLen i s := by
+ Finset.powerset s = (range (s.card + 1)).biUnion fun i => powersetCard i s := by
simpa only [disj_Union_eq_bUnion] using powerset_card_disj_Union s
#align finset.powerset_card_bUnion Finset.powerset_card_biUnion
-/
-#print Finset.powersetLen_sup /-
-theorem powersetLen_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.card) :
- (powersetLen n.succ u).sup id = u := by
+#print Finset.powersetCard_sup /-
+theorem powersetCard_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.card) :
+ (powersetCard n.succ u).sup id = u :=
+ by
apply le_antisymm
· simp_rw [Finset.sup_le_iff, mem_powerset_len]
rintro x ⟨h, -⟩
@@ -393,33 +396,34 @@ theorem powersetLen_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.c
exact mem_union_right _ (mem_image_of_mem _ ht)
· rw [card_erase_of_mem hx]
exact Nat.le_pred_of_lt hn
-#align finset.powerset_len_sup Finset.powersetLen_sup
+#align finset.powerset_len_sup Finset.powersetCard_sup
-/
-#print Finset.powersetLen_card_add /-
+#print Finset.powersetCard_card_add /-
@[simp]
-theorem powersetLen_card_add (s : Finset α) {i : ℕ} (hi : 0 < i) : s.powersetLen (s.card + i) = ∅ :=
- Finset.powersetLen_empty _ (lt_add_of_pos_right (Finset.card s) hi)
-#align finset.powerset_len_card_add Finset.powersetLen_card_add
+theorem powersetCard_card_add (s : Finset α) {i : ℕ} (hi : 0 < i) :
+ s.powersetCard (s.card + i) = ∅ :=
+ Finset.powersetCard_empty _ (lt_add_of_pos_right (Finset.card s) hi)
+#align finset.powerset_len_card_add Finset.powersetCard_card_add
-/
-#print Finset.map_val_val_powersetLen /-
+#print Finset.map_val_val_powersetCard /-
@[simp]
-theorem map_val_val_powersetLen (s : Finset α) (i : ℕ) :
- (s.powersetLen i).val.map Finset.val = s.1.powersetLen i := by
- simp [Finset.powersetLen, map_pmap, pmap_eq_map, map_id']
-#align finset.map_val_val_powerset_len Finset.map_val_val_powersetLen
+theorem map_val_val_powersetCard (s : Finset α) (i : ℕ) :
+ (s.powersetCard i).val.map Finset.val = s.1.powersetCard i := by
+ simp [Finset.powersetCard, map_pmap, pmap_eq_map, map_id']
+#align finset.map_val_val_powerset_len Finset.map_val_val_powersetCard
-/
-#print Finset.powersetLen_map /-
-theorem powersetLen_map {β : Type _} (f : α ↪ β) (n : ℕ) (s : Finset α) :
- powersetLen n (s.map f) = (powersetLen n s).map (mapEmbedding f).toEmbedding :=
+#print Finset.powersetCard_map /-
+theorem powersetCard_map {β : Type _} (f : α ↪ β) (n : ℕ) (s : Finset α) :
+ powersetCard n (s.map f) = (powersetCard n s).map (mapEmbedding f).toEmbedding :=
eq_of_veq <|
Multiset.map_injective (@eq_of_veq _) <| by
simp_rw [map_val_val_powerset_len, map_val, Multiset.map_map, Function.comp,
RelEmbedding.coe_toEmbedding, map_embedding_apply, map_val, ← Multiset.map_map _ val,
- map_val_val_powerset_len, Multiset.powersetLen_map]
-#align finset.powerset_len_map Finset.powersetLen_map
+ map_val_val_powerset_len, Multiset.powersetCard_map]
+#align finset.powerset_len_map Finset.powersetCard_map
-/
end PowersetLen
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,8 +3,8 @@ Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
-import Mathbin.Data.Finset.Lattice
-import Mathbin.Data.Multiset.Powerset
+import Data.Finset.Lattice
+import Data.Multiset.Powerset
#align_import data.finset.powerset from "leanprover-community/mathlib"@"cc70d9141824ea8982d1562ce009952f2c3ece30"
@@ -139,7 +139,7 @@ theorem powerset_insert [DecidableEq α] (s : Finset α) (a : α) :
#align finset.powerset_insert Finset.powerset_insert
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (t «expr ⊆ » s) -/
#print Finset.decidableExistsOfDecidableSubsets /-
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for any subset. -/
instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
@@ -149,7 +149,7 @@ instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t
#align finset.decidable_exists_of_decidable_subsets Finset.decidableExistsOfDecidableSubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (t «expr ⊆ » s) -/
#print Finset.decidableForallOfDecidableSubsets /-
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for every subset. -/
instance decidableForallOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
@@ -203,7 +203,7 @@ theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets
#align finset.empty_mem_ssubsets Finset.empty_mem_ssubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊂ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (t «expr ⊂ » s) -/
#print Finset.decidableExistsOfDecidableSSubsets /-
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for any ssubset. -/
instance decidableExistsOfDecidableSSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
@@ -213,7 +213,7 @@ instance decidableExistsOfDecidableSSubsets {s : Finset α} {p : ∀ (t) (_ : t
#align finset.decidable_exists_of_decidable_ssubsets Finset.decidableExistsOfDecidableSSubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊂ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (t «expr ⊂ » s) -/
#print Finset.decidableForallOfDecidableSSubsets /-
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for every ssubset. -/
instance decidableForallOfDecidableSSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
mathlib commit https://github.com/leanprover-community/mathlib/commit/63721b2c3eba6c325ecf8ae8cca27155a4f6306f
@@ -204,41 +204,41 @@ theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets
-/
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊂ » s) -/
-#print Finset.decidableExistsOfDecidableSsubsets /-
+#print Finset.decidableExistsOfDecidableSSubsets /-
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for any ssubset. -/
-instance decidableExistsOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
+instance decidableExistsOfDecidableSSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
[∀ (t) (h : t ⊂ s), Decidable (p t h)] : Decidable (∃ t h, p t h) :=
decidable_of_iff (∃ (t : _) (hs : t ∈ s.ssubsets), p t (mem_ssubsets.1 hs))
⟨fun ⟨t, _, hp⟩ => ⟨t, _, hp⟩, fun ⟨t, hs, hp⟩ => ⟨t, mem_ssubsets.2 hs, hp⟩⟩
-#align finset.decidable_exists_of_decidable_ssubsets Finset.decidableExistsOfDecidableSsubsets
+#align finset.decidable_exists_of_decidable_ssubsets Finset.decidableExistsOfDecidableSSubsets
-/
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊂ » s) -/
-#print Finset.decidableForallOfDecidableSsubsets /-
+#print Finset.decidableForallOfDecidableSSubsets /-
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for every ssubset. -/
-instance decidableForallOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
+instance decidableForallOfDecidableSSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
[∀ (t) (h : t ⊂ s), Decidable (p t h)] : Decidable (∀ t h, p t h) :=
decidable_of_iff (∀ (t) (h : t ∈ s.ssubsets), p t (mem_ssubsets.1 h))
⟨fun h t hs => h t (mem_ssubsets.2 hs), fun h _ _ => h _ _⟩
-#align finset.decidable_forall_of_decidable_ssubsets Finset.decidableForallOfDecidableSsubsets
+#align finset.decidable_forall_of_decidable_ssubsets Finset.decidableForallOfDecidableSSubsets
-/
-#print Finset.decidableExistsOfDecidableSsubsets' /-
+#print Finset.decidableExistsOfDecidableSSubsets' /-
/-- A version of `finset.decidable_exists_of_decidable_ssubsets` with a non-dependent `p`.
Typeclass inference cannot find `hu` here, so this is not an instance. -/
-def decidableExistsOfDecidableSsubsets' {s : Finset α} {p : Finset α → Prop}
+def decidableExistsOfDecidableSSubsets' {s : Finset α} {p : Finset α → Prop}
(hu : ∀ (t) (h : t ⊂ s), Decidable (p t)) : Decidable (∃ (t : _) (h : t ⊂ s), p t) :=
- @Finset.decidableExistsOfDecidableSsubsets _ _ _ _ hu
-#align finset.decidable_exists_of_decidable_ssubsets' Finset.decidableExistsOfDecidableSsubsets'
+ @Finset.decidableExistsOfDecidableSSubsets _ _ _ _ hu
+#align finset.decidable_exists_of_decidable_ssubsets' Finset.decidableExistsOfDecidableSSubsets'
-/
-#print Finset.decidableForallOfDecidableSsubsets' /-
+#print Finset.decidableForallOfDecidableSSubsets' /-
/-- A version of `finset.decidable_forall_of_decidable_ssubsets` with a non-dependent `p`.
Typeclass inference cannot find `hu` here, so this is not an instance. -/
-def decidableForallOfDecidableSsubsets' {s : Finset α} {p : Finset α → Prop}
+def decidableForallOfDecidableSSubsets' {s : Finset α} {p : Finset α → Prop}
(hu : ∀ (t) (h : t ⊂ s), Decidable (p t)) : Decidable (∀ (t) (h : t ⊂ s), p t) :=
- @Finset.decidableForallOfDecidableSsubsets _ _ _ _ hu
-#align finset.decidable_forall_of_decidable_ssubsets' Finset.decidableForallOfDecidableSsubsets'
+ @Finset.decidableForallOfDecidableSSubsets _ _ _ _ hu
+#align finset.decidable_forall_of_decidable_ssubsets' Finset.decidableForallOfDecidableSSubsets'
-/
end Ssubsets
@@ -375,8 +375,8 @@ theorem powerset_card_biUnion [DecidableEq (Finset α)] (s : Finset α) :
#align finset.powerset_card_bUnion Finset.powerset_card_biUnion
-/
-#print Finset.powerset_len_sup /-
-theorem powerset_len_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.card) :
+#print Finset.powersetLen_sup /-
+theorem powersetLen_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.card) :
(powersetLen n.succ u).sup id = u := by
apply le_antisymm
· simp_rw [Finset.sup_le_iff, mem_powerset_len]
@@ -393,7 +393,7 @@ theorem powerset_len_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.
exact mem_union_right _ (mem_image_of_mem _ ht)
· rw [card_erase_of_mem hx]
exact Nat.le_pred_of_lt hn
-#align finset.powerset_len_sup Finset.powerset_len_sup
+#align finset.powerset_len_sup Finset.powersetLen_sup
-/
#print Finset.powersetLen_card_add /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,15 +2,12 @@
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-
-! This file was ported from Lean 3 source module data.finset.powerset
-! leanprover-community/mathlib commit cc70d9141824ea8982d1562ce009952f2c3ece30
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.Finset.Lattice
import Mathbin.Data.Multiset.Powerset
+#align_import data.finset.powerset from "leanprover-community/mathlib"@"cc70d9141824ea8982d1562ce009952f2c3ece30"
+
/-!
# The powerset of a finset
@@ -142,7 +139,7 @@ theorem powerset_insert [DecidableEq α] (s : Finset α) (a : α) :
#align finset.powerset_insert Finset.powerset_insert
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (t «expr ⊆ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s) -/
#print Finset.decidableExistsOfDecidableSubsets /-
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for any subset. -/
instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
@@ -152,7 +149,7 @@ instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t
#align finset.decidable_exists_of_decidable_subsets Finset.decidableExistsOfDecidableSubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (t «expr ⊆ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s) -/
#print Finset.decidableForallOfDecidableSubsets /-
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for every subset. -/
instance decidableForallOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
@@ -206,7 +203,7 @@ theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets
#align finset.empty_mem_ssubsets Finset.empty_mem_ssubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (t «expr ⊂ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊂ » s) -/
#print Finset.decidableExistsOfDecidableSsubsets /-
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for any ssubset. -/
instance decidableExistsOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
@@ -216,7 +213,7 @@ instance decidableExistsOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t
#align finset.decidable_exists_of_decidable_ssubsets Finset.decidableExistsOfDecidableSsubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (t «expr ⊂ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊂ » s) -/
#print Finset.decidableForallOfDecidableSsubsets /-
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for every ssubset. -/
instance decidableForallOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -295,9 +295,11 @@ theorem powersetLen_empty (n : ℕ) {s : Finset α} (h : s.card < n) : powersetL
#align finset.powerset_len_empty Finset.powersetLen_empty
-/
+#print Finset.powersetLen_eq_filter /-
theorem powersetLen_eq_filter {n} {s : Finset α} :
powersetLen n s = (powerset s).filterₓ fun x => x.card = n := by ext; simp [mem_powerset_len]
#align finset.powerset_len_eq_filter Finset.powersetLen_eq_filter
+-/
#print Finset.powersetLen_succ_insert /-
theorem powersetLen_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h : x ∉ s) (n : ℕ) :
@@ -345,11 +347,13 @@ theorem powersetLen_self (s : Finset α) : powersetLen s.card s = {s} :=
#align finset.powerset_len_self Finset.powersetLen_self
-/
+#print Finset.pairwise_disjoint_powersetLen /-
theorem pairwise_disjoint_powersetLen (s : Finset α) :
Pairwise fun i j => Disjoint (s.powersetLen i) (s.powersetLen j) := fun i j hij =>
Finset.disjoint_left.mpr fun x hi hj =>
hij <| (mem_powersetLen.mp hi).2.symm.trans (mem_powersetLen.mp hj).2
#align finset.pairwise_disjoint_powerset_len Finset.pairwise_disjoint_powersetLen
+-/
#print Finset.powerset_card_disjiUnion /-
theorem powerset_card_disjiUnion (s : Finset α) :
@@ -374,6 +378,7 @@ theorem powerset_card_biUnion [DecidableEq (Finset α)] (s : Finset α) :
#align finset.powerset_card_bUnion Finset.powerset_card_biUnion
-/
+#print Finset.powerset_len_sup /-
theorem powerset_len_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.card) :
(powersetLen n.succ u).sup id = u := by
apply le_antisymm
@@ -392,6 +397,7 @@ theorem powerset_len_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.
· rw [card_erase_of_mem hx]
exact Nat.le_pred_of_lt hn
#align finset.powerset_len_sup Finset.powerset_len_sup
+-/
#print Finset.powersetLen_card_add /-
@[simp]
mathlib commit https://github.com/leanprover-community/mathlib/commit/31c24aa72e7b3e5ed97a8412470e904f82b81004
@@ -142,7 +142,7 @@ theorem powerset_insert [DecidableEq α] (s : Finset α) (a : α) :
#align finset.powerset_insert Finset.powerset_insert
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (t «expr ⊆ » s) -/
#print Finset.decidableExistsOfDecidableSubsets /-
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for any subset. -/
instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
@@ -152,7 +152,7 @@ instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t
#align finset.decidable_exists_of_decidable_subsets Finset.decidableExistsOfDecidableSubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (t «expr ⊆ » s) -/
#print Finset.decidableForallOfDecidableSubsets /-
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for every subset. -/
instance decidableForallOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
@@ -206,7 +206,7 @@ theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets
#align finset.empty_mem_ssubsets Finset.empty_mem_ssubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊂ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (t «expr ⊂ » s) -/
#print Finset.decidableExistsOfDecidableSsubsets /-
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for any ssubset. -/
instance decidableExistsOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
@@ -216,7 +216,7 @@ instance decidableExistsOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t
#align finset.decidable_exists_of_decidable_ssubsets Finset.decidableExistsOfDecidableSsubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊂ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (t «expr ⊂ » s) -/
#print Finset.decidableForallOfDecidableSsubsets /-
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for every ssubset. -/
instance decidableForallOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
mathlib commit https://github.com/leanprover-community/mathlib/commit/5f25c089cb34db4db112556f23c50d12da81b297
@@ -319,16 +319,16 @@ theorem powersetLen_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h : x
theorem powersetLen_nonempty {n : ℕ} {s : Finset α} (h : n ≤ s.card) : (powersetLen n s).Nonempty :=
by
classical
- induction' s using Finset.induction_on with x s hx IH generalizing n
- · rw [card_empty, le_zero_iff] at h
- rw [h, powerset_len_zero]
- exact Finset.singleton_nonempty _
- · cases n
- · simp
- · rw [card_insert_of_not_mem hx, Nat.succ_le_succ_iff] at h
- rw [powerset_len_succ_insert hx]
- refine' nonempty.mono _ ((IH h).image (insert x))
- convert subset_union_right _ _
+ induction' s using Finset.induction_on with x s hx IH generalizing n
+ · rw [card_empty, le_zero_iff] at h
+ rw [h, powerset_len_zero]
+ exact Finset.singleton_nonempty _
+ · cases n
+ · simp
+ · rw [card_insert_of_not_mem hx, Nat.succ_le_succ_iff] at h
+ rw [powerset_len_succ_insert hx]
+ refine' nonempty.mono _ ((IH h).image (insert x))
+ convert subset_union_right _ _
#align finset.powerset_len_nonempty Finset.powersetLen_nonempty
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -146,8 +146,8 @@ theorem powerset_insert [DecidableEq α] (s : Finset α) (a : α) :
#print Finset.decidableExistsOfDecidableSubsets /-
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for any subset. -/
instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
- [∀ (t) (h : t ⊆ s), Decidable (p t h)] : Decidable (∃ (t : _)(h : t ⊆ s), p t h) :=
- decidable_of_iff (∃ (t : _)(hs : t ∈ s.powerset), p t (mem_powerset.1 hs))
+ [∀ (t) (h : t ⊆ s), Decidable (p t h)] : Decidable (∃ (t : _) (h : t ⊆ s), p t h) :=
+ decidable_of_iff (∃ (t : _) (hs : t ∈ s.powerset), p t (mem_powerset.1 hs))
⟨fun ⟨t, _, hp⟩ => ⟨t, _, hp⟩, fun ⟨t, hs, hp⟩ => ⟨t, mem_powerset.2 hs, hp⟩⟩
#align finset.decidable_exists_of_decidable_subsets Finset.decidableExistsOfDecidableSubsets
-/
@@ -166,7 +166,7 @@ instance decidableForallOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t
/-- A version of `finset.decidable_exists_of_decidable_subsets` with a non-dependent `p`.
Typeclass inference cannot find `hu` here, so this is not an instance. -/
def decidableExistsOfDecidableSubsets' {s : Finset α} {p : Finset α → Prop}
- (hu : ∀ (t) (h : t ⊆ s), Decidable (p t)) : Decidable (∃ (t : _)(h : t ⊆ s), p t) :=
+ (hu : ∀ (t) (h : t ⊆ s), Decidable (p t)) : Decidable (∃ (t : _) (h : t ⊆ s), p t) :=
@Finset.decidableExistsOfDecidableSubsets _ _ _ hu
#align finset.decidable_exists_of_decidable_subsets' Finset.decidableExistsOfDecidableSubsets'
-/
@@ -211,7 +211,7 @@ theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for any ssubset. -/
instance decidableExistsOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
[∀ (t) (h : t ⊂ s), Decidable (p t h)] : Decidable (∃ t h, p t h) :=
- decidable_of_iff (∃ (t : _)(hs : t ∈ s.ssubsets), p t (mem_ssubsets.1 hs))
+ decidable_of_iff (∃ (t : _) (hs : t ∈ s.ssubsets), p t (mem_ssubsets.1 hs))
⟨fun ⟨t, _, hp⟩ => ⟨t, _, hp⟩, fun ⟨t, hs, hp⟩ => ⟨t, mem_ssubsets.2 hs, hp⟩⟩
#align finset.decidable_exists_of_decidable_ssubsets Finset.decidableExistsOfDecidableSsubsets
-/
@@ -230,7 +230,7 @@ instance decidableForallOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t
/-- A version of `finset.decidable_exists_of_decidable_ssubsets` with a non-dependent `p`.
Typeclass inference cannot find `hu` here, so this is not an instance. -/
def decidableExistsOfDecidableSsubsets' {s : Finset α} {p : Finset α → Prop}
- (hu : ∀ (t) (h : t ⊂ s), Decidable (p t)) : Decidable (∃ (t : _)(h : t ⊂ s), p t) :=
+ (hu : ∀ (t) (h : t ⊂ s), Decidable (p t)) : Decidable (∃ (t : _) (h : t ⊂ s), p t) :=
@Finset.decidableExistsOfDecidableSsubsets _ _ _ _ hu
#align finset.decidable_exists_of_decidable_ssubsets' Finset.decidableExistsOfDecidableSsubsets'
-/
@@ -320,12 +320,12 @@ theorem powersetLen_nonempty {n : ℕ} {s : Finset α} (h : n ≤ s.card) : (pow
by
classical
induction' s using Finset.induction_on with x s hx IH generalizing n
- · rw [card_empty, le_zero_iff] at h
+ · rw [card_empty, le_zero_iff] at h
rw [h, powerset_len_zero]
exact Finset.singleton_nonempty _
· cases n
· simp
- · rw [card_insert_of_not_mem hx, Nat.succ_le_succ_iff] at h
+ · rw [card_insert_of_not_mem hx, Nat.succ_le_succ_iff] at h
rw [powerset_len_succ_insert hx]
refine' nonempty.mono _ ((IH h).image (insert x))
convert subset_union_right _ _
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -295,12 +295,6 @@ theorem powersetLen_empty (n : ℕ) {s : Finset α} (h : s.card < n) : powersetL
#align finset.powerset_len_empty Finset.powersetLen_empty
-/
-/- warning: finset.powerset_len_eq_filter -> Finset.powersetLen_eq_filter is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {n : Nat} {s : Finset.{u1} α}, Eq.{succ u1} (Finset.{u1} (Finset.{u1} α)) (Finset.powersetLen.{u1} α n s) (Finset.filter.{u1} (Finset.{u1} α) (fun (x : Finset.{u1} α) => Eq.{1} Nat (Finset.card.{u1} α x) n) (fun (a : Finset.{u1} α) => Nat.decidableEq (Finset.card.{u1} α a) n) (Finset.powerset.{u1} α s))
-but is expected to have type
- forall {α : Type.{u1}} {n : Nat} {s : Finset.{u1} α}, Eq.{succ u1} (Finset.{u1} (Finset.{u1} α)) (Finset.powersetLen.{u1} α n s) (Finset.filter.{u1} (Finset.{u1} α) (fun (x : Finset.{u1} α) => Eq.{1} Nat (Finset.card.{u1} α x) n) (fun (a : Finset.{u1} α) => instDecidableEqNat (Finset.card.{u1} α a) n) (Finset.powerset.{u1} α s))
-Case conversion may be inaccurate. Consider using '#align finset.powerset_len_eq_filter Finset.powersetLen_eq_filterₓ'. -/
theorem powersetLen_eq_filter {n} {s : Finset α} :
powersetLen n s = (powerset s).filterₓ fun x => x.card = n := by ext; simp [mem_powerset_len]
#align finset.powerset_len_eq_filter Finset.powersetLen_eq_filter
@@ -351,12 +345,6 @@ theorem powersetLen_self (s : Finset α) : powersetLen s.card s = {s} :=
#align finset.powerset_len_self Finset.powersetLen_self
-/
-/- warning: finset.pairwise_disjoint_powerset_len -> Finset.pairwise_disjoint_powersetLen is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (s : Finset.{u1} α), Pairwise.{0} Nat (fun (i : Nat) (j : Nat) => Disjoint.{u1} (Finset.{u1} (Finset.{u1} α)) (Finset.partialOrder.{u1} (Finset.{u1} α)) (Finset.orderBot.{u1} (Finset.{u1} α)) (Finset.powersetLen.{u1} α i s) (Finset.powersetLen.{u1} α j s))
-but is expected to have type
- forall {α : Type.{u1}} (s : Finset.{u1} α), Pairwise.{0} Nat (fun (i : Nat) (j : Nat) => Disjoint.{u1} (Finset.{u1} (Finset.{u1} α)) (Finset.partialOrder.{u1} (Finset.{u1} α)) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} (Finset.{u1} α)) (Finset.powersetLen.{u1} α i s) (Finset.powersetLen.{u1} α j s))
-Case conversion may be inaccurate. Consider using '#align finset.pairwise_disjoint_powerset_len Finset.pairwise_disjoint_powersetLenₓ'. -/
theorem pairwise_disjoint_powersetLen (s : Finset α) :
Pairwise fun i j => Disjoint (s.powersetLen i) (s.powersetLen j) := fun i j hij =>
Finset.disjoint_left.mpr fun x hi hj =>
@@ -386,12 +374,6 @@ theorem powerset_card_biUnion [DecidableEq (Finset α)] (s : Finset α) :
#align finset.powerset_card_bUnion Finset.powerset_card_biUnion
-/
-/- warning: finset.powerset_len_sup -> Finset.powerset_len_sup is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (u : Finset.{u1} α) (n : Nat), (LT.lt.{0} Nat Nat.hasLt n (Finset.card.{u1} α u)) -> (Eq.{succ u1} (Finset.{u1} α) (Finset.sup.{u1, u1} (Finset.{u1} α) (Finset.{u1} α) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} α) (Finset.lattice.{u1} α (fun (a : α) (b : α) => _inst_1 a b))) (Finset.orderBot.{u1} α) (Finset.powersetLen.{u1} α (Nat.succ n) u) (id.{succ u1} (Finset.{u1} α))) u)
-but is expected to have type
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (u : Finset.{u1} α) (n : Nat), (LT.lt.{0} Nat instLTNat n (Finset.card.{u1} α u)) -> (Eq.{succ u1} (Finset.{u1} α) (Finset.sup.{u1, u1} (Finset.{u1} α) (Finset.{u1} α) (Lattice.toSemilatticeSup.{u1} (Finset.{u1} α) (Finset.instLatticeFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b))) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} α) (Finset.powersetLen.{u1} α (Nat.succ n) u) (id.{succ u1} (Finset.{u1} α))) u)
-Case conversion may be inaccurate. Consider using '#align finset.powerset_len_sup Finset.powerset_len_supₓ'. -/
theorem powerset_len_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.card) :
(powersetLen n.succ u).sup id = u := by
apply le_antisymm
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -49,10 +49,7 @@ theorem mem_powerset {s t : Finset α} : s ∈ powerset t ↔ s ⊆ t := by
#print Finset.coe_powerset /-
@[simp, norm_cast]
theorem coe_powerset (s : Finset α) :
- (s.powerset : Set (Finset α)) = coe ⁻¹' (s : Set α).powerset :=
- by
- ext
- simp
+ (s.powerset : Set (Finset α)) = coe ⁻¹' (s : Set α).powerset := by ext; simp
#align finset.coe_powerset Finset.coe_powerset
-/
@@ -121,9 +118,7 @@ theorem card_powerset (s : Finset α) : card (powerset s) = 2 ^ card s :=
#print Finset.not_mem_of_mem_powerset_of_not_mem /-
theorem not_mem_of_mem_powerset_of_not_mem {s t : Finset α} {a : α} (ht : t ∈ s.powerset)
- (h : a ∉ s) : a ∉ t := by
- apply mt _ h
- apply mem_powerset.1 ht
+ (h : a ∉ s) : a ∉ t := by apply mt _ h; apply mem_powerset.1 ht
#align finset.not_mem_of_mem_powerset_of_not_mem Finset.not_mem_of_mem_powerset_of_not_mem
-/
@@ -206,10 +201,8 @@ theorem mem_ssubsets {s t : Finset α} : t ∈ s.ssubsets ↔ t ⊂ s := by
-/
#print Finset.empty_mem_ssubsets /-
-theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets :=
- by
- rw [mem_ssubsets, ssubset_iff_subset_ne]
- exact ⟨empty_subset s, h.ne_empty.symm⟩
+theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets := by
+ rw [mem_ssubsets, ssubset_iff_subset_ne]; exact ⟨empty_subset s, h.ne_empty.symm⟩
#align finset.empty_mem_ssubsets Finset.empty_mem_ssubsets
-/
@@ -291,10 +284,7 @@ theorem card_powersetLen (n : ℕ) (s : Finset α) : card (powersetLen n s) = Na
theorem powersetLen_zero (s : Finset α) : Finset.powersetLen 0 s = {∅} :=
by
ext; rw [mem_powerset_len, mem_singleton, card_eq_zero]
- refine'
- ⟨fun h => h.2, fun h => by
- rw [h]
- exact ⟨empty_subset s, rfl⟩⟩
+ refine' ⟨fun h => h.2, fun h => by rw [h]; exact ⟨empty_subset s, rfl⟩⟩
#align finset.powerset_len_zero Finset.powersetLen_zero
-/
@@ -312,10 +302,7 @@ but is expected to have type
forall {α : Type.{u1}} {n : Nat} {s : Finset.{u1} α}, Eq.{succ u1} (Finset.{u1} (Finset.{u1} α)) (Finset.powersetLen.{u1} α n s) (Finset.filter.{u1} (Finset.{u1} α) (fun (x : Finset.{u1} α) => Eq.{1} Nat (Finset.card.{u1} α x) n) (fun (a : Finset.{u1} α) => instDecidableEqNat (Finset.card.{u1} α a) n) (Finset.powerset.{u1} α s))
Case conversion may be inaccurate. Consider using '#align finset.powerset_len_eq_filter Finset.powersetLen_eq_filterₓ'. -/
theorem powersetLen_eq_filter {n} {s : Finset α} :
- powersetLen n s = (powerset s).filterₓ fun x => x.card = n :=
- by
- ext
- simp [mem_powerset_len]
+ powersetLen n s = (powerset s).filterₓ fun x => x.card = n := by ext; simp [mem_powerset_len]
#align finset.powerset_len_eq_filter Finset.powersetLen_eq_filter
#print Finset.powersetLen_succ_insert /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/e3fb84046afd187b710170887195d50bada934ee
@@ -376,8 +376,8 @@ theorem pairwise_disjoint_powersetLen (s : Finset α) :
hij <| (mem_powersetLen.mp hi).2.symm.trans (mem_powersetLen.mp hj).2
#align finset.pairwise_disjoint_powerset_len Finset.pairwise_disjoint_powersetLen
-#print Finset.powerset_card_disjUnionᵢ /-
-theorem powerset_card_disjUnionᵢ (s : Finset α) :
+#print Finset.powerset_card_disjiUnion /-
+theorem powerset_card_disjiUnion (s : Finset α) :
Finset.powerset s =
(range (s.card + 1)).disjUnionₓ (fun i => powersetLen i s)
(s.pairwise_disjoint_powersetLen.set_pairwise _) :=
@@ -389,14 +389,14 @@ theorem powerset_card_disjUnionᵢ (s : Finset α) :
mem_powerset_len.mpr ⟨mem_powerset.mp ha, rfl⟩⟩
· rcases mem_disj_Union.mp ha with ⟨i, hi, ha⟩
exact mem_powerset.mpr (mem_powerset_len.mp ha).1
-#align finset.powerset_card_disj_Union Finset.powerset_card_disjUnionᵢ
+#align finset.powerset_card_disj_Union Finset.powerset_card_disjiUnion
-/
-#print Finset.powerset_card_bunionᵢ /-
-theorem powerset_card_bunionᵢ [DecidableEq (Finset α)] (s : Finset α) :
- Finset.powerset s = (range (s.card + 1)).bunionᵢ fun i => powersetLen i s := by
+#print Finset.powerset_card_biUnion /-
+theorem powerset_card_biUnion [DecidableEq (Finset α)] (s : Finset α) :
+ Finset.powerset s = (range (s.card + 1)).biUnion fun i => powersetLen i s := by
simpa only [disj_Union_eq_bUnion] using powerset_card_disj_Union s
-#align finset.powerset_card_bUnion Finset.powerset_card_bunionᵢ
+#align finset.powerset_card_bUnion Finset.powerset_card_biUnion
-/
/- warning: finset.powerset_len_sup -> Finset.powerset_len_sup is a dubious translation:
mathlib commit https://github.com/leanprover-community/mathlib/commit/730c6d4cab72b9d84fcfb9e95e8796e9cd8f40ba
@@ -445,7 +445,7 @@ theorem powersetLen_map {β : Type _} (f : α ↪ β) (n : ℕ) (s : Finset α)
eq_of_veq <|
Multiset.map_injective (@eq_of_veq _) <| by
simp_rw [map_val_val_powerset_len, map_val, Multiset.map_map, Function.comp,
- RelEmbedding.coeFn_toEmbedding, map_embedding_apply, map_val, ← Multiset.map_map _ val,
+ RelEmbedding.coe_toEmbedding, map_embedding_apply, map_val, ← Multiset.map_map _ val,
map_val_val_powerset_len, Multiset.powersetLen_map]
#align finset.powerset_len_map Finset.powersetLen_map
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/4c586d291f189eecb9d00581aeb3dd998ac34442
@@ -147,7 +147,7 @@ theorem powerset_insert [DecidableEq α] (s : Finset α) (a : α) :
#align finset.powerset_insert Finset.powerset_insert
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:628:2: warning: expanding binder collection (t «expr ⊆ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s) -/
#print Finset.decidableExistsOfDecidableSubsets /-
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for any subset. -/
instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
@@ -157,7 +157,7 @@ instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t
#align finset.decidable_exists_of_decidable_subsets Finset.decidableExistsOfDecidableSubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:628:2: warning: expanding binder collection (t «expr ⊆ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s) -/
#print Finset.decidableForallOfDecidableSubsets /-
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for every subset. -/
instance decidableForallOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
@@ -213,7 +213,7 @@ theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets
#align finset.empty_mem_ssubsets Finset.empty_mem_ssubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:628:2: warning: expanding binder collection (t «expr ⊂ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊂ » s) -/
#print Finset.decidableExistsOfDecidableSsubsets /-
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for any ssubset. -/
instance decidableExistsOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
@@ -223,7 +223,7 @@ instance decidableExistsOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t
#align finset.decidable_exists_of_decidable_ssubsets Finset.decidableExistsOfDecidableSsubsets
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:628:2: warning: expanding binder collection (t «expr ⊂ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊂ » s) -/
#print Finset.decidableForallOfDecidableSsubsets /-
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for every ssubset. -/
instance decidableForallOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
@@ -320,9 +320,9 @@ theorem powersetCard_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.
simp only [mem_biUnion, exists_prop, id]
obtain ⟨t, ht⟩ : ∃ t, t ∈ powersetCard n (u.erase x) := powersetCard_nonempty.2
(le_trans (Nat.le_sub_one_of_lt hn) pred_card_le_card_erase)
- · refine' ⟨insert x t, _, mem_insert_self _ _⟩
- rw [← insert_erase hx, powersetCard_succ_insert (not_mem_erase _ _)]
- exact mem_union_right _ (mem_image_of_mem _ ht)
+ refine' ⟨insert x t, _, mem_insert_self _ _⟩
+ rw [← insert_erase hx, powersetCard_succ_insert (not_mem_erase _ _)]
+ exact mem_union_right _ (mem_image_of_mem _ ht)
#align finset.powerset_len_sup Finset.powersetCard_sup
theorem powersetCard_map {β : Type*} (f : α ↪ β) (n : ℕ) (s : Finset α) :
Typeclass search cannot synthesize ∀ t ⊆ s, Decidable (p t)
hypothesis, hence the instance could never fire. Fix it and compress back the binders, both in the instancs and Combinatorics.Additive.SalemSpencer
where they were supposed to be used.
@@ -127,18 +127,16 @@ instance decidableForallOfDecidableSubsets {s : Finset α} {p : ∀ t ⊆ s, Pro
⟨fun h t hs => h t (mem_powerset.2 hs), fun h _ _ => h _ _⟩
#align finset.decidable_forall_of_decidable_subsets Finset.decidableForallOfDecidableSubsets
-/-- A version of `Finset.decidableExistsOfDecidableSubsets` with a non-dependent `p`.
-Typeclass inference cannot find `hu` here, so this is not an instance. -/
-def decidableExistsOfDecidableSubsets' {s : Finset α} {p : Finset α → Prop}
- (hu : ∀ t ⊆ s, Decidable (p t)) : Decidable (∃ (t : _) (_h : t ⊆ s), p t) :=
- @Finset.decidableExistsOfDecidableSubsets _ _ _ hu
+/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for any subset. -/
+instance decidableExistsOfDecidableSubsets' {s : Finset α} {p : Finset α → Prop}
+ [∀ t, Decidable (p t)] : Decidable (∃ t ⊆ s, p t) :=
+ decidable_of_iff (∃ (t : _) (_h : t ⊆ s), p t) $ by simp
#align finset.decidable_exists_of_decidable_subsets' Finset.decidableExistsOfDecidableSubsets'
-/-- A version of `Finset.decidableForallOfDecidableSubsets` with a non-dependent `p`.
-Typeclass inference cannot find `hu` here, so this is not an instance. -/
-def decidableForallOfDecidableSubsets' {s : Finset α} {p : Finset α → Prop}
- (hu : ∀ t ⊆ s, Decidable (p t)) : Decidable (∀ t ⊆ s, p t) :=
- @Finset.decidableForallOfDecidableSubsets _ _ _ hu
+/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for every subset. -/
+instance decidableForallOfDecidableSubsets' {s : Finset α} {p : Finset α → Prop}
+ [∀ t, Decidable (p t)] : Decidable (∀ t ⊆ s, p t) :=
+ decidable_of_iff (∀ (t : _) (_h : t ⊆ s), p t) $ by simp
#align finset.decidable_forall_of_decidable_subsets' Finset.decidableForallOfDecidableSubsets'
end Powerset
@@ -319,7 +319,7 @@ theorem powersetCard_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.
exact h
· rw [sup_eq_biUnion, le_iff_subset, subset_iff]
intro x hx
- simp only [mem_biUnion, exists_prop, id.def]
+ simp only [mem_biUnion, exists_prop, id]
obtain ⟨t, ht⟩ : ∃ t, t ∈ powersetCard n (u.erase x) := powersetCard_nonempty.2
(le_trans (Nat.le_sub_one_of_lt hn) pred_card_le_card_erase)
· refine' ⟨insert x t, _, mem_insert_self _ _⟩
Homogenises porting notes via capitalisation and addition of whitespace.
It makes the following changes:
@@ -44,12 +44,12 @@ theorem coe_powerset (s : Finset α) :
simp
#align finset.coe_powerset Finset.coe_powerset
---Porting note: remove @[simp], simp can prove it
+-- Porting note: remove @[simp], simp can prove it
theorem empty_mem_powerset (s : Finset α) : ∅ ∈ powerset s :=
mem_powerset.2 (empty_subset _)
#align finset.empty_mem_powerset Finset.empty_mem_powerset
---Porting note: remove @[simp], simp can prove it
+-- Porting note: remove @[simp], simp can prove it
theorem mem_powerset_self (s : Finset α) : s ∈ powerset s :=
mem_powerset.2 Subset.rfl
#align finset.mem_powerset_self Finset.mem_powerset_self
@@ -343,7 +343,7 @@ theorem powersetCard_map {β : Type*} (f : α ↪ β) (n : ℕ) (s : Finset α)
rw [← card_map f, this, h.2]; simp
· rintro ⟨a, ⟨has, rfl⟩, rfl⟩
dsimp [RelEmbedding.coe_toEmbedding]
- --Porting note: Why is `rw` required here and not `simp`?
+ -- Porting note: Why is `rw` required here and not `simp`?
rw [mapEmbedding_apply]
simp [has]
#align finset.powerset_len_map Finset.powersetCard_map
@@ -54,7 +54,7 @@ theorem mem_powerset_self (s : Finset α) : s ∈ powerset s :=
mem_powerset.2 Subset.rfl
#align finset.mem_powerset_self Finset.mem_powerset_self
-@[aesop safe apply (rule_sets [finsetNonempty])]
+@[aesop safe apply (rule_sets := [finsetNonempty])]
theorem powerset_nonempty (s : Finset α) : s.powerset.Nonempty :=
⟨∅, empty_mem_powerset _⟩
#align finset.powerset_nonempty Finset.powerset_nonempty
@@ -272,7 +272,7 @@ theorem powersetCard_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h :
simp [card_insert_of_not_mem this, Nat.succ_inj']
#align finset.powerset_len_succ_insert Finset.powersetCard_succ_insert
-@[simp, aesop safe apply (rule_sets [finsetNonempty])]
+@[simp, aesop safe apply (rule_sets := [finsetNonempty])]
lemma powersetCard_nonempty : (powersetCard n s).Nonempty ↔ n ≤ s.card := by
aesop (add simp [Finset.Nonempty, exists_smaller_set, card_le_card])
#align finset.powerset_len_nonempty Finset.powersetCard_nonempty
Finset.sum
(#10538)
Also define a new aesop
rule-set and an auxiliary metaprogram proveFinsetNonempty
for dealing with Finset.Nonempty
conditions.
From LeanAPAP
Co-authored-by: Alex J. Best <alex.j.best@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Alex J Best <alex.j.best@gmail.com>
@@ -54,6 +54,7 @@ theorem mem_powerset_self (s : Finset α) : s ∈ powerset s :=
mem_powerset.2 Subset.rfl
#align finset.mem_powerset_self Finset.mem_powerset_self
+@[aesop safe apply (rule_sets [finsetNonempty])]
theorem powerset_nonempty (s : Finset α) : s.powerset.Nonempty :=
⟨∅, empty_mem_powerset _⟩
#align finset.powerset_nonempty Finset.powerset_nonempty
@@ -271,19 +272,9 @@ theorem powersetCard_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h :
simp [card_insert_of_not_mem this, Nat.succ_inj']
#align finset.powerset_len_succ_insert Finset.powersetCard_succ_insert
-theorem powersetCard_nonempty {n : ℕ} {s : Finset α} (h : n ≤ s.card) :
- (powersetCard n s).Nonempty := by
- classical
- induction' s using Finset.induction_on with x s hx IH generalizing n
- · rw [card_empty, le_zero_iff] at h
- rw [h, powersetCard_zero]
- exact Finset.singleton_nonempty _
- · cases n
- · simp
- · rw [card_insert_of_not_mem hx, Nat.succ_le_succ_iff] at h
- rw [powersetCard_succ_insert hx]
- refine' Nonempty.mono _ ((IH h).image (insert x))
- exact subset_union_right _ _
+@[simp, aesop safe apply (rule_sets [finsetNonempty])]
+lemma powersetCard_nonempty : (powersetCard n s).Nonempty ↔ n ≤ s.card := by
+ aesop (add simp [Finset.Nonempty, exists_smaller_set, card_le_card])
#align finset.powerset_len_nonempty Finset.powersetCard_nonempty
@[simp]
@@ -329,7 +320,7 @@ theorem powersetCard_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.
· rw [sup_eq_biUnion, le_iff_subset, subset_iff]
intro x hx
simp only [mem_biUnion, exists_prop, id.def]
- obtain ⟨t, ht⟩ : ∃ t, t ∈ powersetCard n (u.erase x) := powersetCard_nonempty
+ obtain ⟨t, ht⟩ : ∃ t, t ∈ powersetCard n (u.erase x) := powersetCard_nonempty.2
(le_trans (Nat.le_sub_one_of_lt hn) pred_card_le_card_erase)
· refine' ⟨insert x t, _, mem_insert_self _ _⟩
rw [← insert_erase hx, powersetCard_succ_insert (not_mem_erase _ _)]
@@ -191,6 +191,7 @@ def decidableForallOfDecidableSSubsets' {s : Finset α} {p : Finset α → Prop}
end SSubsets
section powersetCard
+variable {n} {s t : Finset α}
/-- Given an integer `n` and a finset `s`, then `powersetCard n s` is the finset of subsets of `s`
of cardinality `n`. -/
@@ -199,8 +200,7 @@ def powersetCard (n : ℕ) (s : Finset α) : Finset (Finset α) :=
s.2.powersetCard.pmap fun _a _ha _b _hb => congr_arg Finset.val⟩
#align finset.powerset_len Finset.powersetCard
-/-- **Formula for the Number of Combinations** -/
-theorem mem_powersetCard {n} {s t : Finset α} : s ∈ powersetCard n t ↔ s ⊆ t ∧ card s = n := by
+@[simp] lemma mem_powersetCard : s ∈ powersetCard n t ↔ s ⊆ t ∧ card s = n := by
cases s; simp [powersetCard, val_le_iff.symm]
#align finset.mem_powerset_len Finset.mem_powersetCard
@@ -226,6 +226,10 @@ theorem powersetCard_zero (s : Finset α) : s.powersetCard 0 = {∅} := by
exact ⟨empty_subset s, rfl⟩⟩
#align finset.powerset_len_zero Finset.powersetCard_zero
+lemma powersetCard_empty_subsingleton (n : ℕ) :
+ (powersetCard n (∅ : Finset α) : Set $ Finset α).Subsingleton := by
+ simp [Set.Subsingleton, subset_empty]
+
@[simp]
theorem map_val_val_powersetCard (s : Finset α) (i : ℕ) :
(s.powersetCard i).val.map Finset.val = s.1.powersetCard i := by
@@ -237,9 +241,15 @@ theorem powersetCard_one (s : Finset α) :
eq_of_veq <| Multiset.map_injective val_injective <| by simp [Multiset.powersetCard_one]
@[simp]
-theorem powersetCard_empty (n : ℕ) {s : Finset α} (h : s.card < n) : powersetCard n s = ∅ :=
- Finset.card_eq_zero.mp (by rw [card_powersetCard, Nat.choose_eq_zero_of_lt h])
-#align finset.powerset_len_empty Finset.powersetCard_empty
+lemma powersetCard_eq_empty : powersetCard n s = ∅ ↔ s.card < n := by
+ refine ⟨?_, fun h ↦ card_eq_zero.1 $ by rw [card_powersetCard, Nat.choose_eq_zero_of_lt h]⟩
+ contrapose!
+ exact fun h ↦ nonempty_iff_ne_empty.1 $ (exists_smaller_set _ _ h).imp $ by simp
+#align finset.powerset_len_empty Finset.powersetCard_eq_empty
+
+@[simp] lemma powersetCard_card_add (s : Finset α) (hn : 0 < n) :
+ s.powersetCard (s.card + n) = ∅ := by simpa
+#align finset.powerset_len_card_add Finset.powersetCard_card_add
theorem powersetCard_eq_filter {n} {s : Finset α} :
powersetCard n s = (powerset s).filter fun x => x.card = n := by
@@ -326,12 +336,6 @@ theorem powersetCard_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.
exact mem_union_right _ (mem_image_of_mem _ ht)
#align finset.powerset_len_sup Finset.powersetCard_sup
-@[simp]
-theorem powersetCard_card_add (s : Finset α) {i : ℕ} (hi : 0 < i) :
- s.powersetCard (s.card + i) = ∅ :=
- Finset.powersetCard_empty _ (lt_add_of_pos_right (Finset.card s) hi)
-#align finset.powerset_len_card_add Finset.powersetCard_card_add
-
theorem powersetCard_map {β : Type*} (f : α ↪ β) (n : ℕ) (s : Finset α) :
powersetCard n (s.map f) = (powersetCard n s).map (mapEmbedding f).toEmbedding :=
ext fun t => by
@@ -334,7 +334,7 @@ theorem powersetCard_card_add (s : Finset α) {i : ℕ} (hi : 0 < i) :
theorem powersetCard_map {β : Type*} (f : α ↪ β) (n : ℕ) (s : Finset α) :
powersetCard n (s.map f) = (powersetCard n s).map (mapEmbedding f).toEmbedding :=
- ext <| fun t => by
+ ext fun t => by
simp only [card_map, mem_powersetCard, le_eq_subset, gt_iff_lt, mem_map, mapEmbedding_apply]
constructor
· classical
Finset
lemma names (#8894)
Change a few lemma names that have historically bothered me.
Finset.card_le_of_subset
→ Finset.card_le_card
Multiset.card_le_of_le
→ Multiset.card_le_card
Multiset.card_lt_of_lt
→ Multiset.card_lt_card
Set.ncard_le_of_subset
→ Set.ncard_le_ncard
Finset.image_filter
→ Finset.filter_image
CompleteLattice.finset_sup_compact_of_compact
→ CompleteLattice.isCompactElement_finset_sup
@@ -252,7 +252,7 @@ theorem powersetCard_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h :
powersetCard n.succ s ∪ (powersetCard n s).image (insert x) := by
rw [powersetCard_eq_filter, powerset_insert, filter_union, ← powersetCard_eq_filter]
congr
- rw [powersetCard_eq_filter, image_filter]
+ rw [powersetCard_eq_filter, filter_image]
congr 1
ext t
simp only [mem_powerset, mem_filter, Function.comp_apply, and_congr_right_iff]
@@ -299,7 +299,7 @@ theorem powerset_card_disjiUnion (s : Finset α) :
refine' ext fun a => ⟨fun ha => _, fun ha => _⟩
· rw [mem_disjiUnion]
exact
- ⟨a.card, mem_range.mpr (Nat.lt_succ_of_le (card_le_of_subset (mem_powerset.mp ha))),
+ ⟨a.card, mem_range.mpr (Nat.lt_succ_of_le (card_le_card (mem_powerset.mp ha))),
mem_powersetCard.mpr ⟨mem_powerset.mp ha, rfl⟩⟩
· rcases mem_disjiUnion.mp ha with ⟨i, _hi, ha⟩
exact mem_powerset.mpr (mem_powersetCard.mp ha).1
@@ -129,14 +129,14 @@ instance decidableForallOfDecidableSubsets {s : Finset α} {p : ∀ t ⊆ s, Pro
/-- A version of `Finset.decidableExistsOfDecidableSubsets` with a non-dependent `p`.
Typeclass inference cannot find `hu` here, so this is not an instance. -/
def decidableExistsOfDecidableSubsets' {s : Finset α} {p : Finset α → Prop}
- (hu : ∀ (t) (_h : t ⊆ s), Decidable (p t)) : Decidable (∃ (t : _) (_h : t ⊆ s), p t) :=
+ (hu : ∀ t ⊆ s, Decidable (p t)) : Decidable (∃ (t : _) (_h : t ⊆ s), p t) :=
@Finset.decidableExistsOfDecidableSubsets _ _ _ hu
#align finset.decidable_exists_of_decidable_subsets' Finset.decidableExistsOfDecidableSubsets'
/-- A version of `Finset.decidableForallOfDecidableSubsets` with a non-dependent `p`.
Typeclass inference cannot find `hu` here, so this is not an instance. -/
def decidableForallOfDecidableSubsets' {s : Finset α} {p : Finset α → Prop}
- (hu : ∀ (t) (_h : t ⊆ s), Decidable (p t)) : Decidable (∀ (t) (_h : t ⊆ s), p t) :=
+ (hu : ∀ t ⊆ s, Decidable (p t)) : Decidable (∀ t ⊆ s, p t) :=
@Finset.decidableForallOfDecidableSubsets _ _ _ hu
#align finset.decidable_forall_of_decidable_subsets' Finset.decidableForallOfDecidableSubsets'
@@ -161,15 +161,15 @@ theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets
exact ⟨empty_subset s, h.ne_empty.symm⟩
#align finset.empty_mem_ssubsets Finset.empty_mem_ssubsets
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for any ssubset. -/
-instance decidableExistsOfDecidableSSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
- [∀ (t) (h : t ⊂ s), Decidable (p t h)] : Decidable (∃ t h, p t h) :=
+instance decidableExistsOfDecidableSSubsets {s : Finset α} {p : ∀ t ⊂ s, Prop}
+ [∀ t h, Decidable (p t h)] : Decidable (∃ t h, p t h) :=
decidable_of_iff (∃ (t : _) (hs : t ∈ s.ssubsets), p t (mem_ssubsets.1 hs))
⟨fun ⟨t, _, hp⟩ => ⟨t, _, hp⟩, fun ⟨t, hs, hp⟩ => ⟨t, mem_ssubsets.2 hs, hp⟩⟩
#align finset.decidable_exists_of_decidable_ssubsets Finset.decidableExistsOfDecidableSSubsets
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for every ssubset. -/
-instance decidableForallOfDecidableSSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
- [∀ (t) (h : t ⊂ s), Decidable (p t h)] : Decidable (∀ t h, p t h) :=
+instance decidableForallOfDecidableSSubsets {s : Finset α} {p : ∀ t ⊂ s, Prop}
+ [∀ t h, Decidable (p t h)] : Decidable (∀ t h, p t h) :=
decidable_of_iff (∀ (t) (h : t ∈ s.ssubsets), p t (mem_ssubsets.1 h))
⟨fun h t hs => h t (mem_ssubsets.2 hs), fun h _ _ => h _ _⟩
#align finset.decidable_forall_of_decidable_ssubsets Finset.decidableForallOfDecidableSSubsets
@@ -177,14 +177,14 @@ instance decidableForallOfDecidableSSubsets {s : Finset α} {p : ∀ (t) (_ : t
/-- A version of `Finset.decidableExistsOfDecidableSSubsets` with a non-dependent `p`.
Typeclass inference cannot find `hu` here, so this is not an instance. -/
def decidableExistsOfDecidableSSubsets' {s : Finset α} {p : Finset α → Prop}
- (hu : ∀ (t) (_h : t ⊂ s), Decidable (p t)) : Decidable (∃ (t : _) (_h : t ⊂ s), p t) :=
+ (hu : ∀ t ⊂ s, Decidable (p t)) : Decidable (∃ (t : _) (_h : t ⊂ s), p t) :=
@Finset.decidableExistsOfDecidableSSubsets _ _ _ _ hu
#align finset.decidable_exists_of_decidable_ssubsets' Finset.decidableExistsOfDecidableSSubsets'
/-- A version of `Finset.decidableForallOfDecidableSSubsets` with a non-dependent `p`.
Typeclass inference cannot find `hu` here, so this is not an instance. -/
def decidableForallOfDecidableSSubsets' {s : Finset α} {p : Finset α → Prop}
- (hu : ∀ (t) (_h : t ⊂ s), Decidable (p t)) : Decidable (∀ (t) (_h : t ⊂ s), p t) :=
+ (hu : ∀ t ⊂ s, Decidable (p t)) : Decidable (∀ t ⊂ s, p t) :=
@Finset.decidableForallOfDecidableSSubsets _ _ _ _ hu
#align finset.decidable_forall_of_decidable_ssubsets' Finset.decidableForallOfDecidableSSubsets'
∃ x ∈ s, _
instead of ∃ (x) (_ : x ∈ s), _
(#9184)
Search for [∀∃].*(_
and manually replace some occurrences with more readable versions.
In case of ∀
, the new expressions are defeq to the old ones.
In case of ∃
, they differ by exists_prop
.
In some rare cases, golf proofs that needed fixing.
@@ -113,14 +113,14 @@ theorem powerset_insert [DecidableEq α] (s : Finset α) (a : α) :
#align finset.powerset_insert Finset.powerset_insert
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for any subset. -/
-instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
+instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ t ⊆ s, Prop}
[∀ (t) (h : t ⊆ s), Decidable (p t h)] : Decidable (∃ (t : _) (h : t ⊆ s), p t h) :=
decidable_of_iff (∃ (t : _) (hs : t ∈ s.powerset), p t (mem_powerset.1 hs))
⟨fun ⟨t, _, hp⟩ => ⟨t, _, hp⟩, fun ⟨t, hs, hp⟩ => ⟨t, mem_powerset.2 hs, hp⟩⟩
#align finset.decidable_exists_of_decidable_subsets Finset.decidableExistsOfDecidableSubsets
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for every subset. -/
-instance decidableForallOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
+instance decidableForallOfDecidableSubsets {s : Finset α} {p : ∀ t ⊆ s, Prop}
[∀ (t) (h : t ⊆ s), Decidable (p t h)] : Decidable (∀ (t) (h : t ⊆ s), p t h) :=
decidable_of_iff (∀ (t) (h : t ∈ s.powerset), p t (mem_powerset.1 h))
⟨fun h t hs => h t (mem_powerset.2 hs), fun h _ _ => h _ _⟩
cases'
(#9171)
I literally went through and regex'd some uses of cases'
, replacing them with rcases
; this is meant to be a low effort PR as I hope that tools can do this in the future.
rcases
is an easier replacement than cases
, though with better tools we could in future do a second pass converting simple rcases
added here (and existing ones) to cases
.
@@ -317,15 +317,13 @@ theorem powersetCard_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.
rintro x ⟨h, -⟩
exact h
· rw [sup_eq_biUnion, le_iff_subset, subset_iff]
- cases' (Nat.succ_le_of_lt hn).eq_or_lt with h' h'
- · simp [h']
- · intro x hx
- simp only [mem_biUnion, exists_prop, id.def]
- obtain ⟨t, ht⟩ : ∃ t, t ∈ powersetCard n (u.erase x) := powersetCard_nonempty
- (le_trans (Nat.le_sub_one_of_lt hn) pred_card_le_card_erase)
- · refine' ⟨insert x t, _, mem_insert_self _ _⟩
- rw [← insert_erase hx, powersetCard_succ_insert (not_mem_erase _ _)]
- exact mem_union_right _ (mem_image_of_mem _ ht)
+ intro x hx
+ simp only [mem_biUnion, exists_prop, id.def]
+ obtain ⟨t, ht⟩ : ∃ t, t ∈ powersetCard n (u.erase x) := powersetCard_nonempty
+ (le_trans (Nat.le_sub_one_of_lt hn) pred_card_le_card_erase)
+ · refine' ⟨insert x t, _, mem_insert_self _ _⟩
+ rw [← insert_erase hx, powersetCard_succ_insert (not_mem_erase _ _)]
+ exact mem_union_right _ (mem_image_of_mem _ ht)
#align finset.powerset_len_sup Finset.powersetCard_sup
@[simp]
Finset/Multiset.powersetCard 1
(#9137)
for [#9130](https://github.com/leanprover-community/mathlib4/pull/9130/files#r1429368677)
Co-authored-by: Junyan Xu <junyanxu.math@gmail.com>
@@ -218,7 +218,7 @@ theorem card_powersetCard (n : ℕ) (s : Finset α) :
#align finset.card_powerset_len Finset.card_powersetCard
@[simp]
-theorem powersetCard_zero (s : Finset α) : Finset.powersetCard 0 s = {∅} := by
+theorem powersetCard_zero (s : Finset α) : s.powersetCard 0 = {∅} := by
ext; rw [mem_powersetCard, mem_singleton, card_eq_zero]
refine'
⟨fun h => h.2, fun h => by
@@ -226,6 +226,16 @@ theorem powersetCard_zero (s : Finset α) : Finset.powersetCard 0 s = {∅} := b
exact ⟨empty_subset s, rfl⟩⟩
#align finset.powerset_len_zero Finset.powersetCard_zero
+@[simp]
+theorem map_val_val_powersetCard (s : Finset α) (i : ℕ) :
+ (s.powersetCard i).val.map Finset.val = s.1.powersetCard i := by
+ simp [Finset.powersetCard, map_pmap, pmap_eq_map, map_id']
+#align finset.map_val_val_powerset_len Finset.map_val_val_powersetCard
+
+theorem powersetCard_one (s : Finset α) :
+ s.powersetCard 1 = s.map ⟨_, Finset.singleton_injective⟩ :=
+ eq_of_veq <| Multiset.map_injective val_injective <| by simp [Multiset.powersetCard_one]
+
@[simp]
theorem powersetCard_empty (n : ℕ) {s : Finset α} (h : s.card < n) : powersetCard n s = ∅ :=
Finset.card_eq_zero.mp (by rw [card_powersetCard, Nat.choose_eq_zero_of_lt h])
@@ -324,12 +334,6 @@ theorem powersetCard_card_add (s : Finset α) {i : ℕ} (hi : 0 < i) :
Finset.powersetCard_empty _ (lt_add_of_pos_right (Finset.card s) hi)
#align finset.powerset_len_card_add Finset.powersetCard_card_add
-@[simp]
-theorem map_val_val_powersetCard (s : Finset α) (i : ℕ) :
- (s.powersetCard i).val.map Finset.val = s.1.powersetCard i := by
- simp [Finset.powersetCard, map_pmap, pmap_eq_map, map_id']
-#align finset.map_val_val_powerset_len Finset.map_val_val_powersetCard
-
theorem powersetCard_map {β : Type*} (f : α ↪ β) (n : ℕ) (s : Finset α) :
powersetCard n (s.map f) = (powersetCard n s).map (mapEmbedding f).toEmbedding :=
ext <| fun t => by
@@ -312,7 +312,7 @@ theorem powersetCard_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.
· intro x hx
simp only [mem_biUnion, exists_prop, id.def]
obtain ⟨t, ht⟩ : ∃ t, t ∈ powersetCard n (u.erase x) := powersetCard_nonempty
- (le_trans (Nat.le_pred_of_lt hn) pred_card_le_card_erase)
+ (le_trans (Nat.le_sub_one_of_lt hn) pred_card_le_card_erase)
· refine' ⟨insert x t, _, mem_insert_self _ _⟩
rw [← insert_erase hx, powersetCard_succ_insert (not_mem_erase _ _)]
exact mem_union_right _ (mem_image_of_mem _ ht)
@@ -190,118 +190,120 @@ def decidableForallOfDecidableSSubsets' {s : Finset α} {p : Finset α → Prop}
end SSubsets
-section PowersetLen
+section powersetCard
-/-- Given an integer `n` and a finset `s`, then `powersetLen n s` is the finset of subsets of `s`
+/-- Given an integer `n` and a finset `s`, then `powersetCard n s` is the finset of subsets of `s`
of cardinality `n`. -/
-def powersetLen (n : ℕ) (s : Finset α) : Finset (Finset α) :=
- ⟨((s.1.powersetLen n).pmap Finset.mk) fun _t h => nodup_of_le (mem_powersetLen.1 h).1 s.2,
- s.2.powersetLen.pmap fun _a _ha _b _hb => congr_arg Finset.val⟩
-#align finset.powerset_len Finset.powersetLen
+def powersetCard (n : ℕ) (s : Finset α) : Finset (Finset α) :=
+ ⟨((s.1.powersetCard n).pmap Finset.mk) fun _t h => nodup_of_le (mem_powersetCard.1 h).1 s.2,
+ s.2.powersetCard.pmap fun _a _ha _b _hb => congr_arg Finset.val⟩
+#align finset.powerset_len Finset.powersetCard
/-- **Formula for the Number of Combinations** -/
-theorem mem_powersetLen {n} {s t : Finset α} : s ∈ powersetLen n t ↔ s ⊆ t ∧ card s = n := by
- cases s; simp [powersetLen, val_le_iff.symm]
-#align finset.mem_powerset_len Finset.mem_powersetLen
+theorem mem_powersetCard {n} {s t : Finset α} : s ∈ powersetCard n t ↔ s ⊆ t ∧ card s = n := by
+ cases s; simp [powersetCard, val_le_iff.symm]
+#align finset.mem_powerset_len Finset.mem_powersetCard
@[simp]
-theorem powersetLen_mono {n} {s t : Finset α} (h : s ⊆ t) : powersetLen n s ⊆ powersetLen n t :=
- fun _u h' => mem_powersetLen.2 <| And.imp (fun h₂ => Subset.trans h₂ h) id (mem_powersetLen.1 h')
-#align finset.powerset_len_mono Finset.powersetLen_mono
+theorem powersetCard_mono {n} {s t : Finset α} (h : s ⊆ t) : powersetCard n s ⊆ powersetCard n t :=
+ fun _u h' => mem_powersetCard.2 <|
+ And.imp (fun h₂ => Subset.trans h₂ h) id (mem_powersetCard.1 h')
+#align finset.powerset_len_mono Finset.powersetCard_mono
/-- **Formula for the Number of Combinations** -/
@[simp]
-theorem card_powersetLen (n : ℕ) (s : Finset α) : card (powersetLen n s) = Nat.choose (card s) n :=
- (card_pmap _ _ _).trans (Multiset.card_powersetLen n s.1)
-#align finset.card_powerset_len Finset.card_powersetLen
+theorem card_powersetCard (n : ℕ) (s : Finset α) :
+ card (powersetCard n s) = Nat.choose (card s) n :=
+ (card_pmap _ _ _).trans (Multiset.card_powersetCard n s.1)
+#align finset.card_powerset_len Finset.card_powersetCard
@[simp]
-theorem powersetLen_zero (s : Finset α) : Finset.powersetLen 0 s = {∅} := by
- ext; rw [mem_powersetLen, mem_singleton, card_eq_zero]
+theorem powersetCard_zero (s : Finset α) : Finset.powersetCard 0 s = {∅} := by
+ ext; rw [mem_powersetCard, mem_singleton, card_eq_zero]
refine'
⟨fun h => h.2, fun h => by
rw [h]
exact ⟨empty_subset s, rfl⟩⟩
-#align finset.powerset_len_zero Finset.powersetLen_zero
+#align finset.powerset_len_zero Finset.powersetCard_zero
@[simp]
-theorem powersetLen_empty (n : ℕ) {s : Finset α} (h : s.card < n) : powersetLen n s = ∅ :=
- Finset.card_eq_zero.mp (by rw [card_powersetLen, Nat.choose_eq_zero_of_lt h])
-#align finset.powerset_len_empty Finset.powersetLen_empty
+theorem powersetCard_empty (n : ℕ) {s : Finset α} (h : s.card < n) : powersetCard n s = ∅ :=
+ Finset.card_eq_zero.mp (by rw [card_powersetCard, Nat.choose_eq_zero_of_lt h])
+#align finset.powerset_len_empty Finset.powersetCard_empty
-theorem powersetLen_eq_filter {n} {s : Finset α} :
- powersetLen n s = (powerset s).filter fun x => x.card = n := by
+theorem powersetCard_eq_filter {n} {s : Finset α} :
+ powersetCard n s = (powerset s).filter fun x => x.card = n := by
ext
- simp [mem_powersetLen]
-#align finset.powerset_len_eq_filter Finset.powersetLen_eq_filter
+ simp [mem_powersetCard]
+#align finset.powerset_len_eq_filter Finset.powersetCard_eq_filter
-theorem powersetLen_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h : x ∉ s) (n : ℕ) :
- powersetLen n.succ (insert x s) =
- powersetLen n.succ s ∪ (powersetLen n s).image (insert x) := by
- rw [powersetLen_eq_filter, powerset_insert, filter_union, ← powersetLen_eq_filter]
+theorem powersetCard_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h : x ∉ s) (n : ℕ) :
+ powersetCard n.succ (insert x s) =
+ powersetCard n.succ s ∪ (powersetCard n s).image (insert x) := by
+ rw [powersetCard_eq_filter, powerset_insert, filter_union, ← powersetCard_eq_filter]
congr
- rw [powersetLen_eq_filter, image_filter]
+ rw [powersetCard_eq_filter, image_filter]
congr 1
ext t
simp only [mem_powerset, mem_filter, Function.comp_apply, and_congr_right_iff]
intro ht
have : x ∉ t := fun H => h (ht H)
simp [card_insert_of_not_mem this, Nat.succ_inj']
-#align finset.powerset_len_succ_insert Finset.powersetLen_succ_insert
+#align finset.powerset_len_succ_insert Finset.powersetCard_succ_insert
-theorem powersetLen_nonempty {n : ℕ} {s : Finset α} (h : n ≤ s.card) :
- (powersetLen n s).Nonempty := by
+theorem powersetCard_nonempty {n : ℕ} {s : Finset α} (h : n ≤ s.card) :
+ (powersetCard n s).Nonempty := by
classical
induction' s using Finset.induction_on with x s hx IH generalizing n
· rw [card_empty, le_zero_iff] at h
- rw [h, powersetLen_zero]
+ rw [h, powersetCard_zero]
exact Finset.singleton_nonempty _
· cases n
· simp
· rw [card_insert_of_not_mem hx, Nat.succ_le_succ_iff] at h
- rw [powersetLen_succ_insert hx]
+ rw [powersetCard_succ_insert hx]
refine' Nonempty.mono _ ((IH h).image (insert x))
exact subset_union_right _ _
-#align finset.powerset_len_nonempty Finset.powersetLen_nonempty
+#align finset.powerset_len_nonempty Finset.powersetCard_nonempty
@[simp]
-theorem powersetLen_self (s : Finset α) : powersetLen s.card s = {s} := by
+theorem powersetCard_self (s : Finset α) : powersetCard s.card s = {s} := by
ext
- rw [mem_powersetLen, mem_singleton]
+ rw [mem_powersetCard, mem_singleton]
constructor
· exact fun ⟨hs, hc⟩ => eq_of_subset_of_card_le hs hc.ge
· rintro rfl
simp
-#align finset.powerset_len_self Finset.powersetLen_self
+#align finset.powerset_len_self Finset.powersetCard_self
-theorem pairwise_disjoint_powersetLen (s : Finset α) :
- Pairwise fun i j => Disjoint (s.powersetLen i) (s.powersetLen j) := fun _i _j hij =>
+theorem pairwise_disjoint_powersetCard (s : Finset α) :
+ Pairwise fun i j => Disjoint (s.powersetCard i) (s.powersetCard j) := fun _i _j hij =>
Finset.disjoint_left.mpr fun _x hi hj =>
- hij <| (mem_powersetLen.mp hi).2.symm.trans (mem_powersetLen.mp hj).2
-#align finset.pairwise_disjoint_powerset_len Finset.pairwise_disjoint_powersetLen
+ hij <| (mem_powersetCard.mp hi).2.symm.trans (mem_powersetCard.mp hj).2
+#align finset.pairwise_disjoint_powerset_len Finset.pairwise_disjoint_powersetCard
theorem powerset_card_disjiUnion (s : Finset α) :
Finset.powerset s =
- (range (s.card + 1)).disjiUnion (fun i => powersetLen i s)
- (s.pairwise_disjoint_powersetLen.set_pairwise _) := by
+ (range (s.card + 1)).disjiUnion (fun i => powersetCard i s)
+ (s.pairwise_disjoint_powersetCard.set_pairwise _) := by
refine' ext fun a => ⟨fun ha => _, fun ha => _⟩
· rw [mem_disjiUnion]
exact
⟨a.card, mem_range.mpr (Nat.lt_succ_of_le (card_le_of_subset (mem_powerset.mp ha))),
- mem_powersetLen.mpr ⟨mem_powerset.mp ha, rfl⟩⟩
+ mem_powersetCard.mpr ⟨mem_powerset.mp ha, rfl⟩⟩
· rcases mem_disjiUnion.mp ha with ⟨i, _hi, ha⟩
- exact mem_powerset.mpr (mem_powersetLen.mp ha).1
+ exact mem_powerset.mpr (mem_powersetCard.mp ha).1
#align finset.powerset_card_disj_Union Finset.powerset_card_disjiUnion
theorem powerset_card_biUnion [DecidableEq (Finset α)] (s : Finset α) :
- Finset.powerset s = (range (s.card + 1)).biUnion fun i => powersetLen i s := by
+ Finset.powerset s = (range (s.card + 1)).biUnion fun i => powersetCard i s := by
simpa only [disjiUnion_eq_biUnion] using powerset_card_disjiUnion s
#align finset.powerset_card_bUnion Finset.powerset_card_biUnion
-theorem powersetLen_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.card) :
- (powersetLen n.succ u).sup id = u := by
+theorem powersetCard_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.card) :
+ (powersetCard n.succ u).sup id = u := by
apply le_antisymm
- · simp_rw [Finset.sup_le_iff, mem_powersetLen]
+ · simp_rw [Finset.sup_le_iff, mem_powersetCard]
rintro x ⟨h, -⟩
exact h
· rw [sup_eq_biUnion, le_iff_subset, subset_iff]
@@ -309,29 +311,29 @@ theorem powersetLen_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.c
· simp [h']
· intro x hx
simp only [mem_biUnion, exists_prop, id.def]
- obtain ⟨t, ht⟩ : ∃ t, t ∈ powersetLen n (u.erase x) := powersetLen_nonempty
+ obtain ⟨t, ht⟩ : ∃ t, t ∈ powersetCard n (u.erase x) := powersetCard_nonempty
(le_trans (Nat.le_pred_of_lt hn) pred_card_le_card_erase)
· refine' ⟨insert x t, _, mem_insert_self _ _⟩
- rw [← insert_erase hx, powersetLen_succ_insert (not_mem_erase _ _)]
+ rw [← insert_erase hx, powersetCard_succ_insert (not_mem_erase _ _)]
exact mem_union_right _ (mem_image_of_mem _ ht)
-#align finset.powerset_len_sup Finset.powersetLen_sup
+#align finset.powerset_len_sup Finset.powersetCard_sup
@[simp]
-theorem powersetLen_card_add (s : Finset α) {i : ℕ} (hi : 0 < i) :
- s.powersetLen (s.card + i) = ∅ :=
- Finset.powersetLen_empty _ (lt_add_of_pos_right (Finset.card s) hi)
-#align finset.powerset_len_card_add Finset.powersetLen_card_add
+theorem powersetCard_card_add (s : Finset α) {i : ℕ} (hi : 0 < i) :
+ s.powersetCard (s.card + i) = ∅ :=
+ Finset.powersetCard_empty _ (lt_add_of_pos_right (Finset.card s) hi)
+#align finset.powerset_len_card_add Finset.powersetCard_card_add
@[simp]
-theorem map_val_val_powersetLen (s : Finset α) (i : ℕ) :
- (s.powersetLen i).val.map Finset.val = s.1.powersetLen i := by
- simp [Finset.powersetLen, map_pmap, pmap_eq_map, map_id']
-#align finset.map_val_val_powerset_len Finset.map_val_val_powersetLen
+theorem map_val_val_powersetCard (s : Finset α) (i : ℕ) :
+ (s.powersetCard i).val.map Finset.val = s.1.powersetCard i := by
+ simp [Finset.powersetCard, map_pmap, pmap_eq_map, map_id']
+#align finset.map_val_val_powerset_len Finset.map_val_val_powersetCard
-theorem powersetLen_map {β : Type*} (f : α ↪ β) (n : ℕ) (s : Finset α) :
- powersetLen n (s.map f) = (powersetLen n s).map (mapEmbedding f).toEmbedding :=
+theorem powersetCard_map {β : Type*} (f : α ↪ β) (n : ℕ) (s : Finset α) :
+ powersetCard n (s.map f) = (powersetCard n s).map (mapEmbedding f).toEmbedding :=
ext <| fun t => by
- simp only [card_map, mem_powersetLen, le_eq_subset, gt_iff_lt, mem_map, mapEmbedding_apply]
+ simp only [card_map, mem_powersetCard, le_eq_subset, gt_iff_lt, mem_map, mapEmbedding_apply]
constructor
· classical
intro h
@@ -347,8 +349,8 @@ theorem powersetLen_map {β : Type*} (f : α ↪ β) (n : ℕ) (s : Finset α) :
--Porting note: Why is `rw` required here and not `simp`?
rw [mapEmbedding_apply]
simp [has]
-#align finset.powerset_len_map Finset.powersetLen_map
+#align finset.powerset_len_map Finset.powersetCard_map
-end PowersetLen
+end powersetCard
end Finset
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -17,7 +17,7 @@ namespace Finset
open Function Multiset
-variable {α : Type _} {s t : Finset α}
+variable {α : Type*} {s t : Finset α}
/-! ### powerset -/
@@ -328,7 +328,7 @@ theorem map_val_val_powersetLen (s : Finset α) (i : ℕ) :
simp [Finset.powersetLen, map_pmap, pmap_eq_map, map_id']
#align finset.map_val_val_powerset_len Finset.map_val_val_powersetLen
-theorem powersetLen_map {β : Type _} (f : α ↪ β) (n : ℕ) (s : Finset α) :
+theorem powersetLen_map {β : Type*} (f : α ↪ β) (n : ℕ) (s : Finset α) :
powersetLen n (s.map f) = (powersetLen n s).map (mapEmbedding f).toEmbedding :=
ext <| fun t => by
simp only [card_map, mem_powersetLen, le_eq_subset, gt_iff_lt, mem_map, mapEmbedding_apply]
@@ -142,7 +142,7 @@ def decidableForallOfDecidableSubsets' {s : Finset α} {p : Finset α → Prop}
end Powerset
-section Ssubsets
+section SSubsets
variable [DecidableEq α]
@@ -161,34 +161,34 @@ theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets
exact ⟨empty_subset s, h.ne_empty.symm⟩
#align finset.empty_mem_ssubsets Finset.empty_mem_ssubsets
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for any ssubset. -/
-instance decidableExistsOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
+instance decidableExistsOfDecidableSSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
[∀ (t) (h : t ⊂ s), Decidable (p t h)] : Decidable (∃ t h, p t h) :=
decidable_of_iff (∃ (t : _) (hs : t ∈ s.ssubsets), p t (mem_ssubsets.1 hs))
⟨fun ⟨t, _, hp⟩ => ⟨t, _, hp⟩, fun ⟨t, hs, hp⟩ => ⟨t, mem_ssubsets.2 hs, hp⟩⟩
-#align finset.decidable_exists_of_decidable_ssubsets Finset.decidableExistsOfDecidableSsubsets
+#align finset.decidable_exists_of_decidable_ssubsets Finset.decidableExistsOfDecidableSSubsets
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for every ssubset. -/
-instance decidableForallOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
+instance decidableForallOfDecidableSSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
[∀ (t) (h : t ⊂ s), Decidable (p t h)] : Decidable (∀ t h, p t h) :=
decidable_of_iff (∀ (t) (h : t ∈ s.ssubsets), p t (mem_ssubsets.1 h))
⟨fun h t hs => h t (mem_ssubsets.2 hs), fun h _ _ => h _ _⟩
-#align finset.decidable_forall_of_decidable_ssubsets Finset.decidableForallOfDecidableSsubsets
+#align finset.decidable_forall_of_decidable_ssubsets Finset.decidableForallOfDecidableSSubsets
-/-- A version of `Finset.decidableExistsOfDecidableSsubsets` with a non-dependent `p`.
+/-- A version of `Finset.decidableExistsOfDecidableSSubsets` with a non-dependent `p`.
Typeclass inference cannot find `hu` here, so this is not an instance. -/
-def decidableExistsOfDecidableSsubsets' {s : Finset α} {p : Finset α → Prop}
+def decidableExistsOfDecidableSSubsets' {s : Finset α} {p : Finset α → Prop}
(hu : ∀ (t) (_h : t ⊂ s), Decidable (p t)) : Decidable (∃ (t : _) (_h : t ⊂ s), p t) :=
- @Finset.decidableExistsOfDecidableSsubsets _ _ _ _ hu
-#align finset.decidable_exists_of_decidable_ssubsets' Finset.decidableExistsOfDecidableSsubsets'
+ @Finset.decidableExistsOfDecidableSSubsets _ _ _ _ hu
+#align finset.decidable_exists_of_decidable_ssubsets' Finset.decidableExistsOfDecidableSSubsets'
-/-- A version of `Finset.decidableForallOfDecidableSsubsets` with a non-dependent `p`.
+/-- A version of `Finset.decidableForallOfDecidableSSubsets` with a non-dependent `p`.
Typeclass inference cannot find `hu` here, so this is not an instance. -/
-def decidableForallOfDecidableSsubsets' {s : Finset α} {p : Finset α → Prop}
+def decidableForallOfDecidableSSubsets' {s : Finset α} {p : Finset α → Prop}
(hu : ∀ (t) (_h : t ⊂ s), Decidable (p t)) : Decidable (∀ (t) (_h : t ⊂ s), p t) :=
- @Finset.decidableForallOfDecidableSsubsets _ _ _ _ hu
-#align finset.decidable_forall_of_decidable_ssubsets' Finset.decidableForallOfDecidableSsubsets'
+ @Finset.decidableForallOfDecidableSSubsets _ _ _ _ hu
+#align finset.decidable_forall_of_decidable_ssubsets' Finset.decidableForallOfDecidableSSubsets'
-end Ssubsets
+end SSubsets
section PowersetLen
@@ -298,7 +298,7 @@ theorem powerset_card_biUnion [DecidableEq (Finset α)] (s : Finset α) :
simpa only [disjiUnion_eq_biUnion] using powerset_card_disjiUnion s
#align finset.powerset_card_bUnion Finset.powerset_card_biUnion
-theorem powerset_len_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.card) :
+theorem powersetLen_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.card) :
(powersetLen n.succ u).sup id = u := by
apply le_antisymm
· simp_rw [Finset.sup_le_iff, mem_powersetLen]
@@ -314,7 +314,7 @@ theorem powerset_len_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.
· refine' ⟨insert x t, _, mem_insert_self _ _⟩
rw [← insert_erase hx, powersetLen_succ_insert (not_mem_erase _ _)]
exact mem_union_right _ (mem_image_of_mem _ ht)
-#align finset.powerset_len_sup Finset.powerset_len_sup
+#align finset.powerset_len_sup Finset.powersetLen_sup
@[simp]
theorem powersetLen_card_add (s : Finset α) {i : ℕ} (hi : 0 < i) :
@@ -2,15 +2,12 @@
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-
-! This file was ported from Lean 3 source module data.finset.powerset
-! leanprover-community/mathlib commit 9003f28797c0664a49e4179487267c494477d853
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Data.Finset.Lattice
import Mathlib.Data.Multiset.Powerset
+#align_import data.finset.powerset from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
+
/-!
# The powerset of a finset
-/
This PR is the result of running
find . -type f -name "*.lean" -exec sed -i -E 's/^( +)\. /\1· /' {} \;
find . -type f -name "*.lean" -exec sed -i -E 'N;s/^( +·)\n +(.*)$/\1 \2/;P;D' {} \;
which firstly replaces .
focusing dots with ·
and secondly removes isolated instances of such dots, unifying them with the following line. A new rule is placed in the style linter to verify this.
@@ -336,7 +336,7 @@ theorem powersetLen_map {β : Type _} (f : α ↪ β) (n : ℕ) (s : Finset α)
ext <| fun t => by
simp only [card_map, mem_powersetLen, le_eq_subset, gt_iff_lt, mem_map, mapEmbedding_apply]
constructor
- . classical
+ · classical
intro h
have : map f (filter (fun x => (f x ∈ t)) s) = t := by
ext x
@@ -345,7 +345,7 @@ theorem powersetLen_map {β : Type _} (f : α ↪ β) (n : ℕ) (s : Finset α)
fun hx => let ⟨y, hy⟩ := mem_map.1 (h.1 hx); ⟨y, ⟨hy.1, hy.2 ▸ hx⟩, hy.2⟩⟩
refine' ⟨_, _, this⟩
rw [← card_map f, this, h.2]; simp
- . rintro ⟨a, ⟨has, rfl⟩, rfl⟩
+ · rintro ⟨a, ⟨has, rfl⟩, rfl⟩
dsimp [RelEmbedding.coe_toEmbedding]
--Porting note: Why is `rw` required here and not `simp`?
rw [mapEmbedding_apply]
@@ -117,8 +117,8 @@ theorem powerset_insert [DecidableEq α] (s : Finset α) (a : α) :
/-- For predicate `p` decidable on subsets, it is decidable whether `p` holds for any subset. -/
instance decidableExistsOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t ⊆ s), Prop}
- [∀ (t) (h : t ⊆ s), Decidable (p t h)] : Decidable (∃ (t : _)(h : t ⊆ s), p t h) :=
- decidable_of_iff (∃ (t : _)(hs : t ∈ s.powerset), p t (mem_powerset.1 hs))
+ [∀ (t) (h : t ⊆ s), Decidable (p t h)] : Decidable (∃ (t : _) (h : t ⊆ s), p t h) :=
+ decidable_of_iff (∃ (t : _) (hs : t ∈ s.powerset), p t (mem_powerset.1 hs))
⟨fun ⟨t, _, hp⟩ => ⟨t, _, hp⟩, fun ⟨t, hs, hp⟩ => ⟨t, mem_powerset.2 hs, hp⟩⟩
#align finset.decidable_exists_of_decidable_subsets Finset.decidableExistsOfDecidableSubsets
@@ -132,7 +132,7 @@ instance decidableForallOfDecidableSubsets {s : Finset α} {p : ∀ (t) (_ : t
/-- A version of `Finset.decidableExistsOfDecidableSubsets` with a non-dependent `p`.
Typeclass inference cannot find `hu` here, so this is not an instance. -/
def decidableExistsOfDecidableSubsets' {s : Finset α} {p : Finset α → Prop}
- (hu : ∀ (t) (_h : t ⊆ s), Decidable (p t)) : Decidable (∃ (t : _)(_h : t ⊆ s), p t) :=
+ (hu : ∀ (t) (_h : t ⊆ s), Decidable (p t)) : Decidable (∃ (t : _) (_h : t ⊆ s), p t) :=
@Finset.decidableExistsOfDecidableSubsets _ _ _ hu
#align finset.decidable_exists_of_decidable_subsets' Finset.decidableExistsOfDecidableSubsets'
@@ -166,7 +166,7 @@ theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets
/-- For predicate `p` decidable on ssubsets, it is decidable whether `p` holds for any ssubset. -/
instance decidableExistsOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t ⊂ s), Prop}
[∀ (t) (h : t ⊂ s), Decidable (p t h)] : Decidable (∃ t h, p t h) :=
- decidable_of_iff (∃ (t : _)(hs : t ∈ s.ssubsets), p t (mem_ssubsets.1 hs))
+ decidable_of_iff (∃ (t : _) (hs : t ∈ s.ssubsets), p t (mem_ssubsets.1 hs))
⟨fun ⟨t, _, hp⟩ => ⟨t, _, hp⟩, fun ⟨t, hs, hp⟩ => ⟨t, mem_ssubsets.2 hs, hp⟩⟩
#align finset.decidable_exists_of_decidable_ssubsets Finset.decidableExistsOfDecidableSsubsets
@@ -180,7 +180,7 @@ instance decidableForallOfDecidableSsubsets {s : Finset α} {p : ∀ (t) (_ : t
/-- A version of `Finset.decidableExistsOfDecidableSsubsets` with a non-dependent `p`.
Typeclass inference cannot find `hu` here, so this is not an instance. -/
def decidableExistsOfDecidableSsubsets' {s : Finset α} {p : Finset α → Prop}
- (hu : ∀ (t) (_h : t ⊂ s), Decidable (p t)) : Decidable (∃ (t : _)(_h : t ⊂ s), p t) :=
+ (hu : ∀ (t) (_h : t ⊂ s), Decidable (p t)) : Decidable (∃ (t : _) (_h : t ⊂ s), p t) :=
@Finset.decidableExistsOfDecidableSsubsets _ _ _ _ hu
#align finset.decidable_exists_of_decidable_ssubsets' Finset.decidableExistsOfDecidableSsubsets'
sSup
/iSup
(#3938)
As discussed on Zulip
supₛ
→ sSup
infₛ
→ sInf
supᵢ
→ iSup
infᵢ
→ iInf
bsupₛ
→ bsSup
binfₛ
→ bsInf
bsupᵢ
→ biSup
binfᵢ
→ biInf
csupₛ
→ csSup
cinfₛ
→ csInf
csupᵢ
→ ciSup
cinfᵢ
→ ciInf
unionₛ
→ sUnion
interₛ
→ sInter
unionᵢ
→ iUnion
interᵢ
→ iInter
bunionₛ
→ bsUnion
binterₛ
→ bsInter
bunionᵢ
→ biUnion
binterᵢ
→ biInter
Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>
@@ -283,23 +283,23 @@ theorem pairwise_disjoint_powersetLen (s : Finset α) :
hij <| (mem_powersetLen.mp hi).2.symm.trans (mem_powersetLen.mp hj).2
#align finset.pairwise_disjoint_powerset_len Finset.pairwise_disjoint_powersetLen
-theorem powerset_card_disjUnionᵢ (s : Finset α) :
+theorem powerset_card_disjiUnion (s : Finset α) :
Finset.powerset s =
- (range (s.card + 1)).disjUnionᵢ (fun i => powersetLen i s)
+ (range (s.card + 1)).disjiUnion (fun i => powersetLen i s)
(s.pairwise_disjoint_powersetLen.set_pairwise _) := by
refine' ext fun a => ⟨fun ha => _, fun ha => _⟩
- · rw [mem_disjUnionᵢ]
+ · rw [mem_disjiUnion]
exact
⟨a.card, mem_range.mpr (Nat.lt_succ_of_le (card_le_of_subset (mem_powerset.mp ha))),
mem_powersetLen.mpr ⟨mem_powerset.mp ha, rfl⟩⟩
- · rcases mem_disjUnionᵢ.mp ha with ⟨i, _hi, ha⟩
+ · rcases mem_disjiUnion.mp ha with ⟨i, _hi, ha⟩
exact mem_powerset.mpr (mem_powersetLen.mp ha).1
-#align finset.powerset_card_disj_Union Finset.powerset_card_disjUnionᵢ
+#align finset.powerset_card_disj_Union Finset.powerset_card_disjiUnion
-theorem powerset_card_bunionᵢ [DecidableEq (Finset α)] (s : Finset α) :
- Finset.powerset s = (range (s.card + 1)).bunionᵢ fun i => powersetLen i s := by
- simpa only [disjUnionᵢ_eq_bunionᵢ] using powerset_card_disjUnionᵢ s
-#align finset.powerset_card_bUnion Finset.powerset_card_bunionᵢ
+theorem powerset_card_biUnion [DecidableEq (Finset α)] (s : Finset α) :
+ Finset.powerset s = (range (s.card + 1)).biUnion fun i => powersetLen i s := by
+ simpa only [disjiUnion_eq_biUnion] using powerset_card_disjiUnion s
+#align finset.powerset_card_bUnion Finset.powerset_card_biUnion
theorem powerset_len_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.card) :
(powersetLen n.succ u).sup id = u := by
@@ -307,11 +307,11 @@ theorem powerset_len_sup [DecidableEq α] (u : Finset α) (n : ℕ) (hn : n < u.
· simp_rw [Finset.sup_le_iff, mem_powersetLen]
rintro x ⟨h, -⟩
exact h
- · rw [sup_eq_bunionᵢ, le_iff_subset, subset_iff]
+ · rw [sup_eq_biUnion, le_iff_subset, subset_iff]
cases' (Nat.succ_le_of_lt hn).eq_or_lt with h' h'
· simp [h']
· intro x hx
- simp only [mem_bunionᵢ, exists_prop, id.def]
+ simp only [mem_biUnion, exists_prop, id.def]
obtain ⟨t, ht⟩ : ∃ t, t ∈ powersetLen n (u.erase x) := powersetLen_nonempty
(le_trans (Nat.le_pred_of_lt hn) pred_card_le_card_erase)
· refine' ⟨insert x t, _, mem_insert_self _ _⟩
by
s! (#3825)
This PR puts, with one exception, every single remaining by
that lies all by itself on its own line to the previous line, thus matching the current behaviour of start-port.sh
. The exception is when the by
begins the second or later argument to a tuple or anonymous constructor; see https://github.com/leanprover-community/mathlib4/pull/3825#discussion_r1186702599.
Essentially this is s/\n *by$/ by/g
, but with manual editing to satisfy the linter's max-100-char-line requirement. The Python style linter is also modified to catch these "isolated by
s".
@@ -42,8 +42,7 @@ theorem mem_powerset {s t : Finset α} : s ∈ powerset t ↔ s ⊆ t := by
@[simp, norm_cast]
theorem coe_powerset (s : Finset α) :
- (s.powerset : Set (Finset α)) = ((↑) : Finset α → Set α) ⁻¹' (s : Set α).powerset :=
- by
+ (s.powerset : Set (Finset α)) = ((↑) : Finset α → Set α) ⁻¹' (s : Set α).powerset := by
ext
simp
#align finset.coe_powerset Finset.coe_powerset
@@ -100,8 +99,7 @@ theorem not_mem_of_mem_powerset_of_not_mem {s t : Finset α} {a : α} (ht : t
#align finset.not_mem_of_mem_powerset_of_not_mem Finset.not_mem_of_mem_powerset_of_not_mem
theorem powerset_insert [DecidableEq α] (s : Finset α) (a : α) :
- powerset (insert a s) = s.powerset ∪ s.powerset.image (insert a) :=
- by
+ powerset (insert a s) = s.powerset ∪ s.powerset.image (insert a) := by
ext t
simp only [exists_prop, mem_powerset, mem_image, mem_union, subset_insert_iff]
by_cases h : a ∈ t
@@ -161,8 +159,7 @@ theorem mem_ssubsets {s t : Finset α} : t ∈ s.ssubsets ↔ t ⊂ s := by
rw [ssubsets, mem_erase, mem_powerset, ssubset_iff_subset_ne, and_comm]
#align finset.mem_ssubsets Finset.mem_ssubsets
-theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets :=
- by
+theorem empty_mem_ssubsets {s : Finset α} (h : s.Nonempty) : ∅ ∈ s.ssubsets := by
rw [mem_ssubsets, ssubset_iff_subset_ne]
exact ⟨empty_subset s, h.ne_empty.symm⟩
#align finset.empty_mem_ssubsets Finset.empty_mem_ssubsets
@@ -222,8 +219,7 @@ theorem card_powersetLen (n : ℕ) (s : Finset α) : card (powersetLen n s) = Na
#align finset.card_powerset_len Finset.card_powersetLen
@[simp]
-theorem powersetLen_zero (s : Finset α) : Finset.powersetLen 0 s = {∅} :=
- by
+theorem powersetLen_zero (s : Finset α) : Finset.powersetLen 0 s = {∅} := by
ext; rw [mem_powersetLen, mem_singleton, card_eq_zero]
refine'
⟨fun h => h.2, fun h => by
@@ -237,15 +233,14 @@ theorem powersetLen_empty (n : ℕ) {s : Finset α} (h : s.card < n) : powersetL
#align finset.powerset_len_empty Finset.powersetLen_empty
theorem powersetLen_eq_filter {n} {s : Finset α} :
- powersetLen n s = (powerset s).filter fun x => x.card = n :=
- by
+ powersetLen n s = (powerset s).filter fun x => x.card = n := by
ext
simp [mem_powersetLen]
#align finset.powerset_len_eq_filter Finset.powersetLen_eq_filter
theorem powersetLen_succ_insert [DecidableEq α] {x : α} {s : Finset α} (h : x ∉ s) (n : ℕ) :
- powersetLen n.succ (insert x s) = powersetLen n.succ s ∪ (powersetLen n s).image (insert x) :=
- by
+ powersetLen n.succ (insert x s) =
+ powersetLen n.succ s ∪ (powersetLen n s).image (insert x) := by
rw [powersetLen_eq_filter, powerset_insert, filter_union, ← powersetLen_eq_filter]
congr
rw [powersetLen_eq_filter, image_filter]
@@ -273,8 +268,7 @@ theorem powersetLen_nonempty {n : ℕ} {s : Finset α} (h : n ≤ s.card) :
#align finset.powerset_len_nonempty Finset.powersetLen_nonempty
@[simp]
-theorem powersetLen_self (s : Finset α) : powersetLen s.card s = {s} :=
- by
+theorem powersetLen_self (s : Finset α) : powersetLen s.card s = {s} := by
ext
rw [mem_powersetLen, mem_singleton]
constructor
@@ -292,8 +286,7 @@ theorem pairwise_disjoint_powersetLen (s : Finset α) :
theorem powerset_card_disjUnionᵢ (s : Finset α) :
Finset.powerset s =
(range (s.card + 1)).disjUnionᵢ (fun i => powersetLen i s)
- (s.pairwise_disjoint_powersetLen.set_pairwise _) :=
- by
+ (s.pairwise_disjoint_powersetLen.set_pairwise _) := by
refine' ext fun a => ⟨fun ha => _, fun ha => _⟩
· rw [mem_disjUnionᵢ]
exact
The changes I made were.
Use FunLike.coe
instead of the previous definition for the coercion from RelEmbedding
To functions and OrderIso
to functions. The previous definition was
instance : CoeFun (r ↪r s) fun _ => α → β :=
-- ⟨fun o => o.toEmbedding⟩
This does not display nicely.
I also restored the simp
attributes on a few lemmas that had their simp
attributes removed during the port. Eventually
we might want a RelEmbeddingLike
class, but this PR does not implement that.
I also added a few lemmas that proved that coercions to function commute with RelEmbedding.toRelHom
or similar.
The other changes are just fixing the build. One strange issue is that the lemma Finset.mapEmbedding_apply
seems to be harder to use, it has to be used with rw
instead of simp
Co-authored-by: Chris Hughes <33847686+ChrisHughes24@users.noreply.github.com>
@@ -353,7 +353,10 @@ theorem powersetLen_map {β : Type _} (f : α ↪ β) (n : ℕ) (s : Finset α)
refine' ⟨_, _, this⟩
rw [← card_map f, this, h.2]; simp
. rintro ⟨a, ⟨has, rfl⟩, rfl⟩
- simp [*]
+ dsimp [RelEmbedding.coe_toEmbedding]
+ --Porting note: Why is `rw` required here and not `simp`?
+ rw [mapEmbedding_apply]
+ simp [has]
#align finset.powerset_len_map Finset.powersetLen_map
end PowersetLen
The unported dependencies are