Presentation is loading. Please wait.

Presentation is loading. Please wait.

Michaelmas Term 2004 Discrete Mathematics CSC 141 Discrete Mathematics Dr. Corina Sas and Ms. Nelly Bencomo

Similar presentations


Presentation on theme: "Michaelmas Term 2004 Discrete Mathematics CSC 141 Discrete Mathematics Dr. Corina Sas and Ms. Nelly Bencomo"— Presentation transcript:

1 Michaelmas Term 2004 Discrete Mathematics CSC 141 Discrete Mathematics Dr. Corina Sas and Ms. Nelly Bencomo c.sas@lancaster.ac.ukc.sas@lancaster.ac.uk; nelly@comp.lancs.ac.uknelly@comp.lancs.ac.uk Computing Department

2 Michaelmas Term 2004 Discrete Mathematics Course details weeks 1-10 –10 x 50 min lectures Material –http://info.comp.lancs.ac.uk/year1/notes/csc141http://info.comp.lancs.ac.uk/year1/notes/csc141 coursework –written work (relevant to exam) recommended resource –http://www.cs.odu.edu/~toida/nerzic/content/web_cou rse.htmlhttp://www.cs.odu.edu/~toida/nerzic/content/web_cou rse.html

3 Michaelmas Term 2004 Discrete Mathematics Syllabus Sets Relations Functions Recursion Logic –Boolean –propositional –predicate logic

4 Michaelmas Term 2004 Discrete Mathematics Overview Discrete Maths Sets –Defining sets –Set operations –Subsets –Universal and power set

5 Michaelmas Term 2004 Discrete Mathematics Objectives Understanding the relevance of discrete maths for computer science Understanding the basic ideas about sets Facility with basic ideas about sets

6 Michaelmas Term 2004 Discrete Mathematics Discrete maths What –discrete objects Why –formal specification –infinity or indefiniteness –reusability

7 Michaelmas Term 2004 Discrete Mathematics Sets and membership Set = collection of objects –in a set there are no duplicates –a set is Unordered –example set: A = {1, 2, 3, 4, 5, 6, 7} 1 in set A: –1 belongs to the set A –1 is an element/object/member of the set A Write this: –1  A –8  A

8 Michaelmas Term 2004 Discrete Mathematics Defining sets Listing all its members –writing down all the elements –small, finite sets –A = {a, b, {a, b}, c} Listing a property that its members must satisfy –{x | 0 < x < 8} –every integer that is greater than 0 and less than 8 –expression on the left does not have to be a variable: {x-2 | 2 < x < 10} –infinite sets {x | x > 0}

9 Michaelmas Term 2004 Discrete Mathematics Defining sets Procedure (program) to generate the members of a set. –a procedure to generate an infinite set is a never ending procedure –EXERCISES. Formally specify the following sets: all (+ve) even numbers all (+ve) odd numbers all (+ve) numbers exactly divisible by 3 all (+ve) numbers that do not divide exactly by 8

10 Michaelmas Term 2004 Discrete Mathematics Exercise Exercises – answers {2x | x > 0} {2x + 1 | x ≥ 0} {3x | x > 0} {8x + y | x ≥ 0, 1 ≤ y ≤ 7} Procedure: Set =  i = 1 while i >0 do put i*3 into Set i = i+1 endwhile Write similar procedure to generate the other sets

11 Michaelmas Term 2004 Discrete Mathematics Answers (all +ve even numbers) Set =  i = 1 while i ≥ 1 do put i * 2 into Set i := i + 1 endwhile (all +ve odd numbers) Set =  i = 0 while i ≥ 0 do put 2 * i + 1 into Set i := i + 1 endwhile (all +ve numbers not exactly divisible by 8) Set =  i = 0 while i ≥ 0 do for j = 1 to 7 do put i + j into Set endfor i = i + 8 endwhile

12 Michaelmas Term 2004 Discrete Mathematics Set Operations UNION (written  ) –takes all of the elements from two sets, and makes a new set containing those elements (with no duplicate elements) – A  B = { x | x  A  x  B } –Example: If A = {1, 2, 3} and B = {4, 5}, then A  B = {1, 2, 3, 4, 5}. –Example: If A = {1, 2, 3} and B = {1, 2, 4, 5}, then A  B = {1, 2, 3, 4, 5}. INTERSECTION (written  ) –forms a new set from two sets, consisting of all elements that are in BOTH of the original sets –A  B = { x | x  A   x  B } –Example: If A = {1, 2, 3} and B = {1, 2, 4, 5}, then A  B = {1, 2}. –Example: If A = {1, 2, 3} and B = {4, 5}, then A  B = 

13 Michaelmas Term 2004 Discrete Mathematics Set Operations DIFFERENCE (written – or /) –forms a new set from two sets, consisting of all elements from the first set that are not in the second –A - B = { x | x  A  x  B } –Example: If A = {1, 2, 3} and B = {1, 2, 4, 5}, then A - B = {3}. –Example: If A = {1, 2, 3} and B = {4, 5}, then A - B = {1, 2, 3}. Each of the basic set operations: –is infix operator i.e. it is written in between its arguments, as is, for example “+” in arithmetic –takes two sets as its arguments

