In the beginning…
Back in 2012 when I decided to learn Prolog and despite having a pretty good grasp of English and a reasonably good set of maths skills regarding “computer science” I initially found some of the concepts and terms more than confusing enough to stop me in my tracks until I had looked this up, looked that up. It’s not long before you are deep down the Wikipedia rabbit hole wondering how you reached the page on Modus Ponens when all you wanted to know about was Horn Clauses, for example.
To that end, this page will serve as my (and yours) little glossary / explanation page that over time, your personal vocabulary expands to encompass terms that will crop up over and over when reading Prolog or Mercury articles.
Note these explanations are mine to myself but I think they are reasonably clear to help anybody else out starting the damned interesting journey that is declarative logical programming. I will continue to update this page over time as I learn new things or better understand existing terms that I my expand on or otherwise clarify any existing definition I may have given!
- deterministic //
Will succeed exactly once. That is, it will not fail. So, for any given set of inputs, whatever they may be, there will be exactly one valid result, the predicate (or function) will not fail. So when you see
detyou can think that this predicate will never fail and always give me the same answer for the same inputs.
- semi-deterministic //
A predicate that declares itself thus can expect to at most one solution but it may not have any solutions, so in other words it is only half deterministic in that if it does succeed, it will do so at most once but it may not at all.
A fancy alternative to the word
and. That will do, every time you see this word just say
and. In Mercury, you will notice that consecutive predicates are separated by a comma, that is because… the comma is the conjunction operator so in order for a predicate to be true, all of its sub-predicates must be true.
Fancy alternative for the word
or. The dis-junction operator is the semi-colon character, so when you see a bunch of code sandwiched between
;it means this OR this OR this etc. I hope that starts to make sense. To quote the Ralph Beckett book, “a dis-junction is a sequence of goals separated by semicolons.” Isn’t that what I said?
- free variable
Such a variable is one that has no value assigned to it yet. If one side of a unification operation is a free variable, it will succeed because unification always succeeds with an unbound variable. The variable takes on the value of the other side or
- ground term
Nothing to do with beef. This means that the term you are looking at has no free variables in it i.e. it’s fully “grounded” in reality if you like. For example,
thing(X)is not ground because X could be anything, but
thing(dog)is, as is
thing(banana)as well. Bananas of course being nutritious, a Minions favourite thing and the official Reddit unit of measure.
If you have any terms that confuse or you want to improve the contents of this page, use the comment section below.