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

coercion system for nested polynomial ring is not sane #39126

Open
2 of 6 tasks
user202729 opened this issue Dec 14, 2024 · 0 comments
Open
2 of 6 tasks

coercion system for nested polynomial ring is not sane #39126

user202729 opened this issue Dec 14, 2024 · 0 comments
Labels

Comments

@user202729
Copy link
Contributor

user202729 commented Dec 14, 2024

Issue 1: sometimes coerce map is not callable

  • done
sage: QQ["a"]["b,c"].coerce_map_from(QQ["a,c,b"])
Call morphism:
  From: Multivariate Polynomial Ring in a, c, b over Rational Field
  To:   Multivariate Polynomial Ring in b, c over Univariate Polynomial Ring in a over Rational Field
sage: QQ["a"]["b,c"].coerce_map_from(QQ["a,c,b"])(QQ["a,c,b"].1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
...
TypeError: c is not a constant polynomial

I found this while working on #39089 .
The coerce map is reported to exist by Sage only because __call__ is (incorrectly)
overridden by multipolynomial ring implementation (parents are not supposed to override
__call__, they should override _element_constructor_ instead).

Issue 2: sometimes R ← S and S ← T has coerce map, but R ← T has no coerce map

  • done
sage: R=QQ["a,b"]["c,d"]
....: S=QQ["a,b,c,d"]
....: T=QQ["a,c,b,d"]
....: U=QQ["a,c"]["b,d"]
sage: R.coerce_map_from(U) is None
True
sage: R.coerce_map_from(S) * S.coerce_map_from(T) * T.coerce_map_from(U)
Composite map:
  From: Multivariate Polynomial Ring in b, d over Multivariate Polynomial Ring in a, c over Rational Field
  To:   Multivariate Polynomial Ring in c, d over Multivariate Polynomial Ring in a, b over Rational Field
  Defn:   Coercion map:
          From: Multivariate Polynomial Ring in b, d over Multivariate Polynomial Ring in a, c over Rational Field
          To:   Multivariate Polynomial Ring in a, c, b, d over Rational Field
        then
          Coercion map:
          From: Multivariate Polynomial Ring in a, c, b, d over Rational Field
          To:   Multivariate Polynomial Ring in a, b, c, d over Rational Field
        then
          Call morphism:
          From: Multivariate Polynomial Ring in a, b, c, d over Rational Field
          To:   Multivariate Polynomial Ring in c, d over Multivariate Polynomial Ring in a, b over Rational Field

Issue 3: nested polynomial ring with coinciding variable name lead to non-commuting coerce map

  • done
(
		QQ["a,b"]["a,c"].coerce_map_from(QQ["b"]["a,c"])
		* QQ["b"]["a,c"].coerce_map_from(QQ["a"])
		)(QQ["a"].0) == QQ["a,b"]["a,c"].coerce_map_from(QQ["a"])(QQ["a"].0)

(
		QQ["a,b"][["a,c"]].coerce_map_from(QQ["b"][["a,c"]])
		* QQ["b"][["a,c"]].coerce_map_from(QQ["a"])
		)(QQ["a"].0) == QQ["a,b"][["a,c"]].coerce_map_from(QQ["a"])(QQ["a"].0)

(
		QQ[["a,b"]][["a,c"]].coerce_map_from(QQ[["b"]][["a,c"]])
		* QQ[["b"]][["a,c"]].coerce_map_from(QQ[["a"]])
		)(QQ[["a"]].0) == QQ[["a,b"]][["a,c"]].coerce_map_from(QQ[["a"]])(QQ[["a"]].0)

It looks impossible to resolve this issue, unless we deprecate the construction of nested polynomial/power series/Laurent polynomial/series ring/etc. with same variable names.

It gets worse — what about quotient rings?

sage: R.<a,b>=QQ[]
sage: S=R.quotient(a^2+1)
sage: (S["a,c"].coerce_map_from(QQ["b"]["a,c"]) * QQ["b"]["a,c"].coerce_map_from(QQ["a"]))(QQ["a"].0)
a
sage: (S["a,c"].coerce_map_from(QQ["a"]))(QQ["a"].0)
abar

Issue 4: un-flattening morphism may or may not be coercion map depends on univariate/multivariate case

  • done
sage: R = QQ["a"]["b"]
sage: S = R.flattening_morphism().codomain()
sage: R.coerce_map_from(S)
sage: S.coerce_map_from(R)
Coercion map:
  From: Univariate Polynomial Ring in b over Univariate Polynomial Ring in a over Rational Field
  To:   Multivariate Polynomial Ring in a, b over Rational Field
sage: R = QQ["a,b"]["c,d"]
sage: S = R.flattening_morphism().codomain()
sage: R.coerce_map_from(S)
Call morphism:
  From: Multivariate Polynomial Ring in a, b, c, d over Rational Field
  To:   Multivariate Polynomial Ring in c, d over Multivariate Polynomial Ring in a, b over Rational
 Field
sage: S.coerce_map_from(R)
Coercion map:
  From: Multivariate Polynomial Ring in c, d over Multivariate Polynomial Ring in a, b over Rational
 Field
  To:   Multivariate Polynomial Ring in a, b, c, d over Rational Field

Environment

  • OS: Linux
  • Sage Version: latest development source

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant