# 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
# Copyright (C) 2013 Korei Klein <korei.klein1@gmail.com>



class GeneralizedVariable:
  # Return an equivalent variable that is possibly simpler.
  def simplify(self):
    return self
  def render(self):
    raise Exception("Abstract superclass.")
  def applied_variables(self):
    raise Exception("Abstract superclass.")
  def relatedVariable(self):
    return StringVariable('z')

n_variables = 0
class Variable(GeneralizedVariable):
  def __init__(self):
    self._generate_id()

  def _generate_id(self):
    global n_variables
    self._id = n_variables
    n_variables += 1

  def updateVariables(self):
    return Variable()

  def __eq__(self, other):
    return self.__class__ == other.__class__ and self._id == other._id

# 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

# Copyright (C) 2013 Korei Klein <korei.klein1@gmail.com>



class GeneralizedVariable:
  # Return an equivalent variable that is possibly simpler.
  def simplify(self):
    return self
  def render(self):
    raise Exception("Abstract superclass.")
  def applied_variables(self):
    raise Exception("Abstract superclass.")
  def relatedVariable(self):
    return StringVariable('z')

n_variables = 0
class Variable(GeneralizedVariable):
  def __init__(self):
    self._generate_id()

  def _generate_id(self):
    global n_variables
    self._id = n_variables
    n_variables += 1

  def updateVariables(self):
    return Variable()

  def __eq__(self, other):
    return self.__class__ == other.__class__ and self._id == other._id

  def __ne__(self, other):