Reduction example
To show how optimal reduction works, we step through the example term M = o $ \h. o (h I)
from pages 26-35 of [AG99]. To write the derivation tree we must define the recursive type \(\Omega = \, !\Omega \to \Omega\).
Root ret
Cut o1 o1l
o1/[]/[] = PiRight ^func, [x_o1], [ret_o1], [], [] ->
x_o1 = BangC x1_o1 x2_o1
x2_o1 = BangD x2i_o1
x2i_o1 = PiLeft ^func [(x1_o1r, x1_o1/x1_o1r = Identity)] [(ret_o1l, ret_o1l/ret_o1 = Identity)]
o1l = PiLeft ^func [(fp,
fp/[]/[] = Bang f []/[]
f/[]/[] = PiRight ^func, [h_d], [f_ret], [], [] ->
Cut o2 o2l
o2/[]/[] = PiRight ^func, [x_o2], [ret_o2], [], [] ->
x_o2 = BangC x1_o2 x2_o2
x2_o2 = BangD x2i_o2
x2i_o2 = PiLeft ^func [(x1_o2r, x1_o2/x1_o2r = Identity)] [(ret_o2l, ret_o2l/ret_o2 = Identity)]
o2l = PiLeft ^func [(hi_retp,
hi_retp/[h_d]/[] = Bang hi_ret [h_di]/[]
h_di = BangD h
Cut i h_app
i/[]/[] = Bang i_i []/[]
i_i/[]/[] = PiRight ^func, [il], [i_ret], [], [] ->
il = BangD ild
ild/i_ret = Identity
h = PiLeft ^func [(h_appr, h_app/h_appr = Identity)] [(hi_retl, hi_retl/hi_ret = Identity)]
)] [(f_retl, f_retl/f_ret = Identity)]
)] [(ret_l, ret_l/ret = Identity)]
First we reduce the top cut.
To handle the duplication from the contraction we duplicate the cuts/promotion rule and introduce a duplication node Dup to incrementally duplicate the rest of the structure:
The !d/!p pair removes a box; to track level we have renumber the levels of the contents of the box. Instead we retain the levels on the cut node. We also need to remember which side had the box, but in our example the higher side is always the box (this is not true in general because !d can renumber arbitrarily high).
Next we move the dup down; this is duplicating the binder as discussed on page 29.
When it encounters the PiR, technically the Dup node grows in size and becomes a 4-input 2-output node. But since dot doesn’t have enough edge labels for the monster node this is depicted in the graph as a series of 2-input 1-output Dup nodes linked with dashed lines.
On to the reduction in Figure 2.14 (4)-(5).
8
We are doing things a little out of order compared to Asperti; next is the reduction in Fig 2.11 (2)-(3).
10
11
12
13
14
15
16
… 4 duplication steps later …
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
So, an overview of the reduction: 1-2 Beta 5-6 Duplicate lambda 6-7 Beta 8-9 Beta 13-14 Duplicate app (correct) 16-17 Duplicate app x2 (too many) - Duplicate lambda - Beta - Duplicate lambda - Duplicate lambda - Duplicate lambda
Compared to Asperti: - Beta - Beta - Duplicate - Beta - Various duplications - Duplicate - Beta - Beta - Duplicate - Beta - Duplicate - Beta