What do you need to do to adapt your definition of evalSubst to use call-by-name evaluation? You may either write code or prose explaining what your code would do. What are the pros and cons of the two styles of evaluator we’ve written? beta - (App (Abst var body) env) -> (Sub body var env) - eta - (Abst var (App body var')) -> body - alpha - (Sub (Var var) var env) -> env - (Sub (Var var') var env) -> (Var var') - (Sub (Abst var body) var env. Suppose TM is a lambda term that simulates a Turing Machine. You can use error :: String -> a to signal an error if you need to. This code is a representation of lambda calculus using an AST instead of text. Implement a call-by-value interpreter for the pure lambda calculus ( LCExpr) using substitution. You may assume that e is closed-there is no need to be capture-avoiding. Implement the substitution function for the pure lambda calculus ( LCExpr). Write down your thoughts, and then actually implement the function. Let’s start the discussion by writing a lambda calculus interpreter. In this post, I am going to explain how we can implement a call-by-value interpreter using various methods. If the expression has no normal form or it is not a valid. When implementing call-by-value lambda-calculus in Haskell, should I force the evaluation of the arguments to a function in the object language (i.e., the call-by-value lambda-calculus) to get around the call-by-need evaluation order of the meta-language (i.e. Think hard about this question before you do parts (b) and (c). This difference in evaluation model poses some challenges in writing a call-by-value interpreter in Haskell. Your mission, should you choose to accept it, is to write an interpreter which takes as its input an expression of the untyped lambda calculus containing no free variables and produces as its output the expression's normal form (or an expression alpha-congruent to it). What should the type of the substitution function be? How does using substitution change the type of our evaluation function? Do we need to add new datatypes, drop old ones, or leave everything the same? Why or why not? This leads to: > data Dinf NoBeta NoBeta > Fn. Let’s write an interpreter that uses substitution! Remember that a normal form is a lambda term with no beta redexes. The semantics for the lambda calculus we’ve used in class uses substitution, not environments.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |