Search in sources :

Example 1 with B

use of mb.nabl2.terms.build.TermBuild.B in project nabl by metaborg.

the class UnificationPerformanceTest method testCycle.

private static void testCycle() {
    System.out.println("Testing cycle");
    final IUnifier.Transient unifier = PersistentUnifier.Transient.of();
    ITermVar varA = TermBuild.B.newVar("", A);
    ITermVar varB = TermBuild.B.newVar("", B);
    ITermVar varC = TermBuild.B.newVar("", C);
    ITerm termB = TermBuild.B.newTuple(varB, varB);
    ITerm termC = TermBuild.B.newTuple(varC, varC);
    try {
        unifier.unify(varA, termB);
        unifier.unify(varB, termC);
        unifier.unify(varC, termB);
        System.out.println(unifier);
    } catch (UnificationException e) {
        System.out.println("Could not unify");
    }
    System.out.println("ground = " + unifier.isGround(termB));
    System.out.println("cyclic = " + unifier.isCyclic(termB));
    System.out.println("size = " + unifier.size(termB));
    System.out.println("vars = " + unifier.getVars(termB));
    System.out.println("equal = " + unifier.areEqual(termB, termC));
    System.out.println("unequal = " + unifier.areUnequal(termB, termC));
}
Also used : ITermVar(mb.nabl2.terms.ITermVar) ITerm(mb.nabl2.terms.ITerm)

Example 2 with B

use of mb.nabl2.terms.build.TermBuild.B in project nabl by metaborg.

the class UnificationPerformanceTest method testUnify.

private static IUnifier testUnify(int n) {
    final IUnifier.Transient unifier = PersistentUnifier.Transient.of();
    final ITerm left = TermBuild.B.newTuple(Iterables.concat(createVars(A, n), createTuples(B, n), Iterables2.singleton(createVar(A, n))));
    final ITerm right = TermBuild.B.newTuple(Iterables.concat(createTuples(A, n), createVars(B, n), Iterables2.singleton(createVar(B, n))));
    try {
        unifier.unify(left, right);
    } catch (UnificationException e) {
        System.err.println("Unification failed");
        e.printStackTrace(System.err);
    }
    System.out.println("ground = " + unifier.isGround(left));
    System.out.println("cyclic = " + unifier.isCyclic(left));
    System.out.println("size = " + unifier.size(left));
    System.out.println("vars = " + unifier.getVars(left));
    System.out.println("equal = " + unifier.areEqual(left, right));
    System.out.println("unequal = " + unifier.areUnequal(left, right));
    return unifier;
}
Also used : ITerm(mb.nabl2.terms.ITerm)

Example 3 with B

use of mb.nabl2.terms.build.TermBuild.B in project nabl by metaborg.

the class CExists method pp.

@Override
public IMessageContent pp() {
    // exists {a b c}. c
    final Builder builder = MessageContent.builder();
    builder.append("exists {");
    boolean first = true;
    for (ITermVar var : getEVars()) {
        if (first) {
            first = false;
        } else {
            builder.append(" ");
        }
        builder.append(var);
    }
    builder.append(": ");
    builder.append(getConstraint().pp());
    builder.append("}");
    return builder.build();
}
Also used : ITermVar(mb.nabl2.terms.ITermVar) Builder(mb.nabl2.constraints.messages.MessageContent.Builder)

Example 4 with B

use of mb.nabl2.terms.build.TermBuild.B in project nabl by metaborg.

the class CConj method pp.

@Override
public IMessageContent pp() {
    // a == b, c <? d
    final Builder builder = MessageContent.builder();
    builder.append(getLeft().pp());
    builder.append(", ");
    builder.append(getRight().pp());
    return builder.build();
}
Also used : Builder(mb.nabl2.constraints.messages.MessageContent.Builder)

Aggregations

Builder (mb.nabl2.constraints.messages.MessageContent.Builder)2 ITerm (mb.nabl2.terms.ITerm)2 ITermVar (mb.nabl2.terms.ITermVar)2