data.sum.basicMathlib.Data.Sum.Basic

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)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(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(data/prod): bijectivity of prod.map (#18446)

I needed this for showing a statement about invertibility of a map built with linear_map.prod_map (aka a "block diagonal" linear map), where the nonempty conditions are trivially true.

Forward-port will be at https://github.com/leanprover-community/mathlib4/pull/2346

Diff
@@ -388,11 +388,37 @@ lemma surjective.sum_map {f : α → β} {g : α' → β'} (hf : surjective f) (
 | (inl y) := let ⟨x, hx⟩ := hf y in ⟨inl x, congr_arg inl hx⟩
 | (inr y) := let ⟨x, hx⟩ := hg y in ⟨inr x, congr_arg inr hx⟩
 
+lemma bijective.sum_map {f : α → β} {g : α' → β'} (hf : bijective f) (hg : bijective g) :
+  bijective (sum.map f g) :=
+⟨hf.injective.sum_map hg.injective, hf.surjective.sum_map hg.surjective⟩
+
 end function
 
 namespace sum
 open function
 
+@[simp] lemma map_injective {f : α → γ} {g : β → δ} :
+  injective (sum.map f g) ↔ injective f ∧ injective g :=
+⟨λ h, ⟨λ a₁ a₂ ha, inl_injective $ @h (inl a₁) (inl a₂) (congr_arg inl ha : _),
+      λ b₁ b₂ hb, inr_injective $ @h (inr b₁) (inr b₂) (congr_arg inr hb : _)⟩,
+  λ h, h.1.sum_map h.2⟩
+
+@[simp] lemma map_surjective {f : α → γ} {g : β → δ} :
+  surjective (sum.map f g) ↔ surjective f ∧ surjective g :=
+⟨λ h, ⟨λ c, begin
+  obtain ⟨a | b, h⟩ := h (inl c),
+  { exact ⟨a, inl_injective h⟩ },
+  { cases h },
+end, λ d, begin
+  obtain ⟨a | b, h⟩ := h (inr d),
+  { cases h },
+  { exact ⟨b, inr_injective h⟩ },
+end⟩, λ h, h.1.sum_map h.2⟩
+
+@[simp] lemma map_bijective {f : α → γ} {g : β → δ} :
+  bijective (sum.map f g) ↔ bijective f ∧ bijective g :=
+(map_injective.and map_surjective).trans $ and_and_and_comm _ _ _ _
+
 lemma elim_const_const (c : γ) :
   sum.elim (const _ c : α → γ) (const _ c : β → γ) = const _ c :=
 by { ext x, cases x; refl }

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

feat(data/sum/basic): add some missing lemmas (#18184)

Forward-ported to Mathlib 4 in leanprover-community/mathlib4#1583

Diff
@@ -82,12 +82,18 @@ section get
 
 variables {x y : α ⊕ β}
 
-lemma get_left_eq_none_iff : x.get_left = none ↔ x.is_right :=
+@[simp] lemma get_left_eq_none_iff : x.get_left = none ↔ x.is_right :=
 by cases x; simp only [get_left, is_right, coe_sort_tt, coe_sort_ff, eq_self_iff_true]
 
-lemma get_right_eq_none_iff : x.get_right = none ↔ x.is_left :=
+@[simp] lemma get_right_eq_none_iff : x.get_right = none ↔ x.is_left :=
 by cases x; simp only [get_right, is_left, coe_sort_tt, coe_sort_ff, eq_self_iff_true]
 
+@[simp] lemma get_left_eq_some_iff {a} : x.get_left = some a ↔ x = inl a :=
+by cases x; simp only [get_left]
+
+@[simp] lemma get_right_eq_some_iff {b} : x.get_right = some b ↔ x = inr b :=
+by cases x; simp only [get_right]
+
 @[simp] lemma bnot_is_left (x : α ⊕ β) : bnot x.is_left = x.is_right := by cases x; refl
 @[simp] lemma is_left_eq_ff : x.is_left = ff ↔ x.is_right := by cases x; simp
 lemma not_is_left : ¬x.is_left ↔ x.is_right := by simp
@@ -156,9 +162,13 @@ funext $ map_map f' g' f g
 @[simp] lemma map_id_id (α β) : sum.map (@id α) (@id β) = id :=
 funext $ λ x, sum.rec_on x (λ _, rfl) (λ _, rfl)
 
+lemma elim_map {α β γ δ ε : Sort*} {f₁ : α → β} {f₂ : β → ε} {g₁ : γ → δ} {g₂ : δ → ε} {x} :
+  sum.elim f₂ g₂ (sum.map f₁ g₁ x) = sum.elim (f₂ ∘ f₁) (g₂ ∘ g₁) x :=
+by cases x; refl
+
 lemma elim_comp_map {α β γ δ ε : Sort*} {f₁ : α → β} {f₂ : β → ε} {g₁ : γ → δ} {g₂ : δ → ε} :
   sum.elim f₂ g₂ ∘ sum.map f₁ g₁ = sum.elim (f₂ ∘ f₁) (g₂ ∘ g₁) :=
-by ext (_|_); refl
+funext $ λ _, elim_map
 
 @[simp] lemma is_left_map (f : α → β) (g : γ → δ) (x : α ⊕ γ) :
   is_left (x.map f g) = is_left x :=

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(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
@@ -3,8 +3,8 @@ Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro, Yury G. Kudryashov
 -/
-import Mathbin.Logic.Function.Basic
-import Mathbin.Tactic.Basic
+import Logic.Function.Basic
+import Tactic.Basic
 
 #align_import data.sum.basic from "leanprover-community/mathlib"@"bd9851ca476957ea4549eb19b40e7b5ade9428cc"
 
Diff
@@ -148,10 +148,10 @@ theorem getRight?_eq_some_iff {b} : x.getRight? = some b ↔ x = inr b := by
 #align sum.get_right_eq_some_iff Sum.getRight?_eq_some_iff
 -/
 
-#print Sum.not_isLeft /-
+#print Sum.bnot_isLeft /-
 @[simp]
-theorem not_isLeft (x : Sum α β) : not x.isLeft = x.isRight := by cases x <;> rfl
-#align sum.bnot_is_left Sum.not_isLeft
+theorem bnot_isLeft (x : Sum α β) : not x.isLeft = x.isRight := by cases x <;> rfl
+#align sum.bnot_is_left Sum.bnot_isLeft
 -/
 
 #print Sum.isLeft_eq_false /-
@@ -160,15 +160,15 @@ theorem isLeft_eq_false : x.isLeft = false ↔ x.isRight := by cases x <;> simp
 #align sum.is_left_eq_ff Sum.isLeft_eq_false
 -/
 
-#print Sum.Not_isLeft /-
-theorem Not_isLeft : ¬x.isLeft ↔ x.isRight := by simp
-#align sum.not_is_left Sum.Not_isLeft
+#print Sum.not_isLeft /-
+theorem not_isLeft : ¬x.isLeft ↔ x.isRight := by simp
+#align sum.not_is_left Sum.not_isLeft
 -/
 
-#print Sum.not_isRight /-
+#print Sum.bnot_isRight /-
 @[simp]
-theorem not_isRight (x : Sum α β) : not x.isRight = x.isLeft := by cases x <;> rfl
-#align sum.bnot_is_right Sum.not_isRight
+theorem bnot_isRight (x : Sum α β) : not x.isRight = x.isLeft := by cases x <;> rfl
+#align sum.bnot_is_right Sum.bnot_isRight
 -/
 
 #print Sum.isRight_eq_false /-
@@ -177,9 +177,9 @@ theorem isRight_eq_false : x.isRight = false ↔ x.isLeft := by cases x <;> simp
 #align sum.is_right_eq_ff Sum.isRight_eq_false
 -/
 
-#print Sum.Not_isRight /-
-theorem Not_isRight : ¬x.isRight ↔ x.isLeft := by simp
-#align sum.not_is_right Sum.Not_isRight
+#print Sum.not_isRight /-
+theorem not_isRight : ¬x.isRight ↔ x.isLeft := by simp
+#align sum.not_is_right Sum.not_isRight
 -/
 
 #print Sum.isLeft_iff /-
Diff
@@ -80,22 +80,22 @@ theorem inr_injective : Function.Injective (inr : β → Sum α β) := fun x y =
 
 section get
 
-#print Sum.getLeft /-
+#print Sum.getLeft? /-
 /-- Check if a sum is `inl` and if so, retrieve its contents. -/
 @[simp]
-def getLeft : Sum α β → Option α
+def getLeft? : Sum α β → Option α
   | inl a => some a
   | inr _ => none
-#align sum.get_left Sum.getLeft
+#align sum.get_left Sum.getLeft?
 -/
 
-#print Sum.getRight /-
+#print Sum.getRight? /-
 /-- Check if a sum is `inr` and if so, retrieve its contents. -/
 @[simp]
-def getRight : Sum α β → Option β
+def getRight? : Sum α β → Option β
   | inr b => some b
   | inl _ => none
-#align sum.get_right Sum.getRight
+#align sum.get_right Sum.getRight?
 -/
 
 #print Sum.isLeft /-
@@ -118,34 +118,34 @@ def isRight : Sum α β → Bool
 
 variable {x y : Sum α β}
 
-#print Sum.getLeft_eq_none_iff /-
+#print Sum.getLeft?_eq_none_iff /-
 @[simp]
-theorem getLeft_eq_none_iff : x.getLeft = none ↔ x.isRight := by
+theorem getLeft?_eq_none_iff : x.getLeft? = none ↔ x.isRight := by
   cases x <;>
     simp only [get_left, is_right, Bool.coe_sort_true, Bool.coe_sort_false, eq_self_iff_true]
-#align sum.get_left_eq_none_iff Sum.getLeft_eq_none_iff
+#align sum.get_left_eq_none_iff Sum.getLeft?_eq_none_iff
 -/
 
-#print Sum.getRight_eq_none_iff /-
+#print Sum.getRight?_eq_none_iff /-
 @[simp]
-theorem getRight_eq_none_iff : x.getRight = none ↔ x.isLeft := by
+theorem getRight?_eq_none_iff : x.getRight? = none ↔ x.isLeft := by
   cases x <;>
     simp only [get_right, is_left, Bool.coe_sort_true, Bool.coe_sort_false, eq_self_iff_true]
-#align sum.get_right_eq_none_iff Sum.getRight_eq_none_iff
+#align sum.get_right_eq_none_iff Sum.getRight?_eq_none_iff
 -/
 
-#print Sum.getLeft_eq_some_iff /-
+#print Sum.getLeft?_eq_some_iff /-
 @[simp]
-theorem getLeft_eq_some_iff {a} : x.getLeft = some a ↔ x = inl a := by
+theorem getLeft?_eq_some_iff {a} : x.getLeft? = some a ↔ x = inl a := by
   cases x <;> simp only [get_left]
-#align sum.get_left_eq_some_iff Sum.getLeft_eq_some_iff
+#align sum.get_left_eq_some_iff Sum.getLeft?_eq_some_iff
 -/
 
-#print Sum.getRight_eq_some_iff /-
+#print Sum.getRight?_eq_some_iff /-
 @[simp]
-theorem getRight_eq_some_iff {b} : x.getRight = some b ↔ x = inr b := by
+theorem getRight?_eq_some_iff {b} : x.getRight? = some b ↔ x = inr b := by
   cases x <;> simp only [get_right]
-#align sum.get_right_eq_some_iff Sum.getRight_eq_some_iff
+#align sum.get_right_eq_some_iff Sum.getRight?_eq_some_iff
 -/
 
 #print Sum.not_isLeft /-
@@ -346,18 +346,18 @@ theorem isRight_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isRight (x
 #align sum.is_right_map Sum.isRight_map
 -/
 
-#print Sum.getLeft_map /-
+#print Sum.getLeft?_map /-
 @[simp]
-theorem getLeft_map (f : α → β) (g : γ → δ) (x : Sum α γ) : (x.map f g).getLeft = x.getLeft.map f :=
-  by cases x <;> rfl
-#align sum.get_left_map Sum.getLeft_map
+theorem getLeft?_map (f : α → β) (g : γ → δ) (x : Sum α γ) :
+    (x.map f g).getLeft? = x.getLeft?.map f := by cases x <;> rfl
+#align sum.get_left_map Sum.getLeft?_map
 -/
 
-#print Sum.getRight_map /-
+#print Sum.getRight?_map /-
 @[simp]
-theorem getRight_map (f : α → β) (g : γ → δ) (x : Sum α γ) :
-    (x.map f g).getRight = x.getRight.map g := by cases x <;> rfl
-#align sum.get_right_map Sum.getRight_map
+theorem getRight?_map (f : α → β) (g : γ → δ) (x : Sum α γ) :
+    (x.map f g).getRight? = x.getRight?.map g := by cases x <;> rfl
+#align sum.get_right_map Sum.getRight?_map
 -/
 
 open Function (update update_eq_iff update_comp_eq_of_injective update_comp_eq_of_forall_ne)
@@ -500,16 +500,16 @@ theorem isRight_swap (x : Sum α β) : x.symm.isRight = x.isLeft := by cases x <
 #align sum.is_right_swap Sum.isRight_swap
 -/
 
-#print Sum.getLeft_swap /-
+#print Sum.getLeft?_swap /-
 @[simp]
-theorem getLeft_swap (x : Sum α β) : x.symm.getLeft = x.getRight := by cases x <;> rfl
-#align sum.get_left_swap Sum.getLeft_swap
+theorem getLeft?_swap (x : Sum α β) : x.symm.getLeft? = x.getRight? := by cases x <;> rfl
+#align sum.get_left_swap Sum.getLeft?_swap
 -/
 
-#print Sum.getRight_swap /-
+#print Sum.getRight?_swap /-
 @[simp]
-theorem getRight_swap (x : Sum α β) : x.symm.getRight = x.getLeft := by cases x <;> rfl
-#align sum.get_right_swap Sum.getRight_swap
+theorem getRight?_swap (x : Sum α β) : x.symm.getRight? = x.getLeft? := by cases x <;> rfl
+#align sum.get_right_swap Sum.getRight?_swap
 -/
 
 section LiftRel
Diff
@@ -2,15 +2,12 @@
 Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro, Yury G. Kudryashov
-
-! This file was ported from Lean 3 source module data.sum.basic
-! leanprover-community/mathlib commit bd9851ca476957ea4549eb19b40e7b5ade9428cc
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.Logic.Function.Basic
 import Mathbin.Tactic.Basic
 
+#align_import data.sum.basic from "leanprover-community/mathlib"@"bd9851ca476957ea4549eb19b40e7b5ade9428cc"
+
 /-!
 # Disjoint union of types
 
Diff
@@ -168,9 +168,11 @@ theorem Not_isLeft : ¬x.isLeft ↔ x.isRight := by simp
 #align sum.not_is_left Sum.Not_isLeft
 -/
 
+#print Sum.not_isRight /-
 @[simp]
 theorem not_isRight (x : Sum α β) : not x.isRight = x.isLeft := by cases x <;> rfl
 #align sum.bnot_is_right Sum.not_isRight
+-/
 
 #print Sum.isRight_eq_false /-
 @[simp]
@@ -226,40 +228,54 @@ protected def elim {α β γ : Sort _} (f : α → γ) (g : β → γ) : Sum α
 #align sum.elim Sum.elim
 -/
 
+#print Sum.elim_inl /-
 @[simp]
 theorem elim_inl {α β γ : Sort _} (f : α → γ) (g : β → γ) (x : α) : Sum.elim f g (inl x) = f x :=
   rfl
 #align sum.elim_inl Sum.elim_inl
+-/
 
+#print Sum.elim_inr /-
 @[simp]
 theorem elim_inr {α β γ : Sort _} (f : α → γ) (g : β → γ) (x : β) : Sum.elim f g (inr x) = g x :=
   rfl
 #align sum.elim_inr Sum.elim_inr
+-/
 
+#print Sum.elim_comp_inl /-
 @[simp]
 theorem elim_comp_inl {α β γ : Sort _} (f : α → γ) (g : β → γ) : Sum.elim f g ∘ inl = f :=
   rfl
 #align sum.elim_comp_inl Sum.elim_comp_inl
+-/
 
+#print Sum.elim_comp_inr /-
 @[simp]
 theorem elim_comp_inr {α β γ : Sort _} (f : α → γ) (g : β → γ) : Sum.elim f g ∘ inr = g :=
   rfl
 #align sum.elim_comp_inr Sum.elim_comp_inr
+-/
 
+#print Sum.elim_inl_inr /-
 @[simp]
 theorem elim_inl_inr {α β : Sort _} : @Sum.elim α β _ inl inr = id :=
   funext fun x => Sum.casesOn x (fun _ => rfl) fun _ => rfl
 #align sum.elim_inl_inr Sum.elim_inl_inr
+-/
 
+#print Sum.comp_elim /-
 theorem comp_elim {α β γ δ : Sort _} (f : γ → δ) (g : α → γ) (h : β → γ) :
     f ∘ Sum.elim g h = Sum.elim (f ∘ g) (f ∘ h) :=
   funext fun x => Sum.casesOn x (fun _ => rfl) fun _ => rfl
 #align sum.comp_elim Sum.comp_elim
+-/
 
+#print Sum.elim_comp_inl_inr /-
 @[simp]
 theorem elim_comp_inl_inr {α β γ : Sort _} (f : Sum α β → γ) : Sum.elim (f ∘ inl) (f ∘ inr) = f :=
   funext fun x => Sum.casesOn x (fun _ => rfl) fun _ => rfl
 #align sum.elim_comp_inl_inr Sum.elim_comp_inl_inr
+-/
 
 #print Sum.map /-
 /-- Map `α ⊕ β` to `α' ⊕ β'` sending `α` to `α'` and `β` to `β'`. -/
@@ -282,112 +298,150 @@ theorem map_inr (f : α → α') (g : β → β') (x : β) : (inr x).map f g = i
 #align sum.map_inr Sum.map_inr
 -/
 
+#print Sum.map_map /-
 @[simp]
 theorem map_map {α'' β''} (f' : α' → α'') (g' : β' → β'') (f : α → α') (g : β → β') :
     ∀ x : Sum α β, (x.map f g).map f' g' = x.map (f' ∘ f) (g' ∘ g)
   | inl a => rfl
   | inr b => rfl
 #align sum.map_map Sum.map_map
+-/
 
+#print Sum.map_comp_map /-
 @[simp]
 theorem map_comp_map {α'' β''} (f' : α' → α'') (g' : β' → β'') (f : α → α') (g : β → β') :
     Sum.map f' g' ∘ Sum.map f g = Sum.map (f' ∘ f) (g' ∘ g) :=
   funext <| map_map f' g' f g
 #align sum.map_comp_map Sum.map_comp_map
+-/
 
+#print Sum.map_id_id /-
 @[simp]
 theorem map_id_id (α β) : Sum.map (@id α) (@id β) = id :=
   funext fun x => Sum.recOn x (fun _ => rfl) fun _ => rfl
 #align sum.map_id_id Sum.map_id_id
+-/
 
+#print Sum.elim_map /-
 theorem elim_map {α β γ δ ε : Sort _} {f₁ : α → β} {f₂ : β → ε} {g₁ : γ → δ} {g₂ : δ → ε} {x} :
     Sum.elim f₂ g₂ (Sum.map f₁ g₁ x) = Sum.elim (f₂ ∘ f₁) (g₂ ∘ g₁) x := by cases x <;> rfl
 #align sum.elim_map Sum.elim_map
+-/
 
+#print Sum.elim_comp_map /-
 theorem elim_comp_map {α β γ δ ε : Sort _} {f₁ : α → β} {f₂ : β → ε} {g₁ : γ → δ} {g₂ : δ → ε} :
     Sum.elim f₂ g₂ ∘ Sum.map f₁ g₁ = Sum.elim (f₂ ∘ f₁) (g₂ ∘ g₁) :=
   funext fun _ => elim_map
 #align sum.elim_comp_map Sum.elim_comp_map
+-/
 
+#print Sum.isLeft_map /-
 @[simp]
 theorem isLeft_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isLeft (x.map f g) = isLeft x := by
   cases x <;> rfl
 #align sum.is_left_map Sum.isLeft_map
+-/
 
+#print Sum.isRight_map /-
 @[simp]
 theorem isRight_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isRight (x.map f g) = isRight x := by
   cases x <;> rfl
 #align sum.is_right_map Sum.isRight_map
+-/
 
+#print Sum.getLeft_map /-
 @[simp]
 theorem getLeft_map (f : α → β) (g : γ → δ) (x : Sum α γ) : (x.map f g).getLeft = x.getLeft.map f :=
   by cases x <;> rfl
 #align sum.get_left_map Sum.getLeft_map
+-/
 
+#print Sum.getRight_map /-
 @[simp]
 theorem getRight_map (f : α → β) (g : γ → δ) (x : Sum α γ) :
     (x.map f g).getRight = x.getRight.map g := by cases x <;> rfl
 #align sum.get_right_map Sum.getRight_map
+-/
 
 open Function (update update_eq_iff update_comp_eq_of_injective update_comp_eq_of_forall_ne)
 
+#print Sum.update_elim_inl /-
 @[simp]
 theorem update_elim_inl [DecidableEq α] [DecidableEq (Sum α β)] {f : α → γ} {g : β → γ} {i : α}
     {x : γ} : update (Sum.elim f g) (inl i) x = Sum.elim (update f i x) g :=
   update_eq_iff.2 ⟨by simp, by simp (config := { contextual := true })⟩
 #align sum.update_elim_inl Sum.update_elim_inl
+-/
 
+#print Sum.update_elim_inr /-
 @[simp]
 theorem update_elim_inr [DecidableEq β] [DecidableEq (Sum α β)] {f : α → γ} {g : β → γ} {i : β}
     {x : γ} : update (Sum.elim f g) (inr i) x = Sum.elim f (update g i x) :=
   update_eq_iff.2 ⟨by simp, by simp (config := { contextual := true })⟩
 #align sum.update_elim_inr Sum.update_elim_inr
+-/
 
+#print Sum.update_inl_comp_inl /-
 @[simp]
 theorem update_inl_comp_inl [DecidableEq α] [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : α}
     {x : γ} : update f (inl i) x ∘ inl = update (f ∘ inl) i x :=
   update_comp_eq_of_injective _ inl_injective _ _
 #align sum.update_inl_comp_inl Sum.update_inl_comp_inl
+-/
 
+#print Sum.update_inl_apply_inl /-
 @[simp]
 theorem update_inl_apply_inl [DecidableEq α] [DecidableEq (Sum α β)] {f : Sum α β → γ} {i j : α}
     {x : γ} : update f (inl i) x (inl j) = update (f ∘ inl) i x j := by rw [← update_inl_comp_inl]
 #align sum.update_inl_apply_inl Sum.update_inl_apply_inl
+-/
 
+#print Sum.update_inl_comp_inr /-
 @[simp]
 theorem update_inl_comp_inr [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : α} {x : γ} :
     update f (inl i) x ∘ inr = f ∘ inr :=
   update_comp_eq_of_forall_ne _ _ fun _ => inr_ne_inl
 #align sum.update_inl_comp_inr Sum.update_inl_comp_inr
+-/
 
+#print Sum.update_inl_apply_inr /-
 @[simp]
 theorem update_inl_apply_inr [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : α} {j : β} {x : γ} :
     update f (inl i) x (inr j) = f (inr j) :=
   Function.update_noteq inr_ne_inl _ _
 #align sum.update_inl_apply_inr Sum.update_inl_apply_inr
+-/
 
+#print Sum.update_inr_comp_inl /-
 @[simp]
 theorem update_inr_comp_inl [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : β} {x : γ} :
     update f (inr i) x ∘ inl = f ∘ inl :=
   update_comp_eq_of_forall_ne _ _ fun _ => inl_ne_inr
 #align sum.update_inr_comp_inl Sum.update_inr_comp_inl
+-/
 
+#print Sum.update_inr_apply_inl /-
 @[simp]
 theorem update_inr_apply_inl [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : α} {j : β} {x : γ} :
     update f (inr j) x (inl i) = f (inl i) :=
   Function.update_noteq inl_ne_inr _ _
 #align sum.update_inr_apply_inl Sum.update_inr_apply_inl
+-/
 
+#print Sum.update_inr_comp_inr /-
 @[simp]
 theorem update_inr_comp_inr [DecidableEq β] [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : β}
     {x : γ} : update f (inr i) x ∘ inr = update (f ∘ inr) i x :=
   update_comp_eq_of_injective _ inr_injective _ _
 #align sum.update_inr_comp_inr Sum.update_inr_comp_inr
+-/
 
+#print Sum.update_inr_apply_inr /-
 @[simp]
 theorem update_inr_apply_inr [DecidableEq β] [DecidableEq (Sum α β)] {f : Sum α β → γ} {i j : β}
     {x : γ} : update f (inr i) x (inr j) = update (f ∘ inr) i x j := by rw [← update_inr_comp_inr]
 #align sum.update_inr_apply_inr Sum.update_inr_apply_inr
+-/
 
 #print Sum.swap /-
 /-- Swap the factors of a sum type -/
@@ -477,25 +531,33 @@ attribute [protected] lift_rel.inl lift_rel.inr
 variable {r r₁ r₂ : α → γ → Prop} {s s₁ s₂ : β → δ → Prop} {a : α} {b : β} {c : γ} {d : δ}
   {x : Sum α β} {y : Sum γ δ}
 
+#print Sum.liftRel_inl_inl /-
 @[simp]
 theorem liftRel_inl_inl : LiftRel r s (inl a) (inl c) ↔ r a c :=
   ⟨fun h => by cases h; assumption, LiftRel.inl⟩
 #align sum.lift_rel_inl_inl Sum.liftRel_inl_inl
+-/
 
+#print Sum.not_liftRel_inl_inr /-
 @[simp]
 theorem not_liftRel_inl_inr : ¬LiftRel r s (inl a) (inr d) :=
   fun.
 #align sum.not_lift_rel_inl_inr Sum.not_liftRel_inl_inr
+-/
 
+#print Sum.not_liftRel_inr_inl /-
 @[simp]
 theorem not_liftRel_inr_inl : ¬LiftRel r s (inr b) (inl c) :=
   fun.
 #align sum.not_lift_rel_inr_inl Sum.not_liftRel_inr_inl
+-/
 
+#print Sum.liftRel_inr_inr /-
 @[simp]
 theorem liftRel_inr_inr : LiftRel r s (inr b) (inr d) ↔ s b d :=
   ⟨fun h => by cases h; assumption, LiftRel.inr⟩
 #align sum.lift_rel_inr_inr Sum.liftRel_inr_inr
+-/
 
 instance [∀ a c, Decidable (r a c)] [∀ b d, Decidable (s b d)] :
     ∀ (ab : Sum α β) (cd : Sum γ δ), Decidable (LiftRel r s ab cd)
@@ -504,28 +566,38 @@ instance [∀ a c, Decidable (r a c)] [∀ b d, Decidable (s b d)] :
   | inr b, inl c => Decidable.isFalse not_liftRel_inr_inl
   | inr b, inr d => decidable_of_iff' _ liftRel_inr_inr
 
+#print Sum.LiftRel.mono /-
 theorem LiftRel.mono (hr : ∀ a b, r₁ a b → r₂ a b) (hs : ∀ a b, s₁ a b → s₂ a b)
     (h : LiftRel r₁ s₁ x y) : LiftRel r₂ s₂ x y := by cases h;
   exacts [lift_rel.inl (hr _ _ ‹_›), lift_rel.inr (hs _ _ ‹_›)]
 #align sum.lift_rel.mono Sum.LiftRel.mono
+-/
 
+#print Sum.LiftRel.mono_left /-
 theorem LiftRel.mono_left (hr : ∀ a b, r₁ a b → r₂ a b) (h : LiftRel r₁ s x y) : LiftRel r₂ s x y :=
   h.mono hr fun _ _ => id
 #align sum.lift_rel.mono_left Sum.LiftRel.mono_left
+-/
 
+#print Sum.LiftRel.mono_right /-
 theorem LiftRel.mono_right (hs : ∀ a b, s₁ a b → s₂ a b) (h : LiftRel r s₁ x y) :
     LiftRel r s₂ x y :=
   h.mono (fun _ _ => id) hs
 #align sum.lift_rel.mono_right Sum.LiftRel.mono_right
+-/
 
+#print Sum.LiftRel.swap /-
 protected theorem LiftRel.swap (h : LiftRel r s x y) : LiftRel s r x.symm y.symm := by cases h;
   exacts [lift_rel.inr ‹_›, lift_rel.inl ‹_›]
 #align sum.lift_rel.swap Sum.LiftRel.swap
+-/
 
+#print Sum.liftRel_swap_iff /-
 @[simp]
 theorem liftRel_swap_iff : LiftRel s r x.symm y.symm ↔ LiftRel r s x y :=
   ⟨fun h => by rw [← swap_swap x, ← swap_swap y]; exact h.swap, LiftRel.swap⟩
 #align sum.lift_rel_swap_iff Sum.liftRel_swap_iff
+-/
 
 end LiftRel
 
@@ -640,6 +712,7 @@ open Sum
 
 namespace Function
 
+#print Function.Injective.sum_elim /-
 theorem Injective.sum_elim {f : α → γ} {g : β → γ} (hf : Injective f) (hg : Injective g)
     (hfg : ∀ a b, f a ≠ g b) : Injective (Sum.elim f g)
   | inl x, inl y, h => congr_arg inl <| hf h
@@ -647,6 +720,7 @@ theorem Injective.sum_elim {f : α → γ} {g : β → γ} (hf : Injective f) (h
   | inr x, inl y, h => (hfg y x h.symm).elim
   | inr x, inr y, h => congr_arg inr <| hg h
 #align function.injective.sum_elim Function.Injective.sum_elim
+-/
 
 #print Function.Injective.sum_map /-
 theorem Injective.sum_map {f : α → β} {g : α' → β'} (hf : Injective f) (hg : Injective g) :
@@ -681,6 +755,7 @@ namespace Sum
 
 open Function
 
+#print Sum.map_injective /-
 @[simp]
 theorem map_injective {f : α → γ} {g : β → δ} :
     Injective (Sum.map f g) ↔ Injective f ∧ Injective g :=
@@ -689,7 +764,9 @@ theorem map_injective {f : α → γ} {g : β → δ} :
       inr_injective <| @h (inr b₁) (inr b₂) (congr_arg inr hb : _)⟩,
     fun h => h.1.sum_map h.2⟩
 #align sum.map_injective Sum.map_injective
+-/
 
+#print Sum.map_surjective /-
 @[simp]
 theorem map_surjective {f : α → γ} {g : β → δ} :
     Surjective (Sum.map f g) ↔ Surjective f ∧ Surjective g :=
@@ -703,23 +780,31 @@ theorem map_surjective {f : α → γ} {g : β → δ} :
       · exact ⟨b, inr_injective h⟩⟩,
     fun h => h.1.sum_map h.2⟩
 #align sum.map_surjective Sum.map_surjective
+-/
 
+#print Sum.map_bijective /-
 @[simp]
 theorem map_bijective {f : α → γ} {g : β → δ} :
     Bijective (Sum.map f g) ↔ Bijective f ∧ Bijective g :=
   (map_injective.And map_surjective).trans <| and_and_and_comm _ _ _ _
 #align sum.map_bijective Sum.map_bijective
+-/
 
+#print Sum.elim_const_const /-
 theorem elim_const_const (c : γ) : Sum.elim (const _ c : α → γ) (const _ c : β → γ) = const _ c :=
   by ext x; cases x <;> rfl
 #align sum.elim_const_const Sum.elim_const_const
+-/
 
+#print Sum.elim_lam_const_lam_const /-
 @[simp]
 theorem elim_lam_const_lam_const (c : γ) :
     (Sum.elim (fun _ : α => c) fun _ : β => c) = fun _ => c :=
   Sum.elim_const_const c
 #align sum.elim_lam_const_lam_const Sum.elim_lam_const_lam_const
+-/
 
+#print Sum.elim_update_left /-
 theorem elim_update_left [DecidableEq α] [DecidableEq β] (f : α → γ) (g : β → γ) (i : α) (c : γ) :
     Sum.elim (Function.update f i c) g = Function.update (Sum.elim f g) (inl i) c :=
   by
@@ -729,7 +814,9 @@ theorem elim_update_left [DecidableEq α] [DecidableEq β] (f : α → γ) (g :
     · simp [h]
   · simp
 #align sum.elim_update_left Sum.elim_update_left
+-/
 
+#print Sum.elim_update_right /-
 theorem elim_update_right [DecidableEq α] [DecidableEq β] (f : α → γ) (g : β → γ) (i : β) (c : γ) :
     Sum.elim f (Function.update g i c) = Function.update (Sum.elim f g) (inr i) c :=
   by
@@ -739,6 +826,7 @@ theorem elim_update_right [DecidableEq α] [DecidableEq β] (f : α → γ) (g :
     · subst h; simp
     · simp [h]
 #align sum.elim_update_right Sum.elim_update_right
+-/
 
 end Sum
 
Diff
@@ -506,7 +506,7 @@ instance [∀ a c, Decidable (r a c)] [∀ b d, Decidable (s b d)] :
 
 theorem LiftRel.mono (hr : ∀ a b, r₁ a b → r₂ a b) (hs : ∀ a b, s₁ a b → s₂ a b)
     (h : LiftRel r₁ s₁ x y) : LiftRel r₂ s₂ x y := by cases h;
-  exacts[lift_rel.inl (hr _ _ ‹_›), lift_rel.inr (hs _ _ ‹_›)]
+  exacts [lift_rel.inl (hr _ _ ‹_›), lift_rel.inr (hs _ _ ‹_›)]
 #align sum.lift_rel.mono Sum.LiftRel.mono
 
 theorem LiftRel.mono_left (hr : ∀ a b, r₁ a b → r₂ a b) (h : LiftRel r₁ s x y) : LiftRel r₂ s x y :=
@@ -519,7 +519,7 @@ theorem LiftRel.mono_right (hs : ∀ a b, s₁ a b → s₂ a b) (h : LiftRel r
 #align sum.lift_rel.mono_right Sum.LiftRel.mono_right
 
 protected theorem LiftRel.swap (h : LiftRel r s x y) : LiftRel s r x.symm y.symm := by cases h;
-  exacts[lift_rel.inr ‹_›, lift_rel.inl ‹_›]
+  exacts [lift_rel.inr ‹_›, lift_rel.inl ‹_›]
 #align sum.lift_rel.swap Sum.LiftRel.swap
 
 @[simp]
@@ -577,7 +577,7 @@ instance [DecidableRel r] [DecidableRel s] : DecidableRel (Lex r s)
 
 #print Sum.LiftRel.lex /-
 protected theorem LiftRel.lex {a b : Sum α β} (h : LiftRel r s a b) : Lex r s a b := by cases h;
-  exacts[lex.inl ‹_›, lex.inr ‹_›]
+  exacts [lex.inl ‹_›, lex.inr ‹_›]
 #align sum.lift_rel.lex Sum.LiftRel.lex
 -/
 
@@ -588,7 +588,7 @@ theorem liftRel_subrelation_lex : Subrelation (LiftRel r s) (Lex r s) := fun a b
 
 #print Sum.Lex.mono /-
 theorem Lex.mono (hr : ∀ a b, r₁ a b → r₂ a b) (hs : ∀ a b, s₁ a b → s₂ a b) (h : Lex r₁ s₁ x y) :
-    Lex r₂ s₂ x y := by cases h; exacts[lex.inl (hr _ _ ‹_›), lex.inr (hs _ _ ‹_›), lex.sep _ _]
+    Lex r₂ s₂ x y := by cases h; exacts [lex.inl (hr _ _ ‹_›), lex.inr (hs _ _ ‹_›), lex.sep _ _]
 #align sum.lex.mono Sum.Lex.mono
 -/
 
Diff
@@ -168,12 +168,6 @@ theorem Not_isLeft : ¬x.isLeft ↔ x.isRight := by simp
 #align sum.not_is_left Sum.Not_isLeft
 -/
 
-/- warning: sum.bnot_is_right -> Sum.not_isRight is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} (x : Sum.{u1, u2} α β), Eq.{1} Bool (not (Sum.isRight.{u1, u2} α β x)) (Sum.isLeft.{u1, u2} α β x)
-but is expected to have type
-  forall {α : Type.{u1}} {β : Type.{u2}} (x : Sum.{u1, u2} α β), Eq.{1} Bool (not (Decidable.decide (Eq.{1} Bool (Sum.isRight.{u1, u2} α β x) (Sum.isLeft.{u1, u2} α β x)) (instDecidableEqBool (Sum.isRight.{u1, u2} α β x) (Sum.isLeft.{u1, u2} α β x)))) Bool.true
-Case conversion may be inaccurate. Consider using '#align sum.bnot_is_right Sum.not_isRightₓ'. -/
 @[simp]
 theorem not_isRight (x : Sum α β) : not x.isRight = x.isLeft := by cases x <;> rfl
 #align sum.bnot_is_right Sum.not_isRight
@@ -232,78 +226,36 @@ protected def elim {α β γ : Sort _} (f : α → γ) (g : β → γ) : Sum α
 #align sum.elim Sum.elim
 -/
 
-/- warning: sum.elim_inl -> Sum.elim_inl is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Sort.{u3}} (f : α -> γ) (g : β -> γ) (x : α), Eq.{u3} γ (Sum.elim.{u1, u2, u3} α β γ f g (Sum.inl.{u1, u2} α β x)) (f x)
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Sort.{u1}} (f : α -> γ) (g : β -> γ) (x : α), Eq.{u1} γ (Sum.elim.{u3, u2, u1} α β γ f g (Sum.inl.{u3, u2} α β x)) (f x)
-Case conversion may be inaccurate. Consider using '#align sum.elim_inl Sum.elim_inlₓ'. -/
 @[simp]
 theorem elim_inl {α β γ : Sort _} (f : α → γ) (g : β → γ) (x : α) : Sum.elim f g (inl x) = f x :=
   rfl
 #align sum.elim_inl Sum.elim_inl
 
-/- warning: sum.elim_inr -> Sum.elim_inr is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Sort.{u3}} (f : α -> γ) (g : β -> γ) (x : β), Eq.{u3} γ (Sum.elim.{u1, u2, u3} α β γ f g (Sum.inr.{u1, u2} α β x)) (g x)
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Sort.{u1}} (f : α -> γ) (g : β -> γ) (x : β), Eq.{u1} γ (Sum.elim.{u3, u2, u1} α β γ f g (Sum.inr.{u3, u2} α β x)) (g x)
-Case conversion may be inaccurate. Consider using '#align sum.elim_inr Sum.elim_inrₓ'. -/
 @[simp]
 theorem elim_inr {α β γ : Sort _} (f : α → γ) (g : β → γ) (x : β) : Sum.elim f g (inr x) = g x :=
   rfl
 #align sum.elim_inr Sum.elim_inr
 
-/- warning: sum.elim_comp_inl -> Sum.elim_comp_inl is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Sort.{u3}} (f : α -> γ) (g : β -> γ), Eq.{imax (succ u1) u3} (α -> γ) (Function.comp.{succ u1, max (succ u1) (succ u2), u3} α (Sum.{u1, u2} α β) γ (Sum.elim.{u1, u2, u3} α β γ f g) (Sum.inl.{u1, u2} α β)) f
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Sort.{u1}} (f : α -> γ) (g : β -> γ), Eq.{imax (succ u3) u1} (α -> γ) (Function.comp.{succ u3, max (succ u2) (succ u3), u1} α (Sum.{u3, u2} α β) γ (Sum.elim.{u3, u2, u1} α β γ f g) (Sum.inl.{u3, u2} α β)) f
-Case conversion may be inaccurate. Consider using '#align sum.elim_comp_inl Sum.elim_comp_inlₓ'. -/
 @[simp]
 theorem elim_comp_inl {α β γ : Sort _} (f : α → γ) (g : β → γ) : Sum.elim f g ∘ inl = f :=
   rfl
 #align sum.elim_comp_inl Sum.elim_comp_inl
 
-/- warning: sum.elim_comp_inr -> Sum.elim_comp_inr is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Sort.{u3}} (f : α -> γ) (g : β -> γ), Eq.{imax (succ u2) u3} (β -> γ) (Function.comp.{succ u2, max (succ u1) (succ u2), u3} β (Sum.{u1, u2} α β) γ (Sum.elim.{u1, u2, u3} α β γ f g) (Sum.inr.{u1, u2} α β)) g
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Sort.{u1}} (f : α -> γ) (g : β -> γ), Eq.{imax (succ u2) u1} (β -> γ) (Function.comp.{succ u2, max (succ u2) (succ u3), u1} β (Sum.{u3, u2} α β) γ (Sum.elim.{u3, u2, u1} α β γ f g) (Sum.inr.{u3, u2} α β)) g
-Case conversion may be inaccurate. Consider using '#align sum.elim_comp_inr Sum.elim_comp_inrₓ'. -/
 @[simp]
 theorem elim_comp_inr {α β γ : Sort _} (f : α → γ) (g : β → γ) : Sum.elim f g ∘ inr = g :=
   rfl
 #align sum.elim_comp_inr Sum.elim_comp_inr
 
-/- warning: sum.elim_inl_inr -> Sum.elim_inl_inr is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}}, Eq.{max (succ u1) (succ u2)} ((Sum.{u1, u2} α β) -> (Sum.{u1, u2} α β)) (Sum.elim.{u1, u2, max (succ u1) (succ u2)} α β (Sum.{u1, u2} α β) (Sum.inl.{u1, u2} α β) (Sum.inr.{u1, u2} α β)) (id.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u1}}, Eq.{max (succ u1) (succ u2)} ((Sum.{u2, u1} α β) -> (Sum.{u2, u1} α β)) (Sum.elim.{u2, u1, max (succ u2) (succ u1)} α β (Sum.{u2, u1} α β) (Sum.inl.{u2, u1} α β) (Sum.inr.{u2, u1} α β)) (id.{max (succ u1) (succ u2)} (Sum.{u2, u1} α β))
-Case conversion may be inaccurate. Consider using '#align sum.elim_inl_inr Sum.elim_inl_inrₓ'. -/
 @[simp]
 theorem elim_inl_inr {α β : Sort _} : @Sum.elim α β _ inl inr = id :=
   funext fun x => Sum.casesOn x (fun _ => rfl) fun _ => rfl
 #align sum.elim_inl_inr Sum.elim_inl_inr
 
-/- warning: sum.comp_elim -> Sum.comp_elim is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Sort.{u3}} {δ : Sort.{u4}} (f : γ -> δ) (g : α -> γ) (h : β -> γ), Eq.{imax (max (succ u1) (succ u2)) u4} ((Sum.{u1, u2} α β) -> δ) (Function.comp.{max (succ u1) (succ u2), u3, u4} (Sum.{u1, u2} α β) γ δ f (Sum.elim.{u1, u2, u3} α β γ g h)) (Sum.elim.{u1, u2, u4} α β δ (Function.comp.{succ u1, u3, u4} α γ δ f g) (Function.comp.{succ u2, u3, u4} β γ δ f h))
-but is expected to have type
-  forall {α : Type.{u4}} {β : Type.{u3}} {γ : Sort.{u2}} {δ : Sort.{u1}} (f : γ -> δ) (g : α -> γ) (h : β -> γ), Eq.{imax (max (succ u3) (succ u4)) u1} ((Sum.{u4, u3} α β) -> δ) (Function.comp.{max (succ u3) (succ u4), u2, u1} (Sum.{u4, u3} α β) γ δ f (Sum.elim.{u4, u3, u2} α β γ g h)) (Sum.elim.{u4, u3, u1} α β δ (Function.comp.{succ u4, u2, u1} α γ δ f g) (Function.comp.{succ u3, u2, u1} β γ δ f h))
-Case conversion may be inaccurate. Consider using '#align sum.comp_elim Sum.comp_elimₓ'. -/
 theorem comp_elim {α β γ δ : Sort _} (f : γ → δ) (g : α → γ) (h : β → γ) :
     f ∘ Sum.elim g h = Sum.elim (f ∘ g) (f ∘ h) :=
   funext fun x => Sum.casesOn x (fun _ => rfl) fun _ => rfl
 #align sum.comp_elim Sum.comp_elim
 
-/- warning: sum.elim_comp_inl_inr -> Sum.elim_comp_inl_inr is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Sort.{u3}} (f : (Sum.{u1, u2} α β) -> γ), Eq.{imax (max (succ u1) (succ u2)) u3} ((Sum.{u1, u2} α β) -> γ) (Sum.elim.{u1, u2, u3} α β γ (Function.comp.{succ u1, max (succ u1) (succ u2), u3} α (Sum.{u1, u2} α β) γ f (Sum.inl.{u1, u2} α β)) (Function.comp.{succ u2, max (succ u1) (succ u2), u3} β (Sum.{u1, u2} α β) γ f (Sum.inr.{u1, u2} α β))) f
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u2}} {γ : Sort.{u1}} (f : (Sum.{u3, u2} α β) -> γ), Eq.{imax (max (succ u2) (succ u3)) u1} ((Sum.{u3, u2} α β) -> γ) (Sum.elim.{u3, u2, u1} α β γ (Function.comp.{succ u3, max (succ u2) (succ u3), u1} α (Sum.{u3, u2} α β) γ f (Sum.inl.{u3, u2} α β)) (Function.comp.{succ u2, max (succ u2) (succ u3), u1} β (Sum.{u3, u2} α β) γ f (Sum.inr.{u3, u2} α β))) f
-Case conversion may be inaccurate. Consider using '#align sum.elim_comp_inl_inr Sum.elim_comp_inl_inrₓ'. -/
 @[simp]
 theorem elim_comp_inl_inr {α β γ : Sort _} (f : Sum α β → γ) : Sum.elim (f ∘ inl) (f ∘ inr) = f :=
   funext fun x => Sum.casesOn x (fun _ => rfl) fun _ => rfl
@@ -330,12 +282,6 @@ theorem map_inr (f : α → α') (g : β → β') (x : β) : (inr x).map f g = i
 #align sum.map_inr Sum.map_inr
 -/
 
-/- warning: sum.map_map -> Sum.map_map is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {α' : Type.{u3}} {β : Type.{u2}} {β' : Type.{u4}} {α'' : Type.{u5}} {β'' : Type.{u6}} (f' : α' -> α'') (g' : β' -> β'') (f : α -> α') (g : β -> β') (x : Sum.{u1, u2} α β), Eq.{max (succ u5) (succ u6)} (Sum.{u5, u6} α'' β'') (Sum.map.{u3, u4, u5, u6} α' α'' β' β'' f' g' (Sum.map.{u1, u2, u3, u4} α α' β β' f g x)) (Sum.map.{u1, u2, u5, u6} α α'' β β'' (Function.comp.{succ u1, succ u3, succ u5} α α' α'' f' f) (Function.comp.{succ u2, succ u4, succ u6} β β' β'' g' g) x)
-but is expected to have type
-  forall {α : Type.{u3}} {α' : Type.{u5}} {β : Type.{u4}} {β' : Type.{u6}} {α'' : Type.{u2}} {β'' : Type.{u1}} (f' : α' -> α'') (g' : β' -> β'') (f : α -> α') (g : β -> β') (x : Sum.{u3, u4} α β), Eq.{max (succ u1) (succ u2)} (Sum.{u2, u1} α'' β'') (Sum.map.{u5, u6, u2, u1} α' α'' β' β'' f' g' (Sum.map.{u3, u4, u5, u6} α α' β β' f g x)) (Sum.map.{u3, u4, u2, u1} α α'' β β'' (Function.comp.{succ u3, succ u5, succ u2} α α' α'' f' f) (Function.comp.{succ u4, succ u6, succ u1} β β' β'' g' g) x)
-Case conversion may be inaccurate. Consider using '#align sum.map_map Sum.map_mapₓ'. -/
 @[simp]
 theorem map_map {α'' β''} (f' : α' → α'') (g' : β' → β'') (f : α → α') (g : β → β') :
     ∀ x : Sum α β, (x.map f g).map f' g' = x.map (f' ∘ f) (g' ∘ g)
@@ -343,89 +289,41 @@ theorem map_map {α'' β''} (f' : α' → α'') (g' : β' → β'') (f : α →
   | inr b => rfl
 #align sum.map_map Sum.map_map
 
-/- warning: sum.map_comp_map -> Sum.map_comp_map is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {α' : Type.{u3}} {β : Type.{u2}} {β' : Type.{u4}} {α'' : Type.{u5}} {β'' : Type.{u6}} (f' : α' -> α'') (g' : β' -> β'') (f : α -> α') (g : β -> β'), Eq.{max (max (succ u1) (succ u2)) (succ u5) (succ u6)} ((Sum.{u1, u2} α β) -> (Sum.{u5, u6} α'' β'')) (Function.comp.{max (succ u1) (succ u2), max (succ u3) (succ u4), max (succ u5) (succ u6)} (Sum.{u1, u2} α β) (Sum.{u3, u4} α' β') (Sum.{u5, u6} α'' β'') (Sum.map.{u3, u4, u5, u6} α' α'' β' β'' f' g') (Sum.map.{u1, u2, u3, u4} α α' β β' f g)) (Sum.map.{u1, u2, u5, u6} α α'' β β'' (Function.comp.{succ u1, succ u3, succ u5} α α' α'' f' f) (Function.comp.{succ u2, succ u4, succ u6} β β' β'' g' g))
-but is expected to have type
-  forall {α : Type.{u3}} {α' : Type.{u5}} {β : Type.{u4}} {β' : Type.{u6}} {α'' : Type.{u2}} {β'' : Type.{u1}} (f' : α' -> α'') (g' : β' -> β'') (f : α -> α') (g : β -> β'), Eq.{max (max (max (succ u3) (succ u4)) (succ u1)) (succ u2)} ((Sum.{u3, u4} α β) -> (Sum.{u2, u1} α'' β'')) (Function.comp.{max (succ u4) (succ u3), max (succ u6) (succ u5), max (succ u1) (succ u2)} (Sum.{u3, u4} α β) (Sum.{u5, u6} α' β') (Sum.{u2, u1} α'' β'') (Sum.map.{u5, u6, u2, u1} α' α'' β' β'' f' g') (Sum.map.{u3, u4, u5, u6} α α' β β' f g)) (Sum.map.{u3, u4, u2, u1} α α'' β β'' (Function.comp.{succ u3, succ u5, succ u2} α α' α'' f' f) (Function.comp.{succ u4, succ u6, succ u1} β β' β'' g' g))
-Case conversion may be inaccurate. Consider using '#align sum.map_comp_map Sum.map_comp_mapₓ'. -/
 @[simp]
 theorem map_comp_map {α'' β''} (f' : α' → α'') (g' : β' → β'') (f : α → α') (g : β → β') :
     Sum.map f' g' ∘ Sum.map f g = Sum.map (f' ∘ f) (g' ∘ g) :=
   funext <| map_map f' g' f g
 #align sum.map_comp_map Sum.map_comp_map
 
-/- warning: sum.map_id_id -> Sum.map_id_id is a dubious translation:
-lean 3 declaration is
-  forall (α : Type.{u1}) (β : Type.{u2}), Eq.{max (succ u1) (succ u2)} ((Sum.{u1, u2} α β) -> (Sum.{u1, u2} α β)) (Sum.map.{u1, u2, u1, u2} α α β β (id.{succ u1} α) (id.{succ u2} β)) (id.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β))
-but is expected to have type
-  forall (α : Type.{u2}) (β : Type.{u1}), Eq.{max (succ u1) (succ u2)} ((Sum.{u2, u1} α β) -> (Sum.{u2, u1} α β)) (Sum.map.{u2, u1, u2, u1} α α β β (id.{succ u2} α) (id.{succ u1} β)) (id.{max (succ u1) (succ u2)} (Sum.{u2, u1} α β))
-Case conversion may be inaccurate. Consider using '#align sum.map_id_id Sum.map_id_idₓ'. -/
 @[simp]
 theorem map_id_id (α β) : Sum.map (@id α) (@id β) = id :=
   funext fun x => Sum.recOn x (fun _ => rfl) fun _ => rfl
 #align sum.map_id_id Sum.map_id_id
 
-/- warning: sum.elim_map -> Sum.elim_map is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {ε : Sort.{u5}} {f₁ : α -> β} {f₂ : β -> ε} {g₁ : γ -> δ} {g₂ : δ -> ε} {x : Sum.{u1, u3} α γ}, Eq.{u5} ε (Sum.elim.{u2, u4, u5} β δ ε f₂ g₂ (Sum.map.{u1, u3, u2, u4} α β γ δ f₁ g₁ x)) (Sum.elim.{u1, u3, u5} α γ ε (Function.comp.{succ u1, succ u2, u5} α β ε f₂ f₁) (Function.comp.{succ u3, succ u4, u5} γ δ ε g₂ g₁) x)
-but is expected to have type
-  forall {α : Type.{u5}} {β : Type.{u4}} {γ : Type.{u3}} {δ : Type.{u2}} {ε : Sort.{u1}} {f₁ : α -> β} {f₂ : β -> ε} {g₁ : γ -> δ} {g₂ : δ -> ε} {x : Sum.{u5, u3} α γ}, Eq.{u1} ε (Sum.elim.{u4, u2, u1} β δ ε f₂ g₂ (Sum.map.{u5, u3, u4, u2} α β γ δ f₁ g₁ x)) (Sum.elim.{u5, u3, u1} α γ ε (Function.comp.{succ u5, succ u4, u1} α β ε f₂ f₁) (Function.comp.{succ u3, succ u2, u1} γ δ ε g₂ g₁) x)
-Case conversion may be inaccurate. Consider using '#align sum.elim_map Sum.elim_mapₓ'. -/
 theorem elim_map {α β γ δ ε : Sort _} {f₁ : α → β} {f₂ : β → ε} {g₁ : γ → δ} {g₂ : δ → ε} {x} :
     Sum.elim f₂ g₂ (Sum.map f₁ g₁ x) = Sum.elim (f₂ ∘ f₁) (g₂ ∘ g₁) x := by cases x <;> rfl
 #align sum.elim_map Sum.elim_map
 
-/- warning: sum.elim_comp_map -> Sum.elim_comp_map is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {ε : Sort.{u5}} {f₁ : α -> β} {f₂ : β -> ε} {g₁ : γ -> δ} {g₂ : δ -> ε}, Eq.{imax (max (succ u1) (succ u3)) u5} ((Sum.{u1, u3} α γ) -> ε) (Function.comp.{max (succ u1) (succ u3), max (succ u2) (succ u4), u5} (Sum.{u1, u3} α γ) (Sum.{u2, u4} β δ) ε (Sum.elim.{u2, u4, u5} β δ ε f₂ g₂) (Sum.map.{u1, u3, u2, u4} α β γ δ f₁ g₁)) (Sum.elim.{u1, u3, u5} α γ ε (Function.comp.{succ u1, succ u2, u5} α β ε f₂ f₁) (Function.comp.{succ u3, succ u4, u5} γ δ ε g₂ g₁))
-but is expected to have type
-  forall {α : Type.{u5}} {β : Type.{u4}} {γ : Type.{u3}} {δ : Type.{u2}} {ε : Sort.{u1}} {f₁ : α -> β} {f₂ : β -> ε} {g₁ : γ -> δ} {g₂ : δ -> ε}, Eq.{imax (max (succ u3) (succ u5)) u1} ((Sum.{u5, u3} α γ) -> ε) (Function.comp.{max (succ u3) (succ u5), max (succ u2) (succ u4), u1} (Sum.{u5, u3} α γ) (Sum.{u4, u2} β δ) ε (Sum.elim.{u4, u2, u1} β δ ε f₂ g₂) (Sum.map.{u5, u3, u4, u2} α β γ δ f₁ g₁)) (Sum.elim.{u5, u3, u1} α γ ε (Function.comp.{succ u5, succ u4, u1} α β ε f₂ f₁) (Function.comp.{succ u3, succ u2, u1} γ δ ε g₂ g₁))
-Case conversion may be inaccurate. Consider using '#align sum.elim_comp_map Sum.elim_comp_mapₓ'. -/
 theorem elim_comp_map {α β γ δ ε : Sort _} {f₁ : α → β} {f₂ : β → ε} {g₁ : γ → δ} {g₂ : δ → ε} :
     Sum.elim f₂ g₂ ∘ Sum.map f₁ g₁ = Sum.elim (f₂ ∘ f₁) (g₂ ∘ g₁) :=
   funext fun _ => elim_map
 #align sum.elim_comp_map Sum.elim_comp_map
 
-/- warning: sum.is_left_map -> Sum.isLeft_map is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} (f : α -> β) (g : γ -> δ) (x : Sum.{u1, u3} α γ), Eq.{1} Bool (Sum.isLeft.{u2, u4} β δ (Sum.map.{u1, u3, u2, u4} α β γ δ f g x)) (Sum.isLeft.{u1, u3} α γ x)
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} (f : α -> β) (g : γ -> δ) (x : Sum.{u3, u2} α γ), Eq.{1} Bool (Sum.isLeft.{u4, u1} β δ (Sum.map.{u3, u2, u4, u1} α β γ δ f g x)) (Sum.isLeft.{u3, u2} α γ x)
-Case conversion may be inaccurate. Consider using '#align sum.is_left_map Sum.isLeft_mapₓ'. -/
 @[simp]
 theorem isLeft_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isLeft (x.map f g) = isLeft x := by
   cases x <;> rfl
 #align sum.is_left_map Sum.isLeft_map
 
-/- warning: sum.is_right_map -> Sum.isRight_map is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} (f : α -> β) (g : γ -> δ) (x : Sum.{u1, u3} α γ), Eq.{1} Bool (Sum.isRight.{u2, u4} β δ (Sum.map.{u1, u3, u2, u4} α β γ δ f g x)) (Sum.isRight.{u1, u3} α γ x)
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} (f : α -> β) (g : γ -> δ) (x : Sum.{u3, u2} α γ), Eq.{1} Bool (Sum.isRight.{u4, u1} β δ (Sum.map.{u3, u2, u4, u1} α β γ δ f g x)) (Sum.isRight.{u3, u2} α γ x)
-Case conversion may be inaccurate. Consider using '#align sum.is_right_map Sum.isRight_mapₓ'. -/
 @[simp]
 theorem isRight_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isRight (x.map f g) = isRight x := by
   cases x <;> rfl
 #align sum.is_right_map Sum.isRight_map
 
-/- warning: sum.get_left_map -> Sum.getLeft_map is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} (f : α -> β) (g : γ -> δ) (x : Sum.{u1, u3} α γ), Eq.{succ u2} (Option.{u2} β) (Sum.getLeft.{u2, u4} β δ (Sum.map.{u1, u3, u2, u4} α β γ δ f g x)) (Option.map.{u1, u2} α β f (Sum.getLeft.{u1, u3} α γ x))
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} (f : α -> β) (g : γ -> δ) (x : Sum.{u3, u2} α γ), Eq.{succ u4} (Option.{u4} β) (Sum.getLeft.{u4, u1} β δ (Sum.map.{u3, u2, u4, u1} α β γ δ f g x)) (Option.map.{u3, u4} α β f (Sum.getLeft.{u3, u2} α γ x))
-Case conversion may be inaccurate. Consider using '#align sum.get_left_map Sum.getLeft_mapₓ'. -/
 @[simp]
 theorem getLeft_map (f : α → β) (g : γ → δ) (x : Sum α γ) : (x.map f g).getLeft = x.getLeft.map f :=
   by cases x <;> rfl
 #align sum.get_left_map Sum.getLeft_map
 
-/- warning: sum.get_right_map -> Sum.getRight_map is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} (f : α -> β) (g : γ -> δ) (x : Sum.{u1, u3} α γ), Eq.{succ u4} (Option.{u4} δ) (Sum.getRight.{u2, u4} β δ (Sum.map.{u1, u3, u2, u4} α β γ δ f g x)) (Option.map.{u3, u4} γ δ g (Sum.getRight.{u1, u3} α γ x))
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} (f : α -> β) (g : γ -> δ) (x : Sum.{u3, u2} α γ), Eq.{succ u1} (Option.{u1} δ) (Sum.getRight.{u4, u1} β δ (Sum.map.{u3, u2, u4, u1} α β γ δ f g x)) (Option.map.{u2, u1} γ δ g (Sum.getRight.{u3, u2} α γ x))
-Case conversion may be inaccurate. Consider using '#align sum.get_right_map Sum.getRight_mapₓ'. -/
 @[simp]
 theorem getRight_map (f : α → β) (g : γ → δ) (x : Sum α γ) :
     (x.map f g).getRight = x.getRight.map g := by cases x <;> rfl
@@ -433,119 +331,59 @@ theorem getRight_map (f : α → β) (g : γ → δ) (x : Sum α γ) :
 
 open Function (update update_eq_iff update_comp_eq_of_injective update_comp_eq_of_forall_ne)
 
-/- warning: sum.update_elim_inl -> Sum.update_elim_inl is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)] {f : α -> γ} {g : β -> γ} {i : α} {x : γ}, Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((Sum.{u1, u2} α β) -> γ) (Function.update.{max (succ u1) (succ u2), succ u3} (Sum.{u1, u2} α β) (fun (ᾰ : Sum.{u1, u2} α β) => γ) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => _inst_2 a b) (Sum.elim.{u1, u2, succ u3} α β γ f g) (Sum.inl.{u1, u2} α β i) x) (Sum.elim.{u1, u2, succ u3} α β γ (Function.update.{succ u1, succ u3} α (fun (ᾰ : α) => γ) (fun (a : α) (b : α) => _inst_1 a b) f i x) g)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{max (succ u3) (succ u2)} (Sum.{u2, u3} α β)] {f : α -> γ} {g : β -> γ} {i : α} {x : γ}, Eq.{max (max (succ u2) (succ u3)) (succ u1)} ((Sum.{u2, u3} α β) -> γ) (Function.update.{max (succ u3) (succ u2), succ u1} (Sum.{u2, u3} α β) (fun (ᾰ : Sum.{u2, u3} α β) => γ) (fun (a : Sum.{u2, u3} α β) (b : Sum.{u2, u3} α β) => _inst_2 a b) (Sum.elim.{u2, u3, succ u1} α β γ f g) (Sum.inl.{u2, u3} α β i) x) (Sum.elim.{u2, u3, succ u1} α β γ (Function.update.{succ u2, succ u1} α (fun (ᾰ : α) => γ) (fun (a : α) (b : α) => _inst_1 a b) f i x) g)
-Case conversion may be inaccurate. Consider using '#align sum.update_elim_inl Sum.update_elim_inlₓ'. -/
 @[simp]
 theorem update_elim_inl [DecidableEq α] [DecidableEq (Sum α β)] {f : α → γ} {g : β → γ} {i : α}
     {x : γ} : update (Sum.elim f g) (inl i) x = Sum.elim (update f i x) g :=
   update_eq_iff.2 ⟨by simp, by simp (config := { contextual := true })⟩
 #align sum.update_elim_inl Sum.update_elim_inl
 
-/- warning: sum.update_elim_inr -> Sum.update_elim_inr is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{succ u2} β] [_inst_2 : DecidableEq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)] {f : α -> γ} {g : β -> γ} {i : β} {x : γ}, Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((Sum.{u1, u2} α β) -> γ) (Function.update.{max (succ u1) (succ u2), succ u3} (Sum.{u1, u2} α β) (fun (ᾰ : Sum.{u1, u2} α β) => γ) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => _inst_2 a b) (Sum.elim.{u1, u2, succ u3} α β γ f g) (Sum.inr.{u1, u2} α β i) x) (Sum.elim.{u1, u2, succ u3} α β γ f (Function.update.{succ u2, succ u3} β (fun (ᾰ : β) => γ) (fun (a : β) (b : β) => _inst_1 a b) g i x))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{succ u3} β] [_inst_2 : DecidableEq.{max (succ u3) (succ u2)} (Sum.{u2, u3} α β)] {f : α -> γ} {g : β -> γ} {i : β} {x : γ}, Eq.{max (max (succ u2) (succ u3)) (succ u1)} ((Sum.{u2, u3} α β) -> γ) (Function.update.{max (succ u3) (succ u2), succ u1} (Sum.{u2, u3} α β) (fun (ᾰ : Sum.{u2, u3} α β) => γ) (fun (a : Sum.{u2, u3} α β) (b : Sum.{u2, u3} α β) => _inst_2 a b) (Sum.elim.{u2, u3, succ u1} α β γ f g) (Sum.inr.{u2, u3} α β i) x) (Sum.elim.{u2, u3, succ u1} α β γ f (Function.update.{succ u3, succ u1} β (fun (ᾰ : β) => γ) (fun (a : β) (b : β) => _inst_1 a b) g i x))
-Case conversion may be inaccurate. Consider using '#align sum.update_elim_inr Sum.update_elim_inrₓ'. -/
 @[simp]
 theorem update_elim_inr [DecidableEq β] [DecidableEq (Sum α β)] {f : α → γ} {g : β → γ} {i : β}
     {x : γ} : update (Sum.elim f g) (inr i) x = Sum.elim f (update g i x) :=
   update_eq_iff.2 ⟨by simp, by simp (config := { contextual := true })⟩
 #align sum.update_elim_inr Sum.update_elim_inr
 
-/- warning: sum.update_inl_comp_inl -> Sum.update_inl_comp_inl is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)] {f : (Sum.{u1, u2} α β) -> γ} {i : α} {x : γ}, Eq.{max (succ u1) (succ u3)} (α -> γ) (Function.comp.{succ u1, max (succ u1) (succ u2), succ u3} α (Sum.{u1, u2} α β) γ (Function.update.{max (succ u1) (succ u2), succ u3} (Sum.{u1, u2} α β) (fun (ᾰ : Sum.{u1, u2} α β) => γ) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => _inst_2 a b) f (Sum.inl.{u1, u2} α β i) x) (Sum.inl.{u1, u2} α β)) (Function.update.{succ u1, succ u3} α (fun (ᾰ : α) => γ) (fun (a : α) (b : α) => _inst_1 a b) (Function.comp.{succ u1, max (succ u1) (succ u2), succ u3} α (Sum.{u1, u2} α β) γ f (Sum.inl.{u1, u2} α β)) i x)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{max (succ u3) (succ u2)} (Sum.{u2, u3} α β)] {f : (Sum.{u2, u3} α β) -> γ} {i : α} {x : γ}, Eq.{max (succ u2) (succ u1)} (α -> γ) (Function.comp.{succ u2, max (succ u2) (succ u3), succ u1} α (Sum.{u2, u3} α β) γ (Function.update.{max (succ u2) (succ u3), succ u1} (Sum.{u2, u3} α β) (fun (ᾰ : Sum.{u2, u3} α β) => γ) (fun (a : Sum.{u2, u3} α β) (b : Sum.{u2, u3} α β) => _inst_2 a b) f (Sum.inl.{u2, u3} α β i) x) (Sum.inl.{u2, u3} α β)) (Function.update.{succ u2, succ u1} α (fun (ᾰ : α) => γ) (fun (a : α) (b : α) => _inst_1 a b) (Function.comp.{succ u2, max (succ u2) (succ u3), succ u1} α (Sum.{u2, u3} α β) γ f (Sum.inl.{u2, u3} α β)) i x)
-Case conversion may be inaccurate. Consider using '#align sum.update_inl_comp_inl Sum.update_inl_comp_inlₓ'. -/
 @[simp]
 theorem update_inl_comp_inl [DecidableEq α] [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : α}
     {x : γ} : update f (inl i) x ∘ inl = update (f ∘ inl) i x :=
   update_comp_eq_of_injective _ inl_injective _ _
 #align sum.update_inl_comp_inl Sum.update_inl_comp_inl
 
-/- warning: sum.update_inl_apply_inl -> Sum.update_inl_apply_inl is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)] {f : (Sum.{u1, u2} α β) -> γ} {i : α} {j : α} {x : γ}, Eq.{succ u3} γ (Function.update.{max (succ u1) (succ u2), succ u3} (Sum.{u1, u2} α β) (fun (ᾰ : Sum.{u1, u2} α β) => γ) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => _inst_2 a b) f (Sum.inl.{u1, u2} α β i) x (Sum.inl.{u1, u2} α β j)) (Function.update.{succ u1, succ u3} α (fun (ᾰ : α) => γ) (fun (a : α) (b : α) => _inst_1 a b) (Function.comp.{succ u1, max (succ u1) (succ u2), succ u3} α (Sum.{u1, u2} α β) γ f (Sum.inl.{u1, u2} α β)) i x j)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{max (succ u3) (succ u2)} (Sum.{u2, u3} α β)] {f : (Sum.{u2, u3} α β) -> γ} {i : α} {j : α} {x : γ}, Eq.{succ u1} γ (Function.update.{max (succ u2) (succ u3), succ u1} (Sum.{u2, u3} α β) (fun (ᾰ : Sum.{u2, u3} α β) => γ) (fun (a : Sum.{u2, u3} α β) (b : Sum.{u2, u3} α β) => _inst_2 a b) f (Sum.inl.{u2, u3} α β i) x (Sum.inl.{u2, u3} α β j)) (Function.update.{succ u2, succ u1} α (fun (ᾰ : α) => γ) (fun (a : α) (b : α) => _inst_1 a b) (Function.comp.{succ u2, max (succ u2) (succ u3), succ u1} α (Sum.{u2, u3} α β) γ f (Sum.inl.{u2, u3} α β)) i x j)
-Case conversion may be inaccurate. Consider using '#align sum.update_inl_apply_inl Sum.update_inl_apply_inlₓ'. -/
 @[simp]
 theorem update_inl_apply_inl [DecidableEq α] [DecidableEq (Sum α β)] {f : Sum α β → γ} {i j : α}
     {x : γ} : update f (inl i) x (inl j) = update (f ∘ inl) i x j := by rw [← update_inl_comp_inl]
 #align sum.update_inl_apply_inl Sum.update_inl_apply_inl
 
-/- warning: sum.update_inl_comp_inr -> Sum.update_inl_comp_inr is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)] {f : (Sum.{u1, u2} α β) -> γ} {i : α} {x : γ}, Eq.{max (succ u2) (succ u3)} (β -> γ) (Function.comp.{succ u2, max (succ u1) (succ u2), succ u3} β (Sum.{u1, u2} α β) γ (Function.update.{max (succ u1) (succ u2), succ u3} (Sum.{u1, u2} α β) (fun (ᾰ : Sum.{u1, u2} α β) => γ) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => _inst_1 a b) f (Sum.inl.{u1, u2} α β i) x) (Sum.inr.{u1, u2} α β)) (Function.comp.{succ u2, max (succ u1) (succ u2), succ u3} β (Sum.{u1, u2} α β) γ f (Sum.inr.{u1, u2} α β))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{max (succ u3) (succ u2)} (Sum.{u2, u3} α β)] {f : (Sum.{u2, u3} α β) -> γ} {i : α} {x : γ}, Eq.{max (succ u3) (succ u1)} (β -> γ) (Function.comp.{succ u3, max (succ u2) (succ u3), succ u1} β (Sum.{u2, u3} α β) γ (Function.update.{max (succ u2) (succ u3), succ u1} (Sum.{u2, u3} α β) (fun (ᾰ : Sum.{u2, u3} α β) => γ) (fun (a : Sum.{u2, u3} α β) (b : Sum.{u2, u3} α β) => _inst_1 a b) f (Sum.inl.{u2, u3} α β i) x) (Sum.inr.{u2, u3} α β)) (Function.comp.{succ u3, max (succ u2) (succ u3), succ u1} β (Sum.{u2, u3} α β) γ f (Sum.inr.{u2, u3} α β))
-Case conversion may be inaccurate. Consider using '#align sum.update_inl_comp_inr Sum.update_inl_comp_inrₓ'. -/
 @[simp]
 theorem update_inl_comp_inr [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : α} {x : γ} :
     update f (inl i) x ∘ inr = f ∘ inr :=
   update_comp_eq_of_forall_ne _ _ fun _ => inr_ne_inl
 #align sum.update_inl_comp_inr Sum.update_inl_comp_inr
 
-/- warning: sum.update_inl_apply_inr -> Sum.update_inl_apply_inr is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)] {f : (Sum.{u1, u2} α β) -> γ} {i : α} {j : β} {x : γ}, Eq.{succ u3} γ (Function.update.{max (succ u1) (succ u2), succ u3} (Sum.{u1, u2} α β) (fun (ᾰ : Sum.{u1, u2} α β) => γ) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => _inst_1 a b) f (Sum.inl.{u1, u2} α β i) x (Sum.inr.{u1, u2} α β j)) (f (Sum.inr.{u1, u2} α β j))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{max (succ u3) (succ u2)} (Sum.{u2, u3} α β)] {f : (Sum.{u2, u3} α β) -> γ} {i : α} {j : β} {x : γ}, Eq.{succ u1} γ (Function.update.{max (succ u2) (succ u3), succ u1} (Sum.{u2, u3} α β) (fun (ᾰ : Sum.{u2, u3} α β) => γ) (fun (a : Sum.{u2, u3} α β) (b : Sum.{u2, u3} α β) => _inst_1 a b) f (Sum.inl.{u2, u3} α β i) x (Sum.inr.{u2, u3} α β j)) (f (Sum.inr.{u2, u3} α β j))
-Case conversion may be inaccurate. Consider using '#align sum.update_inl_apply_inr Sum.update_inl_apply_inrₓ'. -/
 @[simp]
 theorem update_inl_apply_inr [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : α} {j : β} {x : γ} :
     update f (inl i) x (inr j) = f (inr j) :=
   Function.update_noteq inr_ne_inl _ _
 #align sum.update_inl_apply_inr Sum.update_inl_apply_inr
 
-/- warning: sum.update_inr_comp_inl -> Sum.update_inr_comp_inl is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)] {f : (Sum.{u1, u2} α β) -> γ} {i : β} {x : γ}, Eq.{max (succ u1) (succ u3)} (α -> γ) (Function.comp.{succ u1, max (succ u1) (succ u2), succ u3} α (Sum.{u1, u2} α β) γ (Function.update.{max (succ u1) (succ u2), succ u3} (Sum.{u1, u2} α β) (fun (ᾰ : Sum.{u1, u2} α β) => γ) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => _inst_1 a b) f (Sum.inr.{u1, u2} α β i) x) (Sum.inl.{u1, u2} α β)) (Function.comp.{succ u1, max (succ u1) (succ u2), succ u3} α (Sum.{u1, u2} α β) γ f (Sum.inl.{u1, u2} α β))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{max (succ u3) (succ u2)} (Sum.{u2, u3} α β)] {f : (Sum.{u2, u3} α β) -> γ} {i : β} {x : γ}, Eq.{max (succ u2) (succ u1)} (α -> γ) (Function.comp.{succ u2, max (succ u2) (succ u3), succ u1} α (Sum.{u2, u3} α β) γ (Function.update.{max (succ u2) (succ u3), succ u1} (Sum.{u2, u3} α β) (fun (ᾰ : Sum.{u2, u3} α β) => γ) (fun (a : Sum.{u2, u3} α β) (b : Sum.{u2, u3} α β) => _inst_1 a b) f (Sum.inr.{u2, u3} α β i) x) (Sum.inl.{u2, u3} α β)) (Function.comp.{succ u2, max (succ u2) (succ u3), succ u1} α (Sum.{u2, u3} α β) γ f (Sum.inl.{u2, u3} α β))
-Case conversion may be inaccurate. Consider using '#align sum.update_inr_comp_inl Sum.update_inr_comp_inlₓ'. -/
 @[simp]
 theorem update_inr_comp_inl [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : β} {x : γ} :
     update f (inr i) x ∘ inl = f ∘ inl :=
   update_comp_eq_of_forall_ne _ _ fun _ => inl_ne_inr
 #align sum.update_inr_comp_inl Sum.update_inr_comp_inl
 
-/- warning: sum.update_inr_apply_inl -> Sum.update_inr_apply_inl is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)] {f : (Sum.{u1, u2} α β) -> γ} {i : α} {j : β} {x : γ}, Eq.{succ u3} γ (Function.update.{max (succ u1) (succ u2), succ u3} (Sum.{u1, u2} α β) (fun (ᾰ : Sum.{u1, u2} α β) => γ) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => _inst_1 a b) f (Sum.inr.{u1, u2} α β j) x (Sum.inl.{u1, u2} α β i)) (f (Sum.inl.{u1, u2} α β i))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{max (succ u3) (succ u2)} (Sum.{u2, u3} α β)] {f : (Sum.{u2, u3} α β) -> γ} {i : α} {j : β} {x : γ}, Eq.{succ u1} γ (Function.update.{max (succ u2) (succ u3), succ u1} (Sum.{u2, u3} α β) (fun (ᾰ : Sum.{u2, u3} α β) => γ) (fun (a : Sum.{u2, u3} α β) (b : Sum.{u2, u3} α β) => _inst_1 a b) f (Sum.inr.{u2, u3} α β j) x (Sum.inl.{u2, u3} α β i)) (f (Sum.inl.{u2, u3} α β i))
-Case conversion may be inaccurate. Consider using '#align sum.update_inr_apply_inl Sum.update_inr_apply_inlₓ'. -/
 @[simp]
 theorem update_inr_apply_inl [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : α} {j : β} {x : γ} :
     update f (inr j) x (inl i) = f (inl i) :=
   Function.update_noteq inl_ne_inr _ _
 #align sum.update_inr_apply_inl Sum.update_inr_apply_inl
 
-/- warning: sum.update_inr_comp_inr -> Sum.update_inr_comp_inr is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{succ u2} β] [_inst_2 : DecidableEq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)] {f : (Sum.{u1, u2} α β) -> γ} {i : β} {x : γ}, Eq.{max (succ u2) (succ u3)} (β -> γ) (Function.comp.{succ u2, max (succ u1) (succ u2), succ u3} β (Sum.{u1, u2} α β) γ (Function.update.{max (succ u1) (succ u2), succ u3} (Sum.{u1, u2} α β) (fun (ᾰ : Sum.{u1, u2} α β) => γ) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => _inst_2 a b) f (Sum.inr.{u1, u2} α β i) x) (Sum.inr.{u1, u2} α β)) (Function.update.{succ u2, succ u3} β (fun (ᾰ : β) => γ) (fun (a : β) (b : β) => _inst_1 a b) (Function.comp.{succ u2, max (succ u1) (succ u2), succ u3} β (Sum.{u1, u2} α β) γ f (Sum.inr.{u1, u2} α β)) i x)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{succ u3} β] [_inst_2 : DecidableEq.{max (succ u3) (succ u2)} (Sum.{u2, u3} α β)] {f : (Sum.{u2, u3} α β) -> γ} {i : β} {x : γ}, Eq.{max (succ u3) (succ u1)} (β -> γ) (Function.comp.{succ u3, max (succ u2) (succ u3), succ u1} β (Sum.{u2, u3} α β) γ (Function.update.{max (succ u2) (succ u3), succ u1} (Sum.{u2, u3} α β) (fun (ᾰ : Sum.{u2, u3} α β) => γ) (fun (a : Sum.{u2, u3} α β) (b : Sum.{u2, u3} α β) => _inst_2 a b) f (Sum.inr.{u2, u3} α β i) x) (Sum.inr.{u2, u3} α β)) (Function.update.{succ u3, succ u1} β (fun (ᾰ : β) => γ) (fun (a : β) (b : β) => _inst_1 a b) (Function.comp.{succ u3, max (succ u2) (succ u3), succ u1} β (Sum.{u2, u3} α β) γ f (Sum.inr.{u2, u3} α β)) i x)
-Case conversion may be inaccurate. Consider using '#align sum.update_inr_comp_inr Sum.update_inr_comp_inrₓ'. -/
 @[simp]
 theorem update_inr_comp_inr [DecidableEq β] [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : β}
     {x : γ} : update f (inr i) x ∘ inr = update (f ∘ inr) i x :=
   update_comp_eq_of_injective _ inr_injective _ _
 #align sum.update_inr_comp_inr Sum.update_inr_comp_inr
 
-/- warning: sum.update_inr_apply_inr -> Sum.update_inr_apply_inr is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{succ u2} β] [_inst_2 : DecidableEq.{max (succ u1) (succ u2)} (Sum.{u1, u2} α β)] {f : (Sum.{u1, u2} α β) -> γ} {i : β} {j : β} {x : γ}, Eq.{succ u3} γ (Function.update.{max (succ u1) (succ u2), succ u3} (Sum.{u1, u2} α β) (fun (ᾰ : Sum.{u1, u2} α β) => γ) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => _inst_2 a b) f (Sum.inr.{u1, u2} α β i) x (Sum.inr.{u1, u2} α β j)) (Function.update.{succ u2, succ u3} β (fun (ᾰ : β) => γ) (fun (a : β) (b : β) => _inst_1 a b) (Function.comp.{succ u2, max (succ u1) (succ u2), succ u3} β (Sum.{u1, u2} α β) γ f (Sum.inr.{u1, u2} α β)) i x j)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{succ u3} β] [_inst_2 : DecidableEq.{max (succ u3) (succ u2)} (Sum.{u2, u3} α β)] {f : (Sum.{u2, u3} α β) -> γ} {i : β} {j : β} {x : γ}, Eq.{succ u1} γ (Function.update.{max (succ u2) (succ u3), succ u1} (Sum.{u2, u3} α β) (fun (ᾰ : Sum.{u2, u3} α β) => γ) (fun (a : Sum.{u2, u3} α β) (b : Sum.{u2, u3} α β) => _inst_2 a b) f (Sum.inr.{u2, u3} α β i) x (Sum.inr.{u2, u3} α β j)) (Function.update.{succ u3, succ u1} β (fun (ᾰ : β) => γ) (fun (a : β) (b : β) => _inst_1 a b) (Function.comp.{succ u3, max (succ u2) (succ u3), succ u1} β (Sum.{u2, u3} α β) γ f (Sum.inr.{u2, u3} α β)) i x j)
-Case conversion may be inaccurate. Consider using '#align sum.update_inr_apply_inr Sum.update_inr_apply_inrₓ'. -/
 @[simp]
 theorem update_inr_apply_inr [DecidableEq β] [DecidableEq (Sum α β)] {f : Sum α β → γ} {i j : β}
     {x : γ} : update f (inr i) x (inr j) = update (f ∘ inr) i x j := by rw [← update_inr_comp_inr]
