Lecture 17: Language Recognition

Size: px
Start display at page:

Download "Lecture 17: Language Recognition"

Transcription

1 Lecture 17: Language Recognition Finite State Automata Deterministic and Non-Deterministic Finite Automata Regular Expressions Push-Down Automata Turing Machines

2 Modeling Computation When attempting to deal with theoretical issues concerning digital computers, we need a simplified definition of what a computer does. Such a description is called a computational model. The first computational model we will consider is called a finite automaton or finite state machine. A finite automaton is depicted below as a state control with a read head that scans an input string. At the end of the string the state control will indicate whether or not the scanned string is accepted or rejected as a member of the set of strings recognized by the finite automaton.

3 Formal Definition of Computation The sequence of state transitions shown above is formally defined as computation in the following manner: Let M = (Q,Σ,δ,q 0,F) be a finite automaton and w = w 1 w 2...w n be a string over the alphabet Σ. Then M accepts the string w if a sequence of states r 0,r 1,...,r n exists in Q with the following three conditions: 1. r 0 =q 0, 2. δ(r,w i+1 ) = r i+1 for i = 0,..., n-1, and 3. r n is an element F. These three conditions state that (1) the inital state must be the start state, (2) the sequence of state transitions must be valid transitions for the finite state machine M and (3) the final state of M after processing w must be an accept state.

4 Finite Automaton Formally, a finite Automaton (FA) is defined as a 5-tuple (Q,S, d, q0, F) where, (1) Q is a finite set called the states. (2) S is a finite set called the alphabet. (3) d:q x S -> Q is the transition function (4) q0 is an element of Q called the start state, and (5) F is a subset of Q called the set of accept states. The set of states Q is just a set of labels, q0..q3. The alphabet S is the set of symbols that can be understood by the FA. In this case the alphabet consists of the two symbols 0 and 1. This means that the FA will be able to read (scan the symbols in) strings comprised only of 0's and 1's.

5 State Transition Function The transition function is represented by the arrows in the state transition diagram. This is a discrete function that maps every possible combination of a state with a symbol from the alphabet to another state, as shown in the table below: Note that there is a transition out of each state for each symbol, so we have 4x2=8 transitions. The start state, q0 is the initial state of the FA. The set F is the set of accept states. In our example F = {q1, q3}. This means that the binary string being scanned is recognized or accepted by the FA if the final state (after scanning the binary string) is one of the accept states.

6 Let's try a few example strings. (Scan from left to right)

7 Regular Language The set of all strings A accepted by a finite state machine M is called the language of M. We say that M accepts or recognizes A. Sybollically we write, A={ω M accepts ω} We say that A is a regular language if it is recognized by a finite automaton.

8 Regular Operations The operations of union, concatenation and Kleene-closure (also called star) are called regular operations on regular languages. Union: A U B = {x x is an element of A or x is an element of B} Concatenation: AoB = {xy x is an element of A and y is an element of B} Kleene-closure: A* = {x 1 x 2...x k k>= 0 and each x i is an element of A}

9 Nondeterminism When there is exactly one transition from each state for each alphabet symbol a finite automaton is said to be deterministic. When there can be zero transitions or more than one transition from some states for certain alphabet symbols, then the finite automaton is said to be nondeterministic. Nondeterministic Finite Automata (NFA) are essential to the development of theoretical computer science because they greatly simplify several important proofs. Every deterministic finite automata (DFA) is automatically an NFA since NFAs are a more general form of DFAs. A nondeterministic finite automation is a 5-tuple (Q,Σ,δ,q 0,F), where, (1) Q is a finite set of states (2) Σ is a finite alphabet (3) δ: QxΣε -> P(Q) is the transition function (4) q 0 is an element of Q (the start state) (5) F is a subset of Q (the set of accept states).

10 An Example This definition is similar to the DFA except that the nondeterminism permits the transition from a state to more than one state for the same symbol in the alphabet. In general a nondeterministic transition can be from a state to any subset of the states in Q. This is why QxΣε maps to the power set of Q P(Q) rather than to just Q as for the DFA. Σε refers to the alphabet (set of symbols) with epsilon ε. An epsilon move is a transition from one state to another without reading a symbol from the candidate string. a b b a

11 An Example This definition is similar to the DFA except that the nondeterminism permits the transition from a state to more than one state for the same symbol in the alphabet. In general a nondeterministic transition can be from a state to any subset of the states in Q. This is why QxΣε maps to the power set of Q P(Q) rather than to just Q as for the DFA. Σε refers to the alphabet (set of symbols) with epsilon ε. An epsilon move is a transition from one state to another without reading a symbol from the candidate string. a b b a

12 An Example This definition is similar to the DFA except that the nondeterminism permits the transition from a state to more than one state for the same symbol in the alphabet. In general a nondeterministic transition can be from a state to any subset of the states in Q. This is why QxΣε maps to the power set of Q P(Q) rather than to just Q as for the DFA. Σε refers to the alphabet (set of symbols) with epsilon ε. An epsilon move is a transition from one state to another without reading a symbol from the candidate string. a b b a

