Chapter 3 – Set Theory. What is a Set? A set is a collection of distinguishable objects called elements. When writing out the elements of a set we use.

Slides:



Advertisements
Similar presentations
More Set Definitions and Proofs 1.6, 1.7. Ordered n-tuple The ordered n-tuple (a1,a2,…an) is the ordered collection that has a1 as its first element,
Advertisements

Discrete Mathematics I Lectures Chapter 6
Copyright © Cengage Learning. All rights reserved.
Prof. Johnnie Baker Module Basic Structures: Sets
Discrete Mathematics Lecture 5 Alexander Bukharovich New York University.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Discrete Structures & Algorithms Basics of Set Theory EECE 320 — UBC.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 1: (Part 2): The Foundations: Logic and Proofs.
Instructor: Hayk Melikya
(CSC 102) Discrete Structures Lecture 14.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Copyright © Cengage Learning. All rights reserved.
CS 454 Theory of Computation Sonoma State University, Fall 2011 Instructor: B. (Ravi) Ravikumar Office: 116 I Darwin Hall Original slides by Vahid and.
Discrete Structures Chapter 3 Set Theory Nurul Amelina Nasharuddin Multimedia Department.
Chapter 2 The Basic Concepts of Set Theory
Sets 1.
Sets 1.
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 12 Number theory Mathematical induction Proof by induction Examples.
SETS A set B is a collection of objects such that for every object X in the universe the statement: “X is a member of B” Is a proposition.
Operations on Sets – Page 1CSCI 1900 – Discrete Structures CSCI 1900 Discrete Structures Operations on Sets Reading: Kolman, Section 1.2.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Set theory Sets: Powerful tool in computer science to solve real world problems. A set is a collection of distinct objects called elements. Traditionally,
CSE 311 Foundations of Computing I Lecture 8 Proofs and Set Theory Spring
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
Barnett/Ziegler/Byleen Finite Mathematics 11e1 Chapter 7 Review Important Terms, Symbols, Concepts 7.1. Logic A proposition is a statement (not a question.
Basic Structures: Sets, Functions, Sequences, and Sums CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
Discrete Structure Sets. 2 Set Theory Set: Collection of objects (“elements”) a  A “a is an element of A” “a is a member of A” a  A “a is not an element.
DISCRETE COMPUTATIONAL STRUCTURES
CS201: Data Structures and Discrete Mathematics I
CompSci 102 Discrete Math for Computer Science
Copyright © Cengage Learning. All rights reserved.
Week 6 - Friday.  What did we talk about last time?  Solving recurrence relations.
ELEMENTARY SET THEORY.
Discrete Mathematical Structures 4 th Edition Kolman, Busby, Ross © 2000 by Prentice-Hall, Inc. ISBN
Chapter SETS DEFINITION OF SET METHODS FOR SPECIFYING SET SUBSETS VENN DIAGRAM SET IDENTITIES SET OPERATIONS.
Mathematical Preliminaries
2.1 Sets 2.2 Set Operations –Set Operations –Venn Diagrams –Set Identities –Union and Intersection of Indexed Collections 2.3 Functions 2.4 Sequences and.
CSE 311 Foundations of Computing I Lecture 9 Proofs and Set Theory Autumn 2012 CSE
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
Chapter 2 With Question/Answer Animations. Section 2.1.
Introduction to Set theory. Ways of Describing Sets.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
Review 2 Basic Definitions Set - Collection of objects, usually denoted by capital letter Member, element - Object in a set, usually denoted by lower.
Laws of Boolean Algebra Commutative Law Associative Law Distributive Law Identity Law De Morgan's Theorem.
Discrete Mathematics CS 2610 January 27, part 2.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
1 Section 1.2 Sets A set is a collection of things. If S is a set and x is a member or element of S we write x  S. Othewise we write x  S. The set with.
CSE 311: Foundations of Computing Fall 2013 Lecture 8: Proofs and Set theory.
1 Topic Sets (5.1, 5.2, 5.3). 2 Original author of the slides: Vadim Bulitko University of Alberta Modified by.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
1 Set Theory Second Part. 2 Disjoint Set let A and B be a set. the two sets are called disjoint if their intersection is an empty set. Intersection of.
Section 2.1. Sets A set is an unordered collection of objects. the students in this class the chairs in this room The objects in a set are called the.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Week 8 - Wednesday.  What did we talk about last time?  Relations  Properties of relations  Reflexive  Symmetric  Transitive.
Introduction to Set Theory (§1.6) A set is a new type of structure, representing an unordered collection (group, plurality) of zero or more distinct (different)
Sets, Permutations, and Combinations. Lecture 4-1: Sets Sets: Powerful tool in computer science to solve real world problems. A set is a collection of.
Lecture 6 Set Theory.
Applied Discrete Mathematics Week 1: Logic and Sets
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Set, Combinatorics, Probability & Number Theory
Week 7 - Monday CS322.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
Exercises Show that (P  Q)  (P)  (Q)
CS100: Discrete structures
Set Theory A B C.
Set Operations Section 2.2.
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Presentation transcript:

Chapter 3 – Set Theory

What is a Set? A set is a collection of distinguishable objects called elements. When writing out the elements of a set we use { }. Two kinds of set definitions – list-based and rule-based. The above are examples of list-based definitions of sets. We list all the elements (or enough so that the pattern is obvious). A rule-based definition of a set involves a predicate. { 1, 2, 3,... } -- set of positive integers (Natural Numbers)‏ {red, green, blue} -- primary colors set P = { x : P(x) } E = { x : x is an even integer } = { 0, +2, -2, +4, -4,... } We say “the set of all x such that...”.

Alternative Definitions: Give an alternative definition. A = {x : x is an integer and x 2 + 4x = 12 } B = {x : x is a day of the week not containing the letter 'u'} C = { n 2 : n is an integer }

Well-known Sets: Empty Set: Ø Natural Numbers: N -- { 1, 2, 3,... } Integers: Z -- { 0, ±1, ±2, ±3,... } Rational Numbers: Q -- { a/b : a, b Є Z and b != 0 } Real Numbers: R -- { all decimals } The above sets correspond very closely to the data types of many programming languages.

Data Types: A set of objects (values) together with a well-defined set of operations. When we declare a variable to be of a certain type we are saying that any value it takes on must come from a known set of values. Note that in perl there is a numeric value you can assign to a scalar variable and this numeric value is not a number – NaN.

Sets and Their Operations: A = {1, 2, 3} then we say that A is a subset of N. A set is called a subset of another set if every element of the first set is also an element of the second. We denote this as We use a Venn Diagram to represent this: A B U A B Universe of Discourse or Universal Set

Set Equality: Two sets are defined to be equal if each is a subset of the other. Symbolically we write: Exercise: Define A = {n : n 2 is an odd integer} and B = {n: n is an odd integer}. Prove A = B. A = B if (x A => x B) and (x B => x A) are both true єєє є If x A, then x 2 = 2m + 1. If x is even then x = 2n and so x 2 = 4n 2 so x 2 is even, a contradiction. So by contraposition, x can not be even so x is odd. Hence x B. Now suppose x B. Then x = 2m +1 and x 2 = (2m + 1) 2 = 2m 2 + 4m + 1 = 2(m 2 + 2m) + 1 and so x 2 is odd. Therefore x A. This shows A = B. є є є є

Union: The Union of two sets, A and B, is the set A B = { x: x A or x B} U єє AB

Intersection: The Union of two sets, A and B, is the set A B = { x: x A and x B} U єє B A

Complement of A Relative to B: The Complement of the set A relative to a set B B, is the set A \ B = { x: x A and x B} єє AB

Complement Set: If no “relative” set is mentioned then the complement of a set A is with respect to a Universal Set (represented as the box in our Venn Diagrams). It is everything that is not in A. A Complement of A

Symmetric Difference of A and B: The Complement of the set A relative to a set B B, is the set A B = { x: x A and x B} { x: x B and x A} є AB є єєє U ∆

Examples: A = { 1, 3, 5, 7 }, B = { 2, 4, 6, 8 }, C = {1, 2, 3, 4,5 } A B = { 1, 2, 3, 4, 5, 6, 7, 8 } B C = { 2, 4 } A \ C = { 7 } B C = { 6, 8 } { 1, 3, 5 } = { 1, 3, 5, 6, 8 } U U U ∆

Exercise: Suppose A = { x : 1 <= x <= 12 and x is an even integer } and B = { x : 1 <= x <= 12 and x is an integer multiple of 3 } Verify ~(A B) = ~A ~B. U U Calculate: ~(A B) = Calculate ~A ~B = U U A = { 2, 4, 6, 8, 10, 12 } B = {3, 6, 9, 12 } U = { 1, 2,..., 12 } ~ { 6, 12 } = { 1, 2, 3, 4, 5, 7, 8, 9, 10, 11 } = {1, 3, 5, 7, 9, 11 } {1, 2, 3, 5, 7, 8, 10, 11 } = { 1, 2, 3, 4, 5, 7, 8, 9, 10, 11 } U

Algebra of Sets: There is a nice correspondence between the boolean operators – and, or, not and => on predicates and the set operators intersection, union, complement and subset.

Example (de Morgan's Law): Prove that for any two sets, A and B, ~(A B) = ~A ~B. So we reduced a claim about sets to two compound logical propositions - ~(P and Q) and ~P or ~Q. U U ~(A B) = {x: x (A B)} = {x: not ( x (A B))} = { x: not ( x A and x B )} U Є U Є U ЄЄ ~A ~B = {x: (x A) or (x B)} = { x: (not ( x A)) or (not( x B )} Є ЄЄ UЄ Exercise: Prove the above are logically equivalent

Algebra of Sets: The algebra of sets is governed by certain laws just as basic arithmetic is governed by laws of arithmetic such as association, commutativity, etc. Associative Laws: A (B C) = (A B) C A (B C) = (A B) C U U UUU UUU Commutative Laws: B C = C B B C = C B UU UU Identity Laws: B = B B = B B = B = U U O U OO U U UU

Algebra of Sets (cont): Finally Idempotent Laws: B B = B B B = B U U Distributive Laws: A (B C) = (A B) (A C) A (B C) = (A B) (A C) UUU U U UU UU U Complement Laws: A ~A = A ~A = ~ = ~ = ~(~A) = A O U O O UU U U de Morgan's Laws: ~(B C) = ~C ~B ~(B C) = ~C ~B UU UU

Example: Use the laws of algebra of sets to prove: A B = (A B) ~(A B)‏ Δ Proof: A B is symmetric difference. It is equal to (A ~B) (B ~A)‏ However U U U (A B) ~(B A) = (A B) ((~A) (~B)) -- deM = ((A B) ~A) ((A B) ~B) UU U ∆ U U U U UU U U UU U = ((~A) (A B)) ((~B) (A B)) -- Comm Law = (((~A) A)) ((~A) B)) (((~B) A) ((~B) B))‏ --Dist Law = (((~A) A)) (B (~A))) ((A (~B)) ((~B) B))‏ --Comm Law =( (B (~A))) ((A (~B)) ) --Comp Law = (A ~B) (B ~A) -- Comm and Ident Law -- Dist Law U U UUU U U U UUU UUU UU UU UUU U U U U ОО the same UU

