protected AForAllExp getSuperContext(PExp stitch) { AForAllExp forAllExp = new AForAllExp(); forAllExp.setType(new ABooleanBasicType()); forAllExp.setBindList(cloneBinds(bindings)); forAllExp.setPredicate(stitch); return forAllExp; }
/** * Create the context (forall x,y,z...) for a Proof Obligation for * eq and ord relations. */ protected AForAllExp makeRelContext(ATypeDefinition node, AVariableExp... exps){ AForAllExp forall_exp = new AForAllExp(); forall_exp.setType(new ABooleanBasicType()); ATypeMultipleBind tmb = new ATypeMultipleBind(); List<PPattern> pats = new LinkedList<>(); for (AVariableExp exp : exps) { pats.add(AstFactory.newAIdentifierPattern(exp.getName().clone())); } tmb.setPlist(pats); tmb.setType(node.getType().clone()); List<PMultipleBind> binds = new LinkedList<>(); binds.add(tmb); forall_exp.setBindList(binds); return forall_exp; }
@Override public PExp getContextNode(PExp stitch) { AForAllExp forAllExp = new AForAllExp(); forAllExp.setBindList(makeBinds()); forAllExp.setType(new ABooleanBasicType()); if (deftype.getParameters().isEmpty()) { return stitch; } if (addPrecond && precondition != null) { AImpliesBooleanBinaryExp implies = AstExpressionFactory .newAImpliesBooleanBinaryExp(precondition.clone(), stitch); implies.setType(new ABooleanBasicType()); forAllExp.setPredicate(implies); } else { forAllExp.setPredicate(stitch); } return forAllExp; }
@Override public PExp getContextNode(PExp stitch) { if (anyBinds()) { AForAllExp forAllExp = new AForAllExp(); forAllExp.setType(new ABooleanBasicType()); forAllExp.setBindList(makeBinds()); if (addPrecond && precondition != null) { AImpliesBooleanBinaryExp impliesExp = AstExpressionFactory.newAImpliesBooleanBinaryExp(precondition.clone(), stitch); forAllExp.setPredicate(impliesExp); } else { forAllExp.setPredicate(stitch); } return forAllExp; } else { if (addPrecond && precondition != null) { AImpliesBooleanBinaryExp impliesExp = AstExpressionFactory.newAImpliesBooleanBinaryExp(precondition.clone(), stitch); return impliesExp; } } return stitch; }
@Override public PType caseAForAllExp(AForAllExp node, TypeCheckInfo question) throws AnalysisException { PDefinition def = AstFactory.newAMultiBindListDefinition(node.getLocation(), node.getBindList()); def.apply(THIS, question.newConstraint(null)); Environment local = new FlatCheckedEnvironment(question.assistantFactory, def, question.env, question.scope); if (!question.assistantFactory.createPTypeAssistant().isType(node.getPredicate().apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, null, AstFactory.newABooleanBasicType(node.getLocation()), null)), ABooleanBasicType.class)) { TypeCheckerErrors.report(3097, "Predicate is not boolean", node.getPredicate().getLocation(), node.getPredicate()); } local.unusedCheck(); node.setType(AstFactory.newABooleanBasicType(node.getLocation())); return question.assistantFactory.createPTypeAssistant().checkConstraint(question.constraint, node.getType(), node.getLocation()); }