Download presentation
Presentation is loading. Please wait.
1
PROGRAMMING LANGUAGES
CS 212 LECTURE 03 PROGRAMMING LANGUAGES
2
What is Automata Theory?
An automaton is an abstract model of a digital computer. Alan Turing (1912--‐1954) Father of modern computer science English mathematician Studied abstract machines called Turing machines even before computers existed
3
Finite Automata Finite automata are computing devices that accept or recognize regular languages.
5
Finite state machine Let think about a soda vending machine which accept only 5 and 10 Baht coin. A soda bottle cost 30 Baht. Now we have 7 states to put the coin. Start state need 30 Baht, next state need 25, 20, 15, 10, 5, and a final state need 0 Baht. Let draw a state diagram for the machine
6
FSM ={5,10} State diagram
7
DFA and NFA Finite automata have two types
Deterministic Finite Automata (DFA) Non-Deterministic Finite Automata (NFA)
8
Example DFA Regular expression r over ={a,b} r = (a+b)*bb(a+b)* Draw a state diagram of r Step 1 : Think about the smallest string , should be bb
9
Step 2 : Think about (a+b). in front of bb
Step 2 : Think about (a+b)* in front of bb. It should be aaaaaabb or abababababbb Step 3 : After bb , we can have anything.
10
Example L is a language over ={a,b} which have the even number of a and even number of b Step1: is in L, aa, bb, abab, aaabab, aabb, aaaa, aaaabb, aabbaa … are in L. We should have 4 states. 1) # of a and # of b is even 2) # of a is even and # of b is odd 3) # of a is odd and # of b is even 4) # of a is odd and # of b is odd
11
From start state , if get one b then #of b is odd and #of a is even
From start state , if get one b then #of b is odd and #of a is even. If get another b the #of b is even and # a is even.
12
From start state , if get one a then #of a is odd and #of b is even
From start state , if get one a then #of a is odd and #of b is even. If get another a the #of a is even and # b is even.
13
From state EaOb, if get one a then #of a is odd and #of b is odd
From state EaOb, if get one a then #of a is odd and #of b is odd. If get another a the #of a is even and # b is odd.
14
From state OaOb, if get one b then #of b is even and #of a is odd
From state OaOb, if get one b then #of b is even and #of a is odd. If get another b the #of b is odd and # a is odd.
15
Example Build a DFA for regular expression R = (001)* + (110)*
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.