@explain annotation enables generating detailed explanations for derived facts, helping to understand their provenance and the rules applied. Explanations can be presented in structured JSON format, natural language, or refined reports via LLM, enhancing transparency and aiding debugging.
Materializing Explanations to External Data Sources
The@explain annotation configures how the explanations are stored. Its syntax is as follows:
Explanation Output Structure
The explanation output has three fields:Fact— the derived fact being explained.JsonExplanation— a hierarchical JSON representation of the fact’s derivation.TextualExplanation— a natural language explanation based on model annotations or default verbalization.
Json Explanation Example
Textual Explanation Examples
Without Model Annotations In the absence of model annotations, the explanation uses fact:Explanation Scenarios and Use Cases
Example 1: Linear Rule Explanation without Model Annotations
Example 2: Linear Rule Explanation with Model Annotations
Example 3: Join Rule Explanation
Example 4: Explaining Pre-Materialized Chase Results
By settingchase=false, Prometheux exploits a pre-materialized chase data for explanations, avoiding recomputation.
Explanations are related to the predicates specified in the @output annotation.
To explain specific predicates not in @output, use the predicates='predicate1,predicate2' option.
Chase Materialization:

