axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] 20070824.01.tpd.patch applied to silver


From: daly
Subject: [Axiom-developer] 20070824.01.tpd.patch applied to silver
Date: Mon, 27 Aug 2007 02:47:45 -0500

diff --git a/changelog b/changelog
index 87548f8..eaa591a 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,68 @@
+20070824 tpd src/doc/spadhelp          add DecimalExpansion
+20070824 tpd src/algebra/Makefile      add DecimalExpansion.help 
+20070824 tpd src/algebra/radix.spad    add DecimalExpansion.help 
+20070824 tpd src/algebra/radix.spad    add DecimalExpansion.input
+20070824 tpd src/doc/spadhelp          add DeRhamComplex
+20070824 tpd src/algebra/Makefile      add DeRhamComplex.help 
+20070824 tpd src/algebra/derham.spad   add DeRhamComplex.help 
+20070824 tpd src/algebra/derham.spad   add DeRhamComplex.input
+20070824 tpd src/doc/spadhelp          add CycleIndicators
+20070824 tpd src/algebra/Makefile      add CycleIndicators.help 
+20070824 tpd src/algebra/cycles.spad   add CycleIndicators.help 
+20070824 tpd src/algebra/cycles.spad   add CycleIndicators.input
+20070824 tpd src/input/Makefile implement new algebra regression testing
+20070823 tpd src/doc/spadhelp          add ContinuedFraction
+20070823 tpd src/algebra/Makefile      add ContinuedFraction.help 
+20070823 tpd src/algebra/contfrac.spad add ContinuedFraction.help 
+20070823 tpd src/algebra/contfrac.spad add ContinuedFraction.input
+20070823 tpd src/doc/spadhelp          add Complex
+20070823 tpd src/algebra/Makefile      add Complex.help 
+20070823 tpd src/algebra/gaussian.spad add Complex.help 
+20070823 tpd src/algebra/gaussian.spad add Complex.input
+20070823 tpd src/doc/spadhelp          add CliffordAlgebra
+20070823 tpd src/algebra/Makefile      add CliffordAlgebra.help 
+20070823 tpd src/algebra/clifford.spad add CliffordAlgebra.help 
+20070823 tpd src/algebra/clifford.spad add CliffordAlgebra.input
+20070823 tpd src/doc/spadhelp          add CharacterClass
+20070823 tpd src/algebra/Makefile      add CharacterClass.help 
+20070823 tpd src/algebra/string.spad   add CharacterClass.help 
+20070823 tpd src/algebra/string.spad   add CharacterClass.input
+20070823 tpd src/doc/spadhelp          add Character
+20070823 tpd src/algebra/Makefile      add Character.help 
+20070823 tpd src/algebra/string.spad   add Character.help 
+20070823 tpd src/algebra/string.spad   add Character.input
+20070823 tpd src/doc/spadhelp          add CartesianTensor
+20070823 tpd src/algebra/Makefile      add CartesianTensor.help 
+20070823 tpd src/algebra/carten.spad   add CartesianTensor.help 
+20070823 tpd src/algebra/carten.spad   add CartesianTensor.input
+20070823 tpd src/doc/spadhelp          add CardinalNumber
+20070823 tpd src/algebra/Makefile      add CardinalNumber.help 
+20070823 tpd src/algebra/card.spad     add CardinalNumber.help 
+20070823 tpd src/algebra/card.spad     add CardinalNumber.input
+20070823 tpd src/doc/spadhelp          add BinarySearchTree
+20070823 tpd src/algebra/Makefile      add BinarySearchTree.help 
+20070823 tpd src/algebra/tree.spad     add BinarySearchTree.help 
+20070823 tpd src/algebra/tree.spad     add BinarySearchTree.input
+20070823 tpd src/doc/spadhelp          add BinaryExpansion
+20070823 tpd src/algebra/Makefile      add BinaryExpansion.help 
+20070823 tpd src/algebra/radix.spad    add BinaryExpansion.help 
+20070823 tpd src/algebra/radix.spad    add BinaryExpansion.input
+20070823 tpd src/doc/spadhelp          add BasicOperator
+20070823 tpd src/algebra/Makefile      add BasicOperator.help 
+20070823 tpd src/algebra/op.spad       add BasicOperator.help
+20070823 tpd src/algebra/op.spad       add BasicOperator.input
+20070823 tpd src/doc/spadhelp          add BalancedBinaryTree
+20070823 tpd src/algebra/Makefile      add BalancedBinaryTree.help
+20070823 tpd src/algebra/tree.spad     add BalancedBinaryTree.help
+20070823 tpd src/algebra/tree.spad     add BalancedBinaryTree.input
+20070823 tpd src/doc/spadhelp          add AssociationList
+20070823 tpd src/algebra/Makefile      add AssociationList.help
+20070823 tpd src/algebra/list.spad     add AssociationList.help
+20070823 tpd src/algebra/list.spad     add AssociationList.input
+20070823 tpd src/algebra/Makefile create spadhelp
+20070823 tpd src/Makefile mkdir int/input
+20070823 tpd src/Makefile mkdir mnt/sys/doc/spadhelp
+20070823 tpd src/doc/book.pamphlet fix typos
 20070823 tpd src/doc/spadhelp add additional spadhelp files
 20070823 tpd src/doc/Makefile add additional spadhelp files
 20070822 tpd src/doc/spadhelp add language help
diff --git a/src/Makefile.pamphlet b/src/Makefile.pamphlet
index 13bf3ff..5df04f4 100644
--- a/src/Makefile.pamphlet
+++ b/src/Makefile.pamphlet
@@ -307,6 +307,7 @@ Once {\bf bootsys} exists we need to build {\bf depsys}
 and {\bf interpsys}. Since these two images share a lot of
 files they are built in the interp subdirectory using the
 same Makefile.
+
 <<interpdir>>=
 interpdir: ${SRC}/interp/Makefile
        @echo 25 making ${SRC}/interp
@@ -372,6 +373,13 @@ stanzas that describe the steps to extract the algebra 
from the
 [[src/algebra/*.pamphlet]] files into the [[int/algebra/*.spad]] files.
 Further details are provided in Makefile for src/algebra.
 
+The doc/spadhelp directory contains flat files of help text
+for the help system command. Algebra pamphlet contain examples
+that can be shown from these commands.
+
+We need to make the int/input file here because the algebra Makefile
+will extract input files for regression testing from the algebra pamphlets.
+
 <<algebradir>>=
 algebradir: ${SRC}/algebra/Makefile
        @echo 29 making ${SRC}/algebra
@@ -380,7 +388,9 @@ algebradir: ${SRC}/algebra/Makefile
        @mkdir -p ${OBJ}/${SYS}/algebra
        @mkdir -p ${MNT}/${SYS}/algebra
        @mkdir -p ${MNT}/${SYS}/doc/src/algebra
+       @mkdir -p ${MNT}/${SYS}/doc/spadhelp
        @mkdir -p ${MNT}/${SYS}/src/algebra
+       @mkdir -p ${INT}/input
        @(cd algebra ; ${ENV} ${MAKE} )
 
 ${SRC}/algebra/Makefile: ${SRC}/algebra/Makefile.pamphlet
diff --git a/src/algebra/Makefile.pamphlet b/src/algebra/Makefile.pamphlet
index 6a281bc..3fa3009 100644
--- a/src/algebra/Makefile.pamphlet
+++ b/src/algebra/Makefile.pamphlet
@@ -1148,6 +1148,9 @@ The [[OUTSRC=${MNT}/${SYS}/src/algebra]] subdirectory 
contains the
 algebra source files extracted from the pamphlet files. These sources 
 allow the end user to change the algebra if needed.
 
+The HELP variable points to the location of the files used for the
+[[)help]] system command. These are flat files used to provide command
+line help to Axiom. They are extracted from the algebra pamphlets.
 <<environment>>=
 
 IN=${SRC}/algebra
@@ -1156,6 +1159,7 @@ OUT=${MNT}/${SYS}/algebra
 DOC=${MNT}/${SYS}/doc/src/algebra
 OUTSRC=${MNT}/${SYS}/src/algebra
 INPUT=${INT}/input
+HELP=${MNT}/${SYS}/doc/spadhelp
 
 @
 \subsection{The depsys variable}
@@ -2013,6 +2017,156 @@ layer23done:
        @ echo ==================================
 
 @
+<<environment>>=
+SPADHELP=\
+ ${HELP}/AssociationList.help  ${HELP}/BalancedBinaryTree.help \
+ ${HELP}/BasicOperator.help    ${HELP}/BinaryExpansion.help \
+ ${HELP}/BinarySearchTree.help ${HELP}/CardinalNumber.help \
+ ${HELP}/CartesianTensor.help  ${HELP}/Character.help \
+ ${HELP}/CharacterClass.help   ${HELP}/CliffordAlgebra.help \
+ ${HELP}/Complex.help          ${HELP}/ContinuedFraction.help \
+ ${HELP}/CycleIndicators.help  ${HELP}/DeRhamComplex.help \
+ ${HELP}/DecimalExpansion.help 
+
+@
+The algebra files contain input chunks in regress format.
+This stanza is extracted by the src/input/Makefile after
+all of the other regression tests are complete. This stanza
+is put into a int/Makefile.algebra and then executed by make.
+<<algebra.regress>>=
+TESTSYS=  ${OBJ}/${SYS}/bin/interpsys
+
+REGRESS=\
+ AssociationList.regress  BalancedBinaryTree.regress \
+ BasicOperator.regress    BinaryExpansion.regress \
+ BinarySearchTree.regress CardinalNumber.regress \
+ CartesianTensor.regress  Character.regress \
+ CharacterClass.regress   CliffordAlgebra.regress \
+ Complex.regress          ContinuedFraction.regress \
+ CycleIndicators.regress  DeRhamComplex.regress \
+ DecimalExpansion.regress
+
+%.regress: %.input
+       @ echo algebra regression testing $*
+       @ rm -f $*.output
+       @ echo ')read $*.input' | ${TESTSYS} 
+       @ echo ')lisp (regress "$*.output")' | ${TESTSYS} \
+                | egrep -v '(Timestamp|Version)' | tee $*.regress
+
+all: ${REGRESS}
+       @echo algebra test cases complete.
+@
+<<spadhelp>>=
+${HELP}/AssociationList.help: ${IN}/list.spad.pamphlet
+       @echo 7000 create AssociationList.help from ${IN}/list.spad.pamphlet
+       @${TANGLE} -R"AssociationList.help" ${IN}/list.spad.pamphlet \
+            >${HELP}/AssociationList.help
+       @${TANGLE} -R"AssociationList.input" ${IN}/list.spad.pamphlet \
+            >${INPUT}/AssociationList.input
+
+${HELP}/BalancedBinaryTree.help: ${IN}/tree.spad.pamphlet
+       @echo 7001 create BalancedBinaryTree.help from ${IN}/tree.spad.pamphlet
+       @${TANGLE} -R"BalancedBinaryTree.help" ${IN}/tree.spad.pamphlet \
+            >${HELP}/BalancedBinaryTree.help
+       @${TANGLE} -R"BalancedBinaryTree.input" ${IN}/tree.spad.pamphlet \
+            >${INPUT}/BalancedBinaryTree.input
+
+${HELP}/BasicOperator.help: ${IN}/op.spad.pamphlet
+       @echo 7002 create BasicOperator.help from ${IN}/op.spad.pamphlet
+       @${TANGLE} -R"BasicOperator.help" ${IN}/op.spad.pamphlet \
+            >${HELP}/BasicOperator.help
+       @${TANGLE} -R"BasicOperator.input" ${IN}/op.spad.pamphlet \
+            >${INPUT}/BasicOperator.input
+
+${HELP}/BinaryExpansion.help: ${IN}/radix.spad.pamphlet
+       @echo 7003 create BinaryExpansion.help from ${IN}/radix.spad.pamphlet
+       @${TANGLE} -R"BinaryExpansion.help" ${IN}/radix.spad.pamphlet \
+            >${HELP}/BinaryExpansion.help
+       @${TANGLE} -R"BinaryExpansion.input" ${IN}/radix.spad.pamphlet \
+            >${INPUT}/BinaryExpansion.input
+
+${HELP}/BinarySearchTree.help: ${IN}/tree.spad.pamphlet
+       @echo 7004 create BinarySearchTree.help from ${IN}/tree.spad.pamphlet
+       @${TANGLE} -R"BinarySearchTree.help" ${IN}/tree.spad.pamphlet \
+            >${HELP}/BinarySearchTree.help
+       @${TANGLE} -R"BinarySearchTree.input" ${IN}/tree.spad.pamphlet \
+            >${INPUT}/BinarySearchTree.input
+
+${HELP}/CardinalNumber.help: ${IN}/card.spad.pamphlet
+       @echo 7005 create CardinalNumber.help from ${IN}/card.spad.pamphlet
+       @${TANGLE} -R"CardinalNumber.help" ${IN}/card.spad.pamphlet \
+            >${HELP}/CardinalNumber.help
+       @${TANGLE} -R"CardinalNumber.input" ${IN}/card.spad.pamphlet \
+            >${INPUT}/CardinalNumber.input
+
+${HELP}/CartesianTensor.help: ${IN}/carten.spad.pamphlet
+       @echo 7006 create CartesianTensor.help from ${IN}/carten.spad.pamphlet
+       @${TANGLE} -R"CartesianTensor.help" ${IN}/carten.spad.pamphlet \
+            >${HELP}/CartesianTensor.help
+       @${TANGLE} -R"CartesianTensor.input" ${IN}/carten.spad.pamphlet \
+            >${INPUT}/CartesianTensor.input
+
+${HELP}/Character.help: ${IN}/string.spad.pamphlet
+       @echo 7007 create Character.help from ${IN}/string.spad.pamphlet
+       @${TANGLE} -R"Character.help" ${IN}/string.spad.pamphlet \
+            >${HELP}/Character.help
+       @${TANGLE} -R"Character.input" ${IN}/string.spad.pamphlet \
+            >${INPUT}/Character.input
+
+${HELP}/CharacterClass.help: ${IN}/string.spad.pamphlet
+       @echo 7008 create CharacterClass.help from ${IN}/string.spad.pamphlet
+       @${TANGLE} -R"CharacterClass.help" ${IN}/string.spad.pamphlet \
+            >${HELP}/CharacterClass.help
+       @${TANGLE} -R"CharacterClass.input" ${IN}/string.spad.pamphlet \
+            >${INPUT}/CharacterClass.input
+
+${HELP}/CliffordAlgebra.help: ${IN}/clifford.spad.pamphlet
+       @echo 7009 create CliffordAlgebra.help from \
+          ${IN}/clifford.spad.pamphlet
+       @${TANGLE} -R"CliffordAlgebra.help" ${IN}/clifford.spad.pamphlet \
+            >${HELP}/CliffordAlgebra.help
+       @${TANGLE} -R"CliffordAlgebra.input" ${IN}/clifford.spad.pamphlet \
+            >${INPUT}/CliffordAlgebra.input
+
+${HELP}/Complex.help: ${IN}/gaussian.spad.pamphlet
+       @echo 7010 create Complex.help from ${IN}/gaussian.spad.pamphlet
+       @${TANGLE} -R"Complex.help" ${IN}/gaussian.spad.pamphlet \
+            >${HELP}/Complex.help
+       @${TANGLE} -R"Complex.input" ${IN}/gaussian.spad.pamphlet \
+            >${INPUT}/Complex.input
+
+${HELP}/ContinuedFraction.help: ${IN}/contfrac.spad.pamphlet
+       @echo 7011 create ContinuedFraction.help from \
+            ${IN}/contfrac.spad.pamphlet
+       @${TANGLE} -R"ContinuedFraction.help" ${IN}/contfrac.spad.pamphlet \
+            >${HELP}/ContinuedFraction.help
+       @${TANGLE} -R"ContinuedFraction.input" ${IN}/contfrac.spad.pamphlet \
+            >${INPUT}/ContinuedFraction.input
+
+${HELP}/CycleIndicators.help: ${IN}/cycles.spad.pamphlet
+       @echo 7012 create CycleIndicators.help from \
+            ${IN}/cycles.spad.pamphlet
+       @${TANGLE} -R"CycleIndicators.help" ${IN}/cycles.spad.pamphlet \
+            >${HELP}/CycleIndicators.help
+       @${TANGLE} -R"CycleIndicators.input" ${IN}/cycles.spad.pamphlet \
+            >${INPUT}/CycleIndicators.input
+
+${HELP}/DeRhamComplex.help: ${IN}/derham.spad.pamphlet
+       @echo 7013 create DeRhamComplex.help from ${IN}/derham.spad.pamphlet
+       @${TANGLE} -R"DeRhamComplex.help" ${IN}/derham.spad.pamphlet \
+            >${HELP}/DeRhamComplex.help
+       @${TANGLE} -R"DeRhamComplex.input" ${IN}/derham.spad.pamphlet \
+            >${INPUT}/DeRhamComplex.input
+
+${HELP}/DecimalExpansion.help: ${IN}/radix.spad.pamphlet
+       @echo 7014 create DecimalExpansion.help from ${IN}/radix.spad.pamphlet
+       @${TANGLE} -R"DecimalExpansion.help" ${IN}/radix.spad.pamphlet \
+            >${HELP}/DecimalExpansion.help
+       @${TANGLE} -R"DecimalExpansion.input" ${IN}/radix.spad.pamphlet \
+            >${INPUT}/DecimalExpansion.input
+
+@
+
 \section{The Makefile}
 
 <<*>>=
@@ -2048,7 +2202,8 @@ layer23done:
 <<USERLAYER>>
 <<order>>
 
-all: src ${OUT}/libdb.text ${DOCFILES} ${TESTS} ${SPADBIN}/index.html
+all: src ${OUT}/libdb.text ${DOCFILES} ${TESTS} ${SPADBIN}/index.html \
+        ${SPADHELP}
        @ echo 4302 finished ${IN}
 
 ${SPADBIN}/index.html:
@@ -2086,6 +2241,7 @@ document: ${DOCFILES}
 
 <<genericRules>>
 
+<<spadhelp>>
 <<testrules>>
 <<ps (DOC from SRC)>>
 <<libdb.text (OUT from IN)>>
diff --git a/src/algebra/card.spad.pamphlet b/src/algebra/card.spad.pamphlet
index a158508..4d02a4d 100644
--- a/src/algebra/card.spad.pamphlet
+++ b/src/algebra/card.spad.pamphlet
@@ -10,6 +10,324 @@
 \tableofcontents
 \eject
 \section{domain CARD CardinalNumber}
+<<CardinalNumber.input>>=
+-- card.spad.pamphlet CardinalNumber.input
+)spool CardinalNumber.output
+)set message test on
+)set message auto off
+)clear all
+--S 1 of 20
+c0 := 0 :: CardinalNumber
+--R 
+--R
+--R   (1)  0
+--R                                                         Type: 
CardinalNumber
+--E 1
+
+--S 2 of 20
+c1 := 1 :: CardinalNumber
+--R 
+--R
+--R   (2)  1
+--R                                                         Type: 
CardinalNumber
+--E 2
+
+--S 3 of 20
+c2 := 2 :: CardinalNumber
+--R 
+--R
+--R   (3)  2
+--R                                                         Type: 
CardinalNumber
+--E 3
+
+--S 4 of 20
+c3 := 3 :: CardinalNumber
+--R 
+--R
+--R   (4)  3
+--R                                                         Type: 
CardinalNumber
+--E 4
+
+--S 5 of 20
+A0 := Aleph 0
+--R 
+--R
+--R   (5)  Aleph(0)
+--R                                                         Type: 
CardinalNumber
+--E 5
+
+--S 6 of 20
+A1 := Aleph 1
+--R 
+--R
+--R   (6)  Aleph(1)
+--R                                                         Type: 
CardinalNumber
+--E 6
+
+--S 7 of 20
+finite? c2
+--R 
+--R
+--R   (7)  true
+--R                                                                Type: 
Boolean
+--E 7
+
+--S 8 of 20
+finite? A0
+--R 
+--R
+--R   (8)  false
+--R                                                                Type: 
Boolean
+--E 8
+
+--S 9 of 20
+countable? c2
+--R 
+--R
+--R   (9)  true
+--R                                                                Type: 
Boolean
+--E 9
+
+--S 10 of 20
+countable? A0
+--R 
+--R
+--R   (10)  true
+--R                                                                Type: 
Boolean
+--E 10
+
+--S 11 of 20
+countable? A1
+--R 
+--R
+--R   (11)  false
+--R                                                                Type: 
Boolean
+--E 11
+
+--S 12 of 20
+[c2 + c2, c2 + A1]
+--R 
+--R
+--R   (12)  [4,Aleph(1)]
+--R                                                    Type: List 
CardinalNumber
+--E 12
+
+--S 13 of 20
+[c0*c2, c1*c2, c2*c2, c0*A1, c1*A1, c2*A1, A0*A1]
+--R 
+--R
+--R   (13)  [0,2,4,0,Aleph(1),Aleph(1),Aleph(1)]
+--R                                                    Type: List 
CardinalNumber
+--E 13
+
+--S 14 of 20
+[c2**c0, c2**c1, c2**c2, A1**c0, A1**c1, A1**c2]
+--R 
+--R
+--R   (14)  [1,2,4,1,Aleph(1),Aleph(1)]
+--R                                                    Type: List 
CardinalNumber
+--E 14
+
+--S 15 of 20
+[c2-c1, c2-c2, c2-c3, A1-c2, A1-A0, A1-A1]
+--R 
+--R
+--R   (15)  [1,0,"failed",Aleph(1),Aleph(1),"failed"]
+--R                                    Type: List 
Union(CardinalNumber,"failed")
+--E 15
+
+--S 16 of 20
+generalizedContinuumHypothesisAssumed true
+--R 
+--R
+--R   (16)  true
+--R                                                                Type: 
Boolean
+--E 16
+
+--S 17 of 20
+[c0**A0, c1**A0, c2**A0, A0**A0, A0**A1, A1**A0, A1**A1]
+--R 
+--R
+--R   (17)  [0,1,Aleph(1),Aleph(1),Aleph(2),Aleph(1),Aleph(2)]
+--R                                                    Type: List 
CardinalNumber
+--E 17
+
+--S 18 of 20
+a := Aleph 0
+--R 
+--R
+--R   (18)  Aleph(0)
+--R                                                         Type: 
CardinalNumber
+--E 18
+
+--S 19 of 20
+c := 2**a
+--R 
+--R
+--R   (19)  Aleph(1)
+--R                                                         Type: 
CardinalNumber
+--E 19
+
+--S 20 of 20
+f := 2**c
+--R 
+--R
+--R   (20)  Aleph(2)
+--R                                                         Type: 
CardinalNumber
+--E 20
+)spool
+)lisp (bye)
+@
+<<CardinalNumber.help>>=
+====================================================================
+CardinalNumber examples
+====================================================================
+
+The CardinalNumber domain can be used for values indicating the
+cardinality of sets, both finite and infinite.  For example, the
+dimension operation in the category VectorSpace returns a cardinal
+number.
+
+The non-negative integers have a natural construction as cardinals
+
+  0 = #{ }, 1 = {0}, 2 = {0, 1}, ..., n = {i | 0 <= i < n}.
+
+The fact that 0 acts as a zero for the multiplication of cardinals is
+equivalent to the axiom of choice.
+
+Cardinal numbers can be created by conversion from non-negative integers.
+
+  c0 := 0 :: CardinalNumber
+   0 
+                      Type: CardinalNumber
+
+  c1 := 1 :: CardinalNumber
+   1 
+                      Type: CardinalNumber
+
+  c2 := 2 :: CardinalNumber
+   2 
+                      Type: CardinalNumber
+
+  c3 := 3 :: CardinalNumber
+   3 
+                      Type: CardinalNumber
+
+They can also be obtained as the named cardinal Aleph(n).
+
+  A0 := Aleph 0
+   Aleph(0)
+                      Type: CardinalNumber
+
+  A1 := Aleph 1
+   Aleph(1)
+                      Type: CardinalNumber
+
+The finite? operation tests whether a value is a finite cardinal, that
+is, a non-negative integer.
+
+  finite? c2
+   true
+                      Type: Boolean
+
+  finite? A0
+   false
+                      Type: Boolean
+
+Similarly, the countable?  operation determines whether a value is a
+countable cardinal, that is, finite or Aleph(0).
+
+  countable? c2
+   true
+                      Type: Boolean
+
+  countable? A0
+   true
+                      Type: Boolean
+
+  countable? A1
+   false
+                      Type: Boolean
+
+Arithmetic operations are defined on cardinal numbers as follows:
+If x = #X  and y = #Y then
+
+  x+y  = #(X+Y) cardinality of the disjoint union
+  x-y  = #(X-Y) cardinality of the relative complement
+  x*y  = #(X*Y) cardinality of the Cartesian product
+  x**y = #(X**Y) cardinality of the set of maps from Y to X
+
+Here are some arithmetic examples.
+
+  [c2 + c2, c2 + A1]
+   [4, Aleph(1)]
+                      Type: List CardinalNumber
+
+  [c0*c2, c1*c2, c2*c2, c0*A1, c1*A1, c2*A1, A0*A1]
+   [0, 2, 4, 0, Aleph(1), Aleph(1), Aleph(1)]
+                      Type: List CardinalNumber
+
+  [c2**c0, c2**c1, c2**c2, A1**c0, A1**c1, A1**c2]
+   [1, 2, 4, 1, Aleph(1), Aleph(1)]
+                      Type: List CardinalNumber
+
+Subtraction is a partial operation: it is not defined when subtracting
+a larger cardinal from a smaller one, nor when subtracting two equal
+infinite cardinals.
+
+  [c2-c1, c2-c2, c2-c3, A1-c2, A1-A0, A1-A1]
+   [1, 0, "failed", Aleph(1), Aleph(1), "failed"]
+                      Type: List Union(CardinalNumber,"failed")
+
+The generalized continuum hypothesis asserts that
+
+  2**Aleph i = Aleph(i+1)
+
+and is independent of the axioms of set theory.
+
+(reference: Goedel, The consistency of the continuum hypothesis,
+Ann. Math. Studies, Princeton Univ. Press, 1940.)
+
+The CardinalNumber domain provides an operation to assert whether the
+hypothesis is to be assumed.
+
+  generalizedContinuumHypothesisAssumed true
+   true
+                      Type: Boolean
+
+When the generalized continuum hypothesis is assumed, exponentiation
+to a transfinite power is allowed.
+
+  [c0**A0, c1**A0, c2**A0, A0**A0, A0**A1, A1**A0, A1**A1]
+   [0, 1, Aleph(1), Aleph(1), Aleph(2), Aleph(1), Aleph(2)]
+                      Type: List CardinalNumber
+
+Three commonly encountered cardinal numbers are
+
+  a = #Z countable infinity
+  c = #R the continuum
+  f = #{g| g: [0,1] -> R}
+
+In this domain, these values are obtained under the generalized
+continuum hypothesis in this way.
+
+  a := Aleph 0
+   Aleph(0)
+                      Type: CardinalNumber
+
+  c := 2**a
+   Aleph(1)
+                      Type: CardinalNumber
+
+  f := 2**c
+   Aleph(2)
+                      Type: CardinalNumber
+
+See Also:
+o )show CardinalNumber
+o $AXIOM/doc/src/algebra/card.spad.dvi
+
+@
 <<domain CARD CardinalNumber>>=
 )abbrev domain CARD CardinalNumber
 ++ Author: S.M. Watt
diff --git a/src/algebra/carten.spad.pamphlet b/src/algebra/carten.spad.pamphlet
index 0f1d295..5bcaa75 100644
--- a/src/algebra/carten.spad.pamphlet
+++ b/src/algebra/carten.spad.pamphlet
@@ -102,6 +102,954 @@ GradedAlgebra(R: CommutativeRing, E: AbelianMonoid): 
Category ==
 
 @
 \section{domain CARTEN CartesianTensor}
+<<CartesianTensor.input>>=
+-- carten.spad.pamphlet CartesianTensor.input
+)spool CartesianTensor.output
+)set message test on
+)set message auto off
+)clear all
+--S 1
+CT := CARTEN(i0 := 1, 2, Integer)
+--R 
+--R
+--R   (1)  CartesianTensor(1,2,Integer)
+--R                                                                 Type: 
Domain
+--E 1
+
+--S 2
+t0: CT := 8
+--R 
+--R
+--R   (2)  8
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 2
+
+--S 3
+rank t0
+--R 
+--R
+--R   (3)  0
+--R                                                     Type: 
NonNegativeInteger
+--E 3
+
+--S 4
+v: DirectProduct(2, Integer) := directProduct [3,4]
+--R 
+--R
+--R   (4)  [3,4]
+--R                                               Type: 
DirectProduct(2,Integer)
+--E 4
+
+--S 5
+Tv: CT := v
+--R 
+--R
+--R   (5)  [3,4]
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 5
+
+--S 6
+m: SquareMatrix(2, Integer) := matrix [ [1,2],[4,5] ]
+--R 
+--R
+--R        +1  2+
+--R   (6)  |    |
+--R        +4  5+
+--R                                                Type: 
SquareMatrix(2,Integer)
+--E 6
+
+--S 7
+Tm: CT := m
+--R 
+--R
+--R        +1  2+
+--R   (7)  |    |
+--R        +4  5+
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 7
+
+--S 8
+n: SquareMatrix(2, Integer) := matrix [ [2,3],[0,1] ]
+--R 
+--R
+--R        +2  3+
+--R   (8)  |    |
+--R        +0  1+
+--R                                                Type: 
SquareMatrix(2,Integer)
+--E 8
+
+--S 9
+Tn: CT := n
+--R 
+--R
+--R        +2  3+
+--R   (9)  |    |
+--R        +0  1+
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 9
+
+--S 10
+t1: CT := [2, 3]
+--R 
+--R
+--R   (10)  [2,3]
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 10
+
+--S 11
+rank t1
+--R 
+--R
+--R   (11)  1
+--R                                                        Type: 
PositiveInteger
+--E 11
+
+--S 12
+t2: CT := [t1, t1]
+--R 
+--R
+--R         +2  3+
+--R   (12)  |    |
+--R         +2  3+
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 12
+
+--S 13
+t3: CT := [t2, t2]
+--R 
+--R
+--R          +2  3+ +2  3+
+--R   (13)  [|    |,|    |]
+--R          +2  3+ +2  3+
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 13
+
+--S 14
+tt: CT := [t3, t3]; tt := [tt, tt]
+--R 
+--R
+--R          ++2  3+  +2  3++ ++2  3+  +2  3++
+--R          ||    |  |    || ||    |  |    ||
+--R          |+2  3+  +2  3+| |+2  3+  +2  3+|
+--R   (14)  [|              |,|              |]
+--R          |+2  3+  +2  3+| |+2  3+  +2  3+|
+--R          ||    |  |    || ||    |  |    ||
+--R          ++2  3+  +2  3++ ++2  3+  +2  3++
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 14
+
+--S 15
+rank tt
+--R 
+--R
+--R   (15)  5
+--R                                                        Type: 
PositiveInteger
+--E 15
+
+--S 16
+Tmn := product(Tm, Tn)
+--R 
+--R
+--R         ++2  3+    +4  6+ +
+--R         ||    |    |    | |
+--R         |+0  1+    +0  2+ |
+--R   (16)  |                 |
+--R         |+8  12+  +10  15+|
+--R         ||     |  |      ||
+--R         ++0  4 +  +0   5 ++
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 16
+
+--S 17
+Tmv := contract(Tm,2,Tv,1)
+--R 
+--R
+--R   (17)  [11,32]
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 17
+
+--S 18
+Tm*Tv
+--R 
+--R
+--R   (18)  [11,32]
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 18
+
+--S 19
+Tmv = m * v
+--R 
+--R
+--R   (19)  [11,32]= [11,32]
+--R                                  Type: Equation 
CartesianTensor(1,2,Integer)
+--E 19
+
+--S 20
+t0()
+--R 
+--R
+--R   (20)  8
+--R                                                        Type: 
PositiveInteger
+--E 20
+
+--S 21
+t1(1+1)
+--R 
+--R
+--R   (21)  3
+--R                                                        Type: 
PositiveInteger
+--E 21
+
+--S 22
+t2(2,1)
+--R 
+--R
+--R   (22)  2
+--R                                                        Type: 
PositiveInteger
+--E 22
+
+--S 23
+t3(2,1,2)
+--R 
+--R
+--R   (23)  3
+--R                                                        Type: 
PositiveInteger
+--E 23
+
+--S 24
+Tmn(2,1,2,1)
+--R 
+--R
+--R   (24)  0
+--R                                                     Type: 
NonNegativeInteger
+--E 24
+
+--S 25
+t0[]
+--R 
+--R
+--R   (25)  8
+--R                                                        Type: 
PositiveInteger
+--E 25
+
+--S 26
+t1[2]
+--R 
+--R
+--R   (26)  3
+--R                                                        Type: 
PositiveInteger
+--E 26
+
+--S 27
+t2[2,1]
+--R 
+--R
+--R   (27)  2
+--R                                                        Type: 
PositiveInteger
+--E 27
+
+--S 28
+t3[2,1,2]
+--R 
+--R
+--R   (28)  3
+--R                                                        Type: 
PositiveInteger
+--E 28
+
+--S 29
+Tmn[2,1,2,1]
+--R 
+--R
+--R   (29)  0
+--R                                                     Type: 
NonNegativeInteger
+--E 29
+
+--S 30
+cTmn := contract(Tmn,1,2)
+--R 
+--R
+--R         +12  18+
+--R   (30)  |      |
+--R         +0   6 +
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 30
+
+--S 31
+trace(m) * n
+--R 
+--R
+--R         +12  18+
+--R   (31)  |      |
+--R         +0   6 +
+--R                                                Type: 
SquareMatrix(2,Integer)
+--E 31
+
+--S 32
+contract(Tmn,1,2) = trace(m) * n
+--R 
+--R
+--R         +12  18+  +12  18+
+--R   (32)  |      |= |      |
+--R         +0   6 +  +0   6 +
+--R                                  Type: Equation 
CartesianTensor(1,2,Integer)
+--E 32
+
+--S 33
+contract(Tmn,1,3) = transpose(m) * n
+--R 
+--R
+--R         +2  7 +  +2  7 +
+--R   (33)  |     |= |     |
+--R         +4  11+  +4  11+
+--R                                  Type: Equation 
CartesianTensor(1,2,Integer)
+--E 33
+
+--S 34
+contract(Tmn,1,4) = transpose(m) * transpose(n)
+--R 
+--R
+--R         +14  4+  +14  4+
+--R   (34)  |     |= |     |
+--R         +19  5+  +19  5+
+--R                                  Type: Equation 
CartesianTensor(1,2,Integer)
+--E 34
+
+--S 35
+contract(Tmn,2,3) = m * n
+--R 
+--R
+--R         +2  5 +  +2  5 +
+--R   (35)  |     |= |     |
+--R         +8  17+  +8  17+
+--R                                  Type: Equation 
CartesianTensor(1,2,Integer)
+--E 35
+
+--S 36
+contract(Tmn,2,4) = m * transpose(n)
+--R 
+--R
+--R         +8   2+  +8   2+
+--R   (36)  |     |= |     |
+--R         +23  5+  +23  5+
+--R                                  Type: Equation 
CartesianTensor(1,2,Integer)
+--E 36
+
+--S 37
+contract(Tmn,3,4) = trace(n) * m
+--R 
+--R
+--R         +3   6 +  +3   6 +
+--R   (37)  |      |= |      |
+--R         +12  15+  +12  15+
+--R                                  Type: Equation 
CartesianTensor(1,2,Integer)
+--E 37
+
+--S 38
+tTmn := transpose(Tmn,1,3)
+--R 
+--R
+--R         ++2  3 +  +4   6 ++
+--R         ||     |  |      ||
+--R         |+8  12+  +10  15+|
+--R   (38)  |                 |
+--R         |+0  1+    +0  2+ |
+--R         ||    |    |    | |
+--R         ++0  4+    +0  5+ +
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 38
+
+--S 39
+transpose Tmn
+--R 
+--R
+--R         ++2  8+   +4  10++
+--R         ||    |   |     ||
+--R         |+0  0+   +0  0 +|
+--R   (39)  |                |
+--R         |+3  12+  +6  15+|
+--R         ||     |  |     ||
+--R         ++1  4 +  +2  5 ++
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 39
+
+--S 40
+transpose Tm = transpose m
+--R 
+--R
+--R         +1  4+  +1  4+
+--R   (40)  |    |= |    |
+--R         +2  5+  +2  5+
+--R                                  Type: Equation 
CartesianTensor(1,2,Integer)
+--E 40
+
+--S 41
+rTmn := reindex(Tmn, [1,4,2,3])
+--R 
+--R
+--R         ++2  0+   +3  1+ +
+--R         ||    |   |    | |
+--R         |+4  0+   +6  2+ |
+--R   (41)  |                |
+--R         |+8   0+  +12  4+|
+--R         ||     |  |     ||
+--R         ++10  0+  +15  5++
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 41
+
+--S 42
+tt := transpose(Tm)*Tn - Tn*transpose(Tm)
+--R 
+--R
+--R         +- 6  - 16+
+--R   (42)  |         |
+--R         + 2    6  +
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 42
+
+--S 43
+Tv*(tt+Tn)
+--R 
+--R
+--R   (43)  [- 4,- 11]
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 43
+
+--S 44
+reindex(product(Tn,Tn),[4,3,2,1])+3*Tn*product(Tm,Tm)
+--R 
+--R
+--R         ++46   84 +  +57   114++
+--R         ||        |  |        ||
+--R         |+174  212+  +228  285+|
+--R   (44)  |                      |
+--R         | +18  24+    +17  30+ |
+--R         | |      |    |      | |
+--R         + +57  63+    +63  76+ +
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 44
+
+--S 45
+delta:  CT := kroneckerDelta()
+--R 
+--R
+--R         +1  0+
+--R   (45)  |    |
+--R         +0  1+
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 45
+
+--S 46
+contract(Tmn, 2, delta, 1) = reindex(Tmn, [1,3,4,2])
+--R 
+--R
+--R         + +2  4+   +0  0++  + +2  4+   +0  0++
+--R         | |    |   |    ||  | |    |   |    ||
+--R         | +3  6+   +1  2+|  | +3  6+   +1  2+|
+--R   (46)  |                |= |                |
+--R         |+8   10+  +0  0+|  |+8   10+  +0  0+|
+--R         ||      |  |    ||  ||      |  |    ||
+--R         ++12  15+  +4  5++  ++12  15+  +4  5++
+--R                                  Type: Equation 
CartesianTensor(1,2,Integer)
+--E 46
+
+--S 47
+epsilon:CT := leviCivitaSymbol()
+--R 
+--R
+--R         + 0   1+
+--R   (47)  |      |
+--R         +- 1  0+
+--R                                           Type: 
CartesianTensor(1,2,Integer)
+--E 47
+
+--S 48
+contract(epsilon*Tm*epsilon, 1,2) = 2 * determinant m
+--R 
+--R
+--R   (48)  - 6= - 6
+--R                                  Type: Equation 
CartesianTensor(1,2,Integer)
+--E 48
+)spool
+)lisp (bye)
+@
+<<CartesianTensor.help>>=
+====================================================================
+CartesianTensor
+====================================================================
+
+CartesianTensor(i0,dim,R) provides Cartesian tensors with components
+belonging to a commutative ring R.  Tensors can be described as a
+generalization of vectors and matrices.  This gives a concise tensor
+algebra for multilinear objects supported by the CartesianTensor
+domain.  You can form the inner or outer product of any two tensors
+and you can add or subtract tensors with the same number of components.  
+Additionally, various forms of traces and transpositions are useful.
+
+The CartesianTensor constructor allows you to specify the minimum
+index for subscripting.  In what follows we discuss in detail how to
+manipulate tensors.
+
+Here we construct the domain of Cartesian tensors of dimension 2 over the
+integers, with indices starting at 1.
+
+  CT := CARTEN(i0 := 1, 2, Integer)
+   CartesianTensor(1,2,Integer) 
+                      Type: Domain
+
+====================================================================
+Forming tensors
+====================================================================
+
+Scalars can be converted to tensors of rank zero.
+
+  t0: CT := 8
+   8 
+                      Type: CartesianTensor(1,2,Integer)
+
+  rank t0
+   0 
+                      Type: NonNegativeInteger
+
+Vectors (mathematical direct products, rather than one dimensional array
+structures) can be converted to tensors of rank one.
+
+  v: DirectProduct(2, Integer) := directProduct [3,4]
+   [3, 4]
+                      Type: DirectProduct(2,Integer)
+
+  Tv: CT := v
+   [3, 4]
+                      Type: CartesianTensor(1,2,Integer)
+
+Matrices can be converted to tensors of rank two.
+
+  m: SquareMatrix(2, Integer) := matrix [ [1,2],[4,5] ]
+   +1  2+
+   |    |
+   +4  5+
+                      Type: SquareMatrix(2,Integer)
+
+  Tm: CT := m
+   +1  2+
+   |    |
+   +4  5+
+                      Type: CartesianTensor(1,2,Integer)
+
+  n: SquareMatrix(2, Integer) := matrix [ [2,3],[0,1] ]
+   +2  3+
+   |    |
+   +0  1+
+                      Type: SquareMatrix(2,Integer)
+
+  Tn: CT := n
+   +2  3+
+   |    |
+   +0  1+
+                      Type: CartesianTensor(1,2,Integer)
+
+In general, a tensor of rank k can be formed by making a list of
+rank k-1 tensors or, alternatively, a k-deep nested list of lists.
+
+  t1: CT := [2, 3]
+   [2, 3]
+                      Type: CartesianTensor(1,2,Integer)
+
+  rank t1
+   1 
+                      Type: PositiveInteger
+
+  t2: CT := [t1, t1]
+   +2  3+
+   |    |
+   +2  3+
+                      Type: CartesianTensor(1,2,Integer)
+
+  t3: CT := [t2, t2]
+
+    +2  3+ +2  3+
+   [|    |,|    |]
+    +2  3+ +2  3+
+                      Type: CartesianTensor(1,2,Integer)
+
+  tt: CT := [t3, t3]; tt := [tt, tt]
+    ++2  3+  +2  3++ ++2  3+  +2  3++
+    ||    |  |    || ||    |  |    ||
+    |+2  3+  +2  3+| |+2  3+  +2  3+|
+   [|              |,|              |]
+    |+2  3+  +2  3+| |+2  3+  +2  3+|
+    ||    |  |    || ||    |  |    ||
+    ++2  3+  +2  3++ ++2  3+  +2  3++
+                      Type: CartesianTensor(1,2,Integer)
+
+  rank tt
+   5 
+                      Type: PositiveInteger
+
+====================================================================
+Multiplication
+====================================================================
+
+Given two tensors of rank k1 and k2, the outer product forms a new
+tensor of rank k1+k2. Here
+
+  Tmn(i,j,k,l) = Tm(i,j)Tn(k,l)
+
+  Tmn := product(Tm, Tn)
+    ++2  3+    +4  6+ +
+    ||    |    |    | |
+    |+0  1+    +0  2+ |
+    |                 |
+    |+8  12+  +10  15+|
+    ||     |  |      ||
+    ++0  4 +  +0   5 ++
+                      Type: CartesianTensor(1,2,Integer)
+
+The inner product (contract) forms a tensor of rank k1+k2-2.  This
+product generalizes the vector dot product and matrix-vector product
+by summing component products along two indices.
+
+Here we sum along the second index of Tm and the first index of Tv. Here 
+
+ Tmv = sum {j=1..dim} Tm(i,j) Tv(j)
+
+ Tmv := contract(Tm,2,Tv,1)
+   [11,32]
+                      Type: CartesianTensor(1,2,Integer)
+
+The multiplication operator * is scalar multiplication or an inner
+product depending on the ranks of the arguments.
+
+If either argument is rank zero it is treated as scalar multiplication.  
+Otherwise, a*b is the inner product summing the last index of a with the 
+first index of b.
+
+  Tm*Tv
+   [11,32]
+                     Type: CartesianTensor(1,2,Integer)
+
+This definition is consistent with the inner product on matrices
+and vectors.
+
+  Tmv = m * v
+   [11,32] = [11,32]
+                     Type: Equation CartesianTensor(1,2,Integer)
+
+====================================================================
+Selecting Components
+====================================================================
+
+For tensors of low rank (that is, four or less), components can be selected
+by applying the tensor to its indices.
+
+  t0()
+   8
+                     Type: PositiveInteger
+
+  t1(1+1)
+   3
+                     Type: PositiveInteger
+
+  t2(2,1)
+   2
+                     Type: PositiveInteger
+
+  t3(2,1,2)
+    3
+                     Type: PositiveInteger
+
+  Tmn(2,1,2,1)
+    0
+                     Type: NonNegativeInteger
+
+A general indexing mechanism is provided for a list of indices.
+
+  t0[]
+    8
+                     Type: PositiveInteger
+
+  t1[2]
+    3
+                     Type: PositiveInteger
+
+  t2[2,1]
+    2
+                     Type: PositiveInteger
+
+The general mechanism works for tensors of arbitrary rank, but is
+somewhat less efficient since the intermediate index list must be created.
+
+  t3[2,1,2]
+    3
+                     Type: PositiveInteger
+
+  Tmn[2,1,2,1]
+    0
+                     Type: NonNegativeInteger
+
+====================================================================
+Contraction
+====================================================================
+
+A "contraction" between two tensors is an inner product, as we have
+seen above.  You can also contract a pair of indices of a single
+tensor.  This corresponds to a "trace" in linear algebra.  The
+expression contract(t,k1,k2) forms a new tensor by summing the
+diagonal given by indices in position k1 and k2.
+
+This is the tensor given by
+  xTmn = sum{k=1..dim} Tmn(k,k,i,j)
+
+  cTmn := contract(Tmn,1,2)
+    +12  18+
+    |      |
+    +0   6 +
+                         Type: CartesianTensor(1,2,Integer)
+
+Since Tmn is the outer product of matrix m and matrix n, the above is
+equivalent to this.
+
+  trace(m) * n
+    +12  18+
+    |      |
+    +0   6 +
+                         Type: SquareMatrix(2,Integer)
+
+In this and the next few examples, we show all possible contractions
+of Tmn and their matrix algebra equivalents.
+
+  contract(Tmn,1,2) = trace(m) * n
+   +12  18+  +12  18+
+   |      |= |      |
+   +0   6 +  +0   6 +
+                          Type: Equation CartesianTensor(1,2,Integer)
+
+  contract(Tmn,1,3) = transpose(m) * n
+   +2  7 +  +2  7 +
+   |     |= |     |
+   +4  11+  +4  11+
+                          Type: Equation CartesianTensor(1,2,Integer)
+
+  contract(Tmn,1,4) = transpose(m) * transpose(n)
+   +14  4+  +14  4+
+   |     |= |     |
+   +19  5+  +19  5+
+                          Type: Equation CartesianTensor(1,2,Integer)
+
+  contract(Tmn,2,3) = m * n
+   +2  5 +  +2  5 +
+   |     |= |     |
+   +8  17+  +8  17+
+                          Type: Equation CartesianTensor(1,2,Integer)
+
+  contract(Tmn,2,4) = m * transpose(n)
+   +8   2+  +8   2+
+   |     |= |     |
+   +23  5+  +23  5+
+                          Type: Equation CartesianTensor(1,2,Integer)
+
+  contract(Tmn,3,4) = trace(n) * m
+   +3   6 +  +3   6 +
+   |      |= |      |
+   +12  15+  +12  15+
+                          Type: Equation CartesianTensor(1,2,Integer)
+
+====================================================================
+Transpositions
+====================================================================
+
+You can exchange any desired pair of indices using the transpose
+operation.
+
+Here the indices in positions one and three are exchanged, that is,
+  tTmn(i,j,k,l) = Tmn(k,j,i,l)
+
+  tTmn := transpose(Tmn,1,3)
+   ++2  3 +  +4   6 ++
+   ||     |  |      ||
+   |+8  12+  +10  15+|
+   |                 |
+   |+0  1+    +0  2+ |
+   ||    |    |    | |
+   ++0  4+    +0  5+ +
+                             Type: CartesianTensor(1,2,Integer)
+
+If no indices are specified, the first and last index are exchanged.
+
+  transpose Tmn
+   ++2  8+   +4  10++
+   ||    |   |     ||
+   |+0  0+   +0  0 +|
+   |                |
+   |+3  12+  +6  15+|
+   ||     |  |     ||
+   ++1  4 +  +2  5 ++
+                             Type: CartesianTensor(1,2,Integer)
+
+This is consistent with the matrix transpose.
+
+  transpose Tm = transpose m
+   +1  4+  +1  4+
+   |    |= |    |
+   +2  5+  +2  5+
+                             Type: Equation CartesianTensor(1,2,Integer)
+
+
+If a more complicated reordering of the indices is required, then the
+reindex operation can be used.  This operation allows the indices to
+be arbitrarily permuted.
+
+  rTmn(i,j,k,l) = Tmn(i,l,j,k)
+
+  rTmn := reindex(Tmn, [1,4,2,3])
+   ++2  0+   +3  1+ +
+   ||    |   |    | |
+   |+4  0+   +6  2+ |
+   |                |
+   |+8   0+  +12  4+|
+   ||     |  |     ||
+   ++10  0+  +15  5++
+                              Type: CartesianTensor(1,2,Integer)
+
+====================================================================
+Arithmetic
+====================================================================
+
+Tensors of equal rank can be added or subtracted so arithmetic
+expressions can be used to produce new tensors.
+
+  tt := transpose(Tm)*Tn - Tn*transpose(Tm)
+   +- 6  - 16+
+   |         |
+   + 2    6  +
+                              Type: CartesianTensor(1,2,Integer)
+
+
+  Tv*(tt+Tn)
+   [- 4,- 11]
+                              Type: CartesianTensor(1,2,Integer)
+
+  reindex(product(Tn,Tn),[4,3,2,1])+3*Tn*product(Tm,Tm)
+   ++46   84 +  +57   114++
+   ||        |  |        ||
+   |+174  212+  +228  285+|
+   |                      |
+   | +18  24+    +17  30+ |
+   | |      |    |      | |
+   + +57  63+    +63  76+ +
+                              Type: CartesianTensor(1,2,Integer)
+
+====================================================================
+Specific Tensors
+====================================================================
+
+Two specific tensors have properties which depend only on the dimension.
+
+The Kronecker delta satisfies
+
+             +-              -+
+             |   1  if i  = j |
+delta(i,j) = |                |
+             |   0  if i ^= j |
+             +-              -+
+
+
+  delta:  CT := kroneckerDelta()
+   +1  0+
+   |    |
+   +0  1+
+                              Type: CartesianTensor(1,2,Integer)
+
+This can be used to reindex via contraction.
+
+  contract(Tmn, 2, delta, 1) = reindex(Tmn, [1,3,4,2])
+   + +2  4+   +0  0++  + +2  4+   +0  0++
+   | |    |   |    ||  | |    |   |    ||
+   | +3  6+   +1  2+|  | +3  6+   +1  2+|
+   |                |= |                |
+   |+8   10+  +0  0+|  |+8   10+  +0  0+|
+   ||      |  |    ||  ||      |  |    ||
+   ++12  15+  +4  5++  ++12  15+  +4  5++
+                             Type: Equation CartesianTensor(1,2,Integer)
+
+The Levi Civita symbol determines the sign of a permutation of indices.
+
+  epsilon:CT := leviCivitaSymbol()
+   + 0   1+
+   |      |
+   +- 1  0+
+                              Type: CartesianTensor(1,2,Integer)
+
+Here we have:
+
+  epsilon(i1,...,idim)
+     = +1  if i1,...,idim is an even permutation of i0,...,i0+dim-1
+     = -1  if i1,...,idim is an  odd permutation of i0,...,i0+dim-1
+     =  0  if i1,...,idim is not   a permutation of i0,...,i0+dim-1
+
+This property can be used to form determinants.
+
+  contract(epsilon*Tm*epsilon, 1,2) = 2 * determinant m
+   - 6= - 6
+                            Type: Equation CartesianTensor(1,2,Integer)
+
+
+====================================================================
+Properties of the CartesianTensor domain
+====================================================================
+
+GradedModule(R,E) denotes "E-graded R-module", that is, a collection
+of R-modules indexed by an abelian monoid E. An element g of G[s] for
+some specific s in E is said to be an element of G with degree s.
+Sums are defined in each module G[s] so two elements of G can be added
+if they have the same degree.  Morphisms can be defined and composed
+by degree to give the mathematical category of graded modules.
+
+GradedAlgebra(R,E) denotes "E-graded R-algebra".  A graded algebra is
+a graded module together with a degree preserving R-bilinear map,
+called the product.
+
+  degree(product(a,b))    = degree(a) + degree(b)
+
+  product(r*a,b)          = product(a,r*b) = r*product(a,b)
+  product(a1+a2,b)        = product(a1,b) + product(a2,b)
+  product(a,b1+b2)        = product(a,b1) + product(a,b2)
+  product(a,product(b,c)) = product(product(a,b),c)
+
+The domain CartesianTensor(i0, dim, R) belongs to the category
+GradedAlgebra(R, NonNegativeInteger).  The non-negative integer degree
+is the tensor rank and the graded algebra product is the tensor outer
+product.  The graded module addition captures the notion that only
+tensors of equal rank can be added.
+
+If V is a vector space of dimension dim over R, then the tensor module
+T[k](V) is defined as
+
+ T[0](V) = R
+  T[k](V) = T[k-1](V) * V
+
+where * denotes the R-module tensor product. CartesianTensor(i0,dim,R) 
+is the graded algebra in which the degree k module is T[k](V).
+
+====================================================================
+Tensor Calculus
+====================================================================
+
+It should be noted here that often tensors are used in the context of
+tensor-valued manifold maps.  This leads to the notion of covariant
+and contravariant bases with tensor component functions transforming
+in specific ways under a change of coordinates on the manifold.  This
+is no more directly supported by the CartesianTensor domain than it is
+by the Vector domain.  However, it is possible to have the components
+implicitly represent component maps by choosing a polynomial or
+expression type for the components.  In this case, it is up to the
+user to satisfy any constraints which arise on the basis of this
+interpretation.
+
+See Also
+o )show CartesianTensor
+o $AXIOM/doc/src/algebra/carten.spad.dvi
+
+@
 <<domain CARTEN CartesianTensor>>=
 )abbrev domain CARTEN CartesianTensor
 ++ Author: Stephen M. Watt
diff --git a/src/algebra/clifford.spad.pamphlet 
b/src/algebra/clifford.spad.pamphlet
index 88b7b3d..cd94dd5 100644
--- a/src/algebra/clifford.spad.pamphlet
+++ b/src/algebra/clifford.spad.pamphlet
@@ -236,6 +236,624 @@ $\mathbb{R}_{m,m}$      & --------$>$ & 
$\mathbb{R}^{4^m}$ \\
  $\mathbb{R}(2^m)$      & --------$>$ &  $\mathbb{R}^{4^m}$\\
                &  reshape  &           \\
 \end{tabular}
+<<CliffordAlgebra.input>>=
+-- clifford.spad.pamphlet CliffordAlgebra.input
+)spool CliffordAlgebra.output
+)set message test on
+)set message auto off
+)clear all
+--S 1 of 36
+K := Fraction Polynomial Integer
+--R 
+--R
+--R   (1)  Fraction Polynomial Integer
+--R                                                                 Type: 
Domain
+--E 1
+
+--S 2 of 36
+m := matrix [ [-1] ]
+--R 
+--R
+--R   (2)  [- 1]
+--R                                                         Type: Matrix 
Integer
+--E 2
+
+--S 3 of 36
+C := CliffordAlgebra(1, K, quadraticForm m)
+--R 
+--R
+--R   (3)  CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
+--R                                                                 Type: 
Domain
+--E 3
+
+--S 4 of 36
+i: C := e(1)
+--R 
+--R
+--R   (4)  e
+--R         1
+--R                  Type: CliffordAlgebra(1,Fraction Polynomial 
Integer,MATRIX)
+--E 4
+
+--S 5 of 36
+x := a + b * i
+--R 
+--R
+--R   (5)  a + b e
+--R               1
+--R                  Type: CliffordAlgebra(1,Fraction Polynomial 
Integer,MATRIX)
+--E 5
+
+--S 6 of 36
+y := c + d * i
+--R 
+--R
+--R   (6)  c + d e
+--R               1
+--R                  Type: CliffordAlgebra(1,Fraction Polynomial 
Integer,MATRIX)
+--E 6
+
+--S 7 of 36
+x * y
+--R 
+--R
+--R   (7)  - b d + a c + (a d + b c)e
+--R                                  1
+--R                  Type: CliffordAlgebra(1,Fraction Polynomial 
Integer,MATRIX)
+--E 7
+)clear all
+ 
+--S 8 of 36
+K := Fraction Polynomial Integer
+--R 
+--R
+--R   (1)  Fraction Polynomial Integer
+--R                                                                 Type: 
Domain
+--E 8
+
+--S 9 of 36
+m := matrix [ [-1,0],[0,-1] ]
+--R 
+--R
+--R        +- 1   0 +
+--R   (2)  |        |
+--R        + 0   - 1+
+--R                                                         Type: Matrix 
Integer
+--E 9
+
+--S 10 of 36
+H  := CliffordAlgebra(2, K, quadraticForm m)
+--R 
+--R
+--R   (3)  CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
+--R                                                                 Type: 
Domain
+--E 10
+
+--S 11 of 36
+i: H  := e(1)
+--R 
+--R
+--R   (4)  e
+--R         1
+--R                  Type: CliffordAlgebra(2,Fraction Polynomial 
Integer,MATRIX)
+--E 11
+
+--S 12 of 36
+j: H  := e(2)
+--R 
+--R
+--R   (5)  e
+--R         2
+--R                  Type: CliffordAlgebra(2,Fraction Polynomial 
Integer,MATRIX)
+--E 12
+
+--S 13 of 36
+k: H  := i * j
+--R 
+--R
+--R   (6)  e e
+--R         1 2
+--R                  Type: CliffordAlgebra(2,Fraction Polynomial 
Integer,MATRIX)
+--E 13
+
+--S 14 of 36
+x := a + b * i + c * j + d * k
+--R 
+--R
+--R   (7)  a + b e  + c e  + d e e
+--R               1      2      1 2
+--R                  Type: CliffordAlgebra(2,Fraction Polynomial 
Integer,MATRIX)
+--E 14
+
+--S 15 of 36
+y := e + f * i + g * j + h * k 
+--R 
+--R
+--R   (8)  e + f e  + g e  + h e e
+--R               1      2      1 2
+--R                  Type: CliffordAlgebra(2,Fraction Polynomial 
Integer,MATRIX)
+--E 15
+
+--S 16 of 36
+x + y
+--R 
+--R
+--R   (9)  e + a + (f + b)e  + (g + c)e  + (h + d)e e
+--R                        1           2           1 2
+--R                  Type: CliffordAlgebra(2,Fraction Polynomial 
Integer,MATRIX)
+--E 16
+
+--S 17 of 36
+x * y
+--R 
+--R
+--R   (10)
+--R     - d h - c g - b f + a e + (c h - d g + a f + b e)e
+--R                                                       1
+--R   + 
+--R     (- b h + a g + d f + c e)e  + (a h + b g - c f + d e)e e
+--R                               2                           1 2
+--R                  Type: CliffordAlgebra(2,Fraction Polynomial 
Integer,MATRIX)
+--E 17
+
+--S 18 of 36
+y * x
+--R 
+--R
+--R   (11)
+--R     - d h - c g - b f + a e + (- c h + d g + a f + b e)e
+--R                                                         1
+--R   + 
+--R     (b h + a g - d f + c e)e  + (a h - b g + c f + d e)e e
+--R                             2                           1 2
+--R                  Type: CliffordAlgebra(2,Fraction Polynomial 
Integer,MATRIX)
+--E 18
+)clear all
+ 
+--S 19 of 36
+K := Fraction Polynomial Integer
+--R 
+--R
+--R   (1)  Fraction Polynomial Integer
+--R                                                                 Type: 
Domain
+--E 19
+
+--S 20 of 36
+Ext := CliffordAlgebra(3, K, quadraticForm 0)
+--R 
+--R
+--R   (2)  CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
+--R                                                                 Type: 
Domain
+--E 20
+
+--S 21 of 36
+i: Ext := e(1)
+--R 
+--R
+--R   (3)  e
+--R         1
+--R                  Type: CliffordAlgebra(3,Fraction Polynomial 
Integer,MATRIX)
+--E 21
+
+--S 22 of 36
+j: Ext := e(2)
+--R 
+--R
+--R   (4)  e
+--R         2
+--R                  Type: CliffordAlgebra(3,Fraction Polynomial 
Integer,MATRIX)
+--E 22
+
+--S 23 of 36
+k: Ext := e(3)
+--R 
+--R
+--R   (5)  e
+--R         3
+--R                  Type: CliffordAlgebra(3,Fraction Polynomial 
Integer,MATRIX)
+--E 23
+
+--S 24 of 36
+x := x1*i + x2*j + x3*k
+--R 
+--R
+--R   (6)  x1 e  + x2 e  + x3 e
+--R            1       2       3
+--R                  Type: CliffordAlgebra(3,Fraction Polynomial 
Integer,MATRIX)
+--E 24
+
+--S 25 of 36
+y := y1*i + y2*j + y3*k
+--R 
+--R
+--R   (7)  y1 e  + y2 e  + y3 e
+--R            1       2       3
+--R                  Type: CliffordAlgebra(3,Fraction Polynomial 
Integer,MATRIX)
+--E 25
+
+--S 26 of 36
+x + y
+--R 
+--R
+--R   (8)  (y1 + x1)e  + (y2 + x2)e  + (y3 + x3)e
+--R                  1             2             3
+--R                  Type: CliffordAlgebra(3,Fraction Polynomial 
Integer,MATRIX)
+--E 26
+
+--S 27 of 36
+x * y + y * x
+--R 
+--R
+--R   (9)  0
+--R                  Type: CliffordAlgebra(3,Fraction Polynomial 
Integer,MATRIX)
+--E 27
+
+--S 28 of 36
+dual2 a == coefficient(a,[2,3]) * i + coefficient(a,[3,1]) * j + 
coefficient(a,[1,2]) * k 
+--R 
+--R                                                                   Type: 
Void
+--E 28
+
+--S 29 of 36
+dual2(x*y)
+--R 
+--R   Compiling function dual2 with type CliffordAlgebra(3,Fraction 
+--R      Polynomial Integer,MATRIX) -> CliffordAlgebra(3,Fraction 
+--R      Polynomial Integer,MATRIX) 
+--R
+--R   (11)  (x2 y3 - x3 y2)e  + (- x1 y3 + x3 y1)e  + (x1 y2 - x2 y1)e
+--R                         1                     2                   3
+--R                  Type: CliffordAlgebra(3,Fraction Polynomial 
Integer,MATRIX)
+--E 29
+)clear all
+ 
+--S 30 of 36
+K := Fraction Integer
+--R 
+--R
+--R   (1)  Fraction Integer
+--R                                                                 Type: 
Domain
+--E 30
+
+--S 31 of 36
+g := matrix [ [1,0,0,0], [0,-1,0,0], [0,0,-1,0], [0,0,0,-1] ]
+--R 
+--R
+--R        +1   0    0    0 +
+--R        |                |
+--R        |0  - 1   0    0 |
+--R   (2)  |                |
+--R        |0   0   - 1   0 |
+--R        |                |
+--R        +0   0    0   - 1+
+--R                                                         Type: Matrix 
Integer
+--E 31
+
+--S 32 of 36
+D := CliffordAlgebra(4,K, quadraticForm g)
+--R 
+--R
+--R   (3)  CliffordAlgebra(4,Fraction Integer,MATRIX)
+--R                                                                 Type: 
Domain
+--E 32
+
+--S 33 of 36
+gam := [e(i)$D for i in 1..4]
+--R 
+--R
+--R   (4)  [e ,e ,e ,e ]
+--R          1  2  3  4
+--R                        Type: List CliffordAlgebra(4,Fraction 
Integer,MATRIX)
+--E 33
+
+--S 34 of 36
+m := 1; n:= 2; r := 3; s := 4;
+--R 
+--R
+--R                                                        Type: 
PositiveInteger
+--E 34
+
+--S 35 of 36
+lhs := reduce(+, [reduce(+, [ g(l,t)*gam(l)*gam(m)*gam(n)*gam(r)*gam(s)*gam(t) 
for l in 1..4]) for t in 1..4])
+--R 
+--R
+--R   (6)  - 4e e e e
+--R            1 2 3 4
+--R                             Type: CliffordAlgebra(4,Fraction 
Integer,MATRIX)
+--E 35
+
+--S 36 of 36
+rhs := 2*(gam s * gam m*gam n*gam r + gam r*gam n*gam m*gam s) 
+--R 
+--R
+--R   (7)  - 4e e e e
+--R            1 2 3 4
+--R                             Type: CliffordAlgebra(4,Fraction 
Integer,MATRIX)
+--E 36
+)spool
+)lisp (bye)
+@
+<<CliffordAlgebra.help>>=
+====================================================================
+CliffordAlgebra examples
+====================================================================
+
+CliffordAlgebra(n,K,Q) defines a vector space of dimension 2^n over
+the field K with a given quadratic form Q.  If {e1..en} is a basis for
+K^n then
+
+
+{ 1,
+  e(i)         1 <= i <= n,
+  e(i1)*e(i2)  1 <= i1 < i2 <=n,
+  ...,
+  e(1)*e(2)*...*e(n) }
+
+is a basis for the Clifford algebra. The algebra is defined by the relations
+
+  e(i)*e(i) = Q(e(i))
+  e(i)*e(j) = -e(j)*e(i),  for i ^= j
+
+Examples of Clifford Algebras are gaussians (complex numbers),
+quaternions, exterior algebras and spin algebras.
+
+====================================================================
+The Complex Numbers as a Clifford Algebra
+====================================================================
+
+This is the field over which we will work, rational functions with
+integer coefficients.
+
+  K := Fraction Polynomial Integer
+   Fraction Polynomial Integer
+                         Type: Domain
+
+We use this matrix for the quadratic form.
+
+  m := matrix [ [-1] ]
+   [- 1]
+                         Type: Matrix Integer
+
+We get complex arithmetic by using this domain.
+
+  C := CliffordAlgebra(1, K, quadraticForm m)
+   CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
+                         Type: Domain
+
+Here is i, the usual square root of -1.
+
+  i: C := e(1)
+   e
+    1
+               Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
+
+Here are some examples of the arithmetic.
+
+  x := a + b * i
+   a + b e
+          1
+               Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
+
+  y := c + d * i
+   c + d e
+          1
+               Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
+
+  x * y
+   - b d + a c + (a d + b c)e
+                             1
+               Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
+
+====================================================================
+The Quaternion Numbers as a Clifford Algebra
+====================================================================
+
+This is the field over which we will work, rational functions with
+integer coefficients.
+
+  K := Fraction Polynomial Integer
+   Fraction Polynomial Integer
+                      Type: Domain
+
+We use this matrix for the quadratic form.
+
+  m := matrix [ [-1,0],[0,-1] ]
+   +- 1   0 +
+   |        |
+   + 0   - 1+
+                      Type: Matrix Integer
+
+The resulting domain is the quaternions.
+
+  H  := CliffordAlgebra(2, K, quadraticForm m)
+   CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
+                      Type: Domain
+
+We use Hamilton's notation for i, j, k.
+
+  i: H  := e(1)
+   e
+    1
+              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
+
+  j: H  := e(2)
+   e
+    2
+              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
+
+  k: H  := i * j
+   e e
+    1 2
+              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
+
+  x := a + b * i + c * j + d * k
+   a + b e  + c e  + d e e
+          1      2      1 2
+              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
+
+  y := e + f * i + g * j + h * k 
+   e + f e  + g e  + h e e
+          1      2      1 2
+              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
+
+  x + y
+   e + a + (f + b)e  + (g + c)e  + (h + d)e e
+                   1           2           1 2
+              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
+
+  x * y
+   - d h - c g - b f + a e + (c h - d g + a f + b e)e
+                                                     1
+   + 
+     (- b h + a g + d f + c e)e  + (a h + b g - c f + d e)e e
+                               2                           1 2
+              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
+
+  y * x
+   - d h - c g - b f + a e + (- c h + d g + a f + b e)e
+                                                       1
+   + 
+     (b h + a g - d f + c e)e  + (a h - b g + c f + d e)e e
+                             2                           1 2
+                  Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
+
+====================================================================
+The Exterior Algebra on a Three Space
+====================================================================
+
+This is the field over which we will work, rational functions with
+integer coefficients.
+
+  K := Fraction Polynomial Integer
+   Fraction Polynomial Integer
+                  Type: Domain
+
+If we chose the three by three zero quadratic form, we obtain
+the exterior algebra on e(1),e(2),e(3).
+
+  Ext := CliffordAlgebra(3, K, quadraticForm 0)
+   CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
+                  Type: Domain
+
+This is a three dimensional vector algebra.  We define i, j, k as the
+unit vectors.
+
+  i: Ext := e(1)
+   e
+    1
+             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
+
+  j: Ext := e(2)
+   e
+    2
+             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
+
+  k: Ext := e(3)
+   e
+    3
+             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
+
+Now it is possible to do arithmetic.
+
+  x := x1*i + x2*j + x3*k
+   x1 e  + x2 e  + x3 e
+       1       2       3
+             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
+
+  y := y1*i + y2*j + y3*k
+   y1 e  + y2 e  + y3 e
+       1       2       3
+             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
+
+  x + y
+   (y1 + x1)e  + (y2 + x2)e  + (y3 + x3)e
+             1             2             3
+             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
+
+  x * y + y * x
+   0
+             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
+
+On an n space, a grade p form has a dual n-p form.  In particular, in
+three space the dual of a grade two element identifies 
+ 
+  e1*e2 -> e3, e2*e3 -> e1, e3*e1 -> e2.
+
+  dual2 a == coefficient(a,[2,3]) * i + coefficient(a,[3,1]) * j + 
coefficient(a,[1,2]) * k 
+                      Type: Void
+
+The vector cross product is then given by this.
+
+  dual2(x*y)
+   (x2 y3 - x3 y2)e  + (- x1 y3 + x3 y1)e  + (x1 y2 - x2 y1)e
+                   1                     2                   3
+           Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
+
+====================================================================
+The Dirac Spin Algebra
+====================================================================
+
+In this section we will work over the field of rational numbers.
+
+  K := Fraction Integer
+   Fraction Integer
+                       Type: Domain
+
+We define the quadratic form to be the Minkowski space-time metric.
+
+  g := matrix [ [1,0,0,0], [0,-1,0,0], [0,0,-1,0], [0,0,0,-1] ]
+   +1   0    0    0 +
+   |                |
+   |0  - 1   0    0 |
+   |                |
+   |0   0   - 1   0 |
+   |                |
+   +0   0    0   - 1+
+                       Type: Matrix Integer
+
+We obtain the Dirac spin algebra used in Relativistic Quantum Field Theory.
+
+  D := CliffordAlgebra(4,K, quadraticForm g)
+   CliffordAlgebra(4,Fraction Integer,MATRIX)
+                       Type: Domain
+
+The usual notation for the basis is gamma with a superscript.  For
+Axiom input we will use gam(i):
+
+  gam := [e(i)$D for i in 1..4]
+   [e ,e ,e ,e ]
+     1  2  3  4
+                 Type: List CliffordAlgebra(4,Fraction Integer,MATRIX)
+
+There are various contraction identities of the form
+
+  g(l,t)*gam(l)*gam(m)*gam(n)*gam(r)*gam(s)*gam(t) =
+      2*(gam(s)gam(m)gam(n)gam(r) + gam(r)*gam(n)*gam(m)*gam(s))
+
+where a sum over l and t is implied.
+
+Verify this identity for particular values of m,n,r,s.
+
+  m := 1; n:= 2; r := 3; s := 4;
+                      Type: PositiveInteger
+
+  lhs := reduce(+, [reduce(+, [ 
g(l,t)*gam(l)*gam(m)*gam(n)*gam(r)*gam(s)*gam(t) for l in 1..4]) for t in 1..4])
+   - 4e e e e
+       1 2 3 4
+                      Type: CliffordAlgebra(4,Fraction Integer,MATRIX)
+
+  rhs := 2*(gam s * gam m*gam n*gam r + gam r*gam n*gam m*gam s) 
+   - 4e e e e
+       1 2 3 4
+                      Type: CliffordAlgebra(4,Fraction Integer,MATRIX)
+
+See Also:
+o )help Complex
+o )help Quaternion
+o )show CliffordAlgebra
+o $AXIOM/doc/src/algebra/clifford.spad
+
+@
 <<domain CLIF CliffordAlgebra>>=
 )abbrev domain CLIF CliffordAlgebra
 ++ Author: Stephen M. Watt
diff --git a/src/algebra/contfrac.spad.pamphlet 
b/src/algebra/contfrac.spad.pamphlet
index 2261d76..d6c24af 100644
--- a/src/algebra/contfrac.spad.pamphlet
+++ b/src/algebra/contfrac.spad.pamphlet
@@ -2,7 +2,7 @@
 \usepackage{axiom}
 \begin{document}
 \title{\$SPAD/src/algebra contfrac.spad}
-\author{Stephen M. Watt, Clifton J. Williamson}
+\author{Stephen M. Watt, Clifton J. Williamson, Timothy Daly}
 \maketitle
 \begin{abstract}
 \end{abstract}
@@ -10,6 +10,550 @@
 \tableofcontents
 \eject
 \section{domain CONTFRAC ContinuedFraction}
+<<ContinuedFraction.input>>=
+-- contfrac.spad.pamphlet ContinuedFraction.input
+)spool ContinuedFraction.output
+)set message test on
+)set message auto off
+)clear all
+--S 1 of 22
+c := continuedFraction(314159/100000)
+--R 
+--R
+--R              1 |     1  |     1 |     1  |     1 |     1 |     1 |
+--R   (1)  3 + +---+ + +----+ + +---+ + +----+ + +---+ + +---+ + +---+
+--R            | 7     | 15     | 1     | 25     | 1     | 7     | 4
+--R                                              Type: ContinuedFraction 
Integer
+--E 1
+
+--S 2 of 22
+partialQuotients c
+--R 
+--R
+--R   (2)  [3,7,15,1,25,1,7,4]
+--R                                                         Type: Stream 
Integer
+--E 2
+
+--S 3 of 22
+convergents c
+--R 
+--R
+--R           22 333 355 9208 9563 76149 314159
+--R   (3)  [3,--,---,---,----,----,-----,------]
+--R            7 106 113 2931 3044 24239 100000
+--R                                                Type: Stream Fraction 
Integer
+--E 3
+
+--S 4 of 22
+approximants c
+--R 
+--R
+--R                                      ______
+--R           22 333 355 9208 9563 76149 314159
+--R   (4)  [3,--,---,---,----,----,-----,------]
+--R            7 106 113 2931 3044 24239 100000
+--R                                                Type: Stream Fraction 
Integer
+--E 4
+
+--S 5 of 22
+pq := partialQuotients(1/c)
+--R 
+--R
+--R   (5)  [0,3,7,15,1,25,1,7,4]
+--R                                                         Type: Stream 
Integer
+--E 5
+
+--S 6 of 22
+continuedFraction(first pq,repeating [1],rest pq)
+--R 
+--R
+--R          1 |     1 |     1  |     1 |     1  |     1 |     1 |     1 |
+--R   (6)  +---+ + +---+ + +----+ + +---+ + +----+ + +---+ + +---+ + +---+
+--R        | 3     | 7     | 15     | 1     | 25     | 1     | 7     | 4
+--R                                              Type: ContinuedFraction 
Integer
+--E 6
+
+--S 7 of 22
+z:=continuedFraction(3,repeating [1],repeating [3,6])
+--R 
+--R
+--R   (7)
+--R           1 |     1 |     1 |     1 |     1 |     1 |     1 |     1 |     
1 |
+--R     3 + +---+ + +---+ + +---+ + +---+ + +---+ + +---+ + +---+ + +---+ + 
+---+
+--R         | 3     | 6     | 3     | 6     | 3     | 6     | 3     | 6     | 3
+--R   + 
+--R       1 |
+--R     +---+ + ...
+--R     | 6
+--R                                              Type: ContinuedFraction 
Integer
+--E 7
+
+--S 8 of 22
+dens:Stream Integer := cons(1,generate((x+->x+4),6))
+--R 
+--R
+--R   (8)  [1,6,10,14,18,22,26,30,34,38,...]
+--R                                                         Type: Stream 
Integer
+--E 8
+
+--S 9 of 22
+cf := continuedFraction(0,repeating [1],dens)
+--R 
+--R
+--R   (9)
+--R       1 |     1 |     1  |     1  |     1  |     1  |     1  |     1  |
+--R     +---+ + +---+ + +----+ + +----+ + +----+ + +----+ + +----+ + +----+
+--R     | 1     | 6     | 10     | 14     | 18     | 22     | 26     | 30
+--R   + 
+--R       1  |     1  |
+--R     +----+ + +----+ + ...
+--R     | 34     | 38
+--R                                              Type: ContinuedFraction 
Integer
+--E 9
+
+--S 10 of 22
+ccf := convergents cf
+--R 
+--R
+--R              6 61  860 15541 342762  8927353 268163352  9126481321
+--R   (10)  [0,1,-,--,----,-----,------,--------,---------,-----------,...]
+--R              7 71 1001 18089 398959 10391023 312129649 10622799089
+--R                                                Type: Stream Fraction 
Integer
+--E 10
+
+--S 11 of 22
+eConvergents := [2*e + 1 for e in ccf]
+--R 
+--R
+--R              19 193 2721 49171 1084483 28245729 848456353 28875761731
+--R   (11)  [1,3,--,---,----,-----,-------,--------,---------,-----------,...]
+--R               7  71 1001 18089  398959 10391023 312129649 10622799089
+--R                                                Type: Stream Fraction 
Integer
+--E 11
+
+--S 12 of 22
+eConvergents :: Stream Float
+--R 
+--R
+--R   (12)
+--R   [1.0, 3.0, 2.7142857142 857142857, 2.7183098591 549295775,
+--R    2.7182817182 817182817, 2.7182818287 356957267, 2.7182818284 585634113,
+--R    2.7182818284 590458514, 2.7182818284 590452348, 2.7182818284 590452354,
+--R    ...]
+--R                                                           Type: Stream 
Float
+--E 12
+
+--S 13 of 22
+exp 1.0
+--R 
+--R
+--R   (13)  2.7182818284 590452354
+--R                                                                  Type: 
Float
+--E 13
+
+--S 14 of 22
+cf := continuedFraction(1,[(2*i+1)**2 for i in 0..],repeating [2])
+--R 
+--R
+--R   (14)
+--R           1 |     9 |     25 |     49 |     81 |     121 |     169 |     
225 |
+--R     1 + +---+ + +---+ + +----+ + +----+ + +----+ + +-----+ + +-----+ + 
+-----+
+--R         | 2     | 2     | 2      | 2      | 2      |  2      |  2      |  2
+--R   + 
+--R       289 |     361 |
+--R     +-----+ + +-----+ + ...
+--R     |  2      |  2
+--R                                              Type: ContinuedFraction 
Integer
+--E 14
+
+--S 15 of 22
+ccf := convergents cf
+--R 
+--R
+--R            3 15 105 315 3465 45045 45045 765765 14549535
+--R   (15)  [1,-,--,---,---,----,-----,-----,------,--------,...]
+--R            2 13  76 263 2578 36979 33976 622637 11064338
+--R                                                Type: Stream Fraction 
Integer
+--E 15
+
+--S 16 of 22
+piConvergents := [4/p for p in ccf] 
+--R 
+--R
+--R            8 52 304 1052 10312 147916 135904 2490548 44257352
+--R   (16)  [4,-,--,---,----,-----,------,------,-------,--------,...]
+--R            3 15 105  315  3465  45045  45045  765765 14549535
+--R                                                Type: Stream Fraction 
Integer
+--E 16
+
+--S 17 of 22
+piConvergents :: Stream Float
+--R 
+--R
+--R   (17)
+--R   [4.0, 2.6666666666 666666667, 3.4666666666 666666667,
+--R    2.8952380952 380952381, 3.3396825396 825396825, 2.9760461760 461760462,
+--R    3.2837384837 384837385, 3.0170718170 718170718, 3.2523659347 188758953,
+--R    3.0418396189 294022111, ...]
+--R                                                           Type: Stream 
Float
+--E 17
+
+--S 18 of 22
+continuedFraction((- 122 + 597*%i)/(4 - 4*%i))
+--R 
+--R
+--R                            1    |         1     |
+--R   (18)  - 90 + 59%i + +---------+ + +-----------+
+--R                       | 1 - 2%i     | - 1 + 2%i
+--R                                      Type: ContinuedFraction Complex 
Integer
+--E 18
+
+--S 19 of 22
+r : Fraction UnivariatePolynomial(x,Fraction Integer) 
+--R 
+--R                                                                   Type: 
Void
+--E 19
+
+--S 20 of 22
+r := ((x - 1) * (x - 2)) / ((x-3) * (x-4))
+--R 
+--R
+--R           2
+--R          x  - 3x + 2
+--R   (20)  ------------
+--R          2
+--R         x  - 7x + 12
+--R                      Type: Fraction UnivariatePolynomial(x,Fraction 
Integer)
+--E 20
+
+--S 21 of 22
+continuedFraction r 
+--R 
+--R
+--R                  1    |         1     |
+--R   (21)  1 + +---------+ + +-----------+
+--R             | 1     9     | 16     40
+--R             | - x - -     | -- x - --
+--R             | 4     8     |  3      3
+--R             Type: ContinuedFraction UnivariatePolynomial(x,Fraction 
Integer)
+--E 21
+
+--S 22 of 22
+[i*i for i in convergents(z) :: Stream Float] 
+--R 
+--R
+--R   (22)
+--R   [9.0, 11.1111111111 11111111, 10.9944598337 9501385, 11.0002777777 
77777778,
+--R    10.9999860763 98799786, 11.0000006979 29731039, 10.9999999650 15834446,
+--R    11.0000000017 53603304, 10.9999999999 12099531, 11.0000000000 04406066,
+--R    ...]
+--R                                                           Type: Stream 
Float
+--E 22
+)spool
+)lisp (bye)
+@
+<<ContinuedFraction.help>>=
+====================================================================
+ContinuedFraction examples
+====================================================================
+
+Continued fractions have been a fascinating and useful tool in
+mathematics for well over three hundred years.  Axiom implements
+continued fractions for fractions of any Euclidean domain.  In
+practice, this usually means rational numbers.  In this section we
+demonstrate some of the operations available for manipulating both
+finite and infinite continued fractions.  
+
+The ContinuedFraction domain is a field and therefore you can add,
+subtract, multiply and divide the fractions.
+
+The continuedFraction operation converts its fractional argument to a
+continued fraction.
+
+  c := continuedFraction(314159/100000)
+         1 |     1  |     1 |     1  |     1 |     1 |     1 |
+   3 + +---+ + +----+ + +---+ + +----+ + +---+ + +---+ + +---+
+       | 7     | 15     | 1     | 25     | 1     | 7     | 4
+                        Type: ContinuedFraction Integer
+
+This display is a compact form of the bulkier
+
+        3 +                 1
+            -------------------------------
+            7 +               1
+                ---------------------------
+                15 +            1
+                     ----------------------
+                     1 +          1
+                         ------------------
+                         25 +       1
+                              -------------
+                              1 +     1
+                                  ---------
+                                  7 +   1
+                                      -----
+                                        4
+
+You can write any rational number in a similar form.  The fraction
+will be finite and you can always take the "numerators" to be 1.
+That is, any rational number can be written as a simple, finite
+continued fraction of the form
+
+        a(1) +           1
+               -------------------------
+               a(2) +          1
+                      --------------------
+                      a(3) +
+                             .
+                              .
+                               .
+                                     1
+                               -------------
+                               a(n-1) +  1
+                                        ----
+                                        a(n)
+
+
+The a(i) are called partial quotients and the operation partialQuotients 
+creates a stream of them.
+
+  partialQuotients c
+   [3,7,15,1,25,1,7,4]
+                        Type: Stream Integer
+
+By considering more and more of the fraction, you get the convergents.
+For example, the first convergent is a(1), the second is a(1) + 1/a(2)
+and so on.
+
+  convergents c
+      22 333 355 9208 9563 76149 314159
+   [3,--,---,---,----,----,-----,------]
+       7 106 113 2931 3044 24239 100000
+                         Type: Stream Fraction Integer
+
+Since this is a finite continued fraction, the last convergent is the
+original rational number, in reduced form.  The result of approximants
+is always an infinite stream, though it may just repeat the "last" value.
+
+  approximants c
+                                 ______
+      22 333 355 9208 9563 76149 314159
+   [3,--,---,---,----,----,-----,------]
+       7 106 113 2931 3044 24239 100000
+                         Type: Stream Fraction Integer
+
+Inverting c only changes the partial quotients of its fraction by
+inserting a 0 at the beginning of the list.
+
+  pq := partialQuotients(1/c)
+   [0,3,7,15,1,25,1,7,4]
+                         Type: Stream Integer
+
+Do this to recover the original continued fraction from this list of
+partial quotients.  The three-argument form of the continuedFraction
+operation takes an element which is the whole part of the fraction, a
+stream of elements which are the numerators of the fraction, and a
+stream of elements which are the denominators of the fraction.
+
+  continuedFraction(first pq,repeating [1],rest pq)
+     1 |     1 |     1  |     1 |     1  |     1 |     1 |     1 |
+   +---+ + +---+ + +----+ + +---+ + +----+ + +---+ + +---+ + +---+
+   | 3     | 7     | 15     | 1     | 25     | 1     | 7     | 4
+                         Type: ContinuedFraction Integer
+
+The streams need not be finite for continuedFraction.  Can you guess
+which irrational number has the following continued fraction?  See the
+end of this section for the answer.
+
+  z:=continuedFraction(3,repeating [1],repeating [3,6])
+           1 |     1 |     1 |     1 |     1 |     1 |     1 |     1 |     1 |
+     3 + +---+ + +---+ + +---+ + +---+ + +---+ + +---+ + +---+ + +---+ + +---+
+         | 3     | 6     | 3     | 6     | 3     | 6     | 3     | 6     | 3
+   + 
+       1 |
+     +---+ + ...
+     | 6
+                         Type: ContinuedFraction Integer
+
+In 1737 Euler discovered the infinite continued fraction expansion
+
+        e - 1             1
+        ----- = ---------------------
+          2     1 +         1
+                    -----------------
+                    6 +       1
+                        -------------
+                        10 +    1
+                             --------
+                             14 + ...
+
+
+We use this expansion to compute rational and floating point
+approximations of e. For this and other interesting expansions, see
+C. D. Olds, Continued Fractions, New Mathematical Library, (New York:
+Random House, 1963), pp.  134--139.}
+
+By looking at the above expansion, we see that the whole part is 0 and
+the numerators are all equal to 1.  This constructs the stream of
+denominators.
+
+  dens:Stream Integer := cons(1,generate((x+->x+4),6))
+   [1,6,10,14,18,22,26,30,34,38,...]
+                        Type: Stream Integer
+
+Therefore this is the continued fraction expansion for (e - 1) / 2.
+
+  cf := continuedFraction(0,repeating [1],dens)
+       1 |     1 |     1  |     1  |     1  |     1  |     1  |     1  |
+     +---+ + +---+ + +----+ + +----+ + +----+ + +----+ + +----+ + +----+
+     | 1     | 6     | 10     | 14     | 18     | 22     | 26     | 30
+   + 
+       1  |     1  |
+     +----+ + +----+ + ...
+     | 34     | 38
+                    Type: ContinuedFraction Integer
+
+These are the rational number convergents.
+
+  ccf := convergents cf
+        6 61  860 15541 342762  8927353 268163352  9126481321
+   [0,1,-,--,----,-----,------,--------,---------,-----------,...]
+        7 71 1001 18089 398959 10391023 312129649 10622799089
+                    Type: Stream Fraction Integer
+
+You can get rational convergents for e by multiplying by 2 and adding 1.
+
+  eConvergents := [2*e + 1 for e in ccf]
+         19 193 2721 49171 1084483 28245729 848456353 28875761731
+    [1,3,--,---,----,-----,-------,--------,---------,-----------,...]
+          7  71 1001 18089  398959 10391023 312129649 10622799089
+                    Type: Stream Fraction Integer
+
+You can also compute the floating point approximations to these convergents.
+
+  eConvergents :: Stream Float
+   [1.0, 3.0, 2.7142857142 857142857, 2.7183098591 549295775,
+    2.7182817182 817182817, 2.7182818287 356957267, 2.7182818284 585634113,
+    2.7182818284 590458514, 2.7182818284 590452348, 2.7182818284 590452354,
+    ...]
+                       Type: Stream Float
+
+Compare this to the value of e computed by the exp operation in Float.
+
+  exp 1.0
+   2.7182818284 590452354
+                       Type: Float
+
+In about 1658, Lord Brouncker established the following expansion
+for 4 / pi,
+
+        1 +            1
+            -----------------------
+            2 +          9
+                -------------------
+                2 +        25
+                    ---------------
+                    2 +      49
+                        -----------
+                        2 +    81
+                            -------
+                            2 + ...
+
+Let's use this expansion to compute rational and floating point
+approximations for pi.
+
+  cf := continuedFraction(1,[(2*i+1)**2 for i in 0..],repeating [2])
+           1 |     9 |     25 |     49 |     81 |     121 |     169 |     225 |
+     1 + +---+ + +---+ + +----+ + +----+ + +----+ + +-----+ + +-----+ + +-----+
+         | 2     | 2     | 2      | 2      | 2      |  2      |  2      |  2
+   + 
+       289 |     361 |
+     +-----+ + +-----+ + ...
+     |  2      |  2
+                       Type: ContinuedFraction Integer
+
+  ccf := convergents cf
+      3 15 105 315 3465 45045 45045 765765 14549535
+   [1,-,--,---,---,----,-----,-----,------,--------,...]
+      2 13  76 263 2578 36979 33976 622637 11064338
+                       Type: Stream Fraction Integer
+
+  piConvergents := [4/p for p in ccf] 
+      8 52 304 1052 10312 147916 135904 2490548 44257352
+   [4,-,--,---,----,-----,------,------,-------,--------,...]
+      3 15 105  315  3465  45045  45045  765765 14549535
+                       Type: Stream Fraction Integer
+
+As you can see, the values are converging to
+pi = 3.14159265358979323846..., but not very quickly.
+
+  piConvergents :: Stream Float
+   [4.0, 2.6666666666 666666667, 3.4666666666 666666667,
+    2.8952380952 380952381, 3.3396825396 825396825, 2.9760461760 461760462,
+    3.2837384837 384837385, 3.0170718170 718170718, 3.2523659347 188758953,
+    3.0418396189 294022111, ...]
+                      Type: Stream Float
+
+You need not restrict yourself to continued fractions of integers.
+Here is an expansion for a quotient of Gaussian integers.
+
+  continuedFraction((- 122 + 597*%i)/(4 - 4*%i))
+                      1    |         1     |
+   - 90 + 59%i + +---------+ + +-----------+
+                 | 1 - 2%i     | - 1 + 2%i
+                      Type: ContinuedFraction Complex Integer
+
+This is an expansion for a quotient of polynomials in one variable
+with rational number coefficients.
+
+  r : Fraction UnivariatePolynomial(x,Fraction Integer) 
+                      Type: Void
+
+  r := ((x - 1) * (x - 2)) / ((x-3) * (x-4))
+     2
+    x  - 3x + 2
+   ------------
+    2
+   x  - 7x + 12
+                      Type: Fraction UnivariatePolynomial(x,Fraction Integer)
+
+  continuedFraction r 
+            1    |         1     |
+   1 + +---------+ + +-----------+
+       | 1     9     | 16     40
+       | - x - -     | -- x - --
+       | 4     8     |  3      3
+             Type: ContinuedFraction UnivariatePolynomial(x,Fraction Integer)
+
+To conclude this section, we give you evidence that
+
+    z = 3 +            1
+            -----------------------
+            3 +          1
+                -------------------
+                6 +        1
+                    ---------------
+                    3 +      1
+                        -----------
+                        6 +    1
+                            -------
+                            3 + ...
+
+is the expansion of sqrt(11).
+
+  [i*i for i in convergents(z) :: Stream Float] 
+   [9.0, 11.1111111111 11111111, 10.9944598337 9501385, 11.0002777777 77777778,
+    10.9999860763 98799786, 11.0000006979 29731039, 10.9999999650 15834446,
+    11.0000000017 53603304, 10.9999999999 12099531, 11.0000000000 04406066,
+    ...]
+                        Type: Stream Float
+
+See Also:
+o )help Stream
+o )show ContinuedFraction
+o $AXIOM/doc/src/algebra/contrac.spad.dvi
+
+@
 <<domain CONTFRAC ContinuedFraction>>=
 )abbrev domain CONTFRAC ContinuedFraction
 ++ Author: Stephen M. Watt
diff --git a/src/algebra/cycles.spad.pamphlet b/src/algebra/cycles.spad.pamphlet
index d5747f5..c831683 100644
--- a/src/algebra/cycles.spad.pamphlet
+++ b/src/algebra/cycles.spad.pamphlet
@@ -10,6 +10,913 @@
 \tableofcontents
 \eject
 \section{package CYCLES CycleIndicators}
+<<CycleIndicators.input>>=
+-- cycles.spad.pamphlet CycleIndicators.input
+)spool CycleIndicators.output
+)set message test on
+)set message auto off
+)clear all
+--S 1 of 47
+complete 1
+--R 
+--R
+--R   (1)  (1)
+--R                                   Type: SymmetricPolynomial Fraction 
Integer
+--E 1
+
+--S 2 of 47
+complete 2
+--R 
+--R
+--R        1       1   2
+--R   (2)  - (2) + - (1 )
+--R        2       2
+--R                                   Type: SymmetricPolynomial Fraction 
Integer
+--E 2
+
+--S 3 of 47
+complete 3
+--R 
+--R
+--R        1       1         1   3
+--R   (3)  - (3) + - (2 1) + - (1 )
+--R        3       2         6
+--R                                   Type: SymmetricPolynomial Fraction 
Integer
+--E 3
+
+--S 4 of 47
+complete 7
+--R 
+--R
+--R   (4)
+--R     1       1          1          1     2     1         1            1     
3
+--R     - (7) + - (6 1) + -- (5 2) + -- (5 1 ) + -- (4 3) + - (4 2 1) + -- (4 
1 )
+--R     7       6         10         10          12         8           24
+--R   + 
+--R      1   2      1     2     1       2     1     4     1   3      1   2 3
+--R     -- (3 1) + -- (3 2 ) + -- (3 2 1 ) + -- (3 1 ) + -- (2 1) + -- (2 1 )
+--R     18         24          12            72          48         48
+--R   + 
+--R      1      5      1    7
+--R     --- (2 1 ) + ---- (1 )
+--R     240          5040
+--R                                   Type: SymmetricPolynomial Fraction 
Integer
+--E 4
+
+--S 5 of 47
+elementary 7
+--R 
+--R
+--R   (5)
+--R     1       1          1          1     2     1         1            1     
3
+--R     - (7) - - (6 1) - -- (5 2) + -- (5 1 ) - -- (4 3) + - (4 2 1) - -- (4 
1 )
+--R     7       6         10         10          12         8           24
+--R   + 
+--R      1   2      1     2     1       2     1     4     1   3      1   2 3
+--R     -- (3 1) + -- (3 2 ) - -- (3 2 1 ) + -- (3 1 ) - -- (2 1) + -- (2 1 )
+--R     18         24          12            72          48         48
+--R   + 
+--R        1      5      1    7
+--R     - --- (2 1 ) + ---- (1 )
+--R       240          5040
+--R                                   Type: SymmetricPolynomial Fraction 
Integer
+--E 5
+
+--S 6 of 47
+alternating 7
+--R 
+--R
+--R   (6)
+--R     2       1     2    1           1   2      1     2     1     4     1   
2 3
+--R     - (7) + - (5 1 ) + - (4 2 1) + - (3 1) + -- (3 2 ) + -- (3 1 ) + -- (2 
1 )
+--R     7       5          4           9         12          36          24
+--R   + 
+--R       1    7
+--R     ---- (1 )
+--R     2520
+--R                                   Type: SymmetricPolynomial Fraction 
Integer
+--E 6
+
+--S 7 of 47
+cyclic 7
+--R 
+--R
+--R        6       1   7
+--R   (7)  - (7) + - (1 )
+--R        7       7
+--R                                   Type: SymmetricPolynomial Fraction 
Integer
+--E 7
+
+--S 8 of 47
+dihedral 7
+--R 
+--R
+--R        3       1   3      1   7
+--R   (8)  - (7) + - (2 1) + -- (1 )
+--R        7       2         14
+--R                                   Type: SymmetricPolynomial Fraction 
Integer
+--E 8
+
+--S 9 of 47
+graphs 5
+--R 
+--R
+--R   (9)
+--R   1           1   2    1   2     1   3     1   4 2     1   3 4     1    10
+--R   - (6 3 1) + - (5 ) + - (4 2) + - (3 1) + - (2 1 ) + -- (2 1 ) + --- (1  )
+--R   6           5        4         6         8          12          120
+--R                                   Type: SymmetricPolynomial Fraction 
Integer
+--E 9
+
+--S 10 of 47
+cap(complete 2**2, complete 2*complete 1**2)
+--R 
+--R
+--R   (10)  4
+--R                                                       Type: Fraction 
Integer
+--E 10
+
+--S 11 of 47
+cap(elementary 2**2, complete 2*complete 1**2)
+--R 
+--R
+--R   (11)  2
+--R                                                       Type: Fraction 
Integer
+--E 11
+
+--S 12 of 47
+cap(complete 3*complete 2*complete 1,complete 2**2*complete 1**2)
+--R 
+--R
+--R   (12)  24
+--R                                                       Type: Fraction 
Integer
+--E 12
+
+--S 13 of 47
+cap(elementary 3*elementary 2*elementary 1,complete 2**2*complete 1**2)
+--R 
+--R
+--R   (13)  8
+--R                                                       Type: Fraction 
Integer
+--E 13
+
+--S 14 of 47
+cap(complete 3*complete 2*complete 1,elementary 2**2*elementary 1**2)
+--R 
+--R
+--R   (14)  8
+--R                                                       Type: Fraction 
Integer
+--E 14
+
+--S 15 of 47
+eval(cup(complete 3*complete 2*complete 1, cup(complete 2**2*complete 
1**2,complete 2**3)))
+--R 
+--R
+--R   (15)  1500
+--R                                                       Type: Fraction 
Integer
+--E 15
+
+--S 16 of 47
+square:=dihedral 4
+--R 
+--R
+--R         1       3   2    1     2    1   4
+--R   (16)  - (4) + - (2 ) + - (2 1 ) + - (1 )
+--R         4       8        4          8
+--R                                   Type: SymmetricPolynomial Fraction 
Integer
+--E 16
+
+--S 17 of 47
+cap(complete 2**2,square)
+--R 
+--R
+--R   (17)  2
+--R                                                       Type: Fraction 
Integer
+--E 17
+
+--S 18 of 47
+cap(complete 3*complete 2**2,dihedral 7)
+--R 
+--R
+--R   (18)  18
+--R                                                       Type: Fraction 
Integer
+--E 18
+
+--S 19 of 47
+cap(graphs 5,complete 7*complete 3)
+--R 
+--R
+--R   (19)  4
+--R                                                       Type: Fraction 
Integer
+--E 19
+
+--S 20 of 47
+s(x) == powerSum(x)
+--R 
+--R                                                                   Type: 
Void
+--E 20
+
+--S 21 of 47
+cube:=(1/24)*(s 1**8+9*s 2**4 + 8*s 3**2*s 1**2+6*s 4**2)
+--R 
+--R   Compiling function s with type PositiveInteger -> 
+--R      SymmetricPolynomial Fraction Integer 
+--R
+--R         1   2    1   2 2    3   4     1   8
+--R   (21)  - (4 ) + - (3 1 ) + - (2 ) + -- (1 )
+--R         4        3          8        24
+--R                                   Type: SymmetricPolynomial Fraction 
Integer
+--E 21
+
+--S 22 of 47
+cap(complete 4**2,cube)
+--R 
+--R
+--R   (22)  7
+--R                                                       Type: Fraction 
Integer
+--E 22
+
+--S 23 of 47
+cap(complete 2**3*complete 1**2,wreath(elementary 4,elementary 2))
+--R 
+--R
+--R   (23)  7
+--R                                                       Type: Fraction 
Integer
+--E 23
+
+--S 24 of 47
+cap(complete 2**3*complete 1**2,wreath(elementary 4,complete 2))
+--R 
+--R
+--R   (24)  17
+--R                                                       Type: Fraction 
Integer
+--E 24
+
+--S 25 of 47
+cap(complete 2**3*complete 1**2,wreath(complete 4,elementary 2))
+--R 
+--R
+--R   (25)  10
+--R                                                       Type: Fraction 
Integer
+--E 25
+
+--S 26 of 47
+cap(complete 2**3*complete 1**2,wreath(complete 4,complete 2))
+--R 
+--R
+--R   (26)  23
+--R                                                       Type: Fraction 
Integer
+--E 26
+
+--S 27 of 47
+x: ULS(FRAC INT,'x,0) := 'x 
+--R 
+--R
+--R   (27)  x
+--R                          Type: UnivariateLaurentSeries(Fraction 
Integer,x,0)
+--E 27
+
+--S 28 of 47
+ZeroOrOne: INT -> ULS(FRAC INT, 'x, 0) 
+--R 
+--R                                                                   Type: 
Void
+--E 28
+
+--S 29 of 47
+Integers: INT -> ULS(FRAC INT, 'x, 0) 
+--R 
+--R                                                                   Type: 
Void
+--E 29
+
+--S 30 of 47
+ZeroOrOne n == 1+x**n
+--R 
+--R                                                                   Type: 
Void
+--E 30
+
+--S 31 of 47
+ZeroOrOne 5 
+--R 
+--R   Compiling function ZeroOrOne with type Integer -> 
+--R      UnivariateLaurentSeries(Fraction Integer,x,0) 
+--R
+--R              5
+--R   (31)  1 + x
+--R                          Type: UnivariateLaurentSeries(Fraction 
Integer,x,0)
+--E 31
+
+--S 32 of 47
+Integers n == 1/(1-x**n) 
+--R 
+--R                                                                   Type: 
Void
+--E 32
+
+--S 33 of 47
+Integers 5 
+--R 
+--R   Compiling function Integers with type Integer -> 
+--R      UnivariateLaurentSeries(Fraction Integer,x,0) 
+--R
+--R              5    10      11
+--R   (33)  1 + x  + x   + O(x  )
+--R                          Type: UnivariateLaurentSeries(Fraction 
Integer,x,0)
+--E 33
+
+--S 34 of 47
+)expose EVALCYC
+--R 
+--I   EvaluateCycleIndicators is now explicitly exposed in frame frame0 
+--E 34
+
+--S 35 of 47
+eval(ZeroOrOne, graphs 5) 
+--R 
+--R
+--R                   2     3     4     5     6     7     8    9    10      11
+--R   (34)  1 + x + 2x  + 4x  + 6x  + 6x  + 6x  + 4x  + 2x  + x  + x   + O(x  )
+--R                          Type: UnivariateLaurentSeries(Fraction 
Integer,x,0)
+--E 35
+
+--S 36 of 47
+eval(ZeroOrOne,dihedral 8) 
+--R 
+--R
+--R                   2     3     4     5     6    7    8
+--R   (35)  1 + x + 4x  + 5x  + 8x  + 5x  + 4x  + x  + x
+--R                          Type: UnivariateLaurentSeries(Fraction 
Integer,x,0)
+--E 36
+
+--S 37 of 47
+eval(Integers,complete 4) 
+--R 
+--R
+--R   (36)
+--R             2     3     4     5     6      7      8      9      10      11
+--R   1 + x + 2x  + 3x  + 5x  + 6x  + 9x  + 11x  + 15x  + 18x  + 23x   + O(x  )
+--R                          Type: UnivariateLaurentSeries(Fraction 
Integer,x,0)
+--E 37
+
+--S 38 of 47
+eval(Integers,elementary 4)
+--R 
+--R
+--R   (37)
+--R      6    7     8     9     10     11     12      13      14      15      
16
+--R     x  + x  + 2x  + 3x  + 5x   + 6x   + 9x   + 11x   + 15x   + 18x   + 23x
+--R   + 
+--R        17
+--R     O(x  )
+--R                          Type: UnivariateLaurentSeries(Fraction 
Integer,x,0)
+--E 38
+
+--S 39 of 47
+eval(ZeroOrOne,cube) 
+--R 
+--R
+--R                   2     3     4     5     6    7    8
+--R   (38)  1 + x + 3x  + 3x  + 7x  + 3x  + 3x  + x  + x
+--R                          Type: UnivariateLaurentSeries(Fraction 
Integer,x,0)
+--E 39
+
+--S 40 of 47
+eval(Integers,cube) 
+--R 
+--R
+--R   (39)
+--R               2     3      4      5      6       7       8       9       10
+--R     1 + x + 4x  + 7x  + 21x  + 37x  + 85x  + 151x  + 292x  + 490x  + 848x
+--R   + 
+--R        11
+--R     O(x  )
+--R                          Type: UnivariateLaurentSeries(Fraction 
Integer,x,0)
+--E 40
+
+--S 41 of 47
+eval(Integers,graphs 5) 
+--R 
+--R
+--R   (40)
+--R               2     3      4      5      6       7       8       9       10
+--R     1 + x + 3x  + 7x  + 17x  + 35x  + 76x  + 149x  + 291x  + 539x  + 974x
+--R   + 
+--R        11
+--R     O(x  )
+--R                          Type: UnivariateLaurentSeries(Fraction 
Integer,x,0)
+--E 41
+
+--S 42 of 47
+eval(ZeroOrOne ,graphs 15) 
+--R 
+--R
+--R   (41)
+--R               2     3      4      5      6       7       8        9        
10
+--R     1 + x + 2x  + 5x  + 11x  + 26x  + 68x  + 177x  + 496x  + 1471x  + 4583x
+--R   + 
+--R        11
+--R     O(x  )
+--R                          Type: UnivariateLaurentSeries(Fraction 
Integer,x,0)
+--E 42
+
+--S 43 of 47
+cap(dihedral 30,complete 7*complete 8*complete 5*complete 10)
+--R 
+--R
+--R   (42)  49958972383320
+--R                                                       Type: Fraction 
Integer
+--E 43
+
+--S 44 of 47
+sf3221:= SFunction [3,2,2,1] 
+--R 
+--R
+--R   (43)
+--R      1          1     2     1   2     1            1     4     1   2
+--R     -- (6 2) - -- (6 1 ) - -- (4 ) + -- (4 3 1) + -- (4 1 ) - -- (3 2)
+--R     12         12          16        12           24          36
+--R   + 
+--R      1   2 2     1     2      1       3     1     5     1    4     1   3 2
+--R     -- (3 1 ) - -- (3 2 1) - -- (3 2 1 ) - -- (3 1 ) - --- (2 ) + -- (2 1 )
+--R     36          24           36            72          192        48
+--R   + 
+--R      1   2 4     1      6     1    8
+--R     -- (2 1 ) - --- (2 1 ) + --- (1 )
+--R     96          144          576
+--R                                   Type: SymmetricPolynomial Fraction 
Integer
+--E 44
+
+--S 45 of 47
+cap(sf3221,complete 2**4) 
+--R 
+--R
+--R   (44)  3
+--R                                                       Type: Fraction 
Integer
+--E 45
+
+--S 46 of 47
+cap(sf3221, powerSum 1**8)
+--R 
+--R
+--R   (45)  70
+--R                                                       Type: Fraction 
Integer
+--E 46
+
+--S 47 of 47
+eval(Integers, sf3221)
+--R 
+--R
+--R   (46)
+--R      9     10     11      12      13      14      15       16       17     
  18
+--R     x  + 3x   + 7x   + 14x   + 27x   + 47x   + 79x   + 126x   + 196x   + 
294x
+--R   + 
+--R         19      20
+--R     432x   + O(x  )
+--R                          Type: UnivariateLaurentSeries(Fraction 
Integer,x,0)
+--E 47
+)spool
+)lisp (bye)
+@
+<<CycleIndicators.help>>=
+====================================================================
+\section{CycleIndicators}
+\label{CycleIndicatorsXmpPage}
+
+This section is based upon the paper J. H. Redfield, ``The Theory of
+Group-Reduced Distributions'', American J. Math.,49 (1927) 433-455,
+and is an application of group theory to enumeration problems.  It is
+a development of the work by P. A. MacMahon on the application of
+symmetric functions and Hammond operators to combinatorial theory.
+
+The theory is based upon the power sum symmetric functions s(i) which
+are the sum of the i-th powers of the variables.  The cycle index of a
+permutation is an expression that specifies the sizes of the cycles of
+a permutation, and may be represented as a partition.  A partition of
+a non-negative integer n is a collection of positive integers called
+its parts whose sum is n.  For example, the partition (3^2 2 1^2) will
+be used to represent s^2_3 s_2 s^2_1 and will indicate that the
+permutation has two cycles of length 3, one of length 2 and two of
+length 1.  The cycle index of a permutation group is the sum of the
+cycle indices of its permutations divided by the number of
+permutations.  The cycle indices of certain groups are provided.
+
+The operation complete returns the cycle index of the symmetric group
+of order n for argument n.  Alternatively, it is the n-th complete
+homogeneous symmetric function expressed in terms of power sum
+symmetric functions.
+
+  complete 1
+   (1)
+                      Type: SymmetricPolynomial Fraction Integer
+
+  complete 2
+   1       1   2
+   - (2) + - (1 )
+   2       2
+                      Type: SymmetricPolynomial Fraction Integer
+
+  complete 3
+   1       1         1   3
+   - (3) + - (2 1) + - (1 )
+   3       2         6
+                      Type: SymmetricPolynomial Fraction Integer
+
+  complete 7
+     1       1          1          1     2     1         1            1     3
+     - (7) + - (6 1) + -- (5 2) + -- (5 1 ) + -- (4 3) + - (4 2 1) + -- (4 1 )
+     7       6         10         10          12         8           24
+   + 
+      1   2      1     2     1       2     1     4     1   3      1   2 3
+     -- (3 1) + -- (3 2 ) + -- (3 2 1 ) + -- (3 1 ) + -- (2 1) + -- (2 1 )
+     18         24          12            72          48         48
+   + 
+      1      5      1    7
+     --- (2 1 ) + ---- (1 )
+     240          5040
+                   Type: SymmetricPolynomial Fraction Integer
+
+The operation elementary computes the n-th elementary symmetric
+function for argument n.
+
+  elementary 7
+     1       1          1          1     2     1         1            1     3
+     - (7) - - (6 1) - -- (5 2) + -- (5 1 ) - -- (4 3) + - (4 2 1) - -- (4 1 )
+     7       6         10         10          12         8           24
+   + 
+      1   2      1     2     1       2     1     4     1   3      1   2 3
+     -- (3 1) + -- (3 2 ) - -- (3 2 1 ) + -- (3 1 ) - -- (2 1) + -- (2 1 )
+     18         24          12            72          48         48
+   + 
+        1      5      1    7
+     - --- (2 1 ) + ---- (1 )
+       240          5040
+                  Type: SymmetricPolynomial Fraction Integer
+
+The operation alternating returns the cycle index of the alternating 
+group having an even number of even parts in each cycle partition.
+
+  alternating 7
+     2       1     2    1           1   2      1     2     1     4     1   2 3
+     - (7) + - (5 1 ) + - (4 2 1) + - (3 1) + -- (3 2 ) + -- (3 1 ) + -- (2 1 )
+     7       5          4           9         12          36          24
+   + 
+       1    7
+     ---- (1 )
+     2520
+                  Type: SymmetricPolynomial Fraction Integer
+
+The operation cyclic returns the cycle index of the cyclic group.
+
+  cyclic 7
+   6       1   7
+   - (7) + - (1 )
+   7       7
+                  Type: SymmetricPolynomial Fraction Integer
+
+The operation dihedral is the cycle index of the dihedral group.
+
+  dihedral 7
+   3       1   3      1   7
+   - (7) + - (2 1) + -- (1 )
+   7       2         14
+                  Type: SymmetricPolynomial Fraction Integer
+
+The operation graphs for argument n returns the cycle index of the
+group of permutations on the edges of the complete graph with n nodes
+induced by applying the symmetric group to the nodes.
+
+  graphs 5
+   1           1   2    1   2     1   3     1   4 2     1   3 4     1    10
+   - (6 3 1) + - (5 ) + - (4 2) + - (3 1) + - (2 1 ) + -- (2 1 ) + --- (1  )
+   6           5        4         6         8          12          120
+                  Type: SymmetricPolynomial Fraction Integer
+
+The cycle index of a direct product of two groups is the product of
+the cycle indices of the groups.  Redfield provided two operations on
+two cycle indices which will be called "cup" and "cap" here.  The cup
+of two cycle indices is a kind of scalar product that combines
+monomials for permutations with the same cycles.  The cap operation
+provides the sum of the coefficients of the result of the cup
+operation which will be an integer that enumerates what Redfield
+called group-reduced distributions.
+
+We can, for example, represent complete 2 * complete 2 as the set of
+objects a a b b and complete 2 * complete 1 * complete 1 as c c d e.
+
+This integer is the number of different sets of four pairs.
+
+  cap(complete 2**2, complete 2*complete 1**2)
+    4
+                  Type: Fraction Integer
+
+For example,
+  a a b b     a a b b    a a b b   a a b b
+  c c d e     c d c e    c e c d   d e c c
+
+This integer is the number of different sets of four pairs no two
+pairs being equal.
+
+  cap(elementary 2**2, complete 2*complete 1**2)
+    2
+                  Type: Fraction Integer
+
+For example,
+
+  a a b b    a a b b
+  c d c e    c e c d
+
+In this case the configurations enumerated are easily constructed,
+however the theory merely enumerates them providing little help in
+actually constructing them.
+
+Here are the number of 6-pairs, first from a a a b b c, second
+from d d e e f g.
+
+  cap(complete 3*complete 2*complete 1,complete 2**2*complete 1**2)
+    24
+                     Type: Fraction Integer
+
+Here it is again, but with no equal pairs.
+
+  cap(elementary 3*elementary 2*elementary 1,complete 2**2*complete 1**2)
+    8
+                     Type: Fraction Integer
+
+  cap(complete 3*complete 2*complete 1,elementary 2**2*elementary 1**2)
+    8
+                     Type: Fraction Integer
+
+The number of 6-triples, first from a a a b b c, second from
+d d e e f g, third from h h i i j j.
+
+  eval(cup(complete 3*complete 2*complete 1, cup(complete 2**2*complete 
1**2,complete 2**3)))
+    1500
+                     Type: Fraction Integer
+
+The cycle index of vertices of a square is dihedral 4.
+
+  square:=dihedral 4
+   1       3   2    1     2    1   4
+   - (4) + - (2 ) + - (2 1 ) + - (1 )
+   4       8        4          8
+                     Type: SymmetricPolynomial Fraction Integer
+
+The number of different squares with 2 red vertices and 2 blue vertices.
+
+  cap(complete 2**2,square)
+    2
+                     Type: Fraction Integer
+
+The number of necklaces with 3 red beads, 2 blue beads and 2 green beads.
+
+  cap(complete 3*complete 2**2,dihedral 7)
+    18
+                     Type: Fraction Integer
+
+The number of graphs with 5 nodes and 7 edges.
+
+  cap(graphs 5,complete 7*complete 3)
+    4
+                     Type: Fraction Integer
+
+The cycle index of rotations of vertices of a cube.
+
+  s(x) == powerSum(x)
+                     Type: Void
+
+  cube:=(1/24)*(s 1**8+9*s 2**4 + 8*s 3**2*s 1**2+6*s 4**2)
+   1   2    1   2 2    3   4     1   8
+   - (4 ) + - (3 1 ) + - (2 ) + -- (1 )
+   4        3          8        24
+                     Type: SymmetricPolynomial Fraction Integer
+
+The number of cubes with 4 red vertices and 4 blue vertices.
+
+  cap(complete 4**2,cube)
+    7
+                     Type: Fraction Integer
+
+The number of labeled graphs with degree sequence 2 2 2 1 1 with no 
+loops or multiple edges.
+
+  cap(complete 2**3*complete 1**2,wreath(elementary 4,elementary 2))
+    7
+                     Type: Fraction Integer
+
+Again, but with loops allowed but not multiple edges.
+
+  cap(complete 2**3*complete 1**2,wreath(elementary 4,complete 2))
+    17
+                     Type: Fraction Integer
+
+Again, but with multiple edges allowed, but not loops
+
+  cap(complete 2**3*complete 1**2,wreath(complete 4,elementary 2))
+    10
+                     Type: Fraction Integer
+
+Again, but with both multiple edges and loops allowed
+
+  cap(complete 2**3*complete 1**2,wreath(complete 4,complete 2))
+    23
+                     Type: Fraction Integer
+
+Having constructed a cycle index for a configuration we are at liberty
+to evaluate the s_i components any way we please.  For example we can
+produce enumerating generating functions.  This is done by providing a
+function f on an integer i to the value required of s_i, and then
+evaluating eval(f, cycleindex).
+
+  x: ULS(FRAC INT,'x,0) := 'x 
+   x
+                     Type: UnivariateLaurentSeries(Fraction Integer,x,0)
+
+  ZeroOrOne: INT -> ULS(FRAC INT, 'x, 0) 
+                     Type: Void
+
+  Integers: INT -> ULS(FRAC INT, 'x, 0) 
+                     Type: Void
+
+For the integers 0 and 1, or two colors.
+
+  ZeroOrOne n == 1+x**n
+                     Type: Void
+
+  ZeroOrOne 5 
+         5
+    1 + x
+                     Type: UnivariateLaurentSeries(Fraction Integer,x,0)
+
+For the integers 0, 1, 2, ... we have this.
+
+  Integers n == 1/(1-x**n) 
+                     Type: Void
+
+  Integers 5 
+         5    10      11
+    1 + x  + x   + O(x  )
+                     Type: UnivariateLaurentSeries(Fraction Integer,x,0)
+
+The coefficient of x^n is the number of graphs with 5 nodes and n edges. 
+
+Note that there is an eval function that takes two arguments. It has the 
+signature:
+
+  ((Integer -> D1),SymmetricPolynomial Fraction Integer) -> D1
+    from EvaluateCycleIndicators D1 if D1 has ALGEBRA FRAC INT
+
+This function is not normally exposed (it will not normally be considered
+in the list of eval functions) as it is only useful for this particular
+domain. To use it we ask that it be considered thus:
+
+  )expose EVALCYC
+
+and now we can use it:
+
+  eval(ZeroOrOne, graphs 5) 
+              2     3     4     5     6     7     8    9    10      11
+    1 + x + 2x  + 4x  + 6x  + 6x  + 6x  + 4x  + 2x  + x  + x   + O(x  )
+                     Type: UnivariateLaurentSeries(Fraction Integer,x,0)
+
+The coefficient of x^n is the number of necklaces with n red beads 
+and n-8 green beads.
+
+  eval(ZeroOrOne,dihedral 8) 
+              2     3     4     5     6    7    8
+    1 + x + 4x  + 5x  + 8x  + 5x  + 4x  + x  + x
+                     Type: UnivariateLaurentSeries(Fraction Integer,x,0)
+
+The coefficient of x^n is the number of partitions of n into 4 or fewer parts.
+
+  eval(Integers,complete 4) 
+             2     3     4     5     6      7      8      9      10      11
+   1 + x + 2x  + 3x  + 5x  + 6x  + 9x  + 11x  + 15x  + 18x  + 23x   + O(x  )
+                     Type: UnivariateLaurentSeries(Fraction Integer,x,0)
+
+The coefficient of x^n is the number of partitions of n into 4 boxes
+containing ordered distinct parts.
+
+  eval(Integers,elementary 4)
+      6    7     8     9     10     11     12      13      14      15      16
+     x  + x  + 2x  + 3x  + 5x   + 6x   + 9x   + 11x   + 15x   + 18x   + 23x
+   + 
+        17
+     O(x  )
+                     Type: UnivariateLaurentSeries(Fraction Integer,x,0)
+
+The coefficient of x^n is the number of different cubes with n red
+vertices and 8-n green ones.
+
+  eval(ZeroOrOne,cube) 
+              2     3     4     5     6    7    8
+    1 + x + 3x  + 3x  + 7x  + 3x  + 3x  + x  + x
+                     Type: UnivariateLaurentSeries(Fraction Integer,x,0)
+
+The coefficient of x^n is the number of different cubes with integers
+on the vertices whose sum is n.
+
+  eval(Integers,cube) 
+               2     3      4      5      6       7       8       9       10
+     1 + x + 4x  + 7x  + 21x  + 37x  + 85x  + 151x  + 292x  + 490x  + 848x
+   + 
+        11
+     O(x  )
+                          Type: UnivariateLaurentSeries(Fraction Integer,x,0)
+
+The coefficient of x^n is the number of graphs with 5 nodes and with
+integers on the edges whose sum is n.  In other words, the enumeration
+is of multigraphs with 5 nodes and n edges.
+
+  eval(Integers,graphs 5) 
+               2     3      4      5      6       7       8       9       10
+     1 + x + 3x  + 7x  + 17x  + 35x  + 76x  + 149x  + 291x  + 539x  + 974x
+   + 
+        11
+     O(x  )
+                     Type: UnivariateLaurentSeries(Fraction Integer,x,0)
+
+Graphs with 15 nodes enumerated with respect to number of edges.
+
+  eval(ZeroOrOne ,graphs 15) 
+               2     3      4      5      6       7       8        9        10
+     1 + x + 2x  + 5x  + 11x  + 26x  + 68x  + 177x  + 496x  + 1471x  + 4583x
+   + 
+        11
+     O(x  )
+                     Type: UnivariateLaurentSeries(Fraction Integer,x,0)
+
+Necklaces with 7 green beads, 8 white beads, 5 yellow beads and 10
+red beads.
+
+  cap(dihedral 30,complete 7*complete 8*complete 5*complete 10)
+    49958972383320
+                     Type: Fraction Integer
+
+The operation SFunction is the S-function or Schur function of a
+partition written as a descending list of integers expressed in terms
+of power sum symmetric functions.
+
+In this case the argument partition represents a tableau shape.  For
+example 3,2,2,1 represents a tableau with three boxes in the first
+row, two boxes in the second and third rows, and one box in the fourth
+row.  SFunction [3,2,2,1] counts the number of different tableaux of
+shape 3, 2, 2, 1 filled with objects with an ascending order in the
+columns and a non-descending order in the rows.
+
+  sf3221:= SFunction [3,2,2,1] 
+      1          1     2     1   2     1            1     4     1   2
+     -- (6 2) - -- (6 1 ) - -- (4 ) + -- (4 3 1) + -- (4 1 ) - -- (3 2)
+     12         12          16        12           24          36
+   + 
+      1   2 2     1     2      1       3     1     5     1    4     1   3 2
+     -- (3 1 ) - -- (3 2 1) - -- (3 2 1 ) - -- (3 1 ) - --- (2 ) + -- (2 1 )
+     36          24           36            72          192        48
+   + 
+      1   2 4     1      6     1    8
+     -- (2 1 ) - --- (2 1 ) + --- (1 )
+     96          144          576
+                     Type: SymmetricPolynomial Fraction Integer
+
+This is the number filled with a a b b c c d d.
+
+  cap(sf3221,complete 2**4) 
+    3
+                     Type: Fraction Integer
+
+The configurations enumerated above are:
+
+  a a b    a a c    a a d
+  b c      b b      b b
+  c d      c d      c c
+  d        d        d
+
+This is the number of tableaux filled with 1..8.
+
+  cap(sf3221, powerSum 1**8)
+    70
+                     Type: Fraction Integer
+
+The coefficient of x^n is the number of column strict reverse plane
+partitions of n of shape 3 2 2 1.
+
+  eval(Integers, sf3221)
+      9     10     11      12      13      14      15       16       17
+     x  + 3x   + 7x   + 14x   + 27x   + 47x   + 79x   + 126x   + 196x  
+   + 
+        18      19      20
+    294x  + 432x   + O(x  )
+                          Type: UnivariateLaurentSeries(Fraction Integer,x,0)
+
+The smallest is
+
+  0 0 0
+  1 1
+  2 2
+  3
+
+See Also:
+o )show CycleIndicators
+o $AXIOM/doc/src/algebra/cycles.spad.dvi
+
+@
 <<package CYCLES CycleIndicators>>=
 )abbrev package CYCLES CycleIndicators
 ++ Polya-Redfield enumeration by cycle indices.
diff --git a/src/algebra/derham.spad.pamphlet b/src/algebra/derham.spad.pamphlet
index eb06ae8..47d2db1 100644
--- a/src/algebra/derham.spad.pamphlet
+++ b/src/algebra/derham.spad.pamphlet
@@ -307,6 +307,584 @@ AntiSymm(R:Ring, lVar:List Symbol): Export == Implement 
where
 
 @
 \section{domain DERHAM DeRhamComplex}
+<<DeRhamComplex.input>>=
+-- derham.spad.pamphlet DeRhamComplex.input
+)spool DeRhamComplex.output
+)set message test on
+)set message auto off
+)clear all
+--S 1 of 34
+coefRing := Integer
+--R 
+--R
+--R   (1)  Integer
+--R                                                                 Type: 
Domain
+--E 1
+
+--S 2 of 34
+lv : List Symbol := [x,y,z] 
+--R 
+--R
+--R   (2)  [x,y,z]
+--R                                                            Type: List 
Symbol
+--E 2
+
+--S 3 of 34
+der := DERHAM(coefRing,lv) 
+--R 
+--R
+--R   (3)  DeRhamComplex(Integer,[x,y,z])
+--R                                                                 Type: 
Domain
+--E 3
+
+--S 4 of 34
+R := Expression coefRing
+--R 
+--R
+--R   (4)  Expression Integer
+--R                                                                 Type: 
Domain
+--E 4
+
+--S 5 of 34
+f : R := x**2*y*z-5*x**3*y**2*z**5
+--R 
+--R
+--R            3 2 5    2
+--R   (5)  - 5x y z  + x y z
+--R                                                     Type: Expression 
Integer
+--E 5
+
+--S 6 of 34
+g : R := z**2*y*cos(z)-7*sin(x**3*y**2)*z**2 
+--R 
+--R
+--R            2     3 2       2
+--R   (6)  - 7z sin(x y ) + y z cos(z)
+--R                                                     Type: Expression 
Integer
+--E 6
+
+--S 7 of 34
+h : R :=x*y*z-2*x**3*y*z**2 
+--R 
+--R
+--R            3   2
+--R   (7)  - 2x y z  + x y z
+--R                                                     Type: Expression 
Integer
+--E 7
+
+--S 8 of 34
+dx : der := generator(1)
+--R 
+--R
+--R   (8)  dx
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 8
+
+--S 9 of 34
+dy : der := generator(2)
+--R 
+--R
+--R   (9)  dy
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 9
+
+--S 10 of 34
+dz : der := generator(3)
+--R 
+--R
+--R   (10)  dz
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 10
+
+--S 11 of 34
+[dx,dy,dz] := [generator(i)$der for i in 1..3]
+--R 
+--R
+--R   (11)  [dx,dy,dz]
+--R                                    Type: List 
DeRhamComplex(Integer,[x,y,z])
+--E 11
+
+--S 12 of 34
+alpha : der := f*dx + g*dy + h*dz
+--R 
+--R
+--R   (12)
+--R          3   2                   2     3 2       2
+--R     (- 2x y z  + x y z)dz + (- 7z sin(x y ) + y z cos(z))dy
+--R   + 
+--R          3 2 5    2
+--R     (- 5x y z  + x y z)dx
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 12
+
+--S 13 of 34
+beta  : der := cos(tan(x*y*z)+x*y*z)*dx + x*dy
+--R 
+--R
+--R   (13)  x dy + cos(tan(x y z) + x y z)dx
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 13
+
+--S 14 of 34
+exteriorDifferential alpha
+--R 
+--R
+--R   (14)
+--R         2                  3 2                    3 2
+--R     (y z sin(z) + 14z sin(x y ) - 2y z cos(z) - 2x z  + x z)dy dz
+--R   + 
+--R         3 2 4     2   2          2
+--R     (25x y z  - 6x y z  + y z - x y)dx dz
+--R   + 
+--R           2 2 2     3 2       3   5    2
+--R     (- 21x y z cos(x y ) + 10x y z  - x z)dx dy
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 14
+
+--S 15 of 34
+exteriorDifferential %
+--R 
+--R
+--R   (15)  0
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 15
+
+--S 16 of 34
+gamma := alpha * beta
+--R 
+--R
+--R   (16)
+--R        4   2    2               3   2
+--R     (2x y z  - x y z)dy dz + (2x y z  - x y z)cos(tan(x y z) + x y z)dx dz
+--R   + 
+--R       2     3 2       2                                   4 2 5    3
+--R   ((7z sin(x y ) - y z cos(z))cos(tan(x y z) + x y z) - 5x y z  + x y z)dx 
dy
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 16
+
+--S 17 of 34
+exteriorDifferential(gamma) - (exteriorDifferential(alpha)*beta - alpha * 
exteriorDifferential(beta)) 
+--R 
+--R
+--R   (17)  0
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 17
+
+--S 18 of 34
+a : BOP := operator('a)
+--R 
+--R
+--R   (18)  a
+--R                                                          Type: 
BasicOperator
+--E 18
+
+--S 19 of 34
+b : BOP := operator('b)
+--R 
+--R
+--R   (19)  b
+--R                                                          Type: 
BasicOperator
+--E 19
+
+--S 20 of 34
+c : BOP := operator('c)
+--R 
+--R
+--R   (20)  c
+--R                                                          Type: 
BasicOperator
+--E 20
+
+--S 21 of 34
+sigma := a(x,y,z) * dx + b(x,y,z) * dy + c(x,y,z) * dz 
+--R 
+--R
+--R   (21)  c(x,y,z)dz + b(x,y,z)dy + a(x,y,z)dx
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 21
+
+--S 22 of 34
+theta  := a(x,y,z) * dx * dy + b(x,y,z) * dx * dz + c(x,y,z) * dy * dz 
+--R 
+--R
+--R   (22)  c(x,y,z)dy dz + b(x,y,z)dx dz + a(x,y,z)dx dy
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 22
+
+--S 23 of 34
+totalDifferential(a(x,y,z))$der 
+--R 
+--R
+--R   (23)  a  (x,y,z)dz + a  (x,y,z)dy + a  (x,y,z)dx
+--R          ,3             ,2             ,1
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 23
+
+--S 24 of 34
+exteriorDifferential sigma
+--R 
+--R
+--R   (24)
+--R     (c  (x,y,z) - b  (x,y,z))dy dz + (c  (x,y,z) - a  (x,y,z))dx dz
+--R       ,2           ,3                  ,1           ,3
+--R   + 
+--R     (b  (x,y,z) - a  (x,y,z))dx dy
+--R       ,1           ,2
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 24
+
+--S 25 of 34
+exteriorDifferential theta
+--R 
+--R
+--R   (25)  (c  (x,y,z) - b  (x,y,z) + a  (x,y,z))dx dy dz
+--R           ,1           ,2           ,3
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 25
+
+--S 26 of 34
+one : der := 1
+--R 
+--R
+--R   (26)  1
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 26
+
+--S 27 of 34
+g1 : der := a([x,t,y,u,v,z,e]) * one 
+--R 
+--R
+--R   (27)  a(x,t,y,u,v,z,e)
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 27
+
+--S 28 of 34
+h1 : der := a([x,y,x,t,x,z,y,r,u,x]) * one 
+--R 
+--R
+--R   (28)  a(x,y,x,t,x,z,y,r,u,x)
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 28
+
+--S 29 of 34
+exteriorDifferential g1 
+--R 
+--R
+--R   (29)  a  (x,t,y,u,v,z,e)dz + a  (x,t,y,u,v,z,e)dy + a  (x,t,y,u,v,z,e)dx
+--R          ,6                     ,3                     ,1
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 29
+
+--S 30 of 34
+exteriorDifferential h1
+--R 
+--R
+--R   (30)
+--R     a  (x,y,x,t,x,z,y,r,u,x)dz
+--R      ,6
+--R   + 
+--R     (a  (x,y,x,t,x,z,y,r,u,x) + a  (x,y,x,t,x,z,y,r,u,x))dy
+--R       ,7                         ,2
+--R   + 
+--R         a   (x,y,x,t,x,z,y,r,u,x) + a  (x,y,x,t,x,z,y,r,u,x)
+--R          ,10                         ,5
+--R       + 
+--R         a  (x,y,x,t,x,z,y,r,u,x) + a  (x,y,x,t,x,z,y,r,u,x)
+--R          ,3                         ,1
+--R    *
+--R       dx
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 30
+
+--S 31 of 34
+coefficient(gamma, dx*dy)
+--R 
+--R
+--R            2     3 2       2                                   4 2 5    3
+--R   (31)  (7z sin(x y ) - y z cos(z))cos(tan(x y z) + x y z) - 5x y z  + x y 
z
+--R                                                     Type: Expression 
Integer
+--E 31
+
+--S 32 of 34
+coefficient(gamma, one)
+--R 
+--R
+--R   (32)  0
+--R                                                     Type: Expression 
Integer
+--E 32
+
+--S 33 of 34
+coefficient(g1,one)
+--R 
+--R
+--R   (33)  a(x,t,y,u,v,z,e)
+--R                                                     Type: Expression 
Integer
+--E 33
+
+--S 34 of 34
+gamma := alpha * beta
+--R 
+--R
+--R   (34)
+--R        4   2    2               3   2
+--R     (2x y z  - x y z)dy dz + (2x y z  - x y z)cos(tan(x y z) + x y z)dx dz
+--R   + 
+--R       2     3 2       2                                   4 2 5    3
+--R   ((7z sin(x y ) - y z cos(z))cos(tan(x y z) + x y z) - 5x y z  + x y z)dx 
dy
+--R                                         Type: 
DeRhamComplex(Integer,[x,y,z])
+--E 34
+)spool
+)lisp (bye)
+@
+<<DeRhamComplex.help>>=
+====================================================================
+DeRhamComplex
+====================================================================
+
+The domain constructor DeRhamComplex creates the class of differential
+forms of arbitrary degree over a coefficient ring.  The De Rham
+complex constructor takes two arguments: a ring, coefRing, and a list
+of coordinate variables.
+
+This is the ring of coefficients.
+
+  coefRing := Integer
+   Integer
+                      Type: Domain
+
+These are the coordinate variables.
+
+  lv : List Symbol := [x,y,z] 
+   [x,y,z]
+                      Type: List Symbol
+
+
+This is the De Rham complex of Euclidean three-space using coordinates
+x, y and z.
+
+  der := DERHAM(coefRing,lv) 
+   DeRhamComplex(Integer,[x,y,z])
+                      Type: Domain
+
+This complex allows us to describe differential forms having
+expressions of integers as coefficients.  These coefficients can
+involve any number of variables, for example, f(x,t,r,y,u,z).  As
+we've chosen to work with ordinary Euclidean three-space, expressions
+involving these forms are treated as functions of x, y and z with the
+additional arguments t, r and u regarded as symbolic constants.
+
+Here are some examples of coefficients.
+
+  R := Expression coefRing
+   Expression Integer
+                     Type: Domain
+
+  f : R := x**2*y*z-5*x**3*y**2*z**5
+       3 2 5    2
+   - 5x y z  + x y z
+                     Type: Expression Integer
+
+  g : R := z**2*y*cos(z)-7*sin(x**3*y**2)*z**2 
+       2     3 2       2
+   - 7z sin(x y ) + y z cos(z)
+                     Type: Expression Integer
+
+  h : R :=x*y*z-2*x**3*y*z**2 
+       3   2
+   - 2x y z  + x y z
+                     Type: Expression Integer
+
+We now define the multiplicative basis elements for the exterior
+algebra over R.
+
+  dx : der := generator(1)
+   dx
+                     Type: DeRhamComplex(Integer,[x,y,z])
+
+  dy : der := generator(2)
+   dy
+                     Type: DeRhamComplex(Integer,[x,y,z])
+
+  dz : der := generator(3)
+   dz
+                     Type: DeRhamComplex(Integer,[x,y,z])
+
+This is an alternative way to give the above assignments.
+
+  [dx,dy,dz] := [generator(i)$der for i in 1..3]
+    [dx,dy,dz]
+                     Type: List DeRhamComplex(Integer,[x,y,z])
+
+Now we define some one-forms.
+
+  alpha : der := f*dx + g*dy + h*dz
+          3   2                   2     3 2       2
+     (- 2x y z  + x y z)dz + (- 7z sin(x y ) + y z cos(z))dy
+   + 
+          3 2 5    2
+     (- 5x y z  + x y z)dx
+                     Type: DeRhamComplex(Integer,[x,y,z])
+
+  beta  : der := cos(tan(x*y*z)+x*y*z)*dx + x*dy
+    x dy + cos(tan(x y z) + x y z)dx
+                     Type: DeRhamComplex(Integer,[x,y,z])
+
+A well-known theorem states that the composition of exteriorDifferential 
+with itself is the zero map for continuous forms. Let's verify this 
+theorem for alpha.
+
+  exteriorDifferential alpha
+         2                  3 2                    3 2
+     (y z sin(z) + 14z sin(x y ) - 2y z cos(z) - 2x z  + x z)dy dz
+   + 
+         3 2 4     2   2          2
+     (25x y z  - 6x y z  + y z - x y)dx dz
+   + 
+           2 2 2     3 2       3   5    2
+     (- 21x y z cos(x y ) + 10x y z  - x z)dx dy
+                      Type: DeRhamComplex(Integer,[x,y,z])
+
+We see a lengthy output of the last expression, but nevertheless, the
+composition is zero.
+
+  exteriorDifferential %
+    0
+                      Type: DeRhamComplex(Integer,[x,y,z])
+
+Now we check that exteriorDifferential is a "graded derivation" D,
+that is, D satisfies:
+
+  D(a*b) = D(a)*b + (-1)**degree(a)*a*D(b)
+
+  gamma := alpha * beta
+        4   2    2               3   2
+     (2x y z  - x y z)dy dz + (2x y z  - x y z)cos(tan(x y z) + x y z)dx dz
+   + 
+       2     3 2       2                                   4 2 5    3
+   ((7z sin(x y ) - y z cos(z))cos(tan(x y z) + x y z) - 5x y z  + x y z)dx dy
+                      Type: DeRhamComplex(Integer,[x,y,z])
+
+We try this for the one-forms alpha and beta.
+
+  exteriorDifferential(gamma) - (exteriorDifferential(alpha)*beta - alpha * 
exteriorDifferential(beta)) 
+    0
+                      Type: DeRhamComplex(Integer,[x,y,z])
+
+Now we define some "basic operators"
+
+  a : BOP := operator('a)
+    a
+                      Type: BasicOperator
+
+  b : BOP := operator('b)
+    b
+                      Type: BasicOperator
+
+  c : BOP := operator('c)
+    c
+                      Type: BasicOperator
+
+We also define some indeterminate one- and two-forms using these
+operators.
+
+  sigma := a(x,y,z) * dx + b(x,y,z) * dy + c(x,y,z) * dz 
+    c(x,y,z)dz + b(x,y,z)dy + a(x,y,z)dx
+                      Type: DeRhamComplex(Integer,[x,y,z])
+
+  theta  := a(x,y,z) * dx * dy + b(x,y,z) * dx * dz + c(x,y,z) * dy * dz 
+    c(x,y,z)dy dz + b(x,y,z)dx dz + a(x,y,z)dx dy
+                      Type: DeRhamComplex(Integer,[x,y,z])
+
+This allows us to get formal definitions for the "gradient" ...
+
+  totalDifferential(a(x,y,z))$der 
+   (23)  a  (x,y,z)dz + a  (x,y,z)dy + a  (x,y,z)dx
+          ,3             ,2             ,1
+                      Type: DeRhamComplex(Integer,[x,y,z])
+the "curl" ...
+
+  exteriorDifferential sigma
+     (c  (x,y,z) - b  (x,y,z))dy dz + (c  (x,y,z) - a  (x,y,z))dx dz
+       ,2           ,3                  ,1           ,3
+   + 
+     (b  (x,y,z) - a  (x,y,z))dx dy
+       ,1           ,2
+                       Type: DeRhamComplex(Integer,[x,y,z])
+
+and the "divergence."
+
+  exteriorDifferential theta
+    (c  (x,y,z) - b  (x,y,z) + a  (x,y,z))dx dy dz
+      ,1           ,2           ,3
+                       Type: DeRhamComplex(Integer,[x,y,z])
+
+Note that the De Rham complex is an algebra with unity.  This element
+1 is the basis for elements for zero-forms, that is, functions in our
+space.
+
+  one : der := 1
+    1
+                       Type: DeRhamComplex(Integer,[x,y,z])
+
+To convert a function to a function lying in the De Rham complex,
+multiply the function by "one."
+
+  g1 : der := a([x,t,y,u,v,z,e]) * one 
+    a(x,t,y,u,v,z,e)
+                       Type: DeRhamComplex(Integer,[x,y,z])
+
+A current limitation of Axiom forces you to write functions with more
+than four arguments using square brackets in this way.
+
+  h1 : der := a([x,y,x,t,x,z,y,r,u,x]) * one 
+    a(x,y,x,t,x,z,y,r,u,x)
+                        Type: DeRhamComplex(Integer,[x,y,z])
+
+Now note how the system keeps track of where your coordinate functions
+are located in expressions.
+
+  exteriorDifferential g1 
+    a  (x,t,y,u,v,z,e)dz + a  (x,t,y,u,v,z,e)dy + a  (x,t,y,u,v,z,e)dx
+     ,6                     ,3                     ,1
+                        Type: DeRhamComplex(Integer,[x,y,z])
+
+  exteriorDifferential h1
+     a  (x,y,x,t,x,z,y,r,u,x)dz
+      ,6
+   + 
+     (a  (x,y,x,t,x,z,y,r,u,x) + a  (x,y,x,t,x,z,y,r,u,x))dy
+       ,7                         ,2
+   + 
+         a   (x,y,x,t,x,z,y,r,u,x) + a  (x,y,x,t,x,z,y,r,u,x)
+          ,10                         ,5
+       + 
+         a  (x,y,x,t,x,z,y,r,u,x) + a  (x,y,x,t,x,z,y,r,u,x)
+          ,3                         ,1
+    *
+       dx
+                       Type: DeRhamComplex(Integer,[x,y,z])
+
+In this example of Euclidean three-space, the basis for the De Rham complex
+consists of the eight forms: 1, dx, dy, dz, dx*dy, dx*dz, dy*dz, and dx*dy*dz.
+
+  coefficient(gamma, dx*dy)
+       2     3 2       2                                   4 2 5    3
+    (7z sin(x y ) - y z cos(z))cos(tan(x y z) + x y z) - 5x y z  + x y z
+                       Type: Expression Integer
+
+  coefficient(gamma, one)
+    0
+                       Type: Expression Integer
+
+  coefficient(g1,one)
+    a(x,t,y,u,v,z,e)
+                       Type: Expression Integer
+
+See Also:
+o )help Operator
+o )show DeRhamComplex
+o $AXIOM/doc/src/algebra/derham.spad.dvi
+
+@
 <<domain DERHAM DeRhamComplex>>=
 )abbrev domain DERHAM DeRhamComplex
 ++ Author: Larry A. Lambe
diff --git a/src/algebra/gaussian.spad.pamphlet 
b/src/algebra/gaussian.spad.pamphlet
index ccbd072..744488b 100644
--- a/src/algebra/gaussian.spad.pamphlet
+++ b/src/algebra/gaussian.spad.pamphlet
@@ -529,6 +529,286 @@ ComplexPatternMatch(R, S, CS) : C == T where
 
 @
 \section{domain COMPLEX Complex}
+<<Complex.input>>=
+-- gaussian.spad.pamphlet Complex.input
+)spool Complex.output
+)set message test on
+)set message auto off
+)clear all
+--S 1 of 16
+a := complex(4/3,5/2)
+--R 
+--R
+--R        4   5
+--R   (1)  - + - %i
+--R        3   2
+--R                                               Type: Complex Fraction 
Integer
+--E 1
+
+--S 2 of 16
+b := complex(4/3,-5/2)
+--R 
+--R
+--R        4   5
+--R   (2)  - - - %i
+--R        3   2
+--R                                               Type: Complex Fraction 
Integer
+--E 2
+
+--S 3 of 16
+a + b
+--R 
+--R
+--R        8
+--R   (3)  -
+--R        3
+--R                                               Type: Complex Fraction 
Integer
+--E 3
+
+--S 4 of 16
+a - b
+--R 
+--R
+--R   (4)  5%i
+--R                                               Type: Complex Fraction 
Integer
+--E 4
+
+--S 5 of 16
+a * b
+--R 
+--R
+--R        289
+--R   (5)  ---
+--R         36
+--R                                               Type: Complex Fraction 
Integer
+--E 5
+
+--S 6 of 16
+a / b
+--R 
+--R
+--R          161   240
+--R   (6)  - --- + --- %i
+--R          289   289
+--R                                               Type: Complex Fraction 
Integer
+--E 6
+
+--S 7 of 16
+% :: Fraction Complex Integer
+--R 
+--R
+--R        - 15 + 8%i
+--R   (7)  ----------
+--R         15 + 8%i
+--R                                               Type: Fraction Complex 
Integer
+--E 7
+
+--S 8 of 16
+3.4 + 6.7 * %i
+--R 
+--R
+--R   (8)  3.4 + 6.7 %i
+--R                                                          Type: Complex 
Float
+--E 8
+
+--S 9 of 16
+conjugate a
+--R 
+--R
+--R        4   5
+--R   (9)  - - - %i
+--R        3   2
+--R                                               Type: Complex Fraction 
Integer
+--E 9
+
+--S 10 of 16
+norm a
+--R 
+--R
+--R         289
+--R   (10)  ---
+--R          36
+--R                                                       Type: Fraction 
Integer
+--E 10
+
+--S 11 of 16
+real a
+--R 
+--R
+--R         4
+--R   (11)  -
+--R         3
+--R                                                       Type: Fraction 
Integer
+--E 11
+
+--S 12 of 16
+imag a
+--R 
+--R
+--R         5
+--R   (12)  -
+--R         2
+--R                                                       Type: Fraction 
Integer
+--E 12
+
+--S 13 of 16
+gcd(13 - 13*%i,31 + 27*%i)
+--R 
+--R
+--R   (13)  5 + %i
+--R                                                        Type: Complex 
Integer
+--E 13
+
+--S 14 of 16
+lcm(13 - 13*%i,31 + 27*%i)
+--R 
+--R
+--R   (14)  143 - 39%i
+--R                                                        Type: Complex 
Integer
+--E 14
+
+--S 15 of 16
+factor(13 - 13*%i)
+--R 
+--R
+--R   (15)  - (1 + %i)(2 + 3%i)(3 + 2%i)
+--R                                               Type: Factored Complex 
Integer
+--E 15
+
+--S 16 of 16
+factor complex(2,0)
+--R 
+--R
+--R                      2
+--R   (16)  - %i (1 + %i)
+--R                                               Type: Factored Complex 
Integer
+--E 16
+)spool
+)lisp (bye)
+@
+<<Complex.help>>=
+====================================================================
+Complex
+====================================================================
+
+The Complex constructor implements complex objects over a commutative
+ring R.  Typically, the ring R is Integer, Fraction Integer, Float or
+DoubleFloat.  R can also be a symbolic type, like Polynomial Integer.
+
+Complex objects are created by the complex operation.
+
+  a := complex(4/3,5/2)
+   4   5
+   - + - %i
+   3   2
+                        Type: Complex Fraction Integer
+
+  b := complex(4/3,-5/2)
+   4   5
+   - - - %i
+   3   2
+                        Type: Complex Fraction Integer
+
+The standard arithmetic operations are available.
+
+  a + b
+   8
+   -
+   3
+                        Type: Complex Fraction Integer
+
+  a - b
+   5%i
+                        Type: Complex Fraction Integer
+
+  a * b
+   289
+   ---
+    36
+                        Type: Complex Fraction Integer
+
+If  R is a field, you can also divide the complex objects.
+
+  a / b
+     161   240
+   - --- + --- %i
+     289   289
+                        Type: Complex Fraction Integer
+
+
+We can view the last object as a fraction of complex integers.
+
+  % :: Fraction Complex Integer
+   - 15 + 8%i
+   ----------
+     15 + 8%i
+                       Type: Fraction Complex Integer
+
+The predefined macro %i is defined to be complex(0,1).
+
+  3.4 + 6.7 * %i
+   3.4 + 6.7 %i
+                      Type: Complex Float
+
+You can also compute the conjugate and norm of a complex number.
+
+  conjugate a
+   4   5
+   - - - %i
+   3   2
+                      Type: Complex Fraction Integer
+
+  norm a
+   289
+   ---
+    36
+                      Type: Fraction Integer
+
+The real and imag operations are provided to extract the real and
+imaginary parts, respectively.
+
+  real a
+   4
+   -
+   3
+                      Type: Fraction Integer
+
+  imag a
+   5
+   -
+   2
+                      Type: Fraction Integer
+
+The domain Complex Integer is also called the Gaussian integers.  If R
+is the integers (or, more generally, a EuclideanDomain), you can compute 
+greatest common divisors.
+
+  gcd(13 - 13*%i,31 + 27*%i)
+   5 + %i
+                      Type: Complex Integer
+
+You can also compute least common multiples.
+
+  lcm(13 - 13*%i,31 + 27*%i)
+   143 - 39%i
+                      Type: Complex Integer
+
+You can factor Gaussian integers.
+
+  factor(13 - 13*%i)
+   - (1 + %i)(2 + 3%i)(3 + 2%i)
+                      Type: Factored Complex Integer
+
+  factor complex(2,0)
+                2
+   - %i (1 + %i)
+                      Type: Factored Complex Integer
+
+See Also
+o )show Complex
+o $AXIOM/doc/src/algebra/gaussian.spad.dvi 
+
+@
 <<domain COMPLEX Complex>>=
 )abbrev domain COMPLEX Complex
 ++ Author:
diff --git a/src/algebra/list.spad.pamphlet b/src/algebra/list.spad.pamphlet
index d773bb6..1c534e9 100644
--- a/src/algebra/list.spad.pamphlet
+++ b/src/algebra/list.spad.pamphlet
@@ -671,6 +671,194 @@ ListToMap(A:SetCategory, B:Type): Exports == 
Implementation where
 
 @
 \section{domain ALIST AssociationList}
+<<AssociationList.input>>=
+-- list.spad.pamphlet AssociationList.input
+)spool AssociationList.output
+)set message test on
+)set message auto off
+)clear all
+--S 1 of 10
+Data := Record(monthsOld : Integer, gender : String)
+--R 
+--R
+--R   (1)  Record(monthsOld: Integer,gender: String)
+--R                                                                 Type: 
Domain
+--E 1
+
+--S 2 of 10
+al : AssociationList(String,Data)
+--R 
+--R                                                                   Type: 
Void
+--E 2
+
+--S 3 of 10
+al := table()
+--R 
+--R
+--R   (3)  table()
+--R      Type: AssociationList(String,Record(monthsOld: Integer,gender: 
String))
+--E 3
+
+--S 4 of 10
+al."bob" := [407,"male"]$Data
+--R 
+--R
+--R   (4)  [monthsOld= 407,gender= "male"]
+--R                              Type: Record(monthsOld: Integer,gender: 
String)
+--E 4
+
+--S 5 of 10
+al."judith" := [366,"female"]$Data
+--R 
+--R
+--R   (5)  [monthsOld= 366,gender= "female"]
+--R                              Type: Record(monthsOld: Integer,gender: 
String)
+--E 5
+
+--S 6 of 10
+al."katie" := [24,"female"]$Data
+--R 
+--R
+--R   (6)  [monthsOld= 24,gender= "female"]
+--R                              Type: Record(monthsOld: Integer,gender: 
String)
+--E 6
+
+--S 7 of 10
+al."smokie" := [200,"female"]$Data
+--R 
+--R
+--R   (7)  [monthsOld= 200,gender= "female"]
+--R                              Type: Record(monthsOld: Integer,gender: 
String)
+--E 7
+
+--S 8 of 10
+al
+--R 
+--R
+--R   (8)
+--R   table
+--R      "smokie"= [monthsOld= 200,gender= "female"]
+--R  ,
+--R      "katie"= [monthsOld= 24,gender= "female"]
+--R  ,
+--R      "judith"= [monthsOld= 366,gender= "female"]
+--R  ,
+--R      "bob"= [monthsOld= 407,gender= "male"]
+--R      Type: AssociationList(String,Record(monthsOld: Integer,gender: 
String))
+--E 8
+
+--S 9 of 10
+al."katie" := [23,"female"]$Data
+--R 
+--R
+--R   (9)  [monthsOld= 23,gender= "female"]
+--R                              Type: Record(monthsOld: Integer,gender: 
String)
+--E 9
+
+--S 10 of 10
+delete!(al,1)
+--R 
+--R
+--R   (10)
+--R   table
+--R      "katie"= [monthsOld= 23,gender= "female"]
+--R  ,
+--R      "judith"= [monthsOld= 366,gender= "female"]
+--R  ,
+--R      "bob"= [monthsOld= 407,gender= "male"]
+--R      Type: AssociationList(String,Record(monthsOld: Integer,gender: 
String))
+--E 10
+)spool
+)lisp (bye)
+@
+<<AssociationList.help>>=
+====================================================================
+AssociationList examples
+====================================================================
+
+The AssociationList constructor provides a general structure for
+associative storage.  This type provides association lists in which
+data objects can be saved according to keys of any type.  For a given
+association list, specific types must be chosen for the keys and
+entries.  You can think of the representation of an association list
+as a list of records with key and entry fields.
+
+Association lists are a form of table and so most of the operations
+available for Table are also available for AssociationList.  They can
+also be viewed as lists and can be manipulated accordingly.
+
+This is a Record type with age and gender fields.
+
+  Data := Record(monthsOld : Integer, gender : String)
+    Record(monthsOld: Integer,gender: String)
+                      Type: Domain
+
+In this expression, al is declared to be an association
+list whose keys are strings and whose entries are the above records.
+
+  al : AssociationList(String,Data)
+                      Type: Void
+
+The table operation is used to create an empty association list.
+
+  al := table()
+   table() 
+    Type: AssociationList(String,Record(monthsOld: Integer,gender: String))
+
+You can use assignment syntax to add things to the association list.
+
+  al."bob" := [407,"male"]$Data
+   [monthsOld=407, gender= "male"]
+                      Type: Record(monthsOld: Integer,gender: String)
+
+  al."judith" := [366,"female"]$Data
+   [monthsOld=366, gender= "female"]
+                      Type: Record(monthsOld: Integer,gender: String)
+
+  al."katie" := [24,"female"]$Data
+   [monthsOld=24, gender= "female"]
+                      Type: Record(monthsOld: Integer,gender: String)
+
+Perhaps we should have included a species field.
+
+  al."smokie" := [200,"female"]$Data
+   [monthsOld=200, gender= "female"]
+                      Type: Record(monthsOld: Integer,gender: String)
+
+Now look at what is in the association list.  Note that the last-added
+(key, entry) pair is at the beginning of the list.
+
+  al
+   table("smokie" = [monthsOld=200, gender= "female"],
+         "katie" = [monthsOld=24, gender= "female"],
+         "judith" = [monthsOld=366, gender= "female"],
+         "bob" = [monthsOld=407, gender= "male"])
+      Type: AssociationList(String,Record(monthsOld: Integer,gender: String))
+
+You can reset the entry for an existing key.
+
+  al."katie" := [23,"female"]$Data
+   [monthsOld=23, gender= "female"]
+                      Type: Record(monthsOld: Integer,gender: String)
+
+Use delete! to destructively remove an element of the association
+list.  Use delete to return a copy of the association list with the
+element deleted.  The second argument is the index of the element to
+delete.
+
+  delete!(al,1)
+   table("katie" = [monthsOld=23, gender= "female"],
+         "judith" = [monthsOld=366, gender= "female"],
+         "bob" = [monthsOld=407, gender= "male"])
+    Type: AssociationList(String,Record(monthsOld: Integer,gender: String))
+
+See Also:
+o )help Table
+o )help List
+o )show AssociationList
+o $AXIOM/doc/src/algebra/list.spad.dvi
+
+@
 <<domain ALIST AssociationList>>=
 )abbrev domain ALIST AssociationList
 ++ Author:
diff --git a/src/algebra/op.spad.pamphlet b/src/algebra/op.spad.pamphlet
index 5b93a6a..e443d3c 100644
--- a/src/algebra/op.spad.pamphlet
+++ b/src/algebra/op.spad.pamphlet
@@ -10,6 +10,310 @@
 \tableofcontents
 \eject
 \section{domain BOP BasicOperator}
+<<BasicOperator.input>>=
+-- op.spad.pamphlet BasicOperator.input
+)spool BasicOperator.output
+)set message test on
+)set message auto off
+)clear all
+--S 1 of 18
+y := operator 'y
+--R 
+--R
+--R   (1)  y
+--R                                                          Type: 
BasicOperator
+--E 1
+
+--S 2 of 18
+deq := D(y x, x, 2) + D(y x, x) + y x = 0
+--R 
+--R
+--R         ,,       ,
+--R   (2)  y  (x) + y (x) + y(x)= 0
+--R
+--R                                            Type: Equation Expression 
Integer
+--E 2
+
+--S 3 of 18
+solve(deq, y, x)
+--R 
+--R
+--R                                             x     x
+--R                                     +-+   - -   - -      +-+
+--R                                   x\|3      2     2    x\|3
+--R   (3)  [particular= 0,basis= [cos(-----)%e   ,%e   sin(-----)]]
+--R                                     2                    2
+--RType: Union(Record(particular: Expression Integer,basis: List Expression 
Integer),...)
+--E 3
+
+--S 4 of 18
+nary? y
+--R 
+--R
+--R   (4)  true
+--R                                                                Type: 
Boolean
+--E 4
+
+--S 5 of 18
+unary? y
+--R 
+--R
+--R   (5)  false
+--R                                                                Type: 
Boolean
+--E 5
+
+--S 6 of 18
+opOne := operator('opOne, 1)
+--R 
+--R
+--R   (6)  opOne
+--R                                                          Type: 
BasicOperator
+--E 6
+
+--S 7 of 18
+nary? opOne
+--R 
+--R
+--R   (7)  false
+--R                                                                Type: 
Boolean
+--E 7
+
+--S 8 of 18
+unary? opOne
+--R 
+--R
+--R   (8)  true
+--R                                                                Type: 
Boolean
+--E 8
+
+--S 9 of 18
+arity opOne
+--R 
+--R
+--R   (9)  1
+--R                                          Type: 
Union(NonNegativeInteger,...)
+--E 9
+
+--S 10 of 18
+name opOne
+--R 
+--R
+--R   (10)  opOne
+--R                                                                 Type: 
Symbol
+--E 10
+
+--S 11 of 18
+is?(opOne, 'z2)
+--R 
+--R
+--R   (11)  false
+--R                                                                Type: 
Boolean
+--E 11
+
+--S 12 of 18
+is?(opOne, "opOne")
+--R 
+--R
+--R   (12)  true
+--R                                                                Type: 
Boolean
+--E 12
+
+--S 13 of 18
+properties y
+--R 
+--R
+--R   (13)  table()
+--R                                           Type: 
AssociationList(String,None)
+--E 13
+
+--S 14 of 18
+setProperty(y, "use", "unknown function" :: None )
+--R 
+--R
+--R   (14)  y
+--R                                                          Type: 
BasicOperator
+--E 14
+
+--S 15 of 18
+properties y
+--R 
+--R
+--R   (15)  table("use"= NONE)
+--R                                           Type: 
AssociationList(String,None)
+--E 15
+
+--S 16 of 18
+property(y, "use") :: None pretend String
+--R 
+--R
+--R   (16)  "unknown function"
+--R                                                                 Type: 
String
+--E 16
+
+--S 17 of 18
+deleteProperty!(y, "use")
+--R 
+--R
+--R   (17)  y
+--R                                                          Type: 
BasicOperator
+--E 17
+
+--S 18 of 18
+properties y
+--R 
+--R
+--R   (18)  table()
+--R                                           Type: 
AssociationList(String,None)
+--E 18
+)spool
+)lisp (bye)
+@
+<<BasicOperator.help>>=
+====================================================================
+BasicOperator examples
+====================================================================
+
+A basic operator is an object that can be symbolically applied to a
+list of arguments from a set, the result being a kernel over that set
+or an expression.  
+
+You create an object of type BasicOperator by using the operator
+operation.  This first form of this operation has one argument and it
+must be a symbol.  The symbol should be quoted in case the name has
+been used as an identifier to which a value has been assigned.
+
+A frequent application of BasicOperator is the creation of an operator
+to represent the unknown function when solving a differential equation.
+
+Let y be the unknown function in terms of x.
+
+  y := operator 'y
+   y 
+                      Type: BasicOperator
+
+This is how you enter the equation y'' + y' + y = 0.
+
+  deq := D(y x, x, 2) + D(y x, x) + y x = 0
+    ,,       ,
+   y  (x) + y (x) + y(x) = 0
+                      Type: Equation Expression Integer
+
+To solve the above equation, enter this.
+
+  solve(deq, y, x)
+                                        x     x
+                                +-+   - -   - -      +-+
+                              x\|3      2     2    x\|3
+   [particular= 0,basis= [cos(-----)%e   ,%e   sin(-----)]]
+                                2                    2
+                      Type: Union(Record(particular: Expression Integer,
+                                  basis: List Expression Integer),...)
+
+Use the single argument form of BasicOperator (as above) when you
+intend to use the operator to create functional expressions with an
+arbitrary number of arguments
+
+Nary means an arbitrary number of arguments can be used in the
+functional expressions.
+
+  nary? y
+   true
+                      Type: Boolean
+
+  unary? y
+   false
+                      Type: Boolean
+
+Use the two-argument form when you want to restrict the number of
+arguments in the functional expressions created with the operator.
+
+This operator can only be used to create functional expressions
+with one argument.
+
+  opOne := operator('opOne, 1)
+   opOne 
+                      Type: BasicOperator
+
+  nary? opOne
+   false
+                      Type: Boolean
+
+  unary? opOne
+   true
+                      Type: Boolean
+
+Use arity to learn the number of arguments that can be used.  It
+returns "false" if the operator is nary.
+
+  arity opOne
+   1
+                      Type: Union(NonNegativeInteger,...)
+
+Use name to learn the name of an operator.
+
+  name opOne
+   opOne 
+                      Type: Symbol
+
+Use is? to learn if an operator has a particular name.
+
+  is?(opOne, 'z2)
+   false
+                      Type: Boolean
+
+You can also use a string as the name to be tested against.
+
+  is?(opOne, "opOne")
+   true
+                      Type: Boolean
+
+You can attached named properties to an operator.  These are rarely
+used at the top-level of the Axiom interactive environment but are
+used with Axiom library source code.
+
+By default, an operator has no properties.
+
+  properties y
+   table() 
+                      Type: AssociationList(String,None)
+
+The interface for setting and getting properties is somewhat awkward
+because the property values are stored as values of type None.
+
+Attach a property by using setProperty.
+
+  setProperty(y, "use", "unknown function" :: None )
+   y 
+                      Type: BasicOperator
+
+  properties y
+   table("use"=NONE)
+                      Type: AssociationList(String,None)
+
+We know the property value has type String.
+
+  property(y, "use") :: None pretend String
+   "unknown function"
+                      Type: String
+
+Use deleteProperty! to destructively remove a property.
+
+ deleteProperty!(y, "use")
+  y 
+                      Type: BasicOperator
+
+  properties y
+   table() 
+                      Type: AssociationList(String,None)
+
+
+See Also
+o )help Expression
+o )help Kernel
+o )show BasicOperator
+o $AXIOM/doc/src/algebra/op.spad.dvi
+
+@
 <<domain BOP BasicOperator>>=
 )abbrev domain BOP BasicOperator
 ++ Basic system operators
diff --git a/src/algebra/radix.spad.pamphlet b/src/algebra/radix.spad.pamphlet
index d26f7b5..f35780e 100644
--- a/src/algebra/radix.spad.pamphlet
+++ b/src/algebra/radix.spad.pamphlet
@@ -255,6 +255,168 @@ RadixExpansion(bb): Exports == Implementation where
 
 @
 \section{domain BINARY BinaryExpansion}
+<<BinaryExpansion.input>>=
+-- radix.spad.pamphlet BinaryExpansion.input
+)spool BinaryExpansion.output
+)set message test on
+)set message auto off
+)clear all
+--S 1
+r := binary(22/7)
+--R 
+--R
+--R           ___
+--R   (1)  11.001
+--R                                                        Type: 
BinaryExpansion
+--E 1
+
+--S 2
+r + binary(6/7)
+--R 
+--R
+--R   (2)  100
+--R                                                        Type: 
BinaryExpansion
+--E 2
+
+--S 3
+[binary(1/i) for i in 102..106]
+--R 
+--R
+--R   (3)
+--R       ________    ___________________________________________________
+--R   [0.000000101, 0.000000100111110001000101100101111001110010010101001,
+--R         ____________    ____________
+--R    0.000000100111011, 0.000000100111,
+--R       ____________________________________________________
+--R    0.00000010011010100100001110011111011001010110111100011]
+--R                                                   Type: List 
BinaryExpansion
+--E 3
+
+--S 4
+binary(1/1007)
+--R 
+--R
+--R   (4)
+--R   0.
+--R     OVERBAR
+--R        
00000000010000010001010010010111100000111111000010111111001011000111110
+--R          
100010011100100110011000110010010101011110110100110000000011000011001
+--R          
111011100011010001011110100100011110110000101011101110011101010111001
+--R          
100101001011100000001110001111001000000100100100110111001010100111010
+--R          
001101110110101110001001000001100101101100000010110010111110001010000
+--R          
010101010110101100000110110111010010101111111010111010100110010000101
+--R          0011011000100110001000100001000011000111010011110001
+--R                                                        Type: 
BinaryExpansion
+--E 4
+
+--S 5
+p := binary(1/4)*x**2 + binary(2/3)*x + binary(4/9)
+--R 
+--R
+--R             2     __      ______
+--R   (5)  0.01x  + 0.10x + 0.011100
+--R                                             Type: Polynomial 
BinaryExpansion
+--E 5
+
+--S 6
+q := D(p, x)
+--R 
+--R
+--R                 __
+--R   (6)  0.1x + 0.10
+--R                                             Type: Polynomial 
BinaryExpansion
+--E 6
+
+--S 7
+g := gcd(p, q)
+--R 
+--R
+--R              __
+--R   (7)  x + 1.01
+--R                                             Type: Polynomial 
BinaryExpansion
+--E 7
+)spool
+)lisp (bye)
+@
+<<BinaryExpansion.help>>=
+====================================================================
+BinaryExpansion examples
+====================================================================
+All rational numbers have repeating binary expansions.  Operations to
+access the individual bits of a binary expansion can be obtained by
+converting the value to RadixExpansion(2).  More examples of
+expansions are available with
+
+The expansion (of type BinaryExpansion) of a rational number is
+returned by the binary operation.
+
+  r := binary(22/7)
+      ___
+   11.001
+                      Type: BinaryExpansion
+
+Arithmetic is exact.
+
+  r + binary(6/7)
+   100 
+                      Type: BinaryExpansion
+
+The period of the expansion can be short or long.
+
+  [binary(1/i) for i in 102..106]
+      ________
+   [0.00000101,
+      ___________________________________________________
+    0.000000100111110001000101100101111001110010010101001,
+         ____________    ____________
+    0.000000100111011, 0.000000100111,
+       ____________________________________________________
+    0.00000010011010100100001110011111011001010110111100011]
+                      Type: List BinaryExpansion
+
+or very long.
+
+  binary(1/1007)
+     ________________________________________________________________________
+   0.000000000100000100010100100101111000001111110000101111110010110001111101
+     ________________________________________________________________________
+     000100111001001100110001100100101010111101101001100000000110000110011110
+     ________________________________________________________________________
+     111000110100010111101001000111101100001010111011100111010101110011001010
+     ________________________________________________________________________
+     010111000000011100011110010000001001001001101110010101001110100011011101
+     ________________________________________________________________________
+     101011100010010000011001011011000000101100101111100010100000101010101101
+     ________________________________________________________________________
+     011000001101101110100101011111110101110101001100100001010011011000100110
+     ____________________________________
+     001000100001000011000111010011110001
+                      Type: BinaryExpansion
+
+These numbers are bona fide algebraic objects.
+
+  p := binary(1/4)*x**2 + binary(2/3)*x + binary(4/9)
+               __       ______
+   0.01 x^2 +0.10 x + 0.011100
+                      Type: Polynomial BinaryExpansion
+
+  q := D(p, x)
+             __
+   0.1 x + 0.10
+                      Type: Polynomial BinaryExpansion
+
+  g := gcd(p, q)
+       __
+   x+1.01
+                      Type: Polynomial BinaryExpansion
+
+See Also:
+o )help DecimalExpansion
+o )help HexadecimalExpansion
+o )show BinaryExpansion
+o $AXIOM/doc/src/algebra/radix.spad.dvi
+
+@
 <<domain BINARY BinaryExpansion>>=
 )abbrev domain BINARY BinaryExpansion
 ++ Author: Clifton J. Williamson
@@ -288,6 +450,157 @@ BinaryExpansion(): Exports == Implementation where
 
 @
 \section{domain DECIMAL DecimalExpansion}
+<<DecimalExpansion.input>>=
+-- radix.spad.pamphlet DecimalExpansion.input
+)spool DecimalExpansion.output
+)set message test on
+)set message auto off
+)clear all
+--S 1 of 7
+r := decimal(22/7)
+--R 
+--R
+--R          ______
+--R   (1)  3.142857
+--R                                                       Type: 
DecimalExpansion
+--E 1
+
+--S 2 of 7
+r + decimal(6/7)
+--R 
+--R
+--R   (2)  4
+--R                                                       Type: 
DecimalExpansion
+--E 2
+
+--S 3 of 7
+[decimal(1/i) for i in 350..354]
+--R 
+--R
+--R   (3)
+--R        ______    ______         __    ________________________________
+--R   [0.00285714, 0.002849, 0.0028409, 0.00283286118980169971671388101983,
+--R       __________________________________________________________
+--R    0.00282485875706214689265536723163841807909604519774011299435]
+--R                                                  Type: List 
DecimalExpansion
+--E 3
+
+--S 4 of 7
+decimal(1/2049)
+--R 
+--R
+--R   (4)
+--R   0.
+--R     OVERBAR
+--R        
00048804294777940458760370912640312347486578818936066373840897999023914
+--R          
104441190824792581747193753050268423621278672523182040019521717911176
+--R          
183504148365056124938994631527574426549536359199609565641776476329917
+--R          
032698877501220107369448511469009272816007808687164470473401659346022
+--R          449975597852611029770619814543679843826256710590531966813079551
+--R                                                       Type: 
DecimalExpansion
+--E 4
+
+--S 5 of 7
+p := decimal(1/4)*x**2 + decimal(2/3)*x + decimal(4/9) 
+--R 
+--R
+--R             2     _      _
+--R   (5)  0.25x  + 0.6x + 0.4
+--R                                            Type: Polynomial 
DecimalExpansion
+--E 5
+
+--S 6 of 7
+q := differentiate(p, x)
+--R 
+--R
+--R                 _
+--R   (6)  0.5x + 0.6
+--R                                            Type: Polynomial 
DecimalExpansion
+--E 6
+
+--S 7 of 7
+g := gcd(p, q)
+--R 
+--R
+--R              _
+--R   (7)  x + 1.3
+--R                                            Type: Polynomial 
DecimalExpansion
+--E 7
+)spool
+)lisp (bye)
+@
+<<DecimalExpansion.help>>=
+====================================================================
+DecimalExpansion examples
+====================================================================
+
+All rationals have repeating decimal expansions.  Operations to access
+the individual digits of a decimal expansion can be obtained by
+converting the value to RadixExpansion(10).  
+
+The operation decimal is used to create this expansion of type
+DecimalExpansion.
+
+  r := decimal(22/7)
+      ______
+    3.142857
+                      Type: DecimalExpansion
+
+Arithmetic is exact.
+
+  r + decimal(6/7)
+   4
+                      Type: DecimalExpansion
+
+The period of the expansion can be short or long ...
+
+  [decimal(1/i) for i in 350..354]
+        ______    ______         __    ________________________________
+   [0.00285714, 0.002849, 0.0028409, 0.00283286118980169971671388101983,
+       __________________________________________________________
+    0.00282485875706214689265536723163841807909604519774011299435]
+                      Type: List DecimalExpansion
+
+or very long.
+
+  decimal(1/2049)
+     _______________________________________________________________________
+   0.00048804294777940458760370912640312347486578818936066373840897999023914
+     _____________________________________________________________________
+     104441190824792581747193753050268423621278672523182040019521717911176
+     _____________________________________________________________________
+     183504148365056124938994631527574426549536359199609565641776476329917
+     _____________________________________________________________________
+     032698877501220107369448511469009272816007808687164470473401659346022
+     _______________________________________________________________
+     449975597852611029770619814543679843826256710590531966813079551
+                     Type: DecimalExpansion
+
+These numbers are bona fide algebraic objects.
+
+  p := decimal(1/4)*x**2 + decimal(2/3)*x + decimal(4/9) 
+        2     _      _
+   0.25x  + 0.6x + 0.4
+                     Type: Polynomial DecimalExpansion
+
+  q := differentiate(p, x)
+            _
+   0.5x + 0.6
+                     Type: Polynomial DecimalExpansion
+
+  g := gcd(p, q)
+         _
+   x + 1.3
+                     Type: Polynomial DecimalExpansion
+
+See Also:
+o )help RadixExpansion
+o )help BinaryExpansion
+o )help HexadecimalExpansion
+o )show DecimalExpansion
+o $AXIOM/doc/src/algebra/radix.spad.dvi
+
+@
 <<domain DECIMAL DecimalExpansion>>=
 )abbrev domain DECIMAL DecimalExpansion
 ++ Author: Stephen M. Watt
diff --git a/src/algebra/string.spad.pamphlet b/src/algebra/string.spad.pamphlet
index 6fb42a5..fe270fc 100644
--- a/src/algebra/string.spad.pamphlet
+++ b/src/algebra/string.spad.pamphlet
@@ -10,6 +10,208 @@
 \tableofcontents
 \eject
 \section{domain CHAR Character}
+<<Character.input>>=
+-- string.spad.pamphlet Character.input
+)spool Character.output
+)set message test on
+)set message auto off
+)clear all
+--S 1
+chars := [char "a", char "A", char "X", char "8", char "+"]
+--R 
+--R
+--R   (1)  [a,A,X,8,+]
+--R                                                         Type: List 
Character
+--E 1
+
+--S 2
+space()
+--R 
+--R
+--R   (2)
+--R                                                              Type: 
Character
+--E 2
+
+--S 3
+quote()
+--R 
+--R
+--R   (3)  "
+--R                                                              Type: 
Character
+--E 3
+
+--S 4
+escape()
+--R 
+--R
+--R   (4)  _
+--R                                                              Type: 
Character
+--E 4
+
+--S 5
+[ord c for c in chars]
+--R 
+--R
+--R   (5)  [97,65,88,56,43]
+--R                                                           Type: List 
Integer
+--E 5
+
+--S 6
+[upperCase c for c in chars]
+--R 
+--R
+--R   (6)  [A,A,X,8,+]
+--R                                                         Type: List 
Character
+--E 6
+
+--S 7
+[lowerCase c for c in chars]
+--R 
+--R
+--R   (7)  [a,a,x,8,+]
+--R                                                         Type: List 
Character
+--E 7
+
+--S 8
+[alphabetic? c for c in chars]
+--R 
+--R
+--R   (8)  [true,true,true,false,false]
+--R                                                           Type: List 
Boolean
+--E 8
+
+--S 9
+[upperCase? c for c in chars]
+--R 
+--R
+--R   (9)  [false,true,true,false,false]
+--R                                                           Type: List 
Boolean
+--E 9
+
+--S 10
+[lowerCase? c for c in chars]
+--R 
+--R
+--R   (10)  [true,false,false,false,false]
+--R                                                           Type: List 
Boolean
+--E 10
+
+--S 11
+[digit? c for c in chars]
+--R 
+--R
+--R   (11)  [false,false,false,true,false]
+--R                                                           Type: List 
Boolean
+--E 11
+
+--S 12
+[hexDigit? c for c in chars]
+--R 
+--R
+--R   (12)  [true,true,false,true,false]
+--R                                                           Type: List 
Boolean
+--E 12
+
+--S 13
+[alphanumeric? c for c in chars]
+--R 
+--R
+--R   (13)  [true,true,true,true,false]
+--R                                                           Type: List 
Boolean
+--E 13
+)spool
+)lisp (bye)
+@
+<<Character.help>>=
+====================================================================
+Character examples
+====================================================================
+
+The members of the domain Character are values representing letters,
+numerals and other text elements.
+
+Characters can be obtained using String notation.
+
+  chars := [char "a", char "A", char "X", char "8", char "+"]
+   [a,A,X,8,+]
+                      Type: List Character
+
+Certain characters are available by name. This is the blank character.
+
+  space()
+
+                      Type: Character
+
+This is the quote that is used in strings.
+
+  quote()
+   "
+                      Type: Character
+
+This is the escape character that allows quotes and other characters
+within strings.
+
+  escape()
+   _
+                      Type: Character
+
+Characters are represented as integers in a machine-dependent way.
+The integer value can be obtained using the ord operation.  It is
+always true that char(ord c) = c and ord(char i) = i, provided that i
+is in the range 0..size()$Character-1.
+
+  [ord c for c in chars]
+   [97,65,88,56,43]
+                      Type: List Integer
+ 
+The lowerCase operation converts an upper case letter to the
+corresponding lower case letter.  If the argument is not an upper case
+letter, then it is returned unchanged.
+
+  [upperCase c for c in chars]
+    [A,A,X,8,+]
+                      Type: List Character
+
+The upperCase operation converts lower case letters to upper case.
+
+  [lowerCase c for c in chars]
+   [a,a,x,8,+]
+                      Type: List Character
+
+A number of tests are available to determine whether characters
+belong to certain families.
+
+  [alphabetic? c for c in chars]
+   [true,true,true,false,false]
+                      Type: List Boolean
+
+  [upperCase? c for c in chars]
+   [false,true,true,false,false]
+                      Type: List Boolean
+
+  [lowerCase? c for c in chars]
+    [true,false,false,false,false]
+                      Type: List Boolean
+
+  [digit? c for c in chars]
+   [false,false,false,true,false]
+                      Type: List Boolean
+
+  [hexDigit? c for c in chars]
+   [true,true,false,true,false]
+                      Type: List Boolean
+
+  [alphanumeric? c for c in chars]
+   [true,true,true,true,false]
+                      Type: List Boolean
+
+See Also:
+o )help CharacterClass
+o )help String
+o )show Character
+o $AXIOM/doc/src/algebra/string.spad.dvi
+
+@
 <<domain CHAR Character>>=
 )abbrev domain CHAR Character
 ++ Author: Stephen M. Watt
@@ -202,6 +404,233 @@ Note that this code is not included in the generated 
catdef.spad file.
 (MAKEPROP (QUOTE |Character|) (QUOTE NILADIC) T) 
 @
 \section{domain CCLASS CharacterClass}
+<<CharacterClass.input>>=
+-- string.spad.pamphlet CharacterClass.input
+)spool CharacterClass.output
+)set message test on
+)set message auto off
+)clear all
+--S 1 of 16
+cl1:=charClass[char "a",char "e",char "i",char "o",char "u",char "y"]
+--R 
+--R
+--R   (1)  "aeiouy"
+--R                                                         Type: 
CharacterClass
+--E 1
+
+--S 2 of 16
+cl2 := charClass "bcdfghjklmnpqrstvwxyz"
+--R 
+--R
+--R   (2)  "bcdfghjklmnpqrstvwxyz"
+--R                                                         Type: 
CharacterClass
+--E 2
+
+--S 3 of 16
+digit()
+--R 
+--R
+--R   (3)  "0123456789"
+--R                                                         Type: 
CharacterClass
+--E 3
+
+--S 4 of 16
+hexDigit()
+--R 
+--R
+--R   (4)  "0123456789ABCDEFabcdef"
+--R                                                         Type: 
CharacterClass
+--E 4
+
+--S 5 of 16
+upperCase()
+--R 
+--R
+--R   (5)  "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+--R                                                         Type: 
CharacterClass
+--E 5
+
+--S 6 of 16
+lowerCase()
+--R 
+--R
+--R   (6)  "abcdefghijklmnopqrstuvwxyz"
+--R                                                         Type: 
CharacterClass
+--E 6
+
+--S 7 of 16
+alphabetic()
+--R 
+--R
+--R   (7)  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+--R                                                         Type: 
CharacterClass
+--E 7
+
+--S 8 of 16
+alphanumeric()
+--R 
+--R
+--R   (8)  "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+--R                                                         Type: 
CharacterClass
+--E 8
+
+--S 9 of 16
+member?(char "a", cl1)
+--R 
+--R
+--R   (9)  true
+--R                                                                Type: 
Boolean
+--E 9
+
+--S 10 of 16
+member?(char "a", cl2)
+--R 
+--R
+--R   (10)  false
+--R                                                                Type: 
Boolean
+--E 10
+
+--S 11 of 16
+intersect(cl1, cl2)
+--R 
+--R
+--R   (11)  "y"
+--R                                                         Type: 
CharacterClass
+--E 11
+
+--S 12 of 16
+union(cl1,cl2)
+--R 
+--R
+--R   (12)  "abcdefghijklmnopqrstuvwxyz"
+--R                                                         Type: 
CharacterClass
+--E 12
+
+--S 13 of 16
+difference(cl1,cl2)
+--R 
+--R
+--R   (13)  "aeiou"
+--R                                                         Type: 
CharacterClass
+--E 13
+
+--S 14 of 16
+intersect(complement(cl1),cl2)
+--R 
+--R
+--R   (14)  "bcdfghjklmnpqrstvwxz"
+--R                                                         Type: 
CharacterClass
+--E 14
+
+--S 15 of 16
+insert!(char "a", cl2)
+--R 
+--R
+--R   (15)  "abcdfghjklmnpqrstvwxyz"
+--R                                                         Type: 
CharacterClass
+--E 15
+
+--S 16 of 16
+remove!(char "b", cl2)
+--R 
+--R
+--R   (16)  "acdfghjklmnpqrstvwxyz"
+--R                                                         Type: 
CharacterClass
+--E 16
+)spool
+)lisp (bye)
+@
+<<CharacterClass.help>>=
+====================================================================
+CharacterClass examples
+====================================================================
+
+The CharacterClass domain allows classes of characters to be defined
+and manipulated efficiently.
+ 
+Character classes can be created by giving either a string or a list
+of characters.
+
+  cl1:=charClass[char "a",char "e",char "i",char "o",char "u",char "y"]
+   "aeiouy"
+                      Type: CharacterClass
+
+  cl2 := charClass "bcdfghjklmnpqrstvwxyz"
+   "bcdfghjklmnpqrstvwxyz"
+                      Type: CharacterClass
+
+A number of character classes are predefined for convenience.
+
+  digit()
+   "0123456789"
+                      Type: CharacterClass
+
+  hexDigit()
+   "0123456789ABCDEFabcdef"
+                      Type: CharacterClass
+
+  upperCase()
+   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                      Type: CharacterClass
+
+  lowerCase()
+   "abcdefghijklmnopqrstuvwxyz"
+                      Type: CharacterClass
+
+  alphabetic()
+   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+                      Type: CharacterClass
+
+  alphanumeric()
+   "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+                      Type: CharacterClass
+
+You can quickly test whether a character belongs to a class.
+
+  member?(char "a", cl1)
+   true
+                      Type: Boolean
+
+  member?(char "a", cl2)
+   false
+                      Type: Boolean
+
+Classes have the usual set operations because the CharacterClass
+domain belongs to the category FiniteSetAggregate(Character).
+
+  intersect(cl1, cl2)
+   "y"
+                      Type: CharacterClass
+
+  union(cl1,cl2)
+   "abcdefghijklmnopqrstuvwxyz"
+                      Type: CharacterClass
+
+  difference(cl1,cl2)
+   "aeiou"
+                      Type: CharacterClass
+
+  intersect(complement(cl1),cl2)
+   "bcdfghjklmnpqrstvwxz"
+                      Type: CharacterClass
+
+You can modify character classes by adding or removing characters.
+
+  insert!(char "a", cl2)
+   "abcdfghjklmnpqrstvwxyz"
+                      Type: CharacterClass
+
+  remove!(char "b", cl2)
+   "acdfghjklmnpqrstvwxyz"
+                      Type: CharacterClass
+ 
+See Also:
+o )help Character
+o )help String
+o )show CharacterClass
+o $AXIOM/doc/src/algebra/string.spad.dvi
+
+@
 <<domain CCLASS CharacterClass>>=
 )abbrev domain CCLASS CharacterClass
 ++ Author: Stephen M. Watt
diff --git a/src/algebra/tree.spad.pamphlet b/src/algebra/tree.spad.pamphlet
index ff8ba34..573f7f8 100644
--- a/src/algebra/tree.spad.pamphlet
+++ b/src/algebra/tree.spad.pamphlet
@@ -411,6 +411,210 @@ BinaryTree(S: SetCategory): Exports == Implementation 
where
 
 @
 \section{domain BSTREE BinarySearchTree}
+<<BinarySearchTree.input>>=
+-- tree.spad.pamphlet BinarySearchTree.input
+)spool BinarySearchTree.output
+)set message test on
+)set message auto off
+)clear all
+--S 1 of 12
+lv := [8,3,5,4,6,2,1,5,7]
+--R 
+--R
+--R   (1)  [8,3,5,4,6,2,1,5,7]
+--R                                                   Type: List 
PositiveInteger
+--E 1
+
+--S 2 of 12
+t := binarySearchTree lv
+--R 
+--R
+--R   (2)  [[[1,2,.],3,[4,5,[5,6,7]]],8,.]
+--R                                       Type: BinarySearchTree 
PositiveInteger
+--E 2
+
+--S 3 of 12
+emptybst := empty()$BSTREE(INT)
+--R 
+--R
+--R   (3)  []
+--R                                               Type: BinarySearchTree 
Integer
+--E 3
+
+--S 4 of 12
+t1 := insert!(8,emptybst)
+--R 
+--R
+--R   (4)  8
+--R                                               Type: BinarySearchTree 
Integer
+--E 4
+
+--S 5 of 12
+insert!(3,t1)
+--R 
+--R
+--R   (5)  [3,8,.]
+--R                                               Type: BinarySearchTree 
Integer
+--E 5
+
+--S 6 of 12
+leaves t
+--R 
+--R
+--R   (6)  [1,4,5,7]
+--R                                                   Type: List 
PositiveInteger
+--E 6
+
+--S 7 of 12
+split(3,t)
+--R 
+--R
+--R   (7)  [less= [1,2,.],greater= [[.,3,[4,5,[5,6,7]]],8,.]]
+--RType: Record(less: BinarySearchTree PositiveInteger,greater: 
BinarySearchTree PositiveInteger)
+--E 7
+
+--S 8 of 12
+insertRoot: (INT,BSTREE INT) -> BSTREE INT
+--R 
+--R                                                                   Type: 
Void
+--E 8
+
+--S 9 of 12
+insertRoot(x, t) ==
+    a := split(x, t)
+    node(a.less, x, a.greater)
+--R 
+--R                                                                   Type: 
Void
+--E 9
+
+--S 10 of 12
+buildFromRoot ls == reduce(insertRoot,ls,emptybst)
+--R 
+--R                                                                   Type: 
Void
+--E 10
+
+--S 11 of 12
+rt := buildFromRoot reverse lv
+--R 
+--R   Compiling function buildFromRoot with type List PositiveInteger -> 
+--R      BinarySearchTree Integer 
+--R   Compiling function insertRoot with type (Integer,BinarySearchTree 
+--R      Integer) -> BinarySearchTree Integer 
+--R
+--R   (11)  [[[1,2,.],3,[4,5,[5,6,7]]],8,.]
+--R                                               Type: BinarySearchTree 
Integer
+--E 11
+
+--S 12 of 12
+(t = rt)@Boolean
+--R 
+--R
+--R   (12)  true
+--R                                                                Type: 
Boolean
+--E 12
+)spool
+)lisp (bye)
+@
+<<BinarySearchTree.help>>=
+====================================================================
+BinarySearchTree examples
+====================================================================
+
+BinarySearchTree(R) is the domain of binary trees with elements of
+type R, ordered across the nodes of the tree.  A non-empty binary
+search tree has a value of type R, and right and left binary search
+subtrees.  If a subtree is empty, it is displayed as a period (".").
+
+Define a list of values to be placed across the tree.  The resulting
+tree has 8 at the root; all other elements are in the left subtree.
+
+  lv := [8,3,5,4,6,2,1,5,7]
+   [8, 3, 5, 4, 6, 2, 1, 5, 7]
+                      Type: List PositiveInteger
+
+A convenient way to create a binary search tree is to apply the
+operation binarySearchTree to a list of elements.
+
+  t := binarySearchTree lv
+   [[[1, 2, .], 3, [4, 5, [5, 6, 7]]], 8, .]
+                      Type: BinarySearchTree PositiveInteger
+
+Another approach is to first create an empty binary search tree of integers.
+
+  emptybst := empty()$BSTREE(INT)
+   [] 
+                      Type: BinarySearchTree Integer
+
+Insert the value 8.  This establishes 8 as the root of the binary
+search tree.  Values inserted later that are less than 8 get stored in
+the left subtree, others in the right subtree.
+
+  t1 := insert!(8,emptybst)
+   8 
+                      Type: BinarySearchTree Integer
+
+Insert the value 3. This number becomes the root of the left subtree
+of t1.  For optimal retrieval, it is thus important to insert the
+middle elements first.
+
+  insert!(3,t1)
+   [3, 8, .]
+                      Type: BinarySearchTree Integer
+
+We go back to the original tree t.  The leaves of the binary search
+tree are those which have empty left and right subtrees.
+
+  leaves t
+   [1, 4, 5, 7]
+                      Type: List PositiveInteger
+
+The operation split(k,t) returns a record containing the two subtrees:
+one with all elements "less" than k, another with elements "greater"
+than k.
+
+  split(3,t)
+   [less=[1, 2, .], greater=[[., 3, [4, 5, [5, 6, 7]]], 8, .]]
+              Type: Record(less: BinarySearchTree PositiveInteger,greater: 
+                           BinarySearchTree PositiveInteger)
+
+Define insertRoot to insert new elements by creating a new node.
+
+  insertRoot: (INT,BSTREE INT) -> BSTREE INT
+                      Type: Void
+
+The new node puts the inserted value between its "less" tree and
+"greater" tree.
+
+
+  insertRoot(x, t) ==
+    a := split(x, t)
+    node(a.less, x, a.greater)
+                      Type: Void
+
+
+Function buildFromRoot builds a binary search tree from a list
+of elements ls and the empty tree emptybst.
+
+  buildFromRoot ls == reduce(insertRoot,ls,emptybst)
+                      Type: Void
+
+Apply this to the reverse of the list lv.
+
+  rt := buildFromRoot reverse lv
+   [[[1, 2, . ], 3, [4, 5, [5, 6, 7]]], 8, .]
+                      Type: BinarySearchTree Integer
+
+Have Axiom check that these are equal.
+
+  (t = rt)@Boolean
+   true
+                      Type: Boolean
+
+See Also:
+o )show BinarySearchTree
+o $AXIOM/doc/src/algebra/tree.spad.dvi
+
+@
 <<domain BSTREE BinarySearchTree>>=
 )abbrev domain BSTREE BinarySearchTree
 ++ Description: BinarySearchTree(S) is the domain of
@@ -492,6 +696,198 @@ BinaryTournament(S: OrderedSet): Exports == 
Implementation where
 
 @
 \section{domain BBTREE BalancedBinaryTree}
+<<BalancedBinaryTree.input>>=
+-- tree.spad.pamphlet BalancedBinaryTree.input
+)spool BalancedBinaryTree.output
+)set message test on
+)set message auto off
+)clear all
+--S 1
+lm := [3,5,7,11]
+--R 
+--R
+--R   (1)  [3,5,7,11]
+--R                                                   Type: List 
PositiveInteger
+--E 1
+
+--S 2
+modTree(12,lm)
+--R 
+--R
+--R   (2)  [0,2,5,1]
+--R                                                           Type: List 
Integer
+--E 2
+
+--S 3
+t := balancedBinaryTree(#lm, 0)
+--R 
+--R
+--R   (3)  [[0,0,0],0,[0,0,0]]
+--R                                  Type: BalancedBinaryTree 
NonNegativeInteger
+--E 3
+
+--S 4
+setleaves!(t,lm)
+--R 
+--R
+--R   (4)  [[3,0,5],0,[7,0,11]]
+--R                                  Type: BalancedBinaryTree 
NonNegativeInteger
+--E 4
+
+--S 5
+mapUp!(t,_*)
+--R 
+--R
+--R   (5)  1155
+--R                                                        Type: 
PositiveInteger
+--E 5
+
+--S 6
+t
+--R 
+--R
+--R   (6)  [[3,15,5],1155,[7,77,11]]
+--R                                  Type: BalancedBinaryTree 
NonNegativeInteger
+--E 6
+
+--S 7
+mapDown!(t,12,_rem)
+--R 
+--R
+--R   (7)  [[0,12,2],12,[5,12,1]]
+--R                                  Type: BalancedBinaryTree 
NonNegativeInteger
+--E 7
+
+--S 8
+leaves %
+--R 
+--R
+--R   (8)  [0,2,5,1]
+--R                                                Type: List 
NonNegativeInteger
+--E 8
+
+--S 9
+squares := [x**2 rem m for x in % for m in lm]
+--R 
+--R
+--R   (9)  [0,4,4,1]
+--R                                                Type: List 
NonNegativeInteger
+--E 9
+
+--S 10
+chineseRemainder(%,lm)
+--R 
+--R
+--R   (10)  144
+--R                                                        Type: 
PositiveInteger
+--E 10
+)spool
+)lisp (bye)
+@
+<<BalancedBinaryTree.help>>=
+====================================================================
+BalancedBinaryTree examples
+====================================================================
+
+BalancedBinaryTrees(S) is the domain of balanced binary trees with
+elements of type S at the nodes.  A binary tree is either empty or
+else consists of a node having a value and two branches, each branch a
+binary tree.  A balanced binary tree is one that is balanced with
+respect its leaves.  One with 2^k leaves is perfectly "balanced": the
+tree has minimum depth, and the left and right branch of every
+interior node is identical in shape.
+
+Balanced binary trees are useful in algebraic computation for
+so-called "divide-and-conquer" algorithms.  Conceptually, the data
+for a problem is initially placed at the root of the tree.  The
+original data is then split into two subproblems, one for each
+subtree.  And so on.  Eventually, the problem is solved at the leaves
+of the tree.  A solution to the original problem is obtained by some
+mechanism that can reassemble the pieces.  In fact, an implementation
+of the Chinese Remainder Algorithm using balanced binary trees was
+first proposed by David Y. Y.  Yun at the IBM T. J.  Watson Research
+Center in Yorktown Heights, New York, in 1978.  It served as the
+prototype for polymorphic algorithms in Axiom.
+
+In what follows, rather than perform a series of computations with a
+single expression, the expression is reduced modulo a number of
+integer primes, a computation is done with modular arithmetic for each
+prime, and the Chinese Remainder Algorithm is used to obtain the
+answer to the original problem.  We illustrate this principle with the
+computation of 12^2 = 144.
+
+A list of moduli:
+
+  lm := [3,5,7,11]
+   [3,5,7,11]
+                      Type: PositiveInteger
+
+The expression modTree(n, lm) creates a balanced binary tree with leaf
+values n mod m for each modulus m in lm.
+
+  modTree(12,lm)
+   [0, 2, 5, 1]
+                      Type: List Integer
+
+Operation modTree does this using operations on balanced binary trees.
+We trace its steps.  Create a balanced binary tree t of zeros with
+four leaves.
+
+  t := balancedBinaryTree(#lm, 0)
+   [[0, 0, 0], 0, [0, 0, 0]]
+                      Type: BalancedBinaryTree NonNegativeInteger
+
+The leaves of the tree are set to the individual moduli.
+
+  setleaves!(t,lm)
+   [[3, 0, 5], 0, [7, 0, 11]]
+                      Type: BalancedBinaryTree NonNegativeInteger
+
+mapUp! to do a bottom-up traversal of t, setting each interior node to
+the product of the values at the nodes of its children.
+
+  mapUp!(t,_*)
+   1155 
+                      Type: PositiveInteger
+
+The value at the node of every subtree is the product of the moduli
+of the leaves of the subtree.
+
+  t
+   [[3, 15, 5], 1155, [7, 77, 11]]
+                      Type: BalancedBinaryTree NonNegativeInteger
+
+Operation mapDown!(t,a,fn) replaces the value v at each node of t by
+fn(a,v).
+
+  mapDown!(t,12,_rem)
+   [[0, 12, 2], 12, [5, 12, 1]]
+                      Type: BalancedBinaryTree NonNegativeInteger
+
+The operation leaves returns the leaves of the resulting tree.  In
+this case, it returns the list of 12 mod m for each modulus m.
+
+  leaves %
+   [0, 2, 5, 1]
+                      Type: List NonNegativeInteger
+
+Compute the square of the images of 12 modulo each m.
+
+  squares := [x**2 rem m for x in % for m in lm]
+   [0, 4, 4, 1]
+                      Type: List NonNegativeInteger
+
+Call the Chinese Remainder Algorithm to get the answer for 12^2.
+
+  chineseRemainder(%,lm)
+   144 
+                      Type: PositiveInteger
+
+See Also:
+o )show BalancedBinaryTree
+o $AXIOM/doc/src/algebra/tree.spad.dvi
+
+@
 <<domain BBTREE BalancedBinaryTree>>=
 )abbrev domain BBTREE BalancedBinaryTree
 ++ Description: \spadtype{BalancedBinaryTree(S)} is the domain of balanced
diff --git a/src/doc/Makefile.pamphlet b/src/doc/Makefile.pamphlet
index 7556528..cd17c11 100644
--- a/src/doc/Makefile.pamphlet
+++ b/src/doc/Makefile.pamphlet
@@ -146,7 +146,6 @@ syntax        trace      undo       what       while
 <<spadhelp.files>>=
 ${DVI}/spadhelp/spadhelp.files: ${IN}/spadhelp.pamphlet
        @echo 9 making ${DVI}/spadhelp from ${IN}/spadhelp.pamphlet
-       @mkdir ${DVI}/spadhelp
        @(cd ${DVI}/spadhelp ; \
           for i in ${SPADHELP} ; do \
             ${TANGLE} -R"$$i" ${IN}/spadhelp.pamphlet >$$i.help ; \
diff --git a/src/doc/book.pamphlet b/src/doc/book.pamphlet
index 7f74c97..4930c49 100644
--- a/src/doc/book.pamphlet
+++ b/src/doc/book.pamphlet
@@ -25004,7 +25004,7 @@ $$
 $$
 \returnType{Type: Record(monthsOld: Integer,gender: String)}
 
-Use \spadfunFrom{delete}{AssociationList} to destructively remove an
+Use \spadfunFrom{delete!}{AssociationList} to destructively remove an
 element of the association list.  Use
 \spadfunFrom{delete}{AssociationList} to return a copy of the
 association list with the element deleted.  The second argument is the
diff --git a/src/doc/spadhelp.pamphlet b/src/doc/spadhelp.pamphlet
index 54ea77c..f0e163d 100644
--- a/src/doc/spadhelp.pamphlet
+++ b/src/doc/spadhelp.pamphlet
@@ -1480,6 +1480,15 @@ parallel      pquit      quit       read       repeat    
 savesystem
 set           show       spool      suchthat   synonym    system     
 syntax        trace      undo       what       while
 
+Available algebra help topics are:
+
+AssociationList   BalancedBinaryTree   BasicOperator
+BinaryExpansion   BinarySearchTree     CardinalNumber
+CartesianTensor   Character            CharacterClass
+CliffordAlgebra   Complex              ContinuedFraction
+CycleIndicators   DeRhamComplex        DecimalExpansion
+
+
 @ 
 
 \section{command history}
diff --git a/src/input/Makefile.pamphlet b/src/input/Makefile.pamphlet
index 34850f2..6a8e7e0 100644
--- a/src/input/Makefile.pamphlet
+++ b/src/input/Makefile.pamphlet
@@ -361,7 +361,12 @@ REGRES= algaggr.regress algbrbf.regress  algfacob.regress 
alist.regress  \
 IN=     ${SRC}/input
 MID=   ${INT}/input
 
-all: ${OUTS} ${ALGEBRA} ${REGRES}
+all: ${OUTS} ${ALGEBRA} ${REGRES} 
+       @ echo 0 starting algebra regression testing
+       @ (cd ${MID} ; \
+         ${TANGLE} -t8 -R"algebra.regress" ${SRC}/algebra/Makefile.pamphlet \
+            >Makefile.algebra ; \
+          make -f Makefile.algebra )
        @ echo 1 finished ${INT}/input
  
 %.input: ${IN}/%.input.pamphlet




reply via email to

[Prev in Thread] Current Thread [Next in Thread]