An Efficient Algorithm for Solving the Dyck-CFL Reachability Problem on Trees

  • Hao Yuan
  • Patrick Eugster
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5502)


The context-free language (CFL) reachability problem is well known and studied in computer science, as a fundamental problem underlying many important static analyses such as points-to-analysis. Solving the CFL reachability problem in the general case is very hard. Popular solutions resorting to a graph traversal exhibit a time complexity of O(k 3 n 3) for a grammar of size k. For Dyck CFLs, a particular class of CFLs, this complexity can be reduced to O(kn 3). Only recently the first subcubic algorithm was proposed by Chaudhuri, dividing the complexity of predating solutions by a factor of logn.

In this paper we propose an effective algorithm for solving the CFL reachability problem for Dyck languages when the considered graph is a bidirected tree with specific constraints. Our solution pre-processes the graph in O(n logn logk) time in a space of O(n logn), after which any Dyck-CFL reachability query can be answered in O(1) time, while a naïve online algorithm will require O(n) time to answer a query or require O(n 2) to store the pre-computed results for all pairs of nodes.


Reachability Problem Recursion Tree Pushdown Automaton Trie Node Pivot Node 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Reps, T.W.: Program analysis via graph reachability. Information & Software Technology 40(11-12), 701–726 (1998)CrossRefGoogle Scholar
  2. 2.
    Rehof, J., Fähndrich, M.: Type-based flow analysis: From polymorphic subtyping to CFL-reachability. In: Proceedings of the 28th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 2001), pp. 54–66 (2001)Google Scholar
  3. 3.
    Sridharan, M., Gopan, D., Shan, L., Bodík, R.: Demand-driven points-to analysis for Java. In: Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA 2005), pp. 59–76 (2005)Google Scholar
  4. 4.
    Sridharan, M., Bodík, R.: Refinement-based context-sensitive points-to analysis for Java. In: Proceedings of the ACM SIGPLAN 2006 Conference on Programming Language Design and Implementation (PLDI 2006), pp. 387–400 (2006)Google Scholar
  5. 5.
    Knuth, D.E.: The art of computer programming, volume III: sorting and searching. Addison-Wesley, Reading (1973)MATHGoogle Scholar
  6. 6.
    Hakimi, S.: Optimum locations of switching center and the absolute center and medians of a graph. Operations Research 12, 450–459 (1964)CrossRefMATHGoogle Scholar
  7. 7.
    Knuth, D.E.: The art of computer programming, volume I: fundamental algorithms. Addison-Wesley, Reading (1973)Google Scholar
  8. 8.
    Yannakakis, M.: Graph-theoretic methods in database theory. In: Proceedings of the 9th ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems (PODS 1990), pp. 230–242 (1990)Google Scholar
  9. 9.
    Reps, T.W., Horwitz, S., Sagiv, S.: Precise interprocedural dataflow analysis via graph reachability. In: Conference Record of the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 1995), pp. 49–61 (1995)Google Scholar
  10. 10.
    Reps, T.W.: Shape analysis as a generalized path problem. In: Proceedings of the ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation (PEPM 1995), pp. 1–11 (1995)Google Scholar
  11. 11.
    Zheng, X., Rugina, R.: Demand-driven alias analysis for C. In: Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2008), pp. 197–208 (2008)Google Scholar
  12. 12.
    Chaudhuri, S.: Subcubic algorithms for recursive state machines. In: Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2008), pp. 159–169 (2008)Google Scholar
  13. 13.
    Arlazarov, V.L., Dinic, E.A., Kronok, M.A., Faradzev, I.A.: On economical construction of the transitive closure of an oriented graph. Soviet Mathematics Doklady 11, 1209–1210 (1970)MATHGoogle Scholar
  14. 14.
    Rytter, W.: Time complexity of loop-free two-way pushdown automata. Inf. Process. Lett. 16(3), 127–129 (1983)MathSciNetCrossRefMATHGoogle Scholar
  15. 15.
    Rytter, W.: Fast recognition of pushdown automaton and context-free languages. Inf. Control 67(1-3), 12–22 (1986)MathSciNetCrossRefMATHGoogle Scholar
  16. 16.
    Alur, R., Benedikt, M., Etessami, K., Godefroid, P., Reps, T.W., Yannakakis, M.: Analysis of recursive state machines. ACM Transactions on Programming Languags and Systems 27(4), 786–818 (2005)CrossRefGoogle Scholar
  17. 17.
    Kodumal, J., Aiken, A.: The set constraint/cfl reachability connection in practice. In: Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2004), pp. 207–218 (2004)Google Scholar
  18. 18.
    Alur, R., Madhusudan, P.: Visibly pushdown languages. In: STOC 2004: Proceedings of the thirty-sixth annual ACM symposium on Theory of computing, pp. 202–211. ACM, New York (2004)CrossRefGoogle Scholar
  19. 19.
    Alur, R.: Marrying words and trees. In: PODS 2007: Proceedings of the twenty-sixth ACM SIGMOD-SIGACT-SIGART symposium on Principles of database systems, pp. 233–242. ACM, New York (2007)CrossRefGoogle Scholar
  20. 20.
    Valiant, L.G.: General context-free recognition in less than cubic time. Journal of Computer and System Sciences 10(2), 308–315 (1975)MathSciNetCrossRefMATHGoogle Scholar
  21. 21.
    Goldman, A.: Optimal center location in a simple network. Transportation Science 5, 212–221 (1971)MathSciNetCrossRefGoogle Scholar
  22. 22.
    Harel, D., Tarjan, R.E.: Fast algorithms for finding nearest common ancestors. SIAM Journal of Computing 13(2), 338–355 (1984)MathSciNetCrossRefMATHGoogle Scholar
  23. 23.
    Bender, M.A., Farach-Colton, M.: The lca problem revisited. In: Proceedings of the 4th Latin American Symposium on Theoretical Informatics, pp. 88–94 (2000)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2009

Authors and Affiliations

  • Hao Yuan
    • 1
  • Patrick Eugster
    • 1
  1. 1.Department of Computer SciencePurdue UniversityUSA

Personalised recommendations