Search in sources :

Example 1 with WamInterpreter

use of edu.cmu.ml.proppr.prove.wam.WamInterpreter in project ProPPR by TeamCohen.

the class SplitFactsPluginTest method test.

@Test
public void test() throws LogicProgramException {
    int input = 0;
    int output = 0;
    int constants = Configuration.USE_WAM;
    int modules = 0;
    Configuration c = new Configuration(("--programFiles " + GrounderTest.RULES + ":" + GrounderTest.FACTS + ":" + ADDLFACTS).split(" "), input, output, constants, modules);
    assertEquals("# of plugins", c.plugins.length, 1);
    assertEquals("# of members", ((SplitFactsPlugin) c.plugins[0]).plugins.size(), 2);
    assertTrue("claim", c.plugins[0]._claim("validClass/1"));
    Query q = Query.parse("validClass(X)");
    WamInterpreter interp = new WamInterpreter(c.program, c.plugins);
    int queryStartAddr = c.program.size();
    q.variabilize();
    c.program.append(q);
    interp.executeWithoutBranching(queryStartAddr);
    List<Outlink> outs = c.plugins[0].outlinks(interp.saveState(), interp, true);
    assertEquals("# outlinks", 6, outs.size());
}
Also used : Outlink(edu.cmu.ml.proppr.prove.wam.Outlink) Configuration(edu.cmu.ml.proppr.util.Configuration) Query(edu.cmu.ml.proppr.prove.wam.Query) WamInterpreter(edu.cmu.ml.proppr.prove.wam.WamInterpreter) Test(org.junit.Test) GrounderTest(edu.cmu.ml.proppr.GrounderTest)

Example 2 with WamInterpreter

use of edu.cmu.ml.proppr.prove.wam.WamInterpreter in project ProPPR by TeamCohen.

the class WamInterpreterTest method test.

@Test
public void test() throws IOException {
    WamProgram program = WamBaseProgram.load(new File(SimpleProgramProverTest.PROGRAM));
    WamInterpreter interp = new WamInterpreter(program, new WamPlugin[0]);
    // ? :- coworker(steve,X).
    Query query = new Query(new Goal("coworker", new ConstantArgument("steve"), new ConstantArgument("X")));
    List<State> answers = findAnswers(interp, query);
    for (State s : answers) System.out.println(s);
    assertEquals(2, answers.size());
}
Also used : Goal(edu.cmu.ml.proppr.prove.wam.Goal) Query(edu.cmu.ml.proppr.prove.wam.Query) WamInterpreter(edu.cmu.ml.proppr.prove.wam.WamInterpreter) State(edu.cmu.ml.proppr.prove.wam.State) WamProgram(edu.cmu.ml.proppr.prove.wam.WamProgram) ConstantArgument(edu.cmu.ml.proppr.prove.wam.ConstantArgument) File(java.io.File) Test(org.junit.Test)

Aggregations

Query (edu.cmu.ml.proppr.prove.wam.Query)2 WamInterpreter (edu.cmu.ml.proppr.prove.wam.WamInterpreter)2 Test (org.junit.Test)2 GrounderTest (edu.cmu.ml.proppr.GrounderTest)1 ConstantArgument (edu.cmu.ml.proppr.prove.wam.ConstantArgument)1 Goal (edu.cmu.ml.proppr.prove.wam.Goal)1 Outlink (edu.cmu.ml.proppr.prove.wam.Outlink)1 State (edu.cmu.ml.proppr.prove.wam.State)1 WamProgram (edu.cmu.ml.proppr.prove.wam.WamProgram)1 Configuration (edu.cmu.ml.proppr.util.Configuration)1 File (java.io.File)1