[GiNaC-list] Pattern matching versus non-commutative products (Was: Ordering and pattern matching)

Chris Kelly giltirn at gmail.com
Wed Aug 26 16:37:49 CEST 2009


Hi Alexei,

Thank you for your reply.

On Wed, Aug 26, 2009 at 7:01 AM, Alexei Sheplyakov <varg at metalica.kh.ua>wrote:

> The pattern matching operates on internal representation (in other words
> the matching is `syntactic', not algebraic). It tries to be smart(er) and
> handles sums and _commutative_ products in a special way (to account
> commutativity and associativity), but these tricks are not applicable to
> non-commutative products and/or tensors (a.k.a. indexed). Fortunately you
> don't need pattern matching to solve your problem. Simply choose
> appropriate
> basis (for 4-dimensional space with Minkowski metric that would be the set
> {1, gamma_mu, i/2 [ gamma_mu, a gamma_nu ], gamma_5, gamma_5 gamma_mu }),
> and operate on (commutative) coefficients.
>

The larger problem i am trying to solve is to find the solution to a set of
simultaneous equations involving gamma matrices and objects that can be
represented by sums over products of gamma matrices. This is to be solved in
Euclidean space rather than the canonical Minkowski space.

The equations have the form
S_i = a*Y + b*Y*PR*S_j + c*Y*PL*S_k

where i,j,k are indices, lower-case objects are commuting coefficients and
capitalised objects are non-commuting objects that can be represented by
sums over products of gamma matrices as you say. I am solving for the 'S'
objects, and PR,PL and Y are known, as are the commuting coefficients.

A general way of representing an object on 16 element basis of dirac matrix
products and the unit matrix would be as a 16 component vector. These must
be defined as non-commuting object such that the correct ordering is
retained and I would also need to write code defining the product of these
objects. In all it looks like I would be better off sticking to the existing
clifford algebra for this more complicated problem, although it would
certainly simplify the simpler problem that I posed in the previous email.


>
> > #include<iostream>
> > #include<vector>
> > #include<sstream>
> > #include<ginac/ginac.h>
> > using namespace std;
> > using namespace GiNaC;
> >
> > //Aim is to identify A_mu gamma_mu B_nu gamma_nu == A_mu B_nu delta_mu,nu
> > int main(){
> >
> >   ex metric = unit_matrix(4);
> >   idx i(symbol("i"),4) , j(symbol("j"),4);
> >   // Use generalised clifford gamma matrices for euclidean space
> >   ex al_i = clifford_unit(i,metric);
> >   ex al_j = clifford_unit(j,metric);
> >
> >   //Create generic 'slashed' symbols with euclidean metric
> >
> >   ex s1 = indexed(symbol("A"),i)*al_i;
> >   ex s2 = indexed(symbol("B"),j)*al_j;
> >
> >   //Form the product
> >   ex prod = s1*s2;
> >
> >   cout << s1*s2 << endl;
> >
> >   //Attempt to match to patterns
> >   idx w1(wild(1),4), w2(wild(2),4);
> >   indexed in2_w1 = indexed(wild(2),w1);
>
> Perhaps you mean wild(4) (not wild(2)) here.
>

Indeed. Upon correcting this bug I find that the first set of patterns
(which as you say are all ordered to the same form) now sometimes match the
input.

Unfortunately there are still instances in running when neither pattern
matches the input.

Is there some way to canonically order an expression by a set of rules
rather than by the hash value such that i can find a pattern that is
guaranteed to match?

Thanks,
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cebix.net/pipermail/ginac-list/attachments/20090826/daaacbe9/attachment.htm>


More information about the GiNaC-list mailing list