Rfuzzy framework
Fuzzy reasoning is a very productive research field that during the last years has provided a number of theoretical approaches and practical implementation prototypes. Nevertheless, the classical implementations, like Fril, are not adapted to the lat…
Authors: ** *논문에 저자 정보가 명시되어 있지 않음.* (저자명 및 소속은 원문을 확인하시기 바랍니다.) **
Rfuzzy framew ork Victor Pablos Ceruelo, Susana Munoz-Hernandez, and Hannes Strass Universidad P olit ´ ecnica de Madrid ⋆⋆ { vpablos, susana } at fi.upm.es, hannes.st rass at alumnos.up m.es http://bab el.ls.fi. upm.es/ Abstract. F uzzy reasoning is a very pro ductive researc h field that dur- ing the last years has pro vided a num b er of theoretical app roac hes and practical implementa tion prototypes. Nevertheless, the classical imple- mentatio ns, lik e F ril, are not adapted to the latest formal approaches, lik e m ulti-adjoint logic seman tics. Some promising implemen tations, like F uzzy Prolog, are so general th at the regular user/programmer do es not feel comfortable b ecause either representa tion of fuzzy concepts is complex or the results difficult to interpret. In this paper we p resen t a mo dern f ramew ork, Rfuzzy , that is mo delling multi-adjo int logi c. It provides s ome extensions as default v alues (to rep- resen t missing information, even partial default v alues) and typed v ari- ables. Rfuzzy represen ts the truth v alue of predicates through facts, rules and functions. Rfuzzy a nsw ers queries with direct results (instead of con- strain ts) and it is easy to use for any p erson that wan t s to rep resen t a problem using fuzzy reasoning in a simple w ay (by u sing the classica l representa tion wi th real numbers). Key wor ds : F uzzy reasoning, Implemen tation to ol, F uzzy Logic , Multi- adjoin t logic, Logic Programming Application 1 In t ro duction One o f the reaso ning mo dels that is more useful to represent real situations is fuzzy reasoning. Indeed, world infor ma tion is not represented in a crisp wa y . Its representation is imperfect, fuzzy , etc., so that the ma nagement of uncertain ty is v e r y imp orta nt in knowledge representation. There are m ultiple frameworks for incorp ora ting uncertaint y in logic prog ramming: – fuzzy set theory [5, 38, 32], – probability theory [8, 16, 20 , 25, 26], – m ulti-v alued logic [7, 11, 12 , 15, 1 7, 29], – po ssibilistic logic [6, 36, 37 ] ⋆⋆ This work is partially supp orted b y the pro ject DESAFIO S - TIN 2006-15660-C02- 02 from the S panish Ministry of Ed ucation and Science and p ro ject PROMESAS - S-0505/TIC/04 07 from the Madrid Regional Gov ernment. Rfuzzy framework 63 Despite of the multitude of theoretical approaches to this issue, few o f them resulted in a ctual practically usa ble to o ls. Since Lo gic Prog ramming is tradition- ally used in Knowledge Representation and Reas oning, we argue it is perfectly well-suited to implement a fuzzy reasoning to ol as ours. 1.1 F uzzy Approac he s in Logi c Programmi ng The result o f intro ducing F uzzy Logic into Logic Prog r amming has been t he developmen t of several fuzzy systems ov e r Prolo g. These systems replace the inference mechanism of Prolog , SLD-r esolution, with a fuzzy v aria nt that is able to handle partial truth. Most o f these systems implemen t the fuzzy reso lution int ro duced b y Le e in [1 8], as the Pr o log-Elf system [10], the FRIL Prolog s y stem [2] and the F-Prolog language [1 9]. H ow ever, there is no c o mmon metho d for fuzzifying Pro lo g, a s has been no ted in [28]. Some of these F uzzy Prolog systems only co nsider the predicates’ fuzziness whereas other systems consider fuzzy facts or fuzzy r ules . Ther e is no agr eement ab out which fuzzy logic sho uld be used. Mo st of them use min-max logic (for mo delling the conjunction and disjunction op er a tions) but other systems just use Luk asiewicz logic [13]. F urthermore, logic progr amming is considered a useful to ol for implemen ting metho ds for reaso ning with uncertain ty in [38]. There is a lso an ex tension of constrain t logic prog ramming [3 ], which can mo del logics based on semiring structures. This fra mew ork can model min-max fuzzy logic, which is the only logic with semiring structure. Another theor etical mo del for fuzzy lo gic pro gramming without negation has bee n prop osed by V o jtas in [35], which deals with many-v alued implications. 1.2 F uzzy Prolog One of the most pr omising fuzzy to ols for Pr olog was the “F uzzy Prolo g” s ystem [33, 9]. The mo s t important adv antages aga inst the other approaches ar e: 1. A truth v alue will be a finite union of sub-interv als on [0 , 1]. An in ter v al is a pa rticular case of union of one e le men t, and a unique truth v alue is a particular case of having an in terv a l with only one elemen t. 2. A truth v a lue is propagated through the r ules b y means of an aggr e gation op er ator . The definition of this ag gr e gation op er ator is general and it sub- sumes conjunctiv e o per ators (t riangular norms [14] lik e min, pro d, etc.), disjunctiv e op era tors [3 1] (triangular co- norms, like max, sum, etc.), a ver- age op era tors (averages as arithmetic average, quasi- linear av er age, etc) a nd hybrid o per ators (combinations of the a bove op erato rs [27]). 3. Crisp and fuzzy reaso ning are consistent ly comb ined [24]. F uzzy P rolog adds fuzziness to a P rolog compiler using CLP ( R ) instea d of implemen ting a new fuzzy re solution, as other former fuzzy Pr ologs do. It rep- resents interv als as constraints ov er real n umbers and aggr e gation op er ators as op erations with these constraints, so it uses P rolog ’s built-in inference mecha- nism to handle the concept of par tia l truth. 64 Victor Pablos Ceruelo, Susana Munoz-Hernandez, and Hannes Strass 1.3 Motiv ation and RF uzzy Approac h Over the last few years several pap ers hav e be en published by Medina et al. ([22, 23, 21 ]) a bo ut m ulti-a djoint prog ramming, which describ e a theoretical mo del, but no means of serious implementations apart from promising prototypes [1]. Indeed, that was the reas on for developing F uzzy Prolog [9]. F uzzy Pr olog is a v ery ex pressive to ol whic h a llows the user 1 to pr ogra m a lmo st everything, but we have to pay for this expres siveness. The cost is a complex syn tax difficult to understand. The mo tiv ation for dev eloping Rfuzzy is mainly foc us ed o n reducing this complex syntax. This reduction is based on three ideas: 1. Use real num ber s in stead of interv als bet ween rea l num b ers to represen t truth v alues. F uzzy Pr olog answ e r s to user queries are in terv als like it wil l r ain (t onight, [0, 1]) . This is a bit difficult to understand by no rmal users. T r uth v alue of this example is b et ween 0 and 1 , and this means that progra m c an not conclude anything a bo ut the predicate truth v alue. 2. Whenever it is p ossible, do no t a ns w er user queries using co nstraints. A F uzzy Pro log answ er to an user query ca n be a cons tr aint, like it wil l r ain (tomorr ow, [X, Y]), X > 0, X < 1, Y > 0, Y < 1 . The meaning of this example is exactly the same a s the meaning of the previous one, but it is slightly more difficult to understand it. 3. T ruth v a lue v ar iables do not need to be co ded. T aking ca re of v ar iables to manage t he pr edicates tr uth v alue intro duces errors and makes the code illegible, without giving us any adv an tage. Rfuzzy uses real num b ers to r epresent truth v alues a nd its replie s are never constraints. Besides, it is able to distinguish b etw een crisp and fuzzy predicates and it manages the introduction of truth v alue v aria ble s , so the user does not need to take care of them. T ruth v aria bles are alw ays intro duced at the end of the pr edicate arguments list, so it ca n b e seen as so me s ynt actic sugar. W e explain this in subsection 2.6. F rom the p oint of view of expr e s siveness, we can remark that RF uzzy offers to the user the abilit y to define types, general and conditioned default v alue s and truth v alue represent ations by means of facts, functions or rules. Besides, it implemen ts mult i-adjoint logic with representation of the concept of credibility of the rules, so it is one of the firs t to ols tha t ar e actually mo delling mu lti-adjoint logic 2 . 1 W e refer as ’user’ to the programmer that w ants to represen t a fuzzy problem in a programming fra mew ork to mak e queries and obtain results. 2 A complete formal ization of th e semantics of RF uzzy with a d escription of a least mod el semantics , a least fixp oint semantics, an op erational semantics and the prov e of their equiv alence can be d o wnloaded at http://babel.ls. fi.upm.es/ software/ rfuzzy/ . This pap er has b een submitted and is p ending of acceptance in an inter- national conference. Rfuzzy framework 65 2 Rfuzzy syn tax In this se ction we are going to describe RF uzzy’s syn ta x . Rfuzzy defines the syntax of a new subset of Pr olog predicates to work w ith truth v a lues and to assign credibility to rules. The extensions that we ha ve added to provide f uzziness of predicates are: type informatio n, truth v alues (for facts, functions and rules) and default truth v alues. RF uzzy shares with F uzzy P rolog most of its nice expressive c har acteristics: Prolog -like s ynt ax (based on using facts and claus es), use of an y aggr egation op erator, flexibilit y of query syntax, constructivity o f the answers, etc. Never- theless, RF uzzy is s impler than F uzzy Prolog for the user because t he truth v alues are simple real num b ers instead of the g eneral s tructures of F uzzy P rolog. 2.1 T yp e definition Prolog do es not ha ve t y pes . Prolog co de a re fo rmulas and a t e x ecution time it lo oks for all of them to be tr ue. T o do that, it generates a Herbrand Univ e r se and tries to substitute ev ery v a riable with a Herbrand term. As w e do not want progra ms to lo ok for a n answer infinitely , we offer the user a fac ilit y to restric t the set of p os s ible solutio ns. This extension is named “ t yp e s ” a nd its syntax is shown in (1). :- s et prop pre d/ar = > ty p e pr ed 1 / 1 [ , ty pe p red 2 / 1 ] ∗ . (1) where set pr op is a reserved word, pr e d is the name of the t yp ed predicate, ar is its a rity a nd typ e pr e d { n } is the predicate used to assure that the v alue given to the argument in the p osition n of a call to pr e d/ar is co rrectly typed. Predicate typ e pr e d { n } must hav e ar ity 1. The ex ample b elow shows that the t wo arguments of the predicate has lower pric e/2 hav e to b e of t yp e c ar/1 and which individuals belong to that type. :- set_p rop has_lo wer_pr ice/2 = > car/1, car/1. car(vw _cadd y). car(al fa_ro meo_gt). car(as ton_m artin_bulldog). car(la mborg hini_urraco). 2.2 F act truth v alue F uzzy facts are fac ts to which we assign a truth v alue. T o co de them in progr ams we offer a specia l syntax, s o Prolog can distinguish b etw een no r mal facts and fuzzy facts. This syntax is sho wn in (2). pre d ( arg s ) v alue tru th v al . (2) Arguments ( ar gs ) should b e g round and the truth v alue ( truth val ) must be a rea l num b er b etw een 0 and 1. The example b elow defines that the car alfa r ome o gt is a n exp ens ive c ar with a truth v alue 0.6. expens ive_c ar(alfa_romeo_gt) va lue 0.6 . 66 Victor Pablos Ceruelo, Susana Munoz-Hernandez, and Hannes Strass 2.3 F unctional truth v alue F act truth v alue definition (see subsection 2.2) is worth for a finite (and rela - tive small) n umber of individuals. As w e may want to define a big amoun t of individuals, we need more than this. F uzzy tr uth v alues are usually represented using contin uous functions. Fig. 1 sho ws an example in which the truth v alue function assigns the truth v alue of being te enager from the p erso n’s ag e v alue. 19 20 age 0 9 10 teenager 1 Fig. 1. T eenager credibilit y . A function ca n be defined in several w ays, but the easie st one is via a se q uence of orde r ed pairs whose first element is the fac t and the second element is the truth v alue assig ned to that fact. F unctions use d to define the truth v a lue of some g roup of facts are us ually contin uous and linear o ver in terv als. T o define those functions there is no neces- sity to wr ite do wn the v alue assigned to each ele men t in their doma ins. A b etter wa y to define them is by means o f their inflex ion p oints, so function v alues for the elements b etw een the inflexion p oints are determined by means of interp olation. RF uzzy pr ovides the syn tax for defining functions by stretc hes. This syntax is shown in (3). External brac kets represent the P rolog list symbo ls and internal brack ets represent car dinalit y in the formula no tation. ar g1, ..., ar gN should b e ground terms (num b ers) and tru th val1, ..., truth valN should b e bo rder truth v alues. The truth v a lue of the rest o f the elements (apar t from the b o rder ele- men ts) is obtained by in terp olatio n. pre d :# ([( arg 1 , tr uth v al 1) , ( arg 2 , tru th v al 2) [ , ( arg 3 , tru th v al 3) ] ∗ ]) . (3) :- set_p rop teenag er/1 => people_ age/1. :- defau lt(tee nager/1, 0). teenag er :# ( [ (9, 0), (10, 1), (19, 1), (20, 0) ]) . 2.4 Rule truth v alue A to o l which o nly allows the us er to define truth v alues throug h functions and facts leaks o n allowing him to com bine those truth v a lues for representing more complex situations. A rule is the p erfect to ol to co m bine the truth v alues of facts, functions, and other rules. Rfuzzy framework 67 Rules allow the user to co m bine truth v alues in the correct wa y (b y means of a ggreg ation o p er ators, like maximum or pr o duct ). Besides this com bination truth v alue for the bo dy of the r ule, the r ule can be given an o verall cr e dibilit y truth v alue. Credibility is used to express ho w m uch we trust the rule w e write. Suppo se a small weather example in which we hav e the rule it wil l r ain if it is cloudy and it is hot . As it mig h t rain but it mig h t not, we can a ssign the rule a cr edibilit y of 0.7. As exp ected, the tr uth v alue obtained from the b o dy is com bined with the credibility v a lue of the rule to obtain a final truth v alue. Rfuzzy offer s the us er a co ncrete syntax to define combinations of truth v alues by means of a ggreg a tion opera tions, and assign to that r ule s a credibility . This syntax extension is defined in (4). Indeed, the user ca n choo s e tw o aggr egation op erators 3 : op2 for combining the truth v alues of the subgoals of the rule’s b o dy and op1 for combining the pr evious result with the credibility of the rule. pre d ( arg 1 [ , ar g 2 ] ∗ ) [ cred ( op 1 , v al ue 1 ) ] 0 , 1 : ∼ op 2 pr ed 1( ar g 1 [ , ar g 2 ] ∗ ) [ , pred 2( ar g 1 [ , ar g 2 ] ∗ )] . (4) The following examples show its usag e. The seco nd o ne uses the op era tor pr o d for a ggrega ting truth v alue s of the subgoals of the b o dy a nd the op e rator min to aggr egate the result with the credibility of the r ule, 0.8. As can b e deduced from syntax a nd examples, cr e d and : ∼ ar e reserved words. tempti ng_re staurant(R) :~ prod low_dis tance( R), che ap(R), tradit ional (R). good_p layer (J) c red (min,0. 8) :~ prod swif t(J), tall(J), experi ence( J). 2.5 General and Conditi oned Default T ruth V alues Unfortunately , informatio n provided by the user is not co mplete in gener al. So there are many cases in which we hav e no informa tion a bo ut the truth v a lue of a n individual o r a set of them. Nev ertheless, it is interesting not to stop a complex query ev aluation just bec ause we hav e no informa tio n ab out one or more subgoa ls if w e can use a reasonable approximation. The solution to this problem is using default truth v alues for these cases. The RF uzzy extension to define a default truth v alue for a pr edicate when a pplied to individuals for which the us er has not defined an explicit truth v alue is na med gener al default tru th value . Conditione d default truth value is used when the default truth v alue only applies to a s ubs e t o f the function’s domain. This s ubset is defined b y a mem- ber ship predic a te which is true only when an individua l belo ngs to the subset. 3 Aggregation operators a vai lable are: min for minimum, max for maxim um, pr o d for the pro duct , luka for the Luk asiewicz op erator, dpr o d for the inv erse pro du ct, d l uka for the inv erse Lu k asiewicz operator and c omplement . 68 Victor Pablos Ceruelo, Susana Munoz-Hernandez, and Hannes Strass The member ship predicate ( memb ership pr e dic ate/ar ) and the predicate to which it is applied ( pr e d/ar ) nee d to b e hav e the sa me ar it y ( ar ). If not, an error messag e will b e shown at compilation time. The syntax for defining a gener al default truth v alue is shown in (5), and the syntax for assigning a co nditio ned default tr uth v alue is shown in (6). pr e d/ar is in bo th cases the predicate to which we a re defining default v alues. As exp ected, when defining the three cases (explicit, conditioned a nd default truth v a lue) only one will b e given back when doing a query . The precedence whe n looking for the truth v alue go es from the most concr ete to the least one. :- default( pred / ar, truth v al ue ) . (5) :- de fault( pr ed / ar, truth v al ue ) = > member ship pr edica te / ar . (6) The example below sho ws how to assign a default truth v alue of 0.5 to all cars that do not hav e an explicit truth v alue nor have a default conditio ned truth v alue. Besides, it shows how to a s sign a c o nditioned default truth v alue to all cars b elonging to a small subset and not having an explicit truth v alue. This subset is determined by the mem b ership predicate ex p ensive typ e/1 , and default truth v alue for its elements is 0.9 . So lamb or ghini u rr ac o is an exp ensive c ar with truth v a lue 0.9 but vw c addy is a n exp ensive c ar with truth v alue 0.5. Both v alues are default approximations b ecause we ha ve no dir ect declaration (as for alfa r ome o gt that is an exp ensive c ar with a truth v a lue 0 .6 a s we show ab ove). :- set_p rop e xpensi ve_car /1 => car /1. :- defau lt(exp ensive_car/1, 0.9 ) => expensiv e_type /1. :- defau lt(exp ensive_car/1, 0.5 ). expens ive_t ype(lamborghini_urraco). expens ive_t ype(aston_martin_bulldog). 2.6 Doing queri es wi th truth v alues Indeed the prog ram has to be r un. When compiling, Rfuzzy adds a new arg ument to the arguments list of each fuzzy predicate. This argument ser ves for que r ying ab out the predicate truth v alue . It can b e seen as syntactic sug ar, as truth v alue is not part of the predicate ar gument s, but metadata information. T ruth v alue arg umen t is added to the predicates in a uniform way: it is alwa y s a new argument at the end of the ar guments list of the predica te. In the pr evious example we wro te exp ensive c ar/1 , so to query the system we have to give the predicate tw o arguments instea d of o nly one where the second one will repre sent the query’s truth v alue. This can b e seen in the firs t example of subsection 2.7. 2.7 Constructiv e Answers A fuzzy too l should be able to provide co nstructive answers for queries. The regular (easy) questions are asking for the truth v alue of an elemen t. F o r exa mple, how exp ensive is an alfa r ome o gt ? Rfuzzy framework 69 ?- expen sive_c ar(alfa_romeo_gt,V). V = 0.6 ? ; no But the re a lly int eresting quer ie s are the ones that a sk for v alues that satisfy constraints ov er the truth v alue. F or example, whic h cars are v er y exp ensive?. RF uzzy provides this constructive functionality . ?- expen sive_c ar(X,V), V > 0.8. V = 0.9, X = aston _marti n_bulldog ? ; V = 0.9, X = lambo rghini _urraco ? ; no The RF uzzy pack age implements a meta-translation o f the RF uzzy syntax to ISO Prolog , v ia CLP(R), this is the reaso n for its constructivity . 3 Applications Rfuzzy is ma inly suitable for expert systems applications. As mentioned b efore, its main adv antages in compariso n to F uzzy Prolog are its simpler sy ntax, the use of real n umbers instead o f interv als b etw ee n them and the implicit handling of truth v alues. Bes ides, it pre s ent s facts’ truth v alues (explicit, default or c o n- ditioned default truth v alue), functions’ truth v alues and rules (with or without credibility) whic h simplifies the user development pro c ess a lot. Although a medical exp ert system development w ere the b est example o f using Rfuzzy , due to la ck of space we pre fer to show here one in which we decide which is the b est r estaurant for g o ing out. :- modul e(rest aurant,_,[rfuzzy, c lpq]). :- prop resta urant/ 1. :- set_p rop t emptin g_rest aurant/1 => re staura nt/1. :- defau lt(tem pting_restaurant/1, 0 .1). tempti ng_re staurant(R) :~ prod low_dis tance( R), che ap(R), tradit ional (R). restau rant( kenzo). restau rant( burger_king). restau rant( pizza_jardin). restau rant( subway). restau rant( derroscas). restau rant( il_tempietto). restau rant( kono_pizza). restau rant( paellador). restau rant( tapasbar). 70 Victor Pablos Ceruelo, Susana Munoz-Hernandez, and Hannes Strass crisp_ dista nce(kenzo, 5 0). crisp_ dista nce(burguer_king, 10 0). crisp_ dista nce(pizza_jardin, 70 ). crisp_ dista nce(subway, 85). crisp_ dista nce(derroscas, 12 0). crisp_ dista nce(il_tempietto, 15 0). crisp_ dista nce(kono_pizza, 6 5). crisp_ dista nce(paellador, 55 ). crisp_ dista nce(tapasbar, 4 0). low_di stanc e(R, TV) : - crisp_ distan ce(R, D), low_di stanc e_aux(D, TV) . :- set_p rop l ow_dis tance_ aux/1 => dis tance/ 1. :- defau lt(low _distance_aux/1, 0) . low_di stanc e_aux :# ( [ (0, 1), (50, 0.9), (100, 0.8), (200, 0.6), (300, 0.5), (500, 0.4), (1000, 0.1), (2000, 0) ]). very_l ow_di stance(X) :- cr isp_di stance (X, D), D < 100. :- set_p rop c heap/1 => restau rant/ 1. :- defau lt(che ap/1, 0 .2) => very_low_ dista nce/1. :- defau lt(che ap/1, 0 .5). cheap( kenzo ) v alue 0.2. cheap( el_ri ncon) va lue 1. cheap( el_re ventaero) va lue 1. :- set_p rop t raditi onal/1 => re staura nt/1. :- defau lt(tra ditional/1, 0. 8) => very_lo w_dist ance/1. :- defau lt(tra ditional/1, 1) . tradit ional (kenzo) va lue 0.5. tradit ional (el_reventaero) v alue 0.87. distan ce(0) . distan ce(X) : - distan ce(Y), num ber(Y) , X .=. Y + 1, ( X < 5000 ; ( X >= 5000 , ! , fail) ). In the example we ca n see tha t we know the distance to all the re s tau- rants in a crisp w ay . This crisp v alue is translated by mea ns of low distanc e and low distanc e aux into a fuzzy one which is used into tempting r estaur ant to de- termine its truth v alue. This allows us to as k which is the truth v alue of each Rfuzzy framework 71 tempting r estaurant, whic h r e s taurant is a tempting r estaurant with a truth v alue of, for example, 0.7 or list all tempting resta urants with their truth v alues. The Rfuzzy mo dule with installation instructions and exa mples can b e down- loaded from http: //babe l.ls.fi.upm.es/software/rfuzzy/ . 4 Implemen tation details RF uzzy is a log ic progr amming lang uage that is a ble to mo del all the extensions that are describ ed in section 2. It is implemen ted a s a Ciao Prolog [30] pack ag e bec ause Ciao Pr olog offers the p os s ibilit y of dealing with a hig her order co m- pilation through the implement ation of Cia o pack a ges. Those pack ag es serve as input for the “Ciao System Pr epr o c essor” (Ciao PP) [4], a tool a ble to p erform source-to - source tra nsformations. The reason b eyond the implemen tation of Rfuzz y as a Ciao Prolo g pac k a g e is that the resultant code has to deal with tw o kinds of queries: – q ueries in which the use r a sks for the truth v alue of an individual, and – q ueries in which the user asks for an individual with a co ncrete truth v alue. As can be see n in the following ex ample, this is not an easy task. ?- A is 1, B is 2, C is A + B. A = 1, B = 2, C = 3 ? . yes ?- C is 3, C is A + B. {ERROR : illeg al ar ithmet ic ex pressi on} {ERROR : illeg al ar ithmet ic ex pressi on} no ?- F ormula C is A + B only works if v ariables A and B ar e bound. Almost all predicates that a r e pro blematic with non-b ound v ariables ha ve inside co m- parisons and/or assig nments. This aims us to tra nslate Rfuzzy programs into CLP( R ) pro grams. CLP ( R ) is a Ciao Pr olog Pack age which translates real nu mber op erations in to constraints a pplied to the v ariables inv olved in those op erations. T aking a dv an tage of Rfuzzy and CLP( R ) tra nsformations, o ur to ol compiles Rfuzzy progra ms into ISO Pro log pro grams, so the in terpreter is a ble to work with them as it normally do es. As a result, the glo bal compilation pro cess has tw o prepro cesso r steps : (1) the Rfuzzy prog r am is tr anslated in to CLP( R ) constraints by means of the Rfuzzy pack ag e and (2) those constraints are transla ted in to ISO Prolog by us ing the CLP( R ) pack age . Fig. 2 shows the whole pro cess . In the following example the predicate t empting r estaur ant is translated fro m Rfuzzy s ynt ax into ISO Pr o log syntax. In the first step, the Rfuzzy pack age inserts truth v alue v ariables, the inje ct metapr edicate call (one of its a rguments is the a g grega tion o per ator to be used, pr o d ) and inserts Rfuzzy compariso ns to 72 Victor Pablos Ceruelo, Susana Munoz-Hernandez, and Hannes Strass RFuzzy package preprocessing package preprocessing RFuzzy program program CLP(R) program ISO Prolog CLP(R) Fig. 2. R fuzzy architecture. take care at execution time that th e rule’s truth v alue is always b etw ee n zero and one. In the seco nd step, CLP ( R ) converts comparis ons in to cons tr aints (via predicate calls). % Rfuzzy progra m tempti ng_re staurant(R) :~ prod low_dis tance( R), che ap(R), tradit ional (R). % CLP(R) progra m rfuzzy _rule _tempting_restaurant(R,_1) :- low_di stanc e(R,_2), cheap( R,_3) , tradit ional (R,_4), inject ([_2, _3,_4],prod,_1), _1 .>=. 0, _1 .=<. 1. % ISO Prol og program rfuzzy _rule _tempting_restaurant(R,_1) :- low_di stanc e(R,_2), cheap( R,_3) , tradit ional (R,_4), inject ([_2, _3,_4],prod,_1), solve_ gener ic_1(le,0,_1,-1), solve_ gener ic_1(le,-1,_1,1) . Int ernally , Rfuzzy pack age unifies a nd trans la tes a ll the infor mation given by the user to eac h predicate (Types, default v alues with a nd without condition, truth v alues defined in facts and rules w ith a nd without credibility) into a single predicate b o dy . A simplified v ers io n of the sk eleto n used for that predicate is shown b elow. Rfuzzy p ackage simplifie d skeleton Main :- Types , ( Normal ; Default ) Normal :- ( Fact ; (\+(Fa ct_Au x), F unctio n) ; (\+(Fa ct_Au x), \ +(Func tion_A ux), Rule ) ) Rfuzzy framework 73 Defaul t :- \+(Fact _Aux), \ +(Fun ction_ Aux), \+(R ule_Au x), ( Cl_Wit h_Cond ; (\+(Cl _With _Cond_Aux), Cl_ With_N o_Cond ) ) The skeleton has three differen t par ts: the one which takes ca re o f a llowing only que r ies or a nswers with the exp ected individuals, the one which lo ok s for a concrete truth v alue (it can b e defined b y means of a fact, a function or a rule) and the one which looks for a default truth v alue (conditioned or not). Predicates ending in aux do not take c are on the truth v alue ar g ument . The firs t part is obtained from the type definitions (see 2.1 ), translating a ll t yp es in to a predicate whic h is called at firs t (Types) so we assur e w e only work with the exp ected individuals. The second pa rt lo oks for a concrete v alue whose arg umen ts hav e to unify with the parameter s the user has given. Precedence when loo king for it is: 1. A fact (see subsection 2.2 ) 2. A function (see subsection 2.3 ) 3. A rule (see subsection 2.4) The third part is only called when the seco nd one (searching for a truth v alue) fails, and lo oks for a conditioned or default tr uth v a lue. 5 Conclusions and Current W ork Rfuzzy offers to the users a new framework to r epresent fuzzy pr oblems o ver real num b ers. F uzzy Pr olo g [34, 33, 9] is an existing fra mework for dealing with F uzzy problems representation. Main Rfuzzy adv ant ages over F uzzy Pr olo g are a simpler syntax and the elimination of answers with constrain ts, and R fuzzy is one of the first tools modelling m ulti-a djoin t logic, as explained in subsection 1.3. Rfuzzy s y n tax is simpler that F uzzy Pr olo g syntax. Its fuzzy v alues are sim- ple rea l num ber s instead of interv als b etw een r eal num b ers, and it hides the management of tr uth v alue v aria bles. As norma l fuzzy problems do not use in- terv als to repr e sent fuzziness and do not need to co de an unco mmon behaviour of fuzzy v ariables, this syn tax reduction is an adv ant age. Progra ms written in Rfuzzy syntax are more legible a nd more easy to unders tand than F u zzy Pr olo g progra ms. F uzzy Pr olo g answers to user queries are difficult to understand due to the existence o f constra int s. As normal replies to final user s are g round terms, the progra mmer has to co de by hand how to reach them. T o eliminate those co n- straints and answ er queries with ground terms the pro g rammer tries to substitute v ariables with ground terms un til one makes true all of them. Rfuzz y offer s a powerful to ol to deal with this task: T yp e definition . T yp e definition (see subse c - tion 2.1 ) allows the user to define which terms are s uitable for being s ubstituted 74 Victor Pablos Ceruelo, Susana Munoz-Hernandez, and Hannes Strass int o a v ariable, so s he do es no t have to co de this behaviour a gain. Besides , the elimination o f answers with constr aints provides mor e hum an reada ble answers and mor e easy to test progra ms (because a nswers w e test do not have co ns traints, just ground terms). There is a lso an extension to in tro duce default truth v a lues. As world in- formation is sometimes incomplete, Rfuzzy o ffers to the user the p ossibility to define default truth v alues and default conditioned truth v alues (see subsectio n 2.5). This allows us to make inference with default truth v a lues when we do not know a n ything ab out the truth of some fact. Extensions added to Pr olo g by Rfuzzy are: T yp es, default truth v alues (con- ditioned o r not), assignment of truth v alues to individuals b y means of facts, functions or rules, and assig nmen t of credibilit y to the r ules. Besides, the p ossibility to provide constructive answ er s t o the queries increase its usage, as can be seen in subsectio n 2.7. There are co unt less applications and res earch lines which can benefit fro m the adv antages of using the fuzzy representations o ffered by Rfuzzy . Some e xamples are: Sea rch Engines, Kno wledge Extra c tio n (from databases, ontologies, etc.), Semantic W eb, Business Rules, a nd Co ding Rules (where the viola tion of one rule can b e given a truth v a lue). Current work o n Rfuzzy tries to apply construc tive nega tion to the eng ine. RF uzzy needs to define types in a co nstructive w ay (b y means of predicates that are able to generate all their individuals by backtracking) so w e cannot use constraints. F utur e resear ch will be do ne in this line for widening the definition of types. References 1. J.M. Abietar, P .J. Morcillo, and G. Moreno. Designing a softw are to ol for fuzzy logic programming. In T.E. Simos and G. Maroulis, editors, Pr o c. of the Int. Conf. of Computat ional Metho ds in Scienc es and Engine ering. ICCMSE’07 , volume 2 of Computation in Mor dern Sci enc e and Engine ering , pages 1117–1 120. American Institute of Ph ysics, 2007. Distributed by Springer. 2. J. F. Baldwin, T. P . Martin, and B. W. Pils w orth. F ril: F uzzy and Evidential R e asoning in Art ificial Intel ligenc e . John Wiley & Sons, 199 5. 3. S. Bistarelli , U. Mon t anari, and F. Rossi. Semiring-based constrain t Logic Pro- gramming: syntax and seman t ics. In A CM TOPLAS , volume 2 3, pages 1–29, 2001. 4. F. Bueno, P . L´ opez- Garc ´ ıa, G. Puebla, and M. H ermenegildo. The Ciao Prolog Preprocessor. T ec hnical Report CLIP8/95.0.7.2 0, T ec h nical Universit y of Madrid (UPM), F acultad de Inform´ atica, 28660 Boadilla d el Monte, Madrid, Spain, 1999. 5. T.H. Cao. An notated fuzzy logic programs. F uzzy Sets and Systems , 113(2):277– 298, 2000. 6. D. Dub ois, J. Lang, and H. Prade. T ow ards possibilistic logic programming. In Pr o c. of ICLP-91 , pages 581–595. MIT Press, 1991. 7. M. Fitting. Bilattices and the semantics of logic programming. Journal of Lo gic Pr o gr ammig , 11:91–11 6, 1991. 8. N. F uhr. Probabilistic datalog: Implementing logical information retriev al for ad- v anced applica tions. Journal of the A meric an So ciety for Information Scienc e , 51(2):95–1 10, 2000. Rfuzzy framework 75 9. S. Guadarrama, S . Munoz-Hernandez, and C. V auc heret. F uzzy Prolog: A new approac h u sing soft constrain ts propagation. F uzzy Sets and Syste ms, FSS , 144(1):127 –150, 2004. I SSN 0165-0114. 10. M. Ishizuk a and N. Kanai. Pro log-ELF incorp orating fuzzy Logic. In IJCAI , pages 701–703 , 1985. 11. M. Kifer and Ai Li. On the seman tics o f rule-based expert systems wi th uncertaint y . In Pr o c. of ICDT-88 , n u m b er 326 in LNCS, pages 102–117, 1988. 12. M. Kifer and V.S. S ubrahmanian. Theory of generalized ann otated logic program- ming and its app lications. Journal of Lo gic Pr o gr amm ing , 12:3 35–367, 1992. 13. F. Klaw onn and R. Kruse. A Luka siewicz logic based Prolog. Mathwar e & Soft Computing , 1(1):5–29, 1994. 14. E.P . Klement, R. Mesiar, and E. P ap. T riangular norms. Klu w er Academic Pu b- lishers. 15. L. Lakshmanan. An epistemic foundation for logic programming with uncertaint y . LNCS , 880:89–100, 1994. 16. L. Lakshm anan and N . Shiri. Probabilis tic dedu ctive d atabases. Int. Lo gic Pr o- gr amming Symp osium , pages 254–268, 1994. 17. L. Lakshmanan and N . S hiri. A parametric approach to deduct iv e databases with uncertaint y . IEEE T r ansactions on Know l e dge and Data Engi ne ering , 13(4):554 – 570, 2001. 18. R. C. T. Lee. F uzzy Logic and the resolution principle. Journal of the Asso ciation for Computing Machinery , 19(1):119–129, 1972. 19. D. Li and D. Liu. A F uzzy Pr olo g Datab ase Syst em . John Wiley & Sons, New Y ork, 1990 . 20. T. Luk asiewicz. Fixp oint c haracterizations for many-v alued disjunctiv e logic pro- grams with probabilistic semantics . In Pr o c. of LPNMR-01 , volume 2173, p ages 336–350 , 2001. 21. J. Medin a, M. Ojeda-Aciego, and P . V otjas. A completeness theorem for multi- adjoin t Logic Progra mming. In International F uzzy Systems Confer enc e , pages 1031–10 34. IEEE, 2001 . 22. J. Medina, M . Ojeda-Aciego , and P . V otjas. Multi-adjoint Lo gic P rogramming wi th conti nuous semantics. In LPNMR , v olume 217 3 of LNCS , pages 351–364, Boston, MA (US A), 2001. Springer-V erlag. 23. J. Medina, M. Ojeda-Aciego , and P . V otjas. A p rocedural s emantics for m ulti- adjoin t Logic Programming. In EPIA , volume 2258 of LNCS , pages 290–297, Boston, MA (USA), 20 01. Springer-V erlag. 24. S. Mun oz-Hernandez, C. V aucheret, and S. Guadarrama. Combining crisp and fuzzy Logic in a p rolog compiler. In J. J. Moreno-Nav arro and J. Mari˜ no, editors, Joint Conf. on De clar ative Pr o gr am m ing: APPI A-GULP-PR ODE 2002 , pages 23– 38, Madrid, Spain, Sep tem b er 2002. 25. R. Ng and V.S. Su brahmanian. Stable model semantics for probabilistic d eductive databases. In Pr o c. of ISMIS-91 , n umb er 542 in LNCS, pages 163–171, 1991. 26. R. Ng and V.S . Sub rahmanian. Probabilistic logic programming. Inf ormation and Computation , 1 01(2):150– 201, 1993. 27. A. Pradera, E. T rillas, and T. C alv o. A general class of triangular norm- based aggregatio n op erators: q uasi-linear t-s op erators. International Journal of Appr ox- imate R e asoning , 30(1):57– 72, 2002. 28. Z. Sh en, L. D ing, and M. Muka idono. F u zzy resolution prin ciple. In Pr o c. of 18th International Symp osium on Multiple-value d Lo gic , volume 5, 198 9. 76 Victor Pablos Ceruelo, Susana Munoz-Hernandez, and Hannes Strass 29. V.S. Subrahmanian. On the seman tics of quantitative logic programs. In Pr o c. of 4th IEEE Symp. on Lo gic Pr o gr amming , pages 17 3–182. Computer So ciety Press , 1987. 30. The CLIP Lab. The Ciao Prolog Developmen t Sy stem W WW Site, http://www .clip.dia .fi.upm.es /Software/Ciao/ . 31. E. T rillas, S. Cubillo, and J. L. Castro . Conjunction and disjunction on ([0 , 1] , < =). F uzzy Sets and Systems , 72:15 5–165, 1995. 32. M.H. v an Emden. Quantita tive duduction and its fixp oint theory . Journal of Lo gi c Pr o gr amming , 4(1):37–53, 1986. 33. C. V au c heret, S . Guadarrama, and S. Munoz-Hernandez. F uzzy prolog: A simple general implemen tation using clp(r). In M. Baaz and A. V oronko v , editors, Lo gic for Pr o gr amm i ng, Art ificial Intel l igenc e, and R e asoning, LP AR 2002 , number 2 514 in LNA I, pages 450–46 3, Tbilisi, Georgia, Octob er 20 02. Springer-V erlag. 34. C. V au c heret, S . Guadarrama, and S. Munoz-Hernandez. F uzzy prolog: A simple general implementatio n using clp(r). In P .J. Stuck ey , editor, Int. Conf. in Lo gic Pr o gr amming, ICLP 2002 , n umber 2401 in LNCS, page 469, Cop enhagen, Den- mark, July /August 2002. Springer-V erlag. 35. P . V o jtas. F uzzy logic p rogramming. F uzzy Sets and Systems , 124(1): 361–370 , 2001. 36. G. W agner. A logical reconstruction of fuzzy inference in databases and log ic programs. In Pr o c. of IFSA-97 , Prag ue, 1997. 37. G. W agner. Negation in fuzzy and p ossibilistic logic programs. In Lo gic pr o gr am- ming and Soft Computing . Research St udies Press, 1998 . 38. Ehud Y. and Shapiro. Logic programs with uncertainties: A tool for implementing rule-based systems. In IJCAI , pages 529–532, 1983 .
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment