15-816 Linear Logic

Assignment 8: Programming in Lolli

Exercise 1
Consider the simple imperative programming language which extends the one defined in class and the three judgments together with their evaluation rules. Here are a few examples of the rules:

S |- e ==> v
-------------------- ev_s      ------------------ ev_true
S |- (s e) ==> (s v)           S |- true ==> true


S |- c1 / c2 ; K exec          
--------------------- exec_seq   
S |- c1 ; c2 / K exec         


S1, x=v', S2 |- e ==> v     S1, x=v, S2 |- K term
------------------------------------------------- exec:=	
S1, x=v', S2 |- x := e / K exec


                           S |- c / K exec
------------- term_nop     --------------- term_seq
S |- nop term              S |- c ; K term

	

Question 1: Represent the three judgments in Lolli and encode evaluation, execution and termination.

Question 2: Write a Lolli predicate times2 N which calculates and prints 2 * N, by executing an appropriate program in this language.

Exercise 2
Consider a 2 x 2 cube which is made of 8 little colored cubes. You can rotate either side of this cube. Note, that this cube is different from Rubik's cube, because the visible sides of one little cube have all the same color. In principle, we could write a program which solves the more complicated problem of a 2x2 Rubik's cube, but the running time for such a program would not be acceptable.

Assume the cube has the following initial configuration (front view/ back view).

The goal is to find a sequence of rotations which transforms this configuration into the final configuration.

Encode the representation of the initial configuration in Lolli, together with the possible rotations, and write a function which determines the shortest number of rotations to arrive at the final configuration.


[ home | schedule | assignments | languages | handouts | overview | links ]


Carsten Schuermann
carsten@cs.cmu.edu