data.fintype.cardMathlib.Data.Fintype.Card

This file has been ported!

Changes since the initial port

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.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

feat(order/irreducible): Sup-irreducible elements (#18999)

Define sup- and inf- irreducible and prime elements in a lattice.

Diff
@@ -726,17 +726,15 @@ have ∀ x y, r x y → (univ.filter (λ z, r z x)).card < (univ.filter (λ z, r
     exact ⟨λ z hzx, trans hzx hxy, not_forall_of_exists_not ⟨x, not_imp.2 ⟨hxy, irrefl x⟩⟩⟩,
 subrelation.wf this (measure_wf _)
 
-lemma preorder.well_founded_lt [preorder α] : well_founded ((<) : α → α → Prop) :=
-well_founded_of_trans_of_irrefl _
-
-lemma preorder.well_founded_gt [preorder α] : well_founded ((>) : α → α → Prop) :=
-well_founded_of_trans_of_irrefl _
-
-@[priority 10] instance linear_order.is_well_order_lt [linear_order α] : is_well_order α (<) :=
-{ wf := preorder.well_founded_lt }
-
-@[priority 10] instance linear_order.is_well_order_gt [linear_order α] : is_well_order α (>) :=
-{ wf := preorder.well_founded_gt }
+@[priority 100] -- See note [lower instance priority]
+instance finite.to_well_founded_lt [preorder α] : well_founded_lt α :=
+⟨well_founded_of_trans_of_irrefl _⟩
+@[priority 100] -- See note [lower instance priority]
+instance finite.to_well_founded_gt [preorder α] : well_founded_gt α :=
+⟨well_founded_of_trans_of_irrefl _⟩
+
+@[priority 10] instance linear_order.is_well_order_lt [linear_order α] : is_well_order α (<) := {}
+@[priority 10] instance linear_order.is_well_order_gt [linear_order α] : is_well_order α (>) := {}
 
 end finite
 

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

refactor(tactic/wlog): simplify and speed up wlog (#16495)

Benefits:

  • The tactic is faster
  • The tactic is easier to port to Lean 4

Downside:

  • The tactic doesn't do any heavy-lifting for the user

Zulip thread: https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/wlog/near/296996966

Co-authored-by: Yury G. Kudryashov <urkud@urkud.name> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -864,7 +864,8 @@ private lemma nat_embedding_aux_injective (α : Type*) [infinite α] :
 begin
   rintro m n h,
   letI := classical.dec_eq α,
-  wlog hmlen : m ≤ n using m n,
+  wlog hmlen : m ≤ n generalizing m n,
+  { exact (this h.symm $ le_of_not_le hmlen).symm },
   by_contradiction hmn,
   have hmn : m < n, from lt_of_le_of_ne hmlen hmn,
   refine (classical.some_spec (exists_not_mem_finset

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(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)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -776,7 +776,7 @@ theorem injective_iff_surjective {f : α → α} : Injective f ↔ Surjective f
           eq_of_subset_of_card_le (subset_univ _)
             ((card_image_of_injective univ hinj).symm ▸ le_rfl)
         have h₂ : x ∈ image f univ := h₁.symm ▸ mem_univ _
-        exists_of_bex (mem_image.1 h₂)
+        exists_of_exists_mem (mem_image.1 h₂)
       ⟨this, fun hsurj =>
         has_left_inverse.injective
           ⟨surj_inv hsurj,
Diff
@@ -536,7 +536,7 @@ noncomputable def Fintype.ofFinite (α : Type _) [Finite α] : Fintype α :=
 theorem Finite.of_injective {α β : Sort _} [Finite β] (f : α → β) (H : Injective f) : Finite α :=
   by
   cases nonempty_fintype (PLift β)
-  rw [← Equiv.injective_comp Equiv.plift f, ← Equiv.comp_injective _ equiv.plift.symm] at H 
+  rw [← Equiv.injective_comp Equiv.plift f, ← Equiv.comp_injective _ equiv.plift.symm] at H
   haveI := Fintype.ofInjective _ H
   exact Finite.of_equiv _ Equiv.plift
 #align finite.of_injective Finite.of_injective
@@ -552,7 +552,7 @@ theorem Finite.of_surjective {α β : Sort _} [Finite α] (f : α → β) (H : S
 theorem Finite.exists_univ_list (α) [Finite α] : ∃ l : List α, l.Nodup ∧ ∀ x : α, x ∈ l :=
   by
   cases nonempty_fintype α; obtain ⟨l, e⟩ := Quotient.exists_rep (@univ α _).1
-  have := And.intro univ.2 mem_univ_val; exact ⟨_, by rwa [← e] at this ⟩
+  have := And.intro univ.2 mem_univ_val; exact ⟨_, by rwa [← e] at this⟩
 #align finite.exists_univ_list Finite.exists_univ_list
 -/
 
@@ -697,7 +697,7 @@ theorem card_le_one_iff : card α ≤ 1 ↔ ∀ a b : α, a = b :=
       let ⟨x, hx⟩ := card_eq_one_iff.1 ha.symm
       rw [hx a, hx b], fun _ => ha ▸ le_rfl⟩
   | n + 2 => fun ha =>
-    ⟨fun h => by rw [← ha] at h  <;> exact absurd h (by decide), fun h =>
+    ⟨fun h => by rw [← ha] at h <;> exact absurd h (by decide), fun h =>
       card_unit ▸ card_le_of_injective (fun _ => ()) fun _ _ _ => h _ _⟩
 #align fintype.card_le_one_iff Fintype.card_le_one_iff
 -/
@@ -1000,7 +1000,7 @@ theorem nonempty_iff_card_le [Fintype α] [Fintype β] :
 theorem exists_of_card_le_finset [Fintype α] {s : Finset β} (h : Fintype.card α ≤ s.card) :
     ∃ f : α ↪ β, Set.range f ⊆ s :=
   by
-  rw [← Fintype.card_coe] at h 
+  rw [← Fintype.card_coe] at h
   rcases nonempty_of_card_le h with ⟨f⟩
   exact ⟨f.trans (embedding.subtype _), by simp [Set.range_subset_iff]⟩
 #align function.embedding.exists_of_card_le_finset Function.Embedding.exists_of_card_le_finset
@@ -1391,7 +1391,7 @@ noncomputable def fintypeOfFinsetCardLe {ι : Type _} (n : ℕ) (w : ∀ s : Fin
   intro i
   obtain ⟨s, c⟩ := Infinite.exists_subset_card_eq ι (n + 1)
   specialize w s
-  rw [c] at w 
+  rw [c] at w
   exact Nat.not_succ_le_self n w
 #align fintype_of_finset_card_le fintypeOfFinsetCardLe
 -/
@@ -1483,7 +1483,7 @@ theorem Fintype.induction_subsingleton_or_nontrivial {P : ∀ (α) [Fintype α],
   · apply hbase
   · apply hstep
     intro β _ hlt
-    rw [hn] at hlt 
+    rw [hn] at hlt
     exact ih (Fintype.card β) hlt _ rfl
 #align fintype.induction_subsingleton_or_nontrivial Fintype.induction_subsingleton_or_nontrivial
 -/
Diff
@@ -255,13 +255,13 @@ theorem card_unique [Unique α] [h : Fintype α] : Fintype.card α = 1 :=
 #align fintype.card_unique Fintype.card_unique
 -/
 
-#print Fintype.card_of_isEmpty /-
+#print Fintype.card_ofIsEmpty /-
 /-- Note: this lemma is specifically about `fintype.of_is_empty`. For a statement about
 arbitrary `fintype` instances, use `fintype.card_eq_zero_iff`. -/
 @[simp]
-theorem card_of_isEmpty [IsEmpty α] : Fintype.card α = 0 :=
+theorem card_ofIsEmpty [IsEmpty α] : Fintype.card α = 0 :=
   rfl
-#align fintype.card_of_is_empty Fintype.card_of_isEmpty
+#align fintype.card_of_is_empty Fintype.card_ofIsEmpty
 -/
 
 end Fintype
Diff
@@ -344,7 +344,8 @@ theorem Finset.card_compl [DecidableEq α] [Fintype α] (s : Finset α) :
 
 #print Fintype.card_compl_set /-
 theorem Fintype.card_compl_set [Fintype α] (s : Set α) [Fintype s] [Fintype ↥(sᶜ)] :
-    Fintype.card ↥(sᶜ) = Fintype.card α - Fintype.card s := by classical
+    Fintype.card ↥(sᶜ) = Fintype.card α - Fintype.card s := by
+  classical rw [← Set.toFinset_card, ← Set.toFinset_card, ← Finset.card_compl, Set.toFinset_compl]
 #align fintype.card_compl_set Fintype.card_compl_set
 -/
 
@@ -557,7 +558,8 @@ theorem Finite.exists_univ_list (α) [Finite α] : ∃ l : List α, l.Nodup ∧
 
 #print List.Nodup.length_le_card /-
 theorem List.Nodup.length_le_card {α : Type _} [Fintype α] {l : List α} (h : l.Nodup) :
-    l.length ≤ Fintype.card α := by classical
+    l.length ≤ Fintype.card α := by
+  classical exact List.toFinset_card_of_nodup h ▸ l.to_finset.card_le_univ
 #align list.nodup.length_le_card List.Nodup.length_le_card
 -/
 
@@ -707,7 +709,11 @@ theorem card_le_one_iff_subsingleton : card α ≤ 1 ↔ Subsingleton α :=
 -/
 
 #print Fintype.one_lt_card_iff_nontrivial /-
-theorem one_lt_card_iff_nontrivial : 1 < card α ↔ Nontrivial α := by classical
+theorem one_lt_card_iff_nontrivial : 1 < card α ↔ Nontrivial α := by
+  classical
+  rw [← not_iff_not]
+  push_neg
+  rw [not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton]
 #align fintype.one_lt_card_iff_nontrivial Fintype.one_lt_card_iff_nontrivial
 -/
 
@@ -979,7 +985,7 @@ def truncOfCardLE [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
 
 #print Function.Embedding.nonempty_of_card_le /-
 theorem nonempty_of_card_le [Fintype α] [Fintype β] (h : Fintype.card α ≤ Fintype.card β) :
-    Nonempty (α ↪ β) := by classical
+    Nonempty (α ↪ β) := by classical exact (trunc_of_card_le h).Nonempty
 #align function.embedding.nonempty_of_card_le Function.Embedding.nonempty_of_card_le
 -/
 
@@ -1050,7 +1056,12 @@ theorem Fintype.card_subtype [Fintype α] (p : α → Prop) [DecidablePred p] :
 @[simp]
 theorem Fintype.card_subtype_compl [Fintype α] (p : α → Prop) [Fintype { x // p x }]
     [Fintype { x // ¬p x }] :
-    Fintype.card { x // ¬p x } = Fintype.card α - Fintype.card { x // p x } := by classical
+    Fintype.card { x // ¬p x } = Fintype.card α - Fintype.card { x // p x } := by
+  classical rw [Fintype.card_of_subtype (Set.toFinset (pᶜ)), Set.toFinset_compl p,
+          Finset.card_compl, Fintype.card_of_subtype (Set.toFinset p)] <;>
+        intro <;>
+      simp only [Set.mem_toFinset, Set.mem_compl_iff] <;>
+    rfl
 #align fintype.card_subtype_compl Fintype.card_subtype_compl
 -/
 
@@ -1102,7 +1113,17 @@ variable [Finite α]
 
 #print Finite.wellFounded_of_trans_of_irrefl /-
 theorem wellFounded_of_trans_of_irrefl (r : α → α → Prop) [IsTrans α r] [IsIrrefl α r] :
-    WellFounded r := by classical
+    WellFounded r := by
+  classical cases nonempty_fintype α <;>
+    exact
+      have : ∀ x y, r x y → (univ.filter fun z => r z x).card < (univ.filter fun z => r z y).card :=
+        fun x y hxy =>
+        Finset.card_lt_card <| by
+          simp only [finset.lt_iff_ssubset.symm, lt_iff_le_not_le, Finset.le_iff_subset,
+              Finset.subset_iff, mem_filter, true_and_iff, mem_univ, hxy] <;>
+            exact
+              ⟨fun z hzx => trans hzx hxy, not_forall_of_exists_not ⟨x, not_imp.2 ⟨hxy, irrefl x⟩⟩⟩
+      Subrelation.wf this (measure_wf _)
 #align finite.well_founded_of_trans_of_irrefl Finite.wellFounded_of_trans_of_irrefl
 -/
 
@@ -1201,6 +1222,12 @@ theorem of_injective_to_set {s : Set α} (hs : s ≠ Set.univ) {f : α → s} (h
   of_not_fintype fun h => by
     skip
     classical
+    refine' lt_irrefl (Fintype.card α) _
+    calc
+      Fintype.card α ≤ Fintype.card s := Fintype.card_le_of_injective f hf
+      _ = s.to_finset.card := s.to_finset_card.symm
+      _ < Fintype.card α :=
+        Finset.card_lt_card <| by rwa [Set.toFinset_ssubset_univ, Set.ssubset_univ_iff]
 #align infinite.of_injective_to_set Infinite.of_injective_to_set
 -/
 
@@ -1404,7 +1431,15 @@ many pigeons.
 See also: `finite.exists_ne_map_eq_of_infinite`
 -/
 theorem Finite.exists_infinite_fiber [Infinite α] [Finite β] (f : α → β) :
-    ∃ y : β, Infinite (f ⁻¹' {y}) := by classical
+    ∃ y : β, Infinite (f ⁻¹' {y}) := by
+  classical
+  by_contra! hf
+  cases nonempty_fintype β
+  haveI := fun y => fintypeOfNotInfinite <| hf y
+  let key : Fintype α :=
+    { elems := univ.bUnion fun y : β => (f ⁻¹' {y}).toFinset
+      complete := by simp }
+  exact key.false
 #align finite.exists_infinite_fiber Finite.exists_infinite_fiber
 -/
 
Diff
@@ -344,8 +344,7 @@ theorem Finset.card_compl [DecidableEq α] [Fintype α] (s : Finset α) :
 
 #print Fintype.card_compl_set /-
 theorem Fintype.card_compl_set [Fintype α] (s : Set α) [Fintype s] [Fintype ↥(sᶜ)] :
-    Fintype.card ↥(sᶜ) = Fintype.card α - Fintype.card s := by
-  classical rw [← Set.toFinset_card, ← Set.toFinset_card, ← Finset.card_compl, Set.toFinset_compl]
+    Fintype.card ↥(sᶜ) = Fintype.card α - Fintype.card s := by classical
 #align fintype.card_compl_set Fintype.card_compl_set
 -/
 
@@ -558,8 +557,7 @@ theorem Finite.exists_univ_list (α) [Finite α] : ∃ l : List α, l.Nodup ∧
 
 #print List.Nodup.length_le_card /-
 theorem List.Nodup.length_le_card {α : Type _} [Fintype α] {l : List α} (h : l.Nodup) :
-    l.length ≤ Fintype.card α := by
-  classical exact List.toFinset_card_of_nodup h ▸ l.to_finset.card_le_univ
+    l.length ≤ Fintype.card α := by classical
 #align list.nodup.length_le_card List.Nodup.length_le_card
 -/
 
@@ -709,11 +707,7 @@ theorem card_le_one_iff_subsingleton : card α ≤ 1 ↔ Subsingleton α :=
 -/
 
 #print Fintype.one_lt_card_iff_nontrivial /-
-theorem one_lt_card_iff_nontrivial : 1 < card α ↔ Nontrivial α := by
-  classical
-  rw [← not_iff_not]
-  push_neg
-  rw [not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton]
+theorem one_lt_card_iff_nontrivial : 1 < card α ↔ Nontrivial α := by classical
 #align fintype.one_lt_card_iff_nontrivial Fintype.one_lt_card_iff_nontrivial
 -/
 
@@ -985,7 +979,7 @@ def truncOfCardLE [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
 
 #print Function.Embedding.nonempty_of_card_le /-
 theorem nonempty_of_card_le [Fintype α] [Fintype β] (h : Fintype.card α ≤ Fintype.card β) :
-    Nonempty (α ↪ β) := by classical exact (trunc_of_card_le h).Nonempty
+    Nonempty (α ↪ β) := by classical
 #align function.embedding.nonempty_of_card_le Function.Embedding.nonempty_of_card_le
 -/
 
@@ -1056,12 +1050,7 @@ theorem Fintype.card_subtype [Fintype α] (p : α → Prop) [DecidablePred p] :
 @[simp]
 theorem Fintype.card_subtype_compl [Fintype α] (p : α → Prop) [Fintype { x // p x }]
     [Fintype { x // ¬p x }] :
-    Fintype.card { x // ¬p x } = Fintype.card α - Fintype.card { x // p x } := by
-  classical rw [Fintype.card_of_subtype (Set.toFinset (pᶜ)), Set.toFinset_compl p,
-          Finset.card_compl, Fintype.card_of_subtype (Set.toFinset p)] <;>
-        intro <;>
-      simp only [Set.mem_toFinset, Set.mem_compl_iff] <;>
-    rfl
+    Fintype.card { x // ¬p x } = Fintype.card α - Fintype.card { x // p x } := by classical
 #align fintype.card_subtype_compl Fintype.card_subtype_compl
 -/
 
@@ -1113,17 +1102,7 @@ variable [Finite α]
 
 #print Finite.wellFounded_of_trans_of_irrefl /-
 theorem wellFounded_of_trans_of_irrefl (r : α → α → Prop) [IsTrans α r] [IsIrrefl α r] :
-    WellFounded r := by
-  classical cases nonempty_fintype α <;>
-    exact
-      have : ∀ x y, r x y → (univ.filter fun z => r z x).card < (univ.filter fun z => r z y).card :=
-        fun x y hxy =>
-        Finset.card_lt_card <| by
-          simp only [finset.lt_iff_ssubset.symm, lt_iff_le_not_le, Finset.le_iff_subset,
-              Finset.subset_iff, mem_filter, true_and_iff, mem_univ, hxy] <;>
-            exact
-              ⟨fun z hzx => trans hzx hxy, not_forall_of_exists_not ⟨x, not_imp.2 ⟨hxy, irrefl x⟩⟩⟩
-      Subrelation.wf this (measure_wf _)
+    WellFounded r := by classical
 #align finite.well_founded_of_trans_of_irrefl Finite.wellFounded_of_trans_of_irrefl
 -/
 
@@ -1222,12 +1201,6 @@ theorem of_injective_to_set {s : Set α} (hs : s ≠ Set.univ) {f : α → s} (h
   of_not_fintype fun h => by
     skip
     classical
-    refine' lt_irrefl (Fintype.card α) _
-    calc
-      Fintype.card α ≤ Fintype.card s := Fintype.card_le_of_injective f hf
-      _ = s.to_finset.card := s.to_finset_card.symm
-      _ < Fintype.card α :=
-        Finset.card_lt_card <| by rwa [Set.toFinset_ssubset_univ, Set.ssubset_univ_iff]
 #align infinite.of_injective_to_set Infinite.of_injective_to_set
 -/
 
@@ -1431,15 +1404,7 @@ many pigeons.
 See also: `finite.exists_ne_map_eq_of_infinite`
 -/
 theorem Finite.exists_infinite_fiber [Infinite α] [Finite β] (f : α → β) :
-    ∃ y : β, Infinite (f ⁻¹' {y}) := by
-  classical
-  by_contra! hf
-  cases nonempty_fintype β
-  haveI := fun y => fintypeOfNotInfinite <| hf y
-  let key : Fintype α :=
-    { elems := univ.bUnion fun y : β => (f ⁻¹' {y}).toFinset
-      complete := by simp }
-  exact key.false
+    ∃ y : β, Infinite (f ⁻¹' {y}) := by classical
 #align finite.exists_infinite_fiber Finite.exists_infinite_fiber
 -/
 
Diff
@@ -303,7 +303,7 @@ theorem Finset.card_eq_iff_eq_univ [Fintype α] (s : Finset α) :
 
 #print Finset.card_le_univ /-
 theorem Finset.card_le_univ [Fintype α] (s : Finset α) : s.card ≤ Fintype.card α :=
-  card_le_of_subset (subset_univ s)
+  card_le_card (subset_univ s)
 #align finset.card_le_univ Finset.card_le_univ
 -/
 
Diff
@@ -1433,7 +1433,7 @@ See also: `finite.exists_ne_map_eq_of_infinite`
 theorem Finite.exists_infinite_fiber [Infinite α] [Finite β] (f : α → β) :
     ∃ y : β, Infinite (f ⁻¹' {y}) := by
   classical
-  by_contra' hf
+  by_contra! hf
   cases nonempty_fintype β
   haveI := fun y => fintypeOfNotInfinite <| hf y
   let key : Fintype α :=
Diff
@@ -310,7 +310,7 @@ theorem Finset.card_le_univ [Fintype α] (s : Finset α) : s.card ≤ Fintype.ca
 #print Finset.card_lt_univ_of_not_mem /-
 theorem Finset.card_lt_univ_of_not_mem [Fintype α] {s : Finset α} {x : α} (hx : x ∉ s) :
     s.card < Fintype.card α :=
-  card_lt_card ⟨subset_univ s, not_forall.2 ⟨x, fun hx' => hx (hx' <| mem_univ x)⟩⟩
+  card_lt_card ⟨subset_univ s, Classical.not_forall.2 ⟨x, fun hx' => hx (hx' <| mem_univ x)⟩⟩
 #align finset.card_lt_univ_of_not_mem Finset.card_lt_univ_of_not_mem
 -/
 
@@ -592,7 +592,7 @@ theorem card_lt_of_injective_of_not_mem (f : α → β) (h : Function.Injective
 #print Fintype.card_lt_of_injective_not_surjective /-
 theorem card_lt_of_injective_not_surjective (f : α → β) (h : Function.Injective f)
     (h' : ¬Function.Surjective f) : card α < card β :=
-  let ⟨y, hy⟩ := not_forall.1 h'
+  let ⟨y, hy⟩ := Classical.not_forall.1 h'
   card_lt_of_injective_of_not_mem f h hy
 #align fintype.card_lt_of_injective_not_surjective Fintype.card_lt_of_injective_not_surjective
 -/
@@ -1241,7 +1241,7 @@ theorem of_surjective_from_set {s : Set α} (hs : s ≠ Set.univ) {f : s → α}
 
 #print Infinite.exists_not_mem_finset /-
 theorem exists_not_mem_finset [Infinite α] (s : Finset α) : ∃ x, x ∉ s :=
-  not_forall.1 fun h => Fintype.false ⟨s, h⟩
+  Classical.not_forall.1 fun h => Fintype.false ⟨s, h⟩
 #align infinite.exists_not_mem_finset Infinite.exists_not_mem_finset
 -/
 
@@ -1411,7 +1411,8 @@ See also: `fintype.exists_ne_map_eq_of_card_lt`, `finite.exists_infinite_fiber`.
 -/
 theorem Finite.exists_ne_map_eq_of_infinite {α β} [Infinite α] [Finite β] (f : α → β) :
     ∃ x y : α, x ≠ y ∧ f x = f y := by
-  simpa only [injective, not_forall, not_imp, and_comm] using not_injective_infinite_finite f
+  simpa only [injective, Classical.not_forall, not_imp, and_comm] using
+    not_injective_infinite_finite f
 #align finite.exists_ne_map_eq_of_infinite Finite.exists_ne_map_eq_of_infinite
 -/
 
Diff
@@ -3,11 +3,11 @@ Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 -/
-import Mathbin.Data.Fintype.Basic
-import Mathbin.Data.Finset.Card
-import Mathbin.Data.List.NodupEquivFin
-import Mathbin.Tactic.Positivity
-import Mathbin.Tactic.Wlog
+import Data.Fintype.Basic
+import Data.Finset.Card
+import Data.List.NodupEquivFin
+import Tactic.Positivity
+import Tactic.Wlog
 
 #align_import data.fintype.card from "leanprover-community/mathlib"@"bf2428c9486c407ca38b5b3fb10b87dad0bc99fa"
 
Diff
@@ -375,7 +375,7 @@ theorem fin_injective : Function.Injective Fin := fun m n h =>
 /-- A reversed version of `fin.cast_eq_cast` that is easier to rewrite with. -/
 theorem Fin.cast_eq_cast' {n m : ℕ} (h : Fin n = Fin m) :
     cast h = ⇑(Fin.castIso <| fin_injective h) :=
-  (Fin.castIso_eq_cast _).symm
+  (Fin.cast_eq_cast _).symm
 #align fin.cast_eq_cast' Fin.cast_eq_cast'
 -/
 
Diff
@@ -1085,14 +1085,14 @@ theorem Fintype.card_compl_eq_card_compl [Finite α] (p q : α → Prop) [Fintyp
 #print Fintype.card_quotient_le /-
 theorem Fintype.card_quotient_le [Fintype α] (s : Setoid α)
     [DecidableRel ((· ≈ ·) : α → α → Prop)] : Fintype.card (Quotient s) ≤ Fintype.card α :=
-  Fintype.card_le_of_surjective _ (surjective_quotient_mk _)
+  Fintype.card_le_of_surjective _ (surjective_quotient_mk' _)
 #align fintype.card_quotient_le Fintype.card_quotient_le
 -/
 
 #print Fintype.card_quotient_lt /-
 theorem Fintype.card_quotient_lt [Fintype α] {s : Setoid α} [DecidableRel ((· ≈ ·) : α → α → Prop)]
     {x y : α} (h1 : x ≠ y) (h2 : x ≈ y) : Fintype.card (Quotient s) < Fintype.card α :=
-  Fintype.card_lt_of_surjective_not_injective _ (surjective_quotient_mk _) fun w =>
+  Fintype.card_lt_of_surjective_not_injective _ (surjective_quotient_mk' _) fun w =>
     h1 (w <| Quotient.eq'.mpr h2)
 #align fintype.card_quotient_lt Fintype.card_quotient_lt
 -/
Diff
@@ -807,14 +807,14 @@ theorem injective_iff_surjective_of_equiv {f : α → β} (e : α ≃ β) : Inje
 #align finite.injective_iff_surjective_of_equiv Finite.injective_iff_surjective_of_equiv
 -/
 
-alias injective_iff_bijective ↔ _root_.function.injective.bijective_of_finite _
+alias ⟨_root_.function.injective.bijective_of_finite, _⟩ := injective_iff_bijective
 #align function.injective.bijective_of_finite Function.Injective.bijective_of_finite
 
-alias surjective_iff_bijective ↔ _root_.function.surjective.bijective_of_finite _
+alias ⟨_root_.function.surjective.bijective_of_finite, _⟩ := surjective_iff_bijective
 #align function.surjective.bijective_of_finite Function.Surjective.bijective_of_finite
 
-alias injective_iff_surjective_of_equiv ↔ _root_.function.injective.surjective_of_fintype
-  _root_.function.surjective.injective_of_fintype
+alias ⟨_root_.function.injective.surjective_of_fintype,
+  _root_.function.surjective.injective_of_fintype⟩ := injective_iff_surjective_of_equiv
 #align function.injective.surjective_of_fintype Function.Injective.surjective_of_fintype
 #align function.surjective.injective_of_fintype Function.Surjective.injective_of_fintype
 
Diff
@@ -866,28 +866,28 @@ variable [Fintype α] [Fintype β]
 
 open Fintype
 
-#print Equiv.ofLeftInverseOfCardLe /-
+#print Equiv.ofLeftInverseOfCardLE /-
 /-- Construct an equivalence from functions that are inverse to each other. -/
 @[simps]
-def ofLeftInverseOfCardLe (hβα : card β ≤ card α) (f : α → β) (g : β → α) (h : LeftInverse g f) :
+def ofLeftInverseOfCardLE (hβα : card β ≤ card α) (f : α → β) (g : β → α) (h : LeftInverse g f) :
     α ≃ β where
   toFun := f
   invFun := g
   left_inv := h
   right_inv := h.rightInverse_of_card_le hβα
-#align equiv.of_left_inverse_of_card_le Equiv.ofLeftInverseOfCardLe
+#align equiv.of_left_inverse_of_card_le Equiv.ofLeftInverseOfCardLE
 -/
 
-#print Equiv.ofRightInverseOfCardLe /-
+#print Equiv.ofRightInverseOfCardLE /-
 /-- Construct an equivalence from functions that are inverse to each other. -/
 @[simps]
-def ofRightInverseOfCardLe (hαβ : card α ≤ card β) (f : α → β) (g : β → α) (h : RightInverse g f) :
+def ofRightInverseOfCardLE (hαβ : card α ≤ card β) (f : α → β) (g : β → α) (h : RightInverse g f) :
     α ≃ β where
   toFun := f
   invFun := g
   left_inv := h.leftInverse_of_card_le hαβ
   right_inv := h
-#align equiv.of_right_inverse_of_card_le Equiv.ofRightInverseOfCardLe
+#align equiv.of_right_inverse_of_card_le Equiv.ofRightInverseOfCardLE
 -/
 
 end Equiv
@@ -922,11 +922,11 @@ noncomputable def Finset.equivOfCardEq {s t : Finset α} (h : s.card = t.card) :
 #align finset.equiv_of_card_eq Finset.equivOfCardEq
 -/
 
-#print Fintype.card_Prop /-
+#print Fintype.card_prop /-
 @[simp]
-theorem Fintype.card_Prop : Fintype.card Prop = 2 :=
+theorem Fintype.card_prop : Fintype.card Prop = 2 :=
   rfl
-#align fintype.card_Prop Fintype.card_Prop
+#align fintype.card_Prop Fintype.card_prop
 -/
 
 #print set_fintype_card_le_univ /-
@@ -959,28 +959,28 @@ theorem equiv_of_fintype_self_embedding_to_embedding [Finite α] (e : α ↪ α)
 #align function.embedding.equiv_of_fintype_self_embedding_to_embedding Function.Embedding.equiv_of_fintype_self_embedding_to_embedding
 -/
 
-#print Function.Embedding.is_empty_of_card_lt /-
+#print Function.Embedding.isEmpty_of_card_lt /-
 /-- If `‖β‖ < ‖α‖` there are no embeddings `α ↪ β`.
 This is a formulation of the pigeonhole principle.
 
 Note this cannot be an instance as it needs `h`. -/
 @[simp]
-theorem is_empty_of_card_lt [Fintype α] [Fintype β] (h : Fintype.card β < Fintype.card α) :
+theorem isEmpty_of_card_lt [Fintype α] [Fintype β] (h : Fintype.card β < Fintype.card α) :
     IsEmpty (α ↪ β) :=
   ⟨fun f =>
     let ⟨x, y, Ne, feq⟩ := Fintype.exists_ne_map_eq_of_card_lt f h
     Ne <| f.Injective feq⟩
-#align function.embedding.is_empty_of_card_lt Function.Embedding.is_empty_of_card_lt
+#align function.embedding.is_empty_of_card_lt Function.Embedding.isEmpty_of_card_lt
 -/
 
-#print Function.Embedding.truncOfCardLe /-
+#print Function.Embedding.truncOfCardLE /-
 /-- A constructive embedding of a fintype `α` in another fintype `β` when `card α ≤ card β`. -/
-def truncOfCardLe [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
+def truncOfCardLE [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
     (h : Fintype.card α ≤ Fintype.card β) : Trunc (α ↪ β) :=
   (Fintype.truncEquivFin α).bind fun ea =>
     (Fintype.truncEquivFin β).map fun eb =>
       ea.toEmbedding.trans ((Fin.castLEEmb h).toEmbedding.trans eb.symm.toEmbedding)
-#align function.embedding.trunc_of_card_le Function.Embedding.truncOfCardLe
+#align function.embedding.trunc_of_card_le Function.Embedding.truncOfCardLE
 -/
 
 #print Function.Embedding.nonempty_of_card_le /-
@@ -1160,11 +1160,11 @@ protected theorem Fintype.false [Infinite α] (h : Fintype α) : False :=
 #align fintype.false Fintype.false
 -/
 
-#print is_empty_fintype /-
+#print isEmpty_fintype /-
 @[simp]
-theorem is_empty_fintype {α : Type _} : IsEmpty (Fintype α) ↔ Infinite α :=
+theorem isEmpty_fintype {α : Type _} : IsEmpty (Fintype α) ↔ Infinite α :=
   ⟨fun ⟨h⟩ => ⟨fun h' => (@nonempty_fintype α h').elim h⟩, fun ⟨h⟩ => ⟨fun h' => h h'.Finite⟩⟩
-#align is_empty_fintype is_empty_fintype
+#align is_empty_fintype isEmpty_fintype
 -/
 
 #print fintypeOfNotInfinite /-
@@ -1211,7 +1211,7 @@ namespace Infinite
 
 #print Infinite.of_not_fintype /-
 theorem of_not_fintype (h : Fintype α → False) : Infinite α :=
-  is_empty_fintype.mp ⟨h⟩
+  isEmpty_fintype.mp ⟨h⟩
 #align infinite.of_not_fintype Infinite.of_not_fintype
 -/
 
Diff
@@ -2,11 +2,6 @@
 Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
-
-! This file was ported from Lean 3 source module data.fintype.card
-! leanprover-community/mathlib commit bf2428c9486c407ca38b5b3fb10b87dad0bc99fa
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Data.Fintype.Basic
 import Mathbin.Data.Finset.Card
@@ -14,6 +9,8 @@ import Mathbin.Data.List.NodupEquivFin
 import Mathbin.Tactic.Positivity
 import Mathbin.Tactic.Wlog
 
+#align_import data.fintype.card from "leanprover-community/mathlib"@"bf2428c9486c407ca38b5b3fb10b87dad0bc99fa"
+
 /-!
 # Cardinalities of finite types
 
Diff
@@ -1130,15 +1130,19 @@ theorem wellFounded_of_trans_of_irrefl (r : α → α → Prop) [IsTrans α r] [
 #align finite.well_founded_of_trans_of_irrefl Finite.wellFounded_of_trans_of_irrefl
 -/
 
+#print Finite.to_wellFoundedLT /-
 -- See note [lower instance priority]
 instance (priority := 100) Finite.to_wellFoundedLT [Preorder α] : WellFoundedLT α :=
   ⟨wellFounded_of_trans_of_irrefl _⟩
-#align finite.finite.to_well_founded_lt Finite.Finite.to_wellFoundedLT
+#align finite.finite.to_well_founded_lt Finite.to_wellFoundedLT
+-/
 
+#print Finite.to_wellFoundedGT /-
 -- See note [lower instance priority]
 instance (priority := 100) Finite.to_wellFoundedGT [Preorder α] : WellFoundedGT α :=
   ⟨wellFounded_of_trans_of_irrefl _⟩
-#align finite.finite.to_well_founded_gt Finite.Finite.to_wellFoundedGT
+#align finite.finite.to_well_founded_gt Finite.to_wellFoundedGT
+-/
 
 #print Finite.LinearOrder.isWellOrder_lt /-
 instance (priority := 10) LinearOrder.isWellOrder_lt [LinearOrder α] : IsWellOrder α (· < ·) where
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 
 ! This file was ported from Lean 3 source module data.fintype.card
-! leanprover-community/mathlib commit 92ca63f0fb391a9ca5f22d2409a6080e786d99f7
+! leanprover-community/mathlib commit bf2428c9486c407ca38b5b3fb10b87dad0bc99fa
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -1130,27 +1130,23 @@ theorem wellFounded_of_trans_of_irrefl (r : α → α → Prop) [IsTrans α r] [
 #align finite.well_founded_of_trans_of_irrefl Finite.wellFounded_of_trans_of_irrefl
 -/
 
-#print Finite.Preorder.wellFounded_lt /-
-theorem Preorder.wellFounded_lt [Preorder α] : WellFounded ((· < ·) : α → α → Prop) :=
-  wellFounded_of_trans_of_irrefl _
-#align finite.preorder.well_founded_lt Finite.Preorder.wellFounded_lt
--/
+-- See note [lower instance priority]
+instance (priority := 100) Finite.to_wellFoundedLT [Preorder α] : WellFoundedLT α :=
+  ⟨wellFounded_of_trans_of_irrefl _⟩
+#align finite.finite.to_well_founded_lt Finite.Finite.to_wellFoundedLT
 
-#print Finite.Preorder.wellFounded_gt /-
-theorem Preorder.wellFounded_gt [Preorder α] : WellFounded ((· > ·) : α → α → Prop) :=
-  wellFounded_of_trans_of_irrefl _
-#align finite.preorder.well_founded_gt Finite.Preorder.wellFounded_gt
--/
+-- See note [lower instance priority]
+instance (priority := 100) Finite.to_wellFoundedGT [Preorder α] : WellFoundedGT α :=
+  ⟨wellFounded_of_trans_of_irrefl _⟩
+#align finite.finite.to_well_founded_gt Finite.Finite.to_wellFoundedGT
 
 #print Finite.LinearOrder.isWellOrder_lt /-
-instance (priority := 10) LinearOrder.isWellOrder_lt [LinearOrder α] : IsWellOrder α (· < ·)
-    where wf := Preorder.wellFounded_lt
+instance (priority := 10) LinearOrder.isWellOrder_lt [LinearOrder α] : IsWellOrder α (· < ·) where
 #align finite.linear_order.is_well_order_lt Finite.LinearOrder.isWellOrder_lt
 -/
 
 #print Finite.LinearOrder.isWellOrder_gt /-
-instance (priority := 10) LinearOrder.isWellOrder_gt [LinearOrder α] : IsWellOrder α (· > ·)
-    where wf := Preorder.wellFounded_gt
+instance (priority := 10) LinearOrder.isWellOrder_gt [LinearOrder α] : IsWellOrder α (· > ·) where
 #align finite.linear_order.is_well_order_gt Finite.LinearOrder.isWellOrder_gt
 -/
 
Diff
@@ -982,7 +982,7 @@ def truncOfCardLe [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
     (h : Fintype.card α ≤ Fintype.card β) : Trunc (α ↪ β) :=
   (Fintype.truncEquivFin α).bind fun ea =>
     (Fintype.truncEquivFin β).map fun eb =>
-      ea.toEmbedding.trans ((Fin.castLE h).toEmbedding.trans eb.symm.toEmbedding)
+      ea.toEmbedding.trans ((Fin.castLEEmb h).toEmbedding.trans eb.symm.toEmbedding)
 #align function.embedding.trunc_of_card_le Function.Embedding.truncOfCardLe
 -/
 
Diff
@@ -188,7 +188,7 @@ See `fintype.equiv_fin_of_card_eq` for the noncomputable definition,
 and `fintype.trunc_equiv_fin` and `fintype.equiv_fin` for the bijection `α ≃ fin (card α)`.
 -/
 def truncEquivFinOfCardEq [DecidableEq α] {n : ℕ} (h : Fintype.card α = n) : Trunc (α ≃ Fin n) :=
-  (truncEquivFin α).map fun e => e.trans (Fin.cast h).toEquiv
+  (truncEquivFin α).map fun e => e.trans (Fin.castIso h).toEquiv
 #align fintype.trunc_equiv_fin_of_card_eq Fintype.truncEquivFinOfCardEq
 -/
 
@@ -376,8 +376,9 @@ theorem fin_injective : Function.Injective Fin := fun m n h =>
 
 #print Fin.cast_eq_cast' /-
 /-- A reversed version of `fin.cast_eq_cast` that is easier to rewrite with. -/
-theorem Fin.cast_eq_cast' {n m : ℕ} (h : Fin n = Fin m) : cast h = ⇑(Fin.cast <| fin_injective h) :=
-  (Fin.cast_eq_cast _).symm
+theorem Fin.cast_eq_cast' {n m : ℕ} (h : Fin n = Fin m) :
+    cast h = ⇑(Fin.castIso <| fin_injective h) :=
+  (Fin.castIso_eq_cast _).symm
 #align fin.cast_eq_cast' Fin.cast_eq_cast'
 -/
 
Diff
@@ -158,13 +158,17 @@ end Fintype
 
 namespace Fintype
 
+#print Fintype.ofEquiv_card /-
 theorem ofEquiv_card [Fintype α] (f : α ≃ β) : @card β (ofEquiv α f) = card α :=
   Multiset.card_map _ _
 #align fintype.of_equiv_card Fintype.ofEquiv_card
+-/
 
+#print Fintype.card_congr /-
 theorem card_congr {α β} [Fintype α] [Fintype β] (f : α ≃ β) : card α = card β := by
   rw [← of_equiv_card f] <;> congr
 #align fintype.card_congr Fintype.card_congr
+-/
 
 #print Fintype.card_congr' /-
 @[congr]
@@ -228,12 +232,14 @@ noncomputable def equivOfCardEq (h : card α = card β) : α ≃ β :=
 
 end
 
+#print Fintype.card_eq /-
 theorem card_eq {α β} [F : Fintype α] [G : Fintype β] : card α = card β ↔ Nonempty (α ≃ β) :=
   ⟨fun h =>
     haveI := Classical.propDecidable
     (trunc_equiv_of_card_eq h).Nonempty,
     fun ⟨f⟩ => card_congr f⟩
 #align fintype.card_eq Fintype.card_eq
+-/
 
 #print Fintype.card_ofSubsingleton /-
 /-- Note: this lemma is specifically about `fintype.of_subsingleton`. For a statement about
@@ -339,10 +345,12 @@ theorem Finset.card_compl [DecidableEq α] [Fintype α] (s : Finset α) :
 #align finset.card_compl Finset.card_compl
 -/
 
+#print Fintype.card_compl_set /-
 theorem Fintype.card_compl_set [Fintype α] (s : Set α) [Fintype s] [Fintype ↥(sᶜ)] :
     Fintype.card ↥(sᶜ) = Fintype.card α - Fintype.card s := by
   classical rw [← Set.toFinset_card, ← Set.toFinset_card, ← Finset.card_compl, Set.toFinset_compl]
 #align fintype.card_compl_set Fintype.card_compl_set
+-/
 
 #print Fintype.card_fin /-
 @[simp]
@@ -366,10 +374,12 @@ theorem fin_injective : Function.Injective Fin := fun m n h =>
 #align fin_injective fin_injective
 -/
 
+#print Fin.cast_eq_cast' /-
 /-- A reversed version of `fin.cast_eq_cast` that is easier to rewrite with. -/
 theorem Fin.cast_eq_cast' {n m : ℕ} (h : Fin n = Fin m) : cast h = ⇑(Fin.cast <| fin_injective h) :=
   (Fin.cast_eq_cast _).symm
 #align fin.cast_eq_cast' Fin.cast_eq_cast'
+-/
 
 #print card_finset_fin_le /-
 theorem card_finset_fin_le {n : ℕ} (s : Finset (Fin n)) : s.card ≤ n := by
@@ -433,10 +443,12 @@ theorem Fintype.card_bool : Fintype.card Bool = 2 :=
 #align fintype.card_bool Fintype.card_bool
 -/
 
+#print Fintype.card_ulift /-
 @[simp]
 theorem Fintype.card_ulift (α : Type _) [Fintype α] : Fintype.card (ULift α) = Fintype.card α :=
   Fintype.ofEquiv_card _
 #align fintype.card_ulift Fintype.card_ulift
+-/
 
 #print Fintype.card_plift /-
 @[simp]
@@ -522,6 +534,7 @@ noncomputable def Fintype.ofFinite (α : Type _) [Finite α] : Fintype α :=
 #align fintype.of_finite Fintype.ofFinite
 -/
 
+#print Finite.of_injective /-
 theorem Finite.of_injective {α β : Sort _} [Finite β] (f : α → β) (H : Injective f) : Finite α :=
   by
   cases nonempty_fintype (PLift β)
@@ -529,10 +542,13 @@ theorem Finite.of_injective {α β : Sort _} [Finite β] (f : α → β) (H : In
   haveI := Fintype.ofInjective _ H
   exact Finite.of_equiv _ Equiv.plift
 #align finite.of_injective Finite.of_injective
+-/
 
+#print Finite.of_surjective /-
 theorem Finite.of_surjective {α β : Sort _} [Finite α] (f : α → β) (H : Surjective f) : Finite β :=
   Finite.of_injective _ <| injective_surjInv H
 #align finite.of_surjective Finite.of_surjective
+-/
 
 #print Finite.exists_univ_list /-
 theorem Finite.exists_univ_list (α) [Finite α] : ∃ l : List α, l.Nodup ∧ ∀ x : α, x ∈ l :=
@@ -553,14 +569,19 @@ namespace Fintype
 
 variable [Fintype α] [Fintype β]
 
+#print Fintype.card_le_of_injective /-
 theorem card_le_of_injective (f : α → β) (hf : Function.Injective f) : card α ≤ card β :=
   Finset.card_le_card_of_inj_on f (fun _ _ => Finset.mem_univ _) fun _ _ _ _ h => hf h
 #align fintype.card_le_of_injective Fintype.card_le_of_injective
+-/
 
+#print Fintype.card_le_of_embedding /-
 theorem card_le_of_embedding (f : α ↪ β) : card α ≤ card β :=
   card_le_of_injective f f.2
 #align fintype.card_le_of_embedding Fintype.card_le_of_embedding
+-/
 
+#print Fintype.card_lt_of_injective_of_not_mem /-
 theorem card_lt_of_injective_of_not_mem (f : α → β) (h : Function.Injective f) {b : β}
     (w : b ∉ Set.range f) : card α < card β :=
   calc
@@ -568,26 +589,35 @@ theorem card_lt_of_injective_of_not_mem (f : α → β) (h : Function.Injective
     _ < card β :=
       Finset.card_lt_univ_of_not_mem <| by rwa [← mem_coe, coe_map, coe_univ, Set.image_univ]
 #align fintype.card_lt_of_injective_of_not_mem Fintype.card_lt_of_injective_of_not_mem
+-/
 
+#print Fintype.card_lt_of_injective_not_surjective /-
 theorem card_lt_of_injective_not_surjective (f : α → β) (h : Function.Injective f)
     (h' : ¬Function.Surjective f) : card α < card β :=
   let ⟨y, hy⟩ := not_forall.1 h'
   card_lt_of_injective_of_not_mem f h hy
 #align fintype.card_lt_of_injective_not_surjective Fintype.card_lt_of_injective_not_surjective
+-/
 
+#print Fintype.card_le_of_surjective /-
 theorem card_le_of_surjective (f : α → β) (h : Function.Surjective f) : card β ≤ card α :=
   card_le_of_injective _ (Function.injective_surjInv h)
 #align fintype.card_le_of_surjective Fintype.card_le_of_surjective
+-/
 
+#print Fintype.card_range_le /-
 theorem card_range_le {α β : Type _} (f : α → β) [Fintype α] [Fintype (Set.range f)] :
     Fintype.card (Set.range f) ≤ Fintype.card α :=
   Fintype.card_le_of_surjective (fun a => ⟨f a, by simp⟩) fun ⟨_, a, ha⟩ => ⟨a, by simpa using ha⟩
 #align fintype.card_range_le Fintype.card_range_le
+-/
 
+#print Fintype.card_range /-
 theorem card_range {α β F : Type _} [EmbeddingLike F α β] (f : F) [Fintype α]
     [Fintype (Set.range f)] : Fintype.card (Set.range f) = Fintype.card α :=
   Eq.symm <| Fintype.card_congr <| Equiv.ofInjective _ <| EmbeddingLike.injective f
 #align fintype.card_range Fintype.card_range
+-/
 
 #print Fintype.exists_ne_map_eq_of_card_lt /-
 /-- The pigeonhole principle for finitely many pigeons and pigeonholes.
@@ -727,9 +757,11 @@ theorem two_lt_card_iff : 2 < card α ↔ ∃ a b c : α, a ≠ b ∧ a ≠ c 
 #align fintype.two_lt_card_iff Fintype.two_lt_card_iff
 -/
 
+#print Fintype.card_of_bijective /-
 theorem card_of_bijective {f : α → β} (hf : Bijective f) : card α = card β :=
   card_congr (Equiv.ofBijective f hf)
 #align fintype.card_of_bijective Fintype.card_of_bijective
+-/
 
 end Fintype
 
@@ -767,6 +799,7 @@ theorem surjective_iff_bijective {f : α → α} : Surjective f ↔ Bijective f
 #align finite.surjective_iff_bijective Finite.surjective_iff_bijective
 -/
 
+#print Finite.injective_iff_surjective_of_equiv /-
 theorem injective_iff_surjective_of_equiv {f : α → β} (e : α ≃ β) : Injective f ↔ Surjective f :=
   have : Injective (e.symm ∘ f) ↔ Surjective (e.symm ∘ f) := injective_iff_surjective
   ⟨fun hinj => by
@@ -774,6 +807,7 @@ theorem injective_iff_surjective_of_equiv {f : α → β} (e : α ≃ β) : Inje
     fun hsurj => by
     simpa [Function.comp] using e.injective.comp (this.2 (e.symm.surjective.comp hsurj))⟩
 #align finite.injective_iff_surjective_of_equiv Finite.injective_iff_surjective_of_equiv
+-/
 
 alias injective_iff_bijective ↔ _root_.function.injective.bijective_of_finite _
 #align function.injective.bijective_of_finite Function.Injective.bijective_of_finite
@@ -792,17 +826,21 @@ namespace Fintype
 
 variable [Fintype α] [Fintype β]
 
+#print Fintype.bijective_iff_injective_and_card /-
 theorem bijective_iff_injective_and_card (f : α → β) :
     Bijective f ↔ Injective f ∧ card α = card β :=
   ⟨fun h => ⟨h.1, card_of_bijective h⟩, fun h =>
     ⟨h.1, h.1.surjective_of_fintype <| equivOfCardEq h.2⟩⟩
 #align fintype.bijective_iff_injective_and_card Fintype.bijective_iff_injective_and_card
+-/
 
+#print Fintype.bijective_iff_surjective_and_card /-
 theorem bijective_iff_surjective_and_card (f : α → β) :
     Bijective f ↔ Surjective f ∧ card α = card β :=
   ⟨fun h => ⟨h.2, card_of_bijective h⟩, fun h =>
     ⟨h.1.injective_of_fintype <| equivOfCardEq h.2, h.1⟩⟩
 #align fintype.bijective_iff_surjective_and_card Fintype.bijective_iff_surjective_and_card
+-/
 
 #print Function.LeftInverse.rightInverse_of_card_le /-
 theorem Function.LeftInverse.rightInverse_of_card_le {f : α → β} {g : β → α} (hfg : LeftInverse f g)
@@ -923,6 +961,7 @@ theorem equiv_of_fintype_self_embedding_to_embedding [Finite α] (e : α ↪ α)
 #align function.embedding.equiv_of_fintype_self_embedding_to_embedding Function.Embedding.equiv_of_fintype_self_embedding_to_embedding
 -/
 
+#print Function.Embedding.is_empty_of_card_lt /-
 /-- If `‖β‖ < ‖α‖` there are no embeddings `α ↪ β`.
 This is a formulation of the pigeonhole principle.
 
@@ -934,6 +973,7 @@ theorem is_empty_of_card_lt [Fintype α] [Fintype β] (h : Fintype.card β < Fin
     let ⟨x, y, Ne, feq⟩ := Fintype.exists_ne_map_eq_of_card_lt f h
     Ne <| f.Injective feq⟩
 #align function.embedding.is_empty_of_card_lt Function.Embedding.is_empty_of_card_lt
+-/
 
 #print Function.Embedding.truncOfCardLe /-
 /-- A constructive embedding of a fintype `α` in another fintype `β` when `card α ≤ card β`. -/
@@ -945,15 +985,20 @@ def truncOfCardLe [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
 #align function.embedding.trunc_of_card_le Function.Embedding.truncOfCardLe
 -/
 
+#print Function.Embedding.nonempty_of_card_le /-
 theorem nonempty_of_card_le [Fintype α] [Fintype β] (h : Fintype.card α ≤ Fintype.card β) :
     Nonempty (α ↪ β) := by classical exact (trunc_of_card_le h).Nonempty
 #align function.embedding.nonempty_of_card_le Function.Embedding.nonempty_of_card_le
+-/
 
+#print Function.Embedding.nonempty_iff_card_le /-
 theorem nonempty_iff_card_le [Fintype α] [Fintype β] :
     Nonempty (α ↪ β) ↔ Fintype.card α ≤ Fintype.card β :=
   ⟨fun ⟨e⟩ => Fintype.card_le_of_embedding e, nonempty_of_card_le⟩
 #align function.embedding.nonempty_iff_card_le Function.Embedding.nonempty_iff_card_le
+-/
 
+#print Function.Embedding.exists_of_card_le_finset /-
 theorem exists_of_card_le_finset [Fintype α] {s : Finset β} (h : Fintype.card α ≤ s.card) :
     ∃ f : α ↪ β, Set.range f ⊆ s :=
   by
@@ -961,6 +1006,7 @@ theorem exists_of_card_le_finset [Fintype α] {s : Finset β} (h : Fintype.card
   rcases nonempty_of_card_le h with ⟨f⟩
   exact ⟨f.trans (embedding.subtype _), by simp [Set.range_subset_iff]⟩
 #align function.embedding.exists_of_card_le_finset Function.Embedding.exists_of_card_le_finset
+-/
 
 end Function.Embedding
 
@@ -973,12 +1019,14 @@ theorem Finset.univ_map_embedding {α : Type _} [Fintype α] (e : α ↪ α) : u
 
 namespace Fintype
 
+#print Fintype.card_lt_of_surjective_not_injective /-
 theorem card_lt_of_surjective_not_injective [Fintype α] [Fintype β] (f : α → β)
     (h : Function.Surjective f) (h' : ¬Function.Injective f) : card β < card α :=
   card_lt_of_injective_not_surjective _ (Function.injective_surjInv h) fun hg =>
     have w : Function.Bijective (Function.surjInv h) := ⟨Function.injective_surjInv h, hg⟩
     h' <| h.injective_of_fintype (Equiv.ofBijective _ w).symm
 #align fintype.card_lt_of_surjective_not_injective Fintype.card_lt_of_surjective_not_injective
+-/
 
 end Fintype
 
@@ -1144,6 +1192,7 @@ noncomputable def fintypeOrInfinite (α : Type _) : PSum (Fintype α) (Infinite
 
 end
 
+#print Finset.exists_minimal /-
 theorem Finset.exists_minimal {α : Type _} [Preorder α] (s : Finset α) (h : s.Nonempty) :
     ∃ m ∈ s, ∀ x ∈ s, ¬x < m := by
   obtain ⟨c, hcs : c ∈ s⟩ := h
@@ -1151,11 +1200,14 @@ theorem Finset.exists_minimal {α : Type _} [Preorder α] (s : Finset α) (h : s
   obtain ⟨⟨m, hms : m ∈ s⟩, -, H⟩ := this.has_min Set.univ ⟨⟨c, hcs⟩, trivial⟩
   exact ⟨m, hms, fun x hx hxm => H ⟨x, hx⟩ trivial hxm⟩
 #align finset.exists_minimal Finset.exists_minimal
+-/
 
+#print Finset.exists_maximal /-
 theorem Finset.exists_maximal {α : Type _} [Preorder α] (s : Finset α) (h : s.Nonempty) :
     ∃ m ∈ s, ∀ x ∈ s, ¬m < x :=
   @Finset.exists_minimal αᵒᵈ _ s h
 #align finset.exists_maximal Finset.exists_maximal
+-/
 
 namespace Infinite
 
@@ -1206,13 +1258,17 @@ protected theorem nonempty (α : Type _) [Infinite α] : Nonempty α := by infer
 #align infinite.nonempty Infinite.nonempty
 -/
 
+#print Infinite.of_injective /-
 theorem of_injective {α β} [Infinite β] (f : β → α) (hf : Injective f) : Infinite α :=
   ⟨fun I => (Finite.of_injective f hf).False⟩
 #align infinite.of_injective Infinite.of_injective
+-/
 
+#print Infinite.of_surjective /-
 theorem of_surjective {α β} [Infinite β] (f : α → β) (hf : Surjective f) : Infinite α :=
   ⟨fun I => (Finite.of_surjective f hf).False⟩
 #align infinite.of_surjective Infinite.of_surjective
+-/
 
 end Infinite
 
@@ -1342,10 +1398,13 @@ noncomputable def fintypeOfFinsetCardLe {ι : Type _} (n : ℕ) (w : ∀ s : Fin
 #align fintype_of_finset_card_le fintypeOfFinsetCardLe
 -/
 
+#print not_injective_infinite_finite /-
 theorem not_injective_infinite_finite {α β} [Infinite α] [Finite β] (f : α → β) : ¬Injective f :=
   fun hf => (Finite.of_injective f hf).False
 #align not_injective_infinite_finite not_injective_infinite_finite
+-/
 
+#print Finite.exists_ne_map_eq_of_infinite /-
 /-- The pigeonhole principle for infinitely many pigeons in finitely many pigeonholes. If there are
 infinitely many pigeons in finitely many pigeonholes, then there are at least two pigeons in the
 same pigeonhole.
@@ -1356,11 +1415,15 @@ theorem Finite.exists_ne_map_eq_of_infinite {α β} [Infinite α] [Finite β] (f
     ∃ x y : α, x ≠ y ∧ f x = f y := by
   simpa only [injective, not_forall, not_imp, and_comm] using not_injective_infinite_finite f
 #align finite.exists_ne_map_eq_of_infinite Finite.exists_ne_map_eq_of_infinite
+-/
 
+#print Function.Embedding.is_empty /-
 instance Function.Embedding.is_empty {α β} [Infinite α] [Finite β] : IsEmpty (α ↪ β) :=
   ⟨fun f => not_injective_infinite_finite f f.2⟩
 #align function.embedding.is_empty Function.Embedding.is_empty
+-/
 
+#print Finite.exists_infinite_fiber /-
 /-- The strong pigeonhole principle for infinitely many pigeons in
 finitely many pigeonholes.  If there are infinitely many pigeons in
 finitely many pigeonholes, then there is a pigeonhole with infinitely
@@ -1379,10 +1442,13 @@ theorem Finite.exists_infinite_fiber [Infinite α] [Finite β] (f : α → β) :
       complete := by simp }
   exact key.false
 #align finite.exists_infinite_fiber Finite.exists_infinite_fiber
+-/
 
+#print not_surjective_finite_infinite /-
 theorem not_surjective_finite_infinite {α β} [Finite α] [Infinite β] (f : α → β) : ¬Surjective f :=
   fun hf => (Infinite.of_surjective f hf).not_finite ‹_›
 #align not_surjective_finite_infinite not_surjective_finite_infinite
+-/
 
 section Trunc
 
Diff
@@ -567,7 +567,6 @@ theorem card_lt_of_injective_of_not_mem (f : α → β) (h : Function.Injective
     card α = (univ.map ⟨f, h⟩).card := (card_map _).symm
     _ < card β :=
       Finset.card_lt_univ_of_not_mem <| by rwa [← mem_coe, coe_map, coe_univ, Set.image_univ]
-    
 #align fintype.card_lt_of_injective_of_not_mem Fintype.card_lt_of_injective_of_not_mem
 
 theorem card_lt_of_injective_not_surjective (f : α → β) (h : Function.Injective f)
@@ -1179,7 +1178,6 @@ theorem of_injective_to_set {s : Set α} (hs : s ≠ Set.univ) {f : α → s} (h
       _ = s.to_finset.card := s.to_finset_card.symm
       _ < Fintype.card α :=
         Finset.card_lt_card <| by rwa [Set.toFinset_ssubset_univ, Set.ssubset_univ_iff]
-      
 #align infinite.of_injective_to_set Infinite.of_injective_to_set
 -/
 
Diff
@@ -684,9 +684,9 @@ theorem card_le_one_iff_subsingleton : card α ≤ 1 ↔ Subsingleton α :=
 #print Fintype.one_lt_card_iff_nontrivial /-
 theorem one_lt_card_iff_nontrivial : 1 < card α ↔ Nontrivial α := by
   classical
-    rw [← not_iff_not]
-    push_neg
-    rw [not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton]
+  rw [← not_iff_not]
+  push_neg
+  rw [not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton]
 #align fintype.one_lt_card_iff_nontrivial Fintype.one_lt_card_iff_nontrivial
 -/
 
@@ -782,8 +782,8 @@ alias injective_iff_bijective ↔ _root_.function.injective.bijective_of_finite
 alias surjective_iff_bijective ↔ _root_.function.surjective.bijective_of_finite _
 #align function.surjective.bijective_of_finite Function.Surjective.bijective_of_finite
 
-alias injective_iff_surjective_of_equiv ↔
-  _root_.function.injective.surjective_of_fintype _root_.function.surjective.injective_of_fintype
+alias injective_iff_surjective_of_equiv ↔ _root_.function.injective.surjective_of_fintype
+  _root_.function.surjective.injective_of_fintype
 #align function.injective.surjective_of_fintype Function.Injective.surjective_of_fintype
 #align function.surjective.injective_of_fintype Function.Surjective.injective_of_fintype
 
@@ -1013,10 +1013,10 @@ theorem Fintype.card_subtype_compl [Fintype α] (p : α → Prop) [Fintype { x /
     [Fintype { x // ¬p x }] :
     Fintype.card { x // ¬p x } = Fintype.card α - Fintype.card { x // p x } := by
   classical rw [Fintype.card_of_subtype (Set.toFinset (pᶜ)), Set.toFinset_compl p,
-            Finset.card_compl, Fintype.card_of_subtype (Set.toFinset p)] <;>
-          intro <;>
-        simp only [Set.mem_toFinset, Set.mem_compl_iff] <;>
-      rfl
+          Finset.card_compl, Fintype.card_of_subtype (Set.toFinset p)] <;>
+        intro <;>
+      simp only [Set.mem_toFinset, Set.mem_compl_iff] <;>
+    rfl
 #align fintype.card_subtype_compl Fintype.card_subtype_compl
 -/
 
@@ -1070,17 +1070,15 @@ variable [Finite α]
 theorem wellFounded_of_trans_of_irrefl (r : α → α → Prop) [IsTrans α r] [IsIrrefl α r] :
     WellFounded r := by
   classical cases nonempty_fintype α <;>
-      exact
-        have :
-          ∀ x y, r x y → (univ.filter fun z => r z x).card < (univ.filter fun z => r z y).card :=
-          fun x y hxy =>
-          Finset.card_lt_card <| by
-            simp only [finset.lt_iff_ssubset.symm, lt_iff_le_not_le, Finset.le_iff_subset,
-                Finset.subset_iff, mem_filter, true_and_iff, mem_univ, hxy] <;>
-              exact
-                ⟨fun z hzx => trans hzx hxy,
-                  not_forall_of_exists_not ⟨x, not_imp.2 ⟨hxy, irrefl x⟩⟩⟩
-        Subrelation.wf this (measure_wf _)
+    exact
+      have : ∀ x y, r x y → (univ.filter fun z => r z x).card < (univ.filter fun z => r z y).card :=
+        fun x y hxy =>
+        Finset.card_lt_card <| by
+          simp only [finset.lt_iff_ssubset.symm, lt_iff_le_not_le, Finset.le_iff_subset,
+              Finset.subset_iff, mem_filter, true_and_iff, mem_univ, hxy] <;>
+            exact
+              ⟨fun z hzx => trans hzx hxy, not_forall_of_exists_not ⟨x, not_imp.2 ⟨hxy, irrefl x⟩⟩⟩
+      Subrelation.wf this (measure_wf _)
 #align finite.well_founded_of_trans_of_irrefl Finite.wellFounded_of_trans_of_irrefl
 -/
 
@@ -1175,13 +1173,13 @@ theorem of_injective_to_set {s : Set α} (hs : s ≠ Set.univ) {f : α → s} (h
   of_not_fintype fun h => by
     skip
     classical
-      refine' lt_irrefl (Fintype.card α) _
-      calc
-        Fintype.card α ≤ Fintype.card s := Fintype.card_le_of_injective f hf
-        _ = s.to_finset.card := s.to_finset_card.symm
-        _ < Fintype.card α :=
-          Finset.card_lt_card <| by rwa [Set.toFinset_ssubset_univ, Set.ssubset_univ_iff]
-        
+    refine' lt_irrefl (Fintype.card α) _
+    calc
+      Fintype.card α ≤ Fintype.card s := Fintype.card_le_of_injective f hf
+      _ = s.to_finset.card := s.to_finset_card.symm
+      _ < Fintype.card α :=
+        Finset.card_lt_card <| by rwa [Set.toFinset_ssubset_univ, Set.ssubset_univ_iff]
+      
 #align infinite.of_injective_to_set Infinite.of_injective_to_set
 -/
 
@@ -1375,13 +1373,13 @@ See also: `finite.exists_ne_map_eq_of_infinite`
 theorem Finite.exists_infinite_fiber [Infinite α] [Finite β] (f : α → β) :
     ∃ y : β, Infinite (f ⁻¹' {y}) := by
   classical
-    by_contra' hf
-    cases nonempty_fintype β
-    haveI := fun y => fintypeOfNotInfinite <| hf y
-    let key : Fintype α :=
-      { elems := univ.bUnion fun y : β => (f ⁻¹' {y}).toFinset
-        complete := by simp }
-    exact key.false
+  by_contra' hf
+  cases nonempty_fintype β
+  haveI := fun y => fintypeOfNotInfinite <| hf y
+  let key : Fintype α :=
+    { elems := univ.bUnion fun y : β => (f ⁻¹' {y}).toFinset
+      complete := by simp }
+  exact key.false
 #align finite.exists_infinite_fiber Finite.exists_infinite_fiber
 
 theorem not_surjective_finite_infinite {α β} [Finite α] [Infinite β] (f : α → β) : ¬Surjective f :=
Diff
@@ -525,7 +525,7 @@ noncomputable def Fintype.ofFinite (α : Type _) [Finite α] : Fintype α :=
 theorem Finite.of_injective {α β : Sort _} [Finite β] (f : α → β) (H : Injective f) : Finite α :=
   by
   cases nonempty_fintype (PLift β)
-  rw [← Equiv.injective_comp Equiv.plift f, ← Equiv.comp_injective _ equiv.plift.symm] at H
+  rw [← Equiv.injective_comp Equiv.plift f, ← Equiv.comp_injective _ equiv.plift.symm] at H 
   haveI := Fintype.ofInjective _ H
   exact Finite.of_equiv _ Equiv.plift
 #align finite.of_injective Finite.of_injective
@@ -538,7 +538,7 @@ theorem Finite.of_surjective {α β : Sort _} [Finite α] (f : α → β) (H : S
 theorem Finite.exists_univ_list (α) [Finite α] : ∃ l : List α, l.Nodup ∧ ∀ x : α, x ∈ l :=
   by
   cases nonempty_fintype α; obtain ⟨l, e⟩ := Quotient.exists_rep (@univ α _).1
-  have := And.intro univ.2 mem_univ_val; exact ⟨_, by rwa [← e] at this⟩
+  have := And.intro univ.2 mem_univ_val; exact ⟨_, by rwa [← e] at this ⟩
 #align finite.exists_univ_list Finite.exists_univ_list
 -/
 
@@ -670,7 +670,7 @@ theorem card_le_one_iff : card α ≤ 1 ↔ ∀ a b : α, a = b :=
       let ⟨x, hx⟩ := card_eq_one_iff.1 ha.symm
       rw [hx a, hx b], fun _ => ha ▸ le_rfl⟩
   | n + 2 => fun ha =>
-    ⟨fun h => by rw [← ha] at h <;> exact absurd h (by decide), fun h =>
+    ⟨fun h => by rw [← ha] at h  <;> exact absurd h (by decide), fun h =>
       card_unit ▸ card_le_of_injective (fun _ => ()) fun _ _ _ => h _ _⟩
 #align fintype.card_le_one_iff Fintype.card_le_one_iff
 -/
@@ -958,7 +958,7 @@ theorem nonempty_iff_card_le [Fintype α] [Fintype β] :
 theorem exists_of_card_le_finset [Fintype α] {s : Finset β} (h : Fintype.card α ≤ s.card) :
     ∃ f : α ↪ β, Set.range f ⊆ s :=
   by
-  rw [← Fintype.card_coe] at h
+  rw [← Fintype.card_coe] at h 
   rcases nonempty_of_card_le h with ⟨f⟩
   exact ⟨f.trans (embedding.subtype _), by simp [Set.range_subset_iff]⟩
 #align function.embedding.exists_of_card_le_finset Function.Embedding.exists_of_card_le_finset
@@ -1341,7 +1341,7 @@ noncomputable def fintypeOfFinsetCardLe {ι : Type _} (n : ℕ) (w : ∀ s : Fin
   intro i
   obtain ⟨s, c⟩ := Infinite.exists_subset_card_eq ι (n + 1)
   specialize w s
-  rw [c] at w
+  rw [c] at w 
   exact Nat.not_succ_le_self n w
 #align fintype_of_finset_card_le fintypeOfFinsetCardLe
 -/
@@ -1422,7 +1422,7 @@ theorem Fintype.induction_subsingleton_or_nontrivial {P : ∀ (α) [Fintype α],
   · apply hbase
   · apply hstep
     intro β _ hlt
-    rw [hn] at hlt
+    rw [hn] at hlt 
     exact ih (Fintype.card β) hlt _ rfl
 #align fintype.induction_subsingleton_or_nontrivial Fintype.induction_subsingleton_or_nontrivial
 -/
Diff
@@ -54,7 +54,7 @@ We provide `infinite` instances for
 
 open Function
 
-open Nat
+open scoped Nat
 
 universe u v
 
@@ -1084,21 +1084,29 @@ theorem wellFounded_of_trans_of_irrefl (r : α → α → Prop) [IsTrans α r] [
 #align finite.well_founded_of_trans_of_irrefl Finite.wellFounded_of_trans_of_irrefl
 -/
 
+#print Finite.Preorder.wellFounded_lt /-
 theorem Preorder.wellFounded_lt [Preorder α] : WellFounded ((· < ·) : α → α → Prop) :=
   wellFounded_of_trans_of_irrefl _
 #align finite.preorder.well_founded_lt Finite.Preorder.wellFounded_lt
+-/
 
+#print Finite.Preorder.wellFounded_gt /-
 theorem Preorder.wellFounded_gt [Preorder α] : WellFounded ((· > ·) : α → α → Prop) :=
   wellFounded_of_trans_of_irrefl _
 #align finite.preorder.well_founded_gt Finite.Preorder.wellFounded_gt
+-/
 
+#print Finite.LinearOrder.isWellOrder_lt /-
 instance (priority := 10) LinearOrder.isWellOrder_lt [LinearOrder α] : IsWellOrder α (· < ·)
     where wf := Preorder.wellFounded_lt
 #align finite.linear_order.is_well_order_lt Finite.LinearOrder.isWellOrder_lt
+-/
 
+#print Finite.LinearOrder.isWellOrder_gt /-
 instance (priority := 10) LinearOrder.isWellOrder_gt [LinearOrder α] : IsWellOrder α (· > ·)
     where wf := Preorder.wellFounded_gt
 #align finite.linear_order.is_well_order_gt Finite.LinearOrder.isWellOrder_gt
+-/
 
 end Finite
 
@@ -1125,7 +1133,7 @@ noncomputable def fintypeOfNotInfinite {α : Type _} (h : ¬Infinite α) : Finty
 
 section
 
-open Classical
+open scoped Classical
 
 #print fintypeOrInfinite /-
 /-- Any type is (classically) either a `fintype`, or `infinite`.
Diff
@@ -158,22 +158,10 @@ end Fintype
 
 namespace Fintype
 
-/- warning: fintype.of_equiv_card -> Fintype.ofEquiv_card is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] (f : Equiv.{succ u1, succ u2} α β), Eq.{1} Nat (Fintype.card.{u2} β (Fintype.ofEquiv.{u2, u1} β α _inst_1 f)) (Fintype.card.{u1} α _inst_1)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] (f : Equiv.{succ u2, succ u1} α β), Eq.{1} Nat (Fintype.card.{u1} β (Fintype.ofEquiv.{u1, u2} β α _inst_1 f)) (Fintype.card.{u2} α _inst_1)
-Case conversion may be inaccurate. Consider using '#align fintype.of_equiv_card Fintype.ofEquiv_cardₓ'. -/
 theorem ofEquiv_card [Fintype α] (f : α ≃ β) : @card β (ofEquiv α f) = card α :=
   Multiset.card_map _ _
 #align fintype.of_equiv_card Fintype.ofEquiv_card
 
-/- warning: fintype.card_congr -> Fintype.card_congr is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β], (Equiv.{succ u1, succ u2} α β) -> (Eq.{1} Nat (Fintype.card.{u1} α _inst_1) (Fintype.card.{u2} β _inst_2))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : Fintype.{u1} β], (Equiv.{succ u2, succ u1} α β) -> (Eq.{1} Nat (Fintype.card.{u2} α _inst_1) (Fintype.card.{u1} β _inst_2))
-Case conversion may be inaccurate. Consider using '#align fintype.card_congr Fintype.card_congrₓ'. -/
 theorem card_congr {α β} [Fintype α] [Fintype β] (f : α ≃ β) : card α = card β := by
   rw [← of_equiv_card f] <;> congr
 #align fintype.card_congr Fintype.card_congr
@@ -240,12 +228,6 @@ noncomputable def equivOfCardEq (h : card α = card β) : α ≃ β :=
 
 end
 
-/- warning: fintype.card_eq -> Fintype.card_eq is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [F : Fintype.{u1} α] [G : Fintype.{u2} β], Iff (Eq.{1} Nat (Fintype.card.{u1} α F) (Fintype.card.{u2} β G)) (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}} [F : Fintype.{u2} α] [G : Fintype.{u1} β], Iff (Eq.{1} Nat (Fintype.card.{u2} α F) (Fintype.card.{u1} β G)) (Nonempty.{max (succ u1) (succ u2)} (Equiv.{succ u2, succ u1} α β))
-Case conversion may be inaccurate. Consider using '#align fintype.card_eq Fintype.card_eqₓ'. -/
 theorem card_eq {α β} [F : Fintype α] [G : Fintype β] : card α = card β ↔ Nonempty (α ≃ β) :=
   ⟨fun h =>
     haveI := Classical.propDecidable
@@ -357,12 +339,6 @@ theorem Finset.card_compl [DecidableEq α] [Fintype α] (s : Finset α) :
 #align finset.card_compl Finset.card_compl
 -/
 
-/- warning: fintype.card_compl_set -> Fintype.card_compl_set is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} [_inst_1 : Fintype.{u1} α] (s : Set.{u1} α) [_inst_2 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s)] [_inst_3 : Fintype.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s))], Eq.{1} Nat (Fintype.card.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.booleanAlgebra.{u1} α)) s)) _inst_3) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Fintype.card.{u1} α _inst_1) (Fintype.card.{u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) s) _inst_2))
-but is expected to have type
-  forall {α : Type.{u1}} [_inst_1 : Fintype.{u1} α] (s : Set.{u1} α) [_inst_2 : Fintype.{u1} (Set.Elem.{u1} α s)] [_inst_3 : Fintype.{u1} (Set.Elem.{u1} α (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s))], Eq.{1} Nat (Fintype.card.{u1} (Set.Elem.{u1} α (HasCompl.compl.{u1} (Set.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Set.{u1} α) (Set.instBooleanAlgebraSet.{u1} α)) s)) _inst_3) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Fintype.card.{u1} α _inst_1) (Fintype.card.{u1} (Set.Elem.{u1} α s) _inst_2))
-Case conversion may be inaccurate. Consider using '#align fintype.card_compl_set Fintype.card_compl_setₓ'. -/
 theorem Fintype.card_compl_set [Fintype α] (s : Set α) [Fintype s] [Fintype ↥(sᶜ)] :
     Fintype.card ↥(sᶜ) = Fintype.card α - Fintype.card s := by
   classical rw [← Set.toFinset_card, ← Set.toFinset_card, ← Finset.card_compl, Set.toFinset_compl]
@@ -390,12 +366,6 @@ theorem fin_injective : Function.Injective Fin := fun m n h =>
 #align fin_injective fin_injective
 -/
 
-/- warning: fin.cast_eq_cast' -> Fin.cast_eq_cast' is a dubious translation:
-lean 3 declaration is
-  forall {n : Nat} {m : Nat} (h : Eq.{2} Type (Fin n) (Fin m)), Eq.{1} ((Fin n) -> (Fin m)) (cast.{1} (Fin n) (Fin m) h) (coeFn.{1, 1} (OrderIso.{0, 0} (Fin n) (Fin m) (Fin.hasLe n) (Fin.hasLe m)) (fun (_x : RelIso.{0, 0} (Fin n) (Fin m) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin m) (Fin.hasLe m))) => (Fin n) -> (Fin m)) (RelIso.hasCoeToFun.{0, 0} (Fin n) (Fin m) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin m) (Fin.hasLe m))) (Fin.cast n m (fin_injective n m h)))
-but is expected to have type
-  forall {n : Nat} {m : Nat} (h : Eq.{2} Type (Fin n) (Fin m)), Eq.{1} ((Fin n) -> (Fin m)) (cast.{1} (Fin n) (Fin m) h) (FunLike.coe.{1, 1, 1} (RelIso.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1285 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1287 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1285 x._@.Mathlib.Order.Hom.Basic._hyg.1287) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1300 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1302 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1300 x._@.Mathlib.Order.Hom.Basic._hyg.1302)) (Fin n) (fun (_x : Fin n) => Fin m) (RelHomClass.toFunLike.{0, 0, 0} (RelIso.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1285 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1287 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1285 x._@.Mathlib.Order.Hom.Basic._hyg.1287) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1300 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1302 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1300 x._@.Mathlib.Order.Hom.Basic._hyg.1302)) (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1285 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1287 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1285 x._@.Mathlib.Order.Hom.Basic._hyg.1287) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1300 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1302 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1300 x._@.Mathlib.Order.Hom.Basic._hyg.1302) (RelIso.instRelHomClassRelIso.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1285 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1287 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1285 x._@.Mathlib.Order.Hom.Basic._hyg.1287) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1300 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1302 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1300 x._@.Mathlib.Order.Hom.Basic._hyg.1302))) (Fin.cast n m (fin_injective n m h)))
-Case conversion may be inaccurate. Consider using '#align fin.cast_eq_cast' Fin.cast_eq_cast'ₓ'. -/
 /-- A reversed version of `fin.cast_eq_cast` that is easier to rewrite with. -/
 theorem Fin.cast_eq_cast' {n m : ℕ} (h : Fin n = Fin m) : cast h = ⇑(Fin.cast <| fin_injective h) :=
   (Fin.cast_eq_cast _).symm
@@ -463,12 +433,6 @@ theorem Fintype.card_bool : Fintype.card Bool = 2 :=
 #align fintype.card_bool Fintype.card_bool
 -/
 
-/- warning: fintype.card_ulift -> Fintype.card_ulift is a dubious translation:
-lean 3 declaration is
-  forall (α : Type.{u1}) [_inst_1 : Fintype.{u1} α], Eq.{1} Nat (Fintype.card.{max u1 u2} (ULift.{u2, u1} α) (ULift.fintype.{u1, u2} α _inst_1)) (Fintype.card.{u1} α _inst_1)
-but is expected to have type
-  forall (α : Type.{u2}) [_inst_1 : Fintype.{u2} α], Eq.{1} Nat (Fintype.card.{max u2 u1} (ULift.{u1, u2} α) (ULift.fintype.{u2, u1} α _inst_1)) (Fintype.card.{u2} α _inst_1)
-Case conversion may be inaccurate. Consider using '#align fintype.card_ulift Fintype.card_uliftₓ'. -/
 @[simp]
 theorem Fintype.card_ulift (α : Type _) [Fintype α] : Fintype.card (ULift α) = Fintype.card α :=
   Fintype.ofEquiv_card _
@@ -558,12 +522,6 @@ noncomputable def Fintype.ofFinite (α : Type _) [Finite α] : Fintype α :=
 #align fintype.of_finite Fintype.ofFinite
 -/
 
-/- warning: finite.of_injective -> Finite.of_injective is a dubious translation:
-lean 3 declaration is
-  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Finite.{u2} β] (f : α -> β), (Function.Injective.{u1, u2} α β f) -> (Finite.{u1} α)
-but is expected to have type
-  forall {α : Sort.{u2}} {β : Sort.{u1}} [_inst_1 : Finite.{u1} β] (f : α -> β), (Function.Injective.{u2, u1} α β f) -> (Finite.{u2} α)
-Case conversion may be inaccurate. Consider using '#align finite.of_injective Finite.of_injectiveₓ'. -/
 theorem Finite.of_injective {α β : Sort _} [Finite β] (f : α → β) (H : Injective f) : Finite α :=
   by
   cases nonempty_fintype (PLift β)
@@ -572,12 +530,6 @@ theorem Finite.of_injective {α β : Sort _} [Finite β] (f : α → β) (H : In
   exact Finite.of_equiv _ Equiv.plift
 #align finite.of_injective Finite.of_injective
 
-/- warning: finite.of_surjective -> Finite.of_surjective is a dubious translation:
-lean 3 declaration is
-  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Finite.{u1} α] (f : α -> β), (Function.Surjective.{u1, u2} α β f) -> (Finite.{u2} β)
-but is expected to have type
-  forall {α : Sort.{u2}} {β : Sort.{u1}} [_inst_1 : Finite.{u2} α] (f : α -> β), (Function.Surjective.{u2, u1} α β f) -> (Finite.{u1} β)
-Case conversion may be inaccurate. Consider using '#align finite.of_surjective Finite.of_surjectiveₓ'. -/
 theorem Finite.of_surjective {α β : Sort _} [Finite α] (f : α → β) (H : Surjective f) : Finite β :=
   Finite.of_injective _ <| injective_surjInv H
 #align finite.of_surjective Finite.of_surjective
@@ -601,32 +553,14 @@ namespace Fintype
 
 variable [Fintype α] [Fintype β]
 
-/- warning: fintype.card_le_of_injective -> Fintype.card_le_of_injective is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β] (f : α -> β), (Function.Injective.{succ u1, succ u2} α β f) -> (LE.le.{0} Nat Nat.hasLe (Fintype.card.{u1} α _inst_1) (Fintype.card.{u2} β _inst_2))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : Fintype.{u1} β] (f : α -> β), (Function.Injective.{succ u2, succ u1} α β f) -> (LE.le.{0} Nat instLENat (Fintype.card.{u2} α _inst_1) (Fintype.card.{u1} β _inst_2))
-Case conversion may be inaccurate. Consider using '#align fintype.card_le_of_injective Fintype.card_le_of_injectiveₓ'. -/
 theorem card_le_of_injective (f : α → β) (hf : Function.Injective f) : card α ≤ card β :=
   Finset.card_le_card_of_inj_on f (fun _ _ => Finset.mem_univ _) fun _ _ _ _ h => hf h
 #align fintype.card_le_of_injective Fintype.card_le_of_injective
 
-/- warning: fintype.card_le_of_embedding -> Fintype.card_le_of_embedding is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β], (Function.Embedding.{succ u1, succ u2} α β) -> (LE.le.{0} Nat Nat.hasLe (Fintype.card.{u1} α _inst_1) (Fintype.card.{u2} β _inst_2))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : Fintype.{u1} β], (Function.Embedding.{succ u2, succ u1} α β) -> (LE.le.{0} Nat instLENat (Fintype.card.{u2} α _inst_1) (Fintype.card.{u1} β _inst_2))
-Case conversion may be inaccurate. Consider using '#align fintype.card_le_of_embedding Fintype.card_le_of_embeddingₓ'. -/
 theorem card_le_of_embedding (f : α ↪ β) : card α ≤ card β :=
   card_le_of_injective f f.2
 #align fintype.card_le_of_embedding Fintype.card_le_of_embedding
 
-/- warning: fintype.card_lt_of_injective_of_not_mem -> Fintype.card_lt_of_injective_of_not_mem is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β] (f : α -> β), (Function.Injective.{succ u1, succ u2} α β f) -> (forall {b : β}, (Not (Membership.Mem.{u2, u2} β (Set.{u2} β) (Set.hasMem.{u2} β) b (Set.range.{u2, succ u1} β α f))) -> (LT.lt.{0} Nat Nat.hasLt (Fintype.card.{u1} α _inst_1) (Fintype.card.{u2} β _inst_2)))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : Fintype.{u1} β] (f : α -> β), (Function.Injective.{succ u2, succ u1} α β f) -> (forall {b : β}, (Not (Membership.mem.{u1, u1} β (Set.{u1} β) (Set.instMembershipSet.{u1} β) b (Set.range.{u1, succ u2} β α f))) -> (LT.lt.{0} Nat instLTNat (Fintype.card.{u2} α _inst_1) (Fintype.card.{u1} β _inst_2)))
-Case conversion may be inaccurate. Consider using '#align fintype.card_lt_of_injective_of_not_mem Fintype.card_lt_of_injective_of_not_memₓ'. -/
 theorem card_lt_of_injective_of_not_mem (f : α → β) (h : Function.Injective f) {b : β}
     (w : b ∉ Set.range f) : card α < card β :=
   calc
@@ -636,45 +570,21 @@ theorem card_lt_of_injective_of_not_mem (f : α → β) (h : Function.Injective
     
 #align fintype.card_lt_of_injective_of_not_mem Fintype.card_lt_of_injective_of_not_mem
 
-/- warning: fintype.card_lt_of_injective_not_surjective -> Fintype.card_lt_of_injective_not_surjective is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β] (f : α -> β), (Function.Injective.{succ u1, succ u2} α β f) -> (Not (Function.Surjective.{succ u1, succ u2} α β f)) -> (LT.lt.{0} Nat Nat.hasLt (Fintype.card.{u1} α _inst_1) (Fintype.card.{u2} β _inst_2))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : Fintype.{u1} β] (f : α -> β), (Function.Injective.{succ u2, succ u1} α β f) -> (Not (Function.Surjective.{succ u2, succ u1} α β f)) -> (LT.lt.{0} Nat instLTNat (Fintype.card.{u2} α _inst_1) (Fintype.card.{u1} β _inst_2))
-Case conversion may be inaccurate. Consider using '#align fintype.card_lt_of_injective_not_surjective Fintype.card_lt_of_injective_not_surjectiveₓ'. -/
 theorem card_lt_of_injective_not_surjective (f : α → β) (h : Function.Injective f)
     (h' : ¬Function.Surjective f) : card α < card β :=
   let ⟨y, hy⟩ := not_forall.1 h'
   card_lt_of_injective_of_not_mem f h hy
 #align fintype.card_lt_of_injective_not_surjective Fintype.card_lt_of_injective_not_surjective
 
-/- warning: fintype.card_le_of_surjective -> Fintype.card_le_of_surjective is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β] (f : α -> β), (Function.Surjective.{succ u1, succ u2} α β f) -> (LE.le.{0} Nat Nat.hasLe (Fintype.card.{u2} β _inst_2) (Fintype.card.{u1} α _inst_1))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : Fintype.{u1} β] (f : α -> β), (Function.Surjective.{succ u2, succ u1} α β f) -> (LE.le.{0} Nat instLENat (Fintype.card.{u1} β _inst_2) (Fintype.card.{u2} α _inst_1))
-Case conversion may be inaccurate. Consider using '#align fintype.card_le_of_surjective Fintype.card_le_of_surjectiveₓ'. -/
 theorem card_le_of_surjective (f : α → β) (h : Function.Surjective f) : card β ≤ card α :=
   card_le_of_injective _ (Function.injective_surjInv h)
 #align fintype.card_le_of_surjective Fintype.card_le_of_surjective
 
-/- warning: fintype.card_range_le -> Fintype.card_range_le is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} (f : α -> β) [_inst_3 : Fintype.{u1} α] [_inst_4 : Fintype.{u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} β) Type.{u2} (Set.hasCoeToSort.{u2} β) (Set.range.{u2, succ u1} β α f))], LE.le.{0} Nat Nat.hasLe (Fintype.card.{u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} β) Type.{u2} (Set.hasCoeToSort.{u2} β) (Set.range.{u2, succ u1} β α f)) _inst_4) (Fintype.card.{u1} α _inst_3)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} (f : α -> β) [_inst_3 : Fintype.{u2} α] [_inst_4 : Fintype.{u1} (Set.Elem.{u1} β (Set.range.{u1, succ u2} β α f))], LE.le.{0} Nat instLENat (Fintype.card.{u1} (Set.Elem.{u1} β (Set.range.{u1, succ u2} β α f)) _inst_4) (Fintype.card.{u2} α _inst_3)
-Case conversion may be inaccurate. Consider using '#align fintype.card_range_le Fintype.card_range_leₓ'. -/
 theorem card_range_le {α β : Type _} (f : α → β) [Fintype α] [Fintype (Set.range f)] :
     Fintype.card (Set.range f) ≤ Fintype.card α :=
   Fintype.card_le_of_surjective (fun a => ⟨f a, by simp⟩) fun ⟨_, a, ha⟩ => ⟨a, by simpa using ha⟩
 #align fintype.card_range_le Fintype.card_range_le
 
-/- warning: fintype.card_range -> Fintype.card_range is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {F : Type.{u3}} [_inst_3 : EmbeddingLike.{succ u3, succ u1, succ u2} F α β] (f : F) [_inst_4 : Fintype.{u1} α] [_inst_5 : Fintype.{u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} β) Type.{u2} (Set.hasCoeToSort.{u2} β) (Set.range.{u2, succ u1} β α (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F α (fun (_x : α) => β) (EmbeddingLike.toFunLike.{succ u3, succ u1, succ u2} F α β _inst_3)) f)))], Eq.{1} Nat (Fintype.card.{u2} (coeSort.{succ u2, succ (succ u2)} (Set.{u2} β) Type.{u2} (Set.hasCoeToSort.{u2} β) (Set.range.{u2, succ u1} β α (coeFn.{succ u3, max (succ u1) (succ u2)} F (fun (_x : F) => α -> β) (FunLike.hasCoeToFun.{succ u3, succ u1, succ u2} F α (fun (_x : α) => β) (EmbeddingLike.toFunLike.{succ u3, succ u1, succ u2} F α β _inst_3)) f))) _inst_5) (Fintype.card.{u1} α _inst_4)
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u2}} {F : Type.{u1}} [_inst_3 : EmbeddingLike.{succ u1, succ u3, succ u2} F α β] (f : F) [_inst_4 : Fintype.{u3} α] [_inst_5 : Fintype.{u2} (Set.Elem.{u2} β (Set.range.{u2, succ u3} β α (FunLike.coe.{succ u1, succ u3, succ u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{succ u1, succ u3, succ u2} F α β _inst_3) f)))], Eq.{1} Nat (Fintype.card.{u2} (Set.Elem.{u2} β (Set.range.{u2, succ u3} β α (FunLike.coe.{succ u1, succ u3, succ u2} F α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{succ u1, succ u3, succ u2} F α β _inst_3) f))) _inst_5) (Fintype.card.{u3} α _inst_4)
-Case conversion may be inaccurate. Consider using '#align fintype.card_range Fintype.card_rangeₓ'. -/
 theorem card_range {α β F : Type _} [EmbeddingLike F α β] (f : F) [Fintype α]
     [Fintype (Set.range f)] : Fintype.card (Set.range f) = Fintype.card α :=
   Eq.symm <| Fintype.card_congr <| Equiv.ofInjective _ <| EmbeddingLike.injective f
@@ -818,12 +728,6 @@ theorem two_lt_card_iff : 2 < card α ↔ ∃ a b c : α, a ≠ b ∧ a ≠ c 
 #align fintype.two_lt_card_iff Fintype.two_lt_card_iff
 -/
 
-/- warning: fintype.card_of_bijective -> Fintype.card_of_bijective is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β] {f : α -> β}, (Function.Bijective.{succ u1, succ u2} α β f) -> (Eq.{1} Nat (Fintype.card.{u1} α _inst_1) (Fintype.card.{u2} β _inst_2))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : Fintype.{u1} β] {f : α -> β}, (Function.Bijective.{succ u2, succ u1} α β f) -> (Eq.{1} Nat (Fintype.card.{u2} α _inst_1) (Fintype.card.{u1} β _inst_2))
-Case conversion may be inaccurate. Consider using '#align fintype.card_of_bijective Fintype.card_of_bijectiveₓ'. -/
 theorem card_of_bijective {f : α → β} (hf : Bijective f) : card α = card β :=
   card_congr (Equiv.ofBijective f hf)
 #align fintype.card_of_bijective Fintype.card_of_bijective
@@ -864,12 +768,6 @@ theorem surjective_iff_bijective {f : α → α} : Surjective f ↔ Bijective f
 #align finite.surjective_iff_bijective Finite.surjective_iff_bijective
 -/
 
-/- warning: finite.injective_iff_surjective_of_equiv -> Finite.injective_iff_surjective_of_equiv is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Finite.{succ u1} α] {f : α -> β}, (Equiv.{succ u1, succ u2} α β) -> (Iff (Function.Injective.{succ u1, succ u2} α β f) (Function.Surjective.{succ u1, succ u2} α β f))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Finite.{succ u2} α] {f : α -> β}, (Equiv.{succ u2, succ u1} α β) -> (Iff (Function.Injective.{succ u2, succ u1} α β f) (Function.Surjective.{succ u2, succ u1} α β f))
-Case conversion may be inaccurate. Consider using '#align finite.injective_iff_surjective_of_equiv Finite.injective_iff_surjective_of_equivₓ'. -/
 theorem injective_iff_surjective_of_equiv {f : α → β} (e : α ≃ β) : Injective f ↔ Surjective f :=
   have : Injective (e.symm ∘ f) ↔ Surjective (e.symm ∘ f) := injective_iff_surjective
   ⟨fun hinj => by
@@ -884,18 +782,6 @@ alias injective_iff_bijective ↔ _root_.function.injective.bijective_of_finite
 alias surjective_iff_bijective ↔ _root_.function.surjective.bijective_of_finite _
 #align function.surjective.bijective_of_finite Function.Surjective.bijective_of_finite
 
-/- warning: function.injective.surjective_of_fintype -> Function.Injective.surjective_of_fintype is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Finite.{succ u1} α] {f : α -> β}, (Equiv.{succ u1, succ u2} α β) -> (Function.Injective.{succ u1, succ u2} α β f) -> (Function.Surjective.{succ u1, succ u2} α β f)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Finite.{succ u2} α] {f : α -> β}, (Equiv.{succ u2, succ u1} α β) -> (Function.Injective.{succ u2, succ u1} α β f) -> (Function.Surjective.{succ u2, succ u1} α β f)
-Case conversion may be inaccurate. Consider using '#align function.injective.surjective_of_fintype Function.Injective.surjective_of_fintypeₓ'. -/
-/- warning: function.surjective.injective_of_fintype -> Function.Surjective.injective_of_fintype is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Finite.{succ u1} α] {f : α -> β}, (Equiv.{succ u1, succ u2} α β) -> (Function.Surjective.{succ u1, succ u2} α β f) -> (Function.Injective.{succ u1, succ u2} α β f)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Finite.{succ u2} α] {f : α -> β}, (Equiv.{succ u2, succ u1} α β) -> (Function.Surjective.{succ u2, succ u1} α β f) -> (Function.Injective.{succ u2, succ u1} α β f)
-Case conversion may be inaccurate. Consider using '#align function.surjective.injective_of_fintype Function.Surjective.injective_of_fintypeₓ'. -/
 alias injective_iff_surjective_of_equiv ↔
   _root_.function.injective.surjective_of_fintype _root_.function.surjective.injective_of_fintype
 #align function.injective.surjective_of_fintype Function.Injective.surjective_of_fintype
@@ -907,24 +793,12 @@ namespace Fintype
 
 variable [Fintype α] [Fintype β]
 
-/- warning: fintype.bijective_iff_injective_and_card -> Fintype.bijective_iff_injective_and_card is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β] (f : α -> β), Iff (Function.Bijective.{succ u1, succ u2} α β f) (And (Function.Injective.{succ u1, succ u2} α β f) (Eq.{1} Nat (Fintype.card.{u1} α _inst_1) (Fintype.card.{u2} β _inst_2)))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : Fintype.{u1} β] (f : α -> β), Iff (Function.Bijective.{succ u2, succ u1} α β f) (And (Function.Injective.{succ u2, succ u1} α β f) (Eq.{1} Nat (Fintype.card.{u2} α _inst_1) (Fintype.card.{u1} β _inst_2)))
-Case conversion may be inaccurate. Consider using '#align fintype.bijective_iff_injective_and_card Fintype.bijective_iff_injective_and_cardₓ'. -/
 theorem bijective_iff_injective_and_card (f : α → β) :
     Bijective f ↔ Injective f ∧ card α = card β :=
   ⟨fun h => ⟨h.1, card_of_bijective h⟩, fun h =>
     ⟨h.1, h.1.surjective_of_fintype <| equivOfCardEq h.2⟩⟩
 #align fintype.bijective_iff_injective_and_card Fintype.bijective_iff_injective_and_card
 
-/- warning: fintype.bijective_iff_surjective_and_card -> Fintype.bijective_iff_surjective_and_card is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β] (f : α -> β), Iff (Function.Bijective.{succ u1, succ u2} α β f) (And (Function.Surjective.{succ u1, succ u2} α β f) (Eq.{1} Nat (Fintype.card.{u1} α _inst_1) (Fintype.card.{u2} β _inst_2)))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : Fintype.{u1} β] (f : α -> β), Iff (Function.Bijective.{succ u2, succ u1} α β f) (And (Function.Surjective.{succ u2, succ u1} α β f) (Eq.{1} Nat (Fintype.card.{u2} α _inst_1) (Fintype.card.{u1} β _inst_2)))
-Case conversion may be inaccurate. Consider using '#align fintype.bijective_iff_surjective_and_card Fintype.bijective_iff_surjective_and_cardₓ'. -/
 theorem bijective_iff_surjective_and_card (f : α → β) :
     Bijective f ↔ Surjective f ∧ card α = card β :=
   ⟨fun h => ⟨h.2, card_of_bijective h⟩, fun h =>
@@ -1050,12 +924,6 @@ theorem equiv_of_fintype_self_embedding_to_embedding [Finite α] (e : α ↪ α)
 #align function.embedding.equiv_of_fintype_self_embedding_to_embedding Function.Embedding.equiv_of_fintype_self_embedding_to_embedding
 -/
 
-/- warning: function.embedding.is_empty_of_card_lt -> Function.Embedding.is_empty_of_card_lt is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β], (LT.lt.{0} Nat Nat.hasLt (Fintype.card.{u2} β _inst_2) (Fintype.card.{u1} α _inst_1)) -> (IsEmpty.{max 1 (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : Fintype.{u1} β], (LT.lt.{0} Nat instLTNat (Fintype.card.{u1} β _inst_2) (Fintype.card.{u2} α _inst_1)) -> (IsEmpty.{max (succ u1) (succ u2)} (Function.Embedding.{succ u2, succ u1} α β))
-Case conversion may be inaccurate. Consider using '#align function.embedding.is_empty_of_card_lt Function.Embedding.is_empty_of_card_ltₓ'. -/
 /-- If `‖β‖ < ‖α‖` there are no embeddings `α ↪ β`.
 This is a formulation of the pigeonhole principle.
 
@@ -1078,33 +946,15 @@ def truncOfCardLe [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
 #align function.embedding.trunc_of_card_le Function.Embedding.truncOfCardLe
 -/
 
-/- warning: function.embedding.nonempty_of_card_le -> Function.Embedding.nonempty_of_card_le is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β], (LE.le.{0} Nat Nat.hasLe (Fintype.card.{u1} α _inst_1) (Fintype.card.{u2} β _inst_2)) -> (Nonempty.{max 1 (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : Fintype.{u1} β], (LE.le.{0} Nat instLENat (Fintype.card.{u2} α _inst_1) (Fintype.card.{u1} β _inst_2)) -> (Nonempty.{max (succ u1) (succ u2)} (Function.Embedding.{succ u2, succ u1} α β))
-Case conversion may be inaccurate. Consider using '#align function.embedding.nonempty_of_card_le Function.Embedding.nonempty_of_card_leₓ'. -/
 theorem nonempty_of_card_le [Fintype α] [Fintype β] (h : Fintype.card α ≤ Fintype.card β) :
     Nonempty (α ↪ β) := by classical exact (trunc_of_card_le h).Nonempty
 #align function.embedding.nonempty_of_card_le Function.Embedding.nonempty_of_card_le
 
-/- warning: function.embedding.nonempty_iff_card_le -> Function.Embedding.nonempty_iff_card_le is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β], Iff (Nonempty.{max 1 (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β)) (LE.le.{0} Nat Nat.hasLe (Fintype.card.{u1} α _inst_1) (Fintype.card.{u2} β _inst_2))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : Fintype.{u1} β], Iff (Nonempty.{max (succ u1) (succ u2)} (Function.Embedding.{succ u2, succ u1} α β)) (LE.le.{0} Nat instLENat (Fintype.card.{u2} α _inst_1) (Fintype.card.{u1} β _inst_2))
-Case conversion may be inaccurate. Consider using '#align function.embedding.nonempty_iff_card_le Function.Embedding.nonempty_iff_card_leₓ'. -/
 theorem nonempty_iff_card_le [Fintype α] [Fintype β] :
     Nonempty (α ↪ β) ↔ Fintype.card α ≤ Fintype.card β :=
   ⟨fun ⟨e⟩ => Fintype.card_le_of_embedding e, nonempty_of_card_le⟩
 #align function.embedding.nonempty_iff_card_le Function.Embedding.nonempty_iff_card_le
 
-/- warning: function.embedding.exists_of_card_le_finset -> Function.Embedding.exists_of_card_le_finset is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] {s : Finset.{u2} β}, (LE.le.{0} Nat Nat.hasLe (Fintype.card.{u1} α _inst_1) (Finset.card.{u2} β s)) -> (Exists.{max 1 (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (f : Function.Embedding.{succ u1, succ u2} α β) => HasSubset.Subset.{u2} (Set.{u2} β) (Set.hasSubset.{u2} β) (Set.range.{u2, succ u1} β α (coeFn.{max 1 (succ u1) (succ u2), max (succ u1) (succ u2)} (Function.Embedding.{succ u1, succ u2} α β) (fun (_x : Function.Embedding.{succ u1, succ u2} α β) => α -> β) (Function.Embedding.hasCoeToFun.{succ u1, succ u2} α β) f)) ((fun (a : Type.{u2}) (b : Type.{u2}) [self : HasLiftT.{succ u2, succ u2} a b] => self.0) (Finset.{u2} β) (Set.{u2} β) (HasLiftT.mk.{succ u2, succ u2} (Finset.{u2} β) (Set.{u2} β) (CoeTCₓ.coe.{succ u2, succ u2} (Finset.{u2} β) (Set.{u2} β) (Finset.Set.hasCoeT.{u2} β))) s)))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] {s : Finset.{u1} β}, (LE.le.{0} Nat instLENat (Fintype.card.{u2} α _inst_1) (Finset.card.{u1} β s)) -> (Exists.{max (succ u2) (succ u1)} (Function.Embedding.{succ u2, succ u1} α β) (fun (f : Function.Embedding.{succ u2, succ u1} α β) => HasSubset.Subset.{u1} (Set.{u1} β) (Set.instHasSubsetSet.{u1} β) (Set.range.{u1, succ u2} β α (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α (fun (_x : α) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : α) => β) _x) (EmbeddingLike.toFunLike.{max (succ u2) (succ u1), succ u2, succ u1} (Function.Embedding.{succ u2, succ u1} α β) α β (Function.instEmbeddingLikeEmbedding.{succ u2, succ u1} α β)) f)) (Finset.toSet.{u1} β s)))
-Case conversion may be inaccurate. Consider using '#align function.embedding.exists_of_card_le_finset Function.Embedding.exists_of_card_le_finsetₓ'. -/
 theorem exists_of_card_le_finset [Fintype α] {s : Finset β} (h : Fintype.card α ≤ s.card) :
     ∃ f : α ↪ β, Set.range f ⊆ s :=
   by
@@ -1124,12 +974,6 @@ theorem Finset.univ_map_embedding {α : Type _} [Fintype α] (e : α ↪ α) : u
 
 namespace Fintype
 
-/- warning: fintype.card_lt_of_surjective_not_injective -> Fintype.card_lt_of_surjective_not_injective is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Fintype.{u1} α] [_inst_2 : Fintype.{u2} β] (f : α -> β), (Function.Surjective.{succ u1, succ u2} α β f) -> (Not (Function.Injective.{succ u1, succ u2} α β f)) -> (LT.lt.{0} Nat Nat.hasLt (Fintype.card.{u2} β _inst_2) (Fintype.card.{u1} α _inst_1))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Fintype.{u2} α] [_inst_2 : Fintype.{u1} β] (f : α -> β), (Function.Surjective.{succ u2, succ u1} α β f) -> (Not (Function.Injective.{succ u2, succ u1} α β f)) -> (LT.lt.{0} Nat instLTNat (Fintype.card.{u1} β _inst_2) (Fintype.card.{u2} α _inst_1))
-Case conversion may be inaccurate. Consider using '#align fintype.card_lt_of_surjective_not_injective Fintype.card_lt_of_surjective_not_injectiveₓ'. -/
 theorem card_lt_of_surjective_not_injective [Fintype α] [Fintype β] (f : α → β)
     (h : Function.Surjective f) (h' : ¬Function.Injective f) : card β < card α :=
   card_lt_of_injective_not_surjective _ (Function.injective_surjInv h) fun hg =>
@@ -1240,42 +1084,18 @@ theorem wellFounded_of_trans_of_irrefl (r : α → α → Prop) [IsTrans α r] [
 #align finite.well_founded_of_trans_of_irrefl Finite.wellFounded_of_trans_of_irrefl
 -/
 
-/- warning: finite.preorder.well_founded_lt -> Finite.Preorder.wellFounded_lt is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : Preorder.{u1} α], WellFounded.{succ u1} α (LT.lt.{u1} α (Preorder.toHasLt.{u1} α _inst_2))
-but is expected to have type
-  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : Preorder.{u1} α], WellFounded.{succ u1} α (fun (x._@.Mathlib.Data.Fintype.Card._hyg.6398 : α) (x._@.Mathlib.Data.Fintype.Card._hyg.6400 : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) x._@.Mathlib.Data.Fintype.Card._hyg.6398 x._@.Mathlib.Data.Fintype.Card._hyg.6400)
-Case conversion may be inaccurate. Consider using '#align finite.preorder.well_founded_lt Finite.Preorder.wellFounded_ltₓ'. -/
 theorem Preorder.wellFounded_lt [Preorder α] : WellFounded ((· < ·) : α → α → Prop) :=
   wellFounded_of_trans_of_irrefl _
 #align finite.preorder.well_founded_lt Finite.Preorder.wellFounded_lt
 
