The Big Picture Chapter 3. We want to examine a given computational problem and see how difficult it is. Then we need to compare problems Problems appear.

Slides:



Advertisements
Similar presentations
Part VI NP-Hardness. Lecture 23 Whats NP? Hard Problems.
Advertisements

Complexity Classes: P and NP
NP-Hard Nattee Niparnan.
CS 345: Chapter 9 Algorithmic Universality and Its Robustness
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,
Pushdown Automata Chapter 12. Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Programming Languages Wrap-up. Your Toolkit Object-oriented Imperative Functional Logic.
Recap CS605: The Mathematics and Theory of Computer Science.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Rules have form String of variables and terminals String of variables and terminals.
Fall 2004COMP 3351 The Chomsky Hierarchy. Fall 2004COMP 3352 Non-recursively enumerable Recursively-enumerable Recursive Context-sensitive Context-free.
Analysis of Algorithms CS 477/677
Linear Bounded Automata LBAs
1 Decidability continued. 2 Undecidable Problems Halting Problem: Does machine halt on input ? State-entry Problem: Does machine enter state halt on input.
Chapter 11: Limitations of Algorithmic Power
MA/CSSE 474 Theory of Computation
CMPS 3223 Theory of Computation Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Review Byron Gao. Overview Theory of computation: central areas: Automata, Computability, Complexity Computability: Is the problem solvable? –solvable.
1 CSSE 350 Automata, Formal Languages, and Computability.
TM Design Universal TM MA/CSSE 474 Theory of Computation.
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
Introduction to CS Theory Lecture 15 –Turing Machines Piotr Faliszewski
MA/CSSE 474 Theory of Computation Enumerability Reduction.
MA/CSSE 474 Theory of Computation Decision Problems DFSMs.
Turing Machines Chapter 17. Languages and Machines SD D Context-Free Languages Regular Languages reg exps FSMs cfgs PDAs unrestricted grammars Turing.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
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.
Computability Heap exercise. The class P. The class NP. Verifiers. Homework: Review RELPRIME proof. Find examples of problems in NP.
TM Design Macro Language D and SD MA/CSSE 474 Theory of Computation.
Context-Free and Noncontext-Free Languages Chapter 13.
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
Turing -Recognizable vs. -Decidable
Languages and Strings Chapter 2.
Computability Review homework. Video. Variations. Definitions. Enumerators. Hilbert's Problem. Algorithms. Summary Homework: Give formal definition of.
1 Turing Machines and Equivalent Models Section 13.1 Turing Machines.
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.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 3 The Church-Turing Thesis Contents Turing Machines definitions, examples,
The Big Picture Chapter 3.
CS 461 – Oct. 28 TM applications –Recognize a language √ –Arithmetic √ –Enumerate a set –Encode a data structure or problem to solve Two kinds of TMs –Decider:
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.
The Big Picture Chapter 3. A decision problem is simply a problem for which the answer is yes or no (True or False). A decision procedure answers a decision.
1 Chapter 9 Undecidability  Turing Machines Coded as Binary Strings  Universal Turing machine  Diagonalizing over Turing Machines  Problems as Languages.
Algorithms and Decision Procedures for Regular Languages Chapter 9.
Turing Machines Sections 17.6 – The Universal Turing Machine Problem: All our machines so far are hardwired. ENIAC
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,
MA/CSSE 474 Theory of Computation Languages, prefixes, sets, cardinality, functions.
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
MA/CSSE 474 Theory of Computation Universal Turing Machine Church-Turing Thesis (Winter 2016, these slides were also used for Day 33)
Universal Turing Machine
Theory of Computational Complexity TA : Junichi Teruyama Iwama lab. D3
Week 14 - Friday.  What did we talk about last time?  Simplifying FSAs  Quotient automata.
MA/CSSE 474 Theory of Computation Decision Problems, Continued DFSMs.
Computability. Turing Machines Read input letter & tape letter, write tape letter, move left or right.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
MA/CSSE 474 Theory of Computation Universal Turing Machine Church-Turing Thesis Delayed due dates for HWs See updated schedule page. No class meeting.
Modeling Arithmetic, Computation, and Languages Mathematical Structures for Computer Science Chapter 8 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesTuring.
Decidability and Undecidability Proofs
Part VI NP-Hardness.
MA/CSSE 474 Decision Problems Languages, Machines, Computation
Turing Machines Chapter 17.
LIMITS OF ALGORITHMIC COMPUTATION
Quiz questions referenced here are on the Day 3 quiz
Turing Machines Chapter 17.
MA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation Computation FSM Intro.
MA/CSSE 474 Theory of Computation
Presentation transcript:

The Big Picture Chapter 3

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 Examining Computational Problems

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: 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 Decision Problems

The Power of Encoding For problem already stated as decision problems. 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, must first reformulate the problem as a decision problem, then encode it as a language recognition task

Everything is a String 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: { : d is a candidate match for the query w}

Everything is a String 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}

Everything is a String What If we’re not working with strings? Anything can be encoded as a string. is the string encoding of X. is the string encoding of the pair X, Y.

Everything is a String Primality Testing Problem: Given a nonnegative integer n, is it prime? An instance of the problem: Is 9 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}.

Problem: Given an undirected graph G, is it connected? Instance of the problem: 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}. Everything is a String

Casting multiplication as decision: Problem: Given two nonnegative integers, compute their product. Reformulation: Transform computing into verification. The language to be decided: L = {w of the form: x =, where: is any well formed integer, and integer 3 = integer 1  integer 2 } 12x9=108 12=12 12x8=108 Turning Problems Into Decision Problems

Casting sorting as decision: Problem: Given a list of integers, sort it. Reformulation: Transform the sorting problem into one of examining a pair of lists. The language to be decided: L ={w 1 # w 2 :  n  1 (w 1 is of the form, w 2 is of the form, 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 Turning Problems Into Decision Problems

Casting database querying as decision: 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, ) (Mary, 24, )#(select name age=23)# (John) Turning Problems Into Decision Problems

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. The Traditional Problems and their Language Formulations are Equivalent

Consider the multiplication example: L ={w of the form: x =, where: 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: An Example

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 = { : TM M halts on input string w} Not even in SD: H all = { : TM M halts on all inputs}

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

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

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

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 ? Biggest open question for theorists P  NP  PSPACE

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 Note: Usually defined w.r.t. Turing machines most powerful formalism for algorithms decidable = Turing-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? Decidable

Halting Problem: For any Turing machine M and input w, decide whether M halts on w. w is finite H = { : 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? Undecidable but Semidecidable

Halting-on-all (totality) Problem: For any Turing machine M, decide whether M halts on all inputs. H ALL = { : 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? Not even Semidecidable