1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.

Slides:



Advertisements
Similar presentations
Introduction to Computability Theory
Advertisements

Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
1 Introduction to Computability Theory Lecture14: Recap Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture15: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture5: Context Free Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture13: Mapping Reductions Prof. Amos Israeli.
Decidable languages Sipser 4.1 (pages ). CS 311 Mount Holyoke College 2 Hierarchy of languages All languages Turing-recognizable Turing-decidable.
CS5371 Theory of Computation
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata (cont.) Prof. Amos Israeli.
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
Decidability. Why study un-solvability? When a problem is algorithmically unsolvable, we realize that the problem must be simplified or altered before.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
CHAPTER 4 Decidability Contents Decidable Languages
CS 310 – Fall 2006 Pacific University CS310 Decidability Section 4.1/4.2 November 10, 2006.
Foundations of (Theoretical) Computer Science Chapter 4 Lecture Notes (Section 4.1: Decidable Languages) David Martin With modifications.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
1 Introduction to Computability Theory Lecture11: The Halting Problem Prof. Amos Israeli.
CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)
TM Design Universal TM MA/CSSE 474 Theory of Computation.
Pushdown Automata (PDAs)
Computer Language Theory
Computability Construct TMs. Decidability. Preview: next class: diagonalization and Halting theorem.
Theory of Computation 6. Turing Machines Romi Satria Wahono Mobile:
Decidable languages Section 4.1 CSC 4170 Theory of Computation.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
CSCI 2670 Introduction to Theory of Computing October 12, 2005.
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
D E C I D A B I L I T Y 1. 2 Objectives To investigate the power of algorithms to solve problems. To explore the limits of algorithmic solvability. To.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
Computability Review homework. Video. Variations. Definitions. Enumerators. Hilbert's Problem. Algorithms. Summary Homework: Give formal definition of.
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 4 Decidability Some slides are in courtesy.
 2004 SDU 1 Algorithm Informally speaking, an algorithm is a collection of simple instructions for carrying out a task. Example:  Elementary arithmetic.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
 2005 SDU Lecture11 Decidability.  2005 SDU 2 Topics Discuss the power of algorithms to solve problems. Demonstrate that some problems can be solved.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Decidable.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
PDAs Accept Context-Free Languages
CSE 105 theory of computation
BCS 2143 Theory of Computer Science
CSE 2001: Introduction to Theory of Computation Fall 2013
CSCI 2670 Introduction to Theory of Computing
Chapter 2 FINITE AUTOMATA.
CSE 105 theory of computation
Intro to Theory of Computation
Jaya Krishna, M.Tech, Assistant Professor
Decidable Languages Costas Busch - LSU.
CSC 4170 Theory of Computation Decidable languages Section 4.1.
Instructor: Aaron Roth
CSE 105 theory of computation
Automata, Grammars and Languages
CSE 105 theory of computation
Presentation transcript:

1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli

In this lecture we review some decidable languages related to regular and context free languages. In the next lecture we will present a undecidable language. Introduction and Motivation 2

A language L over is decidable if there exists a Turing machine recognizing L, that stops on every input. Decidable Languages (rerun) 3

The input for a TM is always a string. If we want to give some other object, e.g. an automaton or a grammar, the object must be encoded as a string. Encoding can be straight forward. For example: An undirected graph G, is encoded by specifying its nodes and its edges. G ’s encoding is denoted as. Objects as Input 4

A TM that gets as input the encoding of an undirected graph,, starts its computation by verifying that the encoding is well formed. If this is not the case, the input is rejected. In the future we will regard input representations as implementation details and conveniently ignore them. Objects as Input 5

Let A be the language of strings representing undirected connected graphs. Note: in this way we form a computational problem as a language recognition problem. In the next slide we present a high level description of a TM that decides A. Example: Connected Graphs 6

M= “On input, the encoding of a graph G : 1.Select a node of G and mark it. 2.Repeat until no new nodes are marked: 3. For every node of G, v, if v is connected to a marked node, mark it as connected. 4. If all nodes are marked accept otherwise reject.” Example: Connected Graphs 7

