Download presentation

Presentation is loading. Please wait.

Published byAlicia Haynes Modified over 2 years ago

1
12 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal Methods Functions

2
12 April 2009Instructor: Tasneem Darwish2 Outlines Partial functions Lambda notation Functions on relations Overriding Properties of functions Finite sets

3
12 April 2009Instructor: Tasneem Darwish3 Partial Functions A partial function from X to Y is a relation that maps each element of X to at most one element of Y ; we write to denote the set of all such relations Example 8.1 An organisation has a system for keeping track of its employees while they are on the premises. Each employee is issued with an active badge which reports their current position to a central database. If the set of all people is Person, and the set of all locations is Location, then the information provided by the system may be described by a relation where_is of type Person↔Location. It is impossible for an employee to be in two places at once, so this relation will be a partial function:

4
12 April 2009Instructor: Tasneem Darwish4 Partial Functions These relations are called partial functions because there may be elements of X that are not related to any element of Y. If each element of X is related to some element of Y, then the function is said to be total; we write X →Y to denote the set of all total functions from X to Y Example 8.2 We may define a relation double on the set of natural numbers N as follows: This relation is a total function: for every natural number m there is a unique number n such that

5
12 April 2009Instructor: Tasneem Darwish5 Partial Functions If a lies within the domain of a function f, we write f (a) to denote the unique object that is related to x We say that f (a) is the result of applying function f to argument a There are two inference rules associated with function application:

6
12 April 2009Instructor: Tasneem Darwish6 Partial Functions Example 8.3 If Rachel is an employee, then we may write where_is rachel to denote her current location. Where_is = =

7
12 April 2009Instructor: Tasneem Darwish7 Lambda notation Suppose that f is a function whose domain is precisely those elements of X that satisfy a constraint p. If the result of applying f to an arbitrary element x can be written as the expression e, then f can be described as The lambda notation offers a more concise alternative; Example 8.4 The function double could also be defined by

8
12 April 2009Instructor: Tasneem Darwish8 Lambda notation Example 8.5 The function min maps a set of natural numbers to the least number present in that set: the minimum value If the declaration part of a lambda expression introduces more than one variable, then the source type of the function is given by the resulting characteristic tuple The source is the Cartesian product set

9
12 April 2009Instructor: Tasneem Darwish9 Lambda notation Example 8.6 The function pair takes two functions f and g as arguments, each of which must be a homogeneous relation on N. The result is a function that takes a natural number n and returns the pair formed by applying each of f and g to n: Example 8.7 Let triple be the function

10
12 April 2009Instructor: Tasneem Darwish10 Functions on Relations Example 8.8 The domain and range operators may be defined by

11
12 April 2009Instructor: Tasneem Darwish11 Functions on Relations Example 8.9 The restriction operators may be defined by

12
12 April 2009Instructor: Tasneem Darwish12 Functions on Relations Example 8.10 The relational composition operator may be defined by

13
12 April 2009Instructor: Tasneem Darwish13 Functions on Relations Example 8.11 The relational inverse operator may be defined by

14
12 April 2009Instructor: Tasneem Darwish14 Functions on Relations Example 8.12 The transitive closure operator may be defined by

15
12 April 2009Instructor: Tasneem Darwish15 Overriding To combine the information contained in functions f and g, we could simply write f U g. However, there may be objects that are mapped to one value under f, and to another under g; if this is the case, then f U g is not a function. Function f Function g f U g Not a function

16
12 April 2009Instructor: Tasneem Darwish16 Overriding If f and g are functions of the same type, we write f g to denote the relational overriding of f with g. Relational overriding is a relation that agrees with f everywhere outside the domain of g; but agrees with g where g is defined and its result is a function: Function f Function g Relational overriding of f with g

17
12 April 2009Instructor: Tasneem Darwish17 Overriding Although the operator is usually employed for functions, it may be applied to any two relations of the same type.

18
12 April 2009Instructor: Tasneem Darwish18 Overriding Example 8.13 Suppose that a partial update arrives from the staff location system, informing us that Rachel and Sally are in the lobby and that Tim is in the office. This update may be represented by a partial function from Person to Location: The expression (where_is U update) rachel is not defined, as there are two locations associated with rachel in this relation. If the information obtained from the update function takes precedence, then we may use

19
12 April 2009Instructor: Tasneem Darwish19 Overriding If two functions have disjoint domains, then there is no conflict between them, and overriding behaves as the union operator: In this case, the overriding operator is commutative Example 8.14 If we were to receive two pieces of information, one locating Quentin and Peter and the other locating Rachel and Sally, then then we could combine them in either order:

20
12 April 2009Instructor: Tasneem Darwish20 Properties of functions The characteristic property of a function is a lack of diverging arrows in its graph (no element of the source is mapped to more than one element of the target) If there are no converging arrows, then the function is said to be an injective function, or an injection. f is an injection if Example 8.15 The location function of Example 8.3 is not injective. According to where_is, there are at least two different people in the meeting room: Where_is quentin = meeting Where_is peter = meeting and quentin ≠ peter.

21
12 April 2009Instructor: Tasneem Darwish21 Properties of functions If the range of a function is the whole of the target, then it is said to be a surjective function, or a surjection. If the target of function f is B, then f is a surjection if ran f = B Example 8.16 There are three entrances to the Pink Flamingo: the front door, the back door, and the fire exit. Kenny and Peanut are paid to stand at the front door, Neville and Sammy are watching the back, and Animal is leaning on the fire exit. This situation is represented by a surjective function,

22
12 April 2009Instructor: Tasneem Darwish22 Properties of functions A bijective function, or bijection, is a function which is both injective and surjective (no two elements of the domain are mapped to the same object, and the range is the whole of the target set). Example 8.17 It is Senior Citizens Night at the Pink Flamingo, so Reg Thorpe, the owner, decides that he needs just one bouncer on each door. Peanut and Sammy are given the night off, This is a partial bijection from the set of bouncers

23
12 April 2009Instructor: Tasneem Darwish23 Properties of functions Functions can be categorized to six category according to their properties:

24
12 April 2009Instructor: Tasneem Darwish24 Properties of functions By generic abbreviation we can define the set of all partial injective functions : if A and B are sets, then A total injective function is any member of partial injective functions which is also a total function from A to B. Example 8.18 If s and t are the two sets {1, 2} and {a, b, c} respectively, then the set of all partial injective functions from s to t is given by: and the set of all total injective functions is given by

25
12 April 2009Instructor: Tasneem Darwish25 Properties of functions By generic abbreviation we can define the set of all partial surjective functions : if A and B are sets, then A total surjective function is any member of partial surjective functions which is also a total function from A to B. Example 8.19 If s and t are as defined in Example 8.18, then there are no surjective functions from s to t : The source s has fewer elements than the target t, and for a function to be surjective, there must be at least as many elements in the domain as there are in the target.

26
12 April 2009Instructor: Tasneem Darwish26 Properties of functions By generic abbreviation we can define the set of all partial Bijection functions : if A and B are sets, then A total Bijection function is any member of partial Bijection functions which is also a total function from A to B. Example 8.20 As none of the functions from s and t are surjections, there can be no bijections between these two sets. If we replace t with the set {a, b}, then two bijections are possible: Both of these are total

27
12 April 2009Instructor: Tasneem Darwish27 Finite sets A finite set is one whose elements are countable up to some natural number n The number range operator is a function on pairs of natural numbers, for defining finite sets of numbers. Example 8.22 There are a finite number of oceans: we can exhibit a total bijection from the range 1.. 4 to the set of all Oceans:

28
12 April 2009Instructor: Tasneem Darwish28 Finite sets if X is a set, then the set of all finite subsets of X is given by If X is a finite set, then FX and PX are equal. If s is a finite set, we write #s to denote the number of elements in s. This operator, called size or cardinality. Example 8.23 #Oceans = 4 #Primes is undened

Similar presentations

OK

08 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.

08 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google