# 
#

\delta_{a b}::KroneckerDelta.
obj0:= \delta_{i1 i1};
{i1,i2}::Integer(0..9).
obj1:= @eliminate_kr[@(obj0)];
\Gamma_{?}::GammaMatrix.
obj1bb:= @distribute![ @join![ q \Gamma_{a b} \Gamma_{c} ] ];
#
# The following one fails: eliminate acts now, and then a crash occurs.
# DID NOT TEST WITH CDB_PARANOID ON!!!
#
#obj1b:= @eliminate_kr![q \delta_{i1 i1}];
#obj2:= @eliminate_kr![q*@(obj0)];
# obj1:= \delta_{i1 i1} @eliminate_kr![q*@(obj0)];
# tst1:= 10 q \delta_{i1 i1} - @(obj1);
# @prodsort!(%):
# @collect_terms!(%);
# @assert(tst1);
# 
# 
{a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,m,n,q,r,s,a,b}::Indices(vector).

# Relabelling inside a product.
#
fac:=  f_{m n}*g_{n q};
prod:= @(fac)*@(fac);
test1:= @(prod)-f_{m n}*g_{n q}*f_{m a1}*g_{a1 q};
@collect_terms!(%);
@assert(%);

# Relabelling inside a product occurring inside a sum.
#
obj:=   a_{m n} b^{n};
some:=  q_{n} foo^{n};
funky:= c_{m} + @(obj) @(some);
test2:= @(funky)-c_{m}-a_{m a1}*b^{a1}*q_{a2}*foo^{a2};
@rename_dummies!(%);
@collect_terms!(%);
@assert(%);

# Accepting zeroes in combination with anything.
#
obj3:=  F_{m n p} = 0;

# Some more that should run without producing errors.
#
f_{s} ( g_{r} + h_{r} ) ( q_{r} * s_{q} );
@indexlist(%);

{a1,a2,a3,a4,a5,a6,a7,a8,a9,a10}::Indices(vector).
fac2:=  f_{m r s}*(g_{s q}+p_{s q}*(tens^{a b}*tensb_{a b}))+h_{m n}*g_{n q r};
@indexlist(%);
prod2:= @(fac2)*@(fac2);

{a1,a2,a3,a4,a5,a6,a7,a8,a9,a10}::Indices(vector).
fac2:=  f_{m r s}*(g_{s}+p_{s}*(tens^{a b}*tensb_{a b}))+h_{m n}*g_{n r};
@indexlist(%);
prod2:= @(fac2)*@(fac2);

{a1,a2,a3,a4,a5,a6,a7,a8,a9,a10}::Indices(vector).
one:= a_{m n}+b_{m n};
two:= @(one)*@(one);
three:= @(two)*@(one);
four:=  @(one)*@(two);

# Test 5: range wildcard names.
#

@reset;
{ n#, m, n }::Indices(vector).
obj5:= A_{m n1} B_{n1 n};
obj5b:= @(obj5) * @(obj5);
obj5c:= @(obj5b) * @(obj5b);
@rename_dummies!(%);
tst5:= A_{n1 n2} * B_{n2 n3} * A_{n1 n4} * B_{n4 n3} * A_{n5 n6} * B_{n6 n7} * A_{n5 n8} * B_{n8 n7} - @(obj5c);
@collect_terms!(%);
@assert(tst5);

