cpsc 121 models of computation
play

CPSC 121: Models of Computation Module 11: Sets, Functions and DFAs. - PowerPoint PPT Presentation

CPSC 121: Models of Computation Module 11: Sets, Functions and DFAs. CPSC 121 2016W T1 1 Module 11: Sets, Functions and DFAs By the start of class, you should be able to: Define the set operations union, intersection, complement and


  1. CPSC 121: Models of Computation Module 11: Sets, Functions and DFAs. CPSC 121 – 2016W T1 1

  2. Module 11: Sets, Functions and DFAs By the start of class, you should be able to: Define the set operations union, intersection, complement and 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 in Z + | x 2 > 10 and x is even }). Execute set operations on sets expressed explicitly, using set builder notation, or a combination of these. CPSC 121 – 2016W T1 2

  3. Module 11: Sets, Functions and DFAs By the start of class, you should be able to: Interpret the empty set symbol, including the fact that the empty set has no members and that it is a subset of any set. 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. CPSC 121 – 2016W T1 3

  4. Module 11: Sets, Functions and DFAs. CPSC 121: the BIG questions: ? ? ? 1. How does the computer (e.g. Dr. Racket) decide if ? ? the characters of your program represent a name, a number, or something else? How does it figure ? out if you have mismatched " " or ( )? ? ? ? More generally: ? What can we compute? ? Are there problems we can not solve? ? ? ? ? ? ? CPSC 121 – 2016W T1 4

  5. Module 11: Sets, Functions and DFAs By the end of this module, you should be able to: Define the terms injective (one-to-one), surjective (onto), bijective (one-to-one correspondence), and inverse. Determine whether a given function is injective, surjective, and/or bijective. Relate DFAs to sets and functions. Better understand the limitations of DFAs, that is, what they can and can not do. CPSC 121 – 2016W T1 5

  6. Final Exam information Announcements: Final exam: Monday December 19 th , 8:30 in OSBO. Questions & Answers Sessions (locations TBD): Alice: Wednesday December 14 th , 14:00 to 16:00 Patrice: Thursday December 15 th , 14:00 to 16:00 There will be additional office hours; they will be posted on the course web site. CPSC 121 – 2016W T1 6

  7. Final Exam Information Final exam details: 2.5 hours Covers everything discussed in the course includes labs, although you don't need to memorize all of the solutions. Slightly more emphasis on later topics. The following will be provided if necessary Logical equivalences, rules of inference, powers of 2, regular expression syntax You can bring one 8.5 x 11in 2-sided sheet of paper. CPSC 121 – 2016W T1 7

  8. Teaching/TA Evaluations Teaching assistants: Adam Jozefiak; Angad Kalra; Arshdeep Ganda; Cindy Tu Christine Liu; Elad Michaeli; Hannah Lin; Harsh Patel; Jastine Irwan; Zara Lim; Jessica Que; Jingwei Zhang Jonathan Budiardjo; Leo Sporn; Linh Phan; Luke Schuster Minnie Liu; Pinia Chandra; Sherry Yuan; Willis Peng; Xuejie Tang Yi Ren; Yves Chan CPSC 121 – 2016W T1 8

  9. Teaching/TA Evaluations Labs: CPSC 121 – 2016W T1 9

  10. Module 11: Sets, Functions and DFAs Module Summary Sets. Cardinality, Power sets and Cartesian Products. Injections, surjections, bijections and inverses. DFAs and regular expressions. Computations that we are unable to perform. CPSC 121 – 2016W T1 10

  11. Module 11.1: Sets How does Set Theory fit in with what we have been doing so far in the course? Every set operation is defined in terms of predicate logic and the basic predicate ∈ . So we prove theorems about sets by figuring out which predicate logic statement corresponds to the terms and operations used in the theorem. applying already known proof techniques. No new proof techniques are needed! CPSC 121 – 2016W T1 11

  12. Module 11.1: Sets Confusion: ∈ versus ⊆. The ∈ predicate takes in an element x and a set S, and returns true if the element x belongs to S. The ⊆ predicate takes in two sets S and T, and returns true if every element of S is also an element of T. That is, if ∀ x ∈ D, x ∈ S → x ∈ T CPSC 121 – 2016W T1 12

  13. Module 11.1: Sets Historical Notes: Mathematicians formalized set theory to create a foundation for all of mathematics. Essentially all mathematical constructs can be defined in terms of sets. Hence sets are a powerful means of formalizing new ideas. But we have to be careful! CPSC 121 – 2016W T1 13

  14. Module 11.1: Sets Russel's paradox (part 1). Let S be the set of all sets that contain themselves. Does S contain itself? a) Yes, definitely. b) No, certainly not. c) Maybe (either way is fine). d) None of the above. ▷ CPSC 121 – 2016W T1 14

  15. Module 11.1: Sets Russel's paradox (part 2). Let S be the set of all sets that do not contain themselves (that is, S ∉ S). Does S contain itself? a) Yes, definitely. b) No, certainly not. c) Maybe (either way is fine). d) None of the above. ▷ CPSC 121 – 2016W T1 16

  16. Module 11.1: Sets Despite this, sets (and functions) are incredibly useful. E.g. We can definite valid DFAs formally: a DFA is a 5-tuple ( Σ , S, s 0 , F, δ ) where Σ is a finite set of characters (input alphabet). S is a finite set of states. s 0 ∈ S is the initial state. F ⊆ S is the set of accepting states. δ : S x Σ → S is the transition function. CPSC 121 – 2016W T1 18

  17. Module 11: Sets, Functions and DFAs Module Summary Sets. Cardinality, Power sets and Cartesian Products. Injections, surjections, bijections and inverses. DFAs and regular expressions. Computations that we are unable to perform. CPSC 121 – 2016W T1 19

  18. Module 11.2: Cardinality, Power sets, etc Cardinality: the number of elements of a set S, denoted by |S|. What is the cardinality of the following set: { 1, 2, 3, { a, b, c }, snow, rain } ? a) 3 b) 6 c) 8 d) Some other integer e) The cardinality of the set is undefined. ▷ CPSC 121 – 2016W T1 20

  19. Module 11.2: Cardinality, Power sets, etc This gets trickier with infinite sets. OPTIONAL Consider A = Z + , B = Z, C = Q (the rationals). Which of these sets have the smaller and larger cardinality? a) Smaller: A, larger: C b) Smaller: A and B, larger: C c) All three sets have the same cardinality d) None of the above. ▷ CPSC 121 – 2016W T1 22

  20. Module 11.2: Cardinality, Power sets, etc Suppose we have a set S with n students, and we want to form a group to go watch a movie. What are the different groups that can we form? OR: we have a circuit with n inputs (so S is the set of inputs). What combinations of inputs might be true? In both cases, we are looking for all the subsets of S. That is, we want to find { T | T ⊆ S } CPSC 121 – 2016W T1 24

  21. Module 11.2: Cardinality, Power sets, etc The power set of a set S, denoted P (S), is the set whose elements are all subsets of S. Given the definitions A = { a, b, f }, B = { b, c }, what are: a) P (A) b) P (A - B) c) | P (A ∩ B)| d) | P (A ∪ B)| e) A c CPSC 121 – 2016W T1 25

  22. Module 11.2: Cardinality, Power sets, etc The Cartesian product of two sets S and T, denoted S x T, is the set { (s, t) | s ∈ S ∧ t ∈ T } . Each element of S x T is called an ordered tuple, or simply a tuple (or, in this case, a 2-tuple or a pair). Two ordered tuples are equal if the elements in corresponding positions are the same. Examples: (3, 7) = (4 – 1, 14 / 2) (3, 7) ≠ (7, 3) CPSC 121 – 2016W T1 26

  23. Module 11.2: Cardinality, Power sets, etc We can visualize Z + x Z + as follows: 5 4 3 2 1 1 2 3 4 5 6 7 8 What is { a, b } x { 8, 5, 1 } ? CPSC 121 – 2016W T1 27

  24. Module 11: Sets, Functions and DFAs Module Summary Sets. Cardinality, Power sets and Cartesian Products. Injections, surjections, bijections and inverses. DFAs and regular expressions. Computations that we are unable to perform. CPSC 121 – 2016W T1 28

  25. Module 11.3: Special types of functions You are already familiar with functions: Every combinational circuit implements a function. booleans e.g. m : B x B x B → B m(a, b, c) = a if c is false, b if c is true Which function is this? Sequential circuits and Java methods are not always functions. Why not? CPSC 121 – 2016W T1 29

  26. Module 11.3: Special types of functions You are already familiar with functions: Every combinational circuit implements a function. booleans e.g. m : B x B x B → B m(a, b, c) = a if c is false, b if c is true Which function is this? Sequential circuits and Java methods are not always functions. Why not? CPSC 121 – 2016W T1 30

  27. Module 11.3: Special types of functions Some special types of functions: A function f : A → B is injective (one-to-one) if ∀ ∈ ∀ ∈ x A, y A, x ≠ y → f(x) ≠ f(y). In the arrow diagram: at most one arrow points to each element of B. Not injective: f(George) = f(Patrice) Injective CPSC 110/201 George CPSC 110 George CPSC 121/202 Patrice CPSC 121 Patrice CPSC 121/203 Gail CPSC 210 Neil CPSC 210/BCS Kimberly CPSC 310 Kimberly CPSC 310 Neil CPSC 319 Gail CPSC 319 CPSC 121 – 2016W T1 31

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend