def replace(self, variable, expression, replace_bound=False, alpha_convert=True):
        assert isinstance(variable, Variable), "%s is not a Variable" % variable
        assert isinstance(expression, Expression), "%s is not an Expression" % expression
        #if the bound variable is the thing being replaced
        if self.variable == variable:
            if replace_bound:
                assert isinstance(expression, AbstractVariableExpression),\
                       "%s is not a AbstractVariableExpression" % expression
                return self.__class__(expression.variable,
                                      self.term.replace(variable, expression, True, alpha_convert))
            else:
                return self
        else:
            # if the bound variable appears in the expression, then it must
            # be alpha converted to avoid a conflict
            if alpha_convert and self.variable in expression.free():
                self = self.alpha_convert(unique_variable(pattern=self.variable))

            #replace in the term
            return self.__class__(self.variable,
                                  self.term.replace(variable, expression, replace_bound, alpha_convert))
:see: Expression.replace()
dataset/ETHPy150Open nltk/nltk/nltk/sem/logic.py/VariableBinderExpression.replace