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


Python node.Node类代码示例

本文整理汇总了Python中pynusmv.node.Node的典型用法代码示例。如果您正苦于以下问题:Python Node类的具体用法?Python Node怎么用?Python Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_bounded_semantics_without_loop

 def test_bounded_semantics_without_loop(self):
     # parse the ltl property
     spec = Node.from_ptr(parse_ltl_spec("G ( y <= 7 )"))
     
     # it must raise exception when the bound is not feasible
     with self.assertRaises(ValueError):
         ltlspec.bounded_semantics_without_loop(self.fsm, spec, bound=-1)
     
     # verify that the generated expression corresponds to what is announced
     no_loop = ltlspec.bounded_semantics_without_loop(self.fsm, spec, 10)
     
     # globally w/o loop is false (this is just a test)
     self.assertEqual(no_loop, Be.false(self.fsm.encoding.manager)) 
     
     # an other more complex generation
     spec = Node.from_ptr(parse_ltl_spec("F (y <= 7)"))
     no_loop = ltlspec.bounded_semantics_without_loop(self.fsm, spec, 10)
     
     #
     # The generated expression is [[f]]^{0}_{k} so (! L_{k}) is not taken 
     # care of. And actually, NuSMV does not generate that part of the 
     # formula: it only enforce the loop condition when the semantics with 
     # loop is used 
     # 
     handcrafted = Be.false(self.fsm.encoding.manager)
     y_le_seven  = Wff(parse_ltl_spec("y <= 7")).to_boolean_wff().to_be(self.fsm.encoding)
     for time_x in reversed(range(11)): # 11 because range 'eats' up the last step
         handcrafted |= self.fsm.encoding.shift_to_time(y_le_seven, time_x)
     
     #### debuging info #####
     #print("noloop  = {}".format(no_loop.to_cnf()))
     #print("hancraft= {}".format(handcrafted.to_cnf()))
     #print(self.fsm.encoding)
     self.assertEqual(no_loop, handcrafted)
开发者ID:xgillard,项目名称:pynusmv,代码行数:34,代码来源:testBmcLTLspec.py

示例2: test_iter

    def test_iter(self):
        """tests the behavior of assign and value"""
        with BmcSupport():
            sexp_fsm = master_bool_sexp_fsm()
            be_fsm = master_be_fsm()

            # empty trace
            trace = Trace.create(
                "Dummy example",
                TraceType.COUNTER_EXAMPLE,
                sexp_fsm.symbol_table,
                sexp_fsm.symbols_list,
                is_volatile=True,
            )

            step1 = trace.steps[1]

            yes = Node.from_ptr(parse_simple_expression("TRUE"))
            no = Node.from_ptr(parse_simple_expression("FALSE"))
            v = be_fsm.encoding.by_name["v"].name

            self.assertEqual([], list(step1))

            step1 += v, yes
            self.assertEqual([(v, yes)], list(step1))

            # += really ASSIGNS a value, not append
            step1 += v, no
            self.assertEqual([(v, no)], list(step1))
开发者ID:xgillard,项目名称:pynusmv,代码行数:29,代码来源:testTraceStep.py

示例3: test_assign_value__magicmethod__

    def test_assign_value__magicmethod__(self):
        """tests the behavior of assign and value"""
        with BmcSupport():
            sexp_fsm = master_bool_sexp_fsm()
            be_fsm = master_be_fsm()

            # empty trace
            trace = Trace.create(
                "Dummy example",
                TraceType.COUNTER_EXAMPLE,
                sexp_fsm.symbol_table,
                sexp_fsm.symbols_list,
                is_volatile=True,
            )

            step1 = trace.steps[1]

            yes = Node.from_ptr(parse_simple_expression("TRUE"))
            no = Node.from_ptr(parse_simple_expression("FALSE"))
            v = be_fsm.encoding.by_name["v"].name

            self.assertIsNone(step1.value[v])
            step1 += (v, yes)
            self.assertEqual(yes, step1.value[v])
            step1 += (v, no)
            self.assertEqual(no, step1.value[v])
开发者ID:xgillard,项目名称:pynusmv,代码行数:26,代码来源:testTraceStep.py

示例4: test_generate_problem_with_fairness

 def test_generate_problem_with_fairness(self):
     '''
     This test clearly shows the difference in validating a property with
     or without fairness constraint
     '''
     with tests.Configure(self, __file__, "/philo.smv"):
         # length 0
         # nusmv has fairness always on.
         fml_node= Node.from_ptr(parse_ltl_spec("G (p1.waiting -> F !p1.waiting)"))
         smv     = ltlspec.generate_ltl_problem(self.befsm, fml_node, 0)
         self.assertEqual(SatSolverResult.UNSATISFIABLE, self.satisfiability(smv))
         
         formula = parseLTL("[](p1.waiting => <>!p1.waiting)")
         unfair  = gen.generate_problem(formula, self.befsm, 0, no_fairness=True)
         self.assertEqual(SatSolverResult.UNSATISFIABLE, self.satisfiability(unfair))
         
         fair    = gen.generate_problem(formula, self.befsm, 0, no_fairness=False)
         self.assertEqual(SatSolverResult.UNSATISFIABLE, self.satisfiability(fair))
         
         # length 1
         fml_node= Node.from_ptr(parse_ltl_spec("G (p1.waiting -> F !p1.waiting)"))
         smv     = ltlspec.generate_ltl_problem(self.befsm, fml_node, 1)
         self.assertEqual(SatSolverResult.UNSATISFIABLE, self.satisfiability(smv))
         
         formula = parseLTL("[](p1.waiting => <>!p1.waiting)")
         unfair  = gen.generate_problem(formula, self.befsm, 1, no_fairness=True)
         self.assertEqual(SatSolverResult.SATISFIABLE, self.satisfiability(unfair))
         
         fair    = gen.generate_problem(formula, self.befsm, 1, no_fairness=False)
         self.assertEqual(SatSolverResult.UNSATISFIABLE, self.satisfiability(fair))
开发者ID:xgillard,项目名称:pynusmv,代码行数:30,代码来源:testGen.py

示例5: test_next_with_loop

 def test_next_with_loop(self):
     with tests.Configure(self, __file__, "/example.smv"):
         i,k,l   = 0,2,0
         enc     = self.enc
         
         # One step
         a       = ast.Proposition("a")
         formula = ast.Next(a)
         tool    = formula.semantic_with_loop(enc, i, k, l)
         manual  = a.semantic_with_loop(enc, 1, k, l)
         nusmv   = ltlspec.bounded_semantics(self.befsm, 
                                             Node.from_ptr(parse_ltl_spec("X a")),
                                             bound = k, 
                                             loop  = l)
         
         loop_cond = bmcutils.loop_condition(enc, k, l)
         s_tool  = tests.canonical_cnf(tool   & loop_cond)
         s_manual= tests.canonical_cnf(manual & loop_cond)
         s_nusmv = tests.canonical_cnf(nusmv)
         
         self.assertEqual(s_tool, s_nusmv)
         self.assertEqual(s_tool, s_manual)
         
         # two steps
         formula = ast.Next(ast.Next(a))
         tool    = formula.semantic_with_loop(enc, i, k, l)
         manual  = a.semantic_with_loop(enc, 0, k, l)
         nusmv   = ltlspec.bounded_semantics(self.befsm, 
                                             Node.from_ptr(parse_ltl_spec("X X a")),
                                             bound = k, 
                                             loop  = l)
         
         loop_cond = bmcutils.loop_condition(enc, k, l)
         s_tool  = tests.canonical_cnf(tool   & loop_cond)
         s_manual= tests.canonical_cnf(manual & loop_cond)
         s_nusmv = tests.canonical_cnf(nusmv)
         
         self.assertEqual(s_tool, s_nusmv)
         self.assertEqual(s_tool, s_manual)
          
         # Three steps (getting over k)
         formula = ast.Next(ast.Next(ast.Next(a)))
         tool    = formula.semantic_with_loop(enc, i, k, l)
         manual  = a.semantic_with_loop(enc, 1, k, l)
         nusmv   = ltlspec.bounded_semantics(self.befsm, 
                                             Node.from_ptr(parse_ltl_spec("X X X a")),
                                             bound = k, 
                                             loop  = l)
         
         loop_cond = bmcutils.loop_condition(enc, k, l)
         s_tool  = tests.canonical_cnf(tool   & loop_cond)
         s_manual= tests.canonical_cnf(manual & loop_cond)
         s_nusmv = tests.canonical_cnf(nusmv)
         
         self.assertEqual(s_tool, s_nusmv)
         self.assertEqual(s_tool, s_manual)
