Este proyecto fue realizado para la materia Introducción a la Programación Probabilística dictada en la Facultad de Ciencias Exactas y Naturales durante el segundo bimestre del 2026, por Javier Burroni. Consiste en un intérprete de un lenguaje de programación probabilística, representado como listas estilo Lisp.
La sintaxis del programa incluye las instrucciones let, if, sample, observe, eval y defn. Además, cuenta con las funciones matemáticas + y <, y con la implementación de las distribuciones normal y uniforme continua, normal y uniform-continuous respectivamente.
Existen dos maneras de ejecutar código. La primera es instanciando un ExecutionThread a través de su método initialize. Este recibe un programa y una técnica de sampleo, con la que resolverá las instrucciones sample y observe. Luego, con el método execute() se ejecuta. La segunda es a través de los métodos estáticos de ProbabilisticComputer, runLikelihoodWeighting, runSingleSiteMetropolisHasting y runSamplingMonteCarlo que a partir de un programa utiliza el método de inferencia indicado.
Es importante aclarar que el proyecto asume dado un sampler, por lo que el programa no se recibe como texto sino como una lista de instancias de la clase Primitive, números, valores booleanos, entre otros. Esto se puede visualizar en los tests, que están basados en ejemplos dados en clase.
| Componente | Versión |
|---|---|
| Java (lenguaje / bytecode) | 21 |
| Maven (proyecto) | 3.x (compatible con el pom.xml actual) |
| artifactId / versión del proyecto | probabilistic-programming-language 1.0-SNAPSHOT |
| JUnit Jupiter | 5.11.4 |
| maven-compiler-plugin | 3.13.0 |
| maven-surefire-plugin | 3.5.2 |
La compilación está configurada con maven.compiler.release=21 en el pom.xml.
- JDK 21 instalado y disponible en el
PATH(java -versiondebe mostrar 21). - Apache Maven 3.6+ instalado (
mvn -v). - Conexión a internet la primera vez (para descargar dependencias de Maven Central).
No se requieren bases de datos, servidores externos ni variables de entorno adicionales.
Desde la raíz del proyecto:
# Compilar
mvn compile
# Ejecutar la clase principal
mvn -q exec:java -Dexec.mainClass="org.ppl.Main"Si no tenés el plugin exec configurado, podés correr:
mvn compile
java -cp target/classes org.ppl.MainClase de entrada: org.ppl.Main.
Ejemplo mínimo con ExecutionThread:
// equivalente aproximado a: (let [x 42] x)
List<Object> program = Arrays.asList("let", Arrays.asList(new Symbol("x"), 42), new Symbol("x"));
ExecutionThread thread = ExecutionThread.initialize(program, new SamplingMonteCarlo(new Random(0)));
ThreadOutput output = thread.execute();Métodos estáticos de ProbabilisticComputer:
-
runLikelihoodWeighting(List<Object> aParsedProgramToRun, Random aRandomNumberGenerator, int numberOfExecutions)- Parámetros: programa parseado, generador aleatorio y cantidad de ejecuciones.
- Devuelve:
List<LWInferenceResult>(cada resultado tiene un valorgetValue()y un pesogetW()).
-
runSingleSiteMetropolisHasting(List<Object> aParsedProgramToRun, Random aRandomNumberGenerator, int steps, int warmupSteps)- Parámetros: programa parseado, generador aleatorio, cantidad de pasos y pasos de warmup.
- Devuelve:
List<Double>con los valores muestreados luego del warmup.
-
runSamplingMonteCarlo(List<Object> aParsedProgramToRun, Random aRandomNumberGenerator, int numberOfExecutions)- Parámetros: programa parseado, generador aleatorio y cantidad de ejecuciones (partículas).
- Devuelve:
List<Double>con los valores obtenidos de las partículas.
mvn testLos tests cubren, entre otros, primitivas, let, if, closures y un programa geométrico recursivo.
src/main/java/org/ppl/
├── Main.java
├── distributions/ # Distribuciones de probabilidad
├── execution/ # Motor de ejecución e hilos
├── functions/ # Closures y primitivas
├── instructions/ # Instrucciones del lenguaje
├── outputs/ # Resultados de inferencia
├── sampling/ # Técnicas de muestreo
└── symbol/ # Símbolos del lenguaje
This project was developed for the course Introduction to Probabilistic Programming taught at the Facultad de Ciencias Exactas y Naturales during the second bimester of 2026, by Javier Burroni. It consists of an interpreter for a probabilistic programming language, represented as Lisp-style lists.
The program syntax includes the instructions let, if, sample, observe, eval, and defn. It also provides the mathematical functions + and <, and implementations of the normal and continuous uniform distributions, normal and uniform-continuous respectively.
There are two ways to run code. The first is by instantiating an ExecutionThread through its initialize method. This receives a program and a sampling technique, which it uses to resolve the sample and observe instructions. Then it is executed with the execute() method. The second is through the static methods of ProbabilisticComputer — runLikelihoodWeighting, runSingleSiteMetropolisHasting, and runSamplingMonteCarlo — which take a program and run it using the indicated inference method.
It is important to note that the project assumes a given sampler, so the program is not received as text but as a list of Primitive class instances, numbers, boolean values, among others. This can be seen in the tests, which are based on examples given in class.
| Component | Version |
|---|---|
| Java (language / bytecode) | 21 |
| Maven (project) | 3.x (compatible with the current pom.xml) |
| Project artifactId / version | probabilistic-programming-language 1.0-SNAPSHOT |
| JUnit Jupiter | 5.11.4 |
| maven-compiler-plugin | 3.13.0 |
| maven-surefire-plugin | 3.5.2 |
Compilation is configured with maven.compiler.release=21 in the pom.xml.
- JDK 21 installed and available on the
PATH(java -versionshould show 21). - Apache Maven 3.6+ installed (
mvn -v). - Internet connection the first time (to download dependencies from Maven Central).
No databases, external servers, or additional environment variables are required.
From the project root:
# Build
mvn compile
# Run the main class
mvn -q exec:java -Dexec.mainClass="org.ppl.Main"If you do not have the exec plugin configured, you can run:
mvn compile
java -cp target/classes org.ppl.MainEntry class: org.ppl.Main.
Minimal example with ExecutionThread:
// roughly equivalent to: (let [x 42] x)
List<Object> program = Arrays.asList("let", Arrays.asList(new Symbol("x"), 42), new Symbol("x"));
ExecutionThread thread = ExecutionThread.initialize(program, new SamplingMonteCarlo(new Random(0)));
ThreadOutput output = thread.execute();Static methods of ProbabilisticComputer:
-
runLikelihoodWeighting(List<Object> aParsedProgramToRun, Random aRandomNumberGenerator, int numberOfExecutions)- Parameters: parsed program, random number generator, and number of executions.
- Returns:
List<LWInferenceResult>(each result has a value viagetValue()and a weight viagetW()).
-
runSingleSiteMetropolisHasting(List<Object> aParsedProgramToRun, Random aRandomNumberGenerator, int steps, int warmupSteps)- Parameters: parsed program, random number generator, number of steps, and warmup steps.
- Returns:
List<Double>with the sampled values after warmup.
-
runSamplingMonteCarlo(List<Object> aParsedProgramToRun, Random aRandomNumberGenerator, int numberOfExecutions)- Parameters: parsed program, random number generator, and number of executions (particles).
- Returns:
List<Double>with the values obtained from the particles.
mvn testThe tests cover, among others, primitives, let, if, closures, and a recursive geometric program.
src/main/java/org/ppl/
├── Main.java
├── distributions/ # Probability distributions
├── execution/ # Execution engine and threads
├── functions/ # Closures and primitives
├── instructions/ # Language instructions
├── outputs/ # Inference results
├── sampling/ # Sampling techniques
└── symbol/ # Language symbols