CS 3411 Program 1 -- Prolog Due Wed, Feb 11, 1998 --------------------- Note: Turn-in info will be forthcoming. Questions/clarifications directed to git.cc.class.3411. --------------------- Given the following facts and rules: course(section(1501, a), time(tx, 3), shackelford, 101). course(section(1502, a), time(tx, 3), calvert, 102). course(section(2390, a), time(tx, 1), guzdial, 101). course(section(2390, b), time(tx, 2), potts, 101). course(section(2430, a), time(mwf, 2), greenlee, 102). course(section(2430, b), time(tx, 1), greenlee, 102). course(section(3310, a), time(mwf, 1), arkin, 102). course(section(3310, b), time(mwf, 3), arkin, 102). course(section(3312, a), time(mwf, 2), stasko, 101). course(section(3312, b), time(mwf, 3), stasko, 101). course(section(3411, a), time(mwf, 1), leblanc, 101). course(section(3411, b), time(tx, 2), das, 102). lecturer(Lecturer,Course) :- course(Course,Time,Lecturer,Location). time(Time,Course) :- course(Course,Time,Lecturer,Location). teaches(Day,Lecturer) :- course(Course,time(Day,Time),Lecturer,Location). where the course()'s describe individual courses and lecturer() is a functor that relates who teaches which course and time() relates the the course number and the time it is taught and teaches() relates the day that a lecturer teaches. Write the following functors (shown with sample queries): 1. busy(Lecturer,Time) Relates the time that a lecturer is teaching. | ?- busy(leblanc,time(mwf,1)). yes | ?- busy(leblanc,T). T = time(mwf,1); no | ?- 2. cannot_meet(Time,Lecturer1,Lecturer2) Relates a time that two lecturers cannot meet because one or both are teaching a course. | ?- cannot_meet(time(mwf,1),leblanc,guzdial). yes 3. schedule_conflict(Course1,Course2) Relates times that the two particular courses are taught. | ?- schedule_conflict( section(2390,a), section(2430,b) ). yes | ?- schedule_conflict( section(2390,a), S ). S = section(2390,a); S = section(2430,b); no 4. schedule( ListOfSections ) Should print the particular courses (including time) that are scheduled. | ?- schedule( [ section(1501,a),section(2390,a),section(2430,a), section(3310,a) ] ). Course "1501 a" is on tx at 3. Course "2390 a" is on tx at 1. Course "2430 a" is on mwf at 2. Course "3310 a" is on mwf at 1. yes