1 / 4

CS4026, first practical

CS4026, first practical. Answers to exercises. Answers to Items 1 and 3 can be found here: http://www.csd.abdn.ac.uk/~wvasconc/teaching/ CS4018/abdn.only/practical1_answ.pdf Answers to Items 2 and 4 can be found on the next few pages.

rhester
Download Presentation

CS4026, first practical

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS4026, first practical Answers to exercises

  2. Answers to Items 1 and 3 can be found here: http://www.csd.abdn.ac.uk/~wvasconc/teaching/ CS4018/abdn.only/practical1_answ.pdf • Answers to Items 2 and 4 can be found on the next few pages

  3. Item 2 (constructing a lamda expression for g) 1. You could write gx.2*((x*x)+3), but this has no separate function h. Since hx.(x*x)+3, g can be written as gx.(a.(a(x*x+3))(z.2*z)), or as gx.((z.2*z)(a.(a*a+3))(x)). To check your solution, apply your function to a number. For example: g(4) x.(a.(a(x*x+3))(z.2*z))(4)  (a.(a(4*4)+3))(z.2*z) (z.2*z)((4*4)+3)  2*19  38

  4. Item 2 (existence of normal forms) • (x.x)(x.x) Normal form (after 1 beta conversion step) is x.x • (x.xx)(x.x) Normal form (after two beta conversion steps) is x.x • (x.xx)(x.xx). No normal form. After beta conversion, you get (x.xx)(x.xx) once again, after which beta conversion applies again (etc.) • (x.xxx)(x.xxx). No normal form. After one beta conversion, you get (x.xxx)(x.xxx)(x.xxx). After two beta conversions you get (x.xxx)(x.xxx)(x.xxx)(x.xxx), and so on.

More Related