本文整理汇总了Python中PE.evallToInt方法的典型用法代码示例。如果您正苦于以下问题:Python PE.evallToInt方法的具体用法?Python PE.evallToInt怎么用?Python PE.evallToInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PE
的用法示例。
在下文中一共展示了PE.evallToInt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: proveUniversal
# 需要导入模块: import PE [as 别名]
# 或者: from PE import evallToInt [as 别名]
def proveUniversal(C6, bfactlist, bgoal) :
""" Tries to prove a bgoal of form, ["forall", lo, i, hi, bprop_i_]
from bfactlist. First, attempts to show hi <= lo, meaning
quantification ranges over empty set. If this fails, tries
to establish numerical lower and upper bounds for the quantification
and enumerate proofs for all elements within these bounds.
If this fails, then searches
for a bfact in bfactlist that is a forall of the same form,
but where its upper bound is hi-1. If success, then tries
to prove bprop_hi-1_.
If I have the energy, I'll try to make this smarter later....
"""
#print "proveUNIVERSAL: bfactlist=", bfactlist
#print "goal=", bgoal
lo = bgoal[1]
hi = bgoal[3]
i = bgoal[2]
bprop = bgoal[4]
# first, see if bgoal in premises:
success = bgoal in bfactlist
if not success :
# next, try to prove that domain is empty, ie, hi <= lo :
success = verifyRelation(C6, bfactlist, ["<=", hi, lo])
if not success:
# next, try to establish numerical lower and upper bounds and
# prove bprop for all elements in the numerical range:
lonum = PE.evallToInt(C6, lo)
hinum = PE.evallToInt(C6, hi)
if isinstance(lonum, int) and isinstance(hinum, int):
success = True # so far, so good...
for j in range(lonum, hinum):
stree = Parse.substituteTree(["int", str(j)], i, bprop)
success = success and proveSequent(C6, bfactlist, stree)
if not success:
# then search bfactlist for a forall goal whose body
# matches bprop and whose bounds cover bgoal's all but one:
possibles = [ f for f in bfactlist
if f[0] == "forall" \
and Parse.substituteTree(i, f[2], f[4]) == bprop \
#and verifyRelation(C6, bfactlist, ["==", f[1], lo]) \
and verifyRelation(C6, bfactlist, ["<=", f[1], lo]) \
and verifyRelation(C6, bfactlist, \
["==", ["+", f[3], ["int", "1"]], hi]) \
]
if len(possibles) > 0 :
success = proveSequent(C6, bfactlist,
Parse.substituteTree \
(["-", hi, ["int", "1"]], i, bprop) )
if not success:
#search bfactlist for a forall goal whose body
# matches bprop and whose bounds cover bgoal's:
possibles = [ f for f in bfactlist
if f[0] == "forall" \
and Parse.substituteTree(i, f[2], f[4]) == bprop \
and verifyRelation(C6, bfactlist, ["<=", f[1], lo]) \
and verifyRelation(C6, bfactlist, [">=", f[3], hi]) \
]
success = (len(possibles) > 0)
return success