use of jkind.api.results.AnalysisResult in project AMASE by loonwerks.
the class IvcToSoteriaGenerator method generateModel.
public SoteriaModel generateModel(AnalysisResult result, AgreeResultsLinker linker) {
// get current verification result
AnalysisResult curResult = ((CompositeAnalysisResult) result).getChildren().get(0);
walkthroughResults(curResult, null, linker);
model.addCompLib(compLib);
// create component instances for the base model
model.createCompInst();
// create component connections for the base model
model.createConnections();
return model;
}
use of jkind.api.results.AnalysisResult in project AGREE by loonwerks.
the class VerifyHandler method createVerification.
private AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram, AnalysisType analysisType) {
// ///////
// Logger logger = Logger.getLogger("MyLog");
// FileHandler fh;
// try {
// This block configure the logger with handler and formatter
// fh = new FileHandler("/home/thomas/zzz.log");
// logger.addHandler(fh);
// SimpleFormatter formatter = new SimpleFormatter();
// fh.setFormatter(formatter);
// logger.info("Agree Program:");
// AgreeASTPrettyprinter pp = new AgreeASTPrettyprinter();
// pp.visit(agreeProgram);
// logger.info(pp.toString());
// } catch (SecurityException ex) {
// ex.printStackTrace();
// }
// catch (IOException ex) {
// ex.printStackTrace();
// }
// //////////////
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:
final Set<String> invertedProperties = renaming.getInvertedProperties();
List<Boolean> invertedPropertyMask = mainNode.properties.stream().map(p -> invertedProperties.contains(p)).collect(Collectors.toList());
result = new JKindResult(resultName, properties, invertedPropertyMask, 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.api.results.AnalysisResult in project AGREE by loonwerks.
the class AgreeMenuListener method addViewSupportConsole.
private IAction addViewSupportConsole(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("Support");
Renaming tempRenaming = linker.getRenaming(result);
while (tempRenaming == null) {
AnalysisResult parent = result.getParent();
if (parent == null) {
throw new AgreeException("Problem finding renaming");
}
tempRenaming = linker.getRenaming(parent);
}
final Renaming renaming = tempRenaming;
showConsole(console);
console.clearConsole();
if (patternListener != null) {
console.removePatternMatchListener(patternListener);
}
patternListener = new AgreePatternListener(refMap);
console.addPatternMatchListener(patternListener);
new Thread(() -> {
if (renaming instanceof AgreeRenaming) {
writeIvcResult(result, console, (AgreeRenaming) renaming);
}
}).start();
}
};
}
use of jkind.api.results.AnalysisResult in project AGREE by loonwerks.
the class AgreeMenuListener method addViewCounterexampleMenu.
private void addViewCounterexampleMenu(IMenuManager manager, AnalysisResult original) {
AnalysisResult result = transformResult(original);
final List<Counterexample> cexs = getCounterexamples(result);
final Property property = getProperty(result);
CexExtractorRegistry cexReg = (CexExtractorRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.CEX_EXTRACTOR_EXT_ID);
List<CexExtractor> extractors = cexReg.getCexExtractors();
if (cexs != null) {
for (Counterexample cex : cexs) {
final String cexType = getCounterexampleType(result);
Map<String, EObject> tempRefMap = linker.getReferenceMap(result.getParent());
if (tempRefMap == null) {
tempRefMap = linker.getReferenceMap(result);
}
Layout tempLayout = linker.getLayout(result.getParent());
if (tempLayout == null) {
tempLayout = linker.getLayout(result);
}
Renaming tempRenaming = linker.getRenaming(result.getParent());
if (tempRenaming == null) {
tempRenaming = linker.getRenaming(result);
}
final Layout layout = tempLayout;
final Map<String, EObject> refMap = tempRefMap;
final AgreeRenaming renaming = (AgreeRenaming) tempRenaming;
final Counterexample translatedCex = translateCounterexampleArrayIndices(cex);
MenuManager sub = new MenuManager("View " + cexType + "Counterexample in");
manager.add(sub);
sub.add(new Action("Console") {
@Override
public void run() {
viewCexConsole(translatedCex, layout, refMap, renaming);
}
});
sub.add(new Action("Eclipse") {
@Override
public void run() {
viewCexEclipse(translatedCex, layout, refMap);
}
});
sub.add(new Action("Spreadsheet") {
@Override
public void run() {
viewCexSpreadsheet(translatedCex, layout);
}
});
InvalidProperty invalid = findInvalidProperty(original);
if (invalid != null) {
String report = invalid.getReport();
if (report != null) {
sub.add(new Action("Web Browser") {
@Override
public void run() {
viewCexBrowser(report);
}
});
}
}
// send counterexamples to external plugins
EObject agreeProperty = refMap.get(result.getName());
ComponentImplementation compImpl = linker.getComponent(result.getParent());
for (CexExtractor ex : extractors) {
sub.add(new Action(ex.getDisplayText()) {
@Override
public void run() {
ex.receiveCex(compImpl, property, agreeProperty, cex, refMap);
}
});
}
}
}
}
use of jkind.api.results.AnalysisResult in project AGREE by loonwerks.
the class TcgLinkerFactory method buildAnalysisResult.
private AnalysisResult buildAnalysisResult(String name, ComponentInstance ci) {
CompositeAnalysisResult result = new CompositeAnalysisResult("Test case generation for " + name);
if (containsAGREEAnnex(ci)) {
wrapVerificationResult(ci, result);
ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(ci);
for (ComponentInstance subInst : ci.getComponentInstances()) {
if (AgreeUtils.getInstanceImplementation(subInst) != null) {
AnalysisResult buildAnalysisResult = buildAnalysisResult(subInst.getName(), subInst);
if (buildAnalysisResult != null) {
result.addChild(buildAnalysisResult);
}
}
}
if (result.getChildren().size() != 0) {
linker.setComponent(result, compImpl);
return result;
}
}
return null;
}
Aggregations