# Conference: Week 0

### Welcome!

• Intros.
• Goals for the Class.
• Slack, Zoom, website, etc.
• TAs
• Ground rules for conferences
• Questions?

### Computability

The most important item from lecture:

### Thought Question

Suppose you are given the code for a function $${\tt Crashes}$$:

boolean Crashes(String program, String n) { ... }

This function can determine whether a program $$P$$ crashes with an error on input $$n$$.
Specifically, a call Crashes(P,n) returns:

• true if program $$P$$ halts with an error on input $$n$$.
• false if program $$P$$ does not halt with an error on input $$n$$.

You can assume $$P$$ looks like a function body in Java or a sequence of statements in Python, and that the only errors that can occur are division by 0. For example, if $$P$$ is:

if (n > 0) {
n = n - 1;
} else {
print 10 / n;
}

Then Crashes(P, "10") returns false, but Crashes(P, "0") returns true.

Write a Java function Halt that reads a program text $$P$$ as input, reads a String $$n$$ as input, and then decides whether $$P$$ halts on input $$n$$. Such a Halt program would have the following form, and it would

• print “yes” if $$P$$ halts when it runs with input $$n$$; and
• print “no” if $$P$$ does not halt when runs with input $$n$$.
void Halt() {
...
}

To do this, just describe what replaces  $$\ldots$$  in the Halt program definition above.

Solution
void Halt() {
String P';
P' = P with "print 10/0;" inserted right before each
"return" statement;
return Crashes(P', n);
}