use of jkind.api.results.PropertyResult in project AMASE by loonwerks.
the class FaultsVerifyAllHandler method doFaultPropagationInjection.
protected Program doFaultPropagationInjection(JKindResult result, Program program) {
List<JKindResult> childVerifications = getChildContractResults(result);
// com.rockwellcollins.atc.agree.analysis.VerifyHandler#wrapVerificationResult(ComponentInstance, CompositeAnalysisResult)
if ("Contract Guarantees".equals(result.getName())) {
for (JKindResult childResult : childVerifications) {
AgreeRenaming childRenaming = (AgreeRenaming) linker.getRenaming(childResult);
for (PropertyResult propertyResult : childResult.getPropertyResults()) {
// where it is protected and we need to duplicate the literal here.
if (propertyResult.getProperty() instanceof InvalidProperty && childRenaming.getRefMap().get(propertyResult.getProperty().getName()) instanceof GuaranteeStatement) {
String guaranteeName = propertyResult.getProperty().getName();
String lustreVarName = childRenaming.getLustreNameFromAgreeVar(guaranteeName);
// WARNING: Here we assume that the subnode id of interest is named as given below.
// We need to introduce this literal "_TOP__" here because the computation is hidden in AGREE
// literals in com.rockwellcollins.atc.agree.analysis.LustreAstBuilder#getAssumeGuaranteeLustreProgram(AgreeProgram)
// WARNING: the string literal "Verification for " in the line below needs to match that in
// com.rockwellcollins.atc.agree.analysis.handlers.VerifyHandler#runJob(Element, IProgressMonitor) and
// com.rockwellcollins.atc.agree.analysis.handlers.VerifyHandler#buildAnalysisResult(String, ComponentInstance)
String subnodeName = "_TOP__" + childResult.getParent().getName().replaceFirst("Verification for ", "");
// TODO: The string concatenation is also done in the AddFaultDriverVisitor; unify them
program = new AddFaultDriverVisitor(subnodeName, lustreVarName).visit(program);
} else if (propertyResult.getProperty() instanceof ValidProperty && propertyResult.getProperty().getName().contains(childRenaming.forceRename(AddPairwiseFaultDriverWitnesses.FAULT_DRIVER_PAIR_WITNESS_BASENAME)) && pairwiseFaultDriverProperties.containsKey(childResult) && pairwiseFaultDriverProperties.get(childResult).containsKey(propertyResult.getName()) && // invalidated and have corresponding fault drivers that are present in this verification
pairwiseFaultDriverProperties.get(childResult).get(propertyResult.getName()).entrySet().stream().allMatch(e -> {
PropertyResult p = childResult.getPropertyResult(childRenaming.rename(e.getKey()));
return (p != null) ? p.getProperty() instanceof InvalidProperty : false;
})) {
program = new AddFaultDriverGuardAssertionVisitor(program.main, pairwiseFaultDriverProperties.get(childResult).get(propertyResult.getName()).values().stream().collect(Collectors.toList())).visit(program);
}
}
}
/* If not the top analysis, that is the parent of the composite parent of the composite parent of this result is not null */
if (result.getParent().getParent().getParent() != null) {
Map<PropertyResult, String> accumulatedGuarantees = Maps.newLinkedHashMap();
for (PropertyResult propertyResult : result.getPropertyResults()) {
AgreeRenaming renaming = (AgreeRenaming) linker.getRenaming(result);
if (renaming.getRefMap().get(propertyResult.getName()) instanceof GuaranteeStatement) {
String guaranteeName = propertyResult.getName();
String lustreVarName = renaming.getLustreNameFromAgreeVar(guaranteeName);
accumulatedGuarantees.put(propertyResult, lustreVarName);
}
}
AddPairwiseFaultDriverWitnesses pairwiseFaultVisitor = new AddPairwiseFaultDriverWitnesses(Lists.newArrayList(accumulatedGuarantees.values()));
program = pairwiseFaultVisitor.visit(program);
result.addProperties(pairwiseFaultVisitor.getProperties());
// WARNING: the string literal "Verification for " in the line below needs to match that in
// com.rockwellcollins.atc.agree.analysis.handlers.VerifyHandler#runJob(Element, IProgressMonitor) and
// com.rockwellcollins.atc.agree.analysis.handlers.VerifyHandler#buildAnalysisResult(String, ComponentInstance)
// TODO: the concatenation of nodeName with fault driver is done elsewhere too, unify
String nodeName = "_TOP__" + result.getParent().getName().replaceFirst("Verification for ", "");
pairwiseFaultDriverProperties.put(result, pairwiseFaultVisitor.getPairwiseWitnesses().entrySet().stream().collect(Collectors.toMap(e -> ((AgreeRenaming) linker.getRenaming(result)).forceRename(e.getKey()), e -> e.getValue().stream().collect(Collectors.toMap(id -> id, id -> nodeName + AddFaultDriverVisitor.getFaultDriverId(id))))));
}
}
return program;
}
use of jkind.api.results.PropertyResult in project AMASE by loonwerks.
the class SafetyJKindResult method start.
@Override
public void start() {
for (PropertyResult pr : propertyResults) {
pr.start();
}
ticker = new Ticker(this);
ticker.start();
}
use of jkind.api.results.PropertyResult in project AGREE by loonwerks.
the class AgreeMenuListener method writeIvcResult.
public static void writeIvcResult(AnalysisResult result, final MessageConsole console, final AgreeRenaming renaming) {
try (MessageConsoleStream out = console.newMessageStream()) {
ValidProperty vp = (ValidProperty) (((PropertyResult) result).getProperty());
printHLine(out, 2);
out.println("Set of Support for Guarantee: " + "{" + vp.getName() + "}");
printHLine(out, 2);
if (!vp.getIvc().isEmpty()) {
printHLine(out, 2);
out.println(String.format("%-25s%-25s", "Component name", "Property name"));
printHLine(out, 2);
for (String supportString : vp.getIvc()) {
String componentName = "";
String refStr = renaming.getSupportRefString(supportString);
if (supportString.contains(".")) {
componentName = supportString.substring(0, supportString.indexOf('.'));
} else {
componentName = "Top Level System";
}
out.println(String.format("%-25s%-25s", componentName, "{" + refStr + "}"));
}
printHLine(out, 2);
} else {
out.println("There are no support elements to display.");
}
out.println("");
} catch (IOException e) {
e.printStackTrace();
}
}
use of jkind.api.results.PropertyResult in project AGREE by loonwerks.
the class AgreeMenuListener method addViewTraceabilityConsole.
private IAction addViewTraceabilityConsole(String text, IMenuManager manager, AnalysisResult result) {
return new Action(text) {
@Override
public void run() {
Map<String, EObject> tempRefMap = linker.getReferenceMap(result.getParent());
if (tempRefMap == null) {
tempRefMap = linker.getReferenceMap(result);
}
final Map<String, EObject> refMap = tempRefMap;
final MessageConsole console = findConsole("Traceability");
final Renaming renaming = linker.getRenaming(result);
showConsole(console);
console.clearConsole();
console.addPatternMatchListener(new AgreePatternListener(refMap));
new Thread(() -> {
try {
MessageConsoleStream out = console.newMessageStream();
printHLine(out, 2);
out.println("Traceability for Valid Contract Guarantees");
printHLine(out, 2);
out.println("");
List<PropertyResult> allProperties = new ArrayList<PropertyResult>(((JKindResult) result).getPropertyResults());
if (!allProperties.isEmpty()) {
for (PropertyResult prop : allProperties) {
if (prop.getStatus().equals(jkind.api.results.Status.VALID)) {
if (renaming instanceof AgreeRenaming) {
writeIvcResult(prop, console, (AgreeRenaming) renaming);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}).start();
}
};
}
use of jkind.api.results.PropertyResult in project AGREE by loonwerks.
the class AgreeMenuListener method addResultsLinkingMenu.
private void addResultsLinkingMenu(IMenuManager manager, AnalysisResult result) {
if (result instanceof PropertyResult) {
PropertyResult pr = (PropertyResult) result;
Map<String, EObject> refMap = linker.getReferenceMap(pr.getParent());
EObject property = refMap.get(pr.getName());
if (property instanceof GuaranteeStatement) {
manager.add(createHyperlinkAction("Go To Guarantee", property));
}
if (property instanceof LemmaStatement) {
manager.add(createHyperlinkAction("Go To Lemma", property));
}
if (property instanceof AssumeStatement) {
manager.add(createHyperlinkAction("Go To Assumption", property));
}
if (property instanceof CallExpr) {
manager.add(createHyperlinkAction("Go To Node Call", property));
}
if (property instanceof AgreeStatement) {
AgreeStatement statement = (AgreeStatement) property;
if (statement.reference instanceof AgreePattern) {
AgreePattern pattern = (AgreePattern) statement.reference;
manager.add(createHyperlinkAction("Go To Pattern", pattern.reference));
}
}
}
}
Aggregations