Computational Models Lecture 5

Size: px
Start display at page:

Download "Computational Models Lecture 5"

Transcription

1 Computational Models Lecture 5 Chomsky Normal Form of CFGs Closure Properties of CFLs Push-down Automata (PDAs) Equivalence of PDAs and CFLs Algorithmic Aspects of PDAs and CFLs DFAs and PDAs: Perspectives Sipser s book, 2.1, 2.2 & 2.3 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1

2 Chomsky Normal Form A simplified, canonical form of context free grammars. Elegant by itself, useful (but not crucial) in proving equivalence theorem. Can also be used to slightly simplify proof of pumping lemma. All rules are of the form (1)A (2)A BC (3)S ε where S is the start symbol, A, B and C are any variable, except B and C not the start symbol, and A can be the start symbol. a Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 2

3 Theorem: Any context-free language is generated by a context-free grammar in Chomsky normal form. Basic idea: Add new start symbol S 0. Eliminate all ε rules of the form A ε. Eliminate all unit rules of the form A B. At each step, patch up rules so that grammar generates the same language. Convert remaining long rules to proper form. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 3

4 Proof Add new start symbol S 0 and rule S 0 S. Guarantees that new start symbol does not appear on right-hand-side of a rule. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 4

5 Proof Eliminating ε rules. Repeat: remove some A ε. for each R uav, add rule R uv. and so on: for R uavaw add R uvaw, R uavw, and R uvw. for R A add R ε, except if R ε has already been removed. until all ε-rules not involving the original start variable have been removed. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 5

6 Proof Eliminate unit rules. Repeat: remove some A B. for each B u, add rule A u, unless this is previously removed unit rule. (u is a string of variables and terminals.) until all unit rules have been removed. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 6

7 Proof Finally, convert long rules. To replace each A u 1 u 2...u k (for k 3), introduce new non-terminals N 1,N 2,...,N k 1 and rules A u 1 N 1 N 1 u 2 N 2. N k 3 u k 2 N k 2 N k 2 u k 1 u k Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 7

8 Conversion Example Initial Grammar: S A B ASA ab B S b ε (1) Add new start state: S 0 S S ASA ab A B S B b ε Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 8

9 Conversion Example (2) S 0 S S ASA ab A B S B b ε (2) Remove ε-rule B ε: S 0 S S ASA ab a A B S ε B b ε Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 9

10 Conversion Example (3) S 0 S S ASA ab a A B S ε B b (3) Remove ε-rule A ε: S 0 S S ASA ab a AS SA S A B S ε B b Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 10

11 Conversion Example (4) S 0 S S ASA ab a AS SA S A B S B b (4) Remove unit rule S S S 0 S S ASA ab a AS SA S A B S B b Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 11

12 Conversion Example (5) S 0 S S ASA ab a AS SA A B S B b (5) Remove unit rule S 0 S: S 0 S ASA ab a AS SA S ASA ab a AS SA A B S B b Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 12

13 Conversion Example (6) S 0 ASA ab a AS SA S ASA ab a AS SA A B S B b (6) Remove unit rule A B: S 0 ASA ab a AS SA S ASA ab a AS SA A B S b B b Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 13

14 Conversion Example (7) S 0 ASA ab a AS SA S ASA ab a AS SA A S b B b Remove unit rule A S: S 0 ASA ab a AS SA S ASA ab a AS SA A S b ASA ab a AS SA B b Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 14

15 Conversion Example (8) S 0 ASA ab a AS SA S ASA ab a AS SA A b ASA ab a AS SA B b (8) Final simplification treat long rules: S 0 AA 1 UB a SA AS S AA 1 UB a SA AS A b AA 1 UB a SA AS A 1 SA U a B b Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 15

16 Why is CNF Important? Theorem: If G is a CFG in Chomsky normal form, then for any w L(G), such that w = n, there is a derivation of size 2n 1 of w in G. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 16

17 CFL Closure Properties We saw that Context-Free Languages are closed under union, concatenation, and star. It is time we resolve closure with respect to complementation and intersection. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 17

18 CFL Closure Properties Are the context free languages closed under intersection? Suggested approach: Can we intersect two context free languages to get 0 n 1 n 2 n? Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 18

19 CFL Closure Properties Are the context free languages closed under intersection? S 1 A 1 B 1 S 2 A 2 B 2 A 1 0A A 2 0A 2 ε B 1 2B 1 ε B 2 1B L 1 = 0 n 1 n 2 L 2 = 0 1 n 2 n L 1 L 2 = 0 n 1 n 2 n L 1 is a context free language, L 2 is a context free language, but L 1 L 2 is not! Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 19

20 CFL Closure Properties The fact that CFLs are not closed under intersection but are closed under union implies they are not closed under complementation, as L 1 L 2 = L 1 L 2. Example: L = {ww w {0, 1} }. For any y L, either y s length is odd. y s length is even, 2l, and there is an i 1 such that y i y l+i. It can be shown that L is context-free. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 20

21 CFL Closure Properties Context free languages are closed under intersection with a regular language. That is, if L 1 is a context free language, and L 2 is regular, L 1 L 2 is context-free. Details - in the tutorial... Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 21

