Implement till 4.63
This commit is contained in:
@@ -33,8 +33,44 @@
|
|||||||
|
|
||||||
(display "\nex-4.62 - last-pair\n")
|
(display "\nex-4.62 - last-pair\n")
|
||||||
|
|
||||||
(display "\nex-4.63\n")
|
(eval-query '(rule (last-pair (?x . ()) (?x . ()))))
|
||||||
|
(eval-query
|
||||||
|
'(rule (last-pair (?u . ?v) ?x)
|
||||||
|
(last-pair ?v ?x)))
|
||||||
|
|
||||||
;(display "\nex-4.64\n")
|
(eval-query '(last-pair (1 2 3) ?y))
|
||||||
;(display "\nex-4.65\n")
|
(eval-query '(last-pair (3) ?y))
|
||||||
|
(eval-query '(last-pair (2 3 4 5 ?x) (3)))
|
||||||
|
(newline)
|
||||||
|
|
||||||
|
; (eval-query '(last-pair ?x (3))) results in an endless loop because there is
|
||||||
|
; no definite answer. Any arbitrary number of symbols before the 3 would form a
|
||||||
|
; solution.
|
||||||
|
|
||||||
|
(display "\nex-4.63 - genesis-family\n")
|
||||||
|
|
||||||
|
; Formulate rules such as ``If S is the son of F, and F is the son of G, then S
|
||||||
|
; is the grandson of G'' and ``If W is the wife of M, and S is the son of W,
|
||||||
|
; then S is the son of M'' (which was supposedly more true in biblical times
|
||||||
|
; than today) that will enable the query system to find the grandson of Cain;
|
||||||
|
; the sons of Lamech; the grandsons of Methushael. (See exercise 4.69 for some
|
||||||
|
; rules to deduce more complicated relationships.)
|
||||||
|
|
||||||
|
(eval-query '(rule (grandson ?grandparent ?grandson)
|
||||||
|
(and (nson ?grandparent ?son)
|
||||||
|
(nson ?son ?grandson))))
|
||||||
|
|
||||||
|
(eval-query '(rule (nson ?parent ?son)
|
||||||
|
(or (son ?parent ?son)
|
||||||
|
(and (wife ?parent ?wife)
|
||||||
|
(son ?wife ?son)))))
|
||||||
|
|
||||||
|
(eval-query '(grandson Cain ?x))
|
||||||
|
(eval-query '(nson Lamech ?x))
|
||||||
|
(eval-query '(grandson Methushael ?x))
|
||||||
|
(newline)
|
||||||
|
|
||||||
|
(display "\nex-4.64\n")
|
||||||
|
|
||||||
|
(display "\nex-4.65\n")
|
||||||
|
|
||||||
|
|||||||
@@ -665,6 +665,18 @@
|
|||||||
(or (supervisor ?staff-person ?boss)
|
(or (supervisor ?staff-person ?boss)
|
||||||
(and (supervisor ?staff-person ?middle-manager)
|
(and (supervisor ?staff-person ?middle-manager)
|
||||||
(outranked-by ?middle-manager ?boss))))
|
(outranked-by ?middle-manager ?boss))))
|
||||||
|
|
||||||
|
; From 4.63
|
||||||
|
(son Adam Cain)
|
||||||
|
(son Cain Enoch)
|
||||||
|
(son Enoch Irad)
|
||||||
|
(son Irad Mehujael)
|
||||||
|
(son Mehujael Methushael)
|
||||||
|
(son Methushael Lamech)
|
||||||
|
(wife Lamech Ada)
|
||||||
|
(son Ada Jabal)
|
||||||
|
(son Ada Jubal)
|
||||||
|
|
||||||
))
|
))
|
||||||
|
|
||||||
;; felixm: for easier use from MIT-Scheme
|
;; felixm: for easier use from MIT-Scheme
|
||||||
|
|||||||
Reference in New Issue
Block a user