Computing

, Volume 47, Issue 1, pp 51–67 | Cite as

Uniform random generation of expressions respecting algebraic identities

  • W. J. Gutjahr
Article

Abstract

Algorithms for the uniform random generation of a particular class of formal expressions (containing arithmetical expressions, propositional calculus formulas, tree representations, special algebraic expressions and program structures) are described. “Uniform” means that all non-equivalent expressions of the same size are equiprobable, where equivalence is induced by commutative or associative properties of certain symbols (e.g.“a+b”≡“b+a”). In the special case where no commutative symbols occur, it is shown that the problem can be treated by a modification of Hickey's and Cohen's well known generation algorithm for context-free languages. In order to obtain a speed up in the generation time, a new, parallelizable algorithm is developed, which turns out to be applicable also to the general case (occurrence of commutative symbols).

AMS Subject Classifications

05C 68Q22 68Q45 68R 

Key words

Associativity commutativity enumeration problems generation of expressions generation of trees simply generated families of trees recognizable families of trees uniform random generation 

Uniforme Zufallserzeugung von Ausdrücken unter Beachtung algebraischer Identitäten

Zusammenfassung

Algorithmen zur uniformen Zufallserzeugung einer besonderen Klasse formaler Ausdrücke (die arithmetische Ausdrücke, aussagenlogische Formeln, Baumdarstellungen, spezielle algebraische Ausdrücke und Programmstrukturen umfaßt) werden beschrieben. “Uniform” bedeutet dabei, daß alle nichtäquivalenten Ausdrücke derselben Größe gleich wahrscheinlich sind, wobei Äquivalenz durch kommutative oder assoziative Eigenschaften bestimmter Symbole induziert wird (z.B.“a+b”≡“b+a”). Im Sonderfall der Abwesenheit kommutativer Symbole wird gezeigt, daß das Problem durch eine Modifikation von Hickey's und Cohen's bekanntem Generierungsalgorithmus für kontextfreie Sprachen behandelt werden kann. Um eine Beschleunigung der Generierung zu erreichen, wird ein neuer, parallelisierbarer Algorithmus entwickelt, der sich auch im allgemeinen Fall (Vorkommen kommutativer Symbole) als anwendbar herausstellt.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [1]
    Aho, A. V., Hopcroft, J. E., Ullman, J. D.: The design and analysis of computer algorithms, p. 263. Reading, MA: Addison-Wesley 1978.Google Scholar
  2. [2]
    Aho, A. V., Hopcroft, J. E., Ullman, J. D.: Data structures and algorithms, pp. 80–81, Reading, MA: Addison-Wesley 1983.Google Scholar
  3. [3]
    Devroye, L.: Non-uniform random variate generation, pp. 96–98. Berlin: Springer 1986.Google Scholar
  4. [4]
    Gonzalez, T., Ja'Ja', J.: Evaluation of arithmetic expressions with algebraic identities. SIAM J. Comput.11, 633–662 (1982).Google Scholar
  5. [5]
    Flajolet, Ph., Odlyzko, A.: The average height of binary trees and other simple trees. J. Comp. Syst. Sci.25, 171–213 (1982).Google Scholar
  6. [6]
    Gutjahr, W.: Enumeration of program structures as trees with commutative or associative nodes. J. Comb. Inf. Syst. Sci.12, 13–24 (1987).Google Scholar
  7. [7]
    Harary, F., Palmer, E. M.: Graphical enumeration, pp. 208–214. New York, London: Academic Press 1973.Google Scholar
  8. [8]
    Hickey, T., Cohen, J.: Uniform random generation of strings in a context-free language. SIAM J. Comput.12, 645–655 (1983).Google Scholar
  9. [9]
    Knuth, D. E.: The art of computer programming, Vol. I: Fundamental algorithms, 2nd. ed., pp. 305–422. Reading, MA: Addison-Wesley 1973.Google Scholar
  10. [10]
    Meir, A., Moon, J. W.: On the altidude of nodes in random trees. Can. J. Math.30, 997–1015 (1978).Google Scholar
  11. [11]
    Nijenhuis, A., Wilf, H. S.: Combinatorial algorithms, pp. 77–80. New York, San Francisco, London: Academic Press 1975.Google Scholar
  12. [12]
    Ruskey, F., Proskurowski, A.: Generating binary trees by transpositions. J. of Algorithms11, 68–84 (1990).Google Scholar
  13. [13]
    Sethi, T., Ullman, J. D.: The generation of optimal code for arithmetic expressions. JACM17, 715–728 (1970).Google Scholar
  14. [14]
    Tinhofer, G., Schreck, H.: Linear time tree codes. Computing33, 211–225 (1984).Google Scholar
  15. [15]
    Vouk, M. A.: Back-to-back testing. Inform. Soft. Techn.32, 34–46 (1990).Google Scholar

Copyright information

© Springer-Verlag 1991

Authors and Affiliations

  • W. J. Gutjahr
    • 1
  1. 1.Institut für Statistik und Informatik der Universität WienWienAustria

Personalised recommendations