Upcoming SlideShare
×

# Ch1 sets and_logic(1)

1,241 views
1,084 views

Published on

Published in: Education
2 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
1,241
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
67
0
Likes
2
Embeds 0
No embeds

No notes for slide

### Ch1 sets and_logic(1)

1. 1. Chapter 1 Sets and Logic 2008 학년도 2 학기 고려대학교 과학기술대학 컴퓨터 정보학과
2. 2. 1.1 Sets <ul><li>Set </li></ul><ul><ul><li>a collection of distinct unordered objects </li></ul></ul><ul><ul><li>members of a set are called elements </li></ul></ul><ul><ul><li>notation </li></ul></ul><ul><ul><ul><li>{ }, Φ </li></ul></ul></ul><ul><ul><ul><li>S = { a 1 , a 2 , a 3 , …, a n }, a 1 ∈ S </li></ul></ul></ul><ul><ul><ul><li>{ x ∈ R | － 2 < x < 5 } </li></ul></ul></ul><ul><ul><ul><li>{ { a 1 , a 2 }, { b 1 , b 2 , b 3 } } </li></ul></ul></ul><ul><ul><li>x ∈ R </li></ul></ul><ul><ul><li>x R </li></ul></ul><ul><ul><li>R + : set of positive real numbers </li></ul></ul><ul><ul><li>Z nonneg : set of natural numbers </li></ul></ul>Symbol Set R Set of all REAL numbers Z Set of all INTEGERs Q Set of all RATIONAL numbers superscript indicate ＋ Positive － Negative nonneg nonnegative
3. 3. <ul><li>Cardinality </li></ul><ul><ul><li>|X| = number of elements in the set </li></ul></ul><ul><li>Example 1.1.1 </li></ul><ul><li>Empty Set (or Null Set) </li></ul><ul><ul><li>Only one set with no elements. </li></ul></ul><ul><ul><li>{ },  </li></ul></ul><ul><ul><li>The empty set is a subset of every set. </li></ul></ul>Cardinality &Empty Set A = {1, 2, 3, 4} , |A| = ? |{R, Z}| = ?
4. 4. <ul><li>Equal </li></ul><ul><li>Example 1.1.2 </li></ul><ul><li>Example 1.1.3 </li></ul>Equal Two sets X and Y are equal if X and Y have the same elements. X = Y if for every x , if x ∈ X, then x ∈ Y and for every y , if y ∈ Y, then y ∈ X A = {1, 3, 2}, B = {2, 3, 2, 1}. A = B ? Let us prove that if A = { x | x 2 + x – 6 = 0 } and B = {2, -3} Then A = B .
5. 5. Subset <ul><li>Subset </li></ul>If A and B are sets, then A is called a subset of B , written A⊆ B , If, and only if, every element of A is also an element of B . Symbolically : A ⊆ B ⇔ ∀ x , if x ∈ A then x ∈ B. The phrases A is contained in B and B contains A are alternative ways of saying that A is a subset of B. A set A is not a subset of a set B , written A ⊆ B, if, and only if, there is at least one element of A that is not an element of B . Symbolically : <ul><ul><li>A ⊆ B ⇔ ∃ x , x ∈ A and x ∈ B . </li></ul></ul>
6. 6. <ul><li>Example 1.1.5 </li></ul><ul><li>Example 1.1.7 </li></ul><ul><li>Example 1.1.9 </li></ul>Subset Z ⊆ Q ? Let X = { x | 3 x 2 – x – 2 = 0 }. X ⊆ Z ? C = {1, 3}, B = {1, 2, 3, 4}. C ⊆ A ?
7. 7. Proper Subset <ul><li>Proper subset </li></ul><ul><li>Venn Diagrams </li></ul><ul><ul><li>If sets A and B are represented as regions in the plane, relationships between A and B can be presented by pictures . </li></ul></ul>Let A and B be sets. A is a proper subset of B , if, and only if, every element of A is in B but there is at least one element of B that is not A . A B A = B A B A B B A A B A = B A ⊆ B A ⊆ B A⊂ B
8. 8. Power Set <ul><li>Power set </li></ul><ul><li>Example 1.1.13 </li></ul>Given a set A , the power set of A , denoted P(A), is set of all subsets of A Find the power set of the set A ={ a, b, c }. That is, find P ( A) . P ( A ) = <ul><li>The Number of Subsets of a Set </li></ul>For all integers n ≥ 0, if a set X has n elements, then P(X ) has 2 n elements
9. 9. Set Operations <ul><li>Set Operations </li></ul><ul><li>Let A and B be subset of a universal set U . </li></ul><ul><li>Union : X ∪ Y = { x | x ∈ X or x ∈ Y } </li></ul><ul><li>intersection : X ∩ Y = { x | x ∈ X and x ∈ Y } </li></ul><ul><li>Difference : X – Y = { x | x ∈ X and x  Y } </li></ul><ul><li>Complement : X c = { x | x  A } </li></ul><ul><li>Example 1.1.15 </li></ul>A ={1, 3, 5}, B = {4, 5, 6} A ∪ B = A ∩ B = A – B = B – A = Since Q ⊆ R, R ∪ Q = R ∩ Q = R – Q = Q – R = <ul><li>Example 1.1.14 </li></ul>
10. 10. Disjoint <ul><li>Disjoint </li></ul><ul><li>Example 1.1.14 </li></ul>Two sets are called disjoint if, and only if, they have no elements in common. Symbolically : A and B are disjoint ⇔ A ∩ B = Φ - {1, 4, 5} and {2, 6} - S = {{1, 4, 5,}, {2, 6}, {3}, {7, 8}}
11. 11. Set Operations <ul><li>Example 1.1.20 </li></ul><ul><li>Total students: 165 </li></ul><ul><li>Taking CALC, PSYCH and COMPSCI: 8 </li></ul><ul><li>Taking CALC and COMPSCI: 33 </li></ul><ul><li>Taking CALC and PSYCH : 20 </li></ul><ul><li>Taking PSYCH and COMPSCI: 24 </li></ul><ul><li>Taking CALC: 79 </li></ul><ul><li>Taking PSYCH : 83 </li></ul><ul><li>Taking COMPSCI: 63 </li></ul><ul><li>How many are taking none of the three subjects? </li></ul>
12. 12. Set Identity <ul><li>Theorem 1.1.21 </li></ul><ul><li>Let U be a universal set and let A, B, and C be subsets of U. The following properties hold </li></ul><ul><ul><li>a) Associative laws : </li></ul></ul><ul><ul><li>(A∪B)∪C = A∪(B∪C) and (A ∩ B) ∩ C = A ∩ (B ∩ C) </li></ul></ul><ul><ul><li>b) Commutative laws : </li></ul></ul><ul><ul><li>A∪B = B∪A and A ∩ B = B ∩ A </li></ul></ul><ul><ul><li>c) Distributive laws : </li></ul></ul><ul><ul><li> A∪(B ∩ C) = (A∪B) ∩ (A∪C) </li></ul></ul><ul><ul><li>A ∩ (B ∪C) = (A ∩B) ∪ (A ∩ C) </li></ul></ul><ul><ul><li>d) Identity laws : </li></ul></ul><ul><ul><li>A∪ Φ = A and A ∩ U = A </li></ul></ul><ul><li>e) Complement laws : </li></ul><ul><ul><li>A∪A c = U and A ∩ A c = Φ </li></ul></ul><ul><li> f) Idempotent laws : </li></ul><ul><li>A∪A = A and A ∩ A = A </li></ul>
13. 13. Set Identity <ul><li>g) Bound laws : </li></ul><ul><li> A∪U = U and A ∩ Φ = Φ </li></ul><ul><li>h) Absorption Laws : </li></ul><ul><li> A∪(A∩B) = A and A ∩ (A∪B) = A </li></ul><ul><li>i) Involution law (double negation laws) : </li></ul><ul><li>(A c ) c = A </li></ul><ul><li>j) 0/1 laws: </li></ul><ul><ul><li>U c = Φ and Φ c = U . </li></ul></ul><ul><li>k) DeMorgan’s Laws : </li></ul><ul><li>(A∪B) c = A c ∩ B c and (A∩B) c = A c ∪B c </li></ul>
14. 14. <ul><li>Union & intersection of a family S of sets </li></ul><ul><ul><li>if S = { A 1 , A 2 , …, A n }, </li></ul></ul><ul><ul><li>If S = { A 1 , A 2 ,… }, </li></ul></ul><ul><li>Example 1.1.22 </li></ul>For i ≥ 1, define A i = { i, i+1 , … } and S = { A 1 , A 2 , …, A n }. Then, and ?
15. 15. Partition of sets <ul><li>Mutually disjoint </li></ul><ul><li>Partition </li></ul><ul><ul><li>A partition of a set A divides A into nonoverlapping subsets. </li></ul></ul>Sets A 1 , A 2 , A 3 , …, A n are mutually disjoint if, and only if, no two sets A i and A j with distinct subscripts have any elements in common. More precisely, for all i, j = 1, 2, 3, …, n, A i ∩ A j = Φ whenever i ≠ j <ul><li>A collection of nonempty sets { A 1 , A 2 , A 3 , …, A n } is a partition of a set A if, and only if, </li></ul><ul><ul><li>A = A 1 ∪ A 2 ∪ A 3 , …, ∪ A n </li></ul></ul><ul><ul><li>A 1 , A 2 , A 3 , …, A n are mutually disjoint. </li></ul></ul>A 1 A 2 A 3 … A n
16. 16. Cartesian product <ul><li>Definition </li></ul><ul><li>Example </li></ul><ul><li>Is ( 1, 2 ) = ( 2, 1 )? </li></ul><ul><li>Is ( 3, ( － 2 ) 2 , 1/2 ) = ( , 4, 3/6 )? </li></ul>Let n be a positive integer and let x 1 , x 2 , x 3 , … x n be elements. The ordered n-tuple , ( x 1 , x 2 , x 3 , … x n ), consists of x 1 , x 2 , x 3 , …, x n together with the ordering. An ordered 2-tuple is called an ordered pair ; and an ordered 3-tuples is called an ordered triple . Two ordered n-tuples ( x 1 , x 2 , x 3 , …, x n ) and ( y 1 , y 2 , y 3 , …, y n ) are equal if, and only if, x 1 = y 1 , x 2 = y 2 , x 3 = y 3 , …, x n = y n . Symbolically : ( x 1 , x 2 , x 3 , …, x n ) = ( y 1 , y 2 , y 3 , …, y n ) ⇔ x 1 = y 1 , x 2 = y 2 , x 3 = y 3 , …, x n = y n
17. 17. Cartesian product <ul><li>Definition </li></ul><ul><li>Example 1.1.24 </li></ul><ul><li>Let X = { 1, 2, 3 }, and Y = { a, b }. </li></ul><ul><ul><li>Find X × Y </li></ul></ul><ul><ul><li>Find Y × X </li></ul></ul><ul><ul><li>Find X × X </li></ul></ul><ul><ul><li>Find Y × Y </li></ul></ul>Given two sets A and B , the Cartesian Product of A and B , denote A × B ( read “ A cross B ” ), is the set of all ordered pairs ( a, b ), where a is in A and b is in B . Given A 1 × A 2 × A 3 , …, × A n , is the set of all ordered n-tuples ( a 1 , a 2 , a 3 , …, a n ) where a 1 ∈ A 1 , a 2 ∈ A 2 , a 3 ∈ A 3 , …, a n ∈ A n . Symbolically : A × B = { ( a, b ) | a ∈ A and b ∈ B }, A 1 × A 2 × A 3 ×… × A n = { ( a 1 , a 2 , a 3 , …, a n ) | a 1 ∈ A 1 , a 2 ∈ A 2 , a 3 ∈ A 3 , …, a n ∈ A n }.
18. 18. Logic <ul><li>Logic = the study of correct reasoning </li></ul><ul><li>Use of logic </li></ul><ul><ul><li>In mathematics: to prove theorems </li></ul></ul><ul><ul><li>In computer science: to prove that programs do what they are supposed to do </li></ul></ul>
19. 19. 1.2 Propositions <ul><li>Definition </li></ul><ul><li>Examples: </li></ul><ul><ul><li>The only positive integers that divide 7 are 1 and 7 itself. </li></ul></ul><ul><ul><li>Alfred Hitchcock won an Academy Award in 1940 for directing “Rebecca”. </li></ul></ul><ul><ul><li>For every positive integer n , there is a prime number larger than n . </li></ul></ul><ul><ul><li>Earth is the only planet in the universe that contains life. </li></ul></ul><ul><ul><li>Buy two tickets to the “Unhinged Universe” rock concert for Friday. </li></ul></ul><ul><ul><li>x + 4 = 6 </li></ul></ul>A proposition ( 명제 ) is a statement or sentence that can be determined to be either true or false but not both
20. 20. <ul><li>More examples </li></ul><ul><ul><li>3 + 6 = 8 </li></ul></ul><ul><ul><li>대한민국의 수도는 서울이다 </li></ul></ul><ul><ul><li>물은 수소와 산소로 이루어져 있다 </li></ul></ul><ul><ul><li>3 × 4 > 12 </li></ul></ul><ul><ul><li>다음주 이산구조 수업은 휴강이다 . </li></ul></ul><ul><ul><li>X + Y > 0 </li></ul></ul><ul><ul><li>컴퓨터의 가격은 비싸다 . </li></ul></ul><ul><ul><li>세종 대왕은 이순신 장군보다 훌륭하다 . </li></ul></ul>Propositions
21. 21. Connectives <ul><li>If p and q are propositions, new compound propositions can be formed by using connectives </li></ul><ul><li>Most common connectives: </li></ul><ul><ul><li>Conjunction (AND) Symbol ^ </li></ul></ul><ul><ul><li>(Inclusive) disjunction (OR) Symbol v </li></ul></ul><ul><ul><li>Exclusive disjunction (XOR) Symbol  </li></ul></ul><ul><ul><li>Negation Symbol  </li></ul></ul><ul><ul><li>Implication Symbol  </li></ul></ul><ul><ul><li>Double implication Symbol  </li></ul></ul>
22. 22. Conjunction(  ) <ul><li>Definition 1.2.3 Truth table of conjunction </li></ul><ul><li>Example 1.2.2 </li></ul>If p : It is raining q : It is cold then what is the conjunction of p and q ? p q p  q T T T T F F F T F F F F
23. 23. <ul><li>Example 1.2.4 </li></ul><ul><li>Example 1.2.5 </li></ul>If p : A decade is 10 years q : A millennium is 100 years then what is the conjunction of p and q ? Is it true or false? x < 10 && y > 4
24. 24. Disjunction(  ) <ul><li>Definition 1.1.6 The truth table of (inclusive) disjunction </li></ul><ul><li>Example 1.2.7 </li></ul><ul><li>Example 1.2.8 </li></ul>If p : A millennium is 100 years q: A millennium is 1000 years then what is the disjunction of p and q ? Is it true or false? x < 10 || y > 4 p q p v q T T T T F T F T T F F F
25. 25. Exclusive OR <ul><li>Truth Table of Exclusive OR : </li></ul><ul><li>( p ∨ q ) ∧ ~ ( p ∧ q ) </li></ul>p q p ∨ q p ∧ q ~(p ∧ q) ( p ∨ q ) ∧ ~ ( p ∧ q ) T T T T F F T F T F T T F T T F T T F F F F T F
26. 26. Logical connectives in C programs [Ex] int i, j; i = 2 && ( j = 2 ); printf(“%d %dn”, i, j); /* 1 2 is printed */ ( i = 0 ) && ( j = 3 ); printf(“%d %dn”, i, j); /* 0 2 is printed */ i = 0 || ( j = 4 ); printf(“%d %dn”, i, j); /* 1 4 is printed */ ( i = 2 ) || ( j = 5 ); printf(“%d %dn”, i, j); /* 2 4 is printed */
27. 27. Negation(  ) <ul><li>Definition 1.1.9 Negation of p (  p ): </li></ul><ul><li>Example </li></ul><ul><ul><li>p : Paris is the capital of England </li></ul></ul><ul><ul><li> p : It is not the case that Paris is the capital of England </li></ul></ul><ul><ul><li> p : Paris is not the capital of England </li></ul></ul><ul><li>Example 1.2.11 </li></ul> ! ( x < 10) p  p T F F T
28. 28. More compound statements <ul><li>Example: ( p ∧ q ) ∨  r </li></ul><ul><li>Precedence of logical operations </li></ul><ul><ul><li>first evaluate  , then  , and then  . </li></ul></ul>p q r p ∧ q  r ( p ∧ q ) ∨  r T T T T F T T T F T T T T F T F F F T F F F T T F T T F F F F T F F T T F F T F F F F F F F T T
29. 29. 1.3 Conditional propositions and logical equivalence <ul><li>Definition 1.3.1 conditional proposition </li></ul><ul><ul><li>임의의 명제 p, q 의 조건 연산자는 p -> q 로 표기 </li></ul></ul><ul><ul><ul><li>p is called the hypothesis ( 가정 , 전제조건 ) </li></ul></ul></ul><ul><ul><ul><li>q is called the conclusion( 결론 , 결과 ) </li></ul></ul></ul><ul><ul><li>p -> q </li></ul></ul><ul><ul><ul><li>p is sufficient for q </li></ul></ul></ul><ul><ul><ul><li>q is necessary for p </li></ul></ul></ul><ul><ul><ul><li>P implies q </li></ul></ul></ul><ul><li>Example: </li></ul><ul><ul><li>p : The Mathematics Department gets an additional \$40,000 </li></ul></ul><ul><ul><li>q : The mathematics Department will hire one new faculty member </li></ul></ul><ul><ul><li>p  q : If The Mathematics Department gets an additional \$40,000, then it will hire one new faculty member. </li></ul></ul>
30. 30. Implication(  ) <ul><li>Definition 1.3.3 Truth table of conditional proposition </li></ul>p  q is true when both p and q are true or when p is false true by default or vacuously true p q p  q T T T T F F F T T F F T
31. 31. <ul><li>Example 1.3.5 </li></ul><ul><ul><li>Assume p: true, q: false, and r is true </li></ul></ul><ul><ul><li>p  q -> r </li></ul></ul><ul><ul><li>p  q ->  r </li></ul></ul><ul><ul><li>p  (q -> r) </li></ul></ul><ul><ul><li>p ->(q -> r) </li></ul></ul><ul><li>Example 1.3.6 Restate each proposition in the form if p then q </li></ul><ul><ul><li>Mary will be a good student if she studies hard. </li></ul></ul><ul><ul><li>John takes calculus only if he has sophomore, junior, or senior standing. </li></ul></ul>Implication <ul><ul><li>If &quot;p then q&quot; is considered logically the same as &quot;p only if q&quot; </li></ul></ul>
32. 32. Implication <ul><ul><li>When you sing, my ears hurt. </li></ul></ul><ul><ul><li>A necessary condition for the Cubs to win the World Series is that they sign a right-handed relief pitcher. </li></ul></ul><ul><ul><li>A sufficient condition for Maria to visit France is that she goes to the Eiffel Tower </li></ul></ul>A necessary condition is expressed by the conclusion. A sufficient condition is expressed by the hypothesis.
33. 33. Double Implication(  ) <ul><li>Definition 1.3.8 </li></ul><ul><ul><li>p ↔ q ≡ ( p -> q )∧( q -> p ) </li></ul></ul><ul><ul><li>Truth Table for p ↔ q </li></ul></ul><ul><li>The biconditional of p and q ( p ↔ q ) </li></ul><ul><ul><li>p if and only if q </li></ul></ul><ul><ul><li>p is necessary and sufficient for q </li></ul></ul>p q p -> q q -> p ( p -> q )∧( q -> p ) p ↔ q T T T T T T T F F T F F F T T F F F F F T T T T
34. 34. Logical Equivalence <ul><li>Definition 1.3.10 Logical Equivalence </li></ul><ul><li>Example 1.3.11 De Morgan’s Laws for Logic </li></ul><ul><li>Example 1.3.12 </li></ul><ul><ul><li>x < 10 || x > 20 </li></ul></ul><ul><ul><li>각각의 다른 합성 명제 ( 또는 단순 명제 ) 가 동일한 진리표를 가진다면 , 이 두 개의 명제는 논리적 동치라고 한다 . </li></ul></ul><ul><ul><li>명제 P 와 Q 가 논리적 동치라면 , P ≡ Q 표기 </li></ul></ul><ul><ul><li> ( p ∧ q ) ≡  p ∨  q </li></ul></ul><ul><ul><li> ( p ∨ q ) ≡  p ∧  q </li></ul></ul>
35. 35. Logical Equivalence <ul><li>p -> q ≡ ~ p ∨ q </li></ul>Rewrite the following statement in if-then form Either you get to work on time or you are fired. <ul><li>Example </li></ul>p q p -> q ~p ~p ∨ q T T T F T T F F F F F T T T T F F T T T
36. 36. Logical Equivalence <ul><li>Negation of -> : ~ (p -> q) ≡ p ∧ ~q </li></ul><ul><ul><li>~ (p -> q) ≡ ~ ( ~ p ∨ q ) </li></ul></ul><ul><ul><li>≡ ~ ( ~ p ) ∧ ~q ☞ 드모르간 법칙에 의해 </li></ul></ul><ul><ul><li>≡ p ∧ ~q ☞ 이중 부정 법칙에 의해 </li></ul></ul><ul><li>The Negation of “ if p then q ” is locally equivalent to “ p and not q ”. </li></ul>If Jerry receives a scholarship, then he goes to college <ul><li>Example 1.3.14 Negation of If-Then Statement </li></ul><ul><li>If my car is in the repair shop, then I cannot get to class </li></ul><ul><li>If Sara lives in Athens, then she lives in Greece </li></ul><ul><li>More Example </li></ul>
37. 37. Contrapositive <ul><li>Definition 1.3.16 </li></ul>The contrapositive( 대우 ) of p -> q is ~ q -> ~ p If the network is down, then Dale cannot access the Internet <ul><li>Example 1.3.17 Writing the Contrapositive </li></ul>The conditional statement and its contrapositive are logically equivalent <ul><li>Theorem 1.3.18 </li></ul>p q p -> q ~q ~p ~q -> ~p T T T F F T T F F T F F F T T F T T F F T T T T
38. 38. Converse & Inverse <ul><li>Definition </li></ul><ul><ul><li>Conditional statement and its converse are not equivalent </li></ul></ul><ul><ul><li>Conditional statement and its inverse are not equivalent </li></ul></ul><ul><ul><li>The converse and the inverse of a conditional statement are logically equivalent to each other </li></ul></ul>The converse( 역 ) of p -> q is q -> p The inverse( 이 ) of p -> q is ~ p -> ~ q p q p -> q q -> p ~p ~q ~p -> ~q T T T T F F T T F F T F T T F T T F T F F F F T T T T T
39. 39. Tautology & Contradiction 합성 명제의 진리값이 항상 T 인 명제 , 즉 , 합성명제를 구성하고 있는 단순명제들의 진리값에 상관없이 항상 T 의 진리값을 가진 명제 합성명제의 진리값이 항상 F 인 명제 , 즉 , 합성명제를 구성하고 있는 단순명제들의 진리값에 상관없이 항상 F 의 진리값을 가진 명제 <ul><li>Tautology ( 항진 명제 ) </li></ul><ul><li>Contradiction ( 모순명제 ) </li></ul>
40. 40. Tautology & Contradiction <ul><li>Example: Logical Equivalence Involving Tautologies and Contradictions </li></ul><ul><ul><li>If t is a tautology and c is a contradiction, show that </li></ul></ul><ul><ul><ul><li>p ∧ t ≡ p p ∧ c ≡ c </li></ul></ul></ul>Contradiction Tautology <ul><li>Example </li></ul>p t p ∧ t T T T F T F p c p ∧ c T F F F F F p ~p p ∨ ~p p ∧ ~p T F T F F T T F