Lambda Calculus in 400 Bytes
justine.lol
justine.lol
Technical work like this borders on art.
It is inspiring in the traditional sense of the word, not in the Ted Talks sense of the word, as in it inspires me to blow the dust off old ideas I've had and get working on them and to set the quality bar high for myself.
> See Also
> https://tromp.github.io/cl/Binary_lambda_calculus.html
Anyway I think abstracting away variables+lexer via sed and indexing is hot!
My mind is so rusty, but I can imagine constructing an elegant & expressive language using "category theory + lambda calculus" and oh my god... instead of computing a single result using binary encoding we can compute all results in parallel (array-based) by using a lossless compressor (similar to data-fusion).
A Finite State Entropy Encoder (FSE) with a multi-symbol alphabet (>2) can be used for this purpose. FSE is a very interesting development in ANS encoding (Asymmetric numeral systems). I need to put all these pieces together + self-modifying code. Because I don't have the feeling that this is a dumb idea at all.
Maybe infecting any device like the skynet code isn't that far of a stretch away? Disregarding any malicious intent, this is simply inspiring. Maybe I'm just too much of a nerd though to enjoy this a bit too much.. idk.
https://en.wikipedia.org/wiki/To_Mock_a_Mockingbird
This is a very cool article on lambda calculus that relates to it:
[] - https://www.microsoft.com/en-us/research/publication/the-imp...
During my semester we only went through a few of its chapters but it was very enjoyable in my opinion.
Regarding combinators the famous intro is the latter half of Raymond Smullyan's To Mock a Mockingbird.
It works, but it's very fiddly. My favourite way of solving the problem of names in the lambda calculus is to use Pitts-Gabbay nominal syntax. Wikipedia has a weak article on them, which I mean someday to fix up: https://en.wikipedia.org/wiki/Nominal_terms_(computer_scienc...
https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.36...
And then I just discovered that for some unknown reason, this person has already blocked me on Twitter (I can recall exactly zero interactions with them, but I must have followed them already due to things like APE).
Not sure if she sees this but I'm sorry about whatever I said that I don't recall? Twitter username is same as this one here. Would love to see you in my feed again, will promise to keep big mouth shut
[1] https://tromp.github.io/ [2] https://www.youtube.com/playlist?list=PLi8_XqluS5xc7GL-bgVrx...
Unless I've missed something.
You should also check out the rest of her work! It's all amazing, SectorLISP, Blinkenlights and APE (Actually Portable Executable) are the really well known ones, but many of the other projects are things many programmers would have as the centerpiece of their portfolio.
Reduction (in particular "beta-reduction") is essentially 'calling a function with an argument' (just defined in a precise, mathematically-rigorous way). Since lambda calculus only has functions (AKA "lambdas"), "reducing an expression" is another way of saying "running/executing a program".
"Expansion" would be going the other way; e.g. introducing an abstraction layer which, when reduced/executed, would result in the original expression.
for cc in cc gcc clang
do echo "## $cc"
$cc -no-pie -static -nostdlib -o blc -Wl,--oformat=binary blc.S || exit 1
{ printf 0010; printf 0101; } | ./blc; echo
done
Any suggestions? wget https://justine.lol/lambda/blc.S
wget https://justine.lol/lambda/flat.lds
cc -c -o blc.o blc.S
ld.bfd -o blc blc.o -T flat.lds
Just tested myself on Linux with both GCC and Clang. Whatever you do, do not use any linker except big deal.What could possibly go wrong?
I, for one, would not be comfortable having content distributed as a blob that runs as a virtual machine that builds the software that decodes the content. Justine has made this practical. I can see the appeal. I just worry that we're trading in our jpgs for exes in a sandbox, and I'm not sure its worth the risk.
If you want something that can provide that level of assurance then I'd suggest looking into Blinkenlights, which can be retooled to abstract a level of memory obfuscation and processor insulation that effectively neutralizes such threats, much stronger than alternatives like docker/gvisor/vms/etc., but at a cost of performance.
I.e. it does not suffice to verify that the header is really a lambda calculus evaluator.