OKlibrary  0.2.1.6
Generators.mac
Go to the documentation of this file.
00001 /* Oliver Kullmann, 26.6.2008 (Swansea) */
00002 /* Copyright 2008, 2009, 2010, 2011, 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/Graphs/Lisp/tests/Generators.mac")$
00025 oklib_include("OKlib/ComputerAlgebra/Hypergraphs/Lisp/SetSystems.mac")$
00026 oklib_include("OKlib/ComputerAlgebra/Hypergraphs/Lisp/Generators/Generators.mac")$
00027 
00028 kill(f)$
00029 
00030 
00031 /* ************************
00032    * Complete hypergraphs *
00033    ************************
00034 */
00035 
00036 okltest_complete_hg(f) := (
00037   assert(f({},0) = [{},{{}}]),
00038   assert(f({},1) = [{},{}]),
00039   assert(f({-1},0) = [{-1},{{}}]),
00040   assert(f({-1},1) = [{-1},{{-1}}]),
00041   assert(f({-1},2) = [{-1},{}]),
00042   true)$
00043 
00044 okltest_complete_stdhg(f) := (
00045   assert(f(0,0) = [{},{{}}]),
00046   assert(f(0,1) = [{},{}]),
00047   assert(f(1,0) = [{1},{{}}]),
00048   assert(f(1,1) = [{1},{{1}}]),
00049   assert(f(2,0) = [{1,2},{{}}]),
00050   assert(f(2,1) = [{1,2},{{1},{2}}]),
00051   assert(f(2,2) = [{1,2},{{1,2}}]),
00052   assert(okltest_complete_stdg(buildq([f],lambda([n],f(n,2))))),
00053   true)$
00054 
00055 okltest_complete_ohg(f) := (
00056   assert(f([],0) = [[],[{}]]),
00057   assert(f([2,1,-3],2) = [[2,1,-3],[{2,1},{2,-3},{1,-3}]]),
00058   assert(f([2,1,-3,-2],2) = [[2,1,-3,-2],[{2,1},{2,-3},{1,-3},{2,-2},{1,-2},{-3,-2}]]),
00059   assert(okltest_complete_hg(buildq([f], lambda([V,r], ohg2hg(f(listify(V),r))))) = true),
00060   true)$
00061 
00062 okltest_complete_stdohg(f) := (
00063   assert(f(0,0) = [[],[{}]]),
00064   assert(f(4,2) = [[1,2,3,4],[{1,2},{1,3},{2,3},{1,4},{2,4},{3,4}]]),
00065   assert(okltest_complete_stdhg(buildq([f], lambda([n,r], ohg2hg(f(n,r))))) = true),
00066   true)$
00067 
00068 okltest_nver_complete_hg(f) := (
00069   for n : 0 thru 4 do
00070     for r : 0 thru 4 do block([nver : f(n,r)],
00071       assert(nver = length(complete_stdhg(n,r)[1])),
00072       assert(nver = length(complete_stdohg(n,r)[1]))
00073   ),
00074   true)$
00075 
00076 okltest_nhyp_complete_hg(f) := (
00077   for n : 0 thru 4 do
00078     for r : 0 thru 4 do block([nhyp : f(n,r)],
00079       assert(nhyp = length(complete_stdhg(n,r)[2])),
00080       assert(nhyp = length(complete_stdohg(n,r)[2]))
00081   ),
00082   true)$
00083 
00084 okltest_nver_colouring_hg(f) := (
00085   for n : 0 thru 4 do block([nver : f(n)],
00086     assert(nver = length(colouring_stdhg(n)[1]))
00087   ),
00088   true)$
00089 
00090 okltest_nhyp_colouring_hg(f) := (
00091   for n : 0 thru 4 do block([nhyp : f(n)],
00092     assert(nhyp = length(colouring_stdhg(n)[2]))
00093   ),
00094   true)$
00095 
00096 
00097 /* ***************************
00098    * Generalised Tic-tac-toe *
00099    ***************************
00100 */
00101 
00102 okltest_gttt_tlbr(f) := (
00103   assert(f(1,1) = [[[1,1],[1,1]]]),
00104   for n : 1 thru 5 do
00105     assert(f(1,n) = create_list([[1,i],[1,i]],i,1,n)),
00106   for m : 1 thru 5 do
00107     assert(f(m,1) = create_list([[m-i,1],[m-i,1]],i,0,m-1)),
00108   assert(f(2,2) = [[[2,1],[2,1]],[[1,1],[2,2]],[[1,2],[1,2]]]),
00109   assert(f(2,3) = [[[2,1],[2,1]],[[1,1],[2,2]],[[1,2],[2,3]],[[1,3],[1,3]]]),
00110   assert(f(3,2) = [[[3,1],[3,1]],[[2,1],[3,2]],[[1,1],[2,2]],[[1,2],[1,2]]]),
00111   assert(f(3,3) = [[[3,1],[3,1]],[[2,1],[3,2]],[[1,1],[3,3]],[[1,2],[2,3]],[[1,3],[1,3]]]),
00112   assert(f(4,6) = [[[4,1],[4,1]],[[3,1],[4,2]],[[2,1],[4,3]],[[1,1],[4,4]],[[1,2],[4,5]],[[1,3],[4,6]],[[1,4],[3,6]],[[1,5],[2,6]],[[1,6],[1,6]]]),
00113   true)$
00114 
00115 okltest_gttt_bltr(f) := (
00116   assert(f(1,1) = [[[1,1],[1,1]]]),
00117   for n : 1 thru 5 do
00118     assert(f(1,n) = create_list([[1,i],[1,i]],i,1,n)),
00119   for m : 1 thru 5 do
00120     assert(f(m,1) = create_list([[i,1],[i,1]],i,1,m)),
00121   assert(f(2,2) = [[[1,1],[1,1]],[[2,1],[1,2]],[[2,2],[2,2]]]),
00122   assert(f(2,3) = [[[1,1],[1,1]],[[2,1],[1,2]],[[2,2],[1,3]],[[2,3],[2,3]]]),
00123   assert(f(3,2) = [[[1,1],[1,1]],[[2,1],[1,2]],[[3,1],[2,2]],[[3,2],[3,2]]]),
00124   assert(f(3,3) = [[[1,1],[1,1]],[[2,1],[1,2]],[[3,1],[1,3]],[[3,2],[2,3]],[[3,3],[3,3]]]),
00125   assert(f(4,6) = [[[1,1],[1,1]],[[2,1],[1,2]],[[3,1],[1,3]],[[4,1],[1,4]],[[4,2],[1,5]],[[4,3],[1,6]],[[4,4],[2,6]],[[4,5],[3,6]],[[4,6],[4,6]]]),
00126   true)$
00127 
00128 okltest_gttt_lines(f) := (
00129   assert(f(1,1) = [[[1,1],[1,1]]]),
00130   assert(f(1,2) = [ [[1,1],[1,2]], [[1,1],[1,1]],[[1,2],[1,2]] ]),
00131   assert(f(2,1) = [ [[1,1],[1,1]],[[2,1],[2,1]], [[1,1],[2,1]] ]),
00132   assert(f(2,2) = [ [[1,1],[1,2]],[[2,1],[2,2]], [[1,1],[2,1]],[[1,2],[2,2]], [[2,1],[2,1]],[[1,1],[2,2]],[[1,2],[1,2]], [[1,1],[1,1]],[[2,1],[1,2]],[[2,2],[2,2]] ]),
00133   true)$
00134 
00135 okltest_gttt_length(f) := block([x,y],
00136   assert(f([x,y],[x,y]) = 1),
00137   assert(f([1,1],[3,3]) = 3),
00138   assert(f([3,3],[1,1]) = 3),
00139   assert(f([1,1],[1,4]) = 4),
00140   assert(f([4,7],[9,7]) = 6),
00141   true)$
00142 
00143 okltest_gttt_slope(f) := block([x,y],
00144   assert(f([x,y],[x,y]) = [0,0]),
00145   assert(f([1,1],[1,2]) = [0,1]),
00146   assert(f([1,1],[2,1]) = [1,0]),
00147   assert(f([1,1],[2,2]) = [1,1]),
00148   assert(f([2,1],[1,2]) = [-1,1]),
00149   assert(f([1,1],[1,3]) = [0,1]),
00150   assert(f([1,1],[4,1]) = [1,0]),
00151   assert(f([1,1],[3,3]) = [1,1]),
00152   assert(f([3,1],[1,3]) = [-1,1]),
00153   true)$
00154 
00155 okltest_gttt_startpoints(f) := block([x,y],
00156   assert(f([x,y],[x,y],1) = [[[x,y],[0,0]]]),
00157   assert(f([1,1],[3,1],1) = [[[1,1],[1,0]],[[2,1],[1,0]],[[3,1],[1,0]]]),
00158   assert(f([1,1],[3,1],2) = [[[1,1],[1,0]],[[2,1],[1,0]]]),
00159   assert(f([1,1],[3,1],3) = [[[1,1],[1,0]]]),
00160   assert(f([1,1],[3,1],4) = []),
00161   assert(f([1,1],[3,3],1) = [[[1,1],[1,1]],[[2,2],[1,1]],[[3,3],[1,1]]]),
00162   assert(f([1,1],[3,3],2) = [[[1,1],[1,1]],[[2,2],[1,1]]]),
00163   assert(f([1,1],[3,3],3) = [[[1,1],[1,1]]]),
00164   assert(f([1,1],[3,3],4) = []),
00165   true)$
00166 
00167 okltest_gttt_lines_k(f) := (
00168   assert(f(1,1,1) = [[[1,1],[0,0]]]),
00169   assert(f(1,2,2) = [[[1,1],[0,0]],[[1,2],[0,0]],[[2,1],[0,0]],[[2,2],[0,0]]]),
00170   assert(f(2,1,1) = []),
00171   assert(f(2,1,2) = [[[1,1],[0,1]]]),
00172   assert(f(2,2,1) = [[[1,1],[1,0]]]),
00173   assert(f(2,2,2) = [ [[1,1],[0,1]],[[2,1],[0,1]],[[1,1],[1,0]],[[1,2],[1,0]],[[1,1],[1,1]],[[2,1],[-1,1]] ]),
00174   assert(f(3,2,2) = []),
00175   assert(f(3,2,3) = [[[1,1],[0,1]],[[2,1],[0,1]]]),
00176   assert(f(3,3,2) = [[[1,1],[1,0]],[[1,2],[1,0]]]),
00177   assert(f(3,3,3) = [ [[1,1],[0,1]],[[2,1],[0,1]],[[3,1],[0,1]], [[1,1],[1,0]],[[1,2],[1,0]],[[1,3],[1,0]], [[1,1],[1,1]], [[3,1],[-1,1]] ]),
00178   true)$
00179 
00180 okltest_gttt_ohg(f) := (
00181   assert(f(1,1,1) = [[[1,1]], [{[1,1]}]]),
00182   assert(f(2,1,1) = [[[1,1]], []]),
00183   assert(f(2,2,2) = [[[1,1],[1,2],[2,1],[2,2]], [{[1,1],[1,2]},{[2,1],[2,2]},{[1,1],[2,1]},{[1,2],[2,2]},{[1,1],[2,2]},{[2,1],[1,2]}]]),
00184   true)$
00185