## 15-816 Linear Logic |

- Exercise 1
- Consider the simple imperative programming language which
extends the one defined in class
- Cells: x
- Values: v ::= z | s v | true | false
- Expressions: e ::= z | s e | e1 + e2 | e1 * e2 | x | true | false | not e | and e1 e2 | eq e1 e2
- Commands: c ::= nop | c1 ; c2 | while e do c | x := e | print x
- Store: S := . | S, x = v
- Continuations : K := nop | c; K

- Evaluation: S |- e ==> v
- Execution: S |- c / K exec
- Termination: S |- K term

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.

Carsten Schuermann carsten@cs.cmu.edu