fuzzy_dl_owl2.fuzzydl.concept.negated_nominal
Implements a representation for the logical complement of a named individual in fuzzy description logic.
Description
The software models the logical complement of a named individual within a fuzzy description logic system, allowing the expression of constraints that exclude specific entities from a domain. By inheriting from the base Concept class, it establishes itself as an atomic type that encapsulates an individual identifier and automatically generates a standardized string representation for the negated form. Logical operations such as conjunction and disjunction are supported through delegation to an external operator handler, enabling the construction of complex concept expressions. A strict design constraint is enforced to prevent nested negation, ensuring that attempting to complement an already negated nominal results in a specific exception to maintain logical consistency. Functionality for object cloning and hashing is provided to facilitate the use of these concepts within data structures and algorithms requiring object identity management.
Classes
This class models a negated nominal concept within the framework of fuzzy description logic, specifically representing the complement of a named individual. It is designed to express constraints that exclude specific individuals from a domain, often utilized in range restrictions. To use it, instantiate the object with the name of the individual to be negated; the class automatically generates a standardized string representation for this exclusion. While it supports logical operations like conjunction and disjunction, it enforces a strict limitation where further negation is prohibited, raising an exception if such an operation is attempted. |
Module Contents
UML Class Diagram for NegatedNominal
- class NegatedNominal(ind_name: str)[source]
Bases:
fuzzy_dl_owl2.fuzzydl.concept.concept.Concept
This class models a negated nominal concept within the framework of fuzzy description logic, specifically representing the complement of a named individual. It is designed to express constraints that exclude specific individuals from a domain, often utilized in range restrictions. To use it, instantiate the object with the name of the individual to be negated; the class automatically generates a standardized string representation for this exclusion. While it supports logical operations like conjunction and disjunction, it enforces a strict limitation where further negation is prohibited, raising an exception if such an operation is attempted.
- Parameters:
_ind_name (str) – Internal storage for the identifier of the individual being negated, serving as the backing field for the public property.
name (str) – The canonical string representation of the negated nominal, formatted as “(not { ind_name } )”.
- Raises:
FuzzyOntologyException – Raised when attempting to apply the negation operator to a NegatedNominal instance, as nested negation of nominals is not supported in fuzzy description logic.
- __and__(value: Self) Self[source]
Implements the bitwise AND operation (&) for the NegatedNominal class, enabling logical conjunction between two instances. This method accepts another NegatedNominal object as the right-hand operand and delegates the actual computation to the OperatorConcept.and_ static method. The operation returns a new instance of NegatedNominal representing the result of the conjunction, ensuring type consistency with the operands.
- Parameters:
value (Self) – The other operand to perform the AND operation with, expected to be of the same type as the current instance.
- Returns:
The result of the logical AND operation between this instance and the provided value.
- Return type:
Self
- __hash__() int[source]
Returns an integer hash value for the object, allowing instances to be used as dictionary keys or elements in sets. The hash is calculated by passing the string representation of the instance to the built-in hash function. This means the hash value is strictly dependent on the output of the object’s string conversion method, and any exceptions raised during that conversion will propagate to the caller.
- Returns:
An integer hash value computed from the string representation of the object.
- Return type:
int
- __neg__() Self[source]
Implements the unary negation operation for the nominal. However, since the instance already represents a negated concept, applying a further complement is not permitted by the underlying logic. Consequently, this method always raises a FuzzyOntologyException to enforce the constraint that negated nominals cannot be complemented.
- Raises:
FuzzyOntologyException – Raised when attempting to negate a negated nominal, as negated nominals cannot be complemented.
- Returns:
Raises FuzzyOntologyException indicating that negated nominals cannot be complemented.
- Return type:
Self
- __or__(value: Self) Self[source]
Implements the bitwise OR operator (|) to combine the current instance with another NegatedNominal object. This method delegates the combination logic to OperatorConcept.or_, returning a new instance that represents the union or logical disjunction of the two operands. The operation is side-effect free, as it generates a new object rather than modifying the existing instances.
- Parameters:
value (Self) – The right-hand operand for the OR operation.
- Returns:
Returns the result of the OR operation between this instance and the provided value.
- Return type:
Self
- clone() Self[source]
Creates and returns a new instance of NegatedNominal that is a copy of the current object. The new instance is initialized with the same ind_name attribute as the original, ensuring logical equivalence while maintaining object identity separation. This method does not modify the existing instance or have any side effects on the original object’s state.
- Returns:
A new instance of NegatedNominal initialized with the same individual name as the current object.
- Return type:
Self
- compute_name() str | None[source]
Retrieves the name associated with the NegatedNominal instance. This method returns the value of the name attribute, which may be a string or None if no name has been assigned. It serves as a direct accessor without performing additional computation or modification of the instance state.
- Returns:
The name associated with the instance, or None if it is not set.
- Return type:
str | None
- _ind_name: str
- property ind_name: str
Sets the value of the ind_name property for the NegatedNominal instance. This method accepts a string argument and updates the underlying private attribute _ind_name, thereby modifying the object’s state. It serves as the public interface for mutating the instance’s name, overwriting any existing value without performing validation on the input type or content.
- Parameters:
value (str) – The string value to assign to the ind_name attribute.
- name: str
Updates the name of the Concept instance to the specified string value. This setter modifies the object’s internal state by assigning the provided value to the private _name attribute, effectively replacing any previously stored name.
- Parameters:
value (str) – The new name to assign to the object.