OKlibrary  0.2.1.6
Hindman.mac
Go to the documentation of this file.
00001 /* Oliver Kullmann, 12.7.2009 (Swansea) */
00002 /* Copyright 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 oklib_include("OKlib/ComputerAlgebra/Hypergraphs/Lisp/Generators/Hindman.mac")$
00024 
00025 
00026 /* *****************
00027    * Hindman quads *
00028    *****************
00029 */
00030 
00031 okltest_hindman_a1k2_ohg(f) := (
00032   assert(f(0) = [[],[]]),
00033   assert(f(1) = [[1],[]]),
00034   assert(f(2) = [[1,2],[{1,2}]]),
00035   assert(f(3) = [[1,2,3],[{1,2},{1,2,3}]]),
00036   assert(f(4) = [[1,2,3,4],[{1,2},{1,2,3},{1,3,4},{2,4}]]),
00037   assert(f(5) = [[1,2,3,4,5],[{1,2},{1,2,3},{1,3,4},{1,4,5},{2,4}]]),
00038   assert(f(6) = [[1,2,3,4,5,6],[{1,2},{1,2,3},{1,3,4},{1,4,5},{1,5,6},{2,4},{2,3,5,6}]]),
00039   /* XXX */
00040   true)$
00041 
00042 okltest_nver_hindman_a1k2_ohg(f) := (
00043   for n : 0 thru 10 do
00044     assert(f(n) = length(hindman_a1k2_ohg(n)[1])),
00045   true)$
00046 
00047 okltest_nhyp_hindman_a1k2_ohg(f) := (
00048   for n : 0 thru 10 do
00049     assert(f(n) = length(hindman_a1k2_ohg(n)[2])),
00050   true)$
00051 
00052 
00053 okltest_hindmani_a1k2_ohg(f) := (
00054   assert(f(0) = [[],[]]),
00055   assert(f(1) = [[1],[]]),
00056   assert(f(2) = [[1,2],[]]),
00057   assert(f(3) = [[1,2,3],[{1,2,3}]]),
00058   assert(f(4) = [[1,2,3,4],[{1,2,3},{1,3,4}]]),
00059   assert(f(5) = [[1,2,3,4,5],[{1,2,3},{1,3,4},{1,4,5}]]),
00060   assert(f(6) = [[1,2,3,4,5,6],[{1,2,3},{1,3,4},{1,4,5},{1,5,6},{2,3,5,6}]]),
00061   /* XXX */
00062   true)$
00063 
00064 okltest_nver_hindmani_a1k2_ohg(f) := (
00065   for n : 0 thru 10 do
00066     assert(f(n) = length(hindman_a1k2_ohg(n)[1])),
00067   true)$
00068 
00069 okltest_nhyp_hindmani_a1k2_ohg(f) := (
00070   for n : 0 thru 10 do 
00071     assert(f(n) = length(hindmani_a1k2_ohg(n)[2])),
00072   true)$
00073 
00074 
00075 okltest_hindman_k2_ohg(f) := (
00076   assert(okltest_hindman_a1k2_ohg(buildq([f],lambda([n],f(1,n)))) = true),
00077   assert(f(2,3) = [[2,3],[]]),
00078   assert(f(2,4) = [[2,3,4],[{2,4}]]),
00079   assert(f(3,4) = [[3,4],[]]),
00080   assert(f(2,5) = [[2,3,4,5],[{2,4}]]),
00081   assert(f(2,6) = [[2,3,4,5,6],[{2,4},{2,3,5,6}]]),
00082   assert(f(3,6) = [[3,4,5,6],[]]),
00083   /* XXX */
00084   true)$
00085 
00086 okltest_nver_hindman_k2_ohg(f) := (
00087   for n : 0 thru 8 do
00088     for a : 1 thru 7 do
00089       assert(f(a,n) = length(hindman_k2_ohg(a,n)[1])),
00090   true)$
00091 
00092 okltest_nhyp_hindman_k2_ohg(f) := (
00093   for n : 0 thru 8 do
00094     for a : 1 thru 7 do
00095       assert(f(a,n) = length(hindman_k2_ohg(a,n)[2])),
00096   true)$
00097 
00098 okltest_hindmani_k2_ohg(f) := (
00099   assert(okltest_hindmani_a1k2_ohg(buildq([f],lambda([n],f(1,n)))) = true),
00100   assert(f(2,3) = [[2,3],[]]),
00101   assert(f(2,4) = [[2,3,4],[]]),
00102   assert(f(3,4) = [[3,4],[]]),
00103   assert(f(2,5) = [[2,3,4,5],[]]),
00104   assert(f(2,6) = [[2,3,4,5,6],[{2,3,5,6}]]),
00105   assert(f(3,6) = [[3,4,5,6],[]]),
00106   true)$
00107 
00108 okltest_nver_hindmani_k2_ohg(f) := (
00109   for n : 0 thru 8 do
00110     for a : 1 thru 7 do
00111       assert(f(a,n) = length(hindmani_k2_ohg(a,n)[1])),
00112   true)$
00113 
00114 okltest_nhyp_hindmani_k2_ohg(f) := (
00115   for n : 0 thru 8 do
00116     for a : 1 thru 7 do
00117       assert(f(a,n) = length(hindmani_k2_ohg(a,n)[2])),
00118   true)$
00119 
00120 
00121 /* ********************
00122    * The general case *
00123    ********************
00124 */
00125 
00126 okltest_hindman_ohg(f) := (
00127   assert(f(1,0,0) = [[],[{}]]),
00128   assert(f(1,0,1) = [[1],[{}]]),
00129   assert(f(1,1,0) = [[],[]]),
00130   assert(f(1,1,1) = [[1],[{1}]]),
00131   assert(f(2,1,1) = [[],[]]),
00132   assert(f(2,1,2) = [[2],[{2}]]),
00133   assert(f(1,2,0) = [[],[]]),
00134   assert(f(1,2,1) = [[1],[]]),
00135   assert(f(1,2,2) = [[1,2],[{1,2}]]),
00136   assert(f(1,3,0) = [[],[]]),
00137   assert(f(1,3,1) = [[1],[]]),
00138   assert(f(1,3,2) = [[1,2],[]]),
00139   assert(f(1,3,3) = [[1,2,3],[{1,2,3}]]),
00140   assert(f(1,3,4) = [[1,2,3,4],[{1,2,3},{1,2,3,4}]]),
00141   assert(f(1,3,5) = [[1,2,3,4,5],[{1,2,3},{1,2,3,4},{1,2,3,4,5}]]),
00142   assert(f(2,3,0) = [[],[]]),
00143   assert(f(2,3,1) = [[],[]]),
00144   assert(f(2,3,2) = [[2],[]]),
00145   assert(f(2,3,3) = [[2,3],[]]),
00146   assert(f(2,3,4) = [[2,3,4],[]]),
00147   assert(f(2,3,5) = [[2,3,4,5],[]]),
00148   assert(f(2,3,6) = [[2,3,4,5,6],[]]),
00149   assert(f(2,3,7) = [[2,3,4,5,6,7],[]]),
00150   assert(f(2,3,8) = [[2,3,4,5,6,7,8],[{2,4,6,8}]]),
00151   assert(okltest_hindman_k2_ohg(buildq([f], lambda([a,n], f(a,2,n)))) = true),
00152   true)$
00153 
00154 okltest_hindmani_ohg(f) := block(
00155   assert(f(1,0,0) = [[],[{}]]),
00156   assert(f(1,0,1) = [[1],[{}]]),
00157   assert(f(1,1,0) = [[],[]]),
00158   assert(f(1,1,1) = [[1],[{1}]]),
00159   assert(f(2,1,1) = [[],[]]),
00160   assert(f(2,1,2) = [[2],[{2}]]),
00161   assert(f(1,2,0) = [[],[]]),
00162   assert(f(1,2,1) = [[1],[]]),
00163   assert(f(1,2,2) = [[1,2],[]]),
00164   assert(f(1,3,0) = [[],[]]),
00165   assert(f(1,3,1) = [[1],[]]),
00166   assert(f(1,3,2) = [[1,2],[]]),
00167   assert(f(1,3,3) = [[1,2,3],[]]),
00168   assert(f(1,3,4) = [[1,2,3,4],[]]),
00169   assert(f(1,3,5) = [[1,2,3,4,5],[]]),
00170   assert(f(1,3,6) = [[1,2,3,4,5,6],[{1,2,3,4,5,6}]]),
00171   assert(f(2,3,0) = [[],[]]),
00172   assert(f(2,3,1) = [[],[]]),
00173   assert(f(2,3,2) = [[2],[]]),
00174   assert(f(2,3,3) = [[2,3],[]]),
00175   assert(f(2,3,4) = [[2,3,4],[]]),
00176   assert(f(2,3,5) = [[2,3,4,5],[]]),
00177   assert(f(2,3,6) = [[2,3,4,5,6],[]]),
00178   assert(f(2,3,7) = [[2,3,4,5,6,7],[]]),
00179   assert(f(2,3,8) = [[2,3,4,5,6,7,8],[]]),
00180   assert(okltest_hindmani_k2_ohg(buildq([f], lambda([a,n], f(a,2,n)))) = true),
00181   if oklib_test_level=0 then return(true),
00182   assert(f(2,3,24) = [create_list(i,i,2,24),[{2,3,4,5,6,7,9,8,12,24}]]),
00183   true)$
00184 
00185