use of de.prob.model.eventb.EventBInvariant in project prob2 by bendisposto.
the class MachineXmlHandler method addInvariant.
private void addInvariant(final Attributes attributes) {
String source = attributes.getValue("org.eventb.core.source");
String internalName = source.substring(source.lastIndexOf('#') + 1, source.length());
internalName = internalName.replace("\\", "");
String filePath = source.substring(0, source.indexOf('|'));
String machineName = filePath.substring(filePath.lastIndexOf('/') + 1, filePath.lastIndexOf('.'));
if (machineName.equals(machine.getName())) {
String label = attributes.getValue("org.eventb.core.label");
String predicate = attributes.getValue("org.eventb.core.predicate");
boolean theorem = "true".equals(attributes.getValue("org.eventb.core.theorem"));
EventBInvariant inv = new EventBInvariant(label, predicate, theorem, typeEnv);
invariants.add(inv);
invariantCache.get(machine.getName()).put(internalName, inv);
} else {
inheritedInvariants.add(invariantCache.get(machineName).get(internalName));
}
}
use of de.prob.model.eventb.EventBInvariant in project prob2 by bendisposto.
the class EventBMachineTranslator method processInvariantsAndTheorems.
private List<PModelClause> processInvariantsAndTheorems() {
List<PModelClause> invsAndTheorems = new ArrayList<>();
List<PPredicate> invs = new ArrayList<>();
List<PPredicate> thms = new ArrayList<>();
List<EventBInvariant> allInvs = machine.getInvariants();
for (EventBInvariant ebInv : allInvs) {
PPredicate ppred = (PPredicate) ((EventB) ebInv.getPredicate()).getAst();
nodeInfos.put(ppred, new Tuple2<>(machine.getName(), ebInv.getName()));
if (ebInv.isTheorem()) {
thms.add(ppred);
} else {
invs.add(ppred);
}
}
invsAndTheorems.add(new AInvariantModelClause(invs));
invsAndTheorems.add(new ATheoremsModelClause(thms));
return invsAndTheorems;
}
Aggregations