Skip to main content

On Multi-language Abstraction

Towards a Static Analysis of Multi-language Programs

  • Conference paper
  • First Online:
Static Analysis (SAS 2020)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 12389))

Included in the following conference series:

Abstract

Modern software development rarely takes place within a single programming language. Often, programmers appeal to cross-language interoperability. Examples are exploitation of novel features of one language within another, and cross-language code reuse. Previous works developed a theory of so-called multi-languages, which arise by combining existing languages, defining a precise notion of (algebraic) multi-language semantics. As regards static analysis, the heterogeneity of the multi-language context opens up new and unexplored scenarios. In this paper, we provide a general theory for the combination of abstract interpretations of existing languages, regardless of their inherent nature, in order to gain an abstract semantics of multi-language programs. As a part of this general theory, we show that formal properties of interest of multi-language abstractions (e.g., soundness and completeness) boil down to the features of the interoperability mechanism that binds the underlying languages together. We extend many of the standard concepts of abstract interpretation to the framework of multi-languages.

Supported by Progetto ricerca di base 2017 (prot. RBVR1772AA), funded by University of Verona.

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 59.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 79.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.

    A commercial static code analyser for Java (version 3.2.0.1227 for Linux 64 bit).

  2. 2.

    We ignore the case where \(\rho _2(\texttt {n}) = \bot \), as it is clearly trivial.

  3. 3.

    One can check that \(\alpha (S)\) is a cjm and \((\alpha ,\gamma )\) form a Galois connection.

  4. 4.

    A similar approach has been previously taken in [32] and in the thesis of Pasqua [36].

References

  1. Ahmed, A., Blume, M.: An equivalence-preserving CPS translation via multi-language semantics. SIGPLAN Not. 46(9), 431–444 (2011)

    Article  MATH  Google Scholar 

  2. Amato, G., Meo, M.C., Scozzari, F.: On collecting semantics for program analysis. Theor. Comput. Sci. 823, 1–25 (2020)

    Article  MathSciNet  MATH  Google Scholar 

  3. Arceri, V., Mastroeni, I.: Static program analysis for string manipulation languages. Electron. Proc. Theor. Comput. Sci. 299, 19–33 (2019)

    Article  Google Scholar 

  4. Barrett, E., Bolz, C.F., Tratt, L.: Approaches to interpreter composition. Comput. Lang. Syst. Struct. 44, 199–217 (2015)

    Google Scholar 

  5. Benton, N.: Embedded interpreters. J. Funct. Program. 15(4), 503–542 (2005)

    Article  MathSciNet  MATH  Google Scholar 

  6. Bjørner, N., Gurfinkel, A.: Property directed polyhedral abstraction. In: D’Souza, D., Lal, A., Larsen, K.G. (eds.) VMCAI 2015. LNCS, vol. 8931, pp. 263–281. Springer, Heidelberg (2015). https://doi.org/10.1007/978-3-662-46081-8_15

    Chapter  Google Scholar 

  7. Buro, S., Mastroeni, I.: On the multi-language construction. In: Caires, L. (ed.) ESOP 2019. LNCS, vol. 11423, pp. 293–321. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-17184-1_11

    Chapter  Google Scholar 

  8. Buro, S., Mastroeni, I., Crole, R.L.: Equational logic and categorical semantics for multi-languages. In: In-press (Accepted for Publication at 36th International Conference on Mathematical Foundations of Programming Semantics – MFPS 2020) (2020)

    Google Scholar 

  9. Buro, S., Mastroeni, I., Crole, R.L.: Equational logic and set-theoretic models for multi-languages. In: In-press (Accepted for Publication at 21st Italian Conference on Theoretical Computer Science – ICTCS 2020) (2020)

    Google Scholar 

  10. Campbell, G., Papapetrou, P.P.: SonarQube in Action. Manning Publications Co., New York (2013)

    Google Scholar 

  11. Chisnall, D.: The challenge of cross-language interoperability. Commun. ACM 56(12), 50–56 (2013)

    Article  Google Scholar 

  12. Cohen, H., et al.: Handbook of Elliptic and Hyperelliptic Curve Cryptography. CRC Press, Boca Raton (2005)

    Book  Google Scholar 

  13. Cousot, P.: Constructive design of a hierarchy of semantics of a transition system by abstract interpretation. Theor. Comput. Sci. 277(1–2), 47–103 (2002)

    Article  MathSciNet  MATH  Google Scholar 

  14. Cousot, P., Cousot, R.: Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In: Proceedings of the 4th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, pp. 238–252 (1977)

    Google Scholar 

  15. Cousot, P., Cousot, R.: Abstract interpretation frameworks. J. Log. Comput. 2(4), 511–547 (1992)

    Article  MathSciNet  MATH  Google Scholar 

  16. Cousot, P., Giacobazzi, R., Ranzato, F.: A\(^2\)i: abstract\(^2\) interpretation. Proc. ACM Program. Lang. 3(POPL), 1–31 (2019)

    Google Scholar 

  17. Cousot, P., Halbwachs, N.: Automatic discovery of linear restraints among variables of a program. In: Proceedings of the 5th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, pp. 84–96 (1978)

    Google Scholar 

  18. Furr, M., Foster, J.S.: Checking type safety of foreign function calls. SIGPLAN Not. 40(6), 62–72 (2005)

    Article  Google Scholar 

  19. Giacobazzi, R., Ranzato, F.: Completeness in abstract interpretation: a domain perspective. In: Johnson, M. (ed.) AMAST 1997. LNCS, vol. 1349, pp. 231–245. Springer, Heidelberg (1997). https://doi.org/10.1007/BFb0000474

    Chapter  MATH  Google Scholar 

  20. Giacobazzi, R., Ranzato, F., Scozzari, F.: Making abstract interpretations complete. J. ACM (JACM) 47(2), 361–416 (2000)

    Article  MathSciNet  MATH  Google Scholar 

  21. Goguen, J.A., Diaconescu, R.: An Oxford survey of order sorted algebra. Math. Struct. Comput. Sci. 4(3), 363–392 (1994)

    Article  MathSciNet  MATH  Google Scholar 

  22. Goguen, J.A., Meseguer, J.: Order-sorted algebra I: equational deduction for multiple inheritance, overloading, exceptions and partial operations. Theor. Comput. Sci. 105(2), 217–273 (1992)

    Article  MathSciNet  MATH  Google Scholar 

  23. Goguen, J.A., Thatcher, J.W., Wagner, E.G., Wright, J.B.: Initial algebra semantics and continuous algebras. J. ACM (JACM) 24(1), 68–95 (1977)

    Article  MathSciNet  MATH  Google Scholar 

  24. Gordon, A.D., Syme, D.: Typing a multi-language intermediate code. In: Conference Record of POPL 2001: The 28th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, London, UK, January 17–19, 2001, pp. 248–260. ACM, New York (2001)

    Google Scholar 

  25. Gray, K.E.: Safe cross-language inheritance. In: Vitek, J. (ed.) ECOOP 2008. LNCS, vol. 5142, pp. 52–75. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-70592-5_4

    Chapter  Google Scholar 

  26. Grimmer, M., Schatz, R., Seaton, C., Würthinger, T., Luján, M.: Cross-language interoperability in a multi-language runtime. ACM Trans. Program. Lang. Syst. 40(2), 8:1–8:43 (2018)

    Article  Google Scholar 

  27. JetBrains: Calling Java code from Kotlin. https://kotlinlang.org/docs/reference/java-interop.html

  28. Juneau, J., Baker, J., Wierzbicki, F., Soto, L., Ng, V.: The Definitive Guide to Jython: Python for the Java Platform, 1st edn. Apress, Berkely (2010)

    Book  Google Scholar 

  29. Kochems, J., Ong, C.: Improved functional flow and reachability analyses using indexed linear tree grammars. In: 22nd International Conference on Rewriting Techniques and Applications (RTA 2011). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik (2011)

    Google Scholar 

  30. Li, S., Tan, G.: Finding reference-counting errors in Python/C programs with affine analysis. In: Jones, R. (ed.) ECOOP 2014. LNCS, vol. 8586, pp. 80–104. Springer, Heidelberg (2014). https://doi.org/10.1007/978-3-662-44202-9_4

    Chapter  Google Scholar 

  31. Liang, S.: Java Native Interface: Programmer’s Guide and Reference, 1st edn. Addison-Wesley Longman Publishing Co., Inc., Boston (1999)

    Google Scholar 

  32. Mastroeni, I., Pasqua, M.: Hyperhierarchy of semantics - a formal framework for hyperproperties verification. In: Ranzato, F. (ed.) SAS 2017. LNCS, vol. 10422, pp. 232–252. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-66706-5_12

    Chapter  Google Scholar 

  33. Matthews, J., Findler, R.B.: Operational semantics for multi-language programs. ACM Trans. Program. Lang. Syst. 31(3), 12:1–12:44 (2009)

    Article  MATH  Google Scholar 

  34. Oracle: JNI types and data structures. https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html

  35. Oracle: Nashorn user’s guide. https://docs.oracle.com/en/java/javase/14/nashorn/introduction.html

  36. Pasqua, M.: Hyper static analysis of programs - an abstract interpretation-based framework for hyperproperties verification. Ph.D. thesis, University of Verona (2019)

    Google Scholar 

  37. Patterson, D., Perconti, J., Dimoulas, C., Ahmed, A.: Funtal: reasonably mixing a functional language with assembly. In: Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation, pp. 495–509. ACM, New York (2017)

    Google Scholar 

  38. Perconti, J.T., Ahmed, A.: Verifying an open compiler using multi-language semantics. In: Shao, Z. (ed.) ESOP 2014. LNCS, vol. 8410, pp. 128–148. Springer, Heidelberg (2014). https://doi.org/10.1007/978-3-642-54833-8_8

    Chapter  Google Scholar 

  39. Ramsey, N.: ML module mania: a type-safe, separately compiled, extensible interpreter. Electron. Notes Theor. Comput. Sci. 148(2), 181–209 (2006)

    Article  Google Scholar 

  40. Rival, X., Yi, K.: Introduction to static analysis (2019)

    Google Scholar 

  41. Spoto, F., Jensen, T.: Class analyses as abstract interpretations of trace semantics. ACM Trans. Program. Lang. Syst. (TOPLAS) 25(5), 578–630 (2003)

    Article  Google Scholar 

  42. Tan, G., Morrisett, G.: Ilea: inter-language analysis across Java and C. SIGPLAN Not. 42(10), 39–56 (2007)

    Article  Google Scholar 

  43. Tennent, R.D.: The denotational semantics of programming languages. Commun. ACM 19(8), 437–453 (1976)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Samuele Buro .

Editor information

Editors and Affiliations

A Concrete and Abstract Semantics of \(\mathsf {Imp}\) and \(\mathsf {Num}\)

A Concrete and Abstract Semantics of \(\mathsf {Imp}\) and \(\mathsf {Num}\)

We define the denotational semantics \(\mathscr {D}_i\) and the sign semantics \(\mathscr {A}_i\) for both languages \(\mathsf {Imp}\) and \(\mathsf {Num}\) (we omit the concrete semantics of commands since it is the standard one).

Concrete and Abstract Semantics of Expressions Denotational and sign semantics of expressions are defined in Figs. 9 and 10. The carrier sets on which they are defined are and , respectively. Note that there is an obvious abstraction function \(\widetilde{\alpha }_i:\wp (\mathbb {V}_i) \rightarrow A_\mathcal {V}\) left adjoint to \(\widetilde{\gamma }_i\) (Fig. 7) providing ; and also note that we abuse notation and assume that and \(f_n\) are both syntactical symbols and functions over values, that is and \(f_n:\mathbb {Q}_\bot ^n \rightarrow \mathbb {Q}_\bot \). We denote by and \(f_n^{\natural }:A_\mathcal {V}^n \rightarrow A_\mathcal {V}\) the sign semantics of and \(f_n\), respectively.

Fig. 10.
figure 10

Denotational and sign semantics of \(\mathsf {Num}\) expressions.

Sign Semantics of Commands. We just provide the sign semantics of \(\mathsf {Imp}\)-commands since \(\mathsf {Num}\)-commands are a subset of those of \(\mathsf {Imp}\) (Fig. 11). The carrier set is defined as . The poset \(\langle {\mathbb {Env}^{\natural }, \mathrel {\mathring{\sqsubseteq }}_\mathcal {V}}\rangle \), where \(\rho ^{\natural }_0 \mathrel {\mathring{\sqsubseteq }}_\mathcal {V}\rho ^{\natural }_1\) if \(\rho ^{\natural }_0(x) \sqsubseteq \rho ^{\natural }_1(x)\) for each \(x \in \mathbb {X}\), is trivially a complete lattice \(\langle {\mathbb {Env}^{\natural }, \mathrel {\mathring{\sqsubseteq }}_\mathcal {V}, \mathbin {\mathring{\sqcup }}_\mathcal {V}, \mathbin {\mathring{\sqcap }}_\mathcal {V}, \mathring{\bot }_\mathcal {V}, \mathring{\top }_\mathcal {V}}\rangle \). We can then lift such a posetal structure defined on \(\mathbb {Env}^{\natural }\) to the function space \(\mathbb {Env}^{\natural } \rightarrow \mathbb {Env}^{\natural }\), thus making it a complete lattice \(\langle {\mathbb {Env}^{\natural } \rightarrow \mathbb {Env}^{\natural }, \mathrel {\widetilde{\sqsubseteq }}_\mathcal {V}, \mathbin {\widetilde{\sqcup }}_\mathcal {V}, \widetilde{\sqcap }_\mathcal {V}, \widetilde{\bot }_\mathcal {V}, \widetilde{\top }_\mathcal {V}}\rangle \). In particular, the least upper bound operator is \(\mathbin {\widetilde{\sqcup }}_\mathcal {V}S = \rho ^{\natural } \mapsto \mathbin {\mathring{\sqcup }}_\mathcal {V}\{ \, f^{\natural }(\rho ^{\natural }) \;\vert \; f^{\natural } \in S \,\}\), and the smallest and greatest element are \(\widetilde{\bot }_\mathcal {V}= \rho ^{\natural } \mapsto \mathring{\bot }_\mathcal {V}\) and \(\widetilde{\top }_\mathcal {V}= \rho ^{\natural } \mapsto \mathring{\top }_\mathcal {V}\), respectively. One can check that \(F^{\natural }_{e^{\natural },c^{\natural }}(f^{\natural })\) is continuous, so that the \( loop \) semantics is well-defined.

Fig. 11.
figure 11

Sign semantics of \(\mathsf {Imp}\) commands.

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Buro, S., Crole, R.L., Mastroeni, I. (2020). On Multi-language Abstraction. In: Pichardie, D., Sighireanu, M. (eds) Static Analysis. SAS 2020. Lecture Notes in Computer Science(), vol 12389. Springer, Cham. https://doi.org/10.1007/978-3-030-65474-0_14

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-65474-0_14

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-65473-3

  • Online ISBN: 978-3-030-65474-0

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics