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);
}
}
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))]");
}
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());
}
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);
}
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);
}
}
Aggregations