[Haskell-cafe] Implementing Mathematica

jerzy.karczmarczuk at info.unicaen.fr jerzy.karczmarczuk at info.unicaen.fr
Thu May 31 06:39:14 EDT 2007


This will be a long sermon. Sorry. 

Lennart Augustsson writes: 

> Why do you seem so in awe of Mathematica?  It's just another language with 
> a good set of libraries.  Claims that it is the best, fastest, etc comes 
> from Wolfram advertising, no doubt. :)

All this discussion began to degenerate a bit (I don't know why,
but it happens almost always when people begin to speak about
Mathematica in a context far from it... There is, it seems, some
Original Sin in this business, but most of you are too young to
remember the well known Wolfram Controversy when SMP transmuted
into Mathematica...) 

Anyway... 

Mathematica made its career not as a *language*, and not immediately
as a set of libraries, but as an *integrated package* capable of doing
SYMBOLIC mathematics, with a very decent user interfacing and graphics
a bit better than its competitors. 


The conditions of its career were far from obvious. The World had many
symbolic math packages: Reduce, Macsyma, Schoonschip (beloved by high-
energy physicists), Maple, Scratchpad2/Axiom, later MuSIMP/MuMATH for
small platforms, etc. The group of Wolfram knew all that, they knew that
in order to implement something reasonable, one has to fulfil several
conditions. 

* The algebraic expressions must have a sound design, there must be a
 sufficiently universal, yet efficient representation of math formulae.
 For the polynomial arithmetic this is trivial, it is one of my standard
 Haskell exercices at the undergraduate level. The symbolic differentia-
 tion as well.
 But already the polynomial factorization may be a mess, and requires
 a good deal of algorithmic knowledge. I am reluctant to believe that
 anybody implemented this in 4 days... Anybody tried Zassenhaus? Not
 *too* complicated, implemented in Pari and elsewhere, but quite
 elaborate.
 For general functors the *simplification* issue is not decidable. You
 can't assess a given representation as "the best" formula with a given
 semantics. Again, the simplifier/evaluator is a complicated part of the
 package, not something you can do in a few days.
 Please, have a look on the internal structure of DoCon of Sergei
 Mechveliani, he did a lot of work in Haskell, and the story is still
 incomplete.
 (Let's omit the real mess, for example the Risch symbolic integration
 algorithms, efficient Gröbner bases, etc.) 

* First symbolic packages treated *first* the symbolic expressions as
 something to be evaluated/simplified. One sees that Maple has been built
 on this principle.
 Mathematica changed a bit the perspective, along - perhaps - the same
 lines as Schoonschip, where the fundamental stuff was *rewriting/
 transformations*. So, Mathematica since the begininng was equipped with
 a very powerful pattern-matcher/substitution contraption. For the sake
 of efficiency it was less powerful than a general unifier, but it was
 really nice (and it existed already in SMP, before the birth of
 Mathematica). Now, again, somebody would do that in 4 days??
 The semantic pattern-matcher within an algebraic package, is worlds
 apart from the syntactic/structural pattern-matcher of Haskell.
 This helped a lot to popularize Mathematica, and has been shamelessly
 abused in the advertising, where our friends used to say "we DO
 MATHEMATICS with computers". Non-sense, of course... 


* All the numerical, standard stuff, the interface between the symbolic
 and the numerical functions, with plots 2D/3D, etc. Too often people
 speak about that, comparing, say, Matlab with Mathematica (while Matlab
 has no symbolics, although, being a decent object-oriented language, has
 tools which permitted the construction of symbolic toolboxes, the linking
 of the Maple library, etc.)
 Here the Mathematica team did a serious, thorough job, trying to adapt
 the richness of this layer to many branches of science and engineering.
 It was mainly a compilation process, they hardly added anything new, but
 made a coherent, useful library. Won't repeat it in 4 days, or even in
 4 months. 

=====================================
Is there any sense in "making Mathematica with Haskell"? As a package,
most certainly no, too much to implement, for what? In order to have
another tool of the kind which already exists?
Sergei did a feasibility study, and worked hard on the interplay between
mathematical structures and the Haskell type system.
This, surely, *IS* a useful work. And it should continue. 

We (in the generic meaning of the True Believers in the Functional Church)
can implement other things, for example some formal mathematics dealing
with logic, or with the category theory, or with the computational geometry
or with (my dream) the *true* implementation of quantum calculi. 

Knock, knock! Wake up, the sermon is over. 

Jerzy Karczmarczuk 




More information about the Haskell-Cafe mailing list