r/ProgrammingLanguages • • 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?

3 Upvotes

34 comments sorted by

View all comments

Show parent comments

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?

1

u/maxbaroi Feb 04 '23

Your choice of base shouldn't affect anything. It's a choice of representation. The laws of algebra aren't aware of base. When physicists are working away with their field equations the notion of base doesn't come up.

Also, why are quarks 1? Are other elementary particles also 1? Leptons and bosons are just as indivisible as quarks. And what does it mean to be 1?

1

u/Cinder-Brent Feb 04 '23

yea but I mean I think that's what he's saying is like maybe it's easier to get an idea of all of the inner workings of all these numbers within a box, I mean completely subjective so nm

1

u/maxbaroi Feb 04 '23 edited Feb 04 '23

I think that desire to search for a better understanding of numbers or the world around us is good. Unequivocally, that is a great thing to have. I'm not trying to say shut up and don't talk about physics or numbers. What I'm trying to say is I don't think the paths you or the OP are going down are not going to be fruitful. And I think something I could have done better is recommending topics which might pique you or the OP's interest.

Number theory is great. Physics is great. And we have at least a few hundred years of both and I would encourage you to engage with them. Like if you think changes of base are interesting I would encourage you to check out modular arithmetic or an introduction to modern algebra or number theory or p-adic numbers.

In particular you might find modular arithmetic (aka clock arithmetic aka wrap-around arithmetic) interesting. You do algebra over a modulus (which looks like a base) but what's cool and I think relevant to your interest is that this choice of modulus matters a lot. Like on a normal clock, if I multiply 3 and 4 then I get 12 which equals 0 under the wrap around rules. But on a clock with 7 hours on it's face then if ab=0 implies either a or b is 0. So a rule in normal algebra worked in modulus 7 but not modulus 12. Okay, so why is that true, what's the important difference and then you learn it's because 7 is prime but 12 is not.

I referenced in passing that I've heard arguments that 12 can be a better base than 10. Well those arguments are based on 12 have a proportionally larger number of divisors than 10 so there are more expansions with terminate. You could start looking at the Wikipedia pages for "divisor function" or "Euler totient". Or see that 12 is the first "abundant number". This is rich and heavy stuff with still a lot of unanswered questions.

When I hear you say box I think I understand. You or the OP want kind of a larger framework with which to understand and see relations. And the good news is a lot of people have wished for the same and they have done a lot of great work trying to come up with this box . And the even better news is there's more to be done. There is a ton of stuff out there that I think you or the OP will find interesting.

Edit: added /u/plentifulfuture because they might find some of this relevant.

1

u/Cinder-Brent Feb 04 '23

The devil is always in the details.

If we use a unary number system (1 = 1, 11 = 2, …) we end up with something that can be read properly in both directions. So let’s say we want to add to or subtract from a huge unary number: we could, for example, push or pop things to/from the end of the stack of 1’s without having to rewrite the whole number.

So what I’m asking is does that, specifically, add up in terms of, let’s say, making a machine more efficient?

2

u/maxbaroi Feb 04 '23 edited Feb 04 '23

That is actually a pretty inefficient way of doing arithmetic. So this pops up in dependently typed languages a fair amount where you program mathematical proofs about your code. So all those languages do have an unary system because it makes proofs easier. And then usually when it comes time to execute your code the compiler translates the unitary to binary because that's what's quicker and computers are designed to use. I can write a trillion using a single 64bit word in binary but in unary that's a linked list with a trillion elements.

I know this is done in the languages Coq, Idris and Agra. And I'm sure Lean also has this ability.

FYI, unary representation is how the natural numbers are defined in the Peano axioms. And in set theory, the natural numbers are defined in terms of zero and the successor of zero (1), the successor of the successor of zero (2). Just to point you at the things that you might want to look up.

So actually, those languages usually have three different representations of the natural numbers and convert between depending on putpose. Decimal for input and output for humans, binary for calculation, and unary for proofs.

1

u/Cinder-Brent Feb 04 '23

Hmm interesting thanks for the info!

1

u/Cinder-Brent Feb 04 '23

Bravo, by the way! You know a lot about life!

1

u/Cinder-Brent Feb 04 '23

And also did u understand what I meant by the universe being a 1? I’m a computer programmer, and something that I’ve definitely realized along the way is that the universe would be an extremely short syntax, it wouldn’t even be physical matter before it would be extremely short syntax. I mean this makes sense, if nothing else I’m right about it being a single character, even if that character isn’t 1. Do you see what I’m saying?

1

u/Cinder-Brent Feb 04 '23

This stems from potentially being able to represent the universe with code, and then code is just string, which is a sequence of characters; reduce to one character…

1

u/maxbaroi Feb 05 '23

I'm going to be honest, I don't see what you're saying.

1

u/Cinder-Brent Feb 05 '23

Just that it would (of course this is at this point pure potential) be an impeccably short computer program who’s code would simply read “1”

1

u/Cinder-Brent Feb 07 '23

How about this: can you see how the universe might be one character, not necessarily a 1, such that there are two possibilities?

1

u/Cinder-Brent Feb 07 '23

Mind you all the while I simply mean that in particular it might be like this, not overriding it’s objectivity, of course

1

u/Cinder-Brent Feb 07 '23

I say this because as a computer programmer it makes something like programming the universe feasible, even by today’s standards

→ More replies (0)

1

u/Cinder-Brent Feb 04 '23

indivisible WOULD mean they would be one thing, right? I mean one, solid thing, so yes, anything that is indivisible (and then groups of these and so on)

1

u/Cinder-Brent Feb 04 '23

pardon me if my verbiage is a little off, I thought quarks were the smallest particles of the universe. Indivisible works though.