예제 #1
0
try:
    from dd import cudd as _bdd
except ImportError:
    from dd import autoref as _bdd

from omega.logic import bitvector as bv
from omega.logic import lexyacc
from omega.logic import syntax as stx
from omega.symbolic import bdd as sym_bdd
from omega.symbolic import cover as cov
from omega.symbolic import enumeration as enum
from omega.symbolic import orthotopes as lat

log = logging.getLogger(__name__)
_parser = lexyacc.Parser()
TYPE_HINTS = {'int', 'saturating', 'modwrap'}


class Context(object):
    """First-order interface to a binary decision diagram.

    All operations assume that integer-valued variables
    take only values that correspond to the Boolean-valued
    variables that refine them.

    Quantification is implicitly bounded.
    In the future, the bound will be made explicit
    in the syntax.

    "Context" alludes to extension of a formal theory
예제 #2
0
        for k in attr:
            if k not in players:
                print(('found action key "{k}" '
                       'that is not a player').format(k=k))


class Nodes(_Nodes):
    """Replace metasyntactic identifiers."""
    class Var(_Nodes.Var):
        def flatten(self, meta=None, *arg, **kw):
            var = self.value
            return meta.get(var, var)


# LTL parser for meta-replacements (preprocessor).
parser = lexyacc.Parser(nodes=Nodes)


def replace_meta(s, meta):
    """Return formula after replacing metasyntactic identifiers.

    @param s: LTL formula as `str`
    @param meta: replacements as `dict`
    """
    # a preprocessor
    return parser.parse(s).flatten(meta=meta)


def pick(c):
    """Return an element from container `c`.