fuzzy_dl_owl2.fuzzydl.query.kb_satisfiable_query

A query implementation that determines the logical consistency and satisfiability of a fuzzy knowledge base by verifying if at least one valid interpretation exists for all defined axioms.

Description

It extends the generic query framework to provide a mechanism for validating that a knowledge base does not contain any contradictions. The core logic executes a consistency check by first solving the assertional box and then performing an optimization on a cloned instance of the knowledge base to prevent side effects on the original data. To ensure the optimization can proceed even when the base lacks specific individuals, the logic automatically generates a temporary individual if necessary. The final result is returned as a Solution object, indicating a perfect score of 1.0 for a consistent base or a specific inconsistency status if contradictions or ontology exceptions are encountered.

Classes

KbSatisfiableQuery

This class represents a query designed to determine the satisfiability of a Knowledge Base, effectively checking whether the base is logically consistent. It verifies if there exists at least one interpretation that satisfies all axioms defined within the provided Knowledge Base. To perform the check, an instance of this class should be created and its solve method called with the target KnowledgeBase. The query returns a Solution object containing a score of 1.0 if the base is satisfiable, or a status indicating inconsistency if contradictions are detected or an InconsistentOntologyException is raised during the reasoning process.

Module Contents

UML Class Diagram for KbSatisfiableQuery

UML Class Diagram for KbSatisfiableQuery

class KbSatisfiableQuery

Bases: fuzzy_dl_owl2.fuzzydl.query.query.Query

Inheritance diagram of fuzzy_dl_owl2.fuzzydl.query.kb_satisfiable_query.KbSatisfiableQuery

This class represents a query designed to determine the satisfiability of a Knowledge Base, effectively checking whether the base is logically consistent. It verifies if there exists at least one interpretation that satisfies all axioms defined within the provided Knowledge Base. To perform the check, an instance of this class should be created and its solve method called with the target KnowledgeBase. The query returns a Solution object containing a score of 1.0 if the base is satisfiable, or a status indicating inconsistency if contradictions are detected or an InconsistentOntologyException is raised during the reasoning process.

__str__() str

Returns a human-readable string representation of the query object, specifically designed to serve as a label for the satisfiability check. The implementation returns the static text “Is KnowledgeBase satisfiable? = “, which is typically used to prefix the result of the query when displaying output to a user. This method ignores the internal state of the object and provides a consistent prompt regardless of the specific knowledge base being evaluated.

Returns:

Returns a string representation of the object, specifically the text ‘Is KnowledgeBase satisfiable? = ‘.

Return type:

str

is_consistent_kb(kb: fuzzy_dl_owl2.fuzzydl.knowledge_base.KnowledgeBase) bool

Evaluates whether the provided KnowledgeBase is logically consistent by attempting to find a valid solution through optimization. The process begins by solving the ABox of the input knowledge base, which results in a modification of the input object. A clone of the knowledge base is then created to isolate the check; if this clone lacks individuals, a temporary individual is generated to ensure the optimization can proceed. The method returns True if the optimization yields a solution that is itself consistent, and False otherwise.

Parameters:

kb (KnowledgeBase) – The knowledge base to be evaluated for logical consistency.

Returns:

True if the knowledge base is consistent, False otherwise. Consistency is determined by solving the ABox and verifying the existence of a valid solution after optimization.

Return type:

bool

preprocess(kb: fuzzy_dl_owl2.fuzzydl.knowledge_base.KnowledgeBase) None

Prepares the provided knowledge base for the satisfiability evaluation process by performing necessary transformations or optimizations. This method operates via side effects, potentially modifying the internal state of the query object or the structure of the knowledge base itself to facilitate efficient querying. It does not return a value, and implementations should handle edge cases such as empty or already preprocessed knowledge bases gracefully.

Parameters:

kb (KnowledgeBase) – The knowledge base object to be prepared or cleaned.

solve(kb: fuzzy_dl_owl2.fuzzydl.knowledge_base.KnowledgeBase) fuzzy_dl_owl2.fuzzydl.milp.solution.Solution

Evaluates the satisfiability of the provided Knowledge Base by verifying its internal consistency. If the knowledge base is determined to be consistent, the method returns a Solution object with a confidence score of 1.0. Conversely, if the knowledge base is inconsistent or if an InconsistentOntologyException is raised during the evaluation process, the method returns a Solution marked as inconsistent. This operation does not modify the input Knowledge Base.

Parameters:

kb (KnowledgeBase) – The knowledge base to be solved or checked for consistency.

Returns:

A Solution object representing the outcome of the operation. It returns a solution initialized with 1.0 if the knowledge base is consistent, or a solution marked as inconsistent if the knowledge base is invalid or an ontology exception occurs.

Return type:

Solution