FORMAL LANGUAGES AND AUTOMATA THEORY

Size: px
Start display at page:

Download "FORMAL LANGUAGES AND AUTOMATA THEORY"

Transcription

1 1 FORMAL LANGUAGES AND AUTOMATA THEORY Course Summary This course covers foundational theory and practice of finite state machines, regular expression matching, and context-free grammars. The following are the course learning objectives: design of finite state automata and regular expressions conversion amongst DFA's, NFA's, and regular expressions prove that a language is not regular design of push-down automata and context-free grammars conversion amongst push-down automata and context-free grammars prove that a language is not context-free. Overview: Unit 1 This chapter gives the concepts of Finite State Automata, DFA, NFA, Regular languages and Regular Expressions, Applications of finite automata, Pumping Lemma for regular languages. Objectives: This course introduces the fundamental mathematical models of computation. We study both the inherent capabilities and limitations of these computational models as well as their relationships with formal languages. Topics to be covered include: Finite automata and regular languages Deterministic and nondeterministic computations Context-free grammars, languages, and pushdown automata Turing machines Undecidable problems Computational complexity, NP-completeness

2 2 Introduction: what is automata theory? Study of abstract computing devices, or machines Automaton = an abstract computing device Automata theory is a further step in abstracting your attention away from any particular kind of computer or particular programming language. In automata theory we consider a of computing. Such a model strips the computational machinery the programming language down to the bare minimum, so that it s easy to manipulate these theoretical machines (there are several such models, for different purposes, as you ll soon see) mathematically to prove things about their capabilities. For the most part, these mathematical models are not used for practical programming problems. Real programming languages are much more convenient to use. But the very flexibility that makes real languages easier to use also makes them harder to talk about in a formal way. The stripped-down theoretical machines are designed to be examined mathematically. What s a mathematical model? You ll see one shortly, called a finite-state machine. The point of this study is that the mathematical models are, in some important ways, to real computers and real programming languages. What this means is that any problem that can be solved on a real computer can be solved using these models, and vice versa. Anything we can prove about the models sheds light on the real problems of computer programming as well. Theory of Computation: A Historical Perspective Alan Turing ( )_Father of Modern ComputerScience, _ English mathematician Studied abstract machines calledturing machines even beforereal computers existed 1936 Alan Turing invented the Turing machine, and proved that there exists an unsolvable problem s Stored-program computers were built McCulloch and Pitts invented finite automata Kleene invented regular expressions and proved the equivalence of regular expression and finite automata 1956 Chomsky defined Chomsky hierarchy, which organized languages recognized by different automata into hierarchical classes.

3 Rabin and Scott introduced nondeterministic finite automata and proved its equivalence to (deterministic) finite automata s-1960 s More works on languages, grammars, and compilers 1965 Hartmantis and Stearns defined time complexity, and Lewis, Hartmantis and Stearns defined space complexity Cook showed the first NP-complete problem, the satisfiability prooblem Karp Showed many other NP-complete problems Diffie and Helllman defined Modern Cryptography based on NP-complete problems Rivest, Shamir and Adelman proposed a public-key encryption scheme, RSA.

4 4 Mathematical preliminaries and notations Symbol An atomic unit, such as a digit, character, lower-case letter, etc. Sometimes a word. [Formal language does not deal with the meaning of the symbols.] Alphabet A finite set of symbols, usually denoted by Σ. Σ = {0, 1} Σ = {0, a,, 4} Σ = {a, b, c, d} String A finite length sequence of symbols, presumably from some alphabet. u=ε w = 0110 y = 0aa x = aabcaa z = 111 special string: ε (also denoted by λ) concatenation: wz = length: w = 4 x = 6 but u = 0 reversal: y R = aa0 Some special sets of strings: Σ * Σ + All strings of symbols from Σ Σ * - {ε} Example: Σ = {0, 1} Σ * = {ε, 0, 1, 00, 01, 10, 11, 000, 001, } Σ + = {0, 1, 00, 01, 10, 11, 000, 001, } A (formal) language is: 1) A set of strings from some alphabet (finite or infinite), in other words 2) any subset L of Σ * Some special languages: {} The empty set/language, containing no strings {ε} A language containing one string, the empty string. Examples:

5 5 Σ = {0, 1} L = {x x is in Σ * and x contains an even number of 0 s} Σ = {0, 1, 2,, 9,.} L = {x x is in Σ * and x forms a finite length real number} = {0, 1.5, 9.326, } Σ = {a, b, c,, z, A, B,, Z} L = {x x is in Σ * and x is a Pascal reserved word} = {BEGIN, END, IF, } Σ = {Pascal reserved words} U { (, ),., :, ;, } U {Legal Pascal identifiers} L = {x x is in Σ * and x is a syntactically correct Pascal program} Σ = {English words} L = {x x Σ * and x is a syntactically correct English sentence} Deterministic Finite State Automata (DFA) One-way, infinite tape, broken into cells One-way, read-only tape head. Finite control, I.e., a program, containing the position of the read head, current symbol being scanned, and the current state.

6 6 A string is placed on the tape, read head is positioned at the left end, and the DFA will read the string one symbol at a time until all symbols have been read. The DFA will then either accept or reject. The finite control can be described by a transition diagram: Example #1: q 0 q 0 q 1 q 0 q 0 q 0 One state is final/accepting, all others are rejecting. The above DFA accepts those strings that contain an even number of 0 s Example #2:

7 7 a c c c b accepted q 0 q 0 q 1 q 2 q 2 q 2 a a c rejected q 0 q 0 q 0 q 1 Accepts those strings that contain at least two c s Formal Definition of a DFA A DFA is a five-tuple: M = (Q, Σ, δ, q 0, F) Q Σ q 0 F δ A finite set of states A finite input alphabet The initial/starting state, q 0 is in Q A set of final/accepting states, which is a subset of Q A transition function, which is a total function from Q x Σ to Q δ: (Q x Σ) > Q δ is defined for any q in Q and s in Σ, and δ(q,s) = q is equal to some state q in Q, could be q =q Intuitively, δ(q,s) is the state entered by M after reading symbol s while in state q. For example #1: Q = {q 0, q 1 } Σ = {0, 1} Start state is q 0

8 8 F = {q 0 } δ: 0 1 q 0 q 1 q 0 q 1 q 0 q 1 For example #2: Q = {q 0, q 1, q 2 } Σ = {a, b, c} Start state is q 0 F = {q 2 } δ: a b c q 0 q 0 q 0 q 1 q 1 q 1 q 1 q 2 q 2 q 2 q 2 q 2 Since δ is a function, at each step M has exactly one option. It follows that for a given string, there is exactly one computation.

9 9 Extension of δ to Strings δ^ : (Q x Σ * ) > Q δ^(q,w) The state entered after reading string w having started in state q. Formally: 1) δ^(q, ε) = q, and 2) For all w in Σ * and a in Σ δ^(q,wa) = δ (δ^(q,w), a) Recall Example #1: What is δ^(q 0, 011)? Informally, it is the state entered by M after processing 011 having started in state q 0. Formally: δ^(q 0, 011) = δ (δ^(q 0,01), 1) by rule #2 = δ (δ ( δ^(q 0,0), 1), 1) by rule #2 = δ (δ (δ (δ^(q 0, λ), 0), 1), 1) by rule #2 = δ (δ (δ(q 0,0), 1), 1) by rule #1 = δ (δ (q 1, 1), 1) by definition of δ = δ (q 1, 1) by definition of δ = q 1 by definition of δ

10 10 Is 011 accepted? No, since δ^(q 0, 011) = q 1 is not a final state. Note that: δ^ (q,a) = δ(δ^(q, ε), a) by definition of δ^, rule #2 = δ(q, a) by definition of δ^, rule #1 Therefore: δ^ (q, a 1 a 2 a n ) = δ(δ( δ(δ(q, a1), a2) ), a n ) Hence, we can use δ in place of δ^: δ^(q, a 1 a 2 a n ) = δ(q, a 1 a 2 a n ) Recall Example #2: What is δ(q 0, 011)? Informally, it is the state entered by M after processing 011 having started in state q 0. Formally: δ(q 0, 011) = δ (δ(q 0,01), 1) by rule #2 = δ (δ (δ(q 0,0), 1), 1) by rule #2 = δ (δ (q 1, 1), 1) by definition of δ = δ (q 1, 1) by definition of δ = q 1 by definition of δ Is 011 accepted? No, since δ(q 0, 011) = q 1 is not a final state. What is δ(q 1, 10)? δ(q 1, 10) = δ (δ(q 1,1), 0) by rule #2

11 11 = δ (q 1, 0) by definition of δ = q 2 by definition of δ Is 10 accepted? No, since δ(q 0, 10) = q 1 is not a final state. The fact that δ(q 1, 10) = q 2 is irrelevant!

