Sum α β
, or α ⊕ β
, is the disjoint union of types α
and β
.
An element of α ⊕ β
is either of the form .inl a
where a : α
,
or .inr b
where b : β
.
11.14. Sum Types
inductive type
Sum.{u, v} (α : Type u) (β : Type v) : Type (max u v)
inductive type
PSum.{u, v} (α : Sort u) (β : Sort v) : Sort (max (max 1 u) v)
PSum α β
, or α ⊕' β
, is the disjoint union of types α
and β
.
It differs from α ⊕ β
in that it allows α
and β
to have arbitrary sorts
Sort u
and Sort v
, instead of restricting to Type u
and Type v
. This means
that it can be used in situations where one side is a proposition, like True ⊕' Nat
.
The reason this is not the default is that this type lives in the universe Sort (max 1 u v)
,
which can cause problems for universe level unification,
because the equation max 1 u v = ?u + 1
has no solution in level arithmetic.
PSum
is usually only used in automation that constructs sums of arbitrary types.