Search in sources :

Example 21 with AgreeNode

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

the class AgreePatternTranslator method translate.

public static AgreeProgram translate(AgreeProgram program) {
    List<Node> patternLustreNodes = new ArrayList<>();
    // reset the static variable before refreshing its values in translateNode call
    containsRealTimePatterns = false;
    AgreeNode topNode = new AgreePatternTranslator().translateNode(program.topNode, true);
    List<AgreeNode> agreeNodes = gatherNodes(topNode);
    patternLustreNodes.addAll(program.globalLustreNodes);
    return new AgreeProgram(agreeNodes, patternLustreNodes, program.uninterpretedFunctions, program.globalTypes, topNode, containsRealTimePatterns);
}
Also used : AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram)

Example 22 with AgreeNode

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

the class VerifyHandler method addKind2Properties.

protected void addKind2Properties(AgreeNode agreeNode, List<String> properties, AgreeRenaming renaming, String prefix, String userPropPrefix) {
    int i = 0;
    String propPrefix = (userPropPrefix.equals("")) ? "" : userPropPrefix + ": ";
    for (AgreeStatement statement : agreeNode.lemmas) {
        renaming.addExplicitRename(prefix + "[" + (++i) + "]", propPrefix + statement.string);
        properties.add(prefix.replaceAll("\\.", AgreeASTBuilder.dotChar) + "[" + i + "]");
    }
    for (AgreeStatement statement : agreeNode.guarantees) {
        renaming.addExplicitRename(prefix + "[" + (++i) + "]", propPrefix + statement.string);
        properties.add(prefix.replaceAll("\\.", AgreeASTBuilder.dotChar) + "[" + i + "]");
    }
    userPropPrefix = userPropPrefix.equals("") ? "" : userPropPrefix + ".";
    for (AgreeNode subNode : agreeNode.subNodes) {
        addKind2Properties(subNode, properties, renaming, prefix + "." + subNode.id, userPropPrefix + subNode.id);
    }
}
Also used : AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode)

Example 23 with AgreeNode

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

the class AgreeASTMapVisitor method visit.

@Override
public AgreeConnection visit(AgreeConnection e) {
    if (e instanceof AgreeAADLConnection) {
        AgreeAADLConnection aadlConn = (AgreeAADLConnection) e;
        AgreeNode sourceNode = null;
        if (aadlConn.sourceNode != null) {
            sourceNode = visitedNodes.get(aadlConn.sourceNode.compInst);
        }
        AgreeNode destinationNode = null;
        if (aadlConn.destinationNode != null) {
            destinationNode = visitedNodes.get(aadlConn.destinationNode.compInst);
        }
        AgreeVar sourVar = visit(aadlConn.sourceVarName);
        AgreeVar destVar = visit(aadlConn.destinationVarName);
        ConnectionType type = aadlConn.type;
        boolean latched = aadlConn.latched;
        boolean delayed = aadlConn.delayed;
        EObject reference = aadlConn.reference;
        return new AgreeAADLConnection(sourceNode, destinationNode, sourVar, destVar, type, latched, delayed, reference);
    } else if (e instanceof AgreeOverriddenConnection) {
        AgreeOverriddenConnection overriddenCon = (AgreeOverriddenConnection) e;
        AgreeStatement statement = visit(overriddenCon.statement);
        return new AgreeOverriddenConnection(statement, overriddenCon.aadlConn);
    }
    throw new AgreeException("Unhandled Agree connection type " + e.getClass());
}
Also used : AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) ConnectionType(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection.ConnectionType) AgreeAADLConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection) EObject(org.eclipse.emf.ecore.EObject) AgreeOverriddenConnection(com.rockwellcollins.atc.agree.analysis.ast.AgreeOverriddenConnection) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 24 with AgreeNode

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

the class AgreeInlineLatchedConnections method visit.

@Override
public AgreeNode visit(AgreeNode node) {
    AgreeNodeBuilder builder = new AgreeNodeBuilder(node);
    builder.clearSubNodes();
    for (AgreeNode subNode : node.subNodes) {
        AgreeNode newSubNode = (AgreeNode) subNode.accept(this);
        builder.addSubNode(newSubNode);
    }
    if (node.timing == AgreeNode.TimingModel.LATCHED) {
        for (AgreeNode subNode : builder.build().subNodes) {
            addLatchedInputEqs(builder, subNode);
        }
    }
    AgreeNode finalNode = builder.build();
    nodes.add(finalNode);
    return finalNode;
}
Also used : AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) AgreeNodeBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder)

Example 25 with AgreeNode

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

the class LustreAstBuilder method getAssumeGuaranteeLustreProgram.

public static Program getAssumeGuaranteeLustreProgram(AgreeProgram agreeProgram) {
    nodes = new ArrayList<>();
    uninterpretedFcns = new ArrayList<>();
    AgreeNode flatNode = flattenAgreeNode(agreeProgram, agreeProgram.topNode, "_TOP__");
    List<Expr> assertions = new ArrayList<>();
    List<VarDecl> locals = new ArrayList<>();
    List<VarDecl> inputs = new ArrayList<>();
    List<Equation> equations = new ArrayList<>();
    List<String> properties = new ArrayList<>();
    List<String> ivcs = new ArrayList<>();
    int j = 0;
    for (AgreeStatement assumption : flatNode.assumptions) {
        String assumName = assumeSuffix + j++;
        locals.add(new AgreeVar(assumName, NamedType.BOOL, assumption.reference, flatNode.compInst, null));
        IdExpr assumId = new IdExpr(assumName);
        equations.add(new Equation(assumId, assumption.expr));
        assertions.add(assumId);
        // Else add the defined ivc list.
        if (flatNode.getFaultTreeFlag() == false) {
            ivcs.add(assumId.id);
        }
    }
    for (AgreeStatement assertion : flatNode.assertions) {
        assertions.add(assertion.expr);
    }
    // add assumption and monolithic lemmas first (helps with proving)
    for (AgreeVar var : flatNode.outputs) {
        if (var.reference instanceof AssumeStatement || var.reference instanceof LemmaStatement) {
            properties.add(var.id);
        }
        inputs.add(var);
    }
    // add property that all assumption history is true
    Expr assumeConj = new BoolExpr(true);
    for (AgreeNode subNode : agreeProgram.topNode.subNodes) {
        assumeConj = new BinaryExpr(new IdExpr(subNode.id + "__" + assumeHistSufix), BinaryOp.AND, assumeConj);
    }
    AgreeVar assumeHistVar = new AgreeVar(assumeHistSufix, NamedType.BOOL, agreeProgram.topNode.compInst.getComponentClassifier(), agreeProgram.topNode.compInst, null);
    locals.add(assumeHistVar);
    equations.add(new Equation(new IdExpr(assumeHistVar.id), assumeConj));
    properties.add(assumeHistVar.id);
    int k = 0;
    for (AgreeStatement patternPropState : flatNode.patternProps) {
        String patternVarName = patternPropSuffix + k++;
        locals.add(new AgreeVar(patternVarName, NamedType.BOOL, patternPropState, flatNode.compInst, null));
        equations.add(new Equation(new IdExpr(patternVarName), patternPropState.expr));
        properties.add(patternVarName);
    }
    int lemmaCount = 0;
    for (AgreeStatement lemma : flatNode.lemmas) {
        String lemmaName = lemmaSuffix + lemmaCount++;
        locals.add(new AgreeVar(lemmaName, NamedType.BOOL, lemma.reference, flatNode.compInst, null));
        equations.add(new Equation(new IdExpr(lemmaName), lemma.expr));
        properties.add(lemmaName);
    }
    int i = 0;
    for (AgreeStatement guarantee : flatNode.guarantees) {
        String guarName = guarSuffix + i++;
        locals.add(new AgreeVar(guarName, NamedType.BOOL, guarantee.reference, flatNode.compInst, null));
        equations.add(new Equation(new IdExpr(guarName), guarantee.expr));
        properties.add(guarName);
    }
    if (flatNode.getFaultTreeFlag()) {
        ivcs.addAll(agreeProgram.topNode.getivcElements());
    }
    for (AgreeVar var : flatNode.inputs) {
        inputs.add(var);
    }
    for (AgreeVar var : flatNode.locals) {
        locals.add(var);
    }
    equations.addAll(flatNode.localEquations);
    assertions.add(AgreeRealtimeCalendarBuilder.getTimeConstraint(flatNode.eventTimes));
    NodeBuilder builder = new NodeBuilder("main");
    builder.addInputs(inputs);
    builder.addLocals(locals);
    builder.addEquations(equations);
    builder.addProperties(properties);
    builder.addAssertions(assertions);
    builder.addIvcs(ivcs);
    Node main = builder.build();
    nodes.add(main);
    nodes.addAll(agreeProgram.globalLustreNodes);
    nodes.add(getHistNode());
    // add realtime constraint nodes
    nodes.addAll(AgreeRealtimeCalendarBuilder.getRealTimeNodes());
    List<TypeDef> types = AgreeUtils.getLustreTypes(agreeProgram);
    uninterpretedFcns.addAll(agreeProgram.uninterpretedFunctions);
    Program program = new ProgramBuilder().addTypes(types).addFunctions(uninterpretedFcns).addNodes(nodes).setMain(main.id).build();
    return program;
}
Also used : BoolExpr(jkind.lustre.BoolExpr) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) Node(jkind.lustre.Node) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) ArrayList(java.util.ArrayList) NodeBuilder(jkind.lustre.builders.NodeBuilder) AgreeNodeBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder) LemmaStatement(com.rockwellcollins.atc.agree.agree.LemmaStatement) TypeDef(jkind.lustre.TypeDef) VarDecl(jkind.lustre.VarDecl) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) Program(jkind.lustre.Program) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) IdExpr(jkind.lustre.IdExpr) AssumeStatement(com.rockwellcollins.atc.agree.agree.AssumeStatement) ProgramBuilder(jkind.lustre.builders.ProgramBuilder) BinaryExpr(jkind.lustre.BinaryExpr) Equation(jkind.lustre.Equation) AgreeEquation(com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar) UnaryExpr(jkind.lustre.UnaryExpr) Expr(jkind.lustre.Expr) IntExpr(jkind.lustre.IntExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) IdExpr(jkind.lustre.IdExpr)

Aggregations

AgreeNode (com.rockwellcollins.atc.agree.analysis.ast.AgreeNode)30 ArrayList (java.util.ArrayList)17 Node (jkind.lustre.Node)15 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)13 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)13 IdExpr (jkind.lustre.IdExpr)12 AgreeNodeBuilder (com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder)11 Expr (jkind.lustre.Expr)11 NodeCallExpr (jkind.lustre.NodeCallExpr)10 AgreeProgram (com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram)9 BinaryExpr (jkind.lustre.BinaryExpr)9 BoolExpr (jkind.lustre.BoolExpr)9 UnaryExpr (jkind.lustre.UnaryExpr)9 Program (jkind.lustre.Program)7 TypeDef (jkind.lustre.TypeDef)7 ProgramBuilder (jkind.lustre.builders.ProgramBuilder)7 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)6 AgreeEquation (com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation)6 VarDecl (jkind.lustre.VarDecl)6 Equation (jkind.lustre.Equation)5