def used_variables(*terms):
    """
    Returns a frozenset of variables used in given terms.

    Note that this returns all used variables, not just free ones.
    """

    t = terms[0] if len(terms) == 1 else terms

    if type(t) is Var:
        return frozenset((t,))

    elif type(t) in (tuple, Const, Apply, Eq, Ite, Not, And, Or,
                     Implies, Iff):
        return union(*(used_variables(x) for x in t))

    elif type(t) in (ForAll, Exists):
        return union(used_variables(t.body), t.variables)

    elif hasattr(t,'args'):
        return union(*(used_variables(x) for x in t.args))

    else:
        assert False, type(t)
dataset/ETHPy150Open Microsoft/ivy/ivy/logic_util.py/used_variables/original