context/world and asserting in multiple contexts
Hans Chalupsky <[email protected]> Mon, 20 Nov 2006 12:13:07 -0800
| Newsgroups | gmane.comp.ai.powerloom |
|---|---|
| Message-ID | <[email protected]> |
Kambiz,
worlds are more light-weight, since they are smaller objects (6 slots
vs. 22 slots for modules), and they don't contain symbol (or name)
tables which can become quite large. PowerLoom has two mechanisms to
compartmentalize knowledge bases: name spaces and assertion spaces.
Modules are both name spaces and assertion spaces, worlds are only
assertion spaces. Where this distinction matters most is for
hypothetical reasoning applications where one might try to perform
inferences in many different scenarios each represented by a world
(e.g., for planning).
PowerLoom uses hypothetical worlds (behind the scenes) to prove
entailments, subsumption queries, etc., however, there is (currently)
no user-level language that allows you to create a world, this can
only be done programmatically (e.g., via STELLA's push-world).
For what you are describing, using modules (even if there are several
hundred) should work just fine. One way to optimize this is to have a
top-level module where you define all the names via defconcept,
definstance, etc. and then inherit those names in all the submodules
(that way the symbol tables of the submodules will be more or less
empty and won't consume much space). The submodules would then only
be used as assertion spaces holding the different sets of
propositions.
There is currently no command for asserting a proposition in multiple
modules (that could be done fairly easily programmatically using the
PLI interface). However, one way to potentially handle this from the
command level is to use `assert-from-query'. For example, assume you
are in module A and want to export all its current `name' assertions
to module B. This could be done as follows:
(assert-from-query
(retrieve all (name ?x ?y))
:module B)
More generically, you could export all assertions of a particular
arity from A to B as follows (the `context-of' restriction here makes
sure that the relation ?r was defined in module A, so you don't export
all binary relations that you inherit from higher up such as from
PL-KERNEL):
(assert-from-query
(retrieve all (and (instance-of ?r relation)
(= (context-of ?r) A) ;; the home-module of ?r
(= (arity ?r) 2)
(holds ?r ?x ?y)))
:pattern (kappa (?r ?x ?y) (holds ?r ?x ?y))
:module B)
You can then add further assertions to A and B after the export of the
shared assertions. You'd have to run this multiple times to export to
other modules as well.
Another way of sharing some assertions is of course by using module
inheritance. Note that you can override an inherited assertion in a
submodule by retracting it there and asserting something different.
Finally, for your `name' example another solution would be to add the
country where the name is used as a third argument to the relation.
Hope this helps,
Hans
--------------------------------------------------------------------------
Hans Chalupsky, PhD USC Information Sciences Institute
Project Leader, Loom KR&R Group 4676 Admiralty Way
<[email protected]> Marina del Rey, CA 90292
(310) 448-8745
--------------------------------------------------------------------------
>>>>> Kambiz Darabi <[email protected]> writes:
> Hello,
> I have some questions concerning worlds and cotexts. The manual mentions
> worlds in addition to modules:
>> A PowerLoom context is either a "module", a somewhat heavyweight object
>> that includes its own symbol table, or a "world", a very lightweight
>> object designed for fast switching from one world to another
> How are they more 'lightweight'? If I plan to use many (hundreds of)
> contexts, is it then better to use worlds? If yes, what are the
> functions/commands to work with worlds?
> And when using many contexts, is there a way of defining things and
> asserting facts in multiple contexts simultaneously?
> As an example, I have included some statements at the end, which
> try to represent the fact, that the car model, which is called
> Rabbit in the US, is called Golf in UK and Portugal and Caribe
> in Brazil. Assertions about the name of that model are made in
> different modules which represent languages.
> With simple
> (cc context)
> (assert ...)
> terms, one has to repeat assertions in different modules.
> Is there a way of asserting facts in multiple contexts, so that
> one would only have to write one assert and add to it all
> contexts in which it is valid?
> Many thanks
> Kambiz
> ---
> (defmodule "TEST" :includes "PL-KERNEL-KB")
> (defmodule "LANGUAGE" :includes TEST)
> (defmodule "DE" :includes LANGUAGE)
> (defmodule "DE_DE" :includes DE)
> (defmodule DE_CH :includes DE)
> (defmodule "EN" :includes LANGUAGE)
> (defmodule "EN_US" :includes EN)
> (defmodule "EN_GB" :includes EN)
> (defmodule "PT" :includes LANGUAGE)
> (defmodule "PT_PT" :includes PT)
> (defmodule "PT_BR" :includes PT)
> (in-module "TEST")
> (defconcept model-rabbit)
> ;; the model which is called Rabbit in the US
> ;; is called Golf in European countries
> ;; and Caribe in South America
> (cc "DE")
> (assert (= (name model-rabbit) "Golf"))
> ;; We take Rabbit as the default name, as
> ;; there are more English speaking US citizens
> ;; than there are Englishmen (although I ignore
> ;; the Commonwealth, so this is probably a mistake :-)
> (cc "EN")
> (assert (= (name model-rabbit) "Rabbit"))
> (cc "EN_GB")
> (assert (= (name model-rabbit) "Golf"))
> (cc "EN_US")
> (all-facts-of model-rabbit)
> ;; gives
> ;; (|P|(CONCEPT MODEL-RABBIT)
> ;; |P?|(DUPLICATE-FREE MODEL-RABBIT)
> ;; |P|(= (NAME MODEL-RABBIT) sk07//"Rabbit"))
> ;; Golf in Portugal and Caribe in Brazil
> (cc "PT")
> (assert (= (name model-rabbit) "Golf"))
> (cc "PT_BR")
> (assert (= (name model-rabbit) "Caribe"))
> _______________________________________________
> powerloom-forum mailing list
> [email protected]
> http://mailman.isi.edu/mailman/listinfo/powerloom-forum