fuzzy_dl_owl2.fuzzydl.concept.approximation_concept

A class that models logical constructs constraining individuals based on related entity properties through specific roles within a fuzzy description logic framework.

Description

The software implements a mechanism for defining logical constraints that quantify over related entities using specific roles, supporting various approximation strategies such as lower, upper, tight, and loose variants. By employing static factory methods for instantiation, it ensures that specific approximation types are created correctly without exposing the underlying constructor logic directly. This design allows for the representation of complex description logic constructs where individuals must satisfy conditions based on the properties of their neighbors, effectively bridging the gap between high-level approximation logic and standard quantifier representations. Internally, the logic handles the transformation of these specialized approximations into standard universal and existential quantifiers, facilitating seamless integration with other components of the system. It supports logical operations such as negation by inverting the approximation type and recursively applying negation to the underlying concept, while conjunction and disjunction are delegated to a dedicated operator handler. Furthermore, the implementation includes capabilities for structural manipulation, such as replacing sub-concepts and generating unique string identifiers, which are essential for maintaining consistency across the concept hierarchy and enabling efficient hashing and comparison.

Attributes

LooseLowerApprox

LooseUpperApprox

LowerApprox

TightLowerApprox

TightUpperApprox

UpperApprox

Classes

ApproximationConcept

This class models logical constructs that constrain individuals based on the properties of their related entities through a specific role, effectively representing various forms of quantification within a description logic framework. It encapsulates lower approximations (universal quantification), upper approximations (existential quantification), and their tight or loose nested variants, which define conditions such as "all related individuals must satisfy C" or "there exists a related individual satisfying C." Instead of direct instantiation, users should utilize the provided static factory methods—such as lower_approx or upper_approx—to construct these concepts by specifying a role name and a target concept. The class provides functionality to transform these approximations into standard "all" and "some" quantifier structures, supports logical negation by inverting the approximation type, and integrates seamlessly with the broader concept hierarchy for operations like conjunction, disjunction, and string representation.

Module Contents

UML Class Diagram for ApproximationConcept

UML Class Diagram for ApproximationConcept

class ApproximationConcept(
c_type: fuzzy_dl_owl2.fuzzydl.util.constants.ConceptType,
role: str,
c: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
)

Bases: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept, fuzzy_dl_owl2.fuzzydl.concept.interface.has_role_concept_interface.HasRoleConceptInterface

Inheritance diagram of fuzzy_dl_owl2.fuzzydl.concept.approximation_concept.ApproximationConcept

This class models logical constructs that constrain individuals based on the properties of their related entities through a specific role, effectively representing various forms of quantification within a description logic framework. It encapsulates lower approximations (universal quantification), upper approximations (existential quantification), and their tight or loose nested variants, which define conditions such as “all related individuals must satisfy C” or “there exists a related individual satisfying C.” Instead of direct instantiation, users should utilize the provided static factory methods—such as lower_approx or upper_approx—to construct these concepts by specifying a role name and a target concept. The class provides functionality to transform these approximations into standard “all” and “some” quantifier structures, supports logical negation by inverting the approximation type, and integrates seamlessly with the broader concept hierarchy for operations like conjunction, disjunction, and string representation.

Parameters:
Raises:

ValueError – Raised when the provided concept type is not one of the valid approximation types (LOWER_APPROX, TIGHT_LOWER_APPROX, LOOSE_LOWER_APPROX, UPPER_APPROX, TIGHT_UPPER_APPROX, or LOOSE_UPPER_APPROX).

__and__(value: Self) Self

Implements the bitwise AND operation (&) for the approximation concept, combining the current instance with another instance of the same type. This method delegates the core logic to OperatorConcept.and_, which handles the specific rules for calculating the conjunction or intersection of the two values. The operation returns a new instance of ApproximationConcept representing the result, leaving the original operands unmodified.

Parameters:

value (Self) – The other instance to perform the AND operation with.

Returns:

The result of the logical AND operation between this 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

Returns a new ApproximationConcept representing the negation of the current instance. This operation creates a new object where the approximation type is inverted using the INVERSE_APPROXIMATION mapping, the role remains unchanged, and the underlying curr_concept is negated. The method does not modify the original object in place, but it assumes the current type exists in the inversion mapping and that curr_concept supports the unary minus operation.

Returns:

Returns a new Concept representing the negation of the current concept, inverting both the approximation type and the underlying value.

Return type:

Concept

__or__(value: Self) Self

Implements the bitwise OR operator (|) to combine the current approximation concept with another value of the same type. This method delegates the logic to the OperatorConcept.or_ static method, which performs the specific calculation required to merge the two concepts. It returns a new instance representing the result of the operation, ensuring that the original objects remain unmodified.

Parameters:

value (Self) – The right-hand operand for the OR operation.

Returns:

Returns a new instance representing the logical OR of this concept and the provided value.

Return type:

Self

clone() Self

Creates and returns a new instance of ApproximationConcept that duplicates the state of the current object. The clone is initialized with the same type, role, and curr_concept values as the original. This method does not modify the original object or its attributes.

Returns:

A new instance of the class that is a copy of the current object, initialized with the same type, role, and current concept.

Return type:

Self

compute_atomic_concepts() set[fuzzy_dl_owl2.fuzzydl.concept.concept.Concept]

Calculates the set of atomic concepts derived from the underlying concept stored in curr_concept. The method acts as a wrapper, forwarding the request directly to the compute_atomic_concepts method of the curr_concept attribute and returning the resulting set. It assumes that curr_concept is properly initialized and implements the corresponding computation logic.

Returns:

A set of atomic concepts representing the base-level constituents of the current concept.

Return type:

set[Concept]

compute_name() str | None

Generates a standardized string identifier for the approximation concept based on its type, role, and current concept value. The method maps the internal concept type to a specific abbreviation—such as ‘la’ for lower approximation or ‘ua’ for upper approximation—and formats these components into a parenthesized string. If the concept type is not recognized among the defined approximation categories, the method raises a ValueError.

Raises:

ValueError – Raised when self.type does not correspond to a recognized or supported concept type.

Returns:

A string representing the concept name in the format ‘(type_abbreviation role curr_concept)’.

Return type:

Optional[str]

get_roles() set[str]

Retrieves a comprehensive set of role identifiers associated with the current object and its underlying concept. This method aggregates the specific role defined on the instance with the roles returned by the curr_concept object’s get_roles method, performing a set union to ensure uniqueness. The operation is read-only and does not modify the state of the object or its dependencies.

Returns:

A set of strings representing the union of the object’s role and the roles associated with the current concept.

Return type:

set[str]

static loose_lower_approx(role: str, c: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept) Self

Constructs a new instance of ApproximationConcept representing a loose lower approximation of a given concept. This static factory method accepts a string defining the role and a Concept object, initializing the new entity with the specific type identifier LOOSE_LOWER_APPROX. The method delegates directly to the class constructor, meaning any exceptions raised during instantiation will propagate to the caller, and it does not modify the input arguments or maintain internal state between calls.

Parameters:
  • role (str) – The identifier of the role for which the approximation is defined.

  • c (Concept) – The concept for which the loose lower approximation is defined.

Returns:

An instance representing a loose lower approximation concept initialized with the provided role and concept.

Return type:

Self

static loose_upper_approx(role: str, c: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept) Self

Constructs a new ApproximationConcept instance representing a loose upper approximation. This static method serves as a factory that accepts a role identifier and a base Concept object, initializing the new instance with the specific type LOOSE_UPPER_APPROX. It delegates the actual instantiation to the class constructor, ensuring the resulting object is correctly typed and associated with the provided role and concept.

Parameters:
  • role (str) – The name of the role or relation used to compute the loose upper approximation.

  • c (Concept) – The base concept for which the loose upper approximation is constructed.

Returns:

An instance representing the loose upper approximation of the provided concept for the specified role.

Return type:

Self

static lower_approx(role: str, c: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept) Self

This static method acts as a factory to construct a new instance of ApproximationConcept representing a lower approximation. It accepts a string defining the role and a base Concept object, initializing the new concept with the type ConceptType.LOWER_APPROX. The method returns the newly created object without modifying the input arguments.

Parameters:
  • role (str) – The string identifier representing the specific role or attribute associated with the lower approximation.

  • c (Concept) – The concept to be approximated.

Returns:

A new instance representing the lower approximation of the specified concept for the given role.

Return type:

Self

replace(
a: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
c: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
) fuzzy_dl_owl2.fuzzydl.concept.concept.Concept

Replaces occurrences of a specific concept a with the provided concept c within the current structure. This method recursively applies the replacement operation to the underlying concept (self.curr_concept). If the replacement concept c is an instance of ApproximationConcept, the resulting structure is reconstructed using the specific approximation type (e.g., lower, upper, loose, or tight) defined by c, while preserving the current role. The method returns a new Concept instance without modifying the original.

Parameters:
  • a (Concept) – The concept to be replaced within the underlying concept structure.

  • c (Concept) – The concept to replace a with. If c is an ApproximationConcept, the resulting concept inherits its approximation type.

Returns:

A new Concept resulting from replacing sub-concept a with c. If c is an ApproximationConcept, returns a new ApproximationConcept of the same type as c, preserving the current role and wrapping the recursively modified inner concept.

Return type:

Concept

static tight_lower_approx(role: str, c: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept) Self

Creates and returns an instance of ApproximationConcept configured as a tight lower approximation. This static factory method initializes the object with the specific type ConceptType.TIGHT_LOWER_APPROX, associating it with the provided role string and the source concept. It abstracts the instantiation process, allowing callers to create this specific approximation variant without needing to handle the underlying type enumeration directly.

Parameters:
  • role (str) – The specific role or relation used to define the tight lower approximation of the concept.

  • c (Concept) – The concept to be approximated.

Returns:

An ApproximationConcept instance representing the tight lower approximation of the provided concept.

Return type:

Self

static tight_upper_approx(role: str, c: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept) Self

Creates and returns an ApproximationConcept instance configured as a tight upper approximation. This static factory method initializes the object with the specific type ConceptType.TIGHT_UPPER_APPROX, associating it with the provided role string and the source concept. It acts as a convenience wrapper for the class constructor, ensuring the correct approximation type is applied without requiring the caller to specify the enum value directly.

Parameters:
  • role (str) – The relation or attribute used to compute the tight upper approximation.

  • c (Concept) – The concept to be approximated.

Returns:

Returns an instance representing the tight upper approximation of the provided concept for the specified role.

Return type:

Self

to_all_some_concept() fuzzy_dl_owl2.fuzzydl.concept.all_some_concept.AllSomeConcept

Converts the current approximation instance into an equivalent representation using the AllSomeConcept class based on the specific approximation type. The mapping logic translates lower approximations to universal quantification and upper approximations to existential quantification, with tight and loose variations handled by nesting these quantifiers appropriately using the instance’s role and current concept. If the approximation type is not recognized, a ValueError is raised.

Raises:

ValueError – Raised if self.type does not match any of the expected approximation types.

Returns:

The AllSomeConcept equivalent of the current approximation type, constructed using the role and current concept.

Return type:

AllSomeConcept

static upper_approx(role: str, c: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept) Self

Creates an instance of ApproximationConcept representing an upper approximation for a given concept and role. This static factory method wraps the class constructor, explicitly setting the concept type to ConceptType.UPPER_APPROX while passing through the provided role string and the base concept object. It does not modify the input arguments and relies on the underlying class constructor for validation of the provided parameters.

Parameters:
  • role (str) – The identifier for the role or attribute under which the upper approximation is calculated.

  • c (Concept) – The concept to be approximated.

Returns:

Returns an ApproximationConcept representing the upper approximation of the provided concept for the specified role.

Return type:

Self

INVERSE_APPROXIMATION: dict[fuzzy_dl_owl2.fuzzydl.util.constants.ConceptType, fuzzy_dl_owl2.fuzzydl.util.constants.ConceptType]
name
LooseLowerApprox
LooseUpperApprox
LowerApprox
TightLowerApprox
TightUpperApprox
UpperApprox