% PROGRAM	SPECIFICATION
% 
% In 1991, Sydney will host the next International Joint Conference on Artif-
% icial Intelligence (IJCAI). Cities bid to host the conference in much the
% same way as they bid to host the Olympics. When choosing the host city for
% the conference, the IJCAI committee must be satisfied of the following:
% 
% +    There must be a suitable venue for the conference.
% 
% +    Sufficient hotel accomodation for the attendees must be available.
% 
% +    The local organising committee must be competent.
% 
% A venue is suitable for the conference if:
% 
% +    there is a main hall capable of seating at least 3,000 people,
% 
% +    there two or more lecture theatres capable of seating 800 or more,
% 
% +    there 10 or more tutorial rooms capable of seating 100 or more,
% 
% +    the convention centre has a banquet hall for at least 3,000 people.
% 
% Accomodation must be available for a range of budgets:
% 
% +    200 luxury hotel rooms,
% 
% +    1000 intermediate hotel rooms,
% 
% +    1800 budget beds (in hotels or university colleges).
% 
% The local organising committee is considered competent if:
% 
% +    members of the committee have organised a previous IJCAI conference
% 
% +    OR they have prepared a proposal that satisfies the IJCAI committee
% 
% Translate these rules into a set of Prolog clauses. Your program should be
% able to answer the question:
% 
% 	host(City)?
% 
% with yes if the city satisfies all of the above conditions and fails other-
% wise.  For example:
% 
% 	host(Sydney)?
% 
% would succeed if the following facts were in prolog's data base.
% 
% 	main_hall(sydney, "Entertainment Centre", 8000).
% 
% 	lecture_theatre(sydney,	"Darling Harbour 1", 2000).
% 	lecture_theatre(sydney,	"Darling Harbour 2", 1000).
% 
% 	tutorial_room(sydney, "Darling Harbour 3", 350).
% 	tutorial_room(sydney, "Darling Harbour 4", 300).
% 	tutorial_room(sydney, "Darling Harbour 5", 200).
% 	tutorial_room(sydney, "Darling Harbour 6", 200).
% 	tutorial_room(sydney, "Darling Harbour 7", 150).
% 	tutorial_room(sydney, "Darling Harbour 8", 100).
% 	tutorial_room(sydney, "Darling Harbour 9", 100).
% 	tutorial_room(sydney, "Darling Harbour 10", 100).
% 	tutorial_room(sydney, "Darling Harbour 11", 100).
% 	tutorial_room(sydney, "Darling Harbour 12", 100).
% 
% 	banquet_hall(sydney, "Maritime Museum",	3500).
% 
% 	accomodation(sydney, "Regent Hotel", luxury, 300).
% 	accomodation(sydney, "Menzies Hotel", intermediate, 300).
% 	accomodation(sydney, "Wentworth	Hotel",	luxury,	100).
% 	accomodation(sydney, "Wentworth	Hotel",	intermediate, 200).
% 	accomodation(sydney, "Hyatt Hotel", intermediate, 200).
% 	accomodation(sydney, "Hilton Hotel",  intermediate, 450).
% 	accomodation(sydney, "UNSW Colleges", low, 800).
% 	accomodation(sydney, "Sydney Uni Colleges", low, 800).
% 	accomodation(sydney, "Macquarie	Uni Colleges", low, 400).
% 
% 	local_committee(sydney,	satisfactory_proposal).
% 
% Note that if Sydney had hosted a previous conference then we might have
% entered the following fact into the data base.
% 
% 	local_committee(City, previous_experience).
% 
% 
% You may wish to make use of the following Prolog predicates:

% count_room_capacity specifies	that a city can	provide	rooms of a given
% type and minimum seating capacity and	there are at least MinNumber such
% rooms	available.

count_room_capacity(City, Type,	MinSize, MinNumber) :-
	bagof(N, (Type(City, _,	N), N >= MinSize), RoomList),
	length(RoomList, Length),
	Length >= MinNumber.

% count_beds specifies that a city can provide a minumum number	of beds
% of a given type.

count_beds(City, Type, Minimum)	:-
	bagof(N_beds, accomodation(City, _, Type, N_beds), L),
	sum(L, Sum),
	Sum >= Minimum.

% the first argument of	sum is a list of numbers, the second is	the sum
% of the elements of the list.

sum([],	0).
sum([X|Y], S) :-
	sum(Y, SY),
	S is X + SY.
