mathlib documentation

data.sum

More theorems about the sum type

@[simp]
def sum.get_left {α : Type u_1} {β : Type u_2} (a : α β) :

Check if a sum is inl and if so, retrieve its contents.

Equations
@[simp]
def sum.get_right {α : Type u_1} {β : Type u_2} (a : α β) :

Check if a sum is inr and if so, retrieve its contents.

Equations
@[simp]
def sum.is_left {α : Type u_1} {β : Type u_2} (a : α β) :

Check if a sum is inl.

Equations
@[simp]
def sum.is_right {α : Type u_1} {β : Type u_2} (a : α β) :

Check if a sum is inr.

Equations
@[simp]
theorem sum.forall {α : Type u} {β : Type v} {p : α β → Prop} :
(∀ (x : α β), p x) (∀ (a : α), p (sum.inl a)) ∀ (b : β), p (sum.inr b)

@[simp]
theorem sum.exists {α : Type u} {β : Type v} {p : α β → Prop} :
(∃ (x : α β), p x) (∃ (a : α), p (sum.inl a)) ∃ (b : β), p (sum.inr b)

def sum.map {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} (f : α → α') (g : β → β') (a : α β) :
α' β'

Map α ⊕ β to α' ⊕ β' sending α to α' and β to β'.

Equations
@[simp]
theorem sum.map_inl {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} (f : α → α') (g : β → β') (x : α) :
sum.map f g (sum.inl x) = sum.inl (f x)

@[simp]
theorem sum.map_inr {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} (f : α → α') (g : β → β') (x : β) :
sum.map f g (sum.inr x) = sum.inr (g x)

@[simp]
theorem sum.map_map {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} {α'' : Type u_1} {β'' : Type u_2} (f' : α' → α'') (g' : β' → β'') (f : α → α') (g : β → β') (x : α β) :
sum.map f' g' (sum.map f g x) = sum.map (f' f) (g' g) x

@[simp]
theorem sum.map_comp_map {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} {α'' : Type u_1} {β'' : Type u_2} (f' : α' → α'') (g' : β' → β'') (f : α → α') (g : β → β') :
sum.map f' g' sum.map f g = sum.map (f' f) (g' g)

@[simp]
theorem sum.map_id_id (α : Type u_1) (β : Type u_2) :

theorem sum.inl.inj_iff {α : Type u} {β : Type v} {a b : α} :

theorem sum.inr.inj_iff {α : Type u} {β : Type v} {a b : β} :

theorem sum.inl_ne_inr {α : Type u} {β : Type v} {a : α} {b : β} :

theorem sum.inr_ne_inl {α : Type u} {β : Type v} {a : α} {b : β} :

def sum.elim {α : Type u_1} {β : Type u_2} {γ : Sort u_3} (f : α → γ) (g : β → γ) (a : α β) :
γ

Define a function on α ⊕ β by giving separate definitions on α and β.

Equations
@[simp]
theorem sum.elim_inl {α : Type u_1} {β : Type u_2} {γ : Sort u_3} (f : α → γ) (g : β → γ) (x : α) :
sum.elim f g (sum.inl x) = f x

@[simp]
theorem sum.elim_inr {α : Type u_1} {β : Type u_2} {γ : Sort u_3} (f : α → γ) (g : β → γ) (x : β) :
sum.elim f g (sum.inr x) = g x

theorem sum.elim_injective {α : Type u_1} {β : Type u_2} {γ : Sort u_3} {f : α → γ} {g : β → γ} (hf : function.injective f) (hg : function.injective g) (hfg : ∀ (a : α) (b : β), f a g b) :

inductive sum.lex {α : Type u} {β : Type v} (ra : α → α → Prop) (rb : β → β → Prop) (a a_1 : α β) :
Prop
  • inl : ∀ {α : Type u} {β : Type v} (ra : α → α → Prop) (rb : β → β → Prop) {a₁ a₂ : α}, ra a₁ a₂sum.lex ra rb (sum.inl a₁) (sum.inl a₂)
  • inr : ∀ {α : Type u} {β : Type v} (ra : α → α → Prop) (rb : β → β → Prop) {b₁ b₂ : β}, rb b₁ b₂sum.lex ra rb (sum.inr b₁) (sum.inr b₂)
  • sep : ∀ {α : Type u} {β : Type v} (ra : α → α → Prop) (rb : β → β → Prop) (a : α) (b : β), sum.lex ra rb (sum.inl a) (sum.inr b)

Lexicographic order for sum. Sort all the inl a before the inr b, otherwise use the respective order on α or β.

@[simp]
theorem sum.lex_inl_inl {α : Type u} {β : Type v} {ra : α → α → Prop} {rb : β → β → Prop} {a₁ a₂ : α} :
sum.lex ra rb (sum.inl a₁) (sum.inl a₂) ra a₁ a₂

@[simp]
theorem sum.lex_inr_inr {α : Type u} {β : Type v} {ra : α → α → Prop} {rb : β → β → Prop} {b₁ b₂ : β} :
sum.lex ra rb (sum.inr b₁) (sum.inr b₂) rb b₁ b₂

@[simp]
theorem sum.lex_inr_inl {α : Type u} {β : Type v} {ra : α → α → Prop} {rb : β → β → Prop} {b : β} {a : α} :
¬sum.lex ra rb (sum.inr b) (sum.inl a)

theorem sum.lex_acc_inl {α : Type u} {β : Type v} {ra : α → α → Prop} {rb : β → β → Prop} {a : α} (aca : acc ra a) :
acc (sum.lex ra rb) (sum.inl a)

theorem sum.lex_acc_inr {α : Type u} {β : Type v} {ra : α → α → Prop} {rb : β → β → Prop} (aca : ∀ (a : α), acc (sum.lex ra rb) (sum.inl a)) {b : β} (acb : acc rb b) :
acc (sum.lex ra rb) (sum.inr b)

theorem sum.lex_wf {α : Type u} {β : Type v} {ra : α → α → Prop} {rb : β → β → Prop} (ha : well_founded ra) (hb : well_founded rb) :

@[simp]
def sum.swap {α : Type u} {β : Type v} (a : α β) :
β α

Swap the factors of a sum type

Equations
@[simp]
theorem sum.swap_swap {α : Type u} {β : Type v} (x : α β) :
x.swap.swap = x

@[simp]
theorem sum.swap_swap_eq {α : Type u} {β : Type v} :

@[simp]
theorem sum.swap_left_inverse {α : Type u} {β : Type v} :

@[simp]
theorem sum.swap_right_inverse {α : Type u} {β : Type v} :

theorem function.injective.sum_map {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} {f : α → β} {g : α' → β'} (hf : function.injective f) (hg : function.injective g) :

theorem function.surjective.sum_map {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} {f : α → β} {g : α' → β'} (hf : function.surjective f) (hg : function.surjective g) :