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();
}
}
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));
}
}
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));
}
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;
}
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));
}
}
Aggregations