-/- warning: finite.preorder.well_founded_gt -> Finite.Preorder.wellFounded_gt is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : Preorder.{u1} α], WellFounded.{succ u1} α (GT.gt.{u1} α (Preorder.toHasLt.{u1} α _inst_2))
-but is expected to have type
-  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : Preorder.{u1} α], WellFounded.{succ u1} α (fun (x._@.Mathlib.Data.Fintype.Card._hyg.6438 : α) (x._@.Mathlib.Data.Fintype.Card._hyg.6440 : α) => GT.gt.{u1} α (Preorder.toLT.{u1} α _inst_2) x._@.Mathlib.Data.Fintype.Card._hyg.6438 x._@.Mathlib.Data.Fintype.Card._hyg.6440)
-Case conversion may be inaccurate. Consider using '#align finite.preorder.well_founded_gt Finite.Preorder.wellFounded_gtₓ'. -/
 theorem Preorder.wellFounded_gt [Preorder α] : WellFounded ((· > ·) : α → α → Prop) :=
   wellFounded_of_trans_of_irrefl _
 #align finite.preorder.well_founded_gt Finite.Preorder.wellFounded_gt
 
-/- warning: finite.linear_order.is_well_order_lt -> Finite.LinearOrder.isWellOrder_lt is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : LinearOrder.{u1} α], IsWellOrder.{u1} α (LT.lt.{u1} α (Preorder.toHasLt.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))))
-but is expected to have type
-  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : LinearOrder.{u1} α], IsWellOrder.{u1} α (fun (x._@.Mathlib.Data.Fintype.Card._hyg.6472 : α) (x._@.Mathlib.Data.Fintype.Card._hyg.6474 : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) x._@.Mathlib.Data.Fintype.Card._hyg.6472 x._@.Mathlib.Data.Fintype.Card._hyg.6474)
-Case conversion may be inaccurate. Consider using '#align finite.linear_order.is_well_order_lt Finite.LinearOrder.isWellOrder_ltₓ'. -/
 instance (priority := 10) LinearOrder.isWellOrder_lt [LinearOrder α] : IsWellOrder α (· < ·)
     where wf := Preorder.wellFounded_lt
 #align finite.linear_order.is_well_order_lt Finite.LinearOrder.isWellOrder_lt
 
