Tractable Learning for Complex Probability Queries