Algorithm to check Gibbs' Phase Rule
The gibbs phase rule is simply a way of determining whether the system of equations which describes the system will be overdetermined.
As we are talking about (usually) solids, this system of equations looks like $K=A^nB^m...$
If we take the log of both sides, this can be simplified to $\log{k}=n\log{A}+m\log{B}...$.
If we substitute $a=\log{A}, b=\log{B}$ then this becomes a system of linear equations $\log{k}=n*a+m*b...$
Now we can represent this system of linear of equations as a coefficient matrix and then use the Rouche Cappeli Theorem to determine whether the system is overdetermined. Since each species each unique in your system, you simply need to determine if there are any rank deficiencies in your coefficient matrix.
In the first example: {[0, 1, 2], [0, 2], [1, 2]} can be represented as the matrix
$$\begin{bmatrix}
1 &amp; 1 &amp; 1\\
1 &amp; 0 &amp; 1\\
0 &amp; 1 &amp; 1\\
0 &amp; 1 &amp; 0
\end{bmatrix}$$
Which has a rank deficiency, therefore is overdetermined.