Basics of RNS superstring
Superconformal OPE, BRST charge and PCO

Execute the first two sections to use this Mathematica notebook

The basic idea of OPE is to subtract all singularities until none is found. We consider four types of OPE’s,
  1) Normal, 	:A: :B:    = :AB: + Wick
  2) Exp, 	:A: : (e^B): = Wick : (e^B):
For clarity, we first implement the Normal OPE’s, and then modify it to the Exp OPE’s (the two procedures may be unified).
Our code works only when there exists at most one exponential operator ((e^(±ϕ)) or (e^(±2ϕ))) inside each normal-ordering

Definitions of algorithm

Global variables

Normal ordering is denoted by AngleBracket, ⟨ a, b, c , ... ⟩

(* Abbreviates *)
FS=FullSimplify;
AB=AngleBracket;

(* Notations *)
<<Notation`
Notation[(NotationTemplateTag[(Subscript[g, a_,b_])]) ⟺ (NotationTemplateTag[g[a_,b_]])]
Notation[(NotationTemplateTag[(Subscript[X, m_])[z_]]) ⟺ (NotationTemplateTag[X[z_,m_]])]
Notation[(NotationTemplateTag[Derivative[n_][(Subscript[X, m_])][z_]]) ⟺ (NotationTemplateTag[Derivative[n_,0][X][z_,m_]])]
Notation[(NotationTemplateTag[(Subscript[ψ, m_])[z_]]) ⟺ (NotationTemplateTag[ψ[z_,m_]])]
Notation[(NotationTemplateTag[Derivative[n_][(Subscript[ψ, m_])][z_]]) ⟺ (NotationTemplateTag[Derivative[n_,0][ψ][z_,m_]])]

(* Attributes - Numeric *)
SetAttributes[g,NumericFunction]
λ/:NumericQ[λ]=True;
λ1/:NumericQ[λ1]=True;
λ2/:NumericQ[λ2]=True;
λ3/:NumericQ[λ3]=True;
λ4/:NumericQ[λ4]=True;
μ/:NumericQ[μ]=True;
μ1/:NumericQ[μ1]=True;
μ2/:NumericQ[μ2]=True;
ν/:NumericQ[ν]=True;
ν1/:NumericQ[ν1]=True;
ν2/:NumericQ[ν2]=True;

(* Attributes - Operators *)
opSet={X,ψ,b,c,β,γ,ξ,η,ϕ,Φp,Φm,Φ2p,Φ2m,κ};

(* Attributes - Fermionic *)
fermionSet={b,c,ψ,ξ,η,Φp,Φm,κ};

(* Attributes - Exponential *)
expSet={Φp,Φm,Φ2p,Φ2m};

(* Counting operators *)
NotOperatorQ[x_]:=And@@(FreeQ[x,#]&/@opSet);

Fermions and Exps

The signature function:  ⟨...,ψ,...⟩=(((-1))^(𝕗p))⟨...,ψ⟩=(((-1))^(𝕗b))⟨ψ,...⟩

FermionicQ[x_]:=MemberQ[fermionSet,Head[(x/.Derivative[n_][y_]:>y/.Derivative[n_,m_][y_]:>y)]];
countFermions[ll_]:=Count[FermionicQ/@ll,True];
posFermions[ll_]:=Flatten@Map[First,(Position[ll,#]&/@fermionSet),{2}];

𝕗p[⟨a__⟩,ι_]:=Boole@FermionicQ[⟨a⟩[[ι]]]*(((1-(-1)^(countFermions[⟨a⟩[[ι+1;;]]]))/2));
𝕗b[⟨a__⟩,ι_]:=Boole@FermionicQ[⟨a⟩[[ι]]]*(((1-(-1)^(countFermions[⟨a⟩[[;;ι-1]]]))/2));

(* Reorder fermions *)
reorder[sth_AngleBracket]:=Signature[Part[sth,Sort[posFermions[sth]]]]*Join[
Sort@Part[sth,Complement[Range[Length@sth],posFermions[sth]]],
Sort@Part[sth,Sort@posFermions[sth]]];
statistics[something_]:=something/.X_AngleBracket:>reorder@X ;

ExpQ[x_]:=MemberQ[expSet,Head[(x/.Derivative[n_][y_]:>y/.Derivative[n_,m_][y_]:>y)]];
countExps[ll_]:=Count[ExpQ/@ll,True];
posExps[ll_]:=Flatten@Map[First,(Position[ll,#]&/@expSet),{2}];

countϕ[ll_]:=Count[MemberQ[{ϕ},Head[(#/.Derivative[n_][y_]:>y/.Derivative[n_,m_][y_]:>y)]]&/@ll,True];

countf[ll_]:=countExps[ll]+countϕ[ll];

Wick contractions

Since Wick contractions can be taken in any order, we move the 1st field in the 1st argument to the 1st position in the 2nd argument,
:(Subscript[A, 1])... (Subscript[A, m]) (w): :(Subscript[B, 1])... (Subscript[B, n]) (z): ~ :(Subscript[A, 2])... (Subscript[A, m]) (w): :(Subscript[A, 1])(w)(Subscript[B, 1])... (Subscript[B, n]) (z):+ (∑_i)Wick[(Subscript[A, 1])(w),(Subscript[B, i])(w)]:(Subscript[A, 2])... (Subscript[A, m]) (w): :(Subscript[B, 1])... (Subscript[B, n]) (z):

contractionN[sth__]:=Expand@Distribute@WickN@sth;

(* Wick contractions for normal -- shorten the 1st arg *)
WickN[⟨a__⟩,⟨b__⟩]:=(((-1))^(𝕗p[⟨a⟩,1]))WickN[Drop[⟨a⟩,{1}],Join[AB[⟨a⟩[[1]]],⟨b⟩]]+ (∑_(ι2)^(Length[⟨b⟩]))(((-1))^(𝕗p[⟨a⟩,1]+𝕗b[⟨b⟩,ι2]))propagatorN[⟨a⟩[[1]],⟨b⟩[[ι2]]] WickN[Drop[⟨a⟩,{1}],Drop[⟨b⟩,{ι2}]];

WickN[⟨a__⟩,⟨⟩]:=⟨a⟩;
WickN[⟨⟩,⟨a__⟩]:=⟨a⟩;
WickN[⟨⟩,⟨⟩]:=1;

WickN[Times[before___?NumericQ,AngleBracket[sth__],after___?NumericQ],AngleBracket[sth2__]]:=before *after*WickN[AngleBracket[sth],AngleBracket[sth2]];
WickN[AngleBracket[sth2__],Times[before___?NumericQ,AngleBracket[sth__],after___?NumericQ]]:=before *after*WickN[AngleBracket[sth2],AngleBracket[sth]];
WickN[Times[before___?NumericQ,AngleBracket[sth__],after___?NumericQ],Times[before2___?NumericQ,AngleBracket[sth2__],after2___?NumericQ]]:=before *after*before2*after2*WickN[AngleBracket[sth],AngleBracket[sth2]];


(* Wick contractions for normal -- shorten the 2nd arg, to be used later *)
WickN2[⟨a__⟩,⟨b__⟩]:=(((-1))^(𝕗b[⟨b⟩,1]))WickN2[Join[⟨a⟩,AB[⟨b⟩[[1]]]],Drop[⟨b⟩,{1}]]+ (∑_(ι1)^(Length[⟨a⟩]))(((-1))^(𝕗p[⟨a⟩,ι1]+𝕗b[⟨b⟩,1]))propagatorN[⟨a⟩[[ι1]],⟨b⟩[[1]]] WickN2[Drop[⟨a⟩,{ι1}],Drop[⟨b⟩,{1}]];

WickN2[⟨a__⟩,⟨⟩]:=⟨a⟩;
WickN2[⟨⟩,⟨a__⟩]:=⟨a⟩;
WickN2[⟨⟩,⟨⟩]:=1;

WickN2[Times[before___?NumericQ,AngleBracket[sth__],after___?NumericQ],AngleBracket[sth2__]]:=before *after*WickN2[AngleBracket[sth],AngleBracket[sth2]];
WickN2[AngleBracket[sth2__],Times[before___?NumericQ,AngleBracket[sth__],after___?NumericQ]]:=before *after*WickN2[AngleBracket[sth2],AngleBracket[sth]];
WickN2[Times[before___?NumericQ,AngleBracket[sth__],after___?NumericQ],Times[before2___?NumericQ,AngleBracket[sth2__],after2___?NumericQ]]:=before *after*before2*after2*WickN2[AngleBracket[sth],AngleBracket[sth2]];

(* expand around w=z *)
expansion[sth_]:=expansion[w,z,sth,-1];
expansion0[sth_]:=expansion[w,z,sth,0];
expansion[sth_,nn_]:=expansion[w,z,sth,nn];

expansion[w_,z_,sth_,nn_]:=sth/.Y_AngleBracket:>(Normal@Series[#,{w,z,6}]&/@Y)//.⟨before___,x_+number_.(((w-z))^(n_.))y_,after___⟩:>⟨before,x,after⟩+number(((w-z))^n)⟨before,y,after⟩/;NotOperatorQ[number]//Series[#,{w,z,nn}]&//Simplify

Exp Wick contractions

We repeat the Wick contractions
   Wick[A(w)(Subscript[f, ϕ])(w),B(z) (Subscript[g, ϕ])(z) ]= Wick[A ,B Wick[(Subscript[f, ϕ])(w),(Subscript[g, ϕ])(z)]]   if  (Subscript[f, ϕ])=(e^(m ϕ)) and  (Subscript[g, ϕ])=(e^(n ϕ))
   Wick[A(w)(Subscript[f, ϕ])(w),B(z) (Subscript[g, ϕ])(z) ]= :A (Subscript[f, ϕ]) B (Subscript[g, ϕ]): + Wick[A Wick[(Subscript[f, ϕ])(w),(Subscript[g, ϕ])(z)] ,B ]  if  (Subscript[f, ϕ])=(e^(m ϕ))  and  (Subscript[g, ϕ]) not exp
   Wick[A(w)(Subscript[f, ϕ])(w),B(z) (Subscript[g, ϕ])(z) ]= :A (Subscript[f, ϕ]) B (Subscript[g, ϕ]): + Wick[A , B  Wick[(Subscript[f, ϕ])(w),(Subscript[g, ϕ])(z)] ]  if  (Subscript[g, ϕ])=(e^(n ϕ)) and  (Subscript[f, ϕ])  not exp

(* Pairwise contraction, as a list of {coefficient, bracket} *)
tabWick[op1_,op2_]:=Module[{prop=propagatorX[op1,op2],lisWick,coeffs,brackets},
If[prop===0,{{0,AB[0]}},
lisWick=DeleteCases[List@@Expand[prop+ω ],ω];
coeffs=lisWick/.AB[x___]->1//Simplify;
brackets=lisWick/coeffs//Simplify;
Transpose[{coeffs,brackets}]]
];

contractionX[sth__]:=Expand@Distribute@WickX@sth;

(* Wick contractions for Exp *)
WickX[⟨a__⟩,⟨b__⟩]:=If[countExps[⟨a⟩]*countExps[⟨b⟩]>0,
(* exp in both arg -- shorten the 1st arg *)
If[countExps[⟨a⟩]>1||countExps[⟨b⟩]>1,
Print["Error: multiple exponentials"]; (* this function is never used *)
Speak["Error"],
(((-1))^(𝕗p[⟨a⟩,Plus@@posExps[⟨a⟩]]+𝕗b[⟨b⟩,Plus@@posExps[⟨b⟩]]))(∑_kk^(Length@tabWick[Extract[⟨a⟩,posExps[⟨a⟩]],Extract[⟨b⟩,posExps[⟨b⟩]]]))tabWick[Extract[⟨a⟩,posExps[⟨a⟩]],Extract[⟨b⟩,posExps[⟨b⟩]]][[kk,1]]*WickX[Drop[⟨a⟩,posExps[⟨a⟩]],Join[tabWick[Extract[⟨a⟩,posExps[⟨a⟩]],Extract[⟨b⟩,posExps[⟨b⟩]]][[kk,2]],Drop[⟨b⟩,posExps[⟨b⟩]]]]
],
Which[countExps[⟨a⟩]==0&&countExps[⟨b⟩]>0,
(* exp only in the 2nd arg -- shorten the 1st arg *)
If[countf[⟨a⟩]>0,
(((-1))^(𝕗p[⟨a⟩,1]))WickX[Drop[⟨a⟩,{1}],Join[AB[⟨a⟩[[1]]],⟨b⟩]]+(∑_(ι2)^(posExps[⟨b⟩]))(((-1))^(𝕗p[⟨a⟩,1]+𝕗b[⟨b⟩,ι2]))(∑_kk^(Length@tabWick[⟨a⟩[[1]],⟨b⟩[[ι2]]]))tabWick[⟨a⟩[[1]],⟨b⟩[[ι2]]][[kk,1]]WickX[Drop[⟨a⟩,{1}],Join[tabWick[⟨a⟩[[1]],⟨b⟩[[ι2]]][[kk,2]],Drop[⟨b⟩,{ι2}]]],
WickN[⟨a⟩,⟨b⟩]
],
countExps[⟨a⟩]>0&&countExps[⟨b⟩]==0,
(* exp only in the 1st arg -- shorten the 2nd arg *)
If[countf[⟨b⟩]>0,
(((-1))^(𝕗b[⟨b⟩,1]))WickX[Join[⟨a⟩,AB[⟨b⟩[[1]]]],Drop[⟨b⟩,{1}]]+(∑_(ι1)^(posExps[⟨a⟩]))(((-1))^(𝕗p[⟨a⟩,ι1]+𝕗b[⟨b⟩,1]))(∑_kk^(Length@tabWick[⟨a⟩[[ι1]],⟨b⟩[[1]]]))tabWick[⟨a⟩[[ι1]],⟨b⟩[[1]]][[kk,1]]WickX[Join[Drop[⟨a⟩,{ι1}],tabWick[⟨a⟩[[ι1]],⟨b⟩[[1]]][[kk,2]]],Drop[⟨b⟩,{1}]],
WickN2[⟨a⟩,⟨b⟩]
],
countExps[⟨a⟩]==0&&countExps[⟨b⟩]==0,
 (* no exp -- reduce the 1st arg *)
Which[Length[⟨a⟩]*Length[⟨b⟩]>0,WickN[⟨a⟩,⟨b⟩],
Length[⟨a⟩]==0&&Length[⟨b⟩]>0,⟨b⟩,
Length[⟨a⟩]>0&&Length[⟨b⟩]==0,⟨a⟩,
Length[⟨a⟩]==0&&Length[⟨b⟩]==0,zero[] (* this function is never used *)
]
]
];

WickX[⟨a__⟩,⟨⟩]:=⟨a⟩;
WickX[⟨⟩,⟨a__⟩]:=⟨a⟩;
WickX[⟨⟩,⟨⟩]:=1;
WickX[⟨a__⟩]:=⟨a⟩;

WickX[Times[before___?NumericQ,AngleBracket[sth__],after___?NumericQ],AngleBracket[sth2__]]:=before *after*WickX[AngleBracket[sth],AngleBracket[sth2]];
WickX[AngleBracket[sth2__],Times[before___?NumericQ,AngleBracket[sth__],after___?NumericQ]]:=before *after*WickX[AngleBracket[sth2],AngleBracket[sth]];
WickX[Times[before___?NumericQ,AngleBracket[sth__],after___?NumericQ],Times[before2___?NumericQ,AngleBracket[sth2__],after2___?NumericQ]]:=before *after*before2*after2*WickX[AngleBracket[sth],AngleBracket[sth2]];

Propagators

(* generic propagators *)
propagatorN[f1_[z_],f2_[z_]]:=0 ;
propagatorN[f1_[z_,m_],f2_[z_,n_]]:=0 ;

propagatorN[Derivative[n_][f_][z_],Y_]:=(∂_({z,n}))propagatorN[f[z],Y];
propagatorN[Y_,Derivative[n_][f_][w_]]:=(∂_({w,n}))propagatorN[Y,f[w]];

propagatorN[Derivative[n_,0][f_][z_,m_],Y_]:=(∂_({z,n}))propagatorN[f[z,m],Y];
propagatorN[Y_,Derivative[n_,0][f_][w_,m_]]:=(∂_({w,n}))propagatorN[Y,f[w,m]];
propagatorN[__]=0;

propagatorN[X[w_,m_],X[z_,n_]]:=-g[m,n](Log[w-z]+Log[wb-zb]);
propagatorN[ψ[w_,m_],ψ[z_,n_]]:=((-g[m,n])/((w-z)));
propagatorN[γ[w_],β[z_]]:=(1/(w-z));
propagatorN[β[w_],γ[z_]]:=((-1)/(w-z)) ;
propagatorN[c[w_],b[z_]]:=(1/(w-z));
propagatorN[b[w_],c[z_]]:=(1/(w-z)) ;
propagatorN[η[w_],ξ[z_]]:=(1/(w-z));
propagatorN[ξ[w_],η[z_]]:=(1/(w-z)) ;
propagatorN[ϕ[w_],ϕ[z_]]:=-Log[w-z];

Exp Propagators

Note that  ϕ · (∂_w)(Subscript[Φ, ±])=(∂_w)(-log(z-w)(Subscript[Φ, ±])) and not  (1/(z-w))(Subscript[Φ, ±])

propagatorX[__]=⟨0⟩;
propagatorX[f1_[z_],f2_[z_]]:=⟨0⟩;
propagatorX[f1_[z_,m_],f2_[z_,n_]]:=⟨0⟩;

subDAB={AngleBracket'[f_[w_]]:>AB[f'[w]]/f'[w],
 Derivative[1,0][AngleBracket][f1_[w_],f2_[z_]]:>AB[f1'[w],f2[z]]/f1'[w],
 Derivative[0,1][AngleBracket][f1_[w_],f2_[z_]]:>AB[f1[w],f2'[z]]/f2'[z]};

propagatorX[f_[w_],Derivative[n_][g_][z_]]:=((∂_({z,n}))propagatorX[f[w],g[z]])/.subDAB//Simplify;
propagatorX[Derivative[m_][f_][w_],g_[z_]]:=((∂_({w,m}))propagatorX[f[w],g[z]])/.subDAB//Simplify;

(* propagatorX[ϕ[w_],ϕ[z_]]:=-Log[w-z]⟨1⟩; *)

propagatorX[ϕ[w_],Φp[z_]]:=-Log[w-z]⟨Φp[z]⟩;
propagatorX[ϕ[w_],Φm[z_]]:=+Log[w-z]⟨Φm[z]⟩;
propagatorX[Φp[w_],ϕ[z_]]:=-Log[w-z]⟨Φp[w]⟩;
propagatorX[Φm[w_],ϕ[z_]]:=+Log[w-z]⟨Φm[w]⟩;
propagatorX[Φm[w_],Φm[z_]]:=(1/(w-z)) ⟨Φm[w],Φm[z]⟩;
propagatorX[Φp[w_],Φp[z_]]:=(1/(w-z)) ⟨Φp[w],Φp[z]⟩;
propagatorX[Φm[w_],Φp[z_]]:=(w-z )⟨Φm[w],Φp[z]⟩;
propagatorX[Φp[w_],Φm[z_]]:=(w-z )⟨Φp[w],Φm[z]⟩;

(* extra definitions *)
propagatorX[ϕ[w_],Φ2p[z_]]:=-2Log[w-z]⟨Φ2p[z]⟩;
propagatorX[ϕ[w_],Φ2m[z_]]:=+2Log[w-z]⟨Φ2m[z]⟩;
propagatorX[Φ2p[w_],ϕ[z_]]:=-2Log[w-z]⟨Φ2p[w]⟩;
propagatorX[Φ2m[w_],ϕ[z_]]:=+2Log[w-z]⟨Φ2m[w]⟩;

propagatorX[Φm[w_],Φ2p[z_]]:=(((w-z ))^2)⟨Φm[w],Φ2p[z]⟩;
propagatorX[Φ2p[w_],Φm[z_]]:=(((w-z ))^2)⟨Φ2p[w],Φm[z]⟩;
propagatorX[Φ2m[w_],Φp[z_]]:=(((w-z ))^2)⟨Φ2m[w],Φ2p[z]⟩;
propagatorX[Φp[w_],Φ2m[z_]]:=(((w-z ))^2)⟨Φ2p[w],Φ2m[z]⟩;

Useful functions

(* derivative of brackets *)
delAB[brackets_]:=Module[{lis,terms,coeffs,dels},
lis=DeleteCases[List@@Expand[brackets+ω],ω];
coeffs=lis/.AB[x___]->1;
terms=lis/coeffs;
dels=Table[Sum[ReplacePart[terms[[i]],j->D[terms[[i,j]],z]],{j,Length[terms[[i]]]}],{i,Length[terms]}];
coeffs.dels//FS
]

delAB[brackets_,z_]:=Module[{lis,terms,coeffs,dels},
lis=DeleteCases[List@@Expand[brackets+ω],ω];
coeffs=lis/.AB[x___]->1;
terms=lis/coeffs;
dels=Table[Sum[ReplacePart[terms[[i]],j->D[terms[[i,j]],z]],{j,Length[terms[[i]]]}],{i,Length[terms]}];
coeffs.dels//FS
]

(* κ must have be κ[z]. No κ[w] *)
takeK[bracket_]:=Module[{brac=bracket/.κ[any_]->κ[z],pos},
pos=Flatten@Position[brac,κ[z]];
Which[Length@pos==0,brac,
Length@pos==1,If[Length@brac==1,⟨κ[z]⟩,
(((-1))^(countFermions[brac[[;;First[pos]-1]]]))Join[⟨κ[z]⟩,Drop[brac,pos]]],
Length@pos≥2,0]
];

Definitions of dynamical variables

Stress-energy tensors

TX[z_,μ_,ν_]:=((-1)/2)⟨(∂_z)X[z,μ],(∂_z)X[z,ν]⟩;
Tψ[z_,μ_,ν_]:=(1/2)⟨ψ[z,μ],(∂_z)ψ[z,ν]⟩;
Tβ[z_]:=(((3-2λ)/2))⟨γ[z],(∂_z)β[z]⟩-(((2λ-1)/2))⟨(∂_z)γ[z],β[z]⟩;
Tb[z_]:=-(1-λ)⟨c[z],(∂_z)b[z]⟩+λ⟨(∂_z)c[z],b[z]⟩;
Tϕ[z_]:=((-1)/2)⟨(∂_z)ϕ[z],(∂_z)ϕ[z]⟩-λ1⟨(∂_z)(∂_z)ϕ[z]⟩;

ruleT:=Join[ruleTT[1],ruleTT[2],ruleTT[3],ruleTT[4]];

ruleTT[1]={⟨Derivative[1][(Subscript[X, μ_])][z],Derivative[1][(Subscript[X, ν_])][z]⟩:>((-2)/(Subscript[g, μ,ν]))𝕋X[z],
⟨Derivative[2][(Subscript[X, μ_])][z_],Derivative[1][(Subscript[X, ν_])][z_]⟩:>⟨Derivative[1][(Subscript[X, μ])][z],Derivative[2][(Subscript[X, ν])][z]⟩,
⟨Derivative[1][(Subscript[X, μ_])][z_],Derivative[2][(Subscript[X, ν_])][z_]⟩:>((-1)/(Subscript[g, μ,ν]))(∂_z)𝕋X[z],
⟨(Subscript[ψ, μ_])[z_],(Subscript[ψ, ν_])[z_]⟩:>0,
⟨Derivative[n_][(Subscript[ψ, μ_])][z_],(Subscript[ψ, ν_])[z_]⟩:>-⟨(Subscript[ψ, ν])[z],Derivative[n][(Subscript[ψ, μ])][z]⟩,
⟨(Subscript[ψ, μ_])[z_],Derivative[1][(Subscript[ψ, ν_])][z_]⟩:>(2/(Subscript[g, μ,ν]))𝕋ψ[z],
⟨(Subscript[ψ, μ_])[z_],Derivative[2][(Subscript[ψ, ν_])][z_]⟩:>(2/(Subscript[g, μ,ν]))(∂_z)𝕋ψ[z]-⟨Derivative[1][(Subscript[ψ, μ])][z],Derivative[1][(Subscript[ψ, ν])][z]⟩};

ruleTT[2]={⟨β[z_],γ[z_]⟩:>⟨γ[z],β[z]⟩,
⟨β[z_],γ'[z_]⟩:>⟨γ'[z],β[z]⟩,
⟨β[z_],γ''[z_]⟩:>⟨γ''[z],β[z]⟩,
⟨β'[z_],γ[z_]⟩:>⟨γ[z],β'[z]⟩,
⟨β''[z_],γ[z_]⟩:>⟨γ[z],β''[z]⟩,
⟨γ'[z_],β'[z_]⟩:>⟨β'[z],γ'[z]⟩,
⟨γ'[z_],β[z_]⟩:>(2/(2λ-1))(-𝕋β[z]+(((3-2λ)/2))⟨γ[z],β'[z]⟩),
⟨γ''[z_],β[z_]⟩:>(2/(2λ-1))(-𝕋β'[z]+(((3-2λ)/2))(⟨γ[z],β''[z]⟩+⟨γ'[z],β'[z]⟩))-⟨γ'[z],β'[z]⟩};
ruleTT[3]={⟨b[z_],c[z_]⟩:>-⟨c[z],b[z]⟩,
⟨b[z_],c'[z_]⟩:>-⟨c'[z],b[z]⟩,
⟨b[z_],c''[z_]⟩:>-⟨c''[z],b[z]⟩,
⟨b'[z_],c[z_]⟩:>-⟨c[z],b'[z]⟩,
⟨b'[z_],c'[z_]⟩:>-⟨c'[z],b'[z]⟩,
⟨b''[z_],c[z_]⟩:>-⟨c[z],b''[z]⟩,
⟨c'[z_],b[z_]⟩:>(1/λ)(𝕋b[z]+(1-λ)⟨c[z],b'[z]⟩),
⟨c''[z_],b[z_]⟩:>(1/λ)(𝕋b'[z]+(1-λ)(⟨c[z],b''[z]⟩+⟨c'[z],b'[z]⟩))-⟨c'[z],b'[z]⟩};

ruleTT[4]={⟨ϕ'[z],ϕ'[z]⟩:>-2𝕋ϕ[z]-2λ1⟨Derivative[2][ϕ][z]⟩,
⟨ϕ''[z],ϕ'[z]⟩:>-(∂_z)𝕋ϕ[z]-λ1⟨Derivative[3][ϕ][z]⟩,
⟨ϕ'[z],ϕ''[z]⟩:>-(∂_z)𝕋ϕ[z]-λ1⟨Derivative[3][ϕ][z]⟩};

Stress-energy tensor superfields

(* matter *)
𝕏[z_,μ_]:=AB[X[z,μ]]+AB[κ[z],ψ[z,μ]];
D𝕏[z_,μ_]:=AB[ψ[z,μ]]+AB[κ[z],(∂_z)X[z,μ]];
d𝕏[z_,μ_]:=AB[(∂_z)X[z,μ]]+AB[κ[z],(∂_z)ψ[z,μ]];

(* ghost before bosonization *)
ℂ0[z_]:=AB[c[z]]+AB[κ[z],γ[z]];
𝔹0[z_]:=AB[β[z]]+AB[κ[z],b[z]];
Dℂ0[z_]:=AB[γ[z]]+AB[κ[z],(∂_z)c[z]];
D𝔹0[z_]:=AB[b[z]]+AB[κ[z],(∂_z)β[z]];
dℂ0[z_]:=AB[(∂_z)c[z]]+AB[κ[z],(∂_z)γ[z]];
d𝔹0[z_]:=AB[(∂_z)β[z]]+AB[κ[z],(∂_z)b[z]];

(* ghost after bosonization *)
ℂ[z_]:=AB[c[z]]+AB[κ[z],η[z],Φp[z]];
𝔹[z_]:=AB[Φm[z],(∂_z)ξ[z]]+AB[κ[z],b[z]];
Dℂ[z_]:=AB[η[z],Φp[z]]+AB[κ[z],(∂_z)c[z]];
D𝔹[z_]:=AB[b[z]]+AB[κ[z],(∂_z)Φm[z],(∂_z)ξ[z]]+AB[κ[z],Φm[z],(∂_z)(∂_z)ξ[z]];
dℂ[z_]:=AB[(∂_z)c[z]]+AB[κ[z],(∂_z)η[z],Φp[z]]+AB[κ[z],η[z],(∂_z)Φp[z]];
d𝔹[z_]:=AB[(∂_z)Φm[z],(∂_z)ξ[z]]+AB[Φm[z],(∂_z)(∂_z)ξ[z]]+AB[κ[z],(∂_z)b[z]];

Tmat[z_,μ_,ν_]:=-(1/2) ⟨Derivative[1][(Subscript[X, μ])][z],Derivative[1][(Subscript[X, ν])][z]⟩ +(1/2) ⟨(Subscript[ψ, μ])[z],Derivative[1][(Subscript[ψ, ν])][z]⟩ ;
Gmat[z_,μ_,ν_]:=-(1/2) ⟨(Subscript[ψ, μ])[z],Derivative[1][(Subscript[X, ν])][z]⟩;

Tgh[z_]:=⟨c[z],(∂_z)b[z]⟩+2⟨(∂_z)c[z],b[z]⟩-(1/2)⟨γ[z],(∂_z)β[z]⟩-(3/2)⟨(∂_z)γ[z],β[z]⟩;
Ggh[z_]:=-2 ⟨c[z],(∂_z)β[z]⟩+⟨γ[z],b[z]⟩-3⟨(∂_z)c[z],β[z]⟩;

Tbh[z_]:=⟨c[z],(∂_z)b[z]⟩+2⟨(∂_z)c[z],b[z]⟩-⟨η[z],(∂_z)ξ[z]⟩-(1/2)⟨(∂_z)ϕ[z],(∂_z)ϕ[z]⟩-⟨(∂_z)(∂_z)ϕ[z]⟩;
Gbh[z_]:=-2⟨c[z],Φm[z],(∂_z)(∂_z)ξ[z]⟩-2⟨c[z],(∂_z)Φm[z],(∂_z)ξ[z]⟩+⟨η[z],Φp[z],b[z]⟩-3⟨(∂_z)c[z],Φm[z],(∂_z)ξ[z]⟩;

Tβ2[z_]:=-(1/2)⟨γ[z],(∂_z)β[z]⟩-(3/2)⟨(∂_z)γ[z],β[z]⟩;
Tη2[z_]:=-⟨η[z],(∂_z)ξ[z]⟩-(1/2)⟨(∂_z)ϕ[z],(∂_z)ϕ[z]⟩-⟨(∂_z)(∂_z)ϕ[z]⟩;

ruleGmat={ ⟨(Subscript[ψ, μ_])[z_],Derivative[1][(Subscript[ψ, ν_])][z_]⟩ (Subscript[g, μ_,ν_]):>2𝕋mat[z]+ ⟨Derivative[1][(Subscript[X, μ])][z],Derivative[1][(Subscript[X, ν])][z]⟩ (Subscript[g, μ,ν]),
 ⟨Derivative[1][(Subscript[X, μ_])][z_],(Subscript[ψ, ν_])[z_]⟩ (Subscript[g, μ_,ν_]):>-2𝔾mat[z],
 ⟨(Subscript[ψ, μ_])[z_],Derivative[1][(Subscript[X, ν_])][z_]⟩ (Subscript[g, μ_,ν_]):>-2𝔾mat[z],
⟨Derivative[2][(Subscript[X, μ_])][z_],(Subscript[ψ, ν_])[z_]⟩ (Subscript[g, μ_,ν_]):>-2(∂_z)𝔾mat[z]-⟨Derivative[1][(Subscript[ψ, μ])][z],Derivative[1][(Subscript[X, ν])][z]⟩ (Subscript[g, μ,ν]),
⟨(Subscript[ψ, μ_])[z_],Derivative[2][(Subscript[X, ν_])][z_]⟩ (Subscript[g, μ_,ν_]):>-2(∂_z)𝔾mat[z]-⟨Derivative[1][(Subscript[ψ, μ])][z],Derivative[1][(Subscript[X, ν])][z]⟩ (Subscript[g, μ,ν])};

ruleGh={⟨β[z_],c[z_]⟩:>⟨c[z],β[z]⟩,
⟨β[z_],c'[z_]⟩:>⟨c'[z],β[z]⟩,
⟨Derivative[n_][β][z_],c[z_]⟩:>⟨c[z],Derivative[n][β][z]⟩,
⟨β[z_],Derivative[n_][c][z_]⟩:>⟨Derivative[n][c][z],β[z]⟩,
⟨β'[z_],c'[z_]⟩:>⟨c'[z],β'[z]⟩,
⟨b[z_],γ[z_]⟩:>⟨γ[z],b[z]⟩,
⟨b'[z_],γ[z_]⟩:>⟨γ[z],b'[z]⟩,
⟨b[z_],γ'[z_]⟩:>⟨γ'[z],b[z]⟩,
⟨γ[z_],b[z_]⟩:>𝔾gh[z]+2⟨c[z],(∂_z)β[z]⟩+3⟨(∂_z)c[z],β[z]⟩,
⟨γ'[z_],b[z_]⟩:>(∂_z)𝔾gh[z]+2⟨c[z],(∂_z)(∂_z)β[z]⟩+5⟨(∂_z)c[z],(∂_z)β[z]⟩+3⟨(∂_z)(∂_z)c[z],β[z]⟩-⟨γ[z],b'[z]⟩};

ruleBh={⟨ϕ'[z_],ϕ'[z_]⟩:>-2𝕋ϕ[z]-2⟨Derivative[2][ϕ][z]⟩,
⟨ϕ''[z_],ϕ'[z_]⟩:>-(∂_z)𝕋ϕ[z]-⟨Derivative[3][ϕ][z]⟩,
⟨ϕ'[z_],ϕ''[z_]⟩:>-(∂_z)𝕋ϕ[z]-⟨Derivative[3][ϕ][z]⟩,
⟨ξ'[z_],η[z_]⟩:>Th[z],
⟨η[z_],ξ'[z_]⟩:>-Th[z],
⟨ξ'[z_],η'[z_]⟩:>-⟨η'[z],ξ'[z]⟩,
⟨ξ''[z_],η[z_]⟩:>(∂_z)Th[z]+⟨η'[z],ξ'[z]⟩,
⟨b[z_],c[z_]⟩:>-⟨c[z],b[z]⟩,
⟨b[z_],Derivative[n_][c][z_]⟩:>-⟨Derivative[n][c][z],b[z]⟩,
⟨Derivative[m_][b][z_],c[z_]⟩:>-⟨c[z],Derivative[m][b][z]⟩,
⟨Derivative[m_][b][z_],Derivative[n_][c][z_]⟩:>-⟨Derivative[n][c][z],Derivative[m][b][z]⟩,
⟨c[z_],b'[z_]⟩:>𝕋b[z]-2⟨c'[z],b[z]⟩,
⟨c''[z_],b[z_]⟩:>(1/2)(𝕋b'[z]-(⟨c[z],b''[z]⟩+⟨c'[z],b'[z]⟩))-⟨c'[z],b'[z]⟩,
⟨b[z_],η[z_],Φp[z_]⟩:>𝔾bh[z]+2 ⟨c[z],Φm[z],ξ''[z]⟩+2 ⟨c[z],(Φm)'[z],ξ'[z]⟩+3 ⟨c'[z],Φm[z],ξ'[z]⟩,
⟨b[z_],Φp[z_],η'[z_]⟩:>-(∂_z)𝔾bh[z]-2 ⟨c[z],Φm[z],Derivative[3][ξ][z]⟩-4 ⟨c[z],(Φm)'[z],ξ''[z]⟩-2 ⟨c[z],(Φm)''[z],ξ'[z]⟩+⟨η[z],Φp[z],b'[z]⟩+⟨η[z],(Φp)'[z],b[z]⟩-5 ⟨c'[z],Φm[z],ξ''[z]⟩-5 ⟨c'[z],(Φm)'[z],ξ'[z]⟩-3 ⟨c''[z],Φm[z],ξ'[z]⟩};

to simplify (Subscript[g, μ,ν])

ruleMetric={g[a_,b_]:>g[Sort[{a,b}][[1]],Sort[{a,b}][[2]]],
(((g[a_,b_]))^2):>dim,
Times[x1___,g[a_,b_],x2___,g[a_,b_],x3___]:>x1 x2 x3 dim,Times[x1___,g[a_,b_],x2___,g[a_,c_],x3___]:>x1 x2 x3 (Subscript[g, b,c])/;!b===c,
Times[x1___,g[a_,b_],x2___,g[c_,a_],x3___]:>x1 x2 x3 (Subscript[g, b,c])/;!b===c,Times[x1___,g[b_,a_],x2___,g[a_,c_],x3___]:>x1 x2 x3 (Subscript[g, b,c])/;!b===c,
Times[x1___,g[b_,a_],x2___,g[c_,a_],x3___]:>x1 x2 x3 (Subscript[g, b,c])/;!b===c};

“ruleMetric2” and “ruleMetric2” should not be used if there are more than 2 spacetime vectors

ruleMetric2={⟨any___,Derivative[n1_][(Subscript[X, μ1_])][z_],any2___,Derivative[n2_][(Subscript[X, μ2_])][z_],any3___⟩g[μ1_,μ2_]:>⟨any,Derivative[n1][(Subscript[X, μ])][z],any2,Derivative[n2][(Subscript[X, ν])][z],any3⟩g[μ,ν],
⟨any___,Derivative[n1_][(Subscript[X, μ1_])][z_],any2___,Derivative[n2_][(Subscript[X, μ2_])][z_],any3___⟩g[μ2_,μ1_]:>⟨any,Derivative[n1][(Subscript[X, μ])][z],any2,Derivative[n2][(Subscript[X, ν])][z],any3⟩g[μ,ν],⟨any___,Derivative[n_][(Subscript[X, μ1_])][z_],any2___,(Subscript[ψ, μ2_])[z_],any3___⟩g[μ1_,μ2_]:>⟨any,Derivative[n][(Subscript[X, μ])][z],any2,(Subscript[ψ, ν])[z],any3⟩g[μ,ν],
⟨any___,Derivative[n_][(Subscript[X, μ1_])][z_],any2___,(Subscript[ψ, μ2_])[z_],any3___⟩g[μ2_,μ1_]:>⟨any,Derivative[n][(Subscript[X, μ])][z],any2,(Subscript[ψ, ν])[z],any3⟩g[μ,ν],
⟨any___,(Subscript[ψ, μ1_])[z_],any2___,Derivative[n_][(Subscript[X, μ2_])][z_],any3___⟩g[μ1_,μ2_]:>⟨any,(Subscript[ψ, μ])[z],any2,Derivative[n][(Subscript[X, ν])][z],any3⟩g[μ,ν],
⟨any___,(Subscript[ψ, μ1_])[z_],any2___,Derivative[n_][(Subscript[X, μ2_])][z_],any3___⟩g[μ2_,μ1_]:>⟨any,(Subscript[ψ, μ])[z],any2,Derivative[n][(Subscript[X, ν])][z],any3⟩g[μ,ν],
⟨any___,Derivative[n1_][(Subscript[X, μ1_])][z_],any2___,Derivative[n2_][(Subscript[ψ, μ2_])][z_],any3___⟩g[μ1_,μ2_]:>⟨any,Derivative[n1][(Subscript[X, μ])][z],any2,Derivative[n2][(Subscript[ψ, ν])][z],any3⟩g[μ,ν],
⟨any___,Derivative[n1_][(Subscript[X, μ1_])][z_],any2___,Derivative[n2_][(Subscript[ψ, μ2_])][z_],any3___⟩g[μ2_,μ1_]:>⟨any,Derivative[n1][(Subscript[X, μ])][z],any2,Derivative[n2][(Subscript[ψ, ν])][z],any3⟩g[μ,ν],
⟨any___,Derivative[n1_][(Subscript[ψ, μ1_])][z_],any2___,Derivative[n2_][(Subscript[X, μ2_])][z_],any3___⟩g[μ1_,μ2_]:>⟨any,Derivative[n1][(Subscript[ψ, μ])][z],any2,Derivative[n2][(Subscript[X, ν])][z],any3⟩g[μ,ν],
⟨any___,Derivative[n1_][(Subscript[ψ, μ1_])][z_],any2___,Derivative[n2_][(Subscript[X, μ2_])][z_],any3___⟩g[μ2_,μ1_]:>⟨any,Derivative[n1][(Subscript[ψ, μ])][z],any2,Derivative[n2][(Subscript[X, ν])][z],any3⟩g[μ,ν],
⟨any___,(Subscript[ψ, μ1_])[z_],any2___,(Subscript[ψ, μ2_])[z_],any3___⟩g[μ1_,μ2_]:>⟨any,(Subscript[ψ, μ])[z],any2,(Subscript[ψ, ν])[z],any3⟩g[μ,ν],
⟨any___,(Subscript[ψ, μ1_])[z_],any2___,Derivative[n_][(Subscript[ψ, μ2_])][z_],any3___⟩g[μ1_,μ2_]:>⟨any,(Subscript[ψ, μ])[z],any2,Derivative[n][(Subscript[ψ, ν])][z],any3⟩g[μ,ν],
⟨any___,(Subscript[ψ, μ1_])[z_],any2___,Derivative[n_][(Subscript[ψ, μ2_])][z_],any3___⟩g[μ2_,μ1_]:>⟨any,(Subscript[ψ, μ])[z],any2,Derivative[n][(Subscript[ψ, ν])][z],any3⟩g[μ,ν],⟨any___,Derivative[n_][(Subscript[ψ, μ1_])][z_],any2___,(Subscript[ψ, μ2_])[z_],any3___⟩g[μ1_,μ2_]:>⟨any,((Subscript[ψ, μ])^((n)))[z],any2,(Subscript[ψ, ν])[z],any3⟩g[μ,ν],
⟨any___,Derivative[n_][(Subscript[ψ, μ1_])][z_],any2___,(Subscript[ψ, μ2_])[z_],any3___⟩g[μ2_,μ1_]:>⟨any,((Subscript[ψ, μ])^((n)))[z],any2,(Subscript[ψ, ν])[z],any3⟩g[μ,ν],
⟨any___,Derivative[n1_][(Subscript[ψ, μ1_])][z_],any2___,Derivative[n2_][(Subscript[ψ, μ2_])][z_],any3___⟩g[μ1_,μ2_]:>⟨any,Derivative[n1][(Subscript[ψ, μ])][z],any2,Derivative[n2][(Subscript[ψ, ν])][z],any3⟩g[μ,ν],
⟨any___,Derivative[n1_][(Subscript[ψ, μ1_])][z_],any2___,Derivative[n2_][(Subscript[ψ, μ2_])][z_],any3___⟩g[μ2_,μ1_]:>⟨any,Derivative[n1][(Subscript[ψ, μ])][z],any2,Derivative[n2][(Subscript[ψ, ν])][z],any3⟩g[μ,ν]};

to simplify AngleBrackets

Be careful about the statistics of the exponentials, as :(e^(ϕ(z))): inside :(e^(ϕ(z)-ϕ(w))):  is bosonic
  :(e^(ϕ(z))): :(e^(-ϕ(w))): =-:(e^(-ϕ(w))): :(e^(ϕ(z))):= (z-w):(e^(ϕ(z)-ϕ(w))): =  -(w-z):(e^(-ϕ(w)+ϕ(z))):  
Also, we should not unify exponentials before taking derivatives
  (∂_z)(e^(2ϕ(z)-ϕ(0)))≠(∂_z)(e^(ϕ(z)))

ruleAB1=Join[ruleABfermion,ruleABexp1];
ruleAB=Join[ruleABfermion,ruleABexp1,ruleABexp2];

ruleABfermion={WickX[0]:>0,
⟨⟩->1,
⟨any___,Derivative[n_][κ][z_],any2___⟩:>0,
⟨any___,num_?NumericQ,any2___⟩:>num AB[any,any2],
⟨any___,b[z_],any2___,b[z_],any3___⟩:>0,
⟨any___,c[z_],any2___,c[z_],any3___⟩:>0,
⟨any___,Derivative[n_][c][z_],any2___,Derivative[n_][c][z_],any3___⟩:>0,
⟨any___,ξ[z_],any2___,ξ[z_],any3___⟩:>0,
⟨any___,Derivative[n_][ξ][z_],any2___,Derivative[n_][ξ][z_],any3___⟩:>0,
⟨any___,η[z_],any2___,η[z_],any3___⟩->0,
⟨any___,Derivative[n_][η][z_],any2___,Derivative[n_][η][z_],any3___⟩:>0};

(* How to unify exp(±ϕ) exp(±ϕ) into exp(±ϕ±ϕ) *)
ruleABexp1={⟨any___,((ϕ'[z_])^2),any2___⟩:>AB[any,ϕ'[z],ϕ'[z],any2],
⟨any___,num_?NumericQ ((ϕ'[z_])^2),any2___⟩:>num AB[any,ϕ'[z],ϕ'[z],any2],
⟨any___,num_?NumericQ Derivative[n_][ϕ][z_],any2___⟩:>num AB[any,Derivative[n][ϕ][z],any2],⟨any___,Φm[z],ϕ'[z_],any2___⟩:>⟨any,ϕ'[z],Φm[z],any2⟩,
⟨any___,Φp[z],ϕ'[z_],any2___⟩:>⟨any,ϕ'[z],Φp[z],any2⟩,
⟨any___,(Φm)'[z_],any2___⟩:>-⟨any,ϕ'[z],Φm[z],any2⟩,
⟨any___,(Φp)'[z_],any2___⟩:>⟨any,ϕ'[z],Φp[z],any2⟩,
⟨any___,(Φm)''[z_],any2___⟩:>⟨any,ϕ'[z],ϕ'[z],Φm[z],any2⟩-⟨any,ϕ''[z],Φm[z],any2⟩,
⟨any___,(Φp)''[z_],any2___⟩:>⟨any,ϕ'[z],ϕ'[z],Φp[z],any2⟩+⟨any,ϕ''[z],Φp[z],any2⟩
};
ruleABexp2={⟨any___,Φm[z_],Φp[z_],any2___⟩:>AB[any,any2],
⟨any___,Φp[z_],Φm[z_],any2___⟩:>AB[any,any2],
⟨any___,Φp[z_],Φp[z_],any2___⟩:>⟨any,Φ2p[z],any2⟩,
⟨any___,Φm[z_],Φm[z_],any2___⟩:>⟨any,Φ2m[z],any2⟩,
⟨any___,Φp[z_],Derivative[n_][Φm][z_],any2___⟩:>Distribute@AB[any,(D[Exp[ϕ[zz]-ϕ[ww]],{ww,n}]/.{zz->z,ww->z}),any2],
⟨any___,Derivative[m_][Φp][z_],Φm[z_],any2___⟩:>Distribute@AB[any,(D[Exp[ϕ[zz]-ϕ[ww]],{zz,m}]/.{zz->z,ww->z}),any2],
⟨any___,Derivative[m_][Φp][z_],Derivative[n_][Φm][z_],any2___⟩:>Distribute@AB[any,(D[D[Exp[ϕ[zz]-ϕ[ww]],{zz,m}],{ww,n}]/.{zz->z,ww->z}),any2],
⟨any___,Φm[z_],Derivative[n_][Φp][z_],any2___⟩:>Distribute@AB[any,(D[Exp[-ϕ[zz]+ϕ[ww]],{ww,n}]/.{zz->z,ww->z}),any2],
⟨any___,Derivative[m_][Φm][z_],Φp[z_],any2___⟩:>Distribute@AB[any,(D[Exp[-ϕ[zz]+ϕ[ww]],{zz,m}]/.{zz->z,ww->z}),any2],
⟨any___,Derivative[m_][Φm][z_],Derivative[n_][Φp][z_],any2___⟩:>Distribute@AB[any,(D[D[Exp[-ϕ[zz]+ϕ[ww]],{zz,m}],{ww,n}]/.{zz->z,ww->z}),any2],
⟨any___,Derivative[n_][Φp][z_],Φp[z_],any2___⟩:>⟨any,Φp[z],Derivative[n][Φp][z],any2⟩,⟨any___,Φp[z_],Derivative[n_][Φp][z_],any2___⟩:>Distribute@AB[any,Expand[(D[Exp[ϕ[zz]],{zz,n}]Exp[-ϕ[z]])/.{zz->z}],Φ2p[z],any2],
⟨any___,Derivative[n1_][Φp][z_],Derivative[n2_][Φp][z_],any2___⟩:>Distribute@AB[any,Expand[(D[Exp[ϕ[z]],{z,n1}]D[Exp[ϕ[zz]],{zz,n2}]Exp[-2ϕ[z]])/.{zz->z}],Φ2p[z],any2],⟨any___,Derivative[n_][Φm][z_],Φm[z_],any2___⟩:>⟨any,Φm[z],Derivative[n][Φm][z],any2⟩,⟨any___,Φm[z_],Derivative[n_][Φm][z_],any2___⟩:>Distribute@AB[any,Expand[(D[Exp[-ϕ[z]],{zz,n}]Exp[ϕ[z]])/.{zz->z}],Φ2m[z],any2],
⟨any___,Derivative[n1_][Φm][z_],Derivative[n2_][Φm][z_],any2___⟩:>Distribute@AB[any,Expand[(D[Exp[-ϕ[zz]],{zz,n1}]D[Exp[-ϕ[zz]],{zz,n2}]Exp[2ϕ[z]])/.{zz->z}],Φ2m[z],any2],
⟨any___,Φ2p[z_],Φm[z_],any2___⟩:>Distribute@AB[any,Φp[z],any2],⟨any___,Derivative[m_][Φ2p][z_],Φm[z_],any2___⟩:>Distribute@AB[any,Expand[(D[Exp[2ϕ[zz]-ϕ[ww]],{zz,m}]Exp[-ϕ[z]]/.{zz->z,ww->z})],Φp[z],any2]};

(* Expand derivative of exp(±ϕ) *)
expandDΦ={⟨any___,Derivative[n_][Φp][z_],any2___⟩:>Distribute@AB[any,Expand[(D[Exp[ϕ[z]],{z,n}]Exp[-ϕ[z]])],Φp[z],any2],⟨any___,Derivative[n_][Φm][z_],any2___⟩:>Distribute@AB[any,Expand[(D[Exp[-ϕ[z]],{z,n}]Exp[ϕ[z]])],Φm[z],any2],
⟨any___,Derivative[n_][Φ2p][z_],any2___⟩:>Distribute@AB[any,Expand[(D[Exp[2ϕ[z]],{z,n}]Exp[-2ϕ[z]])],Φ2p[z],any2],
⟨any___,Derivative[n_][Φ2m][z_],any2___⟩:>Distribute@AB[any,Expand[(D[Exp[-2ϕ[z]],{z,n}]Exp[2ϕ[z]])],Φ2m[z],any2]};

ruleDAB={AngleBracket'[f_[z_]]:>AB[f'[z]]/f'[z],
Derivative[1,0][AngleBracket][f_[z_],any_]:>AB[f'[z],any]/f'[z],
Derivative[0,1][AngleBracket][any_,f_[z_]]:>AB[any,f'[z]]/f'[z],
Derivative[1,0,0][AngleBracket][f_[z_],any_,any2_]:>AB[D[f[z],z],any,any2]/D[f[z],z],
Derivative[0,1,0][AngleBracket][any_,f_[z_],any2_]:>AB[any,f'[z],any2]/f'[z],
Derivative[0,0,1][AngleBracket][any_,any2_,f_[z_]]:>AB[any,any2,f'[z]]/f'[z],
Derivative[1,0,0][AngleBracket][f_[z_,m_],any_,any2_]:>AB[D[f[z,m],z],any,any2]/D[f[z,m],z],
Derivative[0,1,0][AngleBracket][any_,f_[z_,m_],any2_]:>AB[any,D[f[z,m],z],any2]/D[f[z,m],z],
Derivative[0,0,1][AngleBracket][any_,any2_,f_[z_,m_]]:>AB[any,any2,D[f[z,m],z]]/D[f[z,m],z],
Derivative[1,0,0,0][AngleBracket][f_[z_,m_],any_,any2_,any3_]:>AB[D[f[z,m],z],any,any2,any3]/D[f[z,m],z],
Derivative[0,1,0,0][AngleBracket][any_,f_[z_,m_],any2_,any3_]:>AB[any,D[f[z,m],z],any2,any3]/D[f[z,m],z],
Derivative[0,0,1,0][AngleBracket][any_,any2_,f_[z_,m_],any3_]:>AB[any,any2,D[f[z,m],z],any3]/D[f[z,m],z],
Derivative[0,0,0,1][AngleBracket][any_,any2_,any3_,f_[z_,m_]]:>AB[any,any2,any3,D[f[z,m],z]]/D[f[z,m],z],
Derivative[1,0,0,0][AngleBracket][f_[z_],any_,any2_,any3_]:>AB[D[f[z],z],any,any2,any3]/D[f[z],z],
Derivative[0,1,0,0][AngleBracket][any_,f_[z_],any2_,any3_]:>AB[any,D[f[z],z],any2,any3]/D[f[z],z],
Derivative[0,0,1,0][AngleBracket][any_,any2_,f_[z_],any3_]:>AB[any,any2,D[f[z],z],any3]/D[f[z],z],
Derivative[0,0,0,1][AngleBracket][any_,any2_,any3_,f_[z_]]:>AB[any,any2,any3,D[f[z],z]]/D[f[z],z]};

(* Replace ⟨Φp ... Φp⟩ by ⟨... Φ2p⟩ *)
unifyΦp[bracket_]:=Module[{posFp=First/@Position[bracket,Φp],fnum},
Which[Length@posFp≤1,bracket,
Length@posFp==2,
(-1)^countFermions[bracket[[posFp[[1]]+1;;posFp[[2]]-1]]]Join[bracket[[;;posFp[[1]]-1]],bracket[[posFp[[1]]+1;;posFp[[2]]-1]],⟨bracket[[posFp[[1]]]],bracket[[posFp[[2]]]]⟩,bracket[[posFp[[2]]+1;;]]]//.ruleAB,
Length@posFp>2,Error[]
]
];

(* Replace ⟨Φm ... Φp⟩ by ⟨...⟩ *)
unifyΦmp[bracket_]:=Module[{posFm=First/@Position[bracket,Φm],posFp=First/@Position[bracket,Φp],posFmp,fnum},
posFmp=Sort@Join[posFm,posFp];
Which[Length@posFmp≤1,bracket,
Length@posFmp==2,
(-1)^countFermions[bracket[[posFmp[[1]]+1;;posFmp[[2]]-1]]]Join[bracket[[;;posFmp[[1]]-1]],bracket[[posFmp[[1]]+1;;posFmp[[2]]-1]],⟨bracket[[posFmp[[1]]]],bracket[[posFmp[[2]]]]⟩,bracket[[posFmp[[2]]+1;;]]]//.ruleAB,
Length@posFmp>2,Error[]
]
];

for (Subscript[Q, BRST])

𝕋gh[z_]=Expand[(1/2) (-2 ⟨c[z],β'[z]⟩+⟨γ[z],b[z]⟩-3 ⟨c'[z],β[z]⟩)+ (⟨κ[z],c[z],b'[z]⟩-(1/2) ⟨κ[z],γ[z],β'[z]⟩+2 ⟨κ[z],c'[z],b[z]⟩-(3/2) ⟨κ[z],γ'[z],β[z]⟩)];

𝕋ghbos[z_]=Expand[(1/2) (-2 ⟨c[z],Φm[z],ξ''[z]⟩-2 ⟨c[z],(Φm)'[z],ξ'[z]⟩-⟨Φp[z],η[z],b[z]⟩-3 ⟨c'[z],Φm[z],ξ'[z]⟩)+(-⟨κ[z],ϕ''[z]⟩+⟨κ[z],c[z],b'[z]⟩-⟨κ[z],η[z],ξ'[z]⟩+2 ⟨κ[z],c'[z],b[z]⟩-(1/2) ⟨κ[z],ϕ'[z],ϕ'[z]⟩)];

Qbrst0[z_,μ_,ν_]:=-(1/4) ⟨γ[z],γ[z],b[z]⟩+(1/2) ⟨γ[z],(Subscript[ψ, μ])[z],Derivative[1][(Subscript[X, ν])][z]⟩ (Subscript[g, μ,ν])+cT0[z,μ,ν];
cT0[z_,μ_,ν_]:=⟨b[z],c[z],c'[z]⟩-(3/2) ⟨β[z],γ'[z],c[z]⟩-(1/2) ⟨γ[z],β'[z],c[z]⟩+(1/2) ⟨c[z],(Subscript[ψ, μ])[z],Derivative[1][(Subscript[ψ, ν])][z]⟩ (Subscript[g, μ,ν])-(1/2) ⟨c[z],Derivative[1][(Subscript[X, μ])][z],Derivative[1][(Subscript[X, ν])][z]⟩ (Subscript[g, μ,ν]);

(* Originally λ3 = 1/2, but Qbrst should be nilpotent for any λ3 *)
Qbrst[z_,μ_,ν_]:=-((λ3)^2) ⟨Φ2p[z],b[z],η[z],η'[z]⟩+g[μ,ν]λ3⟨η[z],Φp[z],(∂_z)X[z,μ],ψ[z,ν]⟩+cT[z,μ,ν];
cT[z_,μ_,ν_]:=-((g[μ,ν])/2)⟨c[z],(∂_z)X[z,μ],(∂_z)X[z,ν]⟩+((g[μ,ν])/2)⟨c[z],ψ[z,μ],(∂_z)ψ[z,ν]⟩+⟨b[z],c[z],c'[z]⟩-⟨ϕ''[z],c[z]⟩-⟨c[z],η[z],ξ'[z]⟩-(1/2) ⟨ϕ'[z],ϕ'[z],c[z]⟩+(3/2)⟨c''[z]⟩;

Superconformal OPE’s

TT OPE’s

Matter

Check ∂T

g[μ,ν]{TX[z,μ,ν],Tψ[z,μ,ν],delAB[TX[z,μ,ν]],delAB[Tψ[z,μ,ν]]}//.ruleTT[1]//FS

Free bosons

TXTX=g[μ1,ν1]g[μ2,ν2]contractionN[TX[w,μ1,ν1],TX[z,μ2,ν2]]//expansion;
Expand[Normal[TXTX]]//.ruleTT[1]//Series[#,{w,z,-1}]&//.ruleTT[1]//Normal//Expand;
%//.ruleMetric//.ruleMetric2//Expand

Free fermions

TψTψ=g[μ1,ν1]g[μ2,ν2]contractionN[Tψ[w,μ1,ν1],Tψ[z,μ2,ν2]]//expansion;
Expand[Normal[TψTψ]]//.ruleTT[1]//Series[#,{w,z,-1}]&//Normal//Expand;
%//.ruleMetric//.ruleTT[1]//.ruleMetric2

Ghost

Check ∂T

{delAB[Tβ[z]],delAB[Tb[z]],delAB[Tϕ[z]]}//.ruleT//FS

βγ CFT

TβTβ=contractionN[Tβ[w],Tβ[z]]//expansion;
Expand[Normal[TβTβ]]//.ruleT//Series[#,{w,z,-1}]&//FS
%/.λ->2

bc CFT

TbTb=contractionN[Tb[w],Tb[z]]//expansion;
Expand[Normal[TbTb]]//.ruleT//Series[#,{w,z,-1}]&//FS
%/.λ->2

Chiral boson CFT

TϕTϕ=contractionN[Tϕ[w],Tϕ[z]]//expansion;
Expand[Normal[TϕTϕ]]//.ruleT//Series[#,{w,z,-1}]&//FullSimplify
%/.λ1->1

BRST charge of bosonic string

Check ((Subscript[Q, BRST])^2)=0

Qbos[z_,μ_,ν_]:=-((g[μ,ν])/2)⟨c[z],(∂_z)X[z,μ],(∂_z)X[z,ν]⟩+⟨b[z],c[z],c'[z]⟩+(3/2)⟨(∂_z)(∂_z)c[z]⟩;

contractionN[Qbos[w,μ1,ν1],Qbos[z,μ2,ν2]]//expansion//Normal//Expand;
%//.ruleMetric//.ruleT//statistics;
%//.ruleMetric2;
%//Series[#,{w,z,-1}]&//Simplify

TT-TG-GG OPE’s, (matter)

Check ∂G

g[μ,ν]delAB[Gmat[z,μ,ν]]//Expand;
%//.ruleGmat//FS

TT OPE

TmatTmat=g[μ1,ν1]g[μ2,ν2]contractionN[Tmat[w,μ1,ν1],Tmat[z,μ2,ν2]]//expansion;
Expand[Normal[TmatTmat]]//.ruleT/.λ->2//Series[#,{w,z,-1}]&//.ruleT//Normal//Expand;
%//.ruleMetric//.ruleMetric2//Expand//Series[#,{w,z,-1}]& //Simplify

TG OPE

TmatGmat=g[μ1,ν1]g[μ2,ν2]contractionN[Tmat[w,μ1,ν1],Gmat[z,μ2,ν2]]//expansion;
Expand[Normal[TmatGmat]]//.ruleMetric//.ruleMetric2;
%//.ruleGmat//Expand

1/4 of GG OPE

GmatGmat=g[μ1,ν1]g[μ2,ν2]contractionN[Gmat[w,μ1,ν1],Gmat[z,μ2,ν2]]//expansion;
Expand[Normal[GmatGmat]]//.ruleMetric//.ruleMetric2;
%//.ruleT/.λ->2//Expand;
%/.AB[Subscript[ψ,μ][z],ψ[z,ν]]g[μ,ν]->0

Mathematica is confused between two notations of ψ

TT-TG-GG OPE’s, (ghost)

Check ∂G

delAB[Ggh[z]]//.ruleGh//FS

TT OPE

TghTgh=contractionN[Tgh[w],Tgh[z]]//expansion;
Expand[Normal[TghTgh]]//.ruleT/.λ->2//Series[#,{w,z,-1}]&//FullSimplify

TG OPE

TghGgh=contractionN[Tgh[w],Ggh[z]]//expansion;
Expand[Normal[TghGgh]]//.ruleGh//Series[#,{w,z,-1}]&//FullSimplify

GG OPE

GghGgh=contractionN[Ggh[w],Ggh[z]]//expansion;
Expand[Normal[GghGgh]]//.ruleT/.λ->2//.ruleGh//Series[#,{w,z,-1}]&//FS

1/4 of GG OPE

(1/4)contractionN[Ggh[w],Ggh[z]]//expansion;
Expand[Normal[%]]//.ruleT/.λ->2//.ruleGh//Series[#,{w,z,-1}]&//FS

Conformal weights (ghost)

{contractionN[Tb[w],⟨b[z]⟩],contractionN[Tb[w],⟨c[z]⟩]}//expansion

{contractionN[Tβ[w],⟨β[z]⟩],contractionN[Tβ[w],⟨γ[z]⟩]}//expansion

Bosonization of βγ

Use  β=(e^(-ϕ))∂ξ  and  γ=η (e^ϕ).
If we use γ= (e^ϕ)η=-η (e^ϕ), we get a wrong sign in the GG OPE

Check ∂T and ∂G

delAB[Tϕ[z]]/.λ1->1//statistics;
%//.ruleBh//statistics//FS

delAB[Gbh[z]]//statistics;
%//.ruleBh//statistics//FS

Compare weights before/after bosonization

{contractionX[Tβ2[w],⟨β[z]⟩],contractionX[Tβ2[w],⟨γ[z]⟩]}//expansion

{contractionX[Tη2[w],⟨(∂_z)ξ[z]⟩],contractionX[Tη2[w],⟨η[z]⟩]}//expansion

Recall ∂(Φm)=-ϕ' Φm

ruleDel={⟨Φm[z_],ξ''[z_]⟩:>-Del[⟨(∂_z)ξ[z],Φm[z]⟩]-⟨ξ'[z],ϕ'[z],Φm[z]⟩,
⟨Φp[z_],η'[z_]⟩:>-Del[⟨η[z],Φp[z]⟩]+⟨η[z],ϕ'[z],Φp[z]⟩};

{contractionX[Tη2[w],⟨Φm[z]⟩],contractionX[Tη2[w],⟨Φp[z]⟩]}/.expandDΦ//statistics//expansion

{contractionX[Tη2[w],⟨Φm[z],(∂_z)ξ[z]⟩],contractionX[Tη2[w],⟨η[z],Φp[z]⟩]}//expansion//statistics//Simplify;
%/.expandDΦ/.ruleDel//statistics//FS

TT-TG-GG OPE’s, bosonized

TT OPE

TbhTbh=contractionX[Tbh[w],Tbh[z]]//expansion;
Expand[Normal[TbhTbh]]//.ruleBh//Series[#,{w,z,-1}]&//FullSimplify

TG OPE

TbhGbh=contractionX[Tbh[w],Gbh[z]]//expansion;
Expand[Normal[TbhGbh]]//.ruleBh//Series[#,{w,z,-1}]&//statistics//Simplify;
%//.ruleBh//.expandDΦ//.ruleAB//statistics//Simplify

GG OPE

GbhGbh=contractionX[Gbh[w],Gbh[z]]//expansion;
Expand[Normal[GbhGbh]]//.ruleBh//.expandDΦ//Series[#,{w,z,-1}]&//Simplify//Normal//Expand;
%//.ruleAB//statistics//Series[#,{w,z,-1}]&//Simplify;
%//.ruleBh//Simplify

BRST charge of superstring, before bosonization

Construct (Subscript[𝕋, gh])

contractionX[ℂ0[w],d𝔹0[z]]/.any_AB:>takeK[any]//expansion0;
Tbos0[1]=Coefficient[%,w-z,0]

contractionX[Dℂ0[w],D𝔹0[z]]/.any_AB:>takeK[any]//expansion0;
Tbos0[2]=Coefficient[%,w-z,0]

contractionX[dℂ0[w],𝔹0[z]]/.any_AB:>takeK[any]//expansion0;
Tbos0[3]=Coefficient[%,w-z,0]

-Tbos0[1]+(1/2)Tbos0[2]-(3/2)Tbos0[3]//.ruleAB;
%/.AB[κ[z],any___]:>λ AB[κ[z],any]//Collect[#,λ,Simplify]&

𝕋gh[z]-%/.λ->1//FS

Construct (Subscript[Q, BRST])

Matter part

Constrct 𝕋

-(1/2)g[μ,ν]contractionX[D𝕏[w,μ],d𝕏[z,ν]]//expansion0;
Normal[%]//Expand//.ruleMetric;
%//.ruleAB/.any_AB:>takeK[any]

-contractionX[ℂ0[w],%]//expansion0;
Coefficient[%,w-z,0]/.any_AB:>takeK[any];
qtot[1]=%/.AB[κ[z],any___]:>λ AB[any]//Coefficient[#,λ]&//Simplify//Expand

Ghost part

-(1/2)contractionX[ℂ0[w],𝕋gh[z]]//expansion0;
%/.any_AB:>takeK[any]//.ruleAB;
Coefficient[%,w-z,0]//statistics//Simplify;
%/.any_AB:>takeK[any]/.AB[κ[z],any___]:>λ AB[any]//Coefficient[#,λ]&;
qtot[2]=%-(3/4)delAB[⟨β[z],γ[z],c[z]⟩,z]//statistics//Simplify

qtot[1]+qtot[2]//Expand

Check

qtot[1]+qtot[2]-Qbrst0[z,μ,ν]//.ruleAB//statistics//Expand;
%//.ruleMetric2//FS

Check ((Subscript[Q, BRST])^2)=0

QBQB0=contractionX[Qbrst0[w,μ1,ν1],Qbrst0[z,μ2,ν2]]//expansion;

Series[Normal@QBQB0,{w,z,-2}]//.ruleMetric//.ruleAB//statistics//FS;
Normal[%]//Expand;
%//.ruleMetric2//Series[#,{w,z,-2}]&//FS

coeffQBQB0=Coefficient[QBQB0,w-z,-1];
%//.ruleMetric//.ruleAB//statistics//FS;
Normal[%]//Expand;
poleQBQB0=%//.ruleMetric2//statistics//FS

delQBQB0=-(3/4) delAB[AB[c[z],c''[z]],z]+(3/8) delAB[AB[γ[z],γ'[z]],z]+(1/8) delAB[⟨γ[z],γ[z],b[z],c[z]⟩,z]+(1/16) delAB[⟨β[z],γ[z],γ[z],γ[z]⟩,z]+(1/8)delAB[⟨γ[z],Derivative[1][(Subscript[X, μ])][z],c[z],(Subscript[ψ, ν])[z]⟩,z]g[μ,ν]//statistics//FS

poleQBQB0-delQBQB0/.{AB[any___,(Subscript[ψ, μ])[z],(Subscript[ψ, ν])[z],any2___]:>0}//statistics//FS
%/.dim->10

Check ((Subscript[Q, BRST])^2)=0 with generalization

QbrstGen0[z_,μ_,ν_]:=-((λ3)^2) ⟨γ[z],γ[z],b[z]⟩+λ3 ⟨γ[z],(Subscript[ψ, μ])[z],Derivative[1][(Subscript[X, ν])][z]⟩ (Subscript[g, μ,ν])+cT0[z,μ,ν];

QBQBGen0=contractionX[QbrstGen0[w,μ1,ν1],QbrstGen0[z,μ2,ν2]]//expansion;

Series[Normal@QBQBGen0,{w,z,-2}]//.ruleMetric//.ruleAB//statistics//FS;
Normal[%]//Expand;
%//.ruleMetric2//Series[#,{w,z,-2}]&//FS

coeffQBQBGen0=Coefficient[QBQBGen0,w-z,-1];
%//.ruleMetric//.ruleAB//statistics//FS;
Normal[%]//Expand;
poleQBQBGen0=%//.ruleMetric2//statistics//FS

delQBQBGen0=-(3/4) delAB[AB[c[z],c''[z]],z]+(3/2) ((λ3)^2)delAB[AB[γ[z],γ'[z]],z]+(((λ3)^2)/2) delAB[⟨γ[z],γ[z],b[z],c[z]⟩,z]+(((λ3)^2)/4) delAB[⟨β[z],γ[z],γ[z],γ[z]⟩,z]+((λ3)/4)delAB[⟨γ[z],Derivative[1][(Subscript[X, μ])][z],c[z],(Subscript[ψ, ν])[z]⟩,z]g[μ,ν]//statistics//FS

poleQBQBGen0-delQBQBGen0/.{AB[any___,(Subscript[ψ, μ])[z],(Subscript[ψ, ν])[z],any2___]:>0}//statistics//FS
%/.dim->10

BRST charge of superstring, after bosonization

Remarks on the OPE associativity

In general, the double expansions depend on the expansion order, which apparently violates the OPE associativity

Order-of-limits problem

Table[Normal@Series[Normal@Series[(1/((z1-z2)(z1-z3))),{z1,z2,n}],{z2,z3,n}],{n,0,3}]/.z1->z2//Simplify
Table[Normal@Series[Normal@Series[(1/((z1-z2)(z1-z3))),{z2,z3,n}],{z3,z1,n}],{n,0,3}]/.z1->z2//Simplify
Table[Normal@Series[Normal@Series[(1/((z1-z2)(z1-z3))),{z2,z1,n}],{z1,z3,n}],{n,0,3}]/.z1->z2//Simplify

The results are correct if series expansion does nothing

Table[Normal@Series[Normal@Series[(1/((z1-z2)(z1-z3))),{z3,z1,n}],{z2,z1,n}],{n,0,3}]//Simplify

γ((Subscript[z, 1]))γ((Subscript[z, 2]))β((Subscript[z, 3])) after bosonization

Analytic answer

answerGGB={(((z1-z3))/((z1-z2)(z2-z3)))⟨η[z1],exps⟩,-(((z2-z3))/((z1-z2)(z1-z3)))⟨η[z2],exps⟩,+(((z2-z3)(z1-z3))/((z1-z2)))⟨η[z1],η[z2],ξ'[z3],exps⟩}//Total;
(*
/. exps -> Exp[ϕ[z1]+ϕ[z2]-ϕ[z3]]
*)

Expand ((1-2)-3) except for exponentials

Series[answerGGB,{z1,z2,0}]//.ruleDAB//Normal//.ruleAB//Simplify;
Series[%,{z2,z3,0}]//.ruleDAB//Normal//.ruleAB//Simplify

Expand (1-(2-3)) except for exponentials

Series[answerGGB,{z2,z3,0}]//.ruleDAB//Normal//.ruleAB//Simplify;
Series[%,{z1,z3,0}]//.ruleDAB//Normal//.ruleAB//Simplify

Expand ((2-3)-1) except for exponentials

Series[answerGGB,{z2,z3,0}]//.ruleDAB//Normal//.ruleAB//Simplify;
Series[%,{z3,z1,0}]//.ruleDAB//Normal//.ruleAB//Simplify

Ghost BRST charge

Compute 1-(2-3)  --  obtain cT

contractionX[dℂ[z2],𝔹[z3]]/.any_AB:>takeK[any]//expansion[z2,z3,#,0]&;
%//.ruleAB//Normal//Expand;
contractionX[ℂ[z1],%]/.any_AB:>takeK[any]//expansion[z1,z3,#,0]&;
%//.ruleAB//Coefficient[#,z1-z3,0]&;
CCB1[1]=%/.z3->z//Simplify

contractionX[Dℂ[z2],D𝔹[z3]]/.any_AB:>takeK[any]//expansion[z2,z3,#,0]&;
%//.ruleAB//Normal//Expand;
%/.any_AB:>unifyΦmp[any];
contractionX[ℂ[z1],%]/.any_AB:>takeK[any]//expansion[z1,z3,#,0]&;
%//.ruleAB//Coefficient[#,z1-z3,0]&;
CCB1[2]=%/.z3->z//Simplify

contractionX[ℂ[z2],d𝔹[z3]]/.any_AB:>takeK[any]//expansion[z2,z3,#,0]&;
%//.ruleAB//Normal//Expand;
%/.any_AB:>unifyΦmp[any];
contractionX[ℂ[z1],%]/.any_AB:>takeK[any]//expansion[z1,z3,#,0]&;
%//.ruleAB//Coefficient[#,z1-z3,0]&;
CCB1[3]=%/.z3->z//Simplify

Table[CCB1[ii],{ii,3}].{-1,(1/2),((-3)/2)}//statistics;
%/.any_AB:>takeK[any]/.AB[κ[z],any___]:>λ AB[any]//Coefficient[#,λ]&//Expand

Compute (1-2)-3  --  wrong coefficients

contractionX[ℂ[z1],dℂ[z2]]/.any_AB:>takeK[any]//expansion[z1,z2,#,0]&;
%//.ruleAB//Normal//Expand;
contractionX[%,𝔹[z3]]/.any_AB:>takeK[any]//expansion[z2,z3,#,0]&;
%//.ruleAB//Coefficient[#,z2-z3,0]&;
CCB2[1]=%/.z3->z/.any_AB:>unifyΦmp[any]//Simplify

contractionX[ℂ[z1],Dℂ[z2]]/.any_AB:>takeK[any]//expansion[z1,z2,#,0]&;
%//.ruleAB//Normal//Expand;
contractionX[%,D𝔹[z3]]/.any_AB:>takeK[any]//expansion[z2,z3,#,0]&;
%//.ruleAB//Coefficient[#,z2-z3,0]&;
CCB2[2]=%/.z3->z/.any_AB:>unifyΦmp[any]//Simplify

contractionX[ℂ[z1],ℂ[z2]]/.any_AB:>takeK[any]//expansion[z1,z2,#,0]&;
%//.ruleAB//Normal//Expand;
contractionX[%,d𝔹[z3]]/.any_AB:>takeK[any]//expansion[z2,z3,#,0]&;
%//.ruleAB//Coefficient[#,z2-z3,0]&;
CCB2[3]=%/.z3->z/.any_AB:>unifyΦmp[any]//Simplify

Table[CCB2[ii],{ii,3}].{-1,(1/2),((-3)/2)}//statistics;
%/.any_AB:>takeK[any]/.AB[κ[z],any___]:>λ AB[any]//Coefficient[#,λ]&//Expand

Construct (Subscript[𝕋, gh])

contractionX[ℂ[w],d𝔹[z]]/.any_AB:>takeK[any]//expansion0;
Tbos[1]=Coefficient[%,w-z,0]

contractionX[Dℂ[w],D𝔹[z]]/.any_AB:>takeK[any]//expansion0;
Tbos[2]=Coefficient[%,w-z,0]

contractionX[dℂ[w],𝔹[z]]/.any_AB:>takeK[any]//expansion0;
Tbos[3]=Coefficient[%,w-z,0]

-Tbos[1]+(1/2)Tbos[2]-(3/2)Tbos[3]//.ruleAB;
%/.AB[κ[z],any___]:>λ AB[κ[z],any]//Collect[#,λ,Simplify]&
𝕋ghbos[z]-%/.expandDΦ/.λ->1//.ruleAB//FS

Construct (Subscript[Q, BRST]), after bosonization

Matter part

Constrct 𝕋

-(1/2)g[μ,ν]contractionX[D𝕏[w,μ],d𝕏[z,ν]]//expansion0;
Normal[%]//Expand//.ruleMetric;
%//.ruleAB/.any_AB:>takeK[any]

-contractionX[ℂ[w],%]//expansion0;
Coefficient[%,w-z,0]/.any_AB:>takeK[any];
qtot[3]=%/.AB[κ[z],any___]:>λ AB[any]//Coefficient[#,λ]&//Simplify//Expand

Ghost part

-(1/2)contractionX[ℂ[w],𝕋ghbos[z]]/.any_AB:>takeK[any]//expansion0;
%/.any_AB:>takeK[any]//.ruleAB;
Coefficient[%,w-z,0]//statistics//Simplify;
%/.any_AB:>takeK[any]/.AB[κ[z],any___]:>λ AB[any]//Coefficient[#,λ]&//Simplify

qtot[4]=%-(3/4)delAB[AB[c[z],ϕ'[z]]]//statistics//Simplify

Check

(qtot[3]+qtot[4]+(3/2) ⟨c''[z]⟩)-Qbrst[z,μ,ν]/.λ3->(1/2)//.ruleAB//statistics//Expand;
%//.ruleMetric2//FS

Total TT OPE

Tall[z_,μ_,ν_]:=-((g[μ,ν])/2)⟨(∂_z)X[z,μ],(∂_z)X[z,ν]⟩+((g[μ,ν])/2)⟨ψ[z,μ],(∂_z)ψ[z,ν]⟩+⟨c[z],b'[z]⟩+2 ⟨c'[z],b[z]⟩-⟨η[z],ξ'[z]⟩-(1/2) ⟨ϕ'[z],ϕ'[z]⟩-⟨ϕ''[z]⟩;

TallTall=contractionX[Tall[w,μ1,ν1],Tall[z,μ2,ν2]]//expansion;

Expand[Normal[TallTall]]//.ruleT//.ruleMetric//.ruleMetric2//Series[#,{w,z,-1}]&//Simplify;
%/.{λ->2,λ1->1}//.ruleBh//.ruleMetric2//Simplify

Algebra of BRST current

dQbrst[z_,μ_,ν_]=D[Qbrst[z,μ,ν],z]//.ruleDAB//Expand

(Subscript[j, BRST])(z) c(0)

contractionX[Qbrst[w,μ,ν],AB[c[z]]]//expansion

T(z) :c T(0):  at O((z^(-2)))

contractionX[Tall[w,μ1,ν1],cT[z,μ2,ν2]]//expansion;
coeffTcT2=Coefficient[%,w-z,-2]

coeffTcT2//.ruleMetric//statistics;
%//.ruleMetric2//.ruleMetric2//FS;
%-cT[z,μ,ν]//statistics//FS

T(z) (Subscript[j, BRST])(0)

contractionX[Tall[w,μ1,ν1],Qbrst[z,μ2,ν2]]-((Qbrst[z,μ,ν])/(((w-z))^2))-((dQbrst[z,μ,ν])/((w-z)))//expansion//Normal//Expand;
%//.ruleMetric//statistics;
%//.ruleMetric2//.ruleMetric2;
%//.expandDΦ//.ruleAB//statistics;
%//Series[#,{w,z,-1}]&//FS

The O((z^(-3))) term vanishes by anti-symmetry

Check ((Subscript[Q, BRST])^2)=0

Qbrst[z,μ,ν]-cT[z,μ,ν]
cT[z,μ,ν]

Terms of order (e^(3ϕ)),(e^(4ϕ))

contractionX[ ⟨Φ2p[w],b[w],η[w],η'[w]⟩,⟨Φ2p[z],b[z],η[z],η'[z]⟩]//expansion
contractionX[ ⟨Φ2p[w],b[w],η[w],η'[w]⟩,⟨η[z],Φp[z],Derivative[1][(Subscript[X, μ2])][z],(Subscript[ψ, ν2])[z]⟩ ]//expansion

Terms of order (e^ϕ)

contractionX[λ3 ⟨η[w],Φp[w],Derivative[1][(Subscript[X, μ1])][w],(Subscript[ψ, ν1])[w]⟩ (Subscript[g, μ1,ν1]),cT[z,μ2,ν2]]//expansion;
%//Coefficient[#,w-z,-1]&//Expand;
%//.ruleMetric//statistics//Expand;
GcT[1]=%//.ruleMetric2//.expandDΦ//statistics//FS

contractionX[cT[w,μ1,ν1],λ3 ⟨η[z],Φp[z],Derivative[1][(Subscript[X, μ2])][z],(Subscript[ψ, ν2])[z]⟩ (Subscript[g, μ2,ν2])]//expansion;
%//Coefficient[#,w-z,-1]&//Expand;
%//.ruleMetric//statistics//Expand;
GcT[2]=%//.ruleMetric2//FS

GcT[2]- λ3 g[μ,ν] delAB[⟨c[z],η[z],Φp[z],Derivative[1][(Subscript[X, μ])][z],(Subscript[ψ, ν])[z]⟩,z];
%//.ruleAB//.expandDΦ//statistics//FS

Compute all terms with general λ3

QBQB2=contractionX[Qbrst[w,μ1,ν1],Qbrst[z,μ2,ν2]]//expansion;

Series[Normal@QBQB2,{w,z,-3}]/.sth_AB:>unifyΦp[sth]//.ruleMetric//.ruleAB//statistics//FS;
%//Normal//Expand//.ruleMetric2//Series[#,{w,z,-3}]&//FS

Coefficient[QBQB2,w-z,-2]/.sth_AB:>unifyΦp[sth]//.ruleMetric//.ruleAB//statistics//Expand;
%//.ruleMetric2//FS

coeffQBQB2=Coefficient[QBQB2,w-z,-1];

coeffQBQB2/.sth_AB:>unifyΦp[sth]//.ruleMetric//.ruleAB//statistics;
%//.ruleMetric2//.ruleMetric2//FS;
%//statistics//Expand;
coeffQBQB2b=%//.ruleMetric2//FS

coeffQBQB2b- ((λ3)^2) delAB[⟨Φ2p[z],η[z],η''[z]⟩,z]+ ((λ3)^2)((4-dim)/4) delAB[⟨Φ2p'[z],η[z],η'[z]⟩,z]+2((λ3)^2) delAB[⟨Φ2p[z],b[z],η[z],c[z],η'[z]⟩,z]-λ3 g[μ,ν] delAB[⟨Derivative[1][(Subscript[X, μ])][z],c[z],η[z],Φp[z],(Subscript[ψ, ν])[z]⟩,z];
%//.ruleAB//.expandDΦ//statistics//FS;
%/.⟨any___,(Subscript[ψ, μ])[z],(Subscript[ψ, ν])[z],any2___⟩:>0//.ruleAB//statistics//FS

Collect[%/.dim->10,λ3,FS]

Picture changing

Definition of vertex operators

F(-1)

VO[-1,z_,μ_,ν_]:=AB[c[z],Φm[z],ψ[z,μ],A[z,ν]];

F0

contractionX[ℂ[w],AB[ψ[z,μ]]+ AB[κ[z],(∂_z)X[z,μ]]]//expansion0//Normal;
CDX[w_,μ_]=%/.f_[z]->f[w]

g[μ,ν]contractionX[CDX[w,μ],AB[A[z,ν]]+ AB[κ[z],ψ[z,ν2],dA[z,ν2,ν]]]/.any_AB:>takeK[any]//expansion0//Coefficient[#,w-z,0]&;
%/.AB[κ[z],any___]:>λ AB[any]//Coefficient[#,λ,1]&//Expand

Picture changing operator

Changin the picture of the vertex operator F(-1)

contractionX[Qbrst[w,μ1,ν1],Join[AB[ξ[z]],VO[-1,z,μ2,ν2]]]g[μ2,ν2]//expansion;
%//Coefficient[#,w-z,-1]&//Expand;
%//.ruleMetric//.ruleAB//statistics//Expand;
%//.ruleMetric2/.{⟨A[z,ν2_],c[z],ξ[z],Φm[z],(Subscript[ψ, μ1_])[z],c'[z]⟩ (Subscript[g, μ1_,ν2_]):>⟨A[z,ν],c[z],ξ[z],Φm[z],(Subscript[ψ, μ])[z],c'[z]⟩ (Subscript[g, μ,ν]),
⟨A[z,ν2_],Derivative[1][(Subscript[X, μ1_])][z],c[z]⟩ (Subscript[g, μ1_,ν2_]):>⟨A[z,ν],Derivative[1][(Subscript[X, μ])][z],c[z]⟩ (Subscript[g, μ,ν]),
⟨A[z,ν2_],η[z],Φp[z],(Subscript[ψ, μ2_])[z]⟩ (Subscript[g, μ2_,ν2_]):>⟨A[z,ν],η[z],Φp[z],(Subscript[ψ, μ])[z]⟩ (Subscript[g, μ,ν])}//Simplify

PCO

contractionX[Qbrst[w,μ,ν],AB[ξ[z]]]//expansion;
%//.ruleAB//statistics//Simplify;
%//Coefficient[#,w-z,-1]&//Expand

%-((λ3)^2) delAB[⟨Φ2p[z],b[z],η[z]⟩,z]//.ruleAB//statistics//FS//Expand
%/.λ3->1

The term of order (e^ϕ) disappears if we use PCO as  (Subscript[V', 0]) = :Z (Subscript[V, -1])(0):

contractionX[⟨c[w],ξ'[w]⟩+((λ3)^2) ⟨Φ2p[w],b[w],η'[w]⟩+λ3 ⟨Derivative[1][(Subscript[X, μ1])][w],Φp[w],(Subscript[ψ, ν1])[w]⟩ (Subscript[g, μ1,ν1]),VO[-1,z,μ2,ν2]]g[μ2,ν2]//expansion0;
%//Coefficient[#,w-z,0]&//Expand;
%//.ruleMetric//.ruleAB