









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










1 Introduction
Decision Problems
Decision Problems Given input, decide “yes” or “no”
General Computational Problem In contrast, typically a problem requires computing some non-boolean function, or carrying out interactive/reactive computation in a distributed environment
What Does a Computation Look Like?
Finite State Computation
q 0 q 1
Figure 3: Transition Diagram of automaton
Example: Computation
q 0 q 1
Example I
q 0
Figure 4: Automaton accepts all strings of 0s and 1s
Example II
q 0 q 1
Figure 5: Automaton accepts strings ending in 1
Example III
q 0 q 1
Figure 6: Automaton accepts strings having an odd number of 1s
Example IV
q 0 q 1
q 3 q 2
Figure 7: Automaton accepts strings having an odd number of 1s and odd number of 0s
Finite Automata in Practice
Set Notation
We will often define languages using the set builder notation. Thus, L = {w ∈ Σ∗^ | p(w)} is the collection of all strings w over Σ that satisfy the property p.
Example 5. • L = {w ∈ { 0 , 1 }∗^ | |w| is even} is the set of all even length strings over { 0 , 1 }.
Defining an Automaton
To describe an automaton, we to need to specify
Thus, the above 5 things are part of the formal definition.
Deterministic Finite Automata Formal Definition
Definition 6. A deterministic finite automaton (DFA) is M = (Q, Σ, δ, q 0 , F ), where
Given a state and a symbol, the next state is “determined”.
Computation
Definition 7. For a DFA M = (Q, Σ, δ, q 0 , F ), string w = w 1 w 2 · · · wk, where for each i wi ∈ Σ, and states q 1 , q 2 ∈ Q, we say q 1 w −→M q 2 if there is a sequence of states r 0 , r 1 ,... rk such that
Definition 8. For a DFA M = (Q, Σ, δ, q 0 , F ) and string w ∈ Σ∗, we say M accepts w iff q 0 w −→M q for some q ∈ F.
Acceptance/Recognition and Regular Languages
Definition 9. The language accepted or recognized by a DFA M over alphabet Σ is L(M ) = {w ∈ Σ∗^ | M accepts w}. A language L is said to be accepted/recognized by M if L = L(M ).
Definition 10. A language L is regular if there is some DFA M such that L = L(M ).
Simple Observations about DFAs
Proposition 11. For a DFA M , string w, and state q 1 , there is exactly one state q 2 such that q 1 −→w M q 2.
Proof. By induction on |w|.
Proposition 12. For DFA M , strings u and v, and states q 1 and q 3 , q 1 −→uvM q 3 if and only if there is a state q 2 such that q 1 u −→M q 2 and q 2 v −→M q 3.
Formal Example of DFA
Example 13.
q 0 q 1
Figure 8: Transition Diagram of DFA
Formally the automaton is Modd = ({q 0 , q 1 }, { 0 , 1 }, δ, q 0 , {q 1 }) where
δ(q 0 , 0) = q 0 δ(q 0 , 1) = q 1 δ(q 1 , 0) = q 1 δ(q 1 , 1) = q 0
Proving Correctness of a DFA
Proof Template Given a DFA M having n states {q 0 , q 1 ,... qn− 1 } with initial state q 0 , to prove that L(M ) = L, we do the following.
3 Designing DFAs
Typical Problem
Problem Given a language L, design a DFA M that accepts L, i.e., L(M ) = L. How does one go about it?
Methodology
Strings containing 0
Problem Design an automaton that accepts all strings over { 0 , 1 } that contain at least one 0.
Solution What do you need to remember? Whether you have seen a 0 so far or not!
qnoz qzer
Figure 10: Automaton accepting strings with at least one 0.
Even length strings
Problem Design an automaton that accepts all strings over { 0 , 1 } that have an even length.
Solution What do you need to remember? Whether you have seen an odd or an even number of symbols.
qe qo
Figure 11: Automaton accepting strings of even length.
Pattern Recognition
Problem Design an automaton that accepts all strings over { 0 , 1 } that have 001 as a substring, where u is a substring of w if there are w 1 and w 2 such that w = w 1 uw 2.
Solution What do you need to remember? Whether you
Knuth-Morris-Pratt (1977): Yes to both the above questions.
Multiples
Problem Design an automaton that accepts all strings w over { 0 , 1 } such that w is the binary representation of a number that is a multiple of 5.
Solution What do you need to remember? The remainder when divided by 5. How do you compute remainders?
Automaton for recognizing Multiples
q 0
q 1
q 4
q 2
q 3
Figure 13: Automaton recognizing strings encoding binary number that are multiples of 5.
A One k-positions from end
Problem
Design an automaton for the language Lk = {w | kth character from end of w is 1}
Solution What do you need to remember? The last k characters seen so far! Formally, Mk = (Q, { 0 , 1 }, δ, q 0 , F )
〈wb〉 if |w| < k 〈w 2 w 3... wkb〉 if w = w 1 w 2... wk
Lower Bound on DFA size
Proposition 15. Any DFA recognizing Lk has at least 2 k^ states.
Proof Let M , with initial state q 0 , recognize Lk and assume (for contradiction) that M has < 2 k^ states.
Proof (contd)
Proof Let i be the first position where w 0 and w 1 differ. Without loss of generality assume that w 0 has 0 in the ith position and w 1 has 1.
w 00 i−^1 =...
k ︷ ︸︸ ︷ 0... 0 i−^1 w 10 i−^1 = (^) ︸︷︷︸... i− 1
k−i
0 i−^1
w 00 i−^1 6 ∈ Lk and w 10 i−^1 ∈ Lk. Thus, M cannot accept both w 00 i−^1 and w 10 i−^1.
Proof (contd)
... Almost there
Proof