Skip to main content
Erschienen in:
Buchtitelbild

Open Access 2019 | OriginalPaper | Buchkapitel

On the Multi-Language Construction

verfasst von : Samuele Buro, Isabella Mastroeni

Erschienen in: Programming Languages and Systems

Verlag: Springer International Publishing

Aktivieren Sie unsere intelligente Suche, um passende Fachinhalte oder Patente zu finden.

search-config
loading …

Abstract

Modern software is no more developed in a single programming language. Instead, programmers tend to exploit cross-language interoperability mechanisms to combine code stemming from different languages, and thus yielding fully-fledged multi-language programs. Whilst this approach enables developers to benefit from the strengths of each single-language, on the other hand it complicates the semantics of such programs. Indeed, the resulting multi-language does not meet any of the semantics of the combined languages. In this paper, we broaden the boundary functions-based approach à la Matthews and Findler to propose an algebraic framework that provides a constructive mathematical notion of multi-language able to determine its semantics. The aim of this work is to overcome the lack of a formal method (resp., model) to design (resp., represent) a multi-language, regardless of the inherent nature of the underlying languages. We show that our construction ensures the uniqueness of the semantic function (i.e., the multi-language semantics induced by the combined languages) by proving the initiality of the term model (i.e., the abstract syntax of the multi-language) in its category.

1 Introduction

Two elementary arguments lie at the heart of the multi-language paradigm: the large availability of existing programming languages, along with a very high number of already written libraries, and software that, in general, needs to interoperate. Although there is consensus in claiming that there is no best programming language regardless of the context [4, 8], it is equally true that many of them are conceived and designed in order to excel for specific tasks. Such examples are R for statistical and graphical computation, Perl for data wrangling, Assembly and C for low-level memory management, etc. “Interoperability between languages has been a problem since the second programming language was invented” [8], so it is hardly surprising that developers have focused on the design of cross-language interoperability mechanisms, enabling programmers to combine code written in different languages. In this sense, we speak of multi-languages.
The field of cross-language interoperability has been driven more by practical concerns than by theoretical questions. The current scenario sees several engines and frameworks [13, 28, 29, 44, 47] (among others) to mix programming languages but only [30] discusses the semantic issues related to the multi-language design from a theoretical perspective. Moreover, the existing interoperability mechanisms differ considerably not only from the viewpoint of the combined languages, but also in terms of the approach used to provide the interoperation. For instance, Nashorn [47] is a JavaScript interpreter written in Java to allow embedding JavaScript in Java applications. Such engineering design works in a similar fashion of embedded interpreters [40, 41].1 On the contrary, Java Native Interface (JNI) framework [29] enables the interoperation of Java with native code written in C, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figa_HTML.gif , or Assembly through external procedure calls between languages, mirroring the widespread mechanism of foreign function interfaces (FFI) [14], whereas theoretical papers follow the more elegant approach of boundary functions (or, for short, boundaries) in the style of Matthews and Findler’s multi-language semantics [30]. Simply put, boundaries act as a gate between single-languages. When a value needs to flow on the other language, they perform a conversion so that it complies to the other language specifications.
The major issue concerning this new paradigm is that multi-language programs do not obey any of the semantics of the combined languages. As a consequence, any method of formal reasoning (such as static program analysis or verification) is neutralized by the absence of a semantics specification. In this paper, we propose an algebraic framework based on the mechanism of boundary functions [30] that unambiguously yields the syntax and the semantics of the multi-language regardless the combined languages.
The Lack of a Multi-Language Framework. The notion of multi-language is employed naively in several works in literature [2, 14, 21, 30, 3537, 49] to indicate the embedding of two programming languages into a new one, with its own syntax and semantics.
The most recurring way to design a multi-language is to exploit a mechanism (like embedded interpreters, FFI, or boundary functions) able to regulate both control flow and value conversion between the underlying languages [30], thus adequate to provide cross-language interoperability [8]. The full construction is usually carried out manually by language designers, which define the multi-language by reusing the formal specifications of the single-languages [2, 30, 36, 37] and by applying the selected mechanism for achieving the interoperation. Inevitably, therefore, all these resulting multi-languages notably differ one from another.
These different ways to achieve a cross-language interoperation are all attributable to the lack of a formal description of multi-language that does not provide neither a method for language designers to conceive new multi-languages nor any guarantee on the correctness of such constructions.
The Proposed Framework: Roadmap and Contributions. Matthews and Findler [30] propose boundary functions as a way to regulate the flow of values between languages. They show their approach on different variants of the same multi-language obtained by mixing ML [33] and Scheme [9], representing two “syntactically sugared” versions of the simply-typed and untyped lambda calculi, respectively.
Rather than showing the embedding of two fixed languages, we extend their approach to the much broader class of order-sorted algebras [19] with the aim of providing a framework that works regardless of the inherent nature of the combined languages. There are a number of reasons to choose order-sorted algebras as the underlying framework for generalizing the multi-language construction. From the first formulation of initial algebra semantics [17], the algebraic approach to program semantics [16] has become a cornerstone in the theory of programming languages [27]. Order-sorted algebras provide a mathematical tool for representing formal systems as algebraic structures through a systematic use of the notion of sort and subsort to model different forms of polymorphism [18, 19], a key aspect when dealing with multi-languages sharing operators among the single-languages. They were initially proposed to ensure a rigorous model-theoretic semantics for error handling, multiple inheritance, retracts, selectors for multiple constructors, polymorphism, and overloading. In the years, several uses [3, 6, 11, 24, 25, 38, 39, 52] and different variants [38, 43, 45, 51] have been proposed for order-sorted algebras, making them a solid starting point for the development of a new framework. In particular, results on rewriting logic [32] extend easily to the order-sorted case [31], thus facilitating a future extension of this paper towards the operational semantics world. Improvements of the order-sorted algebra framework have also been proposed to model languages together with their type systems [10] and to extend order-sorted specification with high-order functions [38] (see [48] and [18] for detailed surveys).
In this paper, we propose three different multi-language constructions according to the semantic properties of boundary functions. The first one models a general notion of multi-language that do not require any constraints on boundaries (Sect. 3). We argue that when such generality is superfluous, we can achieve a neater approach where boundary functions do not need to be annotated with sorts. Indeed, we show that when the cross-language conversion of a term does not depend on the sort at which the term is considered (i.e., when boundaries are subsort polymorphic) the framework is powerful enough to apply the correct conversion (Sect. 4.1). This last construction is an improvement of the original notion of boundaries in [30]. From a practical point of view, it allows programmers to avoid to explicitly deal with sorts when writing code, a non-trivial task that could introduce type cast bugs in real world languages. Finally, we provide a very specific notion of multi-language where no extra operator is added to the syntax (Sect. 4.2). This approach is particularly useful to extend a language in a modular fashion and ensuring the backward compatibility with “old” programs. For each one of these variants we prove an initiality theorem, which in turn ensures the uniqueness of the multi-language semantics and thereby legitimating the proposed framework. Moreover, we show that the framework guarantees a fundamental closure property on the construction: The resulting multi-language admits an order-sorted representation, i.e., it falls within the same formal model of the combined languages. Finally, we model the multi-language designed in [30] in order to show an instantiation of the framework (Sect. 6).

2 Background

All the algebraic background of the paper is firstly stated in [15, 17, 19]. We briefly introduce here the main definitions and results, and we illustrate them on a simple running example.
Given a set of sorts S, an S-sorted set A is a family of sets indexed by S, i.e., https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq1_HTML.gif . Similarly, an S-sorted function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq2_HTML.gif is a family of functions https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq3_HTML.gif . We stick to the convention of using s and w as metavariables for sorts in S and \(S^*\), respectively, and we use the \(\mathbb {blackboard}\) \(\mathbb {bold}\) typeface to indicate a specific sort in S. In addition, if A is an S-sorted set and \(w = s_1\ldots s_n \in S^+\), we denote by \(A_w\) the cartesian product \(A_{s_1} \times \cdots \times A_{s_n}\). Likewise, if f is an S-sorted function and \(a_i \in A_{s_i}\) for \(i = 1, \ldots , n\), then the function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq12_HTML.gif is such that \(f_w(a_1, \ldots , a_n) = (f_{s_1}(a_1), \ldots , f_{s_n}(a_n))\). Given \(P \subseteq S\), the restriction of an S-sorted function f to P is denoted by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq15_HTML.gif and it is the P-sorted function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq16_HTML.gif . Finally, if https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq17_HTML.gif is a function, we still use the symbol g to denote the direct image map of g (also called the additive lift of g), i.e., the function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figb_HTML.gif such that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq18_HTML.gif . Analogously, if \(\le \) is a binary relation on a set A (with elements \(a \in A\)), we use the same relation symbol to denote its pointwise extension, i.e., we write \(a_1 \ldots a_n \le a'_1\ldots a'_n\) for \(a_1 \le a'_1, \ldots , a_n \le a'_n\).
The basic notions underpinning the order-sorted algebra framework are the definitions of signature, that models symbols forming terms of the language, and algebra, that provides an algebraic meaning to symbols.
Definition 1
(Order-Sorted Signature). An order-sorted signature is a triple https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq23_HTML.gif , where S is a set of sorts, \(\le \) is a binary relation on S, and \(\varSigma \) is an \(S^* \times S\)-sorted set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq27_HTML.gif , satisfying the following conditions:
  • (1os) https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq28_HTML.gif is a poset; and
  • (2os) \(\sigma \in \varSigma _{w_1, s_1} \cap \varSigma _{w_2, s_2}\) and \(w_1 \le w_2\) imply \(s_1 \le s_2\).
If \(\sigma \in \varSigma _{w, s}\) (or, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq33_HTML.gif and \(\sigma :s\) when \(w = \varepsilon \), as shorthands), we call \(\sigma \) an operator (symbol) or function symbol, w the arity, s the sort, and (ws) the rank of \(\sigma \); if \(w = \varepsilon \), we say that \(\sigma \) is a constant (symbol). We name \(\le \) the subsort relation and \(\varSigma \) a signature when https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq42_HTML.gif is clear from the context. We abuse notation and write \(\sigma \in \varSigma \) when \(\sigma \in \bigcup _{w, s}\varSigma _{w, s}\).
Definition 2
(Order-Sorted Algebra). An order-sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq45_HTML.gif -algebra \(\mathcal {A}\) over an order-sorted signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq47_HTML.gif is an S-sorted set A of interpretation domains (or, carrier sets or semantic domains) https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq48_HTML.gif , together with interpretation functions https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq49_HTML.gif (or, if \(w = \varepsilon \), https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq51_HTML.gif )2 for each \(\sigma \in \varSigma _{w, s}\), such that:
  • (1oa) \(s \le s'\) implies \(A_s \subseteq A_{s'}\); and
  • (2oa) \(\sigma \in \varSigma _{w_1, s_1} \cap \varSigma _{w_2, s_2}\) and \(w_1 \le w_2\) imply that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq59_HTML.gif for each \(a \in A_{w_1}\).
An important property of signatures, related to polymorphism, is regularity. Its relevance lies in the possibility of linking each term to a unique least sort (see Proposition 2.10 in [19]).
Definition 3
(Regularity of an Order-Sorted Signature). An order-sorted signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq61_HTML.gif is regular if for each \(\sigma \in \varSigma _{\tilde{w}, \tilde{s}}\) and for each lower bound \(w_0 \le \tilde{w}\) the set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq64_HTML.gif has minimum. This minimum is called least rank of \(\sigma \) with respect to \(w_0\).
The freely generated algebra \(\mathcal {T}_\varSigma \) over a given signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq68_HTML.gif provides the notion of term with respect to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq69_HTML.gif .
Definition 4
(Order-Sorted Term Algebra). Let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq70_HTML.gif be an order-sorted signature. The order-sorted term https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq71_HTML.gif -algebra \(\mathcal {T}_\varSigma \) is an order-sorted algebra such that:
  • The S-sorted set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq73_HTML.gif is inductively defined as the least family satisfying:
    (1ot)
    \(\varSigma _{\varepsilon , s} \subseteq T_{\varSigma , s}\);
     
    (2ot)
    \(s \le s'\) implies \(T_{\varSigma , s} \subseteq T_{\varSigma , s'}\); and
     
    (3ot)
    \(\sigma \in \varSigma _{w, s}\), \(w = s_1\ldots s_n \in S^+\), and \(t_i \in T_{\varSigma , s_i}\) for \(i = 1, \ldots , n\) imply https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq81_HTML.gif .
     
  • For each \(\sigma \in \varSigma _{w, s}\) the interpretation function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq83_HTML.gif is defined as
    (4ot)
    https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq84_HTML.gif if \(\sigma \in \varSigma _{\varepsilon , s}\); and
     
    (5ot)
    https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq86_HTML.gif if \(\sigma \in \varSigma _{w, s}\), \(w = s_1\ldots s_n \in S^+\), and \(t_i \in T_{\varSigma , s_i}\) for \(i = 1, \ldots , n\).
     
Homomorphisms between algebras capture the compositionality nature of semantics: The meaning of a term is determined by the meanings of its constituents. They are defined as order-sorted functions that preserve the interpretation of operators.
Definition 5
(Order-Sorted Homomorphism). Let \(\mathcal {A}\) and \(\mathcal {B}\) be https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq93_HTML.gif -algebras. An order-sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq94_HTML.gif -homomorphism from \(\mathcal {A}\) to \(\mathcal {B}\), denoted by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq97_HTML.gif , is an S-sorted function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq98_HTML.gif such that:
(1oh)
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq99_HTML.gif for each \(\sigma \in \varSigma _{w, s}\) and \(a \in A_w\); and
 
(2oh)
\(s \le s'\) implies \(h_s(a) = h_{s'}(a)\) for each \(a \in A_s\).
 
The class of all the order-sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq105_HTML.gif -algebras and the class of all order-sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq106_HTML.gif -homomorphisms form a category denote by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq107_HTML.gif . Furthermore, the homomorphism definition determines the property of the term algebra \(\mathcal {T}_\varSigma \) of being an initial object in its category whenever the signature is regular. Since initiality is preserved by isomorphisms, it allows to identify \(\mathcal {T}_\varSigma \) with the abstract syntax of the language. If \(\mathcal {T}_\varSigma \) is initial, the homomorphism leaving \(\mathcal {T}_\varSigma \) and going to an algebra \(\mathcal {A}\) is called the semantic function (with respect to \(\mathcal {A}\)).
Example. Let \(L_1\) and \(L_2\) be two formal languages (see Fig. 1). The former is a language to construct simple mathematical expressions: \(n \in \mathbb {N}\) is the metavariable for natural numbers, while e inductively generates all the possible additions (Fig. 1a). The latter is a language to build strings over a finite alphabet of symbols https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq117_HTML.gif : https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq118_HTML.gif is the metavariable for atoms (or, characters), whereas s concatenates them into strings (Fig. 1b). A term in \(L_1\) and \(L_2\) denotes an element in the sets https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq121_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq122_HTML.gif , accordingly to equations in Fig. 2a and b, respectively.
The syntax of the language \(L_1\) can be modeled by an order-sorted signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq124_HTML.gif defined as follows: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figc_HTML.gif , a set with sorts https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figd_HTML.gif (stands for expressions) and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Fige_HTML.gif (stands for natural numbers); \(\le _1\) is the reflexive relation on \(S_1\) plus https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figf_HTML.gif (natural numbers are expressions); and the operators in \(\varSigma _1\) are https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figg_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figh_HTML.gif . Similarly, the signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq128_HTML.gif models the syntax of the language \(L_2\): the set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figi_HTML.gif carries the sort for strings https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figj_HTML.gif and the sort for atomic symbols (or, characters) https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figk_HTML.gif the subsort relation \(\le _2\) is the reflexive relation on \(S_2\) plus https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figl_HTML.gif (characters are one-symbol strings); and the operator symbols in \(\varSigma _2\) are https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figm_HTML.gif , https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Fign_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figo_HTML.gif . Semantics of \(L_1\) and \(L_2\) can be embodied by algebras \(\mathcal {A}_1\) and \(\mathcal {A}_2\) over the signatures https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq137_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq138_HTML.gif , respectively. We set the interpretation domains of \(\mathcal {A}_1\) to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figp_HTML.gif and those of \(\mathcal {A}_2\) to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figq_HTML.gif . Moreover, we define the interpretation functions as follows (the juxtaposition of two or more strings denotes their concatenation, and we use \(\hat{a}\) as metavariable ranging over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq142_HTML.gif ):
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ3_HTML.png
Since https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq143_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq144_HTML.gif are regular, then \(\mathcal {A}_1\) and \(\mathcal {A}_2\) induce the semantic functions https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq147_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq148_HTML.gif , providing semantics to the languages.

3 Combining Order-Sorted Theories

The first step towards a multi-language specification is the choice of which terms of one language can be employed in the others [30, 35, 36]. For instance, a multi-language requirement could demand to use ML expressions in place of Scheme expressions and, possibly, but not necessarily, vice versa (such a multi-language is designed in [30]). A multi-language signature is an amenable formalism to specify the compatibility relation between syntactic categories across two languages.
Definition 6
(Multi-Language Signature). A multi-language signature is a triple https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq149_HTML.gif , where https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq150_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq151_HTML.gif are order-sorted signatures, and \(\le \) is a binary relation on \(S = S_1 \cup S_2\), such that satisfies the following condition:
(1s)
\(s, s' \in S_i\) implies \(s \le s'\) if and only if \(s \le _i s'\), for \(i = 1,2\).
 
To make the notation lighter, we introduce the following binary relations on S: \(s \ltimes s'\) if \(s \le s'\) but neither \(s \le _1 s'\) nor \(s \le _2 s'\), and \(s \preccurlyeq s'\) if \(s \le s'\) but not \(s \ltimes s'\).
In the following, we always assume that the sets of sorts \(S_1\) and \(S_2\) of the order-sorted signatures https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq167_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq168_HTML.gif are disjoint.3 Condition (1s) requires the multi-language subsort relation \(\le \) to preserve the original subsort relations \(\le _1\) and \(\le _2\) (i.e., \(\mathord {\le } \cap S_i \times S_i = \mathord {\le _i}\)). The join relation \(\ltimes \) provides a compatibility relation between sorts4 in https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq176_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq177_HTML.gif . More precisely, \(S_i \ni s \ltimes s' \in S_j\) suggests that we want to use terms in \(T_{\varSigma _i, s}\) in place of terms in \(T_{\varSigma _j, s'}\), whereas the intra-language subsort relation \(\preccurlyeq \) shifts the standard notion of subsort from the order-sorted to the multi-language world. In a nutshell, the relation \(\mathord {\le } = \mathord {\preccurlyeq } \cup \mathord {\ltimes }\) can only join (through \(\ltimes \)) the underlying languages without introducing distortions (indeed, \(\mathord {\preccurlyeq } = \mathord {\le _1} \cup \mathord {\le _2}\)).
The role of an algebra is to provide an interpretation domain for each sort, as well as the meaning of every operator symbol in a given signature. When moving towards the multi-language context, the join relation \(\ltimes \) may add subsort constraints between sorts belonging to different signatures. Consequently, if \(s \ltimes s'\), a multi-language algebra has to specify how values of sort s may be interpreted as values of sort \(s'\). These specifications are called boundary functions [30] and provide an algebraic meaning to the subsort constraints added by \(\ltimes \). Henceforth, we define \(S = S_1 \cup S_2\), \(\varSigma = \varSigma _1 \cup \varSigma _2\), and, given \((w, s) \in S_i^* \times S_i\), we denote by \(\varSigma ^i_{w, s}\) the (ws)-sorted component in \(\varSigma _i\).
Definition 7
(Multi-Language Algebra). Let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq194_HTML.gif be a multi-language signature. A multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq195_HTML.gif -algebra \(\mathcal {A}\) is an S-sorted set A of interpretation domains (or, carrier sets or semantic domains) https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq197_HTML.gif , together with interpretation functions https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq198_HTML.gif for each \(\sigma \in \varSigma _{w, s}\), and with a \(\ltimes \)-sorted set \(\alpha \) of boundary functions https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq202_HTML.gif , such that the following constraint holds:
(1a)
the projected algebra \(\mathcal {A}_i\), where \(i = 1,2\), specified by the carrier set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq205_HTML.gif and interpretation functions https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq206_HTML.gif for each \(\sigma \in \varSigma ^i_{w,s}\), must be an order-sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq208_HTML.gif -algebra.
 
If \(\mathcal {M}\) is an algebra, we adopt the convention of denoting by M (standard math font) its carrier set and by \(\mu \) (Greek math font) its boundary functions whenever possible. Condition (1a) is the semantic counterpart of condition (1s): It requires the multi-language to carry (i.e., preserve) the underlying languages order-sorted algebras, whereas the boundary functions model how values can flow between languages.
Given two multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq211_HTML.gif -algebras \(\mathcal {A}\) and \(\mathcal {B}\) we can define morphisms between them that preserve the sorted structure of the underlying projected algebras.
Definition 8
(Multi-Language Homomorphism). Let \(\mathcal {A}\) and \(\mathcal {B}\) be multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq216_HTML.gif -algebras with sets of boundary functions \(\alpha \) and \(\beta \), respectively. A multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq219_HTML.gif -homomorphism https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq220_HTML.gif is an S-sorted function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq221_HTML.gif such that:
(1h)
the restriction https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq222_HTML.gif is an order-sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq223_HTML.gif -homomorphism https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq224_HTML.gif , for \(i = 1,2\); and
 
(2h)
\(s \ltimes s'\) implies \(h_{s'} \circ \alpha _{s,s'} = \beta _{s,s'} \circ h_s\).
 
