Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Sets Steve Wolfman, based on notes by Patrice Belleville and others 1.

Slides:



Advertisements
Similar presentations
Functions Reading: Epp Chp 7.1, 7.2, 7.4
Advertisements

Set Operations. When sets are equal A equals B iff for all x, x is in A iff x is in B or … and this is what we do to prove sets equal.
Chapter Three: Closure Properties for Regular Languages
Discrete Mathematics I Lectures Chapter 6
Copyright © Cengage Learning. All rights reserved.
Prof. Johnnie Baker Module Basic Structures: Sets
Sets Lecture 11: Oct 24 AB C. This Lecture We will first introduce some basic set theory before we do counting. Basic Definitions Operations on Sets Set.
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
Section 1.6: Sets Sets are the most basic of discrete structures and also the most general. Several of the discrete structures we will study are built.
Week 21 Basic Set Theory A set is a collection of elements. Use capital letters, A, B, C to denotes sets and small letters a 1, a 2, … to denote the elements.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Functions Steve Wolfman, based on notes by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes.
1 Section 1.7 Set Operations. 2 Union The union of 2 sets A and B is the set containing elements found either in A, or in B, or in both The denotation.
Discrete Mathematics Lecture 4 Harper Langston New York University.
Discrete Structures Chapter 3 Set Theory Nurul Amelina Nasharuddin Multimedia Department.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Functions Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 DFAs in Depth Benjamin Israel Notes heavily borrowed from Steve Wolfman’s,
Sets 1.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 DFAs in Depth Steve Wolfman, based on notes by Patrice Belleville and others.
Sets 1.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Sets Steve Wolfman, based on notes by Patrice Belleville and others.
Rosen 1.6. Approaches to Proofs Membership tables (similar to truth tables) Convert to a problem in propositional logic, prove, then convert back Use.
Sets.
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,
1 Introduction (Pengenalan) n About the Lecturer: –Nama lengkap: Heru Suhartanto, Ph.D –Kantor: Ruang 1214, Gedung A, Fakultas Ilmu Komputer UI, Depok.
1.1 Sets and Logic Set – a collection of objects. Set brackets {} are used to enclose the elements of a set. Example: {1, 2, 5, 9} Elements – objects inside.
1 Sets CS 202, Spring 2007 Epp, chapter 5 Aaron Bloomfield.
Week 15 - Wednesday.  What did we talk about last time?  Review first third of course.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
Mathematical Preliminaries (Hein 1.1 and 1.2) Sets are collections in which order of elements and duplication of elements do not matter. – {1,a,1,1} =
Sets Defined A set is an object defined as a collection of other distinct objects, known as elements of the set The elements of a set can be anything:
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
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.
CS201: Data Structures and Discrete Mathematics I
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
CompSci 102 Discrete Math for Computer Science
Copyright © Cengage Learning. All rights reserved.
Section 2.1. Section Summary Definition of sets Describing Sets Roster Method Set-Builder Notation Some Important Sets in Mathematics Empty Set and Universal.
Naïve Set Theory. Basic Definitions Naïve set theory is the non-axiomatic treatment of set theory. In the axiomatic treatment, which we will only allude.
1 Introduction to Abstract Mathematics Sets Section 2.1 Basic Notions of Sets Section 2.2 Operations with sets Section 2.3 Indexed Sets Instructor: Hayk.
ELEMENTARY SET THEORY.
Chapter 2 With Question/Answer Animations. Section 2.1.
Snick  snack Supplement: Worked Set Proofs Based on work by Meghan Allen.
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.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
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)
Dr. Ameria Eldosoky Discrete mathematics
CPSC 121: Models of Computation 2012 Summer Term 2
Set, Combinatorics, Probability & Number Theory
Chapter 1 Logic and Proofs Homework 2 Given the statement “A valid password is necessary for you to log on to the campus server.” Express the statement.
Chapter 5, Set Theory 1.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
CS100: Discrete structures
Set Theory A B C.
CPSC 121: Models of Computation 2016W2
Lecture Sets 2.2 Set Operations.
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:

snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Sets Steve Wolfman, based on notes by Patrice Belleville and others 1

Outline Prereqs, Learning Goals, and Quiz Notes Out-of-class notes on set definitions What’s the Use of Sets (history & DFAs) More set operations –Cardinality (size) –Power set (and an induction proof) –Cartesian products (and application to DFAs) Set proofs Next Lecture Notes 2

Learning Goals: Pre-Class By the start of class, you should be able to: –Define the set operations union, intersection, complement, and set difference and the logical operations subset and set equality in terms of predicate logic and set membership (  ). –Translate between sets represented explicitly (possibly using ellipses “…”, e.g., {4, 6, 8, …}) and using “set builder” notation (e.g., {x  Z + | x 2 > 2  x is even}). –Execute the union, intersection, complement, set difference, subset, and set equality operations on sets expressed explicitly, using set builder notation, or a combination of these and set operators. –Interpret the empty set symbol , including the fact that the empty set has no members and that it is a subset of any set. 3

Learning Goals: In-Class By the end of this unit, you should be able to: –Define the power set and cartesian product operations in terms of predicate logic and set membership/subset relations. –Execute the power set, cartesian product, and cardinality operations on sets expressed through any of the notations discussed so far. –Apply your proof skills to proofs involving sets. –Relate DFAs to sets. 4

Quiz Notes (2009W1... Still relevant?) Generally great, but… A  B  Every element of A is an element of B. So, ~(A  B)  Some element of A is not an element of B. 5

Quiz Notes (2009W1.. Still relevant?) How many elements does { } have? a.0 b.1 c.2 d.3 e.None of these. 6

Quiz Notes (2009W1.. Still relevant?) Consider mystery set M, whose contents are a national secret. Is { }  M? a.Definitely yes b.It depends (not enough information) c.Definitely no d.The question is ill-defined e.None of these 7

Outline Prereqs, Learning Goals, and Quiz Notes Out-of-class notes on set definitions What’s the Use of Sets (history & DFAs) More set operations –Cardinality (size) –Power set (and an induction proof) –Cartesian products (and application to DFAs) Set proofs Next Lecture Notes CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 8

Flashback: Sets A set is a collection of elements: –the set of students in this class –the set of lowercase letters in English –the set of natural numbers (N) –the set of all left-handed students in this class An element is either in the set ( x  S ) or not ( x  S ). Is there a set of everything? CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 9

Flashback: Sets and Predicates Is there a predicate that defines each set? –the set of students in this class –the set of lowercase letters in English –the set of natural numbers (N) –the set of all left-handed people in this class CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 10

Flashback: Quantifier Example Someone in this class is left-handed (where C is the set of people in this class):  x  C, L(x) CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 11

What is a Set? A set is an unordered collection of objects. The objects in a set are called members. ( a  S indicates a is a member of S ; a  S indicates a is not a member of S ) A set contains its members. CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 12

Describing Sets (1/4) Some sets… A = {1, 3, 9} B = {1, 3, 9, 27, snow} C = {1, 1, 3, 3, 9, 9} D = {A, B} D' = { {1, 3, 9}, {1, 3, 9, 27, snow} } E = { } CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 13

Describing Sets (2/4) Some sets… A = {1, 5, 25, 125, …} B = {…, -2, -1, 0, 1, 2, …} C = {1, 2, 3, …, 98, 99, 100} “…” is an ellipsis CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 14

Describing Sets (3/4) Some sets, using set builder notation: A = {x  N |  y  N, x = 5 y } B = {2 i - 1 | i is a prime} C = {n  Z | 0 < n  100} To read, start with “the set of all”. Read “ | ” as “such that”. To read A : “the set of all natural numbers x such that x is a (natural) power of 5 ” CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 15

Describing Sets (4/4) Graphical depiction of sets: Venn diagrams. Draw the set of all five-letter things. All red things? All red, five-letter things? fire truck snows happiness Texas heart books 7  U CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 16

Describing Sets (4/4) Graphical depiction of sets: Venn diagrams. Draw the set of all five-letter things. All red things? All red, five-letter things? fire truck snows happiness Texas heart books 7  U CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 17

Containment A set A is a subset of a set B iff  x  U, x  A  x  B. We write A is a subset of B as A  B. If A  B, can B have elements that are not elements of A ? CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 18

Containment A set A is a subset of a set B iff  x  U, x  A  x  B. We write A is a subset of B as A  B. If A  B, can B have elements that are not elements of A ? Yes, but A can’t have elements that are not elements of B. CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 19

Membership and Containment A = {1, {2}} Is 1  A ? Is {1}  A ? Is 1  A ? Is {1}  A ? Is 2  A ? Is {2}  A ? Is 2  A ? Is {2}  A ? CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 20

