Easy, Hard, and Impossible. Easy Tic Tac Toe Hard.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

NP-Hard Nattee Niparnan.
JAYASRI JETTI CHINMAYA KRISHNA SURYADEVARA
22C:19 Discrete Math Graphs Fall 2010 Sukumar Ghosh.
Introduction to Graph Theory Instructor: Dr. Chaudhary Department of Computer Science Millersville University Reading Assignment Chapter 1.
The 7 Bridges of Konigsberg A puzzle in need of solving.
Lecture 24 Coping with NPC and Unsolvable problems. When a problem is unsolvable, that's generally very bad news: it means there is no general algorithm.
Reducibility Class of problems A can be reduced to the class of problems B Take any instance of problem A Show how you can construct an instance of problem.
1 The Limits of Computation Intractable and Non-computable functions.
AMDM UNIT 7: Networks and Graphs
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 5 The Mathematics of Getting Around 5.1Euler Circuit Problems 5.2What.
Complexity 15-1 Complexity Andrei Bulatov Hierarchy Theorem.
A Presentation By: Jillian Minuto Troy Norman Alan Leggett Group Advisor: Prof. G. Warrington Graph Theory.
Approximation Algorithms: Combinatorial Approaches Lecture 13: March 2.
The Theory of NP-Completeness
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
CHAPTER 4 Decidability Contents Decidable Languages
Analysis of Algorithms CS 477/677
Chapter 11: Limitations of Algorithmic Power
Euler Paths and Circuits. The original problem A resident of Konigsberg wrote to Leonard Euler saying that a popular pastime for couples was to try.
GRAPH Learning Outcomes Students should be able to:
NP-Complete Problems CSC 331: Algorithm Analysis NP-Complete Problems.
EECS 203: It’s the end of the class and I feel fine. Graphs.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
Graph Theory Topics to be covered:
The Power and the Limits of Computation Elaine Rich.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
Structures 7 Decision Maths: Graph Theory, Networks and Algorithms.
Can you connect the dots as shown without taking your pen off the page or drawing the same line twice.
Easy, Hard, and Impossible Elaine Rich. Easy Tic Tac Toe.
Euler and Hamilton Paths. Euler Paths and Circuits The Seven bridges of Königsberg a b c d A B C D.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Unsolvability and Infeasibility. Computability (Solvable) A problem is computable if it is possible to write a computer program to solve it. Can all problems.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
CS 200 Algorithms and Data Structures
CSC 413/513: Intro to Algorithms NP Completeness.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
CSE 3813 Introduction to Formal Languages and Automata Chapter 14 An Introduction to Computational Complexity These class notes are based on material from.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
Halting Problem Introduction to Computing Science and Programming I.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Erdal Kose CC30.10 These slides are based of Prof. N. Yanofsky Lecture notes.
Beauty and Joy of Computing Limits of Computing Ivona Bezáková CS10: UC Berkeley, April 14, 2014 (Slides inspired by Dan Garcia’s slides.)
Computability Heap exercise. The class P. The class NP. Verifiers. Homework: Review RELPRIME proof. Find examples of problems in NP.
CIRCUITS, PATHS, AND SCHEDULES Euler and Königsberg.
Associated Matrices of Vertex Edge Graphs Euler Paths and Circuits Block Days April 30, May 1 and May
Euler Paths and Circuits. The original problem A resident of Konigsberg wrote to Leonard Euler saying that a popular pastime for couples was to try.
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.
Lecture 52 Section 11.2 Wed, Apr 26, 2006
Week 13 - Monday.  What did we talk about last time?  B-trees  Hamiltonian tour  Traveling Salesman Problem.
Easy, Hard, and Impossible Elaine Rich. Easy Tic Tac Toe.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
1 Euler and Hamilton paths Jorge A. Cobb The University of Texas at Dallas.
Grade 11 AP Mathematics Graph Theory Definition: A graph, G, is a set of vertices v(G) = {v 1, v 2, v 3, …, v n } and edges e(G) = {v i v j where 1 ≤ i,
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Introduction to Computing Science and Programming I
EECS 203 Lecture 19 Graphs.
Eulerian tours Miles Jones MTThF 8:30-9:50am CSE 4140 August 15, 2016.
Konigsberg’s Seven Bridges
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
EECS 203 Lecture 20 More Graphs.
Introduction to the Analysis of Complexity
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
Introduction to Graph Theory Euler and Hamilton Paths and Circuits
Graphs Chapter 13.
How Hard Can It Be?.
Breakfast Bytes Easy, Hard, and Impossible
Presentation transcript:

Easy, Hard, and Impossible

Easy

Tic Tac Toe

Hard

Chess

Recall the Approach - Search

Searching for the Best Move A B C D E F G H I J K L M (8) (-6) (0) (0) (2) (5) (-4) (10) (5)

How Much Computation Does it Take? Middle game branching factor  35 Lookahead required to play master level chess  

How Much Computation Does it Take? Middle game branching factor  35 Lookahead required to play master level chess   2,000,000,000,000 Seconds in a year 

How Much Computation Does it Take? Middle game branching factor  35 Lookahead required to play master level chess   2,000,000,000,000 Seconds in a year  31,536,000 Seconds since Big Bang  300,000,000,000,000,000

Growth Rates of Functions

Yet Machines Can Do It In 1997, Deep Blue beat Garry Kasparov.

Seems Hard But Really Easy

Nim The player who takes the last stick(s) wins. At your turn, you must choose a pile, then remove as many sticks from the pile as you like.

Nim Now let’s try:

Nim Now let’s try: Oops, now there are a lot of possibilities to try.

Nim 10 (2) 11 (3) 11 For the current player: Guaranteed loss if last row is all 0’s. Guaranteed win otherwise. My turn:

Nim 100 (4) 010 (2) 101 (5) 011 For the current player: Guaranteed loss if last row is all 0’s. Guaranteed win otherwise. My turn:

Nim 100 (4) 001 (1) 101 (5) 000 For the current player: Guaranteed loss if last row is all 0’s. Guaranteed win otherwise. Your turn:

Following Paths

Seven Bridges of Königsberg

Seven Bridges of Königsberg: Seven Bridges of Königsberg

Seven Bridges of Königsberg: Seven Bridges of Königsberg As a graph:

For Any Graph An Eulerian path : Cross every edge exactly once. All these people care:  Bridge inspectors  Road cleaners  Network analysts

Another Example

Define the degree of a vertex to be the number of edges with it as an endpoint. Another Example

Define the degree of a vertex to be the number of edges with it as an endpoint. Euler observed that: ● Eulerian path if and only if exactly two vertices of odd degree. ● Eulerian circuit if and only if all vertices have even degree. Euler’s Observation

An Efficient Algorithm def eulerian_circuit(vertices, edges): for v in vertices: count = 0 for e in edges: if e touches v: count += 1 if odd(count): return(False) return(True) How many steps does it take?

An Efficient Algorithm def eulerian_circuit(vertices, edges): for v in vertices: count = 0 for e in edges: if e touches v: count += 1 if odd(count): return(False) return(True) How many steps does it take? O(|vertices| * |edges|)

Back to the Bridges As a graph:

The Good King and the Evil King The good king wants to build exactly one new bridge so that: There’s an Eulerian path from the pub to his castle. But there isn’t one from the pub to the castle of his evil brother on the other bank of the river.

Here’s What He Starts With As a graph:

Here’s What He Starts With As a graph:

Unfortuntately, There Isn’t Always a Trick Suppose we need to visit every vertex exactly once.

The Traveling Salesman Problem Find the shortest circuit that visits every city exactly once

Visting Vertices Rather Than Edges ● A Hamiltonian path: visit every vertex exactly once. ● A Hamiltonian circuit: visit every vertex exactly once and end up where you started. All these people care: Salesmen, Farm inspectors, Network analysts

The Traveling Salesman Problem Given n cities: Choose a first cityn Choose a secondn-1 Choose a thirdn-2 … n!

The Traveling Salesman Problem Can we do better than n! ● First city doesn’t matter. ● Order doesn’t matter. So we get (n-1)!/2.

The Growth Rate of n!  10 41

Putting it into Perspective Speed of light 3  10 8 m/sec Width of a proton m At one operation in the time it takes light to cross a proton 3  ops/sec Since Big Bang 3  sec Ops since Big Bang 9  ops36! = 3.6  Neurons in brain10 11 Parallel ops since Big Bang 9  ! = 6  10 52

1.Use a technique that is guaranteed to find an optimal solution and likely to do so quickly. 2.Use a technique that is guaranteed to run quickly and find a “good” solution. Getting Close Enough The Concorde TSP Solver found an optimal route that visits 24,978 cities in Sweden.Concorde TSP The World Tour Problem

Is This The Best We Can Do? It is generally believed that there’s no efficient algorithm that finds an exact solution to: The Traveling Salesman problem The question of whether or not a Hamiltonian circuit exists. Would you like to win $1M? The Millenium Prize

Impossible

An Interesting Puzzle List 1List 2 1bbbb 2babbbba 3 a 4bbbaababbb 2 List 1 b a b b b List 2b a

An Interesting Puzzle List 1List 2 1bbbb 2babbbba 3 a 4bbbaababbb 2 1 List 1 b a b b b b List 2b a b b b

An Interesting Puzzle List 1List 2 1bbbb 2babbbba 3 a 4bbbaababbb List 1 b a b b b b b List 2b a b b b b b b

An Interesting Puzzle List 1List 2 1bbbb 2babbbba 3 a 4bbbaababbb List 1 b a b b b b b b a List 2b a b b b b b b a

The Post Correspondence Problem List 1List

The Post Correspondence Problem List 1List 2 1aba 2 ba 3aabaa

The Post Correspondence Problem List 1List 2 1babab 2abbbb 3bababb

The Post Correspondence Problem List 1List Shortest solution has length 252.

Can A Program Do This? Can we write a program to answer the following question: Given a PCP instance P, decide whether or not P has a solution. Return: True if it does. False if it does not.

The Post Correspondence Problem A program to solve this problem: Until a solution or a dead end is found: If dead end, halt and report no. Generate the next candidate solution. Test it. If it is a solution, halt and report yes. So, if there are say 4 rows in the table, we’ll try: ,1 1,2 1,3 1,4 1,5 2,1 …… 1,1,1 ….

Will This Work? If there is a solution: If there is no solution:

A Tiling Problem

Another Tiling Problem 1 2 3

Another Tiling Problem

Can A Program Do This? Can we write a program to answer the following question: Given a tiling problem T, decide whether or not T can tile a plane. Return: True if it can. False if it can not.

Deciding a Tiling Problem A program to solve this problem: Until the answer is clearly yes or a dead end is found: If dead end, halt and report no. Generate the next candidate solution. Test it. If it is a solution, halt and report yes.

Will This Work? If T can tile a plane: If T can not tile a plane:

Programs Debug Programs name = input(“Type your name: ”) if name == “Elaine”: print (“You win!!”) else: print (“You lose  ”) Given an arbitrary program, can it be guaranteed to halt?

Programs Debug Programs number = input(“Enter number: ”) result = 1 counter = 2 while counter <= number: result = result * counter counter +=1 print (result) Given an arbitrary program, can it be guaranteed to halt?

Programs Debug Programs Given an arbitrary program, can it be guaranteed to halt? Suppose number = 5: result number counter number = input(“Enter number: ”) result = 1 counter = 2 while counter <= number: result = result * counter counter +=1 print (result)

Programs Debug Programs Given an arbitrary program, can it be guaranteed to halt? Suppose number = 5: result number counter number = input(“Enter number: ”) result = 1 counter = 2 while counter <= number: number = number * counter counter +=1 print (result)

Programs Debug Programs Given an arbitrary program, can it be guaranteed to halt? Collatz Conjecture: This program always halts. def threen(value): while value != 1: if value % 2 == 0: value = value//2 else: value = 3 * value + 1 print(value) Recall the 3n+1 problem:

The Impossible The halting problem cannot be solved. We can prove that no program can ever be written that can: Look at an arbitrary program and decide whether or not it always halts. Look at an arbitrary program and a specific input and decide whether or not the program will halt on that input.

What is a Program? A Python program But before Python, before computers even, a simple mathematical model: The Turing Machine Alan Turing

Turing Machines

But we can prove that anything that any standard computer can do can also be done on a Turing machine.

Watch One in Action g?hl=en

The Halting Problem is Not Solvable Suppose, for the sake of argument, that the following program did exist: def halts(string1,string2): if string 1 would halt if run on string 2 : return(True) else: return(False)

The Halting Problem is Not Solvable Consider the following program: def trouble(string): if halts(string, string): while 1 == 1: pass # loop forever else: return Now we invoke trouble( ) What should halts(, ) say? If it: Returns True ( trouble will halt): trouble Returns False ( trouble will not halt): trouble

The Halting Problem is Not Solvable Consider the following program: def trouble(string): if halts(string, string): while 1 == 1: pass # loop forever else: return Now we invoke trouble( ) What should halts(, ) say? If it: Returns True ( trouble will halt): trouble loops Returns False ( trouble will not halt): trouble

The Halting Problem is Not Solvable Consider the following program: def trouble(string): if halts(string, string): while 1 == 1: pass # loop forever else: return Now we invoke trouble( ) What should halts(, ) say? If it: Returns True ( trouble will halt): trouble loops Returns False ( trouble will not halt): trouble halts So both answers lead to contradictions.

Recall the Tiling Problem

Other Unsolvable Problems Tiling: We can encode a, pair as an instance of a tiling problem so that there is an infinite tiling just in case does not halt on … So if the tiling problem were solvable then Halting would be. But Halting isn’t. So neither is the tiling problem.

Recall the Post Correspondence Problem List 1List 2 1aba 2 ba 3aabaa

Other Unsolvable Problems PCP: We can encode a, pair as an instance of PCP so that the PCP problem has a solution just in case halts on List 1 b a b b b b b List 2b a b b b b b b So if PCP were solvable then Halting would be. But Halting isn’t. So neither is PCP.

Which is Amazing Given the things programs can do.

Which is Amazing Given the things programs can do.

Which is Amazing Given the things programs can do.

Which is Amazing Given the things programs can do.

Which is Amazing How does Watson win? Watch a sample round: From Day 1 of the real match: Introduction: IBM’s site: Bad Final Jeopardy: Given the things programs can do.