## Description

A Java program was developed which, given a regular grammar G with N variables { V₁, V₂, ... N } of which V₁ is the grammar's start symbol, determines the distribution of word lengths in the corresponding regular language L(G). The program first constructs, by a simple transformation on the grammar G , a system E(G) of N equations which implicitly define the functions { V₁(x), V₂(x), ... N(x), } , where Vk(x) is the ordinary generating function for the set of lengths of words derivable from the variable Vk in G. The system of equations E(G) is then transformed into a matrix equation over the ring of rational functions, the solution of which yields an explicit rational function representation for V₁(x). The number of words of length m in L(G) is then the coefficient of the xm term in the expansion of V₁(x) as a formal power series in x.