public POFunctionDefinitionContext(AImplicitFunctionDefinition definition, boolean precond, IPogAssistantFactory assistantFactory) { this.name = definition.getName(); this.deftype = (AFunctionType) definition.getType(); this.addPrecond = precond; this.paramPatternList = assistantFactory .createAImplicitFunctionDefinitionAssistant() .getParamPatternList(definition); this.precondition = definition.getPrecondition(); this.argtypes = calculateTypes(deftype, false); }
public POOperationDefinitionContext( AImplicitOperationDefinition definition, boolean precond, PDefinition stateDefinition, IPogAssistantFactory assistantFactory) { this.name = definition.getName(); this.deftype = (AOperationType) definition.getType(); this.addPrecond = precond; this.paramPatternList = assistantFactory.createAImplicitOperationDefinitionAssistant().getParamPatternList(definition); this.precondition = definition.getPrecondition(); this.stateDefinition = stateDefinition; this.opDef = definition; }
@Override public IProofObligationList caseABlockSimpleBlockStm( ABlockSimpleBlockStm node, IPOContextStack question) throws AnalysisException { try { IProofObligationList obligations = aF.createPDefinitionAssistant().getProofObligations(node.getAssignmentDefs(), rootVisitor, question); question.push(new POScopeContext()); obligations.addAll(defaultSSimpleBlockStm(node, question)); question.pop(); return obligations; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
public OperationCallObligation(ACallStm stm, SOperationDefinitionBase def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(stm, POType.OP_CALL, ctxt, stm.getLocation(), af); // cannot quote pre-cond so we spell it out with rewritten arguments List<Substitution> subs = new LinkedList<Substitution>(); for (int i = 0; i < stm.getArgs().size(); i++) { PPattern orig = def.getPredef().getParamPatternList().get(0).get(i); ILexNameToken origName = af.createPPatternAssistant().getAllVariableNames(orig).get(0).clone(); PExp new_exp = stm.getArgs().get(0); subs.add(new Substitution(origName, new_exp)); } PExp pre_exp = def.getPrecondition().clone(); for (Substitution sub : subs) { pre_exp = pre_exp.clone().apply(af.getVarSubVisitor(), sub); } stitch = pre_exp; valuetree.setPredicate(ctxt.getPredWithContext(pre_exp)); }
List<PType> rset = new LinkedList<>(); PTypeAssistantTC pta = aF.createPTypeAssistant(); if (pta.isUnion(exp.getLeft().getType())) if (lhs.apply(aF.getIsOrderedVisitor(), exp.getLocation())) if (lhs.apply(aF.getIsOrderedVisitor(), exp.getLocation()) && aF.getTypeComparator().compatible(lhs, rhs))
&& assistantFactory.createPTypeAssistant().isUnion(type)) PType patternType = assistantFactory.createPPatternAssistant().getPossibleType(pattern); AUnionType ut = assistantFactory.createPTypeAssistant().getUnion(type); PTypeSet set = new PTypeSet(assistantFactory); if (assistantFactory.getTypeComparator().compatible(u, patternType)) if (!assistantFactory.getTypeComparator().isSubType(type, compatible)) if (!assistantFactory.getTypeComparator().isSubType(question.checkType(exp, node.getExpType()), type))
&& node.getExpType() instanceof AUnionType) PType patternType = assistantFactory.createPPatternAssistant().getPossibleType(pattern); // With if (assistantFactory.getTypeComparator().compatible(u, patternType)) if (!assistantFactory.getTypeComparator().isSubType(question.checkType(node.getTest(), node.getExpType()), compatible)) if (!assistantFactory.getTypeComparator().isSubType(question.checkType(node.getTest(), node.getExpType()), node.getDefType()))
@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; }
if (assistantFactory.getTypeComparator().isSubType(atype, etype)) if (assistantFactory.getTypeComparator().isSubType(exp.getType(), etype)) etype = assistantFactory.createPTypeAssistant().deBracket(etype); || assistantFactory.getTypeComparator().compatible(pos, atype)) if (assistantFactory.createSNumericBasicTypeAssistant().getWeight(ant) > assistantFactory.createSNumericBasicTypeAssistant().getWeight(ent)) boolean isWhole = assistantFactory.createSNumericBasicTypeAssistant().getWeight(ant) < 3;
private PExp addPossibleType(PExp exp, PPattern node) { PType possibleType = af.createPPatternAssistant().getPossibleType(node); if (possibleType != null) { exp.setType(possibleType.clone()); } else { exp.setType(new AUnknownType()); } return exp; } }
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.getTypeComparator().isSubType(aType, mapType.getFrom())) if (!aF.createPTypeAssistant().isUnknown(type) && aF.createPTypeAssistant().isFunction(type)) AFunctionType funcType = aF.createPTypeAssistant().getFunction(type); ILexNameToken prename = getPreName(root); if (prename == null PType pt = funcType.getParameters().get(i); if (!aF.getTypeComparator().isSubType(argType, pt)) if (aF.createPTypeAssistant().isSeq(type))
@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; }
private PExp invDefs(SClassDefinition def) { PExp root = null; for (PDefinition d : assistantFactory.createSClassDefinitionAssistant().getInvDefs(def.clone())) { AClassInvariantDefinition cid = (AClassInvariantDefinition) d; root = makeAnd(root, cid.getExpression().clone()); } return root; }
public POForAllContext(ALetBeStExp exp, IPogAssistantFactory assistantFactory) { this.bindings = cloneBinds(assistantFactory.createPMultipleBindAssistant().getMultipleBindList(exp.getBind())); }
private PExp buildInvExp(SOperationDefinitionBase calledOp, IPogAssistantFactory af) { List<PExp> invariants = new LinkedList<PExp>(); if (calledOp.getClassDefinition() != null) { try { invariants = calledOp.getClassDefinition().apply(af.getInvExpGetVisitor()); if (invariants.size() > 0) { PExp inv = invariants.get(0).clone(); for (int i = 1; i < invariants.size(); i++) { inv = AstExpressionFactory.newAAndBooleanBinaryExp(inv, invariants.get(i).clone()); } return inv; } else { return null; } } catch (AnalysisException e) { e.printStackTrace(); } } return null; }
public ParameterPatternObligation(AExplicitOperationDefinition def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(def, POType.OPERATION_PATTERNS, ctxt, def.getLocation(), af); this.assistantFactory = af; stitch = generate(def.getPredef(), cloneListPatternList(assistantFactory.createAExplicitOperationDefinitionAssistant().getParamPatternList(def)), cloneListType(((AOperationType) def.getType()).getParameters()), ((AOperationType) def.getType()).getResult().clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
for (PDefinition def : assistantFactory.createPPatternAssistant().getDefinitions(p, typeIter.next(), NameScope.LOCAL)) && !assistantFactory.getTypeComparator().isSubType(node.getActualResult(), ((AOperationType) node.getType()).getResult()))
@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; }
ILexNameToken origName = af.createPPatternAssistant().getAllVariableNames(orig).get(0).clone(); PExp new_exp = args.get(0).clone(); subs.add(new Substitution(origName, new_exp));
private PExp invDefs(PDefinition def) { if (def instanceof AStateDefinition) { return ((AStateDefinition) def).getInvdef().getBody(); } else { PExp root = null; for (PDefinition d : assistantFactory.createSClassDefinitionAssistant().getInvDefs((SClassDefinition) def)) { AClassInvariantDefinition cid = (AClassInvariantDefinition) d; root = makeAnd(root, cid.getExpression().clone()); } return root; } }