Suppose that we have formulas:[Backward chaining only works for
* Horn clauses*, which have at most one positive literal.]

* A *

* B *

* D *

* A &and B &rarr C *

* C &and D &rarr E *

A conclusion * E * can be proved recursively:

- First check whether the desired conclusion is in the database of
facts. If so, return True.
- Otherwise, for each rule that has the desired conclusion
(right-hand side), call the algorithm recursively for each item in the
premise (left-hand side). If all of the premises are true, return True.
- Otherwise, return False.

In this example, we would know that * E * is true if we knew that * C *
and * D * were true; we would know that * C * is true if we knew * A *
and * B *; * A * and * B * are in the database, so * C * must
be true; and * D * is in the database, so * E * is true.

With careful implementation, backchaining can run in linear time.