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

cpsc 121 models of computation
SMART_READER_LITE
LIVE PREVIEW

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:


slide-1
SLIDE 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

slide-2
SLIDE 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

slide-3
SLIDE 3

Task for Today

Design a machine (eventually a circuit) that inputs characters from a finite alphabet (say 1 character per clock tick) and

  • utputs 1 (“Yes”) if the string of characters, x1, x2, . . . , xn, 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

  • ne or more additional digits

CPSC 121: Models of Computation

slide-4
SLIDE 4

Task for Today

Design a machine (eventually a circuit) that inputs characters from a finite alphabet (say 1 character per clock tick) and

  • utputs 1 (“Yes”) if the string of characters, x1, x2, . . . , xn, 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

  • ne or more additional digits

CPSC 121: Models of Computation

slide-5
SLIDE 5

Task for Today

Design a machine (eventually a circuit) that inputs characters from a finite alphabet (say 1 character per clock tick) and

  • utputs 1 (“Yes”) if the string of characters, x1, x2, . . . , xn, 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

  • ne or more additional digits

CPSC 121: Models of Computation

slide-6
SLIDE 6

Task for Today

Design a machine (eventually a circuit) that inputs characters from a finite alphabet (say 1 character per clock tick) and

  • utputs 1 (“Yes”) if the string of characters, x1, x2, . . . , xn, 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

  • ne or more additional digits

CPSC 121: Models of Computation

slide-7
SLIDE 7

Task for Today

Design a machine (eventually a circuit) that inputs characters from a finite alphabet (say 1 character per clock tick) and

  • utputs 1 (“Yes”) if the string of characters, x1, x2, . . . , xn, 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

  • ne or more additional digits

CPSC 121: Models of Computation

slide-8
SLIDE 8

Deterministic Finite State Automaton (DFA)

Definition: A Deterministic Finite State Automaton (DFA) is a 5-tuple I, S, s0, F, N where: I is the input alphabet S is a finite set of states A designated state, s0, 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

slide-9
SLIDE 9

Task for Today (cont’d)

The key to the construction of our DFA is to use its states to:

1

“remember” what characters we’ve seen

2

determine what to do upon processing the next character NOTE: We assume I is the set of ASCII keyboard characters

CPSC 121: Models of Computation

slide-10
SLIDE 10

State Transition Diagram

q0 q1 q3 q4 q2 q7 "−" "."

saw "−" saw "." saw d.d saw d garbage

"−" "." other "." other digit digit "−" "." other any "−" "." other digit digit start digit "−" other

CPSC 121: Models of Computation

slide-11
SLIDE 11

State Transition Table

State Input digit minus period

  • ther

q0 q2 q1 q7 q7 q1 q2 q7 q7 q7 q2 q2 q7 q3 q7 q3 q4 q7 q7 q7 q4 q4 q7 q7 q7 q7 q7 q7 q7 q7

CPSC 121: Models of Computation