Search in sources :

Example 1 with JKindResult

use of jkind.api.results.JKindResult in project AGREE by loonwerks.

the class TcgLinkerFactory method createVerification.

protected AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram) {
    AgreeRenaming agreeRenaming = new AgreeRenaming();
    AgreeLayout layout = new AgreeLayout();
    RenamingVisitor.addRenamings(lustreProgram, agreeRenaming, compInst, layout);
    TcgRenaming renaming = new TcgRenaming(agreeRenaming, agreeRenaming.getRefMap());
    Node mainNode = lustreProgram.getMainNode();
    if (mainNode == null) {
        throw new AgreeException("Could not find main lustre node after translation");
    }
    List<String> properties = new ArrayList<>();
    JKindResult result;
    result = new JKindResult(resultName, properties, renaming);
    queue.add(result);
    ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(compInst);
    linker.setAgreeProgram(result, agreeProgram);
    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 : ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming) JKindResult(jkind.api.results.JKindResult)

Example 2 with JKindResult

use of jkind.api.results.JKindResult 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 3 with JKindResult

use of jkind.api.results.JKindResult in project AGREE by loonwerks.

the class VerifyHandler method doAnalysis.

protected IStatus doAnalysis(final Element root, final IProgressMonitor monitor) {
    Thread analysisThread = new Thread() {

        @Override
        public void run() {
            activateTerminateHandler(monitor);
            KindApi api = PreferencesUtil.getKindApi();
            while (!queue.isEmpty() && !monitor.isCanceled()) {
                JKindResult result = queue.peek();
                NullProgressMonitor subMonitor = new NullProgressMonitor();
                monitorRef.set(subMonitor);
                TcgRenaming tcgRenaming = (TcgRenaming) linker.getRenaming(result);
                Program ufcProgram = constructUfcProgram(linker.getProgram(result), tcgRenaming);
                ufcProgram.getMainNode().properties.forEach(p -> result.addProperty(p));
                writeIntermediateFiles(linker.getProgram(result), ufcProgram);
                try {
                    System.out.println("Calling jkind...");
                    api.execute(ufcProgram, result, monitor);
                    System.out.println("executed API...");
                    TestSuite testSuite = TestSuiteUtils.testSuiteFromJKindResult(result, linker.getComponent(result).getQualifiedName(), result.getName(), result.getText(), tcgRenaming);
                    emitResult(testSuite);
                // showSuiteView(testSuite, linker);
                } catch (JKindException e) {
                    System.out.println(result.getText());
                    System.out.println("******** Error Occurred: HERE IS THE LUSTRE ********");
                    System.out.println(linker.getProgram(result));
                    break;
                } finally {
                    deactivateTerminateHandler();
                    System.out.println("UFC generation complete");
                }
                queue.remove();
            }
        }
    };
    analysisThread.start();
    return Status.OK_STATUS;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Program(jkind.lustre.Program) JKindException(jkind.JKindException) TestSuite(com.rockwellcollins.atc.tcg.suite.TestSuite) KindApi(jkind.api.KindApi) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming) JKindResult(jkind.api.results.JKindResult)

Example 4 with JKindResult

use of jkind.api.results.JKindResult 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 5 with JKindResult

use of jkind.api.results.JKindResult in project AMASE by loonwerks.

the class SafetyLinkerFactory method createVerification.

protected AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram) {
    // Renaming: organizes things between jkind and agree results?
    AgreeRenaming agreeRenaming = new AgreeRenaming();
    AgreeLayout layout = new AgreeLayout();
    RenamingVisitor.addRenamings(lustreProgram, agreeRenaming, compInst, layout);
    SafetyRenaming renaming = new SafetyRenaming(agreeRenaming, agreeRenaming.getRefMap());
    Node mainNode = lustreProgram.getMainNode();
    if (mainNode == null) {
        throw new AgreeException("Could not find main lustre node after translation");
    }
    List<String> properties = new ArrayList<>();
    JKindResult result;
    result = new JKindResult(resultName, properties, renaming);
    queue.add(result);
    // Set the program, component, contract, layout, log, and renaming
    ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(compInst);
    linker.setAgreeProgram(result, agreeProgram);
    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);
    return result;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) JKindResult(jkind.api.results.JKindResult)

Aggregations

JKindResult (jkind.api.results.JKindResult)16 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)9 AgreeRenaming (com.rockwellcollins.atc.agree.analysis.AgreeRenaming)8 ArrayList (java.util.ArrayList)8 ConsistencyResult (com.rockwellcollins.atc.agree.analysis.ConsistencyResult)7 JKindException (jkind.JKindException)7 KindApi (jkind.api.KindApi)7 JRealizabilityResult (jkind.api.results.JRealizabilityResult)7 Program (jkind.lustre.Program)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 AgreeLayout (com.rockwellcollins.atc.agree.analysis.AgreeLayout)6 JKindApi (jkind.api.JKindApi)6 PropertyResult (jkind.api.results.PropertyResult)6 Node (jkind.lustre.Node)6 ComponentImplementation (org.osate.aadl2.ComponentImplementation)6 AgreeProgram (com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram)5 JRealizabilityApi (jkind.api.JRealizabilityApi)5 PartInitException (org.eclipse.ui.PartInitException)5 AgreeAutomater (com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater)4 AgreeAutomaterRegistry (com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry)4