The Big Picture. Chapter 3

Similar documents
TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function

Theory of Computations Spring 2016 Practice Final Exam Solutions

Name: CS 341 Practice Final Exam. 1 a 20 b 20 c 20 d 20 e 20 f 20 g Total 207

Specifying Syntax COMP360

Recursively Enumerable Languages, Turing Machines, and Decidability

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

1. [5 points each] True or False. If the question is currently open, write O or Open.

Theory of Computations Spring 2016 Practice Final

Theory of Programming Languages COMP360

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which:

Decidable Problems. We examine the problems for which there is an algorithm.

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Why Study the Theory of Computation?

Turing Machine Languages

1KOd17RMoURxjn2 CSE 20 DISCRETE MATH Fall

Computability Summary

CpSc 421 Final Solutions

CS21 Decidability and Tractability

Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D.

Material from Recitation 1

ECS 120 Lesson 16 Turing Machines, Pt. 2

Outline. Language Hierarchy

Turing Machines. A transducer is a finite state machine (FST) whose output is a string and not just accept or reject.

Introduction to the Theory of Computation, Sipser, PWS, ISBN X, 1996

Universal Turing Machine Chomsky Hierarchy Decidability Reducibility Uncomputable Functions Rice s Theorem Decidability Continued

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

Theory of Languages and Automata

Theory Bridge Exam Example Questions Version of June 6, 2008

We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack.

Equivalence of NTMs and TMs

Computer Sciences Department

pp Variants of Turing Machines (Sec. 3.2)

Enumerations and Turing Machines

1 Parsing (25 pts, 5 each)

Languages and Automata


ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES *

CSCI 270: Introduction to Algorithms and Theory of Computing Fall 2017 Prof: Leonard Adleman Scribe: Joseph Bebel

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

Skyup's Media. PART-B 2) Construct a Mealy machine which is equivalent to the Moore machine given in table.

CSE 105 THEORY OF COMPUTATION

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

Variants of Turing Machines

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

8.1 Polynomial-Time Reductions

Pushdown Automata. A PDA is an FA together with a stack.

Introduction to Computers & Programming

Introduction to the Analysis of Algorithms. Algorithm

! Greed. O(n log n) interval scheduling. ! Divide-and-conquer. O(n log n) FFT. ! Dynamic programming. O(n 2 ) edit distance.

III. Supplementary Materials

8.1 Polynomial-Time Reductions

Final Course Review. Reading: Chapters 1-9

Multiple Choice Questions

The Turing Machine. Unsolvable Problems. Undecidability. The Church-Turing Thesis (1936) Decision Problem. Decision Problems

CSE 105 THEORY OF COMPUTATION

Theory and Compiling COMP360

Structure of a Compiler: Scanner reads a source, character by character, extracting lexemes that are then represented by tokens.

Rice s Theorem and Enumeration

Theory of Computation, Homework 3 Sample Solution

CS 531: Notes II. January 31, 2014

UNIT I PART A PART B

CS 275 Automata and Formal Language Theory. First Problem of URMs. (a) Definition of the Turing Machine. III.3 (a) Definition of the Turing Machine

Greedy Algorithms 1 {K(S) K(S) C} For large values of d, brute force search is not feasible because there are 2 d {1,..., d}.

CS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)

Problems, Languages, Machines, Computability, Complexity

Chapter 14: Pushdown Automata

Decision Properties for Context-free Languages

More on Polynomial Time and Space

A Characterization of the Chomsky Hierarchy by String Turing Machines

CISC 4090 Theory of Computation

From Theorem 8.5, page 223, we have that the intersection of a context-free language with a regular language is context-free. Therefore, the language

PS3 - Comments. Describe precisely the language accepted by this nondeterministic PDA.

CMPSCI 250: Introduction to Computation. Lecture #14: Induction and Recursion (Still More Induction) David Mix Barrington 14 March 2013

THEORY OF COMPUTATION

Final Exam 1, CS154. April 21, 2010

6.045J/18.400J: Automata, Computability and Complexity. Practice Quiz 2

SECTION A (40 marks)

Examples of P vs NP: More Problems

Automata & languages. A primer on the Theory of Computation. The imitation game (2014) Benedict Cumberbatch Alan Turing ( ) Laurent Vanbever

QUESTION BANK. Unit 1. Introduction to Finite Automata

CT32 COMPUTER NETWORKS DEC 2015

CSE 105 THEORY OF COMPUTATION

Closure Properties of CFLs; Introducing TMs. CS154 Chris Pollett Apr 9, 2007.

MAT 7003 : Mathematical Foundations. (for Software Engineering) J Paul Gibson, A207.

A Note on the Succinctness of Descriptions of Deterministic Languages

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

Problem Set 6 (Optional) Due: 5pm on Thursday, December 20

Reductions. Linear Time Reductions. Desiderata. Reduction. Desiderata. Classify problems according to their computational requirements.

Lecture 5: The Halting Problem. Michael Beeson

CS 580: Algorithm Design and Analysis

