Search code examples
clips

CLIPS: Not conditional element around class instance match


I read that

CLIPS also gives you the capability of specifying an explicit not conditional element on the LHS. The absence of a fact is specified as a pattern on the LHS using the “not” conditional element.

Yet, the below code gives me a [PRNTUTIL2] Syntax Error: Check appropriate syntax for the not conditional element.

(not
    (object (is-a clips_ASDF)
        (name ?some_name)
        (property ?my_property_var))
    (test (eq ?my_property_var nil)))

This however does not cause an error:

    (object (is-a clips_ASDF)
        (name ?some_name)
        (property ?my_property_var))
    (not
        (test (eq ?my_property_var nil)))

Why is that? How can I do the first?


Solution

  • The not conditional element can only can a single conditional element. If you want to place more than one, surround them with an and conditional element:

       (not (and (object (is-a clips_ASDF)
                         (name ?some_name)
                         (property ?my_property_var))
                 (test (eq ?my_property_var nil))))
    

    Alternately, there's no need for a separate test conditional element:

       (not (object (is-a clips_ASDF)
                    (name ?some_name)
                    (property nil)))