  We provide the first systematic technique for deriving witnesses of
contextuality in prepare-transform-measure scenarios. More specifically, we
show how linear quantifier elimination can be used to compute a polytope of
correlations consistent with generalized noncontextuality in such scenarios.
This polytope is specified as a set of noncontextuality inequalities that are
necessary and sufficient conditions for observed data in the scenario to admit
of a classical explanation relative to any linear operational identities, if
one ignores some constraints from diagram preservation. While including these
latter constraints generally leads to tighter inequalities, it seems that
nonlinear quantifier elimination would be required to systematically include
them. We also provide a linear program which can certify the nonclassicality of
a set of numerical data arising in a prepare-transform-measure experiment. We
apply our results to get a robust noncontextuality inequality for
transformations that can be violated within the stabilizer subtheory. Finally,
we give a simple algorithm for computing all the linear operational identities
holding among a given set of states, of transformations, or of measurements.
