#lang scribble/manual @title{Forward Chaining} Forward chaining is an artificial intelligence technique that enables deductive reasoning. @defform[(forward-chain [precedent consequent ...] ...)] provides a 'cond like syntax to implement forward chaining. Each precedent is evaluated at least once (barring back-chain-like escapes). Each set of consequences is evaluated no more than once. Example: @racketblock[(forward-chain [#f (display "Nobody likes me!") (newline)] [#t (display "Hello, World!") (newline)]) (code:comment "A common idiom is to stop processing when some goal is reached") (let [(red #t) (white 'unknown) (green #t) (blue #t)] (let/ec break-chain (forward-chain [(and red white blue) (display "All American") (break-chain)] [(and red green blue) (set! white #t)] [#t (display "Should never get here.") (error)])))] In the above example, nobody knows that nobody likes me. @racket[(display "Hello, World")] is executed once. @racket[(display "All American")]i s skipped on the first pass, but when it's found that red, green, and blue make white later in the rule list, @racket[(and red white blue)] is reevaluated, and the point of laboring on is moot!