本文整理汇总了Python中pynusmv.dd.BDD.false方法的典型用法代码示例。如果您正苦于以下问题:Python BDD.false方法的具体用法?Python BDD.false怎么用?Python BDD.false使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pynusmv.dd.BDD
的用法示例。
在下文中一共展示了BDD.false方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: nfair_gamma_states
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def nfair_gamma_states(fsm, agents):
"""
Return the set of states in which agents cann avoid fair paths.
fsm -- the model
agents -- a list of agents names
"""
# NFair_Gamma = not([Gamma] G True) = <Gamma> F False
agents = frozenset(agents)
if agents not in __nfair_gamma_states:
if len(fsm.fairness_constraints) == 0:
__nfair_gamma_states[agents] = BDD.false(fsm.bddEnc.DDmanager)
else:
def inner(Z):
res = BDD.false(fsm.bddEnc.DDmanager)
for f in fsm.fairness_constraints:
nf = ~f # & fsm.bddEnc.statesMask
res = res | fsm.pre_strat(
fp(lambda Y: (Z | nf) & fsm.pre_strat(Y, agents), BDD.true(fsm.bddEnc.DDmanager)), agents
)
return res
__nfair_gamma_states[agents] = fp(inner, BDD.false(fsm.bddEnc.DDmanager))
return __nfair_gamma_states[agents]
示例2: ceu
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def ceu(fsm, agents, phi, psi):
"""
Return the set of states of fsm satisfying <agents>[phi U psi].
fsm -- a MAS representing the system
agents -- a list of agents names
phi -- a BDD representing the set of states of fsm satisfying phi
psi -- a BDD representing the set of states of fsm satisfying psi
"""
# phi = phi & fsm.bddEnc.statesInputsMask
# psi = psi & fsm.bddEnc.statesInputsMask
if len(fsm.fairness_constraints) == 0:
return fp(lambda Z: psi | (phi & fsm.pre_strat(Z, agents)), BDD.false(fsm.bddEnc.DDmanager))
else:
nfair = nfair_gamma_states(fsm, agents)
def inner(Z):
res = psi
for f in fsm.fairness_constraints:
nf = ~f # & fsm.bddEnc.statesMask
res = res | fsm.pre_strat(
fp(
lambda Y: (phi | psi | nfair) & (Z | nf) & (psi | fsm.pre_strat(Y, agents)),
BDD.true(fsm.bddEnc.DDmanager),
),
agents,
)
return (psi | phi | nfair) & res
return fp(inner, BDD.false(fsm.bddEnc.DDmanager))
示例3: check_cax
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def check_cax(self, fsm, explanation, agents, phi):
"""Check that the explanation is correct."""
# Get the cubes
gamma_cube = fsm.inputs_cube_for_agents(agents)
ngamma_cube = fsm.bddEnc.inputsCube - gamma_cube
# The first state satisfies the spec
self.assertTrue(explanation.state <= ~cex(fsm, agents, ~phi))
acts = BDD.false(fsm.bddEnc.DDmanager)
states = BDD.false(fsm.bddEnc.DDmanager)
for (act, succ) in explanation.successors:
# The successor satisfies phi
self.assertTrue(succ.state <= phi)
# The action is effectively possible
self.assertTrue(act <= fsm.get_inputs_between_states(
explanation.state, succ.state))
# Accumulate states and actions
acts = acts | act
states = states | succ.state
# The actions are effectively all the possible ones
self.assertEqual((fsm.protocol(agents) &
explanation.state).forsome(fsm.bddEnc.statesCube).
forsome(ngamma_cube) &
fsm.bddEnc.statesMask,
acts.forsome(ngamma_cube) & fsm.bddEnc.statesMask)
示例4: nfair_gamma_si
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def nfair_gamma_si(fsm, agents, strat=None):
"""
Return the set of state/inputs pairs of strat
in which agents can avoid a fair path in strat.
If strat is None, it is considered true.
fsm -- the model
agents -- a list of agents names
strat -- a BDD representing allowed state/inputs pairs, or None
"""
if not strat:
strat = BDD.true(fsm.bddEnc.DDmanager)
if len(fsm.fairness_constraints) == 0:
return BDD.false(fsm.bddEnc.DDmanager)
else:
def inner(Z):
res = BDD.false(fsm.bddEnc.DDmanager)
for f in fsm.fairness_constraints:
nf = ~f & fsm.bddEnc.statesMask & strat
res = res | fsm.pre_strat_si(fp(lambda Y :
(Z | nf) &
fsm.pre_strat_si(Y, agents,
strat),
BDD.true(fsm.bddEnc.DDmanager)),
agents, strat)
return res
return fp(inner, BDD.false(fsm.bddEnc.DDmanager))
示例5: check_free_choice
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def check_free_choice(self):
"""
Check whether this MAS satisfies the free-choice property, that is,
in every state, the choices of actions for each agent is not
constrained by the choices of other agents.
Return the set of moves that are not present in the MAS and should,
or that are present but should not.
"""
if len(self.agents) <= 0:
return BDD.false(self.bddEnc.DDmanager)
true = BDD.true(self.bddEnc.DDmanager)
protocols = {agent: self.protocol({agent}) for agent in self.agents}
enabled = (self.weak_pre(self.reachable_states) &
self.reachable_states & self.bddEnc.statesInputsMask)
for s in self.pick_all_states(self.reachable_states):
product = self.bddEnc.statesInputsMask
for agent in self.agents:
product &= protocols[agent] & s
if (enabled & s) != product:
return product.xor(enabled & s)
return BDD.false(self.bddEnc.DDmanager)
示例6: check_cex
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def check_cex(self, fsm, explanation, agents, phi):
"""Check that the explanation is correct."""
# Get the cubes
gamma_cube = fsm.inputs_cube_for_agents(agents)
ngamma_cube = fsm.bddEnc.inputsCube - gamma_cube
# The first state satisfies the spec
self.assertTrue(explanation.state <= cex(fsm, agents, phi))
acts = BDD.false(fsm.bddEnc.DDmanager)
states = BDD.false(fsm.bddEnc.DDmanager)
for (act, succ) in explanation.successors:
ag_action = act.forsome(ngamma_cube)
# The successor satisfies phi
self.assertTrue(succ.state <= phi)
# The action is effectively possible
self.assertTrue(act <= fsm.get_inputs_between_states(
explanation.state, succ.state))
# Accumulate states and actions
acts = acts | act
states = states | succ.state
# The reached states are effectively the reachable states
# through the action
self.assertTrue(states <= fsm.post(explanation.state, ag_action))
self.assertTrue(states >= fsm.post(explanation.state, ag_action)
& fsm.bddEnc.statesMask)
# The actions are effectively all the possible actions completing ag_act
self.assertTrue(acts <= ag_action)
self.assertTrue(acts >= ag_action &
fsm.get_inputs_between_states(explanation.state, states) &
fsm.bddEnc.inputsMask)
示例7: test_get_false
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def test_get_false(self):
(fsm, enc, manager) = self.init_model()
false = BDD.false(manager)
self.assertIsNotNone(false)
self.assertTrue(false.is_false())
self.assertFalse(false.is_true())
self.assertTrue(false.isnot_true())
self.assertFalse(false.isnot_false())
self.assertTrue(false.isnot_true())
false = BDD.false()
self.assertIsNotNone(false)
self.assertTrue(false.is_false())
self.assertFalse(false.is_true())
self.assertTrue(false.isnot_true())
self.assertFalse(false.isnot_false())
self.assertTrue(false.isnot_true())
false = BDD.false()
self.assertIsNotNone(false)
self.assertTrue(false.is_false())
self.assertFalse(false.is_true())
self.assertTrue(false.isnot_true())
self.assertFalse(false.isnot_false())
self.assertTrue(false.isnot_true())
示例8: ceu
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def ceu(fsm, agents, phi, psi, strat=None):
"""
Return the set of states of strat satisfying <agents>[phi U psi]
under full observability in strat.
If strat is None, strat is considered true.
fsm -- a MAS representing the system
agents -- a list of agents names
phi -- a BDD representing the set of states of fsm satisfying phi
psi -- a BDD representing the set of states of fsm satisfying psi
strat -- a BDD representing allowed state/inputs pairs, or None
"""
if len(fsm.fairness_constraints) == 0:
return fp(lambda Z : psi | (phi & fsm.pre_strat(Z, agents, strat)),
BDD.false(fsm.bddEnc.DDmanager))
else:
nfair = nfair_gamma(fsm, agents, strat)
def inner(Z):
res = psi
for f in fsm.fairness_constraints:
nf = ~f
res = res | fsm.pre_strat(fp(lambda Y :
(phi | psi | nfair) &
(Z | nf) &
(psi |
fsm.pre_strat(Y, agents, strat)),
BDD.true(fsm.bddEnc.DDmanager)),
agents, strat)
return (psi | phi | nfair) & res
return fp(inner, BDD.false(fsm.bddEnc.DDmanager))
示例9: test_init
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def test_init(self):
fsm = self.init_model()
manager = fsm.bddEnc.DDmanager
init = fsm.init
initState = fsm.pick_one_state(init)
self.assertTrue(BDD.false(manager) <= init <= BDD.true(manager))
self.assertTrue(BDD.false(manager) < initState <= init)
示例10: eval_strat_FSF
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def eval_strat_FSF(fsm, spec):
"""
Return the BDD representing the set of states of fsm satisfying spec.
spec is a strategic operator <G> pi.
Implement a variant of the algorithm that
filters, splits and then filters.
fsm -- a MAS representing the system;
spec -- an AST-based ATLK specification with a top strategic operator.
"""
if type(spec) is CAX:
# [g] X p = ~<g> X ~p
newspec = CEX(spec.group, Not(spec.child))
return ~eval_strat_FSF(fsm, newspec)
elif type(spec) is CAG:
# [g] G p = ~<g> F ~p
newspec = CEF(spec.group, Not(spec.child))
return ~eval_strat_FSF(fsm, newspec)
elif type(spec) is CAU:
# [g][p U q] = ~<g>[ ~q W ~p & ~q ]
newspec = CEW(spec.group,
Not(spec.right),
And(Not(spec.left), Not(spec.right)))
return ~eval_strat_FSF(fsm, newspec)
elif type(spec) is CAF:
# [g] F p = ~<g> G ~p
newspec = CEG(spec.group, Not(spec.child))
return ~eval_strat_FSF(fsm, newspec)
elif type(spec) is CAW:
# [g][p W q] = ~<g>[~q U ~p & ~q]
newspec = CEU(spec.group,
Not(spec.right),
And(Not(spec.left), Not(spec.right)))
return ~eval_strat_FSF(fsm, newspec)
sat = BDD.false(fsm.bddEnc.DDmanager)
agents = {atom.value for atom in spec.group}
# First filtering
winning = filter_strat(fsm, spec, variant="FSF")
if winning.is_false(): # no state/inputs pairs are winning => return false
return winning
return split_eval(fsm, spec, BDD.false(fsm.bddEnc.DDmanager),
winning)
示例11: inner
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def inner(Z):
res = phi
for f in fsm.fairness_constraints:
res = res & fsm.pre_nstrat(
fp(lambda Y: (Z & f) | (phi & fsm.pre_nstrat(Y, agents)), BDD.false(fsm.bddEnc.DDmanager)), agents
)
return res
示例12: inner
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def inner(Z):
res = Z
for f in fsm.fairness_constraints:
res = res & fixpoint(lambda Y : (Z & f) | (phi &
fsm.weak_pre(Y.forsome(fsm.bddEnc.inputsCube))),
BDD.false(fsm.bddEnc.DDmanager))
return phi & fsm.weak_pre(res.forsome(fsm.bddEnc.inputsCube))
示例13: split_eval
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def split_eval(fsm, spec, common, rest):
"""
Split strats into all its non-conflicting greatest subsets and compute
the states that satisfy spec in strats.
fsm -- the model
strats -- a BDD representing a set of states/inputs pairs
spec -- an AST-based ATLK specification with a top strategic operator.
"""
if (common | rest).is_false():
return common | rest
else:
gamma = {atom.value for atom in spec.group}
sat = BDD.false(fsm.bddEnc.DDmanager)
for newcommon, splitted, newrest in split_one(fsm, rest, gamma):
if splitted.is_false():
# newcommon contains a partial uniform strategy
# we can extract the winning states
# from newcommon | common
# first, filter
winning = (filter_strat(fsm, spec, common | newcommon, "SF")
.forsome(fsm.bddEnc.inputsCube))
# then, get equiv sat
sat = sat | all_equiv_sat(fsm, winning, gamma)
gc.collect()
else:
sat = sat | split_eval(fsm, spec, common | newcommon | splitted,
newrest)
return sat
示例14: get_equiv_class
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def get_equiv_class(fsm, gamma, state, semantics="group"):
"""
Return the equivalence class for gamma state belongs to. The equivalence
class depends on semantics; if semantics is individual, the common
knowledge based equivalence class for gamma containing state is returned;
otherwise (assuming semantics is group), the distributed knowledge based
equivalence fo gamma containing state is returned.
fsm -- the model
gamma -- a set of agents of fsm
semantics -- the semantic to use (group or individual);
if not "individual", "group" semantics is used
"""
if semantics == "individual":
old = BDD.false(fsm.bddEnc.DDmanager)
eq = state
while old != eq:
old = eq
for agent in gamma:
eq |= (fsm.equivalent_states(old, {agent}) &
fsm.reachable_states)
return eq
else:
return fsm.equivalent_states(state, gamma) & fsm.reachable_states
示例15: test_size
# 需要导入模块: from pynusmv.dd import BDD [as 别名]
# 或者: from pynusmv.dd.BDD import false [as 别名]
def test_size(self):
(fsm, enc, manager) = self.init_model()
true = BDD.true(manager)
false = BDD.false(manager)
init = fsm.init
noadmin = eval_simple_expression(fsm, "admin = none")
alice = eval_simple_expression(fsm, "admin = alice")
processing = eval_simple_expression(fsm, "state = processing")
self.assertEqual(BDD.true().size, 1)
self.assertEqual(BDD.false().size, 1)
self.assertEqual(fsm.pick_one_state(BDD.true()).size,
len(fsm.bddEnc.get_variables_ordering("bits")) + 1)
self.assertEqual(init.size, 5)
self.assertEqual(processing.size, 3)