| 1 | """ |
| 2 | Orders in Function Fields |
| 3 | """ |
| 4 | |
| 5 | from sage.structure.parent_gens import ParentWithGens |
| 6 | |
| 7 | from sage.rings.ring import IntegralDomain, PrincipalIdealDomain |
| 8 | |
| 9 | class FunctionFieldOrder(IntegralDomain): |
| 10 | def __init__(self, fraction_field): |
| 11 | """ |
| 12 | EXAMPLES:: |
| 13 | |
| 14 | sage: R = FunctionField(QQ,'y').maximal_order() |
| 15 | sage: isinstance(R, sage.rings.function_field.function_field_order.FunctionFieldOrder) |
| 16 | True |
| 17 | """ |
| 18 | self._fraction_field = fraction_field |
| 19 | |
| 20 | def _repr_(self): |
| 21 | """ |
| 22 | EXAMPLES:: |
| 23 | |
| 24 | sage: FunctionField(QQ,'y').maximal_order()._repr_() |
| 25 | 'Maximal order in Rational function field in y over Rational Field' |
| 26 | """ |
| 27 | return "Order in %s"%self.fraction_field() |
| 28 | |
| 29 | def is_finite(self): |
| 30 | """ |
| 31 | EXAMPLES:: |
| 32 | |
| 33 | sage: FunctionField(QQ,'y').maximal_order().is_finite() |
| 34 | False |
| 35 | """ |
| 36 | return False |
| 37 | |
| 38 | def is_field(self): |
| 39 | """ |
| 40 | EXAMPLES:: |
| 41 | |
| 42 | sage: FunctionField(QQ,'y').maximal_order().is_field() |
| 43 | False |
| 44 | """ |
| 45 | return False |
| 46 | |
| 47 | def fraction_field(self): |
| 48 | """ |
| 49 | EXAMPLES:: |
| 50 | |
| 51 | sage: FunctionField(QQ,'y').maximal_order().fraction_field() |
| 52 | Rational function field in y over Rational Field |
| 53 | """ |
| 54 | return self._fraction_field |
| 55 | |
| 56 | def ideal_with_basis(self, basis, check=True): |
| 57 | """ |
| 58 | Return the ideal with given generators. |
| 59 | |
| 60 | INPUT: |
| 61 | - ``basis`` -- list of elements that are a basis for the |
| 62 | ideal over the maximal order of the base field |
| 63 | - ``check`` -- bool (default: True) |
| 64 | |
| 65 | EXAMPLES:: |
| 66 | |
| 67 | sage: R.<y> = FunctionField(QQ) |
| 68 | sage: S = R.maximal_order() |
| 69 | sage: I = S.ideal_with_basis([y]) |
| 70 | ? |
| 71 | """ |
| 72 | from function_field_ideal import ideal_with_basis |
| 73 | return ideal_with_basis(self.fraction_field(), [self(a) for a in basis], check=check) |
| 74 | |
| 75 | def TODOideal(self, x, check=True): |
| 76 | """ |
| 77 | Return the ideal generated by the element x or the elements in |
| 78 | x if x is a list. |
| 79 | |
| 80 | EXAMPLES:: |
| 81 | |
| 82 | sage: R.<y> = FunctionField(QQ) |
| 83 | sage: S = R.maximal_order() |
| 84 | sage: S.ideal(y) |
| 85 | |
| 86 | """ |
| 87 | from function_field_ideal import ideal_with_gens |
| 88 | return ideal_with_gens(self, x, check=check) |
| 89 | |
| 90 | |
| 91 | class FunctionFieldOrder_basis(FunctionFieldOrder): |
| 92 | """ |
| 93 | An order given by a basis over the maximal order of the base |
| 94 | field. |
| 95 | """ |
| 96 | def __init__(self, basis, check=True): |
| 97 | """ |
| 98 | EXAMPLES:: |
| 99 | |
| 100 | sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order() |
| 101 | sage: S |
| 102 | Order in Function field in Y defined by y^4 + x*y + 4*x + 1 |
| 103 | sage: type(S) |
| 104 | <class 'sage.rings.function_field.function_field_order.FunctionFieldOrder_basis'> |
| 105 | """ |
| 106 | if len(basis) == 0: |
| 107 | raise ValueError, "basis must have positive length" |
| 108 | |
| 109 | fraction_field = basis[0].parent() |
| 110 | if len(basis) != fraction_field.degree(): |
| 111 | raise ValueError, "length of basis must equal degree of field" |
| 112 | |
| 113 | FunctionFieldOrder.__init__(self, fraction_field) |
| 114 | |
| 115 | self._basis = tuple(basis) |
| 116 | V, fr, to = fraction_field.vector_space() |
| 117 | R = fraction_field.base_field().maximal_order() |
| 118 | self._module = V.span([to(b) for b in basis], base_ring=R) |
| 119 | if check: |
| 120 | if self._module.rank() != fraction_field.degree(): |
| 121 | raise ValueError, "basis is not a basis" |
| 122 | IntegralDomain.__init__(self, self, names = fraction_field.variable_names(), normalize = False) |
| 123 | |
| 124 | def fraction_field(self): |
| 125 | """ |
| 126 | EXAMPLES:: |
| 127 | |
| 128 | sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order() |
| 129 | sage: S.fraction_field() |
| 130 | Function field in Y defined by y^4 + x*y + 4*x + 1 |
| 131 | """ |
| 132 | return self._fraction_field |
| 133 | |
| 134 | def basis(self): |
| 135 | """ |
| 136 | EXAMPLES:: |
| 137 | |
| 138 | sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order() |
| 139 | sage: S.basis() |
| 140 | (1, Y, Y^2, Y^3) |
| 141 | |
| 142 | """ |
| 143 | return self._basis |
| 144 | |
| 145 | def free_module(self): |
| 146 | """ |
| 147 | EXAMPLES:: |
| 148 | |
| 149 | sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]; L.<Y> = K.extension(y^4 + x*y + 4*x + 1); S = L.equation_order() |
| 150 | sage: S.free_module() |
| 151 | Free module of degree 4 and rank 4 over Maximal order in Rational function field in x over Finite Field of size 7 |
| 152 | Echelon basis matrix: |
| 153 | [1 0 0 0] |
| 154 | [0 1 0 0] |
| 155 | [0 0 1 0] |
| 156 | [0 0 0 1] |
| 157 | """ |
| 158 | return self._module |
| 159 | |
| 160 | import function_field_element |
| 161 | |
| 162 | class FunctionFieldOrder_rational(PrincipalIdealDomain, FunctionFieldOrder): |
| 163 | """ |
| 164 | The maximal order in a rational function field. |
| 165 | """ |
| 166 | def __init__(self, function_field): |
| 167 | """ |
| 168 | EXAMPLES:: |
| 169 | |
| 170 | sage: K.<t> = FunctionField(GF(19)); K |
| 171 | Rational function field in t over Finite Field of size 19 |
| 172 | sage: R = K.maximal_order(); R |
| 173 | Maximal order in Rational function field in t over Finite Field of size 19 |
| 174 | sage: type(R) |
| 175 | <class 'sage.rings.function_field.function_field_order.FunctionFieldOrder_rational'> |
| 176 | """ |
| 177 | FunctionFieldOrder.__init__(self, function_field) |
| 178 | IntegralDomain.__init__(self, self, names = function_field.variable_names(), normalize = False) |
| 179 | self._ring = function_field.polynomial_ring() |
| 180 | self._populate_coercion_lists_(coerce_list=[self._ring]) |
| 181 | self._gen = self(self._ring.gen()) |
| 182 | |
| 183 | def _repr_(self): |
| 184 | """ |
| 185 | EXAMPLES:: |
| 186 | |
| 187 | sage: FunctionField(QQ,'y').maximal_order()._repr_() |
| 188 | 'Maximal order in Rational function field in y over Rational Field' |
| 189 | """ |
| 190 | return "Maximal order in %s"%self.fraction_field() |
| 191 | |
| 192 | def gen(self, n=0): |
| 193 | """ |
| 194 | EXAMPLES:: |
| 195 | |
| 196 | sage: R = FunctionField(QQ,'y').maximal_order(); R.gen() |
| 197 | y |
| 198 | sage: R.gen(1) |
| 199 | Traceback (most recent call last): |
| 200 | ... |
| 201 | IndexError: Only one generator. |
| 202 | """ |
| 203 | if n != 0: raise IndexError, "Only one generator." |
| 204 | return self._gen |
| 205 | |
| 206 | def ngens(self): |
| 207 | """ |
| 208 | EXAMPLES:: |
| 209 | |
| 210 | sage: R = FunctionField(QQ,'y').maximal_order(); R.ngens() |
| 211 | 1 |
| 212 | """ |
| 213 | return 1 |
| 214 | |
| 215 | def _element_constructor_(self, f): |
| 216 | """ |
| 217 | EXAMPLES:: |
| 218 | |
| 219 | sage: R.<y> = FunctionField(QQ) |
| 220 | sage: R.maximal_order()._element_constructor_(R.polynomial_ring().0) |
| 221 | y |
| 222 | """ |
| 223 | if f.parent() is self.fraction_field(): |
| 224 | f = f.element() |
| 225 | elif f.parent() is self._ring: |
| 226 | return function_field_element.FunctionFieldElement_rational(self, f) |
| 227 | return function_field_element.FunctionFieldElement_rational(self, self._ring(f)) |
| 228 | |
| 229 | |
| 230 | |
| 231 | |