Monday, April 11, 2022

Esolang: OISC 3b

In a (vain, I know) attempt to standardize things, here is OISC:3b, based on OISC:2.  I really do like this format better.  And there are 27 distinct combinations of +/0/- leading to obfuscatory effects!

Obfuscated Indirect Subleq with Coprocessor

Three word instruction:  A B C   

General form: C=B-A 
        Why not A-B=C?  Obfuscation is in the name!

Negative words are indirect addressing, which can be mixed: 
        [C]/[[|-C|]] = [B]/[[|-B|]] - [A]/[[|-A|]]

Instructions are only in positive memory.

If B=0 & C>0:  Output [A]/[[|-A|]] to I/O indicated by C. 

        1= STDOUT, 2= STDERR, 3...= File.
If A=0 & C>0:  Input [B]/[[|-B|]] from I/O indicated by C. 
        1= STDIN, 2= STDERR, 3...= File.

If B=0 & C<0:  Copy [A]/[[|-A|]] to [C]  (to negative memory)
If A=0 & C<0:  Copy [C] to [B]/[[|-B|]] (from negative memory)

If C=0:  If [A]/[[|-A|]] <=0, Jump B/[|-B|]
If A,C=0:  Jump [B]/[[|-B|]]
If B,C=0:  Relative Jump A

If A,B=0:  If [C]/[[|-C|]]<=0, HALT
If A,B,C=0:  HALT


Mem    Function

-1        IP (initialized to 0)
-2        NEXT (always IP+3)
-3        RETURN (set to NEXT before Jump]
-4        Register a
-5        Register b
-6        Register c
-7        Instruction Mode (activates on a,b,c; then resets to 0=NOP)
-8...     Data


Instruction Mode :  Takes immediate action on a,b,c, then resets to 0.

Mode       Effect

0        NOP
1        c = NOT a
2        c = b AND a
3        c = b OR a
4        c = b XOR a
5        c = b << a bits
6        c = b >> a bits
7        c = b*a
8        c = b/a (floored integer division) (HALT on /0)
9        c = b%a (Mod) (floored) (HALT on %0)
10        c = Sign of Int b (+1, 0, -1)
11        c = Sign of Float b (+1, 0, -1)
12        Int c --> Float c
13        Float c --> Int c
14        Int a,b --> Float a,b
15        Float a,b --> Int a,b
16        Float: c = b-a
17        Float: c = b+a
18        Float: c = b*a
19        Float: c = b/a (HALT on /0)
20        Float: c = power a of b
21        Float: c = root a of b (HALT on root 0)
22        Float: c = Log base b of a (HALT on base 0)
23        Float: c = SIN b
24        Float: c = COS b
25        Float: c = TAN b
26        Float: c = CSC b
27        Float: c = SEC b
28        Float: c = COT b
29        Float: c = ASIN b
30        Float: c = ACOS b
31        Float: c = ATAN b
32        Float: c = ACSC b
33        Float: c = ASEC b
34        Float: c = ACOT b
35        Float: a = pi, b = e, c = phi
36        Float: a = 1.0, b = 0.0, c = -1.0

Extensions to Mode are left to the user.

Sunday, April 10, 2022

Esolang: OISC:2

Continuing the attempt to make Subleq more concise.  Not faster or easier, mind.  I really like this one.  Not too easy, but more useful than standard Subleq.

Many thanks to Lawrence Woodman and also to the Truttle1 videos.

Two word instruction:  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 0; HALT

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

Mem    Function

-1        IP (initialized to 0)
-2        NEXT (always IP+2)
-3        RETURN (set to NEXT before Jump]
-4        Register a
-5    
    Register b
-6    
    Register c
-7    
    Instruction Mode (activates on a,b,c; then resets to 0=NOP)
-8        Flag (currently unimplemented and left to the user)
-9...     Data


Instruction Mode:  Takes immediate action on a,b,c, then resets to 0.

IM       Effect

