Skip to content

Instantly share code, notes, and snippets.

@Recoskie
Last active May 23, 2023 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Recoskie/de34fad9c803c670795ba85d721008c8 to your computer and use it in GitHub Desktop.
Save Recoskie/de34fad9c803c670795ba85d721008c8 to your computer and use it in GitHub Desktop.
Modern artificial intelligence, data algorithms, and the limits of computation.

Modern artificial intelligence systems and data algorithms that are great for modern applications but are still not fully applied to software and our daily lives.

The smallest list of instructions we can program with is "AND", "OR", "NOT", and "Shift".

We can also exclude "shift" If we want to only reposition the digits using logical operations.

I built this small code a long time ago to demonstrate it as simply as possible for fun.

The basic logic operations are enough to build all operations and even comparisons.

It is enough to make every operation in a modern CPU or support a modern high-level programming language.

Using this script, you can add/subtract positive and negative numbers together using the "Add or Sub" method.

alert( Add( -13, 7 ) + "" );
alert( Sub( 19, 37 ) + "" );

You can multiply and divide 15-bit numbers.

When using 15-bit, multiply or divide. The two numbers you multiply by or divide by can not be bigger than 32767.

You can make the multiply and divide pattern as big as you like. Continuing the pattern to the next digit will increase the number range you can divide or multiply by a multiple of 2.

You can also compare numbers without comparison. Using the logic implementation of comparison.

Normally comparison is done using arithmetic subtraction. The difference between 0 of two numbers.

In this code, we can simulate the comparison operation and flag outputs.

In some cases, we can actually formulate faster methods than what is built into a programming language math library.

See Fast Bitwise Log2.


Combinational logic is based on the three "AND", "OR", and "NOT" gates to build all Arithmetic. See a brief introduction to combinational logic Link.

Generally speaking. If you want to design a complex function or analyze something that has no answer. It is best to create a table of what you want all the outputs to be relative to all the inputs.

At the smallest scale, we can represent all numbers as ones and zeros in a positional number system based on two digits per column. If we go smaller than two digits per column, we can not do the same tasks as it is no longer positional. See Binary number.

ABOut
0000000
0001001
0010010
0011011
0100001
0101010
0110011
0111100
1000010
1001011
1010100
1011101
1100011
1101100
1110101
1111110

This is called creating a truth table for your custom function or what you are analyzing. Now unlike a quantum computer which can line up to the answer instantly, we have to do it one step at a time in a digital system.

All you have to do is compare each digit using "AND" and "NOT". XOR is basically an "and," "not" comparison and is useful in separating data that is linearly separable in artificial intelligence systems see Neural networks linear data separation using XOR.

However, to solve the data precisely into what it is, you must compare each zero digit using "NOT" under one input combination, then use "AND" to output one if the combination is set. You then have to change this one output to your desired outputs. You do this for each line in the truth table.

If we have input "A" as 10 and input "B" as 01, then flipping all the zeros to ones as follows 1, NOT(0), NOT(0), 1 = 11, 11 will only be all ones if the inputs match. A faster method is to use two values for all inputs. In my ultra-fast log2 implementation, I used the value "V" as the inputs and the value "Vr" as all binary digits flipped.

We then compare using "AND" which will only output a ONE if all values are ones. This limits to just one combination of the inputs.

B1 and not B2 and not B3 and B4

The values B1 to B2 are input "A", and values B3 to B4 are input "B". The output will only be 1 if input "A" is 10 and input "B" is 01. In our case, all things that are "NOT" are "Vr", and all things that are ones are "V".

We then can change this output to any set of outputs we like. Our initial output values will always be all zero, so all we have to do is add our one output for when A=10 and B=01 to be 011. We could multiply our one output by the value 011, which I did with my ultra-fast Log2 Int32 V2 function, but then we have to deconvert the multiply into digit placement.

So we can skip the multiplication and take our one output which is only one when A=10, and B=01, and insert it into our output in places one and two, forming output 011=3. To do this, we shift to the left by one for the second position, "1 << 1 = 10", and add "1 << 0 = 1". To add digits together in our output, we use "OR" = "|". Also, we can do multiple outputs as separate output values.

This creates a single line that outputs the values we want to a specific set of inputs. This can be matching particle collisions to what the outputs should be or solving math functions that had no answer.

You then combine all lines with "OR" which will only output one if any of the lines have a result to the matching inputs to the matching outputs. This combines all our separate lines together. This allows us to align anything we like to an absolute answer by taking out all matching comparisons between all lines. You can see this done under the Log2 Int32 V3 function.

You take out all XOR combinations and replace them with XOR first. You then replace the rest with "ADD", "SUB", "MUL", and "DIV".

This creates your new math function combinationaly. This is also how I built the super fast log 2 function pattern. Except I did not start with a truth table. Instead, I started with the function and did the same thing per value of "n".

You can design a simple function that translates truth tables into the smallest math function possible. Also, A truth table of what all inputs and outputs are is enough to rebuild any digital circuit without knowing its schematic diagram, as the truth table has all the combinations of the inputs to outputs combinations, that is, the underlying circuits. Allowing us to replicate the digital circuit one transistor switch at a time.

Working out "Math.sin" or "Math.cos" takes a big table, but it is also fun. It changes into a pattern, much like the division and multiplication functions. We can match our currently defined division and multiplication functions to the pattern to calculate sine and cosine faster as a series. Generally, we do not need to calculate it very far, for it to be accurate or build a big logic circuit for it. This is because we are limited to the accuracy of a 64-bit floating point number.

You can even reconstruct a comparison that has to happen between the arithmetic math pattern based on zero. As comparison is done relatively between zero logically.

Working this way. You can design all math functions and custom functions like an artist where nothing is impossible. You can also define any kind of function about anything in the world around you.

You can also use it to solve problems that had no answers originally in a quantum solve way. You can automate the entire task as well.

In quantum computing, we have qubits that can be "up" or "down" as a "one", or "zero", or be both "one and zero in a superposition state". We can do the same thing with qubits as we do with "AND", "OR", and "NOT" except much faster as the qubits align to the answer instantly using entanglement rather than us comparing everything in "AND" and "NOT", then "OR" everything together to get our answer. This also means programming a quantum computer to do math along qubits is done differently to align to an answer. This also means some of the simpler calculations are easier to do on a digital system rather than on a quantum system. Alining things to an absolute answer and analyzing data is faster on a quantum computer. A digital system can do such alignment and solving to an absolute answer one step at a time. We can combine most of it together geometrically in a matrix as there is a pattern that runs through all combinations making such alignments fast on the digital system using the defined math functions "addition", "subtraction", "multiplication", and "division".

If you want a faster, more modern automated method that solves all things matrixed geometrically faster. You can use my Q-AI matrix: Link. It also has good documentation and shows the structure of all things and how it builds geometrically in as simple of an explanation as possible.

You may also find it interesting how we can pick a single number apart into what it is see FL64 Number analysis library.


In theory, we can not have a unit smaller than the plank length, and at the plank length, we can create an E8 point space that is consistent with all particles in nature using tetrahedrons that have three states. See Quantum gravity E8.

At the smallest scale, we are legit working with things in a three-state space. Whether it be our "AND", "OR", "NOT" language, qubit entanglement (fast), or The geometry of all things in higher/lower dimensions sequenced geometrically.

Anything is possible. If you take the time to map what you want to solve. There are no limits to what you can solve the answer to, or build. There are some limits, but I will discuss them in detail in the truly random data section.

You also should not have to rebuild the book of physics or calculus by analyzing what is to what it is.

You should be able to visualize your code and methods without having to resort to automated breakdown and auto-solve everything in your reality to functions or code.

However, it can be fun to reconstruct everything based on what we analyze. It can also give us a much deeper understanding when we visualize patterns/code or look at a math formula. It also gives us a much deeper understanding of the world around us. You may eventually realize everything is like a fractal. In which all points are equal to its whole. From a quantum perspective, this is how simple reality is, even though it seems very diverse. It may even become apparent to you that everything connects together. You then may realize everything traces back to a singular point of existence which is present in everything and everyone. Scientifically we call this the singularity.


If we want to dive deep into reality before the plank length, then we would end up with a zero-point space. However, zero would be thought of as being nothing, but it is far from nothing as it is both infinity and nothing in a topological sense. See THE MYSTERIOUS ZERO/INFINITY.

Nuclear energy is much smaller than Atomic energy and is more powerful than Atomic energy. The closer we get to absolute zero, the closer we get to infinity which is the beginning of the universe. It is theorized that if we could go all the way to zero, we would tap into the universe's infinite energy. Zero can not exist without infinity; zero into itself is infinity in an endless feedback loop.

Nothingness - Alan Watts. One suchness - Alan Watts.

Because we can build functions that calculate out what anything is to exactly what it is, we also have a problem with security and encryption of data see Random numbers really random?.

We can reduce any set or outputs back into the simplest function to produce the outputs. This is great when analyzing particle collisions and mapping the function inputs and outputs or designing a function for any given data measured from the world, but also poses a big security risk.

Using results from an already running system, such as the world around us, can make the values more random, but you may be wondering how this is in cause and effect. The laws of cause and effect limit how random anything can be in the universe; see Physics the law of cause and effect. It is not that it violates the law of cause and effect, but it is very complicated what chaos and random actually are.

Take, for example, a series related to one blob in a lava lamp. What happens if another blob hits another in the lava lamp. Well, it changes the output. We can map this effect, but it would take a very long time to map the inputs and outputs into the state and physics calculations of the lava lamp. If the temperature in the environment changes, so does the lava lamp. If someone touches the lava lamp, then the state of the lava lamp changes. The Lava lamp does not violate the laws of cause and effect and can be run as a physics simulation. We can never know for certain what the exact state of the lava lamp is in cause and effect.

Another example is the game of Life simulation.

Just three simple steps allow us to build complete simulations of computers, simulate the game of life in the game of life infinitely, or cell-based simulations. It is more than just a zero-player game or simulation and is not entirely deterministic and also not entirely random, much like reality.

Another example is radioactive decay. What actually is happening is we end up with a function to compute it, but we end up with a 50% chance it disintegrates in its half-life. The half-life comes from the fact of the quantum effect and entanglement. Radioactive particles are not affected by particle interactions but by quantum effects. At very small scales, we get a little bit of random because of quantum interactions that happen across vast distances between entangled particles. Knowing the full picture and state of all particles and what particles are entangled is not possible. We would need a very powerful system that could simulate reality itself in cause and effect. It is not that the environment around us or the noise or interference is completely random. Even at the quantum level, noise is not entirely unpredictable but is complicated to correct. Our brains are hardwired to perceive randomness as we can not see everything that leads to the result, so we perceive a lot as random, which is actually a long series of effects that come together that lead to the result. Random-based and chaos systems self-organize into fractal patterns naturally. We have generally used fractals to correct random noise or predict random data.

Emergence is another example; see Emergence – How Stupid Things Become Smart Together.

Even using real numbers from the real world is not enough, so we have to measure numbers and compare them to make sure they do not trace to anything. This is done to ensure even a quantum computer can not align the values into an answer or that we can not align the values into an answer in "AND", "NOT", and "OR", or use a quantized matrix. We can not prove that random is real in the natural world as what we measure always breaks down. At very small scales, we get a little bit of random because of quantum interactions that happen across vast distances between entangled particles. I do not see us building a system to simulate all of reality in cause and effect at these tiny scales. We can use the quantum effect to get random values. We can measure numbers from the real world and check if they reverse to a function, and if they do, we measure again till we get a value that does not come out as the same function. This then makes it uncertain what the next value is. This ensures the values are unrelated or belong to a much larger set or pattern bigger than the set itself. As the set gets bigger, then it takes longer to sequence all the values in a truth table or even in a quantized matrix, but on a quantum computer, we can align any set instantly into what it is, allowing us to build truly random generators that follow this rule.

//Create Xor. Note Xor is a derived gate function.
function Xor( n1, n2 ) { return( ( ~n1 & n2 ) | ( n1 & ~n2 ) ); }
//The variable C will store the carry after each add.
var c = 0;
/*Binary addition.
Add is a basic xor. If both inputs are not 0 + 0, or 1 + 1 then they add to a sum of 1 (XOR).
The only thing the XOR excludes is if both inputs are 1 + 1 and must carry.
Carry is added the same way using xor with the number per digit.*/
function Adc8( n1, n2 )
{
//The first tow lines is "XOR" as "s1" (SUM total), and "AND" as "s2" (carries).
s1 = Xor( n1, n2 ); s2 = n1 & n2;
//These lines add carry per digit using xor, and shift to "s1".
o1 = Xor( s1, c ) & 1; c = ( ( s2 & 1 ) | ( s1 & c ) ) << 1;
o2 = Xor( s1, c ) & 2; c = ( ( s2 & 2 ) | ( s1 & c ) ) << 1;
o3 = Xor( s1, c ) & 4; c = ( ( s2 & 4 ) | ( s1 & c ) ) << 1;
o4 = Xor( s1, c ) & 8; c = ( ( s2 & 8 ) | ( s1 & c ) ) << 1;
o5 = Xor( s1, c ) & 16; c = ( ( s2 & 16 ) | ( s1 & c ) ) << 1;
o6 = Xor( s1, c ) & 32; c = ( ( s2 & 32 ) | ( s1 & c ) ) << 1;
o7 = Xor( s1, c ) & 64; c = ( ( s2 & 64 ) | ( s1 & c ) ) << 1;
o8 = Xor( s1, c ) & 128; c = ( ( s2 & 128 ) | ( s1 & c ) ) << 1;
//We move carry back Allowing this operation to be called recursively.
c >>= 8;
//We put the result together.
return( o1 | o2 | o3 | o4 | o5 | o6 | o7 | o8 );
}
//We set carry 0 to do a regular 8 bit add.
function Add8( n1, n2 ) { c = 0; return( Adc( n1, n2 ) ); }
//We set carry 0 to do a regular 8 bit add. Then do another add with the continued carry.
function Add16( n1, n2 ) { c = 0; return( Adc8( n1, n2 ) | ( Adc8( n1 >> 8, n2 >> 8 ) << 8 ) ); }
//Do a full 32 bit add.
function Add( n1, n2 ) { c = 0; return( Add16( n1, n2 ) | ( Adc8( n1 >> 16, n2 >> 16 ) << 16 ) | ( Adc8( n1 >> 24, n2 >> 24 ) << 24 ) ); }
//Do a full 32 bit subtract. To subtract we invert input B to our add. We also set carry 1 as it is inverted to act as barrow.
function Sub( n1, n2 ) { c = 1; n2 = ~n2; return( Add16( n1, n2 ) | ( Adc8( n1 >> 16, n2 >> 16 ) << 16 ) | ( Adc8( n1 >> 24, n2 >> 24 ) << 24 ) ); }
//15 bit multiply. Multiply using multiples of 2 using left shift.
function Mul15( n1, n2 )
{
o = ( ( n2 >> 0 ) & 1 ) && ( n1 << 0 );
o = Add( o, ( ( n2 >> 1 ) & 1 ) && ( n1 << 1 ) );
o = Add( o, ( ( n2 >> 2 ) & 1 ) && ( n1 << 2 ) );
o = Add( o, ( ( n2 >> 3 ) & 1 ) && ( n1 << 3 ) );
o = Add( o, ( ( n2 >> 4 ) & 1 ) && ( n1 << 4 ) );
o = Add( o, ( ( n2 >> 5 ) & 1 ) && ( n1 << 5 ) );
o = Add( o, ( ( n2 >> 6 ) & 1 ) && ( n1 << 6 ) );
o = Add( o, ( ( n2 >> 7 ) & 1 ) && ( n1 << 7 ) );
o = Add( o, ( ( n2 >> 8 ) & 1 ) && ( n1 << 8 ) );
o = Add( o, ( ( n2 >> 9 ) & 1 ) && ( n1 << 9 ) );
o = Add( o, ( ( n2 >> 10 ) & 1 ) && ( n1 << 10 ) );
o = Add( o, ( ( n2 >> 11 ) & 1 ) && ( n1 << 11 ) );
o = Add( o, ( ( n2 >> 12 ) & 1 ) && ( n1 << 12 ) );
o = Add( o, ( ( n2 >> 13 ) & 1 ) && ( n1 << 13 ) );
o = Add( o, ( ( n2 >> 14 ) & 1 ) &&( n1 << 14 ) );
return( o );
}
//Do a 15 bit divide. Subtract using multiple of two using left shift.
//Output is each subtractable output from carry acting as barrow.
//Also "n1" can be returned as division remainder.
function Div15( n1, n2 )
{
t = Sub( n1, n2 << 14 ); n1 = c && t || n1; o = c << 14;
t = Sub( n1, n2 << 13 ); n1 = c && t || n1; o |= c << 13;
t = Sub( n1, n2 << 12 ); n1 = c && t || n1; o |= c << 12;
t = Sub( n1, n2 << 11 ); n1 = c && t || n1; o |= c << 11;
t = Sub( n1, n2 << 10 ); n1 = c && t || n1; o |= c << 10;
t = Sub( n1, n2 << 9 ); n1 = c && t || n1; o |= c << 9;
t = Sub( n1, n2 << 8 ); n1 = c && t || n1; o |= c << 8;
t = Sub( n1, n2 << 7 ); n1 = c && t || n1; o |= c << 7;
t = Sub( n1, n2 << 6 ); n1 = c && t || n1; o |= c << 6;
t = Sub( n1, n2 << 5 ); n1 = c && t || n1; o |= c << 5;
t = Sub( n1, n2 << 4 ); n1 = c && t || n1; o |= c << 4;
t = Sub( n1, n2 << 3 ); n1 = c && t || n1; o |= c << 3;
t = Sub( n1, n2 << 2 ); n1 = c && t || n1; o |= c << 2;
t = Sub( n1, n2 << 1 ); n1 = c && t || n1; o |= c << 1;
t = Sub( n1, n2 << 0 ); n1 = c && t || n1; o |= c << 0;
return( o );
}
//Compare if two values are less than.
function lessThan( n1, n2 ) { Sub( n1, n2 ); return( !c ); }
//Compare if two values are grater than.
function graterThan( n1, n2 ) { Sub( n1, n2 ); return( c ); }
//Compare if two values are the same.
function equalTo( n1, n2 ) { Sub( 0, Sub( n1, n2 ) ); return( c ); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment