%%%%Date: Tue, 9 Jun 92 16:12:33 -0700 %%%%From: chan@CS.UCLA.EDU (Christina Chan) Message-Id: <9206092312.AA08676@oahu.cs.ucla.edu> % Christina Chan % cs 239 Project 2 %%%%%%%%%%%%%%%%%% % UCLA MovieBase % %%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% database ( { address(Theatre: string, Street: string, Phone: string, Comments: string), % address, phone no and other information about a theatre chain(Theatres: {string}, Name: string), % The set of theatres that belongs to this chain closer(Theatre1: string, Theatre2: string), % Theatre1 is closer than Theatre2 listing(Theatre: string, Movie: string, Date: string, Times: {real}), % movie listing rating(Movie: string, Rating: string, Categories: {string}), % rating and categories of a movie discount(Chain: string, Price: real) % discount ticket prices of participating chains }). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Query Forms %%%%%%%%%%%%%% % % Database Maintenance % % Remove old listings % export remove($Theatre, $Movie). export delnoshow(Movie). % Add new listings % export new_listing($Theatre, $Movie, $Rating, $Date, $Times, $Categories). % Generic Movie Information %%%%%%%%%%%%%%%%%%%%%%%%%%%% export current_films(Movie). export current_films($Movie). export rating(Movie, Rating, Categories). export rating($Movie, Rating, Categories). export rating(Movie, $Rating, Categories). export listing(Theatre, Movie, Date, Times). export listing($Theatre, Movie, Date, Times). export listing(Theatre, $Movie, Date, Times). export listing(Theatre, Movie, $Date, Times). export listing(Theatre, $Movie, $Date, Times). export listing($Theatre, $Movie, Date, Times). export listing($Theatre, Movie, $Date, Times). export listing($Theatre, $Movie, $Date, Times). export now_showing(Theatre, Movie). export now_showing($Theatre, Movie). export now_showing(Theatre, $Movie). export bring_kids(Movie). export bring_kids($Movie). export student_disc(Movie, Price, Theatre, Chain). export student_disc($Movie, Price, Theatre, Chain). export student_disc(Movie, Price, $Theatre, Chain). export student_disc(Movie, Price, Threatre, $Chain). % Generic Theatre Information %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% export theatre(Name). export theatre($Name). export address(Theatre, Street, Phone, Comments). export address($Theatre, Street, Phone, Comments). export chain(Theatres, Chain). export chain(Theatres, $Chain). export same_chain($Theatre, X). export discount(Chain, Price). export discount($Chain, Price). export closer(Theatre, X). export closer_ucla(X, $Theatre). % Deduces a list of suitable movies given a set of preferred categories % export prefer(Movie, Theatre, $Char, Date, Times). % Deduces the next available showing of a given movie % export next($CurrentTime, $Movie, Theatre, Date, Time). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Rules % % Delete old theatre listings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% remove(Theatre, Movie) <- listing(Theatre, Movie, _, _), -listing(Theatre, Movie, _, _). delnoshow(Movie) <- rating(Movie, _, _), ~listing(_, Movie, _, _), -rating(Movie, _, _). % Add new theatre listings and add new movie's ratings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% new_listing(Theatre, Movie, Rating, Date, Times, Categories) <- +listing(Theatre, Movie, Date, Times), if ( ~rating(Movie, _,_) then +rating(Movie, Rating, Categories) ). % List movies currently playing in theatres %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% current_films(Movie) <- listing(_, Movie, _, _). % List what theatres are showing %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% now_showing(Theatre, Movie) <- listing(Theatre, Movie, _, _). % Find movies that are suitable for kids %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bring_kids(Movie) <- listing(_, Movie, _, Times), rating(Movie, Rating, Categories), Rating ~= r, not_horror(Categories), early(Times). not_horror(Categories) <- ~member(horror, Categories). early(Times) <- member(E, Times), E <= 22.00, E >= 9.00 . % Find whether student discounts are available %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% student_disc(Movie, Price, Theatre, Chain) <- listing(Theatre, Movie, _, _), findchain(Theatre, Chain), discount(Chain, Price). findchain(Theatre, Chain) <- chain(Set, Chain), member(Theatre, Set). % List all theatres %%%%%%%%%%%%%%%%%%%% theatre(Name) <- address(Name, _,_,_). % List all theatres that are in the same chain as the one given %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% same_chain(Theatre, ) <- findchain(Theatre, Chain), findchain(X, Chain), X ~= Theatre. % Find all theatres closer to UCLA than the one given %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% closer_ucla(X, Theatre) <- closer(X, Theatre). closer_ucla(X, Theatre) <- closer(X, Y), closer_ucla(Y, Theatre). % Find a set of movies given a set of preferences %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% prefer(Movie, Theatre, Char, Date, Times) <- rating(Movie, _, Categories), subset(Char, Categories), listing(Theatre, Movie, Date, Times). % Finds next available movie time %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% next(CurrentTime, Movie, Theatre, Date, Time) <- listing(Theatre, Movie, Date, X), later_time(CurrentTime, X, Y), member(Time, Y), ~most(Time, Y). later_time(CurrentTime, X, ) <- member(Y, X), Y > CurrentTime. most(Time, Y) <- member(Time, Y), member(Z, Y), Z < Time. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%