Implement 4.69
This commit is contained in:
@@ -131,15 +131,21 @@
|
|||||||
|
|
||||||
(display "\nex-4.69 - greats\n")
|
(display "\nex-4.69 - greats\n")
|
||||||
|
|
||||||
; Beginning with the data base and the rules you formulated in exercise 4.63,
|
(eval-query
|
||||||
; devise a rule for adding ``greats'' to a grandson relationship. This should
|
'(rule (greats ?relation ?parent ?grandson)
|
||||||
; enable the system to deduce that Irad is the great-grandson of Adam, or that
|
(and (grandson ?parent ?grandson)
|
||||||
; Jabal and Jubal are the great-great-great-great-great-grandsons of Adam.
|
(same ?relation (grandson)))))
|
||||||
; (Hint: Represent the fact about Irad, for example, as ((great grandson) Adam
|
|
||||||
; Irad). Write rules that determine if a list ends in the word grandson. Use
|
(eval-query
|
||||||
; this to express a rule that allows one to derive the relationship ((great .
|
'(rule (greats ?relation ?parent ?grandson)
|
||||||
; ?rel) ?x ?y), where ?rel is a list ending in grandson.) Check your rules on
|
(and (nson ?parent ?son)
|
||||||
; queries such as ((great grandson) ?g ?ggs) and (?relationship Adam Irad).
|
(greats ?son-relation ?son ?grandson)
|
||||||
|
(append-to-form (great) ?son-relation ?relation))))
|
||||||
|
|
||||||
|
(eval-query '(greats ?x Adam Irad))
|
||||||
|
(eval-query '(greats ?x Adam Jabal))
|
||||||
|
(eval-query '(greats (great grandson) Adam ?ggs))
|
||||||
|
(newline)
|
||||||
|
|
||||||
(display "\nex-4.70\n")
|
(display "\nex-4.70\n")
|
||||||
|
|
||||||
7
ex-4_70-xx.scm
Normal file
7
ex-4_70-xx.scm
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
(load "util.scm")
|
||||||
|
(load "misc/sicp-query.scm")
|
||||||
|
|
||||||
|
(initialize-data-base microshaft-data-base)
|
||||||
|
|
||||||
|
(display "\nex-4.70\n")
|
||||||
|
|
||||||
Reference in New Issue
Block a user