Search in sources :

Example 1 with EventBAxiom

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

the class ContextTranslator method processAxiomsAndTheorems.

private List<PContextClause> processAxiomsAndTheorems() {
    List<PContextClause> axiomsAndThms = new ArrayList<>();
    List<PPredicate> axioms = new ArrayList<>();
    List<PPredicate> thms = new ArrayList<>();
    for (EventBAxiom axiom : context.getAxioms()) {
        PPredicate ppred = (PPredicate) ((EventB) axiom.getPredicate()).getAst();
        nodeInfos.put(ppred, new Tuple2<>(context.getName(), axiom.getName()));
        if (axiom.isTheorem()) {
            thms.add(ppred);
        } else {
            axioms.add(ppred);
        }
    }
    axiomsAndThms.add(new AAxiomsContextClause(axioms));
    axiomsAndThms.add(new ATheoremsContextClause(thms));
    return axiomsAndThms;
}
Also used : EventBAxiom(de.prob.model.eventb.EventBAxiom) ArrayList(java.util.ArrayList) ATheoremsContextClause(de.be4.classicalb.core.parser.node.ATheoremsContextClause) PPredicate(de.be4.classicalb.core.parser.node.PPredicate) AAxiomsContextClause(de.be4.classicalb.core.parser.node.AAxiomsContextClause) PContextClause(de.be4.classicalb.core.parser.node.PContextClause)

Example 2 with EventBAxiom

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

the class ContextXmlHandler method addAxiom.

private void addAxiom(final Attributes attributes) {
    String source = attributes.getValue("org.eventb.core.source");
    String internalName = source.substring(source.lastIndexOf('#') + 1, source.length());
    String filePath = source.substring(0, source.indexOf('|'));
    String contextName = filePath.substring(filePath.lastIndexOf('/') + 1, filePath.lastIndexOf('.'));
    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"));
    if (inInternalContext) {
        if (contextName.equals(internalContext.getName())) {
            EventBAxiom axiom = new EventBAxiom(label, predicate, theorem, typeEnv);
            internalAxioms.add(axiom);
            axiomCache.get(internalContext.getName()).put(internalName, axiom);
        } else {
            internalInheritedAxioms.add(axiomCache.get(contextName).get(internalName));
        }
    } else {
        if (contextName.equals(context.getName())) {
            EventBAxiom axiom = new EventBAxiom(label, predicate, theorem, typeEnv);
            axioms.add(axiom);
            axiomCache.get(context.getName()).put(internalName, axiom);
        } else {
            inheritedAxioms.add(axiomCache.get(contextName).get(internalName));
        }
    }
}
Also used : EventBAxiom(de.prob.model.eventb.EventBAxiom)

Example 3 with EventBAxiom

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

the class MachineXmlHandler method addAxiom.

private void addAxiom(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 contextName = filePath.substring(filePath.lastIndexOf('/') + 1, filePath.lastIndexOf('.'));
    if (contextName.equals(internalContext.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"));
        EventBAxiom axiom = new EventBAxiom(label, predicate, theorem, typeEnv);
        axioms.add(axiom);
        axiomCache.get(internalContext.getName()).put(internalName, axiom);
    } else {
        inheritedAxioms.add(axiomCache.get(contextName).get(internalName));
    }
}
Also used : EventBAxiom(de.prob.model.eventb.EventBAxiom)

Example 4 with EventBAxiom

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

the class TheoryTranslator method printAxiomaticDefinitonBlock.

private void printAxiomaticDefinitonBlock(final AxiomaticDefinitionBlock block, final IPrologTermOutput pto) {
    pto.openTerm("axiomatic_def_block");
    pto.printAtom(block.getName());
    printTypeParameters(block.getTypeParameters(), pto);
    pto.openList();
    for (Operator operator : block.getOperators()) {
        printAxiomaticOperator(operator, pto);
    }
    pto.closeList();
    pto.openList();
    for (EventBAxiom axiom : block.getAxioms()) {
        printEventBElement((EventB) axiom.getPredicate(), pto);
    }
    pto.closeList();
    pto.closeTerm();
}
Also used : Operator(de.prob.model.eventb.theory.Operator) EventBAxiom(de.prob.model.eventb.EventBAxiom)

Aggregations

EventBAxiom (de.prob.model.eventb.EventBAxiom)4 AAxiomsContextClause (de.be4.classicalb.core.parser.node.AAxiomsContextClause)1 ATheoremsContextClause (de.be4.classicalb.core.parser.node.ATheoremsContextClause)1 PContextClause (de.be4.classicalb.core.parser.node.PContextClause)1 PPredicate (de.be4.classicalb.core.parser.node.PPredicate)1 Operator (de.prob.model.eventb.theory.Operator)1 ArrayList (java.util.ArrayList)1