Problems, and How Computer Scientists Solve Them Manas Thakur

Similar documents
Turing Machines Part III

COSE215: Theory of Computation. Lecture 20 P, NP, and NP-Complete Problems

Decidability and Undecidability

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

Chapter 3: The Church-Turing Thesis

CSE 105 THEORY OF COMPUTATION

BBM402-Lecture 11: The Class NP

CSCE 551 Final Exam, Spring 2004 Answer Key

CSE 105 THEORY OF COMPUTATION

Decidability (intro.)

COSE215: Theory of Computation. Lecture 21 P, NP, and NP-Complete Problems

ECS 120 Lesson 24 The Class N P, N P-complete Problems

CSE 105 THEORY OF COMPUTATION

Computability and Complexity

V Honors Theory of Computation

Midterm II : Formal Languages, Automata, and Computability

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

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

UNIT-VIII COMPUTABILITY THEORY

CS154, Lecture 17: conp, Oracles again, Space Complexity

Finish K-Complexity, Start Time Complexity

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

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

Theory of Computation (IX) Yijia Chen Fudan University

Computability Theory. CS215, Lecture 6,

Turing Machine Recap

1 Computational Problems

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

Notes for Lecture Notes 2

NP-Completeness. Until now we have been designing algorithms for specific problems

Turing Machines and Time Complexity

Lecture 23: Rice Theorem and Turing machine behavior properties 21 April 2009

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

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

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

CPSC 421: Tutorial #1

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

The Church-Turing Thesis

More Turing Machines. CS154 Chris Pollett Mar 15, 2006.

Intractable Problems [HMU06,Chp.10a]

6.045 Final Exam Solutions

Computer Sciences Department

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

Artificial Intelligence. 3 Problem Complexity. Prof. Dr. Jana Koehler Fall 2016 HSLU - JK

Announcements. Problem Set 7 graded; will be returned at end of lecture. Unclaimed problem sets and midterms moved!

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

Data Structures in Java

Friday Four Square! Today at 4:15PM, Outside Gates

Final exam study sheet for CS3719 Turing machines and decidability.

Decidable Languages - relationship with other classes.

Review of Complexity Theory

Turing Machines A Turing Machine is a 7-tuple, (Q, Σ, Γ, δ, q0, qaccept, qreject), where Q, Σ, Γ are all finite

1 Showing Recognizability

CS154, Lecture 10: Rice s Theorem, Oracle Machines

Decidability. Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff

Exam Computability and Complexity

conp, Oracles, Space Complexity

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

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

CS154, Lecture 13: P vs NP

P,NP, NP-Hard and NP-Complete

CSC 421: Algorithm Design & Analysis. Spring 2018

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

Time Complexity (1) CSCI Spring Original Slides were written by Dr. Frederick W Maier. CSCI 2670 Time Complexity (1)

Lecture Notes: The Halting Problem; Reductions

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP

Definition: conp = { L L NP } What does a conp computation look like?

CSC 1700 Analysis of Algorithms: P and NP Problems

CSE 105 THEORY OF COMPUTATION

Harvard CS 121 and CSCI E-121 Lecture 14: Turing Machines and the Church Turing Thesis

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

UNRESTRICTED GRAMMARS

TURING MAHINES

A Note on Turing Machine Design

Theory of Computation

Turing Machines. Reading Assignment: Sipser Chapter 3.1, 4.2

Reading Assignment: Sipser Chapter 3.1, 4.2

Algorithms and Theory of Computation. Lecture 19: Class P and NP, Reduction

Decidability (What, stuff is unsolvable?)

CS154, Lecture 13: P vs NP

Variants of Turing Machine (intro)

6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch

Lecture 12: Mapping Reductions

Review of unsolvability

Lecture 16: Time Complexity and P vs NP

Tractability. Some problems are intractable: as they grow large, we are unable to solve them in reasonable time What constitutes reasonable time?

CSE 105 THEORY OF COMPUTATION

NP, polynomial-time mapping reductions, and NP-completeness

Turing Machines Part II

CS151 Complexity Theory. Lecture 1 April 3, 2017

CS 301. Lecture 17 Church Turing thesis. Stephen Checkoway. March 19, 2018

On Rice s theorem. Hans Hüttel. October 2001

Turing Machines Part II

Peter Wood. Department of Computer Science and Information Systems Birkbeck, University of London Automata and Formal Languages

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

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

Theory of Computation CS3102 Spring 2015 A tale of computers, math, problem solving, life, love and tragic death

The decision problem (entscheidungsproblem), halting problem, & Turing machines. CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

Complexity Theory Part I

Complexity Theory Part II

Transcription:

Problems, and How Computer Scientists Solve Them PACE Lab, IIT Madras

Content Credits Introduction to Automata Theory, Languages, and Computation, 3rd edition. Hopcroft et al. Introduction to the Theory of Computation, 2nd edition. Michael Sipser. Algorithms, TMH edition. Dasgupta et al. https://en.wikipedia.org https://images.google.com 2

Outline Computation models Solvability Complexity Coping with difculties 3

A Simple Problem Design a machine to determine whether a given program P1 prints Hello World!. int main() { printf( Hello World! ); return 0; } 4

A Simple Problem (Cont.) int main() { int exp(int i, int n) { int n, total, x, y, z; int ans, j; scanf( %d, &n); ans = 1; total = 3; for (j=1; j<=n; ++j) { while (1) { ans *= i; } for (x=1; x<=total-2; ++x) { for (y=1; y<=total-x-1; ++y) { z = total-x-y; if (exp(x,n)+exp(y,n) == exp(z,n)) { printf( Hello World! ); } return ans; } } } ++total; } return 0; } 5

