Can You Compute This?

A computable number is one which, given enough time, can be calculated to whatever degree of precision is desired. For example, the irrational number which has a 1 in every prime slot 0.01101010001010001 0.01101010001010001 \ldots is computable. To calculate it to an accuracy of 1 0 n 10^{-n} , we just need to determine which of the first n n positive integers are prime.

Are there countably many or uncountably many computable numbers?

Countably many Uncountably many

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

4 solutions

Arjen Vreugdenhil
Dec 17, 2017

A computable number is defined by a computation of algorithm, which consists of a finite number of instructions to be performed. No matter what the details of the programming language are, each algorithm A A can eventually be reduced to a finite number of bits A = [ b n 1 b n 2 b 2 b 1 b 0 ] A = [b_{n-1}b_{n-2}\cdots b_2b_1b_0] .

Define N ( A ) = 2 n + b N(A) = 2^n + b , where b = b n 1 b n 2 b 2 b 1 b 0 b = \overline{b_{n-1}b_{n-2}\cdots b_2b_1b_0} interpreted as a binary numeral. Let A \mathbb A be the set of algorithms; then N : A N N:\ \mathbb A \to \mathbb N is an injection, proving that A N = 0 |A| \leq |N| = \aleph_0 is countable.


Concrete example

Suppose we write the algorithm in a language with symbols

1
2
3
4
5
6
7
000:       0
001:       i  (index of digit)
010 x:     x + 1
011 x y:   x := x % y   
100 x y z: if x == 0 then y else z
110:       write 0
111:       write 1

Then the following algorithm produces the number 0.001001001001001001 = 1 / 999 0.001001001001001001\dots = 1/999 :

1
2
i := i % (0 + 1 + 1 + 1)
if i == 0 then write 1 else write 0

Its bitcode is A = [ 011 001 010 010 010 000 100 001 111 110 ] A = [011\ 001\ 010\ 010\ 010\ 000\ 100\ 001\ 111\ 110] ; thus we map this algorithm to the integer

N ( A ) = 1011001 01001001 00001000 01111110 2 = 1 497 958 526. N(A) = \overline{\mathbf 1 011 001\ 010 010 01\ 0 000 100 0\ 01 111 110}_2 = 1\,497\,958\,526.

Note that most integers will not correspond to a meaningful algorithm, and that the same number may be represented by multiple algorithms. Therefore N : A N N:\ \mathbb A \to \mathbb N is not a bijection, but only an injection.

I probably misunderstood the definition of computable number. How does the set of computable numbers differ from the set of real numbers?

Patrick Bourg - 3 years, 5 months ago

Log in to reply

The definition of a computable number entails that for each of the countable (binary) digit, there is a finite process to decide whether it is a zero or a one.

It turns out (as I proved above) that the number of computable numbers is not greater than the number of finite "programs" one can write, which in turn is no greater than the set of natural numbers. (This kind of infinity is "countable".)

On the other hand, it can be proven that the number of real numbers (even just those between 0 and 1) is uncountable , essentially larger than the set of natural numbers.

Therefore, there are (uncountably many) more real numbers than computable numbers. These real numbers exist, but there is no way to describe them or calculate them with infinite precision.

I would argue that the set of computable numbers is greater than the set of algebraic numbers over the rationals Z \mathbb Z . (An algebraic number is a solution of a polynomial equation.) After all, an algebraic number can be obtained by solving a polynomial equation using successive approximations. Also, all sines, cosines, tangents, etc., inverse sines, etc., logarithms are in principle computable with a finite algorithm; this includes irrational, non-algebraic numbers such as π \pi , e e , and ln 2 \ln 2 . Yet all these numbers form a countable set, therefore much smaller than the set of all reals.

Arjen Vreugdenhil - 3 years, 5 months ago

Log in to reply

Any taylor series expansion evaluated at an integer / rational value will give us a computable number, since we have limits on the remainder term.

As an example, a "well-known" way to quickly compute π \pi is to use π 4 = 4 arctan 1 5 arctan 1 239 \frac{\pi}{4} = 4 \arctan\frac{1}{5} - \arctan\frac{1}{239} and then apply Taylor series on arctan θ \arctan \theta .

Calvin Lin Staff - 3 years, 5 months ago

Any limit of a series that is defined according to a finite pattern is computable. Non-computable real numbers are those "without rhyme or reason" in any their pattern of digit or in their Taylor series coefficients. Describing such digits or coefficients would require an infinitely long recipe.

If we allow for (countably) infinitely long lists of coefficients as part of an algorithm, then obviously we can generate all the real numbers. But then the number of algorithms is of the order 2 N = R |2^{\mathbb N}| = |\mathbb R| , that is, uncountable.

Arjen Vreugdenhil - 3 years, 5 months ago

Do we have an example of a number that is not computable?

X Y - 3 years, 5 months ago

Log in to reply

Here is a recipe to find such a number.

Let U = [ 0 , 1 ] U = [0,1] be the uncountable set of all reals between 0 and 1.

Let A \mathbb A be the countable set of all finite algorithms as described in this problem. For an algorithm A A , let c ( A ) c(A) be the number it describes.

Let X = U c [ A ] X = U - c[\mathbb A] be the real numbers between 0 and 1 that are not computable. Since an uncountable is strictly greater than a countable set, X X is not empty.

Invoking the Axiom of Choice, let x X x \in X . Then x x is the desired, non-computable number.

I cannot give you more details. Any constructive algorithm to generate or test x x for a given property in a finite number of calculation steps would make it computable.

(What exactly makes our x x non-computable? Is the set of non-computable numbers paradoxical? Why or why not?)

Arjen Vreugdenhil - 3 years, 5 months ago

Log in to reply

I'm still struggling to grasp the idea, probably because it's a new concept for me. It is a bit like 'trust me there are such numbers, but you can't articulate what they are'. If I randomly generate each of the decimal place of a number, can I tell whether it is a computable number by looking at it?

X Y - 3 years, 5 months ago

Log in to reply

@X Y

Trust me there are such numbers, but you can't articulate what they are

Somewhat. Almost all real numbers that you have encountered (especially before a CS course) are computable.

If you randomly generate each decimal place of a number, with probability 1 (and this is introducing more terminology in measure theory), the number is not computable. This follows because the number of computable numbers is countable.


Another term that falls in this category of "trust me there are such numbers, but it is hard to find them", is a normal number. These are real numbers whose infinite sequence of digits in every positive integer base b b is distributed uniformly in the sense that each of the b b digit values has the same natural density 1 b \frac{1}{b} , also all possible b 2 b^2 pairs of digits are equally likely with density 1 b 2 \frac{1}{b^2} , etc.

Similarly, almost all real numbers are normal, but very few specific numbers are known to be normal. Can you come up with a number that is normal in base 10?

Calvin Lin Staff - 3 years, 5 months ago

I, too, had never heard of computable numbers before this, but I'm curious as to why Cantor's diagonal argument doesn't work here. Very briefly, if c 1 , c 2 , , c n , c_{1},c_{2},\dots,c_{n} ,\dots is an enumeration of the computable numbers in binary, and I constructed a number c c by choosing its n n th digit to be the complement of the n n th digit of c n c_{n} , wouldn't c c still be computable? By the given definition, all I'd have to be able to do is compute c c to an accuracy of 10 n {10}^{-n} for any given n n ; I could do this by finding the first digit of c 1 c_{1} , the second digit of c 2 c_{2} , and so on up to the n n th digit of c n c_{n} , all of which I am able to do by definition. Where does this argument fail?

zico quintina - 3 years, 5 months ago

Log in to reply

Your program would have to generate this enumeration as it is going; we cannot assume that such a list is available beforehand!

1
2
3
4
5
6
7
8
define CantorDigit(n):
   a = 0
   for i = 1 to n-1
      a++ until IsValidAlgorithm(a)

   dig = RunAlgorithm(a, n)   // run program with bitcode 'a' for digit 'n'
   dig = 1 - dig
   return dig

Now suppose that this program has bitcode a a^\star , and is the n n^\star th valid algorithm we encounter. Executing dig = RunAlgorithm(a*, n*) essentially means running CantorDigit(n*) recursively. Thus the program will find itself in an infinite loop! If it could be decided beforehand whether an algorithm would give an answer in a finite number of steps, a a^\star would simply be rejected as not a valid algorithm; but since the "stopping problem" is unsolvable, we must conclude that any attempt to execute your algorithm would result in a hang-up, or infinite loop.

Arjen Vreugdenhil - 3 years, 5 months ago

Log in to reply

I think it would be inappropriate to assume that CantorDigit is an algorithm in the given list. What the diagonalization argument is saying is that if you claim a list of algorithms to be countable, one can come up with another algorithm which does not belong to any of those.

I have a feeling that CantorDigit is not a finite algorithm. Because essentially it has to access a countable set of algorithms (the list of all algorithms) to run. Therefore, its size is not finite.

X Y - 3 years, 5 months ago

Log in to reply

@X Y The number a is not merely an index into a list of all algorithms, but it contains the algorithm itself. CantorDigit has access to these algorithms because it has access to all natural numbers.