@@ -639,45 +477,21 @@ attribute [protected] lift_rel.inl lift_rel.inr
 variable {r r₁ r₂ : α → γ → Prop} {s s₁ s₂ : β → δ → Prop} {a : α} {b : β} {c : γ} {d : δ}
   {x : Sum α β} {y : Sum γ δ}
 
-/- warning: sum.lift_rel_inl_inl -> Sum.liftRel_inl_inl is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {r : α -> γ -> Prop} {s : β -> δ -> Prop} {a : α} {c : γ}, Iff (Sum.LiftRel.{u1, u2, u3, u4} α β γ δ r s (Sum.inl.{u1, u2} α β a) (Sum.inl.{u3, u4} γ δ c)) (r a c)
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} {r : α -> γ -> Prop} {s : β -> δ -> Prop} {a : α} {c : γ}, Iff (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r s (Sum.inl.{u3, u4} α β a) (Sum.inl.{u2, u1} γ δ c)) (r a c)
-Case conversion may be inaccurate. Consider using '#align sum.lift_rel_inl_inl Sum.liftRel_inl_inlₓ'. -/
 @[simp]
 theorem liftRel_inl_inl : LiftRel r s (inl a) (inl c) ↔ r a c :=
   ⟨fun h => by cases h; assumption, LiftRel.inl⟩
 #align sum.lift_rel_inl_inl Sum.liftRel_inl_inl
 
-/- warning: sum.not_lift_rel_inl_inr -> Sum.not_liftRel_inl_inr is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {r : α -> γ -> Prop} {s : β -> δ -> Prop} {a : α} {d : δ}, Not (Sum.LiftRel.{u1, u2, u3, u4} α β γ δ r s (Sum.inl.{u1, u2} α β a) (Sum.inr.{u3, u4} γ δ d))
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} {r : α -> γ -> Prop} {s : β -> δ -> Prop} {a : α} {d : δ}, Not (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r s (Sum.inl.{u3, u4} α β a) (Sum.inr.{u2, u1} γ δ d))
-Case conversion may be inaccurate. Consider using '#align sum.not_lift_rel_inl_inr Sum.not_liftRel_inl_inrₓ'. -/
 @[simp]
 theorem not_liftRel_inl_inr : ¬LiftRel r s (inl a) (inr d) :=
   fun.
 #align sum.not_lift_rel_inl_inr Sum.not_liftRel_inl_inr
 
-/- warning: sum.not_lift_rel_inr_inl -> Sum.not_liftRel_inr_inl is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {r : α -> γ -> Prop} {s : β -> δ -> Prop} {b : β} {c : γ}, Not (Sum.LiftRel.{u1, u2, u3, u4} α β γ δ r s (Sum.inr.{u1, u2} α β b) (Sum.inl.{u3, u4} γ δ c))
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} {r : α -> γ -> Prop} {s : β -> δ -> Prop} {b : β} {c : γ}, Not (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r s (Sum.inr.{u3, u4} α β b) (Sum.inl.{u2, u1} γ δ c))
-Case conversion may be inaccurate. Consider using '#align sum.not_lift_rel_inr_inl Sum.not_liftRel_inr_inlₓ'. -/
 @[simp]
 theorem not_liftRel_inr_inl : ¬LiftRel r s (inr b) (inl c) :=
   fun.
 #align sum.not_lift_rel_inr_inl Sum.not_liftRel_inr_inl
 
-/- warning: sum.lift_rel_inr_inr -> Sum.liftRel_inr_inr is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {r : α -> γ -> Prop} {s : β -> δ -> Prop} {b : β} {d : δ}, Iff (Sum.LiftRel.{u1, u2, u3, u4} α β γ δ r s (Sum.inr.{u1, u2} α β b) (Sum.inr.{u3, u4} γ δ d)) (s b d)
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} {r : α -> γ -> Prop} {s : β -> δ -> Prop} {b : β} {d : δ}, Iff (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r s (Sum.inr.{u3, u4} α β b) (Sum.inr.{u2, u1} γ δ d)) (s b d)
-Case conversion may be inaccurate. Consider using '#align sum.lift_rel_inr_inr Sum.liftRel_inr_inrₓ'. -/
 @[simp]
 theorem liftRel_inr_inr : LiftRel r s (inr b) (inr d) ↔ s b d :=
   ⟨fun h => by cases h; assumption, LiftRel.inr⟩
@@ -690,54 +504,24 @@ instance [∀ a c, Decidable (r a c)] [∀ b d, Decidable (s b d)] :
   | inr b, inl c => Decidable.isFalse not_liftRel_inr_inl
   | inr b, inr d => decidable_of_iff' _ liftRel_inr_inr
 
-/- warning: sum.lift_rel.mono -> Sum.LiftRel.mono is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {r₁ : α -> γ -> Prop} {r₂ : α -> γ -> Prop} {s₁ : β -> δ -> Prop} {s₂ : β -> δ -> Prop} {x : Sum.{u1, u2} α β} {y : Sum.{u3, u4} γ δ}, (forall (a : α) (b : γ), (r₁ a b) -> (r₂ a b)) -> (forall (a : β) (b : δ), (s₁ a b) -> (s₂ a b)) -> (Sum.LiftRel.{u1, u2, u3, u4} α β γ δ r₁ s₁ x y) -> (Sum.LiftRel.{u1, u2, u3, u4} α β γ δ r₂ s₂ x y)
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} {r₁ : α -> γ -> Prop} {r₂ : α -> γ -> Prop} {s₁ : β -> δ -> Prop} {s₂ : β -> δ -> Prop} {x : Sum.{u3, u4} α β} {y : Sum.{u2, u1} γ δ}, (forall (a : α) (b : γ), (r₁ a b) -> (r₂ a b)) -> (forall (a : β) (b : δ), (s₁ a b) -> (s₂ a b)) -> (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r₁ s₁ x y) -> (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r₂ s₂ x y)
-Case conversion may be inaccurate. Consider using '#align sum.lift_rel.mono Sum.LiftRel.monoₓ'. -/
 theorem LiftRel.mono (hr : ∀ a b, r₁ a b → r₂ a b) (hs : ∀ a b, s₁ a b → s₂ a b)
     (h : LiftRel r₁ s₁ x y) : LiftRel r₂ s₂ x y := by cases h;
   exacts[lift_rel.inl (hr _ _ ‹_›), lift_rel.inr (hs _ _ ‹_›)]
 #align sum.lift_rel.mono Sum.LiftRel.mono
 
-/- warning: sum.lift_rel.mono_left -> Sum.LiftRel.mono_left is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {r₁ : α -> γ -> Prop} {r₂ : α -> γ -> Prop} {s : β -> δ -> Prop} {x : Sum.{u1, u2} α β} {y : Sum.{u3, u4} γ δ}, (forall (a : α) (b : γ), (r₁ a b) -> (r₂ a b)) -> (Sum.LiftRel.{u1, u2, u3, u4} α β γ δ r₁ s x y) -> (Sum.LiftRel.{u1, u2, u3, u4} α β γ δ r₂ s x y)
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} {r₁ : α -> γ -> Prop} {r₂ : α -> γ -> Prop} {s : β -> δ -> Prop} {x : Sum.{u3, u4} α β} {y : Sum.{u2, u1} γ δ}, (forall (a : α) (b : γ), (r₁ a b) -> (r₂ a b)) -> (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r₁ s x y) -> (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r₂ s x y)
-Case conversion may be inaccurate. Consider using '#align sum.lift_rel.mono_left Sum.LiftRel.mono_leftₓ'. -/
 theorem LiftRel.mono_left (hr : ∀ a b, r₁ a b → r₂ a b) (h : LiftRel r₁ s x y) : LiftRel r₂ s x y :=
   h.mono hr fun _ _ => id
 #align sum.lift_rel.mono_left Sum.LiftRel.mono_left
 
-/- warning: sum.lift_rel.mono_right -> Sum.LiftRel.mono_right is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {r : α -> γ -> Prop} {s₁ : β -> δ -> Prop} {s₂ : β -> δ -> Prop} {x : Sum.{u1, u2} α β} {y : Sum.{u3, u4} γ δ}, (forall (a : β) (b : δ), (s₁ a b) -> (s₂ a b)) -> (Sum.LiftRel.{u1, u2, u3, u4} α β γ δ r s₁ x y) -> (Sum.LiftRel.{u1, u2, u3, u4} α β γ δ r s₂ x y)
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} {r : α -> γ -> Prop} {s₁ : β -> δ -> Prop} {s₂ : β -> δ -> Prop} {x : Sum.{u3, u4} α β} {y : Sum.{u2, u1} γ δ}, (forall (a : β) (b : δ), (s₁ a b) -> (s₂ a b)) -> (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r s₁ x y) -> (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r s₂ x y)
-Case conversion may be inaccurate. Consider using '#align sum.lift_rel.mono_right Sum.LiftRel.mono_rightₓ'. -/
 theorem LiftRel.mono_right (hs : ∀ a b, s₁ a b → s₂ a b) (h : LiftRel r s₁ x y) :
     LiftRel r s₂ x y :=
   h.mono (fun _ _ => id) hs
 #align sum.lift_rel.mono_right Sum.LiftRel.mono_right
 
-/- warning: sum.lift_rel.swap -> Sum.LiftRel.swap is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {r : α -> γ -> Prop} {s : β -> δ -> Prop} {x : Sum.{u1, u2} α β} {y : Sum.{u3, u4} γ δ}, (Sum.LiftRel.{u1, u2, u3, u4} α β γ δ r s x y) -> (Sum.LiftRel.{u2, u1, u4, u3} β α δ γ s r (Sum.swap.{u1, u2} α β x) (Sum.swap.{u3, u4} γ δ y))
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} {r : α -> γ -> Prop} {s : β -> δ -> Prop} {x : Sum.{u3, u4} α β} {y : Sum.{u2, u1} γ δ}, (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r s x y) -> (Sum.LiftRel.{u4, u3, u1, u2} β α δ γ s r (Sum.swap.{u3, u4} α β x) (Sum.swap.{u2, u1} γ δ y))
-Case conversion may be inaccurate. Consider using '#align sum.lift_rel.swap Sum.LiftRel.swapₓ'. -/
 protected theorem LiftRel.swap (h : LiftRel r s x y) : LiftRel s r x.symm y.symm := by cases h;
   exacts[lift_rel.inr ‹_›, lift_rel.inl ‹_›]
 #align sum.lift_rel.swap Sum.LiftRel.swap
 
-/- warning: sum.lift_rel_swap_iff -> Sum.liftRel_swap_iff is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {r : α -> γ -> Prop} {s : β -> δ -> Prop} {x : Sum.{u1, u2} α β} {y : Sum.{u3, u4} γ δ}, Iff (Sum.LiftRel.{u2, u1, u4, u3} β α δ γ s r (Sum.swap.{u1, u2} α β x) (Sum.swap.{u3, u4} γ δ y)) (Sum.LiftRel.{u1, u2, u3, u4} α β γ δ r s x y)
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u1}} {δ : Type.{u2}} {r : α -> γ -> Prop} {s : β -> δ -> Prop} {x : Sum.{u3, u4} α β} {y : Sum.{u1, u2} γ δ}, Iff (Sum.LiftRel.{u4, u3, u2, u1} β α δ γ s r (Sum.swap.{u3, u4} α β x) (Sum.swap.{u1, u2} γ δ y)) (Sum.LiftRel.{u3, u4, u1, u2} α β γ δ r s x y)
-Case conversion may be inaccurate. Consider using '#align sum.lift_rel_swap_iff Sum.liftRel_swap_iffₓ'. -/
 @[simp]
 theorem liftRel_swap_iff : LiftRel s r x.symm y.symm ↔ LiftRel r s x y :=
   ⟨fun h => by rw [← swap_swap x, ← swap_swap y]; exact h.swap, LiftRel.swap⟩
@@ -856,12 +640,6 @@ open Sum
 
 namespace Function
 
-/- warning: function.injective.sum_elim -> Function.Injective.sum_elim is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {f : α -> γ} {g : β -> γ}, (Function.Injective.{succ u1, succ u3} α γ f) -> (Function.Injective.{succ u2, succ u3} β γ g) -> (forall (a : α) (b : β), Ne.{succ u3} γ (f a) (g b)) -> (Function.Injective.{max (succ u1) (succ u2), succ u3} (Sum.{u1, u2} α β) γ (Sum.elim.{u1, u2, succ u3} α β γ f g))
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} {f : α -> γ} {g : β -> γ}, (Function.Injective.{succ u2, succ u1} α γ f) -> (Function.Injective.{succ u3, succ u1} β γ g) -> (forall (a : α) (b : β), Ne.{succ u1} γ (f a) (g b)) -> (Function.Injective.{max (succ u3) (succ u2), succ u1} (Sum.{u2, u3} α β) γ (Sum.elim.{u2, u3, succ u1} α β γ f g))
-Case conversion may be inaccurate. Consider using '#align function.injective.sum_elim Function.Injective.sum_elimₓ'. -/
 theorem Injective.sum_elim {f : α → γ} {g : β → γ} (hf : Injective f) (hg : Injective g)
     (hfg : ∀ a b, f a ≠ g b) : Injective (Sum.elim f g)
   | inl x, inl y, h => congr_arg inl <| hf h
@@ -903,12 +681,6 @@ namespace Sum
 
 open Function
 
-/- warning: sum.map_injective -> Sum.map_injective is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {f : α -> γ} {g : β -> δ}, Iff (Function.Injective.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Sum.{u1, u2} α β) (Sum.{u3, u4} γ δ) (Sum.map.{u1, u2, u3, u4} α γ β δ f g)) (And (Function.Injective.{succ u1, succ u3} α γ f) (Function.Injective.{succ u2, succ u4} β δ g))
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u1}} {δ : Type.{u2}} {f : α -> γ} {g : β -> δ}, Iff (Function.Injective.{max (succ u4) (succ u3), max (succ u2) (succ u1)} (Sum.{u3, u4} α β) (Sum.{u1, u2} γ δ) (Sum.map.{u3, u4, u1, u2} α γ β δ f g)) (And (Function.Injective.{succ u3, succ u1} α γ f) (Function.Injective.{succ u4, succ u2} β δ g))
-Case conversion may be inaccurate. Consider using '#align sum.map_injective Sum.map_injectiveₓ'. -/
 @[simp]
 theorem map_injective {f : α → γ} {g : β → δ} :
     Injective (Sum.map f g) ↔ Injective f ∧ Injective g :=
@@ -918,12 +690,6 @@ theorem map_injective {f : α → γ} {g : β → δ} :
     fun h => h.1.sum_map h.2⟩
 #align sum.map_injective Sum.map_injective
 
-/- warning: sum.map_surjective -> Sum.map_surjective is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {f : α -> γ} {g : β -> δ}, Iff (Function.Surjective.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Sum.{u1, u2} α β) (Sum.{u3, u4} γ δ) (Sum.map.{u1, u2, u3, u4} α γ β δ f g)) (And (Function.Surjective.{succ u1, succ u3} α γ f) (Function.Surjective.{succ u2, succ u4} β δ g))
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u1}} {δ : Type.{u2}} {f : α -> γ} {g : β -> δ}, Iff (Function.Surjective.{max (succ u4) (succ u3), max (succ u2) (succ u1)} (Sum.{u3, u4} α β) (Sum.{u1, u2} γ δ) (Sum.map.{u3, u4, u1, u2} α γ β δ f g)) (And (Function.Surjective.{succ u3, succ u1} α γ f) (Function.Surjective.{succ u4, succ u2} β δ g))
-Case conversion may be inaccurate. Consider using '#align sum.map_surjective Sum.map_surjectiveₓ'. -/
 @[simp]
 theorem map_surjective {f : α → γ} {g : β → δ} :
     Surjective (Sum.map f g) ↔ Surjective f ∧ Surjective g :=
@@ -938,46 +704,22 @@ theorem map_surjective {f : α → γ} {g : β → δ} :
     fun h => h.1.sum_map h.2⟩
 #align sum.map_surjective Sum.map_surjective
 
-/- warning: sum.map_bijective -> Sum.map_bijective is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {f : α -> γ} {g : β -> δ}, Iff (Function.Bijective.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Sum.{u1, u2} α β) (Sum.{u3, u4} γ δ) (Sum.map.{u1, u2, u3, u4} α γ β δ f g)) (And (Function.Bijective.{succ u1, succ u3} α γ f) (Function.Bijective.{succ u2, succ u4} β δ g))
-but is expected to have type
-  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u1}} {δ : Type.{u2}} {f : α -> γ} {g : β -> δ}, Iff (Function.Bijective.{max (succ u4) (succ u3), max (succ u2) (succ u1)} (Sum.{u3, u4} α β) (Sum.{u1, u2} γ δ) (Sum.map.{u3, u4, u1, u2} α γ β δ f g)) (And (Function.Bijective.{succ u3, succ u1} α γ f) (Function.Bijective.{succ u4, succ u2} β δ g))
-Case conversion may be inaccurate. Consider using '#align sum.map_bijective Sum.map_bijectiveₓ'. -/
 @[simp]
 theorem map_bijective {f : α → γ} {g : β → δ} :
     Bijective (Sum.map f g) ↔ Bijective f ∧ Bijective g :=
   (map_injective.And map_surjective).trans <| and_and_and_comm _ _ _ _
 #align sum.map_bijective Sum.map_bijective
 
-/- warning: sum.elim_const_const -> Sum.elim_const_const is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (c : γ), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((Sum.{u1, u2} α β) -> γ) (Sum.elim.{u1, u2, succ u3} α β γ (Function.const.{succ u3, succ u1} γ α c) (Function.const.{succ u3, succ u2} γ β c)) (Function.const.{succ u3, max (succ u1) (succ u2)} γ (Sum.{u1, u2} α β) c)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} (c : γ), Eq.{max (max (succ u2) (succ u3)) (succ u1)} ((Sum.{u2, u3} α β) -> γ) (Sum.elim.{u2, u3, succ u1} α β γ (Function.const.{succ u1, succ u2} γ α c) (Function.const.{succ u1, succ u3} γ β c)) (Function.const.{succ u1, max (succ u2) (succ u3)} γ (Sum.{u2, u3} α β) c)
-Case conversion may be inaccurate. Consider using '#align sum.elim_const_const Sum.elim_const_constₓ'. -/
 theorem elim_const_const (c : γ) : Sum.elim (const _ c : α → γ) (const _ c : β → γ) = const _ c :=
   by ext x; cases x <;> rfl
 #align sum.elim_const_const Sum.elim_const_const
 
-/- warning: sum.elim_lam_const_lam_const -> Sum.elim_lam_const_lam_const is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} (c : γ), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((Sum.{u1, u2} α β) -> γ) (Sum.elim.{u1, u2, succ u3} α β γ (fun (_x : α) => c) (fun (_x : β) => c)) (fun (_x : Sum.{u1, u2} α β) => c)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} (c : γ), Eq.{max (max (succ u2) (succ u3)) (succ u1)} ((Sum.{u2, u3} α β) -> γ) (Sum.elim.{u2, u3, succ u1} α β γ (fun (_x : α) => c) (fun (_x : β) => c)) (fun (_x : Sum.{u2, u3} α β) => c)
-Case conversion may be inaccurate. Consider using '#align sum.elim_lam_const_lam_const Sum.elim_lam_const_lam_constₓ'. -/
 @[simp]
 theorem elim_lam_const_lam_const (c : γ) :
     (Sum.elim (fun _ : α => c) fun _ : β => c) = fun _ => c :=
   Sum.elim_const_const c
 #align sum.elim_lam_const_lam_const Sum.elim_lam_const_lam_const
 
-/- warning: sum.elim_update_left -> Sum.elim_update_left is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{succ u2} β] (f : α -> γ) (g : β -> γ) (i : α) (c : γ), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((Sum.{u1, u2} α β) -> γ) (Sum.elim.{u1, u2, succ u3} α β γ (Function.update.{succ u1, succ u3} α (fun (ᾰ : α) => γ) (fun (a : α) (b : α) => _inst_1 a b) f i c) g) (Function.update.{max (succ u1) (succ u2), succ u3} (Sum.{u1, u2} α β) (fun (ᾰ : Sum.{u1, u2} α β) => γ) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => Sum.decidableEq.{u1, u2} α (fun (a : α) (b : α) => _inst_1 a b) β (fun (a : β) (b : β) => _inst_2 a b) a b) (Sum.elim.{u1, u2, succ u3} α β γ f g) (Sum.inl.{u1, u2} α β i) c)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u3} β] (f : α -> γ) (g : β -> γ) (i : α) (c : γ), Eq.{max (max (succ u2) (succ u3)) (succ u1)} ((Sum.{u2, u3} α β) -> γ) (Sum.elim.{u2, u3, succ u1} α β γ (Function.update.{succ u2, succ u1} α (fun (ᾰ : α) => γ) (fun (a : α) (b : α) => _inst_1 a b) f i c) g) (Function.update.{max (succ u3) (succ u2), succ u1} (Sum.{u2, u3} α β) (fun (ᾰ : Sum.{u2, u3} α β) => γ) (fun (a : Sum.{u2, u3} α β) (b : Sum.{u2, u3} α β) => Sum.instDecidableEqSum.{u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b) (Sum.elim.{u2, u3, succ u1} α β γ f g) (Sum.inl.{u2, u3} α β i) c)
-Case conversion may be inaccurate. Consider using '#align sum.elim_update_left Sum.elim_update_leftₓ'. -/
 theorem elim_update_left [DecidableEq α] [DecidableEq β] (f : α → γ) (g : β → γ) (i : α) (c : γ) :
     Sum.elim (Function.update f i c) g = Function.update (Sum.elim f g) (inl i) c :=
   by
@@ -988,12 +730,6 @@ theorem elim_update_left [DecidableEq α] [DecidableEq β] (f : α → γ) (g :
   · simp
 #align sum.elim_update_left Sum.elim_update_left
 
-/- warning: sum.elim_update_right -> Sum.elim_update_right is a dubious translation:
-lean 3 declaration is
-  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} [_inst_1 : DecidableEq.{succ u1} α] [_inst_2 : DecidableEq.{succ u2} β] (f : α -> γ) (g : β -> γ) (i : β) (c : γ), Eq.{max (max (succ u1) (succ u2)) (succ u3)} ((Sum.{u1, u2} α β) -> γ) (Sum.elim.{u1, u2, succ u3} α β γ f (Function.update.{succ u2, succ u3} β (fun (ᾰ : β) => γ) (fun (a : β) (b : β) => _inst_2 a b) g i c)) (Function.update.{max (succ u1) (succ u2), succ u3} (Sum.{u1, u2} α β) (fun (ᾰ : Sum.{u1, u2} α β) => γ) (fun (a : Sum.{u1, u2} α β) (b : Sum.{u1, u2} α β) => Sum.decidableEq.{u1, u2} α (fun (a : α) (b : α) => _inst_1 a b) β (fun (a : β) (b : β) => _inst_2 a b) a b) (Sum.elim.{u1, u2, succ u3} α β γ f g) (Sum.inr.{u1, u2} α β i) c)
-but is expected to have type
-  forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} [_inst_1 : DecidableEq.{succ u2} α] [_inst_2 : DecidableEq.{succ u3} β] (f : α -> γ) (g : β -> γ) (i : β) (c : γ), Eq.{max (max (succ u2) (succ u3)) (succ u1)} ((Sum.{u2, u3} α β) -> γ) (Sum.elim.{u2, u3, succ u1} α β γ f (Function.update.{succ u3, succ u1} β (fun (ᾰ : β) => γ) (fun (a : β) (b : β) => _inst_2 a b) g i c)) (Function.update.{max (succ u3) (succ u2), succ u1} (Sum.{u2, u3} α β) (fun (ᾰ : Sum.{u2, u3} α β) => γ) (fun (a : Sum.{u2, u3} α β) (b : Sum.{u2, u3} α β) => Sum.instDecidableEqSum.{u2, u3} α β (fun (a : α) (b : α) => _inst_1 a b) (fun (a : β) (b : β) => _inst_2 a b) a b) (Sum.elim.{u2, u3, succ u1} α β γ f g) (Sum.inr.{u2, u3} α β i) c)
-Case conversion may be inaccurate. Consider using '#align sum.elim_update_right Sum.elim_update_rightₓ'. -/
 theorem elim_update_right [DecidableEq α] [DecidableEq β] (f : α → γ) (g : β → γ) (i : β) (c : γ) :
     Sum.elim f (Function.update g i c) = Function.update (Sum.elim f g) (inr i) c :=
   by
Diff
@@ -647,9 +647,7 @@ but is expected to have type
 Case conversion may be inaccurate. Consider using '#align sum.lift_rel_inl_inl Sum.liftRel_inl_inlₓ'. -/
 @[simp]
 theorem liftRel_inl_inl : LiftRel r s (inl a) (inl c) ↔ r a c :=
-  ⟨fun h => by
-    cases h
-    assumption, LiftRel.inl⟩
+  ⟨fun h => by cases h; assumption, LiftRel.inl⟩
 #align sum.lift_rel_inl_inl Sum.liftRel_inl_inl
 
 /- warning: sum.not_lift_rel_inl_inr -> Sum.not_liftRel_inl_inr is a dubious translation:
@@ -682,9 +680,7 @@ but is expected to have type
 Case conversion may be inaccurate. Consider using '#align sum.lift_rel_inr_inr Sum.liftRel_inr_inrₓ'. -/
 @[simp]
 theorem liftRel_inr_inr : LiftRel r s (inr b) (inr d) ↔ s b d :=
-  ⟨fun h => by
-    cases h
-    assumption, LiftRel.inr⟩
+  ⟨fun h => by cases h; assumption, LiftRel.inr⟩
 #align sum.lift_rel_inr_inr Sum.liftRel_inr_inr
 
 instance [∀ a c, Decidable (r a c)] [∀ b d, Decidable (s b d)] :
@@ -701,9 +697,7 @@ but is expected to have type
   forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} {r₁ : α -> γ -> Prop} {r₂ : α -> γ -> Prop} {s₁ : β -> δ -> Prop} {s₂ : β -> δ -> Prop} {x : Sum.{u3, u4} α β} {y : Sum.{u2, u1} γ δ}, (forall (a : α) (b : γ), (r₁ a b) -> (r₂ a b)) -> (forall (a : β) (b : δ), (s₁ a b) -> (s₂ a b)) -> (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r₁ s₁ x y) -> (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r₂ s₂ x y)
 Case conversion may be inaccurate. Consider using '#align sum.lift_rel.mono Sum.LiftRel.monoₓ'. -/
 theorem LiftRel.mono (hr : ∀ a b, r₁ a b → r₂ a b) (hs : ∀ a b, s₁ a b → s₂ a b)
