fuzzy_dl_owl2.fuzzydl.primitive_concept_definition
A Python class representing a primitive concept definition within a fuzzy logic system, encapsulating the relationship between a named concept and its definition using specific implication operators and truth degrees.
Description
The software models a primitive concept definition as a specific type of general concept inclusion axiom used in fuzzy description logic. It establishes a logical rule where a named concept is defined by or implies a complex fuzzy concept description, utilizing a specific fuzzy implication operator such as Łukasiewicz or Gödel to determine the connection. A float value between 0 and 1 acts as a lower bound degree, representing the extent to which the definition satisfies the concept within the knowledge base. To manage these logical relationships efficiently, the implementation provides mechanisms for cloning instances and modifying the definition or degree through accessor methods. Structural equality and ordering are supported by overriding standard comparison operators, allowing instances to be compared based on their internal state and hash values. The design prioritizes performance by precomputing the first character of implication operator names to avoid expensive enum descriptor lookups during string generation. String representations are lazily constructed and cached upon first access to minimize overhead in scenarios requiring frequent textual output, such as debugging or serialization. The hash function relies on the structural components of the definition, ensuring that objects with identical logical properties produce the same hash code.
Attributes
Classes
This class represents a primitive concept definition within a fuzzy logic system, functioning as a specific type of general concept inclusion axiom. It encapsulates a rule where a named concept is defined by or implies a complex fuzzy concept description, utilizing a specific fuzzy implication operator (such as Łukasiewicz or Gödel) to determine the logical connection. The axiom includes a degree of truth, a float value between 0 and 1, which acts as a lower bound representing the extent to which the definition satisfies the concept. Users can construct instances to define these logical relationships, retrieve or modify the definition and degree via accessor methods, and leverage comparison and cloning utilities for managing axioms within a knowledge base. |
Module Contents
UML Class Diagram for PrimitiveConceptDefinition
- class PrimitiveConceptDefinition(
- defined: str,
- definition: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
- implication: fuzzy_dl_owl2.fuzzydl.util.constants.LogicOperatorType,
- degree: float,
This class represents a primitive concept definition within a fuzzy logic system, functioning as a specific type of general concept inclusion axiom. It encapsulates a rule where a named concept is defined by or implies a complex fuzzy concept description, utilizing a specific fuzzy implication operator (such as Łukasiewicz or Gödel) to determine the logical connection. The axiom includes a degree of truth, a float value between 0 and 1, which acts as a lower bound representing the extent to which the definition satisfies the concept. Users can construct instances to define these logical relationships, retrieve or modify the definition and degree via accessor methods, and leverage comparison and cloning utilities for managing axioms within a knowledge base.
- Parameters:
defined (str) – The name of the primitive concept being defined by this axiom.
definition (Concept) – The fuzzy concept expression that defines the primitive concept.
degree (float) – The lower bound of the axiom, representing the extent to which the primitive concept is satisfied by the definition.
implication (LogicOperatorType) – Specifies the fuzzy logic operator (e.g., Łukasiewicz, Gödel, Product) used to interpret the implication relationship within the axiom.
- __eq__(other: Self) bool
Determines whether the current instance is equal to another object by comparing their structural components. The method returns true only if the provided argument is an instance of the same class and if the defined, definition, degree, and implication attributes of both objects match exactly. If the other object is of a different type, the method returns false, and no side effects occur during the comparison.
- Parameters:
other (Self) – The object to compare against for equality.
- Returns:
True if the other object is an instance of PrimitiveConceptDefinition and all attributes (defined, definition, degree, implication) are equal, otherwise False.
- Return type:
bool
- __ge__(other: Self) bool
Determines whether the current instance is greater than or equal to another instance of the same type. This comparison is implemented by negating the result of the less-than operation, effectively delegating the logic to the __lt__ method. As a result, the specific ordering rules and handling of incompatible types are defined by the implementation of the less-than operator, and this method itself introduces no side effects.
- Parameters:
other (Self) – The object to compare against, which must be an instance of the same class.
- Returns:
True if the instance is greater than or equal to the other instance, False otherwise.
- Return type:
bool
- __gt__(other: Self) bool
Determines if the current instance is greater than the provided object by comparing their hash values. This method strictly enforces type compatibility, returning False if the other object is not an instance of PrimitiveConceptDefinition rather than raising a TypeError. The comparison logic relies solely on the result of the built-in hash function, meaning the ordering is determined by the integer hash values of the instances.
- Parameters:
other (Self) – The object to compare against the current instance based on hash values.
- Returns:
True if other is an instance of PrimitiveConceptDefinition and the hash of the current instance is greater than the hash of other; otherwise, False.
- Return type:
bool
- __hash__() int
Return a hash value for this object, computed from its string representation. This approach ensures that the hash value reflects the structural identity of the object without relying on cached values or additional methods. The hash is derived from the output of the __str__ method, which provides a consistent and unique representation of the concept’s structure. This implementation does not utilize any internal caching mechanism and directly computes the hash each time it is called.
- Returns:
An integer hash value representing the structural identity of this object.
- Return type:
int
- __le__(other: Self) bool
Determines whether the current instance is less than or equal to another instance of the same type. The implementation delegates to the greater-than comparison operator, returning True if self is not greater than other. Consequently, the behavior and validity of this comparison depend entirely on the implementation of the __gt__ method, and any exceptions raised by that method will be propagated.
- Parameters:
other (Self) – The object to compare against the current instance.
- Returns:
True if the object is less than or equal to the other object, otherwise False.
- Return type:
bool
- __lt__(other: Self) bool
Determines whether the current instance is considered less than the provided object by comparing their hash values. The method returns True only if the other argument is an instance of PrimitiveConceptDefinition and the hash of the current instance is strictly less than the hash of the other instance. If other is not an instance of this class, or if the hash of the current instance is greater than or equal to that of other, the method returns False.
- Parameters:
other (Self) – The object to compare against, expected to be an instance of the same class.
- Returns:
True if the other object is an instance of PrimitiveConceptDefinition and the hash of this instance is less than the hash of the other object; otherwise, False.
- Return type:
bool
- __ne__(other: Self) bool
Determines whether the current instance is not equal to another object of the same type. This method implements the inequality operator by returning the logical negation of the equality comparison, effectively delegating the specific logic to the __eq__ method. It performs no side effects or state mutations, and its behavior regarding type compatibility depends entirely on the implementation of the equality check.
- Parameters:
other (Self) – The instance to compare against for inequality.
- Returns:
True if the current instance is not equal to the other object, False otherwise.
- Return type:
bool
- __repr__() str
Returns the official string representation of the PrimitiveConceptDefinition instance. This method delegates directly to the __str__ method, meaning the output is identical to the informal string representation. As a result, the representation provided is primarily intended for display and debugging, relying on the formatting logic defined within the string conversion implementation.
- Returns:
The string representation of the object.
- Return type:
str
- __str__() str
Returns a human-readable string representation of the primitive concept definition, formatted to display the logical relationship between the defined concept and its definition. The representation includes the defined concept, the first character of the implication relation’s name, the definition text, and the associated degree, structured as Defined =>_Implication Definition >= Degree. This method is side-effect free, though it assumes the implication name is not empty to prevent index errors during string formatting.
- Returns:
A human-readable string representation of the object, displaying its defined status, implication name, definition, and degree.
- Return type:
str
- clone() Self
Creates and returns a new instance of PrimitiveConceptDefinition that is a distinct copy of the current object. The new instance is initialized with the exact same values for the defined, definition, implication, and degree attributes as the original. This operation does not modify the state of the original object, allowing the clone to be manipulated independently.
- Returns:
A new instance of the class with identical attribute values to the current instance.
- Return type:
Self
- get_defined_concept() str
Retrieves the specific concept string associated with this definition instance. This method acts as a direct accessor for the internal defined attribute, returning the stored value without performing any validation or transformation. It does not modify the state of the object.
- Returns:
The defined concept associated with the object.
- Return type:
str
- get_definition() fuzzy_dl_owl2.fuzzydl.concept.concept.Concept
Returns the Concept object that defines this primitive concept instance. This method provides access to the internal definition attribute, allowing callers to retrieve the specific concept associated with this definition wrapper. It is a read-only operation with no side effects on the instance itself, though the returned Concept object may be mutable depending on its implementation.
- Returns:
The definition of the object, represented as a Concept.
- Return type:
- get_degree() float
Returns the floating-point value representing the degree associated with this definition. This method serves as a simple accessor for the internal degree attribute, providing the current numeric value without altering the object’s state. It relies on the attribute being initialized prior to invocation to ensure a valid float is returned.
- Returns:
The degree value associated with the object.
- Return type:
float
- get_type() fuzzy_dl_owl2.fuzzydl.util.constants.LogicOperatorType
Retrieves the specific logical operator type associated with this primitive concept definition. This method returns the value stored in the implication attribute, which represents the underlying logical classification or relationship. The operation is read-only and does not modify the state of the object.
- Returns:
Returns the specific logic operator type associated with the instance.
- Return type:
- set_definition(definition: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept) None
Assigns the provided Concept object to the definition attribute of the instance, thereby updating the core data held by the PrimitiveConceptDefinition. This method mutates the object’s state by replacing any existing reference with the new value. It returns None as the operation is performed in place.
- Parameters:
definition (Concept) – The Concept instance to assign as the definition.
- set_degree(deg: float) None
Assigns the specified floating-point value to the degree attribute of the primitive concept definition. This method updates the internal state of the instance by overwriting the existing degree property with the new value provided in the deg argument. It performs no return operation and directly modifies the object in place.
- Parameters:
deg (float) – The new degree value.
- _name: str | None = None
- defined: str
- definition: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept
- degree: float
- _IMPL_CHAR: Dict[fuzzy_dl_owl2.fuzzydl.util.constants.LogicOperatorType, str]