2014年11月1日土曜日

開発環境

計算機プログラムの構造と解釈[第2版](ハロルド エイブルソン (著)、ジュリー サスマン (著)、ジェラルド・ジェイ サスマン (著)、Harold Abelson (原著)、Julie Sussman (原著)、Gerald Jay Sussman (原著)、和田 英一 (翻訳)、翔泳社、原書: Structure and Interpretation of Computer Programs (MIT Electrical Engineering and Computer Science)(SICP))の4(超言語的抽象)、4.4(論理型プログラミング)、4.4.1(推論的情報探索)、データベースの例、単純質問、合成質問、規則、問題 4.60.を解いてみる。

その他参考書籍

問題 4.60.

;; 各人に一意的なidを割り当てて、各対が一度しk現れないようにする方法がある。
;; 表明
(id (Bitdiddle Ben) 0)
(id (Hacker Alyssa P) 1)
(id (Fect Cy D) 2)
(id (Tweakit Lem E) 3)
(id (Reasoner Louis) 4)
(id (Warbucks Oliver) 5)
(id (Scrooge Eben) 6)
(id (Cratchet Robert) 7)
(id (Aull DeWitt) 8)

;; 規則
(rule (lives-near-1 ?person-1 ?person-2)
      (and (address ?person-1 (?town . ?rest-1))
           (address ?person-2 (?town . ?rest-2))
           (id ?person-1 ?n-1)
           (id ?person-2 ?n-2)
           (lisp-value < ?n-1 ?n-2)))

;; 質問
(lives-near-1 ?person-1 ?person-2)

0 コメント:

コメントを投稿