defrule and apply1



On Thu, Sep 9, 2010 at 5:56 AM, Marek Pietrow <mrk at kft.umcs.lublin.pl> wrote:

> matchdeclare(s1,constantp,s2,constantp)$
> declare(C1,constant,C2,constant)$
> defrule(r11, A( ? W1(a),s1*W2(a)),s1*A(W1(a),W2(a)))$
> defrule(r12, A(s1*W1(a), ? W2(a)),s1*A(W1(a),W2(a)))$
> defrule(r13, A(s1*W1(a),s2*W2(a)),s1*s2*A(W1(a),W2(a)))$
> wyr:A(C1*F1(a),C2*F2(a))$
> apply1(wyr,r11,r12,r13);
> *
> do not work properly. There appeared A(C1*F1(a),C2*F2(a)) instead of
> expected
> C1*C2*A(F1(a),F2(a)). Why is this so?

As stated, r11 etc only match expressions in which W1(a) appears.
F1(a) isn't the same, so it doesn't match.

Probably you want something like

matchdeclare ([s1, s2], constantp, [t1, t2], lambda ([e], not constantp (e)));
defrule (r13, A (s1*t1, s2*t2), s1*s2 * A (t1, t2));

and so for r11 and r12.

HTH

Robert Dodier