We present the results of millimeter observations and a suitable chemical and radiative transfer model of the AB Aurigae (HD 31293) circumstellar disk and surrounding envelope. The integral molecular content of this system is studied by observing CO, C18O, CS, HCO+, DCO+, H2CO, HCN, HNC, and SiO rotational lines with the IRAM 30 m antenna, while the disk is mapped in the HCO+ (1-0) transition with the Plateau de Bure Interferometer. Using a flared disk model with a vertical temperature gradient and an isothermal spherical envelope model with a shadowed midplane and two unshielded cones together with a gas-grain chemical network, time-dependent abundances of observationally important molecules are calculated. Then a two-dimensional non-LTE line radiative transfer code is applied to compute excitation temperatures of several rotational transitions of HCO+, CO, C18O, and CS molecules. We synthesize the HCO+ (1-0) interferometric map along with single-dish CO (2-1), C18O (2-1), HCO+ (1-0), HCO+ (3-2), CS (2-1), and CS (5-4) spectra and compare them with the observations. Our disk model successfully reproduces observed interferometric HCO+ (1-0) data, thereby constraining the following disk properties: (1) the inclination angle i=17+6-3 deg, (2) the position angle φ=80deg+/-30deg, (3) the size Rout=400+/-200 AU, (4) the mass Mdisk=1.3×10-2 Msolar (with a factor of ~7 uncertainty), and (5) that the disk is in Keplerian rotation. Furthermore, indirect evidence for a local inhomogeneity of the envelope at >~600 AU is found. The single-dish spectra are synthesized for three different cases, namely, for the disk model, for the envelope model, and for their combination. An overall reasonable agreement between all modeled and acquired line intensities, widths, and profiles is achieved for the latter model, with the exception of the CS (5-4) data that require the presence of high-density clumpy structures in the model. This allows us to constrain the physical structure of the AB Aur inner envelope: (1) its mass-average temperature is about 35+/-14 K; (2) the density goes inversely down with the radius, ρ~r-1.0+/-0.3, starting from an initial value n0~3.9×105 cm-3 at 400 AU; and (3) the mass of the shielded region within 2200 AU is about 4×10-3 Msolar (the latter two quantities are uncertain by a factor of ~7). In addition, evolutionary nature and lifetime for dispersal of the AB Aur system and Herbig Ae/Be systems in general are discussed.