Freeman 1993. J.K. Truss. Discrete Mathematics for Computer Science,. Addison
-Wesley 1991. R. Johnsonbaugh. Discrete Mathematics, Prentice Hall 2000.
K.H. Rosen. Discrete Mathematics and its Applications, McGraw Hill 1995.
Discrete Mathematics
J.L. Gersting. Mathematical Structures for Computer Science, Freeman 1993. Philippa Gardner This course is based on previous lecture notes by Iain Phillips.
J.K. Truss. Discrete Mathematics for Computer Science, Addison-Wesley 1991. R. Johnsonbaugh. Discrete Mathematics, Prentice Hall 2000. C. Schumacher, Fundamental Notions of Abstract Mathematics, Addison-Wesley 2001. 2
1
Some related courses Assessed work
1. Mathematical reasoning: logic 2. Mathematical reasoning: programming 3. Mathematical reasoning: discrete maths (continued)
Week 7: submission date Tuesday, November 23th.
4. Haskell
Week 9: submission date Tuesday, December 7th.
5. Databases In particular, we will use some of the notation introduced in the logic course: A∧B
Assessed exercises
A∨B
¬A A → B
A↔B
∀x.A
Assessed Test in week 11. Exam at the end of the year.
∃x.A
3
4
Motivation: functions Motivation: sets Haskell function Sets are like types in Haskell. Haskell type declaration: data Bool = False | True Set of Boolean values: {False , True} List of Boolean values:
[True, False, True, False]
Set equality {False, True} = {True, False, True, False}
myand myand myand myand myand
:: Bool -> Bool -> Bool False False = False False True = False True False = False True True = True
Computable function described for example using Turing machines. This course explores the notion of mathematical function.
5
6
Exercise Motivation: relations Are these Haskell functions equivalent? Examples 1. The class of the first-year Computer Science students, year 2002. 2. George W Bush is the son of George Bush
myand myand myand myand myand
:: Bool -> Bool -> Bool False False = False False True = False True False = False True True = True
3. 2 < 3 4. One program is equivalent to another program.
7
myand’ :: Bool -> Bool -> Bool myand’ False x = False myand’ True x = x 8
Answer Equivalence of Haskell Functions The functions myand and myand’ do not behave in the same way in the presence of the constant function bottom: bottom :: Bool bottom = bottom Is the following function equivalent to myand and myand’? myand’’ :: Bool -> Bool -> Bool myand’’ b1 b2 = if b1 then b2 else False
Two Haskell functions f : A → B and g : A → B behave in the same way if and only if, for all terms a in type A, then if f a terminates then g a terminates and f a = g a, and if f a does not terminate then g a does not terminate. In this course, we explore the abstract concept of relations.
10
9
Sets
Exercise Are the following Haskell functions equivalent?
Informal definition
g [] y False = 1 g [] True False = 2 g xs y z = 3
A set is a collection of objects (or individuals) taken from a pool of objects. The objects in a set are also called the elements, or members, of the set. A set is said to contain its elements.
g’ [] y g’ xs y
We write x ∈ A when object x is a member of set A.
False = 1 z = 3
We write x 6∈ A, or ¬(x ∈ A), when x is not a member of A.
11
12
Examples Comparing sets: subsets 1. vowels {a, e, i, o, u} 2. arbitrary (nonsense) set {1, 2, e, f, 5, Imperial} 3. natural numbers N = {0, 1, 2, 3, . . .} 4. integers Z = {. . . , −3, −2, −1, 0, 1, 2, 3, . . .}
Let A, B be any two sets, Then A is a subset of B, written A ⊆ B, if and only if all the elements of A are also elements of B: that is, A ⊆ B ⇔ ∀ objects x.(x ∈ A → x ∈ B)
5. primes P = {x ∈ N : x is a prime number} Object x comes from an underlying universe of discourse, sometimes written U .
6. empty set ∅ = { } 7. nested sets, such as {{a, e, i, o, u}, {∅}} 13
14
Examples Analogy Similar to sublist from the Haskell course. The following function h takes a list of integers and an integer n, and returns a sublist of elements less than n: h:: [Int] -> Int -> [Int] h xs n = filter ( Name height :: Person -> Float age :: Person -> Int eyeColour :: Person -> Colour dateOfBirth :: Person -> Date height (_, h, _, _, _) = h
...
35
36
Future We can form the product of three sets in three different ways: A×B×C
(A × B) × C
A × (B × C)
There is a natural correspondence between these three sets. We will make this intuition precise later in the course.
37
Proposition Let Ai be finite sets for each 1 ≤ i ≤ n. Then |A1 × . . . × An | = |A1 | × . . . × |An |.