3/7/2018. CS 580: Algorithm Design and Analysis. 8.1 Polynomial-Time Reductions. Chapter 8. NP and Computational Intractability

CS 44 Exam #2 February 14, 2001

Actually talking about Turing machines this time

W[1]-hardness. Dániel Marx. Recent Advances in Parameterized Complexity Tel Aviv, Israel, December 3, 2017

Best known solution time is Ω(V!) Check every permutation of vertices to see if there is a graph edge between adjacent vertices

W[1]-hardness. Dániel Marx 1. Hungarian Academy of Sciences (MTA SZTAKI) Budapest, Hungary

THE DESIGN AND ANALYSIS OF COMPUTER ALGORITHMS

Regular Languages (14 points) Solution: Problem 1 (6 points) Minimize the following automaton M. Show that the resulting DFA is minimal.

1 Definition of Reduction

Transcription:

The Big Picture Chapter 3

Examining Computational Problems We want to examine a given computational problem and see how difficult it is. Then we need to compare problems Problems appear different We want to cast them into the same kind of problem decision problems in particular, language recognition problem

A decision problem is simply a problem for which the answer is yes or no (True or False). A decision procedure answers a decision problem. Examples: Decision Problems Given an integer n, does n have a pair of consecutive integers as factors? The language recognition problem: Given a language L and a string w, is w in L? Our focus

The Power of Encoding For problem already stated as decision problems: define the language to be decided: encode the inputs as strings and then define a language that contains exactly the set of inputs for which the desired answer is yes. For other problems: first reformulate the problem as a decision problem, then encode it as a language recognition task (as described above)

Even Length Testing Problem: Given w {a, b}*, is w even-length? The language to be decided: {w {a, b}*: w is even-length} The original problem and its language formulation are Equivalent By equivalent we mean that either problem can be reduced to the other. If we have a machine to solve one, we can use it to build a machine to do the other using just the starting machine and other functions that can be built using a machine of equal or lesser power.

Primality Testing Problem: Given a nonnegative integer x, is it prime? To encode the problem we need a way to encode each instance: We encode each nonnegative integer as a binary string. The language to be decided: PRIMES = {w : w is the binary encoding of a prime number}.

Everything is a String Anything can be encoded as a string. <X> is the string encoding of X. <X, Y> is the string encoding of the pair X, Y.

Problem: Given an undirected graph G, is it connected? Instance of the problem: Everything is a String 1 2 3 4 5 Encoding of the problem: Let V be a set of binary numbers, one for each vertex in G. Then we construct G as follows: Write V as a binary number, Write a list of edges, Separate all such binary numbers by /. 101/1/10/10/11/1/100/10/101 The language to be decided: CONNECTED = {w {0, 1, /}* : w = n 1 /n 2 / n i, where each n i is a binary string and w encodes a connected graph, as described above}.

Pattern Matching on the Web Problem: Given a search string w and a web document d, do they match? In other words, should a search engine, on input w, consider returning d? The language to be decided: {<w, d> : d is a candidate match for the query w}

Does a Program Always Halt? Problem: Given a program p, written in some some standard programming language, is p guaranteed to halt on all inputs? The language to be decided: HP ALL = {p : p halts on all inputs}

Turning Problems Into Decision Problems Transform the original problem into a verification problem that verifies the correctness of candidate solutions. a decision problem equivalence in terms of solvability/computability How can we use verification for solving?

Problem: Given two nonnegative integers, compute their product. Reformulation: Transform computing into verification. Is 2x3=5? The language to be decided: L = {w of the form: <integer 1 >x<integer 2 >=<integer 3 >, where: integer n is any well formed integer, and integer 3 = integer 1 integer 2 } 12x9=108 12=12 12x8=108 Multiplication

