def make_new_formula(formula, lit, lit_val):
    """
    Updates a CNF formula with the consequences of setting lit to lit_val.
    Parameters: 
        formula: list of clauses [ [(x, Bool)] ]
        lit: string
        lit_val: True or False
    Returns a modified CNF formula.
    """
    
    new_formula = []
    for c in formula:  
        
        # remove all the clauses with the literal
        if (lit, lit_val) not in c:
            new_formula.append(c.copy())
            
            # update the remaining clasues with (lit, not lit_val)
            while (lit, not lit_val) in new_formula[-1]:
                new_formula[-1].remove((lit, not lit_val)) 
    return new_formula