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

Fix membership in QQbar for number field elements -- canonical embedding of subfields #4621

Open
simon-king-jena opened this issue Nov 26, 2008 · 19 comments

Comments

@simon-king-jena
Copy link
Member

Reported by Alex Raichev
on sage-support.

sage: F.<a> = NumberField(x^2 - 2)
sage: a^2
2
sage: a^2 in QQ
True
sage: a^2 in QQbar
False
sage: 2 in QQbar
True 

or more directly

sage: F(2) in QQbar
False

Perhaps related to this is

sage: F.<a> = NumberField(x^2 - 2)
sage: QQ.is_subring(F)
True
sage: F.is_subring(QQbar)
False 

Robert Bradshow comments that F.is_subring(QQbar) should be False, because QQbar has a canonical embedding into CC, but F has not.

So, from that point of view, it makes sense that a^2 is in F but not in QQbar. However, a^2 is equal to 2 after all, and hence is in a part of F that does have a canonical embedding.

In other words, we have a field element x in F_1 such that there is in fact a subfield F_2 of F_1 with x in F_1. Moreover, we have a field F_3 such that F_2 has a canonical embedding into F_3, but F_1 has no canonical embedding.

Is it possible for Sage to detect that situation?

Idea: Is there a unique maximal subfield F_m of F_1 that has a canonical embedding into F_3? If there is, there could be a method max_subfield_coercing_into(...).

Then, in the original example, we probably have

sage: F.max_subfield_coercing_into(QQbar)
Rational Field

and then x in QQbar would answer True, since

sage: x in F_1.max_subfield_coercing_into(QQbar)
True

Sorry if that idea is not realistic.

CC: @kliem @slel

Component: algebra

Keywords: canonical embedding subfield

Issue created by migration from https://trac.sagemath.org/ticket/4621

@robertwb
Copy link
Contributor

Attachment: 4621-qqbar-embed.patch.gz

@robertwb
Copy link
Contributor

comment:1

This issue is fixed. Followup about embedding into QQbar at #7960.

@wjp
Copy link
Mannequin

wjp mannequin commented Jan 17, 2010

comment:3

A side effect of this patch is the following because it now tries to explicitly convert its argument to QQ. Is that desirable?

sage: GF(7)(2) in QQbar
True

(Related 'in's:

sage: GF(7)(2) in ZZ
True
sage: GF(7)(2) in QQ
False
sage: GF(7)(2) in QQbar
True

)

@wjp wjp mannequin added s: needs info and removed s: needs review labels Jan 17, 2010
@robertwb
Copy link
Contributor

comment:4

This exposes a separate but that == for QQbar is not symetric...

sage: GF(7)(2) == QQbar(2)
False
sage: QQbar(2) == GF(7)(2)
True # after the patch, BOOM before, should be False

@robertwb
Copy link
Contributor

comment:5

See #7984 for a fix for QQbar cmp.

@robertwb
Copy link
Contributor

comment:6

For this to return True, one would have to change the definition of canonical comparison--not something that should be done lightly.

@mwhansen
Copy link
Contributor

comment:7

Just a note -- this patch no longer works with #7984.

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@videlec
Copy link
Contributor

videlec commented Apr 8, 2015

comment:12

The reason why this fails is

sage: F.<a>= NumberField(x^2-2)
sage: two = F(2)
sage: QQbar(two)
Traceback (most recent call last):
...
TypeError: Illegal initializer for algebraic number

One way to fix it is to be more flexible on creation of algebraic number (in AA._element_constructor_ or QQbar._element_constructor_) or to implement a method _algebraic_ to number field elements.

Vincent

@videlec
Copy link
Contributor

videlec commented Apr 27, 2016

comment:13

Replying to @videlec:

The reason why this fails is

sage: F.<a>= NumberField(x^2-2)
sage: two = F(2)
sage: QQbar(two)
Traceback (most recent call last):
...
TypeError: Illegal initializer for algebraic number

One way to fix it is to be more flexible on creation of algebraic number (in AA._element_constructor_ or QQbar._element_constructor_) or to implement a method _algebraic_ to number field elements.

the above is fixed in #14485 and #20400 but it does not solve the containment test!

@mkoeppe mkoeppe modified the milestones: sage-6.4, sage-9.2 Jul 18, 2020
@mkoeppe mkoeppe modified the milestones: sage-9.2, sage-9.3 Oct 24, 2020
@slel
Copy link
Member

slel commented Mar 27, 2021

comment:16

To put it another way.

In Sage 9.3.rc0:

sage: root2 = QuadraticField(2).gen()
sage: root2 in QQbar, root2^2 in QQbar  # expected: (True, True)
(False, False)

@slel

This comment has been minimized.

@slel slel changed the title '2' not in QQbar -- canonical embedding of subfields Fix membership in QQbar for number field elements -- canonical embedding of subfields Mar 27, 2021
@videlec
Copy link
Contributor

videlec commented Mar 27, 2021

comment:17

Replying to @slel:

To put it another way.

In Sage 9.3.rc0:

sage: root2 = QuadraticField(2).gen()
sage: root2 in QQbar, root2^2 in QQbar  # expected: (True, True)
(False, False)

The embedding is not set by writing only QuadraticField(2) (see also #30518 comment:10). You can compare with

sage: root2 = QuadraticField(2, embedding=AA(2).sqrt()).gen()
sage: root2 in QQbar, root2^2 in QQbar
(True, True)

Though the following is definitely annoying

sage: QuadraticField(2).one() in QQbar  # would better be true
False

@videlec
Copy link
Contributor

videlec commented Mar 27, 2021

comment:18

Note that it will quickly become annoying with extensions

sage: K.<a> = QuadraticField(2, embedding=AA(2).sqrt())
sage: x = polygen(ZZ)
sage: L.<b> = K.extension(x**3 - x**2 - x - 1) 
  • Do you expect QQbar(L(a)) to work?
  • What should be the result of L(a) in QQbar?

@videlec
Copy link
Contributor

videlec commented Mar 27, 2021

comment:19

Note also that 1 == 1 does not hold in the following situation

sage: QuadraticField(2).one() == QuadraticField(3).one()
True

Again, with properly set embeddings it compares as a user might expect

sage: K2 = QuadraticField(2, embedding=AA(2).sqrt())
sage: K3 = QuadraticField(3, embedding=AA(3).sqrt())
sage: K2.one() == K3.one()
True

@videlec
Copy link
Contributor

videlec commented Mar 27, 2021

comment:20

The only way I can imagine a fix would be to implement intersection of parents as part of the coercion model. It would have at least the following requirements

  • C = A.intersection(B) is a parent with injective coercions in both A and B
  • A.intersection(B) is identical to B.intersection(A)

Given that, we could design a more reasonable sage.structure.element.Element.__richcmp__.

@slel
Copy link
Member

slel commented Apr 4, 2021

comment:21

Thanks for launching a discussion on sage-devel:

@mkoeppe
Copy link
Member

mkoeppe commented Apr 7, 2021

comment:22

Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Apr 7, 2021
@mkoeppe
Copy link
Member

mkoeppe commented Jul 19, 2021

comment:23

Setting a new milestone for this ticket based on a cursory review.

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe
Copy link
Member

mkoeppe commented Dec 18, 2021

comment:24

Stalled in needs_review or needs_info; likely won't make it into Sage 9.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants