Opened 10 years ago

Last modified 10 years ago

#12404 closed defect

is_squarefree() incorrect over imperfect fields — at Version 13

Reported by: saraedum Owned by: malb
Priority: minor Milestone: sage-5.1
Component: commutative algebra Keywords: sd40.5
Cc: sydahmad Merged in:
Authors: Julian Rueth Reviewers: Paul Zimmermann
Report Upstream: N/A Work issues: coherence with squarefree_decomposition, fix error
Branch: Commit:
Dependencies: #9054, #12988 Stopgaps:

Status badges

Description (last modified by saraedum)

The method is_squarefree() is incorrect for polynomials over function fields over finite fields:

sage: K.<x> = FunctionField(GF(3))
sage: R.<T> = K[]
sage: f=T^3-x
sage: f.factor(proof=False)
T^3 + 2*x
sage: f.is_squarefree()
False

Apply:

  1. trac_12404.patch
  2. trac_12404_warning.patch

to the sage library.

Change History (14)

comment:1 follow-up: Changed 10 years ago by saraedum

The method is_squarefree() returns self.derivative().gcd(self).degree() <= 0. In the example the derivative vanishes which leads to the incorrect behaviour.

As a quick workaround one can do:

True in [d>=2 for (f,d) in f.factor(proof=False)]

comment:2 in reply to: ↑ 1 Changed 10 years ago by saraedum

Replying to saraedum:

True in [d>=2 for (f,d) in f.factor(proof=False)]

This would be "is_not_squarefree()" of course.

comment:3 Changed 10 years ago by zimmerma

see also #12198.

Paul

comment:4 Changed 10 years ago by zimmerma

see also #12129.

Paul

comment:5 Changed 10 years ago by saraedum

Thanks for pointing these out. Since both are in the multivariate case, I don't think they're related.

comment:6 Changed 10 years ago by saraedum

  • Authors set to Julian Rueth
  • Dependencies changed from #9054 to #9054, #12404
  • Status changed from new to needs_review

The attached patch should fix the problem.

comment:7 Changed 10 years ago by saraedum

  • Dependencies changed from #9054, #12404 to #9054, #12988

comment:8 Changed 10 years ago by saraedum

  • Keywords sd40.5 added

comment:9 follow-up: Changed 10 years ago by zimmerma

  • Reviewers set to Paul Zimmermann
  • Status changed from needs_review to needs_work
  • Work issues set to coherence with squarefree_decomposition, fix error

the documentation of is_squarefree says that f is not square-free if g^2 divides f where g is a non-unit. In particular 4*x is not considered square free by is_squarefree, but it is by squarefree_decomposition:

sage: R.<x> = ZZ[]
sage: f = 4*x
sage: f.is_squarefree()
False
sage: f.squarefree_decomposition()
(4) * x

Sage should be coherent in that matter. Personally I prefer not to decompose the coefficient content.

Moreover the following produces an error:

sage: R.<x> = ZZ[]
sage: f = 2*x^2
sage: f.is_squarefree()
...
AttributeError: 'int' object has no attribute 'is_zero'

Paul

comment:10 in reply to: ↑ 9 Changed 10 years ago by saraedum

Replying to zimmerma:

the documentation of is_squarefree says that f is not square-free if g^2 divides f where g is a non-unit. In particular 4*x is not considered square free by is_squarefree, but it is by squarefree_decomposition:

sage: R.<x> = ZZ[]
sage: f = 4*x
sage: f.is_squarefree()
False
sage: f.squarefree_decomposition()
(4) * x

Sage should be coherent in that matter. Personally I prefer not to decompose the coefficient content.

That is true. I also noted this inconsistency. To not break existing code, I'd rather add a warning section in the docstring. Generally I agree that having squarefree_decomposition() factor the content is not what one wants for most purposes.

Would you be ok with just adding a warning and an example showing this problem?

Moreover the following produces an error:

sage: R.<x> = ZZ[]
sage: f = 2*x^2
sage: f.is_squarefree()
...
AttributeError: 'int' object has no attribute 'is_zero'

This should not happen when applying the dependency #12988.

comment:11 Changed 10 years ago by saraedum

  • Status changed from needs_work to needs_info

comment:12 Changed 10 years ago by saraedum

I added a patch with such a warning. I still have to check how it renders in the docs.

comment:13 Changed 10 years ago by saraedum

  • Description modified (diff)
  • Status changed from needs_info to needs_review

I made a few docstring changes in the latest patch.

Changed 10 years ago by saraedum

distinguish characteristic zero and nonzero

Note: See TracTickets for help on using tickets.