cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Similar documents
cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

PRACTICE FINAL SOLUTIONS

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

Theory of Computation

Fundamentele Informatica II

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Author: Vivek Kulkarni ( )

Computability and Complexity

1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata.

Theory of Computation (Classroom Practice Booklet Solutions)

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine

Undecidable Problems and Reducibility

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

CSE 355 Test 2, Fall 2016

HW6 Solutions. Micha l Dereziński. March 20, 2015

Section 1 (closed-book) Total points 30

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

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

Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. The stack

Computational Models - Lecture 5 1

MA/CSSE 474 Theory of Computation

A Universal Turing Machine

Part I: Definitions and Properties

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

SCHEME FOR INTERNAL ASSESSMENT TEST 3

DM17. Beregnelighed. Jacob Aae Mikkelsen

Chapter 3. Regular grammars

Pushdown Automata. Reading: Chapter 6

Pushdown Automata. Chapter 12

Theory Bridge Exam Example Questions

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Foundations of Informatics: a Bridging Course

6.8 The Post Correspondence Problem

CS481F01 Prelim 2 Solutions

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

Homework 4. Chapter 7. CS A Term 2009: Foundations of Computer Science. By Li Feng, Shweta Srivastava, and Carolina Ruiz

Sri vidya college of engineering and technology

Decidability: Church-Turing Thesis

CPS 220 Theory of Computation Pushdown Automata (PDA)

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

Topics in Timed Automata

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

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

CS20a: Turing Machines (Oct 29, 2002)

Theory of Computation

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Theory of Computation Turing Machine and Pushdown Automata

CSE 105 THEORY OF COMPUTATION

VTU QUESTION BANK. Unit 1. Introduction to Finite Automata. 1. Obtain DFAs to accept strings of a s and b s having exactly one a.

Question Bank UNIT I

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

C6.2 Push-Down Automata

The Unsolvability of the Halting Problem. Chapter 19

CSE 105 THEORY OF COMPUTATION

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

Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where

Computational Models - Lecture 4

CSE 105 THEORY OF COMPUTATION

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

Homework 8. a b b a b a b. two-way, read/write

Theory of Computation

Pushdown Automata (Pre Lecture)

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Properties of Context Free Languages

ACS2: Decidability Decidability

SFWR ENG 2FA3. Solution to the Assignment #4

Solutions to Old Final Exams (For Fall 2007)

Context-Free Languages (Pre Lecture)

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

Automata Theory - Quiz II (Solutions)

Rumination on the Formal Definition of DPDA

NPDA, CFG equivalence

Lecture 17: Language Recognition

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

Context-Free Grammars and Languages. Reading: Chapter 5

CS481F01 Solutions 6 PDAS

CSE 105 THEORY OF COMPUTATION

Einführung in die Computerlinguistik

Ogden s Lemma for CFLs

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Fundamentele Informatica 3 Antwoorden op geselecteerde opgaven uit Hoofdstuk 7 en Hoofdstuk 8

CISC4090: Theory of Computation

Context-free Languages and Pushdown Automata

Nondeterministic Finite Automata and Regular Expressions

CPSC 421: Tutorial #1

Name: Student ID: Instructions:

(pp ) PDAs and CFGs (Sec. 2.2)

Introduction to Languages and Computation

Testing Emptiness of a CFL. Testing Finiteness of a CFL. Testing Membership in a CFL. CYK Algorithm

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CS Automata, Computability and Formal Languages

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

Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove

DD2371 Automata Theory

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Transcription:

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

LECTURE 14

SMALL REVIEW FOR FINAL

SOME Y/N QUESTIONS Q1 Given Σ =, there is L over Σ Yes: = {e} and L = {e} Σ Q2 There are uncountably many languages over Σ = {a} Yes: {a} = ℵ 0 and 2 {a} = C and any set of cardinality C is uncountable Q3 Let RE be a set of regular expressions. L Σ is regular iff L = L(r), for some r RE Yes: this is definition of regular language Q4 L = {w Σ : q F (s, w) (q, e)} M No: this is definition of L(M), not of L

SOME Y/N QUESTIONS Q5 L = L + {e} No: only when e L Q6 L = {w 1... w n : w i L, i = 1,..., n} No: only when i = 0, 1,..., n Q7 For any languages L 1, L 2 Σ, if L 1 L 2, then (L 1 L 2 ) = L 2 Yes languages are sets, so (L 1 L 2 ) = L 2 when L 1 L 2 Q8 Yes ((φ a) (φ b )) φ represents a language L = {e} (({e} {a}) {b} ) {e} = {b} {e} = {e}

SOME Y/N QUESTIONS Q9 L(M) = {w Σ : (q, w) (s, e)} M No: only when q F Q10 L(M 1 ) = L(M 2 ) iff M 1 and M 2 are finite automata No: take as M 1, M 2 any finite automata such that L(M 1 ) φ and M 2 such that L(M 2 ) = φ Q11 Any finite language is Context Free Yes: any finite language is regular and we proved that RL CFL Q12 Intersection of any two regular languages is CF language Yes: Regular languages are closed under intersection and RL CFL

SOME Y/N QUESTIONS Q13 Yes: Union of a regular and a CF language is a CF language RL CFL and FCL are closed under union Q14 Yes: If L is regular, there is a PDA M such that L = L(M) FA is a PDA operating on an empty stock Q15 L = {a n b n c n : n 0} is CF No: L is not CF, as proved by Pumping Lemma for CF languages Q16 Yes: Let Σ = {a}, then for any w Σ we have that w R = w a R = a and hence w R = w for w {a}

SOME Y/N QUESTIONS Q17 A Ax, A V, x Σ is the only rule allowed in a regular grammar No: not only, A xb for B A is also a rule of a regular grammar Q18 Let G = ({S, (, )}, {(, )}, R, S) for R = {S SS (S)} L(G) is regular Yes: L(G) = and hence regular Q19 The grammar with rules S AB, B b bb, A e aab generates a language L = {a k b j : k < j} Yes: the rule A e aab produces the same amount of a s and b s, and the rule B bb adds only b s

SOME Y/N QUESTIONS Q20 We can always show that L is regular using Pumping Lemma No: we use Pumping Lemma to prove (if possible) that L is not regular Q21 ((p, e, β), (q, γ)) means: read nothing, move from p to q No: must add: and replace β by γ on the top of the stack Q22 No: CF L = {a n b m c n : n, m N} is CF when n = m we get L = {a n b n c n : n N} that is not Q23 Every subset of a regular language is a regular language No: L = {a n b n : n 0} a b and L is not regular

SOME Y/N QUESTIONS Q24 Class of context-free languages is closed under intersection No: L 1 = {a n b n c m : n, m 0} is CF, L 1 = {a m b n c n : n, m 0} is CF, but L 1 L 2 = {a n b n c n, n 0} is not CF Q25 A regular language is a CF language Yes: Regular grammar is a special case of a context-free grammar Q26 Any regular language is accepted by some PD automaton Yes: Any regular language is accepted by a finite automaton, and a finite automaton is a PD automaton (that never operates on the stock)

SOME Y/N QUESTIONS Q27 Yes: Turing Machines can read and write by definition Q28 A configuration of a Turing machine M = (K, Σ, δ, s, H) is any element of a set K Σ (Σ (Σ { }) {e}), where denotes a blank symbol No: a configuration is an element of a set K Σ (Σ (Σ { }) {e}) Q29 A computation of a Turing machine can start at any position of w Σ Yes: by definition

SOME Y/N QUESTIONS Q30 In Turing machines, words w Σ can t contain blank symbols No: Σ in Turing machine contains the blank symbol Q31 It is proved that everything computable (algorithm) is computable by a Turing Machine and vice versa No: this is Church - Turing Hypothesis, not a theorem Q32 A Turing machine M decides a language L Σ, if for any word w Σ the following is true. If w L, then then M accepts w; and if w L then M rejects w No: must say: any word w Σ 0, and L Σ 0 for Σ 0 = Σ { }

SOME PROBLEMS P1 Let Σ be any alphabet, L 1, L 2 t e L 2 Show that Solution (L 1 Σ L 2 ) = Σ By definition, L 1 Σ, L 2 Σ and Σ Σ. Hence We have to show that also (L 1 Σ L 2 ) Σ Σ (L 1 Σ L 2 ) Let w Σ. We have that also w (L 1 Σ L 2 ) becausew = ewe and e L 1 and e L 2

SOME PROBLEMS P2 Use book or lecture definition (specify which are you using) to construct a non-deterministic finite automaton M, such that L(M) = (ab) (ba) Draw a state diagram. Do not specify all components. Justify your construction by listing some strings accepted by the state diagram Solution 1: We use the lecture definition Components of M are: Σ = {a, b}, K = {q 0, q 1 }, s = q 0, F = {q 0, q 1 }, = {(q 0, ab, q 0 ), (q 0, e, q 1 ), (q 1, ba, q 1 )} You must draw the diagram only! Strings accepted are: ab, abab, abba, ababba,... You must trace the computations accepting these strings!

SOME PROBLEMS P2 Solution 2: We use the book definition Components of M are: Σ = {a, b}, K = {q 0, q 1, q 2, q 3 }, s = q 0, F = {q 2 }, = {(q 0, a, q 1 ), (q 1, b, q 0 ), (q 0, e, q 2 ), (q 2, b, q 3 ), (q 3, a, q 2 )} You must draw the diagram only! Strings accepted are: ab, abab, abba, ababba,... You must trace the computations accepting these strings!

SOME PROBLEMS P3 1. DRAW a DIAGRAM of a PDA M, such that L(M) = {b n a 2n : n 0} Solution 1 Here are the components- you must draw a diagram! M = (K, Σ, Γ,, s, F) for K = {s, f}, Σ = {a, b}, Γ = {a}, s, F = {f}, = {((s, b, e), (s, aa)), ((s, e, e), (f, e)), ((f, a, a), (f, e))}

SOME PROBLEMS P3 2. Explain the construction. Write motivation. Solution M operates as follows: pushes aa on the top of the stock while M is reading b, switches to f (final state) non-deterministically; and pops a while reading a (all in final state) M puts on the stock two a s for each b, and then remove all a s from the stock comparing them witha s in the word while in the final state

SOME PROBLEMS P3 3. Trace a transitions of M that leads to the acceptance of the string bbaaaa The accepting computation is: (s, bbaaaa, e) M (s, baaaa, aa) M (s, aaaa, aaaa) Solution 2 M (f, aaaa, aaaa) M (f, aaa, aaa) M (f, aa, aa) M = (K, Σ, Γ,, s, F) for M (f, a, a) M (f, e, e) K = {s, f}, Σ = {a, b}, Γ = {b}, s, F = {f}, = {((s, b, e), (s, b)), ((s, e, e), (f, e)), ((f, aa, b), (f, e))}

SOME PROBLEMS P4 Given a Regular grammar G = (V, Σ, R, S), where V = {a, b, S, A}, Σ = {a, b}, R = {S as A e, A aba a b} 1. Use the construction in the proof of L-GTheorem: Language L is regular if and only if there exists a regular grammar G such that L = L(G) to construct a finite automaton M, such that L(G) = L(M) Draw a diagram of M

SOME PROBLEMS P4 Solution Given R = {S as A e, A aba a b} we construct a non-deterministic finite automata M = (K, Σ,, s, F) as follows: K = (V Σ) {f}, Σ = Σ, s = S, F = {f}, = {(S, a, S), (S, e, A), (S, e, f), (A, ab, A), (A, a, f), (A, b, f)}

SOME PROBLEMS P4 2. Trace a transitions of M that lead to the acceptance of the string aaaababa, and compare with a derivation of the same string in G Solution The accepting computation is: (S, aaaababa) M (S, aaababa) M (S, aababa) M (S, ababa) M (A, ababa) M (A, aba) M (A, a) M (f, e) G derivation is: S as aas aaas aaaa aaaaba aaaababa aaaababa

SOME PROBLEMS P5 Prove that the Class of context-free languages is NOT closed under intersection Proof Assume that the context-free languages are are closed under intersection Observe that both languages L 1 = {a n b n c m : m, n 0} and L 2 = {a m b n c n : m, n 0} are context-free So the language L 1 L 2 must be context-free, but L 1 L 2 = {a n b n c n : n 0} and we have proved that L = {a n b n c n : n 0} is not context-free Contradiction