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


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


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