-    (h : LiftRel r₁ s₁ x y) : LiftRel r₂ s₂ x y :=
-  by
-  cases h
+    (h : LiftRel r₁ s₁ x y) : LiftRel r₂ s₂ x y := by cases h;
   exacts[lift_rel.inl (hr _ _ ‹_›), lift_rel.inr (hs _ _ ‹_›)]
 #align sum.lift_rel.mono Sum.LiftRel.mono
 
@@ -734,9 +728,7 @@ lean 3 declaration is
 but is expected to have type
   forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u2}} {δ : Type.{u1}} {r : α -> γ -> Prop} {s : β -> δ -> Prop} {x : Sum.{u3, u4} α β} {y : Sum.{u2, u1} γ δ}, (Sum.LiftRel.{u3, u4, u2, u1} α β γ δ r s x y) -> (Sum.LiftRel.{u4, u3, u1, u2} β α δ γ s r (Sum.swap.{u3, u4} α β x) (Sum.swap.{u2, u1} γ δ y))
 Case conversion may be inaccurate. Consider using '#align sum.lift_rel.swap Sum.LiftRel.swapₓ'. -/
-protected theorem LiftRel.swap (h : LiftRel r s x y) : LiftRel s r x.symm y.symm :=
-  by
-  cases h
+protected theorem LiftRel.swap (h : LiftRel r s x y) : LiftRel s r x.symm y.symm := by cases h;
   exacts[lift_rel.inr ‹_›, lift_rel.inl ‹_›]
 #align sum.lift_rel.swap Sum.LiftRel.swap
 
@@ -748,9 +740,7 @@ but is expected to have type
 Case conversion may be inaccurate. Consider using '#align sum.lift_rel_swap_iff Sum.liftRel_swap_iffₓ'. -/
 @[simp]
 theorem liftRel_swap_iff : LiftRel s r x.symm y.symm ↔ LiftRel r s x y :=
-  ⟨fun h => by
-    rw [← swap_swap x, ← swap_swap y]
-    exact h.swap, LiftRel.swap⟩
+  ⟨fun h => by rw [← swap_swap x, ← swap_swap y]; exact h.swap, LiftRel.swap⟩
 #align sum.lift_rel_swap_iff Sum.liftRel_swap_iff
 
 end LiftRel
@@ -777,18 +767,14 @@ variable {r r₁ r₂ : α → α → Prop} {s s₁ s₂ : β → β → Prop} {
 #print Sum.lex_inl_inl /-
 @[simp]
 theorem lex_inl_inl : Lex r s (inl a₁) (inl a₂) ↔ r a₁ a₂ :=
-  ⟨fun h => by
-    cases h
-    assumption, Lex.inl⟩
+  ⟨fun h => by cases h; assumption, Lex.inl⟩
 #align sum.lex_inl_inl Sum.lex_inl_inl
 -/
 
 #print Sum.lex_inr_inr /-
 @[simp]
 theorem lex_inr_inr : Lex r s (inr b₁) (inr b₂) ↔ s b₁ b₂ :=
-  ⟨fun h => by
-    cases h
-    assumption, Lex.inr⟩
+  ⟨fun h => by cases h; assumption, Lex.inr⟩
 #align sum.lex_inr_inr Sum.lex_inr_inr
 -/
 
@@ -806,9 +792,7 @@ instance [DecidableRel r] [DecidableRel s] : DecidableRel (Lex r s)
   | inr b, inr d => decidable_of_iff' _ lex_inr_inr
 
 #print Sum.LiftRel.lex /-
-protected theorem LiftRel.lex {a b : Sum α β} (h : LiftRel r s a b) : Lex r s a b :=
-  by
-  cases h
+protected theorem LiftRel.lex {a b : Sum α β} (h : LiftRel r s a b) : Lex r s a b := by cases h;
   exacts[lex.inl ‹_›, lex.inr ‹_›]
 #align sum.lift_rel.lex Sum.LiftRel.lex
 -/
@@ -820,9 +804,7 @@ theorem liftRel_subrelation_lex : Subrelation (LiftRel r s) (Lex r s) := fun a b
 
 #print Sum.Lex.mono /-
 theorem Lex.mono (hr : ∀ a b, r₁ a b → r₂ a b) (hs : ∀ a b, s₁ a b → s₂ a b) (h : Lex r₁ s₁ x y) :
-    Lex r₂ s₂ x y := by
-  cases h
-  exacts[lex.inl (hr _ _ ‹_›), lex.inr (hs _ _ ‹_›), lex.sep _ _]
+    Lex r₂ s₂ x y := by cases h; exacts[lex.inl (hr _ _ ‹_›), lex.inr (hs _ _ ‹_›), lex.sep _ _]
 #align sum.lex.mono Sum.Lex.mono
 -/
 
@@ -975,9 +957,7 @@ but is expected to have type
   forall {α : Type.{u2}} {β : Type.{u3}} {γ : Type.{u1}} (c : γ), Eq.{max (max (succ u2) (succ u3)) (succ u1)} ((Sum.{u2, u3} α β) -> γ) (Sum.elim.{u2, u3, succ u1} α β γ (Function.const.{succ u1, succ u2} γ α c) (Function.const.{succ u1, succ u3} γ β c)) (Function.const.{succ u1, max (succ u2) (succ u3)} γ (Sum.{u2, u3} α β) c)
 Case conversion may be inaccurate. Consider using '#align sum.elim_const_const Sum.elim_const_constₓ'. -/
 theorem elim_const_const (c : γ) : Sum.elim (const _ c : α → γ) (const _ c : β → γ) = const _ c :=
-  by
-  ext x
-  cases x <;> rfl
+  by ext x; cases x <;> rfl
 #align sum.elim_const_const Sum.elim_const_const
 
 /- warning: sum.elim_lam_const_lam_const -> Sum.elim_lam_const_lam_const is a dubious translation:
@@ -1003,8 +983,7 @@ theorem elim_update_left [DecidableEq α] [DecidableEq β] (f : α → γ) (g :
   by
   ext x; cases x
   · by_cases h : x = i
-    · subst h
-      simp
+    · subst h; simp
     · simp [h]
   · simp
 #align sum.elim_update_left Sum.elim_update_left
@@ -1021,8 +1000,7 @@ theorem elim_update_right [DecidableEq α] [DecidableEq β] (f : α → γ) (g :
   ext x; cases x
   · simp
   · by_cases h : x = i
-    · subst h
-      simp
+    · subst h; simp
     · simp [h]
 #align sum.elim_update_right Sum.elim_update_right
 
Diff
@@ -908,10 +908,12 @@ theorem Surjective.sum_map {f : α → β} {g : α' → β'} (hf : Surjective f)
 #align function.surjective.sum_map Function.Surjective.sum_map
 -/
 
+#print Function.Bijective.sum_map /-
 theorem Bijective.sum_map {f : α → β} {g : α' → β'} (hf : Bijective f) (hg : Bijective g) :
     Bijective (Sum.map f g) :=
   ⟨hf.Injective.sum_map hg.Injective, hf.Surjective.sum_map hg.Surjective⟩
 #align function.bijective.sum_map Function.Bijective.sum_map
+-/
 
 end Function
 
@@ -919,6 +921,12 @@ namespace Sum
 
 open Function
 
+/- warning: sum.map_injective -> Sum.map_injective is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {f : α -> γ} {g : β -> δ}, Iff (Function.Injective.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Sum.{u1, u2} α β) (Sum.{u3, u4} γ δ) (Sum.map.{u1, u2, u3, u4} α γ β δ f g)) (And (Function.Injective.{succ u1, succ u3} α γ f) (Function.Injective.{succ u2, succ u4} β δ g))
+but is expected to have type
+  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u1}} {δ : Type.{u2}} {f : α -> γ} {g : β -> δ}, Iff (Function.Injective.{max (succ u4) (succ u3), max (succ u2) (succ u1)} (Sum.{u3, u4} α β) (Sum.{u1, u2} γ δ) (Sum.map.{u3, u4, u1, u2} α γ β δ f g)) (And (Function.Injective.{succ u3, succ u1} α γ f) (Function.Injective.{succ u4, succ u2} β δ g))
+Case conversion may be inaccurate. Consider using '#align sum.map_injective Sum.map_injectiveₓ'. -/
 @[simp]
 theorem map_injective {f : α → γ} {g : β → δ} :
     Injective (Sum.map f g) ↔ Injective f ∧ Injective g :=
@@ -928,6 +936,12 @@ theorem map_injective {f : α → γ} {g : β → δ} :
     fun h => h.1.sum_map h.2⟩
 #align sum.map_injective Sum.map_injective
 
+/- warning: sum.map_surjective -> Sum.map_surjective is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {f : α -> γ} {g : β -> δ}, Iff (Function.Surjective.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Sum.{u1, u2} α β) (Sum.{u3, u4} γ δ) (Sum.map.{u1, u2, u3, u4} α γ β δ f g)) (And (Function.Surjective.{succ u1, succ u3} α γ f) (Function.Surjective.{succ u2, succ u4} β δ g))
+but is expected to have type
+  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u1}} {δ : Type.{u2}} {f : α -> γ} {g : β -> δ}, Iff (Function.Surjective.{max (succ u4) (succ u3), max (succ u2) (succ u1)} (Sum.{u3, u4} α β) (Sum.{u1, u2} γ δ) (Sum.map.{u3, u4, u1, u2} α γ β δ f g)) (And (Function.Surjective.{succ u3, succ u1} α γ f) (Function.Surjective.{succ u4, succ u2} β δ g))
+Case conversion may be inaccurate. Consider using '#align sum.map_surjective Sum.map_surjectiveₓ'. -/
 @[simp]
 theorem map_surjective {f : α → γ} {g : β → δ} :
     Surjective (Sum.map f g) ↔ Surjective f ∧ Surjective g :=
@@ -942,6 +956,12 @@ theorem map_surjective {f : α → γ} {g : β → δ} :
     fun h => h.1.sum_map h.2⟩
 #align sum.map_surjective Sum.map_surjective
 
+/- warning: sum.map_bijective -> Sum.map_bijective is a dubious translation:
+lean 3 declaration is
+  forall {α : Type.{u1}} {β : Type.{u2}} {γ : Type.{u3}} {δ : Type.{u4}} {f : α -> γ} {g : β -> δ}, Iff (Function.Bijective.{max (succ u1) (succ u2), max (succ u3) (succ u4)} (Sum.{u1, u2} α β) (Sum.{u3, u4} γ δ) (Sum.map.{u1, u2, u3, u4} α γ β δ f g)) (And (Function.Bijective.{succ u1, succ u3} α γ f) (Function.Bijective.{succ u2, succ u4} β δ g))
+but is expected to have type
+  forall {α : Type.{u3}} {β : Type.{u4}} {γ : Type.{u1}} {δ : Type.{u2}} {f : α -> γ} {g : β -> δ}, Iff (Function.Bijective.{max (succ u4) (succ u3), max (succ u2) (succ u1)} (Sum.{u3, u4} α β) (Sum.{u1, u2} γ δ) (Sum.map.{u3, u4, u1, u2} α γ β δ f g)) (And (Function.Bijective.{succ u3, succ u1} α γ f) (Function.Bijective.{succ u4, succ u2} β δ g))
+Case conversion may be inaccurate. Consider using '#align sum.map_bijective Sum.map_bijectiveₓ'. -/
 @[simp]
 theorem map_bijective {f : α → γ} {g : β → δ} :
     Bijective (Sum.map f g) ↔ Bijective f ∧ Bijective g :=

Changes in mathlib4

mathlib3
mathlib4
feat(Data/Sum/Basic): Add LiftRel lemmas. (#6729)

Add lemmas that allow IsLeft/IsRight conclusions from LiftRel and allow for apply functions.

This is necessary because cases cannot run on statements like LiftRel r s (f t) y.

Co-authored-by: lines <34025592+linesthatinterlace@users.noreply.github.com> Co-authored-by: Wrenna Robson <34025592+linesthatinterlace@users.noreply.github.com>

Diff
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro, Yury G. Kudryashov
 -/
 import Mathlib.Logic.Function.Basic
+import Mathlib.Tactic.MkIffOfInductiveProp
 
 #align_import data.sum.basic from "leanprover-community/mathlib"@"bd9851ca476957ea4549eb19b40e7b5ade9428cc"
 
@@ -188,7 +189,9 @@ theorem swap_rightInverse : Function.RightInverse (@swap α β) swap :=
 #align sum.get_left_swap Sum.getLeft?_swap
 #align sum.get_right_swap Sum.getRight?_swap
 
-section LiftRel
+mk_iff_of_inductive_prop Sum.LiftRel Sum.liftRel_iff
+
+namespace LiftRel
 
 #align sum.lift_rel Sum.LiftRel
 #align sum.lift_rel_inl_inl Sum.liftRel_inl_inl
@@ -201,6 +204,36 @@ section LiftRel
 #align sum.lift_rel.swap Sum.LiftRel.swap
 #align sum.lift_rel_swap_iff Sum.liftRel_swap_iff
 
+variable {r : α → γ → Prop} {s : β → δ → Prop} {x : Sum α β} {y : Sum γ δ}
+  {a : α} {b : β} {c : γ} {d : δ}
+
+theorem isLeft_congr (h : LiftRel r s x y) : x.isLeft ↔ y.isLeft := by cases h <;> rfl
+theorem isRight_congr (h : LiftRel r s x y) : x.isRight ↔ y.isRight := by cases h <;> rfl
+
+theorem isLeft_left (h : LiftRel r s x (inl c)) : x.isLeft := by cases h; rfl
+theorem isLeft_right (h : LiftRel r s (inl a) y) : y.isLeft := by cases h; rfl
+theorem isRight_left (h : LiftRel r s x (inr d)) : x.isRight := by cases h; rfl
+theorem isRight_right (h : LiftRel r s (inr b) y) : y.isRight := by cases h; rfl
+
+theorem exists_of_isLeft_left (h₁ : LiftRel r s x y) (h₂ : x.isLeft) :
+    ∃ a c, r a c ∧ x = inl a ∧ y = inl c := by
+  rcases isLeft_iff.mp h₂ with ⟨_, rfl⟩
+  simp only [liftRel_iff, false_and, and_false, exists_false, or_false] at h₁
+  exact h₁
+
+theorem exists_of_isLeft_right (h₁ : LiftRel r s x y) (h₂ : y.isLeft) :
+    ∃ a c, r a c ∧ x = inl a ∧ y = inl c := exists_of_isLeft_left h₁ ((isLeft_congr h₁).mpr h₂)
+
+theorem exists_of_isRight_left (h₁ : LiftRel r s x y) (h₂ : x.isRight) :
+    ∃ b d, s b d ∧ x = inr b ∧ y = inr d := by
+  rcases isRight_iff.mp h₂ with ⟨_, rfl⟩
+  simp only [liftRel_iff, false_and, and_false, exists_false, false_or] at h₁
+  exact h₁
+
+theorem exists_of_isRight_right (h₁ : LiftRel r s x y) (h₂ : y.isRight) :
+    ∃ b d, s b d ∧ x = inr b ∧ y = inr d :=
+  exists_of_isRight_left h₁ ((isRight_congr h₁).mpr h₂)
+
 end LiftRel
 
 section Lex
feat: lemmas about equiv and logic (#7338)
  • From the marginal project
Diff
@@ -34,6 +34,10 @@ theorem inl_injective : Function.Injective (inl : α → Sum α β) := fun _ _ 
 theorem inr_injective : Function.Injective (inr : β → Sum α β) := fun _ _ ↦ inr.inj
 #align sum.inr_injective Sum.inr_injective
 
+theorem sum_rec_congr (P : α ⊕ β → Sort*) (f : ∀ i, P (inl i)) (g : ∀ i, P (inr i))
+    {x y : α ⊕ β} (h : x = y) :
+    @Sum.rec _ _ _ f g x = cast (congr_arg P h.symm) (@Sum.rec _ _ _ f g y) := by cases h; rfl
+
 section get
 
 #align sum.is_left Sum.isLeft
chore: bump Std for #251 (#7126)

Some minor renaming:

  • Sum.not_isLeft becomes Sum.bnot_isLeft
  • Sum.Not_isLeft becomes Sum.not_isLeft

A few explicit arguments also became implicit.

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

Diff
@@ -8,32 +8,9 @@ import Mathlib.Logic.Function.Basic
 #align_import data.sum.basic from "leanprover-community/mathlib"@"bd9851ca476957ea4549eb19b40e7b5ade9428cc"
 
 /-!
-# Disjoint union of types
+# Additional lemmas about sum types
 
-This file proves basic results about the sum type `α ⊕ β`.
-
-`α ⊕ β` is the type made of a copy of `α` and a copy of `β`. It is also called *disjoint union*.
-
-## Main declarations
-
-* `Sum.isLeft`: Returns whether `x : α ⊕ β` comes from the left component or not.
-* `Sum.isRight`: Returns whether `x : α ⊕ β` comes from the right component or not.
-* `Sum.getLeft`: Retrieves the left content of a `x : α ⊕ β` that is known to come from the left.
-* `Sum.getRight`: Retrieves the right content of `x : α ⊕ β` that is known to come from the right.
-* `Sum.getLeft?`: Retrieves the left content of `x : α ⊕ β` as an option type or returns `none`
-  if it's coming from the right.
-* `Sum.getRight?`: Retrieves the right content of `x : α ⊕ β` as an option type or returns `none`
-  if it's coming from the left.
-* `Sum.map`: Maps `α ⊕ β` to `γ ⊕ δ` component-wise.
-* `Sum.elim`: Nondependent eliminator/induction principle for `α ⊕ β`.
-* `Sum.swap`: Maps `α ⊕ β` to `β ⊕ α` by swapping components.
-* `Sum.Lex`: Lexicographic order on `α ⊕ β` induced by a relation on `α` and a relation on `β`.
-
-## Notes
-
-The definition of `Sum` takes values in `Type*`. This effectively forbids `Prop`- valued sum types.
-To this effect, we have `PSum`, which takes value in `Sort*` and carries a more complicated
-universe signature in consequence. The `Prop` version is `or`.
+Most of the former contents of this file have been moved to Std.
 -/
 
 
@@ -43,34 +20,12 @@ variable {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} {γ δ : Type
 
 namespace Sum
 
-deriving instance DecidableEq for Sum
-deriving instance BEq for Sum
-
-@[simp]
-theorem «forall» {p : Sum α β → Prop} : (∀ x, p x) ↔ (∀ a, p (inl a)) ∧ ∀ b, p (inr b) :=
-  ⟨fun h ↦ ⟨fun _ ↦ h _, fun _ ↦ h _⟩, fun ⟨h₁, h₂⟩ ↦ Sum.rec h₁ h₂⟩
 #align sum.forall Sum.forall
-
-@[simp]
-theorem «exists» {p : Sum α β → Prop} : (∃ x, p x) ↔ (∃ a, p (inl a)) ∨ ∃ b, p (inr b) :=
-  ⟨ fun
-    | ⟨inl a, h⟩ => Or.inl ⟨a, h⟩
-    | ⟨inr b, h⟩ => Or.inr ⟨b, h⟩,
-    fun
-    | Or.inl ⟨a, h⟩ => ⟨inl a, h⟩
-    | Or.inr ⟨b, h⟩ => ⟨inr b, h⟩⟩
 #align sum.exists Sum.exists
 
-theorem forall_sum_pi {γ : α ⊕ β → Sort*} (p : (∀ ab, γ ab) → Prop) :
-    (∀ fab, p fab) ↔ (∀ fa fb, p (Sum.rec fa fb)) :=
-  ⟨fun h fa fb => h _, fun h fab => by
-    have h1 : fab = Sum.rec (fun a => fab (Sum.inl a)) (fun b => fab (Sum.inr b)) := by
-      ext ab; cases ab <;> rfl
-    rw [h1]; exact h _ _⟩
-
-theorem exists_sum_pi {γ : α ⊕ β → Sort*} (p : (∀ ab, γ ab) → Prop) :
+theorem exists_sum {γ : α ⊕ β → Sort*} (p : (∀ ab, γ ab) → Prop) :
     (∃ fab, p fab) ↔ (∃ fa fb, p (Sum.rec fa fb)) := by
-  rw [← not_forall_not, forall_sum_pi]
+  rw [← not_forall_not, forall_sum]
   simp
 
 theorem inl_injective : Function.Injective (inl : α → Sum α β) := fun _ _ ↦ inl.inj
@@ -81,90 +36,23 @@ theorem inr_injective : Function.Injective (inr : β → Sum α β) := fun _ _ 
 
 section get
 
-/-- Check if a sum is `inl`. -/
-def isLeft : Sum α β → Bool
-  | inl _ => true
-  | inr _ => false
 #align sum.is_left Sum.isLeft
-
-/-- Check if a sum is `inr`. -/
-def isRight : Sum α β → Bool
-  | inl _ => false
-  | inr _ => true
 #align sum.is_right Sum.isRight
-
-/-- Retrieve the contents from a sum known to be `inl`.-/
-def getLeft : (ab : Sum α β) → ab.isLeft → α
-  | inl a, _ => a
-
-/-- Retrieve the contents from a sum known to be `inr`.-/
-def getRight : (ab : Sum α β) → ab.isRight → β
-  | inr b, _ => b
-
-/-- Check if a sum is `inl` and if so, retrieve its contents. -/
-def getLeft? : Sum α β → Option α
-  | inl a => some a
-  | inr _ => none
 #align sum.get_left Sum.getLeft?
-
-/-- Check if a sum is `inr` and if so, retrieve its contents. -/
-def getRight? : Sum α β → Option β
-  | inr b => some b
-  | inl _ => none
 #align sum.get_right Sum.getRight?
 
 variable {x y : Sum α β}
 
-@[simp] theorem isLeft_inl (x : α) : (inl x : α ⊕ β).isLeft = true := rfl
-@[simp] theorem isLeft_inr (x : β) : (inr x : α ⊕ β).isLeft = false := rfl
-@[simp] theorem isRight_inl (x : α) : (inl x : α ⊕ β).isRight = false := rfl
-@[simp] theorem isRight_inr (x : β) : (inr x : α ⊕ β).isRight = true := rfl
-
-@[simp] theorem getLeft_inl (x : α) (h : (inl x : α ⊕ β).isLeft) : (inl x).getLeft h = x := rfl
-@[simp] theorem getRight_inr (x : β) (h : (inr x : α ⊕ β).isRight) : (inr x).getRight h = x := rfl
-
-@[simp] theorem getLeft?_inl (x : α) : (inl x : α ⊕ β).getLeft? = some x := rfl
-@[simp] theorem getLeft?_inr (x : β) : (inr x : α ⊕ β).getLeft? = none := rfl
-@[simp] theorem getRight?_inl (x : α) : (inl x : α ⊕ β).getRight? = none := rfl
-@[simp] theorem getRight?_inr (x : β) : (inr x : α ⊕ β).getRight? = some x := rfl
-
-@[simp] theorem inl_getLeft : ∀ (x : α ⊕ β) (h : x.isLeft), inl (x.getLeft h) = x
-  | inl _, _ => rfl
-@[simp] theorem inr_getRight : ∀ (x : α ⊕ β) (h : x.isRight), inr (x.getRight h) = x
-  | inr _, _ => rfl
-
-@[simp] theorem getLeft?_eq_none_iff : x.getLeft? = none ↔ x.isRight := by
-  cases x <;> simp only [getLeft?, isRight, eq_self_iff_true]
 #align sum.get_left_eq_none_iff Sum.getLeft?_eq_none_iff
-
-@[simp] theorem getRight?_eq_none_iff : x.getRight? = none ↔ x.isLeft := by
-  cases x <;> simp only [getRight?, isLeft, eq_self_iff_true]
 #align sum.get_right_eq_none_iff Sum.getRight?_eq_none_iff
 
-theorem eq_left_getLeft_of_isLeft : ∀ {x : α ⊕ β} (h : x.isLeft), x = inl (x.getLeft h)
-  | inl _, _ => rfl
-
 theorem eq_left_iff_getLeft_eq {a : α} : x = inl a ↔ ∃ h, x.getLeft h = a := by
-  cases x <;> simp; exact fun c => c.elim
-
-@[simp] theorem getLeft_eq_iff {a : α} (h : x.isLeft) : x.getLeft h = a ↔ x = inl a := by
-  cases x <;> simp at h ⊢
-
-theorem eq_right_getRight_of_isRight : ∀ {x : α ⊕ β} (h : x.isRight), x = inr (x.getRight h)
-  | inr _, _ => rfl
+  cases x <;> simp
 
 theorem eq_right_iff_getRight_eq {b : β} : x = inr b ↔ ∃ h, x.getRight h = b := by
-  cases x <;> simp; exact fun c => c.elim
-
-@[simp] theorem getRight_eq_iff {b : β} (h : x.isRight) : x.getRight h = b ↔ x = inr b := by
-  cases x <;> simp at h ⊢
+  cases x <;> simp
 
-@[simp] theorem getLeft?_eq_some_iff {a : α} : x.getLeft? = some a ↔ x = inl a := by
-  cases x <;> simp only [getLeft?, Option.some.injEq, inl.injEq]
 #align sum.get_left_eq_some_iff Sum.getLeft?_eq_some_iff
-
-@[simp] theorem getRight?_eq_some_iff {b : β} : x.getRight? = some b ↔ x = inr b := by
-  cases x <;> simp only [getRight?, Option.some.injEq, inr.injEq]
 #align sum.get_right_eq_some_iff Sum.getRight?_eq_some_iff
 
 theorem getLeft_eq_getLeft? (h₁ : x.isLeft) (h₂ : x.getLeft?.isSome) :
@@ -173,160 +61,46 @@ theorem getLeft_eq_getLeft? (h₁ : x.isLeft) (h₂ : x.getLeft?.isSome) :
 theorem getRight_eq_getRight? (h₁ : x.isRight) (h₂ : x.getRight?.isSome) :
     x.getRight h₁ = x.getRight?.get h₂ := by simp [← getRight?_eq_some_iff]
 
-@[simp]
-theorem not_isLeft (x : Sum α β) : not x.isLeft = x.isRight := by cases x <;> rfl
-#align sum.bnot_is_left Sum.not_isLeft
-
-@[simp]
-theorem isLeft_eq_false : x.isLeft = false ↔ x.isRight := by cases x <;> simp
+#align sum.bnot_is_left Sum.bnot_isLeft
 #align sum.is_left_eq_ff Sum.isLeft_eq_false
-
-theorem Not_isLeft : ¬x.isLeft ↔ x.isRight := by simp
-#align sum.not_is_left Sum.Not_isLeft
-
-@[simp]
-theorem not_isRight (x : Sum α β) : !x.isRight = x.isLeft := by cases x <;> rfl
-#align sum.bnot_is_right Sum.not_isRight
-
-@[simp]
-theorem isRight_eq_false : x.isRight = false ↔ x.isLeft := by cases x <;> simp
+#align sum.not_is_left Sum.not_isLeft
+#align sum.bnot_is_right Sum.bnot_isRight
 #align sum.is_right_eq_ff Sum.isRight_eq_false
-
-theorem Not_isRight : ¬x.isRight ↔ x.isLeft := by simp
-#align sum.not_is_right Sum.Not_isRight
-
-theorem isLeft_iff : x.isLeft ↔ ∃ y, x = Sum.inl y := by cases x <;> simp
+#align sum.not_is_right Sum.not_isRight
 #align sum.is_left_iff Sum.isLeft_iff
-
-theorem isRight_iff : x.isRight ↔ ∃ y, x = Sum.inr y := by cases x <;> simp
 #align sum.is_right_iff Sum.isRight_iff
 
 @[simp] theorem isSome_getLeft?_iff_isLeft : x.getLeft?.isSome ↔ x.isLeft := by
-rw [isLeft_iff, Option.isSome_iff_exists]; simp
+  rw [isLeft_iff, Option.isSome_iff_exists]; simp
 
 @[simp] theorem isSome_getRight?_iff_isRight : x.getRight?.isSome ↔ x.isRight := by
-rw [isRight_iff, Option.isSome_iff_exists]; simp
+  rw [isRight_iff, Option.isSome_iff_exists]; simp
 
 end get
 
-theorem inl.inj_iff {a b} : (inl a : Sum α β) = inl b ↔ a = b :=
-  ⟨inl.inj, congr_arg _⟩
 #align sum.inl.inj_iff Sum.inl.inj_iff
-
-theorem inr.inj_iff {a b} : (inr a : Sum α β) = inr b ↔ a = b :=
-  ⟨inr.inj, congr_arg _⟩
 #align sum.inr.inj_iff Sum.inr.inj_iff
-
-theorem inl_ne_inr {a : α} {b : β} : inl a ≠ inr b :=
-  fun.
 #align sum.inl_ne_inr Sum.inl_ne_inr
-
-theorem inr_ne_inl {a : α} {b : β} : inr b ≠ inl a :=
-  fun.
 #align sum.inr_ne_inl Sum.inr_ne_inl
-
-/-- Define a function on `α ⊕ β` by giving separate definitions on `α` and `β`. -/
-protected def elim {α β γ : Sort _} (f : α → γ) (g : β → γ) : Sum α β → γ :=
-  fun x ↦ Sum.casesOn x f g
 #align sum.elim Sum.elim
-
-@[simp]
-theorem elim_inl {α β γ : Sort _} (f : α → γ) (g : β → γ) (x : α) : Sum.elim f g (inl x) = f x :=
-  rfl
 #align sum.elim_inl Sum.elim_inl
-
-@[simp]
-theorem elim_inr {α β γ : Sort _} (f : α → γ) (g : β → γ) (x : β) : Sum.elim f g (inr x) = g x :=
-  rfl
 #align sum.elim_inr Sum.elim_inr
-
-@[simp]
-theorem elim_comp_inl {α β γ : Sort _} (f : α → γ) (g : β → γ) : Sum.elim f g ∘ inl = f :=
-  rfl
 #align sum.elim_comp_inl Sum.elim_comp_inl
-
-@[simp]
-theorem elim_comp_inr {α β γ : Sort _} (f : α → γ) (g : β → γ) : Sum.elim f g ∘ inr = g :=
-  rfl
 #align sum.elim_comp_inr Sum.elim_comp_inr
-
-@[simp]
-theorem elim_inl_inr {α β : Sort _} : @Sum.elim α β _ inl inr = id :=
-  funext fun x ↦ Sum.casesOn x (fun _ ↦ rfl) fun _ ↦ rfl
 #align sum.elim_inl_inr Sum.elim_inl_inr
-
-theorem comp_elim {α β γ δ : Sort _} (f : γ → δ) (g : α → γ) (h : β → γ) :
-    f ∘ Sum.elim g h = Sum.elim (f ∘ g) (f ∘ h) :=
-  funext fun x ↦ Sum.casesOn x (fun _ ↦ rfl) fun _ ↦ rfl
 #align sum.comp_elim Sum.comp_elim
-
-@[simp]
-theorem elim_comp_inl_inr {α β γ : Sort _} (f : Sum α β → γ) : Sum.elim (f ∘ inl) (f ∘ inr) = f :=
-  funext fun x ↦ Sum.casesOn x (fun _ ↦ rfl) fun _ ↦ rfl
 #align sum.elim_comp_inl_inr Sum.elim_comp_inl_inr
-
-/-- Map `α ⊕ β` to `α' ⊕ β'` sending `α` to `α'` and `β` to `β'`. -/
-protected def map (f : α → α') (g : β → β') : Sum α β → Sum α' β' :=
-  Sum.elim (inl ∘ f) (inr ∘ g)
 #align sum.map Sum.map
-
-@[simp]
-theorem map_inl (f : α → α') (g : β → β') (x : α) : (inl x).map f g = inl (f x) :=
-  rfl
 #align sum.map_inl Sum.map_inl
-
-@[simp]
-theorem map_inr (f : α → α') (g : β → β') (x : β) : (inr x).map f g = inr (g x) :=
-  rfl
 #align sum.map_inr Sum.map_inr
-
-@[simp]
-theorem map_map {α'' β''} (f' : α' → α'') (g' : β' → β'') (f : α → α') (g : β → β') :
-    ∀ x : Sum α β, (x.map f g).map f' g' = x.map (f' ∘ f) (g' ∘ g)
-  | inl _ => rfl
-  | inr _ => rfl
 #align sum.map_map Sum.map_map
-
-@[simp]
-theorem map_comp_map {α'' β''} (f' : α' → α'') (g' : β' → β'') (f : α → α') (g : β → β') :
-    Sum.map f' g' ∘ Sum.map f g = Sum.map (f' ∘ f) (g' ∘ g) :=
-  funext <| map_map f' g' f g
 #align sum.map_comp_map Sum.map_comp_map
-
-@[simp]
-theorem map_id_id (α β) : Sum.map (@id α) (@id β) = id :=
-  funext fun x ↦ Sum.recOn x (fun _ ↦ rfl) fun _ ↦ rfl
 #align sum.map_id_id Sum.map_id_id
-
-theorem elim_map {α β γ δ ε : Sort _} {f₁ : α → β} {f₂ : β → ε} {g₁ : γ → δ} {g₂ : δ → ε} {x} :
-    Sum.elim f₂ g₂ (Sum.map f₁ g₁ x) = Sum.elim (f₂ ∘ f₁) (g₂ ∘ g₁) x := by
-  cases x <;> rfl
 #align sum.elim_map Sum.elim_map
-
-theorem elim_comp_map {α β γ δ ε : Sort _} {f₁ : α → β} {f₂ : β → ε} {g₁ : γ → δ} {g₂ : δ → ε} :
-    Sum.elim f₂ g₂ ∘ Sum.map f₁ g₁ = Sum.elim (f₂ ∘ f₁) (g₂ ∘ g₁) :=
-  funext $ fun _ => elim_map
 #align sum.elim_comp_map Sum.elim_comp_map
-
-@[simp]
-theorem isLeft_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isLeft (x.map f g) = isLeft x := by
-  cases x <;> rfl
 #align sum.is_left_map Sum.isLeft_map
-
-@[simp]
-theorem isRight_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isRight (x.map f g) = isRight x := by
-  cases x <;> rfl
 #align sum.is_right_map Sum.isRight_map
-
-@[simp]
-theorem getLeft?_map (f : α → β) (g : γ → δ) (x : Sum α γ) :
-    (x.map f g).getLeft? = x.getLeft?.map f := by
-  cases x <;> rfl
 #align sum.get_left_map Sum.getLeft?_map
-
-@[simp]
-theorem getRight?_map (f : α → β) (g : γ → δ) (x : α ⊕ γ) :
-    (x.map f g).getRight? = x.getRight?.map g := by cases x <;> rfl
 #align sum.get_right_map Sum.getRight?_map
 
 open Function (update update_eq_iff update_comp_eq_of_injective update_comp_eq_of_forall_ne)
@@ -389,28 +163,10 @@ theorem update_inr_apply_inr [DecidableEq β] [DecidableEq (Sum α β)] {f : Sum
   rw [← update_inr_comp_inr, Function.comp_apply]
 #align sum.update_inr_apply_inr Sum.update_inr_apply_inr
 
-/-- Swap the factors of a sum type -/
-def swap : Sum α β → Sum β α :=
-  Sum.elim inr inl
 #align sum.swap Sum.swap
-
-@[simp]
-theorem swap_inl (x : α) : swap (inl x : Sum α β) = inr x :=
-  rfl
 #align sum.swap_inl Sum.swap_inl
-
-@[simp]
-theorem swap_inr (x : β) : swap (inr x : Sum α β) = inl x :=
-  rfl
 #align sum.swap_inr Sum.swap_inr
-
-@[simp]
-theorem swap_swap (x : Sum α β) : swap (swap x) = x := by cases x <;> rfl
 #align sum.swap_swap Sum.swap_swap
-
-@[simp]
-theorem swap_swap_eq : swap ∘ swap = @id (Sum α β) :=
-  funext <| swap_swap
 #align sum.swap_swap_eq Sum.swap_swap_eq
 
 @[simp]
@@ -423,188 +179,41 @@ theorem swap_rightInverse : Function.RightInverse (@swap α β) swap :=
   swap_swap
 #align sum.swap_right_inverse Sum.swap_rightInverse
 
-@[simp]
-theorem isLeft_swap (x : Sum α β) : x.swap.isLeft = x.isRight := by cases x <;> rfl
 #align sum.is_left_swap Sum.isLeft_swap
-
-@[simp]
-theorem isRight_swap (x : Sum α β) : x.swap.isRight = x.isLeft := by cases x <;> rfl
 #align sum.is_right_swap Sum.isRight_swap
-
-@[simp]
-theorem getLeft?_swap (x : Sum α β) : x.swap.getLeft? = x.getRight? := by cases x <;> rfl
 #align sum.get_left_swap Sum.getLeft?_swap
-
-@[simp]
-theorem getRight?_swap (x : Sum α β) : x.swap.getRight? = x.getLeft? := by cases x <;> rfl
 #align sum.get_right_swap Sum.getRight?_swap
 
 section LiftRel
 
-/-- Lifts pointwise two relations between `α` and `γ` and between `β` and `δ` to a relation between
-`α ⊕ β` and `γ ⊕ δ`. -/
-inductive LiftRel (r : α → γ → Prop) (s : β → δ → Prop) : Sum α β → Sum γ δ → Prop
-  | protected inl {a c} : r a c → LiftRel r s (inl a) (inl c)
-  | protected inr {b d} : s b d → LiftRel r s (inr b) (inr d)
 #align sum.lift_rel Sum.LiftRel
-
-variable {r r₁ r₂ : α → γ → Prop} {s s₁ s₂ : β → δ → Prop} {a : α} {b : β} {c : γ} {d : δ}
-  {x : Sum α β} {y : Sum γ δ}
-
-@[simp]
-theorem liftRel_inl_inl : LiftRel r s (inl a) (inl c) ↔ r a c :=
-  ⟨fun h ↦ by
-    cases h
-    assumption, LiftRel.inl⟩
 #align sum.lift_rel_inl_inl Sum.liftRel_inl_inl
-
-@[simp]
-theorem not_liftRel_inl_inr : ¬LiftRel r s (inl a) (inr d) :=
-  fun.
 #align sum.not_lift_rel_inl_inr Sum.not_liftRel_inl_inr
-
-@[simp]
-theorem not_liftRel_inr_inl : ¬LiftRel r s (inr b) (inl c) :=
-  fun.
 #align sum.not_lift_rel_inr_inl Sum.not_liftRel_inr_inl
-
-@[simp]
-theorem liftRel_inr_inr : LiftRel r s (inr b) (inr d) ↔ s b d :=
-  ⟨fun h ↦ by
-    cases h
-    assumption, LiftRel.inr⟩
 #align sum.lift_rel_inr_inr Sum.liftRel_inr_inr
-
-instance [∀ a c, Decidable (r a c)] [∀ b d, Decidable (s b d)] :
-    ∀ (ab : Sum α β) (cd : Sum γ δ), Decidable (LiftRel r s ab cd)
-  | inl _, inl _ => decidable_of_iff' _ liftRel_inl_inl
-  | inl _, inr _ => Decidable.isFalse not_liftRel_inl_inr
-  | inr _, inl _ => Decidable.isFalse not_liftRel_inr_inl
-  | inr _, inr _ => decidable_of_iff' _ liftRel_inr_inr
-
-theorem LiftRel.mono (hr : ∀ a b, r₁ a b → r₂ a b) (hs : ∀ a b, s₁ a b → s₂ a b)
-  (h : LiftRel r₁ s₁ x y) : LiftRel r₂ s₂ x y := by
-  cases h
-  · exact LiftRel.inl (hr _ _ ‹_›)
-  · exact LiftRel.inr (hs _ _ ‹_›)
 #align sum.lift_rel.mono Sum.LiftRel.mono
-
-theorem LiftRel.mono_left (hr : ∀ a b, r₁ a b → r₂ a b) (h : LiftRel r₁ s x y) :
-    LiftRel r₂ s x y :=
-  (h.mono hr) fun _ _ ↦ id
 #align sum.lift_rel.mono_left Sum.LiftRel.mono_left
-
-theorem LiftRel.mono_right (hs : ∀ a b, s₁ a b → s₂ a b) (h : LiftRel r s₁ x y) :
-    LiftRel r s₂ x y :=
-  h.mono (fun _ _ ↦ id) hs
 #align sum.lift_rel.mono_right Sum.LiftRel.mono_right
-
-protected theorem LiftRel.swap (h : LiftRel r s x y) : LiftRel s r x.swap y.swap := by
-  cases h
-  · exact LiftRel.inr ‹_›
-  · exact LiftRel.inl ‹_›
 #align sum.lift_rel.swap Sum.LiftRel.swap
-
-@[simp]
-theorem liftRel_swap_iff : LiftRel s r x.swap y.swap ↔ LiftRel r s x y :=
-  ⟨fun h ↦ by
-    rw [← swap_swap x, ← swap_swap y]
-    exact h.swap, LiftRel.swap⟩
 #align sum.lift_rel_swap_iff Sum.liftRel_swap_iff
 
 end LiftRel
 
 section Lex
 
-/-- Lexicographic order for sum. Sort all the `inl a` before the `inr b`, otherwise use the
-respective order on `α` or `β`. -/
-inductive Lex (r : α → α → Prop) (s : β → β → Prop) : Sum α β → Sum α β → Prop
-  | protected inl {a₁ a₂} (h : r a₁ a₂) : Lex r s (inl a₁) (inl a₂)
-  | protected inr {b₁ b₂} (h : s b₁ b₂) : Lex r s (inr b₁) (inr b₂)
-  | sep (a b) : Lex r s (inl a) (inr b)
 #align sum.lex.inl Sum.Lex.inl
 #align sum.lex.inr Sum.Lex.inr
 #align sum.lex.sep Sum.Lex.sep
 #align sum.lex Sum.Lex
-
-attribute [simp] Lex.sep
-
-variable {r r₁ r₂ : α → α → Prop} {s s₁ s₂ : β → β → Prop} {a a₁ a₂ : α} {b b₁ b₂ : β}
-  {x y : Sum α β}
-
-@[simp]
-theorem lex_inl_inl : Lex r s (inl a₁) (inl a₂) ↔ r a₁ a₂ :=
-  ⟨fun h ↦ by
-    cases h
-    assumption, Lex.inl⟩
 #align sum.lex_inl_inl Sum.lex_inl_inl
-
-@[simp]
-theorem lex_inr_inr : Lex r s (inr b₁) (inr b₂) ↔ s b₁ b₂ :=
-  ⟨fun h ↦ by
-    cases h
-    assumption, Lex.inr⟩
 #align sum.lex_inr_inr Sum.lex_inr_inr
-
-@[simp]
-theorem lex_inr_inl : ¬Lex r s (inr b) (inl a) :=
-  fun.
 #align sum.lex_inr_inl Sum.lex_inr_inl
-
-instance instDecidableRelSumLex [DecidableRel r] [DecidableRel s] : DecidableRel (Lex r s)
-  | inl _, inl _ => decidable_of_iff' _ lex_inl_inl
-  | inl _, inr _ => Decidable.isTrue (Lex.sep _ _)
-  | inr _, inl _ => Decidable.isFalse lex_inr_inl
-  | inr _, inr _ => decidable_of_iff' _ lex_inr_inr
-
-protected theorem LiftRel.lex {a b : Sum α β} (h : LiftRel r s a b) : Lex r s a b := by
-  cases h
-  · exact Lex.inl ‹_›
-  · exact Lex.inr ‹_›
 #align sum.lift_rel.lex Sum.LiftRel.lex
-
-theorem liftRel_subrelation_lex : Subrelation (LiftRel r s) (Lex r s) := LiftRel.lex
 #align sum.lift_rel_subrelation_lex Sum.liftRel_subrelation_lex
-
-theorem Lex.mono (hr : ∀ a b, r₁ a b → r₂ a b) (hs : ∀ a b, s₁ a b → s₂ a b) (h : Lex r₁ s₁ x y) :
-    Lex r₂ s₂ x y := by
-  cases h
-  · exact Lex.inl (hr _ _ ‹_›)
-  · exact Lex.inr (hs _ _ ‹_›)
-  · exact Lex.sep _ _
-#align sum.lex.mono Sum.Lex.mono
-
-theorem Lex.mono_left (hr : ∀ a b, r₁ a b → r₂ a b) (h : Lex r₁ s x y) : Lex r₂ s x y :=
-  (h.mono hr) fun _ _ ↦ id
 #align sum.lex.mono_left Sum.Lex.mono_left
-
-theorem Lex.mono_right (hs : ∀ a b, s₁ a b → s₂ a b) (h : Lex r s₁ x y) : Lex r s₂ x y :=
-  h.mono (fun _ _ ↦ id) hs
 #align sum.lex.mono_right Sum.Lex.mono_right
-
-theorem lex_acc_inl {a} (aca : Acc r a) : Acc (Lex r s) (inl a) := by
-  induction aca with
-  | intro _ _ IH =>
-    constructor
-    intro y h
-    cases h with
-    | inl h' => exact IH _ h'
 #align sum.lex_acc_inl Sum.lex_acc_inl
-
-theorem lex_acc_inr (aca : ∀ a, Acc (Lex r s) (inl a)) {b} (acb : Acc s b) :
-    Acc (Lex r s) (inr b) := by
-  induction acb with
-  | intro _ _ IH =>
-    constructor
-    intro y h
-    cases h with
-    | inr h' => exact IH _ h'
-    | sep => exact aca _
 #align sum.lex_acc_inr Sum.lex_acc_inr
-
-theorem lex_wf (ha : WellFounded r) (hb : WellFounded s) : WellFounded (Lex r s) :=
-  have aca : ∀ a, Acc (Lex r s) (inl a) := fun a ↦ lex_acc_inl (ha.apply a)
-  ⟨fun x ↦ Sum.recOn x aca fun b ↦ lex_acc_inr aca (hb.apply b)⟩
 #align sum.lex_wf Sum.lex_wf
 
 end Lex
@@ -680,16 +289,7 @@ theorem map_bijective {f : α → γ} {g : β → δ} :
   (map_injective.and map_surjective).trans <| and_and_and_comm
 #align sum.map_bijective Sum.map_bijective
 
-theorem elim_const_const (c : γ) :
-    Sum.elim (const _ c : α → γ) (const _ c : β → γ) = const _ c := by
-  ext x
-  cases x <;> rfl
 #align sum.elim_const_const Sum.elim_const_const
-
-@[simp]
-theorem elim_lam_const_lam_const (c : γ) :
-    (Sum.elim (fun _ : α ↦ c) fun _ : β ↦ c) = fun _ ↦ c :=
-  Sum.elim_const_const c
 #align sum.elim_lam_const_lam_const Sum.elim_lam_const_lam_const
 
 theorem elim_update_left [DecidableEq α] [DecidableEq β] (f : α → γ) (g : β → γ) (i : α) (c : γ) :
chore: tidy various files (#7035)
Diff
@@ -168,10 +168,10 @@ theorem eq_right_iff_getRight_eq {b : β} : x = inr b ↔ ∃ h, x.getRight h =
 #align sum.get_right_eq_some_iff Sum.getRight?_eq_some_iff
 
 theorem getLeft_eq_getLeft? (h₁ : x.isLeft) (h₂ : x.getLeft?.isSome) :
-x.getLeft h₁ = x.getLeft?.get h₂ := by simp [← getLeft?_eq_some_iff]
+    x.getLeft h₁ = x.getLeft?.get h₂ := by simp [← getLeft?_eq_some_iff]
 
 theorem getRight_eq_getRight? (h₁ : x.isRight) (h₂ : x.getRight?.isSome) :
-x.getRight h₁ = x.getRight?.get h₂ := by simp [← getRight?_eq_some_iff]
+    x.getRight h₁ = x.getRight?.get h₂ := by simp [← getRight?_eq_some_iff]
 
 @[simp]
 theorem not_isLeft (x : Sum α β) : not x.isLeft = x.isRight := by cases x <;> rfl
chore: avoid using cases' early (#6997)

This will help with my cleanup of the early library, facilitating moving tactics upstream.

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

Diff
@@ -583,21 +583,23 @@ theorem Lex.mono_right (hs : ∀ a b, s₁ a b → s₂ a b) (h : Lex r s₁ x y
 #align sum.lex.mono_right Sum.Lex.mono_right
 
 theorem lex_acc_inl {a} (aca : Acc r a) : Acc (Lex r s) (inl a) := by
-  induction' aca with a _ IH
-  constructor
-  intro y h
-  cases' h with a' _ h'
-  exact IH _ h'
+  induction aca with
+  | intro _ _ IH =>
+    constructor
+    intro y h
+    cases h with
+    | inl h' => exact IH _ h'
 #align sum.lex_acc_inl Sum.lex_acc_inl
 
 theorem lex_acc_inr (aca : ∀ a, Acc (Lex r s) (inl a)) {b} (acb : Acc s b) :
     Acc (Lex r s) (inr b) := by
-  induction' acb with b _ IH
-  constructor
-  intro y h
-  cases' h with _ _ _ b' _ h' a
-  · exact IH _ h'
-  · exact aca _
+  induction acb with
+  | intro _ _ IH =>
+    constructor
+    intro y h
+    cases h with
+    | inr h' => exact IH _ h'
+    | sep => exact aca _
 #align sum.lex_acc_inr Sum.lex_acc_inr
 
 theorem lex_wf (ha : WellFounded r) (hb : WellFounded s) : WellFounded (Lex r s) :=
feat(Data/Sum/Basic): create direct versions of get(Left|Right)? analogous to Option.get (#6663)

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

Diff
@@ -16,12 +16,14 @@ This file proves basic results about the sum type `α ⊕ β`.
 
 ## Main declarations
 
-* `Sum.getLeft?`: Retrieves the left content of `x : α ⊕ β` or returns `none` if it's coming from
-  the right.
-* `Sum.getRight?`: Retrieves the right content of `x : α ⊕ β` or returns `none` if it's coming from
-  the left.
 * `Sum.isLeft`: Returns whether `x : α ⊕ β` comes from the left component or not.
 * `Sum.isRight`: Returns whether `x : α ⊕ β` comes from the right component or not.
+* `Sum.getLeft`: Retrieves the left content of a `x : α ⊕ β` that is known to come from the left.
+* `Sum.getRight`: Retrieves the right content of `x : α ⊕ β` that is known to come from the right.
+* `Sum.getLeft?`: Retrieves the left content of `x : α ⊕ β` as an option type or returns `none`
+  if it's coming from the right.
+* `Sum.getRight?`: Retrieves the right content of `x : α ⊕ β` as an option type or returns `none`
+  if it's coming from the left.
 * `Sum.map`: Maps `α ⊕ β` to `γ ⊕ δ` component-wise.
 * `Sum.elim`: Nondependent eliminator/induction principle for `α ⊕ β`.
 * `Sum.swap`: Maps `α ⊕ β` to `β ⊕ α` by swapping components.
@@ -79,6 +81,26 @@ theorem inr_injective : Function.Injective (inr : β → Sum α β) := fun _ _ 
 
 section get
 
+/-- Check if a sum is `inl`. -/
+def isLeft : Sum α β → Bool
+  | inl _ => true
+  | inr _ => false
+#align sum.is_left Sum.isLeft
+
+/-- Check if a sum is `inr`. -/
+def isRight : Sum α β → Bool
+  | inl _ => false
+  | inr _ => true
+#align sum.is_right Sum.isRight
+
+/-- Retrieve the contents from a sum known to be `inl`.-/
+def getLeft : (ab : Sum α β) → ab.isLeft → α
+  | inl a, _ => a
+
+/-- Retrieve the contents from a sum known to be `inr`.-/
+def getRight : (ab : Sum α β) → ab.isRight → β
+  | inr b, _ => b
+
 /-- Check if a sum is `inl` and if so, retrieve its contents. -/
 def getLeft? : Sum α β → Option α
   | inl a => some a
@@ -91,29 +113,25 @@ def getRight? : Sum α β → Option β
   | inl _ => none
 #align sum.get_right Sum.getRight?
 
-/-- Check if a sum is `inl`. -/
-def isLeft : Sum α β → Bool
-  | inl _ => true
-  | inr _ => false
-#align sum.is_left Sum.isLeft
+variable {x y : Sum α β}
 
-/-- Check if a sum is `inr`. -/
-def isRight : Sum α β → Bool
-  | inl _ => false
-  | inr _ => true
-#align sum.is_right Sum.isRight
+@[simp] theorem isLeft_inl (x : α) : (inl x : α ⊕ β).isLeft = true := rfl
+@[simp] theorem isLeft_inr (x : β) : (inr x : α ⊕ β).isLeft = false := rfl
+@[simp] theorem isRight_inl (x : α) : (inl x : α ⊕ β).isRight = false := rfl
+@[simp] theorem isRight_inr (x : β) : (inr x : α ⊕ β).isRight = true := rfl
 
-variable {x y : Sum α β}
+@[simp] theorem getLeft_inl (x : α) (h : (inl x : α ⊕ β).isLeft) : (inl x).getLeft h = x := rfl
+@[simp] theorem getRight_inr (x : β) (h : (inr x : α ⊕ β).isRight) : (inr x).getRight h = x := rfl
 
 @[simp] theorem getLeft?_inl (x : α) : (inl x : α ⊕ β).getLeft? = some x := rfl
 @[simp] theorem getLeft?_inr (x : β) : (inr x : α ⊕ β).getLeft? = none := rfl
 @[simp] theorem getRight?_inl (x : α) : (inl x : α ⊕ β).getRight? = none := rfl
 @[simp] theorem getRight?_inr (x : β) : (inr x : α ⊕ β).getRight? = some x := rfl
 
-@[simp] theorem isLeft_inl (x : α) : (inl x : α ⊕ β).isLeft = true := rfl
-@[simp] theorem isLeft_inr (x : β) : (inr x : α ⊕ β).isLeft = false := rfl
-@[simp] theorem isRight_inl (x : α) : (inl x : α ⊕ β).isRight = false := rfl
-@[simp] theorem isRight_inr (x : β) : (inr x : α ⊕ β).isRight = true := rfl
+@[simp] theorem inl_getLeft : ∀ (x : α ⊕ β) (h : x.isLeft), inl (x.getLeft h) = x
+  | inl _, _ => rfl
+@[simp] theorem inr_getRight : ∀ (x : α ⊕ β) (h : x.isRight), inr (x.getRight h) = x
+  | inr _, _ => rfl
 
 @[simp] theorem getLeft?_eq_none_iff : x.getLeft? = none ↔ x.isRight := by
   cases x <;> simp only [getLeft?, isRight, eq_self_iff_true]
@@ -123,14 +141,38 @@ variable {x y : Sum α β}
   cases x <;> simp only [getRight?, isLeft, eq_self_iff_true]
 #align sum.get_right_eq_none_iff Sum.getRight?_eq_none_iff
 
-@[simp] lemma getLeft?_eq_some_iff {a : α} : x.getLeft? = a ↔ x = inl a := by
+theorem eq_left_getLeft_of_isLeft : ∀ {x : α ⊕ β} (h : x.isLeft), x = inl (x.getLeft h)
+  | inl _, _ => rfl
+
+theorem eq_left_iff_getLeft_eq {a : α} : x = inl a ↔ ∃ h, x.getLeft h = a := by
+  cases x <;> simp; exact fun c => c.elim
+
+@[simp] theorem getLeft_eq_iff {a : α} (h : x.isLeft) : x.getLeft h = a ↔ x = inl a := by
+  cases x <;> simp at h ⊢
+
+theorem eq_right_getRight_of_isRight : ∀ {x : α ⊕ β} (h : x.isRight), x = inr (x.getRight h)
+  | inr _, _ => rfl
+
+theorem eq_right_iff_getRight_eq {b : β} : x = inr b ↔ ∃ h, x.getRight h = b := by
+  cases x <;> simp; exact fun c => c.elim
+
+@[simp] theorem getRight_eq_iff {b : β} (h : x.isRight) : x.getRight h = b ↔ x = inr b := by
+  cases x <;> simp at h ⊢
+
+@[simp] theorem getLeft?_eq_some_iff {a : α} : x.getLeft? = some a ↔ x = inl a := by
   cases x <;> simp only [getLeft?, Option.some.injEq, inl.injEq]
 #align sum.get_left_eq_some_iff Sum.getLeft?_eq_some_iff
 
-@[simp] lemma getRight?_eq_some_iff {b : β} : x.getRight? = b ↔ x = inr b := by
+@[simp] theorem getRight?_eq_some_iff {b : β} : x.getRight? = some b ↔ x = inr b := by
   cases x <;> simp only [getRight?, Option.some.injEq, inr.injEq]
 #align sum.get_right_eq_some_iff Sum.getRight?_eq_some_iff
 
+theorem getLeft_eq_getLeft? (h₁ : x.isLeft) (h₂ : x.getLeft?.isSome) :
+x.getLeft h₁ = x.getLeft?.get h₂ := by simp [← getLeft?_eq_some_iff]
+
+theorem getRight_eq_getRight? (h₁ : x.isRight) (h₂ : x.getRight?.isSome) :
+x.getRight h₁ = x.getRight?.get h₂ := by simp [← getRight?_eq_some_iff]
+
 @[simp]
 theorem not_isLeft (x : Sum α β) : not x.isLeft = x.isRight := by cases x <;> rfl
 #align sum.bnot_is_left Sum.not_isLeft
@@ -159,6 +201,12 @@ theorem isLeft_iff : x.isLeft ↔ ∃ y, x = Sum.inl y := by cases x <;> simp
 theorem isRight_iff : x.isRight ↔ ∃ y, x = Sum.inr y := by cases x <;> simp
 #align sum.is_right_iff Sum.isRight_iff
 
+@[simp] theorem isSome_getLeft?_iff_isLeft : x.getLeft?.isSome ↔ x.isLeft := by
+rw [isLeft_iff, Option.isSome_iff_exists]; simp
+
+@[simp] theorem isSome_getRight?_iff_isRight : x.getRight?.isSome ↔ x.isRight := by
+rw [isRight_iff, Option.isSome_iff_exists]; simp
+
 end get
 
 theorem inl.inj_iff {a b} : (inl a : Sum α β) = inl b ↔ a = b :=
fix(Data/Sum/Basic): Add ? to Sum-get function names. (#6665)

As the getLeft and getRight functions are to Option, they should have a ? on the end.

Diff
@@ -16,9 +16,9 @@ This file proves basic results about the sum type `α ⊕ β`.
 
 ## Main declarations
 
-* `Sum.getLeft`: Retrieves the left content of `x : α ⊕ β` or returns `none` if it's coming from
+* `Sum.getLeft?`: Retrieves the left content of `x : α ⊕ β` or returns `none` if it's coming from
   the right.
-* `Sum.getRight`: Retrieves the right content of `x : α ⊕ β` or returns `none` if it's coming from
+* `Sum.getRight?`: Retrieves the right content of `x : α ⊕ β` or returns `none` if it's coming from
   the left.
 * `Sum.isLeft`: Returns whether `x : α ⊕ β` comes from the left component or not.
 * `Sum.isRight`: Returns whether `x : α ⊕ β` comes from the right component or not.
@@ -80,16 +80,16 @@ theorem inr_injective : Function.Injective (inr : β → Sum α β) := fun _ _ 
 section get
 
 /-- Check if a sum is `inl` and if so, retrieve its contents. -/
-def getLeft : Sum α β → Option α
+def getLeft? : Sum α β → Option α
   | inl a => some a
   | inr _ => none
-#align sum.get_left Sum.getLeft
+#align sum.get_left Sum.getLeft?
 
 /-- Check if a sum is `inr` and if so, retrieve its contents. -/
-def getRight : Sum α β → Option β
+def getRight? : Sum α β → Option β
   | inr b => some b
   | inl _ => none
-#align sum.get_right Sum.getRight
+#align sum.get_right Sum.getRight?
 
 /-- Check if a sum is `inl`. -/
 def isLeft : Sum α β → Bool
@@ -105,31 +105,31 @@ def isRight : Sum α β → Bool
 
 variable {x y : Sum α β}
 
-@[simp] theorem getLeft_inl (x : α) : (inl x : α ⊕ β).getLeft = some x := rfl
-@[simp] theorem getLeft_inr (x : β) : (inr x : α ⊕ β).getLeft = none := rfl
-@[simp] theorem getRight_inl (x : α) : (inl x : α ⊕ β).getRight = none := rfl
-@[simp] theorem getRight_inr (x : β) : (inr x : α ⊕ β).getRight = some x := rfl
+@[simp] theorem getLeft?_inl (x : α) : (inl x : α ⊕ β).getLeft? = some x := rfl
+@[simp] theorem getLeft?_inr (x : β) : (inr x : α ⊕ β).getLeft? = none := rfl
+@[simp] theorem getRight?_inl (x : α) : (inl x : α ⊕ β).getRight? = none := rfl
+@[simp] theorem getRight?_inr (x : β) : (inr x : α ⊕ β).getRight? = some x := rfl
 
 @[simp] theorem isLeft_inl (x : α) : (inl x : α ⊕ β).isLeft = true := rfl
 @[simp] theorem isLeft_inr (x : β) : (inr x : α ⊕ β).isLeft = false := rfl
 @[simp] theorem isRight_inl (x : α) : (inl x : α ⊕ β).isRight = false := rfl
 @[simp] theorem isRight_inr (x : β) : (inr x : α ⊕ β).isRight = true := rfl
 
-@[simp] theorem getLeft_eq_none_iff : x.getLeft = none ↔ x.isRight := by
-  cases x <;> simp only [getLeft, isRight, eq_self_iff_true]
-#align sum.get_left_eq_none_iff Sum.getLeft_eq_none_iff
+@[simp] theorem getLeft?_eq_none_iff : x.getLeft? = none ↔ x.isRight := by
+  cases x <;> simp only [getLeft?, isRight, eq_self_iff_true]
+#align sum.get_left_eq_none_iff Sum.getLeft?_eq_none_iff
 
-@[simp] theorem getRight_eq_none_iff : x.getRight = none ↔ x.isLeft := by
-  cases x <;> simp only [getRight, isLeft, eq_self_iff_true]
-#align sum.get_right_eq_none_iff Sum.getRight_eq_none_iff
+@[simp] theorem getRight?_eq_none_iff : x.getRight? = none ↔ x.isLeft := by
+  cases x <;> simp only [getRight?, isLeft, eq_self_iff_true]
+#align sum.get_right_eq_none_iff Sum.getRight?_eq_none_iff
 
-@[simp] lemma getLeft_eq_some_iff {a : α} : x.getLeft = a ↔ x = inl a := by
-  cases x <;> simp only [getLeft, Option.some.injEq, inl.injEq]
-#align sum.get_left_eq_some_iff Sum.getLeft_eq_some_iff
+@[simp] lemma getLeft?_eq_some_iff {a : α} : x.getLeft? = a ↔ x = inl a := by
+  cases x <;> simp only [getLeft?, Option.some.injEq, inl.injEq]
+#align sum.get_left_eq_some_iff Sum.getLeft?_eq_some_iff
 
-@[simp] lemma getRight_eq_some_iff {b : β} : x.getRight = b ↔ x = inr b := by
-  cases x <;> simp only [getRight, Option.some.injEq, inr.injEq]
-#align sum.get_right_eq_some_iff Sum.getRight_eq_some_iff
+@[simp] lemma getRight?_eq_some_iff {b : β} : x.getRight? = b ↔ x = inr b := by
+  cases x <;> simp only [getRight?, Option.some.injEq, inr.injEq]
+#align sum.get_right_eq_some_iff Sum.getRight?_eq_some_iff
 
 @[simp]
 theorem not_isLeft (x : Sum α β) : not x.isLeft = x.isRight := by cases x <;> rfl
@@ -271,15 +271,15 @@ theorem isRight_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isRight (x
 #align sum.is_right_map Sum.isRight_map
 
 @[simp]
-theorem getLeft_map (f : α → β) (g : γ → δ) (x : Sum α γ) :
-    (x.map f g).getLeft = x.getLeft.map f := by
+theorem getLeft?_map (f : α → β) (g : γ → δ) (x : Sum α γ) :
+    (x.map f g).getLeft? = x.getLeft?.map f := by
   cases x <;> rfl
-#align sum.get_left_map Sum.getLeft_map
+#align sum.get_left_map Sum.getLeft?_map
 
 @[simp]
-theorem getRight_map (f : α → β) (g : γ → δ) (x : α ⊕ γ) :
-    (x.map f g).getRight = x.getRight.map g := by cases x <;> rfl
-#align sum.get_right_map Sum.getRight_map
+theorem getRight?_map (f : α → β) (g : γ → δ) (x : α ⊕ γ) :
+    (x.map f g).getRight? = x.getRight?.map g := by cases x <;> rfl
+#align sum.get_right_map Sum.getRight?_map
 
 open Function (update update_eq_iff update_comp_eq_of_injective update_comp_eq_of_forall_ne)
 
@@ -384,12 +384,12 @@ theorem isRight_swap (x : Sum α β) : x.swap.isRight = x.isLeft := by cases x <
 #align sum.is_right_swap Sum.isRight_swap
 
 @[simp]
-theorem getLeft_swap (x : Sum α β) : x.swap.getLeft = x.getRight := by cases x <;> rfl
-#align sum.get_left_swap Sum.getLeft_swap
+theorem getLeft?_swap (x : Sum α β) : x.swap.getLeft? = x.getRight? := by cases x <;> rfl
+#align sum.get_left_swap Sum.getLeft?_swap
 
 @[simp]
-theorem getRight_swap (x : Sum α β) : x.swap.getRight = x.getLeft := by cases x <;> rfl
-#align sum.get_right_swap Sum.getRight_swap
+theorem getRight?_swap (x : Sum α β) : x.swap.getRight? = x.getLeft? := by cases x <;> rfl
+#align sum.get_right_swap Sum.getRight?_swap
 
 section LiftRel
 
feat(Data/Sum): forall_sum_pi (#6658)

Co-authored-by: Chris Hughes <33847686+ChrisHughes24@users.noreply.github.com>

Diff
@@ -59,6 +59,18 @@ theorem «exists» {p : Sum α β → Prop} : (∃ x, p x) ↔ (∃ a, p (inl a)
     | Or.inr ⟨b, h⟩ => ⟨inr b, h⟩⟩
 #align sum.exists Sum.exists
 
+theorem forall_sum_pi {γ : α ⊕ β → Sort*} (p : (∀ ab, γ ab) → Prop) :
+    (∀ fab, p fab) ↔ (∀ fa fb, p (Sum.rec fa fb)) :=
+  ⟨fun h fa fb => h _, fun h fab => by
+    have h1 : fab = Sum.rec (fun a => fab (Sum.inl a)) (fun b => fab (Sum.inr b)) := by
+      ext ab; cases ab <;> rfl
+    rw [h1]; exact h _ _⟩
+
+theorem exists_sum_pi {γ : α ⊕ β → Sort*} (p : (∀ ab, γ ab) → Prop) :
+    (∃ fab, p fab) ↔ (∃ fa fb, p (Sum.rec fa fb)) := by
+  rw [← not_forall_not, forall_sum_pi]
+  simp
+
 theorem inl_injective : Function.Injective (inl : α → Sum α β) := fun _ _ ↦ inl.inj
 #align sum.inl_injective Sum.inl_injective
 
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
@@ -29,7 +29,7 @@ This file proves basic results about the sum type `α ⊕ β`.
 
 ## Notes
 
-The definition of `Sum` takes values in `Type _`. This effectively forbids `Prop`- valued sum types.
+The definition of `Sum` takes values in `Type*`. This effectively forbids `Prop`- valued sum types.
 To this effect, we have `PSum`, which takes value in `Sort*` and carries a more complicated
 universe signature in consequence. The `Prop` version is `or`.
 -/
@@ -37,7 +37,7 @@ universe signature in consequence. The `Prop` version is `or`.
 
 universe u v w x
 
-variable {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} {γ δ : Type _}
+variable {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} {γ δ : Type*}
 
 namespace Sum
 
chore: ensure all instances referred to directly have explicit names (#6423)

Per https://github.com/leanprover/lean4/issues/2343, we are going to need to change the automatic generation of instance names, as they become too long.

This PR ensures that everywhere in Mathlib that refers to an instance by name, that name is given explicitly, rather than being automatically generated.

There are four exceptions, which are now commented, with links to https://github.com/leanprover/lean4/issues/2343.

This was implemented by running Mathlib against a modified Lean that appended _ᾰ to all automatically generated names, and fixing everything.

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

Diff
@@ -491,7 +491,7 @@ theorem lex_inr_inl : ¬Lex r s (inr b) (inl a) :=
   fun.
 #align sum.lex_inr_inl Sum.lex_inr_inl
 
-instance [DecidableRel r] [DecidableRel s] : DecidableRel (Lex r s)
+instance instDecidableRelSumLex [DecidableRel r] [DecidableRel s] : DecidableRel (Lex r s)
   | inl _, inl _ => decidable_of_iff' _ lex_inl_inl
   | inl _, inr _ => Decidable.isTrue (Lex.sep _ _)
   | inr _, inl _ => Decidable.isFalse lex_inr_inl
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,14 +2,11 @@
 Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro, Yury G. Kudryashov
-
-! This file was ported from Lean 3 source module data.sum.basic
-! leanprover-community/mathlib commit bd9851ca476957ea4549eb19b40e7b5ade9428cc
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.Logic.Function.Basic
 
+#align_import data.sum.basic from "leanprover-community/mathlib"@"bd9851ca476957ea4549eb19b40e7b5ade9428cc"
+
 /-!
 # Disjoint union of types
 
chore: formatting issues (#4947)

Co-authored-by: Scott Morrison <scott.morrison@anu.edu.au> Co-authored-by: Parcly Taxel <reddeloostw@gmail.com>

Diff
@@ -252,23 +252,24 @@ theorem elim_comp_map {α β γ δ ε : Sort _} {f₁ : α → β} {f₂ : β 
 #align sum.elim_comp_map Sum.elim_comp_map
 
 @[simp]
-theorem isLeft_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isLeft (x.map f g) = isLeft x :=
-by cases x <;> rfl
+theorem isLeft_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isLeft (x.map f g) = isLeft x := by
+  cases x <;> rfl
 #align sum.is_left_map Sum.isLeft_map
 
 @[simp]
-theorem isRight_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isRight (x.map f g) = isRight x :=
-by cases x <;> rfl
+theorem isRight_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isRight (x.map f g) = isRight x := by
+  cases x <;> rfl
 #align sum.is_right_map Sum.isRight_map
 
 @[simp]
-theorem getLeft_map (f : α → β) (g : γ → δ) (x : Sum α γ) : (x.map f g).getLeft = x.getLeft.map f :=
-by cases x <;> rfl
+theorem getLeft_map (f : α → β) (g : γ → δ) (x : Sum α γ) :
+    (x.map f g).getLeft = x.getLeft.map f := by
+  cases x <;> rfl
 #align sum.get_left_map Sum.getLeft_map
 
 @[simp]
 theorem getRight_map (f : α → β) (g : γ → δ) (x : α ⊕ γ) :
-  (x.map f g).getRight = x.getRight.map g := by cases x <;> rfl
+    (x.map f g).getRight = x.getRight.map g := by cases x <;> rfl
 #align sum.get_right_map Sum.getRight_map
 
 open Function (update update_eq_iff update_comp_eq_of_injective update_comp_eq_of_forall_ne)
@@ -386,8 +387,8 @@ section LiftRel
 /-- Lifts pointwise two relations between `α` and `γ` and between `β` and `δ` to a relation between
 `α ⊕ β` and `γ ⊕ δ`. -/
 inductive LiftRel (r : α → γ → Prop) (s : β → δ → Prop) : Sum α β → Sum γ δ → Prop
-| protected inl {a c} : r a c → LiftRel r s (inl a) (inl c)
-| protected inr {b d} : s b d → LiftRel r s (inr b) (inr d)
+  | protected inl {a c} : r a c → LiftRel r s (inl a) (inl c)
+  | protected inr {b d} : s b d → LiftRel r s (inr b) (inr d)
 #align sum.lift_rel Sum.LiftRel
 
 variable {r r₁ r₂ : α → γ → Prop} {s s₁ s₂ : β → δ → Prop} {a : α} {b : β} {c : γ} {d : δ}
feat: add Mathlib.Tactic.Common, and import (#4056)

This makes a mathlib4 version of mathlib3's tactic.basic, now called Mathlib.Tactic.Common, which imports all tactics which do not have significant theory requirements, and then is imported all across the base of the hierarchy.

This ensures that all common tactics are available nearly everywhere in the library, rather than having to be imported one-by-one as you need them.

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

Diff
@@ -9,7 +9,6 @@ Authors: Mario Carneiro, Yury G. Kudryashov
 ! if you have ported upstream changes.
 -/
 import Mathlib.Logic.Function.Basic
-import Mathlib.Mathport.Rename
 
 /-!
 # Disjoint union of types
Revert "feat: add Mathlib.Tactic.Common, and import"

This reverts commit 1ce2f69b.

Diff
@@ -9,7 +9,7 @@ Authors: Mario Carneiro, Yury G. Kudryashov
 ! if you have ported upstream changes.
 -/
 import Mathlib.Logic.Function.Basic
-import Mathlib.Tactic.Rename
+import Mathlib.Mathport.Rename
 
 /-!
 # Disjoint union of types
feat: add Mathlib.Tactic.Common, and import
Diff
@@ -9,7 +9,7 @@ Authors: Mario Carneiro, Yury G. Kudryashov
 ! if you have ported upstream changes.
 -/
 import Mathlib.Logic.Function.Basic
-import Mathlib.Mathport.Rename
+import Mathlib.Tactic.Rename
 
 /-!
 # Disjoint union of types
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
@@ -109,12 +109,10 @@ variable {x y : Sum α β}
 
 @[simp] theorem getLeft_eq_none_iff : x.getLeft = none ↔ x.isRight := by
   cases x <;> simp only [getLeft, isRight, eq_self_iff_true]
-
 #align sum.get_left_eq_none_iff Sum.getLeft_eq_none_iff
 
 @[simp] theorem getRight_eq_none_iff : x.getRight = none ↔ x.isLeft := by
   cases x <;> simp only [getRight, isLeft, eq_self_iff_true]
-
 #align sum.get_right_eq_none_iff Sum.getRight_eq_none_iff
 
 @[simp] lemma getLeft_eq_some_iff {a : α} : x.getLeft = a ↔ x = inl a := by
@@ -401,19 +399,16 @@ theorem liftRel_inl_inl : LiftRel r s (inl a) (inl c) ↔ r a c :=
   ⟨fun h ↦ by
     cases h
     assumption, LiftRel.inl⟩
-
 #align sum.lift_rel_inl_inl Sum.liftRel_inl_inl
 
 @[simp]
 theorem not_liftRel_inl_inr : ¬LiftRel r s (inl a) (inr d) :=
   fun.
-
 #align sum.not_lift_rel_inl_inr Sum.not_liftRel_inl_inr
 
 @[simp]
 theorem not_liftRel_inr_inl : ¬LiftRel r s (inr b) (inl c) :=
   fun.
-
 #align sum.not_lift_rel_inr_inl Sum.not_liftRel_inr_inl
 
 @[simp]
@@ -421,7 +416,6 @@ theorem liftRel_inr_inr : LiftRel r s (inr b) (inr d) ↔ s b d :=
   ⟨fun h ↦ by
     cases h
     assumption, LiftRel.inr⟩
-
 #align sum.lift_rel_inr_inr Sum.liftRel_inr_inr
 
 instance [∀ a c, Decidable (r a c)] [∀ b d, Decidable (s b d)] :
@@ -459,7 +453,6 @@ theorem liftRel_swap_iff : LiftRel s r x.swap y.swap ↔ LiftRel r s x y :=
   ⟨fun h ↦ by
     rw [← swap_swap x, ← swap_swap y]
     exact h.swap, LiftRel.swap⟩
-
 #align sum.lift_rel_swap_iff Sum.liftRel_swap_iff
 
 end LiftRel
@@ -514,7 +507,6 @@ protected theorem LiftRel.lex {a b : Sum α β} (h : LiftRel r s a b) : Lex r s
 #align sum.lift_rel.lex Sum.LiftRel.lex
 
 theorem liftRel_subrelation_lex : Subrelation (LiftRel r s) (Lex r s) := LiftRel.lex
-
 #align sum.lift_rel_subrelation_lex Sum.liftRel_subrelation_lex
 
 theorem Lex.mono (hr : ∀ a b, r₁ a b → r₂ a b) (hs : ∀ a b, s₁ a b → s₂ a b) (h : Lex r₁ s₁ x y) :
feat: forward-port leanprover-community/mathlib#18446 (#2346)

Co-authored-by: Jon Eugster <eugster.jon@gmail.com>

Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro, Yury G. Kudryashov
 
 ! This file was ported from Lean 3 source module data.sum.basic
-! leanprover-community/mathlib commit f4ecb599422baaf39055d8278c7d9ef3b5b72b88
+! leanprover-community/mathlib commit bd9851ca476957ea4549eb19b40e7b5ade9428cc
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -588,12 +588,47 @@ theorem Surjective.sum_map {f : α → β} {g : α' → β'} (hf : Surjective f)
     ⟨inr x, congr_arg inr hx⟩
 #align function.surjective.sum_map Function.Surjective.sum_map
 
+theorem Bijective.sum_map {f : α → β} {g : α' → β'} (hf : Bijective f) (hg : Bijective g) :
+    Bijective (Sum.map f g) :=
+  ⟨hf.injective.sum_map hg.injective, hf.surjective.sum_map hg.surjective⟩
+#align function.bijective.sum_map Function.Bijective.sum_map
+
 end Function
 
 namespace Sum
 
 open Function
 
+@[simp]
+theorem map_injective {f : α → γ} {g : β → δ} :
+    Injective (Sum.map f g) ↔ Injective f ∧ Injective g :=
+  ⟨fun h =>
+    ⟨fun a₁ a₂ ha => inl_injective <| @h (inl a₁) (inl a₂) (congr_arg inl ha : _), fun b₁ b₂ hb =>
+      inr_injective <| @h (inr b₁) (inr b₂) (congr_arg inr hb : _)⟩,
+    fun h => h.1.sum_map h.2⟩
+#align sum.map_injective Sum.map_injective
+
+@[simp]
+theorem map_surjective {f : α → γ} {g : β → δ} :
+    Surjective (Sum.map f g) ↔ Surjective f ∧ Surjective g :=
+  ⟨ fun h => ⟨
+      (fun c => by
+        obtain ⟨a | b, h⟩ := h (inl c)
+        · exact ⟨a, inl_injective h⟩
+        · cases h),
+      (fun d => by
+        obtain ⟨a | b, h⟩ := h (inr d)
+        · cases h
+        · exact ⟨b, inr_injective h⟩)⟩,
+    fun h => h.1.sum_map h.2⟩
+#align sum.map_surjective Sum.map_surjective
+
+@[simp]
+theorem map_bijective {f : α → γ} {g : β → δ} :
+    Bijective (Sum.map f g) ↔ Bijective f ∧ Bijective g :=
+  (map_injective.and map_surjective).trans <| and_and_and_comm
+#align sum.map_bijective Sum.map_bijective
+
 theorem elim_const_const (c : γ) :
     Sum.elim (const _ c : α → γ) (const _ c : β → γ) = const _ c := by
   ext x
chore: update SHA of already forward-ported files (#2181)

Update some SHAs of files that changed in mathlib3.

These 17 files need mainly only updated SHA as they've been only touched by backports or already have been forward-ported.

The relevant changes are:

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

Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro, Yury G. Kudryashov
 
 ! This file was ported from Lean 3 source module data.sum.basic
-! leanprover-community/mathlib commit d6aae1bcbd04b8de2022b9b83a5b5b10e10c777d
+! leanprover-community/mathlib commit f4ecb599422baaf39055d8278c7d9ef3b5b72b88
 ! 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
@@ -51,6 +51,7 @@ deriving instance BEq for Sum
 @[simp]
 theorem «forall» {p : Sum α β → Prop} : (∀ x, p x) ↔ (∀ a, p (inl a)) ∧ ∀ b, p (inr b) :=
   ⟨fun h ↦ ⟨fun _ ↦ h _, fun _ ↦ h _⟩, fun ⟨h₁, h₂⟩ ↦ Sum.rec h₁ h₂⟩
+#align sum.forall Sum.forall
 
 @[simp]
 theorem «exists» {p : Sum α β → Prop} : (∃ x, p x) ↔ (∃ a, p (inl a)) ∨ ∃ b, p (inr b) :=
@@ -60,10 +61,13 @@ theorem «exists» {p : Sum α β → Prop} : (∃ x, p x) ↔ (∃ a, p (inl a)
     fun
     | Or.inl ⟨a, h⟩ => ⟨inl a, h⟩
     | Or.inr ⟨b, h⟩ => ⟨inr b, h⟩⟩
+#align sum.exists Sum.exists
 
 theorem inl_injective : Function.Injective (inl : α → Sum α β) := fun _ _ ↦ inl.inj
+#align sum.inl_injective Sum.inl_injective
 
 theorem inr_injective : Function.Injective (inr : β → Sum α β) := fun _ _ ↦ inr.inj
+#align sum.inr_injective Sum.inr_injective
 
 section get
 
@@ -71,21 +75,25 @@ section get
 def getLeft : Sum α β → Option α
   | inl a => some a
   | inr _ => none
+#align sum.get_left Sum.getLeft
 
 /-- Check if a sum is `inr` and if so, retrieve its contents. -/
 def getRight : Sum α β → Option β
   | inr b => some b
   | inl _ => none
+#align sum.get_right Sum.getRight
 
 /-- Check if a sum is `inl`. -/
 def isLeft : Sum α β → Bool
   | inl _ => true
   | inr _ => false
+#align sum.is_left Sum.isLeft
 
 /-- Check if a sum is `inr`. -/
 def isRight : Sum α β → Bool
   | inl _ => false
   | inr _ => true
+#align sum.is_right Sum.isRight
 
 variable {x y : Sum α β}
 
@@ -157,68 +165,84 @@ theorem inr.inj_iff {a b} : (inr a : Sum α β) = inr b ↔ a = b :=
 
 theorem inl_ne_inr {a : α} {b : β} : inl a ≠ inr b :=
   fun.
+#align sum.inl_ne_inr Sum.inl_ne_inr
 
 theorem inr_ne_inl {a : α} {b : β} : inr b ≠ inl a :=
   fun.
+#align sum.inr_ne_inl Sum.inr_ne_inl
 
 /-- Define a function on `α ⊕ β` by giving separate definitions on `α` and `β`. -/
 protected def elim {α β γ : Sort _} (f : α → γ) (g : β → γ) : Sum α β → γ :=
   fun x ↦ Sum.casesOn x f g
+#align sum.elim Sum.elim
 
 @[simp]
 theorem elim_inl {α β γ : Sort _} (f : α → γ) (g : β → γ) (x : α) : Sum.elim f g (inl x) = f x :=
   rfl
+#align sum.elim_inl Sum.elim_inl
 
 @[simp]
 theorem elim_inr {α β γ : Sort _} (f : α → γ) (g : β → γ) (x : β) : Sum.elim f g (inr x) = g x :=
   rfl
+#align sum.elim_inr Sum.elim_inr
 
 @[simp]
 theorem elim_comp_inl {α β γ : Sort _} (f : α → γ) (g : β → γ) : Sum.elim f g ∘ inl = f :=
   rfl
+#align sum.elim_comp_inl Sum.elim_comp_inl
 
 @[simp]
 theorem elim_comp_inr {α β γ : Sort _} (f : α → γ) (g : β → γ) : Sum.elim f g ∘ inr = g :=
   rfl
+#align sum.elim_comp_inr Sum.elim_comp_inr
 
 @[simp]
 theorem elim_inl_inr {α β : Sort _} : @Sum.elim α β _ inl inr = id :=
   funext fun x ↦ Sum.casesOn x (fun _ ↦ rfl) fun _ ↦ rfl
+#align sum.elim_inl_inr Sum.elim_inl_inr
 
 theorem comp_elim {α β γ δ : Sort _} (f : γ → δ) (g : α → γ) (h : β → γ) :
     f ∘ Sum.elim g h = Sum.elim (f ∘ g) (f ∘ h) :=
   funext fun x ↦ Sum.casesOn x (fun _ ↦ rfl) fun _ ↦ rfl
+#align sum.comp_elim Sum.comp_elim
 
 @[simp]
 theorem elim_comp_inl_inr {α β γ : Sort _} (f : Sum α β → γ) : Sum.elim (f ∘ inl) (f ∘ inr) = f :=
   funext fun x ↦ Sum.casesOn x (fun _ ↦ rfl) fun _ ↦ rfl
+#align sum.elim_comp_inl_inr Sum.elim_comp_inl_inr
 
 /-- Map `α ⊕ β` to `α' ⊕ β'` sending `α` to `α'` and `β` to `β'`. -/
 protected def map (f : α → α') (g : β → β') : Sum α β → Sum α' β' :=
   Sum.elim (inl ∘ f) (inr ∘ g)
+#align sum.map Sum.map
 
 @[simp]
 theorem map_inl (f : α → α') (g : β → β') (x : α) : (inl x).map f g = inl (f x) :=
   rfl
+#align sum.map_inl Sum.map_inl
 
 @[simp]
 theorem map_inr (f : α → α') (g : β → β') (x : β) : (inr x).map f g = inr (g x) :=
   rfl
+#align sum.map_inr Sum.map_inr
 
 @[simp]
 theorem map_map {α'' β''} (f' : α' → α'') (g' : β' → β'') (f : α → α') (g : β → β') :
     ∀ x : Sum α β, (x.map f g).map f' g' = x.map (f' ∘ f) (g' ∘ g)
   | inl _ => rfl
   | inr _ => rfl
+#align sum.map_map Sum.map_map
 
 @[simp]
 theorem map_comp_map {α'' β''} (f' : α' → α'') (g' : β' → β'') (f : α → α') (g : β → β') :
     Sum.map f' g' ∘ Sum.map f g = Sum.map (f' ∘ f) (g' ∘ g) :=
   funext <| map_map f' g' f g
+#align sum.map_comp_map Sum.map_comp_map
 
 @[simp]
 theorem map_id_id (α β) : Sum.map (@id α) (@id β) = id :=
   funext fun x ↦ Sum.recOn x (fun _ ↦ rfl) fun _ ↦ rfl
+#align sum.map_id_id Sum.map_id_id
 
 theorem elim_map {α β γ δ ε : Sort _} {f₁ : α → β} {f₂ : β → ε} {g₁ : γ → δ} {g₂ : δ → ε} {x} :
     Sum.elim f₂ g₂ (Sum.map f₁ g₁ x) = Sum.elim (f₂ ∘ f₁) (g₂ ∘ g₁) x := by
@@ -228,6 +252,7 @@ theorem elim_map {α β γ δ ε : Sort _} {f₁ : α → β} {f₂ : β → ε}
 theorem elim_comp_map {α β γ δ ε : Sort _} {f₁ : α → β} {f₂ : β → ε} {g₁ : γ → δ} {g₂ : δ → ε} :
     Sum.elim f₂ g₂ ∘ Sum.map f₁ g₁ = Sum.elim (f₂ ∘ f₁) (g₂ ∘ g₁) :=
   funext $ fun _ => elim_map
+#align sum.elim_comp_map Sum.elim_comp_map
 
 @[simp]
 theorem isLeft_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isLeft (x.map f g) = isLeft x :=
@@ -255,76 +280,93 @@ open Function (update update_eq_iff update_comp_eq_of_injective update_comp_eq_o
 theorem update_elim_inl [DecidableEq α] [DecidableEq (Sum α β)] {f : α → γ} {g : β → γ} {i : α}
     {x : γ} : update (Sum.elim f g) (inl i) x = Sum.elim (update f i x) g :=
   update_eq_iff.2 ⟨by simp, by simp (config := { contextual := true })⟩
+#align sum.update_elim_inl Sum.update_elim_inl
 
 @[simp]
 theorem update_elim_inr [DecidableEq β] [DecidableEq (Sum α β)] {f : α → γ} {g : β → γ} {i : β}
     {x : γ} : update (Sum.elim f g) (inr i) x = Sum.elim f (update g i x) :=
   update_eq_iff.2 ⟨by simp, by simp (config := { contextual := true })⟩
+#align sum.update_elim_inr Sum.update_elim_inr
 
 @[simp]
 theorem update_inl_comp_inl [DecidableEq α] [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : α}
     {x : γ} : update f (inl i) x ∘ inl = update (f ∘ inl) i x :=
   update_comp_eq_of_injective _ inl_injective _ _
+#align sum.update_inl_comp_inl Sum.update_inl_comp_inl
 
 @[simp]
 theorem update_inl_apply_inl [DecidableEq α] [DecidableEq (Sum α β)] {f : Sum α β → γ} {i j : α}
     {x : γ} : update f (inl i) x (inl j) = update (f ∘ inl) i x j := by
   rw [← update_inl_comp_inl, Function.comp_apply]
+#align sum.update_inl_apply_inl Sum.update_inl_apply_inl
 
 @[simp]
 theorem update_inl_comp_inr [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : α} {x : γ} :
     update f (inl i) x ∘ inr = f ∘ inr :=
   (update_comp_eq_of_forall_ne _ _) fun _ ↦ inr_ne_inl
+#align sum.update_inl_comp_inr Sum.update_inl_comp_inr
 
 theorem update_inl_apply_inr [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : α} {j : β} {x : γ} :
     update f (inl i) x (inr j) = f (inr j) :=
   Function.update_noteq inr_ne_inl _ _
+#align sum.update_inl_apply_inr Sum.update_inl_apply_inr
 
 @[simp]
 theorem update_inr_comp_inl [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : β} {x : γ} :
     update f (inr i) x ∘ inl = f ∘ inl :=
   (update_comp_eq_of_forall_ne _ _) fun _ ↦ inl_ne_inr
+#align sum.update_inr_comp_inl Sum.update_inr_comp_inl
 
 theorem update_inr_apply_inl [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : α} {j : β} {x : γ} :
     update f (inr j) x (inl i) = f (inl i) :=
   Function.update_noteq inl_ne_inr _ _
+#align sum.update_inr_apply_inl Sum.update_inr_apply_inl
 
 @[simp]
 theorem update_inr_comp_inr [DecidableEq β] [DecidableEq (Sum α β)] {f : Sum α β → γ} {i : β}
     {x : γ} : update f (inr i) x ∘ inr = update (f ∘ inr) i x :=
   update_comp_eq_of_injective _ inr_injective _ _
+#align sum.update_inr_comp_inr Sum.update_inr_comp_inr
 
 @[simp]
 theorem update_inr_apply_inr [DecidableEq β] [DecidableEq (Sum α β)] {f : Sum α β → γ} {i j : β}
     {x : γ} : update f (inr i) x (inr j) = update (f ∘ inr) i x j := by
   rw [← update_inr_comp_inr, Function.comp_apply]
+#align sum.update_inr_apply_inr Sum.update_inr_apply_inr
 
 /-- Swap the factors of a sum type -/
 def swap : Sum α β → Sum β α :=
   Sum.elim inr inl
+#align sum.swap Sum.swap
 
 @[simp]
 theorem swap_inl (x : α) : swap (inl x : Sum α β) = inr x :=
   rfl
+#align sum.swap_inl Sum.swap_inl
 
 @[simp]
 theorem swap_inr (x : β) : swap (inr x : Sum α β) = inl x :=
   rfl
+#align sum.swap_inr Sum.swap_inr
 
 @[simp]
 theorem swap_swap (x : Sum α β) : swap (swap x) = x := by cases x <;> rfl
+#align sum.swap_swap Sum.swap_swap
 
 @[simp]
 theorem swap_swap_eq : swap ∘ swap = @id (Sum α β) :=
   funext <| swap_swap
+#align sum.swap_swap_eq Sum.swap_swap_eq
 
 @[simp]
 theorem swap_leftInverse : Function.LeftInverse (@swap α β) swap :=
   swap_swap
+#align sum.swap_left_inverse Sum.swap_leftInverse
 
 @[simp]
 theorem swap_rightInverse : Function.RightInverse (@swap α β) swap :=
   swap_swap
+#align sum.swap_right_inverse Sum.swap_rightInverse
 
 @[simp]
 theorem isLeft_swap (x : Sum α β) : x.swap.isLeft = x.isRight := by cases x <;> rfl
@@ -349,6 +391,7 @@ section LiftRel
 inductive LiftRel (r : α → γ → Prop) (s : β → δ → Prop) : Sum α β → Sum γ δ → Prop
 | protected inl {a c} : r a c → LiftRel r s (inl a) (inl c)
 | protected inr {b d} : s b d → LiftRel r s (inr b) (inr d)
+#align sum.lift_rel Sum.LiftRel
 
 variable {r r₁ r₂ : α → γ → Prop} {s s₁ s₂ : β → δ → Prop} {a : α} {b : β} {c : γ} {d : δ}
   {x : Sum α β} {y : Sum γ δ}
@@ -393,19 +436,23 @@ theorem LiftRel.mono (hr : ∀ a b, r₁ a b → r₂ a b) (hs : ∀ a b, s₁ a
   cases h
   · exact LiftRel.inl (hr _ _ ‹_›)
   · exact LiftRel.inr (hs _ _ ‹_›)
+#align sum.lift_rel.mono Sum.LiftRel.mono
 
 theorem LiftRel.mono_left (hr : ∀ a b, r₁ a b → r₂ a b) (h : LiftRel r₁ s x y) :
     LiftRel r₂ s x y :=
   (h.mono hr) fun _ _ ↦ id
+#align sum.lift_rel.mono_left Sum.LiftRel.mono_left
 
 theorem LiftRel.mono_right (hs : ∀ a b, s₁ a b → s₂ a b) (h : LiftRel r s₁ x y) :
     LiftRel r s₂ x y :=
   h.mono (fun _ _ ↦ id) hs
+#align sum.lift_rel.mono_right Sum.LiftRel.mono_right
 
 protected theorem LiftRel.swap (h : LiftRel r s x y) : LiftRel s r x.swap y.swap := by
   cases h
   · exact LiftRel.inr ‹_›
   · exact LiftRel.inl ‹_›
+#align sum.lift_rel.swap Sum.LiftRel.swap
 
 @[simp]
 theorem liftRel_swap_iff : LiftRel s r x.swap y.swap ↔ LiftRel r s x y :=
@@ -428,6 +475,7 @@ inductive Lex (r : α → α → Prop) (s : β → β → Prop) : Sum α β →
 #align sum.lex.inl Sum.Lex.inl
 #align sum.lex.inr Sum.Lex.inr
 #align sum.lex.sep Sum.Lex.sep
+#align sum.lex Sum.Lex
 
 attribute [simp] Lex.sep
 
@@ -439,16 +487,19 @@ theorem lex_inl_inl : Lex r s (inl a₁) (inl a₂) ↔ r a₁ a₂ :=
   ⟨fun h ↦ by
     cases h
     assumption, Lex.inl⟩
+#align sum.lex_inl_inl Sum.lex_inl_inl
 
 @[simp]
 theorem lex_inr_inr : Lex r s (inr b₁) (inr b₂) ↔ s b₁ b₂ :=
   ⟨fun h ↦ by
     cases h
     assumption, Lex.inr⟩
+#align sum.lex_inr_inr Sum.lex_inr_inr
 
 @[simp]
 theorem lex_inr_inl : ¬Lex r s (inr b) (inl a) :=
   fun.
+#align sum.lex_inr_inl Sum.lex_inr_inl
 
 instance [DecidableRel r] [DecidableRel s] : DecidableRel (Lex r s)
   | inl _, inl _ => decidable_of_iff' _ lex_inl_inl
@@ -460,6 +511,7 @@ protected theorem LiftRel.lex {a b : Sum α β} (h : LiftRel r s a b) : Lex r s
   cases h
   · exact Lex.inl ‹_›
   · exact Lex.inr ‹_›
+#align sum.lift_rel.lex Sum.LiftRel.lex
 
 theorem liftRel_subrelation_lex : Subrelation (LiftRel r s) (Lex r s) := LiftRel.lex
 
@@ -471,12 +523,15 @@ theorem Lex.mono (hr : ∀ a b, r₁ a b → r₂ a b) (hs : ∀ a b, s₁ a b 
   · exact Lex.inl (hr _ _ ‹_›)
   · exact Lex.inr (hs _ _ ‹_›)
   · exact Lex.sep _ _
+#align sum.lex.mono Sum.Lex.mono
 
 theorem Lex.mono_left (hr : ∀ a b, r₁ a b → r₂ a b) (h : Lex r₁ s x y) : Lex r₂ s x y :=
   (h.mono hr) fun _ _ ↦ id
+#align sum.lex.mono_left Sum.Lex.mono_left
 
 theorem Lex.mono_right (hs : ∀ a b, s₁ a b → s₂ a b) (h : Lex r s₁ x y) : Lex r s₂ x y :=
   h.mono (fun _ _ ↦ id) hs
+#align sum.lex.mono_right Sum.Lex.mono_right
 
 theorem lex_acc_inl {a} (aca : Acc r a) : Acc (Lex r s) (inl a) := by
   induction' aca with a _ IH
@@ -484,6 +539,7 @@ theorem lex_acc_inl {a} (aca : Acc r a) : Acc (Lex r s) (inl a) := by
   intro y h
   cases' h with a' _ h'
   exact IH _ h'
+#align sum.lex_acc_inl Sum.lex_acc_inl
 
 theorem lex_acc_inr (aca : ∀ a, Acc (Lex r s) (inl a)) {b} (acb : Acc s b) :
     Acc (Lex r s) (inr b) := by
@@ -493,10 +549,12 @@ theorem lex_acc_inr (aca : ∀ a, Acc (Lex r s) (inl a)) {b} (acb : Acc s b) :
   cases' h with _ _ _ b' _ h' a
   · exact IH _ h'
   · exact aca _
+#align sum.lex_acc_inr Sum.lex_acc_inr
 
 theorem lex_wf (ha : WellFounded r) (hb : WellFounded s) : WellFounded (Lex r s) :=
   have aca : ∀ a, Acc (Lex r s) (inl a) := fun a ↦ lex_acc_inl (ha.apply a)
   ⟨fun x ↦ Sum.recOn x aca fun b ↦ lex_acc_inr aca (hb.apply b)⟩
+#align sum.lex_wf Sum.lex_wf
 
 end Lex
 
@@ -512,11 +570,13 @@ theorem Injective.sum_elim {f : α → γ} {g : β → γ} (hf : Injective f) (h
   | inl _, inr _, h => (hfg _ _ h).elim
   | inr _, inl _, h => (hfg _ _ h.symm).elim
   | inr _, inr _, h => congr_arg inr <| hg h
+#align function.injective.sum_elim Function.Injective.sum_elim
 
 theorem Injective.sum_map {f : α → β} {g : α' → β'} (hf : Injective f) (hg : Injective g) :
     Injective (Sum.map f g)
   | inl _, inl _, h => congr_arg inl <| hf <| inl.inj h
   | inr _, inr _, h => congr_arg inr <| hg <| inr.inj h
+#align function.injective.sum_map Function.Injective.sum_map
 
 theorem Surjective.sum_map {f : α → β} {g : α' → β'} (hf : Surjective f) (hg : Surjective g) :
     Surjective (Sum.map f g)
@@ -526,6 +586,7 @@ theorem Surjective.sum_map {f : α → β} {g : α' → β'} (hf : Surjective f)
   | inr y =>
     let ⟨x, hx⟩ := hg y
     ⟨inr x, congr_arg inr hx⟩
+#align function.surjective.sum_map Function.Surjective.sum_map
 
 end Function
 
@@ -537,11 +598,13 @@ theorem elim_const_const (c : γ) :
     Sum.elim (const _ c : α → γ) (const _ c : β → γ) = const _ c := by
   ext x
   cases x <;> rfl
+#align sum.elim_const_const Sum.elim_const_const
 
 @[simp]
 theorem elim_lam_const_lam_const (c : γ) :
     (Sum.elim (fun _ : α ↦ c) fun _ : β ↦ c) = fun _ ↦ c :=
   Sum.elim_const_const c
+#align sum.elim_lam_const_lam_const Sum.elim_lam_const_lam_const
 
 theorem elim_update_left [DecidableEq α] [DecidableEq β] (f : α → γ) (g : β → γ) (i : α) (c : γ) :
     Sum.elim (Function.update f i c) g = Function.update (Sum.elim f g) (inl i) c := by
@@ -552,6 +615,7 @@ theorem elim_update_left [DecidableEq α] [DecidableEq β] (f : α → γ) (g :
       simp
     · simp [h]
   · simp
+#align sum.elim_update_left Sum.elim_update_left
 
 theorem elim_update_right [DecidableEq α] [DecidableEq β] (f : α → γ) (g : β → γ) (i : β) (c : γ) :
     Sum.elim f (Function.update g i c) = Function.update (Sum.elim f g) (inr i) c := by
@@ -562,6 +626,7 @@ theorem elim_update_right [DecidableEq α] [DecidableEq β] (f : α → γ) (g :
     · subst h
       simp
     · simp [h]
+#align sum.elim_update_right Sum.elim_update_right
 
 end Sum
 
@@ -577,15 +642,18 @@ namespace Sum3
 @[match_pattern, simp, reducible]
 def in₀ (a : α) : Sum α (Sum β γ) :=
   inl a
+#align sum3.in₀ Sum3.in₀
 
 /-- The map from the second summand into a ternary sum. -/
 @[match_pattern, simp, reducible]
 def in₁ (b : β) : Sum α (Sum β γ) :=
   inr <| inl b
+#align sum3.in₁ Sum3.in₁
 
 /-- The map from the third summand into a ternary sum. -/
 @[match_pattern, simp, reducible]
 def in₂ (c : γ) : Sum α (Sum β γ) :=
   inr <| inr c
+#align sum3.in₂ Sum3.in₂
 
 end Sum3
chore: Rename Type* to Type _ (#1866)

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

Diff
@@ -33,7 +33,7 @@ This file proves basic results about the sum type `α ⊕ β`.
 
 ## Notes
 
-The definition of `Sum` takes values in `Type*`. This effectively forbids `Prop`- valued sum types.
+The definition of `Sum` takes values in `Type _`. This effectively forbids `Prop`- valued sum types.
 To this effect, we have `PSum`, which takes value in `Sort*` and carries a more complicated
 universe signature in consequence. The `Prop` version is `or`.
 -/
Feat: add lemmas about Sum (#1583)

This is the Lean 4 version of leanprover-community/mathlib#18184

Diff
@@ -99,16 +99,24 @@ variable {x y : Sum α β}
 @[simp] theorem isRight_inl (x : α) : (inl x : α ⊕ β).isRight = false := rfl
 @[simp] theorem isRight_inr (x : β) : (inr x : α ⊕ β).isRight = true := rfl
 
-theorem getLeft_eq_none_iff : x.getLeft = none ↔ x.isRight := by
+@[simp] theorem getLeft_eq_none_iff : x.getLeft = none ↔ x.isRight := by
   cases x <;> simp only [getLeft, isRight, eq_self_iff_true]
 
 #align sum.get_left_eq_none_iff Sum.getLeft_eq_none_iff
 
-theorem getRight_eq_none_iff : x.getRight = none ↔ x.isLeft := by
+@[simp] theorem getRight_eq_none_iff : x.getRight = none ↔ x.isLeft := by
   cases x <;> simp only [getRight, isLeft, eq_self_iff_true]
 
 #align sum.get_right_eq_none_iff Sum.getRight_eq_none_iff
 
+@[simp] lemma getLeft_eq_some_iff {a : α} : x.getLeft = a ↔ x = inl a := by
+  cases x <;> simp only [getLeft, Option.some.injEq, inl.injEq]
+#align sum.get_left_eq_some_iff Sum.getLeft_eq_some_iff
+
+@[simp] lemma getRight_eq_some_iff {b : β} : x.getRight = b ↔ x = inr b := by
+  cases x <;> simp only [getRight, Option.some.injEq, inr.injEq]
+#align sum.get_right_eq_some_iff Sum.getRight_eq_some_iff
+
 @[simp]
 theorem not_isLeft (x : Sum α β) : not x.isLeft = x.isRight := by cases x <;> rfl
 #align sum.bnot_is_left Sum.not_isLeft
@@ -212,8 +220,14 @@ theorem map_comp_map {α'' β''} (f' : α' → α'') (g' : β' → β'') (f : α
 theorem map_id_id (α β) : Sum.map (@id α) (@id β) = id :=
   funext fun x ↦ Sum.recOn x (fun _ ↦ rfl) fun _ ↦ rfl
 
+theorem elim_map {α β γ δ ε : Sort _} {f₁ : α → β} {f₂ : β → ε} {g₁ : γ → δ} {g₂ : δ → ε} {x} :
+    Sum.elim f₂ g₂ (Sum.map f₁ g₁ x) = Sum.elim (f₂ ∘ f₁) (g₂ ∘ g₁) x := by
+  cases x <;> rfl
+#align sum.elim_map Sum.elim_map
+
 theorem elim_comp_map {α β γ δ ε : Sort _} {f₁ : α → β} {f₂ : β → ε} {g₁ : γ → δ} {g₂ : δ → ε} :
-    Sum.elim f₂ g₂ ∘ Sum.map f₁ g₁ = Sum.elim (f₂ ∘ f₁) (g₂ ∘ g₁) := by ext (_ | _) <;> rfl
+    Sum.elim f₂ g₂ ∘ Sum.map f₁ g₁ = Sum.elim (f₂ ∘ f₁) (g₂ ∘ g₁) :=
+  funext $ fun _ => elim_map
 
 @[simp]
 theorem isLeft_map (f : α → β) (g : γ → δ) (x : Sum α γ) : isLeft (x.map f g) = isLeft x :=
feat: refactor of solve_by_elim (#856)

This is a thorough refactor of solve_by_elim.

  • Bug fixes and additional tests.
  • Support for removing local hypotheses using solve_by_elim [-h].
  • Use symm on hypotheses and exfalso on the goal, as needed.
  • To support that, MetaM level tooling for the symm tactic. (rfl and trans deserve the same treatment at some point.)
  • Additional hooks for flow control in solve_by_elim (suspending goals to return to the user, rejecting branches, running arbitrary procedures on the goals).
  • Using those hooks, reimplement apply_assumption and apply_rules as thin wrappers around solve_by_elim, allowing access to new features (removing hypotheses, symm and exfalso) for free.
  • Using those hooks, fix library_search using so example (P Q : List ℕ) (h : ℕ) : List ℕ := by library_search using P, Q -- exact P ∩ Q

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

Diff
@@ -46,6 +46,7 @@ variable {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} {γ δ : Type
 namespace Sum
 
 deriving instance DecidableEq for Sum
+deriving instance BEq for Sum
 
 @[simp]
 theorem «forall» {p : Sum α β → Prop} : (∀ x, p x) ↔ (∀ a, p (inl a)) ∧ ∀ b, p (inr b) :=
chore: fix more casing errors per naming scheme (#1232)

I've avoided anything under Tactic or test.

In correcting the names, I found Option.isNone_iff_eq_none duplicated between Std and Mathlib, so the Mathlib one has been removed.

Co-authored-by: Reid Barton <rwbarton@gmail.com>

Diff
@@ -304,11 +304,11 @@ theorem swap_swap_eq : swap ∘ swap = @id (Sum α β) :=
   funext <| swap_swap
 
 @[simp]
-theorem swap_left_inverse : Function.LeftInverse (@swap α β) swap :=
+theorem swap_leftInverse : Function.LeftInverse (@swap α β) swap :=
   swap_swap
 
 @[simp]
-theorem swap_right_inverse : Function.RightInverse (@swap α β) swap :=
+theorem swap_rightInverse : Function.RightInverse (@swap α β) swap :=
   swap_swap
 
 @[simp]
chore: add source headers to ported theory files (#1094)

The script used to do this is included. The yaml file was obtained from https://raw.githubusercontent.com/wiki/leanprover-community/mathlib/mathlib4-port-status.md

Diff
@@ -2,6 +2,11 @@
 Copyright (c) 2017 Mario Carneiro. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Mario Carneiro, Yury G. Kudryashov
+
+! This file was ported from Lean 3 source module data.sum.basic
+! leanprover-community/mathlib commit d6aae1bcbd04b8de2022b9b83a5b5b10e10c777d
+! Please do not edit these lines, except to modify the commit id
+! if you have ported upstream changes.
 -/
 import Mathlib.Logic.Function.Basic
 import Mathlib.Mathport.Rename

Dependencies

1 files ported (100.0%)
470 lines ported (100.0%)

All dependencies are ported!