Assignment 4
Assignment 4
I semester 2019-20
The language ΛF L (X) extends FL(X) to allow lambda-terms. All the well-typed terms in the language ΛF L (X)
have a β-normal form. In this assignment, you have to check if a term is well-typed as per the types given in
Typing FL Expressions. You can use the inference rules given in Typing axioms. If the term is well-typed,
convert it to its β-normal form.
Problem Statement
Your task is to generate a β-normal form for any given input in language ΛF L (X). For this assignment you
don’t have to consider the language with recursion i.e. ΛRecF L (X). You can use the code of Assignment-3 to
reduce terms of FL(X) to normal forms1 . We have attached a signature file with this document. Your task is
to create a module and implement the signature file named signatureLAMBDAFLX.sml.
5. The function fromString: string -> lterm should take a string as input and return the lterm created
after parsing. The function should raise exception Not wellformed if the input string is not well formed
in the language FL0.
6. Implement the function toString: lterm -> string which returns a string form of input lterm. The
format of the output string should match with the format given above.
7. Function fromInt: int -> lterm takes an integer and converts it to an SS . . . SZ or P P . . . P Z form
in the datatype lterm. For example fromInt ~2 should return (P (P Z)).
1 Since there is a clash of constructor names between the two data types term and lterm, disambiguation by prefixing each use
11. You are not supposed to handle the exception in your program. Our script depends on you raising
the exception from your code.
12. Do not write any code in the signature file signatureLAMBDAFLX.sml attached with the assignment.
Submission Instruction
Important Notes
1. Do not change any of the names given in the signature. You are not even allowed to change upper-case
letters to lower-case letters or vice-versa.
2. You may define any new functions you like besides those mentioned in the signature.
3. Follow the input output specification as given. We will be using automated scripts to execute the code
for evaluation. In case of mismatch, you will be awarded zero marks.