Choosing directions for rules

In ‘expert systems’ and other applications of logic programming, the issue arises of whether to use rules for forward or backward inference, i.e. whether deduction should be driven by the facts available to the program or the questions that are put to it. Often some mixture of the two is cheaper than using either mode exclusively.We show that, under two restrictive assumptions, optimal choices of directions for the rules can be made in time polynomial in the number of rules in the system. If we abandon one of these restrictions, the optimal choice is NP-complete. Search methods are presented which allow graceful degradation from polynomial time to exponential time.The cost estimates on which the optimisation is based are also discussed. The methods used to estimate costs fail when recursion is present in the rules, thus limiting the set of logic programs to which this optimisation can be applied.