FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Similar documents
Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

TURING MAHINES

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Chapter 3: The Church-Turing Thesis

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

Theory of Computation (IX) Yijia Chen Fudan University

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

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

CS21 Decidability and Tractability

Decidability (What, stuff is unsolvable?)

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

Turing Machines (TM) The Turing machine is the ultimate model of computation.

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

CSCC63 Worksheet Turing Machines

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

Turing Machines A Turing Machine is a 7-tuple, (Q, Σ, Γ, δ, q0, qaccept, qreject), where Q, Σ, Γ are all finite

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

The Church-Turing Thesis

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

V Honors Theory of Computation

Computability Theory. CS215, Lecture 6,

Theory of Computation Turing Machine and Pushdown Automata

DM17. Beregnelighed. Jacob Aae Mikkelsen

Introduction to Turing Machines. Reading: Chapters 8 & 9

Intro to Theory of Computation

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

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Decidability (intro.)

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Turing Machines. 22c:135 Theory of Computation. Tape of a Turing Machine (TM) TM versus FA, PDA

Turing machines and linear bounded automata

Chapter 8. Turing Machine (TMs)

UNRESTRICTED GRAMMARS

1 Showing Recognizability

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

SCHEME FOR INTERNAL ASSESSMENT TEST 3

Question Bank UNIT I

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 16 : Turing Machines

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

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

Reducability. Sipser, pages

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 14 : Turing Machines

Final exam study sheet for CS3719 Turing machines and decidability.

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

Turing machines and linear bounded automata

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

CS154, Lecture 10: Rice s Theorem, Oracle Machines

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

Theory of Computation

Automata and Computability. Solutions to Exercises

CSE 105 THEORY OF COMPUTATION

ACS2: Decidability Decidability

Undecidable Problems and Reducibility

UNIT-VIII COMPUTABILITY THEORY

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

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

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

Decidable and undecidable languages

Turing machines and linear bounded automata

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

CS 154 NOTES MOOR XU NOTES FROM A COURSE BY LUCA TREVISAN AND RYAN WILLIAMS

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

TAKE-HOME: OUT 02/21 NOON, DUE 02/25 NOON

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2016, face-to-face day section Prof. Marvin K. Nakayama

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

Chap. 4,5 Review. Algorithms created in proofs from prior chapters

The Turing machine model of computation

NPDA, CFG equivalence

CSE 105 THEORY OF COMPUTATION

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Automata and Computability. Solutions to Exercises

CSE 105 THEORY OF COMPUTATION

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Computability and Complexity

CSE 105 THEORY OF COMPUTATION

Theory of Computation p.1/?? Theory of Computation p.2/?? We develop examples of languages that are decidable

60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor

Functions on languages:

Foundations of Informatics: a Bridging Course

Introduction to Turing Machines

Decidability. Overview. Preliminaries to Halting Problem. Decidable Problems of Regular Languages. Decidable Problems of Context-Free Languages

Theory of Computation

Computability and Complexity

Chapter 5. Finite Automata

CSCE 551 Final Exam, Spring 2004 Answer Key

Most General computer?

Context Free Grammars

CPSC 421: Tutorial #1

I have read and understand all of the instructions below, and I will obey the University Code on Academic Integrity.

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

CS4026 Formal Models of Computation

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

Theory of Computation - Module 4

Transcription:

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: A BC A a S ε B and C aren t start variables a is a terminal S is the start variable Any variable A that is not the start variable can only generate strings of length > 0

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 a terminal S is the start variable S 0S1 S TT T ε S 0 TU TV ε T 0 U SV S TU TV V 1

Theorem: If G is in CNF, w L(G) and w > 0, then any derivation of w in G has length 2 w - 1 Proof (by induction on w ): Base Case: If w = 1, then any derivation of w must have length 1 Inductive Step: Assume true for any string of length at most k 1, and let w = k+1 Since w > 1, derivation starts with A BC So w = xy where B * x, x > 0 and C * y, y > 0 By the inductive hypothesis, the length of any derivation of w must be 1 + (2 x - 1) + (2 y - 1) = 2( x + y ) - 1

