  We map the quantum entanglement problem onto the mathematically well-studied
truncated moment problem. This yields a necessary and sufficient condition for
separability that can be checked by a hierarchy of semi-definite programs. The
algorithm always gives a certificate of entanglement if the state is entangled.
If the state is separable, typically a certificate of separability is obtained
in a finite number of steps and an explicit decomposition into separable pure
states can be extracted.
