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


Python Node.from_ptr方法代碼示例

本文整理匯總了Python中pynusmv.node.Node.from_ptr方法的典型用法代碼示例。如果您正苦於以下問題:Python Node.from_ptr方法的具體用法?Python Node.from_ptr怎麽用?Python Node.from_ptr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pynusmv.node.Node的用法示例。


在下文中一共展示了Node.from_ptr方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_bounded_semantics_without_loop

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
 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,代碼行數:36,代碼來源:testBmcLTLspec.py

示例2: test_iter

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
    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,代碼行數:31,代碼來源:testTraceStep.py

示例3: test_assign_value__magicmethod__

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
    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,代碼行數:28,代碼來源:testTraceStep.py

示例4: test_generate_problem_with_fairness

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
 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,代碼行數:32,代碼來源:testGen.py

示例5: test_next_with_loop

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
 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,代碼行數:58,代碼來源:testSemantics.py

示例6: test_next_noloop

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
 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,代碼行數:54,代碼來源:testSemantics.py

示例7: test_until_with_loop

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
 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,代碼行數:29,代碼來源:testSemantics.py

示例8: test_eventually_with_loop

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
 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,代碼行數:27,代碼來源:testSemantics.py

示例9: test_copy

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
 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,代碼行數:9,代碼來源:testAssoc.py

示例10: test_clear

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
 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,代碼行數:9,代碼來源:testAssoc.py

示例11: test_constraint_context_sigma

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
 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,代碼行數:33,代碼來源:testDiagnosability.py

示例12: test_language_contains

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
    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,代碼行數:27,代碼來源:testTrace.py

示例13: decode_value

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
 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,代碼行數:32,代碼來源:encoder.py

示例14: validate_generate_problem

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
 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,代碼行數:27,代碼來源:testGen.py

示例15: name

# 需要導入模塊: from pynusmv.node import Node [as 別名]
# 或者: from pynusmv.node.Node import from_ptr [as 別名]
 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,代碼行數:12,代碼來源:encoder.py


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