Search in sources :

Example 11 with AnalysisResult

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;
}
Also used : AnalysisResult(jkind.api.results.AnalysisResult) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult)

Example 12 with AnalysisResult

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;
}
Also used : AnnexUtil(org.osate.annexsupport.AnnexUtil) Element(org.osate.aadl2.Element) Program(jkind.lustre.Program) EphemeralImplementationUtil(com.rockwellcollins.atc.agree.analysis.EphemeralImplementationUtil) AnalysisResult(jkind.api.results.AnalysisResult) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult) IStatus(org.eclipse.core.runtime.IStatus) AgreeAutomaterRegistry(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry) Classifier(org.osate.aadl2.Classifier) PartInitException(org.eclipse.ui.PartInitException) Map(java.util.Map) ComponentType(org.osate.aadl2.ComponentType) RenamingVisitor(com.rockwellcollins.atc.agree.analysis.lustre.visitors.RenamingVisitor) IViewPart(org.eclipse.ui.IViewPart) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) PrintWriter(java.io.PrintWriter) SystemInstance(org.osate.aadl2.instance.SystemInstance) AgreeContractSubclause(com.rockwellcollins.atc.agree.agree.AgreeContractSubclause) Set(java.util.Set) Status(org.eclipse.core.runtime.Status) AadlPackage(org.osate.aadl2.AadlPackage) PreferencesUtil(com.rockwellcollins.atc.agree.analysis.preferences.PreferencesUtil) Collectors(java.util.stream.Collectors) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) LustreAstBuilder(com.rockwellcollins.atc.agree.analysis.translation.LustreAstBuilder) IHandlerService(org.eclipse.ui.handlers.IHandlerService) Node(jkind.lustre.Node) List(java.util.List) AgreeUtils(com.rockwellcollins.atc.agree.analysis.AgreeUtils) JRealizabilityApi(jkind.api.JRealizabilityApi) Queue(java.util.Queue) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) AgreeAutomater(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater) ExtensionRegistry(com.rockwellcollins.atc.agree.analysis.extentions.ExtensionRegistry) Dialog(org.osate.ui.dialogs.Dialog) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) AgreePackage(com.rockwellcollins.atc.agree.agree.AgreePackage) ConsistencyResult(com.rockwellcollins.atc.agree.analysis.ConsistencyResult) AgreeSubclause(com.rockwellcollins.atc.agree.agree.AgreeSubclause) Activator(com.rockwellcollins.atc.agree.analysis.Activator) LustreContractAstBuilder(com.rockwellcollins.atc.agree.analysis.translation.LustreContractAstBuilder) ComponentImplementation(org.osate.aadl2.ComponentImplementation) AnalysisErrorReporterManager(org.osate.aadl2.modelsupport.errorreporting.AnalysisErrorReporterManager) HashMap(java.util.HashMap) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) AtomicReference(java.util.concurrent.atomic.AtomicReference) Message(org.osate.aadl2.modelsupport.errorreporting.QueuingAnalysisErrorReporter.Message) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Pair(org.eclipse.xtext.util.Pair) AgreeResultsLinker(com.rockwellcollins.atc.agree.analysis.views.AgreeResultsLinker) JKindResult(jkind.api.results.JKindResult) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) AgreeLogger(com.rockwellcollins.atc.agree.analysis.AgreeLogger) AgreeResultsView(com.rockwellcollins.atc.agree.analysis.views.AgreeResultsView) KindApi(jkind.api.KindApi) JRealizabilityResult(jkind.api.results.JRealizabilityResult) Shell(org.eclipse.swt.widgets.Shell) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) JKindException(jkind.JKindException) StringWriter(java.io.StringWriter) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) JKindApi(jkind.api.JKindApi) AgreeFileUtil(com.rockwellcollins.atc.agree.analysis.saving.AgreeFileUtil) QueuingAnalysisErrorReporter(org.osate.aadl2.modelsupport.errorreporting.QueuingAnalysisErrorReporter) PreferenceConstants(com.rockwellcollins.atc.agree.analysis.preferences.PreferenceConstants) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) AnnexSubclause(org.osate.aadl2.AnnexSubclause) ArrayDeque(java.util.ArrayDeque) Collections(java.util.Collections) AgreeASTBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeASTBuilder) ComponentImplementation(org.osate.aadl2.ComponentImplementation) JRealizabilityResult(jkind.api.results.JRealizabilityResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) Node(jkind.lustre.Node) AgreeNode(com.rockwellcollins.atc.agree.analysis.ast.AgreeNode) 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 13 with AnalysisResult

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();
        }
    };
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) MessageConsole(org.eclipse.ui.console.MessageConsole) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) EObject(org.eclipse.emf.ecore.EObject) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) AnalysisResult(jkind.api.results.AnalysisResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) Renaming(jkind.api.results.Renaming)

Example 14 with AnalysisResult

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);
                    }
                });
            }
        }
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) CexExtractorRegistry(com.rockwellcollins.atc.agree.analysis.extentions.CexExtractorRegistry) CexExtractor(com.rockwellcollins.atc.agree.analysis.extentions.CexExtractor) Counterexample(jkind.results.Counterexample) AnalysisResult(jkind.api.results.AnalysisResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) Renaming(jkind.api.results.Renaming) Layout(jkind.results.layout.Layout) EObject(org.eclipse.emf.ecore.EObject) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ValidProperty(jkind.results.ValidProperty) Property(jkind.results.Property) InvalidProperty(jkind.results.InvalidProperty) UnknownProperty(jkind.results.UnknownProperty) InvalidProperty(jkind.results.InvalidProperty)

Example 15 with AnalysisResult

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;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult) AnalysisResult(jkind.api.results.AnalysisResult) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult)

Aggregations

AnalysisResult (jkind.api.results.AnalysisResult)18 CompositeAnalysisResult (jkind.api.results.CompositeAnalysisResult)11 ComponentImplementation (org.osate.aadl2.ComponentImplementation)10 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)7 IStatus (org.eclipse.core.runtime.IStatus)6 Status (org.eclipse.core.runtime.Status)6 IHandlerService (org.eclipse.ui.handlers.IHandlerService)6 EphemeralImplementationUtil (com.rockwellcollins.atc.agree.analysis.EphemeralImplementationUtil)5 AgreeASTBuilder (com.rockwellcollins.atc.agree.analysis.ast.AgreeASTBuilder)5 AgreeProgram (com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram)5 Program (jkind.lustre.Program)5 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)5 SystemInstance (org.osate.aadl2.instance.SystemInstance)5 AgreeRenaming (com.rockwellcollins.atc.agree.analysis.AgreeRenaming)4 ArrayList (java.util.ArrayList)3 JRealizabilityResult (jkind.api.results.JRealizabilityResult)3 EObject (org.eclipse.emf.ecore.EObject)3 Activator (com.rockwellcollins.atc.agree.analysis.Activator)2 AgreeLayout (com.rockwellcollins.atc.agree.analysis.AgreeLayout)2 AgreeLogger (com.rockwellcollins.atc.agree.analysis.AgreeLogger)2