5.1 Defining Explanation Functions

The explanation function for a predicate is a function that takes the same arguments as the predicate and returns an explanation. The explanation should explain why the predicate, when invoked with the arguments given to the explanation function, returns the value that it returns. The explanation can be any object but should have a comprehensible printed representation. If the return value of the predicate needs no explanation for a given list of arguments, the explanation function should return nil.

To associate an explanation function with a predicate, add the property ert-explainer to the symbol that names the predicate. The value of the property should be the symbol that names the explanation function.