':see: Expression.replace()'

def replace(self, variable, expression, replace_bound=False, alpha_convert=True):

    assert isinstance(variable, Variable), (u'%s    is    not    a    Variable' % variable)
    assert isinstance(expression, Expression), (u'%s    is    not    an    Expression' % expression)
    if (self.variable == variable):
        if replace_bound:
            assert isinstance(expression, AbstractVariableExpression), (u'%s    is    not    a    AbstractVariableExpression' % expression)
            return self.__class__(expression.variable, self.term.replace(variable, expression, True, alpha_convert))
        else:
            return self
    else:
        if (alpha_convert and (self.variable in expression.free())):
            self = self.alpha_convert(unique_variable(pattern=self.variable))
        return self.__class__(self.variable, self.term.replace(variable, expression, replace_bound, alpha_convert))
