Generalized computer methods are developed for inferring details of the formation of cosmochemical systems. Compositions of ideal gas mixtures existing in equilibrium with multicomponent solid and liquid phases are calculated. A comparison of computed results with experimental data is made for the ternary system MgO-FeO-SiO 2. While the ideal-solution approximation is shown to be inaccurate in dealing with the silicate melts, in a system where there are only solids and gas, the stable phases and compositions can be accurately calculated. A model system containing the elements H, O, Si, Mg, S, C, Cl and F is investigated over a range of compositions involving the gas and ten solid phases, to show the power of the technique in dealing with complex gas-solid equilibria. Systems close to cosmic composition are next considered, both with and without iron. When present, most of the iron is computed to be in the metallic state with little going into pyroxene or olivine solid solutions. At low hydrogen concentration and low temperature, troilite becomes the stable iron-bearing phase. The calculated equilibrium concentrations are very sensitive to the assumed ratio of magnesium to silicon. The computational method described is easily applied to complex systems of solids and gases and represents an important tool with which to investigate cosmochemical systems.