/* Computing E-expressions */;

/* Vv is the formal v-tuple parameter,  Uv : formal u-tuple parameter */;

E(l, Vv, Uv) := block ( [],
if (l=0) then 
    1
    else ( 
        -(1/l)*sum(E(l-k,Vv, Uv)*sum(binomial(k,lambd)*Vv(k-lambd)*Uv(lambd), lambd, 0, k), k, 1, l)
    )
);

 /* assignment actual v- and u- symbolci tuples /*/;

U(l):=u[l];V(l):=v[l];

E(0,V,U);E(1,V,U);

expand(ratsimp(E(2,V,U)));

expand(ratsimp(E(3,V,U)));

%/* Computing A-coefficients */;

/* iv is the formal i-tuple parameter */;

A(Vv, iv,l, Uv):=  block ( [],
    if (l=0) then 
    1
    else 
    (
        retVal: expand(E(l, Vv, Uv)),
        for j: 1 while j <= l do
        (
            retVal: ratcoef(retVal, Uv(j), iv(j))
        ),
        retVal
    )
);

/* Computing B-coefficients */;

ol(j):= 0;

B(l, m, Vv, Uv) := ratcoeff(expand(A(Vv, ol, l, Uv)), Uv(0), m);

B(0,0, V, U);

B(1,0, V, U);

B(1,1, V, U);

B(2,0, V, U);B(2,1, V, U);B(2,2, V, U);

B(3,0, V, U);B(3,1, V, U);B(3,2, V, U);B(3,3, V, U);

B(4,0, V, U);B(4,1, V, U);B(4,2, V, U);B(4,3, V, U);B(4,4, V, U);

B(5,0, V, U);B(5,1, V, U);B(5,2, V, U);B(5,3, V, U);B(5,4, V, U);;B(5,5, V, U);

%/* Computing linear combinations of B(l,m) presenting A_{i} */

 /* l=1 */;

E(1, V, U);

A(V, ol, 1, U);

i1_1(j):= block([], 1);

A_1:A(V, i1_1, 1, U);

divide(A_1, B(0,0, V, U),V(1));

/* l=2 */;

i01_2(j) := block ([], if (j=1) then 0 else (if (j=2) then 1 else -1));

A_01:A(V, i01_2, 2, U);

divide(A_01, B(0,0, V, U),V(1), V(2));

i10_2(j) := block ([], if (j=1) then 1 else (if (j=2) then 0 else -1));

A_10:A(V, i10_2, 2, U);

divide(A_10, B(1,1, V, U),V(1), V(2));

i20_2(j) := block ([], if (j=1) then 2 else (if (j=2) then 0 else -1));

A_20:A(V, i20_2, 2, U);

divide(A_20, B(0,0, V, U),V(1), V(2));

;

/* l=3 */

/* sum = 1*/;

i100_3(j) := block ([], if (j=1) then 1 else (if (j=2 or j=3) then 0 else -1));
A_100:expand(A(V, i100_3, 3, U));

H_100_1:divide(A_100, B(2,1, V, U),V(1), V(2));H_100_1[1];;H_100_1[2];

H_100_2:divide(H_100_1[2], B(2,2, V, U),V(1), V(2));

%/* sum = 2 */;

i200_3(j) := block ([], if (j=1) then 2 else (if (j=2 or j=3) then 0 else -1));

A_200:expand(A(V, i200_3, 3, U));

divide(A_200, B(1,1, V, U),V(1), V(2));

i010_3(j) := block ([], if (j=2) then 1 else (if (j=1 or j=3) then 0 else -1));

A_010:A(V, i010_3, 3, U);

divide(A_010, B(1,1, V, U),V(1), V(2));

/* sum = 3 */;

i001_3(j) := block ([], if (j=3) then 1 else (if (j=1 or j=2) then 0 else -1));

A_001:A(V, i001_3, 3, U);

divide(A_001, B(0,0, V, U),V(1), V(2));

i300_3(j) := block ([], if (j=1) then 3 else (if (j=2 or j=3) then 0 else -1));

