Today, we’re going to talk about questions of computability: what can be efficiently computed by an algorithm? Our spec is a problem and some “yes” or “no” output.
Problem: inputs
Output: yes or no
A problem is decidable if there exists an algorithm to solve it that is sound, complete, and terminating. Soundness means that the algorithm never returns “yes” when it shouldn’t, and completeness means it always returns “yes” when it should.
Can we always produce a program that satisfies this spec and runs in efficient time? Not necessarily; consider the Halting Problem. This asks whether a program P halts on a given set of inputs. We can construct a program that runs P and returns “yes” if P halts and “no” otherwise. But if P doesn’t halt, neither does our program!
The term for this is semi-decidable. We can guarantee a correct “yes” instance when P does halt, but we cannot guarantee a correct “no” instance. Thus the Halting Problem is still not decidable.
What if we can correctly output “no” but not necessarily “yes”? The term for this is co-semi-decidable.
Input: A polynomial of one variable with integer coefficients
Ouptut: Does the input have an integer root?
For example, an input might be the polynomial 5a^2 - 9a + 5, and we’re interested in what happens when 5a^2 - 9a + 5 = 0.
To look for integer roots, we can try to produce a finite set of integers to search exhaustibly. Can we guarantee that we can always produce such a set? As long as we have integer coefficients, the Rational Root Theorem tells us that any roots must divide the constant term of the polynomial (in this case, 5). This gives us a finite set of roots to search. Once we’re done searching, we can output a result in finite time that’s sound and complete. This problem is decidable!
What if we try multiple variables? This is Hilbert’s Tenth Problem:
Input: A polynomial of any number of variables with integer coefficients
Output: Does the input have an integer root?
It turns out that this problem is undecidable. There is no algorithm that soundly, completely, and in finite time can tell you whether a multivariate polynomial has an integer root. But is it semi-decidable? We would need to try each possible assignment of variables in finite time. There’s an infinite set of possibilities (the integers), but we can arrange things to guarantee that we’ll visit each possibility in a finite number of iterations. To do so, we need an “increment” operation that zigzags through positive and negative integers. As long as there is a satisfying assignment, we’ll find it in finite time.
This means that the problem is semi-decidable. Can it be co-semi-decidable? Well, we know that it’s undecidable. In general, if a problem is both semi-decidable and co-semi-decidable, then it’s also decidable. We can build a program that runs the “yes” and “no” programs, and returns the results of whichever one halts. So if we know a problem is both undecidable and semi-decidable, then it is NOT co-semi-decidable.
What about ordinary Boolean satisfiability? Is it decidable? You wrote this in the SAT lab, and your programs always terminated with a correct result. So, yes, it is decidable.
How about Alloy? No, it’s not decidable. By placing bounds on the instances it searches, Alloy guarantees finite time but gives up soundness.
More generally, is the problem "I satisfies F" decidable? Let I be an instance and F be a formula. If the instances are finite, this is decidable because we can simply search all possible instances. If the instances are infinite, we might run into problems. An example of an infinite instance is the integers under addition and multiplication, (Z, +, *, <, 0, 1).
Consider Goldbach’s Conjecture (1742): Every even integer greater than 2 can be expressed as the sum of two prime numbers, not necessarily distinct. Semi-formally, we might write this as:
For all x > 2, 2|x implies
there exist some prime a, b such that x = a + b.
Does the set of integers (Z, +, *, <, 0, 1) satisfy Goldbach’s Conjecture? We haven’t yet proven this either way, although people and computers have tested it up to large values of x. If we could come up with a finite set of axioms to describe the integers, then we could write something of the form “Axioms F1, …, Fn satisfy Goldbach’s Conjecture,” which would be semi-decidable.
Ideally, we want something of the form "Z satisfies F if and only if T proves F." Does this submit to mechanical proof? The answer is no. Godel’s Incompleteness Theorem (1931) tells us that any candidtate T must fail for one of the following three reasons:
Even though proof is semi-decidable, we can’t use this to create proofs. This Incompleteness Theorem tells us that there’s no set of axioms that is sound, complete, and terminating for the integers (or for the natural numbers). This is why we can’t necessarily use these techniques in Number Theory, for instance, where instances are often infinite.
What if we limit ourselves to (N, +, 0, 1)? That is, we consider the set of natural numbers but give up multiplication. It turns out that this is decidable! The algorithm's runtime is doubly exponential, but it does terminate. It might seem like we could extend this to include multiplication by defining it as repeated addition, but this doesn't work because of Presburger arithmetic.
Another surprising instance is the set of real numbers, (R, +, *, 0, 1, <).This turns out to be decidable! Again, the runtime is doubly exponential, so an algorithm would terminate but not necessarily any time soon.
What's the takeaway? Proof and finding instances can be subtle, but there are often special cases. If we use finite instances or make other changes, we might come across instances that find ways around undecidability or problems like NP-completeness. We can also give up soundness and completeness to make good approximations. This is to say that even though we might run into problems like undecidability and incompleteness, it can't stop us from finding interesting workarounds and solutions.