rules for non-commutative-multiplication




On Tue, 16 Feb 2010, Reinhard Oldenburg wrote:

< Hallo all,
< I ran into problems when setting rules for the non-commutative multiplication
< operator .
< It seems that rules don't take advantage of associativity.
< I tried to implement three-dimensional geometric algebra with the
< following commands (comment: Of course I now that one should use matchdeclare
< to avoid repetion of similair lines, but I want to make the rules to be easily
< understandable by students):
< 
< tellsimpafter(e[1].e[1],1)$
< tellsimpafter(e[2].e[2],1)$
< tellsimpafter(e[3].e[3],1)$
< tellsimpafter(e[2].e[1],-e[1].e[2])$ tellsimpafter(e[3].e[2],-e[2].e[3])$
< tellsimpafter(e[3].e[1],-e[1].e[3])$
< 
< With this, e[2].e[1] simplifies as expected to -e[1].e[2] but
< e[2].e[1].e[3] does not. How can one trick tellsimpafter into taking
< advantage of associativity?
< Any hints?
< Reinhard
 

Reinhard, this is a good problem.

First, the problem is not associativity, but rather that the default
(dotassoc:true) automatically converts a.b.c to a.(b.c). Note that you
do not see this in the output. You can see that this will frustrate 
application of your rules.

So, I looked at the last example in ? tellsimpafter. It looks
impressive, but it also does not implement all the simplifications
needed. So, after a bit of experimentation, here is what I came up
with

kill(rules);
basis:{e[1],e[2],e[3]};
gt (i, j) := integerp(j) and i < j;
basisp(x):=block([t],
                 t:elementp(x,basis),
                 print("basisp",x,t),
                 t);
basisp_aa(x):=block([t],
                 t:elementp(x,basis),
                 print("basisp aa",x,t),
                 t);
matchdeclare (i, integerp, j, gt(i));
matchdeclare(X,basisp_aa,Y,basisp,Z,basisp,W,basisp);
simp:false;
tellsimp (X^^i, X^mod(i,2));
tellsimp (W.(Y.Z),(W.Y).Z);
tellsimp (e[i] . e[j], -e[j] . e[i]);
simp:true;
e[1].e[2].e[1];
e[2].e[1].e[2];

I put in the print statements to track the simplifier, and I left them
in because you might like to see how the simplifier works through the
simplification. 

Also, note that I use tellsimp, not tellsimpafter. If you use the latter, you don't get
all the simplifications needed. 

You will see that both triples are correctly simplified and the
simplification rules are really quite natural to read. 

Leo

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.