Computability: Exploring Theoretical Limits of Computation

EXERCISE #2
1
OVERVIEW REVIEW
Write your name and answer the following on a piece of paper
What is Rice’s Theorem? How does it interact with the halting problem?
COMPUTABILITY
EECS 677: Software Security Evaluation
Drew Davidson
ADMINISTRIVIA
AND
ANNOUNCEMENTS
 
THE HALTING PROBLEM
GIVEN AN ARBITRARY COMPUTER
PROGRAM AND AN INPUT, DETERMINE
WHETHER THE PROGRAM WILL FINISH
RUNNING, OR CONTINUE TO RUN
FOREVER
4
TODAY’S ROADMAP
Decidability
The Halting Problem
Type I/Type II Errors
Soundness / Completeness
THE LIMITS OF COMPUTATION
6
DECIDABILITY
Computers! What 
can’t
 they do?!
As we begin our exploration of security
evaluation, we care about this question for
two reasons:
We need to know the capabilities of our
analysis target
We need to know the capabilities of our
analysis engine
THEORETICAL LIMITS OF COMPUTATION
7
DECIDABILITY
Computability theory
The study of what is computable
Focused on abstractions for the sake
of generalizability
Considers theoretical hardware,
for example
COMPUTATIONAL POWER
8
DECIDABILITY
What is a program?
A set of executable instructions
COMPUTATIONAL POWER
9
DECIDABILITY
What is a program?
A set of executable instructions
There are many formats for programs
i.e. programming languages
It would be nice to generalize what these
programs can compute (without getting
bogged down in syntax)
ABSTRACTING COMPUTATION
10
DECIDABILITY
Computability theory considers
classes of expressiveness
Combinational logic
Finite-state machines
Pushdown automata
Turing machines
ABSTRACTING COMPUTATION
11
DECIDABILITY
Computability theory considers
classes of expressiveness
Combinational logic
Finite-state machines
Pushdown automata
Turing machines
ABSTRACTING COMPUTATION
12
DECIDABILITY
Computability theory considers
classes of expressiveness
Combinational logic
Finite-state machines
Pushdown automata
Turing machines
ABSTRACTING COMPUTATION
13
DECIDABILITY
Computability theory considers
classes of expressiveness
Combinational logic
Finite-state machines
Pushdown automata
Turing machines
CHURCH-TURING THESIS
14
DECIDABILITY
 
Roughly:
 a function on the natural numbers can be calculated if and only if it is
computable by a 
T
uring machine
 
Practical Upshot:
 Turing machines are powerful!
Turing
Machine
15
VIBE CHECK
DECIDABILITY
 
Does everyone remember why we are doing this?
We want to determine the power of our analysis target
We want to determine the power of our analysis engine
Good news! Both are bounded by 
T
uring computability
Next up: abstracting analysis itself
DECISION PROCEDURES
16
DECIDABILITY
A little vocabulary:
A 
decision problem 
is a computational question that can be solved with either a yes or a no. 
Frequently,
we consider decision problems as detection of a property in a program
A 
decision procedure
 is a method for solving a decision problem that always yields the correct answer
If ther
e is no decision procedure for a given decision problem, that decision problem is called 
undecidable
PROGRAM ANALYSIS
AS DECISION PROCEDURE
17
DECIDABILITY
Since a program is just a list of
instructions, it is valid input to a
decision procedure
Analysis Engine
(property detector
program)
Analysis Target
(arbitrary program)
Yes
(property
present)
No
(property is
not present)
STRONG GUARANTEES
18
DECIDABILITY
A decision procedure is a high bar
Guarantee that:
T
he analysis engine accepts every program
The analysis engine always returns an answer
The answer returned is always correct
Analysis Engine
(property detector
program)
Analysis Target
(arbitrary program)
Yes
(property
present)
No
(property is
not present)
TODAY’S ROADMAP
Decidability
The Halting Problem
Type I/Type II Errors
Soundness / Completeness
STATING THE PROBLEM
20
THE HALTING PROBLEM
Given a description of a Turing machine
and its initial input, determine whether the
program, when executed on this input, ever
halts (completes). The alternative is that it
runs forever without halting
A HALTING DETECTOR
21
THE HALTING PROBLEM
Given a description of a Turing machine
and its initial input, determine whether the
program, when executed on this input, ever
halts (completes). The alternative is that it
runs forever without halting
Is there a decision procedure for the
halting problem?
-
We’ll sketch the proof outline that there is NOT
-
Relies on a proof by contradiction
Halting Detector
Analysis Target
+ Input
(arbitrary program)
Yes
(target halts)
No
(target spins)
PROOF BY CONTRADICTION
22
THE HALTING PROBLEM
Reductio ad absurdum – 
Assuming the premise has obviously incorrect consequences
Here: assume there is a halting detector
Halting
Detector
Yes
(target
halts)
No
(target
spins)
 
