data.finite.card
⟷
Mathlib.Data.Finite.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.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
@@ -158,6 +158,18 @@ by { haveI := fintype.of_finite α, simpa using fintype.card_subtype_lt hx }
end finite
+namespace part_enat
+
+lemma card_eq_coe_nat_card (α : Type*) [finite α] : card α = nat.card α :=
+begin
+ unfold part_enat.card,
+ apply symm,
+ rw cardinal.coe_nat_eq_to_part_enat_iff,
+ exact finite.cast_card_eq_mk ,
+end
+
+end part_enat
+
namespace set
lemma card_union_le (s t : set α) : nat.card ↥(s ∪ t) ≤ nat.card s + nat.card t :=
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(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
@@ -257,7 +257,7 @@ namespace Set
theorem card_union_le (s t : Set α) : Nat.card ↥(s ∪ t) ≤ Nat.card s + Nat.card t :=
by
cases' _root_.finite_or_infinite ↥(s ∪ t) with h h
- · rw [finite_coe_iff, finite_union, ← finite_coe_iff, ← finite_coe_iff] at h
+ · rw [finite_coe_iff, finite_union, ← finite_coe_iff, ← finite_coe_iff] at h
cases h
rw [← Cardinal.natCast_le, Nat.cast_add, Finite.cast_card_eq_mk, Finite.cast_card_eq_mk,
Finite.cast_card_eq_mk]
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,7 +3,7 @@ Copyright (c) 2022 Kyle Miller. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
-/
-import Mathbin.SetTheory.Cardinal.Finite
+import SetTheory.Cardinal.Finite
#align_import data.finite.card from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8"
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,14 +2,11 @@
Copyright (c) 2022 Kyle Miller. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
-
-! This file was ported from Lean 3 source module data.finite.card
-! leanprover-community/mathlib commit 3ff3f2d6a3118b8711063de7111a0d77a53219a8
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.SetTheory.Cardinal.Finite
+#align_import data.finite.card from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8"
+
/-!
# Cardinality of finite types
mathlib commit https://github.com/leanprover-community/mathlib/commit/8b981918a93bc45a8600de608cde7944a80d92b9
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
! This file was ported from Lean 3 source module data.finite.card
-! leanprover-community/mathlib commit 34ee86e6a59d911a8e4f89b68793ee7577ae79c7
+! leanprover-community/mathlib commit 3ff3f2d6a3118b8711063de7111a0d77a53219a8
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -238,6 +238,22 @@ theorem card_subtype_lt [Finite α] {p : α → Prop} {x : α} (hx : ¬p x) :
end Finite
+namespace PartENat
+
+/- warning: part_enat.card_eq_coe_nat_card clashes with part_enat.card_of_finite -> PartENat.card_eq_coe_nat_card
+Case conversion may be inaccurate. Consider using '#align part_enat.card_eq_coe_nat_card PartENat.card_eq_coe_nat_cardₓ'. -/
+#print PartENat.card_eq_coe_nat_card /-
+theorem card_eq_coe_nat_card (α : Type _) [Finite α] : card α = Nat.card α :=
+ by
+ unfold PartENat.card
+ apply symm
+ rw [Cardinal.natCast_eq_toPartENat_iff]
+ exact Finite.cast_card_eq_mk
+#align part_enat.card_eq_coe_nat_card PartENat.card_eq_coe_nat_card
+-/
+
+end PartENat
+
namespace Set
#print Set.card_union_le /-
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -83,13 +83,17 @@ theorem Finite.card_pos [Finite α] [h : Nonempty α] : 0 < Nat.card α :=
namespace Finite
+#print Finite.cast_card_eq_mk /-
theorem cast_card_eq_mk {α : Type _} [Finite α] : ↑(Nat.card α) = Cardinal.mk α :=
Cardinal.cast_toNat_of_lt_aleph0 (Cardinal.lt_aleph0_of_finite α)
#align finite.cast_card_eq_mk Finite.cast_card_eq_mk
+-/
+#print Finite.card_eq /-
theorem card_eq [Finite α] [Finite β] : Nat.card α = Nat.card β ↔ Nonempty (α ≃ β) := by
haveI := Fintype.ofFinite α; haveI := Fintype.ofFinite β; simp [Fintype.card_eq]
#align finite.card_eq Finite.card_eq
+-/
#print Finite.card_le_one_iff_subsingleton /-
theorem card_le_one_iff_subsingleton [Finite α] : Nat.card α ≤ 1 ↔ Subsingleton α := by
@@ -130,11 +134,13 @@ theorem card_le_of_embedding [Finite β] (f : α ↪ β) : Nat.card α ≤ Nat.c
#align finite.card_le_of_embedding Finite.card_le_of_embedding
-/
+#print Finite.card_le_of_surjective /-
theorem card_le_of_surjective [Finite α] (f : α → β) (hf : Function.Surjective f) :
Nat.card β ≤ Nat.card α := by
haveI := Fintype.ofFinite α; haveI := Fintype.ofSurjective f hf
simpa using Fintype.card_le_of_surjective f hf
#align finite.card_le_of_surjective Finite.card_le_of_surjective
+-/
#print Finite.card_eq_zero_iff /-
theorem card_eq_zero_iff [Finite α] : Nat.card α = 0 ↔ IsEmpty α := by haveI := Fintype.ofFinite α;
@@ -142,6 +148,7 @@ theorem card_eq_zero_iff [Finite α] : Nat.card α = 0 ↔ IsEmpty α := by have
#align finite.card_eq_zero_iff Finite.card_eq_zero_iff
-/
+#print Finite.card_le_of_injective' /-
/-- If `f` is injective, then `nat.card α ≤ nat.card β`. We must also assume
`nat.card β = 0 → nat.card α = 0` since `nat.card` is defined to be `0` for infinite types. -/
theorem card_le_of_injective' {f : α → β} (hf : Function.Injective f)
@@ -149,14 +156,18 @@ theorem card_le_of_injective' {f : α → β} (hf : Function.Injective f)
(or_not_of_imp h).casesOn (fun h => le_of_eq_of_le h zero_le') fun h =>
@card_le_of_injective α β (Nat.finite_of_card_ne_zero h) f hf
#align finite.card_le_of_injective' Finite.card_le_of_injective'
+-/
+#print Finite.card_le_of_embedding' /-
/-- If `f` is an embedding, then `nat.card α ≤ nat.card β`. We must also assume
`nat.card β = 0 → nat.card α = 0` since `nat.card` is defined to be `0` for infinite types. -/
theorem card_le_of_embedding' (f : α ↪ β) (h : Nat.card β = 0 → Nat.card α = 0) :
Nat.card α ≤ Nat.card β :=
card_le_of_injective' f.2 h
#align finite.card_le_of_embedding' Finite.card_le_of_embedding'
+-/
+#print Finite.card_le_of_surjective' /-
/-- If `f` is surjective, then `nat.card β ≤ nat.card α`. We must also assume
`nat.card α = 0 → nat.card β = 0` since `nat.card` is defined to be `0` for infinite types. -/
theorem card_le_of_surjective' {f : α → β} (hf : Function.Surjective f)
@@ -164,7 +175,9 @@ theorem card_le_of_surjective' {f : α → β} (hf : Function.Surjective f)
(or_not_of_imp h).casesOn (fun h => le_of_eq_of_le h zero_le') fun h =>
@card_le_of_surjective α β (Nat.finite_of_card_ne_zero h) f hf
#align finite.card_le_of_surjective' Finite.card_le_of_surjective'
+-/
+#print Finite.card_eq_zero_of_surjective /-
/-- NB: `nat.card` is defined to be `0` for infinite types. -/
theorem card_eq_zero_of_surjective {f : α → β} (hf : Function.Surjective f) (h : Nat.card β = 0) :
Nat.card α = 0 := by
@@ -175,29 +188,40 @@ theorem card_eq_zero_of_surjective {f : α → β} (hf : Function.Surjective f)
· haveI := Infinite.of_surjective f hf
exact Nat.card_eq_zero_of_infinite
#align finite.card_eq_zero_of_surjective Finite.card_eq_zero_of_surjective
+-/
+#print Finite.card_eq_zero_of_injective /-
/-- NB: `nat.card` is defined to be `0` for infinite types. -/
theorem card_eq_zero_of_injective [Nonempty α] {f : α → β} (hf : Function.Injective f)
(h : Nat.card α = 0) : Nat.card β = 0 :=
card_eq_zero_of_surjective (Function.invFun_surjective hf) h
#align finite.card_eq_zero_of_injective Finite.card_eq_zero_of_injective
+-/
+#print Finite.card_eq_zero_of_embedding /-
/-- NB: `nat.card` is defined to be `0` for infinite types. -/
theorem card_eq_zero_of_embedding [Nonempty α] (f : α ↪ β) (h : Nat.card α = 0) : Nat.card β = 0 :=
card_eq_zero_of_injective f.2 h
#align finite.card_eq_zero_of_embedding Finite.card_eq_zero_of_embedding
+-/
+#print Finite.card_sum /-
theorem card_sum [Finite α] [Finite β] : Nat.card (Sum α β) = Nat.card α + Nat.card β := by
haveI := Fintype.ofFinite α; haveI := Fintype.ofFinite β; simp
#align finite.card_sum Finite.card_sum
+-/
+#print Finite.card_image_le /-
theorem card_image_le {s : Set α} [Finite s] (f : α → β) : Nat.card (f '' s) ≤ Nat.card s :=
card_le_of_surjective _ Set.surjective_onto_image
#align finite.card_image_le Finite.card_image_le
+-/
+#print Finite.card_range_le /-
theorem card_range_le [Finite α] (f : α → β) : Nat.card (Set.range f) ≤ Nat.card α :=
card_le_of_surjective _ Set.surjective_onto_range
#align finite.card_range_le Finite.card_range_le
+-/
#print Finite.card_subtype_le /-
theorem card_subtype_le [Finite α] (p : α → Prop) : Nat.card { x // p x } ≤ Nat.card α := by
@@ -216,6 +240,7 @@ end Finite
namespace Set
+#print Set.card_union_le /-
theorem card_union_le (s t : Set α) : Nat.card ↥(s ∪ t) ≤ Nat.card s + Nat.card t :=
by
cases' _root_.finite_or_infinite ↥(s ∪ t) with h h
@@ -226,6 +251,7 @@ theorem card_union_le (s t : Set α) : Nat.card ↥(s ∪ t) ≤ Nat.card s + Na
exact Cardinal.mk_union_le s t
· exact nat.card_eq_zero_of_infinite.trans_le (zero_le _)
#align set.card_union_le Set.card_union_le
+-/
end Set
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -219,7 +219,7 @@ namespace Set
theorem card_union_le (s t : Set α) : Nat.card ↥(s ∪ t) ≤ Nat.card s + Nat.card t :=
by
cases' _root_.finite_or_infinite ↥(s ∪ t) with h h
- · rw [finite_coe_iff, finite_union, ← finite_coe_iff, ← finite_coe_iff] at h
+ · rw [finite_coe_iff, finite_union, ← finite_coe_iff, ← finite_coe_iff] at h
cases h
rw [← Cardinal.natCast_le, Nat.cast_add, Finite.cast_card_eq_mk, Finite.cast_card_eq_mk,
Finite.cast_card_eq_mk]
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -36,7 +36,7 @@ it. We generally put such theorems into the `set_theory.cardinal.finite` module.
noncomputable section
-open Classical
+open scoped Classical
variable {α β γ : Type _}
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -83,22 +83,10 @@ theorem Finite.card_pos [Finite α] [h : Nonempty α] : 0 < Nat.card α :=
namespace Finite
-/- warning: finite.cast_card_eq_mk -> Finite.cast_card_eq_mk is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α], Eq.{succ (succ u1)} Cardinal.{u1} ((fun (a : Type) (b : Type.{succ u1}) [self : HasLiftT.{1, succ (succ u1)} a b] => self.0) Nat Cardinal.{u1} (HasLiftT.mk.{1, succ (succ u1)} Nat Cardinal.{u1} (CoeTCₓ.coe.{1, succ (succ u1)} Nat Cardinal.{u1} (Nat.castCoe.{succ u1} Cardinal.{u1} Cardinal.hasNatCast.{u1}))) (Nat.card.{u1} α)) (Cardinal.mk.{u1} α)
-but is expected to have type
- forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α], Eq.{succ (succ u1)} Cardinal.{u1} (Nat.cast.{succ u1} Cardinal.{u1} Cardinal.instNatCastCardinal.{u1} (Nat.card.{u1} α)) (Cardinal.mk.{u1} α)
-Case conversion may be inaccurate. Consider using '#align finite.cast_card_eq_mk Finite.cast_card_eq_mkₓ'. -/
theorem cast_card_eq_mk {α : Type _} [Finite α] : ↑(Nat.card α) = Cardinal.mk α :=
Cardinal.cast_toNat_of_lt_aleph0 (Cardinal.lt_aleph0_of_finite α)
#align finite.cast_card_eq_mk Finite.cast_card_eq_mk
-/- warning: finite.card_eq -> Finite.card_eq is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : Finite.{succ u2} β], Iff (Eq.{1} Nat (Nat.card.{u1} α) (Nat.card.{u2} β)) (Nonempty.{max 1 (max (succ u1) (succ u2)) (succ u2) (succ u1)} (Equiv.{succ u1, succ u2} α β))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Finite.{succ u2} α] [_inst_2 : Finite.{succ u1} β], Iff (Eq.{1} Nat (Nat.card.{u2} α) (Nat.card.{u1} β)) (Nonempty.{max (succ u1) (succ u2)} (Equiv.{succ u2, succ u1} α β))
-Case conversion may be inaccurate. Consider using '#align finite.card_eq Finite.card_eqₓ'. -/
theorem card_eq [Finite α] [Finite β] : Nat.card α = Nat.card β ↔ Nonempty (α ≃ β) := by
haveI := Fintype.ofFinite α; haveI := Fintype.ofFinite β; simp [Fintype.card_eq]
#align finite.card_eq Finite.card_eq
@@ -142,12 +130,6 @@ theorem card_le_of_embedding [Finite β] (f : α ↪ β) : Nat.card α ≤ Nat.c
#align finite.card_le_of_embedding Finite.card_le_of_embedding
-/
-/- warning: finite.card_le_of_surjective -> Finite.card_le_of_surjective is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Finite.{succ u1} α] (f : α -> β), (Function.Surjective.{succ u1, succ u2} α β f) -> (LE.le.{0} Nat Nat.hasLe (Nat.card.{u2} β) (Nat.card.{u1} α))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Finite.{succ u2} α] (f : α -> β), (Function.Surjective.{succ u2, succ u1} α β f) -> (LE.le.{0} Nat instLENat (Nat.card.{u1} β) (Nat.card.{u2} α))
-Case conversion may be inaccurate. Consider using '#align finite.card_le_of_surjective Finite.card_le_of_surjectiveₓ'. -/
theorem card_le_of_surjective [Finite α] (f : α → β) (hf : Function.Surjective f) :
Nat.card β ≤ Nat.card α := by
haveI := Fintype.ofFinite α; haveI := Fintype.ofSurjective f hf
@@ -160,12 +142,6 @@ theorem card_eq_zero_iff [Finite α] : Nat.card α = 0 ↔ IsEmpty α := by have
#align finite.card_eq_zero_iff Finite.card_eq_zero_iff
-/
-/- warning: finite.card_le_of_injective' -> Finite.card_le_of_injective' is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} {f : α -> β}, (Function.Injective.{succ u1, succ u2} α β f) -> ((Eq.{1} Nat (Nat.card.{u2} β) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Eq.{1} Nat (Nat.card.{u1} α) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))))) -> (LE.le.{0} Nat Nat.hasLe (Nat.card.{u1} α) (Nat.card.{u2} β))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} {f : α -> β}, (Function.Injective.{succ u2, succ u1} α β f) -> ((Eq.{1} Nat (Nat.card.{u1} β) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Eq.{1} Nat (Nat.card.{u2} α) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))) -> (LE.le.{0} Nat instLENat (Nat.card.{u2} α) (Nat.card.{u1} β))
-Case conversion may be inaccurate. Consider using '#align finite.card_le_of_injective' Finite.card_le_of_injective'ₓ'. -/
/-- If `f` is injective, then `nat.card α ≤ nat.card β`. We must also assume
`nat.card β = 0 → nat.card α = 0` since `nat.card` is defined to be `0` for infinite types. -/
theorem card_le_of_injective' {f : α → β} (hf : Function.Injective f)
@@ -174,12 +150,6 @@ theorem card_le_of_injective' {f : α → β} (hf : Function.Injective f)
@card_le_of_injective α β (Nat.finite_of_card_ne_zero h) f hf
#align finite.card_le_of_injective' Finite.card_le_of_injective'
-/- warning: finite.card_le_of_embedding' -> Finite.card_le_of_embedding' is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}}, (Function.Embedding.{succ u1, succ u2} α β) -> ((Eq.{1} Nat (Nat.card.{u2} β) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Eq.{1} Nat (Nat.card.{u1} α) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))))) -> (LE.le.{0} Nat Nat.hasLe (Nat.card.{u1} α) (Nat.card.{u2} β))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}}, (Function.Embedding.{succ u2, succ u1} α β) -> ((Eq.{1} Nat (Nat.card.{u1} β) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Eq.{1} Nat (Nat.card.{u2} α) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))) -> (LE.le.{0} Nat instLENat (Nat.card.{u2} α) (Nat.card.{u1} β))
-Case conversion may be inaccurate. Consider using '#align finite.card_le_of_embedding' Finite.card_le_of_embedding'ₓ'. -/
/-- If `f` is an embedding, then `nat.card α ≤ nat.card β`. We must also assume
`nat.card β = 0 → nat.card α = 0` since `nat.card` is defined to be `0` for infinite types. -/
theorem card_le_of_embedding' (f : α ↪ β) (h : Nat.card β = 0 → Nat.card α = 0) :
@@ -187,12 +157,6 @@ theorem card_le_of_embedding' (f : α ↪ β) (h : Nat.card β = 0 → Nat.card
card_le_of_injective' f.2 h
#align finite.card_le_of_embedding' Finite.card_le_of_embedding'
-/- warning: finite.card_le_of_surjective' -> Finite.card_le_of_surjective' is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} {f : α -> β}, (Function.Surjective.{succ u1, succ u2} α β f) -> ((Eq.{1} Nat (Nat.card.{u1} α) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Eq.{1} Nat (Nat.card.{u2} β) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))))) -> (LE.le.{0} Nat Nat.hasLe (Nat.card.{u2} β) (Nat.card.{u1} α))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} {f : α -> β}, (Function.Surjective.{succ u2, succ u1} α β f) -> ((Eq.{1} Nat (Nat.card.{u2} α) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Eq.{1} Nat (Nat.card.{u1} β) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))) -> (LE.le.{0} Nat instLENat (Nat.card.{u1} β) (Nat.card.{u2} α))
-Case conversion may be inaccurate. Consider using '#align finite.card_le_of_surjective' Finite.card_le_of_surjective'ₓ'. -/
/-- If `f` is surjective, then `nat.card β ≤ nat.card α`. We must also assume
`nat.card α = 0 → nat.card β = 0` since `nat.card` is defined to be `0` for infinite types. -/
theorem card_le_of_surjective' {f : α → β} (hf : Function.Surjective f)
@@ -201,12 +165,6 @@ theorem card_le_of_surjective' {f : α → β} (hf : Function.Surjective f)
@card_le_of_surjective α β (Nat.finite_of_card_ne_zero h) f hf
#align finite.card_le_of_surjective' Finite.card_le_of_surjective'
-/- warning: finite.card_eq_zero_of_surjective -> Finite.card_eq_zero_of_surjective is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} {f : α -> β}, (Function.Surjective.{succ u1, succ u2} α β f) -> (Eq.{1} Nat (Nat.card.{u2} β) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Eq.{1} Nat (Nat.card.{u1} α) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} {f : α -> β}, (Function.Surjective.{succ u2, succ u1} α β f) -> (Eq.{1} Nat (Nat.card.{u1} β) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Eq.{1} Nat (Nat.card.{u2} α) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))
-Case conversion may be inaccurate. Consider using '#align finite.card_eq_zero_of_surjective Finite.card_eq_zero_of_surjectiveₓ'. -/
/-- NB: `nat.card` is defined to be `0` for infinite types. -/
theorem card_eq_zero_of_surjective {f : α → β} (hf : Function.Surjective f) (h : Nat.card β = 0) :
Nat.card α = 0 := by
@@ -218,55 +176,25 @@ theorem card_eq_zero_of_surjective {f : α → β} (hf : Function.Surjective f)
exact Nat.card_eq_zero_of_infinite
#align finite.card_eq_zero_of_surjective Finite.card_eq_zero_of_surjective
-/- warning: finite.card_eq_zero_of_injective -> Finite.card_eq_zero_of_injective is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Nonempty.{succ u1} α] {f : α -> β}, (Function.Injective.{succ u1, succ u2} α β f) -> (Eq.{1} Nat (Nat.card.{u1} α) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Eq.{1} Nat (Nat.card.{u2} β) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Nonempty.{succ u2} α] {f : α -> β}, (Function.Injective.{succ u2, succ u1} α β f) -> (Eq.{1} Nat (Nat.card.{u2} α) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Eq.{1} Nat (Nat.card.{u1} β) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))
-Case conversion may be inaccurate. Consider using '#align finite.card_eq_zero_of_injective Finite.card_eq_zero_of_injectiveₓ'. -/
/-- NB: `nat.card` is defined to be `0` for infinite types. -/
theorem card_eq_zero_of_injective [Nonempty α] {f : α → β} (hf : Function.Injective f)
(h : Nat.card α = 0) : Nat.card β = 0 :=
card_eq_zero_of_surjective (Function.invFun_surjective hf) h
#align finite.card_eq_zero_of_injective Finite.card_eq_zero_of_injective
-/- warning: finite.card_eq_zero_of_embedding -> Finite.card_eq_zero_of_embedding is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Nonempty.{succ u1} α], (Function.Embedding.{succ u1, succ u2} α β) -> (Eq.{1} Nat (Nat.card.{u1} α) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero)))) -> (Eq.{1} Nat (Nat.card.{u2} β) (OfNat.ofNat.{0} Nat 0 (OfNat.mk.{0} Nat 0 (Zero.zero.{0} Nat Nat.hasZero))))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Nonempty.{succ u2} α], (Function.Embedding.{succ u2, succ u1} α β) -> (Eq.{1} Nat (Nat.card.{u2} α) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0))) -> (Eq.{1} Nat (Nat.card.{u1} β) (OfNat.ofNat.{0} Nat 0 (instOfNatNat 0)))
-Case conversion may be inaccurate. Consider using '#align finite.card_eq_zero_of_embedding Finite.card_eq_zero_of_embeddingₓ'. -/
/-- NB: `nat.card` is defined to be `0` for infinite types. -/
theorem card_eq_zero_of_embedding [Nonempty α] (f : α ↪ β) (h : Nat.card α = 0) : Nat.card β = 0 :=
card_eq_zero_of_injective f.2 h
#align finite.card_eq_zero_of_embedding Finite.card_eq_zero_of_embedding
-/- warning: finite.card_sum -> Finite.card_sum is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : Finite.{succ u2} β], Eq.{1} Nat (Nat.card.{max u1 u2} (Sum.{u1, u2} α β)) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Nat.card.{u1} α) (Nat.card.{u2} β))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Finite.{succ u2} α] [_inst_2 : Finite.{succ u1} β], Eq.{1} Nat (Nat.card.{max u1 u2} (Sum.{u2, u1} α β)) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Nat.card.{u2} α) (Nat.card.{u1} β))
-Case conversion may be inaccurate. Consider using '#align finite.card_sum Finite.card_sumₓ'. -/
theorem card_sum [Finite α] [Finite β] : Nat.card (Sum α β) = Nat.card α + Nat.card β := by
haveI := Fintype.ofFinite α; haveI := Fintype.ofFinite β; simp
#align finite.card_sum Finite.card_sum
-/- warning: finite.card_image_le -> Finite.card_image_le is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} {s : Set.{u1} α} [_inst_1 : Finite.{succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)] (f : α -> β), LE.le.{0} Nat Nat.hasLe (Nat.card.{u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} β) Type.{u2} (Set.hasCoeToSort.{u2} β) (Set.image.{u1, u2} α β f s))) (Nat.card.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s))
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} {s : Set.{u2} α} [_inst_1 : Finite.{succ u2} (Set.Elem.{u2} α s)] (f : α -> β), LE.le.{0} Nat instLENat (Nat.card.{u1} (Set.Elem.{u1} β (Set.image.{u2, u1} α β f s))) (Nat.card.{u2} (Set.Elem.{u2} α s))
-Case conversion may be inaccurate. Consider using '#align finite.card_image_le Finite.card_image_leₓ'. -/
theorem card_image_le {s : Set α} [Finite s] (f : α → β) : Nat.card (f '' s) ≤ Nat.card s :=
card_le_of_surjective _ Set.surjective_onto_image
#align finite.card_image_le Finite.card_image_le
-/- warning: finite.card_range_le -> Finite.card_range_le is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Finite.{succ u1} α] (f : α -> β), LE.le.{0} Nat Nat.hasLe (Nat.card.{u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} β) Type.{u2} (Set.hasCoeToSort.{u2} β) (Set.range.{u2, succ u1} β α f))) (Nat.card.{u1} α)
-but is expected to have type
- forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Finite.{succ u2} α] (f : α -> β), LE.le.{0} Nat instLENat (Nat.card.{u1} (Set.Elem.{u1} β (Set.range.{u1, succ u2} β α f))) (Nat.card.{u2} α)
-Case conversion may be inaccurate. Consider using '#align finite.card_range_le Finite.card_range_leₓ'. -/
theorem card_range_le [Finite α] (f : α → β) : Nat.card (Set.range f) ≤ Nat.card α :=
card_le_of_surjective _ Set.surjective_onto_range
#align finite.card_range_le Finite.card_range_le
@@ -288,12 +216,6 @@ end Finite
namespace Set
-/- warning: set.card_union_le -> Set.card_union_le is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (s : Set.{u1} α) (t : Set.{u1} α), LE.le.{0} Nat Nat.hasLe (Nat.card.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Union.union.{u1} (Set.{u1} α) (Set.hasUnion.{u1} α) s t))) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat Nat.hasAdd) (Nat.card.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)) (Nat.card.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) t)))
-but is expected to have type
- forall {α : Type.{u1}} (s : Set.{u1} α) (t : Set.{u1} α), LE.le.{0} Nat instLENat (Nat.card.{u1} (Set.Elem.{u1} α (Union.union.{u1} (Set.{u1} α) (Set.instUnionSet.{u1} α) s t))) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Nat.card.{u1} (Set.Elem.{u1} α s)) (Nat.card.{u1} (Set.Elem.{u1} α t)))
-Case conversion may be inaccurate. Consider using '#align set.card_union_le Set.card_union_leₓ'. -/
theorem card_union_le (s t : Set α) : Nat.card ↥(s ∪ t) ≤ Nat.card s + Nat.card t :=
by
cases' _root_.finite_or_infinite ↥(s ∪ t) with h h
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -51,9 +51,7 @@ def Finite.equivFin (α : Type _) [Finite α] : α ≃ Fin (Nat.card α) :=
#print Finite.equivFinOfCardEq /-
/-- Similar to `finite.equiv_fin` but with control over the term used for the cardinality. -/
-def Finite.equivFinOfCardEq [Finite α] {n : ℕ} (h : Nat.card α = n) : α ≃ Fin n :=
- by
- subst h
+def Finite.equivFinOfCardEq [Finite α] {n : ℕ} (h : Nat.card α = n) : α ≃ Fin n := by subst h;
apply Finite.equivFin
#align finite.equiv_fin_of_card_eq Finite.equivFinOfCardEq
-/
@@ -101,26 +99,19 @@ lean 3 declaration is
but is expected to have type
forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Finite.{succ u2} α] [_inst_2 : Finite.{succ u1} β], Iff (Eq.{1} Nat (Nat.card.{u2} α) (Nat.card.{u1} β)) (Nonempty.{max (succ u1) (succ u2)} (Equiv.{succ u2, succ u1} α β))
Case conversion may be inaccurate. Consider using '#align finite.card_eq Finite.card_eqₓ'. -/
-theorem card_eq [Finite α] [Finite β] : Nat.card α = Nat.card β ↔ Nonempty (α ≃ β) :=
- by
- haveI := Fintype.ofFinite α
- haveI := Fintype.ofFinite β
- simp [Fintype.card_eq]
+theorem card_eq [Finite α] [Finite β] : Nat.card α = Nat.card β ↔ Nonempty (α ≃ β) := by
+ haveI := Fintype.ofFinite α; haveI := Fintype.ofFinite β; simp [Fintype.card_eq]
#align finite.card_eq Finite.card_eq
#print Finite.card_le_one_iff_subsingleton /-
-theorem card_le_one_iff_subsingleton [Finite α] : Nat.card α ≤ 1 ↔ Subsingleton α :=
- by
- haveI := Fintype.ofFinite α
- simp [Fintype.card_le_one_iff_subsingleton]
+theorem card_le_one_iff_subsingleton [Finite α] : Nat.card α ≤ 1 ↔ Subsingleton α := by
+ haveI := Fintype.ofFinite α; simp [Fintype.card_le_one_iff_subsingleton]
#align finite.card_le_one_iff_subsingleton Finite.card_le_one_iff_subsingleton
-/
#print Finite.one_lt_card_iff_nontrivial /-
-theorem one_lt_card_iff_nontrivial [Finite α] : 1 < Nat.card α ↔ Nontrivial α :=
- by
- haveI := Fintype.ofFinite α
- simp [Fintype.one_lt_card_iff_nontrivial]
+theorem one_lt_card_iff_nontrivial [Finite α] : 1 < Nat.card α ↔ Nontrivial α := by
+ haveI := Fintype.ofFinite α; simp [Fintype.one_lt_card_iff_nontrivial]
#align finite.one_lt_card_iff_nontrivial Finite.one_lt_card_iff_nontrivial
-/
@@ -132,18 +123,15 @@ theorem one_lt_card [Finite α] [h : Nontrivial α] : 1 < Nat.card α :=
#print Finite.card_option /-
@[simp]
-theorem card_option [Finite α] : Nat.card (Option α) = Nat.card α + 1 :=
- by
- haveI := Fintype.ofFinite α
- simp
+theorem card_option [Finite α] : Nat.card (Option α) = Nat.card α + 1 := by
+ haveI := Fintype.ofFinite α; simp
#align finite.card_option Finite.card_option
-/
#print Finite.card_le_of_injective /-
theorem card_le_of_injective [Finite β] (f : α → β) (hf : Function.Injective f) :
Nat.card α ≤ Nat.card β := by
- haveI := Fintype.ofFinite β
- haveI := Fintype.ofInjective f hf
+ haveI := Fintype.ofFinite β; haveI := Fintype.ofInjective f hf
simpa using Fintype.card_le_of_injective f hf
#align finite.card_le_of_injective Finite.card_le_of_injective
-/
@@ -162,15 +150,12 @@ but is expected to have type
Case conversion may be inaccurate. Consider using '#align finite.card_le_of_surjective Finite.card_le_of_surjectiveₓ'. -/
theorem card_le_of_surjective [Finite α] (f : α → β) (hf : Function.Surjective f) :
Nat.card β ≤ Nat.card α := by
- haveI := Fintype.ofFinite α
- haveI := Fintype.ofSurjective f hf
+ haveI := Fintype.ofFinite α; haveI := Fintype.ofSurjective f hf
simpa using Fintype.card_le_of_surjective f hf
#align finite.card_le_of_surjective Finite.card_le_of_surjective
#print Finite.card_eq_zero_iff /-
-theorem card_eq_zero_iff [Finite α] : Nat.card α = 0 ↔ IsEmpty α :=
- by
- haveI := Fintype.ofFinite α
+theorem card_eq_zero_iff [Finite α] : Nat.card α = 0 ↔ IsEmpty α := by haveI := Fintype.ofFinite α;
simp [Fintype.card_eq_zero_iff]
#align finite.card_eq_zero_iff Finite.card_eq_zero_iff
-/
@@ -262,11 +247,8 @@ lean 3 declaration is
but is expected to have type
forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Finite.{succ u2} α] [_inst_2 : Finite.{succ u1} β], Eq.{1} Nat (Nat.card.{max u1 u2} (Sum.{u2, u1} α β)) (HAdd.hAdd.{0, 0, 0} Nat Nat Nat (instHAdd.{0} Nat instAddNat) (Nat.card.{u2} α) (Nat.card.{u1} β))
Case conversion may be inaccurate. Consider using '#align finite.card_sum Finite.card_sumₓ'. -/
-theorem card_sum [Finite α] [Finite β] : Nat.card (Sum α β) = Nat.card α + Nat.card β :=
- by
- haveI := Fintype.ofFinite α
- haveI := Fintype.ofFinite β
- simp
+theorem card_sum [Finite α] [Finite β] : Nat.card (Sum α β) = Nat.card α + Nat.card β := by
+ haveI := Fintype.ofFinite α; haveI := Fintype.ofFinite β; simp
#align finite.card_sum Finite.card_sum
/- warning: finite.card_image_le -> Finite.card_image_le is a dubious translation:
@@ -290,18 +272,14 @@ theorem card_range_le [Finite α] (f : α → β) : Nat.card (Set.range f) ≤ N
#align finite.card_range_le Finite.card_range_le
#print Finite.card_subtype_le /-
-theorem card_subtype_le [Finite α] (p : α → Prop) : Nat.card { x // p x } ≤ Nat.card α :=
- by
- haveI := Fintype.ofFinite α
- simpa using Fintype.card_subtype_le p
+theorem card_subtype_le [Finite α] (p : α → Prop) : Nat.card { x // p x } ≤ Nat.card α := by
+ haveI := Fintype.ofFinite α; simpa using Fintype.card_subtype_le p
#align finite.card_subtype_le Finite.card_subtype_le
-/
#print Finite.card_subtype_lt /-
theorem card_subtype_lt [Finite α] {p : α → Prop} {x : α} (hx : ¬p x) :
- Nat.card { x // p x } < Nat.card α :=
- by
- haveI := Fintype.ofFinite α
+ Nat.card { x // p x } < Nat.card α := by haveI := Fintype.ofFinite α;
simpa using Fintype.card_subtype_lt hx
#align finite.card_subtype_lt Finite.card_subtype_lt
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
open Classical
(#11199)
We remove all but one open Classical
s, instead preferring to use open scoped Classical
. The only real side-effect this led to is moving a couple declarations to use Exists.choose
instead of Classical.choose
.
The first few commits are explicitly labelled regex replaces for ease of review.
@@ -30,7 +30,7 @@ it. We generally put such theorems into the `SetTheory.Cardinal.Finite` module.
noncomputable section
-open Classical
+open scoped Classical
variable {α β γ : Type*}
A collection of loosely-related lemmas, split out from other work in the hopes of simplifying review.
@@ -213,4 +213,23 @@ theorem card_union_le (s t : Set α) : Nat.card (↥(s ∪ t)) ≤ Nat.card s +
· exact Nat.card_eq_zero_of_infinite.trans_le (zero_le _)
#align set.card_union_le Set.card_union_le
+namespace Finite
+
+variable {s t : Set α} (ht : t.Finite)
+
+theorem card_lt_card (hsub : s ⊂ t) : Nat.card s < Nat.card t := by
+ have : Fintype t := Finite.fintype ht
+ have : Fintype s := Finite.fintype (subset ht (subset_of_ssubset hsub))
+ simp only [Nat.card_eq_fintype_card]
+ exact Set.card_lt_card hsub
+
+theorem eq_of_subset_of_card_le (hsub : s ⊆ t) (hcard : Nat.card t ≤ Nat.card s) : s = t :=
+ (eq_or_ssubset_of_subset hsub).elim id fun h ↦ absurd hcard <| not_le_of_lt <| ht.card_lt_card h
+
+theorem equiv_image_eq_iff_subset (e : α ≃ α) (hs : s.Finite) : e '' s = s ↔ e '' s ⊆ s :=
+ ⟨fun h ↦ by rw [h], fun h ↦ hs.eq_of_subset_of_card_le h <|
+ ge_of_eq (Nat.card_congr (e.image s).symm)⟩
+
+end Finite
+
end Set
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,10 +32,10 @@ noncomputable section
open Classical
-variable {α β γ : Type _}
+variable {α β γ : Type*}
/-- There is (noncomputably) an equivalence between a finite type `α` and `Fin (Nat.card α)`. -/
-def Finite.equivFin (α : Type _) [Finite α] : α ≃ Fin (Nat.card α) := by
+def Finite.equivFin (α : Type*) [Finite α] : α ≃ Fin (Nat.card α) := by
have := (Finite.exists_equiv_fin α).choose_spec.some
rwa [Nat.card_eq_of_equiv_fin this]
#align finite.equiv_fin Finite.equivFin
@@ -46,7 +46,7 @@ def Finite.equivFinOfCardEq [Finite α] {n : ℕ} (h : Nat.card α = n) : α ≃
apply Finite.equivFin
#align finite.equiv_fin_of_card_eq Finite.equivFinOfCardEq
-theorem Nat.card_eq (α : Type _) :
+theorem Nat.card_eq (α : Type*) :
Nat.card α = if h : Finite α then @Fintype.card α (Fintype.ofFinite α) else 0 := by
cases finite_or_infinite α
· letI := Fintype.ofFinite α
@@ -65,7 +65,7 @@ theorem Finite.card_pos [Finite α] [h : Nonempty α] : 0 < Nat.card α :=
namespace Finite
-theorem cast_card_eq_mk {α : Type _} [Finite α] : ↑(Nat.card α) = Cardinal.mk α :=
+theorem cast_card_eq_mk {α : Type*} [Finite α] : ↑(Nat.card α) = Cardinal.mk α :=
Cardinal.cast_toNat_of_lt_aleph0 (Cardinal.lt_aleph0_of_finite α)
#align finite.cast_card_eq_mk Finite.cast_card_eq_mk
@@ -192,7 +192,7 @@ end Finite
namespace PartENat
-theorem card_eq_coe_nat_card (α : Type _) [Finite α] : card α = Nat.card α := by
+theorem card_eq_coe_nat_card (α : Type*) [Finite α] : card α = Nat.card α := by
unfold PartENat.card
apply symm
rw [Cardinal.natCast_eq_toPartENat_iff]
@@ -2,14 +2,11 @@
Copyright (c) 2022 Kyle Miller. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
-
-! This file was ported from Lean 3 source module data.finite.card
-! leanprover-community/mathlib commit 3ff3f2d6a3118b8711063de7111a0d77a53219a8
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.SetTheory.Cardinal.Finite
+#align_import data.finite.card from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8"
+
/-!
# Cardinality of finite types
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller
! This file was ported from Lean 3 source module data.finite.card
-! leanprover-community/mathlib commit dde670c9a3f503647fd5bfdf1037bad526d3397a
+! leanprover-community/mathlib commit 3ff3f2d6a3118b8711063de7111a0d77a53219a8
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
Prove lemmas to handle PartENat.card Inspired from the similar lemmas for Nat.card This is a mathlib4 companion to the PR #19198 of mathlib3
Co-authored-by: Antoine Chambert-Loir <antoine.chambert-loir@math.univ-paris-diderot.fr>
@@ -193,6 +193,17 @@ theorem card_subtype_lt [Finite α] {p : α → Prop} {x : α} (hx : ¬p x) :
end Finite
+namespace PartENat
+
+theorem card_eq_coe_nat_card (α : Type _) [Finite α] : card α = Nat.card α := by
+ unfold PartENat.card
+ apply symm
+ rw [Cardinal.natCast_eq_toPartENat_iff]
+ exact Finite.cast_card_eq_mk
+#align part_enat.card_of_finite PartENat.card_eq_coe_nat_card
+
+end PartENat
+
namespace Set
theorem card_union_le (s t : Set α) : Nat.card (↥(s ∪ t)) ≤ Nat.card s + Nat.card t := by
@@ -206,4 +217,3 @@ theorem card_union_le (s t : Set α) : Nat.card (↥(s ∪ t)) ≤ Nat.card s +
#align set.card_union_le Set.card_union_le
end Set
-
The unported dependencies are