Assignment 6

  +125

This assignment does not require programming. Instead:

  • Solve the four unification exercises in the Type inference notes (they’re at the bottom of the section on Type unification):

    1. \(\textbf{Unify}(\mathtt{real}\to t_4,\;\; t_5\to(\mathtt{string}\to\mathtt{int}))\)
    2. \(\textbf{Unify}(t_1\to(t_2\to\mathtt{real}),\;\; \mathtt{int}\to((t_3\;\mathtt{list})\to \mathtt{real}))\)
    3. \(\textbf{Unify}((\mathtt{int}\;\mathtt{list})\;\mathtt{list},\;\; t_6\;\mathtt{list})\)
    4. \(\textbf{Unify}(((t_7\;\mathtt{list})\times t_8)\times t_8, \;\; (t_9\times(t_{10}\;\mathtt{list}))\times t_9)\)
  • Then work through the algorithm to infer types for the four SML functions at the bottom of that page:

    1. fun borp ts = map explode ts
    2. fun crow xs =
        if null xs then 1
        else hd xs * crow (tl xs)
    3. fun down x = if x=0 then [] else x :: down (x-1)
    4. fun edgar n = crow (down n)

    (You’ll also need the types of the built-in functions and operators, provided at the very end of the notes page.)

You can do the work on paper and scan the pages to create a PDF file. Or you can do the work in a text file. Either way, save the file to the top level of your cs664s16 directory, then add, commit, and push. On the command line, that would be:

git add assn6.pdf
git commit -m "assignment6"
git push

Or you can open any cs664s16 project in IntelliJ and use the Version Control panel at the bottom. You should see your new text or PDF file appear under Unversioned files. Add, commit, push.