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;
}
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);
}
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;
}
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;
}
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);
}
Aggregations