Skip to content

Commit 6eb2b82

Browse files
authored
Merge branch 'master' into bellmanford
2 parents b76171d + 576b836 commit 6eb2b82

File tree

12 files changed

+352
-24
lines changed

12 files changed

+352
-24
lines changed

.github/workflows/stale.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
2+
#
3+
# You can adjust the behavior by modifying this file.
4+
# For more information, see:
5+
# https://github.com/actions/stale
6+
name: Mark stale issues and pull requests
7+
8+
on:
9+
schedule:
10+
- cron: '42 0 * * *'
11+
12+
jobs:
13+
stale:
14+
15+
runs-on: ubuntu-latest
16+
permissions:
17+
issues: write
18+
pull-requests: write
19+
20+
steps:
21+
- uses: actions/stale@v3
22+
with:
23+
repo-token: ${{ secrets.GITHUB_TOKEN }}
24+
stale-issue-message: 'Stale issue message'
25+
stale-pr-message: 'Stale pull request message'
26+
stale-issue-label: 'no-issue-activity'
27+
stale-pr-label: 'no-pr-activity'
28+
days-before-close: -1

doc/attr.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,3 +2429,40 @@ gap> Length(M);
24292429
</Description>
24302430
</ManSection>
24312431
<#/GAPDoc>
2432+
2433+
<#GAPDoc Label="NonUpperSemimodularPair">
2434+
<ManSection>
2435+
<Attr Name="NonUpperSemimodularPair" Arg="D"/>
2436+
<Attr Name="NonLowerSemimodularPair" Arg="D"/>
2437+
<Returns>A pair of vertices or <K>fail</K>.</Returns>
2438+
<Description>
2439+
<C>NonUpperSemimodularPair</C> returns a pair of vertices in the digraph
2440+
<A>D</A> that witnesses the fact that <A>D</A> does not represent an upper
2441+
semimodular lattice, if such a pair exists. <P/>
2442+
2443+
If the digraph <A>D</A> does not satisfy <Ref
2444+
Prop="IsLatticeDigraph"/>, then an error is given. Otherwise if the
2445+
digraph <A>D</A> does satisfy <Ref
2446+
Prop="IsLatticeDigraph"/>, then either a non-upper semimodular pair of
2447+
vertices is returned, or <K>fail</K> is returned if no such pair exists
2448+
(meaning that <A>D</A> is an upper semimodular lattice. <P/>
2449+
2450+
<C>NonLowerSemimodularPair</C> behaves in the analogous way to
2451+
<C>NonUpperSemimodularPair</C> with respect to lower semimodularity. <P/>
2452+
2453+
See <Ref Prop="IsUpperSemimodularDigraph"/> and <Ref
2454+
Prop="IsLowerSemimodularDigraph"/> for the definition of upper
2455+
semimodularity of a lattice.
2456+
2457+
<Example><![CDATA[
2458+
gap> D := DigraphFromDigraph6String(
2459+
> "&M~~sc`lYUZO__KIBboC_@h?U_?_GL?A_?c");
2460+
<immutable digraph with 14 vertices, 66 edges>
2461+
gap> NonLowerSemimodularPair(D);
2462+
[ 10, 9 ]
2463+
gap> NonUpperSemimodularPair(D);
2464+
fail
2465+
]]></Example>
2466+
</Description>
2467+
</ManSection>
2468+
<#/GAPDoc>

doc/digraph.xml

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -421,33 +421,52 @@ gap> D := DigraphByInNeighbours(IsMutableDigraph,
421421

422422
<#GAPDoc Label="AsDigraph">
423423
<ManSection>
424-
<Oper Name="AsDigraph" Arg="[filt, ]f[, n]"
425-
Label="for a transformation or perm"/>
424+
<Oper Name="AsDigraph" Arg="[filt, ]f[, n]" Label="for a binary relation"/>
426425
<Returns>A digraph, or <K>fail</K>.</Returns>
427426
<Description>
428-
If <A>f</A> is a transformation or permutation,
429-
and <A>n</A> is a non-negative integer
430-
such that the restriction of <A>f</A> to <C>[1..<A>n</A>]</C> defines
431-
a function of <C>[1..<A>n</A>]</C>, then <C>AsDigraph</C>
432-
returns the functional digraph with <A>n</A> vertices defined by
433-
<A>f</A>. See <Ref Prop="IsFunctionalDigraph"/>.
434-
<P/>
435-
436-
Specifically, the digraph returned by <C>AsDigraph</C> has <A>n</A> edges:
437-
for each vertex <C>v</C> in <C>[1..<A>n</A>]</C>, there is a unique edge
438-
with source <C>v</C>; this edge has range <C>v^<A>f</A></C>.
439-
<P/>
440427

441-
If the optional second argument <A>n</A> is not supplied, then
442-
the degree of the transformation <A>f</A>,
443-
or the largest moved point of the permutation <A>f</A>,
444-
as applicable, is used by default. If the restriction of
445-
<A>f</A> to <C>[1..<A>n</A>]</C> does not define a function of
446-
<C>[1..<A>n</A>]</C>, then <C>AsDigraph(<A>f</A>, <A>n</A>)</C>
447-
returns <K>fail</K>.
428+
If <A>f</A> is a binary relation represented as one of the following in
429+
&GAP;:
430+
<List>
431+
<Mark>
432+
a transformation
433+
</Mark>
434+
<Item>
435+
satisfying <Ref Filt="IsTransformation" BookName="ref"/>;
436+
</Item>
437+
<Mark>
438+
a permutation
439+
</Mark>
440+
<Item>
441+
satisfying <Ref Filt="IsPerm" BookName="ref"/>;
442+
</Item>
443+
<Mark>
444+
a partial perm
445+
</Mark>
446+
<Item>
447+
satisfying <Ref Filt="IsPartialPerm" BookName="ref"/>;
448+
</Item>
449+
<Mark>
450+
a binary relation
451+
</Mark>
452+
<Item>
453+
satisfying <Ref Filt="IsBinaryRelation" BookName="ref"/>;
454+
</Item>
455+
</List>
456+
and <A>n</A> is a non-negative integer, then <C>AsDigraph</C> attempts
457+
to construct a digraph with <A>n</A> vertices whose edges are determined
458+
by <A>f</A>.<P/>
459+
460+
The digraph returned by <C>AsDigraph</C> has for each vertex
461+
<C>v</C> in <C>[1 .. <A>n</A>]</C>, an edge with source <C>v</C> and range
462+
<C>v ^ <A>f</A></C>. If <C>v ^ <A>f</A></C> is greater than <A>n</A> for any
463+
<C>v</C>, then <K>fail</K> is returned.
448464
<P/>
449465

450-
See also <Ref Attr="AsTransformation"/>.
466+
If the optional second argument <A>n</A> is not supplied, then the degree
467+
of the transformation <A>f</A>, the largest moved point of the permutation
468+
<A>f</A>, the maximum of the degree and the codegree of the partial perm
469+
<A>f</A>, or as applicable, is used by default.
451470
<P/>
452471

453472
&STANDARD_FILT_TEXT;

doc/prop.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,3 +1459,39 @@ true
14591459
</Description>
14601460
</ManSection>
14611461
<#/GAPDoc>
1462+
1463+
<#GAPDoc Label="IsUpperSemimodularDigraph">
1464+
<ManSection>
1465+
<Prop Name="IsUpperSemimodularDigraph" Arg="D"/>
1466+
<Prop Name="IsLowerSemimodularDigraph" Arg="D"/>
1467+
<Returns><K>true</K> or <K>false</K>.</Returns>
1468+
<Description>
1469+
<C>IsUpperSemimodularDigraph</C> returns <K>true</K> if the digraph
1470+
<A>D</A> represents an upper semimodular lattice and <K>false</K> if it
1471+
does not. Similarly, <C>IsLowerSemimodularDigraph</C> returns <K>true</K>
1472+
if <A>D</A> represents a lower semimodular lattice and <K>false</K> if
1473+
it does not. <P/>
1474+
1475+
In a lattice we say that a vertex <C>a</C> <E>covers</E> a vertex <C>b</C>
1476+
if <C>a</C> is greater than <C>b</C>, and there are no further vertices
1477+
between <C>a</C> and <C>b</C>. A lattice is <E>upper semimodular</E> if
1478+
whenever the meet of <C>a</C> and <C>b</C> is covered by <C>a</C>, the join
1479+
of <C>a</C> and <C>b</C> covers <C>b</C>. <E>Lower semimodularity</E> is
1480+
defined analogously. <P/>
1481+
1482+
See also <Ref Prop="IsLatticeDigraph"/>, <Ref Oper="NonUpperSemimodularPair"/>,
1483+
and <Ref Oper="NonLowerSemimodularPair"/>.
1484+
1485+
&MUTABLE_RECOMPUTED_PROP;
1486+
1487+
<Example><![CDATA[
1488+
gap> D := DigraphFromDigraph6String(
1489+
> "&M~~sc`lYUZO__KIBboC_@h?U_?_GL?A_?c");
1490+
<immutable digraph with 14 vertices, 66 edges>
1491+
gap> IsUpperSemimodularDigraph(D);
1492+
true
1493+
gap> IsLowerSemimodularDigraph(D);
1494+
false]]></Example>
1495+
</Description>
1496+
</ManSection>
1497+
<#/GAPDoc>

doc/z-chap4.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@
3535
<#Include Label="InDegreeOfVertex">
3636
<#Include Label="InNeighboursOfVertex">
3737
<#Include Label="DigraphLoops">
38-
<#Include Label="PartialOrderDigraphMeetOfVertices">
3938
<#Include Label="DegreeMatrix">
4039
<#Include Label="LaplacianMatrix">
4140
</Section>
41+
42+
<Section><Heading>Orders</Heading>
43+
<#Include Label="PartialOrderDigraphMeetOfVertices">
44+
<#Include Label="NonUpperSemimodularPair">
45+
</Section>
4246

4347
<Section><Heading>Reachability and connectivity</Heading>
4448
<#Include Label="DigraphDiameter">

doc/z-chap5.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@
2222
<#Include Label="IsSymmetricDigraph">
2323
<#Include Label="IsTournament">
2424
<#Include Label="IsTransitiveDigraph">
25+
</Section>
26+
27+
<Section><Heading>Orders</Heading>
2528
<#Include Label="IsPreorderDigraph">
2629
<#Include Label="IsPartialOrderDigraph">
2730
<#Include Label="IsMeetSemilatticeDigraph">
31+
<#Include Label="IsUpperSemimodularDigraph">
2832
</Section>
2933

3034
<Section><Heading>Regularity</Heading>

gap/attr.gd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,9 @@ DeclareAttribute("DigraphMaximumMatching", IsDigraph);
121121

122122
DeclareAttribute("Bridges", IsDigraph);
123123
DeclareAttributeThatReturnsDigraph("StrongOrientation", IsDigraph);
124+
125+
DeclareAttribute("NonUpperSemimodularPair", IsDigraph);
126+
DeclareAttribute("NonLowerSemimodularPair", IsDigraph);
127+
128+
DeclareProperty("IsUpperSemimodularDigraph", IsDigraph);
129+
DeclareProperty("IsLowerSemimodularDigraph", IsDigraph);

gap/attr.gi

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,3 +2657,73 @@ function(D)
26572657
M := List(DigraphLoops(D), x -> [x, x]);
26582658
return Union(M, DIGRAPHS_MateToMatching(D, mateD));
26592659
end);
2660+
2661+
# The following function is a transliteration from python to GAP of
2662+
# the function find_nonsemimodular_pair
2663+
# in sage/src/sage/combinat/posets/hasse_diagram.py
2664+
2665+
BindGlobal("DIGRAPHS_NonSemimodularPair",
2666+
function(nbs)
2667+
local n, covers, covers_len, a, covers_a, b, e, a_i, b_i;
2668+
n := Length(nbs);
2669+
2670+
for e in [1 .. n] do
2671+
covers := nbs[e];
2672+
covers_len := Length(covers);
2673+
if covers_len < 2 then
2674+
continue;
2675+
fi;
2676+
for a_i in [1 .. covers_len] do
2677+
a := covers[a_i];
2678+
covers_a := nbs[a];
2679+
for b_i in [1 .. a_i] do
2680+
b := covers[b_i];
2681+
if not ForAny(nbs[b], j -> j in covers_a) then
2682+
return [a, b];
2683+
fi;
2684+
od;
2685+
od;
2686+
od;
2687+
2688+
return fail;
2689+
end);
2690+
2691+
InstallMethod(NonUpperSemimodularPair, "for a digraph",
2692+
[IsDigraphByOutNeighboursRep],
2693+
function(D)
2694+
if not IsLatticeDigraph(D) then
2695+
ErrorNoReturn("the argument (a digraph) is not a lattice");
2696+
fi;
2697+
D := DigraphReflexiveTransitiveReduction(DigraphMutableCopyIfMutable(D));
2698+
return DIGRAPHS_NonSemimodularPair(OutNeighbours(D));
2699+
end);
2700+
2701+
InstallMethod(NonLowerSemimodularPair, "for a digraph",
2702+
[IsDigraphByOutNeighboursRep],
2703+
function(D)
2704+
if not IsLatticeDigraph(D) then
2705+
ErrorNoReturn("the argument (a digraph) is not a lattice");
2706+
fi;
2707+
D := DigraphReflexiveTransitiveReduction(DigraphMutableCopyIfMutable(D));
2708+
return DIGRAPHS_NonSemimodularPair(InNeighbours(D));
2709+
end);
2710+
2711+
InstallMethod(IsUpperSemimodularDigraph, "for a digraph",
2712+
[IsDigraphByOutNeighboursRep],
2713+
function(D)
2714+
if not IsLatticeDigraph(D) then
2715+
return false;
2716+
fi;
2717+
D := DigraphReflexiveTransitiveReduction(DigraphMutableCopyIfMutable(D));
2718+
return DIGRAPHS_NonSemimodularPair(OutNeighbours(D)) = fail;
2719+
end);
2720+
2721+
InstallMethod(IsLowerSemimodularDigraph, "for a digraph",
2722+
[IsDigraphByOutNeighboursRep],
2723+
function(D)
2724+
if not IsLatticeDigraph(D) then
2725+
return false;
2726+
fi;
2727+
D := DigraphReflexiveTransitiveReduction(DigraphMutableCopyIfMutable(D));
2728+
return DIGRAPHS_NonSemimodularPair(InNeighbours(D)) = fail;
2729+
end);

gap/digraph.gd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,24 @@ DeclareSynonym("DigraphByInNeighbors", DigraphByInNeighbours);
106106
DeclareConstructor("AsDigraphCons", [IsDigraph, IsBinaryRelation]);
107107
DeclareConstructor("AsDigraphCons", [IsDigraph, IsTransformation]);
108108
DeclareConstructor("AsDigraphCons", [IsDigraph, IsTransformation, IsInt]);
109+
DeclareConstructor("AsDigraphCons", [IsDigraph, IsPartialPerm]);
110+
DeclareConstructor("AsDigraphCons", [IsDigraph, IsPartialPerm, IsInt]);
109111

110112
DeclareOperation("AsDigraph", [IsFunction, IsBinaryRelation]);
111113
DeclareOperation("AsDigraph", [IsFunction, IsTransformation]);
112114
DeclareOperation("AsDigraph", [IsFunction, IsTransformation, IsInt]);
113115
DeclareOperation("AsDigraph", [IsFunction, IsPerm]);
114116
DeclareOperation("AsDigraph", [IsFunction, IsPerm, IsInt]);
117+
DeclareOperation("AsDigraph", [IsFunction, IsPartialPerm]);
118+
DeclareOperation("AsDigraph", [IsFunction, IsPartialPerm, IsInt]);
115119

116120
DeclareOperation("AsDigraph", [IsBinaryRelation]);
117121
DeclareOperation("AsDigraph", [IsTransformation]);
118122
DeclareOperation("AsDigraph", [IsTransformation, IsInt]);
119123
DeclareOperation("AsDigraph", [IsPerm]);
120124
DeclareOperation("AsDigraph", [IsPerm, IsInt]);
125+
DeclareOperation("AsDigraph", [IsPartialPerm]);
126+
DeclareOperation("AsDigraph", [IsPartialPerm, IsInt]);
121127

122128
DeclareOperation("AsBinaryRelation", [IsDigraph]);
123129
DeclareOperation("AsSemigroup", [IsFunction, IsDigraph]);

gap/digraph.gi

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,58 @@ InstallMethod(AsDigraph, "for a function and a perm",
10621062
InstallMethod(AsDigraph, "for a perm", [IsPerm],
10631063
p -> AsDigraph(AsTransformation(p)));
10641064

1065+
InstallMethod(AsDigraphCons,
1066+
"for IsMutableDigraph, a partial perm, and an integer",
1067+
[IsMutableDigraph, IsPartialPerm, IsInt],
1068+
function(filt, f, n)
1069+
local list, x, i;
1070+
if n < 0 then
1071+
ErrorNoReturn("the 2nd argument <n> should be a non-negative integer,");
1072+
fi;
1073+
1074+
list := EmptyPlist(n);
1075+
for i in [1 .. n] do
1076+
x := i ^ f;
1077+
if x > n then
1078+
return fail;
1079+
elif x <> 0 then
1080+
list[i] := [x];
1081+
else
1082+
list[i] := [];
1083+
fi;
1084+
od;
1085+
return DigraphNC(IsMutableDigraph, list);
1086+
end);
1087+
1088+
InstallMethod(AsDigraphCons,
1089+
"for IsImmutableDigraph, a partial perm, and an integer",
1090+
[IsImmutableDigraph, IsPartialPerm, IsInt],
1091+
function(filt, f, n)
1092+
local D;
1093+
D := AsDigraph(IsMutableDigraph, f, n);
1094+
if D <> fail then
1095+
D := MakeImmutable(D);
1096+
SetIsMultiDigraph(D, false);
1097+
fi;
1098+
return D;
1099+
end);
1100+
1101+
InstallMethod(AsDigraph, "for a function, a partial perm, and an integer",
1102+
[IsFunction, IsPartialPerm, IsInt], AsDigraphCons);
1103+
1104+
InstallMethod(AsDigraph, "for a partial perm and an integer",
1105+
[IsPartialPerm, IsInt],
1106+
{t, n} -> AsDigraphCons(IsImmutableDigraph, t, n));
1107+
1108+
InstallMethod(AsDigraph, "for a function and a partial perm",
1109+
[IsFunction, IsPartialPerm],
1110+
{func, t} -> AsDigraphCons(func, t, Maximum(DegreeOfPartialPerm(t),
1111+
CodegreeOfPartialPerm(t))));
1112+
1113+
InstallMethod(AsDigraph, "for a partial perm", [IsPartialPerm],
1114+
t -> AsDigraphCons(IsImmutableDigraph, t, Maximum(DegreeOfPartialPerm(t),
1115+
CodegreeOfPartialPerm(t))));
1116+
10651117
InstallMethod(AsBinaryRelation, "for a digraph", [IsDigraphByOutNeighboursRep],
10661118
function(D)
10671119
local rel;

0 commit comments

Comments
 (0)