Sorting Problem: Given a list of integers, sort it. Reformulation: Transform sorting into verification Given two lists, is the 2 nd in sorted order of the 1 st? The language to be decided: L = {w 1 # w 2 : n 1 (w 1 is of the form <int 1, int 2, int n >, w 2 is of the form <int 1, int 2, int n >, and w 2 contains the same objects as w 1 and w 2 is sorted)} Examples: 1,5,3,9,6#1,3,5,6,9 1,5,3,9,6#1,2,3,4,5,6,7

Database Querying Problem: Given a database and a query, execute the query. Reformulation: Transform the query execution problem into evaluating a reply for correctness. The language to be decided: L = {d # q # a: d is an encoding of a database, q is a string representing a query, and a is the correct result of applying q to d} Example: (name, age, phone), (John, 23, 567-1234) (Mary, 24, 234-9876)#(select name age=23)# (John)

Another Example Showing Equivalence Consider the multiplication example: L = {w of the form: <integer 1 >x<integer 2 >=<integer 3 >, where: integer n is any well formed integer, and integer 3 = integer 1 integer 2 } Given a multiplication machine, we can build the language recognition machine: Given the language recognition machine, we can build a multiplication machine:

Languages and Machines

Finite State Machines An FSM to accept a*b*: We call the class of languages acceptable by some FSM regular There are simple useful languages that are not regular: An FSM to accept A n B n = {a n b n : n 0} How can we compare numbers of a s and b s? The only memory in an FSM is in the states and we must choose a fixed number of states in building it. But no bound on number of a s

Pushdown Automata Build a PDA (roughly, FSM + a single stack) to accept A n B n = {a n b n : n 0} Example: aaabb Stack:

Another Example Bal, the language of balanced parentheses contains strings like (()) or ()(), but not ()))( important, almost all programming languages allow parentheses, need checking PDA can do the trick, not FSM We call the class of languages acceptable by some PDA context-free. There are useful languages not context free. A n B n C n = {a n b n c n : n 0} a stack wouldn t work. All popped out and get empty after counting b

Turing Machines A Turing Machine to accept A n B n C n :

Turing Machines FSM and PDA (exists some equivalent PDA) are guaranteed to halt. But not TM. Now use TM to define new classes of languages, D and SD A language L is in D iff there exists a TM M that halts on all inputs, accepts all strings in L, and rejects all strings not in L. in other words, M can always say yes or no properly A language L is in SD iff there exists a TM M that accepts all strings in L and fails to accept every string not in L. Given a string not in L, M may reject or it may loop forever (no answer). in other words, M can always say yes properly, but not no. give up looking? say no? D SD Bal, A n B n, A n B n C n are all in D how about regular and context-free languages? In SD but D: H = {<M, w> : TM M halts on input string w} Not even in SD: H all = {<M> : TM M halts on all inputs}

Languages and Machines Hierarchy of language classes Rule of Least Power: Use the least powerful language suitable for expressing information, constraints or programs on the World Wide Web. Applies far more broadly. Expressiveness generally comes at a price computational efficiency, decidability, clarity

Languages, Machines, and Grammars SD (recursively enumerable) TMs Unrestricted grammar D (recursive) Context-sensitive languages LBAs Context-sensitive grammar Context-free languages NDPDAs Context-free grammar DCF DPDAs Regular languages FSMs Regular grammar / regular expression

A Tractability Hierarchy P : contains languages that can be decided by a TM in polynomial time NP : contains languages that can be decided by a nondeterministic TM (one can conduct a search by guessing which move to make) in polynomial time PSPACE: contains languages that can be decided by a machine with polynomial space P NP PSPACE P = NP? Biggest open question for theorists

Decision Procedures Chapter 4

Decidability Issues Goal of the book: be able to make useful claims about problems and the programs that solve them. cast problems as language recognition tasks define programs as state machines whose input is a string and output is Accept or Reject

Decision Procedures An algorithm is a detailed procedure that accomplishes some clearly specified task. A decision procedure is an algorithm to solve a decision problem. Decision procedures are programs and must possess two correctness properties: must halt on all inputs when it halts and returns an answer, it must be the correct answer for the given input

Decidability A decision problem is decidable iff there exists a decision procedure for it. A decision problem is undecidable iff there exists no a decision procedure for it. A decision problem is semiecidable iff there exists a semidecision procedure for it. a semidecision procedure is one that halts and returns True whenever True is the correct answer. When False is the answer, it may either halt and return False or it may loop (no answer). Three kinds of problems: decidable (recursive) not decidable but semidecidable (recursively enumerable) not decidable and not even semidecidable

Decidable Checking for even numbers: Is the integer x even? Let / perform truncating integer division, then consider the following program: even(x:integer)= If(x/2)*2 = x then return True else return False Is the program a decision procedure?

Undecidable but Semidecidable Halting Problem: For any Turing machine M and input w, decide whether M halts on w. w is finite H = {<M, w> : TM M halts on input string w} asks whether M enters an infinite loop for a particular input w Java version: Given an arbitrary Java program p that takes a string w as an input parameter. Does p halt on some particular value of w? haltsonw(p:program, w:string) = 1. simulate the execution of p on w. 2. if the simulation halts return True else return False. Is the program a decision procedure?

Not even Semidecidable Halting-on-all (totality) Problem: For any Turing machine M, decide whether M halts on all inputs. H ALL = {<M> : TM M halts on all inputs} If it does, it computes a total function equivalent to the problem of whether a program can ever enter an infinite loop, for any input differs from the halting problem, which asks whether M enters an infinite loop for a particular input Java version: Given an arbitrary Java program p that takes a single string as input parameter. Does p halt on all possible input values? haltsonall(p:program) = 1. for i = 1 to infinity do: simulate the execution of p on all possible input strings of length i. 2. if all the simulations halt return True else return False. Is the program a decision procedure? A semidecision procedure?

Grammars, Languages, and Machines Generates Language Grammar Recognizes or Accepts Machine

Clarification A machine M recognizes a language L iff M accepts all and only those strings in L. A machine M decides a language L iff M accepts all strings in L and rejects all strings not in L. recognize = accept = semi-decide decide When a machine halts, it must either accepts or rejects. So for machines that always halt, accept implies decide. A language L is called semi-decidable iff some TM accepts L. A language L is called decidable iff some TM decides L. SD: set of semi-decidable languages D: set of decidable languages (a subset of SD by definition. actually a proper subset of SD by proof)