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

Add more implications (including some implications of falsity) #494

Merged
merged 3 commits into from
Nov 25, 2021

Conversation

wilfwilson
Copy link
Collaborator

I learned recently (see the discussion starting gap-system/gap#4546 (comment)) that you can use

InstallTrueMethod( HasIsX, IsY );

to, in practice, automatically set IsX(D) = false when IsY(D) = true becomes known. The only pitfall is that if IsX(D) is already (i.e. wrongly) set to true, then this true method doesn't do anything; in particular it doesn't complain. So this doesn't help us to catch bugs (where properties get set incorrectly), but we weren't catching them anyway, and it does offer useful functionality for storing learned information.

Therefore I have added some such 'InstallFalseMethod's to Digraphs. This was made easier with the addition of DigraphHasVertices and DigraphHasEdges, which allows me to easily exclude some trivial exceptions which would otherwise stop certain implications being added.

I also added immediate methods for these things so that they are set to true or false once the attributes DigraphNrVertices and DigraphNrEdges are known; similarly, I added immediate methods for DigraphNrVertices and DigraphNrEdges once the attributes DigraphVertices and DigraphEdges are known.

I still need to add documentation and tests, and possibly I'll come up with some more InstallTrueMethods to add.

@wilfwilson wilfwilson added enhancement A label for PRs that provide enhancements. WIP Label of PRs that are a Work In Progress (WIP) merge-in-to-master A label for PRs that should be merged into the master branch labels Jun 9, 2021
gap/attr.gi Outdated Show resolved Hide resolved
gap/prop.gi Outdated Show resolved Hide resolved
gap/prop.gi Outdated Show resolved Hide resolved
@wilfwilson wilfwilson force-pushed the implications branch 2 times, most recently from 4a8d83d to edd9ebe Compare June 10, 2021 10:08
@james-d-mitchell
Copy link
Member

This is interesting @wilfwilson, I generally like the idea, and see this as a major improvement, but I'm vaguely worried that this feature relies on a (possibly) undocumented implementational detail of the type system in GAP (that if the default value of the bit corresponding to a IsSomething is 0, and if we set HasIsSomething to true but don't set the value of IsSomething it will be false). If this isn't likely to change in GAP in the future, then I'm only vaguely worried, and will forget soon 👍

@wilfwilson
Copy link
Collaborator Author

Fair concern! I can't really imagine this is the sort of thing that would ever change about GAP.

But even if it did, this trick is used in GAP itself, and now in at least one other package (polycyclic). So any change to GAP would have to be (and would be) either backwards compatible, or postponed until all packages using this trick were changed to use some other system.

@wilfwilson wilfwilson force-pushed the implications branch 2 times, most recently from c2af90c to 507c008 Compare October 27, 2021 18:17
@wilfwilson wilfwilson force-pushed the implications branch 2 times, most recently from 2f59a34 to 911ab89 Compare November 22, 2021 17:46
@wilfwilson wilfwilson removed the WIP Label of PRs that are a Work In Progress (WIP) label Nov 22, 2021
@wilfwilson
Copy link
Collaborator Author

I've distilled this into its essence I think, maybe one day I'll make future improvements in a separate PR.

As mentioned above, I do not think that this is the kind that of thing that will be changed in future versions of GAP. But I've added extensive tests for the implications of falsity, so we would immediately catch it if any of them ever stops working. There's no risks that this will give us wrong answers; I suppose the risk is just that the true methods won't do anything any more. If that ever becomes the case we can just remove them.

@wilfwilson wilfwilson merged commit d783a6d into digraphs:master Nov 25, 2021
@wilfwilson wilfwilson deleted the implications branch November 25, 2021 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A label for PRs that provide enhancements. merge-in-to-master A label for PRs that should be merged into the master branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants