

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!


School of Electrical Engineering and Computer Science University of Central Florida April 10, 2006
PROLOG HOMEWORK — Prolog Instructions
This assignment will be due on Friday, April 21 at 11:59pm. It will only be accepted late within 24 hours of the due date, after which it will not be accepted. Email to [email protected]. To turn in, put all of your predicates in a file named by a concatenation of your first initial and last name with an extension “.prl”. Example: John Doe would turn in jdoe.prl. Problem 3 is extra credit. It is worth 5 points, that could go towards your mid-term score. Please write all of you own predicates. The only exception to this is that you may use the built in predicate not. If you need “helper” functions, please include them in your file.
Problem 1. Define predicates for “simple” family information.
All binary predicates of form predicate(A,B) in this exercise can be read as A is predicate of B, unless otherwise noted. For this exercise you will be given a knowledge base containing info for three predicates: parent/2, female/1, and male/1. You need to define the following predicates that will work for any family knowledge base:
Example knowledge base
parent(alice,betty). parent(alice,bob). parent(alice,ricky). parent(rebecca,alice). parent(castro,betty). parent(castro,bob). parent(castro,ricky). parent(dana,castro). parent(dana,vince). parent(vince,erma). male(ricky).
COP 4020 Prolog Homework 1 Spring 2006
male(vince). male(bob). male(castro). female(alice). female(betty). female(dana). female(erma). female(rebecca).
Note! If you are going to test with your own KB (which is recommended!), be sure to define the gender of each person. Also, be sure that no one is their own brother or sister.
Problem 2. Design a predicate segment/2 that tests if the first argument is a contiguous series of elements in the second argument.
Example usage
?- segment([2,3,4],[1,2,3,4]). Yes ?- segment([3],[1,2,4]). No ?- segment([],[1,2,4]). Yes ?- segment([1,2,4],[]). No
Problem 3. Extra credit. Optional. Design a predicate bookends/3 that tests if the first argument is a prefix of third and the second is a suffix of the third.
Example usage
?- bookends([1],[2,3,4],[1,2,3,4]). Yes ?- bookends([],[4],[1,2,3,4]). Yes ?- bookends([1],[2,3],[1,2,3,4]). No
COP 4020 Prolog Homework 2 Spring 2006