From: lisp linux
Subject: Lisa or rule syntax
Date: 
Message-ID: <a8WdnfxRrvz8cU3anZ2dnUVZ_vmlnZ2d@comcast.com>
Hi

I am trying to learn how to do an 'or' rule in Lisa

The following fails to parse unless i remove rule r3
Lisa version used is the latest release 3.21
I get parse error in both clisp2.43 and sbcl 1.0.13
What am I doing wrong ?
I am basically having a hard time doing 'or' rules that have variables for slots.
But in the example below I can't get even fixed slot values to parse right.

;--start code
(eval-when (:compile-toplevel :load-toplevel :execute)
   (when (not (find-package "LISA-TEST"))
     (defpackage "LISA-TEST"
       (:use "LISA-LISP"))))

(in-package "LISA-TEST")

(deftemplate t1 () (slot s))
(deftemplate t2 () (slot s))
(deftemplate t3 () (slot s))

(deffacts testfacts ()
   (t1 (s s1))
   (t2 (s s2))
   (t3 (s s3))
   (t1 (s x1)))

(defrule r1 ()
   (t1 (s ?s1))
   =>
   (format t "from rule r1 - we got ~A. ~%" ?s1))


(defrule r2 ()
   (or (t1 )
       (t2 ))
   =>
   (format t "from rule r2 . ~%"))

(defrule r3 ()
   (or (t1 (s s1))
       (t2 (s s2)))
   =>
   (format t "from rule r3 . ~%"))



(eval-when (:compile-toplevel :load-toplevel :execute)
   (format t "doing stuff ~%")
   (reset)
   (run))

;;-end code


-Antony

From: Andrew Philpot
Subject: Re: Lisa or rule syntax
Date: 
Message-ID: <slrnft32pf.cvq.philpot@ubirr.isi.edu>
On 2008-03-07, lisp linux <·········@lisp.linux> wrote:
> Hi
>
[snip]
> (defrule r3 ()
>    (or (t1 (s s1))
>        (t2 (s s2)))
>    =>
>    (format t "from rule r3 . ~%"))
[snip]

This syntax did work on lisa 2.4, and I also see that it now (3.2)
generates a parse error:

  Error: Rule parsing error: rule name R3, pattern location 0 (malformed slot)
    [condition type: RULE-PARSING-ERROR]

Since by Lisa's semantics of OR this is supposed to expand into two
rules, you could always just code them yourself:

(defrule r3-1 ()
    (t1 (s s1)
    =>
    (format t "from rule r3 . ~%")))

(defrule r3-2 ()
    (t2 (s s2)
    =>
    (format t "from rule r3 . ~%"))

-- 
Andrew Philpot
USC Information Sciences Institute
·······@isi.edu
From: lisp linux
Subject: Re: Lisa or rule syntax
Date: 
Message-ID: <AcudndkXOeyse0_anZ2dnUVZ_hSdnZ2d@comcast.com>
Andrew Philpot wrote:
> On 2008-03-07, lisp linux <·········@lisp.linux> wrote:
>> Hi
>>
> [snip]
>> (defrule r3 ()
>>    (or (t1 (s s1))
>>        (t2 (s s2)))
>>    =>
>>    (format t "from rule r3 . ~%"))
> [snip]
> 
> This syntax did work on lisa 2.4, and I also see that it now (3.2)
> generates a parse error:
> 
>   Error: Rule parsing error: rule name R3, pattern location 0 (malformed slot)
>     [condition type: RULE-PARSING-ERROR]
Thank you for verifying.
> 
> Since by Lisa's semantics of OR this is supposed to expand into two
> rules, you could always just code them yourself:
> 
> (defrule r3-1 ()
>     (t1 (s s1)
>     =>
>     (format t "from rule r3 . ~%")))
> 
> (defrule r3-2 ()
>     (t2 (s s2)
>     =>
>     (format t "from rule r3 . ~%"))
> 

Yes. This was just a stripped down test case to show the problem i ran into.
It would not be much fun if I have to figure out what high level stuff is buggy and translate them 
to low level primitives by hand.
Anyone else uses Lisa ? I can't believe something basic like this can be broken and not noticed.

-Antony