Search in sources :

Example 26 with Node

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

the class SafetyLinkerFactory method createVerification.

protected AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram) {
    // Renaming: organizes things between jkind and agree results?
    AgreeRenaming agreeRenaming = new AgreeRenaming();
    AgreeLayout layout = new AgreeLayout();
    RenamingVisitor.addRenamings(lustreProgram, agreeRenaming, compInst, layout);
    SafetyRenaming renaming = new SafetyRenaming(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);
    // Set the program, component, contract, layout, log, and renaming
    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);
    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) JKindResult(jkind.api.results.JKindResult)

Example 27 with Node

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

the class AddFaultDriverVisitor method visit.

@Override
public Node visit(Node node) {
    List<VarDecl> inputs = Lists.newArrayList(node.inputs);
    List<Equation> equations = Lists.newArrayList(node.equations);
    if (node.id.equals(targetSubnodeName)) {
        equations = visitEquations(node.equations);
        inputs.add(new VarDecl(getFaultDriverId(targetVarName), NamedType.BOOL));
        liftedTargetSubnodeInputs.add(getFaultDriverId(targetVarName));
    }
    return new Node(node.location, node.id, inputs, node.outputs, node.locals, equations, node.properties, node.assertions, node.realizabilityInputs, node.contract, node.ivc);
}
Also used : VarDecl(jkind.lustre.VarDecl) Node(jkind.lustre.Node) Equation(jkind.lustre.Equation)

Example 28 with Node

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

the class FaultsVerifyAllHandler method createVerification.

private AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram, AnalysisType analysisType) {
    AgreeAutomaterRegistry aAReg = (AgreeAutomaterRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.AGREE_AUTOMATER_EXT_ID);
    List<AgreeAutomater> automaters = aAReg.getAgreeAutomaters();
    AgreeRenaming renaming = new AgreeRenaming();
    AgreeLayout layout = new AgreeLayout();
    Node mainNode = null;
    for (Node node : lustreProgram.nodes) {
        if (node.id.equals(lustreProgram.main)) {
            mainNode = node;
            break;
        }
    }
    if (mainNode == null) {
        throw new AgreeException("Could not find main lustre node after translation");
    }
    List<String> properties = new ArrayList<>();
    RenamingVisitor.addRenamings(lustreProgram, renaming, compInst, layout);
    addProperties(renaming, properties, mainNode, agreeProgram);
    for (AgreeAutomater aa : automaters) {
        renaming = aa.rename(renaming);
        layout = aa.transformLayout(layout);
    }
    JKindResult result;
    switch(analysisType) {
        case Consistency:
            result = new ConsistencyResult(resultName, mainNode.properties, Collections.singletonList(true), renaming);
            break;
        case Realizability:
            result = new JRealizabilityResult(resultName, renaming);
            break;
        case AssumeGuarantee:
            result = new SafetyJKindResult(resultName, properties, renaming);
            break;
        default:
            throw new AgreeException("Unhandled Analysis Type");
    }
    queue.add(result);
    ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(compInst);
    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) JRealizabilityResult(jkind.api.results.JRealizabilityResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) SafetyJKindResult(edu.umn.cs.crisys.safety.analysis.results.SafetyJKindResult) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) SafetyJKindResult(edu.umn.cs.crisys.safety.analysis.results.SafetyJKindResult) JKindResult(jkind.api.results.JKindResult) AgreeAutomaterRegistry(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) ConsistencyResult(com.rockwellcollins.atc.agree.analysis.ConsistencyResult) AgreeAutomater(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Example 29 with Node

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

the class GenMCSHandler method createVerification.

/**
 * Copied from AGREE VerifyHandler - allows for min cut set Analysis Type in
 * param analysisType
 *
 * @param resultName
 * @param compInst
 * @param lustreProgram
 * @param agreeProgram
 * @param analysisType
 * @return
 */
private AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram, AnalysisType analysisType) {
    AgreeAutomaterRegistry aAReg = (AgreeAutomaterRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.AGREE_AUTOMATER_EXT_ID);
    List<AgreeAutomater> automaters = aAReg.getAgreeAutomaters();
    AgreeRenaming renaming = new AgreeRenaming();
    AgreeLayout layout = new AgreeLayout();
    Node mainNode = null;
    for (Node node : lustreProgram.nodes) {
        if (node.id.equals(lustreProgram.main)) {
            mainNode = node;
            break;
        }
    }
    if (mainNode == null) {
        throw new AgreeException("Could not find main lustre node after translation");
    }
    List<String> properties = new ArrayList<>();
    RenamingVisitor.addRenamings(lustreProgram, renaming, compInst, layout);
    addProperties(renaming, properties, mainNode, agreeProgram);
    for (AgreeAutomater aa : automaters) {
        renaming = aa.rename(renaming);
        layout = aa.transformLayout(layout);
    }
    JKindResult result;
    switch(analysisType) {
        case Consistency:
            result = new ConsistencyResult(resultName, mainNode.properties, Collections.singletonList(true), renaming);
            break;
        case Realizability:
            result = new JRealizabilityResult(resultName, renaming);
            break;
        case AssumeGuarantee:
            result = new JKindResult(resultName, properties, renaming);
            break;
        default:
            throw new AgreeException("Unhandled Analysis Type");
    }
    queue.add(result);
    ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(compInst);
    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);
    return result;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) JRealizabilityResult(jkind.api.results.JRealizabilityResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) JKindResult(jkind.api.results.JKindResult) AgreeAutomaterRegistry(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) ConsistencyResult(com.rockwellcollins.atc.agree.analysis.ConsistencyResult) AgreeAutomater(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Example 30 with Node

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

the class FaultASTBuilder method createCommNodes.

/**
 * Create communication nodes for each of the connections from sender
 * to receiver.
 *
 * @param senderConnections	List of all connections from the faulty output.
 * @param fstmt	Defines fault and all subcomponents
 * @param fault	The fault on the sender output
 * @param senderOutput The DataPortImpl output on sender component
 */
private void createCommNodes(List<ConnectionInstanceEnd> senderConnections, FaultStatement fstmt, Fault fault, DataPortImpl senderOutput) {
    // For loop goes through the connections
    // and creates a commNode specific for each connection.
    // The fault is passed into the creation method in order to
    // link the fault to the comm node as it is inserted into Lustre.
    String nodeName = "";
    // Get list of connections from parent component that senderOutput is connected to.
    String searchFor = senderOutput.getFullName();
    // Name of sender component (the one with the fanned output)
    String compName = this.agreeNode.compInst.getName();
    List<String> commNodeNamesInput = new ArrayList<>();
    List<String> commNodeNames = new ArrayList<>();
    for (int i = 0; i < senderConnections.size(); i++) {
        nodeName = "asym_node_" + i + "__" + compName + "__" + fault.id;
        Node commNode = createCommNode(this.agreeNode, fstmt, fault, nodeName, i);
        commNodeNamesInput.add(nodeName + "__input");
        commNodeNames.add(nodeName);
        // Make map from comm node to connections
        mapCommNodeOutputToConnections.put(nodeName + "__output", senderConnections.get(i));
        // 4. Add node to lustre
        this.addGlobalLustreNode(commNode);
    }
    // Output of sender component used to build lustre main asserts
    String senderOut = this.agreeNode.id + "__" + searchFor;
    mapAsymCompOutputToCommNodeIn.put(senderOut, commNodeNamesInput);
    mapCompNameToCommNodes.put(compName, commNodeNames);
}
Also used : Node(jkind.lustre.Node) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) ArrayList(java.util.ArrayList)

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