ORIGINAL RESEARCH article

Front. Comput. Sci., 12 July 2022

Sec. Theoretical Computer Science

Volume 4 - 2022 | https://doi.org/10.3389/fcomp.2022.792570

Semantics for Combinatory Logic With Intersection Types

  • 1. Faculty of Technical Sciences, University of Novi Sad, Novi Sad, Serbia

  • 2. Mathematical Institute of the Serbian Academy of Sciences and Arts, Belgrade, Serbia

Article metrics

View details

1,9k

Views

572

Downloads

Abstract

There is a plethora of semantics of computational models, nevertheless, the semantics of combinatory logic are among the less investigated ones. In this paper, we propose semantics for the computational system of combinatory logic with intersection types. We define extensional applicative structures endowed with special elements corresponding to primitive combinators. We prove two soundness and completeness results. First, the equational theory of untyped combinatory logic is proven to be sound and complete with respect to the proposed semantics. Second, the system of the combinatory logic with intersection types is proven to be sound and complete with respect to the proposed semantics. The usual approach to the semantics for calculi with types that can be found in the literature is based on models for the untyped calculus endowed with a valuation of type variables which enables the interpretation of types to be defined inductively. We propose, however, a different approach. In the semantics we propose, the interpretation of types is represented as a family of subsets that satisfies certain properties, whereas for a given valuation of term variables, the interpretation of terms is defined inductively. Due to the wide applicability of semantics of computational models, the presented approach could be further developed to other computational models and beyond—to current and foreseen application of semantics to large distributed systems and new challenging technologies.

1. Introduction

In the 1920s two models of computation were invented, combinatory logic and lambda calculus. The foundations of combinatory logic and lambda calculus was established in Curry (1930) and Church (1936), respectively. They were developed with the aim to describe functions, their behavior and properties. Nowadays they serve as a basis for the design of functional programming languages and programming languages at large. These two models of computation have the same computational power, they can express the same computational concepts; however the syntax of combinatory logic is much simpler. The basic idea of combinatory logic, introduced in Schönfinkel (1924), is to build functions without using variables. In order to control function application, type systems were introduced for both combinatory logic and lambda calculus. A recent comprehensive overview of combinators is given in Wolfram (2021). Apart from usual application in programming languages, typed combinatory logic has found its application in a wide range of different fields, such as machine learning, artificial intelligence, program synthesis. Developments of these fields urge for further investigation and development of the theory of combinatory logic.

