Elektrine lite

← Feed

@dpiponi@mathstodon.xyz

2026-04-09 17:26 UTC

I'm enjoying that after some hacking I can now run BBC Micro ROMs in the terminal. Here I recreate a piece of code that someone demonstrated to me at high school back in the 80s and which probably changed my thinking about computers and mathematics forever. He showed me that in Prolog we could define addition and multiplication using 4 simple axioms. And more importantly, this is executable logic. And the thing that really blew my mind: unmodified this code can also divide. I guess it was also my first exposure to unification. BTW MicroPROLOG fits in a 16K ROM and easily ran in 32K of RAM. (BINE = BINE Is Not an Emulator, of course. It doesn't emulate the BBC Micro hardware, it just executes 6502 instructions like bytecode.) PS The attached image is 70K in size. #bbcmicro #retro

Replies (3)

  • @DrHyde@fosstodon.org 2026-04-09 22:36

    @dpiponi #Prolog always did my head in. I could never write it, but with a bit of concentration it's surprisingly readable. Have you seen the version of tar(1) that someone wrote in it? https://github.com/SuperDisk/tar.pl/blob/master/tar.pl

    Open ##1603995

  • @cliffle@hachyderm.io 2026-04-10 00:11

    @dpiponi what an odd Prolog dialect. Have you seen that s-expr notation elsewhere (among Prologs I mean)?

    Open ##1603996

  • @theohonohan@graphics.social 2026-04-10 00:44

    @dpiponi Most(?) people are only introduced to the formal "Euclid's division lemma" framing of division (with a unique quotient and remainder) at third level. But it's possible to express that in Prolog as well. quotRem(N, D, Q, R) :- leq(D, N), leq(Q, N), mul(D, Q, P), add(P, R, N), lt(R, D). The symmetry of D and Q here feels like it has something to do with the 'partitive' vs 'quotative' interpretations of division, but maybe that's meaningless nonsense.

    Open ##1604009