parameters: (state, order_relations=())
return_statement: return result
docstring: state is an ivy_interp.State with a .universe
  
      result is a dictionary mapping universe constant names to prettier
      names that should be used for displaying to the user
docstring_summary: state is an ivy_interp.State with a .universe
docstring_tokens: state is an ivy_interp . State with a . universe
function: def get_structure_renaming(state, order_relations=()):
      """
      state is an ivy_interp.State with a .universe
  
      result is a dictionary mapping universe constant names to prettier
      names that should be used for displaying to the user
      """
      from ivy_utils import topological_sort
  
      order_relations = frozenset(order_relations)
  
      # add node_info results for universe elements
      elements = list(set([uc for s in state.universe for uc in state.universe[s]]))
  
      # name according to topological sort
      # TODO: make this not specific to leader example
      state_formula = state.clauses.to_formula()
      assert type(state_formula) is And
      order = []
      for lit in state_formula:
          if (type(lit) is Apply and
              lit.func.sort.arity == 2 and
              lit.func.sort.domain[0] == lit.func.sort.domain[1] and
              lit.func.sort.range == Boolean and
              lit.func.name in order_relations):
              order.append(lit.terms)
      elements = topological_sort(elements, order, lambda c: c.name)
  
      result = dict()
      count = defaultdict(int)
      for c in elements:
          prefix = str(c.sort).lower()
          result[c.name] = prefix + str(count[prefix])
          count[prefix] += 1
  
      return result
function_tokens: def get_structure_renaming ( state , order_relations = ( ) ) : from ivy_utils import topological_sort order_relations = frozenset ( order_relations ) # add node_info results for universe elements elements = list ( set ( [ uc for s in state . universe for uc in state . universe [ s ] ] ) ) # name according to topological sort # TODO: make this not specific to leader example state_formula = state . clauses . to_formula ( ) assert type ( state_formula ) is And order = [ ] for lit in state_formula : if ( type ( lit ) is Apply and lit . func . sort . arity == 2 and lit . func . sort . domain [ 0 ] == lit . func . sort . domain [ 1 ] and lit . func . sort . range == Boolean and lit . func . name in order_relations ) : order . append ( lit . terms ) elements = topological_sort ( elements , order , lambda c : c . name ) result = dict ( ) count = defaultdict ( int ) for c in elements : prefix = str ( c . sort ) . lower ( ) result [ c . name ] = prefix + str ( count [ prefix ] ) count [ prefix ] += 1 return result