开发者ID:xgillard,项目名称:pynusmv,代码行数:56,代码来源:testSemantics.py

示例6: test_next_noloop

 def test_next_noloop(self):
     with tests.Configure(self, __file__, "/example.smv"):
         i,k     = 0,2
         enc     = self.enc
         # One step
         a       = ast.Proposition("a")
         formula = ast.Next(a)
         tool    = formula.semantic_no_loop(enc, i, k)
         manual  = a.semantic_no_loop(enc, 1, k)
         nusmv   = ltlspec.bounded_semantics(self.befsm, 
                                             Node.from_ptr(parse_ltl_spec("X a")),
                                             bound = k, 
                                             loop  = bmcutils.no_loopback())
         
         s_tool   = tests.canonical_cnf(tool)
         s_manual = tests.canonical_cnf(manual)
         s_nusmv  = tests.canonical_cnf(nusmv)
         
         self.assertEqual(s_tool, s_nusmv)
         self.assertEqual(s_tool, s_manual)
         
         # two steps
         formula = ast.Next(ast.Next(a))
         tool    = formula.semantic_no_loop(enc, i, k)
         manual  = a.semantic_no_loop(enc, 2, k)
         nusmv   = ltlspec.bounded_semantics(self.befsm, 
                                             Node.from_ptr(parse_ltl_spec("X X a")),
                                             bound = k, 
                                             loop  = bmcutils.no_loopback())
         
         s_tool   = tests.canonical_cnf(tool)
         s_manual = tests.canonical_cnf(manual)
         s_nusmv  = tests.canonical_cnf(nusmv)
         
         self.assertEqual(s_tool, s_nusmv)
         self.assertEqual(s_tool, s_manual)
         
         # Three steps (getting over k)
         formula = ast.Next(ast.Next(ast.Next(a)))
         tool    = formula.semantic_no_loop(enc, i, k)
         manual  = Be.false(enc.manager)
         nusmv   = ltlspec.bounded_semantics(self.befsm, 
                                             Node.from_ptr(parse_ltl_spec("X X X a")),
                                             bound = k, 
                                             loop  = bmcutils.no_loopback())
         
         s_tool   = tests.canonical_cnf(tool)
         s_manual = tests.canonical_cnf(manual)
         s_nusmv  = tests.canonical_cnf(nusmv)
         
         self.assertEqual(s_tool, s_nusmv)
         self.assertEqual(s_tool, s_manual)
开发者ID:xgillard,项目名称:pynusmv,代码行数:52,代码来源:testSemantics.py

示例7: test_until_with_loop

 def test_until_with_loop(self):
     with tests.Configure(self, __file__, "/example.smv"):
         enc  = self.enc
         i,k,l= 0,2,0
         a    = ast.Proposition("a")
         b    = ast.Proposition("b")
 
         expr = ast.Until(a, b)
         tool = expr.semantic_with_loop(enc, i,k,l)
         
         manual = b.semantic_with_loop(enc, i, k, l) | \
                     (a.semantic_with_loop(enc, i, k, l) & b.semantic_with_loop(enc, i+1, k, l))
         
         
         spec  = Node.from_ptr(parse_ltl_spec("a U b"))
         nusmv = ltlspec.bounded_semantics(self.befsm, spec, bound=k, loop=l)
         
         tool   &= bmcutils.loop_condition(enc, k, l)
         manual &= bmcutils.loop_condition(enc, k, l)
         
         # normalized string representation of the BE's (make them comparable)
         s_tool  = tests.canonical_cnf(tool)
         s_nusmv = tests.canonical_cnf(nusmv)
         s_manual= tests.canonical_cnf(manual)
         
         self.assertEqual(s_tool, s_manual)
         self.assertEqual(s_tool, s_nusmv)
开发者ID:xgillard,项目名称:pynusmv,代码行数:27,代码来源:testSemantics.py

示例8: test_eventually_with_loop

 def test_eventually_with_loop(self):
     with tests.Configure(self, __file__, "/example.smv"):
         i,k,l   = 0,2,0
         enc     = self.enc
         a       = ast.Proposition("a")
         formula = ast.Eventually(a)
         
         tool    = formula.semantic_with_loop(enc, i, k, l)
         
         manual  = a.semantic_with_loop(enc, i+1, k, l) |\
                   a.semantic_with_loop(enc, i  , k, l) 
         
         nusmv   = ltlspec.bounded_semantics(
                     self.befsm, Node.from_ptr(parse_ltl_spec("F a")), 
                     bound = k, 
                     loop  = l)
         
         # normalized string representation of the BE's (make them comparable)
         loop_cond = bmcutils.loop_condition(enc, k, l)
         s_tool  = tests.canonical_cnf(tool   & loop_cond)
         s_manual= tests.canonical_cnf(manual & loop_cond)
         s_nusmv = tests.canonical_cnf(nusmv)
         
         self.assertEqual(s_nusmv,  s_tool)
         self.assertEqual(s_manual, s_tool)
开发者ID:xgillard,项目名称:pynusmv,代码行数:25,代码来源:testSemantics.py

示例9: test_copy

 def test_copy(self):
     """Tests the copy behavior"""
     h = Assoc(_u.new_assoc(), freeit=True)
     a = Node.from_ptr(parse_simple_expression("a.car = 3"), freeit=False)
     h[a] = a
     h2= h.copy()
     self.assertTrue(a in h2)
开发者ID:xgillard,项目名称:pynusmv,代码行数:7,代码来源:testAssoc.py

示例10: test_clear

 def test_clear(self):
     """Verifies that clear works as expected"""
     h = Assoc(_u.new_assoc(), freeit=True)
     a = Node.from_ptr(parse_simple_expression("a.car = 3"), freeit=False)
     h[a] = a
     h.clear()
     self.assertFalse(a in h) 
开发者ID:xgillard,项目名称:pynusmv,代码行数:7,代码来源:testAssoc.py

示例11: test_constraint_context_sigma

 def test_constraint_context_sigma(self):
     fsm   = master_be_fsm()
     
     _true = Node.from_ptr(parse_ltl_spec("TRUE"))
     _true = bmcutils.make_nnf_boolean_wff(_true)
     _truen= _true.to_node()
     
     cond  = Wff(parse_ltl_spec("G !(mouse = hover)"))\
                 .to_boolean_wff()\
                 .to_negation_normal_form()
     off_1 = 0
     off_2 = 2
     length= 1
      
     # sigma1
     problem = diagnosability.generate_sat_problem([], (_truen, _truen), length, _true, cond.to_node(), _truen)
     tm_cond = ltlspec.bounded_semantics_at_offset(fsm, cond.to_node(), length, off_1)
     
     canonical_p = tests.canonical_cnf(problem)
     canonical_f = tests.canonical_cnf(tm_cond)
     
     self.assertTrue(all(clause in canonical_p for clause in canonical_f))
     
     # sigma2
     problem = diagnosability.generate_sat_problem([], (_truen, _truen), length, _true, _truen, cond.to_node())
     tm_cond = ltlspec.bounded_semantics_at_offset(fsm, cond.to_node(), length, off_2)
     
     canonical_p = tests.canonical_cnf(problem)
     canonical_f = tests.canonical_cnf(tm_cond)
     
     self.assertTrue(all(clause in canonical_p for clause in canonical_f))
     
开发者ID:xgillard,项目名称:pynusmv,代码行数:31,代码来源:testDiagnosability.py

