Scaling exact inference for discrete probabilistic programs