Expressing problems as language-membership tests Step 1: Represent problem instances as strings over a fnite alphabet. Our program P1 is essentially a string of characters. Step 2: Design a machine M1 that accepts valid strings. Outputs yes, if P1 prints Hello World!. Outputs no, if P1 does not print Hello World!. The language accepted by M1 is: L(M1) = { w w is a program that prints Hello World! } If M1 always terminates and prints yes or no, it decides P1; else it recognizes P1. 6

The Chomsky Hierarchy of Languages 7

DFA and PDA: A Quick Recap 8

Turing Machines 9

Where are we? Computation models Solvability Complexity Coping with NP-Completeness 10

An undecidable problem Given a TM M, and an input w, does M halt on w? Step 1: L(M) = { <M,w> M is a TM that halts on w } Step 2: 11

Our First Undecidability Proof Prove that ATM = { <M,w> M is a TM that accepts w } is undecidable. Assume that ATM is decidable by the following TM H: 12

Our First Undecidability Proof Give the string representation of M as input to H: Construct another TM D as follows: 13

Our First Undecidability Proof What does D do on <D> as input? D accepts <D> if D does not accept <D>, and vice-versa. Contradiction! Hence, H does not exist. Thus, ATM is undecidable!! :-) 14

Reducibility Reduce Problem A to Problem B. f A B If B is decidable, so is A. If A is undecidable, so is B. ~(p implies q) == ~q implies ~p 15

Back to the Halting Problem L(M) = { <M,w> M is a TM that halts on w } Assume MH decides L(M). Reduce ATM to MH: ATM = { <M,w> M is a TM that accepts w } Run MH on <M,w>. If MH rejects (i.e., M does not halt on w), then reject. If MH accepts, then simulate M on w (guaranteed to stop). Accept if M accepts w; reject if M rejects w. Thus, if MH always halts (assumed above), then ATM is decidable. Contradiction! Note that MH is Turing-recognizable, though. 16

Turing Machines and Algorithms Church-Turing Thesis: Every algorithm can be realized as a Turing Machine. A multitape-tm is equivalent to a single-tape TM. A TM can simulate a computer. A computer with an infnite tape can simulate a TM. Turing Machines are more powerful than modern day computers!! What about Nondeterministic Turing Machines? 17

Non-determinism: The Power of Guessing 18

A Shift Computation models Solvability Complexity Coping with NP-Completeness 19

Can a problem be solved in good-enough time? 20

The P class of problems Problems that can be solved in polynomial time by a Deterministic Turing Machine All practical problems that we write algorithms for Example: Minimum Spanning Tree 21

The Minimum Spanning Tree Problem 22

The NP class of problems Problems that can be solved in polynomial time by a Nondeterministic Turing Machine A given solution can be checked in polynomial time by a Deterministic Turing Machine Even though the power of an NTM is equivalent to that of a DTM, the time requirements of NP may not be in the goodenough zone Example: Travelling Salesman Problem (decision version) 23

The Travelling Salesman Problem 24

Is P = NP? A problem Q is NP-Complete if: Q is in NP All problems in NP can be reduced (in polynomial time) to Q A problem R is NP-Hard if: All problems in NP can be reduced (in polynomial time) to R It s not known whether R is in NP Thus, if even a single NP-Complete problem can be solved by an algorithm in polynomial time, then P = NP. It seems that P!= NP; however, there is no proof yet! 25

Some popular problems NP-Complete: TSP SAT Subset sum Vertex cover Graph coloring Decision version of TSP NP-Hard but not NP-Complete: The Halting Problem (undecidable) General TSP 26

A conclusive picture: 27

So do we give up? 28

Never surrender! Computation models Solvability Complexity Coping with NP-Completeness 29

Special Cases SAT is NP-Complete. 2-SAT is in P. Vertex cover problem is NP-Complete. Vertex cover problem for bipartite graphs is in P. 30

Intelligent Backtracking Useful for exhaustive space-search problems Consider the SAT instance: 31

Approximation Obtain a near-optimal solution Consider the following problem: There are 11 towns. According to a government policy, each hospital can cover 30 miles of distance around it. Find the optimal number of hospitals that need to be opened. 32

Approximation (Cont.) Can be reduced to the Set Cover problem: Input: A set of elements Output: A selection of S whose union is B i Cost: Number of sets picked Greedy algorithm: At each step, pick the set Si with the largest number of uncovered elements {a, c, j, f} or {a, c, j, g} Optimal: {b, e, i} It can be proved that if the optimal set has k elements, the Greedy algorithm generates at max k.lnn sets. 33

So how do YOU solve problems? Ask others for a solution Think, re-think, and think more Find a best-attempt solution Simplify the problem Try to generalize the solution Prove it unsolvable! 34

How do Computer Scientists solve problems? Ask others for a solution Reduction Think, re-think, and think more Different algorithms Find a best-attempt solution Approximation Simplify the problem Special cases Try to generalize the solution Other cases? Prove it unsolvable! Prove it NP-Complete! 35

Stay Hungry, Stay Foolish, Stay Connected www.cse.iitm.ac.in/~manas github.com/manasthakur gist.github.com/manasthakur manasthakur17@gmail.com manasthakur.wordpress.com linkedin.com/in/manasthakur manasthakur.github.io/docs/year3sct.pdf 36