Both CustomUnit
and AlsoUnit
are unit-like types, with a single constructor that takes no parameters.
Every pair of terms with either type is definitionally equal.
inductive CustomUnit where
| customUnit
example (e1 e2 : CustomUnit) : e1 = e2 := rfl
structure AlsoUnit where
example (e1 e2 : AlsoUnit) : e1 = e2 := rfl
Types with parameters, such as WithParam
, are also unit-like if they have a single constructor that does not take parameters.
inductive WithParam (n : Nat) where
| mk
example (x y : WithParam 3) : x = y := rfl
Constructors with non-proof parameters are not unit-like, even if the parameters are all unit-like types.
inductive NotUnitLike where
| mk (u : Unit)
example (e1 e2 : NotUnitLike) : e1 = e2 := type mismatch
rfl
has type
?m.13 = ?m.13 : Prop
but is expected to have type
e1 = e2 : Prop
rfl
type mismatch
rfl
has type
?m.13 = ?m.13 : Prop
but is expected to have type
e1 = e2 : Prop
Constructors of unit-like types may take parameters that are proofs.
inductive ProofUnitLike where
| mk : 2 = 2 → ProofUnitLike
example (e1 e2 : ProofUnitLike) : e1 = e2 := rfl