applying function identities (proposal)



Robert Dodier wrote on 05/02/2006 09:39:23 AM:

> Hi Barton,
> 
> > Two defrules can display the same, yet be different:
> 
> Yes, this is a shortcoming of the current system.
> However it's easy to remedy -- just carry the matchdeclare
> info along with the rule definition and display the rule as
> 
>   r1 : f(x) -> x f(x - 1) assuming mapatom(x)
> 
> or something like that.

Oh--I it's possible to make different rules display differently:

(%i1) matchdeclare(z,true)$
(%i2) defrule(r1, f(z), if mapatom(z) then z * f(z-1) else f(z));
(%o2) r1:f(z)->(if mapatom(z) then z*f(z-1) else f(z))
(%i3) apply1(f(x+y),r1);
(%o3) f(y+x)
(%i4) apply1(f(x),r1);
(%o4) x*f(x-1)
(%i5) disprule(r1);
(%t5) r1:f(z)->(if mapatom(z) then z*f(z-1) else f(z))

(%i1) matchdeclare(z,true)$
(%i2) defrule(r2, f(z), if integerp(z) then z * f(z-1) else f(z));
(%o2) r2:f(z)->(if integerp(z) then z*f(z-1) else f(z))
(%i3) disprule(r2);
(%t3) r2:f(z)->(if integerp(z) then z*f(z-1) else f(z))  <-- kind of 
dangerous
(%o3) [%t3]
(%i4) apply1(f(42),r2);
(%o4) 0