Fuzzy Logic and Fuzzy Set Theory
We discussed some of the short-comings of traditional set theory, by
means of a paradox which was well-known to the ancient logicians:
Premise 1: A person with $1,000,000,000 is wealthy.
Premise 2: If you take $0.01 from a wealthy person, they are still wealthy.
Conclusion: Therefore, if a person with $1,000,000,000
loses all their money $0.01 at a time, they are still wealthy even when
they have no money left at all.
The two premises seem perfectly acceptable, but the conclusion is obviously not. To avoid the paradox, you need
to pick some value x and say "people with at least $x are wealthy, and
people with < $x are not wealthy". This does not correspond to
how people actually think.
We also looked at a syllogism about lions:
Premise 1: All adult lions are dangerous.
Premise 2: Simba is an adolescent lion.
Conclusion: ?
Classical
logic does not let us draw any conclusion, yet a human being would
certainly be able to draw the conlcusion that Simba should be
approached with caution.
These problems arise because in traditional (or crisp)
set theory, sets have sharp edges.
We started with an overview of the history of fuzzy logic, from its
first appearance in 1965, through the years of scepticism and
rejection, to the first successful applications and its current
popularity.
We introduced the idea of a fuzzy set, which is defined by a membership
function. For a fuzzy set A and an object x in our universe, the
level of membership of x in A is formally written as MU (sub A) (x),
but because this is difficult in ASCII, we often just write it as
A(x). A(x) can be any
value in the closed interval [0,1].
Membership functions can take almost any shape.
If the universe consists of a continuum (such as a numeric variable
which can have any value from a continuous range) then the membership
function will be best described by a mathematical function - often a
very simple one such as a triangular function.
If the universe consists of a discrete collection (such as a group of
people) then the membership function will often be described by a
vector, in which the i-th element gives the membership value for the
i-th object in the collection.
Union, Intersection, Complement
There are many ways to define the union, intersection and complement of
fuzzy sets. We will use the earliest (and still most widely used)
definitions:
If we think about a numerical interpretation of union for crisp sets A
and B, where any object has membership = 0 or membership = 1, we can
see that an object has membership = 1 in A U B if it has membership
= 1 in A or membership = 1 in B. This can be captured
mathematically by letting the membership in A U B be the max of the membership in A and the membership in B.
We extend this to fuzzy sets A and B by defining "A union B"(x) = max(A(x),B(x))
This makes sense in a natural language sense as well. For example, if
John is very strongly in the set of happy people, and
John is slightly in the set of athletic people,
then it is reasonable to say that John is strongly in the set of people
who are either happy or athletic or both (i.e. the union of the
original sets).
Not too surprisingly, if we look for a numeric interpretation of intersection for crisp sets, we find that min works perfectly. Again we extend this to fuzzy sets A and B by defining "A intersect B"(x) = min(A(x),B(x))
The obvious numerical interpretation for the complement of a crisp set
(i.e. the set A' [note that the complement of A is normally represented
by A with a bar over it, but I don't have that option here] for all
elements are in A' if and only if they are not in A) is to say that the
membership of an object x in A' = 1 - the membership of x in A.
We extend this to fuzzy sets by defining A'(x) = 1 - A(x).
Consider the
properties of fuzzy subsethood and fuzzy set equality.
Originally, fuzzy
subsethood was defined as follows: Let A and B be fuzzy sets.
A is a fuzzy subset of B iff for all x, A(x) <= B(x)
(remember that A(x) is the degree of membership that x has
in A)
This
definition certainly captures crisp subsethood, since membership values
in crisp sets are either 0 or 1, and the only way that A would not
be a subset of B is if there is some x with membership 1 in A and
membership 0 in B. However, this definition has the drawback that
it is completely binary: either A is a subset of B or it is not
... as a definition, it is completely unfuzzy.
A more recent
definition of fuzzy subsethood is based on the observation that if A is
a subset of B, then the intersection of A and B is identical to
A. More usefully, if A is a subset of B, the cardinality (size) of A intersect B is identical to the cardinality of A. Using |A| to denote the cardinality of a set, we can write
The degree to which A is a fuzzy subset of B = |A intersect B| / |A| .
If we imagine A
somehow starting out as a subset of B, then slowing moving "out of" B,
it is clear that the cardinality of the intersection would decrease,
while the cardinality of A would remain the same. The ratio given
above would decrease until we finally reach a point at which A is
completely out of B. At this point the intersection of A and B is
completely empty and the ratio equals 0. Thus the ratio shown
above gives a simple and practical method for defining fuzzy subsethood ...
provided we can define the cardinality of a fuzzy set.
The
cardinality of a crisp set is simply the number of elements it has.
This is equivalent to saying that we can compute the cardinality
of a crisp set by summing its membership function vector (which is all
0's and 1's). We can easily extend this to fuzzy sets. The
cardinality of a fuzzy set A = SUM(A(x)) over all x . For fuzzy
sets with continuous membership functions, we use the area under the
membership function as the cardinality of the set.
Fuzzy set
equality was originally defined simply: fuzzy set A = fuzzy
set B iff A(x) = B(x) for all x. Unfortunately, this is also
completely non-fuzzy. We really want a definition of fuzzy set
equality that will let us say that two fuzzy sets are almost (or
somewhat, or not very) equal.
One very appealing solution is to
observe that two sets are equal iff they are both subsets of the other,
i.e. A = B iff A is a subset of B and
B is a subset of B. Now that we can compute a value for how much
A is a subset of B (and vice versa), we can easily compute a value for
how equal the two fuzzy sets are ... if we had a way of dealing with
the and.
So now we turn to defining the logical operators and, or, negation, and implies.
Fuzzy Logic Operators
The natural relationship between union, intersection and complement in the domain of sets, and or, and and not in the domain of logic led fuzzy logicians to use the same definitions for each of the corresponding terms.
Notation: if PHI is any proposition, we use T(PHI) to mean the truth
value of PHI. T(PHI) can be any value in the range [0,1].
Definition:
T(p AND q) = min(T(p),T(q))
T(p OR q) = max(T(p),T(q))
T(NOT p) = 1 - T(p)
Note that in the decades since Zadeh first published these ideas, other
definitions for AND, OR and NOT have been proposed. There is now
a significant body of mathematics dealing with functions that are
suitable as definitions for AND, OR and NOT in fuzzy logic.
However, the ones given here are still the most widely used.
Which brings us to the last of our basic logical operators: IMPLIES.
In the crisp case we can write the truth table for p -> q, using 0
for a statement that is false and 1 for a statement that is true, like
this
T(p) T(q) T(p -> q)
0 0 1
0 1
1
1 0
0
1 1 1
Looking for a simple numerical way to express this, the first suggestion was
T(p -> q) = 1 if T(p) <= T(q)
= 0 otherwise
So if T(p) = 0.3 and T(q) = 0.8, T(p -> q) = 1
This is called Strict Standard Implication,
and it certainly works for fuzzy logic ... unfortunately, since it only
gives two possible truth values for the implication, it is not really
fuzzy at all. It does have the useful property that it includes
crisp implication as a special case.
The next form of implication is based on the equivalence p -> q == q OR NOT p. Since we have already defined OR and NOT for fuzzy propositions, we can immediately define
T(p -> q) = max(T(q), 1 - T(p))
This also includes crisp implication as a special case, and it makes it
possible for T(p -> q) to have any value in the range [0,1].
This is called Kleene-Dienes Implication.
Here is another definition of fuzzy implication:
Godel Implication - T(p -> q) = 1 if T(p) <= T(q)
=
T(q) otherwise
And one more:
Maximum Fuzzy Implication is based on the logical equivalence p -> q == NOT p OR (p AND q)
Using the standard definitions of NOT, OR and AND, we get T(p -> q) = max(1-T(p), min(T(p),T(q)))
We can compare these definitions of IMPLIES by choosing particular
values for T(p) and T(q) and creating a table. For example,
suppose we consider the truth values {0,0.3,0.7,1} for each of p and q
Strict Standard
|
T(q)
|
0
|
0.3
|
0.7
|
1
|
T(p)
|
0
|
1
|
1
|
1
|
1
|
0.3
|
0
|
1
|
1
|
1
|
0.7
|
0
|
0
|
1
|
1
|
1
|
0
|
0
|
0
|
1
|
Kleene-Dienes
|
T(q)
|
0
|
0.3
|
0.7
|
1
|
T(p)
|
0
|
1
|
1
|
1
|
1
|
0.3
|
0.7
|
0.7
|
0.7
|
1
|
0.7
|
0.3
|
0.3
|
0.7
|
1
|
1
|
0
|
0.3
|
0.7
|
1
|
Godel
|
T(q)
|
0
|
0.3
|
0.7
|
1
|
T(p)
|
0
|
1
|
1
|
1
|
1
|
0.3
|
0
|
1
|
1
|
1
|
0.7
|
0
|
0.3
|
1
|
1
|
1
|
0
|
0.3
|
0.7
|
1
|
Maximum
Fuzzy
|
T(q)
|
0
|
0.3
|
0.7
|
1
|
T(p)
|
0
|
1
|
1
|
1
|
1
|
0.3
|
0.7
|
0.7
|
0.7
|
0.7
|
0.7
|
0.3
|
0.3
|
0.7
|
0.7
|
1
|
0
|
0.3
|
0.7
|
1
|
One reason that there are so many different definitions for "fuzzy
implication" (there are many more than the four we have seen here) is that none of them are universally optimal. Most
are particularly useful for some types of application, and less useful
for others.
Test 5 will cover the material up to this point. However, for
your interest, I am also including here the notes for the final topic
that I had planned/hoped to cover on fuzzy logic.
Application of Fuzzy Logic to a "Real World" Example
To
illustrate how fuzzy logic is applied in practical applications,
consider the problem of stabilizing a cruise ship. Modern cruise
ships have massive gyroscopic stabilizers in them. Spinning the
stabilizer faster makes the ship steadier, but it also uses more
energy. We can design a fuzzy logic control system that will
determine an appropriate rpm for the stabilizer.
The inputs to the system will be
Swell: the swell can be Calm, Moderate, or
Heavy (these are all fuzzy sets)
Speed: the ship's current speed can be Slow, Medium,
or Fast (fuzzy sets)
Direction: the waves hitting the ship can be
Fore-and-Aft, Quarter, or Broadside
(fuzzy sets)
The output will be RPM, which also has three fuzzy sets associated with
it: Low, Medium, High. To illustrate, the High
set for RPM might look like
_____________
/
/
/
___________/
The control system is based on what are called Fuzzy Mapping Rules, such as:
R1: If Swell is Heavy and Speed is Slow and Direction is Broadside, then RPM is High
R2: If Swell is Moderate or Speed is Fast or Direction is Quarter, then RPM is Medium
R3: If Swell is Calm and (Speed is Slow or Direction is Fore-and-Aft), then RPM is Low
R4: If Swell is not Calm and Speed is not Fast, then RPM is not Low
etc.
Note
that we can have as many rules as we want, and that it is perfectly
valid for more than one rule to have the same result (for example, we
could have two rules with the consequent "then RPM is High").
However, we should not have two rules that have the same
requirements but different results (for example, we should not have two
rules like "If Swell is Heavy, then RPM is High" and "If Swell is
Heavy, then RPM is Medium"). The goal is usually to have a
relatively small rule set, but in a real application it is not uncommon
to have a few dozen rules or more. It is almost never necessary
to have rules for all possible combinations of the inputs. The
development of a fuzzy control system is an iterative process: starting
with a basic set of rules and membership functions, the system is
refined and fine-tuned by adding more rules and/or modifying the
membership functions.
Applying the system begins with obtaining
input values. For example, suppose we measure Swell as 9 metre
waves, Speed at 6 knots, and Direction as 95 degrees. Note that
these are crisp values. Fuzzy logic also includes techniques for
dealing with fuzzy inputs, but we will not discuss these here.
For each rule, we determine the strength of its match with the input values.
For
example, consider Rule 1. Suppose that Heavy(9) = 0.5, Slow(6) =
0.5, and Broadside(95) = 0.9. In Rule 1, these conditions are anded together, and in simple fuzzy logic we use min for and.
We conclude that this rule's strength is 0.5. We apply this
to the result condition ("RPM is High") by reducing the maximum value of the the "RPM High" membership function to 0.5
Now
consider Rule 2. Suppose that Moderate(9) = 0.2, Fast(6) = 0.3,
and Quarter(95) = 0.25. Since these conditions are ored together, we take the max
of the values, 0.3, as the strength of this rule. We reduce the
maximum value of the result condition ("RPM is Medium") to 0.3
We
do the same for all the remaining rules. This gives us a
collection of height-reduced fuzzy output sets for RPM ... but what do we do with these?
We need an actual rpm value at which to set the stabilizer.
The final step in the fuzzy control system is defuzzification.
There are many ways to reduce the collection of height-reduced
sets to a single value. One very popular method is to take the
weighted average of all of the reduced output sets. This is
conceptually very simple but can be computationally messy if the
membership functions have odd shapes. Another popular method is
to determine the maximum membership value that any RPM value has in any
of the reduced sets (for example, if we were only dealing with the
first two rules in the current example, the maximum membership value
that any RPM value has in the reduced sets is 0.5). We then find
all RPM values that achieve this level of membership, and compute the
average of these RPM values. Continuing with the example, we
might find that RPM values between 80 and 100 all have membership 0.5
in at least one of the height-reduced sets. The average of these
values
is 90, and this would be our defuzzified final value for RPM.
The benefits of a system like this are two-fold. First, the rules
are simple and intuitive, expressed in terms that are consistent with
the way a human expert would state them. Second, even though the
calculations are very simple, the system can exhibit complex,
non-linear behaviour and can respond very smoothly to changes in input.