use of com.rockwellcollins.atc.agree.analysis.ast.AgreeNode in project AGREE by loonwerks.
the class AgreePatternTranslator method translate.
public static AgreeProgram translate(AgreeProgram program) {
List<Node> patternLustreNodes = new ArrayList<>();
// reset the static variable before refreshing its values in translateNode call
containsRealTimePatterns = false;
AgreeNode topNode = new AgreePatternTranslator().translateNode(program.topNode, true);
List<AgreeNode> agreeNodes = gatherNodes(topNode);
patternLustreNodes.addAll(program.globalLustreNodes);
return new AgreeProgram(agreeNodes, patternLustreNodes, program.uninterpretedFunctions, program.globalTypes, topNode, containsRealTimePatterns);
}
use of com.rockwellcollins.atc.agree.analysis.ast.AgreeNode in project AGREE by loonwerks.
the class VerifyHandler method addKind2Properties.
protected void addKind2Properties(AgreeNode agreeNode, List<String> properties, AgreeRenaming renaming, String prefix, String userPropPrefix) {
int i = 0;
String propPrefix = (userPropPrefix.equals("")) ? "" : userPropPrefix + ": ";
for (AgreeStatement statement : agreeNode.lemmas) {
renaming.addExplicitRename(prefix + "[" + (++i) + "]", propPrefix + statement.string);
properties.add(prefix.replaceAll("\\.", AgreeASTBuilder.dotChar) + "[" + i + "]");
}
for (AgreeStatement statement : agreeNode.guarantees) {
renaming.addExplicitRename(prefix + "[" + (++i) + "]", propPrefix + statement.string);
properties.add(prefix.replaceAll("\\.", AgreeASTBuilder.dotChar) + "[" + i + "]");
}
userPropPrefix = userPropPrefix.equals("") ? "" : userPropPrefix + ".";
for (AgreeNode subNode : agreeNode.subNodes) {
addKind2Properties(subNode, properties, renaming, prefix + "." + subNode.id, userPropPrefix + subNode.id);
}
}
use of com.rockwellcollins.atc.agree.analysis.ast.AgreeNode in project AGREE by loonwerks.
the class AgreeASTMapVisitor method visit.
@Override
public AgreeConnection visit(AgreeConnection e) {
if (e instanceof AgreeAADLConnection) {
AgreeAADLConnection aadlConn = (AgreeAADLConnection) e;
AgreeNode sourceNode = null;
if (aadlConn.sourceNode != null) {
sourceNode = visitedNodes.get(aadlConn.sourceNode.compInst);
}
AgreeNode destinationNode = null;
if (aadlConn.destinationNode != null) {
destinationNode = visitedNodes.get(aadlConn.destinationNode.compInst);
}
AgreeVar sourVar = visit(aadlConn.sourceVarName);
AgreeVar destVar = visit(aadlConn.destinationVarName);
ConnectionType type = aadlConn.type;
boolean latched = aadlConn.latched;
boolean delayed = aadlConn.delayed;
EObject reference = aadlConn.reference;
return new AgreeAADLConnection(sourceNode, destinationNode, sourVar, destVar, type, latched, delayed, reference);
} else if (e instanceof AgreeOverriddenConnection) {
AgreeOverriddenConnection overriddenCon = (AgreeOverriddenConnection) e;
AgreeStatement statement = visit(overriddenCon.statement);
return new AgreeOverriddenConnection(statement, overriddenCon.aadlConn);
}
throw new AgreeException("Unhandled Agree connection type " + e.getClass());
}
use of com.rockwellcollins.atc.agree.analysis.ast.AgreeNode in project AGREE by loonwerks.
the class AgreeInlineLatchedConnections method visit.
@Override
public AgreeNode visit(AgreeNode node) {
AgreeNodeBuilder builder = new AgreeNodeBuilder(node);
builder.clearSubNodes();
for (AgreeNode subNode : node.subNodes) {
AgreeNode newSubNode = (AgreeNode) subNode.accept(this);
builder.addSubNode(newSubNode);
}
if (node.timing == AgreeNode.TimingModel.LATCHED) {
for (AgreeNode subNode : builder.build().subNodes) {
addLatchedInputEqs(builder, subNode);
}
}
AgreeNode finalNode = builder.build();
nodes.add(finalNode);
return finalNode;
}
use of com.rockwellcollins.atc.agree.analysis.ast.AgreeNode in project AGREE by loonwerks.
the class LustreAstBuilder method getAssumeGuaranteeLustreProgram.
public static Program getAssumeGuaranteeLustreProgram(AgreeProgram agreeProgram) {
nodes = new ArrayList<>();
uninterpretedFcns = new ArrayList<>();
AgreeNode flatNode = flattenAgreeNode(agreeProgram, agreeProgram.topNode, "_TOP__");
List<Expr> assertions = new ArrayList<>();
List<VarDecl> locals = new ArrayList<>();
List<VarDecl> inputs = new ArrayList<>();
List<Equation> equations = new ArrayList<>();
List<String> properties = new ArrayList<>();
List<String> ivcs = new ArrayList<>();
int j = 0;
for (AgreeStatement assumption : flatNode.assumptions) {
String assumName = assumeSuffix + j++;
locals.add(new AgreeVar(assumName, NamedType.BOOL, assumption.reference, flatNode.compInst, null));
IdExpr assumId = new IdExpr(assumName);
equations.add(new Equation(assumId, assumption.expr));
assertions.add(assumId);
// Else add the defined ivc list.
if (flatNode.getFaultTreeFlag() == false) {
ivcs.add(assumId.id);
}
}
for (AgreeStatement assertion : flatNode.assertions) {
assertions.add(assertion.expr);
}
// add assumption and monolithic lemmas first (helps with proving)
for (AgreeVar var : flatNode.outputs) {
if (var.reference instanceof AssumeStatement || var.reference instanceof LemmaStatement) {
properties.add(var.id);
}
inputs.add(var);
}
// add property that all assumption history is true
Expr assumeConj = new BoolExpr(true);
for (AgreeNode subNode : agreeProgram.topNode.subNodes) {
assumeConj = new BinaryExpr(new IdExpr(subNode.id + "__" + assumeHistSufix), BinaryOp.AND, assumeConj);
}
AgreeVar assumeHistVar = new AgreeVar(assumeHistSufix, NamedType.BOOL, agreeProgram.topNode.compInst.getComponentClassifier(), agreeProgram.topNode.compInst, null);
locals.add(assumeHistVar);
equations.add(new Equation(new IdExpr(assumeHistVar.id), assumeConj));
properties.add(assumeHistVar.id);
int k = 0;
for (AgreeStatement patternPropState : flatNode.patternProps) {
String patternVarName = patternPropSuffix + k++;
locals.add(new AgreeVar(patternVarName, NamedType.BOOL, patternPropState, flatNode.compInst, null));
equations.add(new Equation(new IdExpr(patternVarName), patternPropState.expr));
properties.add(patternVarName);
}
int lemmaCount = 0;
for (AgreeStatement lemma : flatNode.lemmas) {
String lemmaName = lemmaSuffix + lemmaCount++;
locals.add(new AgreeVar(lemmaName, NamedType.BOOL, lemma.reference, flatNode.compInst, null));
equations.add(new Equation(new IdExpr(lemmaName), lemma.expr));
properties.add(lemmaName);
}
int i = 0;
for (AgreeStatement guarantee : flatNode.guarantees) {
String guarName = guarSuffix + i++;
locals.add(new AgreeVar(guarName, NamedType.BOOL, guarantee.reference, flatNode.compInst, null));
equations.add(new Equation(new IdExpr(guarName), guarantee.expr));
properties.add(guarName);
}
if (flatNode.getFaultTreeFlag()) {
ivcs.addAll(agreeProgram.topNode.getivcElements());
}
for (AgreeVar var : flatNode.inputs) {
inputs.add(var);
}
for (AgreeVar var : flatNode.locals) {
locals.add(var);
}
equations.addAll(flatNode.localEquations);
assertions.add(AgreeRealtimeCalendarBuilder.getTimeConstraint(flatNode.eventTimes));
NodeBuilder builder = new NodeBuilder("main");
builder.addInputs(inputs);
builder.addLocals(locals);
builder.addEquations(equations);
builder.addProperties(properties);
builder.addAssertions(assertions);
builder.addIvcs(ivcs);
Node main = builder.build();
nodes.add(main);
nodes.addAll(agreeProgram.globalLustreNodes);
nodes.add(getHistNode());
// add realtime constraint nodes
nodes.addAll(AgreeRealtimeCalendarBuilder.getRealTimeNodes());
List<TypeDef> types = AgreeUtils.getLustreTypes(agreeProgram);
uninterpretedFcns.addAll(agreeProgram.uninterpretedFunctions);
Program program = new ProgramBuilder().addTypes(types).addFunctions(uninterpretedFcns).addNodes(nodes).setMain(main.id).build();
return program;
}
Aggregations