def cnf_list(expr): """ returns a list representation of the recursive expression EXPR in the form of a dict where the clauses field is the actual list and Map is the mapping of variable names to numbers (in the form of a list of tuples) """ #Get a var map, create a new one (in case the old one #is wrong) and apply the new map. m = PBA.get_var_map(expr) m = PBA.create_new_map(m) PBA.apply_map(expr, m) return {"Clauses" : PBA.cnf_list(expr) , "map" : m }
def number_vars(expr): """ returns the number of variables in expr """ m = PBA.get_var_map(expr) return len(m)
def get_vars(expr): return [x[0] for x in PBA.get_var_map(expr)]