Ben Lynn, a Stanford-affiliated programmer, writes on functional programming, compilers, lambda calculus, geometric algebra and security, including a self-hosting Haskell compiler.
Commenters praise his series on building a self-hosting Haskell compiler, his IOCCC entry, and his lambda calculus pages as helpful for learning language theory.
It's a good question, if we consider that it's been unanswered on the computer science stack exchange for four years. https://cs.stackexchange.com/questions/83533/practical-usage-of-the-%CE%BB-calculus-self-interpreter-and-the-self-reducer
Basically, it does beta normal form reduction. In these kinds of situations, I sometimes feel like it's just as valuable to know how to get the darn thing to run, and then the rest explains itself. So for the purposes of this explanation, I'll share a Hello World example for this interpreter, that should hopefully get you going. This won't cover beta reduction or any of that jazz. Just the simplest possible usage that you can type into the web page at https://crypto.stanford.edu/~blynn/lambda/ and see something happen.
(\a.(\b.a(b b))(\b.a(b b)))(\a.\b.b(\c.c)(\c.\d.a c(a d))(\c.\d.a(c d)))(\a.\b.\c.c(\d.\e.\f.\g.e d))
# a.k.a. Y(λab.b(λc.c)(λcd.ac(ad))(λcd.a(cd)))(λabc.c(λdefg.ed))
# a.k.a. [[Y λλ [[[0 λ 0] λλ [[3 1] [3 0]]] λλ [3 [1 0]]]] λλλ [0 λλλλ [2 3]]]
It should spit out the identity function:
λd.d
Why did this happen? It's because Y(λab.b(λc.c)(λcd.ac(ad))(λcd.a(cd))) is the reducer a.k.a. E and λabc.c(λdefg.ed) is the argument. What is λabc.c(λdefg.ed)? It's an encoded version of the identity function λd.d. So in other words, all it did was output exactly what was inputted. Except the input had to be encoded. Why is it encoded? Normally in LISP, if we wanted to pass a program to a self-interpreter, we've wrap…
I think there's a conflict between the essence of array languages (building a DAG of monadic (in the FP sense) operations and letting arrays flow through it) and the one dimensionality of a stream of symbols in a text file. Ben Lynn [https://crypto.stanford.edu/~blynn/c/apl.html] puts it best:
"Worse still, tacit hooks, forks, and ranks obscures the beautiful category theory connections: hooks and forks are function composition and application within the Reader monad, while adjusting the rank of a function corresponds to applying functors."
Hooks are a structured approach to this problem, while stacks are an unstructured one. And there will always be tension between the two for as long as the current textual model of programming is used (or maybe no matter what representation we use). How obscure are we willing to get in order to get closer to the beautiful DAG we have in our head?
I of course don't have a good answer to that, and I think the dominant paradigm of array languages has set to be discovered. APL gets us close, but we clearly agree that there's more work yet to be done.
Looking at your bytecode design, I was reminded of this old paper about building APL hardware: http://www.softwarepreservation.org/projects/apl/Papers/197002_An%20APL%20Machine-Abrams.pdf . Not sure how relavent that is, but maybe it'll be the inspiration of a beautiful VM architecture!
> unit quaternions also don’t form a vector space
Unit quaternions are the lie group. If you want something you can add willy-nilly, you want the lie algebra of all quaternions, which represent rotational velocities, just as axis-angle represents rotational velocities.
Comparing unit quaternions to axis-angle is a bit of a category error - it would be more appropriate to compare unit quaternions to rotation matrices, and all quaternions to axis-angle.
> One advantage of using quaternions is how easy the exponential map is to compute—if you don’t need a rotation matrix, it’s a good option.
You rarely need a rotation matrix at all when using quaternions. As mentioned in the article, you can compute rotations using `pqp^-1`.
I think the easiest way to understand quaternions is just to read about geometric algebra. It took hundreds of years to invent quaternions, but once you understand geometric algebra (which is shockingly simple), you can invent quaternions in just a few minutes. I found this article to be a good intro several years ago: https://crypto.stanford.edu/~blynn/haskell/ga.html
The way this text does the geometric product is trying to be intuitive by immediately giving a "physical" interpretation as the sum of the inner and outer products. However the physical interpretations breaks down when trying to multiply three of these together.
I think Ben Lynn's approach is actually better: https://crypto.stanford.edu/~blynn/haskell/ga.html (Part 1)
It starts off more abstract, defining the geometric product simply as string concatenation (as in "free monoid" if you're familiar with that term, which you would if you have intermediate Haskell knowledge) plus a very natural constraint. From this natural constraint one can then deduce the sum-based interpretation that the OP gives.
The natural constraint is then further generalised and justified in more detail in Part 3: https://crypto.stanford.edu/~blynn/haskell/cga.html
I would think Clojure vs. Java would be used given immutability. I like both Haskell and Racket for math, especially this article on geometric algebra with Haskell:
https://crypto.stanford.edu/~blynn/haskell/ga.html
I am personally learning Shen[1] because Lisp, optional typing (great type system), and the formal work done within it, and for it in proving, verification and other related endeavors. It seems to tick the Haskell, Lisp, Prolog and logic boxes for me. Its portability is great[2], however, it is still young and building libraries. I am thinking on trying to mimic the DL work done by Dragan Djuric[3] for Clojure in Shen. We'll see how that goes...
[1] http://www.shenlanguage.org/
[2] https://shen-language.github.io/
[3] https://dragan.rocks/
> "What are recent developments in linear algebra?"
Have you heard of geometric algebra? It takes a while to wrap your head around, but unifies a lot of mathematics in a very elegant way. For instance, you can view Euclidean geometry as a special case, and concepts like quaternions and rotations can be explained in a very natural way. There are a few good resources below if you're interested.
[0]: http://geometry.mrao.cam.ac.uk/2020/06/euclidean-geometry-and-geometric-algebra/
[1]: https://www.youtube.com/watch?v=ipqKvNHnABs
[2]: https://alexkritchevsky.com/2020/10/15/ea-operations.html
[3]: https://www.youtube.com/playlist?list=PLpzmRsG7u_gqaTo_vEseQ7U8KFvtiJY4K
[4]: https://crypto.stanford.edu/~blynn/haskell/ga.html
[5]: https://bivector.net/