12 12 Definitions for DFAs Let M = (Q, Σ, δ,q 0,F) be a DFA and let w be in Σ *. Then w is acceptedby Miff δ(q 0,w) = p for some state p in F. Let M = (Q, Σ, δ,q 0,F) be a DFA. Then the language accepted by M is the set: L(M) = {w w is in Σ * and δ(q 0,w) is in F} Another equivalent definition: L(M) = {w w is in Σ * and w is accepted by M} Let L be a language. Then L is a regular languageiff there exists a DFA M such that L = L(M). Let M 1 = (Q 1, Σ 1, δ 1, q 0, F 1 ) and M 2 = (Q 2, Σ 2, δ 2, p 0, F 2 ) be DFAs. Then M 1 and M 2 are equivalentiff L(M 1 ) = L(M 2 ). Notes: A DFA M = (Q, Σ, δ,q 0,F) partitions the set Σ * into two sets: L(M) and Σ * - L(M). If L = L(M) then L is a subset of L(M) and L(M) is a subset of L. Similarly, if L(M 1 ) = L(M 2 ) then L(M 1 ) is a subset of L(M 2 ) and L(M 2 ) is a subset of L(M 1 ). Some languages are regular, others are not. For example, if L 1 = {x x is a string of 0's and 1's containing an even number of 1's} and Questions: L 2 = {x x = 0 n 1 n for some n >= 0} then L 1 is regular but L 2 is not. How do we determine whether or not a given language is regular? How could a program simulate a DFA?

13 13 Give a DFA M such that: L(M) = {x x is a string of 0 s and 1 s and x >= 2} Give a DFA M such that: L(M) = {x x is a string of (zero or more) a s, b s and c s such that x does not contain the substring aa} Give a DFA M such that: L(M) = {x x is a string of a s, b s and c s such that x contains the substring aba}

14 14 Give a DFA M such that: L(M) = {x x is a string of a s and b s such that x contains both aa and bb} Nondeterministic Finite State Automata (NFA) An NFA is a five-tuple: M = (Q, Σ, δ, q 0, F) Q Σ q 0 F δ A finite set of states A finite input alphabet The initial/starting state, q 0 is in Q A set of final/accepting states, which is a subset of Q A transition function, which is a total function from Q x Σ to 2 Q δ: (Q x Σ) > 2 Q -2 Q is the power set of Q, the set of all subsets of Q δ(q,s) -The set of all states p such that there is a transition labeled s from q to p δ(q,s) is a function from Q x S to 2 Q (but not to Q)

15 15 Example #1: some 0 s followed by some 1 s Q = {q 0, q 1, q 2 } Σ = {0, 1} Start state is q 0 F = {q 2 } Example #2: pair os 0 s or pair of 1 s Q = {q 0, q 1, q 2, q 3, q 4 } Σ = {0, 1} Start state is q 0 F = {q 2, q 4 }

16 16 Notes: δ(q,s) may not be defined for some q and s (why?). Informally, a string is said to be accepted if there exists a path to some state in F. The language accepted by an NFA is the set of all accepted strings. Question: How does an NFA find the correct/accepting path for a given string? NFAs are a non-intuitive computing model.

17 17 We are primarily interested in NFAs as language defining devices, i.e., do NFAs accept languages that DFAs do not? Other questions are secondary, including practical questions such as whether or not there is an algorithm for finding an accepting path through an NFA for a given string, Determining if a given NFA (example #2) accepts a given string (001) can be done algorithmically Each level will have at most n states Another example (010): All paths have been explored, and none lead to an accepting state.

18 18 Extension of δ to Strings and Sets of States Step #1: Given δ: (Q x Σ) > 2 Q define δ # : (2 Q x Σ) > 2 Q as follows: 1) δ # (R, a) = δ(q, a) for all subsets R of Q, and symbols a in Σ Note that: δ # ({p},a) = δ(q, a) by definition of δ #, rule #1 above Hence, we can use δ for δ # = δ(p, a) δ({q 0, q 2 }, 0) δ({q 0, q 1, q 2 }, 0) These now make sense, but previously they did not. Example: Step #2: δ({q 0, q 2 }, 0) = δ(q 0, 0) U δ(q 2, 0) = {q 1, q 3 } U {q 3, q 4 } = {q 1, q 3, q 4 } δ({q 0, q 1, q 2 }, 1) = δ(q 0, 1) U δ(q 1, 1) U δ(q 2, 1) = {} U {q 2, q 3 } U {} = {q 2, q 3 } Given δ: (2 Q x Σ) > 2 Q define δ^: (2 Q x Σ*) > 2 Q as follows: δ^(r,w) The set of states M could be in after processing string w, having starting from any state in R. Formally: 2) δ^(r, ε) = R for any subset R of Q 3) δ^(r,wa) = δ (δ^(r,w), a) for any w in Σ *, a in Σ, and subset R of Q

19 19 Note that: Hence, we can use δ for δ^ δ^(r, a) = δ(δ^(r, ε), a) by definition of δ^, rule #3 above = δ(r, a) by definition of δ^, rule #2 above δ({q 0, q 2 }, 0110) δ({q 0, q 1, q 2 }, ) These now make sense, but previously they did not. Example: What is δ({q 0 }, 10)? Informally: The set of states the NFA could be in after processing 10, having started in state q 0, i.e., {q 1, q 2, q 3 }. Formally: δ({q 0 }, 10) = δ(δ({q 0 }, 1), 0) = δ({q 0 }, 0) = {q 1, q 2, q 3 } Is 10 accepted? Yes!

20 20 Example: What is δ({q 0, q 1 }, 1)? δ({q 0, q 1 }, 1) = δ({q 0 }, 1) U δ({q 1 }, 1) = {q 0 } U {q 2, q 3 } = {q 0, q 2, q 3 } What is δ({q 0, q 2 }, 10)? δ({q 0, q 2 }, 10) = δ(δ({q 0, q 2 }, 1), 0) = δ(δ({q 0 }, 1) U δ({q 2 }, 1), 0) = δ({q 0 } U {q 3 }, 0) = δ({q 0,q 3 }, 0) = δ({q 0 }, 0) U δ({q 3 }, 0) = {q 1, q 2, q 3 } U {} = {q 1, q 2, q 3 } Example: δ({q 0 }, 101) = δ(δ({q 0 }, 10), 1) = δ(δ(δ({q 0 }, 1), 0), 1) = δ(δ({q 0 }, 0), 1) = δ({q 1, q 2, q 3 }, 1) = δ({q 1 }, 1) U δ({q 2 }, 1) U δ({q 3 }, 1) = {q 2, q 3 } U {q 3 } U {} = {q 2, q 3 } Is 101 accepted? Yes!

21 21 Definitions for NFAs Let M = (Q, Σ, δ,q 0,F) be an NFA and let w be in Σ *. Then w is accepted by M iffδ({q 0 }, w) contains at least one state in F. Let M = (Q, Σ, δ,q 0,F) be an NFA. Then the language accepted by M is the set: L(M) = {w w is in Σ * and δ({q 0 },w) contains at least one state in F} Another equivalent definition: L(M) = {w w is in Σ * and w is accepted by M} Equivalence of DFAs and NFAs Do DFAs and NFAs accept the same class of languages? Is there a language L that is accepted by a DFA, but not by any NFA? Is there a language L that is accepted by an NFA, but not by any DFA? Observation: Every DFA is an NFA. Therefore, if L is a regular language then there exists an NFA M such that L = L(M). It follows that NFAs accept all regular languages. But do NFAs accept more? Consider the following DFA: 2 or more c s Q = {q 0, q 1, q 2 } Σ = {a, b, c} Start state is q 0 F = {q 2 }

22 22 An Equivalent NFA: Q = {q 0, q 1, q 2 } Σ = {a, b, c} Start state is q 0 F = {q 2 }

23 23 Lemma 1: Let M be an DFA. Then there exists a NFA M such that L(M) = L(M ). Proof: Every DFA is an NFA. Hence, if we let M = M, then it follows that L(M ) = L(M). The above is just a formal statement of the observation from the previous slide. Lemma 2: Let M be an NFA. Then there exists a DFA M such that L(M) = L(M ). Proof: (sketch) Let M = (Q, Σ, δ,q 0,F). Define a DFA M = (Q, Σ, δ,q 0,F ) as: Q = 2 Q Each state in M corresponds to a = {Q 0, Q 1,,} subset of states from M whereq u = [q i0, q i1, q ij ] F = {Q u Q u contains at least one state in F} q 0 = [q 0 ] δ (Q u, a) = Q v iff δ(q u, a) = Q v Example: empty string or start and end with 0 Q = {q 0, q 1 } Σ = {0, 1} Start state is q 0 F = {q 1 }

24 24 Construct DFA M as follows: δ({q 0 }, 0) = {q 1 } => δ ([q 0 ], 0) = [q 1 ] δ({q 0 }, 1) = {} => δ ([q 0 ], 1) = [ ] δ({q 1 }, 0) = {q 0, q 1 } => δ ([q 1 ], 0) = [q 0, q 1 ] δ({q 1 }, 1) = {q 1 } => δ ([q 1 ], 1) = [q 1 ] δ({q 0, q 1 }, 0) = {q 0, q 1 }=> δ ([q 0, q 1 ], 0) = [q 0, q 1 ] δ({q 0, q 1 }, 1) = {q 1 } => δ ([q 0, q 1 ], 1) = [q 1 ] δ({}, 0) = {} => δ ([ ], 0) = [ ] δ({}, 1) = {} => δ ([ ], 1) = [ ] Theorem: Let L be a language. Then there exists an DFA M such that L = L(M) iff there exists an NFA M such that L = L(M ). Proof: (if) Suppose there exists an NFA M such that L = L(M ). Then by Lemma 2 there exists an DFA M such that L = L(M). (only if) Suppose there exists an DFA M such that L = L(M). Then by Lemma 1 there exists an NFA M such that L = L(M ). Corollary: The NFAs define the regular languages.

25 25 Note: Suppose R = {} δ(r, 0) = δ(δ(r, ε), 0) = δ(r, 0) = δ(q, 0) = {} Since R = {} Exercise - Convert the following NFA to a DFA: NFAs with ε Moves An NFA-ε is a five-tuple: M = (Q, Σ, δ, q 0, F) Q A finite set of states Σ A finite input alphabet q 0 The initial/starting state, q 0 is in Q F A set of final/accepting states, which is a subset of Q δa transition function, which is a total function from Q x Σ U {ε} to 2 Q

26 26 δ: (Q x (Σ U {ε})) > 2 Q δ(q,s) -The set of all states p such that there is a transition labeled a from q to p, where a is in Σ U {ε} Sometimes referred to as an NFA-ε other times, simply as an NFA. Example:

27 27 Informal Definitions Let M = (Q, Σ, δ,q 0,F) be an NFA-ε. A String w in Σ * is accepted by M iff there exists a path in M from q 0 to a state in F labeled by w and zero or more ε transitions. The language accepted by M is the set of all strings from Σ * that are accepted by M. ε-closure Define ε-closure(q) to denote the set of all states reachable from q by zero or more ε transitions. Examples: (for the previous NFA) ε-closure(q 0 ) = {q 0, q 1, q 2 } ε-closure(q 2 ) = {q 2 } ε-closure(q 1 ) = {q 1, q 2 } ε-closure(q 3 ) = {q 3 } ε-closure(q) can be extended to sets of states by defining: ε-closure(p) = ε-closure(q) Examples: ε-closure({q 1, q 2 }) = {q 1, q 2 } ε-closure({q 0, q 3 }) = {q 0, q 1, q 2, q 3 } Extension of δ to Strings and Sets of States What we currently have: δ : (Q x (Σ U {ε})) > 2 Q What we want (why?): δ : (2 Q x Σ * ) > 2 Q As before, we will do this in two steps, which will be slightly different from the book, and we will make use of the following NFA.

28 28 Step #1: Given δ: (Q x (Σ U {ε})) > 2 Q define δ # : (2 Q x (Σ U {ε})) > 2 Q as follows: 1) δ # (R, a) = δ(q, a) for all subsets R of Q, and symbols a in Σ U {ε} Note that: δ # ({p},a) = δ(q, a) by definition of δ #, rule #1 above = δ(p, a) Hence, we can use δ for δ # δ({q 0, q 2 }, 0) δ({q 0, q 1, q 2 }, 0) These now make sense, but previously they did not. Examples: What is δ({q 0, q 1, q 2 }, 1)? δ({q 0, q 1, q 2 }, 1) = δ(q 0, 1) U δ(q 1, 1) U δ(q 2, 1) = { } U {q 0, q 3 } U {q 2 } = {q 0, q 2, q 3 } What is δ({q 0, q 1 }, 0)? δ({q 0, q 1 }, 0) = δ(q 0, 0) U δ(q 1, 0) = {q 0 } U {q 1, q 2 } = {q 0, q 1, q 2 }

29 29 Step #2: Given δ: (2 Q x (Σ U {ε})) > 2 Q define δ^: (2 Q x Σ * ) > 2 Q as follows: δ^(r,w) The set of states M could be in after processing string w, having starting from any state in R. Formally: 2) δ^(r, ε) = ε-closure(r) - for any subset R of Q 3) δ^(r,wa) = ε-closure(δ(δ^(r,w), a)) - for any w in Σ *, a in Σ, and Can we use δ for δ^? Consider the following example: δ({q 0 }, 0) = {q 0 } subset R of Q δ^({q 0 }, 0) = ε-closure(δ(δ^({q 0 }, ε), 0)) By rule #3 = ε-closure(δ(ε-closure({q 0 }), 0)) By rule #2 = ε-closure(δ({q 0, q 1, q 2 }, 0)) By ε-closure = ε-closure(δ(q 0, 0) U δ(q 1, 0) U δ(q 2, 0)) By rule #1 = ε-closure({q 0 } U {q 1, q 2 } U {q 2 }) = ε-closure({q 0, q 1, q 2 }) = ε-closure({q 0 }) U ε-closure({q 1 }) U ε-closure({q 2 }) = {q 0, q 1, q 2 } U {q 1, q 2 } U {q 2 } = {q 0, q 1, q 2 } So what is the difference? δ(q 0, 0) δ^(q 0, 0) - Processes 0 as a single symbol, without ε transitions. - Processes 0 using as many ε transitions as are possible.

30 30 Example: δ^({q 0 }, 01) = ε-closure(δ(δ^({q 0 }, 0), 1)) By rule #3 = ε-closure(δ({q 0, q 1, q 2 }), 1) Previous slide = ε-closure(δ(q 0, 1) U δ(q 1, 1) U δ(q 2, 1)) By rule #1 = ε-closure({ } U {q 0, q 3 } U {q 2 }) = ε-closure({q 0, q 2, q 3 }) = ε-closure({q 0 }) U ε-closure({q 2 }) U ε-closure({q 3 }) = {q 0, q 1, q 2 } U {q 2 } U {q 3 } = {q 0, q 1, q 2, q 3 } Definitions for NFA-ε Machines Let M = (Q, Σ, δ,q 0,F) be an NFA-ε and let w be in Σ *. Then w is accepted by M iff δ^({q 0 }, w) contains at least one state in F. Let M = (Q, Σ, δ,q 0,F) be an NFA-ε. Then the language accepted by M is the set: L(M) = {w w is in Σ * and δ^({q 0 },w) contains at least one state in F} Another equivalent definition: L(M) = {w w is in Σ * and w is accepted by M} Equivalence of NFAs and NFA-εs Do NFAs and NFA-ε machines accept the same class of languages? Is there a language L that is accepted by a NFA, but not by any NFA-ε? Is there a language L that is accepted by an NFA-ε, but not by any DFA? Observation: Every NFA is an NFA-ε. Therefore, if L is a regular language then there exists an NFA-ε M such that L = L(M). It follows that NFA-ε machines accept all regular languages. But do NFA-ε machines accept more?

31 31 Lemma 1: Let M be an NFA. Then there exists a NFA-ε M such that L(M) = L(M ). Proof: Every NFA is an NFA-ε. Hence, if we let M = M, then it follows that L(M ) = L(M). The above is just a formal statement of the observation from the previous slide. Lemma 2: Let M be an NFA-ε. Then there exists a NFA M such that L(M) = L(M ). Proof: (sketch) Let M = (Q, Σ, δ,q 0,F) be an NFA-ε. Define an NFA M = (Q, Σ, δ,q 0,F ) as: F = F U {q 0 } if ε-closure(q 0 ) contains at least one state from F F = F otherwise δ (q, a) = δ^(q, a) - for all q in Q and a in Σ Notes: δ : (Q x Σ) > 2 Q is a function M has the same state set, the same alphabet, and the same start state as M M has no ε transitions

32 32

33 33

34 34 Theorem: Let L be a language. Then there exists an NFA M such that L= L(M) iff there exists an NFA-ε M such that L = L(M ). Proof: (if) Suppose there exists an NFA-ε M such that L = L(M ). Then by Lemma 2 there exists an NFA M such that L = L(M). (only if) Suppose there exists an NFA M such that L = L(M). Then by Lemma 1 there exists an NFA-ε M such that L = L(M ). Corollary: The NFA-ε machines define the regular languages.

35 35 Applications of Automata Theory Linguistics Automata theory is the basis for the theory of formal languages. A proper treatment of formal language theory begins with some basic definitions: A symbol is simply a character, an abstraction that is meaningless by itself. An alphabet is a finite set of symbols. A word is a finite string of symbols from a given alphabet. Finally, a language is a set of words formed from a given alphabet. The set of words that form a language is usually infinite, although it may be finite or empty as well. Formal languages are treated like mathematical sets, so they can undergo standard set theory operations such as union and intersection. Additionally, operating on languages always produces a language. As sets, they are defined and classified using techniques of automata theory. Formal languages are normally defined in one of three ways, all of which can be described by automata theory: regular expressions standard automata a formal grammar system Regular Expressions Example alphabeta1={a,b} alphabeta2={1,2} language L1= the set of all words over A1 = {a, aab,...} language L2= the set of all words over A2 = {2, 11221,...} language L3 = L1 L2 language L4 = {an n is even} = {aa, aaaa,...} language L5 = {anbn n is natural} = {ab, aabb,...} Languages can also be defined by any kind of automaton, like a Turing Machine. In general, any automata or machine M operating on an alphabet A can produce a perfectly valid language L. The system could be represented by a bounded Turing Machine tape, for example, with each cell representing a word. After the instructions halt, any word with value 1 (or ON) is accepted and becomes part of the generated language. From this idea, one can defne the complexity of a language, which can be classified as P or NP, exponential, or probabilistic, for example. Noam Chomsky extended the automata theory idea of complexity hierarchy to a formal language hierarchy, which led to the concept of formal grammar. A formal grammar system is

36 36 a kind of automata specifically defined for linguistic purposes. The parameters of formal grammar are generally defined as: a set of non-terminal symbols N a set of terminal symbols Σ a set of production rules P a start symbol S Grammar Example Start symbol = S non-terminals = {S} terminals = {a, b} production rules: S asb, S ba S asb abab S â asb aasbb aababb L = {abab, aababb,...} As in purely mathematical automata, grammar automata can produce a wide variety of complex languages from only a few symbols and a few production rules. Chomsky's hierarchy defines four nested classes of languages, where the more precise aclasses have stricter limitations on their grammatical production rules. The formality of automata theory can be applied to the analysis and manipulation of actual human language as well as the development of human-computer interaction (HCI) and artificial intelligence (AI). Biology To the casual observer, biology is an impossibly complex science. Traditionally, the intricacy and variation found in life science has been attributed to the notion of natural selection. Species become "intentionally" complex because it increases their chance for survival. For example, a camoflauge-patterned toad will have a far lower risk of being eaten by a python than a frog colored entirely in orange. This idea makes sense, but automata theory offers a simpler and more logical explanation, one that relies not on random, optimizing mutations but on a simple set of rules. Basic automata theory shows that simplicity can naturally generate complexity. Apparent randomness in a system results only from inherent complexities in the behavior of automata, and seemingly endless variations in outcome are only the products of different initial states. A simple mathematical example of this notion is found in irrational numbers. The square root of nine is just 3, but the square root of ten has no definable characteristics. One could compute the decimal digits for the lifetime of the universe and never find any kind of recurring patter or orderly progression; instead, the sequence of numbers seemse utterly random. Similar results are

37 37 found in simple two-dimensional cellular automaton. These structures form gaskets and fractals that sometimes appear orderly and geometric, but can resemble random noise without adding any states or instructions to the set of production rules. The most classic merging of automata theory and biology is John Conway's Game of Life. "Life" is probably the most frequently written program in elementary computer science. The basic structure of Life is a two-dimensional cellular automaton that is given a start state of any number of filled cells. Each time step, or generation, switches cells on or off depending on the state of the cells that surround it. The rules are defined as follows: All eight of the cells surrounding the current one are checked to see if they are on or not. Any cells that are on are counted, and this count is then used to determine what will happen to the current cell: 1. Death: if the count is less than 2 or greater than 3, the current cell is switched off. 2. Survival: if (a) the count is exactly 2, or (b) the count is exactly 3 and the current cell is on, the current cell is left unchanged. 3. Birth: if the current cell is off and the count is exactly 3, the current cell is switched on. Like any manifestation of automata theory, the Game of LIfe can be defined using extremely simple and concise rules, but can produce incredibly complex and intricate patterns. In addition to the species-level complexity illustrated by the Game of Life, complexity within an individual organism can also be explained using automata theory. An organism might be complex in its full form, but examining constituent parts reveals consistency, symmetry, and patterns. Simple organisms, like maple leaves and star fish, even suggest mathematical structure in their full form. Using ideas of automata theory as a basis for generating the wide variety of life forms we see today, it becomes easier to think that sets of mathematical rules might be responsible for the complexity we notice every day. Inter-species observations also support the notion of automata theory instead of the specific and random optimization in natural selection. For example, there are striking similarities in patterns between very different orgranisms: Mollusks and pine cones grow by the Fibonacci sequence, reproducible by math. Leopards and snakes can have nearly identical pigmentation patterns, reproducible by two-dimensional automata. With these ideas in mind, it is difficult not to imagine that any biolgical attribute can be simulated with abstract machines and reduced to a more manageable level of simplicity.

38 38 Key Terms: Automaton: Abstract model of a digital computer. Acceptor: Automaton whose output response is Yes or No DFA: Deterministic Finite Automata. NFA: Non-deterministic Finite Automata. Regular Language: Language that can be constructed from the set operations Union, Concatenation and Kleene star. Regular expression: Mathematical tool built from a set of primitives and operations. Two-way Finite Automata: Machines that can read input string in either direction. Multiple Choice Questions 1. The length of the string is= Can not be determined 2. Let A and B are two sets, an element in A but not in B can be denoted by 1. A-B 2. AUB 3. A*B 4. A+B 3. A relation which satisfies reflexive, symmetric, transitive properties then the relation is called as 1. Equivalent Relation 2. Non-equivalent 3. Transpose relation 4. None 4. The Finite Automata accepts which of the language 1. Regular language 2. Context free language 3. Context sensitive language 4. None 5. Identify which of the following is not a regular expression 1. (10+01)* 2. (1+0)*(1+01)* 3. (1+0) (10^11)* 6. Which of the following conversion is not possible 1. NFA to DFA

39 39 2. NFA- to NFA 3. RE to NFA 4. None 7. Finite automata can remember the previous input. 1. True 2. False 8. The transition function of a NFA- includes 1. The mapping from set of states to set of input symbols The mapping from set of states to set of input symbols except and power set of Q 3. The mapping from set of states to set of input symbols including and power set of Q 4. The mapping from set of states to set of input symbols except 9. For every NFA, there exists an equivalent DFA. 1. True 2. False 10. In Finite Automata there may be more than one final state 1. True 2. False 11. is a input symbol, on which we can move from one state to another state with out any effect. 12. The -closure of state q0 is 1. q0 2. q1 3. q2 4. Final state 13. Which of the following is the equivalent language for the regular expression 1) {0, } 2) {,0,01,001,0101.} 3) {,01,011,0111 } 4) {01,0111,..) 14. +RR*= +R*R= 1) R 2) R* 3) 4) which of the following is the method of converting R.E to NFA- 1. Thompson s Construction 2. Arden s Theorem 3. State elimination Technique 4. Mealy Machine

