MELJUN CORTES Automata Theory (Automata2)

126
-1

Published on

MELJUN CORTES Automata Theory (Automata2)

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
126
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

MELJUN CORTES Automata Theory (Automata2)

  1. 1. MELJUN P. CORTES, MBA,MPA,BSCS,ACS CSC 3130: Automata theory and formal languages Nondeterminism MELJUN CORTES
  2. 2. Example from last time • Construct a DFA over alphabet {0, 1} that accepts those strings that end in 101 • Sketch of answer: 0 0 q0 1 qε 1 0 q1 1 q00 1 q01 … q10 q11 1 … 1 1 q001 … 0 q000 q101 … 0 q111 1
  3. 3. Would be easier if… • Suppose we could guess when the string we are reading has only 3 symbols left • Then we could simply look for the sequence 101 and accept if we see it 3 symbols left 1 0 qdie 1 This is not a DFA!
  4. 4. Nondeterminism • Nondeterminism is the ability to make guesses, which we can later verify • Informal nondeterministic algorithm for language of strings that end in 101: 1. Guess if you are approaching end of input 2. If guess is yes, look for 101 and accept if you see it 3. If guess is no, read one more symbol and go to step 1
  5. 5. Nondeterministic finite automaton • This is a kind of automaton that allows you to make guesses 0, 1 q0 1 q1 0 q2 1 q3 • Each state can have zero, one, or more transitions out labeled by the same symbol
  6. 6. Semantics of guessing 0, 1 q0 1 q1 0 q2 1 q3 • State q0 has two transitions labeled 1 • Upon reading 1, we have the choice of staying in q0 or moving to q1
  7. 7. Semantics of guessing 0, 1 q0 1 q1 0 q2 1 q3 • State q1 has no transition labeled 1 • Upon reading 1 in q1, we die; upon reading 0, we continue to q2
  8. 8. Semantics of guessing 0, 1 q0 1 q1 0 q2 • State q3 has no transition going out • Upon reading anything in q3, we die 1 q3
  9. 9. Meaning of automaton Guess if you are 3 symbols away from end of input 0, 1 q0 1 q1 0 If so, guess you will see the pattern 101 q2 1 q3 Check that you are at the end of input
  10. 10. Formal definition • A nondeterministic finite automaton (NFA) is a 5-tuple (Q, Σ, δ, q0, F) where – Q is a finite set of states – Σ is an alphabet – δ: Q × Σ → subsets of Q is a transition function – q0 ∈ Q is the initial state – F ⊆ Q is a set of accepting states (or final states). • Only difference from DFA is that output of δ is a set of states
  11. 11. Example 0, 1 1 q1 alphabet Σ = {0, 1} start state Q = {q0, q1, q2, q3} initial state q0 accepting states F = {q3} 0 q2 1 q3 transition function δ: inputs states q0 q0 q1 q2 q3 0 1 {q0} {q0, q1} {q2} ∅ ∅ {q3} ∅ ∅
  12. 12. Language of an NFA The language of an NFA is the set of all strings for which there is some path that, starting from the initial state, leads to an accepting state as the string is read left to right. • Example 0, 1 q0 1 q1 0 q2 – 1101 is accepted, but 0110 is not 1 q3
  13. 13. NFAs are as powerful as DFAs • Obviously, an NFA can do everything a DFA can do • But can it do more?
  14. 14. NFAs are as powerful as DFAs • Obviously, an NFA can do everything a DFA can do • But can it do more? NO! • Theorem A language L is accepted by some DFA if and only if it is accepted by some NFA.
  15. 15. Proof of theorem • To prove the theorem, we have to show that for every NFA there is a DFA that accepts the same language • We will give a general method for simulating any NFA by a DFA • Let’s do an example first
  16. 16. Simulation example 0, 1 NFA: 1 q0 q0 q2 0 0 DFA: 0 q1 1 q0 or q1 0 1 1 q0 or q2
  17. 17. General method NFA states DFA q0, q1, …, qn ∅, {q0}, {q1}, {q0,q1}, …, {q0,…,qn} one for each subset of states in the NFA initial state q0 {q0} transitions δ δ’({qi1,…,qik}, a) = F⊆Q δ(qi1, a) ∪…∪ δ(qik, a) F’ = {S: S contains some state in F} accepting states
  18. 18. Proof of correctness • Lemma After reading n symbols, the DFA is in state {qi1, …,qik} if and only if the NFA is in one of the states qi1,…,qik • Proof by induction on n • At the end, the DFA accepts iff it is in a state that contains some accepting state of NFA • By lemma, this is true iff the NFA can reach an accepting state
  19. 19. Exercises • Construct NFAs for the following languages over the alphabet {a, b, …, z}: – All strings that contain eat or sea or easy – All strings that contain both sea and tea – All strings that do not contain fool
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×