I found that I can progress most quickly modeling on Mathematica. The design is fairly simple and consistent. Of course the documentation is vague in some places, but so far, it is not a problem. Of course, even if you know logically what the rules should do, there is still the matter of building data structures and applying them. I am more concerned now in getting correct logical behavior than efficient application of rules. I want to see a cohesive system. A lot of risk is reduced, because we know Mathematica works. But, it is good to develop ideas about efficient implementation at the same time, and there is no avoiding it when doing commutative matching.
I installed sympy, but have not played with it yet, but I definitely will. I've looked just a bit at the code. If you have any experience optimizing pattern matching, or other resources, I'd like to hear about it.
Another resource is Richard Fateman's mma4max, which I see has updates since I last built it. It aims more or less to implement mma in common lisp. In fact it has a Julia-compatible license and a complete parser written in common lisp. IIRC the comments show that the pattern matcher is not perfect, but I think it is complete.
In [2]: x = symbols('x')
In [3]: y, z = symbols('y z', commutative=False)
In [4]: x*y == y*x
Out[4]: True
In [5]: y*z == z*y
Out[5]: False
Another resource is Richard Fateman's mma4max, which I see has updates since I last built it. It aims more or less to implement mma in common lisp. In fact it has a Julia-compatible license and a complete parser written in common lisp. IIRC the comments show that the pattern matcher is not perfect, but I think it is complete.
Maybe the parser could be useful if rewritten in Julia:
I am more concerned now in getting correct logical behavior than efficient application of rules.
Side tracking a bit, but one of the reasons I use SymPy instead of something like Maxima is that it meshes seamlessly into the language infrastructure. By writing a parser and creating another system means that it can't use julia's ecosystem without modification. I'd rather see a CAS work within Julia's parser framework. But that's just me.
It is an open source Wolfram Mathematica interpreter written in Python, and uses SymPy as a callback for math algorithms.
You may try it from your browser:
http://www.mathics.net/
If you wish to try sympy out, I may suggest to run " isympy -I " from the console.
Maybe the parser could be useful if rewritten in Julia:
http://www.cs.berkeley.edu/~fateman/lisp/mma4max/parser.lisp
Maybe the parser could be useful if rewritten in Julia:Side tracking a bit, but one of the reasons I use SymPy instead of something like Maxima is that it meshes seamlessly into the language infrastructure. By writing a parser and creating another system means that it can't use julia's ecosystem without modification. I'd rather see a CAS work within Julia's parser framework. But that's just me.
I am more concerned now in getting correct logical behavior than efficient application of rules.Making it just *work* is certainly a priority, but design decisions made now can make things tricky later on. Especially with the design of your internal representation. How you represent expression trees and assumptions can seriously affect the performance of matching/traversals/replacements.
A Mathematica parser could be used as an optional addition, such as what Mathics is to SymPy.
Anyways, there are various options for Julia:
- use Expr and operate on them, this is similar to how Maxima works.
This is interesting and has advantages, but is not what I am looking for, at least not now. I suppose hybridizing etc. is possible
> create a DSL invoked by a macro, this appears to be the case for SJulia
Yes, the macro is just a way to allow more syntax than nested expressions. And this is really the same as your first item, as well.
Using the macro is much easier than writing or modifying a parser.
I expect that at some point, all of these options will be tried with Julia.
To be more clear: First I think the ideas in this thread will be used
in Julia projects in interesting ways we aren't even thinking of---
it's well suited for all of them. At the moment, I'm only interested in
implementing a pattern and rule based system something like
Mathematica. An example of why, is the Rubi integration package
http://www.apmaths.uwo.ca/~arich/
Even if I or someone else, got the all the basic pattern matching
implemented, Rubi (for instance again) still uses Simplify and other
features.
> I read that the next version of Rubi will feature a decision tree, no longer pattern matching.
Interesting. I don't see it, do you have a link?
@ex f(x_, y_Integer, z) := ...
@ex f(x, y::Integer, :z) := ...
On Tuesday, January 27, 2015 at 12:34:43 PM UTC+1, John Lapeyre wrote:> I read that the next version of Rubi will feature a decision tree, no longer pattern matching.
Interesting. I don't see it, do you have a link?
By the way, I was thinking about the syntax, what about instead of
@ex f(x_, y_Integer, z) := ...
AC matching is a b$&%h. For me, there's no sense in continuing the experiment unless I'm convinced the harder stuff can be done.
Of course if you, or someone else want a particular feature to play with, I'd gladly consider implementing it. At present, I consider using the stock Julia parser a stopgap. I did spend some time with the RJF parser and even found a minor bug or two. I also looked at the Julia parser. For me, it looks like a big job. But, if someone else wants to do it, great!