Cosh is an experimental Church implementation that uses dynamic programming based on hashing factored continuations.
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.
-
Install scheme-tools:
-
Clone the scheme-tools repository using
git clone git://github.com/stuhlmueller/scheme-tools.git
. -
Add the scheme-tools directory to your
$VICARE_LIBRARY_PATH
.To add a directory to your
$VICARE_LIBRARY_PATH
, change into the directory and typeecho -e "\nexport VICARE_LIBRARY_PATH=`pwd`:$VICARE_LIBRARY_PATH" >>
. Replace/.bashrc/.bashrc
with the location of your shell config file. -
Add the scheme-tools/bin directory to your
$PATH
.To add a directory to your
$PATH
,cd
into the directory and typeecho -e "\nexport PATH=`pwd`:$PATH" >> ~/.bashrc
.
-
-
Install scheme-transforms:
-
Clone the repository using
git clone git://github.com/stuhlmueller/scheme-transforms.git
. -
Add the scheme-transforms directory to your
$VICARE_LIBRARY_PATH
(see above).
-
-
Install cosh:
-
Clone the repository using
git clone git://github.com/stuhlmueller/cosh.git
. -
Add the cosh directory to your
$VICARE_LIBRARY_PATH
(see above). -
Add the cosh/bin directory to your
$PATH
(see above).
-
-
Reload your shell config file, e.g., via
source ~/.bashrc
.
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.
$ 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