The Design and Implementatin of IBAL: A General-Purpose Probabilistic Language