Built with
doc-gen4 , running Lean4.
Bubbles (
) indicate interactive fragments: hover for details, tap to reveal contents.
Use
Ctrl+↑ Ctrl+↓ to navigate,
Ctrl+🖱️ to focus.
On Mac, use
Cmd instead of
Ctrl .
/-
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
/-!
# Disjoint union of 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.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.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`.
-/
universe u v w x
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» : ∀ {α : Type u} {β : Type v} {p : α ⊕ β → Prop }, (∀ (x : α ⊕ β ), p x ) ↔ (∀ (a : α ), p (inl a ) ) ∧ ∀ (b : β ), p (inr b ) «forall» { p : Sum α β → Prop } : (∀ x , p x ) ↔ (∀ a , p ( inl : {α : Type ?u.2049} → {β : Type ?u.2048} → α → α ⊕ β inl a )) ∧ ∀ b , p ( inr : {α : Type ?u.2060} → {β : Type ?u.2059} → β → α ⊕ β inr b ) :=
⟨ fun h ↦ ⟨ fun _ ↦ h _ , fun _ ↦ h _ ⟩, fun ⟨ h₁ , h₂ ⟩ ↦ Sum.rec : ∀ {α : Type ?u.2134} {β : Type ?u.2133} {motive : α ⊕ β → Sort ?u.2135 },
(∀ (val : α ), motive (inl val ) ) → (∀ (val : β ), motive (inr val ) ) → ∀ (t : α ⊕ β ), motive t Sum.rec h₁ h₂ ⟩
#align sum.forall Sum.forall : ∀ {α : Type u} {β : Type v} {p : α ⊕ β → Prop }, (∀ (x : α ⊕ β ), p x ) ↔ (∀ (a : α ), p (inl a ) ) ∧ ∀ (b : β ), p (inr b ) Sum.forall
@[ simp ]
theorem «exists» { p : Sum α β → Prop } : (∃ x , p x ) ↔ (∃ a , p ( inl : {α : Type ?u.2312} → {β : Type ?u.2311} → α → α ⊕ β inl a )) ∨ ∃ b , p ( inr : {α : Type ?u.2325} → {β : Type ?u.2324} → β → α ⊕ β inr b ) :=
⟨ fun
| ⟨ inl : {α : Type ?u.2345} → {β : Type ?u.2344} → α → α ⊕ β inl a , h ⟩ => Or.inl : ∀ {a b : Prop }, a → a ∨ b Or.inl ⟨ a , h ⟩
| ⟨ inr : {α : Type ?u.2405} → {β : Type ?u.2404} → β → α ⊕ β inr b , h ⟩ => Or.inr : ∀ {a b : Prop }, b → a ∨ b Or.inr ⟨ b , h ⟩,
fun
| Or.inl : ∀ {a b : Prop }, a → a ∨ b Or.inl ⟨ a , h ⟩ => ⟨ inl : {α : Type ?u.2634} → {β : Type ?u.2633} → α → α ⊕ β inl a , h ⟩
| Or.inr : ∀ {a b : Prop }, b → a ∨ b Or.inr ⟨ b , h ⟩ => ⟨ inr : {α : Type ?u.2686} → {β : Type ?u.2685} → β → α ⊕ β inr b , h ⟩⟩
#align sum.exists Sum.exists : ∀ {α : Type u} {β : Type v} {p : α ⊕ β → Prop }, (∃ x , p x ) ↔ (∃ a , p (inl a ) ) ∨ ∃ b , p (inr b ) Sum.exists
theorem inl_injective : Function.Injective : {α : Sort ?u.2878} → {β : Sort ?u.2877} → (α → β ) → Prop Function.Injective ( inl : {α : Type ?u.2887} → {β : Type ?u.2886} → α → α ⊕ β inl : α → Sum α β ) := fun _ _ ↦ inl.inj : ∀ {α : Type ?u.2904} {β : Type ?u.2903} {val val_1 : α }, inl val = inl val_1 → val = val_1 inl.inj
#align sum.inl_injective Sum.inl_injective
theorem inr_injective : Function.Injective : {α : Sort ?u.2943} → {β : Sort ?u.2942} → (α → β ) → Prop Function.Injective ( inr : {α : Type ?u.2952} → {β : Type ?u.2951} → β → α ⊕ β inr : β → Sum α β ) := fun _ _ ↦ inr.inj : ∀ {α : Type ?u.2969} {β : Type ?u.2968} {val val_1 : β }, inr val = inr val_1 → val = val_1 inr.inj
#align sum.inr_injective Sum.inr_injective
section get
/-- Check if a sum is `inl` and if so, retrieve its contents. -/
def getLeft : Sum α β → Option α
| inl : {α : Type ?u.3017} → {β : Type ?u.3016} → α → α ⊕ β inl a => some a
| inr : {α : Type ?u.3040} → {β : Type ?u.3039} → β → α ⊕ β 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 : {α : Type ?u.3246} → {β : Type ?u.3245} → β → α ⊕ β inr b => some b
| inl : {α : Type ?u.3269} → {β : Type ?u.3268} → α → α ⊕ β inl _ => none
#align sum.get_right Sum.getRight
/-- Check if a sum is `inl`. -/
def isLeft : Sum α β → Bool
| inl : {α : Type ?u.3468} → {β : Type ?u.3467} → α → α ⊕ β inl _ => true
| inr : {α : Type ?u.3489} → {β : Type ?u.3488} → β → α ⊕ β inr _ => false
#align sum.is_left Sum.isLeft
/-- Check if a sum is `inr`. -/
def isRight : Sum α β → Bool
| inl : {α : Type ?u.3671} → {β : Type ?u.3670} → α → α ⊕ β inl _ => false
| inr : {α : Type ?u.3692} → {β : Type ?u.3691} → β → α ⊕ β inr _ => true
#align sum.is_right Sum.isRight
variable { x y : Sum α β }
@[ simp ] theorem getLeft_inl ( x : α ) : ( inl : {α : Type ?u.3902} → {β : Type ?u.3901} → α → α ⊕ β inl x : α ⊕ β ). getLeft = some x := rfl : ∀ {α : Sort ?u.3920} {a : α }, a = a rfl
@[ simp ] theorem getLeft_inr ( x : β ) : ( inr : {α : Type ?u.3981} → {β : Type ?u.3980} → β → α ⊕ β inr x : α ⊕ β ). getLeft = none := rfl : ∀ {α : Sort ?u.4026} {a : α }, a = a rfl
@[ simp ] theorem getRight_inl ( x : α ) : ( inl : {α : Type ?u.4087} → {β : Type ?u.4086} → α → α ⊕ β inl x : α ⊕ β ). getRight = none := rfl : ∀ {α : Sort ?u.4132} {a : α }, a = a rfl
@[ simp ] theorem getRight_inr ( x : β ) : ( inr : {α : Type ?u.4193} → {β : Type ?u.4192} → β → α ⊕ β inr x : α ⊕ β ). getRight = some x := rfl : ∀ {α : Sort ?u.4211} {a : α }, a = a rfl
@[ simp ] theorem isLeft_inl ( x : α ) : ( inl : {α : Type ?u.4272} → {β : Type ?u.4271} → α → α ⊕ β inl x : α ⊕ β ). isLeft = true := rfl : ∀ {α : Sort ?u.4287} {a : α }, a = a rfl
@[ simp ] theorem isLeft_inr ( x : β ) : ( inr : {α : Type ?u.4348} → {β : Type ?u.4347} → β → α ⊕ β inr x : α ⊕ β ). isLeft = false := rfl : ∀ {α : Sort ?u.4363} {a : α }, a = a rfl
@[ simp ] theorem isRight_inl ( x : α ) : ( inl : {α : Type ?u.4424} → {β : Type ?u.4423} → α → α ⊕ β inl x : α ⊕ β ). isRight = false := rfl : ∀ {α : Sort ?u.4439} {a : α }, a = a rfl
@[ simp ] theorem isRight_inr ( x : β ) : ( inr : {α : Type ?u.4500} → {β : Type ?u.4499} → β → α ⊕ β inr x : α ⊕ β ). isRight = true := rfl : ∀ {α : Sort ?u.4515} {a : α }, a = a rfl
@[ simp ] theorem getLeft_eq_none_iff : x . getLeft = none ↔ x . isRight := by
cases x <;> simp only [ getLeft , isRight , eq_self_iff_true : ∀ {α : Sort ?u.4784} (a : α ), a = a ↔ True 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 : ∀ {α : Sort ?u.5293} (a : α ), a = a ↔ True 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 : {α : Type ?u.5576} → {β : Type ?u.5575} → α → α ⊕ β inl a := by
cases x <;> simp only [ getLeft , Option.some.injEq : ∀ {α : Type ?u.5695} (val val_1 : α ), (some val = some val_1 ) = (val = val_1 ) Option.some.injEq, inl.injEq : ∀ {α : Type ?u.5710} {β : Type ?u.5709} (val val_1 : α ), (inl val = inl val_1 ) = (val = val_1 ) 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 : {α : Type ?u.6096} → {β : Type ?u.6095} → β → α ⊕ β inr b := by
cases x <;> simp only [ getRight , Option.some.injEq : ∀ {α : Type ?u.6215} (val val_1 : α ), (some val = some val_1 ) = (val = val_1 ) Option.some.injEq, inr.injEq : ∀ {α : Type ?u.6230} {β : Type ?u.6229} (val val_1 : β ), (inr val = inr val_1 ) = (val = val_1 ) 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
@[ simp ]
theorem isLeft_eq_false : x . isLeft = false ↔ x . isRight := by cases x <;> simp
#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.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 : {α : Type ?u.8224} → {β : Type ?u.8223} → α → α ⊕ β Sum.inl y := by cases x <;> simp
#align sum.is_left_iff Sum.isLeft_iff
theorem isRight_iff : x . isRight ↔ ∃ y , x = Sum.inr : {α : Type ?u.8909} → {β : Type ?u.8908} → β → α ⊕ β Sum.inr y := by cases x <;> simp
#align sum.is_right_iff Sum.isRight_iff
end get
theorem inl.inj_iff { a b } : ( inl : {α : Type ?u.9500} → {β : Type ?u.9499} → α → α ⊕ β inl a : Sum α β ) = inl : {α : Type ?u.9506} → {β : Type ?u.9505} → α → α ⊕ β inl b ↔ a = b :=
⟨ inl.inj : ∀ {α : Type ?u.9554} {β : Type ?u.9553} {val val_1 : α }, inl val = inl val_1 → val = val_1 inl.inj, congr_arg : ∀ {α : Sort ?u.9572} {β : Sort ?u.9571} {a₁ a₂ : α } (f : α → β ), a₁ = a₂ → f a₁ = f a₂ congr_arg _ ⟩
#align sum.inl.inj_iff Sum.inl.inj_iff
theorem inr.inj_iff { a b } : ( inr : {α : Type ?u.9612} → {β : Type ?u.9611} → β → α ⊕ β inr a : Sum α β ) = inr : {α : Type ?u.9618} → {β : Type ?u.9617} → β → α ⊕ β inr b ↔ a = b :=
⟨ inr.inj : ∀ {α : Type ?u.9666} {β : Type ?u.9665} {val val_1 : β }, inr val = inr val_1 → val = val_1 inr.inj, congr_arg : ∀ {α : Sort ?u.9684} {β : Sort ?u.9683} {a₁ a₂ : α } (f : α → β ), a₁ = a₂ → f a₁ = f a₂ congr_arg _ ⟩
#align sum.inr.inj_iff Sum.inr.inj_iff
theorem inl_ne_inr : ∀ {a : α } {b : β }, inl a ≠ inr b inl_ne_inr { a : α } { b : β } : inl : {α : Type ?u.9720} → {β : Type ?u.9719} → α → α ⊕ β inl a ≠ inr : {α : Type ?u.9726} → {β : Type ?u.9725} → β → α ⊕ β inr b :=
fun .
#align sum.inl_ne_inr Sum.inl_ne_inr
theorem inr_ne_inl : ∀ {a : α } {b : β }, inr b ≠ inl a inr_ne_inl { a : α } { b : β } : inr : {α : Type ?u.9845} → {β : Type ?u.9844} → β → α ⊕ β inr b ≠ inl : {α : Type ?u.9851} → {β : Type ?u.9850} → α → α ⊕ β 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 : {α : Type u_1} → {β : Type u_2} → {γ : Sort u_3} → (α → γ ) → (β → γ ) → α ⊕ β → γ elim { α β γ : Sort _ } ( f : α → γ ) ( g : β → γ ) : Sum α β → γ :=
fun x ↦ Sum.casesOn : {α : Type ?u.9994} →
{β : Type ?u.9993} →
{motive : α ⊕ β → Sort ?u.9995 } →
(t : α ⊕ β ) → ((val : α ) → motive (inl val ) ) → ((val : β ) → motive (inr val ) ) → motive t Sum.casesOn x f g
#align sum.elim Sum.elim : {α : Type u_1} → {β : Type u_2} → {γ : Sort u_3} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim
@[ simp ]
theorem elim_inl { α β γ : Sort _ } ( f : α → γ ) ( g : β → γ ) ( x : α ) : Sum.elim : {α : Type ?u.10188} → {β : Type ?u.10187} → {γ : Sort ?u.10186} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim f g ( inl : {α : Type ?u.10199} → {β : Type ?u.10198} → α → α ⊕ β inl x ) = f x :=
rfl : ∀ {α : Sort ?u.10212} {a : α }, a = a rfl
#align sum.elim_inl Sum.elim_inl : ∀ {α : Type u_1} {β : Type u_2} {γ : Sort u_3} (f : α → γ ) (g : β → γ ) (x : α ), Sum.elim f g (inl x ) = f x Sum.elim_inl
@[ simp ]
theorem elim_inr { α β γ : Sort _ } ( f : α → γ ) ( g : β → γ ) ( x : β ) : Sum.elim : {α : Type ?u.10286} → {β : Type ?u.10285} → {γ : Sort ?u.10284} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim f g ( inr : {α : Type ?u.10297} → {β : Type ?u.10296} → β → α ⊕ β inr x ) = g x :=
rfl : ∀ {α : Sort ?u.10310} {a : α }, a = a rfl
#align sum.elim_inr Sum.elim_inr : ∀ {α : Type u_1} {β : Type u_2} {γ : Sort u_3} (f : α → γ ) (g : β → γ ) (x : β ), Sum.elim f g (inr x ) = g x Sum.elim_inr
@[ simp ]
theorem elim_comp_inl { α β γ : Sort _ } ( f : α → γ ) ( g : β → γ ) : Sum.elim : {α : Type ?u.10388} → {β : Type ?u.10387} → {γ : Sort ?u.10386} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim f g ∘ inl : {α : Type ?u.10406} → {β : Type ?u.10405} → α → α ⊕ β inl = f :=
rfl : ∀ {α : Sort ?u.10422} {a : α }, a = a rfl
#align sum.elim_comp_inl Sum.elim_comp_inl : ∀ {α : Type u_1} {β : Type u_2} {γ : Sort u_3} (f : α → γ ) (g : β → γ ), Sum.elim f g ∘ inl = f Sum.elim_comp_inl
@[ simp ]
theorem elim_comp_inr { α β γ : Sort _ } ( f : α → γ ) ( g : β → γ ) : Sum.elim : {α : Type ?u.10509} → {β : Type ?u.10508} → {γ : Sort ?u.10507} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim f g ∘ inr : {α : Type ?u.10527} → {β : Type ?u.10526} → β → α ⊕ β inr = g :=
rfl : ∀ {α : Sort ?u.10543} {a : α }, a = a rfl
#align sum.elim_comp_inr Sum.elim_comp_inr : ∀ {α : Type u_1} {β : Type u_2} {γ : Sort u_3} (f : α → γ ) (g : β → γ ), Sum.elim f g ∘ inr = g Sum.elim_comp_inr
@[ simp ]
theorem elim_inl_inr { α β : Sort _ } : @ Sum.elim : {α : Type ?u.10613} → {β : Type ?u.10612} → {γ : Sort ?u.10611} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim α β _ inl : {α : Type ?u.10616} → {β : Type ?u.10615} → α → α ⊕ β inl inr : {α : Type ?u.10625} → {β : Type ?u.10624} → β → α ⊕ β inr = id : {α : Sort ?u.10633} → α → α id :=
funext : ∀ {α : Sort ?u.10677} {β : α → Sort ?u.10676 } {f g : (x : α ) → β x }, (∀ (x : α ), f x = g x ) → f = g funext fun x ↦ Sum.casesOn : ∀ {α : Type ?u.10694} {β : Type ?u.10693} {motive : α ⊕ β → Sort ?u.10695 } (t : α ⊕ β ),
(∀ (val : α ), motive (inl val ) ) → (∀ (val : β ), motive (inr val ) ) → motive t Sum.casesOn x ( fun _ ↦ rfl : ∀ {α : Sort ?u.10740} {a : α }, a = a rfl) fun _ ↦ rfl : ∀ {α : Sort ?u.10748} {a : α }, a = a rfl
#align sum.elim_inl_inr Sum.elim_inl_inr
theorem comp_elim { α β γ δ : Sort _ } ( f : γ → δ ) ( g : α → γ ) ( h : β → γ ) :
f ∘ Sum.elim : {α : Type ?u.10828} → {β : Type ?u.10827} → {γ : Sort ?u.10826} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim g h = Sum.elim : {α : Type ?u.10848} → {β : Type ?u.10847} → {γ : Sort ?u.10846} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim ( f ∘ g ) ( f ∘ h ) :=
funext : ∀ {α : Sort ?u.10899} {β : α → Sort ?u.10898 } {f g : (x : α ) → β x }, (∀ (x : α ), f x = g x ) → f = g funext fun x ↦ Sum.casesOn : ∀ {α : Type ?u.10916} {β : Type ?u.10915} {motive : α ⊕ β → Sort ?u.10917 } (t : α ⊕ β ),
(∀ (val : α ), motive (inl val ) ) → (∀ (val : β ), motive (inr val ) ) → motive t Sum.casesOn x ( fun _ ↦ rfl : ∀ {α : Sort ?u.10965} {a : α }, a = a rfl) fun _ ↦ rfl : ∀ {α : Sort ?u.10974} {a : α }, a = a rfl
#align sum.comp_elim Sum.comp_elim
@[ simp ]
theorem elim_comp_inl_inr { α β γ : Sort _ } ( f : Sum : Type ?u.11020 → Type ?u.11019 → Type (max?u.11020?u.11019) Sum α β → γ ) : Sum.elim : {α : Type ?u.11027} → {β : Type ?u.11026} → {γ : Sort ?u.11025} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim ( f ∘ inl : {α : Type ?u.11043} → {β : Type ?u.11042} → α → α ⊕ β inl) ( f ∘ inr : {α : Type ?u.11066} → {β : Type ?u.11065} → β → α ⊕ β inr) = f :=
funext : ∀ {α : Sort ?u.11085} {β : α → Sort ?u.11084 } {f g : (x : α ) → β x }, (∀ (x : α ), f x = g x ) → f = g funext fun x ↦ Sum.casesOn : ∀ {α : Type ?u.11102} {β : Type ?u.11101} {motive : α ⊕ β → Sort ?u.11103 } (t : α ⊕ β ),
(∀ (val : α ), motive (inl val ) ) → (∀ (val : β ), motive (inr val ) ) → motive t Sum.casesOn x ( fun _ ↦ rfl : ∀ {α : Sort ?u.11151} {a : α }, a = a rfl) fun _ ↦ rfl : ∀ {α : Sort ?u.11159} {a : α }, a = a rfl
#align sum.elim_comp_inl_inr Sum.elim_comp_inl_inr
/-- Map `α ⊕ β` to `α' ⊕ β'` sending `α` to `α'` and `β` to `β'`. -/
protected def map : {α : Type u} → {α' : Type w} → {β : Type v} → {β' : Type x} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' map ( f : α → α' ) ( g : β → β' ) : Sum : Type ?u.11234 → Type ?u.11233 → Type (max?u.11234?u.11233) Sum α β → Sum : Type ?u.11237 → Type ?u.11236 → Type (max?u.11237?u.11236) Sum α' β' :=
Sum.elim : {α : Type ?u.11243} → {β : Type ?u.11242} → {γ : Sort ?u.11241} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim ( inl : {α : Type ?u.11260} → {β : Type ?u.11259} → α → α ⊕ β inl ∘ f ) ( inr : {α : Type ?u.11283} → {β : Type ?u.11282} → β → α ⊕ β inr ∘ g )
#align sum.map Sum.map : {α : Type u} → {α' : Type w} → {β : Type v} → {β' : Type x} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' Sum.map
@[ simp ]
theorem map_inl ( f : α → α' ) ( g : β → β' ) ( x : α ) : ( inl : {α : Type ?u.11438} → {β : Type ?u.11437} → α → α ⊕ β inl x ). map : {α : Type ?u.11444} →
{α' : Type ?u.11442} → {β : Type ?u.11443} → {β' : Type ?u.11441} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' map f g = inl : {α : Type ?u.11465} → {β : Type ?u.11464} → α → α ⊕ β inl ( f x ) :=
rfl : ∀ {α : Sort ?u.11505} {a : α }, a = a rfl
#align sum.map_inl Sum.map_inl
@[ simp ]
theorem map_inr ( f : α → α' ) ( g : β → β' ) ( x : β ) : ( inr : {α : Type ?u.11573} → {β : Type ?u.11572} → β → α ⊕ β inr x ). map : {α : Type ?u.11579} →
{α' : Type ?u.11577} → {β : Type ?u.11578} → {β' : Type ?u.11576} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' map f g = inr : {α : Type ?u.11600} → {β : Type ?u.11599} → β → α ⊕ β inr ( g x ) :=
rfl : ∀ {α : Sort ?u.11640} {a : α }, a = a rfl
#align sum.map_inr Sum.map_inr
@[ simp ]
theorem map_map { α'' β'' } ( f' : α' → α'' ) ( g' : β' → β'' ) ( f : α → α' ) ( g : β → β' ) :
∀ x : Sum : Type ?u.11720 → Type ?u.11719 → Type (max?u.11720?u.11719) Sum α β , ( x . map : {α : Type ?u.11727} →
{α' : Type ?u.11725} → {β : Type ?u.11726} → {β' : Type ?u.11724} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' map f g ). map : {α : Type ?u.11750} →
{α' : Type ?u.11748} → {β : Type ?u.11749} → {β' : Type ?u.11747} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' map f' g' = x . map : {α : Type ?u.11773} →
{α' : Type ?u.11771} → {β : Type ?u.11772} → {β' : Type ?u.11770} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' map ( f' ∘ f ) ( g' ∘ g )
| inl : {α : Type ?u.11833} → {β : Type ?u.11832} → α → α ⊕ β inl _ => rfl : ∀ {α : Sort ?u.11853} {a : α }, a = a rfl
| inr : {α : Type ?u.11938} → {β : Type ?u.11937} → β → α ⊕ β inr _ => rfl : ∀ {α : Sort ?u.11956} {a : α }, a = a rfl
#align sum.map_map Sum.map_map
@[ simp ]
theorem map_comp_map { α'' β'' } ( f' : α' → α'' ) ( g' : β' → β'' ) ( f : α → α' ) ( g : β → β' ) :
Sum.map : {α : Type ?u.12158} →
{α' : Type ?u.12156} → {β : Type ?u.12157} → {β' : Type ?u.12155} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' Sum.map f' g' ∘ Sum.map : {α : Type ?u.12181} →
{α' : Type ?u.12179} → {β : Type ?u.12180} → {β' : Type ?u.12178} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' Sum.map f g = Sum.map : {α : Type ?u.12203} →
{α' : Type ?u.12201} → {β : Type ?u.12202} → {β' : Type ?u.12200} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' Sum.map ( f' ∘ f ) ( g' ∘ g ) :=
funext : ∀ {α : Sort ?u.12254} {β : α → Sort ?u.12253 } {f g : (x : α ) → β x }, (∀ (x : α ), f x = g x ) → f = g funext <| map_map : ∀ {α : Type ?u.12270} {α' : Type ?u.12268} {β : Type ?u.12269} {β' : Type ?u.12267} {α'' : Type ?u.12271}
{β'' : Type ?u.12272} (f' : α' → α'' ) (g' : β' → β'' ) (f : α → α' ) (g : β → β' ) (x : α ⊕ β ),
Sum.map f' g' (Sum.map f g x ) = Sum.map (f' ∘ f ) (g' ∘ g ) x map_map f' g' f g
#align sum.map_comp_map Sum.map_comp_map
@[ simp ]
theorem map_id_id ( α β ) : Sum.map : {α : Type ?u.12392} →
{α' : Type ?u.12390} → {β : Type ?u.12391} → {β' : Type ?u.12389} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' Sum.map (@ id : {α : Sort ?u.12397} → α → α id α ) (@ id : {α : Sort ?u.12400} → α → α id β ) = id : {α : Sort ?u.12404} → α → α id :=
funext : ∀ {α : Sort ?u.12450} {β : α → Sort ?u.12449 } {f g : (x : α ) → β x }, (∀ (x : α ), f x = g x ) → f = g funext fun x ↦ Sum.recOn : ∀ {α : Type ?u.12467} {β : Type ?u.12466} {motive : α ⊕ β → Sort ?u.12468 } (t : α ⊕ β ),
(∀ (val : α ), motive (inl val ) ) → (∀ (val : β ), motive (inr val ) ) → motive t Sum.recOn x ( fun _ ↦ rfl : ∀ {α : Sort ?u.12513} {a : α }, a = a rfl) fun _ ↦ rfl : ∀ {α : Sort ?u.12524} {a : α }, a = a rfl
#align sum.map_id_id Sum.map_id_id
theorem elim_map { α β γ δ ε : Sort _ } { f₁ : α → β } { f₂ : β → ε } { g₁ : γ → δ } { g₂ : δ → ε } { x } :
Sum.elim : {α : Type ?u.12605} → {β : Type ?u.12604} → {γ : Sort ?u.12603} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim f₂ g₂ ( Sum.map : {α : Type ?u.12618} →
{α' : Type ?u.12616} → {β : Type ?u.12617} → {β' : Type ?u.12615} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' Sum.map f₁ g₁ x ) = Sum.elim : {α : Type ?u.12635} → {β : Type ?u.12634} → {γ : Sort ?u.12633} → (α → γ ) → (β → γ ) → α ⊕ β → γ 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 : {α : Type ?u.12848} → {β : Type ?u.12847} → {γ : Sort ?u.12846} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim f₂ g₂ ∘ Sum.map : {α : Type ?u.12868} →
{α' : Type ?u.12866} → {β : Type ?u.12867} → {β' : Type ?u.12865} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' Sum.map f₁ g₁ = Sum.elim : {α : Type ?u.12889} → {β : Type ?u.12888} → {γ : Sort ?u.12887} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim ( f₂ ∘ f₁ ) ( g₂ ∘ g₁ ) :=
funext : ∀ {α : Sort ?u.12942} {β : α → Sort ?u.12941 } {f g : (x : α ) → β x }, (∀ (x : α ), f x = g x ) → f = g funext $ fun _ => elim_map : ∀ {α : Type ?u.12958} {β : Type ?u.12959} {γ : Type ?u.12960} {δ : Type ?u.12961} {ε : Sort ?u.12962} {f₁ : α → β }
{f₂ : β → ε } {g₁ : γ → δ } {g₂ : δ → ε } {x : α ⊕ γ }, Sum.elim f₂ g₂ (Sum.map f₁ g₁ x ) = Sum.elim (f₂ ∘ f₁ ) (g₂ ∘ g₁ ) x elim_map
#align sum.elim_comp_map Sum.elim_comp_map
@[ simp ]
theorem isLeft_map ( f : α → β ) ( g : γ → δ ) ( x : Sum : Type ?u.13051 → Type ?u.13050 → Type (max?u.13051?u.13050) Sum α γ ) : isLeft ( x . map : {α : Type ?u.13062} →
{α' : Type ?u.13060} → {β : Type ?u.13061} → {β' : Type ?u.13059} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' 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 : Type ?u.13269 → Type ?u.13268 → Type (max?u.13269?u.13268) Sum α γ ) : isRight : {α : Type ?u.13274} → {β : Type ?u.13273} → α ⊕ β → Bool isRight ( x . map : {α : Type ?u.13280} →
{α' : Type ?u.13278} → {β : Type ?u.13279} → {β' : Type ?u.13277} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' map f g ) = isRight : {α : Type ?u.13305} → {β : Type ?u.13304} → α ⊕ β → Bool isRight x :=
by cases x <;> rfl
#align sum.is_right_map Sum.isRight_map
@[ simp ]
theorem getLeft_map ( f : α → β ) ( g : γ → δ ) ( x : Sum : Type ?u.13487 → Type ?u.13486 → Type (max?u.13487?u.13486) Sum α γ ) : ( x . map : {α : Type ?u.13494} →
{α' : Type ?u.13492} → {β : Type ?u.13493} → {β' : Type ?u.13491} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' 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 : {α : Type ?u.13724} →
{α' : Type ?u.13722} → {β : Type ?u.13723} → {β' : Type ?u.13721} → (α → α' ) → (β → β' ) → α ⊕ β → α' ⊕ β' 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)
@[ simp ]
theorem update_elim_inl [ DecidableEq : Sort ?u.13938 → Sort (max1?u.13938) DecidableEq α ] [ DecidableEq : Sort ?u.13947 → Sort (max1?u.13947) DecidableEq ( Sum : Type ?u.13949 → Type ?u.13948 → Type (max?u.13949?u.13948) Sum α β )] { f : α → γ } { g : β → γ } { i : α }
{ x : γ } : update : {α : Sort ?u.13972} →
{β : α → Sort ?u.13971 } → [inst : DecidableEq α ] → ((a : α ) → β a ) → (a' : α ) → β a' → (a : α ) → β a update ( Sum.elim : {α : Type ?u.13978} → {β : Type ?u.13977} → {γ : Sort ?u.13976} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim f g ) ( inl : {α : Type ?u.14000} → {β : Type ?u.13999} → α → α ⊕ β inl i ) x = Sum.elim : {α : Type ?u.14056} → {β : Type ?u.14055} → {γ : Sort ?u.14054} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim ( update : {α : Sort ?u.14061} →
{β : α → Sort ?u.14060 } → [inst : DecidableEq α ] → ((a : α ) → β a ) → (a' : α ) → β a' → (a : α ) → β a update f i x ) g :=
update_eq_iff : ∀ {α : Sort ?u.14177} {β : α → Sort ?u.14176 } [inst : DecidableEq α ] {a : α } {b : β a } {f g : (a : α ) → β a },
update f a b = g ↔ b = g a ∧ ∀ (x : α ), x ≠ a → f x = g x update_eq_iff. 2 : ∀ {a b : Prop }, (a ↔ b ) → b → a 2 ⟨ by simp , by simp ( config := { contextual := true }) ⟩
#align sum.update_elim_inl Sum.update_elim_inl
@[ simp ]
theorem update_elim_inr [ DecidableEq : Sort ?u.16305 → Sort (max1?u.16305) DecidableEq β ] [ DecidableEq : Sort ?u.16314 → Sort (max1?u.16314) DecidableEq ( Sum : Type ?u.16316 → Type ?u.16315 → Type (max?u.16316?u.16315) Sum α β )] { f : α → γ } { g : β → γ } { i : β }
{ x : γ } : update : {α : Sort ?u.16339} →
{β : α → Sort ?u.16338 } → [inst : DecidableEq α ] → ((a : α ) → β a ) → (a' : α ) → β a' → (a : α ) → β a update ( Sum.elim : {α : Type ?u.16345} → {β : Type ?u.16344} → {γ : Sort ?u.16343} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim f g ) ( inr : {α : Type ?u.16367} → {β : Type ?u.16366} → β → α ⊕ β inr i ) x = Sum.elim : {α : Type ?u.16423} → {β : Type ?u.16422} → {γ : Sort ?u.16421} → (α → γ ) → (β → γ ) → α ⊕ β → γ Sum.elim f ( update : {α : Sort ?u.16431} →
{β : α → Sort ?u.16430 } → [inst : DecidableEq α ] → ((a : α ) → β a ) → (a' : α ) → β a' → (a : α ) → β a update g i x ) :=
update_eq_iff : ∀ {α : Sort ?u.16543} {β : α → Sort ?u.16542 } [inst : DecidableEq α ] {a : α } {b : β a } {f g : (a : α ) → β a },
update f a b = g ↔ b = g a ∧ ∀ (x : α ), x ≠ a → f x = g x update_eq_iff. 2 : ∀ {a b : Prop }, (a ↔ b ) → b → a 2 ⟨ by simp , by simp ( config := { contextual := true }) ⟩
#align sum.update_elim_inr Sum.update_elim_inr
@[ simp ]
theorem update_inl_comp_inl [ DecidableEq : Sort ?u.18671 → Sort (max1?u.18671) DecidableEq α ] [ DecidableEq : Sort ?u.18680 → Sort (max1?u.18680) DecidableEq ( Sum : Type ?u.18682 → Type ?u.18681 → Type (max?u.18682?u.18681) Sum α β )] { f : Sum : Type ?u.18693 → Type ?u.18692 → Type (max?u.18693?u.18692) Sum α β → γ } { i : α }
{ x : γ } : update : {α : Sort ?u.18709} →
{β : α → Sort ?u.18708 } → [inst : DecidableEq α ] → ((a : α ) → β a ) → (a' : α ) → β a' → (a : α ) → β a update f ( inl : {α : Type ?u.18763} → {β : Type ?u.18762} → α → α ⊕ β inl i ) x ∘ inl : {α : Type ?u.18824} → {β : Type ?u.18823} → α → α ⊕ β inl = update : {α : Sort ?u.18832} →
{β : α → Sort ?u.18831 } → [inst : DecidableEq α ] → ((a : α ) → β a ) → (a' : α ) → β a' → (a : α ) → β a update ( f ∘ inl : {α : Type ?u.18852} → {β : Type ?u.18851} → α → α ⊕ β 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 : Sort ?u.19216 → Sort (max1?u.19216) DecidableEq α ] [ DecidableEq : Sort ?u.19225 → Sort (max1?u.19225) DecidableEq ( Sum : Type ?u.19227 → Type ?u.19226 → Type (max?u.19227?u.19226) Sum α β )] { f : Sum : Type ?u.19238 → Type ?u.19237 → Type (max?u.19238?u.19237) Sum α β → γ } { i j : α }
{ x : γ } : update : {α : Sort ?u.19250} →
{β : α → Sort ?u.19249 } → [inst : DecidableEq α ] → ((a : α ) → β a ) → (a' : α ) → β a' → (a : α ) → β a update f ( inl : {α : Type ?u.19262} → {β : Type ?u.19261} → α → α ⊕ β inl i ) x ( inl : {α : Type ?u.19266} → {β : Type ?u.19265} → α → α ⊕ β inl j ) = update : {α : Sort ?u.19325} →
{β : α → Sort ?u.19324 } → [inst : DecidableEq α ] → ((a : α ) → β a ) → (a' : α ) → β a' → (a : α ) → β a update ( f ∘ inl : {α : Type ?u.19345} → {β : Type ?u.19344} → α → α ⊕ β inl) i x j := by
rw [ ← update_inl_comp_inl , Function.comp_apply : ∀ {β : Sort ?u.19676} {δ : Sort ?u.19677} {α : Sort ?u.19678} {f : β → δ } {g : α → β } {x : α }, (f ∘ g ) x = f (g x ) Function.comp_apply]
#align sum.update_inl_apply_inl Sum.update_inl_apply_inl
@[ simp ]
theorem update_inl_comp_inr [ DecidableEq : Sort ?u.19792 → Sort (max1?u.19792) DecidableEq ( Sum : Type ?u.19794 → Type ?u.19793 → Type (max?u.19794?u.19793) Sum α β )] { f : Sum : Type ?u.19805 → Type ?u.19804 → Type (max?u.19805?u.19804) Sum α β → γ } { i : α } { x : γ } :
update : {α : Sort ?u.19821} →
{β : α → Sort ?u.19820 } → [inst : DecidableEq α ] → ((a : α ) → β a ) → (a' : α ) → β a' → (a : α ) → β a update f ( inl : {α : Type ?u.19873} → {β : Type ?u.19872} → α → α ⊕ β inl i ) x ∘ inr : {α : Type ?u.19932} → {β : Type ?u.19931} → β → α ⊕ β inr = f ∘ inr : {α : Type ?u.19949} → {β : Type ?u.19948} → β → α ⊕ β inr :=
( update_comp_eq_of_forall_ne : ∀ {α' : Sort ?u.19966} [inst : DecidableEq α' ] {α : Sort ?u.19967} {β : Sort ?u.19968} (g : α' → β ) {f : α → α' }
{i : α' } (a : β ), (∀ (x : α ), f x ≠ i ) → update g i a ∘ f = g ∘ f update_comp_eq_of_forall_ne _ _ ) fun _ ↦ inr_ne_inl : ∀ {α : Type ?u.20052} {β : Type ?u.20051} {a : α } {b : β }, inr b ≠ inl a inr_ne_inl
#align sum.update_inl_comp_inr Sum.update_inl_comp_inr
theorem update_inl_apply_inr [ DecidableEq : Sort ?u.20169 → Sort (max1?u.20169) DecidableEq ( Sum : Type ?u.20171 → Type ?u.20170 → Type (max?u.20171?u.20170) Sum α β )] { f : Sum : Type ?u.20182 → Type ?u.20181 → Type (max?u.20182?u.20181) Sum α β → γ } { i : α } { j : β } { x : γ } :
update : {α : Sort ?u.20194} →
{β : α → Sort ?u.20193 } → [inst : DecidableEq α ] → ((a : α ) → β a ) → (a' : α ) → β a' → (a : α ) → β a update f ( inl : {α : Type ?u.20206} → {β : Type ?u.20205} → α → α ⊕ β inl i ) x (