ϵ">]>
9. CVIČENIE Z PREDMETU ÚVOD DO DEKLARATÍVNEHO PROGRAMOVANIA
http://ii.fmph.uniba.sk/cl/courses/1-AIN-505-udp/0910ls/ex/ex09.cl
Dátum: streda 26. a 28. 4. 2010
Odporúčaná verzia CL: 5.81.19
WWW stránka predmetu: http://ii.fmph.uniba.sk/cl/courses/1-AIN-505-udp/0910ls/?lang=sk
Assignment 1. Define a format of codes of numeric terms with variables. is true if its argument was constructed using only the functions (constructors) , , , .
Assignment 2. Define the denotation function for numeric terms with variables , which yields the value of the term under the valuation of variables . A valuation of variables is a list such that the value of variable is the -th element of the list .
Assignment 3. Programs for the postfix machine are lists of instructions. Define a predicate which holds true for such programs.
Operation of the machine. For any programs , , a stack , and a stack frame we have
for some . We the say that the execution of program by the postfix machine pushes the value computed by to the top of the stack .
The idea of stack frames is to hold the values of variables accessed in by instructions . Note that when such an instruction is executed with a current stack we should have for some and then the value pushed on the top of will be taken from the frame as .
Assignment 4. Define a function which simulates the run of the postfix machine for the program and stack .
Assignment 5. Define the function which compiles the term into a program, which expects the stack frame in the depth . If for any , , and such that we have then we also have for any