CS 3240 – Chapter 11.  They may not halt on every possible input!  And not just because the creator of a specific TM was a doofus  This is related.

Slides:



Advertisements
Similar presentations
Natural Language Processing - Formal Language - (formal) Language (formal) Grammar.
Advertisements

CS 461 – Nov. 9 Chomsky hierarchy of language classes –Review –Let’s find a language outside the TM world! –Hints: languages and TM are countable, but.
1 Introduction to Computability Theory Lecture14: Recap Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Courtesy Costas Busch - RPI1 A Universal Turing Machine.
CS 3240 – Chapter 3.  How would you delete all C++ files from a directory from the command line?  How about all PowerPoint files that start with the.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata are like Turing Machines with a restriction: The working space of the tape is the space of the.
Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages.
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Rules have form String of variables and terminals String of variables and terminals.
Decidable and undecidable problems deciding regular languages and CFL’s Undecidable problems.
1 Uncountable Sets continued Theorem: Let be an infinite countable set. The powerset of is uncountable.
CHAPTER 4 Decidability Contents Decidable Languages
Linear Bounded Automata LBAs
Homework #9 Solutions.
Fall 2005Costas Busch - RPI1 Recursively Enumerable and Recursive Languages.
Normal forms for Context-Free Grammars
Fall 2004COMP 3351 A Universal Turing Machine. Fall 2004COMP 3352 Turing Machines are “hardwired” they execute only one program A limitation of Turing.
CS 310 – Fall 2006 Pacific University CS310 The Halting Problem Section 4.2 November 15, 2006.
CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state.
January 28, 2015CS21 Lecture 101 CS21 Decidability and Tractability Lecture 10 January 28, 2015.
CS21 Decidability and Tractability
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 Undecidability Reading: Chapter 8 & 9. 2 Decidability vs. Undecidability There are two types of TMs (based on halting): (Recursive) TMs that always.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
A Universal Turing Machine
Turing Machines. The Next Level of Computation Turing Machines –From Alan Turing, 1936 Turns out to be the LAST –The only machine you'll ever need The.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata (LBAs) are the same as Turing Machines with one difference: The input string tape space is the.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
CS 461 – Nov. 7 Decidability concepts –Countable = can number the elements  –Uncountable = numbering scheme impossible  –A TM undecidable –Language classes.
Grammars A grammar is a 4-tuple G = (V, T, P, S) where 1)V is a set of nonterminal symbols (also called variables or syntactic categories) 2)T is a finite.
Recursively Enumerable Languages
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
Recursively Enumerable and Recursive Languages
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata (LBAs) are the same as Turing Machines with one difference: The input string tape space is the.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 12 Mälardalen University 2007.
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Productions String of variables and terminals String of variables and terminals.
1 Chapter 9 Undecidability  Turing Machines Coded as Binary Strings  Universal Turing machine  Diagonalizing over Turing Machines  Problems as Languages.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
CS 3240 – Chapter 9.  Turing Machines  From Alan Turing, 1936  Turns out to be the LAST machine  The only machine you'll ever need  The Church-Turing.
Theory of Languages and Automata By: Mojtaba Khezrian.
CS 3813: Introduction to Formal Languages and Automata Chapter 11 A Hierarchy of Formal Languages and Automata These class notes are based on material.
CS 154 Formal Languages and Computability May 12 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
CS 154 Formal Languages and Computability April 28 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
Turing Machines CS 130 Theory of Computation HMU Textbook: Chap 8.
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
CS6800 Advance Theory of Computation Spring 2016 Nasser Alsaedi
1 A Universal Turing Machine. 2 Turing Machines are “hardwired” they execute only one program A limitation of Turing Machines: Real Computers are re-programmable.
Recursively Enumerable and Recursive Languages
This statement is false.
Linear Bounded Automata LBAs
Lecture12 The Halting Problem
CSCI 2670 Introduction to Theory of Computing
Natural Language Processing - Formal Language -
Context Sensitive Languages and Linear Bounded Automata
PDAs Accept Context-Free Languages
BCS 2143 Theory of Computer Science
Summary.
A HIERARCHY OF FORMAL LANGUAGES AND AUTOMATA
Decidable Languages Costas Busch - LSU.
CS21 Decidability and Tractability
Formal Languages, Automata and Models of Computation
CS21 Decidability and Tractability
Subject Name: FORMAL LANGUAGES AND AUTOMATA THEORY
CSCI 2670 Introduction to Theory of Computing
Cpt S 317: Spring 2009 Reading: Chapter 8 & 9
Instructor: Aaron Roth
Turing Machines Everything is an Integer
MA/CSSE 474 Theory of Computation
Presentation transcript:

CS 3240 – Chapter 11

 They may not halt on every possible input!  And not just because the creator of a specific TM was a doofus  This is related to the major mathematical/computational discovery of the 20 th century!  There are propositions that cannot be decided (“proven”)

 A question is decidable if there is a TM that always halts and answers “yes” or “no” for each possible input  The TM therefore constitutes an algorithm  A language is decidable if there is a TM that always halts and answers “accept” or “reject” whenever an input string is in the language or not  aka “Turing acceptable”

 A function is computable if there is a TM that always halts with the appropriate output for each possible input in the function domain  aka “Total function”

 Let g(x,y) be some computable function  Let f(x) = the smallest p where g(x, p) = 1, or 0, if such a p does not exist  “Pseudo-algorithm” for f(x): m = 0; while (g(x, m) != 1) ++m; cout << m;  If there is no m for a given g and x, then we hang!

 3 possibilities in general when a TM processes an input string:  Accepts (goes to an accepting halt state)  Rejects (e.g., crashes, or gives a “no” answer)  Hangs (infinite loop)

 A language for which there is a TM that always halts for and accepts strings in the language is recognizable  “It knows one when it sees one” :-)  But it may hang on strings not in the language

 A function that is defined for only some of its domain elements is a partial function  It may hang (or “blow up”) on some inputs  e.g., divide by zero  This is the computational analogue to a recognizable language  you’ll always get an answer with a valid input  it may hang on invalid input

LanguageMachineGrammar RegularFinite AutomatonRegular Expression, Regular Grammar Context-FreePushdown AutomatonContext-Free Grammar Recursively Enumerable Turing MachineUnrestricted Phrase- Structure Grammar 9CS Introduction

A language L over the alphabet is called recursively enumerable (aka “recognizable”) if there is a TM T that accepts every word in L and either rejects (crashes) or loops forever for every word in the language L', the complement of L: accept(T) = L reject(T) + loop(T) = L' recursively enumerable (r.e.) = recognizable

 We just saw one (slide 5)  Let g(x,y) be some computable function  Let f(x) = the smallest p where g(x, p) = 1, or 0, if such a p does not exist  Let L g be the set of functions, f, corresponding to all computable functions g, as explained above  Such functions can be encoded as strings, and are therefore countable  L g can then be seen as a language (a set of strings)

A language L over the alphabet is called recursive (aka “decidable”) if there is a TM T that accepts every word in L and rejects every word in L'; that is, accept(T) = L reject(T) = L' A TM that accepts a recursive set is a model of an algorithm. It always halts. recursive = decidable

 There exist languages that are r.e. but not recursive  We just saw one  There exist languages that aren't even r.e.!  (You'll see one soon)  All are “contrived”  Languages generated by grammars are r.e. or “better”

 All r.e. languages are closed under union, intersection, concatenation, and Kleene*  Everything but complement!  Recursive languages are also closed under complement  Also: If L and L' are r.e., then L is recursive  Here come the Proofs…

 Let M be a machine that decides a recursive language, L  Form the machine M' by inverting the acceptability output of M  Goes to a reject state instead  Then M' decides L'  So L' is recursive

 Suppose L and L' are both r.e.  Let M recognize L, and M' recognize L'  M may hang on elements of L', but M' doesn't  Form a new machine, M * that calls M and M' in parallel (non-deterministically)  If M accepts w, so does M *  If M' accepts w, reject w  There are no other possibilities! (No hanging)  Therefore, L is decidable/recursive, by definition

 TMs can recognize/accept strings from certain languages and/or compute functions  If there is a TM, M, that accepts a language, L, and M always halts, then L is recursive  If there is no such M for L, but there is instead a machine M that accepts every string in L, but M may hang on strings not in L, then L is recursively enumerable

 The complement of a recursive language is recursive  In fact, recursive languages are closed under all operations, like regular languages are  r.e. languages are closed under intersection  The complement of a r.e. language may not be r.e.  But if it is, then both languages are actually recursive!

A Timely Interlude

 The real numbers in (0,1) are uncountable  They cannot be mapped in a 1-to-1 fashion to the counting numbers  Proof:  Assume they can be: r 0, r 1, r 2, …  Arrange their digits in a table a[ ][ ] ▪ each row, a[i], contains the digits or r i  The diagonal sequence (a[n][n]+1) mod 10, representing a valid real number, is not in the table! Contradiction!

 The power set of the natural numbers, N  the set of all subsets (2 N )  Suppose it is countable  The we can enumerate the sets: p 0, p 1, p 2, …  Now consider the set T = {i | i ∉ f(i) = p i }  Certainly T is a set of integers, so T ∈ P(N) ▪ Call it p k  Question: Is k in T = p k ?

 The power set of any countably infinite set is uncountable  Much bigger than a countable set!  The number of countable sets is negligible compared to the number of uncountable sets

 Well?

 A language over an alphabet Σ is a subset of Σ *  the latter being an infinite set  The set of all languages over Σ is therefore the power set of Σ * (2 ∑* )  which we just showed is uncountable  So… the number of languages over any finite alphabet is uncountable

 The # of TMs are countable, but the # of languages is not  Therefore, some languages cannot be recognized by a TM  There aren't enough TMs to go around!  Just like there are more reals than integers  So, non-r.e. languages must exist!

 Just take the complement of any r.e. language that is not recursive  Example (page 279):  Consider all TMs, M i with alphabet Σ={a}.  Let X = {a i : a i ∈ L(M i )} ▪ This is r.e., but not recursive ▪ Because we can construct a TM that carries out the computation, but it may not halt when a i ∉ L(M i )  Then X’ must be non-r.e.!

 Suppose X’ is r.e.  Then there is a TM, M k, that recognizes it  Now ask the question, is a k ∈ X’ ?  If it is, this means a k ∉ L(M k ) = X’, by definition  Contradiction!  If it isn’t, then this means that a k ∈ L(M k ) = X’  Again, by definition  Again, a contradiction!  ⇒ X’ is not r.e.

 What we have just described is the membership problem:  “Given a r.e. language, L, and a string, w, is w in L?”  We have just shown that the membership problem is, in general, undecidable

LanguageMachineGrammar RegularFinite AutomatonRegular Expression, Regular Grammar Context-FreePushdown AutomatonContext-Free Grammar Recursively EnumerableTuring MachineUnrestricted Grammar 29CS Introduction

 Left-hand side of the rule is a concatenation of one or more symbols  There must be at least one variable on the left ▪ λ is not allowed on the left  Any string is allowed on the right, including λ  aka “Type 0” Grammar

S → aAbc | abc | λ Ab → bA Ac → Bbcc bB → Bb aB → aa | aaA S ⇒ aAbc ⇒ abAc ⇒ abBbcc ⇒ aBbbcc ⇒ aabbcc An A is created as the left-most variable. It travels to the right until it finds a 'c', then creates a new b and c, and becomes a B. The B moves back to create the extra needed a. The last rule allows the option to do it all over again (by introducing another A). This is similar to what the Turing machine for the same language does, except the TM marks instead of generates the letters.

 We have already seen CFGs for this  This unrestricted grammar:  Introduces X’s and Y’s together  Allows moving X’s and Y’s arbitrarily by swapping them  S → XYS | λ XY → YX YX → XY X → a Y → b

 Cannot use the decidability algorithms for CFGs  e.g., CYK algorithm does not apply  No “Normal Form”  Non-null productions may create shorter strings  Terminals can disappear!

 For every r.e. language, there is an unrestricted grammar that generates it  For every unrestricted grammar, there is a TM that recognizes its language  It may or may not decide it  We will not prove this  but the book does

 Like Unrestricted Grammars except:  Right-hand side must be no shorter than left-hand side ▪ So strings never shrink  Hence the name “non-contracting” or “monotonic”  Cannot contain λ anywhere  Context-sensitive languages don't need unlimited memory  Since intermediate sentential forms never shrink, the largest memory requirement is proportional to |w|  Accepting machine: Linear Bounded Automaton

S → aAbc | abc Ab → bA Ac → Bbcc bB → Bb aB → aa | aaA

 Every context-sensitive language is recursive  there is a TM that accepts it (i.e., always halts)  But not all recursive languages are context- sensitive  So Context Sensitive languages form a proper subset of Recursive Languages  Just like Recursive languages are a proper subset of Recursively enumerable languages

Type 3 grammar Type 2 grammar Type 1 grammar Type 0 grammar

LanguageGrammarMachine Recursively Enumerable (“Turing Recognizable”) Unrestricted Phrase Structure (Type 0) TM (that may not halt) Recursive (“Turing Decidable”) "TM (that always halts) Context-SensitiveContext Sensitive (Type 1) (monotonic/non- contracting) Linear-bounded automata (bounded TM) Context FreeContext Free (Type 2)PDA Deterministic Context Free "DPDA RegularRegular (Type 3) (Right-linear or Left-linear) FA