combstruct
gfseries
return the series of the generating functions associated with a grammar
Calling Sequence
Parameters
Description
Examples
gfseries(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 gfseries function returns a table containing the generating functions, in series form, that count the objects associated with each production in the grammar.
Each nonterminal has an associated equation which uses the nonterminal name as the name of the equation. For example, A⁡z would be the generating function for A.
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 series has an extra variable that marks the object. The same tag can be associated with more than one Epsilon name. The tag does not need to be a variable.
The gfseries function uses the series command to generate the series. Thus, the order of the result is controlled by the Order environment 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:
gfseries⁡tree,labeled,z
table⁡T⁡z=z+z3+2⁢z5+O⁡z7,N⁡z=z,L⁡z=z
Mark the leaf nodes of an unlabeled general tree.
tree1≔L=Prod⁡leaf,Atom,N=Atom,T=Union⁡L,Prod⁡N,Set⁡T,leaf=Ε:
gfseries⁡tree1,unlabeled,z,u,leaf
table⁡L⁡z,u=u⁢z,T⁡z,u=u+1⁢z+u+1⁢z2+u2+2⁢u+2⁢z3+u3+3⁢u2+5⁢u+4⁢z4+u4+4⁢u3+10⁢u2+13⁢u+9⁢z5+O⁡z6,leaf⁡z,u=u,N⁡z,u=z
Order≔10
gfseries⁡tree,unlabeled,z
table⁡T⁡z=z+z3+2⁢z5+5⁢z7+14⁢z9+O⁡z11,N⁡z=z,L⁡z=z
See Also
combstruct[gfeqns]
combstruct[gfsolve]
combstruct[specification]
Download Help Document