3515ICT Theory of Computation Decidability

Similar documents
The Halting Problem is Undecidable

3515ICT Theory of Computation Turing Machines

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

Model 2.4 Faculty member + student

Overview of E0222: Automata and Computability

Automata and Computability. Solutions to Exercises

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

CS 3719 (Theory of Computation and Algorithms) Lecture 4

Computational Models Lecture 8, Spring 2009

24 Uses of Turing Machines

Chapter 7 Uncomputability

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

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

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

Course Manual Automata & Complexity 2015

Turing Machines: An Introduction

Introduction to Automata Theory. Reading: Chapter 1

Computability Theory

Notes on Complexity Theory Last updated: August, Lecture 1

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

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

6.080/6.089 GITCS Feb 12, Lecture 3

Implementation of Recursively Enumerable Languages using Universal Turing Machine in JFLAP

CS 301 Course Information

Informatique Fondamentale IMA S8

Approximating Context-Free Grammars for Parsing and Verification

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

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

Regular Expressions and Automata using Haskell

How To Compare A Markov Algorithm To A Turing Machine

Introduction to Theory of Computation

How to make the computer understand? Lecture 15: Putting it all together. Example (Output assembly code) Example (input program) Anatomy of a Computer

CS5236 Advanced Automata Theory

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

Compiler Construction

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

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

Theory of Computation Chapter 2: Turing Machines

Finite Automata. Reading: Chapter 2

Scanner. tokens scanner parser IR. source code. errors

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

T Reactive Systems: Introduction and Finite State Automata

Automata and Formal Languages

Finite Automata. Reading: Chapter 2

The Model Checker SPIN

FINITE STATE AND TURING MACHINES

How To Understand The Theory Of Computer Science

Complexity Theory. Jörg Kreiker. Summer term Chair for Theoretical Computer Science Prof. Esparza TU München

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

CAs and Turing Machines. The Basis for Universal Computation

CS143 Handout 08 Summer 2008 July 02, 2007 Bottom-Up Parsing

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

NP-Completeness and Cook s Theorem

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

Lecture 2: Universality

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

Turing Machines, Part I

CS5310 Algorithms 3 credit hours 2 hours lecture and 2 hours recitation every week

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

Finite Automata and Formal Languages

Automata on Infinite Words and Trees

Reading 13 : Finite State Automata and Regular Expressions

Complexity Classes P and NP

Algebraic Computation Models. Algebraic Computation Models

Introduction to Turing Machines

CHAPTER 7 GENERAL PROOF SYSTEMS

Genetic programming with regular expressions

Regular Languages and Finite Automata

Computer Science Theory. From the course description:

THE TURING DEGREES AND THEIR LACK OF LINEAR ORDER

MATHEMATICS: CONCEPTS, AND FOUNDATIONS Vol. III - Logic and Computer Science - Phokion G. Kolaitis

Bottom-Up Syntax Analysis LR - metódy

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

Computer Architecture Syllabus of Qualifying Examination

Basic Parsing Algorithms Chart Parsing

10.2 Series and Convergence

The Classes P and NP

1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification)

C H A P T E R Regular Expressions regular expression

Universal Turing Machine: A Model for all Computational Problems

Deterministic Finite Automata


Regular Languages and Finite State Machines

Computing exponents modulo a number: Repeated squaring

Welcome to... Problem Analysis and Complexity Theory , 3 VU

Omega Automata: Minimization and Learning 1

Lecture summary for Theory of Computation

CMPSCI611: Approximating MAX-CUT Lecture 20

Handout #1: Mathematical Reasoning

Remarks on the computational complexity of small universal Turing machines

NFAs with Tagged Transitions, their Conversion to Deterministic Automata and Application to Regular Expressions

5.1 Bipartite Matching

Introduction to Logic in Computer Science: Autumn 2006

Prime Numbers. Difficulties in Factoring a Number: from the Perspective of Computation. Computation Theory. Turing Machine 電 腦 安 全

Polarization codes and the rate of polarization

Enforcing Security Policies. Rahul Gera

Transcription:

