Prolog
Amzi! offers both free and commercial Prolog development tools. This tutorial text refers to the Amzi!® Eclipse IDE. Amzi! runs under all forms of Windows, and many forms of Unix including Linux and Solaris. You can download a copy from our web site:
www.amzi.com
You can find other freely available Prolog tools for Windows and other plat-forms in the Prolog FAQ and onvarious Prolog and AI repositories. Our web site contains up-to-date pointers to these sites.
You will also find numerous articles on our web site about:
• Learning and using Prolog,
• Building expert systems, agents and intelligent components in Prolog,
• Embedding Prolog modules in C/C++, Java, Delphi, Visual Basic and other applications,
• Using intelligent components on theInternet, and
• Many other topics
Our web site also contains pointers to:
• Books,
• Prolog source code repositories,
• Papers and FAQs,
• Other Prolog, AI and expert systems sites, and
• Newsgroups.
1
Getting Started
Prolog stands for PROgramming in LOGic. It was developed from a foundation of logical theorem proving and originally used for research innatural language processing. Although its popularity has sprung up mainly in the artificial intelligence (AI) community, where it has been used for applications such as expert systems, natural language, and intelligent databases, it is also useful for more conventional types of applications. It allows for more rapid development and prototyping than most languages because it is semantically close to thelogical specification of a program. As such, it approaches the ideal of executable program specifications.
Programming in Prolog is significantly different from conventional procedural programming and requires a readjustment in the way one thinks about programming. Logical relationships are asserted, and Prolog is used to determine whether or not certain statements are true, and if true, whatvariable bindings make them true. This leads to a very declarative style of programming.
In fact, the term program does not accurately describe a Prolog collection of executable facts, rules and logical relationships, so you will often see term logicbase used in this book as well.
While Prolog is a fascinating language from a purely theoretical viewpoint, this book will stress Prolog as a practicaltool for application development.
Much of the book will be built around the writing of a short adventure game. The adventure game is a good example since it contains mundane programming constructs, symbolic reasoning, natural language, data, and logic.
Through exercises you will also build a simple expert system, an intelligent genealogical logicbase, and a mundane customer order entryapplication.
You should create a source file for the game, and enter the examples from the book as you go. You should also create source files for the other three programs covered in the exercises. Sample source code for each of the programs is included in the appendix.
The adventure game is called Nani Search. Your persona as the adventurer is that of a three year old girl. The lost treasure withmagical powers is your nani (security blanket). The terrifying obstacle between you and success is a dark room. It is getting late and you're tired, but you can't go to sleep without your nani. Your mission is to find the nani.
Nani Search is composed of
• A read and execute command loop
• A natural language input parser
• Dynamic facts/data describing the current environment
•Commands that manipulate the environment
• Puzzles that must be solved
You control the game by using simple English commands (at the angle bracket (>) prompt) expressing the action you wish to take. You can go to other rooms, look at your surroundings, look in things, take things, drop things, eat things, inventory the things you have, and turn things on and off.
Figure 1.1 shows a run of a...
Regístrate para leer el documento completo.