diff --git a/src/ext/gap/console.g b/src/ext/gap/console.g index 57043ff..db8b925 100644 --- a/src/ext/gap/console.g +++ b/src/ext/gap/console.g @@ -1,6 +1,6 @@ -# If we are loaded with a workspace then $SAGE will be defined and in +# If we are loaded with a workspace then \$SAGE will be defined and in # that case we need to call StartInteract so that the pager will be # set correctly. See trac #5043. -if IsBound($SAGE) then - $SAGE.StartInteract(); +if IsBound(\$SAGE) then + \$SAGE.StartInteract(); fi; diff --git a/src/ext/gap/sage.g b/src/ext/gap/sage.g index 8535b7d..2216fda 100644 --- a/src/ext/gap/sage.g +++ b/src/ext/gap/sage.g @@ -2,15 +2,15 @@ # # SAGE support utilities to read into the GAP session. # -$SAGE := rec(); +\$SAGE := rec(); -$SAGE.OldPager := Pager; +\$SAGE.OldPager := Pager; -$SAGE.NewPager := +\$SAGE.NewPager := function( data ) local str, lines, line, fn, start; - str := OutputTextFile($SAGE.tempfile,false); + str := OutputTextFile(\$SAGE.tempfile,false); start := 1; if IsRecord(data) then lines := data.lines; @@ -30,38 +30,38 @@ $SAGE.NewPager := Print("Page from ",start,"\n"); end; -$SAGE.StartInteract := function() +\$SAGE.StartInteract := function() MakeReadWriteGlobal("Pager"); - Pager := $SAGE.OldPager; - HELP_VIEWER_INFO.screen.show := $SAGE.OldPager; + Pager := \$SAGE.OldPager; + HELP_VIEWER_INFO.screen.show := \$SAGE.OldPager; MakeReadOnlyGlobal("Pager"); end; -$SAGE.StopInteract := function() +\$SAGE.StopInteract := function() MakeReadWriteGlobal("Pager"); - Pager := $SAGE.NewPager; - HELP_VIEWER_INFO.screen.show := $SAGE.NewPager; + Pager := \$SAGE.NewPager; + HELP_VIEWER_INFO.screen.show := \$SAGE.NewPager; MakeReadOnlyGlobal("Pager"); end; -$SAGE.StopInteract(); +\$SAGE.StopInteract(); -#$SAGE.ErrorHandler := function(m,a,m2,mode) +#\$SAGE.ErrorHandler := function(m,a,m2,mode) # PrintTo("*errout*", m); # if a <> fail then # PrintTo("*errout*",a); # fi; -# SetErrorHandler($SAGE.ErrorHandler); +# SetErrorHandler(\$SAGE.ErrorHandler); # return true; #end; -#SetErrorHandler($SAGE.ErrorHandler); +#SetErrorHandler(\$SAGE.ErrorHandler); SetAllInfoLevels(0); -$SAGE.OperationsAdmittingFirstArgument := function(obj) +\$SAGE.OperationsAdmittingFirstArgument := function(obj) local hits, myflags, i, flagss, flags; hits := []; myflags := FlagsType(TypeObj(obj)); @@ -78,7 +78,7 @@ $SAGE.OperationsAdmittingFirstArgument := function(obj) end; -$SAGE.CleanOperationName := function(name) +\$SAGE.CleanOperationName := function(name) local lt, ls; lt := Length("Tester("); if Length(name) > lt and name{[1..lt]} = "Tester(" then @@ -91,7 +91,7 @@ $SAGE.CleanOperationName := function(name) return name; end; -$SAGE.HasAtLeastOneMethodAsFirstArgument := function(op,obj) +\$SAGE.HasAtLeastOneMethodAsFirstArgument := function(op,obj) local t, f, n, meths, i; t := TypeObj(obj); f := FlagsType(t); @@ -107,11 +107,11 @@ $SAGE.HasAtLeastOneMethodAsFirstArgument := function(op,obj) end; -$SAGE.PlausibleTabCompletionsForSage := function(o) +\$SAGE.PlausibleTabCompletionsForSage := function(o) local ops, opnames; - ops := Filtered($SAGE.OperationsAdmittingFirstArgument(o), op -> - $SAGE.HasAtLeastOneMethodAsFirstArgument(op,o)); - opnames := List(ops, op -> $SAGE.CleanOperationName(NameFunction(op))); + ops := Filtered(\$SAGE.OperationsAdmittingFirstArgument(o), op -> + \$SAGE.HasAtLeastOneMethodAsFirstArgument(op,o)); + opnames := List(ops, op -> \$SAGE.CleanOperationName(NameFunction(op))); return Concatenation(opnames, GLOBAL_FUNCTION_NAMES); end; diff --git a/src/sage/groups/finitely_presented.py b/src/sage/groups/finitely_presented.py index 92a4393..fd856ef 100644 --- a/src/sage/groups/finitely_presented.py +++ b/src/sage/groups/finitely_presented.py @@ -1168,9 +1168,7 @@ class FinitelyPresentedGroup(GroupMixinLibGAP, UniqueRepresentation, You can attempt to reduce the presentation of the output group:: sage: D = C2.semidirect_product(C8, hom); D - Finitely presented group < a, b, c, d | - a^2, b^-1*a^-1*b*a*d^-1*c^-1, c^-1*a^-1*c*a*d^-1, d^-1*a^-1*d*a, - b^2*c^-1, c^-1*b^-1*c*b, d^-1*b^-1*d*b, c^2*d^-1, d^-1*c^-1*d*c, d^2 > + Finitely presented group < a, b | a^2, b^8, a^-1*b*a*b > sage: D = C2.semidirect_product(C8, hom, reduced=True); D Finitely presented group < a, b | a^2, (a*b)^2, b^8 > @@ -1178,10 +1176,9 @@ class FinitelyPresentedGroup(GroupMixinLibGAP, UniqueRepresentation, sage: C4 = groups.presentation.Cyclic(4) sage: hom = (C3.gens(), [(C4.gens(), C4.gens())]) sage: C3.semidirect_product(C4, hom) - Finitely presented group < a, b, c | - a^3, b^-1*a^-1*b*a, c^-1*a^-1*c*a, b^2*c^-1, c^-1*b^-1*c*b, c^2 > + Finitely presented group < a, b | a^3, b^4, a^-1*b*a*b^-1 > sage: D = C3.semidirect_product(C4, hom, reduced=True); D - Finitely presented group < a, b | a^3, b^4, b^-1*a^-1*b*a > + Finitely presented group < a, b | a^3, b^4, a^-1*b*a*b^-1 > sage: D.as_permutation_group().is_cyclic() True @@ -1193,9 +1190,7 @@ class FinitelyPresentedGroup(GroupMixinLibGAP, UniqueRepresentation, sage: C12 = groups.presentation.Cyclic(12) sage: hom = (C5.gens(), [(C12.gens(), C12.gens())]) sage: sp = C5.semidirect_product(C12, hom, check=False); sp - Finitely presented group < a, b, c, d | - a^5, b^-1*a^-1*b*a, c^-1*a^-1*c*a, d^-1*a^-1*d*a, b^2*d^-1, - c^-1*b^-1*c*b, d^-1*b^-1*d*b, c^3, d^-1*c^-1*d*c, d^2 > + Finitely presented group < a, b | a^5, b^12, a^-1*b*a*b^-1 > sage: sp.as_permutation_group().is_cyclic(), sp.order() (True, 60) diff --git a/src/sage/groups/matrix_gps/matrix_group.py b/src/sage/groups/matrix_gps/matrix_group.py index 698a587..3e200e6 100644 --- a/src/sage/groups/matrix_gps/matrix_group.py +++ b/src/sage/groups/matrix_gps/matrix_group.py @@ -584,19 +584,19 @@ class MatrixGroup_gap(GroupMixinLibGAP, MatrixGroup_generic, ParentLibGAP): sage: i = iter(GL(6,5)) sage: [ next(i) for j in range(8) ] [ - [1 0 0 0 0 0] [4 0 0 0 0 1] [0 4 0 0 0 0] [0 4 0 0 0 0] - [0 1 0 0 0 0] [4 0 0 0 0 0] [0 0 4 0 0 0] [0 0 4 0 0 0] - [0 0 1 0 0 0] [0 4 0 0 0 0] [0 0 0 4 0 0] [0 0 0 4 0 0] - [0 0 0 1 0 0] [0 0 4 0 0 0] [0 0 0 0 4 0] [0 0 0 0 4 0] - [0 0 0 0 1 0] [0 0 0 4 0 0] [0 0 0 0 0 4] [0 0 0 0 0 4] - [0 0 0 0 0 1], [0 0 0 0 4 0], [1 4 0 0 0 0], [2 4 0 0 0 0], + [1 0 0 0 0 0] [2 0 0 0 0 0] [3 0 0 0 0 0] [3 2 0 0 0 0] + [0 1 0 0 0 0] [0 1 0 0 0 0] [0 1 0 0 0 0] [0 1 0 0 0 0] + [0 0 1 0 0 0] [0 0 1 0 0 0] [0 0 1 0 0 0] [0 0 1 0 0 0] + [0 0 0 1 0 0] [0 0 0 1 0 0] [0 0 0 1 0 0] [0 0 0 1 0 0] + [0 0 0 0 1 0] [0 0 0 0 1 0] [0 0 0 0 1 0] [0 0 0 0 1 0] + [0 0 0 0 0 1], [0 0 0 0 0 1], [0 0 0 0 0 1], [0 0 0 0 0 1], - [3 0 0 0 0 1] [4 0 0 1 3 3] [0 0 0 2 0 0] [1 0 0 0 4 4] - [3 0 0 0 0 0] [4 0 0 0 3 3] [0 0 0 0 4 0] [1 0 0 0 0 4] - [0 4 0 0 0 0] [3 0 0 0 0 1] [2 2 0 0 0 2] [1 0 0 0 0 0] - [0 0 4 0 0 0] [3 0 0 0 0 0] [1 4 0 0 0 0] [0 1 0 0 0 0] - [0 0 0 4 0 0] [0 4 0 0 0 0] [0 2 4 0 0 0] [0 0 1 0 0 0] - [4 0 0 0 2 3], [2 0 3 4 4 4], [0 0 1 4 0 0], [0 0 0 1 0 0] + [2 1 0 0 0 0] [3 3 0 2 3 0] [2 4 0 1 4 0] [1 2 4 1 0 3] + [0 1 0 0 0 0] [0 1 0 0 0 0] [0 1 0 0 0 0] [0 1 0 0 0 0] + [0 0 1 0 0 0] [0 0 1 0 0 0] [0 0 1 0 0 0] [0 0 1 0 0 0] + [0 0 0 1 0 0] [0 0 0 1 0 0] [0 0 0 1 0 0] [0 0 0 1 0 0] + [0 0 0 0 1 0] [0 0 0 0 1 0] [0 0 0 0 1 0] [0 0 0 0 1 0] + [0 0 0 0 0 1], [0 0 0 0 0 1], [0 0 0 0 0 1], [0 0 0 0 0 1] ] This is the direct computation in GAP, which will just run diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py index 2a426f1..5295949 100644 --- a/src/sage/groups/perm_gps/permgroup.py +++ b/src/sage/groups/perm_gps/permgroup.py @@ -1548,18 +1548,23 @@ class PermutationGroup_generic(group.FiniteGroup): EXAMPLES:: - sage: SymmetricGroup(10).stabilizer(4)._order() + sage: G = SymmetricGroup(10).subgroup([(i, 10) for i in range(1, 10) if i != 4]) + sage: G._order() 362880 - sage: SymmetricGroup(10).stabilizer(4).stabilizer(5)._order() - 40320 - sage: SymmetricGroup(200).stabilizer(100)._order() == factorial(199) # this should be very fast - True TESTS:: sage: [SymmetricGroup(n).stabilizer(1)._gap_().Size() for n in [4..10]] [6, 24, 120, 720, 5040, 40320, 362880] - sage: [SymmetricGroup(n).stabilizer(1)._order() for n in [4..10]] + sage: special_gens = [ + ....: [(3,4), (2,4)], + ....: [(4,5), (3,5), (2,5)], + ....: [(5,6), (4,6), (3,6), (2,6)], + ....: [(6,7), (5,7), (4,7), (3,7), (2,7)], + ....: [(7,8), (6,8), (5,8), (4,8), (3,8), (2,8)], + ....: [(8,9), (7,9), (6,9), (5,9), (4,9), (3,9), (2,9)], + ....: [(9,10), (8,10), (7,10), (6,10), (5,10), (4,10), (3,10), (2,10)]] + sage: [SymmetricGroup(n).subgroup(gen)._order() for gen in special_gens] [6, 24, 120, 720, 5040, 40320, 362880] """ gens = self.gens() diff --git a/src/sage/interfaces/expect.py b/src/sage/interfaces/expect.py index 756f701..88dbf82 100644 --- a/src/sage/interfaces/expect.py +++ b/src/sage/interfaces/expect.py @@ -1423,13 +1423,13 @@ class StdOutContext: return self.interface def __exit__(self, typ, value, tb): - """ + r""" EXAMPLE:: sage: from sage.interfaces.expect import StdOutContext sage: with StdOutContext(gap): ....: gap('1+1') - $sage... + \$sage... """ if self.silent: return diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py index 1f446aa..198fe84 100644 --- a/src/sage/interfaces/gap.py +++ b/src/sage/interfaces/gap.py @@ -716,7 +716,7 @@ class Gap_generic(ExtraTabCompletion, Expect): sage: gap.eval('quit;') '' sage: a = gap(3) - ** Gap crashed or quit executing '$sage...:=3;;' ** + ** Gap crashed or quit executing '\$sage...:=3;;' ** Restarting Gap and trying again sage: a 3 @@ -858,7 +858,7 @@ class Gap_generic(ExtraTabCompletion, Expect): EXAMPLES:: sage: print gap.version() - 4.7... + 4.8... """ return self.eval('VERSION')[1:-1] @@ -1162,25 +1162,29 @@ class Gap(Gap_generic): return reduce_load_GAP, tuple([]) def _next_var_name(self): - """ + r""" Returns the next unused variable name. + Note that names starting with dollar signs are valid GAP + identifiers, but need to be escaped with a backslash starting + with GAP-4.8. + EXAMPLES:: sage: g = Gap() sage: g._next_var_name() - '$sage1' + '\\$sage1' sage: g(2)^2 4 sage: g._next_var_name() - '$sage...' + '\\$sage...' """ if len(self._available_vars) != 0: v = self._available_vars[0] del self._available_vars[0] return v self.__seq += 1 - return '$sage%s'%self.__seq + return r'\$sage%s'%self.__seq def _start(self): """ @@ -1324,7 +1328,7 @@ class Gap(Gap_generic): else: tmp_to_use = self._local_tmpfile() self.eval('SetGAPDocTextTheme("none")') - self.eval('$SAGE.tempfile := "%s";'%tmp_to_use) + self.eval(r'\$SAGE.tempfile := "%s";'%tmp_to_use) line = Expect.eval(self, "? %s"%s) Expect.eval(self, "? 1") match = re.search("Page from (\d+)", line) @@ -1384,7 +1388,7 @@ class Gap(Gap_generic): sage: gap._pre_interact() sage: gap._post_interact() """ - self._eval_line("$SAGE.StartInteract();") + self._eval_line(r'\$SAGE.StartInteract();') def _post_interact(self): """ @@ -1393,7 +1397,7 @@ class Gap(Gap_generic): sage: gap._pre_interact() sage: gap._post_interact() """ - self._eval_line("$SAGE.StopInteract();") + self._eval_line(r'\$SAGE.StopInteract();') def _eval_line_using_file(self, line): i = line.find(':=') @@ -1641,7 +1645,7 @@ class GapElement(GapElement_generic): """ from sage.misc.misc import uniq P = self.parent() - v = P.eval('$SAGE.OperationsAdmittingFirstArgument(%s)'%self.name()) + v = P.eval(r'\$SAGE.OperationsAdmittingFirstArgument(%s)'%self.name()) v = v.replace('Tester(','').replace('Setter(','').replace(')','').replace('\n', '') v = v.split(',') v = [ oper.split('"')[1] for oper in v ] diff --git a/src/sage/libs/gap/gap_includes.pxd b/src/sage/libs/gap/gap_includes.pxd index bd945c7..fa23ba5 100644 --- a/src/sage/libs/gap/gap_includes.pxd +++ b/src/sage/libs/gap/gap_includes.pxd @@ -131,7 +131,7 @@ cdef extern from "gap/objects.h": cdef int libGAP_LAST_TESTING_TNUM cdef extern from "gap/read.h": - void* libGAP_ReadEvalCommand(libGAP_Obj context) + void* libGAP_ReadEvalCommand(libGAP_Obj context, libGAP_UInt *dualSemicolon) void* libGAP_ReadEvalFile() void* libGAP_ReadEvalResult bint libGAP_READ_ERROR() diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx index 52a75be..d62b8e9 100644 --- a/src/sage/libs/gap/util.pyx +++ b/src/sage/libs/gap/util.pyx @@ -280,7 +280,7 @@ cdef libGAP_Obj gap_eval(str gap_string) except? NULL: libgap_start_interaction(cmd) try: sig_on() - status = libGAP_ReadEvalCommand(libGAP_BottomLVars) + status = libGAP_ReadEvalCommand(libGAP_BottomLVars, NULL) if status != libGAP_STATUS_END: libgap_call_error_handler() sig_off() @@ -464,7 +464,7 @@ def command(command_string): libgap_start_interaction(cmd) try: sig_on() - status = libGAP_ReadEvalCommand(libGAP_BottomLVars) + status = libGAP_ReadEvalCommand(libGAP_BottomLVars, NULL) if status != libGAP_STATUS_END: libgap_call_error_handler() sig_off()