Membership and Containment A = {1, {2}} Is 1  A ? Yes Is {1}  A ? Yes Is 1  A ? No (not meaningful since 1 is not a set) Is {1}  A ? No Is 2  A ? No Is {2}  A ? No Is 2  A ? No (not meaningful since 2 is not a set) Is {2}  A ? Yes CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 21

Thought Question What if A  B and B  A ? CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 22

Set Equality Sets A and B are equal — denoted A = B — if and only if  x  U, x  A  x  B. Can we prove that that’s equivalent to our mutual subset relationship? CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 23

Set Equality Sets A and B are equal — denoted A = B — if and only if  x  U, x  A  x  B. Can we prove that that’s equivalent to our mutual subset relationship? Yes, using a standard predicate logic proof in which we note that p  q is logically equivalent to p  q  p  q. CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 24

Set Union The union of A and B — denoted A  B — is {x  U | x  A  x  B}. A  B is the blue region... AB U CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 25

Set Intersection The intersection of A and B — denoted A  B — is {x  U | x  A  x  B}. A  B is the dark blue region... AB U CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 26

Set Difference The difference of A and B — denoted A - B — is {x  U | x  A  x  B}. A – B is the pure blue region. AB U CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 27

Set Complement The complement of A — denoted A — is {x  U | x  A}. A is everything but the blue region. A U Can we express this as a set difference? CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 28

Set Operation Identities Many logical equivalences have analogous set operation identities. Here are a few… read more in the text! A  B = B  A Commutative Law (A  B)  C = (A  C)  (B  C) Distributive Law (A  B) = A  B DeMorgan’s Law A  U = A U as identity for ... CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 29

Outline Prereqs, Learning Goals, and Quiz Notes Out-of-class notes on set definitions What’s the Use of Sets (history & DFAs) More set operations –Cardinality (size) –Power set (and an induction proof) –Cartesian products (and application to DFAs) Set proofs Next Lecture Notes 30

What Are Sets Good For? Historically: Mathematicians attempted to formalize set theory to create a foundation for all of mathematics. Essentially all mathematical constructs can be defined in terms of sets. Good news: this means sets are a powerful way to communicate many types of ideas. 31

Bad News: Russell’s Paradox (and other problems) Does the “set of all sets that contain themselves” contain itself? a.Yes, definitely. b.Maybe, either way is fine. c.No, definitely not. d.None of these. 32

Bad News: Russell’s Paradox (and other problems) Does the “set of all sets that do not contain themselves” contain itself? a.Yes, definitely. b.Maybe, either way is fine. c.No, definitely not. d.None of these. Same question, different form: “Imagine a barber that shaves every man in town who does not shave himself. Does the barber shave himself?” 33

What Are Sets Good For? Applications for us: Codifying and communicating ideas. For example, formalizing DFAs... 34

What is a DFA? The input language is: ________________ The states are: ______ The start state is: ____ The accepting states are: _____________ What’s left? a b b a,b a 35

The Transition Function The arrows in our DFA have the following properties: An arrow starts from every state, for every letter in the input alphabet. The arrows lead to other states. We’ll formalize this as the function N soon, which will complete our DFA! a b b a,b a 36

What is a DFA? (Deterministic Finite Automaton) Ithe (finite) set of letters in the input language. Sthe (finite) set of states. s 0 the initial state; s 0  S. Fthe set of accepting (“final”) states; F  S. Nthe next-state function, to be described. These are just standard names we use, but the constraints make sense regardless of names. a b b a,b a 37

Problem: Formalizing an Example DFA For this DFA: I= { } S= { } s 0 = F= { } N: (, )  (, )  a b b a,b a 38

Worked: Formalizing an Example DFA For this DFA: I= { a, b } S= { t, m, b, g} s 0 = t F = { t, b } N: (t, a)  m (t, b)  b (m, a)  g (m, b)  b (b, a)  b (b, b)  b (g, a)  g (g, b)  g a b b a,b a t m b g “g” is for “garbage”. A garbage state is a rejecting state you cannot escape. 39

Problem: Testing the DFA Formalism Ithe (finite) set of letters in the input language. Sthe (finite) set of states. s 0 the initial state; s 0  S. Fthe set of accepting (“final”) states; F  S. Nthe next-state function, to be described. Must a DFA have an initial state? Can a DFA have more than one initial state? Must a DFA have an accepting state? Can all states in a DFA be accepting? Can the initial state be accepting? a. Yes b. No c. Not enough information. 40

Testing the DFA Formalism Must a DFA have an initial state? Can a DFA have more than one initial state? Must a DFA have an accepting state? Can all states in a DFA be accepting? Can the initial state be accepting? s 0 is the initial state; so, yes. s 0 is the only initial state; so, no. F  S. Is   S? F  S. Is S  S? s 0  S and F  S. Can s 0  F? 41

Must a DFA Have an Accepting State? What does a DFA with no accepting states look like? What language does it accept? 42

Can All States in a DFA Be Accepting? What does a DFA with no rejecting states look like? What language does it accept? 43

Outline Prereqs, Learning Goals, and Quiz Notes Out-of-class notes on set definitions What’s the Use of Sets (history & DFAs) More set operations –Cardinality (size) –Power set (and an induction proof) –Cartesian products (and application to DFAs) Set proofs Next Lecture Notes 44

Cardinality The cardinality of a set A — denoted |A| — is the set’s size. For finite sets, the cardinality of the set is the number of elements it contains… |A| = |{1, 3}| = 2 |B| = |{1, 3, 27, snow}| = 4 |C| = |{ {1, 3}, {1, 3, 27, snow} }| = 2 |D| = |  | = 0 45

How Big Is a Set? How big are these sets? A = {1, 3} B = {1, 3, 27, snow} C = { {1, 3}, {1, 3, 27, snow} } D =  E = N F = { …, -4, -2, 0, 2, 4, … } a. 0 b. 1 c. 2 d. 3 e. None of these 46

Cardinality of Infinite Sets? For now, we won’t worry about the cardinality of infinite sets. Why? Well, we can’t count the members of such sets. Side note: Depending on our definition, however, the results can be surprising. For example, under the standard definition of cardinality, these have the same cardinality: E = N = {1, 2, 3, … } F = { …, -4, -2, 0, 2, 4, … } Why? Try “folding” the set F over creatively. 47

Problem: Cardinality Exercises Given the definitions: A = {1, 2, 3} B = {2, 4, 6, 8} What are: |A|= _________ |B|= _________ |A  B|= _________ |A  B|= _________ |A – B|= _________ |B – A|= _________ |{{}}|= _________ |{  }|= _________ |{{  }}|= _________ a. 0 b. 1 c. 2 d. 3 e. None of these 48

Worked Cardinality Exercises Given the definitions: A = {1, 2, 3} B = {2, 4, 6, 8} What are: |A|= 3________ |B|= 4________ |A  B|= 6________ |A  B|= 1________ |A – B|= 2________ |B – A|= 3________ |{{}}|= 1________ |{  }|= 1________ |{{  }}|= 1________ 49

Outline Prereqs, Learning Goals, and Quiz Notes Out-of-class notes on set definitions What’s the Use of Sets (history & DFAs) More set operations –Cardinality (size) –Power set (and an induction proof) –Cartesian products (and application to DFAs) Set proofs Next Lecture Notes 50

A Touch of Logic Consider the four propositional logic variables p, q, r, and s. What are all the different ways we can assign truth values to each of these? Now, imagine a set S that contains exactly the true variables among p, q, r, and s. What are the possible “ S s” (depending on p, q, r, and s ’s truth values)? 51

A Touch of Logic: Rephrased Consider the set {p, q, r, s}. What are all the subsets of this set? Equivalently, what is: {S  U | S  {p,q,r,s}} ? 52

Power Sets The power set of a set T — denoted P(T) — is the set of all subsets of T : { S  U | S  T } 53

Using Logic to Build Power Sets pqrs Set from P(…) FFFF {} FFFT {s} FFTF {r} FFTT {r,s} FTFF {q} FTFT {q,s} FTTF {q,r} FTTT {q,r,s} pqrs Set from P(…) TFFF {p} TFFT {p,s} TFTF {p,r} TFTT {p,r,s} TTFF {p,q} TTFT {p,q,s} TTTF {p,q,r} TTTT {p,q,r,s} So, how big is the power set of a set? P({p,q,r,s}) = … 54

Problem: Power Set Exercises Given the definitions: A = {1, 2} B = {2, 4, 6} What are: P(A)= _____________________________ P(B)= _____________________________ |P(A)|= _____________________________ |P(B)|= _____________________________ |P(P(A))|= _____________________________ P(P(A))= _____________________________ P(A  B)= _____________________________ 55

Power Set Exercises (Partially Worked) Given the definitions: A = {1, 2} B = {2, 4, 6} What are: P(A)= {{},{1},{2},{1,2}}___________ P(B)= {{},{2},{4},{6},{2,4},{2,6},{4,6},{2,4,6}} |P(A)|= 4____________________________ |P(B)|= 8____________________________ |P(P(A))|= 16___________________________ P(A  B)= Big; similar to P({p,q,r,s}) P(P(A))= Big; similar to P({p,q,r,s}) 56