A_300:A(V, i300_3, 3, U);

i110_3(j) := block ([], if (j=1 or j=2) then 1 else (if (j=3) then 0 else -1));

A_110:A(V, i110_3, 3, U);

divide(A_110, B(0,0, V, U),V(1), V(2));

;

/* l=4 */;

/* sum = 1 */;

i1000_4(j) := block ([], if (j=1) then 1 else (if (j=1 or j=2 or j=3 or j=4) then 0 else -1));

A_1000: A(V, i1000_4, 4, U);

H_1000_1:divide(A_1000, B(3,1, V, U), V(1), V(2), V(3));

H_1000_2:divide(H_1000_1[2], B(3,2, V, U), V(1), V(2), V(3));

H_1000_3:divide(H_1000_2[2], B(3,3, V, U), V(1), V(2), V(3));

/* sum = 2*/;

i0100_4(j) := block ([], if (j=2) then 1 else (if (j=1 or j=3 or j=4) then 0 else -1));

A_0100: A(V, i0100_4, 4, U);

H_0100_1:divide(A_0100, B(2,1, V, U), V(1), V(2), V(3));

H_0100_2:divide(H_0100_1[2], B(2,2, V, U), V(1), V(2), V(3));

i2000_4(j) := block ([], if (j=1) then 2 else (if (j=2 or j=3 or j=4) then 0 else -1));

A_2000: A(V, i2000_4, 4, U);

H_2000_1:divide(A_2000, B(2,1, V, U), V(1), V(2), V(3));

H_2000_2:divide(H_2000_1[2], B(2,2, V, U), V(1), V(2), V(3));

/* sum = 3*/;

i3000_4(j) := block ([], if (j=1) then 3 else (if (j=2 or j=3 or j=4) then 0 else -1));

A_3000: A(V, i3000_4, 4, U);

divide(A_3000, B(1,1, V, U), V(1), V(2), V(3));

i1100_4(j) := block ([], if (j=1 or j=2) then 1 else (if (j=3 or j=4) then 0 else -1));

A_1100: A(V, i1100_4, 4, U);

divide(A_1100, B(1,1, V, U), V(1), V(2), V(3));

%/*sum = 4*/;

i0001_4(j) := block ([], if (j=4) then 1 else (if (j=1 or j=2 or j=3) then 0 else -1));

A_0001: A(V, i0001_4, 4, U);

i0200_4(j) := block ([], if (j=2) then 2 else (if (j=1 or j=3 or j=4) then 0 else -1));

A_0200: A(V, i0200_4, 4, U);

i1010_4(j) := block ([], if (j=1 or j=3) then 1 else (if (j=2 or j=4) then 0 else -1));

A_1010: A(V, i1010_4, 4, U);

i2100_4(j) := block ([], if (j=1) then 2 else (if (j=2) then 1 else if (j=3 or j=4) then 0 else -1));

A_2100: A(V, i2100_4, 4, U);

i4000_4(j) := block ([], if (j=1) then 4 else (if (j=2 or j=3 or j=4) then 0 else -1));

A_4000: A(V, i4000_4, 4, U);

/* l=5 */;

i10000_5(j) := block ([], if (j=1) then 1 else (if (j=2 or j=3 or j=4 or j=5) then 0 else -1));

A_10000: A(V, i10000_5, 5, U);

H_10000_1:divide(A_10000, B(4,1, V, U), V(1), V(2), V(3), V(4));

H_10000_2:divide(H_10000_1[2], B(4,2, V, U), V(1), V(2), V(3), V(4));

H_10000_3:divide(H_10000_2[2], B(4,3, V, U), V(1), V(2), V(3), V(4));

H_10000_4:divide(H_10000_3[2], B(4,4, V, U), V(1), V(2), V(3), V(4));

i20000_5(j) := block ([], if (j=1) then 2 else (if (j=2 or j=3 or j=4 or j=5) then 0 else -1));

A_20000: A(V, i20000_5, 5, U);

