Functions

Vincent Tam

4th Sept., 2022

Settings

What is function?

wife function concubine function
length function
  • need better words to describes things
  • what about inverse functions?

Name list

Z M S G
ๅง“ ๅ surname given name
็Ž‹ ๅ…ซๆ—ฆ Wong Eight Eggs
ๆŽ ๅด”็‰› Li Tsui Ngau
็‰› ๆŸ่‘‰ Ngau Albert
ไธ ไธ€ๅฎ Ting One
ๆŽ ้นตๅ‘ณ Lee Braised Dishes
ๆŽ ่€็ซ‡ Li Lo Dull
้ปƒ ๅœŸๅœฐ Wong Land
ๆŽ ่€่กจ Li Low Bill
ๆŽ ่…ฆ็ดฐ Lee Old boss
่ข ๅฐผๅง‘ Yuen Nun
ๅฎน ๆตท้พœ Yung Hoi Kwai
ๆŽ ่€ๅ‹ Lee No Friend
ๆŽ ่€ๆฟ Lee Low Ban
ไปป ไฝ•ไบบ Yam Ho Yan
ๆญ้™ฝ ๆŽ Au Yeung Lee
ๅฎน ๆตทๆญธ Yung Hoi Kwai
ๆฅŠ ็ฅ– Yeung Joe
้บฅ ้บฅๅฎ‹ Mak Mac Delivery
็‹„ ็‹„ๅฐผ Dick Disney

Two ways to write sets

Goal: To write a set of all persons with surname โ€œๆŽโ€

ETV

set operations

venn diagram 2 circles ย 

union (โˆช)

intersection (โˆฉ)

complement (c)

difference (\)

Cartesian product

cartesian product ย 

Logical AND (โˆง)

Example: Save (Ctrl + S)

Ctrl S Ctrl + S
โœ“ โœ“ โœ“
โœ“ โœ— โœ—
โœ— โœ“ โœ—
โœ— โœ— โœ—
p q p โˆง q
T T T
T F F
F T F
F F F

Logical OR (โˆจ)

Example: digit key (e.g.ย 1 in numpad or above alphabets)

numpad 1 alphabet 1 enter 1
โœ“ โœ“ โœ“
โœ“ โœ— โœ“
โœ— โœ“ โœ“
โœ— โœ— โœ—
p q p โˆจ q
T T T
T F T
F T T
F F F

Implication (โŸน)

Example 1

entered Univ through JUPAS attended secondary school entered Univ through JUPAS โŸน attended secondary school example
โœ“ โœ“ โœ“ me
โœ“ โœ— โœ— who?
โœ— โœ“ โœ“ IB, GCE A Level
โœ— โœ— โœ“ ๆฒˆ่ฉฉ้ˆž

Implication (โŸน)

Example 2

Promise: win Mark Six (ๅ…ญๅˆๅฝฉ) โŸน treat you to dinner in a seafood restaurant

P bought Mark Six? bill on me? promise kept?
๐Ÿ‘ฉโ€๐Ÿณ โœ“ โœ“ โœ“
๐Ÿ‘ฎ โœ“ โœ— โœ—
๐Ÿ‘จโ€๐ŸŒพ โœ— โœ“ โœ“
๐Ÿ‘จโ€๐Ÿ’ป โœ— โœ— โœ“

๐Ÿ‘จโ€๐Ÿ’ป: I donโ€™t buy Mark Six, so I donโ€™t have to spring for your dinner. ๐Ÿ˜›

set of persons who kept their promise = {๐Ÿƒโ€โ™‚๏ธ โˆˆ P | ๐Ÿƒโ€โ™‚๏ธ kept his/her promise} = {๐Ÿ‘ฉโ€๐Ÿณ, ๐Ÿ‘จโ€๐ŸŒพ, ๐Ÿ‘จโ€๐Ÿ’ป}

Implication (โŸน) and subsets

p q p โŸน q
T T T
T F F
F T T
F F T

Recall:

Implication (โŸน)

To prove a โ€œโŸนโ€ statement

Direct way

  1. Assume the premise p is true.
  2. Show that the conclusion q is true.

Implication (โŸน)

To prove a โ€œโŸนโ€ statement

By contradiction

Example: solve Sudoku (ๆ•ธ็จ) by guessing.