Further Properties of Sets: The cardinality of a finite set is the number of elements in the set (written |S|). If A and B are finite sets then |A B| = |A| + |B| - |A B|. Proof: A B = (A\B) (A B) (B\A)‏ so |A B| = |A\B| + |A B| + |B\A| Suppose |A\B| = m, |A B| = n, |B\A| = p Then |A B| = m + n + p = (m + n) + (n + p) – n = |A| + |B| - |A B| AB A \ B A B B \ A U U U U U U U U U U U U

Exercise: 63 students study CS – 16 with the Accounting option, 37 with the business option and 5 studied both. How many studied neither ? Ans: 15

Cartesian Products: An ordered pair is a tuple (a,b) where a A and b B. A cartesian product A x B = {(a,b): a A, b B}. Cartesian products are fundamentally important because they are the basis of all functions (math) and relations (dbms). R 2, the real plane, is an example of a cartesian product. If A 1, A 2, A 3,..., A n are a collection of sets then A 1 x A 2 x A 3 x... x A n = { (a 1,a 2,a 3,..., a n ) : a 1 A 1,..., a n A n } If A 1 = A 2 = A 3 =... = A n = A we express this as A n. єє єє єє

Relational Database Example: The rows in the Employee table correspond in a 1-1 fashion to employees in a company. They also belong to the following cartesian product EmployeeID EName DOB Gender Employee {EmployeeID} x {EName} x {DOB} x {Gender} You can refer to all the rows of the cartesian product that lie in Employee as information rows and the rows outside Employee, the rows that don't correspond to reality as the noise rows.

