Tutorial 5: Church Programming

Tutorial Overview

Diagram with photos of three types of stacked objectsdishes in a sink, stable tower of blocks and collapsing unstable tower of blocks. Josh Tenenbaum and colleagues propose that our intuitions about properties like the stability of a stack of blocks, may derive from "probabilistic programs" that can simulate, with some uncertainty, the physics that governs how objects behave in space and time. Such programs can be implemented and tested using probabilistic programming languages such as the Church language. (Image courtesy of Josh Tenenbaum, used with permission.)

The unit on modeling human cognition introduced a framework based on the creation of generative models of the physical and social worlds that enable probabilistic inference about objects, agents, and events. The Church programming language was designed to facilitate the implementation and testing of such models. In this tutorial, you will first learn the syntax and some basic primitives of the Church language, and how to define functions that implement simple probabilistic models and inference methods. The concepts are then explored through examples such as hypothesis testing in the domain of coin-flipping, and reasoning about the goals and beliefs of an agent.

Unit Activities

Useful Background

  • Introductions to probability and probabilistic approaches to modeling behavior
  • Video lectures on computational models of cognition by Josh Tenenbaum
  • Introduction to computer programming

Videos and Slides

Code

Church_examples (RTF) contains the code examples described in the two-part tutorial video. These examples can be executed by copying the code into one of the following Church programming environments. Code can also be written from scratch and modified in these environments:

  1. First edition of the Probabilistic Models of Cognition electronic text, cited in the section below on Future Study, which includes a separate Play space where code can be copied, modified, and executed
  2. webchurch engine that runs Church code in a web browser, which is available on GitHub for download onto your local computer

Further Study

Goodman, N. D., and J. B. Tenenbaum. Probabilistic Models of Cognition, First Edition (electronic).

  • This interactive text introduces many probabilistic modeling techniques and contains an embedded Church programming environment with coding examples throughout the text that can be modified and executed in place. The text also includes a separate Play space and Church language reference.

Goodman, N. D, and J. B. Tenenbaum. Probabilistic Models of Cognition, Second Edition (electronic). With programming exercises written in the web-based probabilistic programming language, WebPPL.

Goodman, N. D., and A. Stuhlmüller. The Design and Implementation of Probabilistic Programming Languages. (electronic)

  • This online text describes how probablistic programming languages (PPLs) can be embedded in other languages, and introduces the WebPPL language, a web-based PPL embedded in JavaScript.

forestdb.org: A repository of probabilistic models implemented in the Church language

The Church language is one of several probabilistic programming languages. Learn more about such languages at the Probabilistic-Programming wiki.