当前位置: 首页>>代码示例>>Python>>正文


Python SmtLibParser.get_script方法代码示例

本文整理汇总了Python中pysmt.smtlib.parser.SmtLibParser.get_script方法的典型用法代码示例。如果您正苦于以下问题:Python SmtLibParser.get_script方法的具体用法?Python SmtLibParser.get_script怎么用?Python SmtLibParser.get_script使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pysmt.smtlib.parser.SmtLibParser的用法示例。


在下文中一共展示了SmtLibParser.get_script方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestParserExtensibility

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
class TestParserExtensibility(TestCase):

    def setUp(self):
        self.ts_parser = TSSmtLibParser()
        self.smt_parser = SmtLibParser()

    def test_wrong(self):
        txt = """
        (declare-fun A () Bool)
        (declare-fun B () Bool)
        (assert (and A B))
        (check-sat)
        (exit)
        """
        with self.assertRaises(UnknownSmtLibCommandError):
            self.ts_parser.get_ts(cStringIO(txt))
        script = self.smt_parser.get_script(cStringIO(txt))
        self.assertIsNotNone(script)

    def test_basic(self):
        txt = """
        (declare-fun A () Bool)
        (declare-fun B () Bool)
        (init (and A B))
        (trans (=> A (next A)))
        (exit)
        """
        with self.assertRaises(UnknownSmtLibCommandError):
            self.smt_parser.get_script(cStringIO(txt))
        ts = self.ts_parser.get_ts(cStringIO(txt))
        self.assertIsNotNone(ts)
开发者ID:bingcao,项目名称:pysmt,代码行数:33,代码来源:test_parser_extensibility.py

示例2: test_parse_exception

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
 def test_parse_exception(self):
     from pysmt.exceptions import PysmtSyntaxError
     smtlib_input = "(declare-const x x x Int)" +\
                    "(check-sat)"
     parser = SmtLibParser()
     buffer_ = cStringIO(smtlib_input)
     try:
         parser.get_script(buffer_)
         self.assertFalse(True)
     except PysmtSyntaxError as ex:
         self.assertEqual(ex.pos_info[0], 0)
         self.assertEqual(ex.pos_info[1], 19)
开发者ID:mpreiner,项目名称:pysmt,代码行数:14,代码来源:test_regressions.py

示例3: test_parse_bvconst_width

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
 def test_parse_bvconst_width(self):
     smtlib_input = "(assert (> #x10 #x10))"
     parser = SmtLibParser()
     buffer_ = cStringIO(smtlib_input)
     expr = parser.get_script(buffer_).get_last_formula()
     const = expr.args()[0]
     self.assertEqual(const.bv_width(), 8, const.bv_width())
开发者ID:mpreiner,项目名称:pysmt,代码行数:9,代码来源:test_regressions.py

示例4: test_define_funs_arg_and_fun

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
 def test_define_funs_arg_and_fun(self):
     smtlib_script = "\n".join(['(define-fun f ((n Int)) Int n)', '(declare-fun n () Real)'])
     stream = cStringIO(smtlib_script)
     parser = SmtLibParser()
     _ = parser.get_script(stream)
     # No exceptions are thrown
     self.assertTrue(True)
开发者ID:pysmt,项目名称:pysmt,代码行数:9,代码来源:test_smtlibscript.py

示例5: test_dumped_logic

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
    def test_dumped_logic(self):
        # Dumped logic matches the logic in the example
        fs = get_example_formulae()

        for (f_out, _, _, logic) in fs:
            buf_out = cStringIO()
            script_out = smtlibscript_from_formula(f_out)
            script_out.serialize(outstream=buf_out)

            buf_in = cStringIO(buf_out.getvalue())
            parser = SmtLibParser()
            script_in = parser.get_script(buf_in)
            for cmd in script_in:
                if cmd.name == "set-logic":
                    logic_in = cmd.args[0]
                    if logic == logics.QF_BOOL:
                        self.assertEqual(logic_in, logics.QF_UF)
                    elif logic == logics.BOOL:
                        self.assertEqual(logic_in, logics.LRA)
                    else:
                        self.assertEqual(logic_in, logic, script_in)
                    break
            else: # Loops exited normally
                print("-"*40)
                print(script_in)
