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

*To*: mathgroup at smc.vnet.net*Subject*: [mg28424] Re: Can Mathematica be used as expert system (rule-based computations like CLIPS?)*From*: "John Doty" <jpd at w-d.org>*Date*: Wed, 18 Apr 2001 03:23:27 -0400 (EDT)*References*: <9bgfah$deg@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

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 smc.vnet.net>, "Rudy Cazabon" <raygunprez at earthlink.net> 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 w-d.org | Work: jpd at space.mit.edu