H_20000_1:divide(A_20000, B(3,1, V, U), V(1), V(2), V(3));

H_20000_2:divide(H_20000_1[2], B(3,2, V, U), V(1), V(2), V(3));

H_20000_3:divide(H_20000_2[2], B(3,3, V, U), V(1), V(2), V(3));

i01000_5(j) := block ([], if (j=2) then 1 else (if (j=1 or j=3 or j=4 or j=5) then 0 else -1));

A_01000: A(V, i01000_5, 5, U);

H_01000_1:divide(A_01000, B(3,1, V, U), V(1), V(2), V(3));

H_01000_2:divide(H_01000_1[2], B(3,2, V, U), V(1), V(2), V(3));

H_01000_3:divide(H_01000_2[2], B(3,3, V, U), V(1), V(2), V(3));

i30000_5(j) := block ([], if (j=1) then 3 else (if (j=2 or j=3 or j=4 or j=5) then 0 else -1));

A_30000: A(V, i30000_5, 5, U);

H_30000_1:divide(A_30000, B(2,1, V, U), V(1), V(2));

H_30000_2:divide(H_30000_1[2], B(2,2, V, U), V(1), V(2));

i11000_5(j) := block ([], if (j=1 or j=2) then 1 else (if (j=3 or j=4 or j=5) then 0 else -1));

A_11000: A(V, i11000_5, 5, U);

H_11000_1:divide(A_11000, B(2,1, V, U), V(1), V(2));

H_11000_2:divide(H_11000_1[2], B(2,2, V, U), V(1), V(2));

i00100_5(j) := block ([], if (j=3) then 1 else (if (j=1 or j=2 or j=4 or j=5) then 0 else -1));

A_00100: A(V, i00100_5, 5, U);

H_00100_1:divide(A_00100, B(2,1, V, U), V(1), V(2));

H_00100_2:divide(H_00100_1[2], B(2,2, V, U), V(1), V(2));

i40000_5(j) := block ([], if (j=1) then 4 else (if (j=2 or j=3 or j=4 or j=5) then 0 else -1));

A_40000: A(V, i40000_5, 5, U);

divide(A_40000, B(1,1, V, U), V(1));

;

i10100_5(j) := block ([], if (j=1 or j=3) then 1 else (if (j=2 or j=4 or j=5) then 0 else -1));

A_10100: A(V, i10100_5, 5, U);

divide(A_10100, B(1,1, V, U), V(1));

i20100_5(j) := block ([], if (j=1) then 2 else (if (j=2) then 1 else if (j=3 or j=4 or j=5) then 0 else -1));

A_20100: A(V, i20100_5, 5, U);

divide(A_20100, B(1,1, V, U), V(1));

i02000_5(j) := block ([], if (j=2) then 2 else (if (j=1 or j=3 or j=4  or j=5) then 0 else -1));

A_02000: A(V, i02000_5, 5, U);

divide(A_02000, B(1,1, V, U), V(1));

i00010_5(j) := block ([], if (j=4) then 1 else (if (j=1 or j=2 or j=3 or j=5) then 0 else -1));

A_00010: A(V, i00010_5, 5, U);divide(A_00010, B(1,1, V, U), V(1));

i50000_5(j) := block ([], if (j=1) then 5 else (if (j=2 or j=3 or j=4 or j=5) then 0 else -1));

A_50000: A(V, i50000_5, 5, U);

i10010_5(j) := block ([], if (j=1 or j=4) then 1 else (if (j=2 or j=3 or j=5) then 0 else -1));

A_10010: A(V, i10010_5, 5, U);

i12000_5(j) := block ([], if (j=1) then 1 else (if (j=2) then 2 else if (j=3 or j=4 or j=5) then 0 else -1));

A_12000: A(V, i12000_5, 5, U);

i01100_5(j) := block ([], if (j=2 or j=3) then 1 else (if (j=1 or j=4 or j=5) then 0 else -1));

A_01100: A(V, i01100_5, 5, U);

i31000_5(j) := block ([], if (j=1) then 3 else (if (j=2) then 1 else if (j=3 or j=4 or j=5) then 0 else -1));

A_31000: A(V, i31000_5, 5, U);

i20100_5(j) := block ([], if (j=1) then 2 else (if (j=3) then 1 else if (j=2 or j=4 or j=5) then 0 else -1));

A_20100: A(V, i20100_5, 5, U);

i00001_5(j) := block ([], if (j=5) then 1 else (if (j=1 or j=2 or j=3 or j=4) then 0 else -1));

A_00001: A(V, i00001_5, 5, U);

/* l=6 */;

i100000_6(j) := block ([], if (j=1) then 1 else (if (j=2 or j=3 or j=4 or j=5 or j=6) then 0 else -1));

i200000_6(j) := block ([], if (j=1) then 2 else (if (j=2 or j=3 or j=4 or j=5 or j=6) then 0 else -1));

%/* A_200000 is not a linear combination of B(4,4, V, U);B(4,3, V, U);B(4,2, V, U);B(4,1, V, U);*/

A_200000: expand(A(V, i200000_6, 6, U));

B(4,4, V, U);B(4,3, V, U);B(4,2, V, U);B(4,1, V, U);

%/* proof via linear system w.r.t. coefficients of the hypothetic linear commbination A_200000 = x[1]*B(4,1, V, U)+x[2]*B(4,2, V, U)+x[3]*B(4,3, V, U)+x[4]*B(4,4, V, U); */

b[1]:ratcoeff(A_200000, V(4), 1); b[2]:ratcoeff(A_200000, V(1)*V(3), 1);b[3]:ratcoeff(A_200000, V(2)*V(2), 1);

b[4]:ratcoeff(A_200000, V(1)*V(1)*V(2)); b[5]:ratcoeff(A_200000, V(1), 4);

%/* A_200000 = x[1]*B(4,1, V, U)+x[2]*B(4,2, V, U)+x[3]*B(4,3, V, U)+x[4]*B(4,4, V, U); */

e1: b[1]-x[1]*ratcoeff(B(4,1,V,U), V(4), 1)-x[2]*ratcoeff(B(4,2,V,U), V(4), 1)-x[3]*ratcoeff(B(4,3,V,U), V(4), 1)-x[4]*ratcoeff(B(4,4,V,U), V(4), 1);

e2: b[2]-x[1]*ratcoeff(B(4,1,V,U), V(1)*V(3), 1)-x[2]*ratcoeff(B(4,2,V,U), V(1)*V(3), 1)-x[3]*ratcoeff(B(4,3,V,U), V(1)*V(3), 1)-x[4]*ratcoeff(B(4,4,V,U), V(1)*V(3), 1);

e3: b[3]-x[1]*ratcoeff(B(4,1,V,U), V(2)*V(2), 1)-x[2]*ratcoeff(B(4,2,V,U), V(2)*V(2), 1)-x[3]*ratcoeff(B(4,3,V,U), V(2)*V(2), 1)-x[4]*ratcoeff(B(4,4,V,U), V(2)*V(2), 1);

e4: b[4]-x[1]*ratcoeff(B(4,1,V,U), V(1)*V(1)*V(2))-x[2]*ratcoeff(B(4,2,V,U),V(1)*V(1)*V(2))-x[3]*ratcoeff(B(4,3,V,U),V(1)*V(1)*V(2))-x[4]*ratcoeff(B(4,4,V,U), V(1)*V(1)*V(2), 1);

e5: b[5]-x[1]*ratcoeff(B(4,1,V,U), V(1), 4)-x[2]*ratcoeff(B(4,2,V,U), V(1), 4)-x[3]*ratcoeff(B(4,3,V,U), V(1), 4)-x[4]*ratcoeff(B(4,4,V,U), V(1), 4);

solve([e2], [x[2]]);solve([e3], [x[2]]);

solve([e2,e3], [x[2]]);

%/* proof using poynomial division */