Griffith University 3515ICT Theory of Computation Decidability (Based loosely on slides by Harald Søndergaard of The University of Melbourne) 12-0

Decidable Problems We are interested in algorithms for deciding problems about languages. Examples of such questions are: Is a given string in a given regular language? Is a given regular language empty? Is a given context-free language finite? Is a given context-free language a subset of another context-free language? Is a given context-free language deterministic? Is a given language Turing-decidable? In answering such questions, we may assume the languages are presented as regular expressions, finite automata, context-free grammars, Turing machines, etc. 12-1

Decidable Problems (cont.) Interesting problems regarding regular languages are generally decidable. For example, the acceptance problem for DFAs is decidable: given a DFA D and a string w, does D accept w? Since we can encode a DFA D as a string D, the acceptance problem is equivalent to testing for membership in the language A DFA = { D, w D is a DFA that accepts w } The acceptance problem is called decidable if the corresponding language is (Turing-)decidable. Problems about context-free languages may or may not be decidable. Problems about Turing machines are most commonly undecidable. 12-2

DFA Acceptance Is Decidable Theorem. A DFA = { D, w D is a DFA that accepts w } is a decidable language. Proof outline. The crucial point is that it is possible for a Turing machine M to simulate a DFA D. M starts with D, w on its tape, e.g., 1...73 }{{} Q ## ab...z ## 1a2#1b3#... ## 1 }{{}}{{}}{{} Σ δ ## 13#29 }{{} q 0 First M checks that the first five components represent a valid DFA, and if not, rejects. When the last symbol in w has been read, M accepts if D is in a state in F, and rejects otherwise. F ## ba... $ }{{} w Then M simulates the moves of D, keeping track of D s state and the current position in w, by writing these details on its tape, after $, or on a second tape. 12-3

TMs as Interpreters We did not show the details of how a Turing machine goes about simulating a DFA D. Many low-level programming steps are involved. However, it should be clear that it is possible for a Turing machine to model DFA behaviour this way. The description of D is nothing but a program and the a Turing machine can act as an interpreter for this language. Later, we shall see that Turing machines themselves can be encoded as strings, and that one Turing machine can interpret other Turing machines. This is no more strange than the fact that we can write an interpreter for Scheme, say, in Scheme. 12-4

NFA Acceptance Is Decidable Theorem. A NFA = { N, w N is a NFA that accepts w } is a decidable language. Proof outline. The procedure we gave for translating an NFA to an equivalent DFA was mechanical and terminating, so a halting Turing machine can do the translation. Thus, to recognise whether a given N, w pair is in A NFA, a Turing machine can: 1. Transform the NFA N to an equivalent DFA D; 2. Run the TM M from the previous theorem on input D, w. 3. If M accepts, accept, otherwise reject. 12-5

Reg. Exp. Acceptance is Decidable Theorem. A REX = { E, w E is a regular expression and w L(E) } is a decidable language. Proof. By translating E into a DFA D and again using the Turing machine M. Thus, in principle, it does not matter whether we describe a regular language L by a DFA, an NFA or a regular expression, the problem of deciding whether a string w is in L is decidable. In practice, e.g., in editors and compilers, we describe regular languages by regular expressions, and acceptance is performed by transforming the regular expression to an equivalent NFA, and simulating the behaviour of the NFA by maintaining the set of states it could be in after reading each successive input symbol. 12-6

DFA Emptiness Is Decidable Theorem. E DFA = { D D is a DFA and L(D) = } is decidable. Proof outline. We can design a Turing machine which takes D = (Q, Σ, δ, q 0, F) as input and performs a reachability analysis: 1. Set reachable = {q 0 }, D s start state. 2. Set new = { q m reachable and δ(m, x) = q } \ reachable 3. If new, set reachable = reachable new, and go to step 2. 4. If reachable F, accept, otherwise reject. 12-7

DFA Finiteness Is Decidable Theorem. FINITE DFA = { A A is a DFA and L(A) is finite } is decidable. Proof. See Sipser, Problem 4.9. 12-8

DFA Equivalence Is Decidable Theorem. EQ DFA = { A, B A and B are DFAs and L(A) = L(B)} is decidable. Proof outline. We previously saw how it is possible to construct, from DFAs A and B, DFAs for L(A) L(B), L(A) L(B), and L(A). These procedures are mechanistic and finite a halting Turing machine M can perform them. Hence from DFAs A and B, M can produce a DFA C to recognise L(C) = ( L(A) L(B) ) ( L(A) L(B) ) Note that L(C) = iff L(A) = L(B). Finally, M runs the Turing machine M E to test whether the constructed DFA C is empty, and accept iff M E accepts. 12-9

Generation by CFGs Is Decidable Theorem. A CFG = { G, w G is a CFG that generates w } is decidable. Proof. We can put a bound on the number of derivation steps needed to derive any w L(G). First transform G to an equivalent grammar G in Chomsky Normal Form. So every rule is of form A B C or A a. Let w = n. To derive w we need to use rules of the first form n 1 times, and rules of the second form n times. So any derivation of w has exactly 2n 1 steps. A Turing machine can therefore take G and w, transform G to G, generate all derivations of length 2n 1, and accept iff any one of these generates w. 12-10

Ugh! Generating all possible derivations to see if a string is in a CFL is not very efficient! A more practical parser for arbitrary CFGs is the dynamic programming algorithm described in Sipser, Theorem 7.16, which is O(n 3 ), where n = w. The most practical parser for arbitrary CFGs is Early s parser. Any deterministic language can be parsed in O(n) time, using Knuth s LR(k) parser. Practical (deterministic) languages can be parsed in O(n) time using LALR(1) or SLR(1) parsers. I.e., parsing practical CFLs is as efficient as parsing regular languages. 12-11

CFG Emptiness Is Decidable Theorem. E CFG = { G G is a CFG and L(G) = } is decidable. Proof. We can design a Turing machine which takes G = (V, Σ, R, S) as input and performs a producer analysis: 1. Set producers = Σ, all of G s terminals. 2. Set new = A A U 1 U n R, {U 1,...,U n } producers \producers 3. If new, set producers = producers new, and go to step 2. 4. If S producers, accept, otherwise reject. 12-12

CFG Finiteness Is Decidable Theorem. FINITE CFG = { G G is a CFG and L(G) is finite } is decidable. Proof. See Sipser, Problem 4.10. 12-13

Every CFL Is Decidable Several slides back we saw that it is decidable whether a CFG G generates a string w. The deciding Turing machine, S, thus took G, w as input. Now we are claining that any particular CFL L 0 is decidable: Theorem. Every context-free language L 0 is decidable. Proof. This amounts to saying that we can specialise (or partially evaluate) S. If L 0 has a grammar G 0, the decider for L 0 simply takes input w and runs S on G 0, w. 12-14

Every CFL Is Decidable (cont.) Turing recognisable (c.e.) Decidable Context-free Regular Are there c.e. languages that are not decidable? Are there any languages that are not c.e.? 12-15

Undecidable CFL Problems Context-free languages are much more complex than regular languages. The following problems (which are decidable for regular languages) are undecidable for context-free languages. Equality: The language EQ CFG = { G, H G and H are CFLs and L(G) = L(H) } is undecidable. Ambiguity: The language AMB CFG = { G G is an ambiguous CFG } is undecidable. (Have pity on the poor TOC lecturer trying to decide whether his students grammars generate the correct language or are unambiguous.) 12-16

More Decidable Problems Is natural number n 2 a prime? Is every even natural number n > 2 the sum of two primes? (Goldbach) Is there a path from node x to node y in directed graph G? Is graph G 1 isomorphic to a subgraph of graph G 2? Is propositional formula P is a tautology? Are terms s and t are unifiable? Many, many more. 12-17

More Decidable Problems (cont.) As far as decidability is concerned, a problem is only interesting if it is parameterised, i.e., if it has infinitely many instances. Below is the Turing machine that decides: Is every even natural number n > 2 the sum of two primes? q a q r q r q a Currently we don t know which of these two it is, but in any case it is a simple Turing machine! 12-18