Chapter 4, Metalinguistic Abstraction
Exercise 4.57
Rule:
Notice assert!
for adding rules.
1
2
3
4
5
6
7
8
9
10
;;; Query input:
(assert!
(rule (can-replace ?per1 ?per2)
(and (job ?per1 ?job1)
(job ?per2 ?job2)
(not (same ?per1 ?per2))
(or (same ?job1 ?job2)
(can-do-job ?job1 ?job2)))))
Assertion added to data base.
(a)
1
2
3
4
5
6
;;; Query input:
(can-replace ?per1 (Fect Cy D))
;;; Query results:
(can-replace (hacker alyssa p) (fect cy d))
(can-replace (bitdiddle ben) (fect cy d))
(b)
1
2
3
4
5
6
;;; Query input:
(and (can-replace ?p1 ?p2) (and (salary ?p1 ?s1) (salary ?p2 ?s2) (lisp-value < ?s1 ?s2)))
;;; Query results:
(and (can-replace (fect cy d) (hacker alyssa p)) (and (salary (fect cy d) 35000) (salary (hacker alyssa p) 40000) (lisp-value < 35000 40000)))
(and (can-replace (aull dewitt) (warbucks oliver)) (and (salary (aull dewitt) 25000) (salary (warbucks oliver) 150000) (lisp-value < 25000 150000)))