H_200000_1:divide(A_200000, B(4,1, V, U), V(1), V(2), V(3), V(4));

B(4,4, V, U);B(4,3, V, U);B(4,2, V, U);

expand(H_200000_1[2]);

H_200000_2:divide(expand(H_200000_1[2]), B(4,4, V, U), V(1));

expand(H_200000_2[2]);

H_200000_3:divide(expand(H_200000_2[2]), B(4,2, V, U), V(1), V(2), V(3));

H_200000_4:divide(expand(H_200000_3[2]), B(4,3, V, U), V(2), V(1));

;

/* A_010000 is not a linear combination of B(4,4, V, U);B(4,3, V, U);B(4,2, V, U);B(4,1, V, U);*/

i010000_6(j) := block ([], if (j=2) then 1 else (if (j=1 or j=3 or j=4 or j=5 or j=6) then 0 else -1));

A_010000: expand(A(V, i010000_6, 6, U));

%/* proof via linear system w.r.t. coefficients of the hypothetic linear commbination A_200000 = x[1]*B(4,1, V, U)+x[2]*B(4,2, V, U)+x[3]*B(4,3, V, U)+x[4]*B(4,4, V, U); */

c[1]:ratcoeff(A_010000, V(4), 1); c[2]:ratcoeff(A_010000, V(1)*V(3), 1);c[3]:ratcoeff(A_010000, V(2)*V(2), 1);

c[4]:ratcoeff(A_010000, V(1)*V(1)*V(2)); c[5]:ratcoeff(A_010000, V(1), 4);

%/* A_010000 = y[1]*B(4,1, V, U)+y[2]*B(4,2, V, U)+y[3]*B(4,3, V, U)+y[4]*B(4,4, V, U); */

ee1: b[1]-y[1]*ratcoeff(B(4,1,V,U), V(4), 1)-y[2]*ratcoeff(B(4,2,V,U), V(4), 1)-y[3]*ratcoeff(B(4,3,V,U), V(4), 1)-y[4]*ratcoeff(B(4,4,V,U), V(4), 1);

ee2: b[2]-y[1]*ratcoeff(B(4,1,V,U), V(1)*V(3), 1)-y[2]*ratcoeff(B(4,2,V,U), V(1)*V(3), 1)-y[3]*ratcoeff(B(4,3,V,U), V(1)*V(3), 1)-y[4]*ratcoeff(B(4,4,V,U), V(1)*V(3), 1);

ee3: b[3]-y[1]*ratcoeff(B(4,1,V,U), V(2)*V(2), 1)-y[2]*ratcoeff(B(4,2,V,U), V(2)*V(2), 1)-y[3]*ratcoeff(B(4,3,V,U), V(2)*V(2), 1)-y[4]*ratcoeff(B(4,4,V,U), V(2)*V(2), 1);

ee4: b[4]-y[1]*ratcoeff(B(4,1,V,U), V(1)*V(1)*V(2))-y[2]*ratcoeff(B(4,2,V,U),V(1)*V(1)*V(2))-y[3]*ratcoeff(B(4,3,V,U),V(1)*V(1)*V(2))-y[4]*ratcoeff(B(4,4,V,U), V(1)*V(1)*V(2), 1);

ee5: b[5]-y[1]*ratcoeff(B(4,1,V,U), V(1), 4)-y[2]*ratcoeff(B(4,2,V,U), V(1), 4)-y[3]*ratcoeff(B(4,3,V,U), V(1), 4)-y[4]*ratcoeff(B(4,4,V,U), V(1), 4);

solve([ee2], [y[2]]);solve([ee3], [y[2]]);

solve([ee2,ee3], [y[2]]);

%/* proof using poynomial division */

H_010000_1:divide(A_010000, B(4,1, V, U), V(1), V(2), V(3), V(4));

H_010000_2:divide(expand(H_010000_1[2]), B(4,4, V, U), V(1));

H_010000_3:divide(expand(H_010000_2[2]), B(4,2, V, U), V(1), V(2), V(3));

