# Path: calculus/symbol.py
# class Symbol:
# class StringSymbol(Symbol):
#   def __init__(self, type):
#   def _generate_id(self):
#   def __eq__(self, other):
#   def __ne__(self):
#   def __hash__(self):
#   def __repr__(self):
#   def __init__(self, s, type, infix = None):
#   def __repr__(self):
# 
# Path: ui/render/text/primitives.py
# def newTextStack(color, s):
# def wrapVariableInfix(s):
# def holds():
# def surroundWithNot(s):
# def solidSquare(color, widths):
# def identical(covariant):
# def iff():
# def _dimension_for_variance(covariant):
# def _dual_dimension(dimension):
# def andDivider(covariant):
#   def f(length):
# def orDivider(covariant):
#   def f(length):
# def quantifierDivider(covariant, length):
# def divider(color, dimension, length, width, special_character = None):
# 
# Path: ui/render/text/colors.py
# def productPairsColor(i):
# def exponentialColor(isAlways):
# 
# Path: ui/render/text/distances.py

# 
# Path: ui/stack/stack.py
# def stack(self, dimension, other, spacing = 0):
#   if self._backend.stacks():
#     offset = [0 for i in range(self.dimension())]
#     offset[dimension] = spacing
#     coords = list(self._coords)
#     for i in range(len(coords)):
#       if i == dimension:
#         coords[i] += spacing + other._coords[i]
#       else:
#         coords[i] = max(coords[i], other._coords[i])
#     return Stack(coords, self._backend.stack(dimension, other._backend.shift(offset)))
#   else:
#     offset = [0 for i in range(self.dimension())]
#     offset[dimension] = self.widths()[dimension] + spacing
#     return self.below(other.shift(offset))


from sets import Set
from calculus import symbol
from ui.render.text import primitives, colors, distances
from ui.stack import stack
      return Set([self.symbol]).union(self.variable.applied_variables())
    else:
      return self.variable.applied_variables()
  def __ne__(self, other):
    return not (self == other)
  def __repr__(self):
    return "<: " + repr(self.variable) + " :: " + repr(self.symbol) + " :>"
  def updateVariables(self):
    return ApplySymbolVariable(variable = self.variable.updateVariables(), symbol = self.symbol)
  def substituteVariable(self, a, b):
    return ApplySymbolVariable(variable = self.variable.substituteVariable(a, b), symbol = self.symbol)
  def freeVariables(self):
    return self.variable.freeVariables()

  def render(self):
    symbolBackgroundColor, variableBackgroundColor = colors_for_symbol(self.symbol)
    if isinstance(self.symbol, Variable):
      if self.symbol.infix is not None:
        return primitives.wrapVariableInfix(renderInfix(self.variable, self.symbol.infix, self.symbol))
      else:
        symbolStack = self.symbol.render()
        return self.variable.render().stack(0, primitives.dot).stack(0, symbolStack)
    else:
      symbolStack = renderSymbol(self.symbol)
      return self.variable.render().stack(0, primitives.dot).stack(0, symbolStack)

def colors_for_symbol(symbol):
  if isinstance(symbol, Variable):
    return (colors.callSymbolBackgroundColor, colors.callVariableBackgroundColor)
  else:

# Path: calculus/symbol.py
# class Symbol:
# class StringSymbol(Symbol):
#   def __init__(self, type):
#   def _generate_id(self):
#   def __eq__(self, other):
#   def __ne__(self):
#   def __hash__(self):
#   def __repr__(self):
#   def __init__(self, s, type, infix = None):
#   def __repr__(self):
# 
# Path: ui/render/text/primitives.py
# def newTextStack(color, s):
# def wrapVariableInfix(s):
# def holds():
# def surroundWithNot(s):
# def solidSquare(color, widths):
# def identical(covariant):
# def iff():
# def _dimension_for_variance(covariant):
# def _dual_dimension(dimension):
# def andDivider(covariant):
#   def f(length):
# def orDivider(covariant):
#   def f(length):
# def quantifierDivider(covariant, length):
# def divider(color, dimension, length, width, special_character = None):
# 
# Path: ui/render/text/colors.py
# def productPairsColor(i):
# def exponentialColor(isAlways):
# 
# Path: ui/render/text/distances.py

# 
# Path: ui/stack/stack.py
# def stack(self, dimension, other, spacing = 0):
#   if self._backend.stacks():
#     offset = [0 for i in range(self.dimension())]
#     offset[dimension] = spacing
#     coords = list(self._coords)
#     for i in range(len(coords)):
#       if i == dimension:
#         coords[i] += spacing + other._coords[i]
#       else:
#         coords[i] = max(coords[i], other._coords[i])
#     return Stack(coords, self._backend.stack(dimension, other._backend.shift(offset)))
#   else:
#     offset = [0 for i in range(self.dimension())]
#     offset[dimension] = self.widths()[dimension] + spacing
#     return self.below(other.shift(offset))


# Path: calculus/variable.py
from sets import Set
from calculus import symbol
from ui.render.text import primitives, colors, distances
from ui.stack import stack

      return Set([self.symbol]).union(self.variable.applied_variables())
    else:
      return self.variable.applied_variables()
  def __ne__(self, other):
    return not (self == other)
  def __repr__(self):
    return "<: " + repr(self.variable) + " :: " + repr(self.symbol) + " :>"
  def updateVariables(self):
    return ApplySymbolVariable(variable = self.variable.updateVariables(), symbol = self.symbol)
  def substituteVariable(self, a, b):
    return ApplySymbolVariable(variable = self.variable.substituteVariable(a, b), symbol = self.symbol)
  def freeVariables(self):
    return self.variable.freeVariables()

  def render(self):
    symbolBackgroundColor, variableBackgroundColor = colors_for_symbol(self.symbol)
    if isinstance(self.symbol, Variable):
      if self.symbol.infix is not None:
        return primitives.wrapVariableInfix(renderInfix(self.variable, self.symbol.infix, self.symbol))
      else:
        symbolStack = self.symbol.render()
        return self.variable.render().stack(0, primitives.dot).stack(0, symbolStack)
    else:
      symbolStack = renderSymbol(self.symbol)
      return self.variable.render().stack(0, primitives.dot).stack(0, symbolStack)

def colors_for_symbol(symbol):
  if isinstance(symbol, Variable):
    return (colors.callSymbolBackgroundColor, colors.callVariableBackgroundColor)
  else:

    return (colors.symbolBackgroundColor, colors.symbolForegroundColor)