3 - Sets can be finite or infinite In fact we shall see...

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Sets can be finite or infinite. In fact, we shall see that there are many different infinite sizes! Finite sets can be defined by listing their elements. Infinite sets can be defined 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 infinite 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 define 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