A number of program transformations currently of interest can be derived from Wadler's ‘free theorems’ for calculi approximating modern functional languages. Although delicate but fundamental issues arise in proving the correctness of free theorems-based program transformations, these issues have usually been left unaddressed in the correctness proofs appearing in the literature. As a result, most such proofs are incomplete, and most free theorems-based transformations are applied to programs in calculi for which they are not actually known to be correct. The purpose of this paper is three-fold. First, we raise and clarify some of the issues that must be addressed when constructing correctness proofs for free theorems-based program transformations. Second, we offer a principled approach to developing such proofs. Third, we use Pitts' recent work on parametricity and observational equivalence to show how our approach can be used to give the first proof that transformations based on the Acid Rain theorems preserve observational equivalence of programs in a polymorphic lambda calculus supporting FPC-style fixpoints and algebraic data types. Correctness of the foldr-build rule, the destroy-unfoldr rule, and the hylofusion program transformation for this calculus follows immediately. The same approach is expected to yield complete correctness proofs for free theorems-based transformations in calculi that even more closely resemble languages with which programmers are concerned in practice.
当前有许多感兴趣的程序转换可以从瓦德勒的“自由定理”中估计现代功能语言,尽管在提供基于自由定理的程序转换的正确性方面出现了,但这些问题通常在结果出现在文献中,大多数这样的证明是不完整的,并且大多数基于定理的转换都适用于实际上,他们的目的是三倍,我们的目的是正确的。我们提供了制定此类证据的主要方法。基于酸雨定理的转换保留了多态性lambda计算中程序的观察等效性,支持FPC风格的固定点和代数数据类型,折叠式构建规则的正确性立即遵循相同的方法。实践中与程序员有关的语言。