capture
[rrq/gorite.git] / examples / ruleset / Main.java
1 package examples.ruleset;
2
3 import com.intendico.data.*;
4 import com.intendico.data.addon.*;
5 import java.util.Vector;
6
7 public class Main {
8
9     // Missing constructor
10     static Rule asRule(Vector v) {
11         return new Rule( (Query) v.get( 0 ), (Query) v.get( 1 ) );
12     }
13     
14     /**
15      * Application main.
16      */
17     static public void main(String [] args) {
18         Language logic = Language.getLanguage();
19         //logic.trace = -1;
20         
21         // Define the belief structures
22         Vector kb = new Vector();
23         kb.add( new Relation( "P", 1 ) );
24
25         // Define the theory
26         RuleSet rs = new RuleSet();
27         rs.add( asRule( logic.textToRule( "P($x) => Not P($x)", kb ) ) );
28         rs.add( asRule( logic.textToRule( "Lost P($x) => P($x)", kb ) ) );
29
30         // Add a belief
31         logic.textToQuery( "P(1)", kb, null, null ).add();
32
33         // Tell the start state
34         System.out.println( kb );
35         System.out.println( rs );
36
37         // Run infer as per the theory
38         rs.run();
39
40         // Tell the result
41         System.out.println( kb );
42     }
43 }