@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 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 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 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; }
@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); } } } } }
List<PType> rset = new LinkedList<>(); PTypeAssistantTC pta = aF.createPTypeAssistant(); if (pta.isUnion(exp.getLeft().getType()))
if (aF.createPTypeAssistant().isMap(type)) SMapType mapType = aF.createPTypeAssistant().getMap(type); obligations.add(new MapApplyObligation(node.getRoot(), node.getArgs().get(0), question, aF)); PType aType = question.checkType(node.getArgs().get(0), node.getArgtypes().get(0)); if (!aF.createPTypeAssistant().isUnknown(type) && aF.createPTypeAssistant().isFunction(type)) AFunctionType funcType = aF.createPTypeAssistant().getFunction(type); ILexNameToken prename = getPreName(root); if (prename == null if (aF.createPTypeAssistant().isSeq(type))
private <T> IProofObligationList handleBinaryBooleanExp(T node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); PExp[] leftRight = getLeftRight(node); PExp lExp = leftRight[LEFT]; PType lType = lExp.getType(); PExp rExp = leftRight[RIGHT]; PType rType = rExp.getType(); if (aF.createPTypeAssistant().isUnion(lType)) { TypeCompatibilityObligation sto = TypeCompatibilityObligation.newInstance(lExp, AstFactory.newABooleanBasicType(lExp.getLocation()), lType, question, aF); if (sto != null) { obligations.add(sto); } } if (aF.createPTypeAssistant().isUnion(rType)) { TypeCompatibilityObligation sto = TypeCompatibilityObligation.newInstance(rExp, AstFactory.newABooleanBasicType(rExp.getLocation()), rType, question, aF); if (sto != null) { obligations.add(sto); } } obligations.addAll(lExp.apply(mainVisitor, question)); obligations.addAll(rExp.apply(mainVisitor, question)); return obligations; }
@Override public IProofObligationList caseAImpliesBooleanBinaryExp( AImpliesBooleanBinaryExp node, IPOContextStack question) throws AnalysisException { ProofObligationList obligations = new ProofObligationList(); PExp[] leftRight = getLeftRight(node); PExp lExp = leftRight[LEFT]; PType lType = lExp.getType(); PExp rExp = leftRight[RIGHT]; PType rType = rExp.getType(); if (aF.createPTypeAssistant().isUnion(lType)) { obligations.add(TypeCompatibilityObligation.newInstance(lExp, AstFactory.newABooleanBasicType(lExp.getLocation()), lType, question, aF)); } if (aF.createPTypeAssistant().isUnion(rType)) { obligations.add(TypeCompatibilityObligation.newInstance(rExp, AstFactory.newABooleanBasicType(rExp.getLocation()), rType, question, aF)); } obligations.addAll(lExp.apply(mainVisitor, question)); question.push(new POImpliesContext(lExp)); obligations.addAll(rExp.apply(mainVisitor, question)); question.pop(); return obligations; }
@Override // see [1] pg. 179 unary expressions public IProofObligationList caseAHeadUnaryExp(AHeadUnaryExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = defaultSUnaryExp(node, question); PExp exp = node.getExp(); // RWL This is a hack. The new ast LexNameToken's toString method // includes the module e.g. like Test`b for variables // which the old one did not. Hence proof obligations with variable // names are different as "Test`b" is just b with the old proof // obligations generator. PExp fake = exp.clone(); if (exp instanceof AVariableExp) { AVariableExp var = (AVariableExp) fake; var.setName(new LexNameToken("", var.getName().getIdentifier().clone())); } if (!aF.createPTypeAssistant().isType(exp.getType(), ASeq1SeqType.class)) { obligations.add(new NonEmptySeqObligation(fake, question, aF)); } return obligations; }
PType rType = rExp.getType(); if (aF.createPTypeAssistant().isUnion(lType)) if (aF.createPTypeAssistant().isUnion(rType))
domM1.setExp(getVarExp(m1, mapEnumExp.getType())); SSetType domType = new ASetSetType(); domType.setSetof(af.createPTypeAssistant().getMap(mapEnumExp.getType().clone())); domM1.setType(domType.clone()); AMapDomainUnaryExp domM2 = new AMapDomainUnaryExp(); domM2.setType(domType.clone()); AApplyExp applyExp = getApplyExp(getVarExp(m2, mapEnumExp.getType()), af.createPTypeAssistant().getMap(mapEnumExp.getType()).getTo(), getVarExp(d2, domType)); AApplyExp applyExp2 = getApplyExp(getVarExp(m1, mapEnumExp.getType()),af.createPTypeAssistant().getMap(mapEnumExp.getType()).getTo(), getVarExp(d1, domType)); AEqualsBinaryExp equalsExp = getEqualsExp(applyExp2, applyExp); AImpliesBooleanBinaryExp implies = AstExpressionFactory.newAImpliesBooleanBinaryExp(getEqualsExp(getVarExp(d1, domType), getVarExp(d2, domType)), equalsExp);
&& assistantFactory.createPTypeAssistant().isUnion(type)) AUnionType ut = assistantFactory.createPTypeAssistant().getUnion(type); PTypeSet set = new PTypeSet(assistantFactory);
PType leftPType = assistantFactory.createPTypeAssistant().getFunction(exp.getLeft().getType()).getParameters().get(0).clone(); forallExp.setBindList(getMultipleTypeBindList(leftPType, arg)); PExp firstPart = null;
public FuncIterationObligation(AStarStarBinaryExp exp, ILexNameToken preName, IPOContextStack ctxt, IPogAssistantFactory assistantFactory) throws AnalysisException { super(exp, POType.FUNC_ITERATION, ctxt, exp.getLocation(), assistantFactory); // n > 1 AGreaterNumericBinaryExp gTExp = AstExpressionFactory.newAGreaterNumericBinaryExp(exp.getRight().clone(), getIntLiteral(1)); // forall n :T & P(X) AForAllExp forAllExp = new AForAllExp(); ILexNameToken arg = getUnique("arg"); List<PMultipleBind> bindList = getMultipleTypeBindList(assistantFactory.createPTypeAssistant().getNumeric(exp.getRight().getType().clone()), arg); forAllExp.setBindList(bindList); forAllExp.setPredicate(getPredicate(exp.clone(), preName.clone(), arg)); // n > 1 => forall n :T & P(X) AImpliesBooleanBinaryExp impliesExp = AstExpressionFactory.newAImpliesBooleanBinaryExp(gTExp, forAllExp); stitch = impliesExp.clone(); valuetree.setPredicate(ctxt.getPredWithContext(impliesExp)); }
etype = assistantFactory.createPTypeAssistant().deBracket(etype);