(* Here we check the first part of the main theorem for 0≤r≤5. *)

s[0]=0;s[1]=1;
s[n_]:=If[EvenQ[n],s[n/2],s[Floor[n/2]]+s[Ceiling[n/2]]];
SternRow[r_]:=Map[s,Range[(2^r),(2^(r+1))]];
OrderedSRow[r_]:=OrderedSRow[r]=Union[SternRow[r]];
L[m_,r_]:=If[m>Length[OrderedSRow[r]],-∞,OrderedSRow[r][[-m]]];

For[r=0,r≤5,r++,
Print[Table[L[m,r],{m,1,Ceiling[r/2]}]==Reverse[Union[Table[Fibonacci[r+2]-Fibonacci[i]Fibonacci[r-1-i],{i,0,r-1}]]]]
]

(* Here we calculate some matrix products. *)

Mat2=(({{F[p0+1], F[p0]}, {F[p0], F[p0-1]}})).(({{2, 1}, {1, 0}})).(({{F[p1+1], F[p1]}, {F[p1], F[p1-1]}}));

Mat3=(({{F[p0+1], F[p0]}, {F[p0], F[p0-1]}})).(({{3, 1}, {1, 0}})).(({{F[p1+1], F[p1]}, {F[p1], F[p1-1]}}));

Mat22=(({{F[p0+1], F[p0]}, {F[p0], F[p0-1]}})).(({{2, 1}, {1, 0}})).(({{F[p1+1], F[p1]}, {F[p1], F[p1-1]}})).(({{2, 1}, {1, 0}})).(({{F[p2+1], F[p2]}, {F[p2], F[p2-1]}}));

kappa2=Expand[Mat2[[1,1]]]

kappa3=Expand[Mat3[[1,1]]]

kappa22=Expand[Mat22[[1,1]]]

(* Now we check the stated Fibonacci identities for kappa1, kappa2, kappa3 defined above. *)

kappa2newform1=F[p0+p1+3]-F[p0]F[p1];
kappa2newform2=F[p0+p1+2]+F[p0+p1]+F[p0-1]F[p1-1];
kappa3newform=F[p0+p1+3]+F[p0+p1+1]-2F[p0+p1-2]-2F[p0-2]F[p1-2];
kappa22newform=(F[p0+p1+p2+4]+F[p0+p1+p2+2]-F[p0+p1+p2-4])-(F[p1](F[p0-1]F[p2-1]+3F[p0-2]F[p2-1]+3F[p0-1]F[p2-2])+2F[p0-2]F[p1+1]F[p2-2]);

rule1={
F[p0+2]->F[p0]+F[p0+1],
F[p0-1]->F[p0+1]-F[p0],
F[p0-2]->2F[p0]-F[p0+1],
F[p1+2]->F[p1]+F[p1+1],
F[p1-1]->F[p1+1]-F[p1],
F[p1-2]->2F[p1]-F[p1+1],
F[p2+2]->F[p2]+F[p2+1],
F[p2-1]->F[p2+1]-F[p2],
F[p2-2]->2F[p2]-F[p2+1],
F[p2-3]->2F[p2+1]-3F[p2]
};

rule2={
F[p0+p1]->F[p0] F[p1-1]+F[p0+1] F[p1],
F[p0+p1+1]->F[p0] F[p1]+F[p0+1] F[p1+1],
F[p0+p1+2]->F[p0] F[p1+1]+F[p0+1] F[p1+2],
F[p0+p1+3]->F[p0+1] F[p1+1]+F[p0+2] F[p1+2],
F[p0+p1-1]->F[p0-1] F[p1-1]+F[p0] F[p1],
F[p0+p1-2]->F[p0-1] F[p1-2]+F[p0] F[p1-1]
};

rule3={
F[p0+p1+p2]->F[p0+p1+1]F[p2]+F[p0+p1]F[p2-1],
F[p0+p1+p2+2]->F[p0+p1+1]F[p2+2]+F[p0+p1]F[p2+1],
F[p0+p1+p2+4]->F[p0+p1+3]F[p2+2]+F[p0+p1+2]F[p2+1],
F[p0+p1+p2-2]->F[p0+p1+1]F[p2-2]+F[p0+p1]F[p2-3],
F[p0+p1+p2-4]->F[p0+p1-1]F[p2-2]+F[p0+p1-2]F[p2-3]
};

Expand[
ReplaceAll[ReplaceAll[kappa2-kappa2newform1,rule2],rule1]]

Expand[ReplaceAll[ReplaceAll[kappa2-kappa2newform2,rule2],rule1]]

Expand[ReplaceAll[ReplaceAll[kappa3-kappa3newform,rule2],rule1]]

Expand[ReplaceAll[ReplaceAll[ReplaceAll[kappa22-kappa22newform,rule3],rule2],rule1]]