Search in sources :

Example 1 with EventBInvariant

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));
    }
}
Also used : EventBInvariant(de.prob.model.eventb.EventBInvariant)

Example 2 with EventBInvariant

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;
}
Also used : PModelClause(de.be4.classicalb.core.parser.node.PModelClause) AInvariantModelClause(de.be4.classicalb.core.parser.node.AInvariantModelClause) ArrayList(java.util.ArrayList) PPredicate(de.be4.classicalb.core.parser.node.PPredicate) ATheoremsModelClause(de.be4.classicalb.core.parser.node.ATheoremsModelClause) EventBInvariant(de.prob.model.eventb.EventBInvariant)

Aggregations

EventBInvariant (de.prob.model.eventb.EventBInvariant)2 AInvariantModelClause (de.be4.classicalb.core.parser.node.AInvariantModelClause)1 ATheoremsModelClause (de.be4.classicalb.core.parser.node.ATheoremsModelClause)1 PModelClause (de.be4.classicalb.core.parser.node.PModelClause)1 PPredicate (de.be4.classicalb.core.parser.node.PPredicate)1 ArrayList (java.util.ArrayList)1