p : known grids
7 4 6 9 5 2 3
6 9 5 2 7 8
2 3 7 5 6 9
8 2 3 5 7 6 9
5 6 9 2 8 7
1 7 4 6 9 8 2 3 5
3 6 7 4 8 2
4 2 6 7
9 8 7 1 2 6
some posibilities
7 4 18 18 6 9 5 2 3
6 9 5 2 34 13 7 14 8
2 3 7 5 6 9 14
8 2 3 14 5 7 14 6 9
5 6 9 2 8 7 14
1 7 4 6 9 8 2 3 5
3 6 7 4 8 2
4 2 6 7
9 8 7 1 2 6
~q : wrong guess
7 4 6 9 5 2 3
6 9 5 2 7 8
2 3 7 5 6 9
8 2 3 5 7 6 9
5 6 9 2 8 7
1 7 4 6 9 8 2 3 5
3 6 7 4 8 2
4 2 6 7
9 8 7 1 2 6
  1. p True
  2. p โˆง ~q False
  3. so ~q False (i.e.ย q True)

Sudoku source

Wikiโ€™s Function definition

A function f: A โ†’ B is a subset of A ร— B such that

right-unique (็”จๆƒ…ๅฐˆไธ€)
๐Ÿง‘โค๐Ÿฆธโ€โ™€๏ธ โˆง ๐Ÿง‘โค๐Ÿฆน โ‡’ ๐Ÿฆธโ€โ™€๏ธ = ๐Ÿฆน
โˆ€ a โˆˆ A, โˆ€ b โˆˆ B, โˆ€ bโ€™ โˆˆ B,
((a,b) โˆˆ f โˆง (a,bโ€™) โˆˆ f) โŸน b = bโ€™
no concubine
total (ๅ†‡ๅ–ฎ่บซ็‹—)
โˆ€ ๐Ÿง‘ โˆˆ A, โˆƒ ๐Ÿ‘ฉ โˆˆ B : ๐Ÿง‘โค๐Ÿ‘ฉ
โˆ€ a โˆˆ A, โˆƒ b โˆˆ B : (a,b) โˆˆ f
no bachelor

The domain of f is A.

Domain, codomain and range

domain and range ย 

In the picture,

Injective functions and Surjective functions

injective function (ๅฅณ็‰ˆ็”จๆƒ…ๅฐˆไธ€)
๐Ÿ‘ฉโ€๐Ÿ’ปโค๐Ÿ‘ฉ โˆง ๐Ÿ‘ทโค๐Ÿ‘ฉ โ‡’ ๐Ÿ‘ฉโ€๐Ÿ’ป = ๐Ÿ‘ท
โˆ€ a โˆˆ A, โˆ€ aโ€™ โˆˆ A, โˆ€ b โˆˆ B,
((a,b) โˆˆ f โˆง (aโ€™,b) โˆˆ f) โŸน a = aโ€™

๐Ÿ“ To prove that a function f is injective,
we assume that f(a) = f(aโ€™),
then we show that a = aโ€™.
left-unique
surjective function (ๅ†‡ๅ–ฎ่บซ็‹—ไนธ)
โˆ€ ๐Ÿ‘ฉ โˆˆ B, โˆƒ ๐Ÿง‘ โˆˆ A : ๐Ÿง‘โค๐Ÿ‘ฉ
โˆ€ b โˆˆ B, โˆƒ a โˆˆ A : (a,b) โˆˆ f

๐Ÿ“ To prove that a function f is surjective,
we pick an arbitrary element b in the codomain B,
then we try to find an element a in the domain A such that f(a) = b.
no spinster

Bijective functions and inverse functions

A function is bijective is it is both injective and surjective.

  1. surjective function (ๅ†‡ๅ–ฎ่บซ็‹—ไนธ)

    Given ๐Ÿ‘ฉ โˆˆ B. You can find a ๐Ÿง‘ โˆˆ A so that ๐Ÿง‘โค๐Ÿ‘ฉ.

  2. injective function (ๅฅณ็‰ˆ็”จๆƒ…ๅฐˆไธ€)

    You canโ€™t have two different ๐Ÿง‘ & ๐Ÿ‘ฆ such that ๐Ÿง‘โค๐Ÿ‘ฉ & ๐Ÿ‘ฆโค๐Ÿ‘ฉ. They must been the same person. (represented by ๐Ÿง‘)

If we have a bijective function f : A โ†’ B defined by f : ๐Ÿง‘ โ†ฆ ๐Ÿ‘ฉ, then we can define an inverse function fโปยน : ๐Ÿ‘ฉ โ†ฆ ๐Ÿง‘.

Comments and critiques

Field medalist Shing-Tung Yau (ไธ˜ๆˆๆก) has emphasized the importance of asking good questions (not in the textbook).