Re: equality reasoning with functions and existentials?
Hans Chalupsky <[email protected]> Thu, 17 Feb 2011 12:26:11 -0800
| Newsgroups | gmane.comp.ai.powerloom |
|---|---|
| Message-ID | <[email protected]> |
The problem is that PowerLoom's just-in-time forward inference isn't comple= te enough here to pick up all that's required, and you have to run forward rul= es explicitly. When you define an "inverse" for a relation, the required rules are created by forward inference which isn't triggered by the JIT in this case. As an aside, inverse relations in a logic system like PowerLoom are redundant and generally a bad idea for performance reasons. Also, if you declare an inverse on one relation, you shouldn't also do it on the inverse, since it will generate redundant rules. I know, PowerLoom should adivse us= ers on that, but currently it doesn't :-) Anyway, after you do a "run-forward-rules" in the trace below, you get the answer you are looking for. Hans STELLA(99): (clear-module pl-user) :VOID STELLA(100): (deffunction the (?i) :-> (?x Thing)) |f|THE STELLA(101): (defrelation state-code (?s ?c) :axioms (inverse code-state state-code)) |r|STATE-CODE STELLA(102): (deffunction code-state (?c ?p) :axioms (inverse state-code code-state)) ;; this is redundant and shoul= d be avoided |f|CODE-STATE STELLA(103): (defrelation state-bird (?place ?birdtype)) |r|STATE-BIRD STELLA(104): (defrelation population (?place ?pop)) |r|POPULATION STELLA(105): (assert (exists (?x) (and (state-code (the ?x) "KS") (population (the ?x) 2688418)))) (|P|(=3D (THE sk8884) sk8885) |P|(STATE-CODE sk8885 "KS") |P|(=3D (THE sk88= 84) sk8886) |P|(POPULATION sk8886 2688418)) STELLA(106): (assert (exists (?y) (and (state-code (the ?y) "KS") (state-bird (the ?y) western-meadowlark)))) (|P|(=3D (THE sk8888) sk8889) |P|(STATE-CODE sk8889 "KS") |P|(=3D (THE sk88= 88) sk8890) |P|(STATE-BIRD sk8890 WESTERN-MEADOWLARK)) STELLA(107): (retrieve all (and (population ?x 2688418) (state-bird ?y western-meadowlark) (state-code ?x ?code) (state-code ?y ?code))) [2011-FEB-17 12:16:55.000 PL] Processing check-types agenda... There is 1 solution: #1: ?X=3Dsk8886, ?Y=3Dsk8890, ?CODE=3D"KS" STELLA(108): (retrieve all (and (population ?x 2688418) (state-bird ?y western-meadowlark) (code-state ?code ?x) (code-state ?code ?y))) There is 1 solution: #1: ?X=3Dsk8886, ?Y=3Dsk8890, ?CODE=3D"KS" STELLA(109): (retrieve all (and (population ?z 2688418) (state-bird ?z western-meadowlark))) No solutions. ;;; so far, everything was as in the original formulation ;;; now we turn off the JIT and run forward rules explicitly: STELLA(110): (unset-feature :JUST-IN-TIME-INFERENCE) |l|(:JUSTIFICATIONS :EMIT-THINKING-DOTS) STELLA(111): (run-forward-rules "PL-USER") |L|TRUE STELLA(112): (retrieve all (and (population ?z 2688418) (state-bird ?z western-meadowlark))) There is 1 solution: #1: ?Z=3Dsk8885 STELLA(113): = >>>>> Dan Connolly <[email protected]> writes: > I discovered powerloom the other day via a tweet > =A0=A0http://twitter.com/danja/status/37660228791042048 > It looks pretty nifty. > I'm trying to tell it: > =A0state-code is unambiguous (i.e. its inverse is a function). > =A0There's a place with state-code "KS" and population 28000. > =A0There's also a place with state-code "KS" and state-bird western-meado= wlark. > and then ask it: > =A0Is there a place with population 28000 and state-bird western-meadowla= rk? > The attached is my attempt. It's *almost* working, but not quite. I > don't understand why not. > Clues, please, anyone? > -- > Dan Connolly > http://www.madmode.com/ > untyped binary data, ,same-state.pl [Click mouse-2 to save to a file] > _______________________________________________ > powerloom-forum mailing list > [email protected] > http://mailman.isi.edu/mailman/listinfo/powerloom-forum