Understanding :<= vs :<<= etc.

View: New views
2 Messages — Rating Filter:   Alert me  

Understanding :<= vs :<<= etc.

by srini_ottawa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am trying to understand the compiler directives:

:=> v/s :=>> or the reverse :<<= vs :<=. Also, <=> vs <<=> OR <=>>.

1. Take the inital code:

(defconcept person (?x))
(defrelation alive (?x))

(defconcept live-person (?x person)
  :<=> (alive ?x)
  )

Print out the internal form: (print-rules live-person)

(FORALL (?x1)
   (<= (PERSON ?x1)
       (LIVE-PERSON ?x1))) ; sub-concept rule, ignore

(FORALL (?x1)
   (<= (ALIVE ?x1)
       (LIVE-PERSON ?x1)))   ;; compare with the second version below

(FORALL (?x1)
   (<= (LIVE-PERSON ?x1)     ;; compare with third version below
       (ALIVE ?x1)))

2. Change the definition of live-person to use the compiler directive :forward-only
(defconcept live-person (?x person)
  :<=>> (alive ?x)
  )

Print out the internal form: (print-rules live-person)

(FORALL (?x1)
   (<= (PERSON ?x1)
       (LIVE-PERSON ?x1)))    ; sub-concept rule, ignore

(FORALL (?x1)
   (=>> (LIVE-PERSON ?x1)    ; only difference from previous form
        (ALIVE ?x1)))

(FORALL (?x1)
   (<= (LIVE-PERSON ?x1)      ; same as before
       (ALIVE ?x1))) 

I guess the difference is that, in the second version
-- alive can be deduced if liveperson is given as a fact but not the reverse
-- When live-person is given as a fact, alive is also asserted via forward-chaining. this does not happen in the first, which has to find alive at query time.
Am I correct?


3. Change the definition of live-person to use the compiler directive :backward-only
(defconcept live-person (?x person)
  :<<=> (alive ?x)
  )

Now see the expansion:
(print-rules live-person)

(FORALL (?x1)
   (<= (PERSON ?x1)
       (LIVE-PERSON ?x1)))   ; sub-concept rule, ignore

(FORALL (?x1)
   (<= (ALIVE ?x1)
       (LIVE-PERSON ?x1)))   ; same as first version

(FORALL (?x1)
   (<<= (LIVE-PERSON ?x1)
        (ALIVE ?x1)))

What is the difference between the highlighted rule above and the one in the very first version:

(FORALL (?x1)
   (<= (LIVE-PERSON ?x1)
       (ALIVE ?x1)))

Thanks

Srini.



_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum

Re: Understanding :<= vs :<<= etc.

by Hans Chalupsky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Srini,

answers in-line:

>>>>> Srini Ram <srini_ramaswamy_i@...> writes:

> I am trying to understand the compiler directives:
> :=> v/s :=>> or the reverse :<<= vs :<=. Also, <=> vs <<=> OR <=>>.

The double arrows are short-hands for search control directives.  For
example:

(assert (<<= (cq ?x ?y) (ant ?y ?x)))

is a shorthand for

(assert (about (<= (cq ?x ?y) (ant ?y ?x)) :direction :backward))

which means this rule is only to be used during backward inference
from goals (consequents) to antecedents (similar to Prolog).

Note that this is equivalent to

(assert (about (=> (ant ?y ?x) (cq ?x ?y)) :direction :backward))

Whether you use => or <= is a matter of taste, but in order to use the
<<= syntax, you have to write the rule via reverse implication, since
we are adding a second "backward" arrow to indicate the
directionality.  So, this can be a bit confusing, since the "inner"
single arrow <= or => is about logical implication, while the
additional < is about backward direction.

Conversely,

(assert (=>> (ant ?y ?x) (cq ?x ?y)))

is a shorthand for

(assert (about (=> (ant ?y ?x) (cq ?x ?y)) :direction :forward))

which means this rule is only to be used during forward inference
from assertions matching rule antecedents to consequents (mildly
similar to production systems).

Combination arrows such as <<=>, <<=>>, etc. can be understood by
decomposing them into two single arrow rules, for example:

(<=>> (ant ?y ?x) (cq ?x ?y))

is equivalent to

(and (<= (ant ?y ?x) (cq ?x ?y))
     (=>> (ant ?y ?x) (cq ?x ?y)))

