kenzo/examples/Chapter1.ipynb
2015-08-08 16:59:01 -05:00

29 KiB

Chapter 1

In [51]:
(ql:quickload "kenzo")
Out[51]:
("kenzo")
In [52]:
(cat:cat-init)
---done---
Out[52]:
NIL

1.2.2 Ordering the generators

In [53]:
(documentation 'cat:f-cmpr 'function)
Out[53]:
"--------------------------------------------------------------[function-doc]
F-CMPR
Args: (n1 n2)
Returns :LESS, :EQUAL, or :GREATER, according to the result of the canonical
comparison of the integers N1 and N2.
------------------------------------------------------------------------------"
In [54]:
(cat:f-cmpr 123 789)
Out[54]:
:LESS
In [55]:
(documentation 'cat:s-cmpr 'function)
Out[55]:
"--------------------------------------------------------------[function-doc]
S-CMPR
Args: (symbol1 symbol2)
Returns :LESS, :EQUAL, or :GREATER, according to the result of the Lisp string
comparison function of the strings (SYMBOL-NAME SYMBOL1) and
(SYMBOL-NAME SYMBOL2).
------------------------------------------------------------------------------"
In [56]:
(cat:s-cmpr 'circulation 'circular)
Out[56]:
:GREATER
In [57]:
(documentation 'cat:l-cmpr 'function)
Out[57]:
"--------------------------------------------------------------[function-doc]
L-CMPR
Args: (list1 list2)
Returns :LESS, :EQUAL, or :GREATER, according to the lexicographical ordering
of the generator lists LIST1 and LIST2.
------------------------------------------------------------------------------"
In [58]:
(cat:l-cmpr '(1 a b) '(1 a))
Out[58]:
:GREATER

1.2.3 Functions handling combinations

In [59]:
(documentation 'cat:cmbn 'function)
Out[59]:
"--------------------------------------------------------------[function-doc]
CMBN
Args: (degr &rest rest)
Returns a combination of degree DEGR from a sum of terms provided as a sequence
CF1 GNRT1 CF2 GNRT2 ... CFn GNRTn of coefficient / generator pairs in REST.
REST can be of arbitrary even length and can be empty, in which case the
combination is an instance of the null combination of degree DEGR.
------------------------------------------------------------------------------"
In [60]:
(cat:def comb1 (cat:cmbn 1 1 'u 2 'v 3 'w 4 'z))
Out[60]:
----------------------------------------------------------------------{CMBN 1}
<1 * U>
<2 * V>
<3 * W>
<4 * Z>
------------------------------------------------------------------------------
In [61]:
(documentation 'cat:cmbn-non-zero-p 'function)
Out[61]:
"-----------------------------------------------------------------[macro-doc]
CMBN-NON-ZERO-P
Args: (cmbn)
Tests if the combination CMBN is a non-null combination of any degree.
------------------------------------------------------------------------------"
In [62]:
(cat:cmbn-non-zero-p comb1)
Out[62]:
T
In [63]:
(cat:cmbn-list comb1)
Out[63]:
((1 . U) (2 . V) (3 . W) (4 . Z))
In [64]:
(cat:def term3 (third (cat:cmbn-list comb1)))
Out[64]:
(3 . W)
In [64]:
(cat:cffc term3)
Out[64]:
3
In [64]:
(cat:gnrt term3)
Out[64]:
W
In [64]:
(documentation 'cat:cmbn-opps 'function)
Out[64]:
"--------------------------------------------------------------[function-doc]
CMBN-OPPS
Args: (cmbn)
Returns the combination opposite combination of CMBN.
------------------------------------------------------------------------------"
In [64]:
(cat:def mcomb1 (cat:cmbn-opps comb1))
Out[64]:
----------------------------------------------------------------------{CMBN 1}
<-1 * U>
<-2 * V>
<-3 * W>
<-4 * Z>
------------------------------------------------------------------------------
In [64]:
(documentation 'cat:n-cmbn 'function)
Out[64]:
"--------------------------------------------------------------[function-doc]
N-CMBN
Args: (n cmbn)
Returns N times the combination CMBN. N must be non-zero.
------------------------------------------------------------------------------"
In [64]:
(cat:def comb2 (cat:n-cmbn 10 comb1))
Out[64]:
----------------------------------------------------------------------{CMBN 1}
<10 * U>
<20 * V>
<30 * W>
<40 * Z>
------------------------------------------------------------------------------
In [64]:
(documentation 'cat:2cmbn-add 'function)
Out[64]:
"--------------------------------------------------------------[function-doc]
2CMBN-ADD
Args: (cmpr cmbn1 cmbn2)
Returns the combination, which is the sum of CMBN1 and CMBN2. The first
argument, CMPR, must be a function or macro, which is used to compare the
generators of the combination arguments and to order the terms of the result
combination.
------------------------------------------------------------------------------"
In [64]:
(cat:def cmb12 (cat:2cmbn-add #'cat:s-cmpr comb1 comb2))
Out[64]:
----------------------------------------------------------------------{CMBN 1}
<11 * U>
<22 * V>
<33 * W>
<44 * Z>
------------------------------------------------------------------------------
In [64]:
(documentation 'cat:2cmbn-sbtr 'function)
Out[64]:
"--------------------------------------------------------------[function-doc]
2CMBN-SBTR
Args: (cmpr cmbn1 cmbn2)
Returns the combination, which is the difference of CMBN1 and CMBN2. The first
argument, CMPR, must be a function or macro, which is used to compare the
generators of the combination arguments and to order the terms of the result
combination.
------------------------------------------------------------------------------"
In [64]:
(documentation 'cat:ncmbn-add 'function)
Out[64]:
"--------------------------------------------------------------[function-doc]
NCMBN-ADD
Args: (cmpr cmbn &rest rest)
Returns the sum of an arbitrary number of combinations. The first argument,
CMPR, must be a function or macro, which is used to compare the generators of
the input combinations and to order the terms of the result combination.
------------------------------------------------------------------------------"
In [64]:
(cat:ncmbn-add #'cat:s-cmpr
               comb1 comb2 comb1 comb2 comb1 comb2 comb1 comb2 comb1 comb2)
Out[64]:
----------------------------------------------------------------------{CMBN 1}
<55 * U>
<110 * V>
<165 * W>
<220 * Z>
------------------------------------------------------------------------------

1.3.1 The function build-chcm

A first example of a chain complex

In [64]:
(cat:def diabolo-cmpr #'cat:s-cmpr)
Out[64]:
#<Compiled-function CAT:S-CMPR #x302001AC5DCF>
In [64]:
(cat:def diabolo-basis #'(lambda (dmn)
                                 (case dmn
                                     (0 '(s0 s1 s2 s3 s4 s5))
                                     (1 '(s01 s02 s12 s23 s34 s35 s45))
                                     (2 '(s345))
                                     (otherwise nil))))
Out[64]:
#<Anonymous Function #x302001D901FF>
In [64]:
(cat:def diabolo-bspn 's0)
Out[64]:
S0
In [64]:
(cat:def diabolo-pure-dffr
         #'(lambda (dmn gnr)
                   (unless (<= 0 dmn 2)
                       (error "Incorrect dimension for diabolo-dp."))
                   (case dmn
                       (0 (cat:cmbn -1))  ; Note the null combination of degree -1
                       (1 (case gnr
                              (s01 (cat:cmbn 0 -1 's0 1 's1))
                              (s02 (cat:cmbn 0 -1 's0 1 's2))
                              (s12 (cat:cmbn 0 -1 's1 1 's2))
                              (s23 (cat:cmbn 0 -1 's2 1 's3))
                              (s34 (cat:cmbn 0 -1 's3 1 's4))
                              (s35 (cat:cmbn 0 -1 's3 1 's5))
                              (s45 (cat:cmbn 0 -1 's4 1 's5))))
                       (2 (case gnr
                              (s345 (cat:cmbn 1 1 's34 -1 's35 1 's45))))
                       (otherwise (error "Bad generator for complex diabolo")))))
Out[64]:
#<Anonymous Function #x302001DC6D4F>
In [64]:
(cat:def diabolo-strt :GNRT)
Out[64]:
:GNRT
In [64]:
(cat:def diabolo-orgn '(diabolo-for-example))
Out[64]:
(DIABOLO-FOR-EXAMPLE)
In [64]:
(documentation 'cat:build-chcm 'function)
Out[64]:
"--------------------------------------------------------------[function-doc]
BUILD-CHCM
Args: (&key cmpr basis bsgn intr-dffr strt orgn)
Returns an instance of the class CHAIN-COMPLEX. The keyword arguments are as
follows:

:CMPR CMPR, the comparison function for generators

:BASIS BASIS, the function defining the basis of the freee Z-modules C_p or the
              the keyword :LOCALLY-EFFECTIVE

:BSGN BSGN, a generator, the base point of the underlying set

:INTR-DFFR INTR-DFFR, a Lisp function defining the differential homomorphism
                      for each p (d_p: C_p -> C_{p-1}

:STRT STRT, one of the keywords :GNRT or :CMBN, defining the mapping strategy
            of the differential homomorphism, either by generator or by
            combination. The default is :GNRT

:ORGN ORGN, a list containing a relevant and carefully chosen comment about
            the origin of the chain complex. This comment should be unique
            for a Kenzo session (between calls of CAT-INIT), as it is used
            for caching purposes.

Use this function instead of creating instances via the standard constructor
MAKE-INSTANCE.
------------------------------------------------------------------------------"
In [64]:
(cat:def diabolo (cat:build-chcm :cmpr diabolo-cmpr :basis diabolo-basis
                                 :bsgn diabolo-bspn :intr-dffr diabolo-pure-dffr
                                 :strt diabolo-strt :orgn diabolo-orgn))
Out[64]:
[K1 Chain-Complex]
In [64]:
(documentation 'cat:chcm 'function)
Out[64]:
"--------------------------------------------------------------[function-doc]
CHCM
Args: (idnm)
Return from the list *CHCM-LIST* the chain complex instance with Kenzo
identifier IDNUM or NIL, if it doesn't exist.
------------------------------------------------------------------------------"
In [64]:
(cat:chcm 1)
Out[64]:
[K1 Chain-Complex]
In [64]:
(cat:orgn diabolo)
Out[64]:
(DIABOLO-FOR-EXAMPLE)
In [64]:
(cat:idnm diabolo)
Out[64]:
1
In [64]:
(cat:basis diabolo 0)
Out[64]:
(S0 S1 S2 S3 S4 S5)
In [64]:
(cat:basis diabolo 1)
Out[64]:
(S01 S02 S12 S23 S34 S35 S45)
In [64]:
(cat:basis diabolo 2)
Out[64]:
(S345)
In [64]:
(cat:basis diabolo 10)
Out[64]:
NIL
In [64]:
(cat:dffr diabolo 2 's345)
Out[64]:
----------------------------------------------------------------------{CMBN 1}
<1 * S34>
<-1 * S35>
<1 * S45>
------------------------------------------------------------------------------
In [64]:
(cat:dffr diabolo (cat:dffr diabolo 2 's345))
Out[64]:
----------------------------------------------------------------------{CMBN 0}
------------------------------------------------------------------------------

An important trivial case: the unit chain complex, $\mathbb{Z}$

In [64]:
(cat:def ZCC
         (the cat:chain-complex
              (cat:build-chcm
               :cmpr #'(lambda (gnrt1 gnrt2)
                               (declare (ignore gnrt1 gnrt2))
                               (the cat:cmpr :equal))
               :basis #'(lambda (n)
                                (the list
                                     (if (zerop n) '(:Z-gnrt) cat:+empty-list+)))
               :bsgn :Z-gnrt
               :intr-dffr #'(lambda (cmbn)
                                    (the cat:cmbn (cat:zero-cmbn (1- (cat:cmbn-degr cmbn)))))
               :strt :cmbn
               :orgn '(zcc-constant))))
Out[64]:
[K3 Chain-Complex]
In [64]:
(documentation 'cat:z-chcm 'function)
Out[64]:
"--------------------------------------------------------------[function-doc]
Z-CHCM
Args: ()
Build the unit chain complex.
------------------------------------------------------------------------------"

The chain complex $\texttt{circle}$

In [64]:
(defun CIRCLE ()
    (the cat:chain-complex
         (cat:build-chcm
          :cmpr #'(lambda (gnrt1 gnrt2)
                          (declare (ignore gnrt1 gnrt2))
                          (the cat:cmpr :equal))
          :basis #'(lambda (dmns)
                           (the list
                                (case dmns (0 '(*)) (1 '(s1))
                                    (otherwise cat:+empty-list+))))
          :bsgn '*
          :intr-dffr #'cat:zero-intr-dffr
          :strt :cmbn
          :orgn '(circle))))
Out[64]:
CIRCLE