We construct a microscopic model of electron interactions that gives r
ise to both superconductivity and antiferromagnetism, and which admits
an approximate SO(5) symmetry that relates these two phases. The symm
etry can be exact, or it may exist only in the long-wavelength limit,
depending on the detailed form of the interactions. We compute the mac
roscopic Landau-Ginzburg free energy for this model as a function of t
emperature and doping, by explicitly integrating out the fermions. We
find that the resulting phase diagram can resemble that observed for t
he cuprates, with the antiferromagnetism realized as a spin-density wa
ve, whose wavelength might be incommensurate with the lattice spacing
away from half filling.