Pensieve header: OneCo, the local picture. Continues pensieve://2016-03/SnG.nb.

Print["In the U(T)⊗U(H) conventions. Internal use symbols: ", {rr,pp}]

SetDirectory["C:\\drorbn\\AcademicPensieve\\Projects\\OneCo-1604"]

Generalities

Simp[ε_] := Expand[ε];
CF[ε_]:=ε/.λ_β|λ_a|λ_δβ|λ_δa|λ_δaa:>MapAt[Simp,λ,1];
AutoCollecting[λ_] := (λ /: λ[0,___] = 0;
λ /: λ[f_, r___] + λ[g_, r___] := λ[Simp[f+g], r];
λ /: g_*λ[f_, r___] := λ[Simp[g f], r]);
AutoCollecting /@ {β, a, δβ, δa,δaa};
UU /: UU[x_]+UU[y_] := UU[x+y];
UU /: a_*UU[x_] := UU[Expand[a x]];
UU /: D[u_UU, vs__] := CF[u/.λ_β|λ_a|λ_δβ|λ_δa|λ_δaa :> MapAt[D[#,vs]&, λ, 1]];
UU /: β[f_]**u_UU := CF[u/.λ_β|λ_a|λ_δβ|λ_δa|λ_δaa :> MapAt[f#&, λ, 1]];
(Subscript[b, ç])=1; ca[f_,i_,j_,k_] := δaa[f,ç,i,j,k];
γ[f_, j_,k_] := δa[f,j,k]-δa[(Subscript[b, j])f,ç,k];
γa[f_, j_,k_,l_,m_] := δaa[f,j,k,l,m]-ca[(Subscript[b, j])f,k,l,m];
Kδ /: (Subscript[Kδ, is__]):=KroneckerDelta[1,Length[Union[{is}]]];

δaa relations

i_⪯j_:=OrderedQ[{i,j}]; i_≺j_:=!OrderedQ[{j,i}];
CF[UU[ε_]]:=UU[CF[ε/.δaa[f_,i_,j_,k_,l_]:>Which[
k===ç,δaa[f,ç,l,i,j]+(Subscript[Kδ, j,l])γ[f,i,j],
(i===ç)∨(i⪯k∧j⪯l), δaa[f,i,j,k,l],
k≺i∧j≺l, δaa[f,k,j,i,l]+ca[-f (Subscript[b, i]),l,k,j]+ca[f (Subscript[b, i]) ,j,k,l]+ca[-f (Subscript[b, k]) ,j,i,l]+ca[f (Subscript[b, k]),l,i,j],
k≺i∧j===l, δa[-f (Subscript[b, i]) ,k,j]+δa[f (Subscript[b, k]) ,i,j]+δaa[f,k,j,i,j],
i⪯k∧l≺j, δaa[f,i,l,k,j]+ca[-f (Subscript[b, i]) ,l,k,j]+ca[f (Subscript[b, i]) ,j,k,l]+ca[-f (Subscript[b, k]),j,i,l]+ca[f (Subscript[b, k]) ,l,i,j],
k≺i∧l≺j, δaa[f,k,l,i,j]
]]];

Bases

UUBasis[T_List, H_List, f_] := Module[
{ff,n=0,h,t,h1,h2},
ff:=(Subscript[f, ++n])@@Table[(Subscript[b, t]), {t,T}];
CF /@ UU /@ Flatten@{
β[ff],δβ[ff],
Table[a[ff, t,h], {t,T}, {h,H}],
Table[δa[ff,t,h], {t,T⋃{ç}}, {h,H}],
Table[ca[ff, h1,t,h2], {t,T}, {h1,H},{h2,H}],
Table[δaa[ff, T[[i]],H[[j]],T[[k]],H[[l]]], {k,Length@T},{i,k}, {l,Length@H},{j,l}]
} /. (Subscript[1, _])[___] -> 1
];
UUBasis[S_List,f_] := UUBasis[S,S,f];
UUBasis[n_Integer,m_Integer,f_] := UUBasis[Range@n,Range@m,f];
UUBasis[n_Integer, f_] := UUBasis[Range@n, f];

tm, hm, hts, dm

UU[ε_] // tm[x_,y_,z_] := (rr=Replace[x|y->z];
CF[UU[Expand[ε /. {
a[f_,x,j_] :> a[f,z,j]+γ[(∂_(Subscript[b, y]))f,z,j],
a[f_,y,j_] :> a[f,z,j],
δa[f_,x|y,j_] :> δa[f,z,j],
δaa[f_,i_,j_,k_,l_] :> δaa[f,rr@i, j, rr@k, l]
} /. (Subscript[b, x|y])->(Subscript[b, z])]]]);

UU[ε_] // hm[x_,y_,z_] := (rr=Replace[x|y->z];
CF[UU[Expand[ε /. {
a[f_,i_,x|y] :> a[f,i,z],
δa[f_,i_,x|y] :> δa[f,i,z],
δaa[f_,i_,y,k_,x] :> δaa[f,k,z,i,z],
δaa[f_,i_,j_,k_,l_] :> δaa[f,i,rr@j, k, rr@l]
}]]]);

UU[ε_] // hts[y_,x_] := CF[UU[Expand[ε /. {
a[f_,i_,j_] :> a[f,i,j] - (Subscript[Kδ, j,y])γ[(∂_(Subscript[b, x]))f,i,y] - (Subscript[Kδ, i,x])(Subscript[Kδ, j,y])(β[f (Subscript[b, x])]-δa[f,ç,y]-δβ[(Subscript[b, x])(∂_(Subscript[b, x]))f]),
δa[f_,x,y] :> δa[f,x,y] -δβ[f (Subscript[b, x])],
δaa[f_,i_,j_,k_,l_] :> δaa[f,i,j,k,l]+(Subscript[Kδ, i,x])(Subscript[Kδ, j,y])δa[-(Subscript[b, x])f,k,l] + (Subscript[Kδ, i,x])(Subscript[Kδ, l,y])(δa[(Subscript[b, k])f,x,j]-δa[(Subscript[b, x])f,k,j]) + (Subscript[Kδ, k,x])(Subscript[Kδ, j,y])(δa[(Subscript[b, i])f,x,l]-δa[(Subscript[b, x])f,i,l]) + (Subscript[Kδ, k,x])(Subscript[Kδ, l,y])δa[-(Subscript[b, x])f,i,j]-(Subscript[Kδ, i,x])(Subscript[Kδ, j,l,y])δβ[(Subscript[b, x])(Subscript[b, k])f]+2(Subscript[Kδ, x,i,k])(Subscript[Kδ, y,j,l])δβ[(Subscript[b, x])(Subscript[b, x])f]
}]]];

dm[x_,y_,z_][ε_] := ε // hts[x,y] // tm[x,y,z] // hm[x,y,z]

tσ, hσ, dσ on {β, a, δβ, δa, δaa}

tσ[x_List,y_List][ε_] := (rr=Replace[Thread[x->y]];
CF[ε /. (Subscript[b, i_]):>(Subscript[b, rr@i]) /. {
a[f_,i_,j_] :> a[f,rr@i,j],
δa[f_,i_,j_] :> δa[f,rr@i,j],
δaa[f_,i_,j_,k_,l_]:>δaa[f,rr@i,j,rr@k,l]
}]);
tσ[x_,y_][ε_] := tσ[{x},{y}][ε];
hσ[x_List,y_List][ε_] := (rr=Replace[Thread[x->y]];
CF[ε /. {
a[f_,i_,j_] :> a[f,i,rr@j],
δa[f_,i_,j_] :> δa[f,i,rr@j],
δaa[f_,i_,j_,k_,l_]:>δaa[f,i,rr@j,k,rr@l]
}]);
hσ[x_,y_][ε_] := hσ[{x},{y}][ε];
dσ[x_,y_][ε_] := ε // tσ[x,y] // hσ[x,y];

tb, hb, thb, htb, db, bb on {β, a, δβ, δa, δaa}

tb[x_][UU[L_],UU[R_]] := CF[UU[Expand[Distribute[pp[L,R]] /. {
pp[0,_] -> 0, pp[_,0] -> 0,
pp[_β|_δβ|_δa|_δaa, _β|_δβ|_δa|_δaa] -> 0,
pp[u_β|u_δβ|u_δa|u_δaa, v_a] :> -pp[v,u]
} /. {
pp[a[f_,x,j_], u_] :> (u /. {
β[g_] :> γ[f(∂_(Subscript[b, x]))g,x,j],
a[g_,k_,l_] :> γa[f(∂_(Subscript[b, x]))g,x,j,k,l] +(Subscript[Kδ, x,k])(-γa[g(∂_(Subscript[b, k]))f,k,l,x,j] + ca[f g,l,x,j]-ca[f g,j,k,l]),
_ -> 0
}),
pp[a[f_,j_,k_], a[g_,x,l_]] /; j=!=x :> -γa[g(∂_(Subscript[b, x]))f,x,l,j,k],
pp[_,_] -> 0
}]]];