-/- warning: finite.linear_order.is_well_order_gt -> Finite.LinearOrder.isWellOrder_gt is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : LinearOrder.{u1} α], IsWellOrder.{u1} α (GT.gt.{u1} α (Preorder.toHasLt.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))))
-but is expected to have type
-  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : LinearOrder.{u1} α], IsWellOrder.{u1} α (fun (x._@.Mathlib.Data.Fintype.Card._hyg.6509 : α) (x._@.Mathlib.Data.Fintype.Card._hyg.6511 : α) => GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) x._@.Mathlib.Data.Fintype.Card._hyg.6509 x._@.Mathlib.Data.Fintype.Card._hyg.6511)
-Case conversion may be inaccurate. Consider using '#align finite.linear_order.is_well_order_gt Finite.LinearOrder.isWellOrder_gtₓ'. -/
 instance (priority := 10) LinearOrder.isWellOrder_gt [LinearOrder α] : IsWellOrder α (· > ·)
     where wf := Preorder.wellFounded_gt
 #align finite.linear_order.is_well_order_gt Finite.LinearOrder.isWellOrder_gt
@@ -1319,12 +1139,6 @@ noncomputable def fintypeOrInfinite (α : Type _) : PSum (Fintype α) (Infinite
 
 end
 
-/- warning: finset.exists_minimal -> Finset.exists_minimal is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Finset.{u1} α), (Finset.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (m : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) m s) (fun (H : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) m s) => forall (x : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) x s) -> (Not (LT.lt.{u1} α (Preorder.toHasLt.{u1} α _inst_1) x m)))))
-but is expected to have type
-  forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Finset.{u1} α), (Finset.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (m : α) => And (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) m s) (forall (x : α), (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) x s) -> (Not (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_1) x m)))))
-Case conversion may be inaccurate. Consider using '#align finset.exists_minimal Finset.exists_minimalₓ'. -/
 theorem Finset.exists_minimal {α : Type _} [Preorder α] (s : Finset α) (h : s.Nonempty) :
     ∃ m ∈ s, ∀ x ∈ s, ¬x < m := by
   obtain ⟨c, hcs : c ∈ s⟩ := h
@@ -1333,12 +1147,6 @@ theorem Finset.exists_minimal {α : Type _} [Preorder α] (s : Finset α) (h : s
   exact ⟨m, hms, fun x hx hxm => H ⟨x, hx⟩ trivial hxm⟩
 #align finset.exists_minimal Finset.exists_minimal
 
-/- warning: finset.exists_maximal -> Finset.exists_maximal is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Finset.{u1} α), (Finset.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (m : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) m s) (fun (H : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) m s) => forall (x : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) x s) -> (Not (LT.lt.{u1} α (Preorder.toHasLt.{u1} α _inst_1) m x)))))
-but is expected to have type
-  forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Finset.{u1} α), (Finset.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (m : α) => And (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) m s) (forall (x : α), (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) x s) -> (Not (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_1) m x)))))
-Case conversion may be inaccurate. Consider using '#align finset.exists_maximal Finset.exists_maximalₓ'. -/
 theorem Finset.exists_maximal {α : Type _} [Preorder α] (s : Finset α) (h : s.Nonempty) :
     ∃ m ∈ s, ∀ x ∈ s, ¬m < x :=
   @Finset.exists_minimal αᵒᵈ _ s h
@@ -1394,22 +1202,10 @@ protected theorem nonempty (α : Type _) [Infinite α] : Nonempty α := by infer
 #align infinite.nonempty Infinite.nonempty
 -/
 
-/- warning: infinite.of_injective -> Infinite.of_injective is a dubious translation:
-lean 3 declaration is
-  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Infinite.{u2} β] (f : β -> α), (Function.Injective.{u2, u1} β α f) -> (Infinite.{u1} α)
-but is expected to have type
-  forall {α : Sort.{u2}} {β : Sort.{u1}} [_inst_1 : Infinite.{u1} β] (f : β -> α), (Function.Injective.{u1, u2} β α f) -> (Infinite.{u2} α)
-Case conversion may be inaccurate. Consider using '#align infinite.of_injective Infinite.of_injectiveₓ'. -/
 theorem of_injective {α β} [Infinite β] (f : β → α) (hf : Injective f) : Infinite α :=
   ⟨fun I => (Finite.of_injective f hf).False⟩
 #align infinite.of_injective Infinite.of_injective
 
-/- warning: infinite.of_surjective -> Infinite.of_surjective is a dubious translation:
-lean 3 declaration is
-  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Infinite.{u2} β] (f : α -> β), (Function.Surjective.{u1, u2} α β f) -> (Infinite.{u1} α)
-but is expected to have type
-  forall {α : Sort.{u2}} {β : Sort.{u1}} [_inst_1 : Infinite.{u1} β] (f : α -> β), (Function.Surjective.{u2, u1} α β f) -> (Infinite.{u2} α)
-Case conversion may be inaccurate. Consider using '#align infinite.of_surjective Infinite.of_surjectiveₓ'. -/
 theorem of_surjective {α β} [Infinite β] (f : α → β) (hf : Surjective f) : Infinite α :=
   ⟨fun I => (Finite.of_surjective f hf).False⟩
 #align infinite.of_surjective Infinite.of_surjective
@@ -1542,22 +1338,10 @@ noncomputable def fintypeOfFinsetCardLe {ι : Type _} (n : ℕ) (w : ∀ s : Fin
 #align fintype_of_finset_card_le fintypeOfFinsetCardLe
 -/
 
-/- warning: not_injective_infinite_finite -> not_injective_infinite_finite is a dubious translation:
-lean 3 declaration is
-  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Infinite.{u1} α] [_inst_2 : Finite.{u2} β] (f : α -> β), Not (Function.Injective.{u1, u2} α β f)
-but is expected to have type
-  forall {α : Sort.{u2}} {β : Sort.{u1}} [_inst_1 : Infinite.{u2} α] [_inst_2 : Finite.{u1} β] (f : α -> β), Not (Function.Injective.{u2, u1} α β f)
-Case conversion may be inaccurate. Consider using '#align not_injective_infinite_finite not_injective_infinite_finiteₓ'. -/
 theorem not_injective_infinite_finite {α β} [Infinite α] [Finite β] (f : α → β) : ¬Injective f :=
   fun hf => (Finite.of_injective f hf).False
 #align not_injective_infinite_finite not_injective_infinite_finite
 
-/- warning: finite.exists_ne_map_eq_of_infinite -> Finite.exists_ne_map_eq_of_infinite is a dubious translation:
-lean 3 declaration is
-  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Infinite.{u1} α] [_inst_2 : Finite.{u2} β] (f : α -> β), Exists.{u1} α (fun (x : α) => Exists.{u1} α (fun (y : α) => And (Ne.{u1} α x y) (Eq.{u2} β (f x) (f y))))
-but is expected to have type
-  forall {α : Sort.{u2}} {β : Sort.{u1}} [_inst_1 : Infinite.{u2} α] [_inst_2 : Finite.{u1} β] (f : α -> β), Exists.{u2} α (fun (x : α) => Exists.{u2} α (fun (y : α) => And (Ne.{u2} α x y) (Eq.{u1} β (f x) (f y))))
-Case conversion may be inaccurate. Consider using '#align finite.exists_ne_map_eq_of_infinite Finite.exists_ne_map_eq_of_infiniteₓ'. -/
 /-- The pigeonhole principle for infinitely many pigeons in finitely many pigeonholes. If there are
 infinitely many pigeons in finitely many pigeonholes, then there are at least two pigeons in the
 same pigeonhole.
@@ -1569,22 +1353,10 @@ theorem Finite.exists_ne_map_eq_of_infinite {α β} [Infinite α] [Finite β] (f
   simpa only [injective, not_forall, not_imp, and_comm] using not_injective_infinite_finite f
 #align finite.exists_ne_map_eq_of_infinite Finite.exists_ne_map_eq_of_infinite
 
-/- warning: function.embedding.is_empty -> Function.Embedding.is_empty is a dubious translation:
-lean 3 declaration is
-  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Infinite.{u1} α] [_inst_2 : Finite.{u2} β], IsEmpty.{max 1 (imax u1 u2)} (Function.Embedding.{u1, u2} α β)
-but is expected to have type
-  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Infinite.{u1} α] [_inst_2 : Finite.{u2} β], IsEmpty.{max (max 1 u2) u1} (Function.Embedding.{u1, u2} α β)
-Case conversion may be inaccurate. Consider using '#align function.embedding.is_empty Function.Embedding.is_emptyₓ'. -/
 instance Function.Embedding.is_empty {α β} [Infinite α] [Finite β] : IsEmpty (α ↪ β) :=
   ⟨fun f => not_injective_infinite_finite f f.2⟩
 #align function.embedding.is_empty Function.Embedding.is_empty
 
-/- warning: finite.exists_infinite_fiber -> Finite.exists_infinite_fiber is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} [_inst_1 : Infinite.{succ u1} α] [_inst_2 : Finite.{succ u2} β] (f : α -> β), Exists.{succ u2} β (fun (y : β) => Infinite.{succ u1} (coeSort.{succ u1, succ (succ u1)} (Set.{u1} α) Type.{u1} (Set.hasCoeToSort.{u1} α) (Set.preimage.{u1, u2} α β f (Singleton.singleton.{u2, u2} β (Set.{u2} β) (Set.hasSingleton.{u2} β) y))))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}} [_inst_1 : Infinite.{succ u2} α] [_inst_2 : Finite.{succ u1} β] (f : α -> β), Exists.{succ u1} β (fun (y : β) => Infinite.{succ u2} (Set.Elem.{u2} α (Set.preimage.{u2, u1} α β f (Singleton.singleton.{u1, u1} β (Set.{u1} β) (Set.instSingletonSet.{u1} β) y))))
-Case conversion may be inaccurate. Consider using '#align finite.exists_infinite_fiber Finite.exists_infinite_fiberₓ'. -/
 /-- The strong pigeonhole principle for infinitely many pigeons in
 finitely many pigeonholes.  If there are infinitely many pigeons in
 finitely many pigeonholes, then there is a pigeonhole with infinitely
@@ -1604,12 +1376,6 @@ theorem Finite.exists_infinite_fiber [Infinite α] [Finite β] (f : α → β) :
     exact key.false
 #align finite.exists_infinite_fiber Finite.exists_infinite_fiber
 
-/- warning: not_surjective_finite_infinite -> not_surjective_finite_infinite is a dubious translation:
-lean 3 declaration is
-  forall {α : Sort.{u1}} {β : Sort.{u2}} [_inst_1 : Finite.{u1} α] [_inst_2 : Infinite.{u2} β] (f : α -> β), Not (Function.Surjective.{u1, u2} α β f)
-but is expected to have type
-  forall {α : Sort.{u2}} {β : Sort.{u1}} [_inst_1 : Finite.{u2} α] [_inst_2 : Infinite.{u1} β] (f : α -> β), Not (Function.Surjective.{u2, u1} α β f)
-Case conversion may be inaccurate. Consider using '#align not_surjective_finite_infinite not_surjective_finite_infiniteₓ'. -/
 theorem not_surjective_finite_infinite {α β} [Finite α] [Infinite β] (f : α → β) : ¬Surjective f :=
   fun hf => (Infinite.of_surjective f hf).not_finite ‹_›
 #align not_surjective_finite_infinite not_surjective_finite_infinite
Diff
@@ -136,10 +136,7 @@ theorem subtype_card {p : α → Prop} (s : Finset α) (H : ∀ x : α, x ∈ s
 
 #print Fintype.card_of_subtype /-
 theorem card_of_subtype {p : α → Prop} (s : Finset α) (H : ∀ x : α, x ∈ s ↔ p x)
-    [Fintype { x // p x }] : card { x // p x } = s.card :=
-  by
-  rw [← subtype_card s H]
-  congr
+    [Fintype { x // p x }] : card { x // p x } = s.card := by rw [← subtype_card s H]; congr
 #align fintype.card_of_subtype Fintype.card_of_subtype
 -/
 
@@ -236,8 +233,7 @@ the specialization to `fin`.
 -/
 noncomputable def equivOfCardEq (h : card α = card β) : α ≃ β :=
   by
-  letI := Classical.decEq α
-  letI := Classical.decEq β
+  letI := Classical.decEq α; letI := Classical.decEq β
   exact (trunc_equiv_of_card_eq h).out
 #align fintype.equiv_of_card_eq Fintype.equivOfCardEq
 -/
@@ -316,9 +312,7 @@ theorem Finset.eq_univ_of_card [Fintype α] (s : Finset α) (hs : s.card = Finty
 #print Finset.card_eq_iff_eq_univ /-
 theorem Finset.card_eq_iff_eq_univ [Fintype α] (s : Finset α) :
     s.card = Fintype.card α ↔ s = Finset.univ :=
-  ⟨s.eq_univ_of_card, by
-    rintro rfl
-    exact Finset.card_univ⟩
+  ⟨s.eq_univ_of_card, by rintro rfl; exact Finset.card_univ⟩
 #align finset.card_eq_iff_eq_univ Finset.card_eq_iff_eq_univ
 -/
 
@@ -591,10 +585,8 @@ theorem Finite.of_surjective {α β : Sort _} [Finite α] (f : α → β) (H : S
 #print Finite.exists_univ_list /-
 theorem Finite.exists_univ_list (α) [Finite α] : ∃ l : List α, l.Nodup ∧ ∀ x : α, x ∈ l :=
   by
-  cases nonempty_fintype α
-  obtain ⟨l, e⟩ := Quotient.exists_rep (@univ α _).1
-  have := And.intro univ.2 mem_univ_val
-  exact ⟨_, by rwa [← e] at this⟩
+  cases nonempty_fintype α; obtain ⟨l, e⟩ := Quotient.exists_rep (@univ α _).1
+  have := And.intro univ.2 mem_univ_val; exact ⟨_, by rwa [← e] at this⟩
 #align finite.exists_univ_list Finite.exists_univ_list
 -/
 
@@ -1054,10 +1046,7 @@ noncomputable def equivOfFintypeSelfEmbedding [Finite α] (e : α ↪ α) : α 
 #print Function.Embedding.equiv_of_fintype_self_embedding_to_embedding /-
 @[simp]
 theorem equiv_of_fintype_self_embedding_to_embedding [Finite α] (e : α ↪ α) :
-    e.equivOfFintypeSelfEmbedding.toEmbedding = e :=
-  by
-  ext
-  rfl
+    e.equivOfFintypeSelfEmbedding.toEmbedding = e := by ext; rfl
 #align function.embedding.equiv_of_fintype_self_embedding_to_embedding Function.Embedding.equiv_of_fintype_self_embedding_to_embedding
 -/
 
@@ -1199,9 +1188,7 @@ theorem Fintype.card_subtype_mono (p q : α → Prop) (h : p ≤ q) [Fintype { x
 theorem Fintype.card_compl_eq_card_compl [Finite α] (p q : α → Prop) [Fintype { x // p x }]
     [Fintype { x // ¬p x }] [Fintype { x // q x }] [Fintype { x // ¬q x }]
     (h : Fintype.card { x // p x } = Fintype.card { x // q x }) :
-    Fintype.card { x // ¬p x } = Fintype.card { x // ¬q x } :=
-  by
-  cases nonempty_fintype α
+    Fintype.card { x // ¬p x } = Fintype.card { x // ¬q x } := by cases nonempty_fintype α;
   simp only [Fintype.card_subtype_compl, h]
 #align fintype.card_compl_eq_card_compl Fintype.card_compl_eq_card_compl
 -/
Diff
@@ -1489,7 +1489,6 @@ private noncomputable def nat_embedding_aux (α : Type _) [Infinite α] : ℕ 
       (exists_not_mem_finset
         ((Multiset.range n).pmap (fun m (hm : m < n) => nat_embedding_aux m) fun _ =>
             Multiset.mem_range.1).toFinset)
-#align infinite.nat_embedding_aux infinite.nat_embedding_aux
 
 private theorem nat_embedding_aux_injective (α : Type _) [Infinite α] :
     Function.Injective (natEmbeddingAux α) :=
@@ -1508,7 +1507,6 @@ private theorem nat_embedding_aux_injective (α : Type _) [Infinite α] :
       _
   refine' Multiset.mem_toFinset.2 (Multiset.mem_pmap.2 ⟨m, Multiset.mem_range.2 hmn, _⟩)
   rw [h, nat_embedding_aux]
-#align infinite.nat_embedding_aux_injective infinite.nat_embedding_aux_injective
 
 #print Infinite.natEmbedding /-
 /-- Embedding of `ℕ` into an infinite type. -/
@@ -1675,7 +1673,6 @@ open Positivity
 private theorem card_univ_pos (α : Type _) [Fintype α] [Nonempty α] :
     0 < (Finset.univ : Finset α).card :=
   Finset.univ_nonempty.card_pos
-#align tactic.card_univ_pos tactic.card_univ_pos
 
 /-- Extension for the `positivity` tactic: `finset.card s` is positive if `s` is nonempty. -/
 @[positivity]
Diff
@@ -400,7 +400,7 @@ theorem fin_injective : Function.Injective Fin := fun m n h =>
 lean 3 declaration is
   forall {n : Nat} {m : Nat} (h : Eq.{2} Type (Fin n) (Fin m)), Eq.{1} ((Fin n) -> (Fin m)) (cast.{1} (Fin n) (Fin m) h) (coeFn.{1, 1} (OrderIso.{0, 0} (Fin n) (Fin m) (Fin.hasLe n) (Fin.hasLe m)) (fun (_x : RelIso.{0, 0} (Fin n) (Fin m) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin m) (Fin.hasLe m))) => (Fin n) -> (Fin m)) (RelIso.hasCoeToFun.{0, 0} (Fin n) (Fin m) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin m) (Fin.hasLe m))) (Fin.cast n m (fin_injective n m h)))
 but is expected to have type
-  forall {n : Nat} {m : Nat} (h : Eq.{2} Type (Fin n) (Fin m)), Eq.{1} ((Fin n) -> (Fin m)) (cast.{1} (Fin n) (Fin m) h) (FunLike.coe.{1, 1, 1} (RelIso.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298)) (Fin n) (fun (_x : Fin n) => Fin m) (RelHomClass.toFunLike.{0, 0, 0} (RelIso.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298)) (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.instRelHomClassRelIso.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298))) (Fin.cast n m (fin_injective n m h)))
+  forall {n : Nat} {m : Nat} (h : Eq.{2} Type (Fin n) (Fin m)), Eq.{1} ((Fin n) -> (Fin m)) (cast.{1} (Fin n) (Fin m) h) (FunLike.coe.{1, 1, 1} (RelIso.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1285 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1287 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1285 x._@.Mathlib.Order.Hom.Basic._hyg.1287) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1300 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1302 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1300 x._@.Mathlib.Order.Hom.Basic._hyg.1302)) (Fin n) (fun (_x : Fin n) => Fin m) (RelHomClass.toFunLike.{0, 0, 0} (RelIso.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1285 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1287 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1285 x._@.Mathlib.Order.Hom.Basic._hyg.1287) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1300 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1302 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1300 x._@.Mathlib.Order.Hom.Basic._hyg.1302)) (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1285 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1287 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1285 x._@.Mathlib.Order.Hom.Basic._hyg.1287) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1300 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1302 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1300 x._@.Mathlib.Order.Hom.Basic._hyg.1302) (RelIso.instRelHomClassRelIso.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1285 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1287 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1285 x._@.Mathlib.Order.Hom.Basic._hyg.1287) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1300 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1302 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1300 x._@.Mathlib.Order.Hom.Basic._hyg.1302))) (Fin.cast n m (fin_injective n m h)))
 Case conversion may be inaccurate. Consider using '#align fin.cast_eq_cast' Fin.cast_eq_cast'ₓ'. -/
 /-- A reversed version of `fin.cast_eq_cast` that is easier to rewrite with. -/
 theorem Fin.cast_eq_cast' {n m : ℕ} (h : Fin n = Fin m) : cast h = ⇑(Fin.cast <| fin_injective h) :=
Diff
@@ -1253,29 +1253,45 @@ theorem wellFounded_of_trans_of_irrefl (r : α → α → Prop) [IsTrans α r] [
 #align finite.well_founded_of_trans_of_irrefl Finite.wellFounded_of_trans_of_irrefl
 -/
 
-#print Finite.Preorder.wellFounded_lt /-
+/- warning: finite.preorder.well_founded_lt -> Finite.Preorder.wellFounded_lt is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : Preorder.{u1} α], WellFounded.{succ u1} α (LT.lt.{u1} α (Preorder.toHasLt.{u1} α _inst_2))
+but is expected to have type
+  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : Preorder.{u1} α], WellFounded.{succ u1} α (fun (x._@.Mathlib.Data.Fintype.Card._hyg.6398 : α) (x._@.Mathlib.Data.Fintype.Card._hyg.6400 : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_2) x._@.Mathlib.Data.Fintype.Card._hyg.6398 x._@.Mathlib.Data.Fintype.Card._hyg.6400)
+Case conversion may be inaccurate. Consider using '#align finite.preorder.well_founded_lt Finite.Preorder.wellFounded_ltₓ'. -/
 theorem Preorder.wellFounded_lt [Preorder α] : WellFounded ((· < ·) : α → α → Prop) :=
   wellFounded_of_trans_of_irrefl _
 #align finite.preorder.well_founded_lt Finite.Preorder.wellFounded_lt
--/
 
-#print Finite.Preorder.wellFounded_gt /-
+/- warning: finite.preorder.well_founded_gt -> Finite.Preorder.wellFounded_gt is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : Preorder.{u1} α], WellFounded.{succ u1} α (GT.gt.{u1} α (Preorder.toHasLt.{u1} α _inst_2))
+but is expected to have type
+  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : Preorder.{u1} α], WellFounded.{succ u1} α (fun (x._@.Mathlib.Data.Fintype.Card._hyg.6438 : α) (x._@.Mathlib.Data.Fintype.Card._hyg.6440 : α) => GT.gt.{u1} α (Preorder.toLT.{u1} α _inst_2) x._@.Mathlib.Data.Fintype.Card._hyg.6438 x._@.Mathlib.Data.Fintype.Card._hyg.6440)
+Case conversion may be inaccurate. Consider using '#align finite.preorder.well_founded_gt Finite.Preorder.wellFounded_gtₓ'. -/
 theorem Preorder.wellFounded_gt [Preorder α] : WellFounded ((· > ·) : α → α → Prop) :=
   wellFounded_of_trans_of_irrefl _
 #align finite.preorder.well_founded_gt Finite.Preorder.wellFounded_gt
