Friday, May 6, 2022

You have to ask the right questions

 To get the right answers, you have to ask the right questions.

The fundamental questions of physics are: 1) "What is motion?" 2) "What is time?" 3) "What is space?" 4) "What is spacetime?"

The answers to these questions turn out to be ridiculously simple.

1. Standing wave in spacetime. (If motion and gravity (spacetime curvature) have the same effects, they must have similar causes. Note that a tangent to the curvature of spacetime is literally distance over time.)
2. Steadily increasing linear eccentricity (C) of a hyperbola. (The focus is steadily moving away from the origin.) A^2 - B^2 = C^2
3. Steadily increasing radius of a sphere with center at the focus of the time hyperbola. (Distance C from the origin.) A^2 + B^2 = C^2
4. Potential energy field with a fixed maximum, from which all other fields draw their energy. (Total energy everywhere is a constant.) There being no such thing as negative energy, there is also a fixed minimum. This is where black holes show up, and why they are hollow shells of maximal density with nothing inside.

The universe is an expanding sphere in an ever expanding light speed cone defining a hyperbola which is time. As my daughter said, we are tiny sprinkles in the ice cream cone of existence.

Hypothesis: At creation, antimatter and "negative energy" went into the cone extending the other way from the origin. Thus, everything really does sum up to zero over the largest view.


Tuesday, May 3, 2022

Esolang OISC:3e

 I know, I know.  I'm fascinated and nobody else cares.

My ideas have shifted with the experience of building and using the assemblers and interpreters.  This is the latest, greatest version of how OISC:3 works.

Obfuscated Indirect Subleq with Coprocessor: 3 word instructions

Positive and negative memory both exist in the same save file.  Instructions are restricted to positive memory.  Indirect addressing is accomplished through the use of real/float/decimal numbers ("121.0").  This is the key to unlocking useful negative addressing and simplifying everything.

The assembler will work with raw numbers, names, and even with the built in instruction macro names (in italics below).  And yes, I have a working assembler and interpreter.  It even can output an executable raw numbers file.

Instruction formats:

A B C    [C] = [B] - [A]                 /sub    
A B 0    [B] = [B] - A                   /lit-    
A 0 C    if [A] <= 0, call C             /call
                pushes NextIP onto the return stack
0 B C    if [B] <= 0, jump to C          /jump
A 0 0    push [A] onto the stack         /push
0 B 0    pop the top of stack to B       /pop
0 0 C    execute instruction [C]         /exec
                operates on the stack
0 0 0    return                          /ret
                pops the top of return stack to NextIP


Assembler formats:

#            comment
%            data
name:        naming a memory word
name         using a named word
*name        indirect reference [[name]] (if N is 23, *N is 23.0)
@            this word
?            next word
% --NEGATIVE: --NEGATIVE--     mandatory memory separator
!            0
;            end of instruction
,            separator
" or '       string delimiters
ZERO         automatically created word containing 0

/sub can be called with 1, 2 or 3 words
    A B C    [C] = [B] - [A]
    A B      [B] = [B] - [A]
    A        [A] = 0
/lit- must be called with 2 words
    A B      [B] = [B] - A
/call and /jump can be called with 1 or 2 words.
    A B      if [A] <= 0, branch to B
    A        unconditional branch to A
/push/pop and /exec are called with 1 word
    A        push [A] / pop to [A] / execute instruction [A]
/ret takes no arguments.  If the return stack is empty, the program will halt.  Branching to a negative address will also halt.


Stack instructions:

     Positive                      Negative
1    input char ( -- a)            output char (a -- )
2    input digit  ( -- a)          output number (a -- )
3    DUP (a -- aa)                 DROP (a -- )
4    OVER (ab -- aba)              SWAP (ab -- ba)
5    roll left N (abcd1 -- bcda)   roll right N (abcd2 -- cdab)
6    reverse stack (abcd -- dcba)  clear stack (abcd -- )
7    depth of stack ( -- a)        pick N (abcd3 -- abcdb) 
8    bitwise true ( -- -1)         bitwise false ( -- 0)
9    bitwise AND (ab -- a&b)       bitwise NOT (a -- ~a)
10   bitwise OR (ab -- a|b)        bitwise XOR (ab -- a^b)
11   shift left N bits (aN -- a)   shift right N bits (aN -- a)
12   times (ab -- a*b)             divide (ab -- a/b)
13   int division (ab -- a//b)     remainder (ab -- a%b)
14   exponent e (a -- exp(a))      natural log (a -- log(a))
15   convert to integer (a -- a)   convert to float (a -- a)
16   alloc N words (sign matters)  free N words (sign matters)
17   plus (ab -- a+b)              minus (ab -- a-b)
18   sin (a -- sin(a))             asin (a -- asin(a))
19   cos (a -- cos(a))             acos (a -- acos(a))
20   
tan (a -- tan(a))             atan (a -- atan(a))
21   sinh (a -- sinh(a))           asinh (a -- asinh(a))
22   cosh (a -- cos(a))            acosh (a -- acosh(a))
23   tanh (a -- cos(a))            atanh (a -- atanh(a))













Wednesday, April 27, 2022

The basis of physics

1.  Total energy is a constant at every point.

2.  There is no such thing as negative energy.

3.  Spacetime is a field of potential energy.

Everything else follows.

Black holes are hollow spheres of maximal energy density/zero potential energy.  There is nothing inside them.  There are no singularities.  There are no infinities.  There are no contradictions.

The spacetime gradient is a change in distance divided by a change in time.  It's literally motion and acceleration.

Oh, I almost forgot.  Rule zero:  Everything except energy sums to zero.  (Even energy sums to zero if our antimatter/negative energy counterpart universe is moving away from us on the opposite end of the conic section.)

Tuesday, April 26, 2022

More thoughts on the ice cream cone universe

 So, if the universe really is ice cream cone shaped...


Space is a sphere, indicated by the circle on the cone.  Time is a hyperbola, perpendicular to the circle (as all dimensions should be perpendicular).

If the universe really is expanding, then the circle is getting bigger and moving up the cone.  Assuming the foci of the hyperbola are the centers of the circles, that means the hyperbola's modulus must also be getting larger.  This could be the explanation for galactic redshift.  It's not space stretching, but time.  The photons are running uphill over the long stretch (heh) of time.

Does that mean that the big bang happened at the center, and our universe went one way, while the antimatter universe went the other?  This would match up with physics rule zero, that postulates that everything except energy adds up to zero.  Huh.  This makes just a bit too much sense, and is a little too simple.

Subleq Plus

I got the Subleq+ compiler and interpreter working.  They're posted on GitHub.  This is a huge advance over hand jamming the physical addresses.  Many thanks to Chris Lloyd for the basis of the system.  The parser is still mostly his code.

Subleq is a single instruction computer.  That instruction consists of three words, A B C.  The function is [B] = [B] - [A]; if [B] <= 0, jump to C.  "[x]" means the contents of memory at location x.  As limited as it seems, you can theoretically do anything with a computer like this.  It just takes longer.

Why am I interested in this?

  1. I'm a geek.  If that wasn't obvious by now, you haven't been paying attention.
  2. Subleq reminds me of a programming project I found in a magazine for the Commodore-64 back when I was a kid.  There was some toy language that only had two instructions:  Increment an address by one, and decrement an address by one and jump if it was zero.  I played around with that for weeks.  Good times.  Happy memories.
  3. This has gotten me back into programming for the first time in almost 30 years.  I actually went to college for programming back in the early 90's.  I dropped out (the second time) when I noticed that I, as a Junior, was helping the grad students with their projects.  I also saw that my friends were having trouble finding local jobs in the field, as the industry was leaving Ohio and moving to California at the time.  I just lost interest and motivation.
  4. Being partially disabled and mostly stuck at home, I have a lot of time on my hands and I get bored.  This is a nice challenge.
So, where to go from here?  I could adapt the system for OISC:2.  But I would want to update the design to accommodate some of the new ideas I've had for OISC:3.  Negative memory references actually to go negative memory, where they are automagically redirected.  OISC:3 will use a stack, and the program counters, etc, won't be in addressable memory.  Input and output will also be stack commands.  This, of course, won't work well for OISC:2, because of the constraints of the language.  So I think I'll just leave it alone, and maybe adapt the parser to it.  Oh, and I'm renumbering the mode commands to use negative numbers, because I like the symmetry of having things like addition/subtraction, multiplication/division, power/log, sin/asin and or/xor having opposite signs.

Is a stack too much power for an esolang like this?  If course it is!  Could it take some of the challenge of using a language like this away?  Of course it can!  But that's not really the point, is it?  It's not to use the language so much as to create a usable language.  And it still doesn't have an explicit instruction.  It's all just data and memory locations.  But then, that's all computers really are.

Monday, April 18, 2022

Esolang OISC:2b

Obfuscated Indirect Subleq with Coprocessor
2 word instructions
version b

I finally have a working emulator for OISC:2b that accepts positive and (optional) negative memory files.  The coprocessor has been improved.  Positive memory is loaded as integers only.  Jumps to negative memory Halt.

Two word instructions:  A B

If A & B are both positive: [B]=[B]-[A]
If A & B are both negative: [[B]]=[[B]]-[[A]]

If A is positive and B is negative: IF [A] <= 0 Jump |B|
If A is negative and B is positive: IF [[A]] <= 0 Jump B

If A is 0 and B is positive: STDIN -> [B]
If A is 0 and B is negative: STDIN -> [[B]] 

If A is positive and B is 0: [A] -> STDOUT
If A is negative and B is 0: [[A]] -> STDOUT

If A & B are both 0: HALT

Negative memory can be addressed by indirection, but instructions are only in positive memory.

Negative Memory
Address        Function
-1                IP (initially 0)
-2                NEXT (always IP+3)
-3                RETURN (initially 0, set to NEXT before any jump.)
-4                Register a
-5                Register b
-6                Register c
-7                Mode (activates a, b, c; then resets to 0)
-8                MaxPos memory size
-9                MaxNeg memory size
-10...           Data (address: start from 0, add 10, negate)

Coprocessor
Mode    Function
0          NOP
1          c = ~b (bitwise not)
2          c = b & a (bitwise and)
3          c = b | a (bitwise or)
4          c = b ^ a (bitwise xor)
5          c = b << a (shift b left by a bits)
6          c = b >> a (shift b right by a bits)
7          sign of b   (+1, 0, -1)
8          floor of b (integer)
9          truncate b (round down, integer)
10        c = b - a
11        c = b + a
12        c = b * a
13        c = b // a (integer division)
14        c = b % a (mod, integer remainder)
15        c = b / a
16        c = b to power of a
17        c = a root of b
18        c = log base b of a
19        c = sin(b)
20        c = cos(b)
21        c = tan(b)
22        c = asin(b)
23        c = acos(b)
24        c = atan(b)
25        c = sinh(b)
26        c = cosh(b)
27        c = tanh(b)
28        c = asinh(b)
29        c = acosh(b)
30        c = atanh(b)
31        c = sqrt(b**2 + a**2)  (hypotenuse)
32        a = pi, b = e, c = phi (golden ration)
33        c radians <-- b degrees
34        c degrees <-- b radians
35        c = greatest common divisor of b and a
36        c = a permutations of b items (unique)
37        c = a combinations of b items (not unique)
38        c = b! (factorial)
39        c = sum of 0..b (integers, works with negatives)


Sunday, April 17, 2022

Esolang OISC:3d

Updated:  18 April 2022

No, I can't leave well enough alone.  I think we've established that by now.  This one might be more useful.  Too useful?  Negative addresses were a pain in the previous versions, and most instructions aren't indirect, so I've swapped functionality to simplify the interpreter.  It should also make programming easier and negative memory much more useful.  Note that memory address 0 is still impossible to directly address.  

Positive memory is loaded as integers only.
A jump to negative memory Halts & Fails.

Instruction    Function
A B C            [C] = [B] - [A]
0 B C            If [B] <= 0, Jump to C//[-C]
A 0 C            If [A] <= 0, Relative jump by C
A B 0            [[B]] = [[B]] - [[A]]  (indirect addressing)
A 0 0            Input [A] as character
0 B 0            Output [B] as character  (if [B] < 0, Halt & Fail)
0 0 C            Output [C] as number
0 0 0            Halt & Succeed

Address        Function
-1                IP (initially 0)
-2                NEXT (always IP+3)
-3                RETURN (initially 0, set to NEXT before any jump.)
-4                Register a
-5                Register b
-6                Register c
-7                Mode (activates a, b, c; then resets to 0)
-8                MaxPos memory size
-9                MaxNeg memory size
-10...           Data (address: start from 0, add 10, negate)

Mode    Function
0          NOP
1          c = ~b (bitwise not)
2          c = b & a (bitwise and)
3          c = b | a (bitwise or)
4          c = b ^ a (bitwise xor)
5          c = b << a (shift b left by a bits)
6          c = b >> a (shift b right by a bits)
7          sign of b, +1, 0, -1
8          floor of b (integer)
9          truncate b (round down, integer)
10        c = b - a
11        c = b + a
12        c = b * a
13        c = b // a (integer division)
14        c = b % a (mod, integer remainder)
15        c = b / a
16        c = b to power of a
17        c = a root of b
18        c = log base b of a
19        c = sin(b)
20        c = cos(b)
21        c = tan(b)
22        c = asin(b)
23        c = acos(b)
24        c = atan(b)
25        c = sinh(b)
26        c = cosh(b)
27        c = tanh(b)
28        c = asinh(b)
29        c = acosh(b)
30        c = atanh(b)
31        c = sqrt(b**2 + a**2)  (hypotenuse)
32        a = pi, b = e, c = phi (golden ration)
33        c radians <-- b degrees
34        c degrees <-- b radians
35        c = gcd(b, a)  (greatest common divisor)
36        c = a permutations of b items (unique)
37        c = a combinations of b items (not unique)
38        c = b! (factorial)
39        c = sum of 0..b (integers, works with negatives)