[Haskell-cafe] Implementing Mathematica

jerzy.karczmarczuk at info.unicaen.fr jerzy.karczmarczuk at info.unicaen.fr
Thu May 31 19:35:32 EDT 2007


Jon Harrop after myself: 

>>  The semantic pattern-matcher within an algebraic package, is worlds
>>  apart from the syntactic/structural pattern-matcher of Haskell.
> 
> Can you elaborate on this? 
> 
> I would imagine that the pattern matcher in a term-level Haskell interpreter 
> would be quite similar to one from a toy Mathematica-like rewriter. 
> 
> Also, what aspects of this do you think would take more than 4 days?

Well, I don't know what is your definition of "toy". I can make in about
15 minutes a toy atomic bomb, using Lego.
Certainly, there is a possibility and need for syntactic pattern matching,
as in Haskell, although the identification of common terms is so important
that I would rather use a unification procedure, like in logic languages.
But this is not enough for computer algebra. OK, if you wish some SIMPLE
examples (among infinitely more) of something beyond... 

* the simplification of rational expressions, beginning with the reduction
 of (x^2-1)/(1+x)-x = 1, ending with a full polynomial factorizer...
 Gathering of all the 'x in  a+x+b+x+ ... + x + ... so as to get M*x is
 already not so trivial, and requires some decisions. Will you keep your
 expressions sorted? How?...
* sin(z)^2 + ... + cos(z)^2 should simplify to 1 + ... independently of z,
 so the equivalence of shared expressions should be treated seriously. 

We are usually not interested in 'term-level' trivialities. 

If you look at the plethora of pattern-matching functions in Mathematica,
all those MemberQ, MatchQ, FreeQ, all those DeleteCases, the functions which
give you the *position* at which a given pattern occurs within a formula,
etc., you become a bit modest. If you add to it the possibility/necessity
of renaming the variables in patterns present within the Function[{x}...]
formulae, you see that just assimilating the documentation needs something
like 4 days. Of course, this is not restricted to Mathematica. All Comp.
Algebra systems have such tools. 

But, OK, I am old, tired and slow. There are, fortunately for us, some
people very fast and efficient. 


Jerzy Karczmarczuk. 


PS. Somebody (A. Coppin?) said that Mathematica not without reason costs
10000.
Weeeeelll, less than 2000, and for students there are much cheaper possibi-
lities. I am the last to make free ads for Wolfram, I recommend the usage
of Axiom and Maxima to my students, but there is no need to say publicly
some dubious truths about commercial software. 




More information about the Haskell-Cafe mailing list