(* Set quotient *)
Q[A_,B_]:=Flatten[Table[a/b,{a,A},{b,B}]]

(*Class in K-theory*)
F[A_]:=Product[1-1/a,{a,A}]

(* Variables *)
Z={z1,z2};
T={t1,t2};

(* Roots of G2 *)
positive={{2,-1},{1,0},{1,1},{0,1},{-1,2},{1,-1}};
Pnegative={-1,1};
negative=-positive;
tangent= Complement[negative,{Pnegative}];
(* get monomial *)
weight[w_]:=Product[u,{u,{t1,t2}^w}]

(* get vector on the plane *)
planecoordinates[v_]:=v[[1]] {1,Sqrt[3]}+v[[2]] {-1,Sqrt[3]}

(* picture of the root system *)
arrow[v_]:={Arrowheads[{{.1,1}}],Arrow[{{0,0},planecoordinates[v]}],Text[Style[weight[v],Medium,Black],1.1 planecoordinates[v]]}
Graphics[Join[{Green},{arrow[Pnegative]},{Red},Table[arrow[v],{v,tangent}],{Black},Table[arrow[v],{v,positive}]]]

(*  60 degrees rotation *)
r=Transpose[{{0,1},{-1,1}}];
drawvectors[A_]:=Graphics[Join[{Red},Table[arrow[v],{v,A}],{Black}]]

(* The points of G2/P indexed by the rotations *)
points={IdentityMatrix[2],r,r.r,r.r.r,r.r.r.r,r.r.r.r.r};
tangentweights[a_]:=Table[a.x,{x,tangent}]
euler[a_]:=F[Table[Product[factor,{factor,T^v}],{v,tangentweights[a]}]]
arguments[a_]:={Product[factor,{factor,T^-tangentweights[a][[3]]}],Product[factor,{factor,T^-tangentweights[a][[4]]}]}
(* Picture *)
MatrixForm[Table[{MatrixForm[a],Show[drawvectors[tangentweights[a]],ImageSize->{150,150}],f[arguments[a]]/euler[a]},{a,points}]]

(* Example of a push-forward *)
function[aa_]:=aa[[1]]^5aa[[2]]+aa[[1]]aa[[2]]^5
function[{t1, t2}]
Expand[Factor[Sum[function[arguments[a]]/euler[a],{a,points}]]]

(* Grothendieck polynomials in inverses of variables *)
grothendieck[a_,t_]:=Factor[(1-t[[1]])^(a[[1]]+1) (1-t[[2]])^a[[2]]/(1-t[[1]]/t[[2]])+(1-t[[2]])^(a[[1]]+1) (1-t[[1]])^a[[2]]/(1-t[[2]]/t[[1]])]

(* Partitions contained in 5 x 2 rectangle *)
partitionlist=Select[Flatten[Table[Table[{a-b,b},{b,0,a/2}],{a,0,10}],1],#[[1]]<6&]

(* list of Grothendieck polynomials *)
grothendiecklist=Table[grothendieck[partition,{z1,z2}],{partition,partitionlist}];
Do[Print[partitionlist[[i]]," -> ",grothendiecklist[[i]]],{i,1,21}]

(* weights of torus Grass(2,7) *)
 TT={t1,t2,t1 /t2,1,t2 /t1,t2^-1,t1^-1};
(* fixed points on Grass(2,7) *)
points27=Subsets[TT,{2}];

(* push-forward of products *)
g27[i_,j_]:=Factor[Sum[( grothendiecklist[[i]]grothendiecklist[[j]]/.{z1->pt[[1]],z2->pt[[2]]})/F[Q[Complement[TT,pt],pt]],{pt,points27}]];
(* Intersection form in the basis of Grothendieck polynomials *)
Monitor[intersectionform=Table[g27[i,j],{i,1,21},{j,1,21}],{i,j}];

TableForm[intersectionform/.{t1->1,t2->1},TableHeadings->{partitionlist.{10,1},partitionlist.{10,1}},TableSpacing->{2,2}]

(* list of push-forwards of Grothendieck polynomials from G2/P *)
pushgroth[i_]:=Factor[Sum[grothendieck[i,arguments[a]]/euler[a],{a,points}]];
listpushgroth=Table[pushgroth[i],{i,partitionlist}];
listpushgroth/.{t1->1,t2->1}
Do[Print[partitionlist[[i]]," -> ",Expand[listpushgroth[[i]]]],{i,1,21}]

(* coefficients of the fundamental class of [G2/P] in Grass(2,7) *)
coefficients=LinearSolve[intersectionform,listpushgroth];
Sum[Expand[coefficients[[i]]] G[partitionlist[[i]]],{i,1,21}]
fundamentalclass=Factor[Sum[coefficients[[i]] grothendieck[partitionlist[[i]],{z1 ,z2  }],{i,1,21}]];

(* Product form *)
(z1 z2 (1-z1) (1-z2) (1-z1 z2))Expand[Factor[fundamentalclass/(z1 z2 (1-z1) (1-z2) (1-z1 z2))]]

(* Nonequivariant class *)
fundamentalclass/.{t1->1,t2->1}

(* fundamental Class in cohomology *)
Factor[SeriesCoefficient[fundamentalclass/.{t1->E^(-h t1),t2->E^(-h t2),z1->E^(-h x1),z2->E^(-h x2)},{h,0,5}]]

(* Values of the push-forward of Grothendiecks in the variables A, B *)
A=3-(t1+1/t2+t2/t1);
B=3-(1/t1+t1/t2+t2);
a=Numerator[Factor[z1-A -B]];
b=Numerator[Factor[z2-A B]];
c=z0-t1 t2;
ideal={a,b,c};
vars=Variables[ideal];

Do[Q=Numerator[Factor[listpushgroth[[i]]]];
S=Denominator[Factor[listpushgroth[[i]]]]/.{t1->z0,t2->1};
Print[partitionlist[[i]]," --> ",Factor[Last[PolynomialReduce[Q,GroebnerBasis[ideal,vars],vars]]/S/.{z1->e,z2->f}]],{i,1,21}]
Print["e=A+B, f=AB"]

(* the intersection matrix in the variables e=A+B and f=AB *)
Monitor[Do[If[i>j,intersectionformAB[i,j]=".",Q=Numerator[Factor[intersectionform[[i,j]]]];
S=Denominator[Factor[intersectionform[[i,j]]]]/.{t1->z0,t2->1};
intersectionformAB[i,j]=Factor[Last[PolynomialReduce[Q,GroebnerBasis[ideal,vars],vars]]/S/.{z1->e,z2->f}]],{i,1,21},{j,1,21}],{i,j}]
intersectionformX=Table[intersectionformAB[i,j],{i,1,21},{j,1,21}];
Print["Determinant = ",Det[intersectionform]]

Style[TableForm[intersectionformX,TableHeadings->{partitionlist.{10,1},partitionlist.{10,1}},TableSpacing->{2,0.4}],Small]

(* The entries appearing in the intersection form *)
Column[Union[Flatten[intersectionformX]]]