Search in sources :

Example 21 with Compound

use of nars.term.Compound in project narchy by automenta.

the class RevisionTest method testIntermpolation0invalid.

@Test
public void testIntermpolation0invalid() throws Narsese.NarseseException {
    Compound a = $.$("(a &&+3 (b &&+3 c))");
    Compound b = $.$("(a &&+1 b)");
    try {
        Set<Term> p = permuteChooses(a, b);
        fail("");
    } catch (Error e) {
        assertTrue(true);
    }
}
Also used : Compound(nars.term.Compound) Term(nars.term.Term) Test(org.junit.jupiter.api.Test)

Example 22 with Compound

use of nars.term.Compound in project narchy by automenta.

the class RevisionTest method testIntermpolationOrderPartialMismatch.

@Test
public void testIntermpolationOrderPartialMismatch() throws Narsese.NarseseException {
    Compound a = $.$("(a &&+1 (b &&+1 c))");
    Compound b = $.$("(a &&+1 (c &&+1 b))");
    permuteChoose(a, b, "[(a &&+1 (b&&c))]");
}
Also used : Compound(nars.term.Compound) Test(org.junit.jupiter.api.Test)

Example 23 with Compound

use of nars.term.Compound in project narchy by automenta.

the class SerialCompoundTest method assertEqual.

static void assertEqual(Compound x) {
    SerialCompound y = new SerialCompound(x);
    System.out.println(x + " encoded to " + y.length() + " bytes");
    assertTrue(y.length() > 1);
    Compound z = y.build();
    // assertNotSame(x, z); //<- when cached on construction, they may be the same
    assertEquals(x, z);
    assertEquals(x.subs(), z.subs());
    assertEquals(x.volume(), z.volume());
    assertEquals(x.toString(), z.toString());
}
Also used : Compound(nars.term.Compound)

Example 24 with Compound

use of nars.term.Compound in project narchy by automenta.

the class UnitCompoundTest method testUnitCompound2.

@Test
public void testUnitCompound2() {
    Atomic x = Atomic.the("x");
    Term c = $.p(x);
    System.out.println(c);
    System.out.println(c.sub(0));
    Compound d = $.inh(x, Atomic.the("y"));
    System.out.println(d);
}
Also used : Atomic(nars.term.atom.Atomic) Compound(nars.term.Compound) Term(nars.term.Term) Test(org.junit.jupiter.api.Test)

Example 25 with Compound

use of nars.term.Compound in project narchy by automenta.

the class EllipsisTest method testCombinations.

static void testCombinations(Compound _X, Compound Y, int expect) {
    Compound X = (Compound) new PatternIndex().pattern(_X);
    for (int seed = 0; seed < 3; /*expect*5*/
    seed++) {
        Set<String> results = $.newHashSet(0);
        Random rng = new XorShift128PlusRandom(seed);
        Unify f = new Unify(VAR_PATTERN, rng, Param.UnificationStackMax, 128) {

            @Override
            public void tryMatch() {
                results.add(xy.toString());
            }
        };
        f.unify(X, Y, true);
        results.forEach(System.out::println);
        assertEquals(expect, results.size(), () -> "insufficient permutations for: " + X + " .. " + Y);
    }
}
Also used : Unify(nars.term.subst.Unify) XorShift128PlusRandom(jcog.math.random.XorShift128PlusRandom) Random(java.util.Random) XorShift128PlusRandom(jcog.math.random.XorShift128PlusRandom) Compound(nars.term.Compound) PatternIndex(nars.index.term.PatternIndex)

Aggregations

Compound (nars.term.Compound)58 Test (org.junit.jupiter.api.Test)38 Term (nars.term.Term)20 Unify (nars.term.subst.Unify)3 FasterList (jcog.list.FasterList)2 XorShift128PlusRandom (jcog.math.random.XorShift128PlusRandom)2 Op (nars.Op)2 PatternCompound (nars.derive.PatternCompound)2 PatternIndex (nars.index.term.PatternIndex)2 Atomic (nars.term.atom.Atomic)2 Variable (nars.term.var.Variable)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 alice.tuprolog (alice.tuprolog)1 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Prioritized (jcog.pri.Prioritized)1 Narsese (nars.Narsese)1