1 / 24

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

CSC 141 Discrete Mathematics Dr. Corina Sas and Ms. Nelly Bencomo c.sas@lancaster.ac.uk ; nelly@comp.lancs.ac.uk Computing Department. Course details. weeks 1-10 10 x 50 min lectures Material http://info.comp.lancs.ac.uk/year1/notes/csc141 coursework written work (relevant to exam)

grady-yang
Download Presentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Course details • weeks 1-10 • 10 x 50 min lectures • Material • http://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_course.html Discrete Mathematics

  3. Syllabus • Sets • Relations • Functions • Recursion • Logic • Boolean • propositional • predicate logic Discrete Mathematics

  4. Overview • Discrete Maths • Sets • Defining sets • Set operations • Subsets • Universal and power set Discrete Mathematics

  5. Objectives • Understanding the relevance of discrete maths for computer science • Understanding the basic ideas about sets • Facility with basic ideas about sets Discrete Mathematics

  6. Discrete maths • What • discrete objects • Why • formal specification • infinity or indefiniteness • reusability Discrete Mathematics

  7. 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 Discrete Mathematics

  8. 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} Discrete Mathematics

  9. 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 Discrete Mathematics

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

  11. (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 Answers Discrete Mathematics

  12. 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 =  Discrete Mathematics

  13. 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 Discrete Mathematics

  14. 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 Discrete Mathematics

  15. 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) Discrete Mathematics

  16. 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 =  Discrete Mathematics

  17. 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 <x, y>. • Two ordered pairs <a, b> and <c, d> are equal if and only if a = c and b = d. For example the ordered pair <1, 2> is not equal to the ordered pair <2, 1>. • The set of all ordered pairs <a, b>, 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 = {<1, a>, <1, b>, <2, a>, <2, b>, <3, a>, <3, b>} . • Example 2: For the same A and B as in Example 1, B x A = {<a, 1>, <a, 2>, <a, 3>, <b, 1>, <b, 2>, <b, 3>} . 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. Discrete Mathematics

  18. Set operations - Exercises • if A = {a, b, c, y}, B = {a, b, c , d, e} and C = {x, y} evaluate: • A  (B  C) • (A  B)  C • C – A • (A – B) – C • A – (B – C) • (A  C)  B • A  (C  B) Discrete Mathematics

  19. Answers • A • {y} • {x} •  • {y} • {a, b, c , d, e, y} • A Discrete Mathematics

  20. 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? Discrete Mathematics

  21. 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: • B  B • B  B • B  A • C  A • (B  C)  A • D  A • (D  C)  A • (D  C)  A Discrete Mathematics

  22. Answers • true (of any set) • false (of any set) • true • true • true • false • true • false Discrete Mathematics

  23. 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) Discrete Mathematics

  24. 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   2A  or  (A) . • For example for A = {1, 2},   • (A) = {, {1}, {2}, {1, 2} } Discrete Mathematics

More Related