--/
 
-#print Finite.LinearOrder.isWellOrder_lt /-
+/- warning: finite.linear_order.is_well_order_lt -> Finite.LinearOrder.isWellOrder_lt is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : LinearOrder.{u1} α], IsWellOrder.{u1} α (LT.lt.{u1} α (Preorder.toHasLt.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))))
+but is expected to have type
+  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : LinearOrder.{u1} α], IsWellOrder.{u1} α (fun (x._@.Mathlib.Data.Fintype.Card._hyg.6472 : α) (x._@.Mathlib.Data.Fintype.Card._hyg.6474 : α) => LT.lt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) x._@.Mathlib.Data.Fintype.Card._hyg.6472 x._@.Mathlib.Data.Fintype.Card._hyg.6474)
+Case conversion may be inaccurate. Consider using '#align finite.linear_order.is_well_order_lt Finite.LinearOrder.isWellOrder_ltₓ'. -/
 instance (priority := 10) LinearOrder.isWellOrder_lt [LinearOrder α] : IsWellOrder α (· < ·)
     where wf := Preorder.wellFounded_lt
 #align finite.linear_order.is_well_order_lt Finite.LinearOrder.isWellOrder_lt
--/
 
-#print Finite.LinearOrder.isWellOrder_gt /-
+/- warning: finite.linear_order.is_well_order_gt -> Finite.LinearOrder.isWellOrder_gt is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : LinearOrder.{u1} α], IsWellOrder.{u1} α (GT.gt.{u1} α (Preorder.toHasLt.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (LinearOrder.toLattice.{u1} α _inst_2))))))
+but is expected to have type
+  forall {α : Type.{u1}} [_inst_1 : Finite.{succ u1} α] [_inst_2 : LinearOrder.{u1} α], IsWellOrder.{u1} α (fun (x._@.Mathlib.Data.Fintype.Card._hyg.6509 : α) (x._@.Mathlib.Data.Fintype.Card._hyg.6511 : α) => GT.gt.{u1} α (Preorder.toLT.{u1} α (PartialOrder.toPreorder.{u1} α (SemilatticeInf.toPartialOrder.{u1} α (Lattice.toSemilatticeInf.{u1} α (DistribLattice.toLattice.{u1} α (instDistribLattice.{u1} α _inst_2)))))) x._@.Mathlib.Data.Fintype.Card._hyg.6509 x._@.Mathlib.Data.Fintype.Card._hyg.6511)
+Case conversion may be inaccurate. Consider using '#align finite.linear_order.is_well_order_gt Finite.LinearOrder.isWellOrder_gtₓ'. -/
 instance (priority := 10) LinearOrder.isWellOrder_gt [LinearOrder α] : IsWellOrder α (· > ·)
     where wf := Preorder.wellFounded_gt
 #align finite.linear_order.is_well_order_gt Finite.LinearOrder.isWellOrder_gt
--/
 
 end Finite
 
@@ -1318,7 +1334,7 @@ end
 
 /- warning: finset.exists_minimal -> Finset.exists_minimal is a dubious translation:
 lean 3 declaration is
-  forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Finset.{u1} α), (Finset.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (m : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) m s) (fun (H : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) m s) => forall (x : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) x s) -> (Not (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_1) x m)))))
+  forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Finset.{u1} α), (Finset.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (m : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) m s) (fun (H : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) m s) => forall (x : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) x s) -> (Not (LT.lt.{u1} α (Preorder.toHasLt.{u1} α _inst_1) x m)))))
 but is expected to have type
   forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Finset.{u1} α), (Finset.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (m : α) => And (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) m s) (forall (x : α), (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) x s) -> (Not (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_1) x m)))))
 Case conversion may be inaccurate. Consider using '#align finset.exists_minimal Finset.exists_minimalₓ'. -/
@@ -1332,7 +1348,7 @@ theorem Finset.exists_minimal {α : Type _} [Preorder α] (s : Finset α) (h : s
 
 /- warning: finset.exists_maximal -> Finset.exists_maximal is a dubious translation:
 lean 3 declaration is
-  forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Finset.{u1} α), (Finset.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (m : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) m s) (fun (H : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) m s) => forall (x : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) x s) -> (Not (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_1) m x)))))
+  forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Finset.{u1} α), (Finset.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (m : α) => Exists.{0} (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) m s) (fun (H : Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) m s) => forall (x : α), (Membership.Mem.{u1, u1} α (Finset.{u1} α) (Finset.hasMem.{u1} α) x s) -> (Not (LT.lt.{u1} α (Preorder.toHasLt.{u1} α _inst_1) m x)))))
 but is expected to have type
   forall {α : Type.{u1}} [_inst_1 : Preorder.{u1} α] (s : Finset.{u1} α), (Finset.Nonempty.{u1} α s) -> (Exists.{succ u1} α (fun (m : α) => And (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) m s) (forall (x : α), (Membership.mem.{u1, u1} α (Finset.{u1} α) (Finset.instMembershipFinset.{u1} α) x s) -> (Not (LT.lt.{u1} α (Preorder.toLT.{u1} α _inst_1) m x)))))
 Case conversion may be inaccurate. Consider using '#align finset.exists_maximal Finset.exists_maximalₓ'. -/
Diff
@@ -400,7 +400,7 @@ theorem fin_injective : Function.Injective Fin := fun m n h =>
 lean 3 declaration is
   forall {n : Nat} {m : Nat} (h : Eq.{2} Type (Fin n) (Fin m)), Eq.{1} ((Fin n) -> (Fin m)) (cast.{1} (Fin n) (Fin m) h) (coeFn.{1, 1} (OrderIso.{0, 0} (Fin n) (Fin m) (Fin.hasLe n) (Fin.hasLe m)) (fun (_x : RelIso.{0, 0} (Fin n) (Fin m) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin m) (Fin.hasLe m))) => (Fin n) -> (Fin m)) (RelIso.hasCoeToFun.{0, 0} (Fin n) (Fin m) (LE.le.{0} (Fin n) (Fin.hasLe n)) (LE.le.{0} (Fin m) (Fin.hasLe m))) (Fin.cast n m (fin_injective n m h)))
 but is expected to have type
-  forall {n : Nat} {m : Nat} (h : Eq.{2} Type (Fin n) (Fin m)), Eq.{1} ((Fin n) -> (Fin m)) (cast.{1} (Fin n) (Fin m) h) (FunLike.coe.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin m)) (Fin n) (fun (_x : Fin n) => (fun (x._@.Mathlib.Data.FunLike.Embedding._hyg.19 : Fin n) => Fin m) _x) (EmbeddingLike.toFunLike.{1, 1, 1} (Function.Embedding.{1, 1} (Fin n) (Fin m)) (Fin n) (Fin m) (Function.instEmbeddingLikeEmbedding.{1, 1} (Fin n) (Fin m))) (RelEmbedding.toEmbedding.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.toRelEmbedding.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (Fin.cast n m (fin_injective n m h)))))
+  forall {n : Nat} {m : Nat} (h : Eq.{2} Type (Fin n) (Fin m)), Eq.{1} ((Fin n) -> (Fin m)) (cast.{1} (Fin n) (Fin m) h) (FunLike.coe.{1, 1, 1} (RelIso.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298)) (Fin n) (fun (_x : Fin n) => Fin m) (RelHomClass.toFunLike.{0, 0, 0} (RelIso.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298)) (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298) (RelIso.instRelHomClassRelIso.{0, 0} (Fin n) (Fin m) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1281 : Fin n) (x._@.Mathlib.Order.Hom.Basic._hyg.1283 : Fin n) => LE.le.{0} (Fin n) (instLEFin n) x._@.Mathlib.Order.Hom.Basic._hyg.1281 x._@.Mathlib.Order.Hom.Basic._hyg.1283) (fun (x._@.Mathlib.Order.Hom.Basic._hyg.1296 : Fin m) (x._@.Mathlib.Order.Hom.Basic._hyg.1298 : Fin m) => LE.le.{0} (Fin m) (instLEFin m) x._@.Mathlib.Order.Hom.Basic._hyg.1296 x._@.Mathlib.Order.Hom.Basic._hyg.1298))) (Fin.cast n m (fin_injective n m h)))
 Case conversion may be inaccurate. Consider using '#align fin.cast_eq_cast' Fin.cast_eq_cast'ₓ'. -/
 /-- A reversed version of `fin.cast_eq_cast` that is easier to rewrite with. -/
 theorem Fin.cast_eq_cast' {n m : ℕ} (h : Fin n = Fin m) : cast h = ⇑(Fin.cast <| fin_injective h) :=
Diff
@@ -1085,7 +1085,7 @@ def truncOfCardLe [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
     (h : Fintype.card α ≤ Fintype.card β) : Trunc (α ↪ β) :=
   (Fintype.truncEquivFin α).bind fun ea =>
     (Fintype.truncEquivFin β).map fun eb =>
-      ea.toEmbedding.trans ((Fin.castLe h).toEmbedding.trans eb.symm.toEmbedding)
+      ea.toEmbedding.trans ((Fin.castLE h).toEmbedding.trans eb.symm.toEmbedding)
 #align function.embedding.trunc_of_card_le Function.Embedding.truncOfCardLe
 -/
 
Diff
@@ -342,16 +342,12 @@ theorem Finset.card_lt_iff_ne_univ [Fintype α] (s : Finset α) :
 #align finset.card_lt_iff_ne_univ Finset.card_lt_iff_ne_univ
 -/
 
-/- warning: finset.card_compl_lt_iff_nonempty -> Finset.card_compl_lt_iff_nonempty is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Iff (LT.lt.{0} Nat Nat.hasLt (Finset.card.{u1} α (HasCompl.compl.{u1} (Finset.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} α) (Finset.booleanAlgebra.{u1} α _inst_1 (fun (a : α) (b : α) => _inst_2 a b))) s)) (Fintype.card.{u1} α _inst_1)) (Finset.Nonempty.{u1} α s)
-but is expected to have type
-  forall {α : Type.{u1}} [_inst_1 : Fintype.{u1} α] [_inst_2 : DecidableEq.{succ u1} α] (s : Finset.{u1} α), Iff (LT.lt.{0} Nat instLTNat (Finset.card.{u1} α (HasCompl.compl.{u1} (Finset.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} α) (Finset.instBooleanAlgebraFinset.{u1} α _inst_1 (fun (a : α) (b : α) => _inst_2 a b))) s)) (Fintype.card.{u1} α _inst_1)) (Finset.Nonempty.{u1} α s)
-Case conversion may be inaccurate. Consider using '#align finset.card_compl_lt_iff_nonempty Finset.card_compl_lt_iff_nonemptyₓ'. -/
+#print Finset.card_compl_lt_iff_nonempty /-
 theorem Finset.card_compl_lt_iff_nonempty [Fintype α] [DecidableEq α] (s : Finset α) :
     sᶜ.card < Fintype.card α ↔ s.Nonempty :=
   sᶜ.card_lt_iff_ne_univ.trans s.compl_ne_univ_iff_nonempty
 #align finset.card_compl_lt_iff_nonempty Finset.card_compl_lt_iff_nonempty
+-/
 
 #print Finset.card_univ_diff /-
 theorem Finset.card_univ_diff [DecidableEq α] [Fintype α] (s : Finset α) :
@@ -360,16 +356,12 @@ theorem Finset.card_univ_diff [DecidableEq α] [Fintype α] (s : Finset α) :
 #align finset.card_univ_diff Finset.card_univ_diff
 -/
 
-/- warning: finset.card_compl -> Finset.card_compl is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} α] (s : Finset.{u1} α), Eq.{1} Nat (Finset.card.{u1} α (HasCompl.compl.{u1} (Finset.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} α) (Finset.booleanAlgebra.{u1} α _inst_2 (fun (a : α) (b : α) => _inst_1 a b))) s)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat Nat.hasSub) (Fintype.card.{u1} α _inst_2) (Finset.card.{u1} α s))
-but is expected to have type
-  forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : Fintype.{u1} α] (s : Finset.{u1} α), Eq.{1} Nat (Finset.card.{u1} α (HasCompl.compl.{u1} (Finset.{u1} α) (BooleanAlgebra.toHasCompl.{u1} (Finset.{u1} α) (Finset.instBooleanAlgebraFinset.{u1} α _inst_2 (fun (a : α) (b : α) => _inst_1 a b))) s)) (HSub.hSub.{0, 0, 0} Nat Nat Nat (instHSub.{0} Nat instSubNat) (Fintype.card.{u1} α _inst_2) (Finset.card.{u1} α s))
-Case conversion may be inaccurate. Consider using '#align finset.card_compl Finset.card_complₓ'. -/
+#print Finset.card_compl /-
 theorem Finset.card_compl [DecidableEq α] [Fintype α] (s : Finset α) :
     sᶜ.card = Fintype.card α - s.card :=
   Finset.card_univ_diff s
 #align finset.card_compl Finset.card_compl
+-/
 
 /- warning: fintype.card_compl_set -> Fintype.card_compl_set is a dubious translation:
 lean 3 declaration is
@@ -457,26 +449,18 @@ theorem Fintype.card_pempty : Fintype.card PEmpty = 0 :=
 #align fintype.card_pempty Fintype.card_pempty
 -/
 
-/- warning: fintype.card_unit -> Fintype.card_unit is a dubious translation:
-lean 3 declaration is
-  Eq.{1} Nat (Fintype.card.{0} Unit PUnit.fintype.{0}) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))
-but is expected to have type
-  Eq.{1} Nat (Fintype.card.{0} Unit instFintypePUnit.{0}) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))
-Case conversion may be inaccurate. Consider using '#align fintype.card_unit Fintype.card_unitₓ'. -/
+#print Fintype.card_unit /-
 theorem Fintype.card_unit : Fintype.card Unit = 1 :=
   rfl
 #align fintype.card_unit Fintype.card_unit
+-/
 
-/- warning: fintype.card_punit -> Fintype.card_punit is a dubious translation:
-lean 3 declaration is
-  Eq.{1} Nat (Fintype.card.{u1} PUnit.{succ u1} PUnit.fintype.{u1}) (OfNat.ofNat.{0} Nat 1 (OfNat.mk.{0} Nat 1 (One.one.{0} Nat Nat.hasOne)))
-but is expected to have type
-  Eq.{1} Nat (Fintype.card.{u1} PUnit.{succ u1} instFintypePUnit.{u1}) (OfNat.ofNat.{0} Nat 1 (instOfNatNat 1))
-Case conversion may be inaccurate. Consider using '#align fintype.card_punit Fintype.card_punitₓ'. -/
+#print Fintype.card_punit /-
 @[simp]
 theorem Fintype.card_punit : Fintype.card PUnit = 1 :=
   rfl
 #align fintype.card_punit Fintype.card_punit
+-/
 
 #print Fintype.card_bool /-
 @[simp]
@@ -489,7 +473,7 @@ theorem Fintype.card_bool : Fintype.card Bool = 2 :=
 lean 3 declaration is
   forall (α : Type.{u1}) [_inst_1 : Fintype.{u1} α], Eq.{1} Nat (Fintype.card.{max u1 u2} (ULift.{u2, u1} α) (ULift.fintype.{u1, u2} α _inst_1)) (Fintype.card.{u1} α _inst_1)
 but is expected to have type
-  forall (α : Type.{u2}) [_inst_1 : Fintype.{u2} α], Eq.{1} Nat (Fintype.card.{max u2 u1} (ULift.{u1, u2} α) (instFintypeULift.{u2, u1} α _inst_1)) (Fintype.card.{u2} α _inst_1)
+  forall (α : Type.{u2}) [_inst_1 : Fintype.{u2} α], Eq.{1} Nat (Fintype.card.{max u2 u1} (ULift.{u1, u2} α) (ULift.fintype.{u2, u1} α _inst_1)) (Fintype.card.{u2} α _inst_1)
 Case conversion may be inaccurate. Consider using '#align fintype.card_ulift Fintype.card_uliftₓ'. -/
 @[simp]
 theorem Fintype.card_ulift (α : Type _) [Fintype α] : Fintype.card (ULift α) = Fintype.card α :=

Changes in mathlib4

