fuzzy_dl_owl2.fuzzydl.concept.has_value_concept
Defines a fuzzy logic concept representing an existential restriction where an entity must have a specific value for a given role.
Description
Models a specific type of existential restriction, often termed a “has-value” concept, which asserts that an individual must be related to a specific value through a defined role. Structurally, it represents the logical form (b-some r v), meaning an entity satisfies this concept if it participates in the relationship r with a target entity that corresponds to v. Instantiation requires a string representing the role and a target value of arbitrary type, after which the object automatically derives a canonical name for identification. Composition with other logical constructs is supported through operator overloading for conjunction, disjunction, and negation, while the architecture explicitly prevents the replacement of internal components to maintain atomic integrity. Identity comparisons rely on a hashing mechanism that combines the concept type, role, and value to ensure consistency within the broader system.
Classes
This class models a specific type of existential restriction, often referred to as a "has-value" concept, which asserts that an individual must be related to a specific value through a defined role. Structurally, it represents the logical form (b-some r v), meaning an entity satisfies this concept if it participates in the relationship r with a target entity that corresponds to v. To utilize this class, instantiate it by providing a string representing the role and the target value, which can be of various types such as strings or numbers. Once created, the concept can be combined with other concepts using standard logical operators like conjunction, disjunction, and negation, and it automatically generates a standardized string representation for identification. Note that attempting to replace sub-concepts within this specific concept type will result in an error, as it is treated as an atomic unit in that context. |
Module Contents
UML Class Diagram for HasValueConcept
- class HasValueConcept(role: str, value: Any)
Bases:
fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,fuzzy_dl_owl2.fuzzydl.concept.interface.has_value_interface.HasValueInterface
This class models a specific type of existential restriction, often referred to as a “has-value” concept, which asserts that an individual must be related to a specific value through a defined role. Structurally, it represents the logical form (b-some r v), meaning an entity satisfies this concept if it participates in the relationship r with a target entity that corresponds to v. To utilize this class, instantiate it by providing a string representing the role and the target value, which can be of various types such as strings or numbers. Once created, the concept can be combined with other concepts using standard logical operators like conjunction, disjunction, and negation, and it automatically generates a standardized string representation for identification. Note that attempting to replace sub-concepts within this specific concept type will result in an error, as it is treated as an atomic unit in that context.
- Parameters:
name (str) – String representation of the concept in the format (b-some role value).
- __and__(value: Self) Self
Performs a bitwise AND operation between the current instance and another value of the same type, enabling the use of the & operator. The logic is delegated to OperatorConcept.and_, which constructs and returns a new instance representing the conjunction of the two operands. This method generally does not modify the original instances, but may raise an error if the provided value is not a compatible type.
- Parameters:
value (Self) – The other operand to combine with the current instance using the AND operation.
- Returns:
The result of the AND operation between the current instance and the provided value.
- Return type:
Self
- __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
- __neg__() fuzzy_dl_owl2.fuzzydl.concept.concept.Concept
Overloads the unary minus operator to provide the logical negation of the current concept. This method returns a new Concept instance representing the inverse condition of the original object, effectively wrapping it in a logical ‘NOT’ operation by delegating to OperatorConcept.not_. The operation is side-effect free, leaving the original instance unmodified.
- Returns:
The logical negation of this concept.
- Return type:
- __or__(value: Self) Self
Performs a logical OR operation between the current concept and another value using the bitwise OR operator (|). This method delegates the logic to OperatorConcept.or_, constructing and returning a new instance that represents the combination of the two operands. It allows for the chaining or composition of concepts without modifying the original objects.
- Parameters:
value (Self) – The right-hand operand for the OR operation, which must be an instance of the same class.
- Returns:
A new instance representing the logical OR of the current object and the provided value.
- Return type:
Self
- clone() Self
Creates and returns a new instance of the class that is a deep copy of the current object. The new instance preserves the role attribute from the original, while the value attribute is recursively copied using copy.deepcopy to ensure that modifications to the new object’s value do not affect the original. This method is useful for creating independent duplicates of the concept without altering the source data, though it may raise an exception if the value contains objects that cannot be deep-copied.
- Returns:
A new instance of the class with the same role and a deep copy of the value.
- Return type:
Self
- compute_atomic_concepts() set[fuzzy_dl_owl2.fuzzydl.concept.concept.Concept]
Returns an empty set, as a HasValueConcept does not decompose into or reference any atomic named concepts. Unlike complex class expressions that might be unions or intersections of other classes, a HasValue restriction is defined solely by a property and a specific filler value, meaning there are no atomic concepts to extract. This method has no side effects and consistently returns an empty set regardless of the internal state of the concept.
- Returns:
A set of atomic concepts computed by the object.
- Return type:
set[Concept]
- compute_name() str | None
Constructs a string identifier for the concept by interpolating its role and value attributes into a specific parenthetical format. The output follows the pattern ‘(b-some role value)’, serving as a computed name for the entity. This method does not modify the object’s state and assumes that the role and value attributes are available for string formatting.
- Returns:
A string representing the computed name, formatted as “(b-some {role} {value})”.
- Return type:
Optional[str]
- get_roles() set[str]
Retrieves the set of roles associated with the current concept. This default implementation returns an empty set, signifying that no roles are inherently defined for this base concept. The method is designed to be overridden by subclasses to return specific role identifiers as strings, allowing for the extension of functionality within the broader module hierarchy. Because a new set instance is created on every invocation, the operation has no side effects on the object’s state.
- Returns:
A set of strings representing the roles assigned to the object.
- Return type:
set[str]
- static has_value(role: str, i: Any) Self
Creates and returns a new instance of the HasValueConcept class, associating a specific value with a defined role. This static method acts as a factory function, allowing for the instantiation of the concept using a role identifier and an arbitrary value of any type. Since the method simply delegates to the class constructor, it has no side effects and relies on the underlying class implementation for any input validation or processing.
- Parameters:
role (str) – A string identifying the role or name of the value.
i (Any) – The value to be associated with the specified role.
- Returns:
An instance of HasValueConcept initialized with the provided role and value.
- Return type:
Self
- replace( ) fuzzy_dl_owl2.fuzzydl.concept.concept.Concept
This method attempts to replace a specified concept a with another concept c within the current object’s structure. However, this functionality is not supported for HasValueConcept instances; invoking it results in an error being reported and the method returning None rather than performing a substitution.
- name: str