Decidability
Christian Gram Kalhauge
Is program analysis easy?
In what circumstances would you want a May vs a Must analysis?
What does it mean that an analysis is sound?
It all started with math.
A program is structured object , from a language , with a step function from state to state:
Using automatic techniques to figure out facts about a computer program.
What is a turing complete language?
A language in which you can compute anything a (Turing) machine can compute.
Almost all real
programming languages are Turing complete
It can...
fire the missiles,
not fire the missiles,
never terminate,
kill grandma, and worst of all
throw a null pointer exception!
Given any program from the language , decide if it is going to terminate (halt) when executed on a state .
Do these programs halt?
def forever():
while True:
print("Running!")def never():
while False:
print("Running!")A harder one
def does_halt(p : Program) -> bool:
...def main():
while does_halt(main):
print("Running")Wait! That's illegal!
def main():
something_that_might_go_forever()
fire_the_nukes()Rice's Theorem
This means... that there is no best solution.
Welcome to Art School.
In a sound system, we can only prove true things. Or if we can prove given () then is true given ().
In a complete system, we can prove all true things. Or if is true given () then is provable given ().
An individual proposition is either a true positive, true negative, false positive, or false negative, following the table below:
| TP | FP | |
| FN | TN |
Program based questions, soundness and completeness
Trace based questions, soundness and completeness
In case of confusion, use may and must instead.
[...], virtually all published wholeprogram analyses are unsound and omit conservative handling of common language features when applied to real programming languages.
— In Defense of Soundiness: A Manifesto
Write an analysis that given the name of a JVM method, predict the possible behaviors.
Evaluate it on the JPAMB suite.
Upload your results to ???.
$> ./your-analysis "info"
<please-dump-info>
$> ./your-analysis "jpamb.cases.Simple.assertPositive:(I)V"
assertion error;<probability of error>import jpamb
methodid = jpamb.getmethodid("test", "0.0",
"The Rice Theorem Cookers", [],
for_science=True)
print("assertion error;80%")
print("ok;5")
print("*;-10")
print("divide by zero;10%")
print("out of bounds;0%")Test it like so:
$> uvx jpamb test python ./guess.py
... test output ...And evaluate it like so:
$> uvx jpamb evaluate python ./guess.py > result.jsonWhich you should upload to ??
Also research is done on this!
But, you can opt out if you like
Is program analysis easy?
In what circumstances would you want a May vs a Must analysis?
What does it mean that an analysis is sound?