<<PolylogTools`

L4[x_] := Li[{4},{x}];

phi[x_,3,y_] := -(1/4)(CiTi[1-x, x, x, y] - CiTi[x, 1-x, x, y])

kappa[x_,y_] :=-(phi[1-x, 3, x/y] + phi[1-y, 3, x/y] + phi[(1-1/x)/(1-1/y), 3, x/y] - phi[(1-x)/(1-y), 3, x/y]+ 
+ phi[x/y, 3,(1-y)/(1-x)] - phi[x,3, 1-y] + phi[y, 3, 1-x]);

(kappa[x,y]//ReduceTensorProduct//flatTensor//Expand//del//Expand)

(* ------------- *)

kappa[x,y] + kappa[1/x, y]//ReduceTensorProduct//flatTensor//Expand//del//Expand

A[y_] :=(1/2) L4i[x(1-y)^2/(y(1-x)^2)] - (1/2) L4i[x y] + (1/2) L4i[x/y] + 2 L4i[(1-x)/(1-y)] + 2 L4i[y(1-x)/(x(1-y))]  +  2 L4i[(x-1)/(x(1-y))] + 2 L4i[y(1-x)/(y-1)] -L4i[y] - 2L4i[1-x] + 2L4i[1-y] - 2L4i[(x-1)/x] + 2 L4i[(y-1)/y];

kappa[x,y] + kappa[1/x, y] - (CreateTensor[A[y]/.L4i->L4]//sh)//ReduceTensorProduct//flatTensor//Expand

(* ------------ *)

kappa[x,y] + kappa[y,x]//ReduceTensorProduct//flatTensor//Expand

eta[y_] := -((1/(a b c))L4i[(t/(y^a(1-y)^b))] + (b/a)Lip[((1-p)/(1-y))]- (b/c)Lip[((1-1/y)/(1-1/p))] - (a/b)Lip[(y/p)] - (b/a)Lip[1-p] - b L4i[1 - 1/y] - c L4i[y])

(* a = 1; b = 2; c = -(a + b);

(* roots = a + b;

(* px[1] = 1/(1-x + x^2);
px[2] = px[1]/.x->1-1/x//Factor;
px[3] = px[2]/.x->1-1/x//Factor;

(* tx = px[1]^a(1-px[1])^b//Factor;

(* L4p[x_] := Sum[L4[x/.p->px[i]], {i, 1, roots}];

Sum[kappa[p,y]/.p->px[i], {i, 1, 3}] - (CreateTensor[eta[y]/.{Lip->L4p,t->tx}]//sh)//ReduceTensorProduct//flatTensor//Expand

Sum[kappa[y,p]/.p->px[i], {i, 1, 3}] - (CreateTensor[-eta[y]/.{Lip->L4p,t->tx}]//sh)//ReduceTensorProduct//flatTensor//Expand

(* ----------- *)

L4can[arg_] := If[Sort[Factor[{arg, 1/arg}]][[1]] ===Factor[arg], L4i[Factor[arg]], -L4i[Factor[1/arg]]]
Lpcan[arg_] := If[Sort[Factor[{arg, 1/arg}]][[1]] ===Factor[arg], Lip[Factor[arg]], -Lip[Factor[1/arg]]]

makeL4can[expr_]:= expr/.L4i->L4can
makeLpcan[expr_]:= expr/.Lip->Lpcan

(* Sum[A[p]] = Sum[kappa[x,p] + kappa[1/x, p]] = -eta[x] - eta[1/x]

out = (A[p]/.L4i->Lip) - (-eta[x] - eta[1/x])//makeL4can//makeLpcan

coeffsimp[expr_] := Plus@@(#[[1]]#[[2]]&/@(({Factor[Plus@@#[[All,1]]],#[[1,2]]})&/@(expr//Cases[#,(a_:1) b_L4i| (a_:1) b_Lip:>{a,b}]&//GatherBy[#, #[[2]]&]&)))

simp1 = -2*b*out/(c-a)//Expand//coeffsimp

simp2 = (simp1/.{Lip[1-x]:>-c*L4i[1-x],Lip[(-1+x)/x]->-c L4i[(-1+x)/x]}//Expand//coeffsimp)/.{2a + b->a-c,b + 2c->c-a}//coeffsimp

F := -2b L4i[1-x] - 2b L4i[1-1/x] + (2/(a c (c-a)))L4i[(t/(x^a(1-x)^b))] + (2/(a c(c-a)))L4i[(t/(x^c(x-1)^b))] + 
+ (b/(c-a))Lip[(1-x)^2/x * p/(1-p)^2] + ((2b)/a)Lip[(1-x)/(1-p)] + ((2b)/a)Lip[(1-1/x)/(1-p)] - ((2b)/c)Lip[(1-x)/(1-1/p)] - ((2b)/( c))Lip[(1-1/x)/(1-1/p)] + Lip[x/p] - Lip[x p] + 2 Lip[p]

alg4 = 1/a Lip[1/(1-p)] + 1/b Lip[p] + 1/c Lip[1-1/p];

F - (simp2+ ((4b c)/(c-a))alg4)/.c->-a-b//makeL4can//makeLpcan//Expand//coeffsimp