Decidability (intro.)

Similar documents
Theory of Computation (IX) Yijia Chen Fudan University

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Computability Theory

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

ACS2: Decidability Decidability

acs-07: Decidability Decidability Andreas Karwath und Malte Helmert Informatik Theorie II (A) WS2009/10

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

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

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

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

UNIT-VIII COMPUTABILITY THEORY

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

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

Computability Theory

Decidability (What, stuff is unsolvable?)

} Some languages are Turing-decidable A Turing Machine will halt on all inputs (either accepting or rejecting). No infinite loops.

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

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

Decidable and undecidable languages

1 Showing Recognizability

Computability and Complexity

MTAT Introduction to Theoretical Computer Science

Variants of Turing Machine (intro)

Theory of Computation

Intro to Theory of Computation

V Honors Theory of Computation

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

CSE 105 THEORY OF COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

TURING MAHINES

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

Reducability. Sipser, pages

Mapping Reducibility. Human-aware Robotics. 2017/11/16 Chapter 5.3 in Sipser Ø Announcement:

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

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Decidable Languages - relationship with other classes.

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

CSE 105 THEORY OF COMPUTATION

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Computation Histories

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION

Introduction to Languages and Computation

CSE 105 THEORY OF COMPUTATION

CS20a: Turing Machines (Oct 29, 2002)

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

Homework Assignment 6 Answers

MA/CSSE 474 Theory of Computation

CPSC 421: Tutorial #1

Intro to Theory of Computation

Decidability and Undecidability

Non-emptiness Testing for TMs

Final exam study sheet for CS3719 Turing machines and decidability.

DM17. Beregnelighed. Jacob Aae Mikkelsen

Undecidable Problems and Reducibility

CS154, Lecture 10: Rice s Theorem, Oracle Machines

CSE 105 THEORY OF COMPUTATION

Theory of Computation (IV) Yijia Chen Fudan University

Computational Models Lecture 8 1

CP405 Theory of Computation

CS20a: Turing Machines (Oct 29, 2002)

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

Problems, and How Computer Scientists Solve Them Manas Thakur

Computational Models Lecture 8 1

CSE 105 THEORY OF COMPUTATION

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

1 Reducability. CSCC63 Worksheet Reducability. For your reference, A T M is defined to be the language { M, w M accepts w}. Theorem 5.

Computational Models Lecture 8 1

Undecidability. We are not so much concerned if you are slow as when you come to a halt. (Chinese Proverb)

Turing Machines Part III

CS481F01 Solutions 8

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

Announcements. Final exam review session tomorrow in Gates 104 from 2:15PM 4:15PM Final Friday Four Square of the quarter!

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

4.2 The Halting Problem

Introduction to Turing Machines. Reading: Chapters 8 & 9

CSCC63 Worksheet Turing Machines

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

Automata and Computability. Solutions to Exercises

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

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

Automata and Computability. Solutions to Exercises

CSE 105 THEORY OF COMPUTATION

Computability and Complexity

Asymptotic notation : big-o and small-o

CSE 105 Theory of Computation

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Turing Machines. Reading Assignment: Sipser Chapter 3.1, 4.2

Reading Assignment: Sipser Chapter 3.1, 4.2

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

NPDA, CFG equivalence

Exam Computability and Complexity

Properties of Context-Free Languages. Closure Properties Decision Properties

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

15-251: Great Theoretical Ideas in Computer Science Lecture 7. Turing s Legacy Continues

CSE 105 THEORY OF COMPUTATION

Part I: Definitions and Properties

Announcements. Using a 72-hour extension, due Monday at 11:30AM.

Transcription:

