OKlibrary  0.2.1.6
Basics.mac
Go to the documentation of this file.
00001 /* Oliver Kullmann, 3.2.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 oklib_include("OKlib/ComputerAlgebra/Hypergraphs/Lisp/SetSystems.mac")$
00024 
00025 kill(f)$
00026 
00027 
00028 okltest_transversal_p(f) := (
00029   assert(f({},{}) = true),
00030   assert(f({},{{}}) = false),
00031   assert(f({},{{1}}) = false),
00032   assert(f({1,2},{{1,3},{2,4},{1,2,3,4}}) = true),
00033   assert(f({1,2,9},{{1,3},{2,4},{1,2,3,4}}) = true),
00034   true)$
00035 
00036 okltest_etransversal_p(f) := (
00037   assert(f({},{}) = true),
00038   assert(f({},{{}}) = false),
00039   assert(f({},{{1}}) = false),
00040   assert(f({1,2},{{1,3},{2,4},{1,2,3,4}}) = false),
00041   assert(f({1,2},{{1,3},{2,4},{2,3,4}}) = true),
00042   assert(f({1,2,9},{{1,3},{2,4},{1,2,3,4}}) = false),
00043   assert(f({1,2,9},{{1,3},{2,4},{1,3,4}}) = true),
00044   assert(f({{2},{2,1},{2,3},{2,4}}, {{{1},{2},{3,4}},{{1},{2,3},{4}},{{1},{3},{2,4}},{{1,2},{3},{4}},{{1,3},{2},{4}},{{1,4},{2},{3}}}) = true),
00045   true)$
00046 
00047 
00048 /* ************************
00049    * Greedy approximation *
00050    ************************
00051 */
00052 
00053 okltest_greedy_transversal_ohg(f) := (
00054   assert(f([{},{}]) = {}),
00055   assert(f([{},{{}}]) = false),
00056   /* XXX */
00057   true)$
00058 
00059 okltest_greedy_transversal_(f) := (
00060   assert(f([]) = {}),
00061   for n : 0 thru 5 do block([N : setn(n)],
00062     assert(f(listify(singletons(N))) = N)),
00063   assert(f([{1,2},{1,3},{2,4},{1,5},{2,3}]) = {1,2}),
00064   /* XXX */
00065   true)$
00066 
00067