# Path: tt/definitions/operands.py
# BOOLEAN_VALUES = {0, 1, True, False}
# 
# Path: tt/errors/evaluation.py
# class InvalidBooleanValueError(EvaluationError):
#     """An exception for when an invalid truth or don't care value is passed.
# 
#     Here's an example where we attempt to evaluate a \
#     :class:`BooleanExpression <tt.expressions.bexpr.BooleanExpression>` with
#     an invalid value passed through ``kwargs``::
# 
#         >>> from tt import BooleanExpression
#         >>> b = BooleanExpression('A or B')
#         >>> b.evaluate(A=1, B='brian')
#         Traceback (most recent call last):
#             ...
#         tt.errors.evaluation.InvalidBooleanValueError: "brian" passed as \
# value for "B" is not a valid Boolean value
# 
#     """
# 
# Path: tt/errors/symbols.py
# class DuplicateSymbolError(SymbolError):
#     """An exception type for user-specified duplicate symbols.
# 
#     Here's an example where we try to pass duplicate symbols to the
#     ``ordering`` property of the :class:`TruthTable \
#     <tt.tables.truth_table.TruthTable>` class::
# 
#         >>> from tt import TruthTable
#         >>> t = TruthTable('A or B', ordering=['A', 'A', 'B'])
#         Traceback (most recent call last):
#             ...
#         tt.errors.symbols.DuplicateSymbolError: Received duplicate symbols
# 
#     """
# 
# class ExtraSymbolError(SymbolError):
#     """An exception for a passed token that is not a parsed symbol.
# 
#     Here's a quick table example::
# 
#         >>> from tt import TruthTable
#         >>> t = TruthTable('A or B', ordering=['A', 'B', 'C'])
#         Traceback (most recent call last):
#             ...
#         tt.errors.symbols.ExtraSymbolError: Received unexpected symbols: "C"
# 
#     """
# 
# class MissingSymbolError(SymbolError):
#     """An exception type for a missing token value in evaluation.
# 
#     .. code-block:: python
# 
#         >>> from tt import BooleanExpression
#         >>> b = BooleanExpression('A and B')
#         >>> b.evaluate(A=1)
#         Traceback (most recent call last):
#             ...
#         tt.errors.symbols.MissingSymbolError: Did not receive value for the \
# following symbols: "B"
# 
#     """


from tt.definitions import BOOLEAN_VALUES
from tt.errors import (
    DuplicateSymbolError,
    ExtraSymbolError,
    InvalidBooleanValueError,
    MissingSymbolError)
def assert_all_valid_keys(symbol_input_dict, symbol_set):
    """Assert that all keys in the passed input dict are valid.

    Valid keys are considered those that are present in the passed set of
    symbols and that map to valid Boolean values. Dictionaries cannot have
    duplicate keys, so no duplicate checking is necessary.

    :param symbol_input_dict: A dict containing symbol names mapping to what
        should be Boolean values.
    :type symbol_input_dict: Dict{:class:`str <python:str>`: truthy}

    :param symbol_set: A set of the symbol names expected to be present as keys
        in ``symbol_input_dict``.
    :type symbol_set: Set[:class:`str <python:str>`]

    :raises ExtraSymbolError: If any keys in the passed input dict are not
        present in the passed set of symbols.
    :raises InvalidBooleanValueError: If any values in the passed input dict
        are not valid Boolean values (``1``, ``0``, ``True``, or ``False``).

    This assert is used for validation of user-specified kwargs which map
    symbols to expected values.

    """
    for k, v in symbol_input_dict.items():
        if k not in symbol_set:
            raise ExtraSymbolError(
                '"{}" is not a symbol in this expression'.format(k))

        if v not in BOOLEAN_VALUES:

# Path: tt/definitions/operands.py
# BOOLEAN_VALUES = {0, 1, True, False}
# 
# Path: tt/errors/evaluation.py
# class InvalidBooleanValueError(EvaluationError):
#     """An exception for when an invalid truth or don't care value is passed.
# 
#     Here's an example where we attempt to evaluate a \
#     :class:`BooleanExpression <tt.expressions.bexpr.BooleanExpression>` with
#     an invalid value passed through ``kwargs``::
# 
#         >>> from tt import BooleanExpression
#         >>> b = BooleanExpression('A or B')
#         >>> b.evaluate(A=1, B='brian')
#         Traceback (most recent call last):
#             ...
#         tt.errors.evaluation.InvalidBooleanValueError: "brian" passed as \
# value for "B" is not a valid Boolean value
# 
#     """
# 
# Path: tt/errors/symbols.py
# class DuplicateSymbolError(SymbolError):
#     """An exception type for user-specified duplicate symbols.
# 
#     Here's an example where we try to pass duplicate symbols to the
#     ``ordering`` property of the :class:`TruthTable \
#     <tt.tables.truth_table.TruthTable>` class::
# 
#         >>> from tt import TruthTable
#         >>> t = TruthTable('A or B', ordering=['A', 'A', 'B'])
#         Traceback (most recent call last):
#             ...
#         tt.errors.symbols.DuplicateSymbolError: Received duplicate symbols
# 
#     """
# 
# class ExtraSymbolError(SymbolError):
#     """An exception for a passed token that is not a parsed symbol.
# 
#     Here's a quick table example::
# 
#         >>> from tt import TruthTable
#         >>> t = TruthTable('A or B', ordering=['A', 'B', 'C'])
#         Traceback (most recent call last):
#             ...
#         tt.errors.symbols.ExtraSymbolError: Received unexpected symbols: "C"
# 
#     """
# 
# class MissingSymbolError(SymbolError):
#     """An exception type for a missing token value in evaluation.
# 
#     .. code-block:: python
# 
#         >>> from tt import BooleanExpression
#         >>> b = BooleanExpression('A and B')
#         >>> b.evaluate(A=1)
#         Traceback (most recent call last):
#             ...
#         tt.errors.symbols.MissingSymbolError: Did not receive value for the \
# following symbols: "B"
# 
#     """


# Path: tt/_assertions/collections.py
from tt.definitions import BOOLEAN_VALUES
from tt.errors import (
    DuplicateSymbolError,
    ExtraSymbolError,
    InvalidBooleanValueError,
    MissingSymbolError)

def assert_all_valid_keys(symbol_input_dict, symbol_set):
    """Assert that all keys in the passed input dict are valid.

    Valid keys are considered those that are present in the passed set of
    symbols and that map to valid Boolean values. Dictionaries cannot have
    duplicate keys, so no duplicate checking is necessary.

    :param symbol_input_dict: A dict containing symbol names mapping to what
        should be Boolean values.
    :type symbol_input_dict: Dict{:class:`str <python:str>`: truthy}

    :param symbol_set: A set of the symbol names expected to be present as keys
        in ``symbol_input_dict``.
    :type symbol_set: Set[:class:`str <python:str>`]

    :raises ExtraSymbolError: If any keys in the passed input dict are not
        present in the passed set of symbols.
    :raises InvalidBooleanValueError: If any values in the passed input dict
        are not valid Boolean values (``1``, ``0``, ``True``, or ``False``).

    This assert is used for validation of user-specified kwargs which map
    symbols to expected values.

    """
    for k, v in symbol_input_dict.items():
        if k not in symbol_set:
            raise ExtraSymbolError(
                '"{}" is not a symbol in this expression'.format(k))

        if v not in BOOLEAN_VALUES:

            raise InvalidBooleanValueError(