Attachment 'cur_coerce_diagram.sage'

Download

   1 def brute_force_rings(args):
   2     """
   3     Just try and create all sorts of rings, with the given arguments as constructors
   4     """
   5     for name, obj in sage.rings.all.__dict__.iteritems():
   6         if obj is farey or obj is ComplexNumber:
   7             continue
   8         for arg in args:
   9             try:
  10                 R = obj(*arg)
  11                 if is_Ring(R):
  12                     yield R
  13             except Exception, e:
  14                 pass
  15                 
  16 def rand_elm(R):
  17     try:
  18         return R.random_element()
  19     except:
  20         try:
  21             return R.random_element(10)
  22         except:
  23             return R.random_element(-10, 10)
  24 
  25 
  26 def coercion_graph(objs):
  27     G = DiGraph()
  28     for obj in objs:
  29         G.add_vertex(obj)
  30     for A in objs:
  31         for B in objs:
  32             try:
  33                 a, b = canonical_coercion(rand_elm(A), rand_elm(B))
  34                 if a.parent() != A:
  35                     G.add_arc(A, a.parent())
  36                 if b.parent() != B:
  37                     G.add_arc(B, b.parent())
  38             except:
  39                 pass
  40     return G
  41 
  42 # The functions below are kind of brute-force, but work for small graphs. 
  43 
  44 def find_longest_path(G, a, b, max_len=None):
  45     if a is b:
  46         return []
  47     elif max_len is None:
  48         max_len = len(G)-1
  49     elif max_len < 1:
  50         return None
  51     all = []
  52     for out in G.outgoing_arc_iterator(a):
  53         s = out[1]
  54         if s is b:
  55             all.append([b])
  56         else:
  57             p = find_longest_path(G, s, b, max_len-1)
  58             if p:
  59                 all.append([s] + p)
  60     if len(all) == 0:
  61         return None
  62     else:
  63         m = max([len(p) for p in all])
  64         for p in all:
  65             if len(p) == m:
  66                 return p
  67                 
  68 # Performs a kind of inverse to transative closure. 
  69                 
  70 def remove_redundant(G):
  71     """
  72     Performs a kind of inverse to transative closure 
  73     on a directed acyclic graph.
  74     """
  75     G = G.copy()
  76     for top in G.vertex_iterator():
  77         if len(G.incoming_arcs([top])) == 0:
  78             dists = {}
  79             for v in G.vertex_iterator():
  80                 p = find_longest_path(G, top, v)
  81                 if p is None:
  82                     dists[v] = -1
  83                 else:
  84                     dists[v] = len(p)
  85             for e in G.arcs():
  86                 if dists[e[1]] - dists[e[0]] > 1 and dists[e[0]] != -1:
  87                     p = find_longest_path(G, e[0], e[1], dists[e[1]] - dists[e[0]])
  88                     if len(p) != 1:
  89                         G.delete_arc(e[0], e[1])
  90     return G
  91     
  92 
  93 def dot(G):
  94     s = "digraph" if G.is_directed() else "graph"
  95     s += ' "%r" {\n'%G
  96     for v in G.vertex_iterator():
  97         s += '  "%r"\n'%v
  98     if G.is_directed():
  99         for e in G.arc_iterator():
 100             s += '  "%r" -> "%r"\n'%(e[0], e[1])
 101     else:
 102         for e in G.edge_iterator():
 103             s += '  "%r" -> "%r"\n'%(e[0], e[1])
 104     s += "}"
 105     return s
 106         
 107 ################
 108 
 109 args = [(), (7,), (7^3,), (7^3, 'a'), (ZZ, 'x')]
 110 print "Constructing rings"
 111 all = set(brute_force_rings(args))
 112 # all.remove(RR) # gets messy
 113 
 114 print len(all), "unique rings"
 115 print "Creating coercion graph..."
 116 G = coercion_graph(all);
 117 G.save("coerce")
 118 G.plot().save("coerce.png")
 119 f = open("coerce.dot", "w")
 120 f.write(dot(G))
 121 f.close()
 122 
 123 print "Simplifying..."
 124 GG = remove_redundant(G)
 125 G.save("coerce_simple")
 126 G.plot().save("coerce_simple.png")
 127 f = open("coerce_simple.dot", "w")
 128 f.write(dot(GG))
 129 f.close()

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2007-06-22 02:15:33, 256.7 KB) [[attachment:cur_coerce.png]]
  • [get | view] (2007-06-22 02:15:44, 3.4 KB) [[attachment:cur_coerce_diagram.sage]]
  • [get | view] (2007-12-16 22:01:56, 0.2 KB) [[attachment:latex_04beb4dfed40bda7cd6aeaad694729e2ec3344c6_p1.png]]
  • [get | view] (2007-12-16 22:01:55, 0.8 KB) [[attachment:latex_0b81d91e2b2ac08eb088755f1280cd2ef89627ed_p1.png]]
  • [get | view] (2007-12-16 22:01:57, 0.2 KB) [[attachment:latex_11c1e42143a0b29fd608cb0a0c4847c3a6f4ef04_p1.png]]
  • [get | view] (2007-12-16 22:01:54, 0.2 KB) [[attachment:latex_1c97bcefec265e135b66558b1064cd512f158bc4_p1.png]]
  • [get | view] (2007-12-16 22:01:56, 0.3 KB) [[attachment:latex_1d25f51d8f75e4836d6109e5da1ee1a9547cf793_p1.png]]
  • [get | view] (2007-12-16 22:01:56, 0.3 KB) [[attachment:latex_1e00f059b7edbd3719e6b0b6e0fdcaceb3703984_p1.png]]
  • [get | view] (2007-12-16 22:01:56, 0.3 KB) [[attachment:latex_24783f2de6052870ce65b65b9d2be8a9dec78ced_p1.png]]
  • [get | view] (2007-12-16 22:01:56, 0.7 KB) [[attachment:latex_264b3801ddfc0895e6bc321e0b138d16e7077242_p1.png]]
  • [get | view] (2007-12-16 22:01:55, 0.2 KB) [[attachment:latex_274d0e826838773c8ca4a25ab2805c3e4baeea3b_p1.png]]
  • [get | view] (2007-12-16 22:01:54, 0.7 KB) [[attachment:latex_2dd73b34a1613eef9335834f63ac5e4f11981136_p1.png]]
  • [get | view] (2007-12-16 22:01:57, 0.3 KB) [[attachment:latex_3018b69150f99b3c537e2a1215717412d8cbf048_p1.png]]
  • [get | view] (2007-12-16 22:01:55, 0.5 KB) [[attachment:latex_34e66804dcdc67850784a5f0d71922b2a1c98992_p1.png]]
  • [get | view] (2007-12-16 22:01:57, 0.2 KB) [[attachment:latex_37ae431d0d5a9eecdb4213b63c77c3935db5fccf_p1.png]]
  • [get | view] (2007-12-16 22:01:56, 0.9 KB) [[attachment:latex_3ae3dcef1aba49731c89ecc39b38be41aca1fa26_p1.png]]
  • [get | view] (2007-12-16 22:01:56, 0.4 KB) [[attachment:latex_425fb71847294c02d531e3435b383b41cc8febb9_p1.png]]
  • [get | view] (2007-12-16 22:01:54, 0.4 KB) [[attachment:latex_5756ec273de61a4969b6acb519ea3ed659942586_p1.png]]
  • [get | view] (2007-12-16 22:01:57, 0.3 KB) [[attachment:latex_5cfc4a0dc040caff3f34f95774d8f6981f15b90f_p1.png]]
  • [get | view] (2007-12-16 22:01:55, 0.3 KB) [[attachment:latex_63c3045b63a60c849f618d7fde3e5600fc213933_p1.png]]
  • [get | view] (2007-12-16 22:01:55, 0.2 KB) [[attachment:latex_8395778e56db294890a28a4233f0c38aabdc01e3_p1.png]]
  • [get | view] (2007-12-16 22:01:57, 0.4 KB) [[attachment:latex_86c78bad6562254e6a1949040127c0ff72e0c2fb_p1.png]]
  • [get | view] (2007-12-16 22:01:54, 0.2 KB) [[attachment:latex_96522269cb1f7f1b13dab746b114e0191b36f688_p1.png]]
  • [get | view] (2007-12-16 22:01:54, 0.5 KB) [[attachment:latex_990ee97f2a97fa440a741c513616149e3c029bda_p1.png]]
  • [get | view] (2007-12-16 22:01:56, 0.9 KB) [[attachment:latex_9bfd985421066825118b0368c8089481c6271c13_p1.png]]
  • [get | view] (2007-12-16 22:01:54, 0.6 KB) [[attachment:latex_ab0109e80c513bc9ae9a8b405ad5abed7300590f_p1.png]]
  • [get | view] (2007-12-16 22:01:56, 0.2 KB) [[attachment:latex_b1dfc546fd35599dca826e3fdbb0e49a3abbf430_p1.png]]
  • [get | view] (2007-12-16 22:01:54, 0.6 KB) [[attachment:latex_b3836391d684b5c57ff1c4b664f7af8d7ddca204_p1.png]]
  • [get | view] (2007-12-16 22:01:54, 0.4 KB) [[attachment:latex_b60edf03634ef59f40fa812cc6db7970905c536c_p1.png]]
  • [get | view] (2007-12-16 22:01:54, 0.2 KB) [[attachment:latex_b6fff43ea3ab1273379d045423ec9089fd87d937_p1.png]]
  • [get | view] (2007-12-16 22:01:55, 0.2 KB) [[attachment:latex_b8950ebb446762bdb8e8084f8b0914b7bc50b931_p1.png]]
  • [get | view] (2007-12-16 22:01:55, 0.4 KB) [[attachment:latex_ba787470d637475f7c06ed428b976198cb56395b_p1.png]]
  • [get | view] (2007-12-16 22:01:55, 0.5 KB) [[attachment:latex_c136f1340830dfc480ed6fae44ab722292636181_p1.png]]
  • [get | view] (2007-12-16 22:01:56, 0.3 KB) [[attachment:latex_c1eed1c6a067391033db136d8f6f6e3961547bd8_p1.png]]
  • [get | view] (2007-12-16 22:01:55, 0.8 KB) [[attachment:latex_c46b59e69ea7e83058497b2cc8145e9ac473626b_p1.png]]
  • [get | view] (2007-12-16 22:01:56, 0.2 KB) [[attachment:latex_ed45432016aa8f461445b268b596ea92edbcc79e_p1.png]]
  • [get | view] (2007-12-16 22:01:54, 0.6 KB) [[attachment:latex_f613919c911d992c2dffa84fd050288c9329de98_p1.png]]
  • [get | view] (2007-12-16 22:01:57, 0.5 KB) [[attachment:latex_fafe9829b2bd424810a33c3aaf9db93630707ac9_p1.png]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.