We establish virtual surjection to pairs (VSP)
as a general criterion for the finite presentability of
subdirect products of groups: if G_1,...,G_n are finitely
presented groups and S is a subgroup of their direct product
that projects to a subgroup of finite index in each G_i\times G_j,
then S is finitely presented.
We use the VSP criterion to characterize
finitely
presented residually free groups. We prove that the class of such groups
is recursively enumerable. We describe
an algorithm that, given a
finite presentation of a group in the class, will construct
a canonical embedding into a direct product of
finitely many
limit groups. We solve the (multiple) conjuagacy and membership problems
for finitely presented residually free groups.
New families of subdirect
products of free groups are constructed,
including the first examples
of finitely presented subgroups that are neither
${\rm{FP}}_\infty$
nor of Stallings-Bieri type.