title: Forward chaining and Backward chaining in java
body: <p>What will be the best approach to implement forward chaining and backward chaining for reasoning process in java?</p>
  
  <p>We have been given Horn-form knowledge base which has set of statements.</p>
  
  <p>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.</p>
  
  <p>My understanding :</p>
  
  <p>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.</p>
  
  <pre><code> public class Sentence{
  
      private String impliedBy;
      private String implementedVar;
  
      public Sentence(String sentence){
         String[] relation = sentence.split("=&gt;");
         this.impliedBy = relation[0];
         this.implementedVar = relation[1];
      }
      ...
   }
  </code></pre>
  
  <p>Calling above class by saying...</p>
  
  <pre><code>Sentence s = new Sentence("a&amp;b=&gt;c");
  </code></pre>
  
  <p>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...</p>
  
  <p>Thanks!</p>