Presentation is loading. Please wait.

Presentation is loading. Please wait.

Finite State Automata CS480(Prasad) L9FSA.

Similar presentations


Presentation on theme: "Finite State Automata CS480(Prasad) L9FSA."— Presentation transcript:

1 Finite State Automata CS480(Prasad) L9FSA

2 Formal Specification of Languages
Generators Context-free Grammars Regular Expressions Recognizers Parsers, Push-down Automata Finite State Automata FSA is a mechanism to recognize a set of valid inputs before carrying out an action. FSA is a notation for describing a family of language recognition algorithms. CS480(Prasad) L9FSA

3 Parity Problem 1 EP OP 1 CS480(Prasad) L9FSA

4 Basic Features Consumes the entire input string.
Remembers the parity of the bit string by abstracting from the number of 1s in the string. Finite amount of memory required for this purpose. Observe that counting requires unbounded memory, while computing the parity requires very small and fixed amount of memory. Accepts/Rejects the input in a deterministic fashion. CS480(Prasad) L9FSA

5 Final / Accepting state State Transition
Indicates the status of the machine after consuming some portion of the input. Summarizes the history of the computation that is relevant to the future course of action. Initial / Start State Final / Accepting state State Transition 1 Even Parity Odd Parity CS480(Prasad) L9FSA

6 Deterministic Finite State Automaton (DFA)
Q: Finite set of states S: Finite Alphabet d: Transition function total function from QxS to Q : Initial/Start State F : Set of final/accepting state CS480(Prasad) L9FSA

7 Operation of the machine
1 Input Tape Finite Control Read the current letter of input under the tape head. Transit to a new state depending on the current input and the current state, as dictated by the transition function. Halt after consuming the entire input. CS480(Prasad) L9FSA

8 Associating Language with the DFA
Machine configuration: Yields relation: Language: CS480(Prasad) L9FSA

9 Examples CS480(Prasad) L9FSA

10 Set of strings over {a,b} that contain bb
Design states by parititioning S*. Strings containing bb q2 Strings not containing bb Strings that end in b q1 Strings that do not end in b q0 Initial state: q0 Final state: q2 CS480(Prasad) L9FSA

11 State Diagram and Table
q0 q1 q2 b a b d a b q0 q1 q2 CS480(Prasad) L9FSA

12 Strings over {a,b} that do not contain bb
q0 q1 q2 b a b d a b q0 q1 q2 CS480(Prasad) L9FSA

13 DFA for the complement of L given DFA for L
Let M = (Q,S,d,q0,F) be a DFA. Then, M’ = (Q,S,d,q0,Q-F) is a DFA with L(M’) = S* - L(M). Implication: Languages associated with DFAs are closed under complementation. (Recall that languages associated with regular expressions are closed under union, concatenation, and Kleene Star operations, by definition.) CS480(Prasad) L9FSA

14 Strings over {a,b} containing even number of a’s and odd number of b’s.
Ea Oa Eb Ob Eb Ob b [Ea,Eb] [Ea,Ob] b a a a a b [Oa,Ob] [Oa,Eb] b CS480(Prasad) L9FSA

15 (ab)*c S* valid prefix invalid prefix end_a end_b end_c a a Ea Eb b c
Incompletely specified DFA if Err deleted Bold multiple arcs. c a,c l b c Ec Err a,b,c a,b,c b CS480(Prasad) L9FSA

16 (ab)*c S* valid prefix invalid prefix end_a end_b end_c a Ea Eb b c
Incompletely specified DFA if Err deleted Bold multiple arcs. Eb is where /\ leads us. If necessary, we can either relabel the state because /\ is not ending in b Or create a new start state with three out arrows yielding a non-minimal DFA. c a,c b Ec Err a,b,c a,b,c CS480(Prasad) L9FSA

17 Nondeterministic Finite Automata
qi qi qj qj a DFA a qk q NFA CS480(Prasad) L9FSA

18 How do we associate a language with an NFA?
Every DFA is an NFA. However, does non-determinism make NFAs strictly more expressive (powerful) than DFAs? DFA: Unique computation for a given string NFA: Accept if there exists an accepting computation CS480(Prasad) L9FSA

19 NFA State Diagram (Strings over {a,b} ending in bb)
q0 q1 q2 b b d a b q0 {q0} {q0,q1} q1 f {q2} q2 CS480(Prasad) L9FSA

20 Halts in non-accepting state after consuming the input.
Halts in accepting state after consuming the input. CS480(Prasad) L9FSA

21 NFA State Diagram (a U b)* bb (a U b)*
q2 q0 q1 a b DFA a b a q0 q1 q2 b b a CS480(Prasad) L9FSA

22 NFA for (a U b)* (aa U bb) (a U b)*
q2 q0 q1 a b a b q11 q22 b b CS480(Prasad) L9FSA

23 Introducing l-transitions into NFA
A l-transition causes the machine to change its state non-deterministically, without consuming any input. CS480(Prasad) L9FSA

24 Closure Properties of NFA-ls
M1 l l M M2 l l L(M)* L(M1) U L(M2) These results do not hold for ordinary NFAs. Compositionality; Modularity. l l l M1 M2 L(M1) L(M2) CS480(Prasad) L9FSA

25 … … a a a a a0 a1 b1 a2 b2 a3 b3 a3 b3 an b b b b b b b bn
This construction cannot be generalized to recognize because the machine will have infinite number of states. CS480(Prasad) L9FSA


Download ppt "Finite State Automata CS480(Prasad) L9FSA."

Similar presentations


Ads by Google