Skip to main content

Fuzzy operators: AND, OR, NOT

Boolean AND, OR and NOT only work on 0 and 1. Fuzzy logic needs versions that work on any degree in [0,1][0, 1]. There is no single correct choice. There is a whole family of operators that behave sensibly, and each family member has its own character.

T-norms (fuzzy AND)​

A t-norm T:[0,1]2→[0,1]T : [0,1]^2 \to [0,1] is any operator that is

  • commutative: T(a,b)=T(b,a)T(a, b) = T(b, a)
  • associative: T(a,T(b,c))=T(T(a,b),c)T(a, T(b, c)) = T(T(a, b), c)
  • monotone: if a≤a′a \le a' then T(a,b)≤T(a′,b)T(a, b) \le T(a', b)
  • has identity 1: T(a,1)=aT(a, 1) = a

Every t-norm agrees with Boolean AND on {0,1}\{0, 1\}, and every t-norm satisfies T(a,b)≤min⁡(a,b)T(a, b) \le \min(a, b). Minimum is the largest possible t-norm, and drastic product is the smallest.

Name (kind=)AliasesFormula T(a,b)T(a, b)
"min" (default)godel, zadeh, standardmin⁡(a,b)\min(a, b)
"product"prod, algebraica ba\,b
"lukasiewicz"luk, boundedmax⁡(0, a+b−1)\max(0,\ a + b - 1)
"drastic"bb if a=1a = 1; aa if b=1b = 1; else 00
"einstein"a b2−(a+b−a b)\dfrac{a\,b}{2 - (a + b - a\,b)}
"hamacher"a ba+b−a b\dfrac{a\,b}{a + b - a\,b} (0 when a=b=0a = b = 0)

T-conorms (fuzzy OR)​

A t-conorm SS has the same first three properties, but its identity is 0: S(a,0)=aS(a, 0) = a. Every t-conorm satisfies S(a,b)≥max⁡(a,b)S(a, b) \ge \max(a, b). Each t-norm has a dual t-conorm S(a,b)=1−T(1−a,1−b)S(a, b) = 1 - T(1 - a, 1 - b), and the table lists them in dual pairs.

Name (kind=)AliasesFormula S(a,b)S(a, b)
"max" (default)godel, zadeh, standardmax⁡(a,b)\max(a, b)
"probor"prob, probabilistic, algebraica+b−a ba + b - a\,b
"lukasiewicz"luk, boundedmin⁡(1, a+b)\min(1,\ a + b)
"drastic"bb if a=0a = 0; aa if b=0b = 0; else 11
"einstein"a+b1+a b\dfrac{a + b}{1 + a\,b}
"hamacher"a+b−2a b1−a b\dfrac{a + b - 2a\,b}{1 - a\,b} (1 when a=b=1a = b = 1)

Names are case-insensitive.

Complements (fuzzy NOT)​

Name (kind=)Parameter (param=)Formula c(μ)c(\mu)
"standard" (default)none1−μ1 - \mu
"sugeno"λ>−1\lambda > -11−μ1+λμ\dfrac{1 - \mu}{1 + \lambda\mu}
"yager"w>0w > 0(1−μw)1/w(1 - \mu^{w})^{1/w}

λ=0\lambda = 0 and w=1w = 1 both reduce to the standard complement.

A parameter outside its range, or an unknown kind name, raises ff.FuzzyError (a ValueError). Rule strings (IS NOT) always use the standard complement.

The same inputs, every operator​

For a=0.7a = 0.7 and b=0.4b = 0.4:

import ferrifuzz as ff

a, b = 0.7, 0.4
for kind in ["min", "product", "lukasiewicz", "drastic", "einstein", "hamacher"]:
print(f"T {kind:12s}", round(ff.Operator.t_norm(a, b, kind=kind), 4))
for kind in ["max", "probor", "lukasiewicz", "drastic", "einstein", "hamacher"]:
print(f"S {kind:12s}", round(ff.Operator.t_conorm(a, b, kind=kind), 4))

ff.Operator.complement(0.7) # 0.3
ff.Operator.complement(0.7, "sugeno", 2.0) # 0.125
ff.Operator.complement(0.7, "yager", 2.0) # 0.714...
OperatorT-norm (AND)T-conorm (OR)
min / max0.40.7
product / probor0.280.82
Łukasiewicz0.11.0
drastic0.01.0
Einstein0.23730.8594
Hamacher0.34150.75

Some intuition:

  • min / max are non-interactive. The result depends only on the weaker (or stronger) argument. They are idempotent (min⁡(a,a)=a\min(a,a)=a), and they are the classic Mamdani choice.
  • product / probor let both arguments matter. Two half-true conditions give 0.250.25, not 0.50.5. The output surface is smoother, and gradients are non-zero in both arguments.
  • Łukasiewicz and drastic are strict: two weak conditions can give exactly 0.
  • Einstein and Hamacher sit between product and min.

Operators on intervals​

For interval type-2 sets, a degree is an interval [μ‾,μ‾][\underline{\mu}, \overline{\mu}]. T-norms and t-conorms are monotone, so they apply bound by bound. The complement swaps the bounds so that lower ≤ upper still holds:

T([a‾,a‾],[b‾,b‾])=[T(a‾,b‾), T(a‾,b‾)]c([μ‾,μ‾])=[c(μ‾), c(μ‾)]T([\underline a, \overline a], [\underline b, \overline b]) = [T(\underline a, \underline b),\ T(\overline a, \overline b)] \qquad c([\underline\mu, \overline\mu]) = [c(\overline\mu),\ c(\underline\mu)]
ff.Operator.t_norm((0.6, 0.8), (0.5, 0.9), kind="product")   # (0.3, 0.72)
ff.Operator.complement((0.2, 0.6)) # (0.4, 0.8)

How inference uses them​

The antecedent of a rule is kept in disjunctive normal form, an OR of AND-groups:

IF a IS x AND b IS y OR c IS z THEN ...   →   (a IS x ∧ b IS y) ∨ (c IS z)

The firing strength is

w=S( T(μx(a),μy(b)), μz(c) )w = S\big(\, T(\mu_x(a), \mu_y(b)),\ \mu_z(c) \,\big)

with TT = the system's and_method and SS = its or_method:

system = ff.FuzzySystem(and_method="product", or_method="probor")

and_method accepts all six t-norm names and or_method all six t-conorm names. How the firing strength then shapes the output (implication and aggregation) is covered in Inference.

In ferrifuzz​