Here is a possible implementation of RunAlgorithm(a, n) in pseudocode, in which we assume that the algorithm is coded in a programming language that uses 16-bit instruction codes:

1
2
3
4
5
while a > 1:
   instr = a mod 65536
   a = a / 65536

   // perform instruction 'instr'

This is a perfectly finite code!

Arjen Vreugdenhil - 3 years, 5 months ago

Thanks for replying, Arjen, but I must confess I didn't understand much of what you said as I have virtually no experience with programming. There was no mention of programs or algorithms in the question, and it's categorized as a Discrete Math question, not Computer Science, so I approached it just as a set of numbers and tried to decide whether it was countable or uncountable; the scenario I was trying to describe was not based on any program. Is there a non-algorithmic answer to my question, or does the problem not make sense outside of the world of programming?

zico quintina - 3 years, 5 months ago

Please correct me if I misunderstand this. Surely if any number n is computable, then any number k that can be obtained by performing an operation or set of operations on n must also be computable? This would prove there is an infinite amount of computable numbers by induction, right? Example: take n = 0.10010110111 Perform any operation on n (in this case divide by 2 (10 in binary) for simplicity) k = 0.010010110111 Repeat ad infinitum to generate infinite computable numbers.

Isaac Pace - 3 years, 5 months ago

Log in to reply

Are you aware of the different cardinality ? We can have an infinite list of numbers, but they could still be countably infinite. For example, the integers are a countable set. Using your example of n 2 k \frac{ n}{ 2^k } , this is still a countable set (indexed by k k ).

We need to add "much much more" in order to go from countable to the uncountable.

Calvin Lin Staff - 3 years, 5 months ago

Can you prove that your sample language is Turing complete?

Stewart Gordon - 3 years, 5 months ago

Log in to reply

We could make Turing-completeness the definition of computability--it is the classical and best rigorous way of doing so. I did not want to go into these technical details.

Arjen Vreugdenhil - 3 years, 5 months ago

I have a question why does my "counter-proof" fail. (I will show that it's uncountably infinite.)

Assume that it's countably infinite. Then, there is a representation between them and the natural numbers. (So we can write them in a sequence, and mark which is the first element, the second, etc.)

We use Cantor's diagonal method: take the first number's first digit after the comma, the second number's second digit, etc. (If it's a rational number, just write infinitely many 0s after it). Write these digits down in a sequence, this will be our second sequence (first digit=first element, ...). We'll mark sequence's elements as b 1 , b 2 , . . . b_1,b_2,... . We take the number n=0,... for which: -the k-th digit of n after the comma is 0, if b k = 1 , b_k=1, else let it be 1.

Clearly, n is a computable number. That's because you can just take the first N numbers of our first sequence of computable numbers, they define the first N digits. (This is true no matter if N is a fixed number, or N can be arbitrary large.) Thus, n is in our first sequence, say it's the m-th element. But if the m-th element's m-th digit is 1, we get a contradiction, if not then we also get a contradiction. We are done, n can't be in this sequence, so it doesn't exist, and our statement is false, these numbers are uncountably infinite.

Mihaly Hanics - 3 years, 5 months ago

Log in to reply

Your algorithm will not produce a computable number, but get stuck in an infinite loop or otherwise undefined.

First of all, while the list of all computable numbers "exists" in a mathematical sense, your algorithms do not have access to this list; it cannot be stored as part of the program because it is doubly infinite, and it cannot be generated in its entirety in finite time. This is why the Cantor argument does not apply in the same way.

What you do have is a way to interpret any integer N N as an algorithm (computation), so that in principle you can calculate the n n th digit of the N N th number in finite time.

Now suppose that your clever, Cantor-style algorithm is encoded in integer N N^\star . It applies algorithm 1 to generate digit 1 of the first number; you flip it. It applies algorithm 2 to generate digit 2 of the second number; you flip it. And so on. This may go well, until you get to digit number n = N n^\star = N^\star . In order to find this digit, your algorithm must execute algorithm N N^\star (i.e. itself!) to generate the n n^\star th digit-- precisely the process that you are currently working on. Thus we have a recursive application of the algorithm, which will never finish.

The crux is that an algorithm FindDigit(n) may not only return 1 or 0, but can also remain undecided, for instance because it never stops. It is well-known that one cannot escape the "halting problem" (i.e. any function DoesItStop(N) may get into an infinite loop).

Arjen Vreugdenhil - 3 years, 5 months ago

That's a great question!

You are computing the digits b i b_i from some enumeration a i , n a_{i,n} , where represents the i i th digit of the n n th computable number. However, if there is no way to compute the digits a i , n a_{i,n} , then you cannot computet b b either. The main issue is "there is a representation between them and the natural numbers", where you implicitly assume that this function is computable.

