Search in sources :

Example 26 with AgreeException

use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AMASE by loonwerks.

the class FaultsVerifyAllHandler method runJob.

@Override
protected IStatus runJob(Element root, IProgressMonitor monitor) {
    EphemeralImplementationUtil implUtil = new EphemeralImplementationUtil(monitor);
    // this flag is set by the rerun handler to prevent clearing the advice map
    if (!calledFromRerun) {
        rerunAdviceMap.clear();
    }
    calledFromRerun = false;
    disableRerunHandler();
    handlerService = getWindow().getService(IHandlerService.class);
    try {
        // Make sure the user selected a component implementation
        ComponentImplementation ci = getComponentImplementation(root, implUtil);
        SystemInstance si = getSysInstance(ci, implUtil);
        AnalysisResult result;
        CompositeAnalysisResult wrapper = new CompositeAnalysisResult("");
        if (isRecursive()) {
            if (AgreeUtils.usingKind2()) {
                throw new AgreeException("Kind2 only supports monolithic verification");
            }
            result = buildAnalysisResult(ci.getName(), si);
            wrapper.addChild(result);
            result = wrapper;
        } else if (isRealizability()) {
            AgreeProgram agreeProgram = new AgreeASTBuilder().getAgreeProgram(si, false);
            Program program = LustreAstBuilder.getRealizabilityLustreProgram(agreeProgram);
            wrapper.addChild(createVerification("Realizability Check", si, program, agreeProgram, AnalysisType.Realizability));
            result = wrapper;
        } else {
            CompositeAnalysisResult wrapperTop = new CompositeAnalysisResult("Verification for " + ci.getName());
            wrapVerificationResult(si, wrapperTop);
            wrapper.addChild(wrapperTop);
            result = wrapper;
        }
        showView(result, linker);
        return doAnalysis(ci, monitor);
    } catch (Throwable e) {
        String messages = getNestedMessages(e);
        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, messages, e);
    } finally {
        implUtil.cleanup();
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Program(jkind.lustre.Program) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) EphemeralImplementationUtil(com.rockwellcollins.atc.agree.analysis.EphemeralImplementationUtil) AnalysisResult(jkind.api.results.AnalysisResult) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult) IHandlerService(org.eclipse.ui.handlers.IHandlerService) AgreeASTBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeASTBuilder) SystemInstance(org.osate.aadl2.instance.SystemInstance) CompositeAnalysisResult(jkind.api.results.CompositeAnalysisResult) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Example 27 with AgreeException

use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AMASE by loonwerks.

the class FaultsVerifyAllHandler method wrapVerificationResult.

@Override
protected void wrapVerificationResult(ComponentInstance si, CompositeAnalysisResult wrapper) {
    AgreeProgram agreeProgram = new AgreeASTBuilder().getAgreeProgram(si, isMonolithic());
    // generate different lustre depending on which model checker we are
    // using
    Program program;
    if (AgreeUtils.usingKind2()) {
        if (!isMonolithic()) {
            throw new AgreeException("Kind2 now only supports monolithic verification");
        }
        program = LustreContractAstBuilder.getContractLustreProgram(agreeProgram);
    } else {
        program = LustreAstBuilder.getAssumeGuaranteeLustreProgram(agreeProgram);
    }
    List<Pair<String, Program>> consistencies = LustreAstBuilder.getConsistencyChecks(agreeProgram);
    wrapper.addChild(createVerification("Contract Guarantees", si, program, agreeProgram, AnalysisType.AssumeGuarantee));
    for (Pair<String, Program> consistencyAnalysis : consistencies) {
        wrapper.addChild(createVerification(consistencyAnalysis.getFirst(), si, consistencyAnalysis.getSecond(), agreeProgram, AnalysisType.Consistency));
    }
}
Also used : Program(jkind.lustre.Program) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) AgreeASTBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeASTBuilder) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) Pair(org.eclipse.xtext.util.Pair)

Example 28 with AgreeException

use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AMASE by loonwerks.

the class GenMCSHandler method wrapVerificationResult.

@Override
protected void wrapVerificationResult(ComponentInstance si, CompositeAnalysisResult wrapper) {
    AgreeProgram agreeProgram = new AgreeASTBuilder().getAgreeProgram(si, isMonolithic());
    Program program;
    if (AgreeUtils.usingKind2()) {
        if (!isMonolithic()) {
            throw new AgreeException("Kind2 now only supports monolithic verification");
        }
        program = LustreContractAstBuilder.getContractLustreProgram(agreeProgram);
    } else {
        program = LustreAstBuilder.getAssumeGuaranteeLustreProgram(agreeProgram);
    }
    wrapper.addChild(createVerification("Contract Guarantees", si, program, agreeProgram, AnalysisType.AssumeGuarantee));
}
Also used : Program(jkind.lustre.Program) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) AgreeASTBuilder(com.rockwellcollins.atc.agree.analysis.ast.AgreeASTBuilder) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Example 29 with AgreeException

use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AMASE by loonwerks.

the class GenMCSHandler method createVerification.

/**
 * Copied from AGREE VerifyHandler - allows for min cut set Analysis Type in
 * param analysisType
 *
 * @param resultName
 * @param compInst
 * @param lustreProgram
 * @param agreeProgram
 * @param analysisType
 * @return
 */
private AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram, AnalysisType analysisType) {
    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:
            result = new JKindResult(resultName, properties, 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);
    return result;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) JRealizabilityResult(jkind.api.results.JRealizabilityResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) Node(jkind.lustre.Node) 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 30 with AgreeException

use of com.rockwellcollins.atc.agree.analysis.AgreeException in project AGREE by loonwerks.

the class AgreeASTBuilder method gatherUnspecifiedAadlProperties.

private void gatherUnspecifiedAadlProperties(Map<String, GetPropertyExpr> unspecifiedAadlProperties, List<AgreeVar> inputs, List<AgreeStatement> assumptions, List<AgreeStatement> guarantees) {
    for (Entry<String, GetPropertyExpr> entry : unspecifiedAadlProperties.entrySet()) {
        String propInputName = entry.getKey();
        GetPropertyExpr expr = entry.getValue();
        Property prop = (Property) expr.getProp();
        Expr propInputIdExpr = new IdExpr(propInputName);
        Type type;
        Expr bound = null;
        if (prop.getReferencedPropertyType() instanceof AadlBoolean) {
            type = NamedType.BOOL;
        } else if (prop.getReferencedPropertyType() instanceof AadlInteger) {
            AadlInteger aadlInteger = (AadlInteger) prop.getReferencedPropertyType();
            type = NamedType.INT;
            if (aadlInteger.getRange() != null) {
                PropertyExpression lowerBound = aadlInteger.getRange().getLowerBound();
                PropertyExpression upperBound = aadlInteger.getRange().getUpperBound();
                Expr lowVal = new IntExpr(BigDecimal.valueOf(((IntegerLiteral) lowerBound).getScaledValue()).toBigInteger());
                Expr highVal = new IntExpr(BigDecimal.valueOf(((IntegerLiteral) upperBound).getScaledValue()).toBigInteger());
                Expr lowBound = new BinaryExpr(lowVal, BinaryOp.LESSEQUAL, propInputIdExpr);
                Expr highBound = new BinaryExpr(propInputIdExpr, BinaryOp.LESSEQUAL, highVal);
                bound = LustreExprFactory.makeANDExpr(lowBound, highBound);
            }
        } else if (prop.getReferencedPropertyType() instanceof AadlReal) {
            AadlReal aadlReal = (AadlReal) prop.getReferencedPropertyType();
            type = NamedType.REAL;
            if (aadlReal.getRange() != null) {
                PropertyExpression lowerBound = aadlReal.getRange().getLowerBound();
                PropertyExpression upperBound = aadlReal.getRange().getUpperBound();
                Expr lowVal = new RealExpr(BigDecimal.valueOf(((RealLiteral) lowerBound).getValue()));
                Expr highVal = new RealExpr(BigDecimal.valueOf(((RealLiteral) upperBound).getValue()));
                Expr lowBound = new BinaryExpr(lowVal, BinaryOp.LESSEQUAL, propInputIdExpr);
                Expr highBound = new BinaryExpr(propInputIdExpr, BinaryOp.LESSEQUAL, highVal);
                bound = LustreExprFactory.makeANDExpr(lowBound, highBound);
            }
        } else {
            throw new AgreeException("Could not locate property value '\" + prop.getFullName() + \"' in component '\"\n" + "//						+ compName.getName() + \"'.   Analysis on abstract values not supported for " + "AADL property type " + prop.getReferencedPropertyType() + ".");
        }
        AgreeVar propInputVar = new AgreeVar(propInputName, type, expr, curInst, null);
        Expr constraint = getUnchangingConstraintExpr(propInputIdExpr);
        if (bound != null) {
            constraint = LustreExprFactory.makeANDExpr(constraint, bound);
        }
        inputs.add(propInputVar);
        assumptions.add(new AgreeStatement("", constraint, prop));
    }
}
Also used : AadlReal(org.osate.aadl2.AadlReal) IdExpr(jkind.lustre.IdExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealLiteral(org.osate.aadl2.RealLiteral) ConnectionType(com.rockwellcollins.atc.agree.analysis.ast.AgreeAADLConnection.ConnectionType) Type(jkind.lustre.Type) NamedType(jkind.lustre.NamedType) FeatureGroupType(org.osate.aadl2.FeatureGroupType) DataSubcomponentType(org.osate.aadl2.DataSubcomponentType) ComponentType(org.osate.aadl2.ComponentType) AadlBoolean(org.osate.aadl2.AadlBoolean) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) ArrayExpr(jkind.lustre.ArrayExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) IdExpr(jkind.lustre.IdExpr) TimeExpr(com.rockwellcollins.atc.agree.agree.TimeExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) IntExpr(jkind.lustre.IntExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) PropertyExpression(org.osate.aadl2.PropertyExpression) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) AadlInteger(org.osate.aadl2.AadlInteger) IntExpr(jkind.lustre.IntExpr) Property(org.osate.aadl2.Property) RealExpr(jkind.lustre.RealExpr) IntegerLiteral(org.osate.aadl2.IntegerLiteral)

Aggregations

AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)47 IdExpr (jkind.lustre.IdExpr)23 Expr (jkind.lustre.Expr)21 BinaryExpr (jkind.lustre.BinaryExpr)19 BoolExpr (jkind.lustre.BoolExpr)18 NodeCallExpr (jkind.lustre.NodeCallExpr)18 UnaryExpr (jkind.lustre.UnaryExpr)18 ArrayList (java.util.ArrayList)16 IntExpr (jkind.lustre.IntExpr)15 ComponentImplementation (org.osate.aadl2.ComponentImplementation)13 SelectionExpr (com.rockwellcollins.atc.agree.agree.SelectionExpr)12 IfThenElseExpr (jkind.lustre.IfThenElseExpr)12 GetPropertyExpr (com.rockwellcollins.atc.agree.agree.GetPropertyExpr)11 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)11 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)11 RealLitExpr (com.rockwellcollins.atc.agree.agree.RealLitExpr)11 ArrayLiteralExpr (com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr)10 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)10 ArrayUpdateExpr (com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr)10 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)10