# 3 - Sets can be ﬁnite or inﬁnite In fact we shall see...

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Sets can be ﬁnite or inﬁnite. In fact, we shall see that there are many different inﬁnite sizes! Finite sets can be deﬁned by listing their elements. Inﬁnite sets can be deﬁned using a pattern or restriction. Here are some examples: 1. the two-element set Bool = {True, False}, which is analogous to the Haskell data type data Bool = True | False 2. the set of vowels V = {a, e, i, o, u}, which is read ‘V is the set containing the objects (in this case letters) a, e, i, o, u’; 3. an arbitrary (nonsense) set {1, 2, e, f , 5, Imperial}, which is a set containing numbers, letters and a string of letters with no obvious relationship to each other; 4. the set of natural numbers N = {0, 1, 2, 3, . . . }, which is read ‘N is the set containing the natural numbers 0, 1, 2, 3, ...’; 5. the set of integers Z = {. . . , −3, −2, −1, 0, 1, 2, 3, . . . }; 6. the set of primes P = {x ∈ N : x is a prime number}; 7. the empty set ∅ = { }, which contains no elements; 8. nested sets, such as the set {{∅}, {a, e, i, o, u}} containing the sets {∅} and {a, e, i, o, u} as its two elements. The set N is of course an inﬁnite set. The ‘...’ indicates that the remaining elements are given by some rule, which should be apparent from the initial examples: in this case, the rule is to add one to the previous number. Notice that sets can themselves be members of other sets, as the last example illustrates. There is an important distinction between {a, b, c} and {{a, b, c}} for example, or between ∅ and {∅}. 2.1 Comparing Sets We deﬁne the notion of one set being a subset of (contained in) another set, and the related notion of two sets being equal. You will be familiar with the notion of sublist from the Haskell course: h:: [Int] -> Int -> [Int] h xs n = filter (<n) xs 4 ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online