(* ::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.                                                         *)
(************************************************************************)



SetDirectory["C:\\drorbn\\AcademicPensieve\\Projects\\KBH"];


<< FreeLie.m
$SeriesShowDegree=3; $SeriesCompareDegree = 5;


Format[s_CWSeries, StandardForm] := MapAt[
Style[#, GrayLevel[0.6]]&,
TopBracketForm[s[{$SeriesShowDegree}]],
1];
CWSeries[ser_Symbol][{dd_Integer}] := MapAt[
Style[#, GrayLevel[0.6]]&,
TopBracketForm[CWS@@Table[ser[d], {d, dd}]],
1];


Domain[f_List] := First /@ f;
f_\[Backslash]key_ := DeleteCases[f, key -> _];
f_ \[Backslash] keys_List := Fold[#1\[Backslash]#2&, f, keys];
f1_List \[Congruent] f2_List := Domain[f1]===Domain[f2] && (And @@ (
((#/.f1)\[Congruent](#/.f2))& /@ Domain[f1]));
LieMorphism[mor_][f_List] := MapAt[LieMorphism[mor], f, {All, 2}];
M[\[Lambda]1_, \[Omega]1_] \[Congruent] M[\[Lambda]2_, \[Omega]2_] := (\[Lambda]1\[Congruent]\[Lambda]2) && (\[Omega]1\[Congruent]\[Omega]2);


Subscript[RC, u_][\[Gamma]_LieSeries, ub_][s_] := StableApply[LieMorphism[\[LeftAngleBracket]u\[RightAngleBracket] -> Ad[\[Gamma]][\[LeftAngleBracket]ub\[RightAngleBracket]]], s];
Subscript[RC, u_][\[Gamma]_LieSeries][s_] := s // Subscript[RC, u][\[Gamma],\[LeftAngleBracket]\[Upsilon]\[RightAngleBracket]] // LieMorphism[\[LeftAngleBracket]\[Upsilon]\[RightAngleBracket]->\[LeftAngleBracket]u\[RightAngleBracket]];
Subscript[J, u_][\[Gamma]_] := Module[{s},\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(1\)]\(\((\(\(\[Gamma]\  // \ 
\(\*SubscriptBox[\(RC\), \(u\)]\)[s\ \[Gamma]]\)\  // \ 
\*SubscriptBox[\(div\), \(u\)]\)\  // \ LieMorphism[u\  -> \ \(Ad[\(-s\)\ \[Gamma]]\)[u]])\) \[DifferentialD]s\)\)];


M /: M[\[Lambda]1_, \[Omega]1_]*M[\[Lambda]2_, \[Omega]2_] := M[\[Lambda]1 \[Union] \[Lambda]2, \[Omega]1+\[Omega]2];tm[u_,v_,w_][\[Lambda]_List] := \[Lambda] //  LieMorphism[\[LeftAngleBracket]u\[RightAngleBracket]->\[LeftAngleBracket]w\[RightAngleBracket], \[LeftAngleBracket]v\[RightAngleBracket]->\[LeftAngleBracket]w\[RightAngleBracket]];
tm[u_,v_,w_][M[\[Lambda]_, \[Omega]_]] := LieMorphism[\[LeftAngleBracket]u\[RightAngleBracket]->\[LeftAngleBracket]w\[RightAngleBracket], \[LeftAngleBracket]v\[RightAngleBracket]->\[LeftAngleBracket]w\[RightAngleBracket]] /@ M[\[Lambda], \[Omega]];
hm[x_,y_,z_][\[Lambda]_List] := Union[\[Lambda]\[Backslash]{x,y}, {z->BCH[x/.\[Lambda], y/.\[Lambda]]}];
hm[x_,y_,z_][M[\[Lambda]_, \[Omega]_]] := M[\[Lambda] // hm[x,y,z], \[Omega]];
tha[u_, x_][\[Lambda]_List] := MapAt[Subscript[RC, u][x /. \[Lambda]], \[Lambda], {All, 2}];
tha[u_, x_][M[\[Lambda]_, \[Omega]_]] := M[\[Lambda] // tha[u,x], (\[Omega]+Subscript[J, u][x /. \[Lambda]]) // Subscript[RC, u][x /. \[Lambda]]];


h\[Epsilon][x_] := M[{x->MakeLieSeries[0]}, MakeCWSeries[0]]
SuperPlus[\[Rho]][u_,x_] := M[{x->MakeLieSeries[\[LeftAngleBracket]u\[RightAngleBracket]]}, MakeCWSeries[0]];
SuperMinus[\[Rho]][u_,x_] := M[{x->MakeLieSeries[-\[LeftAngleBracket]u\[RightAngleBracket]]}, MakeCWSeries[0]];


SuperPlus[R][a_,b_] := SuperPlus[\[Rho]][a,b]*h\[Epsilon][a]; SuperMinus[R][a_,b_] := SuperMinus[\[Rho]][a,b]*h\[Epsilon][a];
dm[a_,b_,c_][\[Mu]_] := \[Mu] // tha[\[LeftAngleBracket]a\[RightAngleBracket],b] // tm[\[LeftAngleBracket]a\[RightAngleBracket],\[LeftAngleBracket]b\[RightAngleBracket],\[LeftAngleBracket]c\[RightAngleBracket]] // hm[a,b,c];


\[Mu]2= SuperMinus[R][r,6]SuperPlus[R][2,4]SuperMinus[R][g,9]SuperPlus[R][5,7]SuperMinus[R][b,3]SuperPlus[R][8,1];
(Do[\[Mu]2 = \[Mu]2 // dm[r,k,r], {k,1,3}]; Do[\[Mu]2 = \[Mu]2 // dm[g,k,g], {k,4,6}];
Do[\[Mu]2 = \[Mu]2 // dm[b,k,b], {k,7,9}];  \[Mu]2)



