๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐“ก๐“ธ๐“ธ๐“ถ5: ๐’ฆ๐‘œ๐“‡๐‘’๐’ถ ๐’ฐ๐“ƒ๐’พ๐“‹/Discrete mathematics

[์ด์‚ฐ์ˆ˜ํ•™] Chapter 3. Relations

1. Relations

 

- ์ฃผ์–ด์ง„ ์ง‘ํ•ฉ X, Y์—์„œ Cartesian product X x Y ๋ฅผ ํ•˜๋ฉด ๊ทธ ๊ฒฐ๊ณผ๋Š” x∈X, y∈Y์ธ (x, y)์˜ ๋ชจ๋“  ordered paris ์ด๋‹ค. 

 X x Y = {(x,y) | x∈X and y∈Y}

 

-Binary relation (์ด์ง„ ๊ด€๊ณ„) : ๋‘ ์ง‘ํ•ฉ์˜ ์›์†Œ ์‚ฌ์ด์˜ ๊ด€๊ณ„

 ์ง‘ํ•ฉ X ์—์„œ ์ง‘ํ•ฉ Y ๋กœ์˜ binary relation R์€, Cartesian product X x Y ์˜ subset(๋ถ€๋ถ„์ง‘ํ•ฉ)์ด๋‹ค. 

 

 Ex) X = { 1, 2, 3 } and Y = { a, b }

     R = {(1, a), (1, b), (2, b), (3, a)} ๋Š” X์™€ Y ์‚ฌ์ด์˜ relation์ด๋‹ค. 

 

- Domain : y∈Y์ธ y์— ๋Œ€ํ•˜์—ฌ (x, y)๊ฐ€ relation R์— ์†ํ•  ๋•Œ, x∈X์ธ x๋ฅผ Dom(R)์ด๋ผ๊ณ  ํ•œ๋‹ค.

               Dom(R) = { x∈X | (x, y) ∈ R for some y∈Y }

  Range :  x∈X์ธ x์— ๋Œ€ํ•˜์—ฌ (x, y)๊ฐ€ relation R์— ์†ํ•  ๋•Œ, y∈Y์ธ y๋ฅผ Rng(R)์ด๋ผ๊ณ  ํ•œ๋‹ค.

               Rng(R) = { y∈Y | (x, y) ∈ R for some x∈X }

์‰ฝ๊ฒŒ ์ƒ๊ฐํ•ด ํ•จ์ˆ˜์—์„œ ์ •์˜์—ญ๊ณผ ์น˜์—ญ์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค.

f(x)์—์„œ x์˜ ๋ฒ”์œ„๊ฐ€ ์ •์˜์—ญ, ๊ทธ์— ๋”ฐ๋ฅธ y์˜ ๊ฐ’์˜ ๋ฒ”์œ„๊ฐ€ ์น˜์—ญ์ด์—ˆ๋˜ ๊ฒƒ์ฒ˜๋Ÿผ relation๋„ ๋งˆ์ฐฌ๊ฐ€์ง€!

 

Ex) X={ 1, 2, 3 } , Y={ a, b }, R = { (1, a), (1, b), (2, b) }

์ผ ๋•Œ Dom(R) = { 1, 2 }, Rng(R) = { a, b }

 

 

- digraph of a relation : relation์˜ ์œ ํ–ฅ ๊ทธ๋ž˜ํ”„ (๋ฐฉํ–ฅ์ด ์žˆ๋Š” ๊ทธ๋ž˜ํ”„) 

 

 

- Properties of relations

 1) Reflexive : ๋ชจ๋“  x∈X์— ๋Œ€ํ•ด์„œ (x,x)∈R์ธ relation, ์ฆ‰ ์ž๊ธฐ ์ž์‹ ์„ ํ•ญ์ƒ ๊ฐ€๋ฆฌํ‚ค๋Š” relation

 2) Symmetric(๋Œ€์นญ) : ๋ชจ๋“  x, y๊ฐ€ (x, y)∈R ์ด๋ฉด (y, x)∈R์ธ relation

 3) transitive (์ „์ด(์ถ”์ด)๊ด€๊ณ„) : (x, y)∈R์ด๊ณ  (y, z)∈R์ด๋ฉด (x, z)∈R์ด ๋˜๋Š” relation

 4) antisymmetric (๋ฐ˜๋Œ€์นญ์ ) : x ≠ y์ผ ๋•Œ, (x, y)∈R์ด๋ฉด (y, x)๋Š” relation์— ์†ํ•˜์ง€ ์•Š๋Š” ๊ฒƒ. 

                                       ์ฆ‰, (a, a)๋ฅผ ์ œ์™ธํ•˜๊ณ  (a, b)๊ฐ€ R์— ์†ํ–ˆ์œผ๋ฉด (b, a)๋Š” ์†ํ•ด์žˆ์œผ๋ฉด ์•ˆ๋จ

 

- Order relations

 

  1) Partial order : R์ด reflexive, antisymmetric, transitiveํ•˜๋ฉด ์ด R์€ partial order์ด๋‹ค. 

     ex) (x, y) in R (y๋Š” x๋กœ ๋‚˜๋ˆ„์–ด ๋–จ์–ด์ง€๊ณ , x์™€ y๋Š” ์–‘์˜ ์ •์ˆ˜) 

         --> (5, 10), (5, 15), (5, 20), (10, 20)

      - ๋ชจ๋“  ์–‘์˜ ์ •์ˆ˜๋Š” ์ž๊ธฐ ์ž์‹ ์œผ๋กœ ๋‚˜๋ˆ„์–ด ๋–จ์–ด์ง€๋ฏ€๋กœ reflexive

      - (a, n*a)๊ฐ€ ์„ฑ๋ฆฝํ•  ๊ฒฝ์šฐ (n*a, a)๋Š” ์„ฑ๋ฆฝํ•  ์ˆ˜ ์—†์œผ๋ฏ€๋กœ antisymmetric

      - (a, n*a)์ด๊ณ  (n*a, m*na)์ผ ๊ฒฝ์šฐ (a, mna) ์ด๋ฏ€๋กœ transitive

 

 2) Comparable : (x, y) or (y, x)๊ฐ€ R์— ์กด์žฌํ•˜๋ฉด x์™€ y๋Š” comparableํ•˜๋‹ค.

    Incomparable : (x, y)์™€ (y, x)๊ฐ€ ๋‘˜ ๋‹ค R์— ์žˆ์ง€ ์•Š์œผ๋ฉด incomparableํ•˜๋‹ค.

 

3) Total order : X์— ์žˆ๋Š” elements์˜ ๋ชจ๋“  ์Œ์ด comparableํ•˜๋ฉด R์€ total order on X์ด๋‹ค. 

    ์ฆ‰, X์— ์žˆ๋Š” ๋ชจ๋“  ์›์†Œ๊ฐ€ R์— ์กด์žฌํ•  ๊ฒฝ์šฐ R์€ X์˜ total order ์ด๋‹ค. (๋ชจ๋“  (x, y)๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ๋˜, ์ˆœ์„œ ๋ฐ”๊ฟ”์„œ ๊ฒน์น˜๋ฉด ์•ˆ๋œ๋‹ค(antisymmetric ํ•ด์•ผํ•˜๊ธฐ ๋•Œ๋ฌธ))

 

   ex) (x, y) in R ( x ≤ y, x์™€ y๋Š” ์–‘์˜ ์ •์ˆ˜ )

 

- Inverse of a relation

  : ์ฃผ์–ด์ง„ relation R์ด X->Y ์˜€๋‹ค๋ฉด, ๊ทธ๊ฒƒ์˜ inverse์ธ R^(-1)์€ Y-X์ธ relation์ด๋‹ค. 

   R^(-1) = { (y, x) | (x, y)∈R } 

  (๊ทธ๋ƒฅ ์—ญํ•จ์ˆ˜ ์ƒ๊ฐํ•˜๋ฉด ํŽธํ•˜๋‹ค)

 

- Composition of relation

  : R1 : relation from X to Y

   R2 : relation from Y to Z

   R2ºR1 (composition of R1 and R2) : relation from X to Z

  ->  R2ºR1 = { (x, z) | (x, y)∈R1 and (y,z)∈R2 for some y∈Y}

 

2. Equivalence Relations

 - Equivalence relation on X  = R์€ reflexiveํ•˜๊ณ  symmetric ํ•˜๊ณ  transitiveํ•˜๋‹ค

 

