Implement 4.69

main
Felix Martin 2021-03-04 12:35:22 -05:00
parent 209e58d1c5
commit ea4a51aca1
2 changed files with 22 additions and 9 deletions

View File

@ -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")

7
ex-4_70-xx.scm Normal file
View File

@ -0,0 +1,7 @@
(load "util.scm")
(load "misc/sicp-query.scm")
(initialize-data-base microshaft-data-base)
(display "\nex-4.70\n")