  For eight-dimensional quantum systems there is a Kochen-Specker (KS) set of
40 quantum yes-no tests that is related to the Greenberger-Horne-Zeilinger
(GHZ) proof of Bell's theorem. Here we experimentally implement this KS set
using an eight-dimensional Hilbert space spanned by the transverse momentum of
single photons. We show that the experimental results of these tests violate a
state-independent noncontextuality inequality. In addition, we show that, if
the system is prepared in states that are formally equivalent to a three-qubit
GHZ and $W$ states, then the results of a subset of 16 tests violate a
noncontextuality inequality that is formally equivalent to the three-party
Mermin's Bell inequality, but for single eight-dimensional quantum systems.
These experimental results highlight the connection between quantum
contextuality and nonlocality for eight-dimensional quantum systems.
