Re: Assigning a function to the current value of another

"Prasan Samtani" <[email protected]> Tue, 3 Jul 2007 13:46:35 -0700
Newsgroups gmane.comp.ai.powerloom
Message-ID <479348D61212AC4DB31C9906F8C7028D025E0355@EXVBE012-5.exch012.intermedia.net>
Thanks... I'm currently accessing PowerLoom through a Java interface, so
it looks like it might be easier to maintain the system time in Java,
and then set the time to a literal. Or, in the general case, retrieve a
variable's value, store it in a variable, and then call assert.

Thanks for the help though, it helped my understanding of the system,
Prasan


-----Original Message-----
From: Hans Chalupsky [mailto:[email protected]] 
Sent: Tuesday, July 03, 2007 1:08 PM
To: Prasan Samtani
Cc: [email protected]
Subject: Re: [PowerLoom Forum] Assigning a function to the current value
of another

Prasan,

that's an interesting question.  PowerLoom currently always equates
function terms intensionally (their descriptions such as "Joe's age")
as opposed to extensionally (their values).  The value dereferencing is
done at query time.

When you assert a new function value at the top level, PowerLoom
"clips" the old value which means it actually first performs a
retraction (a non-monotonic operation) and then assert the new value,
for example:

(assert (= (age Joe) 10))
(assert (= (age Joe) 20))

is really

(assert (= (age Joe) 10))
(retract (= (age Joe) 10))
(assert (= (age Joe) 20))

PowerLoom takes the minimal interpretation here with respect to
retraction.  What you want it to do would be something like this which
is a much more elaborate interpretation:

(assert (= (age Joe) 10))
(assert (= (age Fred) (age Joe)))
(retract (= (age Joe) 10))
(retract (= (age Fred) (age Joe)))
(assert (= (age Fred) 10))
(assert (= (age Joe) 20))

But I think what you really want to do is something like this:

(assert (= (age Joe) 10))
(assert (= (age Fred) (current-value-of (age Joe))))

which doesn't exist in PowerLoom.  One problem with this approach is
that it has a procedural aspect, since suddently the order of
assertions would matter (even without any intervening retractions).
In a monotonic logic

(assert (= (age Joe) 10))
(assert (= (age Fred) (current-value-of (age Joe))))

should be equivalent to

(assert (= (age Fred) (current-value-of (age Joe))))
(assert (= (age Joe) 10))

which isn't the case anymore.

One way to maybe do what you want is to use `assert-from-query', even
though the syntax isn't very elegant for what you are trying to do:

STELLA(12): (assert (= (age Joe) 10))
|P|(= (AGE JOE) sk05//10)
STELLA(13): (assert-from-query
             (retrieve (?p ?a)
                       (and (= ?p Fred) (= ?a (age Joe))))
             :relation age)
(|P|(= (AGE FRED) 10))
STELLA(14): (assert (= (age Joe) 20))
|P|(= (AGE JOE) sk05//20)
STELLA(15): (retrieve (= (AGE FRED) ?a))
There is 1 solution so far:
  #1: ?A=10
STELLA(16): 

Here the query does the assertion-time value lookup for you and then
asserts the equivalence to the value as opposed to "Joe's age".

Hope that helps,

Hans

>>>>> Prasan Samtani <[email protected]> writes:

> In the powerloom manual, there is a section that explains how one can
> assert equality between skolems that represent function terms:

> (deffunction age (?x ?y))
> (assert (= (age Joe) 10))
> (assert (= (age Fred) (age Joe)))

> Now if I were to call:

> (retrieve (age Fred ?x))

> I get 10, as expected. However, lets say I change the value of Joe's
age
> and then query the value of Fred's age again:

> (assert (= (age Joe) 20))

> (retrieve (age Fred ?x))

> Now, I get 20.

> Is there a way to set Fred's age to the current value of Joe's age, so
> that any subsequent changes to Joe's age will not affect the value of
> Fred's age? For example, if there was a counter maintaining the system
> time, and I wanted to set the value of an event's time to the current
> value of the system time. Subsequently changing the system time should
> not affect the value of when the event occurred.

> Thanks,

> Prasan