AI Notes
Master fuzzy logic. Fuzzy sets, membership. AI reasoning 2024.
Beyond True and False
Classical (Boolean) logic operates in a binary world: statements are either true or false, elements either belong to a set or don't. But the real world is rarely so crisp. Is 28°C "hot"? Is a person at 5'10" "tall"? Is driving at 62 mph "fast"? These are matters of degree, not binary categories.
Fuzzy logic, introduced by Lotfi Zadeh in 1965, extends classical logic to handle partial truth. Instead of membership being 0 or 1, fuzzy sets allow membership values anywhere in [0, 1]. A temperature of 28°C might be 0.6 "warm" and 0.3 "hot" simultaneously. This models how humans naturally reason with vague, imprecise concepts.
Fuzzy logic is widely used in control systems (washing machines, air conditioners, anti-lock brakes), decision support systems, and anywhere that human-like approximate reasoning is needed without exact mathematical models.
Fuzzy Sets and Membership Functions
Classical vs. Fuzzy Sets
Classical set "Tall People" (crisp boundary at 6 feet)
5'11" → NOT tall (membership = 0)
6'0" → tall (membership = 1)
Absurd! One inch shouldn't flip the classification entirely.
Fuzzy set "Tall People" (gradual transition)
5'6" → membership = 0.0 (definitely not tall)
5'9" → membership = 0.3 (slightly tall)
6'0" → membership = 0.7 (fairly tall)
6'3" → membership = 1.0 (definitely tall)
Common Membership Function Shapes
| Triangular | μ(x) = max(0, 1 - |x-center|/width) |
| Trapezoidal | Flat top (full membership range) + linear slopes |
| Gaussian | μ(x) = exp(-(x-center)²/(2σ²)) |
| Sigmoid | μ(x) = 1/(1 + exp(-a(x-c))) |
Example: Temperature Membership Functions
| COLD | Trapezoidal: full membership below 10°C, drops to 0 at 20°C |
| WARM | Triangular: peaks at 25°C, zero below 15°C and above 35°C |
| HOT | Sigmoid: starts at 28°C, full membership above 38°C |
Fuzzy Operations
Basic Fuzzy Set Operations
| Union (OR) | μ_A∪B(x) = max(μ_A(x), μ_B(x)) |
| Intersection (AND) | μ_A∩B(x) = min(μ_A(x), μ_B(x)) |
| Complement (NOT) | μ_A'(x) = 1 - μ_A(x) |
| Example | "warm AND humid" |
Fuzzy Inference System: Complete Walkthrough
Problem: Automatic Fan Speed Controller
| Inputs | Temperature (°C), Humidity (%) |
| Output | Fan Speed (RPM) |
| Temperature | {Cold, Warm, Hot} |
| Humidity | {Low, Medium, High} |
| Fan Speed | {Slow, Medium, Fast} |
Step 1: Fuzzification
Convert crisp inputs to fuzzy membership values:
Step 2: Rule Evaluation
Rule Base
R1: IF temp=warm AND humidity=medium THEN fan=medium
R2: IF temp=hot AND humidity=medium THEN fan=fast
R3: IF temp=hot AND humidity=high THEN fan=fast
R4: IF temp=warm AND humidity=high THEN fan=medium
Evaluate (using min for AND)
R1: min(μ_warm, μ_medium) = min(0.4, 0.5) = 0.4 → fan=medium (0.4)
R2: min(μ_hot, μ_medium) = min(0.6, 0.5) = 0.5 → fan=fast (0.5)
R3: min(μ_hot, μ_high) = min(0.6, 0.5) = 0.5 → fan=fast (0.5)
R4: min(μ_warm, μ_high) = min(0.4, 0.5) = 0.4 → fan=medium (0.4)
Step 3: Aggregation
Combine all rule outputs (using max for same consequent):
Step 4: Defuzzification (Centroid Method)
Convert fuzzy output back to crisp value:
Fuzzy Logic vs. Classical Logic
| Aspect | Classical Logic | Fuzzy Logic |
|---|---|---|
| Truth values | {0, 1} | [0, 1] continuous |
| Set membership | In or out | Degree of belonging |
| Boundaries | Sharp, crisp | Gradual, smooth |
| Reasoning | Exact | Approximate |
| Handles vagueness | No | Yes |
| Implementation | Simple | More complex |
Applications of Fuzzy Logic
Consumer Electronics
- Washing machines (load size → water level/cycle)
- Rice cookers (moisture sensing → heat control)
- Camera autofocus (fuzzy rules for focus adjustment)
Industrial Control
- Cement kiln temperature regulation
- Subway train operation (Sendai, Japan - 1987)
- Chemical process control
Automotive
- Anti-lock braking systems (ABS)
- Automatic transmission shifting
- Cruise control
Decision Support
- Credit risk assessment
- Medical diagnosis assistance
- Stock trading signals
Mamdani vs. Sugeno Fuzzy Systems
| Mamdani (classical) | Consequent is fuzzy set |
| Output | fuzzy set, needs defuzzification |
| Sugeno (modern) | Consequent is function of inputs |
| Output | weighted average of function outputs |
Interview Questions
Q: Why use fuzzy logic instead of probability theory? A: Fuzzy logic handles vagueness (imprecise concepts like "tall" or "hot"), while probability handles randomness (uncertain events). "John is tall" is vague (degree of tallness), not probabilistic (there's no random event). They address different types of uncertainty and can be combined.
Q: How do you design membership functions? A: Three approaches: (1) Expert knowledge—ask domain experts where categories overlap, (2) Data-driven—learn functions from training data using clustering, (3) Optimization—use genetic algorithms or gradient descent to tune parameters for best system performance.
Q: What is defuzzification and why is it needed? A: Defuzzification converts a fuzzy output set into a single crisp value for actuation. A motor needs one specific RPM, not a fuzzy set. Common methods: centroid (center of gravity), bisector, mean of maximum, or smallest/largest of maximum.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Fuzzy Logic - Approximate Reasoning.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Artificial Intelligence topic.
Search Terms
artificial-intelligence, artificial intelligence, artificial, intelligence, expert, systems, fuzzy, logic
Related Artificial Intelligence Topics