Skip to content
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

Plan: get rid of hidden implications #2336

Open
2 of 5 tasks
fingolfin opened this issue Mar 30, 2018 · 3 comments
Open
2 of 5 tasks

Plan: get rid of hidden implications #2336

fingolfin opened this issue Mar 30, 2018 · 3 comments
Labels
kind: discussion discussions, questions, requests for comments, and so on

Comments

@fingolfin
Copy link
Member

fingolfin commented Mar 30, 2018

Short summary

I would like to get rid of hidden implications in GAP completely. They can lead to counterintuitive problems, like the order in which packages were loaded can affect ranking; and other problems, see e.g. issue #1649 (and esp. this comment by @frankluebeck which already sketches the plan here, and gives additional useful information)

Background: What are hidden implications?

Currently, GAP's method ranking relies on both implications, and so-called "hidden implications". An implication is when a filter IsFOO implies another filter IsBAR (e.g. via InstallTrueMethod). In that case, the rank of IsFOO should be larger than that of IsBAR, reflecting the idea that the more "properties" (used in a non-technical sense here) a filter implies, the higher it should be ranked.

This is all good and fine, but apparently was/is not quite good enough to get a good ranking system (?). Thus GAP also uses so-called "hidden" implications: A "hidden" implication from a filter IsFOO to a filter IsBAR has the same effect on the relative ranking of the two filters, but without a mathematical implication between the two.

These typical are created indirectly when you declare a property or attribute. Example:

DeclareProperty( "IsNilpotentGroup", IsGroup );

This creates a hidden implication from IsNilpotentGroup to IsGroup, but not a mathematical one. Meaning that the rank of IsNilpotentGroup is larger than that of IsGroup; but in principle at least, something could be in the filter IsNilpotentGroup without being also in the filter IsGroup. Now, in this particular case, one "obviously" also intended an actual proper implication -- but none exists! One has to manually establish it, e.g. via this:

InstallTrueMethod( IsGroup, IsNilpotentGroup )

The reason for this is clearer if you consider this example: in polycyclic, we have this:

DeclareProperty( "IsTorsionFree", IsGroup );

Now, this installs a hidden implication IsTorsionFree to IsGroup. But now perhaps you are writing a package in which you deal with torsion free monoids. So you add this:

DeclareProperty( "IsTorsionFree", IsMonoid );

Both can happily coexist, but now we are glad that GAP did not erroneously install an actual implication from IsTorsionFree to IsGroup, as our most beloved torsion free monoid, the set N of natural numbers, isn't a group.

But GAP only installs a hidden implication the first time a property is declared... Thus now the ranking of the filter IsTorsionFree depends on the order in which packages are loaded: if the polycyclic package is loaded first, then the rank will be higher than as if your new package is loaded, as IsGroup has a higher rank than IsMonoid.

This kind of example is not made up, it occurs in practice that people want to define properties for different kind of objects.

Proposed solution

Get rid of hidden implications, gradually, as sketched above.

TODO: add more details later on?

@fingolfin fingolfin added request for comments kind: discussion discussions, questions, requests for comments, and so on labels Mar 30, 2018
@fingolfin
Copy link
Member Author

One suggestion by @ThomasBreuer was that there could be an optional argument to DeclareProperty to indicate that a true reverse implications is intended; my variation of that would be to have a separately named declare function, such as DeclarePropertyWithReverseImplication or DeclareExclusiveProperty, as that stands out more and is easy to grep for

In either case, we could then keep track of this explicitly, and issue a warning or even error if a property of this kind gets redefined.

Also, one may consider a similar for the tester of an attribute: e.g. HasDerivedSubgroup and HasDerivedSeriesOfGroup both likely should imply IsGroup, so it would make sense to have such "automatic" reverse implications for attributes, too.

@ThomasBreuer
Copy link
Contributor

It is fine to have two functions for the two purposes of property declarations.
The main point is that GAP can detect (on startup or when a package gets loaded)
where an existing property shall be redeclared with another intended behavior concerning implications,
and can signal a warning or an error.
I would not use the term reverse implication, DeclarePropertyWithImplication would fit.

@fingolfin fingolfin added this to the GAP 4.11 milestone Oct 15, 2018
@fingolfin fingolfin removed this from the GAP 4.11 milestone Mar 24, 2019
fingolfin added a commit to gap-packages/congruence that referenced this issue May 15, 2019
This makes various "hidden" implications created by DeclareProperty
explicit, thus fixing a bunch of warnings that show up if one starts
the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to fingolfin/laguna that referenced this issue May 15, 2019
This makes various "hidden" implications created by DeclareProperty
explicit, thus fixing a bunch of warnings that show up if one starts
the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to gap-packages/sophus that referenced this issue May 15, 2019
This makes various "hidden" implications created by DeclareProperty
explicit, thus fixing a bunch of warnings that show up if one starts
the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to fingolfin/cryst that referenced this issue May 15, 2019
This makes various "hidden" implications created by DeclareProperty
explicit, thus fixing a bunch of warnings that show up if one starts
the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to fingolfin/xmod that referenced this issue May 16, 2019
This makes various "hidden" implications created by DeclareProperty
explicit, thus fixing a bunch of warnings that show up if one starts
the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to fingolfin/xmodalg that referenced this issue May 16, 2019
This makes various "hidden" implications created by DeclareProperty
explicit, thus fixing a bunch of warnings that show up if one starts
the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to gap-packages/resclasses that referenced this issue May 17, 2019
This makes a "hidden" implication created by DeclareProperty
explicit, thus fixing a bunch of warnings that show up if one starts
the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to gap-packages/groupoids that referenced this issue May 17, 2019
This makes various "hidden" implications created by DeclareProperty
explicit, thus fixing a bunch of warnings that show up if one starts
the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to fingolfin/gap that referenced this issue May 17, 2019
Some time ago we added the command line option -N to disable
hidden methods (see also gap-system#2336). This causes many InstallMethod
invocations in packages to print warnings. Improve these warnings
to make it easier to resolve them.
olexandr-konovalov pushed a commit to gap-packages/laguna that referenced this issue May 19, 2019
This makes various "hidden" implications created by DeclareProperty
explicit, thus fixing a bunch of warnings that show up if one starts
the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
olexandr-konovalov pushed a commit to gap-packages/congruence that referenced this issue May 19, 2019
This makes various "hidden" implications created by DeclareProperty
explicit, thus fixing a bunch of warnings that show up if one starts
the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to gap-packages/resclasses that referenced this issue May 19, 2019
This makes a "hidden" implication created by DeclareProperty
explicit, thus fixing a bunch of warnings that show up if one starts
the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit that referenced this issue May 19, 2019
Some time ago we added the command line option -N to disable
hidden methods (see also #2336). This causes many InstallMethod
invocations in packages to print warnings. Improve these warnings
to make it easier to resolve them.
fingolfin added a commit to gap-packages/resclasses that referenced this issue Sep 6, 2019
This makes a so-called "hidden" implication created by DeclareProperty
explicit, thereby resolving a bunch of warnings that show up if one
starts the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to gap-packages/resclasses that referenced this issue Sep 6, 2019
This seems correct, as there were no real methods to compute it. Also,
it is very similar to IsIntegers, which is also a category.

This makes a so-called "hidden" implication created by DeclareProperty
explicit, thereby resolving a bunch of warnings that show up if one
starts the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to gap-packages/resclasses that referenced this issue Sep 6, 2019
This seems correct, as there were no real methods to compute it. Also,
it is very similar to IsIntegers, which is also a category.

This makes a so-called "hidden" implication created by DeclareProperty
explicit, thereby resolving a bunch of warnings that show up if one
starts the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to gap-packages/resclasses that referenced this issue Sep 9, 2019
This seems correct, as there were no real methods to compute it. Also,
it is very similar to IsIntegers, which is also a category.

This makes a so-called "hidden" implication created by DeclareProperty
explicit, thereby resolving a bunch of warnings that show up if one
starts the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to gap-packages/resclasses that referenced this issue Sep 17, 2019
This seems correct, as there were no real methods to compute it. Also,
it is very similar to IsIntegers, which is also a category.

This makes a so-called "hidden" implication created by DeclareProperty
explicit, thereby resolving a bunch of warnings that show up if one
starts the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to gap-packages/resclasses that referenced this issue Sep 17, 2019
This seems correct, as there were no real methods to compute it. Also,
it is very similar to IsIntegers, which is also a category.

This makes a so-called "hidden" implication created by DeclareProperty
explicit, thereby resolving a bunch of warnings that show up if one
starts the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to gap-packages/resclasses that referenced this issue Sep 17, 2019
This seems correct, as there were no real methods to compute it. Also,
it is very similar to IsIntegers, which is also a category.

This makes a so-called "hidden" implication created by DeclareProperty
explicit, thereby resolving a bunch of warnings that show up if one
starts the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to gap-packages/resclasses that referenced this issue Sep 17, 2019
This seems correct, as there were no real methods to compute it. Also,
it is very similar to IsIntegers, which is also a category.

This makes a so-called "hidden" implication created by DeclareProperty
explicit, thereby resolving a bunch of warnings that show up if one
starts the upcoming GAP 4.11 with the `-N` command line option, and then
loads this package.

For some information on the background of this, see also
<gap-system/gap#1649> and
<gap-system/gap#2336>
fingolfin added a commit to gap-packages/qpa that referenced this issue Aug 8, 2022
This fixes warnings when starting GAP with the -N option. For more
information, see gap-system/gap#2336
@fingolfin fingolfin added this to the GAP 4.13.0 milestone Aug 8, 2022
@fingolfin
Copy link
Member Author

Sadly things got worse since I last touched this, as lots packages added new code relying (accidentally) on hidden implications. At the same time, we keep encountering problems caused by hidden implications (see e.g. https://github.com/gap-system/gap/pull/4935/files#r940054140).

Ideally we'd come up with a plan to migrate incrementally to a world without hidden implications.... Perhaps we could add an optional argument for DeclareAttribute etc. which turns off (or on!) hidden implications for just that one call. Then the -N option would basically decide what the default for that option is. This would allow us to already avoid hidden implications in some places now, before the full switch.

Or perhaps we just need to make the switch, hard:

  1. Switch PackageDistribution to use -N by default (possibly on a branch) to find any offending packages (to have that work, patch GAP to error instead of warn when there is a problem; perhaps we could have variants of -N like --hidden-implications=[on|warn|off] with warn corresponding to what giving -N does right now)
  2. get as many (all?) packages to accept patches to fix any warnings they show when loaded with -N active
  3. Also do the same to fix their test suites
  4. Switch package CI job to (also? only) test with the --hidden-implications=off option to ensure they stay fixed
  5. finally turn it off in GAP for good

@fingolfin fingolfin removed this from the GAP 4.13.0 milestone Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: discussion discussions, questions, requests for comments, and so on
Projects
None yet
Development

No branches or pull requests

2 participants