diff --git a/ex-4_61-xx.scm b/ex-4_61-69.scm similarity index 86% rename from ex-4_61-xx.scm rename to ex-4_61-69.scm index 7930ba5..f1d431b 100644 --- a/ex-4_61-xx.scm +++ b/ex-4_61-69.scm @@ -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") diff --git a/ex-4_70-xx.scm b/ex-4_70-xx.scm new file mode 100644 index 0000000..0368ce8 --- /dev/null +++ b/ex-4_70-xx.scm @@ -0,0 +1,7 @@ +(load "util.scm") +(load "misc/sicp-query.scm") + +(initialize-data-base microshaft-data-base) + +(display "\nex-4.70\n") +