H_010000_4:divide(expand(H_010000_3[2]), B(4,3, V, U), V(2), V(1));

i300000_6(j) := block ([], if (j=1) then 3 else (if (j=2 or j=3 or j=4 or j=5 or j=6) then 0 else -1));

i110000_6(j) := block ([], if (j=1 or j=2) then 1 else (if (j=3 or j=4 or j=5 or j=6) then 0 else -1));

i001000_6(j) := block ([], if (j=3) then 1 else (if (j=1 or j=2 or j=4 or j=5 or j=6) then 0 else -1));0

i400000_6(j) := block ([], if (j=1) then 4 else (if (j=2 or j=3 or j=4 or j=5 or j=6) then 0 else -1));

i101000_6(j) := block ([], if (j=1 or j=3) then 1 else (if (j=2 or j=4 or j=5 or j=6) then 0 else -1));

i201000_6(j) := block ([], if (j=1) then 2 else (if (j=2) then 1 else if (j=3 or j=4 or j=5  or j=6) then 0 else -1));

i020000_6(j) := block ([], if (j=2) then 2 else (if (j=1 or j=3 or j=4  or j=5  or j=6) then 0 else -1));

i000100_6(j) := block ([], if (j=4) then 1 else (if (j=1 or j=2 or j=3 or j=5 or j=6) then 0 else -1));

i500000_6(j) := block ([], if (j=1) then 5 else (if (j=2 or j=3 or j=4 or j=5 or j=6) then 0 else -1));

i100100_6(j) := block ([], if (j=1 or j=4) then 1 else (if (j=2 or j=3 or j=5 or j=6) then 0 else -1));

i120000_6(j) := block ([], if (j=1) then 1 else (if (j=2) then 2 else if (j=3 or j=4 or j=5 or j=6) then 0 else -1));

i011000_6(j) := block ([], if (j=2 or j=3) then 1 else (if (j=1 or j=4 or j=5 or j=6) then 0 else -1));

i201000_6(j) := block ([], if (j=1) then 2 else (if (j=3) then 1 else if (j=2 or j=4 or j=5 or j=6) then 0 else -1));

i000010_6(j) := block ([], if (j=5) then 1 else (if (j=1 or j=2 or j=3 or j=4 or j=6) then 0 else -1));

i310000_6(j) := block ([], if (j=1) then 3 else (if (j=2) then 1 else if (j=3 or j=4 or j=5 or j=6) then 0 else -1));

i000001_6(j) := block ([], if (j=6) then 1 else (if (j=1 or j=2 or j=3 or j=4 or j=5) then 0 else -1));

i030000_6(j) := block ([], if (j=2) then 3 else (if (j=1 or j=3 or j=4 or j=5 or j=6) then 0 else -1));

i002000_6(j) := block ([], if (j=3) then 2 else (if (j=1 or j=2 or j=4 or j=5 or j=6) then 0 else -1));

i100010_6(j) := block ([], if (j=1) then 1 else (if (j=5) then 1 else if (j=2 or j=3 or j=4 or j=6) then 0 else -1));

i111000_6(j) := block ([], if (j=1 or j=2 or j=3) then 1 else (if (j=4 or j=5 or j=6) then 0 else -1));

i200100_6(j) := block ([], if (j=1) then 2 else (if (j=4) then 1 else if (j=2 or j=3 or j=5 or j=6) then 0 else -1));

i220000_6(j) := block ([], if (j=1 or j=2) then 2 else if ( j=3 or j=5 or j=6) then 0 else -1));

i301000_6(j) := block ([], if (j=1) then 3 else (if (j=3) then 1 else if (j=2 or j=4 or j=5 or j=6) then 0 else -1));

i410000_6(j) := block ([], if (j=1) then 4 else (if (j=2) then 1 else if (j=3 or j=4 or j=5 or j=6) then 0 else -1));

i600000_6(j) := block ([], if (j=1) then 2 else (if (j=2 or j=3 or j=4 or j=5 or j=6) then 0 else -1));