or

(and (=> (cq ?x ?y) (ant ?y ?x))
     (=>> (ant ?y ?x) (cq ?x ?y)))

In general, you should only use search control hints when you are sure
what you are doing.  They allow you to tune inference performance
depending on the characteristics of the domain.

The keyword versions of these arrows used in definitions are again
just short-hand or "half-rules" which can be expanded by inserting the
relation and its arguments on the left-hand side.  In your example:

(defconcept live-person (?x person)
  :<=>> (alive ?x))

expands into the rule

(<=>> (live-person ?x) (alive ?x))


> 1. Take the inital code:

> (defconcept person (?x))
> (defrelation alive (?x))

> (defconcept live-person (?x person)
>   :<=> (alive ?x)
>   )

> Print out the internal form: (print-rules live-person)

> (FORALL (?x1)
>    (<= (PERSON ?x1)
>        (LIVE-PERSON ?x1))) ; sub-concept rule, ignore

> (FORALL (?x1)
>    (<= (ALIVE ?x1)
>        (LIVE-PERSON ?x1)))   ;; compare with the second version below

> (FORALL (?x1)
>    (<= (LIVE-PERSON ?x1)     ;; compare with third version below
>        (ALIVE ?x1)))

> 2. Change the definition of live-person to use the compiler directive :forward-only

> (defconcept live-person (?x person)
>   :<=>> (alive ?x)
>   )

> Print out the internal form: (print-rules live-person)

> (FORALL (?x1)
>    (<= (PERSON ?x1)
>        (LIVE-PERSON ?x1)))    ; sub-concept rule, ignore

> (FORALL (?x1)
>    (=>> (LIVE-PERSON ?x1)    ; only difference from previous form
>         (ALIVE ?x1)))

> (FORALL (?x1)
>    (<= (LIVE-PERSON ?x1)      ; same as before
>        (ALIVE ?x1))) 

> I guess the difference is that, in the second version
> -- alive can be deduced if liveperson is given as a fact but not the reverse
> -- When live-person is given as a fact, alive is also asserted via
> forward-chaining. this does not happen in the first, which has to find
> alive at query time.

> Am I correct?

Mostly.  You can still infer LIVE-PERSON from ALIVE.  Logically, all
three of your formulations are equivalent.  The only difference is how
the information gets inferred (i.e., by the forward or backward
chainer).  BUT: in your specific examples the rules will actually
never be explicitly chained through, since they are representable via
a simple subset relationship (try (ask (subset-of LIVE-PERSON ALIVE))
and vice versa), therefore, they can all be handled directly by the
assertion lookup machinery which takes subrelations into account.

> 3. Change the definition of live-person to use the compiler directive :backward-only
> (defconcept live-person (?x person)
>   :<<=> (alive ?x)
>   )

> Now see the expansion: (print-rules live-person)

> (FORALL (?x1)
>    (<= (PERSON ?x1)
>        (LIVE-PERSON ?x1)))   ; sub-concept rule, ignore

> (FORALL (?x1)
>    (<= (ALIVE ?x1)
>        (LIVE-PERSON ?x1)))   ; same as first version

> (FORALL (?x1)
>    (<<= (LIVE-PERSON ?x1)
>         (ALIVE ?x1)))

> What is the difference between the highlighted rule above and the one in the very first version:

> (FORALL (?x1)
>    (<= (LIVE-PERSON ?x1)
>        (ALIVE ?x1)))

As explained in the beginning, they are logically equivalent, the only
difference is the search control annotation.  The double arrow says to
only use the rule in backward direction, the single arrow doesn't say
anything about search control and leaves it up to PowerLoom how to use
the rule.  Again, in your specific example, the rules will never be
chained through, so there is no practical difference at all between
the two versions.

Hans

> Thanks

> Srini.

--------------------------------------------------------------------------
Hans Chalupsky, PhD                     USC Information Sciences Institute
Project Leader, Loom KR&R Group         4676 Admiralty Way
<hans@...>                          Marina del Rey, CA 90292
(310) 448-8745
--------------------------------------------------------------------------

_______________________________________________
powerloom-forum mailing list
powerloom-forum@...
http://mailman.isi.edu/mailman/listinfo/powerloom-forum