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



(* ::Input::Initialization:: *)
CCF[\[ScriptCapitalE]_] := Factor[\[ScriptCapitalE]]; 
CF[\[ScriptCapitalE]_] := Module[{vs=Union@Cases[\[ScriptCapitalE],Subscript[(\[Xi]|x), _],\[Infinity]]},
Total[(CCF[#[[2]]](Times@@(vs^#[[1]])))& /@ CoefficientRules[\[ScriptCapitalE], vs]]];


(* ::Input::Initialization:: *)
\[CapitalGamma]/:\[CapitalGamma][is1_,os1_,cs1_,\[Omega]1_,\[Lambda]1_]\[CapitalGamma][is2_,os2_,cs2_,\[Omega]2_,\[Lambda]2_]:=\[CapitalGamma][is1\[Union]is2,os1\[Union]os2,Join[cs1,cs2],\[Omega]1 \[Omega]2,\[Lambda]1+\[Lambda]2]
\[CapitalGamma]/:\[CapitalGamma][is1_,os1_,_,\[Omega]1_,\[Lambda]1_]\[Congruent]\[CapitalGamma][is2_,os2_,_,\[Omega]2_,\[Lambda]2_]:=TrueQ[(Sort@is1===Sort@is2)\[And](Sort@os1===Sort@os2)\[And]Simplify[\[Omega]1==\[Omega]2]\[And]CF@\[Lambda]1==CF@\[Lambda]2]


(* ::Input::Initialization:: *)
Subscript[c, h_,t_]@\[CapitalGamma][is_,os_,cs_,\[Omega]_,\[Lambda]_]:=Module[{\[Alpha],\[Eta],y,\[Mu]},
\[Alpha]=\!\(
\*SubscriptBox[\(\[PartialD]\), \(
\*SubscriptBox[\(\[Xi]\), \(t\)], 
\*SubscriptBox[\(x\), \(h\)]\)]\[Lambda]\); \[Mu]=\[Lambda]/.Subscript[\[Xi], t]|Subscript[x, h]->0;
\[Eta]=\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(x\), \(h\)]]\[Lambda]\)/.Subscript[\[Xi], t]->0; y=\!\(
\*SubscriptBox[\(\[PartialD]\), 
SubscriptBox[\(\[Xi]\), \(t\)]]\[Lambda]\)/.Subscript[x, h]->0;
 \[CapitalGamma][
DeleteCases[is,t],DeleteCases[os,h],KeyDrop[cs,{Subscript[x, h],Subscript[\[Xi], t]}],
CCF[(1-\[Alpha])\[Omega]],CF[\[Mu]+\[Eta] y/(1-\[Alpha])]
] /. If[MatchQ[cs[Subscript[\[Xi], t]],Subscript[\[Tau], _]], cs[Subscript[\[Xi], t]]->cs[Subscript[x, h]],cs[Subscript[x, h]]-> cs[Subscript[\[Xi], t]]]];
c@\[CapitalGamma][is_,os_,cs_,\[Omega]_,\[Lambda]_]:=Fold[Subscript[c, #2,#2][#1]&,\[CapitalGamma][is,os,cs,\[Omega],\[Lambda]],is\[Intersection]os]


(* ::Input::Initialization:: *)
\[CapitalGamma][Subscript[X, i_,j_,k_,l_][S_,T_]]:=\[CapitalGamma][{l,i},{j,k},<|Subscript[\[Xi], i]->S,Subscript[x, j]->T,Subscript[x, k]->S,Subscript[\[Xi], l]->T|>,T^(-1/2),CF[{Subscript[\[Xi], l],Subscript[\[Xi], i]} . ({
 {1, 1-T},
 {0, T}
}) . {Subscript[x, j],Subscript[x, k]}]];
\[CapitalGamma][Subscript[\!\(\*OverscriptBox[\(X\), \(_\)]\), i_,j_,k_,l_][S_,T_]]:=\[CapitalGamma][{i,j},{k,l},<|Subscript[\[Xi], i]->S,Subscript[\[Xi], j]->T,Subscript[x, k]->S,Subscript[x, l]->T|>,T^(1/2),CF[{Subscript[\[Xi], i],Subscript[\[Xi], j]} . ({
 {T^-1, 0},
 {1-T^-1, 1}
}) . {Subscript[x, k],Subscript[x, l]}]];
\[CapitalGamma][Subscript[X, i_,j_,k_,l_]]:=\[CapitalGamma][Subscript[X, i,j,k,l][Subscript[\[Tau], i],Subscript[\[Tau], l]]];
\[CapitalGamma][Subscript[\!\(\*OverscriptBox[\(X\), \(_\)]\), i_,j_,k_,l_]]:=\[CapitalGamma][Subscript[\!\(\*OverscriptBox[\(X\), \(_\)]\), i,j,k,l][Subscript[\[Tau], i],Subscript[\[Tau], j]]];


(* ::Input::Initialization:: *)
\[CapitalGamma][Subscript[P, i_,j_][T_]]:=\[CapitalGamma][{i},{j},<|Subscript[\[Xi], i]->T,Subscript[x, j]->T|>,1,Subscript[\[Xi], i] Subscript[x, j]];
\[CapitalGamma][Subscript[P, i_,j_]]:=\[CapitalGamma][Subscript[P, i,j][Subscript[\[Tau], i]]];


(* ::Input::Initialization:: *)
\[CapitalGamma][{\[Gamma]_\[CapitalGamma]}]:=c[\[Gamma]];
\[CapitalGamma][{\[Gamma]1_\[CapitalGamma],\[Gamma]s__\[CapitalGamma]}]:=Module[{\[Gamma]2},
\[Gamma]2=First@MaximalBy[{\[Gamma]s},Length[\[Gamma]1[[1]]\[Intersection]#[[2]]]+Length[\[Gamma]1[[2]]\[Intersection]#[[1]]]&];
\[CapitalGamma][Join[{c[\[Gamma]1 \[Gamma]2]}, DeleteCases[{\[Gamma]s},\[Gamma]2]]] ]
\[CapitalGamma][\[ScriptCapitalO]s_List]:=\[CapitalGamma][\[CapitalGamma]/@\[ScriptCapitalO]s]


(* ::Input::Initialization:: *)
\[CapitalGamma]@\[ScriptCapitalA][is_,os_,cs_,w_]:=Module[{i,j,\[Omega]=Coefficient[w,Wedge[]]},
\[CapitalGamma][is,os,cs,\[Omega],Sum[Cancel[-Coefficient[w,Subscript[x, j]\[Wedge]Subscript[\[Xi], i]] Subscript[\[Xi], i]Subscript[x, j]/\[Omega]], {i,is},{j,os}]]
];
\[ScriptCapitalA]@\[CapitalGamma][is_,os_,cs_,\[Omega]_,\[Lambda]_]:=\[ScriptCapitalA][is,os,cs,Expand[\[Omega] WExp[Expand[\[Lambda]]/.Subscript[\[Xi], a_] Subscript[x, b_]:>Subscript[\[Xi], a]\[Wedge]Subscript[x, b]]]];



