PowerLoom Overview Practical Artificial Intelligence Programming With Java

;;; Relation: defrelation parent-of ?p1 parent ?p2 person Here I have defined two concepts: person and parent. Note that we have a hierarchy of concept types here: the parent is a more specific concept type than the person concept. All instances that are parents are also of type person. The relation parent- of links a parent concept to a person concept. We will learn more about basic PowerLoom functionality in the next two sections as we use PowerLoom in an interactive session and when we embed PowerLoom in a Java example program.

3.3 Running PowerLoom Interactively

We will experiment with PowerLoom concepts, relations, and rules in this section in an interactive command shell. I will introduce more examples of PowerLoom functionality for asserting instances of concepts, performing queries, loading Pow- erLoom source files, defining relations, using separate modules, and asking Power- Loom to explain the inference process that it used for query processing. You can run PowerLoom using the command line interface by changing directory to the lib subdirectory from the ZIP file for this book and trying: java -cp powerloom.jar:stella.jar \\ edu.isi.powerloom.PowerLoom This starts the PowerLoom standalone system and prints a prompt that includes the name of the current module. The default module name is “PL-USER”. In the first example, when I enter the person concept at the interactive prompt then PowerLoom prints the result of the expression that just entered. PL-USER |= defconcept person |c|PERSON PL-USER |= defconcept parent ?p person |c|PARENT PL-USER |= defrelation parent-of ?p1 parent ?p2 person |r|PARENT-OF PL-USER |= assert person Ken |P|PERSON KEN PL-USER |= assert person Mark 49 |P|PERSON MARK PL-USER |= assert parent-of Ken Mark |P|PARENT-OF KEN MARK Now that we have entered two concepts, a test relation, and asserted a few facts, we can look at an example of PowerLoom’s query language: PL-USER |= retrieve all ?p person ?p There are 2 solutions: 1: ?P=MARK 2: ?P=KEN PL-USER |= retrieve all ?p parent ?p There is 1 solution: 1: ?P=KEN PL-USER |= The obvious point to note from this example is that we never specified that Ken was a parent; rather, PowerLoom deduced this from the parent-of relation. PowerLoom’s command line system prompts you with the string “PL-USER —=“ and you can type any definition or query. Like Lisp, PowerLoom uses a prefix notation and expressions are contained in parenthesis. PowerLoom supports a mod- ule system for partitioning concepts, relations, functions, and rules into different sets and as previously mentioned “PL-USER” is the default module. PowerLoom modules can form a hierarchy, inheriting concepts, relations, and rules from parent modules. The subdirectory test data contains the demo file business.plm written by Robert MacGregor that is supplied with the full PowerLoom distribution. You can load his complete example using: PL-USER |= load ..test_databusiness.plm This is a good example because it demonstrates most of the available functionality of PowerLoom in a short 200 lines. When you are done reading this chapter, please take a few minutes to read through this example file since I do not list it here. There are a few things to notice in this example. Here we see a rule used to make the relation “contains” transitive: defrelation contains ?l1 geographic-location ?l2 geographic-location 50