A Sound Definitional Interpreter for a Simply Typed Functional Language
Abstract
:1. Introduction
- (i)
- If an arbitrarily given term is well-typed, then it either reduces in a single step into some other term or it is already a value. That is, well-typed terms are never stuck;
- (ii)
- the type of a given term does not vary under reduction/evaluation.
1.1. Related Work and Contributions
- The presented interpreter is implemented to be computational; not living in Coq’s Prop. Amin et al. [17] definitionally implemented a similar interpreter; however, the attached soundness proof was not handled by progress and preservation. Moreover, the approach conducted in Software Foundations [18] and Koprowski’s paper [19] makes use of non-definitional interpreters, living in Coq’s Prop, it, however, obtains soundness proof via progress and preservation. In essence, we combine these approaches.
- We aimed to have complete literature on the Coq formalization surrounding the definitional interpreters for simply typed languages, alongside [20,21]. We discuss the technical machinery that closes the soundness proof of the interpreter. Even though the main message of the paper is well-known, to the author’s best knowledge, there is no Coq formalization that implements both type-checking and reduction (for some extension of ) in a definitional fashion (outside Coq’s Prop), formally relating to one another.
- Our extension involves a ’fixpoint’, branching constructors, and a few binary operations over natural numbers and Booleans.
1.2. Organization of the Paper
2. A Quick Recap of the Calculus
t | := | x | term variable/identifier |
∣ | function abstraction | ||
∣ | function application |
2.1. Evaluation Strategies
⇒ | ||
⇒ |
2.2. Extensions
⇒ | true | |
⇒ | true | |
⇒ | true | |
⇒ | false |
⇒ | ||
⇒ | ||
⇒ | ||
⇒ | ||
⇒ | ||
⇒ | ||
⇒ | ||
⇒ | ||
⇒ | ||
⇒ |
2.3. A Type System with a Coq Implementation
2.4. A Definitional Interpreter in Coq
- Substitution would be applicable not only when but also when to avoid the bound variable y being captured by any free variable present in the substituted term n.
- If the bound variable y is somehow captured by either of the cases and , one possibility to avoid the capture is to introduce a fresh variable and replace it with the bound variable y. Another choice may be to completely discard the naming bound variables by employing de Bruijn indices [26] in the Lambda binder, or alternatively pick a locally nameless strategy [27], or maybe embark on (parametric) higher-order abstract syntax [28]. Opting one of these methods, and adjusting the implementation accordingly is set as a future goal.
3. Type Soundness
- 1.
- for some arbitrary type .
- (a)
- for some arbitrary type . In this case, both and are individually well-typed under the empty context. By employing this fact, the rule () and the hypothesis (H), it is easy to deduce that . Under the same set of assumptions, we could show holds just by plugging in the type (or equivalently ) for . The hypothesis (H) would not hold otherwise.
- (b)
- . Given that the application is well-typed, under the empty context, the term must be well-typed as well. This case is a violation thus the goal is closed by contradiction.
- 2.
- . Similar to the item above, if the application is well-typed, the term must also be well-typed under the empty context context. This case is a violation, thus, the goal is closed by contradiction as well.
- 1
- for some arbitrary type .
- (a)
- for some arbitrary type .
- i.
- for some arbitrary type . In this case, the terms , , and are all individually well-typed under the empty context. With this, the hypothesis (H), and the rule (), we could simply deduce the facts that must be , and both and must be . Any other choice of s would contradict the hypothesis (H).
- ii.
- . If the term is well-typed, under the empty context, the term must also be well-typed. This case is a violation, thus, the goal is closed by contradiction.
- (b)
- . The goal in this case similarly holds by contradiction.
- 2.
- . The goal in this case is closed by contradiction in a similar manner with that of the above item.
- for some arbitrary type . Thanks to the hypothesis (H) and the rule (), we could easily reason that must be ; the hypothesis (H) would not hold otherwise.
- . If the term is well-typed, under the empty context, the term t must also be well-typed. This case is a violation, thus, the goal is closed by contradiction.
- 1.
- for some arbitrary type .
- (a)
- for some arbitrary type . In this case, the terms and are individually well-typed under the empty context. With this, the hypothesis (H), and the rule (), it is easy to deduce the fact that the types , and must be . Any other choice of s and would be in contradiction with the hypothesis (H).
- (b)
- . If the term is well-typed, under the empty context, the term must also be well-typed. This case is a violation, thus, the goal is closed by contradiction.
- 2.
- . The goal in this case is closed by contradiction in a similar manner with that of the above item.
- 1.
- The case with the application (), for some terms and , is more involved. There, we aim to prove that isvalue given () for some type , along with two induction hypotheses isvalue () for some type , and isvalue () for some type . Notice that isvalue ; therefore, we consider showing the right disjunction here. It is easy to demonstrate that the Boolean function isvalue is decidable. That is, . We start off with a case analysis, specializing this fact on the term , and throw two individual subgoals to close the assuming and , independently:
- (a)
- . We proceed with a case analysis specializing the decidability of the isvalue function, this time with the term and obtain two more subgoals to prove, given and separately:
- i.
- . On a case analysis over the term , we in fact have to prove the below three cases in which is a value (other cases, such as being , are trivial just because s are not values that yield in contradictory cases):
- , for some type . Mind that the goal here turns out to be . There obviously exists some ; that is the substitution , closing the goal thanks to the rule () in Figure 2.
- . In this case, the hypothesis () takes the following shape: , which is indeed false and yields in a contradiction as the first term in an application needs to be of some arrow-type but it is of type here.
- . This case is proven in a similar fashion to that of the above item.
- ii.
- . Thanks to Lemma 1, we have , for some type out of . We use this fact to specialize the induction hypothesis () to turn it into . We destruct this, and are supposed to prove the below statements, assuming and individually:
- A.
- . This case holds by contradiction.
- B.
- . On a case analysis over the term , we in fact have to prove the below three cases in which is a value (other cases, such as being , are trivial just because s are not values that yield in contradictory cases):
- , for some type . The goal we aim to show in this case is . Such a obviously exists as due to the rule () in Figure 2.
- . In this case, the hypothesis () takes the following shape: , which is a contradiction, because in an application, the first term needs to be of some arrow-type, but it is here.
- . This case is proven in a similar manner to that of the above item.
- (b)
- . Thanks to Lemma 1, we have , for some type out of . We use this fact to specialize the induction hypothesis () to turn it into the shape . We destruct this, and are supposed to prove the below statements, assuming and separately:
- i.
- . The statement in this case trivially holds by contradiction.
- ii.
- . In a case analysis over the term , we in fact have to prove subgoals in which is not a value (other cases such as being are trivial just because s are values that yield in proofs by contradiction):
- Recall that we are trying to show such that is not a value. We close all such cases uniformly: there definitely exists a being () given , due to the rule () in Figure 2.
- 2.
- Looking into the case with , we need to show isvalue given () for some type , along with three induction hypotheses isvalue () for some type , isvalue () for some type , and isvalue () for some type . Notice that the sole case we are supposed to demonstrate is as isvalue . Plugging the hypothesis () into Lemma 2, we deduce the facts that (), (), and (). We then specialize the induction hypothesis () with (), and obtain isvalue . Destructing this hypothesis, we are supposed to prove the goal twice, assuming isvalue and individually:
- (a)
- isvalue. On a case analysis over the term , we in fact have to prove the below three cases in which is a value (other cases such as being are trivial just because s are not values that yield in contradictory cases):
- , for some type . It is possible to show that holds just by contradiction as the hypothesis (), namely proves False. The Lambda terms are of the arrow-type.
- . In this case, it is similarly possible to prove False within the set of hypotheses: considering the hypothesis (), namely , we deduce False as it in fact is .
- . If the Boolean variable b is true, then the statement could easily be proven by plugging the term in place of due to the rule (). If b is the Boolean false, then is chosen to be to close the goal due to the rule () in Figure 2.
- (b)
- . The term is obviously not a value as it reduces at least one step. Therefore, it cannot be , , and . We prove the statement uniformly for the other choices of as follows: just plug in the term for the term within the goal, and obtain , which trivially holds thanks to the rule () presented in Figure 2.
- 3.
- For the case with , we need to prove that isvalue given () for some type , along with the induction hypothesis isvaluef = true (). Lemma 3 gives proof of the fact that , for some type out of (). We specialize in the induction hypothesis () with this fact and handle isvalue . By destructing this, we are supposed to prove the goal (as isvalue ) twice for both isvalue and .
- (a)
- isvalue. On a case analysis over the term f, we in fact have to prove the below three cases in which f is a value (other cases, such as f being are trivial just because fs are not values that yield in contradictory cases):
- , for some type . It suffices to plug the term into the formula , and then apply the rule () in Figure 2 to have this case proven.
- . In this case, it is possible to prove False within the current context: considering (), namely is simply false as it is an ill-typed term according to the rules in Figure 4. See the rule () that states that terms of the form are well-typed only when f is of some arrow-type with the same domain and co-domain. This does not match with the fact that .
- . This case holds due to the same reason as that of given above.
- (b)
- . Given the rule () in Figure 2, one can reason that holds simply by plugging the term in, for except for the cases where f is a value. These cases are contradictory as there is no into which f evaluates.
- 4.
- Considering the case involving , we need to show isvalue given () for some type , along with two induction hypotheses isvalue () for some type , and isvalue () for some type . Notice that we are supposed to prove only as isvalue . Employing Lemma 4, we deduce the facts that (), and that () out of the hypothesis (). Specializing the induction hypotheses () with () and () with (), we obtain isvalue and isvalue . We carry on with a case analysis on the decidability of the isvalue function parameterized by the term . We, therefore, need to prove the aforementioned goal twice for two distinct cases with and :
- (a)
- . Applying a case analysis on the term , we are supposed to prove the below three cases (others, such as being , are trivial just because s are not values that yield in contradictions):
- i.
- , for some type . Notice that in this case, the goal turns out to be . This holds by contradiction just because the type of is an arrow-type while it is expected to be by the hypothesis (). Please check out the rule () given in Figure 4 for a justification.
- ii.
- . In this case, we start off destructing the induction hypothesis (), and are in the need of proving the goal twice provided and individually:
- A.
- isvalue. We proceed with the case analysis of the term , we are supposed to prove the below three cases (others, such as being , are trivial just because s are not values that yield in contradictions):
- , for some type . Here, we need to show that holds. This is doable again by contradiction as the term is of an arrow-type, while it is expected to be by the hypothesis ().
- . In this case, we could simply show that holds by first plugging in the term for , and then employing the rule () presented in Figure 2.
- . The goal in this case holds also by contradiction: the type of is while it is expected to be by the rule ().
- B.
- . In this case, needs to be shown. In cases where is a value, we close the goal by contradiction, as allows for proving False: values do not evaluate any further. For the rest, we plug the term into the goal, for the term , and solve it with the rule () stated in Figure 2.
- iii.
- . It is possible to show that by contradiction as the type of is while it is here expected to be by the rule ().
- (b)
- . On a case analysis over the term , we in fact have to prove subgoals where is not a value (other cases such as being are trivial just because s are values that yield in contradictory cases):
- Recall that we are trying to show , such that is not a value. We close all such cases uniformly: there definitely exists a as given , thanks to the rule () presented in Figure 2.
- 5.
- The remaining cases with, for instance, , could be proven by employing a very similar idea presented in the above item 4.
- for some arbitrary string s. If , the hypothesis takes the following shape: which implies that . The goal simplifies into by Definition 2 of the substitution function. Employing the fact that (named context_invariance in the Coq code), we deduce out of the hypothesis , and the goal is closed. Else if then () turns into . The goal simplifies into again by Definition 2. This is in fact the hypothesis () itself.
- for some arbitrary string s, type , and term e. The goal we aim to prove is , provided an induction hypothesis (). If then we have amounts to by Definition 2. Therefore, the goal turns out to be . Using the fact that (context_invariance in the Coq code) over the contexts and with the hypothesis (namely, ), we manage to extend the list of assumptions with , and have the goal closed. If , we need to show that or better that thanks to Definition 2 and to the () rule in Figure 4. Remark that in this case, the hypothesis () first takes the shape then simplifies into again by the () rule. Specializing the induction hypothesis () with the context , simplified version of () and (), we close this goal.
- for some terms and . We try proving given () and () as induction hypotheses. We deduce (H) and (), for some type , by inversion over the hypothesis (), namely . Using (H) and () in (), and () and () in (), we, respectively, obtain and , which prove the goal thanks to Definition 4 of the substitution function and the rule () in Figure 4.
- for some terms , , and . The statement we intend to show in this case turns out to be given (), () and () as induction hypotheses. It is quite easy to infer (H), (), and () by inversion over the hypothesis (), namely . We then specialize () with (H) and (), () with () and (), and () with () and () to respectively obtain , and . These are adequate to prove the statement due to Definition 4 of the substitution function and the rule () in Figure 4.
- for some term . The goal of the case is of the following shape: . We additionally have a single induction hypothesis (). The hypothesis (), , entails by inversion that (H). We then specialize () with (H) and () to have . This is enough to close the goal thanks to Definition 4 of the substitution function and the rule () in Figure 4.
- for some terms and . The goal we aim to close in this case is along with two induction hypotheses (), (). We infer (H) and () inverting the hypothesis (). Lastly, we specialize () with (H) and (), () with () and () to handle , which prove the goal due to Definition 4 and the rule () in Figure 4.
- The cases with t, being either , , , or follow the same lines with the proof given in the above item 6. The cases where and are trivial just because the substitution function has no impact on these terms.
- 1.
- The case with the application (), for some arbitrary terms and , are more appealing and, thus, deserve a closer look. Here, we are supposed to show (for all types ) that holds; provided (H), (), and a pair of induction hypotheses () and (). Notice that by plugging in the hypothesis (H) into Lemma 1, we can deduce the facts that () and (), for some type . At this stage, we apply a case analysis on the term (below the goals) to close:
- (a)
- for some term e and type . We definitely obtain some after beta-reducing the term inhabited by the hypothesis (H) depending on the choice of whether is a value or not:
- i.
- . In this case, amounts to , due to the rule () presented in Figure 2, and we are expected to prove that . Thanks to Lemma 5, to obtain (proven), we need to close two goals, which are and :
- . Recall that we have due to (). We solve the goal just by inverting the rule () in Figure 4.
- . This one is exactly ().
- ii.
- . Thanks to Progress Theorem 1 and the hypothesis (), we have . As the left side of the disjunction is contradictory to the assumption of the case, we focus on the right side, which tells us that there exists some , such that . Therefore, amounts to due to the rule () presented in Figure 2. Namely, we are supposed to show that holds. By properly specializing the induction hypothesis (), we end up with . With this information in hand, just by employing the rule () in Figure 4, we ensure that the application is of type under the empty context.
- (b)
- for some arbitrary terms and . It is known by () that the application is of type under the empty context. Passing this well-typed information to Progress Theorem 1, we have . Due to the fact that , we are left with . Therefore, the goal that we aim to prove in this case takes the following shape: due to the rule () presented in Figure 2. Specializing the induction hypothesis () with the correct ingredients gives us . Making use of the hypothesis () and the rule () placed in Figure 4, we conclude that holds.
- (c)
- for some arbitrary terms , and . Similar to the proof in the above item, we know that the term is of type under the empty context. This, Progress Theorem 1 gives us . Just that is incorrect, we focus on . This heads us toward proving due to the rule () presented in Figure 2. Similar to that of the above item (b), we specialize in the induction hypothesis () with the correct ingredients, and have . We close this goal just by employing the hypothesis () and the rule () appearing in Figure 4.
- (d)
- for some arbitrary term . By chasing the exact same steps demonstrated in the above items (b) and (c), we end up retaining to show , which we solve again by putting the induction hypothesis () together with the rule () in operation.
- (e)
- for some arbitrary terms and . The goal in this case is proven by contradiction as due to the hypothesis (), the term needs to be of some arrow-type , but it is of type .
- (f)
- The other cases in which the term appears to be either , , , , or , and could be proven in a similar manner with that of the above item (e). The goal where amounts to is similarly proven with a single difference, where is of type , not . Lastly, the goal with holds by contradiction as the term is ill-typed under the empty context.
- 2.
- for some terms , and . In this case, we aim to prove for all types that holds; given that (H), () along with three induction hypotheses (), (), and (). Note also that we deduce the facts (), (), and () by specializing Lemma 2 with the hypothesis (H). The proof proceeds with a case analysis over the term , and requires the following cases to be proven:
- (a)
- The goals in which the term is , , , , , , , or are trivially shown by contradictions, as none of these terms are of type as expected by the hypothesis ().
- (b)
- for some arbitrary terms and . The hypothesis tells us that . This, with Progress Theorem 1, entails that . The left side of the disjunction is obviously incorrect. We, therefore, obtain . Accordingly, the goal we intend to prove in this case turns out to be due to the rule () presented in Figure 2. By specializing the induction hypothesis () with proper terms and types, we have . Thanks to the hypotheses (), (), and the rule () given in Figure 4, we show that .
- (c)
- for Boolean b. We carry on with a case distinction on b:
- (d)
- for some arbitrary terms , and . The hypothesis entails that . Progress Theorem 1 over this fact gives . Provided that , we focus on the right side of the disjunction; that is . In this parallel, the goal we want to close is thanks to the rule () presented in Figure 2. By specializing the induction hypothesis () with proper terms and types, we have . Thanks to the hypotheses (), (), and the rule () stated in Figure 4, we show that .
- (e)
- for some term f. Similar to case (d) above, the hypothesis () entails that . This, with Progress Theorem 1, we deduce . As it is obvious that , we are left with . The goal we want to close here is that due to the rule () presented in Figure 2. We now specialize the induction hypothesis () with proper terms and types, and obtain . Thanks to the hypotheses (), (), and the rule () appearing in Figure 4, we prove that .
- 3.
- For the case , we aim to prove for all types that holds; given that (H), () strengthened with the induction hypothesis (). Moreover, we have () when Lemma 3 is applied to the hypothesis (H). The proof proceeds with a case analysis over the term f, and requires the following cases to be proven:
- (a)
- The goals in which the term is any of , , , , , , and are trivially demonstrated by contradiction as none of these terms are of the arrow type as expected by the hypothesis ().
- (b)
- for some term e and type . Recall that the rule () stated in Figure 2, we have . Notice that, on a side note, the term needs to be of type due to the hypothesis (). By inversion here, we deduce that and (). Having said that, let us look into the statement that needs to be proven in this case: (due to the rule () presented in Figure 2). Thanks to Lemma 5, to prove the mentioned goal, we need to close two goals: and .
- . This is exactly the hypothesis ().
- . This one matches with the hypothesis (H).
- (c)
- for some arbitrary terms and . The hypothesis () entails that . Employing this fact within Progress Theorem 1, we deduce . The left side of the disjunction is obviously incorrect. We therefore obtain . Thus the goal turns out to be due to the rule () presented in Figure 2. By properly specializing the induction hypothesis (), we have . Now by the rule () given in Figure 4, we conclude that .
- (d)
- for some arbitrary terms , and . Similar to case (c) above, the hypothesis () entails that . Progress Theorem 1 specialized with this fact implies that . Provided that , we focus on the right side of the disjunction; that is . In this parallel, the goal we want to close here is due to the rule () presented in Figure 2. We now specialize the induction hypothesis (), and obtain . Now by the rule () stated in Figure 4, we conclude that .
- (e)
- for some arbitrary term e. By following the exact same steps presented in the above items (c) and (d), we end up having to show (due to the rule () presented in Figure 2) which we solve again by putting the induction hypothesis () together with the rule () in use.
- 4.
- Concerning the case with , for some arbitrarily chosen terms, and , we want to prove for all types that holds, provided that (H), () and two induction hypotheses (), (). In addition to these, we enrich the set of hypotheses with (), (), and () just by applying Lemma 4 over the hypothesis (H). The proof proceeds with a case distinction over the term , and throws us cases to prove:
- (a)
- The goals in which term is , , , , or and trivially proven by contradiction as none of these terms are of type as expected by the hypothesis ().
- (b)
- for some arbitrary terms and . We deduce out of the hypothesis () that . With this information, we could further infer that thanks to Progress Theorem 1. Given that , we take into account, and therefore the goal takes the following shape: , due to the rule () presented in Figure 2. We could put the induction hypothesis () into the following shape: employing the hypothesis (). Now, by using the rule (), and the hypothesis (), we conclude that holds.
- (c)
- for some Coq natural n. Thanks to the hypothesis (), we already know that . Applying Progress Theorem 1 to this fact, we obtain . Destructing this disjunction throws us the following two goals to prove, independently assuming and :
- . We proceed with a case distinction on the term . Note that the statements where is a value trivially hold, no further reductions from are possible, which contradicts the assumption of the case. We have the statement to be proven for the remaining cases, due to the rule () stated in Figure 2. To prove this statement, we specialize the induction hypothesis () with proper terms and types, and turn it into . This fact and the rule () presented in Figure 4 give us .
- (d)
- for some arbitrary terms , and . The hypothesis () can be used to infer . Using this within Progress Theorem 1, it is possible to infer . Recall that only the right side of this disjunction is useful as the other leads to a contradiction. Building on this, our goal here turns out to be due to the rule () given in Figure 2. We then specialize the induction hypothesis () properly and obtain . By the rule () and the hypothesis (), we have proven.
- (e)
- for some arbitrary term f. We follow the exact same steps presented in the above items (b) and (d): first infer then show by employing the rule (), and putting the induction hypothesis () in the intended shape.
- (f)
- for some arbitrary terms and . We follow the same step with that of the above item (e). That is, we first have out of Progress Theorem 1, and aim at proving (thanks to the rule () presented in Figure 2). The proof is constructed out of the rule () and correctly shaped induction hypothesis ().
- (g)
- The other cases in which the term appears to be or could be proven in a similar manner to described in the above item (f).
- 5.
- The remaining cases with, for instance, , could be proven, employing a very similar idea presented in the above item 4.
evaln t 0 | → | t |
evaln t (S n) | → | let evaln n |
- . Notice that the hypothesis () (with ) entails that . We employ Progress Theorem 1 specialized by the hypothesis (), and deduce . The goal, in this case, is trivially proven as the left side of the disjunction contradicts with (), while the right-hand side contradicts with ().
- . In this case, we additionally have the induction hypothesis (). We again make use of Progress Theorem 1 specialized by the hypothesis (), and obtain . We now destruct this fact, and are supposed to prove the goal, which is False here, twice assuming and independently:
- . It is obvious in this case that the term t does not reduce even a single step further. Namely, there is no , such that , which contradicts the hypothesis (), and closes the goal.
- . We know that there is some term e into which the term t reduces in a single beta-step. We also know by the hypothesis () that t reduces into some term in (or ) steps. Putting these together, we infer that the term e reduces into the in m steps, namely . Moreover, we specialize the Preservation Theorem 2 with the hypothesis () and the fact that to retain (). This time, making use of () and the fact that , we put the induction hypothesis () into the following shape: . Into this, we plug the conjunction of the hypotheses () and (), and obtain a proof of False, which literally implies everything.
4. Discussion
5. Conclusions
- Extending the interpreter to handle polymorphically typed Lambda calculus embarking on the same approach presented herenote1 is (a definitional interpreted for a polymorphically typed functional language coded in Haskell) another goal to achieve.
- The interpreter could be expanded and scaled to handle some other programming blocks, such as pairs, match-end constructs, let bindings, pairs, lists, and records.
Funding
Data Availability Statement
Conflicts of Interest
Appendix A. Organization of the Coq Sources
- Auxiliaries.v: includes some simple proofs of statements about contexts that are indeed defined as lists of pairs.
- Terms.v: involves declarations of terms and types along with decidable equality among terms and types, and reflection proofs of such equalities into Coq’s Prop.
- Typecheck.v: the file in which the function typecheck is implemented. It also contains proofs of some properties given in Lemmata 1–5. To exemplify how the typecheck function works, we implemented the factorial function as follows: One could run the typecheck function on the term under the empty context (nil) with the Compute vernacular, and monitor the output that is commented out in the below snippet: Of course, the below computation returns None as the term is ill-typed under the empty context:
- Eval.v: includes the single-step and multi-step beta-reduction functions, respectively, named beta and evaln. Observe that in exactly 40 steps, the factorial function computes the value of factorial 7 to be 5040: Unlikely, the below computation, returns None as the input term is stuck.
- Progress.v: contains the proof of Progress Theorem 1.
- Preservation.v: includes the proof of Preservation Theorem 2.
- Soundness.v: contains what it means for a term being stuck (Definition 6) alongside the proof of Soundness Theorem 3.
References
- Reynolds, J.C. Definitional Interpreters for Higher-Order Programming Languages. High. Order Symb. Comput. 1998, 11, 363–397. [Google Scholar] [CrossRef]
- Church, A. A Formulation of the Simple Theory of Types. J. Symb. Log. 1940, 5, 56–68. [Google Scholar] [CrossRef] [Green Version]
- The Coq Development Team. The Coq Proof Assistant Reference Manual; The Coq Development Team: Paris, France, 2018. [Google Scholar]
- Wright, A.K.; Felleisen, M. A Syntactic Approach to Type Soundness. Inf. Comput. 1994, 115, 38–94. [Google Scholar] [CrossRef] [Green Version]
- Poulsen, C.B.; Rouvoet, A.; Tolmach, A.; Krebbers, R.; Visser, E. Intrinsically-typed definitional interpreters for imperative languages. Proc. ACM Program. Lang. 2018, 2, 16:1–16:34. [Google Scholar] [CrossRef] [Green Version]
- Altenkirch, T.; Reus, B. Monadic Presentations of Lambda Terms Using Generalized Inductive Types. In Proceedings of the Computer Science Logic, 13th International Workshop, CSL ’99, 8th Annual Conference of the EACSL, Madrid, Spain, 20–25 September 1999; Flum, J., Rodríguez-Artalejo, M., Eds.; Springer: Berlin/Heidelberg, Germany, 1999; Volume 1683, Lecture Notes in Computer Science. pp. 453–468. [Google Scholar] [CrossRef]
- Reynolds, J.C. The Meaning of Types From Intrinsic to Extrinsic Semantics. BRICS Rep. Ser. 2000, 7, 1–35. [Google Scholar] [CrossRef] [Green Version]
- Augustsson, L.; Carlsson, M. An exercise in dependent types: A well-typed interpreter. In Workshop on Dependent Types in Programming, Gothenburg; 1999. Available online: https://www.semanticscholar.org/paper/An-exercise-in-dependent-types%3A-A-well-typed-Augustsson-Carlsson/5dae20b002f4e9d91e60db6af192c69d7fe764c6 (accessed on 4 September 2022).
- Rouvoet, A.; Poulsen, C.B.; Krebbers, R.; Visser, E. Intrinsically-typed definitional interpreters for linear, session-typed languages. In Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and Proofs, CPP 2020, New Orleans, LA, USA, 20–21 January 2020; Blanchette, J., Hritcu, C., Eds.; ACM: New York, NY, USA, 2020; pp. 284–298. [Google Scholar] [CrossRef] [Green Version]
- Darais, D.; Labich, N.; Nguyen, P.C.; Horn, D.V. Abstracting definitional interpreters (functional pearl). Proc. ACM Program. Lang. 2017, 1, 12:1–12:25. [Google Scholar] [CrossRef] [Green Version]
- Darais, D.; Might, M.; Horn, D.V. Galois transformers and modular abstract interpreters: Reusable metatheory for program analysis. In Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2015, part of SPLASH 2015, Pittsburgh, PA, USA, 25–30 October 2015; Aldrich, J., Eugster, P., Eds.; ACM: New York, NY, USA, 2015; pp. 552–571. [Google Scholar] [CrossRef] [Green Version]
- Sergey, I.; Devriese, D.; Might, M.; Midtgaard, J.; Darais, D.; Clarke, D.; Piessens, F. Monadic abstract interpreters. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’13, Seattle, WA, USA, 16–19 June 2013; Boehm, H., Flanagan, C., Eds.; ACM: New York, NY, USA, 2013; pp. 399–410. [Google Scholar] [CrossRef]
- Johnson, J.I.; Sergey, I.; Earl, C.; Might, M.; Horn, D.V. Pushdown flow analysis with abstract garbage collection. J. Funct. Program. 2014, 24, 218–283. [Google Scholar] [CrossRef] [Green Version]
- Glück, R. Simulation of Two-Way Pushdown Automata Revisited. In Proceedings of the Semantics, Abstract Interpretation, and Reasoning about Programs: Essays Dedicated to David A. Schmidt on the Occasion of his Sixtieth Birthday, EPTCS, Manhattan, KS, USA, 19–20 September 2013; Banerjee, A., Danvy, O., Doh, K., Hatcliff, J., Eds.; 2013; Volume 129, pp. 250–258. [Google Scholar] [CrossRef] [Green Version]
- Johnson, J.I.; Horn, D.V. Abstracting abstract control. In Proceedings of the DLS’14, Proceedings of the 10th ACM Symposium on Dynamic Languages, part of SLASH 2014, Portland, OR, USA, 20–24 October 2014; Black, A.P., Tratt, L., Eds.; ACM: New York, NY, USA, 2014; pp. 11–22. [Google Scholar] [CrossRef] [Green Version]
- Gilray, T.; Lyde, S.; Adams, M.D.; Might, M.; Horn, D.V. Pushdown control-flow analysis for free. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, St. Petersburg, FL, USA, 20–22 January 2016; Bodík, R., Majumdar, R., Eds.; ACM: New York, NY, USA, 2016; pp. 691–704. [Google Scholar] [CrossRef] [Green Version]
- Amin, N.; Rompf, T. Type soundness proofs with definitional interpreters. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, France, 18–20 January 2017; Castagna, G., Gordon, A.D., Eds.; ACM: New York, NY, USA, 2017; pp. 666–679. [Google Scholar] [CrossRef] [Green Version]
- Pierce, B.C.; de Amorim, A.A.; Casinghino, C.; Gaboardi, M.; Greenberg, M.; Hriţcu, C.; Sjöberg, V.; Tolmach, A.; Yorgey, B. Programming Language Foundations; Software Foundations Series; Electronic textbook, 2022; Volume 2, Version 5.5; Available online: http://www.cis.upenn.edu/~bcpierce/sf (accessed on 1 August 2019).
- Koprowski, A. A Formalization of the Simply Typed Lambda Calculus in Coq; INRIA: Le Chesnay-Rocquencourt, France, 2006. [Google Scholar]
- Wei, G. A Soundness Proof of STLC by Definitional Interpreters in Agda. 2019. Available online: https://continuation.passing.style/blog/stlc-soundness.html (accessed on 1 August 2018).
- van Der Bilt, P.; STLC in Coq Extended with a Sound Big-Step Semantics, Functions as Closures and Records as Lists. Coq-Lang-Playarea. 2015. Available online: https://github.com/pvanderbilt/coq-lang-playarea (accessed on 1 August 2019).
- Barendregt, H. Introduction to Generalized Type Systems. J. Funct. Program. 1991, 1, 125–154. [Google Scholar] [CrossRef] [Green Version]
- Girard, J. The System F of Variable Types, Fifteen Years Later. Theor. Comput. Sci. 1986, 45, 159–192. [Google Scholar] [CrossRef] [Green Version]
- Coquand, T.; Huet, G.P. The Calculus of Constructions. Inf. Comput. 1988, 76, 95–120. [Google Scholar] [CrossRef] [Green Version]
- Moggi, E. Notions of Computation and Monads. Inf. Comput. 1991, 93, 55–92. [Google Scholar] [CrossRef] [Green Version]
- Nicolaas Govert de Bruijn. Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indag. Math. Proc. 1972, 75, 381–392. [Google Scholar] [CrossRef]
- Charguéraud, A. The Locally Nameless Representation. J. Autom. Reason. 2012, 49, 363–408. [Google Scholar] [CrossRef]
- Chlipala, A. Parametric higher-order abstract syntax for mechanized semantics. In Proceedings of the 13th ACM SIGPLAN International Conference on Functional Programming, ICFP 2008, Victoria, BC, Canada, 20–28 September 2008; pp. 143–156. [Google Scholar] [CrossRef] [Green Version]
- Nigron, P.; Dagand, P. Reaching for the Star: Tale of a Monad in Coq. In Proceedings of the 12th International Conference on Interactive Theorem Proving, ITP 2021, Rome, Italy (Virtual Conference), 29 June–1 July 2021; Cohen, L., Kaliszyk, C., Eds.; Schloss Dagstuhl-Leibniz-Zentrum für Informatik: Wadern, Germany, 2021; Volume 193, LIPIcs. pp. 29:1–29:19. [Google Scholar] [CrossRef]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2022 by the author. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Ekici, B. A Sound Definitional Interpreter for a Simply Typed Functional Language. Axioms 2023, 12, 43. https://doi.org/10.3390/axioms12010043
Ekici B. A Sound Definitional Interpreter for a Simply Typed Functional Language. Axioms. 2023; 12(1):43. https://doi.org/10.3390/axioms12010043
Chicago/Turabian StyleEkici, Burak. 2023. "A Sound Definitional Interpreter for a Simply Typed Functional Language" Axioms 12, no. 1: 43. https://doi.org/10.3390/axioms12010043
APA StyleEkici, B. (2023). A Sound Definitional Interpreter for a Simply Typed Functional Language. Axioms, 12(1), 43. https://doi.org/10.3390/axioms12010043