Skip to main content

Pattern Eliminating Transformations

  • Conference paper
  • First Online:
Logic-Based Program Synthesis and Transformation (LOPSTR 2020)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 12561))

Abstract

Program transformation is a common practice in computer science, and its many applications can have a range of different objectives. For example, a program written in an original high level language could be either translated into machine code for execution purposes, or towards a language suitable for formal verification. Such compilations are split into several so-called passes which generally aim at eliminating certain constructions of the original language to get a program in some intermediate languages and finally generate the target code. Rewriting is a widely established formalism to describe the mechanism and the logic behind such transformations. In a typed context, the underlying type system can be used to give syntactic guarantees on the shape of the results obtained after each pass, but this approach could lead to an accumulation of auxiliary types that should be considered. We propose in this paper a less intrusive approach based on simply annotating the function symbols with the (anti-)patterns the corresponding transformations are supposed to eliminate. We show how this approach allows one to statically check that the rewrite system implementing the transformation is consistent with the annotations and thus, that it eliminates the respective patterns.

This work is partially supported by the project ANR-16-CE25-0007 FORMEDICIS.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 64.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 84.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    The source code can be downloaded from http://github.com/plermusiaux/pfree_check and the online version is available at http://htmlpreview.github.io/?https://github.com/plermusiaux/pfree_check/blob/webnix/out/index.html.

References

  1. Alur, R., Cerný, P.: Streaming transducers for algorithmic verification of single-pass list-processing programs. In: ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2011, pp. 599–610. ACM (2011). https://doi.org/10.1145/1926385.1926454

  2. Alur, R., Filiot, E., Trivedi, A.: Regular transformations of infinite strings. In: IEEE Symposium on Logic in Computer Science, LICS 2012, pp. 65–74. IEEE Computer Society (2012). https://doi.org/10.1109/LICS.2012.18

  3. Arts, T., Giesl, J.: Termination of term rewriting using dependency pairs. Theoret. Comput. Sci. 236(1–2), 133–178 (2000). https://doi.org/10.1016/S0304-3975(99)00207-8

    Article  MathSciNet  MATH  Google Scholar 

  4. Baader, F., Nipkow, T.: Term Rewriting and All That. Cambridge University Press, Cambridge (1998)

    Book  Google Scholar 

  5. Balland, E., Brauner, P., Kopetz, R., Moreau, P.-E., Reilles, A.: Tom: piggybacking rewriting on Java. In: Baader, F. (ed.) RTA 2007. LNCS, vol. 4533, pp. 36–47. Springer, Heidelberg (2007). https://doi.org/10.1007/978-3-540-73449-9_5

    Chapter  Google Scholar 

  6. Barthe, G., Frade, M.J.: Constructor subtyping. In: Swierstra, S.D. (ed.) ESOP 1999. LNCS, vol. 1576, pp. 109–127. Springer, Heidelberg (1999). https://doi.org/10.1007/3-540-49099-X_8

    Chapter  Google Scholar 

  7. Bellegarde, F.: Program transformation and rewriting. In: Book, R.V. (ed.) RTA 1991. LNCS, vol. 488, pp. 226–239. Springer, Heidelberg (1991). https://doi.org/10.1007/3-540-53904-2_99

    Chapter  Google Scholar 

  8. Cirstea, H., Lenglet, S., Moreau, P.: A faithful encoding of programmable strategies into term rewriting systems. In: International Conference on Rewriting Techniques and Applications, RTA 2015. LIPIcs, vol. 36, pp. 74–88. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik (2015). https://doi.org/10.4230/LIPIcs.RTA.2015.74

  9. Cirstea, H., Lermusiaux, P., Moreau, P.E.: Pattern eliminating transformations, October 2020. https://hal.inria.fr/hal-02476012. Long version

  10. Cirstea, H., Moreau, P.: Generic encodings of constructor rewriting systems. In: International Symposium on Principles and Practice of Programming Languages, PPDP 2019, pp. 8:1–8:12. ACM (2019). https://doi.org/10.1145/3354166.3354173

  11. Clavel, M., et al.: The Maude 2.0 system. In: Nieuwenhuis, R. (ed.) RTA 2003. LNCS, vol. 2706, pp. 76–87. Springer, Heidelberg (2003). https://doi.org/10.1007/3-540-44881-0_7

    Chapter  Google Scholar 

  12. Freeman, T.S., Pfenning, F.: Refinement types for ML. In: ACM SIGPLAN’91 Conference on Programming Language Design and Implementation (PLDI), pp. 268–277. ACM (1991). https://doi.org/10.1145/113445.113468

  13. Fuhs, C., Giesl, J., Parting, M., Schneider-Kamp, P., Swiderski, S.: Proving termination by dependency pairs and inductive theorem proving. J. Autom. Reasoning 47(2), 133–160 (2011). https://doi.org/10.1007/s10817-010-9215-9

    Article  MathSciNet  MATH  Google Scholar 

  14. Garrigue, J.: Programming with polymorphic variants. In: ACM Workshop on ML (1998)

    Google Scholar 

  15. Genet, T.: Towards static analysis of functional programs using tree automata completion. In: Escobar, S. (ed.) WRLA 2014. LNCS, vol. 8663, pp. 147–161. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-12904-4_8

    Chapter  Google Scholar 

  16. Genet, T.: Termination criteria for tree automata completion. J. Log. Algebr. Methods Program. 85(1), 3–33 (2016). https://doi.org/10.1016/j.jlamp.2015.05.003

    Article  MathSciNet  MATH  Google Scholar 

  17. Giesl, J., Schneider-Kamp, P., Thiemann, R.: AProVE 1.2: automatic termination proofs in the dependency pair framework. In: Furbach, U., Shankar, N. (eds.) IJCAR 2006. LNCS (LNAI), vol. 4130, pp. 281–286. Springer, Heidelberg (2006). https://doi.org/10.1007/11814771_24

    Chapter  Google Scholar 

  18. Giesl, J., Thiemann, R., Schneider-Kamp, P., Falke, S.: Mechanizing and improving dependency pairs. J. Autom. Reasoning 37(3), 155–203 (2006). https://doi.org/10.1007/s10817-006-9057-7

    Article  MathSciNet  MATH  Google Scholar 

  19. Haudebourg, T., Genet, T., Jensen, T.P.: Regular language type inference with term rewriting. ACM on Program. Lang. 4(ICFP), 112:1–112:29 (2020). https://doi.org/10.1145/3408994

  20. Hirokawa, N., Middeldorp, A.: Automating the dependency pair method. Inf. Comput. 199(1–2), 172–199 (2005). https://doi.org/10.1016/j.ic.2004.10.004

    Article  MathSciNet  MATH  Google Scholar 

  21. Jouannaud, J., Kirchner, C.: Solving equations in abstract algebras: a rule-based survey of unification. In: Computational Logic - Essays in Honor of Alan Robinson, pp. 257–321. The MIT Press (1991)

    Google Scholar 

  22. Jouannaud, J., Kirchner, H.: Completion of a set of rules modulo a set of equations. SIAM J. Comput. 15(4), 1155–1194 (1986). https://doi.org/10.1137/0215084

    Article  MathSciNet  MATH  Google Scholar 

  23. Keep, A.W., Dybvig, R.K.: A nanopass framework for commercial compiler development. In: ACM SIGPLAN International Conference on Functional Programming, ICFP 2013. pp. 343–350. ACM (2013). https://doi.org/10.1145/2500365.2500618

  24. Kobayashi, N.: Types and higher-order recursion schemes for verification of higher-order programs. In: ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 20099, pp. 416–428. ACM (2009). https://doi.org/10.1145/1480881.1480933

  25. Kobayashi, N., Tabuchi, N., Unno, H.: Higher-order multi-parameter tree transducers and recursion schemes for program verification. In: ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2010, pp. 495–508. ACM (2010). https://doi.org/10.1145/1706299.1706355

  26. Korp, M., Sternagel, C., Zankl, H., Middeldorp, A.: Tyrolean termination tool 2. In: Treinen, R. (ed.) RTA 2009. LNCS, vol. 5595, pp. 295–304. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-02348-4_21

    Chapter  Google Scholar 

  27. Lacey, D., de Moor, O.: Imperative program transformation by rewriting. In: Wilhelm, R. (ed.) CC 2001. LNCS, vol. 2027, pp. 52–68. Springer, Heidelberg (2001). https://doi.org/10.1007/3-540-45306-7_5

    Chapter  Google Scholar 

  28. Meseguer, J., Braga, C.: Modular rewriting semantics of programming languages. In: Rattray, C., Maharaj, S., Shankland, C. (eds.) AMAST 2004. LNCS, vol. 3116, pp. 364–378. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-27815-3_29

    Chapter  Google Scholar 

  29. Ong, C.L., Ramsay, S.J.: Verifying higher-order functional programs with pattern-matching algebraic data types. In: ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2011, pp. 587–598. ACM (2011). https://doi.org/10.1145/1926385.1926453

  30. Pottier, F.: Visitors unchained. ACM Program. Lang. 1(ICFP), 28:1–28:28 (2017). https://doi.org/10.1145/3110272

  31. Rosu, G., Serbanuta, T.: An overview of the K semantic framework. J. Log. Algebr. Program. 79(6), 397–434 (2010). https://doi.org/10.1016/j.jlap.2010.03.012

    Article  MathSciNet  MATH  Google Scholar 

  32. Takai, T.: A verification technique using term rewriting systems and abstract interpretation. In: van Oostrom, V. (ed.) RTA 2004. LNCS, vol. 3091, pp. 119–133. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-25979-4_9

    Chapter  MATH  Google Scholar 

  33. Bezem, M., Klop, J.W., de Vrijer, R. (eds.) Term Rewriting Systems. Cambridge University Press, Cambridge (2003)

    Google Scholar 

  34. Visser, E.: Strategic pattern matching. In: Narendran, P., Rusinowitch, M. (eds.) RTA 1999. LNCS, vol. 1631, pp. 30–44. Springer, Heidelberg (1999). https://doi.org/10.1007/3-540-48685-2_3

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Pierre-Etienne Moreau .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Cirstea, H., Lermusiaux, P., Moreau, PE. (2021). Pattern Eliminating Transformations. In: Fernández, M. (eds) Logic-Based Program Synthesis and Transformation. LOPSTR 2020. Lecture Notes in Computer Science(), vol 12561. Springer, Cham. https://doi.org/10.1007/978-3-030-68446-4_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-68446-4_4

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-68445-7

  • Online ISBN: 978-3-030-68446-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics