Search in sources :

Example 1 with AgreeException

use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.

the class TcgLinkerFactory method createVerification.

protected AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram) {
    AgreeRenaming agreeRenaming = new AgreeRenaming();
    AgreeLayout layout = new AgreeLayout();
    RenamingVisitor.addRenamings(lustreProgram, agreeRenaming, compInst, layout);
    TcgRenaming renaming = new TcgRenaming(agreeRenaming, agreeRenaming.getRefMap());
    Node mainNode = lustreProgram.getMainNode();
    if (mainNode == null) {
        throw new AgreeException("Could not find main lustre node after translation");
    }
    List<String> properties = new ArrayList<>();
    JKindResult result;
    result = new JKindResult(resultName, properties, renaming);
    queue.add(result);
    ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(compInst);
    linker.setAgreeProgram(result, agreeProgram);
    linker.setProgram(result, lustreProgram);
    linker.setComponent(result, compImpl);
    linker.setContract(result, getContract(compImpl));
    linker.setLayout(result, layout);
    // linker.setReferenceMap(result, renaming.getRefMap());
    linker.setLog(result, AgreeLogger.getLog());
    linker.setRenaming(result, renaming);
    // System.out.println(program);
    return result;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming) JKindResult(jkind.api.results.JKindResult)

Example 2 with AgreeException

use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.

the class AgreeASTBuilder method caseTagExpr.

@Override
public Expr caseTagExpr(TagExpr e) {
    String stemString = null;
    if (e.getStem() instanceof NamedElmExpr) {
        stemString = ((NamedElmExpr) e.getStem()).getElm().getName();
    } else if (e.getStem() instanceof SelectionExpr) {
        stemString = dottedNameToString(e.getStem());
    } else {
        throw new AgreeException("Pattern");
    }
    String tag = e.getTag();
    if (tag != null) {
        switch(tag) {
            case "_CLK":
                IdExpr clockId = new IdExpr(stemString + clockIDSuffix);
                return clockId;
            default:
                throw new AgreeException("use of uknown tag: '" + tag + "' in expression following " + stemString);
        }
    }
    throw new AgreeException("Pattern");
}
Also used : IdExpr(jkind.lustre.IdExpr) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr)

Example 3 with AgreeException

use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.

the class AgreeASTBuilder method caseExistsExpr.

