WIP: Fixes for vector spaces with DimensionOfVectors(V) = 0 (DO NOT MERGE)#2125
WIP: Fixes for vector spaces with DimensionOfVectors(V) = 0 (DO NOT MERGE)#2125fingolfin wants to merge 1 commit intogap-system:masterfrom
Conversation
…0, we currently have Zero(V) = []. This commit makes the following snippets work: * Coefficients(Basis(V), []) * Position(Enumerator(V), []) * [] in V
|
I agree with the statement by @fingolfin that it is not clear Let us look at some more examples.
One can change the behaviour of empty lists in particular situations, I think the only clean way out of this problem would be In practice, |
|
Regarding empty compressed vectors comparing equal: The "ideal" fix for that would be to make compressed vectors and matrices not lie in But yeah, for now, we need to deal with the specific problem at hand. BTW, the thing I don't like about adding special cases for zero dimensions everywhere is not so much that it's less elegant, but rather that it's a game of whack-a-mole: We'll never know that we didn't miss a spot, and it's quite likely people will write new code which lacks special cases for the zero-dimensional case. |
|
I think the right way to do this is just to retire the existing compressed vectors entirely in favour of somethign based on cvec and/or meataxe64 which have never been designed to lie in IsList. Cleaning up all the crud in the existing compressed vectors which is only there because of compatibility with lists is probably more work than writing something better. However, I think that means switching all the linear algebra and matrix groups to work via MatrixObj, which is a huge task. |
ThomasBreuer
left a comment
There was a problem hiding this comment.
These changes extend the support for empty lists in the context of domains, which might encourage people to (mis)use the behaviour, and then it is likely that problems arise in other places.
I am not voting against the changes, but I do not really like them.
|
Just to clarify: I also don't like the changes in this PR very much. I mostly put it out here to have a better foundation for discussion. I'll close this now, though, as I think it's clear we want to go in another direction. I added some more issues (#2148 and #2149) regarding empty vectors and possible semantics for comparing MatrixObj and VectorObj. |
[This is motivated by #2117 resp #2121; in particular, it fixes #2117)
Given a vector space V with DimensionOfVectors(V) = 0, e.g. V:=GF(5)^0, we currently
have Zero(V) = []. This commit makes the following snippets work:
Especially the last point requires a rather nasty hack: By definition, "[a] collection in GAP consists of elements in the same family"; and any vector space
Vin GAP is such a collection, yet its only element, the empty list[], is not in the correct family. This already is strictly speaking a bug, and forcing\into work regardless could equally be described as a "fix" or as "making things even worse".So all in all I am conflicted about merging this... But what is the alternative? For vectors over small fields, we could realize #2121 and make empty compressed vectors safe to use, but that doesn't solve e.g. the case of
Rationals^0.