The areas / V01. The language of Mathlib
Mathlib.Data.Sum.Basic
56 declarations. Mathlib docs · Source
Additional lemmas about sum types
Most of the former contents of this file have been moved to Batteries.
Ternary sum
Abbreviations for the maps from the summands to α ⊕ β ⊕ γ. This is useful for pattern-matching.
PSum
theorem Option.get.hcongr_3 E1 #
∀ (α α' : Type u),
α = α' →
∀ (o : Option α) (o' : Option α'),
o ≍ o' → ∀ (a : o.isSome = true) (a' : o'.isSome = true), a ≍ a' → o.get a ≍ o'.get a'
theorem Sum.getLeft.hcongr_4 E1 #
∀ (α α' : Type u_1),
α = α' →
∀ (β β' : Type u_2),
β = β' →
∀ (ab : α ⊕ β) (ab' : α' ⊕ β'),
ab ≍ ab' → ∀ (a : ab.isLeft = true) (a' : ab'.isLeft = true), a ≍ a' → ab.getLeft a ≍ ab'.getLeft a'
theorem Sum.getRight.hcongr_4 E1 #
∀ (α α' : Type u_1),
α = α' →
∀ (β β' : Type u_2),
β = β' →
∀ (ab : α ⊕ β) (ab' : α' ⊕ β'),
ab ≍ ab' → ∀ (a : ab.isRight = true) (a' : ab'.isRight = true), a ≍ a' → ab.getRight a ≍ ab'.getRight a'
theorem not_isLeft_and_isRight E1 #
∀ {α : Type u} {β : Type v} {x : α ⊕ β}, ¬(x.isLeft = true ∧ x.isRight = true)
theorem Sum.elim_swap E0 #
∀ {α : Type u_3} {β : Type u_4} {γ : Type u_5} {f : α → γ} {g : β → γ}, Sum.elim f g ∘ Sum.swap = Sum.elim g f
theorem Sum.exists_sum E1 #
∀ {α : Type u} {β : Type v} {γ : α ⊕ β → Sort u_3} (p : ((ab : α ⊕ β) → γ ab) → Prop),
(∃ fab, p fab) ↔ ∃ fa fb, p fun t ↦ Sum.rec fa fb t
theorem Sum.inl_injective E2 #
∀ {α : Type u} {β : Type v}, Function.Injective Sum.inl
theorem Sum.inr_injective E2 #
∀ {α : Type u} {β : Type v}, Function.Injective Sum.inr
theorem Sum.sum_rec_congr E1 #
∀ {α : Type u} {β : Type v} (P : α ⊕ β → Sort u_3) (f : (i : α) → P (Sum.inl i)) (g : (i : β) → P (Sum.inr i))
{x y : α ⊕ β} (h : x = y), Sum.rec f g x = cast ⋯ (Sum.rec f g y)
theorem Sum.getLeft_eq_getLeft? E1 #
∀ {α : Type u} {β : Type v} {x : α ⊕ β} (h₁ : x.isLeft = true) (h₂ : x.getLeft?.isSome = true),
x.getLeft h₁ = x.getLeft?.get h₂
theorem Sum.getRight_eq_getRight? E1 #
∀ {α : Type u} {β : Type v} {x : α ⊕ β} (h₁ : x.isRight = true) (h₂ : x.getRight?.isSome = true),
x.getRight h₁ = x.getRight?.get h₂
theorem Sum.isSome_getLeft?_iff_isLeft E0 #
∀ {α : Type u} {β : Type v} {x : α ⊕ β}, x.getLeft?.isSome = true ↔ x.isLeft = true
theorem Sum.isSome_getRight?_iff_isRight E0 #
∀ {α : Type u} {β : Type v} {x : α ⊕ β}, x.getRight?.isSome = true ↔ x.isRight = true
theorem Sum.update_elim_inl E0 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} [inst : DecidableEq α] [inst_1 : DecidableEq (α ⊕ β)] {f : α → γ} {g : β → γ}
{i : α} {x : γ}, Function.update (Sum.elim f g) (Sum.inl i) x = Sum.elim (Function.update f i x) g
theorem Sum.update_elim_inr E0 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} [inst : DecidableEq β] [inst_1 : DecidableEq (α ⊕ β)] {f : α → γ} {g : β → γ}
{i : β} {x : γ}, Function.update (Sum.elim f g) (Sum.inr i) x = Sum.elim f (Function.update g i x)
theorem Sum.update_inl_comp_inl E0 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} [inst : DecidableEq α] [inst_1 : DecidableEq (α ⊕ β)] {f : α ⊕ β → γ} {i : α}
{x : γ}, Function.update f (Sum.inl i) x ∘ Sum.inl = Function.update (f ∘ Sum.inl) i x
theorem Sum.update_inl_apply_inl E0 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} [inst : DecidableEq α] [inst_1 : DecidableEq (α ⊕ β)] {f : α ⊕ β → γ}
{i j : α} {x : γ}, Function.update f (Sum.inl i) x (Sum.inl j) = Function.update (f ∘ Sum.inl) i x j
theorem Sum.update_inl_comp_inr E0 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} [inst : DecidableEq (α ⊕ β)] {f : α ⊕ β → γ} {i : α} {x : γ},
Function.update f (Sum.inl i) x ∘ Sum.inr = f ∘ Sum.inr
theorem Sum.update_inl_apply_inr E1 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} [inst : DecidableEq (α ⊕ β)] {f : α ⊕ β → γ} {i : α} {j : β} {x : γ},
Function.update f (Sum.inl i) x (Sum.inr j) = f (Sum.inr j)
theorem Sum.update_inr_comp_inl E0 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} [inst : DecidableEq (α ⊕ β)] {f : α ⊕ β → γ} {i : β} {x : γ},
Function.update f (Sum.inr i) x ∘ Sum.inl = f ∘ Sum.inl
theorem Sum.update_inr_apply_inl E1 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} [inst : DecidableEq (α ⊕ β)] {f : α ⊕ β → γ} {i : α} {j : β} {x : γ},
Function.update f (Sum.inr j) x (Sum.inl i) = f (Sum.inl i)
theorem Sum.update_inr_comp_inr E0 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} [inst : DecidableEq β] [inst_1 : DecidableEq (α ⊕ β)] {f : α ⊕ β → γ} {i : β}
{x : γ}, Function.update f (Sum.inr i) x ∘ Sum.inr = Function.update (f ∘ Sum.inr) i x
theorem Sum.update_inr_apply_inr E0 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} [inst : DecidableEq β] [inst_1 : DecidableEq (α ⊕ β)] {f : α ⊕ β → γ}
{i j : β} {x : γ}, Function.update f (Sum.inr i) x (Sum.inr j) = Function.update (f ∘ Sum.inr) i x j
theorem Sum.update_inl_apply_inl' E0 #
∀ {α : Type u} {β : Type v} {γ : α ⊕ β → Type u_3} [inst : DecidableEq α] [inst_1 : DecidableEq (α ⊕ β)]
{f : (i : α ⊕ β) → γ i} {i : α} {x : γ (Sum.inl i)} (j : α),
Function.update f (Sum.inl i) x (Sum.inl j) = Function.update (fun j ↦ f (Sum.inl j)) i x j
theorem Sum.update_inr_apply_inr' E0 #
∀ {α : Type u} {β : Type v} {γ : α ⊕ β → Type u_3} [inst : DecidableEq β] [inst_1 : DecidableEq (α ⊕ β)]
{f : (i : α ⊕ β) → γ i} {i : β} {x : γ (Sum.inr i)} (j : β),
Function.update f (Sum.inr i) x (Sum.inr j) = Function.update (fun j ↦ f (Sum.inr j)) i x j
theorem Sum.rec_update_left E0 #
∀ {α : Type u} {β : Type v} {γ : α ⊕ β → Sort u_3} [inst : DecidableEq α] [inst_1 : DecidableEq β]
(f : (a : α) → γ (Sum.inl a)) (g : (b : β) → γ (Sum.inr b)) (a : α) (x : γ (Sum.inl a)),
(fun t ↦ Sum.rec (Function.update f a x) g t) = Function.update (fun t ↦ Sum.rec f g t) (Sum.inl a) x
theorem Sum.rec_update_right E0 #
∀ {α : Type u} {β : Type v} {γ : α ⊕ β → Sort u_3} [inst : DecidableEq α] [inst_1 : DecidableEq β]
(f : (a : α) → γ (Sum.inl a)) (g : (b : β) → γ (Sum.inr b)) (b : β) (x : γ (Sum.inr b)),
(fun t ↦ Sum.rec f (Function.update g b x) t) = Function.update (fun t ↦ Sum.rec f g t) (Sum.inr b) x
theorem Sum.elim_update_left E0 #
∀ {α : Type u} {β : Type v} {γ : Sort u_3} [inst : DecidableEq α] [inst_1 : DecidableEq β] (f : α → γ) (g : β → γ)
(a : α) (x : γ), Sum.elim (Function.update f a x) g = Function.update (Sum.elim f g) (Sum.inl a) x
theorem Sum.elim_update_right E0 #
∀ {α : Type u} {β : Type v} {γ : Sort u_3} [inst : DecidableEq α] [inst_1 : DecidableEq β] (f : α → γ) (g : β → γ)
(b : β) (x : γ), Sum.elim f (Function.update g b x) = Function.update (Sum.elim f g) (Sum.inr b) x
theorem Sum.swap_leftInverse E0 #
∀ {α : Type u} {β : Type v}, Function.LeftInverse Sum.swap Sum.swap
theorem Sum.swap_rightInverse E0 #
∀ {α : Type u} {β : Type v}, Function.RightInverse Sum.swap Sum.swap
theorem Sum.liftRel_iff E0 #
∀ {α : Type u_1} {γ : Type u_2} {β : Type u_3} {δ : Type u_4} (r : α → γ → Prop) (s : β → δ → Prop) (a : α ⊕ β)
(a_1 : γ ⊕ δ),
Sum.LiftRel r s a a_1 ↔
(∃ a_2 c, r a_2 c ∧ a = Sum.inl a_2 ∧ a_1 = Sum.inl c) ∨ ∃ b d, s b d ∧ a = Sum.inr b ∧ a_1 = Sum.inr d
theorem Sum.LiftRel.isLeft_congr E1 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {r : α → γ → Prop} {s : β → δ → Prop} {x : α ⊕ β} {y : γ ⊕ δ},
Sum.LiftRel r s x y → (x.isLeft = true ↔ y.isLeft = true)
theorem Sum.LiftRel.isRight_congr E1 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {r : α → γ → Prop} {s : β → δ → Prop} {x : α ⊕ β} {y : γ ⊕ δ},
Sum.LiftRel r s x y → (x.isRight = true ↔ y.isRight = true)
theorem Sum.LiftRel.isLeft_left E1 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {r : α → γ → Prop} {s : β → δ → Prop} {x : α ⊕ β} {c : γ},
Sum.LiftRel r s x (Sum.inl c) → x.isLeft = true
theorem Sum.LiftRel.isLeft_right E1 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {r : α → γ → Prop} {s : β → δ → Prop} {y : γ ⊕ δ} {a : α},
Sum.LiftRel r s (Sum.inl a) y → y.isLeft = true
theorem Sum.LiftRel.isRight_left E1 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {r : α → γ → Prop} {s : β → δ → Prop} {x : α ⊕ β} {d : δ},
Sum.LiftRel r s x (Sum.inr d) → x.isRight = true
theorem Sum.LiftRel.isRight_right E1 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {r : α → γ → Prop} {s : β → δ → Prop} {y : γ ⊕ δ} {b : β},
Sum.LiftRel r s (Sum.inr b) y → y.isRight = true
theorem Sum.LiftRel.exists_of_isLeft_left E1 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {r : α → γ → Prop} {s : β → δ → Prop} {x : α ⊕ β} {y : γ ⊕ δ},
Sum.LiftRel r s x y → x.isLeft = true → ∃ a c, r a c ∧ x = Sum.inl a ∧ y = Sum.inl c
theorem Sum.LiftRel.exists_of_isLeft_right E1 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {r : α → γ → Prop} {s : β → δ → Prop} {x : α ⊕ β} {y : γ ⊕ δ},
Sum.LiftRel r s x y → y.isLeft = true → ∃ a c, r a c ∧ x = Sum.inl a ∧ y = Sum.inl c
theorem Sum.LiftRel.exists_of_isRight_left E1 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {r : α → γ → Prop} {s : β → δ → Prop} {x : α ⊕ β} {y : γ ⊕ δ},
Sum.LiftRel r s x y → x.isRight = true → ∃ b d, s b d ∧ x = Sum.inr b ∧ y = Sum.inr d
theorem Sum.LiftRel.exists_of_isRight_right E1 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {r : α → γ → Prop} {s : β → δ → Prop} {x : α ⊕ β} {y : γ ⊕ δ},
Sum.LiftRel r s x y → y.isRight = true → ∃ b d, s b d ∧ x = Sum.inr b ∧ y = Sum.inr d
theorem Function.Injective.sumElim E1 #
∀ {α : Type u} {β : Type v} {γ : Sort u_3} {f : α → γ} {g : β → γ},
Function.Injective f → Function.Injective g → (∀ (a : α) (b : β), f a ≠ g b) → Function.Injective (Sum.elim f g)
theorem Function.Injective.sumMap E1 #
∀ {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} {f : α → β} {g : α' → β'},
Function.Injective f → Function.Injective g → Function.Injective (Sum.map f g)
theorem Function.Surjective.sumMap E1 #
∀ {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} {f : α → β} {g : α' → β'},
Function.Surjective f → Function.Surjective g → Function.Surjective (Sum.map f g)
theorem Function.Bijective.sumMap E1 #
∀ {α : Type u} {α' : Type w} {β : Type v} {β' : Type x} {f : α → β} {g : α' → β'},
Function.Bijective f → Function.Bijective g → Function.Bijective (Sum.map f g)
theorem Sum.elim_injective E0 #
∀ {α : Type u} {β : Type v} {γ : Sort u_3} {f : α → γ} {g : β → γ},
Function.Injective (Sum.elim f g) ↔ Function.Injective f ∧ Function.Injective g ∧ ∀ (a : α) (b : β), f a ≠ g b
theorem Sum.elim_injective' E0 #
∀ {α : Type u} {β : Type v} {γ : Sort u_3} {f : α → γ}, Function.Injective (Sum.elim f)
theorem Sum.map_injective E0 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {f : α → γ} {g : β → δ},
Function.Injective (Sum.map f g) ↔ Function.Injective f ∧ Function.Injective g
theorem Sum.map_surjective E0 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {f : α → γ} {g : β → δ},
Function.Surjective (Sum.map f g) ↔ Function.Surjective f ∧ Function.Surjective g
theorem Sum.map_bijective E0 #
∀ {α : Type u} {β : Type v} {γ : Type u_1} {δ : Type u_2} {f : α → γ} {g : β → δ},
Function.Bijective (Sum.map f g) ↔ Function.Bijective f ∧ Function.Bijective g
def Sum3.in₀ E1 #
{α : Type u} → {β : Type v} → {γ : Type u_1} → α → α ⊕ β ⊕ γ
The map from the first summand into a ternary sum.
def Sum3.in₁ E1 #
{α : Type u} → {β : Type v} → {γ : Type u_1} → β → α ⊕ β ⊕ γ
The map from the second summand into a ternary sum.
def Sum3.in₂ E1 #
{α : Type u} → {β : Type v} → {γ : Type u_1} → γ → α ⊕ β ⊕ γ
The map from the third summand into a ternary sum.
theorem PSum.inl_injective E1 #
∀ {α : Sort u_3} {β : Sort u_4}, Function.Injective PSum.inl
theorem PSum.inr_injective E1 #
∀ {α : Sort u_3} {β : Sort u_4}, Function.Injective PSum.inr