13 An Example This definition is similar to the DFA except that the nondeterminism permits the transition from a state to more than one state for the same symbol in the alphabet. In general a nondeterministic transition can be from a state to any subset of the states in Q. This is why QxΣε maps to the power set of Q P(Q) rather than to just Q as for the DFA. Σε refers to the alphabet (set of symbols) with epsilon ε. An epsilon move is a transition from one state to another without reading a symbol from the candidate string. a b b a

14 An Example This definition is similar to the DFA except that the nondeterminism permits the transition from a state to more than one state for the same symbol in the alphabet. In general a nondeterministic transition can be from a state to any subset of the states in Q. This is why QxΣε maps to the power set of Q P(Q) rather than to just Q as for the DFA. Σε refers to the alphabet (set of symbols) with epsilon ε. An epsilon move is a transition from one state to another without reading a symbol from the candidate string. a b b a

15 An Example This definition is similar to the DFA except that the nondeterminism permits the transition from a state to more than one state for the same symbol in the alphabet. In general a nondeterministic transition can be from a state to any subset of the states in Q. This is why QxΣε maps to the power set of Q P(Q) rather than to just Q as for the DFA. Σε refers to the alphabet (set of symbols) with epsilon ε. An epsilon move is a transition from one state to another without reading a symbol from the candidate string. a b b a

16 An Example This definition is similar to the DFA except that the nondeterminism permits the transition from a state to more than one state for the same symbol in the alphabet. In general a nondeterministic transition can be from a state to any subset of the states in Q. This is why QxΣε maps to the power set of Q P(Q) rather than to just Q as for the DFA. Σε refers to the alphabet (set of symbols) with epsilon ε. An epsilon move is a transition from one state to another without reading a symbol from the candidate string. a b b a

17 Equivalence of NFA's and DFA's In terms of computational power, the DFA and the NFA are equivalent. This means that for every NFA there is a DFA that recognizes the same language. Since every DFA is an NFA the reverse is trivially true. Rather than reviewing the proof we will use the proof idea The methods in this to generate an equivalent DFA for an NFA as shown in the following example: Given the NFA of the previous examle, we will construct a DFA that recognizes the same language. 1. We will build a DFA with a set of states Q D whose members correspond to the members of P(Q). Since the NFA has states Q={q 0,q 1,q 2 } the DFA will have states corresponding to { φ, {q 0 }, {q 1 }, {q 2 }, {q 0,q 1 }, {q 0,q 2 }, {q 1,q 2 }, {q 0,q 1,q 2 }} and represented by Q D ={q φ, q 0, q 1, q 2, q 01,q 02, q 12, q 012 }.

18 2. The start state for the DFA is the state representing the subset of states in the NFA that includes the start state and all the states reachable from the start state on an epsilon move. In this case the start state is q 01. The accept states in the DFA are all the states derived from one or more of the accept states of the NFA. Recall that, in a DFA there is a transition from each state for each symbol in the alphabet Σ. Since states in an NFA may have no transitions for some symbols, we need a trap state in our DFA to dump the deadend transitions (i.e. those that do not exist in the NFA). This trap state is not an accept state and it has a transition to itself on every symbol.

19 3. Now we will define the DFA transitions for each of the NFA transitions. Transitions from q 0 - Starting with state q 0 we observe that there is no transistion in the NFA from q 0 reading the symbol a, therefore we will include a transition from state q 0 in the DFA to state q φ. There is a transistion from q 0 to q 2 in the NFA so we simply replicate this transition for the DFA. For convenience we show the NFA on the right below.

20 Transitions from q 1 - The NFA transitions from q 1 reading a and b are transferred to the DFA. Since there is no transition from q0 since

21 Transitions from q 0 and q 1 - The state q 01 in the DFA corresponds to the pair of states q 0 and q 1 in the NFA. Look at the NFA and determine all the states that can be reached from both of these states when reading the symbol a. In this case we note that the transtion from q1 to q0 for the symbol a also leads back to q1 on an epsilon move. Since states q 0 and q 1 can both be reached upon reading the symbol a, we note that this corresponds to the single state q 01 in the DFA.

22 Transitions from q 2 - State q 2 in the NFA has two transitions for the symbol a, one to state q 1 and one back to state q 2, so we generate a transition from state q 2 to state q 12 in the DFA. Threre is a single transition from q 2 to q 1 in the NFA so it is copied to the DFA.

23 Transitions from q 1 and q 2 - We observe that from states q 1 and q 2 every state in the NFA can be reached on transitions for the symbol a. We represent this set of transitions in the DFA with an a-transition from q 12 to q 012. There is only one transition for the symbol b from states q 1 and q 2 in the NFA, which we copy to the DFA.

24 Transitions from q 0 and q 2 - Transitions from q 0 and q 2 for both a and b go to states q 1 and q 2 in the NFA, therefore we generate transitions from state q 02 to state q 12 in the DFA for symbols a and b.

