A multimode quantum theory of a degenerate parametric amplifier in a cavity