Module Prob_lang


module Prob_lang: sig .. end
An extremely small probabilistic language.

It was inspired by

D. Koller, D. McAllester, and A. Pfeffer, "Effective Bayesian inference for stochastic programs," Proceedings of the Fourteenth National Conference on Artificial Intelligence, AAAI Press, Menlo Park, Calif., 1997, pp. 740--747. http://citeseer.ist.psu.edu/koller97effective.html

and

A. Pfeffer. IBAL: A probabilistic rational programming language. In B. Nebel, editor, Proceedings of the Seventeenth International Joint Conference on Artificial Intelligence (IJCAI-01), pages 733--740. Morgan Kaufmann Publishers, Inc., 2001. http://citeseer.ist.psu.edu/pfeffer01ibal.html

However, it's smaller (probably over-simplified), and for now, the only base type is integers.


type varname = string Pervasives.ref 
Using distinct "string ref"s as distinct variable names, sort of like "gensym".
exception Prob_error of string

type term =
| Var of varname
| Lam of varname * term
| App of term * term
| Const of int
| Case of (int * term) list
| Flip of float * term * term
The terms are the untyped lambda calculus, plus a nondeterministic "flip" construct.
val subst : varname -> term -> term -> term
Substitution.
val term_to_string : term -> string
Printing terms (only works for constants for now)
type dist = (term * float) list 
A distribution (for now, not using log probabilities.)
val weight_dist : float -> ('a * float) list -> ('a * float) list
Weights a distribution by some amount.
val contains_var : varname -> term -> bool
Tests if a term contains a variable.
val simplify_dist : ('a * float) list -> ('a * float) list
Simplifies a distribution. This doesn't recognize everything that it could as equivalent.
val dist : term -> (term * float) list
Computes the distribution of values of a term.
val dist_apply : term -> term -> (term * float) list
Computes the distribution of a function application.