25 Transitions from states q 0, q 1 and q 2 - Generating the DFA transitions for state q 012 requires that we determine all the states that can be reached from any state in the NFA for each of the symbols a and b. Every state in the NFA is can be reached on an a-transition from some state, therefore we generate a transition from q012 to itself for the symbol a. There is a transition from some state to every state but q 0 for the symbol b, so we generate a b- transition from state q 012 to state q 12 in the DFA.

26 4. Next we remove any unreachable states. In this example, state q 0 and q 02 have no transitions into them, therefore they are unrechable and can be removed without affecting the language being recognized by this DFA.

27 Finally we can rearrange the positions of the nodes to simplify the graphical representation. NFA DFA

28 Regular Expressions Up to now we have defined regular languages using finite automata and we have shown that DFAs and NFAs are equivalent. Sometimes using a state transition diagram to describe a regular language is inconvenient. Regular expressions are algebraic forms for defining regular languages, that use regular operations on the symbols of the regular language to indicate the member strings of the lanugage. For example, the regular expression, (0+1)0* describes the regular language over the alphabet {0,1} consisting of all binay strings starting with a 0 or a 1 and followed by zero or more 0's. The regular operations include a choice or union operator (+ or ), concatenation (implied by sequence of symbols or shown as a fixed number of repetitions n e.g. xy n z), and star or Kleene closure (*) which means zero or more repetitions of a substring..

29 Regular Expressions are Equivalent to NFA's We wish to show that the regular expressions are equivalent to NFAs and DFAs in the ability to describe regular languages (i.e. they all have the same computational power to describe the class of languages called regular). The first step in this goal is to show that the class of regular languages are closed under the regular operations of union, concatenation and star. The formal proofs are covered in the textbook. Here will look at graphical representations of the proof ideas. We represent generic NFAs as collections of three types of states,. and we will use epsion moves to combine generic NFAs to construct new NFAs demonstrating closure for each of the regular operations.

30 Regular Languages Closed under Union Theorem: The class of regular languages is closed under the union operation. In the diagram above we see that the two NFAs, N1 and N2 can be combined into a new NFA, N that recognizes the union of the languages on N1 and N2. N is constructed by adding a new start state and connecting it to the start states of N1 and N2 with epsilon moves. The remaining structures of N1 and N2 are left unchanged. It should be clear that any string that is accepted by N1 or N2 will be accepted by N and that any string that is accepted by N would be accepted by N1 or N2 or both.

31 Regular Languages Closed under Concatenation Theorem: The class of regular languages is closed under the concatenation operation. In this construction we wish to show that N accepts any string that is the contatenation of a member string from N2 to the end of a member string from N1. N is created by connecting all the accept states in N1 to the start state of N2 with epsilon moves. We then convert all the accept states of N1 to non-accept states (there will be no accept states in the portion of N that was N1.) Note that this works whether or not the start states of N1 and N2 are accept states. For example, if N1 accepts the empty string but N2 does not, then N should not accept the empty string. On the other hand if both N1 and N2 accept the empty string then there will be an epsion move from the start state of N1 to the start state of N2 (which will still be an accept state).

32 Regular Languages Closed under Star Operation Kleene Closure Theorem: The class of regular languages is closed under the star operation. Converting an NFA, N1 into N1* can be accomplished by connecting all the accept states to the original start state through epsilon moves. Since N1* must accept the empty string we will add a new start state which is also an accept state and connect it to the original start state of N1 through an epsion move. You may wonder why we don't just make the original start state into an accept state. The reason this does not work is that the NFA, N1 could have a path of transitions back to the start state for some string of symbols that is not a member string. Converting the start state of N1 into an accept state would result in these strings being accepted.

33 Generating Regular Expressions Create a regular expression for the set of binary strings that contain at least two consecutive 0's. any sequence of 0's and 1's including nothing followed by two consecutive 0's followed by any sequence of 0's and 1's including nothing (0 + 1)* 00 (0 + 1)*

34 another Example Create a regular expression to generation all binary strings that do not contain two consecutive 0's (1 + 01)* (0 + λ)