14 Michaelmas Term 2004 Discrete Mathematics Union Examples: –{a, b, c}  {b, c, d} = {a, b, c, d} –{a, b, c}   = {a, b, c} –   {a, b, c} = {a, b, c} –{2x | x > 0}  {2x + 1 | x ≥ 0} = {x | x > 0} NOTE that for all sets A, B, C: –A  B = B  A (commutative law) –A   = A (identity law) –A  A = A (idempotent law) –(A  B)  C = A  (B  C) (associative law) Checkpoint: “prove” the above to yourself

15 Michaelmas Term 2004 Discrete Mathematics Intersection Examples –{a, b, c}  {b, c, d} = {b, c} –{a, b, c}   =  –   {a, b, c} =  –{2x | x > 0}  {3x | x > 0} = {6x | x > 0} –{2x | x > 0}  {2x + 1 | x ≥ 0 } =  NOTE that for all sets A, B, C: –A  B = B  A (commutative law) –A   =  (domination law) –A  A = A (idempotent law) –(A  B)  C = A  (B  C) (associative law)

16 Michaelmas Term 2004 Discrete Mathematics Set difference Examples: –{a, b, c} - {b, c, d} = {a} –{b, c, d} – {a, b, c} = {d} –{a, b, c} – {} = {a, b, c} –{a, b, c} – {d, e, f} = {a, b, c} –{x | x > 0} – {2x + 1 | x ≥ 0} = {2x | x > 0} NOTE: for all sets, A –A –  = A –  – A =  –A – A = 

17 Michaelmas Term 2004 Discrete Mathematics Cartesian product An ordered pair is a pair of objects with an order associated with them. If objects are represented by x and y, then we write the ordered pair as. Two ordered pairs and are equal if and only if a = c and b = d. For example the ordered pair is not equal to the ordered pair. The set of all ordered pairs, where a is an element of A and b is an element of B, is called the Cartesian product of A and B and is denoted by A x B. Example 1: Let A = {1, 2, 3} and B = {a, b}. Then A x B = {,,,,, }. Example 2: For the same A and B as in Example 1, B x A = {,,,,, }. In general, A x B ≠B x A unless A = , B =  or A = B. Note that A x  =  x A =  because there is no element in  to form ordered pairs with elements of A.

18 Michaelmas Term 2004 Discrete Mathematics Set operations - Exercises if A = {a, b, c, y}, B = {a, b, c, d, e} and C = {x, y} evaluate: 1.A  (B  C) 2.(A  B)  C 3.C – A 4.(A – B) – C 5.A – (B – C) 6.(A  C)  B 7.A  (C  B)

19 Michaelmas Term 2004 Discrete Mathematics Answers 1.A 2.{y} 3.{x} 4.  5.{y} 6.{a, b, c, d, e, y} 7.A

20 Michaelmas Term 2004 Discrete Mathematics Subsets A is a subset of another set, B, means that all members of the set A are also members of the set B. Notation: A  B we say “A is a subset of B”, or “B is a superset of A” or “A is contained in B” or “B contains A” Examples: –{a, b, c}  {a, b, c, d, e} –{2x | x > 1}  {x | x > 0} If A  B, and the set B also contains elements that the set A does not, we say A is a proper subset of B, and we write: A  B Checkpoint: can we correctly use  instead of  in the two examples above?

21 Michaelmas Term 2004 Discrete Mathematics Subset Exercises if A = {a, b, c, d, e, f}, B = {a, b, e}, C = {c, d}, and D = {d, f, g} say which of the following are true statements: 1.B  B 2.B  B 3.B  A 4.C  A 5.(B  C)  A 6.D  A 7.(D  C)  A 8.(D  C)  A

22 Michaelmas Term 2004 Discrete Mathematics Answers 1.true (of any set) 2.false (of any set) 3.true 4.true 5.true 6.false 7.true 8.false

23 Michaelmas Term 2004 Discrete Mathematics Universal sets we often consider sets in terms of them all being subsets of a so called universal set or universe –for example, all the sets of numbers we have considered so far have been subsets of the set of all positive integers –the so-called natural numbers, sometimes written N this leads to the notion of the complement of a set –the complement is the difference between the universe and a given set –e.g. with a universe of N, the complement of {2x | x > 1} is {2x + 1 | x > 0} –the complement of a set A is usually written Ā we’ll write comp(A)

24 Michaelmas Term 2004 Discrete Mathematics Power sets Universal sets - examples suppose the universe, U = {a, b, c, d, e, f, g}, A = {a, b, c} and B = {b, c, d, e} –comp(A) = {d, e, f, g} –comp(B) = {a, f, g} –comp (A)  comp(B) = {a, d, e, f, g} –comp(A  B) = comp({b, c}) = {a, d, e, f, g} –comp(A)  comp(B) = {f, g} –comp (A  B) = comp({a, b, c, d, e}) = {f, g} Power Sets - the set of all subsets of a set A is called the power set of A and denoted by 2 A or  (A). –For example for A = {1, 2}, –  (A) = { , {1}, {2}, {1, 2} }


Download ppt "Michaelmas Term 2004 Discrete Mathematics CSC 141 Discrete Mathematics Dr. Corina Sas and Ms. Nelly Bencomo"

Similar presentations


Ads by Google