CHAPTER 4 Decidability Contents Decidable Languages decidable problems concerning regular languages decidable problems concerning context-free languages The Halting Problem The diagonalization method The halting problem is undecidable A Turing unrecognizable languages Theory of Computation, Feodor F. Dragan, Kent State University 1 Decidability (intro.) We have introduced Turing machines as a model of a general purpose computer We defined the notion of algorithm in terms of Turing machines by means of the Church-Turing thesis In this chapter we begin to investigate the power of algorithms to solve problems demonstrate certain problems that can be solved algorithmically and others that cannot Our objective is to explore the limits of algorithmic solvability Why should we study unsolvability? Showing that a problem is unsolvable doesn t appear to be of any use if we have to solve it. But We need to study this phenomenon for two reasons: First, knowing that a problem is algorithmically unsolvable is useful because then you realize that the problem must be simplified or altered before you can find an algorithmic solution. The second reason is cultural. Even if you deal with problems that clearly are solvable, a glimpse of the unsolvable can stimulate your imagination and help you gain an important perspective on computation. Theory of Computation, Feodor F. Dragan, Kent State University 2 1

Decidable Languages In this section we give some examples of languages that are decidable by algorithms. For example, we present an algorithm which tests whether a string is a member of a context-free language. This problem is related to the problem of recognizing and compiling programs in a programming language. Decidable Problems Concerning Regular Languages We begin with certain computation problems concerning finite automata We give algorithms for testing whether a finite automata accepts a string, whether the language of a finite automaton is empty, and whether two finite automata are equivalent. For convenience we use languages to represent various computational problems. For example, the acceptance problem for DFAs of testing whether a particular finite automaton accepts a given string can be expressed as a language,. = { < B, w > : B is a DFA that accepts input string w}. The problem of testing whether a DFA B accepts an input w is the same as the problem of testing whether <B,w> is a member of the language. Similarly, we can formulate other computational problems in terms of testing membership in a language. Showing that a language is decidable is the same as showing that the computation problem is decidable (= algorithmically solvable). Theory of Computation, Feodor F. Dragan, Kent State University 3 The Acceptance Problem for DFAs is Decidable Theorem 1 We present a TM M that decides. M = on input <B,w>, where B is a DFA and w is a string: 1. Simulate B on input w. 2. If the simulation ends in an accept state, accept. If it ends in a nonaccepting state, reject. A few implementation details: The input is <B,w>. It is a representation of a DFA B together with a string w. One reasonable representation of B is a list of its five components, Q, Σ, δ, q 0, F. When M receives its input, M first checks on whether it properly represents a DFA B and a string w. If not, it rejects. Then M carries out the simulation in a direct way. It keeps track of B s current state and B s current position in the input w. Initially, B s current state is q 0 and B s current position is the leftmost symbol of w. The states and position are updated according to the specified transition function δ. When M finishes processing the last symbol of w, M accepts if B is in an accepting state; M rejects if B is in a non-accepting state. Theory of Computation, Feodor F. Dragan, Kent State University 4 2

