29.4 Test Series with Polynomial Coefficients

710test polynomial series 707+   (704)  707  711
testTimes1(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from S, Q, T, P, DataStream P;
        v1: V := 1 :: V;
        v2: V := 2 :: V;
        p1: P := power(v1, 1) :: P;
        p2: P := power(v2, 1) :: P;
        geo1: S := stream(power(v1, i)$T :: P for i: I in 0..) :: S;
        geo2: S := stream(power(v2, i)$T :: P for i: I in 0..) :: S;
-- Note that for geo2 the n-th coefficient is of degree 2n.
        s: S := geo1 * geo2;
        assertEquals(P, 1, coefficient(s, 0));
        assertEquals(P, p1+p2, coefficient(s, 1));
        assertEquals(P, p1*p1+p1*p2+p2*p2, coefficient(s, 2));
        p: P := p1*p1*p1+p1*p1*p2+p1*p2*p2+p2*p2*p2;
        assertEquals(P, p, coefficient(s, 3));
}

Uses CycleIndexSeries 330, CycleIndexVariable 329, DataStream 386, I 47, Q 47, SparseDistributedPolynomial 526, and SparseIndexedPowerProduct 506.

Whereas the coefficients of the above test are homogeneous with respect to total degree, the following test groups with respect to weighted degree where each variable xi has weight i.

711test polynomial series 707+   (704)  710  712b
testTimes2(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from S, Q, T, P, DataStream P;
        v1: V := 1 :: V;
        v2: V := 2 :: V;
        p1: P := power(v1, 1) :: P;
        p2: P := power(v2, 1) :: P;
        geo1: S := stream(power(v1, i)$T :: P for i: I in 0..) :: S;
        g: Generator P := generate {
                for i: I in 0.. repeat {
                        yield power(v2, i)$T :: P;
                        yield 0;
                }
        }
        geo2: S := stream(g) :: S;
        s: S := geo1 * geo2;
        assertEquals(P, 1, coefficient(s, 0));
        assertEquals(P, p1, coefficient(s, 1));
        assertEquals(P, p1*p1+p2, coefficient(s, 2));
        assertEquals(P, p1*p1*p1+p1*p2, coefficient(s, 3));
        p: P := p1*p1*p1*p1+p1*p1*p2+p2*p2;
        assertEquals(P, p, coefficient(s, 4));
}

Uses CycleIndexSeries 330, CycleIndexVariable 329, DataStream 386, Generator 617, I 47, Q 47, SparseDistributedPolynomial 526, and SparseIndexedPowerProduct 506.

Let us give an auxiliary function that tests equality of the first few coefficients of two series.

712atest polynomial series auxiliaries 712a  (704)
checkEquals(a1: CycleIndexSeries, a2: CycleIndexSeries): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
        }
        l1: List P := [q for i:I in 0..9 for q in coefficients a1];
        l2: List P := [q for i:I in 0..9 for q in coefficients a2];
        assertEquals(List P, l1, l2);
}

Uses CycleIndexSeries 330, CycleIndexVariable 329, I 47, Q 47, SparseDistributedPolynomial 526, and SparseIndexedPowerProduct 506.
712btest polynomial series 707+   (704)  711  713
testStretch1(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from S, Q, V, T, P, DataStream P;
        local x(i:I): P == power(i :: V, 1) :: P;
        local g(k: I): Generator P == generate {
                yield 1;
                for i: I in 1.. repeat {
                        for j:I in 1..prev k repeat yield 0;
                        yield (i::Z::Q) * x(k*i);
                }
        }
        geo: S := stream(g 1) :: S;
        for k: I in 1..9 repeat checkEquals(stream(g k)::S, stretch(geo, k));
}

Uses CycleIndexSeries 330, CycleIndexVariable 329, DataStream 386, Generator 617, I 47, Q 47, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, and Z 47.
713test polynomial series 707+   (704)  712b  714
testStretch2(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from S, Q, V, T, P, DataStream P;
        local x(i: I): P == power(i :: V, 1) :: P;
        local p(k: I, i:I): P == (i::Z::Q)*x(k*i)*x(k*i) + x(2*k*i);
        local g(k: I): Generator P == generate {
                yield 1;
                for i: I in 1.. repeat {
                        for j:I in 1..prev(2*k) repeat yield 0;
                        yield p(k, i);
                }
        }
        geo: S := stream(g 1) :: S;
        for k: I in 1..9 repeat checkEquals(stream(g k)::S, stretch(geo, k));
}