Cardinality of a Finite Power Set Theorem: |P(S)| = 2 |S| Basis step: When |S| = 0, what is S ? What is P(S) ? How do we know? 57

Cardinality of a Finite Power Set Inductive Hypothesis: Assume for all sets S of cardinality k  0, |P(S)| = 2 |S|. Inductive step: To prove: Given the induction hypothesis, for all sets T, |P(T)| = 2 |T| when |T| = k+1. The key is to drop an element from a set of size k+1. Then, take the power set. Then, consider how to put the element back in. 58

Worked: Cardinality of a Finite Power Set Basis step: The only set with |S| = 0 (i.e., with no elements) is the empty set {}. P(  ) = {S  P( U ) | S  {}} But, only {} is a subset of {}. So, |P(  )| = 1 =

Worked: Cardinality of a Finite Power Set Inductive step: Consider an arbitrary set T where |T| = k+1  1. (So, T has at least one element!) Let x be an arbitrary element of T. Consider T – {x}. |T – {x}| = k. So, |P(T – {x})| = 2 k by the inductive hypothesis. Furthermore P(T – {x}) is the set of all subsets of T that do not include x. 60

Worked: Cardinality of a Finite Power Set Inductive step (continued): However, there are exactly as many subsets of T that include x as do not include x. (Because each subset of T that does include x can be matched up with exactly one of the subsets that does not include x that is the same but for x.) So, |P(T)| = 2|P(T – {x})| = 2*2 k = 2 k+1 QED! 61

Outline Prereqs, Learning Goals, and Quiz Notes Out-of-class notes on set definitions What’s the Use of Sets (history & DFAs) More set operations –Cardinality (size) –Power set (and an induction proof) –Cartesian products (and application to DFAs) Set proofs Next Lecture Notes 62

Tuples A tuple is an ordered collection of elements. (An n -tuple is a tuple with n elements.) Two tuples are equal when each pair of corresponding elements is the same: (a, 1,  )= (a, 5 – 4, A  A) (a, b, c)  (a, c, b) Actual fact: database people love the word “tuple”. And… why shouldn’t they? Say “two-tuple”. Isn’t that great? 63

Formalizing DFAs: Where the Arrows Come From The arrows in our DFA have the following properties: An arrow starts from every state, for every letter in the input alphabet. The arrows lead to other states. We’ll formalize this as a function soon. What is the set of “things” for which there is an arrow? a b b a,b a t m b g 64

Cartesian Products The Cartesian product of the sets A and B — denoted A  B — is the set of all tuples whose first element is drawn from A and whose second element is drawn from B. In other words, A  B = {(a,b) | a  A  b  B} 65

Cartesian Products and the Cartesian Plane Let’s visualize N  N:

Calculating Cartesian Products What is {a,b}  {1,2,3} : ab (, ) 67

Calculating Cartesian Products What is {a,b}  {1,2,3} : ab ( a, 3 ) ( a, 2 ) ( a, 1 ) ( b, 3 ) ( b, 2 ) ( b, 1 ) The order of the tuples definitely matters! 68

Formalizing DFAs: Where the Arrows Come From The arrows in our DFA have the following properties: An arrow starts from every state, for every letter in the input alphabet. The arrows lead to other states. We’ll formalize this as a function soon. Each tuple of a state and a letter has an arrow. There’s an arrow for every member of S  I a b b a,b a t m b g 69

Example DFA, Revisited For this DFA: I= { a, b } S= { t, m, b, g} s 0 = t F= { t, b } N: (t, a)  m (t, b)  b (m, a)  g (m, b)  b (b, a)  b (b, b)  b (g, a)  g (g, b)  g a b b a,b a t m b g 70

Outline Prereqs, Learning Goals, and Quiz Notes Out-of-class notes on set definitions What’s the Use of Sets (history & DFAs) More set operations –Cardinality (size) –Power set (and an induction proof) –Cartesian products (and application to DFAs) Set proofs Next Lecture Notes 71

Problem: Proofs with Sets (1/2) Prove by contradiction that for all sets A and B, if A  B then A  B = { }. (Note: B contains all elements in the universe that are not in B.) 72

Problem: Proofs with Sets (2/2) Prove for all sets A and B, if A  B then P(A)  P(B). (Note: if A  B and B  C, then A  C.) 73

