Human speech is full of vague words such as tall, warm and fast. Fuzzy logic lets a computer work with such terms in a precise way.

Boolean Logic versus Fuzzy Logic

In Boolean logic a statement is either true (1) or false (0). A person is either tall or not tall, with a sharp line at, say, 180 cm. This is unnatural, since someone of 179 cm is nearly as tall. Fuzzy logic, proposed by Lotfi Zadeh in 1965, allows a statement to be true to a degree between 0 and 1. A person of 170 cm might be tall to degree 0.3, and one of 185 cm to degree 0.9. It thus models the way people reason with approximate ideas.

Definition: Fuzzy logic. A form of logic in which a statement can be true to any degree between 0 and 1, which allows reasoning with vague and approximate concepts.

Fuzzy Sets

In a crisp set, an element either belongs or does not. In a fuzzy set A of a universe X, each element x has a degree of membership μA(x) between 0 and 1. The fuzzy set Tall may contain 160 cm with 0.1, 170 cm with 0.5 and 185 cm with 0.9. The support is the set of elements with membership above 0. A fuzzy subset A is a subset of B if μA(x) is at most μB(x) for every x.

Membership Functions

A membership function is a curve that gives the degree of membership for every value. Common shapes are the triangular, with three points a, b and c, the trapezoidal, with four points, the Gaussian, a bell shape, and the sigmoid. For a triangular function with peak at b, μ(x) = (x - a) / (b - a) for x between a and b, μ(x) = (c - x) / (c - b) for x between b and c, and 0 outside. The function is chosen by experts or by data.

Fuzzy Set Operations

The operations extend those of crisp sets. The union takes the maximum: μ(A or B) = max(μA, μB). The intersection takes the minimum: μ(A and B) = min(μA, μB). The complement is 1 - μA. A linguistic variable, such as Temperature, takes values that are words, such as Cold, Warm and Hot, each of which is a fuzzy set. Hedges such as very and slightly change a set, for example very can be the square of the membership.

Table 4.4: Crisp and fuzzy sets

Feature Crisp set Fuzzy set
Membership 0 or 1 0 to 1
Boundary Sharp Gradual
Union OR Maximum
Intersection AND Minimum
Complement NOT 1 minus membership

Example 4.4: Membership of a triangular set

Problem: The fuzzy set Warm has a triangular membership function with a = 15, b = 25, c = 35 degrees. Find the membership of 20, 25 and 30 degrees.

Solution:

  1. For 20: (20 - 15) / (25 - 15) = 0.5.
  2. For 25: it is the peak, so 1.
  3. For 30: (35 - 30) / (35 - 25) = 0.5.

Result: Warm has membership 0.5 at 20, 1 at 25, and 0.5 at 30 degrees.

def tri(x, a, b, c):
    if x <= a or x >= c:
        return 0.0
    return (x - a) / (b - a) if x <= b else (c - x) / (c - b)
for t in (20, 25, 30):
    print(t, tri(t, 15, 25, 35))

Output

20 0.5
25 1.0
30 0.5

Common mistakes

  • Treating a membership value as a probability. It measures the degree of belonging.
  • Using sum instead of maximum for the union.
  • Forgetting that the complement is 1 minus the membership.

Key takeaways

  • Boolean logic has two values, fuzzy logic has degrees between 0 and 1.
  • A fuzzy set gives each element a membership degree.
  • Union is the maximum, intersection the minimum, complement 1 minus membership.
  • A linguistic variable takes words as values.

Practice questions

  1. How does fuzzy logic differ from Boolean logic?
  2. What is a membership function?
  3. Give the fuzzy union and intersection.

Answers to the practice questions

  1. Boolean logic allows only true or false, fuzzy logic allows any degree of truth between 0 and 1.
  2. A curve that gives the degree of membership of each value in a fuzzy set.
  3. Union is the maximum and intersection is the minimum of the memberships.

Sources

  • Official BCA syllabus Artificial Intelligence and Expert Systems, course code 25BCA405DS02, Unit IV