1

Given this implementation of the addition of Churck numerals,

plus = λm. λn. λs. λz. m s (n s z)

and this first implementation of the product, that builds on top of it,

times = λm. λn. m (plus n) c0

exercise 5.2.3 asks to implement times without using plus; here's the solution:

times = λm. λn. λs. m (n s)

Despite both are individually clear to me, I'm not sure how to show that they are actually the same thing; I suppose I should prove that m (plus n) c0 and λs. m (n s) are the same thing.

I can surely expand the former like follows, to show that it is indeed the product function:

m (plus n) c0 = m (λm. λs. λz. m s (n s z)) c0
              -- appropriately defining h
              = m h c0
              = h (h (h ... (h (h c0)) ... ))
                \----- ×m ------/
              = h (h (h ... (h (λs. λz. c0 s (n s z))) ... ))
                \-- ×(m-1) --/
              = h (h (h ... (h (λs. λz. n s z)) ... ))
              = h (h (h ... (h cn) ... ))
              = c(m×n)

where c(m×n) is the m×n-th Church numeral. And surely I can do something similar for the second version of times, but it feels like I'm "cheating" because I'm using ..., and I'm even using m-1, but - is not even defined yet, so I guess I shouldn't need it.

Enlico
  • 127
  • 9

0 Answers0