
Some examples for testing code for assignment #1.  (You don't have to
use my function names!)  

;; ================================================================
;; Some inputs that aren't legal expressions.
;; ================================================================

(check-expression-form '(is-in? (?y strauss) claremont))
(check-expression-form '(member? (+ ?x ?y) "my items"))
(check-expression-form '((method-of mywindow) ?x ?z))
(check-expression-form '(apply ((method-of mywindow) ?x) ?z))

;; ================================================================
;; Applying a substitution list to an expression
;; ================================================================

(do-substitution '(parent-of george (child-of ?ppy)) '((?ppy louise))) 
  --> '(parent-of george (child of louise))
(do-substitution '(parent-of george (child-of ?ppy)) '((?foo louise) (?ppy ?foo)))
  --> '(parent-of george (child of louise))
(do-substitution '(west-of ?y (nearest-building (dorm-of ?mm))) '((?mm ?zz)))
  --> '(west-of ?y (nearest-building (dorm-of ?zz)))
(do-substitution '(west-of ?y (f ?x (dorm-of ?mm))) '((?mm ?zz) (?y 43) (?zz 28)))
  --> '(west-of 43 (f ?x (dorm-of 28)))

;; ================================================================
;; occurs-check
;; ================================================================

   ;; examples that should return #f

(occurs-check 'y '(west-of ?y (f ?x (dorm-of ?mm))))
(occurs-check '?xx '(parent-of (mutual-friend-of ?ppy ?zztop) george))

   ;; examples that should return #t

(occurs-check '?y '(west-of ?y (f ?x (dorm-of ?mm))))
(occurs-check '?mm '(west-of ?y (f ?x (dorm-of ?mm))))
(occurs-check '?ppy '(parent-of (child of ?ppy) george))
(occurs-check '?ppy '(parent-of (child-of ?ppy) george))
(occurs-check '?ppy '(parent-of (mutual-friend-of ?ppy ?zztop) george))

;; ================================================================
;; unify
;; ================================================================

   ;; Does unify (or unify-aux) correctly handle basic expressions 
   ;;    that don't require calling unify-lists?

(unify '?xx '?actor)
  --> '((?xx ?actor))
(unify '?xx 'fred)
  --> '((?xx fred))
(unify 'fred '?yy)
  --> '((?yy fred))
(unify '?xx '(+ 2 zz))
  --> '((?xx (+ 2 zz)))
(unify '(+ 2 zz) '?xx)
  -->'((?xx (+ 2 zz)))
(unify 'actor 'strauss)
  --> #f
(unify 'actor '(friend-of strauss))
  --> #f

   ;; Does it work if some substitutions are explicitly specified?

(unify-aux '?xx '(+ 2 zz) '((?xx strauss)))
  --> #f
(unify-aux '?xx '(+ 2 zz) '((?xx ?yy)))
  --> '((?yy (+ 2 zz)) (?xx ?yy))
(unify-aux '?xx '(+ 2 zz) '((?yy kevin) (?xx ?yy)))
  --> #f
(unify-aux '?xx '(+ 2 zz) '((?yy kevin) (?mm keller)))
  --> '((?xx (+ 2 zz)) (?yy kevin) (?mm keller))

   ;; Is unify-lists working?
   ;; Notice that you can replace the calls to unify with a call to
   ;;   unify-lists or unify-aux by adding a null substitution list.
   ;;   (See the first example.)

(unify '(+ 2 ?yy) '(+ ?xx -37))
  --> '((?yy -37) (?xx 2))
(unify-lists  '(+ 2 ?yy) '(+ ?xx -37) '())
  --> '((?yy -37) (?xx 2))

   ;; The following examples should fail the first clause(s) of unify-lists,
   ;;   which check that the lengths and function names match.  To be sure that
   ;;   the right thing is happening, you might add a statement (e.g. use format)
   ;;   to these clauses that prints a message telling you which clause has
   ;;   rejected the match.

(unify '(+ ?xx ?yy) '(friend-of ??zz ?yy))
  --> #f
(unify '(+ ?xx ?yy) '(+ ??zz ?yy ?yy))
  --> #f

   ;; Is unify-lists successfully matching the inputs to the function call?

(unify '(friend-of bill ?xx) '(friend-of ?yy monica))
  --> '((?xx monica) (?yy bill))
(unify '(friend-of bill hilary) '(friend-of ?yy monica))
  --> #f
(unify-lists '(friend-of bill ?xx) '(friend-of ?yy monica) '((?yy edward)))
  --> #f
(unify '(friend-of bill ?xx) '(friend-of ?xx monica))
  --> #f
(unify '(friend-of bill ?xx) '(friend-of 37 monica))
  --> #f
(unify '(friend-of (husband-of hilary) ?xx) '(friend-of ?yy monica))
  --> '((?xx monica) (?yy (husband-of hilary)))

   ;; Unify-lists should reject these due to length or function-name mismatches.
   ;;   However, the problem will not be detected by the first call to unify-lists
   ;;   but, rather, by a later recursive call.

(unify '(friend-of bill (foo ?x ?y)) '(friend-of bill (bar ?x ?y)))
  --> #f
(unify '(friend-of (foo ?x ?y ?z) aa bb) '(friend-of (foo ?x ?y) aa bb))
  --> #f

   ;; Other cases in which unify-lists calls unify which calls unify-lists

(unify '(friend-of (husband-of hilary) ?xx) '(friend-of (husband-of ?yy) monica))
  --> '((?xx monica) (?yy hilary))
(unify '(+ (f ?x 42) (g (h ?z))) '(+ (f 75 ?y) (g (h ?mm))))
  --> '((?z ?mm) (?y 42) (?x 75))
(unify '(+ (f ?x 42) (g (h ?z))) '(+ (f ?x 75) (g (h ?mm))))
  --> #f
(unify '(+ (f ?x 42) (g (h ?z))) '(+ (f ?mm ?y) (g (h ?mm))))
  --> '((?z ?mm) (?y 42) (?x ?mm))
(unify '(+ (f ?x ?x) (g (h ?z))) '(+ (f ?mm ?y) (g (h ?mm))))
  --> '((?z ?y) (?mm ?y) (?x ?mm))
(unify '(+ (f ?x 37) (g (h pi))) '(+ (f ?mm ?x) (g (h ?mm))))
  --> #f
