OKlibrary  0.2.1.6
Basics.mac
Go to the documentation of this file.
00001 /* Matthew Gwynne, 17.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    * Boolean vectors *
00030    *******************
00031 */
00032 
00033 okltest_lex_bv_l(f) := (
00034   assert(f(0) = [[]]),
00035   assert(f(1) = [[0],[1]]),
00036   assert(f(2) = [[0,0],[0,1],[1,0],[1,1]]),
00037   true)$
00038 
00039 okltest_unrank_lex_bv(f) := (
00040   for k : 0 thru 5 do
00041     assert(lex_bv_l(k) = create_list(f(i,k),i,1,2^k)),
00042   true)$
00043 
00044 okltest_rank_lex_bv(f) := (
00045   for k : 0 thru 5 do
00046     assert(map(f,lex_bv_l(k)) = create_list(i,i,1,2^k)),
00047   true)$
00048 
00049 okltest_bv2c(f) := (
00050   assert(f([]) = {}),
00051   assert(f([0]) = {-1}),
00052   assert(f([1]) = {1}),
00053   assert(f([1,0,1,0,0]) = {-5,-4,-2,1,3}),
00054   assert(f([0,0,0,0,0]) = {-5,-4,-3,-2,-1}),
00055   true)$
00056 
00057 okltest_bv2c_wv(f) := block([a,b,c],
00058   assert(f([],[]) = {}),
00059   assert(f([0,1,0],[a,b,c]) = {-a,b,-c}),
00060   assert(okltest_bv2c(buildq([f], lambda([v],f(v,create_list(i,i,1,length(v)))))) = true),
00061   true)$
00062 
00063 
00064 /* *****************
00065    * Constructions *
00066    *****************
00067 */
00068 
00069 okltest_bfnm2n1(f) := block(
00070   assert(f(zero_bf,1)([0]) = [0]),
00071   assert(f(zero_bf,1)([1]) = [0]),
00072   assert(f(zero_bf,1)([1,0,1,0,1]) = [0]),
00073   assert(f(one_bf,1)([0]) = [1]),
00074   assert(f(one_bf,1)([1]) = [1]),
00075   assert(f(one_bf,1)([1,0,1,0,1]) = [1]),
00076   assert(f(neg_bf,1)([1,0,1,0]) = [0]),
00077   assert(f(neg_bf,2)([1,0,1,0]) = [1]),
00078   assert(f(neg_bf,3)([1,0,1,0]) = [0]),
00079   assert(f(neg_bf,4)([1,0,1,0]) = [1]),
00080   true)$
00081 
00082