You are on page 1of 28

This denotes the empty set – i.e., the set with no elements in it. This can also be denoted
as {}.
{Matthew, Mark, Luke, John}

This is a set of people containing four elements. The types of Matthew, Mark, Luke, John
must be compatible!
{0, 1, 2} = {0, 0, 1, 0, 2, 1} = {1, 2, 0}

All three of these represent a three-element set of numbers. An important property of


sets is that there is no inherent ordering in its elements (unlike in a list for example).
Thus, the numbers above may be specified in any order, and repeated elements simply
map on top of one another.
{0, 1, 2, 3, . . .}
This is the set of natural numbers, or integers ranging from zero upwards. Note that this
set contains an infinite number of elements. Since the set of natural numbers is a very
important set in many Z specifications, it is normally denoted N for brevity.
{∅} ≠ ∅
It is important to understand that the set containing the empty set is not the same as the
empty set itself. It is a set containing one element (namely, the empty set). Thus it is
possible to have sets containing other sets (which may themselves contain sets), and so
on.
‘x is an element of (member of) S’ as: x ∈ S
0 ∈ {0, 1, 2}
This is patently true since 0 is one of the elements in the set containing 0, 1 and 2.
Note that every set must be drawn from some basic type (or given set) in Z. This even applies to the empty set, ∅. I.e.,
there is a different empty set for each type. When the empty set is used in Z, its type should be obvious from the
context. If not, there is probably something wrong with the specification. To avoid confusion, the notation ∅[T] may
be used to indicate the empty set drawn from type T.
∅ ∈ {∅}

The empty set (of a particular type) is a member of the set containing just the empty set
of that type. In fact it is the only member.

0∉ ∅

This is another way of writing ‘¬ (0 ∈ ∅)’ – i.e., 0 is not a member of the empty set (of
numbers). This is true because no element can be a member of the empty set; there are
no elements in it by definition. In fact, for any x, we can say x ∉ ∅. A special notation is
used for ‘is not a member of ’ since this occurs quite often in specifications.

Paul ∉ {Matthew, Mark, Luke, John}

The set being checked by ∉ need not be empty for a predicate using it to be true.
For example, the set of people given here does not include Paul, so the predicate is true.
Venn Diagram
Venn Diagram
Venn Diagram
Venn Diagram
A ⊆B Each element of A is also an element of B.

This is always true. Every set contains at least the


∅ ⊆A
empty set (of compatible type).

A ⊆A Every set ‘contains’ itself.

The numbers 0 and 1 make up a subset of the


{0, 1} ⊆ N
natural numbers.

{x : N | x is_prime ∧ x
The set of prime numbers (not including the
≠ 2} ⊆ {x : N | x
number 2) is a subset of the odd numbers.
is_odd}
Set intersection (∩) and logical conjunction (∧):
{x : T | p} ∩ {x : T | q} = {x : T | p ∧ q}
Union (∪) and disjunction (∨):
{x : T | p} ∪ {x : T | q} = {x : T | p ∨ q}
Complementing a set is like negating a predicate:
{x : T | p}− = {x : T | ¬ p}
The notion of a subset (⊆) matches that of implication (⇒):
{x : T | p} ⊆ {x : T | q} iff p ⇒ q
Set equality (=) matches logical equivalence (⇔):
{x : T | p} = {x : T | q} iff p ⇔ q
Sets and predicates are similar in some respects. Each set operator has a
corresponding logical connective which may be associated with it.
The empty set (of a particular type T) is equivalent to the false
predicate:
∅ [T] = {x : T | false}
The entire set of a given type is equivalent to the true predicate:
T = {x : T | true}

You might also like