Lab 12

Goal

To examine ambmicro carefully and modify it so that require is a built-in special form.

Experiment

To use ambmicro to solve problems, we found it useful to define the procedure require while running ambmicro as follows:
(define (require p)
  (cond ((not p) (amb))
        (else #t)))
(I have modified require so that (require p) will return #t when p is true.) It will be even nicer if this special form were built into the amb evaluator so that we don't have to redefine require every time we need it.

Your assignment is to modify amb-eval (by adding another branch to the main conditional statement) so that it will evaluate require statements as built-in special forms. The version of ambmicro that you will start with is the one found in file ambmicro.scm, found on the class web site.

If you have modified amb-eval properly, you should get the following behavior:

> (micro-r-e-p)
ambmicro> (require 2)
new problem
#t
ambmicro> try-again
no more values for (require 2)
ambmicro> (require #f)
new problem
no more values for (require #f)
ambmicro> ((lambda (x y)
	     (require (eq? x y))
	     (require (not (eq? y 2)))
	     (cons x y))
	   (amb 1 2 3)
	   (amb 1 2 3))
new problem
(1 . 1)
ambmicro> try-again
(3 . 3)
ambmicro> try-again
no more values for ((lambda (x y) (require (eq? x y)) (require (not (eq? y 2)))
(cons x y)) (amb 1 2 3) (amb 1 2 3))
ambmicro> (exit)
Leaving ambmicro
>
After you have modified amb-eval to give the desired performance for required, submit your version of amb-eval to the Automated Tester. Do not include any other code except amb-eval.