40 40 Review Questions: 1. Define Finite automaton. 2. What is a finite automaton? Give two examples. 3. What is a transition diagram? 4. Enumerate the differences between DFA and NFA. 5. Construct a DFA for the regular expression aa*/bb*. 6. Construct a finite automata for the language {0n n mod 3 =2,n>=0}. 7. Explain the extended transition function for NFA, DFA and - NFA. 8. Construct a DFA that accepts all the strings on {0,1} except those containing the substring Explain in detail with an example the conversion of NFA to DFA. 10. Construct a NFA accepting the set of strings over {a,b} ending in aba. Use it to construct a DFA accepting the same set of strings. 11. For the finite state machine M given in the following table, test whether the strings , are accepted by M. State Input 0 1 q0 q0 q1 q1 q3 q0 q2 q0 q3 q3 q1 q2 12. Prove the following by the principle of induction Σk2 = n(n+1)(2n+1)/6 13. Construct a DFA that will accept strings on {a, b} where the number of b s is divisible by 3.

41 41 2 Marks question and Answers

42 42 SUMMARY Finite automata involves states and transitions among states in response to inputs. The basic method of deductive proofs proceeds by listing statements that are either given to be true or that follow logically from some of the previous statements. A DFA has a finite set of states and a finite set of input symbols. Transition diagrams are convenient to represent automata by a graph in which the nodes are the states and arcs are labeled by input symbols, indicating the transitions of that automaton. NFA differs from the DFA in that the NFA can have any number of transitions

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT. Recap DFA,NFA, DTM Slides by Prof. Debasis Mitra, FIT. 1 Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { {, } } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite

More information

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CS 154. Finite Automata, Nondeterminism, Regular Expressions CS 54 Finite Automata, Nondeterminism, Regular Expressions Read string left to right The DFA accepts a string if the process ends in a double circle A DFA is a 5-tuple M = (Q, Σ, δ, q, F) Q is the set

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY NON-DETERMINISM and REGULAR OPERATIONS THURSDAY JAN 6 UNION THEOREM The union of two regular languages is also a regular language Regular Languages Are

More information

Chapter 5. Finite Automata

Chapter 5. Finite Automata Chapter 5 Finite Automata 5.1 Finite State Automata Capable of recognizing numerous symbol patterns, the class of regular languages Suitable for pattern-recognition type applications, such as the lexical

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be

More information

Languages, regular languages, finite automata

Languages, regular languages, finite automata Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,

More information

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r Syllabus R9 Regulation UNIT-II NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: In the automata theory, a nondeterministic finite automaton (NFA) or nondeterministic finite state machine is a finite

More information

Uses of finite automata

Uses of finite automata Chapter 2 :Finite Automata 2.1 Finite Automata Automata are computational devices to solve language recognition problems. Language recognition problem is to determine whether a word belongs to a language.

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 6 CHAPTER 2 FINITE AUTOMATA 2. Nondeterministic Finite Automata NFA 3. Finite Automata and Regular Expressions 4. Languages

More information

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2 BIJU PATNAIK UNIVERSITY OF TECHNOLOGY, ODISHA Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2 Prepared by, Dr. Subhendu Kumar Rath, BPUT, Odisha. UNIT 2 Structure NON-DETERMINISTIC FINITE AUTOMATA

More information

Finite Automata. Mahesh Viswanathan

