Difference between revisions of "Chaitin's construction"

From HaskellWiki
Jump to navigation Jump to search
m (→‎Table for simpler CL-terms: The table is easier to understand with this order of columns)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
  +
:'''''Correction in process. There is a substantial point that is lacking yet, the formulae and the concepts are not correct without it.'''''
  +
 
__TOC__
 
__TOC__
   
Line 7: Line 9:
   
 
See Wikipedia article on [http://en.wikipedia.org/wiki/Chaitin%27s_constant Chaitin's construction], referring to e.g.
 
See Wikipedia article on [http://en.wikipedia.org/wiki/Chaitin%27s_constant Chaitin's construction], referring to e.g.
* [http://www.expmath.org/expmath/volumes/11/11.3/Calude361_370.pdf Computing a Glimpse of Randomness] (written by Cristian S. Calude, Michael J. Dinneen, and Chi-Kou Shu)
 
 
* [http://www.plus.maths.org.uk/issue37/features/omega/index.html Omega and why math has no TOEs] (Gregory Chaitin).
 
* [http://www.plus.maths.org.uk/issue37/features/omega/index.html Omega and why math has no TOEs] (Gregory Chaitin).
  +
  +
== PROBLEM with the approach below ==
  +
  +
The approach below fails to take into account that a halting probability is only (provably) random if the programming language used is additively optimal. That is, it must provide access to raw binary data without overhead. Thus, a binary code for Combinatory Logic or Lambda Calculus does not suffice. It's also necessary to apply the encoded term on the binary data that follows the encoded term, as is done for example in Section 4.1 of [https://tromp.github.io/cl/LC.pdf Tromp's paper].
   
 
== Basing it on combinatory logic ==
 
== Basing it on combinatory logic ==
Line 16: Line 21:
 
=== Coding ===
 
=== Coding ===
   
See the prefix coding system described in [http://homepages.cwi.nl/~tromp/cl/cl.html Binary Lambda Calculus and Combinatory Logic] (page 20) written by John Tromp:
+
See the prefix coding system described in [http://tromp.github.io/cl/cl.html Binary Lambda Calculus and Combinatory Logic] (page 20) written by John Tromp:
 
:<math>\widehat{\mathbf S} \equiv 00</math>
 
:<math>\widehat{\mathbf S} \equiv 00</math>
 
:<math>\widehat{\mathbf K} \equiv 01</math>
 
:<math>\widehat{\mathbf K} \equiv 01</math>
Line 49: Line 54:
 
! Decodable strings, ratio, their sum till now
 
! Decodable strings, ratio, their sum till now
 
! Terminating, ratio, their sum till now
 
! Terminating, ratio, their sum till now
  +
! <math>\Omega</math> approximated till now: mantissa -- binary, length-fitting binary, decimal
 
|-
 
|-
 
| 0
 
| 0
Line 54: Line 60:
 
| 0, 0, 0
 
| 0, 0, 0
 
| 0, 0, 0
 
| 0, 0, 0
  +
| -, -, -
 
|-
 
|-
 
| 1
 
| 1
Line 59: Line 66:
 
| 0, 0, 0
 
| 0, 0, 0
 
| 0, 0, 0
 
| 0, 0, 0
  +
| -, 0, 0
 
|-
 
|-
 
| 2
 
| 2
Line 64: Line 72:
 
| 2, <math>\frac12</math>, <math>\frac12</math>
 
| 2, <math>\frac12</math>, <math>\frac12</math>
 
| 2, <math>\frac12</math>, <math>\frac12</math>
 
| 2, <math>\frac12</math>, <math>\frac12</math>
  +
| 1, 10, 5
 
|-
 
|-
 
| 3
 
| 3
Line 69: Line 78:
 
| 0, 0, <math>\frac12</math>
 
| 0, 0, <math>\frac12</math>
 
| 0, 0, <math>\frac12</math>
 
| 0, 0, <math>\frac12</math>
  +
| 1, 100, 5
 
|-
 
|-
 
| 4
 
| 4
Line 74: Line 84:
 
| 0, 0, <math>\frac12</math>
 
| 0, 0, <math>\frac12</math>
 
| 0, 0, <math>\frac12</math>
 
| 0, 0, <math>\frac12</math>
  +
| 1, 1000, 5
 
|-
 
|-
 
| 5
 
| 5
Line 79: Line 90:
 
| 4, <math>\frac18</math>, <math>\frac58</math>
 
| 4, <math>\frac18</math>, <math>\frac58</math>
 
| 4, <math>\frac18</math>, <math>\frac58</math>
 
| 4, <math>\frac18</math>, <math>\frac58</math>
  +
| 101, 10100, 625
 
|}
 
|}
  +
It illustrates nicely, that Chaitin's construction is a [http://en.wikipedia.org/wiki/Normal_number normal number], as if its digits (in binary representation) were generated by tossing a coin.
   
 
== Eliminating any concept of code by handling [[combinatory logic]] terms directly ==
 
== Eliminating any concept of code by handling [[combinatory logic]] terms directly ==
   
  +
Chaitin's construction can be grasped also as
We can avoid referring to any code notion, if we transfer (lift) the notion of “length” from bit sequences to [[combinatory logic]] terms in an appropriate way. Let us call it the “norm” of the term:
 
 
:<math>\sum_{p\in \mathrm{CL},\;\mathrm{hnf}\;p} 2^{-\left|\mathrm{dc}^{-1}\;p\right|}</math>
   
  +
We can avoid referring to any code notion, if we modularize out function
:<math>\sum_{p\in\mathrm{CL},\;\mathrm{hnf}\;p} 2^{-\left\Vert p\right\Vert}</math>
 
  +
:<math>\left|\cdot\right|\circ\mathrm{dc}^{-1}</math>
where
 
  +
and give it a separate name, e.g.
 
:<math>\left\Vert\cdot\right\Vert : \mathrm{CL}\to\mathbb N</math>
 
:<math>\left\Vert\cdot\right\Vert : \mathrm{CL}\to\mathbb N</math>
  +
and notice that it can be defined directly in terms of CL-terms (we need not use any decoding concept any longer):
  +
 
:<math>\left\Vert\mathbf K\right\Vert = 2</math>
 
:<math>\left\Vert\mathbf K\right\Vert = 2</math>
 
:<math>\left\Vert\mathbf S\right\Vert = 2</math>
 
:<math>\left\Vert\mathbf S\right\Vert = 2</math>
 
:<math>\left\Vert\left(x\;y\right)\right\Vert = 1 + \left\Vert x\right\Vert + \left\Vert y\right\Vert</math>
 
:<math>\left\Vert\left(x\;y\right)\right\Vert = 1 + \left\Vert x\right\Vert + \left\Vert y\right\Vert</math>
  +
 
Thus, we transfer (lift) the notion of “length” from bit sequences to [[combinatory logic]] terms in an appropriate way. Let us call it, e.g. the “norm” of the term.
  +
  +
Thus, Chaitin's construction is grasped also as
  +
:<math>\sum_{p \in \mathrm{Dom}_{\mathrm{nf}}} 2^{-\left\Vert p\right\Vert}</math>
 
where
  +
:<math>\mathrm{nf} : \mathrm{CL} \supset\!\to \mathrm{CL}</math>
  +
is a partial function defined on CL terms, it attributes to each "terminating" term its normal form.
   
 
Thus, we have no notions of “bit sequence”,“code”, “coding”, “decoding” at all. But their ghosts still haunt us: the definition of norm function looks rather strange without thinking on the fact that is was transferred from a concept of coding.
 
Thus, we have no notions of “bit sequence”,“code”, “coding”, “decoding” at all. But their ghosts still haunt us: the definition of norm function looks rather strange without thinking on the fact that is was transferred from a concept of coding.
Line 105: Line 130:
 
And is it worth doing it at all? The former one, at leat, had a good theoretical foundation (based on analysis, arithmetic and probability theory). This latter one is not so cleaner, that we should prefer it, so, lacking theoretical grounds.
 
And is it worth doing it at all? The former one, at leat, had a good theoretical foundation (based on analysis, arithmetic and probability theory). This latter one is not so cleaner, that we should prefer it, so, lacking theoretical grounds.
   
What I really want is to exclude the (IMHO) underestimation of this “probability of termination” number -- an underestimation coming from taking into account the syntactically non-correct codes (IMHO). Thus taking only termination vs nontermination into account, when calculating this number (which can be interpreted as a probability).
+
What I really want is to exclude conceptually the notion of coding, and with it the notion of “syntactically incorrect versus syntactically correct but diverging”. Thus, taking into account only syntactically correct things, seeing only the choice of terminating versus non-terminating. Thus taking only termination vs nontermination into account, when calculating Chaitin's construction.
  +
  +
What I want to preserve:
  +
* it can be interpreted as a probability
  +
* it is a [http://en.wikipedia.org/wiki/Normal_number normal number], as if its digits (in binary representation) were generated by tossing a coin
  +
thus I do not want to spoil these features.
   
 
==== Table for simpler CL-terms ====
 
==== Table for simpler CL-terms ====
Line 164: Line 194:
 
=== Architecture ===
 
=== Architecture ===
   
A CL term generator generates CL terms in “ascending order” (in terms of a theoretically appropriate “norm”), and by computing the norm of each CL-term, it approximates Chaitin's construct (at a given number of digits, and according to the given maximal limit of reduction steps).
+
A CL term generator generates CL terms in “ascending order” (in terms of a theoretically appropriate “norm”), and by computing the norm of each CL-term, it approximates Chaitin's construction (at a given number of digits, and according to the given maximal limit of reduction steps).
   
 
=== User interface ===
 
=== User interface ===
Line 223: Line 253:
 
* Making tasks described in [[#Implementation]]
 
* Making tasks described in [[#Implementation]]
 
* Making more natural norm functions (from CL-terms), see [[#More natural norm functions (from CL terms)]]
 
* Making more natural norm functions (from CL-terms), see [[#More natural norm functions (from CL terms)]]
  +
  +
[[Category:Pages under construction]]

Latest revision as of 09:31, 24 April 2024

Correction in process. There is a substantial point that is lacking yet, the formulae and the concepts are not correct without it.

Introduction

Are there any real numbers which are defined exactly, but cannot be computed? This question leads us to exact real arithmetic, and algorithmic information theory, and foundations of mathematics and computer science.

See Wikipedia article on Chaitin's construction, referring to e.g.

PROBLEM with the approach below

The approach below fails to take into account that a halting probability is only (provably) random if the programming language used is additively optimal. That is, it must provide access to raw binary data without overhead. Thus, a binary code for Combinatory Logic or Lambda Calculus does not suffice. It's also necessary to apply the encoded term on the binary data that follows the encoded term, as is done for example in Section 4.1 of Tromp's paper.

Basing it on combinatory logic

Some more direct relatedness to functional programming: we can base on combinatory logic (instead of a Turing machine).

Coding

See the prefix coding system described in Binary Lambda Calculus and Combinatory Logic (page 20) written by John Tromp:

of course, , are meta-variables, and also some other notations are changed slightly.

Decoding

Having seen this, decoding is rather straightforward. Here is a parser for illustration, but it serves only didactical purposes: it will not be used in the final implementation, because a good term generator makes parsing superfluous at this task.

Chaitin's construction

Now, Chaitin's construction will be here

where

should denote an unary predicate “has normal form” (“terminates”)
should mean an operator “decode” (a function from finite bit sequences to combinatory logic terms)
should denote the set of all finite bit sequences
should denote the set of syntactically correct bit sequences (semantically, they may either terminate or diverge), i.e. the domain of the decoding function, i.e. the range of the coding function. Thus,
“Absolute value”
should mean the length of a bit sequence (not combinatory logic term evaluation!)

Table for small legths

Length () All strings () Decodable strings, ratio, their sum till now Terminating, ratio, their sum till now approximated till now: mantissa -- binary, length-fitting binary, decimal
0 1 0, 0, 0 0, 0, 0 -, -, -
1 2 0, 0, 0 0, 0, 0 -, 0, 0
2 4 2, , 2, , 1, 10, 5
3 8 0, 0, 0, 0, 1, 100, 5
4 16 0, 0, 0, 0, 1, 1000, 5
5 32 4, , 4, , 101, 10100, 625

It illustrates nicely, that Chaitin's construction is a normal number, as if its digits (in binary representation) were generated by tossing a coin.

Eliminating any concept of code by handling combinatory logic terms directly

Chaitin's construction can be grasped also as

We can avoid referring to any code notion, if we modularize out function

and give it a separate name, e.g.

and notice that it can be defined directly in terms of CL-terms (we need not use any decoding concept any longer):

Thus, we transfer (lift) the notion of “length” from bit sequences to combinatory logic terms in an appropriate way. Let us call it, e.g. the “norm” of the term.

Thus, Chaitin's construction is grasped also as

where

is a partial function defined on CL terms, it attributes to each "terminating" term its normal form.

Thus, we have no notions of “bit sequence”,“code”, “coding”, “decoding” at all. But their ghosts still haunt us: the definition of norm function looks rather strange without thinking on the fact that is was transferred from a concept of coding.

More natural norm functions (from CL terms)

Question: If we already move away from the approaches referring to any code concept, then could we define norm in other ways? E.g.

And is it worth doing it at all? The former one, at leat, had a good theoretical foundation (based on analysis, arithmetic and probability theory). This latter one is not so cleaner, that we should prefer it, so, lacking theoretical grounds.

What I really want is to exclude conceptually the notion of coding, and with it the notion of “syntactically incorrect versus syntactically correct but diverging”. Thus, taking into account only syntactically correct things, seeing only the choice of terminating versus non-terminating. Thus taking only termination vs nontermination into account, when calculating Chaitin's construction.

What I want to preserve:

  • it can be interpreted as a probability
  • it is a normal number, as if its digits (in binary representation) were generated by tossing a coin

thus I do not want to spoil these features.

Table for simpler CL-terms

Let us not take into account coding and thus excluding the notion of “syntactically incorrect coding” even conceptually. Can we guess a good norm?

Binary tree pattern Maximal depth, vertices, edges Leafs, branches So many CL-terms = how to count it Terminating, ratio So many till now, ratio till now
0, 1, 0 1, 0 2, 1 2, 1
1, 3, 2 2, 1 4, 1 6, 1
2, 5, 4 3, 2 8, 1 14, 1
2, 5, 4 3, 2 8, 1 22, 1
2, 7, 6 4, 3 16, 1 38, 1

Implementation

To do: Writing a program in Haskell -- or in combinatory logic:-) -- which could help in making conjectures on combinatory logic-based Chaitin's constructions. It would make only approximations, in a similar way that most Mandelbrot plotting softwares work. The analogy:

  • they ask for a maximum limit of iterations, so that they can make a conjecture on convergence of a series;
  • this program will ask for the maximum limit of reducton steps, so that it can make a conjecture on termination (having-normal-form) of a CL term.

Explanation for this: non-termination of each actually examined CL-term cannot be proven by the program, but a good conjecture can be made: if termination does not take place in the given limit of reduction steps, then the actually examined CL-term is regarded as non-terminating.

Architecture

A CL term generator generates CL terms in “ascending order” (in terms of a theoretically appropriate “norm”), and by computing the norm of each CL-term, it approximates Chaitin's construction (at a given number of digits, and according to the given maximal limit of reduction steps).

User interface

chaitin --model-of-computation=cl --encoding=tromp --limit-of-reduction-steps=500 --digits=9 --decimal
chaitin --model-of-computation=cl --encoding=direct --limit-of-reduction-steps=500 --digits=9 --decimal

Term generator

 module CLGen where

 import Generator (gen0)
 import CL (k, s, apply)

 direct :: [CL]
 direct = gen0 apply [s, k]

See combinatory logic term modules here.

 module Generator (gen0) where

 import PreludeExt (cross)

 gen0 :: (a -> a -> a) -> [a] -> [a]
 gen0 f c = gen f c 0

 gen :: (a -> a -> a) -> [a] -> Integer -> [a]
 gen f c n = sizedGen f c n ++ gen f c (succ n)

 sizedGen :: (a -> a -> a) -> [a] -> Integer -> [a]
 sizedGen f c 0 = c
 sizedGen f c (n + 1) = map (uncurry f)
                      $
                      concat [sizedGen f c i `cross` sizedGen f c (n - i) | i <- [0..n]]
 module PreludeExt (cross) where

 cross :: [a] -> [a] -> [(a, a)]
 cross xs ys = [(x, y) | x <- xs, y <- ys]

Related concepts

To do