本文整理匯總了Python中pysmt.shortcuts.And.substitute方法的典型用法代碼示例。如果您正苦於以下問題:Python And.substitute方法的具體用法?Python And.substitute怎麽用?Python And.substitute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pysmt.shortcuts.And
的用法示例。
在下文中一共展示了And.substitute方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_substitute_memoization
# 需要導入模塊: from pysmt.shortcuts import And [as 別名]
# 或者: from pysmt.shortcuts.And import substitute [as 別名]
def test_substitute_memoization(self):
a = Symbol("A", BOOL)
b = Symbol("B", BOOL)
f = And(a, b)
g = f.substitute({a:Bool(True)})
h = f.substitute({a:Bool(False)})
self.assertNotEqual(h, g)
示例2: test_get_implicant_unsat
# 需要導入模塊: from pysmt.shortcuts import And [as 別名]
# 或者: from pysmt.shortcuts.And import substitute [as 別名]
def test_get_implicant_unsat(self):
varA = Symbol("A", BOOL)
varB = Symbol("B", BOOL)
f = And(varA, Not(varB))
g = f.substitute({varB:varA})
for solver in get_env().factory.all_solvers(logic=QF_BOOL):
res = get_implicant(g, solver_name=solver)
self.assertIsNone(res, "Formula was expected to be UNSAT")
示例3: test_is_sat
# 需要導入模塊: from pysmt.shortcuts import And [as 別名]
# 或者: from pysmt.shortcuts.And import substitute [as 別名]
def test_is_sat(self):
varA = Symbol("A", BOOL)
varB = Symbol("B", BOOL)
f = And(varA, Not(varB))
g = f.substitute({varB:varA})
self.assertUnsat(g, logic=QF_BOOL,
msg="Formula was expected to be UNSAT")
for solver in get_env().factory.all_solvers():
self.assertUnsat(g, solver_name=solver,
msg="Formula was expected to be UNSAT")
示例4: test_create_and_solve
# 需要導入模塊: from pysmt.shortcuts import And [as 別名]
# 或者: from pysmt.shortcuts.And import substitute [as 別名]
def test_create_and_solve(self):
solver = Solver(logic=QF_BOOL)
varA = Symbol("A", BOOL)
varB = Symbol("B", BOOL)
f = And(varA, Not(varB))
g = f.substitute({varB:varA})
solver.add_assertion(g)
res = solver.solve()
self.assertFalse(res, "Formula was expected to be UNSAT")
h = And(g, Bool(False))
simp_h = h.simplify()
self.assertEqual(simp_h, Bool(False))
示例5: Symbol
# 需要導入模塊: from pysmt.shortcuts import And [as 別名]
# 或者: from pysmt.shortcuts.And import substitute [as 別名]
# Checking satisfiability of a formula.
#
# This example shows:
# 1. How to build a formula
# 2. How to perform substitution
# 3. Printing
# 4. Satisfiability checking
from pysmt.shortcuts import Symbol, And, Not, is_sat
varA = Symbol("A") # Default type is Boolean
varB = Symbol("B")
f = And([varA, Not(varB)])
g = f.substitute({varB:varA})
res = is_sat(f)
assert res # SAT
print("f := %s is SAT? %s" % (f, res))
res = is_sat(g)
print("g := %s is SAT? %s" % (g, res))
assert not res # UNSAT