Finite Automata. Mahesh Viswanathan Finite Automata Mahesh Viswanathan In this lecture, we will consider different models of finite state machines and study their relative power. These notes assume that the reader is familiar with DFAs,

More information

Theory of Computation

Theory of Computation Thomas Zeugmann Hokkaido University Laboratory for Algorithmics http://www-alg.ist.hokudai.ac.jp/ thomas/toc/ Lecture 3: Finite State Automata Motivation In the previous lecture we learned how to formalize

More information

Computational Models - Lecture 4

Computational Models - Lecture 4 Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push

More information

Introduction to Turing Machines. Reading: Chapters 8 & 9

Introduction to Turing Machines. Reading: Chapters 8 & 9 Introduction to Turing Machines Reading: Chapters 8 & 9 1 Turing Machines (TM) Generalize the class of CFLs: Recursively Enumerable Languages Recursive Languages Context-Free Languages Regular Languages

More information

Sri vidya college of engineering and technology

Sri vidya college of engineering and technology Unit I FINITE AUTOMATA 1. Define hypothesis. The formal proof can be using deductive proof and inductive proof. The deductive proof consists of sequence of statements given with logical reasoning in order

More information

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism, CS 54, Lecture 2: Finite Automata, Closure Properties Nondeterminism, Why so Many Models? Streaming Algorithms 0 42 Deterministic Finite Automata Anatomy of Deterministic Finite Automata transition: for

More information

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences

More information

Introduction: Computer Science is a cluster of related scientific and engineering disciplines concerned with the study and application of computations. These disciplines range from the pure and basic scientific

More information

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is, Recall A deterministic finite automaton is a five-tuple where S is a finite set of states, M = (S, Σ, T, s 0, F ) Σ is an alphabet the input alphabet, T : S Σ S is the transition function, s 0 S is the

More information

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F) Outline Nondeterminism Regular expressions Elementary reductions http://www.cs.caltech.edu/~cs20/a October 8, 2002 1 Determistic Finite Automata A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F) Q is a finite

More information

Theory of Computation (II) Yijia Chen Fudan University

Theory of Computation (II) Yijia Chen Fudan University Theory of Computation (II) Yijia Chen Fudan University Review A language L is a subset of strings over an alphabet Σ. Our goal is to identify those languages that can be recognized by one of the simplest

More information

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013 CMPSCI 250: Introduction to Computation Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013 λ-nfa s to NFA s to DFA s Reviewing the Three Models and Kleene s Theorem The Subset

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 5 CHAPTER 2 FINITE AUTOMATA 1. Deterministic Finite Automata DFA 2. Nondeterministic Finite Automata NDFA 3. Finite Automata

More information

Finite Automata. Finite Automata

Finite Automata. Finite Automata Finite Automata Finite Automata Formal Specification of Languages Generators Grammars Context-free Regular Regular Expressions Recognizers Parsers, Push-down Automata Context Free Grammar Finite State

More information

Lecture 17: Language Recognition

Lecture 17: Language Recognition Lecture 17: Language Recognition Finite State Automata Deterministic and Non-Deterministic Finite Automata Regular Expressions Push-Down Automata Turing Machines Modeling Computation When attempting to

More information

Computational Theory

Computational Theory Computational Theory Finite Automata and Regular Languages Curtis Larsen Dixie State University Computing and Design Fall 2018 Adapted from notes by Russ Ross Adapted from notes by Harry Lewis Curtis Larsen

More information

MA/CSSE 474 Theory of Computation

MA/CSSE 474 Theory of Computation MA/CSSE 474 Theory of Computation CFL Hierarchy CFL Decision Problems Your Questions? Previous class days' material Reading Assignments HW 12 or 13 problems Anything else I have included some slides online

More information

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET Regular Languages and FA A language is a set of strings over a finite alphabet Σ. All languages are finite or countably infinite. The set of all languages

More information

INF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo

INF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo INF28 1. Introduction and Regular Languages Daniel Lupp Universitetet i Oslo 18th January 218 Department of Informatics University of Oslo INF28 Lecture :: 18th January 1 / 33 Details on the Course consists

More information

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013 Q.2 a. Prove by mathematical induction n 4 4n 2 is divisible by 3 for n 0. Basic step: For n = 0, n 3 n = 0 which is divisible by 3. Induction hypothesis: Let p(n) = n 3 n is divisible by 3. Induction

More information

CPSC 421: Tutorial #1

CPSC 421: Tutorial #1 CPSC 421: Tutorial #1 October 14, 2016 Set Theory. 1. Let A be an arbitrary set, and let B = {x A : x / x}. That is, B contains all sets in A that do not contain themselves: For all y, ( ) y B if and only

More information

Nondeterministic Finite Automata and Regular Expressions

Nondeterministic Finite Automata and Regular Expressions Nondeterministic Finite Automata and Regular Expressions CS 2800: Discrete Structures, Spring 2015 Sid Chaudhuri Recap: Deterministic Finite Automaton A DFA is a 5-tuple M = (Q, Σ, δ, q 0, F) Q is a finite

More information

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova. Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures Tuesday 10:45 pm - 12:15 pm Instructions Tuesday 12:30

More information

Foundations of Informatics: a Bridging Course

Foundations of Informatics: a Bridging Course Foundations of Informatics: a Bridging Course Week 3: Formal Languages and Semantics Thomas Noll Lehrstuhl für Informatik 2 RWTH Aachen University noll@cs.rwth-aachen.de http://www.b-it-center.de/wob/en/view/class211_id948.html

More information

Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs) CS/ECE 374: Algorithms & Models of Computation, Fall 28 Deterministic Finite Automata (DFAs) Lecture 3 September 4, 28 Chandra Chekuri (UIUC) CS/ECE 374 Fall 28 / 33 Part I DFA Introduction Chandra Chekuri

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 15 Ana Bove May 17th 2018 Recap: Context-free Languages Chomsky hierarchy: Regular languages are also context-free; Pumping lemma

More information

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova. Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures and Instructions 23.10. 3.11. 17.11. 24.11. 1.12. 11.12.

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata Not A DFA Does not have exactly one transition from every state on every symbol: Two transitions from q 0 on a No transition from q 1 (on either a or b) Though not a DFA,

More information

Final exam study sheet for CS3719 Turing machines and decidability.

Final exam study sheet for CS3719 Turing machines and decidability. Final exam study sheet for CS3719 Turing machines and decidability. A Turing machine is a finite automaton with an infinite memory (tape). Formally, a Turing machine is a 6-tuple M = (Q, Σ, Γ, δ, q 0,

More information

CS 121, Section 2. Week of September 16, 2013

CS 121, Section 2. Week of September 16, 2013 CS 121, Section 2 Week of September 16, 2013 1 Concept Review 1.1 Overview In the past weeks, we have examined the finite automaton, a simple computational model with limited memory. We proved that DFAs,

More information

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS 154, Lecture 3: DFA NFA, Regular Expressions CS 154, Lecture 3: DFA NFA, Regular Expressions Homework 1 is coming out Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and

More information

Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs) Algorithms & Models of Computation CS/ECE 374, Fall 27 Deterministic Finite Automata (DFAs) Lecture 3 Tuesday, September 5, 27 Sariel Har-Peled (UIUC) CS374 Fall 27 / 36 Part I DFA Introduction Sariel

More information

Computational Models - Lecture 5 1

Computational Models - Lecture 5 1 Computational Models - Lecture 5 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 10/22, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