开发者ID:0Chuzz,项目名称:pysmt,代码行数:27,代码来源:test_parser_examples.py

示例6: test_define_funs_same_args

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
 def test_define_funs_same_args(self):
     # n is defined once as an Int and once as a Real
     smtlib_script = "\n".join(['(define-fun f ((n Int)) Int n)', '(define-fun f ((n Real)) Real n)'])
     stream = cStringIO(smtlib_script)
     parser = SmtLibParser()
     _ = parser.get_script(stream)
     # No exceptions are thrown
     self.assertTrue(True)
开发者ID:pysmt,项目名称:pysmt,代码行数:10,代码来源:test_smtlibscript.py

示例7: test_parse_declare_const

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
 def test_parse_declare_const(self):
     smtlib_input = """
     (declare-const s Int)
     (check-sat)"""
     parser = SmtLibParser()
     buffer_ = cStringIO(smtlib_input)
     script = parser.get_script(buffer_)
     self.assertIsNotNone(script)
开发者ID:mpreiner,项目名称:pysmt,代码行数:10,代码来源:test_regressions.py

示例8: test_smtlib_define_fun_serialization

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
 def test_smtlib_define_fun_serialization(self):
     smtlib_input = "(define-fun init ((x Bool)) Bool (and x (and x (and x (and x (and x (and x x)))))))"
     parser = SmtLibParser()
     buffer_ = cStringIO(smtlib_input)
     s = parser.get_script(buffer_)
     for c in s:
         res = c.serialize_to_string(daggify=False)
     self.assertEqual(res.replace('__x0', 'x'), smtlib_input)
开发者ID:mpreiner,项目名称:pysmt,代码行数:10,代码来源:test_regressions.py

示例9: test_annotations_colon_values

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
    def test_annotations_colon_values(self):
        source ="""\
(declare-fun |"v__AT0"| () Bool)
(define-fun .def_1 () Bool (! |"v__AT0"| :next :this_is_considered_a_value))
"""
        buf = StringIO(source)
        parser = SmtLibParser()
        script = parser.get_script(buf)
        ann = script.annotations
        v0 = self.env.formula_manager.get_symbol('"v__AT0"')
        v1_str = next(iter(ann[v0]["next"]))
        self.assertEquals(v1_str, ":this_is_considered_a_value")
开发者ID:agriggio,项目名称:pysmt,代码行数:14,代码来源:test_annotations.py

示例10: test_complex_annotations_values

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
    def test_complex_annotations_values(self):
        source ="""\
(declare-fun |"v__AT0"| () Bool)
(define-fun .def_1 () Bool (! |"v__AT0"| :next (+ 1     meaningless)))
"""
        buf = StringIO(source)
        parser = SmtLibParser()
        script = parser.get_script(buf)
        ann = script.annotations
        v0 = self.env.formula_manager.get_symbol('"v__AT0"')
        v1_str = next(iter(ann[v0]["next"]))
        self.assertEquals(v1_str, "(+ 1     meaningless)")
开发者ID:agriggio,项目名称:pysmt,代码行数:14,代码来源:test_annotations.py

示例11: test_string_constant_quote_escaping_parsing

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
    def test_string_constant_quote_escaping_parsing(self):
        script = """
        (declare-const x String)
        (assert (= x "a""b"))
        (assert (= x "\"\""))
        (assert (= x "\"\"\"\""))
        """

        p = SmtLibParser()
        buffer = cStringIO(script)
        s = p.get_script(buffer)
        self.assertEqual('a"b', s.commands[1].args[0].arg(1).constant_value())
        self.assertEqual('"', s.commands[2].args[0].arg(1).constant_value())
        self.assertEqual('""', s.commands[3].args[0].arg(1).constant_value())
开发者ID:mpreiner,项目名称:pysmt,代码行数:16,代码来源:test_regressions.py

示例12: test_interpreting_annotations

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
    def test_interpreting_annotations(self):
        source ="""\
(declare-fun |"v__AT0"| () Bool)
(declare-fun |"v__AT1"| () Bool)
(define-fun .def_1 () Bool (! |"v__AT0"| :next |"v__AT1"|))
"""
        buf = StringIO(source)
        parser = SmtLibParser()
        script = parser.get_script(buf)
        ann = script.annotations
        v0 = self.env.formula_manager.get_symbol('"v__AT0"')
        v1_str = next(iter(ann[v0]["next"]))
        self.env.formula_manager.get_symbol(v1_str)
        self.assertEquals(v1_str, '"v__AT1"')
开发者ID:agriggio,项目名称:pysmt,代码行数:16,代码来源:test_annotations.py

示例13: test_parse_examples_daggified_bv

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
    def test_parse_examples_daggified_bv(self):
        fs = get_example_formulae()

        for (f_out, _, _, logic) in fs:
            if logic != logics.QF_BV:
                # See test_parse_examples_daggified
                continue
            buf_out = cStringIO()
            script_out = smtlibscript_from_formula(f_out)
            script_out.serialize(outstream=buf_out, daggify=True)
            buf_in = cStringIO(buf_out.getvalue())
            parser = SmtLibParser()
            script_in = parser.get_script(buf_in)
            f_in = script_in.get_last_formula()
            self.assertValid(Iff(f_in, f_out), f_in.serialize())
开发者ID:mpreiner,项目名称:pysmt,代码行数:17,代码来源:test_parser_examples.py

示例14: test_parse_examples

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
    def test_parse_examples(self):
        fs = get_example_formulae()

        for (f_out, _, _, logic) in fs:
            if logic == logics.QF_BV:
                # See test_parse_examples_bv
                continue
            buf_out = cStringIO()
            script_out = smtlibscript_from_formula(f_out)
            script_out.serialize(outstream=buf_out)

            buf_in = cStringIO(buf_out.getvalue())
            parser = SmtLibParser()
            script_in = parser.get_script(buf_in)
            f_in = script_in.get_last_formula()
            self.assertEqual(f_in.simplify(), f_out.simplify())
开发者ID:0Chuzz,项目名称:pysmt,代码行数:18,代码来源:test_parser_examples.py

示例15: test_parse_bvx_var

# 需要导入模块: from pysmt.smtlib.parser import SmtLibParser [as 别名]
# 或者: from pysmt.smtlib.parser.SmtLibParser import get_script [as 别名]
 def test_parse_bvx_var(self):
     """bvX is a valid identifier."""
     smtlib_input = """
     (declare-fun bv1 () (_ BitVec 8))
     (assert (bvult (_ bv0 8) (bvmul (bvadd bv1 (_ bv1 8)) (_ bv5 8))))
     (check-sat)"""
     parser = SmtLibParser()
     buffer_ = cStringIO(smtlib_input)
     script = parser.get_script(buffer_)
     # Check Parsed result
     iscript = iter(script)
     cmd = next(iscript)
     self.assertEqual(cmd.name, DECLARE_FUN)
     bv1 = cmd.args[0]
     self.assertEqual(bv1.symbol_type().width, 8)
     cmd = next(iscript)
     parsed_f = cmd.args[0]
     target_f = BVULT(BV(0, 8),
                      BVMul(BVAdd(bv1, BV(1, 8)), BV(5, 8)))
     self.assertEqual(parsed_f, target_f)
开发者ID:mpreiner,项目名称:pysmt,代码行数:22,代码来源:test_regressions.py


注:本文中的pysmt.smtlib.parser.SmtLibParser.get_script方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。