Add forward chaining.
Fix compile error. Fix bug.