aima/logic.py
def subst(s, x):
    """Substitute the substitution s into the expression x.
    >>> subst({x: 42, y:0}, F(x) + y)
    (F(42) + 0)
    """
    if isinstance(x, list):
        return [subst(s, xi) for xi in x]
    elif isinstance(x, tuple):
        return tuple([subst(s, xi) for xi in x])
    elif not isinstance(x, Expr):
        return x
    elif is_var_symbol(x.op):
        return s.get(x, x)
    else:
        return Expr(x.op, *[subst(s, arg) for arg in x.args])
def subst(s, x):
    """Substitute the substitution s into the expression x.
    >>> subst({x: 42, y:0}, F(x) + y)
    (F(42) + 0)
    """
    if isinstance(x, list):
        return [subst(s, xi) for xi in x]
    elif isinstance(x, tuple):
        return tuple([subst(s, xi) for xi in x])
    elif not isinstance(x, Expr):
        return x
    elif is_var_symbol(x.op):
        return s.get(x, x)
    else:
        return Expr(x.op, *[subst(s, arg) for arg in x.args])
def subst ( s , x ) : if isinstance ( x , list ) : return [ subst ( s , xi ) for xi in x ] elif isinstance ( x , tuple ) : return tuple ( [ subst ( s , xi ) for xi in x ] ) elif not isinstance ( x , Expr ) : return x elif is_var_symbol ( x . op ) : return s . get ( x , x ) else : return Expr ( x . op , * [ subst ( s , arg ) for arg in x . args ] )
Substitute the substitution s into the expression x.
    >>> subst({x: 42, y:0}, F(x) + y)
    (F(42) + 0)
Substitute the substitution s into the expression x . >>> subst ( { x : 42 y : 0 } F ( x ) + y ) ( F ( 42 ) + 0 )