PCF-Compiler icon indicating copy to clipboard operation
PCF-Compiler copied to clipboard

Capture avoidance in substitution

Open Blaisorblade opened this issue 10 years ago • 0 comments

How do you prevent variable capture in substitution?

I think your code would cause capture with (for instance) subst("fun x -> y", "y", "x z") (where I write concrete syntax instead of ASTs). That could be triggered when normalizing (fun y -> fun x -> y) (x z). With your current code, this example won't be a problem since you have an evaluator, which refuses open terms; so I'm not sure this bug can already be triggered in this particular way.

But (I'd say) this is the sort of thing that at the very least deserves a comment. Alternatively, I'd just implement (some variant of) capture-avoiding substitution.

See the intro to chapter 6 of Pierce's TAPL for a list of approaches.

Blaisorblade avatar Dec 31 '15 16:12 Blaisorblade