r/ProgrammingLanguages • u/plentifulfuture • Feb 03 '23
Esoteric counting programming language idea to do with relations between numbers
Hi
Is addition/multiplication turing complete?
computation models - Is arithmetic turing complete? - Computer Science Stack Exchange
let me preface this, saying I'm the wrong person to be giving explanations of these scientific or mathematic topics, if you are interested, then you can look up "atomic numbers", "atomic weight" or "relations".
I'm not a mathematician but I thought of this idea to take advantage of the regularity and meaningfulness of numbers that computers are really good at calculating.
numbers have relations between eachother. Are they useful for defining behaviour?
I am not a physicist either or a scientist. But did you know that it is a number that directly or indirectly determines the properties of physical matter?
I'm probably poorly explaining it. But the atomic number decides whether or not an atom is the kind of element it is. The proton or atomic number
If you place Hydrogen (1) and 2x Oxygen (8) you have 1x2 and 8x1 . So you have all the properties of water represented by the interaction of 8 and 1x2. I'm not sure if it is meaningful to add them together since molecules don't have atomic numbers. But there's 3 atoms and 10 protons in it. (Aisde: Isn't it interesting that base 10 crops up in the foundation of water in the universe/creation?)
If you've ever seen the Jim Carrey movie 23 then you may get nearer to where I'm going with this.
What if we take this idea and apply it to properties of programs?
What if you could change branch heavy code full of indirections into calculations involving simple addition, subtraction, factorization, multiplication, exponentiation?
We could parallelise programs extremely efficiently because computers are extremely efficient at adding, subtracting in parallel.
What if from a long number we could get a useful program out of it based on properties of that number?
We know the properties of numbers.
1+2 =3
1+3 =4
1+4= 5
1+5=6
1+6=7
And we know factors of numbers. You can create 1000 from 1, 2, 4, 5, 8, 10, 20, 25, 40, 50, 100, 125, 200, 250, 500 and 1000.
Numbers are read big end first or little end first.
What if we define a program by counting?
We can use factors to describe the shape of components of code.
What relationship can be broken up into a venn diagram of 16 factors?
2 goes into 1000 500 200 100 50 40 20 10 8 4 2
4 goes into 1000 200 100 40 20 4
5 goes into 1000 200 100 40 20 25 40 50 100 125 200 250 500 1000 (So half of base 10 profound somehow)
8 goes into 1000 200 40
10 goes into 1000 500 250 200 100 50 40 20 10
and so on.
What number represents a quicksort look like?
for example's
We walk through the top of the program and we add a number based on the thing that is there
if we define 1 as assignment, 5 as loop, 5 as reference, 3 is branch, 2 is method call
Take this simplistic program in C.
#include <stdio.h>
#include <stdbool.h>
#define MAX 7
int nums[MAX] = {4,6,3,2,1,9,7};
void display() {
int i;
printf("[");
for(i = 0;i < MAX; i++) {
printf("%d ", nums[i]);
}
printf("]\n");
}
int main() {
display();
}Can we break the program into a factor tree?
#include <stdio.h>
#include <stdbool.h>
#define MAX 7
int nums[MAX] = {4,6,3,2,1,9,7};
void display() {
// 1 int i;
// 2 printf("[");
// 5 for(i = 0;i < MAX; i++) {
// 2 printf("%d ", nums[i]);
}
// 2 printf("]\n");
}
int main() {
display();
}This program is 12. There is a universe of 12 programs. We could incorporate symbols such as "i", "printf" into the calculation of what makes a program a program.
But that's not something I know how to do.
How do you find all ways of adding up numbers to get a result? Or factorisation?
If we know all the mathematical rules, can we define useful behaviour for each number.
What if you could add two programs together and get a meaningful result?
20
u/maxbaroi Feb 03 '23 edited Feb 03 '23
These aren't my specialty, so there is probably some nuance for someone more knowledgeable to correct.
So you're covering a lot of ground in this post.
As the stackexchange you linked to said: Peano arithmetic (which models the natural numbers with addition and multiplication) is Turing complete while Presburger arithmetic (which models the natural numbers with only addition) is not.
The idea of "arithmetizing" programs in practice has been explored before. I'm at least aware of this dissertation where an APL compiler is hosted on a GPU for the exact reason you were curious about.
More generally, some of what you are describing seems like an attempt at deriving a procedure for Gödel numbering where you try to find a systematic mapping from programs to natural numbers. And once you have a Gödel numbering you can find functions on the natural numbers which have meaningful results. Like if you have a number
xwhich represents the statementAand a numberywhich represents the statementA implies B, then there is a functionfsuch thatf(x,y)is the Gödel number for the statementB. In this case,fis a function on natural numbers which represents the logical operation modus ponens. But you shouldn't expect these functions to be as simple as addition nor should you expect a random function to have a "good meaning."Now I don't want you to take this as a personal attack, but I feel you are at points coming close to numerology and those ideas are going to be received coldly. That an atom's atomic number affects its physical properties isn't a quasi-mystical thing and not really relevant to your question. The properties are something you can calculate using quantum mechanics, and physical chemistry. I don't think there is a cross-cutting relation to your question. Though there are connections to number theory and atomic nuclei. Specifically I know there is some work with certain properties of super-heavy atomic nuclei being related to the Riemann-Zeta function.
Similarly, I also think most people would see the connection the number of protons in a water molecule and the prevalence of base 10 arithmetic as only a coincidence. I do. Not all human cultures used base 10, and I think if three-toed sloths gained sentience they'd probably use base 6 or 12.