home *** CD-ROM | disk | FTP | other *** search
-
- /*
- City -- This is a simple Turbo Prolog program which uses fuzzy logic to
- determine how "nice" various cities are.
- */
-
-
- include "fuzzy.pro" /* Include the fuzzy logic module */
-
-
- predicates
- nice_city(symbol) location(symbol)
- city(symbol) climate(symbol)
- warm(symbol) dry(symbol)
- characteristics(symbol)
- population(symbol, integer)
- expensive(symbol)
-
-
- clauses
-
- nice_city(X) :- init_fuzzy, location(X), fuzzy(0.5), p_AND,
- characteristics(X), fuzzy(0.9), p_AND, p_OR,
- fuzzy(Rating),
- write(X, " has a rating of ", Rating), nl.
-
- location(X) :- city(X), climate(X), f_AND.
-
- climate(X) :- warm(X), dry(X), f_AND.
-
- characteristics(X) :- population(X,Pop), Val = Pop/2500.0,
- fuzzy(Val), fuzzy(0.9), p_AND,
- expensive(X), f_NOT, fuzzy(0.5), p_AND,
- p_OR, f_AND.
-
-
- /* Data on various cities */
-
- city(albuquerque) :- fuzzy(1.0).
- city(boston) :- fuzzy(1.0).
- city(ft_worth) :- fuzzy(1.0).
-
- warm(albuquerque) :- fuzzy(0.9).
- warm(boston) :- fuzzy(0.5).
- warm(ft_worth) :- fuzzy(0.9).
-
- dry(albuquerque) :- fuzzy(0.9).
- dry(boston) :- fuzzy(0.6).
- dry(ft_worth) :- fuzzy(0.7).
-
- population(albuquerque, 500) :- fuzzy(1.0).
- population(boston, 2000) :- fuzzy(1.0).
- population(ft_worth, 1500) :- fuzzy(1.0).
-
- expensive(albuquerque) :- fuzzy(0.6).
- expensive(boston) :- fuzzy(0.9).
- expensive(ft_worth) :- fuzzy(0.8).
-