Modifiers and Degrees
Two small but pervasive object families: modifiers, which reshape the membership function of a concept (the fuzzy hedges such as very), and degrees, which carry the truth value attached to an axiom. For the FDL syntax that produces them see Grammatics; this page describes the runtime classes.
Modifiers
A modifier is a function on the unit interval that transforms a membership
degree. They are declared in FDL with define-modifier and applied either to a
concept ((very High)) or inside a modified concrete concept
((define-fuzzy-concept VeryHigh modified(very, High))).
Class hierarchy
All modifiers derive from the abstract base
fuzzy_dl_owl2.fuzzydl.modifier.modifier.Modifier, which fixes the contract:
Member |
Purpose |
|---|---|
|
Canonical string name of the modifier instance. |
|
A copy of the modifier. |
|
Wrap a |
|
Apply the modifier’s transform to a single membership value, clamped to |
There are two concrete modifiers:
LinearModifier
(define-modifier very linear-modifier(0.8))
Constructed as LinearModifier(name, c) with a single parameter c > 0. The
parameter fixes the inflection point of a piecewise-linear transform; internally
the class derives an (a, b) break-point pair from c. modify produces a
LinearlyModifiedConcept. Membership is clamped to [0, 1].
TriangularModifier
(define-modifier around triangular-modifier(0.2, 0.5, 0.8))
Constructed as TriangularModifier(name, a, b, c) — the three break-points of a
triangular transform (leftmost a, peak b, rightmost c). modify produces
a TriangularlyModifiedConcept.
How the parser wires them
DLParser._parse_modifier reads the define-modifier form, instantiates
LinearModifier(name, c) or TriangularModifier(name, a, b, c) from the
keyword, and registers it with DLParser.kb.add_modifier(name, modifier). The
modifier is then available by name anywhere a modifier is expected.
The modified concepts these produce (
LinearlyModifiedConcept,TriangularlyModifiedConcept,ModifiedConcreteConcept) are documented in Fuzzy Concepts.
Degrees
A degree is the truth value on the right-hand side of an axiom — the optional
trailing value in (instance a C 0.8), (related a b R 0.8),
(implies C D 0.7), and so on. When the value is omitted it defaults to 1
(crisp).
Class hierarchy
All degrees derive from the abstract base
fuzzy_dl_owl2.fuzzydl.degree.degree.Degree. The base provides a get_degree
factory and the operations the MILP layer needs to fold a degree into a
constraint:
Member |
Purpose |
|---|---|
|
Factory: build the right |
|
Whether the degree is a constant. |
|
A copy of the degree. |
|
Build the MILP inequality that has this degree on the right-hand side. |
|
Combine the degree into a MILP |
|
Quick constant checks used during normalisation. |
Three concrete degrees:
Class |
FDL form |
Carries |
|---|---|---|
|
a literal, e.g. |
a constant |
|
a variable name |
a MILP |
|
a linear expression |
a MILP |
How the parser wires them
DLParser._parse_degree chooses the subclass from the token type:
a number ->
DegreeNumeric.get_degree(float(...));an
Expression->DegreeExpression.get_degree(...);a name -> first checked against the KB’s truth constants (
define-truth-constant); if it matches, aDegreeNumericwith that constant is used, otherwise the name is treated as a variable and aDegreeVariableis built.
This is why a degree slot accepts a literal, a previously defined truth constant, a free variable, or a linear expression interchangeably.
Truth constants
(define-truth-constant V 0.53) registers a named constant on the knowledge
base. Wherever V later appears as a degree, the parser resolves it to a
DegreeNumeric holding 0.53 — constants are folded at parse time, not kept as
variables.
See also
Grammatics — FDL syntax for
define-modifier,define-truth-constant, and the degree slot of each axiom.Fuzzy Concepts — the modified-concept classes produced by
modify.Architecture — how degrees become MILP constraints.