Forward chaining and Backward chaining in java

TeaCupApp picture TeaCupApp · May 23, 2011 · Viewed 12.2k times · Source

What will be the best approach to implement forward chaining and backward chaining for reasoning process in java?

We have been given Horn-form knowledge base which has set of statements.

I have tried to search on internet but I was unable to find any description regarding how to implement these sort of Artificial Intelligence concept into coding.

My understanding :

I have thought so far that I will read each sentence(Horn-Form) and create an object of it. Each Sentence class object will have relationship variables and when I will ask knowledge bases for Backward or Forward chain, It will check array of those objects and constructs my desired chain.

 public class Sentence{

    private String impliedBy;
    private String implementedVar;

    public Sentence(String sentence){
       String[] relation = sentence.split("=>");
       this.impliedBy = relation[0];
       this.implementedVar = relation[1];
    }
    ...
 }

Calling above class by saying...

Sentence s = new Sentence("a&b=>c");

Am I on right track of sorry I am noob for these sort of complicated programming and as per my prediction I might need lots of optimisation to run these sort of reasoning at very high level. But it seems like I need good understanding by someone thank you if some of you can help...

Thanks!

Answer

duffymo picture duffymo · May 23, 2011

I'd use a rules engine like Drools or JESS before I'd try writing this for myself.

Unless your purpose is to learn how to write a Rete rules engine, in which case I'll withdraw my answer. I'd go and look for Charles Forgy's papers.