(* This file contains code for computing the region of full dimensionality for the Correlated Equilibria polytopes of 2x2 games which is used in Example 4.3 of our paper. 
This idea in general is discussed in Section 4 of our paper. *)

(* This creates a list of indeterminates with appropriate upper and lower subscripts*)
y = {{Subsuperscript[Y,1,1], Subsuperscript[Y,2,1]},{Subsuperscript[Y,1,2], Subsuperscript[Y,2,2]}};

(* This is the matrix A(Y) which is described in Section 4. This is simply the matrix whose rows are the inequalities which cut out the correlated equilibria cone of a 2x2 game for any given Y. *)
A ={{y[[1,1]][1,2], y[[1,2]][1,2], 0, 0},
	 {0, 0,-y[[1,1]][1,2], -y[[1,2]][1,2]},
	 {y[[2,1]][1,2], 0, y[[2,2]][1,2], 0},
          {0, -y[[2,1]][1,2], 0,  -y[[2,2]][1,2]},
	{1, 0, 0, 0},
         {0, 1, 0, 0},
         {0, 0, 1, 0},
         {0, 0, 0, 1}};
A//MatrixForm

(* The cone C(Y) is full dimensional if and only if there is a point in its relative interior meaning there exists p such that A(y)p 0. The following code performs quantifier elimination to determine which Y's guarantee this condition *)
p = {p11, p12, p21, p22};

(* This makes the list of inequalities Ap > 0 *)
ineqs= Table[(A.p)[[i]]> 0, {i,1, 8}];

(* This eliminates the euqnaitfier and computes the inequalities in the space of Y's.*)
(* As expected, the resulting semialgebraic set consists of two orthants *)
Reduce[Exists[{p11, p12, p21, p22}, ineqs], Reals]