Karim Belabas on Mon, 08 Jul 2024 16:50:35 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Are there known false positives for GP ispseudoprime() ?
|
- To: hermann@stamm-wilbrandt.de
- Subject: Re: Are there known false positives for GP ispseudoprime() ?
- From: Karim Belabas <Karim.Belabas@math.u-bordeaux.fr>
- Date: Mon, 8 Jul 2024 16:50:30 +0200
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1720450232; c=relaxed/relaxed; bh=msR2anGdGdrRO91pyByhHWQ6eJWnRXYHZfh228weuo8=; h=DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: Mail-Followup-To:References:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; b=14t0bOkm3Yixy7VQNAwFwPr1QE0X33+qCV4RNh1QNFzroEKkEumZ9yFctYl95Z2K2DCClr8VDtcpjztFz96C74GMA0ZXyk2nd0hJxcTDdsJt3sV6Elo8TsUauwcaqxapRr/KOcpUzasnRraGd98U+ioazcaMr86kwRVqp4UNm5htxN/jEbLmG6gzcCd3JKJh3ERCfLwlv3b10ewF3adW20jWVh3MM4swrigz10496m6jydLRAjX0TNgh8tDBx+HsL/dsKr8LORPkTn1n3WEuSd8q3465H5cIyHtrbslnNznvcydhGfftzJ3Yw0MpBZYNR6wEqw/lfpNM2aWi7mad8VtWxicTTy8Lk+Hq+HgBWwPwwLwXiPLcAqWzPy+If4naSqlNvZlKEASmMPeJC5r/+R5hmj9s/Ssuz7i+Xt4KwXBrfhbdU0MGx8zN7ttA7cw2E1Qj9yIJvjYr9CnAF34J6S8SNBuEvzLYXJNMThJQ6ewazI1LGxV7Q6oTCdWVKsw1wZXdt1nLT5mz/xJAo8l14m28SHjIb3mcLiM93oX5a0Bms6BuDIH9sHrsuKxVsa5GRi5q3p/m1JIrUyikmPioaJIEPeMuW4OCUh2b/WfDeoGhyn1ld6exxNmM9sDPEnVGSvegaU/0CPkSzp0+olFuYJFVSFa51u3OI90UePRpF/s=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1720450232; cv=none; b=Rwmolftkg5xN2Y2XcMUyIz06pQjrvW562tr80lFWxLJYK6KfX4ERFy3rNuzt1jFxqA7eejKwfDrR0K5ex6w8EbURCKahJ2yyAgNb530OSu6NCYqaUgQYLDiwEQb2ulhwlTU9TNhMoekhiJKpSRoi9z5L18dexwTl4TlFkmQlTSN5WO76I+LtDgho9tq6BGf7uZySKML3Bx+p75gudKM/vzPfK+AgM/P3bG0ImdDzoz8U2VwSvN2l1O0HP9zGUTwy6GL9LU0X1GWjoswI2ED/HLb0/WYwqNtZ3D/e32HIfpSgO26KSU7LhyKatM+ParxAp3OuwtKKtYmeuwll3gIJ7Cd0LcPjcxyr+WhWHMUT9TSIcmnAnM4jI5O6eJzjzFd7Ya+RKOLuU2KAVVWZeIoOYdNeue8UOI9sBKbWemPERQq67riaTYZfn+PLQX712Eb44phuXBH0/SpLSy0YDOilLskPm9ErzSWZBNZvjv8V0cicMHubs/ttJ8gt87eiAaOMuyq7QOrle5qId2IPLt+vZYRA+kp0mAn/2yidYHp2tUzv6i0XFFxRLkEolagO4b/jwfy3Rer85xbTCYUpD9y7ojjr6aHB7KFYfy+1WbAYRjrHOEFcu72YSqIbs63es4NYXYialubSJk2IbXD9bT4g7JrP4u3VZyS4bmAG5xVL6Po=
- Authentication-results: smail; dmarc=none header.from=math.u-bordeaux.fr
- Authentication-results: smail; arc=none
- Cc: pari-users@pari.math.u-bordeaux.fr
- Delivery-date: Mon, 08 Jul 2024 16:50:36 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1720450232; bh=msR2anGdGdrRO91pyByhHWQ6eJWnRXYHZfh228weuo8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=f6E/9VmMxc6Emsp/eouUc1p/KMLGfpfVKy5Izd123VMg2cAdxwhliLbvqm/tOUcgL 9DTr97uTPj5IsbHtm3TAQbmVF57cmOJvLJQLe9hUNPztgv/cYhps5mE96+WUuh3s94 J13Ou2DIXj0d+uC8y0siA4rYLK2qLOjO5S7zPL2Da/CO3WpSz4dVKbcHLtFS/C2b9C OWo46/wu2ls7vn0N4/IifR7JWjkI/GaJB0Wnq3dERBH2kjBVKObdtA2tlZLHAFlwoO FQldmxkqv05NnuU2eUxjqxzFszMh+Rt5JbnL9bHZHcItIRoa7TzISdem9kW4HW+mtM QJGRZ/8lHEhFuqPqKjR8ZSNzPAiHOLvFqi0I4CCwONKyGiFlnYNh9wzC4lSfOBv4m9 WKpUaLeAxPfoHo27AkPaWRT1n8ZrmFnl2lKLb/G6soOYPV+hf6sfhrJUeC324womMe VWfUMtYBxnVgVIDU5zGbBr/elCwohjqR9SWpL+qyIk74Q5v/A/p5gPfIxczZGknGxT pZK3eZ0Cp1EdkAJgXIS15ARcWV9T6GtaQ9AnLWoZN00MC4ZHbAiG+rhXf0JVEoonks m/MWWYFhXIZSt6ieWVMtdFmhjUk5YqxmDAJY33+OzAEweQCrPOmFHFxT3ICnBvmLC2 52h2De/qJGplN8ej1oYLSQhA=
- In-reply-to: <43e29ee77ef095709739efa027750bb5@stamm-wilbrandt.de>
- Mail-followup-to: hermann@stamm-wilbrandt.de, pari-users@pari.math.u-bordeaux.fr
- References: <112d5de1e91aaaf96a99dd682950ca0c@stamm-wilbrandt.de> <ZovXFwDwg6fPCafH@math.u-bordeaux.fr> <43e29ee77ef095709739efa027750bb5@stamm-wilbrandt.de>
* hermann@stamm-wilbrandt.de [2024-07-08 16:01]:
[...]
> Btw, I found a small inconsistency in PARI/GP user guide vs. source:
> https://pari.math.u-bordeaux.fr/pub/pari/manuals/2.15.5/users.pdf#page=206
> "If flag = 0, checks whether x has no small prime divisors (up to 101
> included) ..."
>
> src/basemath/ispower.c has "static ulong tinyprimes[] = {2, 3, ..., 197,
> 199};"
Nope: this 'tinyprimes' table is only used in ispower().
The quoted documentation for ispseudoprime(, 0) is correct; see
basemath/prime.c:BPSW_psp()
lines 436-451.
> I was interested in which test was used in creating this error message:
>
> ? sqrt(Mod(-1,85))
> *** at top-level: sqrt(Mod(-1,85))
> *** ^----------------
> *** sqrt: not a prime number in sqrt [modulus]: 85.
[...]
> So BPSW_psp() is directly called, and ispseudoprime() flag is irrelevant for
> that code path.
ispseudoprime is never used in the PARI library; we usually use BPSW_psp()
[ which guarantees that a negative result is correct but may miss
(for know unkown) composites > 2^64 ].
The implementations follow the following general principle: we run an
"infinite" loop (usually making random choices) that is expected to halt
quickly if the precondition "p is prime" is met. After a "large
enough" number of failed tests, we perform a single BPSW_psp() test,
which is expected to quickly detect composites.
In practice, if "p" is indeed prime, the loop halts before the
BPSW_psp() test is run. And if not, we either trigger the aforementioned
pari_err_PRIME / e_PRIME exception, or the loop runs forever
[no instance known]
Cheers,
K.B.
--
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/