MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Can Mathematica be used as expert system (rule-based computations like CLIPS?)

  • To: mathgroup at
  • Subject: [mg28424] Re: Can Mathematica be used as expert system (rule-based computations like CLIPS?)
  • From: "John Doty" <jpd at>
  • Date: Wed, 18 Apr 2001 03:23:27 -0400 (EDT)
  • References: <9bgfah$>
  • Sender: owner-wri-mathgroup at

Instead of "->" (Rule), use ":>" (RuleDelayed). RuleDelayed evaluates its
RHS *after* it is used, so you can arrange for the consequences of
evaluation to do what you want, when you want it.

It may be useful to use ";" (CompundExpression) within the delayed
replacement. This evaluates and discards its LHS (for your actions), and
yields its (evaluated) RHS (in this case, a handy placeholder to indicate
the action has been taken).

In[1]:= r = a :> ( Print[ "Side Effect!" ]; aDone )

Out[1]= a :> (Print[Side Effect!]; aDone)

In[2]:= a /. r
Side Effect!

Out[2]= aDone

In article <9bgfah$deg at>, "Rudy Cazabon"
<raygunprez at> wrote:

> Hi everyone...
> I would like to know if anyone could comment on whether Mathematica can
> be used as an expert system?
> I have been looking into several expert systems out there that are of a
> rules-based paradigm.  Specifically, one called CLIPS developed by NASA.
> The upside is that CLIPS is available and it works.  The downside is
> that it does not have an expansive set of mathematical tools in
> available to it. Although CLIPS is open source and can be modified any
> which way you want and need, the task of getting it to talk
> back-and-forth to Mathematica to request math computations and the such
> would be development effort on its own.
> So, I would like to explore the possibility of hosting some of these
> expert-system capabilities using Mathematica's symbolic capabilities.
> However, these are the portions that I am somewhat at a loss with
> regards to Mathematica rules applications and pattern-matching...
> In the CLIPS system you define a rule as follows:
> (defrule <rule name> [<optional comment>]
>     <1-or-more patterns>* ;; this corresponds to the LHS of a rule
>     statement
>     =>  ;; the THEN operator like in "if A = B THEN B is blah"
>     <1-or-more actions>* ;; if the pattern matches, do something
> )
> however, from what I can see, in Mathematica the definition of rules is
> expr /. LHS -> RHS
> and that pattern definition is LHS->RHS .
> So, my question is ... rather than getting a rule to perform a
> replacement operation can I get it to do an arbitrary operation?

| John Doty		"You can't confuse me, that's my job."
| Home: jpd at
| Work: jpd at

  • Prev by Date: Re: conditionals during nonlinear regression
  • Next by Date: MatrixTemplate (Generalization)
  • Previous by thread: Re: Can Mathematica be used as expert system (rule-based computations like CLIPS?)
  • Next by thread: circular plot question