Huyck's Implementation of Backward Chaining in Clips
- As far as I can tell, Clips doesn't have backward chaining.
As I'd like to show my students backward chaining, I implemented
it myself.
- The code is not exhaustively tested. Feel free to use it if you'd
like, but it is derived from the clips that is downloadable,
and I'm not licensing this to anyone, and am not responsible
for any bugs. So, it's the standard
shareware thing.
- I wanted to write a backward chaining system using the rules
in Clips. This was because I needed a backward chaining system
and wanted to see how easy it was to write something real in
clips. Unfortunately, I needed access to data that wasn't accessible
by the rules.
- Fortunately, one of the cool things about clips is that you can download
and modify the source code. I did that. I made a new file
chrisfuncts.c and modified
the main file main.c.
- The backchaing rules get loaded. They preprocess the
rules (ignoring themselves which are prefixed with BCC__) to
get the RHS assert, the LHS conditions, and the name.
- They then put stuff on a stack to try and satisfy the goals.
- They also prompt the user for facts when there is a fact like
(promptuser "fact").
- As far as I can tell, it works on the following files:
monkeys
- test 1
- test 2
- test 3
- test 4
- test 5
- test 6
Potential Problems
- It reads in all the rules; if you have too many rules the
exe will crash. You can change the constant in chrisfuncts
and recompile.
- I'm pretty sure you can get into a loop with subgoals.
- The subgoaling doesn't account for variables.