2 - the above relationship between equivalent Haskell...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
bottom :: Bool bottom = bottom The functions myand and myand ’ do not behave in the same way using bottom . The expression ( myand False bottom ) evaluates to False , whereas the ex- pression ( myand False bottom ) does not terminate. Now consider in addi- tion the Haskell function myand’’ :: Bool -> Bool -> Bool myand’’ b1 b2 = if b1 then b2 else False The function myand’’ has identical behaviour to myand’ . We can describe the relationship between equivalent Haskell functions as follows: Two Haskell functions f : A B and g : A B behave in the same way if and only if, for all terms a in type A , then if f a terminates then g a terminates and f a = g a , and if f a does not terminate then g a does not terminate. You will be learning more about this story in the operational semantics course in the second year. Here, we explore the abstract concept of rela- tions. We will describe equivalence relations , special relations which for ex- ample behave like the standard equality on the natural numbers and include
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: the above relationship between equivalent Haskell functions, and orderings which for example behave like the less than ordering between natural num-bers. We will also describe natural ways of constructing new relations from old, including those used in relational databases. 2 Sets Our starting point will be the idea of a set, a concept that we shall not formally deFne. Instead, we shall simply use the intuitive idea that a set is a collection of objects. D EFINITION 2.1 (I NFORMAL ) A set is a collection of objects (or individuals) taken from a pool of objects. The objects in a set are also called the elements , or members , of the set. A set is said to contain its elements. We write x A when object x is a member of set A . When x is not a member of A , we write x A or sometimes ( x A ) using notation from the logic course. 3...
View Full Document

Ask a homework question - tutors are online