本文整理汇总了Python中PE.prove方法的典型用法代码示例。如果您正苦于以下问题:Python PE.prove方法的具体用法?Python PE.prove怎么用?Python PE.prove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PE
的用法示例。
在下文中一共展示了PE.prove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: saveDistinctElements
# 需要导入模块: import PE [as 别名]
# 或者: from PE import prove [as 别名]
def saveDistinctElements(C6, arraymap, indexpe) :
"""retains within arraymay only those elements provably
distinct from indexpe
"""
akeys = arraymap.keys()
for key in akeys :
elempe = PE.tupleToPe(key) # get pe-value of element-index
# is the following good enough? Or will we need theorem proving?
distinct = PE.prove(C6["rels"], ["!=", elempe, indexpe])
if not distinct :
del arraymap[key]
示例2: verifyRelation
# 需要导入模块: import PE [as 别名]
# 或者: from PE import prove [as 别名]
def verifyRelation(C6, bfactlist, bgoal) :
"""attempts to verify bgoal, which is a primitive (relop or forall)
params: C6 table
bfactlist: a list of facts of form
[relop, e1, e2] or [forall/exists, lo, i, hi, e]
bgoal: a single fact of form [relop, e1, e2]
or [forall/exists, lo, i, hi, e]
returns : True, if bfactlist |- bgoal is proved
False, if not
"""
#print "verifyRelation: C6"#, C6
#print "bfactlist:", bfactlist
#print "bgoal:", bgoal
#raw_input("press Enter")
if (bgoal[0] in RELOPS) : # [relop, e1, e2]
# eval goal:
pe1 = PE.evall(C6, bgoal[1])
pe2 = PE.evall(C6, bgoal[2])
goal = [bgoal[0], pe1, pe2]
# eval all facts in the bfactlist:
factlist = []
for f in list(bfactlist) :
if f[0] in RELOPS :
pe1 = PE.evall(C6, f[1])
pe2 = PE.evall(C6, f[2])
factlist.append([f[0], pe1, pe2])
elif f[0] in ("forall", "exists") :
pass # can't handle quantified phrases (yet) in PE!
# If I am brave, I might try to evaluate lower and upper
# bounds of quantification and enumerate the facts therein.
# But this is high overhead....
# send off the PE-valued facts and goal to the prover:
#print "In verifyrelation; ready to call PE.prove:"
#print "all facts=", factlist + C6["rels"]
#print "goal=", goal
return PE.prove(factlist + C6["rels"], goal)
elif bgoal[0] == "forall" :
return proveUniversal(C6, bfactlist, bgoal)
else : # ["exists", lo, i, hi, e] ???
return False