JESS: [EXTERNAL] Second order JESS?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

JESS: [EXTERNAL] Second order JESS?

Sam Sarjant
Hello,
  I'm looking to use JESS within an application where second-order logic is needed (or at least it makes things easier). Does JESS support second-order logic in any form?

For example, a rule such as:
(ruleDef (factPredicate ?foo) (factArgs ?bar))
=>
(assert (?foo ?bar)))

is an example of the structure I am looking for (where factPredicate is a String slot and factArgs is a multislot). The LHS of the rule compiles fine (with the appropriate ruleDef deftemplate), but the RHS throws an exception as it is expecting a template name after assert.

--
- Thanks, Sam Sarjant
Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Second order JESS?

Friedman-Hill, Ernest
You can build the fact you want as a string and assert that — for example

(assert-string (str-cat "(" ?foo " " ?bar ")"))


From: Sam Sarjant <[hidden email]>
Reply-To: <[hidden email]>
Date: Sun, 15 Apr 2012 13:21:47 +1200
To: <[hidden email]>
Subject: JESS: [EXTERNAL] Second order JESS?

Hello,
  I'm looking to use JESS within an application where second-order logic is needed (or at least it makes things easier). Does JESS support second-order logic in any form?

For example, a rule such as:
(ruleDef (factPredicate ?foo) (factArgs ?bar))
=>
(assert (?foo ?bar)))

is an example of the structure I am looking for (where factPredicate is a String slot and factArgs is a multislot). The LHS of the rule compiles fine (with the appropriate ruleDef deftemplate), but the RHS throws an exception as it is expecting a template name after assert.

--
- Thanks, Sam Sarjant
Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Second order JESS?

David Scuse
An alternative that would permit you to manipulate your facts
in a somewhat second-order manner is to define a predicate such as my-fact
and then use:
    (assert (my-fact ?foo ?bar))
 
This way, ?foo is no longer a predicate but instead is a term within the fact my-fact.
----- Original Message -----
Sent: Monday, April 16, 2012 10:27 AM
Subject: Re: JESS: [EXTERNAL] Second order JESS?

You can build the fact you want as a string and assert that — for example

(assert-string (str-cat "(" ?foo " " ?bar ")"))


From: Sam Sarjant <[hidden email]>
Reply-To: <[hidden email]>
Date: Sun, 15 Apr 2012 13:21:47 +1200
To: <[hidden email]>
Subject: JESS: [EXTERNAL] Second order JESS?

Hello,
  I'm looking to use JESS within an application where second-order logic is needed (or at least it makes things easier). Does JESS support second-order logic in any form?

For example, a rule such as:
(ruleDef (factPredicate ?foo) (factArgs ?bar))
=>
(assert (?foo ?bar)))

is an example of the structure I am looking for (where factPredicate is a String slot and factArgs is a multislot). The LHS of the rule compiles fine (with the appropriate ruleDef deftemplate), but the RHS throws an exception as it is expecting a template name after assert.

--
- Thanks, Sam Sarjant