class_docstr: Replacer object to perform multiple pattern matching and subexpression
  replacements in SymPy expressions.
  
  Examples
  ========
  
  Example to construct a simple first degree equation solver:
  
  >>> from sympy.utilities.matchpy_connector import WildDot, Replacer
  >>> from sympy import Equality, Symbol
  >>> x = Symbol("x")
  >>> a_ = WildDot("a_", optional=1)
  >>> b_ = WildDot("b_", optional=0)
  
  The lines above have defined two wildcards, ``a_`` and ``b_``, the
  coefficients of the equation `a x + b = 0`. The optional values specified
  indicate which expression to return in case no match is found, they are
  necessary in equations like `a x = 0` and `x + b = 0`.
  
  Create two constraints to make sure that ``a_`` and ``b_`` will not match
  any expression containing ``x``:
  
  >>> from matchpy import CustomConstraint
  >>> free_x_a = CustomConstraint(lambda a_: not a_.has(x))
  >>> free_x_b = CustomConstraint(lambda b_: not b_.has(x))
  
  Now create the rule replacer with the constraints:
  
  >>> replacer = Replacer(common_constraints=[free_x_a, free_x_b])
  
  Add the matching rule:
  
  >>> replacer.add(Equality(a_*x + b_, 0), -b_/a_)
  
  Let's try it:
  
  >>> replacer.replace(Equality(3*x + 4, 0))
  -4/3
  
  Notice that it will not match equations expressed with other patterns:
  
  >>> eq = Equality(3*x, 4)
  >>> replacer.replace(eq)
  Eq(3*x, 4)
  
  In order to extend the matching patterns, define another one (we also need
  to clear the cache, because the previous result has already been memorized
  and the pattern matcher will not iterate again if given the same expression)
  
  >>> replacer.add(Equality(a_*x, b_), b_/a_)
  >>> replacer._matcher.clear()
  >>> replacer.replace(eq)
  4/3
class_docstr_tok: ["Replacer","object","to","perform","multiple","pattern","matching","and","subexpression","replacements","in","SymPy","expressions",".","Examples","========","Example","to","construct","a","simple","first","degree","equation","solver",":",">",">",">","from","sympy.utilities.matchpy_connector","import","WildDot",",","Replacer",">",">",">","from","sympy","import","Equality",",","Symbol",">",">",">","x","=","Symbol","(","``","x","''",")",">",">",">","a_","=","WildDot","(","``","a_","''",",","optional=1",")",">",">",">","b_","=","WildDot","(","``","b_","''",",","optional=0",")","The","lines","above","have","defined","two","wildcards",",","``","a_","``","and","``","b_","``",",","the","coefficients","of","the","equation","`","a","x","+","b","=","0","`",".","The","optional","values","specified","indicate","which","expression","to","return","in","case","no","match","is","found",",","they","are","necessary","in","equations","like","`","a","x","=","0","`","and","`","x","+","b","=","0","`",".","Create","two","constraints","to","make","sure","that","``","a_","``","and","``","b_","``","will","not","match","any","expression","containing","``","x","``",":",">",">",">","from","matchpy","import","CustomConstraint",">",">",">","free_x_a","=","CustomConstraint","(","lambda","a_",":","not","a_.has","(","x",")",")",">",">",">","free_x_b","=","CustomConstraint","(","lambda","b_",":","not","b_.has","(","x",")",")","Now","create","the","rule","replacer","with","the","constraints",":",">",">",">","replacer","=","Replacer","(","common_constraints=","[","free_x_a",",","free_x_b","]",")","Add","the","matching","rule",":",">",">",">","replacer.add","(","Equality","(","a_","*","x","+","b_",",","0",")",",","-b_\/a_",")","Let","'s","try","it",":",">",">",">","replacer.replace","(","Equality","(","3","*","x","+","4",",","0",")",")","-4\/3","Notice","that","it","will","not","match","equations","expressed","with","other","patterns",":",">",">",">","eq","=","Equality","(","3","*","x",",","4",")",">",">",">","replacer.replace","(","eq",")","Eq","(","3","*","x",",","4",")","In","order","to","extend","the","matching","patterns",",","define","another","one","(","we","also","need","to","clear","the","cache",",","because","the","previous","result","has","already","been","memorized","and","the","pattern","matcher","will","not","iterate","again","if","given","the","same","expression",")",">",">",">","replacer.add","(","Equality","(","a_","*","x",",","b_",")",",","b_\/a_",")",">",">",">","replacer._matcher.clear","(",")",">",">",">","replacer.replace","(","eq",")","4\/3"]
code: def add(
      self,
      expr: Expr,
      replacement,
      conditions_true: List[Expr] = [],
      conditions_nonfalse: List[Expr] = [],
      info: Any = None,
  ) -> None:
      expr = _sympify(expr)
      replacement = _sympify(replacement)
      constraints = self._common_constraint[:]
      constraint_conditions_true = [
          self._get_custom_constraint_true(cond)
          for cond in conditions_true
      ]
      constraint_conditions_nonfalse = [
          self._get_custom_constraint_nonfalse(cond)
          for cond in conditions_nonfalse
      ]
      constraints.extend(constraint_conditions_true)
      constraints.extend(constraint_conditions_nonfalse)
      pattern = matchpy.Pattern(expr, *constraints)
      if self._lambdify:
          lambda_str = f"lambda {', '.join((x.name for x in expr.atoms(_WildAbstract)))}: {_get_srepr(replacement)}"
          lambda_expr = self._get_lambda(lambda_str)
          replacement = lambda_expr
      else:
          self._wildcards.update(
              {str(i): i for i in expr.atoms(Wildcard)}
          )
      if self._info:
          replacement = ReplacementInfo(replacement, info)
      self._matcher.add(pattern, replacement)
  
imports: import re
  from typing import List, Callable, NamedTuple, Any, Dict
  from sympy.core.sympify import _sympify
  from sympy.external import import_module
  from sympy.functions import log, sin, cos, tan, cot, csc, sec, erf, gamma, uppergamma
  from sympy.functions.elementary.hyperbolic import acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch
  from sympy.functions.elementary.trigonometric import atan, acsc, asin, acot, acos, asec
  from sympy.functions.special.error_functions import fresnelc, fresnels, erfc, erfi, Ei
  from sympy.core.add import Add
  from sympy.core.basic import Basic
  from sympy.core.expr import Expr
  from sympy.core.mul import Mul
  from sympy.core.power import Pow
  from sympy.core.relational import Equality, Unequality
  from sympy.core.symbol import Symbol
  from sympy.functions.elementary.exponential import exp
  from sympy.integrals.integrals import Integral
  from sympy.printing.repr import srepr
  from sympy.utilities.decorator import doctest_depends_on
label_desc: Use image node_id 6 for calling the Replacer obj's underlying member method code with example usage: obj.add(expr, replacement, conditions_true, conditions_nonfalse, info) without return types