Search in sources :

Example 66 with NAR

use of nars.NAR 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)

Example 67 with NAR

use of nars.NAR 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 68 with NAR

use of nars.NAR 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 69 with NAR

use of nars.NAR 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)

Example 70 with NAR

use of nars.NAR in project narchy by automenta.

the class BooleanChallenge method main.

public static void main(String[] args) {
    Global.DEBUG = true;
    NAR n = new NAR(new Equalized(1024, 4, 3).setInternalExperience(null));
    // NAR n = new NAR(new Discretinuous());
    // new NARPrologMirror(n, 0.95f, true, true, false);
    // NAR n = new CurveBagNARBuilder().builder();
    // new TraceWriter(n, System.out);
    new TextOutput(n, System.out);
    new BooleanChallenge(n, 2, 122550, 0.65f).getScore();
}
Also used : TextOutput(nars.io.out.TextOutput) Equalized(nars.nar.experimental.Equalized) NAR(nars.NAR)

Aggregations

NAR (nars.NAR)124 Test (org.junit.jupiter.api.Test)92 NARS (nars.NARS)23 Term (nars.term.Term)20 Truth (nars.truth.Truth)18 TestNAR (nars.test.TestNAR)16 BeliefTable (nars.table.BeliefTable)10 Disabled (org.junit.jupiter.api.Disabled)9 PrologCore (nars.op.prolog.PrologCore)8 Nullable (org.jetbrains.annotations.Nullable)8 Task (nars.Task)7 Concept (nars.concept.Concept)6 Param (nars.Param)5 Termed (nars.term.Termed)5 List (java.util.List)4 FasterList (jcog.list.FasterList)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 nars.$ (nars.$)3 ITask (nars.task.ITask)3 NALTest (nars.util.NALTest)3