def dpq(states, actions, initial_value=0):
    """dynamic programming definition for Q-learning

    This implementation returns a table like, nested
    dict of states and actions -- where the inner values
    q[s][a] reflect the best current estimates of expected
    rewards for taking action a on state s.

    See [1] chapter 3 for details.

    PARAMETERS
    ----------
    * states: list, tuple or any other enumerable
    Where each state in the collection is representated by
    any other immutable type i.g int or tuple.

    * actions: list, tuple or any other enumerable
    Where each action in the collection is representated by
    any other immutable type i.g int or tuple.

    * initial_value: numeric
    Initial a priori guess for the Q function

    RETURNS
    -------
    * q: dictionary
    Where q is a nested dictionary where the outer keys
    are states and the inner keys are the actions

    REFERENCE
    ---------

    [1] Sutton et Barto, Reinforcement Learning 2nd Ed 2018
    """
    return {
            s: {
                a: initial_value
                for a in actions
            }
            for s in states
    }