22 CFL Closure Properties: Example Is L = {(0 1 2) : # of 0 s = # of 1 s = # of 2 s } context free? Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 22

23 CFL Closure Properties L {(0 1 2) : # 0 s = # 1 s = # 2 s } Is L context free? L ={0 n 1 n 2 n : n > 0} which is not context free. Context free languages intersected with a regular languages are context free is regular. So L is not a context free language! Could this be proven directly, using pumping? Probably, but we prefer to work less (provided the proofs are correct :-). Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 23

24 String Generators and String Acceptors Regular expressions are string generators they tell us how to generate all strings in a language L Finite Automata (DFA, NFA) are string acceptors they tell us if a specific string w is in L CFGs are string generators Are there string acceptors for Context-Free languages? YES! Push-down automata Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 24

25 A Finite Automaton Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 25

26 A PushDown Automaton Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 26

27 A PushDown Automaton We add a memory device with restricted access: A stack (last in, first out; push/pop). Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 27

28 An Example Recall that the language {0 n 1 n n 0} is not regular. Consider the following PDA: Read input symbols, one by one For each 0, push it on the stack As soon as a 1 is seen, pop a 0 for each 1 read Accept if stack is empty when last symbol read Reject if Stack is non-empty when end of input symbol read Stack is empty but input symbol(s) still exist, 0 is read after 1. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 28

29 Comparing PDA and Finite Automata PDA may be deterministic or non-deterministic. Unlike finite automata, non-determinism adds power: There are some languages accepted only by non-deterministic PDAs. Transition function δ looks different than DFA or NFA cases, reflecting stack functionality. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 29

30 The Transition Function Denote input alphabet by Σ and stack alphabet by Γ. the domain of the transition function δ is current state: Q next input, if any: Σ ε = Σ {ε} stack symbol popped, if any: Γ ε = Γ {ε} and its range is new state: Q stack symbol pushed, if any: Γ ε non-determinism: P(of two components above) δ : Q Σ ε Γ ε P(Q Γ ε ) Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 30

31 Formal Definitions A pushdown automaton (PDA) is a 6-tuple (Q, Σ, Γ,δ,q 0,F), where Q is a finite set called the states, Σ is a finite set called the input alphabet, Γ is a finite set called the stack alphabet, δ : Q Σ ε Γ ε P(Q Γ ε ) is the transition function, q 0 Q is the start state, and F Q is the set of accept states. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 31

32 Meaning of ε-transitions δ(q,ε,a) = {(q 1,b), (q 2,c)} - don t read input δ(q,b,ε) = {(q 1,b), (q 2,c)} - don t pop δ(q,b,a) = {(q 1,ε), (q 2,c)} - don t push Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 32

33 How to define acceptance of a PDA? Two options: Accept when reaching a final state. Accept when the stack is empty. These two notions of acceptance are equivalent in the sense that for every PDA accepting L by a final state, there is a PDA accepting L by empty stack, and vice versa. To show this equivalence, it will be convenient to assume that at the beginning of the run the stack of a PDA contains a special beginning marker X. So we extend the definition of a PDA from M = (Q, Σ, Γ,δ,q 0,F) to M = (Q, Σ, Γ,δ,q 0,F,X), where X Γ is a marker on top of stack of M at the beginning of the run. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 33

34 Formal Definition - Acceptance by Final State A PDA M = (Q, Σ, Γ,δ,q 0,F,X) accepts input w if w = w 1 w 2...w m, where each w i Σ ε, and sequences of r 0,r 1,...,r m Q and strings s 0,s 1,...,s m Γ exist that satisfy the following conditions: r 0 = q 0 and s 0 = X (M starts in start state with X on top of stack). For i = 0,...,m 1, we have (r i+1,b) δ(r i,w i+1,a), where s i = at and s i+1 = bt for some a,b Γ ε and t Γ (M moves properly according to the state, stack and next input symbol). r m F (Acceptance by final state). The language L(M) is the set of all words accepted by M by final state. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 34

35 Formal Definition - Acceptance by Empty Stack A PDA M = (Q, Σ, Γ,δ,q 0,F,X) accepts input w if w = w 1 w 2...w m, where each w i Σ ε, and sequences of r 0,r 1,...,r m Q and strings s 0,s 1,...,s m Γ exist that satisfy the following conditions: r 0 = q 0 and s 0 = X (M starts in start state with X on top of stack). For i = 0,...,m 1, we have (r i+1,b) δ(r i,w i+1,a), where s i = at and s i+1 = bt for some a,b Γ ε and t Γ (M moves properly according to the state, stack and next input symbol). s m = ε (Acceptance by empty stack). The language E(M) is the set of all words accepted by M by empty stack. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 35

36 Equivalence of Acceptance - 1 If a language L is L(M 2 ) for some PDA M 2, then L is E(M 1 ) for some PDA M 1. Proof Idea: M 1 should simulate M 2, with the option for M 1 to erase its stack whenever M 2 enters a final state. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 36

37 Equivalence of Acceptance - The Proof If a language L is L(M 2 ) for some PDA M 2, then L is E(M 1 ) for some PDA M 1. Let M 2 = (Q, Σ, Γ,δ,q 0,F,Z 0 ). Construct M 1 as follows: M 1 = (Q {q e,q 0}, Σ, Γ {X 0 },δ,q 0,,X 0 ) δ (q 0,ǫ,ǫ) = {(q 0,Z 0 )}. For all q Q, a Σ ε and b Γ ε, δ (q,a,b) = δ(q,a,b). For all q F,(q e,ε) δ (q,ε,ε). For all a Γ ε {X 0 }, (q e,ε) δ (q e,ε,a). Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 37

38 Equivalence of Acceptance - 2 If a language L is E(M 1 ) for some PDA M 1, then L is L(M 2 ) for some PDA M 2. Proof Idea: M 2 should simulate M 1, and detect when M 1 empties its stack. M 2 enters a final state when and only when this occurs. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 38

39 Equivalence of Acceptance - Proof If a language L is E(M 1 ) for some PDA M 1, then L is L(M 2 ) for some PDA M 2. Let M 1 = (Q, Σ, Γ,δ,q 0,,Z 0 ). Construct M 2 as follows: M 2 = (Q {q 0,q f }, Σ, Γ {X 0 },δ,q 0, {q f },X 0 ) δ (q 0,ε,ε) = {(q 0,Z 0 )}. For all q Q, a Σ ε and b Γ ε, δ (q,a,b) = δ(q,a,b). For all q Q, (q f,ε) δ (q,ε,x 0 ). From now on we will use the more standard definition of acceptance by final state. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 39

40 Notation Transition a,b c means if read a from input and pop b from stack then push c onto stack Meaning of ε transitions: if a = ε, don t read inputs if b = ε, don t pop any symbols if c = ε, don t push any symbols Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 40

41 Example The PDA accepts {0 n 1 n n 1}. Does it also accept the empty string? Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 41

42 Another Example A PDA that accepts { } a i b j c k $ i,j,k > 0 and i = j or i = k Informally: read and push a s either pop and match with b s or else ignore b s. Pop and match with c s a non-deterministic choice! Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 42

43 Another Example (cont.) This PDA accepts { } a i b j c k $ i,j,k > 0 and i = j or i = k Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 43

44 Non-determinism Adds Power to PDAs Recall that all regular languages are accepted by deterministic finite automata. For finite automata, non-determinism does not add power. But there are context free languages that are accepted only by non-deterministic push down automata. Examples: { a i b j c k i,j,k 0 and i = j or i = k } { ww R w {0, 1} } Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 44

45 PDA Languages The Push-Down Automata Languages, L PDA, is the set of all languages that can be described by some PDA: L PDA = {L : PDA M L[M] = L} We already know L PDA L DFA, since every DFA is just a PDA that ignores the stack. L CFG L PDA? L PDA L CFG? Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 45

46 CFL/PDA Equivalence Theorem Theorem: A language is context free if and only if some pushdown automaton accepts it. We will present a high level view of the proof (not all details). Full details in pp of Sipser s book. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 46

47 If Part Theorem: If a language is context free, then some pushdown automaton accepts it. Let A be a context-free language. By definition, A has a context-free grammar G generating it. On input w, the PDA P should figure out if there is a derivation of w using G. Question: How does P figure out which substitution to make? Answer: It guesses. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 47

48 CFL Implies PDA (cont.) Where do we keep the intermediate string? can t put it all on the stack only strings whose first letter is a variable are kept on stack Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 48

49 CFL Implies PDA Informally, on input string w Σ : P pushes start variable S on stack keeps making substitutions when popping a terminal, P checks equality with current input string rejects if not equal when popping a variable, P pushes to top of stack a right hand side of some rule corresponding to variable (zero, one, or two symbols). if EOI reached when stack is empty, accept. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 49

50 CFL Implies PDA (cont.) Informal description of P : Place the marker symbol $ and the start variable on stack Repeat the following steps: if top of stack is variable A, non-deterministically select rule and substitute. if top of stack is terminal a, read next input symbol and compare. If they differ, reject. if top of stack is $, enter accept state. (Namely accepts only if input has all been read and stack is empty!). Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 50

51 CFL Implies PDA (cont.) Need shorthand to push strings of length > 1 onto stack. For example, suppose S ABC is a derivation of the CFG. And suppose that we would like the PDA to go from state q to state r, on input a popping S and pushing the string ABC to stack: δ(q,a,s) = {(r,abc),...} This cannot be done in one move, so we need to add intermediate states q 1 and q 2, so that: δ(q,a,s) = {(q 1,C),..., } δ(q 1,ε,ε) = {(q 1,B)} δ(q 1,ε,ε) = {(r,a),..., } Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 51

52 CFL Implies PDA (cont.) States of P are start state q s accept state q a loop state q l q e states, needed for shorthand of right hand sides of rules Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 52

53 Transition Function Initialize stack δ(q s,ε,ε) = {q l,s$} Top of stack is variable (shorthand for a number of transitions) δ(q l,ε,a) = {(q l,w) where A w is a rule } Top of stack is terminal δ(q l,a,a) = {(q l,ε)} End of Stack δ(q l,ε, $) = {(q a,ε)} Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 53

54 Example S T atb b Ta ε Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 54

55 Only If Part Theorem: If a PDA accepts a language, L, then L is context-free. For each pair of states p and q in P, we will have a variable A pq in the grammar G. This variable, A pq, generates all strings that take P from p with an empty stack to q with empty stack. Same string also takes p with any stack to q with same stack! Start variable is A q0,q a (assuming a single accept state q a ). Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 55

56 PDA Implies CFL To make things easier, we slightly modify P Has single accept state q a. It empties stack before accepting. Each transition either pushes a symbol on stack, or pops a symbol from stack, but not both. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 56

57 PDA Implies CFL (2) Modify P to make things easier single accept state q a ε,ε ε,ε ε ε empties stack before accepting each transition pushes or pops, but not both. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 57

58 PDA Implies CFL (3) Modify P to make things easier single accept state q a empties stack before accepting ε,ε ε ε,ε ε ε,ε ε ε,a ε ε,ε ε ε,ε ε Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 58

59 PDA Implies CFL (4) Modify P to make things easier single accept state q a empties stack before accepting transition either pushes or pops, but not both a,b c a,b ε c ε,ε Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 59

60 Proof Idea Suppose string x takes P from p with empty stack to q with empty stack. First move that touches the stack must be a push, last must be a pop. In between, two possibilities: Stack is empty only at start and finish, but not in middle. Stack was also empty at some point in between. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 60

61 Proof Idea (2) Suppose string x takes P from p with empty stack to q with empty stack. First move that touches the stack must be a push, last must be a pop. In between, two possibilities: Stack is empty only at start and finish, but not in middle. Simulate by: A pq aa rs b, where a,b are first and last symbols in x (shorter x will be taken care of too), r follows p, and s precedes q. Stack was also empty at some point in between. Simulate by: A pq A pr A rq, r is intermediate state where P has empty stack. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 61

62 Details of Simulating Grammar Given PDA P = (Q, Σ, Γ,δ,q 0, {q a }), construct grammar G. Variables are {A pq p,q Q}. Start variable is A q0 q a. Rules: For p,q,r,s Q, t Γ, and a,b Σ, if (r,t) δ(p,a,ε) and (q,ε) δ(s,b,t), add rule A pq aa rs b. for every p,q,r Q, add rule A pq A pr A rq. for each p Q, add rule A pp ε. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 62

63 Overall Structure Should now prove Claim: A pq generates x if and only if x brings P from p with empty stack to q with empty stack. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 63

64 Only If Part Theorem: If a PDA accepts a language, L, then L is context-free. Proof: After constructing the grammar G, should prove it generates exactly the same language accepted by the PDA. This is done by induction on the length of any computation of P on any input string x. The induction argument is a bit lengthy and tedious, and we ll skip it. Diehards are welcome to consult pp in Sipser s book. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 64

65 Algorithmic Questions for NFAs Q.: Given an NFA, N, and a string s, is s L(N)? Answer: Construct the DFA equivalent to N and run it on w. Q.: Is L(N) =? Answer: This is a reachability question in graphs: Is there a path in the states graph of N from the start state to some accepting state. There are simple, efficient algorithms for this task. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 65

66 More Algorithmic Questions for NFAs Q.: Is L(N) = Σ? Answer: Check if L(N) =. Q.: Given N 1 and N 2, is L(N 1 ) L(N 2 )? Answer: Check if L(N 2 ) L(N 1 ) =. Q.: Given N 1 and N 2, is L(N 1 ) = L(N 2 )? Answer: Check if L(N 1 ) L(N 2 ) and L(N 2 ) L(N 1 ). Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 66

67 Algorithmic Questions Regarding DFAs Given a regular expression, R, find the smallest DFA (minimum number of states) that accepts L(R). Initial Idea: Use the algorithm described in class to transform R into an NFA. Then transform this NFA into a DFA, M. That s very nice, but how do we know M is minimal? It need not be! Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 67

68 Algorithmic Questions for DFAs (2) Given a regular expression, R, find the smallest DFA that accepts L(R) (minimum number of states). We can enumerate all DFAs that are strictly smaller than M. For each such M i, test if L(M i ) = L(M) (we saw an algorithm for this). Take the smallest such M i. Algorithm is very inefficient. More efficient algorithm is known, using the Myhill-Nerode theorem. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 68

69 Algorithmic Questions Regarding CFGs Given a CFG, G, and a string w, does G generate w? Initial Idea: Design an algorithm that tries all derivations. Problem: If G does not generate w, we ll never stop. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 69

70 Algorithmic Questions for CFGs (2) Recall: If G is in Chomsky normal form, w = n, and w is generated by G, then w has a derivation of length 2n 1 or less. Modified algorithm s idea: First, convert G to Chomsky normal form. Now need only consider a finite number of derivations those of length 2n 1 or less. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 70

71 Algorithmic Questions for CFGs (3) Theorem: There is an algorithm (that halts on every inputs) A, that on inputs G and w, decides if G generates w. On input G,w, where G is a grammar and w a string, 1. Convert G to Chomsky normal form. 2. List all derivations with 2n 1 steps, were n = w. 3. If any generates w, accept, otherwise reject. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 71

72 Emptiness of CFGs Given a CFG, G, is L(G) =? In other words, is there any string w, such that G generates w? Theorem: There is an algorithm that solves this problem (and always halts). Possible approaches for a proof: Bad Idea: We know how to test whether w L(G) for any string w, so just try it for each w. (criticize this...) Better Idea: Can the start variable generate a string of terminals? Even Better Idea: Can a particular variable generate a string of terminals? Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 72

73 CFG Emptiness (2) Algorithm: On input G (a CFG), 1. Mark all terminal symbols in G. 2. Repeat until no new variables become marked. 3. Mark any A where A U 1 U 2...U k and all U i have already been marked. 4. If start symbol marked, accept, else reject. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 73

74 CFGs Fullness Given a CFG, G, is L(G) = Σ? We just saw an algorithm to determine, given a CFG, G, if L(G) = L(G) = Σ iff L(G) =. Why not modify the algorithm so it determines emptiness of the complement? Unfortunately, CFGs are not closed under complement. Fact: There is no algorithm to solve this problem. We are not prepared to prove this remarkable fact (yet). Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 74

75 When Are Two CFGs equivalent? Given two CFGs, G,H, is L(G) = L(H)? Hey, we did this already for equivalence of DFAs! We constructed C from A and B: ( ) L(C) = L(A) L(B) and tested whether L(C) is empty. ( ) L(A) L(B). Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 75

76 When Are Two CFGs equivalent? This approach was fine for DFAs, but not for CFLs! The class of context-free languages is not closed under complementation or intersection. Fact: There is no algorithm to solve this problem. We are not prepared to prove this remarkable fact (yet). Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 76

77 A Short Summary Regular Languages Finite Automata. Context Free Languages Push Down Automata. Closure properties of regular languages and of CFLs. Most algorithmic problems for finite automata are solvable. Some algorithmic problems for finite automata are not solvable. Pumping lemmata for both classes of languages. There are additional languages out there. Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 77

78 The View Over The Horizon enumerable decidable context free regular Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 78

Automata and Computability. Solutions to Exercises

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

More information

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch 6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010 Class 4 Nancy Lynch Today Two more models of computation: Nondeterministic Finite Automata (NFAs)

More information

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March

More information

Finite Automata. Reading: Chapter 2

Finite Automata. Reading: Chapter 2 Finite Automata Reading: Chapter 2 1 Finite Automaton (FA) Informally, a state diagram that comprehensively captures all possible states and transitions that a machine can take while responding to a stream

More information

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

CSE 135: Introduction to Theory of Computation Decidability and Recognizability CSE 135: Introduction to Theory of Computation Decidability and Recognizability Sungjin Im University of California, Merced 04-28, 30-2014 High-Level Descriptions of Computation Instead of giving a Turing

More information

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, 2014. School of Informatics University of Edinburgh als@inf.ed.ac.

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, 2014. School of Informatics University of Edinburgh als@inf.ed.ac. Pushdown automata Informatics 2A: Lecture 9 Alex Simpson School of Informatics University of Edinburgh als@inf.ed.ac.uk 3 October, 2014 1 / 17 Recap of lecture 8 Context-free languages are defined by context-free

More information

Automata and Formal Languages

Automata and Formal Languages Automata and Formal Languages Winter 2009-2010 Yacov Hel-Or 1 What this course is all about This course is about mathematical models of computation We ll study different machine models (finite automata,

More information

Computational Models Lecture 8, Spring 2009

Computational Models Lecture 8, Spring 2009 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown Univ. p. 1 Computational Models Lecture 8, Spring 2009 Encoding of TMs Universal Turing Machines The Halting/Acceptance

More information

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile Pushdown Automata In the last section we found that restricting the computational power of computing devices produced solvable decision problems for the class of sets accepted by finite automata. But along

More information

C H A P T E R Regular Expressions regular expression

C H A P T E R Regular Expressions regular expression 7 CHAPTER Regular Expressions Most programmers and other power-users of computer systems have used tools that match text patterns. You may have used a Web search engine with a pattern like travel cancun

More information

Finite Automata. Reading: Chapter 2

Finite Automata. Reading: Chapter 2 Finite Automata Reading: Chapter 2 1 Finite Automata Informally, a state machine that comprehensively captures all possible states and transitions that a machine can take while responding to a stream (or

More information

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move. CS54 Turing Machines Turing Machine q 0 AI N P U T IN TAPE read write move read write move Language = {0} q This Turing machine recognizes the language {0} Turing Machines versus DFAs TM can both write

More information

Automata on Infinite Words and Trees

Automata on Infinite Words and Trees Automata on Infinite Words and Trees Course notes for the course Automata on Infinite Words and Trees given by Dr. Meghyn Bienvenu at Universität Bremen in the 2009-2010 winter semester Last modified:

More information

3515ICT Theory of Computation Turing Machines

3515ICT Theory of Computation Turing Machines Griffith University 3515ICT Theory of Computation Turing Machines (Based loosely on slides by Harald Søndergaard of The University of Melbourne) 9-0 Overview Turing machines: a general model of computation

More information

Scanner. tokens scanner parser IR. source code. errors

Scanner. tokens scanner parser IR. source code. errors Scanner source code tokens scanner parser IR errors maps characters into tokens the basic unit of syntax x = x + y; becomes = + ; character string value for a token is a lexeme

More information

Reading 13 : Finite State Automata and Regular Expressions

Reading 13 : Finite State Automata and Regular Expressions CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model

More information

CS5236 Advanced Automata Theory

CS5236 Advanced Automata Theory CS5236 Advanced Automata Theory Frank Stephan Semester I, Academic Year 2012-2013 Advanced Automata Theory is a lecture which will first review the basics of formal languages and automata theory and then

More information

Turing Machines: An Introduction

Turing Machines: An Introduction CIT 596 Theory of Computation 1 We have seen several abstract models of computing devices: Deterministic Finite Automata, Nondeterministic Finite Automata, Nondeterministic Finite Automata with ɛ-transitions,

More information

Chapter 7 Uncomputability

Chapter 7 Uncomputability Chapter 7 Uncomputability 190 7.1 Introduction Undecidability of concrete problems. First undecidable problem obtained by diagonalisation. Other undecidable problems obtained by means of the reduction

More information

Model 2.4 Faculty member + student

Model 2.4 Faculty member + student Model 2.4 Faculty member + student Course syllabus for Formal languages and Automata Theory. Faculty member information: Name of faculty member responsible for the course Office Hours Office Number Email

More information

The Halting Problem is Undecidable

The Halting Problem is Undecidable 185 Corollary G = { M, w w L(M) } is not Turing-recognizable. Proof. = ERR, where ERR is the easy to decide language: ERR = { x { 0, 1 }* x does not have a prefix that is a valid code for a Turing machine

More information

Regular Languages and Finite State Machines

Regular Languages and Finite State Machines Regular Languages and Finite State Machines Plan for the Day: Mathematical preliminaries - some review One application formal definition of finite automata Examples 1 Sets A set is an unordered collection

More information

Regular Expressions and Automata using Haskell

Regular Expressions and Automata using Haskell Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions

More information

CS 3719 (Theory of Computation and Algorithms) Lecture 4

CS 3719 (Theory of Computation and Algorithms) Lecture 4 CS 3719 (Theory of Computation and Algorithms) Lecture 4 Antonina Kolokolova January 18, 2012 1 Undecidable languages 1.1 Church-Turing thesis Let s recap how it all started. In 1990, Hilbert stated a

More information

Deterministic Finite Automata

Deterministic Finite Automata 1 Deterministic Finite Automata Definition: A deterministic finite automaton (DFA) consists of 1. a finite set of states (often denoted Q) 2. a finite set Σ of symbols (alphabet) 3. a transition function

More information

SRM UNIVERSITY FACULTY OF ENGINEERING & TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF SOFTWARE ENGINEERING COURSE PLAN

SRM UNIVERSITY FACULTY OF ENGINEERING & TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF SOFTWARE ENGINEERING COURSE PLAN Course Code : CS0355 SRM UNIVERSITY FACULTY OF ENGINEERING & TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF SOFTWARE ENGINEERING COURSE PLAN Course Title : THEORY OF COMPUTATION Semester : VI Course : June

More information

Lecture summary for Theory of Computation

Lecture summary for Theory of Computation Lecture summary for Theory of Computation Sandeep Sen 1 January 8, 2015 1 Department of Computer Science and Engineering, IIT Delhi, New Delhi 110016, India. E- mail:ssen@cse.iitd.ernet.in Contents 1 The

More information

Overview of E0222: Automata and Computability

Overview of E0222: Automata and Computability Overview of E0222: Automata and Computability Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. August 3, 2011 What this course is about What we study

More information

Introduction to Automata Theory. Reading: Chapter 1

Introduction to Automata Theory. Reading: Chapter 1 Introduction to Automata Theory Reading: Chapter 1 1 What is Automata Theory? Study of abstract computing devices, or machines Automaton = an abstract computing device Note: A device need not even be a

More information

Informatique Fondamentale IMA S8

Informatique Fondamentale IMA S8 Informatique Fondamentale IMA S8 Cours 1 - Intro + schedule + finite state machines Laure Gonnord http://laure.gonnord.org/pro/teaching/ Laure.Gonnord@polytech-lille.fr Université Lille 1 - Polytech Lille

More information

On Winning Conditions of High Borel Complexity in Pushdown Games

On Winning Conditions of High Borel Complexity in Pushdown Games Fundamenta Informaticae (2005) 1 22 1 IOS Press On Winning Conditions of High Borel Complexity in Pushdown Games Olivier Finkel Equipe de Logique Mathématique U.F.R. de Mathématiques, Université Paris

More information

Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology

Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology Honors Class (Foundations of) Informatics Tom Verhoeff Department of Mathematics & Computer Science Software Engineering & Technology www.win.tue.nl/~wstomv/edu/hci c 2011, T. Verhoeff @ TUE.NL 1/20 Information

More information

Automata and Formal Languages. Push Down Automata. Sipser pages 109-114. Lecture 13. Tim Sheard 1

Automata and Formal Languages. Push Down Automata. Sipser pages 109-114. Lecture 13. Tim Sheard 1 Automata and Formal Languages Push Down Automata Sipser pages 109-114 Lecture 13 Tim Sheard 1 Push Down Automata Push Down Automata (PDAs) are ε-nfas with stack memory. Transitions are labeled by an input

More information

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER JASPER DEANTONIO Abstract. This paper is a study of the Turing Degrees, which are levels of incomputability naturally arising from sets of natural numbers.

More information

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems. 3130CIT: Theory of Computation Turing machines and undecidability (IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems. An undecidable problem

More information

6.080/6.089 GITCS Feb 12, 2008. Lecture 3

6.080/6.089 GITCS Feb 12, 2008. Lecture 3 6.8/6.89 GITCS Feb 2, 28 Lecturer: Scott Aaronson Lecture 3 Scribe: Adam Rogal Administrivia. Scribe notes The purpose of scribe notes is to transcribe our lectures. Although I have formal notes of my

More information

Regular Languages and Finite Automata

Regular Languages and Finite Automata Regular Languages and Finite Automata 1 Introduction Hing Leung Department of Computer Science New Mexico State University Sep 16, 2010 In 1943, McCulloch and Pitts [4] published a pioneering work on a

More information

CAs and Turing Machines. The Basis for Universal Computation

CAs and Turing Machines. The Basis for Universal Computation CAs and Turing Machines The Basis for Universal Computation What We Mean By Universal When we claim universal computation we mean that the CA is capable of calculating anything that could possibly be calculated*.

More information

ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear:

ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear: ω-automata ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear: in verification, as encodings of non-terminating executions of a program. in arithmetic,

More information

Genetic programming with regular expressions

Genetic programming with regular expressions Genetic programming with regular expressions Børge Svingen Chief Technology Officer, Open AdExchange bsvingen@openadex.com 2009-03-23 Pattern discovery Pattern discovery: Recognizing patterns that characterize

More information

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions CSC45 AUTOMATA 2. Finite Automata: Examples and Definitions Finite Automata: Examples and Definitions A finite automaton is a simple type of computer. Itsoutputislimitedto yes to or no. It has very primitive

More information

Compiler Construction

Compiler Construction Compiler Construction Regular expressions Scanning Görel Hedin Reviderad 2013 01 23.a 2013 Compiler Construction 2013 F02-1 Compiler overview source code lexical analysis tokens intermediate code generation

More information

Computability Theory

Computability Theory CSC 438F/2404F Notes (S. Cook and T. Pitassi) Fall, 2014 Computability Theory This section is partly inspired by the material in A Course in Mathematical Logic by Bell and Machover, Chap 6, sections 1-10.

More information

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013 CMPSCI 250: Introduction to Computation Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013 Regular Expressions and Their Languages Alphabets, Strings and Languages

More information

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2 CS 70 Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2 Proofs Intuitively, the concept of proof should already be familiar We all like to assert things, and few of us

More information

Properties of Stabilizing Computations

Properties of Stabilizing Computations Theory and Applications of Mathematics & Computer Science 5 (1) (2015) 71 93 Properties of Stabilizing Computations Mark Burgin a a University of California, Los Angeles 405 Hilgard Ave. Los Angeles, CA

More information

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson Mathematics for Computer Science/Software Engineering Notes for the course MSM1F3 Dr. R. A. Wilson October 1996 Chapter 1 Logic Lecture no. 1. We introduce the concept of a proposition, which is a statement

More information

Lecture 2: Universality

Lecture 2: Universality CS 710: Complexity Theory 1/21/2010 Lecture 2: Universality Instructor: Dieter van Melkebeek Scribe: Tyson Williams In this lecture, we introduce the notion of a universal machine, develop efficient universal

More information

T-79.186 Reactive Systems: Introduction and Finite State Automata

T-79.186 Reactive Systems: Introduction and Finite State Automata T-79.186 Reactive Systems: Introduction and Finite State Automata Timo Latvala 14.1.2004 Reactive Systems: Introduction and Finite State Automata 1-1 Reactive Systems Reactive systems are a class of software

More information

Philadelphia University Faculty of Information Technology Department of Computer Science First Semester, 2007/2008.

Philadelphia University Faculty of Information Technology Department of Computer Science First Semester, 2007/2008. Philadelphia University Faculty of Information Technology Department of Computer Science First Semester, 2007/2008 Course Syllabus Course Title: Theory of Computation Course Level: 3 Lecture Time: Course

More information

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy Kim S. Larsen Odense University Abstract For many years, regular expressions with back referencing have been used in a variety

More information

Finite Automata and Regular Languages

Finite Automata and Regular Languages CHAPTER 3 Finite Automata and Regular Languages 3. Introduction 3.. States and Automata A finite-state machine or finite automaton (the noun comes from the Greek; the singular is automaton, the Greek-derived

More information

Single machine models: Maximum Lateness -12- Approximation ratio for EDD for problem 1 r j,d j < 0 L max. structure of a schedule Q...

Single machine models: Maximum Lateness -12- Approximation ratio for EDD for problem 1 r j,d j < 0 L max. structure of a schedule Q... Lecture 4 Scheduling 1 Single machine models: Maximum Lateness -12- Approximation ratio for EDD for problem 1 r j,d j < 0 L max structure of a schedule 0 Q 1100 11 00 11 000 111 0 0 1 1 00 11 00 11 00

More information

Lecture 16 : Relations and Functions DRAFT

Lecture 16 : Relations and Functions DRAFT CS/Math 240: Introduction to Discrete Mathematics 3/29/2011 Lecture 16 : Relations and Functions Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT In Lecture 3, we described a correspondence

More information

11 Ideals. 11.1 Revisiting Z

11 Ideals. 11.1 Revisiting Z 11 Ideals The presentation here is somewhat different than the text. In particular, the sections do not match up. We have seen issues with the failure of unique factorization already, e.g., Z[ 5] = O Q(

More information

Algorithmic Software Verification

Algorithmic Software Verification Algorithmic Software Verification (LTL Model Checking) Azadeh Farzan What is Verification Anyway? Proving (in a formal way) that program satisfies a specification written in a logical language. Formal

More information

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi Automata Theory Automata theory is the study of abstract computing devices. A. M. Turing studied an abstract machine that had all the capabilities of today s computers. Turing s goal was to describe the

More information

Is Sometime Ever Better Than Alway?

Is Sometime Ever Better Than Alway? Is Sometime Ever Better Than Alway? DAVID GRIES Cornell University The "intermittent assertion" method for proving programs correct is explained and compared with the conventional method. Simple conventional

More information

1 if 1 x 0 1 if 0 x 1

1 if 1 x 0 1 if 0 x 1 Chapter 3 Continuity In this chapter we begin by defining the fundamental notion of continuity for real valued functions of a single real variable. When trying to decide whether a given function is or

More information

How To Compare A Markov Algorithm To A Turing Machine

How To Compare A Markov Algorithm To A Turing Machine Markov Algorithm CHEN Yuanmi December 18, 2007 1 Abstract Markov Algorithm can be understood as a priority string rewriting system. In this short paper we give the definition of Markov algorithm and also

More information

Course Manual Automata & Complexity 2015

Course Manual Automata & Complexity 2015 Course Manual Automata & Complexity 2015 Course code: Course homepage: Coordinator: Teachers lectures: Teacher exercise classes: Credits: X_401049 http://www.cs.vu.nl/~tcs/ac prof. dr. W.J. Fokkink home:

More information

Diagonalization. Ahto Buldas. Lecture 3 of Complexity Theory October 8, 2009. Slides based on S.Aurora, B.Barak. Complexity Theory: A Modern Approach.

Diagonalization. Ahto Buldas. Lecture 3 of Complexity Theory October 8, 2009. Slides based on S.Aurora, B.Barak. Complexity Theory: A Modern Approach. Diagonalization Slides based on S.Aurora, B.Barak. Complexity Theory: A Modern Approach. Ahto Buldas Ahto.Buldas@ut.ee Background One basic goal in complexity theory is to separate interesting complexity

More information

Regular Languages and Finite Automata

Regular Languages and Finite Automata Regular Languages and Finite Automata A C Norman, Lent Term 1996 Part IA 1 Introduction This course is short, but it is present in Part 1A because of the way it introduces links between many different

More information

2.1 Complexity Classes

2.1 Complexity Classes 15-859(M): Randomized Algorithms Lecturer: Shuchi Chawla Topic: Complexity classes, Identity checking Date: September 15, 2004 Scribe: Andrew Gilpin 2.1 Complexity Classes In this lecture we will look

More information

CS 341: Foundations of Computer Science II elearning Section Syllabus, Spring 2015

CS 341: Foundations of Computer Science II elearning Section Syllabus, Spring 2015 CS 341: Foundations of Computer Science II elearning Section Syllabus, Spring 2015 Course Info Instructor: Prof. Marvin K. Nakayama Office: GITC 4312 Phone: 973-596-3398 E-mail: marvin@njit.edu (Be sure

More information

4.6 The Primitive Recursive Functions

4.6 The Primitive Recursive Functions 4.6. THE PRIMITIVE RECURSIVE FUNCTIONS 309 4.6 The Primitive Recursive Functions The class of primitive recursive functions is defined in terms of base functions and closure operations. Definition 4.6.1

More information

Implementation of Recursively Enumerable Languages using Universal Turing Machine in JFLAP

Implementation of Recursively Enumerable Languages using Universal Turing Machine in JFLAP International Journal of Information and Computation Technology. ISSN 0974-2239 Volume 4, Number 1 (2014), pp. 79-84 International Research Publications House http://www. irphouse.com /ijict.htm Implementation

More information

Push-down Automata and Context-free Grammars

Push-down Automata and Context-free Grammars 14 Push-down Automata and Context-free Grammars This chapter details the design of push-down automata (PDA) for various languages, the conversion of CFGs to PDAs, and vice versa. In particular, after formally

More information

1 Definition of a Turing machine

1 Definition of a Turing machine Introduction to Algorithms Notes on Turing Machines CS 4820, Spring 2012 April 2-16, 2012 1 Definition of a Turing machine Turing machines are an abstract model of computation. They provide a precise,

More information

ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 15 april 2003. Master Edition

ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 15 april 2003. Master Edition ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK 5 april 23 Master Edition CONTEXT FREE LANGUAGES & PUSH-DOWN AUTOMATA CONTEXT-FREE GRAMMARS, CFG Problems Sudkamp Problem. (3.2.) Which language generates the grammar

More information

Cartesian Products and Relations

Cartesian Products and Relations Cartesian Products and Relations Definition (Cartesian product) If A and B are sets, the Cartesian product of A and B is the set A B = {(a, b) :(a A) and (b B)}. The following points are worth special

More information

Fast nondeterministic recognition of context-free languages using two queues

Fast nondeterministic recognition of context-free languages using two queues Fast nondeterministic recognition of context-free languages using two queues Burton Rosenberg University of Miami Abstract We show how to accept a context-free language nondeterministically in O( n log

More information

Omega Automata: Minimization and Learning 1

Omega Automata: Minimization and Learning 1 Omega Automata: Minimization and Learning 1 Oded Maler CNRS - VERIMAG Grenoble, France 2007 1 Joint work with A. Pnueli, late 80s Summary Machine learning in general and of formal languages in particular

More information

Learning Analysis by Reduction from Positive Data

Learning Analysis by Reduction from Positive Data Learning Analysis by Reduction from Positive Data František Mráz 1, Friedrich Otto 1, and Martin Plátek 2 1 Fachbereich Mathematik/Informatik, Universität Kassel 34109 Kassel, Germany {mraz,otto}@theory.informatik.uni-kassel.de

More information

Continued Fractions and the Euclidean Algorithm

Continued Fractions and the Euclidean Algorithm Continued Fractions and the Euclidean Algorithm Lecture notes prepared for MATH 326, Spring 997 Department of Mathematics and Statistics University at Albany William F Hammond Table of Contents Introduction

More information

SOLUTION Trial Test Grammar & Parsing Deficiency Course for the Master in Software Technology Programme Utrecht University

SOLUTION Trial Test Grammar & Parsing Deficiency Course for the Master in Software Technology Programme Utrecht University SOLUTION Trial Test Grammar & Parsing Deficiency Course for the Master in Software Technology Programme Utrecht University Year 2004/2005 1. (a) LM is a language that consists of sentences of L continued

More information

Composability of Infinite-State Activity Automata*

Composability of Infinite-State Activity Automata* Composability of Infinite-State Activity Automata* Zhe Dang 1, Oscar H. Ibarra 2, Jianwen Su 2 1 Washington State University, Pullman 2 University of California, Santa Barbara Presented by Prof. Hsu-Chun

More information

Factoring & Primality

Factoring & Primality Factoring & Primality Lecturer: Dimitris Papadopoulos In this lecture we will discuss the problem of integer factorization and primality testing, two problems that have been the focus of a great amount

More information

Graph Theory Problems and Solutions

Graph Theory Problems and Solutions raph Theory Problems and Solutions Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles November, 005 Problems. Prove that the sum of the degrees of the vertices of any finite graph is

More information

Boolean Algebra Part 1

Boolean Algebra Part 1 Boolean Algebra Part 1 Page 1 Boolean Algebra Objectives Understand Basic Boolean Algebra Relate Boolean Algebra to Logic Networks Prove Laws using Truth Tables Understand and Use First Basic Theorems

More information

Chapter 6: Episode discovery process

Chapter 6: Episode discovery process Chapter 6: Episode discovery process Algorithmic Methods of Data Mining, Fall 2005, Chapter 6: Episode discovery process 1 6. Episode discovery process The knowledge discovery process KDD process of analyzing

More information

CONTENTS 1. Peter Kahn. Spring 2007

CONTENTS 1. Peter Kahn. Spring 2007 CONTENTS 1 MATH 304: CONSTRUCTING THE REAL NUMBERS Peter Kahn Spring 2007 Contents 2 The Integers 1 2.1 The basic construction.......................... 1 2.2 Adding integers..............................

More information

Software Model Checking: Theory and Practice

Software Model Checking: Theory and Practice Software Model Checking: Theory and Practice Lecture: Specification Checking - LTL Model Checking Copyright 2004, Matt Dwyer, John Hatcliff, and Robby. The syllabus and all lectures for this course are

More information

Increasing Interaction and Support in the Formal Languages and Automata Theory Course

Increasing Interaction and Support in the Formal Languages and Automata Theory Course Increasing Interaction and Support in the Formal Languages and Automata Theory Course [Extended Abstract] Susan H. Rodger rodger@cs.duke.edu Jinghui Lim Stephen Reading ABSTRACT The introduction of educational

More information

Mathematical Induction

Mathematical Induction Mathematical Induction (Handout March 8, 01) The Principle of Mathematical Induction provides a means to prove infinitely many statements all at once The principle is logical rather than strictly mathematical,

More information

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay Lecture - 17 Shannon-Fano-Elias Coding and Introduction to Arithmetic Coding

More information

CS 301 Course Information

CS 301 Course Information CS 301: Languages and Automata January 9, 2009 CS 301 Course Information Prof. Robert H. Sloan Handout 1 Lecture: Tuesday Thursday, 2:00 3:15, LC A5 Weekly Problem Session: Wednesday, 4:00 4:50 p.m., LC

More information

Testing LTL Formula Translation into Büchi Automata

Testing LTL Formula Translation into Büchi Automata Testing LTL Formula Translation into Büchi Automata Heikki Tauriainen and Keijo Heljanko Helsinki University of Technology, Laboratory for Theoretical Computer Science, P. O. Box 5400, FIN-02015 HUT, Finland

More information

How To Understand The Theory Of Computer Science

How To Understand The Theory Of Computer Science Theory of Computation Lecture Notes Abhijat Vichare August 2005 Contents 1 Introduction 2 What is Computation? 3 The λ Calculus 3.1 Conversions: 3.2 The calculus in use 3.3 Few Important Theorems 3.4 Worked

More information

1 = (a 0 + b 0 α) 2 + + (a m 1 + b m 1 α) 2. for certain elements a 0,..., a m 1, b 0,..., b m 1 of F. Multiplying out, we obtain

1 = (a 0 + b 0 α) 2 + + (a m 1 + b m 1 α) 2. for certain elements a 0,..., a m 1, b 0,..., b m 1 of F. Multiplying out, we obtain Notes on real-closed fields These notes develop the algebraic background needed to understand the model theory of real-closed fields. To understand these notes, a standard graduate course in algebra is

More information

3. Mathematical Induction

3. Mathematical Induction 3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)

More information

Formal Grammars and Languages

Formal Grammars and Languages Formal Grammars and Languages Tao Jiang Department of Computer Science McMaster University Hamilton, Ontario L8S 4K1, Canada Bala Ravikumar Department of Computer Science University of Rhode Island Kingston,

More information

CPS 140 - Mathematical Foundations of CS Dr. S. Rodger Section: Properties of Context-Free Languages èhandoutè Section 3.5 Which of the following languages are CFL? æ L=fa n b n c j j 0 énçjg æ L=fa n

More information

CS 103X: Discrete Structures Homework Assignment 3 Solutions

CS 103X: Discrete Structures Homework Assignment 3 Solutions CS 103X: Discrete Structures Homework Assignment 3 s Exercise 1 (20 points). On well-ordering and induction: (a) Prove the induction principle from the well-ordering principle. (b) Prove the well-ordering

More information

26 Integers: Multiplication, Division, and Order

26 Integers: Multiplication, Division, and Order 26 Integers: Multiplication, Division, and Order Integer multiplication and division are extensions of whole number multiplication and division. In multiplying and dividing integers, the one new issue

More information

Lecture I FINITE AUTOMATA

Lecture I FINITE AUTOMATA 1. Regular Sets and DFA Lecture I Page 1 Lecture I FINITE AUTOMATA Lecture 1: Honors Theory, Spring 02, Yap We introduce finite automata (deterministic and nondeterministic) and regular languages. Some

More information

The Goldberg Rao Algorithm for the Maximum Flow Problem

The Goldberg Rao Algorithm for the Maximum Flow Problem The Goldberg Rao Algorithm for the Maximum Flow Problem COS 528 class notes October 18, 2006 Scribe: Dávid Papp Main idea: use of the blocking flow paradigm to achieve essentially O(min{m 2/3, n 1/2 }

More information

Finite Automata and Formal Languages

Finite Automata and Formal Languages Finite Automata and Formal Languages TMV026/DIT321 LP4 2011 Ana Bove Lecture 1 March 21st 2011 Course Organisation Overview of the Course Overview of today s lecture: Course Organisation Level: This course

More information

Introduction to NP-Completeness Written and copyright c by Jie Wang 1

Introduction to NP-Completeness Written and copyright c by Jie Wang 1 91.502 Foundations of Comuter Science 1 Introduction to Written and coyright c by Jie Wang 1 We use time-bounded (deterministic and nondeterministic) Turing machines to study comutational comlexity of

More information

Notes on Complexity Theory Last updated: August, 2011. Lecture 1

Notes on Complexity Theory Last updated: August, 2011. Lecture 1 Notes on Complexity Theory Last updated: August, 2011 Jonathan Katz Lecture 1 1 Turing Machines I assume that most students have encountered Turing machines before. (Students who have not may want to look

More information