Nexus Learn

Lecture 22: Fuzzy Sets and Fuzzy Logic

Lecture Slides CS-511 Artificial Intelligence 6 min read Updated 8 Nov 2026

↓ Download slides (PowerPoint)

Recap of Lecture 21 and Homework Check

LAST LECTURE · 5 MIN

Today: is 182 cm 'tall'? Is 30 °C 'hot'? Probability cannot answer - the problem is not chance but a vague word.

Today's Plan (50 minutes)

ROADMAP

0-5

Recap of Lecture 21 and homework check

S02

5-8

Plan and learning outcomes

S03-S04

8-18

Module 1: Fuzzy sets - crisp vs fuzzy, linguistic variables, fuzziness vs probability

S05-S08

18-27

Module 2: Membership functions - shapes and features

S09-S11

27-35

Module 3: Fuzzy logic - operations, hedges, rules, applications

S12-S15

35-43

Class activity: degrees, operations and hedges

S16

43-48

Common mistakes and recap quiz

S17-S18

48-50

Homework and next lecture

S19

Learning Outcomes (SLOs)

BY THE END OF THIS LECTURE YOU WILL BE ABLE TO

SLO 22.1

Differentiate crisp and fuzzy sets, and fuzziness from probability, using linguistic variables

→ CLO3 · C2 Understand

SLO 22.2

Apply triangular, trapezoidal, Gaussian and sigmoid membership functions and find support, core and crossover points

→ CLO3 · C3 Apply

SLO 22.3

Apply fuzzy union, intersection, complement and hedges, and explain why the excluded-middle law fails

→ CLO3 · C3 Apply

  • Course Learning Outcome(s) served
  • CLO3: Apply various techniques and algorithms of AI used in general problem solving, optimization problems, constraint satisfaction problems, and game programming.

Slide 5

MODULE 1

Fuzzy Sets

Belonging is a matter of degree

Crisp Sets vs Fuzzy Sets

MODULE 1 · THE IDEA

REAL OUTPUT: L22/CRISP_VS_FUZZY.PY

  • height crisp tall fuzzy tall
  • 165 cm 0 0.00
  • 175 cm 0 0.33
  • 180 cm 0 0.67
  • 182 cm 0 0.80
  • 183 cm 1 0.87
  • 190 cm 1 1.00

Membership Functions and Linguistic Variables

MODULE 1 · DEFINITIONS

You have used these: P07a built cold, comfortable and hot on 0-50 °C - a linguistic variable with three terms.

Fuzziness Is Not Probability

MODULE 1 · COMPARISON

Bottle A: membership 0.91

Bottle B: probability 0.91

'Fairly drinkable' - a little muddy, but safe.

9% chance it is poison. Which one would you drink?

Slide 9

MODULE 2

Membership Functions

Shapes and features

Four Common Shapes

MODULE 2 · SHAPES

REAL OUTPUT: L22/SHAPES.PY - DEGREE OF 26 °C

  • shape mu(26 C)
  • triangle trimf [15, 24, 33] 0.78
  • trapezoid trapmf [15, 20, 28, 33] 1.00
  • Gaussian gaussmf mean 24, sigma 4 0.88
  • sigmoid 'hot' sigmf centre 33, slope 0.6 0.01

Features of a Fuzzy Set

MODULE 2 · SUPPORT, CORE, CROSSOVER

REAL OUTPUT: L22/FEATURES.PY

  • comfortable trimf [15, 24, 33]
  • support 15 < x < 33 C (degree > 0)
  • core 24.0 to 24.0 C (degree = 1)
  • crossover 19.5, 28.5 C (degree = 0.5)
  • height 1.0 -> normal set
  • hot trapmf [28, 38, 50, 50]
  • support 28 < x <= 50 C (degree > 0)
  • core 38.0 to 50.0 C (degree = 1)
  • crossover 33.0 C (degree = 0.5)
  • height 1.0 -> normal set

Triangle shortcut: for trimf [a, b, c] the crossovers are (a + b)/2 and (b + c)/2: 19.5 and 28.5 for [15, 24, 33].

Slide 12

MODULE 3

Fuzzy Logic

AND, OR, NOT with degrees

Fuzzy Operations

MODULE 3 · UNION, INTERSECTION, COMPLEMENT

