Well, the problem is that i is not known to be an integer.
You could try this:
matchdeclare (i, lambda ([e], integerp (e) or featurep (e, integer)));
and then after the rule,
declare (i, integer);
or you relax the matchdeclare for i to accept any symbol:
matchdeclare (i, symbolp);
and then it will match i without any declaration for i.
HTH
Robert Dodier
On 4/26/11, beren olvar <beren.olvar at gmail.com> wrote:
> Hi,
>
> I'm using tellsimp to write some simple rules to work with some operators
> (a, ad) acting on some vectors(ket,bra).
> So far I have something like this:
>
> basis:{a,ad}$
> basisp(x):=elementp(x,basis)$
> ketp(x):=is(equal(op(x),ket))$
>
> matchdeclare(K1,ketp )$
> matchdeclare(Z1,basisp)$
> matchdeclare (i,integerp)$
>
> simp:false$
> tellsimp(Z1[i].K1, evolve(Z1,i,K1))$ /*operator acting over a state (ket)*/
> simp:true$
>
> where evolve is a function I have defined before.
> The problem is that if I use the basis elements "a" or "ad" explicitly it
> works,for example:
> a[1].ket(0,0,0,0);
> gives
> (%o1) evolve(a,1,ket(0,0,0,0))
>
> but if I do something like
> r:a[i]$
> r.ket(0,0,0,0);
>
> it will just write
> (%o2) a[i] . ket(0,0,0,0)
>
> and "evolve" will not be called as it should. Is there a way I can force the
> last expansion before the simplification is attempted so my rules are used?
> Do you know of any other way I should try doing this?
>
> Thank you very much
> Regards
> Fernando
>