Blog
Fuzzy logic introduction
Fuzzy logic is an extension of classical logic that allows for the modeling of imperfections in data, and in some ways, it more closely resembles the flexibility of human reasoning.
In this introductory course, we’ll begin by defining the basic concepts of fuzzy logic and then explain them with an example that we’ll use throughout the course. The example is: deciding on the tip amount after a restaurant meal based on the perceived quality of the service and food. This is a classic case often used to introduce fuzzy logic.
Prerequisites: You’ll need a foundational knowledge of set theory and classical (Boolean) logic.
Introduction
Fuzzy logic is an extension of Boolean logic proposed by Lotfi Zadeh in 1965. It’s based on his fuzzy set theory, which generalizes classical set theory. By introducing the concept of degree into condition evaluation, a condition is no longer simply “true” or “false,” but can exist in an intermediate state. This makes reasoning more flexible and capable of handling vague and uncertain information.
One advantage of fuzzy logic is that its rules are often expressed in natural language. For example, a driver (who is very careful about their license) might follow rules like these:
- If the red light is on… the car is going fast… and it’s close… → I’ll brake hard.
- If the red light is on… the car is going slow… and it’s far away… → I’ll maintain my speed.
- If the orange light is on… the car is going at a medium speed… and it’s far away… → I’ll brake gently.
- If the green light is on… the car is going slow… and it’s close… → I’ll accelerate.
Intuitively, our brains don’t process these input variables with precise values, but rather with approximate assessments. This corresponds perfectly to the fuzzy logic concept of “degree of satisfaction” for a condition.
In this course, we’ll progressively design a fuzzy inference system with the goal of determining the tip amount based on the quality of service and food.
Fuzzy Subsets
Fuzzy logic is built upon fuzzy set theory, which is a generalization of classical set theory. In academic literature, the terms “fuzzy subset” and “fuzzy set” are often used interchangeably. Classical sets are also referred to as “crisp sets,” in contrast to “fuzzy” ones. Similarly, classical logic is also known as Boolean or two-valued logic.
For example, here’s a function that describes the membership function for the fuzzy subset “good service quality”:

Membership function characterizing the subset ‘good’ of service quality
Definition: A fuzzy subset A of a set X is defined by a membership function . This function is the fuzzy equivalent of a classical set’s characteristic function.
For our tipping example, we need to define membership functions for fuzzy subsets across three types of variables:
- Input 1: Service Quality → Fuzzy subsets: Poor, Good, Excellent
- Input 2: Food Quality → Fuzzy subsets: Bad, Delicious
- Output: Tip Amount → Fuzzy subsets: Low, Medium, High
The shape of these membership functions is a design choice. They can be determined based on expert knowledge or statistical analysis and may take the form of S-functions, hyperbolic tangent functions, exponential functions, or Gaussian functions, among others.
This graph visually demonstrates the difference between a classical set and its corresponding fuzzy set for “delicious food”:

Graphical representation of a classic set and a fuzzy set
This diagram compares the two membership functions corresponding to the previous sets:

Comparison between the characteristic function of a classical set and the membership function of a fuzzy set
To define the characteristics of fuzzy sets, we first redefine and extend the usual properties of classical sets.
Let be a set, a fuzzy subset of , and its characteristic membership function.
DEFINITION: The height of , denoted , corresponds to the supremum of the range of its membership function: .
DEFINITION: is said to be normalized if and only if . In practice, it is extremely rare to work with non-normalized fuzzy sets.
DEFINITION: The support of is the set of elements in that belong to even in the slightest degree. In other words, it is the set .
DEFINITION: The core of is the set of elements in that belong to completely. In other words, it is the set . By construction, .
DEFINITION: An -cut of is the classical subset of elements with a degree of membership greater than or equal to : .
Here is another membership function for a medium tip, with the properties above illustrated:

