Search in sources :

Example 1 with ValidProperty

use of jkind.results.ValidProperty in project AGREE by loonwerks.

the class AgreeMenuListener method addTraceabilityMatrixMenu.

private void addTraceabilityMatrixMenu(IMenuManager manager, AnalysisResult result) {
    IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
    if (prefs.getString(PreferenceConstants.PREF_MODEL_CHECKER).equals(PreferenceConstants.MODEL_CHECKER_JKIND) && prefs.getBoolean(PreferenceConstants.PREF_SUPPORT) && result instanceof JKindResult) {
        JKindResult jresult = (JKindResult) result;
        Set<String> reqs = new HashSet<String>();
        for (PropertyResult pr : jresult.getPropertyResults()) {
            if (pr.getProperty() instanceof ValidProperty) {
                ValidProperty vp = (ValidProperty) pr.getProperty();
                Set<String> ivc = vp.getIvc();
                if (ivc != null && !ivc.isEmpty()) {
                    reqs.addAll(ivc);
                }
            }
        }
        String nodeName = linker.getComponent(result).getName();
        manager.add(new Action("View traceability matrix for " + nodeName) {

            @Override
            public void run() {
                viewTraceabilityMatrix(jresult, reqs);
            }
        });
    }
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) ValidProperty(jkind.results.ValidProperty) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) PropertyResult(jkind.api.results.PropertyResult) JKindResult(jkind.api.results.JKindResult) HashSet(java.util.HashSet)

Example 2 with ValidProperty

use of jkind.results.ValidProperty in project AGREE by loonwerks.

the class AgreeTraceabilityMatrixView method createContent.

private void createContent(JKindResult result, List<String> raw) {
    for (PropertyResult pr : result.getPropertyResults()) {
        if (pr.getProperty() instanceof ValidProperty) {
            ValidProperty vp = (ValidProperty) pr.getProperty();
            Set<String> ivc = vp.getIvc();
            if (ivc != null && !ivc.isEmpty()) {
                createRow(vp.getName(), ivc, raw);
            }
        }
    }
}
Also used : ValidProperty(jkind.results.ValidProperty) PropertyResult(jkind.api.results.PropertyResult)

Example 3 with ValidProperty

use of jkind.results.ValidProperty in project AGREE by loonwerks.

the class AgreeTraceabilityMatrixView method usedCandidates.

public List<String> usedCandidates(JKindResult result) {
    Set<String> reqs = new HashSet<>();
    for (PropertyResult pr : result.getPropertyResults()) {
        if (pr.getProperty() instanceof ValidProperty) {
            ValidProperty vp = (ValidProperty) pr.getProperty();
            Set<String> ivc = vp.getIvc();
            if (ivc != null && !ivc.isEmpty()) {
                reqs.addAll(ivc);
            }
        }
    }
    return reqs.stream().collect(Collectors.toList());
}
Also used : ValidProperty(jkind.results.ValidProperty) PropertyResult(jkind.api.results.PropertyResult) HashSet(java.util.HashSet)

Example 4 with ValidProperty

use of jkind.results.ValidProperty in project AMASE by loonwerks.

the class IvcToFTGenerator method extractPropertyResult.

private void extractPropertyResult(String compName, AgreeRenaming renaming, PropertyResult propertyResult) {
    // get original property name
    String origPropertyName = propertyResult.getName();
    String lustreName = renaming.getLustreNameFromAgreeVar(origPropertyName);
    String propertyName = MHSUtils.updateElemName(compName + "_" + lustreName);
    // if it is a guarantee
    if (lustreName.startsWith("__GUARANTEE")) {
        // if it's a valid guarantee
        if (propertyResult.getStatus().equals(jkind.api.results.Status.VALID)) {
            // TODO: get user specified property name if exists
            String propertyDescription = propertyResult.getName();
            ValidProperty property = (ValidProperty) propertyResult.getProperty();
            // check if there is timeout in MIVC analysis
            if (property.getMivcTimedOut()) {
                new SafetyException("MIVC ANALYSIS TIMEOUT FOR " + lustreName + ": " + origPropertyName);
            }
            // Create mapPropToMCS for hierarchical ft printout
            String propName = propertyName + ": " + propertyDescription;
            Set<List<String>> mcsList = new HashSet<List<String>>();
            // turn MIVC sets to MCS sets
            // no limit on mhs set size
            Set<List<String>> mcsSets = MHSUtils.computeMHS(property.getIvcSets(), 0, false);
            // Create list for prop->MCS mapping
            mcsList = createMCSList(mcsSets, renaming);
            mapPropertyToMCSs.put(componentName + "__" + lustreName, mcsList);
            // create node when mcsSets is not empty
            if (!mcsSets.isEmpty()) {
                FTNonLeafNode propertyNode;
                boolean isNewNode = true;
                boolean createOrNode = (mcsSets.size() > 1);
                if (!faultTree.intermediateNodes.containsKey(propertyName)) {
                    if (createOrNode) {
                        propertyNode = new FTOrNode(propertyName, propertyDescription);
                    } else {
                        propertyNode = new FTAndNode(propertyName, propertyDescription);
                    }
                } else {
                    propertyNode = faultTree.intermediateNodes.get(propertyName);
                    // if the no child node has been populated for this node yet
                    if (!(propertyNode instanceof FTOrNode) && !(propertyNode instanceof FTAndNode)) {
                        if (createOrNode) {
                            propertyNode = new FTOrNode(propertyName, propertyNode.propertyDescription);
                        } else {
                            propertyNode = new FTAndNode(propertyName, propertyNode.propertyDescription);
                        }
                    } else {
                        isNewNode = false;
                    }
                }
                if (isNewNode) {
                    int index = 0;
                    for (List<String> mcsSet : mcsSets) {
                        String mcsSetNodeName = propertyName + "_" + Integer.toString(index);
                        FTAndNode mcsSetNode = new FTAndNode(mcsSetNodeName, propertyDescription);
                        extractMCSSets(compName, renaming, mcsSetNode, mcsSet);
                        propertyNode.addChildNode(mcsSetNodeName, mcsSetNode);
                        // mcsSetNode.addParentNode(propertyNode);
                        faultTree.addIntermediateNode(mcsSetNodeName, mcsSetNode);
                        // update intermediate node
                        faultTree.addIntermediateNode(propertyNode.nodeName, propertyNode);
                        index++;
                    }
                }
                if (!isLowerLevel) {
                    faultTree.addRootNode(propertyName, propertyNode);
                    propertyNode.setRoot();
                }
                faultTree.addIntermediateNode(propertyName, propertyNode);
            } else {
                FTNonLeafNode propertyNode = new FTNonLeafNode(propertyName, propertyDescription);
                if (faultTree.intermediateNodes.containsKey(propertyName)) {
                    propertyNode = faultTree.intermediateNodes.get(propertyName);
                }
                propertyNode.resolved = true;
                propertyNode.nodeValue = false;
                if (!isLowerLevel) {
                    faultTree.addRootNode(propertyName, propertyNode);
                    propertyNode.setRoot();
                }
                faultTree.addIntermediateNode(propertyName, propertyNode);
            }
        } else if (propertyResult.getStatus().equals(jkind.api.results.Status.CANCELED)) {
            throw new SafetyException("One of the properties was canceled in the process of model checking." + " Rerun this analysis to proceed.");
        } else if (propertyResult.getStatus().equals(jkind.api.results.Status.INVALID)) {
            throw new SafetyException("One of the properties is invalid. The model must be valid using AGREE Verify All Layers.");
        } else if (propertyResult.getStatus().equals(jkind.api.results.Status.UNKNOWN)) {
            throw new SafetyException("One of the properties is unknown. All properties must be known and valid to generate minimal cut sets" + " Tip: Set solver to Z3 and set analysis properties PDR = 4.");
        }
    }
}
Also used : FTAndNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTAndNode) ValidProperty(jkind.results.ValidProperty) ArrayList(java.util.ArrayList) List(java.util.List) FTOrNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTOrNode) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException) FTNonLeafNode(edu.umn.cs.crisys.safety.analysis.faultTree.FTNonLeafNode) HashSet(java.util.HashSet)

Example 5 with ValidProperty

use of jkind.results.ValidProperty 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)

Aggregations

ValidProperty (jkind.results.ValidProperty)8 PropertyResult (jkind.api.results.PropertyResult)6 HashSet (java.util.HashSet)3 JKindResult (jkind.api.results.JKindResult)3 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)2 InvalidProperty (jkind.results.InvalidProperty)2 GuaranteeStatement (com.rockwellcollins.atc.agree.agree.GuaranteeStatement)1 AgreeRenaming (com.rockwellcollins.atc.agree.analysis.AgreeRenaming)1 SimulationProgram (edu.uah.rsesc.aadlsimulator.agree.SimulationProgram)1 SimulationProperty (edu.uah.rsesc.aadlsimulator.agree.SimulationProperty)1 AddFaultDriverGuardAssertionVisitor (edu.umn.cs.crisys.safety.analysis.ast.visitors.AddFaultDriverGuardAssertionVisitor)1 AddFaultDriverVisitor (edu.umn.cs.crisys.safety.analysis.ast.visitors.AddFaultDriverVisitor)1 AddPairwiseFaultDriverWitnesses (edu.umn.cs.crisys.safety.analysis.ast.visitors.AddPairwiseFaultDriverWitnesses)1 FTAndNode (edu.umn.cs.crisys.safety.analysis.faultTree.FTAndNode)1 FTNonLeafNode (edu.umn.cs.crisys.safety.analysis.faultTree.FTNonLeafNode)1 FTOrNode (edu.umn.cs.crisys.safety.analysis.faultTree.FTOrNode)1 SafetyJKindResult (edu.umn.cs.crisys.safety.analysis.results.SafetyJKindResult)1 CompContractViolation (edu.umn.cs.crisys.safety.analysis.soteria.CompContractViolation)1 SoteriaFormula (edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFormula)1 SoteriaFormulaSubgroup (edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFormulaSubgroup)1