Skip to content
Tutorials Center
My learning

Topics

Lesson 14 of 36 ยท Fuzzy Inference

Fuzzy IF-THEN Rules

Learn how fuzzy IF-THEN rules are built, how firing strength is computed with AND, OR and NOT, what a rule base and FAM table are, and how implication clips or scales the output.

Rules are where an expert's knowledge enters a fuzzy system. They look like sentences, IF the room is cold THEN the heater is high, but each part has a precise computational meaning. This lesson takes a rule apart: the antecedent (condition), the consequent (conclusion), the firing strength, and the implication step that turns a strength into an output shape. It also explains how rule bases grow and how to check that they are complete.

The vocabulary comes from Linguistic Variables and Hedges, and the operators from T-norms and S-norms.

Anatomy of a rule

TEXT
IF  temperature is cold  AND  humidity is high   THEN  heater is high
    \__________________________________________/       \____________/
                    antecedent                           consequent
  • The antecedent (also premise or condition) is made of one or more propositions of the form variable is term. They are combined with AND, OR and NOT. Hedges are allowed: temperature is very cold.
  • The consequent (also conclusion) is one or more propositions about output variables: heater is high.
  • The firing strength (also degree of fulfillment or rule activation) is the single number between 0 and 1 that says how true the antecedent is for the current input.

So evaluating a rule has two steps: first compute the firing strength from the inputs, then use it to shape the consequent (the implication step).

Step 1: the firing strength

Each proposition is evaluated by reading a membership degree. Then the connectives combine the degrees with the chosen operators: AND with a t-norm (usually min), OR with an s-norm (usually max), NOT with 1 - x.

Python Evaluating the antecedent of a rule

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

At 14 degrees and 70 % humidity the temperature is cold to degree 0.22 and warm to 0.4; the humidity is high to degree 0.5. So the first rule fires with strength min(0.22, 0.5) = 0.22. A strength of 0 means the rule does not apply at all, and a strength of 1 means it applies completely. Most real inputs activate several rules partially at once.

Step 2: implication

Now the consequent must be shaped by the strength. The consequent is a fuzzy set (like "heater is high"), and the implication operator decides how the firing strength w modifies it. The two classic choices:

  • Mamdani (min) implication clips the consequent: min(w, mu_high(y)). The top is cut off flat at height w.
  • Larsen (product) implication scales the consequent: w * mu_high(y). The shape is kept but shrunk.

Both give a set that is "as true as the rule allows" and equal the full consequent when w = 1, and the empty set when w = 0.

Python Clipping versus scaling a consequent

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Scaling keeps the shape of the consequent, which can matter in the defuzzification step; clipping is simpler and is the default. Other implications (Lukasiewicz, Kleene-Dienes) come from formal logic and are mostly of theoretical interest: in logic, A -> B is true when A is false, which would make an unfired rule claim "everything is possible". Fuzzy control therefore uses the "and-like" Mamdani/Larsen style.

The rule base

A rule base is the set of all rules, and the system fires all of them in parallel, combining their results. A few principles help to keep it healthy:

  • Completeness. Every input combination should fire at least one rule. With evenly overlapping terms this is automatic when the rule base has one rule per combination.
  • Consistency. Do not give two rules the same antecedent with contradictory consequents (IF cold THEN heater high and IF cold THEN heater low).
  • Size. For k inputs with n terms each, a complete grid needs n^k rules: 5 terms and 3 inputs already means 125 rules. Keep the number of inputs small, group inputs, or use hierarchical systems.

For two inputs the complete rule base fits in a FAM table (fuzzy associative memory): rows for one input's terms, columns for the other's, cells for the output term.

humidity low humidity medium humidity high
cold medium high high
warm low medium high
hot off low medium

The table has 9 cells and therefore 9 rules. Empty cells are easy to spot, which is the main benefit of this notation.

Python Rules as data and a completeness check

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

For a combination with no rule (hot and high here), the system produces no output when only that cell is active. Tools should warn about gaps, as this script does.

Weights, hedges and more outputs

Real rule bases add small refinements:

  • A rule weight between 0 and 1 multiplies the firing strength, letting you mark a rule as less important.
  • Hedges in antecedents (temperature is very hot).
  • Several consequents: THEN heater is high AND fan is low is just two rules sharing an antecedent.
  • Default rules: a rule such as IF no other rule is active THEN output is neutral.
flowchart LR
    I["Inputs"] --> P["Propositions<br/>read memberships"]
    P --> A["AND / OR / NOT<br/>firing strength w"]
    A --> M["Implication<br/>clip or scale consequent"]
    M --> O["Output fuzzy set<br/>of this rule"]

One rule: from inputs to a shaped output set.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. In IF temperature is cold AND humidity is high THEN heater is high, what is the antecedent?

    The antecedent is the condition between IF and THEN; the part after THEN is the consequent.
  2. 2. Cold has degree 0.22 and humid has degree 0.5. What is the firing strength of cold AND humid with the min t-norm?

    min(0.22, 0.5) = 0.22.
  3. 3. How does Larsen (product) implication differ from Mamdani (min) implication?

    Product implication multiplies the consequent by the strength, keeping its shape; min implication cuts it off at that height.
  4. 4. A system has 4 inputs with 5 terms each. How many rules does a complete grid rule base need?

    5 ** 4 = 625. The count grows exponentially with the number of inputs.
  5. 5. What should happen to a rule whose firing strength is 0?

    A strength of 0 turns the consequent into the empty set, so the rule has no influence.

Summary

  • A rule has an antecedent (propositions joined by AND/OR/NOT) and a consequent.
  • The firing strength is computed from membership degrees with t-norms, s-norms and complement.
  • Implication shapes the consequent: min clips it (Mamdani), product scales it (Larsen).
  • Rule bases should be complete and consistent; sizes grow as n^k, so keep inputs few.
  • FAM tables show a two-input rule base at a glance and reveal missing cells.

Next: Fuzzification