Search in sources :

Example 6 with PrologCore

use of nars.op.prolog.PrologCore in project narchy by automenta.

the class PrologCoreTest method testPrologCoreDerivedTransitive2.

@Test
public void testPrologCoreDerivedTransitive2() throws Narsese.NarseseException {
    NAR n = NARS.tmp();
    PrologCore p = new PrologCore(n);
    n.input("a:b.");
    n.input("b:c.");
    n.input("c:d.");
    n.input("d:e.");
    n.input("e:f.");
    n.run(1);
    n.input("a:f?");
    // expect true
    n.run(1);
    n.input("a:?x?");
    // expect true
    n.run(1);
}
Also used : PrologCore(nars.op.prolog.PrologCore) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Example 7 with PrologCore

use of nars.op.prolog.PrologCore in project narchy by automenta.

the class PrologCoreTest method testPrologShell.

@Test
public void testPrologShell() throws MalformedGoalException {
    NAR n = NARS.tmp();
    PrologCore p = new PrologCore(n);
    try {
        p.input(new Theory(PrologCoreTest.class.getClassLoader().getResource("shell.prolog").openStream()));
    } catch (InvalidTheoryException | IOException e) {
        e.printStackTrace();
    }
    p.solve("do(help).");
}
Also used : PrologCore(nars.op.prolog.PrologCore) Theory(alice.tuprolog.Theory) InvalidTheoryException(alice.tuprolog.InvalidTheoryException) IOException(java.io.IOException) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Example 8 with PrologCore

use of nars.op.prolog.PrologCore in project narchy by automenta.

the class PrologCoreTest method testPrologCoreImplToRule.

@Test
public void testPrologCoreImplToRule() throws Narsese.NarseseException {
    NAR n = NARS.tmp(1);
    n.log();
    Param.DEBUG = true;
    PrologCore p = new PrologCore(n);
    n.input("f(x,y).");
    n.input("(f($x,$y)==>g($y,$x)).");
    n.run(1);
    n.input("g(x,y)?");
    n.input("g(y,x)?");
    n.run(1);
    assertEquals(1f, n.beliefTruth("g(y,x)", ETERNAL).freq());
    assertNull(n.beliefTruth("g(x,y)", ETERNAL));
}
Also used : PrologCore(nars.op.prolog.PrologCore) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Aggregations

NAR (nars.NAR)8 PrologCore (nars.op.prolog.PrologCore)8 Test (org.junit.jupiter.api.Test)8 InvalidTheoryException (alice.tuprolog.InvalidTheoryException)1 Theory (alice.tuprolog.Theory)1 IOException (java.io.IOException)1