descriptionConcurrent propagator system implemented in Clojure
last changeMon, 24 Jan 2011 16:42:06 +0000 (24 09:42 -0700)
content tags

Concurrent Propagator in Clojure

A concurrent propagator system implemented in Clojure. This simple project builds on the scheme propagator system from Gerald Sussman's The art of the Propagator.

We develop a programming model built on the idea that the basic computational elements are autonomous machines interconnected by shared cells through which they communicate. Each machine continuously examines the cells it is interested in, and adds information to some based on deductions it can make from information from the others. This model makes it easy to smoothly combine expression-oriented and constraint-based programming; it also easily accommodates implicit incremental distributed search in ordinary programs. This work builds on the original research of Guy Lewis Steele Jr. and was developed more recently with the help of Chris Hanson.

Major differences between this system and the one implemented in The art of the Propagator are that,

  1. this implementation admits parallel execution through the use of Clojure's agents.
  2. this version does not implement the backtracking system which breaks the locality of the propagator system

(note: this is an exploratory, educational implementation and isn't suitable for any sort of production application.)

This system is implemented in 26 lines of Clojure code in src/propagator.clj.

Usage Examples

  • square roots calculation using Heron's method
    (in-ns 'propagator)
    (defcell guess 1)
    (defcell x 9)
    (defcell done false)
    (defcell margin 0.1)
    ;; check if we're close enough to a solution to cease improving
    (defpropagator enough [x guess] [done]
      (Thread/sleep 1000) ; sleep to allow observation of incremental calculation
      (if (< (abs (- (* guess guess) x)) @margin) true false))
    ;; incrementally improve our guess
    (defpropagator heron [x done guess] [guess]
      (Thread/sleep 1000)
      (if done
        (/ (+ guess (/ x guess)) 2.0)))
    (comment           ; after building the system
      (set-cell x 89)  ; update the value of x
      (deref guess)    ; immediately begin observing improvements in guess
      (deref guess))
  • parallel spread sheet using Clojure formulas is implemented in 33 in src/spreadsheet.clj.


Copyright (C) 2010 Eric Schulte

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see

2011-01-24 Eric Schulteremoved dependency on ring which was only used for... master
2011-01-24 Eric Schulteupdating main readme for publishing on
2011-01-24 Eric Schultea simple spreadsheet application
2011-01-24 Eric Schultemultiple improvements based on Ken Wesson's comments
2011-01-24 Eric Schultemoving forward to current versions of dependencies
2010-09-04 Eric Schulteupdated git urls
2010-09-04 Eric Schulteadding tangled source files to the repo
2010-09-03 Eric Schulteadding commentary and licence for sharing
2010-05-17 Eric Schultecompletely breaking the graph stuff out of the main...
2010-05-17 Eric Schultetiny indentation change
2010-05-03 Eric Schultemore cleanup and prep for live demo
2010-04-24 Eric Schultesome general cleanup
2010-04-24 Eric Schultenicer html experience
2010-04-19 Eric Schultepropagator web page actually working
2010-04-19 Eric Schulteadding web-server example
2010-04-17 Eric Schulteadding ability to remember and graph structure of propa...
7 years ago master