
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

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).