data.finset.card
⟷
Mathlib.Data.Finset.Card
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.
(last sync)
attach
and filter
lemmas (#18087)
Left commutativity and cardinality of list.filter
/multiset.filter
/finset.filter
. Interaction of count
/countp
and attach
.
@@ -42,6 +42,7 @@ variables {s t : finset α} {a b : α}
def card (s : finset α) : ℕ := s.1.card
lemma card_def (s : finset α) : s.card = s.1.card := rfl
+@[simp] lemma card_val (s : finset α) : s.1.card = s.card := rfl
@[simp] lemma card_mk {m nodup} : (⟨m, nodup⟩ : finset α).card = m.card := rfl
More lemmas about is_clique
, is_n_clique
, edge_set
. Also define clique_free_on
, a local version of clique_free
.
@@ -434,6 +434,13 @@ begin
exact card_le_of_subset hx }
end
+lemma exists_mem_ne (hs : 1 < s.card) (a : α) : ∃ b ∈ s, b ≠ a :=
+begin
+ by_contra',
+ haveI : nonempty α := ⟨a⟩,
+ exact hs.not_le (card_le_one_iff_subset_singleton.2 ⟨a, subset_singleton_iff'.2 this⟩),
+end
+
/-- A `finset` of a subsingleton type has cardinality at most one. -/
lemma card_le_one_of_subsingleton [subsingleton α] (s : finset α) : s.card ≤ 1 :=
finset.card_le_one_iff.2 $ λ _ _ _ _, subsingleton.elim _ _
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(first ported)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -664,7 +664,7 @@ theorem card_eq_one : s.card = 1 ↔ ∃ a, s = {a} := by
#align finset.card_eq_one Finset.card_eq_one
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (a «expr ∉ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (a «expr ∉ » s) -/
#print Finset.exists_eq_insert_iff /-
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
(∃ (a : _) (_ : a ∉ s), insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card :=
@@ -818,7 +818,7 @@ theorem card_eq_three [DecidableEq α] :
/- ./././Mathport/Syntax/Translate/Command.lean:299:8: warning: using_well_founded used, estimated equivalent -/
-/- ./././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.strongInduction /-
/-- Suppose that, given objects defined on all strict subsets of any finset `s`, one knows how to
define an object on `s`. Then one can inductively define an object on all finsets, starting from
@@ -833,7 +833,7 @@ termination_by x => WellFounded.wrap (measure_wf card) x
#align finset.strong_induction Finset.strongInduction
-/
-/- ./././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.strongInduction_eq /-
theorem strongInduction_eq {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s)
(s : Finset α) : strongInduction H s = H s fun t h => strongInduction H t := by
@@ -841,7 +841,7 @@ theorem strongInduction_eq {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ :
#align finset.strong_induction_eq Finset.strongInduction_eq
-/
-/- ./././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.strongInductionOn /-
/-- Analogue of `strong_induction` with order of arguments swapped. -/
@[elab_as_elim]
@@ -850,7 +850,7 @@ def strongInductionOn {p : Finset α → Sort _} (s : Finset α) :
#align finset.strong_induction_on Finset.strongInductionOn
-/
-/- ./././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.strongInductionOn_eq /-
theorem strongInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) :
@@ -859,7 +859,7 @@ theorem strongInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
#align finset.strong_induction_on_eq Finset.strongInductionOn_eq
-/
-/- ./././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.case_strong_induction_on /-
@[elab_as_elim]
theorem case_strong_induction_on [DecidableEq α] {p : Finset α → Prop} (s : Finset α) (h₀ : p ∅)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -302,13 +302,13 @@ theorem card_image_of_injOn [DecidableEq β] (H : Set.InjOn f s) : (s.image f).c
#print Finset.injOn_of_card_image_eq /-
theorem injOn_of_card_image_eq [DecidableEq β] (H : (s.image f).card = s.card) : Set.InjOn f s :=
by
- change (s.1.map f).dedup.card = s.1.card at H
+ change (s.1.map f).dedup.card = s.1.card at H
have : (s.1.map f).dedup = s.1.map f :=
by
refine' Multiset.eq_of_le_of_card_le (Multiset.dedup_le _) _
rw [H]
simp only [Multiset.card_map]
- rw [Multiset.dedup_eq_self] at this
+ rw [Multiset.dedup_eq_self] at this
exact inj_on_of_nodup_map this
#align finset.inj_on_of_card_image_eq Finset.injOn_of_card_image_eq
-/
@@ -382,7 +382,7 @@ theorem map_eq_of_subset {f : α ↪ α} (hs : s.map f ⊆ s) : s.map f = s :=
theorem filter_card_eq {p : α → Prop} [DecidablePred p] (h : (s.filterₓ p).card = s.card) (x : α)
(hx : x ∈ s) : p x :=
by
- rw [← eq_of_subset_of_card_le (s.filter_subset p) h.ge, mem_filter] at hx
+ rw [← eq_of_subset_of_card_le (s.filter_subset p) h.ge, mem_filter] at hx
exact hx.2
#align finset.filter_card_eq Finset.filter_card_eq
-/
@@ -482,7 +482,7 @@ theorem surj_on_of_inj_on_of_card_le {t : Finset β} (f : ∀ a ∈ s, β) (hf :
let ⟨a, ha₁, ha₂⟩ := mem_image.1 h
ha₂ ▸ hf _ _)
(by simp [hst, h])
- rw [← h'] at hb
+ rw [← h'] at hb
obtain ⟨a, ha₁, ha₂⟩ := mem_image.1 hb
exact ⟨a, a.2, ha₂.symm⟩
#align finset.surj_on_of_inj_on_of_card_le Finset.surj_on_of_inj_on_of_card_le
@@ -562,7 +562,7 @@ theorem card_union_of_disjoint (h : Disjoint s t) : card (s ∪ t) = s.card + t.
#print Finset.card_sdiff /-
theorem card_sdiff (h : s ⊆ t) : card (t \ s) = t.card - s.card :=
by
- suffices card (t \ s) = card (t \ s ∪ s) - s.card by rwa [sdiff_union_of_subset h] at this
+ suffices card (t \ s) = card (t \ s ∪ s) - s.card by rwa [sdiff_union_of_subset h] at this
rw [card_disjoint_union sdiff_disjoint, add_tsub_cancel_right]
#align finset.card_sdiff Finset.card_sdiff
-/
@@ -648,7 +648,7 @@ theorem exists_subset_or_subset_of_two_mul_lt_card [DecidableEq α] {X Y : Finse
have h₁ : (X ∩ (Y \ X)).card = 0 := finset.card_eq_zero.mpr (Finset.inter_sdiff_self X Y)
have h₂ : (X ∪ Y).card = X.card + (Y \ X).card := by
rw [← card_union_add_card_inter X (Y \ X), Finset.union_sdiff_self_eq_union, h₁, add_zero]
- rw [h₂, two_mul] at hXY
+ rw [h₂, two_mul] at hXY
rcases lt_or_lt_of_add_lt_add hXY with (h | h)
· exact ⟨X, h, Or.inl (Finset.Subset.refl X)⟩
· exact ⟨Y \ X, h, Or.inr (Finset.sdiff_subset Y X)⟩
@@ -806,7 +806,7 @@ theorem card_eq_three [DecidableEq α] :
· rw [card_eq_succ]
simp_rw [card_eq_two]
rintro ⟨a, _, abc, rfl, b, c, bc, rfl⟩
- rw [mem_insert, mem_singleton, not_or] at abc
+ rw [mem_insert, mem_singleton, not_or] at abc
exact ⟨a, b, c, abc.1, abc.2, bc, rfl⟩
· rintro ⟨x, y, z, xy, xz, yz, rfl⟩
simp only [xy, xz, yz, mem_insert, card_insert_of_not_mem, not_false_iff, mem_singleton,
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -544,17 +544,19 @@ theorem card_union_le (s t : Finset α) : (s ∪ t).card ≤ s.card + t.card :=
#align finset.card_union_le Finset.card_union_le
-/
-#print Finset.card_union_eq /-
-theorem card_union_eq (h : Disjoint s t) : (s ∪ t).card = s.card + t.card := by
+#print Finset.card_union_of_disjoint /-
+theorem card_union_of_disjoint (h : Disjoint s t) : (s ∪ t).card = s.card + t.card := by
rw [← disj_union_eq_union s t h, card_disj_union _ _ _]
-#align finset.card_union_eq Finset.card_union_eq
+#align finset.card_union_eq Finset.card_union_of_disjoint
-/
-#print Finset.card_disjoint_union /-
+/- warning: finset.card_disjoint_union clashes with finset.card_union_eq -> Finset.card_union_of_disjoint
+Case conversion may be inaccurate. Consider using '#align finset.card_disjoint_union Finset.card_union_of_disjointₓ'. -/
+#print Finset.card_union_of_disjoint /-
@[simp]
-theorem card_disjoint_union (h : Disjoint s t) : card (s ∪ t) = s.card + t.card :=
- card_union_eq h
-#align finset.card_disjoint_union Finset.card_disjoint_union
+theorem card_union_of_disjoint (h : Disjoint s t) : card (s ∪ t) = s.card + t.card :=
+ card_union_of_disjoint h
+#align finset.card_disjoint_union Finset.card_union_of_disjoint
-/
#print Finset.card_sdiff /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -815,7 +815,7 @@ theorem card_eq_three [DecidableEq α] :
/-! ### Inductions -/
-/- ./././Mathport/Syntax/Translate/Command.lean:298:8: warning: using_well_founded used, estimated equivalent -/
+/- ./././Mathport/Syntax/Translate/Command.lean:299:8: warning: using_well_founded used, estimated equivalent -/
/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (t «expr ⊂ » s) -/
#print Finset.strongInduction /-
/-- Suppose that, given objects defined on all strict subsets of any finset `s`, one knows how to
@@ -827,8 +827,7 @@ def strongInduction {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s
H s fun t h =>
have : t.card < s.card := card_lt_card h
strong_induction t
-termination_by
- _ x => WellFounded.wrap (measure_wf card) x
+termination_by x => WellFounded.wrap (measure_wf card) x
#align finset.strong_induction Finset.strongInduction
-/
@@ -869,7 +868,7 @@ theorem case_strong_induction_on [DecidableEq α] {p : Finset α → Prop} (s :
#align finset.case_strong_induction_on Finset.case_strong_induction_on
-/
-/- ./././Mathport/Syntax/Translate/Command.lean:298:8: warning: using_well_founded used, estimated equivalent -/
+/- ./././Mathport/Syntax/Translate/Command.lean:299:8: warning: using_well_founded used, estimated equivalent -/
#print Finset.strongDownwardInduction /-
/-- Suppose that, given that `p t` can be defined on all supersets of `s` of cardinality less than
`n`, one knows how to define `p s`. Then one can inductively define `p s` for all finsets `s` of
@@ -882,8 +881,7 @@ def strongDownwardInduction {p : Finset α → Sort _} {n : ℕ}
H s fun t ht h =>
have : n - t.card < n - s.card := (tsub_lt_tsub_iff_left_of_le ht).2 (Finset.card_lt_card h)
strong_downward_induction t ht
-termination_by
- _ x => WellFounded.wrap (measure_wf fun t : Finset α => n - t.card) x
+termination_by x => WellFounded.wrap (measure_wf fun t : Finset α => n - t.card) x
#align finset.strong_downward_induction Finset.strongDownwardInduction
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -398,19 +398,49 @@ theorem card_eq_of_bijective (f : ∀ i, i < n → α) (hf : ∀ a ∈ s, ∃ i,
(hf' : ∀ (i) (h : i < n), f i h ∈ s)
(f_inj : ∀ (i j) (hi : i < n) (hj : j < n), f i hi = f j hj → i = j) : s.card = n := by
classical
+ have : ∀ a : α, a ∈ s ↔ ∃ (i : _) (hi : i ∈ range n), f i (mem_range.1 hi) = a := fun a =>
+ ⟨fun ha =>
+ let ⟨i, hi, Eq⟩ := hf a ha
+ ⟨i, mem_range.2 hi, Eq⟩,
+ fun ⟨i, hi, Eq⟩ => Eq ▸ hf' i (mem_range.1 hi)⟩
+ have : s = (range n).attach.image fun i => f i.1 (mem_range.1 i.2) := by
+ simpa only [ext_iff, mem_image, exists_prop, Subtype.exists, mem_attach, true_and_iff]
+ calc
+ s.card = card ((range n).attach.image fun i => f i.1 (mem_range.1 i.2)) := by rw [this]
+ _ = card (range n).attach :=
+ (card_image_of_injective _ fun ⟨i, hi⟩ ⟨j, hj⟩ eq =>
+ Subtype.eq <| f_inj i j (mem_range.1 hi) (mem_range.1 hj) Eq)
+ _ = card (range n) := card_attach
+ _ = n := card_range n
#align finset.card_eq_of_bijective Finset.card_eq_of_bijective
-/
#print Finset.card_congr /-
theorem card_congr {t : Finset β} (f : ∀ a ∈ s, β) (h₁ : ∀ a ha, f a ha ∈ t)
(h₂ : ∀ a b ha hb, f a ha = f b hb → a = b) (h₃ : ∀ b ∈ t, ∃ a ha, f a ha = b) :
- s.card = t.card := by classical
+ s.card = t.card := by
+ classical calc
+ s.card = s.attach.card := card_attach.symm
+ _ = (s.attach.image fun a : { a // a ∈ s } => f a.1 a.2).card :=
+ (Eq.symm (card_image_of_injective _ fun a b h => Subtype.eq <| h₂ _ _ _ _ h))
+ _ = t.card :=
+ congr_arg card
+ (Finset.ext fun b =>
+ ⟨fun h =>
+ let ⟨a, ha₁, ha₂⟩ := mem_image.1 h
+ ha₂ ▸ h₁ _ _,
+ fun h =>
+ let ⟨a, ha₁, ha₂⟩ := h₃ b h
+ mem_image.2 ⟨⟨a, ha₁⟩, by simp [ha₂]⟩⟩)
#align finset.card_congr Finset.card_congr
-/
#print Finset.card_le_card_of_inj_on /-
theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s, f a ∈ t)
- (f_inj : ∀ a₁ ∈ s, ∀ a₂ ∈ s, f a₁ = f a₂ → a₁ = a₂) : s.card ≤ t.card := by classical
+ (f_inj : ∀ a₁ ∈ s, ∀ a₂ ∈ s, f a₁ = f a₂ → a₁ = a₂) : s.card ≤ t.card := by
+ classical calc
+ s.card = (s.image f).card := (card_image_of_inj_on f_inj).symm
+ _ ≤ t.card := card_le_of_subset <| image_subset_iff.2 hf
#align finset.card_le_card_of_inj_on Finset.card_le_card_of_inj_on
-/
@@ -418,7 +448,13 @@ theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s
/-- If there are more pigeons than pigeonholes, then there are two pigeons in the same pigeonhole.
-/
theorem exists_ne_map_eq_of_card_lt_of_maps_to {t : Finset β} (hc : t.card < s.card) {f : α → β}
- (hf : ∀ a ∈ s, f a ∈ t) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y := by classical
+ (hf : ∀ a ∈ s, f a ∈ t) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y := by
+ classical
+ by_contra! hz
+ refine' hc.not_le (card_le_card_of_inj_on f hf _)
+ intro x hx y hy
+ contrapose
+ exact hz x hx y hy
#align finset.exists_ne_map_eq_of_card_lt_of_maps_to Finset.exists_ne_map_eq_of_card_lt_of_maps_to
-/
@@ -434,7 +470,21 @@ theorem le_card_of_inj_on_range (f : ℕ → α) (hf : ∀ i < n, f i ∈ s)
#print Finset.surj_on_of_inj_on_of_card_le /-
theorem surj_on_of_inj_on_of_card_le {t : Finset β} (f : ∀ a ∈ s, β) (hf : ∀ a ha, f a ha ∈ t)
(hinj : ∀ a₁ a₂ ha₁ ha₂, f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂) (hst : t.card ≤ s.card) :
- ∀ b ∈ t, ∃ a ha, b = f a ha := by classical
+ ∀ b ∈ t, ∃ a ha, b = f a ha := by
+ classical
+ intro b hb
+ have h : (s.attach.image fun a : { a // a ∈ s } => f a a.Prop).card = s.card :=
+ @card_attach _ s ▸
+ card_image_of_injective _ fun ⟨a₁, ha₁⟩ ⟨a₂, ha₂⟩ h => Subtype.eq <| hinj _ _ _ _ h
+ have h' : image (fun a : { a // a ∈ s } => f a a.Prop) s.attach = t :=
+ eq_of_subset_of_card_le
+ (fun b h =>
+ let ⟨a, ha₁, ha₂⟩ := mem_image.1 h
+ ha₂ ▸ hf _ _)
+ (by simp [hst, h])
+ rw [← h'] at hb
+ obtain ⟨a, ha₁, ha₂⟩ := mem_image.1 hb
+ exact ⟨a, a.2, ha₂.symm⟩
#align finset.surj_on_of_inj_on_of_card_le Finset.surj_on_of_inj_on_of_card_le
-/
@@ -547,7 +597,8 @@ end Lattice
#print Finset.filter_card_add_filter_neg_card_eq_card /-
theorem filter_card_add_filter_neg_card_eq_card (p : α → Prop) [DecidablePred p] :
- (s.filterₓ p).card + (s.filterₓ (Not ∘ p)).card = s.card := by classical
+ (s.filterₓ p).card + (s.filterₓ (Not ∘ p)).card = s.card := by
+ classical simp [← card_union_eq, filter_union_filter_neg_eq, disjoint_filter]
#align finset.filter_card_add_filter_neg_card_eq_card Finset.filter_card_add_filter_neg_card_eq_card
-/
@@ -555,7 +606,27 @@ theorem filter_card_add_filter_neg_card_eq_card (p : α → Prop) [DecidablePred
/-- Given a set `A` and a set `B` inside it, we can shrink `A` to any appropriate size, and keep `B`
inside it. -/
theorem exists_intermediate_set {A B : Finset α} (i : ℕ) (h₁ : i + card B ≤ card A) (h₂ : B ⊆ A) :
- ∃ C : Finset α, B ⊆ C ∧ C ⊆ A ∧ card C = i + card B := by classical
+ ∃ C : Finset α, B ⊆ C ∧ C ⊆ A ∧ card C = i + card B := by
+ classical
+ rcases Nat.le.dest h₁ with ⟨k, _⟩
+ clear h₁
+ induction' k with k ih generalizing A
+ · exact ⟨A, h₂, subset.refl _, h.symm⟩
+ have : (A \ B).Nonempty :=
+ by
+ rw [← card_pos, card_sdiff h₂, ← h, Nat.add_right_comm, add_tsub_cancel_right, Nat.add_succ]
+ apply Nat.succ_pos
+ rcases this with ⟨a, ha⟩
+ have z : i + card B + k = card (erase A a) :=
+ by
+ rw [card_erase_of_mem (mem_sdiff.1 ha).1, ← h]
+ rfl
+ rcases ih _ z with ⟨B', hB', B'subA', cards⟩
+ · exact ⟨B', hB', trans B'subA' (erase_subset _ _), cards⟩
+ · rintro t th
+ apply mem_erase_of_ne_of_mem _ (h₂ th)
+ rintro rfl
+ exact not_mem_sdiff_of_mem_right th ha
#align finset.exists_intermediate_set Finset.exists_intermediate_set
-/
@@ -671,6 +742,17 @@ theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠
#print Finset.two_lt_card_iff /-
theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c := by
classical
+ refine' ⟨fun h => _, _⟩
+ · obtain ⟨c, hc⟩ := card_pos.mp (zero_lt_two.trans h)
+ have : 1 < (s.erase c).card := by rwa [← add_lt_add_iff_right 1, card_erase_add_one hc]
+ obtain ⟨a, b, ha, hb, hab⟩ := one_lt_card_iff.mp this
+ exact
+ ⟨a, b, c, mem_of_mem_erase ha, mem_of_mem_erase hb, hc, hab, ne_of_mem_erase ha,
+ ne_of_mem_erase hb⟩
+ · rintro ⟨a, b, c, ha, hb, hc, hab, hac, hbc⟩
+ rw [← card_erase_add_one hc, ← card_erase_add_one (mem_erase_of_ne_of_mem hbc hb), ←
+ card_erase_add_one (mem_erase_of_ne_of_mem hab (mem_erase_of_ne_of_mem hac ha))]
+ apply Nat.le_add_left
#align finset.two_lt_card_iff Finset.two_lt_card_iff
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -398,49 +398,19 @@ theorem card_eq_of_bijective (f : ∀ i, i < n → α) (hf : ∀ a ∈ s, ∃ i,
(hf' : ∀ (i) (h : i < n), f i h ∈ s)
(f_inj : ∀ (i j) (hi : i < n) (hj : j < n), f i hi = f j hj → i = j) : s.card = n := by
classical
- have : ∀ a : α, a ∈ s ↔ ∃ (i : _) (hi : i ∈ range n), f i (mem_range.1 hi) = a := fun a =>
- ⟨fun ha =>
- let ⟨i, hi, Eq⟩ := hf a ha
- ⟨i, mem_range.2 hi, Eq⟩,
- fun ⟨i, hi, Eq⟩ => Eq ▸ hf' i (mem_range.1 hi)⟩
- have : s = (range n).attach.image fun i => f i.1 (mem_range.1 i.2) := by
- simpa only [ext_iff, mem_image, exists_prop, Subtype.exists, mem_attach, true_and_iff]
- calc
- s.card = card ((range n).attach.image fun i => f i.1 (mem_range.1 i.2)) := by rw [this]
- _ = card (range n).attach :=
- (card_image_of_injective _ fun ⟨i, hi⟩ ⟨j, hj⟩ eq =>
- Subtype.eq <| f_inj i j (mem_range.1 hi) (mem_range.1 hj) Eq)
- _ = card (range n) := card_attach
- _ = n := card_range n
#align finset.card_eq_of_bijective Finset.card_eq_of_bijective
-/
#print Finset.card_congr /-
theorem card_congr {t : Finset β} (f : ∀ a ∈ s, β) (h₁ : ∀ a ha, f a ha ∈ t)
(h₂ : ∀ a b ha hb, f a ha = f b hb → a = b) (h₃ : ∀ b ∈ t, ∃ a ha, f a ha = b) :
- s.card = t.card := by
- classical calc
- s.card = s.attach.card := card_attach.symm
- _ = (s.attach.image fun a : { a // a ∈ s } => f a.1 a.2).card :=
- (Eq.symm (card_image_of_injective _ fun a b h => Subtype.eq <| h₂ _ _ _ _ h))
- _ = t.card :=
- congr_arg card
- (Finset.ext fun b =>
- ⟨fun h =>
- let ⟨a, ha₁, ha₂⟩ := mem_image.1 h
- ha₂ ▸ h₁ _ _,
- fun h =>
- let ⟨a, ha₁, ha₂⟩ := h₃ b h
- mem_image.2 ⟨⟨a, ha₁⟩, by simp [ha₂]⟩⟩)
+ s.card = t.card := by classical
#align finset.card_congr Finset.card_congr
-/
#print Finset.card_le_card_of_inj_on /-
theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s, f a ∈ t)
- (f_inj : ∀ a₁ ∈ s, ∀ a₂ ∈ s, f a₁ = f a₂ → a₁ = a₂) : s.card ≤ t.card := by
- classical calc
- s.card = (s.image f).card := (card_image_of_inj_on f_inj).symm
- _ ≤ t.card := card_le_of_subset <| image_subset_iff.2 hf
+ (f_inj : ∀ a₁ ∈ s, ∀ a₂ ∈ s, f a₁ = f a₂ → a₁ = a₂) : s.card ≤ t.card := by classical
#align finset.card_le_card_of_inj_on Finset.card_le_card_of_inj_on
-/
@@ -448,13 +418,7 @@ theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s
/-- If there are more pigeons than pigeonholes, then there are two pigeons in the same pigeonhole.
-/
theorem exists_ne_map_eq_of_card_lt_of_maps_to {t : Finset β} (hc : t.card < s.card) {f : α → β}
- (hf : ∀ a ∈ s, f a ∈ t) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y := by
- classical
- by_contra! hz
- refine' hc.not_le (card_le_card_of_inj_on f hf _)
- intro x hx y hy
- contrapose
- exact hz x hx y hy
+ (hf : ∀ a ∈ s, f a ∈ t) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y := by classical
#align finset.exists_ne_map_eq_of_card_lt_of_maps_to Finset.exists_ne_map_eq_of_card_lt_of_maps_to
-/
@@ -470,21 +434,7 @@ theorem le_card_of_inj_on_range (f : ℕ → α) (hf : ∀ i < n, f i ∈ s)
#print Finset.surj_on_of_inj_on_of_card_le /-
theorem surj_on_of_inj_on_of_card_le {t : Finset β} (f : ∀ a ∈ s, β) (hf : ∀ a ha, f a ha ∈ t)
(hinj : ∀ a₁ a₂ ha₁ ha₂, f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂) (hst : t.card ≤ s.card) :
- ∀ b ∈ t, ∃ a ha, b = f a ha := by
- classical
- intro b hb
- have h : (s.attach.image fun a : { a // a ∈ s } => f a a.Prop).card = s.card :=
- @card_attach _ s ▸
- card_image_of_injective _ fun ⟨a₁, ha₁⟩ ⟨a₂, ha₂⟩ h => Subtype.eq <| hinj _ _ _ _ h
- have h' : image (fun a : { a // a ∈ s } => f a a.Prop) s.attach = t :=
- eq_of_subset_of_card_le
- (fun b h =>
- let ⟨a, ha₁, ha₂⟩ := mem_image.1 h
- ha₂ ▸ hf _ _)
- (by simp [hst, h])
- rw [← h'] at hb
- obtain ⟨a, ha₁, ha₂⟩ := mem_image.1 hb
- exact ⟨a, a.2, ha₂.symm⟩
+ ∀ b ∈ t, ∃ a ha, b = f a ha := by classical
#align finset.surj_on_of_inj_on_of_card_le Finset.surj_on_of_inj_on_of_card_le
-/
@@ -597,8 +547,7 @@ end Lattice
#print Finset.filter_card_add_filter_neg_card_eq_card /-
theorem filter_card_add_filter_neg_card_eq_card (p : α → Prop) [DecidablePred p] :
- (s.filterₓ p).card + (s.filterₓ (Not ∘ p)).card = s.card := by
- classical simp [← card_union_eq, filter_union_filter_neg_eq, disjoint_filter]
+ (s.filterₓ p).card + (s.filterₓ (Not ∘ p)).card = s.card := by classical
#align finset.filter_card_add_filter_neg_card_eq_card Finset.filter_card_add_filter_neg_card_eq_card
-/
@@ -606,27 +555,7 @@ theorem filter_card_add_filter_neg_card_eq_card (p : α → Prop) [DecidablePred
/-- Given a set `A` and a set `B` inside it, we can shrink `A` to any appropriate size, and keep `B`
inside it. -/
theorem exists_intermediate_set {A B : Finset α} (i : ℕ) (h₁ : i + card B ≤ card A) (h₂ : B ⊆ A) :
- ∃ C : Finset α, B ⊆ C ∧ C ⊆ A ∧ card C = i + card B := by
- classical
- rcases Nat.le.dest h₁ with ⟨k, _⟩
- clear h₁
- induction' k with k ih generalizing A
- · exact ⟨A, h₂, subset.refl _, h.symm⟩
- have : (A \ B).Nonempty :=
- by
- rw [← card_pos, card_sdiff h₂, ← h, Nat.add_right_comm, add_tsub_cancel_right, Nat.add_succ]
- apply Nat.succ_pos
- rcases this with ⟨a, ha⟩
- have z : i + card B + k = card (erase A a) :=
- by
- rw [card_erase_of_mem (mem_sdiff.1 ha).1, ← h]
- rfl
- rcases ih _ z with ⟨B', hB', B'subA', cards⟩
- · exact ⟨B', hB', trans B'subA' (erase_subset _ _), cards⟩
- · rintro t th
- apply mem_erase_of_ne_of_mem _ (h₂ th)
- rintro rfl
- exact not_mem_sdiff_of_mem_right th ha
+ ∃ C : Finset α, B ⊆ C ∧ C ⊆ A ∧ card C = i + card B := by classical
#align finset.exists_intermediate_set Finset.exists_intermediate_set
-/
@@ -742,17 +671,6 @@ theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠
#print Finset.two_lt_card_iff /-
theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c := by
classical
- refine' ⟨fun h => _, _⟩
- · obtain ⟨c, hc⟩ := card_pos.mp (zero_lt_two.trans h)
- have : 1 < (s.erase c).card := by rwa [← add_lt_add_iff_right 1, card_erase_add_one hc]
- obtain ⟨a, b, ha, hb, hab⟩ := one_lt_card_iff.mp this
- exact
- ⟨a, b, c, mem_of_mem_erase ha, mem_of_mem_erase hb, hc, hab, ne_of_mem_erase ha,
- ne_of_mem_erase hb⟩
- · rintro ⟨a, b, c, ha, hb, hc, hab, hac, hbc⟩
- rw [← card_erase_add_one hc, ← card_erase_add_one (mem_erase_of_ne_of_mem hbc hb), ←
- card_erase_add_one (mem_erase_of_ne_of_mem hab (mem_erase_of_ne_of_mem hac ha))]
- apply Nat.le_add_left
#align finset.two_lt_card_iff Finset.two_lt_card_iff
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -166,11 +166,11 @@ theorem card_insert_eq_ite : card (insert a s) = if a ∈ s then s.card else s.c
#align finset.card_insert_eq_ite Finset.card_insert_eq_ite
-/
-#print Finset.card_doubleton /-
+#print Finset.card_pair /-
@[simp]
-theorem card_doubleton (h : a ≠ b) : ({a, b} : Finset α).card = 2 := by
+theorem card_pair (h : a ≠ b) : ({a, b} : Finset α).card = 2 := by
rw [card_insert_of_not_mem (not_mem_singleton.2 h), card_singleton]
-#align finset.card_doubleton Finset.card_doubleton
+#align finset.card_doubleton Finset.card_pair
-/
#print Finset.card_erase_of_mem /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -76,10 +76,10 @@ theorem card_empty : card (∅ : Finset α) = 0 :=
#align finset.card_empty Finset.card_empty
-/
-#print Finset.card_le_of_subset /-
-theorem card_le_of_subset : s ⊆ t → s.card ≤ t.card :=
- Multiset.card_le_of_le ∘ val_le_iff.mpr
-#align finset.card_le_of_subset Finset.card_le_of_subset
+#print Finset.card_le_card /-
+theorem card_le_card : s ⊆ t → s.card ≤ t.card :=
+ Multiset.card_le_card ∘ val_le_iff.mpr
+#align finset.card_le_of_subset Finset.card_le_card
-/
#print Finset.card_mono /-
@@ -246,7 +246,7 @@ theorem Multiset.card_toFinset : m.toFinset.card = m.dedup.card :=
#print Multiset.toFinset_card_le /-
theorem Multiset.toFinset_card_le : m.toFinset.card ≤ m.card :=
- card_le_of_le <| dedup_le _
+ card_le_card <| dedup_le _
#align multiset.to_finset_card_le Multiset.toFinset_card_le
-/
@@ -350,7 +350,7 @@ theorem card_subtype (p : α → Prop) [DecidablePred p] (s : Finset α) :
#print Finset.card_filter_le /-
theorem card_filter_le (s : Finset α) (p : α → Prop) [DecidablePred p] :
(s.filterₓ p).card ≤ s.card :=
- card_le_of_subset <| filter_subset _ _
+ card_le_card <| filter_subset _ _
#align finset.card_filter_le Finset.card_filter_le
-/
@@ -567,7 +567,7 @@ theorem card_sdiff (h : s ⊆ t) : card (t \ s) = t.card - s.card :=
#print Finset.card_sdiff_add_card_eq_card /-
theorem card_sdiff_add_card_eq_card {s t : Finset α} (h : s ⊆ t) : card (t \ s) + card s = card t :=
- ((Nat.sub_eq_iff_eq_add (card_le_of_subset h)).mp (card_sdiff h).symm).symm
+ ((Nat.sub_eq_iff_eq_add (card_le_card h)).mp (card_sdiff h).symm).symm
#align finset.card_sdiff_add_card_eq_card Finset.card_sdiff_add_card_eq_card
-/
@@ -575,7 +575,7 @@ theorem card_sdiff_add_card_eq_card {s t : Finset α} (h : s ⊆ t) : card (t \
theorem le_card_sdiff (s t : Finset α) : t.card - s.card ≤ card (t \ s) :=
calc
card t - card s ≤ card t - card (s ∩ t) :=
- tsub_le_tsub_left (card_le_of_subset (inter_subset_left s t)) _
+ tsub_le_tsub_left (card_le_card (inter_subset_left s t)) _
_ = card (t \ (s ∩ t)) := (card_sdiff (inter_subset_right s t)).symm
_ ≤ card (t \ s) := by rw [sdiff_inter_self_right t s]
#align finset.le_card_sdiff Finset.le_card_sdiff
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -815,6 +815,7 @@ theorem card_eq_three [DecidableEq α] :
/-! ### Inductions -/
+/- ./././Mathport/Syntax/Translate/Command.lean:298:8: warning: using_well_founded used, estimated equivalent -/
/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (t «expr ⊂ » s) -/
#print Finset.strongInduction /-
/-- Suppose that, given objects defined on all strict subsets of any finset `s`, one knows how to
@@ -826,7 +827,8 @@ def strongInduction {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s
H s fun t h =>
have : t.card < s.card := card_lt_card h
strong_induction t
-termination_by' ⟨_, measure_wf card⟩
+termination_by
+ _ x => WellFounded.wrap (measure_wf card) x
#align finset.strong_induction Finset.strongInduction
-/
@@ -867,6 +869,7 @@ theorem case_strong_induction_on [DecidableEq α] {p : Finset α → Prop} (s :
#align finset.case_strong_induction_on Finset.case_strong_induction_on
-/
+/- ./././Mathport/Syntax/Translate/Command.lean:298:8: warning: using_well_founded used, estimated equivalent -/
#print Finset.strongDownwardInduction /-
/-- Suppose that, given that `p t` can be defined on all supersets of `s` of cardinality less than
`n`, one knows how to define `p s`. Then one can inductively define `p s` for all finsets `s` of
@@ -879,7 +882,8 @@ def strongDownwardInduction {p : Finset α → Sort _} {n : ℕ}
H s fun t ht h =>
have : n - t.card < n - s.card := (tsub_lt_tsub_iff_left_of_le ht).2 (Finset.card_lt_card h)
strong_downward_induction t ht
-termination_by' ⟨_, measure_wf fun t : Finset α => n - t.card⟩
+termination_by
+ _ x => WellFounded.wrap (measure_wf fun t : Finset α => n - t.card) x
#align finset.strong_downward_induction Finset.strongDownwardInduction
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -711,12 +711,14 @@ theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x
#align finset.card_le_one_iff_subset_singleton Finset.card_le_one_iff_subset_singleton
-/
+#print Finset.exists_mem_ne /-
theorem exists_mem_ne (hs : 1 < s.card) (a : α) : ∃ b ∈ s, b ≠ a :=
by
by_contra!
haveI : Nonempty α := ⟨a⟩
exact hs.not_le (card_le_one_iff_subset_singleton.2 ⟨a, subset_singleton_iff'.2 this⟩)
#align finset.exists_mem_ne Finset.exists_mem_ne
+-/
#print Finset.card_le_one_of_subsingleton /-
/-- A `finset` of a subsingleton type has cardinality at most one. -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -450,7 +450,7 @@ theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s
theorem exists_ne_map_eq_of_card_lt_of_maps_to {t : Finset β} (hc : t.card < s.card) {f : α → β}
(hf : ∀ a ∈ s, f a ∈ t) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y := by
classical
- by_contra' hz
+ by_contra! hz
refine' hc.not_le (card_le_card_of_inj_on f hf _)
intro x hx y hy
contrapose
@@ -713,7 +713,7 @@ theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x
theorem exists_mem_ne (hs : 1 < s.card) (a : α) : ∃ b ∈ s, b ≠ a :=
by
- by_contra'
+ by_contra!
haveI : Nonempty α := ⟨a⟩
exact hs.not_le (card_le_one_iff_subset_singleton.2 ⟨a, subset_singleton_iff'.2 this⟩)
#align finset.exists_mem_ne Finset.exists_mem_ne
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -55,10 +55,12 @@ theorem card_def (s : Finset α) : s.card = s.1.card :=
#align finset.card_def Finset.card_def
-/
+#print Finset.card_val /-
@[simp]
theorem card_val (s : Finset α) : s.1.card = s.card :=
rfl
#align finset.card_val Finset.card_val
+-/
#print Finset.card_mk /-
@[simp]
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -6,7 +6,7 @@ Authors: Leonardo de Moura, Jeremy Avigad
import Data.Finset.Image
import Tactic.ByContra
-#align_import data.finset.card from "leanprover-community/mathlib"@"3365b20c2ffa7c35e47e5209b89ba9abdddf3ffe"
+#align_import data.finset.card from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83"
/-!
# Cardinality of a finite set
@@ -55,6 +55,11 @@ theorem card_def (s : Finset α) : s.card = s.1.card :=
#align finset.card_def Finset.card_def
-/
+@[simp]
+theorem card_val (s : Finset α) : s.1.card = s.card :=
+ rfl
+#align finset.card_val Finset.card_val
+
#print Finset.card_mk /-
@[simp]
theorem card_mk {m nodup} : (⟨m, nodup⟩ : Finset α).card = m.card :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/3365b20c2ffa7c35e47e5209b89ba9abdddf3ffe
@@ -6,7 +6,7 @@ Authors: Leonardo de Moura, Jeremy Avigad
import Data.Finset.Image
import Tactic.ByContra
-#align_import data.finset.card from "leanprover-community/mathlib"@"e04043d6bf7264a3c84bc69711dc354958ca4516"
+#align_import data.finset.card from "leanprover-community/mathlib"@"3365b20c2ffa7c35e47e5209b89ba9abdddf3ffe"
/-!
# Cardinality of a finite set
@@ -704,6 +704,13 @@ theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x
#align finset.card_le_one_iff_subset_singleton Finset.card_le_one_iff_subset_singleton
-/
+theorem exists_mem_ne (hs : 1 < s.card) (a : α) : ∃ b ∈ s, b ≠ a :=
+ by
+ by_contra'
+ haveI : Nonempty α := ⟨a⟩
+ exact hs.not_le (card_le_one_iff_subset_singleton.2 ⟨a, subset_singleton_iff'.2 this⟩)
+#align finset.exists_mem_ne Finset.exists_mem_ne
+
#print Finset.card_le_one_of_subsingleton /-
/-- A `finset` of a subsingleton type has cardinality at most one. -/
theorem card_le_one_of_subsingleton [Subsingleton α] (s : Finset α) : s.card ≤ 1 :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,8 +3,8 @@ Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Jeremy Avigad
-/
-import Mathbin.Data.Finset.Image
-import Mathbin.Tactic.ByContra
+import Data.Finset.Image
+import Tactic.ByContra
#align_import data.finset.card from "leanprover-community/mathlib"@"e04043d6bf7264a3c84bc69711dc354958ca4516"
@@ -655,7 +655,7 @@ theorem card_eq_one : s.card = 1 ↔ ∃ a, s = {a} := by
#align finset.card_eq_one Finset.card_eq_one
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a «expr ∉ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (a «expr ∉ » s) -/
#print Finset.exists_eq_insert_iff /-
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
(∃ (a : _) (_ : a ∉ s), insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card :=
@@ -799,7 +799,7 @@ theorem card_eq_three [DecidableEq α] :
/-! ### Inductions -/
-/- ./././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.strongInduction /-
/-- Suppose that, given objects defined on all strict subsets of any finset `s`, one knows how to
define an object on `s`. Then one can inductively define an object on all finsets, starting from
@@ -814,7 +814,7 @@ termination_by' ⟨_, measure_wf card⟩
#align finset.strong_induction Finset.strongInduction
-/
-/- ./././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.strongInduction_eq /-
theorem strongInduction_eq {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s)
(s : Finset α) : strongInduction H s = H s fun t h => strongInduction H t := by
@@ -822,7 +822,7 @@ theorem strongInduction_eq {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ :
#align finset.strong_induction_eq Finset.strongInduction_eq
-/
-/- ./././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.strongInductionOn /-
/-- Analogue of `strong_induction` with order of arguments swapped. -/
@[elab_as_elim]
@@ -831,7 +831,7 @@ def strongInductionOn {p : Finset α → Sort _} (s : Finset α) :
#align finset.strong_induction_on Finset.strongInductionOn
-/
-/- ./././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.strongInductionOn_eq /-
theorem strongInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) :
@@ -840,7 +840,7 @@ theorem strongInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
#align finset.strong_induction_on_eq Finset.strongInductionOn_eq
-/
-/- ./././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.case_strong_induction_on /-
@[elab_as_elim]
theorem case_strong_induction_on [DecidableEq α] {p : Finset α → Prop} (s : Finset α) (h₀ : p ∅)
mathlib commit https://github.com/leanprover-community/mathlib/commit/32a7e535287f9c73f2e4d2aef306a39190f0b504
@@ -94,7 +94,7 @@ theorem card_pos : 0 < s.card ↔ s.Nonempty :=
#align finset.card_pos Finset.card_pos
-/
-alias card_pos ↔ _ nonempty.card_pos
+alias ⟨_, nonempty.card_pos⟩ := card_pos
#align finset.nonempty.card_pos Finset.Nonempty.card_pos
#print Finset.card_ne_zero_of_mem /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,15 +2,12 @@
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Jeremy Avigad
-
-! This file was ported from Lean 3 source module data.finset.card
-! leanprover-community/mathlib commit e04043d6bf7264a3c84bc69711dc354958ca4516
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.Finset.Image
import Mathbin.Tactic.ByContra
+#align_import data.finset.card from "leanprover-community/mathlib"@"e04043d6bf7264a3c84bc69711dc354958ca4516"
+
/-!
# Cardinality of a finite set
@@ -658,7 +655,7 @@ theorem card_eq_one : s.card = 1 ↔ ∃ a, s = {a} := by
#align finset.card_eq_one Finset.card_eq_one
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (a «expr ∉ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a «expr ∉ » s) -/
#print Finset.exists_eq_insert_iff /-
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
(∃ (a : _) (_ : a ∉ s), insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card :=
@@ -802,7 +799,7 @@ theorem card_eq_three [DecidableEq α] :
/-! ### Inductions -/
-/- ./././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.strongInduction /-
/-- Suppose that, given objects defined on all strict subsets of any finset `s`, one knows how to
define an object on `s`. Then one can inductively define an object on all finsets, starting from
@@ -817,7 +814,7 @@ termination_by' ⟨_, measure_wf card⟩
#align finset.strong_induction Finset.strongInduction
-/
-/- ./././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.strongInduction_eq /-
theorem strongInduction_eq {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s)
(s : Finset α) : strongInduction H s = H s fun t h => strongInduction H t := by
@@ -825,7 +822,7 @@ theorem strongInduction_eq {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ :
#align finset.strong_induction_eq Finset.strongInduction_eq
-/
-/- ./././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.strongInductionOn /-
/-- Analogue of `strong_induction` with order of arguments swapped. -/
@[elab_as_elim]
@@ -834,7 +831,7 @@ def strongInductionOn {p : Finset α → Sort _} (s : Finset α) :
#align finset.strong_induction_on Finset.strongInductionOn
-/
-/- ./././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.strongInductionOn_eq /-
theorem strongInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) :
@@ -843,7 +840,7 @@ theorem strongInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
#align finset.strong_induction_on_eq Finset.strongInductionOn_eq
-/
-/- ./././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.case_strong_induction_on /-
@[elab_as_elim]
theorem case_strong_induction_on [DecidableEq α] {p : Finset α → Prop} (s : Finset α) (h₀ : p ∅)
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -52,14 +52,18 @@ def card (s : Finset α) : ℕ :=
#align finset.card Finset.card
-/
+#print Finset.card_def /-
theorem card_def (s : Finset α) : s.card = s.1.card :=
rfl
#align finset.card_def Finset.card_def
+-/
+#print Finset.card_mk /-
@[simp]
theorem card_mk {m nodup} : (⟨m, nodup⟩ : Finset α).card = m.card :=
rfl
#align finset.card_mk Finset.card_mk
+-/
#print Finset.card_empty /-
@[simp]
@@ -230,17 +234,23 @@ section ToListMultiset
variable [DecidableEq α] (m : Multiset α) (l : List α)
+#print Multiset.card_toFinset /-
theorem Multiset.card_toFinset : m.toFinset.card = m.dedup.card :=
rfl
#align multiset.card_to_finset Multiset.card_toFinset
+-/
+#print Multiset.toFinset_card_le /-
theorem Multiset.toFinset_card_le : m.toFinset.card ≤ m.card :=
card_le_of_le <| dedup_le _
#align multiset.to_finset_card_le Multiset.toFinset_card_le
+-/
+#print Multiset.toFinset_card_of_nodup /-
theorem Multiset.toFinset_card_of_nodup {m : Multiset α} (h : m.Nodup) : m.toFinset.card = m.card :=
congr_arg card <| Multiset.dedup_eq_self.mpr h
#align multiset.to_finset_card_of_nodup Multiset.toFinset_card_of_nodup
+-/
#print List.card_toFinset /-
theorem List.card_toFinset : l.toFinset.card = l.dedup.length :=
@@ -312,15 +322,19 @@ theorem card_image_of_injective [DecidableEq β] (s : Finset α) (H : Injective
#align finset.card_image_of_injective Finset.card_image_of_injective
-/
+#print Finset.fiber_card_ne_zero_iff_mem_image /-
theorem fiber_card_ne_zero_iff_mem_image (s : Finset α) (f : α → β) [DecidableEq β] (y : β) :
(s.filterₓ fun x => f x = y).card ≠ 0 ↔ y ∈ s.image f := by
rw [← pos_iff_ne_zero, card_pos, fiber_nonempty_iff_mem_image]
#align finset.fiber_card_ne_zero_iff_mem_image Finset.fiber_card_ne_zero_iff_mem_image
+-/
+#print Finset.card_map /-
@[simp]
theorem card_map (f : α ↪ β) : (s.map f).card = s.card :=
Multiset.card_map _ _
#align finset.card_map Finset.card_map
+-/
#print Finset.card_subtype /-
@[simp]
@@ -426,6 +440,7 @@ theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s
#align finset.card_le_card_of_inj_on Finset.card_le_card_of_inj_on
-/
+#print Finset.exists_ne_map_eq_of_card_lt_of_maps_to /-
/-- If there are more pigeons than pigeonholes, then there are two pigeons in the same pigeonhole.
-/
theorem exists_ne_map_eq_of_card_lt_of_maps_to {t : Finset β} (hc : t.card < s.card) {f : α → β}
@@ -437,6 +452,7 @@ theorem exists_ne_map_eq_of_card_lt_of_maps_to {t : Finset β} (hc : t.card < s.
contrapose
exact hz x hx y hy
#align finset.exists_ne_map_eq_of_card_lt_of_maps_to Finset.exists_ne_map_eq_of_card_lt_of_maps_to
+-/
#print Finset.le_card_of_inj_on_range /-
theorem le_card_of_inj_on_range (f : ℕ → α) (hf : ∀ i < n, f i ∈ s)
@@ -491,10 +507,12 @@ theorem inj_on_of_surj_on_of_card_le {t : Finset β} (f : ∀ a ∈ s, β) (hf :
#align finset.inj_on_of_surj_on_of_card_le Finset.inj_on_of_surj_on_of_card_le
-/
+#print Finset.card_disjUnion /-
@[simp]
theorem card_disjUnion (s t : Finset α) (h) : (s.disjUnion t h).card = s.card + t.card :=
Multiset.card_add _ _
#align finset.card_disj_union Finset.card_disjUnion
+-/
/-! ### Lattice structure -/
@@ -522,14 +540,18 @@ theorem card_union_le (s t : Finset α) : (s ∪ t).card ≤ s.card + t.card :=
#align finset.card_union_le Finset.card_union_le
-/
+#print Finset.card_union_eq /-
theorem card_union_eq (h : Disjoint s t) : (s ∪ t).card = s.card + t.card := by
rw [← disj_union_eq_union s t h, card_disj_union _ _ _]
#align finset.card_union_eq Finset.card_union_eq
+-/
+#print Finset.card_disjoint_union /-
@[simp]
theorem card_disjoint_union (h : Disjoint s t) : card (s ∪ t) = s.card + t.card :=
card_union_eq h
#align finset.card_disjoint_union Finset.card_disjoint_union
+-/
#print Finset.card_sdiff /-
theorem card_sdiff (h : s ⊆ t) : card (t \ s) = t.card - s.card :=
@@ -569,10 +591,12 @@ theorem card_sdiff_add_card : (s \ t).card + t.card = (s ∪ t).card := by
end Lattice
+#print Finset.filter_card_add_filter_neg_card_eq_card /-
theorem filter_card_add_filter_neg_card_eq_card (p : α → Prop) [DecidablePred p] :
(s.filterₓ p).card + (s.filterₓ (Not ∘ p)).card = s.card := by
classical simp [← card_union_eq, filter_union_filter_neg_eq, disjoint_filter]
#align finset.filter_card_add_filter_neg_card_eq_card Finset.filter_card_add_filter_neg_card_eq_card
+-/
#print Finset.exists_intermediate_set /-
/-- Given a set `A` and a set `B` inside it, we can shrink `A` to any appropriate size, and keep `B`
@@ -690,9 +714,11 @@ theorem card_le_one_of_subsingleton [Subsingleton α] (s : Finset α) : s.card
#align finset.card_le_one_of_subsingleton Finset.card_le_one_of_subsingleton
-/
+#print Finset.one_lt_card /-
theorem one_lt_card : 1 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, a ≠ b := by rw [← not_iff_not]; push_neg;
exact card_le_one
#align finset.one_lt_card Finset.one_lt_card
+-/
#print Finset.one_lt_card_iff /-
theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b := by rw [one_lt_card];
@@ -717,9 +743,11 @@ theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c
#align finset.two_lt_card_iff Finset.two_lt_card_iff
-/
+#print Finset.two_lt_card /-
theorem two_lt_card : 2 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, ∃ c ∈ s, a ≠ b ∧ a ≠ c ∧ b ≠ c := by
simp_rw [two_lt_card_iff, exists_prop, exists_and_left]
#align finset.two_lt_card Finset.two_lt_card
+-/
#print Finset.exists_ne_of_one_lt_card /-
theorem exists_ne_of_one_lt_card (hs : 1 < s.card) (a : α) : ∃ b, b ∈ s ∧ b ≠ a :=
@@ -790,10 +818,12 @@ termination_by' ⟨_, measure_wf card⟩
-/
/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (t «expr ⊂ » s) -/
+#print Finset.strongInduction_eq /-
theorem strongInduction_eq {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s)
(s : Finset α) : strongInduction H s = H s fun t h => strongInduction H t := by
rw [strong_induction]
#align finset.strong_induction_eq Finset.strongInduction_eq
+-/
/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (t «expr ⊂ » s) -/
#print Finset.strongInductionOn /-
@@ -805,11 +835,13 @@ def strongInductionOn {p : Finset α → Sort _} (s : Finset α) :
-/
/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (t «expr ⊂ » s) -/
+#print Finset.strongInductionOn_eq /-
theorem strongInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) :
s.strong_induction_on H = H s fun t h => t.strong_induction_on H := by
dsimp only [strong_induction_on]; rw [strong_induction]
#align finset.strong_induction_on_eq Finset.strongInductionOn_eq
+-/
/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (t «expr ⊆ » s) -/
#print Finset.case_strong_induction_on /-
@@ -838,12 +870,14 @@ termination_by' ⟨_, measure_wf fun t : Finset α => n - t.card⟩
#align finset.strong_downward_induction Finset.strongDownwardInduction
-/
+#print Finset.strongDownwardInduction_eq /-
theorem strongDownwardInduction_eq {p : Finset α → Sort _}
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁)
(s : Finset α) :
strongDownwardInduction H s = H s fun t ht hst => strongDownwardInduction H t ht := by
rw [strong_downward_induction]
#align finset.strong_downward_induction_eq Finset.strongDownwardInduction_eq
+-/
#print Finset.strongDownwardInductionOn /-
/-- Analogue of `strong_downward_induction` with order of arguments swapped. -/
@@ -855,11 +889,13 @@ def strongDownwardInductionOn {p : Finset α → Sort _} (s : Finset α)
#align finset.strong_downward_induction_on Finset.strongDownwardInductionOn
-/
+#print Finset.strongDownwardInductionOn_eq /-
theorem strongDownwardInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
s.strongDownwardInductionOn H = H s fun t ht h => t.strongDownwardInductionOn H ht := by
dsimp only [strong_downward_induction_on]; rw [strong_downward_induction]
#align finset.strong_downward_induction_on_eq Finset.strongDownwardInductionOn_eq
+-/
#print Finset.lt_wf /-
theorem lt_wf {α} : WellFounded (@LT.lt (Finset α) _) :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/7e5137f579de09a059a5ce98f364a04e221aabf0
@@ -394,7 +394,6 @@ theorem card_eq_of_bijective (f : ∀ i, i < n → α) (hf : ∀ a ∈ s, ∃ i,
Subtype.eq <| f_inj i j (mem_range.1 hi) (mem_range.1 hj) Eq)
_ = card (range n) := card_attach
_ = n := card_range n
-
#align finset.card_eq_of_bijective Finset.card_eq_of_bijective
-/
@@ -415,7 +414,6 @@ theorem card_congr {t : Finset β} (f : ∀ a ∈ s, β) (h₁ : ∀ a ha, f a h
fun h =>
let ⟨a, ha₁, ha₂⟩ := h₃ b h
mem_image.2 ⟨⟨a, ha₁⟩, by simp [ha₂]⟩⟩)
-
#align finset.card_congr Finset.card_congr
-/
@@ -425,7 +423,6 @@ theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s
classical calc
s.card = (s.image f).card := (card_image_of_inj_on f_inj).symm
_ ≤ t.card := card_le_of_subset <| image_subset_iff.2 hf
-
#align finset.card_le_card_of_inj_on Finset.card_le_card_of_inj_on
-/
@@ -447,7 +444,6 @@ theorem le_card_of_inj_on_range (f : ℕ → α) (hf : ∀ i < n, f i ∈ s)
calc
n = card (range n) := (card_range n).symm
_ ≤ s.card := card_le_card_of_inj_on f (by simpa only [mem_range]) (by simpa only [mem_range])
-
#align finset.le_card_of_inj_on_range Finset.le_card_of_inj_on_range
-/
@@ -556,7 +552,6 @@ theorem le_card_sdiff (s t : Finset α) : t.card - s.card ≤ card (t \ s) :=
tsub_le_tsub_left (card_le_of_subset (inter_subset_left s t)) _
_ = card (t \ (s ∩ t)) := (card_sdiff (inter_subset_right s t)).symm
_ ≤ card (t \ s) := by rw [sdiff_inter_self_right t s]
-
#align finset.le_card_sdiff Finset.le_card_sdiff
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/31c24aa72e7b3e5ed97a8412470e904f82b81004
@@ -639,7 +639,7 @@ theorem card_eq_one : s.card = 1 ↔ ∃ a, s = {a} := by
#align finset.card_eq_one Finset.card_eq_one
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a «expr ∉ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (a «expr ∉ » s) -/
#print Finset.exists_eq_insert_iff /-
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
(∃ (a : _) (_ : a ∉ s), insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card :=
@@ -779,7 +779,7 @@ theorem card_eq_three [DecidableEq α] :
/-! ### Inductions -/
-/- ./././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.strongInduction /-
/-- Suppose that, given objects defined on all strict subsets of any finset `s`, one knows how to
define an object on `s`. Then one can inductively define an object on all finsets, starting from
@@ -794,13 +794,13 @@ termination_by' ⟨_, measure_wf card⟩
#align finset.strong_induction Finset.strongInduction
-/
-/- ./././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) -/
theorem strongInduction_eq {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s)
(s : Finset α) : strongInduction H s = H s fun t h => strongInduction H t := by
rw [strong_induction]
#align finset.strong_induction_eq Finset.strongInduction_eq
-/- ./././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.strongInductionOn /-
/-- Analogue of `strong_induction` with order of arguments swapped. -/
@[elab_as_elim]
@@ -809,14 +809,14 @@ def strongInductionOn {p : Finset α → Sort _} (s : Finset α) :
#align finset.strong_induction_on Finset.strongInductionOn
-/
-/- ./././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) -/
theorem strongInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) :
s.strong_induction_on H = H s fun t h => t.strong_induction_on H := by
dsimp only [strong_induction_on]; rw [strong_induction]
#align finset.strong_induction_on_eq Finset.strongInductionOn_eq
-/- ./././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.case_strong_induction_on /-
@[elab_as_elim]
theorem case_strong_induction_on [DecidableEq α] {p : Finset α → Prop} (s : Finset α) (h₀ : p ∅)
mathlib commit https://github.com/leanprover-community/mathlib/commit/5f25c089cb34db4db112556f23c50d12da81b297
@@ -380,21 +380,21 @@ theorem card_eq_of_bijective (f : ∀ i, i < n → α) (hf : ∀ a ∈ s, ∃ i,
(hf' : ∀ (i) (h : i < n), f i h ∈ s)
(f_inj : ∀ (i j) (hi : i < n) (hj : j < n), f i hi = f j hj → i = j) : s.card = n := by
classical
- have : ∀ a : α, a ∈ s ↔ ∃ (i : _) (hi : i ∈ range n), f i (mem_range.1 hi) = a := fun a =>
- ⟨fun ha =>
- let ⟨i, hi, Eq⟩ := hf a ha
- ⟨i, mem_range.2 hi, Eq⟩,
- fun ⟨i, hi, Eq⟩ => Eq ▸ hf' i (mem_range.1 hi)⟩
- have : s = (range n).attach.image fun i => f i.1 (mem_range.1 i.2) := by
- simpa only [ext_iff, mem_image, exists_prop, Subtype.exists, mem_attach, true_and_iff]
- calc
- s.card = card ((range n).attach.image fun i => f i.1 (mem_range.1 i.2)) := by rw [this]
- _ = card (range n).attach :=
- (card_image_of_injective _ fun ⟨i, hi⟩ ⟨j, hj⟩ eq =>
- Subtype.eq <| f_inj i j (mem_range.1 hi) (mem_range.1 hj) Eq)
- _ = card (range n) := card_attach
- _ = n := card_range n
-
+ have : ∀ a : α, a ∈ s ↔ ∃ (i : _) (hi : i ∈ range n), f i (mem_range.1 hi) = a := fun a =>
+ ⟨fun ha =>
+ let ⟨i, hi, Eq⟩ := hf a ha
+ ⟨i, mem_range.2 hi, Eq⟩,
+ fun ⟨i, hi, Eq⟩ => Eq ▸ hf' i (mem_range.1 hi)⟩
+ have : s = (range n).attach.image fun i => f i.1 (mem_range.1 i.2) := by
+ simpa only [ext_iff, mem_image, exists_prop, Subtype.exists, mem_attach, true_and_iff]
+ calc
+ s.card = card ((range n).attach.image fun i => f i.1 (mem_range.1 i.2)) := by rw [this]
+ _ = card (range n).attach :=
+ (card_image_of_injective _ fun ⟨i, hi⟩ ⟨j, hj⟩ eq =>
+ Subtype.eq <| f_inj i j (mem_range.1 hi) (mem_range.1 hj) Eq)
+ _ = card (range n) := card_attach
+ _ = n := card_range n
+
#align finset.card_eq_of_bijective Finset.card_eq_of_bijective
-/
@@ -403,19 +403,19 @@ theorem card_congr {t : Finset β} (f : ∀ a ∈ s, β) (h₁ : ∀ a ha, f a h
(h₂ : ∀ a b ha hb, f a ha = f b hb → a = b) (h₃ : ∀ b ∈ t, ∃ a ha, f a ha = b) :
s.card = t.card := by
classical calc
- s.card = s.attach.card := card_attach.symm
- _ = (s.attach.image fun a : { a // a ∈ s } => f a.1 a.2).card :=
- (Eq.symm (card_image_of_injective _ fun a b h => Subtype.eq <| h₂ _ _ _ _ h))
- _ = t.card :=
- congr_arg card
- (Finset.ext fun b =>
- ⟨fun h =>
- let ⟨a, ha₁, ha₂⟩ := mem_image.1 h
- ha₂ ▸ h₁ _ _,
- fun h =>
- let ⟨a, ha₁, ha₂⟩ := h₃ b h
- mem_image.2 ⟨⟨a, ha₁⟩, by simp [ha₂]⟩⟩)
-
+ s.card = s.attach.card := card_attach.symm
+ _ = (s.attach.image fun a : { a // a ∈ s } => f a.1 a.2).card :=
+ (Eq.symm (card_image_of_injective _ fun a b h => Subtype.eq <| h₂ _ _ _ _ h))
+ _ = t.card :=
+ congr_arg card
+ (Finset.ext fun b =>
+ ⟨fun h =>
+ let ⟨a, ha₁, ha₂⟩ := mem_image.1 h
+ ha₂ ▸ h₁ _ _,
+ fun h =>
+ let ⟨a, ha₁, ha₂⟩ := h₃ b h
+ mem_image.2 ⟨⟨a, ha₁⟩, by simp [ha₂]⟩⟩)
+
#align finset.card_congr Finset.card_congr
-/
@@ -423,9 +423,9 @@ theorem card_congr {t : Finset β} (f : ∀ a ∈ s, β) (h₁ : ∀ a ha, f a h
theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s, f a ∈ t)
(f_inj : ∀ a₁ ∈ s, ∀ a₂ ∈ s, f a₁ = f a₂ → a₁ = a₂) : s.card ≤ t.card := by
classical calc
- s.card = (s.image f).card := (card_image_of_inj_on f_inj).symm
- _ ≤ t.card := card_le_of_subset <| image_subset_iff.2 hf
-
+ s.card = (s.image f).card := (card_image_of_inj_on f_inj).symm
+ _ ≤ t.card := card_le_of_subset <| image_subset_iff.2 hf
+
#align finset.card_le_card_of_inj_on Finset.card_le_card_of_inj_on
-/
@@ -434,11 +434,11 @@ theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s
theorem exists_ne_map_eq_of_card_lt_of_maps_to {t : Finset β} (hc : t.card < s.card) {f : α → β}
(hf : ∀ a ∈ s, f a ∈ t) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y := by
classical
- by_contra' hz
- refine' hc.not_le (card_le_card_of_inj_on f hf _)
- intro x hx y hy
- contrapose
- exact hz x hx y hy
+ by_contra' hz
+ refine' hc.not_le (card_le_card_of_inj_on f hf _)
+ intro x hx y hy
+ contrapose
+ exact hz x hx y hy
#align finset.exists_ne_map_eq_of_card_lt_of_maps_to Finset.exists_ne_map_eq_of_card_lt_of_maps_to
#print Finset.le_card_of_inj_on_range /-
@@ -456,19 +456,19 @@ theorem surj_on_of_inj_on_of_card_le {t : Finset β} (f : ∀ a ∈ s, β) (hf :
(hinj : ∀ a₁ a₂ ha₁ ha₂, f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂) (hst : t.card ≤ s.card) :
∀ b ∈ t, ∃ a ha, b = f a ha := by
classical
- intro b hb
- have h : (s.attach.image fun a : { a // a ∈ s } => f a a.Prop).card = s.card :=
- @card_attach _ s ▸
- card_image_of_injective _ fun ⟨a₁, ha₁⟩ ⟨a₂, ha₂⟩ h => Subtype.eq <| hinj _ _ _ _ h
- have h' : image (fun a : { a // a ∈ s } => f a a.Prop) s.attach = t :=
- eq_of_subset_of_card_le
- (fun b h =>
- let ⟨a, ha₁, ha₂⟩ := mem_image.1 h
- ha₂ ▸ hf _ _)
- (by simp [hst, h])
- rw [← h'] at hb
- obtain ⟨a, ha₁, ha₂⟩ := mem_image.1 hb
- exact ⟨a, a.2, ha₂.symm⟩
+ intro b hb
+ have h : (s.attach.image fun a : { a // a ∈ s } => f a a.Prop).card = s.card :=
+ @card_attach _ s ▸
+ card_image_of_injective _ fun ⟨a₁, ha₁⟩ ⟨a₂, ha₂⟩ h => Subtype.eq <| hinj _ _ _ _ h
+ have h' : image (fun a : { a // a ∈ s } => f a a.Prop) s.attach = t :=
+ eq_of_subset_of_card_le
+ (fun b h =>
+ let ⟨a, ha₁, ha₂⟩ := mem_image.1 h
+ ha₂ ▸ hf _ _)
+ (by simp [hst, h])
+ rw [← h'] at hb
+ obtain ⟨a, ha₁, ha₂⟩ := mem_image.1 hb
+ exact ⟨a, a.2, ha₂.symm⟩
#align finset.surj_on_of_inj_on_of_card_le Finset.surj_on_of_inj_on_of_card_le
-/
@@ -585,25 +585,25 @@ inside it. -/
theorem exists_intermediate_set {A B : Finset α} (i : ℕ) (h₁ : i + card B ≤ card A) (h₂ : B ⊆ A) :
∃ C : Finset α, B ⊆ C ∧ C ⊆ A ∧ card C = i + card B := by
classical
- rcases Nat.le.dest h₁ with ⟨k, _⟩
- clear h₁
- induction' k with k ih generalizing A
- · exact ⟨A, h₂, subset.refl _, h.symm⟩
- have : (A \ B).Nonempty :=
- by
- rw [← card_pos, card_sdiff h₂, ← h, Nat.add_right_comm, add_tsub_cancel_right, Nat.add_succ]
- apply Nat.succ_pos
- rcases this with ⟨a, ha⟩
- have z : i + card B + k = card (erase A a) :=
- by
- rw [card_erase_of_mem (mem_sdiff.1 ha).1, ← h]
- rfl
- rcases ih _ z with ⟨B', hB', B'subA', cards⟩
- · exact ⟨B', hB', trans B'subA' (erase_subset _ _), cards⟩
- · rintro t th
- apply mem_erase_of_ne_of_mem _ (h₂ th)
- rintro rfl
- exact not_mem_sdiff_of_mem_right th ha
+ rcases Nat.le.dest h₁ with ⟨k, _⟩
+ clear h₁
+ induction' k with k ih generalizing A
+ · exact ⟨A, h₂, subset.refl _, h.symm⟩
+ have : (A \ B).Nonempty :=
+ by
+ rw [← card_pos, card_sdiff h₂, ← h, Nat.add_right_comm, add_tsub_cancel_right, Nat.add_succ]
+ apply Nat.succ_pos
+ rcases this with ⟨a, ha⟩
+ have z : i + card B + k = card (erase A a) :=
+ by
+ rw [card_erase_of_mem (mem_sdiff.1 ha).1, ← h]
+ rfl
+ rcases ih _ z with ⟨B', hB', B'subA', cards⟩
+ · exact ⟨B', hB', trans B'subA' (erase_subset _ _), cards⟩
+ · rintro t th
+ apply mem_erase_of_ne_of_mem _ (h₂ th)
+ rintro rfl
+ exact not_mem_sdiff_of_mem_right th ha
#align finset.exists_intermediate_set Finset.exists_intermediate_set
-/
@@ -708,17 +708,17 @@ theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠
#print Finset.two_lt_card_iff /-
theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c := by
classical
- refine' ⟨fun h => _, _⟩
- · obtain ⟨c, hc⟩ := card_pos.mp (zero_lt_two.trans h)
- have : 1 < (s.erase c).card := by rwa [← add_lt_add_iff_right 1, card_erase_add_one hc]
- obtain ⟨a, b, ha, hb, hab⟩ := one_lt_card_iff.mp this
- exact
- ⟨a, b, c, mem_of_mem_erase ha, mem_of_mem_erase hb, hc, hab, ne_of_mem_erase ha,
- ne_of_mem_erase hb⟩
- · rintro ⟨a, b, c, ha, hb, hc, hab, hac, hbc⟩
- rw [← card_erase_add_one hc, ← card_erase_add_one (mem_erase_of_ne_of_mem hbc hb), ←
- card_erase_add_one (mem_erase_of_ne_of_mem hab (mem_erase_of_ne_of_mem hac ha))]
- apply Nat.le_add_left
+ refine' ⟨fun h => _, _⟩
+ · obtain ⟨c, hc⟩ := card_pos.mp (zero_lt_two.trans h)
+ have : 1 < (s.erase c).card := by rwa [← add_lt_add_iff_right 1, card_erase_add_one hc]
+ obtain ⟨a, b, ha, hb, hab⟩ := one_lt_card_iff.mp this
+ exact
+ ⟨a, b, c, mem_of_mem_erase ha, mem_of_mem_erase hb, hc, hab, ne_of_mem_erase ha,
+ ne_of_mem_erase hb⟩
+ · rintro ⟨a, b, c, ha, hb, hc, hab, hac, hbc⟩
+ rw [← card_erase_add_one hc, ← card_erase_add_one (mem_erase_of_ne_of_mem hbc hb), ←
+ card_erase_add_one (mem_erase_of_ne_of_mem hab (mem_erase_of_ne_of_mem hac ha))]
+ apply Nat.le_add_left
#align finset.two_lt_card_iff Finset.two_lt_card_iff
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -143,7 +143,7 @@ theorem card_insert_of_mem (h : a ∈ s) : card (insert a s) = s.card := by rw [
#print Finset.card_insert_le /-
theorem card_insert_le (a : α) (s : Finset α) : card (insert a s) ≤ s.card + 1 := by
- by_cases a ∈ s <;> [· rw [insert_eq_of_mem h]; exact Nat.le_succ _;rw [card_insert_of_not_mem h]]
+ by_cases a ∈ s <;> [· rw [insert_eq_of_mem h]; exact Nat.le_succ _; rw [card_insert_of_not_mem h]]
#align finset.card_insert_le Finset.card_insert_le
-/
@@ -288,13 +288,13 @@ theorem card_image_of_injOn [DecidableEq β] (H : Set.InjOn f s) : (s.image f).c
#print Finset.injOn_of_card_image_eq /-
theorem injOn_of_card_image_eq [DecidableEq β] (H : (s.image f).card = s.card) : Set.InjOn f s :=
by
- change (s.1.map f).dedup.card = s.1.card at H
+ change (s.1.map f).dedup.card = s.1.card at H
have : (s.1.map f).dedup = s.1.map f :=
by
refine' Multiset.eq_of_le_of_card_le (Multiset.dedup_le _) _
rw [H]
simp only [Multiset.card_map]
- rw [Multiset.dedup_eq_self] at this
+ rw [Multiset.dedup_eq_self] at this
exact inj_on_of_nodup_map this
#align finset.inj_on_of_card_image_eq Finset.injOn_of_card_image_eq
-/
@@ -364,7 +364,7 @@ theorem map_eq_of_subset {f : α ↪ α} (hs : s.map f ⊆ s) : s.map f = s :=
theorem filter_card_eq {p : α → Prop} [DecidablePred p] (h : (s.filterₓ p).card = s.card) (x : α)
(hx : x ∈ s) : p x :=
by
- rw [← eq_of_subset_of_card_le (s.filter_subset p) h.ge, mem_filter] at hx
+ rw [← eq_of_subset_of_card_le (s.filter_subset p) h.ge, mem_filter] at hx
exact hx.2
#align finset.filter_card_eq Finset.filter_card_eq
-/
@@ -380,7 +380,7 @@ theorem card_eq_of_bijective (f : ∀ i, i < n → α) (hf : ∀ a ∈ s, ∃ i,
(hf' : ∀ (i) (h : i < n), f i h ∈ s)
(f_inj : ∀ (i j) (hi : i < n) (hj : j < n), f i hi = f j hj → i = j) : s.card = n := by
classical
- have : ∀ a : α, a ∈ s ↔ ∃ (i : _)(hi : i ∈ range n), f i (mem_range.1 hi) = a := fun a =>
+ have : ∀ a : α, a ∈ s ↔ ∃ (i : _) (hi : i ∈ range n), f i (mem_range.1 hi) = a := fun a =>
⟨fun ha =>
let ⟨i, hi, Eq⟩ := hf a ha
⟨i, mem_range.2 hi, Eq⟩,
@@ -446,7 +446,7 @@ theorem le_card_of_inj_on_range (f : ℕ → α) (hf : ∀ i < n, f i ∈ s)
(f_inj : ∀ i < n, ∀ j < n, f i = f j → i = j) : n ≤ s.card :=
calc
n = card (range n) := (card_range n).symm
- _ ≤ s.card := card_le_card_of_inj_on f (by simpa only [mem_range] ) (by simpa only [mem_range] )
+ _ ≤ s.card := card_le_card_of_inj_on f (by simpa only [mem_range]) (by simpa only [mem_range])
#align finset.le_card_of_inj_on_range Finset.le_card_of_inj_on_range
-/
@@ -466,7 +466,7 @@ theorem surj_on_of_inj_on_of_card_le {t : Finset β} (f : ∀ a ∈ s, β) (hf :
let ⟨a, ha₁, ha₂⟩ := mem_image.1 h
ha₂ ▸ hf _ _)
(by simp [hst, h])
- rw [← h'] at hb
+ rw [← h'] at hb
obtain ⟨a, ha₁, ha₂⟩ := mem_image.1 hb
exact ⟨a, a.2, ha₂.symm⟩
#align finset.surj_on_of_inj_on_of_card_le Finset.surj_on_of_inj_on_of_card_le
@@ -538,7 +538,7 @@ theorem card_disjoint_union (h : Disjoint s t) : card (s ∪ t) = s.card + t.car
#print Finset.card_sdiff /-
theorem card_sdiff (h : s ⊆ t) : card (t \ s) = t.card - s.card :=
by
- suffices card (t \ s) = card (t \ s ∪ s) - s.card by rwa [sdiff_union_of_subset h] at this
+ suffices card (t \ s) = card (t \ s ∪ s) - s.card by rwa [sdiff_union_of_subset h] at this
rw [card_disjoint_union sdiff_disjoint, add_tsub_cancel_right]
#align finset.card_sdiff Finset.card_sdiff
-/
@@ -623,7 +623,7 @@ theorem exists_subset_or_subset_of_two_mul_lt_card [DecidableEq α] {X Y : Finse
have h₁ : (X ∩ (Y \ X)).card = 0 := finset.card_eq_zero.mpr (Finset.inter_sdiff_self X Y)
have h₂ : (X ∪ Y).card = X.card + (Y \ X).card := by
rw [← card_union_add_card_inter X (Y \ X), Finset.union_sdiff_self_eq_union, h₁, add_zero]
- rw [h₂, two_mul] at hXY
+ rw [h₂, two_mul] at hXY
rcases lt_or_lt_of_add_lt_add hXY with (h | h)
· exact ⟨X, h, Or.inl (Finset.Subset.refl X)⟩
· exact ⟨Y \ X, h, Or.inr (Finset.sdiff_subset Y X)⟩
@@ -642,7 +642,7 @@ theorem card_eq_one : s.card = 1 ↔ ∃ a, s = {a} := by
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a «expr ∉ » s) -/
#print Finset.exists_eq_insert_iff /-
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
- (∃ (a : _)(_ : a ∉ s), insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card :=
+ (∃ (a : _) (_ : a ∉ s), insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card :=
by
constructor
· rintro ⟨a, ha, rfl⟩
@@ -768,7 +768,7 @@ theorem card_eq_three [DecidableEq α] :
· rw [card_eq_succ]
simp_rw [card_eq_two]
rintro ⟨a, _, abc, rfl, b, c, bc, rfl⟩
- rw [mem_insert, mem_singleton, not_or] at abc
+ rw [mem_insert, mem_singleton, not_or] at abc
exact ⟨a, b, c, abc.1, abc.2, bc, rfl⟩
· rintro ⟨x, y, z, xy, xz, yz, rfl⟩
simp only [xy, xz, yz, mem_insert, card_insert_of_not_mem, not_false_iff, mem_singleton,
@@ -789,8 +789,8 @@ def strongInduction {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s
| s =>
H s fun t h =>
have : t.card < s.card := card_lt_card h
- strong_induction t termination_by'
- ⟨_, measure_wf card⟩
+ strong_induction t
+termination_by' ⟨_, measure_wf card⟩
#align finset.strong_induction Finset.strongInduction
-/
@@ -838,8 +838,8 @@ def strongDownwardInduction {p : Finset α → Sort _} {n : ℕ}
| s =>
H s fun t ht h =>
have : n - t.card < n - s.card := (tsub_lt_tsub_iff_left_of_le ht).2 (Finset.card_lt_card h)
- strong_downward_induction t ht termination_by'
- ⟨_, measure_wf fun t : Finset α => n - t.card⟩
+ strong_downward_induction t ht
+termination_by' ⟨_, measure_wf fun t : Finset α => n - t.card⟩
#align finset.strong_downward_induction Finset.strongDownwardInduction
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -866,11 +866,13 @@ theorem strongDownwardInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
dsimp only [strong_downward_induction_on]; rw [strong_downward_induction]
#align finset.strong_downward_induction_on_eq Finset.strongDownwardInductionOn_eq
+#print Finset.lt_wf /-
theorem lt_wf {α} : WellFounded (@LT.lt (Finset α) _) :=
have H : Subrelation (@LT.lt (Finset α) _) (InvImage (· < ·) card) := fun x y hxy =>
card_lt_card hxy
Subrelation.wf H <| InvImage.wf _ <| Nat.lt_wfRel
#align finset.lt_wf Finset.lt_wf
+-/
end Finset
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -52,22 +52,10 @@ def card (s : Finset α) : ℕ :=
#align finset.card Finset.card
-/
-/- warning: finset.card_def -> Finset.card_def is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (s : Finset.{u1} α), Eq.{1} Nat (Finset.card.{u1} α s) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Finset.val.{u1} α s))
-but is expected to have type
- forall {α : Type.{u1}} (s : Finset.{u1} α), Eq.{1} Nat (Finset.card.{u1} α s) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Finset.val.{u1} α s))
-Case conversion may be inaccurate. Consider using '#align finset.card_def Finset.card_defₓ'. -/
theorem card_def (s : Finset α) : s.card = s.1.card :=
rfl
#align finset.card_def Finset.card_def
-/- warning: finset.card_mk -> Finset.card_mk is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {m : Multiset.{u1} α} {nodup : Multiset.Nodup.{u1} α m}, Eq.{1} Nat (Finset.card.{u1} α (Finset.mk.{u1} α m nodup)) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) m)
-but is expected to have type
- forall {α : Type.{u1}} {m : Multiset.{u1} α} {nodup : Multiset.Nodup.{u1} α m}, Eq.{1} Nat (Finset.card.{u1} α (Finset.mk.{u1} α m nodup)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) m)
-Case conversion may be inaccurate. Consider using '#align finset.card_mk Finset.card_mkₓ'. -/
@[simp]
theorem card_mk {m nodup} : (⟨m, nodup⟩ : Finset α).card = m.card :=
rfl
@@ -242,32 +230,14 @@ section ToListMultiset
variable [DecidableEq α] (m : Multiset α) (l : List α)
-/- warning: multiset.card_to_finset -> Multiset.card_toFinset is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (m : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m))
-but is expected to have type
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (m : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m))
-Case conversion may be inaccurate. Consider using '#align multiset.card_to_finset Multiset.card_toFinsetₓ'. -/
theorem Multiset.card_toFinset : m.toFinset.card = m.dedup.card :=
rfl
#align multiset.card_to_finset Multiset.card_toFinset
-/- warning: multiset.to_finset_card_le -> Multiset.toFinset_card_le is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (m : Multiset.{u1} α), LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) m)
-but is expected to have type
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (m : Multiset.{u1} α), LE.le.{0} Nat instLENat (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) m)
-Case conversion may be inaccurate. Consider using '#align multiset.to_finset_card_le Multiset.toFinset_card_leₓ'. -/
theorem Multiset.toFinset_card_le : m.toFinset.card ≤ m.card :=
card_le_of_le <| dedup_le _
#align multiset.to_finset_card_le Multiset.toFinset_card_le
-/- warning: multiset.to_finset_card_of_nodup -> Multiset.toFinset_card_of_nodup is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {m : Multiset.{u1} α}, (Multiset.Nodup.{u1} α m) -> (Eq.{1} Nat (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) m))
-but is expected to have type
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {m : Multiset.{u1} α}, (Multiset.Nodup.{u1} α m) -> (Eq.{1} Nat (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) m))
-Case conversion may be inaccurate. Consider using '#align multiset.to_finset_card_of_nodup Multiset.toFinset_card_of_nodupₓ'. -/
theorem Multiset.toFinset_card_of_nodup {m : Multiset α} (h : m.Nodup) : m.toFinset.card = m.card :=
congr_arg card <| Multiset.dedup_eq_self.mpr h
#align multiset.to_finset_card_of_nodup Multiset.toFinset_card_of_nodup
@@ -342,23 +312,11 @@ theorem card_image_of_injective [DecidableEq β] (s : Finset α) (H : Injective
#align finset.card_image_of_injective Finset.card_image_of_injective
-/
-/- warning: finset.fiber_card_ne_zero_iff_mem_image -> Finset.fiber_card_ne_zero_iff_mem_image is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} (s : Finset.{u1} α) (f : α -> β) [_inst_1 : DecidableEq.{succ u2} β] (y : β), Iff (Ne.{1} Nat (Finset.card.{u1} α (Finset.filter.{u1} α (fun (x : α) => Eq.{succ u2} β (f x) y) (fun (a : α) => _inst_1 (f a) y) s)) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) y (Finset.image.{u1, u2} α β (fun (a : β) (b : β) => _inst_1 a b) f s))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} (s : Finset.{u2} α) (f : α -> β) [_inst_1 : DecidableEq.{succ u1} β] (y : β), Iff (Ne.{1} Nat (Finset.card.{u2} α (Finset.filter.{u2} α (fun (x : α) => Eq.{succ u1} β (f x) y) (fun (a : α) => _inst_1 (f a) y) s)) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) (Membership.mem.{u1, u1} β (Finset.{u1} β) (Finset.instMembershipFinset.{u1} β) y (Finset.image.{u2, u1} α β (fun (a : β) (b : β) => _inst_1 a b) f s))
-Case conversion may be inaccurate. Consider using '#align finset.fiber_card_ne_zero_iff_mem_image Finset.fiber_card_ne_zero_iff_mem_imageₓ'. -/
theorem fiber_card_ne_zero_iff_mem_image (s : Finset α) (f : α → β) [DecidableEq β] (y : β) :
(s.filterₓ fun x => f x = y).card ≠ 0 ↔ y ∈ s.image f := by
rw [← pos_iff_ne_zero, card_pos, fiber_nonempty_iff_mem_image]
#align finset.fiber_card_ne_zero_iff_mem_image Finset.fiber_card_ne_zero_iff_mem_image
-/- warning: finset.card_map -> Finset.card_map is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} (f : Function.Embedding.{succ u1, succ u2} α β), Eq.{1} Nat (Finset.card.{u2} β (Finset.map.{u1, u2} α β f s)) (Finset.card.{u1} α s)
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} {s : Finset.{u2} α} (f : Function.Embedding.{succ u2, succ u1} α β), Eq.{1} Nat (Finset.card.{u1} β (Finset.map.{u2, u1} α β f s)) (Finset.card.{u2} α s)
-Case conversion may be inaccurate. Consider using '#align finset.card_map Finset.card_mapₓ'. -/
@[simp]
theorem card_map (f : α ↪ β) : (s.map f).card = s.card :=
Multiset.card_map _ _
@@ -471,12 +429,6 @@ theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s
#align finset.card_le_card_of_inj_on Finset.card_le_card_of_inj_on
-/
-/- warning: finset.exists_ne_map_eq_of_card_lt_of_maps_to -> Finset.exists_ne_map_eq_of_card_lt_of_maps_to is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β}, (LT.lt.{0} Nat Nat.hasLt (Finset.card.{u2} β t) (Finset.card.{u1} α s)) -> (forall {f : α -> β}, (forall (a : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) -> (Membership.Mem.{u2, u2} β (Finset.{u2} β) (Finset.hasMem.{u2} β) (f a) t)) -> (Exists.{succ u1} α (fun (x : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) x s) (fun (H : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) x s) => Exists.{succ u1} α (fun (y : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) y s) (fun (H : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) y s) => And (Ne.{succ u1} α x y) (Eq.{succ u2} β (f x) (f y))))))))
-but is expected to have type
- forall {α : Type.{u1}} {β : Type.{u2}} {s : Finset.{u1} α} {t : Finset.{u2} β}, (LT.lt.{0} Nat instLTNat (Finset.card.{u2} β t) (Finset.card.{u1} α s)) -> (forall {f : α -> β}, (forall (a : α), (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) a s) -> (Membership.mem.{u2, u2} β (Finset.{u2} β) (Finset.instMembershipFinset.{u2} β) (f a) t)) -> (Exists.{succ u1} α (fun (x : α) => And (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) x s) (Exists.{succ u1} α (fun (y : α) => And (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) y s) (And (Ne.{succ u1} α x y) (Eq.{succ u2} β (f x) (f y))))))))
-Case conversion may be inaccurate. Consider using '#align finset.exists_ne_map_eq_of_card_lt_of_maps_to Finset.exists_ne_map_eq_of_card_lt_of_maps_toₓ'. -/
/-- If there are more pigeons than pigeonholes, then there are two pigeons in the same pigeonhole.
-/
theorem exists_ne_map_eq_of_card_lt_of_maps_to {t : Finset β} (hc : t.card < s.card) {f : α → β}
@@ -543,12 +495,6 @@ theorem inj_on_of_surj_on_of_card_le {t : Finset β} (f : ∀ a ∈ s, β) (hf :
#align finset.inj_on_of_surj_on_of_card_le Finset.inj_on_of_surj_on_of_card_le
-/
-/- warning: finset.card_disj_union -> Finset.card_disjUnion is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (s : Finset.{u1} α) (t : Finset.{u1} α) (h : Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.orderBot.{u1} α) s t), Eq.{1} Nat (Finset.card.{u1} α (Finset.disjUnion.{u1} α s t h)) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Finset.card.{u1} α s) (Finset.card.{u1} α t))
-but is expected to have type
- forall {α : Type.{u1}} (s : Finset.{u1} α) (t : Finset.{u1} α) (h : Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} α) s t), Eq.{1} Nat (Finset.card.{u1} α (Finset.disjUnion.{u1} α s t h)) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Finset.card.{u1} α s) (Finset.card.{u1} α t))
-Case conversion may be inaccurate. Consider using '#align finset.card_disj_union Finset.card_disjUnionₓ'. -/
@[simp]
theorem card_disjUnion (s t : Finset α) (h) : (s.disjUnion t h).card = s.card + t.card :=
Multiset.card_add _ _
@@ -580,22 +526,10 @@ theorem card_union_le (s t : Finset α) : (s ∪ t).card ≤ s.card + t.card :=
#align finset.card_union_le Finset.card_union_le
-/
-/- warning: finset.card_union_eq -> Finset.card_union_eq is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {s : Finset.{u1} α} {t : Finset.{u1} α} [_inst_1 : DecidableEq.{succ u1} α], (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.orderBot.{u1} α) s t) -> (Eq.{1} Nat (Finset.card.{u1} α (Union.union.{u1} (Finset.{u1} α) (Finset.hasUnion.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s t)) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Finset.card.{u1} α s) (Finset.card.{u1} α t)))
-but is expected to have type
- forall {α : Type.{u1}} {s : Finset.{u1} α} {t : Finset.{u1} α} [_inst_1 : DecidableEq.{succ u1} α], (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} α) s t) -> (Eq.{1} Nat (Finset.card.{u1} α (Union.union.{u1} (Finset.{u1} α) (Finset.instUnionFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s t)) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Finset.card.{u1} α s) (Finset.card.{u1} α t)))
-Case conversion may be inaccurate. Consider using '#align finset.card_union_eq Finset.card_union_eqₓ'. -/
theorem card_union_eq (h : Disjoint s t) : (s ∪ t).card = s.card + t.card := by
rw [← disj_union_eq_union s t h, card_disj_union _ _ _]
#align finset.card_union_eq Finset.card_union_eq
-/- warning: finset.card_disjoint_union -> Finset.card_disjoint_union is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {s : Finset.{u1} α} {t : Finset.{u1} α} [_inst_1 : DecidableEq.{succ u1} α], (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.orderBot.{u1} α) s t) -> (Eq.{1} Nat (Finset.card.{u1} α (Union.union.{u1} (Finset.{u1} α) (Finset.hasUnion.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s t)) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Finset.card.{u1} α s) (Finset.card.{u1} α t)))
-but is expected to have type
- forall {α : Type.{u1}} {s : Finset.{u1} α} {t : Finset.{u1} α} [_inst_1 : DecidableEq.{succ u1} α], (Disjoint.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α) (Finset.instOrderBotFinsetToLEToPreorderPartialOrder.{u1} α) s t) -> (Eq.{1} Nat (Finset.card.{u1} α (Union.union.{u1} (Finset.{u1} α) (Finset.instUnionFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b)) s t)) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Finset.card.{u1} α s) (Finset.card.{u1} α t)))
-Case conversion may be inaccurate. Consider using '#align finset.card_disjoint_union Finset.card_disjoint_unionₓ'. -/
@[simp]
theorem card_disjoint_union (h : Disjoint s t) : card (s ∪ t) = s.card + t.card :=
card_union_eq h
@@ -640,12 +574,6 @@ theorem card_sdiff_add_card : (s \ t).card + t.card = (s ∪ t).card := by
end Lattice
-/- warning: finset.filter_card_add_filter_neg_card_eq_card -> Finset.filter_card_add_filter_neg_card_eq_card is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {s : Finset.{u1} α} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p], Eq.{1} Nat (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Finset.card.{u1} α (Finset.filter.{u1} α p (fun (a : α) => _inst_1 a) s)) (Finset.card.{u1} α (Finset.filter.{u1} α (Function.comp.{succ u1, 1, 1} α Prop Prop Not p) (fun (a : α) => Not.decidable (p a) (_inst_1 a)) s))) (Finset.card.{u1} α s)
-but is expected to have type
- forall {α : Type.{u1}} {s : Finset.{u1} α} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] [inst._@.Mathlib.Data.Finset.Card._hyg.4896 : forall (x : α), Decidable (Not (p x))], Eq.{1} Nat (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Finset.card.{u1} α (Finset.filter.{u1} α p (fun (a : α) => _inst_1 a) s)) (Finset.card.{u1} α (Finset.filter.{u1} α (fun (a : α) => Not (p a)) (fun (a : α) => inst._@.Mathlib.Data.Finset.Card._hyg.4896 a) s))) (Finset.card.{u1} α s)
-Case conversion may be inaccurate. Consider using '#align finset.filter_card_add_filter_neg_card_eq_card Finset.filter_card_add_filter_neg_card_eq_cardₓ'. -/
theorem filter_card_add_filter_neg_card_eq_card (p : α → Prop) [DecidablePred p] :
(s.filterₓ p).card + (s.filterₓ (Not ∘ p)).card = s.card := by
classical simp [← card_union_eq, filter_union_filter_neg_eq, disjoint_filter]
@@ -767,12 +695,6 @@ theorem card_le_one_of_subsingleton [Subsingleton α] (s : Finset α) : s.card
#align finset.card_le_one_of_subsingleton Finset.card_le_one_of_subsingleton
-/
-/- warning: finset.one_lt_card -> Finset.one_lt_card is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {s : Finset.{u1} α}, Iff (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne))) (Finset.card.{u1} α s)) (Exists.{succ u1} α (fun (a : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) (fun (H : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) => Exists.{succ u1} α (fun (b : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) b s) (fun (H : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) b s) => Ne.{succ u1} α a b)))))
-but is expected to have type
- forall {α : Type.{u1}} {s : Finset.{u1} α}, Iff (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) (Finset.card.{u1} α s)) (Exists.{succ u1} α (fun (a : α) => And (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) a s) (Exists.{succ u1} α (fun (b : α) => And (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) b s) (Ne.{succ u1} α a b)))))
-Case conversion may be inaccurate. Consider using '#align finset.one_lt_card Finset.one_lt_cardₓ'. -/
theorem one_lt_card : 1 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, a ≠ b := by rw [← not_iff_not]; push_neg;
exact card_le_one
#align finset.one_lt_card Finset.one_lt_card
@@ -800,12 +722,6 @@ theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c
#align finset.two_lt_card_iff Finset.two_lt_card_iff
-/
-/- warning: finset.two_lt_card -> Finset.two_lt_card is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {s : Finset.{u1} α}, Iff (LT.lt.{0} Nat Nat.hasLt (OfNat.ofNat.{0} Nat 2 (OfNat.mk.{0} Nat 2 (bit0.{0} Nat Nat.hasAdd (One.one.{0} Nat Nat.hasOne)))) (Finset.card.{u1} α s)) (Exists.{succ u1} α (fun (a : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) (fun (H : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) a s) => Exists.{succ u1} α (fun (b : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) b s) (fun (H : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) b s) => Exists.{succ u1} α (fun (c : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) c s) (fun (H : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) c s) => And (Ne.{succ u1} α a b) (And (Ne.{succ u1} α a c) (Ne.{succ u1} α b c)))))))))
-but is expected to have type
- forall {α : Type.{u1}} {s : Finset.{u1} α}, Iff (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 2 (instOfNatNat 2)) (Finset.card.{u1} α s)) (Exists.{succ u1} α (fun (a : α) => And (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) a s) (Exists.{succ u1} α (fun (b : α) => And (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) b s) (Exists.{succ u1} α (fun (c : α) => And (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) c s) (And (Ne.{succ u1} α a b) (And (Ne.{succ u1} α a c) (Ne.{succ u1} α b c)))))))))
-Case conversion may be inaccurate. Consider using '#align finset.two_lt_card Finset.two_lt_cardₓ'. -/
theorem two_lt_card : 2 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, ∃ c ∈ s, a ≠ b ∧ a ≠ c ∧ b ≠ c := by
simp_rw [two_lt_card_iff, exists_prop, exists_and_left]
#align finset.two_lt_card Finset.two_lt_card
@@ -878,12 +794,6 @@ def strongInduction {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s
#align finset.strong_induction Finset.strongInduction
-/
-/- warning: finset.strong_induction_eq -> Finset.strongInduction_eq is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {p : (Finset.{u1} α) -> Sort.{u2}} (H : forall (s : Finset.{u1} α), (forall (t : Finset.{u1} α), (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) t s) -> (p t)) -> (p s)) (s : Finset.{u1} α), Eq.{u2} (p s) (Finset.strongInduction.{u1, u2} α (fun (t : Finset.{u1} α) => p t) H s) (H s (fun (t : Finset.{u1} α) (h : HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) t s) => Finset.strongInduction.{u1, u2} α p H t))
-but is expected to have type
- forall {α : Type.{u2}} {p : (Finset.{u2} α) -> Sort.{u1}} (H : forall (s : Finset.{u2} α), (forall (t : Finset.{u2} α), (HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t s) -> (p t)) -> (p s)) (s : Finset.{u2} α), Eq.{u1} (p s) (Finset.strongInduction.{u2, u1} α (fun (t : Finset.{u2} α) => p t) H s) (H s (fun (t : Finset.{u2} α) (h : HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t s) => Finset.strongInduction.{u2, u1} α (fun (t : Finset.{u2} α) => p t) H t))
-Case conversion may be inaccurate. Consider using '#align finset.strong_induction_eq Finset.strongInduction_eqₓ'. -/
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊂ » s) -/
theorem strongInduction_eq {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s)
(s : Finset α) : strongInduction H s = H s fun t h => strongInduction H t := by
@@ -899,12 +809,6 @@ def strongInductionOn {p : Finset α → Sort _} (s : Finset α) :
#align finset.strong_induction_on Finset.strongInductionOn
-/
-/- warning: finset.strong_induction_on_eq -> Finset.strongInductionOn_eq is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {p : (Finset.{u1} α) -> Sort.{u2}} (s : Finset.{u1} α) (H : forall (s : Finset.{u1} α), (forall (t : Finset.{u1} α), (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) t s) -> (p t)) -> (p s)), Eq.{u2} (p s) (Finset.strongInductionOn.{u1, u2} α (fun (t : Finset.{u1} α) => p t) s H) (H s (fun (t : Finset.{u1} α) (h : HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) t s) => Finset.strongInductionOn.{u1, u2} α (fun (t : Finset.{u1} α) => p t) t H))
-but is expected to have type
- forall {α : Type.{u2}} {p : (Finset.{u2} α) -> Sort.{u1}} (s : Finset.{u2} α) (H : forall (s : Finset.{u2} α), (forall (t : Finset.{u2} α), (HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t s) -> (p t)) -> (p s)), Eq.{u1} (p s) (Finset.strongInductionOn.{u2, u1} α (fun (t : Finset.{u2} α) => p t) s H) (H s (fun (t : Finset.{u2} α) (h : HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t s) => Finset.strongInductionOn.{u2, u1} α (fun (t : Finset.{u2} α) => p t) t H))
-Case conversion may be inaccurate. Consider using '#align finset.strong_induction_on_eq Finset.strongInductionOn_eqₓ'. -/
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊂ » s) -/
theorem strongInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) :
@@ -939,12 +843,6 @@ def strongDownwardInduction {p : Finset α → Sort _} {n : ℕ}
#align finset.strong_downward_induction Finset.strongDownwardInduction
-/
-/- warning: finset.strong_downward_induction_eq -> Finset.strongDownwardInduction_eq is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {n : Nat} {p : (Finset.{u1} α) -> Sort.{u2}} (H : forall (t₁ : Finset.{u1} α), (forall {t₂ : Finset.{u1} α}, (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α t₂) n) -> (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) t₁ t₂) -> (p t₂)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α t₁) n) -> (p t₁)) (s : Finset.{u1} α), Eq.{u2} ((LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α s) n) -> (p s)) (Finset.strongDownwardInduction.{u1, u2} α (fun (t₂ : Finset.{u1} α) => p t₂) n H s) (H s (fun (t : Finset.{u1} α) (ht : LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α t) n) (hst : HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) s t) => Finset.strongDownwardInduction.{u1, u2} α p n H t ht))
-but is expected to have type
- forall {α : Type.{u2}} {n : Nat} {p : (Finset.{u2} α) -> Sort.{u1}} (H : forall (t₁ : Finset.{u2} α), (forall {t₂ : Finset.{u2} α}, (LE.le.{0} Nat instLENat (Finset.card.{u2} α t₂) n) -> (HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t₁ t₂) -> (p t₂)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} α t₁) n) -> (p t₁)) (s : Finset.{u2} α), Eq.{u1} ((LE.le.{0} Nat instLENat (Finset.card.{u2} α s) n) -> (p s)) (Finset.strongDownwardInduction.{u2, u1} α (fun (t₂ : Finset.{u2} α) => p t₂) n H s) (H s (fun {t : Finset.{u2} α} (ht : LE.le.{0} Nat instLENat (Finset.card.{u2} α t) n) (hst : HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) s t) => Finset.strongDownwardInduction.{u2, u1} α (fun (t₂ : Finset.{u2} α) => p t₂) n H t ht))
-Case conversion may be inaccurate. Consider using '#align finset.strong_downward_induction_eq Finset.strongDownwardInduction_eqₓ'. -/
theorem strongDownwardInduction_eq {p : Finset α → Sort _}
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁)
(s : Finset α) :
@@ -962,24 +860,12 @@ def strongDownwardInductionOn {p : Finset α → Sort _} (s : Finset α)
#align finset.strong_downward_induction_on Finset.strongDownwardInductionOn
-/
-/- warning: finset.strong_downward_induction_on_eq -> Finset.strongDownwardInductionOn_eq is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {n : Nat} {p : (Finset.{u1} α) -> Sort.{u2}} (s : Finset.{u1} α) (H : forall (t₁ : Finset.{u1} α), (forall {t₂ : Finset.{u1} α}, (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α t₂) n) -> (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) t₁ t₂) -> (p t₂)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α t₁) n) -> (p t₁)), Eq.{u2} ((LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α s) n) -> (p s)) (Finset.strongDownwardInductionOn.{u1, u2} α n (fun (t₂ : Finset.{u1} α) => p t₂) s H) (H s (fun (t : Finset.{u1} α) (ht : LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α t) n) (h : HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) s t) => Finset.strongDownwardInductionOn.{u1, u2} α n (fun (t₂ : Finset.{u1} α) => p t₂) t H ht))
-but is expected to have type
- forall {α : Type.{u2}} {n : Nat} {p : (Finset.{u2} α) -> Sort.{u1}} (s : Finset.{u2} α) (H : forall (t₁ : Finset.{u2} α), (forall {t₂ : Finset.{u2} α}, (LE.le.{0} Nat instLENat (Finset.card.{u2} α t₂) n) -> (HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t₁ t₂) -> (p t₂)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} α t₁) n) -> (p t₁)), Eq.{u1} ((LE.le.{0} Nat instLENat (Finset.card.{u2} α s) n) -> (p s)) (fun (a._@.Mathlib.Data.Finset.Card._hyg.8672 : LE.le.{0} Nat instLENat (Finset.card.{u2} α s) n) => Finset.strongDownwardInductionOn.{u2, u1} α n (fun (x._@.Mathlib.Data.Finset.Card._hyg.8773 : Finset.{u2} α) => p x._@.Mathlib.Data.Finset.Card._hyg.8773) s H a._@.Mathlib.Data.Finset.Card._hyg.8672) (H s (fun {t : Finset.{u2} α} (ht : LE.le.{0} Nat instLENat (Finset.card.{u2} α t) n) (h : HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) s t) => Finset.strongDownwardInductionOn.{u2, u1} α n (fun (t₂ : Finset.{u2} α) => p t₂) t H ht))
-Case conversion may be inaccurate. Consider using '#align finset.strong_downward_induction_on_eq Finset.strongDownwardInductionOn_eqₓ'. -/
theorem strongDownwardInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
s.strongDownwardInductionOn H = H s fun t ht h => t.strongDownwardInductionOn H ht := by
dsimp only [strong_downward_induction_on]; rw [strong_downward_induction]
#align finset.strong_downward_induction_on_eq Finset.strongDownwardInductionOn_eq
-/- warning: finset.lt_wf -> Finset.lt_wf is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}}, WellFounded.{succ u1} (Finset.{u1} α) (LT.lt.{u1} (Finset.{u1} α) (Preorder.toHasLt.{u1} (Finset.{u1} α) (PartialOrder.toPreorder.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α))))
-but is expected to have type
- forall {α : Type.{u1}}, WellFounded.{succ u1} (Finset.{u1} α) (LT.lt.{u1} (Finset.{u1} α) (Preorder.toLT.{u1} (Finset.{u1} α) (PartialOrder.toPreorder.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α))))
-Case conversion may be inaccurate. Consider using '#align finset.lt_wf Finset.lt_wfₓ'. -/
theorem lt_wf {α} : WellFounded (@LT.lt (Finset α) _) :=
have H : Subrelation (@LT.lt (Finset α) _) (InvImage (· < ·) card) := fun x y hxy =>
card_lt_card hxy
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -155,10 +155,7 @@ theorem card_insert_of_mem (h : a ∈ s) : card (insert a s) = s.card := by rw [
#print Finset.card_insert_le /-
theorem card_insert_le (a : α) (s : Finset α) : card (insert a s) ≤ s.card + 1 := by
- by_cases a ∈ s <;>
- [·
- rw [insert_eq_of_mem h]
- exact Nat.le_succ _;rw [card_insert_of_not_mem h]]
+ by_cases a ∈ s <;> [· rw [insert_eq_of_mem h]; exact Nat.le_succ _;rw [card_insert_of_not_mem h]]
#align finset.card_insert_le Finset.card_insert_le
-/
@@ -301,10 +298,8 @@ variable {s t : Finset α} {f : α → β} {n : ℕ}
#print Finset.length_toList /-
@[simp]
-theorem length_toList (s : Finset α) : s.toList.length = s.card :=
- by
- rw [to_list, ← Multiset.coe_card, Multiset.coe_toList]
- rfl
+theorem length_toList (s : Finset α) : s.toList.length = s.card := by
+ rw [to_list, ← Multiset.coe_card, Multiset.coe_toList]; rfl
#align finset.length_to_list Finset.length_toList
-/
@@ -748,10 +743,7 @@ theorem card_le_one : s.card ≤ 1 ↔ ∀ a ∈ s, ∀ b ∈ s, a = b :=
-/
#print Finset.card_le_one_iff /-
-theorem card_le_one_iff : s.card ≤ 1 ↔ ∀ {a b}, a ∈ s → b ∈ s → a = b :=
- by
- rw [card_le_one]
- tauto
+theorem card_le_one_iff : s.card ≤ 1 ↔ ∀ {a b}, a ∈ s → b ∈ s → a = b := by rw [card_le_one]; tauto
#align finset.card_le_one_iff Finset.card_le_one_iff
-/
@@ -781,17 +773,12 @@ lean 3 declaration is
but is expected to have type
forall {α : Type.{u1}} {s : Finset.{u1} α}, Iff (LT.lt.{0} Nat instLTNat (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1)) (Finset.card.{u1} α s)) (Exists.{succ u1} α (fun (a : α) => And (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) a s) (Exists.{succ u1} α (fun (b : α) => And (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) b s) (Ne.{succ u1} α a b)))))
Case conversion may be inaccurate. Consider using '#align finset.one_lt_card Finset.one_lt_cardₓ'. -/
-theorem one_lt_card : 1 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, a ≠ b :=
- by
- rw [← not_iff_not]
- push_neg
+theorem one_lt_card : 1 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, a ≠ b := by rw [← not_iff_not]; push_neg;
exact card_le_one
#align finset.one_lt_card Finset.one_lt_card
#print Finset.one_lt_card_iff /-
-theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b :=
- by
- rw [one_lt_card]
+theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b := by rw [one_lt_card];
simp only [exists_prop, exists_and_left]
#align finset.one_lt_card_iff Finset.one_lt_card_iff
-/
@@ -921,10 +908,8 @@ Case conversion may be inaccurate. Consider using '#align finset.strong_inductio
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊂ » s) -/
theorem strongInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) :
- s.strong_induction_on H = H s fun t h => t.strong_induction_on H :=
- by
- dsimp only [strong_induction_on]
- rw [strong_induction]
+ s.strong_induction_on H = H s fun t h => t.strong_induction_on H := by
+ dsimp only [strong_induction_on]; rw [strong_induction]
#align finset.strong_induction_on_eq Finset.strongInductionOn_eq
/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (t «expr ⊆ » s) -/
@@ -985,10 +970,8 @@ but is expected to have type
Case conversion may be inaccurate. Consider using '#align finset.strong_downward_induction_on_eq Finset.strongDownwardInductionOn_eqₓ'. -/
theorem strongDownwardInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
- s.strongDownwardInductionOn H = H s fun t ht h => t.strongDownwardInductionOn H ht :=
- by
- dsimp only [strong_downward_induction_on]
- rw [strong_downward_induction]
+ s.strongDownwardInductionOn H = H s fun t ht h => t.strongDownwardInductionOn H ht := by
+ dsimp only [strong_downward_induction_on]; rw [strong_downward_induction]
#align finset.strong_downward_induction_on_eq Finset.strongDownwardInductionOn_eq
/- warning: finset.lt_wf -> Finset.lt_wf is a dubious translation:
mathlib commit https://github.com/leanprover-community/mathlib/commit/8d33f09cd7089ecf074b4791907588245aec5d1b
@@ -158,7 +158,7 @@ theorem card_insert_le (a : α) (s : Finset α) : card (insert a s) ≤ s.card +
by_cases a ∈ s <;>
[·
rw [insert_eq_of_mem h]
- exact Nat.le_succ _, rw [card_insert_of_not_mem h]]
+ exact Nat.le_succ _;rw [card_insert_of_not_mem h]]
#align finset.card_insert_le Finset.card_insert_le
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8
@@ -991,13 +991,17 @@ theorem strongDownwardInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
rw [strong_downward_induction]
#align finset.strong_downward_induction_on_eq Finset.strongDownwardInductionOn_eq
-#print Finset.lt_wf /-
+/- warning: finset.lt_wf -> Finset.lt_wf is a dubious translation:
+lean 3 declaration is
+ forall {α : Type.{u1}}, WellFounded.{succ u1} (Finset.{u1} α) (LT.lt.{u1} (Finset.{u1} α) (Preorder.toHasLt.{u1} (Finset.{u1} α) (PartialOrder.toPreorder.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α))))
+but is expected to have type
+ forall {α : Type.{u1}}, WellFounded.{succ u1} (Finset.{u1} α) (LT.lt.{u1} (Finset.{u1} α) (Preorder.toLT.{u1} (Finset.{u1} α) (PartialOrder.toPreorder.{u1} (Finset.{u1} α) (Finset.partialOrder.{u1} α))))
+Case conversion may be inaccurate. Consider using '#align finset.lt_wf Finset.lt_wfₓ'. -/
theorem lt_wf {α} : WellFounded (@LT.lt (Finset α) _) :=
have H : Subrelation (@LT.lt (Finset α) _) (InvImage (· < ·) card) := fun x y hxy =>
card_lt_card hxy
Subrelation.wf H <| InvImage.wf _ <| Nat.lt_wfRel
#align finset.lt_wf Finset.lt_wf
--/
end Finset
mathlib commit https://github.com/leanprover-community/mathlib/commit/36b8aa61ea7c05727161f96a0532897bd72aedab
@@ -981,7 +981,7 @@ def strongDownwardInductionOn {p : Finset α → Sort _} (s : Finset α)
lean 3 declaration is
forall {α : Type.{u1}} {n : Nat} {p : (Finset.{u1} α) -> Sort.{u2}} (s : Finset.{u1} α) (H : forall (t₁ : Finset.{u1} α), (forall {t₂ : Finset.{u1} α}, (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α t₂) n) -> (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) t₁ t₂) -> (p t₂)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α t₁) n) -> (p t₁)), Eq.{u2} ((LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α s) n) -> (p s)) (Finset.strongDownwardInductionOn.{u1, u2} α n (fun (t₂ : Finset.{u1} α) => p t₂) s H) (H s (fun (t : Finset.{u1} α) (ht : LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α t) n) (h : HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) s t) => Finset.strongDownwardInductionOn.{u1, u2} α n (fun (t₂ : Finset.{u1} α) => p t₂) t H ht))
but is expected to have type
- forall {α : Type.{u2}} {n : Nat} {p : (Finset.{u2} α) -> Sort.{u1}} (s : Finset.{u2} α) (H : forall (t₁ : Finset.{u2} α), (forall {t₂ : Finset.{u2} α}, (LE.le.{0} Nat instLENat (Finset.card.{u2} α t₂) n) -> (HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t₁ t₂) -> (p t₂)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} α t₁) n) -> (p t₁)), Eq.{u1} ((LE.le.{0} Nat instLENat (Finset.card.{u2} α s) n) -> (p s)) (fun (a._@.Mathlib.Data.Finset.Card._hyg.8679 : LE.le.{0} Nat instLENat (Finset.card.{u2} α s) n) => Finset.strongDownwardInductionOn.{u2, u1} α n (fun (x._@.Mathlib.Data.Finset.Card._hyg.8780 : Finset.{u2} α) => p x._@.Mathlib.Data.Finset.Card._hyg.8780) s H a._@.Mathlib.Data.Finset.Card._hyg.8679) (H s (fun {t : Finset.{u2} α} (ht : LE.le.{0} Nat instLENat (Finset.card.{u2} α t) n) (h : HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) s t) => Finset.strongDownwardInductionOn.{u2, u1} α n (fun (t₂ : Finset.{u2} α) => p t₂) t H ht))
+ forall {α : Type.{u2}} {n : Nat} {p : (Finset.{u2} α) -> Sort.{u1}} (s : Finset.{u2} α) (H : forall (t₁ : Finset.{u2} α), (forall {t₂ : Finset.{u2} α}, (LE.le.{0} Nat instLENat (Finset.card.{u2} α t₂) n) -> (HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t₁ t₂) -> (p t₂)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} α t₁) n) -> (p t₁)), Eq.{u1} ((LE.le.{0} Nat instLENat (Finset.card.{u2} α s) n) -> (p s)) (fun (a._@.Mathlib.Data.Finset.Card._hyg.8672 : LE.le.{0} Nat instLENat (Finset.card.{u2} α s) n) => Finset.strongDownwardInductionOn.{u2, u1} α n (fun (x._@.Mathlib.Data.Finset.Card._hyg.8773 : Finset.{u2} α) => p x._@.Mathlib.Data.Finset.Card._hyg.8773) s H a._@.Mathlib.Data.Finset.Card._hyg.8672) (H s (fun {t : Finset.{u2} α} (ht : LE.le.{0} Nat instLENat (Finset.card.{u2} α t) n) (h : HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) s t) => Finset.strongDownwardInductionOn.{u2, u1} α n (fun (t₂ : Finset.{u2} α) => p t₂) t H ht))
Case conversion may be inaccurate. Consider using '#align finset.strong_downward_induction_on_eq Finset.strongDownwardInductionOn_eqₓ'. -/
theorem strongDownwardInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
mathlib commit https://github.com/leanprover-community/mathlib/commit/3180fab693e2cee3bff62675571264cb8778b212
@@ -56,7 +56,7 @@ def card (s : Finset α) : ℕ :=
lean 3 declaration is
forall {α : Type.{u1}} (s : Finset.{u1} α), Eq.{1} Nat (Finset.card.{u1} α s) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Finset.val.{u1} α s))
but is expected to have type
- forall {α : Type.{u1}} (s : Finset.{u1} α), Eq.{1} Nat (Finset.card.{u1} α s) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.398 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Finset.val.{u1} α s))
+ forall {α : Type.{u1}} (s : Finset.{u1} α), Eq.{1} Nat (Finset.card.{u1} α s) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Finset.val.{u1} α s))
Case conversion may be inaccurate. Consider using '#align finset.card_def Finset.card_defₓ'. -/
theorem card_def (s : Finset α) : s.card = s.1.card :=
rfl
@@ -66,7 +66,7 @@ theorem card_def (s : Finset α) : s.card = s.1.card :=
lean 3 declaration is
forall {α : Type.{u1}} {m : Multiset.{u1} α} {nodup : Multiset.Nodup.{u1} α m}, Eq.{1} Nat (Finset.card.{u1} α (Finset.mk.{u1} α m nodup)) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) m)
but is expected to have type
- forall {α : Type.{u1}} {m : Multiset.{u1} α} {nodup : Multiset.Nodup.{u1} α m}, Eq.{1} Nat (Finset.card.{u1} α (Finset.mk.{u1} α m nodup)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.398 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) m)
+ forall {α : Type.{u1}} {m : Multiset.{u1} α} {nodup : Multiset.Nodup.{u1} α m}, Eq.{1} Nat (Finset.card.{u1} α (Finset.mk.{u1} α m nodup)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) m)
Case conversion may be inaccurate. Consider using '#align finset.card_mk Finset.card_mkₓ'. -/
@[simp]
theorem card_mk {m nodup} : (⟨m, nodup⟩ : Finset α).card = m.card :=
@@ -249,7 +249,7 @@ variable [DecidableEq α] (m : Multiset α) (l : List α)
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (m : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m))
but is expected to have type
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (m : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.398 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m))
+ forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (m : Multiset.{u1} α), Eq.{1} Nat (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Multiset.dedup.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m))
Case conversion may be inaccurate. Consider using '#align multiset.card_to_finset Multiset.card_toFinsetₓ'. -/
theorem Multiset.card_toFinset : m.toFinset.card = m.dedup.card :=
rfl
@@ -259,7 +259,7 @@ theorem Multiset.card_toFinset : m.toFinset.card = m.dedup.card :=
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (m : Multiset.{u1} α), LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) m)
but is expected to have type
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (m : Multiset.{u1} α), LE.le.{0} Nat instLENat (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.398 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) m)
+ forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (m : Multiset.{u1} α), LE.le.{0} Nat instLENat (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) m)
Case conversion may be inaccurate. Consider using '#align multiset.to_finset_card_le Multiset.toFinset_card_leₓ'. -/
theorem Multiset.toFinset_card_le : m.toFinset.card ≤ m.card :=
card_le_of_le <| dedup_le _
@@ -269,7 +269,7 @@ theorem Multiset.toFinset_card_le : m.toFinset.card ≤ m.card :=
lean 3 declaration is
forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {m : Multiset.{u1} α}, (Multiset.Nodup.{u1} α m) -> (Eq.{1} Nat (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) m))
but is expected to have type
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {m : Multiset.{u1} α}, (Multiset.Nodup.{u1} α m) -> (Eq.{1} Nat (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.398 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) m))
+ forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] {m : Multiset.{u1} α}, (Multiset.Nodup.{u1} α m) -> (Eq.{1} Nat (Finset.card.{u1} α (Multiset.toFinset.{u1} α (fun (a : α) (b : α) => _inst_1 a b) m)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) m))
Case conversion may be inaccurate. Consider using '#align multiset.to_finset_card_of_nodup Multiset.toFinset_card_of_nodupₓ'. -/
theorem Multiset.toFinset_card_of_nodup {m : Multiset α} (h : m.Nodup) : m.toFinset.card = m.card :=
congr_arg card <| Multiset.dedup_eq_self.mpr h
@@ -649,7 +649,7 @@ end Lattice
lean 3 declaration is
forall {α : Type.{u1}} {s : Finset.{u1} α} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p], Eq.{1} Nat (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Finset.card.{u1} α (Finset.filter.{u1} α p (fun (a : α) => _inst_1 a) s)) (Finset.card.{u1} α (Finset.filter.{u1} α (Function.comp.{succ u1, 1, 1} α Prop Prop Not p) (fun (a : α) => Not.decidable (p a) (_inst_1 a)) s))) (Finset.card.{u1} α s)
but is expected to have type
- forall {α : Type.{u1}} {s : Finset.{u1} α} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] [inst._@.Mathlib.Data.Finset.Card._hyg.4889 : forall (x : α), Decidable (Not (p x))], Eq.{1} Nat (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Finset.card.{u1} α (Finset.filter.{u1} α p (fun (a : α) => _inst_1 a) s)) (Finset.card.{u1} α (Finset.filter.{u1} α (fun (a : α) => Not (p a)) (fun (a : α) => inst._@.Mathlib.Data.Finset.Card._hyg.4889 a) s))) (Finset.card.{u1} α s)
+ forall {α : Type.{u1}} {s : Finset.{u1} α} (p : α -> Prop) [_inst_1 : DecidablePred.{succ u1} α p] [inst._@.Mathlib.Data.Finset.Card._hyg.4896 : forall (x : α), Decidable (Not (p x))], Eq.{1} Nat (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Finset.card.{u1} α (Finset.filter.{u1} α p (fun (a : α) => _inst_1 a) s)) (Finset.card.{u1} α (Finset.filter.{u1} α (fun (a : α) => Not (p a)) (fun (a : α) => inst._@.Mathlib.Data.Finset.Card._hyg.4896 a) s))) (Finset.card.{u1} α s)
Case conversion may be inaccurate. Consider using '#align finset.filter_card_add_filter_neg_card_eq_card Finset.filter_card_add_filter_neg_card_eq_cardₓ'. -/
theorem filter_card_add_filter_neg_card_eq_card (p : α → Prop) [DecidablePred p] :
(s.filterₓ p).card + (s.filterₓ (Not ∘ p)).card = s.card := by
@@ -981,7 +981,7 @@ def strongDownwardInductionOn {p : Finset α → Sort _} (s : Finset α)
lean 3 declaration is
forall {α : Type.{u1}} {n : Nat} {p : (Finset.{u1} α) -> Sort.{u2}} (s : Finset.{u1} α) (H : forall (t₁ : Finset.{u1} α), (forall {t₂ : Finset.{u1} α}, (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α t₂) n) -> (HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) t₁ t₂) -> (p t₂)) -> (LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α t₁) n) -> (p t₁)), Eq.{u2} ((LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α s) n) -> (p s)) (Finset.strongDownwardInductionOn.{u1, u2} α n (fun (t₂ : Finset.{u1} α) => p t₂) s H) (H s (fun (t : Finset.{u1} α) (ht : LE.le.{0} Nat Nat.hasLe (Finset.card.{u1} α t) n) (h : HasSSubset.SSubset.{u1} (Finset.{u1} α) (Finset.hasSsubset.{u1} α) s t) => Finset.strongDownwardInductionOn.{u1, u2} α n (fun (t₂ : Finset.{u1} α) => p t₂) t H ht))
but is expected to have type
- forall {α : Type.{u2}} {n : Nat} {p : (Finset.{u2} α) -> Sort.{u1}} (s : Finset.{u2} α) (H : forall (t₁ : Finset.{u2} α), (forall {t₂ : Finset.{u2} α}, (LE.le.{0} Nat instLENat (Finset.card.{u2} α t₂) n) -> (HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t₁ t₂) -> (p t₂)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} α t₁) n) -> (p t₁)), Eq.{u1} ((LE.le.{0} Nat instLENat (Finset.card.{u2} α s) n) -> (p s)) (fun (a._@.Mathlib.Data.Finset.Card._hyg.8671 : LE.le.{0} Nat instLENat (Finset.card.{u2} α s) n) => Finset.strongDownwardInductionOn.{u2, u1} α n (fun (x._@.Mathlib.Data.Finset.Card._hyg.8772 : Finset.{u2} α) => p x._@.Mathlib.Data.Finset.Card._hyg.8772) s H a._@.Mathlib.Data.Finset.Card._hyg.8671) (H s (fun {t : Finset.{u2} α} (ht : LE.le.{0} Nat instLENat (Finset.card.{u2} α t) n) (h : HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) s t) => Finset.strongDownwardInductionOn.{u2, u1} α n (fun (t₂ : Finset.{u2} α) => p t₂) t H ht))
+ forall {α : Type.{u2}} {n : Nat} {p : (Finset.{u2} α) -> Sort.{u1}} (s : Finset.{u2} α) (H : forall (t₁ : Finset.{u2} α), (forall {t₂ : Finset.{u2} α}, (LE.le.{0} Nat instLENat (Finset.card.{u2} α t₂) n) -> (HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t₁ t₂) -> (p t₂)) -> (LE.le.{0} Nat instLENat (Finset.card.{u2} α t₁) n) -> (p t₁)), Eq.{u1} ((LE.le.{0} Nat instLENat (Finset.card.{u2} α s) n) -> (p s)) (fun (a._@.Mathlib.Data.Finset.Card._hyg.8679 : LE.le.{0} Nat instLENat (Finset.card.{u2} α s) n) => Finset.strongDownwardInductionOn.{u2, u1} α n (fun (x._@.Mathlib.Data.Finset.Card._hyg.8780 : Finset.{u2} α) => p x._@.Mathlib.Data.Finset.Card._hyg.8780) s H a._@.Mathlib.Data.Finset.Card._hyg.8679) (H s (fun {t : Finset.{u2} α} (ht : LE.le.{0} Nat instLENat (Finset.card.{u2} α t) n) (h : HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) s t) => Finset.strongDownwardInductionOn.{u2, u1} α n (fun (t₂ : Finset.{u2} α) => p t₂) t H ht))
Case conversion may be inaccurate. Consider using '#align finset.strong_downward_induction_on_eq Finset.strongDownwardInductionOn_eqₓ'. -/
theorem strongDownwardInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
mathlib commit https://github.com/leanprover-community/mathlib/commit/4c586d291f189eecb9d00581aeb3dd998ac34442
@@ -437,8 +437,8 @@ theorem card_eq_of_bijective (f : ∀ i, i < n → α) (hf : ∀ a ∈ s, ∃ i,
calc
s.card = card ((range n).attach.image fun i => f i.1 (mem_range.1 i.2)) := by rw [this]
_ = card (range n).attach :=
- card_image_of_injective _ fun ⟨i, hi⟩ ⟨j, hj⟩ eq =>
- Subtype.eq <| f_inj i j (mem_range.1 hi) (mem_range.1 hj) Eq
+ (card_image_of_injective _ fun ⟨i, hi⟩ ⟨j, hj⟩ eq =>
+ Subtype.eq <| f_inj i j (mem_range.1 hi) (mem_range.1 hj) Eq)
_ = card (range n) := card_attach
_ = n := card_range n
@@ -452,7 +452,7 @@ theorem card_congr {t : Finset β} (f : ∀ a ∈ s, β) (h₁ : ∀ a ha, f a h
classical calc
s.card = s.attach.card := card_attach.symm
_ = (s.attach.image fun a : { a // a ∈ s } => f a.1 a.2).card :=
- Eq.symm (card_image_of_injective _ fun a b h => Subtype.eq <| h₂ _ _ _ _ h)
+ (Eq.symm (card_image_of_injective _ fun a b h => Subtype.eq <| h₂ _ _ _ _ h))
_ = t.card :=
congr_arg card
(Finset.ext fun b =>
@@ -716,7 +716,7 @@ theorem card_eq_one : s.card = 1 ↔ ∃ a, s = {a} := by
#align finset.card_eq_one Finset.card_eq_one
-/
-/- ./././Mathport/Syntax/Translate/Basic.lean:628:2: warning: expanding binder collection (a «expr ∉ » s) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (a «expr ∉ » s) -/
#print Finset.exists_eq_insert_iff /-
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
(∃ (a : _)(_ : a ∉ s), insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card :=
@@ -876,7 +876,7 @@ theorem card_eq_three [DecidableEq α] :
/-! ### Inductions -/
-/- ./././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.strongInduction /-
/-- Suppose that, given objects defined on all strict subsets of any finset `s`, one knows how to
define an object on `s`. Then one can inductively define an object on all finsets, starting from
@@ -897,13 +897,13 @@ lean 3 declaration is
but is expected to have type
forall {α : Type.{u2}} {p : (Finset.{u2} α) -> Sort.{u1}} (H : forall (s : Finset.{u2} α), (forall (t : Finset.{u2} α), (HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t s) -> (p t)) -> (p s)) (s : Finset.{u2} α), Eq.{u1} (p s) (Finset.strongInduction.{u2, u1} α (fun (t : Finset.{u2} α) => p t) H s) (H s (fun (t : Finset.{u2} α) (h : HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t s) => Finset.strongInduction.{u2, u1} α (fun (t : Finset.{u2} α) => p t) H t))
Case conversion may be inaccurate. Consider using '#align finset.strong_induction_eq Finset.strongInduction_eqₓ'. -/
-/- ./././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) -/
theorem strongInduction_eq {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s)
(s : Finset α) : strongInduction H s = H s fun t h => strongInduction H t := by
rw [strong_induction]
#align finset.strong_induction_eq Finset.strongInduction_eq
-/- ./././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.strongInductionOn /-
/-- Analogue of `strong_induction` with order of arguments swapped. -/
@[elab_as_elim]
@@ -918,7 +918,7 @@ lean 3 declaration is
but is expected to have type
forall {α : Type.{u2}} {p : (Finset.{u2} α) -> Sort.{u1}} (s : Finset.{u2} α) (H : forall (s : Finset.{u2} α), (forall (t : Finset.{u2} α), (HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t s) -> (p t)) -> (p s)), Eq.{u1} (p s) (Finset.strongInductionOn.{u2, u1} α (fun (t : Finset.{u2} α) => p t) s H) (H s (fun (t : Finset.{u2} α) (h : HasSSubset.SSubset.{u2} (Finset.{u2} α) (Finset.instHasSSubsetFinset.{u2} α) t s) => Finset.strongInductionOn.{u2, u1} α (fun (t : Finset.{u2} α) => p t) t H))
Case conversion may be inaccurate. Consider using '#align finset.strong_induction_on_eq Finset.strongInductionOn_eqₓ'. -/
-/- ./././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) -/
theorem strongInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) :
s.strong_induction_on H = H s fun t h => t.strong_induction_on H :=
@@ -927,7 +927,7 @@ theorem strongInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
rw [strong_induction]
#align finset.strong_induction_on_eq Finset.strongInductionOn_eq
-/- ./././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.case_strong_induction_on /-
@[elab_as_elim]
theorem case_strong_induction_on [DecidableEq α] {p : Finset α → Prop} (s : Finset α) (h₀ : p ∅)
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
deprecated
attributeWhy these changes?
@@ -849,12 +849,6 @@ theorem lt_wf {α} : WellFounded (@LT.lt (Finset α) _) :=
Subrelation.wf H <| InvImage.wf _ <| (Nat.lt_wfRel).2
#align finset.lt_wf Finset.lt_wf
-/-!
-### Deprecated lemmas
-
-Those lemmas have been deprecated on 2023-12-27.
--/
-
-@[deprecated] alias card_le_of_subset := card_le_card
+@[deprecated] alias card_le_of_subset := card_le_card -- 2023-12-27
end Finset
@@ -668,7 +668,7 @@ theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠
theorem one_lt_card_iff_nontrivial : 1 < s.card ↔ s.Nontrivial := by
rw [← not_iff_not, not_lt, Finset.Nontrivial, ← Set.nontrivial_coe_sort,
- not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton_coe]; rfl
+ not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton_coe, coe_sort_coe]
@[deprecated] alias one_lt_card_iff_nontrivial_coe := one_lt_card_iff_nontrivial
Data.Finset.Card
(#11592)
Switch to using tactics rather than term proofs, and cleanup formatting that was from mathport. The intent is to make it more maintainable.
(A subproof of Finset.card_eq_of_bijective
was used as an example of mathlib in the LeanSSR paper.)
@@ -334,48 +334,50 @@ nonrec lemma card_lt_card (h : s ⊂ t) : s.card < t.card := card_lt_card <| val
lemma card_strictMono : StrictMono (card : Finset α → ℕ) := fun _ _ ↦ card_lt_card
theorem card_eq_of_bijective (f : ∀ i, i < n → α) (hf : ∀ a ∈ s, ∃ i, ∃ h : i < n, f i h = a)
- (hf' : ∀ (i) (h : i < n), f i h ∈ s)
- (f_inj : ∀ (i j) (hi : i < n) (hj : j < n), f i hi = f j hj → i = j) : s.card = n := by
+ (hf' : ∀ i (h : i < n), f i h ∈ s)
+ (f_inj : ∀ i j (hi : i < n) (hj : j < n), f i hi = f j hj → i = j) : s.card = n := by
classical
- have : ∀ a : α, a ∈ s ↔ ∃ (i : _) (hi : i ∈ range n), f i (mem_range.1 hi) = a := fun a =>
- ⟨fun ha =>
- let ⟨i, hi, eq⟩ := hf a ha
- ⟨i, mem_range.2 hi, eq⟩,
- fun ⟨i, hi, eq⟩ => eq ▸ hf' i (mem_range.1 hi)⟩
- have : s = (range n).attach.image fun i => f i.1 (mem_range.1 i.2) := by
- simpa only [ext_iff, mem_image, exists_prop, Subtype.exists, mem_attach, true_and_iff]
- calc
- s.card = card ((range n).attach.image fun i => f i.1 (mem_range.1 i.2)) := by rw [this]
- _ = card (range n).attach :=
- (card_image_of_injective _) fun ⟨i, hi⟩ ⟨j, hj⟩ eq =>
- Subtype.eq <| f_inj i j (mem_range.1 hi) (mem_range.1 hj) eq
- _ = card (range n) := card_attach
- _ = n := card_range n
+ have : s = (range n).attach.image fun i => f i.1 (mem_range.1 i.2) := by
+ ext a
+ suffices _ : a ∈ s ↔ ∃ (i : _) (hi : i ∈ range n), f i (mem_range.1 hi) = a by
+ simpa only [mem_image, mem_attach, true_and_iff, Subtype.exists]
+ constructor
+ · intro ha; obtain ⟨i, hi, rfl⟩ := hf a ha; use i, mem_range.2 hi
+ · rintro ⟨i, hi, rfl⟩; apply hf'
+ calc
+ s.card = ((range n).attach.image fun i => f i.1 (mem_range.1 i.2)).card := by rw [this]
+ _ = (range n).attach.card := ?_
+ _ = (range n).card := card_attach
+ _ = n := card_range n
+ apply card_image_of_injective
+ intro ⟨i, hi⟩ ⟨j, hj⟩ eq
+ exact Subtype.eq <| f_inj i j (mem_range.1 hi) (mem_range.1 hj) eq
#align finset.card_eq_of_bijective Finset.card_eq_of_bijective
theorem card_congr {t : Finset β} (f : ∀ a ∈ s, β) (h₁ : ∀ a ha, f a ha ∈ t)
(h₂ : ∀ a b ha hb, f a ha = f b hb → a = b) (h₃ : ∀ b ∈ t, ∃ a ha, f a ha = b) :
s.card = t.card := by
- classical calc
- s.card = s.attach.card := card_attach.symm
- _ = (s.attach.image fun a : { a // a ∈ s } => f a.1 a.2).card :=
- Eq.symm ((card_image_of_injective _) fun a b h => Subtype.eq <| h₂ _ _ _ _ h)
- _ = t.card :=
- congr_arg card
- (Finset.ext fun b =>
- ⟨fun h =>
- let ⟨a, _, ha₂⟩ := mem_image.1 h
- ha₂ ▸ h₁ _ _,
- fun h =>
- let ⟨a, ha₁, ha₂⟩ := h₃ b h
- mem_image.2 ⟨⟨a, ha₁⟩, by simp [ha₂]⟩⟩)
+ classical
+ calc
+ s.card = s.attach.card := card_attach.symm
+ _ = (s.attach.image fun a : { a // a ∈ s } => f a.1 a.2).card := Eq.symm ?_
+ _ = t.card := ?_
+ · apply card_image_of_injective
+ intro ⟨_, _⟩ ⟨_, _⟩ h
+ simpa using h₂ _ _ _ _ h
+ · congr 1
+ ext b
+ constructor
+ · intro h; obtain ⟨_, _, rfl⟩ := mem_image.1 h; apply h₁
+ · intro h; obtain ⟨a, ha, rfl⟩ := h₃ b h; exact mem_image.2 ⟨⟨a, ha⟩, by simp⟩
#align finset.card_congr Finset.card_congr
theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s, f a ∈ t)
(f_inj : ∀ a₁ ∈ s, ∀ a₂ ∈ s, f a₁ = f a₂ → a₁ = a₂) : s.card ≤ t.card := by
- classical calc
- s.card = (s.image f).card := (card_image_of_injOn f_inj).symm
- _ ≤ t.card := card_le_card <| image_subset_iff.2 hf
+ classical
+ calc
+ s.card = (s.image f).card := (card_image_of_injOn f_inj).symm
+ _ ≤ t.card := card_le_card <| image_subset_iff.2 hf
#align finset.card_le_card_of_inj_on Finset.card_le_card_of_inj_on
/-- If there are more pigeons than pigeonholes, then there are two pigeons in the same pigeonhole.
@@ -383,37 +385,39 @@ theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s
theorem exists_ne_map_eq_of_card_lt_of_maps_to {t : Finset β} (hc : t.card < s.card) {f : α → β}
(hf : ∀ a ∈ s, f a ∈ t) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y := by
classical
- by_contra! hz
- refine' hc.not_le (card_le_card_of_inj_on f hf _)
- intro x hx y hy
- contrapose
- exact hz x hx y hy
+ by_contra! hz
+ refine hc.not_le (card_le_card_of_inj_on f hf ?_)
+ intro x hx y hy
+ contrapose
+ exact hz x hx y hy
#align finset.exists_ne_map_eq_of_card_lt_of_maps_to Finset.exists_ne_map_eq_of_card_lt_of_maps_to
theorem le_card_of_inj_on_range (f : ℕ → α) (hf : ∀ i < n, f i ∈ s)
(f_inj : ∀ i < n, ∀ j < n, f i = f j → i = j) : n ≤ s.card :=
calc
n = card (range n) := (card_range n).symm
- _ ≤ s.card := card_le_card_of_inj_on f (by simpa only [mem_range] ) (by simpa only [mem_range] )
+ _ ≤ s.card := card_le_card_of_inj_on f (by simpa only [mem_range]) (by simpa only [mem_range])
#align finset.le_card_of_inj_on_range Finset.le_card_of_inj_on_range
theorem surj_on_of_inj_on_of_card_le {t : Finset β} (f : ∀ a ∈ s, β) (hf : ∀ a ha, f a ha ∈ t)
(hinj : ∀ a₁ a₂ ha₁ ha₂, f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂) (hst : t.card ≤ s.card) :
∀ b ∈ t, ∃ a ha, b = f a ha := by
classical
- intro b hb
- have h : (s.attach.image fun a : { a // a ∈ s } => f a a.prop).card = s.card :=
- @card_attach _ s ▸
- card_image_of_injective _ fun ⟨a₁, ha₁⟩ ⟨a₂, ha₂⟩ h => Subtype.eq <| hinj _ _ _ _ h
- have h' : image (fun a : { a // a ∈ s } => f a a.prop) s.attach = t :=
- eq_of_subset_of_card_le
- (fun b h =>
- let ⟨a, _, ha₂⟩ := mem_image.1 h
- ha₂ ▸ hf _ _)
- (by simp [hst, h])
- rw [← h'] at hb
- obtain ⟨a, _, ha₂⟩ := mem_image.1 hb
- exact ⟨a, a.2, ha₂.symm⟩
+ intro b hb
+ have h : (s.attach.image fun a : { a // a ∈ s } => f a a.prop).card = s.card := by
+ rw [← @card_attach _ s]
+ apply card_image_of_injective
+ intro ⟨_, _⟩ ⟨_, _⟩ h
+ exact Subtype.eq <| hinj _ _ _ _ h
+ have h' : image (fun a : { a // a ∈ s } => f a a.prop) s.attach = t := by
+ apply eq_of_subset_of_card_le
+ · intro b h
+ obtain ⟨_, _, rfl⟩ := mem_image.1 h
+ apply hf
+ · simp [hst, h]
+ rw [← h'] at hb
+ obtain ⟨a, _, rfl⟩ := mem_image.1 hb
+ use a, a.2
#align finset.surj_on_of_inj_on_of_card_le Finset.surj_on_of_inj_on_of_card_le
theorem inj_on_of_surj_on_of_card_le {t : Finset β} (f : ∀ a ∈ s, β) (hf : ∀ a ha, f a ha ∈ t)
@@ -571,6 +571,10 @@ theorem exists_smaller_set (A : Finset α) (i : ℕ) (h₁ : i ≤ card A) :
⟨B, x₁, x₂⟩
#align finset.exists_smaller_set Finset.exists_smaller_set
+theorem le_card_iff_exists_subset_card : n ≤ s.card ↔ ∃ t ⊆ s, t.card = n := by
+ refine' ⟨fun h => _, fun ⟨t, hst, ht⟩ => ht ▸ card_le_card hst⟩
+ exact exists_smaller_set s n h
+
theorem exists_subset_or_subset_of_two_mul_lt_card [DecidableEq α] {X Y : Finset α} {n : ℕ}
(hXY : 2 * n < (X ∪ Y).card) : ∃ C : Finset α, n < C.card ∧ (C ⊆ X ∨ C ⊆ Y) := by
have h₁ : (X ∩ (Y \ X)).card = 0 := Finset.card_eq_zero.mpr (Finset.inter_sdiff_self X Y)
@@ -664,25 +668,6 @@ theorem one_lt_card_iff_nontrivial : 1 < s.card ↔ s.Nontrivial := by
@[deprecated] alias one_lt_card_iff_nontrivial_coe := one_lt_card_iff_nontrivial
-theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c := by
- classical
- refine' ⟨fun h => _, _⟩
- · obtain ⟨c, hc⟩ := card_pos.mp (pos_of_gt h)
- have : 1 < (s.erase c).card := by rwa [← add_lt_add_iff_right 1, card_erase_add_one hc]
- obtain ⟨a, b, ha, hb, hab⟩ := one_lt_card_iff.mp this
- exact
- ⟨a, b, c, mem_of_mem_erase ha, mem_of_mem_erase hb, hc, hab, ne_of_mem_erase ha,
- ne_of_mem_erase hb⟩
- · rintro ⟨a, b, c, ha, hb, hc, hab, hac, hbc⟩
- rw [← card_erase_add_one hc, ← card_erase_add_one (mem_erase_of_ne_of_mem hbc hb), ←
- card_erase_add_one (mem_erase_of_ne_of_mem hab (mem_erase_of_ne_of_mem hac ha))]
- apply Nat.le_add_left
-#align finset.two_lt_card_iff Finset.two_lt_card_iff
-
-theorem two_lt_card : 2 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, ∃ c ∈ s, a ≠ b ∧ a ≠ c ∧ b ≠ c := by
- simp_rw [two_lt_card_iff, exists_and_left]
-#align finset.two_lt_card Finset.two_lt_card
-
theorem exists_ne_of_one_lt_card (hs : 1 < s.card) (a : α) : ∃ b, b ∈ s ∧ b ≠ a := by
obtain ⟨x, hx, y, hy, hxy⟩ := Finset.one_lt_card.mp hs
by_cases ha : y = a
@@ -738,6 +723,21 @@ theorem card_eq_three : s.card = 3 ↔ ∃ x y z, x ≠ y ∧ x ≠ z ∧ y ≠
end DecidableEq
+theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c := by
+ classical
+ simp_rw [lt_iff_add_one_le, le_card_iff_exists_subset_card, reduceAdd, card_eq_three,
+ ← exists_and_left, exists_comm (α := Finset α)]
+ constructor
+ · rintro ⟨a, b, c, t, hsub, hab, hac, hbc, rfl⟩
+ exact ⟨a, b, c, by simp_all [insert_subset_iff]⟩
+ · rintro ⟨a, b, c, ha, hb, hc, hab, hac, hbc⟩
+ exact ⟨a, b, c, {a, b, c}, by simp_all [insert_subset_iff]⟩
+#align finset.two_lt_card_iff Finset.two_lt_card_iff
+
+theorem two_lt_card : 2 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, ∃ c ∈ s, a ≠ b ∧ a ≠ c ∧ b ≠ c := by
+ simp_rw [two_lt_card_iff, exists_and_left]
+#align finset.two_lt_card Finset.two_lt_card
+
/-! ### Inductions -/
this will break once https://github.com/leanprover/lean4/pull/3658 lands, so let's fix this now.
Also avoids binding unused variables in termination_by
.
@@ -799,7 +799,7 @@ protected lemma Nonempty.strong_induction {p : ∀ s, s.Nonempty → Prop}
· refine h₁ hs fun t ht hts ↦ ?_
have := card_lt_card hts
exact ht.strong_induction h₀ h₁
-termination_by Finset.card ‹_›
+termination_by s => Finset.card s
/-- Suppose that, given that `p t` can be defined on all supersets of `s` of cardinality less than
`n`, one knows how to define `p s`. Then one can inductively define `p s` for all finsets `s` of
Homogenises porting notes via capitalisation and addition of whitespace.
It makes the following changes:
@@ -753,7 +753,7 @@ def strongInduction {p : Finset α → Sort*} (H : ∀ s, (∀ t ⊂ s, p t) →
termination_by s => Finset.card s
#align finset.strong_induction Finset.strongInduction
-@[nolint unusedHavesSuffices] --Porting note: false positive
+@[nolint unusedHavesSuffices] -- Porting note: false positive
theorem strongInduction_eq {p : Finset α → Sort*} (H : ∀ s, (∀ t ⊂ s, p t) → p s)
(s : Finset α) : strongInduction H s = H s fun t _ => strongInduction H t := by
rw [strongInduction]
@@ -765,7 +765,7 @@ def strongInductionOn {p : Finset α → Sort*} (s : Finset α) :
(∀ s, (∀ t ⊂ s, p t) → p s) → p s := fun H => strongInduction H s
#align finset.strong_induction_on Finset.strongInductionOn
-@[nolint unusedHavesSuffices] --Porting note: false positive
+@[nolint unusedHavesSuffices] -- Porting note: false positive
theorem strongInductionOn_eq {p : Finset α → Sort*} (s : Finset α)
(H : ∀ s, (∀ t ⊂ s, p t) → p s) :
s.strongInductionOn H = H s fun t _ => t.strongInductionOn H := by
@@ -815,7 +815,7 @@ def strongDownwardInduction {p : Finset α → Sort*} {n : ℕ}
termination_by s => n - s.card
#align finset.strong_downward_induction Finset.strongDownwardInduction
-@[nolint unusedHavesSuffices] --Porting note: false positive
+@[nolint unusedHavesSuffices] -- Porting note: false positive
theorem strongDownwardInduction_eq {p : Finset α → Sort*}
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁)
(s : Finset α) :
@@ -831,7 +831,7 @@ def strongDownwardInductionOn {p : Finset α → Sort*} (s : Finset α)
strongDownwardInduction H s
#align finset.strong_downward_induction_on Finset.strongDownwardInductionOn
-@[nolint unusedHavesSuffices] --Porting note: false positive
+@[nolint unusedHavesSuffices] -- Porting note: false positive
theorem strongDownwardInductionOn_eq {p : Finset α → Sort*} (s : Finset α)
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
s.strongDownwardInductionOn H = H s fun {t} ht _ => t.strongDownwardInductionOn H ht := by
@@ -57,6 +57,7 @@ theorem card_empty : card (∅ : Finset α) = 0 :=
rfl
#align finset.card_empty Finset.card_empty
+@[gcongr]
theorem card_le_card : s ⊆ t → s.card ≤ t.card :=
Multiset.card_le_card ∘ val_le_iff.mpr
#align finset.card_le_of_subset Finset.card_le_card
Init.CCLemmas
(#10696)
Those lemmas were weird and unused, except the last few about transitivity of =
and ≠
, which I moved to Logic.Basic
@@ -3,7 +3,6 @@ Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Jeremy Avigad
-/
-import Mathlib.Init.CCLemmas
import Mathlib.Data.Finset.Image
#align_import data.finset.card from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83"
@@ -590,6 +590,10 @@ theorem card_eq_one : s.card = 1 ↔ ∃ a, s = {a} := by
simp only [Multiset.card_eq_one, Finset.card, ← val_inj, singleton_val]
#align finset.card_eq_one Finset.card_eq_one
+theorem _root_.Multiset.toFinset_card_eq_one_iff [DecidableEq α] (s : Multiset α) :
+ s.toFinset.card = 1 ↔ Multiset.card s ≠ 0 ∧ ∃ a : α, s = Multiset.card s • {a} := by
+ simp_rw [card_eq_one, Multiset.toFinset_eq_singleton_iff, exists_and_left]
+
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
(∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
constructor
@@ -469,8 +469,10 @@ theorem card_union_le (s t : Finset α) : (s ∪ t).card ≤ s.card + t.card :=
card_union_add_card_inter s t ▸ Nat.le_add_right _ _
#align finset.card_union_le Finset.card_union_le
-@[simp] lemma card_union_of_disjoint (h : Disjoint s t) : (s ∪ t).card = s.card + t.card := by
- rw [← disjUnion_eq_union s t h, card_disjUnion _ _ _]
+lemma card_union_eq_card_add_card : (s ∪ t).card = s.card + t.card ↔ Disjoint s t := by
+ rw [← card_union_add_card_inter]; simp [disjoint_iff_inter_eq_empty]
+
+@[simp] alias ⟨_, card_union_of_disjoint⟩ := card_union_eq_card_add_card
#align finset.card_union_eq Finset.card_union_of_disjoint
#align finset.card_disjoint_union Finset.card_union_of_disjoint
(s ∩ t).card = s.card + t.card - (s ∪ t).card
(#10224)
once coerced to an AddGroupWithOne
. Also unify Finset.card_disjoint_union
and Finset.card_union_eq
From LeanAPAP
@@ -459,22 +459,36 @@ theorem card_inter_add_card_union (s t : Finset α) :
(s ∩ t).card + (s ∪ t).card = s.card + t.card := by rw [add_comm, card_union_add_card_inter]
#align finset.card_inter_add_card_union Finset.card_inter_add_card_union
+lemma card_union (s t : Finset α) : (s ∪ t).card = s.card + t.card - (s ∩ t).card := by
+ rw [← card_union_add_card_inter, Nat.add_sub_cancel]
+
+lemma card_inter (s t : Finset α) : (s ∩ t).card = s.card + t.card - (s ∪ t).card := by
+ rw [← card_inter_add_card_union, Nat.add_sub_cancel]
+
theorem card_union_le (s t : Finset α) : (s ∪ t).card ≤ s.card + t.card :=
card_union_add_card_inter s t ▸ Nat.le_add_right _ _
#align finset.card_union_le Finset.card_union_le
-theorem card_union_eq (h : Disjoint s t) : (s ∪ t).card = s.card + t.card := by
+@[simp] lemma card_union_of_disjoint (h : Disjoint s t) : (s ∪ t).card = s.card + t.card := by
rw [← disjUnion_eq_union s t h, card_disjUnion _ _ _]
-#align finset.card_union_eq Finset.card_union_eq
+#align finset.card_union_eq Finset.card_union_of_disjoint
+#align finset.card_disjoint_union Finset.card_union_of_disjoint
-@[simp]
-theorem card_disjoint_union (h : Disjoint s t) : card (s ∪ t) = s.card + t.card :=
- card_union_eq h
-#align finset.card_disjoint_union Finset.card_disjoint_union
+-- 2024-02-09
+@[deprecated] alias card_union_eq := card_union_of_disjoint
+@[deprecated] alias card_disjoint_union := card_union_of_disjoint
+
+lemma cast_card_inter [AddGroupWithOne R] :
+ ((s ∩ t).card : R) = s.card + t.card - (s ∪ t).card := by
+ rw [eq_sub_iff_add_eq, ← cast_add, card_inter_add_card_union, cast_add]
+
+lemma cast_card_union [AddGroupWithOne R] :
+ ((s ∪ t).card : R) = s.card + t.card - (s ∩ t).card := by
+ rw [eq_sub_iff_add_eq, ← cast_add, card_union_add_card_inter, cast_add]
theorem card_sdiff (h : s ⊆ t) : card (t \ s) = t.card - s.card := by
suffices card (t \ s) = card (t \ s ∪ s) - s.card by rwa [sdiff_union_of_subset h] at this
- rw [card_disjoint_union sdiff_disjoint, add_tsub_cancel_right]
+ rw [card_union_of_disjoint sdiff_disjoint, add_tsub_cancel_right]
#align finset.card_sdiff Finset.card_sdiff
lemma cast_card_sdiff [AddGroupWithOne R] (h : s ⊆ t) : ((t \ s).card : R) = t.card - s.card := by
@@ -497,7 +511,7 @@ theorem card_le_card_sdiff_add_card : s.card ≤ (s \ t).card + t.card :=
#align finset.card_le_card_sdiff_add_card Finset.card_le_card_sdiff_add_card
theorem card_sdiff_add_card : (s \ t).card + t.card = (s ∪ t).card := by
- rw [← card_disjoint_union sdiff_disjoint, sdiff_union_self_eq_union]
+ rw [← card_union_of_disjoint sdiff_disjoint, sdiff_union_self_eq_union]
#align finset.card_sdiff_add_card Finset.card_sdiff_add_card
lemma card_sdiff_comm (h : s.card = t.card) : (s \ t).card = (t \ s).card :=
@@ -507,7 +521,7 @@ lemma card_sdiff_comm (h : s.card = t.card) : (s \ t).card = (t \ s).card :=
@[simp]
lemma card_sdiff_add_card_inter (s t : Finset α) :
(s \ t).card + (s ∩ t).card = s.card := by
- rw [← card_disjoint_union (disjoint_sdiff_inter _ _), sdiff_union_inter]
+ rw [← card_union_of_disjoint (disjoint_sdiff_inter _ _), sdiff_union_inter]
@[simp]
lemma card_inter_add_card_sdiff (s t : Finset α) :
@@ -519,7 +533,8 @@ end Lattice
theorem filter_card_add_filter_neg_card_eq_card
(p : α → Prop) [DecidablePred p] [∀ x, Decidable (¬p x)] :
(s.filter p).card + (s.filter (fun a => ¬ p a)).card = s.card := by
- classical rw [← card_union_eq (disjoint_filter_filter_neg _ _ _), filter_union_filter_neg_eq]
+ classical
+ rw [← card_union_of_disjoint (disjoint_filter_filter_neg _ _ _), filter_union_filter_neg_eq]
#align finset.filter_card_add_filter_neg_card_eq_card Finset.filter_card_add_filter_neg_card_eq_card
/-- Given a set `A` and a set `B` inside it, we can shrink `A` to any appropriate size, and keep `B`
Provide instances
Nontrivial (TensorAlgebra R M)
when M
is a module over
a nontrivial semiring R
NoZeroDivisors (FreeAlgebra R X)
when R
is a commutative
semiring with no zero-divisors and X
any typeIsDomain (FreeAlgebra R X)
when R
is an integral domain
and X
is any typeTwoUniqueProds (FreeMonoid X)
where X
is any type
(this provides NoZeroDivisors (MonoidAlgebra R (FreeMonoid X))
when R
is a semiring and X
any type,
via TwoUniqueProds.toUniqueProds
and MonoidAlgebra.instNoZeroDivisorsOfUniqueProds
)NoZeroDivisors (TensorAlgebra R M)
when M
is a free module
over a commutative semiring R
with no zero-divisorsIsDomain (TensorAlgebra R M)
when M
is a free module over
an integral domain R
In Algebra.Group.UniqueProds:
UniqueProds.mulHom_image_of_injective
to
UniqueProds.of_injective_mulHom
.UniqueMul.of_mulHom_image
, UniqueProds.of_mulHom
,
TwoUniqueProds.of_mulHom
show the relevant property holds in the
domain of a multiplicative homomorphism if it holds in the codomain,
under a certain hypothesis on the homomorphism.Co-authored-by: Richard Copley <rcopley@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Junyan Xu <junyanxu.math@gmail.com>
@@ -637,8 +637,11 @@ theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠
simp only [exists_prop, exists_and_left]
#align finset.one_lt_card_iff Finset.one_lt_card_iff
-theorem one_lt_card_iff_nontrivial_coe : 1 < s.card ↔ Nontrivial (s : Type _) := by
- rw [← not_iff_not, not_lt, not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton_coe]
+theorem one_lt_card_iff_nontrivial : 1 < s.card ↔ s.Nontrivial := by
+ rw [← not_iff_not, not_lt, Finset.Nontrivial, ← Set.nontrivial_coe_sort,
+ not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton_coe]; rfl
+
+@[deprecated] alias one_lt_card_iff_nontrivial_coe := one_lt_card_iff_nontrivial
theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c := by
classical
Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
@@ -726,7 +726,7 @@ def strongInduction {p : Finset α → Sort*} (H : ∀ s, (∀ t ⊂ s, p t) →
H s fun t h =>
have : t.card < s.card := card_lt_card h
strongInduction H t
- termination_by strongInduction s => Finset.card s
+ termination_by s => Finset.card s
#align finset.strong_induction Finset.strongInduction
@[nolint unusedHavesSuffices] --Porting note: false positive
@@ -775,7 +775,7 @@ protected lemma Nonempty.strong_induction {p : ∀ s, s.Nonempty → Prop}
· refine h₁ hs fun t ht hts ↦ ?_
have := card_lt_card hts
exact ht.strong_induction h₀ h₁
-termination_by Nonempty.strong_induction _ => Finset.card ‹_›
+termination_by Finset.card ‹_›
/-- Suppose that, given that `p t` can be defined on all supersets of `s` of cardinality less than
`n`, one knows how to define `p s`. Then one can inductively define `p s` for all finsets `s` of
@@ -788,7 +788,7 @@ def strongDownwardInduction {p : Finset α → Sort*} {n : ℕ}
H s fun {t} ht h =>
have : n - t.card < n - s.card := (tsub_lt_tsub_iff_left_of_le ht).2 (Finset.card_lt_card h)
strongDownwardInduction H t ht
- termination_by strongDownwardInduction s => n - s.card
+ termination_by s => n - s.card
#align finset.strong_downward_induction Finset.strongDownwardInduction
@[nolint unusedHavesSuffices] --Porting note: false positive
@@ -24,10 +24,7 @@ This defines the cardinality of a `Finset` and provides induction principles for
* `Finset.strongDownwardInduction`
* `Finset.strongDownwardInductionOn`
* `Finset.case_strong_induction_on`
-
-## TODO
-
-Should we add a noncomputable version?
+* `Finset.Nonempty.strong_induction`
-/
@@ -760,6 +757,26 @@ theorem case_strong_induction_on [DecidableEq α] {p : Finset α → Prop} (s :
(h₁ a s n) fun t ss => ih _ (lt_of_le_of_lt ss (ssubset_insert n) : t < _)
#align finset.case_strong_induction_on Finset.case_strong_induction_on
+/-- Suppose that, given objects defined on all nonempty strict subsets of any nontrivial finset `s`,
+one knows how to define an object on `s`. Then one can inductively define an object on all finsets,
+starting from singletons and iterating.
+
+TODO: Currently this can only be used to prove properties.
+Replace `Finset.Nonempty.exists_eq_singleton_or_nontrivial` with computational content
+in order to let `p` be `Sort`-valued. -/
+@[elab_as_elim]
+protected lemma Nonempty.strong_induction {p : ∀ s, s.Nonempty → Prop}
+ (h₀ : ∀ a, p {a} (singleton_nonempty _))
+ (h₁ : ∀ ⦃s⦄ (hs : s.Nontrivial), (∀ t ht, t ⊂ s → p t ht) → p s hs.nonempty) :
+ ∀ ⦃s : Finset α⦄ (hs), p s hs
+ | s, hs => by
+ obtain ⟨a, rfl⟩ | hs := hs.exists_eq_singleton_or_nontrivial
+ · exact h₀ _
+ · refine h₁ hs fun t ht hts ↦ ?_
+ have := card_lt_card hts
+ exact ht.strong_induction h₀ h₁
+termination_by Nonempty.strong_induction _ => Finset.card ‹_›
+
/-- Suppose that, given that `p t` can be defined on all supersets of `s` of cardinality less than
`n`, one knows how to define `p s`. Then one can inductively define `p s` for all finsets `s` of
cardinality less than `n`, starting from finsets of card `n` and iterating. This
Finset.cast_card_sdiff
(#9563)
The two types were accidentally the same.
@@ -33,7 +33,7 @@ Should we add a noncomputable version?
open Function Multiset Nat
-variable {α β : Type*}
+variable {α β R : Type*}
namespace Finset
@@ -480,7 +480,7 @@ theorem card_sdiff (h : s ⊆ t) : card (t \ s) = t.card - s.card := by
rw [card_disjoint_union sdiff_disjoint, add_tsub_cancel_right]
#align finset.card_sdiff Finset.card_sdiff
-lemma cast_card_sdiff [AddGroupWithOne α] (h : s ⊆ t) : ((t \ s).card : α) = t.card - s.card := by
+lemma cast_card_sdiff [AddGroupWithOne R] (h : s ⊆ t) : ((t \ s).card : R) = t.card - s.card := by
rw [card_sdiff h, Nat.cast_sub (card_mono h)]
theorem card_sdiff_add_card_eq_card {s t : Finset α} (h : s ⊆ t) : card (t \ s) + card s = card t :=
@@ -40,7 +40,7 @@ namespace Finset
variable {s t : Finset α} {a b : α}
/-- `s.card` is the number of elements of `s`, aka its cardinality. -/
-def card (s : Finset α) : ℕ :=
+@[pp_dot] def card (s : Finset α) : ℕ :=
Multiset.card s.1
#align finset.card Finset.card
@@ -480,6 +480,9 @@ theorem card_sdiff (h : s ⊆ t) : card (t \ s) = t.card - s.card := by
rw [card_disjoint_union sdiff_disjoint, add_tsub_cancel_right]
#align finset.card_sdiff Finset.card_sdiff
+lemma cast_card_sdiff [AddGroupWithOne α] (h : s ⊆ t) : ((t \ s).card : α) = t.card - s.card := by
+ rw [card_sdiff h, Nat.cast_sub (card_mono h)]
+
theorem card_sdiff_add_card_eq_card {s t : Finset α} (h : s ⊆ t) : card (t \ s) + card s = card t :=
((Nat.sub_eq_iff_eq_add (card_le_card h)).mp (card_sdiff h).symm).symm
#align finset.card_sdiff_add_card_eq_card Finset.card_sdiff_add_card_eq_card
$
with <|
(#9319)
See Zulip thread for the discussion.
@@ -501,7 +501,8 @@ theorem card_sdiff_add_card : (s \ t).card + t.card = (s ∪ t).card := by
#align finset.card_sdiff_add_card Finset.card_sdiff_add_card
lemma card_sdiff_comm (h : s.card = t.card) : (s \ t).card = (t \ s).card :=
- add_left_injective t.card $ by simp_rw [card_sdiff_add_card, ← h, card_sdiff_add_card, union_comm]
+ add_left_injective t.card <| by
+ simp_rw [card_sdiff_add_card, ← h, card_sdiff_add_card, union_comm]
@[simp]
lemma card_sdiff_add_card_inter (s t : Finset α) :
@@ -149,9 +149,11 @@ theorem card_insert_eq_ite : card (insert a s) = if a ∈ s then s.card else s.c
#align finset.card_insert_eq_ite Finset.card_insert_eq_ite
@[simp]
-theorem card_doubleton (h : a ≠ b) : ({a, b} : Finset α).card = 2 := by
+theorem card_pair (h : a ≠ b) : ({a, b} : Finset α).card = 2 := by
rw [card_insert_of_not_mem (not_mem_singleton.2 h), card_singleton]
-#align finset.card_doubleton Finset.card_doubleton
+#align finset.card_doubleton Finset.card_pair
+
+@[deprecated] alias card_doubleton := Finset.card_pair
/-- $\#(s \setminus \{a\}) = \#s - 1$ if $a \in s$. -/
@[simp]
@@ -694,7 +696,7 @@ theorem card_eq_two : s.card = 2 ↔ ∃ x y, x ≠ y ∧ s = {x, y} := by
rintro ⟨a, _, hab, rfl, b, rfl⟩
exact ⟨a, b, not_mem_singleton.1 hab, rfl⟩
· rintro ⟨x, y, h, rfl⟩
- exact card_doubleton h
+ exact card_pair h
#align finset.card_eq_two Finset.card_eq_two
theorem card_eq_three : s.card = 3 ↔ ∃ x y z, x ≠ y ∧ x ≠ z ∧ y ≠ z ∧ s = {x, y, z} := by
@@ -120,6 +120,26 @@ theorem card_insert_le (a : α) (s : Finset α) : card (insert a s) ≤ s.card +
· rw [card_insert_of_not_mem h]
#align finset.card_insert_le Finset.card_insert_le
+section
+
+variable {a b c d e f : α}
+
+theorem card_le_two : card {a, b} ≤ 2 := card_insert_le _ _
+
+theorem card_le_three : card {a, b, c} ≤ 3 :=
+ (card_insert_le _ _).trans (Nat.succ_le_succ card_le_two)
+
+theorem card_le_four : card {a, b, c, d} ≤ 4 :=
+ (card_insert_le _ _).trans (Nat.succ_le_succ card_le_three)
+
+theorem card_le_five : card {a, b, c, d, e} ≤ 5 :=
+ (card_insert_le _ _).trans (Nat.succ_le_succ card_le_four)
+
+theorem card_le_six : card {a, b, c, d, e, f} ≤ 6 :=
+ (card_insert_le _ _).trans (Nat.succ_le_succ card_le_five)
+
+end
+
/-- If `a ∈ s` is known, see also `Finset.card_insert_of_mem` and `Finset.card_insert_of_not_mem`.
-/
theorem card_insert_eq_ite : card (insert a s) = if a ∈ s then s.card else s.card + 1 := by
Lemmas around this were a mess, throth in terms of names, statement and location. This PR standardises everything to be in Algebra.BigOperators.Basic
and changes the lemmas to take in InjOn
and SurjOn
assumptions where possible (and where impossible make sure the hypotheses are taken in the correct order) and moves the equality of functions hypothesis last.
Also add a few lemmas that help fix downstream uses by golfing.
From LeanAPAP and LeanCamCombi
@@ -398,14 +398,14 @@ theorem surj_on_of_inj_on_of_card_le {t : Finset β} (f : ∀ a ∈ s, β) (hf :
#align finset.surj_on_of_inj_on_of_card_le Finset.surj_on_of_inj_on_of_card_le
theorem inj_on_of_surj_on_of_card_le {t : Finset β} (f : ∀ a ∈ s, β) (hf : ∀ a ha, f a ha ∈ t)
- (hsurj : ∀ b ∈ t, ∃ a ha, b = f a ha) (hst : s.card ≤ t.card) ⦃a₁ a₂⦄ (ha₁ : a₁ ∈ s)
+ (hsurj : ∀ b ∈ t, ∃ a ha, f a ha = b) (hst : s.card ≤ t.card) ⦃a₁⦄ (ha₁ : a₁ ∈ s) ⦃a₂⦄
(ha₂ : a₂ ∈ s) (ha₁a₂ : f a₁ ha₁ = f a₂ ha₂) : a₁ = a₂ :=
haveI : Inhabited { x // x ∈ s } := ⟨⟨a₁, ha₁⟩⟩
let f' : { x // x ∈ s } → { x // x ∈ t } := fun x => ⟨f x.1 x.2, hf x.1 x.2⟩
let g : { x // x ∈ t } → { x // x ∈ s } :=
@surjInv _ _ f' fun x =>
let ⟨y, hy₁, hy₂⟩ := hsurj x.1 x.2
- ⟨⟨y, hy₁⟩, Subtype.eq hy₂.symm⟩
+ ⟨⟨y, hy₁⟩, Subtype.eq hy₂⟩
have hg : Injective g := injective_surjInv _
have hsg : Surjective g := fun x =>
let ⟨y, hy⟩ :=
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
@@ -61,12 +61,12 @@ theorem card_empty : card (∅ : Finset α) = 0 :=
rfl
#align finset.card_empty Finset.card_empty
-theorem card_le_of_subset : s ⊆ t → s.card ≤ t.card :=
- Multiset.card_le_of_le ∘ val_le_iff.mpr
-#align finset.card_le_of_subset Finset.card_le_of_subset
+theorem card_le_card : s ⊆ t → s.card ≤ t.card :=
+ Multiset.card_le_card ∘ val_le_iff.mpr
+#align finset.card_le_of_subset Finset.card_le_card
@[mono]
-theorem card_mono : Monotone (@card α) := by apply card_le_of_subset
+theorem card_mono : Monotone (@card α) := by apply card_le_card
#align finset.card_mono Finset.card_mono
@[simp]
@@ -197,7 +197,7 @@ theorem Multiset.card_toFinset : m.toFinset.card = Multiset.card m.dedup :=
#align multiset.card_to_finset Multiset.card_toFinset
theorem Multiset.toFinset_card_le : m.toFinset.card ≤ Multiset.card m :=
- card_le_of_le <| dedup_le _
+ card_le_card <| dedup_le _
#align multiset.to_finset_card_le Multiset.toFinset_card_le
theorem Multiset.toFinset_card_of_nodup {m : Multiset α} (h : m.Nodup) :
@@ -284,7 +284,7 @@ theorem card_subtype (p : α → Prop) [DecidablePred p] (s : Finset α) :
theorem card_filter_le (s : Finset α) (p : α → Prop) [DecidablePred p] :
(s.filter p).card ≤ s.card :=
- card_le_of_subset <| filter_subset _ _
+ card_le_card <| filter_subset _ _
#align finset.card_filter_le Finset.card_filter_le
theorem eq_of_subset_of_card_le {s t : Finset α} (h : s ⊆ t) (h₂ : t.card ≤ s.card) : s = t :=
@@ -309,8 +309,7 @@ theorem filter_card_eq {p : α → Prop} [DecidablePred p] (h : (s.filter p).car
exact hx.2
#align finset.filter_card_eq Finset.filter_card_eq
-theorem card_lt_card (h : s ⊂ t) : s.card < t.card :=
- card_lt_of_lt <| val_lt_iff.2 h
+nonrec lemma card_lt_card (h : s ⊂ t) : s.card < t.card := card_lt_card <| val_lt_iff.2 h
#align finset.card_lt_card Finset.card_lt_card
lemma card_strictMono : StrictMono (card : Finset α → ℕ) := fun _ _ ↦ card_lt_card
@@ -357,7 +356,7 @@ theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s
(f_inj : ∀ a₁ ∈ s, ∀ a₂ ∈ s, f a₁ = f a₂ → a₁ = a₂) : s.card ≤ t.card := by
classical calc
s.card = (s.image f).card := (card_image_of_injOn f_inj).symm
- _ ≤ t.card := card_le_of_subset <| image_subset_iff.2 hf
+ _ ≤ t.card := card_le_card <| image_subset_iff.2 hf
#align finset.card_le_card_of_inj_on Finset.card_le_card_of_inj_on
/-- If there are more pigeons than pigeonholes, then there are two pigeons in the same pigeonhole.
@@ -460,13 +459,13 @@ theorem card_sdiff (h : s ⊆ t) : card (t \ s) = t.card - s.card := by
#align finset.card_sdiff Finset.card_sdiff
theorem card_sdiff_add_card_eq_card {s t : Finset α} (h : s ⊆ t) : card (t \ s) + card s = card t :=
- ((Nat.sub_eq_iff_eq_add (card_le_of_subset h)).mp (card_sdiff h).symm).symm
+ ((Nat.sub_eq_iff_eq_add (card_le_card h)).mp (card_sdiff h).symm).symm
#align finset.card_sdiff_add_card_eq_card Finset.card_sdiff_add_card_eq_card
theorem le_card_sdiff (s t : Finset α) : t.card - s.card ≤ card (t \ s) :=
calc
card t - card s ≤ card t - card (s ∩ t) :=
- tsub_le_tsub_left (card_le_of_subset (inter_subset_left s t)) _
+ tsub_le_tsub_left (card_le_card (inter_subset_left s t)) _
_ = card (t \ (s ∩ t)) := (card_sdiff (inter_subset_right s t)).symm
_ ≤ card (t \ s) := by rw [sdiff_inter_self_right t s]
#align finset.le_card_sdiff Finset.le_card_sdiff
@@ -590,7 +589,7 @@ theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x
· exact ⟨x, fun y hy => by rw [card_le_one.1 H y hy x hx, mem_singleton]⟩
· rintro ⟨x, hx⟩
rw [← card_singleton x]
- exact card_le_of_subset hx
+ exact card_le_card hx
#align finset.card_le_one_iff_subset_singleton Finset.card_le_one_iff_subset_singleton
lemma exists_mem_ne (hs : 1 < s.card) (a : α) : ∃ b ∈ s, b ≠ a := by
@@ -779,4 +778,12 @@ theorem lt_wf {α} : WellFounded (@LT.lt (Finset α) _) :=
Subrelation.wf H <| InvImage.wf _ <| (Nat.lt_wfRel).2
#align finset.lt_wf Finset.lt_wf
+/-!
+### Deprecated lemmas
+
+Those lemmas have been deprecated on 2023-12-27.
+-/
+
+@[deprecated] alias card_le_of_subset := card_le_card
+
end Finset
∃ 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.
@@ -552,7 +552,7 @@ theorem card_eq_one : s.card = 1 ↔ ∃ a, s = {a} := by
#align finset.card_eq_one Finset.card_eq_one
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
- (∃ (a : _) (_ : a ∉ s), insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
+ (∃ a ∉ s, insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
constructor
· rintro ⟨a, ha, rfl⟩
exact ⟨subset_insert _ _, (card_insert_of_not_mem ha).symm⟩
@@ -698,7 +698,7 @@ end DecidableEq
/-- Suppose that, given objects defined on all strict subsets of any finset `s`, one knows how to
define an object on `s`. Then one can inductively define an object on all finsets, starting from
the empty set and iterating. This can be used either to define data, or to prove properties. -/
-def strongInduction {p : Finset α → Sort*} (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) :
+def strongInduction {p : Finset α → Sort*} (H : ∀ s, (∀ t ⊂ s, p t) → p s) :
∀ s : Finset α, p s
| s =>
H s fun t h =>
@@ -708,7 +708,7 @@ def strongInduction {p : Finset α → Sort*} (H : ∀ s, (∀ (t) (_ : t ⊂ s)
#align finset.strong_induction Finset.strongInduction
@[nolint unusedHavesSuffices] --Porting note: false positive
-theorem strongInduction_eq {p : Finset α → Sort*} (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s)
+theorem strongInduction_eq {p : Finset α → Sort*} (H : ∀ s, (∀ t ⊂ s, p t) → p s)
(s : Finset α) : strongInduction H s = H s fun t _ => strongInduction H t := by
rw [strongInduction]
#align finset.strong_induction_eq Finset.strongInduction_eq
@@ -716,12 +716,12 @@ theorem strongInduction_eq {p : Finset α → Sort*} (H : ∀ s, (∀ (t) (_ : t
/-- Analogue of `strongInduction` with order of arguments swapped. -/
@[elab_as_elim]
def strongInductionOn {p : Finset α → Sort*} (s : Finset α) :
- (∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) → p s := fun H => strongInduction H s
+ (∀ s, (∀ t ⊂ s, p t) → p s) → p s := fun H => strongInduction H s
#align finset.strong_induction_on Finset.strongInductionOn
@[nolint unusedHavesSuffices] --Porting note: false positive
theorem strongInductionOn_eq {p : Finset α → Sort*} (s : Finset α)
- (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) :
+ (H : ∀ s, (∀ t ⊂ s, p t) → p s) :
s.strongInductionOn H = H s fun t _ => t.strongInductionOn H := by
dsimp only [strongInductionOn]
rw [strongInduction]
@@ -729,7 +729,7 @@ theorem strongInductionOn_eq {p : Finset α → Sort*} (s : Finset α)
@[elab_as_elim]
theorem case_strong_induction_on [DecidableEq α] {p : Finset α → Prop} (s : Finset α) (h₀ : p ∅)
- (h₁ : ∀ a s, a ∉ s → (∀ (t) (_ : t ⊆ s), p t) → p (insert a s)) : p s :=
+ (h₁ : ∀ a s, a ∉ s → (∀ t ⊆ s, p t) → p (insert a s)) : p s :=
Finset.strongInductionOn s fun s =>
Finset.induction_on s (fun _ => h₀) fun a s n _ ih =>
(h₁ a s n) fun t ss => ih _ (lt_of_le_of_lt ss (ssubset_insert n) : t < _)
P
is no greater than n
iff every subset with more than n
elements contains an element not satisfying P
(#9048)
@@ -267,6 +267,11 @@ theorem fiber_card_ne_zero_iff_mem_image (s : Finset α) (f : α → β) [Decida
rw [← pos_iff_ne_zero, card_pos, fiber_nonempty_iff_mem_image]
#align finset.fiber_card_ne_zero_iff_mem_image Finset.fiber_card_ne_zero_iff_mem_image
+lemma card_filter_le_iff (s : Finset α) (P : α → Prop) [DecidablePred P] (n : ℕ) :
+ (s.filter P).card ≤ n ↔ ∀ s' ⊆ s, n < s'.card → ∃ a ∈ s', ¬ P a :=
+ (s.1.card_filter_le_iff P n).trans ⟨fun H s' hs' h ↦ H s'.1 (by aesop) h,
+ fun H s' hs' h ↦ H ⟨s', nodup_of_le hs' s.2⟩ (fun x hx ↦ subset_of_le hs' hx) h⟩
+
@[simp]
theorem card_map (f : α ↪ β) : (s.map f).card = s.card :=
Multiset.card_map _ _
Forward port https://github.com/leanprover-community/mathlib/pull/19203
@@ -588,6 +588,12 @@ theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x
exact card_le_of_subset hx
#align finset.card_le_one_iff_subset_singleton Finset.card_le_one_iff_subset_singleton
+lemma exists_mem_ne (hs : 1 < s.card) (a : α) : ∃ b ∈ s, b ≠ a := by
+ have : Nonempty α := ⟨a⟩
+ by_contra!
+ exact hs.not_le (card_le_one_iff_subset_singleton.2 ⟨a, subset_singleton_iff'.2 this⟩)
+#align finset.exists_mem_ne Finset.exists_mem_ne
+
/-- A `Finset` of a subsingleton type has cardinality at most one. -/
theorem card_le_one_of_subsingleton [Subsingleton α] (s : Finset α) : s.card ≤ 1 :=
Finset.card_le_one_iff.2 fun {_ _ _ _} => Subsingleton.elim _ _
Characterise IsAtom
, IsCoatom
, Covby
in Set α
, Multiset α
, Finset α
and deduce that Multiset α
, Finset α
are graded orders.
Note I am moving some existing characterisations to here because it makes sense thematically, but I could be convinced otherwise.
@@ -308,6 +308,8 @@ theorem card_lt_card (h : s ⊂ t) : s.card < t.card :=
card_lt_of_lt <| val_lt_iff.2 h
#align finset.card_lt_card Finset.card_lt_card
+lemma card_strictMono : StrictMono (card : Finset α → ℕ) := fun _ _ ↦ card_lt_card
+
theorem card_eq_of_bijective (f : ∀ i, i < n → α) (hf : ∀ a ∈ s, ∃ i, ∃ h : i < n, f i h = a)
(hf' : ∀ (i) (h : i < n), f i h ∈ s)
(f_inj : ∀ (i j) (hi : i < n) (hj : j < n), f i hi = f j hj → i = j) : s.card = n := by
@@ -677,16 +679,6 @@ theorem card_eq_three : s.card = 3 ↔ ∃ x y z, x ≠ y ∧ x ≠ z ∧ y ≠
or_self_iff, card_singleton]
#align finset.card_eq_three Finset.card_eq_three
-lemma covby_iff_card_sdiff_eq_one : t ⋖ s ↔ t ⊆ s ∧ (s \ t).card = 1 := by
- rw [covby_iff_exists_insert]
- constructor
- · rintro ⟨a, ha, rfl⟩
- simp [*]
- · simp_rw [card_eq_one]
- rintro ⟨hts, a, ha⟩
- refine ⟨a, (mem_sdiff.1 $ superset_of_eq ha $ mem_singleton_self _).2, ?_⟩
- rw [insert_eq, ← ha, sdiff_union_of_subset hts]
-
end DecidableEq
/-! ### Inductions -/
@@ -358,7 +358,7 @@ theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s
theorem exists_ne_map_eq_of_card_lt_of_maps_to {t : Finset β} (hc : t.card < s.card) {f : α → β}
(hf : ∀ a ∈ s, f a ∈ t) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y := by
classical
- by_contra' hz
+ by_contra! hz
refine' hc.not_le (card_le_card_of_inj_on f hf _)
intro x hx y hy
contrapose
@@ -473,7 +473,7 @@ theorem card_sdiff_add_card : (s \ t).card + t.card = (s ∪ t).card := by
#align finset.card_sdiff_add_card Finset.card_sdiff_add_card
lemma card_sdiff_comm (h : s.card = t.card) : (s \ t).card = (t \ s).card :=
- add_left_injective t.card $ by simp_rw [card_sdiff_add_card, ←h, card_sdiff_add_card, union_comm]
+ add_left_injective t.card $ by simp_rw [card_sdiff_add_card, ← h, card_sdiff_add_card, union_comm]
@[simp]
lemma card_sdiff_add_card_inter (s t : Finset α) :
@@ -507,7 +507,7 @@ theorem exists_intermediate_set {A B : Finset α} (i : ℕ) (h₁ : i + card B
apply Nat.succ_pos
have z : i + card B + k = card (erase A a) := by
rw [card_erase_of_mem (mem_sdiff.1 ha).1, ← h,
- Nat.add_sub_assoc (Nat.one_le_iff_ne_zero.mpr k.succ_ne_zero), ←pred_eq_sub_one,
+ Nat.add_sub_assoc (Nat.one_le_iff_ne_zero.mpr k.succ_ne_zero), ← pred_eq_sub_one,
k.pred_succ]
have : B ⊆ A.erase a := by
rintro t th
@@ -685,7 +685,7 @@ lemma covby_iff_card_sdiff_eq_one : t ⋖ s ↔ t ⊆ s ∧ (s \ t).card = 1 :=
· simp_rw [card_eq_one]
rintro ⟨hts, a, ha⟩
refine ⟨a, (mem_sdiff.1 $ superset_of_eq ha $ mem_singleton_self _).2, ?_⟩
- rw [insert_eq, ←ha, sdiff_union_of_subset hts]
+ rw [insert_eq, ← ha, sdiff_union_of_subset hts]
end DecidableEq
Multiset.toFinset_card_eq_card_iff_nodup
which is converse to Multiset.toFinset_card_of_nodup
(credits: @Ruben-VandeVelde)Finset.card_eq_of_equiv_fin
and Finset.card_eq_of_equiv
which are converse to Finset.equivFinOfCardEq
and Finset.equivOfCardEq
, respectively. I'm not sure for the necessarily of these two, since they are also easy corollaries of Fintype.card_eq
and Fintype.card_coe
.@@ -205,6 +205,13 @@ theorem Multiset.toFinset_card_of_nodup {m : Multiset α} (h : m.Nodup) :
congr_arg card <| Multiset.dedup_eq_self.mpr h
#align multiset.to_finset_card_of_nodup Multiset.toFinset_card_of_nodup
+theorem Multiset.dedup_card_eq_card_iff_nodup {m : Multiset α} :
+ card m.dedup = card m ↔ m.Nodup :=
+ .trans ⟨fun h ↦ eq_of_le_of_card_le (dedup_le m) h.ge, congr_arg _⟩ dedup_eq_self
+
+theorem Multiset.toFinset_card_eq_card_iff_nodup {m : Multiset α} :
+ m.toFinset.card = card m ↔ m.Nodup := dedup_card_eq_card_iff_nodup
+
theorem List.card_toFinset : l.toFinset.card = l.dedup.length :=
rfl
#align list.card_to_finset List.card_toFinset
attach
and filter
lemmas (#1470)
Match https://github.com/leanprover-community/mathlib/pull/18087
@@ -6,7 +6,7 @@ Authors: Leonardo de Moura, Jeremy Avigad
import Mathlib.Init.CCLemmas
import Mathlib.Data.Finset.Image
-#align_import data.finset.card from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
+#align_import data.finset.card from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83"
/-!
# Cardinality of a finite set
@@ -48,6 +48,9 @@ theorem card_def (s : Finset α) : s.card = Multiset.card s.1 :=
rfl
#align finset.card_def Finset.card_def
+@[simp] lemma card_val (s : Finset α) : Multiset.card s.1 = s.card := rfl
+#align finset.card_val Finset.card_val
+
@[simp]
theorem card_mk {m nodup} : (⟨m, nodup⟩ : Finset α).card = Multiset.card m :=
rfl
@@ -465,6 +465,16 @@ theorem card_sdiff_add_card : (s \ t).card + t.card = (s ∪ t).card := by
lemma card_sdiff_comm (h : s.card = t.card) : (s \ t).card = (t \ s).card :=
add_left_injective t.card $ by simp_rw [card_sdiff_add_card, ←h, card_sdiff_add_card, union_comm]
+@[simp]
+lemma card_sdiff_add_card_inter (s t : Finset α) :
+ (s \ t).card + (s ∩ t).card = s.card := by
+ rw [← card_disjoint_union (disjoint_sdiff_inter _ _), sdiff_union_inter]
+
+@[simp]
+lemma card_inter_add_card_sdiff (s t : Finset α) :
+ (s ∩ t).card + (s \ t).card = s.card := by
+ rw [add_comm, card_sdiff_add_card_inter]
+
end Lattice
theorem filter_card_add_filter_neg_card_eq_card
Move the lemmas characterising Covby
on Finset α
from Data.Finset.Interval
to Data.Finset.Basic
. Golf the other proofs in Data.Finset.Interval
and make sure the lemma names reflect whether each lemma is about insert
or cons
.
@@ -624,8 +624,10 @@ lemma exists_of_one_lt_card_pi {ι : Type*} {α : ι → Type*} [∀ i, Decidabl
obtain rfl | hne := eq_or_ne (a2 i) ai
exacts [⟨a1, h1, hne⟩, ⟨a2, h2, hne⟩]
-theorem card_eq_succ [DecidableEq α] :
- s.card = n + 1 ↔ ∃ a t, a ∉ t ∧ insert a t = s ∧ t.card = n :=
+section DecidableEq
+variable [DecidableEq α]
+
+theorem card_eq_succ : s.card = n + 1 ↔ ∃ a t, a ∉ t ∧ insert a t = s ∧ t.card = n :=
⟨fun h =>
let ⟨a, has⟩ := card_pos.mp (h.symm ▸ Nat.zero_lt_succ _ : 0 < s.card)
⟨a, s.erase a, s.not_mem_erase a, insert_erase has, by
@@ -633,7 +635,7 @@ theorem card_eq_succ [DecidableEq α] :
fun ⟨a, t, hat, s_eq, n_eq⟩ => s_eq ▸ n_eq ▸ card_insert_of_not_mem hat⟩
#align finset.card_eq_succ Finset.card_eq_succ
-theorem card_eq_two [DecidableEq α] : s.card = 2 ↔ ∃ x y, x ≠ y ∧ s = {x, y} := by
+theorem card_eq_two : s.card = 2 ↔ ∃ x y, x ≠ y ∧ s = {x, y} := by
constructor
· rw [card_eq_succ]
simp_rw [card_eq_one]
@@ -643,8 +645,7 @@ theorem card_eq_two [DecidableEq α] : s.card = 2 ↔ ∃ x y, x ≠ y ∧ s = {
exact card_doubleton h
#align finset.card_eq_two Finset.card_eq_two
-theorem card_eq_three [DecidableEq α] :
- s.card = 3 ↔ ∃ x y z, x ≠ y ∧ x ≠ z ∧ y ≠ z ∧ s = {x, y, z} := by
+theorem card_eq_three : s.card = 3 ↔ ∃ x y z, x ≠ y ∧ x ≠ z ∧ y ≠ z ∧ s = {x, y, z} := by
constructor
· rw [card_eq_succ]
simp_rw [card_eq_two]
@@ -656,6 +657,18 @@ theorem card_eq_three [DecidableEq α] :
or_self_iff, card_singleton]
#align finset.card_eq_three Finset.card_eq_three
+lemma covby_iff_card_sdiff_eq_one : t ⋖ s ↔ t ⊆ s ∧ (s \ t).card = 1 := by
+ rw [covby_iff_exists_insert]
+ constructor
+ · rintro ⟨a, ha, rfl⟩
+ simp [*]
+ · simp_rw [card_eq_one]
+ rintro ⟨hts, a, ha⟩
+ refine ⟨a, (mem_sdiff.1 $ superset_of_eq ha $ mem_singleton_self _).2, ?_⟩
+ rw [insert_eq, ←ha, sdiff_union_of_subset hts]
+
+end DecidableEq
+
/-! ### Inductions -/
@@ -462,6 +462,9 @@ theorem card_sdiff_add_card : (s \ t).card + t.card = (s ∪ t).card := by
rw [← card_disjoint_union sdiff_disjoint, sdiff_union_self_eq_union]
#align finset.card_sdiff_add_card Finset.card_sdiff_add_card
+lemma card_sdiff_comm (h : s.card = t.card) : (s \ t).card = (t \ s).card :=
+ add_left_injective t.card $ by simp_rw [card_sdiff_add_card, ←h, card_sdiff_add_card, union_comm]
+
end Lattice
theorem filter_card_add_filter_neg_card_eq_card
@@ -130,11 +130,22 @@ theorem card_doubleton (h : a ≠ b) : ({a, b} : Finset α).card = 2 := by
rw [card_insert_of_not_mem (not_mem_singleton.2 h), card_singleton]
#align finset.card_doubleton Finset.card_doubleton
+/-- $\#(s \setminus \{a\}) = \#s - 1$ if $a \in s$. -/
@[simp]
theorem card_erase_of_mem : a ∈ s → (s.erase a).card = s.card - 1 :=
Multiset.card_erase_of_mem
#align finset.card_erase_of_mem Finset.card_erase_of_mem
+/-- $\#(s \setminus \{a\}) = \#s - 1$ if $a \in s$.
+ This result is casted to any additive group with 1,
+ so that we don't have to work with `ℕ`-subtraction. -/
+@[simp]
+theorem cast_card_erase_of_mem {R} [AddGroupWithOne R] {s : Finset α} (hs : a ∈ s) :
+ ((s.erase a).card : R) = s.card - 1 := by
+ rw [card_erase_of_mem hs, Nat.cast_sub, Nat.cast_one]
+ rw [Nat.add_one_le_iff, Finset.card_pos]
+ exact ⟨a, hs⟩
+
@[simp]
theorem card_erase_add_one : a ∈ s → (s.erase a).card + 1 = s.card :=
Multiset.card_erase_add_one
@@ -597,6 +597,19 @@ theorem exists_ne_of_one_lt_card (hs : 1 < s.card) (a : α) : ∃ b, b ∈ s ∧
· exact ⟨y, hy, ha⟩
#align finset.exists_ne_of_one_lt_card Finset.exists_ne_of_one_lt_card
+/-- If a Finset in a Pi type is nontrivial (has at least two elements), then
+ its projection to some factor is nontrivial, and the fibers of the projection
+ are proper subsets. -/
+lemma exists_of_one_lt_card_pi {ι : Type*} {α : ι → Type*} [∀ i, DecidableEq (α i)]
+ {s : Finset (∀ i, α i)} (h : 1 < s.card) :
+ ∃ i, 1 < (s.image (· i)).card ∧ ∀ ai, s.filter (· i = ai) ⊂ s := by
+ simp_rw [one_lt_card_iff, Function.ne_iff] at h ⊢
+ obtain ⟨a1, a2, h1, h2, i, hne⟩ := h
+ refine ⟨i, ⟨_, _, mem_image_of_mem _ h1, mem_image_of_mem _ h2, hne⟩, fun ai => ?_⟩
+ rw [filter_ssubset]
+ obtain rfl | hne := eq_or_ne (a2 i) ai
+ exacts [⟨a1, h1, hne⟩, ⟨a2, h2, hne⟩]
+
theorem card_eq_succ [DecidableEq α] :
s.card = n + 1 ↔ ∃ a t, a ∉ t ∧ insert a t = s ∧ t.card = n :=
⟨fun h =>
Finset.card_le_one_iff_subsingleton
and Finset.one_lt_card_iff_nontrivial
(#7131)
The versions for Fintype
already exist but are missing for Finset
.
@@ -539,6 +539,9 @@ theorem card_le_one_iff : s.card ≤ 1 ↔ ∀ {a b}, a ∈ s → b ∈ s → a
tauto
#align finset.card_le_one_iff Finset.card_le_one_iff
+theorem card_le_one_iff_subsingleton_coe : s.card ≤ 1 ↔ Subsingleton (s : Type _) :=
+ card_le_one.trans (s : Set α).subsingleton_coe.symm
+
theorem card_le_one_iff_subset_singleton [Nonempty α] : s.card ≤ 1 ↔ ∃ x : α, s ⊆ {x} := by
refine' ⟨fun H => _, _⟩
· obtain rfl | ⟨x, hx⟩ := s.eq_empty_or_nonempty
@@ -565,6 +568,9 @@ theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠
simp only [exists_prop, exists_and_left]
#align finset.one_lt_card_iff Finset.one_lt_card_iff
+theorem one_lt_card_iff_nontrivial_coe : 1 < s.card ↔ Nontrivial (s : Type _) := by
+ rw [← not_iff_not, not_lt, not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton_coe]
+
theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c ∈ s ∧ a ≠ b ∧ a ≠ c ∧ b ≠ c := by
classical
refine' ⟨fun h => _, _⟩
@@ -3,6 +3,7 @@ Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Jeremy Avigad
-/
+import Mathlib.Init.CCLemmas
import Mathlib.Data.Finset.Image
#align_import data.finset.card from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
@@ -74,7 +74,7 @@ theorem card_pos : 0 < s.card ↔ s.Nonempty :=
pos_iff_ne_zero.trans <| (not_congr card_eq_zero).trans nonempty_iff_ne_empty.symm
#align finset.card_pos Finset.card_pos
-alias card_pos ↔ _ Nonempty.card_pos
+alias ⟨_, Nonempty.card_pos⟩ := card_pos
#align finset.nonempty.card_pos Finset.Nonempty.card_pos
theorem card_ne_zero_of_mem (h : a ∈ s) : s.card ≠ 0 :=
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -32,7 +32,7 @@ Should we add a noncomputable version?
open Function Multiset Nat
-variable {α β : Type _}
+variable {α β : Type*}
namespace Finset
@@ -628,7 +628,7 @@ theorem card_eq_three [DecidableEq α] :
/-- Suppose that, given objects defined on all strict subsets of any finset `s`, one knows how to
define an object on `s`. Then one can inductively define an object on all finsets, starting from
the empty set and iterating. This can be used either to define data, or to prove properties. -/
-def strongInduction {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) :
+def strongInduction {p : Finset α → Sort*} (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) :
∀ s : Finset α, p s
| s =>
H s fun t h =>
@@ -638,19 +638,19 @@ def strongInduction {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s
#align finset.strong_induction Finset.strongInduction
@[nolint unusedHavesSuffices] --Porting note: false positive
-theorem strongInduction_eq {p : Finset α → Sort _} (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s)
+theorem strongInduction_eq {p : Finset α → Sort*} (H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s)
(s : Finset α) : strongInduction H s = H s fun t _ => strongInduction H t := by
rw [strongInduction]
#align finset.strong_induction_eq Finset.strongInduction_eq
/-- Analogue of `strongInduction` with order of arguments swapped. -/
@[elab_as_elim]
-def strongInductionOn {p : Finset α → Sort _} (s : Finset α) :
+def strongInductionOn {p : Finset α → Sort*} (s : Finset α) :
(∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) → p s := fun H => strongInduction H s
#align finset.strong_induction_on Finset.strongInductionOn
@[nolint unusedHavesSuffices] --Porting note: false positive
-theorem strongInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
+theorem strongInductionOn_eq {p : Finset α → Sort*} (s : Finset α)
(H : ∀ s, (∀ (t) (_ : t ⊂ s), p t) → p s) :
s.strongInductionOn H = H s fun t _ => t.strongInductionOn H := by
dsimp only [strongInductionOn]
@@ -669,7 +669,7 @@ theorem case_strong_induction_on [DecidableEq α] {p : Finset α → Prop} (s :
`n`, one knows how to define `p s`. Then one can inductively define `p s` for all finsets `s` of
cardinality less than `n`, starting from finsets of card `n` and iterating. This
can be used either to define data, or to prove properties. -/
-def strongDownwardInduction {p : Finset α → Sort _} {n : ℕ}
+def strongDownwardInduction {p : Finset α → Sort*} {n : ℕ}
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
∀ s : Finset α, s.card ≤ n → p s
| s =>
@@ -680,7 +680,7 @@ def strongDownwardInduction {p : Finset α → Sort _} {n : ℕ}
#align finset.strong_downward_induction Finset.strongDownwardInduction
@[nolint unusedHavesSuffices] --Porting note: false positive
-theorem strongDownwardInduction_eq {p : Finset α → Sort _}
+theorem strongDownwardInduction_eq {p : Finset α → Sort*}
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁)
(s : Finset α) :
strongDownwardInduction H s = H s fun {t} ht _ => strongDownwardInduction H t ht := by
@@ -689,14 +689,14 @@ theorem strongDownwardInduction_eq {p : Finset α → Sort _}
/-- Analogue of `strongDownwardInduction` with order of arguments swapped. -/
@[elab_as_elim]
-def strongDownwardInductionOn {p : Finset α → Sort _} (s : Finset α)
+def strongDownwardInductionOn {p : Finset α → Sort*} (s : Finset α)
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
s.card ≤ n → p s :=
strongDownwardInduction H s
#align finset.strong_downward_induction_on Finset.strongDownwardInductionOn
@[nolint unusedHavesSuffices] --Porting note: false positive
-theorem strongDownwardInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
+theorem strongDownwardInductionOn_eq {p : Finset α → Sort*} (s : Finset α)
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
s.strongDownwardInductionOn H = H s fun {t} ht _ => t.strongDownwardInductionOn H ht := by
dsimp only [strongDownwardInductionOn]
ListM
has been moved to Std
and renamed as MLList
.
There are some slight API functions, that ensure operations are lazy, requiring the addition of some fun _ =>
here in Mathlib.
Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Mario Carneiro <di.gama@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Bulhwi Cha <chabulhwi@semmalgil.com>
@@ -173,7 +173,7 @@ theorem card_attach : s.attach.card = s.card :=
end Finset
-section ToListMultiset
+section ToMLListultiset
variable [DecidableEq α] (m : Multiset α) (l : List α)
@@ -202,7 +202,7 @@ theorem List.toFinset_card_of_nodup {l : List α} (h : l.Nodup) : l.toFinset.car
Multiset.toFinset_card_of_nodup h
#align list.to_finset_card_of_nodup List.toFinset_card_of_nodup
-end ToListMultiset
+end ToMLListultiset
namespace Finset
@@ -2,14 +2,11 @@
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura, Jeremy Avigad
-
-! This file was ported from Lean 3 source module data.finset.card
-! 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.Image
+#align_import data.finset.card from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
+
/-!
# Cardinality of a finite set
@@ -293,7 +293,7 @@ theorem card_eq_of_bijective (f : ∀ i, i < n → α) (hf : ∀ a ∈ s, ∃ i,
(hf' : ∀ (i) (h : i < n), f i h ∈ s)
(f_inj : ∀ (i j) (hi : i < n) (hj : j < n), f i hi = f j hj → i = j) : s.card = n := by
classical
- have : ∀ a : α, a ∈ s ↔ ∃ (i : _)(hi : i ∈ range n), f i (mem_range.1 hi) = a := fun a =>
+ have : ∀ a : α, a ∈ s ↔ ∃ (i : _) (hi : i ∈ range n), f i (mem_range.1 hi) = a := fun a =>
⟨fun ha =>
let ⟨i, hi, eq⟩ := hf a ha
⟨i, mem_range.2 hi, eq⟩,
@@ -513,7 +513,7 @@ theorem card_eq_one : s.card = 1 ↔ ∃ a, s = {a} := by
#align finset.card_eq_one Finset.card_eq_one
theorem exists_eq_insert_iff [DecidableEq α] {s t : Finset α} :
- (∃ (a : _)(_ : a ∉ s), insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
+ (∃ (a : _) (_ : a ∉ s), insert a s = t) ↔ s ⊆ t ∧ s.card + 1 = t.card := by
constructor
· rintro ⟨a, ha, rfl⟩
exact ⟨subset_insert _ _, (card_insert_of_not_mem ha).symm⟩
This makes a mathlib4 version of mathlib3's tactic.basic
, now called Mathlib.Tactic.Common
, which imports all tactics which do not have significant theory requirements, and then is imported all across the base of the hierarchy.
This ensures that all common tactics are available nearly everywhere in the library, rather than having to be imported one-by-one as you need them.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -9,7 +9,6 @@ Authors: Leonardo de Moura, Jeremy Avigad
! if you have ported upstream changes.
-/
import Mathlib.Data.Finset.Image
-import Mathlib.Tactic.ByContra
/-!
# Cardinality of a finite set
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".
@@ -495,8 +495,7 @@ theorem exists_smaller_set (A : Finset α) (i : ℕ) (h₁ : i ≤ card A) :
#align finset.exists_smaller_set Finset.exists_smaller_set
theorem exists_subset_or_subset_of_two_mul_lt_card [DecidableEq α] {X Y : Finset α} {n : ℕ}
- (hXY : 2 * n < (X ∪ Y).card) : ∃ C : Finset α, n < C.card ∧ (C ⊆ X ∨ C ⊆ Y) :=
- by
+ (hXY : 2 * n < (X ∪ Y).card) : ∃ C : Finset α, n < C.card ∧ (C ⊆ X ∨ C ⊆ Y) := by
have h₁ : (X ∩ (Y \ X)).card = 0 := Finset.card_eq_zero.mpr (Finset.inter_sdiff_self X Y)
have h₂ : (X ∪ Y).card = X.card + (Y \ X).card := by
rw [← card_union_add_card_inter X (Y \ X), Finset.union_sdiff_self_eq_union, h₁, add_zero]
@@ -564,8 +563,7 @@ theorem one_lt_card : 1 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, a ≠ b := by
exact card_le_one
#align finset.one_lt_card Finset.one_lt_card
-theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b :=
- by
+theorem one_lt_card_iff : 1 < s.card ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b := by
rw [one_lt_card]
simp only [exists_prop, exists_and_left]
#align finset.one_lt_card_iff Finset.one_lt_card_iff
@@ -704,8 +702,7 @@ def strongDownwardInductionOn {p : Finset α → Sort _} (s : Finset α)
@[nolint unusedHavesSuffices] --Porting note: false positive
theorem strongDownwardInductionOn_eq {p : Finset α → Sort _} (s : Finset α)
(H : ∀ t₁, (∀ {t₂ : Finset α}, t₂.card ≤ n → t₁ ⊂ t₂ → p t₂) → t₁.card ≤ n → p t₁) :
- s.strongDownwardInductionOn H = H s fun {t} ht _ => t.strongDownwardInductionOn H ht :=
- by
+ s.strongDownwardInductionOn H = H s fun {t} ht _ => t.strongDownwardInductionOn H ht := by
dsimp only [strongDownwardInductionOn]
rw [strongDownwardInduction]
#align finset.strong_downward_induction_on_eq Finset.strongDownwardInductionOn_eq
closes #3680, see https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/Stepping.20through.20simp_rw/near/326712986
@@ -586,7 +586,7 @@ theorem two_lt_card_iff : 2 < s.card ↔ ∃ a b c, a ∈ s ∧ b ∈ s ∧ c
#align finset.two_lt_card_iff Finset.two_lt_card_iff
theorem two_lt_card : 2 < s.card ↔ ∃ a ∈ s, ∃ b ∈ s, ∃ c ∈ s, a ≠ b ∧ a ≠ c ∧ b ≠ c := by
- simp_rw [two_lt_card_iff, exists_prop, exists_and_left]
+ simp_rw [two_lt_card_iff, exists_and_left]
#align finset.two_lt_card Finset.two_lt_card
theorem exists_ne_of_one_lt_card (hs : 1 < s.card) (a : α) : ∃ b, b ∈ s ∧ b ≠ a := by
This PR fixes two things:
align
statements for definitions and theorems and instances that are separated by two newlines from the relevant declaration (s/\n\n#align/\n#align
). This is often seen in the mathport output after ending calc
blocks.#align
statements. (This was needed for a script I wrote for #3630.)@@ -333,7 +333,6 @@ theorem card_le_card_of_inj_on {t : Finset β} (f : α → β) (hf : ∀ a ∈ s
classical calc
s.card = (s.image f).card := (card_image_of_injOn f_inj).symm
_ ≤ t.card := card_le_of_subset <| image_subset_iff.2 hf
-
#align finset.card_le_card_of_inj_on Finset.card_le_card_of_inj_on
/-- If there are more pigeons than pigeonholes, then there are two pigeons in the same pigeonhole.
@@ -353,7 +352,6 @@ theorem le_card_of_inj_on_range (f : ℕ → α) (hf : ∀ i < n, f i ∈ s)
calc
n = card (range n) := (card_range n).symm
_ ≤ s.card := card_le_card_of_inj_on f (by simpa only [mem_range] ) (by simpa only [mem_range] )
-
#align finset.le_card_of_inj_on_range Finset.le_card_of_inj_on_range
theorem surj_on_of_inj_on_of_card_le {t : Finset β} (f : ∀ a ∈ s, β) (hf : ∀ a ha, f a ha ∈ t)
@@ -446,7 +444,6 @@ theorem le_card_sdiff (s t : Finset α) : t.card - s.card ≤ card (t \ s) :=
tsub_le_tsub_left (card_le_of_subset (inter_subset_left s t)) _
_ = card (t \ (s ∩ t)) := (card_sdiff (inter_subset_right s t)).symm
_ ≤ card (t \ s) := by rw [sdiff_inter_self_right t s]
-
#align finset.le_card_sdiff Finset.le_card_sdiff
theorem card_le_card_sdiff_add_card : s.card ≤ (s \ t).card + t.card :=
This is an extremely partial port of the mono*
tactic from Lean 3, implemented as a macro on top of solve_by_elim
. The original mono
had many configuration options and no documentation, so quite a bit is missing (and almost all the Lean 3 tests fail). Nonetheless I think it's worth merging this, because
@[mono]
mono
will succeed fairly often in the port even though it fails nearly all the testsCo-authored-by: thorimur <68410468+thorimur@users.noreply.github.com>
@@ -65,7 +65,7 @@ theorem card_le_of_subset : s ⊆ t → s.card ≤ t.card :=
Multiset.card_le_of_le ∘ val_le_iff.mpr
#align finset.card_le_of_subset Finset.card_le_of_subset
--- Porting note: no @[mono]
+@[mono]
theorem card_mono : Monotone (@card α) := by apply card_le_of_subset
#align finset.card_mono Finset.card_mono
@@ -18,7 +18,7 @@ This defines the cardinality of a `Finset` and provides induction principles for
## Main declarations
-* `Finset.card`: `s.card : ℕ` returns the cardinality of `s : finset α`.
+* `Finset.card`: `s.card : ℕ` returns the cardinality of `s : Finset α`.
### Induction principles
IsTrans α r → Trans r r r
and Trans r r r → IsTrans α r
(#1522)
Now Trans.trans
conflicts with _root_.trans
.
@@ -487,7 +487,7 @@ theorem exists_intermediate_set {A B : Finset α} (i : ℕ) (h₁ : i + card B
rintro rfl
exact not_mem_sdiff_of_mem_right th ha
rcases ih this z with ⟨B', hB', B'subA', cards⟩
- exact ⟨B', hB', trans B'subA' (erase_subset _ _), cards⟩
+ exact ⟨B', hB', B'subA'.trans (erase_subset _ _), cards⟩
#align finset.exists_intermediate_set Finset.exists_intermediate_set
/-- We can shrink `A` to any smaller size. -/
@@ -463,8 +463,7 @@ theorem filter_card_add_filter_neg_card_eq_card
(p : α → Prop) [DecidablePred p] [∀ x, Decidable (¬p x)] :
(s.filter p).card + (s.filter (fun a => ¬ p a)).card = s.card := by
classical rw [← card_union_eq (disjoint_filter_filter_neg _ _ _), filter_union_filter_neg_eq]
-#align finset.filter_card_add_filter_neg_card_eq_card
- Finset.filter_card_add_filter_neg_card_eq_card
+#align finset.filter_card_add_filter_neg_card_eq_card Finset.filter_card_add_filter_neg_card_eq_card
/-- Given a set `A` and a set `B` inside it, we can shrink `A` to any appropriate size, and keep `B`
inside it. -/
@@ -508,9 +507,7 @@ theorem exists_subset_or_subset_of_two_mul_lt_card [DecidableEq α] {X Y : Finse
rcases lt_or_lt_of_add_lt_add hXY with (h | h)
· exact ⟨X, h, Or.inl (Finset.Subset.refl X)⟩
· exact ⟨Y \ X, h, Or.inr (Finset.sdiff_subset Y X)⟩
-#align
- finset.exists_subset_or_subset_of_two_mul_lt_card
- Finset.exists_subset_or_subset_of_two_mul_lt_card
+#align finset.exists_subset_or_subset_of_two_mul_lt_card Finset.exists_subset_or_subset_of_two_mul_lt_card
/-! ### Explicit description of a finset from its card -/
@@ -282,7 +282,7 @@ theorem map_eq_of_subset {f : α ↪ α} (hs : s.map f ⊆ s) : s.map f = s :=
theorem filter_card_eq {p : α → Prop} [DecidablePred p] (h : (s.filter p).card = s.card) (x : α)
(hx : x ∈ s) : p x := by
- rw [← eq_of_subset_of_card_le (s.filter_subset p) h.ge, mem_filter, decide_eq_true_eq] at hx
+ rw [← eq_of_subset_of_card_le (s.filter_subset p) h.ge, mem_filter] at hx
exact hx.2
#align finset.filter_card_eq Finset.filter_card_eq
@@ -459,7 +459,8 @@ theorem card_sdiff_add_card : (s \ t).card + t.card = (s ∪ t).card := by
end Lattice
-theorem filter_card_add_filter_neg_card_eq_card (p : α → Bool) :
+theorem filter_card_add_filter_neg_card_eq_card
+ (p : α → Prop) [DecidablePred p] [∀ x, Decidable (¬p x)] :
(s.filter p).card + (s.filter (fun a => ¬ p a)).card = s.card := by
classical rw [← card_union_eq (disjoint_filter_filter_neg _ _ _), filter_union_filter_neg_eq]
#align finset.filter_card_add_filter_neg_card_eq_card
The unported dependencies are