##################################################### ## ## qaos.mpl ## ## Maple interface to the KANT databases (Qaos) ## ## Copyright (C) 2005 by Sebastian Freundt, Sebastian Pauli ## Authors: Sebastian Freundt ## Sebastian Pauli ## ## Fakultaet II - Institut fuer Mathematik ## Technische Unversitaet Berlin ## Strasse des 17. Juni 136 ## D-10623 Berlin ## Germany ## ## Created: 2005/09/24 ## ## This program is free software; you can redistribute it and/or modify it ## under a BSD-like licence. ## ## Redistribution and use in source and binary forms, with or without ## modification, are permitted provided that the following conditions are met: ## Redistributions of source code must retain the above copyright notice, this ## list of conditions and the following disclaimer. ## Redistributions in binary form must reproduce the above copyright notice, ## this list of conditions and the following disclaimer in the documentation ## and/or other materials provided with the distribution. ## Neither the name of Technische Unversitaet Berlin nor the names of its ## contributors may be used to endorse or promote products derived from this ## software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ## POSSIBILITY OF SUCH DAMAGE. ## ##################################################### Qaos := module() description "Maple interface to the QaoS databases"; export QaosNumberField, DefiningPolynomial, Regulator, GaloisGroup, Signature, Degree, Discriminant, ClassNumber, ClassGroup, QaosTransitiveGroup, PermutationGroup, GroupOrder, IsAbelian, IsMetaAbelian, IsSimple, IsSolvable, IsSuperSolvable, IsCyclic, IsPrimitive, IsNilpotent, LengthCompositionSeries, TransitiveGroupIdentification, LengthLowerCentralSeries; local QaosQueryTypes, QaosError, UrlEncode, QaosURL, QaosQuery, ModuleLoad, ModulePrint, ModuleApply; ModuleLoad := proc() global `print/QAOSNUMBERFIELD`, `print/QAOSTRANSITIVEGROUP`; # number field ######################### `print/QAOSNUMBERFIELD` := proc(q) `Number field defined by`,q:-generator; end proc; TypeTools[AddType](qaosnumberfield, t->evalb(op(0,t)='QAOSNUMBERFIELD')); # transitive group ##################### `print/QAOSTRANSITIVEGROUP` := proc(q) `transitive group`,q:-name; end proc; TypeTools[AddType](qaostransitivegroup, t->evalb(op(0,t)='QAOSTRANSITIVEGROUP')); end proc; ModuleLoad(); ModulePrint := proc() printf("\nMaple interface to the QaoS databases\n"); printf("by Sebastian Freundt and Sebastian Pauli\n"); end proc; ModuleApply := proc() printf("use QaosNumberField to query the KANT database of number fields.\n"); printf("type Describe(QaosNumberField) for instructions.\n\n"); printf("use QaosTransitiveGroup to query the QaoS database of transitive groups.\n"); printf("type Describe(QaosTransitiveGroup) for instructions.\n"); end proc; ################################################# UrlEncode:= proc(string) local tmp; tmp := StringTools['SubstituteAll'](string," ","+"); tmp := StringTools['SubstituteAll'](tmp,"<","%3C"); tmp := StringTools['SubstituteAll'](tmp,"=","%3D"); tmp := StringTools['SubstituteAll'](tmp,">","%3E"); tmp; end proc; ################################################# QaosURL := "http://www.math.tu-berlin.de/cgi-bin/kant/qaos/query.scm"; QaosQueryTypes := Record('numberfield'= Record('type'="?type=anf", 'last_query'="", 'offset'=0, 'limit'=10, 'print'=QAOSNUMBERFIELD), 'transitivegroup'= Record('type'="?type=trnsg", 'last_query'="", 'offset'=0, 'limit'=10, 'print'=QAOSTRANSITIVEGROUP) ); QaosError := "usage Qaos{NumberField,TransitiveGroup}([query::string>],[limit::integer])"; ################################################# QaosQuery := proc(kind,narguments,arguments) local uri, query, result, L, i; #print("args ",arguments); if narguments = 0 then if kind:-last_query ="" then error "no previous query"; end if; else if type(arguments[1],integer) then if arguments[1] > 0 then kind:-limit := arguments[1]; end if; #print("changing limit to ",arguments[1]); elif type(arguments[1],string) then kind:-last_query := arguments[1]; if narguments = 2 and type(arguments[2],integer) then kind:-limit := arguments[2]; end if; else error QaosError; end if; end if; #print("constructing uri"); uri:= cat( QaosURL, kind:-type, "&limit=",convert(kind:-limit,string), "&offset=",convert(kind:-offset,string), "&action=Go", "&cgall=on", "&output=maple", "&query=", UrlEncode(kind:-last_query)); #print(uri); result := process['popen'](cat("curl -s \"",uri,"\""),READ); L := fscanf(result,%a); process['pclose'](result); #print("L",L); if nops(L)=0 or L=[] or L=[[]] then return []; else #print("L",L); L := eval(L[1]):-base; end if; #print("L",L); # last entry of query result does not contain a field if nops(L)<>0 then L := L[1..nops(L)-1]; #print(L); # i am not sure why these lines should be here. # without them maple complains that i is not a module below. #for i in L do (kind:-print(i)); od; # make QAOSNUMBERFIELD from the records L := [seq(kind:-print(i),i in L)]; end if; kind:-offset := kind:-offset+kind:-limit; return L; end proc; ####################################################################### # transitive group functions -- query and access QaosTransitiveGroup:=proc() description ##################### "QaosTransitiveGroup(query::string[,limit::integer])::list(qaostransitivegroup)", "QaosTransitiveGroup([limit::integer])::list(qaostransitivegroup)", "", "Searches the QaoS transitive group database in Berlin. Returns at most 'limit' matches. \ The string 'query' is made up of terms of the form invariant=value, where invariant is one of:", "", "Keywords with integer values, Syntax: keyword integer", "", "d, deg, degr, degree: The degree of the transitive group ", "o, ord, order: The order of the transitive group ", "of, ord fac, order factor: A factor of the order of the transitive group ", "n, num, numb: The number of the transitive group in the tn nomenclature ", "csl, compser len, compseries length: The length of the composition series ", "lcsl, lcentser len, lowercentralseries length: The length of the lower central series", "", "Keywords with string values, Syntax: keyword 'string'", "", "name: The name of the transitive group, either a trivial name or a name in the tn nomenclature", "", "Keywords with boolean values, Syntax: keyword | not keyword", "", "a ab abel abelian: The abelian property of the group", "ma metab metabel metabelian: The metabelian property of the group", "c cyc cyclic: The cyclic property of the group", "p pr prim primitive: The primitive property of the group", "si sim simp simple: The simple property of the group", "s sol solv solvable: The solvable property of the group", "ss supsol supsolv supersolvable: The supersolvable property of the group", "np nilp nilpot nilpotent: The nilpotent property of the group", "", "If value is a number then >, <, >=, <= or != can be used instead of =.\ You can omit the relation if you want it to be =.", "", "Called without an argument QaosTransitiveGroup returns more groups matching the previous search query.", "", "The procedure PermutationGroup converts groups from the database to permutation groups. ", "", "The invariants of the returned groups can be accessed withh the procedure: \ GroupOrder, IsAbelian, IsMetaAbelian, IsSimple, IsSolvable, IsSuperSolvable, IsCyclic, IsPrimitive, IsNilpotent, TransitiveGroupIdentification, LengthCompositionSeries.", "", "You must have 'curl' installed and properly configured in order to use the database."; # end description ################ return QaosQuery(QaosQueryTypes:-transitivegroup,nargs,[args]); end proc; PermutationGroup := overload([ proc(q::qaostransitivegroup) description "Convert a transitive group from the QaoS database into a permutation group."; option overload; local g, nelts, genlist, flatlist; # print("q",q); g := op(1,q); genlist := (convert(g:-perm_gens,list)); # print("genlist",genlist); flatlist := ListTools[Flatten](genlist); # print("flatlist",flatlist); nelts := max(seq(i,i in flatlist)); # print("nelts",nelts); return permgroup(nelts,g:-perm_gens); end proc, proc() return permgroup(args); end proc ]); GroupOrder := proc(q::qaostransitivegroup) return op(1,q):-ord; end; TransitiveGroupIdentification := proc(q::qaostransitivegroup) return [op(1,q):-deg,op(1,q):-num]; end; LengthCompositionSeries := proc(q::qaostransitivegroup) return op(1,q):-compser_l; end; LengthLowerCentralSeries := proc(q::qaostransitivegroup) return op(1,q):-lcentser_l; end; ####################################################################### # number field functions -- query and access QaosNumberField:=proc() description ##################### "QaosNumberField(query::string [,limit::integer])::list(qaosnumberfield)", "QaosNumberField([limit::integer])::list(qaosnumberfield)", "", "Searches the KANT number field database in Berlin. Returns at most 'limit' matches. \ The string 'query' is made up of terms of the form invariant=value, where invariant is one of:", "", "degree or deg,", "classnumber or classnum or class,", "real signature or sig-real or rsig,", "imaginary signature or sig-im or isig,", "discriminant or disc,", "regulator or reg, or", "galoisgroup or galgrp.", "", "If value is a number then >, <, >=,, <= or <> can be used instead of =.\ You can omit the relation if you want it to be =.\ The Galois group may be enclosed in single quotes, e.g. galoisgroup='S5' or\ galgrp is 's5'. Several terms are implied to be connected by AND, e.g.\ degree=3 cls 2 |disc| <= 9876.", "", "Called without an argument QaosNumberField returns more fields matching the previous search query.", "", "The procedure DefiningPolynomial returns a defining polynomial of a field. \ The invariants of the returned fields can be accessed withh the procedure: \ ClassGroup, ClassNumber, Degree, Discriminant, GaloisGroup, Regulator, Signature ", "", "Properties of the Galois group can be obtained with the procedures: IsAbelian, IsMetaAbelian, IsSimple, IsSolvable, IsSuperSolvable, IsCyclic, IsPrimitive, IsNilpotent", "", "You must have 'curl' installed and properly configured in order to use the database."; # end description ################ # print("args ",args); return QaosQuery(QaosQueryTypes:-numberfield,nargs,[args]); end proc; DefiningPolynomial := proc (q::qaosnumberfield) description "The defining polynomial of a number field from the KANT database."; return op(1,q):-generator; end proc; Regulator := proc (q::qaosnumberfield) description "The regulator of a number field from the KANT database."; return op(1,q):-reg; end proc; GaloisGroup := proc (q::qaosnumberfield) description "A name of the Galois group of a number field from the KANT database."; return op(1,q):-galois_group; end proc; Signature := proc (q::qaosnumberfield) description "The signature [r_1,r_2] of a number field from the KANT database."; return [op(1,q):-sig_re,op(1,q):-sig_im]; end proc; ClassNumber := proc (q::qaosnumberfield) description "The class number of a number field from the KANT database."; return op(1,q):-class_num; end proc; ClassGroup := proc (q::qaosnumberfield) description "The class group of a number field from the KANT database."; return op(1,q):-class_group; end proc; Discriminant := proc (q::qaosnumberfield) description "The discriminant of a number field from the KANT database."; return op(1,q):-disc; end proc; #################################################### # invariants for number fields and transitive groups Degree := overload([ #description "The degree of a field extension or transitive group from the Qaos database."; proc (q::qaosnumberfield) option overload; return op(1,q):-deg; end proc, proc(q::qaostransitivegroup) option overload; return op(1,q):-deg; end proc ]); IsAbelian := overload([ proc(q::qaostransitivegroup) option overload; return op(1,q):-abel; end proc, proc(q::qaosnumberfield) option overload; return op(1,q):-abel; end proc ]); IsMetaAbelian := overload([ proc(q::qaostransitivegroup) option overload; return op(1,q):-metab; end proc, proc(q::qaosnumberfield) option overload; return op(1,q):-metab; end proc ]); IsCyclic := overload([ proc(q::qaostransitivegroup) option overload; return op(1,q):-cyc; end proc, proc(q::qaosnumberfield) option overload; return op(1,q):-cyc; end proc ]); IsPrimitive := overload([ proc(q::qaostransitivegroup) option overload; return op(1,q):-prim; end proc, proc(q::qaosnumberfield) option overload; return op(1,q):-prim; end proc ]); IsSimple := overload([ proc(q::qaostransitivegroup) option overload; return op(1,q):-simp; end proc, proc(q::qaosnumberfield) option overload; return op(1,q):-simp; end proc ]); IsSolvable := overload([ proc(q::qaostransitivegroup) option overload; return op(1,q):-solv; end proc, proc(q::qaosnumberfield) option overload; return op(1,q):-solv; end proc ]); IsSuperSolvable := overload([ proc(q::qaostransitivegroup) option overload; return op(1,q):-supsolv; end proc, proc(q::qaosnumberfield) option overload; return op(1,q):-supsolv; end proc ]); proc(q::qaostransitivegroup) option overload; return op(1,q):-supsolv; end; IsNilpotent := overload([ proc(q::qaostransitivegroup) option overload; return op(1,q):-nilpot; end proc, proc(q::qaosnumberfield) option overload; return op(1,q):-nilpot; end proc ]); end module; with(Qaos);