Teaching Computers

Computers are very powerful, but they are really dumb. Because they don't know anything.

There are certain fundamental rules in Mathematics, Physics and Chemistry which computers are completely unaware of. Computers come loaded with basically nothing.

The Web

We can search the web for "what is the equation relating acceleration to velocity and time?" and we get lots of shitty websites filled with banner ads. I have tried many times to search for basic Mathematics and Physics formulas and am constantly shocked how bad some of this stuff is.

  • Wikipedia aims to be "extensive" or "exhaustive" meaning a given Wikipedia page on a topic can be very difficult to understand.
  • Everything else is more or less crap clickbait.

It's really not good enough, and I shudder to think that students encounter on the web when trying to learn a topic in school.

Mathematics

Everything is Mathematics, but:

Mathematical notation is hard on computers

Computers are really good at ASCII text (or utf8) - they are not good at all at Mathematical notation. Mathematical notation is very difficult to enter into a computer, and computers are pretty bad at reading mathematical notation. For example, check out MathML. If that disgusts you (as it should) a marginally better but still terrible alternative is LaTeX. An interesting alternative is Math ASCII Notation. There is also asciimath which is supported by MathJAX - a JS math rendering library.

To quote Mathematical notation on Wikipedia:

General typesetting systems are generally not well-suited for mathematical
notation. One of the reasons is that, in mathematical notation, the symbols
are often arranged in two dimensional figures.

So we don't even have a good way of expressing Mathematics on computer systems in 2022. Mathematics evolved with paper and pen. To write a program that allows you to express and manipulate mathematical notation is a gigantic task in of itself.

Mathematical notation has a lot of shorthands

Mathematical notation evolved from a desire to make it concise. As such there are many rules you must memorize in order to "parse" mathematical notation:

y = 7x + 2

If you have a value for x and you want to know y you first have to multiply x by 7. Why? Where is the multiplication operator? Because putting two symbols right next to each other means "multiply". You have to do this before adding the 2, because 7(x + 2) means something different from 7x + 2.

The hard sciences require deep mathematical knowledge

In order to get anywhere in Physics you must be adept at mathematics. This means you must learn the intricate rules of mathematics, and in particular how to parse and execute mathematical notation in your head.

Polish notation is cool but it looks nothing like mathematical notation

The Polish Notation is awesome because it unambigously describes a mathematical expression. The biggest problem with it is how different it is from regular mathematical notation. Because:

(== y (+ (* 7 x) 2))

Looks a lot different to:

y = 7x + 2

Lets go Polish

For the sake of argument lets just assume we all agree on Polish notation for mathematical expressions for computers. The problem is that kids will learn regular mathematical notation in school and be completely confused by the difference.

Once we teach computers how to represent mathematical notation in a way that isn't bat-shit insane, we then need to start teaching computers the rules of Algebra. From an example ripped from that page:

Find a number x such that 3x + 1 = 10

We should be able to enter that into our computer:

(== 10 (+ 1 (* 3 x)))

And the computer should be able to instantly transform that into:

(== x (/ (- 10 1) 3))

And then obviously solve it too:

(== x 3)

But think for a second about what the computer must do to make this transformation:

from: (== 10 (+ 1 (* 3 x)))
to:   (== x (/ (- 10 1) 3))

It is some kind of weird inside-out-but-not-quite transformation. It roughly translates into "do the same thing to both sides", but it's not clear how the computer should start "doing things to both sides". I believe the algorythim is roughly: "descend recursively into the expression until you find the variable you want to solve for, then on the way back out do the same thing to both sides".

Even something as basic as this is surprisingly complex for a computer to do. Or, I should say is surprisingly complex for a programmer to implement because a) computers don't know how to do anything, and b) we don't seem to even have this basic functionality implemented in libraries.

Like, why don't we have:

(rearrange-for x (== 10 (+ 1 (* 3 x))))

just built right in to our programming languages? In Lisp it would be a macro I guess...

More steps

Ok, so imagine we a) have a sane mathematical notation that doesn't require a apprentiship in typesetting to input and b) we have a computer language that has been taught Algebra and Calculus. Now we can start teaching this computer about the world. We can teach it all the fundamental Physical relationships and forumala.

I am imagining something like boot-to-lisp - you switch the computer on and within microseconds you are in a Lisp prompt, and that Lisp knows everything there is to know about Mathematics and Physics. Oh, it has to know about units...

Units

Units are pretty interesting. Mass (grams, kilograms) is different from velocity. Velocity is made up of distance and time units. Computers just store and manipulate bit-patterns. Computers are only really capable of boolean mathematics. They "fake" integer mathematics with clever tricks, and have even more clever tricks for faking real numbers. But those tricks are "baked into" the computer so they can almost be considered real.

We can trick computers into understanding units by using another trick called types. But types are at a level higher than the computer hardware. Types are the domain of compilers and interpreters. Types stop you from accidentially trying to do an integer operation on a floating point set of bits. Remember that computers just see bit patterns so they are easily fooled into this kind of mistake.

Lisp system frequently are untyped so it will be hard to use a nonexistent type system for expressing units.

Physical equations...

Take the formula relating accelleration to force and mass:

F = Ma

There are three units here: Force, Mass and Acceleration. If you know the specific values of two of the quantities you can easily know the third. A common way to look at a function is like a machine: you stick two numbers into the machine and it spits out a third number.

But another way of looking at this is as a mapping between values. The formula describes a geometric "shape". The quantities of the units are any possible real number on infinite number lines. Or to say it another way, each of the symbols represents any possible real number. But the formula itself restricts the possible numbers. If the force is 10N and the mass is 1Kg, the acceleration can only be one of all possible values for acceleration. If the force is 10N and the mass and acceleration are unknown, these two unknown values are bound to each other.

This restriction defines a geometric plane (because there are 3 variables, it is a 3 dimensional shape). The shape is the function, and the function is the shape. Mathematics lets us define any shapes we want but physics tells us the shape of the real world. For example:

F = Ma^2

Or "Force equals mass times the square of acceleration". This is a completely valid mathematical expression. But when we make observations of reality we discover that it is wrong. Physics is the process of performing experiments to gather data, and then using that data to figure out what the real relationships are between the quantities.

Once Newton discovered the "F = Ma" relationship, that relationship was applied to the motion of planets. However it was shown that the motion of the planets didn't quite fit exactly. Physicists gathered data about the motion of the planets and discovered that their motion did not fit that function. Einstein discovered a better forumla that described planetary motion - a slightly different mapping between values. A slightly different gemoetric shape.