0        No Op
1        c = NOT b
2        c = b AND a
3        c = b OR a
4        c = b XOR a
5        c = b << a bits
6        c = b >> a bits
7        c = integer b*a
8        c = b//a (floored integer division) (HALT on /0)
9        c = b%a (Mod) (floored) (HALT on %0)
10        c = Sign of b (+1, 0, -1)
11        c = Floor of b
12        Int c --> Float c
13        Float c --> Int c
14        Int a,b --> Float a,b
15        Float a,b --> Int a,b
16        c = b-a
17        c = b+a
18        c = b*a
19        c = b/a (HALT on /0)
20        c = power a of b
21        c = root a of b (HALT on root 0)
22        c = Log base b of a (HALT on base 0)
23        c = SIN b
24        c = COS b
25        c = TAN b
26        c = CSC b
27        c = SEC b
28        c = COT b
29        c = ASIN b
30        c = ACOS b
31        c = ATAN b
32        c = ACSC b
33        c = ASEC b
34        c = ACOT b
35        a = pi, b = e, c = phi
36        a = 1.0, b = 0.0, c = -1.0
37        c = b Rad --> Deg
38        c = b Deg --> Rad

Extensions to Mode are left to the user.

Friday, April 8, 2022

Esolang OISC:3

OISC:3 is a three word variant of OISC:4.  Naturally, we have to cut down on options.  It dispenses with the "if <=0, Jump" from every instruction.  Which, frankly, is no great loss.  I guess that makes this not technically a Subleq, but it keeps to the spirit of the thing.

Instruction A B C

If A>0:  Mem[C]=Mem[B]-Mem[A]
If A=0:  If Mem[B]<=0: Jump to C (Mem[|C|] if negative)

Negative addresses are indirect:  Mem[Mem[|A|]].

We can still use negative memory for data, but it has to be addressed indirectly.

Memory    Function
2             RET (set to NEXT before Jump)
1             NEXT (always IP+3)
0             IP (Initialized to 3) (HALT if negative)
-1           Input (replaces whichever A or B addressed it, -1 if none)
-2           Input Source and format
       (0 = wait for STDIN, 1 = immediate STDIN, 2... are Files)
-3           Output (outputs when a value is sent to it)
-4           Output Target and format
       (0 is STDOUT, 1 is STDERR, 2... are Files)
-5           Register a 
-6           Register b 
-7           Register c 
-8           Instruction Mode (IM) (activates Registers, then resets itself to 0)
-9...        Data

Thursday, April 7, 2022

Esolang OISC:4

Here is my esoteric language (esolang), Obfuscated Indirect Subleq with Coprocessor: 4 words per instruction (OISC:4).  {The joke is that OISC stands for One Instruction Set Computer.}

Instruction format:  A B C D are a 4 word instruction.
IP is the Instruction Pointer.  RET is the return pointer.
Positive memory:  Instructions and data, assumed to be signed integers.
Negative memory:  Coprocessor and data, may be integers or floats.

D>0:  Mem[C] = Mem[B] - Mem[A]; 
    if Mem[C]<=0, RET=NEXT, IP=D; else IP=NEXT

D=0:  Mem[C] = Mem[B] - A; (A is Literal)
    IP=NEXT

D<0:  Mem[Mem[C]] = Mem[Mem[B]] - Mem[Mem[A]]; (Indirect)
    if Mem[Mem[C]]<=0, RET=NEXT, IP=Mem[|D|]; else IP=NEXT

Low Memory

3        Z (initialized to 0)
2        RET (initialized to 4)
1        NEXT (always IP+4)
0        IP (if <0, HALT) initialized to 4
-1       Input (replaces whichever A or B addressed it, -1 if none)
-2       Input Source and format
       (0 = wait for STDIN, 1 = immediate STDIN, 2... are Files)
-3       Output (outputs when a value is sent to it)
-4       Output Target and format
       (0 is STDOUT, 1 is STDERR, 2... are Files)
-5       Register a 
-6       Register b 
-7       Register c 
-8       Instruction Mode (IM)
-9...    Data

Mode:  Takes immediate action on a,b,c, then resets to 0.

IM       Effect

0        No Op
1        c = NOT a
2        c = b AND a
3        c = b OR a
4        c = b XOR a
5        c = b << a bits
6        c = b >> a bits
7        c = b*a
8        c = b/a (floored integer division) (HALT on /0)
9        c = b%a (Mod) (floored) (HALT on %0)
10        c = Sign of Int b (+1, 0, -1)
11        c = Sign of Float b (+1, 0, -1)
12        Int c --> Float c
13        Float c --> Int c
14        Int a,b --> Float a,b
15        Float a,b --> Int a,b
16        Float: c = b-a
17        Float: c = b+a
18        Float: c = b*a
19        Float: c = b/a (HALT on /0)
20        Float: c = power a of b
21        Float: c = root a of b (HALT on root 0)

22        Float: c = Log base b of a (HALT on base 0)
23        Float: c = SIN b
24        Float: c = COS b
25        Float: c = TAN b
26        Float: c = CSC b
27        Float: c = SEC b
28        Float: c = COT b
29        Float: c = ASIN b
30        Float: c = ACOS b
31        Float: c = ATAN b
32        Float: c = ACSC b
33        Float: c = ASEC b
34        Float: c = ACOT b
35        Float: a = pi, b = e, c = phi
36        Float: a = 1.0, b = 0.0, c = -1.0

Extensions to Mode are left to the user.




Wednesday, April 6, 2022

Quantum Spin 1/2

 Let me repeat myself:  The map is not the territory.

Now, watch this video: "Electrons DO NOT Spin".  (I don't support PBS, but Spacetime is a really good show.)

Now, imagine a circle.  And a cosine wave.  And a sine wave.









What is a cosine (red) wave?  It's what you get if you attach a pen to the edge of a circle, and then roll the circle along in a straight line.  Note that the speed of rotation does not have to match the velocity of the center of the circle, but both must remain constant.  (A cosine wave is a sine (blue) wave, but 90 degrees off.)

Notice how the red "pen" starts at the top of the circle.  It moves along as the circle rotates until it reaches the bottom.  Notice what the sine (blue) wave does in that time.  It moves from zero to a positive peak and then back to zero.  Now look at where the red "pen" travels from the bottom back up to the top, completing one full rotation of the circle.  Notice how the blue pen, in that same time, moves from zero to a negative peak and back to zero.

This is what is going on with quantum spin 1/2.  The particle is rotating, but what the scientists are measuring is the sine function, because that's all they can detect.  You can only measure what you can see.

The map is not the territory.

Tuesday, April 5, 2022

Ice Cream Cone Universe

First, watch this Science Asylum video.

Each dimension is at a right angle to all others, by definition.  Up and down, forward and back, left and right.  These are the three dimensions of space.  Space, as nearly our best measurements can tell, is flat, or circular, or spherical in 3 dimensions.  That means the Pythagorean theorem holds.  A² + B² = C². 

Spacetime, on the other hand, is curved, as our best measurements have shown.  This is because time is hyperbolic.   A² - B² = C².

Circles are where a plane cuts through a cone horizontally.  They are also where a sphere resting inside the cone touches the cone.  Hyperbolas are where a plane cuts the cone vertically.  Vertical is at right angles to horizontal.  (Please note that the diagram below, stolen shamelessly from the internet, has an error.  A parabola is not a vertical slice.  Rather, it is a diagonal slice that exceeds the critical angle, and so isn't an ellipse.  A hyperbola isn't a "deep vertical" slice, whatever that may mean.  It's simply vertical.  Words have meanings.)




And thus, time is at 90 degrees to space.  

When using matrices to formulate spacetime, the three space dimensions are always written with a negative sign.  This is because space goes both ways.  Negative times negative is positive.  The time dimension is always written as a positive number, because time only and always goes forward.  positive times positive is still positive, and there is no way to make it become negative.

The angle of the cone represents the speed of light, the speed of causality.

We live in a sphere resting in a cone.  Our universe, in a very fundamental way, resembles an ice cream cone that never, ever drips down the sides.




Spinors explained

 In quantum mechanics, spinors are the name for this "weird" effect that for certain particles, it takes two "rotations" to return to the same state.  That's because what they're measuring as a "rotation" is really the magnitude of the wave created by a rotation that they are not directly measuring.

As you rotate a circle, the sine starts at zero.  It rises to 1 at a quarter rotation, and then falls back to zero at a half rotation.  Then it drops to negative one at three-quarters rotation, and then returns to zero at one full rotation.

One rotation of a circle, but if you're measuring only the sine (because that's all your instruments will do), you saw it appear to rotate twice, in opposite directions, before returning to the same starting configuration.

Quantum behavior is not rocket science.  It's geometry and trigonometry.

The map is not the territory.  Forget this at your peril.