Pluck - A Probabilistic Programming LanguagePluck<br>Probabilistic Programming with Lazy Inference
Pluck is a probabilistic programming language with efficient inference based on lazy knowledge compilation. It supports higher-order functions, many recursive programs, and recursive types.<br>Get startedRead the docsRead the paper
Quick Start<br>Install Pluck and run your first program:<br>Install & RunExpected Output<br># In your shell:<br>git clone --recurse-submodules https://github.com/mlb2251/Pluck.jl.git<br>cd Pluck.jl
# Compile the rsdd library (required for Pluck)<br>cd src/RSDD/rsdd<br>cargo build --release --features ffi<br>cd ../../..
# In Julia:<br>using Pkg<br>Pkg.activate(".")<br>Pkg.instantiate()<br>using Pluck<br>load_pluck_file("programs/simple_example.pluck");
Expressive, Lazy, Functional Programs<br>Pluck programs are expressive functional programs, that can also make (discrete) random choices. It supports lazy algebraic data types, higher-order functions, and recursion.<br>Random TreesModeling TyposNetwork VerificationProbabilistic GrammarsInfinite HMM<br>Pluck code:<br>(define-type tree (Leaf) (Node nat tree tree))
(define (random-tree)<br>(if (flip 0.6)<br>(Leaf)<br>(let ((left (random-tree))<br>(right (random-tree)))<br>(Node (geom 0.5) left right))))
Sampled values for random-tree:<br>Node 2 (Leaf) (Node 0 (Leaf) (Leaf))<br>Leaf<br>Node 1 (Leaf) (Leaf)
Exact Inference<br>Pluck can compute the exact probability distributions of many expressions.<br>Random TreesModeling TyposNetwork VerificationProbabilistic GrammarsInfinite HMM<br>Pluck query:<br>;; What is the probability that a random tree has fewer than 4 nodes?<br>(query tree-size-small<br>(Marginal ( (length (nodes (random-tree))) 4)))
Output:<br>tree-size-small:<br>true 0.855<br>false 0.145
Bayesian Conditioning<br>Pluck can also compute the exact conditional (i.e., posterior) distribution of an expression, given some Boolean condition.<br>Random TreesModeling TyposProbabilistic GrammarsInfinite HMM<br>Pluck code:<br>(query bst-given-size8-bounded<br>(let ((t (random-tree)))<br>(Posterior<br>(isBST t)<br>(and (== (size t) 8) (all-nodes-between t 0 10)))))
Output<br>bst-given-size8-bounded:<br>false 0.9999999999998865<br>true 1.1346479311669095e-13
Posterior Sampling<br>Pluck can draw exact samples from posterior distributions, even in infinite spaces.<br>Random TreesModeling TyposProbabilistic GrammarsInfinite HMM<br>Pluck code:<br>(query tree-samples-given-size8-bst-bounded<br>(let ((t (random-tree)))<br>(PosteriorSamples<br>(and (== (size t) 8)<br>(all-nodes-between t 0 10)<br>(isBST t))<br>5)))
Sampled values for tree-samples-given-size8-bst-bounded:<br>(Node 9 (Node 7 (Node 6 (Node 4 (Node 3 (Node 2 (Node 1 (Leaf) (Leaf)) (Leaf)) (Leaf)) (Node 5 (Leaf) (Leaf))) (Leaf)) (Leaf)) (Leaf))<br>(Node 8 (Node 5 (Node 4 (Node 2 (Node 1 (Leaf) (Leaf)) (Node 3 (Leaf) (Leaf))) (Leaf)) (Node 6 (Leaf) (Leaf))) (Node 9 (Leaf) (Leaf)))<br>(Node 8 (Node 7 (Node 5 (Node 1 (Leaf) (Node 4 (Node 2 (Leaf) (Node 3 (Leaf) (Leaf))) (Leaf))) (Node 6 (Leaf) (Leaf))) (Leaf)) (Leaf))<br>(Node 8 (Node 6 (Node 3 (Node 1 (Leaf) (Node 2 (Leaf) (Leaf))) (Node 4 (Leaf) (Node 5 (Leaf) (Leaf)))) (Node 7 (Leaf) (Leaf))) (Leaf))<br>(Node 8 (Node 7 (Node 6 (Node 1 (Leaf) (Node 3 (Node 2 (Leaf) (Leaf)) (Node 5 (Node 4 (Leaf) (Leaf)) (Leaf)))) (Leaf)) (Leaf)) (Leaf))