Fractran: Difference between revisions

From BusyBeaverWiki
Jump to navigation Jump to search
Champions: Add vector rep for champions
Fix matrix notation (get rid of extra empty row).
Line 23: Line 23:
   2 &  0 & -1 \\
   2 &  0 & -1 \\
   -1 &  1 &  0 \\
   -1 &  1 &  0 \\
   0 & -1 &  2 \\
   0 & -1 &  2
\end{bmatrix}</math>
\end{bmatrix}</math>


Line 41: Line 41:
| 2 || 1 || <code>[1/2]</code>
| 2 || 1 || <code>[1/2]</code>
|<math>\begin{bmatrix}
|<math>\begin{bmatrix}
   -1 \\
   -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
| 3 || 1 || <code>[3/2]</code>
| 3 || 1 || <code>[3/2]</code>
|<math>\begin{bmatrix}
|<math>\begin{bmatrix}
   -1 & 1 \\
   -1 & 1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
| 4 || 1 || <code>[9/2]</code>
| 4 || 1 || <code>[9/2]</code>
|<math>\begin{bmatrix}
|<math>\begin{bmatrix}
   -1 & 2 \\
   -1 & 2
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 57: Line 57:
|<math>\begin{bmatrix}
|<math>\begin{bmatrix}
   -1 &  1 \\
   -1 &  1 \\
   0 & -1 \\
   0 & -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 63: Line 63:
|<math>\begin{bmatrix}
|<math>\begin{bmatrix}
   -1 &  2 \\
   -1 &  2 \\
   0 & -1 \\
   0 & -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 69: Line 69:
|<math>\begin{bmatrix}
|<math>\begin{bmatrix}
   -1 &  3 \\
   -1 &  3 \\
   0 & -1 \\
   0 & -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 75: Line 75:
|<math>\begin{bmatrix}
|<math>\begin{bmatrix}
   -1 &  4 \\
   -1 &  4 \\
   0 & -1 \\
   0 & -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 81: Line 81:
|<math>\begin{bmatrix}
|<math>\begin{bmatrix}
   -1 &  5 \\
   -1 &  5 \\
   0 & -1 \\
   0 & -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 87: Line 87:
|<math>\begin{bmatrix}
|<math>\begin{bmatrix}
   -1 &  6 \\
   -1 &  6 \\
   0 & -1 \\
   0 & -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 94: Line 94:
   -1 &  3 &  0 \\
   -1 &  3 &  0 \\
   0 & -1 &  2 \\
   0 & -1 &  2 \\
   0 &  0 & -1 \\
   0 &  0 & -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 101: Line 101:
   -1 &  4 &  0 \\
   -1 &  4 &  0 \\
   0 & -1 &  2 \\
   0 & -1 &  2 \\
   0 &  0 & -1 \\
   0 &  0 & -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 108: Line 108:
   -1 &  4 &  0 \\
   -1 &  4 &  0 \\
   0 & -1 &  3 \\
   0 & -1 &  3 \\
   0 &  0 & -1 \\
   0 &  0 & -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 115: Line 115:
   -1 &  5 &  0 \\
   -1 &  5 &  0 \\
   0 & -1 &  3 \\
   0 & -1 &  3 \\
   0 &  0 & -1 \\
   0 &  0 & -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 123: Line 123:
   2 &  0 & -1 \\
   2 &  0 & -1 \\
   -1 &  1 &  0 \\
   -1 &  1 &  0 \\
   0 & -1 &  2 \\
   0 & -1 &  2
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 131: Line 131:
   2 &  0 & -1 \\
   2 &  0 & -1 \\
   -1 &  1 &  0 \\
   -1 &  1 &  0 \\
   0 & -1 &  3 \\
   0 & -1 &  3
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 139: Line 139:
   -1 &  0 &  0 &  2 \\
   -1 &  0 &  0 &  2 \\
     0 &  1 & -1 &  0 \\
     0 &  1 & -1 &  0 \\
     3 &  0 &  1 & -1 \\
     3 &  0 &  1 & -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 147: Line 147:
   -1 &  0 &  0 &  2 \\
   -1 &  0 &  0 &  2 \\
     0 &  1 & -1 &  0 \\
     0 &  1 & -1 &  0 \\
     4 &  0 &  1 & -1 \\
     4 &  0 &  1 & -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|-
|-
Line 155: Line 155:
   -1 &  0 &  0 &  2 \\
   -1 &  0 &  0 &  2 \\
     0 &  1 & -1 &  0 \\
     0 &  1 & -1 &  0 \\
     5 &  0 &  1 & -1 \\
     5 &  0 &  1 & -1
\end{bmatrix}</math>
\end{bmatrix}</math>
|}
|}

Revision as of 22:14, 10 November 2025

Fractran (originally styled FRACTRAN) is an esoteric Turing complete model of computation invented by John Conway in 1987.[1] In this model a program is simply a finite list of fractions, the program state is an integer. For more details see https://en.wikipedia.org/wiki/FRACTRAN

BB_fractran(n) or BBf(n) is the Busy Beaver function for Fractran programs.

Definition

A fractran program is a list of rational numbers [q0,q1,...qk1]called rules and a fractran state is an integer s. We say that a rule qi applies to state s if sqi. If no rule applies, we say that the computation has halted otherwise we apply the first applicable rule at each step. In that case we say st and t=sqi and i=min{i:sqi}. We say that a program has runtime N (or halts in N steps) starting in state s if ss1sN and no rule applies to sN.

Let Ω(n) be the total number of prime factors of a positive integer n. In other words Ω(1)=0 and Ω(pn)=Ω(n) for any prime number p. Then given a rule ab we say that size(ab)=Ω(a)+Ω(b). And the size of a fractran program [q0,q1,...qk1] is k+i=0k1size(qi).

BB_fractran(n) or BBf(n) is the maximum runtime starting in state 2 for all halting fractran programs of size n. It is a non-computable function akin to the Busy Beaver Functions since Fractran is Turing Complete.

Vector Representation

Fractran programs are not easy to interpret, in fact it may be completely unclear at first that they can perform any computation at all. One of the key insights is to represent all numbers (states and rules) in their prime factorization form. For example, we can use a vector [a0,a1,,an1]n to represent the number 2a03a1pn1an1.

Let the vector representation (for a sufficiently large n) for a state a=2a03a1pn1an1 be v(a)=[a0,a1,,an1]n and the vector representation for a rule ab be v(ab)=v(a)v(b)n (Note that this is just an extension of the original definition extended to allow negative ai).

Now, rule q applies to state s iff v(s)+v(q)n (all components of the vector are ≥0) and if st then v(t)=v(s)+v(q). So the fractran multiplication model is completely equivalent to the vector adding model. For presentation, we will represent a fractran program with a matrix where each row is the vector representation for a rule.

For example, the BBf(15) champion ([1/45, 4/5, 3/2, 25/3]) would be represented as:

[021201110012]

In this representation, it becomes much easier to reason about fractran programs and describe general rules.

Champions

n BBf(n) Example Champion Vector Representation
1 0 [1/1]
2 1 [1/2] [1]
3 1 [3/2] [11]
4 1 [9/2] [12]
5 2 [3/2, 1/3] [1101]
6 3 [9/2, 1/3] [1201]
7 4 [27/2, 1/3] [1301]
8 5 [81/2, 1/3] [1401]
9 6 [243/2, 1/3] [1501]
10 7 [729/2, 1/3] [1601]
11 10 [27/2, 25/3, 1/5] [130012001]
12 13 [81/2, 25/3, 1/5] [140012001]
13 17 [81/2, 125/3, 1/5] [140013001]
14 21 [243/2, 125/3, 1/5] [150013001]
15 28 [1/45, 4/5, 3/2, 25/3] [021201110012]
16 53 [1/45, 4/5, 3/2, 125/3] [021201110013]
17 107 [5/6, 49/2, 3/5, 40/7] [1110100201103011]
18 211 [5/6, 49/2, 3/5, 80/7] [1110100201104011]
19 ≳ 370 [5/6, 49/2, 3/5, 160/7] [1110100201105011]

References

  1. Conway, John H. (1987). "FRACTRAN: A Simple Universal Programming Language for Arithmetic". Open Problems in Communication and Computation. Springer-Verlag New York, Inc. pp. 4–26. http://doi.org/10.1007/978-1-4612-4808-8_2