Consider a representation of a graph by two lists: 1.List of nodes (natural numbers). 2.List of edges (pairs of nodes). Note: We do not specify the alphabet which can be binary, decimal or other. The idea is to ignore insignificant implementation details. Connected Graphs-Representation 8

Check that the input consists of: 1.A list of nodes (natural numbers) with no repetition. To check uniqueness use the machine presented on yesterday’s discussion. 2.A list of edges: A list of pairs of nodes that appear in the previous list. Input Verification 9

1.Select a node of G and mark it - Mark the first node on the list. One way to do it is to “dot” its leftmost digit. 2.Repeat until no new nodes are marked - Mark the first un-dotted node on the list by underlining (different from dotting) its leftmost digit. Implementation 10

2. Repeat until no new nodes are marked: Underline first un-dotted node on list, n For every node of G, v, if v is connected to a marked node, mark it as connected – Underline the first dotted node on the list, n 2. Search edges for ( n 1,n 2 ) edge. Implementation 11

2. Repeat until no new nodes are marked: Underline first un-dotted node on list as n 1 3. For every node of G, v, if v is connected to a marked node, mark it as connected – Underline the first dotted node on the list n 2, search edges for ( n 1,n 2 ) edge. If found mark n 1 as dotted. Remove underlines go back to 2. Implementation 12

2. Repeat until no new nodes are marked: Underline first un-dotted node on list as n 1 3. For every node of G, v, if v is connected to a marked node, mark it as connected – Underline the first dotted node on the list n 2, search edges for ( n 1,n 2 ) edge. If not underline the next dotted node on the list as n 2. Implementation 13

2. Repeat until no new nodes are marked: 3. For every node of G, v, if v is connected to a marked node, mark it as connected. 4. If all nodes are marked accept otherwise reject.”- Scan the node list. if you find an un-dotted node – reject. Otherwise – accept. Implementation 14

Now we turn do deal with some problems related to regular and CF Languages. Typical problems are: Deciding whether a DFA accepts a language. Deciding whether a language is empty. Deciding whether two languages are equal, etc. Decision Problems on Automatons 15

Consider the language Note that once again we formulate a computational problem as a membership problem. Theorem A DFA is a decidable language. Finite Automatons are Decidable 16

Consider M= “On a input : 1. Simulate B on input w. 2. If B accepts - accept. Otherwise – reject.“ Proof 17

The encoding of can be straight forward: The five components of B are listed on M ‘s tape one after the other. TM M starts its computation by verifying that the encoding is well formed. If this is not the case, the input is rejected. Implementation 18

Following that M simulates on B ‘s computation on w in a way, very similar to the way a computer program will do. Implementation 19

Assume that the DFA is encoded by a list of its components. TM M should first verify that the string representing B is well formed. Than it should use a “state dot” to mark B ’s initial state as its current state and an “input dot” to mark w ’s first symbol as the current input symbol. Simulation of a DFA Initialization 20

Following that, M scans the substring representing B ’s transition function to find the transition that should take place for the current state and the current input symbol. Once the right transition is found, the new current state is known. Simulation of a DFA 21

At this point, M moves the “state dot” from the previous current state, to the new current state, and moves the “input dot” from the previous input symbol to the next input symbol. This procedure repeats until the input is finished. If at this stage B ’s current state is accepting, M accepts, otherwise it rejects. Simulation of a DFA 22

Now we turn to consider the language and prove: Theorem A NFA is a decidable language. Finite Automatons are Decidable 23

Consider N= “On a input : 1. Convert NFA B to an equivalent DFA C. 2. Simulate C on input w using TM M (See previous proof). 3. If C accepts - accept. Otherwise – reject.“ Proof 24

Item 2 N ’s high level description says: “Simulate C on input w using TM M.” Here M is used by N as a procedure. This can be done as follows: 1. N is equipped with an additional tape on which M ’s input will be written. Implementation 25

2. At the point in which M is called, a section in which M ’s input is written on the additional tape is added to N. 3. Following this section we add to N a complete copy of M, using its input tape. 4. This procedure is repeated on each call to M. Implementation 26

An additional way to describe Regular Languages is by use of regular expressions. Now we consider the language and prove: Theorem A REX is a decidable language. Regular Expressions are Decidable 27

Consider P= “On a input : 1. Convert RE R to an equivalent NFA A. 2. Run TM N (See previous proof) 0n w. 3. If N accepts - accept. Otherwise – reject.“ Proof 28

In this problem it is required to compute whether a given DFA accepts at least one string: Consider the language and prove: Theorem E DFA is a decidable language. The Emptiness Problem for DFA-s 29

Consider T= “On a DFA input : 1.Mark the start state of A. 2.Repeat until no new states are marked: 3. Mark any state that has an incoming transition from an already marked state. 4. If no accept state is marked - accept. Otherwise – reject.“ Proof 30

Our survey of decidability problems for regular languages is completed by considering and proving: Theorem EQ DFA is a decidable language. DFA Equivalence is Decidable 31

In order to prove this theorem we use the TM T of the previous proof. The input for T is a DFA C satisfying: This expression is called The symmetric difference of and and it can be proved that iff. Proof 32

DFA C is constructed using the algorithms for constructing Union, Intersection, and Complementation, Of Chapter 1. Proof 33

The TM machine F for Deciding EQ DFA gets as input to DFA-s A and B. This machine first activates the algorithms of Chapter 1 to construct DFA C and then it calls TM T to check whether. If T accepts so does F. Otherwise F rejects. Proof 34

Now we consider the language and prove: Theorem A CFG is a decidable language. Decidable CFG Related Languages 35

If we try to prove this theorem by checking all possible derivations of, we may run into trouble on grammars containing cycles, e.g. This grammar has an infinite derivation which is hard to deal with. Decidable CFG Related Languages 36

The way to solve this problem is by using the following definition and theorem: Definition A context-free grammar is in Chomsky normal form (CNF) if every rule is of the form: Decidable CFG Related Languages 37

Theorem Every context-free grammar has an equivalent grammar in Chomsky normal form. Note: In a CNF grammar every non-final derivation extends the current string. Decidable CFG Related Languages 38

Result If G is a context-free grammar in CNF then: 1.A derivation of 0-length string w takes a single production. 2.A derivation of an n -length string w takes a 2 n- 1 productions. Decidable CFG Related Languages 39

Consider S= “On input : 1.Convert G to an equivalent CNF grammar. 2.List al all derivations with 2 n- 1 productions. 3.If w is generated by one of these derivations - accept. Otherwise – reject.“ Proof of Theorem 40

Consider the language Theorem E DFA is a decidable language. How can this be proved? The Emptiness Problem for CFL-s 41

M= “On input, where G is a CFG: 1.Mark all terminal symbols in G. 2.Repeat until no new variables are marked: 3. Mark any variable A where G has a rule of the form and are all marked. 4. If the start variable is not marked accept otherwise reject.” The Emptiness Problem for CFL-s 42

Consider the language Unlike DFA-s CFL-s are not closed under intersection and complementation. Therefore we cannot decide EQ CFG using the method we used for EQ CFG. In the near future we will prove: Theorem EQ CFG is an undecidable language. CFG Equivalence is not Decidable 43

Our survey of decidability problems for CFL-s/CFG-s is completed by considering the decision problem for context Free Languages, namely: Given a context free language L, does there exist a TM that decides L ? CFL-s are Decidable 44

Recall that every CFL is recognized by some PDA. It is not hard to prove that a TM can simulate a PDA, but this is not enough? For many CFL-s the PDA recognizing them is nondeterministic, which may cause the following problem: CFL-s are Decidable 45

Let L be a CFL, let p a be a PDA recognizing L and let w be a string such that. PDA P may never stop on w and a TM simulating P may loop while a decider should stop on every input. Nevertheless there is a solution: Theorem Let L be a CFL. There exists a TM deciding L. CFL-s are Decidable 46

Since L is a CFL, there exist a CFG G that generates L. The problem is solved by TM that contains a copy of G, as follows. “On input w : 1. RUN TM S on input 2. If S accepts - accept. Otherwise – reject.“ Proof 47