OKlibrary  0.2.1.6
Constructions.mac
Go to the documentation of this file.
00001 /* Oliver Kullmann, 6.7.2008 (Swansea) */
00002 /* Copyright 2008, 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/CombinatorialMatrices/Lisp/Basics.mac")$
00023 
00024 /* ***********************
00025    * Complex composition *
00026    ***********************
00027 */
00028 
00029 /* For a given composition, derive the "complex composition", which
00030    for subsets X, Y computes the composition of all combinations: */
00031 complex_compo(compo_) := buildq([compo_], lambda([X,Y],
00032  block([result : {}],
00033   if length(X) <= length(Y) then
00034    for x in X do result : union(result, map(lambda([y],apply(compo_,[x,y])),Y))
00035    else for y in Y do result : union(result, map(lambda([x],apply(compo_,[x,y])),X)),
00036   result)))$
00037 /* Remark: A simpler implementation is
00038 complex_compo(compo) := buildq([compo], lambda([X,Y],
00039   map(lambda([P],apply(compo,P)),cartesian_product(X,Y))))$
00040 however this has a large memory consumption, and is also slower.
00041 */
00042 
00043 complex_grd(V) := [powerset(V[1]), complex_compo(V[2])]$
00044 
00045 
00046 /* *********************
00047    * Product groupoids *
00048    *********************
00049 */
00050 
00051 /* For two compositions, derive the "product composition": */
00052 product_compo(compo1,compo2) := buildq([compo1,compo2], lambda([x,y],
00053   [compo1(x[1],y[1]), compo2(x[2],y[2])]))$
00054 
00055 product_grd(V1,V2) := [cartesian_product(V1[1],V2[1]), 
00056   product_compo(V1[2],V2[2])]$
00057 
00058 
00059 /* *****************
00060    * Transposition *
00061    *****************
00062 */
00063 
00064 /* Transpose a composition: */
00065 transposed_compo(compo) := buildq([compo], lambda([x,y],
00066   compo(y,x)))$
00067 
00068 transposed_grd(V) := [V[1], transposed_compo(V[2])]$
00069 transposed_ugrd(V) := [V[1], transposed_compo(V[2]), V[3]]$
00070 
00071