Author(s): Claudio Vaucheret, Sergio Guadarrama, Francisco Bueno.
Version: 1.11#222 (2004/5/24, 13:8:7 CEST)
Version of last change: 1.11#201 (2004/2/26, 15:42:27 CET)
This package impements an extension of prolog to deal with uncertainty. We implement a fuzzy prolog that models interval-valued fuzzy logic. This approach is more general than other fuzzy prologs in two aspects:
We add uncertainty using CLP(R) instead of implementing a new fuzzy resolution as other fuzzy prologs. In this way, we use the original inference mechanism of Prolog, and we use the constraints and its operations provided by CLP(R) to handle the concept of partial truth. We represent intervals as constrains over real numbers and aggregation operators as operations with constraints.
Each fuzzy predicate has an additional argument which represents its truth value. We use ":~" instead of ":-" to distinguish fuzzy clauses from prolog clauses. In fuzzy clauses, truth values are obtained via an aggregation operator. There is also some syntactic sugar for defining fuzzy predicates with certain membership functions, the fuzzy counterparts of crisp predicates, and the fuzzy negation of a fuzzy predicate.
fuzzy
):- use_package(fuzzy).
or
:- module(...,...,[fuzzy]).
:~/2
[1200,xfx],
:~/1
[1200,xf],
:=/2
[1200,xfx],
:=/1
[1200,xf],
:#/2
[1200,xfx],
=>/1
[1175,fx],
fnot/1
[1150,fx],
aggr/1
[1150,fx],
##/2
[1120,xfy],
<#/2
[1120,xfy],
#>/2
[1120,xfy],
fuzzy/1
[1150,fx],
fuzzy_predicate/1
[1190,fx],
fuzzy_discrete/1
[1190,fx].
aggr/1
.
fuzzy
)
Usage: :- aggr(Name)
.
Name
an aggregator. Its binary definition has to be provided. For example:
:- aggr myaggr. myaggr(X,Y,Z):- Z .=. X*Y.defines an aggregator identical to
prod
.
Name
is an atomic term (an atom or a number).
(basic_props:constant/1
)
fuzzy
)
Usage: :#(Name, Decl)
Name
from the declaration Decl
.
Name
is a Name/Arity structure denoting a predicate name:
predname(P/A) :- atm(P), nnegint(A).(
basic_props:predname/1
)
Decl
is one of the following three:
fuzzydecl(fuzzy_predicate(_1)). fuzzydecl(fuzzy(_1)). fuzzydecl(fnot(_1)).(
user(... /fuzzy_doc):fuzzydecl/1
)
Usage: fuzzy_predicate(Domain)
Domain
, which is a list of pairs of domain-truth values, in increasing order and exhaustive. For example:
young :# fuzzy_predicate([(0,1),(35,1),(45,0),(120,0)]).defines the predicate:
young(X,1):- X .>=. 0, X .<. 35. young(X,M):- X .>=. 35, X .<. 45, 10*M .=. 45-X. young(X,0):- X .>=. 45, X .=<. 120.
Domain
is a list.
(basic_props:list/1
)
Usage: fuzzy(Name)
Name
. For example,
p_f :# fuzzy p/2defines a new fuzzy predicate
p_f/3
(the last argument is the truth value) with truth value equal to 0 if p/2
fails and 1 otherwise.
Name
is a Name/Arity structure denoting a predicate name:
predname(P/A) :- atm(P), nnegint(A).(
basic_props:predname/1
)
Usage: fnot(Name)
Name
. For example,
notp_f :# fnot p_f/3defines the predicate:
notp_f(X,Y,M) :- p_f(X,Y,Mp), M .=. 1 - Mp.
Name
is a Name/Arity structure denoting a predicate name:
predname(P/A) :- atm(P), nnegint(A).(
basic_props:predname/1
)
Usage: :~(Head, Body)
Head
is the truth value of the clause, which is obtained as the aggregation of the truth values of the body goals. An example:
:- module(young2,_,[fuzzy]). young_couple(X,Y,Mu) :~ min age(X,X1), age(Y,Y1), young(X1,MuX), young(Y1,MuY). age(john,37). age(rose,39). young :# fuzzy_predicate([(0,1),(35,1),(45,0),(120,0)]).so that:
?- young_couple(john,rose,M). M .=. 0.6 ?
Head
is a term which represents a goal, i.e., an atom or a structure.
(basic_props:callable/1
)
Body
is a clause body plus an optional aggregation operator.
(user(... /fuzzy_doc):fuzzybody/1
)
A clause body, optionally prefixed by the name of an aggregation operator. The agregators currently provided are listed under faggregator/1
. By default, the aggregator used is min
.
Usage: fuzzybody(B)
B
is a clause body plus an optional aggregation operator.
The first three are, respectively, the T-norms: minimum, product, and Lukasiewicz's. The last three are their corresponding T-conorms. Aggregators can be defined by the user, see aggr/1
.
faggregator(min). faggregator(prod). faggregator(luka). faggregator(max). faggregator(dprod). faggregator(dluka).
Usage: faggregator(Aggr)
Aggr
is an aggregator which is cumulative, i.e., its application to several values by iterating pairwise the binary operation is safe.
Usage: =>(Aggr, A, B, Truth)
A => B
defined by aggregator Aggr
, resulting in the truth value Truth
.
Aggr
is an aggregator which is cumulative, i.e., its application to several values by iterating pairwise the binary operation is safe.
(user(... /fuzzy_doc):faggregator/1
)
A
is a term which represents a goal, i.e., an atom or a structure.
(basic_props:callable/1
)
B
is a term which represents a goal, i.e., an atom or a structure.
(basic_props:callable/1
)
Truth
is a free variable.
(term_typing:var/1
)
fuzzy
)An example program:
:- module(dicesum5,_,[fuzzy]). % this example tries to measure which is the possibility % that a couple of values, obtained throwing two loaded dice, sum 5. Let % us suppose we only know that one die is loaded to obtain a small value % and the other is loaded to obtain a large value. % % the query is ? sum(5,M) % small :# fuzzy_predicate([(1,1),(2,1),(3,0.7),(4,0.3),(5,0),(6,0)]). large :# fuzzy_predicate([(1,0),(2,0),(3,0.3),(4,0.7),(5,1),(6,1)]). die1(X,M) :~ small(X,M). die2(X,M) :~ large(X,M). two_dice(X,Y,M):~ prod die1(X,M1), die2(Y,M2). sum(2,M) :~ two_dice(1,1,M1). sum(5,M) :~ dprod two_dice(4,1,M1), two_dice(1,4,M2), two_dice(3,2,M3), two_dice(2,3,M4).
There are more examples in the subdirectory fuzzy/examples
of the distribution.
fuzzy
)sum/2
in the dice example.
Go to the first, previous, next, last section, table of contents.