However, there is no computable function f ( i , n ) f(i,n) that satisfies the following conditions:

  • For every i i , the function n f ( i , n ) n \mapsto f(i,n) gives a decimal expansion of a real number - This means that the numbers are real. We could require that the output is an integer from 0 to 9.
  • For any i , n i, n , f ( i , n ) f(i,n) eventually returns some output - This means that the real numbers are computable.
  • For every computable real a a , there is some i i with a n = f ( i , n ) a_n = f (i,n) for all n n - This means that all the computable numbers are in the list.

In fact, the diagonalization argument is how we prove that no such f ( i , n ) f(i,n) exists. Specifically, if such a function exists, we can take the cantor-diagonalization to get another computable real, which contradicts the claim that every computable real is on the list.

Note: In the event that this has/hasn't blown your mind, think about why this counter-counter-argument doesn't apply to show that the real numbers are countable.

Calvin Lin Staff - 3 years, 5 months ago
Peter Macgregor
Dec 20, 2017

There is a 1-1 correspondence between the computable numbers and their (shortest) corresponding programs.

Order these programs alphabetically.

Then there is a first, second, third...... program corresponding to the

first, second, third....... computable number. And so

The computable numbers are countable \boxed{\text{The computable numbers are countable}}

Extra

'Countable' does not mean 'finite'. It means that the set is no larger than the (infinite) set of counting numbers. Here is an interesting article explaining what this means.

My solution is an example of a powerful technique for demonstrating countability. If each element of a set has a finite description (no matter how large), then the set is countable, because you can simply order the descriptions lexicographically and count off the defined elements, first, second, third and so on.

For instance the list for the rationals, using the English alphabet plus 'space' after z, might begin

eight over eight, eight over eighty, ........

As a more sophisticated example we can see that the algebraic numbers are countable, because each one is a solution of a finite polynomial equation, and the equations can be ordered lexicographically!

The algebraic and computable numbers are rare stars shining in the dense continuum of the uncountable reals - and yet we find it extremely hard to exhibit examples of the overwhelmingly more numerous transcendental and non-computable numbers!

For every computable number there exists a Turing machine that computes it.

Since every Turing machine can be encoded as a finite string, the set of all Turing machines has the cardinality of the natural numbers i.e. 0 \aleph_0 and so is the set of all computable numbers.

The actual problem for was that I though n wasn't supposed to be a concrete number. I keep reading too fast... After a second of thought, i find this question quite cheap. "can you count what you can count?"

jacki kay - 3 years, 5 months ago
Nick Vandermeeren
Dec 19, 2017

You have to know when a set is (infinite) countable. Any subset of the natural numbers is countable when it has the same cardinality as a subset from the natural numbers.

When you want to calculate the computable number to a certain accuracy, you just have to know how many prime places are included as decimals. So you only take the prime numbers into account. Since there are uncountable primes, you can always make a new number such as the example states.

In itself the set of all prime numbers is uncountable, but the set of prime numbers are a a subgroup of the natural numbers. So there is at least an injective relation between the set of all primes and the set of all natural numbers. By definition this makes the set of all primes countable. And by this there are countable computable numbers possible to make.

I do not understand what you are trying to say.

Note that there are countably many primes. In particular, as you mentioned, there are countably many natural numbers, and any subset of them is countable.

Calvin Lin Staff - 3 years, 5 months ago

I have a question why does my "counter-proof" fail. (I will show that it's uncountably infinite.)

Assume that it's countably infinite. Then, there is a representation between them and the natural numbers. (So we can write them in a sequence, and mark which is the first element, the second, etc.)

We use Cantor's diagonal method: take the first number's first digit after the comma, the second number's second digit, etc. (If it's a rational number, just write infinitely many 0s after it). Write these digits down in a sequence, this will be our second sequence (first digit=first element, ...). We'll mark sequence's elements as b 1 , b 2 , . . . b_1,b_2,... . We take the number n=0,... for which: -the k-th digit of n after the comma is 0, if b k = 1 , b_k=1, else let it be 1.

Clearly, n is a computable number. That's because you can just take the first N numbers of our first sequence of computable numbers, they define the first N digits. (This is true no matter if N is a fixed number, or N can be arbitrary large.) Thus, n is in our first sequence, say it's the m-th element. But if the m-th element's m-th digit is 1, we get a contradiction, if not then we also get a contradiction. We are done, n can't be in this sequence, so it doesn't exist, and our statement is false, these numbers are uncountably infinite.

Mihaly Hanics - 3 years, 5 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...