def substitute(t, subs):

    if not isinstance(subs, dict):
        subs = dict(subs)

    if type(t) in (Var, Const):
        if t in subs:
            return subs[t]
        else:
            return t

    elif type(t) in (Apply, Eq, Ite, Not, And, Or, Implies, Iff):
        return type(t)(*(substitute(x, subs) for x in t))

    elif type(t) in (ForAll, Exists):
        forbidden_variables = free_variables(*subs.values())
        if forbidden_variables.isdisjoint(t.variables):
            return type(t)(t.variables, substitute(t.body, (
                (k, v) for k, v in subs.iteritems()
                if k not in t.variables
            )))
        else:
            assert False, (t, subs) # capturing would be created

    else:
        assert False, type(e)
Return the resource corresponding to a single access.
dataset/ETHPy150Open Microsoft/ivy/ivy/logic_util.py/substitute--crossover with--dataset/ETHPy150Open ducksboard/libsaas/libsaas/services/basecamp/calendars.py/Calendar.access