patterns



On 8/21/13 1:13 PM, Robert Dodier wrote:
> On 2013-08-14, Richard Fateman <fateman at gmail.com> wrote:
>
>> For a start, let me observe that the pattern matching program has
>> undergone some alterations since I wrote it in 1969 or so.
There was a rewrite of it by someone at Symbolics, but that has
not been transferred to Maxima.
> Yeah -- I've fixed a lot of bugs.
No doubt -- some that you introduced and fixed, too.
>>     Some of these changes are noted in the source code and consist of the
>> disabling of error messages.  Some accompanying comments indicate
>> that ...  because some programmer who went into the code and did not
>> understand it and did not understand the message, did not ask the author
>> for clarification, decided to just strike it out.
> I don't suppose you're willing to talk about specifics here.
Sure, the one I just noticed was right in the code in the defmatch file. 
There may be others
elsewhere or that have been removed and would require looking in source 
code control
or text comparison.

>
>> Secondly, the process of pattern matching generally puts the objects
>> being matched into a canonical form, so that in trying to match (y-yy)^2,
>> before anything happens, that expression is changed to  y^2-2*y*yy+yy^2.
> No, it doesn't, and it shouldn't.
Um, searching for the coefficients of terms like y, y^2, y^3 is done by 
extracting
coefficients from a rational expression.  There are ways to defeat this 
mechanism
but they generally lead to confusion.
example
matchdeclare([a,b],true);
defmatch(qq,a*x^2+b);
qq((x+1)^3); -->     b = x^3  + 3 x + 1, a = 3]

So my reaction is

Yes it does and yes it should.  If you are writing patterns that avoid this
(i.e. are not picking out coefficients from a polynomial, in effect) expect
to be confused.

You can, if you wish, define another pattern matcher that does something
else  (like the Mathematica matcher which I wrote in Lisp.  Would that
be more or less confusing?  Hard to say.  I haven't tried to fully integrate
it into Maxima.  The Mathematica overall philosophy involves making
too much that is already in Maxima operate differently.)

There is of course the possibility that additional pattern matching
ideas would surpass anything we have in any computer algebra system
in utility and comprehensibility.

In which case I think different command names should be used.

RJF




>
> Robert Dodier
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima