Science Fair Projects Ideas - Church integer

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Church integer

A Church integer is a representation of natural numbers as functions, invented by Alonzo Church as part of his lambda calculus. The natural number n is represented as a higher-order function, which takes a function f as argument and returns the n-fold composition f o f o ... o f as result.

For example, in Haskell, a function that returns a particular Church integer might be

church 0 = \ f x -> x
church n = c
  where
    c f x = c' f (f x)
      where
        c' = church (n - 1) 

The transformation from a Church integer to an integer might be

unchurch n = n (+1) 0

Thus the (+1) function would be applied to an initial value of 0 n times, yielding the ordinary integer n.

In Scheme, one simple expression of the Church integers is as follows:

(define zero (lambda (x) (lambda (f) x)))
(define one  (lambda (x) (lambda (f) (f x))))
(define two  (lambda (x) (lambda (f) (f (f x)))))
(define three (lambda (x) (lambda (f) (f (f (f x))))))


This set of numbers can be transformed to integers as follows:

(define add1 (lambda (x) (+ 1 x)))
(define unchurch (lambda (c) ((c 0) add1)))

Then (unchurch two) returns the value 2

There are other mappings--the church integers will map onto anything countable. Here is a mapping onto powers of 2.

(define times2 (lambda (x) (* 2 x)))
(define unchurchpoweroftwo (lambda (c) ((c 1) times2)))

Then (unchurchpoweroftwo three) returns 8, the third power of 2.

See also

External links

10-26-2009 08:16:03
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice