Skip to content

Commit 424510c

Browse files
committed
Improve ShowImpliedFilters
1 parent 24c69d0 commit 424510c

File tree

1 file changed

+27
-34
lines changed

1 file changed

+27
-34
lines changed

lib/methwhy.g

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,6 @@ end);
280280
## <Example><![CDATA[
281281
## gap> ShowImpliedFilters(IsNilpotentGroup);
282282
## Implies:
283-
## IsNilpotentGroup
284-
## HasIsNilpotentGroup
285283
## IsSupersolvableGroup
286284
## HasIsSupersolvableGroup
287285
## IsSolvableGroup
@@ -293,57 +291,52 @@ end);
293291
## May imply with:
294292
## +IsFinitelyGeneratedGroup
295293
## +HasIsFinitelyGeneratedGroup
296-
## IsFinitelyGeneratedGroup
297-
## HasIsFinitelyGeneratedGroup
298-
## IsNilpotentGroup
299-
## HasIsNilpotentGroup
300-
## IsSupersolvableGroup
301-
## HasIsSupersolvableGroup
302-
## IsSolvableGroup
303-
## HasIsSolvableGroup
304294
## IsPolycyclicGroup
305295
## HasIsPolycyclicGroup
306-
## IsNilpotentByFinite
307-
## HasIsNilpotentByFinite
308296
##
309297
## ]]></Example>
310298
## </Description>
311299
## </ManSection>
312300
## <#/GAPDoc>
313301
##
314-
BIND_GLOBAL("ShowImpliedFilters",function(fil)
315-
local flags,f,i,j,l,m,n;
316-
flags:=FLAGS_FILTER(fil);
302+
BIND_GLOBAL("ShowImpliedFilters",function(filter)
303+
local flags, implied, f, extra_implications, implication, name, diff_reqs, diff_impls;
304+
flags:=FLAGS_FILTER(filter);
305+
implied := WITH_IMPS_FLAGS(flags);
317306
atomic readonly IMPLICATIONS_SIMPLE do
318307
f:=Filtered(IMPLICATIONS_SIMPLE, x->IS_SUBSET_FLAGS(x[2],flags));
319308
Append(f, Filtered(IMPLICATIONS_COMPOSED, x->IS_SUBSET_FLAGS(x[2],flags)));
320-
l:=[];
321-
m:=[];
322-
for i in f do
323-
n:=SUB_FLAGS(i[2],flags); # the additional requirements
324-
if SIZE_FLAGS(n)=0 then
325-
Add(l,i[1]);
326-
else
327-
Add(m,[n,i[1]]);
309+
extra_implications:=[];
310+
for implication in f do
311+
diff_reqs:=SUB_FLAGS(implication[2],flags); # the additional requirements
312+
diff_impls:=SUB_FLAGS(implication[1],implied); # the additional implications
313+
diff_impls:=SUB_FLAGS(diff_impls,diff_reqs);
314+
if SIZE_FLAGS(diff_reqs) > 0 and SIZE_FLAGS(diff_impls) > 0 then
315+
Add(extra_implications, [diff_reqs, diff_impls]);
328316
fi;
329317
od;
330318
od; # end atomic
331-
if Length(l)>0 then
319+
320+
# remove "obvious" implications
321+
if IS_ELEMENTARY_FILTER(filter) then
322+
implied := SUB_FLAGS(implied, flags);
323+
fi;
324+
325+
if SIZE_FLAGS(implied) > 0 then
332326
Print("Implies:\n");
333-
for i in l do
334-
for j in NamesFilter(i) do
335-
Print(" ",j,"\n");
336-
od;
327+
for name in NamesFilter(implied) do
328+
Print(" ",name,"\n");
337329
od;
338330
fi;
339-
if Length(m)>0 then
331+
332+
if Length(extra_implications) > 0 then
340333
Print("\n\nMay imply with:\n");
341-
for i in m do
342-
for j in NamesFilter(i[1]) do
343-
Print("+",j,"\n");
334+
for implication in extra_implications do
335+
for name in NamesFilter(implication[1]) do
336+
Print("+",name,"\n");
344337
od;
345-
for j in NamesFilter(i[2]) do
346-
Print(" ",j,"\n");
338+
for name in NamesFilter(implication[2]) do
339+
Print(" ",name,"\n");
347340
od;
348341
Print("\n");
349342
od;

0 commit comments

Comments
 (0)