Uses CycleIndexSeries 330, CycleIndexVariable 329, DataStream 386, Generator 617, I 47, Q 47, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, and Z 47.

Here we check whether for the series

∞∑  xn-
    n
n=1
(195)
the operations stretch(k) and exponentiate commute.
714test polynomial series 707+   (704)  713  715
testStretch3(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from S, I, Z, Q, V, T, P, DataStream P;
        local x(i: I): P == power(i :: V, 1) :: P;
        local g: Generator P := generate {
                yield 0$P; -- constant term
                for n:I in 1.. repeat yield inv(n::Z)*x(n);
        }
        local s: S == stream(g)::S;
        BugWorkaround(S has with {exponentiate: % -> %}){
                for n: I in 1..9 repeat {
                        a1: S := stretch(exponentiate s, n);
                        a2: S := exponentiate stretch(s, n);
                        checkEquals(a1, a2);
                }
        }
}

Uses BugWorkaround 48, CycleIndexSeries 330, CycleIndexVariable 329, DataStream 386, Generator 617, I 47, Q 47, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, and Z 47.

Here we check whether for the series

∞∑  xn-
    n
n=1
(196)
the operations stretch(k) and * commute.
715test polynomial series 707+   (704)  714  716
testStretch4(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from S, I, Z, Q, V, T, P, DataStream P;
        local x(i: I): P == power(i :: V, 1) :: P;
        local g: Generator P := generate {
                yield 0$P; -- constant term
                for n:I in 1.. repeat yield inv(n::Z)*x(n);
        }
        local s: S == g::S;
        for n: I in 1..9 repeat {
                checkEquals(stretch(s * s, n), stretch(s, n) * stretch(s, n));
        }
}

Uses CycleIndexSeries 330, CycleIndexVariable 329, DataStream 386, Generator 617, I 47, Q 47, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, and Z 47.

Let us check whether the cycle index series of the partition species is equal to the cycle index series of the composition of the set species and the non-empty set species.

716test polynomial series 707+   (704)  715  717a
testPartitionViaCompose(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from P, DataStream P;
        cisPartition: S := cycleIndexSeries $ Partition(Z);
        cisSet: S := cycleIndexSeries $ SetSpecies(Z);
        local g: Generator P := generate {
                yield 0$P; -- constant term
                for n:I in 1.. repeat yield coefficient(cisSet, n);
        }
        cisNonEmptySet: S := g::S;
        cisPart: S := compose(cisSet, cisNonEmptySet);
        checkEquals(cisPartition, cisPart);
}

Uses CycleIndexSeries 330, CycleIndexVariable 329, DataStream 386, Generator 617, I 47, Partition 146, Q 47, SetSpecies 117, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, and Z 47.
717atest polynomial series 707+   (704)  716  717b
testRecursive1(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from S, I, Z, Q, V, T, P, DataStream P;
        local x(i: I, e: I): P == power(i :: V, e) :: P;
        b: S := new();
        set!(b, 1 + term(x(1,1),1) * b * b);
        lz: List Integer := [1, 2, 5, 14, 42];
        l1: List P := [(z :: Q) * x(1,i) for i: I in 1.. for z in lz];
        l1 := cons(1, l1);
        l2: List P := [c for p in l1 for c in coefficients b];
        assertEquals(List P, l1, l2);
}

Uses CycleIndexSeries 330, CycleIndexVariable 329, DataStream 386, I 47, Integer 66, Q 47, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, and Z 47.
717btest polynomial series 707+   (704)  717a  719
testRecursive1b(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from S, I, Z, Q, V, T, P, DataStream P;
        local x(i: I, e: I): P == power(i :: V, e) :: P;
        b: S := new();
        set!(b, term(x(1,1),1) + b * b);
        lz: List Integer := [1, 1, 2, 5, 14, 42];
        l1: List P := [(z :: Q) * x(1,i) for i: I in 1.. for z in lz];
        l1 := cons(0, l1);
        l2: List P := [c for p in l1 for c in coefficients b];
        assertEquals(List P, l1, l2);
}

Uses CycleIndexSeries 330, CycleIndexVariable 329, DataStream 386, I 47, Integer 66, Q 47, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, and Z 47.

See testBinaryForests in TestCombinatorialSpecies.

719test polynomial series 707+   (704)  717b  721
testBinaryForests(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from S, I, Z, Q, V, T, P, DataStream P;
        local x(i: I): P == power(i :: V, 1) :: P;
        local x(i: I, e: I): P == power(i :: V, e) :: P;
        -- B(L: LabelType): CS L == Plus(X, Times(B,B))(L) add;
        b: S := new();
        set!(b, term(x(1),1) + b * b);
        --F(L: LabelType): CS L == Compose(SetSpecies, B)(L) add;
        s: S := cycleIndexSeries $ SetSpecies(Z);
        f: S := compose(s, b);
        l1: List P := [
            1,
            x(1),
            (3/2)*x(1,2)+(inv 2)*x(2),
            (19/6)*x(1,3)+(inv 2)*x(1)*x(2)+(inv 3)*x(3),
            (193/24)*x(1,4)+(3/4)*x(1,2)*x(2)+(inv 3)*x(1)*x(3)
              +(5/8)*x(2,2)+(inv 4)*x(4),
            (907/40)*x(1,5)+(19/12)*x(1,3)*x(2)+(inv 2)*x(1,2)*x(3)
              +(5/8)*x(1)*x(2,2)+(inv 4)*x(1)*x(4)+(inv 6)*x(2)*x(3)
              +(inv 5)*x(5),
            (49171/720)*x(1,6)+(193/48)*x(1,4)*x(2)+(19/18)*x(1,3)*x(3)
              +(15/16)*x(1,2)*x(2,2)+(3/8)*x(1,2)*x(4)
              +(inv 6)*x(1)*x(2)*x(3)+(inv 5)*x(1)*x(5)+(61/48)*x(2,3)
              +(inv 8)*x(2)*x(4)+(7/18)*x(3,2)+(inv 6)*x(6),
            (1084483/5040)*x(1,7)+(907/80)*x(1,5)*x(2)
              +(193/72)*x(1,4)*x(3)+(95/48)*x(1,3)*x(2,2)
              +(19/24)*x(1,3)*x(4)+(inv 4)*x(1,2)*x(2)*x(3)
              +(3/10)*x(1,2)*x(5)+(61/48)*x(1)*x(2,3)
              +(inv 8)*x(1)*x(2)*x(4)+(7/18)*x(1)*x(3,2)
              +(inv 6)*x(1)*x(6)+(5/24)*x(2,2)*x(3)+(inv 10)*x(2)*x(5)
              +(inv 12)*x(3)*x(4)+(inv 7)*x(7),
            (9415243/13440)*x(1,8)+(49171/1440)*x(1,6)*x(2)
              +(907/120)*x(1,5)*x(3)+(965/192)*x(1,4)*x(2,2)
              +(193/96)*x(1,4)*x(4)+(19/36)*x(1,3)*x(2)*x(3)
              +(19/30)*x(1,3)*x(5)+(61/32)*x(1,2)*x(2,3)
              +(3/16)*x(1,2)*x(2)*x(4)+(7/12)*x(1,2)*x(3,2)
              +(inv 4)*x(1,2)*x(6)+(5/24)*x(1)*x(2,2)*x(3)
              +(inv 10)*x(1)*x(2)*x(5)+(inv 12)*x(1)*x(3)*x(4)
              +(inv 7)*x(1)*x(7)+(1225/384)*x(2,4)+(5/32)*x(2,2)*x(4)
              +(7/36)*x(2)*x(3,2)+(inv 12)*x(2)*x(6)+(inv 15)*x(3)*x(5)
              +(9/32)*x(4,2)+(inv 8)*x(8),
            (848456353/362880)*x(1,9)+(1084483/10080)*x(1,7)*x(2)
              +(49171/2160)*x(1,6)*x(3)+(907/64)*x(1,5)*x(2,2)
              +(907/160)*x(1,5)*x(4)+(193/144)*x(1,4)*x(2)*x(3)
              +(193/120)*x(1,4)*x(5)+(1159/288)*x(1,3)*x(2,3)
              +(19/48)*x(1,3)*x(2)*x(4)+(133/108)*x(1,3)*x(3,2)
              +(19/36)*x(1,3)*x(6)+(5/16)*x(1,2)*x(2,2)*x(3)
              +(3/20)*x(1,2)*x(2)*x(5)+(inv 8)*x(1,2)*x(3)*x(4)
              +(3/14)*x(1,2)*x(7)+(1225/384)*x(1)*x(2,4)
              +(5/32)*x(1)*x(2,2)*x(4)+(7/36)*x(1)*x(2)*x(3,2)
              +(inv 12)*x(1)*x(2)*x(6)+(inv 15)*x(1)*x(3)*x(5)
              +(9/32)*x(1)*x(4,2)+(inv 8)*x(1)*x(8)+(61/144)*x(2,3)*x(3)
              +(inv 8)*x(2,2)*x(5)+(inv 24)*x(2)*x(3)*x(4)
              +(inv 14)*x(2)*x(7)+(127/162)*x(3,3)+(inv 18)*x(3)*x(6)
              +(inv 20)*x(4)*x(5)+(inv 9)*x(9)
        ];
        l2: List P := [q for p in l1 for q in coefficients f];
        assertEquals(List P, l1, l2);
}

Uses Compose 182a, CycleIndexSeries 330, CycleIndexVariable 329, DataStream 386, I 47, LabelType 62, Plus 166a, Q 47, SetSpecies 117, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, Times 175a, and Z 47.

See testBinaryForest in TestCombinatorialSpecies.

721test polynomial series 707+   (704)  719  723
testBinaryTreesOfSets(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from S, I, Z, Q, V, T, P, DataStream P;
        local x(i: I): P == power(i :: V, 1) :: P;
        local x(i: I, e: I): P == power(i :: V, e) :: P;

        -- B(L: LabelType): CS L == Plus(X, Times(B,B))(L) add;
        b: S := new();
        set!(b, term(x(1),1) + b * b);

        cisSet: S := cycleIndexSeries $ SetSpecies(Z);
        local g: Generator P := generate {
                yield 0$P; -- constant term
                for n:I in 1.. repeat yield coefficient(cisSet, n);
        }
        cisNonEmptySet: S := stream(g)::S;
        --F(L: LabelType): CS L == Compose(B, NonEmpty SetSpecies)(L) add;
        f: S := compose(b, cisNonEmptySet);
        l1: List P := [
            0,
            x(1),
            (3/2)*x(1,2)+(inv 2)*x(2),
            (19/6)*x(1,3)+(3/2)*x(1)*x(2)+(inv 3)*x(3),
            (69/8)*x(1,4)+(19/4)*x(1,2)*x(2)+x(1)*x(3)+(3/8)*x(2,2)
            +(inv 4)*x(4),

            (3211/120)*x(1,5)+(69/4)*x(1,3)*x(2)+(19/6)*x(1,2)*x(3)
            +(19/8)*x(1)*x(2,2)+(3/4)*x(1)*x(4)+(inv 2)*x(2)*x(3)
            +(inv 5)*x(5),

            (21461/240)*x(1,6)+(3211/48)*x(1,4)*x(2)+(23/2)*x(1,3)*x(3)
            +(207/16)*x(1,2)*x(2,2)+(19/8)*x(1,2)*x(4)
            +(19/6)*x(1)*x(2)*x(3)+(3/5)*x(1)*x(5)+(19/48)*x(2,3)
            +(3/8)*x(2)*x(4)+(inv 6)*x(3,2)+(inv 6)*x(6),

            (1581259/5040)*x(1,7)+(21461/80)*x(1,5)*x(2)
            +(3211/72)*x(1,4)*x(3)+(3211/48)*x(1,3)*x(2,2)
            +(69/8)*x(1,3)*x(4)+(69/4)*x(1,2)*x(2)*x(3)
            +(19/10)*x(1,2)*x(5)+(69/16)*x(1)*x(2,3)+(19/8)*x(1)*x(2)*x(4)
            +(19/18)*x(1)*x(3,2)+(inv 2)*x(1)*x(6)+(19/24)*x(2,2)*x(3)
            +(3/10)*x(2)*x(5)+(inv 4)*x(3)*x(4)+(inv 7)*x(7),

            (15316309/13440)*x(1,8)+(1581259/1440)*x(1,6)*x(2)
            +(21461/120)*x(1,5)*x(3)+(21461/64)*x(1,4)*x(2,2)
            +(3211/96)*x(1,4)*x(4)+(3211/36)*x(1,3)*x(2)*x(3)
            +(69/10)*x(1,3)*x(5)+(3211/96)*x(1,2)*x(2,3)
            +(207/16)*x(1,2)*x(2)*x(4)+(23/4)*x(1,2)*x(3,2)
            +(19/12)*x(1,2)*x(6)+(69/8)*x(1)*x(2,2)*x(3)
            +(19/10)*x(1)*x(2)*x(5)+(19/12)*x(1)*x(3)*x(4)
            +(3/7)*x(1)*x(7)+(69/128)*x(2,4)+(19/32)*x(2,2)*x(4)
            +(19/36)*x(2)*x(3,2)+(inv 4)*x(2)*x(6)
            +(inv 5)*x(3)*x(5)+(3/32)*x(4,2)+(inv 8)*x(8),

            (1541641771/362880)*x(1,9)+(15316309/3360)*x(1,7)*x(2)
            +(1581259/2160)*x(1,6)*x(3)+(1581259/960)*x(1,5)*x(2,2)
            +(21461/160)*x(1,5)*x(4)+(21461/48)*x(1,4)*x(2)*x(3)
            +(3211/120)*x(1,4)*x(5)+(21461/96)*x(1,3)*x(2,3)
            +(3211/48)*x(1,3)*x(2)*x(4)+(3211/108)*x(1,3)*x(3,2)
            +(23/4)*x(1,3)*x(6)+(3211/48)*x(1,2)*x(2,2)*x(3)
            +(207/20)*x(1,2)*x(2)*x(5)+(69/8)*x(1,2)*x(3)*x(4)
            +(19/14)*x(1,2)*x(7)+(3211/384)*x(1)*x(2,4)
            +(207/32)*x(1)*x(2,2)*x(4)+(23/4)*x(1)*x(2)*x(3,2)
            +(19/12)*x(1)*x(2)*x(6)+(19/15)*x(1)*x(3)*x(5)
            +(19/32)*x(1)*x(4,2)+(3/8)*x(1)*x(8)+(23/16)*x(2,3)*x(3)
            +(19/40)*x(2,2)*x(5)+(19/24)*x(2)*x(3)*x(4)+(3/14)*x(2)*x(7)
            +(19/162)*x(3,3)+(inv 6)*x(3)*x(6)+(3/20)*x(4)*x(5)
            +(inv 9)*x(9)
        ];
        l2: List P := [q for p in l1 for q in coefficients f];
        assertEquals(List P, l1, l2);
}

Uses Compose 182a, CycleIndexSeries 330, CycleIndexVariable 329, DataStream 386, Generator 617, I 47, LabelType 62, NonEmpty 131a, Plus 166a, Q 47, SetSpecies 117, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, Times 175a, and Z 47.

We now check the cycle index series of the species of rooted trees A whose recursion equation is given by

A = X ⋅(E ∘A )
(197)
where X denotes the singleton species and E the species of sets. The first few terms of this series is explicitly given in Example 3.1.3 in [BLL98].
           2  3 3   x1x2  8  4   2    x1x3
Z A = x1 + x1 + 2x1 + 2 + 3 x1 + x1x2 + 3  + ...
(198)
723test polynomial series 707+   (704)  721  724
testRootedTrees(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from S, I, Z, Q, V, T, P, DataStream P;
        local x(i: I): P == power(i :: V, 1) :: P;
        local x(i: I, e: I): P == power(i :: V, e) :: P;

        -- A(L: LabelType): CS L == Times(X, Compose(SetSpecies, A))(L) add;
        cisSet: S := cycleIndexSeries $ SetSpecies(Z);
        a: S := new();
        set!(a, term(x(1),1) * compose(cisSet, a));
        l1: List P := [
            0,
            x(1),
            x(1,2),
            (3/2)*x(1,3)+(inv 2)*x(1)*x(2),
            (8/3)*x(1,4)+x(1,2)*x(2)+(inv 3)*x(1)*x(3)
        ];
        l2: List P := [q for p in l1 for q in coefficients a];
        assertEquals(List P, l1, l2);
}

Uses Compose 182a, CycleIndexSeries 330, CycleIndexVariable 329, DataStream 386, I 47, LabelType 62, Q 47, SetSpecies 117, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, Times 175a, and Z 47.
724test polynomial series 707+   (704)  723  725
testSetSpeciesSeries(): () == {
        import from SetSpecies Z;
        cis: CycleIndexSeries := cycleIndexSeries;

        ogs: OrdinaryGeneratingSeries := isomorphismTypeGeneratingSeries;
        ogs2 := cis :: OrdinaryGeneratingSeries;
        lz1: List Z := [z for i:I in 0..9 for z in coefficients ogs];
        lz2: List Z := [z for i:I in 0..9 for z in coefficients ogs2];
        assertEquals(List Z, lz1, lz2);

        egs: ExponentialGeneratingSeries := generatingSeries;
        egs2 := cis :: ExponentialGeneratingSeries;
        lq1: List Q := [q for i:I in 0..9 for q in coefficients egs];
        lq2: List Q := [q for i:I in 0..9 for q in coefficients egs2];
        assertEquals(List Q, lq1, lq2);
}

Uses CycleIndexSeries 330, ExponentialGeneratingSeries 316, I 47, OrdinaryGeneratingSeries 311, Q 47, SetSpecies 117, and Z 47.
725test polynomial series 707+   (704)  724  726
testPartitionSeriesCoercion(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        cisSet: S := cycleIndexSeries $ SetSpecies(Z);
        local g: Generator P := generate {
                yield 0$P; -- constant term
                d := cisSet :: DataStream P;
                for p in elements(d, 1) repeat yield p;
        }
        cisNonEmptySet: S := g :: S;
        cis: S := compose(cisSet, cisNonEmptySet);
        ogs := cis :: OrdinaryGeneratingSeries;
        ol1: List Z := [1,1,2,3,5,7,11,15,22,30,42,56,77,101,135];
        ol2: List Z := [z for zz in ol1 for z in coefficients ogs];
        assertEquals(List Z, ol1, ol2);

        egs := cis :: ExponentialGeneratingSeries;
        el1: List Z := [1,1,2,5,15,52,203,877,4140,21147,115975];
        el2: List Z := [count(egs, n) for n:I in 0.. for z in el1];
        assertEquals(List Z, el1, el2);
}

Uses CycleIndexSeries 330, CycleIndexVariable 329, DataStream 386, ExponentialGeneratingSeries 316, Generator 617, I 47, OrdinaryGeneratingSeries  311, Q 47, SetSpecies 117, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, and Z 47.
726test polynomial series 707+   (704)  725  727
testAut(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from Z, Q, V, T, S;
        local t(i: I, e: I): T == power(i :: V, e);
        assertEquals(Z, 1, aut 1);
        assertEquals(Z, 1, aut t(1,1));
        assertEquals(Z, 2, aut t(2,1));
        assertEquals(Z, 8, aut t(2,2));
        assertEquals(Z, 18, aut t(3,2));
        assertEquals(Z, 24*162*50, aut(t(1,4)*t(3,3)*t(5,2)));
}

Uses CycleIndexSeries 330, CycleIndexVariable 329, I 47, Q 47, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, and Z 47.
727test polynomial series 707+   (704)  726
testSetSpeciesCoefficients(): () == {
        macro {
                V == CycleIndexVariable;
                T == SparseIndexedPowerProduct(V, I);
                P == SparseDistributedPolynomial(Q, V, T);
                S == CycleIndexSeries;
        }
        import from Z, Q, V, T, P;
        local t(i: I, e: I): T == power(i :: V, e);
        local x(i: I, e: I): P == t(i, e) :: P;
        s: S := cycleIndexSeries $ SetSpecies(Z);
        a: Array P := [
            1,
            x(1,1),
            inv(2)*(x(2,1)+x(1,2)),
            (inv 6)*x(1,3) + (inv 2)*x(1,1)*x(2,1) + (inv 3)*x(3,1),
            inv(24)*x(1,4)+inv(4)*x(1,2)*x(2,1)+inv(3)*x(1,1)*x(3,1)
              +inv(8)*x(2,2)+inv(4)*x(4,1)
        ];
        assertEquals(P, a.0, coefficient(s, 0));
        assertEquals(P, a.1, coefficient(s, 1));
        assertEquals(P, a.2, coefficient(s, 2));
        assertEquals(P, a.3, coefficient(s, 3));
        assertEquals(Q, 1,     coefficient(s, 1$T));
        assertEquals(Q, 1,     coefficient(s, t(1,1)));
        assertEquals(Q, inv 2, coefficient(s, t(1,2)));
        assertEquals(Q, inv 6, coefficient(s, t(1,3)));
        assertEquals(Q, inv 2, coefficient(s, t(2,1)));
        assertEquals(Q, inv 3, coefficient(s, t(3,1)));
        assertEquals(Q, inv 2, coefficient(s, t(1,1)*t(2,1)));
        assertEquals(Z, 1, count(s, t(1,1)*t(2,1)));
        assertEquals(Q, inv 8, coefficient(s, t(2,2)));
        assertEquals(Z, 1, count(s, t(2,2)));
        assertEquals(Q, inv 3, coefficient(s, t(1,1)*t(3,1)));
        assertEquals(Z, 1, count(s, t(1,1)*t(3,1)));
}

Uses Array 599, CycleIndexSeries 330, CycleIndexVariable 329, I 47, Q 47, SetSpecies 117, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, and Z 47.