Implement 4.69
parent
209e58d1c5
commit
ea4a51aca1
|
@ -131,15 +131,21 @@
|
|||
|
||||
(display "\nex-4.69 - greats\n")
|
||||
|
||||
; Beginning with the data base and the rules you formulated in exercise 4.63,
|
||||
; devise a rule for adding ``greats'' to a grandson relationship. This should
|
||||
; enable the system to deduce that Irad is the great-grandson of Adam, or that
|
||||
; Jabal and Jubal are the great-great-great-great-great-grandsons of Adam.
|
||||
; (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
|
||||
; this to express a rule that allows one to derive the relationship ((great .
|
||||
; ?rel) ?x ?y), where ?rel is a list ending in grandson.) Check your rules on
|
||||
; queries such as ((great grandson) ?g ?ggs) and (?relationship Adam Irad).
|
||||
(eval-query
|
||||
'(rule (greats ?relation ?parent ?grandson)
|
||||
(and (grandson ?parent ?grandson)
|
||||
(same ?relation (grandson)))))
|
||||
|
||||
(eval-query
|
||||
'(rule (greats ?relation ?parent ?grandson)
|
||||
(and (nson ?parent ?son)
|
||||
(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")
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
(load "util.scm")
|
||||
(load "misc/sicp-query.scm")
|
||||
|
||||
(initialize-data-base microshaft-data-base)
|
||||
|
||||
(display "\nex-4.70\n")
|
||||
|
Loading…
Reference in New Issue