CISC4090: Theory of Computation

CISC4090: Theory of Computation CISC4090: Theory of Computation Chapter 2 Context-Free Languages Courtesy of Prof. Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Spring, 2014 Overview In Chapter

More information

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harry Lewis October 8, 2013 Reading: Sipser, pp. 119-128. Pushdown Automata (review) Pushdown Automata = Finite automaton

More information

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties Recall a closure property is a statement

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata Mahesh Viswanathan Introducing Nondeterminism Consider the machine shown in Figure. Like a DFA it has finitely many states and transitions labeled by symbols from an input

More information

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen Pushdown automata Twan van Laarhoven Institute for Computing and Information Sciences Intelligent Systems Version: fall 2014 T. van Laarhoven Version: fall 2014 Formal Languages, Grammars and Automata

More information

COM364 Automata Theory Lecture Note 2 - Nondeterminism

COM364 Automata Theory Lecture Note 2 - Nondeterminism COM364 Automata Theory Lecture Note 2 - Nondeterminism Kurtuluş Küllü March 2018 The FA we saw until now were deterministic FA (DFA) in the sense that for each state and input symbol there was exactly

More information

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM) Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM) 1 Deterministic Turing Machine (DTM).. B B 0 1 1 0 0 B B.. Finite Control Two-way, infinite tape, broken into

More information

Chapter Five: Nondeterministic Finite Automata

Chapter Five: Nondeterministic Finite Automata Chapter Five: Nondeterministic Finite Automata From DFA to NFA A DFA has exactly one transition from every state on every symbol in the alphabet. By relaxing this requirement we get a related but more

More information

Lecture 3: Nondeterministic Finite Automata

Lecture 3: Nondeterministic Finite Automata Lecture 3: Nondeterministic Finite Automata September 5, 206 CS 00 Theory of Computation As a recap of last lecture, recall that a deterministic finite automaton (DFA) consists of (Q, Σ, δ, q 0, F ) where

More information

Computational Models - Lecture 3

