Extending C with Prolog (1994)
72 points by Antibabelic 4 days ago | 26 comments

sprior 2 days ago
I started using Prolog in my self written home automation system over 20 years ago. At first I was using CORBA and I linked ACE/Tao into SWI-Prolog so that Prolog could catch and send CORBA messages. That worked for years but was too annoying to add new message types since a wrapper had to be written for each, plus threading had to be coordinated between C++ and Prolog. Eventually I ditched the CORBA stuff and switched to MQTT, but instead of binding the C++ and Prolog together I found and extended MQTT support for Prolog directly, actually I've mostly replaced the C++ parts of my HA system with Java. The Prolog is pretty nice the way I can now specify predicates for MQTT topic paths, and I use shared topics for scalability. Now all of this is running deployed in k3s.
reply
justinhj 2 days ago
This sounds really cool and I am glad that Prolog has outlived CORBA
reply
sprior 24 hours ago
Yeah, CORBA really needed to go away.
reply
pjmlp 10 hours ago
Except that CORBA spirit thrives in 2026 still, gRPC, D-BUS, COM/DCOM, WinRT, XPC, Android IPC, SDKs over REST/GraphQL, MCP,...
reply
vintagedave 4 days ago
> We recently installed Gateway multi-media kits on our PCs, but found the installation less than trivial because of conflicts in our interrupt (IRQ) channels. A simple expert system could have helped to resolve those IRQ conflicts. ... The sample program is set up to allow installation of two different devices, a 'Sound Blaster' and a 'Mitsumi CD- ROM'.

This was a real blast from the past. I wonder why more systems today don't have this kind of logic solving built in. Possibly, too many complex behaviours that are not cleanly quantified.

reply
bitwize 17 hours ago
Pepperidge Farm remembers when reasoning systems could actually reason, instead of backing out the part of the context they're told is erroneous, appending "Wait..." and then continuing to predict tokens as before.
reply
krzyk 2 days ago
Is this the time of year when we try to force redditors to stay away by posting about Prolog?

I see three stories already.

reply
Davidbrcz 2 days ago
Refreshing stories between all the AI ones (and crypto/web3 before that)
reply
linguae 2 days ago
Ironically, once upon a time Prolog and logic programming in general were part of the cutting-edge of AI. There's quite a fascinating history of Japan's fifth-generation computing efforts in the 1980s when Japan focused on logic programming and massively parallel computing. My former manager, who is from Japan, earned his PhD in the 1990s in a topic related to constraint logic programming.
reply
copx 2 days ago
I remember when so-called "expert systems" written in Prolog or LISP were supposed to replace doctors. Then came the (first) AI winter after people realized how unrealistic that was.

Nowadays LLMs are supposed to replace doctors.. and that makes even less sense given that LLMs are error-prone by design. They will hallucinate, you cannot fix that because of their probabilistic nature, yet all the money in the world is thrown at people who preach LLMs will eventually be able to do every human job.

The second AI winter cannot come soon enough.

reply
anthk 14 hours ago
The LLM collapse will yield the classical AI reborn with environments like Common Lisp.
reply
fc417fc802 2 days ago
Even now NEC makes some cool massively parallel chips and accelerators that I wish were more mainstream because they look like they'd be fun to play with.
reply
thesz 2 days ago
You said AI: https://github.com/stassa/louise

  Louise (Patsantzis & Muggleton 2021) is a machine learning system that learns Prolog programs.

  Louise is a Meta-Interpretive Learning (MIL) system. MIL (Muggleton et al. 2014), (Muggleton et al. 2015), is a new setting for Inductive Logic Programming (ILP) (Muggleton, 1991). ILP is a form of weakly-supervised machine learning of logic programs from examples of program behaviour (meaning examples of the inputs and outputs of the programs to be learned). Unlike conventional, statistical machine learning algorithms, ILP approaches do not need to see examples of programs to learn new programs and instead rely on background knowledge, a library of pre-existing logic programs that they reuse to compose new programs.
This is what was done by Douglas Lenat from late 1970-s on [1]. He did his work using Lisp, this thing does something close using Prolog.

[1] https://en.wikipedia.org/wiki/Eurisko

reply
discarded1023 20 hours ago
If we're going down that path: Ehud Shapiro got there back in 1984 [1]. His PhD thesis is excellent and shows what logic programming could do (/could have been).

He viewed the task of learning predicates (programs/relations) as a debugging task. The magic is in a refinement operator that enumerates new programs. The diagnostic part was wildly insightful -- he showed how to operationalise Popper's notion of falsification. There are plenty of more modern accounts of that aspect but sadly the learning part was broadly neglected.

There are more recent probabilistic accounts of this approach to learning from the 1990s.

... and if you want to go all the way back you can dig up Gordon Plotkin's PhD thesis on antiunification from the early 1970s.

[1] https://en.wikipedia.org/wiki/Algorithmic_program_debugging

reply
dgxyz 2 days ago
Well at least it's not clojure or scheme.
reply
rramadass 2 days ago
We need more.

In case you weren't aware, people are using Prolog with LLMs;

https://news.ycombinator.com/item?id=42039527

https://news.ycombinator.com/item?id=45712934

reply
Antibabelic 2 days ago
What's the third one? I see this one and the Lambda Prolog one.
reply
ofrzeta 2 days ago
Related: Using Prolog in Windows NT Network Configuration (1996) https://news.ycombinator.com/item?id=36821871
reply
juancn 9 hours ago
Windows NT used to have the network configuration run in prolog:

https://web.archive.org/web/20030218034509/http://www.resear...

reply
mcswell 2 days ago
FWIW (not much), around the time of that article, I reversed this: I used Arity Prolog for a morphological parsing program, with C calls for the bit fiddling (because I needed 64 bits, and the Prolog I was using only handled 16 bit strings).
reply
HexDecOctBin 2 days ago
I often wonder what a Prolog implemented as an Objective-C like extension to C would look like. Since WAM has proper stack and heap IIRC, it might be possible to plug that in through some region-based memory management on C side. Is there some prior art like this?
reply
NetMageSCW 23 hours ago
I ported from Pascal to C a Lisp interpreter system that had an embedded Prolog in it (that used Lisp syntax) (and wrote a new memory subsystem) in my spare time in College. Later I helped a grad student a little bit with their implementation of a Warren machine (runtime for a Prolog compiler) for it. That’s the only embedded Prolog I’m aware of.
reply
anthk 14 hours ago
Check http://t3x.org, it has some book on logic for Scheme which implements a Prolog under it wich very few files and lines per file.
reply
crustycoder 2 days ago
Things have moved on since 1994, not only can you still embed it in C and a load of other languages, you can even run it directly in your browser as there's a WASM port.

https://www.swi-prolog.org/pldoc/man?section=wasm-version

reply
buescher 2 days ago
There's another updated version of that prolog here along with some links, including an archived article from Microsoft Research on how it was (once upon a time) used in Windows NT network configuration: https://github.com/opless/small-prolog
reply
umairnadeem123 2 days ago
[dead]
reply
dirtytoken7 2 days ago
[flagged]
reply
mcswell 2 days ago
You (we) may be able to extend that 30 years, one year for each calendar year. Because I'm told LLMs don't really do chained reasoning.

Disclaimer: I'm no expert on LLMs.

reply