本文整理匯總了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