def vars_in_support(u, fol): """Return variables that `u` depends on. Returns unprimed identifiers for all variables that occur (primed or not) in the support of `u`. """ vrs = set() for k in fol.support(u): if stx.isprimed(k): vrs.add(stx.unprime(k)) elif is_variable(k, fol): vrs.add(k) assert vrs == (flexible_support(u, fol) | {stx.unprime(s) for s in primed_support(u, fol)}) return vrs
def _add_bitnames(t): """Map each integer to a list of bit variables.""" for var, d in t.items(): if d['type'] != 'int': continue assert d['type'] == 'int', d['type'] if stx.isprimed(var): name = stx.unprime(var) prime = stx.PRIME else: name = var prime = '' bits = [ '{name}_{i}{prime}'.format( name=name, i=i, prime=prime) for i in range(d['width'])] are_booleans = list(filter(t.__contains__, bits)) assert not are_booleans, (bits, t) d['bitnames'] = bits
def assert_consistent(self, moore=True): """Assert that `init` and `win` contain state predicates.""" varlists = list(self.varlist.values()) assert pairwise_disjoint(varlists) for u in self.init.values(): assert sym_bdd.is_state_predicate(u) # Moore actions for player, action in self.action.items(): primed = { stx.unprime(var) for var in self.support(action) if stx.isprimed(var) } # applicable only after unzip # assert primed.issubset(self.varlist[player]), ( # (player, primed)) for d in self.win.values(): for v in d.values(): for u in v: assert sym_bdd.is_state_predicate(u)
def _add_bitnames(t): """Map each integer to a list of bit variables.""" for var, d in t.items(): if d['type'] != 'int': continue assert d['type'] == 'int', d['type'] if stx.isprimed(var): name = stx.unprime(var) prime = stx.PRIME else: name = var prime = '' bits = [ '{name}_{i}{prime}'.format(name=name, i=i, prime=prime) for i in range(d['width']) ] are_booleans = list(filter(t.__contains__, bits)) assert not are_booleans, (bits, t) d['bitnames'] = bits
def _unprime_state(primed_state): """Return same state but with identifiers unprimed.""" return {stx.unprime(k): v for k, v in primed_state.items()}
def unprime(u, fol): """Unprime primed variables in support of `u`.""" primed_vars = primed_support(u, fol) let = {s: stx.unprime(s) for s in primed_vars} return fol.let(let, u)
def unprime_vars(self, vrs): """Return `list` of primed variables from `vrs`.""" return [stx.unprime(var) for var in vrs]