OKlibrary  0.2.1.6
SurrealNumbers.mac
Go to the documentation of this file.
00001 /* Oliver Kullmann, 1.6.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 
00024 kill(f)$
00025 
00026 /* ******************************************
00027    * The basic notion of a "surreal number" *
00028    ******************************************
00029 */
00030 
00031 okltest_surnum_p(f) := (
00032   assert(f(0) = false),
00033   assert(f([{}]) = false),
00034   assert(f([{},{}]) = true),
00035   assert(f([{[{},{}]},{}]) = true),
00036   assert(f([{},{[{},{}]}]) = true),
00037   assert(f([{[{},{}]},{[{},{}]}]) = false),
00038   true)$
00039 
00040 okltest_surnum_lep(f) := (
00041   assert(f([{},{}], [{},{}]) = true),
00042   assert(f([{},{[{},{}]}], [{},{}]) = true),
00043   assert(f([{[{},{}]},{}], [{},{}]) = false),
00044   true)$
00045 
00046 okltest_surnum_ltp(f) := (
00047   assert(f([{},{}], [{},{}]) = false),
00048   assert(f([{},{[{},{}]}], [{},{}]) = true),
00049   assert(f([{[{},{}]},{}], [{},{}]) = false),
00050   true)$
00051 
00052 okltest_epoche_surnum(f) := (
00053   assert(f(0) = {[{},{}]}),
00054   assert(f(1) = {[{},{}], [{[{},{}]},{}], [{},{[{},{}]}]}),
00055   /* XXX */
00056   true)$
00057 
00058 okltest_surnum_equalp(f) := (
00059   assert(f([{},{}], [{},{}]) = true),
00060   assert(f([{},{[{},{}]}], [{},{}]) = false),
00061   assert(f([{[{},{}]},{}], [{},{}]) = false),
00062   assert(f([{},{}], [{[{},{[{},{}]}]},{[{[{},{}]},{}]}]) = true),
00063   /* XXX */
00064   true)$
00065 
00066 okltest_eqc_epoche_surnum(f) := (
00067   assert(f(0) = {{[{},{}]}}),
00068   assert(f(1) = {{[{},{}]}, {[{[{},{}]},{}]}, {[{},{[{},{}]}]}}),
00069   /* XXX */
00070   true)$
00071 
00072 
00073 /* ***************************
00074    * Arithmetical operations *
00075    ***************************
00076 */
00077 
00078 okltest_surnum_add(f) := (
00079   assert(f([{},{}],[{},{}]) = [{},{}]),
00080   assert(f([{},{}],[{[{},{}]},{}]) = [{[{},{}]},{}]),
00081   /* XXX */
00082   true)$
00083 
00084 okltest_surnum_neg1(f) := (
00085   assert(f([{},{}]) = [{},{}]),
00086   assert(f([{[{},{}]},{}]) = [{},{[{},{}]}]),
00087   assert(f([{},{[{},{}]}]) = [{[{},{}]},{}]),
00088   /* XXX */
00089   true)$
00090 
00091 okltest_surnum_neg2(f) := (
00092   assert(f([{},{}],[{},{}]) = [{},{}]),
00093   assert(f([{},{}],[{[{},{}]},{}]) = [{},{[{},{}]}]),
00094   assert(f([{},{[{},{}]}],[{},{[{},{}]}]) = [{[{},{[{},{}]}]},{[{[{},{}]},{}]}]),
00095   /* XXX */
00096   true)$
00097 
00098 okltest_surnum_prod(f) := (
00099   assert(f([{},{}],[{},{}]) = [{},{}]),
00100   assert(f([{[{},{}]},{}], ([{[{},{}]},{}])) = [{[{},{}]},{}]),
00101   assert(f([{[{},{}]},{}], ([{},{[{},{}]}])) = [{},{[{},{}]}]),
00102   /* XXX */
00103   true)$
00104 
00105 
00106 /* ***************
00107    * Conversions *
00108    ***************
00109 */
00110 
00111 okltest_nat2surnum(f) := (
00112   assert(f(0) = [{},{}]),
00113   assert(f(1) = [{[{},{}]},{}]),
00114   assert(f(2) = [{[{},{}],[{[{},{}]},{}]},{}]),
00115   true)$
00116 
00117 okltest_nnat2surnum(f) := (
00118   assert(f(0) = [{},{}]),
00119   assert(f(1) = [{},{[{},{}]}]),
00120   assert(f(2) = [{},{[{},{}],[{},{[{},{}]}]}]),
00121   true)$
00122 
00123 okltest_int2surnum(f) := (
00124   assert(f(0) = [{},{}]),
00125   assert(okltest_nat2surnum(f) = true),
00126   assert(okltest_nnat2surnum(buildq([f],lambda([n],f(-n)))) = true),
00127   true)$
00128 
00129