expand before simplification?



Thanks for your answer, but I think that is not the problem.
For instance, if I write a[1].a[2].a[3].ket(1)
it works, whereas, if I use
r:a[1].a[2].a[3];
r.ket(1)
it doesn't. So I think the rule applies. I'll try your suggestion 
anyways as soon as I can.

Regards
Fernando

On 4/27/2011 5:40 PM, Robert Dodier wrote:
> The problem is that (a . b) . c doesn't match the rule even
> though a . c or b . c does match the rule.
> Try extending basisp to recognize products of operators:
>    basisp (x) := op (x) = 'ket or (op (x) = "." and every (basisp, args (x)));
> I didn't try that; it might be wrong.
> It turns out the problem doesn't really have anything to do with
> using intermediate variables, for what it's worth.
>
> best
>
> Robert Dodier
>
> On 4/27/11, Fernando Aguayo<beren.olvar at gmail.com>  wrote:
>> Oops!
>> It seems I oversimplified the example, and my mistake of writing an "i"
>> instead of 1 lead me to think it was good enough. Let me show you a more
>> complete (non) working example of what my problem is:
>>
>> I need to use several operators over a "vector", so I make the following:
>>
>> kill(rules)$
>> dotdistrib:true$
>> dotscrules:true$
>> basis:{a,ad}$
>>
>> basisp(x):=elementp(x,basis)$
>> ketp(x):=is(equal(op(x),ket))$
>>
>> matchdeclare (i,integerp)$
>> matchdeclare([Z1,Z2,Z3],basisp)$
>> matchdeclare(K1,ketp )$
>>
>> simp:false$
>> tellsimp(Z1[i] . K1, ket(evolve(Z1,i,K1)))$
>> simp:true$
>>
>> phi:ket(n)$
>> r:a[1].ad[2]$
>> a[1].ad[2] . phi;
>> r.phi;
>>
>> So, is basically the same, but now I'm using two operators. The output
>> of this is:
>> (%o33) |evolve(a,1,|evolve(ad,2,|n>)>)>
>> (%o34) a[1] . |evolve(ad,2,|n>)>
>>
>> (I have defined the output of ket(n) as |n>)
>> So If I write the complete expression it will work, but if I use an
>> auxilary variable it
>> will apply the rule correctly once, but not the second time. This happes
>> for any
>> number of operators. How can I make it apply the rules for the whole
>> expression?
>>
>> Thanks!
>>
>> On 4/27/2011 12:00 AM, Robert Dodier wrote:
>>> 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
>>>>
>>