# ln024 - Homework Assignment #10 (see website) Prolog Rules...

This preview shows pages 1–4. Sign up to view the full content.

Homework Assignment #10 (see website)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Prolog Rules Prolog rules are Horn clauses, but they are written “backwards”, consider: X,Y[female(X) parent(X,Y) mother(X,Y)] is written in Prolog as mother(X,Y) :- female(X) , parent(X,Y) . Implies (“think of ”) “and” head body You can think of a rule as introducing a new “fact” (the head), but the fact is defined in terms of a compound goal (the body). That is, predicates defined as rules are only true if the associated compound goal can be shown to be true. Prolog rules a implicitly universally quantified!
% a simple prolog program female(pam). female(liz). female(ann). female(pat). male(tom). male(bob). male(jim). parent(pam,bob). parent(tom,bob). parent(tom,liz). parent(bob,ann). parent(bob,pat). parent(pat,jim). mother(X,Y) :- female(X),parent(X,Y). ! Queries: ?- mother(pam,bob). ?- mother(Z,jim). ?- mother(P,Q).

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 10/03/2011 for the course CSC 301 taught by Professor Hamel during the Spring '08 term at Rhode Island.

### Page1 / 13

ln024 - Homework Assignment #10 (see website) Prolog Rules...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online