ex) X๋ฅผ ์ •์ˆ˜๋ผ๊ณ  ํ•˜๊ณ , R์„ X์— ๋Œ€ํ•œ relation์ด๋ผ๊ณ  ํ•˜์ž. xRy <=> x-y = 5k (k๋Š” ์ •์ˆ˜)

 ==> R is and equivalence relation

{ ..., (10, 5), (11, 6), (5, 5), (6, 11), (5, 10) ,... }

 

  x - y = 5k ๋ฉด y - x = -5k

  x = y ๋ฉด x - y = 0

  x3 - x2 = 5k1, x2 - x1 = 5k2 ๋ฉด x3-x1 = 5(k1-k2)

 

  - Partition S : X๋ฅผ ์ด๋ฃจ๋Š” ๋ถ€๋ถ„์ง‘ํ•ฉ๋“ค์˜ ๋ชจ์ž„ {A1, A2 ,..., An}

    A1∪A2A3∪A4∪...∪An=X

    ๋‹จ, 1<=j, k<=n์ด๊ณ  ์„œ๋กœ ๋‹ค๋ฅธ ๋ชจ๋“  j, k์— ๋Œ€ํ•ด Aj ∩ Ak = ø 

 

    ex) X= {์ •์ˆ˜} , E = {์ง์ˆ˜), O = {ํ™€์ˆ˜} ์ด๋ฉด S = { E, O } ๋Š” X์˜ partition

 

 - Equivalence relation : S๋ฅผ ์ง‘ํ•ฉ X์˜ partition์ด๋ผ๊ณ  ํ•  ๋•Œ, R์„ xRy๋ผ๋Š” relation์œผ๋กœ ์ •์˜ํ•˜์ž. R์—์„œ x, y๊ฐ€ T∈S์ธ T ์ง‘ํ•ฉ์— ์†ํ•  ๋•Œ, R์€ X์— ๋Œ€ํ•ด equivalence relation์ด๋‹ค. 

 

์ด๊ฒŒ ๋Œ€์ฒด ๋ฌด์Šจ ์†Œ๋ฆฐ์ง€ ํ•œ์ฐธ์„ ๋“ค์—ฌ๋‹ค ๋ดค๋Š”๋ฐ, ์˜ˆ๋ฅผ ๋“ค์–ด๋ณด์ž.

X์˜ partial S๊ฐ€ ์žˆ๋‹ค. ์ด S๋Š” A1, A2, A3์˜ ๋ถ€๋ถ„์ง‘ํ•ฉ๋“ค์„ ๊ฐ–๋Š”๋‹ค. ๋งŒ์•ฝ ์–ด๋–ค relation xRy๊ฐ€ A1์ด๋ผ๋Š” T ์ง‘ํ•ฉ์—๋งŒ ์†ํ•œ x, y๋ฅผ ์ „๋ถ€ ํฌํ•จํ•œ relation์ด๋ผ๋ฉด ์ด relation์€ X์˜ equivalence relation์ธ ๊ฒƒ์ด๋‹ค. 

์™œ๋ƒ?

์˜ˆ๋ฅผ ๋“ค์–ด "x-y = 2k"๋ผ๋Š” relation R์ด ์žˆ๋‹ค.

xRy๋Š” ๋งŒ์•ฝ x์™€ y๊ฐ€ ๊ฐ™์€ partition(T= even or odd) ์— ์žˆ์„ ๋•Œ true๊ฐ€ ๋œ๋‹ค. (X์˜ partition S = Integer, S = E + O)

์ด ๋•Œ ์ด R์€ X์˜ equivalence relations ์ด ๋œ๋‹ค. ์ •๋ฆฌํ•˜๋ฉด, ๊ฐ™์€ partition ์•ˆ์˜ ์š”์†Œ๋ผ๋ฆฌ relation์„ ๋งŒ๋“œ๋Š”, ๊ทธ๋ž˜์„œ relation ์•ˆ์— partition์˜ element๊ฐ€ ์ „๋ถ€ ํฌํ•จ๋œ relation์€  equivalence relation์ธ ๊ฒƒ. (์‚ฌ์‹ค ์ดํ•ด ์•ˆํ•˜๊ณ  ์œ„์— reflexive, symmetric, transitive ํŠน์ง• ์“ฐ๋Š”๊ฒŒ ๋” ๋‚˜์„ ๋“ฏ ์‹ถ๋‹ค..)  

 

  - Equivalence classes : ์ง‘ํ•ฉ ๐‘จ ์— ๋Œ€ํ•œ ๊ด€๊ณ„ ๐‘น ์ด ๋™์น˜๊ด€๊ณ„(Equivalence Relation) ์ผ ๋•Œ, ์ง‘ํ•ฉ ๐‘จ ์˜ ๊ฐ ์›์†Œ ๐’‚ ์™€ ์ˆœ์„œ์Œ์„ ์ด๋ฃจ๋Š” ์›์†Œ๋“ค์˜ ์ง‘ํ•ฉ [a]

