Search in sources :

Example 6 with PropertyResult

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;
}
Also used : GuaranteeStatement(com.rockwellcollins.atc.agree.agree.GuaranteeStatement) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) ValidProperty(jkind.results.ValidProperty) AddFaultDriverGuardAssertionVisitor(edu.umn.cs.crisys.safety.analysis.ast.visitors.AddFaultDriverGuardAssertionVisitor) AddFaultDriverVisitor(edu.umn.cs.crisys.safety.analysis.ast.visitors.AddFaultDriverVisitor) InvalidProperty(jkind.results.InvalidProperty) PropertyResult(jkind.api.results.PropertyResult) AddPairwiseFaultDriverWitnesses(edu.umn.cs.crisys.safety.analysis.ast.visitors.AddPairwiseFaultDriverWitnesses) SafetyJKindResult(edu.umn.cs.crisys.safety.analysis.results.SafetyJKindResult) JKindResult(jkind.api.results.JKindResult)

Example 7 with PropertyResult

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

Example 8 with PropertyResult

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();
    }
}
Also used : ValidProperty(jkind.results.ValidProperty) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream) IOException(java.io.IOException) PropertyResult(jkind.api.results.PropertyResult)

Example 9 with PropertyResult

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();
        }
    };
}
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) MessageConsoleStream(org.eclipse.ui.console.MessageConsoleStream) PropertyResult(jkind.api.results.PropertyResult) PartInitException(org.eclipse.ui.PartInitException) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) Renaming(jkind.api.results.Renaming) JKindResult(jkind.api.results.JKindResult) EObject(org.eclipse.emf.ecore.EObject) List(java.util.List) ArrayList(java.util.ArrayList)

Example 10 with PropertyResult

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));
            }
        }
    }
}
Also used : GuaranteeStatement(com.rockwellcollins.atc.agree.agree.GuaranteeStatement) AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) AssumeStatement(com.rockwellcollins.atc.agree.agree.AssumeStatement) EObject(org.eclipse.emf.ecore.EObject) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) LemmaStatement(com.rockwellcollins.atc.agree.agree.LemmaStatement) PropertyResult(jkind.api.results.PropertyResult) AgreePattern(com.rockwellcollins.atc.agree.analysis.realtime.AgreePattern)

Aggregations

PropertyResult (jkind.api.results.PropertyResult)14 ValidProperty (jkind.results.ValidProperty)6 JKindResult (jkind.api.results.JKindResult)5 EObject (org.eclipse.emf.ecore.EObject)4 GuaranteeStatement (com.rockwellcollins.atc.agree.agree.GuaranteeStatement)3 ArrayList (java.util.ArrayList)3 InvalidProperty (jkind.results.InvalidProperty)3 AssumeStatement (com.rockwellcollins.atc.agree.agree.AssumeStatement)2 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)2 LemmaStatement (com.rockwellcollins.atc.agree.agree.LemmaStatement)2 AgreeRenaming (com.rockwellcollins.atc.agree.analysis.AgreeRenaming)2 TcgRenaming (com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Renaming (jkind.api.results.Renaming)2 Counterexample (jkind.results.Counterexample)2 Action (org.eclipse.jface.action.Action)2 IAction (org.eclipse.jface.action.IAction)2 MessageConsoleStream (org.eclipse.ui.console.MessageConsoleStream)2 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)1