AI Course Properties of a fuzzy set
Linguistic Variables
With membership functions, we can define fuzzy systems using natural language. A linguistic variable provides a way to link numerical variables with fuzzy subsets.
Definition: A linguistic variable is a triplet , where is a variable (e.g., service quality or tip amount), is its range of values, and is a set of its corresponding fuzzy subsets.
Examples:
- Service Quality → {Poor, Good, Excellent}
- Food Quality → {Bad, Delicious}
- Tip Amount → {Low, Medium, High}

Linguistic variable service quality

Linguistic variable tip amount

Linguistic variable the quality of the food
Fuzzy Operators
To work with fuzzy sets, we need to redefine the classical set operators (AND, OR, NOT) so they can handle membership values between 0 and 1.
There are two common types of operators:
Zadeh Operations (Most Common)
- Intersection (A ∩ B):
- Union (A ∪ B):
- Complement ():
Probabilistic Operations
- Intersection (A ∩ B):
- Union (A ∪ B):
- Complement ():
These operations maintain commutativity, associativity, and distributivity. However, they differ from classical logic in two key ways:
- The law of the excluded middle does not hold:
- An element can partially belong to both A and not A at the same time:
Fuzzy Inference
In classical logic, inference follows this pattern:
If is true is also true
In fuzzy logic, fuzzy inference (also known as approximate reasoning) is based on fuzzy rules expressed in natural language, using the linguistic variables we defined earlier. A fuzzy rule typically has the following form:
“If and , then ”
where , , and are fuzzy sets.
For example, a rule might be: “If (food quality is delicious), then (the tip will be high).”
The degree to which the variable “tip” belongs to the fuzzy set “high” depends on the degree to which the premise holds—that is, the membership value of the variable “food quality” in the fuzzy set “delicious.” The core idea is: the more a proposition in the premise is validated, the more the suggested output action in the conclusion should be respected. To determine the truth value of the fuzzy proposition “the tip will be high,” we must define fuzzy implication (the fuzzy implication relation).
Like other fuzzy operators, fuzzy implication doesn’t have a single, universal definition. The designer of a fuzzy system must choose from a variety of existing fuzzy implications or define one manually. The two most common definitions used in practice are:
It’s worth noting that these two implications do not generalize classical implication (i.e., they don’t include it as a special case). While other fuzzy implications that do generalize classical implication exist, they are less commonly used.
If we choose the Mamdani implication for the rule “If (food quality is delicious), then (the tip will be high),” and the food quality is rated as 8.31 on a 10-point scale, we get the following result:

AI Course Example of fuzzy implication
The outcome of applying a single fuzzy rule depends on three factors:
- The chosen fuzzy implication definition.
- The membership function of the fuzzy set in the rule’s conclusion.
- The degree of truth (membership) of the proposition in the rule’s premise.
Since we’ve defined fuzzy AND, OR, and NOT operators, the premise of a fuzzy rule can be composed of several fuzzy propositions combined with a conjunction (AND). The entire set of rules for a fuzzy system is called the decision matrix. Here is our decision matrix for the tipping example:
- If service is poor or food is bad, then the tip is low.
- If service is good, then the tip is medium.
- If service is great or food is delicious, then the tip is high.
Now, we’ll use these three rules from our decision matrix to perform inference. This will result in three fuzzy sets for the tip amount. We then aggregate them into a single fuzzy set, typically using the MAX operator. The following diagram illustrates this aggregation:

AI Course Example of fuzzy involvement using the decision matrix
As we can see, all that’s left is to make the final decision: the exact tip amount to give, given a service quality score of 7.83 out of 10 and a food quality score of 7.32 out of 10. This final step, which converts the fuzzy set resulting from the aggregation of conclusions into a single, concrete decision, is called defuzzification.
Defuzzification
Like all fuzzy operators, the designer of the fuzzy system must choose from several possible defuzzification methods. We’ll briefly present the two main methods: the Mean of Maxima (MM) method and the Centroid of Gravity (COG) method.
The MM defuzzification method defines the output (the tip amount) as the average of the x-coordinates of the maxima of the fuzzy set resulting from the aggregated conclusions.
The formula provided is actually for the Center of Gravity (COG) method, not the Mean of Maxima. The correct formula for the COG is:
where and is the aggregated fuzzy set from the conclusions.
The Mean of Maxima (MM) method, on the other hand, is a simpler calculation. It finds all points on the fuzzy set with the highest membership value (the “maxima”) and then averages their corresponding x-values.
Important Note: The text you provided mixes up the descriptions and formulas. The formula as you wrote it, is a special case of COG applied only to the subset of points with maximum membership, which is a bit ambiguous. It’s more accurate to say that COG uses the entire fuzzy set, while MM focuses only on the points with the highest membership value.

Defuzzification using the maximum average method
The more commonly used method is Center of Gravity (COG) defuzzification. This method defines the output as the x-coordinate of the centroid (center of gravity) of the area under the membership function curve for the aggregated fuzzy set.
The formula for the COG decision is:
.jpg)
Defuzzification using the centroid method (COG)
COG defuzzification, while more computationally intensive, avoids the discontinuities that can occur with the MM method. Some research focuses on finding less complex alternatives that still maintain performance. As we saw when applying MM versus COG to our example, the choice of defuzzification method can have a significant impact on the final decision.
Conclusion + Keywords
Throughout the definition process, we’ve seen that fuzzy system designers must make many choices. These choices are typically based on expert advice or statistical analysis of historical data, especially when defining membership functions and the decision matrix.
Here is a synoptic overview of a fuzzy system:

AI course introduction synoptic overview of a fuzzy system
In our example:
- Input is “service quality rated 7.83/10, food quality rated 7.32/10.”
- Fuzzifier corresponds to the three linguistic variables: “service quality,” “food quality,” and “tip amount.”
- Inference engine is made up of the chosen fuzzy operators.
- Fuzzy knowledge base is the set of fuzzy rules.
- Defuzzifier is where the defuzzification method is applied.
- Output is the final decision: “tip amount of 25.1.”
It’s interesting to compare the set of decisions from our fuzzy inference system with those from a classical logic system:

AI Course Set of decisions of a fuzzy system

Easy Set of decisions of a system based on classical logic
The full power of fuzzy logic lies in its ability to create flexible, non-linear reasoning systems that produce decisions without sharp discontinuities. These decisions are closer to human behavior than the rigid, binary decisions of classical logic. Furthermore, expressing rules in a natural language offers many advantages, such as directly incorporating the expertise of non-computer specialists into the decision system or more subtly modeling certain aspects of natural language.
Keypoints
Fuzzy Logic Introduction
- Definition: An extension of Boolean logic that allows for “degrees” of truth between true/false.
- Prerequisites: Set theory + Boolean logic.
Core Concepts
- Fuzzy Set: Defined by a membership function .
- Key Properties: Height, support, core, alpha-cut.
- Linguistic Variable: Described using natural language (e.g., Service Quality = Poor/Good/Excellent).
Operators
- Zadeh-type: min, max, .
- Probabilistic-type: product, algebraic sum.
- Does not satisfy the law of the excluded middle: .
Fuzzy Inference
- Rules: If…then… (natural language).
- Implication: Mamdani (min), Larsen (product).
- Aggregation: MAX method.
Defuzzification
- Mean of Maxima (MM): Simple but can be discontinuous.
- Center of Gravity (COG): More precise but computationally intensive.
Example: Tipping System
Inputs: Service Quality, Food Quality.
Output: Tip Amount (Low/Medium/High).
Rules:
- Poor or Bad Low
- Good Medium
- Excellent or Delicious High
Conclusion
- Fuzzy logic = a mathematical approach to human-like reasoning.
- System design requires choosing: membership functions, operators, implication, aggregation, and defuzzification methods.

Easy AI Course Introduction fuzzy logic mindmap