當前位置: 首頁>>代碼示例>>Python>>正文


Python And.substitute方法代碼示例

本文整理匯總了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)
開發者ID:0Chuzz,項目名稱:pysmt,代碼行數:11,代碼來源:test_regressions.py

示例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")
開發者ID:0Chuzz,項目名稱:pysmt,代碼行數:12,代碼來源:test_solving.py

示例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")
開發者ID:0Chuzz,項目名稱:pysmt,代碼行數:15,代碼來源:test_solving.py

示例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))
開發者ID:0Chuzz,項目名稱:pysmt,代碼行數:18,代碼來源:test_solving.py

示例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
開發者ID:agriggio,項目名稱:pysmt,代碼行數:23,代碼來源:basic.py


注:本文中的pysmt.shortcuts.And.substitute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。