Soft Constraints for Inference with Declarative Knowledge