(* ::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\\2012-07"];
<< "FreeLie.m"


Random\[Lambda][d_,m_,n_] := Module[{bas},
bas=AllLyndonWords[{d}, Characters[StringTake["1234567890", m]]];
\[Lambda][
MakeCWSeries[RandomInteger[{-2,2},Length[bas]].bas /. LW->CW],
Sum[h[j]MakeLieSeries[RandomInteger[{-2,2},Length[bas]].bas], {j,n}]
]
];
hL[\[Lambda]_] := Union[Cases[\[Lambda], h[s_] :> s, Infinity]];
\[Lambda][\[Omega]_,\[Mu]_][d_] := \[Lambda][\[Omega][d], \[Mu] /. s_LieSeries :> s[d]];
\[Lambda][\[Omega]1_, \[Mu]1_] \[Congruent] \[Lambda][\[Omega]2_, \[Mu]2_] := \[Omega]1\[Congruent]\[Omega]2 && (And @@ ((D[\[Mu]1, h[#]]\[Congruent]D[\[Mu]2, h[#]])& /@ hL[{\[Mu]1, \[Mu]2}]));
LieDerivation[der_][\[Lambda][\[Omega]_, \[Mu]_]] := \[Lambda][\[Omega]//der, Collect[\[Mu], _h, der]];
LieMorphism[mor_][\[Lambda][\[Omega]_, \[Mu]_]] := \[Lambda][\[Omega]//mor, Collect[\[Mu], _h, mor]];


\[Lambda] /: \[Lambda][\[Omega]1_, \[Mu]1_]\[Lambda][\[Omega]2_, \[Mu]2_] := \[Lambda][
AddCWSeries[\[Omega]1, \[Omega]2],
Collect[\[Mu]1+\[Mu]2, _h,
(# /. ls1_LieSeries + ls2_LieSeries :> AddLieSeries[ls1,ls2])&
]
];
tm[x_,y_,z_][\[Lambda][\[Omega]_, \[Mu]_]] := \[Lambda][\[Omega], \[Mu]] //  LieMorphism[{\[LeftAngleBracket]x\[RightAngleBracket]->\[LeftAngleBracket]z\[RightAngleBracket], \[LeftAngleBracket]y\[RightAngleBracket]->\[LeftAngleBracket]z\[RightAngleBracket]}];
hm[x_,y_,z_][\[Lambda][\[Omega]_, \[Mu]_]] := \[Lambda][\[Omega], Plus[
\[Mu] /. {h[x]->0, h[y]->0},
h[z]BCH[D[\[Mu], h[x]], D[\[Mu], h[y]]]
]];
hta[x_,y_,z_][\[Lambda][\[Omega]_, \[Mu]_]] := Module[{\[Mu]x, Ad\[Mu]x},
\[Mu]x = MakeLieSeries[D[\[Mu], h[x]]];
Ad\[Mu]x = LieMorphism[{LW[y] -> Ad[ScaleLieSeries[-1,\[Mu]x]][LW[z]]}];
\[Lambda][
AddCWSeries[StableApply[Ad\[Mu]x, \[Omega]], J[LW[y], \[Mu]x]],
Collect[\[Mu], _h, StableApply[Ad\[Mu]x,#]&]
]
];
hta[x_,y_][\[Lambda][\[Omega]_, \[Mu]_]] := \[Lambda][\[Omega], \[Mu]] // hta[x,y,\[LeftAngleBracket]"z"\[RightAngleBracket]] // LieMorphism[{LW["z"] -> LW[y]}];
dm[x_,y_,z_][\[Lambda]_] := \[Lambda] // hta[y,x] // tm[x,y,z] // hm[x,y,z];
Rp[x_,y_] := \[Lambda][MakeCWSeries[0],h[y]MakeLieSeries[\[LeftAngleBracket]x\[RightAngleBracket]]];
Rm[x_,y_] := \[Lambda][MakeCWSeries[0],h[y]MakeLieSeries[-\[LeftAngleBracket]x\[RightAngleBracket]]];