mathlib3
mathlib4
chore: remove unnecessary cdots (#12417)

These · are scoping when there is a single active goal.

These were found using a modification of the linter at #12339.

Diff
@@ -1251,13 +1251,13 @@ theorem List.exists_pw_disjoint_with_card {α : Type*} [Fintype α]
     exact ranges_nodup hu
   · -- pairwise disjoint
     refine Pairwise.map _ (fun s t ↦ disjoint_map (Equiv.injective _)) ?_
-    · -- List.Pairwise List.disjoint l
-      apply Pairwise.pmap (List.ranges_disjoint c)
-      intro u hu v hv huv
-      apply disjoint_pmap
-      · intro a a' ha ha' h
-        simpa only [klift, Fin.mk_eq_mk] using h
-      exact huv
+    -- List.Pairwise List.disjoint l
+    apply Pairwise.pmap (List.ranges_disjoint c)
+    intro u hu v hv huv
+    apply disjoint_pmap
+    · intro a a' ha ha' h
+      simpa only [klift, Fin.mk_eq_mk] using h
+    exact huv
 
 end Ranges
 
style: replace '.-/' by '. -/' (#11938)

Purely automatic replacement. If this is in any way controversial; I'm happy to just close this PR.

Diff
@@ -773,7 +773,7 @@ theorem Finset.card_eq_of_equiv_fintype {s : Finset α} [Fintype β] (i : s ≃
     s.card = Fintype.card β := card_eq_of_equiv_fin <| i.trans <| Fintype.equivFin β
 
 /-- Noncomputable equivalence between two finsets `s` and `t` as fintypes when there is a proof
-that `s.card = t.card`.-/
+that `s.card = t.card`. -/
 noncomputable def Finset.equivOfCardEq {s : Finset α} {t : Finset β} (h : s.card = t.card) :
     s ≃ t := Fintype.equivOfCardEq ((Fintype.card_coe _).trans (h.trans (Fintype.card_coe _).symm))
 #align finset.equiv_of_card_eq Finset.equivOfCardEq
chore: classify new theorem / theorem porting notes (#11432)

Classifies by adding issue number #10756 to porting notes claiming anything equivalent to:

  • "added theorem"
  • "added theorems"
  • "new theorem"
  • "new theorems"
  • "added lemma"
  • "new lemma"
  • "new lemmas"
Diff
@@ -637,7 +637,7 @@ namespace Finite
 
 variable [Finite α]
 
--- Porting note: new theorem
+-- Porting note (#10756): new theorem
 theorem surjective_of_injective {f : α → α} (hinj : Injective f) : Surjective f := by
   intro x
   have := Classical.propDecidable
chore: remove tactics (#11365)

More tactics that are not used, found using the linter at #11308.

The PR consists of tactic removals, whitespace changes and replacing a porting note by an explanation.

Diff
@@ -582,7 +582,7 @@ theorem card_le_one_iff : card α ≤ 1 ↔ ∀ a b : α, a = b :=
       let ⟨x, hx⟩ := card_eq_one_iff.1 ha.symm
       rw [hx a, hx b], fun _ => ha ▸ le_rfl⟩
   | n + 2, ha =>
-    ⟨fun h => False.elim <| by rw [← ha] at h; cases h with | step h => cases h; done, fun h =>
+    ⟨fun h => False.elim <| by rw [← ha] at h; cases h with | step h => cases h; , fun h =>
       card_unit ▸ card_le_of_injective (fun _ => ()) fun _ _ _ => h _ _⟩
 #align fintype.card_le_one_iff Fintype.card_le_one_iff
 
chore: replace λ by fun (#11301)

Per the style guidelines, λ is disallowed in mathlib. This is close to exhaustive; I left some tactic code alone when it seemed to me that tactic could be upstreamed soon.

Notes

  • In lines I was modifying anyway, I also converted => to .
  • Also contains some mild in-passing indentation fixes in Mathlib/Order/SupClosed.
  • Some doc comments still contained Lean 3 syntax λ x, , which I also replaced.
Diff
@@ -1123,8 +1123,8 @@ private theorem natEmbeddingAux_injective (α : Type*) [Infinite α] :
   by_contra hmn
   have hmn : m < n := lt_of_le_of_ne hmlen hmn
   refine (Classical.choose_spec (exists_not_mem_finset
-    ((Multiset.range n).pmap (λ m (_ : m < n) => natEmbeddingAux α m)
-      (fun _ => Multiset.mem_range.1)).toFinset)) ?_
+    ((Multiset.range n).pmap (fun m (_ : m < n) ↦ natEmbeddingAux α m)
+      (fun _ ↦ Multiset.mem_range.1)).toFinset)) ?_
   refine Multiset.mem_toFinset.2 (Multiset.mem_pmap.2 ⟨m, Multiset.mem_range.2 hmn, ?_⟩)
   rw [h, natEmbeddingAux]
 
chore: scope open Classical (#11199)

We remove all but one open Classicals, 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.

Diff
@@ -980,7 +980,7 @@ noncomputable def fintypeOfNotInfinite {α : Type*} (h : ¬Infinite α) : Fintyp
 
 section
 
-open Classical
+open scoped Classical
 
 /-- Any type is (classically) either a `Fintype`, or `Infinite`.
 
feat: Unions and intersections indexed by Finset.sigma (#10851)

Followup to #8964

From PFR

Diff
@@ -541,6 +541,8 @@ theorem card_eq_zero_iff : card α = 0 ↔ IsEmpty α := by
   card_eq_zero_iff.2 ‹_›
 #align fintype.card_eq_zero Fintype.card_eq_zero
 
+alias card_of_isEmpty := card_eq_zero
+
 theorem card_eq_one_iff_nonempty_unique : card α = 1 ↔ Nonempty (Unique α) :=
   ⟨fun h =>
     let ⟨d, h⟩ := Fintype.card_eq_one_iff.mp h
chore: prepare Lean version bump with explicit simp (#10999)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -1235,7 +1235,8 @@ theorem List.exists_pw_disjoint_with_card {α : Type*} [Fintype α]
   constructor
   · -- length
     rw [← ranges_length c]
-    simp only [map_map, map_pmap, Function.comp_apply, length_map, length_pmap, pmap_eq_map]
+    simp only [l, klift', map_map, map_pmap, Function.comp_apply, length_map, length_pmap,
+      pmap_eq_map]
   constructor
   · -- nodup
     intro s
@@ -1253,7 +1254,7 @@ theorem List.exists_pw_disjoint_with_card {α : Type*} [Fintype α]
       intro u hu v hv huv
       apply disjoint_pmap
       · intro a a' ha ha' h
-        simpa only [Fin.mk_eq_mk] using h
+        simpa only [klift, Fin.mk_eq_mk] using h
       exact huv
 
 end Ranges
chore(CategoryTheory/Limits): Fintype -> Finite (#10915)
Diff
@@ -450,12 +450,15 @@ noncomputable def Fintype.ofFinite (α : Type*) [Finite α] : Fintype α :=
 #align fintype.of_finite Fintype.ofFinite
 
 theorem Finite.of_injective {α β : Sort*} [Finite β] (f : α → β) (H : Injective f) : Finite α := by
-  cases nonempty_fintype (PLift β)
-  rw [← Equiv.injective_comp Equiv.plift f, ← Equiv.comp_injective _ Equiv.plift.symm] at H
-  haveI := Fintype.ofInjective _ H
-  exact Finite.of_equiv _ Equiv.plift
+  rcases Finite.exists_equiv_fin β with ⟨n, ⟨e⟩⟩
+  classical exact .of_equiv (Set.range (e ∘ f)) (Equiv.ofInjective _ (e.injective.comp H)).symm
 #align finite.of_injective Finite.of_injective
 
+/-- This instance also provides `[Finite s]` for `s : Set α`. -/
+instance Subtype.finite {α : Sort*} [Finite α] {p : α → Prop} : Finite { x // p x } :=
+  Finite.of_injective (↑) Subtype.coe_injective
+#align subtype.finite Subtype.finite
+
 theorem Finite.of_surjective {α β : Sort*} [Finite α] (f : α → β) (H : Surjective f) : Finite β :=
   Finite.of_injective _ <| injective_surjInv H
 #align finite.of_surjective Finite.of_surjective
chore: classify simp can do this porting notes (#10619)

Classify by adding issue number (#10618) to porting notes claiming anything semantically equivalent to simp can prove this or simp can simplify this.

Diff
@@ -340,13 +340,13 @@ theorem card_finset_fin_le {n : ℕ} (s : Finset (Fin n)) : s.card ≤ n := by
   simpa only [Fintype.card_fin] using s.card_le_univ
 #align card_finset_fin_le card_finset_fin_le
 
---@[simp] Porting note: simp can prove it
+--@[simp] Porting note (#10618): simp can prove it
 theorem Fintype.card_subtype_eq (y : α) [Fintype { x // x = y }] :
     Fintype.card { x // x = y } = 1 :=
   Fintype.card_unique
 #align fintype.card_subtype_eq Fintype.card_subtype_eq
 
---@[simp] Porting note: simp can prove it
+--@[simp] Porting note (#10618): simp can prove it
 theorem Fintype.card_subtype_eq' (y : α) [Fintype { x // y = x }] :
     Fintype.card { x // y = x } = 1 :=
   Fintype.card_unique
chore(Data/Fin): move Fin.equiv_iff_eq (#10522)

The new proof is longer but I need this lemma before Fintype for a future refactor, see #9794

Diff
@@ -340,10 +340,6 @@ theorem card_finset_fin_le {n : ℕ} (s : Finset (Fin n)) : s.card ≤ n := by
   simpa only [Fintype.card_fin] using s.card_le_univ
 #align card_finset_fin_le card_finset_fin_le
 
-theorem Fin.equiv_iff_eq {m n : ℕ} : Nonempty (Fin m ≃ Fin n) ↔ m = n :=
-  ⟨fun ⟨h⟩ => by simpa using Fintype.card_congr h, fun h => ⟨Equiv.cast <| h ▸ rfl⟩⟩
-#align fin.equiv_iff_eq Fin.equiv_iff_eq
-
 --@[simp] Porting note: simp can prove it
 theorem Fintype.card_subtype_eq (y : α) [Fintype { x // x = y }] :
     Fintype.card { x // x = y } = 1 :=
chore: tidy various files (#10453)
Diff
@@ -225,9 +225,9 @@ theorem card_unique [Unique α] [h : Fintype α] : Fintype.card α = 1 :=
 /-- Note: this lemma is specifically about `Fintype.ofIsEmpty`. For a statement about
 arbitrary `Fintype` instances, use `Fintype.card_eq_zero`. -/
 @[simp]
-theorem card_of_isEmpty [IsEmpty α] : @Fintype.card α Fintype.ofIsEmpty = 0 :=
+theorem card_ofIsEmpty [IsEmpty α] : @Fintype.card α Fintype.ofIsEmpty = 0 :=
   rfl
-#align fintype.card_of_is_empty Fintype.card_of_isEmpty
+#align fintype.card_of_is_empty Fintype.card_ofIsEmpty
 
 end Fintype
 
refactor(Data/FunLike): use unbundled inheritance from FunLike (#8386)

The FunLike hierarchy is very big and gets scanned through each time we need a coercion (via the CoeFun instance). It looks like unbundled inheritance suits Lean 4 better here. The only class that still extends FunLike is EquivLike, since that has a custom coe_injective' field that is easier to implement. All other classes should take FunLike or EquivLike as a parameter.

Zulip thread

Important changes

Previously, morphism classes would be Type-valued and extend FunLike:

/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
  extends FunLike F A B :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))

After this PR, they should be Prop-valued and take FunLike as a parameter:

/-- `MyHomClass F A B` states that `F` is a type of `MyClass.op`-preserving morphisms.
You should extend this class when you extend `MyHom`. -/
class MyHomClass (F : Type*) (A B : outParam <| Type*) [MyClass A] [MyClass B]
  [FunLike F A B] : Prop :=
(map_op : ∀ (f : F) (x y : A), f (MyClass.op x y) = MyClass.op (f x) (f y))

(Note that A B stay marked as outParam even though they are not purely required to be so due to the FunLike parameter already filling them in. This is required to see through type synonyms, which is important in the category theory library. Also, I think keeping them as outParam is slightly faster.)

Similarly, MyEquivClass should take EquivLike as a parameter.

As a result, every mention of [MyHomClass F A B] should become [FunLike F A B] [MyHomClass F A B].

Remaining issues

Slower (failing) search

While overall this gives some great speedups, there are some cases that are noticeably slower. In particular, a failing application of a lemma such as map_mul is more expensive. This is due to suboptimal processing of arguments. For example:

variable [FunLike F M N] [Mul M] [Mul N] (f : F) (x : M) (y : M)

theorem map_mul [MulHomClass F M N] : f (x * y) = f x * f y

example [AddHomClass F A B] : f (x * y) = f x * f y := map_mul f _ _

Before this PR, applying map_mul f gives the goals [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]. Since M and N are out_params, [MulHomClass F ?M ?N] is synthesized first, supplies values for ?M and ?N and then the Mul M and Mul N instances can be found.

After this PR, the goals become [FunLike F ?M ?N] [Mul ?M] [Mul ?N] [MulHomClass F ?M ?N]. Now [FunLike F ?M ?N] is synthesized first, supplies values for ?M and ?N and then the Mul M and Mul N instances can be found, before trying MulHomClass F M N which fails. Since the Mul hierarchy is very big, this can be slow to fail, especially when there is no such Mul instance.

A long-term but harder to achieve solution would be to specify the order in which instance goals get solved. For example, we'd like to change the arguments to map_mul to look like [FunLike F M N] [Mul M] [Mul N] [highPriority <| MulHomClass F M N] because MulHomClass fails or succeeds much faster than the others.

As a consequence, the simpNF linter is much slower since by design it tries and fails to apply many map_ lemmas. The same issue occurs a few times in existing calls to simp [map_mul], where map_mul is tried "too soon" and fails. Thanks to the speedup of leanprover/lean4#2478 the impact is very limited, only in files that already were close to the timeout.

simp not firing sometimes

This affects map_smulₛₗ and related definitions. For simp lemmas Lean apparently uses a slightly different mechanism to find instances, so that rw can find every argument to map_smulₛₗ successfully but simp can't: leanprover/lean4#3701.

Missing instances due to unification failing

Especially in the category theory library, we might sometimes have a type A which is also accessible as a synonym (Bundled A hA).1. Instance synthesis doesn't always work if we have f : A →* B but x * y : (Bundled A hA).1 or vice versa. This seems to be mostly fixed by keeping A B as outParams in MulHomClass F A B. (Presumably because Lean will do a definitional check A =?= (Bundled A hA).1 instead of using the syntax in the discrimination tree.)

Workaround for issues

The timeouts can be worked around for now by specifying which map_mul we mean, either as map_mul f for some explicit f, or as e.g. MonoidHomClass.map_mul.

map_smulₛₗ not firing as simp lemma can be worked around by going back to the pre-FunLike situation and making LinearMap.map_smulₛₗ a simp lemma instead of the generic map_smulₛₗ. Writing simp [map_smulₛₗ _] also works.

Co-authored-by: Matthew Ballard <matt@mrb.email> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Scott Morrison <scott@tqft.net> Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>

Diff
@@ -511,7 +511,7 @@ theorem card_range_le {α β : Type*} (f : α → β) [Fintype α] [Fintype (Set
   Fintype.card_le_of_surjective (fun a => ⟨f a, by simp⟩) fun ⟨_, a, ha⟩ => ⟨a, by simpa using ha⟩
 #align fintype.card_range_le Fintype.card_range_le
 
-theorem card_range {α β F : Type*} [EmbeddingLike F α β] (f : F) [Fintype α]
+theorem card_range {α β F : Type*} [FunLike F α β] [EmbeddingLike F α β] (f : F) [Fintype α]
     [Fintype (Set.range f)] : Fintype.card (Set.range f) = Fintype.card α :=
   Eq.symm <| Fintype.card_congr <| Equiv.ofInjective _ <| EmbeddingLike.injective f
 #align fintype.card_range Fintype.card_range
chore: remove spurious imports of positivity (#9924)

Some of these are already transitively imported, others aren't used at all (but not handled by noshake in #9772).

Mostly I wanted to avoid needing all of algebra imported (but unused!) in FilteredColimitCommutesFiniteLimit; there are now some assert_not_exists to preserve this.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -7,7 +7,6 @@ import Mathlib.Data.Fintype.Basic
 import Mathlib.Data.Finset.Card
 import Mathlib.Data.List.NodupEquivFin
 import Mathlib.Data.Set.Image
-import Mathlib.Tactic.Positivity
 
 #align_import data.fintype.card from "leanprover-community/mathlib"@"bf2428c9486c407ca38b5b3fb10b87dad0bc99fa"
 
chore: reduce imports (#9830)

This uses the improved shake script from #9772 to reduce imports across mathlib. The corresponding noshake.json file has been added to #9772.

Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -6,6 +6,7 @@ Authors: Mario Carneiro
 import Mathlib.Data.Fintype.Basic
 import Mathlib.Data.Finset.Card
 import Mathlib.Data.List.NodupEquivFin
+import Mathlib.Data.Set.Image
 import Mathlib.Tactic.Positivity
 
 #align_import data.fintype.card from "leanprover-community/mathlib"@"bf2428c9486c407ca38b5b3fb10b87dad0bc99fa"
chore(*): use α → β instead of ∀ _ : α, β (#9529)
Diff
@@ -1280,9 +1280,8 @@ to that instance and use that name.
 @[elab_as_elim]
 theorem Fintype.induction_subsingleton_or_nontrivial {P : ∀ (α) [Fintype α], Prop} (α : Type*)
     [Fintype α] (hbase : ∀ (α) [Fintype α] [Subsingleton α], P α)
-    (hstep :
-      ∀ (α) [Fintype α] [Nontrivial α],
-        ∀ _ih : ∀ (β) [Fintype β], ∀ _h : Fintype.card β < Fintype.card α, P β, P α) :
+    (hstep : ∀ (α) [Fintype α] [Nontrivial α],
+      (∀ (β) [Fintype β], Fintype.card β < Fintype.card α → P β) → P α) :
     P α := by
   obtain ⟨n, hn⟩ : ∃ n, Fintype.card α = n := ⟨Fintype.card α, rfl⟩
   induction' n using Nat.strong_induction_on with n ih generalizing α
chore(*): replace $ with <| (#9319)

See Zulip thread for the discussion.

Diff
@@ -581,7 +581,7 @@ theorem card_le_one_iff : card α ≤ 1 ↔ ∀ a b : α, a = b :=
       let ⟨x, hx⟩ := card_eq_one_iff.1 ha.symm
       rw [hx a, hx b], fun _ => ha ▸ le_rfl⟩
   | n + 2, ha =>
-    ⟨fun h => False.elim $ by rw [← ha] at h; cases h with | step h => cases h; done, fun h =>
+    ⟨fun h => False.elim <| by rw [← ha] at h; cases h with | step h => cases h; done, fun h =>
       card_unit ▸ card_le_of_injective (fun _ => ()) fun _ _ _ => h _ _⟩
 #align fintype.card_le_one_iff Fintype.card_le_one_iff
 
@@ -1118,7 +1118,7 @@ private theorem natEmbeddingAux_injective (α : Type*) [Infinite α] :
   rintro m n h
   letI := Classical.decEq α
   wlog hmlen : m ≤ n generalizing m n
-  · exact (this h.symm $ le_of_not_le hmlen).symm
+  · exact (this h.symm <| le_of_not_le hmlen).symm
   by_contra hmn
   have hmn : m < n := lt_of_le_of_ne hmlen hmn
   refine (Classical.choose_spec (exists_not_mem_finset
chore: Improve Finset lemma names (#8894)

Change a few lemma names that have historically bothered me.

  • Finset.card_le_of_subsetFinset.card_le_card
  • Multiset.card_le_of_leMultiset.card_le_card
  • Multiset.card_lt_of_ltMultiset.card_lt_card
  • Set.ncard_le_of_subsetSet.ncard_le_ncard
  • Finset.image_filterFinset.filter_image
  • CompleteLattice.finset_sup_compact_of_compactCompleteLattice.isCompactElement_finset_sup
Diff
@@ -261,7 +261,7 @@ theorem Finset.card_eq_iff_eq_univ [Fintype α] (s : Finset α) :
 #align finset.card_eq_iff_eq_univ Finset.card_eq_iff_eq_univ
 
 theorem Finset.card_le_univ [Fintype α] (s : Finset α) : s.card ≤ Fintype.card α :=
-  card_le_of_subset (subset_univ s)
+  card_le_card (subset_univ s)
 #align finset.card_le_univ Finset.card_le_univ
 
 theorem Finset.card_lt_univ_of_not_mem [Fintype α] {s : Finset α} {x : α} (hx : x ∉ s) :
feat: Basic finset lemmas (#9225)

From LeanAPAP and LeanCamCombi

Diff
@@ -398,6 +398,12 @@ theorem Fintype.card_lex (α : Type*) [Fintype α] : Fintype.card (Lex α) = Fin
   rfl
 #align fintype.card_lex Fintype.card_lex
 
+@[simp] lemma Fintype.card_multiplicative (α : Type*) [Fintype α] :
+    card (Multiplicative α) = card α := Finset.card_map _
+
+@[simp] lemma Fintype.card_additive (α : Type*) [Fintype α] : card (Additive α) = card α :=
+  Finset.card_map _
+
 /-- Given that `α ⊕ β` is a fintype, `α` is also a fintype. This is non-computable as it uses
 that `Sum.inl` is an injection, but there's no clear inverse if `α` is empty. -/
 noncomputable def Fintype.sumLeft {α β} [Fintype (Sum α β)] : Fintype α :=
chore: remove uses of cases' (#9171)

I literally went through and regex'd some uses of cases', replacing them with rcases; this is meant to be a low effort PR as I hope that tools can do this in the future.

rcases is an easier replacement than cases, though with better tools we could in future do a second pass converting simple rcases added here (and existing ones) to cases.

Diff
@@ -1138,7 +1138,7 @@ theorem exists_superset_card_eq [Infinite α] (s : Finset α) (n : ℕ) (hn : s.
     ∃ t : Finset α, s ⊆ t ∧ t.card = n := by
   induction' n with n IH generalizing s
   · exact ⟨s, subset_refl _, Nat.eq_zero_of_le_zero hn⟩
-  · cases' hn.eq_or_lt with hn' hn'
+  · rcases hn.eq_or_lt with hn' | hn'
     · exact ⟨s, subset_refl _, hn'⟩
     obtain ⟨t, hs, ht⟩ := IH _ (Nat.le_of_lt_succ hn')
     obtain ⟨x, hx⟩ := exists_not_mem_finset t
feat: demote the instance Fintype.ofIsEmpty to a def (#8816)

Rationale: this instance creates (empty) data out of nothing, which may conflict with other data. If you have in the context [Fintype i] and case on whether i is empty or not, then this gave two non-defeq instances of [Fintype i] around.

Diff
@@ -222,10 +222,10 @@ theorem card_unique [Unique α] [h : Fintype α] : Fintype.card α = 1 :=
   Subsingleton.elim (ofSubsingleton default) h ▸ card_ofSubsingleton _
 #align fintype.card_unique Fintype.card_unique
 
-/-- Note: this lemma is specifically about `Fintype.of_is_empty`. For a statement about
-arbitrary `Fintype` instances, use `Fintype.card_eq_zero_iff`. -/
+/-- Note: this lemma is specifically about `Fintype.ofIsEmpty`. For a statement about
+arbitrary `Fintype` instances, use `Fintype.card_eq_zero`. -/
 @[simp]
-theorem card_of_isEmpty [IsEmpty α] : Fintype.card α = 0 :=
+theorem card_of_isEmpty [IsEmpty α] : @Fintype.card α Fintype.ofIsEmpty = 0 :=
   rfl
 #align fintype.card_of_is_empty Fintype.card_of_isEmpty
 
@@ -356,12 +356,10 @@ theorem Fintype.card_subtype_eq' (y : α) [Fintype { x // y = x }] :
   Fintype.card_unique
 #align fintype.card_subtype_eq' Fintype.card_subtype_eq'
 
-@[simp]
 theorem Fintype.card_empty : Fintype.card Empty = 0 :=
   rfl
 #align fintype.card_empty Fintype.card_empty
 
-@[simp]
 theorem Fintype.card_pempty : Fintype.card PEmpty = 0 :=
   rfl
 #align fintype.card_pempty Fintype.card_pempty
@@ -534,7 +532,7 @@ theorem card_eq_zero_iff : card α = 0 ↔ IsEmpty α := by
   rw [card, Finset.card_eq_zero, univ_eq_empty_iff]
 #align fintype.card_eq_zero_iff Fintype.card_eq_zero_iff
 
-theorem card_eq_zero [IsEmpty α] : card α = 0 :=
+@[simp] theorem card_eq_zero [IsEmpty α] : card α = 0 :=
   card_eq_zero_iff.2 ‹_›
 #align fintype.card_eq_zero Fintype.card_eq_zero
 
chore: bump Std dependency to leanprover/std4#432 (#9094)

This covers these changes in Std: https://github.com/leanprover/std4/compare/6b4cf96c89e53cfcd73350bbcd90333a051ff4f0...[9dd24a34](https://github.com/leanprover-community/mathlib/commit/9dd24a3493cceefa2bede383f21e4ef548990b68)

  • Int.ofNat_natAbs_eq_of_nonneg has become Int.natAbs_of_nonneg (and one argument has become implicit)
  • List.map_id'' and List.map_id' have exchanged names. (Yay naming things using primes!)
  • Some meta functions have moved to Std and can be deleted here.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -1227,7 +1227,7 @@ theorem List.exists_pw_disjoint_with_card {α : Type*} [Fintype α]
     intro a ha
     conv_rhs => rw [← List.map_id a]
     rw [List.map_pmap]
-    simp only [Fin.valEmbedding_apply, Fin.val_mk, List.pmap_eq_map, List.map_id'', List.map_id]
+    simp only [Fin.valEmbedding_apply, Fin.val_mk, List.pmap_eq_map, List.map_id', List.map_id]
   use l.map (List.map (Fintype.equivFin α).symm)
   constructor
   · -- length
chore: remove workaround natEmbeddingAux_injective_aux in Data.Fintype.Card (#8501)

Data.Fintype.Card was ported in #1668. After that, wlog was added in #2144. This means that we can now avoid needing the private workaround theorem natEmbeddingAux_injective_aux.

Co-authored-by: Yaël Dillies <yael.dillies@gmail.com>

Diff
@@ -1109,28 +1109,19 @@ private noncomputable def natEmbeddingAux (α : Type*) [Infinite α] : ℕ → 
         ((Multiset.range n).pmap (fun m (hm : m < n) => natEmbeddingAux _ m) fun _ =>
             Multiset.mem_range.1).toFinset)
 
--- Porting note: new theorem, to work around missing `wlog`
-private theorem natEmbeddingAux_injective_aux (α : Type*) [Infinite α] (m n : ℕ)
-  (h : Infinite.natEmbeddingAux α m = Infinite.natEmbeddingAux α n) (hmn : m < n) : m = n := by
-  letI := Classical.decEq α
-  exfalso
-  refine'
-    (Classical.choose_spec
-        (exists_not_mem_finset
-          ((Multiset.range n).pmap (fun m (_hm : m < n) => natEmbeddingAux α m) fun _ =>
-              Multiset.mem_range.1).toFinset))
-      _
-  refine' Multiset.mem_toFinset.2 (Multiset.mem_pmap.2 ⟨m, Multiset.mem_range.2 hmn, _⟩)
-  rw [h, natEmbeddingAux]
-
 private theorem natEmbeddingAux_injective (α : Type*) [Infinite α] :
     Function.Injective (natEmbeddingAux α) := by
   rintro m n h
   letI := Classical.decEq α
-  rcases lt_trichotomy m n with hmn | rfl | hnm
-  · apply natEmbeddingAux_injective_aux α m n h hmn
-  · rfl
-  · apply (natEmbeddingAux_injective_aux α n m h.symm hnm).symm
+  wlog hmlen : m ≤ n generalizing m n
+  · exact (this h.symm $ le_of_not_le hmlen).symm
+  by_contra hmn
+  have hmn : m < n := lt_of_le_of_ne hmlen hmn
+  refine (Classical.choose_spec (exists_not_mem_finset
+    ((Multiset.range n).pmap (λ m (_ : m < n) => natEmbeddingAux α m)
+      (fun _ => Multiset.mem_range.1)).toFinset)) ?_
+  refine Multiset.mem_toFinset.2 (Multiset.mem_pmap.2 ⟨m, Multiset.mem_range.2 hmn, ?_⟩)
+  rw [h, natEmbeddingAux]
 
 /-- Embedding of `ℕ` into an infinite type. -/
 noncomputable def natEmbedding (α : Type*) [Infinite α] : ℕ ↪ α :=
chore: rename by_contra' to by_contra! (#8797)

To fit with the "please try harder" convention of ! tactics.

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -1199,7 +1199,7 @@ See also: `Finite.exists_ne_map_eq_of_infinite`
 theorem Finite.exists_infinite_fiber [Infinite α] [Finite β] (f : α → β) :
     ∃ y : β, Infinite (f ⁻¹' {y}) := by
   classical
-    by_contra' hf
+    by_contra! hf
     cases nonempty_fintype β
     haveI := fun y => fintypeOfNotInfinite <| hf y
     let key : Fintype α :=
chore: space after (#8178)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -1313,7 +1313,7 @@ private theorem card_univ_pos (α : Type*) [Fintype α] [Nonempty α] :
 -- unsafe def positivity_finset_card : expr → tactic strictness
 --   | q(Finset.card $(s)) => do
 --     let p
---       ←-- TODO: Partial decision procedure for `Finset.nonempty`
+--       ← -- TODO: Partial decision procedure for `Finset.nonempty`
 --             to_expr
 --             ``(Finset.Nonempty $(s)) >>=
 --           find_assumption
feat(Data/Finset/Card): add converse to some existing theorems (#8515)
  • Add Multiset.toFinset_card_eq_card_iff_nodup which is converse to Multiset.toFinset_card_of_nodup (credits: @Ruben-VandeVelde)
  • Add 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.
Diff
@@ -761,12 +761,21 @@ noncomputable def Finset.equivFinOfCardEq {s : Finset α} {n : ℕ} (h : s.card
   Fintype.equivFinOfCardEq ((Fintype.card_coe _).trans h)
 #align finset.equiv_fin_of_card_eq Finset.equivFinOfCardEq
 
+theorem Finset.card_eq_of_equiv_fin {s : Finset α} {n : ℕ} (i : s ≃ Fin n) : s.card = n :=
+  Fin.equiv_iff_eq.1 ⟨s.equivFin.symm.trans i⟩
+
+theorem Finset.card_eq_of_equiv_fintype {s : Finset α} [Fintype β] (i : s ≃ β) :
+    s.card = Fintype.card β := card_eq_of_equiv_fin <| i.trans <| Fintype.equivFin β
+
 /-- Noncomputable equivalence between two finsets `s` and `t` as fintypes when there is a proof
 that `s.card = t.card`.-/
-noncomputable def Finset.equivOfCardEq {s t : Finset α} (h : s.card = t.card) : s ≃ t :=
-  Fintype.equivOfCardEq ((Fintype.card_coe _).trans (h.trans (Fintype.card_coe _).symm))
+noncomputable def Finset.equivOfCardEq {s : Finset α} {t : Finset β} (h : s.card = t.card) :
+    s ≃ t := Fintype.equivOfCardEq ((Fintype.card_coe _).trans (h.trans (Fintype.card_coe _).symm))
 #align finset.equiv_of_card_eq Finset.equivOfCardEq
 
+theorem Finset.card_eq_of_equiv {s : Finset α} {t : Finset β} (i : s ≃ t) : s.card = t.card :=
+  (card_eq_of_equiv_fintype i).trans (Fintype.card_coe _)
+
 @[simp]
 theorem Fintype.card_prop : Fintype.card Prop = 2 :=
   rfl
fix: fixes of 3 PRs (#8248)

Fixes mistake introduced in #7976 (ping to @alreadydone that you should use @[to_additive (attr := simp)] and not @[to_additive, simp]) and some namespacing mistakes from my own PRs #7337 and #7755

Diff
@@ -290,12 +290,12 @@ theorem Finset.card_compl [DecidableEq α] [Fintype α] (s : Finset α) :
 #align finset.card_compl Finset.card_compl
 
 @[simp]
-theorem card_add_card_compl [DecidableEq α] [Fintype α] (s : Finset α) :
+theorem Finset.card_add_card_compl [DecidableEq α] [Fintype α] (s : Finset α) :
     s.card + sᶜ.card = Fintype.card α := by
   rw [Finset.card_compl, ← Nat.add_sub_assoc (card_le_univ s), Nat.add_sub_cancel_left]
 
 @[simp]
-theorem card_compl_add_card [DecidableEq α] [Fintype α] (s : Finset α) :
+theorem Finset.card_compl_add_card [DecidableEq α] [Fintype α] (s : Finset α) :
     sᶜ.card + s.card = Fintype.card α := by
   rw [add_comm, card_add_card_compl]
 
feat (GroupTheory.Perm.Cycle.PossibleTypes) : cycleTypes of perm (#7433)

Characterize the possible types of permutations: given m : Multiset ℕ, there are permutations in Equiv.Perm α with cycleType m if and only if m.sumis at most Fintype.card α and the members of m are at least 2.

This result will be used in later PR which computes the cardinality of conjugacy classes in Equiv.Perm α and alternatingGroup α

Co-authored-by: Antoine Chambert-Loir <antoine.chambert-loir@math.univ-paris-diderot.fr>

Diff
@@ -1203,6 +1203,58 @@ theorem not_surjective_finite_infinite {α β} [Finite α] [Infinite β] (f : α
   fun hf => (Infinite.of_surjective f hf).not_finite ‹_›
 #align not_surjective_finite_infinite not_surjective_finite_infinite
 
+section Ranges
+
+/-- For any `c : List ℕ` whose sum is at most `Fintype.card α`,
+  we can find `o : List (List α)` whose members have no duplicate,
+  whose lengths given by `c`, and which are pairwise disjoint -/
+theorem List.exists_pw_disjoint_with_card {α : Type*} [Fintype α]
+    {c : List ℕ} (hc : c.sum ≤ Fintype.card α) :
+    ∃ o : List (List α),
+      o.map length = c ∧ (∀ s ∈ o, s.Nodup) ∧ Pairwise List.Disjoint o := by
+  let klift (n : ℕ) (hn : n < Fintype.card α) : Fin (Fintype.card α) :=
+    (⟨n, hn⟩ : Fin (Fintype.card α))
+  let klift' (l : List ℕ) (hl : ∀ a ∈ l, a < Fintype.card α) :
+    List (Fin (Fintype.card α)) := List.pmap klift l hl
+  have hc'_lt : ∀ l ∈ c.ranges, ∀ n ∈ l, n < Fintype.card α := by
+    intro l hl n hn
+    apply lt_of_lt_of_le _ hc
+    rw [← mem_mem_ranges_iff_lt_sum]
+    exact ⟨l, hl, hn⟩
+  let l := (ranges c).pmap klift' hc'_lt
+  have hl : ∀ (a : List ℕ) (ha : a ∈ c.ranges),
+    (klift' a (hc'_lt a ha)).map Fin.valEmbedding = a := by
+    intro a ha
+    conv_rhs => rw [← List.map_id a]
+    rw [List.map_pmap]
+    simp only [Fin.valEmbedding_apply, Fin.val_mk, List.pmap_eq_map, List.map_id'', List.map_id]
+  use l.map (List.map (Fintype.equivFin α).symm)
+  constructor
+  · -- length
+    rw [← ranges_length c]
+    simp only [map_map, map_pmap, Function.comp_apply, length_map, length_pmap, pmap_eq_map]
+  constructor
+  · -- nodup
+    intro s
+    rw [mem_map]
+    rintro ⟨t, ht, rfl⟩
+    apply Nodup.map (Equiv.injective _)
+    obtain ⟨u, hu, rfl⟩ := mem_pmap.mp ht
+    apply Nodup.of_map
+    rw [hl u hu]
+    exact ranges_nodup hu
+  · -- pairwise disjoint
+    refine Pairwise.map _ (fun s t ↦ disjoint_map (Equiv.injective _)) ?_
+    · -- List.Pairwise List.disjoint l
+      apply Pairwise.pmap (List.ranges_disjoint c)
+      intro u hu v hv huv
+      apply disjoint_pmap
+      · intro a a' ha ha' h
+        simpa only [Fin.mk_eq_mk] using h
+      exact huv
+
+end Ranges
+
 section Trunc
 
 /-- A `Fintype` with positive cardinality constructively contains an element.
chore: fix some cases in names (#7469)

And fix some names in comments where this revealed issues

Diff
@@ -1247,12 +1247,12 @@ private theorem card_univ_pos (α : Type*) [Fintype α] [Nonempty α] :
   Finset.univ_nonempty.card_pos
 
 --Porting note(https://github.com/leanprover-community/mathlib4/issues/6038): restore
--- /-- Extension for the `positivity` tactic: `finset.card s` is positive if `s` is nonempty. -/
+-- /-- Extension for the `positivity` tactic: `Finset.card s` is positive if `s` is nonempty. -/
 -- @[positivity]
 -- unsafe def positivity_finset_card : expr → tactic strictness
 --   | q(Finset.card $(s)) => do
 --     let p
---       ←-- TODO: Partial decision procedure for `finset.nonempty`
+--       ←-- TODO: Partial decision procedure for `Finset.nonempty`
 --             to_expr
 --             ``(Finset.Nonempty $(s)) >>=
 --           find_assumption
@@ -1261,7 +1261,7 @@ private theorem card_univ_pos (α : Type*) [Fintype α] [Nonempty α] :
 --   | e =>
 --     pp e >>=
 --       fail ∘
---       format.bracket "The expression `" "` isn't of the form `finset.card s` or `fintype.card α`"
+--       format.bracket "The expression `" "` isn't of the form `Finset.card s` or `Fintype.card α`"
 -- #align tactic.positivity_finset_card tactic.positivity_finset_card
 
 end Tactic
feat: lemmas about finset (#7337)

From the marginal project

Diff
@@ -289,6 +289,16 @@ theorem Finset.card_compl [DecidableEq α] [Fintype α] (s : Finset α) :
   Finset.card_univ_diff s
 #align finset.card_compl Finset.card_compl
 
+@[simp]
+theorem card_add_card_compl [DecidableEq α] [Fintype α] (s : Finset α) :
+    s.card + sᶜ.card = Fintype.card α := by
+  rw [Finset.card_compl, ← Nat.add_sub_assoc (card_le_univ s), Nat.add_sub_cancel_left]
+
+@[simp]
+theorem card_compl_add_card [DecidableEq α] [Fintype α] (s : Finset α) :
+    sᶜ.card + s.card = Fintype.card α := by
+  rw [add_comm, card_add_card_compl]
+
 theorem Fintype.card_compl_set [Fintype α] (s : Set α) [Fintype s] [Fintype (↥sᶜ : Sort _)] :
     Fintype.card (↥sᶜ : Sort _) = Fintype.card α - Fintype.card s := by
   classical rw [← Set.toFinset_card, ← Set.toFinset_card, ← Finset.card_compl, Set.toFinset_compl]
chore: replace Fin.castIso and Fin.revPerm with Fin.cast and Fin.rev for the bump of Std (#5847)

Some theorems in Data.Fin.Basic are copied to Std at the recent commit in Std. These are written using Fin.cast and Fin.rev, so declarations using Fin.castIso and Fin.revPerm in Mathlib should be rewritten.

Co-authored-by: Pol'tta / Miyahara Kō <52843868+Komyyy@users.noreply.github.com> Co-authored-by: Johan Commelin <johan@commelin.net>

Diff
@@ -321,7 +321,7 @@ theorem fin_injective : Function.Injective Fin := fun m n h =>
 
 /-- A reversed version of `Fin.cast_eq_cast` that is easier to rewrite with. -/
 theorem Fin.cast_eq_cast' {n m : ℕ} (h : Fin n = Fin m) :
-    _root_.cast h = ⇑(Fin.castIso <| fin_injective h) := by
+    _root_.cast h = Fin.cast (fin_injective h) := by
   cases fin_injective h
   rfl
 #align fin.cast_eq_cast' Fin.cast_eq_cast'
feat: exists_unique_iff_card_one (#7067)

Adds a theorem

Diff
@@ -593,6 +593,13 @@ theorem card_eq_one_of_forall_eq {i : α} (h : ∀ j, j = i) : card α = 1 :=
   Fintype.card_eq_one_iff.2 ⟨i, h⟩
 #align fintype.card_eq_one_of_forall_eq Fintype.card_eq_one_of_forall_eq
 
+theorem exists_unique_iff_card_one {α} [Fintype α] (p : α → Prop) [DecidablePred p] :
+    (∃! a : α, p a) ↔ (Finset.univ.filter p).card = 1 := by
+  rw [Finset.card_eq_one]
+  refine' exists_congr fun x => _
+  simp only [forall_true_left, Subset.antisymm_iff, subset_singleton_iff', singleton_subset_iff,
+      true_and, and_comm, mem_univ, mem_filter]
+
 theorem one_lt_card [h : Nontrivial α] : 1 < Fintype.card α :=
   Fintype.one_lt_card_iff_nontrivial.mpr h
 #align fintype.one_lt_card Fintype.one_lt_card
feat: add 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.

Diff
@@ -576,10 +576,7 @@ theorem card_le_one_iff_subsingleton : card α ≤ 1 ↔ Subsingleton α :=
 #align fintype.card_le_one_iff_subsingleton Fintype.card_le_one_iff_subsingleton
 
 theorem one_lt_card_iff_nontrivial : 1 < card α ↔ Nontrivial α := by
-  classical
-    rw [← not_iff_not]
-    push_neg
-    rw [not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton]
+  rw [← not_iff_not, not_lt, not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton]
 #align fintype.one_lt_card_iff_nontrivial Fintype.one_lt_card_iff_nontrivial
 
 theorem exists_ne_of_one_lt_card (h : 1 < card α) (a : α) : ∃ b : α, b ≠ a :=
chore: fix port of surjective_quotient_mk (#7096)

The mathlib3 lemma is about quotient.mk, which takes an instance argument and is translated into mathlib4 as Quotient.mk'.

Diff
@@ -880,12 +880,12 @@ theorem Fintype.card_compl_eq_card_compl [Finite α] (p q : α → Prop) [Fintyp
 
 theorem Fintype.card_quotient_le [Fintype α] (s : Setoid α)
     [DecidableRel ((· ≈ ·) : α → α → Prop)] : Fintype.card (Quotient s) ≤ Fintype.card α :=
-  Fintype.card_le_of_surjective _ (surjective_quotient_mk _)
+  Fintype.card_le_of_surjective _ (surjective_quotient_mk' _)
 #align fintype.card_quotient_le Fintype.card_quotient_le
 
 theorem Fintype.card_quotient_lt [Fintype α] {s : Setoid α} [DecidableRel ((· ≈ ·) : α → α → Prop)]
     {x y : α} (h1 : x ≠ y) (h2 : x ≈ y) : Fintype.card (Quotient s) < Fintype.card α :=
-  Fintype.card_lt_of_surjective_not_injective _ (surjective_quotient_mk _) fun w =>
+  Fintype.card_lt_of_surjective_not_injective _ (surjective_quotient_mk' _) fun w =>
     h1 (w <| Quotient.eq.mpr h2)
 #align fintype.card_quotient_lt Fintype.card_quotient_lt
 
feat: nilpotent matrices have nilpotent trace (#6588)

Also some related results

Co-authored-by: damiano <adomani@gmail.com>

Diff
@@ -549,6 +549,7 @@ theorem card_pos [h : Nonempty α] : 0 < card α :=
   card_pos_iff.mpr h
 #align fintype.card_pos Fintype.card_pos
 
+@[simp]
 theorem card_ne_zero [Nonempty α] : card α ≠ 0 :=
   _root_.ne_of_gt card_pos
 #align fintype.card_ne_zero Fintype.card_ne_zero
feat: Elements less than some value of a sorted tuple are at the beginning of the tuple. (#6728)

For a sorted (monotone) tuple containing n elements with exactly r elements less than or equal some value, all these elements are at the first r locations of the tuple.

Proofs by @Ruben-VandeVelde , @ericrbg @eric-wieser see Zulip Thread

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -299,6 +299,15 @@ theorem Fintype.card_fin (n : ℕ) : Fintype.card (Fin n) = n :=
   List.length_finRange n
 #align fintype.card_fin Fintype.card_fin
 
+theorem Fintype.card_fin_lt_of_le {m n : ℕ} (h : m ≤ n) :
+    Fintype.card {i : Fin n // i < m} = m := by
+  conv_rhs => rw [← Fintype.card_fin m]
+  apply Fintype.card_congr
+  exact { toFun := fun ⟨⟨i, _⟩, hi⟩ ↦ ⟨i, hi⟩
+          invFun := fun ⟨i, hi⟩ ↦ ⟨⟨i, lt_of_lt_of_le hi h⟩, hi⟩
+          left_inv := fun i ↦ rfl
+          right_inv := fun i ↦ rfl }
+
 @[simp]
 theorem Finset.card_fin (n : ℕ) : Finset.card (Finset.univ : Finset (Fin n)) = n := by
   rw [Finset.card_univ, Fintype.card_fin]
feat: patch for new alias command (#6172)
Diff
@@ -643,14 +643,15 @@ theorem injective_iff_surjective_of_equiv {f : α → β} (e : α ≃ β) : Inje
     simpa [Function.comp] using e.injective.comp (this.2 (e.symm.surjective.comp hsurj))⟩
 #align finite.injective_iff_surjective_of_equiv Finite.injective_iff_surjective_of_equiv
 
-alias injective_iff_bijective ↔ _root_.Function.Injective.bijective_of_finite _
+alias ⟨_root_.Function.Injective.bijective_of_finite, _⟩ := injective_iff_bijective
 #align function.injective.bijective_of_finite Function.Injective.bijective_of_finite
 
-alias surjective_iff_bijective ↔ _root_.Function.Surjective.bijective_of_finite _
+alias ⟨_root_.Function.Surjective.bijective_of_finite, _⟩ := surjective_iff_bijective
 #align function.surjective.bijective_of_finite Function.Surjective.bijective_of_finite
 
-alias injective_iff_surjective_of_equiv ↔
-  _root_.Function.Injective.surjective_of_fintype _root_.Function.Surjective.injective_of_fintype
+alias ⟨_root_.Function.Injective.surjective_of_fintype,
+    _root_.Function.Surjective.injective_of_fintype⟩ :=
+  injective_iff_surjective_of_equiv
 #align function.injective.surjective_of_fintype Function.Injective.surjective_of_fintype
 #align function.surjective.injective_of_fintype Function.Surjective.injective_of_fintype
 
refactor(*): Protect Function.Commute (#6456)

This PR protects Function.Commute, so that it no longer clashes with Commute in the root namespace, as suggested by @j-loreaux in #6290.

Diff
@@ -1062,7 +1062,7 @@ instance Prod.infinite_of_left [Infinite α] [Nonempty β] : Infinite (α × β)
 #align prod.infinite_of_left Prod.infinite_of_left
 
 instance instInfiniteProdSubtypeCommute [Mul α] [Infinite α] :
-    Infinite { p : α × α // _root_.Commute p.1 p.2 } :=
+    Infinite { p : α × α // Commute p.1 p.2 } :=
   Infinite.of_injective (fun a => ⟨⟨a, a⟩, rfl⟩) (by intro; simp)
 
 namespace Infinite
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -51,7 +51,7 @@ open Nat
 
 universe u v
 
-variable {α β γ : Type _}
+variable {α β γ : Type*}
 
 open Finset Function
 
@@ -238,7 +238,7 @@ variable {s t : Set α}
 -- We use an arbitrary `[Fintype s]` instance here,
 -- not necessarily coming from a `[Fintype α]`.
 @[simp]
-theorem toFinset_card {α : Type _} (s : Set α) [Fintype s] : s.toFinset.card = Fintype.card s :=
+theorem toFinset_card {α : Type*} (s : Set α) [Fintype s] : s.toFinset.card = Fintype.card s :=
   Multiset.card_map Subtype.val Finset.univ.val
 #align set.to_finset_card Set.toFinset_card
 
@@ -362,22 +362,22 @@ theorem Fintype.card_bool : Fintype.card Bool = 2 :=
 #align fintype.card_bool Fintype.card_bool
 
 @[simp]
-theorem Fintype.card_ulift (α : Type _) [Fintype α] : Fintype.card (ULift α) = Fintype.card α :=
+theorem Fintype.card_ulift (α : Type*) [Fintype α] : Fintype.card (ULift α) = Fintype.card α :=
   Fintype.ofEquiv_card _
 #align fintype.card_ulift Fintype.card_ulift
 
 @[simp]
-theorem Fintype.card_plift (α : Type _) [Fintype α] : Fintype.card (PLift α) = Fintype.card α :=
+theorem Fintype.card_plift (α : Type*) [Fintype α] : Fintype.card (PLift α) = Fintype.card α :=
   Fintype.ofEquiv_card _
 #align fintype.card_plift Fintype.card_plift
 
 @[simp]
-theorem Fintype.card_orderDual (α : Type _) [Fintype α] : Fintype.card αᵒᵈ = Fintype.card α :=
+theorem Fintype.card_orderDual (α : Type*) [Fintype α] : Fintype.card αᵒᵈ = Fintype.card α :=
   rfl
 #align fintype.card_order_dual Fintype.card_orderDual
 
 @[simp]
-theorem Fintype.card_lex (α : Type _) [Fintype α] : Fintype.card (Lex α) = Fintype.card α :=
+theorem Fintype.card_lex (α : Type*) [Fintype α] : Fintype.card (Lex α) = Fintype.card α :=
   rfl
 #align fintype.card_lex Fintype.card_lex
 
@@ -396,23 +396,23 @@ noncomputable def Fintype.sumRight {α β} [Fintype (Sum α β)] : Fintype β :=
 /-!
 ### Relation to `Finite`
 
-In this section we prove that `α : Type _` is `Finite` if and only if `Fintype α` is nonempty.
+In this section we prove that `α : Type*` is `Finite` if and only if `Fintype α` is nonempty.
 -/
 
 
 -- @[nolint fintype_finite] -- Porting note: do we need this
-protected theorem Fintype.finite {α : Type _} (_inst : Fintype α) : Finite α :=
+protected theorem Fintype.finite {α : Type*} (_inst : Fintype α) : Finite α :=
   ⟨Fintype.equivFin α⟩
 #align fintype.finite Fintype.finite
 
 /-- For efficiency reasons, we want `Finite` instances to have higher
 priority than ones coming from `Fintype` instances. -/
 -- @[nolint fintype_finite] -- Porting note: do we need this
-instance (priority := 900) Finite.of_fintype (α : Type _) [Fintype α] : Finite α :=
+instance (priority := 900) Finite.of_fintype (α : Type*) [Fintype α] : Finite α :=
   Fintype.finite ‹_›
 #align finite.of_fintype Finite.of_fintype
 
-theorem finite_iff_nonempty_fintype (α : Type _) : Finite α ↔ Nonempty (Fintype α) :=
+theorem finite_iff_nonempty_fintype (α : Type*) : Finite α ↔ Nonempty (Fintype α) :=
   ⟨fun h =>
     let ⟨_k, ⟨e⟩⟩ := @Finite.exists_equiv_fin α h
     ⟨Fintype.ofEquiv _ e.symm⟩,
@@ -420,24 +420,24 @@ theorem finite_iff_nonempty_fintype (α : Type _) : Finite α ↔ Nonempty (Fint
 #align finite_iff_nonempty_fintype finite_iff_nonempty_fintype
 
 /-- See also `nonempty_encodable`, `nonempty_denumerable`. -/
-theorem nonempty_fintype (α : Type _) [Finite α] : Nonempty (Fintype α) :=
+theorem nonempty_fintype (α : Type*) [Finite α] : Nonempty (Fintype α) :=
   (finite_iff_nonempty_fintype α).mp ‹_›
 #align nonempty_fintype nonempty_fintype
 
 /-- Noncomputably get a `Fintype` instance from a `Finite` instance. This is not an
 instance because we want `Fintype` instances to be useful for computations. -/
-noncomputable def Fintype.ofFinite (α : Type _) [Finite α] : Fintype α :=
+noncomputable def Fintype.ofFinite (α : Type*) [Finite α] : Fintype α :=
   (nonempty_fintype α).some
 #align fintype.of_finite Fintype.ofFinite
 
-theorem Finite.of_injective {α β : Sort _} [Finite β] (f : α → β) (H : Injective f) : Finite α := by
+theorem Finite.of_injective {α β : Sort*} [Finite β] (f : α → β) (H : Injective f) : Finite α := by
   cases nonempty_fintype (PLift β)
   rw [← Equiv.injective_comp Equiv.plift f, ← Equiv.comp_injective _ Equiv.plift.symm] at H
   haveI := Fintype.ofInjective _ H
   exact Finite.of_equiv _ Equiv.plift
 #align finite.of_injective Finite.of_injective
 
-theorem Finite.of_surjective {α β : Sort _} [Finite α] (f : α → β) (H : Surjective f) : Finite β :=
+theorem Finite.of_surjective {α β : Sort*} [Finite α] (f : α → β) (H : Surjective f) : Finite β :=
   Finite.of_injective _ <| injective_surjInv H
 #align finite.of_surjective Finite.of_surjective
 
@@ -448,7 +448,7 @@ theorem Finite.exists_univ_list (α) [Finite α] : ∃ l : List α, l.Nodup ∧
   exact ⟨_, by rwa [← e] at this⟩
 #align finite.exists_univ_list Finite.exists_univ_list
 
-theorem List.Nodup.length_le_card {α : Type _} [Fintype α] {l : List α} (h : l.Nodup) :
+theorem List.Nodup.length_le_card {α : Type*} [Fintype α] {l : List α} (h : l.Nodup) :
     l.length ≤ Fintype.card α := by
   classical exact List.toFinset_card_of_nodup h ▸ l.toFinset.card_le_univ
 #align list.nodup.length_le_card List.Nodup.length_le_card
@@ -483,12 +483,12 @@ theorem card_le_of_surjective (f : α → β) (h : Function.Surjective f) : card
   card_le_of_injective _ (Function.injective_surjInv h)
 #align fintype.card_le_of_surjective Fintype.card_le_of_surjective
 
-theorem card_range_le {α β : Type _} (f : α → β) [Fintype α] [Fintype (Set.range f)] :
+theorem card_range_le {α β : Type*} (f : α → β) [Fintype α] [Fintype (Set.range f)] :
     Fintype.card (Set.range f) ≤ Fintype.card α :=
   Fintype.card_le_of_surjective (fun a => ⟨f a, by simp⟩) fun ⟨_, a, ha⟩ => ⟨a, by simpa using ha⟩
 #align fintype.card_range_le Fintype.card_range_le
 
-theorem card_range {α β F : Type _} [EmbeddingLike F α β] (f : F) [Fintype α]
+theorem card_range {α β F : Type*} [EmbeddingLike F α β] (f : F) [Fintype α]
     [Fintype (Set.range f)] : Fintype.card (Set.range f) = Fintype.card α :=
   Eq.symm <| Fintype.card_congr <| Equiv.ofInjective _ <| EmbeddingLike.injective f
 #align fintype.card_range Fintype.card_range
@@ -810,7 +810,7 @@ theorem exists_of_card_le_finset [Fintype α] {s : Finset β} (h : Fintype.card
 end Function.Embedding
 
 @[simp]
-theorem Finset.univ_map_embedding {α : Type _} [Fintype α] (e : α ↪ α) : univ.map e = univ := by
+theorem Finset.univ_map_embedding {α : Type*} [Fintype α] (e : α ↪ α) : univ.map e = univ := by
   rw [← e.equiv_of_fintype_self_embedding_to_embedding, univ_map_equiv_to_embedding]
 #align finset.univ_map_embedding Finset.univ_map_embedding
 
@@ -930,12 +930,12 @@ protected theorem Fintype.false [Infinite α] (_h : Fintype α) : False :=
 #align fintype.false Fintype.false
 
 @[simp]
-theorem isEmpty_fintype {α : Type _} : IsEmpty (Fintype α) ↔ Infinite α :=
+theorem isEmpty_fintype {α : Type*} : IsEmpty (Fintype α) ↔ Infinite α :=
   ⟨fun ⟨h⟩ => ⟨fun h' => (@nonempty_fintype α h').elim h⟩, fun ⟨h⟩ => ⟨fun h' => h h'.finite⟩⟩
 #align is_empty_fintype isEmpty_fintype
 
 /-- A non-infinite type is a fintype. -/
-noncomputable def fintypeOfNotInfinite {α : Type _} (h : ¬Infinite α) : Fintype α :=
+noncomputable def fintypeOfNotInfinite {α : Type*} (h : ¬Infinite α) : Fintype α :=
   @Fintype.ofFinite _ (not_infinite_iff_finite.mp h)
 #align fintype_of_not_infinite fintypeOfNotInfinite
 
@@ -947,13 +947,13 @@ open Classical
 
 One can obtain the relevant typeclasses via `cases fintypeOrInfinite α`.
 -/
-noncomputable def fintypeOrInfinite (α : Type _) : PSum (Fintype α) (Infinite α) :=
+noncomputable def fintypeOrInfinite (α : Type*) : PSum (Fintype α) (Infinite α) :=
   if h : Infinite α then PSum.inr h else PSum.inl (fintypeOfNotInfinite h)
 #align fintype_or_infinite fintypeOrInfinite
 
 end
 
-theorem Finset.exists_minimal {α : Type _} [Preorder α] (s : Finset α) (h : s.Nonempty) :
+theorem Finset.exists_minimal {α : Type*} [Preorder α] (s : Finset α) (h : s.Nonempty) :
     ∃ m ∈ s, ∀ x ∈ s, ¬x < m := by
   obtain ⟨c, hcs : c ∈ s⟩ := h
   have : WellFounded (@LT.lt { x // x ∈ s } _) := Finite.wellFounded_of_trans_of_irrefl _
@@ -961,7 +961,7 @@ theorem Finset.exists_minimal {α : Type _} [Preorder α] (s : Finset α) (h : s
   exact ⟨m, hms, fun x hx hxm => H ⟨x, hx⟩ trivial hxm⟩
 #align finset.exists_minimal Finset.exists_minimal
 
-theorem Finset.exists_maximal {α : Type _} [Preorder α] (s : Finset α) (h : s.Nonempty) :
+theorem Finset.exists_maximal {α : Type*} [Preorder α] (s : Finset α) (h : s.Nonempty) :
     ∃ m ∈ s, ∀ x ∈ s, ¬m < x :=
   @Finset.exists_minimal αᵒᵈ _ s h
 #align finset.exists_maximal Finset.exists_maximal
@@ -996,12 +996,12 @@ theorem exists_not_mem_finset [Infinite α] (s : Finset α) : ∃ x, x ∉ s :=
 #align infinite.exists_not_mem_finset Infinite.exists_not_mem_finset
 
 -- see Note [lower instance priority]
-instance (priority := 100) (α : Type _) [H : Infinite α] : Nontrivial α :=
+instance (priority := 100) (α : Type*) [H : Infinite α] : Nontrivial α :=
   ⟨let ⟨x, _hx⟩ := exists_not_mem_finset (∅ : Finset α)
     let ⟨y, hy⟩ := exists_not_mem_finset ({x} : Finset α)
     ⟨y, x, by simpa only [mem_singleton] using hy⟩⟩
 
-protected theorem nonempty (α : Type _) [Infinite α] : Nonempty α := by infer_instance
+protected theorem nonempty (α : Type*) [Infinite α] : Nonempty α := by infer_instance
 #align infinite.nonempty Infinite.nonempty
 
 theorem of_injective {α β} [Infinite β] (f : β → α) (hf : Injective f) : Infinite α :=
@@ -1067,7 +1067,7 @@ instance instInfiniteProdSubtypeCommute [Mul α] [Infinite α] :
 
 namespace Infinite
 
-private noncomputable def natEmbeddingAux (α : Type _) [Infinite α] : ℕ → α
+private noncomputable def natEmbeddingAux (α : Type*) [Infinite α] : ℕ → α
   | n =>
     letI := Classical.decEq α
     Classical.choose
@@ -1076,7 +1076,7 @@ private noncomputable def natEmbeddingAux (α : Type _) [Infinite α] : ℕ →
             Multiset.mem_range.1).toFinset)
 
 -- Porting note: new theorem, to work around missing `wlog`
-private theorem natEmbeddingAux_injective_aux (α : Type _) [Infinite α] (m n : ℕ)
+private theorem natEmbeddingAux_injective_aux (α : Type*) [Infinite α] (m n : ℕ)
   (h : Infinite.natEmbeddingAux α m = Infinite.natEmbeddingAux α n) (hmn : m < n) : m = n := by
   letI := Classical.decEq α
   exfalso
@@ -1089,7 +1089,7 @@ private theorem natEmbeddingAux_injective_aux (α : Type _) [Infinite α] (m n :
   refine' Multiset.mem_toFinset.2 (Multiset.mem_pmap.2 ⟨m, Multiset.mem_range.2 hmn, _⟩)
   rw [h, natEmbeddingAux]
 
-private theorem natEmbeddingAux_injective (α : Type _) [Infinite α] :
+private theorem natEmbeddingAux_injective (α : Type*) [Infinite α] :
     Function.Injective (natEmbeddingAux α) := by
   rintro m n h
   letI := Classical.decEq α
@@ -1099,13 +1099,13 @@ private theorem natEmbeddingAux_injective (α : Type _) [Infinite α] :
   · apply (natEmbeddingAux_injective_aux α n m h.symm hnm).symm
 
 /-- Embedding of `ℕ` into an infinite type. -/
-noncomputable def natEmbedding (α : Type _) [Infinite α] : ℕ ↪ α :=
+noncomputable def natEmbedding (α : Type*) [Infinite α] : ℕ ↪ α :=
   ⟨_, natEmbeddingAux_injective α⟩
 #align infinite.nat_embedding Infinite.natEmbedding
 
 /-- See `Infinite.exists_superset_card_eq` for a version that, for an `s : Finset α`,
 provides a superset `t : Finset α`, `s ⊆ t` such that `t.card` is fixed. -/
-theorem exists_subset_card_eq (α : Type _) [Infinite α] (n : ℕ) : ∃ s : Finset α, s.card = n :=
+theorem exists_subset_card_eq (α : Type*) [Infinite α] (n : ℕ) : ∃ s : Finset α, s.card = n :=
   ⟨(range n).map (natEmbedding α), by rw [card_map, card_range]⟩
 #align infinite.exists_subset_card_eq Infinite.exists_subset_card_eq
 
@@ -1126,7 +1126,7 @@ theorem exists_superset_card_eq [Infinite α] (s : Finset α) (n : ℕ) (hn : s.
 end Infinite
 
 /-- If every finset in a type has bounded cardinality, that type is finite. -/
-noncomputable def fintypeOfFinsetCardLe {ι : Type _} (n : ℕ) (w : ∀ s : Finset ι, s.card ≤ n) :
+noncomputable def fintypeOfFinsetCardLe {ι : Type*} (n : ℕ) (w : ∀ s : Finset ι, s.card ≤ n) :
     Fintype ι := by
   apply fintypeOfNotInfinite
   intro i
@@ -1197,7 +1197,7 @@ The major premise is `Fintype α`, so to use this with the `induction` tactic yo
 to that instance and use that name.
 -/
 @[elab_as_elim]
-theorem Fintype.induction_subsingleton_or_nontrivial {P : ∀ (α) [Fintype α], Prop} (α : Type _)
+theorem Fintype.induction_subsingleton_or_nontrivial {P : ∀ (α) [Fintype α], Prop} (α : Type*)
     [Fintype α] (hbase : ∀ (α) [Fintype α] [Subsingleton α], P α)
     (hstep :
       ∀ (α) [Fintype α] [Nontrivial α],
@@ -1217,7 +1217,7 @@ namespace Tactic
 
 --open Positivity
 
-private theorem card_univ_pos (α : Type _) [Fintype α] [Nonempty α] :
+private theorem card_univ_pos (α : Type*) [Fintype α] [Nonempty α] :
     0 < (Finset.univ : Finset α).card :=
   Finset.univ_nonempty.card_pos
 
refactor(GroupTheory/GroupAction/Quotient): Move conjugacy class formula earlier (#6290)

This PR moves a formula for the number of conjugacy classes earlier. The proof uses Burnside's theorem, so it cannot be moved any earlier than GroupTheory/GroupAction/Quotient.

Diff
@@ -1061,6 +1061,10 @@ instance Prod.infinite_of_left [Infinite α] [Nonempty β] : Infinite (α × β)
   Infinite.of_surjective Prod.fst Prod.fst_surjective
 #align prod.infinite_of_left Prod.infinite_of_left
 
+instance instInfiniteProdSubtypeCommute [Mul α] [Infinite α] :
+    Infinite { p : α × α // _root_.Commute p.1 p.2 } :=
+  Infinite.of_injective (fun a => ⟨⟨a, a⟩, rfl⟩) (by intro; simp)
+
 namespace Infinite
 
 private noncomputable def natEmbeddingAux (α : Type _) [Infinite α] : ℕ → α
chore: tidy various files (#6291)
Diff
@@ -696,27 +696,27 @@ open Fintype
 
 /-- Construct an equivalence from functions that are inverse to each other. -/
 @[simps]
-def ofLeftInverseOfCardLe (hβα : card β ≤ card α) (f : α → β) (g : β → α) (h : LeftInverse g f) :
+def ofLeftInverseOfCardLE (hβα : card β ≤ card α) (f : α → β) (g : β → α) (h : LeftInverse g f) :
     α ≃ β where
   toFun := f
   invFun := g
   left_inv := h
   right_inv := h.rightInverse_of_card_le hβα
-#align equiv.of_left_inverse_of_card_le Equiv.ofLeftInverseOfCardLe
-#align equiv.of_left_inverse_of_card_le_symm_apply Equiv.ofLeftInverseOfCardLe_symm_apply
-#align equiv.of_left_inverse_of_card_le_apply Equiv.ofLeftInverseOfCardLe_apply
+#align equiv.of_left_inverse_of_card_le Equiv.ofLeftInverseOfCardLE
+#align equiv.of_left_inverse_of_card_le_symm_apply Equiv.ofLeftInverseOfCardLE_symm_apply
+#align equiv.of_left_inverse_of_card_le_apply Equiv.ofLeftInverseOfCardLE_apply
 
 /-- Construct an equivalence from functions that are inverse to each other. -/
 @[simps]
-def ofRightInverseOfCardLe (hαβ : card α ≤ card β) (f : α → β) (g : β → α) (h : RightInverse g f) :
+def ofRightInverseOfCardLE (hαβ : card α ≤ card β) (f : α → β) (g : β → α) (h : RightInverse g f) :
     α ≃ β where
   toFun := f
   invFun := g
   left_inv := h.leftInverse_of_card_le hαβ
   right_inv := h
-#align equiv.of_right_inverse_of_card_le Equiv.ofRightInverseOfCardLe
-#align equiv.of_right_inverse_of_card_le_symm_apply Equiv.ofRightInverseOfCardLe_symm_apply
-#align equiv.of_right_inverse_of_card_le_apply Equiv.ofRightInverseOfCardLe_apply
+#align equiv.of_right_inverse_of_card_le Equiv.ofRightInverseOfCardLE
+#align equiv.of_right_inverse_of_card_le_symm_apply Equiv.ofRightInverseOfCardLE_symm_apply
+#align equiv.of_right_inverse_of_card_le_apply Equiv.ofRightInverseOfCardLE_apply
 
 end Equiv
 
@@ -743,9 +743,9 @@ noncomputable def Finset.equivOfCardEq {s t : Finset α} (h : s.card = t.card) :
 #align finset.equiv_of_card_eq Finset.equivOfCardEq
 
 @[simp]
-theorem Fintype.card_Prop : Fintype.card Prop = 2 :=
+theorem Fintype.card_prop : Fintype.card Prop = 2 :=
   rfl
-#align fintype.card_Prop Fintype.card_Prop
+#align fintype.card_Prop Fintype.card_prop
 
 theorem set_fintype_card_le_univ [Fintype α] (s : Set α) [Fintype s] :
     Fintype.card s ≤ Fintype.card α :=
@@ -776,23 +776,23 @@ This is a formulation of the pigeonhole principle.
 
 Note this cannot be an instance as it needs `h`. -/
 @[simp]
-theorem is_empty_of_card_lt [Fintype α] [Fintype β] (h : Fintype.card β < Fintype.card α) :
+theorem isEmpty_of_card_lt [Fintype α] [Fintype β] (h : Fintype.card β < Fintype.card α) :
     IsEmpty (α ↪ β) :=
   ⟨fun f =>
     let ⟨_x, _y, ne, feq⟩ := Fintype.exists_ne_map_eq_of_card_lt f h
     ne <| f.injective feq⟩
-#align function.embedding.is_empty_of_card_lt Function.Embedding.is_empty_of_card_lt
+#align function.embedding.is_empty_of_card_lt Function.Embedding.isEmpty_of_card_lt
 
 /-- A constructive embedding of a fintype `α` in another fintype `β` when `card α ≤ card β`. -/
-def truncOfCardLe [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
+def truncOfCardLE [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
     (h : Fintype.card α ≤ Fintype.card β) : Trunc (α ↪ β) :=
   (Fintype.truncEquivFin α).bind fun ea =>
     (Fintype.truncEquivFin β).map fun eb =>
       ea.toEmbedding.trans ((Fin.castLEEmb h).toEmbedding.trans eb.symm.toEmbedding)
-#align function.embedding.trunc_of_card_le Function.Embedding.truncOfCardLe
+#align function.embedding.trunc_of_card_le Function.Embedding.truncOfCardLE
 
 theorem nonempty_of_card_le [Fintype α] [Fintype β] (h : Fintype.card α ≤ Fintype.card β) :
-    Nonempty (α ↪ β) := by classical exact (truncOfCardLe h).nonempty
+    Nonempty (α ↪ β) := by classical exact (truncOfCardLE h).nonempty
 #align function.embedding.nonempty_of_card_le Function.Embedding.nonempty_of_card_le
 
 theorem nonempty_iff_card_le [Fintype α] [Fintype β] :
@@ -847,11 +847,10 @@ theorem Fintype.card_subtype_compl [Fintype α] (p : α → Prop) [Fintype { x /
     [Fintype { x // ¬p x }] :
     Fintype.card { x // ¬p x } = Fintype.card α - Fintype.card { x // p x } := by
   classical
-    rw [Fintype.card_of_subtype (Set.toFinset pᶜ), Set.toFinset_compl p,
-      Finset.card_compl, Fintype.card_of_subtype (Set.toFinset p)] <;>
+    rw [Fintype.card_of_subtype (Set.toFinset { x | p x }ᶜ), Set.toFinset_compl,
+      Finset.card_compl, Fintype.card_of_subtype] <;>
     · intro
-      simp only [Set.mem_toFinset, Set.mem_compl_iff]
-      rfl
+      simp only [Set.mem_toFinset, Set.mem_compl_iff, Set.mem_setOf]
 #align fintype.card_subtype_compl Fintype.card_subtype_compl
 
 theorem Fintype.card_subtype_mono (p q : α → Prop) (h : p ≤ q) [Fintype { x // p x }]
@@ -894,18 +893,17 @@ variable [Finite α]
 theorem wellFounded_of_trans_of_irrefl (r : α → α → Prop) [IsTrans α r] [IsIrrefl α r] :
     WellFounded r := by
   classical
-  cases nonempty_fintype α;
-  exact
-    have :
-      ∀ x y, r x y → (univ.filter fun z => r z x).card < (univ.filter fun z => r z y).card :=
-      fun x y hxy =>
-      Finset.card_lt_card <| by
-        simp only [Finset.lt_iff_ssubset.symm, lt_iff_le_not_le, Finset.le_iff_subset,
-            Finset.subset_iff, mem_filter, true_and_iff, mem_univ, hxy];
-        exact
-          ⟨fun z hzx => _root_.trans hzx hxy,
-            not_forall_of_exists_not ⟨x, not_imp.2 ⟨hxy, irrefl x⟩⟩⟩
-    Subrelation.wf (this _ _) (measure _).wf
+  cases nonempty_fintype α
+  have :
+    ∀ x y, r x y → (univ.filter fun z => r z x).card < (univ.filter fun z => r z y).card :=
+    fun x y hxy =>
+    Finset.card_lt_card <| by
+      simp only [Finset.lt_iff_ssubset.symm, lt_iff_le_not_le, Finset.le_iff_subset,
+          Finset.subset_iff, mem_filter, true_and_iff, mem_univ, hxy];
+      exact
+        ⟨fun z hzx => _root_.trans hzx hxy,
+          not_forall_of_exists_not ⟨x, not_imp.2 ⟨hxy, irrefl x⟩⟩⟩
+  exact Subrelation.wf (this _ _) (measure _).wf
 #align finite.well_founded_of_trans_of_irrefl Finite.wellFounded_of_trans_of_irrefl
 
 -- See note [lower instance priority]
@@ -932,9 +930,9 @@ protected theorem Fintype.false [Infinite α] (_h : Fintype α) : False :=
 #align fintype.false Fintype.false
 
 @[simp]
-theorem is_empty_fintype {α : Type _} : IsEmpty (Fintype α) ↔ Infinite α :=
+theorem isEmpty_fintype {α : Type _} : IsEmpty (Fintype α) ↔ Infinite α :=
   ⟨fun ⟨h⟩ => ⟨fun h' => (@nonempty_fintype α h').elim h⟩, fun ⟨h⟩ => ⟨fun h' => h h'.finite⟩⟩
-#align is_empty_fintype is_empty_fintype
+#align is_empty_fintype isEmpty_fintype
 
 /-- A non-infinite type is a fintype. -/
 noncomputable def fintypeOfNotInfinite {α : Type _} (h : ¬Infinite α) : Fintype α :=
@@ -947,7 +945,7 @@ open Classical
 
 /-- Any type is (classically) either a `Fintype`, or `Infinite`.
 
-One can obtain the relevant typeclasses via `cases fintypeOrInfinite α; resetI`.
+One can obtain the relevant typeclasses via `cases fintypeOrInfinite α`.
 -/
 noncomputable def fintypeOrInfinite (α : Type _) : PSum (Fintype α) (Infinite α) :=
   if h : Infinite α then PSum.inr h else PSum.inl (fintypeOfNotInfinite h)
@@ -971,14 +969,13 @@ theorem Finset.exists_maximal {α : Type _} [Preorder α] (s : Finset α) (h : s
 namespace Infinite
 
 theorem of_not_fintype (h : Fintype α → False) : Infinite α :=
-  is_empty_fintype.mp ⟨h⟩
+  isEmpty_fintype.mp ⟨h⟩
 #align infinite.of_not_fintype Infinite.of_not_fintype
 
 /-- If `s : Set α` is a proper subset of `α` and `f : α → s` is injective, then `α` is infinite. -/
 theorem of_injective_to_set {s : Set α} (hs : s ≠ Set.univ) {f : α → s} (hf : Injective f) :
     Infinite α :=
   of_not_fintype fun h => by
-    skip
     classical
       refine' lt_irrefl (Fintype.card α) _
       calc
@@ -1220,7 +1217,7 @@ private theorem card_univ_pos (α : Type _) [Fintype α] [Nonempty α] :
     0 < (Finset.univ : Finset α).card :=
   Finset.univ_nonempty.card_pos
 
---Porting note: not porting meta code yet
+--Porting note(https://github.com/leanprover-community/mathlib4/issues/6038): restore
 -- /-- Extension for the `positivity` tactic: `finset.card s` is positive if `s` is nonempty. -/
 -- @[positivity]
 -- unsafe def positivity_finset_card : expr → tactic strictness
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,17 +2,14 @@
 Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
-
-! This file was ported from Lean 3 source module data.fintype.card
-! leanprover-community/mathlib commit bf2428c9486c407ca38b5b3fb10b87dad0bc99fa
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Data.Fintype.Basic
 import Mathlib.Data.Finset.Card
 import Mathlib.Data.List.NodupEquivFin
 import Mathlib.Tactic.Positivity
 
+#align_import data.fintype.card from "leanprover-community/mathlib"@"bf2428c9486c407ca38b5b3fb10b87dad0bc99fa"
+
 /-!
 # Cardinalities of finite types
 
chore: forward port #18999 (#5974)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 
 ! This file was ported from Lean 3 source module data.fintype.card
-! leanprover-community/mathlib commit 92ca63f0fb391a9ca5f22d2409a6080e786d99f7
+! leanprover-community/mathlib commit bf2428c9486c407ca38b5b3fb10b87dad0bc99fa
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -911,20 +911,20 @@ theorem wellFounded_of_trans_of_irrefl (r : α → α → Prop) [IsTrans α r] [
     Subrelation.wf (this _ _) (measure _).wf
 #align finite.well_founded_of_trans_of_irrefl Finite.wellFounded_of_trans_of_irrefl
 
-theorem Preorder.wellFounded_lt [Preorder α] : WellFounded ((· < ·) : α → α → Prop) :=
-  wellFounded_of_trans_of_irrefl _
-#align finite.preorder.well_founded_lt Finite.Preorder.wellFounded_lt
+-- See note [lower instance priority]
+instance (priority := 100) to_wellFoundedLT [Preorder α] : WellFoundedLT α :=
+  ⟨wellFounded_of_trans_of_irrefl _⟩
+#align finite.finite.to_well_founded_lt Finite.to_wellFoundedLT
 
-theorem Preorder.wellFounded_gt [Preorder α] : WellFounded ((· > ·) : α → α → Prop) :=
-  wellFounded_of_trans_of_irrefl _
-#align finite.preorder.well_founded_gt Finite.Preorder.wellFounded_gt
+-- See note [lower instance priority]
+instance (priority := 100) to_wellFoundedGT [Preorder α] : WellFoundedGT α :=
+  ⟨wellFounded_of_trans_of_irrefl _⟩
+#align finite.finite.to_well_founded_gt Finite.to_wellFoundedGT
 
-instance (priority := 10) LinearOrder.isWellOrder_lt [LinearOrder α] : IsWellOrder α (· < ·)
-    where wf := Preorder.wellFounded_lt
+instance (priority := 10) LinearOrder.isWellOrder_lt [LinearOrder α] : IsWellOrder α (· < ·) := {}
 #align finite.linear_order.is_well_order_lt Finite.LinearOrder.isWellOrder_lt
 
-instance (priority := 10) LinearOrder.isWellOrder_gt [LinearOrder α] : IsWellOrder α (· > ·)
-    where wf := Preorder.wellFounded_gt
+instance (priority := 10) LinearOrder.isWellOrder_gt [LinearOrder α] : IsWellOrder α (· > ·) := {}
 #align finite.linear_order.is_well_order_gt Finite.LinearOrder.isWellOrder_gt
 
 end Finite
chore: bump to nightly-2023-07-01 (#5409)

Open in Gitpod

Co-authored-by: Komyyy <pol_tta@outlook.jp> Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Ruben Van de Velde <65514131+Ruben-VandeVelde@users.noreply.github.com> Co-authored-by: Mario Carneiro <di.gama@gmail.com>

Diff
@@ -791,7 +791,7 @@ def truncOfCardLe [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
     (h : Fintype.card α ≤ Fintype.card β) : Trunc (α ↪ β) :=
   (Fintype.truncEquivFin α).bind fun ea =>
     (Fintype.truncEquivFin β).map fun eb =>
-      ea.toEmbedding.trans ((Fin.castLE h).toEmbedding.trans eb.symm.toEmbedding)
+      ea.toEmbedding.trans ((Fin.castLEEmb h).toEmbedding.trans eb.symm.toEmbedding)
 #align function.embedding.trunc_of_card_le Function.Embedding.truncOfCardLe
 
 theorem nonempty_of_card_le [Fintype α] [Fintype β] (h : Fintype.card α ≤ Fintype.card β) :
chore: rename Fin.cast to Fin.castIso (#5584)

Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>

Diff
@@ -168,7 +168,7 @@ See `Fintype.equivFinOfCardEq` for the noncomputable definition,
 and `Fintype.truncEquivFin` and `Fintype.equivFin` for the bijection `α ≃ Fin (card α)`.
 -/
 def truncEquivFinOfCardEq [DecidableEq α] {n : ℕ} (h : Fintype.card α = n) : Trunc (α ≃ Fin n) :=
-  (truncEquivFin α).map fun e => e.trans (Fin.cast h).toEquiv
+  (truncEquivFin α).map fun e => e.trans (Fin.castIso h).toEquiv
 #align fintype.trunc_equiv_fin_of_card_eq Fintype.truncEquivFinOfCardEq
 
 /-- If the cardinality of `α` is `n`, there is noncomputably a bijection between `α` and `Fin n`.
@@ -315,7 +315,7 @@ theorem fin_injective : Function.Injective Fin := fun m n h =>
 
 /-- A reversed version of `Fin.cast_eq_cast` that is easier to rewrite with. -/
 theorem Fin.cast_eq_cast' {n m : ℕ} (h : Fin n = Fin m) :
-    _root_.cast h = ⇑(Fin.cast <| fin_injective h) := by
+    _root_.cast h = ⇑(Fin.castIso <| fin_injective h) := by
   cases fin_injective h
   rfl
 #align fin.cast_eq_cast' Fin.cast_eq_cast'
chore: fix grammar in docs (#5668)
Diff
@@ -1105,7 +1105,7 @@ noncomputable def natEmbedding (α : Type _) [Infinite α] : ℕ ↪ α :=
   ⟨_, natEmbeddingAux_injective α⟩
 #align infinite.nat_embedding Infinite.natEmbedding
 
-/-- See `Infinite.exists_superset_card_eq` for a version that, for a `s : Finset α`,
+/-- See `Infinite.exists_superset_card_eq` for a version that, for an `s : Finset α`,
 provides a superset `t : Finset α`, `s ⊆ t` such that `t.card` is fixed. -/
 theorem exists_subset_card_eq (α : Type _) [Infinite α] (n : ℕ) : ∃ s : Finset α, s.card = n :=
   ⟨(range n).map (natEmbedding α), by rw [card_map, card_range]⟩
fix: change compl precedence (#5586)

Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>

Diff
@@ -292,8 +292,8 @@ theorem Finset.card_compl [DecidableEq α] [Fintype α] (s : Finset α) :
   Finset.card_univ_diff s
 #align finset.card_compl Finset.card_compl
 
-theorem Fintype.card_compl_set [Fintype α] (s : Set α) [Fintype s] [Fintype (↥(sᶜ) : Sort _)] :
-    Fintype.card (↥(sᶜ) : Sort _) = Fintype.card α - Fintype.card s := by
+theorem Fintype.card_compl_set [Fintype α] (s : Set α) [Fintype s] [Fintype (↥sᶜ : Sort _)] :
+    Fintype.card (↥sᶜ : Sort _) = Fintype.card α - Fintype.card s := by
   classical rw [← Set.toFinset_card, ← Set.toFinset_card, ← Finset.card_compl, Set.toFinset_compl]
 #align fintype.card_compl_set Fintype.card_compl_set
 
@@ -850,7 +850,7 @@ theorem Fintype.card_subtype_compl [Fintype α] (p : α → Prop) [Fintype { x /
     [Fintype { x // ¬p x }] :
     Fintype.card { x // ¬p x } = Fintype.card α - Fintype.card { x // p x } := by
   classical
-    rw [Fintype.card_of_subtype (Set.toFinset (pᶜ)), Set.toFinset_compl p,
+    rw [Fintype.card_of_subtype (Set.toFinset pᶜ), Set.toFinset_compl p,
       Finset.card_compl, Fintype.card_of_subtype (Set.toFinset p)] <;>
     · intro
       simp only [Set.mem_toFinset, Set.mem_compl_iff]
chore: fix many typos (#4967)

These are all doc fixes

Diff
@@ -27,7 +27,7 @@ import Mathlib.Tactic.Positivity
 * `Infinite.natEmbedding`: An embedding of `ℕ` into an infinite type.
 
 We also provide the following versions of the pigeonholes principle.
-* `Fintype.exists_ne_map_eq_of_card_lt` and `isEpty_of_card_lt`: Finitely many pigeons and
+* `Fintype.exists_ne_map_eq_of_card_lt` and `isEmpty_of_card_lt`: Finitely many pigeons and
   pigeonholes. Weak formulation.
 * `Finite.exists_ne_map_eq_of_infinite`: Infinitely many pigeons in finitely many pigeonholes.
   Weak formulation.
chore: fix upper/lowercase in comments (#4360)
  • Run a non-interactive version of fix-comments.py on all files.
  • Go through the diff and manually add/discard/edit chunks.
Diff
@@ -20,10 +20,10 @@ import Mathlib.Tactic.Positivity
 
 * `Fintype.card α`: Cardinality of a fintype. Equal to `Finset.univ.card`.
 * `Fintype.truncEquivFin`: A fintype `α` is computably equivalent to `Fin (card α)`. The
-  `trunc`-free, noncomputable version is `Fintype.equivFin`.
+  `Trunc`-free, noncomputable version is `Fintype.equivFin`.
 * `Fintype.truncEquivOfCardEq` `Fintype.equivOfCardEq`: Two fintypes of same cardinality are
   equivalent. See above.
-* `Fin.equiv_iff_eq`: `fin m ≃ fin n` iff `m = n`.
+* `Fin.equiv_iff_eq`: `Fin m ≃ Fin n` iff `m = n`.
 * `Infinite.natEmbedding`: An embedding of `ℕ` into an infinite type.
 
 We also provide the following versions of the pigeonholes principle.
@@ -181,7 +181,7 @@ noncomputable def equivFinOfCardEq {n : ℕ} (h : Fintype.card α = n) : α ≃
   (truncEquivFinOfCardEq h).out
 #align fintype.equiv_fin_of_card_eq Fintype.equivFinOfCardEq
 
-/-- Two `fintype`s with the same cardinality are (computably) in bijection.
+/-- Two `Fintype`s with the same cardinality are (computably) in bijection.
 
 See `Fintype.equivOfCardEq` for the noncomputable version,
 and `Fintype.truncEquivFinOfCardEq` and `Fintype.equivFinOfCardEq` for
@@ -950,7 +950,7 @@ open Classical
 
 /-- Any type is (classically) either a `Fintype`, or `Infinite`.
 
-One can obtain the relevant typeclasses via `cases fintype_or_infinite α; resetI`.
+One can obtain the relevant typeclasses via `cases fintypeOrInfinite α; resetI`.
 -/
 noncomputable def fintypeOrInfinite (α : Type _) : PSum (Fintype α) (Infinite α) :=
   if h : Infinite α then PSum.inr h else PSum.inl (fintypeOfNotInfinite h)
@@ -1106,7 +1106,7 @@ noncomputable def natEmbedding (α : Type _) [Infinite α] : ℕ ↪ α :=
 #align infinite.nat_embedding Infinite.natEmbedding
 
 /-- See `Infinite.exists_superset_card_eq` for a version that, for a `s : Finset α`,
-provides a superset `t : finset α`, `s ⊆ t` such that `t.card` is fixed. -/
+provides a superset `t : Finset α`, `s ⊆ t` such that `t.card` is fixed. -/
 theorem exists_subset_card_eq (α : Type _) [Infinite α] (n : ℕ) : ∃ s : Finset α, s.card = n :=
   ⟨(range n).map (natEmbedding α), by rw [card_map, card_range]⟩
 #align infinite.exists_subset_card_eq Infinite.exists_subset_card_eq
chore: Rename to sSup/iSup (#3938)

As discussed on Zulip

Renames

  • supₛsSup
  • infₛsInf
  • supᵢiSup
  • infᵢiInf
  • bsupₛbsSup
  • binfₛbsInf
  • bsupᵢbiSup
  • binfᵢbiInf
  • csupₛcsSup
  • cinfₛcsInf
  • csupᵢciSup
  • cinfᵢciInf
  • unionₛsUnion
  • interₛsInter
  • unionᵢiUnion
  • interᵢiInter
  • bunionₛbsUnion
  • binterₛbsInter
  • bunionᵢbiUnion
  • binterᵢbiInter

Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>

Diff
@@ -1171,7 +1171,7 @@ theorem Finite.exists_infinite_fiber [Infinite α] [Finite β] (f : α → β) :
     cases nonempty_fintype β
     haveI := fun y => fintypeOfNotInfinite <| hf y
     let key : Fintype α :=
-      { elems := univ.bunionᵢ fun y : β => (f ⁻¹' {y}).toFinset
+      { elems := univ.biUnion fun y : β => (f ⁻¹' {y}).toFinset
         complete := by simp }
     exact key.false
 #align finite.exists_infinite_fiber Finite.exists_infinite_fiber
chore: bye-bye, solo bys! (#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 bys".

Diff
@@ -866,8 +866,7 @@ theorem Fintype.card_subtype_mono (p q : α → Prop) (h : p ≤ q) [Fintype { x
 theorem Fintype.card_compl_eq_card_compl [Finite α] (p q : α → Prop) [Fintype { x // p x }]
     [Fintype { x // ¬p x }] [Fintype { x // q x }] [Fintype { x // ¬q x }]
     (h : Fintype.card { x // p x } = Fintype.card { x // q x }) :
-    Fintype.card { x // ¬p x } = Fintype.card { x // ¬q x } :=
-  by
+    Fintype.card { x // ¬p x } = Fintype.card { x // ¬q x } := by
   cases nonempty_fintype α
   simp only [Fintype.card_subtype_compl, h]
 #align fintype.card_compl_eq_card_compl Fintype.card_compl_eq_card_compl
@@ -1115,8 +1114,7 @@ theorem exists_subset_card_eq (α : Type _) [Infinite α] (n : ℕ) : ∃ s : Fi
 /-- See `Infinite.exists_subset_card_eq` for a version that provides an arbitrary
 `s : Finset α` for any cardinality. -/
 theorem exists_superset_card_eq [Infinite α] (s : Finset α) (n : ℕ) (hn : s.card ≤ n) :
-    ∃ t : Finset α, s ⊆ t ∧ t.card = n :=
-  by
+    ∃ t : Finset α, s ⊆ t ∧ t.card = n := by
   induction' n with n IH generalizing s
   · exact ⟨s, subset_refl _, Nat.eq_zero_of_le_zero hn⟩
   · cases' hn.eq_or_lt with hn' hn'
chore: fix #align lines (#3640)

This PR fixes two things:

  • Most 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.
  • All remaining more-than-one-line #align statements. (This was needed for a script I wrote for #3630.)
Diff
@@ -117,7 +117,6 @@ def truncFinBijection (α) [Fintype α] : Trunc { f : Fin (card α) → α // Bi
       univ.val
       (fun l (h : ∀ x : α, x ∈ l) (nd : l.Nodup) => Trunc.mk (nd.getBijectionOfForallMemList _ h))
       mem_univ_val univ.2
-
 #align fintype.trunc_fin_bijection Fintype.truncFinBijection
 
 theorem subtype_card {p : α → Prop} (s : Finset α) (H : ∀ x : α, x ∈ s ↔ p x) :
@@ -475,7 +474,6 @@ theorem card_lt_of_injective_of_not_mem (f : α → β) (h : Function.Injective
     card α = (univ.map ⟨f, h⟩).card := (card_map _).symm
     _ < card β :=
       Finset.card_lt_univ_of_not_mem <| by rwa [← mem_coe, coe_map, coe_univ, Set.image_univ]
-
 #align fintype.card_lt_of_injective_of_not_mem Fintype.card_lt_of_injective_of_not_mem
 
 theorem card_lt_of_injective_not_surjective (f : α → β) (h : Function.Injective f)
@@ -992,7 +990,6 @@ theorem of_injective_to_set {s : Set α} (hs : s ≠ Set.univ) {f : α → s} (h
         _ = s.toFinset.card := s.toFinset_card.symm
         _ < Fintype.card α :=
           Finset.card_lt_card <| by rwa [Set.toFinset_ssubset_univ, Set.ssubset_univ_iff]
-
 #align infinite.of_injective_to_set Infinite.of_injective_to_set
 
 /-- If `s : Set α` is a proper subset of `α` and `f : s → α` is surjective, then `α` is infinite. -/
chore: rename castLe (#3326)
Diff
@@ -793,7 +793,7 @@ def truncOfCardLe [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
     (h : Fintype.card α ≤ Fintype.card β) : Trunc (α ↪ β) :=
   (Fintype.truncEquivFin α).bind fun ea =>
     (Fintype.truncEquivFin β).map fun eb =>
-      ea.toEmbedding.trans ((Fin.castLe h).toEmbedding.trans eb.symm.toEmbedding)
+      ea.toEmbedding.trans ((Fin.castLE h).toEmbedding.trans eb.symm.toEmbedding)
 #align function.embedding.trunc_of_card_le Function.Embedding.truncOfCardLe
 
 theorem nonempty_of_card_le [Fintype α] [Fintype β] (h : Fintype.card α ≤ Fintype.card β) :
feat: Add instance of Infinite String (#1973)

This proves that the String type is infinite.

Diff
@@ -42,7 +42,7 @@ See `Infinite.of_injective` and `Infinite.of_surjective`.
 ## Instances
 
 We provide `Infinite` instances for
-* specific types: `ℕ`, `ℤ`
+* specific types: `ℕ`, `ℤ`, `String`
 * type constructors: `Multiset α`, `List α`
 
 -/
@@ -1039,6 +1039,12 @@ instance [Nonempty α] : Infinite (Multiset α) :=
 instance [Nonempty α] : Infinite (List α) :=
   Infinite.of_surjective ((↑) : List α → Multiset α) (surjective_quot_mk _)
 
+instance String.infinite : Infinite String :=
+  Infinite.of_injective (String.mk) <| by
+    intro _ _ h
+    cases h with
+    | refl => rfl
+
 instance Infinite.set [Infinite α] : Infinite (Set α) :=
   Infinite.of_injective singleton Set.singleton_injective
 #align infinite.set Infinite.set
feat: port RepresentationTheory.Maschke (#2986)
Diff
@@ -549,6 +549,8 @@ theorem card_ne_zero [Nonempty α] : card α ≠ 0 :=
   _root_.ne_of_gt card_pos
 #align fintype.card_ne_zero Fintype.card_ne_zero
 
+instance [Nonempty α] : NeZero (card α) := ⟨card_ne_zero⟩
+
 theorem card_le_one_iff : card α ≤ 1 ↔ ∀ a b : α, a = b :=
   let n := card α
   have hn : n = card α := rfl
chore: resync ported files (#2135)

This PR resyncs the first 28 entries of https://leanprover-community.github.io/mathlib-port-status/out-of-sync.html after sorting by diff size.

  • resync Mathlib/Data/Bool/Count
  • resync Mathlib/Order/Max
  • resync Mathlib/Algebra/EuclideanDomain/Instances
  • resync Mathlib/Data/List/Duplicate
  • resync Mathlib/Data/Multiset/Nodup
  • resync Mathlib/Data/Set/Pointwise/ListOfFn
  • resync Mathlib/Dynamics/FixedPoints/Basic
  • resync Mathlib/Order/OmegaCompletePartialOrder
  • resync Mathlib/Order/PropInstances
  • resync Mathlib/Topology/LocallyFinite
  • resync Mathlib/Data/Bool/Set
  • resync Mathlib/Data/Fintype/Card
  • resync Mathlib/Data/Multiset/Bind
  • resync Mathlib/Data/Rat/Floor
  • resync Mathlib/Algebra/Order/Floor
  • resync Mathlib/Data/Int/Basic
  • resync Mathlib/Data/Int/Dvd/Basic
  • resync Mathlib/Data/List/Sort
  • resync Mathlib/Data/Nat/GCD/Basic
  • resync Mathlib/Data/Set/Enumerate
  • resync Mathlib/Data/Set/Intervals/OrdConnectedComponent
  • resync Mathlib/GroupTheory/Subsemigroup/Basic
  • resync Mathlib/Topology/Connected
  • resync Mathlib/Topology/NhdsSet
  • resync Mathlib/Algebra/BigOperators/Multiset/Lemmas
  • resync Mathlib/Algebra/CharZero/Infinite
  • resync Mathlib/Data/Multiset/Range
  • resync Mathlib/Data/Set/Pointwise/Finite
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro
 
 ! This file was ported from Lean 3 source module data.fintype.card
-! leanprover-community/mathlib commit 509de852e1de55e1efa8eacfa11df0823f26f226
+! leanprover-community/mathlib commit 92ca63f0fb391a9ca5f22d2409a6080e786d99f7
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
chore: add missing #align statements (#1902)

This PR is the result of a slight variant on the following "algorithm"

  • take all mathlib 3 names, remove _ and make all uppercase letters into lowercase
  • take all mathlib 4 names, remove _ and make all uppercase letters into lowercase
  • look for matches, and create pairs (original_lean3_name, OriginalLean4Name)
  • for pairs that do not have an align statement:
    • use Lean 4 to lookup the file + position of the Lean 4 name
    • add an #align statement just before the next empty line
  • manually fix some tiny mistakes (e.g., empty lines in proofs might cause the #align statement to have been inserted too early)
Diff
@@ -706,6 +706,8 @@ def ofLeftInverseOfCardLe (hβα : card β ≤ card α) (f : α → β) (g : β
   left_inv := h
   right_inv := h.rightInverse_of_card_le hβα
 #align equiv.of_left_inverse_of_card_le Equiv.ofLeftInverseOfCardLe
+#align equiv.of_left_inverse_of_card_le_symm_apply Equiv.ofLeftInverseOfCardLe_symm_apply
+#align equiv.of_left_inverse_of_card_le_apply Equiv.ofLeftInverseOfCardLe_apply
 
 /-- Construct an equivalence from functions that are inverse to each other. -/
 @[simps]
@@ -716,6 +718,8 @@ def ofRightInverseOfCardLe (hαβ : card α ≤ card β) (f : α → β) (g : β
   left_inv := h.leftInverse_of_card_le hαβ
   right_inv := h
 #align equiv.of_right_inverse_of_card_le Equiv.ofRightInverseOfCardLe
+#align equiv.of_right_inverse_of_card_le_symm_apply Equiv.ofRightInverseOfCardLe_symm_apply
+#align equiv.of_right_inverse_of_card_le_apply Equiv.ofRightInverseOfCardLe_apply
 
 end Equiv
 
chore: Rename Type* to Type _ (#1866)

A bunch of docstrings were still mentioning Type*. This changes them to Type _.

Diff
@@ -400,7 +400,7 @@ noncomputable def Fintype.sumRight {α β} [Fintype (Sum α β)] : Fintype β :=
 /-!
 ### Relation to `Finite`
 
-In this section we prove that `α : Type*` is `Finite` if and only if `Fintype α` is nonempty.
+In this section we prove that `α : Type _` is `Finite` if and only if `Fintype α` is nonempty.
 -/
 
 
Feat: prove IsTrans α r → Trans r r r and Trans r r r → IsTrans α r (#1522)

Now Trans.trans conflicts with _root_.trans.

Diff
@@ -903,7 +903,7 @@ theorem wellFounded_of_trans_of_irrefl (r : α → α → Prop) [IsTrans α r] [
         simp only [Finset.lt_iff_ssubset.symm, lt_iff_le_not_le, Finset.le_iff_subset,
             Finset.subset_iff, mem_filter, true_and_iff, mem_univ, hxy];
         exact
-          ⟨fun z hzx => trans hzx hxy,
+          ⟨fun z hzx => _root_.trans hzx hxy,
             not_forall_of_exists_not ⟨x, not_imp.2 ⟨hxy, irrefl x⟩⟩⟩
     Subrelation.wf (this _ _) (measure _).wf
 #align finite.well_founded_of_trans_of_irrefl Finite.wellFounded_of_trans_of_irrefl
feat: port Data.ZMod.Defs (#1713)

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -1023,7 +1023,7 @@ instance : Infinite ℕ :=
     intro h
     exact (Finset.range _).card_le_univ.not_lt ((Nat.lt_succ_self _).trans_eq (card_range _).symm)
 
-instance : Infinite ℤ :=
+instance Int.infinite : Infinite ℤ :=
   Infinite.of_injective Int.ofNat fun _ _ => Int.ofNat.inj
 
 instance [Nonempty α] : Infinite (Multiset α) :=
chore: tidy various files (#1693)
Diff
@@ -133,13 +133,13 @@ theorem card_of_subtype {p : α → Prop} (s : Finset α) (H : ∀ x : α, x ∈
 #align fintype.card_of_subtype Fintype.card_of_subtype
 
 @[simp]
-theorem card_of_finset {p : Set α} (s : Finset α) (H : ∀ x, x ∈ s ↔ x ∈ p) :
+theorem card_ofFinset {p : Set α} (s : Finset α) (H : ∀ x, x ∈ s ↔ x ∈ p) :
     @Fintype.card p (ofFinset s H) = s.card :=
   Fintype.subtype_card s H
-#align fintype.card_of_finset Fintype.card_of_finset
+#align fintype.card_of_finset Fintype.card_ofFinset
 
 theorem card_of_finset' {p : Set α} (s : Finset α) (H : ∀ x, x ∈ s ↔ x ∈ p) [Fintype p] :
-    Fintype.card p = s.card := by rw [← card_of_finset s H]; congr; apply Subsingleton.elim
+    Fintype.card p = s.card := by rw [← card_ofFinset s H]; congr; apply Subsingleton.elim
 #align fintype.card_of_finset' Fintype.card_of_finset'
 
 end Fintype
@@ -198,8 +198,7 @@ See `Fintype.truncEquivOfCardEq` for the computable version,
 and `Fintype.truncEquivFinOfCardEq` and `Fintype.equivFinOfCardEq` for
 the specialization to `Fin`.
 -/
-noncomputable def equivOfCardEq (h : card α = card β) : α ≃ β :=
-  by
+noncomputable def equivOfCardEq (h : card α = card β) : α ≃ β := by
   letI := Classical.decEq α
   letI := Classical.decEq β
   exact (truncEquivOfCardEq h).out
@@ -218,21 +217,21 @@ theorem card_eq {α β} [_F : Fintype α] [_G : Fintype β] : card α = card β
 arbitrary `Fintype` instances, use either `Fintype.card_le_one_iff_subsingleton` or
 `Fintype.card_unique`. -/
 @[simp]
-theorem card_of_subsingleton (a : α) [Subsingleton α] : @Fintype.card _ (ofSubsingleton a) = 1 :=
+theorem card_ofSubsingleton (a : α) [Subsingleton α] : @Fintype.card _ (ofSubsingleton a) = 1 :=
   rfl
-#align fintype.card_of_subsingleton Fintype.card_of_subsingleton
+#align fintype.card_of_subsingleton Fintype.card_ofSubsingleton
 
 @[simp]
 theorem card_unique [Unique α] [h : Fintype α] : Fintype.card α = 1 :=
-  Subsingleton.elim (ofSubsingleton default) h ▸ card_of_subsingleton _
+  Subsingleton.elim (ofSubsingleton default) h ▸ card_ofSubsingleton _
 #align fintype.card_unique Fintype.card_unique
 
 /-- Note: this lemma is specifically about `Fintype.of_is_empty`. For a statement about
 arbitrary `Fintype` instances, use `Fintype.card_eq_zero_iff`. -/
 @[simp]
-theorem card_of_is_empty [IsEmpty α] : Fintype.card α = 0 :=
+theorem card_of_isEmpty [IsEmpty α] : Fintype.card α = 0 :=
   rfl
-#align fintype.card_of_is_empty Fintype.card_of_is_empty
+#align fintype.card_of_is_empty Fintype.card_of_isEmpty
 
 end Fintype
 
@@ -377,9 +376,9 @@ theorem Fintype.card_plift (α : Type _) [Fintype α] : Fintype.card (PLift α)
 #align fintype.card_plift Fintype.card_plift
 
 @[simp]
-theorem Fintype.card_order_dual (α : Type _) [Fintype α] : Fintype.card αᵒᵈ = Fintype.card α :=
+theorem Fintype.card_orderDual (α : Type _) [Fintype α] : Fintype.card αᵒᵈ = Fintype.card α :=
   rfl
-#align fintype.card_order_dual Fintype.card_order_dual
+#align fintype.card_order_dual Fintype.card_orderDual
 
 @[simp]
 theorem Fintype.card_lex (α : Type _) [Fintype α] : Fintype.card (Lex α) = Fintype.card α :=
@@ -399,9 +398,9 @@ noncomputable def Fintype.sumRight {α β} [Fintype (Sum α β)] : Fintype β :=
 #align fintype.sum_right Fintype.sumRight
 
 /-!
-### Relation to `finite`
+### Relation to `Finite`
 
-In this section we prove that `α : Type*` is `finite` if and only if `fintype α` is nonempty.
+In this section we prove that `α : Type*` is `Finite` if and only if `Fintype α` is nonempty.
 -/
 
 
@@ -410,8 +409,8 @@ protected theorem Fintype.finite {α : Type _} (_inst : Fintype α) : Finite α
   ⟨Fintype.equivFin α⟩
 #align fintype.finite Fintype.finite
 
-/-- For efficiency reasons, we want `finite` instances to have higher
-priority than ones coming from `fintype` instances. -/
+/-- For efficiency reasons, we want `Finite` instances to have higher
+priority than ones coming from `Fintype` instances. -/
 -- @[nolint fintype_finite] -- Porting note: do we need this
 instance (priority := 900) Finite.of_fintype (α : Type _) [Fintype α] : Finite α :=
   Fintype.finite ‹_›
@@ -435,8 +434,7 @@ noncomputable def Fintype.ofFinite (α : Type _) [Finite α] : Fintype α :=
   (nonempty_fintype α).some
 #align fintype.of_finite Fintype.ofFinite
 
-theorem Finite.of_injective {α β : Sort _} [Finite β] (f : α → β) (H : Injective f) : Finite α :=
-  by
+theorem Finite.of_injective {α β : Sort _} [Finite β] (f : α → β) (H : Injective f) : Finite α := by
   cases nonempty_fintype (PLift β)
   rw [← Equiv.injective_comp Equiv.plift f, ← Equiv.comp_injective _ Equiv.plift.symm] at H
   haveI := Fintype.ofInjective _ H
@@ -447,8 +445,7 @@ theorem Finite.of_surjective {α β : Sort _} [Finite α] (f : α → β) (H : S
   Finite.of_injective _ <| injective_surjInv H
 #align finite.of_surjective Finite.of_surjective
 
-theorem Finite.exists_univ_list (α) [Finite α] : ∃ l : List α, l.Nodup ∧ ∀ x : α, x ∈ l :=
-  by
+theorem Finite.exists_univ_list (α) [Finite α] : ∃ l : List α, l.Nodup ∧ ∀ x : α, x ∈ l := by
   cases nonempty_fintype α
   obtain ⟨l, e⟩ := Quotient.exists_rep (@univ α _).1
   have := And.intro (@univ α _).2 (@mem_univ_val α _)
@@ -511,11 +508,12 @@ theorem exists_ne_map_eq_of_card_lt (f : α → β) (h : Fintype.card β < Finty
 #align fintype.exists_ne_map_eq_of_card_lt Fintype.exists_ne_map_eq_of_card_lt
 
 theorem card_eq_one_iff : card α = 1 ↔ ∃ x : α, ∀ y, y = x := by
-  rw [← card_unit, card_eq];
-    exact
-      ⟨fun ⟨a⟩ => ⟨a.symm (), fun y => a.injective (Subsingleton.elim _ _)⟩, fun ⟨x, hx⟩ =>
-        ⟨⟨fun _ => (), fun _ => x, fun _ => (hx _).trans (hx _).symm, fun _ =>
-            Subsingleton.elim _ _⟩⟩⟩
+  rw [← card_unit, card_eq]
+  exact
+    ⟨fun ⟨a⟩ => ⟨a.symm (), fun y => a.injective (Subsingleton.elim _ _)⟩,
+     fun ⟨x, hx⟩ =>
+      ⟨⟨fun _ => (), fun _ => x, fun _ => (hx _).trans (hx _).symm, fun _ =>
+          Subsingleton.elim _ _⟩⟩⟩
 #align fintype.card_eq_one_iff Fintype.card_eq_one_iff
 
 theorem card_eq_zero_iff : card α = 0 ↔ IsEmpty α := by
@@ -780,8 +778,8 @@ Note this cannot be an instance as it needs `h`. -/
 theorem is_empty_of_card_lt [Fintype α] [Fintype β] (h : Fintype.card β < Fintype.card α) :
     IsEmpty (α ↪ β) :=
   ⟨fun f =>
-    let ⟨_x, _y, Ne, feq⟩ := Fintype.exists_ne_map_eq_of_card_lt f h
-    Ne <| f.injective feq⟩
+    let ⟨_x, _y, ne, feq⟩ := Fintype.exists_ne_map_eq_of_card_lt f h
+    ne <| f.injective feq⟩
 #align function.embedding.is_empty_of_card_lt Function.Embedding.is_empty_of_card_lt
 
 /-- A constructive embedding of a fintype `α` in another fintype `β` when `card α ≤ card β`. -/
@@ -802,8 +800,7 @@ theorem nonempty_iff_card_le [Fintype α] [Fintype β] :
 #align function.embedding.nonempty_iff_card_le Function.Embedding.nonempty_iff_card_le
 
 theorem exists_of_card_le_finset [Fintype α] {s : Finset β} (h : Fintype.card α ≤ s.card) :
-    ∃ f : α ↪ β, Set.range f ⊆ s :=
-  by
+    ∃ f : α ↪ β, Set.range f ⊆ s := by
   rw [← Fintype.card_coe] at h
   rcases nonempty_of_card_le h with ⟨f⟩
   exact ⟨f.trans (Embedding.subtype _), by simp [Set.range_subset_iff]⟩
@@ -839,8 +836,7 @@ theorem Fintype.card_subtype_lt [Fintype α] {p : α → Prop} [DecidablePred p]
 #align fintype.card_subtype_lt Fintype.card_subtype_lt
 
 theorem Fintype.card_subtype [Fintype α] (p : α → Prop) [DecidablePred p] :
-    Fintype.card { x // p x } = ((Finset.univ : Finset α).filter p).card :=
-  by
+    Fintype.card { x // p x } = ((Finset.univ : Finset α).filter p).card := by
   refine' Fintype.card_of_subtype _ _
   simp
 #align fintype.card_subtype Fintype.card_subtype
@@ -849,10 +845,11 @@ theorem Fintype.card_subtype [Fintype α] (p : α → Prop) [DecidablePred p] :
 theorem Fintype.card_subtype_compl [Fintype α] (p : α → Prop) [Fintype { x // p x }]
     [Fintype { x // ¬p x }] :
     Fintype.card { x // ¬p x } = Fintype.card α - Fintype.card { x // p x } := by
-  classical rw [Fintype.card_of_subtype (Set.toFinset (pᶜ)), Set.toFinset_compl p,
-            Finset.card_compl, Fintype.card_of_subtype (Set.toFinset p)] <;>
-          intro <;>
-        simp only [Set.mem_toFinset, Set.mem_compl_iff] <;>
+  classical
+    rw [Fintype.card_of_subtype (Set.toFinset (pᶜ)), Set.toFinset_compl p,
+      Finset.card_compl, Fintype.card_of_subtype (Set.toFinset p)] <;>
+    · intro
+      simp only [Set.mem_toFinset, Set.mem_compl_iff]
       rfl
 #align fintype.card_subtype_compl Fintype.card_subtype_compl
 
feat: port Data.Fintype.Card (#1668)

Co-authored-by: ChrisHughes24 <chrishughes24@gmail.com>

Dependencies 2 + 164

165 files ported (98.8%)
76412 lines ported (99.8%)
Show graph

The unported dependencies are