-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turn hidden implications into actual implications #2222
Conversation
Regarding point 2, I wrote a super simple script, and compared its output between this PR and master: for n in NamesGVars() do
if not IsBoundGlobal(n) then continue; fi;
f:=ValueGlobal(n);
if IsFilter(f) then
Print(n, ": ", RankFilter(f), "\n");
fi;
od; The good news: they are identical! The bad news: if I remove hidden implications, they start to differ radically. To get an overview, I run the following on the master branch and on this PR; the code mimics RankFilter with hidden imps off. count:=0;;
for n in NamesGVars() do
if not IsBoundGlobal(n) then continue; fi;
f:=ValueGlobal(n);
if IsFilter(f) then
rank := RankFilter(f);
rank_no_hidden := Sum(RANK_FILTERS{TRUES_FLAGS(WITH_IMPS_FLAGS(FLAGS_FILTER(f)))});
if rank <> rank_no_hidden then
Print(n, ": ", rank, " vs ", rank_no_hidden, "\n");
count := count + 1;
fi;
fi;
od;
Print("Total differences: ", count, "\n"); The result is that on
But also:
In the end, I guess most of this will be OK, but perhaps we need to check some things... E.g. perhaps some explicit implications are needed for tests? E.g. with master and this PR, I see this:
With this PR and hidden imps turned off, I get this:
One may now argue that |
Here is a simple program to deal with point 4, i.e., determine whether methods in some operations changed: # scan global variables for operations
count := 0;
ops_with_diffs := 0;
meths_with_diffs := 0;
RankFilterNoHidden:=function(f)
if IsFunction(f) then f:=FLAGS_FILTER(f); fi;
return Sum(RANK_FILTERS{TRUES_FLAGS(WITH_IMPS_FLAGS(f))});
end;
# give all filters which have hidden implications from <filter>, but
# not actual impllications;
HiddenImpliedFilters:=function(filter)
local flags, imps, hidden, diff;
flags := FLAGS_FILTER(filter);
imps := WITH_IMPS_FLAGS(flags);
hidden := WITH_HIDDEN_IMPS_FLAGS(flags);
diff := Difference(TRUES_FLAGS(hidden),TRUES_FLAGS(imps));
return FILTERS{diff};
end;
for name in NamesGVars() do
if not IsBoundGlobal(name) then continue; fi;
v:=ValueGlobal(name);
if not IsOperation(v) then continue; fi;
count := count + 1;
# FIXME: skip constructors for now
if IS_CONSTRUCTOR(v) then continue; fi;
# iterate over all methods
for n in [0..7] do
methods := METHODS_OPERATION(v, n);
ranks_old := [];
ranks_new := [];
for i in [1..Length(methods)/(n+4)] do
filters := methods{[(n+4)*(i-1)+2 .. (n+4)*(i-1)+1+n]};
rank := methods[(n+4)*(i-1)+3+n];
rank_bonus := rank - Sum(filters, RankFilter);
#Assert(0, rank_bonus >= 0);
Add(ranks_old, rank);
Add(ranks_new, rank_bonus + Sum(filters, RankFilterNoHidden));
od;
Assert(0, IsSortedList(Reversed(ranks_old)));
if not IsSortedList(Reversed(ranks_new)) then
ops_with_diffs := ops_with_diffs + 1;
# find positions with changed order
bad := Filtered([1..Length(ranks_new)-1], i-> ranks_new[i] < ranks_new[i+1]);
#Error("foo");
Print("Method order change for ", name, ": ", bad, "\n");
meths_with_diffs := meths_with_diffs + Length(bad);
for i in bad do
info := methods[(n+4)*(i-1)+4+n];
func := methods[(n+4)*(i-1)+2+n];
loc := LocationFunc(func);
if IsEmpty(loc) then
loc := "???";
fi;
info2 := methods[(n+4)*(i)+4+n];
func2 := methods[(n+4)*(i)+2+n];
loc2 := LocationFunc(func);
if IsEmpty(loc2) then
loc2 := "???";
fi;
Print(" '", info, "' at ", loc, "\n");
Print(" old rank ", ranks_old[i], "; new rank ", ranks_new[i], "\n");
Print(" versus\n");
Print(" '", info2, "' at ", loc2, "\n");
Print(" old rank ", ranks_old[i+1], "; new rank ", ranks_new[i+1], "\n");
Print("\n");
od;
fi;
od;
od;
Print("Total number of operations checked: ", count, "\n");
Print(" ", ops_with_diffs, " had methods whose relative rank changed\n");
Print(" about ", meths_with_diffs, " methods were reordered\n"); Summary of the results: In
With this PR, I get:
Here is a typical bit of output:
The helper function
OK, we definitely do not want to have these as actual implications. And in this particular example, the order change did not matter, as both methods end up calling the same function anyway (though that does not yet quite mean things are fine, because I only print neighbors which are ordered wrong, and not all methods which changed relative order). Anyway, this means that in order to remove hidden implications, quite a lot more work is needed. |
Note that many of the changes in relative order can be resolved by additional implications, the tricky part is finding them and getting the implications right. Example:
So, yeah, it would make sense to have |
As far as I understand the intended setup, the proposed additions of explicit implications However, these implications can also be dangerous in the situation where an attribute/property Would it perhaps make sense to install the implication not via a separate call of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[This is concerning change 0365e99, Remove invalid implication for IsSubsetLocallyFiniteGroup, only]
I don't understand this. IsFFE are elements of a finite degree extension of GF(p). If I have finitely many of them they all lie in a finite degree extension. What Do I miss?
Also I suggest to be careful with simply removing implications without checking why they were added in the first place. There can be situations where removing an implication of finiteness or so can suddenly cause certain calculations go very slow.
@hulpke: The removed implication installation is
The point is that |
@hulpke First off, that change also has its own PR #2220. You write "Also I suggest to be careful with simply removing implications without checking why they were added in the first place", which seems to suggest that I am removing an implication without checking why it was added in the first place. But I did! I also did not "simply remove it", instead I submitted a PR, with the understanding that people will review it, and hopefully catch if I made a mistake, which of course can happen despite me taking great care in what changes I make. So, I heartily invite you to comment on PR #2220. I suggest we discuss this further on PR #2220, not here, as this commit is only in this PR because the changes in here revealed this incorrect implication and turned it into a serious problem (e.g. |
d38c45d
to
fef3c02
Compare
Codecov Report
@@ Coverage Diff @@
## master #2222 +/- ##
==========================================
+ Coverage 74.27% 74.27% +<.01%
==========================================
Files 484 484
Lines 245343 245343
==========================================
+ Hits 182218 182225 +7
+ Misses 63125 63118 -7
|
@ThomasBreuer You are of course right, one has to be careful with this implications. For this PR, I restricted myself to implications which are "obviously right", e.g. because the filter name already suggest it: That said, mistakes happen, and if GAP can do something to give a helpful warning, then we should do that. In so far, I like you suggestion of adding an extra argument to This would then also allow us choose between the implication I can implement this in this PR, but I'll wait a bit to see if others have thoughts on this idea. |
Ah, I have actually largely done what I proposed in #1649. But I didn't find time to write up a detailed explanation and to finish all tests I wanted to do. Therefore, it it not yet pushed. If there is interest, I can try to turn my two pull requests into a presentable state within the next days. |
I had a closer look at the proposed changes, and suggest the following.
|
fef3c02
to
0689af8
Compare
@ThomasBreuer thanks, took care of both your points |
0689af8
to
0b2f48f
Compare
@frankluebeck sure, if you have such code, it certainly would be interesting to see it in a PR (or multiple) |
0b2f48f
to
8847935
Compare
The remaining test failure is caused by issue #2252. |
8847935
to
b5a54f8
Compare
Rebased this PR and adjusted for recent changes. If all tests pass, I think it could be merged now. |
To give an example of why I think this PR is already now useful, consider this example, in the master branch:
and with this PR:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In principle, I am in favor of these changes.
However, I do not see whether they could be improved
further by adopting parts of # 2247 (by @frankluebeck).
Since Frank is also asked for a review, I leave the decision to him.
I am sure further improvements are possible; perhaps some already are in PR #2247; most likely there are more not covered in either PR. But I don't see why the possibility of even further improvements should stop us from already adding some improvements right away? |
b5a54f8
to
7f0b172
Compare
@frankluebeck @ThomasBreuer I've now updated this, taking PR #2247 into account. |
@frankluebeck @ThomasBreuer Ping? Still needs your approval... |
This looks fine. The current master branch behaves in many respects as if the explicit implications which are added here are already there (because of "hidden implications"). Making these implications explicit is an important step towards getting rid of the hidden implications. I suggest to add the following three small changes:
Then one can use the Further explicit implications will be needed which will become clear by comparing filter ranks when gap is called with and without |
7f0b172
to
7c8aec8
Compare
This allows installing methods for "IsList and IsEmpty", which is a list but not a collection.
@frankluebeck I added your first and last suggestion. I am a bit wary of the middle one, and would prefer if this was added in a future PR (if at all), instead of delaying this PR further, which has been cooking since Februar 28. (Specifically, this PR still has no explicit approval as described on https://help.github.com/articles/approving-a-pull-request-with-required-reviews/, so it cannot be merged). The reason I am wary about the middle change is this: There are various ways to address this, but again, I'd prefer to do this in a separate fresh PR, instead of revising this one again and again; I think this PR already is useful, even if it does not yet resolve all warnings reported by your |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see discussion for details
@fingolfin: I understand the complaint about the change concerning |
@frankluebeck That may very well be! We recently discovered a bunch of issues of a very similar kind. Definitely should be investigated. |
I'll submit an issue for it, so we don't forget |
This implements parts of the proposal for fixing #1649, by turning many "hidden" implications into actual implications. I think this is beneficial for its own sake, although the long term plan is to try and see if we can get rid of hidden implication; see also PRs #2246 and #2247.
See also the new issue #2336 for the overarching goal of getting rid of hidden implications.
OLD TEXT follows.
With this applied, I can remove the code for setting / handling hidden implications and start GAP with
-A
and get no warnings. However, some tests do not pass if I do that. Beyond that, many packages needInstallTrueMethod
calls before we can consider removing hidden implications.There are three [UPDATE: four] things I'd like to do before merging this PR:
Merge PRs Fix implication for IsSubsetLocallyFiniteGroup; and teach Units(GF(q)) its size #2220 and Bug fix: IsRightAlgebraModule is a right module, not left (DO NOT MERGE) #2221, which are required for this PR (and right now they are contained in it)Investigate and resolve the test failures when hidden implications are disabled (I hope point24 will help with this).