Search in sources :

Example 1 with ProofObligation

use of de.prob.model.eventb.ProofObligation in project prob2 by bendisposto.

the class EventBModelTranslator method printProlog.

public void printProlog(final IPrologTermOutput pto) {
    RodinPosPrinter labelPrinter = new RodinPosPrinter();
    List<Node> machineNodes = new ArrayList<>();
    List<Node> contextNodes = new ArrayList<>();
    for (EventBMachineTranslator trans : machineTranslators) {
        machineNodes.add(trans.translateMachine());
        labelPrinter.addNodeInfos(trans.getNodeInfos());
    }
    for (ContextTranslator t : contextTranslators) {
        contextNodes.add(t.translateContext());
        labelPrinter.addNodeInfos(t.getNodeInfos());
    }
    ASTProlog printer = new ASTProlog(pto, labelPrinter);
    pto.openTerm("load_event_b_project");
    pto.openList();
    for (Node node : machineNodes) {
        node.apply(printer);
    }
    pto.closeList();
    pto.openList();
    for (Node node : contextNodes) {
        node.apply(printer);
    }
    pto.closeList();
    pto.openList();
    pto.openTerm("exporter_version");
    pto.printNumber(3);
    pto.closeTerm();
    for (ProofObligation po : proofObligations) {
        po.toProlog(pto);
    }
    theoryTranslator.toProlog(pto);
    printPragmas(pto);
    pto.closeList();
    pto.printVariable("_Error");
    pto.closeTerm();
}
Also used : ASTProlog(de.be4.classicalb.core.parser.analysis.prolog.ASTProlog) ProofObligation(de.prob.model.eventb.ProofObligation) Node(de.be4.classicalb.core.parser.node.Node) ArrayList(java.util.ArrayList)

Example 2 with ProofObligation

use of de.prob.model.eventb.ProofObligation in project prob2 by bendisposto.

the class ProofExtractor method addProofs.

private void addProofs(final EventBMachine m) {
    for (Map.Entry<String, String> entry : descriptions.entrySet()) {
        String name = entry.getKey();
        String desc = entry.getValue();
        boolean isDischarged = discharged.contains(name);
        String[] split = name.split("/");
        String type;
        if (split.length == 1) {
            type = split[0];
        } else if (split.length == 2) {
            type = split[1];
        } else {
            type = split[2];
        }
        String source = m.getName();
        List<Tuple2<String, String>> elements = new ArrayList<>();
        if ("GRD".equals(type)) {
            Event concreteEvent = m.getEvent(split[0]);
            for (Event event : concreteEvent.getRefines()) {
                if (event.getGuards().getElement(split[1]) != null) {
                    EventBGuard guard = event.getGuards().getElement(split[1]);
                    elements.add(new Tuple2<>("event", event.getName()));
                    elements.add(new Tuple2<>("guard", guard.getName()));
                }
            }
            elements.add(new Tuple2<>("event", concreteEvent.getName()));
            proofs.add(new ProofObligation(source, name, isDischarged, desc, elements));
        } else if ("INV".equals(type)) {
            elements.add(new Tuple2<>("event", "invariant"));
            proofs.add(new ProofObligation(source, name, isDischarged, desc, elements));
        } else if ("THM".equals(type)) {
            if (split.length == 2) {
                elements.add(new Tuple2<>("invariant", split[0]));
            } else {
                elements.add(new Tuple2<>("guard", split[1]));
                elements.add(new Tuple2<>("event", split[0]));
            }
            proofs.add(new ProofObligation(source, name, isDischarged, desc, elements));
        } else if ("WD".equals(type)) {
            if (split.length == 2) {
                elements.add(new Tuple2<>("invariant", split[0]));
            } else {
                Event event = m.getEvent(split[0]);
                if (event.getActions().getElement(split[1]) != null) {
                    elements.add(new Tuple2<>("event", event.getName()));
                    elements.add(new Tuple2<>("action", split[1]));
                } else {
                    elements.add(new Tuple2<>("event", event.getName()));
                    elements.add(new Tuple2<>("guard", split[1]));
                }
                proofs.add(new ProofObligation(source, name, isDischarged, desc, elements));
            }
        } else {
            proofs.add(new ProofObligation(source, name, isDischarged, desc, elements));
        }
    }
}
Also used : Tuple2(de.prob.util.Tuple2) ProofObligation(de.prob.model.eventb.ProofObligation) ArrayList(java.util.ArrayList) Event(de.prob.model.eventb.Event) EventBGuard(de.prob.model.eventb.EventBGuard) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with ProofObligation

use of de.prob.model.eventb.ProofObligation in project prob2 by bendisposto.

the class ProofExtractor method addProofs.

private void addProofs(final Context c) {
    for (Map.Entry<String, String> entry : descriptions.entrySet()) {
        String name = entry.getKey();
        String desc = entry.getValue();
        boolean isDischarged = discharged.contains(name);
        String[] split = name.split("/");
        String type;
        if (split.length == 1) {
            type = split[0];
        } else if (split.length == 2) {
            type = split[1];
        } else {
            type = split[2];
        }
        String source = c.getName();
        List<Tuple2<String, String>> elements = new ArrayList<>();
        if ("THM".equals(type) || "WD".equals(type)) {
            elements.add(new Tuple2<>("axiom", split[0]));
        }
        proofs.add(new ProofObligation(source, name, isDischarged, desc, elements));
    }
}
Also used : Tuple2(de.prob.util.Tuple2) ProofObligation(de.prob.model.eventb.ProofObligation) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ProofObligation (de.prob.model.eventb.ProofObligation)3 ArrayList (java.util.ArrayList)3 Tuple2 (de.prob.util.Tuple2)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ASTProlog (de.be4.classicalb.core.parser.analysis.prolog.ASTProlog)1 Node (de.be4.classicalb.core.parser.node.Node)1 Event (de.prob.model.eventb.Event)1 EventBGuard (de.prob.model.eventb.EventBGuard)1