a, b ∈ X ์ด๋ฉด [a] = [b] ์ด๊ฑฐ๋‚˜ [a] ∩ [b] = ø ์ด๋‹ค. 

ex) Even Integer : [2] = [4] = [10002] 

 

์ด๊ฒƒ๋„ ๋ญ”์†Œ๋ฆฐ๊ฐ€ ํ–ˆ๋”๋‹ˆ, ๊ทธ๋ƒฅ [a]๋ผ๋Š” ๊ฒƒ์ด ์žˆ์œผ๋ฉด, [a]๋Š” a๋ผ๋Š” element๊ฐ€ ์†ํ•œ partition์˜ ์›์†Œ๋“ค์˜ ์ง‘ํ•ฉ, ์ฆ‰ ๊ทธ partition์„ ๋งํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ๊ทธ๋ž˜์„œ [2]=[4]=[10002]๋Š” ์ „๋ถ€ even integer๋ผ๋Š” integer์˜ partition์ด๋ผ๋Š” ๋ง์”€. 

๋งŒ์•ฝ a์™€ b๊ฐ€ ๋‘˜ ๋‹ค X์— ์†ํ•˜๊ฒŒ ๋˜๋ฉด ๋‘˜ ๋‹ค ๊ฐ™์€ partition์— ์†ํ•ด [a]=[b]๊ฐ€ ๋˜๊ฑฐ๋‚˜, ์„œ๋กœ ๋‹ค๋ฅธ partition์— ์†ํ•ด [a]์™€ [b]์˜ ๊ต์ง‘ํ•ฉ์ด ์กด์žฌํ•˜์ง€ ์•Š๊ฒŒ ๋œ๋‹ค. 

 

 

3. Matrices of Relations

 : Relation์„ Matrices๋กœ ํ‘œํ˜„ํ•ด๋ณด์ž!

 - ํ–‰์€ X์˜ elements๋กœ, ์—ด์€ Y์˜ elements๋กœ, Aij = 0 ์ด๋ฉด not related, 1์ด๋ฉด related!

๋ญ ๋Œ€์ถฉ ์ด๋Ÿฐ๊ฑฐ ์‰ฝ์ง€?

 

- The Product of matrices ( ํ–‰๋ ฌ์˜ ๊ณฑ )

 : R1์˜ Matrix A(l x m)๊ณผ R2์˜ Matrix B(mxn)์„ ๊ณฑํ•˜๋ฉด ?

(์„ค๋งˆ ํ–‰๋ ฌ๊ณฑ์„ ์‹œํ‚ค๊ฒ ์–ด?)

  ์ด ๋•Œ, ๊ณฑํ•œ ๊ฐ’์ด 0์ด ์•„๋‹ˆ๋ฉด 1, 0์ด๋ฉด 0์ด๋‹ค. ์ด๊ฑธ ์–ธ์ œ ์“ฐ๋ƒ?

 

-> R2ºR1 (composed relation)์„ ๊ณ„์‚ฐํ•  ๋•Œ ์“ด๋‹ค.

 

 

- Matrix๋กœ ์•Œ์•„๋ณด๋Š” relation์˜ ํŠน์ง•๋“ค

  1) Reflexive : ๋ชจ๋“  Aii์˜ ๊ฐ’์ด 1์ด๋‹ค

  2) Symmetric : ๋ชจ๋“  i, j์— ๋Œ€ํ•ด Aij = Aji ์ด๋‹ค.

  3) Transitive : C = A^2(=AxA)์˜ Cij๊ฐ€ 0์ด ์•„๋‹ˆ๋ฉด, A์˜ aij๋„ 0์ด ์•„๋‹ˆ๋‹ค.

4. Relational Database