mappings = (dict(zip(symbols, values)) for values in itertools.product([
    False, True], repeat=len(symbols)))
solutions = [sorted(name for name in mapping if mapping[name]) for mapping in
    mappings if eval(expression, None, mapping)]
return sorted(s1 for s1 in solutions if not any(set(s1) > set(s2) for s2 in
    solutions))
get elements in "AND" in logic string with Python