use of com.rockwellcollins.atc.agree.agree.LemmaStatement in project AGREE by loonwerks.
the class TestCaseGeneratorMenuListener method addResultsLinkingMenu.
private void addResultsLinkingMenu(IMenuManager manager, AnalysisResult result) {
if (result instanceof PropertyResult) {
PropertyResult pr = (PropertyResult) result;
Map<String, EObject> refMap = ((TcgRenaming) linker.getRenaming(result.getParent())).getTcgRefMap();
if (refMap != null) {
EObject property = refMap.get(pr.getName());
if (property instanceof GuaranteeStatement) {
manager.add(createHyperlinkAction("Go To Guarantee", property));
}
if (property instanceof LemmaStatement) {
manager.add(createHyperlinkAction("Go To Lemma", property));
}
if (property instanceof AssumeStatement) {
manager.add(createHyperlinkAction("Go To Assumption", property));
}
if (property instanceof CallExpr) {
manager.add(createHyperlinkAction("Go To Node Call", property));
}
}
}
}
use of com.rockwellcollins.atc.agree.agree.LemmaStatement in project AGREE by loonwerks.
the class LustreAstBuilder method addHistoricalAssumptionConstraint.
private static void addHistoricalAssumptionConstraint(AgreeNode agreeNode, String prefix, Expr clockExpr, List<AgreeStatement> assertions, Node lustreNode) {
Expr assumConj = new BoolExpr(true);
for (VarDecl lustreVar : lustreNode.inputs) {
AgreeVar var = (AgreeVar) lustreVar;
if (var.reference instanceof AssumeStatement || var.reference instanceof LemmaStatement) {
Expr varId = new IdExpr(prefix + var.id);
assumConj = LustreExprFactory.makeANDExpr(varId, assumConj);
}
}
// assumConj = new BinaryExpr(clockExpr, BinaryOp.IMPLIES, assumConj);
Expr histCall = new NodeCallExpr(historyNodeName, assumConj);
Expr assertExpr = new BinaryExpr(new IdExpr(prefix + assumeSuffix + "__HIST"), BinaryOp.EQUAL, histCall);
assertions.add(new AgreeStatement("", assertExpr, null));
}
use of com.rockwellcollins.atc.agree.agree.LemmaStatement in project AGREE by loonwerks.
the class LustreContractAstBuilder method addInitConstraint.
protected static void addInitConstraint(AgreeNode agreeNode, List<AgreeVar> outputs, List<AgreeStatement> assertions, AgreeNode subAgreeNode, String prefix, Expr clockExpr, Node lustreNode) {
if (agreeNode.timing != TimingModel.SYNC) {
String tickedName = subAgreeNode.id + "___TICKED";
outputs.add(new AgreeVar(tickedName, NamedType.BOOL, null, agreeNode.compInst, null));
Expr tickedId = new IdExpr(tickedName);
Expr preTicked = new UnaryExpr(UnaryOp.PRE, tickedId);
Expr tickedOrPre = new BinaryExpr(clockExpr, BinaryOp.OR, preTicked);
Expr initOrTicked = new BinaryExpr(clockExpr, BinaryOp.ARROW, tickedOrPre);
Expr tickedEq = new BinaryExpr(tickedId, BinaryOp.EQUAL, initOrTicked);
assertions.add(new AgreeStatement("", tickedEq, null));
// we have two re-write the ids in the initial expressions
IdRewriter rewriter = id -> new IdExpr(prefix + id.id);
Expr newInit = subAgreeNode.initialConstraint.accept(new IdRewriteVisitor(rewriter));
Expr initConstr = new BinaryExpr(new UnaryExpr(UnaryOp.NOT, tickedId), BinaryOp.IMPLIES, newInit);
assertions.add(new AgreeStatement("", initConstr, null));
// we also need to add hold expressions for the assumptions and
// lemmas
Expr assumeLemmaTrue = new BoolExpr(true);
for (VarDecl lustreVar : lustreNode.inputs) {
AgreeVar var = (AgreeVar) lustreVar;
if (var.reference instanceof AssumeStatement || var.reference instanceof LemmaStatement) {
assumeLemmaTrue = new BinaryExpr(assumeLemmaTrue, BinaryOp.AND, new IdExpr(prefix + var.id));
}
}
assumeLemmaTrue = new BinaryExpr(new UnaryExpr(UnaryOp.NOT, tickedId), BinaryOp.IMPLIES, assumeLemmaTrue);
assertions.add(new AgreeStatement("", assumeLemmaTrue, null));
}
}
use of com.rockwellcollins.atc.agree.agree.LemmaStatement in project AGREE by loonwerks.
the class LustreContractAstBuilder method getContractLustreProgram.
public static Program getContractLustreProgram(AgreeProgram agreeProgram) {
nodes = new ArrayList<>();
List<TypeDef> types = AgreeUtils.getLustreTypes(agreeProgram);
AgreeNode flatNode = flattenAgreeNodeKindContract(agreeProgram.topNode, "_TOP__");
List<Expr> assertions = new ArrayList<>();
List<VarDecl> locals = new ArrayList<>();
List<VarDecl> inputs = new ArrayList<>();
List<VarDecl> outputs = new ArrayList<>();
List<Equation> equations = new ArrayList<>();
List<String> properties = new ArrayList<>();
List<Expr> requires = new ArrayList<>();
List<Expr> ensures = new ArrayList<>();
for (AgreeStatement assertion : flatNode.assertions) {
assertions.add(assertion.expr);
}
for (AgreeStatement assumption : flatNode.assumptions) {
requires.add(assumption.expr);
}
for (AgreeStatement guarantee : flatNode.lemmas) {
ensures.add(guarantee.expr);
}
for (AgreeStatement guarantee : flatNode.guarantees) {
ensures.add(guarantee.expr);
}
for (AgreeVar var : flatNode.inputs) {
inputs.add(var);
}
for (AgreeVar var : flatNode.outputs) {
outputs.add(var);
}
for (AgreeVar var : flatNode.outputs) {
if (var.reference instanceof AssumeStatement || var.reference instanceof LemmaStatement) {
throw new AgreeException("This shouldn't happen");
}
}
Contract contract = new Contract(requires, ensures);
NodeBuilder builder = new NodeBuilder("_TOP");
builder.addInputs(inputs);
builder.addOutputs(outputs);
builder.addLocals(locals);
builder.addEquations(equations);
builder.addProperties(properties);
builder.addAssertions(assertions);
builder.setContract(contract);
Node main = builder.build();
nodes.addAll(agreeProgram.globalLustreNodes);
nodes.add(main);
Program program = new ProgramBuilder().addTypes(types).addNodes(nodes).setMain(main.id).build();
return program;
}
use of com.rockwellcollins.atc.agree.agree.LemmaStatement in project AGREE by loonwerks.
the class AgreeASTBuilder method getLemmaStatements.
private List<AgreeStatement> getLemmaStatements(EList<SpecStatement> specs) {
List<AgreeStatement> lemmas = new ArrayList<>();
for (SpecStatement spec : specs) {
if (spec instanceof LemmaStatement) {
LemmaStatement lemma = (LemmaStatement) spec;
if (lemma.getExpr() != null) {
lemmas.add(new AgreeStatement(lemma.getStr(), doSwitch(lemma.getExpr()), spec));
} else {
PatternStatement pattern = lemma.getPattern();
lemmas.add(new AgreePatternBuilder(lemma.getStr(), lemma, this).doSwitch(pattern));
}
}
}
return lemmas;
}
Aggregations