35 Regular Expressions are not Unique L = { all strings with at least two consecutive 0 } r1 = (1 + 01)*(0 + λ) r = (1*011*)*(0 + λ ) + 1*(0 + 2 λ ) L r ) = L( r ) = ( 1 2 L r and 1 r 2 are equivalent regular expr.

36 Converting a Regular Expression to an NFA 0 ( )* 0 start 0 ε 0 ε ε 0 0 ε ε 1 1 ε

37 Pushdown Automata We will learn that some context-free grammars are not regular. The reason for this is that context-free grammars can be recursive. We can modify finite automata to be able to account for this recursive structure and to recognize context-free languages. The missing feature in finite automata is an accessible and arbitrarily large memory capacity. We include a stack memory component to an NFA to obtain the pushdown automata.

38 Formal Definition of Pushdown Automata A pushdown automata (PDA) reads symbols from the input string and pushes symbols to, and pops symbols from, a stack memory. The symbol set for the input string is not necessarily the same as the symbol set for the stack memory. Formally we define a pushdown automata as a 6-tuple (Q,Σ,Γ,δ,q 0,F) where 1. Q is the set of states, 2. Σ is the input symbol set, 3. Γ is the stack symbol set, 4. δ:q x Σε x Γε-> P(Q x Γε) is the transition function, 5. q 0 is an element of Q (the start state), 6. F is a subset of Q (the set of accept states). The symbol ε as a subscript on the input symbol set and the stack symbol set in the definition of the transition function means that the PDA can move (transition) without reading an input symbol or a stack symbol.

39 Pushdown Automata is more Computationally Powerful than Regular Expressions Example: Recall that the language {0 n 1 n n>= 0 } is not regular so there is no NFA that can recognize it. As an example of the increased computational power of pushdown automata we will describe a PDA that recognizes this non-regular language. Q = { q1, q2, q3, q4}, Σ = { 0,1} Γ = {0,$}, q start = q1, F = {q1,q4}, δ is defined in the table below:

40 Graphical Representation of the PDA Also, we can display the PDA graphically as, The left side of each transition label represents the current input symbol, the right side shows the stack symbol being popped off the top off the stack followed by the stack symbol to be pushed onto the stack. Input symbols are read in a left-to-right direction. The ε symbol indicates either an epsilon move (i.e. transition without reading input symbol or a stack symbol) or that the PDA should not write to the stack for the current transition.

41 Operation of the PDA Let's examine the operation of this PDA a little more closely. First of all, since the start state is an accept state, an empty input string is accepted. Since there is an epsilon move out of state q1, we also transition to state q2. On this transition a $ symbol is pushed onto the stack when the PDA transitions to state q2. Each 0 symbol read from the input string when the PDA is in state q2 causes a 0 to be pushed onto the stack. When a 1 is read from the input string in state q2 one of the zero's (if stack not empty) is popped off the stack and the PDA transitions to state q3 without pushing anything back onto the stack. For each 1 read from the input while in state q3, a 0 is popped off the stack. As soon as the special symbol $ reaches the top of the stack the PDA executes an epsilon move to state q4. If the end of the string has been reached at this time it will be accepted (PDA in an accept state). If another input symbol is read when the PDA is in states q3 and q4 there is no valid transition and all control paths are terminated.

42 An Example For example, consider the operation of this PDA while scanning the string At the begining the non-deterministic nature of the PDA is realized as we transition from q1 to q2 on an epsilon move. Before we read the first symbol of the input string we have pushed a '$' onto the stack.

43 The first symbol in the input string is a '0' so the only valid transition is from q2 to q2. For this transition we do not pop a value from the stack but we push a '0' symbol onto the stack. This transition is repeated for the next two '0' symbols in the input string as shown below:

44 The next input symbol being read is a '1'. For this symbol the only valid transition is from q2 to q3. For this transition we pop a symbol '0' off the stack but we do not push a symbol onto the stack. Note that there is no epsilon move from q3 to q4 at this point since we are not seeing a '$' symbol at the top of the stack. For the next two input symbols (both of them '1's) we stay in state q3 and pop a '0' off the stack.

45 Since the '$' symbol is now at the top of the stack, there is a valid epsilon move from q3 to q4. This transition pops the '$' off the stack leaving it empty and placing the PDA in both states q3 and q4. If this were the end of the string we would accept it as a member of the language {0 n 1 n n>= 0 }, however there is another '1' symbol in the input string. Reading the final '1' symbol in the input string we find that there is no valid transition from either q3 or q4 on a '1' input symbol AND an empty stack. In this case we are left in no state, so we do not accept.

46 Theorem: Context-Free <=> Pushdown Automaton Theorem: A language is context free if and only if some pushdown automaton recognizes it. This theorem is typical of the if and only if theorems in that it requires a proof in two directions. Lemma: If a language is context free, then some pushdown automaton recognizes it. We will assume that A is a CFL. By definition A must have a corresponding CFG, G, that generates it. We need a procedure (an algorithm) for converting any CFG, G into an equivalent PDA, P. We can define such an algorithm: 1. Place the marker symbol $ and the start variable on the stack of the PDA P. 2. Repeat the following steps forever: a. If the top of stack is a variable symbol A, nondeterministically select one of the rules for A and substitute A by the string on the right-hand side of the rule. b. If the top of stack is a terminal symbol a, read the next symbol from the input and compare it to a. If they match then repeat. If they do not match, reject on this branch of the nondeterminism. c. If the top of stack is the symbol $, enter the accept state. Doing so accepts the input if it has all been read.

47 Lemma: If a pushdown automaton recognizes some language, then it is context free. Given a PDA, P we need to design a CFG, G that will generate all the strings accepted by P where P=(Q,Σ,Γ,δ,q0,{q accept }). The variables of G are {A pq p,q are in Q}. the start variable is Aqo,q accept. The rules of Γ are: 1. For each p,q,r,s in Q, t in Γ, and a,b in Σε, if δ(p,a,ε) contains (r,t) and δ(s,b,t) contains (q,ε) put the rule A pq -> aa rs b in G. 2. For each p,q,r in Q put the rule A pq -> A pr A rq in G. 3. Finally, for each p in Q put the rule A pp ->ε in G. We can prove that this construction works by demonstratring that A pq generates x if and only if (iff) x can bring P from p with empty stack to q with empty stack. Once again this proof is broken down into two separate cases corresponding to the two if..then conditions implied by the iff. Both of these proofs are by induction and can be found in a number of textbooks. We will assume that the proof is valid and, instead, spend our time using it to generate CFG's from PDA's and vice versa.

48 Designing Context-Free Grammars The design and construction of CFG's is a bit more involved than the creation of finite automata. We can use the following techniques to make this process simpler. Technique 1: Many CFG's can be constructed through the union of simpler CFG's. If your goal CFG can be broken down into a number of simpler CFG's you can combine them by creating a new rule S -> S1 S2... Sk, where the Si are the start variables for each of the simpler CFG's and S is the start variable for the goal CFG. Example: Create the grammar for the language L= { 0 n 1 n or 1 n 0 n n>=0}. S 1 -> 0S 1 1 ε is the grammar for { 0 n 1 n n>=0}. S 2 -> 1S 2 0 ε is the grammar for { 1 n 0 n n>=0}. so S -> S 1 S 2 S1 -> 0S 1 1 ε S 2 -> 1S 2 0 ε is the grammar for L.

49 Technique 2: When constructing a CFG for a language that is regular, you can first create a DFA for the language. You can convert any DFA into an equivalent CFG in the following way: 1. Make a variable R i for each state qi of the DFA. 2. Add the rule R i -> ar j to the CFG for each transition δ(q i,a) = q j in the DFA. 3. Add the rule R i -> ε if qi is an accept state of the DFA. 4. Make R 0 the start variable of the grammar, where q 0 is the start state of the DFA. Example: Create a grammar to recognize the language over {0,1} of all strings containing the substring First we create the DFA as shown below: Now, using these rules, we build the CFG: R 0 -> 0R 0 1R 1 R 1 -> 0R 0 1R 2 R 2 -> 0R 3 1R 2 R 3 -> 0R 0 1R 4 R 4 -> 0R 4 1R 4 ε

50 Technique 3: Some context-free languages are defined by the matching or comparing arbitrarily long substrings. In such cases the substrings are said to be linked. Consider the example of palindromes, P={ w w R aw is in P and a is in Σε), where w R is the reverse substring of w. The substrings w and w R are linked. In such situations we can construct a CFG using a rule of the form R -> urv, which simultaneously generates the linked substrings on either side of the variable R. Example: Create a CFG over {0,1} for the language {0 n 1 n n>=0} R 0 -> 0R1 ε.

51 Technique 4: In more practical CFG's such as grammars for computer languages or arithmetic expressions, the stirngs can contain recursively occurring structures. When generating such grammars you may place symbols that resolve to these recursive structures into the rules at the locations at which the recursive structures can appear. Example: Create a CFG that generates arithmetic expressions with the terminals a,b and c and the operations of addition (+) and multiplication (x). <EXPR> -> <EXPR> + <TERM> <TERM> <TERM> -> <TERM> x <FACTOR> <FACTOR> <FACTOR> -> ( <EXPR> ) a b c The parse trees above show how the grammar generates valid arithmetic expressions. The tree on the right includes a recursive component in which a <FACTOR> can generate another expression inside parentheses.

52 Theorem: The Pumping Lemma for Context-Free Languages. If A is a context-free language, then there is a number p (the pumping length) where, if s is any string in A of length at least p, then s may be divided into five pieces s = uvxyz satisfying the conditions: 1. For each i >= 0, uv i xy i z is an element of A, 2. vy > 0, and 3. vxy <= p.

53 Example: Use the pumping lemma for context-free languages to show that the language B={a n b n c n n >= 0} is not context free. Just as with the pumping lemma for regular expressions we will use proof by contradiction to show that our example language is not context-free. First assume that B is a context-free language, then let p be the pumping length for B. This p must exist by the pumping lemma. Now we select a string s = a p b p c p. Possible examples of s include abc aabbcc aaabbbccc aaaabbbbcccc We note that s is a member of B and that s >=p, as required by the pumping lemma. Now if we assume that s is context-free then we will be able to divide it into five sections s = uvxyz where either v or y is nonempty (condition 2). We can now consider one of two possibilities for the substrings v and y. Case 1: The substrings v and y each contain all of the same symbols. Whether v and y both contain the same symbols or different symbols at most there will be two of the three symbols in v and y. Therefore, pumping v and y will result in an unequal number of the symbols a, b and/or c. Case 2: One of the two substrings v and y (or both) contain more than one type of symbol. In this case pumping v and/or y creates symbols in the wrong order. One of these two cases must occur and since each results in a contradiction, so B is not context free.

54 Some Philosophical Questions Are natural languages context-free? Are context-free grammars useful for describing/understanding the grammar of a natural language? Not too long ago, the answer to the first question was clearly no, however, more recent studies have brought these earlier conclusions into question. In 1957, Noam Chomsky demonstrated that context-free grammars were inadequate to represent the grammar of natural languages (called transformational grammars). He showed that a context free grammar could represent only the 'base component' of natural language and that any natural language would need the addition of transformations. However, in 1982, Gazdar showed that a context free grammar could, in fact, encompass all the transformations suggested by Chomsky. Since that time it remains an open question if all natural languages can be represented by context free grammars or if CFG's are the best way to represent them even if it is possible. Pullum provides a good overview of the history of this development in formal linguistics.

55 References 1. Lecture 28. Push-Down Storage Automata and Context-Free Grammars - Ling 409 Lecture Notes, Partee, Lecture 28, Dec 8, Pullum, Geoffrey K The Great Eskimo Snow Vocabulary Hoax and Other Irreverent Essays on the Study of Language. Chicago: The University of Chicago Press. book review.

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

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

Introduction to Theory of Computing

Introduction to Theory of Computing CSCI 2670, Fall 2012 Introduction to Theory of Computing Department of Computer Science University of Georgia Athens, GA 30602 Instructor: Liming Cai www.cs.uga.edu/ cai 0 Lecture Note 3 Context-Free Languages

More information

PUSHDOWN AUTOMATA (PDA)

PUSHDOWN AUTOMATA (PDA) PUSHDOWN AUTOMATA (PDA) FINITE STATE CONTROL INPUT STACK (Last in, first out) input pop push ε,ε $ 0,ε 0 1,0 ε ε,$ ε 1,0 ε PDA that recognizes L = { 0 n 1 n n 0 } Definition: A (non-deterministic) PDA

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

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

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 2 Define push down automata Trace the computation of a push down automaton Design

More information

October 6, Equivalence of Pushdown Automata with Context-Free Gramm

October 6, Equivalence of Pushdown Automata with Context-Free Gramm Equivalence of Pushdown Automata with Context-Free Grammar October 6, 2013 Motivation Motivation CFG and PDA are equivalent in power: a CFG generates a context-free language and a PDA recognizes a context-free

More information

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu Part 4 out of 5 ETH Zürich (D-ITET) October, 12 2017 Last week, we showed the equivalence of DFA, NFA and REX

More information

SCHEME FOR INTERNAL ASSESSMENT TEST 3

SCHEME FOR INTERNAL ASSESSMENT TEST 3 SCHEME FOR INTERNAL ASSESSMENT TEST 3 Max Marks: 40 Subject& Code: Automata Theory & Computability (15CS54) Sem: V ISE (A & B) Note: Answer any FIVE full questions, choosing one full question from each

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

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

Pushdown Automata. We have seen examples of context-free languages that are not regular, and hence can not be recognized by finite automata.

Pushdown Automata. We have seen examples of context-free languages that are not regular, and hence can not be recognized by finite automata. Pushdown Automata We have seen examples of context-free languages that are not regular, and hence can not be recognized by finite automata. Next we consider a more powerful computation model, called a

More information

Theory of Computation (IV) Yijia Chen Fudan University

Theory of Computation (IV) Yijia Chen Fudan University Theory of Computation (IV) Yijia Chen Fudan University Review language regular context-free machine DFA/ NFA PDA syntax regular expression context-free grammar Pushdown automata Definition A pushdown automaton

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

(pp ) PDAs and CFGs (Sec. 2.2)

(pp ) PDAs and CFGs (Sec. 2.2) (pp. 117-124) PDAs and CFGs (Sec. 2.2) A language is context free iff all strings in L can be generated by some context free grammar Theorem 2.20: L is Context Free iff a PDA accepts it I.e. if L is context

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

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

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

CPS 220 Theory of Computation

CPS 220 Theory of Computation CPS 22 Theory of Computation Review - Regular Languages RL - a simple class of languages that can be represented in two ways: 1 Machine description: Finite Automata are machines with a finite number of

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2017 http://cseweb.ucsd.edu/classes/sp17/cse105-ab/ Review of CFG, CFL, ambiguity What is the language generated by the CFG below: G 1 = ({S,T 1,T 2 }, {0,1,2}, { S

More information

Context-Free Languages (Pre Lecture)

Context-Free Languages (Pre Lecture) Context-Free Languages (Pre Lecture) Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2017 Dantam (Mines CSCI-561) Context-Free Languages (Pre Lecture) Fall 2017 1 / 34 Outline Pumping Lemma

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

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

CPS 220 Theory of Computation Pushdown Automata (PDA)

CPS 220 Theory of Computation Pushdown Automata (PDA) CPS 220 Theory of Computation Pushdown Automata (PDA) Nondeterministic Finite Automaton with some extra memory Memory is called the stack, accessed in a very restricted way: in a First-In First-Out fashion

More information

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA) Deterministic Finite Automata Non deterministic finite automata Automata we ve been dealing with have been deterministic For every state and every alphabet symbol there is exactly one move that the machine

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

