Rfuzzy: An expressive simple fuzzy compiler Víctor Pablos Ceruelo, Susana Muñoz-Hernandez and Hannes Straß Babel Group, Facultad de Informática Universidad Politécnica de Madrid (T.U. of Madrid), Spain http://babel.ls.fi.upm.es IWANN 2009, Salamanca, Spain VPC, SMH, HS (Babel Group, UPM, Spain) Rfuzzy Framework IWANN 09, Salamanca 1 / 13
Motivation (I): What can we model by using Rfuzzy? We are able to model Credibility and Fuzziness. Example of rule: IF cloudy THEN i t m a y r a i n Credibility: Consider that it is cloudy. How much do we trust the rule that says that it may rain? Fuzziness: How much cloudy is it? Can we see the sun? We have different degrees. VPC, SMH, HS (Babel Group, UPM, Spain) Rfuzzy Framework IWANN 09, Salamanca 2 / 13
Motivation (II): Rfuzzy vs Fuzzy Prolog How Rfuzzy reduces Fuzzy Prolog complexity Uses real numbers instead of intervals between real numbers to represent truth values. Answers queries with direct values instead of constraints. Programmer does not have to code variables to manage truth values. How Rfuzzy increases Fuzzy Prolog expressiveness Defines a types extension to limit the set of valid individuals. Allows to define default truth values for subsets of individuals. We do not compare Rfuzzy with other approaches that substitute the SLD-resolution with a fuzzy variant that is able to handle partial truth. The main advantage of our proposal over them is that we can reuse thousands of existing lines of prolog code, and mix fuzzy with crisp resolution. VPC, SMH, HS (Babel Group, UPM, Spain) Rfuzzy Framework IWANN 09, Salamanca 3 / 13
Rfuzzy syntax example I % t y p e d e f o f 1 s t argument o f p r e d i c a t e young : s e t p r o p young/1 person /1. person ( john ). person ( mike ). person ( marcus ). person ( hannes ). person ( susana ). person ( v i c t o r ). % d e f a u l t and c o n c r e t e t r u t h v a l u e s d e c l : d e f a u l t ( young /1, 0). % d e f a u l t : Nobody % i s young young ( john ) value 0. 9. % He i s 11 y e a r s old. young ( mike ) value 0. 8. % He i s 15 y e a r s old. VPC, SMH, HS (Babel Group, UPM, Spain) Rfuzzy Framework IWANN 09, Salamanca 4 / 13
Rfuzzy syntax example II teenager 1 0 9 10 19 20 age : d e f a u l t ( teenager /1, 0). % f u n c t i o n t r u t h v a l u e d e c l a r a t i o n teenager :# ([ (9, 0), (10, 1), (19, 1), (20, 0) ]). VPC, SMH, HS (Babel Group, UPM, Spain) Rfuzzy Framework IWANN 09, Salamanca 5 / 13
Rfuzzy syntax example III : d e f a u l t ( teenager /1, 0). teenager :# ([ (9, 0), (10, 1), (19, 1), (20, 0) ]). : d e f a u l t ( c h i l d /1, 0). c h i l d :# ([ (0, 1), (10, 1), (12, 0) ]). : d e f a u l t ( young /1, 0). young (P) cred (min, 0.3) : max c h i l d (P), teenager (P). % Every one i s young with a t v o f 0.3 Available aggregation operators: minimum, maximum, (inverse) product, (inverse) Lukasiewicz operator. VPC, SMH, HS (Babel Group, UPM, Spain) Rfuzzy Framework IWANN 09, Salamanca 6 / 13
Rfuzzy syntax example IV % Susana s a y s t h a t she i s s t i l l young... young ( susana ) value 0. 7. % But the f a c t i s t h a t a l l the authors are s t i l l % young. ( the p r e v i o u s d e c l a r a t i o n i s removed ) % C o n d i t i o n a l t r u t h v a l u e d e c l a r a t i o n : d e f a u l t ( young /1, 0.7) paper author /1. paper author ( susana ). paper author ( hannes ). paper author ( v i c t o r ). % P r e v i o u s d e f and d e c l o f young : d e f a u l t ( young /1, 0). young (P) cred (min, 0.3) : max c h i l d (P), teenager (P). VPC, SMH, HS (Babel Group, UPM, Spain) Rfuzzy Framework IWANN 09, Salamanca 7 / 13
Queries, Answers and Constructivity On compilation we add a new argument ( V is the truth value arg) % non c o n s t r u c t i v e % c o n s t r u c t i v e? young ( hannes, V).? young (X, V), V 0. 8. V = 0.7? ; V = 0.9, X = john? ; no V = 0.8, X = mike? ; no We say that it is constructive because it does not return a constraint X susana, hannes, victor, marcus. Instead of that it returns the valid values in a Prolog way (i.e. one by one). When looking for the truth value of an individual Rfuzzy returns only one truth value, and it is always the most concrete truth value declared in the program. VPC, SMH, HS (Babel Group, UPM, Spain) Rfuzzy Framework IWANN 09, Salamanca 8 / 13
Rfuzzy Implementation The global compilation process has two preprocessor steps: 1 the Rfuzzy program is translated into CLP(R) constraints by means of the Rfuzzy package and 2 those constraints are translated into ISO Prolog by using the CLP(R) package. RFuzzy program RFuzzy package preprocessing CLP(R) program CLP(R) package preprocessing ISO Prolog program Y We do not create a new SLD-resolution. Instead of that we use prolog SLD resolution. This allows us to mix prolog code with fuzzy prolog code, and reuse a lot of prolog existing code. VPC, SMH, HS (Babel Group, UPM, Spain) Rfuzzy Framework IWANN 09, Salamanca 9 / 13
Example: MYCIN can be modelled by using Rfuzzy IF The s t a i n of the organism i s Gram negative, AND The morphology o f the organism i s rod, AND The a e r o b i c i t y of the organism i s a e r o b i c THEN There i s s t r o n g l y s u g g e s t i v e evidence ( 0. 8 ) t h a t the c l a s s of the organism i s E n t e r o b a c t e r i a c e a e Rules have credibility and facts have a truth value. CF( s t a i n = gram negative ) = 0. 4. CF( morphology = rod ) = 0. 6. CF( a e r o b i c i t y = a e r o b i c ) = 0.4. VPC, SMH, HS (Babel Group, UPM, Spain) Rfuzzy Framework IWANN 09, Salamanca 10 / 13
Conclusions Rfuzzy offers to the users a new framework to represent fuzzy problems over real numbers. Main Rfuzzy advantages over Fuzzy Prolog are a simpler syntax and the elimination of answers with constraints. Its fuzzy values are simple real numbers instead of intervals between real numbers, it hides the management of truth value variables and as it does not answer queries with constraints, answers are always ground terms. This is a more human-readable way of answering questions and it can be used in web forms (constraints can not be used there). Applications: Search Engines, Knowledge Extraction (from databases, ontologies, etc.), Semantic Web, Business Rules, Coding Rules (where the violation of one rule can be given a truth value), etc. VPC, SMH, HS (Babel Group, UPM, Spain) Rfuzzy Framework IWANN 09, Salamanca 11 / 13
Current work? young (X, V). Apply constructive negation to the engine, but first we have to find the correct semantics. What do we want to obtain when we make a query like this one? Have fuzzy relations in the Semantic Web, allowing the user to represent not only who is young or not but the fact that the authors of this paper belong to the young set with a truth value of 0.7.... VPC, SMH, HS (Babel Group, UPM, Spain) Rfuzzy Framework IWANN 09, Salamanca 12 / 13
Questions VPC, SMH, HS (Babel Group, UPM, Spain) Rfuzzy Framework IWANN 09, Salamanca 13 / 13