fuzzy_dl_owl2.fuzzydl.query.kb_satisfiable_query
A query implementation that determines the logical consistency and satisfiability of a fuzzy description logic knowledge base.
Description
Extending the abstract query framework, this component provides the logic necessary to verify whether a given knowledge base contains any logical contradictions or if it admits at least one valid interpretation. The evaluation process relies on solving the assertional component of the knowledge base and performing an optimization step to validate the existence of a consistent model. To handle scenarios where the knowledge base lacks specific individuals, the implementation dynamically generates temporary entities to ensure the optimization algorithm can execute correctly. The final result is encapsulated in a solution object that either confirms satisfiability with a perfect score or explicitly marks the knowledge base as inconsistent when contradictions or exceptions are detected.
Classes
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
- class KbSatisfiableQuery[source]
Bases:
fuzzy_dl_owl2.fuzzydl.query.query.Query
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[source]
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[source]
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[source]
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[source]
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: