cpsc 121 models of computation module 11 sets functions
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 Announcements: Final exam: Wednesday Dec 18 th at 8:30 in SRC. Review Session: Monday Dec 16 th from 14:00 to 16:00 in MCML 166. There will be additional office hours with me


  1. CPSC 121: Models of Computation Module 11: Sets, Functions and DFAs Announcements: Final exam: Wednesday Dec 18 th at 8:30 in SRC. Review Session: Monday Dec 16 th from 14:00 to 16:00 in MCML 166. There will be additional office hours with me and the Module 11: Sets, Functions and DFAs. TAs; we are still working on the schedule. CPSC 121 – 2013W T1 1 CPSC 121 – 2013W T1 2 Module 11: Sets, Functions and DFAs Module 11: Sets, Functions and DFAs By the start of class, you should be able to: Final exam details: Define the set operations union, intersection, 2.5 hours complement and difference, and the logical Covers everything discussed in the course operations subset and set equality in terms of includes labs, although you don't need to memorize predicate logic and set membership. all of the solutions. Translate between sets represented explicitly Slightly more emphasis on later topics. (possibly using ellipses, e.g., { 4, 6, 8, … }) and using "set builder" notation (e.g., { x in Z + | x 2 > 10 and x is The following will be provided if necessary even }). Logical equivalences, rules of inference, powers of 2, regular expression syntax Execute set operations on sets expressed explicitly, using set builder notation, or a combination of these. You can bring one 8.5 x 11in 2-sided sheet of paper. CPSC 121 – 2013W T1 3 CPSC 121 – 2013W T1 4

  2. Module 11: Sets, Functions and DFAs Module 11: Sets, Functions and DFAs By the start of class, you should be able to: Teaching Assistants: Interpret the empty set symbol, including the fact that Sanjana Bajracharya, Kevin Cheang, Kai Di Chen, Rose Gambrel, Étienne Hossack, Jonathan Lee, William Li, the empty set has no members and that it is a subset Jonathan Louie, Jodi Spacek, Patty Wang, Mike Wu, Kailun of any set. Zhang Define the terms domain, co-domain, range, image, Tutorials and Labs: 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 – 2013W T1 5 CPSC 121 – 2013W T1 6 Module 11: Sets, Functions and DFAs. Module 11: Sets, Functions and DFAs CPSC 121: the BIG questions: By the end of this module, you should be able ? ? ? to: 1. How does the computer (e.g. Dr. Racket) decide if ? ? the characters of your program represent a name, Define the terms injective (one-to-one), surjective a number, or something else? How does it figure (onto), bijective (one-to-one correspondence), and ? out if you have mismatched " " or ( )? ? inverse. ? ? More generally: ? Determine whether a given function is injective, surjective, and/or bijective. What can we compute? ? Relate DFAs to sets and functions. Are there problems we can not solve? ? ? Better understand the limitations of DFAs, that is, ? what they can and can not do. ? ? ? CPSC 121 – 2013W T1 7 CPSC 121 – 2013W T1 8

  3. Module 11: Sets, Functions and DFAs Module 11: Sets, Functions and DFAs Module Summary How does Set Theory fit in with what we have been doing so far in the course? Sets. Every set operation is defined in terms of predicate Cardinality, Power sets and Cartesian Products. logic and the basic predicate ∈ . Injections, surjections, bijections and inverses. So we prove theorems about sets by DFAs and regular expressions. figuring out which predicate logic statement Computations that we are unable to perform. corresponds to the terms and operations used in the theorem. applying already known proof techniques. No new proof techniques are needed! CPSC 121 – 2013W T1 9 CPSC 121 – 2013W T1 10 Module 11: Sets, Functions and DFAs Module 11: Sets, Functions and DFAs Historical Notes: Confusion: ∈ versus ⊆. Mathematicians formalized set theory to create a The ∈ predicate takes in an element x and a set S, foundation for all of mathematics. Essentially all and returns true if the element x belongs to S. mathematical constructs can be defined in terms of sets. The ⊆ predicate takes in two sets S and T, and Hence sets are a powerful means of formalizing returns true if every element of S is also an new ideas. element of T. That is, if ∀ x ∈ D, x ∈ S → x ∈ T But we have to be careful! CPSC 121 – 2013W T1 11 CPSC 121 – 2013W T1 12

  4. Module 11: Sets, Functions and DFAs Module 11: Sets, Functions and DFAs Russel's paradox (part 1). Russel's paradox (part 2). Let S be the set of all sets that contain themselves. Let S be the set of all sets that do not contain themselves (that is, S ∉ S). Does S contain itself? Does S contain itself? a) Yes, definitely. a) Yes, definitely. b) No, certainly not. c) Maybe (either way is fine). b) No, certainly not. c) Maybe (either way is fine). d) None of the above. d) None of the above. So, no problem here. Argh!!! CPSC 121 – 2013W T1 13 CPSC 121 – 2013W T1 14 Module 11: Sets, Functions and DFAs Module 11: Sets, Functions and DFAs Despite this, sets (and functions) are incredibly Module Summary useful. Sets. E.g. We can definite valid DFAs formally: a DFA Cardinality, Power sets and Cartesian Products. is a 5-tuple ( Σ , S, s 0 , F, δ ) where Injections, surjections, bijections and inverses. Σ is a finite set of characters (input alphabet). DFAs and regular expressions. S is a finite set of states. Computations that we are unable to perform. s 0 ∈ S is the initial state. F ⊆ S is the set of accepting states. δ : S x Σ → S is the transition function. CPSC 121 – 2013W T1 15 CPSC 121 – 2013W T1 16

  5. Module 11: Sets, Functions and DFAs Module 11: Sets, Functions and DFAs Cardinality: the number of elements of a set S, This gets trickier with infinite sets. OPTIONAL denoted by |S|. Consider A = Z + , B = Z, C = Q (the rationals). What is the cardinality of the following set: Which of these sets have the smaller and larger { 1, 2, 3, { a, b, c }, snow, rain } ? cardinality? a) 3 a) Smaller: A, larger: C b) 6 b) Smaller: A and B, larger: C c) 8 c) All three sets have the same cardinality d) Some other integer d) None of the above. e) The cardinality of the set is undefined. CPSC 121 – 2013W T1 17 CPSC 121 – 2013W T1 18 Module 11: Sets, Functions and DFAs Module 11: Sets, Functions and DFAs The power set of a set S, denoted P (S), is the Suppose we have a set S with n students, and set whose elements are all subsets of S. we want to form a group to go watch a movie. Given the definitions A = { a, b, f }, B = { b, c }, What are the different groups that can we form? what are: OR: we have a circuit with n inputs (so S is the a) P (A) set of inputs). b) P (A - B) What combinations of inputs might be true? c) | P (A ∩ B)| In both cases, we are looking for all the subsets d) | P (A ∪ B)| e) A c of S. That is, we want to find { T | T ⊆ S } CPSC 121 – 2013W T1 19 CPSC 121 – 2013W T1 20

  6. Module 11: Sets, Functions and DFAs Module 11: Sets, Functions and DFAs The cartesian product of two sets S and T, We can visualize Z + x Z + as follows: denoted S x T, is the set { (s, t) | s ∈ S ∧ t ∈ T } . 5 Each element of S x T is called an ordered tuple, or 4 simply a tuple (or, in this case, a 2-tuple or a pair). 3 Two ordered tuples are equal if the elements in 2 corresponding positions are the same. 1 Examples: (3, 7) = (4 – 1, 14 / 2) 1 2 3 4 5 6 7 8 (3, 7) ≠ (7, 3) What is { a, b } x { 8, 5, 1 } ? CPSC 121 – 2013W T1 21 CPSC 121 – 2013W T1 22 Module 11: Sets, Functions and DFAs Module 11: Sets, Functions and DFAs Module Summary You are already familiar with functions: Sets. Every combinational circuit implements a function. booleans Cardinality, Power sets and Cartesian Products. e.g. m : B x B x B → B m(a, b, c) = a if c is false, b if c is true Injections, surjections, bijections and inverses. Which function is this? DFAs and regular expressions. Dr. Racket functions are also functions. Computations that we are unable to perform. Sequential circuits and Java methods are not always functions. Why not? CPSC 121 – 2013W T1 23 CPSC 121 – 2013W T1 24

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