Search in sources :

Example 6 with Node

use of jkind.lustre.Node in project AGREE by loonwerks.

the class RemoveProperties method transform.

public static SimulationProgram transform(final SimulationProgram program) {
    final Program lustreProgram = program.getLustreProgram();
    if (lustreProgram.nodes.size() != 1) {
        throw new IllegalArgumentException("Only lustre programs with exactly one node are supported");
    }
    final SimulationProgramBuilder simulationProgramBuilder = new SimulationProgramBuilder(program);
    final ProgramBuilder lustreProgramBuilder = new ProgramBuilder(lustreProgram);
    lustreProgramBuilder.clearNodes();
    final Node node = lustreProgram.getMainNode();
    final NodeBuilder nodeBuilder = new NodeBuilder(node);
    nodeBuilder.clearProperties();
    // Add the new node to the new lustre program
    lustreProgramBuilder.addNode(nodeBuilder.build());
    simulationProgramBuilder.setLustreProgram(lustreProgramBuilder.build());
    return simulationProgramBuilder.build();
}
Also used : SimulationProgram(edu.uah.rsesc.aadlsimulator.agree.SimulationProgram) Program(jkind.lustre.Program) ProgramBuilder(jkind.lustre.builders.ProgramBuilder) SimulationProgramBuilder(edu.uah.rsesc.aadlsimulator.agree.SimulationProgramBuilder) Node(jkind.lustre.Node) SimulationProgramBuilder(edu.uah.rsesc.aadlsimulator.agree.SimulationProgramBuilder) NodeBuilder(jkind.lustre.builders.NodeBuilder)

Example 7 with Node

use of jkind.lustre.Node in project AGREE by loonwerks.

the class RemovePropertySatisficationRequirements method transform.

// private final static String assumeBaseId = "__ASSUME";
public static SimulationProgram transform(final SimulationProgram program) {
    final SimulationProgramBuilder simulationProgramBuilder = new SimulationProgramBuilder(program);
    final ProgramBuilder lustreProgramBuilder = new ProgramBuilder(program.getLustreProgram());
    lustreProgramBuilder.clearNodes();
    for (final Node node : program.getLustreProgram().nodes) {
        final NodeBuilder nodeBuilder = new NodeBuilder(new AstMapVisitor() {

            @Override
            public Node visit(final Node n) {
                return super.visit(n);
            }

            @Override
            public Equation visit(final Equation e) {
                // Force the assumption conjunction to be true
                if (e.lhs.size() == 1 && e.lhs.get(0).id.equals(assumptionConjunctionId)) {
                    return new Equation(new IdExpr(assumptionConjunctionId), new BoolExpr(true));
                }
                final Equation result = super.visit(e);
                return result;
            }
        }.visit(node));
        lustreProgramBuilder.addNode(nodeBuilder.build());
    }
    simulationProgramBuilder.setLustreProgram(lustreProgramBuilder.build());
    return simulationProgramBuilder.build();
}
Also used : BoolExpr(jkind.lustre.BoolExpr) AstMapVisitor(jkind.lustre.visitors.AstMapVisitor) IdExpr(jkind.lustre.IdExpr) ProgramBuilder(jkind.lustre.builders.ProgramBuilder) SimulationProgramBuilder(edu.uah.rsesc.aadlsimulator.agree.SimulationProgramBuilder) Node(jkind.lustre.Node) SimulationProgramBuilder(edu.uah.rsesc.aadlsimulator.agree.SimulationProgramBuilder) Equation(jkind.lustre.Equation) NodeBuilder(jkind.lustre.builders.NodeBuilder)

Example 8 with Node

use of jkind.lustre.Node in project AGREE by loonwerks.

the class CreateLocalVariablesForPropertyExpressions method transform.

public static SimulationProgram transform(final SimulationProgram program) {
    final Program lustreProgram = program.getLustreProgram();
    final SimulationProgramBuilder builder = new SimulationProgramBuilder(program);
    // Build mappings between Agree Statements, expressions, and Agree Nodes
    final Map<Expr, AgreeStatement> exprToStatementMap = new HashMap<>();
    final Map<AgreeStatement, AgreeNode> agreeStatementToAgreeNodeMap = new HashMap<>();
    for (final AgreeNode agreeNode : program.getAllAgreeNodes()) {
        for (final AgreeStatement statement : agreeNode.assertions) {
            if (statement.reference instanceof AssertStatement) {
                exprToStatementMap.put(statement.expr, statement);
                agreeStatementToAgreeNodeMap.put(statement, agreeNode);
            }
        }
        for (final AgreeStatement statement : agreeNode.assumptions) {
            exprToStatementMap.put(statement.expr, statement);
            agreeStatementToAgreeNodeMap.put(statement, agreeNode);
        }
        for (final AgreeStatement statement : agreeNode.guarantees) {
            exprToStatementMap.put(statement.expr, statement);
            agreeStatementToAgreeNodeMap.put(statement, agreeNode);
        }
    }
    // Create local variables for assert statements, assumptions, and guarantees
    final ProgramBuilder lustreBuilder = new ProgramBuilder(lustreProgram).clearNodes();
    for (final Node lustreNode : lustreProgram.nodes) {
        lustreBuilder.addNode(VariableCreator.transform(lustreNode, exprToStatementMap, agreeStatementToAgreeNodeMap));
    }
    builder.setLustreProgram(lustreBuilder.build());
    return builder.build();
}
Also used : Program(jkind.lustre.Program) SimulationProgram(edu.uah.rsesc.aadlsimulator.agree.SimulationProgram) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) TupleExpr(jkind.lustre.TupleExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) UnaryExpr(jkind.lustre.UnaryExpr) RecordUpdateExpr(jkind.lustre.RecordUpdateExpr) CondactExpr(jkind.lustre.CondactExpr) ArrayExpr(jkind.lustre.ArrayExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) IntExpr(jkind.lustre.IntExpr) IdExpr(jkind.lustre.IdExpr) ArrayUpdateExpr(jkind.lustre.ArrayUpdateExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) RecordExpr(jkind.lustre.RecordExpr) HashMap(java.util.HashMap) ProgramBuilder(jkind.lustre.builders.ProgramBuilder) SimulationProgramBuilder(edu.uah.rsesc.aadlsimulator.agree.SimulationProgramBuilder) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) Node(jkind.lustre.Node) SimulationProgramBuilder(edu.uah.rsesc.aadlsimulator.agree.SimulationProgramBuilder) AssertStatement(com.rockwellcollins.atc.agree.agree.AssertStatement)

Example 9 with Node

use of jkind.lustre.Node 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 10 with Node

use of jkind.lustre.Node in project AGREE by loonwerks.

the class AgreeASTBuilder method getMNSynchConstraint.

private Expr getMNSynchConstraint(MNSynchStatement sync) {
    Set<String> nodeNames = new HashSet<>();
    Expr clockAssertion = new BoolExpr(true);
    for (int i = 0; i < sync.getComp1().size(); i++) {
        Subcomponent maxComp = (Subcomponent) sync.getComp1().get(i);
        Subcomponent minComp = (Subcomponent) sync.getComp2().get(i);
        Expr maxClock = new IdExpr(maxComp.getName() + clockIDSuffix);
        Expr minClock = new IdExpr(minComp.getName() + clockIDSuffix);
        int max = Integer.valueOf(sync.getMax().get(i));
        int min = Integer.valueOf(sync.getMin().get(i));
        MNSynchronyElement elem = new MNSynchronyElement(maxClock, minClock, max, min);
        String nodeName = "__calendar_node_" + elem.max + "_" + elem.min;
        nodeName = getObjectLocationPrefix(sync) + nodeName;
        if (!nodeNames.contains(nodeName)) {
            nodeNames.add(nodeName);
            Node calNode = AgreeCalendarUtils.getMNCalendar(nodeName, elem.max, elem.min);
            addToNodeList(calNode);
        }
        NodeCallExpr nodeCall = new NodeCallExpr(nodeName, elem.maxClock, elem.minClock);
        clockAssertion = LustreExprFactory.makeANDExpr(clockAssertion, nodeCall);
        nodeCall = new NodeCallExpr(nodeName, elem.minClock, elem.maxClock);
        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) Subcomponent(org.osate.aadl2.Subcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Node(jkind.lustre.Node) HashSet(java.util.HashSet) MNSynchronyElement(com.rockwellcollins.atc.agree.analysis.MNSynchronyElement)

Aggregations

Node (jkind.lustre.Node)46 ArrayList (java.util.ArrayList)28 IdExpr (jkind.lustre.IdExpr)24 UnaryExpr (jkind.lustre.UnaryExpr)20 BinaryExpr (jkind.lustre.BinaryExpr)19 Expr (jkind.lustre.Expr)19 AgreeNode (com.rockwellcollins.atc.agree.analysis.ast.AgreeNode)18 NodeCallExpr (jkind.lustre.NodeCallExpr)17 BoolExpr (jkind.lustre.BoolExpr)16 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)12 Equation (jkind.lustre.Equation)12 Program (jkind.lustre.Program)12 VarDecl (jkind.lustre.VarDecl)12 NodeBuilder (jkind.lustre.builders.NodeBuilder)12 AgreeProgram (com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram)11 ProgramBuilder (jkind.lustre.builders.ProgramBuilder)11 IfThenElseExpr (jkind.lustre.IfThenElseExpr)10 IntExpr (jkind.lustre.IntExpr)10 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)9 AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)8