Automata Theory CS F-13 Unrestricted Grammars

Size: px
Start display at page:

Download "Automata Theory CS F-13 Unrestricted Grammars"

Transcription

1 Automata Theory CS F-13 Unrestricted Grammars David Galles Department of Computer Science University of San Francisco

2 13-0: Language Hierarchy Regular Languaes Regular Expressions Finite Automata Context Free Languages Context-Free Grammars Push-Down Automata Recusively Enumerable Languages?? Turing Machines

3 13-1: CFG Review G = (V,Σ,R,S) V = Set of symbols, both terminals & non-terminals Σ V set of terminals (alphabet for the language being described) R ((V Σ) V ) Set of rules S (V Σ) Start symbol

4 13-2: Unrestricted Grammars G = (V,Σ,R,S) V = Set of symbols, both terminals & non-terminals Σ V set of terminals (alphabet for the language being described) R (V (V Σ)V V ) Set of rules S (V Σ) Start symbol

5 13-3: Unrestricted Grammars R (V (V Σ)V V ) Set of rules In an Unrestricted Grammar, the left-hand side of a rule contains a string of terminals and non-terminals (at least one of which must be a non-terminal) Rules are applied just like CFGs: Find a substring that matches the LHS of some rule Replace with the RHS of the rule

6 13-4: Unrestricted Grammars To generate a string with an Unrestricted Grammar: Start with the initial symbol While the string contains at least one non-terminal: Find a substring that matches the LHS of some rule Replace that substring with the RHS of the rule

7 13-5: Unrestricted Grammars Example: Grammar for L = {a n b n c n : n > 0} First, generate (ABC) Next, non-deterministically rearrange string Finally, convert to terminals (A a, B b, etc.), ensuring that string was reordered to form a b c

8 13-6: Unrestricted Grammars Example: Grammar for L = {a n b n c n : n > 0} S ABCS S T C CA AC BA AB CB BC CT C T C c T C T B BT B T B b T B T A AT A T A a T A ǫ

9 13-7: Unrestricted Grammars S ABCS ABCABCS ABACBCS AABCBCS AABBCCS AABBCCT C AABBCT C c AABBT C cc AABBT B cc AABT B bcc AAT B bbcc AAT A bbcc AT A abbcc T A aabbcc aabbcc

10 13-8: Unrestricted Grammars S ABCS ABCABCS ABCABCABCS ABACBCABCS AABCBCABCS AABCBACBCS AABCABCBCS AABACBCBCS AAABCBCBCS AAABBCCBCS AAABBCBCCS AAABBBCCCS AAABBBBCCCT C AAABBBCCT C c AAABBBCT C cc AAABBBT C ccc AAABBBT B ccc AAABBT B bccc AAABT B bbccc AAAT B bbbccc AAAT A bbbccc AAT A abbbccc AT A aabbbccc T A aaabbbccc aaabbbccc

11 13-9: Unrestricted Grammars Example: Grammar for L = {ww : w a,b }

12 13-10: Unrestricted Grammars Example: Grammar for L = {ww : w a,b } Hints: What if we created a string, and then rearranged it (like (abc) a n b n c n )

13 13-11: Unrestricted Grammars Example: Grammar for L = {ww : w a,b } Hints: What if we created a string, and then rearranged it (like (abc) a n b n c n ) What about trying ww R

14 13-12: Unrestricted Grammars L = {ww : w a,b } S S Z S as A S bs B S ǫ AZ XZ AX XA BX XB ax aa bx ba BZ YZ AY YA BY YB ay ab by bb

15 13-13: Unrestricted Grammars L UG is the set of languages that can be described by an Unrestricted Grammar: L UG = {L : Unrestricted Grammar G,L[G] = L} Claim: L UG = L re To Prove: Prove L UG L re Prove L re L UG

16 13-14: L UG L re Given any Unrestricted Grammar G, we can create a Turing Machine M that semi-decides L[G]

17 13-15: L UG L re Given any Unrestricted Grammar G, we can create a Turing Machine M that semi-decides L[G] Two tape machine: One tape stores the input, unchanged Second tape implements the derivation Check to see if the derived string matches the input, if so accept, if not run forever

18 13-16: L UG L re To implement the derivation on the second tape: Write the initial symbol on the second tape Non-deterministically move the read/write head to somewhere on the tape Non-deterministically decide which rule to apply Scan the current position of the read/write head, to make sure the LHS of the rule is at that location Remove the LHS of the rule from the tape, and splice in the RHS

19 13-17: L UG L re Input Tape a a b b c c Work Tape S

20 13-18: L UG L re Input Tape a a b b c c Work Tape S

21 13-19: L UG L re Input Tape a a b b c c Work Tape ABC S

22 13-20: L UG L re Input Tape a a b b c c Work Tape ABC S

23 13-21: L UG L re Input Tape a a b b c c Work Tape ABCABC S

24 13-22: L UG L re Input Tape a a b b c c Work Tape ABCABC S

25 13-23: L UG L re Input Tape a a b b c c Work Tape ABACBC S

26 13-24: L UG L re Input Tape a a b b c c Work Tape ABACBC S

27 13-25: L UG L re Input Tape a a b b c c Work Tape AABCBC S

28 13-26: L UG L re Input Tape a a b b c c Work Tape AABCBC S

29 13-27: L UG L re Input Tape a a b b c c Work Tape AABBCC S

30 13-28: L UG L re Input Tape a a b b c c Work Tape AABBCC S

31 13-29: L UG L re Input Tape a a b b c c Work Tape AABBCCT C

32 13-30: L UG L re Input Tape a a b b c c Work Tape AABBCCT C

33 13-31: L UG L re Input Tape a a b b c c Work Tape AA BBCT c C

34 13-32: L UG L re Input Tape a a b b c c Work Tape AA BBCT c C

35 13-33: L UG L re Input Tape a a b b c c Work Tape AABB T C c c

36 13-34: L UG L re Input Tape a a b b c c Work Tape AABB T C c c

37 13-35: L UG L re Input Tape a a b b c c Work Tape AABB T B c c

38 13-36: L UG L re Input Tape a a b b c c Work Tape AABB T B c c

39 13-37: L UG L re Input Tape a a b b c c Work Tape AA B T B b c c

40 13-38: L UG L re Input Tape a a b b c c Work Tape AA B T B b c c

41 13-39: L UG L re Input Tape a a b b c c Work Tape AA T B b b c c

42 13-40: L UG L re Input Tape a a b b c c Work Tape AA T B b b c c

43 13-41: L UG L re Input Tape a a b b c c Work Tape AA T A b b c c

44 13-42: L UG L re Input Tape a a b b c c Work Tape AA T A b b c c

45 13-43: L UG L re Input Tape a a b b c c Work Tape A a b b T A c c

46 13-44: L UG L re Input Tape a a b b c c Work Tape A a b b T A c c

47 13-45: L UG L re Input Tape a a b b c c Work Tape T A a a b b c c

48 13-46: L UG L re Input Tape a a b b c c Work Tape T A a a b b c c

49 13-47: L UG L re Input Tape a a b b c c Work Tape a a b b c c

50 13-48: L UG L re Input Tape a a b b c c Work Tape a a b b c c

51 13-49: L re L UG Given any Turing Machine M that semi-decides the language L, we can create an Unrestricted Grammar G such that L[G] = L

52 13-50: L re L UG Given any Turing Machine M that semi-decides the language L, we can create an Unrestricted Grammar G such that L[G] = L Will assume that all Turing Machines accept in the same configuration: (h, ) Not a major restriction why?

53 13-51: L re L UG Given any Turing Machine M that semi-decides the language L, we can create an Unrestricted Grammar G such that L[G] = L Will assume that all Turing Machines accept in the same configuration: (h, ) Not a major restriction why? Add a tape erasing machine right before the accepting state, that erases the tape, leaving the read/write head at the beginning of the tape

54 13-52: L re L UG Given any Turing Machine M that semi-decides the language L, we can create an Unrestricted Grammar G such that L[G] = L Grammar: Generates a string Turing Machine: Works from string to accept state Two formalisms work in different directions Simulating Turing Machine with a Grammar can be difficult..

55 13-53: L re L UG Two formalisms work in different directions Simulate a Turing Machine in reverse! Each partial derivation represents a configuration Each rule represents a backwards step in Turing Machine computation

56 13-54: L re L UG Given a TM M, we create a Grammar G: Language for G: Everything in Σ M Everything in K M Start symbol S Symbols and

57 13-55: L re L UG Configuration (Q, uaw) represented by the string: uaqw For example, (Q, abc a) is represented by the string abcq a

58 13-56: L re L UG For each element in δ M of the form: ((Q 1,a),(Q 2,b)) Add the rule: bq 2 aq 1 Remember, simulating backwards computation

