#Prior to publication, we desired to guarantee the correctness of our prime lists (i.e. the text documents containing the lists L(q,a)). #To do so, we decided to filter out potential flaws in our computations. Hereinafter, we fastly describe and analyze each step individually: #1) While loading the existing data, we thrust the correctness of the lists generated by Bennett et al. #2) Considering our auxiliary functions, only one of them might be compromised. Indeed, TBound only carries out a usual max computation and is not supposed to fail. # On the other hand, primes_in_AP_List uses a repeated application of the next_prime_in_AP function and might be flawed. # More precisely, the prime detection might produce false results. We essentially trust the built-in Pari/GP function, but neglect its exact implementation. # Thus, the potential flaw might stem from our simplification in the while loop, namely, assuming that P<2^64 is enough to guarantee primality. # This criterion might be compromised by a slightly modified version of the Pari/GP function inside the SAGEMath environment. # Note however, that in worst case a number has been classified as prime (although it is not) (i.e. a false positive). # Under no circumstances a number has been jumped (i.e. classified as composite when it was prime - a false negative). #3) Our final function is correct whenever the previous parts where correct. #To bypass the potential compromised computation highlighted in 2) and to verify the overall correctness of the given lists (i.e. no printing errors or compromised bits), #we wrote a verification algorithm. As no number might be forgotten to be classified as prime (if the number is in the list and is a prime, then it is indeed the smallest prime satisfying all criteria) #it is sufficient to test the primality of the computed numbers. #The final verification has been carried out on another machine and version of SAGE (limiting the impact of corrupted source files). def SecondaryPrimalityTest(): #This algorithm will take a text file generated by primes_in_AP_Bound and check whether all the numbers inside the prime lists L(q,a) are primes. File = open("PrimesInAP.txt", "r") #First, we open the file to be tested. line=File.readline() #To reduce memory of the work environment, we load only one line at a time. #Every line in the given document is formatted in the same manner, namely line="L(q,a)=[p1,p2,...,pn]\n". while line: #In order to work with the entries, we need to modify the strings and cast the entries into integers. #We will only indicate the change achieved by each line. line=line[:-2] #line="L(q,a)=[p1,p2,...,pn". Line=line.split("=[") #Line=["L(q,a)","p1,p2,...,pn"] PrimesString=Line[1].split(",") #PrimesString=["p1","p2",...,"pn"] Primes=list(map(int,PrimesString)) #Primes=[p1,p2,...,pn] Test=0 #Auxillary variable I=-1 #Auxillary variable for i in range(len(Primes)): if not Integer(Primes[i]).is_prime(proof=True): #We test now primality using a deterministic (primality certifying) primality test (not important which one is used by SAGE). Test=1 I=i break if Test==1: #If we find a composite among our presumed primes, the computation stops. print("There is a problem with "+Line[0]+" "+str(Primes[I])) print(str(Primes[I])+" is not prime!") break #Otherwise, the computation goes on with the next line. print(Line[0]) #Here again, the finished lists are shown to track the well functioning of the algorithm. line=File.readline() File.close #Luckily, no miscomputation has been detected during our second verification.