zarpy

Formally verified biased coin and n-sided die


Keywords
zar, zarpy, random, sampler, biased, coin, bernoulli, uniform, die, verified, coq, compiler, formal-verification, probabilistic-programming, sampling
License
Other
Install
pip install zarpy==1.0.1

Documentation

pypi

Zar

Paper: https://arxiv.org/abs/2211.06747

Setup

  • Coq development:
opam pin add coq 8.16.0
opam repo add coq-released https://coq.inria.fr/opam/released
opam install coq-itree
make -j4
opam install pythonlib ppx_import ppx_deriving
cd python/zar/ocaml
dune build zar.so
cd ..
make install

Or:

pip install zarpy
  • Extracted sampler analysis scripts (e.g., analyze.py):
pip install numpy matplotlib scipy

Foundational

cpGCL and cwp

CF Trees

Generating Interaction Trees

Order/Domain Theory and Algebraic Coinductives

Sampling Equidistribution Theorems

Empirical Validation

extract/ contains driver code and scripts for evaluating extracted samplers (e.g., dueling coins, n-sided die, geometric distribution, discrete gaussian, hare and tortoise).

fast-loaded-dice-roller/ contains a clone of https://github.com/probcomp/fast-loaded-dice-roller modified to track entropy usage.

optimal-approximate-sampling/ contains a clone of https://github.com/probcomp/optimal-approximate-sampling modified to track entropy usage.

python/zar/ contains the zarpy pip package source.

python/tf/ contains the TensorFlow 2 project, with batch_gen.py implementing a sampling-without-replacement generator on top of the zarpy sampler package.