Additional lemmas about sum types #
Most of the former contents of this file have been moved to Batteries.
@[simp]
theorem
Sum.update_elim_inl
{α : Type u}
{β : Type v}
{γ : Type u_1}
[DecidableEq α]
[DecidableEq (α ⊕ β)]
{f : α → γ}
{g : β → γ}
{i : α}
{x : γ}
:
Function.update (Sum.elim f g) (inl i) x = Sum.elim (Function.update f i x) g
@[simp]
theorem
Sum.update_elim_inr
{α : Type u}
{β : Type v}
{γ : Type u_1}
[DecidableEq β]
[DecidableEq (α ⊕ β)]
{f : α → γ}
{g : β → γ}
{i : β}
{x : γ}
:
Function.update (Sum.elim f g) (inr i) x = Sum.elim f (Function.update g i x)
@[simp]
theorem
Sum.update_inl_comp_inl
{α : Type u}
{β : Type v}
{γ : Type u_1}
[DecidableEq α]
[DecidableEq (α ⊕ β)]
{f : α ⊕ β → γ}
{i : α}
{x : γ}
:
Function.update f (inl i) x ∘ inl = Function.update (f ∘ inl) i x
@[simp]
theorem
Sum.update_inl_apply_inl
{α : Type u}
{β : Type v}
{γ : Type u_1}
[DecidableEq α]
[DecidableEq (α ⊕ β)]
{f : α ⊕ β → γ}
{i j : α}
{x : γ}
:
Function.update f (inl i) x (inl j) = Function.update (f ∘ inl) i x j
@[simp]
theorem
Sum.update_inl_comp_inr
{α : Type u}
{β : Type v}
{γ : Type u_1}
[DecidableEq (α ⊕ β)]
{f : α ⊕ β → γ}
{i : α}
{x : γ}
:
theorem
Sum.update_inl_apply_inr
{α : Type u}
{β : Type v}
{γ : Type u_1}
[DecidableEq (α ⊕ β)]
{f : α ⊕ β → γ}
{i : α}
{j : β}
{x : γ}
:
Function.update f (inl i) x (inr j) = f (inr j)
@[simp]
theorem
Sum.update_inr_comp_inl
{α : Type u}
{β : Type v}
{γ : Type u_1}
[DecidableEq (α ⊕ β)]
{f : α ⊕ β → γ}
{i : β}
{x : γ}
:
theorem
Sum.update_inr_apply_inl
{α : Type u}
{β : Type v}
{γ : Type u_1}
[DecidableEq (α ⊕ β)]
{f : α ⊕ β → γ}
{i : α}
{j : β}
{x : γ}
:
Function.update f (inr j) x (inl i) = f (inl i)
@[simp]
theorem
Sum.update_inr_comp_inr
{α : Type u}
{β : Type v}
{γ : Type u_1}
[DecidableEq β]
[DecidableEq (α ⊕ β)]
{f : α ⊕ β → γ}
{i : β}
{x : γ}
:
Function.update f (inr i) x ∘ inr = Function.update (f ∘ inr) i x
@[simp]
theorem
Sum.update_inr_apply_inr
{α : Type u}
{β : Type v}
{γ : Type u_1}
[DecidableEq β]
[DecidableEq (α ⊕ β)]
{f : α ⊕ β → γ}
{i j : β}
{x : γ}
:
Function.update f (inr i) x (inr j) = Function.update (f ∘ inr) i x j
@[simp]
@[simp]
theorem
Function.Surjective.sum_map
{α : Type u}
{α' : Type w}
{β : Type v}
{β' : Type x}
{f : α → β}
{g : α' → β'}
(hf : Surjective f)
(hg : Surjective g)
:
Surjective (Sum.map f g)
@[simp]
theorem
Sum.map_injective
{α : Type u}
{β : Type v}
{γ : Type u_1}
{δ : Type u_2}
{f : α → γ}
{g : β → δ}
:
@[simp]
theorem
Sum.map_surjective
{α : Type u}
{β : Type v}
{γ : Type u_1}
{δ : Type u_2}
{f : α → γ}
{g : β → δ}
:
@[simp]
theorem
Sum.map_bijective
{α : Type u}
{β : Type v}
{γ : Type u_1}
{δ : Type u_2}
{f : α → γ}
{g : β → δ}
:
theorem
Sum.elim_update_left
{α : Type u}
{β : Type v}
{γ : Type u_1}
[DecidableEq α]
[DecidableEq β]
(f : α → γ)
(g : β → γ)
(i : α)
(c : γ)
:
Sum.elim (Function.update f i c) g = Function.update (Sum.elim f g) (inl i) c
theorem
Sum.elim_update_right
{α : Type u}
{β : Type v}
{γ : Type u_1}
[DecidableEq α]
[DecidableEq β]
(f : α → γ)
(g : β → γ)
(i : β)
(c : γ)
:
Sum.elim f (Function.update g i c) = Function.update (Sum.elim f g) (inr i) c
Ternary sum #
Abbreviations for the maps from the summands to α ⊕ β ⊕ γ
. This is useful for pattern-matching.