OKlibrary  0.2.1.6
GreenTao.mac
Go to the documentation of this file.
00001 /* Oliver Kullmann, 17.10.2009 (Swansea) */
00002 /* Copyright 2009, 2010 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007 
00022 oklib_include("OKlib/ComputerAlgebra/TestSystem/Lisp/Asserts.mac")$
00023 oklib_include("OKlib/ComputerAlgebra/Hypergraphs/Lisp/Generators/VanderWaerden.mac")$
00024 oklib_include("OKlib/ComputerAlgebra/Hypergraphs/Lisp/Generators/GreenTao.mac")$
00025 
00026 kill(f)$
00027 
00028 
00029 /* *****************************************
00030    * Arithmetic progressions in the primes *
00031    *****************************************
00032 */
00033 
00034 okltest_arithprog_primes_finish(f) := block(
00035   assert(okltest_arithprog_primes_finish_nm(buildq([f],lambda([k,p],f[k,p]))) = true),
00036   true)$
00037 
00038 okltest_arithprog_primes_finish_nm(f) := block([prp,prk],
00039   prp : 6, prk : true,
00040   assert(f(3,5) = []),
00041   assert(f(3,7) = [[3,5,7]]),
00042   assert(f(3,11) = [[3,7,11]]),
00043   assert(f(3,13) = []),
00044   assert(f(3,17) = [[5,11,17]]),
00045   assert(f(3,19) = [[3,11,19],[7,13,19]]),
00046   assert(f(3,29) = [[5,17,29],[17,23,29]]),
00047   prk : false,
00048   assert(f(4,5) = []),
00049   assert(f(4,7) = []),
00050   assert(f(4,11) = []),
00051   assert(f(4,13) = []),
00052   assert(f(4,17) = []),
00053   assert(f(4,19) = []),
00054   assert(f(4,23) = [[5,11,17,23]]),
00055   prp : 30, prk : true,
00056   assert(f(5,7) = []),
00057   assert(f(5,23) = []),
00058   assert(f(5,29) = [[5,11,17,23,29]]),
00059   /* XXX */
00060   true)$
00061 
00062 okltest_arithprog_primes(f) := (
00063   /* XXX */
00064   for k : 0 thru if oklib_test_level=0 then 4 else 6 do
00065     for n : 0 thru if oklib_test_level=0 then 10 else 40 do block(
00066      [A : setify(arithmetic_progressions(primes_first(n),k))],
00067       assert(setify(f(k,n,false)) = A),
00068       assert(setify(f(k,n,true)) = A)
00069   ),
00070   true)$
00071 
00072 okltest_arithprog_primes_ohg(f) := (
00073   assert(f(0,0) = [[],[{}]]),
00074   assert(f(0,1) = [[2],[{}]]),
00075   assert(f(1,0) = [[],[]]),
00076   assert(f(1,1) = [[2],[{2}]]),
00077   assert(f(1,2) = [[2,3],[{2},{3}]]),
00078   assert(f(2,0) = [[],[]]),
00079   assert(f(2,1) = [[2],[]]),
00080   assert(f(2,2) = [[2,3],[{2,3}]]),
00081   assert(f(2,3) = [[2,3,5],[{2,3},{2,5},{3,5}]]),
00082   assert(f(2,4) = [[2,3,5,7],[{2,3},{2,5},{3,5},{2,7},{3,7},{5,7}]]),
00083   assert(f(3,4) = [[2,3,5,7],[{3,5,7}]]),
00084   assert(f(3,5) = [[2,3,5,7,11],[{3,5,7},{3,7,11}]]),
00085   assert(f(3,6) = [[2,3,5,7,11,13],[{3,5,7},{3,7,11}]]),
00086   assert(f(3,8) = [[2,3,5,7,11,13,17,19],[{3,5,7},{3,7,11},{5,11,17},{3,11,19},{7,13,19}]]),
00087   true)$
00088 
00089 okltest_arithprog_primes_max_ohg(f) := block(
00090   assert(f(0,0) = [[],[{}]]),
00091   assert(f(0,1) = [[2],[{}]]),
00092   assert(f(1,1) = [[2],[{2}]]),
00093   assert(f(1,2) = [[2,3], [{2,3}]]),
00094   assert(f(1,3) = [[2,3,5], [{2,3},{2,5},{3,5}]]),
00095   assert(f(1,4) = [[2,3,5,7], [{2,3},{2,5},{2,7},{3,5,7}]]),
00096   assert(f(2,2) = [[2,3],[{2,3}]]),
00097   assert(f(2,3) = [[2,3,5],[{2,3},{2,5},{3,5}]]),
00098   assert(f(2,4) = [[2,3,5,7], [{2,3},{2,5},{2,7},{3,5,7}]]),
00099   /* XXX */
00100   if oklib_test_level = 0 then return(true),
00101   assert(setify(map(setify,lappend(map(lambda([P],arithmetic_progressions(listify(P),3)), f(3,100)[2])))) = arithprog_primes_hg(3,100)[2]),
00102   true)$
00103 
00104 
00105 /* **************
00106    * Statistics *
00107    **************
00108 */
00109 
00110 okltest_nver_arithprog_primes_ohg(f) := (
00111   for k : 0 thru 4 do
00112     for n : 0 thru 5 do
00113       assert(f(k,n) = length(arithprog_primes_ohg(k,n)[1])),
00114   true)$
00115 
00116 okltest_nver_arithprog_primes_hg(f) := (
00117   for k : 0 thru 4 do
00118     for n : 0 thru 5 do
00119       assert(f(k,n) = length(arithprog_primes_hg(k,n)[1])),
00120   true)$
00121 
00122 okltest_nhyp_arithprog_primes_ohg(f) := (
00123   for k : 0 thru if oklib_test_level=0 then 4 else 6 do
00124     for n : 0 thru if oklib_test_level=0 then 6 else 40 do
00125       assert(f(k,n) = length(arithprog_primes_ohg(k,n)[2])),
00126   true)$
00127 
00128 okltest_nhyp_arithprog_primes_hg(f) := (
00129   for k : 0 thru if oklib_test_level=0 then 4 else 6 do
00130     for n : 0 thru if oklib_test_level=0 then 6 else 40 do
00131       assert(f(k,n) = length(arithprog_primes_hg(k,n)[2])),
00132   true)$
00133 
00134 
00135 /* *******************
00136    * Standardisation *
00137    *******************
00138 */
00139 
00140 okltest_std_primes_ohg(f) := (
00141   assert(f([[],[]]) = [[],[]]),
00142   assert(f([[2,3],[]]) = [[1,2],[]]),
00143   assert(f([[2,3],[{2},{2,3},{3},{}]]) = [[1,2],[{1},{1,2},{2},{}]]),
00144   assert(f([[2,3,5,7,11],[{2,3,5},{3,7,11}]]) = [[1,2,3,4,5], [{1,2,3},{2,4,5}]]),
00145   true)$
00146