OKlibrary  0.2.1.6
RandomBooleanFunctions.mac
Go to the documentation of this file.
00001 /* Oliver Kullmann, 29.1.2011 (Swansea) */
00002 /* Copyright 2011 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/DataStructures/Lisp/Lists.mac")$
00024 
00025 
00026 kill(f)$
00027 
00028 
00029 okltest_random_subset(f) := block(
00030   assert(f({}) = {}),
00031   set_random(1),
00032   assert(f({1}) = {1}),
00033   assert(f({1}) = {1}),
00034   assert(f({1}) = {}),
00035   assert(f({1,2,3}) = {2,3}),
00036   if oklib_test_level = 0 then return(true),
00037   for i : 0 thru 500 do
00038     assert(subsetp(f({1,2,3,4,5,6,7,8}),{1,2,3,4,5,6,7,8})),
00039   true)$
00040 
00041 okltest_random_bf_fcs(f) := block(
00042   set_random(1),
00043   assert(f(0) = [{},{{}}]),
00044   assert(f(1) = [{1},{{-1}}]),
00045   assert(f(2) = [{1,2},{{-2,1},{-1,2},{1,2}}]),
00046   assert(f(3) = [{1,2,3},{{-3,-2,-1},{-3,-2,1},{-2,-1,3},{-1,2,3},{1,2,3}}]),
00047   true)$
00048 
00049 okltest_random_bal_bf_fcs(f) := block(
00050   set_random(1),
00051   assert(f(1) = [{1},{{1}}]),
00052   assert(f(2) = [{1,2},{{-2,-1},{1,2}}]),
00053   assert(f(3) = [{1,2,3},{{-3,-2,-1},{-3,-1,2},{-3,1,2},{-2,-1,3}}]),
00054   if oklib_test_level = 0 then return(true),
00055   for i : 0 thru 500 do
00056     assert(length(f(3)[2]) = 4),
00057   for i : 0 thru 500 do
00058     assert(length(f(5)[2]) = 16),
00059   true)$
00060