In computation and type theory, intersection types characterize exactly all strongly normalizing lambda terms (Coppo and Dezani-Ciancaglini, 1978; Sallé, 1978; Pottinger, 1980) providing, on the computational side, a significant extension of simple types, which do not type even some normal forms, such as λx.xx. On the semantical side, intersection types became a powerful tool suitable for analysing lambda models (Barendregt et al., 1983, 2013). Intersection types for different systems have been studied (e.g., van Bakel et al., 2018; de'Liguoro and Treglia, 2019). Combinatory logic was equipped with intersection types in Dezani-Ciancaglini and Hindley (1992) with the same computational advantage of characterizing exactly all strongly normalizing combinatory terms, i.e., computations that always terminate.

The main contributions and results of this paper:

  • We propose a novel semantics for combinatory logic with intersection types. We define extensional applicative structures endowed with special elements corresponding to primitive combinators S, K and I.

  • We prove that the equational theory of untyped combinatory logic is sound and complete with respect to the proposed semantics.

  • We then prove that combinatory logic with intersection types is sound and complete with respect to the proposed semantics.

1.1. Background and Motivation

There have been several approaches to semantics of lambda calculus with intersection types (Barendregt et al., 1983; Dezani-Ciancaglini and Margaria, 1984; Barbanera et al., 1995; Ong and Tsukada, 2012; de Carvalho, 2018) nevertheless none of them addresses combinatory logic. In Barendregt et al. (1983), the authors have introduced the filter models for lambda calculus and proved the soundness and completeness of the type assignment system with respect to the proposed semantics. Further, in Dezani-Ciancaglini and Margaria (1984) a modification of intersection type discipline has been considered, and it has been proved that this type system is sound and complete with respect to the F-semantics. The type assignment system with intersection and union types has been introduced in Barbanera et al. (1995), where authors proposed three semantics for the introduced system and proved soundness and completeness results. In de Carvalho (2018), the author introduced a non-uniform semantics of lambda calculus which allows to measure execution time and presented the intersection type system induced by these semantics, which can be seen as a reformulation of the system of Coppo et al. (1980). In Ong and Tsukada (2012), the two-level game semantics is used to model intersection types.

On the other hand, semantics for combinatory logic with intersection types has not been investigated as much as the semantics for lambda calculus with intersection types. An overview of models of combinatory logic is given in Bimbó (2012), however most of these models are models of untyped combinatory logic. Particularly, one class of models for combinatory logic with intersection types is presented based on theories of types which are in 1 − 1 correspondence with filters. Nevertheless, to the best of our knowledge filter models for combinatory logic with intersection types has not been published anywhere. The lack of study of models of combinatory logic has been our motivation for the present research.

1.2. Organization of the Paper

In Section 2, we briefly review basic notions of the untyped combinatory logic and intersection type assignment system for combinatory logic. We then define the semantics in Section 3. Section 4 presents the results of the paper: in Section 4.1, we prove the soundness and completeness of the equational theory of the untyped combinatory logic with respect to the proposed semantics; in Section 4.2, we prove the soundness and completeness of the combinatory logic with intersection types with respect to the proposed semantics. Section 5 concludes and contains the discussion of the related work.

2. Combinatory Logic With Intersection Types

We shortly review some basic notions of the untyped combinatory logic CL (Barendregt, 1985; Hindley and Seldin, 1986; Bimbó, 2012), and intersection types for combinatory logic (Dezani-Ciancaglini and Hindley, 1992).

2.1. Combinatory Logic

The language of combinatory logic is build up from a countable set of term variables V and a set of term constants using application, the only (binary) operation. Terms of combinatory logic, called CL-terms, are generated by the following grammar:

where x is a term variable and S, K, I are term constants, or constants for short. The set of all CL-terms is denoted by CL and is ranged over by capital letters M, N, …, M1, …. The set of variables that occur in a term M is denoted by FV(M), and the result of substitution of the term N for variable x in the term M is denoted by M{N/x}. The use of parentheses is minimized by the convention that application associates to the left: M1M2Mn means […(M1M2)…Mn].

The main objects of study in combinatory logic are the relations between terms. We will consider the equivalence relation generated by the equational theory given in Figure 1.

Figure 1

Figure 1

Equational theory .

If M = N can be derived from the set of axioms and rules of Figure 1 we say that terms M and N are equal, and we write M = N. The equational theory obtained by adding the rule

to the equational theory will be denoted by , and it represents the extensional equational theory. We write M =ηN, whenever M = N is provable in . We use the notion of equivalence classes: .

2.2. Intersection Types

Intersection types for combinatory logic were introduced in Dezani-Ciancaglini and Hindley (1992). The set of intersection types is generated by the following grammar:

where a belongs to a countable set of type variables VType and ω is a type constant. There are two type forming operations: the arrow, →, which generates the simple types and the intersection, ∩, which provides the extension of the simple types. The set of all intersection types is denoted by Types and is ranged over by σ, τ, …, σ1, …. We can omit parentheses in arrow types by removing outer parentheses and using the convention that, unless otherwise bracketed, nested arrows associate to the right: σ1 → … → σn−1 → σn means (σ1 → … → (σn−1 → σn)). Intersection types are associative: (σ ∩ τ) ∩ ρ is the same as σ ∩ (τ ∩ ρ), and an intersection type takes precedence over an arrow type: σ ∩ τ → ρ means (σ ∩ τ) → ρ.

Definition 2.1 (Dezani-Ciancaglini and Hindley, 1992; Barendregt et al., 2013).

  • A statement is of the form M : σ, where MCL and σ ∈ Types. The term M is the subject and the type σ is the predicate of the statement.

  • A declaration is a statement with a term variable as subject, i.e., x : σ.

  • A basis (context) is a set of declarations with distinct term variables as subjects.

  • Let Γ = {x1 : σ1, …, xn : σn} be a basis. The set dom(Γ) = {x1, …, xn} is the domain of the basis Γ.

  • Let Γ = {x1 : σ1, …, xn : σn} be a basis. Then |Γ| = {σ1, …, σn}.

The subtyping (pre-order) relation on the set of intersection types is defined in the following way.

Definition 2.2 (Dezani-Ciancaglini and Hindley, 1992). The relation ≤ is the smallest binary relation satisfying:

  • σ ≤ σ;

  • σ ≤ σ ∩ σ;

  • σ ≤ ω;

  • σ ∩ τ ≤ σ, σ ∩ τ ≤ τ;

  • ω ≤ ω → ω;

  • (σ → ρ) ∩ (σ → τ) ≤ σ → (ρ ∩ τ);

  • if σ ≤ τ, τ ≤ ρ then σ ≤ ρ;

  • if σ ≤ σ1, τ ≤ τ1, then σ ∩ σ1 ≤ τ ∩ τ1;

  • if σ ≤ σ1, τ ≤ τ1, then σ1 → τ ≤ σ → τ1,

The induced equivalence relation ~ is defined by

The type-assignment system for combinatory logic with intersection types, denoted by CL, is presented in Figure 2. If the typing judgment Γ ⊢ M : σ can be derived by the rules in Figure 2, then it means that the statement M : σ is derivable from the basis Γ and that the term M is typable in the given basis Γ with type σ.

Figure 2

Figure 2

Type-assignment system CL.

The rules (axiom S), (axiom K), and (axiom I) type the combinators S, K, and I, respectively. The rule (axiom ω) enables every combinatory term M to be typable. The rules (→ elim), (∩ elim-l), and (∩ elim-r) are the usual elimination rules for → and ∩, respectively. The rule (∩ intro) is the introduction rule for ∩. The rule (sub-type) is the subsumption rule induced by the subtyping relation on types and the rule (eq) is the rule which enables type preservation under equality.

Remark 2.3. The type-assignment system of Dezani-Ciancaglini and Hindley (1992) is obtained from CL by omitting the rule (eq). Type-assignment statements in are preserved by the equality generated by the equational theory (Dezani-Ciancaglini and Hindley, 1992, Theorem 3.12). In order to obtain a type-assignment system in which types are preserved by the equality generated by the extensional equational theory , the rule (eq) has to be added.

Lemma 2.4 (Weakening lemma). If Γ ⊢ M : σ and Γ ⊆ Γ′ then Γ′ ⊢ M : σ.

Proof. By induction on the length of derivation of Γ ⊢ M : σ.     □

3. Semantics for CL

In this section, we introduce a semantics for combinatory logic with intersection types. We define a model for CL as an applicative structure equipped with an environment.

Definition 3.1. An applicative structure forCL is a tuple

which consists of:

  • a non-empty set D, called domain,

  • a family {Aσ} of sets indexed by types σ, such that for every σ, τ ∈ Types,

    • AσD,

    • Aω = D,

    • Aσ∩τ = AσAτ,

    • if σ ≤ τ, then AσAτ.

  • an application function App:D × DD, such that for every σ, τ ∈ Types,

    App↾(Aσ → τ × Aσ):Aσ → τ × AσAτ.

Definition 3.2. An applicative structure

has combinators if there exist elements s, k, i of the domain D such that

  • sA(σ → (ρ → τ)) → ((σ → ρ) → (σ → τ)) for every σ, ρ, τ ∈ Types,

  • kAσ → (τ → σ) for every σ, τ ∈ Types,

  • iAσ → σ for every σ ∈ Types,

  • for every a, b, cD the following equations hold:

Definition 3.3. An applicative structure

is extensional if for all f, gD it holds that

Definition 3.4. An environment ρ for an applicative structure is a mapping from a set of term variables to the domain, ρ:VD.

Although the proposed semantics is not Kripke-style semantics, its definition is inspired by the Kripke-style semantics introduced in Mitchell and Moggi (1991) and Kašterović and Ghilezan (2020), where a model is also defined as an applicative structure provided with an environment. The important difference between Definition 3.4 and the definition of an environment in Kašterović and Ghilezan (2020) is the fact that the environment in Kašterović and Ghilezan (2020) was a partial mapping, whereas herein it is a total mapping. The motivation for defining environments as total mappings will be explained in Remark 4.5.

Let ρ be an environment for and aD. By ρ(x: = a) we denote the environment for such that for all yV

Definition 3.5. A model for CL is a pair , where is an extensional applicative structure for CL with combinators, and ρ is an environment for .

Definition 3.6. Let be a model for CL. We define the meaning of a term M in the environment ρ, denoted by ⟦Mρ, inductively as follows:

  • xρ = ρ(x),

  • Sρ = s,

  • Kρ = k,

  • Iρ = i,

  • MNρ = App(⟦Mρ, ⟦Nρ).

Note that the meaning of a term does not depend on the meaning of the variables that do not occur in the term. Since an environment ρ is a total mapping and ρ(x) is defined for every variable x, the meaning of every term M, denoted by ⟦Mρ, is also well-defined.

Remark 3.7. An important difference between the applicative structure we define and the one introduced in Mitchell and Moggi (1991) is that we have a domain in the applicative structure. In Mitchell and Moggi (1991) the authors define the interpretation of the judgment Γ ⊢ M : σ, they interpret the term with its type. In turn, we wanted to be able to define the interpretation of a term independent of its type. For this reason we have introduced a domain as part of the applicative structure.

Lemma 3.8. Letbe an extensional applicative structure forCLwith combinators, ρ1and ρ2environments forandMaCL-term. If ρ1(x) = ρ2(x) holds for every variablexFV(M), thenMρ1 = ⟦Mρ2.

Proof. We prove the statement by induction on the structure of the term M.

  • Let M be a variable x. If ρ1(x) = ρ2(x), then ⟦xρ1 = ρ1(x) = ρ2(x) = ⟦xρ2.

  • If M is a term constant, then its interpretation does not depend on the environment, but only on the applicative structure. For example, let M be a term constant S, then ⟦Sρ1 = s = ⟦Sρ2.

  • If M is an application NL, then by the induction hypothesis the statement holds for terms N and L, ⟦Nρ1 = ⟦Nρ2 and ⟦Lρ1 = ⟦Lρ2. Now, by Definition 3.6 we have

     □

Lemma 3.9 (Substitution lemma). LetM, NbeCL-terms and ρ an environment for an applicative structure. Then,

The satisfiability of a statement M : σ in a model and the notion of semantical consequence are defined as follows.

Definition 3.10 (Kašterović and Ghilezan, 2020).

  • A statement M : σ is satisfied in a model Mρ, denoted by , if and only if . In this case we say is a model of the statement M : σ. If a model does not satisfy the statement M : σ, we write .

  • A model is a model of a basis Γ, denoted by , if and only if every declaration x : σ from the basis Γ is satisfied in the model , namely .

  • A statement M : σ is a semantical consequence of a basis Γ, denoted by Γ ⊧ M : σ, if and only if every model of the basis Γ is also a model of the statement M : σ.

4. Soundness and Completeness Results

In this section we present the main results of the paper. We prove in Section 4.1 that the equational theory of the untyped combinatory logic is sound and complete with respect to the proposed semantics. In Section 4.2, we prove that the type-assignment system CL is sound and complete with respect to the proposed semantics.

4.1. Soundness and Completeness of Equational Theory

In the previous section we have introduced models for CL such that the interpretation of every term is defined in a model. A fundamental question to ask is: if two terms are proven to be equal in the equational theory are their interpretations equal in a model?—this is referred to as the soundness of the equational theory with respect to the model. The other direction: if interpretations of two terms are equal in every model are the terms proven to be equal in the equational theory?—is referred to as the completeness.

In the sequel, we prove that the equational theory of untyped combinatory logic is sound and complete with respect to the proposed semantics.

Theorem 4.1 (Soundness of ). IfM =ηN, thenMρ = ⟦Nρfor every model.

Proof. The proof is by induction on the length of the proof of M = N in .

If M = N is an instance of axiom (id), then terms M and N represent the same term L and it holds that ⟦Mρ = ⟦Lρ = ⟦Nρ for every model .

If M = N is obtained by axiom (S), then there exist terms P, Q and R such that terms M and N are terms SPQR and (PR)(QR), respectively. Then, from Definitions 3.2 and 3.6 we obtain

If M = N is obtained by axiom (K), then there exist terms P and Q, such that terms M and N are terms KPQ and P, respectively. Then, from Definitions 3.2 and 3.6 we obtain

If M = N falls under axiom (I), then terms M and N are of the form IP and P, respectively, for some term P. In a similar way as in the previous two cases, we obtain

If M = N is obtained from N = M by rule (sym), then by induction hypothesis ⟦Nρ = ⟦Mρ and the statement holds.

If M = N is obtained from M = L and L = N by rule (trans), then ⟦Mρ = ⟦Lρ and ⟦Lρ = ⟦Nρ hold by induction hypothesis. Thus, ⟦Mρ = ⟦Nρ also holds.

Next, let us suppose that M = N is obtained from L = Q by rule (app-l), then terms M and N are of the form LP and QP, respectively, for some term P. By induction hypothesis ⟦Lρ = ⟦Qρ. From the latter we obtain

Similarly to the previous case, if M = N is obtained by rule (app-r), then terms M and N are of the form PL and PQ, respectively, for some terms P, L, Q such that L = Q is provable in . By induction hypothesis we obtain ⟦Lρ = ⟦Qρ, and thus

Finally, we consider the case where M = N is obtained by applying rule (ext) to Mx = Nx, with x being a variable which appears neither in M nor in N. Let be a model for CL. In order to prove that ⟦Mρ = ⟦Nρ holds, it is enough to prove that for every dD it holds that App(⟦Mρ, d) = App(⟦Nρ, d), because of the extensionality of the applicative structure . Let dD. Since by induction hypothesis ⟦Mxρ = ⟦Nxρ holds in any model, it also holds in model , that is App(⟦Mρ(x: = d), ⟦xρ(x: = d)) = App(⟦Nρ(x: = d), ⟦xρ(x: = d)). From the assumption that x does not appear in M and Lemma 3.8, we obtain ⟦Mρ = ⟦Mρ(x: = d). Similarly, ⟦Nρ = ⟦Nρ(x: = d). Now, we have

Thus, ⟦Mρ = ⟦Nρ due to the extensionality of the applicative structure.

This concludes the proof.     □

Recall that by [M] we denote the equivalence class of term M with respect to the equivalence relation generated by the equational theory , .

In order to prove the completeness, we first prove the following property.

Lemma 4.2. Letbe an extensional applicative structure with combinators, such thatD = {[M]∣MCL}, App([M], [N]) = [MN], s = [S], k = [K] andi = [I]. If an environment ρis defined by ρ(x) = [x], then.

Proof. The proof is by induction on the structure of M.

  • If the term M is a variable x, then by Definition 3.6 we have .

  • If the term M is a term constant, for example S, then by Definition 3.6 we have . Similarly, for term constants K and I.

  • If the term M is an application NL, then by the induction hypothesis the statement holds for terms N and L, and . Further, by Definition 3.6 we obtain .

     □

Theorem 4.3 (Completeness of ). IfMρ = ⟦Nρholds in every model, thenM =ηN.

Proof. Suppose that ⟦Mρ = ⟦Nρ holds for any model . We define a model where is an applicative structure 〈D, {Aσ}, App〉 with the following components:

  • the domain D is defined by D = {[M] ∣ MCL};

  • for every σ ∈ Types, Aσ = {[M] ∣ MCL and ⊢ M : σ};

  • App is a function defined by App([M], [N]) = [MN].

The environment ρ is defined by ρ(x) = [x].

First we prove that the structure is an applicative structure, meaning that it satisfies conditions of Definition 3.1. The set D is a non-empty set. For every σ ∈ Types, the set Aσ = {[M] ∣ MCL and ⊢ M : σ} is a subset of the set D = {[M] ∣ MCL}. Since for every term M it holds that ⊢ M : ω, we have that Aω = {[M] ∣ MCL and ⊢ M : ω} = {[M] ∣ MCL} = D. Next, we look at the sets Aσ and Aτ. By the definition of the applicative structure we have Aσ = {[M] ∣ MCL and ⊢ M : σ} and Aτ = {[M] ∣ MCL and ⊢ M : τ}. If [M] ∈ AσAτ, then ⊢ M : σ and ⊢ M : τ. By rule (∩ intro) of Figure 2 we obtain ⊢ M : σ ∩ τ, which is equivalent to [M] ∈ Aσ∩τ, and we conclude AσAτAσ∩τ. Similarly, we prove that Aσ∩τAσAτ and we conclude Aσ∩τ = AσAτ. Let σ, τ ∈ Types such that σ ≤ τ. If [M] ∈ Aσ, then ⊢ M : σ holds, and since σ ≤ τ we obtain ⊢ M : τ by rule (sub-type). It follows that [M] ∈ Aτ and we can conclude that σ ≤ τ implies AσAτ. The function App defined by App([M], [N]) = [MN] maps D × D to D. If [M] ∈ Aσ → τ and [N] ∈ Aσ, then by the definition of the applicative structure we have ⊢ M : σ → τ and ⊢ N : σ. By rule (→ elim) of Figure 2 we obtain ⊢ MN : τ, thus we conclude [MN] ∈ Aτ and App ↾ (Aσ → τ × Aσ):Aσ → τ × AσAτ.

Next, we prove that the applicative structure has combinators. We consider the equivalence classes [S], [K], [I] ∈ D and denote them by s, k, i, respectively. Since ⊢ S:(σ → (τ → ρ)) → ((σ → τ) → (σ → ρ)) holds by (axiom S) of Figure 2, we have that s = [S] ∈ A(σ → (τ → ρ)) → ((σ → τ) → (σ → ρ)) for any σ, τ, ρ ∈ Types. Similarly, we obtain k = [K] ∈ Aσ → (τ → σ) and i = [I] ∈ Aσ → σ. We also have to prove that the elements s, k, and i satisfy the Equations (1)–(3). By the rules of the equational theory we obtain [SMNL] = [(ML)(NL)], [KMN] = [M] and [IM] = [M] and it follows that:

The extensionality of the applicative structure follows from the extensionality of combinatory logic. Let [M], [N] ∈ D such that for every [L] ∈ D, App([M], [L]) = App([N], [L]), i.e., [ML] = [NL]. Then, for a variable x, that does not appear in terms M and N, it holds that [Mx] = [Nx], that is Mx = Nx is provable in . By rule (ext) we obtain M = N is provable in , so [M] = [N].

We have proved that is a model for CL. If ⟦Mρ = ⟦Nρ in any model, then it also holds in the model . Hence, we have that . From Lemma 4.2 we get and . Now we can conclude that [M] = [N] holds, that is M =ηN.     □

Theorems 4.1 and 4.3 prove that the equational theory of untyped combinatory logic is both sound and complete with respect to the proposed semantics, hence the proposed semantics is a semantics of the untyped combinatory logic.

4.2. Soundness and Completeness of Type-Assignment System CL

In the sequel we consider another fundamental question: if M : σ is (syntactically) derivable in the type system CL, ⊢ M : σ, is it valid in all models, ⊧ M : σ?—this is referred to as the soundness of the type-assignment system with respect to the model. More general, if Γ ⊢ M : σ is (syntactically) derivable in the type system CL, is it semantically derivable, Γ ⊧ M : σ? The other direction: if M : σ is valid in all models of CL, is it derivable in CL?—is referred to as the completeness. More general, does semantical derivability Γ ⊧ M : σ imply syntactical derivability Γ ⊢ M : σ?

We prove herein the type-assignment system CL to be sound and complete with respect to the proposed semantics.

Theorem 4.4 (Soundness of CL). If Γ ⊢ M : σ, then Γ ⊧ M : σ.

Proof. We prove the statement by induction on the derivation of Γ ⊢ M : σ, considering the last rule used.

  • Let be the last rule used. Assume that is a model, such that . By Definition 3.10, the latter implies that for every y : τ ∈ Γ, . From the premise we have x : σ ∈ Γ, thus .

  • If Γ ⊢ M : σ falls under (axiom S), then we have Γ ⊢ S:(σ1 → (ρ1 → τ1)) → ((σ1 → ρ1) → (σ1 → τ1)) for some σ1, τ1, ρ1Types. Let be an arbitrary model for CL. By Definition 3.6 we have that . Thus, and we can conclude Γ ⊧ S:(σ1 → (ρ1 → τ1)) → ((σ1 → ρ1) → (σ1 → τ1)).

  • If Γ ⊢ M : σ falls under (axiom K), then we have Γ ⊢ K : σ1 → (τ1 → σ1) for some σ1, τ1Types. Let be an arbitrary model for CL. We have that . Thus, holds and we can conclude Γ ⊧ K : σ1 → (τ1 → σ1).

  • If Γ ⊢ M : σ falls under (axiom I), then we have Γ ⊢ I : σ1 → σ1 for some σ1Types. For an arbitrary model it holds that . Hence, and Γ ⊧ I : σ1 → σ1.

  • If Γ ⊢ M : σ falls under (axiom ω), then we have Γ ⊢ M : ω. Let be an arbitrary model for CL. We have that ⟦MρD and Aω = D. From this we obtain , that is .

  • Let be the last rule used and a model which satisfies Γ. By the induction hypothesis, we have that the statement holds for premises Γ ⊢ M : σ → τ and Γ ⊢ N : σ, i.e., Γ ⊧ M : σ → τ and Γ ⊧ N : σ. From the induction hypothesis and the assumption , we obtain and . The former implies and the latter implies . Thus, it holds that , and we obtain .

  • Let be the last rule used and a model of Γ. By the induction hypothesis we have , which implies that holds. Since Aσ∩τ = AσAτ by Definition 3.1, we have . Thus, we conclude .

  • If the last rule used is the proof proceeds similarly as in the previous case.

  • Let be the last rule used and a model of Γ. By the induction hypothesis we obtain and . The former implies that holds, and the latter implies that holds. Since AσAτ = Aσ∩τ by Definition 3.1, we have . Finally, we conclude .

  • Let be the last rule used and a model which satisfies the basis Γ. By the induction hypothesis we obtain that the statement holds for the premise, i.e., Γ ⊧ M : σ and since we have that . The latter implies . By Definition 3.1 we know that σ ≤ τ implies AσAτ. Hence, it holds that , and we can conclude .

  • Let be the last rule used and a model of Γ. By the induction hypothesis we have , which implies that holds. From M =ηN, that is M = N is provable in , and Theorem 4.1 we obtain ⟦Mρ = ⟦Nρ. Thus, we can conclude , that is .

    This concludes the proof.

     □

Remark 4.5. As pointed out in Section 3, we have defined an environment as a total mapping, whereas in Kašterović and Ghilezan (2020) an environment was defined as a partial mapping. Every combinatory term is typable with the type ω, i.e., Γ ⊢ M : ω for any basis Γ, and in order to obtain the soundness of the type-assignment system we need to prove that M : ω holds in every model. Thus, we had to define environments so that the meaning of every term M is defined in all models. This is specific to intersection type systems and is due to the rule (axiom ω) which ensures typability of all terms.

We define a class of canonical models, following the approach used in Kašterović and Ghilezan (2020), in order to prove the completeness of the type-assignment system CL with respect to the models presented in Section 3. Each canonical model is defined with respect to some basis, so that it satisfies only statements that can be derived from that basis. More precisely, we will define a model such that

Definition 4.6. Let Γ be a basis. A canonical model is a pair , where

such that

  • D = {[M] ∣ MCL},

  • Aσ = {[M] ∣ MCL and Γ ⊢ M : σ},

  • App([M], [N]) = [MN],

and ρ(x) = [x].

Lemma 4.7. The canonical modelis a model forCL.

Proof. We need to prove that the tuple introduced in Definition 4.6 satisfies the conditions of Definition 3.5. First, we prove that is an applicative structure. The set D is a non-empty set. The set Aσ = {[M] ∣ MCL and Γ ⊢ M : σ} is a subset of D = {[M] ∣ MCL}. For every CL-term M we have Γ ⊢ M : ω, thus Aω = {[M] ∣ MCL and Γ ⊢ M : ω} = {[M] ∣ MCL} = D. The proofs that the family {Aσ} and the application function App satisfy the conditions of Definition 3.1 are obtained similarly as in the proof of Theorem 4.3.

We have proved that the tuple is an applicative structure. Next, we prove that it has combinators and that it is extensional. Similarly as in the proof of Theorem 4.3 we denote equivalence classes [S], [K], [I] by s, k, i, respectively. From the type-assignment system (Figure 2) we know that for the basis Γ, Γ ⊢ S:(σ → (τ → ρ)) → ((σ → τ) → (σ → ρ)). From the latter it follows that s = [S] ∈ A(σ → (τ → ρ)) → ((σ → τ) → (σ → ρ)). Similarly, we obtain k = [K] ∈ Aσ → (τ → σ) and i = [I] ∈ Aσ → σ. The proof that elements [S], [K], [I] satisfy Equations (1)–(3) is given in the proof of Theorem 4.3.

We have proved that the applicative structure introduced in Definition 4.6 has combinators. The proof that the applicative structure is extensional is the same as in the proof of Theorem 4.3.

The mapping ρ defined by ρ(x) = [x] is an environment for the applicative structure .

This completes the proof that is a model for CL.     □

Lemma 4.8. Letbe the canonical model. For everyCL-termM, it holds.

Proof. This is a straightforward consequence of Lemma 4.2.     □

Theorem 4.9. Letbe a canonical model. It holds that

Proof. By Definition 4.6 and Lemma 4.8 we obtain

     □

Theorem 4.10 (Completeness of CL). If Γ ⊧ M : σ, then Γ ⊢ M : σ.

Proof. Suppose that Γ ⊧ M : σ. Let be a canonical model (Definition 4.6). First, we need to prove that . Let x : σ be a declaration from the basis Γ. By Lemma 4.8 and Definition 4.6 we have

It follows that . From the latter and the assumption Γ ⊧ M : σ we obtain . By Theorem 4.9 we obtain Γ ⊢ M : σ.     □

Theorems 4.4 and 4.10 prove that the type-assignment system CL is both sound and complete with respect to the proposed semantics. Hence the proposed semantics is a semantics of the combinatory logic with intersection types and of the untyped combinatory logic, as proven in Section 4.1.

5. Discussion and Conclusion

Combinatory logic, both typed and untyped, found its application in different scientific fields of computer science, e.g., machine learning (Liang et al., 2010) and artificial intelligence (e.g., Garrette et al., 2015), cognitive representation (e.g., Pierre Desclés, 2004), program synthesis (e.g., Düdder et al., 2012). The development of these fields urge for the further development of combinatory logic, typed, and untyped. Combinatory logic with intersection types has been the object of several studies (Dezani-Ciancaglini and Hindley, 1992; Bunder, 2002; Rehof and Urzyczyn, 2011; Bimbó, 2012). In Dezani-Ciancaglini and Hindley (1992), two different formulations of intersection types for combinatory logic are proposed and we consider in the paper one of these formulations. The authors proved that type-assignment statements are preserved by combinatory β-equality. A logic of intersection types is considered in Venneri (1994), by studying a logical characterization for the intersection-type discipline. The author presents a new formulation of the intersection type inference, equivalent to the original one, and then define a Hilbert-style axiomatization such that a formula is provable in the logical system if and only if it is an inhabited intersection type. Bunder (2002) also studies a logic of intersection types for lambda-terms and combinators by introducing a new system for intersection types, weaker than the one of Venneri (1994), and with the advantage that the logic of types can be obtained directly from the rules of the type-assignment system. None of these papers consider semantics for combinatory logic with intersection types. Models for combinatory logic with intersection types are presented in Bimbó (2012) along with the proof that the type-assignment system is sound and complete with respect to the presented models. Kripke-style semantics for lambda calculus and combinatory logic with types are introduced in Mitchell and Moggi (1991) and Kašterović and Ghilezan (2020). In Mitchell and Moggi (1991), calculi with simple types are considered, whereas in Kašterović and Ghilezan (2020) the authors considered full simply typed calculi. However, to the best of our knowledge the semantics we propose is novel.

We have introduced a semantics for combinatory logic with intersection types. As the main results of the paper we have proved that both the extensional equational theory of the untyped CL and the intersection type-assignment system CL are sound and complete with respect to the proposed semantics.

The usual approach to the semantics for calculi with types that can be found in the literature, e.g., filter models for lambda calculus with intersection types (Barendregt et al., 1983), is based on a model for the untyped calculus endowed with a valuation of type variables which enables the interpretation of types to be defined inductively. We propose a different approach. In the semantics we propose, the interpretation of types is represented as a family of subsets that satisfies certain properties. Moreover, for a given valuation of term variables, the interpretation of terms is defined inductively, whereas in the previously mentioned semantics the interpretation of terms is defined as a function that satisfies specified conditions.

We plan to further develop this approach to lambda calculus, to different frameworks in logic and computation, e.g., polymorphic types.

Funding

This research reported in the paper is partly supported by the Science Fund Republic of Serbia #6526707 AI4TrustBC.

Publisher's Note

All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.

Statements

Data availability statement

The original contributions presented in the study are included in the article/supplementary materials, further inquiries can be directed to the corresponding author/s.

Author contributions

Both authors listed have made a substantial, direct, and intellectual contribution to the work and approved it for publication.

Acknowledgments

The authors would like to thank the referees whose suggestions lead to major improvements.

Conflict of interest

The authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

References

  • 1

    BarbaneraF.Dezani-CiancagliniM.de'LiguoroU. (1995). Intersection and union types: syntax and semantics. Inf. Comput. 119, 202230. 10.1006/inco.1995.1086

  • 2

    BarendregtH. P. (1985). The Lambda Calculus - Its Syntax and Semantics, Volume 103 of Studies in Logic and the Foundations of Mathematics. Elsevier: North-Holland.

  • 3

    BarendregtH. P.CoppoM.Dezani-CiancagliniM. (1983). A filter lambda model and the completeness of type assignment. J. Symb. Logic. 48, 931940. 10.2307/2273659

  • 4

    BarendregtH. P.DekkersW.StatmanR. (2013). Lambda Calculus With Types. Perspectives in Logic.Cambridge: University Press. 10.1017/CBO9781139032636

  • 5

    BimbóK. (2012). Combinatory Logic: Pure, Applied, and Typed. Boca Raton, FL: CRC Press; Taylor & Francis Group. 10.1201/b11046

  • 6

    BunderM. W. (2002). Intersection types for lambda-terms and combinators and their logics. Log. J. IGPL10, 357378. 10.1093/jigpal/10.4.357

  • 7

    ChurchA. (1936). An unsolvable problem of elementary number theory. Am. J. Math. 58, 345363. 10.2307/2371045

  • 8

    CoppoM.Dezani-CiancagliniM. (1978). A new type assignment for λ-terms. Arch. Math. Log. 19, 139156. 10.1007/BF02011875

  • 9

    CoppoM.Dezani-CiancagliniM.VenneriB. (1980). Principal type schemes and lambda-calculus semantics, in H.B.Curry: Essays on Combinatory Logic, Lambda-Calculus and Formalism (San Diego, CA: Academic Press), 535560.

  • 10

    CurryH. B. (1930). Grundlagen der kombinatorischen logik. Am. J. Math. 52, 509536. 10.2307/2370619

  • 11

    de CarvalhoD. (2018). Execution time of λ-terms via denotational semantics and intersection types. Math. Struct. Comput. Sci. 28, 11691203. 10.1017/S0960129516000396

  • 12

    de'LiguoroU.TregliaR. (2019). Intersection types for the computational lambda-calculus, in Proceedings of the 20th Italian Conference on Theoretical Computer Science, ICTCS 2019, eds CherubiniA.SabadiniN.TiniS. (Como), 184189.

  • 13

    Dezani-CiancagliniM.HindleyJ. R. (1992). Intersection types for combinatory logic. Theor. Comput. Sci. 100, 303324. 10.1016/0304-3975(92)90306-Z

  • 14

    Dezani-CiancagliniM.MargariaI. (1984). F-semantics for intersection type discipline, in Semantics of Data Types, International Symposium Sophia-Antipolis, Vol. 173 of Lecture Notes in Computer Science, eds KahnG.MacQueenD. B.PlotkinG. D. (Berlin; Heidelberg: Springer), 279300. 10.1007/3-540-13346-1_14

  • 15

    DüdderB.MartensM.RehofJ.UrzyczynP. (2012). Bounded combinatory logic, in Computer Science Logic (CSL'12) - 26th International Workshop/21st Annual Conference of the EACSL, CSL 2012, Vol. 16 of LIPIcs, eds CégielskiP.DurandA. (Fontainebleau: Schloss Dagstuhl - Leibniz-Zentrum für Informatik), 243258.

  • 16

    GarretteD.DyerC.BaldridgeJ.SmithN. A. (2015). Weakly-supervised grammar-informed Bayesian CCG parser learning, in Proceedings of the Twenty-Ninth AAAI Conference on Artificial Intelligence, eds BonetB.KoenigS. (Austin, TX: AAAI Press), 22462252.

  • 17

    HindleyJ. R.SeldinJ. P. (1986). Introduction to Combinators and Lambda-Calculus. Cambridge: Cambridge University Press.

  • 18

    KašterovićS.GhilezanS. (2020). Kripke-style semantics and completeness for full simply typed lambda calculus. J. Log. Comput. 30, 15671608. 10.1093/logcom/exaa055

  • 19

    LiangP.JordanM. I.KleinD. (2010). Learning programs: a hierarchical Bayesian approach, in Proceedings of the 27th International Conference on Machine Learning (ICML-10), eds FürnkranzJ.JoachimsT. (Haifa: Omnipress), 639646.

  • 20

    MitchellJ. C.MoggiE. (1991). Kripke-style models for typed lambda calculus. Ann Pure Appl. Logic51, 99124. 10.1016/0168-0072(91)90067-V

  • 21

    OngC. L.TsukadaT. (2012). Two-level game semantics, intersection types, and recursion schemes, in Automata, Languages, and Programming - 39th International Colloquium, ICALP 2012, Vol. 7392 of Lecture Notes in Computer Science, eds CzumajA.MehlhornK.PittsA. M.WattenhoferR. (Warwick: Springer), 325336. 10.1007/978-3-642-31585-5_31

  • 22

    Pierre DesclésJ. (2004). Combinatory logic, language, and cognitive representations, in Alternative Logics. Do Sciences Need Them?, ed WeingartnerP. (Berlin: Springer Verlag), 115148. 10.1007/978-3-662-05679-0_9

  • 23

    PottingerG. (1980). A type assignment for the strongly normalizable λ-terms, in To H. B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, eds SeldinJ. P.HindleyJ. R. (London: Academic Press), 561577.

  • 24

    RehofJ.UrzyczynP. (2011). Finite combinatory logic with intersection types, in Typed Lambda Calculi and Applications - 10th International Conference, TLCA 2011, Volume 6690 of Lecture Notes in Computer Science, ed OngC. L. (Novi Sad: Springer), 169183. 10.1007/978-3-642-21691-6_15

  • 25

    SalléP. (1978). Une extension de la théorie des types en lambda-calcul, in 5th International Conference on Automata, Languages and Programming, ICALP'78, Vol. 62 of Lecture Notes in Computer Science, eds AusielloG.BöhmC. (Udine: Springer), 398410. 10.1007/3-540-08860-1_30

  • 26

    SchönfinkelM. (1924). Über die bausteine der mathematischen logik. Math. Ann. 92, 305316. 10.1007/BF01448013

  • 27

    van BakelS.BarbaneraF.de'LiguoroU. (2018). Intersection types for the lambda-mu calculus. arXiv:1704.00272. 10.48550/arXiv.1704.00272

  • 28

    VenneriB. (1994). Intersection types as logical formulae. J. Log. Comput. 4, 109124. 10.1093/logcom/4.2.109

  • 29

    WolframS. (2021). Combinators: a centennial view. CoRR, abs/2103.12811.

Summary

Keywords

computational systems, combinatory logic, equational theory, type theory, intersection types, soundness, completeness, semantics

Citation

Ghilezan S and Kašterović S (2022) Semantics for Combinatory Logic With Intersection Types. Front. Comput. Sci. 4:792570. doi: 10.3389/fcomp.2022.792570

Received

10 October 2021

Accepted

17 June 2022

Published

12 July 2022

Volume

4 - 2022

Edited by

Jonni Virtema, The University of Sheffield, United Kingdom

Reviewed by

Marcos Cramer, Technical University Dresden, Germany; Harsh Beohar, The University of Sheffield, United Kingdom

Updates

Copyright

*Correspondence: Silvia Ghilezan

This article was submitted to Theoretical Computer Science, a section of the journal Frontiers in Computer Science

Disclaimer

All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article or claim that may be made by its manufacturer is not guaranteed or endorsed by the publisher.

Outline

Figures

Cite article

Copy to clipboard


Export citation file


Share article

Article metrics