My Experience Learning Prolog

I first heard about the Prolog programming language in the book Seven Languages in Seven Weeks. The book, as promised, introduces the reader to the syntax and paradigms of seven different languages. What attracted me to Prolog was its similarity to constraint programming (programs are defined by and solved using their constraints), its similarity to SQL (data-focused and declarative), and its recursive nature.

Normally, I would learn a new language by playing with it, but Prolog was too foreign and intimidating, so I looked for a more structured learning approach.

TALE-SPIN in Prolog

TALE-SPIN TALE-SPIN1 is an AI program developed in 1977 by James R. Meehan. It works by using a knowledge base of actions to solve and modify goals. As actions are performed, they output text that form a story. In the words of the author:

TALE-SPIN is a problem solver, top-down and goal-directed. Its output may be regarded as a trace through problem-solving procedures.

Meehan rejected previous approaches with clean formulations that involved defining “one kind” of knowledge but sometimes resulted in bizarre stories.

Chopsticks in Prolog

The Game Chopsticks is a simple game of many variations played by children and college students. The variation I play is:

two players start by each sticking both index fingers out to represent a count of one on each hand players alternate turns until someone loses by having a count of zero on both hands on a player’s turn, he must either: use one of his hands with positive count $H1$ to tap one of the other player’s hands $H2$.