lee martie | 7 Nov 2010 12:14
Picon
Favicon

Integer instances and arithmetic

I am trying to create instances of type integer and increment these 
instances by some amount.

I have found a work around to do this but would be very appreciative
for a simpler solution if one exists or pointers to Powerloom features I 
am overlooking.

I found that I could not accomplish defining an integer instance with 
"(assert (INTEGER x))".
I am using the following workaround:

(deffunction intVar ((?x thing)) :-> (?y integer)) .

I also have a need to increment an integer instance by some amount.

I found that:
(assert (=(intVar g) 0))
(assert (=(intVar g) (+ (intVar g) 1)))

will not map "g" to "1" .

I am instead incrementing "g" by executing:

(assert-from-query
(retrieve all (+ (intVar g) 1 ?x))
:pattern
(setofall (?x Integer) (=(intVar g) ?x) ) )

Thanks for your help and time.
Lee Martie
(Continue reading)

Thomas Russ | 8 Nov 2010 17:54
Picon
Favicon

Re: Integer instances and arithmetic

On Nov 7, 2010, at 3:14 AM, lee martie wrote:

> I am trying to create instances of type integer and increment these
> instances by some amount.
>
> I have found a work around to do this but would be very appreciative
> for a simpler solution if one exists or pointers to Powerloom  
> features I
> am overlooking.
>
> I found that I could not accomplish defining an integer instance with
> "(assert (INTEGER x))".

That's correct.  Integers are literal objects in PowerLoom and not  
actual instances.  So you could only use literals, which are immutable  
objects.

If you want something that you can increment then you have to create  
some object and give it a value.  The simplest way of doing that is to  
use a function (via deffunction) and then change the value of that  
function on the instance.  That is what you end up doing below:

> I am using the following workaround:
>
> (deffunction intVar ((?x thing)) :-> (?y integer)) .

Yes.  This will create an object with a functional value that can be  
set to various integers.

> I also have a need to increment an integer instance by some amount.
(Continue reading)

lee martie | 10 Nov 2010 13:42
Picon
Favicon

Internal Error: Invocation Target Exception in funcall of function

Powerloom 4.0.0 beta is giving me an internal error.

Can you tell me if the following error is due to a
Powerloom bug or if I am doing something incorrectly?

When running the following commands:

(deffunction lookup ((?x thing)) :-> (?y function))
(deffunction numVar ((?x thing)) :-> (?y number))
(assert (= (lookup x) numVar))
(assert (=(numVar x)20))
(ask  (forall (?y) (= ((lookup x)x) 20) ) )

I get the following error:

 >> Internal Error: Invocation Target Exception in funcall of function:
     public static edu.isi.powerloom.logic.TruthValue 
edu.isi.powerloom.logic.Logic.askEvaluatorWrapper(edu.isi.stella.Cons) 
(((FORALL (?Y) (= (sk05//NUMVAR  <at> X |L|20) |L|20))))
     java.lang.ArrayIndexOutOfBoundsException: -2147483648
     -2147483648
java.lang.ArrayIndexOutOfBoundsException: -2147483648
     at 
edu.isi.powerloom.logic.PatternVariable.helpBindVariableToValueP(PatternVariable.java:433)
     at 
edu.isi.powerloom.logic.PatternVariable.bindVariableToValueP(PatternVariable.java:401)
     at 
edu.isi.powerloom.logic.ControlFrame.tryUniversalIntroductionProof(ControlFrame.java:1008)
     at 
edu.isi.powerloom.logic.ControlFrame.executeProofStrategy(ControlFrame.java:2502)
(Continue reading)

Thomas Russ | 10 Nov 2010 18:23
Picon
Favicon

Re: Internal Error: Invocation Target Exception in funcall of function


On Nov 10, 2010, at 4:42 AM, lee martie wrote:

> Powerloom 4.0.0 beta is giving me an internal error.
>
> Can you tell me if the following error is due to a
> Powerloom bug or if I am doing something incorrectly?

Well, it's a bit of both.  The PowerLoom in the ASK below is not  
correct.  But PowerLoom should print an error message instead of  
breaking.

>
> When running the following commands:
>
> (deffunction lookup ((?x thing)) :-> (?y function))
> (deffunction numVar ((?x thing)) :-> (?y number))
> (assert (= (lookup x) numVar))
> (assert (=(numVar x)20))
> (ask  (forall (?y) (= ((lookup x)x) 20) ) )

The problem you have here is that you are universally quantifying over  
the variable ?Y, but then it doesn't appear in the body of the  
quantification.  Also, universal quantification generally has to  
follow the pattern:

   (forall (?y) (=> (...) (...)))

where there is an implication.  That is because almost anything else  
that is universally quantified will be false, since very few sentences  
(Continue reading)


Gmane