Introduction to Logic Programming and SWI-Prolog
As machine learning matures, it is becoming obvious that we need explainable solutions. As functional programming matures it becomes obvious that we need inference and nondeterminism. And linked open data demands reasoning. This all day workshop will introduce the logic programming paradigm, in which programs are expressed as a set of logical rules and executed by finding proofs of queries.
SWI-Prolog is the most highly developed and widely used language for logic programming.
The language, which has been in continuous use in academic research settings since it's invention in 1972, provides unparalleled power. Many problems which would be difficult to express in other languages are simple in SWI-Prolog. SWI-Prolog is a 'batteries included' modern language, ready for real world tasks like web development and process control.
In this dynamic hands on workshop we'll learn the basics of SWI-Prolog, and look at some of the amazing things it can do.
Outline/Structure of the Workshop
- Intro to the SWI-Prolog environment
- SWI-Prolog atomics, compounds, and lists
- SLD resolution on the quick (with cuts)
- family tree
- lunch break
- video rental store exercise
- web framework intro
- Survey of awesomeness
Learning Outcome
Students will be able to write and understand simple programs in SWI-Prolog, understand the conceptually difficult SLD resolution material, and be capable of achieving full fluency with post-class self study.
Target Audience
Programmers brand new to logic programming
Prerequisites for Attendees
Participants should bring a laptop with a recent (post 7.7.11) install of SWI-Prolog (http://swi-prolog.org).Latest as of this moment is 7.7.23
Windows users - just download and install using the installer from the website.
Linux/mac:
I recommend using swivm to install https://github.com/fnogatz/swivm
Instructions:
Install release 0.5.0 of swivm https://github.com/fnogatz/swivm
Install the listed prerequisites as shown in the readme, and then
sudo apt install cmake
(if you failed to do this, swivm uninstall 7.7.23, install cmake, swivm install 7.7.23)
Then use swivm to install swi-prolog 7.7.23 with:
swivm install 7.7.23
swivm use 7.7.23
swipl
This launches SWI-Prolog and should leave you at a ?- prompt.
?-check_installation. (dont type ?-, do type period)
This tests your installation.
SWI-Prolog is 'batteries included' and hence has lots of dependencies. Those not needed canfail.
These libs aren't needed and can fail:
- jpl (java interop),
- odbc (database connect),
- readline (if you have readline OR editline you're good),
- uuid,
- zlib (zip encoding),
- ssl
Download samples
https://github.com/Anniepoo/fnconfworkshop
Links
I am one of three people who produce a channel about Prolog, Playing with Prolog, on youtube
I run the official online school for SWI-Prolog
Many of the lectures from the Intro to SWI-Prolog course are on the Playing with Prolog channel.
I run the SWI-Prolog twitter account @SWI_Prolog
Presentation at Strange Loop
The official SWI-Prolog website
The 'slides' for the Web Development workshop I did at Strangeloop are a Prolog program