{ "metadata": { "language": "common-lisp", "name": "", "signature": "sha256:ce53837f0f933b602cdca49e885032e60c5523054bbed0154b1b627bcc3a6755" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 1" ] }, { "cell_type": "code", "collapsed": false, "input": [ "(ql:quickload \"kenzo\")" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 51, "text": [ "(\"kenzo\")" ] } ], "prompt_number": 51 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:cat-init)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "---done---" ] }, { "metadata": {}, "output_type": "pyout", "prompt_number": 52, "text": [ "NIL" ] } ], "prompt_number": 52 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "1.2.2 Ordering the generators" ] }, { "cell_type": "code", "collapsed": false, "input": [ "(documentation 'cat:f-cmpr 'function)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 53, "text": [ "\"--------------------------------------------------------------[function-doc]\n", "F-CMPR\n", "Args: (n1 n2)\n", "Returns :LESS, :EQUAL, or :GREATER, according to the result of the canonical\n", "comparison of the integers N1 and N2.\n", "------------------------------------------------------------------------------\"" ] } ], "prompt_number": 53 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:f-cmpr 123 789)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 54, "text": [ ":LESS" ] } ], "prompt_number": 54 }, { "cell_type": "code", "collapsed": false, "input": [ "(documentation 'cat:s-cmpr 'function)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 55, "text": [ "\"--------------------------------------------------------------[function-doc]\n", "S-CMPR\n", "Args: (symbol1 symbol2)\n", "Returns :LESS, :EQUAL, or :GREATER, according to the result of the Lisp string\n", "comparison function of the strings (SYMBOL-NAME SYMBOL1) and\n", "(SYMBOL-NAME SYMBOL2).\n", "------------------------------------------------------------------------------\"" ] } ], "prompt_number": 55 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:s-cmpr 'circulation 'circular)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 56, "text": [ ":GREATER" ] } ], "prompt_number": 56 }, { "cell_type": "code", "collapsed": false, "input": [ "(documentation 'cat:l-cmpr 'function)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 57, "text": [ "\"--------------------------------------------------------------[function-doc]\n", "L-CMPR\n", "Args: (list1 list2)\n", "Returns :LESS, :EQUAL, or :GREATER, according to the lexicographical ordering\n", "of the generator lists LIST1 and LIST2.\n", "------------------------------------------------------------------------------\"" ] } ], "prompt_number": 57 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:l-cmpr '(1 a b) '(1 a))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 58, "text": [ ":GREATER" ] } ], "prompt_number": 58 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "1.2.3 Functions handling combinations" ] }, { "cell_type": "code", "collapsed": false, "input": [ "(documentation 'cat:cmbn 'function)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 59, "text": [ "\"--------------------------------------------------------------[function-doc]\n", "CMBN\n", "Args: (degr &rest rest)\n", "Returns a combination of degree DEGR from a sum of terms provided as a sequence\n", "CF1 GNRT1 CF2 GNRT2 ... CFn GNRTn of coefficient / generator pairs in REST.\n", "REST can be of arbitrary even length and can be empty, in which case the\n", "combination is an instance of the null combination of degree DEGR.\n", "------------------------------------------------------------------------------\"" ] } ], "prompt_number": 59 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:def comb1 (cat:cmbn 1 1 'u 2 'v 3 'w 4 'z))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 60, "text": [ "\n", "----------------------------------------------------------------------{CMBN 1}\n", "<1 * U>\n", "<2 * V>\n", "<3 * W>\n", "<4 * Z>\n", "------------------------------------------------------------------------------\n" ] } ], "prompt_number": 60 }, { "cell_type": "code", "collapsed": false, "input": [ "(documentation 'cat:cmbn-non-zero-p 'function)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 61, "text": [ "\"-----------------------------------------------------------------[macro-doc]\n", "CMBN-NON-ZERO-P\n", "Args: (cmbn)\n", "Tests if the combination CMBN is a non-null combination of any degree.\n", "------------------------------------------------------------------------------\"" ] } ], "prompt_number": 61 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:cmbn-non-zero-p comb1)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 62, "text": [ "T" ] } ], "prompt_number": 62 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:cmbn-list comb1)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 63, "text": [ "((1 . U) (2 . V) (3 . W) (4 . Z))" ] } ], "prompt_number": 63 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:def term3 (third (cat:cmbn-list comb1)))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "(3 . W)" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:cffc term3)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "3" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:gnrt term3)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "W" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(documentation 'cat:cmbn-opps 'function)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\"--------------------------------------------------------------[function-doc]\n", "CMBN-OPPS\n", "Args: (cmbn)\n", "Returns the combination opposite combination of CMBN.\n", "------------------------------------------------------------------------------\"" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:def mcomb1 (cat:cmbn-opps comb1))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\n", "----------------------------------------------------------------------{CMBN 1}\n", "<-1 * U>\n", "<-2 * V>\n", "<-3 * W>\n", "<-4 * Z>\n", "------------------------------------------------------------------------------\n" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(documentation 'cat:n-cmbn 'function)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\"--------------------------------------------------------------[function-doc]\n", "N-CMBN\n", "Args: (n cmbn)\n", "Returns N times the combination CMBN. N must be non-zero.\n", "------------------------------------------------------------------------------\"" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:def comb2 (cat:n-cmbn 10 comb1))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\n", "----------------------------------------------------------------------{CMBN 1}\n", "<10 * U>\n", "<20 * V>\n", "<30 * W>\n", "<40 * Z>\n", "------------------------------------------------------------------------------\n" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(documentation 'cat:2cmbn-add 'function)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\"--------------------------------------------------------------[function-doc]\n", "2CMBN-ADD\n", "Args: (cmpr cmbn1 cmbn2)\n", "Returns the combination, which is the sum of CMBN1 and CMBN2. The first\n", "argument, CMPR, must be a function or macro, which is used to compare the\n", "generators of the combination arguments and to order the terms of the result\n", "combination.\n", "------------------------------------------------------------------------------\"" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:def cmb12 (cat:2cmbn-add #'cat:s-cmpr comb1 comb2))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\n", "----------------------------------------------------------------------{CMBN 1}\n", "<11 * U>\n", "<22 * V>\n", "<33 * W>\n", "<44 * Z>\n", "------------------------------------------------------------------------------\n" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(documentation 'cat:2cmbn-sbtr 'function)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\"--------------------------------------------------------------[function-doc]\n", "2CMBN-SBTR\n", "Args: (cmpr cmbn1 cmbn2)\n", "Returns the combination, which is the difference of CMBN1 and CMBN2. The first\n", "argument, CMPR, must be a function or macro, which is used to compare the\n", "generators of the combination arguments and to order the terms of the result\n", "combination.\n", "------------------------------------------------------------------------------\"" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(documentation 'cat:ncmbn-add 'function)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\"--------------------------------------------------------------[function-doc]\n", "NCMBN-ADD\n", "Args: (cmpr cmbn &rest rest)\n", "Returns the sum of an arbitrary number of combinations. The first argument,\n", "CMPR, must be a function or macro, which is used to compare the generators of\n", "the input combinations and to order the terms of the result combination.\n", "------------------------------------------------------------------------------\"" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:ncmbn-add #'cat:s-cmpr\n", " comb1 comb2 comb1 comb2 comb1 comb2 comb1 comb2 comb1 comb2)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\n", "----------------------------------------------------------------------{CMBN 1}\n", "<55 * U>\n", "<110 * V>\n", "<165 * W>\n", "<220 * Z>\n", "------------------------------------------------------------------------------\n" ] } ], "prompt_number": 64 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "1.3.1 The function build-chcm" ] }, { "cell_type": "heading", "level": 4, "metadata": {}, "source": [ "A first example of a chain complex" ] }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:def diabolo-cmpr #'cat:s-cmpr)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "#" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:def diabolo-basis #'(lambda (dmn)\n", " (case dmn\n", " (0 '(s0 s1 s2 s3 s4 s5))\n", " (1 '(s01 s02 s12 s23 s34 s35 s45))\n", " (2 '(s345))\n", " (otherwise nil))))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "#" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:def diabolo-bspn 's0)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "S0" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:def diabolo-pure-dffr\n", " #'(lambda (dmn gnr)\n", " (unless (<= 0 dmn 2)\n", " (error \"Incorrect dimension for diabolo-dp.\"))\n", " (case dmn\n", " (0 (cat:cmbn -1)) ; Note the null combination of degree -1\n", " (1 (case gnr\n", " (s01 (cat:cmbn 0 -1 's0 1 's1))\n", " (s02 (cat:cmbn 0 -1 's0 1 's2))\n", " (s12 (cat:cmbn 0 -1 's1 1 's2))\n", " (s23 (cat:cmbn 0 -1 's2 1 's3))\n", " (s34 (cat:cmbn 0 -1 's3 1 's4))\n", " (s35 (cat:cmbn 0 -1 's3 1 's5))\n", " (s45 (cat:cmbn 0 -1 's4 1 's5))))\n", " (2 (case gnr\n", " (s345 (cat:cmbn 1 1 's34 -1 's35 1 's45))))\n", " (otherwise (error \"Bad generator for complex diabolo\")))))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "#" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:def diabolo-strt :GNRT)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ ":GNRT" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:def diabolo-orgn '(diabolo-for-example))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "(DIABOLO-FOR-EXAMPLE)" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(documentation 'cat:build-chcm 'function)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\"--------------------------------------------------------------[function-doc]\n", "BUILD-CHCM\n", "Args: (&key cmpr basis bsgn intr-dffr strt orgn)\n", "Returns an instance of the class CHAIN-COMPLEX. The keyword arguments are as\n", "follows:\n", "\n", ":CMPR CMPR, the comparison function for generators\n", "\n", ":BASIS BASIS, the function defining the basis of the freee Z-modules C_p or the\n", " the keyword :LOCALLY-EFFECTIVE\n", "\n", ":BSGN BSGN, a generator, the base point of the underlying set\n", "\n", ":INTR-DFFR INTR-DFFR, a Lisp function defining the differential homomorphism\n", " for each p (d_p: C_p -> C_{p-1}\n", "\n", ":STRT STRT, one of the keywords :GNRT or :CMBN, defining the mapping strategy\n", " of the differential homomorphism, either by generator or by\n", " combination. The default is :GNRT\n", "\n", ":ORGN ORGN, a list containing a relevant and carefully chosen comment about\n", " the origin of the chain complex. This comment should be unique\n", " for a Kenzo session (between calls of CAT-INIT), as it is used\n", " for caching purposes.\n", "\n", "Use this function instead of creating instances via the standard constructor\n", "MAKE-INSTANCE.\n", "------------------------------------------------------------------------------\"" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:def diabolo (cat:build-chcm :cmpr diabolo-cmpr :basis diabolo-basis\n", " :bsgn diabolo-bspn :intr-dffr diabolo-pure-dffr\n", " :strt diabolo-strt :orgn diabolo-orgn))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "[K1 Chain-Complex]" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(documentation 'cat:chcm 'function)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\"--------------------------------------------------------------[function-doc]\n", "CHCM\n", "Args: (idnm)\n", "Return from the list *CHCM-LIST* the chain complex instance with Kenzo\n", "identifier IDNUM or NIL, if it doesn't exist.\n", "------------------------------------------------------------------------------\"" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:chcm 1)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "[K1 Chain-Complex]" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:orgn diabolo)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "(DIABOLO-FOR-EXAMPLE)" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:idnm diabolo)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "1" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:basis diabolo 0)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "(S0 S1 S2 S3 S4 S5)" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:basis diabolo 1)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "(S01 S02 S12 S23 S34 S35 S45)" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:basis diabolo 2)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "(S345)" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:basis diabolo 10)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "NIL" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:dffr diabolo 2 's345)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\n", "----------------------------------------------------------------------{CMBN 1}\n", "<1 * S34>\n", "<-1 * S35>\n", "<1 * S45>\n", "------------------------------------------------------------------------------\n" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:dffr diabolo (cat:dffr diabolo 2 's345))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\n", "----------------------------------------------------------------------{CMBN 0}\n", "------------------------------------------------------------------------------\n" ] } ], "prompt_number": 64 }, { "cell_type": "heading", "level": 4, "metadata": {}, "source": [ "An important trivial case: the unit chain complex, $\\mathbb{Z}$" ] }, { "cell_type": "code", "collapsed": false, "input": [ "(cat:def ZCC\n", " (the cat:chain-complex\n", " (cat:build-chcm\n", " :cmpr #'(lambda (gnrt1 gnrt2)\n", " (declare (ignore gnrt1 gnrt2))\n", " (the cat:cmpr :equal))\n", " :basis #'(lambda (n)\n", " (the list\n", " (if (zerop n) '(:Z-gnrt) cat:+empty-list+)))\n", " :bsgn :Z-gnrt\n", " :intr-dffr #'(lambda (cmbn)\n", " (the cat:cmbn (cat:zero-cmbn (1- (cat:cmbn-degr cmbn)))))\n", " :strt :cmbn\n", " :orgn '(zcc-constant))))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "[K3 Chain-Complex]" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "(documentation 'cat:z-chcm 'function)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "\"--------------------------------------------------------------[function-doc]\n", "Z-CHCM\n", "Args: ()\n", "Build the unit chain complex.\n", "------------------------------------------------------------------------------\"" ] } ], "prompt_number": 64 }, { "cell_type": "heading", "level": 4, "metadata": {}, "source": [ "The chain complex $\\texttt{circle}$" ] }, { "cell_type": "code", "collapsed": false, "input": [ "(defun CIRCLE ()\n", " (the cat:chain-complex\n", " (cat:build-chcm\n", " :cmpr #'(lambda (gnrt1 gnrt2)\n", " (declare (ignore gnrt1 gnrt2))\n", " (the cat:cmpr :equal))\n", " :basis #'(lambda (dmns)\n", " (the list\n", " (case dmns (0 '(*)) (1 '(s1))\n", " (otherwise cat:+empty-list+))))\n", " :bsgn '*\n", " :intr-dffr #'cat:zero-intr-dffr\n", " :strt :cmbn\n", " :orgn '(circle))))" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "CIRCLE" ] } ], "prompt_number": 64 } ], "metadata": {} } ] }