Automata Theory CS F-13 Unrestricted Grammars

Similar documents
CA320 - Computability & Complexity

Automata Theory CS F-08 Context-Free Grammars

Context Sensitive Grammar

1 Unrestricted Computation

Automata Theory CS S-12 Turing Machine Modifications

Theory of Computation Turing Machine and Pushdown Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Theory of Computation - Module 3

Theory of Computation - Module 4

Chapter 8. Turing Machine (TMs)

UNRESTRICTED GRAMMARS

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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.

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

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

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Undecidable Problems and Reducibility

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CA320 - Computability & Complexity

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

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

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

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.

Section 1 (closed-book) Total points 30

Grammars and Context-free Languages; Chomsky Hierarchy

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

CS21004 Formal Languages and Automata Theory, Spring

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

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

Fundamentele Informatica II

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

HW 3 Solutions. Tommy November 27, 2012

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

Theory of Computation (Classroom Practice Booklet Solutions)

CS21 Decidability and Tractability

The Post Correspondence Problem

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

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

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

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Theory of Computation

Automata and Computability. Solutions to Exercises

CSE 105 THEORY OF COMPUTATION

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

SFWR ENG 2FA3. Solution to the Assignment #4

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

CSCC63 Worksheet Turing Machines

MA/CSSE 474 Theory of Computation

The View Over The Horizon

CPSC 313 Introduction to Computability

Automata and Computability. Solutions to Exercises

ECS 120 Lesson 20 The Post Correspondence Problem

Automata Theory - Quiz II (Solutions)

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

Theory of Computation (IX) Yijia Chen Fudan University

Chapter 3: The Church-Turing Thesis

Theory of Computation

Turing machines and linear bounded automata

Computability and Complexity

CS 21 Decidability and Tractability Winter Solution Set 3

CpSc 421 Final Exam December 15, 2006

CSCI3390-Assignment 2 Solutions

Learning Context Free Grammars with the Syntactic Concept Lattice

Automata Theory CS F-04 Non-Determinisitic Finite Automata

Most General computer?

Equivalent Variations of Turing Machines

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

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

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

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

Turing Machines Part II

Theory of Computer Science

Pushdown Automata. Reading: Chapter 6

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

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

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Context-Free Grammars and Languages. Reading: Chapter 5

CSE 105 THEORY OF COMPUTATION

Turing Machines. Chapter 17

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

Languages, regular languages, finite automata

Part I: Definitions and Properties

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

Introduction to Theory of Computing

CISC4090: Theory of Computation

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

A Universal Turing Machine

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

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Question Bank UNIT I

Lecture 12: Mapping Reductions

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

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

More About Turing Machines. Programming Tricks Restrictions Extensions Closure Properties

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

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

Transcription:

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

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

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

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

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

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

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

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 ǫ

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

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

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

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-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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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?

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

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..

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

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

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

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

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

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)

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 Σ

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)

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

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

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)

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

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

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

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

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

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

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

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

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

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

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

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

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