Bool
setDefinition of Bool
with two elements true
and false
:
data Bool : Set where true : Bool false : Bool
Interpretation:
Bool
is a Set
true
is a Bool
false
is a Bool
Bool
true
and false
are differentIt is because of the last two points that the syntax of the definition doesn't look like this:
Bool : Set
true : Bool
false : Bool
data
and where
are keywordsSet
is the set of sets (a constant)true
and false
constructors of data type Bool
(more explanations of constructors come later)Define a set named Answer
with three elements, yes
, no
and maybe
.
Define a set named Quarter
with four elements, east
, west
, north
and south
.
Suppose we have Bool'
defined:
data Bool' : Set where true' : Bool' false' : Bool'
Bool
and Bool'
the same sets?Bool
and Bool'
are definitionally different but they are isomorphic.
Interpretation (or meaning) is the opposite relation to representation.
Bool
is the set of Boolean values.Bool
.Bool'
.We can define finite sets with n = 0, 1, 2, ... elements.
The special case with n = 0 is the empty set:
data ⊥ : Set where -- There is no constructor.
The special case with n = 1 is the singleton set (set with one element):
data ⊤ : Set where tt : ⊤
⊥
and ⊤
have interesting interpretations as we will see.
Basic differences between types and sets:
true
cannot be the element of two different types at the same time.data
defines types, not sets!
Set
is the type of types, so it should be called Type
.Set
.If we have multiple elements of the same type we can define them in one line:
data name : Set where elem₁ elem₂ : name