def is_solution(cnf, assignment):
    """Test whether the given assignment is a solution to the CNF.

    assignment is a dictionary from variable names to truth values.
    It is not required that all variables in the CNF are assigned.

    """
    for clause in cnf:
        satisfied = False
        for lit in clause:
            name, val = lit
            if name in assignment and val == assignment[name]:
                satisfied = True
                break
        if not satisfied:
            return False
    return True