At the forefront of Artificial Intelligence
  Home Articles Reviews Interviews JDK Glossary Features Discussion Search

An Introduction to Fuzzy Logic

This is a very basic introduction to fuzzy logic. Chances are if you've read any documentation on fuzzy logic, there will be nothing new in this essay. What might be of interest, though, is a small canonical C++ class I wrote to handle fuzzy logic operators. See the end of the essay for more information.


How many times in real life do question allow answers as simple as 'true' or 'false'? Very rarely indeed! The idea of fuzzy logic dates all the way back to Plato who proposed that there was a third region between true and false - the uncertain. It took many centuries before this system was ever formalized. In the 1900s a man called Lukasiewicz proposed a tri-valued logic system. Later, Lukasiewicz experimented with four and five-valued logic systems, and finally proposed that an infinite-valued logic was no less plausible than a finite one. Finally, in 1965, Lofti Zadeh published his work on what he called fuzzy logic - a part of set theory that operated over the range [0.0 - 1.0].

Fuzzy Set Theory

The major difference between fuzzy logic and boolean (standard) logic is that possible values range from 0.0 to 1.0 (inclusive), not just 0 and 1. For example, you could say that the fuzzy truth value (FTV) of the statement "Graham is tall" is 0.75 if Graham is 2 metres tall. To write this more formally:

m(TALL(Graham)) = 0.75
m is a membership function and is the function that would map 2 metres to an FTV of 0.75. Membership functions can be incredibly simple, or incredibly complex. For example, a relatively simple membership function could be:

A formal definition of a membership function can be stated as a function that maps each point of fuzzy set A to the real interval [0.0, 1.0] such that as m(A(x)) approaches the grade of membership for x in A increases.

Logic Operators
In boolean logic there are the union (or), intersection (and) and not operators. These operators exist in fuzzy logic too, but are defined differently:

  • A OR B = MAX(m(A(x)), m(B(x)))
  • A AND B = MIN(m(A(x)), m(B(x)))
  • A' (NOT A) = 1 - mA(x)
The intersection and union operators are the obvious departure from both boolean logic and standard probabilty functions. To see why they are defined like this, let us look at an example. Take the statements "Graham is very tall" and "Graham is very clever" - if you were to combine these using probability, you would get:
m(TALL(Graham)) * m(CLEVER(Graham)) = 0.90 * 0.90 = 0.81
Note: This is obviously making the assumption that "very" equates to 0.9 in both the membership functions TALL and CLEVER. Let us also make the assumption that the range [0.8 and 0.9) equates to "quite." The resulting statement reads "Graham is quite smart and clever" - this is obviously not correct. Using fuzzy logic:
MIN(m(TALL(Graham)) * m(CLEVER(Graham))) = MIN(0.90,  0.90) = 0.90
Which yields the correct statement "Graham is very smart and clever." The result of this gets more noticeable as more variables are taken into consideration, for example 6 variables with values of 0.8 would yield 0.262 using probability - far from the fuzzy value of 0.8!

Hedges
Hedges are operators that are independently created to modify the fuzzy values. Like a lot of fuzzy logic, they can be equated to English words. For example, the hedge "VERY" could be equated to m(A(x))2, or "SOMEWHAT" to m(A(x))0.5.

Note that equating words to fuzzy values and performing operations upon them (eg, LOWER THAN) requires complicated algorithmic manipulation. It has been done though, most notably by F.Wenstop who equated words to 7-valued fuzzy vectors.

Applications

Fuzzy logic can be most readily applied to expert systems whose information is inherently fuzzy. Doctors, lawyers, engineers can diagnose problems a lot quicker if the expert system they use to diagnose the problem lists a few fuzzy solutions that they can use to augment their own findings.

Another area the fuzzy logic is used is hand-writing recognition - especially here in Japan, complicated Kanji strokes can be detected as they're written using fuzzy methods. Applications of fuzzy logic has also been seen in areas such as cement kiln control and financial prediction/control.

C++ Code

Although this is not a case study because I haven't looked at a specific example of fuzzy logic, I DID write a small class to encompass what has been discussed above. The class is built to act like a fuzzy value, all C++ operators have been overloaded so that you can use it as you would a basic type. Note that the class will allow its value to go below/above the boundaries (0,1). Here is a small example program:
#include <iostream.h>
#include <math.h>
#include "fuzzy.h"

void main() {
   fuzzy fz1 = 0.5,                   // 0.5
         fz2 = (fz1 | 0.4f) & 0.45f,  // 0.45
         fz3 = !fz2 | fz2,            // 0.55
         fz4 = !(fz1 - fz2);          // 0.95
   bool  bl5 = fz3.contained(fz2),    // false
         bl6 = fz2.contained(fz3);    // true

   cout << "Class 'fuzzy' logical operators:" << endl;
   cout << "fz1 = " << fz1 << endl
        << "fz2 = " << fz2 << endl
        << "fz3 = " << fz3 << endl
        << "fz4 = " << fz4 << endl;
   cout << endl;
   cout << "bl5 = " << ((bl5) ? "true" : "false") << endl
        << "bl6 = " << ((bl6) ? "true" : "false") << endl;
}
Judging from the comments I've put in, I think you can guess the output of the program! Nevertheless, you can see how easy it is to use the class. Just to reassure you, let us look at fz2 and fz3. fz2 is the result of ((0.5 OR 0.4) AND 0.45). Remember OR takes the maximum, so that equates to 0.5, and AND takes the minimum - therefore fz2 equals 0.45. On to fz3, that is (NOT(fz2) OR fz2) - the NOT of fz2 is 1 - 0.45 = 0.55, which is bigger than 0.45.

The "contained" function returns true iff A <= B. The class also has float type conversion routine, so you can use fuzzy and float synonymously when pass parameters to functions (like cout::operator<<). You can download the code here, alternately you can look at the documentation for the class and download it there.

Submitted: 31/12/1999

Article content copyright © James Matthews, 1999.
 Article Toolbar
Print
BibTeX entry

Search

Latest News
- Generation5 10-year Anniversary (03/09/2008)
- New Generation5 Design! (09/04/2007)
- Happy New Year 2007 (02/01/2007)
- Where has Generation5 Gone?! (04/11/2005)
- NeuroEvolving Robotic Operatives (NERO) (25/06/2005)

What's New?
- Back-propagation using the Generation5 JDK (07/04/2008)
- Hough Transforms (02/01/2008)
- Kohonen-based Image Analysis using the Generation5 JDK (11/12/2007)
- Modelling Bacterium using the JDK (19/03/2007)
- Modelling Bacterium using the JDK (19/03/2007)


All content copyright © 1998-2007, Generation5 unless otherwise noted.
- Privacy Policy - Legal - Terms of Use -