[libmath-prime-util-perl] 146/181: Trim some tests, convert some proofs to new cert format, more tests work with pre-5.8 64-bit

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:51:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.36
in repository libmath-prime-util-perl.

commit a0d9c79ce007be5e4f4d1d5224ac0e1e5865c050
Author: Dana Jacobsen <dana at acm.org>
Date:   Wed Jan 8 19:40:45 2014 -0800

    Trim some tests, convert some proofs to new cert format, more tests work with pre-5.8 64-bit
---
 t/23-primality-proofs.t | 180 +++++++++++++++++++++++++++++++++---------------
 t/80-pp.t               |  42 +++++------
 2 files changed, 147 insertions(+), 75 deletions(-)

diff --git a/t/23-primality-proofs.t b/t/23-primality-proofs.t
index 25edfde..cdc5912 100644
--- a/t/23-primality-proofs.t
+++ b/t/23-primality-proofs.t
@@ -15,12 +15,21 @@ BEGIN {
   $use_test_warn = $@ ? 0 : 1;
 }
 
-my $extra = defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING};
+my $extra = 0+(defined $ENV{EXTENDED_TESTING} && $ENV{EXTENDED_TESTING});
 my $use64 = ~0 > 4294967295;
 my $broken64 = (18446744073709550592 == ~0);
+# Do some tests only if:
+#   EXTENDED_TESTING is on OR we have the GMP backend
+# Note that with Calc, these things are incredibly slow.
+my $doexpensive = 0 + ($extra || ( (!$use64 || !$broken64) && Math::BigInt->config()->{lib} eq 'Math::BigInt::GMP' ));
 
-my @plist = qw/20907001 809120722675364249 677826928624294778921
-               980098182126316404630169387/;
+my @plist = qw/20907001 809120722675364249/;
+if ($extra || $use64) {
+  push @plist, "677826928624294778921";
+}
+if ($extra || prime_get_config->{'gmp'}) {
+  push @plist, "980098182126316404630169387";
+}
 
 ## This is too slow without Math::Prime::Util::GMP.
 #push @plist, '3364125245431456304736426076174232972735419017865223025179282077503701'
@@ -39,12 +48,17 @@ my @plist = qw/20907001 809120722675364249 677826928624294778921
 
 plan tests => 0
             + 2  # is_provable_prime
-            + 5 * scalar(@plist)
-            + 6  # hand-done proofs
+            + 6 * scalar(@plist)
+                                   #  hand-done proofs
+            + 1*$doexpensive       #  n-1 for 2^521-1
+            + 1*$extra             #  n-1 for 2^607-1
+            #+ (($doexpensive && !$broken64) ? 1 : 0)  # n-1 proof
+            + (($doexpensive) ? 1 : 0)  # n-1 proof
+            + 2                    #  Pratt and ECPP
             + 28 # borked up certificates generate warnings
             + 6  # verification failures (tiny/BPSW)
             + 8  # verification failures (Lucas/Pratt)
-            + 11 # verification failures (n-1)
+            + 8  # verification failures (n-1)
             + 7  # verification failures (ECPP)
             + 3  # Verious other types
             + 0;
@@ -56,12 +70,8 @@ foreach my $p (@plist) {
  
   SKIP: {
     skip "Broken 64-bit causes trial factor to barf", 6
-      if $broken64 && $p > 2**48;
+      if $broken64 && $p > 2**60;
     ok( is_prime($p), "$p is prime" );
-    skip "These take a long time on non-64-bit.  Skipping", 5
-      if !$use64 && !$extra && $p =~ /^(6778|9800)/;
-    skip "Skipping a certificate without GMP", 5
-      if !prime_get_config->{'gmp'} && !$extra && $p =~ /^9800/;
     my($isp, $cert) = is_provable_prime_with_cert($p);
     is( $isp, 2, "   is_provable_prime_with_cert returns 2" );
     ok( defined($cert) && $cert =~ /^Type/m,
@@ -69,7 +79,7 @@ foreach my $p (@plist) {
     prime_set_config(verbose=>1);
     ok( verify_prime($cert), "   verification of certificate for $p done" );
     prime_set_config(verbose=>0);
-    # Note, in some cases the two certs could be non-equal (but both must be valid!)
+    # Note, in some cases the certs could be non-equal (but both must be valid!)
     my $cert2 = prime_certificate($p);
     ok( defined($cert2) && $cert2 =~ /^Type/m,
         "   prime_certificate is also non-null" );
@@ -81,47 +91,81 @@ foreach my $p (@plist) {
   }
 }
 
-# TODO: All these proofs are using the old format.  That's ok for now,
-# as verify_prime will convert them for us.  But we really should do
-# testing with the new format, including possible errors it could have.
-
 # Some hand-done proofs
-SKIP: {
-  skip "Skipping 2**521-1 verification without Math::BigInt::GMP", 1
-       unless Math::BigInt->config()->{lib} eq 'Math::BigInt::GMP';
-  my @proof = ('6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151', 'n-1',
-  [ 2,3,5,11,17,31,41,53,131,157,521,1613,61681,8191,42641,858001,51481, '7623851', '308761441' ],
-  [ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 ] );
-  ok( verify_prime(@proof), "2**521-1 primality proof verified" );
-}
-SKIP: {
-  skip "Skipping 2**607-1 verification without Math::BigInt::GMP", 1
-       unless Math::BigInt->config()->{lib} eq 'Math::BigInt::GMP';
-  skip "Skipping 2**607-1 verification on broken Perl", 1 if $broken64;
-  my @proof = ('531137992816767098689588206552468627329593117727031923199444138200403559860852242739162502265229285668889329486246501015346579337652707239409519978766587351943831270835393219031728127', 'n-1',
-  [ 2,3,7,607,'112102729', '341117531003194129', '7432339208719',
-    ['845100400152152934331135470251', 'n-1',
-      [2,5,11,31,41,101,251,601,1801],
-      [2,3,3,3,3,2,3,3,3]
-    ] ],
-  [ 3,5,3,2,3,3,3,3 ] );
-  ok( verify_prime(@proof), "2**607-1 primality proof verified" );
+if ($doexpensive) {
+  my $proof = <<EOPROOF;
+[MPU - Primality Certificate]
+Version 1.0
+
+Proof for:
+N 6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151
+
+Type BLS5
+N  6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151
+Q[1]  65427463921
+Q[2]  308761441
+Q[3]  7623851
+Q[4]  409891
+Q[5]  61681
+Q[6]  1613
+Q[7]  521
+Q[8]  157
+Q[9]  131
+Q[10]  53
+Q[11]  41
+Q[12]  31
+Q[13]  17
+A[0]  3
+A[1]  3
+A[2]  3
+A[3]  3
+A[4]  3
+A[5]  3
+A[6]  3
+A[8]  3
+A[9]  3
+A[10]  3
+A[11]  3
+A[12]  3
+A[13]  3
+----
+EOPROOF
+  ok( verify_prime($proof), "2**521-1 primality proof verified" );
 }
-#{
-#  my @proof = ('809120722675364249', "n-1", ["B", 20000, '22233477760919', 2], [2, 4549], [3, 2]);
-#  ok( verify_prime(@proof), "n-1 T7 primality proof of 809120722675364249 verified" );
-#}
-{
-  my @proof = (20907001, "Pratt", [ 2,
-                                 3,
-                                 5,
-                                 [23,"Pratt",[2,[11,"Pratt",[2,5],2]],5],
-                                 [101, "Pratt", [2, 5], 2],
-                               ], 14 );
-  ok( verify_prime(@proof), "simple Lucas/Pratt proof verified" );
+if ($extra) {
+  my $proof = <<EOPROOF;
+[MPU - Primality Certificate]
+Version 1.0
+
+Proof for:
+N 531137992816767098689588206552468627329593117727031923199444138200403559860852242739162502265229285668889329486246501015346579337652707239409519978766587351943831270835393219031728127
+
+Type BLS5
+N  531137992816767098689588206552468627329593117727031923199444138200403559860852242739162502265229285668889329486246501015346579337652707239409519978766587351943831270835393219031728127
+Q[1]  845100400152152934331135470251
+Q[2]  341117531003194129
+Q[3]  7432339208719
+Q[4]  607
+A[0]  3
+A[1]  3
+A[2]  3
+A[3]  3
+----
+
+Type BLS5
+N  845100400152152934331135470251
+Q[1]  1801
+Q[2]  601
+Q[3]  251
+Q[4]  101
+A[1]  3
+A[2]  3
+A[3]  3
+----
+EOPROOF
+  ok( verify_prime($proof), "2**607-1 primality proof verified" );
 }
-SKIP: {
-  skip "Skipping n-1 verification on broken Perl", 1 if $broken64;
+if ($doexpensive) {
   my @proof = ('3364125245431456304736426076174232972735419017865223025179282077503701', 'n-1',
     [2,5,127, ['28432789963853652887491983185920687231739655787', 'n-1',
                 [ 2,3,163,650933, [ '44662634059309451871488121651101494489', 'n-1',
@@ -135,9 +179,38 @@ SKIP: {
   ok( verify_prime(@proof), "simple n-1 proof verified" );
 }
 {
-  my @proof = ('677826928624294778921',"AGKM", ['677826928624294778921', '404277700094248015180', '599134911995823048257', '677826928656744857936', '104088901820753203', ['2293544533', '356794037129589115041']], ['104088901820753203', '0', '73704321689372825', '104088902465395836', '1112795797', ['3380482019', '53320146243107032']], ['1112795797', '0', '638297481', '1112860899', '39019', ['166385704', '356512285']]);
-  ok( verify_prime(@proof), "ECPP primality proof of 677826928624294778921 verified" );
+  my @proof = (20907001, "Pratt", [ 2,
+                                 3,
+                                 5,
+                                 [23,"Pratt",[2,[11,"Pratt",[2,5],2]],5],
+                                 [101, "Pratt", [2, 5], 2],
+                               ], 14 );
+  ok( verify_prime(@proof), "simple Lucas/Pratt proof verified" );
 }
+{
+  my $proof = <<EOPROOF;
+[MPU - Primality Certificate]
+Version 1.0
+
+Proof for:
+N 1030291136596639351761062717
+
+Type ECPP
+N  1030291136596639351761062717
+A  1030291136596639351761062709
+B  0
+M  1030291136596575744618987466
+Q  317851433704525489
+X  4215121326
+Y  246323849244309081587435955
+EOPROOF
+
+  ok( verify_prime($proof), "ECPP primality proof of 1030291136596639351761062717 verified" );
+}
+#{
+#  my @proof = ('809120722675364249', "n-1", ["B", 20000, '22233477760919', 2], [2, 4549], [3, 2]);
+#  ok( verify_prime(@proof), "n-1 T7 primality proof of 809120722675364249 verified" );
+#}
 
 # Failures for verify_prime
 
@@ -265,8 +338,7 @@ is( verify_prime([1490266103, "ECPP",
                  [694361, 694358, 0, 695162, [26737, "n-1", [2],[2]], [348008, 638945]]]),
                  0, "ECPP non-prime last q" );
 
-SKIP: {
-  skip "Skipping additional verifications on broken Perl", 3 if $broken64;
+{
   my $header = "[MPU - Primality Certificate]\nVersion 1.0\nProof for:";
   {
   my $cert = join "\n", $header,
diff --git a/t/80-pp.t b/t/80-pp.t
index fc937c1..fa5340a 100644
--- a/t/80-pp.t
+++ b/t/80-pp.t
@@ -41,27 +41,27 @@ my @composites = qw/
 
 # pseudoprimes to various small prime bases
 my %pseudoprimes = (
-   2 => [ qw/2047 3277 4033 4681 8321 15841 29341 42799 49141 52633 65281 74665 80581 85489 88357 90751/ ],
-   3 => [ qw/121 703 1891 3281 8401 8911 10585 12403  87913 88573 97567/ ],
-   5 => [ qw/781 1541 5461 5611 7813 13021 14981  44801 53971 79381/ ],
-   7 => [ qw/25 325 703 2101 2353 4525 11041  79381 87673 88399 88831/ ],
-  11 => [ qw/133 793 2047 4577 5041 12403 13333  86347 87913 88831/ ],
-  13 => [ qw/85 1099 5149 7107 8911 9637 13019  75241 83333 85285 86347/ ],
-  17 => [ qw/9 91 145 781 1111 2821 4033 4187  78881 88831 96433 97921 98671/ ],
-  19 => [ qw/9 49 169 343 1849 2353 2701 4033  66421 68257 73555 96049/ ],
-  23 => [ qw/169 265 553 1271 2701 4033 4371  62849 82513 96049/ ],
-  29 => [ qw/15 91 341 469 871 2257 4371 4411  48133 49141 54913 79003/ ],
-  31 => [ qw/15 49 133 481 931 6241 8911 9131  79003 83333 87061 88183/ ],
-  37 => [ qw/9 451 469 589 685 817 1333 3781  79501 83333 84151 96727/ ],
-  61 => [ qw/217 341 1261 2701 3661 6541 6697  76301 77421 79381 80041/ ],
-  73 => [ qw/205 259 533 1441 1921 2665 3439  67069 76429 79501 93521/ ],
- psp2       => [ qw/341 561 645 1105 1387 1729  8321 8481 8911 10261 10585/ ],
- psp3       => [ qw/91 121 286 671 703 949 1105  7381 8401 8911 10585 11011/ ],
- lucas      => [ qw/9179 10877 11419 11663 13919  18407 18971 19043/ ],
- slucas     => [ qw/5459 5777 10877 16109 18971  40309 58519 75077/ ],
- eslucas    => [ qw/989 3239 5777 10877 27971  72389 73919 75077 100127/ ],
- aeslucas1  => [ qw/989 3239 5777 10469 10877 27971 29681 30739 31631 39059 72389 73919 75077 100127/ ],
- aeslucas2  => [ qw/3239 4531 5777 10877 12209  36079 37949 47849 50959/ ],
+   2 => [ qw/2047   42799 4335241 1078467589/ ],
+   3 => [ qw/121    44287 4252381 1075490821/ ],
+   5 => [ qw/781    38081 4265257 1075156291/ ],
+   7 => [ qw/25 325 29857 4411681 1074439981/ ],
+  11 => [ qw/133    43213 4224533 1076929261/ ],
+  13 => [ qw/85     35371 4336879 1079159203/ ],
+  17 => [ qw/9 91   71071 4224533 1076237119/ ],
+  19 => [ qw/9 49   49771 4384693 1074718783/ ],
+  23 => [ qw/169    25201 4219129 1079063371/ ],
+  29 => [ qw/15 91  48133 4219129 1075151447/ ],
+  31 => [ qw/15 49  29341 4270657 1073833843/ ],
+  37 => [ qw/9 451  59563 4287817 1075430539/ ],
+  61 => [ qw/217    79381 4219129 1079326249/ ],
+  73 => [ qw/205    34219 4321153 1074220489/ ],
+ psp2       => [ qw/341 561       29341 4259905 1073823745/ ],
+ psp3       => [ qw/91 121        44287 4252381 1073827147/ ],
+ lucas      => [ qw/9179 10877    44099 4259789 1074039119/ ],
+ slucas     => [ qw/5459 5777     75077 4309631 1080085439/ ],
+ eslucas    => [ qw/989 3239 5777 72389 4226777 1076503199/ ],
+ aeslucas1  => [ qw/989 10469     39059 4269341 1076503199/ ],
+ aeslucas2  => [ qw/4531 12209    62479 4403027 1074695441/ ],
 );
 # Test a pseudoprime larger than 2^32.
 push @{$pseudoprimes{2}}, 75792980677 if $use64;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git



More information about the Pkg-perl-cvs-commits mailing list