Lesson goal: Starting with AI and Prolog

Previous: Work with student grades | Home | Next: Introduction Part II: Compound facts

Thus far, most of the lessons on this site have been about equations, mathematical operations, and numbers. We made the computer crunch numbers. It turns out, there's a lot to learn about coding that involves processing symbols (names, places, words, etc.). It's an odd thing to do with computers, that often gives surprising results that may give you hint of Artificial intelligence (or AI).

In this series of lessons, we'll stop with the Lua language, and use a language called Prolog to do some symbolic processing. Prolog is a very different and unique language that has a bit of the AI "wow factor" in what it can do (and how we code using it).

To start, Prolog is a very expressive language. You kind of make up the language yourself, as you need, almost like the way you think of words you need when you write a story. You are not bound to using for and if statements, and the like as you did in Lua.

In this example, let's use Prolog to express some facts about some things a person called "Tom" likes. Then we'll use Prolog to tell us what Tom likes.
goal: likes(tom,X).
Move the mouse over a dotted box for more information.

Be sure all of your ideas and words are in all lower case. Only variables start with an upper-case letter. You can express as many such "facts" as you wish. Put each one on a line by itself.

Now you try. Certainly run this code, but also try to put in your own name and things you like.

Type your code here:

See your results here: