(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



DQ[is___] := (Sort[{is}]===Union[{is}]);
OQ[is___] := OrderedQ[{is}];


Simp[expr_] := Simplify[expr];
S[\[Beta][f_]] := \[Beta][Simp[f]];
S[a[i_,j_]] := a[i,j];
S[a[f_, i_,j_]] := a[Simp[f], i,j];
S[c[f_, k_]] := c[Simp[f], k];
S[\[Delta]a[f_, i_,j_]] := \[Delta]a[Simp[f], i,j];
S[ca[f_, j_,k_,l_]] := ca[Simp[f], j,k,l];
S[\[Delta]aa[f_, i_,j_,k_,l_]] := \[Delta]aa[Simp[f], i,j,k,l];
S[expr_] := expr /. (\[Lambda]_\[Beta]|\[Lambda]_a|\[Lambda]_\[Delta]a|\[Lambda]_c|\[Lambda]_ca|\[Lambda]_\[Delta]aa) :> S[\[Lambda]];


\[Beta][0] :=0;
\[Beta] /: \[Beta][f_] + \[Beta][g_] := \[Beta][f+g] // S;
\[Beta] /: g_*\[Beta][f_] := \[Beta][g f] // S;
a[0,_,_] := 0;
a /: a[f_,j_,k_] + a[g_, j_,k_] := a[f+g, j,k] // S;
a /: g_*a[f_, j_,k_] := a[g f, j,k] // S;
c[0,_] :=0;
c /: c[f_,j_] + c[g_, j_] := c[f+g, j] // S;
c/: g_*c[f_, j_] := c[g f, j] // S;
\[Delta]a[0,_,_] := 0;
\[Delta]a /: \[Delta]a[f_,j_,k_] + \[Delta]a[g_, j_,k_] := \[Delta]a[f+g, j,k] // S;
\[Delta]a /: g_*\[Delta]a[f_, j_,k_] := \[Delta]a[g f, j,k] // S;
ca[0,_,_,_] :=0;
ca /: ca[f_,j_,k_,l_] + ca[g_, j_,k_,l_] := ca[f+g, j,k,l] // S;
ca /: g_*ca[f_, j_,k_,l_] := ca[g f, j,k,l] // S;
\[Delta]aa[0, _,_,_,_] :=0;
\[Delta]aa /: \[Delta]aa[f_,i_,j_,k_,l_] + \[Delta]aa[g_, i_,j_,k_,l_] := \[Delta]aa[f+g, i,j,k,l] // S;
\[Delta]aa /: g_*\[Delta]aa[f_, i_,j_,k_,l_] := \[Delta]aa[g f, i,j,k,l] // S;


Unprotect[NonCommutativeMultiply];
NonCommutativeMultiply[0,_] =0; NonCommutativeMultiply[_, 0] = 0;
NonCommutativeMultiply[x_,x_] = 0;
NonCommutativeMultiply[x_Plus, y_] := NonCommutativeMultiply[#,y]& /@ x;
NonCommutativeMultiply[x_, y_Plus] := NonCommutativeMultiply[x,#]& /@ y;


\[Beta][f_]**a[g_,j_,k_] := a[f g, j,k];
\[Beta][f_]**c[g_,j_] := c[f g, j];
c[g_,j_] ** \[Beta][f_] := c[f g, j];
\[Beta][f_]**\[Delta]a[g_,j_,k_] := \[Delta]a[f g, j,k];
\[Beta][f_]**ca[g_,i_,j_,k_] := ca[f g, i,j,k];
ca[g_,i_,j_,k_]**\[Beta][f_] := ca[f g, i,j,k];
\[Beta][f_]**\[Delta]aa[g_,i_,j_,k_,l_] := \[Delta]aa[f g, i,j,k,l];
\[Delta]a[g_,j_,k_] ** \[Beta][f_] := \[Delta]a[f g, j,k];
\[Delta]**a[f_,i_,j_] := \[Delta]a[f,i,j];
c[f_,i_]**a[g_,j_,k_] := ca[f g, i,j,k];
a[f_,i_,j_]**\[Delta]a[g_,k_,l_] := \[Delta]aa[f g,i,j,k,l];
\[Delta]a[f_,i_,j_]**a[g_,k_,l_] := \[Delta]aa[f g,i,j,k,l];


\[Delta]**_c = 0;
\[Delta]**_\[Delta]a = 0;
\[Delta]**_ca = 0;
\[Delta]**_\[Delta]aa = 0;
_c**_c=0;
_c**_\[Delta]a = _\[Delta]a**_c = 0;
_c**_ca = _ca**_c = 0;
_c**_\[Delta]aa = _\[Delta]aa**_c = 0;
_\[Delta]a**_\[Delta]a = 0;
_\[Delta]a**_\[Delta]aa = _\[Delta]aa**_\[Delta]a = 0;
_\[Delta]a**_ca = _ca**_\[Delta]a = 0;


NonCommutativeMultiply::ndef = "NonCommuatativeMultiply is not defined on {`1`,`2`}."
NonCommutativeMultiply[x_,y_] := (Message[NonCommutativeMultiply::ndef, x,y]; Undefined);


B[0,_] =0; B[_, 0] = 0;
B[x_,x_] = 0;
B[x_Plus, y_] := B[#,y]& /@ x;
B[x_, y_Plus] := B[x,#]& /@ y;


\[Gamma][f_, j_,k_] := \[Delta]a[f,j,k]-c[Subscript[b, j]f,k] // S;
\[Gamma][f_, j_,k_,l_] /; DQ[j,k,l] := ca[f,l,j,k] - ca[f,k,j,l] // S;
ac[f_, j_,k_,l_] := ca[f, l,j,k] + B[a[1,j,k], c[f,l]];
adown[f_, j_] := a[f, j,j] + \[Beta][Subscript[\[Epsilon], 1]f Subscript[b, j]]+c[Subscript[\[Epsilon], 1]f,j];


B[a[j_,k_],\[Beta][g_]]:=\[Gamma][\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(b\), \(j\)]]g\)-\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(b\), \(k\)]]g\),j,k];
B[\[Beta][g_], a[j_,k_]] := -B[a[j,k], \[Beta][g]];
B[a[j_,k_],a[l_,m_]] /; ({j,k}\[Intersection]{l,m}==={}) := 0;B[a[j_,k_],a[j_,l_]]/;DQ[j,k,l]:=\[Gamma][1,j,k,l] // S;
B[a[j_,k_],a[i_,k_]]/;DQ[i,j,k]:=a[Subscript[b, i],j,k]-a[Subscript[b, j],i,k] // S;
B[a[j_,k_],a[k_,l_]]/;DQ[j,k,l]:=a[Subscript[b, j],k,l]-a[Subscript[b, k],j,l]-\[Gamma][1,j,k,l] // S;
B[a[k_,l_], a[j_,k_]]/;DQ[j,k,l]:= -B[a[j,k],a[k,l]];
(* backie *) B[a[j_,k_], a[k_,j_]] /; DQ[j,k] := a[Subscript[\[Epsilon], 5] Subscript[b, j],k,j]-a[Subscript[\[Epsilon], 5] Subscript[b, k],j,k]+a[Subscript[\[Epsilon], 5] Subscript[b, j],k,k]-a[Subscript[\[Epsilon], 5] Subscript[b, k],j,j]+ca[Subscript[\[Epsilon], 4],k,k,j]-ca[Subscript[\[Epsilon], 4],j,j,k]+ca[Subscript[\[Epsilon], 4],k,j,j]-ca[Subscript[\[Epsilon], 4],j,k,k]+\[Gamma][Subscript[\[Epsilon], 4],j,k]-\[Gamma][Subscript[\[Epsilon], 4],k,j];
(* [tail, selfie] *) B[a[j_,k_], a[j_,j_]] /; DQ[j,k] := \[Gamma][-Subscript[\[Epsilon], 6],j,k] //S;
B[a[j_,j_], a[j_,k_]] /; DQ[j,k] := -B[a[j,k], a[j,j]];
(* [head, selfie] *) B[a[j_,k_], a[k_,k_]] /; DQ[j,k] := \[Gamma][-Subscript[\[Epsilon], 7],j,k] //S;
B[a[k_,k_], a[j_,k_]] /; DQ[j,k] := -B[a[j,k], a[k,k]];
B[a[f_,j_,k_], c[g_,j_]] /; DQ[j,k] := \[Gamma][-f g,j,k];
B[a[f_,j_,k_], c[g_,k_]] /; DQ[j,k] := \[Gamma][f g,j,k];
B[a[f_,j_,k_], c[g_,l_]] /; ({j,k}\[Intersection]{l}==={}) := 0;
B[a[f_,j_,j_], c[g_,j_]] = 0;
B[c[g_,l_], a[f_,j_,k_]] := -B[a[f,j,k], c[g,l]];


B[_\[Beta], _\[Beta]|\[Delta]|_c|_\[Delta]a|_ca|_\[Delta]aa] = 0;
B[_\[Beta]|\[Delta]|_c|_\[Delta]a|_ca|_\[Delta]aa, _\[Beta]] = 0;
B[\[Delta]|_c|_\[Delta]a|_ca|_\[Delta]aa, \[Delta]|_c|_\[Delta]a|_ca|_\[Delta]aa] = 0;


B[a[f_, j_,k_],\[Beta][g_]] :=\[Beta][f]**B[a[j,k],\[Beta][g]];
B[\[Beta][g_], a[f_, j_,k_]] := -B[a[f,j,k], \[Beta][g]];
B[a[f_, j_,k_], a[l_,m_]] := B[\[Beta][f], a[l,m]]**a[1,j,k] + \[Beta][f]**B[a[j,k], a[l,m]];
B[a[f_, j_,k_], a[g_, l_,m_]] := B[a[f,j,k], \[Beta][g]]**a[1,l,m] + \[Beta][g]**B[a[f,j,k], a[l,m]];
B[a[f_,i_,j_], \[Delta]a[g_,k_,l_]] := \[Delta]**B[a[f,i,j], a[g,k,l]];
B[\[Delta]a[f_,i_,j_], a[g_,k_,l_]] := \[Delta]**B[a[f,i,j], a[g,k,l]];
B[a[f_,i_,j_], ca[g_,k_,l_,m_]] := B[a[f,i,j], c[g,k]]**a[1,l,m]+c[g,k]**B[a[f,i,j],a[l,m]];
B[ca[g_,k_,l_,m_], a[f_,i_,j_]] := -B[a[f,i,j], ca[g,k,l,m]];
B[a[f_,i_,j_], \[Delta]aa[g_,k_,l_,m_,n_]] := B[a[f,i,j], \[Delta]a[g,k,l]]**a[1,m,n]+\[Delta]a[g,k,l]**B[a[f,i,j],a[m,n]];
B[\[Delta]aa[g_,k_,l_,m_,n_], a[f_,i_,j_]] := -B[a[f,i,j], \[Delta]aa[g,k,l,m,n]];


B::ndef = "B is not defined on {`1`,`2`}."
B[x_,y_] := (Message[B::ndef, x,y]; Undefined);



