10.07.2015 Views

An Introduction to Functional Programming Through Lambda Calculus

An Introduction to Functional Programming Through Lambda Calculus

An Introduction to Functional Programming Through Lambda Calculus

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

- 70 -or by specifying a base object and a means of constructing new objects from the base, for example for naturalnumbers:0 is a numberSUCC N is a numberif N is a numberThus, we can show that:SUCC (SUCC (SUCC 0))is a number because:0SUCC 0SUCC (SUCC 0)are all numbers.Operations may be specified exhaustively with a case for each base value, for example for booleans, negation:NOT TRUE = FALSENOT FALSE = TRUEand conjunction:AND FALSE FALSE = FALSEAND FALSE TRUE = FALSEAND TRUE FALSE = FALSEAND TRUE TRUE = TRUEOperations may also be specified constructively in terms of base cases for the base objects and general cases for theconstructive objects. For example for natural numbers, the predecessor function:PRED 0 = 0PRED (SUCC X) = Xand addition:ADD X 0 = XADD X (SUCC Y) = ADD (SUCC X)Yand subtraction:SUB X 0 = XSUB (SUCC X) (SUCC Y) = SUB X Yand multiplication:MULT X 0 = 0MULT X (SUCC Y) = ADD X (MULT X Y)Note that we have just formalised the informal descriptions from the last chapter. We will look at the relationshipbetween exhaustive and case definitions, and our conditional style of definition later in this chapter.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!