bourhood of Los Angeles city. The database con-
sists of three tables (relations, represented by BPL
facts) with a total of eight attributes. The
film
ta-
ble has three attributes: title, director and category
of the film. The
theater
table is characterized by
the theater name, owner and location of the theater.
The
engagement
table is used to link the information
stored in the first two tables and it has two attributes:
the title of the film and the name of the theater. The
fuzzy component is defined by two proximity rela-
tions. The first one states the similarity between the
different film categories (i.e., it is defined on the syn-
tactic domain of film categories) and the second one
states the closeness of two theater locations (i.e., it is
defined on the syntactic domain of theater locations).
In this example, both fuzzy relations are implemented
explicitly by means of a set of proximity equations.
%% DIRECTIVE
:-lambdaCut(0.5). %% only approximation degrees equal or
%% greater than 0.5 are considered
%% PROXIMITY RELATIONS
%% Location Distance Relationship
bervely_hills˜downtown=0.3. downtown˜santa_monica=0.23.
bervely_hills˜santa_monica=0.45.downtown˜westwood=0.25.
bervely_hills˜hollywood=0.56. hollywood˜santa_monica=0.3.
bervely_hills˜westwood=0.9. hollywood˜westwood=0.45.
downtown˜hollywood=0.45. santa_monica˜westwood=0.9.
%% Category Relationship
comedy˜drama=0.6. drama˜adventure=0.6.
comedy˜adventure=0.3. drama˜suspense=0.6.
comedy˜suspense=0.3. adventure˜suspense=0.9.
%% Films Table
%% film(Title, Director, Category)
film(four_feathers, korda, adventure).
film(modern_times, chaplin, comedy).
film(psycho, hitchcock, suspense).
film(rear_window, hitchcock, suspense).
film(robbery, yates, suspense).
film(star_wars, lucas, adventure).
film(surf_party, dexter, drama).
%% Theaters Table
%% theater(Name,Owner,Location).
theater(chinese, mann, hollywood).
theater(egyptian, va, westwood).
theater(music_hall, lae, bervely_hills).
theater(odeon, cineplex, santa_monica).
theater(rialto, independent, downtown).
theater(village, mann, westwood).
%% Engagements Table
%% engagement(Film,Theater)
engagement(modern_times, rialto).
engagement(start_wars, rialto).
engagement(star_wars, chinese).
engagement(rear_window, egyptian).
engagement(surf_party, village).
engagement(robbery, odeon).
engagement(modern_times, odeon).
engagement(four_feathers, music_hall).
%% MAIN RULE
%% search(input, input, output, output)
search(Category, Location, Film, Theater) :-
film(Film, _, Category), engagement(Film, Theater),
theater(Theater, _, Location).
The predicate
search/4
allows us to know the
cinema which is showing a film closest to our
location and category of preference. If we
launch the goal “
search(adventure, westwood,
Film, Theater).
”, the system answers: “
Film =
rear window, Theater = egyptian, with 0.9
”
(a suspense film located at
west- wood
), “
Film =
surf party, Theater = village, with 0.6
” (a
drama film located at
westwood
), “
Film = robbery,
Theater = odeon, with 0.9
” (a suspense film lo-
cated at
santa monica
), “
Film = four feathers,
Theater = music hall, with 0.9
” (an adventure
film located at
bervely hills
).
Next, we present a BPL program implementing a
fragment of a flexible deductive database in the style
of Prade and Testemale. That is, databases that incor-
porate the notion of fuzziness by means of fuzzy sets
that may be used as attributes of a table.
In this example we model a database fragment for
a real state company with information about flats to
be hired. The company wants to help clients to select
flats in stock, according their preferences.
%% DIRECTIVES declaring and defining linguistic variables
%% (i.e., fuzzy sets)
%% Linguistic variable: rental
:-domain(rental(0,600,euros)).
:-fuzzy_set(rental[cheap(100,100,250,500),
normal(100,300,400,600), expensive(300,450,600,600)]).
%% Linguistic variable: distance
:-domain(distance(0,50,minutes)).
:-fuzzy_set(distance[close(0,0,15,40),
medial(15,25,30,35), far(20,35,50,50)]).
%% Linguistic variable: flat conditions
:-domain(condition(0,10,conditions)).
:-fuzzy_set(conditions[unfair(0,0,1,3), fair(1,3,6),
good(4,6,8), excellent(7,9,10,10)]).
%% FACTS
%% Flats table
%% flat(Code, Street, Rental, Condition).
flat(f1, libertad_street, rental#300, more_or_less#good).
flat(f2, ciruela_street, rental#450, somewhat#good).
flat(f3, granja_street, rental#200, unfair).
%% Streets table
%% street(Name, District)
street(libertad_street, ronda_la_mata).
street(ciruela_street, downtwon).
þÿBOUSI"<PROLOG - A Fuzzy Logic Programming Language for Modeling Vague Knowledge and Approximate Reasoning
95