The Acceptance Problem for NFAs and REXs. We can prove similar result for NFAs and Regular Expressions. A NFA = { < B, w > : B is a NFA that accepts input string w}. Theorem 2: A NFA N = on input <B,w>, where B is a NFA and w is a string: 1. Convert NFA B to an equivalent DFA C using the procedure for this conversion given in Theorem subset construction. 2. Run TM M from Theorem 1 on input <C,w>. 3. If M accepts, accept, otherwise reject. Running TM M in stage 2 means incorporating M into the design of N as a subprocedure. A REX = { < R, w > : R is a regular Expression that generates string w}. Theorem 3: A REX P = on input <R,w>, where R is a reg.expr. and w is a string: 1. Convert R to an equivalent DFA C using the procedure for this conversion given in Theorem earlier. 2. Run TM M from Theorem 1 on input <C,w>. 3. If M accepts, accept, otherwise reject. Theory of Computation, Feodor F. Dragan, Kent State University 5 The Emptiness Problem for the Language of a Finite Automaton. Theorem 4: E DFA E DFA T = on input <A>, where A is a DFA : 1. Mark the start state of A. = { < A > : A is a DFA and L( = }. accepts some string if and only if reaching an accept state from the start state by traveling along the arrows of the DFA is possible. To test this condition we can design a TM T that uses marking algorithm similar to that used in example connectedness of a graph. 2. Repeat the following stage until no new states get marked: 3. Mark any state that has a transition coming into it from any state that is already marked. 4. If no accept state is marked, accept; otherwise reject. Theory of Computation, Feodor F. Dragan, Kent State University 6 3

The Equivalence Problem for Finite Automata. = { < A, B > : A and B are DFAs and L( B)}. Theorem 5: Consider a symmetric difference of L( and L(B), i.e a language L(C) Hence, L ( C) = if and only if L( B). The complement of L( We can construct C from A and B with the constructions for proving the class of regular languages closed under complementation, union, and intersection. These constructions are algorithms that can be carried out by Turing machines. F= on input <A,B>, where A,B are DFAs : 1. Construct DFA C as described. 2. Run TM T from theorem 4 on input <C>. 3. If T accepts, accept; if T rejects, reject. L( L(B) Theory of Computation, Feodor F. Dragan, Kent State University 7 Decidable Problems Concerning CFLs Here we describe algorithms to test whether a CFG generates a particular string and to test whether the language of a CFG is empty. Let A CFG = { < G, w > : G is a CFG that generates string w}. Theorem 6: A CFG For CFG G and string w we want to test whether G generates w. One idea is to use G to go through all derivations to determine whether any is a derivation of w. This idea doesn t work, as infinitely many derivations may have to be tried. If G does not generate w, this algorithm would never halt. Hence this idea gives a TM which is recognizer, not a decider. To make this TM into a decider we need to ensure that the algorithm tries only finite many derivations. If G is in Chomsky normal form, any derivation of w has 2n-1 steps, where n is the length of w. Only finite many such derivations exist. We present a TM S that decides A CFG. S = on input <G,w>, where G is a CFG and w is a string: 1. Convert G to an equivalent grammar in Chomsky normal form. 2. List all derivations with 2n-1 steps, where n is the length of w, except if n=0, then instead list all derivations with 1 step. 3. If any of these derivations generate w, accept; if not, reject. Theory of Computation, Feodor F. Dragan, Kent State University 8 4

Here we describe an algorithm to test whether the language of a CFG is empty. Let Decidable Problems Concerning CFLs(cont.) E CFG Theorem 7: = { < G > : G is a CFG and L( G) = }. E CFG For CFG G we need to test whether the start variable can generate a string of terminals. The algorithm does so by solving a more general problem. It determines for each variable whether that variable is capable of generating a string of terminals. When the algorithm has determined that a variable can generate some string of terminals, the algorithm keeps track of this information by placing a mark on that variable. First the algorithm marks all terminal symbols in the grammar. Then it scans all the rules of the grammar. If it ever finds a rule that permits some variable to be replaced by some string of symbols all of which are already marked, the algorithm knows that this variable can be marked, too. The algorithm continues in this way until it cannot mark any additional variables. The TM R implements this algorithm. R = on input <G>, where G is a CFG: 1. Mark all terminals in G. Repeat (2) until no new variables get marked: 2. Mark any variable A where G has a rule A U and each 1U 2... U k symbol U U,..., has already been marked. 1, 2 U k 3. If the start symbol is not marked, accept; otherwise reject. Theory of Computation, Feodor F. Dragan, Kent State University 9 Decidable Problems Concerning CFLs(cont.) Let EQ CFG = { < G, H > : G and H are CFGs and L( G) H )}. This language is undecidable (we cannot apply technique used in the class of CFLs is not closed under complementation and intersection). is decidable ; We can prove now the following. Theorem 8: Every CFL is decidable. Let A be a CFL and G be a CFG for A. Turing-recognizable decidable Here is a TM M(G) that decides A. We build a copy of G into M(G). S is a TM from Theorem 6. M(G) = on input w: 1. Run TM S on input <G,w> 2. If this machine accepts, accept; if it rejects, reject. context-free regular Theory of Computation, Feodor F. Dragan, Kent State University 10 5