use of de.bmoth.backend.TranslationOptions in project bmoth by hhu-stups.
the class MachineTranslatorTest method testInvariantGeneration.
@Test
public void testInvariantGeneration() {
assertEquals(translator.getInvariantConstraint(), translator.getInvariantConstraint(TranslationOptions.UNPRIMED));
assertEquals("(let ((a!1 (forall ((a Int) (b Int))\n" + " (! (let ((a!1 (ite (= 0 (mod b 2))\n" + " (* (POWER_OF a (div b 2))\n" + " (POWER_OF a (div b 2)))\n" + " (* a (POWER_OF a (- b 1))))))\n" + " (= (POWER_OF a b) (ite (= 0 b) 1 a!1)))\n" + " :pattern ((POWER_OF a b))\n" + " :weight 2\n" + " :qid |:rec-fun|))))\n" + " (and true (= (POWER_OF x 2) (* x x)) a!1))", translator.getInvariantConstraint().toString());
assertEquals("(let ((a!1 (forall ((a Int) (b Int))\n" + " (! (let ((a!1 (ite (= 0 (mod b 2))\n" + " (* (POWER_OF a (div b 2))\n" + " (POWER_OF a (div b 2)))\n" + " (* a (POWER_OF a (- b 1))))))\n" + " (= (POWER_OF a b) (ite (= 0 b) 1 a!1)))\n" + " :pattern ((POWER_OF a b))\n" + " :weight 2\n" + " :qid |:rec-fun|))))\n" + " (and true (= (POWER_OF |x'24| 2) (* |x'24| |x'24|)) a!1))", translator.getInvariantConstraint(new TranslationOptions(24)).toString());
}
use of de.bmoth.backend.TranslationOptions in project bmoth by hhu-stups.
the class MachineTranslatorTest method testInitialValueGeneration.
@Test
public void testInitialValueGeneration() {
assertEquals(translator.getInitialValueConstraint(), translator.getInitialValueConstraint(TranslationOptions.PRIMED_0));
assertEquals("(= |x'0| (- 3))", translator.getInitialValueConstraint().toString());
assertEquals("(= |x'1024| (- 3))", translator.getInitialValueConstraint(new TranslationOptions(1024)).toString());
}
use of de.bmoth.backend.TranslationOptions in project bmoth by hhu-stups.
the class MachineToZ3Translator method getDistinctVars.
public BoolExpr getDistinctVars(int from, int to) {
if (tuple == null) {
Expr[] variables = getVariables().stream().map(this::getVariable).toArray(Expr[]::new);
Symbol[] symbols = Arrays.stream(variables).map(var -> var.getFuncDecl().getName()).toArray(Symbol[]::new);
Sort[] sorts = Arrays.stream(variables).map(Expr::getSort).toArray(Sort[]::new);
tuple = z3Context.mkTupleSort(z3Context.mkSymbol("tuple"), symbols, sorts);
}
Expr[] distinct = new Expr[to - from + 1];
for (int v = from, i = 0; v <= to; v++, i++) {
int finalV = v;
Expr[] vector = getVariables().stream().map(var -> getPrimedVariable(var, new TranslationOptions(finalV))).toArray(Expr[]::new);
distinct[i] = tuple.mkDecl().apply(vector);
}
return z3Context.mkDistinct(distinct);
}
use of de.bmoth.backend.TranslationOptions in project bmoth by hhu-stups.
the class TranslationOptionTest method testToString.
@Test
public void testToString() {
TranslationOptions ops = new TranslationOptions(234);
assertEquals("prime level 234", ops.toString());
assertEquals("prime level 0", PRIMED_0.toString());
assertEquals("not primed", UNPRIMED.toString());
}
use of de.bmoth.backend.TranslationOptions in project bmoth by hhu-stups.
the class MachineTranslatorTest method testOperationsGeneration.
@Test
public void testOperationsGeneration() {
assertEquals(1, translator.getOperationConstraints().size());
assertEquals(translator.getOperationConstraints(), translator.getOperationConstraints(new SubstitutionOptions(TranslationOptions.PRIMED_0, TranslationOptions.UNPRIMED)));
assertEquals("[(and (< x 50) (= |x'0| (+ x 1)))]", translator.getOperationConstraints().toString());
assertEquals("[(and (< |x'128| 50) (= |x'512| (+ |x'128| 1)))]", translator.getOperationConstraints(new SubstitutionOptions(new TranslationOptions(512), new TranslationOptions(128))).toString());
}
Aggregations