Computational Models - Lecture 3 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models - Lecture 3 Equivalence of regular expressions and regular languages (lukewarm leftover

More information

CSCE 551: Chin-Tser Huang. University of South Carolina

CSCE 551: Chin-Tser Huang. University of South Carolina CSCE 551: Theory of Computation Chin-Tser Huang huangct@cse.sc.edu University of South Carolina Church-Turing Thesis The definition of the algorithm came in the 1936 papers of Alonzo Church h and Alan

More information

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010 University of Virginia - cs3102: Theory of Computation Spring 2010 PS2 - Comments Average: 77.4 (full credit for each question is 100 points) Distribution (of 54 submissions): 90, 12; 80 89, 11; 70-79,

More information

The Pumping Lemma. for all n 0, u 1 v n u 2 L (i.e. u 1 u 2 L, u 1 vu 2 L [but we knew that anyway], u 1 vvu 2 L, u 1 vvvu 2 L, etc.

The Pumping Lemma. for all n 0, u 1 v n u 2 L (i.e. u 1 u 2 L, u 1 vu 2 L [but we knew that anyway], u 1 vvu 2 L, u 1 vvvu 2 L, etc. The Pumping Lemma For every regular language L, there is a number l 1 satisfying the pumping lemma property: All w L with w l can be expressed as a concatenation of three strings, w = u 1 vu 2, where u

More information

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata : Organization of Programming Languages Theory of Regular Expressions Finite Automata Previous Course Review {s s defined} means the set of string s such that s is chosen or defined as given s A means

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 14 Ana Bove May 14th 2018 Recap: Context-free Grammars Simplification of grammars: Elimination of ǫ-productions; Elimination of

More information

Finite Automata and Regular Languages

Finite Automata and Regular Languages Finite Automata and Regular Languages Topics to be covered in Chapters 1-4 include: deterministic vs. nondeterministic FA, regular expressions, one-way vs. two-way FA, minimization, pumping lemma for regular

More information

Pushdown Automata. Reading: Chapter 6

Pushdown Automata. Reading: Chapter 6 Pushdown Automata Reading: Chapter 6 1 Pushdown Automata (PDA) Informally: A PDA is an NFA-ε with a infinite stack. Transitions are modified to accommodate stack operations. Questions: What is a stack?

More information

CS 455/555: Finite automata

CS 455/555: Finite automata CS 455/555: Finite automata Stefan D. Bruda Winter 2019 AUTOMATA (FINITE OR NOT) Generally any automaton Has a finite-state control Scans the input one symbol at a time Takes an action based on the currently

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION FORMAL LANGUAGES, AUTOMATA AND COMPUTATION DECIDABILITY ( LECTURE 15) SLIDES FOR 15-453 SPRING 2011 1 / 34 TURING MACHINES-SYNOPSIS The most general model of computation Computations of a TM are described

More information

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata. Finite Automata Automata (singular: automation) are a particularly simple, but useful, model of computation. They were initially proposed as a simple model for the behavior of neurons. The concept of a

More information

Lecture 1: Finite State Automaton

Lecture 1: Finite State Automaton Lecture 1: Finite State Automaton Instructor: Ketan Mulmuley Scriber: Yuan Li January 6, 2015 1 Deterministic Finite Automaton Informally, a deterministic finite automaton (DFA) has finite number of s-

More information

Turing Machines Part III

Turing Machines Part III Turing Machines Part III Announcements Problem Set 6 due now. Problem Set 7 out, due Monday, March 4. Play around with Turing machines, their powers, and their limits. Some problems require Wednesday's

More information

UNIT-III REGULAR LANGUAGES

UNIT-III REGULAR LANGUAGES Syllabus R9 Regulation REGULAR EXPRESSIONS UNIT-III REGULAR LANGUAGES Regular expressions are useful for representing certain sets of strings in an algebraic fashion. In arithmetic we can use the operations

More information

UNIT-VIII COMPUTABILITY THEORY

UNIT-VIII COMPUTABILITY THEORY CONTEXT SENSITIVE LANGUAGE UNIT-VIII COMPUTABILITY THEORY A Context Sensitive Grammar is a 4-tuple, G = (N, Σ P, S) where: N Set of non terminal symbols Σ Set of terminal symbols S Start symbol of the

More information

Theory of computation: initial remarks (Chapter 11)

Theory of computation: initial remarks (Chapter 11) Theory of computation: initial remarks (Chapter 11) For many purposes, computation is elegantly modeled with simple mathematical objects: Turing machines, finite automata, pushdown automata, and such.

More information

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS Automata Theory Lecture on Discussion Course of CS2 This Lecture is about Mathematical Models of Computation. Why Should I Care? - Ways of thinking. - Theory can drive practice. - Don t be an Instrumentalist.

More information

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages COMP/MATH 300 Topics for Spring 2017 June 5, 2017 Review and Regular Languages Exam I I. Introductory and review information from Chapter 0 II. Problems and Languages A. Computable problems can be expressed

More information

DM17. Beregnelighed. Jacob Aae Mikkelsen

DM17. Beregnelighed. Jacob Aae Mikkelsen DM17 Beregnelighed Jacob Aae Mikkelsen January 12, 2007 CONTENTS Contents 1 Introduction 2 1.1 Operations with languages...................... 2 2 Finite Automata 3 2.1 Regular expressions/languages....................

More information

10. The GNFA method is used to show that

10. The GNFA method is used to show that CSE 355 Midterm Examination 27 February 27 Last Name Sample ASU ID First Name(s) Ima Exam # Sample Regrading of Midterms If you believe that your grade has not been recorded correctly, return the entire

More information

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA) Languages Non deterministic finite automata with ε transitions Recall What is a language? What is a class of languages? Finite Automata Consists of A set of states (Q) A start state (q o ) A set of accepting

More information

Undecidable Problems and Reducibility

Undecidable Problems and Reducibility University of Georgia Fall 2014 Reducibility We show a problem decidable/undecidable by reducing it to another problem. One type of reduction: mapping reduction. Definition Let A, B be languages over Σ.

More information

Intro to Theory of Computation

Intro to Theory of Computation Intro to Theory of Computation 1/19/2016 LECTURE 3 Last time: DFAs and NFAs Operations on languages Today: Nondeterminism Equivalence of NFAs and DFAs Closure properties of regular languages Sofya Raskhodnikova

More information

What we have done so far

What we have done so far What we have done so far DFAs and regular languages NFAs and their equivalence to DFAs Regular expressions. Regular expressions capture exactly regular languages: Construct a NFA from a regular expression.

More information

Finite Automata and Regular languages

Finite Automata and Regular languages Finite Automata and Regular languages Huan Long Shanghai Jiao Tong University Acknowledgements Part of the slides comes from a similar course in Fudan University given by Prof. Yijia Chen. http://basics.sjtu.edu.cn/

More information

Theory Bridge Exam Example Questions

Theory Bridge Exam Example Questions Theory Bridge Exam Example Questions Annotated version with some (sometimes rather sketchy) answers and notes. This is a collection of sample theory bridge exam questions. This is just to get some idea

More information

ACS2: Decidability Decidability

ACS2: Decidability Decidability Decidability Bernhard Nebel and Christian Becker-Asano 1 Overview An investigation into the solvable/decidable Decidable languages The halting problem (undecidable) 2 Decidable problems? Acceptance problem

More information

Pushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen

Pushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen Pushdown Automata Notes on Automata and Theory of Computation Chia-Ping Chen Department of Computer Science and Engineering National Sun Yat-Sen University Kaohsiung, Taiwan ROC Pushdown Automata p. 1

More information

Nondeterministic finite automata

Nondeterministic finite automata Lecture 3 Nondeterministic finite automata This lecture is focused on the nondeterministic finite automata (NFA) model and its relationship to the DFA model. Nondeterminism is an important concept in the

More information

1 More finite deterministic automata

1 More finite deterministic automata CS 125 Section #6 Finite automata October 18, 2016 1 More finite deterministic automata Exercise. Consider the following game with two players: Repeatedly flip a coin. On heads, player 1 gets a point.

More information

UNIT II REGULAR LANGUAGES

UNIT II REGULAR LANGUAGES 1 UNIT II REGULAR LANGUAGES Introduction: A regular expression is a way of describing a regular language. The various operations are closure, union and concatenation. We can also find the equivalent regular

More information

Theory of computation: initial remarks (Chapter 11)

Theory of computation: initial remarks (Chapter 11) Theory of computation: initial remarks (Chapter 11) For many purposes, computation is elegantly modeled with simple mathematical objects: Turing machines, finite automata, pushdown automata, and such.

More information

Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs) Algorithms & Models of Computation CS/ECE 374, Spring 29 Deterministic Finite Automata (DFAs) Lecture 3 Tuesday, January 22, 29 L A TEXed: December 27, 28 8:25 Chan, Har-Peled, Hassanieh (UIUC) CS374 Spring

More information

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam ECS 120: Theory of Computation Handout MT UC Davis Phillip Rogaway February 16, 2012 Midterm Exam Instructions: The exam has six pages, including this cover page, printed out two-sided (no more wasted

More information

Grade 6 Math Circles October 20/21, Formalism and Languages: Beyond Regular Languages

Grade 6 Math Circles October 20/21, Formalism and Languages: Beyond Regular Languages Faculty of Mathematics Waterloo, Ontario N2L 3G1 Centre for Education in Mathematics and Computing Grade 6 Math Circles October 20/21, 2015 Formalism and Languages: Beyond Regular Languages Dr. Troy Vasiga

More information

Finite Automata and Languages

Finite Automata and Languages CS62, IIT BOMBAY Finite Automata and Languages Ashutosh Trivedi Department of Computer Science and Engineering, IIT Bombay CS62: New Trends in IT: Modeling and Verification of Cyber-Physical Systems (2

More information

CONCATENATION AND KLEENE STAR ON DETERMINISTIC FINITE AUTOMATA

CONCATENATION AND KLEENE STAR ON DETERMINISTIC FINITE AUTOMATA 1 CONCATENATION AND KLEENE STAR ON DETERMINISTIC FINITE AUTOMATA GUO-QIANG ZHANG, XIANGNAN ZHOU, ROBERT FRASER, LICONG CUI Department of Electrical Engineering and Computer Science, Case Western Reserve

More information

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I Internal Examination 2017-18 B.Tech III Year VI Semester Sub: Theory of Computation (6CS3A) Time: 1 Hour 30 min. Max Marks: 40 Note: Attempt all three

More information

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata. CMSC 330: Organization of Programming Languages Last Lecture Languages Sets of strings Operations on languages Finite Automata Regular expressions Constants Operators Precedence CMSC 330 2 Clarifications

More information

Deterministic Finite Automaton (DFA)

Deterministic Finite Automaton (DFA) 1 Lecture Overview Deterministic Finite Automata (DFA) o accepting a string o defining a language Nondeterministic Finite Automata (NFA) o converting to DFA (subset construction) o constructed from a regular

More information

CSE 105 Theory of Computation

CSE 105 Theory of Computation CSE 105 Theory of Computation http://www.jflap.org/jflaptmp/ Professor Jeanne Ferrante 1 Today s Agenda Quick Review of CFG s and PDA s Introduction to Turing Machines and their Languages Reminders and

More information

V Honors Theory of Computation

V Honors Theory of Computation V22.0453-001 Honors Theory of Computation Problem Set 3 Solutions Problem 1 Solution: The class of languages recognized by these machines is the exactly the class of regular languages, thus this TM variant

More information

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY RYAN DOUGHERTY If we want to talk about a program running on a real computer, consider the following: when a program reads an instruction,

More information

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata Sungjin Im University of California, Merced 1-27-215 Nondeterminism Michael Rabin and Dana Scott (1959) Michael Rabin Dana

More information

Automata Theory and Formal Grammars: Lecture 1

Automata Theory and Formal Grammars: Lecture 1 Automata Theory and Formal Grammars: Lecture 1 Sets, Languages, Logic Automata Theory and Formal Grammars: Lecture 1 p.1/72 Sets, Languages, Logic Today Course Overview Administrivia Sets Theory (Review?)

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION "Winter" 2018 http://cseweb.ucsd.edu/classes/wi18/cse105-ab/ Today's learning goals Sipser Section 1.1 Design an automaton that recognizes a given language. Specify each of

More information

Automata: a short introduction

Automata: a short introduction ILIAS, University of Luxembourg Discrete Mathematics II May 2012 What is a computer? Real computers are complicated; We abstract up to an essential model of computation; We begin with the simplest possible

More information

Most General computer?

Most General computer? Turing Machines Most General computer? DFAs are simple model of computation. Accept only the regular languages. Is there a kind of computer that can accept any language, or compute any function? Recall

More information