Search in sources :

Example 6 with ObligationSet

use of com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet in project AGREE by loonwerks.

the class GenerateUfcObligationsVisitor method visit.

@Override
public ObligationSet visit(BinaryExpr e) {
    if (e.op == BinaryOp.AND) {
        ObligationSet lhs = e.left.accept(this);
        ObligationSet rhs = e.right.accept(this);
        lhs.extendContext(e.right);
        rhs.extendContext(e.left);
        lhs.addAll(rhs);
        return lhs;
    } else if (e.op == BinaryOp.OR) {
        ObligationSet lhs = e.left.accept(this);
        ObligationSet rhs = e.right.accept(this);
        lhs.extendContext(notExpr(e.right));
        rhs.extendContext(notExpr(e.left));
        lhs.addAll(rhs);
        return lhs;
    } else if (e.op == BinaryOp.IMPLIES) {
        Expr equivExpr = binExpr(notExpr(e.left), BinaryOp.OR, e.right);
        return equivExpr.accept(this);
    } else if (e.op == BinaryOp.ARROW) {
        ObligationSet lhs = e.left.accept(this);
        ObligationSet rhs = e.right.accept(this);
        lhs.makeInitStepOnly();
        rhs.makeAfter1Only();
        lhs.addAll(rhs);
        return lhs;
    } else if (isBoolExpr(e.left)) {
        if (e.op == BinaryOp.XOR || e.op == BinaryOp.NOTEQUAL) {
            Expr equivExpr = notExpr(binExpr(e.left, BinaryOp.EQUAL, e.right));
            return equivExpr.accept(this);
        } else if (e.op == BinaryOp.EQUAL) {
            Expr equivExpr = binExpr(binExpr(e.left, BinaryOp.AND, e.right), BinaryOp.OR, notExpr(binExpr(e.left, BinaryOp.OR, e.right)));
            return equivExpr.accept(this);
        } else {
            // other relational operator over booleans (this may be dead code)
            ObligationSet lhs = e.left.accept(this);
            ObligationSet rhs = e.right.accept(this);
            lhs.addAll(rhs);
            return baseExpr(e, lhs);
        }
    } else {
        // Other kind of operator (arithmetic?)
        ObligationSet lhs = e.left.accept(this);
        ObligationSet rhs = e.right.accept(this);
        lhs.addAll(rhs);
        return baseExpr(e, lhs);
    }
}
Also used : ObligationSet(com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet) RecordAccessExpr(jkind.lustre.RecordAccessExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) RecordUpdateExpr(jkind.lustre.RecordUpdateExpr) CondactExpr(jkind.lustre.CondactExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) IntExpr(jkind.lustre.IntExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) RecordExpr(jkind.lustre.RecordExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) ArrayExpr(jkind.lustre.ArrayExpr) IdExpr(jkind.lustre.IdExpr) ArrayUpdateExpr(jkind.lustre.ArrayUpdateExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr)

Example 7 with ObligationSet

use of com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet in project AGREE by loonwerks.

the class GenerateUfcObligationsVisitor method visit.

@Override
public ObligationSet visit(ArrayUpdateExpr e) {
    ObligationSet obs1 = e.array.accept(this);
    ObligationSet obs2 = e.index.accept(this);
    ObligationSet obs3 = e.value.accept(this);
    obs1.addAll(obs2);
    obs1.addAll(obs3);
    return baseExpr(e, obs1);
}
Also used : ObligationSet(com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet)

Example 8 with ObligationSet

use of com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet in project AGREE by loonwerks.

the class GenerateUfcObligationsVisitor method visit.

@Override
public ObligationSet visit(Equation equation) {
    ObligationSet result = new ObligationSet();
    boolean isGuaranteeEq = equation.lhs.size() == 1 && equation.lhs.get(0).id.startsWith(GenerateUfcObligationsVisitor.GUARANTEE_PREFIX);
    boolean isAssumptionEq = false;
    /* how do we determine this? */
    boolean isNormalEq = !isGuaranteeEq;
    if (this.generateGuaranteeObligations && isGuaranteeEq) {
        if (equation.lhs.size() == 1 && equation.lhs.get(0).id.startsWith(GenerateUfcObligationsVisitor.GUARANTEE_PREFIX)) {
            result = expr(equation.expr);
        }
    } else if (this.generateAssumptionObligations && isAssumptionEq) {
        result = expr(equation.expr);
    } else if (this.generateEqObligations && isNormalEq) {
        result = expr(equation.expr);
    } else if (this.generatePropertyObligations) {
        // Check if the equation is for a property in the current node
        if (equation.lhs.size() == 1 && currentNode != null && currentNode.properties.contains(equation.lhs.get(0).id)) {
            result = expr(equation.expr);
        }
    }
    if (!equation.lhs.isEmpty()) {
        result.setEqId(equation.lhs.get(0).id);
    }
    return result;
}
Also used : ObligationSet(com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet)

Example 9 with ObligationSet

use of com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet in project AGREE by loonwerks.

the class GenerateUfcObligationsVisitor method constructNewProgram.

public Program constructNewProgram() {
    List<Node> nodes = new ArrayList<>();
    for (Entry<Node, ObligationSet> nodeElem : obligations.entrySet()) {
        nodes.add(constructNewNode(nodeElem.getKey(), nodeElem.getValue()));
    }
    Program newProgram = new Program(initialProgram.location, initialProgram.types, initialProgram.constants, Collections.emptyList(), nodes, initialProgram.main);
    return newProgram;
}
Also used : ObligationSet(com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet) Program(jkind.lustre.Program) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList)

Aggregations

ObligationSet (com.rockwellcollins.atc.tcg.obligations.ufc.ObligationSet)9 ArrayAccessExpr (jkind.lustre.ArrayAccessExpr)3 ArrayExpr (jkind.lustre.ArrayExpr)3 ArrayUpdateExpr (jkind.lustre.ArrayUpdateExpr)3 BinaryExpr (jkind.lustre.BinaryExpr)3 BoolExpr (jkind.lustre.BoolExpr)3 CastExpr (jkind.lustre.CastExpr)3 CondactExpr (jkind.lustre.CondactExpr)3 Expr (jkind.lustre.Expr)3 FunctionCallExpr (jkind.lustre.FunctionCallExpr)3 IdExpr (jkind.lustre.IdExpr)3 IfThenElseExpr (jkind.lustre.IfThenElseExpr)3 IntExpr (jkind.lustre.IntExpr)3 NodeCallExpr (jkind.lustre.NodeCallExpr)3 RealExpr (jkind.lustre.RealExpr)3 RecordAccessExpr (jkind.lustre.RecordAccessExpr)3 RecordExpr (jkind.lustre.RecordExpr)3 RecordUpdateExpr (jkind.lustre.RecordUpdateExpr)3 TupleExpr (jkind.lustre.TupleExpr)3 UnaryExpr (jkind.lustre.UnaryExpr)3