(self, formula, subs=None, interpretations=None)
return res
Replaces any subformula in formula with the definition in subs (if
        any) and interprets function symbols with the interpretations
        in `interpretations`

        For example, let `phi` be the formula `phi = Equals(Function(f,
        [Int(2), Int(3)]), Plus(a, Int(1)))` where `a` is a Symbol of type INT and `f`
        is an uninterpreted function with two INT parameters that returns
        INT.

        Examples:

        - Basic substitution:
        `self.substitute(phi, {a: Int(5)})`
        will give `Equals(Function(f, [Int(2), Int(3)]), Plus(Int(5), Int(1)))`

        - Interpretation:
        ```
        x, y = Symbol('x', INT), Symbol('y', INT)
        i = FunctionInterpretation([x, y], Plus(x, y))
        self.substitute(phi, interpretations={f:i})
        ```
        will give `Equals(Int(5), Plus(a, Int(1)))`

        - Term substitution
        `self.substitute(phi, {Plus(a, Int(1)): Int(5)})`
        will give `Equals(Function(f, [Int(2), Int(3)]), Int(6))`
Replaces any subformula in formula with the definition in subs (if
        any) and interprets function symbols with the interpretations
        in `interpretations`
Replaces any subformula in formula with the definition in subs ( if any ) and interprets function symbols with the interpretations in interpretations
def substitute(self, formula, subs=None, interpretations=None):
        """Replaces any subformula in formula with the definition in subs (if
        any) and interprets function symbols with the interpretations
        in `interpretations`

        For example, let `phi` be the formula `phi = Equals(Function(f,
        [Int(2), Int(3)]), Plus(a, Int(1)))` where `a` is a Symbol of type INT and `f`
        is an uninterpreted function with two INT parameters that returns
        INT.

        Examples:

        - Basic substitution:
        `self.substitute(phi, {a: Int(5)})`
        will give `Equals(Function(f, [Int(2), Int(3)]), Plus(Int(5), Int(1)))`

        - Interpretation:
        ```
        x, y = Symbol('x', INT), Symbol('y', INT)
        i = FunctionInterpretation([x, y], Plus(x, y))
        self.substitute(phi, interpretations={f:i})
        ```
        will give `Equals(Int(5), Plus(a, Int(1)))`

        - Term substitution
        `self.substitute(phi, {Plus(a, Int(1)): Int(5)})`
        will give `Equals(Function(f, [Int(2), Int(3)]), Int(6))`
        """

        # Check that formula is a term
        if not formula.is_term():
            raise PysmtTypeError("substitute() can only be used on terms.")

        if subs is None:
            subs = {}
        if interpretations is None:
            interpretations = {}

        for i, (k, v) in enumerate(subs.items()):
            # Check that substitutions are terms
            if not k.is_term():
                raise PysmtTypeError(
                    "Only terms should be provided as substitutions." +
                    " Non-term '%s' found." % k)
            if not v.is_term():
                raise PysmtTypeError(
                    "Only terms should be provided as substitutions." +
                    " Non-term '%s' found." % v)
            # Check that substitutions belong to the current formula manager
            if k not in self.manager:
                raise PysmtTypeError(
                    "Key %d does not belong to the Formula Manager." % i)
            if v not in self.manager:
                raise PysmtTypeError(
                    "Value %d does not belong to the Formula Manager." % i)

        for i, (k, v) in enumerate(interpretations.items()):
            # Check that interpretations are terms
            if not k.is_symbol() or k.is_term():
                raise PysmtTypeError(
                    "Only function symbols should be provided as interpretation"
                    " keys. Non-function '%s' found." % k)
            if not isinstance(v, FunctionInterpretation):
                raise PysmtTypeError(
                    "Only FunctionInterpretation objects should be provided as "
                    "interpretation values. Object '%s' of type %s "
                    "found." % (v, type(v)))
            # Check that interpretations belong to the current formula manager
            if k not in self.manager:
                raise PysmtTypeError(
                    "Key %d does not belong to the Formula Manager." % i)

        res = self.walk(formula, substitutions=subs,
                        interpretations=interpretations)
        return res
def substitute ( self , formula , subs = None , interpretations = None ) : # Check that formula is a term if not formula . is_term ( ) : raise PysmtTypeError ( "substitute() can only be used on terms." ) if subs is None : subs = { } if interpretations is None : interpretations = { } for i , ( k , v ) in enumerate ( subs . items ( ) ) : # Check that substitutions are terms if not k . is_term ( ) : raise PysmtTypeError ( "Only terms should be provided as substitutions." + " Non-term '%s' found." % k ) if not v . is_term ( ) : raise PysmtTypeError ( "Only terms should be provided as substitutions." + " Non-term '%s' found." % v ) # Check that substitutions belong to the current formula manager if k not in self . manager : raise PysmtTypeError ( "Key %d does not belong to the Formula Manager." % i ) if v not in self . manager : raise PysmtTypeError ( "Value %d does not belong to the Formula Manager." % i ) for i , ( k , v ) in enumerate ( interpretations . items ( ) ) : # Check that interpretations are terms if not k . is_symbol ( ) or k . is_term ( ) : raise PysmtTypeError ( "Only function symbols should be provided as interpretation" " keys. Non-function '%s' found." % k ) if not isinstance ( v , FunctionInterpretation ) : raise PysmtTypeError ( "Only FunctionInterpretation objects should be provided as " "interpretation values. Object '%s' of type %s " "found." % ( v , type ( v ) ) ) # Check that interpretations belong to the current formula manager if k not in self . manager : raise PysmtTypeError ( "Key %d does not belong to the Formula Manager." % i ) res = self . walk ( formula , substitutions = subs , interpretations = interpretations ) return res