Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Dynamic programming inference by continuation hashing.

tree: 84b7970341

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.md

Cosh

Cosh is an experimental Church implementation that uses dynamic programming based on hashing factored continuations.

Installation

This installation assumes that you have git and a R6RS Scheme installed. The instructions on the Church wiki describe how to install Vicare Scheme with foreign function interface enabled.

  1. Install scheme-tools:

    1. Clone the scheme-tools repository using git clone git://github.com/stuhlmueller/scheme-tools.git.

    2. Add the scheme-tools directory to your $VICARE_LIBRARY_PATH.

      To add a directory to your $VICARE_LIBRARY_PATH, change into the directory and type echo -e "\nexport VICARE_LIBRARY_PATH=`pwd`:\$VICARE_LIBRARY_PATH" >> ~/.bashrc. Replace ~/.bashrc with the location of your shell config file.

    3. Add the scheme-tools/bin directory to your $PATH.

      To add a directory to your $PATH, cd into the directory and type echo -e "\nexport PATH=`pwd`:\$PATH" >> ~/.bashrc.

  2. Install scheme-transforms:

    1. Clone the repository using git clone git://github.com/stuhlmueller/scheme-transforms.git.

    2. Add the scheme-transforms directory to your $VICARE_LIBRARY_PATH (see above).

  3. Install cosh:

    1. Clone the repository using git clone git://github.com/stuhlmueller/cosh.git.

    2. Add the cosh directory to your $VICARE_LIBRARY_PATH (see above).

    3. Add the cosh/bin directory to your $PATH (see above).

  4. Reload your shell config file, e.g., via source ~/.bashrc.

Usage

Create a file called myprogram.church with the following content:

(rejection-query
 (define x (flip))
 (define y (flip))
 (list x y)
 (or x y))

Then, on the command line, type:

cosh myprogram.church

You should see the following output:

(#f #t): 0.3333333333333332 (-1.09861228866811)
(#t #f): 0.3333333333333332 (-1.09861228866811)
(#t #t): 0.3333333333333332 (-1.09861228866811)

This shows the probability (and log probability) of each possible program return value.

Options

$ cosh --help
Usage: cosh <file> [options]

Options:
  -h, --help            show this help message and exit
  -d, --debug           run all scheme commands in debug mode
  -k, --keep            do not delete compiled file
  -l LIMIT, --limit=LIMIT
                        restrict graph size
  -v, --verbose         display all executed commands
  -t, --time            record runtime
Something went wrong with that request. Please try again.