Using Subtyping in Program Optimization

Constructive logics can be used to write the specifications of programs as logic formulas to be proved. By using the Curry-Howard isomorphism, we can automatically extract executable code from constructive proofs. Normally, programs automatically generated are inefficent. They contains parts useless to compute the final result. In this paper, we show a technique to erase such useless parts from programs. Our technique is essentially an extension of another method, developed by S. Berardi, optimizing simply typed λ-terms. By using the notion of subtyping, we can overcome some intrinsecal limitations of the original method. We prove that optimized terms are equivalent to the original ones and we give an algorithm to find such optimizations