Dear Stavros,
Many thanks for these helpful comments. I had already begun with the last
suggestion, that of defining parallel noun forms of the arithmetic
operators. I shall pursue this option first.
Chris
On Tue, 7 Feb 2006, Stavros Macrakis wrote:
> >
> > (1) Is it possible to perform only "steps" in the calculation. That
> > is to say, perform only one simplification at a time?
>
>
> The simplest way is probably using Box'es to isolate subexpressions from the
> simplifier, e.g.
>
> box(2*x)+box(3*x)
>
> does not simplify. Take a look at the whole series of box functions.
>
> Another way is to turn off simp and try to fool the simplifier into
> believing some things are already simplified when you turn it back on. But
> this has problems.
> -------------------------
>
> ;; Forces an expression to be treated as simplified -- use with simp:false
> (defun $deemsimp (x)
> (cond ((atom x) x)
> ((memq 'simp (car x)) x)
> (t (cons (append (car x) '(simp)) (cdr x)))))
>
> /* Auxiliary conveniences */
> inop(ex):=block([inflag:true],op(ex));
> inargs(ex):=block([inflag:true],args(ex));
>
> /* Main function */
> onelevelsimp(expr):=
> if atom(expr) then expr
> else
> block([op:inop(expr),
> args:map(deemsimp,inargs(expr)),
> simp:true],
> apply(op,args));
>
> However, the simplifier depends on subexpressions which have been marked as
> simplified to be in a standardized form, and so will not give correct
> results in some cases:
>
> simp:false$
> sx2:deemsimp(x*2)$
> simp:true$
> 2*x - sx2 => 2*x !!!!
>
> ------------------------------------
>
> (2) How would I go about writing a function which selectively
> > simplified on some of the algebraic properties. For example, I'd
> > like to use idempotence and write a function which matched
> >
> > 0*x = 0
> >
> > and identities as
> >
> > 0+x = x
> > 1*x = x
> >
>
> Presumably you'd use the pattern matching system, but I believe it depends
> on the simplifer to drive it.
>
> -----------------------
>
> I think the best solution is to define your own series of non-simplifying
> operators, e.g.
>
> infix("***")$ infix("+++")$
>
> etc. and define pattern matching simplifications on them. When you want to
> use the standard simplifier, swap out the non-standard for the standard
> operators.
>
> Good luck!
>
> -s
>