{VERSION 2 3 "DEC ALPHA UNIX" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 256 "times" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 263 "times" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Courier" 1 14 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Tex t Output" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 }1 0 0 0 6 6 0 0 0 0 0 0 -1 0 }{PSTYLE "Warning" 2 7 1 {CSTYLE "" -1 -1 "" 0 1 0 0 255 1 0 0 0 0 0 0 1 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Error" 7 8 1 {CSTYLE "" -1 -1 "" 0 1 255 0 255 1 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "" 11 12 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 } 1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }{PSTYLE "R3 Font 0" -1 256 1 {CSTYLE "" -1 -1 "Courier" 1 12 0 0 0 0 2 2 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 2 " -1 257 1 {CSTYLE "" -1 -1 "Courier" 1 14 0 0 0 0 2 2 2 0 0 0 0 0 0 } 0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 3" -1 258 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 4" -1 259 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "R3 Font 5" -1 260 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 6" -1 261 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 7" -1 262 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 8" -1 263 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R 3 Font 9" -1 264 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 2 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 10" -1 265 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 0 1 1 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 267 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE " " 0 268 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 272 1 {CSTYLE "" -1 -1 "ti mes" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "" 0 273 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 274 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 275 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 277 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 278 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE " " 0 279 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 281 1 {CSTYLE "" -1 -1 "ti mes" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "" 0 283 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 284 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 285 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 287 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 289 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE " " 0 291 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 292 1 {CSTYLE "" -1 -1 "ti mes" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "" 0 293 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 294 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 296 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 297 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 298 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE " " 0 300 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 301 1 {CSTYLE "" -1 -1 "ti mes" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "" 0 302 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 304 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 306 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0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E "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 338 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 339 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE " " 0 346 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 347 1 {CSTYLE "" -1 -1 "ti mes" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "" 0 349 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 351 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 352 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 354 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 356 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE " " 0 358 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 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0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 393 1 {CSTYLE "" -1 -1 "times" 1 12 0 0 0 0 0 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 18 394 1 {CSTYLE "" -1 -1 "times" 1 24 0 0 0 0 0 0 2 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 394 "" 0 "" {TEXT -1 52 "Introduction to the Comb inatorial Structures Package" }}{PARA 267 "" 0 "" {TEXT -1 1374 "\nThe combinatorial structures package, combstruct, is used to define and m anipulate combinatorial structures.\n\nWith combstruct, you may define a combinatorial class of objects, generate uniformly at random object s belonging to that class, and count the number of objects of a given \+ size. For certain common structures which have been pre-defined in th e system, it is also possible to create an iterator which will travers e all the objects in the given class, and to list all such objects at \+ once.\n\nThere are two main portions to combstruct - the facility to d efine your own structures using a grammar, and using the pre-defined s tructures provided by the system.\n\nNote: The pre-defined structures portion of combstruct provides an extension of the functions in the c ombinat package involving combinations, permutations, partitions, comp ositions and subsets. The combstruct functions do everything these fu nctions do, and more (in some cases, much more), as well as providing \+ a consistent interface in terms of function names and syntax.\n\nThis \+ worksheet is a fairly detailed explanation of how to use combstruct. \+ A companion worksheet describes some of the uses of the package. The \+ help pages give a shorter overview. In particular, refer to the help f or combstruct, combstruct[specification] and combstruct[structures].\n \nFirst, define the combstruct package functions.\n" }}{PARA 268 "> " 0 "" {MPLTEXT 1 0 17 "with(combstruct);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#7.%+allstructsG%&countG%%drawG%)finishedG%'gfeqnsG%)gfseriesG%(g fsolveG%,iterstructsG%+nextstructG%,prog_gfeqnsG%.prog_gfseriesG%-prog _gfsolveG" }}}{SECT 0 {PARA 3 "" 0 "" {TEXT 256 22 "Grammar Specificat ions" }}{EXCHG {PARA 272 "" 0 "" {TEXT -1 825 "The strength of this sy stem is in the ability to define your own combinatorial structures. A \+ combinatorial class is defined by writing a grammar specification that describes it. In this way, an extensive collection of different clas ses may be defined. For example, the system applies to all regular an d context-free grammars, grammars to define binary trees, plane genera l trees, necklaces, functional graphs, expression trees etc. All gram mar specifications may be labelled or unlabelled. \n\nGrammar specifi cations are written using Atom, Epsilon, and the constructors Union, P rod, Set (multi-set: repetition of elements is allowed), Sequence, Cyc le and Subst (substitution).\n\nOnce you have a grammar specification, you may draw objects of a given size, uniformly at random, or count t he number of objects of that size.\n\n" }}{PARA 273 "" 0 "" {TEXT 257 14 "Union and Prod" }}{PARA 274 "" 0 "" {TEXT -1 159 "\nFor a very sim ple example, let's look at binary trees. We define a specification fo r a binary tree using the constructors for unions and product as follo ws:\n" }}{PARA 275 "> " 0 "" {MPLTEXT 1 0 33 "sys := \{B = Union(Z, Pr od(B,B))\};" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%$sysG<#/%\"BG-%&Union G6$%\"ZG-%%ProdG6$F'F'" }}}{EXCHG {PARA 277 "" 0 "" {TEXT -1 179 "A bi nary tree is either a single leaf, Z, for the tree of size 1, or (the \+ Union gives the 'or') it is made up of two (smaller) binary trees join ed together (by Prod) at the root.\n" }}{PARA 278 "" 0 "" {TEXT -1 84 "We can generate binary trees of size 5 uniformly at random using the \+ function draw.\n" }}{PARA 279 "> " 0 "" {MPLTEXT 1 0 23 "draw([B, sys] , size=5);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%%ProdG6$-F$6$-F$6$%\"Z G-F$6$F*F*F*F*" }}}{EXCHG {PARA 281 "> " 0 "" {MPLTEXT 1 0 23 "draw([B , sys], size=5);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%%ProdG6$-F$6$%\" ZGF(-F$6$F(F&" }}}{EXCHG {PARA 283 "" 0 "" {TEXT -1 1 "\n" }{TEXT 258 23 "Labelled and Unlabelled" }}{PARA 284 "" 0 "" {TEXT -1 196 "\nBy de fault, structures are unlabelled, so atoms are not distinguishable.\nA ny specification can also be treated as labelled.\n\nThe same specific ation can be used to generate labelled binary trees.\n" }}{PARA 285 "> " 0 "" {MPLTEXT 1 0 34 "count([B, sys, labelled], size=5);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"%!o\"" }}}{EXCHG {PARA 287 "> " 0 "" {MPLTEXT 1 0 33 "draw([B, sys, labelled], size=5);" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#-%%ProdG6$-F$6$-F$6$&%\"ZG6#\"\"%&F+6#\"\"#&F+6#\"\"& -F$6$&F+6#\"\"$&F+6#\"\"\"" }}}{EXCHG {PARA 289 "> " 0 "" {MPLTEXT 1 0 36 "count([B, sys, unlabelled], size=5);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#9" }}}{EXCHG {PARA 291 "" 0 "" {TEXT -1 1 "\n" } {TEXT 259 16 "Atom and Epsilon" }}{PARA 292 "" 0 "" {TEXT -1 182 "\nZ \+ is an atom that is built into the system. Other atoms can be defined \+ in a grammar specification. For example, we can define a necklace that has beads of three different colours.\n" }}{PARA 293 "> " 0 "" {MPLTEXT 1 0 75 "necklace := \{N=Cycle(Union(red,blue,green)),red=Atom ,blue=Atom,green=Atom\}:" }}}{EXCHG {PARA 294 "> " 0 "" {MPLTEXT 1 0 39 "draw([N,necklace,unlabelled], size=10);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%&CycleG6,%%blueGF&F&F&%&greenGF&F'F&%$redGF'" }}} {EXCHG {PARA 296 "" 0 "" {TEXT -1 167 "\nAll atoms have weight one. T he object Epsilon has weight 0. Our previous definition of a binary t ree did not allow for the empty tree. This new definition does. \n" }}{PARA 297 "> " 0 "" {MPLTEXT 1 0 55 "tree := \{T = Union(Epsilon, B) , B=Union(Z, Prod(Z,Z))\}:" }}}{EXCHG {PARA 298 "> " 0 "" {MPLTEXT 1 0 36 "draw([T, tree, unlabelled], size=0);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%(EpsilonG" }}}{EXCHG {PARA 300 "" 0 "" {TEXT -1 403 " \n(That's not the letter \"E\", that's how Maple prints a capital Epsi lon.) Like atoms, you can give different names to Epsilon. This is par ticularly useful to tag smaller components of an overall structure. F or example, to model series and parallel circuits of resistors, a para llel circuit is made up of two or more resistors in series, and a seri es circuit is made up of two or more parallel circuits.\n" }}{PARA 301 "> " 0 "" {MPLTEXT 1 0 90 "circuit :=\{C=Union(P,S,R), P=Set(Union (S,R),card>=2), \nS=Set(Union(P,R),card>=2), R=Atom\}:" }}}{EXCHG {PARA 302 "> " 0 "" {MPLTEXT 1 0 36 "count([C,circuit,labelled], size= 5);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"$s%" }}}{EXCHG {PARA 304 "> \+ " 0 "" {MPLTEXT 1 0 35 "draw([C,circuit,labelled], size=5);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%$SetG6$-F$6$&%\"RG6#\"\"$&F)6#\"\"&-F$6$&F )6#\"\"%-F$6$&F)6#\"\"#&F)6#\"\"\"" }}}{EXCHG {PARA 306 "" 0 "" {TEXT -1 309 "\nEach set contains (sub) circuits made up of one or more resi stors. From this result, we cannot know which sub-circuits are joined \+ in parallel and which are joined in series, because of the symmetry in their definitions. So we rewrite the grammar, adding an Epsilon tag \+ to each portion of the specification.\n" }}{PARA 307 "> " 0 "" {MPLTEXT 1 0 135 "circuit2 :=\{C=Union(P,S,R), P=Prod(par,Set(Union(S, R),card>=2)),\nS=Prod(ser,Set(Union(P,R),card>=2)), R=Atom, par=Epsilo n,ser=Epsilon\}:" }}}{EXCHG {PARA 308 "> " 0 "" {MPLTEXT 1 0 36 "count ([C,circuit2,labelled],size=5);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"$ s%" }}}{EXCHG {PARA 310 "> " 0 "" {MPLTEXT 1 0 35 "draw([C,circuit2,la belled],size=5);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%%ProdG6$%$parG-% $SetG6$&%\"RG6#\"\"$-F$6$%$serG-F(6$&F+6#\"\"%-F$6$F&-F(6$&F+6#\"\"#-F $6$F0-F(6$&F+6#\"\"&&F+6#\"\"\"" }}}{EXCHG {PARA 312 "" 0 "" {TEXT -1 261 "\nMembers of the sets that are associated with the tag \"par\" vi a a product are joined together in parallel, and those marked with the tag \"ser\" are joined together in series. Because Epsilon has weigh t 0, we have not changed the number of objects of each size.\n" }} {PARA 313 "" 0 "" {TEXT 260 23 "Set, Cycle and Sequence" }}{PARA 314 " " 0 "" {TEXT -1 204 "\nAs shown in the above example, you may specifiy the cardinality of a set (here, we insisted that all circuits have at least two resistors). You may also specify the cardinality of cycles and sequences.\n" }}{PARA 315 "> " 0 "" {MPLTEXT 1 0 51 "count([M, \{ M=Set(Z, card > 8)\}, labelled], size=7);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"!" }}}{EXCHG {PARA 317 "> " 0 "" {MPLTEXT 1 0 48 "d raw([A, \{A=Cycle(Z, card=4)\},labelled],size=4);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%&CycleG6&&%\"ZG6#\"\"\"&F'6#\"\"%&F'6#\"\"#&F'6#\"\"$ " }}}{EXCHG {PARA 319 "> " 0 "" {MPLTEXT 1 0 49 "count([A, \{A=Cycle(Z , card=4)\},labelled],size=3);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\" !" }}}{EXCHG {PARA 321 "> " 0 "" {MPLTEXT 1 0 69 "draw([S, \{S=Sequenc e(Set(Z, card>0), card <=10)\}, labelled], size=6);" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#-%)SequenceG6&-%$SetG6$&%\"ZG6#\"\"#&F*6#\"\"%-F'6#&F *6#\"\"\"-F'6#&F*6#\"\"$-F'6$&F*6#\"\"'&F*6#\"\"&" }}}{EXCHG {PARA 323 "> " 0 "" {MPLTEXT 1 0 58 "count([S, \{S=Sequence(Z, card <=10)\}, labelled], size=13);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"!" }}} {EXCHG {PARA 325 "> " 0 "" {MPLTEXT 1 0 57 "draw([S, \{S=Sequence(Z, c ard <=10)\}, labelled], size=13);" }}{PARA 8 "" 1 "" {TEXT -1 69 "Erro r, (in combstruct/drawgrammar) there is no structure of this size" }}} {EXCHG {PARA 327 "" 0 "" {TEXT 261 5 "Subst" }}{PARA 328 "" 0 "" {TEXT -1 586 "\nSubst is a mechanism that allows the substition of all the atoms of one object by another object. Subst(A,B) means take a B- object, and for every atom in that object, replace the atom with an A- object. We can use Subst to write a recursive definition of 2-3 trees . A 2-3 tree is a tree that has all its leaves at the same level, and every internal vertex has either two or three children. We define ou r tree by saying that it is either a single leaf, or it is a 2-3 tree \+ with each of the leaves replaced by an internal vertex with 2 children or an internal vertex with 3 children. \n" }}{PARA 329 "> " 0 "" {MPLTEXT 1 0 64 "t23 := \{T = Union(Z, Subst(Union(Prod(Z,Z), Prod(Z,Z ,Z)), T)) \}:" }}}{EXCHG {PARA 330 "> " 0 "" {MPLTEXT 1 0 24 "draw([T, t23], size=11);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%%ProdG6$-F$6$-F$ 6$%\"ZGF*-F$6%F*F*F*-F$6$F+F+" }}}{EXCHG {PARA 332 "" 0 "" {TEXT -1 0 "" }}{PARA 333 "" 0 "" {TEXT 262 19 "Manipulating Output" }}{PARA 334 "" 0 "" {TEXT -1 286 "\nThe object returned by draw is a maple object \+ which can be manipulated with other commands. This is particularly us eful to change the result from its very general form to one more suite d to the particular problem.\n\nFor example, say we wish to generate w ords of the form C = (a C b) *\n" }}{PARA 335 "> " 0 "" {MPLTEXT 1 0 53 "sys := \{ C=Sequence( Prod(a, C, b)), a=Atom, b=Atom\}:" }}} {EXCHG {PARA 336 "> " 0 "" {MPLTEXT 1 0 22 "draw([C,sys], size=6);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#-%)SequenceG6#-%%ProdG6%%\"aG-F$6$-F'6 %F)%(EpsilonG%\"bGF,F/" }}}{EXCHG {PARA 338 "" 0 "" {TEXT -1 233 "\nHe re, Epsilon means that the empty sequence was chosen. All we really wa nt is a string of a's and b's. The draw command gave more information \+ about the derivation structure than is needed in this case. So we the n do the following.\n" }}{PARA 339 "> " 0 "" {MPLTEXT 1 0 70 "eval(sub s(Prod=( ()->args ), Sequence=( ()->args ), Epsilon=NULL, \"));" }} {PARA 11 "" 1 "" {XPPMATH 20 "6(%\"aGF#%\"bGF#F$F$" }}}}{SECT 0 {PARA 3 "" 0 "" {TEXT 263 22 "Pre-Defined Structures" }}{EXCHG {PARA 346 "" 0 "" {TEXT -1 627 "Certain combinatorial structures are common enough \+ that they merit specialized algorithms rather than using the very gene ral methods obtained with grammars. The structures that are pre-define d in the combstruct system are:\n\nCombination (also called Subset) - \+ combinations of elements\nPermutation - permutations of elements\nPart ition - integer partitions (split into summands, order does not matte r)\nComposition - integer compositions (split into summands, order mat ters)\n\nThe functions that understand these structures are:\ndraw\nco unt\nallstructs\niterstructs\n\nLike structures defined by a grammar, \+ you may draw and count them.\n" }}{PARA 347 "> " 0 "" {MPLTEXT 1 0 43 "draw(Combination(\{a,b,c,d,e,f,g\}), size=5);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#<'%\"aG%\"fG%\"dG%\"eG%\"gG" }}}{EXCHG {PARA 349 "> " 0 "" {MPLTEXT 1 0 30 "count(Partition(95), size=40);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"'o2X" }}}{EXCHG {PARA 351 "" 0 "" {TEXT -1 1045 " \nAll the functions that manipulate these structures have the same syn tax. As in manipulating structures defined by grammars, the first arg ument to the function is a definition of the structure, and the second is the size. Here, the structure is defined by Structure(structure a rguments), where the structure arguments depend on the structure. Thu s Partition and Composition require integers, whereas Combination and \+ Permutation will accept lists, sets or integers (in which case the int eger n is treated to mean \{1,...,n\} for Combination and [1,...,n] fo r Permutation).\n\nEach structure has a default size associated with i t, so when no size is specified, the function will make the most natur al assumption for the structure. Also, instead of giving an integer a s a size, the string 'allsizes' may be specified, saying that the stru cture should be chosen from all possible sizes of the object defined. \+ ('allsizes' is the default for all structures except Permutation, whe re the default is the number of elements in the list to be permuted.) \n" }}{PARA 352 "> " 0 "" {MPLTEXT 1 0 35 "draw(Combination(\{a,b,c,d, e,f,g\}));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#<#%\"fG" }}}{EXCHG {PARA 354 "> " 0 "" {MPLTEXT 1 0 22 "draw(Permutation(42));" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#7L\"\"(\"#N\"#D\"#=\"#;\"#R\"#J\"#Q\"#>\"#L \"\"&\"#G\"#M\"#E\"\"%\"#H\"#7\"\"'\"#B\"#K\"\"#\"#<\"#8\"\"*\"#C\"#: \"#?\"#A\"#S\"\"$\"#5\"\"\"\"#T\"\")\"#P\"#I\"#O\"#U\"#9\"#6\"#@\"#F" }}}{EXCHG {PARA 356 "> " 0 "" {MPLTEXT 1 0 38 "draw(Permutation(16),si ze='allsizes');" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7'\"\"#\"\"(\"#7\"# ;\"#:" }}}{EXCHG {PARA 358 "> " 0 "" {MPLTEXT 1 0 22 "draw(Composition (32));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7-\"\"'\"\"$\"\"#\"\"%F&F'\" \"\"F%F(F%F%" }}}{EXCHG {PARA 360 "" 0 "" {TEXT -1 83 "\nThe function \+ allstructs is used to generate all the structures of a given size. \n " }}{PARA 361 "> " 0 "" {MPLTEXT 1 0 27 "allstructs(Combination(4));" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#<2<#\"\"\"<\"<&F%\"\"#\"\"$\"\"%<%F( F)F*<#F(<$F%F(<#F)<$F%F)<$F(F)<%F%F(F)<%F%F(F*<#F*<$F%F*<$F(F*<$F)F*<% F%F)F*" }}}{EXCHG {PARA 363 "> " 0 "" {MPLTEXT 1 0 42 "allstructs(Perm utation([a,a,b,c]),size=3);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#7.7%%\" aGF%%\"bG7%F%F%%\"cG7%F%F&F%7%F%F&F(7%F%F(F%7%F%F(F&7%F&F%F%7%F&F%F(7% F&F(F%7%F(F%F%7%F(F%F&7%F(F&F%" }}}{EXCHG {PARA 365 "> " 0 "" {MPLTEXT 1 0 25 "allstructs(Partition(4));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7'7&\"\"\"F%F%F%7%F%F%\"\"#7$F'F'7$F%\"\"$7#\"\"%" }}} {EXCHG {PARA 367 "> " 0 "" {MPLTEXT 1 0 27 "allstructs(Composition(6)) ;" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#7B7$\"\"\"\"\"&7$\"\"$F(7$\"\"#\" \"%7$F+F*7$F&F%7#\"\"'7%F*F%F(7%F%F*F(7%F(F%F*7%F*F*F*7%F%F(F*7%F*F(F% 7%F%F+F%7%F+F%F%7%F(F*F%7&F%F(F%F%7&F*F*F%F%7&F(F%F%F%7&F*F%F*F%7&F%F* F*F%7&F%F%F(F%7%F%F%F+7(F%F%F%F%F%F%7'F*F%F%F%F%7'F%F%F%F%F*7'F%F%F*F% F%7'F%F*F%F%F%7'F%F%F%F*F%7&F%F%F%F(7&F%F%F*F*7&F%F*F%F*7&F*F%F%F*" }} }{EXCHG {PARA 369 "" 0 "" {TEXT -1 207 "\nThe function iterstructs cre ates a mechanism to generate all the structures of a given size, one a t a time. The functions nextstruct and finished are used to manipula te the table returned by iterstructs.\n" }}{PARA 370 "> " 0 "" {MPLTEXT 1 0 64 "it := iterstructs(Combination([apple, orange, banana] ), size=2):" }}}{EXCHG {PARA 371 "> " 0 "" {MPLTEXT 1 0 44 "while not \+ finished(it) do nextstruct(it) od;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6# 7$%&appleG%'bananaG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7$%&appleG%'ora ngeG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7$%'bananaG%'orangeG" }}} {EXCHG {PARA 375 "> " 0 "" {MPLTEXT 1 0 51 "it := iterstructs(Permutat ion(3), size='allsizes'):" }}}{EXCHG {PARA 376 "> " 0 "" {MPLTEXT 1 0 44 "while not finished(it) do nextstruct(it) od;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7#\"\"\"" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#7#\"\"#" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7#\"\"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7$\"\"\"\"\"#" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#7$\"\"#\"\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7$\"\"\"\"\"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7$\"\" $\"\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7$\"\"#\"\"$" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#7$\"\"$\"\"#" }}{PARA 11 "" 1 "" {XPPMATH 20 "6# 7%\"\"\"\"\"#\"\"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%\"\"#\"\"\"\" \"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%\"\"$\"\"\"\"\"#" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%\"\"\"\"\"$\"\"#" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7%\"\"#\"\"$\"\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7 %\"\"$\"\"#\"\"\"" }}}{EXCHG {PARA 393 "" 0 "" {TEXT -1 148 "\nYou may add your own specialized structures into the combstruct system. Deta ils on how to do this are in the help page for combstruct[structures]. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}}{MARK "0 2 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }