A (Very) Short Introduction
At its core, Prolog is a logical deduction engine with the following core mechanics:
- Prolog source code is a collection of rules of the form
left_hand_side :- right_hand_side.
This reads as: the left hand side is true if the right hand side is true.
- Lower case symbols, called atoms, are concrete values whilst symbols starting with an upper case letter are variables.
- If the right hand side is just the atom
true
then the rule can be abbreviated as left_hand_side.
This is called a fact.
- Facts can have arguments. For example:
- Rules can contain variables. Every instances of the same variable in a rule must resolve to the same value. For example:
- We can then inquire the system for the validity of facts:
Other Resources
A Concise Introduction To Prolog
Kinda like a Learn X in Y minutes page where X is Prolog.
Prolog syntax and semantics
Also another cheatsheet-like page.
Preface
A book-length tutorial on building an adventure game in Prolog.
Learn Prolog Now!
I personally learned Prolog through this guide.
The Power of Prolog
Good stuff and modern but rather hard to follow.
Prolog and the Relational Model for Data
[TO BE WRITTEN]
- Prolog facts vs. relation
- Inner join
- Outer joins