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.

Friday, April 1, 2022

So there I was in Kosovo

 Once upon a time, in a land far away, young SGT McChuck was newly arrived in Germany.  Right after finishing inprocessing, I was told to go to war with these two others whom I had never met, because they were still inprocessing.  The regular teams were away, training to be deployed, so they couldn't be deployed to war.  No, I'm not kidding.  So the few people still there at the base helped me collect all the broken gear that nobody else wanted.  I found an Albanian phrase book in the base library, and copied the map out of a thirty year old encyclopedia set.

Our little team of three ended up doing more than any other CI team in theater, just by sheer bad luck.  I got to sit on an actual Serbian prisoner, with orders to tell him to shut up.  I later saw him on the news, standing with President BJ Clinton at the White House.  Then they sent him and the other prisoner back to Serbia, where they were tortured to death.

One day, we were told we had 20 minutes to load up the truck and meet a convoy going out for an overnight trip.  We spent the next six weeks tooling around northern Albania with the MLRS battery.  Why yes, it did completely suck, thanks for asking.  But I got to watch a B52 strike on the other side of a mountain, across a lake, at night.  It was glorious.  I drove the truck up a logging path that was a few inches more narrow than the truck, against a 2,000 foot cliff.  And then go back down the next morning.  (Our civilian girl 'terp from Manhattan had no idea that you could actually see the sun rise in the morning.  She was cute but dumb.)  I got a close view of a battalion of T-55's.  One day the convoy stopped in a river valley and a helicopter landed on the stony shallows.  A US Special Forces team came over and abducted our older male US civilian 'terp.  They abandoned him in place a couple days later (assholes), and we eventually rescued him.  

But what reminded me of all this was:

https://borepatch.blogspot.com/2022/03/what-is-it-with-air-force-and-bronze.html

I was one of the troops in Albania (day 4) and Kosovo (day 2). I got a coin, a wart, and a NATO medal with star. What a stupid war. We got involved to keep it from spiraling into a regional conflict (and so BJ Clinton could show what a strong President he was). Albania was preparing to invade Serbia to defend their Kosovar cousins. Greece was preparing to attack Albania to defend their Orthodox brethren. And Turkey was threatening to attack Greece because two thirds of Albanians were Muslim. (And because Turkey/Greece, of course.)

In the end, Russia won, and used Kosovo as an excuse to invade Georgia. But I got to play with a Russian BRDM at the Pristina airfield. (It sucked to be the only Serbian/Russian linguist. Especially when you've been speaking Serbian so much that you can't speak coherent Russian any more. And your little team of three is sent cross country alone, to go ask the Russians to leave before Secretary Albright's plane lands.)
https://en.wikipedia.org/wiki/Incident_at_Pristina_airport