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

Cantor-Zassenhaus may enter infinite loop over GF(2**k) and cannot be interrupted #16162

Closed
jpflori opened this issue Apr 14, 2014 · 33 comments
Closed

Comments

@jpflori
Copy link
Contributor

jpflori commented Apr 14, 2014

A solution is to use random polynomials just as for odd characteristic.

This also replaces calls to power_mod by calls to pow with three arguments which uses implementation optimized code for modular exponentiation.

CC: @defeo @pjbruin @sagetrac-sbesnier

Component: finite rings

Keywords: finite field polynomial root factor

Author: Jean-Pierre Flori

Branch/Commit: 80db6aa

Reviewer: Peter Bruin

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

@jpflori jpflori added this to the sage-6.2 milestone Apr 14, 2014
@jpflori
Copy link
Contributor Author

jpflori commented Apr 15, 2014

Commit: 4858154

@jpflori
Copy link
Contributor Author

jpflori commented Apr 15, 2014

Author: Jean-Pierre Flori

@jpflori
Copy link
Contributor Author

jpflori commented Apr 15, 2014

Changed keywords from none to finite field polynomial root factor

@jpflori
Copy link
Contributor Author

jpflori commented Apr 15, 2014

Branch: u/jpflori/ticket/16162

@jpflori
Copy link
Contributor Author

jpflori commented Apr 15, 2014

comment:1

The any_root should surely be refactored as well.
That will ease the implementation of special case more efficient methods.


New commits:

4858154Quick fix for infinite loop and bugs in Cantor-Zassenhaus implementation.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 15, 2014

Changed commit from 4858154 to a47c436

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 15, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

a47c436Correction for previous commit fixing Cantor-Zassenhaus.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 15, 2014

Changed commit from a47c436 to b3bda42

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 15, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

b3bda42Further little improvements for Cantor-Zassenhaus.

@jpflori

This comment has been minimized.

@jpflori jpflori changed the title (x**2+x+a).any_root() over GF(2**k) seemingly loops and cannot be interrupted Cantor-Zassenhaus may enter infinite loop over GF(2**k) and cannot be interrupted Apr 16, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@jpflori

This comment has been minimized.

@jpflori
Copy link
Contributor Author

jpflori commented May 16, 2014

comment:7

This looks good enough for me as a first step toward better factorization over finite fields.

@pjbruin
Copy link
Contributor

pjbruin commented May 16, 2014

comment:8

Could you add some doctests, e.g. an example that used to fail?

@jpflori
Copy link
Contributor Author

jpflori commented May 16, 2014

comment:9

Nice... while adding tests, I found a way to trigger segfaults.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 16, 2014

Changed commit from b3bda42 to 8c4907c

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 16, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

8c4907cAdd a few tests for Cantor-Zassenhaus fixes.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 16, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

9a10e7bFix previous doctests for Cantor-Zassenhaus.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 16, 2014

Changed commit from 8c4907c to 9a10e7b

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 16, 2014

Changed commit from 9a10e7b to 630bc0b

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 16, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

630bc0bBetter syntax for Cantor-Zassenhaus doctest.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 16, 2014

Changed commit from 630bc0b to 27ae9b7

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 16, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

27ae9b7Better use of modular exponentiation in Cantor-Zassenhaus + sig_on magic.

@jpflori
Copy link
Contributor Author

jpflori commented May 16, 2014

comment:14

Peter, please have a look at the sig_on/sig_off stuff.
I'm not sure what I've done is robust or even makes sense.

@pjbruin
Copy link
Contributor

pjbruin commented May 16, 2014

comment:15

You should not put anything inside a sig_on()...sig_off() block that can interfere with the Python interpreter. From the code it is not clear (to me) if that can happen.

Is the sig_on()...sig_off() to prevent segfaults, to allow the code to be interrupted, or both? If it is to prevent segfaults, you have to find out where this occurs (this can hopefully be narrowed down to pure Cython code with no calls to the Python interpreter) and wrap this as tightly as possible in sig_on()...sig_off(). If it is to allow Control-C, alarm() etc., you can also periodically check for interrupts (I don't remember the details right now).

@jpflori
Copy link
Contributor Author

jpflori commented May 16, 2014

comment:16

Nope, the segfaults were surely caused by the x**q computation with q = 2**50 (some overflow in NTL I'd say, but the issue might be a real one, at least now it does not happen anymore).

I added the sig_on magic to ensure you can interrupt the code (even in some of the while loops, not only because of x**q with large q stuff).
But it seems to me that some sig_on are now useless and potentially wrong as some Python code might get called at some point (in the spirit of your Python interpreter remark I guess), even if it wasn't before, maybe because of the pow modifications, though it does not really make sense to me.
Maybe some of the sig_on should be removed, but I'd definitely say some are needed.

Feel free to have a deeper look and modify the code, I won't touch that before tuesday.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 19, 2014

Changed commit from 27ae9b7 to fa6d509

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 19, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

d00de84Add examples for Cantor-Zassenhaus.
fa6d509Another try for Cantor-Zassenhaus without si_on/off.

@jpflori
Copy link
Contributor Author

jpflori commented May 19, 2014

comment:18

FYI, the segfault I got was really from:

sage: K.<a> = GF(2**10)
sage: R.<x> = K[]
sage: x**(2**33)

(Which really needs to ba allowed to be interrupted, and to be faster (for exp < 2**33), and fixed of course (for exp >= 2**33)...)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 19, 2014

Changed commit from fa6d509 to 80db6aa

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 19, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

80db6aaAdd sig_on magic for NTL polynomial exponentiation.

@jpflori
Copy link
Contributor Author

jpflori commented May 19, 2014

comment:20

Ok, the latest commit does not seem enough to let NTL be interrupted when allocating a huge array or something like that.
Not sure why.

Anyhow, this is not necessary to fix Sage's CZ implem and can be postponed.

@pjbruin
Copy link
Contributor

pjbruin commented May 21, 2014

Reviewer: Peter Bruin

@vbraun
Copy link
Member

vbraun commented May 22, 2014

Changed branch from u/jpflori/ticket/16162 to 80db6aa

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

3 participants