Example: If B = {0,1} describe B 8. Suppose S is a finite ordered set with elements {s 1, s 2,..., s n }. Suppose A S. We define a characteristic function that corresponds to A as: So f A corresponds to an ordered tuple of n 0s and 1s. f A : S --> {0,1} where f A (s i ) = 1 if s i A = 0 if s i A є є

Example (cont): S = {1,2,3,4,5,6,7,8}, A = {2,3,4,6,7}, B = {1,3,4,5} f A = , f B = Find A B. This is just the bit operation f A or f B = This is the characteristic function of the set {1,2,3,4,5,6,7} which is A B. U Exercise: Find A B. U U and is the characteristic function of the set {3,4} so A B = {3,4}. U

Bit Map Example: Go back to the Employee table. Suppose BD = {birth dates}, G = {male, female}. For each element of G, create a sequence of 0s and 1s. These sequences are called bit maps. Repeat the process for every date in BD. Convince yourself that finding all females born on August 4, 1975 is just a matter or ANDing two bit maps. EmployeeID EName DOB Gender Employee male = where i th digit is 1 iff i th employee is male female = where i th digit is 1 iff i th employee is female

Homework: Do the Exercises at the end of the chapter.

Prolog: Prolog is a logic programming language. Prolog uses facts and rules to deduce new facts. % prolog facts % parent(x,y) means x is the parent of y parent(george_1, george_2). parent(george_3, george_4). parent(george_3,edward). parent(edward,victoria). parent(victoria,edward_7). parent(edward_7,george_5). parent(george_5,edward_8). parent(george_5,george_6). parent(george_6,elizabeth_2). parent(victoria,alice). parent(alice,victoria_alberta). parent(victoria_alberta,alice_mountbatten). parent(alice_mountbatten,philip). % wife(x,y) means x is the wife of y wife(sophia,george_1). wife(wilemina,george_2). wife(charlotte,george_3). wife(caroline,george_4). wife(adelaide,william_4). wife(victoria,albert). wife(victoria_mary,george_5). wife(elizabeth_qm,george_6). wife(elizabeth_2,philip).

Prolog Rules and Questions: % rules: female(X) :- wife(X,Y). % if X is wife of Y then X is female ancestor(X,Y) :- parent(X,Y). % if X is parent of Y then X is ancestor of Y ancestor(X,Y) :- parent(X,Z), ancestor(Z,Y). % is X is parent of Z and Z is ancestor of Y then X is ancestor of Y %questions female(victoria). yes female(george_3). no

How Do Questions Get Answered: Logically, prolog rules are expressed as quantified predicates: female(X) :- wife(X,Y)‏ can be expressed as X Y wife(X,Y) --> female(X)‏ this is the same as X Y ~wife(X,Y) or female(x)‏ Since this rule is part of the program it is TRUE. If I ask the question female(victoria)‏ then logically I am asking Y ~wife(victoria,Y) or female(victoria)‏ Since wife(victoria,albert) is TRUE, ~wife(victoria,Y) can not be TRUE for all Y. Hence the only way this rule can be true is if female(victoria) is TRUE. AA AA A

How Do Questions Get Answered: Logically, prolog rules are expressed as quantified predicates: female(X) :- wife(X,Y)‏ can be expressed as X Y wife(X,Y) --> female(X)‏ this is the same as X Y ~wife(X,Y) or female(x)‏ Since this rule is part of the program it is assumed TRUE. If I ask the question female(albert)‏ then logically I am asking Y ~wife(albert,Y) or female(albert)‏ Since wife(albert,Y) is never TRUE, ~wife(albert,Y) is TRUE for all Y. Hence the rule can be true even if female(albert) is FALSE. This leads us to note that in prolog, FALSE means “no evidence it is TRUE”. AA AA A

Exercise Understand the logic of finding There are two ancestor(x,y) rules X Y parent(X,Y) -> ancestor(X,Y)‏ X Y Z parent(X,Z) and ancestor(Z,Y) -> ancestor(X,Y)‏ Which can be rewritten ( X Y ~parent(X,Y) or ancestor(X,Y)) or ( X Y Z ~(parent(X,Z) and ancestor(Z,Y)) or ancestor(X,Y)) Which can be rewritten ( X Y ~parent(X,Y) or ancestor(X,Y)) or ( X Y Z ~parent(X,Z) or ~ancestor(Z,Y)) or ancestor(X,Y)) Now we ask the question: ancestor(alice,X). We first try to find as many solutions as possible to ( Y ~parent(alice,Y) or ancestor(alice,Y))‏ Since ~parent(alice,Y) fails for Y == victoria_alberta we can conclude that ancestor(alice,victoria_alberta) is TRUE. AA AAA AA AAA AA AAA A

Exercise Now we work with ( Y ~parent(alice,victoria_alberta) or ~ancestor(victoria_alberta,Y)) or ancestor(alice,Y))‏ ~parent(alice,victoria_alberta) is FALSE and we already have alice as an ancestor of victoria_alberta so we look for a Y that makes ~ancestor(victoria_alberta,Y) fail; Y == alice_mountbatten does this This makes the only way the above quantified pedicate can be TRUE is if ancestor(alice,alice_mountbatten)‏ is TRUE. Continuing in this way we get all royals for whom alice is an ancestor. A

Monty Python: girls are witches. View the video.

Example: Monty Python A witch is a female who burns. Witches burn - because they're made of wood. Wood floats. What else floats on water? A duck; if something has the same weight as a duck it must float. A duck and scales are fetched. The girl and the duck balance perfectly. “Burn the witch!” witch(X) :- female(X), burns(X). burns(X) :- floats(X). floats(wood). floats(duck). floats(X) :- sameWeight(duck,X). sameWeight(duck,girl). female(girl). :- witch(girl)? yes

Exercise: Give as many examples of faulty logic from the skit as you can find. Are any of them inverse or converse reasoning?