50 Years of Prolog and Beyond
arxiv.org
arxiv.org
Not wanting to take away from that Festschrift and the wealth of authors covering generations of Prolog programming, but realistically, Prolog Commons contributed very little, was almost entirely ignored, had its last update almost ten years ago, can't be contributed towards, and those things it did add feel distinctly un-Prolog-ish and procedural, such as get_ and put_ primitives for maps.
Also, ISO/IEC 13211-1:1995/Cor.2:2012(E) feels kindof rushed (eg specifying false/0 thereby trivially breaking existing Prolog code such as ILP packages for no reason, insufficient description for subsumes_term/2, introducing call/N and the concept of closures without sufficient precedent, etc.)
Yes, SWI will probably complain of an attempt to redefine a static procedure if false/0 is redefined. It's actually defined in the system module (or a module imported therein) so I guess that an error will be raised even if the negative examples are declared in a module.
I wonder then, how does Aleph work around that? Or does it?
This actually points to a slight inconsistency between theory and practice in ILP, at least when the target language is Prolog. As a reminder, this is the standard setting for ILP: given background knowledge B and positive and negative examples E⁺, E⁻, find a hypothesis H such that H ∧ B ⊨ E⁺ and ∀e⁻ ∈ E⁻: H ∧ B ⊭ e⁻.
That makes a lot of sense intuitively: we want a correct hypothesis that entails all the positive and none of the negative examples, with respect to background knowledge. But it leaves open the question of what, exactly, are the negative examples. Especially when the target language is Prolog where we're operating under a closed-world assumption, where we only define the things we know to be true, it gets a bit tricky to explain how some examples (be they clauses or atoms) are "negative" when there's no real way to represent negation (only negation-as-failure) in a logic program (i.e. a set of definite clauses- no Horn goals in there!).
For me the ideal answer is that positive examples are atoms in the Herbrand base of a target predicate (the "top" predicate in H) that are assigned the value "true" by an interpretation ι, where H is a "name" for ι. So, negative examples must be the same as positive examples: atoms, assigned the value "false" by ι. So they should be written as atoms, without negation. That simplifies notation, allows learning a "contra-theory" (by switching the signs of E⁺ and E⁻) and avoids the need for syntactic conventions like "false:- <body>". But, my intuition is coloured from my experience with Meta-Interpretive Learning systems where examples are always atoms and learning is a proof by SLD-refutation of examples, both positive and negative (as opposed to inverse resolution which is... more complicated; let's just say that MIL makes a lot more sense to me than IR).
Digression, eh!
1: http://www.let.rug.nl/bos/lpn//lpnpage.php?pagetype=html&pag...
First, this is the main M:tG game language interpreter (the "MGL" interpreter; "MGL" is my own terminology, since the langauge on M:tG cards doesn't have an official name):
https://github.com/stassa/Gleemin/blob/master/mgl_interprete...
The first two-thirds of the source in the linked file is a grammar of a subset of the M:tG game language as a set of production rules in DCG form. That's already a parser for that subset of the M:tG language, right there in the DCG rules themselves (DCGs are just syntactic sugar for ordinary Prolog clauses so a grammar in DCG form is a Prolog program that can be executed as any Prolog program). The rest of the file implements rule engine functions some of which are called by the grammar, while others act as an interface with the rest of the rules engine. Probably. I don't remember what everything does...
The next file is a DCG for M:tG mana costs:
https://github.com/stassa/Gleemin/blob/master/mana_grammar.p...
This grammar is referenced from the previous source file where the "mana" nonterminal appears. So that's just an example of how you can modularise your code to avoid having all the rules in one big endless file. On the other hand, nothing stops you from making a big ball of mess by interleaving your grammar with the rest of your code.
Like all Prolog programs, DCG grammars can be "run backwards" so that a grammar that acts as a recogniser when given an input string, can act as a generator when given no input (Prolog doesn't have clear input and outputs, just variables to be instantiated as the program runs). So with my M:tG grammar above I could generate text for new M:tG cards. To facilitate this I set up the "MGL parser interface" below:
https://github.com/stassa/Gleemin/blob/master/mgl_parser_int...
The first defined predicate in there, identify_MGL/0 is used to identify the type of an M:tG language expression (given or generated), such as "activated ability", "triggered ability", "static ability" etc. So that's one example how to use a DCG for semantic analysis of a bit of text. As a for instance, you could use my identify_MGL/0 to search for abilities of a certain type (alongside a keyword search) which most search engines don't really let you do. My "parser interface" used it to generate abilities of a given type.
Anyway, that's an example of DCGs "in the wild" (though from someone who had no clue what she was doing when she wrote it). I hope it's instructive and I didn't just toot my own horn for no reason!
I can't remember details, although last time I mentioned this here, I remember some guy replied to my comment and confirmed with details, so ... Angola Search is your friend :)
[0] https://www.cs.nmsu.edu/ALP/2011/03/natural-language-process...
“Most people probably have used SICStus Prolog without knowing it,” says Mats Carlsson, its lead developer. “One of our customers runs a flight booking system on SICStus which handles nearly a third of all airline tickets in the world.”
https://www.sics.se/projects/sicstus-prolog-leading-prolog-t...
Quite substantial (for Prolog) applications in Prolog are commonly developed in the field of Inductive Logic Programming research most of which studies algorithms that learn Prolog programs from input-output examples. Here's a nice, recent overview:
Inductive logic programming at 30
https://link.springer.com/article/10.1007%2Fs10994-021-06089...
Historically, you would have found a lot more Prolog (more precisely, resolution-based logic programming) used in commercial software mostly around the 1980's and 1990's. Hard to believe today, but there was a time when Prolog was hyped about as much as deep learning today, as the hot new stuff in AI. The hype cycle started with the initiation of the Fifth Generation Computer project in Japan, in 1982:
The Fifth Generation Computer Systems (FGCS) was an initiative by Japan's Ministry of International Trade and Industry (MITI), begun in 1982, to create computers using massively parallel computing and logic programming. It was to be the result of a government/industry research project in Japan during the 1980s. It aimed to create an "epoch-making computer" with supercomputer-like performance and to provide a platform for future developments in artificial intelligence.
https://en.wikipedia.org/wiki/Fifth_generation_computer
The hype cycle picked up steam with a book, published in the US in 1983, written by Pamela McCorduck and Ed Feigenbaum (Turing Award recipient and the "father of expert systems") titled: The Fifth Generation: Artificial Intelligence and Japan's Computer Challenge to the World.
The book awakened a huge FOMO in Western industry and political figures and for a while everybody was trying to follow on the Japanese' footsteps. Unfortunately their project failed and probably took logic programming and Prolog with it. However, for a while at least, you'd have found a whole bunch of quite substantial Prolog projects being created in industry... and, knowing industry, it's very likely that quite a few of them are still putt-putt-putting quitely in some forgotten back-end in a bank, detecting fraud, or in a shipping agency planning routes etc. People invested lots of money on such systems and they worked reasonably well (like all software, that is) so nobody would have happily thrown them out when the AI winter of the '90s hit for good.
I wasn't around back then to see all this happening first hand so I'm guesstimating about the continued existence of Prolog systems. Anyway, when I first got interested in Prolog, when I was doing my degree back in 2011, I read the McCorduck and Feigenbaum book and I was struck by how confident its authors were that the Fifth Generation Computer project was poised to do to the computer industry what the Japanese had already done to the home appliances and automotive industry. I also remember reading a Prolog textbook from the 1990's (I forget the title- it was not one of the better known ones) whose introduction chapter opened with a certain exuberance about the usefuleness of knowning Prolog saying that it is now the language to know and that it's poised to take over the world, kind of thing.
There's perhaps a lesson to be learned from all this, for people studying more modern approaches to AI.
Creating many cool things: graphical chess problem solver, watching the search process on a VGA screen on a 386 CPU, expert systems, logic analyzers.
But it's been a long time. C became my next new love (Turbo C first), and many years later a plethora of OO languages.
But Prolog still holds a special place. Too bad it really didn't catch on in my professional career.
AFAIK nowadays the compiler is still being developed as Visual Prolog.
Happy birthday Prolog.
However, Prolog is also a valid general purpose programming language, so you can actually implement forward chaining rule systems in them (see for example CHR[1] and Heiseneye [2]). CLIPS is not a general purpose programming language.
[1] https://www.swi-prolog.org/man/chr.html [2] https://github.com/IDLabResearch/Heiseneye