@Override
public Expr caseExistsExpr(ExistsExpr expr) {
    com.rockwellcollins.atc.agree.agree.Expr arrayExpr = expr.getArray();
    Expr array = doSwitch(arrayExpr);
    AgreeTypeSystem.TypeDef agreeType = AgreeTypeSystem.infer(arrayExpr);
    int size = 0;
    if (agreeType instanceof AgreeTypeSystem.ArrayTypeDef) {
        size = ((AgreeTypeSystem.ArrayTypeDef) agreeType).size;
    } else {
        throw new AgreeException("ERROR: caseExistsExpr - '" + agreeType.getClass() + "' not handled");
    }
    NamedID binding = expr.getBinding();
    Expr final_expr = new BoolExpr(false);
    for (int i = 0; i < size; ++i) {
        Expr arrayAccess = new ArrayAccessExpr(array, i);
        Expr body = doSwitch(expr.getExpr()).accept(new SubstitutionVisitor(binding.getName(), arrayAccess));
        final_expr = LustreExprFactory.makeORExpr(final_expr, body);
    }
    return final_expr;
}
Also used : BoolExpr(jkind.lustre.BoolExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) NamedID(com.rockwellcollins.atc.agree.agree.NamedID) AgreeTypeSystem(com.rockwellcollins.atc.agree.AgreeTypeSystem) SubstitutionVisitor(jkind.translation.SubstitutionVisitor) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) ArrayExpr(jkind.lustre.ArrayExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) IdExpr(jkind.lustre.IdExpr) TimeExpr(com.rockwellcollins.atc.agree.agree.TimeExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) IntExpr(jkind.lustre.IntExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Example 4 with AgreeException

use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.

the class AgreeASTBuilder method getSynchConstraint.

private Expr getSynchConstraint(SynchStatement spec, List<AgreeNode> subNodes) {
    int val1 = Integer.decode(spec.getVal());
    if (val1 == 0) {
        return new BoolExpr(true);
    }
    List<Expr> clockIds = new ArrayList<>();
    Expr clockAssertion;
    for (AgreeNode subNode : subNodes) {
        clockIds.add(new IdExpr(subNode.clockVar.id));
    }
    String dfaPrefix = getObjectLocationPrefix(spec);
    if (spec.getVal2() == null) {
        Node dfaNode = AgreeCalendarUtils.getDFANode(dfaPrefix + "__DFA_NODE", val1);
        Node calNode = AgreeCalendarUtils.getCalendarNode(dfaPrefix + "__CALENDAR_NODE", dfaNode.id, clockIds.size());
        // we do not need to make copies of the nodes if they exist
        if (!nodeNameExists(dfaNode.id)) {
            if (nodeNameExists(calNode.id)) {
                throw new AgreeException("The calander node should not exist if the dfa node does not exist");
            }
            addToNodeList(dfaNode);
            addToNodeList(calNode);
        }
        clockAssertion = new NodeCallExpr(calNode.id, clockIds);
    } else {
        int val2 = Integer.decode(spec.getVal2());
        String nodeName = "__calendar_node_" + val1 + "_" + val2;
        nodeName = dfaPrefix + nodeName;
        Node calNode = AgreeCalendarUtils.getMNCalendar(nodeName, val1, val2);
        if (!nodeNameExists(calNode.id)) {
            addToNodeList(calNode);
        }
        clockAssertion = new BoolExpr(true);
        int i, j;
        for (i = 0; i < clockIds.size(); i++) {
            Expr clock1 = clockIds.get(i);
            for (j = i + 1; j < clockIds.size(); j++) {
                Expr clock2 = clockIds.get(j);
                NodeCallExpr nodeCall = new NodeCallExpr(nodeName, clock1, clock2);
                clockAssertion = LustreExprFactory.makeANDExpr(clockAssertion, nodeCall);
                nodeCall = new NodeCallExpr(nodeName, clock2, clock1);
                clockAssertion = LustreExprFactory.makeANDExpr(clockAssertion, nodeCall);
            }
        }
    }
    return clockAssertion;
}
Also used : BoolExpr(jkind.lustre.BoolExpr) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) ArrayExpr(jkind.lustre.ArrayExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) IdExpr(jkind.lustre.IdExpr) TimeExpr(com.rockwellcollins.atc.agree.agree.TimeExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) IntExpr(jkind.lustre.IntExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Example 5 with AgreeException

use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.

the class AgreeASTBuilder method portToAgreeVar.

private void portToAgreeVar(List<AgreeVar> outputs, List<AgreeVar> inputs, FeatureInstance feature, List<AgreeStatement> assumptions, List<AgreeStatement> guarantees) {
    Feature dataFeature = feature.getFeature();
    NamedElement dataClass;
    if (dataFeature instanceof DataPort) {
        DataPort dataPort = (DataPort) dataFeature;
        dataClass = dataPort.getDataFeatureClassifier();
    } else if (dataFeature instanceof EventDataPort) {
        EventDataPort eventDataPort = (EventDataPort) dataFeature;
        dataClass = eventDataPort.getDataFeatureClassifier();
    } else {
        dataClass = null;
    }
    String name = feature.getName();
    boolean isEvent = feature.getCategory() == FeatureCategory.EVENT_DATA_PORT || feature.getCategory() == FeatureCategory.EVENT_PORT;
    if (isEvent) {
        AgreeVar var = new AgreeVar(name + eventSuffix, NamedType.BOOL, feature.getFeature(), feature.getComponentInstance(), feature);
        switch(feature.getDirection()) {
            case IN:
                inputs.add(var);
                break;
            case OUT:
                outputs.add(var);
                break;
            default:
                throw new AgreeException("Unable to reason about bi-directional event port: " + dataFeature.getQualifiedName());
        }
    }
    if (dataClass == null) {
        // we do not reason about this type
        return;
    }
    AgreeTypeSystem.TypeDef td = AgreeTypeSystem.inferFromNamedElement(dataFeature);
    Type type = symbolTable.updateLustreTypeMap(td);
    if (type == null) {
        // we do not reason about this type
        return;
    }
    AgreeVar agreeVar = new AgreeVar(name, type, feature.getFeature(), feature.getComponentInstance(), feature);
    switch(feature.getDirection()) {
        case IN:
            inputs.add(agreeVar);
            if (dataClass instanceof DataClassifier) {
                List<Expr> constraints = getConstraintsFromTypeDef(name, td);
                if (!constraints.isEmpty()) {
                    assumptions.add(getDataClassifierTypePredicate(feature.getName(), constraints, dataFeature));
                }
            }
            break;
        case OUT:
            outputs.add(agreeVar);
            if (dataClass instanceof DataClassifier) {
                List<Expr> constraints = getConstraintsFromTypeDef(name, td);
                if (!constraints.isEmpty()) {
                    guarantees.add(getDataClassifierTypePredicate(feature.getName(), constraints, dataFeature));
                }
            }
            break;
        default:
            throw new AgreeException("Unable to reason about bi-directional event port: " + dataFeature.getQualifiedName());
    }
}
Also used : DataClassifier(org.osate.aadl2.DataClassifier) Feature(org.osate.aadl2.Feature) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) AgreeTypeSystem(com.rockwellcollins.atc.agree.AgreeTypeSystem) ConnectionType(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection.ConnectionType) Type(jkind.lustre.Type) NamedType(jkind.lustre.NamedType) FeatureGroupType(org.osate.aadl2.FeatureGroupType) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) ComponentType(org.osate.aadl2.ComponentType) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) ArrayExpr(jkind.lustre.ArrayExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) IdExpr(jkind.lustre.IdExpr) TimeExpr(com.rockwellcollins.atc.agree.agree.TimeExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) IntExpr(jkind.lustre.IntExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) EventDataPort(org.osate.aadl2.EventDataPort) NamedElement(org.osate.aadl2.NamedElement)

Aggregations

AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)47 IdExpr (jkind.lustre.IdExpr)23 Expr (jkind.lustre.Expr)21 BinaryExpr (jkind.lustre.BinaryExpr)19 BoolExpr (jkind.lustre.BoolExpr)18 NodeCallExpr (jkind.lustre.NodeCallExpr)18 UnaryExpr (jkind.lustre.UnaryExpr)18 ArrayList (java.util.ArrayList)16 IntExpr (jkind.lustre.IntExpr)15 ComponentImplementation (org.osate.aadl2.ComponentImplementation)13 SelectionExpr (com.rockwellcollins.atc.agree.agree.SelectionExpr)12 IfThenElseExpr (jkind.lustre.IfThenElseExpr)12 GetPropertyExpr (com.rockwellcollins.atc.agree.agree.GetPropertyExpr)11 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)11 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)11 RealLitExpr (com.rockwellcollins.atc.agree.agree.RealLitExpr)11 ArrayLiteralExpr (com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr)10 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)10 ArrayUpdateExpr (com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr)10 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)10