hb[y_][UU[L_],UU[R_]] := CF[UU[Expand[Distribute[pp[L,R]] /. {
pp[0,_] -> 0, pp[_,0] -> 0,
pp[_β|_δβ,_] -> 0,
pp[_, _β|_δβ] -> 0,
pp[_δa|_δaa, _δa|_δaa] -> 0,
pp[u_δa|u_δaa, v_a] :> -pp[v,u]
} /. {
pp[a[f_,i_,y], u_] :> (u /. {
a[g_,j_,k_] :> (Subscript[Kδ, y,k])(a[(Subscript[b, j])f g,i,y]-a[(Subscript[b, i])f g,j,k]),
δa[g_,j_,k_] :> (Subscript[Kδ, y,k])(δa[(Subscript[b, j])f g,i,y]-δa[(Subscript[b, i])f g,j,k]),
δaa[g_,j_,k_,l_,m_] :> (Subscript[Kδ, y,k])(δaa[(Subscript[b, j])f g,i,y,l,m]-δaa[(Subscript[b, i])f g,j,k,l,m]) + (Subscript[Kδ, y,m])(δaa[(Subscript[b, l])f g,j,k,i,y]-δaa[(Subscript[b, i])f g,j,k,l,m])
}),
_pp -> 0
}]]];

thb[x_,y_][UU[L_],UU[R_]] := CF[UU[Expand[Distribute[pp[L,R]] /. {
pp[0,_] -> 0, pp[_,0] -> 0,
pp[_β|_δβ|_δa|_δaa, _β|_δβ|_δa|_δaa] -> 0,
pp[_a,_β|_δβ] -> 0,
pp[β[f_], a[g_,i_,j_]] :> (Subscript[Kδ, y,j])γ[g(∂_(Subscript[b, x]))f, i,y],
pp[a[f_,i_,j_], a[g_,k_,l_]] :> (Subscript[Kδ, y,l])(
γa[g(∂_(Subscript[b, x]))f,k,l,i,j]+(Subscript[Kδ, x,i])(
γ[-(Subscript[b, k])g(∂_(Subscript[b, x]))f,i,j]+δa[(Subscript[b, k])g(∂_(Subscript[b, x]))f,i,j]-δa[(Subscript[b, i])g(∂_(Subscript[b, x]))f,k,j]-a[(Subscript[b, k])f g,i,j]+a[(Subscript[b, i])f g,k,j]+ca[f g, j,k,l]-ca[f g,l,k,j])),
pp[a[f_,i_,j_], δa[g_,k_,l_]] :> (Subscript[Kδ, x,i])(Subscript[Kδ, y,l])(-δa[(Subscript[b, k])f g,i,j]+δa[(Subscript[b, i])f g,k,j]),
pp[a[f_,i_,j_], δaa[g_,k_,l_,m_,n_]] :> (Subscript[Kδ, x,i])(
(Subscript[Kδ, y,l])(-δaa[(Subscript[b, k])f g,i,j,m,n]+δaa[(Subscript[b, i])f g,k,j,m,n]) + (Subscript[Kδ, y,n])(-δaa[(Subscript[b, m])f g,k,l,i,j]+δaa[(Subscript[b, i])f g,k,l,m,j])+(Subscript[Kδ, y,l,n])(δa[(Subscript[b, x])(Subscript[b, m])f g,k,j]-δa[(Subscript[b, k])(Subscript[b, m])f g,x,j])),
pp[_δβ,_a] -> 0,
pp[δa[f_,i_,j_], a[g_,k_,l_]] :> (Subscript[Kδ, x,i])(Subscript[Kδ, y,l])(-δa[(Subscript[b, k])f g,i,j]+δa[(Subscript[b, i])f g,k,j]),
pp[δaa[f_,i_,j_,m_,n_], a[g_,k_,l_]] :> (Subscript[Kδ, x,i])(Subscript[Kδ, y,l])(-δaa[(Subscript[b, k])f g,i,j,m,n]+δaa[(Subscript[b, i])f g,k,j,m,n]) + (Subscript[Kδ, x,m])(Subscript[Kδ, y,l])(-δaa[(Subscript[b, k])f g,i,j,m,n]+δaa[(Subscript[b, m])f g,i,j,k,n])
}]]];
htb[x_,y_][L_UU,R_UU] := -thb[y,x][R,L];

(Subscript[t, 1])(Subscript[h, 1])(Subscript[t, 2])(Subscript[h, 2]) -> (Subscript[t, 1])(Subscript[t, 2])(Subscript[h, 1])(Subscript[h, 2]) -> (Subscript[t, 2])(Subscript[t, 1])(Subscript[h, 1])(Subscript[h, 2]) -> (Subscript[t, 2])(Subscript[t, 1])(Subscript[h, 2])(Subscript[h, 1]) -> (Subscript[t, 2])(Subscript[h, 2])(Subscript[t, 1])(Subscript[h, 1]):

db[x_][u_UU,v_UU] := Module[{t,h}, Plus[
htb[x,x][u//tσ[x,t],v//hσ[x,h]]//tm[t,x,x]//hm[x,h,x],
tb[x][u,v//hσ[x,h]] // hm[x,h,x],
hb[x][u,v//tσ[x,t]] // tm[t,x,x],
thb[x,x][u//hσ[x,h],v//tσ[x,t]]//tm[t,x,x]//hm[x,h,x] ]];

bb[S_List] := Module[{w,bar,t,n=0,i,k},
w=#2//dσ[S,bar/@S];
Sum[t=db[S[[k]]][#1,w // dσ[bar[S[[k]]], S[[k]]]];
Do[t=t//dm[bar[S[[i]]], S[[i]], S[[i]]], {i,1,k-1}];
Do[t=t//dm[S[[i]], bar[S[[i]]], S[[i]]], {i,k+1,Length@S}];
t, {k,Length@S}] ]&
bb[S___] := bb[{S}]

ct (contract)

ct::usage="ct[h,t][L,R] contracts the head h in L with the tail t in R. ct[s][L,R] takes h=t=s, and ct[][L,R] takes s=0. When ambiguous, L is placeed below R.";

ct[s_] := ct[s,s]; ct[] = ct[0,0];
ct[h_,t_][UU[L_],UU[R_]] := CF[UU[Distribute[pp[L,R]] /. {
pp[_β|_δβ,_] -> 0,
pp[a[f_,i_,h], β[g_]] :> β[f (Subscript[b, i])(((∂_(Subscript[b, t]))g) /. (Subscript[b, t])->0)],
pp[a[f_,i_,h], a[g_,t,j_]] :> a[f(g/.(Subscript[b, t])->0), i,j],
pp[a[f_,i_,h], a[g_,j_,k_]] :> a[f(Subscript[b, i])(((∂_(Subscript[b, t]))g) /. (Subscript[b, t])->0), j,k],
pp[a[f_,i_,h], δa[g_,t,j_]] :> δa[f(g/.(Subscript[b, t])->0), i,j],
pp[a[f_,i_,h], δa[g_,j_,k_]] :> δa[f (Subscript[b, i])(((∂_(Subscript[b, t]))g) /. (Subscript[b, t])->0), j,k],
pp[a[f_,i_,h], δaa[g_,t,j_,t,k_]]  -> 0,
pp[a[f_,i_,h], δaa[g_,t,j_,k_,l_]] :> δaa[f(g/.(Subscript[b, t])->0), i,j,k,l],
pp[a[f_,i_,h], δaa[g_,j_,k_,t,l_]] :> δaa[f(g/.(Subscript[b, t])->0), j,k,i,l],
pp[a[f_,i_,h], δaa[g_,j_,k_,l_,m_]] :> δaa[f (Subscript[b, i])(((∂_(Subscript[b, t]))g) /. (Subscript[b, t])->0), j,k,l,m],
pp[a[__], _] -> 0, pp[_δa|_δaa, _δβ|_δa|_δaa] -> 0,
pp[δa[f_,i_,h], β[g_]] :> δβ[f (Subscript[b, i])(((∂_(Subscript[b, t]))g) /. (Subscript[b, t])->0)],
pp[δa[f_,i_,h], a[g_,t,j_]] :> δa[f(g/.(Subscript[b, t])->0),i,j],
pp[δa[f_,i_,h], a[g_,j_,k_]] :> δa[f (Subscript[b, i])(((∂_(Subscript[b, t]))g) /. (Subscript[b, t])->0), j,k],
pp[_δa,_] -> 0, pp[δaa[_,_,h,_,h], _] -> 0,
pp[δaa[f_,i_,h,j_,k_], β[g_]] :> δa[f (Subscript[b, i])(((∂_(Subscript[b, t]))g) /. (Subscript[b, t])->0),j,k],
pp[δaa[f_,i_,h,j_,k_], a[g_,t,l_]] :> δaa[f (g/.(Subscript[b, t])->0),i,l,j,k],
pp[δaa[f_,i_,h,j_,k_], a[g_,l_,m_]] :> δaa[f (Subscript[b, i])(((∂_(Subscript[b, t]))g) /. (Subscript[b, t])->0), j,k,l,m],
pp[δaa[f_,i_,j_,k_,h], β[g_]] :> δa[f (Subscript[b, k])(((∂_(Subscript[b, t]))g) /. (Subscript[b, t])->0), i,j],
pp[δaa[f_,i_,j_,k_,h], a[g_,t,l_]] :> δaa[f (g/.(Subscript[b, t])->0),i,j,k,l],
pp[δaa[f_,i_,j_,k_,h], a[g_,l_,m_]] :> δaa[f (Subscript[b, k])(((∂_(Subscript[b, t]))g) /. (Subscript[b, t])->0), i,j,l,m],
pp[_δaa, _] -> 0 }]];

dect (de-contract)

dect::usage="dect[h,t][uu] returns a pair {L,R} such that ct[h,t][L,R]=uu. Similarly for dect[s] and dect[]. uu is assumed to be atomic.";
dect[s_] := dect[s,s];
dect[] = dect[0,0];
dect[h_,t_][β[f_]] :=  {};
dect[h_,t_][δβ[f_]] :=  TBD;

Exporting the above as PDF files

The below is adapted from pensieve://2016-04/GaussGassner/GaussGassnerDemo.nb.

SetDirectory["C:\\drorbn\\AcademicPensieve\\Projects\\OneCo-1604"];

ConditionalExport[fname_String, rest___] := Module[{temp, exists},
temp="ConditionalExportTemporary"<>"."<>FileExtension[fname];
exists=FileExistsQ[fname];
Export[temp, rest];
If[exists && FileByteCount[fname]===FileByteCount[temp],
DeleteFile[temp],
(* else *) Print["Exporting "<>fname<>"..."];
If[exists, DeleteFile[fname]];
RenameFile[temp, fname]
];
fname
]

Button["Export",
SetOptions[$FrontEndSession,PrintingStyleEnvironment->"Working"];
TagProperties[_] := {};
TagProperties["ct-def"] = {PageWidth ->6/0.65};
Options[CellExport] = {
PageWidth -> 4/0.65, CellFilter -> Identity, ExportDirectory -> "Snips", ExportBaseFilename -> Automatic, ExportFormat -> ".pdf", ExportOptions -> {}, Split -> False
};
CellExport[tag_String, opts___Rule] := CellExport[
NotebookGet[EvaluationNotebook[]],
tag, opts
];
CellExport[nb_Notebook, tag_String] := CellExport[nb, tag, TagProperties[tag]];
CellExport[nb_Notebook, tag_String, OptionsPattern[]] := Module[
{cells, cell, filename, format},
filename = FileNameJoin[{
OptionValue[ExportDirectory] /. Automatic -> Directory[],
OptionValue[ExportBaseFilename] /. Automatic -> tag
}];
format=OptionValue[ExportFormat];
cells=OptionValue[CellFilter][Cases[
nb, c_Cell /; FreeQ[List@@c, Cell] && !FreeQ[c, CellTags->tag],
Infinity
]];
If[!OptionValue[Split],
If[Length[cells]≥1,
If[Length[cells]==1,
cells=Append[First[cells], PageWidth ->1.2 72OptionValue[PageWidth]],
cells=Cell[CellGroup[cells], PageWidth -> 72OptionValue[PageWidth]]
];
ConditionalExport[
filename<>format,cells,
ImageResolution -> 300,
OptionValue[ExportOptions]
]
],
k=0;
Table[
++k;
ConditionalExport[
filename<>"-"<>ToString[k]<>format,
Append[cell, PageWidth -> 72OptionValue[PageWidth]],
ImageResolution -> 300,
OptionValue[ExportOptions]
],
{cell, cells}
]
]
];
nb=NotebookGet[EvaluationNotebook[]];
tags=Cases[nb, (CellTags->tag_) :> tag, Infinity ] // Union;
CellExport /@ tags;
Print["Done."]
]