@Override public IProofObligationList caseAMapEnumMapExp(AMapEnumMapExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); List<AMapletExp> members = node.getMembers(); for (AMapletExp maplet : members) { obligations.addAll(maplet.apply(mainVisitor, question)); } if (members.size() > 1) { obligations.add(new MapInjectivityEnum(node, question, aF)); } return obligations; }
@Override public IProofObligationList caseADistMergeUnaryExp(ADistMergeUnaryExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); obligations.add(new MapInjectivityComp(node.getExp(), question, aF)); return obligations; }
@Override public IProofObligationList caseAWhileStm(AWhileStm node, IPOContextStack question) throws AnalysisException { try { IProofObligationList obligations = new ProofObligationList(); obligations.add(new WhileLoopObligation(node, question, aF)); obligations.addAll(node.getExp().apply(rootVisitor, question)); obligations.addAll(node.getStatement().apply(mainVisitor, question)); return obligations; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
@Override public IProofObligationList caseADistIntersectUnaryExp( ADistIntersectUnaryExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = node.getExp().apply(mainVisitor, question); obligations.add(new org.overture.pog.obligation.NonEmptySetObligation(node.getExp(), question, aF)); return obligations; }
private <T extends PExp> IProofObligationList handleDivideNumericBinaryExp( T node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); PExp[] leftRight = getLeftRight(node); PExp rExp = leftRight[RIGHT]; obligations.addAll(defaultSNumericBinaryExp((SNumericBinaryExp) node, question)); if (!neverZero(rExp)) { obligations.add(new NonZeroObligation(node.getLocation(), rExp, question, aF)); } return obligations; }
@Override public IProofObligationList caseAMapUnionBinaryExp(AMapUnionBinaryExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = handleBinaryExpression(node, question); obligations.add(new MapCompatibleObligation(node.getLeft(), node.getRight(), question, aF)); return obligations; }
@Override public IProofObligationList caseAStateDefinition(AStateDefinition node, IPOContextStack question) throws AnalysisException { try { IProofObligationList list = new ProofObligationList(); if (node.getInvdef() != null) { list.addAll(node.getInvdef().apply(mainVisitor, question)); list.add(new SatisfiabilityObligation(node, question, assistantFactory)); } return list; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
@Override public IProofObligationList caseAMapInverseUnaryExp( AMapInverseUnaryExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = node.getExp().apply(mainVisitor, question); if (!node.getMapType().getEmpty()) { obligations.add(new org.overture.pog.obligation.MapInverseObligation(node, question, aF)); } return obligations; }
@Override public IProofObligationList caseAIotaExp(AIotaExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = node.getBind().apply(rootVisitor, question); obligations.add(new UniqueExistenceObligation(node, question, aF)); question.push(new POForAllContext(aF, node)); obligations.addAll(node.getPredicate().apply(mainVisitor, question)); question.pop(); return obligations; }
@Override public IProofObligationList caseAStarStarBinaryExp(AStarStarBinaryExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); PExp lExp = node.getLeft(); PType lType = lExp.getType(); if (aF.createPTypeAssistant().isFunction(lType)) { ILexNameToken preName = getPreName(lExp); if (preName == null || !preName.equals(NO_PRECONDITION)) { obligations.add(new org.overture.pog.obligation.FuncIterationObligation(node, preName, question, aF)); } } if (aF.createPTypeAssistant().isMap(lType)) { obligations.add(new MapIterationObligation(node, question, aF)); } return obligations; }
@Override public IProofObligationList caseALetBeStStm(ALetBeStStm node, IPOContextStack question) throws AnalysisException { try { IProofObligationList obligations = new ProofObligationList(); obligations.add(new LetBeExistsObligation(node, question, aF)); obligations.addAll(node.getBind().apply(rootVisitor, question)); if (node.getSuchThat() != null) { obligations.addAll(node.getSuchThat().apply(rootVisitor, question)); } question.push(new POScopeContext()); obligations.addAll(node.getStatement().apply(mainVisitor, question)); question.pop(); return obligations; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
@Override public IProofObligationList caseAMapSeqStateDesignator( AMapSeqStateDesignator node, IPOContextStack question) throws AnalysisException { try { IProofObligationList list = new ProofObligationList(); if (node.getSeqType() != null) { list.add(new SeqApplyObligation(node.getMapseq(), node.getExp(), question, assistantFactory)); } // Maps are OK, as you can create new map domain entries return list; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
@Override // RWL See [1] pg.95 public IProofObligationList caseALetBeStExp(ALetBeStExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); obligations.add(new LetBeExistsObligation(node, question, aF)); obligations.addAll(node.getBind().apply(rootVisitor, question)); PExp suchThat = node.getSuchThat(); if (suchThat != null) { question.push(new POForAllContext(node, aF)); obligations.addAll(suchThat.apply(mainVisitor, question)); question.pop(); } question.push(new POForAllPredicateContext(node, aF)); obligations.addAll(node.getValue().apply(mainVisitor, question)); question.pop(); return obligations; }
@Override public IProofObligationList caseAPlusPlusBinaryExp(APlusPlusBinaryExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = handleBinaryExpression(node, question); PType lType = node.getLeft().getType(); if (aF.createPTypeAssistant().isSeq(lType)) { obligations.add(new org.overture.pog.obligation.SeqModificationObligation(node, question, aF)); } return obligations; }
@Override public IProofObligationList caseACallStm(ACallStm node, IPOContextStack question) throws AnalysisException { try { IProofObligationList obligations = new ProofObligationList(); for (PExp exp : node.getArgs()) { obligations.addAll(exp.apply(rootVisitor, question)); } // stick possible op post_condition in the context SOperationDefinitionBase calledOp = node.apply(new GetOpCallVisitor()); if (calledOp != null) { if (calledOp.getPrecondition() != null) { obligations.add(new OperationCallObligation(node, calledOp, question, aF)); } question.push(new OpPostConditionContext(calledOp.getPostdef(), node, calledOp, aF, question)); } return obligations; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
@Override public IProofObligationList caseACompBinaryExp(ACompBinaryExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); PExp lExp = node.getLeft(); PType lType = lExp.getType(); PExp rExp = node.getRight(); if (aF.createPTypeAssistant().isFunction(lType)) { ILexNameToken pref1 = getPreName(lExp); ILexNameToken pref2 = getPreName(rExp); if (pref1 == null || !pref1.equals(NO_PRECONDITION)) { obligations.add(new FuncComposeObligation(node, pref1, pref2, question, aF));// gkanos:add on more // argument for the // assistantFactory need // it } } if (aF.createPTypeAssistant().isMap(lType)) { obligations.add(new MapComposeObligation(node, question, aF)); } return obligations; }
@Override public IProofObligationList caseANarrowExp(ANarrowExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); PType expected = node.getTypedef() == null ? node.getBasicType() : aF.createPDefinitionAssistant().getType(node.getTypedef()); question.noteType(node.getTest(), expected); if (!aF.getTypeComparator().isSubType(node.getTest().getType(), expected)) { TypeCompatibilityObligation sto = TypeCompatibilityObligation.newInstance(node.getTest(), expected, node.getTest().getType(), question, aF); if (sto != null) { obligations.add(sto); } } obligations.addAll(node.getTest().apply(rootVisitor, question)); return obligations; }
@Override public IProofObligationList caseATailUnaryExp(ATailUnaryExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = node.getExp().apply(mainVisitor, question); if (!aF.createPTypeAssistant().isType(node.getExp().getType(), ASeq1SeqType.class)) { obligations.add(new NonEmptySeqObligation(node.getExp(), question, aF)); } return obligations; }
private void handleBinExpSubNode(IPOContextStack question, IProofObligationList obligations, PExp left, PType ltype) throws AnalysisException { PTypeAssistantTC pTA = aF.createPTypeAssistant(); if (pTA.isUnion(ltype)) { for (PType type : pTA.getUnion(ltype).getTypes()){ if (!pTA.isNumeric(type)){ TypeCompatibilityObligation sto = TypeCompatibilityObligation.newInstance(left, AstFactory.newARealNumericBasicType(left.getLocation()), ltype, question, aF); if (sto != null) { obligations.add(sto); } } } } }
@Override public IProofObligationList caseAFieldNumberExp(AFieldNumberExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = node.getTuple().apply(mainVisitor, question); PType puType = node.getTuple().getType(); if (aF.createPTypeAssistant().isUnion(puType)) { AUnionType utype = (AUnionType) aF.createPTypeAssistant().getUnion(puType); for (PType t : utype.getTypes()) { if (t instanceof AProductType) { AProductType aprodType = (AProductType) t; if (aprodType.getTypes().size() >= node.getField().getValue()) { // tuple selection is fine. do nothing and check the // next one continue; } } obligations.add(new TupleSelectObligation(node.getTuple(), t, question, aF)); } } return obligations; }