File: implicit.cdb

package info (click to toggle)
cadabra2 2.4.3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,796 kB
  • sloc: ansic: 133,450; cpp: 92,064; python: 1,530; javascript: 203; sh: 184; xml: 182; objc: 53; makefile: 51
file content (297 lines) | stat: -rw-r--r-- 7,233 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297

def test01():
    __cdbkernel__=create_scope()
    {a,b,c,d}::Indices(type1);
    {m,n,p,q}::Indices(type2);
    A::ImplicitIndex(A_{m n});
    C::ImplicitIndex(C_{m n});
    D::ImplicitIndex(D_{a b});
    ex:= D C A D;
    sort_product(_)
    tst:= C A D D - @(ex);
    assert(tst==0)
    print("Test 01 passed")

test01()

def test02():
    __cdbkernel__=create_scope()
    {a,b,c,d}::Indices(spinor);
    Tr{#}::Trace(indices=spinor);
    A::ImplicitIndex(A_{a b});
    B::ImplicitIndex(B_{a b});    
    ex:= Tr( A B A C B ) - Tr( C );
    untrace(_)
    tst:= C Tr( A B A B ) - C Tr(1) - @(ex);
    assert(tst==0)
    print("Test 02 passed")

test02()

def test03():
    __cdbkernel__=create_scope()
    {a,b,c,d}::Indices(spinor);
    \sigma^{\mu}::ImplicitIndex(\sigma^{\mu a}_{b});    
    Tr{#}::Trace(indices=spinor);
    ex:= Tr( \sigma^{\mu} q \sigma^{\nu} );
    untrace(_)
    tst:= q Tr( \sigma^{\mu} \sigma^{\nu} ) - @(ex);
    assert(tst==0)
    print("Test 03 passed")
    
test03()
        
def test04():
    __cdbkernel__=create_scope()
    {a,b}::Indices(spinor);
    {m,n}::Indices(vector);
    Tr{#}::Trace(indices=spinor);
    A::ImplicitIndex(A_{a b});
    B::ImplicitIndex(B_{m n});
    A::Traceless(indices=spinor);
    B::Traceless(indices=vector);
    ex:=Tr( A ) + Tr( B );
    canonicalise(_)
    tst:= Tr( B ) - @(ex);
    assert(tst==0)
    print("Test 04 passed")

test04()

def test05():
    __cdbkernel__=create_scope()
    {a,b,c,d}::Indices(vector);
    ex:=(A)_{a b} (B)_{b c} (C)_{c d};
    combine(_)
    tst:= (A B C)_{a d} - @(ex);
    assert(tst==0)
    print("Test 05 passed")

test05()

def test06():
    __cdbkernel__=create_scope()
    {a,b}::Indices(vector);
    ex:=(A)_{a b} (B)_{b a};
    combine(_)
    tst:= (B A)_{b b} - @(ex);
    assert(tst==0)
    print("Test 06 passed")

test06()

def test07():
    __cdbkernel__=create_scope()
    {a,b}::Indices(vector);
    Tr{#}::Trace(indices=vector);
    ex:=(A)_{a b} (B)_{b a};
    combine(_, trace_op=$Tr$)
    tst:= Tr( B A ) - @(ex);
    assert(tst==0)
    print("Test 07 passed")

test07()

def test08():
    __cdbkernel__=create_scope()
    {a,b}::Indices(vector);
    {A,B}::AntiCommuting;
    ex:=(A)_{a b} (B)_{b a};
    combine(_)
    tst:= \indexbracket{-B A}_{b b} - @(ex);
    assert(tst==0)
    print("Test 08 passed")

test08()

def test09():
    __cdbkernel__=create_scope()
    {m,n}::Indices(vector);
    {a,b,c}::Indices(spinor, position=fixed);
    \Gamma^{m}::ImplicitIndex(\Gamma^{m a}_{b});
    \Gamma^{m}::Matrix;
    ex:=(\Gamma^{m} \Gamma^{n})^{a}_{c};
    expand(_)
    tst:= (\Gamma^{m})^{a}_{b} (\Gamma^{n})^{b}_{c} - @(ex);
    assert(tst==0)
    print("Test 09 passed")

test09()

def test10():
    __cdbkernel__=create_scope()
    {a,b}::Indices(vector);
    ex:=(u)_{a} (M)^{a b} (v)_{b};
    combine(_)
    tst:= \indexbracket(u M v) - @(ex);
    assert(tst==0)
    print("Test 10 passed")

if sys.platform == "darwin":
    print("Skipping test 10, segfault on Darwin.")
else:
    test10()

def test11():
    __cdbkernel__=create_scope()
    {a,b,c}::Indices(vector);
    ex:=(B)_{b c} (A)_{a b};
    combine(_)
    tst:= (A B)_{a c} - @(ex);
    assert(tst==0)
    print("Test 11 passed")

test11()

def test12():
    __cdbkernel__=create_scope()
    {a,b}::Indices(vector);
    Tr{#}::Trace(indices=vector);
    A::ImplicitIndex(A_{a b});
    B::ImplicitIndex(B_{a b});
    {A_{a b}, B_{a b}, C, D}::AntiCommuting;
    ex:=Tr( A C B D );
    untrace(_)
    sort_product(_)
    tst:= -C D Tr( A B ) - @(ex);
    assert(tst==0)
    print("Test 12 passed")

test12()

def test13():
    __cdbkernel__=create_scope()
    {a,b}::Indices(vector);
    Tr{#}::Trace(indices=vector);
    A::ImplicitIndex(A_{a b});
    B::ImplicitIndex(B_{a b});
    {A_{a b}, B_{a b}}::AntiCommuting;
    ex:=Tr( B A );
    sort_product(_)
    tst:= Tr( -A B ) - @(ex);
    assert(tst==0)
    print("Test 13 passed")

test13()

def test14():
    __cdbkernel__=create_scope()
    {A,B,C}::ImplicitIndex;
    ex:=(B A C)_{a a};
    sort_product(_)
    tst:= (A C B)_{a a} - @(ex);
    assert(tst==0)
    print("Test 14 passed")

test14()

def test15():
    __cdbkernel__=create_scope()
    {\mu,\nu,\rho}::Indices(vector).
    {a^{\mu},b^{\mu},c^{\mu}}::NonCommuting.
    tr{#}::Trace.
    ex:=tr(a^{\mu} b^{\nu} c^{\rho}  a^{\mu} b^{\rho} c^{\nu}+b^{\mu} c^{\nu} a^{\rho} b^{\nu} c^{\mu} a^{\rho}+c^{\mu} a^{\nu} b^{\mu} c^{\rho} a^{\nu} b^{\rho});
    sort_product(_)
    rename_dummies(_)
    tst:= 3 tr( a^{\mu} b^{\nu} c^{\rho}  a^{\mu} b^{\rho} c^{\nu} ) - @(ex);
    assert(tst==0)
    print("Test 15 passed")
    
test15()
        
def test16():
    __cdbkernel__=create_scope()
    {\mu,\nu,\rho}::Indices(vector).
    {a^{\mu},b^{\mu},c^{\mu}}::NonCommuting.
    tr{#}::Trace.
    ex:=tr( b^{\mu} c^{\nu} a^{\rho} b^{\nu} c^{\mu} a^{\rho} );
    sort_product(_)
    rename_dummies(_)
    tst:= tr( a^{\mu} b^{\nu} c^{\rho}  a^{\mu} b^{\rho} c^{\nu} ) - @(ex);
    assert(tst==0)
    print("Test 16 passed")
    
test16()

def test17():
    __cdbkernel__=create_scope()
    {A,B}::ImplicitIndex.
    tr{#}::Trace.
    ex:=tr( A B B A );
    sort_product(_)
    tst:= tr( A A B B ) - @(ex);
    assert(tst==0)
    print("Test 17 passed")

test17()

def test18():
    __cdbkernel__=create_scope()
    {\mu,\nu}::Indices(vector).
    tr{#}::Trace.
    {a^{\mu},b^{\mu}}::NonCommuting.
    {a^{\mu},b^{\mu}}::SelfNonCommuting.
    ex:=tr{a^{\mu} b^{\mu} b^{\nu} a^{\nu}} - tr{a^{\mu} a^{\nu} b^{\nu} b^{\mu} };
    sort_product(_)
    rename_dummies(_)        
    assert(ex==0)
    print("Test 18 passed")

test18()

def test19():
    __cdbkernel__=create_scope()
    i::ImaginaryI;
    A::ImplicitIndex.
    tr{#}::Trace.
    ex:= i tr(i A);
    untrace(_, repeat=True)
    tst:= -tr(A) - @(ex);
    assert("Test 19 passed")

test19()

def test20():
    __cdbkernel__=create_scope()
    {\mu,\nu}::Indices(vector).
    tr{#}::Trace.
    ex:=A A tr{u^{\mu} u^{\nu}} tr{u^{\nu} u^{\mu}}- B B tr{u^{\mu} u^{\nu}} tr{u^{\mu} u^{\nu}};
    collect_factors(_)
    tst:= A**2 tr{u^{\mu} u^{\nu}} tr{u^{\nu} u^{\mu}}- B**2 tr{u^{\mu} u^{\nu}} tr{u^{\mu} u^{\nu}} - @(ex);
    assert(tst==0)
    print("Test 20 passed")

test20()

def test21():
    __cdbkernel__=create_scope()
    {\mu,\nu}::Indices(vector).
    A^{\mu\nu}::Symmetric.
    B^{\mu\nu}::AntiSymmetric.
    tr{#}::Trace.
    B^{\mu\nu}::ImplicitIndex.
    \epsilon^{\mu\nu\rho\sigma}::EpsilonTensor.
    ex:=A^{\mu\nu} tr{B^{\mu\nu}};
    canonicalise(_)
    assert ex==0
    print("Test 21a passed")
    ex:=\epsilon^{\mu\nu\rho\sigma} tr{A^{\mu\nu} B^{\rho\sigma}};
    canonicalise(_)
    assert ex==0
    print("Test 21b passed")    
    ex:=\epsilon^{\mu\nu\rho\sigma} A^{\nu\mu} B^{\rho\sigma};
    canonicalise(_)
    assert ex==0
    print("Test 21c passed")    
    ex:=\epsilon^{\mu\nu\rho\sigma} tr{ A^{\nu\mu} B^{\rho\sigma} };
    canonicalise(_)    
    assert ex==0
    print("Test 21d passed")    
    ex:=\epsilon^{\mu\nu\rho\sigma} tr{ A^{\nu\mu} B^{\rho\sigma} + A^{\mu\nu} B^{\rho\sigma} };
    # FIXME: this does not work with repeat=True?
    canonicalise(_)
    canonicalise(_)
    assert ex==0
    print("Test 21e passed")
    
test21()