Abstract
This paper describes the precise specification, design, analysis, implementation, and measurements of an efficient algorithm for solving regular tree grammar based constraints. The particular constraints are for dead-code elimination on recursive data, but the method used for the algorithm design and complexity analysis is general and applies to other program analysis problems as well. The method is centered around Paige’s finite differencing, i.e., computing expensive set expressions incrementally, and allows the algorithm to be derived and analyzed formally and implemented easily. We propose higher-level transformations that make the derived algorithm concise and allow its complexity to be analyzed accurately. Although a rough analysis shows that the worst-case time complexity is cubic in program size, an accurate analysis shows that it is linear in the number of live program points and in other parameters, including mainly the arity of data constructors and the number of selector applications into whose arguments the value constructed at a program point might flow. These parameters explain the performance of the analysis in practice. Our implementation also runs two to ten times as fast as a previous implementation of an informally designed algorithm.
This work is supported in part by ONR under grants N00014-99-1-0132, N00014-99-1-0358, and N00014-01-1-0109, by NSF under grants CCR-9711253 and CCR-9876058, and by a Motorola University Partnership in Research Grant.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
A. V. Aho, J. E. Hopcroft, and J. D. Ullman. The Design and Analysis of Computer Algorithms. Addison-Wesley, Reading, Mass., 1974.
A. Aiken and B. R. Murphy. Static type inference in a dynamically typed language. In Conference Record of the 18th Annual ACM Symposium on Principles of Programming Languages. ACM, New York, Jan. 1991.
A. Aiken, E. Wimmers, and T. Lakshman. Soft typing with conditional types. In Conference Record of the 21st Annual ACM Symposium on Principles of Programming Languages. ACM, New York, Jan. 1994.
L. Birkedal and M. Welinder. Binding-time analysis for standard ML. In Proceedings of the ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation, Technical Report 94/9, pages 61–71. Department of Computer Science, The University of Melbourne, June 1994.
L. Birkedal and M. Welinder. Binding-time analysis for Standard ML. Lisp and Symbolic Computation, 8(3):191–208, Sept. 1995.
A. Bondorf and J. Jorgensen. Efficient analyses for realistic off-line partial evaluation. Journal of Functional Programming, 3(3):315–346, July 1993.
J. Cai, P. Facon, F. Henglein, R. Paige, and E. Schonberg. Type analysis and data structure selection. In B. M. Poller, editor, Constructing Programs from Specifications, pages 126–164. North-Holland, Amsterdam, 1991.
J. Cai and R. Paige. Program derivation by fixed point computation. Sci. Comput. Program., 11:197–261, Sept. 1988/89.
P. Cousot and R. Cousot. Formal language, grammar and set-constraint-based program analysis by abstract interpretation. In Proceedings of the 7th International Conference on Functional Programming Languages and Computer Architecture, pages 170–181. ACM, New York, June 1995.
N. Dershowitz and E. M. Reingold. Calendrical calculations. Software-Practice and Experience, 20(9):899–928, Sept. 1990.
M. Fähndrich, J. S. Foster, Z. Su, and A. Aiken. Partial online cycle elimination in inclusion constraint graphs. In Proceedings of the ACM SIGPLAN’ 98 Conference on Programming Language Design and Implementation, pages 85–96. ACM, New York, June 1998.
C. Fecht and H. Seidl. Propagating differences: An efficient new fixpoint algorithm for distributive constraint systems. In C. Hankin, editor, Proceedings of the 7th European Symposium on Programming, volume 1381 of Lecture Notes in Computer Science, pages 90–104. Springer-Verlag, Berlin, 1998.
C. Flanagan and M. Felleisen. Componential set-based analysis. ACM Trans. Program. Lang. Syst., 21(2):370–416, Mar. 1999.
F. Gecseg and M. Steinb. Tree Automata. Akademiai Kiado, Budapest, 1984.
D. Goyal. A Language Theoretic Approach to Algorithms. PhD thesis, Department of Computer Science, New York University, Jan. 2000.
N. Heintze. Practical aspects of set based analysis. In K. Apt, editor, Proceedings of the Joint International Conference and Symposium on Logic Programming, pages 765–779. The MIT Press, Cambridge, Mass., Nov. 1992.
N. Heintze. Set-based analysis of ML programs. In Proceedings of the 1994 ACM Conference on LISP and Functional Programming, pages 306–317. ACM, New York, June 1994.
N. Heintze and J. Jaffar. Set constraints and set-based analysis. In Proceedings of the 2nd International Workshop on Principles and Practice of Constraint Programming, volume 874 of Lecture Notes in Computer Science, pages 281–298. Springer-Verlag, Berlin, 1994.
N. Heintze and D. McAllester. Linear-time subtransitive control flow analysis. In Proceedings of the ACM SIGPLAN’ 97 Conference on Programming Language Design and Implementation. ACM, New York, June 1997.
F. Henglein. Efficient type inference for higher-order binding-time analysis. In Proceedings of the 5th International Conference on Functional Programming Languages and Computer Architecture, volume 523 of Lecture Notes in Computer Science, pages 448–472. Springer-Verlag, Berlin, Aug. 1991.
The Internet Scheme Repository. http://www.cs.indiana.edu/scheme-repository/.
N. D. Jones and S. S. Muchnick. Flow analysis and optimization of LISP-like structures. In S. S. Muchnick and N. D. Jones, editors, Program Flow Analysis, pages 102–131. Prentice-Hall, Englewood Cliffs, N.J., 1981.
Y. A. Liu. Efficiency by incrementalization: An introduction. Higher-Order and Symbolic Computation, 13(4):289–313, Dec. 2000.
Y. A. Liu and S. D. Stoller. Dynamic programming via static incrementalization. In Proceedings of the 8th European Symposium on Programming, volume 1576 of Lecture Notes in Computer Science, pages 288–305. Springer-Verlag, Berlin, Mar. 1999.
Y. A. Liu and S.D. Stoller. Eliminating dead code on recursive data. In SAS 1999 [39], pages 211–231.
Y. A. Liu, S. D. Stoller, and T. Teitelbaum. Static caching for incremental computation. ACM Trans. Program. Lang. Syst., 20(3):546–585, May 1998.
Y. A. Liu and T. Teitelbaum. Systematic derivation of incremental programs. Sci. Comput. Program., 24(1):1–39, Feb. 1995.
D. McAllester. On the complexity analysis of static analyses. In SAS 1999 [39], pages 312–329.
T. Mogensen. Separating binding times in language specifications. In Proceedings of the 4th International Conference on Functional Programming Languages and Computer Architecture, pages 12–25. ACM, New York, Sept. 1989.
F. Nielson, H. R. Nielson, and C. Hankin, editors. Principles of Program Analysis. Springer-Verlag, 1999.
R. Paige. Formal Differentiation: A Program Synthesis Technique, volume 6 of Computer Science and Artificial Intelligence. UMI Research Press, Ann Arbor, Michigan, 1981. Revision of Ph.D. dissertation, New York University, 1979.
R. Paige. Programming with invariants. IEEE Software, 3(1):56–69, Jan. 1986.
R. Paige. Real-time simulation of a set machine on a RAM. In Computing and Information, Vol. II, pages 69–73. Canadian Scholars Press, 1989. Proceedings of ICCI ’89: The International Conference on Computing and Information, Toronto, Canada, May 23–27, 1989.
R. Paige and S. Koenig. Finite differencing of computable expressions. ACM Trans. Program. Lang. Syst., 4(3):402–454, July 1982.
J. Rehof. The Complexity of Simple Subtyping Systems. PhD thesis, DIKU, University of Copenhagen, Copenhagen, Denmark, Apr. 1998.
T. Reps and T. Teitelbaum. The Synthesizer Generator: A System for Constructing Language-Based Editors. Springer-Verlag, New York, 1988.
T. Reps and T. Turnidge. Program specialization via program slicing. In O. Danvy, R. Glück, and P. Thiemann, editors, Proceedings of the Dagstuhl Seminar on Partial Evaluation, volume 1110 of Lecture Notes in Computer Science, pages 409–429. Springer-Verlag, Berlin, 1996.
J. C. Reynolds. Automatic computation of data set definitions. In A. J. H. Morrell, editor, Information Processing 68: Proceedings of IFIP Congress 1968, volume 1, pages 456–461. North-Holland, Amsterdam, 1969.
Proceedings of the 6th International Static Analysis Symposium, volume 1694 of Lecture Notes in Computer Science. Springer-Verlag, Berlin, Sept. 1999.
J. T. Schwartz. Optimization of very high level languages-I: Value transmission and its corollaries. Journal of Computer Languages, 1(2): 161–194, 1975.
J. T. Schwartz, R. B. K. Dewar, E. Dubinsky, and E. Schonberg. Programming with Sets: An Introduction to SETL. Springer-Verlag, Berlin, New York, 1986.
W. K. Snyder. The SETL2 Programming Language. Technical report 490, Courant Institute of Mathematical Sciences, New York University, Sept. 1990.
B. Steensgaard. Points-to analysis by type inference of programs with structures and unions. In T. Gyimothy, editor, Proceedings of the 6th International Conference on Compiler Construction, volume 1060 of Lecture Notes in Computer Science, pages 136–150. Springer-Verlag, Berlin, 1996.
B. Steensgaard. Points-to analysis in almost linear time. In Conference Record of the 23rd Annual ACM Symposium on Principles of Programming Languages, pages 32–41. ACM, New York, Jan. 1996.
Z. Su, M. Fähndrich, and A. Aiken. Projection merging: Reducing redundancies in inclusion constraint graphs. In Conference Record of the 27th Annual ACM Symposium on Principles of Programming Languages, pages 81–95. ACM, New York, Jan. 2000.
J. D. Ullman. Principles of Database and Knowledge-Base Systems, volume II. Computer Science Press, New York, 1988.
D. M. Yellin. Speeding up dynamic transitive closure for bounded degree graphs. Acta Informatica, 30(4):369–384, July 1993.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2001 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Liu, Y.A., Li, N., Stoller, S.D. (2001). Solving Regular Tree Grammar Based Constraints. In: Cousot, P. (eds) Static Analysis. SAS 2001. Lecture Notes in Computer Science, vol 2126. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-47764-0_13
Download citation
DOI: https://doi.org/10.1007/3-540-47764-0_13
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-42314-0
Online ISBN: 978-3-540-47764-8
eBook Packages: Springer Book Archive