We have recently conceived a very easy way to model truth degrees lattices for being included into the FLOPER tool. All relevant components of each lattice can be encapsulated inside a Prolog file which must necessarily contain the definitions of a minimal set of predicates defining the set of valid elements (including special mentions to the "top" and "bottom" ones), the full or partial ordering established among them, as well as the repertoire of fuzzy connectives which can be used for their subsequent manipulation. In order to simplify our explanation, assume that file "bool.pl" refers to the simplest notion of (a binary) adjoint lattice, thus implementing the following set of predicates:
member(X) :- number(X),0=<X,X=<1.
bot(0). top(1).
leq(X,Y) :- X=<Y.
and_luka(X,Y,Z) :- pri_add(X,Y,U1),pri_sub(U1,1,U2),pri_max(0,U2,Z).
and_godel(X,Y,Z):- pri_min(X,Y,Z).
and_prod(X,Y,Z) :- pri_prod(X,Y,Z).or_luka(X,Y,Z) :- pri_add(X,Y,U1),pri_min(U1,1,Z).
or_godel(X,Y,Z) :- pri_max(X,Y,Z).
or_prod(X,Y,Z) :-pri_prod(X,Y,U1),pri_add(X,Y,U2),pri_sub(U2,U1,Z).
agr_aver(X,Y,Z) :- pri_add(X,Y,U),pri_div(U,2,Z).
pri_add(X,Y,Z) :- Z is X+Y. pri_min(X,Y,Z) :- (X=Y,Z=Y).
pri_sub(X,Y,Z) :- Z is X-Y. pri_max(X,Y,Z) :- (X=Y,Z=X).
pri_prod(X,Y,Z) :- Z is X * Y. pri_div(X,Y,Z) :- Z is X/Y.
Figure 1: [0,1] lattice (download)
The reader can easily check that the use of lattice "bool.pl" when working with MALP programs whose rules have the form "A ←bool &bool(B1, ... ,Bn) with 1", being A and Bi typical atoms, successfully mimics the behaviour of classical Prolog programs where clauses accomplish with the shape "A : - B1, . . . ,Bn". As a novelty in the fuzzy setting, when evaluating goals each output will contain the corresponding Prolog's substitution (i.e., the crisp notion of computed answer obtained by means of classical SLD-resolution) together with the maximum truth degree 1. On the other hand, in Figure 1 we have modeled the more flexible lattice (that we will mainly use in our examples, beyond the boolean case) which enables the possibility of working with truth degrees in the infinite space of the real numbers between 0 and 1, allowing too the possibility of using conjunction and disjunction operators recasted from the three typical fuzzy logics described before (i.e., the Lukasiewicz, Gödel and product logics), as well as an useful description for the hybrid aggregator average. Note also we have included definitions for auxiliary predicates, whose names always begin with the prefix "pri ". All them are intended to describe primitive/arithmetic operators (in our case +, -, *, /, min and max) in a Prolog style, for being appropriately called from the bodies of clauses defining predicates with higher levels of expressivity (this is the case for instance, of the three kinds of fuzzy connectives we are considering: conjuntions, disjunctions and agreggations).
Since till now we have considered two classical, fully ordered lattices (with a finite and infinite number of elements, collected in files "bool.pl" and "num.pl", respectively), we wish now to introduce a different case coping with a very simple lattice where not always any pair of truth degrees are comparable. So, consider the following partially ordered multi-adjoint lattice in the diagram below for which the conjunction and implication connectives based on the Gödel intuistionistic logic conform an adjoint pair.... but with the particularity now that, in the general case, the Gödel's conjunction must be expressed as &G(x, y) ≜ inf(x, y), where it is important to note that we must replace the use of "min" by "inf" in the connective definition.
member(bottom).
member(alpha).
member(beta).
member(top).
members([bottom,alpha,beta,top]).
leq(bottom,X). leq(X,top).
leq(X,X).
and_godel(X,Y,Z) :- pri_inf(X,Y,Z).
pri_inf(bottom,X,bottom):-!.
pri_inf(alpha,X,alpha):-leq(alpha,X),!.
pri_inf(beta,X,beta):-leq(beta,X),!.
pri_inf(top,X,X):-!.
pri_inf(X,Y,bot).
Figure 2: Example of lattice (download)
To this end, observe in the Prolog code accompanying the figure above that we have introduced five clauses defining the new primitive operator "pri_inf/3" which is intended to return the infimum of two elements. Related with this fact, we must to point out the following aspects:
In order to test the capability of FLOPER for handling lattices, we have prepared these examples: