  (Abridged) Aims & Methods. A two-dimensional, semi-analytical model is
presented that follows, for the first time, the chemical evolution from a
collapsing molecular cloud (a pre-stellar core) to a protostar and
circumstellar disk. The model computes infall trajectories from any point in
the cloud and tracks the radial and vertical motion of material in the
viscously evolving disk. It includes a full time-dependent radiative transfer
treatment of the dust temperature, which controls much of the chemistry. A
small parameter grid is explored to understand the effects of the sound speed
and the mass and rotation of the cloud. The freeze-out and evaporation of
carbon monoxide (CO) and water (H2O), as well as the potential for forming
complex organic molecules in ices, are considered as important first steps to
illustrate the full chemistry.
  Results. Both species freeze out towards the centre before the collapse
begins. Pure CO ice evaporates during the infall phase and re-adsorbs in those
parts of the disk that cool below the CO desorption temperature of ~18 K. H2O
remains solid almost everywhere during the infall and disk formation phases and
evaporates within ~10 AU of the star. Mixed CO-H2O ices are important in
keeping some solid CO above 18 K and in explaining the presence of CO in
comets. Material that ends up in the planet- and comet-forming zones of the
disk is predicted to spend enough time in a warm zone during the collapse to
form first-generation complex organic species on the grains. The dynamical
timescales in the hot inner envelope (hot core or hot corino) are too short for
abundant formation of second-generation molecules by high-temperature gas-phase
chemistry.
