THEORETICAL PEARL Church numerals, twice!

  • Authors:
  • Ralf Hinze

  • Affiliations:
  • Institut für Informatik III, Universität Bonn, Römerstraβe 164, 53117 Bonn, Germany (e-mail: ralf@informatik.uni-bonn.de)

  • Venue:
  • Journal of Functional Programming
  • Year:
  • 2005

Quantified Score

Hi-index 0.00

Visualization

Abstract

This pearl explains Church numerals, twice. The first explanation links Church numerals to Peano numerals via the well-known encoding of data types in the polymorphic λ-calculus. This view suggests that Church numerals are folds in disguise. The second explanation, which is more elaborate, but also more insightful, derives Church numerals from first principles, that is, from an algebraic specification of addition and multiplication. Additionally, we illustrate the use of the parametricity theorem by proving exponentiation as reverse application correct.