fuzzy_dl_owl2.fuzzydl.general_concept_inclusion
A Python class representing a fuzzy logic axiom that defines the inclusion of one concept within another to a specific degree of truth.
Description
The software models a graded subsumption relationship between two concepts within a fuzzy description logic framework, capturing the extent to which a sub-concept is included in a super-concept. It encapsulates a specific logic operator type, such as Łukasiewicz or Gödel, to determine the semantic implications of the relationship, while storing a degree value that serves as a lower bound for the truth of the inclusion. Designed as a mutable data structure, the implementation allows for the modification of the underlying concepts and the degree of truth after instantiation, facilitating dynamic updates to the logical axioms. To support integration into larger systems, the implementation provides mechanisms for structural equality comparison, hash-based ordering, and a human-readable string representation that visualizes the logical structure and associated truth value.
Classes
Represents a fuzzy logic axiom stating that one concept is included within another to a specific degree of truth. It defines a relationship between a subsumed concept and a subsumer concept, utilizing a specific logic operator type (such as Łukasiewicz or Gödel) to determine the implication semantics. Users can instantiate this class to define axioms, modify the degree or concepts via setter methods, and compare instances for equality or ordering. The object is mutable, allowing updates to the underlying concepts or the degree of inclusion after creation. |
Module Contents
UML Class Diagram for GeneralConceptInclusion
- class GeneralConceptInclusion(
- subsumer: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
- subsumed: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
- degree: fuzzy_dl_owl2.fuzzydl.degree.degree.Degree,
- type_: fuzzy_dl_owl2.fuzzydl.util.constants.LogicOperatorType,
Represents a fuzzy logic axiom stating that one concept is included within another to a specific degree of truth. It defines a relationship between a subsumed concept and a subsumer concept, utilizing a specific logic operator type (such as Łukasiewicz or Gödel) to determine the implication semantics. Users can instantiate this class to define axioms, modify the degree or concepts via setter methods, and compare instances for equality or ordering. The object is mutable, allowing updates to the underlying concepts or the degree of inclusion after creation.
- Parameters:
subsumer (Concept) – The general concept or super-category that encompasses the subsumed concept.
subsumed (Concept) – The concept that is included within the subsumer concept.
degree (Degree) – The lower bound truth value specifying the minimum extent to which the subsumed concept is included in the subsumer concept.
type (LogicOperatorType) – Specifies the fuzzy implication operator (e.g., Łukasiewicz, Gödel, Product) used to evaluate the truth of the inclusion.
- __eq__(other: Self) bool[source]
Determines structural equality between the current instance and another object by verifying that the other object is an instance of the same class and that all critical attributes are identical. The comparison specifically checks that the subsumed, subsumer, degree, and type attributes of both objects match exactly. If the other object is not a GeneralConceptInclusion or if any of these attributes differ, the method returns False.
- Parameters:
other (Self) – The object to compare for equality.
- Returns:
True if the other object is an instance of GeneralConceptInclusion and all attributes (subsumed, subsumer, degree, and type) are equal; otherwise, False.
- Return type:
bool
- __ge__(other: Self) bool[source]
Implements the greater-than-or-equal-to comparison operator for the instance. The method determines the result by negating the outcome of the less-than comparison (self < other), effectively checking if the current object is not strictly less than the other. This implementation relies entirely on the __lt__ method; any exceptions raised during the less-than comparison will be propagated, and if __lt__ returns NotImplemented, this method will return False rather than allowing the interpreter to try the reflected comparison.
- Parameters:
other (Self) – The object to compare against the current instance.
- Returns:
True if the object is greater than or equal to the other object, False otherwise.
- Return type:
bool
- __gt__(other: Self) bool[source]
Determines whether this instance is considered greater than another object by comparing their hash values. The method returns True if the provided argument is an instance of GeneralConceptInclusion and the hash of the current instance is strictly greater than the hash of the argument. If the argument is not an instance of the same class or if its hash value is equal to or less than the current instance’s hash, the method returns False.
- Parameters:
other (Self) – Another instance of the same class to compare against based on hash value.
- Returns:
True if other is an instance of GeneralConceptInclusion and the hash of the current object is greater than the hash of other; otherwise, False.
- Return type:
bool
- __hash__() int[source]
Returns the hash value of the object by calculating the hash of its string representation. This allows instances of this class to be used as dictionary keys or stored in sets. Because the hash is derived from the string output, any changes to the object’s state that affect its string representation will alter its hash, which may lead to unexpected behavior if the object is used in hash-based collections after modification.
- Returns:
An integer hash value computed from the string representation of the object.
- Return type:
int
- __le__(other: Self) bool[source]
Checks if the current instance is less than or equal to another instance by inverting the result of the greater-than comparison. This implementation relies on the __gt__ method to define the ordering relationship, returning True whenever the instance is not greater than the provided argument. The method performs no side effects and simply returns a boolean value based on the existing comparison logic.
- Parameters:
other (Self) – The object to compare against the current instance.
- Returns:
True if the instance is less than or equal to the other instance, False otherwise.
- Return type:
bool
- __lt__(other: Self) bool[source]
Determines whether the current instance is considered less than another object based on their hash values. The method first checks if the other argument is an instance of GeneralConceptInclusion; if the types do not match, it returns False. When both objects are of the same type, the comparison is performed by evaluating if the hash of the current instance is strictly less than the hash of the other instance. Note that because this relies on hash values, the ordering is arbitrary and may vary between Python runs, and distinct objects with identical hash values will not be strictly ordered relative to one another.
- Parameters:
other (Self) – The object to compare against.
- Returns:
True if other is an instance of GeneralConceptInclusion and the hash of the current instance is less than the hash of other; otherwise, False.
- Return type:
bool
- __ne__(other: Self) bool[source]
Checks for inequality between the current instance and another GeneralConceptInclusion object. The method returns True if the two instances are not considered equal, and False otherwise. This implementation relies on the __eq__ method, effectively returning the logical negation of the equality comparison. Consequently, any specific logic or edge cases handled by the equality operator are implicitly applied here in reverse.
- Parameters:
other (Self) – The object to compare against.
- Returns:
True if the object is not equal to the other object, False otherwise.
- Return type:
bool
- __repr__() str[source]
Returns a string representation of the concept inclusion by delegating to the __str__ method. Consequently, the output is identical to the informal string representation, prioritizing human readability over a machine-parseable format. This behavior ensures that the object appears consistently whether printed directly or inspected in a debugger.
- Returns:
Returns the string representation of the object.
- Return type:
str
- __str__() str[source]
Returns a human-readable string representation of the concept inclusion relationship, formatted to display the logical structure and its associated degree of truth. The representation concatenates the subsumed concept, the first character of the inclusion type’s name, the subsumer concept, and the degree value into a specific notation: “subsumed =>_{type} subsumer >= degree”. This method has no side effects, though it requires the internal attributes to be properly initialized to avoid errors during string interpolation.
- Returns:
A formatted string representing the subsumption relationship, displaying the subsumed item, the first letter of the type, the subsumer, and the degree.
- Return type:
str
- clone() Self[source]
Creates and returns a new instance of the class that replicates the state of the current object. The new object is initialized with the same subsumer, subsumed, degree, and type attributes as the original. This method performs a shallow copy of the attributes, meaning that if they are mutable objects, modifications to those objects in the clone will affect the original instance. The operation does not modify the state of the current object.
- Returns:
A new instance of the class with the same attribute values as the current object.
- Return type:
Self
- get_degree() fuzzy_dl_owl2.fuzzydl.degree.degree.Degree[source]
Returns the degree associated with this general concept inclusion. This method serves as an accessor to retrieve the internal attribute representing the weight, confidence, or specific metric of the inclusion relationship. It performs a read-only operation and does not alter the state of the object.
- Returns:
The Degree object associated with this instance.
- Return type:
- get_subsumed() fuzzy_dl_owl2.fuzzydl.concept.concept.Concept[source]
Returns the concept that is subsumed within this general concept inclusion axiom. In the context of the inclusion relationship, this represents the subclass or the left-hand side of the statement. The method acts as a simple accessor for the internal subsumed attribute and does not modify the state of the object or perform any computations.
- Returns:
The concept that is subsumed by this instance.
- Return type:
- get_subsumer() fuzzy_dl_owl2.fuzzydl.concept.concept.Concept[source]
Retrieves the super-concept, or subsumer, associated with this general concept inclusion. This represents the concept on the right-hand side of the inclusion relationship, effectively the broader category that the sub-concept falls under. The method acts as a simple accessor for the internal subsumer attribute and does not modify the object’s state.
- Returns:
The concept that subsumes the current object.
- Return type:
- get_type() fuzzy_dl_owl2.fuzzydl.util.constants.LogicOperatorType[source]
Retrieves the specific logic operator type associated with this general concept inclusion instance. This method acts as a getter for the internal type attribute, returning the classification of the logical operator without modifying the object’s state.
- Returns:
The logic operator type associated with this instance.
- Return type:
- set_degree(deg: fuzzy_dl_owl2.fuzzydl.degree.degree.Degree) None[source]
Assigns the specified degree value to the GeneralConceptInclusion instance, replacing any existing value stored in the degree attribute. This method acts as a direct setter for the internal state, accepting a Degree object as input. Since it performs a direct assignment without validation logic, callers should ensure that the provided deg argument is valid and appropriate for the context of the concept inclusion, as this mutation occurs in place and affects subsequent operations that rely on the degree property.
- Parameters:
deg (Degree) – The degree value to assign to the instance.
- set_subsumed(new_concept: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept) None[source]
Assigns the provided concept as the subsumed entity within this general concept inclusion relationship. This method directly overwrites the existing subsumed attribute with the new value, effectively updating the left-hand side of the inclusion statement. It performs no validation on the input type beyond the type hint, so passing an incompatible object may lead to errors in subsequent operations.
- Parameters:
new_concept (Concept) – The concept to assign to the subsumed attribute.
- set_subsumer(new_concept: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept) None[source]
Updates the super-concept, or subsumer, associated with this General Concept Inclusion. The method accepts a Concept instance which replaces the current value of the subsumer attribute. This operation directly mutates the object’s state, overwriting any previously defined subsumer without performing validation or checks on the new concept.
- Parameters:
new_concept (Concept) – The concept to assign as the subsumer.