Computational Models: Class 5

Computational Models: Class 5 Computational Models: Class 5 Benny Chor School of Computer Science Tel Aviv University March 27, 2019 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation CISC 4090 Theory of Computation Context-Free Languages and Push Down Automata Professor Daniel Leeds dleeds@fordham.edu JMH 332 Languages: Regular and Beyond Regular: a b c b d e a Not-regular: c n bd

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

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

2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a

2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a . Solution E T F a E E + T T + T F + T a + T a + F a + a E E + T E + T + T T + T + T F + T + T a + T + T a + F + T a + a + T a + a + F a + a + a E T F ( E) ( T ) ( F) (( E)) (( T )) (( F)) (( a)) . Solution

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

Pushdown Automata (2015/11/23)

Pushdown Automata (2015/11/23) Chapter 6 Pushdown Automata (2015/11/23) Sagrada Familia, Barcelona, Spain Outline 6.0 Introduction 6.1 Definition of PDA 6.2 The Language of a PDA 6.3 Euivalence of PDA s and CFG s 6.4 Deterministic PDA

More information

CSE 211. Pushdown Automata. CSE 211 (Theory of Computation) Atif Hasan Rahman

CSE 211. Pushdown Automata. CSE 211 (Theory of Computation) Atif Hasan Rahman CSE 211 Pushdown Automata CSE 211 (Theory of Computation) Atif Hasan Rahman Lecturer Department of Computer Science and Engineering Bangladesh University of Engineering & Technology Adapted from slides

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

