(* This file contains code for computing the different possible combinatorial types of for the Correlated Equilibria polytopes of 2x3 games. 
 This file contains part of the computational proof of Theorem 5.7 in our paper. *)
SetDirectory[NotebookDirectory[]];
y = {{Subsuperscript[Y,1,1], Subsuperscript[Y,2,1], Subsuperscript[Y, 3,1]},{Subsuperscript[Y,1,2], Subsuperscript[Y,2,2]}};

(* In Macaulay2 we computed the algebraic boundary for the oriented matroid strata which is given by the following 12 polynomials *)
Irreducibles ={ 
y[[1, 1]][1, 2],
y[[1, 2]] [1 ,2],
y[[1, 3]][1, 2],
y[[2, 1]][1, 2],
y[[2 ,2]][1, 2],
y[[2, 1]][1, 3],
y[[2, 2]][1, 3],
y[[2, 1]][2, 3],
y[[2, 2]][2, 3],
y[[2,2]][1,2]*y[[2,1]][2,3]-y[[2,1]][1,2]*y[[2,2]][2,3],
y[[2,2]][1,2]*y[[2,1]][1,3]-y[[2,1]][1,2]*y[[2,2]][1,3],
y[[2,2]][1,3]*y[[2,1]][2,3]-y[[2,1]][1,3]*y[[2,2]][2,3]
};

(* We can consider every possible sign configuration of these polynomials. Some of these signings may not give an oriented matroid and thus the region cut out by signVector.irreducibles > 0 may be empty. In this case we can throw out this sign vector when considering combinatorial types. On each nonempty region, we know that any solution Y gives us the same oriented matroid and thus the same combinatorial type so we simply record a single represenative. *)
signs = Tuples[{1,-1}, 12];
strataReps= {};
(* These equations correspond to the Correlated Equilibria space for 2x3 games as explained in Definition 3.2. We must make sure the Y's we find satisfy these equations or else we may get polytopes that don't actually correspond to correlated equilibria. *)
eqs = {y[[2,1]][1,2]+y[[2,1]][2,3]==y[[2,1]][1,3] ,y[[2,2]][1,2]+y[[2,2]][2,3]==y[[2,2]][1,3]};

Do[
sign = signs[[i]];
ineqs = Table[sign[[j]]*Irreducibles[[j]] > 0,{j, 1, 12}];

rep = FindInstance[Join[ineqs, eqs],{y[[1, 1]][1, 2],y[[1, 2]] [1 ,2],y[[1, 3]][1, 2],y[[2, 1]][1, 2],y[[2 ,2]][1, 2],y[[2, 1]][1, 3],y[[2, 2]][1, 3],y[[2, 1]][2, 3],y[[2, 2]][2, 3]}];

If[Length[rep] > 0, 
rep = {y[[1, 1]][1, 2],y[[1, 2]] [1 ,2],y[[1, 3]][1, 2],y[[2, 1]][1, 2],y[[2 ,2]][1, 2],y[[2, 1]][1, 3],y[[2, 2]][1, 3],y[[2, 1]][2, 3],y[[2, 2]][2, 3]} /. rep[[1]],
Continue[]
];


AppendTo[strataReps, rep];

,{i, 1, Length[signs]}];

(* This saves the strataReps as a text file which we can then read into SageMath. We will now use SageMath to determine the combinatorial type of each polytope. *)
Save["strataReps2x3.txt",strataReps]