Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Fixing some documentation, moving code up to sage.groups.galois_group
Browse files Browse the repository at this point in the history
  • Loading branch information
roed314 committed Mar 3, 2021
1 parent 14c1448 commit d5b9025
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 40 deletions.
101 changes: 86 additions & 15 deletions src/sage/groups/galois_group.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
r"""
Galois groups of field extensions
AUTHORS:
Expand All @@ -15,7 +15,7 @@
from functools import wraps

def _alg_key(self, algorithm=None, recompute=False):
"""
r"""
Return a key for use in cached_method calls.
If recompute is false, will cache using ``None`` as the key, so no recomputation will be done.
Expand All @@ -36,7 +36,7 @@ def _alg_key(self, algorithm=None, recompute=False):
return algorithm

class GaloisGroup(PermutationGroup_generic):
"""
r"""
The group of automorphisms of a Galois closure of a given field.
INPUT:
Expand All @@ -50,6 +50,14 @@ class GaloisGroup(PermutationGroup_generic):
of the original extension). The default value may vary based on the type of field.
"""
def __init__(self, field, algorithm=None, names=None, gc_numbering=False):
r"""
EXAMPLES::
sage: R.<x> = ZZ[]
sage: K.<a> = NumberField(x^3 + 2*x + 2)
sage: G = K.galois_group()
sage: TestSuite(G).run()
"""
self._field = field
self._default_algorithm = algorithm
self._base = field.base_field()
Expand All @@ -66,8 +74,24 @@ def __init__(self, field, algorithm=None, names=None, gc_numbering=False):
# Instead, the relevant attributes are computed lazily
super(PermutationGroup_generic, self).__init__(category=category)

def _get_algorithm(self, algorithm):
def _repr_(self):
"""
String representation of this Galois group
EXAMPLES::
sage: from sage.groups.galois_group import GaloisGroup
sage: R.<x> = ZZ[]
sage: K.<a> = NumberField(x^3 + 2*x + 2)
sage: G = K.galois_group()
sage: GaloisGroup._repr_(G)
'Galois group of x^3 + 2*x + 2'
"""
f = self._field.defining_polynomial()
return "Galois group of %s" % f

def _get_algorithm(self, algorithm):
r"""
Allows overriding the default algorithm specified at object creation.
EXAMPLES::
Expand All @@ -87,13 +111,15 @@ def _get_algorithm(self, algorithm):
# methods (taking algorithm and recompute as arguments):
# * transitive_number
# * order
# * _element_constructor_ -- for creating elements

# lazy_attributes
# * _gcdata -- a pair, the Galois closure and an embedding of the top field into it

# * _gens -- the list of generators of this group, as elements. This is not computed during __init__ for speed
# * _elts -- the list of all elements of this group.

def top_field(self):
"""
r"""
Return the larger of the two fields in the extension defining this Galois group.
Note that this field may not be Galois.
Expand All @@ -113,7 +139,7 @@ def top_field(self):
return self._field

def transitive_label(self):
"""
r"""
Return the transitive label for the action of this Galois group on the roots of
the defining polynomial of the field extension.
Expand All @@ -125,11 +151,29 @@ def transitive_label(self):
sage: G.transitive_label()
'8T44'
"""
return "%sT%s" % (self._field.degree(), self.transitive_number())
try:
return "%sT%s" % (self._field.degree(), self.transitive_number())
except NotImplementedError: # relative number fields don't support degree
return "%sT%s" % (self._field.relative_degree(), self.transitive_number())

def is_galois(self):
r"""
Return whether the top field is Galois over its base.
EXAMPLES::
sage: R.<x> = ZZ[]
sage: K.<a> = NumberField(x^8 - x^5 + x^4 - x^3 + 1)
sage: G = K.galois_group()
sage: from sage.groups.galois_group import GaloisGroup
sage: GaloisGroup.is_galois(G)
False
"""
return self.order() == self._field.degree()

@lazy_attribute
def _galois_closure(self):
"""
r"""
The Galois closure of the top field.
EXAMPLES::
Expand All @@ -142,9 +186,23 @@ def _galois_closure(self):
"""
return self._gcdata[0]

def splitting_field(self):
r"""
The Galois closure of the top field.
EXAMPLES::
sage: K = NumberField(x^3 - x + 1, 'a')
sage: K.galois_group(names='b').splitting_field()
Number Field in b with defining polynomial x^6 - 6*x^4 + 9*x^2 + 23
sage: L = QuadraticField(-23, 'c'); L.galois_group().splitting_field() is L
True
"""
return self._galois_closure

@lazy_attribute
def _gc_map(self):
"""
r"""
The inclusion of the top field into the Galois closure.
EXAMPLES::
Expand All @@ -162,7 +220,7 @@ def _gc_map(self):

@lazy_attribute
def _deg(self):
"""
r"""
The number of moved points in the permutation representation.
This will be the degree of the original number field if `_gc_numbering``
Expand All @@ -182,11 +240,14 @@ def _deg(self):
if self._gc_numbering:
return self.order()
else:
return self._field.degree()
try:
return self._field.degree()
except NotImplementedError: # relative number fields don't support degree
return self._field.relative_degree()

@lazy_attribute
def _domain(self):
"""
r"""
The integers labeling the roots on which this Galois group acts.
EXAMPLES::
Expand All @@ -204,7 +265,7 @@ def _domain(self):

@lazy_attribute
def _domain_to_gap(self):
"""
r"""
Dictionary implementing the identity (used by PermutationGroup_generic).
EXAMPLES::
Expand All @@ -219,7 +280,7 @@ def _domain_to_gap(self):

@lazy_attribute
def _domain_from_gap(self):
"""
r"""
Dictionary implementing the identity (used by PermutationGroup_generic).
EXAMPLES::
Expand All @@ -232,3 +293,13 @@ def _domain_from_gap(self):
"""
return dict((i+1, key) for i, key in enumerate(self._domain))

def ngens(self):
r"""
Number of generators of this Galois group
EXAMPLES::
sage: QuadraticField(-23, 'a').galois_group().ngens()
1
"""
return len(self._gens)
25 changes: 0 additions & 25 deletions src/sage/rings/number_field/galois_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,17 +601,6 @@ def is_galois(self):
else:
return len(K.automorphisms()) == d

def ngens(self):
r"""
Number of generators of this Galois group
EXAMPLES::
sage: QuadraticField(-23, 'a').galois_group().ngens()
1
"""
return len(self._gens)

def _repr_(self):
r"""
String representation of this Galois group
Expand Down Expand Up @@ -650,20 +639,6 @@ def number_field(self):
"""
return self._field

def splitting_field(self):
r"""
The Galois closure of the ambient number field.
EXAMPLES::
sage: K = NumberField(x^3 - x + 1, 'a')
sage: K.galois_group(names='b').splitting_field()
Number Field in b with defining polynomial x^6 - 6*x^4 + 9*x^2 + 23
sage: L = QuadraticField(-23, 'c'); L.galois_group().splitting_field() is L
True
"""
return self._galois_closure

def list(self):
r"""
List of the elements of self.
Expand Down

0 comments on commit d5b9025

Please sign in to comment.