]> www.ginac.de Git - ginac.git/blob - ginac/clifford.cpp
- removed an unused statement in tensor.cpp
[ginac.git] / ginac / clifford.cpp
1 /** @file clifford.cpp
2  *
3  *  Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2002 Johannes Gutenberg University Mainz, Germany
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #include <iostream>
24 #include <stdexcept>
25
26 #include "clifford.h"
27 #include "ex.h"
28 #include "idx.h"
29 #include "ncmul.h"
30 #include "symbol.h"
31 #include "numeric.h" // for I
32 #include "symmetry.h"
33 #include "lst.h"
34 #include "relational.h"
35 #include "mul.h"
36 #include "print.h"
37 #include "archive.h"
38 #include "utils.h"
39
40 namespace GiNaC {
41
42 GINAC_IMPLEMENT_REGISTERED_CLASS(clifford, indexed)
43 GINAC_IMPLEMENT_REGISTERED_CLASS(diracone, tensor)
44 GINAC_IMPLEMENT_REGISTERED_CLASS(diracgamma, tensor)
45 GINAC_IMPLEMENT_REGISTERED_CLASS(diracgamma5, tensor)
46
47 //////////
48 // default ctor, dtor, copy ctor, assignment operator and helpers
49 //////////
50
51 clifford::clifford() : representation_label(0)
52 {
53         tinfo_key = TINFO_clifford;
54 }
55
56 void clifford::copy(const clifford & other)
57 {
58         inherited::copy(other);
59         representation_label = other.representation_label;
60 }
61
62 DEFAULT_DESTROY(clifford)
63 DEFAULT_CTORS(diracone)
64 DEFAULT_CTORS(diracgamma)
65 DEFAULT_CTORS(diracgamma5)
66
67 //////////
68 // other constructors
69 //////////
70
71 /** Construct object without any indices. This constructor is for internal
72  *  use only. Use the dirac_ONE() function instead.
73  *  @see dirac_ONE */
74 clifford::clifford(const ex & b, unsigned char rl) : inherited(b), representation_label(rl)
75 {
76         tinfo_key = TINFO_clifford;
77 }
78
79 /** Construct object with one Lorentz index. This constructor is for internal
80  *  use only. Use the dirac_gamma() function instead.
81  *  @see dirac_gamma */
82 clifford::clifford(const ex & b, const ex & mu, unsigned char rl) : inherited(b, mu), representation_label(rl)
83 {
84         GINAC_ASSERT(is_a<varidx>(mu));
85         tinfo_key = TINFO_clifford;
86 }
87
88 clifford::clifford(unsigned char rl, const exvector & v, bool discardable) : inherited(sy_none(), v, discardable), representation_label(rl)
89 {
90         tinfo_key = TINFO_clifford;
91 }
92
93 clifford::clifford(unsigned char rl, exvector * vp) : inherited(sy_none(), vp), representation_label(rl)
94 {
95         tinfo_key = TINFO_clifford;
96 }
97
98 //////////
99 // archiving
100 //////////
101
102 clifford::clifford(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
103 {
104         unsigned rl;
105         n.find_unsigned("label", rl);
106         representation_label = rl;
107 }
108
109 void clifford::archive(archive_node &n) const
110 {
111         inherited::archive(n);
112         n.add_unsigned("label", representation_label);
113 }
114
115 DEFAULT_UNARCHIVE(clifford)
116 DEFAULT_ARCHIVING(diracone)
117 DEFAULT_ARCHIVING(diracgamma)
118 DEFAULT_ARCHIVING(diracgamma5)
119
120 //////////
121 // functions overriding virtual functions from base classes
122 //////////
123
124 int clifford::compare_same_type(const basic & other) const
125 {
126         GINAC_ASSERT(is_a<clifford>(other));
127         const clifford &o = static_cast<const clifford &>(other);
128
129         if (representation_label != o.representation_label) {
130                 // different representation label
131                 return representation_label < o.representation_label ? -1 : 1;
132         }
133
134         return inherited::compare_same_type(other);
135 }
136
137 bool clifford::match_same_type(const basic & other) const
138 {
139         GINAC_ASSERT(is_a<clifford>(other));
140         const clifford &o = static_cast<const clifford &>(other);
141
142         return representation_label == o.representation_label;
143 }
144
145 void clifford::print(const print_context & c, unsigned level) const
146 {
147         if (!is_a<diracgamma5>(seq[0]) && !is_a<diracgamma>(seq[0]) && !is_a<diracone>(seq[0])) {
148
149                 // dirac_slash() object is printed differently
150                 if (is_a<print_tree>(c))
151                         inherited::print(c, level);
152                 else if (is_a<print_latex>(c)) {
153                         c.s << "{";
154                         seq[0].print(c, level);
155                         c.s << "\\hspace{-1.0ex}/}";
156                 } else {
157                         seq[0].print(c, level);
158                         c.s << "\\";
159                 }
160
161         } else
162                 inherited::print(c, level);
163 }
164
165 DEFAULT_COMPARE(diracone)
166 DEFAULT_COMPARE(diracgamma)
167 DEFAULT_COMPARE(diracgamma5)
168
169 DEFAULT_PRINT_LATEX(diracone, "ONE", "\\mathbb{1}")
170 DEFAULT_PRINT_LATEX(diracgamma, "gamma", "\\gamma")
171 DEFAULT_PRINT_LATEX(diracgamma5, "gamma5", "{\\gamma^5}")
172
173 /** This function decomposes gamma~mu -> (1, mu) and a\ -> (a.ix, ix) */
174 static void base_and_index(const ex & c, ex & b, ex & i)
175 {
176         GINAC_ASSERT(is_a<clifford>(c));
177         GINAC_ASSERT(c.nops() == 2);
178
179         if (is_a<diracgamma>(c.op(0))) { // proper dirac gamma object
180                 i = c.op(1);
181                 b = _ex1;
182         } else if (is_a<diracgamma5>(c.op(0))) { // gamma5
183                 i = _ex0;
184                 b = _ex1;
185         } else { // slash object, generate new dummy index
186                 varidx ix((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(c.op(1)).get_dim());
187                 b = indexed(c.op(0), ix.toggle_variance());
188                 i = ix;
189         }
190 }
191
192 /** Contraction of a gamma matrix with something else. */
193 bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
194 {
195         GINAC_ASSERT(is_a<clifford>(*self));
196         GINAC_ASSERT(is_a<indexed>(*other));
197         GINAC_ASSERT(is_a<diracgamma>(self->op(0)));
198         unsigned char rl = ex_to<clifford>(*self).get_representation_label();
199
200         if (is_a<clifford>(*other)) {
201
202                 // Contraction only makes sense if the represenation labels are equal
203                 if (ex_to<clifford>(*other).get_representation_label() != rl)
204                         return false;
205
206                 ex dim = ex_to<idx>(self->op(1)).get_dim();
207
208                 // gamma~mu gamma.mu = dim ONE
209                 if (other - self == 1) {
210                         *self = dim;
211                         *other = dirac_ONE(rl);
212                         return true;
213
214                 // gamma~mu gamma~alpha gamma.mu = (2-dim) gamma~alpha
215                 } else if (other - self == 2
216                         && is_a<clifford>(self[1])) {
217                         *self = 2 - dim;
218                         *other = _ex1;
219                         return true;
220
221                 // gamma~mu gamma~alpha gamma~beta gamma.mu = 4 g~alpha~beta + (dim-4) gamam~alpha gamma~beta
222                 } else if (other - self == 3
223                         && is_a<clifford>(self[1])
224                         && is_a<clifford>(self[2])) {
225                         ex b1, i1, b2, i2;
226                         base_and_index(self[1], b1, i1);
227                         base_and_index(self[2], b2, i2);
228                         *self = 4 * lorentz_g(i1, i2) * b1 * b2 * dirac_ONE(rl) + (dim - 4) * self[1] * self[2];
229                         self[1] = _ex1;
230                         self[2] = _ex1;
231                         *other = _ex1;
232                         return true;
233
234                 // gamma~mu gamma~alpha gamma~beta gamma~delta gamma.mu = -2 gamma~delta gamma~beta gamma~alpha - (dim-4) gamam~alpha gamma~beta gamma~delta
235                 } else if (other - self == 4
236                         && is_a<clifford>(self[1])
237                         && is_a<clifford>(self[2])
238                         && is_a<clifford>(self[3])) {
239                         *self = -2 * self[3] * self[2] * self[1] - (dim - 4) * self[1] * self[2] * self[3];
240                         self[1] = _ex1;
241                         self[2] = _ex1;
242                         self[3] = _ex1;
243                         *other = _ex1;
244                         return true;
245
246                 // gamma~mu S gamma~alpha gamma.mu = 2 gamma~alpha S - gamma~mu S gamma.mu gamma~alpha
247                 // (commutate contracted indices towards each other, simplify_indexed()
248                 // will re-expand and re-run the simplification)
249                 } else {
250                         exvector::iterator it = self + 1, next_to_last = other - 1;
251                         while (it != other) {
252                                 if (!is_a<clifford>(*it))
253                                         return false;
254                                 ++it;
255                         }
256
257                         it = self + 1;
258                         ex S = _ex1;
259                         while (it != next_to_last) {
260                                 S *= *it;
261                                 *it++ = _ex1;
262                         }
263
264                         *self = 2 * (*next_to_last) * S - (*self) * S * (*other) * (*next_to_last);
265                         *next_to_last = _ex1;
266                         *other = _ex1;
267                         return true;
268                 }
269         }
270
271         return false;
272 }
273
274 /** Perform automatic simplification on noncommutative product of clifford
275  *  objects. This removes superfluous ONEs, permutes gamma5's to the front
276  *  and removes squares of gamma objects. */
277 ex clifford::simplify_ncmul(const exvector & v) const
278 {
279         exvector s;
280         s.reserve(v.size());
281
282         // Remove superfluous ONEs
283         exvector::const_iterator cit = v.begin(), citend = v.end();
284         while (cit != citend) {
285                 if (!is_a<clifford>(*cit) || !is_a<diracone>(cit->op(0)))
286                         s.push_back(*cit);
287                 cit++;
288         }
289
290         bool something_changed = false;
291         int sign = 1;
292
293         // Anticommute gamma5's to the front
294         if (s.size() >= 2) {
295                 exvector::iterator first = s.begin(), next_to_last = s.end() - 2;
296                 while (true) {
297                         exvector::iterator it = next_to_last;
298                         while (true) {
299                                 exvector::iterator it2 = it + 1;
300                                 if (is_a<clifford>(*it) && is_a<clifford>(*it2) && !is_a<diracgamma5>(it->op(0)) && is_a<diracgamma5>(it2->op(0))) {
301                                         it->swap(*it2);
302                                         sign = -sign;
303                                         something_changed = true;
304                                 }
305                                 if (it == first)
306                                         break;
307                                 --it;
308                         }
309                         if (next_to_last == first)
310                                 break;
311                         --next_to_last;
312                 }
313         }
314
315         // Remove equal adjacent gammas
316         if (s.size() >= 2) {
317                 exvector::iterator it, itend = s.end() - 1;
318                 for (it = s.begin(); it != itend; ++it) {
319                         ex & a = it[0];
320                         ex & b = it[1];
321                         if (!is_a<clifford>(a) || !is_a<clifford>(b))
322                                 continue;
323                         bool a_is_diracgamma = is_a<diracgamma>(a.op(0));
324                         bool b_is_diracgamma = is_a<diracgamma>(b.op(0));
325                         if (a_is_diracgamma && b_is_diracgamma) {
326                                 const ex & ia = a.op(1);
327                                 const ex & ib = b.op(1);
328                                 if (ia.is_equal(ib)) { // gamma~alpha gamma~alpha -> g~alpha~alpha
329                                         a = lorentz_g(ia, ib);
330                                         b = dirac_ONE(representation_label);
331                                         something_changed = true;
332                                 }
333                         } else if (is_a<diracgamma5>(a.op(0)) && is_a<diracgamma5>(b.op(0))) {
334                                 // Remove squares of gamma5
335                                 a = dirac_ONE(representation_label);
336                                 b = dirac_ONE(representation_label);
337                                 something_changed = true;
338                         } else if (!a_is_diracgamma && !b_is_diracgamma) {
339                                 const ex & ba = a.op(0);
340                                 const ex & bb = b.op(0);
341                                 if (ba.is_equal(bb)) { // a\ a\ -> a^2
342                                         varidx ix((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(a.op(1)).get_dim());
343                                         a = indexed(ba, ix) * indexed(bb, ix.toggle_variance());
344                                         b = dirac_ONE(representation_label);
345                                         something_changed = true;
346                                 }
347                         }
348                 }
349         }
350
351         if (s.empty())
352                 return clifford(diracone(), representation_label) * sign;
353         if (something_changed)
354                 return nonsimplified_ncmul(s) * sign;
355         else
356                 return simplified_ncmul(s) * sign;
357 }
358
359 ex clifford::thisexprseq(const exvector & v) const
360 {
361         return clifford(representation_label, v);
362 }
363
364 ex clifford::thisexprseq(exvector * vp) const
365 {
366         return clifford(representation_label, vp);
367 }
368
369 //////////
370 // global functions
371 //////////
372
373 ex dirac_ONE(unsigned char rl)
374 {
375         return clifford(diracone(), rl);
376 }
377
378 ex dirac_gamma(const ex & mu, unsigned char rl)
379 {
380         if (!is_a<varidx>(mu))
381                 throw(std::invalid_argument("index of Dirac gamma must be of type varidx"));
382
383         return clifford(diracgamma(), mu, rl);
384 }
385
386 ex dirac_gamma5(unsigned char rl)
387 {
388         return clifford(diracgamma5(), rl);
389 }
390
391 ex dirac_gamma6(unsigned char rl)
392 {
393         return clifford(diracone(), rl) + clifford(diracgamma5(), rl);
394 }
395
396 ex dirac_gamma7(unsigned char rl)
397 {
398         return clifford(diracone(), rl) - clifford(diracgamma5(), rl);
399 }
400
401 ex dirac_slash(const ex & e, const ex & dim, unsigned char rl)
402 {
403         // Slashed vectors are actually stored as a clifford object with the
404         // vector as its base expression and a (dummy) index that just serves
405         // for storing the space dimensionality
406         return clifford(e, varidx(0, dim), rl);
407 }
408
409 /** Check whether a given tinfo key (as returned by return_type_tinfo()
410  *  is that of a clifford object with the specified representation label. */
411 static bool is_clifford_tinfo(unsigned ti, unsigned char rl)
412 {
413         return ti == (TINFO_clifford + rl);
414 }
415
416 /** Check whether a given tinfo key (as returned by return_type_tinfo()
417  *  is that of a clifford object (with an arbitrary representation label). */
418 static bool is_clifford_tinfo(unsigned ti)
419 {
420         return (ti & ~0xff) == TINFO_clifford;
421 }
422
423 /** Take trace of a string of an even number of Dirac gammas given a vector
424  *  of indices. */
425 static ex trace_string(exvector::const_iterator ix, unsigned num)
426 {
427         // Tr gamma.mu gamma.nu = 4 g.mu.nu
428         if (num == 2)
429                 return lorentz_g(ix[0], ix[1]);
430
431         // Tr gamma.mu gamma.nu gamma.rho gamma.sig = 4 (g.mu.nu g.rho.sig + g.nu.rho g.mu.sig - g.mu.rho g.nu.sig
432         else if (num == 4)
433                 return lorentz_g(ix[0], ix[1]) * lorentz_g(ix[2], ix[3])
434                      + lorentz_g(ix[1], ix[2]) * lorentz_g(ix[0], ix[3])
435                      - lorentz_g(ix[0], ix[2]) * lorentz_g(ix[1], ix[3]);
436
437         // Traces of 6 or more gammas are computed recursively:
438         // Tr gamma.mu1 gamma.mu2 ... gamma.mun =
439         //   + g.mu1.mu2 * Tr gamma.mu3 ... gamma.mun
440         //   - g.mu1.mu3 * Tr gamma.mu2 gamma.mu4 ... gamma.mun
441         //   + g.mu1.mu4 * Tr gamma.mu3 gamma.mu3 gamma.mu5 ... gamma.mun
442         //   - ...
443         //   + g.mu1.mun * Tr gamma.mu2 ... gamma.mu(n-1)
444         exvector v(num - 2);
445         int sign = 1;
446         ex result;
447         for (unsigned i=1; i<num; i++) {
448                 for (unsigned n=1, j=0; n<num; n++) {
449                         if (n == i)
450                                 continue;
451                         v[j++] = ix[n];
452                 }
453                 result += sign * lorentz_g(ix[0], ix[i]) * trace_string(v.begin(), num-2);
454                 sign = -sign;
455         }
456         return result;
457 }
458
459 ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
460 {
461         if (is_a<clifford>(e)) {
462
463                 if (ex_to<clifford>(e).get_representation_label() == rl
464                  && is_a<diracone>(e.op(0)))
465                         return trONE;
466                 else
467                         return _ex0;
468
469         } else if (is_ex_exactly_of_type(e, mul)) {
470
471                 // Trace of product: pull out non-clifford factors
472                 ex prod = _ex1;
473                 for (unsigned i=0; i<e.nops(); i++) {
474                         const ex &o = e.op(i);
475                         if (is_clifford_tinfo(o.return_type_tinfo(), rl))
476                                 prod *= dirac_trace(o, rl, trONE);
477                         else
478                                 prod *= o;
479                 }
480                 return prod;
481
482         } else if (is_ex_exactly_of_type(e, ncmul)) {
483
484                 if (!is_clifford_tinfo(e.return_type_tinfo(), rl))
485                         return _ex0;
486
487                 // Expand product, if necessary
488                 ex e_expanded = e.expand();
489                 if (!is_a<ncmul>(e_expanded))
490                         return dirac_trace(e_expanded, rl, trONE);
491
492                 // gamma5 gets moved to the front so this check is enough
493                 bool has_gamma5 = is_a<diracgamma5>(e.op(0).op(0));
494                 unsigned num = e.nops();
495
496                 if (has_gamma5) {
497
498                         // Trace of gamma5 * odd number of gammas and trace of
499                         // gamma5 * gamma.mu * gamma.nu are zero
500                         if ((num & 1) == 0 || num == 3)
501                                 return _ex0;
502
503                         // Tr gamma5 gamma.mu gamma.nu gamma.rho gamma.sigma = 4I * epsilon(mu, nu, rho, sigma)
504                         // (the epsilon is always 4-dimensional)
505                         if (num == 5) {
506                                 ex b1, i1, b2, i2, b3, i3, b4, i4;
507                                 base_and_index(e.op(1), b1, i1);
508                                 base_and_index(e.op(2), b2, i2);
509                                 base_and_index(e.op(3), b3, i3);
510                                 base_and_index(e.op(4), b4, i4);
511                                 return trONE * I * (lorentz_eps(ex_to<idx>(i1).replace_dim(_ex4), ex_to<idx>(i2).replace_dim(_ex4), ex_to<idx>(i3).replace_dim(_ex4), ex_to<idx>(i4).replace_dim(_ex4)) * b1 * b2 * b3 * b4).simplify_indexed();
512                         }
513
514                         // Tr gamma5 S_2k =
515                         //   I/4! * epsilon0123.mu1.mu2.mu3.mu4 * Tr gamma.mu1 gamma.mu2 gamma.mu3 gamma.mu4 S_2k
516                         // (the epsilon is always 4-dimensional)
517                         exvector ix(num-1), bv(num-1);
518                         for (unsigned i=1; i<num; i++)
519                                 base_and_index(e.op(i), bv[i-1], ix[i-1]);
520                         num--;
521                         int *iv = new int[num];
522                         ex result;
523                         for (unsigned i=0; i<num-3; i++) {
524                                 ex idx1 = ix[i];
525                                 for (unsigned j=i+1; j<num-2; j++) {
526                                         ex idx2 = ix[j];
527                                         for (unsigned k=j+1; k<num-1; k++) {
528                                                 ex idx3 = ix[k];
529                                                 for (unsigned l=k+1; l<num; l++) {
530                                                         ex idx4 = ix[l];
531                                                         iv[0] = i; iv[1] = j; iv[2] = k; iv[3] = l;
532                                                         exvector v;
533                                                         v.reserve(num - 4);
534                                                         for (unsigned n=0, t=4; n<num; n++) {
535                                                                 if (n == i || n == j || n == k || n == l)
536                                                                         continue;
537                                                                 iv[t++] = n;
538                                                                 v.push_back(ix[n]);
539                                                         }
540                                                         int sign = permutation_sign(iv, iv + num);
541                                                         result += sign * lorentz_eps(ex_to<idx>(idx1).replace_dim(_ex4), ex_to<idx>(idx2).replace_dim(_ex4), ex_to<idx>(idx3).replace_dim(_ex4), ex_to<idx>(idx4).replace_dim(_ex4))
542                                                                 * trace_string(v.begin(), num - 4);
543                                                 }
544                                         }
545                                 }
546                         }
547                         delete[] iv;
548                         return trONE * I * result * mul(bv);
549
550                 } else { // no gamma5
551
552                         // Trace of odd number of gammas is zero
553                         if ((num & 1) == 1)
554                                 return _ex0;
555
556                         // Tr gamma.mu gamma.nu = 4 g.mu.nu
557                         if (num == 2) {
558                                 ex b1, i1, b2, i2;
559                                 base_and_index(e.op(0), b1, i1);
560                                 base_and_index(e.op(1), b2, i2);
561                                 return trONE * (lorentz_g(i1, i2) * b1 * b2).simplify_indexed();
562                         }
563
564                         exvector iv(num), bv(num);
565                         for (unsigned i=0; i<num; i++)
566                                 base_and_index(e.op(i), bv[i], iv[i]);
567
568                         return trONE * (trace_string(iv.begin(), num) * mul(bv)).simplify_indexed();
569                 }
570
571         } else if (e.nops() > 0) {
572
573                 // Trace maps to all other container classes (this includes sums)
574                 pointer_to_map_function_2args<unsigned char, const ex &> fcn(dirac_trace, rl, trONE);
575                 return e.map(fcn);
576
577         } else
578                 return _ex0;
579 }
580
581 ex canonicalize_clifford(const ex & e)
582 {
583         // Scan for any ncmul objects
584         lst srl;
585         ex aux = e.to_rational(srl);
586         for (unsigned i=0; i<srl.nops(); i++) {
587
588                 ex lhs = srl.op(i).lhs();
589                 ex rhs = srl.op(i).rhs();
590
591                 if (is_ex_exactly_of_type(rhs, ncmul)
592                  && rhs.return_type() == return_types::noncommutative
593                  && is_clifford_tinfo(rhs.return_type_tinfo())) {
594
595                         // Expand product, if necessary
596                         ex rhs_expanded = rhs.expand();
597                         if (!is_a<ncmul>(rhs_expanded)) {
598                                 srl.let_op(i) = (lhs == canonicalize_clifford(rhs_expanded));
599                                 continue;
600
601                         } else if (!is_a<clifford>(rhs.op(0)))
602                                 continue;
603
604                         exvector v;
605                         v.reserve(rhs.nops());
606                         for (unsigned j=0; j<rhs.nops(); j++)
607                                 v.push_back(rhs.op(j));
608
609                         // Stupid recursive bubble sort because we only want to swap adjacent gammas
610                         exvector::iterator it = v.begin(), next_to_last = v.end() - 1;
611                         if (is_a<diracgamma5>(it->op(0)))
612                                 ++it;
613                         while (it != next_to_last) {
614                                 if (it[0].compare(it[1]) > 0) {
615                                         ex save0 = it[0], save1 = it[1];
616                                         ex b1, i1, b2, i2;
617                                         base_and_index(it[0], b1, i1);
618                                         base_and_index(it[1], b2, i2);
619                                         it[0] = (lorentz_g(i1, i2) * b1 * b2).simplify_indexed();
620                                         it[1] = _ex2;
621                                         ex sum = ncmul(v);
622                                         it[0] = save1;
623                                         it[1] = save0;
624                                         sum -= ncmul(v, true);
625                                         srl.let_op(i) = (lhs == canonicalize_clifford(sum));
626                                         goto next_sym;
627                                 }
628                                 ++it;
629                         }
630 next_sym:       ;
631                 }
632         }
633         return aux.subs(srl).simplify_indexed();
634 }
635
636 } // namespace GiNaC