Smallstep rules for the explicit-refs machine ================================================================ Expressions: e ::= n | -(e1,e2) zero?(e1) | if e1 then e2 else e3 x | let x = e1 in e2 | proc(x)e | (e1 e2) letrec {f(x)=e}* in e begin e; e* end newref e | deref e | setref e1 e2 //---additional expression forms for values, introduced by substitution---// %loc(n) // location values %true // boolean values %false // Configurations: C ::= where e is an expression and s is a store ================================================================ Values: v ::= n proc(x)e // must be closed %true, %false %location(n) ================================================================ Frames and Reduction Contexts: F ::= -([],e) // diff1-frame -(v,[]) // diff2-frame zero?([]) // zero?-frame if [] then e1 else e2 // if-test-frame let id=[] in e2 // let-rhs-frame ([] e2) // app-rator-frame (v []) // app-rand-frame begin [] e* end // begin-frame newref [] deref [] setref [] e2 setref v1 [] K = F* ================================================================ Rules (using alternate grouping) focus-up <[], v, s> -> v focus-down -> focus-up focus-down -> focus-up focus-down -> focus-up focus-down -> focus-up focus-down -> focus-down focus-down -> focus-down focus-up -> focus-down focus-up -> focus-up where p = v1-v2 focus-down -> focus-down focus-up -> focus-up {or } focus-down -> focus-down focus-up -> focus-down {or } focus-down -> focus-down focus-up -> focus-down // in explicit-refs, "let" doesn't allocate focus-down -> focus-down focus-up -> focus-down focus-up -> focus-down focus-down -> focus-down focus-up -> focus-up focus-up -> focus-down focus-down -> focus-down focus-up -> focus-up where n not in dom(s) focus-down -> focus-down focus-up -> focus-up where v = s(n) focus-down -> focus-down focus-up -> focus-down focus-up -> focus-up ================================================================ reduce-letrec: letrec D in e -> e[f_i |-> proc (x_i) letrec D in e_i]_i where D = (f_i x_i e_i)_i ================================================================ No-dangling-pointers invariant: INV(): If %loc(n) appears in e or in the range of s, then n is in dom(s). ================================================================ Proposition: If e contains no subterms of the form %loc(n), and > ->* >, then INV() is true. Proof: By induction on the number of steps in the reduction. Base Step: INV is true. Induction Step: We must show that if INV() and > -> >, then INV(). If %loc(n) appears in then either it must have appeared in or it must have been introduced by the rule focus-up -> focus-up where n not in dom(s) If %loc(n) was in e or the range of s, then n in dom(s) \subset dom(s'). If %loc(n) was introduced by the focus-up-newref rule, then n is in dom(s'). So we're done. ================================================================