Backward chaining (or backward reasoning) is an
inference
Inferences are steps in logical reasoning, moving from premises to logical consequences; etymologically, the word '' infer'' means to "carry forward". Inference is theoretically traditionally divided into deduction and induction, a distinct ...
method described colloquially as working backward from the goal. It is used in
automated theorem prover
Automated theorem proving (also known as ATP or automated deduction) is a subfield of automated reasoning and mathematical logic dealing with proving mathematical theorems by computer programs. Automated reasoning over mathematical proof was a ma ...
s,
inference engines,
proof assistant
In computer science and mathematical logic, a proof assistant or interactive theorem prover is a software tool to assist with the development of formal proofs by human–machine collaboration. This involves some sort of interactive proof edi ...
s, and other
artificial intelligence
Artificial intelligence (AI) is the capability of computer, computational systems to perform tasks typically associated with human intelligence, such as learning, reasoning, problem-solving, perception, and decision-making. It is a field of re ...
applications.
In
game theory
Game theory is the study of mathematical models of strategic interactions. It has applications in many fields of social science, and is used extensively in economics, logic, systems science and computer science. Initially, game theory addressed ...
, researchers apply it to (simpler)
subgames to find a solution to the game, in a process called ''
backward induction
Backward induction is the process of determining a sequence of optimal choices by reasoning from the endpoint of a problem or situation back to its beginning using individual events or actions. Backward induction involves examining the final point ...
''. In chess, it is called
retrograde analysis, and it is used to generate table bases for
chess endgame
The endgame (or ending) is the final stage of a chess game which occurs after the middlegame. It begins when few pieces are left on the board.
The line between the middlegame and the endgame is often not clear, and may occur gradually or with ...
s for
computer chess
Computer chess includes both hardware (dedicated computers) and software capable of playing chess. Computer chess provides opportunities for players to practice even in the absence of human opponents, and also provides opportunities for analysi ...
.
Backward chaining is implemented in
logic programming
Logic programming is a programming, database and knowledge representation paradigm based on formal logic. A logic program is a set of sentences in logical form, representing knowledge about some problem domain. Computation is performed by applyin ...
by
SLD resolution
SLD resolution (''Selective Linear Definite'' clause resolution) is the basic rule of inference, inference rule used in logic programming. It is a refinement of Resolution (logic), resolution, which is both Soundness, sound and refutation Completen ...
. Both rules are based on the
modus ponens
In propositional logic, (; MP), also known as (), implication elimination, or affirming the antecedent, is a deductive argument form and rule of inference. It can be summarized as "''P'' implies ''Q.'' ''P'' is true. Therefore, ''Q'' must ...
inference rule. It is one of the two most commonly used methods of
reasoning
Reason is the capacity of consciously applying logic by drawing valid conclusions from new or existing information, with the aim of seeking the truth. It is associated with such characteristically human activities as philosophy, religion, scien ...
with
inference rule
Rules of inference are ways of deriving conclusions from premises. They are integral parts of formal logic, serving as norms of the logical structure of valid arguments. If an argument with true premises follows a rule of inference then the co ...
s and
logical implications – the other is
forward chaining. Backward chaining systems usually employ a
depth-first search
Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible al ...
strategy, e.g.
Prolog
Prolog is a logic programming language that has its origins in artificial intelligence, automated theorem proving, and computational linguistics.
Prolog has its roots in first-order logic, a formal logic. Unlike many other programming language ...
.
Usage
Backward chaining starts with a list of
goal
A goal or objective is an idea of the future or desired result that a person or a group of people envision, plan, and commit to achieve. People endeavour to reach goals within a finite time by setting deadlines.
A goal is roughly similar to ...
s (or a
hypothesis
A hypothesis (: hypotheses) is a proposed explanation for a phenomenon. A scientific hypothesis must be based on observations and make a testable and reproducible prediction about reality, in a process beginning with an educated guess o ...
) and works backwards from the
consequent
A consequent is the second half of a hypothetical proposition. In the standard form of such a proposition, it is the part that follows "then". In an implication, if ''P'' implies ''Q'', then ''P'' is called the antecedent and ''Q'' is called t ...
to the
antecedent to see if any
data
Data ( , ) are a collection of discrete or continuous values that convey information, describing the quantity, quality, fact, statistics, other basic units of meaning, or simply sequences of symbols that may be further interpreted for ...
supports any of these consequents.
An
inference engine using backward chaining would search the
inference
Inferences are steps in logical reasoning, moving from premises to logical consequences; etymologically, the word '' infer'' means to "carry forward". Inference is theoretically traditionally divided into deduction and induction, a distinct ...
rules until it finds one with a consequent (Then clause) that matches a desired goal. If the antecedent (If clause) of that rule is not known to be true, then it is added to the list of goals (for one's goal to be confirmed one must also provide data that confirms this new rule).
For example, suppose a new pet, Fritz, is delivered in an opaque box along with two facts about Fritz:
* Fritz croaks
* Fritz eats flies
The goal is to decide whether Fritz is green, based on a
rule base containing the following four rules:

# If X croaks and X eats flies – Then X is a frog
# If X chirps and X sings – Then X is a canary
# If X is a frog – Then X is green
# If X is a canary – Then X is yellow
With backward reasoning, an inference engine can determine whether Fritz is green in four steps. To start, the query is phrased as a goal assertion that is to be proven: "Fritz is green".
1. Fritz is substituted for X in rule #3 to see if its consequent matches the goal, so rule #3 becomes:
If Fritz is a frog – Then Fritz is green
Since the consequent matches the goal ("Fritz is green"), the rules engine now needs to see if the antecedent ("Fritz is a frog") can be proven. The antecedent, therefore, becomes the new goal:
Fritz is a frog
2. Again substituting Fritz for X, rule #1 becomes:
If Fritz croaks and Fritz eats flies – Then Fritz is a frog
Since the consequent matches the current goal ("Fritz is a frog"), the inference engine now needs to see if the antecedent ("Fritz croaks and eats flies") can be proven. The antecedent, therefore, becomes the new goal:
Fritz croaks and Fritz eats flies
3. Since this goal is a conjunction of two statements, the inference engine breaks it into two sub-goals, both of which must be proven:
Fritz croaks
Fritz eats flies
4. To prove both of these sub-goals, the inference engine sees that both of these sub-goals were given as initial facts. Therefore, the conjunction is true:
Fritz croaks and Fritz eats flies
therefore the antecedent of rule #1 is true and the consequent must be true:
Fritz is a frog
therefore the antecedent of rule #3 is true and the consequent must be true:
Fritz is green
This derivation, therefore, allows the inference engine to prove that Fritz is green. Rules #2 and #4 were not used.
Note that the goals always match the affirmed versions of the consequents of implications (and not the negated versions as in
modus tollens
In propositional logic, ''modus tollens'' () (MT), also known as ''modus tollendo tollens'' (Latin for "mode that by denying denies") and denying the consequent, is a deductive argument form and a rule of inference. ''Modus tollens'' is a m ...
) and even then, their antecedents are then considered as the new goals (and not the conclusions as in
affirming the consequent
In propositional logic, affirming the consequent (also known as converse error, fallacy of the converse, or confusion of necessity and sufficiency) is a formal fallacy (or an invalid form of argument) that is committed when, in the context of a ...
), which ultimately must match known facts (usually defined as consequents whose antecedents are always true); thus, the inference rule used is
modus ponens
In propositional logic, (; MP), also known as (), implication elimination, or affirming the antecedent, is a deductive argument form and rule of inference. It can be summarized as "''P'' implies ''Q.'' ''P'' is true. Therefore, ''Q'' must ...
.
Because the list of goals determines which rules are selected and used, this method is called
goal-driven, in contrast to
data-driven
Data ( , ) are a collection of discrete or continuous value (semiotics), values that convey information, describing the quantity, qualitative property, quality, fact, statistics, other basic units of meaning, or simply sequences of symbols t ...
forward-chaining
Forward chaining (or forward reasoning) is one of the two main methods of reasoning when using an inference engine and can be described logically as repeated application of ''modus ponens''. Forward chaining is a popular implementation strategy ...
inference. The backward chaining approach is often employed by
expert systems
In artificial intelligence (AI), an expert system is a computer system emulating the decision-making ability of a human expert.
Expert systems are designed to solve complex problems by Automated reasoning system, reasoning through bodies of knowl ...
.
Programming languages such as
Prolog
Prolog is a logic programming language that has its origins in artificial intelligence, automated theorem proving, and computational linguistics.
Prolog has its roots in first-order logic, a formal logic. Unlike many other programming language ...
,
Knowledge Machine
The Knowledge Machine is a concept of Seymour Papert, which is intended to enable children to explore any situation and engage them completely. Although Papert never clearly defined the Knowledge Machine, one interpretation is a virtual reality ...
and
ECLiPSe
An eclipse is an astronomical event which occurs when an astronomical object or spacecraft is temporarily obscured, by passing into the shadow of another body or by having another body pass between it and the viewer. This alignment of three ...
support backward chaining within their inference engines.
See also
*
Backtracking
Backtracking is a class of algorithms for finding solutions to some computational problems, notably constraint satisfaction problems, that incrementally builds candidates to the solutions, and abandons a candidate ("backtracks") as soon as it de ...
*
Backward induction
Backward induction is the process of determining a sequence of optimal choices by reasoning from the endpoint of a problem or situation back to its beginning using individual events or actions. Backward induction involves examining the final point ...
*
Forward chaining
*
Opportunistic reasoning
References
[
Definition of backward chaining as a depth-first search method:
*
]
[
Languages that support backward chaining:
*
]
Sources
*
External links
Backward chaining example{{Automated reasoning
Expert systems
Logic in computer science
Reasoning
Automated reasoning