Constraint Propagation + Junior Mints

Scheme + Junior Mints

At this very moment my world seems to have narrowed to only scheme and junior mints (yum!). I have a nice assignment to add a set value system to the constraint propagation being developed by Sussman and Chris Hanson in 6.891. Here is a transcript showing off where I am with this.

(declare (usual-integrations))
;Unspecified return value

(load "load")
;Loading "load.scm"
;Loading "ps-util.scm" -- done
;Loading "tms.scm" -- done
;Loading "constraints.scm" -- done
;Loading "equality-constraint.scm" -- done
;Loading "boolean-constraints.scm" -- done
;Loading "numerical-constraints.scm" -- done
;Loading "line-prefix.scm" -- done
;Loading "proofs.scm" -- done
;Loading "handler.scm" -- done
;Loading "solve.scm" -- done
-- done
;Value: d2?

(load "set-constraints")
;Loading "set-constraints.scm"
;Loading "set.scm" -- done
-- done
;Value: cp:identity

(define network
(cp:make-network 'network
(cp:make-value-model set:is_set?
set:=?
set:smallest)))
;Value: network

(define a (cp:make-connector 'a network))
;Value: a

(define b (cp:make-connector 'b network))
;Value: b

(define c (cp:make-connector 'c network))
;Value: c

(cp:make-constraint cp:intersection #f network a b c)
;Value: #[cp:constraint 13]

(cp:assume-value b (set:construct_from_list '(x y z 1 2 3)))
;Unspecified return value

(cp:assume-value c (set:construct_from_list '(x z 2)))
;Unspecified return value

(cp:has-value? a)
;Value: #t

(cp:value-of a)
;Value: (*set* #[primitive-procedure eq?] 2 z x)

(cp:assume-value a (set:construct_from_list '(x z)))
;Warning: Contradiction: #[tms:node 14]
;Warning: Contradiction: #[tms:node 14]
;Warning: Contradiction: #[tms:node 14]
;Unspecified return value

(cp:value-of a)
;Value: (*set* #[primitive-procedure eq?] z x)

(cp:value-of b)
;Value: (*set* #[primitive-procedure eq?] z x)

(cp:value-of c)
;Value: (*set* #[primitive-procedure eq?] 2 z x)

What I’ve written so far does in fact allow intersection and union, which is nice, but I’m also looking to mix in the boolean system with cp:subset?

Vincent happened to stop by the PLW briefly while I was working on this thing, and when I explained it he suggested a networked, distributed version. This is in fact something I was thinking about several weeks ago, this idea of setting up simple connector and constraint P2P client programs. Input could come from anything: sensor values, humans, stock market, etc. Each type of constraint or value node is essentially offered as a service, and people can compose them to create new nodes.

I won’t be working on that just yet, but I’ll leave it percolating up there, swirling around with social contracts and slow computing. They all seem to relate. In the meantime I have a few more junior mints to eat.

Leave a Reply