SlideShare ist ein Scribd-Unternehmen logo
1 von 29
cs1120 Fall 2011
David Evans
16 November 2011   Halting Problems Hockey Team
Reminders
PS7 Due (electronic) 11:59pm tonight
Exam 2 review sessions (Rice 442):
  Today, 7:30pm                My Thursday office
                               hours moved to 4-5pm
  Thursday, 6:30pm
Friday’s class: Rice Hall Dedication
  11am Dedication; noon-3pm Tours;
  3pm Dean Kamen talk; 5pm Scavenger Hunt
  Office hours from now on are in “Davis Commons”!
                                                      2
PS8, Part 1
Option C/W:              Option J:
  Clear description of
  what you plan to do    PS8 Part 1 posted on
  including:               course site.
1. Goal
2. Target audience
3. Plan                  Due next week Tuesday,
4. Team, how you will    22 November (11:59pm)
   manage and
   distribute work

                                                  3
Impossibility Results
                Mathematics (Declarative Knowledge)
Friday/Monday




                 Gödel: Any powerful axiomatic system cannot be
                 both complete and consistent
                       If it is possible to express “This statement has no
                       proof.” in the system, it must be incomplete or
                       inconsistent.
                Computer Science (Imperative Knowledge)
                  Are there (well-defined) problems that cannot be
Now




                  solved by any algorithm?
                    Alan Turing (and Alonzo Church): Yes!
Impossibility of Halts
Recall how Gödel showed incompleteness of PM:
  Find a statement that leads to a contradiction
  Gödel’s statement: “This statement has no proof.”
  The HALTING Problem:
  Input: a string representing a Python program.
  Output: If evaluating the input program would ever finish,
  output true. Otherwise, output false.

 Assume halts(s) is a Python procedure that solves the HALTING
    problem. Is there an input that leads to a contradiction?
Hmm..let’s try self-reference!




                                 6
Informal Proof
    def paradox():
     if halts('paradox()'):
        while True:
           pass
What should halts('paradox() ') evaluate to?
Proving Non-Existence by Contradiction

1. Show X is nonsensical.
2. Show that if you have A you can make X.
3. Therefore, A must not exist.
Proving Non-Existence by Contradiction

1. Show X is nonsensical.
2. Show that if you have A you can make X.
3. Therefore, A must not exist.
   Noncomputability                 Incompleteness
      (Alan Turing)                   (Kurt Gödel)
X = paradox procedure       X = “This statement has no
A = algorithm that solves          proof.”
     HALTING Problem        A = a complete and
                                   consistent axiomatic
                                   system
Halting Problem is Non-Computable

                           1. paradox leads to a
                              contradiction.
 def paradox():            2. If we have halts, an
  if halts('paradox()'):      algorithm that solves the
     while True:              Halting Problem, we can
                              define paradox.
        pass               3. Therefore, halts must not
                              exist.


   Are there any other noncomputable problems?
Evaluates-to-3 Problem
Input: A string, s, representing a Python
  program.
Output: True if s evaluates to 3;
  otherwise, False.


     Is “Evaluates-to-3” computable?
Proof by Contradiction
1. Show X is nonsensical.
2. Show that if you have A you can make X.
3. Therefore, A must not exist.


     X = halts algorithm
     A = Evaluates-to-3 algorithm
Undecidability Proof
Suppose we could define evaluates_to_3(s).
that decides it. Could we define halts(s)?
Undecidability Proof

     def halts(s):
      return evaluates_to_3(
         cleanreturns(s) + ''''''
           return 3
                      Where cleanreturns(s) is a
           ''''')     procedure that replaces all return x
                                     statements in s with x; return 3
The only way the program s passed to evaluates_to_3 could not evaluate
to 3, is if s doesn’t halt. (Note: assumes evaluating s cannot produce an
error, but we can use error handling to deal with this case.)
How convincing is our
              Halting Problem proof?
                                  1. paradox leads to a
def paradox():                       contradiction.
 if halts('paradox()'):           2. If we have halts, an algorithm
                                     that solves the Halting
    while True:                      Problem, we can define
       pass                          paradox.
                                  3. Therefore, halts must not exist.

“Proof” assumes Python exists and means exactly what it should!
Python is too complex to believe this (and Turing didn’t have it, of
course!): need a simple and precise model of computation.
Turing’s Model: Turing Machine
...   #   1   0      1    1   0     1   1    1    0    1    1    0    1       1    1    #    ...
                  Infinite Tape: Finite set of symbols, one in each square
                                 Can read/write one square each step


      Start               Input: #                                           Controller:
                                                      Input: 1               Limited (finite)
                          Write: #
                                                      Write: 0               number of states
                          Move:
                                                      Move:
                 1
                                                                             Follow rules based
                                            2         Input: 0
                                                                             on current state
                                                                             and read symbol
                                                      Write: #
      Input: 1           Input: 0                     Move: Halt             Write one square
      Write: 1           Write: 0                                            each step, move
      Move:              Move:
                                                             3
                                                                             left or right or
                                                                             halt, change state

                                                                                                  16
Turing Machine Summary
Model Input, Output, and Scratch Memory
 Infinite tape, divided into discrete squares
 Each square can contain a single symbol from
     a finite alphabet
Model Processing
 Finite State Machine
     Keep track of a finite state (in your head)
     Follow transition rules:
       next state = f(current state, input symbol)

                                                     17
Halting Problem for TM

Input: a string describing a Turing Machine, M

Output: if M would eventually Halt, output True;
 otherwise, output False.

Is there a Turing Machine that solves the Halting Problem for TMs?



                                                                     18
Turing Machine State
    Infinite Tape
z     z              z                 z              z   z                 z             z   z      z    z    z   z    z    z    z   z    z   z   z


                                                                                                  TuringMachine ::= < Alphabet, Tape, FSM >
                                            ), X, L
          ), #, R
                                                                                                  Alphabet ::= { Symbol* }
                                                                                (, #, L

                                   1
                                                            2:
                                                          look
                                                          for (
                                                                                                  Tape ::= < LeftSide, Current, RightSide >
             Start

                                            (, X, R
                                                                                                  OneSquare ::= Symbol | #
                                                                                                  Current ::= OneSquare
                         #, 1, -
                                              HALT
                                                                  #, 0, -
                                                                                                  LeftSide ::= [ Square* ]
                                           Finite State Machine                                   RightSide ::= [ Square* ]

                                                                                                  Everything to left of LeftSide is #.
                                                                                                  Everything to right of RightSide is #.

                              Although we typically draw TMs as pictures, we could write them down as
                              strings in this language (which could be converted to whole numbers)
Enumerating Turing Machines
Now that we’ve decided how to describe Turing
 Machines, we can number them
TM-5023582376       = balancing parens
TM-57239683314      = less than function (Exam 1)
TM-                 = Universal TM
      3523796834721038296738259873



TM-   3672349872381692309875823987609823712347823   = Angry Birds
         Not the real numbers –
       they would be much much
        much much much bigger!
Halting Problem
Pythonic Halting Problem           TM Halting Problem

Input: a string describing a    Input: a string describing a
   Python program, P               Turing Machine, M

Output: if evaluating P would   Output: if M would eventually
  eventually finish, output       Halt, output True;
  True; otherwise, output         otherwise, output False.
  False.
Halting Problem “Proof”
Pythonic Halting Problem                        TM Halting Problem

                                    HALTS(M) = TM that solves TM Halting
  def paradox():                    Problem: input tape describes TM
   if halts('paradox()'):           M, output tape: #1 if M
      while True:                   halts, otherwise #0
         pass
                                    PARADOX = TM that:
                                      1. simulates HALTS(PARADOX)
                                      2. Then, if tape is #1, loop forever;
                                         if tape is #0, HALT
    simulates? This proof assumes we can design a TM that simulates any other TM!
An Any TM Simulator
    Input: < Description of some TM M, w >
    Output: result of running M on w

M                                   Output
             Universal              Tape
              Turing                for running
                                    TM-M
w            Machine                starting on
                                    tape w
Manchester Illuminated Universal Turing Machine, #9
from http://www.verostko.com/manchester/manchester.html
Universal Computing Machine
 2-state, 3-symbol Turing machine proved
      universal by Alex Smith in 2007




                         Alex Smith,
                  University of Birmingham
What This Means
If you can:
   Keep track of a finite state
   Follow transition rules
   Read and write to memory
   you can simulate a universal Turing machine.
A Turing machine can simulate the world’s most
   powerful supercomputer (it’ll just take a lot
   longer and will run out of memory)
It is impossible to solve the Halting Problem for any
   computing system that can simulate a TM
Alan Turing (1912-1954)
Published On Computable Numbers … (1936)
   Introduced the Halting Problem 5 years after
   Formal model of computation    Gödel’s proof!
     (now known as “Turing Machine”)
Codebreaker at Bletchley Park
   Led efforts to break Enigma Cipher
   Contributed to Colossus
After the war: convicted of “gross indecency”
  (homosexuality, then a crime in
  Britain), forced to undergo hormone
  treatments, committed suicide eating
  cyanide apple
Prime Minister’s Apology
It is no exaggeration to say that, without his outstanding
contribution, the history of World War Two could well have
been very different. He truly was one of those individuals we
can point to whose unique contribution helped to turn the
tide of war. The debt of gratitude he is owed makes it all the
more horrifying, therefore, that he was treated so
inhumanely....

So on behalf of the British government, and all those who
live freely thanks to Alan’s work I am very proud to say:
we’re sorry, you deserved so much better.

                           Gordon Brown, 10 September 2009
Charge
Before midnight tonight: submit PS7
Exam Review Sessions:
  Today, 7:30pm; Thursday, 6:30pm
Friday’s Class: Rice Hall Dedication
Monday: Exam 2 out
Tuesday: PS8 Part 1 Due



                                       29

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207Volume 2-issue-6-2205-2207
Volume 2-issue-6-2205-2207
 
Invariant-Free Clausal Temporal Resolution
Invariant-Free Clausal Temporal ResolutionInvariant-Free Clausal Temporal Resolution
Invariant-Free Clausal Temporal Resolution
 
nuts and bolts of c++
nuts and bolts of c++nuts and bolts of c++
nuts and bolts of c++
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statement
 
Cse lecture-7-c loop
Cse lecture-7-c loopCse lecture-7-c loop
Cse lecture-7-c loop
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlan
 
Flow of Control
Flow of ControlFlow of Control
Flow of Control
 
Ch6
Ch6Ch6
Ch6
 
Pattern matching
Pattern matchingPattern matching
Pattern matching
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
 
Computability, turing machines and lambda calculus
Computability, turing machines and lambda calculusComputability, turing machines and lambda calculus
Computability, turing machines and lambda calculus
 
NP completeness
NP completenessNP completeness
NP completeness
 
PNP
PNPPNP
PNP
 
Program control statements in c#
Program control statements in c#Program control statements in c#
Program control statements in c#
 
lecture 29
lecture 29lecture 29
lecture 29
 
Scala: Pattern matching, Concepts and Implementations
Scala: Pattern matching, Concepts and ImplementationsScala: Pattern matching, Concepts and Implementations
Scala: Pattern matching, Concepts and Implementations
 
App a
App aApp a
App a
 
Seminar on quantum automata (complete)
Seminar on quantum automata (complete)Seminar on quantum automata (complete)
Seminar on quantum automata (complete)
 
Mp neuron
Mp neuronMp neuron
Mp neuron
 
report
reportreport
report
 

Ähnlich wie Class 36: Halting Problem

1LECTURE 9TuringMachines.ppt
1LECTURE 9TuringMachines.ppt1LECTURE 9TuringMachines.ppt
1LECTURE 9TuringMachines.pptMarvin886766
 
Class 16: Making Loops
Class 16: Making LoopsClass 16: Making Loops
Class 16: Making LoopsDavid Evans
 
Winter 8 Tutorial TM.pptx
Winter 8 Tutorial TM.pptxWinter 8 Tutorial TM.pptx
Winter 8 Tutorial TM.pptxHarisPrince
 
Coding in Disaster Relief - Worksheet (Advanced)
Coding in Disaster Relief - Worksheet (Advanced)Coding in Disaster Relief - Worksheet (Advanced)
Coding in Disaster Relief - Worksheet (Advanced)Charling Li
 
How Hard Can a Problem Be ?
How Hard Can a Problem Be ?How Hard Can a Problem Be ?
How Hard Can a Problem Be ?Ahmed Saeed
 
Dynamic Programming - Laughlin Lunch and Learn
Dynamic Programming - Laughlin Lunch and LearnDynamic Programming - Laughlin Lunch and Learn
Dynamic Programming - Laughlin Lunch and LearnBillie Rose
 
2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練Abner Huang
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptxssuser47f7f2
 
Winter 8 TM.pptx
Winter 8 TM.pptxWinter 8 TM.pptx
Winter 8 TM.pptxHarisPrince
 
Python programming workshop session 2
Python programming workshop session 2Python programming workshop session 2
Python programming workshop session 2Abdul Haseeb
 
constructing_generic_algorithms__ben_deane__cppcon_2020.pdf
constructing_generic_algorithms__ben_deane__cppcon_2020.pdfconstructing_generic_algorithms__ben_deane__cppcon_2020.pdf
constructing_generic_algorithms__ben_deane__cppcon_2020.pdfSayanSamanta39
 
Theory of computation:Finite Automata, Regualr Expression, Pumping Lemma
Theory of computation:Finite Automata, Regualr Expression, Pumping LemmaTheory of computation:Finite Automata, Regualr Expression, Pumping Lemma
Theory of computation:Finite Automata, Regualr Expression, Pumping LemmaPRAVEENTALARI4
 

Ähnlich wie Class 36: Halting Problem (20)

1LECTURE 9TuringMachines.ppt
1LECTURE 9TuringMachines.ppt1LECTURE 9TuringMachines.ppt
1LECTURE 9TuringMachines.ppt
 
Class 16: Making Loops
Class 16: Making LoopsClass 16: Making Loops
Class 16: Making Loops
 
Winter 8 Tutorial TM.pptx
Winter 8 Tutorial TM.pptxWinter 8 Tutorial TM.pptx
Winter 8 Tutorial TM.pptx
 
Coding in Disaster Relief - Worksheet (Advanced)
Coding in Disaster Relief - Worksheet (Advanced)Coding in Disaster Relief - Worksheet (Advanced)
Coding in Disaster Relief - Worksheet (Advanced)
 
How Hard Can a Problem Be ?
How Hard Can a Problem Be ?How Hard Can a Problem Be ?
How Hard Can a Problem Be ?
 
Dynamic Programming - Laughlin Lunch and Learn
Dynamic Programming - Laughlin Lunch and LearnDynamic Programming - Laughlin Lunch and Learn
Dynamic Programming - Laughlin Lunch and Learn
 
CS.15.Turing.pdf
CS.15.Turing.pdfCS.15.Turing.pdf
CS.15.Turing.pdf
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練2009 CSBB LAB 新生訓練
2009 CSBB LAB 新生訓練
 
Matlab Script - Loop Control
Matlab Script - Loop ControlMatlab Script - Loop Control
Matlab Script - Loop Control
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
Theory of computation and automata
Theory of computation and automataTheory of computation and automata
Theory of computation and automata
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptx
 
Winter 8 TM.pptx
Winter 8 TM.pptxWinter 8 TM.pptx
Winter 8 TM.pptx
 
Python programming workshop session 2
Python programming workshop session 2Python programming workshop session 2
Python programming workshop session 2
 
L06
L06L06
L06
 
constructing_generic_algorithms__ben_deane__cppcon_2020.pdf
constructing_generic_algorithms__ben_deane__cppcon_2020.pdfconstructing_generic_algorithms__ben_deane__cppcon_2020.pdf
constructing_generic_algorithms__ben_deane__cppcon_2020.pdf
 
lect_23.pdf
lect_23.pdflect_23.pdf
lect_23.pdf
 
Turing machine
Turing machineTuring machine
Turing machine
 
Theory of computation:Finite Automata, Regualr Expression, Pumping Lemma
Theory of computation:Finite Automata, Regualr Expression, Pumping LemmaTheory of computation:Finite Automata, Regualr Expression, Pumping Lemma
Theory of computation:Finite Automata, Regualr Expression, Pumping Lemma
 

Mehr von David Evans

Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!David Evans
 
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksTrick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksDavid Evans
 
Hidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeHidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeDavid Evans
 
Anonymity in Bitcoin
Anonymity in BitcoinAnonymity in Bitcoin
Anonymity in BitcoinDavid Evans
 
Midterm Confirmations
Midterm ConfirmationsMidterm Confirmations
Midterm ConfirmationsDavid Evans
 
Scripting Transactions
Scripting TransactionsScripting Transactions
Scripting TransactionsDavid Evans
 
How to Live in Paradise
How to Live in ParadiseHow to Live in Paradise
How to Live in ParadiseDavid Evans
 
Mining Economics
Mining EconomicsMining Economics
Mining EconomicsDavid Evans
 
Becoming More Paranoid
Becoming More ParanoidBecoming More Paranoid
Becoming More ParanoidDavid Evans
 
Asymmetric Key Signatures
Asymmetric Key SignaturesAsymmetric Key Signatures
Asymmetric Key SignaturesDavid Evans
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to CryptographyDavid Evans
 
Class 1: What is Money?
Class 1: What is Money?Class 1: What is Money?
Class 1: What is Money?David Evans
 
Multi-Party Computation for the Masses
Multi-Party Computation for the MassesMulti-Party Computation for the Masses
Multi-Party Computation for the MassesDavid Evans
 
Proof of Reserve
Proof of ReserveProof of Reserve
Proof of ReserveDavid Evans
 
Blooming Sidechains!
Blooming Sidechains!Blooming Sidechains!
Blooming Sidechains!David Evans
 
Useful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinUseful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinDavid Evans
 

Mehr von David Evans (20)

Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!
 
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for CypherpunksTrick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
 
Hidden Services, Zero Knowledge
Hidden Services, Zero KnowledgeHidden Services, Zero Knowledge
Hidden Services, Zero Knowledge
 
Anonymity in Bitcoin
Anonymity in BitcoinAnonymity in Bitcoin
Anonymity in Bitcoin
 
Midterm Confirmations
Midterm ConfirmationsMidterm Confirmations
Midterm Confirmations
 
Scripting Transactions
Scripting TransactionsScripting Transactions
Scripting Transactions
 
How to Live in Paradise
How to Live in ParadiseHow to Live in Paradise
How to Live in Paradise
 
Bitcoin Script
Bitcoin ScriptBitcoin Script
Bitcoin Script
 
Mining Economics
Mining EconomicsMining Economics
Mining Economics
 
Mining
MiningMining
Mining
 
The Blockchain
The BlockchainThe Blockchain
The Blockchain
 
Becoming More Paranoid
Becoming More ParanoidBecoming More Paranoid
Becoming More Paranoid
 
Asymmetric Key Signatures
Asymmetric Key SignaturesAsymmetric Key Signatures
Asymmetric Key Signatures
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to Cryptography
 
Class 1: What is Money?
Class 1: What is Money?Class 1: What is Money?
Class 1: What is Money?
 
Multi-Party Computation for the Masses
Multi-Party Computation for the MassesMulti-Party Computation for the Masses
Multi-Party Computation for the Masses
 
Proof of Reserve
Proof of ReserveProof of Reserve
Proof of Reserve
 
Silk Road
Silk RoadSilk Road
Silk Road
 
Blooming Sidechains!
Blooming Sidechains!Blooming Sidechains!
Blooming Sidechains!
 
Useful Proofs of Work, Permacoin
Useful Proofs of Work, PermacoinUseful Proofs of Work, Permacoin
Useful Proofs of Work, Permacoin
 

Kürzlich hochgeladen

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Kürzlich hochgeladen (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

Class 36: Halting Problem

  • 1. cs1120 Fall 2011 David Evans 16 November 2011 Halting Problems Hockey Team
  • 2. Reminders PS7 Due (electronic) 11:59pm tonight Exam 2 review sessions (Rice 442): Today, 7:30pm My Thursday office hours moved to 4-5pm Thursday, 6:30pm Friday’s class: Rice Hall Dedication 11am Dedication; noon-3pm Tours; 3pm Dean Kamen talk; 5pm Scavenger Hunt Office hours from now on are in “Davis Commons”! 2
  • 3. PS8, Part 1 Option C/W: Option J: Clear description of what you plan to do PS8 Part 1 posted on including: course site. 1. Goal 2. Target audience 3. Plan Due next week Tuesday, 4. Team, how you will 22 November (11:59pm) manage and distribute work 3
  • 4. Impossibility Results Mathematics (Declarative Knowledge) Friday/Monday Gödel: Any powerful axiomatic system cannot be both complete and consistent If it is possible to express “This statement has no proof.” in the system, it must be incomplete or inconsistent. Computer Science (Imperative Knowledge) Are there (well-defined) problems that cannot be Now solved by any algorithm? Alan Turing (and Alonzo Church): Yes!
  • 5. Impossibility of Halts Recall how Gödel showed incompleteness of PM: Find a statement that leads to a contradiction Gödel’s statement: “This statement has no proof.” The HALTING Problem: Input: a string representing a Python program. Output: If evaluating the input program would ever finish, output true. Otherwise, output false. Assume halts(s) is a Python procedure that solves the HALTING problem. Is there an input that leads to a contradiction?
  • 7. Informal Proof def paradox(): if halts('paradox()'): while True: pass What should halts('paradox() ') evaluate to?
  • 8. Proving Non-Existence by Contradiction 1. Show X is nonsensical. 2. Show that if you have A you can make X. 3. Therefore, A must not exist.
  • 9. Proving Non-Existence by Contradiction 1. Show X is nonsensical. 2. Show that if you have A you can make X. 3. Therefore, A must not exist. Noncomputability Incompleteness (Alan Turing) (Kurt Gödel) X = paradox procedure X = “This statement has no A = algorithm that solves proof.” HALTING Problem A = a complete and consistent axiomatic system
  • 10. Halting Problem is Non-Computable 1. paradox leads to a contradiction. def paradox(): 2. If we have halts, an if halts('paradox()'): algorithm that solves the while True: Halting Problem, we can define paradox. pass 3. Therefore, halts must not exist. Are there any other noncomputable problems?
  • 11. Evaluates-to-3 Problem Input: A string, s, representing a Python program. Output: True if s evaluates to 3; otherwise, False. Is “Evaluates-to-3” computable?
  • 12. Proof by Contradiction 1. Show X is nonsensical. 2. Show that if you have A you can make X. 3. Therefore, A must not exist. X = halts algorithm A = Evaluates-to-3 algorithm
  • 13. Undecidability Proof Suppose we could define evaluates_to_3(s). that decides it. Could we define halts(s)?
  • 14. Undecidability Proof def halts(s): return evaluates_to_3( cleanreturns(s) + '''''' return 3 Where cleanreturns(s) is a ''''') procedure that replaces all return x statements in s with x; return 3 The only way the program s passed to evaluates_to_3 could not evaluate to 3, is if s doesn’t halt. (Note: assumes evaluating s cannot produce an error, but we can use error handling to deal with this case.)
  • 15. How convincing is our Halting Problem proof? 1. paradox leads to a def paradox(): contradiction. if halts('paradox()'): 2. If we have halts, an algorithm that solves the Halting while True: Problem, we can define pass paradox. 3. Therefore, halts must not exist. “Proof” assumes Python exists and means exactly what it should! Python is too complex to believe this (and Turing didn’t have it, of course!): need a simple and precise model of computation.
  • 16. Turing’s Model: Turing Machine ... # 1 0 1 1 0 1 1 1 0 1 1 0 1 1 1 # ... Infinite Tape: Finite set of symbols, one in each square Can read/write one square each step Start Input: # Controller: Input: 1 Limited (finite) Write: # Write: 0 number of states Move: Move: 1 Follow rules based 2 Input: 0 on current state and read symbol Write: # Input: 1 Input: 0 Move: Halt Write one square Write: 1 Write: 0 each step, move Move: Move: 3 left or right or halt, change state 16
  • 17. Turing Machine Summary Model Input, Output, and Scratch Memory Infinite tape, divided into discrete squares Each square can contain a single symbol from a finite alphabet Model Processing Finite State Machine Keep track of a finite state (in your head) Follow transition rules: next state = f(current state, input symbol) 17
  • 18. Halting Problem for TM Input: a string describing a Turing Machine, M Output: if M would eventually Halt, output True; otherwise, output False. Is there a Turing Machine that solves the Halting Problem for TMs? 18
  • 19. Turing Machine State Infinite Tape z z z z z z z z z z z z z z z z z z z z TuringMachine ::= < Alphabet, Tape, FSM > ), X, L ), #, R Alphabet ::= { Symbol* } (, #, L 1 2: look for ( Tape ::= < LeftSide, Current, RightSide > Start (, X, R OneSquare ::= Symbol | # Current ::= OneSquare #, 1, - HALT #, 0, - LeftSide ::= [ Square* ] Finite State Machine RightSide ::= [ Square* ] Everything to left of LeftSide is #. Everything to right of RightSide is #. Although we typically draw TMs as pictures, we could write them down as strings in this language (which could be converted to whole numbers)
  • 20. Enumerating Turing Machines Now that we’ve decided how to describe Turing Machines, we can number them TM-5023582376 = balancing parens TM-57239683314 = less than function (Exam 1) TM- = Universal TM 3523796834721038296738259873 TM- 3672349872381692309875823987609823712347823 = Angry Birds Not the real numbers – they would be much much much much much bigger!
  • 21. Halting Problem Pythonic Halting Problem TM Halting Problem Input: a string describing a Input: a string describing a Python program, P Turing Machine, M Output: if evaluating P would Output: if M would eventually eventually finish, output Halt, output True; True; otherwise, output otherwise, output False. False.
  • 22. Halting Problem “Proof” Pythonic Halting Problem TM Halting Problem HALTS(M) = TM that solves TM Halting def paradox(): Problem: input tape describes TM if halts('paradox()'): M, output tape: #1 if M while True: halts, otherwise #0 pass PARADOX = TM that: 1. simulates HALTS(PARADOX) 2. Then, if tape is #1, loop forever; if tape is #0, HALT simulates? This proof assumes we can design a TM that simulates any other TM!
  • 23. An Any TM Simulator Input: < Description of some TM M, w > Output: result of running M on w M Output Universal Tape Turing for running TM-M w Machine starting on tape w
  • 24. Manchester Illuminated Universal Turing Machine, #9 from http://www.verostko.com/manchester/manchester.html
  • 25. Universal Computing Machine 2-state, 3-symbol Turing machine proved universal by Alex Smith in 2007 Alex Smith, University of Birmingham
  • 26. What This Means If you can: Keep track of a finite state Follow transition rules Read and write to memory you can simulate a universal Turing machine. A Turing machine can simulate the world’s most powerful supercomputer (it’ll just take a lot longer and will run out of memory) It is impossible to solve the Halting Problem for any computing system that can simulate a TM
  • 27. Alan Turing (1912-1954) Published On Computable Numbers … (1936) Introduced the Halting Problem 5 years after Formal model of computation Gödel’s proof! (now known as “Turing Machine”) Codebreaker at Bletchley Park Led efforts to break Enigma Cipher Contributed to Colossus After the war: convicted of “gross indecency” (homosexuality, then a crime in Britain), forced to undergo hormone treatments, committed suicide eating cyanide apple
  • 28. Prime Minister’s Apology It is no exaggeration to say that, without his outstanding contribution, the history of World War Two could well have been very different. He truly was one of those individuals we can point to whose unique contribution helped to turn the tide of war. The debt of gratitude he is owed makes it all the more horrifying, therefore, that he was treated so inhumanely.... So on behalf of the British government, and all those who live freely thanks to Alan’s work I am very proud to say: we’re sorry, you deserved so much better. Gordon Brown, 10 September 2009
  • 29. Charge Before midnight tonight: submit PS7 Exam Review Sessions: Today, 7:30pm; Thursday, 6:30pm Friday’s Class: Rice Hall Dedication Monday: Exam 2 out Tuesday: PS8 Part 1 Due 29