use of jkind.lustre.BoolExpr in project AGREE by loonwerks.
the class InputConstraintToLustreValueExpression method lustreExprToValue.
// Only binary, unary, and literal expressions are supported
private static Value lustreExprToValue(final Expr lustreExpr) {
if (lustreExpr instanceof BoolExpr) {
return BooleanValue.fromBoolean(((BoolExpr) lustreExpr).value);
} else if (lustreExpr instanceof IntExpr) {
return new IntegerValue(((IntExpr) lustreExpr).value);
} else if (lustreExpr instanceof RealExpr) {
final RealExpr realExpr = (RealExpr) lustreExpr;
return new RealValue(BigFraction.valueOf(realExpr.value));
} else if (lustreExpr instanceof BinaryExpr) {
final BinaryExpr binaryExpr = (BinaryExpr) lustreExpr;
final Value leftValue = lustreExprToValue(binaryExpr.left);
final Value rightValue = lustreExprToValue(binaryExpr.right);
return leftValue.applyBinaryOp(binaryExpr.op, rightValue);
} else if (lustreExpr instanceof UnaryExpr) {
final UnaryExpr unaryExpr = (UnaryExpr) lustreExpr;
final Value operandValue = lustreExprToValue(unaryExpr.expr);
return operandValue.applyUnaryOp(unaryExpr.op);
}
throw new RuntimeException("Unsupported expression: " + lustreExpr);
}
use of jkind.lustre.BoolExpr in project AGREE by loonwerks.
the class Main method testBoolean.
private static void testBoolean() throws IOException {
System.out.println("=============Boolean Test=============");
final Evaluator baseEvaluator = createEvaluator(INPUT_DIRECTORY + "symb_test_bool.lus");
final Evaluator evaluator = new Evaluator(baseEvaluator, Arrays.asList(new BinaryExpr(new IdExpr("__SIM_PE__TOP__ss__TILDE__0__DOT____GUARANTEE0"), BinaryOp.EQUAL, new BoolExpr(true)), new BinaryExpr(new IdExpr("__SIM_PE__TOP__ss__TILDE__0__DOT____GUARANTEE1"), BinaryOp.EQUAL, new BoolExpr(true)), new BinaryExpr(new IdExpr("in1"), BinaryOp.EQUAL, new BoolExpr(true)), new BinaryExpr(new IdExpr("in2"), BinaryOp.EQUAL, new BoolExpr(true))));
testValue("in1", evaluator, BooleanValue.TRUE);
testValue("in2", evaluator, BooleanValue.TRUE);
testValue("out1", evaluator, BooleanValue.TRUE);
testValue("out2", evaluator, BooleanValue.TRUE);
}
use of jkind.lustre.BoolExpr in project AGREE by loonwerks.
the class AgreeCalendarUtils method getAllClksHaveTicked.
public static List<Equation> getAllClksHaveTicked(String name, String clkPref, List<Expr> clks) {
Expr result = new BoolExpr(true);
List<Equation> eqs = new ArrayList<>();
int i = 0;
for (Expr clk : clks) {
Equation clkHasTicked = getClkHasTicked(new IdExpr(clkPref + i), clk);
result = new BinaryExpr(result, BinaryOp.AND, clkHasTicked.lhs.get(0));
eqs.add(clkHasTicked);
i++;
}
eqs.add(new Equation(new IdExpr(name), result));
return eqs;
}
Aggregations