There are two major theoretical issues for the star formation law (the relation between the surface densities of molecular gas and star formation rate on a galaxy scale): (i) At low metallicity, it is not obvious that star-forming regions are rich in H 2 because the H 2 formation rate depends on the dust abundance; and (ii) whether or not CO really traces H 2 is uncertain, especially at low metallicity. To clarify these issues, we use a hydrodynamic simulation of an isolated disc galaxy with a spatial resolution of a few tens parsecs. The evolution of dust abundance and grain size distribution is treated consistently with the metal enrichment and the physical state of the interstellar medium. We compute the H 2 and CO abundances using a subgrid post-processing model based on the dust abundance and the dissociating radiation field calculated in the simulation. We find that when the metallicity is 0.4 Z ⊙ (t < 1 Gyr), H 2 is not a good tracer of star formation rate because H 2 -rich regions are limited to dense compact regions. At Z 0.8 Z ⊙ , a tight star formation law is established for both H 2 and CO. At old (t ∼ 10 Gyr) ages, we also find that adopting the so-called MRN grain size distribution with an appropriate dust-to-metal ratio over the entire disc gives reasonable estimates for the H 2 and CO abundances. For CO, improving the spatial resolution of the simulation is important while the H 2 abundance is not sensitive to sub-resolution structures at Z 0.4 Z ⊙ .