Opened 7 years ago

Closed 7 years ago

#18275 closed defect (fixed)

subtraction fails for cartesian products of rings

Reported by: vdelecroix Owned by:
Priority: major Milestone: sage-6.7
Component: algebra Keywords:
Cc: nthiery Merged in:
Authors: Vincent Delecroix Reviewers: Jori Mäntysalo
Report Upstream: N/A Work issues:
Branch: 8cd8bba (Commits, GitHub, GitLab) Commit: 8cd8bbabfcb478512864a551efd4157c2ac43d7e
Dependencies: Stopgaps:

Status badges

Description

sage: C = GF(5).cartesian_product(GF(5))
sage: C.one() - C.one()
... BOOOOM (infinite recursion) ...

The reason is that there is no default implementation of _sub_ in ElementMethods of Rings (whereas there is one in sage.structure.element.RingElement).

Change History (5)

comment:1 Changed 7 years ago by vdelecroix

  • Authors set to Vincent Delecroix
  • Branch set to u/vdelecroix/18275
  • Commit set to 8cd8bbabfcb478512864a551efd4157c2ac43d7e
  • Status changed from new to needs_review

New commits:

8cd8bbaTrac 18275: fix __sub__ for additive magmas

comment:2 follow-up: Changed 7 years ago by jmantysalo

  • Reviewers set to Jori Mäntysalo
  • Status changed from needs_review to positive_review

Seems to be OK. If you want to modify something, maybe add a phrase like "By default a-b is defined just as a sum of a and the negation of b."

comment:3 in reply to: ↑ 2 Changed 7 years ago by vdelecroix

Replying to jmantysalo:

Seems to be OK. If you want to modify something, maybe add a phrase like "By default a-b is defined just as a sum of a and the negation of b."

I do not especially want to modify something ;-) Actually this is what is in sage.structure.element.RingElement. But not all ring elements inherit from it. Hence the failure.

comment:4 Changed 7 years ago by jmantysalo

Yep, so the real problem behind this specific error is that there is no .direct_product(...) for rings (like at least groups have). But I think that (default) definition A-B := A+(-B) is always the right thing to do.

comment:5 Changed 7 years ago by vbraun

  • Branch changed from u/vdelecroix/18275 to 8cd8bbabfcb478512864a551efd4157c2ac43d7e
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.