Should variable names be distinct? #1944
Replies: 6 comments 5 replies
-
On Wed, Feb 15, 2023 at 02:52:24AM -0800, JohnAAbbott wrote:
When creating a polynomial ring one specifies the names of the variables:
```
julia> PolynomialRing(QQ, ["x","x"])
(Multivariate Polynomial Ring in x, x over Rational Field, fmpq_mpoly[x, x])
```
Do we wish to allow duplicate names? Currently it is apparently not forbidden (see above).
Personally, I cannot think of a reasonable use-case where duplicate names would be useful.
Neither can I, but as the names are only used for printing and have no
meaning for the maths, I'm not sure its worth while filtering.
Also remember, the same name might be used in any number of other rings,
including the coefficient ring...
…
--
Reply to this email directly or view it on GitHub:
#1944
You are receiving this because you are subscribed to this thread.
Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Indeed, the check would have to be "recursive". The names might also be used when doing conversion from a string to a ring element (if this is possible in Oscar). Singular and CoCoA do forbid duplicate names. Can an element of a polynomial ring with duplicate variable names |
Beta Was this translation helpful? Give feedback.
-
On Wed, Feb 15, 2023 at 03:05:20AM -0800, JohnAAbbott wrote:
Indeed, the check would have to be "recursive".
The names might also be used when doing conversion from a string to a ring element (if this is possible in Oscar).
Not possible - well, of course you can, but it's not supported
So with duplicate names ambiguity arises, and for instance special behaviour would be needed if we want to be able
to print out a string which can be re-read to produce an equivalent value -- normal printing would discard too much
information in this situation. For instance what does `x^2 - x^2` represent?
Singular and CoCoA do forbid duplicate names. Can an element of a polynomial ring with duplicate variable names
that is in the creation of a single ring. I don't know if this is
checked recursively - in particular if the coeff. ring is not a poly
ring, there is no uniform interface to even get the printing symbol
safely be sent to Singular for processing?
I think yes as in Oscar names have absolutely no function, they are only
used for printing. The reading in bit is in general not possible -
unless you created the create the correct ring in advance - and rings
created with cache = false cannot be re-created.
In fact, in almost all cases I do not even specify names:
R, x = PolynomialRing(QQ, 10)
S, y = PolynomialRing(QQ, 5)
...
Names are important in interactive use, but (to me) not in programming
(I've created both in Magma and in Oscar many situation where you see
many _a or $1 that are in different rings: $1*$1*$1 is a good one.)
…
--
Reply to this email directly or view it on GitHub:
#1944 (comment)
You are receiving this because you commented.
Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
It would require bigger changes. PolyRing(PolyRing(QQ, 2), 2)
The system would need to be able to recursively choose distinct names, also
across the bottom ring...
…On Tue, 11 Apr 2023, 17:39 JohnAAbbott, ***@***.***> wrote:
@fingolfin <https://github.com/fingolfin> The comment about recursive
checking and generic code is a convincing argument. Somewhere it should be
documented that duplicate names are permitted (and that this is unwise for
interactive use).
I do wonder whether duplicates in the list of names given to the
polynomial ring constructor should trigger an error (or warning?): that
would help protect a careless user against some accidental typos. The last
example above would trigger the error/warning. I cannot think of a sane
use-case where one would really want to specify duplicate names in the list
of names.
A disadvantage of my proposal just above is that it is a "half measure",
so could leave some users perplexed.
—
Reply to this email directly, view it on GitHub
<#1944 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA36CV6P2X6X7ECJU35LS6DXAV3KNANCNFSM6AAAAAAU4V6LSU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
On Tue, Apr 11, 2023 at 09:59:29AM -0700, Lars Kastner wrote:
> Also note that unlike Singular and perhaps other systems, the name of the ring variables (the mathematical objects) is completely unrelated to the names of whatever, if any, Julia variables they might be stored in. I can write code like this:
Probably this was asked before, but is there a way to deduce variable names in case only variables are given, but no names? E.g. I would want the following to work:
```julia
R, (a,b) = PolynomialRing(QQ)
```
such that `f = a+b` then is printed as `a+b`. Probably wontfix or requires too much macro magic. It is just a bit cumbersome to have to enter these things "twice" in all scenarios.
There is AbstractAlgebra.find_name which could do that...
It is used in some printing functions for parent structures, but would
work for a and b as well.
The name cannot be deducted on creation, but on first printing (or
otherwise using)
…
--
Reply to this email directly or view it on GitHub:
#1944 (reply in thread)
You are receiving this because you commented.
Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
This discussion has been idle for over 3 months, so I propose closing it. |
Beta Was this translation helpful? Give feedback.
-
When creating a polynomial ring one specifies the names of the variables:
Do we wish to allow duplicate names? Currently it is apparently not forbidden (see above).
Personally, I cannot think of a reasonable use-case where duplicate names would be useful.
Beta Was this translation helpful? Give feedback.
All reactions