|
From: Richard F. <fa...@be...> - 2014-07-24 15:17:00
|
(July 24, 2014) copy the directory http://www.cs.berkeley.edu/~fateman/lisp/mma4max I've mucked around with the MockMMA code from years ago. This code does a lot more than pattern matching (e.g. symbolic integration, rational simplification ....) but the part that is specifically being interfaced and described here with respect to Maxima is the pattern matcher. I'm assuming you know something of pattern matching in Mathematica. If not, the next few paragraphs will not make much sense. ............ From the README file This is a touch-up for Maxima, GCL in particular, allowing what appears to be direct access to the pattern matching in MockMMA. Actually there is some translation to and from the MockMMA representation from Maxima. Until someone comes up with an alternative simple Maxima syntax for patterns like those in Mathematica, we will use the roughly equivalent FullForm style patterns. Though we use () instead of []. Thus Mathematica's _ is Blank() a_ is Pattern(a,Blank()) a__ is Pattern(a,BlankSequence()) a___ is Pattern(a,BlankNullSequence()) a_foo is Pattern(a,Blank(foo)) a?fooq is PatternTest(a,fooq) Now if you don't like to write these things explicitly you can, for example, write z:Pattern(a,BlankNullSequence()) and use z in patterns. There are a host of uses of patterns in Mathematica that we do not explicitly or implicitly support, e.g. member, subst, but which could be programmed. We can (already do) support in MockMMA the pattern-replacement evaluation typical of Mathematica. However, this is in conflict with the usual Maxima evaluation process, and so the support here implicitly is for the Maxima user to convert the data into the mma format, mess around with it for a while with a different model of evaluation, and convert it back. Here's what we support "out of the box" here, as of July 24, 2014. A program sm (for simple match) sm(p,e,vars) is how it is called. p is a pattern e is an expression to be matched vars is a list of variables whose binding is of interest. sm(Pattern(aa,BlankSequence())+x, y+z+x,[aa]); returns [aa=z+y] sm(Cos(Pattern(a,Blank()))+Pattern(a,Blank()), x+Cos(x),[a]); returns [a=x] sm(Cos(Pattern(a,Blank()))+Pattern(b,Blank()), y+Cos(x)+z,[a,b]); returns [a=x,b=z+y] sm(Cos(Blank()),43,[]) returns false .......... the README file continues with installation instructions etc. I'm happy to receive comments. However, be alerted to the possibility that the bugs you find may be your "user errors" in designing patterns, rather than the pattern matching code itself. So look carefully. Not that the code is so perfectly written etc. Just that in my own personal experience, I'm far more likely to write a bad pattern than to newly discover a bug in the matching code. There is a file hey.batch with about 140 patterns in MockMMA syntax testing various features. And a whole bunch of other stuff after that to exercise MockMMA's general programming. None of this will work directly in Maxima because the syntax is not Maxima syntax. It is entirely possible to have Maxima read MockMMA syntax, e.g. (%i54) Convert2Maxima("a_+Cos[a_]") but then where do you go with that? Also there are sticky parts of the parsing program with respect to low-level input of characters.. it doesn't seem to work with wxmaxima but is ok in simpler modes. Maybe switching readtables is problem?? This stuff described here sm(p,e,vars) does not use the parser. RJF |