Theory of Computation (I) Yijia Chen Fudan University

Theory of Computation (I) Yijia Chen Fudan University Theory of Computation (I) Yijia Chen Fudan University Instructor Yijia Chen Homepage: http://basics.sjtu.edu.cn/~chen Email: yijiachen@fudan.edu.cn Textbook Introduction to the Theory of Computation Michael

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

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Fall 28 Alexis Maciel Department of Computer Science Clarkson University Copyright c 28 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

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

Pushdown Automata. Chapter 12

Pushdown Automata. Chapter 12 Pushdown Automata Chapter 12 Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely what it needs is a stack, which gives it an unlimited

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

Context-Free Languages

Context-Free Languages CS:4330 Theory of Computation Spring 2018 Context-Free Languages Pushdown Automata Haniel Barbosa Readings for this lecture Chapter 2 of [Sipser 1996], 3rd edition. Section 2.2. Finite automaton 1 / 13

More information

Computer Sciences Department

Computer Sciences Department 1 Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER 3 objectives Finite automaton Infinite automaton Formal definition State diagram Regular and Non-regular

More information

Cliff s notes for equivalence of CFLs and L(PDAs) LisaCFL L = L(M) for some PDA M L=L(M)forsomePDAM L = L(G) for some CFG G

Cliff s notes for equivalence of CFLs and L(PDAs) LisaCFL L = L(M) for some PDA M L=L(M)forsomePDAM L = L(G) for some CFG G What s on our plate today? Cliff s notes for equivalence of CFLs and L(PDAs) LisaCFL L = L(M) for some PDA M L=L(M)forsomePDAM L = L(G) for some CFG G Pumping Lemma (one last time) Statement of Pumping

More information

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions? Before We Start The Pumping Lemma Any questions? The Lemma & Decision/ Languages Future Exam Question What is a language? What is a class of languages? Context Free Languages Context Free Languages(CFL)

More information

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Spring 27 Alexis Maciel Department of Computer Science Clarkson University Copyright c 27 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

UNIT-VI PUSHDOWN AUTOMATA

UNIT-VI PUSHDOWN AUTOMATA Syllabus R09 Regulation UNIT-VI PUSHDOWN AUTOMATA The context free languages have a type of automaton that defined them. This automaton, called a pushdown automaton, is an extension of the nondeterministic

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 3.3, 4.1 State and use the Church-Turing thesis. Give examples of decidable problems.

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

(pp ) PDAs and CFGs (Sec. 2.2)

(pp ) PDAs and CFGs (Sec. 2.2) (pp. 117-124) PDAs and CFGs (Sec. 2.2) A language is context free iff all strings in L can be generated by some context free grammar Theorem 2.20: L is Context Free iff a PDA accepts it I.e. if L is context

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

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

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) Definition 1 (Alphabet) A alphabet is a finite set of objects called symbols. Definition 2 (String)

More information

Pushdown Automata: Introduction (2)

Pushdown Automata: Introduction (2) Pushdown Automata: Introduction Pushdown automaton (PDA) M = (K, Σ, Γ,, s, A) where K is a set of states Σ is an input alphabet Γ is a set of stack symbols s K is the start state A K is a set of accepting

More information

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is Abstraction of Problems Data: abstracted as a word in a given alphabet. Σ: alphabet, a finite, non-empty set of symbols. Σ : all the words of finite length built up using Σ: Conditions: abstracted as a

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

Theory of Languages and Automata

Theory of Languages and Automata Theory of Languages and Automata Chapter 1- Regular Languages & Finite State Automaton Sharif University of Technology Finite State Automaton We begin with the simplest model of Computation, called finite

More information

Theory of Computation Turing Machine and Pushdown Automata

Theory of Computation Turing Machine and Pushdown Automata Theory of Computation Turing Machine and Pushdown Automata 1. What is a Turing Machine? A Turing Machine is an accepting device which accepts the languages (recursively enumerable set) generated by type

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

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

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

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

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

CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)

CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL) CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL) Objectives Introduce Pumping Lemma for CFL Apply Pumping Lemma to show that some languages are non-cfl Pumping Lemma

More information

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 10 : Context-Free Grammars

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 10 : Context-Free Grammars COMP-330 Theory of Computation Fall 2017 -- Prof. Claude Crépeau Lec. 10 : Context-Free Grammars COMP 330 Fall 2017: Lectures Schedule 1-2. Introduction 1.5. Some basic mathematics 2-3. Deterministic finite

More information

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

September 11, Second Part of Regular Expressions Equivalence with Finite Aut Second Part of Regular Expressions Equivalence with Finite Automata September 11, 2013 Lemma 1.60 If a language is regular then it is specified by a regular expression Proof idea: For a given regular language

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

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation CISC 4090 Theory of Computation Context-Free Languages and Push Down Automata Professor Daniel Leeds dleeds@fordham.edu JMH 332 Languages: Regular and Beyond Regular: Captured by Regular Operations a b

More information

MA/CSSE 474 Theory of Computation

MA/CSSE 474 Theory of Computation MA/CSSE 474 Theory of Computation Bottom-up parsing Pumping Theorem for CFLs Recap: Going One Way Lemma: Each context-free language is accepted by some PDA. Proof (by construction): The idea: Let the stack

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

Context-Free and Noncontext-Free Languages

Context-Free and Noncontext-Free Languages Examples: Context-Free and Noncontext-Free Languages a*b* is regular. A n B n = {a n b n : n 0} is context-free but not regular. A n B n C n = {a n b n c n : n 0} is not context-free The Regular and the

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

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

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 2 January 5, 2018 January 5, 2018 CS21 Lecture 2 1 Outline Finite Automata Nondeterministic Finite Automata Closure under regular operations NFA, FA equivalence

More information

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES Contents i SYLLABUS UNIT - I CHAPTER - 1 : AUT UTOMA OMATA Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 2 : FINITE AUT UTOMA OMATA An Informal Picture of Finite Automata,

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 2 Design a PDA and a CFG for a given language Give informal description for a PDA,

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

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

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

MTH401A Theory of Computation. Lecture 17

MTH401A Theory of Computation. Lecture 17 MTH401A Theory of Computation Lecture 17 Chomsky Normal Form for CFG s Chomsky Normal Form for CFG s For every context free language, L, the language L {ε} has a grammar in which every production looks

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

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

Pumping Lemma for CFLs

Pumping Lemma for CFLs Pumping Lemma for CFLs v y s Here we go again! Intuition: If L is CF, then some CFG G produces strings in L If some string in L is very long, it will have a very tall parse tree If a parse tree is taller

More information

Accept or reject. Stack

Accept or reject. Stack Pushdown Automata CS351 Just as a DFA was equivalent to a regular expression, we have a similar analogy for the context-free grammar. A pushdown automata (PDA) is equivalent in power to contextfree grammars.

More information

Pushdown Automata (Pre Lecture)

Pushdown Automata (Pre Lecture) Pushdown Automata (Pre Lecture) Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2017 Dantam (Mines CSCI-561) Pushdown Automata (Pre Lecture) Fall 2017 1 / 41 Outline Pushdown Automata Pushdown

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

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

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

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

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

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

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

CpSc 421 Final Exam December 15, 2006

CpSc 421 Final Exam December 15, 2006 CpSc 421 Final Exam December 15, 2006 Do problem zero and six of problems 1 through 9. If you write down solutions for more that six problems, clearly indicate those that you want graded. Note that problems

More information

Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules).

Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules). Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules). 1a) G = ({R, S, T}, {0,1}, P, S) where P is: S R0R R R0R1R R1R0R T T 0T ε (S generates the first 0. R generates

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

CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA)

CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA) CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA) Objectives Introduce the Pumping Lemma for CFL Show that some languages are non- CFL Discuss the DPDA, which

More information

CPS 220 Theory of Computation REGULAR LANGUAGES

CPS 220 Theory of Computation REGULAR LANGUAGES CPS 22 Theory of Computation REGULAR LANGUAGES Introduction Model (def) a miniature representation of a thing; sometimes a facsimile Iraq village mockup for the Marines Scientific modelling - the process

More information

CS243, Logic and Computation Nondeterministic finite automata

CS243, Logic and Computation Nondeterministic finite automata CS243, Prof. Alvarez NONDETERMINISTIC FINITE AUTOMATA (NFA) Prof. Sergio A. Alvarez http://www.cs.bc.edu/ alvarez/ Maloney Hall, room 569 alvarez@cs.bc.edu Computer Science Department voice: (67) 552-4333

More information

Theory of Computation

Theory of Computation Fall 2002 (YEN) Theory of Computation Midterm Exam. Name:... I.D.#:... 1. (30 pts) True or false (mark O for true ; X for false ). (Score=Max{0, Right- 1 2 Wrong}.) (1) X... If L 1 is regular and L 2 L

More information