Skip to content

Commit

Permalink
ExtendedImageSet is now a HashSet + all the consequences
Browse files Browse the repository at this point in the history
  • Loading branch information
egri-nagy committed Aug 12, 2023
1 parent daf71f9 commit a7c8412
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 39 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.9.7
Breaking changes: ContainsSet(sk, P) replaced with P in ExtendedImageSet(sk), since ExtendedImageSet is now a HashSet for faster lookup. SortedExtendedImageSet added for retaining the functionality of having a sorted list of the extended images.
0.9.6
MakeRepresentative added. To simplify the process of changing a representative, the primitve caching mechanism for the words navigating in the equivalence classes were removed. This makes computing the morphism for holonomy less performant. Proper memoization is to be added later.
0.9.5
Expand Down
2 changes: 2 additions & 0 deletions doc/holonomy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ can create, display and act on finite sets.
The skeleton of a transformation semigroup is a data structure containing information about the action on the state set. For instance, the set of images, their strongly connected components and mapping between and within these components. These details are calculated by the <Package>Semigrops</Package> package.
<#Include Label="Skeleton">
<#Include Label="ExtendedImageSet">
<#Include Label="SortedExtendedImageSet">

<#Include Label="Singletons">
<#Include Label="NonImageSingletons">
<#Include Label="RepresentativeSets">
Expand Down
31 changes: 26 additions & 5 deletions doc/mansections.xml
Original file line number Diff line number Diff line change
Expand Up @@ -524,17 +524,18 @@ Transformation( [ 1, 3, 1, 2 ] )
<#GAPDoc Label="ExtendedImageSet">
<ManSection>
<Attr Name="ExtendedImageSet" Arg="skeleton"/>
<Returns>The set of images of the semigroup action.</Returns>
<Returns>The extended set of images of the semigroup action.</Returns>
<Description>
The state set, the singletons and all image sets <M>X^s, s\in S</M>.
Stored in a HashSet, thus it is useful for quick checks for the existence of an image.
<Example>
gap> SgpDecFiniteSetDisplayOn();
gap> S := Semigroup(Transformation([1,1,3,3]));
&lt;commutative transformation semigroup of degree 4 with 1 generator&gt;
gap> sk := Skeleton(S);;
gap> ExtendedImageSet(sk);
[ {1,2,3,4}, {1,3}, {1}, {2}, {3}, {4} ]
gap> SgpDecFiniteSetDisplayOff();
gap> FiniteSet([1,3],4) in ExtendedImageSet(sk);
true
gap> FiniteSet([2,3],4) in ExtendedImageSet(sk);
false
</Example>
</Description>
</ManSection>
Expand Down Expand Up @@ -1032,6 +1033,26 @@ gap> Skeleton(FullTransformationSemigroup(4));
</ManSection>
<#/GAPDoc>

<#GAPDoc Label="SortedExtendedImageSet">
<ManSection>
<Func Name="SortedExtendedImageSet" Arg="skeleton"/>
<Returns>The extended set of images of the semigroup action sorted in descending order.</Returns>
<Description>
The state set, the singletons and all image sets <M>X^s, s\in S</M>.
<Example>
gap> SgpDecFiniteSetDisplayOn();
gap> S := Semigroup(Transformation([1,1,3,3]));
&lt;commutative transformation semigroup of degree 4 with 1 generator&gt;
gap> sk := Skeleton(S);;
gap> SortedExtendedImageSet(sk);
[ {1,2,3,4}, {1,3}, {1}, {2}, {3}, {4} ]
gap> SgpDecFiniteSetDisplayOff();
</Example>
</Description>
</ManSection>
<#/GAPDoc>


##T

<#GAPDoc Label="Chains">
Expand Down
3 changes: 2 additions & 1 deletion lib/finiteset.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
##
## finiteset.gd SgpDec package
##
## Copyright (C) 2010-2013
## Copyright (C) 2010-2023
##
## Attila Egri-Nagy, Chrystopher L. Nehaniv, James D. Mitchell
##
Expand All @@ -24,6 +24,7 @@ DeclareGlobalFunction("SgpDecFiniteSetDisplayOff");
DeclareGlobalFunction("FiniteSet");
DeclareSynonym("Cardinality",SizeBlist);
DeclareSynonym("FiniteSetSize",SizeBlist);
DeclareGlobalFunction("FiniteSetComparator");
DeclareGlobalFunction("OnFiniteSet");
DeclareGlobalFunction("IsIdentityOnFiniteSet");
DeclareGlobalFunction("IsSingleton");
Expand Down
12 changes: 11 additions & 1 deletion lib/finiteset.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
##
## finiteset.gi SgpDec package
##
## Copyright (C) 2010-2013
## Copyright (C) 2010-2023
##
## Attila Egri-Nagy, Chrystopher L. Nehaniv, James D. Mitchell
##
Expand Down Expand Up @@ -62,6 +62,16 @@ local i;
return true;
end);

#for sorting finitesets, first by size, then by content
InstallGlobalFunction(FiniteSetComparator,
function(A,B)
if SizeBlist(A) <> SizeBlist(B) then
return SizeBlist(A)>SizeBlist(B);
else
return A<B;
fi;
end);

################################################################################
### ToggleFiniSetDisplay #######################################################
InstallGlobalFunction(SgpDecFiniteSetDisplayOn,
Expand Down
2 changes: 1 addition & 1 deletion lib/lowerbound.gi
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ InstallGlobalFunction(CheckEssentialDependency, function(sk, d1, d2)

skJ := Skeleton(Semigroup(CalI2));

if ContainsSet( skJ, x2 ) then
if x2 in ExtendedImageSet(skJ) then
JGroup := PermutatorGroup(skJ, x2);

if Size(JGroup) > 1 then # the stricter test is PermutatorGroup(sk, x2) = JGroup
Expand Down
2 changes: 1 addition & 1 deletion lib/skeleton.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ DeclareAttribute("RepresentativeSets",IsSkeleton);
DeclareGlobalFunction("RepresentativeSetsOnDepth");

#functions
DeclareGlobalFunction("ContainsSet");
DeclareGlobalFunction("SortedExtendedImageSet");
DeclareGlobalFunction("TilesOf");
DeclareGlobalFunction("TilesContaining");
DeclareGlobalFunction("DepthOfSet");
Expand Down
40 changes: 14 additions & 26 deletions lib/skeleton.gi
Original file line number Diff line number Diff line change
Expand Up @@ -61,37 +61,25 @@ function(sk)
return Filtered(Singletons(sk), x-> not x in ForwardOrbit(sk));
end);

#for sorting finitesets, first by size, then by content
DescendingSizeSorter := function(v,w)
if SizeBlist(v) <> SizeBlist(w) then
return SizeBlist(v)>SizeBlist(w);
else
return v<w;
fi;
end;
MakeReadOnlyGlobal("DescendingSizeSorter");

# the image set extended with singletons and ordered by descending size
# we only need to add non-image singletons, as the base set is in the orbit
InstallMethod(ExtendedImageSet, "for a skeleton (SgpDec)", [IsSkeleton],
function(sk)
local imageset;
#we have to copy it
imageset := ShallowCopy(UnderlyingPlist(ForwardOrbit(sk)));
local extimgs;
extimgs := HashSet();
Perform(ForwardOrbit(sk), function(A) AddSet(extimgs,A);end);
#add the missing singletons
Perform(NonImageSingletons(sk),
function(x) Add(imageset,x);end);
#now sorting descending by size
Sort(imageset,DescendingSizeSorter);
return imageset;
Perform(NonImageSingletons(sk), function(A) AddSet(extimgs,A);end);
return extimgs;
end);

InstallGlobalFunction(ContainsSet,
function(sk, set)
#checking whether we have the set somewhere
return set in ForwardOrbit(sk)
or set = BaseSet(sk)
or set in NonImageSingletons(sk);
#just to give a nice descending view of the sets
InstallGlobalFunction(SortedExtendedImageSet,
function(sk)
local sets;
sets := ShallowCopy(AsSet(ExtendedImageSet(sk)));
Sort(sets,FiniteSetComparator);
return sets;
end);

################################################################################
Expand All @@ -102,7 +90,7 @@ InstallMethod(InclusionCoverRelation,
"for a skeleton (SgpDec)", [IsSkeleton],
function(sk)
return HasseDiagramBinaryRelation(
PartialOrderByOrderingFunction(Domain(ExtendedImageSet(sk)),
PartialOrderByOrderingFunction(Domain(AsSet(ExtendedImageSet(sk))),
IsSubsetBlist));
end);

Expand Down Expand Up @@ -300,7 +288,7 @@ end);

InstallGlobalFunction(TilesOf,
function(sk,set)
if ContainsSet(sk,set) then
if set in ExtendedImageSet(sk) then
return Images(InclusionCoverRelation(sk),set);
else
return fail;
Expand Down
2 changes: 1 addition & 1 deletion lib/skeletongroups.gi
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ end);
InstallGlobalFunction(NontrivialRoundTripWords,
function(sk,set)
local roundtrips,rtws,nontrivs;
if not ContainsSet(sk,set) then return fail;fi;
if not (set in ExtendedImageSet(sk)) then return fail;fi;
rtws := RoundTripWords(sk,set);
roundtrips := List(rtws, w->EvalWordInSkeleton(sk,w));
nontrivs := Filtered([1..Size(roundtrips)],
Expand Down
6 changes: 3 additions & 3 deletions tst/skeleton.tst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ gap> S := Semigroup(Transformation([5,5,5,5,5]));;
gap> sk := Skeleton(S);;
gap> Display(sk);
<skeleton of Semigroup( [ Transformation( [ 5, 5, 5, 5, 5 ] ) ] )>
gap> ExtendedImageSet(sk);
gap> SortedExtendedImageSet(sk);
[ {1,2,3,4,5}, {1}, {2}, {3}, {4}, {5} ]
gap> ImageWitness(sk, FiniteSet([1..5]), FiniteSet([5]));
fail
Expand Down Expand Up @@ -62,7 +62,7 @@ gap> Q := FiniteSet([3,4],6);;
gap> IsSubsetBlist(OnFiniteSet(Q, EvalWordInSkeleton(sk,
> SubductionWitness(sk,P,Q))),P);
true
gap> ExtendedImageSet(sk);
gap> SortedExtendedImageSet(sk);
[ {1,2,3,4,5,6}, {1,2,3,4}, {1,2,3}, {4,5,6}, {1,2}, {1,3}, {1,4}, {2,3},
{2,4}, {3,4}, {4,5}, {4,6}, {5,6}, {1}, {2}, {3}, {4}, {5}, {6} ]
gap> Interpret(sk, 1,1);
Expand All @@ -77,7 +77,7 @@ gap> DominatingChains(sk, [FiniteSet([1],6)]);
[ {1,2,3,4,5,6}, {1,2,3,4}, {1,2,3}, {1,3}, {1} ],
[ {1,2,3,4,5,6}, {1,2,3,4}, {1,4}, {1} ] ]
gap> sk := Skeleton(Semigroup(Transformation([5,5,5,5,5])));;
gap> ExtendedImageSet(sk);
gap> SortedExtendedImageSet(sk);
[ {1,2,3,4,5}, {1}, {2}, {3}, {4}, {5} ]
gap> NonImageSingletonClasses(sk);
[ [ {4} ], [ {3} ], [ {2} ], [ {1} ] ]
Expand Down

0 comments on commit a7c8412

Please sign in to comment.