Theorem: Any context-free language can be generated by a context-free grammar in Chomsky normal form Can transform any CFG into Chomsky normal form

Theorem: Any context-free language can be generated by a context-free grammar in Chomsky normal form Proof Idea: 1. Add a new start variable 2. Eliminate all A ε rules. Repair grammar 3. Eliminate all A B rules. Repair 4. Convert A u 1 u 2... u k to A u 1 A 1, A 1 u 2 A 2,... If u i is a terminal, replace u i with U i and add U i u i

1. Add a new start variable S 0 and add the rule S 0 S S 0S1 S T#T S T T ε

1. Add a new start variable S 0 and add the rule S 0 S S 0 S S 0S1 S T#T S T T ε

2. Remove all A ε rules (where A is not S 0 ) For each occurrence of A on right hand side of a rule, add a new rule with the occurrence deleted If we have the rule B A, add B ε, unless we have previously removed B ε S 0 S S 0S1 S T#T S T T ε S T# S #T S # S 01 S 0 ε

2. Remove all A ε rules (where A is not S 0 ) For each occurrence of A on right hand side of a rule, add a new rule with the occurrence deleted If we have the rule B A, add B ε, unless we have previously removed B ε 3. Remove unit rules A B Whenever B w appears, add the rule A w unless this was a unit rule previously removed S 0 S S 0S1 S T#T S T T ε S T# S #T S # S 01 S 0 ε S 0 0S1

4. Convert all remaining rules into the proper form: S 0 0S1 S 0 A 1 A 2 A 1 0 A 2 SA 3 A 3 1 S 0 01 S 0 A 1 A 3 S 01 S A 1 A 3 S 0 ε S 0 0S1 S 0 T#T S 0 T# S 0 #T S 0 # S 0 01 S 0S1 S T#T S T# S #T S # S 01

Convert the following into Chomsky normal form: A BAB B ε B 00 ε S 0 A A BAB B ε B 00 ε S 0 A ε A BAB B BB AB BA B 00 S 0 BAB 00 BB AB BA ε A BAB 00 BB AB BA B 00 S 0 BC DD BB AB BA ε, C AB, A BC DD BB AB BA, B DD, D 0

TURING MACHINE FINITE STATE CONTROL I N P U T INFINITE TAPE

read write move 0 0, R, R q accept, R 0 0, R q reject

read write move 0 0, R, R q accept, R 0 0, R 0 0, R, L

TMs VERSUS FINITE AUTOMATA TM can both write to and read from the tape The head can move left and right The input doesn t have to be read entirely, and the computation can continue after all the input has been read Accept and Reject take immediate effect

Definition: A Turing Machine is a 7-tuple T = (Q, Σ, Γ, δ, q 0, q accept, q reject ), where: Q is a finite set of states Σ is the input alphabet, where Σ Γ is the tape alphabet, where Γ and Σ Γ δ : Q Γ Q Γ {L, R} q 0 Q is the start state q accept Q is the accept state q reject Q is the reject state, and q reject q accept

CONFIGURATIONS 11010q 7 00110 corresponds to: q 7 1 1 0 1 0 0 0 1 1 0

A Turing Machine M accepts input w if there is a sequence of configurations C 1,, C k such that 1. C 1 is a start configuration of M on input w, ie C 1 is q 0 w 2. each C i yields C i+1, ie M can legally go from C i to C i+1 in a single step ua q i bv yields u q j acv if δ (q i, b) = (q j, c, L) ua qi bv yields uac q j v if δ (q i, b) = (q j, c, R)

A Turing Machine M accepts input w if there is a sequence of configurations C 1,, C k such that 1. C 1 is a start configuration of M on input w, ie C 1 is q 0 w 2. each C i yields C i+1, ie M can legally go from C i to C i+1 in a single step 3. C k is an accepting configuration, ie the state of the configuration is q accept

