Query Results Explanation

Execute query ‘What are all the grandparent/grandson pairs?’. In the Queries Results window, click ? in the row with Aaron as ?Grandparent and Darryn as ?Grandson to see an explanation for this result. As seen in Fig. 221, an explanation shows up in a new tab in the Query Results window. By default, it is presented in a tree format. Expand the explanation tree to see each reasoning step along with the rules and instances used.

Explanation in a **Tree** for query result **Aaron** and **Darryn**

Fig. 221 Explanation in a Tree for query result Aaron and Darryn

Two other views of an explanation are available: Graph and English. Graph presents the explanation in a connected graph, as shown in Fig. 222, and English presents the explanation, to the extent possible, in everyday English, as shown in Fig. 223.

Explanation in a **Graph** for query result **Aaron** and **Darryn**

Fig. 222 Explanation in a Graph for query result Aaron and Darryn

Explanation in **English** for query result **Aaron** and **Darryn**

Fig. 223 Explanation in English for query result Aaron and Darryn

Query result explanations can be shown in a more user-friendly language such as everyday English. See Section Natural Language Paraphrasing on how to use manual annotations to do this.

Query Results Explanations with Notrace Option

To exclude execution steps of a specific rule in the query results explanation, the notrace option can be used. For example, suppose we are not interested in seeing the steps of ‘GrandSonRule’ in the explanation, we can specify the notrace option in the rule. That is, edit ‘GrandSonRule’ to look like:

@!{GrandsonRule [notrace]}
?Person [grandson -> ?Grandson] :-
  ?Grandson : Man [grandparent -> ?Person].

Save family.flr and execute the query ‘What are all the grandparent/grandson pairs?’ again. This time in the Query Results window, click the ? corresponding to the answer pair Aaron and Darryn, and you will see a one level deep explanation, with no sub steps included for the ‘GrandSonRule’, as seen in Fig. 224.

Explanation for query result **Aaron** and **Darryn** when **notrace** is used in GrandSonRule

Fig. 224 Explanation for query result Aaron and Darryn when notrace is used in GrandSonRule