本文整理汇总了Python中pynusmv.be.expression.Be.false方法的典型用法代码示例。如果您正苦于以下问题:Python Be.false方法的具体用法?Python Be.false怎么用?Python Be.false使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pynusmv.be.expression.Be
的用法示例。
在下文中一共展示了Be.false方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bounded_semantics_without_loop
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [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)
示例2: test_false
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [as 别名]
def test_false(self):
with self.assertRaises(Exception):
Be.false(None)
expr = Be.false(self._manager)
self.assertFalse(expr.is_true())
self.assertTrue(expr.is_false())
self.assertTrue(expr.is_constant())
示例3: test_globally_no_loop
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [as 别名]
def test_globally_no_loop(self):
with Configure(self, __file__, "/models/flipflops.smv"):
fsm = self.befsm
formula = self.nnf("G (a <-> !b)")
# bound 0
ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 0)
expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, 0)
self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
# bound 1
ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 1)
expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, 0)
self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
# ---- other offset ----
# bound 0
offset = 1
ref_expr= Be.false(fsm.encoding.manager)
expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, offset)
self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
# bound 1
offset = 1
ref_expr= Be.false(fsm.encoding.manager)
expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, offset)
self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
示例4: test_next_no_loop
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [as 别名]
def test_next_no_loop(self):
with Configure(self, __file__, "/models/flipflops.smv"):
fsm = self.befsm
formula = self.nnf("X (a <-> !b)")
# bound 0
ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 0)
expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, 0)
self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
# bound 1
ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 1)
expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, 0)
self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
# ---- other offset ----
# bound 0
offset = 1
ref_expr= Be.false(fsm.encoding.manager)
expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, offset)
self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
# bound 1
offset = 1
ref_expr= Wff.decorate(ltlspec.car(formula)).to_be(fsm.encoding)
ref_expr= fsm.encoding.shift_to_time(ref_expr, offset+1)
expr = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, offset)
self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
示例5: test_constant_with_loop
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [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))
示例6: bounded_semantics
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [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
示例7: test_add_
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [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())
示例8: test_sub_
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [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())
示例9: test_and
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [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())
示例10: test__and_
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [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())
示例11: _semantic
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [as 别名]
def _semantic(time, cnt):
"""auxiliary function to stop recursing after k steps"""
# at infinity, it is false: psi MUST happen at some time
if cnt == k:
return Be.false(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))
示例12: semantic_no_loop
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [as 别名]
def semantic_no_loop(self, enc, i, k):
"""The semantics when there is no loop:: [[lhs W rhs]]_{bound}^{time}"""
# k is not infinity when there is no loop
if i > k:
return Be.false(enc.manager)
psi = self.rhs.semantic_no_loop(enc, i, k)
phi = self.lhs.semantic_no_loop(enc, i, k)
return psi | (phi & self.semantic_no_loop(enc, i + 1, k))
示例13: test_globally_no_loop
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [as 别名]
def test_globally_no_loop(self):
with tests.Configure(self, __file__, "/example.smv"):
i,k = 0,2
enc = self.enc
mgr = enc.manager
a = ast.Proposition("a")
formula = ast.Globally(a)
tool = formula.semantic_no_loop(enc, i, k)
self.assertEqual(Be.false(mgr), tool)
示例14: semantic_with_loop
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [as 别名]
def semantic_with_loop(self, enc, i, k, l):
# without moving at least one step, it is impossible to go through a loop
if k == 0:
return Be.false(enc.manager)
def _semantic(time, cnt):
if cnt == k:
return Be.false(enc.manager)
now = self.prop.semantic_with_loop(enc, time, k, l)
return now | _semantic(successor(time, k, l), cnt + 1)
return _semantic(i, 0)
示例15: bounded_semantics_at_offset
# 需要导入模块: from pynusmv.be.expression import Be [as 别名]
# 或者: from pynusmv.be.expression.Be import false [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