REAL OUTPUT: L22/OPS.PY

  • warm = {1.00/25, 0.60/30, 0.30/35, 0.00/40}
  • hot = {0.00/25, 0.20/30, 0.70/35, 1.00/40}
  • warm OR hot = {1.00/25, 0.60/30, 0.70/35, 1.00/40}
  • warm AND hot = {0.00/25, 0.20/30, 0.30/35, 0.00/40}
  • NOT hot = {1.00/25, 0.80/30, 0.30/35, 0.00/40}

Check: with degrees 0 and 1 only, max / min / 1 - μ give the ordinary OR / AND / NOT truth tables of Lecture 6.

Hedges and the Excluded Middle

MODULE 3 · PROPERTIES

REAL OUTPUT: L22/OPS.PY

  • very hot = {0.00/25, 0.04/30, 0.49/35, 1.00/40}
  • somewhat hot = {0.00/25, 0.45/30, 0.84/35, 1.00/40}
  • hot OR NOT hot = {1.00/25, 0.80/30, 0.70/35, 1.00/40} (not all 1)
  • hot AND NOT hot = {0.00/25, 0.20/30, 0.30/35, 0.00/40} (not all 0)

very A = μ²

somewhat A = √μ

Crossover 33 °C

Stricter: 0.7 becomes 0.49.

Looser: 0.7 becomes 0.84.

hot = NOT hot = 0.5 - the most doubtful point.

Fuzzy Rules and Where Fuzzy Logic Is Used

MODULE 3 · APPLICATIONS

A FUZZY RULE (P08)

  • IF temperature is hot AND humidity is NOT dry
  • THEN fan speed is fast

Sendai subway (1987)

Washing machines

Cameras, ACs, cars

Irrigation

Smooth braking and acceleration.

Wash time from dirt level and load.

Autofocus, cooling level, gear changes.

Tubewell run time from soil moisture and heat.

Activity: Degrees, Operations and Hedges

CLASS ACTIVITY · PAIRS · 8 MIN

Pairs, 6 min + 2 min check. Calculators allowed.

tall = trapmf [170, 185, 220, 220]. Degree of 178 cm? Crisp (>= 183)?

A degree of 0.6: 'very' and 'somewhat'?

comfortable = trimf [15, 24, 33]. Degree of 30 °C? Crossover points?

0.6 AND NOT 0.6 = ? Which law of ordinary logic fails?

A = {0.2/25, 0.6/30, 1.0/35}, B = {0.7/25, 0.4/30, 0.1/35}. Find A OR B, A AND B, NOT A.

Fuzzy or probability? (a) 70% chance of rain (b) the tea is fairly hot

Common Mistakes

WATCH OUT

WRONG IDEA

CORRECT IDEA

✗ A fuzzy degree is a probability.

✓ Degree = how well a word fits; probability = chance.

✗ Degrees in all terms must add to 1.

✓ They need not: 36 °C is hot 0.8, comfortable 0.

✗ '0.7/35' means 0.7 divided by 35.

✓ It pairs degree 0.7 with the value 35.

✗ Fuzzy AND is multiplication.

✓ Standard AND is min (product is another choice).

✗ very hot = 2 x hot.

✓ very = μ², which stays between 0 and 1.

Recap Quiz

CHECK YOUR UNDERSTANDING · 3 MIN

  • Q1. In a fuzzy set, membership is:
  • (a) Only 0 or 1 (b) Any value from 0 to 1 (c) Any real number (d) Always 0.5
  • Q2. Crossover points of trimf [15, 24, 33] are:
  • (a) 15 and 33 (b) 19.5 and 28.5 (c) 24 only (d) 20 and 30
  • Q3. Fuzzy union (OR) of 0.3 and 0.7 is:
  • (a) 0.21 (b) 0.3 (c) 0.7 (d) 1.0
  • Q4. 'very hot' for a degree of 0.7 is:
  • (a) 0.49 (b) 0.84 (c) 1.4 (d) 0.3

Homework and Next Lecture

BEFORE THE NEXT CLASS

  • Task 1: young = trapmf [0, 0, 25, 40] on age 0-100. Degrees of ages 20, 30, 35, 45? Support and core?
  • Task 2: 'about 50 %' humidity = gaussmf (mean 50, sigma 10). Degrees of 40, 60 and 70 %? Use μ = e^(-(x - 50)² / (2 x 10²)).
  • Task 3: hot = trapmf [28, 38, 50, 50]. For 30, 33 and 36 °C compute hot OR NOT hot and hot AND NOT hot. Where is vagueness greatest?

NEXT LECTURE

  • Lecture 23:
  • Fuzzy Inference: Mamdani and Sugeno

← All CS-511 material