Search in sources :

Example 1 with PrologCore

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

the class PrologCoreTest method testPrologCoreDerivedTransitive.

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

Example 2 with PrologCore

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

the class PrologCoreTest method testPrologCoreQuestionTruthAnswer.

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

Example 3 with PrologCore

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

the class PrologCoreTest method testConjunction3.

@Test
public void testConjunction3() throws Narsese.NarseseException {
    NAR n = NARS.tmp();
    PrologCore p = new PrologCore(n);
    n.input("(&&,a,b,c).");
    n.run(1);
    assertTrue(p.isTrue("'&&'(a,b,c)."));
    assertTrue(p.isTrue("a,b,c."));
// assertTrue(p.isTrue("','(a,','(b,c))."));
}
Also used : PrologCore(nars.op.prolog.PrologCore) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Example 4 with PrologCore

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

the class PrologCoreTest method testPrologCoreBeliefAssertion.

@Test
public void testPrologCoreBeliefAssertion() throws Narsese.NarseseException {
    NAR n = NARS.tmp();
    PrologCore p = new PrologCore(n);
    n.input("a:b.");
    n.input("(--, c:d).");
    n.run(1);
    assertTrue(p.isTrue("'-->'(b,a)."));
    assertFalse(p.isTrue("'-->'(a,b)."));
    assertTrue(p.isTrue("'--'('-->'(d,c))."));
    assertFalse(p.isTrue("'-->'(d,c)."));
}
Also used : PrologCore(nars.op.prolog.PrologCore) NAR(nars.NAR) Test(org.junit.jupiter.api.Test)

Example 5 with PrologCore

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

the class PrologCoreTest method testConjunction3b.

@Test
public void testConjunction3b() throws Exception {
    NAR n = NARS.tmp();
    Param.DEBUG = true;
    PrologCore p = new PrologCore(n);
    n.believe("x:a");
    assertTrue(p.isTrue("'-->'(a,x)."));
    assertFalse(p.isTrue("'-->'(a,y)."));
    n.believe("y:b");
    n.believe("z:c", false);
    n.run(1);
    assertTrue(p.isTrue("'-->'(a,x), '-->'(b,y)."));
    assertTrue(p.isTrue("'-->'(a,x), '-->'(b,y), '--'('-->'(c,z))."));
    assertFalse(p.isTrue("'-->'(a,x), '-->'(b,y), '-->'(c,z)."));
// assertTrue(p.isTrue("','(a,','(b,c))."));
}
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