cpsc 121 models of computation
play

CPSC 121: Models of Computation Instructor: Bob Woodham - PowerPoint PPT Presentation

CPSC 121: Models of Computation Instructor: Bob Woodham woodham@cs.ubc.ca Department of Computer Science University of British Columbia Lecture Notes 2008/2009, Section 203 CPSC 121: Models of Computation Menu February 25, 2009 Topics:


  1. CPSC 121: Models of Computation Instructor: Bob Woodham woodham@cs.ubc.ca Department of Computer Science University of British Columbia Lecture Notes 2008/2009, Section 203 CPSC 121: Models of Computation

  2. Menu February 25, 2009 Topics: Midterm Follow Up Discussion Deterministic Finite State Automata Reading: Today: Epp 12.2 (pages 745–747), Designing a Finite Automaton (pages 752–754, skipping part b of the examples) Next: Epp 4.1 (as background) Epp 4.2 Reminders: Marked Assignment 2 available in tutorials — solution posted to Sample Solutions area of the course WebCT site Lab 5 week of March 2–6 READ the WebCT Vista course announcements board CPSC 121: Models of Computation

  3. Task for Today Design a machine (eventually a circuit) that inputs characters from a finite alphabet (say 1 character per clock tick) and outputs 1 (“Yes”) if the string of characters, x 1 , x 2 , . . . , x n , is in a set of acceptable strings (its language) and 0 (“No”) otherwise For our example, let the language be the set of real numbers whose syntax we describe by [ − ]digit(s)[.digits(s)] where elements in square brackets, [ · ], are optional A real number can start with an optional ’ − ’ sign. It continues with one or more digits and ends with an optional period AND one or more additional digits CPSC 121: Models of Computation

  4. Task for Today Design a machine (eventually a circuit) that inputs characters from a finite alphabet (say 1 character per clock tick) and outputs 1 (“Yes”) if the string of characters, x 1 , x 2 , . . . , x n , is in a set of acceptable strings (its language) and 0 (“No”) otherwise For our example, let the language be the set of real numbers whose syntax we describe by [ − ]digit(s)[.digits(s)] where elements in square brackets, [ · ], are optional A real number can start with an optional ’ − ’ sign. It continues with one or more digits and ends with an optional period AND one or more additional digits CPSC 121: Models of Computation

  5. Task for Today Design a machine (eventually a circuit) that inputs characters from a finite alphabet (say 1 character per clock tick) and outputs 1 (“Yes”) if the string of characters, x 1 , x 2 , . . . , x n , is in a set of acceptable strings (its language) and 0 (“No”) otherwise For our example, let the language be the set of real numbers whose syntax we describe by [ − ]digit(s)[.digits(s)] where elements in square brackets, [ · ], are optional A real number can start with an optional ’ − ’ sign. It continues with one or more digits and ends with an optional period AND one or more additional digits CPSC 121: Models of Computation

  6. Task for Today Design a machine (eventually a circuit) that inputs characters from a finite alphabet (say 1 character per clock tick) and outputs 1 (“Yes”) if the string of characters, x 1 , x 2 , . . . , x n , is in a set of acceptable strings (its language) and 0 (“No”) otherwise For our example, let the language be the set of real numbers whose syntax we describe by [ − ]digit(s)[.digits(s)] where elements in square brackets, [ · ], are optional A real number can start with an optional ’ − ’ sign. It continues with one or more digits and ends with an optional period AND one or more additional digits CPSC 121: Models of Computation

  7. Task for Today Design a machine (eventually a circuit) that inputs characters from a finite alphabet (say 1 character per clock tick) and outputs 1 (“Yes”) if the string of characters, x 1 , x 2 , . . . , x n , is in a set of acceptable strings (its language) and 0 (“No”) otherwise For our example, let the language be the set of real numbers whose syntax we describe by [ − ]digit(s)[.digits(s)] where elements in square brackets, [ · ], are optional A real number can start with an optional ’ − ’ sign. It continues with one or more digits and ends with an optional period AND one or more additional digits CPSC 121: Models of Computation

  8. Deterministic Finite State Automaton (DFA) Definition: A Deterministic Finite State Automaton (DFA) is a 5-tuple � I , S , s 0 , F , N � where: I is the input alphabet S is a finite set of states A designated state, s 0 , is the initial state A designated subset, F , of S , is the set of accepting states N : S × I → S is the next state transition function CPSC 121: Models of Computation

  9. Task for Today (cont’d) The key to the construction of our DFA is to use its states to: “remember” what characters we’ve seen 1 determine what to do upon processing the next character 2 NOTE: We assume I is the set of ASCII keyboard characters CPSC 121: Models of Computation

  10. State Transition Diagram start q 0 "−" digit "." other digit digit "−" "." other saw d saw "−" garbage q 2 q 1 q 7 any "−" other "." saw "." q 3 "−" "." other digit digit saw d.d "−" "." other q 4 CPSC 121: Models of Computation

  11. State Transition Table State Input digit minus period other q 0 q 2 q 1 q 7 q 7 q 1 q 2 q 7 q 7 q 7 q 2 q 2 q 7 q 3 q 7 q 3 q 4 q 7 q 7 q 7 q 4 q 4 q 7 q 7 q 7 q 7 q 7 q 7 q 7 q 7 CPSC 121: Models of Computation

Recommend


More recommend