59 13-57: L re L UG For each element in δ M of the form: ((Q 1,a),(Q 2, )) Add the rule: Q 2 a aq 1

60 13-58: L re L UG For each element in δ M of the form: ((Q 1, ),(Q 2, )) Add the rule Q 2 Q 1 (undoing erasing extra blanks)

61 13-59: L re L UG For each element in δ M of the form: ((Q 1,a),(Q 2, )) Add the rule abq 2 aq 1 b For all b Σ

62 13-60: L re L UG For each element in δ M of the form: ((Q 1,a),(Q 2, )) Add the rule a Q 2 aq 1 (undoing moving to the right onto unused tape)

63 13-61: L re L UG Finally, add the rules: S h Q s ǫ ǫ

64 13-62: L re L UG If the Turing machine can move from w to h Then the Grammar can transform Q h to Q s w Then, remove Q s and to leave w

65 13-63: L re L UG Example: Create a Turing Machine that accepts (ab), halting in the configuration (h, ) (assume tape starts out as w)

66 13-64: L re L UG Example: Create a Turing Machine that accepts (ab), halting in the configuration (h, ) L yes R a b R R a L a,b yes

67 13-65: L re L UG a b q 0 (q 1, ) (q 1, ) (q 1, ) q 1 (q 2, ) (q h, ) q 2 (q 3, ) q 3 (q 2, ) (q 4, ) q 4 (q 5, ) (q 5, ) (q h, ) (q 4, ) q 5

68 13-66: L re L UG ((q 0,a),(q 1, )) aaq 1 aq 0 a abq 1 aq 0 b a Q 1 aq 0 a Q 1 aq 0

69 13-67: L re L UG ((q 0,b),(q 1, )) baq 1 bq 0 a bbq 1 bq 0 b b Q 1 bq 0 b Q 1 bq 0

70 13-68: L re L UG ((q 0, ),(q 1, )) aq 1 Q 0 a bq 1 Q 0 b Q 1 Q 0 Q 1 Q 0

71 13-69: L re L UG ((q 1,a),(q 2, )) aaq 2 aq 1 a abq 2 aq 1 b a Q 2 aq 1 a Q 2 aq 1

72 13-70: L re L UG ((q 1, ),(q h, )) h Q 1

73 13-71: L re L UG ((q 2,b),(q 3, )) baq 3 bq 2 a bbq 3 bq 2 b b Q 3 bq 2 b Q 3 bq 2

74 13-72: L re L UG ((q 3,a),(q 4, )) aaq 4 aq 3 a abq 4 aq 3 b a Q 4 aq 3 a Q 4 aq 3

75 13-73: L re L UG ((q 4,a),(q 5, )) Q 5 aq 4 ((q 4,b),(q 5, )) Q 5 bq 4 ((q 4, ),(q h, )) h Q 4 ((q 5, ),(q 4, )) Q 4 Q 5

76 13-74: L re L UG S h aq 1 Q 0 a b Q 3 bq 2 Q 0 ǫ bq 1 Q 0 b b Q 3 bq 2 ǫ Q 1 Q 0 aaq 4 aq 3 a aaq 1 aq 0 a Q 1 Q 0 abq 4 aq 3 b abq 1 aq 0 b aaq 2 aq 1 a a Q 4 aq 3 a Q 1 aq 0 abq 2 aq 1 b a Q 4 aq 3 a Q 1 aq 0 a Q 2 aq 1 Q 5 aq 4 baq 1 bq 0 a a Q 2 aq 1 Q 5 bq 4 bbq 1 bq 0 b h Q 1 h Q 4 b Q 1 bq 0 baq 3 bq 2 a Q 4 Q 5 b Q 1 bq 0 bbq 3 bq 2 b

77 13-75: L re L UG Generating abab S h h Q 4 Q 4 Q 5 Q 5 aq 4 aq 4 a Q 5 a Q 5 abq 4 abq 4 ab Q 5 ab Q 5 abaq 4 abaq 4 aba Q 5 aba Q 5 ababq 4

78 13-76: L re L UG Generating abab ababq 4 abab Q 3 abab Q 3 ababq 2 ababq 2 abaq 3 b abaq 3 b abq 2 ab abq 2 ab aq 1 bab aq 1 bab Q 0 abab Q 0 abab abab abab abab

CA320 - Computability & Complexity

CA320 - Computability & Complexity CA320 - Computability & Complexity David Sinclair Context-Sensitive Grammars An unrestricted grammar is a 4-tuple G = (V,Σ,S,P), where V and Σ are disjoint sets of variables and terminals respectively.

More information

Automata Theory CS F-08 Context-Free Grammars

Automata Theory CS F-08 Context-Free Grammars Automata Theory CS411-2015F-08 Context-Free Grammars David Galles Department of Computer Science University of San Francisco 08-0: Context-Free Grammars Set of Terminals (Σ) Set of Non-Terminals Set of

More information

Context Sensitive Grammar

Context Sensitive Grammar Context Sensitive Grammar Aparna S Vijayan Department of Computer Science and Automation December 2, 2011 Aparna S Vijayan (CSA) CSG December 2, 2011 1 / 12 Contents Aparna S Vijayan (CSA) CSG December

More information

1 Unrestricted Computation

1 Unrestricted Computation 1 Unrestricted Computation General Computing Machines Machines so far: DFAs, NFAs, PDAs Limitations on how much memory they can use: fixed amount of memory plus (for PDAs) a stack Limitations on what they

More information

Automata Theory CS S-12 Turing Machine Modifications

Automata Theory CS S-12 Turing Machine Modifications Automata Theory CS411-2015S-12 Turing Machine Modifications David Galles Department of Computer Science University of San Francisco 12-0: Extending Turing Machines When we added a stack to NFA to get a

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

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

Theory of Computation - Module 3

Theory of Computation - Module 3 Theory of Computation - Module 3 Syllabus Context Free Grammar Simplification of CFG- Normal forms-chomsky Normal form and Greibach Normal formpumping lemma for Context free languages- Applications of

More information

Theory of Computation - Module 4

Theory of Computation - Module 4 Theory of Computation - Module 4 Syllabus Turing Machines Formal definition Language acceptability by TM TM as acceptors, Transducers - designing of TM- Two way infinite TM- Multi tape TM - Universal Turing

More information

Chapter 8. Turing Machine (TMs)

Chapter 8. Turing Machine (TMs) Chapter 8 Turing Machine (TMs) Turing Machines (TMs) Accepts the languages that can be generated by unrestricted (phrase-structured) grammars No computational machine (i.e., computational language recognition

More information

UNRESTRICTED GRAMMARS

UNRESTRICTED GRAMMARS 136 UNRESTRICTED GRAMMARS Context-free grammar allows to substitute only variables with strings In an unrestricted grammar (or a rewriting system) one may substitute any non-empty string (containing variables

More information

Introduction to Formal Languages, Automata and Computability p.1/42

Introduction to Formal Languages, Automata and Computability p.1/42 Introduction to Formal Languages, Automata and Computability Pushdown Automata K. Krithivasan and R. Rama Introduction to Formal Languages, Automata and Computability p.1/42 Introduction We have considered

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Chomsky Normal Form and TURING MACHINES TUESDAY Feb 4 CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form:

More information

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.

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. 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.(5m )( Dec-2014) 2. Obtain a DFA to accept strings of a s and b s having even

More information

TAFL 1 (ECS-403) Unit- IV. 4.1 Push Down Automata. 4.2 The Formal Definition of Pushdown Automata. EXAMPLES for PDA. 4.3 The languages of PDA

TAFL 1 (ECS-403) Unit- IV. 4.1 Push Down Automata. 4.2 The Formal Definition of Pushdown Automata. EXAMPLES for PDA. 4.3 The languages of PDA TAFL 1 (ECS-403) Unit- IV 4.1 Push Down Automata 4.2 The Formal Definition of Pushdown Automata EXAMPLES for PDA 4.3 The languages of PDA 4.3.1 Acceptance by final state 4.3.2 Acceptance by empty stack

More information

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0 Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0 Turing Machines Now for a machine model of much greater power.

More information

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4 Chomsky Normal Form and TURING MACHINES TUESDAY Feb 4 CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form: A BC A a S ε B and C aren t start variables a is

More information

Undecidable Problems and Reducibility

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

More information

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine) CS537 Theory of Computation Lecture : Computability Theory I (Turing Machine) Objectives Introduce the Turing Machine (TM) Proposed by Alan Turing in 936 finite-state control + infinitely long tape A stronger

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

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

More information

CA320 - Computability & Complexity

CA320 - Computability & Complexity CA320 - Computability & Complexity Dav Sinclair Context-Free Grammars A context-free grammar (CFG) is a 4-tuple G = (N,Σ,S,P) where N is a set of nonterminal symbols, or variables, Σ is a set of terminal

More information

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine) CS537 Theory of Computation Lecture : Computability Theory I (Turing Machine) Objectives Introduce the Turing Machine (TM)? Proposed by Alan Turing in 936 finite-state control + infinitely long tape A

