---
title: "Fuzzy logic and fuzzy inference"
subject: "Artificial Intelligence"
chapter: 4
key: "semester_6/artificial_intelligence:fuzzy-logic-inference"
source: https://www.bctengineer.com/q/semester_6/artificial_intelligence/fuzzy-logic-inference
site: BCT Engineering
---

# Fuzzy logic and fuzzy inference

Artificial Intelligence · Chapter 4: Knowledge Representation, Inference & Reasoning

- Asked in: 2070 Magh, 2+6 marks; 2073 Magh, 3+7 marks (asked 2 times)
- Video: [Fuzzy Inference System Walkthrough | Fuzzy Logic, Part 2](https://www.youtube.com/watch?v=CBTEVFphv-E) — MATLAB
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/artificial_intelligence/fuzzy-logic-inference
- Whole chapter: https://www.bctengineer.com/md/semester_6/artificial_intelligence/chapter-4

## Question

What is Fuzzy Logic? Explain the Fuzzy Inference (Mamdani Fuzzy Inference Method) with suitable example.

## Short answer

Fuzzy logic handles partial truth with membership functions. Mamdani inference fuzzifies crisp inputs, evaluates rules by min clipping, aggregates by max, and defuzzifies via centroid. Example: temperature 28°C, humidity 60% gives fan speed ≈ 59.6%.

## Answer

#### Fuzzy logic
**Fuzzy logic** is a form of many-valued logic introduced by Lotfi Zadeh (1965) in which a statement can be **partially true**, with a degree of truth between 0 and 1, instead of only true (1) or false (0). It handles vagueness and uncertainty in human language such as "warm", "tall" or "fast".

- A **fuzzy set** A is defined by a **membership function** μA(x) ∈ [0, 1].
- Operations: AND (intersection) μ = min(μA, μB); OR (union) μ = max(μA, μB); NOT μ = 1 − μA.
- **Linguistic variables** (e.g. temperature) take values such as Cold, Warm, Hot.

#### Mamdani fuzzy inference
Mamdani's method (1975) uses IF-THEN rules whose inputs and outputs are fuzzy sets. Four steps:
1. **Fuzzification:** convert crisp inputs to membership degrees in the input fuzzy sets.
2. **Rule evaluation:** compute the firing strength of each rule (AND = min, OR = max); clip (min) the output set at this strength.
3. **Aggregation:** combine all clipped output sets into one fuzzy set using max (union).
4. **Defuzzification:** convert the aggregated set into one crisp value, usually by the **centroid** method: x* = Σ x·μ(x) / Σ μ(x).

```text
Crisp   -> Fuzzification -> Rule evaluation -> Aggregation
input                          (rule base)         |
                                                   v
Crisp output <------------ Defuzzification <-------+
```

#### Example: fan speed controller
Inputs: temperature = 28 °C, humidity = 60 %. Output: fan speed (0-100 %).

Rules:
- R1: IF temperature is Hot AND humidity is High THEN speed is Fast.
- R2: IF temperature is Warm AND humidity is Medium THEN speed is Medium.

Membership functions (triangular, given as (left, peak, right)): Warm (15, 25, 35), Hot (25, 40, 55); Medium humidity (30, 50, 70), High (50, 80, 110); speed Medium (25, 50, 75), Fast (50, 100, 150).

**Step 1: Fuzzification**
- μWarm(28) = (35 − 28)/10 = 0.7; μHot(28) = (28 − 25)/15 = 0.2
- μMedium(60) = (70 − 60)/20 = 0.5; μHigh(60) = (60 − 50)/30 = 0.33

**Step 2: Rule firing strength**
- R1 = min(0.2, 0.33) = **0.2** → clip "Fast" at 0.2
- R2 = min(0.7, 0.5) = **0.5** → clip "Medium" at 0.5

**Step 3: Aggregation** (max of the clipped sets), sampled every 10 %:

| Speed x | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 |
|---|---|---|---|---|---|---|---|---|
| Medium clipped | 0.2 | 0.5 | 0.5 | 0.5 | 0.2 | 0 | 0 | 0 |
| Fast clipped | 0 | 0 | 0 | 0.2 | 0.2 | 0.2 | 0.2 | 0.2 |
| Aggregate μ | 0.2 | 0.5 | 0.5 | 0.5 | 0.2 | 0.2 | 0.2 | 0.2 |

**Step 4: Defuzzification (centroid)**

Σ x·μ = 30(0.2) + 40(0.5) + 50(0.5) + 60(0.5) + 70(0.2) + 80(0.2) + 90(0.2) + 100(0.2) = 149

Σ μ = 2.5

x* = 149 / 2.5 ≈ **59.6 %**

**Answer:** the fan speed is set to about 60 %.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What distinguishes fuzzy logic from classical logic?
   A. Statements have a degree of truth between 0 and 1
   B. Statements are only true or false
   C. It uses only probabilities of events
   D. It forbids linguistic variables
   Answer: A. Membership functions give partial truth in [0, 1], which handles vague terms such as warm or tall. (Key point: Fuzzy logic idea)

2. How are AND, OR and NOT computed on membership values?
   A. AND = max, OR = min, NOT = 1 - μ
   B. AND = min, OR = max, NOT = 1 - μ
   C. AND = product, OR = sum, NOT = -μ
   D. AND = min, OR = min, NOT = μ
   Answer: B. Intersection is min, union is max and complement is 1 - μ. (Key point: Fuzzy operators)

3. What is the order of the Mamdani inference steps?
   A. Defuzzification, aggregation, rule evaluation, fuzzification
   B. Fuzzification, rule evaluation, aggregation, defuzzification
   C. Rule evaluation, fuzzification, defuzzification, aggregation
   D. Aggregation, fuzzification, rules, defuzzification
   Answer: B. Crisp inputs are fuzzified, rules fire and clip outputs, the clipped sets are aggregated by max, then a crisp value is obtained. (Key point: Mamdani steps)

4. With μHot(28) = 0.2 and μHigh(60) = 0.33, what is the firing strength of 'IF Hot AND High'?
   A. 0.33
   B. 0.2
   C. 0.53
   D. 0.066
   Answer: B. AND uses min(0.2, 0.33) = 0.2, so the output set Fast is clipped at 0.2. (Key point: Rule strength)
