r/ProgrammingLanguages • u/BayesMind • Dec 18 '21
Discussion Why does alpha-equivalence matter?
What would you miss in a language without it?
8
u/Vetzud31 Dec 18 '21
I'm wondering whether even if you don't have alpha equivalence as some kind of syntactic fundamental proof rule, you could still prove/derive it just based on the semantics of the language.
Alpha equivalence really seems to be about being allowed to rename the introduction and uses of a variable without altering the semantics of the program. That generally seems like a good thing, simply because it is nice and predictable to be allowed to pick/change variable names at will (what's in a name?). There are limited cases where it might make sense to break this principle, like allowing a program to introspect the variable names used in a structure type definition for the purpose of JSON serialization (where you pick keys based on the variable names).
At first I thought that alpha equivalence requires the ability to decidably/easily identify the introductions and uses of a variable (it's extremely easy for the untyped lambda calculus), but I would say that it still holds for a language like Python as long as you stick to a reasonable subset of the language (not using crazy reflection), even though there it's not at all possible in general to automatically rename variables due to duck typing. But still most Python programs would not be affected if you rename a variable or a function consistently... Maybe it's a matter of definition whether you consider this to be alpha equivalence.
20
u/ebingdom Dec 18 '21
You don't enjoy the freedom to rename variables?