이산수학(Discrete Mathematics)
관계와 표현
(Relations and Representation)
2016년 봄학기
강원대학교 컴퓨터과학전공 문양세
강의 내용
Relations and Representation
관계와 속성(Relation and Its Properties)
n-항 관계(n-ary Relations)
관계의 표현(Representing Relations)
Page 2
Discrete Mathematics
by Yang-Sae Moon
Binary Relations (이진 관계)
Relations & Its Properties
Let A, B be any two sets.
A binary relation R from A to B, written R:A↔B, is a subset of
A×B. (A에서 B로의 이진 관계 R은 R:A↔B로 표기하며 A×B의 부분집합이다.)
• E.g., let < : N↔N :≡ {(n,m) | n < m}
The notation a R b or aRb means (a,b)R.
• E.g., a < b means (a,b) <
If aRb, we may say “a is related to b (by relation R).”
(aRb이면, “a는 (관계 R에 의해서) b에 관계된다”고 말한다.)
Page 3
Discrete Mathematics
by Yang-Sae Moon
Complementary Relations (보수 관계)
Relations & Its Properties
Let R:A↔B be any binary relation.
Then, R:A↔B, the complement of R, is the binary relation
defined by
R :≡ {(a,b) | (a,b)R} = (A×B) − R
Note the complement of R is R.
Example: < = {(a,b) | (a,b)<} = {(a,b) | ¬(a<b)} = ≥
Page 4
Discrete Mathematics
by Yang-Sae Moon
Complementary Relation Example
Relations & Its Properties
예제:
A = {0, 1, 2}, B = {a, b}라 하면, {(0,a), (0,b), (1,a), (2,b)}는 A에서 B로
의 관계 R로 표현할 수 있다. 이 때,
• (0,a)R 이므로, 0Ra라 할 수 있다.
• 그러나, (1,b)R 이므로, 1Rb라 할 수 있다.
Page 5
Discrete Mathematics
by Yang-Sae Moon
Inverse Relations (역 관계)
Relations & Its Properties
Any binary relation R:A↔B has an inverse relation R−1:B↔A,
defined by
R−1 :≡ {(b,a) | (a,b)R}.
E.g., if R:People↔Foods is defined by
aRb a eats b, then:
b R−1 a b is eaten by a. (Passive voice.)
(R−1 will be “is eaten by.”)
Page 6
Discrete Mathematics
by Yang-Sae Moon
Relations on a Set
Relations & Its Properties
A (binary) relation from a set A to itself is called a relation
on the set A.
(집합 A에서 A로의 관계를 집합 A상의 관계라 한다.)
E.g., the “<” relation from earlier was defined as a
relation on the set N of natural numbers.
(“<”은 정수 집합 N에 대한 관계이다.)
The identity relation IA on a set A is the set {(a,a)|aA}.
(집합 A에 대한 항등 관계 IA는 집합 {(a,a)|aA}를 의미한다.)
Page 7
Discrete Mathematics
by Yang-Sae Moon
Examples of Relations on a Set (1/2)
Relations & Its Properties
예제:
A = {1, 2, 3, 4}라 할 때, 관계 R = {(a,b)| a divides b}에 속하는 순서쌍은?
• A x A의 원소인 (a,b)에 있어서 b를 a로 나눌 수 있는 순서쌍을 구한다.
• 즉, R = {(1,1), (1,2), (1,3), (1,4), (2,2), (2,4), (3,3), (4,4)}이다.
Page 8
Discrete Mathematics
by Yang-Sae Moon
Examples of Relations on a Set (2/2)
Relations & Its Properties
예제:
n개의 원소를 갖는 집합에는 몇 개의 관계가 있는가?
• 정의에 의해, 집합 A에 대한 관계는 A x A의 부분집합이다.
• A x A의 원소 개수는 n2이다.
• 또한, m개의 원소를 가지는 집합의 부분집합 개수는 2m개 이다.
2
• 그러므로, A x A의 부분집합 개수는 2 n 이 된다.
n2
• 결국, n개 원소를 갖는 집합에 대한 가능한 관계의 수는 2 이다.
Page 9
Discrete Mathematics
by Yang-Sae Moon
Reflexivity (반사성)
Relations & Its Properties
A relation R on A is reflexive if aA, aRa.
• E.g., the relation ≥ :≡ {(a,b) | a≥b} is reflexive.
• 즉, (a,a)를 원소로 가지면 반사적(reflexive)이라고 이야기한다.
A relation is irreflexive iff its complementary relation is
reflexive.
(역관계가 반사이면, 해당 관계는 비반사이다)
• Example: < is irreflexive.
Page 10
Discrete Mathematics
by Yang-Sae Moon
Reflexivity Example
Relations & Its Properties
예제:
양의 정수 집합에 대해 “나누다” 관계는 반사적인가?
• 임의의 양의 정수 a에 대해 a|a가 성립한다.
• 즉, 양의 정수 a는 자기 자신 a로 나누어 떨어진다.
• 따라서, “나누다”는 양의 정수 집합에 대해 반사적이다.
Page 11
Discrete Mathematics
by Yang-Sae Moon
Symmetry & Antisymmetry (대칭성)
Relations & Its Properties
A binary relation R on A is symmetric iff R = R−1, that is, if
(a,b)R ↔ (b,a)R.
• E.g., = (equality) is symmetric. < is not.
• “is married to” is symmetric, but “likes” is not.
• 즉, (a,b)가 R의 원소일 때, 반드시 (b,a)도 원소이면 대칭적이라 한다.
A binary relation R is antisymmetric if (a,b)R → (b,a)R.
• < is antisymmetric, “likes” is also antisymmetric.
Page 12
Discrete Mathematics
by Yang-Sae Moon
Symmetry & Antisymmetry Example
Relations & Its Properties
예제:
양의 정수 집합에 대한 “나누다” 관계는 대칭인가? 반대칭인가?
• 반례(counterexample)를 들어 반대칭임을 보인다.
• 즉, 1|2 이지만 2|1이므로, 반대칭이다.
Page 13
Discrete Mathematics
by Yang-Sae Moon
Transitivity (전이성)
Relations & Its Properties
A relation R is transitive iff (for all a,b,c)
(a,b)R (b,c)R → (a,c)R.
A relation is intransitive if it is not transitive.
Examples: “is an ancestor of” is transitive.
“likes” is intransitive.
Page 14
Discrete Mathematics
by Yang-Sae Moon
Transitivity Example
Relations & Its Properties
예제:
양의 정수 집합에 대한 “나누다” 관계가 전이적인가?
• 양의 정수 a, b, c에 대해서, a가 b를 나누고, b가 c를 나눈다고 하자.
• 즉, a|b, b|c가 성립한다고 가정하자.
• 그러면, b = ak, c = bl인 양의 정수 k와 l이 있다.
• 따라서, c = a(kl)이 성립하므로, a는 c를 나눌 수 있다.
• 즉, a|c가 성립하므로, “나누다”는 전이적이다.
Page 15
Discrete Mathematics
by Yang-Sae Moon
Composite Relations (관계 합성/결합)
Relations & Its Properties
Let R:A↔B, and S:B↔C. Then the composite SR of R and
S is defined as:
SR = {(a,c) | b: aRb bSc}
((a,b)R이고 (b,c)S이면, SR은 (a,c)을 원소로 하는 관계이다.)
Note function composition fg is an example.
The nth power Rn of a relation R on a set A (A에 대한 관계 R의
n 제곱) can be defined recursively by:
R0 :≡ IA ;
Rn+1 :≡ RnR
Page 16
for all n≥0.
Discrete Mathematics
by Yang-Sae Moon
Examples of Composite Relations (1/2)
Relations & Its Properties
예제:
{1, 2, 3}에서 {1, 2, 3, 4}로의 관계 R = {(1,1), (1,4), (2,3), (3,1), (3,4)}
과, {1, 2, 3, 4}에서 {0, 1, 2}로의 관계 S = {(1,0), (2,0), (3,1), (3,2),
(4,1)}가 있을 때, R과 S의 합성 SR 은?
• SR의 구성을 위해서는, R에 속한 순서쌍의 두 번째 원소와 S에 속한
순서쌍의 첫 번째 원소가 같은 것을 찾으면 된다.
• 예를 들어, R의 (2,3)과 S의 (3,1)을 바탕으로 SR의 순서쌍 (2,1)을 만
든다.
• 결국, SR = {(1,0), (1,1), (2,1), (2,2), (3,0), (3,1)}이 된다.
Page 17
Discrete Mathematics
by Yang-Sae Moon
Examples of Composite Relations (2/2)
Relations & Its Properties
예제:
R = {(1,1), (2,1), (3,2), (4,3)}이라 하자. n = 2, 3, 4, … 일 때, 거듭 제곱
Rn을 구하라.
• R2 = RR = {(1,1), (2,1), (3,1), (4,2)}
• R3 = R2R = {(1,1), (2,1), (3,1), (4,1)}
• R4 = R3R = {(1,1), (2,1), (3,1), (4,1)}
• …
• Rn = Rn-1R = {(1,1), (2,1), (3,1), (4,1)}
You can get Rn using “induction.”
Page 18
Discrete Mathematics
by Yang-Sae Moon
강의 내용
Relations and Representation
관계와 속성(Relation and Its Properties)
n-항 관계(n-ary Relations)
관계의 표현(Representing Relations)
Page 19
Discrete Mathematics
by Yang-Sae Moon
n-ary Relations (n-항 관계)
n-ary Relations
An n-ary relation R on sets A1,…,An, written R:A1,…,An, is a
subset R A1× … × An.
(A1,…,An에 대한 n-항 관계 R은 A1× … × An의 부분집합이다.)
The sets Ai are called the domains of R.
(Ai를 R의 정의역이라 한다.)
The degree of R is n.
(관계 R의 차수는 n이다.)
Page 20
Discrete Mathematics
by Yang-Sae Moon
Relational Databases (관계형 DB)
n-ary Relations
A relational database is essentially an n-ary relation R.
(관계형 데이터베이스란 n-항 관계 R을 의미한다.)
A domain Ai is a primary key for the database if the
relation R contains at most one n-tuple (…, ai, …) for any
value ai within Ai.
(만일 R이 (정의역 Ai에 포함된) ai에 대해서 기껏해야 하나의 n-항 튜플 (…, ai, …)
를 포함하면, Ai는 기본 키라 한다.)
(다시 말해서, ai 값을 가지는 n-항 튜플이 유일하면 Ai를 키본 키라 한다.)
A composite key for the database is a set of domains {Ai, Aj,
…} such that R contains at most 1 n-tuple (…,ai,…,aj,…) for
each composite value (ai, aj,…)Ai×Aj×…
Page 21
Discrete Mathematics
by Yang-Sae Moon
Primary Key 예제
n-ary Relations
예제: (새로운 튜플이 추가되지 않는다고 할 때,) 다음 테이블에서 어떤
정의역이 기본 키인가?
Student_name
ID_number
Major
GPA
Ackermann
231455
Computer Science
3.88
Adams
888323
Physics
3.45
Chou
102147
Computer Science
3.49
Goodfriend
453876
Mathematics
3.45
Rao
678543
Mathematics
3.90
Stevens
786576
Psychology
2.99
• Student_name은 키본 키이다. (유일하게 구분 짓는다.)
• 마찬가지로, ID_number 또한 기본 키이다.
• 반면에, Major나 GPA는 기본 키가 아니다.
Page 22
Discrete Mathematics
by Yang-Sae Moon
Composite Key 예제
n-ary Relations
예제: (새로운 튜플이 추가되지 않는다고 할 때,) 다음 테이블에서 {Major,
GPA}는 합성 키인가?
Student_name
ID_number
Major
GPA
Ackermann
231455
Computer Science
3.88
Adams
888323
Physics
3.45
Chou
102147
Computer Science
3.49
Goodfriend
453876
Mathematics
3.45
Rao
678543
Mathematics
3.90
Stevens
786576
Psychology
2.99
•Major와 GPA를 조합하여 사용하면 튜플을 유일하게 구분 지을
수 있으므로, {Major, GPA}는 상기 테이블의 합성 키이다.
Page 23
Discrete Mathematics
by Yang-Sae Moon
Selection Operator ()
n-ary Relations
Let A be any n-ary domain A=A1×…×An, and let P:A→{T,F}
be any predicate on elements of A.
(A를 n-항 관계의 정의역이라 하고, P를 A에서 {T,F}로의 술어라 하자.)
Then, the selection operator p is the operator that maps
any (n-ary) relation R on A to the n-ary relation of all ntuples from R that satisfy P.
(셀렉션 연산자 p 은 관계 R의 n-튜플 중에서 술어 P를 만족하는 튜플들의 관계
로 정의한다.)
• I.e., RA, p(R) = R{aA | P(a) = T}
Page 24
Discrete Mathematics
by Yang-Sae Moon
Selection Example
n-ary Relations
Suppose we have a domain
A = StudentName × Level × SocSecNos
Suppose we define a certain predicate on A,
UpperLevel(name, level, ssn) :≡
[(level = junior) (level = senior)]
Then, UpperLevel is the selection operator that takes any
relation R on A (database of students) and produces a
relation consisting of just the upper-level classes (juniors
and seniors).
Student_name
That is, (level = junior) (level = senior)(R)
Page 25
ID_number
Major
GPA
Computer Science
3.88
888323
Physics
3.45
Chou
102147
Computer Science
3.49
Goodfriend
453876
Mathematics
3.45
Rao
678543
Mathematics
3.90
Stevens
786576
Psychology
2.99
Ackermann
231455
Adams
Discrete Mathematics
by Yang-Sae Moon
Projection Operator ()
n-ary Relations
Let A = A1×…×An be any n-ary domain, and let {ik}=(i1,…,im)
be a sequence of indexes,
• That is, where 1 ≤ ik ≤ n for all 1 ≤ k ≤ m.
Then the projection operator on n-tuples
{ ik } : A Ai1
Aim
is defined by:
Student_name
ID_number
Major
GPA
Ackermann
231455
Computer Science
3.88
Adams
888323
Physics
3.45
Chou
102147
Computer Science
3.49
Goodfriend
453876
Mathematics
3.45
Rao
678543
Mathematics
3.90
Stevens
786576
Psychology
2.99
{ ik } ( a1 ,..., an ) ( ai1 ,..., aim )
Page 26
Discrete Mathematics
by Yang-Sae Moon
Projection Example
n-ary Relations
Suppose we have a ternary (3-ary) domain
Cars = Model×Year×Color. (note n=3).
Consider the index sequence {ik}= 1,3. (m=2)
Then the projection simply maps each tuple (a1,a2,a3) =
(model,year,color) to its image:
(ai1 , ai2 ) (a1 , a3 ) (model, color )
Student_name
Page 27
ID_number
Major
GPA
Computer Science
3.88
888323
Physics
3.45
102147
Computer Science
3.49
Goodfriend
453876
Mathematics
3.45
Rao
678543
Mathematics
3.90
Stevens
786576
Psychology
2.99
Ackermann
231455
Adams
Chou
Discrete Mathematics
by Yang-Sae Moon
(Natural) Join Operator (
)
n-ary Relations
Puts two relations together to form a sort of combined
relation.
(관계를 합성하는 한 가지 방법)
If the tuple (A,B) appears in R1, and the tuple (B,C)
appears in R2, then the tuple (A,B,C) appears in the join
R1
R2.
• A, B, C can also be sequences of elements rather than single
elements.
Page 28
Discrete Mathematics
by Yang-Sae Moon
(Natural) Join Example
n-ary Relations
Suppose R1 is a teaching assignment table, relating
Professors to Courses.
((Professor, Courses)로 구성된 관계)
Suppose R2 is a room assignment table relating Courses to
Rooms,Times.
Then R1
((Courses, Rooms, Times)로 구성된 관계)
R2 is like your class schedule, listing
(professor,course,room,time).
Page 29
Discrete Mathematics
by Yang-Sae Moon
강의 내용
Relations and Representation
관계와 속성(Relation and Its Properties)
n-항 관계(n-ary Relations)
관계의 표현(Representing Relations)
Page 30
Discrete Mathematics
by Yang-Sae Moon
Representing Relations
Representing Relations
Some ways to represent n-ary relations:
• With an explicit list or table of its tuples.
• With a function,
or with an algorithm for computing this function.
Some special ways to represent binary relations:
• With a zero-one matrix.
• With a directed graph.
Page 31
Discrete Mathematics
by Yang-Sae Moon
Using Zero-One Matrices
Representing Relations
To represent a relation R by a matrix
MR = [mij], let mij = 1 if (ai,bj)R, else 0.
E.g., Joe likes Susan and Mary, Fred likes Mary, and Mark
likes Sally.
The 0-1 matrix
representation
of that “Likes”
relation:
Susan
Joe 1
Fred 0
Mark 0
Page 32
Mary Sally
1
0
1
0
0
1
Discrete Mathematics
by Yang-Sae Moon
Zero-One Reflexive, Symmetric (1/2)
Representing Relations
Terms: Reflexive, irreflexive, symmetric, and
antisymmetric.
• These relation characteristics are very easy to recognize by
inspection of the zero-one matrix.
1
any-
thing
1
any- 1
thing
1
Reflexive:
all 1’s on diagonal
0
any-
thing
0
0
any
thing
0
Irreflexive:
all 0’s on diagonal
Page 33
Discrete Mathematics
by Yang-Sae Moon
Zero-One Reflexive, Symmetric (2/2)
1
1
0
Representing Relations
0
1
0 1
0
0
0
Symmetric:
all identical
across diagonal
Antisymmetric:
all 1’s are across
from 0’s
Page 34
Discrete Mathematics
by Yang-Sae Moon
Using Directed Graphs (1/2)
Representing Relations
A directed graph or digraph G=(VG,EG) is a set VG of
vertices (nodes) with a set EGVG×VG of edges (arcs,links).
(관계는 노드(꼭지점)의 집합 V와 에지(링크)의 집합 E로 표현되는 방향성 그래
프로 나타낼 수 있다.)
Visually represented using dots for nodes, and arrows for
edges. Notice that a relation R:A↔B can be represented
as a graph GR=(VG=AB, EG=R).
(일반적으로, 노드는 점으로, 에지는 화살표로 표현한다.)
Page 35
Discrete Mathematics
by Yang-Sae Moon
Using Directed Graphs (2/2)
MR
Susan
Joe 1
Fred 0
Mark 0
Representing Relations
GR
Mary Sally
1
0
1
0
0
1
Edge set EG
(blue arrows)
Joe
Fred
Mark
Susan
Mary
Sally
Node set VG
(black dots)
Page 36
Discrete Mathematics
by Yang-Sae Moon
Digraph Reflexive, Symmetric
Representing Relations
It is extremely easy to recognize the reflexive/irreflexive/
symmetric/antisymmetric properties by graph inspection.
Reflexive:
Irreflexive:
Every node
No node
has a self-loop links to itself
Symmetric: Antisymmetric:
Every link is
No link is
bidirectional bidirectional
Asymmetric, non-antisymmetric
Non-reflexive, non-irreflexive
Page 37
Discrete Mathematics
by Yang-Sae Moon
강의 내용
Relations and Representation
관계와 속성(Relation and Its Properties)
n-항 관계(n-ary Relations)
관계의 표현(Representing Relations)
Page 38
Discrete Mathematics
by Yang-Sae Moon
Homework #7
Representing Relations
Page 39
Discrete Mathematics
by Yang-Sae Moon
© Copyright 2026 Paperzz