Conditions (1h) and (2h) are easily intelligible when the domain algebra is the abstract syntax of the language [15]: Simply put, both conditions require the semantics of a term to be a function of the meaning of its subterms, in the sense of [15, 46]. In particular, the second condition demands that boundary functions act as operators.5
The identity homomorphism on a multi-language algebra \(\mathcal {A}\) is denoted by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figr_HTML.gif and it is the set-theoretic identity on the carrier set A of the algebra \(\mathcal {A}\). The composition of two homomorphisms https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq230_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq231_HTML.gif is defined as the sorted function composition https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq232_HTML.gif , thus https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figs_HTML.gif and associativity follows easily by the definition of \(\circ \).
Proposition 1
Multi-language homomorphisms are closed under composition.
Hence, as in the many-sorted and order-sorted case [15, 19], we have immediately the category of all the multi-language algebras over a multi-language signature:
Theorem 1
Let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq234_HTML.gif be a multi-language signature. The class of all https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq235_HTML.gif -algebras and the class of all https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq236_HTML.gif -homomorphisms form a category denoted by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq237_HTML.gif .

3.1 The Initial Term Model

In this section, we introduce the concepts of (multi-language) term and (multi-language) semantics in order to show how a multi-language algebra yields a unique interpretation for any regular (see Definition 11) multi-language specification.
Multi-language terms should comprise all of the underlying languages terms, plus those obtained by the merging of the two languages according to the join relation \(\ltimes \). In particular, we aim for a construction where subterms of sort \(s'\) may have been replaced by terms of sort s, whenever \(s \ltimes s'\) (we recall that s and \(s'\) are two syntactic categories of different languages due to Definition 6). Nonetheless, we must be careful not to add ambiguities during this process: A term t may belong to both https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq242_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq243_HTML.gif term algebras but with different meanings https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq244_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq245_HTML.gif (assuming that \(\mathcal {A}_1\) and \(\mathcal {A}_2\) are algebras over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq248_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq249_HTML.gif , respectively). When t is included in the multi-language, we lose the information to determine which one of the two interpretations choose, thus making the (multi-language) semantics of t ambiguous. The same problem arises whenever an operator \(\sigma \) belongs to both languages with different interpretation functions. The simplest solution to avoid such issues is to add syntactical notations to make explicit the context of the language in which we are operating.
Definition 9
(Associated Signature). The associated signature to the multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq251_HTML.gif is the ordered triple https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq252_HTML.gif , where \(S = S_1 \cup S_2\), \(\mathord {\preccurlyeq } = \mathord {\le _1} \cup \mathord {\le _2}\), and
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ4_HTML.png
It is trivial to prove that an associated signature is indeed an order-sorted signature, thus admitting a term algebra \(\mathcal {T}_\varPi \). All the symbols forming terms in \(\mathcal {T}_\varPi \) carry the source language information as a subscript, and all the new operators \(\hookrightarrow _{s,s'}\) specify when a term of sort s is used in place of a term of sort \(s'\). Although \(\mathcal {T}_\varPi \) seems a suitable definition for multi-language terms, it is not a multi-language algebra according to Definition 7. However, we can exploit the construction of \(\mathcal {T}_\varPi \) in order to provide a fully-fledged multi-language algebra able to generate multi-language terms.
Definition 10
(Multi-Language Term Algebra). The multi-language term algebra \(\mathcal {T}\) over a multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq262_HTML.gif with boundary functions \(\tau \) is defined as follows:
(1t)
\(s \in S\) implies \(T_s = T_{\varPi ,s}\);
 
(2t)
\(\sigma \in \varSigma ^i_{w,s}\) implies https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq267_HTML.gif for \(i = 1,2\); and
 
(3t)
\(s \ltimes s'\) implies https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq270_HTML.gif .
 
Proving that \(\mathcal {T}\) satisfies Definition 7 is easy and omitted. \(\mathcal {T}\) and \(\mathcal {T}_\varPi \) share the same carrier sets (condition (1t)), and each single-language operator \(\sigma \in \varSigma ^i_{w, s}\) is interpreted as its annotated version \(\sigma _i\) in \(\mathcal {T}_\varPi \) (condition (2t)). Furthermore, the multi-language operators \(\hookrightarrow _{s, s'}\) no longer belong to the signature (they do not belong neither to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq278_HTML.gif nor to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq279_HTML.gif ) but their semantics is inherited by the boundary functions \(\tau \) (condition (3t)), while their syntactic values are still in the carrier sets of the algebra (this construction is highly technical and very similar to the freely generated \(\varSigma (X)\)-algebra over a set of variables X, see [15]).
Note that this is exactly the formalization of the ad hoc multi-language specifications in [2, 30, 36, 37]: [2, 36, 37] exploit distinct colors to disambiguate the source language of the operators, whereas [30] use different font styles for different languages. Moreover, boundary functions in [30] conceptually match the introduced operators \(\hookrightarrow _{s, s'}\).
The last step in order to finalize the framework is to provide semantics for each term in \(\mathcal {T}\). As with the order-sorted case, we need a notion of regularity for proving the initiality of the term algebra in its category, which in turn ensures a single eligible (initial algebra) semantics.
Definition 11
(Regularity). A multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq284_HTML.gif is regular if its associated signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq285_HTML.gif is regular.
Proposition 2
The associated signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq286_HTML.gif of a multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq287_HTML.gif is regular if and only if https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq288_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq289_HTML.gif are regular.
The last proposition enables to avoid checking the multi-language regularity whenever the regularity of the order-sorted signatures is known.
Theorem 2
(Initiality of \(\mathcal {T}\)). The multi-language term algebra \(\mathcal {T}\) over a regular multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq292_HTML.gif is initial in the category https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq293_HTML.gif .
Initiality of \(\mathcal {T}\) is essential to assign a unique mathematical meaning to each term, as in the order-sorted case: Given a multi-language algebra \(\mathcal {A}\), there is only one way of interpreting each term \(t \in \mathcal {T}\) in \(\mathcal {A}\) (satisfying the homomorphism conditions).
Definition 12
((Multi-Language) Semantics). Let \(\mathcal {A}\) be a multi-language algebra over a regular multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq299_HTML.gif . The (multi-language) semantics of a (multi-language) term \(t \in \mathcal {T}\) induced by \(\mathcal {A}\) is defined as
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ5_HTML.png
The last equation is well-defined since h is the unique multi-language homomorphism https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq302_HTML.gif and for each \(t \in \mathcal {T}\) there exists a least sort https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq304_HTML.gif such that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq305_HTML.gif (see Prop. 2.10 in [19]).
Example. Suppose we are interested in a multi-language over the signatures https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq306_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq307_HTML.gif specified in the example given in the background section such that satisfies the following properties:
  • Terms denoting natural numbers can be used in place of characters https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq308_HTML.gif according to the function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figt_HTML.gif that maps the natural number n to the character symbol https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq309_HTML.gif (we are assuming a total lexicographical order https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq310_HTML.gif on https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq311_HTML.gif );
  • Terms denoting strings can be used in place of natural numbers \(n \in \mathbb {N}\) according to the function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq313_HTML.gif , which is the inverse of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq314_HTML.gif restricted the initial segment on natural numbers https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq315_HTML.gif .
In order to achieve such a multi-language specification, we can simply provide a join relation \(\ltimes \) on S and a boundary function \(\alpha _{s, s'}\) for each extra-language subsort relation \(s \ltimes s'\) introduced by \(\ltimes \). We define the join relation and the boundary functions as follows:
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ6_HTML.png
The multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq320_HTML.gif -algebra \(\mathcal {A}\) can now be obtained by joining the projected algebras \(\mathcal {A}_1\) and \(\mathcal {A}_2\) with the set of boundary functions \(\alpha \). The term algebra \(\mathcal {T}\) over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq326_HTML.gif provides all the multi-language terms, and Theorem 2 ensures a unique denotation of each \(t \in \mathcal {T}\) in \(\mathcal {A}\). For instance, the term
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ1_HTML.png
(1)
is syntactically equivalent to the following but with a less pedantic notation, where language subscripts are replaced by colors ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figu_HTML.gif for one, and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figv_HTML.gif for two) and prefix notation is replaced by infix notation
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ7_HTML.png
and it denotes the natural numbers 765:
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ8_HTML.png
(see the proof of Prop. 2.10 in [19] to check how to compute the least sort of a term).

4 Refining the Construction

The construction in Sect. 3 does not set any constraint on boundary functions, thus giving a great deal of flexibility to language designers. For instance, they can provide boundary functions that act differently with respect to the intra-language subsort relation \(\preccurlyeq \): According to the previous example, it would have been possible to define https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figw_HTML.gif to employ different value conversion specifications for terms in https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figx_HTML.gif , based on whether they are used as natural numbers ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figy_HTML.gif ) or as expressions ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figz_HTML.gif ). However, when this amount of flexibility is not needed, we can refine the previous construction by reducing the amount of syntax introduced by the associated signature. In this section we examine
  • the case where boundary functions satisfy the monotonicity conditions of order-sorted algebra operators (Sect. 4.1); and
  • the case where boundary functions commutes with the semantics of operator symbols (Sect. 4.2).
In both cases, we prove that the introduced refinements do not affect the initiality of the term algebra, thereby providing unambiguous semantics to the multi-language.

4.1 Subsort Polymorphic Boundary Functions

In Sect. 3, the join relation constraints \(s \ltimes s'\) are turned in syntactical operators \(\hookrightarrow _{s, s'}\) in the associated signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq332_HTML.gif . We now show how to handle all the syntactical overhead introduced by \(\ltimes \) with a single polymorphic operator \(\hookrightarrow \) whenever the boundary functions satisfy the monotonicity conditions of the order-sorted algebras [19]. Such conditions require a subsort relation \(s_1 \le s_2\) between the sorts of a polymorphic operator \(\sigma \in \varSigma _{w_1, s_1} \cap \varSigma _{w_2, s_2}\), assuming that \(w_1 \le w_2\). In our case, \(\sigma = \hookrightarrow \), and thus we extend Definition 6 with the following ad hoc constraint (2s\(^{*}\)):
Definition 6\(^{*}\) (SP Multi-Language Signature). A subsort polymorphic (SP) multi-language signature is a multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq341_HTML.gif such that
  • (2s\(^{*}\)) \(s_1 \ltimes s'_1\), \(s_2 \ltimes s'_2\), and \(s_1 \preccurlyeq s_2\) imply \(s'_1 \preccurlyeq s'_2\).
Furthermore, order-sorted algebras demand consistency of the interpretation functions of a subsort polymorphic operator on the smaller domain, which results in the following condition (2a\(^{*}\)) on boundary functions (that extends Definition 7):
Definition 7\(^{*}\) (SP Multi-Language Algebra). Let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq349_HTML.gif be a SP multi-language signature. A subsort polymorphic (SP) multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq350_HTML.gif -algebra is a multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq351_HTML.gif -algebra \(\mathcal {A}\) such that
  • (2a\(^{*}\)) \(s_1 \ltimes s'_1\), \(s_2 \ltimes s'_2\), and \(s_1 \preccurlyeq s_2\) imply that \(\alpha _{s_1,s'_1}(a) = \alpha _{s_2,s'_2}(a)\) for each \(a \in A_{s_1}\).
The notion of homomorphism in this new context does not change (an homomorphism between two https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figaa_HTML.gif algebras is still an S-sorted function decomposable in two order-sorted homomorphisms that commutes with boundaries), whereas the associated signature to an https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figab_HTML.gif multi-language signature merely differs from Definition 9 for having a unique polymorphic operator \(\hookrightarrow \) instead of a family of parametrized symbols https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq360_HTML.gif .
Definition 9\(^{*}\) (SP Associated Signature). The subsort polymorphic (SP) associated signature to the SP multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq362_HTML.gif is the ordered triple https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq363_HTML.gif , where \(S = S_1 \cup S_2\), \(\mathord {\preccurlyeq } = \mathord {\le _1} \cup \mathord {\le _2}\), and
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ9_HTML.png
Since the associated signature is the basis for the term algebra, we need to modify the condition (3t) in Definition 9:
Definition 10\(^{*}\) (SP Multi-Language Term Algebra). The subsort polymorphic (SP) multi-language term algebra \(\mathcal {T}\) over a SP multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq368_HTML.gif with boundary functions \(\tau \) is defined as follows:
  • (1t) \(s \in S\) implies \(T_s = T_{\varPi ,s}\);
  • (2t) \(\sigma \in \varSigma ^i_{w,s}\) implies https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq373_HTML.gif for \(i = 1,2\); and
  • (3t\(^{*}\)) \(s \ltimes s'\) implies https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq377_HTML.gif .
Signature regularity is still defined as in Definition 11 and Proposition 2 still holds for the extended version developed in this section. As a result, the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figac_HTML.gif multi-language term https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq378_HTML.gif -algebra \(\mathcal {T}\) is still initial in the category https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq380_HTML.gif of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figad_HTML.gif multi-language algebras over the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figae_HTML.gif multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq381_HTML.gif .
Theorem 3
Let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq382_HTML.gif be a https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figaf_HTML.gif multi-language signature. The class of all https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figag_HTML.gif https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq383_HTML.gif -algebras and the class of all https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq384_HTML.gif -homomorphisms form a category denoted by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq385_HTML.gif .
Theorem 4
(Initiality of \(\mathcal {T}\)). The https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figah_HTML.gif multi-language term algebra \(\mathcal {T}\) over a regular https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figai_HTML.gif multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq388_HTML.gif is initial in the category https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq389_HTML.gif .
The semantics of a term t induced by a https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figaj_HTML.gif multi-language algebra \(\mathcal {A}\) is defined in the same way of Definition 12, thanks to the initiality result: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq391_HTML.gif . The main advantage of dealing with https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figak_HTML.gif multi-language terms is that the framework is able to determine the correct interpretation function of the operator \(\hookrightarrow \), making the subscript notation developed in the previous section superfluous. This also means that programmers are exempted from explicitly annotating multi-language programs with sorts, a non-trivial task in the general case that could introduce type cast bugs.
Example. The boundary functions of the previous example are subsort polymorphic: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figal_HTML.gif for each character https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq393_HTML.gif , and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figam_HTML.gif by definition. Thus, the equivalent of the term t (see Eq. 1) in the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figan_HTML.gif term algebra is
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ2_HTML.png
(2)
or, according to the previous notation,
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ10_HTML.png
and denoting the same natural number 765.

4.2 Semantic-Only Boundary Functions

In the previous section, we have shown how to handle the flow of values across different languages with a single polymorphic operator. Now, we present a new multi-language construction where neither extra operators are added to the associated signature, nor single-language operators have to be annotated with subscripts indicating their original language. Thus, the resulting multi-language syntax comprises only symbols in \(\varSigma _1 \cup \varSigma _2\). Such a construction is achieved by:
  • Imposing commutativity conditions on algebras, making homomorphisms transparently inherit the semantics of boundary functions. The framework is therefore able to apply the correct value conversion function whenever is necessary, without the need for an explicit syntactical operator \(\hookrightarrow \).
  • Requiring a new form of cross-language polymorphism able to cope with shared operators among languages. The initiality of term algebras is preserved by modifying the notion of signature in a way that every operator admits a least sort.
The variant of the framework presented in this section is particularly useful when designing the extension of a language in a modular fashion. For instance, if the signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq396_HTML.gif models the syntax of a simple functional language (for an example, see [15, p. 77]) without an explicit encoding for string values, and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq397_HTML.gif is a language for manipulating strings (similar to the language \(L_2\) of the running example of this paper), we can exploit the construction presented below in order to embed https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq399_HTML.gif into https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq400_HTML.gif .
Signature. The main issue that can arise at this stage of multi-language signature is the presence of shared operators in \(\varSigma _1\) and \(\varSigma _2\). Contrary to the previous cases where such ambiguity is solved by adding subscripts in the associated signature, the trade off here is requiring ad hoc or subsort polymorphism across signatures.
Definition 6\(^{\star }\) (SO Multi-Language Signature). A semantic-only (SO) multi-language signature is a multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq404_HTML.gif such that
  • (2s\(^{\star }\)) https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq406_HTML.gif is a poset; and
  • (3s\(^{\star }\)) \(\sigma \in \varSigma ^i_{w_1, s_1} \cap \varSigma ^j_{w_2, s_2}\) and \(w_1 \ltimes w_2\) imply \(s_1 \ltimes s_2\) with \(i, j = 1, 2\) and \(i \ne j\).
Condition (2s\(^{\star }\)) forces the subsort relation to be directed, avoiding symmetricity of syntactic categories (this is typical when modeling language extensions), while condition (3s\(^{\star }\)) shifts the monotonicity condition of order-sorted signature to syntactically equal operators in \(\varSigma _1 \cap \varSigma _2\).
The associated signature is defined without adding extra symbols in the signature, i.e., \(\varPi = \varSigma _1 \cup \varSigma _2\), and deliberately confounding the relations \(\ltimes \) and \(\preccurlyeq \) in \(\le \):
Definition 9\(^{\star }\) (SO Associated Signature). The SO associated signature to the SO multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq421_HTML.gif is the ordered triple https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq422_HTML.gif , where \(S = S_1 \cup S_2\), \(\mathord {\le } = \mathord {\preccurlyeq } \cup \mathord {\ltimes }\), and \(\varPi = \varSigma _1 \cup \varSigma _2\).
The embedding of \(\ltimes \) in \(\le \) (i.e., \(\mathord {\ltimes } \subseteq \mathord {\le }\)) in the associated signature enables the order-sorted term algebra construction to automatically build multi-language terms, without the need for an explicit operator \(\hookrightarrow \) that acts as a bridge between syntactic categories. It is easy to see that the term algebra over the associated signature is precisely the symbols-free version of multi-language described at the beginning.
Unfortunately, multi-language regularity does not follow anymore from single-languages regularity and vice versa (see Figs. 3 and 4)6. More formally, Proposition 2 does not hold in this new context:
  • Suppose https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figao_HTML.gif , https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figap_HTML.gif , \(\le _1\) and \(\le _2\) to be the reflexive relations on \(S_1\) and \(S_2\), respectively, plus https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figaq_HTML.gif , and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figar_HTML.gif . If the join relation \(\ltimes \) is defined as https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figas_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figat_HTML.gif , the resulting associated signature is no longer regular, although https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq441_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq442_HTML.gif are regular (Fig. 3a). In Fig. 3b, it is easy to see that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figau_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figav_HTML.gif but the set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figaw_HTML.gif does not have a least element w.r.t. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq443_HTML.gif .
  • On the other hand, let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figax_HTML.gif , https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figay_HTML.gif , \(\le _1\) and \(\le _2\) be the reflexive relations on \(S_1\) and \(S_2\), respectively, plus https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figaz_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figba_HTML.gif , and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbb_HTML.gif . If the join relation \(\ltimes \) is defined as https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbc_HTML.gif , and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbd_HTML.gif , the resulting associated signature is regular (Fig. 4a), although https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq449_HTML.gif is not: given https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbe_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbf_HTML.gif , the set https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbg_HTML.gif has least element https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbh_HTML.gif w.r.t. https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbi_HTML.gif (Fig. 4b).
A positive result can be obtained by recalling that regularity is easier to check when https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq450_HTML.gif satisfies the descending chain condition ( https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbj_HTML.gif ):
Lemma 1
(Regularity over DCC poset [19]). An order-sorted signature \(\varSigma \) over a https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbk_HTML.gif poset https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq452_HTML.gif is regular if and only if whenever \(\sigma \in \varSigma _{w_1, s_1} \cap \varSigma _{w_2, s_2}\) and there is some \(w_0 \le w_1, w_2\), then there is some \(w \le w_1, w_2\) such that \(\sigma \in \varSigma _{w, s}\) and \(w_0 \le w\).
At this point, we can relate the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbl_HTML.gif of the poset https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq458_HTML.gif in the associated signature of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq459_HTML.gif to the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbm_HTML.gif of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq460_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq461_HTML.gif :
Proposition 3
Let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq462_HTML.gif be the associated signature of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq463_HTML.gif . Then, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq464_HTML.gif is https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbn_HTML.gif if and only if https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq465_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq466_HTML.gif are https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbo_HTML.gif .
As a result, whenever we know that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq467_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq468_HTML.gif are https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbp_HTML.gif , we can check the regularity of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq469_HTML.gif by employing the Lemma 1 without checking whether https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq470_HTML.gif is https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbq_HTML.gif .
Algebra. In this multi-language construction, the boundary functions behaviour is no more bounded to syntactical operators as in the previous sections, but it is inherited by homomorphisms. A necessary condition to accomplish this aim is the commutativity of interpretation functions with boundary functions:
Definition 7\(^{\star }\) (SO Multi-Language Algebra). Let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq472_HTML.gif be an https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbr_HTML.gif multi-language signature. A semantic-only (SO) multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq473_HTML.gif -algebra is an SP multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq474_HTML.gif -algebra \(\mathcal {A}\) such that
  • (3a\(^{\star }\))  \(\sigma \in \varSigma _{w_1, s_1} \cap \varSigma _{w_2, s_2}\) and \(w_1 \ltimes w_2\) imply that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq479_HTML.gif for each \(a \in A_{w_1}\).
Note that \(\sigma \in \varSigma _{w_1, s_1} \cap \varSigma _{w_2, s_2}\) and \(w_1 \ltimes w_2\) imply \(s_1 \ltimes s_2\) by condition (3s\(^{\star }\)). The notion of homomorphism remains unchanged from Definition 8 (to understand how the homomorphisms inherit the boundary functions behaviour, see the proof of Theorem 6).
The term algebra is defined similarly to Definition 10, except for boundary functions:
Definition 10\(^{\star }\) (SO Multi-Language Term Algebra). The semantic-only (SO) multi-language term algebra \(\mathcal {T}\) over an SO multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq487_HTML.gif with boundary functions \(\tau \) is defined as follows:
  • (1t\(^{\star }\)) \(s \in S\) implies \(T_s = T_{\varPi , s}\);
  • (2t\(^{\star }\)) \(\sigma \in \varSigma _{w, s}\) implies https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq494_HTML.gif ; and
  • (3t\(^{\star }\)) \(s \ltimes s'\) implies https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbs_HTML.gif .
Since the subsort relation \(\le \) includes the join relation \(\ltimes \), \(s \ltimes s'\) implies \(T_{\varPi ,s} = T_s \subseteq T_{s'} = T_{\varPi ,s'}\). Thus, the boundary function \(\tau _{s,s'}\) can be defined as the identity on the smaller domain (note that it trivially satisfies the commutativity condition (3a\(^{\star }\))).
Proposition 4
Let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq503_HTML.gif be an https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbt_HTML.gif multi-language signature. Then, the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbu_HTML.gif multi-language term https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq504_HTML.gif -algebra is a proper https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbv_HTML.gif multi-language algebra.
Theorem 5
Let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq505_HTML.gif be a https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbw_HTML.gif multi-language signature. The class of all https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbx_HTML.gif https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq506_HTML.gif -algebras and the class of all https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq507_HTML.gif -homomorphisms form a category denoted by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq508_HTML.gif .
We can now prove the initiality of \(\mathcal {T}\) in its category.
Theorem 6
(Initiality of \(\mathcal {T}\)). Let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq511_HTML.gif be a regular multi-language signature. Then, the term algebra \(\mathcal {T}\) is an initial object in the category https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq513_HTML.gif .
Thanks to the initiality of the term algebra, the definition of term semantics is the same of Definition 12.
Example. Let \(\mathcal {A}_1\) and \(\mathcal {A}_2\) be two order-sorted algebras over the signatures https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq516_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq517_HTML.gif , respectively, as formalized in the example in Sect. 3. Suppose we are interested in a new multi-language \(\mathcal {A}\) over https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq519_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq520_HTML.gif such that any string expressions t of sort https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figby_HTML.gif in https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq521_HTML.gif can denote the natural number https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq522_HTML.gif when embedded in https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq523_HTML.gif terms. For instance, we require that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figbz_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figca_HTML.gif , but https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcb_HTML.gif (parentheses in the last term have only been used to disambiguate the parsing result).
Since the requirements demand to use string expressions in place of natural numbers, the join relation \(\ltimes \) shall define https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcc_HTML.gif and ensure transitivity, hence https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcd_HTML.gif , https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figce_HTML.gif , and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcf_HTML.gif .
The signatures https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq525_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq526_HTML.gif are trivially regular. However, by merging https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq527_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq528_HTML.gif , we are causing subsort polymorphism on the symbol \(\texttt {+}\), which is used as sum operator in \(\mathcal {A}_1\) and as concatenation operator in \(\mathcal {A}_2\), and therefore we have to check the regularity: Let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcg_HTML.gif , and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figch_HTML.gif . Given \(\texttt {+} \in \varSigma _{w_1,s_1} \cap \varSigma _{w_2,s_2}\) and the lower bound https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figci_HTML.gif , then there exists https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcj_HTML.gif such that \(w \le w_1, w_2\) and \(\texttt {+} \in \varSigma _{w,s}\), where https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figck_HTML.gif (we have employed Lemma 1 thanks to Proposition 3). Analogously, when \(w_0 = w_1, w_2\) the relative least rank is https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcl_HTML.gif .
The multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq536_HTML.gif -algebra \(\mathcal {A}\) is now defined by joining the projected algebras \(\mathcal {A}_1\) and \(\mathcal {A}_2\) and by defining boundary functions \(a_{s, s'}\) for each \(s \ltimes s'\) such that convert strings in naturals (their length) when strings are used in place of naturals:
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ11_HTML.png
The above definition of boundary functions satisfy both conditions (2a\(^{*}\)) and (3a\(^{\star }\)).
The initiality theorem yields the semantic homomorphism from \(\mathcal {T}\) to \(\mathcal {A}\). For instance, suppose we want to compute the semantics of the term
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ12_HTML.png
The least sorts of t, \(t_1\), and \(t_2\) are https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcm_HTML.gif , and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcn_HTML.gif , respectively. The operator \(\texttt {+}\) belongs to both https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figco_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcp_HTML.gif , and its least rank w.r.t. the lower bound https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcq_HTML.gif is https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcr_HTML.gif . By Definition 12 we have
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ13_HTML.png
At this point, since https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcs_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figct_HTML.gif , then the least rank of the root symbol + of \(t_1\) w.r.t. the lower bound https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcu_HTML.gif is https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcv_HTML.gif , thus
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ14_HTML.png
Similarly, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcw_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcx_HTML.gif . Then, the least rank of the root symbol + of \(t_2\) w.r.t. the lower bound https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcy_HTML.gif is https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figcz_HTML.gif and therefore we have
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ15_HTML.png
Finally,
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ16_HTML.png
as desired.
We can observe that without any syntactical operator the framework is still able to apply the correct boundary functions to move values across languages.

5 Reduction to Order-Sorted Algebra

The constructions in the previous sections beg the question whether a multi-language algebra admits an equivalent order-sorted representation. Conceptually, it would mean that being a multi-language is essentially a matter of perspective: By forgetting how the multi-language has been constructed, what is left is simply an ordinary language. Mathematically speaking, it requires us to exhibit a reduction functor F from the multi-language category to an order-sorted one, such that there is an isomorphism \(\phi \) between the carrier sets of the multi-language term https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq552_HTML.gif -algebra \(\mathcal {T}\) and \(F(\mathcal {T})\), and such that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figda_HTML.gif for each \(t \in \mathcal {T}\) and for each multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq556_HTML.gif -algebra \(\mathcal {A}\).
In the following, we denote the reduction functor by F, \(F^*\), and \(F^\star \) accordingly whether its domain is the category https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq560_HTML.gif , https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq561_HTML.gif , and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq562_HTML.gif , respectively.
In the case of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq563_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq564_HTML.gif categories, the construction of F and \(F^*\) is very simple, and we illustrate it only for the plain multi-language algebras of Sect. 3: Let \(\mathcal {A}\) be a multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq567_HTML.gif -algebra. Then, we define the order-sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq568_HTML.gif -algebra \(\mathcal {A}_\varPi \) (called the associated order-sorted algebra of \(\mathcal {A}\)) by setting
  • \((1\pi )\) \(A_{\varPi , s} = A_s\) for each \(s \in S\);
  • \((2\pi )\) https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdb_HTML.gif for each \(\sigma \in \varSigma ^i_{w,s}\) and \(i = 1,2\); and
  • \((3\pi )\) https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdc_HTML.gif for each \(s \ltimes s'\).
If \(\mathcal {A}\) and \(\mathcal {B}\) are multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq581_HTML.gif -algebras, and h is a multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq582_HTML.gif -homomorphism from \(\mathcal {A}\) to \(\mathcal {B}\), the functor F maps \(\mathcal {A}\) and \(\mathcal {B}\) to their associated order-sorted algebras \(\mathcal {A}_\varPi \) and \(\mathcal {B}_\varPi \) and the homomorphism h to itself. Since \(A_\varPi = A\), the isomorphism \(\phi \) is the identity function.
Theorem 7
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq591_HTML.gif is a functor for every multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq592_HTML.gif . Moreover, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq593_HTML.gif for each \(t \in \mathcal {T}\) and for each multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq595_HTML.gif -algebra \(\mathcal {A}\).
If \(\mathcal {A}\) is an https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdd_HTML.gif multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq598_HTML.gif -algebra, the construction of the reduction functor \(F^*\) is similar to the definition of F. The only difference is the equation in the condition (3\(\pi \)) that turns into
  • (3\(\pi ^*\)) https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq602_HTML.gif for each \(s \ltimes s'\).
Finally, the definition of \(F^\star \) starting from the category https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq605_HTML.gif of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figde_HTML.gif multi-language algebras is slightly different. We define \(F^\star \) as a map from the multi-language category https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq607_HTML.gif to the order-sorted category https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq608_HTML.gif . We denote the reduction of a multi-language algebra \(\mathcal {A}\) and a homomorphism https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq610_HTML.gif as https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq611_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq612_HTML.gif . The order-sorted algebra https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq613_HTML.gif has the same carrier sets of the multi-language algebra \(\mathcal {A}\), i.e., https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq615_HTML.gif , and interpretation functions https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdf_HTML.gif . Furthermore, we define https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq616_HTML.gif . Intuitively, the algebra https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq617_HTML.gif is formally defined simply by forgetting about the boundary functions, while the homomorphism https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq618_HTML.gif inherits their semantics from h. Again, the isomorphism \(\phi \) is the identity.
Theorem 8
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq620_HTML.gif is a functor for every https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdg_HTML.gif multi-language signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq621_HTML.gif . Moreover, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq622_HTML.gif for each \(t \in \mathcal {T}\) and for each https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdh_HTML.gif multi-language https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq624_HTML.gif -algebra \(\mathcal {A}\).
Unfortunately, even though \(\mathcal {T}\) is an initial algebra in its category, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq627_HTML.gif is not: Given two multi-language algebras \(\mathcal {A}\) and \(\mathcal {A}'\) that differ only in the boundary functions (we denote by \(\alpha \) and \(\alpha '\) the families of boundary functions of \(\mathcal {A}\) and \(\mathcal {A}'\), respectively) they both get mapped by \(F^\star \) to the same order-sorted algebra https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq635_HTML.gif . Thus, if https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq636_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq637_HTML.gif are the unique homomorphisms going from \(\mathcal {T}\) to \(\mathcal {A}\) and \(\mathcal {A}'\), the functor F maps them to two different order-sorted homomorphisms https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq641_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq642_HTML.gif both leaving https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq643_HTML.gif and going to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq644_HTML.gif , hence losing the uniqueness property. However, this does not pose a problem once fixed a family of boundary functions:
Theorem 9
Let \(\mathcal {T}\) be the multi-language term https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq646_HTML.gif -algebra and \(\mathcal {A}\) be an order-sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq648_HTML.gif -algebra. Given a family of boundary functions https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq649_HTML.gif such that satisfies condition (3a\(^{\star }\)), there exists a unique order-sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdi_HTML.gif -homomorphism https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq651_HTML.gif commuting with \(\alpha \), i.e., if \(s \ltimes s'\), then \(h^\alpha _{s'}(t) = \alpha _{s, s'}(h^\alpha _s(t))\) for each \(t \in T_s\).
The reduction theorems presented in this section have a strong consequence: all the already known results for the order-sorted algebras can be lifted to the multi-language world.

6 An Example of Multi-Language Construction

The first theoretical paper addressing the problem of multi-language construction is [30]. The authors study the so-called natural embedding (a more realistic improvement of the lump embedding [7, 30, 34, 40]), in which Scheme terms can be converted to equivalent ML terms, and vice versa.7 The novelty in their approach is how they succeed to define boundaries in order to translate values from Scheme to ML. Indeed, the latter does not admit an equivalent representation for each Scheme function. Their solution is to “represent a Scheme procedure in ML at type \(\tau _1\rightarrow \tau _2\) by a new procedure that takes an argument of type \(\tau _1\), converts it to a Scheme equivalent, runs the original Scheme procedure on that value, and then converts the result back to ML at type \(\tau _2\).
Our goal here is not to discuss a fully explained presentation of ML and Scheme languages in the form of order-sorted algebras, but rather to show how we can model the natural embedding construction in our framework. Doing so, we provide a sketchy formalization of Scheme and ML syntax and semantics, and we redirect the reader to [30] for all the languages details.
To provide the semantics of Scheme, we follow the same approach of Goguen et al. [15] where the denotational semantics of the simple applicative language (SAL) introduced by Reynolds [42] is given by means of an algebra, exploiting the initiality theorem. Such a language is a “syntactically sugared” version of the untyped lambda calculus with the fixpoint operator, which in turn is very similar to Scheme.
Let https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq659_HTML.gif be a set of variables and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq660_HTML.gif be the naturals lattice with \(\top \) and \(\bot \) adjoined. From [46], there exists a complete lattice V such that satisfies the isomorphism https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdj_HTML.gif , where \(+\) is the disjoint union with minimum and maximum elements identified, and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdk_HTML.gif is the complete lattice of Scott-continuous functions from V to V. Given https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdl_HTML.gif , we define the injections https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdm_HTML.gif and \(i_\xi = \phi ^{-1} \circ j_\xi \), and the projection https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq665_HTML.gif such that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdn_HTML.gif . The set of all Scheme environments is the lattice of all total functions \(\text {P}= X\rightarrow V\) with componentwise ordering \(\rho \sqsubseteq \rho '\) if and only if \(\rho (x) \sqsubseteq \rho '(x)\) in V for all \(x \in X\). Furthermore, we define auxiliary functions (see [15] for a more detailed explanation) in order to provide the semantics of the language (in the following, \(x \in X\) and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq671_HTML.gif ):
  • https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq672_HTML.gif , \(\textit{get}_x(\rho ) = \rho (x)\) (evaluation function);
  • https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq674_HTML.gif , \(\textit{val}_{n}(\rho ) = n\) (n-constant function);
  • https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq676_HTML.gif , \(\textit{put}_x(\rho , v) = \rho [v/x]\), where https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdo_HTML.gif (environment updating);
  • https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq678_HTML.gif , https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdp_HTML.gif (function application);
  • https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq679_HTML.gif , https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdq_HTML.gif (natural predicate);
  • https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq680_HTML.gif , https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdr_HTML.gif (function predicate);
  • given https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq681_HTML.gif for \(1 \le i \le k\), then https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq683_HTML.gif is defined by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq684_HTML.gif (target-tupling); and
  • given D, \(D'\) and \(D''\), then https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figds_HTML.gif is defined by \(((\textit{abs}(f))(x))(y) = f(x, y)\) (abstraction); and
  • https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq688_HTML.gif (conditional function), https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq689_HTML.gif (addition), and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq690_HTML.gif (subtraction)
    https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ17_HTML.png
    The definition of \(\textit{sub}\) is analogous to the function \(\textit{add}\), with the only difference that, in the second case, \(\textit{sub}(v_1, v_2) = v_1 -_{\mathbb {N}} v_2\), where https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq694_HTML.gif for each \(v_1, v_2 \in \mathbb {N}\).
The semantics of the language is obtained by defining an algebra \(\mathcal {H}\) over a signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq697_HTML.gif ,8 then the initiality yields the unique homomorphism from the term algebra. A Scheme term denotes a continuous function in the semantic domain https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdt_HTML.gif . The interpretation functions of the operators are defined by the following equations:
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ18_HTML.png
For the sake of simplicity, we made a minor change to the language presented in [30]. They have an extra operator wrong to print an error message in case of an illegal operation, due to the lack of a type system. For instance, the sum of two functions produces the error wrong "non-number". To avoid to add cases almost everywhere in the definition of the interpretation functions, we let ill-typed terms to denote the value \(\bot \) without an explicit encoding of the error message. Furthermore, we denote by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq700_HTML.gif the function application.
The ML-like language defined in [30] is an extended version of the simply-typed lambda calculus. As before, we provide its semantics by defining an algebra \(\mathcal {M}\) over an order-sorted signature https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdu_HTML.gif .
Let \(\text {I}\) (should read ‘iota’) be a set of base types and K a \(\text {I}\)-sorted set of base values https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq704_HTML.gif . We inductively define the set of simple types \(\text {T}\): If \(\iota \) is a base type, then it is a simple type; If \(\tau , \tau '\) are simple types, then \((\tau )\rightarrow (\tau ')\) is a simple type (henceforth we omit the parentheses). We abuse notation and extend K to the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq709_HTML.gif -sorted set of simple values https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq710_HTML.gif where \(K_{\tau \rightarrow \tau '} = K_\tau \rightarrow K_{\tau '}\).
The set of all ML environments is defined as the set of all total functions \(\varDelta = Y \rightarrow K\), where https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq713_HTML.gif is a set of variables disjoint from X (this assumption comes from [30]) and \(K = \bigcup _{\tau \in \text {T}} K_\tau \). We instantiate https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdv_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdw_HTML.gif . The poset https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdx_HTML.gif carries all the simple types (i.e., \(\text {T}\subseteq S_2\)) and the sort https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdy_HTML.gif ; \(\le _2\) is the reflexive relation on \(S_2\) plus https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figdz_HTML.gif for each \(\tau \in \text {T}\). An ML term of type \(\tau \) denotes a total function in \(M_\tau = \varDelta \rightarrow K_\tau \), and we define https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figea_HTML.gif . Due to the Turing-incompleteness of such a language, we do not need all the mathematical machinery of [15, 46] to formalize its semantics.
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ19_HTML.png
Until now, we have just formalized the single-languages. The multi-language \(\mathcal {A}\) that combines Scheme and ML is obtained by requiring https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figeb_HTML.gif and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figec_HTML.gif in order to use ML terms in place of Scheme terms and vice versa. However, in the simplest version of the natural embedding, “the system has stuck states, since a boundary might receive a value of an inappropriate shape” [30]. They restore the type-soundness by first employing dynamic checks, and then by decoupling error-handling from the value conversion through the use of higher-order contracts [12]. We limit ourselves here to describe the first version; the subsequent refinements can be embodied by further complicating the semantics of the boundary functions (we do not have forced any constraints on them).
Since we need a value representing the notion of stuck state in ML, we have to extend the algebra \(\mathcal {M}\). This is particularly easy by exploiting the underlying framework: We make \(\mathcal {M}^\bot \) into an order-sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq724_HTML.gif -algebra by defining \(M_{\tau }^\bot = \varDelta ^\bot \rightarrow K_{\tau }^\bot \), where \(\varDelta ^\bot = Y \rightarrow K^\bot \), \(K^\bot = \bigcup _{\tau \in \text {T}} K_\tau ^\bot \), and https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq728_HTML.gif , and the https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq729_HTML.gif -sorted injection \(\phi \) from \(M_\tau \) to \(M_\tau ^\bot \) such that \(\varphi (\hat{t}) = \hat{t}\). Now, \(\mathcal {M}^\bot \) becomes an algebra by letting \(\varphi \) to be an order-sorted https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq736_HTML.gif -homomorphism (this in turn forces https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq737_HTML.gif ) and letting the interpretation functions to denote the value \(\bot \) in the remaining non-yet defined cases (namely, they compute the value \(\bot \) whenever one of their arguments is \(\bot \)).
The boundary function https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figed_HTML.gif moves the Scheme value https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq741_HTML.gif in \(M_\tau \):
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ20_HTML.png
where https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figee_HTML.gif and
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ21_HTML.png
Vice versa, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figef_HTML.gif moves values from ML to Scheme. Its definition is analogous to the previous case: https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figeg_HTML.gif where \(\hat{n} = \delta \mapsto n\), and
https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Equ22_HTML.png
These definitions adhere the conversion approach of the natural embedding in [30]: If \(\hat{e}\) is the value denoted by a natural number in Scheme, then it is converted—aside from cases deriving from ill-typed terms—by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figeh_HTML.gif to the corresponding constant function denoting the same natural value in ML. Otherwise, if \(\hat{e}\) is the value denoted by a Scheme function, then it is mapped by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figei_HTML.gif to the ML function with variable x at type \(\tau \rightarrow \tau '\) such that converts its argument of type \(\tau \) to the Scheme equivalent by its conversion through https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figej_HTML.gif to x. Then it runs the original procedure \(\hat{e}\) on it and convert back the result by https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/MediaObjects/480721_1_En_11_Figek_HTML.gif .
Since the given boundary functions are subsort polymorphic, we can improve the construction and handle all the value conversions with a single polymorphic operator as explained in Sect. 4.1.

7 Concluding Remarks

In this paper, we have addressed the problem of providing a formal semantics to the combination of programming languages, the so-called multi-languages. We have introduced a new algebraic framework for modeling this new paradigm, and we have constructively shown how to attain a multi-language specification by only stipulate (1) how the syntactic categories of the single-languages have to be combined and (2) how the values may flow from one language to the other. We have proved the suitability of the framework to unambiguously yield the algebraic semantics of each multi-language term, while simultaneously preserving the single-languages semantics. We have also proved that combining languages is a close operation, i.e., that every multi-language admits an equivalent order-sorted representation. In particular, we have focused our study on the semantic properties of boundary functions in order to provide three different notions of multi-language designed to suit both general and specific cases.
To the best of our knowledge, this is the first attempt to provide a formal semantics of a multi-language independently from the combined languages.
Related Works. Cross-language interoperability is a well-researched area both from theoretical and practical points of view. The most related work to our approach is undoubtedly [30], which provides operational semantics to a combined language obtained by embedding a Scheme-like language into an ML-like language. Such an outcome is achieved by introducing boundaries, syntactic constructs that model the flow of values from one language to the other. Ours boundary functions draw heavily from their work. Nonetheless, we shift them to a semantic level, in order to several variants of multi-language constructions.
[7, 21, 36, 40, 53] take a similar line and combine typed and untyped languages (Lua and ML [40], Java and PLT Scheme [21], or Assembly and a typed functional language [36]), focusing on typing issues and values exchanging techniques. Instead of focusing on a particular problem, we adopt a rather general framework to model languages. This choice abstracts away many low-level details, allowing us to reason on semantic concerns in more general terms, without having to fix any particular pair of languages.
A lot of work has been done on multi-language runtime mechanisms: [20] provides a type system for a fragment of Microsoft Intermediate Language (IL) used by the .NET framework, that allows programmers to write components in several languages (C#, Visual Basic, VBScript, ...) which are then translated to IL. [22] proposes a virtual machine that can execute the composition of dynamically typed programming languages (Ruby and JavaScript) and statically typed one (C). [4, 5] describes a multi-language runtime mechanism achieved by combining single-language interpreters of (different versions of) Python and Prolog.
Future Works. From our perspective, the research presented in this paper opens up on three directions. Firstly, future works should aim to provide an operational semantics to the formalization of multi-languages. Rewriting logic seems the most reasonable approach to unifying the denotational world, presented in this paper, to the operational one [31]. This line of research is particularly useful in order to move towards an implementation of an automatic tool able to combine languages such that the resulting multi-language guarantees the results proved in the paper.
Secondly, future research applies to use the multi-language model in order to study the problem of analyzing multi-language programs. In particular, we aim at investigating how it is possible to obtain analyses of multi-language programs by merging already existing analyses of the single combined languages.
Finally, further studies should investigate the problem of compiling multi-languages. Current compilers are closed tools, non-parametric on language constructs (for instance, we cannot compile a single if-then-else term of a standard language like C or Java unless it is plugged into a valid program). Several works on typing [1, 20, 26], compiling [2, 37], and running [23, 50] multi-language programs already exist, but without providing a formal notion of multi-language. It would be beneficial to study how their approaches can be applied to the formal framework developed in this paper.
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.
The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.
Fußnoten
1
Other popular engines that obey the embedded interpreters paradigm are Jython [28], JScript [44], and Rhino [13].
 
2
To be pedantic, we should introduce the one-point domain https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq52_HTML.gif and then define https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq53_HTML.gif .
 
3
This hypothesis is non-restrictive: We can always perform a renaming of the sorts.
 
4
Sorts may be understood as syntactic categories, in the sense of formal grammars. Given a context-free grammar G, it is possible to define a many-sorted signature \(\varSigma _G\) where non-terminals become sorts and such that each term t in the term algebra \(\mathcal {T}_{\varSigma _G}\) is isomorphic to the parse tree of t with respect to G (see [15] for details).
 
5
This is essential in order to generalize the concept of syntactical boundary functions of [30] to semantic-only functions in Sect. 4.2.
 
6
An (horizontal) arrow from an arity symbol w to a sort s labelled with an operator symbol \(\sigma \) is an alternative shorthand for https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq431_HTML.gif . A (vertical) single line between two sorts s below \(s'\) labelled with a binary relation \(\le \) means that \(s\le s'\) (if the binary relation is the join relation \(\ltimes \) the line is doubled). A dotted rectangle around operators is a graphical representation of the set of ranks (ws) that must have a minimum element (red arrows) in order for the signature to be regular.
 
7
To be specific, the authors combine “an extended model of the untyped call-by-value lambda calculus, which is used as a stand-in for Scheme, and an extended model of the simply-typed lambda calculus, which is used as a stand-in for ML”.
 
8
We do not define https://static-content.springer.com/image/chp%3A10.1007%2F978-3-030-17184-1_11/480721_1_En_11_IEq698_HTML.gif explicitly since it can be inferred by the algebra equations below.
 
Literatur
1.
Zurück zum Zitat Abadi, M., Cardelli, L., Pierce, B.C., Plotkin, G.D.: Dynamic typing in a statically typed language. ACM Trans. Program. Lang. Syst. 13(2), 237–268 (1991)CrossRef Abadi, M., Cardelli, L., Pierce, B.C., Plotkin, G.D.: Dynamic typing in a statically typed language. ACM Trans. Program. Lang. Syst. 13(2), 237–268 (1991)CrossRef
2.
Zurück zum Zitat Ahmed, A., Blume, M.: An equivalence-preserving CPS translation via multi-language semantics. SIGPLAN Not. 46(9), 431–444 (2011)CrossRef Ahmed, A., Blume, M.: An equivalence-preserving CPS translation via multi-language semantics. SIGPLAN Not. 46(9), 431–444 (2011)CrossRef
3.
Zurück zum Zitat Alencar, A.J., Goguen, J.A.: Object-oriented specification case studies. In: Lano, K., Haughton, H. (eds.) Specification in OOZE with Examples, pp. 158–183. Prentice Hall International (UK) Ltd., Hertfordshire (1994) Alencar, A.J., Goguen, J.A.: Object-oriented specification case studies. In: Lano, K., Haughton, H. (eds.) Specification in OOZE with Examples, pp. 158–183. Prentice Hall International (UK) Ltd., Hertfordshire (1994)
4.
Zurück zum Zitat Barrett, E., Bolz, C.F., Tratt, L.: Unipycation: a case study in cross-language tracing. In: Proceedings of the 7th ACM Workshop on Virtual Machines and Intermediate Languages, pp. 31–40. ACM, New York (2013) Barrett, E., Bolz, C.F., Tratt, L.: Unipycation: a case study in cross-language tracing. In: Proceedings of the 7th ACM Workshop on Virtual Machines and Intermediate Languages, pp. 31–40. ACM, New York (2013)
5.
Zurück zum Zitat Barrett, E., Bolz, C.F., Tratt, L.: Approaches to interpreter composition. Comput. Lang. Syst. Struct. 44, 199–217 (2015) Barrett, E., Bolz, C.F., Tratt, L.: Approaches to interpreter composition. Comput. Lang. Syst. Struct. 44, 199–217 (2015)
6.
Zurück zum Zitat Beierle, C., Meyer, G.: Run-time type computations in the Warren abstract machine. J. Log. Program. 18(2), 123–148 (1994)MathSciNetCrossRef Beierle, C., Meyer, G.: Run-time type computations in the Warren abstract machine. J. Log. Program. 18(2), 123–148 (1994)MathSciNetCrossRef
8.
Zurück zum Zitat Chisnall, D.: The challenge of cross-language interoperability. Commun. ACM 56(12), 50–56 (2013)CrossRef Chisnall, D.: The challenge of cross-language interoperability. Commun. ACM 56(12), 50–56 (2013)CrossRef
9.
Zurück zum Zitat Dybvig, R.K.: The Scheme Programming Language, 4th edn. The MIT Press, Cambridge (2009)MATH Dybvig, R.K.: The Scheme Programming Language, 4th edn. The MIT Press, Cambridge (2009)MATH
11.
Zurück zum Zitat Erwig, M., Güting, R.H.: Explicit graphs in a functional model for spatial databases. IEEE Trans. Knowl. Data Eng. 6(5), 787–804 (1994)CrossRef Erwig, M., Güting, R.H.: Explicit graphs in a functional model for spatial databases. IEEE Trans. Knowl. Data Eng. 6(5), 787–804 (1994)CrossRef
12.
Zurück zum Zitat Findler, R.B., Felleisen, M.: Contracts for higher-order functions. In: Proceedings of the Seventh ACM SIGPLAN International Conference on Functional Programming, ICFP 2002, pp. 48–59. ACM, New York (2002) Findler, R.B., Felleisen, M.: Contracts for higher-order functions. In: Proceedings of the Seventh ACM SIGPLAN International Conference on Functional Programming, ICFP 2002, pp. 48–59. ACM, New York (2002)
13.
Zurück zum Zitat Flanagan, D.: JavaScript: The Definitive Guide. O’Reilly Media Inc., Sebastopol (2006)MATH Flanagan, D.: JavaScript: The Definitive Guide. O’Reilly Media Inc., Sebastopol (2006)MATH
14.
Zurück zum Zitat Furr, M., Foster, J.S.: Checking type safety of foreign function calls. SIGPLAN Not. 40(6), 62–72 (2005)CrossRef Furr, M., Foster, J.S.: Checking type safety of foreign function calls. SIGPLAN Not. 40(6), 62–72 (2005)CrossRef
15.
Zurück zum Zitat Goguen, J.A., Thatcher, J.W., Wagner, E.G., Wright, J.B.: Initial algebra semantics and continuous algebras. J. ACM 24(1), 68–95 (1977)MathSciNetCrossRef Goguen, J.A., Thatcher, J.W., Wagner, E.G., Wright, J.B.: Initial algebra semantics and continuous algebras. J. ACM 24(1), 68–95 (1977)MathSciNetCrossRef
16.
Zurück zum Zitat Goguen, J.: Tossing algebraic flowers down the great divide (1999) Goguen, J.: Tossing algebraic flowers down the great divide (1999)
18.
Zurück zum Zitat Goguen, J.A., Diaconescu, R.: An oxford survey of order sorted algebra. Math. Struct. Comput. Sci. 4(3), 363–392 (1994)MathSciNetCrossRef Goguen, J.A., Diaconescu, R.: An oxford survey of order sorted algebra. Math. Struct. Comput. Sci. 4(3), 363–392 (1994)MathSciNetCrossRef
19.
Zurück zum Zitat 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)MathSciNetCrossRef 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)MathSciNetCrossRef
20.
Zurück zum Zitat 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, 17–19 January 2001, pp. 248–260. ACM, New York (2001) 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, 17–19 January 2001, pp. 248–260. ACM, New York (2001)
22.
Zurück zum Zitat 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)CrossRef 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)CrossRef
23.
Zurück zum Zitat Grimmer, M., Seaton, C., Schatz, R., Würthinger, T., Mössenböck, H.: High-performance cross-language interoperability in a multi-language runtime. In: Proceedings of the 11th Symposium on Dynamic Languages, DLS 2015, Part of SPLASH 2015, Pittsburgh, PA, USA, 25–30 October 2015, pp. 78–90. ACM, New York (2015) Grimmer, M., Seaton, C., Schatz, R., Würthinger, T., Mössenböck, H.: High-performance cross-language interoperability in a multi-language runtime. In: Proceedings of the 11th Symposium on Dynamic Languages, DLS 2015, Part of SPLASH 2015, Pittsburgh, PA, USA, 25–30 October 2015, pp. 78–90. ACM, New York (2015)
24.
Zurück zum Zitat Haxthausen, A.E.: Order-sorted algebraic specifications with higher-order functions. Theor. Comput. Sci. 183(2), 157–185 (1997)MathSciNetCrossRef Haxthausen, A.E.: Order-sorted algebraic specifications with higher-order functions. Theor. Comput. Sci. 183(2), 157–185 (1997)MathSciNetCrossRef
25.
Zurück zum Zitat Hearn, A.C., Schrüfer, E.: A computer algebra system based on order-sorted algebra. J. Symb. Comput. 19(1), 65–77 (1995)MathSciNetCrossRef Hearn, A.C., Schrüfer, E.: A computer algebra system based on order-sorted algebra. J. Symb. Comput. 19(1), 65–77 (1995)MathSciNetCrossRef
26.
Zurück zum Zitat Henglein, F., Rehof, J.: Safe polymorphic type inference for scheme: translating scheme to ML. In: Proceedings of the Seventh International Conference on Functional Programming Languages and Computer Architecture, FPCA 1995, La Jolla, California, USA, 25–28 June 1995, pp. 192–203. ACM, New York (1995) Henglein, F., Rehof, J.: Safe polymorphic type inference for scheme: translating scheme to ML. In: Proceedings of the Seventh International Conference on Functional Programming Languages and Computer Architecture, FPCA 1995, La Jolla, California, USA, 25–28 June 1995, pp. 192–203. ACM, New York (1995)
28.
Zurück zum Zitat 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)CrossRef 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)CrossRef
29.
Zurück zum Zitat Liang, S.: Java Native Interface: Programmer’s Guide and Reference, 1st edn. Addison-Wesley Longman Publishing Co., Inc., Boston (1999) Liang, S.: Java Native Interface: Programmer’s Guide and Reference, 1st edn. Addison-Wesley Longman Publishing Co., Inc., Boston (1999)
30.
Zurück zum Zitat Matthews, J., Findler, R.B.: Operational semantics for multi-language programs. SIGPLAN Not. 42(1), 3–10 (2007)CrossRef Matthews, J., Findler, R.B.: Operational semantics for multi-language programs. SIGPLAN Not. 42(1), 3–10 (2007)CrossRef
31.
Zurück zum Zitat Meseguer, J., Rosu, G.: The rewriting logic semantics project. Electr. Notes Theor. Comput. Sci. 156(1), 27–56 (2006)CrossRef Meseguer, J., Rosu, G.: The rewriting logic semantics project. Electr. Notes Theor. Comput. Sci. 156(1), 27–56 (2006)CrossRef
32.
Zurück zum Zitat Meseguer, J.: Conditional rewriting logic as a unified model of concurrency. Theor. Comput. Sci. 96(1), 73–155 (1992)MathSciNetCrossRef Meseguer, J.: Conditional rewriting logic as a unified model of concurrency. Theor. Comput. Sci. 96(1), 73–155 (1992)MathSciNetCrossRef
33.
Zurück zum Zitat Milner, R., Tofte, M., Macqueen, D.: The Definition of Standard ML. MIT Press, Cambridge (1997)CrossRef Milner, R., Tofte, M., Macqueen, D.: The Definition of Standard ML. MIT Press, Cambridge (1997)CrossRef
34.
Zurück zum Zitat Ohori, A., Kato, K.: Semantics for communication primitives in a polymorphic language. In: Proceedings of the 20th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1993, pp. 99–112. ACM, New York (1993) Ohori, A., Kato, K.: Semantics for communication primitives in a polymorphic language. In: Proceedings of the 20th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1993, pp. 99–112. ACM, New York (1993)
35.
Zurück zum Zitat Osera, P.M., Sjöberg, V., Zdancewic, S.: Dependent interoperability. In: Proceedings of the Sixth Workshop on Programming Languages Meets Program Verification, PLPV 2012, pp. 3–14. ACM, New York (2012) Osera, P.M., Sjöberg, V., Zdancewic, S.: Dependent interoperability. In: Proceedings of the Sixth Workshop on Programming Languages Meets Program Verification, PLPV 2012, pp. 3–14. ACM, New York (2012)
36.
Zurück zum Zitat Patterson, D., Perconti, J., Dimoulas, C., Ahmed, A.: FunTAL: reasonably mixing a functional language with assembly. SIGPLAN Not. 52(6), 495–509 (2017)CrossRef Patterson, D., Perconti, J., Dimoulas, C., Ahmed, A.: FunTAL: reasonably mixing a functional language with assembly. SIGPLAN Not. 52(6), 495–509 (2017)CrossRef
38.
Zurück zum Zitat Poigné, A.: Parametrization for order-sorted algebraic specification. J. Comput. Syst. Sci. 40(2), 229–268 (1990)MathSciNetCrossRef Poigné, A.: Parametrization for order-sorted algebraic specification. J. Comput. Syst. Sci. 40(2), 229–268 (1990)MathSciNetCrossRef
39.
Zurück zum Zitat Qian, Z.: Another look at parameterization for order-sorted algebraic specifications. J. Comput. Syst. Sci. 49(3), 620–666 (1994)MathSciNetCrossRef Qian, Z.: Another look at parameterization for order-sorted algebraic specifications. J. Comput. Syst. Sci. 49(3), 620–666 (1994)MathSciNetCrossRef
40.
Zurück zum Zitat Ramsey, N.: Embedding an interpreted language using higher-order functions and types. In: Proceedings of the 2003 Workshop on Interpreters, Virtual Machines and Emulators, IVME 2003, pp. 6–14. ACM, New York (2003) Ramsey, N.: Embedding an interpreted language using higher-order functions and types. In: Proceedings of the 2003 Workshop on Interpreters, Virtual Machines and Emulators, IVME 2003, pp. 6–14. ACM, New York (2003)
41.
Zurück zum Zitat Ramsey, N.: ML module mania: a type-safe, separately compiled, extensible interpreter. Electron. Notes Theor. Comput. Sci. 148(2), 181–209 (2006)CrossRef Ramsey, N.: ML module mania: a type-safe, separately compiled, extensible interpreter. Electron. Notes Theor. Comput. Sci. 148(2), 181–209 (2006)CrossRef
42.
Zurück zum Zitat Reynolds, J.C.: Definitional interpreters for higher-order programming languages. In: Proceedings of the ACM Annual Conference - Volume 2, ACM 1972, pp. 717–740. ACM, New York (1972) Reynolds, J.C.: Definitional interpreters for higher-order programming languages. In: Proceedings of the ACM Annual Conference - Volume 2, ACM 1972, pp. 717–740. ACM, New York (1972)
43.
Zurück zum Zitat Robinson, E.: Variations on algebra: monadicity and generalisations of equational therories. Form. Asp. Comput. 13(3), 308–326 (2002)CrossRef Robinson, E.: Variations on algebra: monadicity and generalisations of equational therories. Form. Asp. Comput. 13(3), 308–326 (2002)CrossRef
44.
Zurück zum Zitat Rogers, J.: Microsoft JScript.Net Programming. Sams, Indianapolis (2001) Rogers, J.: Microsoft JScript.Net Programming. Sams, Indianapolis (2001)
46.
Zurück zum Zitat Scott, D.S., Strachey, C.: Toward a Mathematical Semantics for Computer Languages, vol. 1. Oxford University Computing Laboratory, Programming Research Group, Oxford (1971)MATH Scott, D.S., Strachey, C.: Toward a Mathematical Semantics for Computer Languages, vol. 1. Oxford University Computing Laboratory, Programming Research Group, Oxford (1971)MATH
47.
Zurück zum Zitat Sharan, K.: Scripting in Java: Integrating with Groovy and JavaScript, 1st edn. Apress, Berkely (2014) Sharan, K.: Scripting in Java: Integrating with Groovy and JavaScript, 1st edn. Apress, Berkely (2014)
49.
Zurück zum Zitat Tan, G., Morrisett, G.: Ilea: Inter-language analysis across Java and C. SIGPLAN Not. 42(10), 39–56 (2007)CrossRef Tan, G., Morrisett, G.: Ilea: Inter-language analysis across Java and C. SIGPLAN Not. 42(10), 39–56 (2007)CrossRef
53.
Zurück zum Zitat Wrigstad, T., Nardelli, F.Z., Lebresne, S., Östlund, J., Vitek, J.: Integrating typed and untyped code in a scripting language. In: Hermenegildo, M.V., Palsberg, J. (eds.) Proceedings of the 37th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2010, Madrid, Spain, 17–23 January 2010, pp. 377–388. ACM (2010) Wrigstad, T., Nardelli, F.Z., Lebresne, S., Östlund, J., Vitek, J.: Integrating typed and untyped code in a scripting language. In: Hermenegildo, M.V., Palsberg, J. (eds.) Proceedings of the 37th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2010, Madrid, Spain, 17–23 January 2010, pp. 377–388. ACM (2010)
Metadaten
Titel
On the Multi-Language Construction
verfasst von
Samuele Buro
Isabella Mastroeni
Copyright-Jahr
2019
DOI
https://doi.org/10.1007/978-3-030-17184-1_11