OKlibrary  0.2.1.6
Ramsey.mac
Go to the documentation of this file.
00001 /* Oliver Kullmann, 5.8.2012 (Swansea) */
00002 /* Copyright 2012 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/Basics.mac")$
00024 oklib_include("OKlib/ComputerAlgebra/Hypergraphs/Lisp/Generators/Ramsey.mac")$
00025 
00026 kill(f)$
00027 
00028 
00029 /* ********************
00030    * Ramsey's theorem *
00031    ********************
00032 */
00033 
00034 okltest_ramsey_hg(f) := (
00035   for q : 0 thru 3 do
00036     for r : 0 thru 3 do
00037       for n : 0 thru 3 do block([G : f(q,r,n)],
00038         assert(length(G[1]) = binomial(n,r)),
00039         assert(length(G[2]) = if q>n then 0 else
00040           if r<=q then (if r=0 then 1 else binomial(n,q)) else 0)),
00041   true)$
00042 
00043 okltest_ramsey_ohg(f) := (
00044   assert(f(0,0,0) = [[{}],[{{}}]]),
00045   assert(f(0,0,1) = [[{}],[{{}}]]),
00046   assert(f(0,1,0) = [[],[]]),
00047   assert(f(1,0,0) = [[{}],[]]),
00048   assert(f(0,0,2) = [[{}], [{{}}]]),
00049   assert(f(0,2,0) = [[], []]),
00050   assert(f(2,0,0) = [[{}], []]).
00051   /* XXX */
00052   for q : 0 thru 3 do
00053     for r : 0 thru 3 do
00054       for n : 0 thru 3 do
00055         assert(ohg_p(f(q,r,n))),
00056   assert(okltest_ramsey_hg(buildq([f],lambda([q,r,n],ohg2hg(f(q,r,n)))))),
00057   true)$
00058 
00059 okltest_rv_var(f) := block([x,y,z],
00060   assert(f() = rv()),
00061   assert(f(x) = rv(x)),
00062   assert(f(x,y) = rv(x,y)),
00063   assert(f(x,y,z) = rv(x,y,z)),
00064   true)$
00065 
00066 okltest_set_rv(f) := (
00067   assert(f({}) = rv()),
00068   assert(f({1}) = rv(1)),
00069   assert(f({1,3,5}) = rv(1,3,5)),
00070   true)$
00071 
00072 okltest_ramseyrv_ohg(f) := block(
00073   /* XXX */
00074   if oklib_test_level = 0 then return(true),
00075   assert(okltest_ramsey_ohg(buildq([f], lambda([q,r,n], ev(f(q,r,n), rv([L]):=setify(L), rv)))) = true),
00076   true)$
00077 
00078 okltest_ramsey_stdohg(f) := (
00079   assert(f(4,3,5) = [[1,2,5,3,6,8,4,7,9,10],[{1,2,3,4},{1,5,6,7},{2,5,8,9},{3,6,8,10},{4,7,9,10}]]),
00080   /* XXX */
00081   true)$
00082 
00083 okltest_nver_ramsey_ohg(f) := (
00084   for q : 0 thru 4 do
00085     for r : 0 thru 5 do
00086       for n : 0 thru 5 do
00087         assert(f(q,r,n) = length(ramsey_ohg(q,r,n)[1])),
00088   true)$
00089 
00090 okltest_nver_ramsey_hg(f) := (
00091   for q : 0 thru 4 do
00092     for r : 0 thru 5 do
00093       for n : 0 thru 5 do
00094         assert(f(q,r,n) = length(ramsey_hg(q,r,n)[1])),
00095   true)$
00096 
00097 okltest_nhyp_ramsey_ohg(f) := (
00098   for q : 0 thru if oklib_test_level=0 then 4 else 6 do
00099     for r : 0 thru if oklib_test_level=0 then 6 else 10 do
00100       for n : 0 thru if oklib_test_level=0 then 6 else 15 do
00101         assert(f(q,r,n) = length(ramsey_ohg(q,r,n)[2])),
00102   true)$
00103 
00104 okltest_nhyp_ramsey_hg(f) := (
00105   for q : 0 thru if oklib_test_level=0 then 4 else 6 do
00106     for r : 0 thru if oklib_test_level=0 then 6 else 10 do
00107       for n : 0 thru if oklib_test_level=0 then 6 else 15 do 
00108         assert(f(q,r,n) = length(ramsey_hg(q,r,n)[2])),
00109   true)$
00110 
00111