combstruct
gfsolve
solve the system of generating functions associated with a grammar
Calling Sequence
Parameters
Description
Examples
gfsolve(spec, typ, var, tags)
spec
-
combinatorial specification
typ
labeling type; 'labeled' or 'unlabeled'
var
variable to use in the generating functions
tags
(optional) list of lists; each list contains a variable tag followed by the Epsilon nonterminal name(s) associated with that tag
The gfsolve function returns a set containing the generating functions which count the objects described in the specification.
Each nonterminal A, has an associated generating function A⁡z, found by solving the system of generating function equations associated with the specification. If it cannot solve the system, it returns FAIL.
For more information, see combstruct[gfeqns].
If the objects are labeled, exponential generating functions are produced. If the objects are unlabeled, ordinary generating functions are used.
Objects can be marked (tagged) by forming the product of that object with a named Epsilon and associating a tag with that Epsilon. If the tag is a variable name, the resulting generating function has an extra variable that marks that object. The same tag can be associated with more than one Epsilon name. The tag does not need to be a variable.
For information on how to write specifications, see combstruct and combstruct[specification].
with⁡combstruct:
An example of a labeled binary tree.
tree≔L=Atom,N=Atom,T=Union⁡L,Prod⁡N,T,T:
gfsolve⁡tree,labeled,z
L⁡z=z,N⁡z=z,T⁡z=−−1+−4⁢z2+12⁢z
Nonplane ternary trees. Mark the leaf nodes of an unlabeled general tree.
ternary_tree≔G=Union⁡Z,Prod⁡Z,Set⁡G,card=3,labeled:
gfsolve⁡ternary_tree,x
G⁡x=−−3⁢x+9⁢x3−8x⁢x2132⁢x−1−3⁢x+9⁢x3−8x⁢x213−I⁢3⁢−3⁢x+9⁢x3−8x⁢x213x−2−3⁢x+9⁢x3−8x⁢x2132,Z⁡x=x
Mark the leaf nodes of an labeled general tree.
tree1≔L=Prod⁡leaf,Atom,N=Atom,T=Union⁡L,Prod⁡N,Set⁡T,leaf=Ε:
gfsolve⁡tree1,labeled,z,u,leaf
L⁡z,u=u⁢z,N⁡z,u=z,T⁡z,u=u⁢z−LambertW⁡−z⁢ⅇu⁢z,leaf⁡z,u=u
See Also
combstruct[gfeqns]
combstruct[gfseries]
combstruct[specification]
Download Help Document