use of nars.term.var.Variable in project narchy by automenta.
the class NoCommonSubtermConstraint method isSubtermOfTheOther.
static boolean isSubtermOfTheOther(Term a, Term b, boolean recurse, boolean excludeVariables) {
if ((excludeVariables) && (a instanceof Variable || b instanceof Variable))
return false;
int av = a.volume();
int bv = b.volume();
if (av == bv) {
// impossible for either to contain the other
return false;
} else {
if (av < bv) {
// swap
Term c = a;
a = b;
b = c;
}
return recurse ? a.containsRecursively(b, true, limit) : a.containsRoot(b);
}
}
use of nars.term.var.Variable in project narchy by automenta.
the class TermIOTest method testTermSerialization3_2.
@Test
public void testTermSerialization3_2() throws Narsese.NarseseException {
// multiple variables
Variable q = $.varQuery(1);
Compound twoB = $.inh($.varDep(2), Atomic.the("b"));
assertNotEquals(q.compareTo(twoB), twoB.compareTo(q));
assertTermEqualSerialize("((#a --> b) <-> ?c)");
Term a = $("(#2-->b)");
Term b = $("?1");
int x = a.compareTo(b);
int y = b.compareTo(a);
assertNotEquals((int) Math.signum(x), (int) Math.signum(y));
}
use of nars.term.var.Variable in project narchy by automenta.
the class LinkageTest method links.
public boolean links(@NotNull String premise1, String premise2, @NotNull TestNAR tester) throws Narsese.NarseseException {
Concept ret = tester.nar.conceptualize(premise1);
boolean passed = false;
if (ret != null) {
for (PriReference<Term> entry : ret.termlinks()) {
Term et1 = entry.get().term();
if (et1.toString().equals(premise2)) {
passed = true;
break;
}
if (!(et1 instanceof Variable)) {
Concept Wc = tester.nar.concept(et1);
if (Wc != null) {
for (PriReference<Term> entry2 : Wc.termlinks()) {
Term et2 = entry2.get().term();
if (et2.toString().equals(premise2)) {
passed = true;
break;
}
Concept Wc2 = tester.nar.concept(et2);
if (Wc2 != null) {
for (PriReference<Term> entry3 : Wc2.termlinks()) {
Term et3 = entry3.get().term();
if (et3.toString().equals(premise2)) {
passed = true;
break;
}
}
}
}
}
}
/*if (w.toString().equals(premise2)) {
passed = true;
}*/
}
}
return passed;
}
use of nars.term.var.Variable in project narchy by automenta.
the class NarseseBaseTest method testVariables.
@Test
public void testVariables() throws Narsese.NarseseException {
Variable v;
v = testVar(Op.VAR_DEP.ch);
assertTrue(v.hasVarDep());
v = testVar(Op.VAR_INDEP.ch);
assertTrue(v.hasVarIndep());
v = testVar(Op.VAR_QUERY.ch);
assertTrue(v.hasVarQuery());
}
use of nars.term.var.Variable in project narchy by automenta.
the class CommonVariableTest method testInvalid.
@Test
public void testInvalid() {
assertThrows(RuntimeException.class, () -> {
Variable p1p1 = CommonVariable.common(p1, p1);
assertEquals("#x1y1", p1p1.toString());
});
}
Aggregations