oops, here's the code! I keep getting server erros when trying to attach as a file, so I'm just including the text of the code file below:
class GroupAction(Parent): def __init__(self, G, S, phi): #phi a group action G\times S \rightarrow S self.phi=phi self.G=G self.S=S def __repr__(self): return "Action of "+self.G.__repr__()+" on the set "+self.S.__repr__() def action(self, g, s): """ Gives the action of g on s. """ return self.phi(g,s) def group(self): """ Group which acts. """ return self.G def gset(self): """ Set on which the group acts. """ return self.S def action_function(self): """ Function from `G\times S \rightarrow S`. """ return self.phi def check_action(self, g, h, s): """ Checks whether g(hs)=(gh)s. """ return self.phi(g*h,s)==self.phi(g,self.phi(h,s)) def check_action_full(self, gens=None, contragradiant=False): """ Checks that this is actually a group action using a generating set for the group acting on the full set. """ assert self.S.is_finite(), 'Cannot check group action on an infinite set.' if gens==None: #Should check if g has gens implemented. gens=self.group().gens() for g in gens: for h in gens: for s in S: if contragradiant: if not self.phi(g*h,s)==self.phi(g,self.phi(h,s)): stringy=g.__repr__()+', '+h.__repr__()+' '+s.__repr__() assert False, 'Action fails on '+stringy else: if not self.phi(h*g,s)==self.phi(g,self.phi(h,s)): stringy=g.__repr__()+', '+h.__repr__()+' '+s.__repr__() assert False, 'Action fails on '+stringy return True def orbit(self, s): return Set([self.action(g,s) for g in self.group()]) def is_transitive(self): if len(self.gset())==0: return True s=self.gset()[0] return orbit(s)==Set(self.gset()) def twist(self, endomorphism): """ Twists this representation by an endomorphism of the group. """ phi=self.action_function() kappa=lambda g,s: phi( endomorphism(g), s) return GroupAction(self.G, self.S, kappa) def character(self): """ Count fixed points for conjugacy class representatives. """ c=[] for g in self.G.conjugacy_classes_representatives(): fix=0 for s in self.S: if self.action(g,s)==s: fix+=1 c.append(fix) return c def cayley_graph(self, gens=None): """ Builds a cayley graph of the group action, using the specified generating set. """ assert self.S.is_finite(), 'Cannot check group action on an infinite set.' if gens==None: #Should check if g has gens implemented. gens=self.group().gens() G=DiGraph() for g in gens: for s in self.gset(): G.add_edge( s, self.action(g,s) ) return G def product_action(self, B): """ Given a second group action B with the same group and set T, generates the product group action of self and B. """ assert self.group()==B.group(), 'Actions need to have same group acting.' T=B.gset() U=CartesianProduct(self.gset(),T) kappa=lambda g, u: U( [self.action_function()(g,u[0]), B.action(g,u[1])] ) return GroupAction(G,U,kappa) """ #Example 1: Usual symmetric group action. sage: G=SymmetricGroup(4) sage: S=Set([1,2,3,4]) sage: phi = lambda g,s: g(s) sage: A=GroupAction(G,S,phi) sage: A.character() [4, 2, 0, 1, 0] #Example 2: Symmetric group acting on a set. sage: rho=lambda g,s: Set([phi(g,t) for t in s]) sage: T=Subsets(S,2) sage: B=GroupAction(G,T,rho) sage: B.character() [6, 2, 2, 0, 0] #Example 3: Product action. sage: C=A.product_action(B) sage: C.character() [24, 4, 0, 0, 0] #Example 4: Twist by an automorphism. sage: a=G.an_element()^2 sage: ai=a.inverse() sage: auto=lambda g: a*g*ai sage: At=A.twist(auto) sage: y=G.simple_reflection(1) sage: [A.action(y,s) for s in S] [2, 1, 3, 4] sage: [At.action(y,s) for s in S] [1, 2, 4, 3] """ -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.