This proves the theorem for (two qubits) and then for every . The case needs a different construction and is proved by Kochen and Specker.
Product rule. If and commute, they have a common eigenbasis, so there is a Hermitian (with distinct eigenvalues on that basis) and functions with , , and . Condition 2 gives . By induction the same holds for any number of mutually commuting operators.
The square.
Every entry has eigenvalues . The three entries of each row commute, as do those of each column, and using , one checks that each row multiplies to and each column to (for example the third row gives , and the third column ).
Contradiction. Suppose exists and let be the value of the entry in row , column . By the product rule and , for each row and for each column. Multiplying all three row equations gives ; multiplying all three column equations gives . Each is the value of one fixed operator, the same in its row and its column — this is where noncontextuality enters — so both products are the same number. Contradiction.
Larger dimensions. The two forms of the theorem are equivalent: a valuation of observables gives values to projectors with (the are functions of ), and conversely a projector valuation defines as the eigenvalue whose spectral projector has value 1. Now let and suppose a projector valuation exists on . In any orthonormal basis exactly one vector has ; let be spanned by and three other vectors of that basis, with projector , so (complete with the remaining basis vectors, all of value 0). For any orthogonal projectors on summing to , completing the family with , which has value , gives . So restricts to a projector valuation on the four-dimensional space , which the square has ruled out.