Docsity

Logic Programming and Artificial Intelligence Practical Problem Sheet 7 Solutions, Study notes of Computer Numerical Control

Toggle sidebar
bg1
Logic Programming and Artificial Intelligence
Practical Problem Sheet 7
Solutions
1. Here are the required predicates:
patient/2: patient(X,Y) denotes that doctor X is assigned patient Y.
illness/3: illness(X,Y,Z) denotes that patient X had illness Y in year Z.
registered/2: registered(X,Y) denotes that patient X has registered with the
practice in year Y.
male/1: male(X) denotes that patient X is male.
female/1: female(X) denotes that patient X is female.
2.
a) registered(smith,X).
b) illness(X,high_blood_pressure,W), female(X), W < 2000.
c) patient(X,Y), patient(Z,X).
d) patient(X,X).
3.
It is necessary to be able to use an inequality operator, let’s call it “\=”. This would
then lead to the query: illness(X,Y,W),illness(X,Z,W), X \= Z.
4.
a) The output is:
T1 = [d,e | T2]
L = [a,b,c,d,e | T2] – T2
Yes.
b) The predicate is appending the second list to the first, and returns it in the third list.
c) It is much more efficient than the recursive version of “append” defined in the
lectures, since it just performs unification and no recursion.
d) p(A-B,B–C,C–D,A–D).

Partial preview of the text

Download Logic Programming and Artificial Intelligence Practical Problem Sheet 7 Solutions and more Study notes Computer Numerical Control in PDF only on Docsity!

Logic Programming and Artificial Intelligence Practical Problem Sheet 7 Solutions

1. Here are the required predicates:  patient/2: patient(X,Y) denotes that doctor X is assigned patient Y.  illness/3: illness(X,Y,Z) denotes that patient X had illness Y in year Z.  registered/2: registered(X,Y) denotes that patient X has registered with the practice in year Y.  male/1: male(X) denotes that patient X is male.  female/1: female(X) denotes that patient X is female. 2. a) registered(smith,X). b) illness(X,high_blood_pressure,W), female(X), W < 2000. c) patient(X,Y), patient(Z,X). d) patient(X,X). 3. It is necessary to be able to use an inequality operator, let’s call it “=”. This would then lead to the query: illness(X,Y,W),illness(X,Z,W), X = Z. 4. a) The output is: T1 = [d,e | T2] L = [a,b,c,d,e | T2] – T Yes. b) The predicate is appending the second list to the first, and returns it in the third list. c) It is much more efficient than the recursive version of “append” defined in the lectures, since it just performs unification and no recursion. d) p(A - B, B – C, C – D, A – D).