OKlibrary  0.2.1.6
Enumeration.mac
Go to the documentation of this file.
00001 /* Oliver Kullmann, 14.1.2009 (Swansea) */
00002 /* Copyright 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 
00024 kill(f)$
00025 
00026 
00027 /* *********************
00028    * Basic enumeration *
00029    *********************
00030 */
00031 
00032 okltest_all_grd2m(f) := block(
00033   assert(f(0) = [matrix()]),
00034   assert(f(1) = [matrix([1])]),
00035   assert(f(2) = [
00036  matrix([1,1],[1,1]),matrix([1,1],[1,2]),matrix([1,1],[2,1]),
00037  matrix([1,1],[2,2]),matrix([1,2],[1,1]),matrix([1,2],[1,2]),
00038  matrix([1,2],[2,1]),matrix([1,2],[2,2]),matrix([2,1],[1,1]),
00039  matrix([2,1],[1,2]),matrix([2,1],[2,1]),matrix([2,1],[2,2]),
00040  matrix([2,2],[1,1]),matrix([2,2],[1,2]),matrix([2,2],[2,1]),
00041  matrix([2,2],[2,2])]),
00042   if oklib_test_level = 0 then return(true),
00043   assert(length(f(3)) = 19683),
00044   true)$
00045 
00046 okltest_all_grd(f) := block(
00047   okltest_all_grd2m(buildq([f], lambda([n], map(lmscom2m,f(n))))),
00048   true)$
00049 
00050 
00051 /* ************
00052    * Counting *
00053    ************
00054 */
00055 
00056 okltest_counting_groupoids(F) := block(
00057  [N : if oklib_test_level = 0 then 2 else 3],
00058   for n : 0 thru N do block([L : all_grd(n)],
00059     for P in F do (
00060       assert(P[1](n) = length(sublist(L,
00061         lambda([G], every_s(lambda([p],p(G)), P[2])))))
00062   )),
00063   true)$
00064 
00065 
00066 /* ***********************************
00067    * Enumerating isomorphism classes *
00068    ***********************************
00069 */
00070 
00071 /* Generic test function whether f(n) computes all isomorphism classes of
00072    groupoids (represented as matrices) of order n:
00073 */
00074 okltest_all_isomorphism_classes_grd(f) := (
00075   assert(f(0) = {{matrix()}}),
00076   assert(f(1) = {{matrix([1])}}),
00077   assert(f(2) = {
00078  {matrix([1,1],[1,1]),matrix([2,2],[2,2])},
00079  {matrix([1,1],[1,2]),matrix([1,2],[2,2])},
00080  {matrix([1,1],[2,1]),matrix([2,1],[2,2])},
00081  {matrix([1,1],[2,2])},
00082  {matrix([1,2],[1,1]),matrix([2,2],[1,2])},
00083  {matrix([1,2],[1,2])},
00084  {matrix([1,2],[2,1]),matrix([2,1],[1,2])},
00085  {matrix([2,1],[1,1]),matrix([2,2],[2,1])},
00086  {matrix([2,1],[2,1])},
00087  {matrix([2,2],[1,1])}}),
00088   true)$
00089 
00090 okltest_all_isomorphism_classes_actively_sm_grd(f) := (
00091   /* XXX */
00092   true)$
00093 
00094 
00095 /* *********************************
00096    * Enumerating isotopism classes *
00097    *********************************
00098 */
00099 
00100 /* Generic test function whether f(n) computes all isotopism classes of
00101    groupoids (represented as matrices) of order n:
00102 */
00103 okltest_all_isotopism_classes_grd(f) := (
00104   assert(f(0) = {{matrix()}}),
00105   assert(f(1) = {{matrix([1])}}),
00106   assert(f(2) = {
00107  {matrix([1,1],[1,1]),matrix([2,2],[2,2])},
00108  {matrix([1,1],[1,2]),matrix([1,1],[2,1]),matrix([1,2],[1,1]),
00109     matrix([1,2],[2,2]),matrix([2,1],[1,1]),matrix([2,1],[2,2]),
00110     matrix([2,2],[1,2]),matrix([2,2],[2,1])},
00111  {matrix([1,1],[2,2]),matrix([2,2],[1,1])},
00112  {matrix([1,2],[1,2]),matrix([2,1],[2,1])},
00113  {matrix([1,2],[2,1]),matrix([2,1],[1,2])}}),
00114   true)$
00115 
00116 okltest_all_isotopismisomorphism_classes_grd(f) := (
00117   assert(f(0) = {{{matrix()}}}),
00118   assert(f(1) = {{{matrix([1])}}}),
00119   assert(f(2) = {
00120  { {matrix([1,1],[1,1]),matrix([2,2],[2,2])} },
00121  { {matrix([1,1],[1,2]),matrix([1,2],[2,2])},
00122    {matrix([1,1],[2,1]),matrix([2,1],[2,2])},
00123    {matrix([1,2],[1,1]),matrix([2,2],[1,2])},
00124    {matrix([2,1],[1,1]),matrix([2,2],[2,1])}},
00125  { {matrix([1,1],[2,2])},
00126    {matrix([2,2],[1,1])} },
00127  { {matrix([1,2],[1,2])},
00128    {matrix([2,1],[2,1])} },
00129  { {matrix([1,2],[2,1]),matrix([2,1],[1,2])} }}),
00130   true)$
00131 
00132