// Automorphisms Test File. // written by Florian Hess, version 20050829 //SetVerbose("Aut1", 3); //SetVerbose("Aut2", 1); SetEchoInput(true); /////////////////////////////////////////////////////////////////////////// // // Get relative time unit. // // // get a relative time unit timing := function(n) sum := 0; for i in [1..n] do sum := sum + 1; end for; return true; end function; t := Cputime(); b := timing(2*10^7); sec := (Cputime() - t) / 5.0; //sec := 0.99; CheckTime := procedure(t, tbound) dt := (Cputime() - t) / sec; print "Time is ", dt, " upper bound is ", tbound; if dt gt tbound then print "Time bound violation !!!"; end if; end procedure; /////////////////////////////////////////////////////////////////////////// // // Function field automorphisms, isomorphisms // // // Remark: // The following sometimes uses intrinsics FieldCategory() and // FunctionFieldCategory() and related stuff. These special // intrinsics should be regarded as internal to the file autiso.m. // This is not documented and might be subject of significant change. // So don't use it or use it at your own risk. k := GF(5); kxf := RationalFunctionField(k); L := Automorphisms(kxf); t := Cputime(); assert #L eq #PGL(2, k); CheckTime(t, 0.03); assert &and [ IsMorphism(f) : f in L ]; assert Equality(L[1], L[1]); assert not Equality(L[2], L[3]); k := GF(4); kxf := RationalFunctionField(k); id := IdentityFieldMorphism(k); L := Automorphisms(kxf : BaseMorphism := id); assert #L eq #PGL(2, k); L := Automorphisms(kxf); assert #L eq 2 * #PGL(2, k); k := GF(4); kxf := RationalFunctionField(k); F := FunctionField(Places(kxf)); L := Automorphisms(F); assert #L eq 2 * #PGL(2, k); k := GF(5); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); F := FunctionField(x^2 + y^2 - 1); L := Isomorphisms(kxf, F); assert #L eq #PGL(2, k); k := GF(5); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f := x^3 + y^3 + 1; F := FunctionField(f); f := Numeration(Set(Places(F, 1))); G, h, K := AutomorphismGroup(F, f); assert #G eq 12; j := h(G.2); i := Inverse(j); assert i@@h eq G.2^(-1); G, f := AutomorphismGroup(F); L := Automorphisms(F); assert f(G.2)@@f eq G.2; //assert L[1]@@f eq G.1; // bug in GrpFP assert L[2]@@f eq G.2; assert L[3]@@f eq G.3; k := GF(5); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f := x^3 + y^3 + 1; F := FunctionField(f); V, f := SpaceOfDifferentialsFirstKind(F); G, h, K := AutomorphismGroup(F, f); assert #G eq 2; D := &+ Places(F, 1); V, f := DifferentialSpace( -D ); G, h := AutomorphismGroup(F, f); assert #G eq 12; V, f := RiemannRochSpace( D ); G, h := AutomorphismGroup(F, f); assert #G eq 12; k := GF(5); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f := y^2 - x^5 - x; F := FunctionField(f); V, f := SpaceOfDifferentialsFirstKind(F); G, h := AutomorphismGroup(F, f); assert #G eq 8; k := GF(25); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f := x^3 + y^3 + 1; F := FunctionField(f); t := Cputime(); L := Automorphisms(F); assert #L eq 432; CheckTime(t, 15); k := Rationals(); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); F := FunctionField(y^2 - x^5 + 1); C := FieldCategory(); E := FunctionFieldCategory(); c := Coercion(C)(k, F); Fb := BaseExtension(E)(F, c); L := Automorphisms(Fb); assert #L eq 4; k := GF(9); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f := w*y + w*y^5 + w^3*x + w^3*x^5 + 1; F1 := FunctionField(f); g := w^3*y + w^3*y^5 + w*x + w*x^5 + 1; F2 := FunctionField(g); L := Isomorphisms(F1, F2); assert #L eq 4; C := FieldCategory(); ok, cc := HasFrobeniusEndomorphism(C)(k, 3); L := Automorphisms(F1 : BaseMorphism := cc); assert #L eq 2; E := FunctionFieldCategory(); ok, f := HasMorphismFromImagesAndBaseMorphism(E)(F1, F1, [F1!x, F1.1], cc); assert ok; assert AreEqualMorphisms(E)(f, L[2]); // might depend on the order I := [F1!x, F1.1]; ok, f := HasMorphismFromImagesAndBaseMorphism(E)(F1, F1, I, cc); assert ok; k := GF(7); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f := y^2 + x^14 + x + 1; F := FunctionField(f); L := Automorphisms(F); assert #L eq 2; // Problematic case, cannot be dealt with yet. k := GF(2^30); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f := y^2 + x*y + x^11 + x + 1; F := FunctionField(f); Automorphisms(F : BaseMorphism := IdentityFieldMorphism(k)); // yields nice error message? // p divides the pole numbers k := GF(9); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f := x^4 + y^4 + x + y + 1; F := FunctionField(f); t := Cputime(); L := Automorphisms(F); assert #L eq 32; CheckTime(t, 95); k := GF(2); kx := RationalFunctionField(k); kxy := PolynomialRing(kx); F := FunctionField(y^2 - y + x^9 - 1); t := Cputime(); L := Automorphisms(F : Bound := 1); assert #L eq 1; CheckTime(t, 0.1); k := GF(7^2); kx := RationalFunctionField(k); kxy := PolynomialRing(kx); F := FunctionField(y^4 + x^7 - x); t := Cputime(); L := Automorphisms(F); assert #L eq 2688; CheckTime(t, 80); M := [ [ f(F.1), f(F!x), f(F!k.1) ] : f in L ]; assert #Set(M) eq 2688; // RHS is irreducible, can use place of degree one at infinity k := GF(107); kx := RationalFunctionField(k); kxy := PolynomialRing(kx); F := FunctionField(y^2- x^7 + 63*x^6 + 69*x^5 + 55*x^4 + 92*x^3 + 35*x^2 + 72*x + 92); t := Cputime(); L := Automorphisms(F); assert #L eq 2; CheckTime(t, 0.5); // RHS is irreducible, needs to work over base ext of degree 6 and restrict k := GF(107); kx := RationalFunctionField(k); kxy := PolynomialRing(kx); F := FunctionField(y^2- x^6 + 57*x^5 + 75*x^4 + 52*x^3 + 52*x^2 + 106*x + 25); t := Cputime(); L := Automorphisms(F); assert #L eq 2; CheckTime(t, 1.4); // dfferent LHS and RHS k := Rationals(); kx := RationalFunctionField(k); kxy := PolynomialRing(kx); F1 := FunctionField(y^2 - x^5 - 1); F2 := FunctionField(y^2 - (x+1)^5 - 1); assert #Isomorphisms(F1, F2) eq 2; // dfferent LHS and RHS k := Rationals(); kx := PolynomialRing(k); k1 := NumberField(x^2 - 3); k2 := NumberField((x+1)^2 - 3); k1x := RationalFunctionField(k1); k1xy := PolynomialRing(k1x); F1 := FunctionField(y^2 - x^5 - 1); k2x := RationalFunctionField(k2); k2xy := PolynomialRing(k2x); F2 := FunctionField(y^2 - (x+1)^5 - 1); assert #Isomorphisms(F1, F2) eq 4; C := FieldCategory(); E := FunctionFieldCategory(); k := GF(5); kx := RationalFunctionField(k); kxy := PolynomialRing(kx); F1 := FunctionField(y^3 - x^3 - 1); c := Coercion(C)(k, GF(25)); _, f1 := BaseExtension(E)(F1, c); F2 := F1; f2 := f1; FF1 := Codomain(f1); FF2 := Codomain(f2); t := Cputime(); assert #Isomorphisms(FF1, FF2) eq 432; CheckTime(t, 20); k := GF(25); kx := RationalFunctionField(k); kxy := PolynomialRing(kx); F1 := FunctionField(y^2 - x^7 - w); F2 := FunctionField(y^2 - x^7 - w^5); t := Cputime(); L := Isomorphisms(F1, F2); assert #L eq 4; M := [ [ f(F1.1), f(F1!x), f(F1!k.1) ] : f in L ]; assert #Set(M) eq 4; CheckTime(t, 1.3); k := GF(9); kx := RationalFunctionField(k); kxy := PolynomialRing(kx); F := FunctionField(y^5 + y^2 + x^5 + x^2 + 1); t := Cputime(); L := Automorphisms(F); assert #L eq 4; M := [ [ f(F.1), f(F!x), f(F!k.1) ] : f in L ]; assert #Set(M) eq 4; CheckTime(t, 9); k := GF(9); C := FieldCategory(); E := FunctionFieldCategory(); c := Automorphisms(C)(k, 19)[2]; kx := RationalFunctionField(k); kxy := PolynomialRing(kx); F := FunctionField(w*y^5 + w*y^2 + w^3*x^5 + w^3*x^2 + 1); FF := BaseExtension(E)(F, c); t := Cputime(); assert #Isomorphisms(F, FF : BaseMorphism := c) eq 1; assert #Automorphisms(F) eq 2; assert #Automorphisms(F : BaseMorphism := c) eq 1; assert #Automorphisms(F : BaseMorphism := IdentityFieldMorphism(k)) eq 1; f := MorphismFromImagesAndBaseMorphism(E)(F, F, [F!x, F.1], c); CheckTime(t, 55); // rational case t := Cputime(); Q := Rationals(); Qx := PolynomialRing(Q); Qx := PolynomialRing(Qx); T := [ [ 1, -1, -1, -1 ], [ 1, 1, -1, -1 ], [-1, -1, -1, -1 ], [-1, 1, -1, -1 ], [0, 1, 1, 1 ], [0, -1, -1, -1 ], [0, 1, -1, 1 ] ]; S := [ 2, 2, 2, 2, 4, 4, 4 ]; for i in [1..#T] do d, a, b, c := Explode(T[i]); f := y^3 + d*y + a*x^5 + b*x^3 + c*x; F := FunctionField(f); time L := Automorphisms(F); assert #L eq S[i]; M := [ [f(F.1), f(F!x) ] : f in L ]; //print f, M; end for; CheckTime(t, 65); // cyclotomic case t := Cputime(); k := Rationals(); kx := PolynomialRing(k); kxy := PolynomialRing(kx); F := FunctionField(y^2 - kx!CyclotomicPolynomial(18)); L := Automorphisms(F); M := [ [ f(F.1), f(F!BaseField(F).1) ] : f in L ]; assert #Set(M) eq 4; CheckTime(t, 5.5); t := Cputime(); k := NumberField(CyclotomicPolynomial(18)); kx := PolynomialRing(k); kxy := PolynomialRing(kx); F := FunctionField(y^2 - kx!CyclotomicPolynomial(18)); L := Automorphisms(F : BaseMorphism := IdentityFieldMorphism(k)); M := [ [ f(F.1), f(F!BaseField(F).1) ] : f in L ]; assert #Set(M) eq 12; CheckTime(t, 5.5); // nested case Q := Rationals(); Qt := PolynomialRing(Q); K := NumberField(t^2 - 3); Kxf := RationalFunctionField(K); Kxfy := PolynomialRing(Kxf); w := Kxf.1; G := FunctionField(y^2 - (w-1)*(w-2)*(w-3)*(w-4)*(w-5)); C := FieldCategory(); E := FunctionFieldCategory(); i := Coercion(C)(K, G); ok, H := HasBaseExtension(E)(G, i); t := Cputime(); L := Automorphisms(H); assert #L eq 8; M := [ [ f(H.1), f(H!x), f(H!G.1), f(H!(G!BaseRing(G).1)), f(H!K.1) ] : f in L ]; assert #Set(M) eq #M; CheckTime(t, 90); // quite nested case Q := Rationals(); Qt := PolynomialRing(Q); K := NumberField(t^2 - 3); Kt := PolynomialRing(K); L := NumberField(t^2 - 5); Lxf := RationalFunctionField(L); Lxfy := PolynomialRing(Lxf); //F := FunctionField(y - x); F := Lxf; w := Lxf.1; Fy := PolynomialRing(F); G := FunctionField(y^2 - (w-1)*(w-2)*(w-3)*(w-4)*(w-5)); C := FieldCategory(); E := FunctionFieldCategory(); i := Coercion(C)(L, G); ok, H := HasBaseExtension(E)(G, i); t := Cputime(); N := Automorphisms(H); assert #N eq 16; M := [ [ f(H.1), f(BaseRing(H).1), f(G.1), f(BaseRing(G).1), f(L.1), f(K.1) ] : f in N ]; assert #Set(M) eq #M; CheckTime(t, 118); // quite nested case // F linear or quadratic causes problems // BaseExtension() or Genus() do not work properly Q := Rationals(); Qt := PolynomialRing(Q); K := NumberField(t^2 - 3); Kt := PolynomialRing(K); L := NumberField(t^2 - 5); Lxf := RationalFunctionField(L); Lxfy := PolynomialRing(Lxf); F := FunctionField(y^2 - x); Fy := PolynomialRing(F); G := FunctionField(y^2 - (w-1)*(w-2)*(w-3)*(w-4)*(w-5)); C := FieldCategory(); E := FunctionFieldCategory(); i := Coercion(C)(L, G); ok, H := HasBaseExtension(E)(G, i); t := Cputime(); N := Automorphisms(H); assert #N eq 16; M := [ [ f(H.1), f(BaseRing(H).1), f(G.1), f(BaseRing(G).1), f(L.1), f(K.1) ] : f in N ]; assert #Set(M) eq #M; CheckTime(t, 118); /* Q := Rationals(); Qt := PolynomialRing(Q); K := NumberField(t^2 - 3); Kt := PolynomialRing(K); L := NumberField(t^2 - 5); Lxf := RationalFunctionField(L); Lxfy := PolynomialRing(Lxf); F := FunctionField(y^2 - x); Fy := PolynomialRing(F); G := FunctionField(y^2 - (w-1)*(w-2)*(w-3)*(w-4)*(w-5)); L := G; Lxf := RationalFunctionField(L); Lxfy := PolynomialRing(Lxf); F := FunctionField(y^2 - x); Fy := PolynomialRing(F); G := FunctionField(y^2 - (w-1)*(w-2)*(w-3)*(w-4)*(w-5)); takes ages Q := Rationals(); Qt := PolynomialRing(Q); K := NumberField(t^2 - 3); Kt := PolynomialRing(K); L := NumberField(t^2 - 5); Lxf := RationalFunctionField(L); Lxfy := PolynomialRing(Lxf); F := FunctionField(y - x); Fy := PolynomialRing(F); G := FunctionField(y^2 - (w-1)*(w-2)*(w-3)*(w-4)*(w-5)); L := G; Lxf := RationalFunctionField(L); Lxfy := PolynomialRing(Lxf); F := FunctionField(y - x); Fy := PolynomialRing(F); G := FunctionField(y^2 - (w-1)*(w-2)*(w-3)*(w-4)*(w-5)); Genus(G) takes ages both fairly fast without use of F */ // simplest weil res example. // Aut(F/k) -> Aut(F) -> Aut(k) does not split on the right here. k := GF(2,2); kx := FunctionField(k); kxy := PolynomialRing(kx); ww := PrimitiveElement(k); a := ww; assert Trace(a) ne 0; c := ww^3; b := ww^3; assert c eq 1; assert Trace(c) eq 0; F := FunctionField(y^2 + y + c/x + a + b*x); // //mc = mb = t + 1; //mf = lcm(mc, mb, t+1) = mc; //g = 2^1 - 2^0 - 2^0 + 1 = 1 // C := FieldCategory(); L := Automorphisms(F); assert #L eq 8; M := [ [ f(F.1), f(F!x), f(F!k.1) ] : f in L ]; assert #Set(M) eq 8; /* _, c := HasFrobeniusEndomorphism(C)(k, 2); i := Coercion(C)(k, F); ok, f := HasExtension(C)(c, i, i, [ F.1 + w, F!x ] ); assert IsIsomorphism(C)(f) eq "true"; */ ok, c := HasFrobeniusEndomorphism(FieldCategory())(k, 2); assert ok; G, f := AutomorphismGroup(F : BaseMorphism := c); /* too many bugs in distribute alffs ... hence to done // weil res example. k := GF(2,4); kx := FunctionField(k); kxy := PolynomialRing(kx); ww := PrimitiveElement(k); a := ww^3; assert Trace(a) ne 0; c := w; b := w; assert Trace(w) eq 0; F := FunctionField([ y^2 + y + c/x + a + b*x, y^2 + y + c^2/x + a^2 + b^2*x, y^2 + y + c^4/x + a^4 + b^4*x ]); // //mc = mb = t^3 + t^2 + t + 1; //mf = lcm(mc, mb, t+1) = mc; //g = 2^3 - 2^0 - 2^0 + 1 = 7 // C := FieldCategory(); _, c := HasFrobeniusEndomorphism(C)(k, 2); L := Automorphisms(F : BaseMorphism := c); */ /* Generic places stuff. F1 := UnderlyingField(F1); F2 := UnderlyingField(F2); Isomorphisms(F1, F2, id); k := Rationals(); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f1 := y^2 + (x)^3 + 1; F1 := FunctionField(f1); P1 := Poles(F1.1)[1]; f2 := y^2 + (x+1)^3 + 1; F2 := FunctionField(f2); P2 := Poles(F2.1)[1]; k := GF(5); k := Rationals(); S := RationalFunctionField(k, 2); A := PolynomialRing(S, 2); I := ideal< A | a1^2 + x1^3 + 1, a2^2 + (x2 + 1)^3 + 1 >; K := quo< A | I >; FF1 := ConstantFieldExtension(F1, K); FF2 := ConstantFieldExtension(F2, K); R := RationalFunctionField(K); PP1 := CommonZeros( [ FF1!xx - K!x1, aa1 - K!a1 ] )[1]; PP2 := CommonZeros( [ FF2!xx - K!x2, aa2 - K!a2 ] )[1]; //Basis(3*PP1); //C := FieldCategory(); //id := Identity(C)(K); //IsomorphismsWithPlace(PP1, PP2, 1); k := GF(7); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f1 := y^2 + (x)^5 + 1; F1 := FunctionField(f1); P1 := Poles(F1.1)[1]; f2 := y^2 + (x+1)^5 + 1; F2 := FunctionField(f2); P2 := Poles(F2.1)[1]; FF1 := ConstantFieldExtension(F1, F2); R := RationalFunctionField(F1); FF2 := ConstantFieldExtension(F2, F2); R := RationalFunctionField(F2); PP1 := CommonZeros( [ FF1!xx + 1, FF1.1 ] )[1]; PP2 := CommonZeros( [ FF2!xx - (F2!BaseField(F2).1), aa2 - F2.1 ] )[1]; //Basis(3*PP1); //C := FieldCategory(); //id := Identity(C)(K); //IsomorphismsWithPlace(PP1, PP2, 1); */ //////////////////////////////////////////////////////////////////////////// // // Parametrizations // k := GF(5); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f := y^2 - x^3 + 1; F := FunctionField(f); P := Zeros(a)[1]; Q := Zeros(a+1)[1]; D := -5*Q; ok, f := HasAlmostUniqueLocalParametrization(D, P); assert ok; c := f(a, 10); /////////////////////////////////////////////////////////////////////////// // // Supports extensions // // k := Rationals(); kxf := FunctionField(k); C := FieldCategory(); i := Coercion(C)(k, kxf); ok, aff, polys, gens := SupportsExtension(C)(i); assert ok; k := Rationals(); G := RationalFunctionField(k, 2); C := FieldCategory(); i := Coercion(C)(k, G); ok, aff, polys, gens := SupportsExtension(C)(i); assert ok; k := Rationals(); kxf := FunctionField(k); kxfy := PolynomialRing(kxf); F := FunctionField(y^2 - x^3 - 1); i := Coercion(C)(k, F); ok, aff, polys, gens := SupportsExtension(C)(i); assert ok; i := Coercion(C)(kxf, F); ok, aff, polys, gens := SupportsExtension(C)(i); assert ok; G := UnderlyingField(F); i := Coercion(C)(kxf, F); ok, aff, polys, gens := SupportsExtension(C)(i); assert ok; Z := Integers(); Zx := PolynomialRing(Z); K1 := NumberField(x^2 - 2); K2 := NumberField(x^2 - 2*3^2); Embed(K1, K2, K2.1/3); C := FieldCategory(); i := Coercion(C)(K1, K2); ok, aff, polys, gens := SupportsExtension(C)(i); assert ok; Z := Integers(); Zx := PolynomialRing(Z); K1 := NumberField(x^2 - 2); K2 := NumberField(x^4 - 2*3^2); Embed(K1, K2, K2.1^2/3); C := FieldCategory(); i := Coercion(C)(K1, K2); ok, aff, polys, gens := SupportsExtension(C)(i); assert ok; // finite alff exts k := Rationals(); kx := PolynomialRing(k); kxy := PolynomialRing(kx); F := FunctionField(y^2 - x); C := FieldCategory(); i := Coercion(C)(BaseField(F), F); ok, aff, polys, gens := SupportsExtension(C)(i); assert ok cmpeq true; assert #aff eq 1; assert #gens eq 1; assert Evaluate(polys(F.1), gens[1]) eq F.1; n, d := polys(1/F.1); assert Evaluate(n, gens[1]) / Evaluate(d, gens[1]) eq 1/F.1; c := Identity(C)(BaseField(F)); ok, f := HasExtension(C)(c, i, i, gens); assert ok; assert IsIdentity(C)(f); k := Rationals(); kx := PolynomialRing(k); kxy := PolynomialRing(kx); F := FunctionField([y^2 - x]); C := FieldCategory(); i := Coercion(C)(BaseField(F), F); ok, aff, polys, gens := SupportsExtension(C)(i); assert ok cmpeq true; assert #aff eq 1; assert #gens eq 1; assert Evaluate(polys(F.1), gens) eq F.1; n, d := polys(1/F.1); assert Evaluate(n, gens) / Evaluate(d, gens) eq 1/F.1; c := Identity(C)(BaseField(F)); ok, f := HasExtension(C)(c, i, i, gens); assert ok; assert IsIdentity(C)(f); k := Rationals(); kx := PolynomialRing(k); kxy := PolynomialRing(kx); F := FunctionField([y^2 - x, y^2 - x+1]); C := FieldCategory(); i := Coercion(C)(BaseField(F), F); ok, aff, polys, gens := SupportsExtension(C)(i); assert ok cmpeq true; assert #aff eq 2; assert #gens eq 2; assert Evaluate(polys(F.1), gens) eq F.1; assert Evaluate(polys(F.2), gens) eq F.2; n, d := polys(1/F.1); assert Evaluate(n, gens) / Evaluate(d, gens) eq 1/F.1; c := Identity(C)(BaseField(F)); ok, f := HasExtension(C)(c, i, i, gens); assert ok; assert IsIdentity(C)(f); // infinite alff exts k := Rationals(); kx := PolynomialRing(k); kxy := PolynomialRing(kx); F := FunctionField(y^2 - x); C := FieldCategory(); i := Coercion(C)(k, F); ok, aff, polys, gens := SupportsExtension(C)(i); assert ok cmpeq true; assert #aff eq 1; assert #gens eq 2; assert Evaluate(polys(F.1), gens) eq F.1; n, d := polys(1/F.1); assert Evaluate(n, gens) / Evaluate(d, gens) eq 1/F.1; c := Identity(C)(k); n, d := polys(1/F!x); assert Evaluate(n, gens) / Evaluate(d, gens) eq 1/F!x; ok, f := HasExtension(C)(c, i, i, gens); assert ok; assert IsIdentity(C)(f); k := Rationals(); kx := PolynomialRing(k); kxy := PolynomialRing(kx); F := FunctionField([y^2 - x]); C := FieldCategory(); i := Coercion(C)(k, F); ok, aff, polys, gens := SupportsExtension(C)(i); assert ok cmpeq true; assert #aff eq 1; assert #gens eq 2; assert Evaluate(polys(F.1), gens) eq F.1; n, d := polys(1/F.1); assert Evaluate(n, gens) / Evaluate(d, gens) eq 1/F.1; n, d := polys(1/F!x); assert Evaluate(n, gens) / Evaluate(d, gens) eq 1/F!x; c := Identity(C)(k); ok, f := HasExtension(C)(c, i, i, gens); assert ok; assert IsIdentity(C)(f); k := Rationals(); kx := PolynomialRing(k); kxy := PolynomialRing(kx); F := FunctionField([y^2 - x, y^2 - x+1]); C := FieldCategory(); i := Coercion(C)(k, F); ok, aff, polys, gens := SupportsExtension(C)(i); assert ok cmpeq true; assert #aff eq 2; assert #gens eq 3; assert Evaluate(polys(F.1), gens) eq F.1; assert Evaluate(polys(F.2), gens) eq F.2; n, d := polys(1/F.1); assert Evaluate(n, gens) / Evaluate(d, gens) eq 1/F.1; n, d := polys(1/F!x); assert Evaluate(n, gens) / Evaluate(d, gens) eq 1/F!x; c := Identity(C)(k); ok, f := HasExtension(C)(c, i, i, gens); assert ok; assert IsIdentity(C)(f); // recursive situation k := Rationals(); kxf := FunctionField(k); kxy := PolynomialRing(kxf); F1 := FunctionField(y - x); F1y := PolynomialRing(F1); F2 := FunctionField([y^2 - x+1, y^2 - x+2]); F2y := PolynomialRing(F2); F3 := FunctionField(y^2 - F2.1); C := FieldCategory(); i := Coercion(C)(k, kxf); ok, aff, polys, gens := SupportsExtension(C)(i); assert #aff eq 0; assert #gens eq 1; c := Identity(C)(k); ok, f := HasExtension(C)(c, i, i, gens); assert ok; assert IsIdentity(C)(f); i := Coercion(C)(k, F1); ok, aff, polys, gens := SupportsExtension(C)(i); assert #aff eq 1; assert #gens eq 2; c := Identity(C)(k); ok, f := HasExtension(C)(c, i, i, gens); assert ok; assert IsIdentity(C)(f); i := Coercion(C)(k, F3); ok, aff, polys, gens := SupportsExtension(C)(i); assert #aff eq 4; assert #gens eq 5; c := Identity(C)(k); ok, f := HasExtension(C)(c, i, i, gens); assert ok; assert IsIdentity(C)(f); // F := NumberField([x^3-2, x^7+2] : Abs); /////////////////////////////////////////////////////////////////////////// // // IsIsomorphic Test for FldNum. // This is needed/implicitly asserted in MakeIsomorphisms() // Z := Integers(); Zx := PolynomialRing(Integers()); K1 := NumberField(x^2 - 2); K1x := PolynomialRing(K1); K2 := NumberField(x^2 - 3); Z := Integers(); Zx := PolynomialRing(Integers()); L1 := NumberField(x^2 - 3); L1x := PolynomialRing(L1); L2 := NumberField(x^2 - 2); assert IsIsomorphic(K2, L2); C := FieldCategory(); L := Isomorphisms(C)(K2, L2, Infinity()); assert #L eq 4; //////////////////////////////////////////////////////////////////// // // Semi trivial support general rational function fields // k := Rationals(); kxf := RationalFunctionField(k); C := FieldCategory(); assert IsIsomorphic(C)(kxf, kxf) cmpeq "true"; E := FunctionFieldCategory(); assert IsIsomorphic(E)(kxf, kxf) cmpeq "true"; k := Rationals(); kxf := RationalFunctionField(k, 2); C := FieldCategory(); assert IsIsomorphic(C)(kxf, kxf) cmpeq "true"; E := FunctionFieldCategory(); assert IsIsomorphic(E)(kxf, kxf) cmpeq "unknown"; Z := Integers(); Zx := PolynomialRing(Integers()); K1 := NumberField(x^2 - 2); K1x := PolynomialRing(K1); K2 := NumberField(x^2 - 3); Z := Integers(); Zx := PolynomialRing(Integers()); L1 := NumberField(x^2 - 3); L1x := PolynomialRing(L1); L2 := NumberField(x^2 - 2); R1 := RationalFunctionField(K2, 2); R2 := RationalFunctionField(L2, 2); C := FieldCategory(); ok, f := IsIsomorphic(C)(R1, R2); assert ok cmpeq "true"; Z := Integers(); Zx := PolynomialRing(Integers()); K1 := NumberField(x^2 - 2); K1x := PolynomialRing(K1); K2 := NumberField(x^2 - 3); Z := Integers(); Zx := PolynomialRing(Integers()); L1 := NumberField(x^2 - 3); L1x := PolynomialRing(L1); L2 := NumberField(x^2 - 2); R1 := RationalFunctionField(K2); R2 := RationalFunctionField(L2); C := FieldCategory(); ok, f := IsIsomorphic(C)(R1, R2); assert ok cmpeq "true"; E := FunctionFieldCategory(); ok, f := IsIsomorphic(E)(R1, R2); assert ok cmpeq "true"; assert f(a1) eq b2; assert f(a2) eq b1; assert f(R1.1) eq R2.1; assert b2@@f eq a1; ok, f := IsIsomorphic(R1, R2); assert ok; Z := Integers(); Zx := PolynomialRing(Integers()); K1 := NumberField(x^2 - 2); K1x := PolynomialRing(K1); K2 := NumberField(x^2 - 3); Z := Integers(); Zx := PolynomialRing(Integers()); L1 := NumberField(x^2 - 3); L1x := PolynomialRing(L1); L2 := NumberField(x^2 - 2); R1 := RationalFunctionField(K2); R2 := RationalFunctionField(L2); C := FieldCategory(); ok, c := IsIsomorphic(C)(K2, L2); assert ok cmpeq "true"; E := FunctionFieldCategory(); ok, f := IsIsomorphic(R1, R2 : BaseMorphism := c); assert ok; assert f(a1) eq b2; assert f(a2) eq b1; assert f(R1.1) eq R2.1; assert b2@@f eq a1; //////////////////////////////////////////////////////////////////////////// // // Base extension, and restriction // C := FieldCategory(); E := ExtensionCategory(C); F := GF(125); c := Coercion(C)(GF(5), GF(25)); F1, ff := BaseExtension(E)(F, c); ok, zz := HasPreimage(ff, ff(F.1)); assert ok and zz eq F.1; C := FieldCategory(); E := FunctionFieldCategory(); k := GF(5); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f := y^2 + (x)^3 + 1; F := FunctionField(f); c := Coercion(C)(GF(5), GF(25)); F1, ff := BaseExtension(E)(F, c); ok, zz := HasPreimage(ff, ff(F.1)); assert ok and zz eq F.1; Ft := PolynomialRing(F); G := FunctionField(t^2 - F.1); G1, gg := BaseExtension(E)(G, c); ok, zz := HasPreimage(gg, gg(G.1)); assert ok and zz eq G.1; F := UnderlyingField(F); F1, ff := BaseExtension(E)(F, c); ok, zz := HasPreimage(ff, ff(F.1)); assert ok and zz eq F.1; // base ext test k := GF(25); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f := y^2 - w*x^5 - x; F := FunctionField(f); g := (y-1)^2 - w^5*(x+1)^5 - (x+1); G := FunctionField(g); C := FieldCategory(); E := FunctionFieldCategory(); _, d := HasFrobeniusEndomorphism(C)(k, 5); f := MorphismFromImagesAndBaseMorphism(E)(F, G, [ b-1, G!x+1], d ); kt := PolynomialRing(k); K1 := ext< k | RandomPrimePolynomial(kt, 2) >; K1t := PolynomialRing(K1); h := RandomPrimePolynomial(K1t, 2); K2 := ext< K1 | h >; i := Coercion(C)(k, K1); j := Coercion(C)(k, K2); c := Extension(C)(d, i, j, [ (K2!w1)^5 ] ); ok, fb, ib, jb := HasBaseExtensionMorphisms(E)(f, i, j, c); assert ok; Z := MorphismCategory( E ); D := MorphismCategory( C ); cc := Morphism(D)(Bottom(f), c, j, i); ok, fb, ib := HasBaseExtension(Z)(f, cc); assert ok; k := GF(25); kxf := RationalFunctionField(k); kxfy := PolynomialRing(kxf); f := y^2 - w*x^5 - x; F := FunctionField(f); g := (y-1)^2 - w^5*(x+1)^5 - (x+1); G := FunctionField(g); C := FieldCategory(); E := FunctionFieldCategory(); _, d := HasFrobeniusEndomorphism(C)(k, 5); f := MorphismFromImagesAndBaseMorphism(E)(F, G, [ b-1, G!x+1], d ); K1 := GF(25^2); K2 := GF(25^4); //Embed(K1, K2); i := Coercion(C)(k, K1); j := Coercion(C)(k, K2); c := Extension(C)(d, i, j, [ (K2!w1)^5 ] ); ok, fb, ib, jb := HasBaseExtensionMorphisms(E)(f, i, j, c); assert ok; k := GF(3); kxf := RationalFunctionField(k); L := Automorphisms(kxf); assert #L eq #PGL(2, k); C := FieldCategory(); E := FunctionFieldCategory(); i := Coercion(C)(k, GF(9)); c := Identity(C)(GF(9)); f := L[2]; ok, fb := HasBaseExtensionMorphisms(E)(f, i, i, c); assert assigned fb`static`preimageconstr; assert assigned fb`static`data`inverseconstr; assert HasPreimageFunction(fb); assert not assigned fb`static`preimageconstr; assert HasInverse(fb) cmpeq "true"; assert not assigned fb`static`data`inverseconstr; f := L[1]; ok, fb := HasBaseExtensionMorphisms(E)(f, i, i, c); assert assigned fb`static`preimageconstr; //assert assigned fb`static`data`inverseconstr; assert HasPreimageFunction(fb); assert not assigned fb`static`preimageconstr; assert HasInverse(fb) cmpeq "true"; assert not assigned fb`static`data`inverseconstr; f := L[3]; ok, fb := HasBaseExtensionMorphisms(E)(f, i, i, c); assert assigned fb`static`preimageconstr; assert assigned fb`static`data`inverseconstr; assert HasInverse(fb) cmpeq "true"; assert not assigned fb`static`data`inverseconstr; assert not assigned fb`static`preimageconstr; assert HasPreimageFunction(fb); // restriction test C := FieldCategory(); E := FunctionFieldCategory(); k := GF(5); K := GF(25); F := RationalFunctionField(k); c := Coercion(C)(k, K); F1, f := BaseExtension(E)(F, c); ok, h := HasMorphismFromImages(E)(F1, F1, [ F1.1 + 1 ]); assert ok; ok, d := HasRestriction(E)(h, f, f); assert HasInverse(E)(d) cmpeq "unknown"; ok, hinv := HasMorphismFromImages(E)(F1, F1, [ F1.1 - 1 ]); h, hinv := SpecifyInverseMorphisms(E)(h, hinv); ok, d := HasRestriction(E)(h, f, f); assert ok; assert HasInverse(E)(d) cmpeq "true"; assert F.1@@d eq F.1 - 1; ok, h := HasMorphismFromImages(E)(F1, F1, [ K.1*F1.1 + 1 ]); assert HasRestriction(E)(h, f, f) eq false; //////////////////////////////////////////////////////////////////////////// // // Field isomorphisms, automorphisms // C := FieldCategory(); assert IsIsomorphic(C)(GF(5), GF(5)) eq "true"; assert IsIsomorphic(C)(Rationals(), Rationals()) eq "true"; C := FieldCategory(); k1 := GF(25); x := PolynomialRing(GF(5)).1; k2 := ext< GF(5) | x^2 - x - 3 >; ok, f := IsIsomorphic(C)(k1, k2); assert ok eq "true"; assert IsIsomorphism(C)(f) eq "true"; assert HasInverse(C)(f) eq "true"; C := FieldCategory(); Q := Rationals(); Qx := PolynomialRing(Q); k1 := NumberField(x^2 - 5); k2 := NumberField((x+1)^2 - 5); ok, f := IsIsomorphic(C)(k1, k2); assert ok eq "true"; assert IsIsomorphism(C)(f) eq "true"; assert HasInverse(C)(f) eq "true"; C := FieldCategory(); Q := Rationals(); Qx := PolynomialRing(Q); k1 := NumberField(x^2 - 5); k2 := NumberField((x+1)^2 - 5); D := ExtensionCategory(C, Q); ok, f := IsIsomorphic(D)(k1, k2); assert ok eq "true"; assert IsIsomorphism(D)(f) eq "true"; assert HasInverse(D)(f) eq "true"; k := Rationals(); kx := PolynomialRing(k); K1 := NumberField(x^2 - 5); K1x := PolynomialRing(K1); K2 := NumberField(x^2 - 3); K2x := PolynomialRing(K2); K3 := NumberField(x^2 - 7); kx := PolynomialRing(k); L1 := NumberField((x+1)^2 - 3); L1x := PolynomialRing(L1); L2 := NumberField((x-1)^2 - 5); L2x := PolynomialRing(L2); L3 := NumberField((x-2)^2 - 7); C := FieldCategory(); ok, f := IsIsomorphic(C)(K3, L3); assert ok eq "true"; assert IsIsomorphism(C)(f) eq "true"; assert HasInverse(C)(f) eq "true"; D := ExtensionCategory(C, k); ok, f := IsIsomorphic(D)(K3, L3); assert ok eq "true"; assert IsIsomorphism(D)(f) eq "true"; assert HasInverse(D)(f) eq "true"; D := ExtensionCategory(C); assert IsObject(D)(K3); assert IsObject(D)(L3); ok, f := IsIsomorphic(D)(K3, L3); assert ok eq "true"; assert IsIsomorphism(D)(f) eq "true"; assert HasInverse(D)(f) eq "true"; k := Rationals(); kx := PolynomialRing(k); K1 := NumberField(x^3 - 2); K1x := PolynomialRing(K1); K2 := NumberField(x^2 - K1.1 * x + K1.1^2); C := FieldCategory(); L := Automorphisms(C)(K2, 10); assert #L eq 6; assert IsIdentity(C)(L[1]); assert IsIsomorphism(C)(L[6]) eq "true"; assert HasInverse(C)(L[6]) eq "true"; D := ExtensionCategory(C); L := Automorphisms(D)(K2, 10); assert #L eq 2; assert IsIdentity(D)(L[1]); assert IsIsomorphism(D)(L[2]) eq "true"; assert HasInverse(D)(L[2]) eq "true"; D := ExtensionCategory(C, k); L := Automorphisms(D)(K2, 10); assert #L eq 6; assert IsIdentity(D)(L[1]); assert IsIsomorphism(D)(L[6]) eq "true"; assert HasInverse(D)(L[6]) eq "true"; D := ExtensionCategory(C, K1); L := Automorphisms(D)(K2, 10); assert #L eq 2; assert IsIdentity(D)(L[1]); assert IsIsomorphism(D)(L[2]) eq "true"; assert HasInverse(D)(L[2]) eq "true"; k := Rationals(); kx := PolynomialRing(k); k1 := NumberField(x^2 - 5); k2 := NumberField(x^2 - 3^2*5); K1 := RationalFunctionField(k1); K2 := RationalFunctionField(k2); C := FunctionFieldCategory(); ok, f := IsIsomorphic(C)(K1, K2); assert ok eq "true"; assert IsIsomorphism(C)(f) eq "true"; assert HasInverse(C)(f) eq "true"; k := Rationals(); kx := PolynomialRing(k); k1 := NumberField(x^2 - 5); k2 := NumberField(x^2 - 3^2*5); C := FieldCategory(); K1 := RationalFunctionField(k1, 2); K2 := RationalFunctionField(k2, 2); ok, f := IsIsomorphic(C)(K1, K2); assert ok eq "true"; assert IsIsomorphism(C)(f) eq "true"; assert HasInverse(C)(f) eq "true"; C := FieldCategory(); k1 := GF(25); x := PolynomialRing(GF(5)).1; k2 := ext< GF(5) | x^2 - x - 3 >; ok, c := IsIsomorphic(C)(k1, k2); assert ok eq "true"; L := GF(25^2); i := Coercion(C)(k1, L); j := Coercion(C)(k2, L); ok, L := HasIsomorphismExtensions(C)(c, i, j, 10); assert ok cmpeq "true"; C := FieldCategory(); K := GF(25^2); E := ExtensionCategory(C, GF(5)); assert #Automorphisms(E)(K, 10) eq 4; E := ExtensionCategory(C, GF(25)); assert #Automorphisms(E)(K, 10) eq 2; Q := Rationals(); Qx := PolynomialRing(Q); k1 := NumberField(x^2 - 5); k1x := PolynomialRing(k1); k2 := NumberField(x^2 - 7); k2x := PolynomialRing(k2); k3 := NumberField(x^2 - 2); C := FieldCategory(); E := ExtensionCategory(C, Q); assert #Automorphisms(E)(k3, Infinity()) eq 8; E := ExtensionCategory(C, k1); assert #Automorphisms(E)(k3, Infinity()) eq 4; Q := Rationals(); Qx := PolynomialRing(Q); l1 := NumberField(x^2 - 5); l1x := PolynomialRing(l1); l2 := NumberField(x^2 - 7); l2x := PolynomialRing(l2); l3 := NumberField(x^2 - 2); C := FieldCategory(); E := ExtensionCategory(C, Q); assert #Isomorphisms(C)(k3, l3, Infinity()) eq 8; E := ExtensionCategory(C, k1); assert #Isomorphisms(E)(k3, l3, Infinity()) eq 4; //////////////////////////////////////////////////////////////////////////// // // The map support // f := map< GF(5) -> GF(5) | x :-> 3 >; image := ImageFunction(f); ok, b := image(2); assert ok and b eq 3; assert HasPreimageFunction(f) eq false; f := map< GF(5) -> GF(5) | x :-> 3, y :-> 1 >; assert HasPreimageFunction(f) eq false; import "/home/magma/package/Ring/FldFun/autiso.m" : CoercionMap, CompositionMap, CompositionMapSequence, ImportMap, InstallPreimage, GenericMap, GenericMapFromMap, InstallImage, InstallPreimageConstructor, InstallImageConstructor, HasInverseMap; f := CoercionMap(GF(5), GF(5)); assert f(1) eq 1; assert 1@@f eq 1; image := ImageFunction(f); ok, b := image(1); assert ok and b eq 1; ok, preim := HasPreimageFunction(f); assert ok; ok, b := preim(2); assert ok and b eq 2; g := CompositionMap(f, f); assert f(1) eq 1; assert 1@@f eq 1; image := ImageFunction(g); ok, b := image(1); assert ok and b eq 1; ok, preim := HasPreimageFunction(g); assert ok; ok, b := preim(2); assert ok and b eq 2; f := CoercionMap(GF(5), GF(5)); delete f`static`preimage; preim := function(x) print "Doing preim"; if x eq 1 then return false, _; end if; return true, x-1; end function; f := InstallPreimage(f, preim); ok, b := HasPreimage(f, GF(5)!2); assert ok; ok, b := HasPreimage(f, GF(5)!1); assert not ok; g := CompositionMap(f, f); g := CompositionMap(g, f); ok, b := HasPreimage(g, GF(5)!4); assert ok; ok, b := HasPreimage(g, GF(5)!3); assert not ok; L := [ f, f, f ]; g := CompositionMapSequence(L); ok, b := HasPreimage(g, GF(5)!4); assert ok; ok, b := HasPreimage(g, GF(5)!3); assert not ok; f := map< GF(5) -> GF(5) | x :-> 3 >; f := ImportMap(f, false); assert not HasPreimageFunction(f); preim := function(x) if x eq 1 then return false, _; end if; return true, x-1; end function; f := InstallPreimage(f, preim); assert HasPreimageFunction(f); f := GenericMap(GF(5), GF(5)); image := function(x) return true, x; end function; f := InstallImage(f, image); assert f(2) eq 2; f := InstallPreimage(f, image); assert 2@@f eq 2; assert Preimage(f, GF(5)!2) eq 2; f := map< GF(5) -> GF(5) | x :-> 3 >; f := ImportMap(f, false); g := GenericMapFromMap(f); assert g(1) eq 3; image := ImageFunction(g); ok, preim := HasPreimageFunction(g); assert not ok; preimconstr := function(static) print "Construction preimage"; return true, function(x) return true, x; end function; end function; g := InstallPreimageConstructor(g, preimconstr); ok, preim := HasPreimageFunction(g); assert ok; assert 4@@g eq 4; assert not assigned g`static`preimageconstr; ok, preim := HasPreimageFunction(g); assert ok; assert 4@@g eq 4; f := GenericMap(GF(5), GF(5)); imageconstr := function(static) print "Construction image"; return true, function(x) return true, x+1; end function; end function; preimageconstr := function(static) print "Construction preimage"; return true, function(x) return true, x-1; end function; end function; f := InstallImageConstructor(f, imageconstr); f := InstallPreimageConstructor(f, preimageconstr); assert f(1) eq 2; assert not assigned f`static`imageconstr; assert f(2) eq 3; assert 2@@f eq 1; assert not assigned f`static`preimageconstr; assert 3@@f eq 2; ok, g := HasInverseMap(f); assert ok; assert g(2) eq 1; assert 1@@g eq 2; f := GenericMap(GF(5), GF(5)); imageconstr := function(static) print "Construction image"; return true, function(x) return true, x+1; end function; end function; preimageconstr := function(static) print "Construction preimage"; return true, function(x) return true, x-1; end function; end function; f := InstallImageConstructor(f, imageconstr); f := InstallPreimageConstructor(f, preimageconstr); image := ImageFunction(f : Lazy := true); assert image(3) eq true; ok, g := HasInverseMap(f); assert ok; assert g(3) eq 2;