fuzzy_dl_owl2.fuzzydl.concept.all_some_concept

Implements a class representing universal and existential role restrictions within a fuzzy description logic framework.

Description

Quantified role restrictions are modeled to handle universal and existential constraints, ensuring that individuals satisfy specific conditions regarding their relationships to other concepts. A factory pattern is employed to manage instantiation, applying logical optimizations that reduce trivial cases—such as an existential restriction on the bottom concept—to their simplest forms before construction. The design integrates with the broader logic system by inheriting from a base concept class and adhering to an interface for role handling, which allows for consistent manipulation of complex expressions. Operations such as negation are implemented by swapping the quantifier type and recursively negating the nested concept, preserving logical validity while maintaining immutability through cloning and replacement methods. Structural identity is determined by the role, quantifier type, and nested concept, which are used to generate hash values and string representations for comparison and storage.

Attributes

All

Some

Classes

AllSomeConcept

Represents quantified role restrictions, specifically universal ("all") and existential ("some") restrictions, within a description logic framework. It defines conditions that an individual must satisfy regarding its relationships: for a universal restriction, every individual connected via a specific role must belong to a target concept, while for an existential restriction, at least one such connected individual must belong to the target concept. Instances are best created using the static factory methods all and some, which apply logical optimizations—such as reducing (all r TOP) to TOP—before construction. The object supports standard concept operations including negation, which inverts the quantifier type and negates the nested concept, as well as cloning and sub-concept replacement.

Module Contents

UML Class Diagram for AllSomeConcept

UML Class Diagram for AllSomeConcept

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

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.all_some_concept.AllSomeConcept

Represents quantified role restrictions, specifically universal (“all”) and existential (“some”) restrictions, within a description logic framework. It defines conditions that an individual must satisfy regarding its relationships: for a universal restriction, every individual connected via a specific role must belong to a target concept, while for an existential restriction, at least one such connected individual must belong to the target concept. Instances are best created using the static factory methods all and some, which apply logical optimizations—such as reducing (all r TOP) to TOP—before construction. The object supports standard concept operations including negation, which inverts the quantifier type and negates the nested concept, as well as cloning and sub-concept replacement.

Parameters:

_name (str) – Computed string representation of the concept, formatted as “(all r C)” or “(some r C)”.

__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

Implements the unary negation operator for the concept, returning a new instance that represents the logical inverse. The method swaps the quantifier type between ‘ALL’ and ‘SOME’, retains the current role, and recursively negates the inner concept. This operation is side-effect free, leaving the original object unchanged.

Returns:

The logical negation of the concept, with the quantifier type toggled between ALL and SOME and the underlying concept negated.

Return type:

Concept

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

Constructs a new AllSomeConcept instance representing a universal quantification over the provided concept. This static factory method accepts a role string and a Concept object, initializing the instance with the specific type ConceptType.ALL. It serves as a convenience wrapper around the internal new method to simplify the creation of “all” relationships within the module.

Parameters:
  • role (str) – The name of the role or property defining the universal restriction.

  • concept (Concept) – The concept defining the range of the universal restriction.

Returns:

Returns a new instance representing a universal quantification over the specified role and concept.

Return type:

Self

clone() Self

Creates and returns a distinct copy of the current AllSomeConcept instance. This method generates the new object by passing the current object’s type, role, and curr_concept attributes to the class constructor. The original object remains unmodified by this operation, although the clone will reference the same underlying attribute values as the source.

Returns:

A new instance of the class with the same type, role, and current concept as the current object.

Return type:

Self

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

Calculates and returns the set of atomic concepts by delegating the computation to the concept object stored in the curr_concept attribute. This method serves as a wrapper that forwards the request, allowing the underlying concept to determine its own atomic constituents. The result is a set containing the fundamental concepts that compose the current structure, and the operation relies entirely on the implementation of the delegated method within the referenced concept.

Returns:

A set of atomic concepts that constitute the current concept.

Return type:

set[Concept]

compute_name() str

Generates a string representation of the concept based on its quantifier type, formatting the output to include the role and current concept within parentheses. If the concept type is defined as ‘ALL’, the resulting string uses the ‘all’ quantifier; otherwise, it defaults to the ‘some’ quantifier. This method does not modify the object’s state and relies on the string representations of the associated role and concept attributes.

Returns:

A string representation of the concept, formatted as ‘(all role concept)’ or ‘(some role concept)’ based on the concept type.

Return type:

str

get_atoms() list[Self]

Retrieves the fundamental atomic elements associated with the current concept by delegating the call to the get_atoms method of the internal curr_concept attribute. The returned list contains instances of the class, representing the indivisible components that constitute the concept’s structure. This method acts as a pass-through wrapper without modifying the state of the object, though it may raise an error if the underlying curr_concept is not initialized.

Returns:

A list of instances of this class representing the atomic components of the current concept.

Return type:

list[Self]

get_roles() set[str]

Returns a comprehensive set of role identifiers associated with the current instance and its related concept. The method constructs a set containing the instance’s own role attribute and merges it with the roles retrieved from the curr_concept attribute via a recursive call to get_roles. This ensures that the returned collection includes both the local role and any roles inherited or defined by the linked concept object.

Returns:

A set of role strings representing the union of the instance’s role and the roles of the current concept.

Return type:

set[str]

is_complemented_atomic() bool

Determines if the current concept represents a complemented atomic concept, which is the negation of a primitive class. Because this class models a complex restriction involving quantifiers rather than a simple negation, it cannot satisfy this condition. The method always returns False and has no side effects.

Returns:

True if the object is complemented atomic, False otherwise.

Return type:

bool

static new(
c_type: fuzzy_dl_owl2.fuzzydl.util.constants.ConceptType,
role: str,
concept: fuzzy_dl_owl2.fuzzydl.concept.concept.Concept,
) Self

Acts as a factory method for instantiating AllSomeConcept objects based on a specified concept type, role, and nested concept. When optimizations are enabled via the configuration, the method applies logical simplifications: if the type is SOME and the nested concept is BOTTOM, it returns the global bottom concept; conversely, if the type is ALL and the nested concept is TOP, it returns the global top concept. If these optimization conditions are not met, the method constructs and returns a new AllSomeConcept instance initialized with the provided arguments.

Parameters:
  • c_type (fuzzy_dl_owl2.fuzzydl.util.constants.ConceptType) – Specifies the type of concept to instantiate, determining whether it represents a universal (ALL) or existential (SOME) quantification.

  • role (str) – The role or property name used to define the concept restriction.

  • concept (Concept) – The concept instance to be wrapped or restricted.

Returns:

Returns a new instance representing the specified restriction. If optimizations are enabled and the result is trivial (e.g., SOME of BOTTOM or ALL of TOP), returns the corresponding TruthConcept singleton.

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

Creates and returns a new AllSomeConcept instance where all occurrences of the specified concept a within the underlying curr_concept are replaced by concept c. The type and role attributes of the original instance are preserved in the resulting object. This method does not modify the current instance in place, ensuring immutability.

Parameters:
  • a (Concept) – The concept to be replaced.

  • c (Concept) – The concept to substitute in place of a.

Returns:

Returns a new concept where all occurrences of concept a are replaced by concept c.

Return type:

Concept

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

Constructs a new instance of the class representing a specific type of concept relationship defined by the SOME type identifier. This static factory method accepts a string defining the role and a Concept object, delegating the actual instantiation logic to the underlying new method. It serves as a semantic convenience for creating objects that represent partial or existential quantification within the broader concept system.

Parameters:
  • role (str) – The name or identifier of the property or relation involved in the existential restriction.

  • concept (Concept) – The concept to be represented as a ‘some’ concept.

Returns:

A new instance of the class representing a “some” concept relationship initialized with the provided role and concept.

Return type:

Self

_name: str | None = None
All
Some