def __init__(self, number_field, names=None): r""" Create a Galois group. EXAMPLES:: sage: QuadraticField(-23,'a').galois_group() Galois group of Number Field in a with defining polynomial x^2 + 23 sage: NumberField(x^3 - 2, 'b').galois_group() Traceback (most recent call last): ... TypeError: You must specify the name of the generator. sage: NumberField(x^3 - 2, 'b').galois_group(names="c") Galois group of Galois closure in c of Number Field in b with defining polynomial x^3 - 2 """ self._number_field = number_field if not number_field.is_galois(): self._galois_closure, self._gc_map = number_field.galois_closure(names=names, map=True) else: self._galois_closure, self._gc_map = (number_field, number_field.hom(number_field.gen(), number_field)) self._pari_gc = self._galois_closure.__pari__() g = self._pari_gc.galoisinit() self._pari_data = g # Sort the vector of permutations using .list() as key to avoid errors # from using comparison operators on non-scalar PARI objects. PermutationGroup_generic.__init__(self, sorted(g[6], key=lambda x: x.list())) # PARI computes all the elements of self anyway, so we might as well store them self._elts = sorted([self(x, check=False) for x in g[5]])
def __init__(self, ambient, elts): r""" Create a subgroup of a Galois group with the given elements. It is generally better to use the subgroup() method of the parent group. EXAMPLES:: sage: from sage.rings.number_field.galois_group import GaloisGroup_subgroup sage: G = NumberField(x^3 - x - 1, 'a').galois_closure('b').galois_group() sage: GaloisGroup_subgroup( G, [ G(1), G([(1,2,3),(4,5,6)]), G([(1,3,2),(4,6,5)])]) Subgroup [(), (1,2,3)(4,5,6), (1,3,2)(4,6,5)] of Galois group of Number Field in b with defining polynomial x^6 - 6*x^4 + 9*x^2 + 23 TESTS: Check that :trac:`17664` is fixed:: sage: L.<c> = QuadraticField(-1) sage: P = L.primes_above(5)[0] sage: G = L.galois_group() sage: H = G.decomposition_group(P) sage: H.domain() {1, 2} sage: G.artin_symbol(P) () """ # XXX This should be fixed so that this can use GaloisGroup_v2.__init__ PermutationGroup_generic.__init__(self, elts, canonicalize=True, domain=ambient.domain()) self._ambient = ambient self._number_field = ambient.number_field() self._galois_closure = ambient._galois_closure self._pari_data = ambient._pari_data self._pari_gc = ambient._pari_gc self._gc_map = ambient._gc_map self._elts = elts
def __init__(self, cartan_type): """ Construct this Coxeter group as a Sage permutation group, by fetching the permutation representation of the generators from Chevie's database. TESTS:: sage: from sage.combinat.root_system.coxeter_group import CoxeterGroupAsPermutationGroup sage: W = CoxeterGroupAsPermutationGroup(CartanType(["H",3])) # optional - chevie sage: TestSuite(W).run() # optional - chevie """ assert cartan_type.is_finite() assert cartan_type.is_irreducible() self._semi_simple_rank = cartan_type.n from sage.interfaces.gap3 import gap3 gap3._start() gap3.load_package("chevie") self._gap_group = gap3('CoxeterGroup("%s",%s)'%(cartan_type.letter,cartan_type.n)) # Following #9032, x.N is an alias for x.numerical_approx in every Sage object ... N = self._gap_group.__getattr__("N").sage() generators = [str(x) for x in self._gap_group.generators] self._is_positive_root = [None] + [ True ] * N + [False]*N PermutationGroup_generic.__init__(self, gens = generators, category = Category.join([FinitePermutationGroups(), FiniteCoxeterGroups()]))
def __init__(self, cartan_type, prefix): """ Initialize ``self``. EXAMPLES:: sage: W = WeylGroup(['F',4], implementation="permutation") sage: TestSuite(W).run() """ self._cartan_type = cartan_type self._index_set = cartan_type.index_set() self._index_set_inverse = { ii: i for i, ii in enumerate(cartan_type.index_set()) } self._reflection_representation = None self._prefix = prefix #from sage.libs.all import libgap Q = cartan_type.root_system().root_lattice() Phi = list(Q.positive_roots()) + [-x for x in Q.positive_roots()] p = [[Phi.index(x.weyl_action([i])) + 1 for x in Phi] for i in self._cartan_type.index_set()] cat = FiniteWeylGroups() if self._cartan_type.is_irreducible(): cat = cat.Irreducible() cat = (cat, PermutationGroups().Finite()) PermutationGroup_generic.__init__(self, gens=p, canonicalize=False, category=cat)
def __init__(self, number_field, names=None): r""" Create a Galois group. EXAMPLES:: sage: QuadraticField(-23,'a').galois_group() Galois group of Number Field in a with defining polynomial x^2 + 23 sage: NumberField(x^3 - 2, 'b').galois_group() Traceback (most recent call last): ... TypeError: You must specify the name of the generator. sage: NumberField(x^3 - 2, 'b').galois_group(names="c") Galois group of Galois closure in c of Number Field in b with defining polynomial x^3 - 2 """ from sage.groups.perm_gps.permgroup_element import PermutationGroupElement self._number_field = number_field if not number_field.is_galois(): self._galois_closure, self._gc_map = number_field.galois_closure(names=names, map=True) else: self._galois_closure, self._gc_map = (number_field, number_field.hom(number_field.gen(), number_field)) self._pari_gc = self._galois_closure._pari_() g = self._pari_gc.galoisinit() self._pari_data = g PermutationGroup_generic.__init__(self, sorted(g[6])) # PARI computes all the elements of self anyway, so we might as well store them self._elts = sorted([self(x, check=False) for x in g[5]])
def __init__(self, ambient, elts): r""" Create a subgroup of a Galois group with the given elements. It is generally better to use the subgroup() method of the parent group. EXAMPLE:: sage: from sage.rings.number_field.galois_group import GaloisGroup_subgroup sage: G = NumberField(x^3 - x - 1, 'a').galois_closure('b').galois_group() sage: GaloisGroup_subgroup( G, [ G(1), G([(1,2,3),(4,5,6)]), G([(1,3,2),(4,6,5)])]) Subgroup [(), (1,2,3)(4,5,6), (1,3,2)(4,6,5)] of Galois group of Number Field in b with defining polynomial x^6 - 6*x^4 + 9*x^2 + 23 TESTS: Check that :trac:`17664` is fixed:: sage: L.<c> = QuadraticField(-1) sage: P = L.primes_above(5)[0] sage: G = L.galois_group() sage: H = G.decomposition_group(P) sage: H.domain() {1, 2} sage: G.artin_symbol(P) () """ #XXX: This should be fixed so that this can use GaloisGroup_v2.__init__ PermutationGroup_generic.__init__(self, elts, canonicalize=True, domain=ambient.domain()) self._ambient = ambient self._number_field = ambient.number_field() self._galois_closure = ambient._galois_closure self._pari_data = ambient._pari_data self._pari_gc = ambient._pari_gc self._gc_map = ambient._gc_map self._elts = elts
def __init__(self, number_field, names=None): r""" Create a Galois group. EXAMPLES:: sage: QuadraticField(-23,'a').galois_group() Galois group of Number Field in a with defining polynomial x^2 + 23 sage: NumberField(x^3 - 2, 'b').galois_group() Traceback (most recent call last): ... TypeError: You must specify the name of the generator. sage: NumberField(x^3 - 2, 'b').galois_group(names="c") Galois group of Galois closure in c of Number Field in b with defining polynomial x^3 - 2 """ from sage.groups.perm_gps.permgroup_element import PermutationGroupElement self._number_field = number_field if not number_field.is_galois(): self._galois_closure, self._gc_map = number_field.galois_closure(names=names, map=True) else: self._galois_closure, self._gc_map = (number_field, number_field.hom(number_field.gen(), number_field)) self._pari_gc = self._galois_closure._pari_() g = self._pari_gc.galoisinit() self._pari_data = g # Sort the vector of permutations using cmp() to avoid errors # from using comparison operators on non-scalar PARI objects. PermutationGroup_generic.__init__(self, sorted(g[6], cmp=cmp)) # PARI computes all the elements of self anyway, so we might as well store them self._elts = sorted([self(x, check=False) for x in g[5]])
def __init__(self, cartan_type): """ Construct this Coxeter group as a Sage permutation group, by fetching the permutation representation of the generators from Chevie's database. TESTS:: sage: from sage.combinat.root_system.coxeter_group import CoxeterGroupAsPermutationGroup sage: W = CoxeterGroupAsPermutationGroup(CartanType(["H",3])) # optional - chevie sage: TestSuite(W).run() # optional - chevie """ assert cartan_type.is_finite() assert cartan_type.is_irreducible() self._semi_simple_rank = cartan_type.n from sage.interfaces.gap3 import gap3 gap3._start() gap3.load_package("chevie") self._gap_group = gap3('CoxeterGroup("%s",%s)' % (cartan_type.letter, cartan_type.n)) # Following #9032, x.N is an alias for x.numerical_approx in every Sage object ... N = self._gap_group.__getattr__("N").sage() generators = [str(x) for x in self._gap_group.generators] self._is_positive_root = [None] + [True] * N + [False] * N PermutationGroup_generic.__init__(self, gens=generators, category=Category.join([ FinitePermutationGroups(), FiniteCoxeterGroups() ]))
def __init__(self, number_field, names=None): r""" Create a Galois group. EXAMPLES:: sage: QuadraticField(-23,'a').galois_group() Galois group of Number Field in a with defining polynomial x^2 + 23 sage: NumberField(x^3 - 2, 'b').galois_group() Traceback (most recent call last): ... TypeError: You must specify the name of the generator. sage: NumberField(x^3 - 2, 'b').galois_group(names="c") Galois group of Galois closure in c of Number Field in b with defining polynomial x^3 - 2 TESTS:: sage: F.<z> = CyclotomicField(7) sage: G = F.galois_group() We test that a method inherited from PermutationGroup_generic returns the right type of element (see :trac:`133`):: sage: phi = G.random_element() sage: type(phi) is G.element_class True sage: phi(z) # random z^3 """ self._number_field = number_field if not number_field.is_galois(): self._galois_closure, self._gc_map = number_field.galois_closure( names=names, map=True) else: self._galois_closure, self._gc_map = (number_field, number_field.hom( number_field.gen(), number_field)) self._pari_gc = self._galois_closure.__pari__() g = self._pari_gc.galoisinit() self._pari_data = g # Sort the vector of permutations using .list() as key to avoid errors # from using comparison operators on non-scalar PARI objects. PermutationGroup_generic.__init__(self, sorted(g[6], key=lambda x: x.list())) # PARI computes all the elements of self anyway, so we might as well store them self._elts = sorted([self(x, check=False) for x in g[5]])
def __init__(self, number_field, names=None, elts=None, print_mode='roots'): self._number_field = number_field self._subgroup_class = GaloisGroup_subgroup_v3 #### self._non_galois_not_impl = False #### if not number_field.is_galois(): self._galois_closure, self._gc_map = number_field.galois_closure(names=names, map=True) else: self._galois_closure, self._gc_map = (number_field, number_field.hom(number_field.gen(), number_field)) self._pari_gc = self._galois_closure._pari_() g = self._pari_gc.galoisinit() self._pari_data = g self._print_mode = print_mode L = self._galois_closure _roots = tuple(r[0] for r in number_field.defining_polynomial().roots(L)) #_roots = [r[0] for r in number_field.defining_polynomial().roots(L)] _elem_dict = {} for gamma in g[5]: _elem_dict[gamma] = g.galoispermtopol(gamma) self._as_auts = L.Hom(L) #### #self._elts = [self._as_auts(L(_elem_dict[gamma])) for gamma in g[5]] #self._elts_dict = dict([[g[5][i], self._elts[i]] for i in range(len(g[5]))]) self._elts_dict = {} #### self._pari_dict = {} #### for gamma in g[5]: aut = self._as_auts(L(_elem_dict[gamma])) self._elts_dict[gamma] = aut self._pari_dict[aut] = gamma #self._elts_dict = dict([[gamma, self._as_auts(L(_elem_dict[gamma]))] for gamma in g[5]]) _gens = [] self._roots_to_homs_dict = {} #### self._homs_to_roots_dict = {} #### for gamma in g[6]: im_roots = [L(self._pari_gc.galoisapply(_elem_dict[gamma], r._pari_())) for r in _roots] _gens.append(im_roots) tup = tuple(im_roots) self._roots_to_homs_dict[repr(tup)] = self._elts_dict[gamma] self._homs_to_roots_dict[self._elts_dict[gamma]] = tup PermutationGroup_generic.__init__(self, _gens, domain=_roots) self._elts = [] #### for gamma in g[5]: self._elts.append(self._elts_dict[gamma]) if gamma not in g[6]: im_roots = tuple(L(self._pari_gc.galoisapply(_elem_dict[gamma], r._pari_())) for r in _roots) self._roots_to_homs_dict[repr(im_roots)] = self._elts_dict[gamma] self._homs_to_roots_dict[self._elts_dict[gamma]] = im_roots
def __init__(self, ambient, elts): r""" Return the subgroup of this Galois group generated by the given elements. It is generally better to use the :meth:`subgroup` method of the parent group. EXAMPLES:: sage: from sage.rings.number_field.galois_group import GaloisGroup_subgroup sage: G = NumberField(x^3 - x - 1, 'a').galois_closure('b').galois_group() sage: GaloisGroup_subgroup( G, [ G(1), G([(1,2,3),(4,5,6)]), G([(1,3,2),(4,6,5)])]) Subgroup [(), (1,2,3)(4,5,6), (1,3,2)(4,6,5)] of Galois group 6T2 ([3]2) with order 6 of x^6 - 6*x^4 + 9*x^2 + 23 TESTS: Check that :trac:`17664` is fixed:: sage: L.<c> = QuadraticField(-1) sage: P = L.primes_above(5)[0] sage: G = L.galois_group() sage: H = G.decomposition_group(P) sage: H.domain() {1, 2} sage: G.artin_symbol(P) () """ # XXX This should be fixed so that this can use GaloisGroup_v2.__init__ PermutationGroup_generic.__init__(self, elts, canonicalize=True, domain=ambient.domain()) self._ambient = ambient self._field = ambient.number_field() self._galois_closure = ambient._galois_closure self._pari_data = ambient._pari_data self._gc_map = ambient._gc_map self._default_algorithm = ambient._default_algorithm self._type = None # Backward compatibility self._elts = sorted(self.iteration())
def __init__(self, ambient, elts): r""" Create a subgroup of a Galois group with the given elements. It is generally better to use the subgroup() method of the parent group. EXAMPLE:: sage: from sage.rings.number_field.galois_group import GaloisGroup_subgroup sage: G = NumberField(x^3 - x - 1, 'a').galois_closure('b').galois_group() sage: GaloisGroup_subgroup( G, [ G(1), G([(1,2,3),(4,5,6)]), G([(1,3,2),(4,6,5)])]) Subgroup [(), (1,2,3)(4,5,6), (1,3,2)(4,6,5)] of Galois group of Number Field in b with defining polynomial x^6 - 6*x^4 + 9*x^2 + 23 """ #XXX: This should be fixed so that this can use GaloisGroup_v2.__init__ PermutationGroup_generic.__init__(self, elts, canonicalize=True) self._ambient = ambient self._number_field = ambient.number_field() self._galois_closure = ambient._galois_closure self._pari_data = ambient._pari_data self._pari_gc = ambient._pari_gc self._gc_map = ambient._gc_map self._elts = elts
def __init__(self, ambient, elts): r""" Create a subgroup of a Galois group with the given elements. It is generally better to use the subgroup() method of the parent group. EXAMPLE:: sage: from sage.rings.number_field.galois_group import GaloisGroup_subgroup sage: G = NumberField(x^3 - x - 1,'a').galois_closure('b').galois_group() sage: GaloisGroup_subgroup( G, [ G(1), G([(1,5,2),(3,4,6)]), G([(1,2,5),(3,6,4)])]) Subgroup [(), (1,5,2)(3,4,6), (1,2,5)(3,6,4)] of Galois group of Number Field in b with defining polynomial x^6 - 14*x^4 + 20*x^3 + 49*x^2 - 140*x + 307 """ #XXX: This should be fixed so that this can use GaloisGroup_v2.__init__ PermutationGroup_generic.__init__(self, elts, canonicalize = True) self._ambient = ambient self._number_field = ambient.number_field() self._galois_closure = ambient._galois_closure self._pari_data = ambient._pari_data self._pari_gc = ambient._pari_gc self._gc_map = ambient._gc_map self._elts = elts
def __init__(self, cartan_type, prefix): """ Initialize ``self``. EXAMPLES:: sage: W = WeylGroup(['F',4], implementation="permutation") sage: TestSuite(W).run() """ self._cartan_type = cartan_type self._index_set = cartan_type.index_set() self._index_set_inverse = {ii: i for i,ii in enumerate(cartan_type.index_set())} self._reflection_representation = None self._prefix = prefix #from sage.libs.all import libgap Q = cartan_type.root_system().root_lattice() Phi = list(Q.positive_roots()) + [-x for x in Q.positive_roots()] p = [[Phi.index(x.weyl_action([i]))+1 for x in Phi] for i in self._cartan_type.index_set()] cat = FiniteWeylGroups() if self._cartan_type.is_irreducible(): cat = cat.Irreducible() cat = (cat, PermutationGroups().Finite()) PermutationGroup_generic.__init__(self, gens=p, canonicalize=False, category=cat)