Functions. A function between two sets is a relation between those sets that has a special property, namely that each member of the from-set is related.

Slides:



Advertisements
Similar presentations
Functions Reading: Epp Chp 7.1, 7.2, 7.4
Advertisements

1.6 Functions. Chapter 1, section 6 Functions notation: f: A B x in A, y in B, f(x) = y. concepts: –domain of f, –codomain of f, –range of f, –f maps.
Functions.
Functions A function, f, is a mechanism that relates (or maps) one set of elements to another set. –More specifically, f, is a special type of relation.
12 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
The Engineering Design of Systems: Models and Methods
Relations. Ipoh Kota Bharu Alor Star Seremban Pasir Mas Perak Kelantan Kedah Neg. Sembilan citiesstates isin.
Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
1 Functions Chapter 10 Formal Specification using Z.
Schemas. Nature of a schema: scope of names in a Z specification Names that are not confined inside schemas. Need to declare and called as global declaration.
Relations. Ipoh Kota Bharu Alor Star Seremban Pasir Mas Perak Kelantan Kedah Neg. Sembilan citiesstates isin.
Functions Goals Introduce the concept of function Introduce injective, surjective, & bijective functions.
1 Section 1.8 Functions. 2 Loose Definition Mapping of each element of one set onto some element of another set –each element of 1st set must map to something,
Section 4.1 Finite Permutation Groups Permutation of a Set Let A be the set { 1, 2, …, n }. A permutation on A is a function f : A  A that is both one-to-one.
CS 2210 (22C:019) Discrete Structures Sets and Functions Spring 2015 Sukumar Ghosh.
Function: Definition A function is a correspondence from a first set, called the domain, to a second set, called the range, such that each element in the.
RMIT University; Taylor's College
Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping.
The Z Notation: relations and functions Compiled By Tariq R. Soomro, Ph.D. Reference: Text Book Week-7.
Logics for Data and Knowledge Representation Introduction to Algebra Chiara Ghidini, Luciano Serafini, Fausto Giunchiglia and Vincenzo Maltese.
Relations and Functions Another Foundational Concept Copyright © 2014 – Curt Hill.
SECTION 1.1 FUNCTIONS FUNCTIONS. DEFINITION OF A RELATION A relation is a correspondence between two sets. If x and y are two elements in these sets and.
12 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
Foundations of Discrete Mathematics Chapter 3 By Dr. Dalia M. Gil, Ph.D.
Discrete Maths Objectives to show the connection between relations and functions, and to introduce some functions with useful, special properties ,
Functions. Copyright © Peter Cappello2 Definition Let D and C be nonempty sets. A function f from D to C, for each element d  D, assigns exactly 1 element.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
1 Annoucement n Skills you need: (1) (In Thinking) You think and move by Logic Definitions Mathematical properties (Basic algebra etc.) (2) (In Exploration)
Functions1 Elementary Discrete Mathematics Jim Skon.
Chapter 1 SETS, FUNCTIONs, ELEMENTARY LOGIC & BOOLEAN ALGEBRAs BY: MISS FARAH ADIBAH ADNAN IMK.
1.4 Sets Definition 1. A set is a group of objects . The objects in a set are called the elements, or members, of the set. Example 2 The set of positive.
Functions Reading: Chapter 6 (94 – 107) from the text book 1.
Basic Structures: Functions Muhammad Arief download dari
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
Agenda Week 10 Lecture coverage: –Functions –Types of Function –Composite function –Inverse of a function.
Language: Set of Strings
MAT 2720 Discrete Mathematics Section 3.1 Functions
Sets. Definitions (I) Collection of elements such that: There are no duplicates There is no order Special sets Universe (U or E): all elements under consideration.
Formal Methods in SE Lecture 16 Formal Methods in SE Qaisar Javaid Assistant Professor.
Basic Structures: Sets, Functions, Sequences, and Sums.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
Functions (Mappings). Definitions A function (or mapping)  from a set A to a set B is a rule that assigns to each element a of A exactly one element.
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
Set Theory Concepts Set – A collection of “elements” (objects, members) denoted by upper case letters A, B, etc. elements are lower case brackets are used.
FUNCTIONS COSC-1321 Discrete Structures 1. Function. Definition Let X and Y be sets. A function f from X to Y is a relation from X to Y with the property.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Functions CSRU1400 Spring 2008Ellen Zhang 1 CISC1400, Fall 2010 Ellen Zhang.
1 Lecture 5 Functions. 2 Functions in real applications Curve of a bridge can be described by a function Converting Celsius to Fahrenheit.
Section 2.3. Section Summary  Definition of a Function. o Domain, Cdomain o Image, Preimage  One-to-one (Injection), onto (Surjection), Bijection 
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
Functions Goals Introduce the concept of function
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Relations and Functions
Relations, Functions, and Matrices
Cartesian product Given two sets A, B we define their Cartesian product is the set of all the pairs whose first element is in A and second in B. Note that.
MATH 224 – Discrete Mathematics
Chapter 2 Sets and Functions.
Relation and function.
Chapter 3 Relation and Function Homework 4 For each of the following relations on set A = { 1,2,3,4 }, check each of them whether they are reflexive, irreflexive,
Functions Section 2.3.
CS201: Data Structures and Discrete Mathematics I
Yet another important mathematical concept
Propositional Logic Defining Propositional Logic
Functions.
Introduction to Relations and Functions
Ch 5 Functions Chapter 5: Functions
MAT 2720 Discrete Mathematics
Functions.
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
Copyright © Zeph Grunschlag,
Presentation transcript:

Functions

A function between two sets is a relation between those sets that has a special property, namely that each member of the from-set is related to at most one member of the to-set. Functions Ipoh Kota Bharu Alor Star Seremban Pasir Mas Kangar Perak Kelantan Kedah Neg. Sembilan cities states isin

Partial Function From the diagram the city can only be in one state; there is only one arrow connecting it The domain of the function need not be the whole of the from-set

Partial Function : Examples Isin : cities ↛ states Lent_to is a function that allows a book to be borrowed by only one person at a time can be declared as Lent_to : Book ↛ Person The type of Lent_to is p (Book  Person) The predicate Book ↛ Person  Book  Person formalizes the fact that every function from Book to Person is also a relation. Lent_to : Book ↛ Person Lent_to = {r : Book  Person |  b : Book; p, q : Person  (( b r p  b r q )  p = q ))}

Partial Function : Example

Some notes Domain, range, domain restriction, range restriction, domain subtraction, range subtraction, inverse, composition apply to functions Inverse of a function may not be a function Union, intersection, difference can be used for functions Union of two functions might not be a function

Function definition by lambda abstraction

Lambda expression is equivalent to function described by set expression x : T | pred term is equivalent to {x : T | pred x ↦ term} Example : function which maps any number of which is less than 5 to its square n :  | n < 5 n 2 can also be written as {n :  | n < 5 n ↦ n 2 }

Function application Since a function maps each element of its domain to one range element we use the notation f x to denote for any x in the domain of f the unique range element to which f maps x Example: let Lent_to : Book ↛ Person suppose b : Book is in the domain Lent_to then we apply Lent_to to b by writing Lent_to b this denote the person to whom the book b has been lent. b is called the argument of the function application. Lent_to b is the value of for argument b

Examples Definition by set comprehension isqrt : { n :  | n  0  n 2 ↦ n } we would have isqrt 9 = 3 or we don’t have the function name { n :  | n  0  n 2 ↦ n } 9 = 3

Total Functions A function is total function when its domain is the whole of its from- set

Total Functions - example Suppose we define a new relation relating each Potter to their age in years: ageofPotter : Potters   it is a function since each Potter is related to only one number. every Potter has an age so the domain of this function is the whole of the from-set. This means the function is total We use → to denote total function Example: we would declare ageofPotter : Potters → 

Toolkit functions

Function Overriding

Another example Suppose the present value of Lent_to function is given by the following set enumeration old == {29 ↦ joe, 567 ↦ sue, 49 ↦ joe, 1022 ↦ les} suppose certain amendments are to be incorporated by the following set enumeration new == {29 ↦ jim, 95 ↦ joe} if we have old ⊕ new then the result will be {29 ↦ jim, 95 ↦ joe, 567 ↦ sue, 49 ↦ joe, 1022 ↦ les}

Injective Functions If each element of the domain is mapped to a different element of the to-set, then the function is injective (partial injection or 1 to 1 function) Second members of the pairs are unique Denoted by if the domain of an injection is the whole of the from-set, we call the injection a total injection Denoted by ↣

Surjective functions If the range of the function is the whole of the to-set, then the function is surjective (onto) For each second member of the pairs, there is at least one first member of the pairs Notations used partial surjective total surjective

Bijection functions A function which is both injective and surjective is said to be bijective ( 1 to 1 correspondance) Notations used

When declaring a function in a specification the important questions to consider are as follows:  is it total or partial?  is it injective?  is it surjective?  is the source a finite set?

Data type definition: free type definition Suppose we have fiction and non-fiction books. The given set for them is [Non_Fiction, Fiction] let say we want to construct a type Book to cover both kinds: we define Book ::= fict > | nfict > the definition introduces: 1) the new type Book 2) two construct functions fict and nfict > is called disjoint union bracket

Data type definition: free type definition The above definition is equivalent to: 1) [Book] 2) fict : Fiction ↣ Book 3) nfict : Non_Fiction ↣ Book 4) ran fict  ran nfict =  5) Book = ran fict  ran nfict Given this declaration f : Fiction; Lent_to : Book ↛ Person The person who has borrowed f is Lent_to (fict f)