It has been argued that any test of quantum contextuality is nullified by the fact that perfect orthogonality and perfect compatibility cannot be achieved in finite precision experiments. We introduce experimentally testable two-qutrit violations of inequalities for noncontextual theories in which compatibility is guaranteed by the fact that measurements are performed on separated qutrits. The inequalities are inspired by the basic building block of the Kochen-Specker proof of quantum contextuality for a qutrit, despite the fact that their proof is completely independent of it.
The output randomness from a random number generator can be certified by observing the violation of quantum contextuality inequalities based on the Kochen-Specker theorem. Contextuality can be tested in a single quantum system, which significantly simplifies the experimental requirements to observe the violation comparing to the ones based on nonlocality tests. However, it is not yet resolved as to how to ensure compatibilities for sequential measurements that is required in contextuality tests. Here, we employ a modified Klyachko-Can-Binicio\ifmmode \breve{g}\else \u{g}\fi{}lu-Shumovsky contextuality inequality, which can ease the strict compatibility requirement on measurements. On a trapped single
138Ba+ ion system, we experimentally demonstrate violation of the contextuality inequality and realize quantum random number expansion by closing detection loopholes. We perform $1.29\ifmmode\times\else\texttimes\fi{}{10}^{8}$ trials of experiments and extract a randomness of $5.28\ifmmode\times\else\texttimes\fi{}{10}^{5}$ bits with a speed of $270\phantom{\rule{0.2em}{0ex}}\mathrm{bits}\phantom{\rule{0.2em}{0ex}}{\mathrm{s}}^{\ensuremath{-}1}$. Our demonstration paves the way for practical high-speed spot-checking quantum random number expansion and other secure information processing applications.