  We study a wide class of topological free-fermion systems on a hypercubic
lattice in spatial dimensions $d\ge 1$. When the Fermi level lies in a spectral
gap or a mobility gap, the topological properties, e.g., the integral
quantization of the topological invariant, are protected by certain symmetries
of the Hamiltonian against disorder. This generic feature is characterized by a
generalized index theorem which is a noncommutative analogue of the
Atiyah-Singer index theorem. The noncommutative index defined in terms of a
pair of projections gives a precise formula for the topological invariant in
each symmetry class in any dimension ($d \ge 1$). Under the assumption on the
nonvanishing spectral or mobility gap, we prove that the index formula
reproduces Bott periodicity and all of the possible values of topological
invariants in the classification table of topological insulators and
superconductors. We also prove that the indices are robust against
perturbations that do not break the symmetry of the unperturbed Hamiltonian.
