Efficient Evaluation of Fuzzy Deduction Karel Jezˇek ? jezek
[email protected]
Martin Zı´ma?
[email protected]
Abstract: We describe the application of the magic sets method for efficient query evaluation of fuzzy logic programs. The logic programs considered are written in Datalog language and are processed by the deductive database system developed at the Department of Computer Science and Engineering, University of West Bohemia. Deductive system enriched with fuzzy logic is able to better serve as a knowledge system. Speeding up its execution makes this system practically useful. Key Words: Confidence Factor, Deductive Database, Fuzzy Logic, Magic Sets Method
1 Introduction The Experimental Deductive Database System (EDD) developed at CS&E Dept. of UWB is designed as a translator’s front-end compiling Datalog programs into the SQL language. The produced SQL program is processed by a commercial Oracle database system [4]. Deductive database systems make it possible to deduce new facts not contained among facts of original (extensional) database. These new facts are derived on the base of deduction rules (intensional database). In the case when the facts of the extensional database and/or the rules describing intensional database are vague, the evaluation with uncertainty has to be used. Uncertain information may arise in databases and knowledge bases in various ways. Imprecise information may be expressed at the attribute value level, at the level of the predicate applicability or at the tuple (fact) level. Only the last two are considered in this paper. What concerns the uncertainty model, we have used the fuzzy logic approach. The alternative way is to introduce the probability into the process of deduction. Both of these mentioned approaches have many similarities, but probabilistic methods are computationally more costly and fail in the case of recursive evaluation of deduction. From varieties of fuzzy logics we have investigated Zadeh’s logic, Go¨del’s logic and Lukasiewicz’s logic. Principles of deduction evaluation with fuzzy logic were published in [5], where the notion of confidence (certainty) factor (CF) is introduced. As a confidence factor we use the real number from [0, 1] interval. We believe the deductive system equipped with fuzzy logic should serve as knowledge system, able to operate (with respect to Oracle’s back-end) on big amount of data. Efficiency of query evaluation in database systems (deductive as well) is crucial. Sophisticated query optimization techniques, such as magic sets and counting methods, have existed in the deductive database literature for many years [1, 2], but have yet to be studied in any detail for fuzzy and probabilistic deductive databases [8]. ?
Department of Computer Science, University of West Bohemia, Univerzitnı´ 22, 306 14, Plzenˇ
In the second section the semantics of fuzzy logics is described. Third section deals with possibility of magic sets method application in the environment of fuzzy logic programs. The results of some experiments are introduced in the fourth section.
2 Fuzzy Logic Semantics Definition 1. Let p, q be predicates, u and v their argument value vectors u = u1; u2 ; : : :; un , v = v1; v2; : : : ; vm, where ui : i = 1::n, vj : j = 1::m have to be instantiated with constants. The
semantics of Go¨del and Zadeh fuzzy conjunction (^), fuzzy disjunction (_) and fuzzy negation (not) is as follows:
CF (p(u) ^ q(v)) = min CF (p(u)); CF (q(v)) CF (p(u) _ q(v)) = max CF (p(u)); CF (q(v)) CF (not p(u)) = if CF (p(u)) = 0 then 1 else 0 CF (not p(u)) = 1 ? CF (p(u))
for Go¨del fuzzy negation for Zadeh fuzzy negation
and the Lukasiewicz connectives are introduced as :
CF (p(u) ^ q(v)) = max 0; CF (p(u)) + CF (q(v)) ? 1 CF (p(u) _ q(v)) = min 1; CF (p(u)) + CF (q(v)) CF (not p(u)) = 1 ? CF (p(u)) We will use CF (p) instead CF (p(u)) for brevity in the equations introduced below. Theorem 2. If p1 , p2 , . . . , pn are predicates, CF (p1 ), CF (p2), . . . , CF (pn ) their confidence factors, then the resulting Zadeh or Go¨del fuzzy conjunction of these predicates is: n ^ CF pi = min CF (p1); CF (p2); : : :; CF (pn) i=1 Proof. Obvious. Theorem 3. If p1 , p2 , . . . , pn are predicates, CF (p1 ), CF (p2), . . . , CF (pn ) their confidence factors, then the resulting Lukasiewicz fuzzy conjunction of these predicates is:
CF
n ^ i=1
pi
=
n X
max 0;
i=1
CF (pi) ? n + 1
Proof. Mathematic induction shall be used to proof this theorem. 1. Initialization step
CF (p1 ^ p2) = max 0; CF (p1) + CF (p2) ? 2 + 1 = max 0; CF (p1 ) + CF (p2 ) ? 1
2. Assumption for k predicates
CF
k ^
pi
=
k X
max 0;
CF (pi) ? k + 1
i=1 i=1 3. Proof for k + 1 predicates ! k +1 ^ k^ CF pi = max 0; CF pi + CF (pk+1) ? 1 i=1 i=1 ! X k CF (pi) ? k + 1 + CF (pk+1) ? 1 = max 0; max 0; i=1 ! kX +1 CF (pi) ? (k + 1) + 1 = max 0; i=1
3 Application of Magic Sets Method
P denotes a set of rules, D denotes a set of facts belonging to a logical program IP = P [ D. Definition 4. Let us have two different logical programs P [ D, P [ D and the query Q. We say the P and P are equivalent sets of rules if for every possible extensional database D, the programs P [ D and P [ D produce the same answer to the query Q. We denote these Suppose
0
0
00
00
0
00
programs equivalent as well.
As it was mentioned in the introduction, magic sets method can be used to optimize query evaluation. This method produces the so-called magic program IPm which is equivalent with the original program IP. The program IPm consists of magic rules defining magic predicates and modified original rules. The construction of the resulting magic program is described in [1, 2, 6, 9]. We obtain the modified rules by putting magic predicates into the bodies of the original rules. Every modified rule can contain a different number of magic predicates in its body. But the evaluation of modified rules must not change the resulting value of the head predicate confidence factors. In the case the original rule has the form:
p(X ) : ?p1(X1); p2(X2); : : :; pn (Xn ) CF value: The resulting value of the confidence factor for predicate p is n ^ CF = CF pi value i=1 Let us denote magic predicates as m pj , j
(1)
::m. The modified rule has the form: p(X ) : ?p1(X1); : : :; pn (Xn ); m p1(Y1); : : : ; m pm (Ym ) CF value: =1
The resulted value of confidence factor is ! ^ m n ^ m pj value pi ^ CF = CF j =1 i=1
(2)
The original program and its corresponding magic program have to be equivalent (including the resulting CF values). From this follows that the values of equations (1) and (2) must be identical. We reach this equivalence easily for Go¨del’s or Zadeh’s fuzzy logic where fuzzy conjunction is expressed as the minimum.
min CF (p1); CF (p2); : : :; CF (pn) = = min CF (p1 ); CF (p2); : : : ; CF (pn ); CF (m p1 ); CF (m p2 ); : : : ; CF (m pm ) The solution of this equation is as follows
8i 2 [1; m] min CF (p1); CF (p2); : : :; CF (pn )