Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/cyclotom.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,20 @@ function (A,B)
end );


InstallMethod( IsSubset, "for a cyclotomic semiring and a range",
[IsCyclotomicCollection and IsSemiringWithOne,
IsRange],
function (D, R)
if IsEmpty(R) then return true; fi;
# Since D is a semiring-with-one, and thus in particular an additive magma,
# it suffices to check whether the start and end point of the given range
# are contained in it. Actually it suffices if the smaller one is contained
# in it, but figuring out which end is smaller is more work than just
# directly checking both end points.
return First(R) in D and Last(R) in D;
end );


InstallMethod( Intersection2, "for certain cyclotomic semirings",
[IsCyclotomicCollection and IsSemiringWithOne,
IsCyclotomicCollection and IsSemiringWithOne],
Expand Down
13 changes: 12 additions & 1 deletion tst/testinstall/cyclotom.tst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#@local a,cyc,gm,i,l1,l2,l3,mat,n,r,x,y,z,sets
#@local a,b,cyc,gm,i,l1,l2,l3,mat,n,r,ranges,s,x,y,z,sets
gap> START_TEST("cyclotom.tst");

# Check basic arithmetic operations.
Expand Down Expand Up @@ -352,5 +352,16 @@ gap> SetX(r, r, {i,j} -> IsSubset(sets[i],sets[j]) = (i>=j));
gap> SetX(r, r, {i,j} -> (sets[i]=sets[j]) = (i=j));
[ true ]

#
# IsSubset for cyclotomic semirings and ranges for large bounds
#
gap> sets:=[ PositiveIntegers, NonnegativeIntegers, Integers, GaussianIntegers, GaussianRationals, Cyclotomics ];;
gap> b:=2^(8*GAPInfo.BytesPerVariable - 6);;
gap> ranges:=[ [-2..-1], [-1..0], [-1..1], [0..1], [1..2], [-b..-1], [-b..0], [-b..1], [-1..b], [0..b], [1..b], [-b,b]];;
Copy link
Member Author

@limakzi limakzi Mar 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note test contains a test for a list as well.
The cyclotomics must not be subset of finite list.
My concern is whether we should split this test case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused as to what you are talking about here.

Ah -- is it maybe the [-b,b] at the end? That's a typo, what I meant is this:

Suggested change
gap> ranges:=[ [-2..-1], [-1..0], [-1..1], [0..1], [1..2], [-b..-1], [-b..0], [-b..1], [-1..b], [0..b], [1..b], [-b,b]];;
gap> ranges:=[ [-2..-1], [-1..0], [-1..1], [0..1], [1..2], [-b..-1], [-b..0], [-b..1], [-1..b], [0..b], [1..b], [-b..b]];;

gap> SetX(ranges, sets, {r,s} -> IsSubset(s,r) = (IsEmpty(r) or (First(r) in s and Last(r) in s)));
[ true ]
gap> SetX(ranges, sets, {r,s} -> not IsSubset(r,s));
[ true ]

#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I wrote that I'd suggest to keep the tests for ranges and lists apart, my idea was to insert something like this, here below the ranges tests:

Suggested change
#
#
gap> lists:=[ [-2,-1], [], [-1,0,1], [0,1], [1,2], [-b,-1], [-b,0], [-b,1], [-1,b], [0,b], [1,b], [-b,b]];;
#
gap> SetX(ranges, lists, {r,s} -> IsSubset(s,r) = (IsEmpty(r) or (First(r) in s and Last(r) in s)));
[ true ]
gap> SetX(ranges, lists, {r,s} -> not IsSubset(r,s));
[ true ]

gap> STOP_TEST("cyclotom.tst");
Loading