halts(ANY ARBITRARY PROGRAM)
 
black_magic(){
   if (halts(black_magic){
     while(true){} //Spin
   }
   //Halt
}
 
Assumption
Black_magic
black_magic
halts
Black_magic
spins
 
spin
 
halt
Black_magic
Halting
Detector
WHO CARES?
23
THE HALTING PROBLEM
No halting decision procedure means no reachability decision procedure
1. int main(){
2.    if (my_function()){
3.       int * a = nullptr;
4.       *a = 1;
5.    }
6. }
black_magic()
This program crashes if and only if it reaches line 4,
which depends on the result of a function call being
true
RICE’S THEOREM
24
THE HALTING PROBLEM
No halting decision procedure means no reachability decision procedure
1. int main(){
2.    if (my_function()){
3.       int * a = nullptr;
4.       *a = 1;
5.    }
6. }
black_magic()
This program crashes if and only if it reaches line 4,
which depends on the result of a function call being
true
Exhibits the behavior you care about
behavior you care about
RICE’S THEOREM
25
THE HALTING PROBLEM
“All non-trivial semantic properties of programs are undecidable”
LIMITATIONS OF RICE’S THEOREM
26
THE HALTING PROBLEM
Rice’s Theorem is less catastrophic than you might expect for security:
A decision procedure is a pretty high bar
A Turing machine is actually not a perfect approximation of the computers we use!
Despite these limitations, it is widely accepted that program analysis is 
always
approximate
We can’t be right all of the time
We can choose what types of errors we make
TODAY’S ROADMAP
Decidability
The Halting Problem
Categorizing Program Analyses
Soundness / Completeness
TYPES OF ANALYSIS
28
CATEGORIZING PROGRAM ANALYSES
In order to determine the properties of a given program analysis, let’s frame it as a
detector
Analysis Engine
(property detector
program)
Analysis Target
(arbitrary program)
Yes
(property
present)
No
(property is
not present)
 
Note: we can detect bad
behavior or good behavior
CLASSIFYING ERRORS
29
CATEGORIZING PROGRAM ANALYSES
Positive
Negative
True
False
Has report
Has bug
No report
No bug
No bug
Has report
No report
Has bug
report
bug
No bug
report
Analysis is correct
Analysis is wrong
Correct
Correct
Type I 
Error
Type II 
Error
Analysis Engine
(bug detector)
Analysis Target
(arbitrary program)
Yes
(buggy)
No
(property is
not present)
TODAY’S ROADMAP
Decidability
The Halting Problem
Categorizing Program Analyses
Soundness / Completeness
GUARANTEES OF IMPERFECT ANALYSES
31
SOUNDNESS / COMPLETENESS
Consistency / Reliability super important for users
We’d like to limit the 
kinds
 of errors we report
We can choose which type of bug report error to avoid
Soundness: No false positives
Completeness: No false negatives
VISUAL ANALOGY
32
SOUNDNESS / COMPLETENESS
 
Imagine the universe of all
programs is contained in a circle
You can draw a circle around the
programs you report as buggy
The actual buggy programs
occupy a jagged region
Buggy programs
 
Reported
bugs
VISUAL ANALOGY
33
SOUNDNESS / COMPLETENESS
All Programs
 
All Programs
 
Complete bug detection
 
Reported
bugs
 
All buggy programs get flagged
(No false negative problem)
 
Some correct programs get flagged
(has false positive problem)
 
False
Positive
Buggy programs
Buggy programs
 
Reported
bugs
 
Sound bug detection
 
Some buggy programs pass through
(has false negative problem)
 
All correct programs pass through
(No false positive problem)
 
False
Negative
TRIVIAL SOUNDNESS
34
CATEGORIZING PROGRAM ANALYSES
All Programs
Buggy programs
 
Reported
bugs
 
Sound bug detection
 
Some buggy programs pass through
(has false negative problem)
 
All correct programs pass through
(No false positive problem)
 
False
Negative
Analysis Engine
(bug detector)
Analysis Target
(arbitrary program)
No
(property is
not present)
TRIVIAL COMPLETENESS
35
CATEGORIZING PROGRAM ANALYSES
Analysis Engine
(bug detector)
Analysis Target
(arbitrary program)
Yes
(buggy)
 
All Programs
 
Complete bug detection
 
Reported
bugs
 
All buggy programs get flagged
(No false negative problem)
 
Some correct programs get flagged
(has false positive problem)
 
False
Positive
Buggy programs
36
BEYOND ALL-OR-NOTHING
SOUNDNESS / COMPLETENESS
As you can imagine, soundness and completeness are not the full story
Guarantees are nice, but we want legitimately useful analyses!
Many practical analyses are neither sound nor complete
37
STATIC VS DYNAMIC ANALYSIS
SOUNDNESS / COMPLETENESS
One distinction in analysis is how
the analysis treats the target
Static analysis – Operates
without running the program
Dynamic analysis  - Operates
with running the program
38
ANALYSIS METHOD VS ERRORS
SOUNDNESS / COMPLETENESS
It’s natural to consider the types of compromises of each
analysis method
Static analysis
Often builds a model of the program, makes
inferences on that model
Tends to make completeness easier
Scalability concerns for large programs
Dynamic analysis
Often performs the analysis by straight up running
the program, observing behavior
Tends to make soundness easier
Coverage problems
39
ABOUT COVERAGE
SOUNDNESS / COMPLETENESS
 
Line coverage
 
Path coverage
 
Branch coverage
int f(bool b) {
    Obj * o = null;
    int v = 2;
    if (b) {
        o = new Obj ();
        v = rand_int();
    }
    if (v == 2){
        o->setInvalid()
    }
    return o->property();
}
LECTURE END
Summary:
-
Decidability
-
Computational Theory
-
Categorizing analysis
41
42
43
Slide Note
Embed
Share

Delve into computability theory, focusing on what is computable and the limits of computation. Explore concepts like Rice's Theorem, the Halting Problem, and classes of expressiveness in computability theory, such as combinational logic, finite-state machines, pushdown automata, and Turing machines.

  • Computability theory
  • Theoretical limits
  • Computation
  • Rices Theorem
  • Halting Problem

Uploaded on Apr 16, 2024 | 5 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. EXERCISE #2 OVERVIEW REVIEW Write your name and answer the following on a piece of paper What is Rice s Theorem? How does it interact with the halting problem? 1

  2. COMPUTABILITY EECS 677: Software Security Evaluation Drew Davidson

  3. ADMINISTRIVIA AND ANNOUNCEMENTS

  4. 4 THE HALTING PROBLEM GIVEN AN ARBITRARY COMPUTER PROGRAM AND AN INPUT, DETERMINE WHETHER THE PROGRAM WILL FINISH RUNNING, OR CONTINUE TO RUN FOREVER

  5. TODAYS ROADMAP Decidability The Halting Problem Type I/Type II Errors Soundness / Completeness

  6. 6 THE LIMITS OF COMPUTATION DECIDABILITY Computers! What can t they do?! As we begin our exploration of security evaluation, we care about this question for two reasons: We need to know the capabilities of our analysis target We need to know the capabilities of our analysis engine

  7. 7 THEORETICAL LIMITS OF COMPUTATION DECIDABILITY Computability theory The study of what is computable Focused on abstractions for the sake of generalizability Considers theoretical hardware, for example

  8. 8 COMPUTATIONAL POWER DECIDABILITY What is a program? A set of executable instructions

  9. 9 COMPUTATIONAL POWER DECIDABILITY What is a program? A set of executable instructions There are many formats for programs i.e. programming languages It would be nice to generalize what these programs can compute (without getting bogged down in syntax)

  10. 10 ABSTRACTING COMPUTATION DECIDABILITY Computability theory considers classes of expressiveness Combinational logic Finite-state machines Pushdown automata Turing machines

  11. 11 ABSTRACTING COMPUTATION DECIDABILITY Computability theory considers classes of expressiveness Combinational logic Finite-state machines Pushdown automata Turing machines

  12. 12 ABSTRACTING COMPUTATION DECIDABILITY Computability theory considers classes of expressiveness Combinational logic Finite-state machines Pushdown automata Turing machines

  13. 13 ABSTRACTING COMPUTATION DECIDABILITY Computability theory considers classes of expressiveness Combinational logic Finite-state machines Pushdown automata Turing machines

  14. 14 CHURCH-TURING THESIS DECIDABILITY Roughly: a function on the natural numbers can be calculated if and only if it is computable by a Turing machine Practical Upshot: Turing machines are powerful! Turing Machine

  15. 15 VIBE CHECK DECIDABILITY Does everyone remember why we are doing this? We want to determine the power of our analysis target We want to determine the power of our analysis engine Good news! Both are bounded by Turing computability Next up: abstracting analysis itself

  16. 16 DECISION PROCEDURES DECIDABILITY A little vocabulary: A decision problem is a computational question that can be solved with either a yes or a no. Frequently, we consider decision problems as detection of a property in a program A decision procedure is a method for solving a decision problem that always yields the correct answer If there is no decision procedure for a given decision problem, that decision problem is called undecidable

  17. 17 PROGRAM ANALYSIS AS DECISION PROCEDURE DECIDABILITY Since a program is just a list of instructions, it is valid input to a decision procedure Analysis Target (arbitrary program) Analysis Engine (property detector program) Yes No (property present) (property is not present)

  18. 18 STRONG GUARANTEES DECIDABILITY A decision procedure is a high bar Analysis Target (arbitrary program) Guarantee that: The analysis engine accepts every program The analysis engine always returns an answer The answer returned is always correct Analysis Engine (property detector program) Rice s Theorem Yes No (property present) (property is not present)

  19. TODAYS ROADMAP Decidability The Halting Problem Type I/Type II Errors Soundness / Completeness

  20. 20 STATING THE PROBLEM THE HALTING PROBLEM Given a description of a Turing machine and its initial input, determine whether the program, when executed on this input, ever halts (completes). The alternative is that it runs forever without halting

  21. 21 A HALTING DETECTOR THE HALTING PROBLEM Analysis Target + Input (arbitrary program) Given a description of a Turing machine and its initial input, determine whether the program, when executed on this input, ever halts (completes). The alternative is that it runs forever without halting Halting Detector Is there a decision procedure for the halting problem? - We ll sketch the proof outline that there is NOT - Relies on a proof by contradiction Yes No (target halts) (target spins)

  22. 22 PROOF BY CONTRADICTION THE HALTING PROBLEM Reductio ad absurdum Assuming the premise has obviously incorrect consequences Here: assume there is a halting detector Assumption Black_magic Black_magic Halting Detector black_magic(){ if (halts(black_magic){ while(true){} //Spin } //Halt } Halting Detector Yes No (target halts) (target spins) black_magic halts Black_magic spins spin halt halts(ANY ARBITRARY PROGRAM)

  23. 23 WHO CARES? THE HALTING PROBLEM No halting decision procedure means no reachability decision procedure 1. int main(){ 2. if (my_function()){ 3. int * a = nullptr; 4. *a = 1; 5. } 6. } This program crashes if and only if it reaches line 4, which depends on the result of a function call being true black_magic()

  24. 24 RICE S THEOREM THE HALTING PROBLEM No halting decision procedure means no reachability decision procedure Exhibits the behavior you care about 1. int main(){ 2. if (my_function()){ 3. int * a = nullptr; 4. *a = 1; 5. } 6. } This program crashes if and only if it reaches line 4, which depends on the result of a function call being true black_magic() behavior you care about

  25. 25 RICE S THEOREM THE HALTING PROBLEM All non-trivial semantic properties of programs are undecidable

  26. 26 LIMITATIONS OF RICE S THEOREM THE HALTING PROBLEM Rice s Theorem is less catastrophic than you might expect for security: A decision procedure is a pretty high bar A Turing machine is actually not a perfect approximation of the computers we use! Despite these limitations, it is widely accepted that program analysis is always approximate We can t be right all of the time We can choose what types of errors we make

  27. TODAYS ROADMAP Decidability The Halting Problem Categorizing Program Analyses Soundness / Completeness

  28. 28 TYPES OF ANALYSIS CATEGORIZING PROGRAM ANALYSES In order to determine the properties of a given program analysis, let s frame it as a detector Analysis Target (arbitrary program) Note: we can detect bad behavior or good behavior Analysis Engine (property detector program) Yes No (property present) (property is not present)

  29. 29 CLASSIFYING ERRORS CATEGORIZING PROGRAM ANALYSES False Analysis is wrong True Analysis is correct Analysis Target (arbitrary program) Has report Has report Has bug No bug Positive report bug Type I Error Correct Analysis Engine (bug detector) No report No bug No report Has bug Negative No bug report Type II Error No Correct Yes (property is not present) (buggy)

  30. TODAYS ROADMAP Decidability The Halting Problem Categorizing Program Analyses Soundness / Completeness

  31. 31 GUARANTEES OF IMPERFECT ANALYSES SOUNDNESS / COMPLETENESS Consistency / Reliability super important for users We d like to limit the kinds of errors we report We can choose which type of bug report error to avoid Soundness: No false positives Completeness: No false negatives

  32. 32 VISUAL ANALOGY SOUNDNESS / COMPLETENESS Reported bugs Imagine the universe of all programs is contained in a circle You can draw a circle around the programs you report as buggy The actual buggy programs occupy a jagged region All Programs Buggy programs

  33. 33 VISUAL ANALOGY SOUNDNESS / COMPLETENESS Reported bugs Reported bugs All Programs All Programs False Positive Buggy programs Buggy programs False Negative Sound bug detection All correct programs pass through (No false positive problem) Complete bug detection All buggy programs get flagged (No false negative problem) Some buggy programs pass through (has false negative problem) Some correct programs get flagged (has false positive problem)

  34. 34 TRIVIAL SOUNDNESS CATEGORIZING PROGRAM ANALYSES Reported bugs All Programs Analysis Target (arbitrary program) Buggy programs Analysis Engine (bug detector) False Negative No (property is not present) Sound bug detection All correct programs pass through (No false positive problem) Some buggy programs pass through (has false negative problem)

  35. 35 TRIVIAL COMPLETENESS CATEGORIZING PROGRAM ANALYSES Reported bugs All Programs Analysis Target (arbitrary program) False Positive Buggy programs Analysis Engine (bug detector) Yes (buggy) Complete bug detection All buggy programs get flagged (No false negative problem) Some correct programs get flagged (has false positive problem)

  36. 36 BEYOND ALL-OR-NOTHING SOUNDNESS / COMPLETENESS As you can imagine, soundness and completeness are not the full story Guarantees are nice, but we want legitimately useful analyses! Many practical analyses are neither sound nor complete

  37. 37 STATIC VS DYNAMIC ANALYSIS SOUNDNESS / COMPLETENESS One distinction in analysis is how the analysis treats the target Static analysis Operates without running the program Dynamic analysis - Operates with running the program

  38. 38 ANALYSIS METHOD VS ERRORS SOUNDNESS / COMPLETENESS It s natural to consider the types of compromises of each analysis method Static analysis Often builds a model of the program, makes inferences on that model Tends to make completeness easier Scalability concerns for large programs Dynamic analysis Often performs the analysis by straight up running the program, observing behavior Tends to make soundness easier Coverage problems

  39. 39 ABOUT COVERAGE SOUNDNESS / COMPLETENESS int f(bool b) { Obj * o = null; int v = 2; if (b) { o = new Obj (); v = rand_int(); } if (v == 2){ o->setInvalid() } return o->property(); } Line coverage Branch coverage Path coverage

  40. LECTURE END Summary: - Decidability - Computational Theory - Categorizing analysis

  41. 41

  42. 42

  43. 43

Related


More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#