Reversing the order of matching as Stavros says, is one way that
occurred to me, but it may also be reasonable to write a program
foo(e,x):=
block([the_var:x],
/* now you can pattern match on e-the_var etc.
*/
I think that for people who want a matcher that does backtracking and
can involve (say) exponential time, there are a number of them already
around, written in Lisp. In Reduce, in MockMMA.(looks like Mathematica
version 3.0).
These could be put into Maxima. Or a front end could be put on
Schatchen (in Maxima's integration code, named M1, M2, I think) which
is a backtracking pattern matcher written by Joel Moses for his
integrator, SIN.
Exactly how would you like the design to fit in? Replacement of
tellsimp (etc?) or an alternative for matching?
RJF
Stavros Macrakis wrote:
> On 5/9/07, Richard Fateman <fateman at eecs.berkeley.edu> wrote:
>
>>
>> as for matching pp(a1+a2), I suggest you do this:
>>
>> matchdeclare(s,sum_of_two_atoms);
>> sum_of_two_atoms(z):= not(atom(z)) and
>> equal(part(z,0),"+") and length(z)=2 and
>> atom(part(z,1))and atom(part(z,2)
>>
>
> First of all, I do understand that there are some difficult tradeoffs
> here.
> But requiring a mathematical user (as opposed to a programmer) to
> write the
> above rather than a1+a2 is problematic. Of course, the pattern a1+a2
> is not
> particularly useful or interesting mathematically -- it was a simplified
> example
>
> The original example was:
>
> laplace(signum(x-a),x,s)
>
> where x and s are symbols and a is an arbitrary expression that is
> free of x
> (though that wasn't explicitly stated). That is a slightly less
> simple, but
> mathematically meaningful, example.
>
> How would you do that? Given the matcher's left-to-right scan, it
> would seem
> that you'd have to first transform to laplacex(x,s,signum(x-a)), at which
> point the matcher has no problem. Can you do better?
>
> -s
>