Re: context/world and asserting in multiple contexts
Thomas Russ <[email protected]> Mon, 20 Nov 2006 18:27:10 -0800
| Newsgroups | gmane.comp.ai.powerloom |
|---|---|
| Message-ID | <[email protected]> |
On Nov 19, 2006, at 7:54 AM, Kambiz Darabi wrote: > And when using many contexts, is there a way of defining things and > asserting facts in multiple contexts simultaneously? If they are arranged hierarchically, then you can just make the assertion in the higher level module and have it then be visible (via inheritance) in the lower level modules. This applies for assertions made at any time. In the example below, I create several levels of module and then make assertions in upper, shared modules. Those assertions are then visible in all of the lower, modules (unless specifically retracted there). Example: ? (defmodule "LEVEL-1" :includes "PL-KERNEL-KB") :VOID ? (defmodule "LEVEL-2" :includes "LEVEL-1") :VOID ? (defmodule "LEVEL-3A" :includes "LEVEL-2") :VOID ? (defmodule "LEVEL-3B" :includes "LEVEL-2") :VOID ? (in-module "LEVEL-1") |MDL|/PL-KERNEL-KB/LEVEL-1 ? (defconcept c) |c|C ? (defrelation r (?x ?y)) |r|R ? (assert (r fred barney)) |P|(R FRED BARNEY) ? (assert (r pebbles bam-bam)) |P|(R PEBBLES BAM-BAM) ? (in-module "LEVEL-3A") |MDL|/PL-KERNEL-KB/LEVEL-1/LEVEL-2/LEVEL-3A ? (assert (r wilma betty)) |P|(R WILMA BETTY) ? (retrieve all (r ?x ?y)) There are 3 solutions: #1: ?X=WILMA, ?Y=BETTY #2: ?X=PEBBLES, ?Y=BAM-BAM #3: ?X=FRED, ?Y=BARNEY ? (in-module "LEVEL-1") |MDL|/PL-KERNEL-KB/LEVEL-1 ? (assert (r jim bob)) |P|(R JIM BOB) ? (in-module "LEVEL-3A") |MDL|/PL-KERNEL-KB/LEVEL-1/LEVEL-2/LEVEL-3A ? (retrieve all (r ?x ?y)) There are 4 solutions: #1: ?X=JIM, ?Y=BOB #2: ?X=WILMA, ?Y=BETTY #3: ?X=PEBBLES, ?Y=BAM-BAM #4: ?X=FRED, ?Y=BARNEY ? (in-module "LEVEL-3B") |MDL|/PL-KERNEL-KB/LEVEL-1/LEVEL-2/LEVEL-3B ? (retrieve all (r ?x ?y)) There are 3 solutions: #1: ?X=JIM, ?Y=BOB #2: ?X=PEBBLES, ?Y=BAM-BAM #3: ?X=FRED, ?Y=BARNEY ;; ;; Example of explicit retraction: ;; ? (retract (r jim bob)) |P?|(R JIM BOB) ? (retrieve all (r ?x ?y)) There are 2 solutions: #1: ?X=PEBBLES, ?Y=BAM-BAM #2: ?X=FRED, ?Y=BARNEY ? (in-module "LEVEL-3A") |MDL|/PL-KERNEL-KB/LEVEL-1/LEVEL-2/LEVEL-3A ? (retrieve all (r ?x ?y)) There are 4 solutions: #1: ?X=JIM, ?Y=BOB #2: ?X=WILMA, ?Y=BETTY #3: ?X=PEBBLES, ?Y=BAM-BAM #4: ?X=FRED, ?Y=BARNEY ? (in-module "LEVEL-2") |MDL|/PL-KERNEL-KB/LEVEL-1/LEVEL-2 ? (retrieve all (r ?x ?y)) There are 3 solutions: #1: ?X=JIM, ?Y=BOB #2: ?X=PEBBLES, ?Y=BAM-BAM #3: ?X=FRED, ?Y=BARNEY ?