SpinFrames

Handling of spin frame formalisms

Thomas Bäckdahl     thomas.backdahl@chalmers.se
Mathematical Sciences,
Chalmers University of Technology and University of Gothenburg
Gothenburg, Sweden


Steffen Aksteiner     steffen.aksteiner@aei.mpg.de
Albert Einstein Institute
Potsdam, Germany

(c) 2014-2021, under GPL

http://www.xAct.es/
http://groups.google.com/group/xAct

SpinFrames is a package for handling NP and GHP spin frame formalisms.

SpinFrames is distributed under the GNU General Public License, and runs on top of xTensor, a free package for fast manipulation of abstract tensor expressions.

DateList[]

xAct`SpinFrames`$Version={"0.5.3",{2021,09,03}}

1. Initialization

1.0. TODO list

1.1. GPL

(* SpinFrames: Handling of spin frame formalisms *)

(* Copyright (C) 2014-2018 Thomas Bäckdahl and Steffen Aksteiner *)

(* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License,or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place-Suite 330, Boston, MA 02111-1307, USA. 
*)

1.2. Info package

(* :Title: SpinFrames *)

(* :Authors: Thomas Bäckdahl and Steffen Aksteiner *)

(* :Summary: Handling of spin frame formalisms *)

(* :Brief Discussion:
   - Handles Newman-Penrose and Geroch-Held-Penrose formalisms. *)
  
(* :Context: xAct`SpinFrames` *)

(* :Package Version: 0.5.3 *)

(* :Copyright: Thomas Bäckdahl and Steffen Aksteiner (2014-2021) *)

(* :History: See SpinFrames.History *)

(* :Keywords: *)

(* :Source: SpinFrames.nb *)

(* :Warning: *)

(* :Mathematica Version: 9.0 and later *)

(* :Limitations: *)
	
(* :Acknowledgements:
	The package is partly based on a notebook by Alfonso Garcia-Parrado Gomez-Lobo.
	The autors would like to thank Johannes Mosig, Alfonso Garcia-Parrado Gomez-Lobo 
	and Jose M. Martin-Garcia for helpful discussions. *)

1.3. BeginPackage

If[Unevaluated[xAct`xCore`Private`$LastPackage]===xAct`xCore`Private`$LastPackage,xAct`xCore`Private`$LastPackage="xAct`SpinFrames`"];

xAct`xCore`Private`$LastPackage

"xAct`SpinFrames`"

Explicit (not hidden) import of TexAct, xCoba, Spinors, xTensor, xPerm and xCore:

BeginPackage["xAct`SpinFrames`",{"xAct`SymManipulator`","xAct`TexAct`","xAct`xCoba`","xAct`Spinors`","xAct`xTensor`","xAct`xPerm`","xAct`xCore`"}]

"xAct`SpinFrames`"

Print[xAct`xCore`Private`bars]
Print["Package xAct`SpinFrames`  version ",$Version[[1]],", ",$Version[[2]]];
Print["CopyRight (C) 2014-2021, Thomas Bäckdahl and Steffen Aksteiner, under the General Public License."];

We specify the context xAct`Spinors` to avoid overriding the Disclaimer of the other packages. However we need to turn off the message General:shdw temporarily:

Off[General::shdw]
xAct`SymManipulator`Disclaimer[]:=Print["These are points 11 and 12 of the General Public License:\n\nBECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM `AS IS´ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\nIN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES."]
On[General::shdw]

If xSpaceSpinors is not being called from other package then write this GPL short disclaimer:

If[xAct`xCore`Private`$LastPackage==="xAct`SpinFrames`",
Unset[xAct`xCore`Private`$LastPackage];
Print[xAct`xCore`Private`bars];
Print["These packages come with ABSOLUTELY NO WARRANTY; for details type Disclaimer[]. This is free software, and you are welcome to redistribute it under certain conditions. See the General Public License for details."];
Print[xAct`xCore`Private`bars]]

Note that symbols in the Global` context cannot be accessed right now.

$ContextPath

{"xAct`SpinFrames`","xAct`SymManipulator`","xAct`TexAct`","xAct`xCoba`","xAct`Spinors`","xAct`xTensor`","xAct`xPerm`","xAct`xCore`","System`"}

$Context

"xAct`SpinFrames`"

Established connection to external executable?

$xpermQ

1.4. Non-standard setup

Screen all dollar indices:

$PrePrint = ScreenDollarIndices;

Timings will be shown if they are above 0.1 Second (Only for this notebook; this is not included in the package):

<<xAct/ShowTime1.m

$ShowTimeThreshold=0.1

We also read the package (this is not automatic in xCore anymore since its version 0.6.2):

1.5. Usage messages

DefNPTetrad::usage ="DefNPTetrad[NP,{lNP[a],nNP[a],mNP[a]}]";
DefSpinDyad::usage ="DefSpinDyad[Dyad,{o[A],ι[A]},NP]";
VectorsOfTetrad::usage="VectorsOfTetrad[NP] gives the list of vectors in the tetrad NP.";
SpinorsOfDyad::usage="SpinorsOfDyad[Dyad] gives the list of dyad spinors.";
TetradOfDyad::usage="TetradOfDyad[Dyad] returns the tetrad used in DefSpinDyad";
TetradToDyadRules::usage="TetradToDyadRules[tetrad] contains a list of rules that transforms the tetrad vectors into their corresponding spinor expressions.";
TetradToBasisRules::usage="TetradToBasisRules[tetrad] contains a list of rules that transforms the tetrad vectors to their corresponding Basis objects.";
BasisToTetradRules::usage="BasisToTetradRules[tetrad] contains a list of rules that transforms Basis objects to their corresponding tetrad vectors.";
DyadToBasisRules::usage ="DyadToBasisRules[dyad] contains a list of rules that transforms the dyad spinors to their corresponding Basis objects.";
BasisToDyadRules::usage ="BasisToDyadRules[dyad] contains a list of rules that transforms Basis objects to their corresponding dyad spinors.";
CovDDyadRules::usage ="CovDDyadRules[dyad] contains a list of rules that transforms covariant derivatives of the dyad spinors into NP spin oefficients.";
AutocanonicalizeComponents::usage="AutocanonicalizeComponents[T[inds]] where inds are basis indices, creates automatic rules for all non canoical index configurations, so they are replaced by their canonical ordering.";
NPSpinCoefficients::usage="NPSpinCoefficients[Dyad] gives the list of NP spin coefficients for Dyad.";
GHPSpinCoefficients::usage="GHPSpinCoefficients[Dyad] gives the list of GHP spin coefficients for Dyad.";
GHPWeightOf::usage="GHPWeightOf[expr] returns the GHP boost and spin weight of any expression. If the expression is not properly weighted, then an error message is returned. For expressions with undefined weight the default value {0,0} is assumed.";
NPToGHPSpinCoeffs::usage="NPToGHPSpinCoeffs[dyad] contains a list of rules that transforms the NP spin coefficients into GHP notation.";
GHPToNPSpinCoeffs::usage="GHPToNPSpinCoeffs[dyad] contains a list of rules that transforms the GHP spin coefficients into NP notation.";
GHPWeightRules::usage="GHPWeightRules[T, Dyad] sets the GHPWeightOf all components of the tensor T in Dyad assuming that T is unweighted.";
CovDToGHPRules::usage="CovDToGHPRules[Dyad] contains a list of rules that transforms covariant derivatives to GHP derivatives assuming that all covariant derivatives acts on properly weighted expressions. Warning: Use this only on expressions with first order covariant derivatives to avoid GHP derivatives acting on covariant derivatives.";
CovDToNPRules::usage="CovDToNPRules[Dyad] converts the covariant derivatives in expr to NP operators.";
CommuteGHPOp::usage="CommuteGHPOp[ΘDyad[{1,-NP}],ΘDyad[{2,-NP}]] gives a rule that commutes the ΘDyad[{1,-NP}] and ΘDyad[{2,-NP}] operators. CommuteGHPOp[ΘDyad[{1,-NP}],ΘDyad[{2,-NP}],s] gives the rule acting only on s.";
CommuteNPOp::usage="CommuteNPOp[PDNP[{1,-NP}],PDNP[{2,-NP}]] gives a rule that commutes the PDNP[{1,-NP}] and PDNP[{2,-NP}] operators. CommuteNPOp[PDNP[{1,-NP}],PDNP[{2,-NP}], s] gives the rule acting only on s.";
SetTexComponents::usage="SetTexComponents[Dyad,T] sets the Tex output of the component of the spinor T in Dyad to the style T_{ij'} where i is the number of iota contracted on the abstract spinor and j the number of Dagger@iota. This is only done if the spinor is completely symmetric. It is also an option for DyadExpansionEq.";
FormatComponents::usage="FormatComponents[Dyad,T] sets the output of the component of the spinor T in Dyad to the style T_{ij'} where i is the number of iota contracted on the abstract spinor and j the number of Dagger@iota. This is only done if the spinor is completely symmetric. It is also an option for DyadExpansionEq.";
SortByGHPOrder::usage="SortByGHPOrder[expr] sorts the terms in expr according to the order of the GHP operators. The result is a list like structure which can be used for Tex output, but not additive manupulations.";
GHPCommutatorsForward::usage="GHPCommutatorsForward[Dyad] gives a list of commutator rules for the GHP operators.";
GHPCommutatorsBackward::usage="GHPCommutatorsBackward[Dyad] gives a list of commutator rules for the GHP operators.";
NPCommutatorsForward::usage="NPCommutatorsForward[Dyad] gives a list of commutator rules for the NP operators.";
NPCommutatorsBackward::usage="NPCommutatorsBackward[Dyad] gives a list of commutator rules for the NP operators.";
CovDsToGHP::usage="CovDsToGHP[expr, Dyad] converts the covariant derivatives in expr to GHP operators. All internal expressions are expected to already be expanded in the corresponding dyad. Currently only first order covariant derivaties are supported.";
CovDsToNP::usage="CovDsToNP[expr, Dyad] converts the covariant derivatives in expr to NP operators. All internal expressions are expected to already be expanded in the corresponding dyad. Currently only first order covariant derivaties are supported.";
GHPRicciRules::usage="GHPRicciRules[Dyad] gives a the GHP Ricci equations in the form of a list of replacement rules.";
NPRicciRules::usage="NPRicciRules[Dyad] gives a the NP Ricci equations in the form of a list of replacement rules.";
NPBianchiRules::usage="NPBianchiRules[Dyad] gives a the NP Bianchi equations in the form of a list of replacement rules.";
GHPBianchiRules::usage="GHPBianchiRules[Dyad] gives a the GHP Bianchi equations in the form of a list of replacement rules.";
DyadExpansionEq::usage="DyadExpansionEq[T, Dyad] gives an equation for the tensor T[inds] expanded in the dyad Dyad. The GHPWeightOf the componets are set and SetTexComponents is called.";
ToGHP::usage="ToGHP[expr,Dyad] tries to expand expr in the dyad and transform all fundamental spinor operators and covariant derivatives into GHP operators. GHPComponentRules is used recursively.";
ToNP::usage="ToNP[expr,Dyad] tries to expand expr in the dyad and transform all covariant derivatives into NP operators. NPComponentRules is used recursively.";
DyadComponents::usage="DyadComponents[expr,Dyad] gives a list of independent dyad components of expr.";
$GHPExtraRules::usage="$GHPExtraRules is a user defined list of extra rules used for the conversion of an expression into GHP formalism.";
$NPExtraRules::usage="$NPExtraRules is a user defined list of extra rules used for the conversion of an expression into NP formalism.";
GHPComponentRules::usage="GHPComponentRules[T,Dyad] gives a list of component values for the spinor T. If T consists of a fundamental spinor operator or CovarD object, this is expressed in terms of GHP derivative operators. The user can also set GHPComponentRules[T,Dyad] to a suitable list of component rules.";
NPComponentRules::usage="NPComponentRules[T,Dyad] gives a list of component values for the spinor T. If T consists of a CovarD object, this is expressed in terms of NP derivative operators. The user can also set NPComponentRules[T,Dyad] to a suitable list of component rules.";
NPToGHPRules::usage="NPToGHPRules[Dyad] contains a list of rules that converts the NP differential operators to GHP operators. Waring: This can only be used on first order expressions because the conversion is done from the outside in and the GHP weight of the NP operators are not correct.";
GHPToNPRules::usage="NPToGHPRules[Dyad] contains a list of rules that converts the NP differential operators to GHP operators.";
InertScalarOp::usage="InertScalarOp[x,F[x]][expr] gives an inert form of F[expr] which can be printed using TexPrint. To expand it, use InsertScalarOp -> Function";
SymbolFormattingFunction::usage="SymbolFormattingFunction is an option for DefNPTetrad and DefSpinDyad giving a function that transforms the formatting of the symbols.";
SymbolTexFunction::usage="SymbolTexFunction is an option for DefNPTetrad and DefSpinDyad giving a function that transforms the Tex formatting of the symbols.";
DyadComponentByNumber::usage="DyadComponentByNumber[T,{i,j}, Dyad] gives the component with i iotas and j iota' in the symmetric spinor T. Observe that we assume that SlotsOfTensor only have down spinor indices.";
$DyadCalcInfo::usage="$DyadCalcInfo=False turns off messages from Dyad calculations.";

1.6. Begin private

Begin["`Private`"]

"xAct`SpinFrames`Private`"

The reserved words in the current version:

Names["xAct`SpinFrames`*"]

%//Length

$ContextPath

{"Utilities`ShowTime`","xAct`SpinFrames`","xAct`SymManipulator`","xAct`TexAct`","xAct`xCoba`","xAct`Spinors`","xAct`xTensor`","xAct`xPerm`","xAct`xCore`","System`"}

$Context

"xAct`SpinFrames`Private`"

2. General tools

2.1. Printing

PrintDaggerAsBar[T_?xTensorQ]:=With[{dgT=Dagger[T]},PrintAs[dgT]^=Overline@PrintAs@T]

2.2. AutocanonicalizeComponents

AutocanonicalizeComponents[T_?xTensorQ[inds___]]:=Module[{comps=Flatten[ComponentArray[T[inds]]],canonicalrules,unchanged},
canonicalrules=Rule[#,ToCanonical@#]&/@comps;
unchanged=SameQ@@@canonicalrules;
Pick[canonicalrules,Not/@unchanged]/.Rule->(TagSet[T,#1,#2]&);];

2.3. Extracting independent components

IndependentComponents[T_?xTensorQ[inds___]]:=Module[{comps=Flatten[ComponentArray[T[inds]]],canonicalrules},
canonicalrules=Rule[#,ToCanonical@#]&/@comps;
First/@Pick[canonicalrules,SameQ@@@canonicalrules]]

2.4. MakeSimpleRule

RemoveSignFromEq[-x_==y_]:=x==-y;
RemoveSignFromEq[x_==y_]:=x==y;
RemoveSignFromEq[-x_->y_]:=x->-y;
RemoveSignFromEq[x_->y_]:=x->y;
RemoveSignFromEq[x_]:=x;

MakeSimpleRule[{LHS_,RHS_,conditions___},options___]:=With[{HeldLHS=Hold[LHS],HeldRHS=Hold[RHS]},
Module[{
(* Unblocked indices *)
indsLHS=List@@xAct`xTensor`Private`TakeEIndices[FindIndices[HeldLHS]],
freesLHS=List@@xAct`xTensor`Private`TakeEIndices[FindFreeIndices[HeldLHS]],
dirinds=List@@Select[FindIndices[HeldLHS],DIndexQ],
verb,
indsLHSinfo,
rulesLHS,
(*newHeldLHS=xAct`xTensor`Private`ReplaceIsolated[HeldLHS],
newHeldRHS=ReplaceDummies[HeldRHS],*)
rules,conds},

(* Options *)
{verb}={Verbose}/.CheckOptions[options]/.Options[MakeRule];

(**** B. Construct indsLHSinfo ****)
(* 0. Convert LHS inds to names *)
indsLHS=xAct`xTensor`Private`IndexName/@indsLHS;
freesLHS=xAct`xTensor`Private`IndexName/@freesLHS;

(* 1. Name of index in input rule *)
indsLHSinfo=Partition[indsLHS,1];

(* 2. Free character *)
indsLHSinfo=Append[#,MemberQ[freesLHS,First@#]]&/@indsLHSinfo;

(* 3. MetricOn. up/down character is corrected *)
indsLHSinfo=Append[#,MetricEndowedQ@VBundleOfIndex@First@#]&/@indsLHSinfo;

(* 4. TestIndices *)
indsLHSinfo=Append[#,True]&/@indsLHSinfo;

(* 5. Pattern character in final rule. up/down character in patindsLHS is corrected *)
indsLHSinfo=Append[#,True]&/@indsLHSinfo;

(* 6. Name in final rule. Currently we do not change names *)
indsLHSinfo=Append[#,First@#]&/@indsLHSinfo;
If[verb,Print["indsLHSinfo: ",indsLHSinfo]];
If[verb,Print["dirinds:", dirinds]];
(* 7. Final rules for LHS indices *)
rulesLHS=Join[(xAct`xTensor`Private`FormatIndexRule/@indsLHSinfo),FormatDirRule/@dirinds]/.{xAct`xTensor`Private`patternTest->PatternTest,xAct`xTensor`Private`pattern->Pattern};
If[verb,Print["rulesLHS: ",rulesLHS]];

(**** C. Construct rules ****)

(* 3. Construct rules *)
rules={Rule[HeldLHS,HeldRHS]};
If[verb,Print["rules: ",InputForm[rules]]];

(* 4. Replace indices *)
rules=rules/.Rule[lhs_Hold,rhs_Hold]:>Rule[ReplaceIndex[lhs,rulesLHS],rhs];
If[verb,Print["rules after pattern: ",rules]];

(* 5. Add Module on the RHS *)
rules=rules/.Rule->IndexRule;

(* 6. Add conditions *)
conds=Hold[conditions];
If[verb,Print["Conditions: ",conds]];
rules=(xAct`xTensor`Private`addconditions[#,conds]&/@rules)/.Hold[cond_]->cond;

(* 7. Return rules *)
ScreenDollarIndices@rules
]
]

2.5 Extracting dyad component by number

DyadComponentByNumber[T_?xTensorQ,{i_,j_},dyad_]:=Module[{k=Length@Cases[UpIndex /@ SlotsOfTensor[T], VBundleOfBasis[dyad]],l=Length@Cases[UpIndex /@ SlotsOfTensor[T], Dagger@VBundleOfBasis[dyad]]},PlaceIndicesInTensor[T,Join[Table[{0,-dyad},k-i],Table[{1,-dyad},i],Table[{0,-Dagger@dyad},l-j],Table[{1,-Dagger@dyad},j]]]]/;CompatibleSymQ[SlotsOfTensor[T],SymmetryGroupOfTensor@T,{VBundleOfBasis[dyad],Dagger@VBundleOfBasis[dyad]}]

3. Definition of NP tetrad, spin dyad and operators

3.1. NP tetrad

TetradToBasisRules[_]={};
BasisToTetradRules[_]={};

Options[DefNPTetrad]={SymbolFormattingFunction->Identity,SymbolTexFunction->Identity,BasisColor->RGBColor[0,0,1]};

DefNPTetrad[tetrad_,{lnp_[a_],nnp_[a_],mnp_[a_]},options:OptionsPattern[]]:=Module[{tangentvb=VBundleOfIndex@a,mfd=BaseOfVBundle@VBundleOfIndex@a, metric=First@MetricsOfVBundle@VBundleOfIndex@a,mnpdg,pdnp,symbform=OptionValue[SymbolFormattingFunction],texform=OptionValue[SymbolTexFunction]},
If[Not@xTensorQ[lnp],DefTensor[lnp[a],mfd,PrintAs->symbform@"l"]];
If[Not@xTensorQ[nnp],DefTensor[nnp[a],mfd,PrintAs->symbform@"n"]];
If[Not@xTensorQ[mnp],DefTensor[mnp[a],mfd,Dagger->Complex,PrintAs->symbform@"m"]];
mnpdg=Dagger@mnp;
PrintDaggerAsBar@mnp;
DefBasis[tetrad,tangentvb,{1,2,3,4},BasisColor->OptionValue[BasisColor]];
SetDaggerMatrix[tetrad,{{1,0,0,0},{0,1,0,0},{0,0,0,1},{0,0,1,0}}];
(* Formatting. Observe that we only only format the PDNP derivative, not the CDe derivative. *)
pdnp=PDOfBasis@tetrad;
VectorsOfTetrad[tetrad]^={lnp,nnp,mnp,mnpdg};
xTensorFormStop[];
FormatBasis[pdnp[{1,-tetrad}],symbform@"D"];
FormatBasis[pdnp[{2,-tetrad}],symbform@"Δ"];
FormatBasis[pdnp[{3,-tetrad}],symbform@"δ"];
FormatBasis[pdnp[{4,-tetrad}],symbform@"(OverBar[δ])"];
xTensorFormStart[];
FormatTexBasis[pdnp[{1,-tetrad}],StringJoin[texform@"D"," "]];
FormatTexBasis[pdnp[{2,-tetrad}],StringJoin[texform@"\\Delta"," "]];
FormatTexBasis[pdnp[{3,-tetrad}],StringJoin[texform@"\\delta"," "]];
FormatTexBasis[pdnp[{4,-tetrad}],StringJoin[texform@"\\bar\\delta"," "]];
(* Transformation between Basis and Tetrad *)
SetToRule@metric;
MetricInBasis[metric,tetrad,{{0,1,0,0},{1,0,0,0},{0,0,0,-1},{0,0,-1,0}}];
MetricInBasis[metric,-tetrad,{{0,1,0,0},{1,0,0,0},{0,0,0,-1},{0,0,-1,0}}];
RuleToSet@metric;
SetToRule/@{lnp,nnp,mnp,mnpdg};
AllComponentValues[lnp[{a, tetrad}] , Basis[{1, -tetrad}, {a, tetrad}]];
AllComponentValues[nnp[{a, tetrad}] , Basis[{2, -tetrad}, {a, tetrad}]];
AllComponentValues[mnp[{a, tetrad}] , Basis[{3, -tetrad}, {a, tetrad}]];
AllComponentValues[mnpdg[{a, tetrad}] , Basis[{4, -tetrad}, {a, tetrad}]];
AllComponentValues[lnp[{-a, -tetrad}] ,{0,1,0,0}];
AllComponentValues[nnp[{-a, -tetrad}] ,{1,0,0,0}];
AllComponentValues[mnp[{-a, -tetrad}] ,{0,0,0,-1}];
AllComponentValues[mnpdg[{-a, -tetrad}] ,{0,0,-1,0}];
RuleToSet/@{lnp,nnp,mnp,mnpdg};
TetradToBasisRules[tetrad]^=Flatten[MakeRule[Evaluate[#],UseSymmetries->False,MetricOn->None,ContractMetrics->False]&/@{{lnp[a],Basis[{1,-tetrad},a]},{nnp[a],Basis[{2,-tetrad},a]},{mnp[a],Basis[{3,-tetrad},a]},{mnpdg[a],Basis[{4,-tetrad},a]},{lnp[-a],Basis[-a,{2,tetrad}]},{nnp[-a],Basis[-a,{1,tetrad}]},{mnp[-a],-Basis[-a,{4,tetrad}]},{mnpdg[-a],-Basis[-a,{3,tetrad}]}}];
BasisToTetradRules[tetrad]^=Flatten[MakeRule[Evaluate[#],UseSymmetries->False,MetricOn->None,ContractMetrics->False]&/@{{Basis[{1,-tetrad},a],lnp[a]},{Basis[{2,-tetrad},a],nnp[a]},{Basis[{3,-tetrad},a],mnp[a]},{Basis[{4,-tetrad},a],mnpdg[a]},{Basis[-a,{1,tetrad}],nnp[-a]},{Basis[-a,{2,tetrad}],lnp[-a]},{Basis[-a,{3,tetrad}],-mnpdg[-a]},{Basis[-a,{4,tetrad}],-mnp[-a]}}];
];

3.2. Spin Dyad

DyadToBasisRules[_]={};
BasisToDyadRules[_]={};
TetradToDyadRules[_]={};
CovDDyadRules[_]={};
NPToGHPSpinCoeffs[_]={};
GHPToNPSpinCoeffs[_]={};
CovDNPSpinCoeffRules[_]={};
TetradSigmaRules[_]={};

NPSpinCoefficients[dyad_]:=SymbolJoin[#,dyad][]&/@{"α","β","γ","ϵ","κ","λ","μ","ν","π","ρ","σ","τ"};

GHPSpinCoefficients[dyad_]:=SymbolJoin[#,dyad][]&/@{"κ","ρ","σ","τ","κp","ρp","σp","τp"};

Options[DefSpinDyad]={SymbolFormattingFunction->Identity,SymbolTexFunction->Identity,BasisColor->RGBColor[1,0,0]};

DefSpinDyad[dyad_,{omicron_[Ai_], iota_[Ai_]},tetrad_,options:OptionsPattern[]]:=Module[{spin=VBundleOfIndex@Ai, mfd=BaseOfVBundle@VBundleOfIndex@Ai, A,B, C, D,Adg, Bdg,dyaddg, eps=First@MetricsOfVBundle@VBundleOfIndex@Ai,epsdg,omicrondg, iotadg, sigma=SolderingFormOfVBundle@VBundleOfIndex@Ai,a,b,c,lnp,nnp,mnp,mnpdg,spincoeffnames,tmprules,cde=CovDOfMetric@First@MetricsOfVBundle@VBundleOfIndex@Ai,pddyad,pdnp,achristoffelcdepddyad,christoffelcdepdnp,tetradtodyadeqs,ExtraGHPspincoeffnames,tmpeqs,symbform=OptionValue[SymbolFormattingFunction],texform=OptionValue[SymbolTexFunction]},
epsdg=Dagger@eps;
{A,B, C, D}=Take[First@IndicesOfVBundle@spin,4];
{a,b,c}=Take[First@IndicesOfVBundle@VBundleOfBasis@tetrad,3];
Adg=DaggerIndex@A;
Bdg=DaggerIndex@B;
(* Spin Dyad *)
If[Not@xTensorQ[omicron],DefSpinor[omicron[A],mfd]];
If[Not@xTensorQ[iota],DefSpinor[iota[A],mfd]];
PrintAs[omicron]^=symbform["o"];
PrintAs[iota]^=symbform["ι"];
PrintDaggerAsBar/@{omicron,iota};
omicrondg=Dagger@omicron;
iotadg=Dagger@iota;
DefBasis[dyad,spin,{0,1},BasisColor->OptionValue[BasisColor],Dagger->Complex];
SpinorsOfDyad[dyad]^={omicron,iota};
dyaddg=Dagger@dyad;
TetradOfDyad[dyad]^=tetrad;
Evaluate[dyad]/:CIndexForm[i_Integer,dyad]:=symbform@ToString[i];
Evaluate[dyaddg]/:CIndexForm[i_Integer,dyaddg]:=StringJoin[symbform@ToString[i],"'"];
SetToRule/@{eps,epsdg};
MetricInBasis[eps,dyad,{{0,1},{-1,0}}];
MetricInBasis[eps,-dyad,{{0,1},{-1,0}}];
MetricInBasis[epsdg,dyaddg,{{0,1},{-1,0}}];
MetricInBasis[epsdg,-dyaddg,{{0,1},{-1,0}}];
RuleToSet/@{eps,epsdg};
SetToRule/@{omicron, iota, omicrondg,iotadg};
AllComponentValues[omicrondg[{Adg,dyaddg}],{1,0}];
AllComponentValues[iotadg[{Adg,dyaddg}],{0,1}];
AllComponentValues[omicron[{A,dyad}],{1,0}];
AllComponentValues[iota[{A,dyad}],{0,1}];
AllComponentValues[omicrondg[{-Adg,-dyaddg}],{0,1}];
AllComponentValues[iotadg[{-Adg,-dyaddg}],{-1,0}];
AllComponentValues[omicron[{-A,-dyad}],{0,1}];
AllComponentValues[iota[{-A,-dyad}],{-1,0}];
RuleToSet/@{omicron, iota, omicrondg,iotadg};
AutomaticRules[omicron,MakeRule[{omicron[-A]*iota[A] , 1},MetricOn->All,ContractMetrics->True]];
AutomaticRules[Evaluate[omicrondg],MakeRule[{Evaluate[omicrondg[-Adg]*iotadg[Adg]] , 1},MetricOn->All,ContractMetrics->True]];
If[Evaluate[omicron[-A]*omicron[A]]=!=0,AutomaticRules[omicron,MakeRule[{omicron[-A]*omicron[A] , 0},MetricOn->None,ContractMetrics->False,UseSymmetries->False]]];
If[Evaluate[iota[-A]*iota[A]]=!=0,AutomaticRules[iota,MakeRule[{iota[-A]*iota[A] , 0},MetricOn->None,ContractMetrics->False,UseSymmetries->False]]];
If[Evaluate[omicrondg[-Adg]*omicrondg[Adg]]=!=0,AutomaticRules[Evaluate[omicrondg],MakeRule[{Evaluate[omicrondg[-Adg]*omicrondg[Adg]] , 0},MetricOn->None,ContractMetrics->False,UseSymmetries->False]]];
If[Evaluate[iotadg[-Adg]*iotadg[Adg]]=!=0,AutomaticRules[Evaluate[iotadg],MakeRule[{Evaluate[iotadg[-Adg]*iotadg[Adg]] , 0},MetricOn->None,ContractMetrics->False,UseSymmetries->False]]];
DyadToBasisRules[dyad]^=Flatten[MakeRule[#,UseSymmetries->False,MetricOn->None]&/@{{omicron[A],Basis[{0,-dyad},A]},{iota[A],Basis[{1,-dyad},A]},{omicrondg[Adg],Basis[{0,-dyaddg},Adg]},{iotadg[Adg],Basis[{1,-dyaddg},Adg]},{omicron[-A],Basis[-A,{1,dyad}]},{iota[-A],-Basis[-A,{0,dyad}]},{omicrondg[-Adg],Basis[-Adg,{1,dyaddg}]},{iotadg[-Adg],-Basis[-Adg,{0,dyaddg}]}}];
BasisToDyadRules[dyad]^=Flatten[MakeRule[#,UseSymmetries->False,MetricOn->None]&/@{{Basis[{0,-dyad},A],omicron[A]},{Basis[{1,-dyad},A],iota[A]},{Basis[{0,-dyaddg},Adg],omicrondg[Adg]},{Basis[{1,-dyaddg},Adg],iotadg[Adg]},{Basis[-A,{1,dyad}],omicron[-A]},{Basis[-A,{0,dyad}],-iota[-A]},{Basis[-Adg,{1,dyaddg}],omicrondg[-Adg]},{Basis[-Adg,{0,dyaddg}],-iotadg[-Adg]}}];
(* Relation between tetrad and dyad *)
SetToRule@sigma;
{lnp,nnp,mnp,mnpdg}=VectorsOfTetrad[tetrad];
{sigma[{1,tetrad},{0,-dyad},{0,-dyaddg}]==1,sigma[{2,tetrad},{0,-dyad},{0,-dyaddg}]==0,sigma[{3,tetrad},{0,-dyad},{0,-dyaddg}]==0,sigma[{4,tetrad},{0,-dyad},{0,-dyaddg}]==0,sigma[{1,tetrad},{1,-dyad},{1,-dyaddg}]==0,sigma[{2,tetrad},{1,-dyad},{1,-dyaddg}]==1,sigma[{3,tetrad},{1,-dyad},{1,-dyaddg}]==0,sigma[{4,tetrad},{1,-dyad},{1,-dyaddg}]==0,sigma[{1,tetrad},{0,-dyad},{1,-dyaddg}]==0,sigma[{2,tetrad},{0,-dyad},{1,-dyaddg}]==0,sigma[{3,tetrad},{0,-dyad},{1,-dyaddg}]==1,sigma[{4,tetrad},{0,-dyad},{1,-dyaddg}]==0,sigma[{1,tetrad},{1,-dyad},{0,-dyaddg}]==0,sigma[{2,tetrad},{1,-dyad},{0,-dyaddg}]==0,sigma[{3,tetrad},{1,-dyad},{0,-dyaddg}]==0,sigma[{4,tetrad},{1,-dyad},{0,-dyaddg}]==1,sigma[{1,-tetrad},{0,dyad},{0,dyaddg}]==1,sigma[{1,-tetrad},{0,dyad},{1,dyaddg}]==0,sigma[{1,-tetrad},{1,dyad},{0,dyaddg}]==0,sigma[{1,-tetrad},{1,dyad},{1,dyaddg}]==0,sigma[{2,-tetrad},{0,dyad},{0,dyaddg}]==0,sigma[{2,-tetrad},{0,dyad},{1,dyaddg}]==0,sigma[{2,-tetrad},{1,dyad},{0,dyaddg}]==0,sigma[{2,-tetrad},{1,dyad},{1,dyaddg}]==1,sigma[{3,-tetrad},{0,dyad},{0,dyaddg}]==0,sigma[{3,-tetrad},{0,dyad},{1,dyaddg}]==1,sigma[{3,-tetrad},{1,dyad},{0,dyaddg}]==0,sigma[{3,-tetrad},{1,dyad},{1,dyaddg}]==0,sigma[{4,-tetrad},{0,dyad},{0,dyaddg}]==0,sigma[{4,-tetrad},{0,dyad},{1,dyaddg}]==0,sigma[{4,-tetrad},{1,dyad},{0,dyaddg}]==1,sigma[{4,-tetrad},{1,dyad},{1,dyaddg}]==0}/.Equal->ComponentValue;
RuleToSet@sigma;
tetradtodyadeqs={lnp[a]==omicron[A]*omicrondg[Adg]*sigma[a,-A,-Adg],nnp[a]==iota[A]*iotadg[Adg]*sigma[a,-A,-Adg],mnp[a]==iotadg[Adg]*omicron[A]*sigma[a,-A,-Adg],mnpdg[a]==iota[A]*omicrondg[Adg]*sigma[a,-A,-Adg]};
TetradToDyadRules[tetrad]^=Flatten[MakeRule[#,MetricOn->All,ContractMetrics->True]&/@List@@@tetradtodyadeqs];
(* TetradSigmaRules *)
tmpeqs={sigma[{1,tetrad},-A,-Adg]==iota[-A] Dagger[iota][-Adg],sigma[{2,tetrad},-A,-Adg]==omicron[-A] Dagger[omicron][-Adg],sigma[{3,tetrad},-A,-Adg]==-Dagger[omicron][-Adg] iota[-A],sigma[{4,tetrad},-A,-Adg]==-omicron[-A] Dagger[iota][-Adg]};
TetradSigmaRules[tetrad]^=Flatten[MakeRule[#,MetricOn->All,ContractMetrics->True]&/@List@@@tmpeqs];
(* Spin coefficients and Christoffel symbols dyad *)
pddyad=PDOfBasis@dyad;
spincoeffnames=Head/@NPSpinCoefficients[dyad];
ExtraGHPspincoeffnames=Head/@Take[GHPSpinCoefficients[dyad],-4];
(DefSpinor[SymbolJoin[#,dyad][],mfd,PrintAs->symbform@#];Tex[SymbolJoin[#,dyad]]^=texform@Tex[#];
Tex[Dagger@SymbolJoin[#,dyad]]^=TexBar@texform@Tex[#];)&/@{"α","β","γ","ϵ","κ","λ","μ","ν","π","ρ","σ","τ"};
DefSpinor[SymbolJoin["τp",dyad][],mfd,PrintAs->symbform@"τ"<>"'"];
DefSpinor[SymbolJoin["σp",dyad][],mfd,PrintAs->symbform@"σ"<>"'"];
DefSpinor[SymbolJoin["ρp",dyad][],mfd,PrintAs->symbform@"ρ"<>"'"];
DefSpinor[SymbolJoin["κp",dyad][],mfd,PrintAs->symbform@"κ"<>"'"];
Tex[Evaluate@SymbolJoin["τp",dyad]]^=(texform@Tex@"τ")<>"'";
Tex[Evaluate@SymbolJoin["σp",dyad]]^=(texform@Tex@"σ")<>"'";
Tex[Evaluate@SymbolJoin["ρp",dyad]]^=(texform@Tex@"ρ")<>"'";
Tex[Evaluate@SymbolJoin["κp",dyad]]^=(texform@Tex@"κ")<>"'";
PrintAs[Evaluate@Dagger@SymbolJoin["τp",dyad]]^=Overline[symbform@"τ"]<>"'";
PrintAs[Evaluate@Dagger@SymbolJoin["σp",dyad]]^=Overline[symbform@"σ"]<>"'";
PrintAs[Evaluate@Dagger@SymbolJoin["ρp",dyad]]^=Overline[symbform@"ρ"]<>"'";
PrintAs[Evaluate@Dagger@SymbolJoin["κp",dyad]]^=Overline[symbform@"κ"]<>"'";
Tex[Evaluate@Dagger@SymbolJoin["τp",dyad]]^=TexBar[texform@Tex@"τ"]<>"'";
Tex[Evaluate@Dagger@SymbolJoin["σp",dyad]]^=TexBar[texform@Tex@"σ"]<>"'";
Tex[Evaluate@Dagger@SymbolJoin["ρp",dyad]]^=TexBar[texform@Tex@"ρ"]<>"'";
Tex[Evaluate@Dagger@SymbolJoin["κp",dyad]]^=TexBar[texform@Tex@"κ"]<>"'";
PrintDaggerAsBar/@spincoeffnames;
FormatComponents[dyad,SS_?xTensorQ]^:=FormatComponents[dyad,SS,symbform];
SetTexComponents[dyad,SS_?xTensorQ]^:=SetTexComponents[dyad,SS,texform];
(* GHP weights of the spin coefficients *)
(GHPWeightOf[Evaluate[#[[1]]]]^=#[[2]])&/@Thread[{NPSpinCoefficients[dyad][[#]]&/@Range[5,12],{{3,1},{-3,1},{-1,-1},{-3,-1},{-1,1},{1,1},{3,-1},{1,-1}}}];
(GHPWeightOf[Evaluate[#[[1]]]]^=#[[2]])&/@Thread[{Take[GHPSpinCoefficients[dyad],-4],{{-3,-1},{-1,-1},{-3,1},{-1,1}}}];
UpSet[GHPWeightOf@#,Reverse@GHPWeightOf@Dagger@#]&/@(Dagger/@Join[NPSpinCoefficients[dyad][[#]]&/@Range[5,12],Take[GHPSpinCoefficients[dyad],-4]]);
(* *)
NPToGHPSpinCoeffs[dyad]^={NPSpinCoefficients[dyad][[6]]->-GHPSpinCoefficients[dyad][[7]],NPSpinCoefficients[dyad][[7]]->-GHPSpinCoefficients[dyad][[6]],NPSpinCoefficients[dyad][[8]]->-GHPSpinCoefficients[dyad][[5]],NPSpinCoefficients[dyad][[9]]->-GHPSpinCoefficients[dyad][[8]],Dagger@NPSpinCoefficients[dyad][[6]]->-Dagger@GHPSpinCoefficients[dyad][[7]],Dagger@NPSpinCoefficients[dyad][[7]]->-Dagger@GHPSpinCoefficients[dyad][[6]],Dagger@NPSpinCoefficients[dyad][[8]]->-Dagger@GHPSpinCoefficients[dyad][[5]],Dagger@NPSpinCoefficients[dyad][[9]]->-Dagger@GHPSpinCoefficients[dyad][[8]]};
GHPToNPSpinCoeffs[dyad]^={GHPSpinCoefficients[dyad][[7]]->-NPSpinCoefficients[dyad][[6]],GHPSpinCoefficients[dyad][[6]]->-NPSpinCoefficients[dyad][[7]],GHPSpinCoefficients[dyad][[5]]->-NPSpinCoefficients[dyad][[8]],GHPSpinCoefficients[dyad][[8]]->-NPSpinCoefficients[dyad][[9]],Dagger@GHPSpinCoefficients[dyad][[7]]->-Dagger@NPSpinCoefficients[dyad][[6]],Dagger@GHPSpinCoefficients[dyad][[6]]->-Dagger@NPSpinCoefficients[dyad][[7]],Dagger@GHPSpinCoefficients[dyad][[5]]->-Dagger@NPSpinCoefficients[dyad][[8]],Dagger@GHPSpinCoefficients[dyad][[8]]->-Dagger@NPSpinCoefficients[dyad][[9]]};
(* *)
achristoffelcdepddyad=Head@AChristoffel[cde,pddyad][{0,dyaddg},{1,-tetrad},{0,-dyaddg}];
tmprules=Evaluate[{AChristoffel[cde,pddyad][{0,dyad},{1,-tetrad},{0,-dyad}]->spincoeffnames[[4]][],
AChristoffel[cde,pddyad][{0,dyad},{1,-tetrad},{1,-dyad}]->spincoeffnames[[9]][],
AChristoffel[cde,pddyad][{0,dyad},{2,-tetrad},{0,-dyad}]->spincoeffnames[[3]][],AChristoffel[cde,pddyad][{0,dyad},{2,-tetrad},{1,-dyad}]->spincoeffnames[[8]][],AChristoffel[cde,pddyad][{0,dyad},{3,-tetrad},{0,-dyad}]->spincoeffnames[[2]][],AChristoffel[cde,pddyad][{0,dyad},{3,-tetrad},{1,-dyad}]->spincoeffnames[[7]][],AChristoffel[cde,pddyad][{0,dyad},{4,-tetrad},{0,-dyad}]->spincoeffnames[[1]][],AChristoffel[cde,pddyad][{0,dyad},{4,-tetrad},{1,-dyad}]->spincoeffnames[[6]][],AChristoffel[cde,pddyad][{1,dyad},{1,-tetrad},{0,-dyad}]->-spincoeffnames[[5]][],
AChristoffel[cde,pddyad][{1,dyad},{1,-tetrad},{1,-dyad}]->-spincoeffnames[[4]][],
AChristoffel[cde,pddyad][{1,dyad},{2,-tetrad},{0,-dyad}]->-spincoeffnames[[12]][],AChristoffel[cde,pddyad][{1,dyad},{2,-tetrad},{1,-dyad}]->-spincoeffnames[[3]][],AChristoffel[cde,pddyad][{1,dyad},{3,-tetrad},{0,-dyad}]->-spincoeffnames[[11]][],AChristoffel[cde,pddyad][{1,dyad},{3,-tetrad},{1,-dyad}]->-spincoeffnames[[2]][],AChristoffel[cde,pddyad][{1,dyad},{4,-tetrad},{0,-dyad}]->-spincoeffnames[[10]][],AChristoffel[cde,pddyad][{1,dyad},{4,-tetrad},{1,-dyad}]->-spincoeffnames[[1]][]}];
Map[Dagger,tmprules,{2}]/.Rule->ComponentValue;
tmprules/.Rule->ComponentValue;
RuleToSet@Evaluate@achristoffelcdepddyad;
RuleToSet@Evaluate@Dagger@achristoffelcdepddyad;
tmprules={cde[-A,-Adg][omicron[-B]]==-(iotadg[-Adg]*omicron[-A]*omicron[-B]*spincoeffnames[[1]][])-iota[-A]*omicron[-B]*omicrondg[-Adg]*spincoeffnames[[2]][]+omicron[-A]*omicron[-B]*omicrondg[-Adg]*spincoeffnames[[3]][]+iota[-A]*iotadg[-Adg]*omicron[-B]*spincoeffnames[[4]][]-iota[-A]*iota[-B]*iotadg[-Adg]*spincoeffnames[[5]][]+iota[-B]*iotadg[-Adg]*omicron[-A]*spincoeffnames[[10]][]+iota[-A]*iota[-B]*omicrondg[-Adg]*spincoeffnames[[11]][]-iota[-B]*omicron[-A]*omicrondg[-Adg]*spincoeffnames[[12]][],cde[-A,-Adg][iota[-B]]==iota[-B]*iotadg[-Adg]*omicron[-A]*spincoeffnames[[1]][]+iota[-A]*iota[-B]*omicrondg[-Adg]*spincoeffnames[[2]][]-iota[-B]*omicron[-A]*omicrondg[-Adg]*spincoeffnames[[3]][]-iota[-A]*iota[-B]*iotadg[-Adg]*spincoeffnames[[4]][]-iotadg[-Adg]*omicron[-A]*omicron[-B]*spincoeffnames[[6]][]-iota[-A]*omicron[-B]*omicrondg[-Adg]*spincoeffnames[[7]][]+omicron[-A]*omicron[-B]*omicrondg[-Adg]*spincoeffnames[[8]][]+iota[-A]*iotadg[-Adg]*omicron[-B]*spincoeffnames[[9]][]};
CovDDyadRules[dyad]^=Flatten[MakeRule[Evaluate[List@@#],MetricOn->All,ContractMetrics->True]&/@Join[tmprules,Map[Dagger,tmprules,{2}]]];
(* Christoffel symbols pdnp *)
pdnp=PDOfBasis@tetrad;
christoffelcdepdnp=Head@Christoffel[cde,pdnp][{1,tetrad},{1,-tetrad},{1,-tetrad}];
Flatten@ComponentArray@Map[TraceBasisDummy[ToBasis[dyaddg]@ToBasis[dyad]@ToBasis[tetrad]@ToBasis[tetrad]@cde[-b][#]/.cde->pdnp]&,tetradtodyadeqs,{2}]/.Equal->ComponentValue;
RuleToSet@christoffelcdepdnp;
(* Torsion *)
AllComponentValues@ToBasis[tetrad]@Torsion[pdnp][a,-b,-c];
IndependentComponents[Torsion[pdnp][{a,tetrad},{-b,-tetrad},{-c,-tetrad}]]/.Torsion[pdnp][{aa_Integer,tetrad},{ab_Integer,-tetrad},{ac_Integer,-tetrad}]:>ComponentValue[Torsion[pdnp][{aa,tetrad},{ab,-tetrad},{ac,-tetrad}],$TorsionSign*(-christoffelcdepdnp[{aa,tetrad},{ab,-tetrad},{ac,-tetrad}]+christoffelcdepdnp[{aa,tetrad},{ac,-tetrad},{ab,-tetrad}])];
RuleToSet[Torsion[pdnp]];
(* Curvature *)
DefSpinor[SymbolJoin["Psi",cde,ToString[#],dyad][],mfd,PrintAs->StringJoin["\!","\(Ψ\_\(",symbform@ToString[#],"\)\)"],PrintDaggerAs->StringJoin["\!","\(\(Ψ\&_\)\_\(",symbform@ToString[#],"\)\)"]]&/@Range[0,4];
(Tex[Evaluate[SymbolJoin["Psi",cde,ToString[#],dyad]]]^="\\Psi_{"<>texform@ToString[#]<>"}")&/@Range[0,4];
(Tex[Evaluate[Dagger@SymbolJoin["Psi",cde,ToString[#],dyad]]]^="\\bar\\Psi_{"<>texform@ToString[#]<>"}")&/@Range[0,4];
DefSpinor[SymbolJoin["Phi",cde,#,dyad][],mfd,PrintAs->StringJoin["\!","\(Φ\_\(",symbform@StringTake[#,1],symbform@StringDrop[#,1],"'\)\)"],PrintDaggerAs->StringJoin["\!","\(\(Φ\&_\)\_\(",symbform@StringTake[#,1],symbform@StringDrop[#,1],"'\)\)"]]&/@{"00","01","02","10","11","12","20","21","22"};
(Tex[Evaluate[SymbolJoin["Phi",cde,ToString[#],dyad]]]^="\\Phi_{"<>texform@StringTake[#,1]<>texform@StringDrop[#,1]<>"'}")&/@{"00","01","02","10","11","12","20","21","22"};
(Tex[Evaluate[Dagger@SymbolJoin["Phi",cde,ToString[#],dyad]]]^="\\bar\\Phi_{"<>texform@StringTake[#,1]<>texform@StringDrop[#,1]<>"'}")&/@{"00","01","02","10","11","12","20","21","22"};
{GHPWeightOf@Evaluate@SymbolJoin["Psi",cde,"0",dyad][]^={4,0},GHPWeightOf@Evaluate@SymbolJoin["Psi",cde,"1",dyad][]^={2,0},GHPWeightOf@Evaluate@SymbolJoin["Psi",cde,"2",dyad][]^={0,0},GHPWeightOf@Evaluate@SymbolJoin["Psi",cde,"3",dyad][]^={-2,0},GHPWeightOf@Evaluate@SymbolJoin["Psi",cde,"4",dyad][]^={-4,0},GHPWeightOf@Evaluate@Dagger@SymbolJoin["Psi",cde,"0",dyad][]^={0,4},GHPWeightOf@Evaluate@Dagger@SymbolJoin["Psi",cde,"1",dyad][]^={0,2},GHPWeightOf@Evaluate@Dagger@SymbolJoin["Psi",cde,"2",dyad][]^={0,0},GHPWeightOf@Evaluate@Dagger@SymbolJoin["Psi",cde,"3",dyad][]^={0,-2},GHPWeightOf@Evaluate@Dagger@SymbolJoin["Psi",cde,"4",dyad][]^={0,-4},GHPWeightOf@Evaluate@SymbolJoin["Phi",cde,"00",dyad][]^={2,2},
GHPWeightOf@Evaluate@SymbolJoin["Phi",cde,"10",dyad][]^={0,2},
GHPWeightOf@Evaluate@SymbolJoin["Phi",cde,"01",dyad][]^={2,0},
GHPWeightOf@Evaluate@SymbolJoin["Phi",cde,"11",dyad][]^={0,0},
GHPWeightOf@Evaluate@SymbolJoin["Phi",cde,"20",dyad][]^={-2,2},GHPWeightOf@Evaluate@SymbolJoin["Phi",cde,"21",dyad][]^={-2,0},GHPWeightOf@Evaluate@SymbolJoin["Phi",cde,"02",dyad][]^={2,-2},GHPWeightOf@Evaluate@SymbolJoin["Phi",cde,"12",dyad][]^={0,-2},GHPWeightOf@Evaluate@SymbolJoin["Phi",cde,"22",dyad][]^={-2,-2}
};
(* Make sure that the curvature is not formated again *)
SetGHPWeightAndFormatSymmetric[Evaluate@Psi[cde],dyad]^=Null;
SetGHPWeightAndFormatSymmetric[Evaluate@Dagger[Psi[cde]],dyad]^=Null;
SetGHPWeightAndFormatSymmetric[Evaluate@Phi[cde],dyad]^=Null;
tmprules={Psi[cde][{0,-dyad},{0,-dyad},{0,-dyad},{0,-dyad}]->SymbolJoin["Psi",cde,"0",dyad][],Psi[cde][{0,-dyad},{0,-dyad},{0,-dyad},{1,-dyad}]->SymbolJoin["Psi",cde,"1",dyad][],Psi[cde][{0,-dyad},{0,-dyad},{1,-dyad},{1,-dyad}]->SymbolJoin["Psi",cde,"2",dyad][],Psi[cde][{0,-dyad},{1,-dyad},{1,-dyad},{1,-dyad}]->SymbolJoin["Psi",cde,"3",dyad][],Psi[cde][{1,-dyad},{1,-dyad},{1,-dyad},{1,-dyad}]->SymbolJoin["Psi",cde,"4",dyad][]};
Map[Dagger,tmprules,{2}]/.Rule->(TagSet[Evaluate[Dagger@Psi[cde]],#1,#2]&);
tmprules/.Rule->(TagSet[Evaluate[Psi[cde]],#1,#2]&);
tmprules={Phi[cde][{0,-dyad},{0,-dyad},{0,-dyaddg},{0,-dyaddg}]->SymbolJoin["Phi",cde,"00",dyad][],Phi[cde][{0,-dyad},{0,-dyad},{0,-dyaddg},{1,-dyaddg}]->SymbolJoin["Phi",cde,"01",dyad][],Phi[cde][{0,-dyad},{0,-dyad},{1,-dyaddg},{1,-dyaddg}]->SymbolJoin["Phi",cde,"02",dyad][],Phi[cde][{0,-dyad},{1,-dyad},{0,-dyaddg},{0,-dyaddg}]->SymbolJoin["Phi",cde,"10",dyad][],Phi[cde][{1,-dyad},{1,-dyad},{0,-dyaddg},{0,-dyaddg}]->SymbolJoin["Phi",cde,"20",dyad][],Phi[cde][{0,-dyad},{1,-dyad},{0,-dyaddg},{1,-dyaddg}]->SymbolJoin["Phi",cde,"11",dyad][],Phi[cde][{1,-dyad},{1,-dyad},{0,-dyaddg},{1,-dyaddg}]->SymbolJoin["Phi",cde,"21",dyad][],Phi[cde][{0,-dyad},{1,-dyad},{1,-dyaddg},{1,-dyaddg}]->SymbolJoin["Phi",cde,"12",dyad][],Phi[cde][{1,-dyad},{1,-dyad},{1,-dyaddg},{1,-dyaddg}]->SymbolJoin["Phi",cde,"22",dyad][]};
tmprules/.Rule->(TagSet[Evaluate[Phi[cde]],#1,#2]&);
tmprules={SymbolJoin["Phi",cde,"00",dyaddg][]->SymbolJoin["Phi",cde,"00",dyad][],SymbolJoin["Phi",cde,"01",dyaddg][]->SymbolJoin["Phi",cde,"10",dyad][],SymbolJoin["Phi",cde,"02",dyaddg][]->SymbolJoin["Phi",cde,"20",dyad][],SymbolJoin["Phi",cde,"10",dyaddg][]->SymbolJoin["Phi",cde,"01",dyad][],SymbolJoin["Phi",cde,"11",dyaddg][]->SymbolJoin["Phi",cde,"11",dyad][],SymbolJoin["Phi",cde,"12",dyaddg][]->SymbolJoin["Phi",cde,"21",dyad][],SymbolJoin["Phi",cde,"20",dyaddg][]->SymbolJoin["Phi",cde,"02",dyad][],SymbolJoin["Phi",cde,"21",dyaddg][]->SymbolJoin["Phi",cde,"12",dyad][],SymbolJoin["Phi",cde,"22",dyaddg][]->SymbolJoin["Phi",cde,"22",dyad][]};
tmprules/.Rule->Set;
(* NP operators *)
DefNPOperatorTools[dyad,tetrad,cde,{a,A}];
(* GHP operators *)
DefGHPOperator[dyad,tetrad,cde,{a,A},symbform,texform];
(* Derivatives of the NP but not GHP spin coefficients (i.e. a subset of the NP Ricci) *)
tmprules={cde[A,Adg][NPSpinCoefficients[dyad][[1]]]==iota[A]*iotadg[Adg]*pdnp[{1,-tetrad}][NPSpinCoefficients[dyad][[1]]]+omicron[A]*omicrondg[Adg]*pdnp[{2,-tetrad}][NPSpinCoefficients[dyad][[1]]]-omicrondg[Adg]*iota[A]*pdnp[{3,-tetrad}][NPSpinCoefficients[dyad][[1]]]-omicron[A]*iotadg[Adg]*pdnp[{4,-tetrad}][NPSpinCoefficients[dyad][[1]]],cde[A,Adg][NPSpinCoefficients[dyad][[2]]]==-$LambdaSign*$RiemannSign*Lambda[cde][]*omicron[A]*iotadg[Adg]-omicron[A]*$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"11",dyad][]*iotadg[Adg]+omicron[A]*$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"2",dyad][]*iotadg[Adg]+omicron[A]*NPSpinCoefficients[dyad][[1]]*Dagger@NPSpinCoefficients[dyad][[1]]*iotadg[Adg]-2*omicron[A]*NPSpinCoefficients[dyad][[1]]*NPSpinCoefficients[dyad][[2]]*iotadg[Adg]+omicron[A]*NPSpinCoefficients[dyad][[2]]*Dagger@NPSpinCoefficients[dyad][[2]]*iotadg[Adg]+omicron[A]*NPSpinCoefficients[dyad][[4]]*iotadg[Adg]*NPSpinCoefficients[dyad][[7]]-omicron[A]*NPSpinCoefficients[dyad][[4]]*iotadg[Adg]*Dagger@NPSpinCoefficients[dyad][[7]]+omicron[A]*NPSpinCoefficients[dyad][[3]]*iotadg[Adg]*NPSpinCoefficients[dyad][[10]]+omicron[A]*iotadg[Adg]*NPSpinCoefficients[dyad][[7]]*NPSpinCoefficients[dyad][[10]]-omicron[A]*NPSpinCoefficients[dyad][[3]]*iotadg[Adg]*Dagger@NPSpinCoefficients[dyad][[10]]-omicron[A]*iotadg[Adg]*NPSpinCoefficients[dyad][[6]]*NPSpinCoefficients[dyad][[11]]+iota[A]*iotadg[Adg]*pdnp[{1,-tetrad}][NPSpinCoefficients[dyad][[2]]]+omicron[A]*omicrondg[Adg]*pdnp[{2,-tetrad}][NPSpinCoefficients[dyad][[2]]]-omicron[A]*iotadg[Adg]*pdnp[{3,-tetrad}][NPSpinCoefficients[dyad][[1]]]-omicrondg[Adg]*iota[A]*pdnp[{3,-tetrad}][NPSpinCoefficients[dyad][[2]]],cde[A,Adg][NPSpinCoefficients[dyad][[3]]]==omicrondg[Adg]*$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"12",dyad][]*iota[A]+omicrondg[Adg]*Dagger@NPSpinCoefficients[dyad][[1]]*NPSpinCoefficients[dyad][[3]]*iota[A]+2*omicrondg[Adg]*NPSpinCoefficients[dyad][[2]]*NPSpinCoefficients[dyad][[3]]*iota[A]-omicrondg[Adg]*NPSpinCoefficients[dyad][[2]]*Dagger@NPSpinCoefficients[dyad][[3]]*iota[A]+omicron[A]*$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"3",dyad][]*iotadg[Adg]+omicron[A]*Dagger@NPSpinCoefficients[dyad][[2]]*NPSpinCoefficients[dyad][[3]]*iotadg[Adg]+omicron[A]*NPSpinCoefficients[dyad][[1]]*Dagger@NPSpinCoefficients[dyad][[3]]*iotadg[Adg]-omicron[A]*NPSpinCoefficients[dyad][[2]]*iotadg[Adg]*NPSpinCoefficients[dyad][[6]]-omicrondg[Adg]*NPSpinCoefficients[dyad][[1]]*iota[A]*Dagger@NPSpinCoefficients[dyad][[6]]-omicrondg[Adg]*NPSpinCoefficients[dyad][[2]]*iota[A]*NPSpinCoefficients[dyad][[7]]-omicron[A]*NPSpinCoefficients[dyad][[1]]*iotadg[Adg]*Dagger@NPSpinCoefficients[dyad][[7]]+omicron[A]*NPSpinCoefficients[dyad][[4]]*iotadg[Adg]*NPSpinCoefficients[dyad][[8]]+omicrondg[Adg]*NPSpinCoefficients[dyad][[4]]*iota[A]*Dagger@NPSpinCoefficients[dyad][[8]]+omicron[A]*iotadg[Adg]*NPSpinCoefficients[dyad][[8]]*NPSpinCoefficients[dyad][[10]]+omicrondg[Adg]*iota[A]*NPSpinCoefficients[dyad][[8]]*NPSpinCoefficients[dyad][[11]]-omicrondg[Adg]*NPSpinCoefficients[dyad][[3]]*iota[A]*NPSpinCoefficients[dyad][[12]]-omicron[A]*iotadg[Adg]*NPSpinCoefficients[dyad][[6]]*NPSpinCoefficients[dyad][[12]]-omicrondg[Adg]*iota[A]*NPSpinCoefficients[dyad][[7]]*NPSpinCoefficients[dyad][[12]]-omicron[A]*NPSpinCoefficients[dyad][[3]]*iotadg[Adg]*Dagger@NPSpinCoefficients[dyad][[12]]+iota[A]*iotadg[Adg]*pdnp[{1,-tetrad}][NPSpinCoefficients[dyad][[3]]]-omicron[A]*iotadg[Adg]*pdnp[{2,-tetrad}][NPSpinCoefficients[dyad][[1]]]-omicrondg[Adg]*iota[A]*pdnp[{2,-tetrad}][NPSpinCoefficients[dyad][[2]]]+omicron[A]*omicrondg[Adg]*pdnp[{2,-tetrad}][NPSpinCoefficients[dyad][[3]]],cde[A,Adg][NPSpinCoefficients[dyad][[4]]]==-$RiemannSign*$LambdaSign*Lambda[cde][]*omicron[A]*omicrondg[Adg]+$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"11",dyad][]omicron[A]*omicrondg[Adg]+$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"2",dyad][]omicron[A]*omicrondg[Adg]+2*omicron[A]*omicrondg[Adg]*NPSpinCoefficients[dyad][[3]]*NPSpinCoefficients[dyad][[4]]+omicron[A]*omicrondg[Adg]*Dagger@NPSpinCoefficients[dyad][[3]]*NPSpinCoefficients[dyad][[4]]+omicron[A]*omicrondg[Adg]*NPSpinCoefficients[dyad][[3]]*Dagger@NPSpinCoefficients[dyad][[4]]-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"1",dyad][]omicrondg[Adg]*iota[A]-omicrondg[Adg]*Dagger@NPSpinCoefficients[dyad][[1]]*NPSpinCoefficients[dyad][[4]]*iota[A]-omicrondg[Adg]*NPSpinCoefficients[dyad][[2]]*Dagger@NPSpinCoefficients[dyad][[4]]*iota[A]-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"10",dyad][]omicron[A]*iotadg[Adg]-2*omicron[A]*NPSpinCoefficients[dyad][[1]]*NPSpinCoefficients[dyad][[4]]*iotadg[Adg]-omicron[A]*Dagger@NPSpinCoefficients[dyad][[2]]*NPSpinCoefficients[dyad][[4]]*iotadg[Adg]+omicron[A]*NPSpinCoefficients[dyad][[1]]*Dagger@NPSpinCoefficients[dyad][[4]]*iotadg[Adg]-omicrondg[Adg]*NPSpinCoefficients[dyad][[3]]*iota[A]*NPSpinCoefficients[dyad][[5]]-omicron[A]*NPSpinCoefficients[dyad][[3]]*iotadg[Adg]*Dagger@NPSpinCoefficients[dyad][[5]]-omicron[A]*iotadg[Adg]*NPSpinCoefficients[dyad][[5]]*NPSpinCoefficients[dyad][[6]]-omicrondg[Adg]*iota[A]*NPSpinCoefficients[dyad][[5]]*NPSpinCoefficients[dyad][[7]]+omicron[A]*omicrondg[Adg]*NPSpinCoefficients[dyad][[5]]*NPSpinCoefficients[dyad][[8]]-omicron[A]*omicrondg[Adg]*NPSpinCoefficients[dyad][[2]]*NPSpinCoefficients[dyad][[9]]+omicron[A]*NPSpinCoefficients[dyad][[4]]*iotadg[Adg]*NPSpinCoefficients[dyad][[9]]-omicron[A]*omicrondg[Adg]*NPSpinCoefficients[dyad][[1]]*Dagger@NPSpinCoefficients[dyad][[9]]+omicrondg[Adg]*NPSpinCoefficients[dyad][[4]]*iota[A]*Dagger@NPSpinCoefficients[dyad][[9]]+omicron[A]*NPSpinCoefficients[dyad][[1]]*iotadg[Adg]*NPSpinCoefficients[dyad][[10]]+omicron[A]*iotadg[Adg]*NPSpinCoefficients[dyad][[9]]*NPSpinCoefficients[dyad][[10]]+omicrondg[Adg]*NPSpinCoefficients[dyad][[2]]*iota[A]*Dagger@NPSpinCoefficients[dyad][[10]]+omicrondg[Adg]*NPSpinCoefficients[dyad][[1]]*iota[A]*NPSpinCoefficients[dyad][[11]]+omicrondg[Adg]*iota[A]*NPSpinCoefficients[dyad][[9]]*NPSpinCoefficients[dyad][[11]]+omicron[A]*NPSpinCoefficients[dyad][[2]]*iotadg[Adg]*Dagger@NPSpinCoefficients[dyad][[11]]-omicron[A]*omicrondg[Adg]*NPSpinCoefficients[dyad][[1]]*NPSpinCoefficients[dyad][[12]]-omicron[A]*omicrondg[Adg]*NPSpinCoefficients[dyad][[9]]*NPSpinCoefficients[dyad][[12]]-omicron[A]*omicrondg[Adg]*NPSpinCoefficients[dyad][[2]]*Dagger@NPSpinCoefficients[dyad][[12]]-omicron[A]*iotadg[Adg]*pdnp[{1,-tetrad}][NPSpinCoefficients[dyad][[1]]]-omicrondg[Adg]*iota[A]*pdnp[{1,-tetrad}][NPSpinCoefficients[dyad][[2]]]+omicron[A]*omicrondg[Adg]*pdnp[{1,-tetrad}][NPSpinCoefficients[dyad][[3]]]+iota[A]*iotadg[Adg]*pdnp[{1,-tetrad}][NPSpinCoefficients[dyad][[4]]]};
CovDNPSpinCoeffRules[dyad]^=Flatten[MakeRule[Evaluate[List@@#],MetricOn->All,ContractMetrics->True]&/@Join[tmprules,Map[Dagger,tmprules,{2}]]];
(* Dyad expansions of curvature *)
DyadExpansionEq[eps,dyad]^=eps[-A,-B]==ToCanonical[TraceBasisDummy@SeparateBasis[dyad]@eps[-A,-B]/.BasisToDyadRules[dyad]];
DyadExpansionEq[Evaluate[Psi[cde]],dyad]^=Psi[cde][-A,-B,-C,-D]==ToCanonical[TraceBasisDummy@SeparateBasis[dyad]@Psi[cde][-A,-B,-C,-D]/.BasisToDyadRules[dyad]];
DyadExpansionEq[Evaluate[Dagger@Psi[cde]],dyad]^=Dagger/@DyadExpansionEq[Evaluate[Psi[cde]],dyad];
DyadExpansionEq[Evaluate[Phi[cde]],dyad]^=Phi[cde][-A,-B,-Adg,-Bdg]==ToCanonical[TraceBasisDummy@SeparateBasis[dyad]@SeparateBasis[dyaddg]@Phi[cde][-A,-B,-Adg,-Bdg]/.BasisToDyadRules[dyad]];
]

3.3. Tex and sorting

FormatComponents[dyad_,SS_?xTensorQ,symbform_]:=(Union@Flatten@ToCanonical@ComponentArray[ToBasis[Dagger@dyad]@ToBasis[dyad]@GiveIndicesToTensor@SS]/.TT_?xTensorQ[inds___]:>Module[{dyadinds=Select[{inds},#[[2]]===-dyad&],dyaddginds=Select[{inds},#[[2]]===-Dagger[dyad]&]},UpSet[MakeBoxes[TT[inds],StandardForm],xAct`xTensor`Private`interpretbox[TT[inds],SubscriptBox[PrintAs[TT],StringJoin["",If[Length[dyadinds]>0,symbform@ToString[Plus@@(First/@dyadinds)],""],If[Length[dyaddginds]>0,StringJoin[symbform@ToString[Plus@@(First/@dyaddginds)],"'"],""],""]]]]])/;CompatibleSymQ[SlotsOfTensor[SS],SymmetryGroupOfTensor@SS,{VBundleOfBasis@dyad,Dagger@VBundleOfBasis@dyad}];

SetTexComponents[dyad_, SS_?xTensorQ, texform_]:=(Union@Flatten@ToCanonical@ComponentArray[ToBasis[Dagger@dyad]@ToBasis[dyad]@GiveIndicesToTensor@SS]/.TT_?xTensorQ[inds___]:>Module[{dyadinds=Select[{inds},#[[2]]===-dyad&],dyaddginds=Select[{inds},#[[2]]===-Dagger[dyad]&]},UpSet[Tex[TT[inds]],StringJoin[Tex[TT],"_{",If[Length[dyadinds]>0,texform@ToString[Plus@@(First/@dyadinds)],""],If[Length[dyaddginds]>0,StringJoin[texform@ToString[Plus@@(First/@dyaddginds)],"'"],""],"}"]]])/;CompatibleSymQ[SlotsOfTensor[SS],SymmetryGroupOfTensor@SS,{VBundleOfBasis@dyad,Dagger@VBundleOfBasis@dyad}];

GHPOrderOfTerm[prod_Times]:=Max@@(GHPOrderOfTerm/@(List@@prod))

GHPOrderOfTerm[a_]:=0

GHPOrderOfTerm[x:InertScalarOp[__][_]]:=Max[GHPOrderOfTerm/@xAct`xTensor`Private`ListOfTerms[Expand[x/.InertScalarOp->Function/.OrderedPlus->Plus]]]

SortByGHPOrder[expr_Equal]:=SortByGHPOrder/@expr

Order by - the GHP order so the highest number of derivatives comes first.

SortByGHPOrder[expr_]:=OrderedPlus@@SortBy[xAct`xTensor`Private`ListOfTerms[expr],(-GHPOrderOfTerm@#)&]

4. NP Tools

4.1. NP differential operator tools

DefNPOperatorTools[dyad_,tetrad_,cde_,{a_,A_}]:=
With[{omicronA=SpinorsOfDyad[dyad][[1]][A],
iotaA=SpinorsOfDyad[dyad][[2]][A],omicrondgAdg=Dagger[SpinorsOfDyad[dyad][[1]][A]],iotadgAdg=Dagger[SpinorsOfDyad[dyad][[2]][A]],
αdyad=NPSpinCoefficients[dyad][[1]],
βdyad=NPSpinCoefficients[dyad][[2]],
γdyad=NPSpinCoefficients[dyad][[3]],
ϵdyad=NPSpinCoefficients[dyad][[4]],
κdyad=NPSpinCoefficients[dyad][[5]],
λdyad=NPSpinCoefficients[dyad][[6]],
μdyad=NPSpinCoefficients[dyad][[7]],
νdyad=NPSpinCoefficients[dyad][[8]],
πdyad=NPSpinCoefficients[dyad][[9]],
ρdyad=NPSpinCoefficients[dyad][[10]],
σdyad=NPSpinCoefficients[dyad][[11]],
τdyad=NPSpinCoefficients[dyad][[12]],
lambda=-$LambdaSign*$RiemannSign*Lambda[cde][],
psi0=-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"0",dyad][],
psi1=-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"1",dyad][],
psi2=-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"2",dyad][],psi3=-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"3",dyad][],psi4=-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"4",dyad][],phi00=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"00",dyad][],
phi01=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"01",dyad][],
phi02=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"02",dyad][],
phi10=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"10",dyad][],
phi11=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"11",dyad][],
phi12=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"12",dyad][],
phi20=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"20",dyad][],
phi21=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"21",dyad][],
phi22=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"22",dyad][],
sigma=SolderingFormOfVBundle@VBundleOfIndex@A,exprsymb=Symbol["expr"]
},With[{pdnp=PDOfBasis@tetrad,Adg=DaggerIndex@A,
tangentpmQ=xAct`xTensor`Private`VBundleIndexPMQ[VBundleOfIndex[a]],spinpmQ=xAct`xTensor`Private`VBundleIndexPMQ[VBundleOfIndex[A]],spindgpmQ=xAct`xTensor`Private`VBundleIndexPMQ[VBundleOfIndex@DaggerIndex[A]]},
(* Commutators *)
CommuteNPOp[pdnp[{1, -tetrad}],pdnp[{2, -tetrad}],s___]:=pdnp[{1, -tetrad}][pdnp[{2, -tetrad}][expr_]] :> (pdnp[{2, -tetrad}][pdnp[{1, -tetrad}][expr]]
-(γdyad+Dagger@γdyad)*pdnp[{1, -tetrad}][expr]
-(ϵdyad+Dagger@ϵdyad)*pdnp[{2, -tetrad}][expr]
+(πdyad+Dagger@τdyad)*pdnp[{3, -tetrad}][expr]
+(τdyad+Dagger@πdyad)*pdnp[{4, -tetrad}][expr]
)/;Or[Length@List@s==0 ,expr==s];
CommuteNPOp[pdnp[{2, -tetrad}],pdnp[{1, -tetrad}],s___]:=pdnp[{2, -tetrad}][pdnp[{1, -tetrad}][expr_]] :> (pdnp[{1, -tetrad}][pdnp[{2, -tetrad}][expr]]
+(γdyad+Dagger@γdyad)*pdnp[{1, -tetrad}][expr]
+(ϵdyad+Dagger@ϵdyad)*pdnp[{2, -tetrad}][expr]
-(πdyad+Dagger@τdyad)*pdnp[{3, -tetrad}][expr]
-(τdyad+Dagger@πdyad)*pdnp[{4, -tetrad}][expr]
)/;Or[Length@List@s==0 ,expr==s];
CommuteNPOp[pdnp[{1, -tetrad}],pdnp[{3, -tetrad}],s___]:=pdnp[{1, -tetrad}][pdnp[{3, -tetrad}][expr_]] :> (pdnp[{3, -tetrad}][pdnp[{1, -tetrad}][expr]]
-(Dagger@αdyad+βdyad-Dagger@πdyad)*pdnp[{1, -tetrad}][expr]
-κdyad*pdnp[{2, -tetrad}][expr]
+(ϵdyad-Dagger@ϵdyad+Dagger@ρdyad)*pdnp[{3, -tetrad}][expr]
+σdyad*pdnp[{4, -tetrad}][expr]
)/;Or[Length@List@s==0 ,expr==s];
CommuteNPOp[pdnp[{3, -tetrad}],pdnp[{1, -tetrad}],s___]:=pdnp[{3, -tetrad}][pdnp[{1, -tetrad}][expr_]] :> (pdnp[{1, -tetrad}][pdnp[{3, -tetrad}][expr]]
+(Dagger@αdyad+βdyad-Dagger@πdyad)*pdnp[{1, -tetrad}][expr]
+κdyad*pdnp[{2, -tetrad}][expr]
-(ϵdyad-Dagger@ϵdyad+Dagger@ρdyad)*pdnp[{3, -tetrad}][expr]
-σdyad*pdnp[{4, -tetrad}][expr]
)/;Or[Length@List@s==0 ,expr==s];
CommuteNPOp[pdnp[{1, -tetrad}],pdnp[{4, -tetrad}],s___]:=pdnp[{1, -tetrad}][pdnp[{4, -tetrad}][expr_]] :> (pdnp[{4, -tetrad}][pdnp[{1, -tetrad}][expr]]
-(αdyad+Dagger@βdyad-πdyad)*pdnp[{1, -tetrad}][expr]
-Dagger@κdyad*pdnp[{2, -tetrad}][expr]
+Dagger@σdyad*pdnp[{3, -tetrad}][expr]
+(-ϵdyad+Dagger@ϵdyad+ρdyad)*pdnp[{4, -tetrad}][expr]
)/;Or[Length@List@s==0 ,expr==s];
CommuteNPOp[pdnp[{4, -tetrad}],pdnp[{1, -tetrad}],s___]:=pdnp[{4, -tetrad}][pdnp[{1, -tetrad}][expr_]] :> (pdnp[{1, -tetrad}][pdnp[{4, -tetrad}][expr]]
+(αdyad+Dagger@βdyad-πdyad)*pdnp[{1, -tetrad}][expr]
+Dagger@κdyad*pdnp[{2, -tetrad}][expr]
-Dagger@σdyad*pdnp[{3, -tetrad}][expr]
-(-ϵdyad+Dagger@ϵdyad+ρdyad)*pdnp[{4, -tetrad}][expr]
)/;Or[Length@List@s==0 ,expr==s];CommuteNPOp[pdnp[{2, -tetrad}],pdnp[{3, -tetrad}],s___]:=pdnp[{2, -tetrad}][pdnp[{3, -tetrad}][expr_]] :> (pdnp[{3, -tetrad}][pdnp[{2, -tetrad}][expr]]
+Dagger@νdyad*pdnp[{1, -tetrad}][expr]
+(Dagger@αdyad+βdyad-τdyad)*pdnp[{2, -tetrad}][expr]
+(γdyad-Dagger@γdyad-μdyad)*pdnp[{3, -tetrad}][expr]
-Dagger@λdyad*pdnp[{4, -tetrad}][expr]
)/;Or[Length@List@s==0 ,expr==s];
CommuteNPOp[pdnp[{3, -tetrad}],pdnp[{2, -tetrad}],s___]:=pdnp[{3, -tetrad}][pdnp[{2, -tetrad}][expr_]] :> (pdnp[{2, -tetrad}][pdnp[{3, -tetrad}][expr]]
-Dagger@νdyad*pdnp[{1, -tetrad}][expr]
-(Dagger@αdyad+βdyad-τdyad)*pdnp[{2, -tetrad}][expr]
-(γdyad-Dagger@γdyad-μdyad)*pdnp[{3, -tetrad}][expr]
+Dagger@λdyad*pdnp[{4, -tetrad}][expr]
)/;Or[Length@List@s==0 ,expr==s];
CommuteNPOp[pdnp[{2, -tetrad}],pdnp[{4, -tetrad}],s___]:=pdnp[{2, -tetrad}][pdnp[{4, -tetrad}][expr_]] :> (pdnp[{4, -tetrad}][pdnp[{2, -tetrad}][expr]]
+ νdyad*pdnp[{1, -tetrad}][expr]
+(αdyad+Dagger@βdyad-Dagger@τdyad)*pdnp[{2, -tetrad}][expr]
-λdyad*pdnp[{3, -tetrad}][expr]
-(γdyad-Dagger@γdyad+Dagger@μdyad)*pdnp[{4, -tetrad}][expr]
)/;Or[Length@List@s==0 ,expr==s];
CommuteNPOp[pdnp[{4, -tetrad}],pdnp[{2, -tetrad}],s___]:=pdnp[{4, -tetrad}][pdnp[{2, -tetrad}][expr_]] :> (pdnp[{2, -tetrad}][pdnp[{4, -tetrad}][expr]]
- νdyad*pdnp[{1, -tetrad}][expr]
-(αdyad+Dagger@βdyad-Dagger@τdyad)*pdnp[{2, -tetrad}][expr]
+λdyad*pdnp[{3, -tetrad}][expr]
+(γdyad-Dagger@γdyad+Dagger@μdyad)*pdnp[{4, -tetrad}][expr]
)/;Or[Length@List@s==0 ,expr==s];
CommuteNPOp[pdnp[{3, -tetrad}],pdnp[{4, -tetrad}],s___]:=pdnp[{3, -tetrad}][pdnp[{4, -tetrad}][expr_]] :> (pdnp[{4, -tetrad}][pdnp[{3, -tetrad}][expr]]
+(μdyad-Dagger@μdyad)*pdnp[{1, -tetrad}][expr]
+(ρdyad-Dagger@ρdyad)*pdnp[{2, -tetrad}][expr]
+(-αdyad+Dagger@βdyad)*pdnp[{3, -tetrad}][expr]
-(βdyad-Dagger@αdyad)*pdnp[{4, -tetrad}][expr]
)/;Or[Length@List@s==0 ,expr==s];
CommuteNPOp[pdnp[{4, -tetrad}],pdnp[{3, -tetrad}],s___]:=pdnp[{4, -tetrad}][pdnp[{3, -tetrad}][expr_]] :> (pdnp[{3, -tetrad}][pdnp[{4, -tetrad}][expr]]
-(μdyad-Dagger@μdyad)*pdnp[{1, -tetrad}][expr]
-(ρdyad-Dagger@ρdyad)*pdnp[{2, -tetrad}][expr]
-(-αdyad+Dagger@βdyad)*pdnp[{3, -tetrad}][expr]
+(βdyad-Dagger@αdyad)*pdnp[{4, -tetrad}][expr]
)/;Or[Length@List@s==0 ,expr==s];
CommuteNPOp[pdnp[aa_][pdnp[bb_][expr_]]]:=CommuteNPOp[pdnp[aa],pdnp[bb],expr];
NPCommutatorsForward[dyad]^=CommuteNPOp[pdnp[{#[[1]],-tetrad}],pdnp[{#[[2]],-tetrad}]]&/@Select[Join@@Outer[List,Range@4,Range@4],#[[1]]>#[[2]]&];
NPCommutatorsBackward[dyad]^=CommuteNPOp[pdnp[{#[[2]],-tetrad}],pdnp[{#[[1]],-tetrad}]]&/@Select[Join@@Outer[List,Range@4,Range@4],#[[1]]>#[[2]]&];
Module[
(* Ricci *)
{tmpeqs=Evaluate[{pdnp[{2,-tetrad}][ϵdyad]==lambda-phi11-psi2+2*γdyad*ϵdyad+κdyad*νdyad-βdyad*πdyad-αdyad*τdyad-πdyad*τdyad+ϵdyad*Dagger[γdyad]+γdyad*Dagger[ϵdyad]-αdyad*Dagger[πdyad]-βdyad*Dagger[τdyad]+pdnp[{1,-tetrad}][γdyad],pdnp[{2,-tetrad}][κdyad]==-phi01-psi1+3*γdyad*κdyad-πdyad*σdyad-ϵdyad*τdyad-ρdyad*τdyad+κdyad*Dagger[γdyad]+τdyad*Dagger[ϵdyad]-ρdyad*Dagger[πdyad]-σdyad*Dagger[τdyad]+pdnp[{1,-tetrad}][τdyad],pdnp[{2,-tetrad}][πdyad]==-phi21-psi3+3*ϵdyad*νdyad-γdyad*πdyad-μdyad*πdyad-λdyad*τdyad+πdyad*Dagger[γdyad]+νdyad*Dagger[ϵdyad]-λdyad*Dagger[πdyad]-μdyad*Dagger[τdyad]+pdnp[{1,-tetrad}][νdyad],pdnp[{3,-tetrad}][γdyad]==phi12-2*βdyad*γdyad+βdyad*μdyad-νdyad*σdyad+γdyad*τdyad+μdyad*τdyad-γdyad*Dagger[αdyad]+βdyad*Dagger[γdyad]+αdyad*Dagger[λdyad]-ϵdyad*Dagger[νdyad]+pdnp[{2,-tetrad}][βdyad],pdnp[{3,-tetrad}][ϵdyad]==-psi1+γdyad*κdyad+κdyad*μdyad-αdyad*σdyad-πdyad*σdyad+ϵdyad*Dagger[αdyad]+βdyad*Dagger[ϵdyad]-ϵdyad*Dagger[πdyad]-βdyad*Dagger[ρdyad]+pdnp[{1,-tetrad}][βdyad],pdnp[{3,-tetrad}][κdyad]==-psi0+3*βdyad*κdyad-3*ϵdyad*σdyad-ρdyad*σdyad+κdyad*τdyad+κdyad*Dagger[αdyad]+σdyad*Dagger[ϵdyad]-κdyad*Dagger[πdyad]-σdyad*Dagger[ρdyad]+pdnp[{1,-tetrad}][σdyad],pdnp[{3,-tetrad}][νdyad]==phi22+γdyad*μdyad+μdyad^2-3*βdyad*νdyad+νdyad*τdyad-νdyad*Dagger[αdyad]+μdyad*Dagger[γdyad]+λdyad*Dagger[λdyad]-πdyad*Dagger[νdyad]+pdnp[{2,-tetrad}][μdyad],pdnp[{3,-tetrad}][πdyad]==-2*lambda-psi2+ϵdyad*μdyad+κdyad*νdyad-βdyad*πdyad-λdyad*σdyad+πdyad*Dagger[αdyad]+μdyad*Dagger[ϵdyad]-πdyad*Dagger[πdyad]-μdyad*Dagger[ρdyad]+pdnp[{1,-tetrad}][μdyad],pdnp[{3,-tetrad}][τdyad]==phi02-3*γdyad*σdyad+μdyad*σdyad+βdyad*τdyad+τdyad^2-τdyad*Dagger[αdyad]+σdyad*Dagger[γdyad]+ρdyad*Dagger[λdyad]-κdyad*Dagger[νdyad]+pdnp[{2,-tetrad}][σdyad],pdnp[{4,-tetrad}][βdyad]==-lambda-phi11+psi2+2*αdyad*βdyad-ϵdyad*μdyad-γdyad*ρdyad-μdyad*ρdyad+λdyad*σdyad-αdyad*Dagger[αdyad]-βdyad*Dagger[βdyad]+ϵdyad*Dagger[μdyad]+γdyad*Dagger[ρdyad]+pdnp[{3,-tetrad}][αdyad],pdnp[{4,-tetrad}][γdyad]==psi3+βdyad*λdyad-ϵdyad*νdyad-νdyad*ρdyad+λdyad*τdyad-γdyad*Dagger[βdyad]-αdyad*Dagger[γdyad]+αdyad*Dagger[μdyad]+γdyad*Dagger[τdyad]+pdnp[{2,-tetrad}][αdyad],pdnp[{4,-tetrad}][ϵdyad]==-phi10+2*αdyad*ϵdyad+κdyad*λdyad-ϵdyad*πdyad-αdyad*ρdyad-πdyad*ρdyad+ϵdyad*Dagger[βdyad]-αdyad*Dagger[ϵdyad]+γdyad*Dagger[κdyad]-βdyad*Dagger[σdyad]+pdnp[{1,-tetrad}][αdyad],pdnp[{4,-tetrad}][κdyad]==-phi00+3*αdyad*κdyad-κdyad*πdyad-ϵdyad*ρdyad-ρdyad^2+κdyad*Dagger[βdyad]-ρdyad*Dagger[ϵdyad]+τdyad*Dagger[κdyad]-σdyad*Dagger[σdyad]+pdnp[{1,-tetrad}][ρdyad],pdnp[{4,-tetrad}][μdyad]==-phi21+psi3+3*βdyad*λdyad-αdyad*μdyad-μdyad*πdyad-νdyad*ρdyad-λdyad*Dagger[αdyad]-μdyad*Dagger[βdyad]+πdyad*Dagger[μdyad]+νdyad*Dagger[ρdyad]+pdnp[{3,-tetrad}][λdyad],pdnp[{4,-tetrad}][νdyad]==psi4+3*γdyad*λdyad+λdyad*μdyad-3*αdyad*νdyad-νdyad*πdyad-νdyad*Dagger[βdyad]-λdyad*Dagger[γdyad]+λdyad*Dagger[μdyad]+νdyad*Dagger[τdyad]+pdnp[{2,-tetrad}][λdyad],pdnp[{4,-tetrad}][πdyad]==-phi20+3*ϵdyad*λdyad-αdyad*πdyad-πdyad^2-λdyad*ρdyad+πdyad*Dagger[βdyad]-λdyad*Dagger[ϵdyad]+νdyad*Dagger[κdyad]-μdyad*Dagger[σdyad]+pdnp[{1,-tetrad}][λdyad],pdnp[{4,-tetrad}][σdyad]==-phi01+psi1-κdyad*μdyad-βdyad*ρdyad+3*αdyad*σdyad-ρdyad*τdyad-ρdyad*Dagger[αdyad]-σdyad*Dagger[βdyad]+κdyad*Dagger[μdyad]+τdyad*Dagger[ρdyad]+pdnp[{3,-tetrad}][ρdyad],pdnp[{4,-tetrad}][τdyad]==2*lambda+psi2-κdyad*νdyad-γdyad*ρdyad+λdyad*σdyad+αdyad*τdyad-τdyad*Dagger[βdyad]-ρdyad*Dagger[γdyad]+ρdyad*Dagger[μdyad]+τdyad*Dagger[τdyad]+pdnp[{2,-tetrad}][ρdyad]}]},
NPRicciRules[dyad]^=(Join[tmpeqs,Dagger/@tmpeqs]/.Equal->Rule);
(* Bianchi *)
tmpeqs={pdnp[{1,-tetrad}][phi01]==4*psi0*αdyad-2*phi00*βdyad+2*phi01*ϵdyad-2*psi1*ϵdyad-2*phi11*κdyad+3*psi2*κdyad-psi0*πdyad-4*psi1*ρdyad+2*phi10*σdyad-2*phi00*Dagger[αdyad]-phi02*Dagger[κdyad]+phi00*Dagger[πdyad]+2*phi01*Dagger[ρdyad]+pdnp[{1,-tetrad}][psi1]+pdnp[{3,-tetrad}][phi00]-pdnp[{4,-tetrad}][psi0],pdnp[{1,-tetrad}][phi02]==-2*phi01*βdyad-2*psi1*βdyad+4*psi0*γdyad+2*phi02*ϵdyad-2*phi12*κdyad-psi0*μdyad+2*phi11*σdyad+3*psi2*σdyad-4*psi1*τdyad-2*phi02*Dagger[ϵdyad]-phi00*Dagger[λdyad]+2*phi01*Dagger[πdyad]+phi02*Dagger[ρdyad]-pdnp[{2,-tetrad}][psi0]+pdnp[{3,-tetrad}][phi01]+pdnp[{3,-tetrad}][psi1],pdnp[{1,-tetrad}][phi11]==2*psi1*αdyad-phi21*κdyad+2*psi3*κdyad+psi0*λdyad-phi00*μdyad+phi01*πdyad-2*psi1*πdyad-3*psi2*ρdyad+phi20*σdyad-2*phi10*Dagger[αdyad]-phi12*Dagger[κdyad]+phi10*Dagger[πdyad]+2*phi11*Dagger[ρdyad]-pdnp[{1,-tetrad}][lambda]+pdnp[{1,-tetrad}][psi2]+pdnp[{3,-tetrad}][phi10]-pdnp[{4,-tetrad}][psi1],pdnp[{1,-tetrad}][phi22]==2*phi21*βdyad+2*psi3*βdyad-2*phi22*ϵdyad-2*phi11*μdyad-3*psi2*μdyad+2*psi1*νdyad+2*phi12*πdyad+psi4*σdyad-2*psi3*τdyad-2*phi22*Dagger[ϵdyad]-phi20*Dagger[λdyad]+2*phi21*Dagger[πdyad]+phi22*Dagger[ρdyad]-2*pdnp[{2,-tetrad}][lambda]-pdnp[{2,-tetrad}][psi2]+pdnp[{3,-tetrad}][phi21]+pdnp[{3,-tetrad}][psi3],pdnp[{1,-tetrad}][psi4]==2*phi21*αdyad+2*psi3*αdyad-2*phi20*γdyad-4*psi4*ϵdyad-2*phi11*λdyad-3*psi2*λdyad+2*phi10*νdyad+4*psi3*πdyad+psi4*ρdyad+2*phi20*Dagger[γdyad]-phi20*Dagger[μdyad]+phi22*Dagger[σdyad]-2*phi21*Dagger[τdyad]-pdnp[{2,-tetrad}][phi20]+pdnp[{4,-tetrad}][phi21]+pdnp[{4,-tetrad}][psi3],pdnp[{2,-tetrad}][phi00]==-2*phi01*αdyad-2*psi1*αdyad+2*phi00*γdyad-2*psi3*κdyad-psi0*λdyad+2*psi1*πdyad+2*phi11*ρdyad+3*psi2*ρdyad-2*phi10*τdyad+2*phi00*Dagger[γdyad]-phi00*Dagger[μdyad]+phi02*Dagger[σdyad]-2*phi01*Dagger[τdyad]-2*pdnp[{1,-tetrad}][lambda]-pdnp[{1,-tetrad}][psi2]+pdnp[{4,-tetrad}][phi01]+pdnp[{4,-tetrad}][psi1],pdnp[{2,-tetrad}][phi11]==-2*psi3*βdyad-phi02*λdyad+3*psi2*μdyad+phi01*νdyad-2*psi1*νdyad+phi22*ρdyad-psi4*σdyad-phi21*τdyad+2*psi3*τdyad+2*phi12*Dagger[βdyad]-2*phi11*Dagger[μdyad]+phi10*Dagger[νdyad]-phi12*Dagger[τdyad]-pdnp[{2,-tetrad}][lambda]+pdnp[{2,-tetrad}][psi2]-pdnp[{3,-tetrad}][psi3]+pdnp[{4,-tetrad}][phi12],pdnp[{2,-tetrad}][phi21]==2*phi22*αdyad-4*psi4*βdyad-2*phi21*γdyad+2*psi3*γdyad-2*phi12*λdyad+4*psi3*μdyad+2*phi11*νdyad-3*psi2*νdyad+psi4*τdyad+2*phi22*Dagger[βdyad]-2*phi21*Dagger[μdyad]+phi20*Dagger[νdyad]-phi22*Dagger[τdyad]+pdnp[{2,-tetrad}][psi3]-pdnp[{3,-tetrad}][psi4]+pdnp[{4,-tetrad}][phi22],pdnp[{3,-tetrad}][phi11]==-2*psi1*γdyad+phi22*κdyad+phi01*μdyad+2*psi1*μdyad-psi0*νdyad-phi02*πdyad-phi21*σdyad-2*psi3*σdyad+3*psi2*τdyad+2*phi12*Dagger[ϵdyad]+phi10*Dagger[λdyad]-2*phi11*Dagger[πdyad]-phi12*Dagger[ρdyad]+pdnp[{1,-tetrad}][phi12]+pdnp[{2,-tetrad}][psi1]+pdnp[{3,-tetrad}][lambda]-pdnp[{3,-tetrad}][psi2],pdnp[{4,-tetrad}][phi02]==2*phi02*αdyad-2*phi01*γdyad+2*psi1*γdyad-2*psi1*μdyad+psi0*νdyad-2*phi12*ρdyad+2*psi3*σdyad+2*phi11*τdyad-3*psi2*τdyad-2*phi02*Dagger[βdyad]+2*phi01*Dagger[μdyad]-phi00*Dagger[νdyad]+phi02*Dagger[τdyad]+pdnp[{2,-tetrad}][phi01]-pdnp[{2,-tetrad}][psi1]+2*pdnp[{3,-tetrad}][lambda]+pdnp[{3,-tetrad}][psi2],pdnp[{4,-tetrad}][phi11]==phi20*βdyad-phi21*ϵdyad+3*psi3*ϵdyad+(3*psi4*κdyad)/2+phi01*λdyad+3*psi1*λdyad-phi10*μdyad-phi00*νdyad+phi11*πdyad-(9*psi2*πdyad)/2-phi21*ρdyad-3*psi3*ρdyad+phi20*τdyad-phi20*Dagger[αdyad]-2*phi10*Dagger[γdyad]-(phi22*Dagger[κdyad])/2+phi10*Dagger[μdyad]+(phi20*Dagger[πdyad])/2+phi21*Dagger[ρdyad]-phi12*Dagger[σdyad]+2*phi11*Dagger[τdyad]-pdnp[{1,-tetrad}][phi21]/2+(3*pdnp[{1,-tetrad}][psi3])/2+pdnp[{2,-tetrad}][phi10]+pdnp[{3,-tetrad}][phi20]/2-(3*pdnp[{4,-tetrad}][psi2])/2,pdnp[{4,-tetrad}][Dagger[psi1]]==2*phi20*ϵdyad+phi00*λdyad-2*phi10*πdyad-phi20*ρdyad+2*phi10*Dagger[βdyad]+2*Dagger[psi1]*Dagger[βdyad]-4*Dagger[psi0]*Dagger[γdyad]-2*phi20*Dagger[ϵdyad]+2*phi21*Dagger[κdyad]+Dagger[psi0]*Dagger[μdyad]-2*phi11*Dagger[σdyad]-3*Dagger[psi2]*Dagger[σdyad]+4*Dagger[psi1]*Dagger[τdyad]+pdnp[{1,-tetrad}][phi20]+pdnp[{2,-tetrad}][Dagger[psi0]]-pdnp[{4,-tetrad}][phi10],pdnp[{4,-tetrad}][Dagger[psi2]]==2*phi21*ϵdyad-2*psi3*ϵdyad-psi4*κdyad-2*psi1*λdyad+phi00*νdyad-2*phi11*πdyad+3*psi2*πdyad+2*psi3*ρdyad-phi20*τdyad+2*phi10*Dagger[γdyad]-2*Dagger[psi1]*Dagger[γdyad]+phi22*Dagger[κdyad]+2*Dagger[psi1]*Dagger[μdyad]-Dagger[psi0]*Dagger[νdyad]-phi20*Dagger[πdyad]-2*Dagger[psi3]*Dagger[σdyad]-2*phi11*Dagger[τdyad]+3*Dagger[psi2]*Dagger[τdyad]+pdnp[{1,-tetrad}][phi21]-pdnp[{1,-tetrad}][psi3]-pdnp[{2,-tetrad}][phi10]+pdnp[{2,-tetrad}][Dagger[psi1]]+pdnp[{4,-tetrad}][psi2],pdnp[{4,-tetrad}][Dagger[psi3]]==2*phi21*βdyad+2*psi3*βdyad+phi02*λdyad-2*phi11*μdyad-3*psi2*μdyad+2*psi1*νdyad-phi22*ρdyad+psi4*σdyad-2*psi3*τdyad-2*phi12*Dagger[βdyad]-2*Dagger[psi3]*Dagger[βdyad]-phi20*Dagger[λdyad]+2*phi11*Dagger[μdyad]+3*Dagger[psi2]*Dagger[μdyad]-2*Dagger[psi1]*Dagger[νdyad]+phi22*Dagger[ρdyad]-Dagger[psi4]*Dagger[σdyad]+2*Dagger[psi3]*Dagger[τdyad]-pdnp[{2,-tetrad}][psi2]+pdnp[{2,-tetrad}][Dagger[psi2]]+pdnp[{3,-tetrad}][phi21]+pdnp[{3,-tetrad}][psi3]-pdnp[{4,-tetrad}][phi12],pdnp[{4,-tetrad}][Dagger[psi4]]==2*phi22*βdyad-2*phi12*μdyad+phi02*νdyad-phi22*τdyad+2*phi22*Dagger[αdyad]-4*Dagger[psi4]*Dagger[βdyad]-2*phi12*Dagger[γdyad]+2*Dagger[psi3]*Dagger[γdyad]-2*phi21*Dagger[λdyad]+4*Dagger[psi3]*Dagger[μdyad]+2*phi11*Dagger[νdyad]-3*Dagger[psi2]*Dagger[νdyad]+Dagger[psi4]*Dagger[τdyad]-pdnp[{2,-tetrad}][phi12]+pdnp[{2,-tetrad}][Dagger[psi3]]+pdnp[{3,-tetrad}][phi22],pdnp[{3,-tetrad}][Dagger[psi0]]==-2*phi00*αdyad-phi20*κdyad+phi00*πdyad+2*phi10*ρdyad+4*Dagger[psi0]*Dagger[αdyad]-2*phi00*Dagger[βdyad]+2*phi10*Dagger[ϵdyad]-2*Dagger[psi1]*Dagger[ϵdyad]-2*phi11*Dagger[κdyad]+3*Dagger[psi2]*Dagger[κdyad]-Dagger[psi0]*Dagger[πdyad]-4*Dagger[psi1]*Dagger[ρdyad]+2*phi01*Dagger[σdyad]-pdnp[{1,-tetrad}][phi10]+pdnp[{1,-tetrad}][Dagger[psi1]]+pdnp[{4,-tetrad}][phi00],pdnp[{3,-tetrad}][Dagger[psi1]]==-2*phi01*αdyad-2*psi1*αdyad-2*psi3*κdyad-psi0*λdyad+phi00*μdyad+2*psi1*πdyad+2*phi11*ρdyad+3*psi2*ρdyad-phi20*σdyad+2*phi10*Dagger[αdyad]+2*Dagger[psi1]*Dagger[αdyad]+2*Dagger[psi3]*Dagger[κdyad]+Dagger[psi0]*Dagger[λdyad]-phi00*Dagger[μdyad]-2*Dagger[psi1]*Dagger[πdyad]-2*phi11*Dagger[ρdyad]-3*Dagger[psi2]*Dagger[ρdyad]+phi02*Dagger[σdyad]-pdnp[{1,-tetrad}][psi2]+pdnp[{1,-tetrad}][Dagger[psi2]]-pdnp[{3,-tetrad}][phi10]+pdnp[{4,-tetrad}][phi01]+pdnp[{4,-tetrad}][psi1],pdnp[{3,-tetrad}][Dagger[psi2]]==-2*phi01*γdyad+2*psi1*γdyad-phi22*κdyad-2*psi1*μdyad+psi0*νdyad+phi02*πdyad+2*psi3*σdyad+2*phi11*τdyad-3*psi2*τdyad-2*phi12*Dagger[ϵdyad]+2*Dagger[psi3]*Dagger[ϵdyad]+Dagger[psi4]*Dagger[κdyad]+2*Dagger[psi1]*Dagger[λdyad]-phi00*Dagger[νdyad]+2*phi11*Dagger[πdyad]-3*Dagger[psi2]*Dagger[πdyad]-2*Dagger[psi3]*Dagger[ρdyad]+phi02*Dagger[τdyad]-pdnp[{1,-tetrad}][phi12]+pdnp[{1,-tetrad}][Dagger[psi3]]+pdnp[{2,-tetrad}][phi01]-pdnp[{2,-tetrad}][psi1]+pdnp[{3,-tetrad}][psi2],pdnp[{3,-tetrad}][Dagger[psi3]]==-2*phi02*γdyad+phi02*μdyad-phi22*σdyad+2*phi12*τdyad-2*phi12*Dagger[αdyad]-2*Dagger[psi3]*Dagger[αdyad]+2*phi02*Dagger[γdyad]+4*Dagger[psi4]*Dagger[ϵdyad]+2*phi11*Dagger[λdyad]+3*Dagger[psi2]*Dagger[λdyad]-2*phi01*Dagger[νdyad]-4*Dagger[psi3]*Dagger[πdyad]-Dagger[psi4]*Dagger[ρdyad]+pdnp[{1,-tetrad}][Dagger[psi4]]+pdnp[{2,-tetrad}][phi02]-pdnp[{3,-tetrad}][phi12],pdnp[{4,-tetrad}][lambda]==phi20*βdyad-phi21*ϵdyad+psi3*ϵdyad+(psi4*κdyad)/2+psi1*λdyad-phi10*μdyad+phi11*πdyad-(3*psi2*πdyad)/2-psi3*ρdyad-phi20*Dagger[αdyad]-(phi22*Dagger[κdyad])/2+(phi20*Dagger[πdyad])/2+phi21*Dagger[ρdyad]-pdnp[{1,-tetrad}][phi21]/2+pdnp[{1,-tetrad}][psi3]/2+pdnp[{3,-tetrad}][phi20]/2-pdnp[{4,-tetrad}][psi2]/2};tmpeqs=RemoveSignFromEq/@tmpeqs;
NPBianchiRules[dyad]^=(tmpeqs/.Equal->Rule);
(* CovDToNPRules *)
CovDToNPRules[dyad]^={(Evaluate[HoldPattern[(cde[xAct`xTensor`Private`pattern[A,Blank[]],xAct`xTensor`Private`pattern[Adg,Blank[]]][xAct`xTensor`Private`pattern[exprsymb,Blank[]]])]/.xAct`xTensor`Private`pattern->Pattern]:>Module[{a},xAct`xCoba`TraceBasisDummy[sigma[{a,tetrad},A,Adg]pdnp[{-a,-tetrad}]@exprsymb]/.TetradSigmaRules[tetrad]])};
];
]]

4.2. Conversion

$NPExtraRules={};
$NPExtraDyadExpansions={};
$DyadCalcInfo=True;

EqToRule1[expr_Equal]:=MakeRule[Evaluate[List@@expr],MetricOn->All,ContractMetrics->True]

CovDsToNP[expr_,dyad_]:=ToCanonical@Expand[Expand[expr/.CovDDyadRules[dyad]]/.CovDToNPRules[dyad]//.$NPExtraRules];

TensorNamesInExpr[expr_]:=Head/@Cases[expr,T_?xTensorQ[___],{0,Infinity}]

NonScalarTensorsInExpr[expr_,spin_]:=Select[TensorNamesInExpr[expr],Length[Select[SlotsOfTensor[#],Or[UpIndex[#]===spin,UpIndex[#]===Dagger@spin]&]]>0&]

NonScalarTensorsInExprNoDyad[expr_,dyad_]:=DeleteCases[NonScalarTensorsInExpr[expr,VBundleOfBasis[dyad]],Alternatives@@Flatten[{#,Dagger@#}&/@SpinorsOfDyad[dyad]]];

TensorsInExprNoDyad[expr_,dyad_]:=DeleteCases[TensorNamesInExpr[expr],Alternatives@@Flatten[{#,Dagger@#}&/@SpinorsOfDyad[dyad]]];

ToNP[expr_,dyad_]:=ToNP2[Expand[expr//.cd1_?CovDQ[cd1inds__][cd2_?CovDQ[cd2inds__][T_?xTensorQ[inds___]]]:>cd1[cd1inds][xAct`SymManipulator`Private`ToCovarD[cd2[cd2inds][T[inds]]]]],dyad];ToNP2[expr_,dyad_]:=Expand[Expand[CovDsToNP[Expand[expr/.Flatten[EqToRule1/@(DyadExpansionEq[#,dyad]&/@NonScalarTensorsInExprNoDyad[expr,dyad])]],dyad]]//.Flatten[NPComponentRules[#,dyad]&/@TensorsInExprNoDyad[expr,dyad]]//.$NPExtraRules];

NPComponentRules[xAct`SymManipulator`CovarD[cde_?CovDQ,TT_?xTensorQ,vbs_List],dyad_]:=NPComponentRules[xAct`SymManipulator`CovarD[cde,TT,vbs],dyad]=Module[{lhs=GiveIndicesToTensor[xAct`SymManipulator`CovarD[cde,TT,vbs]],rhs,spin=VBundleOfBasis@dyad},
(* Make sure the GHPWeights and Tex output are set by expanding into dyad *)
DyadExpansionEq[xAct`SymManipulator`CovarD[cde,TT,vbs],dyad];
If[$DyadCalcInfo,Print["Calculating the ",dyad,"components of ",lhs," in NP form."]];
rhs=xAct`SymManipulator`Private`ExpandCovarD@lhs;
If[Length[Select[SlotsOfTensor[TT],Or[UpIndex[#]===spin,UpIndex[#]===Dagger@spin]&]]>0,rhs=rhs/.EqToRule1@DyadExpansionEq[TT,dyad]/.$NPExtraDyadExpansions];
Expand[DyadComponents[lhs==Expand[ToCanonical[Expand[Expand[rhs]/.CovDDyadRules[dyad]]/.CovDToNPRules[dyad]//.$NPExtraRules]],dyad]/.NPComponentRules[TT,dyad]//.$NPExtraRules]/.Equal->Rule];

NPComponentRules[___]:={};

Options[DyadExpansionEq]={SetTexComponents->True,FormatComponents->True};

DyadExpansionEq[T_?xTensorQ,dyad_,options:OptionsPattern[]]:=DyadExpansionEq[T,dyad]^=Module[{X=GiveIndicesToTensor[T]},
If[$DyadCalcInfo,Print["GHP weights for ",X," components are generated, ",If[OptionValue[FormatComponents],"components are formatted, ",""],If[OptionValue[SetTexComponents],"Tex components are set, ",""],"and it is expanded into ", dyad]];
GHPWeightRules[T,dyad];
If[OptionValue[FormatComponents],FormatComponents[dyad,T]];
If[OptionValue[SetTexComponents],SetTexComponents[dyad,T]];
If[Or[HermitianQ[T]=!=True,AntihermitianQ[T]=!=True],GHPWeightRules[Dagger@T,dyad];If[OptionValue[FormatComponents],FormatComponents[dyad,Dagger@T]];
If[OptionValue[SetTexComponents],SetTexComponents[dyad,Dagger @T]];];
X==ToCanonical[TraceBasisDummy@SeparateBasis[Dagger@dyad]@SeparateBasis[dyad]@X/.BasisToDyadRules[dyad]]]

DyadComponents[expr_,dyad_]:=Union@Flatten[{ToCanonical@ComponentArray[ToBasis[dyad]/@ToBasis[Dagger@dyad]/@expr]}]

5. GHP Tools

5.1. Boost and spin weights

The GHP formalism only admits weighted quantities. In this subsection we introduce a command, called GHPWeightOf, which computes the boost and spin weight of any quantity. These are integers which are kept in a list.  The command GHPWeightOf also checks that the GHP weight of the terms of any sum all agree, throwing an error otherwise.

Weights of integers, rationals and complex numbers.

GHPWeightOf[num_?IntegerQ ]:={0,0};
GHPWeightOf[_Rational]:={0,0};
GHPWeightOf[_Complex]:={0,0};

Weights of products.

GHPWeightOf[expr_Times]:=Apply[Plus,GHPWeightOf/@Level[expr,{1}]];

Weights of sums

GHPWeightOf@expr_Plus:=If[Length@Union[GHPWeightOf/@Level[expr,1]]>1,Throw@Message[GHPWeightOf::Error],First@Union[GHPWeightOf/@Level[expr,1]]];
GHPWeightOf::Error="Inconsistent weights on Plus expression";

Weights of powers

GHPWeightOf[expr_^(n_?IntegerQ)]:=n GHPWeightOf@expr;

If we do not have GHP weights, we assume zero:

GHPWeightOf[expr_]:={0,0};

Contruct GHP weights for components

getindexrange[k_,vbundle_]:=Module[{n=Length@Flatten[IndicesOfVBundle[vbundle]]},NewIndexIn[vbundle]&/@Range[k-n];Take[Flatten[IndicesOfVBundle[vbundle]],k]]

giveindicestotensor[TT_?xTensorQ,upvbundles_:{}]:=Module[{n=Length@SlotsOfTensor@TT,vbundles=UpIndex/@SlotsOfTensor@TT,gatheredslots,inds,slotrules},gatheredslots=GatherBy[Range@n,vbundles[[#]]&];
inds=Flatten[getindexrange@@@({Length@#,vbundles[[First@#]]}&/@gatheredslots)];
inds=If[MemberQ[upvbundles,VBundleOfIndex[#]],#,DownIndex[#]]&/@inds;
slotrules=Thread@Rule[Flatten@gatheredslots,inds];
TT@@(Range@n/.slotrules)]

GHPWeightRules[SS_?xTensorQ,dyad_]:=Union@Flatten@ToCanonical@ComponentArray[ToBasis[Dagger@dyad]@ToBasis[dyad]@giveindicestotensor@SS]/.TT_?xTensorQ[inds___]:>Module[{dyadinds=Select[{inds},#[[2]]===-dyad&],dyaddginds=Select[{inds},#[[2]]===-Dagger[dyad]&]},UpSet[GHPWeightOf[TT[inds]],{Length@dyadinds-2*(Plus@@(First/@dyadinds)),Length@dyaddginds-2*(Plus@@(First/@dyaddginds))}]];

5.2. GHP differential operators

DefGHPOperator[dyad_,tetrad_,cde_,{a_,A_},symbform_,texform_]:=
With[{omicronA=SpinorsOfDyad[dyad][[1]][A],
iotaA=SpinorsOfDyad[dyad][[2]][A],omicrondgAdg=Dagger[SpinorsOfDyad[dyad][[1]][A]],iotadgAdg=Dagger[SpinorsOfDyad[dyad][[2]][A]],
commutatorexpr1a=-$LambdaSign*$RiemannSign*Lambda[cde][]+$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"11",dyad][]+$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"2",dyad][]-GHPSpinCoefficients[dyad][[1]]*GHPSpinCoefficients[dyad][[5]]+GHPSpinCoefficients[dyad][[4]]*GHPSpinCoefficients[dyad][[8]],
commutatorexpr1b=(Dagger@GHPSpinCoefficients[dyad][[4]]-GHPSpinCoefficients[dyad][[8]]),
commutatorexpr2a=-$LambdaSign*$RiemannSign*Lambda[cde][]-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"11",dyad][]+$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"2",dyad][]-GHPSpinCoefficients[dyad][[2]]*GHPSpinCoefficients[dyad][[6]]+GHPSpinCoefficients[dyad][[3]]*GHPSpinCoefficients[dyad][[7]],commutatorexpr3a=-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"1",dyad][]+GHPSpinCoefficients[dyad][[1]]*GHPSpinCoefficients[dyad][[6]]-GHPSpinCoefficients[dyad][[3]]*GHPSpinCoefficients[dyad][[8]],commutatorexpr4a=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"12",dyad][]+GHPSpinCoefficients[dyad][[5]]*GHPSpinCoefficients[dyad][[3]]-GHPSpinCoefficients[dyad][[6]]*GHPSpinCoefficients[dyad][[4]],commutatorexpr4b=-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"3",dyad][]+GHPSpinCoefficients[dyad][[5]]*GHPSpinCoefficients[dyad][[2]]-GHPSpinCoefficients[dyad][[7]]*GHPSpinCoefficients[dyad][[4]],commutatorexpr5a=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"10",dyad][]+GHPSpinCoefficients[dyad][[1]]*GHPSpinCoefficients[dyad][[7]]-GHPSpinCoefficients[dyad][[2]]*GHPSpinCoefficients[dyad][[8]],commutatorexpr5b=-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"1",dyad][]+GHPSpinCoefficients[dyad][[1]]*GHPSpinCoefficients[dyad][[6]]-GHPSpinCoefficients[dyad][[3]]*GHPSpinCoefficients[dyad][[8]],κdyad=GHPSpinCoefficients[dyad][[1]],
ρdyad=GHPSpinCoefficients[dyad][[2]],
σdyad=GHPSpinCoefficients[dyad][[3]],
τdyad=GHPSpinCoefficients[dyad][[4]],
κpdyad=GHPSpinCoefficients[dyad][[5]],
ρpdyad=GHPSpinCoefficients[dyad][[6]],
σpdyad=GHPSpinCoefficients[dyad][[7]],
τpdyad=GHPSpinCoefficients[dyad][[8]],
lambda=-$LambdaSign*$RiemannSign*Lambda[cde][],
psi0=-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"0",dyad][],
psi1=-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"1",dyad][],
psi2=-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"2",dyad][],psi3=-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"3",dyad][],psi4=-$PsiSign*$RiemannSign*SymbolJoin["Psi",cde,"4",dyad][],phi00=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"00",dyad][],
phi01=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"01",dyad][],
phi02=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"02",dyad][],
phi10=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"10",dyad][],
phi11=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"11",dyad][],
phi12=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"12",dyad][],
phi20=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"20",dyad][],
phi21=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"21",dyad][],
phi22=-$PhiSign*$RiemannSign*SymbolJoin["Phi",cde,"22",dyad][],
αdyad=NPSpinCoefficients[dyad][[1]],
βdyad=NPSpinCoefficients[dyad][[2]],
γdyad=NPSpinCoefficients[dyad][[3]],
ϵdyad=NPSpinCoefficients[dyad][[4]],
pdnp=PDOfBasis@tetrad},With[{theta=SymbolJoin["Θ",dyad],Adg=DaggerIndex@A,sigmaexprtetrad=(NPSpinCoefficients[dyad][[3]]VectorsOfTetrad[tetrad][[1]][a]+NPSpinCoefficients[dyad][[4]]VectorsOfTetrad[tetrad][[2]][a]-NPSpinCoefficients[dyad][[1]]VectorsOfTetrad[tetrad][[3]][a]-NPSpinCoefficients[dyad][[2]]VectorsOfTetrad[tetrad][[4]][a]),sigmaexprdyad=(NPSpinCoefficients[dyad][[3]]*omicronA*omicrondgAdg+NPSpinCoefficients[dyad][[4]]*iotaA*iotadgAdg-NPSpinCoefficients[dyad][[1]]*omicronA*iotadgAdg-NPSpinCoefficients[dyad][[2]]*iotaA*omicrondgAdg),sigmaexprdyaddg=Dagger[(NPSpinCoefficients[dyad][[3]]*omicronA*omicrondgAdg+NPSpinCoefficients[dyad][[4]]*iotaA*iotadgAdg-NPSpinCoefficients[dyad][[1]]*omicronA*iotadgAdg-NPSpinCoefficients[dyad][[2]]*iotaA*omicrondgAdg)],
tangentpmQ=xAct`xTensor`Private`VBundleIndexPMQ[VBundleOfIndex[a]],spinpmQ=xAct`xTensor`Private`VBundleIndexPMQ[VBundleOfIndex[A]],spindgpmQ=xAct`xTensor`Private`VBundleIndexPMQ[VBundleOfIndex@DaggerIndex[A]]},
CovDQ[theta]^=True;
 xAct`xTensor`Private`MakeLinearDerivative[Evaluate[{theta[xAct`xTensor`Private`pattern[A,BlankSequence[]]],theta[A]}/.xAct`xTensor`Private`pattern->Pattern],True];
SymmetryGroupOfCovD[theta]^=StrongGenSet[{},GenSet[]];
ManifoldOfCovD[theta]^=ManifoldOfCovD[cde];
VBundlesOfCovD[theta]^=VBundlesOfCovD[cde];
Dagger[Evaluate[(theta[xAct`xTensor`Private`pattern[a,Blank[]]][expr_]/.xAct`xTensor`Private`pattern->Pattern)]]^:=theta[DaggerIndex[a]][Dagger[expr]];
SymbolOfCovD[theta]^={"?",symbform@"Θ"};
(* GHP weights *)
GHPWeightOf@theta[{1,-tetrad}]^={1,1};
GHPWeightOf@theta[{2,-tetrad}]^={-1,-1};
GHPWeightOf@theta[{3,-tetrad}]^={1,-1};
GHPWeightOf@theta[{4,-tetrad}]^={-1,1};
GHPWeightOf[theta[ind_?CIndexQ]@sc_]:={Part[GHPWeightOf@theta[ind],1]+Part[GHPWeightOf@sc,1],Part[GHPWeightOf@theta[ind],2]+Part[GHPWeightOf@sc,2]};
(* Formating *)
xTensorFormStop[CovD];
FormatBasis[theta[{1,-tetrad}],symbform@"þ"];
FormatBasis[theta[{2,-tetrad}],symbform@"þ"<>"'"];
FormatBasis[theta[{3,-tetrad}],symbform@"ð"];
FormatBasis[theta[{4,-tetrad}],symbform@"ð"<>"'"];
xTensorFormStart[CovD];
FormatTexBasis[theta[{1,-tetrad}],StringJoin[texform@"\\tho"," "]];
FormatTexBasis[theta[{2,-tetrad}],StringJoin[texform@"\\tho","' "]];
FormatTexBasis[theta[{3,-tetrad}],StringJoin[texform@"\\edt"," "]];
FormatTexBasis[theta[{4,-tetrad}],StringJoin[texform@"\\edt","' "]];
$TexInitLatexExtraCode=DeleteDuplicates@Join[$TexInitLatexExtraCode,{"\\DeclareMathOperator{\\tho}{\\text{\\textthorn}}","\\DeclareMathOperator{\\edt}{\\eth}"}];
$TexInitLatexPackages=DeleteDuplicates@Append[$TexInitLatexPackages,"{tipa}"];
(* Conversion *)
CovDToGHPRules[dyad]^={Evaluate[(cde[PatternTest[xAct`xTensor`Private`pattern[a,Blank[]],tangentpmQ]][expr_]/.xAct`xTensor`Private`pattern->Pattern)]:> theta[a][expr]+(First@GHPWeightOf[expr]*sigmaexprtetrad+Last@GHPWeightOf[expr]*Dagger[sigmaexprtetrad])*expr,Evaluate[(cde[PatternTest[xAct`xTensor`Private`pattern[A,Blank[]],spinpmQ],PatternTest[xAct`xTensor`Private`pattern[Adg,Blank[]],spindgpmQ]][expr_]/.xAct`xTensor`Private`pattern->Pattern)]:> iotaA*iotadgAdg (theta[{1,-tetrad}][expr])+omicronA*omicrondgAdg(theta[{2,-tetrad}][expr])-iotaA*omicrondgAdg(theta[{3,-tetrad}][expr])-omicronA*iotadgAdg (theta[{4,-tetrad}][expr])+(First@GHPWeightOf[expr]*sigmaexprdyad+Last@GHPWeightOf[expr]*sigmaexprdyaddg)*expr};
(* Commutators *)
CommuteGHPOp[theta[{1, -tetrad}],theta[{2, -tetrad}],s___]:=theta[{1, -tetrad}][theta[{2, -tetrad}][expr_]] :> (theta[{2, -tetrad}][theta[{1, -tetrad}][expr]]+expr*(First@GHPWeightOf[expr]*commutatorexpr1a +Last@GHPWeightOf[expr]*Dagger@commutatorexpr1a )+commutatorexpr1b*theta[{3, -tetrad}][expr] +Dagger@commutatorexpr1b*theta[{4, -tetrad}][expr])/;Or[Length@List@s==0 ,expr==s];
CommuteGHPOp[theta[{2,-tetrad}],theta[{1,-tetrad}],s___]:=theta[{2,-tetrad}][theta[{1,-tetrad}][expr_]]:>(theta[{1,-tetrad}][theta[{2,-tetrad}][expr]]-expr*(First@GHPWeightOf[expr]*commutatorexpr1a+Last@GHPWeightOf[expr]*Dagger@commutatorexpr1a)-commutatorexpr1b*theta[{3,-tetrad}][expr]-Dagger@commutatorexpr1b*theta[{4,-tetrad}][expr])/;Or[Length@List@s==0,expr==s];
CommuteGHPOp[theta[{3,-tetrad}],theta[{4,-tetrad}],s___]:=theta[{3,-tetrad}][theta[{4,-tetrad}][expr_]]:>(theta[{4,-tetrad}][theta[{3,-tetrad}][expr]]+expr*(-First@GHPWeightOf[expr]*commutatorexpr2a+Last@GHPWeightOf[expr]*Dagger@commutatorexpr2a)+(-ρpdyad+Dagger@ρpdyad)*theta[{1,-tetrad}][expr]+(ρdyad-Dagger@ρdyad)*theta[{2,-tetrad}][expr])/;Or[Length@List@s==0,expr==s];
CommuteGHPOp[theta[{4,-tetrad}],theta[{3,-tetrad}],s___]:=theta[{4,-tetrad}][theta[{3,-tetrad}][expr_]]:>(theta[{3,-tetrad}][theta[{4,-tetrad}][expr]]-expr*(-First@GHPWeightOf[expr]*commutatorexpr2a+Last@GHPWeightOf[expr]*Dagger@commutatorexpr2a)-(-ρpdyad+Dagger@ρpdyad)*theta[{1,-tetrad}][expr]-(ρdyad-Dagger@ρdyad)*theta[{2,-tetrad}][expr])/;Or[Length@List@s==0,expr==s];
CommuteGHPOp[theta[{1,-tetrad}],theta[{3,-tetrad}],s___]:=theta[{1,-tetrad}][theta[{3,-tetrad}][expr_]]:>(theta[{3,-tetrad}][theta[{1,-tetrad}][expr]]-(expr*(First@GHPWeightOf[expr]*commutatorexpr3a+Last@GHPWeightOf[expr]*Dagger@commutatorexpr5a))-Dagger@τpdyad*theta[{1,-tetrad}][expr]-κdyad*theta[{2,-tetrad}][expr]+Dagger@ρdyad*theta[{3,-tetrad}][expr]+σdyad*theta[{4,-tetrad}][expr])/;Or[Length@List@s==0,expr==s];
CommuteGHPOp[theta[{3,-tetrad}],theta[{1,-tetrad}],s___]:=theta[{3,-tetrad}][theta[{1,-tetrad}][expr_]]:>(theta[{1,-tetrad}][theta[{3,-tetrad}][expr]]+(expr*(First@GHPWeightOf[expr]*commutatorexpr3a+Last@GHPWeightOf[expr]*Dagger@commutatorexpr5a))+Dagger@τpdyad*theta[{1,-tetrad}][expr]+κdyad*theta[{2,-tetrad}][expr]-Dagger@ρdyad*theta[{3,-tetrad}][expr]-σdyad*theta[{4,-tetrad}][expr])/;Or[Length@List@s==0,expr==s];
CommuteGHPOp[theta[{2,-tetrad}],theta[{3,-tetrad}],s___]:=theta[{2,-tetrad}][theta[{3,-tetrad}][expr_]]:>
(theta[{3,-tetrad}][theta[{2,-tetrad}][expr]]+expr*(First@GHPWeightOf[expr]*commutatorexpr4a+Last@GHPWeightOf[expr]*Dagger@commutatorexpr4b)-Dagger@κpdyad*theta[{1,-tetrad}][expr]-τdyad*theta[{2,-tetrad}][expr]+ρpdyad*theta[{3,-tetrad}][expr]+Dagger@σpdyad*theta[{4,-tetrad}][expr])/;Or[Length@List@s==0,expr==s];
CommuteGHPOp[theta[{3,-tetrad}],theta[{2,-tetrad}],s___]:=theta[{3,-tetrad}][theta[{2,-tetrad}][expr_]]:>
(theta[{2,-tetrad}][theta[{3,-tetrad}][expr]]-expr*(First@GHPWeightOf[expr]*commutatorexpr4a+Last@GHPWeightOf[expr]*Dagger@commutatorexpr4b)+Dagger@κpdyad*theta[{1,-tetrad}][expr]+τdyad*theta[{2,-tetrad}][expr]-ρpdyad*theta[{3,-tetrad}][expr]-Dagger@σpdyad*theta[{4,-tetrad}][expr])/;Or[Length@List@s==0,expr==s];
CommuteGHPOp[theta[{1,-tetrad}],theta[{4,-tetrad}],s___]:=theta[{1,-tetrad}][theta[{4,-tetrad}][expr_]]:>
(theta[{4,-tetrad}][theta[{1,-tetrad}][expr]]-expr*(First@GHPWeightOf[expr]*commutatorexpr5a+Last@GHPWeightOf[expr]*Dagger@commutatorexpr5b)-τpdyad*theta[{1,-tetrad}][expr]-Dagger@κdyad*theta[{2,-tetrad}][expr]+Dagger@σdyad*theta[{3,-tetrad}][expr]+ρdyad*theta[{4,-tetrad}][expr])/;Or[Length@List@s==0,expr==s];
CommuteGHPOp[theta[{4,-tetrad}],theta[{1,-tetrad}],s___]:=theta[{4,-tetrad}][theta[{1,-tetrad}][expr_]]:>
(theta[{1,-tetrad}][theta[{4,-tetrad}][expr]]+expr*(First@GHPWeightOf[expr]*commutatorexpr5a+Last@GHPWeightOf[expr]*Dagger@commutatorexpr5b)+τpdyad*theta[{1,-tetrad}][expr]+Dagger@κdyad*theta[{2,-tetrad}][expr]-Dagger@σdyad*theta[{3,-tetrad}][expr]-ρdyad*theta[{4,-tetrad}][expr])/;Or[Length@List@s==0,expr==s];
CommuteGHPOp[theta[{2,-tetrad}],theta[{4,-tetrad}],s___]:=theta[{2,-tetrad}][theta[{4,-tetrad}][expr_]]:>
(theta[{4,-tetrad}][theta[{2,-tetrad}][expr]]+expr*(First@GHPWeightOf[expr]*commutatorexpr4b+Last@GHPWeightOf[expr]*Dagger@commutatorexpr4a)-κpdyad*theta[{1,-tetrad}][expr]-Dagger@τdyad*theta[{2,-tetrad}][expr]+σpdyad*theta[{3,-tetrad}][expr]+Dagger@ρpdyad*theta[{4,-tetrad}][expr])/;Or[Length@List@s==0,expr==s];
CommuteGHPOp[theta[{4,-tetrad}],theta[{2,-tetrad}],s___]:=theta[{4,-tetrad}][theta[{2,-tetrad}][expr_]]:>
(theta[{2,-tetrad}][theta[{4,-tetrad}][expr]]-expr*(First@GHPWeightOf[expr]*commutatorexpr4b+Last@GHPWeightOf[expr]*Dagger@commutatorexpr4a)+κpdyad*theta[{1,-tetrad}][expr]+Dagger@τdyad*theta[{2,-tetrad}][expr]-σpdyad*theta[{3,-tetrad}][expr]-Dagger@ρpdyad*theta[{4,-tetrad}][expr])/;Or[Length@List@s==0,expr==s];
CommuteGHPOp[theta[aa_][theta[bb_][expr_]]]:=CommuteGHPOp[theta[aa],theta[bb],expr];
GHPCommutatorsForward[dyad]^=CommuteGHPOp[theta[{#[[1]],-tetrad}],theta[{#[[2]],-tetrad}]]&/@Select[Join@@Outer[List,Range@4,Range@4],#[[1]]>#[[2]]&];
GHPCommutatorsBackward[dyad]^=CommuteGHPOp[theta[{#[[2]],-tetrad}],theta[{#[[1]],-tetrad}]]&/@Select[Join@@Outer[List,Range@4,Range@4],#[[1]]>#[[2]]&];
(* Ordering *)
GHPOrderOfTerm[theta[{i_,-tetrad}][expr_]]:=1+GHPOrderOfTerm[expr];
Module[
(* GHP Ricci equations *){tmpeqs=Evaluate[{theta[{2,-tetrad}][κdyad]==-phi01-psi1-ρdyad*τdyad+σdyad*τpdyad-σdyad*Dagger[τdyad]+ρdyad*Dagger[τpdyad]+theta[{1,-tetrad}][τdyad],theta[{2,-tetrad}][τpdyad]==phi21+psi3-σpdyad*τdyad+ρpdyad*τpdyad-ρpdyad*Dagger[τdyad]+σpdyad*Dagger[τpdyad]+theta[{1,-tetrad}][κpdyad],theta[{3,-tetrad}][κdyad]==-psi0-σdyad*(ρdyad+Dagger[ρdyad])+κdyad*(τdyad+Dagger[τpdyad])+theta[{1,-tetrad}][σdyad],theta[{3,-tetrad}][κpdyad]==-phi22-ρpdyad^2+κpdyad*τdyad+τpdyad*Dagger[κpdyad]-σpdyad*Dagger[σpdyad]+theta[{2,-tetrad}][ρpdyad],theta[{3,-tetrad}][τdyad]==phi02-ρpdyad*σdyad+τdyad^2+κdyad*Dagger[κpdyad]-ρdyad*Dagger[σpdyad]+theta[{2,-tetrad}][σdyad],theta[{3,-tetrad}][τpdyad]==2*lambda+psi2+κdyad*κpdyad-σdyad*σpdyad-ρpdyad*Dagger[ρdyad]+τpdyad*Dagger[τpdyad]+theta[{1,-tetrad}][ρpdyad],theta[{4,-tetrad}][κdyad]==-phi00-ρdyad^2+κdyad*τpdyad+τdyad*Dagger[κdyad]-σdyad*Dagger[σdyad]+theta[{1,-tetrad}][ρdyad],theta[{4,-tetrad}][κpdyad]==-psi4-σpdyad*(ρpdyad+Dagger[ρpdyad])+κpdyad*(τpdyad+Dagger[τdyad])+theta[{2,-tetrad}][σpdyad],theta[{4,-tetrad}][ρpdyad]==phi21-psi3-κpdyad*ρdyad+ρpdyad*τpdyad+κpdyad*Dagger[ρdyad]-τpdyad*Dagger[ρpdyad]+theta[{3,-tetrad}][σpdyad],theta[{4,-tetrad}][σdyad]==-phi01+psi1+κdyad*ρpdyad-ρdyad*τdyad+τdyad*Dagger[ρdyad]-κdyad*Dagger[ρpdyad]+theta[{3,-tetrad}][ρdyad],theta[{4,-tetrad}][τdyad]==2*lambda+psi2+κdyad*κpdyad-σdyad*σpdyad-ρdyad*Dagger[ρpdyad]+τdyad*Dagger[τdyad]+theta[{2,-tetrad}][ρdyad],theta[{4,-tetrad}][τpdyad]==phi20-ρdyad*σpdyad+τpdyad^2+κpdyad*Dagger[κdyad]-ρpdyad*Dagger[σdyad]+theta[{1,-tetrad}][σpdyad]}]},
GHPRicciRules[dyad]^=(Join[tmpeqs,Dagger/@tmpeqs]/.Equal->Rule);
(* GHP Bianchi equations *)
tmpeqs={theta[{3,-tetrad}][psi1]==2*phi12*κdyad-psi0*ρpdyad-2*phi11*σdyad-3*psi2*σdyad+4*psi1*τdyad-phi02*Dagger[ρdyad]-phi00*Dagger[σpdyad]+2*phi01*Dagger[τpdyad]+theta[{1,-tetrad}][phi02]+theta[{2,-tetrad}][psi0]-theta[{3,-tetrad}][phi01],theta[{3,-tetrad}][Dagger[psi1]]==-(phi00*ρpdyad)-phi20*σdyad+2*phi10*τdyad+2*Dagger[psi3]*Dagger[κdyad]-2*phi11*Dagger[ρdyad]-3*Dagger[psi2]*Dagger[ρdyad]-Dagger[psi0]*Dagger[σpdyad]+2*phi01*Dagger[τdyad]+2*Dagger[psi1]*Dagger[τpdyad]+2*theta[{1,-tetrad}][lambda]+theta[{1,-tetrad}][Dagger[psi2]]+theta[{2,-tetrad}][phi00]-theta[{3,-tetrad}][phi10],theta[{3,-tetrad}][psi2]==phi22*κdyad+psi0*κpdyad-phi01*ρpdyad-2*psi1*ρpdyad-phi21*σdyad-2*psi3*σdyad+3*psi2*τdyad+phi02*τpdyad-phi12*Dagger[ρdyad]-phi10*Dagger[σpdyad]+2*phi11*Dagger[τpdyad]+theta[{1,-tetrad}][phi12]+theta[{2,-tetrad}][psi1]+theta[{3,-tetrad}][lambda]-theta[{3,-tetrad}][phi11],theta[{3,-tetrad}][Dagger[psi2]]==-(phi01*ρpdyad)-phi21*σdyad+2*phi11*τdyad+Dagger[psi4]*Dagger[κdyad]+phi00*Dagger[κpdyad]-phi12*Dagger[ρdyad]-2*Dagger[psi3]*Dagger[ρdyad]-phi10*Dagger[σpdyad]-2*Dagger[psi1]*Dagger[σpdyad]+phi02*Dagger[τdyad]+3*Dagger[psi2]*Dagger[τpdyad]+theta[{1,-tetrad}][Dagger[psi3]]+theta[{2,-tetrad}][phi01]+theta[{3,-tetrad}][lambda]-theta[{3,-tetrad}][phi11],theta[{3,-tetrad}][psi3]==2*psi1*κpdyad-2*phi11*ρpdyad-3*psi2*ρpdyad-psi4*σdyad+2*psi3*τdyad+2*phi12*τpdyad-phi22*Dagger[ρdyad]-phi20*Dagger[σpdyad]+2*phi21*Dagger[τpdyad]+theta[{1,-tetrad}][phi22]+2*theta[{2,-tetrad}][lambda]+theta[{2,-tetrad}][psi2]-theta[{3,-tetrad}][phi21],theta[{3,-tetrad}][Dagger[psi3]]==-(phi02*ρpdyad)-phi22*σdyad+2*phi12*τdyad+2*phi01*Dagger[κpdyad]-Dagger[psi4]*Dagger[ρdyad]-2*phi11*Dagger[σpdyad]-3*Dagger[psi2]*Dagger[σpdyad]+4*Dagger[psi3]*Dagger[τpdyad]+theta[{1,-tetrad}][Dagger[psi4]]+theta[{2,-tetrad}][phi02]-theta[{3,-tetrad}][phi12],theta[{4,-tetrad}][phi00]==phi20*κdyad-2*phi10*ρdyad+phi00*τpdyad+2*phi11*Dagger[κdyad]-3*Dagger[psi2]*Dagger[κdyad]+4*Dagger[psi1]*Dagger[ρdyad]-2*phi01*Dagger[σdyad]-Dagger[psi0]*Dagger[τpdyad]+theta[{1,-tetrad}][phi10]-theta[{1,-tetrad}][Dagger[psi1]]+theta[{3,-tetrad}][Dagger[psi0]],theta[{4,-tetrad}][phi01]==phi21*κdyad-2*phi11*ρdyad-phi00*ρpdyad-phi20*σdyad+2*phi10*τdyad+phi01*τpdyad+phi12*Dagger[κdyad]-2*phi11*Dagger[ρdyad]-phi00*Dagger[ρpdyad]-phi02*Dagger[σdyad]+2*phi01*Dagger[τdyad]+phi10*Dagger[τpdyad]+3*theta[{1,-tetrad}][lambda]+theta[{1,-tetrad}][phi11]+theta[{2,-tetrad}][phi00]-theta[{3,-tetrad}][phi10],theta[{4,-tetrad}][phi02]==phi22*κdyad-2*phi12*ρdyad-phi01*ρpdyad-phi21*σdyad+2*phi11*τdyad+phi02*τpdyad+phi00*Dagger[κpdyad]-phi12*Dagger[ρdyad]-2*phi01*Dagger[ρpdyad]-phi10*Dagger[σpdyad]+phi02*Dagger[τdyad]+2*phi11*Dagger[τpdyad]+theta[{1,-tetrad}][phi12]+theta[{2,-tetrad}][phi01]+3*theta[{3,-tetrad}][lambda]-theta[{3,-tetrad}][phi11],theta[{4,-tetrad}][phi11]==phi00*κpdyad-phi21*ρdyad-2*phi10*ρpdyad-phi01*σpdyad+phi20*τdyad+2*phi11*τpdyad+phi22*Dagger[κdyad]-2*phi21*Dagger[ρdyad]-phi10*Dagger[ρpdyad]-phi12*Dagger[σdyad]+2*phi11*Dagger[τdyad]+phi20*Dagger[τpdyad]+theta[{1,-tetrad}][phi21]+theta[{2,-tetrad}][phi10]-theta[{3,-tetrad}][phi20]+3*theta[{4,-tetrad}][lambda],theta[{4,-tetrad}][phi12]==phi01*κpdyad-phi22*ρdyad-2*phi11*ρpdyad-phi02*σpdyad+phi21*τdyad+2*phi12*τpdyad+phi10*Dagger[κpdyad]-phi22*Dagger[ρdyad]-2*phi11*Dagger[ρpdyad]-phi20*Dagger[σpdyad]+phi12*Dagger[τdyad]+2*phi21*Dagger[τpdyad]+theta[{1,-tetrad}][phi22]+3*theta[{2,-tetrad}][lambda]+theta[{2,-tetrad}][phi11]-theta[{3,-tetrad}][phi21],theta[{4,-tetrad}][phi22]==2*phi11*κpdyad-3*psi2*κpdyad+4*psi3*ρpdyad-2*phi12*σpdyad-psi4*τdyad+phi20*Dagger[κpdyad]-2*phi21*Dagger[ρpdyad]+phi22*Dagger[τdyad]+theta[{2,-tetrad}][phi21]-theta[{2,-tetrad}][psi3]+theta[{3,-tetrad}][psi4],theta[{4,-tetrad}][psi0]==-2*phi11*κdyad+3*psi2*κdyad-4*psi1*ρdyad+2*phi10*σdyad+psi0*τpdyad-phi02*Dagger[κdyad]+2*phi01*Dagger[ρdyad]-phi00*Dagger[τpdyad]-theta[{1,-tetrad}][phi01]+theta[{1,-tetrad}][psi1]+theta[{3,-tetrad}][phi00],theta[{4,-tetrad}][psi1]==-(phi21*κdyad)+2*psi3*κdyad-3*psi2*ρdyad+phi00*ρpdyad+phi20*σdyad-psi0*σpdyad-phi01*τpdyad+2*psi1*τpdyad-phi12*Dagger[κdyad]+2*phi11*Dagger[ρdyad]-phi10*Dagger[τpdyad]-theta[{1,-tetrad}][lambda]-theta[{1,-tetrad}][phi11]+theta[{1,-tetrad}][psi2]+theta[{3,-tetrad}][phi10],theta[{4,-tetrad}][Dagger[psi1]]==-(phi20*ρdyad)-phi00*σpdyad+2*phi10*τpdyad+2*phi21*Dagger[κdyad]-Dagger[psi0]*Dagger[ρpdyad]-2*phi11*Dagger[σdyad]-3*Dagger[psi2]*Dagger[σdyad]+4*Dagger[psi1]*Dagger[τdyad]+theta[{1,-tetrad}][phi20]+theta[{2,-tetrad}][Dagger[psi0]]-theta[{4,-tetrad}][phi10],theta[{4,-tetrad}][psi2]==psi4*κdyad-2*psi3*ρdyad+2*phi10*ρpdyad-2*psi1*σpdyad-2*phi11*τpdyad+3*psi2*τpdyad-phi22*Dagger[κdyad]+2*phi21*Dagger[ρdyad]-phi20*Dagger[τpdyad]-theta[{1,-tetrad}][phi21]+theta[{1,-tetrad}][psi3]+theta[{3,-tetrad}][phi20]-2*theta[{4,-tetrad}][lambda],theta[{4,-tetrad}][Dagger[psi2]]==-(phi00*κpdyad)+2*phi10*ρpdyad-phi20*τdyad+Dagger[psi0]*Dagger[κpdyad]+2*phi21*Dagger[ρdyad]-2*Dagger[psi1]*Dagger[ρpdyad]-2*Dagger[psi3]*Dagger[σdyad]-2*phi11*Dagger[τdyad]+3*Dagger[psi2]*Dagger[τdyad]-theta[{2,-tetrad}][phi10]+theta[{2,-tetrad}][Dagger[psi1]]+theta[{3,-tetrad}][phi20]-2*theta[{4,-tetrad}][lambda],theta[{4,-tetrad}][psi3]==2*phi10*κpdyad-psi4*ρdyad-2*phi11*σpdyad-3*psi2*σpdyad+4*psi3*τpdyad-phi20*Dagger[ρpdyad]-phi22*Dagger[σdyad]+2*phi21*Dagger[τdyad]+theta[{1,-tetrad}][psi4]+theta[{2,-tetrad}][phi20]-theta[{4,-tetrad}][phi21],theta[{4,-tetrad}][Dagger[psi3]]==-(phi01*κpdyad)+2*phi11*ρpdyad-phi21*τdyad-phi10*Dagger[κpdyad]+2*Dagger[psi1]*Dagger[κpdyad]+phi22*Dagger[ρdyad]-3*Dagger[psi2]*Dagger[ρpdyad]-Dagger[psi4]*Dagger[σdyad]+phi20*Dagger[σpdyad]-phi12*Dagger[τdyad]+2*Dagger[psi3]*Dagger[τdyad]-theta[{2,-tetrad}][lambda]-theta[{2,-tetrad}][phi11]+theta[{2,-tetrad}][Dagger[psi2]]+theta[{3,-tetrad}][phi21],theta[{4,-tetrad}][Dagger[psi4]]==-(phi02*κpdyad)+2*phi12*ρpdyad-phi22*τdyad-2*phi11*Dagger[κpdyad]+3*Dagger[psi2]*Dagger[κpdyad]-4*Dagger[psi3]*Dagger[ρpdyad]+2*phi21*Dagger[σpdyad]+Dagger[psi4]*Dagger[τdyad]-theta[{2,-tetrad}][phi12]+theta[{2,-tetrad}][Dagger[psi3]]+theta[{3,-tetrad}][phi22]};
GHPBianchiRules[dyad]^=(tmpeqs/.Equal->Rule);
(* NP \[UndirectedEdge] GHP conversion *)
GHPToNPRules[dyad]^={theta[{1,-tetrad}][ηw_]:>(-(First[GHPWeightOf[ηw]]*ϵdyad)-Last[GHPWeightOf[ηw]]*Dagger[ϵdyad])*ηw+pdnp[{1,-tetrad}][ηw],
theta[{2,-tetrad}][ηw_]:>(-(First[GHPWeightOf[ηw]]*γdyad)-Last[GHPWeightOf[ηw]]*Dagger[γdyad])*ηw+pdnp[{2,-tetrad}][ηw],
theta[{3,-tetrad}][ηw_]:>(-(Last[GHPWeightOf[ηw]]*Dagger[αdyad])-First[GHPWeightOf[ηw]]*βdyad)*ηw+pdnp[{3,-tetrad}][ηw],
theta[{4,-tetrad}][ηw_]:>(-(First[GHPWeightOf[ηw]]*αdyad)-Last[GHPWeightOf[ηw]]*Dagger[βdyad])*ηw+pdnp[{4,-tetrad}][ηw]};
NPToGHPRules[dyad]^={pdnp[{1,-tetrad}][ηw_]:>First[GHPWeightOf[ηw]]*ϵdyad*ηw+Last[GHPWeightOf[ηw]]*Dagger[ϵdyad]*ηw+theta[{1,-tetrad}][ηw],
pdnp[{2,-tetrad}][ηw_]:>First[GHPWeightOf[ηw]]*γdyad*ηw+Last[GHPWeightOf[ηw]]*Dagger[γdyad]*ηw+theta[{2,-tetrad}][ηw],
pdnp[{3,-tetrad}][ηw_]:>Last[GHPWeightOf[ηw]]*Dagger[αdyad]*ηw+First[GHPWeightOf[ηw]]*βdyad*ηw+theta[{3,-tetrad}][ηw],
pdnp[{4,-tetrad}][ηw_]:>First[GHPWeightOf[ηw]]*αdyad*ηw+Last[GHPWeightOf[ηw]]*Dagger[βdyad]*ηw+theta[{4,-tetrad}][ηw]};
];
]]

5.3. Conversion

$GHPExtraRules={};
$GHPExtraDyadExpansions={};

CovDsToGHP[expr_,dyad_]:=ToCanonical@Expand[Expand[expr/.CovDDyadRules[dyad]/.NPToGHPSpinCoeffs[dyad]/.CovDDyadRules[dyad]/.CovDNPSpinCoeffRules[dyad]/.NPToGHPSpinCoeffs[dyad]]/.CovDToGHPRules[dyad]//.$GHPExtraRules];

ToGHP[expr_,dyad_]:=ToGHP2[Expand[expr//.cd1_?CovDQ[cd1inds__][cd2_?CovDQ[cd2inds__][T_?xTensorQ[inds___]]]:>cd1[cd1inds][xAct`SymManipulator`Private`ToCovarD[cd2[cd2inds][T[inds]]]]],dyad];ToGHP2[expr_,dyad_]:=Expand[Expand[CovDsToGHP[Expand[expr/.Flatten[EqToRule1/@(DyadExpansionEq[#,dyad]&/@NonScalarTensorsInExprNoDyad[expr,dyad])]],dyad]]//.Flatten[GHPComponentRules[#,dyad]&/@TensorsInExprNoDyad[expr,dyad]]//.$GHPExtraRules];

GHPComponentRules[xAct`SymManipulator`CovarD[cde_?CovDQ,TT_?xTensorQ,vbs_List],dyad_]:=GHPComponentRules[xAct`SymManipulator`CovarD[cde,TT,vbs],dyad]=Module[{lhs=GiveIndicesToTensor[xAct`SymManipulator`CovarD[cde,TT,vbs]],rhs,spin=VBundleOfBasis@dyad},
(* Make sure the GHPWeights and Tex output are set by expanding into dyad *)
DyadExpansionEq[xAct`SymManipulator`CovarD[cde,TT,vbs],dyad];
If[$DyadCalcInfo,Print["Calculating the ",dyad,"components of ",lhs," in GHP form."]];
rhs=xAct`SymManipulator`Private`ExpandCovarD@lhs;
If[Length[Select[SlotsOfTensor[TT],Or[UpIndex[#]===spin,UpIndex[#]===Dagger@spin]&]]>0,rhs=rhs/.EqToRule1@DyadExpansionEq[TT,dyad]/.$GHPExtraDyadExpansions];
Expand[DyadComponents[lhs==Expand[ToCanonical[Expand[Expand[rhs]/.CovDDyadRules[dyad]]/.CovDToGHPRules[dyad]/.NPToGHPSpinCoeffs[dyad]//.$GHPExtraRules]],dyad]/.GHPComponentRules[TT,dyad]//.$GHPExtraRules]/.Equal->Rule];

Older code inactivated

GHPComponentRules[(op_?FundSpinOpQ)[TT_?xTensorQ,extr___],dyad_]:=GHPComponentRules[op[TT,extr],dyad]=Module[{lhs=GiveIndicesToTensor[op[TT,extr]],rhs,spin=VBundleOfBasis@dyad},
(* Make sure the GHPWeights and Tex output are set by expanding into dyad *)
DyadExpansionEq[op[TT,extr],dyad];
If[$DyadCalcInfo,Print["Calculating the ",dyad,"components of ",lhs," in GHP form."]];
rhs=GHPFundSpinopExpandFunction@lhs;
If[Length[Select[SlotsOfTensor[TT],Or[UpIndex[#]===spin,UpIndex[#]===Dagger@spin]&]]>0,rhs=rhs/.EqToRule1@DyadExpansionEq[TT,dyad]/.$GHPExtraDyadExpansions];
Expand[DyadComponents[lhs==Expand[ToCanonical[Expand[Expand[rhs]/.CovDDyadRules[dyad]]/.CovDToGHPRules[dyad]/.NPToGHPSpinCoeffs[dyad]//.$GHPExtraRules]],dyad]/.GHPComponentRules[TT,dyad]//.$GHPExtraRules]/.Equal->Rule];

GHPFundSpinopExpandFunction[expr_]:=ExpandSym[ExpandFundSpinOp@expr,SmartExpand->True]

GHPComponentRules[___]:={};

5.4  Special section for symmetric spinors (NEW in version 5.3)

DefConstantSymbol[NoComponent]

DyadComponentByNumberSymmetric[ϕ_?xTensorQ,{i_?IntegerQ,j_?IntegerQ},dyad_]:=Module[{k=NumOfUnprimedSlotsDyad[dyad]@ϕ,l=NumOfPrimedSlotsDyad[dyad]@ϕ},If[i>k||j>l||i<0||j<0,NoComponent,xAct`SymManipulator`Private`PlaceIndicesInSpinor[ϕ,Flatten[{ConstantArray[{0,-dyad},k-i],ConstantArray[{1,-dyad},i],ConstantArray[{0,-Dagger@dyad},l-j],ConstantArray[{1,-Dagger@dyad},j]},1],{VBundleOfBasis[dyad],Dagger@VBundleOfBasis[dyad]}]]];

AllDyadComponentsSymmetric[T_?xTensorQ,dyad_]:=AllDyadComponentsSymmetric[T,dyad]^=Module[{k=NumOfUnprimedSlotsDyad[dyad][T],l=NumOfPrimedSlotsDyad[dyad][T]},Flatten@Table[xAct`SymManipulator`Private`PlaceIndicesInSpinor[T,Join[Table[{0,-dyad},k-i],Table[{1,-dyad},i],Table[{0,-Dagger@dyad},l-j],Table[{1,-Dagger@dyad},j]],{VBundleOfBasis[dyad],Dagger@VBundleOfBasis[dyad]}],{i,0,k},{j,0,l}]]

GHPWeightRulesSymmetric[SS_?xTensorQ,dyad_]:=AllDyadComponentsSymmetric[SS,dyad]/.TT_?xTensorQ[inds___]:>Module[{dyadinds=Select[{inds},#[[2]]===-dyad&],dyaddginds=Select[{inds},#[[2]]===-Dagger[dyad]&]},UpSet[GHPWeightOf[TT[inds]],{Length@dyadinds-2*(Plus@@(First/@dyadinds)),Length@dyaddginds-2*(Plus@@(First/@dyaddginds))}]];

FormatComponentsSymmetric[dyad_,SS_?xTensorQ,symbform_]:=(AllDyadComponentsSymmetric[SS,dyad]/.TT_?xTensorQ[inds___]:>Module[{dyadinds=Select[{inds},#[[2]]===-dyad&],dyaddginds=Select[{inds},#[[2]]===-Dagger[dyad]&]},UpSet[MakeBoxes[TT[inds],StandardForm],xAct`xTensor`Private`interpretbox[TT[inds],SubscriptBox[PrintAs[TT],StringJoin["",If[Length[dyadinds]>0,symbform@ToString[Plus@@(First/@dyadinds)],""],If[Length[dyaddginds]>0,StringJoin[symbform@ToString[Plus@@(First/@dyaddginds)],"'"],""],""]]]]]);

SetTexComponentsSymmetric[dyad_, SS_?xTensorQ, texform_]:=(AllDyadComponentsSymmetric[SS,dyad]/.TT_?xTensorQ[inds___]:>Module[{dyadinds=Select[{inds},#[[2]]===-dyad&],dyaddginds=Select[{inds},#[[2]]===-Dagger[dyad]&]},UpSet[Tex[TT[inds]],StringJoin[Tex[TT],"_{",If[Length[dyadinds]>0,texform@ToString[Plus@@(First/@dyadinds)],""],If[Length[dyaddginds]>0,StringJoin[texform@ToString[Plus@@(First/@dyaddginds)],"'"],""],"}"]]]);

SetGHPWeightAndFormatSymmetric[SS_?xTensorQ,dyad_]:=(SetGHPWeightAndFormatSymmetric[SS,dyad]^=Module[{},If[$DyadCalcInfo,Print["GHP weights for ",SS," components are generated, ",If[OptionValue[DyadExpansionEq,FormatComponents],"components are formatted, ",""],If[OptionValue[DyadExpansionEq,SetTexComponents],"Tex components are set.",""]]];
GHPWeightRulesSymmetric[SS,dyad];
If[OptionValue[DyadExpansionEq,FormatComponents],FormatComponentsSymmetric[dyad,SS,OptionValue[DefSpinDyad,SymbolFormattingFunction]]];
If[OptionValue[DyadExpansionEq,SetTexComponents],SetTexComponentsSymmetric[dyad,SS,OptionValue[DefSpinDyad,SymbolTexFunction]]];
If[Or[HermitianQ[SS]=!=True,AntihermitianQ[SS]=!=True],GHPWeightRulesSymmetric[Dagger@SS,dyad];If[OptionValue[DyadExpansionEq,FormatComponents],FormatComponentsSymmetric[dyad,Dagger@SS,OptionValue[DefSpinDyad,SymbolFormattingFunction]]];
If[OptionValue[DyadExpansionEq,SetTexComponents],SetTexComponentsSymmetric[dyad,Dagger@SS,OptionValue[DefSpinDyad,SymbolTexFunction]]];
];])

DyadExpansionEq[T_?xTensorQ,dyad_,options:OptionsPattern[]]:=(DyadExpansionEq[T,dyad]^=Module[{X=GiveIndicesToTensor[T],k=NumOfUnprimedSlotsDyad[dyad][T],l=NumOfPrimedSlotsDyad[dyad][T],unprimedinds, primedinds,M},
SetGHPWeightAndFormatSymmetric[T,dyad];
If[$DyadCalcInfo,Print[T," is expanded into ", dyad]];
{unprimedinds, primedinds}=ExtractUnprimedAndPrimed[VBundleOfBasis@dyad][List@@X];
X==Expand[Sum[(-1)^(k-m+l-n)Binomial[k,m]Binomial[l,n]DyadComponentByNumberSymmetric[T,{m,n},dyad]ExpandSym[ImposeSym[Product[SpinorsOfDyad[dyad][[1]][unprimedinds[[M]]],{M,1,m}]Product[SpinorsOfDyad[dyad][[2]][unprimedinds[[M]]],{M,m+1,k}]],SmartExpand->True]ExpandSym[ImposeSym[Product[Dagger[SpinorsOfDyad[dyad][[1]]][primedinds[[M]]],{M,1,n}]Product[Dagger[SpinorsOfDyad[dyad][[2]]][primedinds[[M]]],{M,n+1,l}]],SmartExpand->True],{m,0,k},{n,0,l}]]]
)/;CompatibleSymQ[SlotsOfTensor[T],SymmetryGroupOfTensor@T,{VBundleOfBasis[dyad],Dagger@VBundleOfBasis[dyad]}]

5.5 GHPComponentRules for symmetric spinors (NEW in version 5.3)

Prototype for general CovD :

GHPComponentRules[(op_?FundSpinOpQ)[ϕ_?xTensorQ],dyad_]:=(GHPComponentRules[op[ϕ],dyad]=Module[{i,j,k=NumOfUnprimedSlotsDyad[dyad]@ϕ,l=NumOfPrimedSlotsDyad[dyad]@ϕ,κdyad=GHPSpinCoefficients[dyad][[1]],
ρdyad=GHPSpinCoefficients[dyad][[2]],
σdyad=GHPSpinCoefficients[dyad][[3]],
τdyad=GHPSpinCoefficients[dyad][[4]],
κpdyad=GHPSpinCoefficients[dyad][[5]],
ρpdyad=GHPSpinCoefficients[dyad][[6]],
σpdyad=GHPSpinCoefficients[dyad][[7]],
τpdyad=GHPSpinCoefficients[dyad][[8]],theta=SymbolJoin["Θ",dyad],np=TetradOfDyad[dyad]},
SetGHPWeightAndFormatSymmetric[ϕ,dyad];
SetGHPWeightAndFormatSymmetric[op[ϕ],dyad];
If[$DyadCalcInfo,Print["Calculating the ",dyad,"components of ",op[ϕ]," in GHP form. (Improved code)"]];
Expand[Expand[Flatten[Table[Table[DyadComponentByNumberSymmetric[op[ϕ],{i,j},dyad]->1/((k+1) (l+1))*(
(k-i+1)(l-j+1)(theta[{1,-np}][DyadComponentByNumberSymmetric[ϕ,{i,j},dyad]]+i*ρdyad*DyadComponentByNumberSymmetric[ϕ,{i,j},dyad] + j*Dagger[ρdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j},dyad])
+(k-i+1)j(theta[{3,-np}][DyadComponentByNumberSymmetric[ϕ,{i,j-1},dyad]]+i*τdyad*DyadComponentByNumberSymmetric[ϕ,{i,j-1},dyad] + (l-j+1)*Dagger[τpdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j-1},dyad])
+i(l-j+1)(theta[{4,-np}][DyadComponentByNumberSymmetric[ϕ,{i-1,j},dyad]]+(k-i+1)*τpdyad*DyadComponentByNumberSymmetric[ϕ,{i-1,j},dyad] + j*Dagger[τdyad]*DyadComponentByNumberSymmetric[ϕ,{i-1,j},dyad])
+i j(theta[{2,-np}][DyadComponentByNumberSymmetric[ϕ,{i-1,j-1},dyad]]+(k-i+1)*ρpdyad*DyadComponentByNumberSymmetric[ϕ,{i-1,j-1},dyad] + (l-j+1)*Dagger[ρpdyad]*DyadComponentByNumberSymmetric[ϕ,{i-1,j-1},dyad])
+(k-i+1)(k-i)(l-j+1)*κdyad*DyadComponentByNumberSymmetric[ϕ,{i+1,j},dyad]
+(k-i+1)(k-i)j*σdyad*DyadComponentByNumberSymmetric[ϕ,{i+1,j-1},dyad]
+i(i-1)(l-j+1)*σpdyad*DyadComponentByNumberSymmetric[ϕ,{i-2,j},dyad]
+i(i-1)j*κpdyad*DyadComponentByNumberSymmetric[ϕ,{i-2,j-1},dyad]
+(k-i+1)(l-j+1)(l-j)*Dagger[κdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j+1},dyad]
+i(l-j+1)(l-j)*Dagger[σdyad]*DyadComponentByNumberSymmetric[ϕ,{i-1,j+1},dyad]
+(k-i+1)j(j-1)*Dagger[σpdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j-2},dyad]
+i j (j-1)*Dagger[κpdyad]*DyadComponentByNumberSymmetric[ϕ,{i-1,j-2},dyad])
,{i,0,k+1}],{j,0,l+1}]]//.$GHPExtraRules]/.GHPComponentRules[ϕ,dyad]//.$GHPExtraRules]])/;op===xAct`SymManipulator`Private`TwistName[CovDOfFundSpinOp[op]];

GHPComponentRules[(op_?FundSpinOpQ)[ϕ_?xTensorQ],dyad_]:=(GHPComponentRules[op[ϕ],dyad]=Module[{i,j,k=NumOfUnprimedSlotsDyad[dyad]@ϕ,l=NumOfPrimedSlotsDyad[dyad]@ϕ,κdyad=GHPSpinCoefficients[dyad][[1]],
ρdyad=GHPSpinCoefficients[dyad][[2]],
σdyad=GHPSpinCoefficients[dyad][[3]],
τdyad=GHPSpinCoefficients[dyad][[4]],
κpdyad=GHPSpinCoefficients[dyad][[5]],
ρpdyad=GHPSpinCoefficients[dyad][[6]],
σpdyad=GHPSpinCoefficients[dyad][[7]],
τpdyad=GHPSpinCoefficients[dyad][[8]],theta=SymbolJoin["Θ",dyad],np=TetradOfDyad[dyad]},
SetGHPWeightAndFormatSymmetric[ϕ,dyad];
SetGHPWeightAndFormatSymmetric[op[ϕ],dyad];
If[$DyadCalcInfo,Print["Calculating the ",dyad,"components of ",op[ϕ]," in GHP form. (Improved code)"]];
Expand[Expand[Flatten[Table[Table[DyadComponentByNumberSymmetric[op[ϕ],{i,j},dyad]->(theta[{1,-np}][DyadComponentByNumberSymmetric[ϕ,{i+1,j+1},dyad]]-(k-i)*ρdyad*DyadComponentByNumberSymmetric[ϕ,{i+1,j+1},dyad] -(l-j)*Dagger[ρdyad]*DyadComponentByNumberSymmetric[ϕ,{i+1,j+1},dyad])
+(theta[{2,-np}][DyadComponentByNumberSymmetric[ϕ,{i,j},dyad]]-(i+1)*ρpdyad*DyadComponentByNumberSymmetric[ϕ,{i,j},dyad] -(j+1)*Dagger[ρpdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j},dyad])
-(theta[{3,-np}][DyadComponentByNumberSymmetric[ϕ,{i+1,j},dyad]]-(k-i)*τdyad*DyadComponentByNumberSymmetric[ϕ,{i+1,j},dyad] -(j+1)*Dagger[τpdyad]*DyadComponentByNumberSymmetric[ϕ,{i+1,j},dyad])
-(theta[{4,-np}][DyadComponentByNumberSymmetric[ϕ,{i,j+1},dyad]]-(i+1)*τpdyad*DyadComponentByNumberSymmetric[ϕ,{i,j+1},dyad] -(l-j)*Dagger[τdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j+1},dyad])
+(k-i-1)*κdyad*DyadComponentByNumberSymmetric[ϕ,{i+2,j+1},dyad]
-(k-i-1)*σdyad*DyadComponentByNumberSymmetric[ϕ,{i+2,j},dyad]
-i*σpdyad*DyadComponentByNumberSymmetric[ϕ,{i-1,j+1},dyad]
+i*κpdyad*DyadComponentByNumberSymmetric[ϕ,{i-1,j},dyad]
+(l-j-1)*Dagger[κdyad]*DyadComponentByNumberSymmetric[ϕ,{i+1,j+2},dyad]
-(l-j-1)*Dagger[σdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j+2},dyad]
-j*Dagger[σpdyad]*DyadComponentByNumberSymmetric[ϕ,{i+1,j-1},dyad]
+j*Dagger[κpdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j-1},dyad]
,{i,0,k-1}],{j,0,l-1}]]//.$GHPExtraRules]/.GHPComponentRules[ϕ,dyad]//.$GHPExtraRules]])/;op===xAct`SymManipulator`Private`DivName[CovDOfFundSpinOp[op]];

GHPComponentRules[(op_?FundSpinOpQ)[ϕ_?xTensorQ],dyad_]:=(GHPComponentRules[op[ϕ],dyad]=Module[{i,j,k=NumOfUnprimedSlotsDyad[dyad]@ϕ,l=NumOfPrimedSlotsDyad[dyad]@ϕ,κdyad=GHPSpinCoefficients[dyad][[1]],
ρdyad=GHPSpinCoefficients[dyad][[2]],
σdyad=GHPSpinCoefficients[dyad][[3]],
τdyad=GHPSpinCoefficients[dyad][[4]],
κpdyad=GHPSpinCoefficients[dyad][[5]],
ρpdyad=GHPSpinCoefficients[dyad][[6]],
σpdyad=GHPSpinCoefficients[dyad][[7]],
τpdyad=GHPSpinCoefficients[dyad][[8]],theta=SymbolJoin["Θ",dyad],np=TetradOfDyad[dyad]},
SetGHPWeightAndFormatSymmetric[ϕ,dyad];
SetGHPWeightAndFormatSymmetric[op[ϕ],dyad];
If[$DyadCalcInfo,Print["Calculating the ",dyad,"components of ",op[ϕ]," in GHP form. (Improved code)"]];
Expand[Expand[Flatten[Table[Table[DyadComponentByNumberSymmetric[op[ϕ],{i,j},dyad]->
1/(k+1)(-(k-i+1)*(theta[{1,-np}][DyadComponentByNumberSymmetric[ϕ,{i,j+1},dyad]]
+i*ρdyad*DyadComponentByNumberSymmetric[ϕ,{i,j+1},dyad] 
-(l-j)*Dagger[ρdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j+1},dyad])
+i*(theta[{2,-np}][DyadComponentByNumberSymmetric[ϕ,{i-1,j},dyad]]
+(k-i+1)*ρpdyad*DyadComponentByNumberSymmetric[ϕ,{i-1,j},dyad] 
-(j+1)*Dagger[ρpdyad]*DyadComponentByNumberSymmetric[ϕ,{i-1,j},dyad])
+(k-i+1)*(theta[{3,-np}][DyadComponentByNumberSymmetric[ϕ,{i,j},dyad]]
+i*τdyad*DyadComponentByNumberSymmetric[ϕ,{i,j},dyad] 
-(j+1)*Dagger[τpdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j},dyad])
-i*(theta[{4,-np}][DyadComponentByNumberSymmetric[ϕ,{i-1,j+1},dyad]]
+(k-i+1)*τpdyad*DyadComponentByNumberSymmetric[ϕ,{i-1,j+1},dyad] 
-(l-j)*Dagger[τdyad]*DyadComponentByNumberSymmetric[ϕ,{i-1,j+1},dyad])
-(k-i+1)(k-i)*κdyad*DyadComponentByNumberSymmetric[ϕ,{i+1,j+1},dyad]
+(k-i+1)(k-i)*σdyad*DyadComponentByNumberSymmetric[ϕ,{i+1,j},dyad]
-i(i-1)*σpdyad*DyadComponentByNumberSymmetric[ϕ,{i-2,j+1},dyad]
+i(i-1)*κpdyad*DyadComponentByNumberSymmetric[ϕ,{i-2,j},dyad]
-(k-i+1)(l-j-1)*Dagger[κdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j+2},dyad]
-i(l-j-1)*Dagger[σdyad]*DyadComponentByNumberSymmetric[ϕ,{i-1,j+2},dyad]
+(k-i+1)j*Dagger[σpdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j-1},dyad]
+i*j*Dagger[κpdyad]*DyadComponentByNumberSymmetric[ϕ,{i-1,j-1},dyad])
,{i,0,k+1}],{j,0,l-1}]]//.$GHPExtraRules]/.GHPComponentRules[ϕ,dyad]//.$GHPExtraRules]])/;op===xAct`SymManipulator`Private`CurlName[CovDOfFundSpinOp[op]];

GHPComponentRules[(op_?FundSpinOpQ)[ϕ_?xTensorQ],dyad_]:=(GHPComponentRules[op[ϕ],dyad]=Module[{i,j,k=NumOfUnprimedSlotsDyad[dyad]@ϕ,l=NumOfPrimedSlotsDyad[dyad]@ϕ,κdyad=GHPSpinCoefficients[dyad][[1]],
ρdyad=GHPSpinCoefficients[dyad][[2]],
σdyad=GHPSpinCoefficients[dyad][[3]],
τdyad=GHPSpinCoefficients[dyad][[4]],
κpdyad=GHPSpinCoefficients[dyad][[5]],
ρpdyad=GHPSpinCoefficients[dyad][[6]],
σpdyad=GHPSpinCoefficients[dyad][[7]],
τpdyad=GHPSpinCoefficients[dyad][[8]],theta=SymbolJoin["Θ",dyad],np=TetradOfDyad[dyad]},
SetGHPWeightAndFormatSymmetric[ϕ,dyad];
SetGHPWeightAndFormatSymmetric[op[ϕ],dyad];
If[$DyadCalcInfo,Print["Calculating the ",dyad,"components of ",op[ϕ]," in GHP form. (Improved code)"]];
Expand[Expand[Flatten[Table[Table[DyadComponentByNumberSymmetric[op[ϕ],{i,j},dyad]->
1/(l+1)(-(l-j+1)*(theta[{1,-np}][DyadComponentByNumberSymmetric[ϕ,{i+1,j},dyad]]
+j*Dagger[ρdyad]*DyadComponentByNumberSymmetric[ϕ,{i+1,j},dyad] 
-(k-i)*ρdyad*DyadComponentByNumberSymmetric[ϕ,{i+1,j},dyad])
+j*(theta[{2,-np}][DyadComponentByNumberSymmetric[ϕ,{i,j-1},dyad]]
+(l-j+1)*Dagger[ρpdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j-1},dyad] 
-(i+1)*ρpdyad*DyadComponentByNumberSymmetric[ϕ,{i,j-1},dyad])
+(l-j+1)*(theta[{4,-np}][DyadComponentByNumberSymmetric[ϕ,{i,j},dyad]]
+j*Dagger[τdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j},dyad] 
-(i+1)*τpdyad*DyadComponentByNumberSymmetric[ϕ,{i,j},dyad])
-j*(theta[{3,-np}][DyadComponentByNumberSymmetric[ϕ,{i+1,j-1},dyad]]
+(l-j+1)*Dagger[τpdyad]*DyadComponentByNumberSymmetric[ϕ,{i+1,j-1},dyad] 
-(k-i)*τdyad*DyadComponentByNumberSymmetric[ϕ,{i+1,j-1},dyad])
-(l-j+1)(l-j)*Dagger[κdyad]*DyadComponentByNumberSymmetric[ϕ,{i+1,j+1},dyad]
+(l-j+1)(l-j)*Dagger[σdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j+1},dyad]
-j(j-1)*Dagger[σpdyad]*DyadComponentByNumberSymmetric[ϕ,{i+1,j-2},dyad]
+j(j-1)*Dagger[κpdyad]*DyadComponentByNumberSymmetric[ϕ,{i,j-2},dyad]
-(l-j+1)(k-i-1)*κdyad*DyadComponentByNumberSymmetric[ϕ,{i+2,j},dyad]
-j(k-i-1)*σdyad*DyadComponentByNumberSymmetric[ϕ,{i+2,j-1},dyad]
+(l-j+1)i*σpdyad*DyadComponentByNumberSymmetric[ϕ,{i-1,j},dyad]
+i*j*κpdyad*DyadComponentByNumberSymmetric[ϕ,{i-1,j-1},dyad])
,{i,0,k-1}],{j,0,l+1}]]//.$GHPExtraRules]/.GHPComponentRules[ϕ,dyad]//.$GHPExtraRules]])/;op===xAct`SymManipulator`Private`CurlDgName[CovDOfFundSpinOp[op]];

6. Special Tools

6.1. Operators in factored form

$TexInertScalarOpSortingFunc=SortByGHPOrder;

SetAttributes[InertScalarOp,HoldAll]

Tex[InertScalarOp[x_,func_][expr_]]^:=StringJoin["(",TexFunc[x,func],")",Tex[expr]]

Tex[InertScalarOp[x_,func_][expr_Plus]]^:=StringJoin["(",xAct`SpinFrames`Private`TexFunc[x,func],")(",Tex[expr],")"]

InertScalarOp[x_,0][_]:=0;
InertScalarOp[x_,expr_][0]:=0;

TexFunc[x_,func_Plus]:=StringJoin@@Riffle[TexFuncTerm[x,xAct`xTensor`Private`ListOfFactors@#]&/@List@@($TexInertScalarOpSortingFunc@func),xAct`TexAct`Private`TexOperator[Plus]];

TexFunc[x_,a_*b_]:=StringJoin[Tex[a],xAct`TexAct`Private`TexOpen["("],TexFunc[x,b],xAct`TexAct`Private`TexClose[")"]]/;FreeQ[a,x]

TexFunc[x_,x_]:="";

TexFunc[x_,y_]:=TexFuncTerm[x,{y}];

TexFuncTerm[x_,{x_}]:="1";

TexFuncTerm[x_,{y___,x_,z___}]:=Tex[Times[y,z]];

TexFuncTerm[x_,{covd1_Symbol?CovDQ[inds1__][covd2_Symbol?CovDQ[inds2__][x_]]}]:=StringJoin[xAct`TexAct`Private`TexCovDCombine[covd1,"",IndexList[inds1],$CovDFormat],xAct`TexAct`Private`TexCovDCombine[covd2,"",IndexList[inds2],$CovDFormat]];

TexFuncTerm[x_,{y___,covd1_Symbol?CovDQ[inds1__][covd2_Symbol?CovDQ[inds2__][x_]],z___}]:=StringJoin[xAct`TexAct`Private`TexFactor[Times[y,z]],xAct`TexAct`Private`TexCovDCombine[covd1,"",IndexList[inds1],$CovDFormat],xAct`TexAct`Private`TexCovDCombine[covd2,"",IndexList[inds2],$CovDFormat]];

TexFuncTerm[x_,{covd_Symbol?CovDQ[inds__][x_]}]:=xAct`TexAct`Private`TexCovDCombine[covd,"",IndexList[inds],$CovDFormat];

TexFuncTerm[x_,{y___,covd_Symbol?CovDQ[inds__][x_],z___}]:=StringJoin[Tex[Times[y,z]],xAct`TexAct`Private`TexCovDCombine[covd,"",IndexList[inds],$CovDFormat]];

TexFuncTerm[x_,{InertScalarOp[y_,func_][covd_Symbol?CovDQ[inds__][x_]]}]:=StringJoin["(",TexFunc[y,func],")",xAct`TexAct`Private`TexCovDCombine[covd,"",IndexList[inds],$CovDFormat]];

TexFuncTerm[x_,{InertScalarOp[y_,func_][x_]}]:=StringJoin["(",TexFunc[y,func],")"];

TexFuncTerm[x_,{InertScalarOp[y1_,func1_][InertScalarOp[y2_,func2_][x_]]}]:=StringJoin["(",TexFunc[y1,func1],")(",TexFunc[y2,func2],")"];

BoxStartWithMinusQ=MatchQ[#,RowBox[{"-"|_?#0,__}]]&;

MakeBoxes[InertScalarOp[x_,func_][expr_],StandardForm]:=
With[{x0=Evaluate@Coefficient[func,x,0],x1=Evaluate@Coefficient[func,x,1]},If[(Expand[func-x0-x*x1]==0)===True,With[{x1box=MakeBoxes[x1,StandardForm]},xAct`xTensor`Private`interpretbox[InertScalarOp[x,func][expr],RowBox[{"(",If[x0=!=0,MakeBoxes[x0,StandardForm]/.MakeBoxes[x,StandardForm]->"",""],If[x1=!=0,Sequence@@{If[BoxStartWithMinusQ[x1box],"","+"],x1box},""],")",MakeBoxes[expr,StandardForm]}]]],
xAct`xTensor`Private`interpretbox[InertScalarOp[x,func][expr],RowBox[{"(",MakeBoxes[func,StandardForm]/.MakeBoxes[x,StandardForm]->"•",")",MakeBoxes[expr,StandardForm]}]]
]]

GHPWeightOf[y:InertScalarOp[x_,func_][expr_]]:=GHPWeightOf[Evaluate[y/.InertScalarOp->Function]]

7. End private and package

End[];
EndPackage[];

8. Examples

The user context is empty :

?Global`*

Define a manifold

$DefInfoQ=False;

$CVVerbose=False;

SetOptions[AutomaticRules,Verbose->False];

DefManifold[M4,4,{a,b,c,d,f,h,l,m,p,q}]

DefMetric[{1,3,0},g[-a,-b],CD,{";","▽"}]

Off[ValidateSymbol::"capital"]

SetOptions[DefAbstractIndex,PrintAs->PrimeDagger]

DefSpinStructure[g,Spin,{A,B,C,D,F,H,L,M,P,Q,R,S},ϵ,σ,CDe,{";","▽"},SpinorPrefix->SP,SpinorMark->"S"]

Follow Penrose Rindler sign conventions ($RiemannSign is opposite to the conventions of Wald)

$RiemannSign=-1;

{PrintAs[PsiCDe]^="Ψ",PrintAs[PhiCDe]^="Φ",PrintAs[LambdaCDe]^="Λ"};

xAct`SpinFrames`Private`PrintDaggerAsBar/@{ϵ,PsiCDe}

DefNPTetrad[NP,{lNP[a],nNP[a],mNP[a]}]

{PDNP[{1, -NP}][lNP[a]],PDNP[{2, -NP}][lNP[a]],PDNP[{3, -NP}][lNP[a]],PDNP[{4, -NP}][lNP[a]]}

DefSpinDyad[Dyad,{o[A],ι[A]},NP]

DyadToBasisRules[Dyad]

BasisToDyadRules[Dyad]

{o[-A],ι[-A],o†[-A†],ι†[-A†],o[A],ι[A],o†[A†],ι†[A†]}

ToValues[TraceBasisDummy/@SeparateBasis[Dyad]/@SeparateBasis[Dyad†]/@%]==(%/.DyadToBasisRules[Dyad])

{o[-A],ι[-A],o†[-A†],ι†[-A†],o[A],ι[A],o†[A†],ι†[A†]}

(ToValues[TraceBasisDummy/@SeparateBasis[Dyad]/@SeparateBasis[Dyad†]/@%]/.BasisToDyadRules[Dyad])==%

DefSpinor[κ[-A],M4]

DyadExpansionEq[κ,Dyad]

InertScalarOp[x,ΘDyad[{1,-NP}][x]+3ρDyad[]*x]@InertScalarOp[x,ΘDyad[{4,-NP}][x]+ τpDyad[]*x][κ[{0,-Dyad}]]

TexPrint@%

%%/.InertScalarOp->Function