示例12: test_language_contains

    def test_language_contains(self):
        with BmcSupport():
            sexp_fsm = master_bool_sexp_fsm()
            be_fsm = master_be_fsm()

            trace = Trace.create(
                "Dummy example",
                TraceType.COUNTER_EXAMPLE,
                sexp_fsm.symbol_table,
                sexp_fsm.symbols_list,
                is_volatile=True,
            )

            v = be_fsm.encoding.by_name["v"]
            w = be_fsm.encoding.by_name["w"]
            f = be_fsm.encoding.by_name["f"]
            i = be_fsm.encoding.by_name["i"]

            self.assertTrue(v.name in trace)
            self.assertTrue(w.name in trace)
            self.assertTrue(f.name in trace)
            self.assertTrue(i.name in trace)

            x = parse_simple_expression("x")
            self.assertFalse(Node.from_ptr(x) in trace)
开发者ID:xgillard,项目名称:pynusmv,代码行数:25,代码来源:testTrace.py

示例13: decode_value

 def decode_value(self, list_of_bits_and_value):
     """
     Returns a node (:see:`pynusmv.node.Node`) corresponding to the value of
     the variable encoded by the list of bits and values.
     
     :param list_of_bits_and_value: a sequence of tuples (BeVar, BooleanValue)
         which represent a bit and its value.
     :return: an intelligible value node corresponding to what these bits
         means when interpreted in the context of the SMV model.
     """
     if not list_of_bits_and_value:
         raise ValueError("The given list of bits and values must at least "+
                          "contain one bit")
     # if the variable to be decoded is boolean in the model 
     if not list_of_bits_and_value[0][0].is_bit:
         return list_of_bits_and_value[0][1]
     
     # otherwise decode the bits
     bool_enc = self._bool_enc
     scalar   = list_of_bits_and_value[0][0].scalar
     
     bv = _bool.BitValues_create(bool_enc, scalar._ptr)
     for bit,val in list_of_bits_and_value:
         bit_index = _bool.BoolEnc_get_index_from_bit(bool_enc, bit.name._ptr)
         _bool.BitValues_set(bv, bit_index, val)
         
     result_ptr = _bool.BoolEnc_get_value_from_var_bits(bool_enc, bv)
     
     _bool.BitValues_destroy(bv)
     return Node.from_ptr(result_ptr)
开发者ID:xgillard,项目名称:pynusmv,代码行数:30,代码来源:encoder.py

示例14: validate_generate_problem

 def validate_generate_problem(self, bound, custom_text, nusmv_text):
     fsm     = self.befsm
     # formulae
     formula = parseLTL(custom_text)
     fml_node= Node.from_ptr(parse_ltl_spec(nusmv_text))
      
     # IMPORTANT NOTE: each instantiation of the problem creates new CNF 
     #   literal which appears in the clauses list (even in canonical form)
     #   hence, the canonical forms of the different instantiations cannot
     #   simply be compared as there is no a priori way to know what CNF 
     #   literal reconcile with what other.
     #   However, the different expressions should all have the exact same
     #   satisfiability. So, that's how this test proceeds.
       
     smv     = ltlspec.generate_ltl_problem(fsm, fml_node, bound)
     tool    = gen.generate_problem(formula, fsm, bound)
     manual  = gen.model_problem(fsm, bound) &\
               formula.nnf(True).bounded_semantics(fsm, bound)
      
     sat_smv = self.satisfiability(smv)
     sat_tool= self.satisfiability(tool)
     sat_man = self.satisfiability(manual)
      
     self.assertEqual(sat_tool, sat_man)
     self.assertEqual(sat_tool, sat_smv)
开发者ID:xgillard,项目名称:pynusmv,代码行数:25,代码来源:testGen.py

示例15: name

 def name(self):
     """
     Returns the name of this BOOLEAN variable. If this variable was not
     declared boolean in the SMV text, this is going to be the name of one
     of the bits composing that variable. 
     
     :return: the name node corresponding to this boolean variable.
     """
     ptr = _be.BeEnc_index_to_name(self.encoding._ptr, self.untimed.index)
     return Node.from_ptr(ptr)
开发者ID:xgillard,项目名称:pynusmv,代码行数:10,代码来源:encoder.py


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