Advanced Search

Browse by Discipline

Scientific Societies

E-print Alerts

Add E-prints

E-print Network

  Advanced Search  

Verifying Program Optimizations in Agda Case Study: List Deforestation

Summary: Verifying Program Optimizations in Agda
Case Study: List Deforestation
Andreas Abel
16 July 2009
This is a case study on proving program optimizations correct. We prove the foldr-unfold
fusion law, an instance of deforestation. As a result we show that the summation of the
rst n natural numbers, implemented by producing the list n :: ... :: 1 :: 0 :: [ ] and
summing up the its elements, can be automatically optimized into a version which does
not use an intermediate list.
module Fusion where
open import Data.Maybe
open import Data.Nat
open import Data.Product
open import Data.List hiding (downFrom)
open import Relation.Binary.PropositionalEquality
import Relation.Binary.EqReasoning as Eq
From Data.List we import foldr which is the standard iterator for lists.
foldr : {a b : Set} (a b b) b List a b
foldr c n [ ] = n
foldr c n (x :: xs) = c x (foldr c n xs)


Source: Abel, Andreas - Theoretische Informatik, Ludwig-Maximilians-Universit√§t M√ľnchen


Collections: Computer Technologies and Information Sciences