After the abductive system is loaded and the abductive theory is imported, diagnosis tasks can be performed as abductive queries. The predicate for a query is query(+ListOfGoals, -Answer). Upon the success of the query, Answer is a tuple (As, Cs, Ns), where As is a list of (possibly non-ground) abducibles, Cs is a list of arithmetic constraints (which will be introduced in Section 3), and Ns is a list of collected dynamic denial of the form fail(ListOfUniversalVars, ListOfGoals). A dynamic denial, e.g., fail([X], [p(X, Y), q(X), r(Y)]), should be read as
.
Let us go back to the car diagnosis example. To find out why my car does not start, you can execute the following query:
| ?- query([car_doesnt_start(mycar)], Ans). Ans = ([has_no_fuel(mycar)],[],[fail([_A],[battery_flat(_A),lights_go_on(_A)]),fail([_B], [has_no_fuel(_B),\+fuel_indicator_empty(_B),\+broken_indicator(_B)])]) ? ; no | ?-
Alternatively, if you are only interested in the collected abducibles and constraints, or if you also want to find out why a different car does not start, you can execute the queries:
| ?- query([car_doesnt_start(mycar)], (As, Cs, _)). As = [has_no_fuel(mycar)], Cs = [] ? ; no | ?- query([car_doesnt_start(yourcar)], (As, Cs, _)). As = [battery_flat(yourcar)], Cs = [] ? ; As = [broken_indicator(yourcar),has_no_fuel(yourcar)], Cs = [] ? ; no | ?-
Finally, if you want a diagnosis of any car, you can execute the query with non-ground goal(s), e.g.,
| ?- query([car_doesnt_start(AnyCar)], (As, Cs, _)). As = [battery_flat(AnyCar)], Cs = [AnyCar=/=mycar], AnyCar=/=mycar ? ; As = [has_no_fuel(mycar)], Cs = [], AnyCar = mycar ? ; As = [broken_indicator(AnyCar),has_no_fuel(AnyCar)], Cs = [AnyCar=/=mycar], AnyCar=/=mycar ? ; no | ?-