OKlibrary  0.2.1.6
Idempotency.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 oklib_include("OKlib/ComputerAlgebra/Algebra/Lisp/Groupoids/Semigroups/BasicExamples.mac")$
00024 oklib_include("OKlib/ComputerAlgebra/Algebra/Lisp/Groupoids/tests/BasicNotions.mac")$
00025 
00026 kill(f)$
00027 
00028 
00029 okltest_idempotent_el_grd(f) := (
00030   assert(f(singleton_sgr,1) = true),
00031   for x in {1,2,3} do block([V : leftnull_sgr({1,2,3})],
00032     assert(f(V,x) = true)),
00033   for x in {1,2,3} do block([V : rightnull_sgr({1,2,3})],
00034     assert(f(V,x) = true)),
00035   true)$
00036 
00037 okltest_has_idempotent_el_grd(f) := (
00038   assert(f(empty_sgr) = false),
00039   assert(f(singleton_sgr) = true),
00040   assert(f(leftnull_sgr({1,2,3})) = true),
00041   assert(f(rightnull_sgr({1,2,3})) = true),
00042   assert(f(null_sgr({1,2,3},1)) = true),
00043   assert(f(scom2grd(m2scom(matrix([2,1],[2,1])))) = false),
00044   true)$
00045 
00046 okltest_idempotent_bydef_grd(f) := (
00047   assert(f(empty_sgr) = true),
00048   assert(f(singleton_sgr) = true),
00049   assert(f(leftnull_sgr({1,2,3})) = true),
00050   assert(f(rightnull_sgr({1,2,3})) = true),
00051   assert(f(null_sgr({1,2,3},1)) = false),
00052   assert(f(scom2grd(m2scom(matrix([2,1],[2,1])))) = false),
00053   true)$
00054 
00055 okltest_idempotents_grd(f) := (
00056   okltest_idempotent_el_grd(buildq([f], lambda([V,x], elementp(x,f(V))))),
00057   okltest_has_idempotent_el_grd(buildq([f], lambda([V], not emptyp(f(V))))),
00058   okltest_idempotent_bydef_grd(buildq([f], lambda([V], is(f(V) = V[1])))),
00059   assert(f(null_sgr({1,2,3},2)) = {2}),
00060   true)$
00061