diff --git a/lib/cyclotom.gi b/lib/cyclotom.gi index 77c2cc128c..a6e7c66664 100644 --- a/lib/cyclotom.gi +++ b/lib/cyclotom.gi @@ -2002,8 +2002,8 @@ BindGlobal("CompareCyclotomicCollectionHelper_Filters", [ BindGlobal("CompareCyclotomicCollectionHelper_Proxies", [ [ 1 ], [ 0, 1 ], [ -1, 0, 1 ], [ -1, 0, 1, E(4) ], - [ -1, 0, 1/2, 1 ], [ -1, 0, 1, 1/2, E(4) ], - [ -1, 0, 1, 1/2, E(4), E(9) ], fail + [ -1, 0, 1/2, 1 ], [ -1, 0, 1/2, 1, E(4), 1/2+E(4) ], + [ -1, 0, 1/2, 1, E(4), 1/2+E(4), E(9) ], fail ] ); if IsHPCGAP then @@ -2033,6 +2033,7 @@ function (A,B) return ab[1] = ab[2]; end ); + InstallMethod( IsSubset, "for certain cyclotomic semirings", [IsCyclotomicCollection and IsSemiringWithOne, IsCyclotomicCollection and IsSemiringWithOne], @@ -2058,6 +2059,20 @@ function (A,B) end ); +InstallMethod( Union2, "for certain cyclotomic semirings", + [IsCyclotomicCollection and IsSemiringWithOne, + IsCyclotomicCollection and IsSemiringWithOne], +function (A,B) + local ab, i; + ab := CompareCyclotomicCollectionHelper(A, B); + # Verify that we recognized both A and B, otherwise give up. + if fail in ab then TryNextMethod(); fi; + i := Position( CompareCyclotomicCollectionHelper_Proxies, Union2( ab[1], ab[2] ) ); + if i = fail then TryNextMethod(); fi; + return CompareCyclotomicCollectionHelper_Semirings[i]; +end ); + + ############################################################################# ## #E diff --git a/tst/testinstall/cyclotom.tst b/tst/testinstall/cyclotom.tst index 57eac67902..f1a3389bc4 100644 --- a/tst/testinstall/cyclotom.tst +++ b/tst/testinstall/cyclotom.tst @@ -317,6 +317,35 @@ Error, COEFFSCYC: must be a cyclotomic (not a boolean or fail) gap> CycList([1,fail]); Error, CycList: each entry must be a rational (not a boolean or fail) +# +# Some tests for some operations on certain pre-defined infinite collections +# of cyclotomics, which are implemented using CompareCyclotomicCollectionHelper. +# For the tests, we exploit that the supported collections can be grouped into +# two totally ordered chains. +# +gap> sets:=[ PositiveIntegers, NonnegativeIntegers, Integers, Rationals, GaussianRationals, Cyclotomics ];; +gap> r:=[1..Length(sets)];; +gap> SetX(r, r, {i,j} -> Intersection(sets[i],sets[j]) = sets[Minimum(i,j)]); +[ true ] +gap> SetX(r, r, {i,j} -> Union(sets[i],sets[j]) = sets[Maximum(i,j)]); +[ true ] +gap> SetX(r, r, {i,j} -> IsSubset(sets[i],sets[j]) = (i>=j)); +[ true ] +gap> SetX(r, r, {i,j} -> (sets[i]=sets[j]) = (i=j)); +[ true ] + +# +gap> sets:=[ PositiveIntegers, NonnegativeIntegers, Integers, GaussianIntegers, GaussianRationals, Cyclotomics ];; +gap> r:=[1..Length(sets)];; +gap> SetX(r, r, {i,j} -> Intersection(sets[i],sets[j]) = sets[Minimum(i,j)]); +[ true ] +gap> SetX(r, r, {i,j} -> Union(sets[i],sets[j]) = sets[Maximum(i,j)]); +[ true ] +gap> SetX(r, r, {i,j} -> IsSubset(sets[i],sets[j]) = (i>=j)); +[ true ] +gap> SetX(r, r, {i,j} -> (sets[i]=sets[j]) = (i=j)); +[ true ] + # gap> STOP_TEST( "cyclotom.tst", 1);