Ejemplo n.º 1
0
 def sup_func(self, var_name, pred):
     from pecan.lang.ast_substitution import ASTSubstitution
     from pecan.lang.ir.base import IRNode
     var = VarRef(var_name)
     temp = VarRef(IRNode.fresh_name())
     subs = {var_name: temp}
     fresh_pred = ASTSubstitution(subs).transform(pred)
     upper_bound = TypeHint(
         temp, var,
         Forall([temp], Implies(fresh_pred, GreaterEquals(var, temp))))
     return self.min_func(var_name, upper_bound)
Ejemplo n.º 2
0
 def max_func(self, var_name, pred):
     from pecan.lang.ast_substitution import ASTSubstitution
     from pecan.lang.ir.base import IRNode
     var = VarRef(var_name)
     temp = VarRef(IRNode.fresh_name())
     subs = {var_name: temp}
     fresh_pred = ASTSubstitution(subs).transform(pred)
     return PredicateExpr(
         var_name,
         TypeHint(
             temp, var,
             Conjunction(
                 pred,
                 Forall([temp], Implies(fresh_pred,
                                        GreaterEquals(var, temp))))))