Różnice
Różnice między wybraną wersją a wersją aktualną.
|
|
pl:prolog:pllib:backward-chaining_rule_interpreter [2019/06/27 15:50] |
pl:prolog:pllib:backward-chaining_rule_interpreter [2019/06/27 15:50] (aktualna) |
| ====== Backward-chaining rule interpreter ====== |
| {{tag>backward-chaining rules interpreter}} |
| ===== Description ===== |
| A backward chaining interpreter for if-then rules. |
| |
| **Source**: PROLOG programming for artificial intelligence, 3rd Edition, Harlow, 2001, ISBN 0-201-40375-7. |
| ===== Download ===== |
| Program source code: {{backward-chaining_rule_interpreter.pl}} |
| ===== Listing ===== |
| <code prolog> |
| % Figure 15.6 A backward chaining interpreter for if-then rules. |
| |
| |
| % A simple backward chaining rule interpreter |
| |
| :- op( 800, fx, if). |
| :- op( 700, xfx, then). |
| :- op( 300, xfy, or). |
| :- op( 200, xfy, and). |
| |
| is_true( P) :- |
| fact( P). |
| |
| is_true( P) :- |
| if Condition then P, % A relevant rule |
| is_true( Condition). % whose condition is true |
| |
| is_true( P1 and P2) :- |
| is_true( P1), |
| is_true( P2). |
| |
| is_true( P1 or P2) :- |
| is_true( P1) |
| ; |
| is_true( P2). |
| </code> |
| ===== Comments ===== |
| |