A TM recognizes a language iff it accepts all and only those strings in the language A language L is called Turing-recognizable or recursively enumerable or semidecidable iff some TM recognizes L A TM decides a language L iff it accepts all strings in L and rejects all strings not in L A language L is called decidable or recursive iff some TM decides L

A language is called Turing-recognizable or recursively enumerable (r.e.) or semidecidable if some TM recognizes it A language is called decidable or recursive if some TM decides it r.e. languages recursive languages Theorem: If A and A are r.e. then A is recursive

Theorem: If A and A are r.e. then A is recursive Given: a TM that recognizes A and a TM that recognizes A, we can build a new machine that decides A

2 { 0 n n 0 } Is decidable PSEUDOCODE: 1. Sweep from left to right, cross out every other 0 2. If in stage 1, the tape had only one 0, accept 3. If in stage 1, the tape had an odd number of 0 s, reject 4. Move the head back to the first input symbol. 5. Go to stage 1.

2 { 0 n n 0 } x x, L 0 0, L q 2 x x, R, R, L x x, R q 0 q 1 0, R 0 x, R q 3 x x, R, R, R 0 x, R 0 0, R q reject q accept q 4, R x x, R

2 { 0 n n 0 } Is decidable q 0 0000 q 1 000 xq 3 00 x0q 4 0 x0xq 3 x0q 2 x xq 2 0x q 2 x0x q 2 x0x

C = {a i b j c k k = ij, and i, j, k 1} PSEUDOCODE: 1. If the input doesn t match a*b*c*, reject. 2. Move the head back to the leftmost symbol. 3. Cross off an a, scan to the right until b. Sweep between b s and c s, crossing off one of each until all b s are crossed off. 4. Uncross all the b s. If there s another a left, then repeat stage 3. If all a s are crossed out, Check if all c s are crossed off. If yes, then accept, else reject.

C = {a i b j c k k = ij, and i, j, k 1} aabbbcccccc xabbbcccccc xayyyzzzccc xabbbzzzccc xxyyyzzzzzz

MULTITAPE TURING MACHINES FINITE STATE CONTROL δ : Q Γ k Q Γ k {L,R} k

Theorem: Every Multitape Turing Machine can be transformed into a single tape Turing Machine 1 0 0 FINITE STATE CONTROL FINITE STATE CONTROL... 1 0 0 # # #

Theorem: Every Multitape Turing Machine can be transformed into a single tape Turing Machine 1 0 0 FINITE STATE CONTROL FINITE STATE CONTROL... 1 0 0 # # #

THE CHURCH-TURING THESIS Intuitive Notion of Algorithms EQUALS Turing Machines

We can encode a TM as a string of 0s and 1s n states start state reject state 0 n 10 m 10 k 10 s 10 t 10 r 10 u 1 m tape symbols (first k are input symbols) accept state blank symbol ( (p, a), (q, b, L) ) = 0 p 10 a 10 q 10 b 10 ( (p, a), (q, b, R) ) = 0 p 10 a 10 q 10 b 11

Similarly, we can encode DFAs, NFAs, CFGs, etc. into strings of 0s and 1s So we can define the following languages: A DFA = { (B, w) B is a DFA that accepts string w } A NFA = { (B, w) B is an NFA that accepts string w } A CFG = { (G, w) G is a CFG that generates string w }

Similarly, we can encode DFAs, NFAs, CFGs, etc. into strings of 0s and 1s So we can define the following languages: A DFA = { (B, w) B is a DFA that accepts string w } Theorem: A DFA is decidable Proof Idea: Simulate B on w A NFA = { (B, w) B is an NFA that accepts string w } Theorem: A NFA is decidable A CFG = { (G, w) G is a CFG that generates string w } Theorem: A CFG is decidable Proof Idea: Transform G into Chomsky Normal Form. Try all derivations of length up to 2 w -1

WWW.FLAC.WS Read Chapter 3 of the book for next time