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


Python Be.true方法代碼示例

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


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

示例1: test_true

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
 def test_true(self):
     with self.assertRaises(Exception):
         Be.true(None)
     expr = Be.true(self._manager)
     self.assertTrue(expr.is_true())
     self.assertFalse(expr.is_false())
     self.assertTrue(expr.is_constant())
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:9,代碼來源:testBe.py

示例2: bounded_semantics

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
    def bounded_semantics(self, fsm, k, fairness=True):
        """
        Returns a boolean expression corresponding to the bounded semantics of
        the formula denoted by `self` on a path of length k. This combines both
        the semantics in case of a loopy path and the case of a non-loopy path.

        .. note::
            This function takes the same approach as NuSMV and does not enforce
            the absence of loop when using the more restrictive semantic_no_loop.

        :param fsm: the FSM representing the model. It is used to gain access
            to the encoder (-> shift variables) and to obtain the list of
            fairness constraints.
        :param k: the last time that exists in the universe of this expression
        :param fairness: a flag indicating whether or not the fairness constraints
            should be taken into account while generating the formula.
        :return: a boolean expression translating the bounded semantics of this
            formula.
        """
        enc = fsm.encoding
        noloop = self.semantic_no_loop(enc, 0, k)

        w_loop = Be.false(enc.manager)
        for l in range(k):  # [0; k-1]
            fairness_cond = fairness_constraint(fsm, k, l) if fairness else Be.true(enc.manager)

            w_loop |= loop_condition(enc, k, l) & fairness_cond & self.semantic_with_loop(enc, 0, k, l)

        return noloop | w_loop
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:31,代碼來源:ast.py

示例3: loop_condition

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
def loop_condition(enc, k, l):
    """
    This function generates a Be expression representing the loop condition
    which is necessary to determine that k->l is a backloop.

    Formally, the returned constraint is denoted _{l}L_{k}

    Because the transition relation is encoded in Nusmv as formula (and not as
    a relation per-se), we determine the existence of a backloop between
    l < k and forall var, var(i) == var(k)

    That is to say: if it is possible to encounter two times the same state
    (same state being all variables have the same value in both states) we know
    there is a backloop on the path

    .. note::
        An other implementation of this function (w/ the same semantics) exists
        in :mod:`pynusmv.bmc.utils`. This version is merely re-implemented to
        1. show that it can be easily done
        2. stick closely to the definition given in the paper by Biere et al.
            (see other note)


    :param fsm: the fsm on which the condition will be evaluated
    :param k: the highest time
    :param l: the time where the loop is assumed to start
    :return: a Be expression representing the loop condition that verifies that
        k-l is a loop path.
    """
    cond = Be.true(enc.manager)
    for v in enc.curr_variables:  # for all untimed variable
        vl = v.at_time[l].boolean_expression
        vk = v.at_time[k].boolean_expression
        cond = cond & (vl.iff(vk))
    return cond
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:37,代碼來源:ast.py

示例4: test_constant_with_loop

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
 def test_constant_with_loop(self):
     with tests.Configure(self, __file__, "/example.smv"):
         expr = ast.Constant("TRUE")
         self.assertEqual(Be.true(self.mgr), expr.semantic_with_loop(self.enc, 0, 5, 2))
         
         expr = ast.Constant("FALSE")
         self.assertEqual(Be.false(self.mgr), expr.semantic_with_loop(self.enc, 0, 5, 2))
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:9,代碼來源:testSemantics.py

示例5: test_sub_

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
    def test_sub_(self):
        # and not
        true = Be.true(self._manager)
        false = Be.false(self._manager)

        self.assertTrue((true - false).is_true())
        self.assertFalse((true - false).is_false())
        self.assertTrue((true - false).is_constant())
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:10,代碼來源:testBe.py

示例6: test_and

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
    def test_and(self):
        # using the function
        true = Be.true(self._manager)
        false = Be.false(self._manager)

        self.assertFalse(true.and_(false).is_true())
        self.assertTrue(true.and_(false).is_false())
        self.assertTrue(true.and_(false).is_constant())
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:10,代碼來源:testBe.py

示例7: test__and_

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
    def test__and_(self):
        # using the keyword
        true = Be.true(self._manager)
        false = Be.false(self._manager)

        self.assertFalse((true and false).is_true())
        self.assertTrue((true and false).is_false())
        self.assertTrue((true and false).is_constant())
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:10,代碼來源:testBe.py

示例8: test_fairness_list

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
 def test_fairness_list(self):
     self.assertEqual(1, len(self._TESTED.fairness_list))   
     # returned items are boolean expressions
     fairness = self._TESTED.fairness_list[0]
     # manually recoding v = True
     v        = self._TESTED.encoding.by_name['v'].boolean_expression
     manual   = Be.true(self._TESTED.encoding.manager).iff(v)
     self.assertEqual(fairness, manual)
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:10,代碼來源:testBeFsm.py

示例9: test_add_

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
    def test_add_(self):
        # using the algebraic notation
        true = Be.true(self._manager)
        false = Be.false(self._manager)

        self.assertTrue((true + false).is_true())
        self.assertFalse((true + false).is_false())
        self.assertTrue((true + false).is_constant())
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:10,代碼來源:testBe.py

示例10: _semantic

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
 def _semantic(time, cnt):
     """auxiliary function to stop recursing after k steps"""
     # at infinity, it is true: psi is not forced if []phi
     if cnt == k:
         return Be.true(enc.manager)
     psi = self.rhs.semantic_with_loop(enc, time, k, l)
     phi = self.lhs.semantic_with_loop(enc, time, k, l)
     return psi | (phi & _semantic(successor(time, k, l), cnt + 1))
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:10,代碼來源:ast.py

示例11: test_inline

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
    def test_inline(self):
        true = Be.true(self._manager)
        self.assertIsNotNone(true.inline(True))
        self.assertIsNotNone(true.inline(False))

        # with a non constant expression
        v = self._fsm.encoding.by_name["v"].boolean_expression
        self.assertIsNotNone(v.inline(True))
        self.assertIsNotNone(v.inline(False))
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:11,代碼來源:testBe.py

示例12: verify_step_fairness_constraint

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
 def verify_step_fairness_constraint(self):
     # must be true
     tool = ast.fairness_constraint(self.befsm, 0, 0)
     self.assertEqual(tool, Be.true(self.mgr))
      
     # loop position does not matter if not feasible
     tool = ast.fairness_constraint(self.befsm, 0, 1)
     self.assertEqual(tool, Be.true(self.mgr))
     
     model= bmcutils.BmcModel()
     # step 0
     tool = ast.fairness_constraint(self.befsm, 1, 0)
     smv  = model.fairness(1, 0) 
     self.assertEqual(tool, smv)
      
     # step 1
     tool = ast.fairness_constraint(self.befsm, 2, 1)
     smv  = model.fairness(2, 1) 
     self.assertEqual(tool, smv)
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:21,代碼來源:testSemantics.py

示例13: verify_invariants_constraint

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
 def verify_invariants_constraint(self, bound):
     model  = bmcutils.BmcModel() 
         
     manual = Be.true(self.mgr) 
     for i in range(bound+1):
         manual &= model.invar[i]
     
     tool = gen.invariants_constraint(self.befsm, bound)
     
     self.assertEqual(tests.canonical_cnf(tool), 
                      tests.canonical_cnf(manual))
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:13,代碼來源:testGen.py

示例14: test_to_cnf

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
    def test_to_cnf(self):
        true = Be.true(self._manager)
        self.assertIsNotNone(true.to_cnf(Polarity.NOT_SET))
        self.assertIsNotNone(true.to_cnf(Polarity.NEGATIVE))
        self.assertIsNotNone(true.to_cnf(Polarity.POSITIVE))

        # with a non constant expression
        v = self._fsm.encoding.by_name["v"].boolean_expression
        self.assertIsNotNone(v.to_cnf(Polarity.NOT_SET))
        self.assertIsNotNone(v.to_cnf(Polarity.NEGATIVE))
        self.assertIsNotNone(v.to_cnf(Polarity.POSITIVE))
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:13,代碼來源:testBe.py

示例15: bounded_semantics_at_offset

# 需要導入模塊: from pynusmv.be.expression import Be [as 別名]
# 或者: from pynusmv.be.expression.Be import true [as 別名]
def bounded_semantics_at_offset(fsm, formula, bound, offset, fairness=True):
    """
    Generates the Be [[formula]]_{bound} corresponding to the bounded semantic 
    of `formula` but encodes it with an `offset` long shift in the timeline of the encoder.

    .. note:: 

        This function plays the same role as `bounded_semantics_all_loops` but allows to 
        position the time blocks at some place we like in the encoder timeline. This is mostly
        helpful if you want to devise verification methods that need to have multiple parallel
        verifications. (ie. diagnosability).

        Note however, that the two implementations are different.

    .. warning::

        So far, the only supported temporal operators are F, G, U, R, X

    :param fsm: the BeFsm for which the property will be verified. Actually, it is only used to 
        provide the encoder used to assign the variables to some time blocks. The api was kept 
        this ways to keep uniformity with its non-offsetted counterpart.
    :param formula: the property for which to generate a verification problem
        represented in a 'node' format (subclass of :see::class:`pynusmv.node.Node`)
        which corresponds to the format obtained from the ast. (remark: if you
        need to manipulate [ie negate] the formula before passing it, it is
        perfectly valid to pass a node decorated by `Wff.decorate`).
    :param bound: the logical time bound to the problem. (Leave out the offset for this param: if you
        intend to have a problem with at most 10 steps, say bound=10)
    :param offset: the time offset in the encoding block where the sem of this formula will be 
        generated.
    :param fairness: a flag indicating whether or not to take the fairness 
        constraint into account.
    :return: a Be corresponding to the semantics of `formula` for a problem with a maximum of `bound` 
        steps encoded to start at time `offset` in the `fsm` encoding timeline.
    """
    if bound< 0:
        raise ValueError("Bound must be a positive integer")
    if offset<0:
        raise ValueError("The offset must be a positive integer")
    
    enc = fsm.encoding
    straight = bounded_semantics_without_loop_at_offset(fsm, formula, 0, bound, offset)
    k_loop   = Be.false(enc.manager)
    for i in range(bound): 
        fairness_cond = utils.fairness_constraint(fsm, offset+bound, offset+i) \
                                 if fairness \
                                 else Be.true(enc.manager)
        k_loop |= ( utils.loop_condition(enc, offset+bound, offset+i) \
                  & fairness_cond \
                  & bounded_semantics_with_loop_at_offset(fsm, formula, 0, bound, i, offset))
    
    # this is just the sem of the formula
    return straight | k_loop    
開發者ID:xgillard,項目名稱:pynusmv,代碼行數:55,代碼來源:ltlspec.py


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