Outline Prereqs, Learning Goals, and Quiz Notes Out-of-class notes on set definitions What’s the Use of Sets (history & DFAs) More set operations –Cardinality (size) –Power set (and an induction proof) –Cartesian products (and application to DFAs) Set proofs Next Lecture Notes 74

Learning Goals: In-Class By the end of this unit, you should be able to: –Define the power set and cartesian product operations in terms of predicate logic and set membership/subset relations. –Execute the power set, cartesian product, and cardinality operations on sets expressed through any of the notations discussed so far. –Apply your proof skills to proofs involving sets. –Relate DFAs to sets. 75

Next Lecture Learning Goals: Pre-Class By the start of class, you should be able to: –Define the terms domain, co-domain, range, image, and pre-image –Use appropriate function syntax to relate these terms (e.g., f : A  B indicates that f is a function mapping domain A to co- domain B ). –Determine whether f : A  B is a function given a definition for f as an equation or arrow diagram. 76

Next Lecture Prerequisites See the “Functions” readings on the “Textbook and References” section of the website. Complete the quiz on Vista before class. 77

snick  snack Extra Slides: Worked Proofs (Thanks to Meghan Allen) 78

Proofs with Sets #1 version 1 Prove that for all sets A and B: A  B = A  B Proof #1: A  B = {x  U | x  ( A  B)} = {x  U | ~(x  A  x  B)} = {x  U | x  A  x  B} = {x  U | x  A  x  B} = A  B Def’n of  De Morgan’s Def’n of Def’n of  Def’n of 79

Proofs with Sets #1 version 2 Remember that for any two sets C and D, C = D iff C is a subset of D and D is a subset of C. C = D  [C  D  D  C] 80

Proofs with Sets #1 version 2 a)Prove that: A  B  A  B Pick an arbitrary x  A  B, Then x  A  B. ~(x  A  x  B) x  A  x  B x  A  x  B x  ( A  B) Def’n of  De Morgan’s Def’n of Def’n of  81

Proofs with Sets #1 version 2 b)Prove that: A  B  A  B Pick an arbitrary x  A  B Then, x  A  x  B x  A  x  B ~(x  A  x  B) x  A  B x  A  B 82

Proofs with Sets #1 version 2 conclusion We have shown that A  B  A  B and A  B  A  B. Therefore, A  B = A  B. 83

Proof with Sets #2 Prove that, for all sets A, B and C: (A  B) – C = (A – C)  (B – C) This time we’ll use the Set Identities LHS: (A  B) – C = (A  B)  C Set Difference Law = C  (A  B) Commutative Law = (C  A)  (C  B) Distributive Law = (A  C)  (B  C) Commutative Law = (A - C)  (B – C) Set Difference Law 84

Proofs with Sets #3 Prove or disprove, for all sets A and B, A – B = B – A We can disprove this with a counterexample. Let A = {1,2} and B = {2,3} Then, A-B = {1} and B-A = {3} A – B ≠ B – A 85

Proofs with Sets #4 Prove that for all sets A and B, if A  B then A  B =  Proof by contradiction. Assume A  B and A  B  . Then, there exists an element x  A  B. By the definition of intersection, that means x  A and x  B. Since x  B, x  B by the definition of complement. But, A  B, so since x  A, x  B by definition of subset. Thus, x  B and x  B which is a contradiction. Hence the assumption is false and therefore for all sets A and B, if A  B then A  B =  86

Proofs with Sets #5 Prove that for all sets A and B, if A  B then P(A)  P(B) WLOG, let A and B be sets. Proof by antecedent assumption: Assume A  B. Now, consider X  P(A). X  A by the definition of power set. But, because A  B, X  B by the transitive property of subsets* and thus, by the definition of power set, X  P(B). This proves that for all X, if X  P(A) then X  P(B) and so P(A)  P(B). *Epp -Theorem

Proofs with Sets #6 version 1 Prove that for all sets S,   S. We proceed by contradiction. Assume that there is a set S such that the empty set is not a subset of S. Then, by definition of subset, there must be some element x of the empty set that is not an element of S. However, the empty set has no elements. This is a contradiction. QED 88

Proofs with Sets #6 version 2 Prove that for all sets S,   S. Note that   S   x  U, x    x  S   x  U, x    x  S. We proceed by proving this last statement. We know nothing is an element of the empty set:  x  U, x  . By generalization, it follows that:  x  U, x    x  S. QED 89