A compositional approach to probabilistic knowledge compilation