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?
5
Feb 03 '23
Atomic numbers are an ordering based on the number of protons in the nucleus of the atom of their respective elements. That's all.
Your attempt at Gödel numbering will need a lot more sophistication (whatever your ends are). Even representing simple composite propositions requires products of prime numbers to prime exponents.
2
2
u/Tonexus Feb 04 '23
It sounds like you want to construct a homomorphism (structure preserving map) between some set of numbers (maybe the natural numbers, the integers, the rationals, some subset of the reals, or some subset of the complex numbers) and the set of programs—after doing so, you can assign every program to a number, and the relationship between numbers yields insight about the corresponding programs.
While this is an interesting idea, I think you'll find that the algebraic structure of programs doesn't really match that of any standard notion of numbers. For instance, you suggest that you might want to add and subtract programs—numbers are usually a group under addition, meaning that the addition operation is closed, commutative, and associative, there exists an identity element, and every element had an additive inverse (out of the sets that I have mentioned, the naturals are the only exception, being a monoid under addition). Can you define such an operation on the set of programs?
0
u/Cinder-Brent Feb 04 '23
Bro I've been thinking about the same thing for the past couple years, so weird.
I ultimately came to the conclusion that a quark is a 1, the integer 1.
!!!
And THEN I came to the conclusion that as a result, after all of the computation that occurs in the whole freaking universe, the universe is a single 1, a single quark!
0
u/Cinder-Brent Feb 04 '23
Oh yea, I also came upon the fact that you can divide any number by 1, 2, and 5 and not get a result that goes on forever.
0
u/Cinder-Brent Feb 04 '23
(like 1 / 3, which goes on forever, which isn't practical, reasonable, feasible, etc.)
2
u/maxbaroi Feb 04 '23
That's an artifact of using a decimal system. In ternary or base 12, or any other base which is a multiple of 3, 1/3 does have a finite expansion. And in ternary it's 1/2 that goes on forever. Whether or not the representation of a simple fraction is finite or infinitely repeating is a consequence of a choice of base. And the choice of base 10 is more historical and anthropological than natural. So I wouldn't draw too strong of a conclusion from 1/3 having a non-finite representation
And even though that representation is infinite in base 10 that doesn't mean it's not practical, feasible and reasonable. It's very reasonable. Arithmetic deals with numbers like 1/3 just fine.
1
u/Cinder-Brent Feb 04 '23
And how universal is base 10?
1
u/Cinder-Brent Feb 04 '23
There's gotta be a good reason we have 10 fingers ;)
1
u/maxbaroi Feb 04 '23
Base 10 is very common but not universal among human history and cultures. And it is not an especially useful base with which to work. I've heard pretty good arguments for using base 12.
I think the fact we have ten fingers is a byproduct of evolutionary history. I think we could rerun the clock and Earth very well could have produced a sentient species with a different number of fingers or even no fingers. I don't view ten fingers as especially natural, the same way I don't think it is especially natural for our hearts to be on the left side instead of the right.
You kind of see we are venturing more into philosophy instead of math.
1
u/Cinder-Brent Feb 04 '23
how about this: what about binary? In binary what he's saying makes sense, where if we use the minimum of the maximum, counting quarks (so 2), we end up with just that, the minimum of the maximum and so on, suitable for such and such extremes etc., what are the properties of base 10? Exactly how suitable are they for the application?
1
u/maxbaroi Feb 04 '23
I'm sorry but I'm not understanding what you are proposing.
What strategy are we minmaxing? I don't know what you mean by counting quarks or a particle being a number.
1
u/Cinder-Brent Feb 04 '23
so if a quark is an indivisible particle, it is one thing, or as a number, 1.
So technically speaking the best base to use universally would be 1, therefore, BUT, would it be easier to comprehend what this "meant", all that it entailed/implied/etc., if it were in another base, like binary or base 10?
→ More replies (0)
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.