More information

More Turing Machines. CS154 Chris Pollett Mar 15, 2006.

More Turing Machines. CS154 Chris Pollett Mar 15, 2006. More Turing Machines CS154 Chris Pollett Mar 15, 2006. Outline Multitape Turing Machines Nondeterministic Turing Machines Enumerators Introduction There have been many different proposals for what it means

More information

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014 Q.2 a. Show by using Mathematical Induction that n i= 1 i 2 n = ( n + 1) ( 2 n + 1) 6 b. Define language. Let = {0; 1} denote an alphabet. Enumerate five elements of the following languages: (i) Even binary

More information

Problem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y.

Problem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y. CSE2001, Fall 2006 1 Problem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y. S 00S1 A - xay, where x = 2 y.

More information

Section 1 (closed-book) Total points 30

Section 1 (closed-book) Total points 30 CS 454 Theory of Computation Fall 2011 Section 1 (closed-book) Total points 30 1. Which of the following are true? (a) a PDA can always be converted to an equivalent PDA that at each step pops or pushes

More information

Grammars and Context-free Languages; Chomsky Hierarchy

Grammars and Context-free Languages; Chomsky Hierarchy Regular and Context-free Languages; Chomsky Hierarchy H. Geuvers Institute for Computing and Information Sciences Version: fall 2015 H. Geuvers Version: fall 2015 Huygens College 1 / 23 Outline Regular

More information

(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},

(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}, Code No: 07A50501 R07 Set No. 2 III B.Tech I Semester Examinations,MAY 2011 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 80 Answer any FIVE Questions All

More information

CS21004 Formal Languages and Automata Theory, Spring

CS21004 Formal Languages and Automata Theory, Spring CS21004 Formal Languages and Automata Theory, Spring 2011 12 End-Semester Test Maximum marks: 60 Date: 20 Apr 2012 Duration: Three hours Roll no: Name: Write your answers in the question paper itself.

More information

Busch Complexity Lectures: Turing Machines. Prof. Busch - LSU 1

Busch Complexity Lectures: Turing Machines. Prof. Busch - LSU 1 Busch Complexity ectures: Turing Machines Prof. Busch - SU 1 The anguage Hierarchy a n b n c n? ww? Context-Free anguages n b n a ww egular anguages a* a *b* Prof. Busch - SU 2 a n b anguages accepted

More information

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

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 Recitation 11 Notes Context Free Grammars Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x A V, and x (V T)*. Examples Problem 1. Given the

More information

Fundamentele Informatica II

Fundamentele Informatica II Fundamentele Informatica II Answer to selected exercises 5 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 5.1.a (q 0, ab, Z 0 ) (q 1, b,

More information

7.2 Turing Machines as Language Acceptors 7.3 Turing Machines that Compute Partial Functions

7.2 Turing Machines as Language Acceptors 7.3 Turing Machines that Compute Partial Functions CSC4510/6510 AUTOMATA 7.1 A General Model of Computation 7.2 Turing Machines as Language Acceptors 7.3 Turing Machines that Compute Partial Functions A General Model of Computation Both FA and PDA are

More information

HW 3 Solutions. Tommy November 27, 2012

HW 3 Solutions. Tommy November 27, 2012 HW 3 Solutions Tommy November 27, 2012 5.1.1 (a) Online solution: S 0S1 ɛ. (b) Similar to online solution: S AY XC A aa ɛ b ɛ C cc ɛ X axb aa b Y by c b cc (c) S X A A A V AV a V V b V a b X V V X V (d)

More information

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

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine There is no known model of computation more powerful than Turing Machines Definition of Algorithm:

More information

Theory of Computation (Classroom Practice Booklet Solutions)

Theory of Computation (Classroom Practice Booklet Solutions) Theory of Computation (Classroom Practice Booklet Solutions) 1. Finite Automata & Regular Sets 01. Ans: (a) & (c) Sol: (a) The reversal of a regular set is regular as the reversal of a regular expression

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 8 January 24, 2018 Outline Turing Machines and variants multitape TMs nondeterministic TMs Church-Turing Thesis So far several models of computation finite automata

More information

The Post Correspondence Problem

The Post Correspondence Problem The Post Correspondence Problem - Given a set, P of pairs of strings: where t i, b i Σ P = {[ t 1 b 1 ], t 2 b 2 ],, t k b k ]} - Question: Does there exist a sequence i 1, i 2, i n such that: t i1 t i2

More information

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

Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove Tuesday 28 of May 2013 Total: 60 points TMV027/DIT321 registration VT13 TMV026/DIT321 registration before VT13 Exam

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 14 SMALL REVIEW FOR FINAL SOME Y/N QUESTIONS Q1 Given Σ =, there is L over Σ Yes: = {e} and L = {e} Σ Q2 There are uncountably

More information

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG) CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG) Objectives Recall that decidable languages are languages that can be decided by TM (that means,

More information

Turing Machines. Fall The Chinese University of Hong Kong. CSCI 3130: Formal languages and automata theory

Turing Machines. Fall The Chinese University of Hong Kong. CSCI 3130: Formal languages and automata theory The Chinese University of Hong Kong Fall 2011 CSCI 3130: Formal languages and automata theory Turing Machines Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130 Turing Machines control head a

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

Theory of Computation

Theory of Computation Theory of Computation Lecture #10 Sarmad Abbasi Virtual University Sarmad Abbasi (Virtual University) Theory of Computation 1 / 43 Lecture 10: Overview Linear Bounded Automata Acceptance Problem for LBAs

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

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

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

SFWR ENG 2FA3. Solution to the Assignment #4

SFWR ENG 2FA3. Solution to the Assignment #4 SFWR ENG 2FA3. Solution to the Assignment #4 Total = 131, 100%= 115 The solutions below are often very detailed on purpose. Such level of details is not required from students solutions. Some questions

More information

Turing Machines. The Language Hierarchy. Context-Free Languages. Regular Languages. Courtesy Costas Busch - RPI 1

Turing Machines. The Language Hierarchy. Context-Free Languages. Regular Languages. Courtesy Costas Busch - RPI 1 Turing Machines a n b n c The anguage Hierarchy n? ww? Context-Free anguages a n b n egular anguages a * a *b* ww Courtesy Costas Busch - PI a n b n c n Turing Machines anguages accepted by Turing Machines

More information

CSCC63 Worksheet Turing Machines

CSCC63 Worksheet Turing Machines 1 An Example CSCC63 Worksheet Turing Machines Goal. Design a turing machine, M that accepts only strings of the form {w#w w {0, 1} }. Idea. Describe in words how the machine would work. Read first symbol

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

The View Over The Horizon

The View Over The Horizon The View Over The Horizon enumerable decidable context free regular Context-Free Grammars An example of a context free grammar, G 1 : A 0A1 A B B # Terminology: Each line is a substitution rule or production.

More information

CPSC 313 Introduction to Computability

CPSC 313 Introduction to Computability CPSC 313 Introduction to Computability Grammars in Chomsky Normal Form (Cont d) (Sipser, pages 109-111 (3 rd ed) and 107-109 (2 nd ed)) Renate Scheidler Fall 2018 Chomsky Normal Form A context-free grammar

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

ECS 120 Lesson 20 The Post Correspondence Problem

ECS 120 Lesson 20 The Post Correspondence Problem ECS 120 Lesson 20 The Post Correspondence Problem Oliver Kreylos Wednesday, May 16th, 2001 Today we will continue yesterday s discussion of reduction techniques by looking at another common strategy, reduction

More information

Automata Theory - Quiz II (Solutions)

Automata Theory - Quiz II (Solutions) Automata Theory - Quiz II (Solutions) K. Subramani LCSEE, West Virginia University, Morgantown, WV {ksmani@csee.wvu.edu} 1 Problems 1. Induction: Let L denote the language of balanced strings over Σ =

More information

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

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

More information

Theory of Computation (IX) Yijia Chen Fudan University

Theory of Computation (IX) Yijia Chen Fudan University Theory of Computation (IX) Yijia Chen Fudan University Review The Definition of Algorithm Polynomials and their roots A polynomial is a sum of terms, where each term is a product of certain variables and

More information

Chapter 3: The Church-Turing Thesis

Chapter 3: The Church-Turing Thesis Chapter 3: The Church-Turing Thesis 1 Turing Machine (TM) Control... Bi-direction Read/Write Turing machine is a much more powerful model, proposed by Alan Turing in 1936. 2 Church/Turing Thesis Anything

More information

Theory of Computation

Theory of Computation Theory of Computation Lecture #2 Sarmad Abbasi Virtual University Sarmad Abbasi (Virtual University) Theory of Computation 1 / 1 Lecture 2: Overview Recall some basic definitions from Automata Theory.

More information

Turing machines and linear bounded automata

Turing machines and linear bounded automata and linear bounded automata Informatics 2A: Lecture 30 John Longley School of Informatics University of Edinburgh jrl@inf.ed.ac.uk 25 November 2016 1 / 17 The Chomsky hierarchy: summary Level Language

More information

Computability and Complexity

Computability and Complexity Computability and Complexity Push-Down Automata CAS 705 Ryszard Janicki Department of Computing and Software McMaster University Hamilton, Ontario, Canada janicki@mcmaster.ca Ryszard Janicki Computability

More information

CS 21 Decidability and Tractability Winter Solution Set 3

CS 21 Decidability and Tractability Winter Solution Set 3 CS 21 Decidability and Tractability Winter 2018 Posted: January 31 Solution Set 3 If you have not yet turned in the Problem Set, you should not consult these solutions. 1. (a) A 2-NPDA is a 7-tuple (Q,,

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

CSCI3390-Assignment 2 Solutions

CSCI3390-Assignment 2 Solutions CSCI3390-Assignment 2 Solutions due February 3, 2016 1 TMs for Deciding Languages Write the specification of a Turing machine recognizing one of the following three languages. Do one of these problems.

More information

Learning Context Free Grammars with the Syntactic Concept Lattice

Learning Context Free Grammars with the Syntactic Concept Lattice Learning Context Free Grammars with the Syntactic Concept Lattice Alexander Clark Department of Computer Science Royal Holloway, University of London alexc@cs.rhul.ac.uk ICGI, September 2010 Outline Introduction

More information

Automata Theory CS F-04 Non-Determinisitic Finite Automata

Automata Theory CS F-04 Non-Determinisitic Finite Automata Automata Theory CS411-2015F-04 Non-Determinisitic Finite Automata David Galles Department of Computer Science University of San Francisco 04-0: Non-Determinism A Deterministic Finite Automata s transition

More information

Most General computer?

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

More information

Equivalent Variations of Turing Machines

Equivalent Variations of Turing Machines Equivalent Variations of Turing Machines Nondeterministic TM = deterministic TM npda = pushdown automata with n stacks 2PDA = npda = TM for all n 2 Turing machines with n tapes (n 2) and n tape heads has

More information

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

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

More information

PART 3. CONTEXT FREE GRAMMARS AND PUSHDOWN AUTOMATA. FEATURES AND INDICES.

PART 3. CONTEXT FREE GRAMMARS AND PUSHDOWN AUTOMATA. FEATURES AND INDICES. PART 3. CONTEXT FREE GRAMMARS AND PUSHDOWN AUTOMATA. FEATURES AND INDICES. As we have seen, in a context free grammar, all rules are of the form Aα, with A V N and α V + (and allowing Se if the grammar

More information

CS 275 Automata and Formal Language Theory. Disclaimer. Course Notes Part II: The Recognition Problem (II) Chapter II.1: The Chomsky Hierarchy (12.

CS 275 Automata and Formal Language Theory. Disclaimer. Course Notes Part II: The Recognition Problem (II) Chapter II.1: The Chomsky Hierarchy (12. C 275 Automata and Formal Language Theory Course Notes Part II: The Recognition Problem (II) Chapter II.1: The Chomsky Hierarchy (12.1) Anton etzer (Based on a book draft by J. V. Tucker and K. tephenson)

More information

Equivalence of TMs and Multitape TMs. Theorem 3.13 and Corollary 3.15 By: Joseph Lauman

Equivalence of TMs and Multitape TMs. Theorem 3.13 and Corollary 3.15 By: Joseph Lauman Equivalence of TMs and Multitape TMs Theorem 3.13 and Corollary 3.15 By: Joseph Lauman Turing Machines First proposed by Alan Turing in 1936 Similar to finite automaton, but with an unlimited and unrestricted

More information

Turing Machines Part II

Turing Machines Part II Turing Machines Part II COMP2600 Formal Methods for Software Engineering Katya Lebedeva Australian National University Semester 2, 2016 Slides created by Katya Lebedeva COMP 2600 Turing Machines 1 Why

More information

Theory of Computer Science

Theory of Computer Science Theory of Computer Science C1. Formal Languages and Grammars Malte Helmert University of Basel March 14, 2016 Introduction Example: Propositional Formulas from the logic part: Definition (Syntax of Propositional

More information

Pushdown Automata. Reading: Chapter 6

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

More information

The Pumping Lemma (cont.) 2IT70 Finite Automata and Process Theory

The Pumping Lemma (cont.) 2IT70 Finite Automata and Process Theory The Pumping Lemma (cont.) 2IT70 Finite Automata and Process Theory Technische Universiteit Eindhoven May 4, 2016 The Pumping Lemma theorem if L Σ is a regular language then m > 0 : w L, w m : x,y,z : w

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

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

Context-Free Grammars and Languages. Reading: Chapter 5

Context-Free Grammars and Languages. Reading: Chapter 5 Context-Free Grammars and Languages Reading: Chapter 5 1 Context-Free Languages The class of context-free languages generalizes the class of regular languages, i.e., every regular language is a context-free

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/ Today's learning goals Sipser Ch 3 Trace the computation of a Turing machine using its transition function and configurations.

More information

Turing Machines. Chapter 17

Turing Machines. Chapter 17 Turing Machines Chapter 17 Languages and Machines SD D Context-Free Languages Regular Languages reg exps FSMs cfgs PDAs unrestricted grammars Turing Machines Grammars, SD Languages, and Turing Machines

More information

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012 Decision Problems with TM s Look at following sets: Lecture 31: Halting Problem CSCI 81 Spring, 2012 Kim Bruce A TM = { M,w M is a TM and w L(M)} H TM = { M,w M is a TM which halts on input w} TOTAL TM

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

Part I: Definitions and Properties

Part I: Definitions and Properties Turing Machines Part I: Definitions and Properties Finite State Automata Deterministic Automata (DFSA) M = {Q, Σ, δ, q 0, F} -- Σ = Symbols -- Q = States -- q 0 = Initial State -- F = Accepting States

More information

5.A Examples of Context-Free Grammars 3.1 and 3.2 of Du & Ko s book(pp )

5.A Examples of Context-Free Grammars 3.1 and 3.2 of Du & Ko s book(pp ) 5.A Examples of Context-Free Grammars 3.1 and 3.2 of Du & Ko s book(pp. 91-108) Example 3.1 Consider S ε asb. What is L(S)? Solution S asb aasbb a n Sb n a n b n. L(S) = {a n b n n 0} Example 3.2 Consider

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

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

Automata Theory (2A) Young Won Lim 5/31/18

Automata Theory (2A) Young Won Lim 5/31/18 Automata Theory (2A) Copyright (c) 2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

A Universal Turing Machine

A Universal Turing Machine A Universal Turing Machine A limitation of Turing Machines: Turing Machines are hardwired they execute only one program Real Computers are re-programmable Solution: Universal Turing Machine Attributes:

More information

CFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa.

CFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa. CFGs and PDAs are Equivalent We provide algorithms to convert a CFG to a PDA and vice versa. CFGs and PDAs are Equivalent We now prove that a language is generated by some CFG if and only if it is accepted

More information

Conflict Removal. Less Than, Equals ( <= ) Conflict

Conflict Removal. Less Than, Equals ( <= ) Conflict Conflict Removal As you have observed in a recent example, not all context free grammars are simple precedence grammars. You have also seen that a context free grammar that is not a simple precedence grammar

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

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

More information

Question Bank UNIT I

Question Bank UNIT I Siddhivinayak Technical Campus School of Engineering & Research Technology Department of computer science and Engineering Session 2016-2017 Subject Name- Theory of Computation Subject Code-4KS05 Sr No.

More information

Lecture 12: Mapping Reductions

Lecture 12: Mapping Reductions Lecture 12: Mapping Reductions October 18, 2016 CS 1010 Theory of Computation Topics Covered 1. The Language EQ T M 2. Mapping Reducibility 3. The Post Correspondence Problem 1 The Language EQ T M The

More information

Please give details of your answer. A direct answer without explanation is not counted.

Please give details of your answer. A direct answer without explanation is not counted. Please give details of your answer. A direct answer without explanation is not counted. Your answers must be in English. Please carefully read problem statements. During the exam you are not allowed to

More information

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

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

More information

More About Turing Machines. Programming Tricks Restrictions Extensions Closure Properties

More About Turing Machines. Programming Tricks Restrictions Extensions Closure Properties More About Turing Machines Programming Tricks Restrictions Extensions Closure Properties 1 Overview At first, the TM doesn t look very powerful. Can it really do anything a computer can? We ll discuss

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

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