This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Visual Prolog 6 Tutorials Fundamental Prolog (Part 1) Written by Thomas Linder Puls Prolog Development Center A/S Last updated: In this tutorial you will learn about the very fundamental ideas of Prolog programming. Visual Prolog 6 is object oriented, strictly typed and mode checked. You will of course have to master all this to write Visual Prolog 6 programs. But here we will focus on the core of the code, i.e. the code when disregarding classes, types and modes. For this purpose we will use the PIE example that is included in the Visual Prolog 6 distribution. PIE is a "classical" Prolog interpreter, by using this you can learn and experiment with Prolog without at all being concerned with classes, types, etc. Horn Clause Logic Visual Prolog and other Prolog dialects are based on Horn Clause logic. Horn Clause logic is a formal system for reasoning about things and the way they relate to each other. In natural language I can express a statement like: John is the father of Bill. Here I have two "things": John and Bill, and a "relation" between these, namely that one is the father of the other. In Horn Clause Logic I can formalize this statement in the following way: father( "Bill" , "John" ). father is a predicate/relation taking two arguments, where the second is the father of the first. Notice that I have chosen that the second person should be the father of the first . I might as well have chosen it the other way around: The order of the arguments is the choice of the "designer" of the formalization. However, once you have chosen, you must be consistent. So in my formalization the father must always be the second person. I have chosen to represent the persons by their names (which are string literals). In a more complex world this would not be sufficient because many people have same name. But for now we will be content with this simple formalization. With formalizations like the one above I can state any kind of family relation between any persons. But for this to become really interesting I will also have to formalize rules like this: X is the grandfather of Z, if X is the father of Y and Y is the father of Z where X , Y and Z are persons. In Horn Clause Logic I can formalize this rule like this: grandFather( Person , GrandFather ) :- father( Person , Father ), father( Father , GrandFather )....
View Full Document
- Spring '10