OKlibrary  0.2.1.6
Numbers.mac
Go to the documentation of this file.
00001 /* Matthew Gwynne, 25.11.2008 (Swansea) */
00002 /* Copyright 2008, 2009 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 
00024 kill(f)$
00025 
00026 okltest_ramsey(f) := block(
00027   for i : 1 thru 5 do
00028     assert(f([2,[1,i]]) = 1),
00029   assert(f([2,[3,3]]) = 6),
00030   assert(f([2,[4,4]]) = 18),
00031   assert(f([2,[3,3,3]]) = 17),
00032   true)$
00033 
00034 
00035 okltest_ramsey_p(f) := block(
00036   assert(not f([])),
00037   for i : -5 thru 5 do
00038     assert(not f([i])),
00039   assert(not f(["test"])),
00040   assert(not f(["test",[]])),
00041   assert(not f([1,["test"]])),
00042   for i : 0 thru 5 do
00043     assert(f([i,[i]])),
00044   for i : 0 thru 5 do
00045     assert(not f([i,[]])),
00046   assert(f([2,[3,3]])),
00047   assert(f([2,[4,5]])),
00048   assert(f([2,[4,5,6,7,8,9]])),
00049   assert(not f([2,"test"])),
00050   true)$
00051 
00052 
00053 /* *****************
00054    * Trivial cases *
00055    *****************
00056 */
00057 
00058 okltest_ramseyr0_a(f) := block(
00059   for i : 1 thru 5 do
00060     assert(f([1,[]]) = []),
00061   assert(f([1,[1,5]]) = []),
00062   assert(f([2,[1,5]]) = []),
00063   assert(f([]) = []),
00064   assert(f([1,2,3]) = []),
00065   assert(f([-1,[-3,-4]]) = []),
00066   assert(f([-1,4]) = []),
00067   assert(f([0,[1,5]]) = [5]),
00068   assert(f([0,[1,2]]) = [2]),
00069   true)$
00070 
00071 
00072 okltest_ramseyr0(f) := block(
00073   for i : 0 thru 5 do
00074     assert(f(i) = i),
00075   true)$
00076 
00077 okltest_ramseytrivle_a(f) := block(
00078   for i : 1 thru 5 do
00079     assert(f([1,[]]) = []),
00080   assert(f([1,[1,5]]) = []),
00081   assert(f([2,[1,5]]) = [1]),
00082   assert(f([]) = []),
00083   assert(f([1,2,3]) = []),
00084   assert(f([-1,[-3,-4]]) = []),
00085   assert(f([-1,4]) = []),
00086   true)$
00087 
00088 
00089 okltest_ramseytrivle(f) := block(
00090   for i : 0 thru 5 do
00091     assert(f(i) = i),
00092   true)$
00093 
00094 
00095 okltest_ramseytriveq_a(f) := block( 
00096   for i : 1 thru 5 do
00097     assert(f([1,[]]) = []),
00098   assert(f([1,[1,5]]) = [[1,[5]]]),
00099   assert(f([2,[1,5]]) = []),
00100   assert(f([]) = []),
00101   assert(f([1,2,3]) = []),
00102   assert(f([-1,[-3,-4]]) = []),
00103   assert(f([-1,4]) = []),
00104   true)$
00105 
00106 
00107 okltest_ramseytriveq(f) := block(
00108   assert(f([2,[2,3,3]]) = 6),
00109   assert(f([2,[2,2,2,4,4]]) = 18),
00110   true)$
00111 
00112 
00113 okltest_ramseytrivk_a(f) := block(
00114   for i : 1 thru 5 do
00115     assert(f([1,[]]) = []),
00116   for i : 1 thru 5 do
00117     assert(f([i,[i]]) = [i]),
00118   assert(f([2,[1,1]]) = []),
00119   assert(f([]) = []),
00120   assert(f([1,2,3]) = []),
00121   assert(f([-1,[-3,-4]]) = []),
00122   assert(f([-1,4]) = []),
00123   true)$
00124 
00125 
00126 okltest_ramseytrivk(f) := block(
00127   for i : 0 thru 5 do
00128     assert(f(i) = i),
00129   true)$
00130 
00131 /* *********************
00132    * Two-colour graphs *
00133    *********************
00134 */
00135 
00136 okltest_ramseyg2_3_a(f) := block(
00137   for i : 3 thru 5 do
00138     assert(f([i,[3,4]]) = []),
00139   assert(f([2,[]]) = []),
00140   assert(f([2,[3]]) = []),
00141   assert(f([2,[3,4]]) = [4]),
00142   assert(f([]) = []),
00143   assert(f([1,2,3]) = []),
00144   assert(f([-1,[-3,-4]]) = []),
00145   assert(f([-1,4]) = []),
00146   true)$
00147 
00148 
00149 okltest_ramseyg2_3(f) := block(
00150   assert(f(1) = 1),
00151   assert(f(2) = 3),
00152   assert(f(3) = 6),
00153   true)$
00154 
00155 
00156 okltest_ramseyg2_4_a(f) := block(
00157   for i : 3 thru 5 do
00158     assert(f([i,[3,4]]) = []),
00159   assert(f([2,[]]) = []),
00160   assert(f([2,[3]]) = []),
00161   assert(f([2,[3,4]]) = []),
00162   assert(f([2,[4,5]]) = [5]),
00163   assert(f([]) = []),
00164   assert(f([1,2,3]) = []),
00165   assert(f([-1,[-3,-4]]) = []),
00166   assert(f([-1,4]) = []),
00167   true)$
00168 
00169 
00170 okltest_ramseyg2_4(f) := block(
00171   assert(f(1) = 1),
00172   assert(f(2) = 4),
00173   assert(f(4) = 18),
00174   true)$
00175 
00176 okltest_ramseyg2_5_a(f) := block(
00177   for i : 3 thru 5 do
00178     assert(f([i,[3,4]]) = []),
00179   assert(f([2,[]]) = []),
00180   assert(f([2,[3]]) = []),
00181   assert(f([2,[3,4]]) = []),
00182   assert(f([2,[4,5]]) = []),
00183   assert(f([2,[5,6]]) = [6]),
00184   assert(f([]) = []),
00185   assert(f([1,2,3]) = []),
00186   assert(f([-1,[-3,-4]]) = []),
00187   assert(f([-1,4]) = []),
00188   true)$
00189 
00190 
00191 okltest_ramseyg2_5(f) := block(
00192   assert(f(1) = 1),
00193   assert(f(2) = 5),
00194   assert(f(4) = 25),
00195   assert(f(5) # unknown),
00196   true)$
00197 
00198 
00199 okltest_ramseyg2_6_a(f) := block(
00200   for i : 3 thru 5 do
00201     assert(f([i,[3,4]]) = []),
00202   assert(f([2,[]]) = []),
00203   assert(f([2,[3]]) = []),
00204   assert(f([2,[3,4]]) = []),
00205   assert(f([2,[4,5]]) = []),
00206   assert(f([2,[6,7]]) = [7]),
00207   assert(f([]) = []),
00208   assert(f([1,2,3]) = []),
00209   assert(f([-1,[-3,-4]]) = []),
00210   assert(f([-1,4]) = []),
00211   true)$
00212 
00213 okltest_ramseyg2_6(f) := block(
00214   assert(f(1) = 1),
00215   assert(f(2) = 6),
00216   assert(f(3) = 18),
00217   assert(f(4) # unknown),
00218   true)$
00219 
00220 
00221 okltest_ramseyg2_7_a(f) := block(
00222   for i : 3 thru 5 do
00223     assert(f([i,[3,4]]) = []),
00224   assert(f([2,[]]) = []),
00225   assert(f([2,[3]]) = []),
00226   assert(f([2,[3,4]]) = []),
00227   assert(f([2,[4,5]]) = []),
00228   assert(f([2,[7,8]]) = [8]),
00229   assert(f([]) = []),
00230   assert(f([1,2,3]) = []),
00231   assert(f([-1,[-3,-4]]) = []),
00232   assert(f([-1,4]) = []),
00233   true)$
00234 
00235 
00236 okltest_ramseyg2_7(f) := block(
00237   assert(f(1) = 1),
00238   assert(f(2) = 7),
00239   assert(f(3) = 23),
00240   assert(f(4) # unknown),
00241   true)$
00242 
00243 
00244 okltest_ramseyg2_8_a(f) := block(
00245   for i : 3 thru 5 do
00246     assert(f([i,[3,4]]) = []),
00247   assert(f([2,[]]) = []),
00248   assert(f([2,[3]]) = []),
00249   assert(f([2,[3,4]]) = []),
00250   assert(f([2,[4,5]]) = []),
00251   assert(f([2,[8,9]]) = [9]),
00252   assert(f([]) = []),
00253   assert(f([1,2,3]) = []),
00254   assert(f([-1,[-3,-4]]) = []),
00255   assert(f([-1,4]) = []),
00256   true)$
00257 
00258 
00259 okltest_ramseyg2_8(f) := block(
00260   assert(f(1) = 1),
00261   assert(f(2) = 8),
00262   assert(f(3) = 28),
00263   assert(f(4) # unknown),
00264   true)$
00265 
00266 
00267 okltest_ramseyg2_9(f) := block(
00268   assert(f(1) = 1),
00269   assert(f(2) = 9),
00270   assert(f(3) = 36),
00271   assert(f(4) # unknown),
00272   true)$
00273 
00274 
00275 okltest_ramseyg2_9_a(f) := block(
00276   for i : 3 thru 5 do
00277     assert(f([i,[3,4]]) = []),
00278   assert(f([2,[]]) = []),
00279   assert(f([2,[3]]) = []),
00280   assert(f([2,[3,4]]) = []),
00281   assert(f([2,[4,5]]) = []),
00282   assert(f([2,[9,10]]) = [10]),
00283   assert(f([]) = []),
00284   assert(f([1,2,3]) = []),
00285   assert(f([-1,[-3,-4]]) = []),
00286   assert(f([-1,4]) = []),
00287   true)$
00288 
00289 
00290 okltest_ramseyg2_10(f) := block(
00291   assert(f(1) = 1),
00292   assert(f(2) = 10),
00293   assert(f(3) # unknown),
00294   true)$
00295 
00296 
00297 okltest_ramseyg2_10_a(f) := block(
00298   for i : 3 thru 5 do
00299     assert(f([i,[3,4]]) = []),
00300   assert(f([2,[]]) = []),
00301   assert(f([2,[3]]) = []),
00302   assert(f([2,[3,4]]) = []),
00303   assert(f([2,[4,5]]) = []),
00304   assert(f([2,[10,11]]) = [11]),
00305   assert(f([]) = []),
00306   assert(f([1,2,3]) = []),
00307   assert(f([-1,[-3,-4]]) = []),
00308   assert(f([-1,4]) = []),
00309   true)$
00310 
00311 
00312 okltest_ramseyg3_3_3_a(f) := block(
00313   for i : 3 thru 5 do
00314     assert(f([i,[3,4]]) = []),
00315   assert(f([2,[]]) = []),
00316   assert(f([2,[3]]) = []),
00317   assert(f([2,[3,4]]) = []),
00318   assert(f([2,[4,5]]) = []),
00319   assert(f([2,[3,3]]) = []),
00320   assert(f([2,[3,3,3]]) = [3]),
00321   assert(f([]) = []),
00322   assert(f([1,2,3]) = []),
00323   assert(f([-1,[-3,-4]]) = []),
00324   assert(f([-1,4]) = []),
00325   true)$
00326 
00327 
00328 okltest_ramseyg3_3_3(f) := block(
00329   assert(f(1) = 1),
00330   assert(f(2) = 6),
00331   assert(f(3) = 17),
00332   true)$
00333 
00334 /* ***************
00335    * Hypergraphs *
00336    ***************
00337 */
00338 
00339 okltest_ramseyhg3_2_4_a(f) := block(
00340   for i : 3 thru 5 do
00341     assert(f([i,[3,4]]) = []),
00342   assert(f([2,[]]) = []),
00343   assert(f([2,[3]]) = []),
00344   assert(f([2,[3,4]]) = []),
00345   assert(f([2,[4,5]]) = []),
00346   assert(f([2,[5,6]]) = []),
00347   assert(f([3,[5,6]]) = []),
00348   assert(f([3,[4,6]]) = [6]),
00349   assert(f([]) = []),
00350   assert(f([1,2,3]) = []),
00351   assert(f([-1,[-3,-4]]) = []),
00352   assert(f([-1,4]) = []),
00353   true)$
00354 
00355 
00356 okltest_ramseyhg3_2_4(f) := block(
00357   assert(f(4) = 13),
00358   true)$
00359 
00360 
00361 /* **********
00362    * Bounds *
00363    **********
00364 */
00365 
00366 okltest_ramsey_ub(f) := block(
00367   for i : 1 thru 5 do 
00368     assert(f(i) = i),
00369   for i : 1 thru 5 do
00370     assert(f([1,i]) = i),
00371   assert(f(200) = 200),
00372   assert(f([100,200]) = 200),
00373   true)$
00374 
00375 okltest_ramsey_ub_s(f) := block(
00376   for i : 1 thru 5 do 
00377     assert(f(i) = i),
00378   for i : 1 thru 5 do
00379     assert(f([1,i]) = i),
00380   assert(f(200) = 200),
00381   assert(f([100,200]) = 200),
00382   assert(f(unknown) = inf),
00383   assert(f([unknown,10]) = 10),
00384   assert(f([1,unknown]) = inf),
00385   true)$
00386 
00387 
00388 okltest_ramsey_lb(f) := block(
00389   for i : 1 thru 5 do 
00390     assert(f(i) = i),
00391   for i : 1 thru 5 do
00392     assert(f([i,i+10]) = i),
00393   assert(f(200) = 200),
00394   assert(f([100,200]) = 100),
00395   true)$
00396 
00397 okltest_ramsey_lb_s(f) := block(
00398   for i : 1 thru 5 do 
00399     assert(f(i) = i),
00400   for i : 1 thru 5 do
00401     assert(f([i,i+10]) = i),
00402   assert(f(200) = 200),
00403   assert(f([100,200]) = 100),
00404   assert(f(unknown) = 0),
00405   assert(f([unknown,10]) = 0),
00406   assert(f([1,unknown]) = 1),
00407   true)$
00408