use of jkind.lustre.Node in project AGREE by loonwerks.
the class RemoveProperties method transform.
public static SimulationProgram transform(final SimulationProgram program) {
final Program lustreProgram = program.getLustreProgram();
if (lustreProgram.nodes.size() != 1) {
throw new IllegalArgumentException("Only lustre programs with exactly one node are supported");
}
final SimulationProgramBuilder simulationProgramBuilder = new SimulationProgramBuilder(program);
final ProgramBuilder lustreProgramBuilder = new ProgramBuilder(lustreProgram);
lustreProgramBuilder.clearNodes();
final Node node = lustreProgram.getMainNode();
final NodeBuilder nodeBuilder = new NodeBuilder(node);
nodeBuilder.clearProperties();
// Add the new node to the new lustre program
lustreProgramBuilder.addNode(nodeBuilder.build());
simulationProgramBuilder.setLustreProgram(lustreProgramBuilder.build());
return simulationProgramBuilder.build();
}
use of jkind.lustre.Node in project AGREE by loonwerks.
the class RemovePropertySatisficationRequirements method transform.
// private final static String assumeBaseId = "__ASSUME";
public static SimulationProgram transform(final SimulationProgram program) {
final SimulationProgramBuilder simulationProgramBuilder = new SimulationProgramBuilder(program);
final ProgramBuilder lustreProgramBuilder = new ProgramBuilder(program.getLustreProgram());
lustreProgramBuilder.clearNodes();
for (final Node node : program.getLustreProgram().nodes) {
final NodeBuilder nodeBuilder = new NodeBuilder(new AstMapVisitor() {
@Override
public Node visit(final Node n) {
return super.visit(n);
}
@Override
public Equation visit(final Equation e) {
// Force the assumption conjunction to be true
if (e.lhs.size() == 1 && e.lhs.get(0).id.equals(assumptionConjunctionId)) {
return new Equation(new IdExpr(assumptionConjunctionId), new BoolExpr(true));
}
final Equation result = super.visit(e);
return result;
}
}.visit(node));
lustreProgramBuilder.addNode(nodeBuilder.build());
}
simulationProgramBuilder.setLustreProgram(lustreProgramBuilder.build());
return simulationProgramBuilder.build();
}
use of jkind.lustre.Node in project AGREE by loonwerks.
the class CreateLocalVariablesForPropertyExpressions method transform.
public static SimulationProgram transform(final SimulationProgram program) {
final Program lustreProgram = program.getLustreProgram();
final SimulationProgramBuilder builder = new SimulationProgramBuilder(program);
// Build mappings between Agree Statements, expressions, and Agree Nodes
final Map<Expr, AgreeStatement> exprToStatementMap = new HashMap<>();
final Map<AgreeStatement, AgreeNode> agreeStatementToAgreeNodeMap = new HashMap<>();
for (final AgreeNode agreeNode : program.getAllAgreeNodes()) {
for (final AgreeStatement statement : agreeNode.assertions) {
if (statement.reference instanceof AssertStatement) {
exprToStatementMap.put(statement.expr, statement);
agreeStatementToAgreeNodeMap.put(statement, agreeNode);
}
}
for (final AgreeStatement statement : agreeNode.assumptions) {
exprToStatementMap.put(statement.expr, statement);
agreeStatementToAgreeNodeMap.put(statement, agreeNode);
}
for (final AgreeStatement statement : agreeNode.guarantees) {
exprToStatementMap.put(statement.expr, statement);
agreeStatementToAgreeNodeMap.put(statement, agreeNode);
}
}
// Create local variables for assert statements, assumptions, and guarantees
final ProgramBuilder lustreBuilder = new ProgramBuilder(lustreProgram).clearNodes();
for (final Node lustreNode : lustreProgram.nodes) {
lustreBuilder.addNode(VariableCreator.transform(lustreNode, exprToStatementMap, agreeStatementToAgreeNodeMap));
}
builder.setLustreProgram(lustreBuilder.build());
return builder.build();
}
use of jkind.lustre.Node 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;
}
use of jkind.lustre.Node in project AGREE by loonwerks.
the class AgreeASTBuilder method getMNSynchConstraint.
private Expr getMNSynchConstraint(MNSynchStatement sync) {
Set<String> nodeNames = new HashSet<>();
Expr clockAssertion = new BoolExpr(true);
for (int i = 0; i < sync.getComp1().size(); i++) {
Subcomponent maxComp = (Subcomponent) sync.getComp1().get(i);
Subcomponent minComp = (Subcomponent) sync.getComp2().get(i);
Expr maxClock = new IdExpr(maxComp.getName() + clockIDSuffix);
Expr minClock = new IdExpr(minComp.getName() + clockIDSuffix);
int max = Integer.valueOf(sync.getMax().get(i));
int min = Integer.valueOf(sync.getMin().get(i));
MNSynchronyElement elem = new MNSynchronyElement(maxClock, minClock, max, min);
String nodeName = "__calendar_node_" + elem.max + "_" + elem.min;
nodeName = getObjectLocationPrefix(sync) + nodeName;
if (!nodeNames.contains(nodeName)) {
nodeNames.add(nodeName);
Node calNode = AgreeCalendarUtils.getMNCalendar(nodeName, elem.max, elem.min);
addToNodeList(calNode);
}
NodeCallExpr nodeCall = new NodeCallExpr(nodeName, elem.maxClock, elem.minClock);
clockAssertion = LustreExprFactory.makeANDExpr(clockAssertion, nodeCall);
nodeCall = new NodeCallExpr(nodeName, elem.minClock, elem.maxClock);
clockAssertion = LustreExprFactory.makeANDExpr(clockAssertion, nodeCall);
}
return clockAssertion;
}
Aggregations