* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download X - UOW
Science of Logic wikipedia , lookup
Structure (mathematical logic) wikipedia , lookup
Axiom of reducibility wikipedia , lookup
Meaning (philosophy of language) wikipedia , lookup
Mathematical proof wikipedia , lookup
List of first-order theories wikipedia , lookup
Foundations of mathematics wikipedia , lookup
History of the function concept wikipedia , lookup
Willard Van Orman Quine wikipedia , lookup
Fuzzy logic wikipedia , lookup
Jesús Mosterín wikipedia , lookup
First-order logic wikipedia , lookup
Lorenzo Peña wikipedia , lookup
Quantum logic wikipedia , lookup
Propositional calculus wikipedia , lookup
Combinatory logic wikipedia , lookup
History of logic wikipedia , lookup
Mathematical logic wikipedia , lookup
Modal logic wikipedia , lookup
Curry–Howard correspondence wikipedia , lookup
Natural deduction wikipedia , lookup
Truth-bearer wikipedia , lookup
Intuitionistic logic wikipedia , lookup
Law of thought wikipedia , lookup
Principia Mathematica wikipedia , lookup
WUCT121 Discrete Mathematics Logic 1. Logic 2. Predicate Logic 3. Proofs 4. Set Theory 5. Relations and Functions WUCT121 Logic 1 Section 1. 1.1. Logic Introduction. In developing a mathematical theory, assertions or statements are made. These statements are made in the form of sentences using words and mathematical symbols. When proving a theory, a mathematician uses a system of logic. This is also the case when developing an algorithm for a program or system of programs in computer science. The system of logic is applied to decide if a statement follows from, or is a logical consequence of, one or more other statements. You are familiar with using numbers in arithmetic and symbols in algebra. You are also familiar with the ‘rules’ of arithmetic and algebra. Examples: (3 + 4) + 6 = 3 + (4 + 6) Associativity = 3 + 10 • = 13 • 3 x − 5 x = (3 − 5)x WUCT121 Distributivity = −2 x Logic 2 In a similar way, Logic deals with statements or sentences by defining symbols and establishing ‘rules’. Roughly speaking, in arithmetic an operation is a rule for producing new numbers from a pair of given numbers, like addition (+) or multiplication (× ). In logic, we form new statements by combining short statements using connectives, like the words and, or. Examples: • This room is hot and I am tired. • x < 1 or x > 7 . 1.2. Statements 1.2.1. Definition Definition: Statement. A statement or proposition is an assertion or declarative sentence which is true or false, but not both. The truth value of a mathematical statement can be determined by application of known rules, axioms and laws of mathematics. WUCT121 Logic 3 A statement which is true requires a proof. Examples: • Is the following statement True or False? For a real number x, if x 2 = 1, then x = 1 or x = −1. The statement is TRUE. Therefore, we must prove it. Consider x 2 = 1. Adding − 1 to both sides gives x 2 − 1 = 0 . Factorising this equation, we have ( x − 1)( x + 1) = 0 . Therefore, x − 1 = 0 or x + 1 = 0 . Case 1: x −1 = 0. Add 1 to both sides and we have x = 1. Case 2: x +1 = 0. Add − 1 to both sides and we have x = −1. WUCT121 Logic 4 A statement which is false requires a demonstration. Example: • Is the following statement True or False? 5 − (3 − 2) = (5 − 3) − 2 The statement is FALSE. Therefore, we must demonstrate it. 5 − (3 − 2) = 5 − 1 =4 (5 − 3) − 2 = 2 − 2 =0 ∴ 5 − (3 − 2) ≠ (5 − 3) − 2 WUCT121 Logic 5 Exercise: Determine which of the following sentences are statements. For those which are statements, determine their truth value. (i) 2 + 3 = 5 Statement (ii) It is hot and sunny Statement True outside. (iii) 2 + 3 = 6 Statement (iv) Is it raining? Not a statement (v) Go away! Not a statement (vi) There exists an Statement False True even prime number. (vii) There are six Statement people in this room. (viii) For some real Statement True number , x, x < 2 (ix) x < 2 See comment in notes (x) x + y = y + x See comment in notes WUCT121 Logic 6 Strictly speaking, as we don’t know what x or y are, in parts (ix) and (x), these should not be statements. In Mathematics, x and y usually represent real numbers and we will assume this is the case here. Therefore, (ix) is either true or false (even if we don’t know which) and (x) is always true, so we will allow both. 1.2.2. Simple Statements Definition: Simple Statement. A simple or primitive statement is a statement which cannot be broken down into anything simpler. A simple statement is denoted by use of letters p, q, r... Examples: • p: There are seven days in a week p is a simple statement • p:2+3= 6 p is a simple statement WUCT121 Logic 7 1.2.3. Compound Statements Definition: Compound Statement. A compound or composite statement is a statement which is comprised of simple statements and logical operations. A compound statement is denoted by use of letters P, Q, R... Examples: • P: There are seven days in a week and twelve months in a year. Is a compound statement. p: There are seven days in a week q: There twelve months in a year Operation: and • P: 2 + 3 = 6 or 5 − (3 − 2) = (5 − 3) − 2 . Is a compound statement. p: 2 + 3 = 6 q: 5 − (3 − 2) = (5 − 3) − 2 Operation: or WUCT121 Logic 8 • P: If it is not raining then I will go outside and eat my lunch. Is a compound statement p: It is raining q: I will go outside r: I will eat my lunch Negation of p Operations: If … then, and WUCT121 Logic 9 Exercises: Determine which of the following are simple statements, and which are not. For those which are not, identify the simple statement(s) used. Simple Statement (i) 2 + 3 = 5 is a simple Statement (ii) It is hot and p: It is hot sunny outside. Operation and q: It is sunny outside (iii) 2 + 3 ≠ 6 p: 2 + 3 = 6 negation (iv) x ≤ 2 p: x < 2 or q: x = 2 (v) − 5 < x < 2 p: − 5 < x and q: x < 2 (vi) If I study hard then I will pass p: I study hard If..then q: I will pass my exam my exam WUCT121 Logic 10 1.3. Truth Tables A statement P can hold one of two truth values, true or false. These are denoted “T” and “F” respectively. Note: Some books may use “1” for true and “0” for false. When determining the truth value of a compound statement all possible combinations of the truth values of the statements comprising it must be considered. This is done systematically by the use of truth tables. Each connective is defined by its own unique truth table. There are five fundamental truth tables which will be covered in the following sections. 1.3.1. Truth Table Construction To construct a truth table assign each statement a column. The number of rows in the table is determined by the number of statements. For n statements, 2 n rows will be required. Systematically assign truth vales to each of the statements, beginning in the first column. WUCT121 Logic 11 Once all possible truth values for the simple statements are inserted, determine the truth vales of the compound statements following the rules for the operations. Example: • Given three statements P, Q, R. The table setup is: WUCT121 P Q R T T T T T F T F T T F F F T T F T F F F T F F F Compound Statement Logic 12 1.4. Logical Operations There are five main operations which when applied to a statement will return a statement. If P and Q are statements, the five primary operations used are: not P, the negation of P. P or Q, the disjunction of P and Q. P and Q, the conjunction of P and Q. P implies Q, the conditional of P and Q. P if and only if Q, the biconditional of P and Q. 1.4.1. Negation, “not” Definition: Statement Negation. If P is a statement, the negation of P is “not P” or “it is not the case that P” and is denoted ~P. WUCT121 Logic 13 Examples: • There are not seven days in a week p: There are seven days in a week • P: It is raining outside. ~P: ~(It is raining outside.) It is not raining outside. • x > 2 or x < 2 Q: ~Q: ~( x > 2 or x < 2 ) Simplified: x = 2 . Exercises: For each statement P, write down ~P. • P: Discrete Maths is interesting. ~P: ~( Discrete Maths is interesting) Discrete Maths is not interesting. • P ~ P: x2 −1 = 0 ( ~ x 2 −1 = 0 ) x2 −1 ≠ 0 WUCT121 Logic 14 1.4.1.1 Truth Table for Negation The negation of P has the opposite truth value from P, ~P is false when P is true; ~P is true when P is false. All possible truth values for P P ~P T F F T All possible truth values for ~P depending on the value of P. Example: Write down the truth value of the following statements. • • P ~P 2+5= 7 2+5≠ 7 T F This room is empty empty F WUCT121 This room is not T Logic 15 Exercise: Write down the truth value of the following statements. • • P ~P 1∈ T 1∉ F Division is a closed Division is not a closed operation on T operation on F Note: The truth table for negation tells us that for any • statement P, exactly one of P or ~P is true. So, to prove P is true, we have two methods: ∗ Direct: Start with some facts and end up proving P in a direct step-by-step manner. ∗ Indirect: Don’t prove P is true directly, but prove that ~P is false. • Generally, brackets are left out around ‘ ~ P ’. Thus, ~ P ∨ Q means (~ P) ∨ Q , and not ~ ( P ∨ Q) . This is similar to arithmetic where − x + y means (− x ) + y and not − ( x + y ). WUCT121 Logic 16 1.4.2. Disjunction, “or” Definition: Disjunction. If P and Q are statements the disjunction of P and Q is “P or Q”, denoted P ∨ Q . Examples: • Given P : 2 + 3 = 5 , Q : 2 + 3 = 6 , write down P ∨ Q . P ∨ Q : 2 + 3 = 5 or 2 + 3 = 6 alternatively : ( 2 + 3 = 5 ) ∨ ( 2 + 3 = 6) simplified : 2 + 3 = 5 or 6 • Write P : x ≤ 5 using “ ∨ ”. ( x < 5) ∨ ( x = 5) Exercises: • Write the following statements using “ ∨ ” ∗ I am catching the bus or train home. (I am catching the bus home) ∨ (I am catching the train home) ∗ A month has 30 or 31 days. (A month has 30 days) ∨ (A month has 31 days) WUCT121 Logic 17 • For the statements P and Q, write down P ∨ Q . ∗ P: x >0 Q: x =0 P ∨ Q : ( x > 0) ∨ ( x = 0) simplified : x≥0 ∗ P: x is the square of an integer, Q: x is prime P ∨ Q : ( x is the square of an integer ) ∨ ( x is prime) 1.4.2.1 Truth Table for Disjunction The disjunction of P and Q is true when either P is true, or Q is true, or both P and Q are true; it is false only when both P and Q are false. WUCT121 P Q P∨Q T T T T F T F T T F F F Logic 18 Example: Write down the truth value of the following statements. P • 2+3=5 T • 1∉ F P∨Q Q 2+3=6 F T 0∈ F F Exercise: Write down the truth value of the following statements. P • • • 2 >1 Q ( x + 1) 2 = x 2 + 2 x + 1 T T 2 is odd 5 is odd F T 2 <1 T T This room is empty F WUCT121 P∨Q F Logic F 19 1.4.3. Conjunction, “and” Definition: Conjunction. If P and Q are statements the conjunction of P and Q is “P and Q”, denoted P ∧ Q . Examples: • Given P: It is hot, Q: It is sunny, write down P ∧ Q . P ∧ Q : (It is hot) ∧ (It is sunny) Simplified: It is hot and sunny • Write P : 0 < x < 5 using “ ∧ ”. (0 < x ) ∧ ( x < 5) Exercises: • Write the following statements using “ ∧ ” ∗ Snow is cold and wet. (Snow is cold) ∧ (Snow is wet) ∗ Natural numbers are positive and whole numbers. (Natural numbers are positive numbers) ∧ (Natural numbers are whole numbers) WUCT121 Logic 20 • For the statements P and Q, write down P ∧ Q . ∗ P: x >0 Q : x <1 P ∧ Q : ( x > 0 ) ∧ ( x < 1) simplified : 0 < x <1 ∗ P: x is even, Q: x is a natural number P ∧ Q : ( x is even ) ∧ ( x is a natural number ) 1.4.3.1 Truth Table for Conjunction The conjunction of P and Q is true when, and only when, both P and Q are true. If either P or Q are false, of if both are false, P ∧ Q is false. WUCT121 P Q P∧Q T T T T F F F T F F F F Logic 21 Example: Write down the truth value of the following statements. P • 2+3=5 T • 1∉ F P∧Q Q 2+3=6 F F 0∈ F F Exercise: Write down the truth value of the following statements. P • • • Q 6 >π 2 >1 T T 2 is odd 5 is odd F T 2 <1 T F 4 = 23 F WUCT121 P∧Q F Logic F 22 1.4.4. Conditional, “If … then”, “implies” Definition: Conditional. If P and Q are statements the conditional of P by Q is “If P then Q” or “P implies Q”, and is denoted P ⇒ Q . Examples: • Given P: It is raining, Q: I will go home, write down P ⇒ Q. P ⇒ Q : (It is raining) ⇒ (I will go home) Simplified: If it raining then I will go home • Write “If x is even then x 2 is even” using “ ⇒ ”. x is even ⇒ x 2 is even Exercises: • Write the following statements using “ ⇒ ” ∗ If the snow is good then I will go skiing. (The snow is good) ⇒ (I will go skiing) ∗ If x is a natural number then x is an integer. (x is a natural number) ⇒ (x is an integer) WUCT121 Logic 23 • For the statements P and Q, write down P ⇒ Q . ∗ P : x > −1 Q: x >0 P ⇒ Q : ( x > −1) ⇒ ( x > 0 ) ∗ P: x is even, Q: x is a natural number P ⇒ Q : ( x is even ) ⇒ ( x is a natural number ) If x is even then x is a natural number 1.4.4.1 Truth Table for Conditional The conditional of P by Q is false when P is true and Q false, otherwise it is true. We call P the hypothesis (or antecedent) of the conditional and Q the conclusion (or consequent). In determining the truth values for conditional, consider the following example. Suppose your lecturer say to you: “If you arrive for the lecture on time, then I will mark you present. Under what circumstances are you justified in saying the lecturer lied? In other words under what circumstances is the above statement false? WUCT121 Logic 24 It is false when you show up on time and are not marked present. The lecturers promise only says you will be marked present if a certain condition (arriving on time) is met; it says nothing about what will happen if the condition is not met. So if the condition (arriving on time) is not met, you cannot in fairness say the promise is false regardless of whether or not you are marked present. This example demonstrates that the only combination of circumstances in which you have a conditional statement false is when the hypothesis is true and the conclusion is false. Thus the truth table for conditional is: WUCT121 P Q P⇒Q T T T T F F F T T F F T Logic 25 Example: Write down the truth value of the following statements. P • 2+3=5 T • 1∉ F P⇒Q Q 2+3=6 F F 0∈ F T Exercise: Write down the truth value of the following statements. P • Q 2 >1 2 >1 T • 2 is even T F 2 <1 F 4 <1 F WUCT121 T 5 is even T • P⇒Q F Logic T 26 Alternative wording for P ⇒ Q can be: • If P then Q. • P implies Q. • Q if P. • Q provided P. • Q whenever P. • P is a sufficient condition for Q. • Q is a necessary condition for P. • P only if Q. WUCT121 Logic 27 1.4.5. Biconditional, “If and only if” Definition: Biconditional. If P and Q are statements the biconditional of P and Q is “P if, and only if Q” and is denoted P ⇔ Q . Examples: • Given P: Mark can study algebra, Q: Mark passes pre-algebra, write down P ⇔ Q . P ⇔ Q : (Mark can study algebra) ⇔ (Mark passes pre-algebra) Simplified: Mark can study algebra if, and only if, he passes pre-algebra • Write “Water boils if, and only if, it’s temperature is over 100 oC ” using “ ⇔ ”. Water boils ⇔ Water temperature is over 100o C Exercises: • Write the following statements using “ ⇔ ” ∗ I will go swimming if, and only if, the water is warm. (I will go swimming) ⇔ (The water is warm) WUCT121 Logic 28 ∗ x is a natural number if, and only if, x is an integer. (x is a natural number) ⇔ (x is an integer) • For the statements P and Q, write down P ⇔ Q . ∗ P : x ∈ Q: x >0 P ⇔ Q : ( x ∈ ) ⇔ ( x > 0 ) ∗ P: x is positive, Q: x is a natural number P ⇔ Q : ( x is positive) ⇔ ( x is a natural number ) 1.4.5.1 Truth Table for Biconditional The biconditional of P and Q is true if both P and Q have the same truth value, and is false if P and Q have opposite truth values. WUCT121 P Q P⇔Q T T T T F F F T F F F T Logic 29 Example: Write down the truth value of the following statements. P • 2+3=5 T • 1∉ F P⇔Q Q 2+3=6 F F 0∈ F T Exercise: Write down the truth value of the following statements. P • • • Q 2 >1 2 >1 T T 2 is odd 5 is odd F T 2 <1 T F 4 <1 F WUCT121 P⇔Q F Logic T 30 Alternative wording for P ⇔ Q can be: • P if, and only if Q. • P iff Q. • P implies and is implied by Q. • P is equivalent to Q. • P is a necessary and sufficient condition for Q. WUCT121 Logic 31 1.4.6. Order of Operation for Logical Operators. The order of operation for logical operators is as follows: 1. Evaluate negations first 2. Evaluate ∨ and ∧ second. When both are present, parenthesis may be needed, otherwise work left to right. Evaluate ⇒ and ⇔ third. When both are present, 3. parenthesis may be needed, otherwise work left to right. Note: Use of parenthesis will determine order of operations which over ride the above order. Examples: Indicate the order of operations in the following: • ~ { p∧ {q • ~ { ( p∧ {q) • 1 • 2 2 ~ { p∧ {( q∨ {r) 1 1 3 2 ~ { p⇒ {r {q∧ 1 3 2 Exercises: Indicate the order of operations in the following: • (~ { p⇒ {r { q )∧ • ~ { ( p∨ {q) • 1 • 2 WUCT121 2 3 ~ { p⇒ {r { q∨ 1 1 2 ~ { p⇔ {r { q∧ 1 Logic 3 3 2 32 1.4.7. Main Connective Definition: Main Connective. The main connective is the operation which “binds” the statement together. It is the final operation performed and is denoted with “*”. Examples: Indicate the main connective in the following: • ~ { p∧ {q • ~ { ( p∧ {q) • 1 • 2* 2* ~ { p∧ { ( q∨ {r) 1 1 3* 2 ~ { p⇒ {r {q∧ 1 3* 2 Exercises: Indicate the main connective in the following: • (~ { p⇒ {r {q)∧ • ~ { ( p∨ {q) • 1 • 2* WUCT121 2 3* ~ { p⇒ {r { q∨ 1 1 2 ~ { p⇔ {r { q∧ 1 Logic 3* 3* 2 33 Example: Construct a truth table for ~ ( p∧ ~ q ) , indicating order of operations and the main connective T ∧ F F F F T T F T T F F F F T F T 3* 2 1 p q ~ T T T Step: (p ~ q) Exercises: • Construct a truth table for ~ p ⇒~ q ∧ p , indicating order of operations and the main connective ⇒ ~ F T F ∧ F F F T T T F T T F F F F F T F T F 1 3* 1 2 p q ~ T T T Step: WUCT121 p Logic q p 34 • Construct a truth table for ( p ∨ q ) ∧ (r ∨ q ), indicating order of operations and the main connective p T T T T F F F F Step: • q T T F F T T F F r T F T F T F T F (p ∨ T T T T T T F F 1 q) ∧ T T T F T T F F 2* (r ∨ T T T F T T T F 1 q) Construct a truth table for (~ q ∧ r ) ∨ ~ ( p ∧ r ) , indicating order of operations and the main connective p T T T T F F F F Step: WUCT121 q T T F F T T F F r (~ q T F F F T T F T T F F F T T F T 1 ∧ r) ∨ F F F T T T F T F T F T T T F T 2 3* Logic ~ (p ∧ r) F T T F F T T F T F T F T F T F 2 1 35 1.5. Tautologies and Contradictions 1.5.1. Tautology Definition: Tautology. Any statement that is true regardless of the truth values of the constituent parts is called a tautology or tautological statement. Examples: Complete the truth table for the statement P ⇒ (Q ⇒ P ) WUCT121 (Q ⇒ Q T T T T T F T T F T T F F F T T 2* 1 Step: P ⇒ P Logic P) 36 Exercises: • Complete the truth table for the statement (( P ⇒ Q ) ∧ P ) ⇒ Q to show it is a tautology. ⇒ Q T T T ∧ T T F F F T F T T F T F F T F T 1 2 3* ((P Step: • ⇒ P Q) P) Q T Complete the truth table for the statement (( P ⇒ Q ) ∧ ~ Q ) ⇒ ~ P to show it is a tautology. Q T T T ∧ F T F F F T F F Step: WUCT121 ⇒ P ((P Q) ~Q) ⇒ ~ P F T F F T T F T F F T T T T T T T 2 3 1 4* 1 Logic 37 1.5.1.1 Quick Method for Showing a Tautology In constructing a truth table for a compound statement comprised of n statements, there will be 2n combinations of truth values. This method can be long for large numbers of statements. We will consider a quicker method for determining if a compound statement is a tautology. However, truth tables are reliable (“safe”) and are highly recommended if the “quick” method is confusing or leading nowhere! The quick method relies on the fact that if a truth value of “F” can occur under the main connective (for some combination of truth values for the components), then the statement is not a tautology. If this truth value is not possible, then we have a tautology. Therefore, to determine whether a statement is a tautology, we place an “F” under the main connective and work backwards. WUCT121 Logic 38 Examples: • Determine if P ⇒ (Q ⇒ P ) is a tautology, using the quick method P Step 1.Place “F” under main ⇒ (Q ⇒ 2* 1 P) F connective 2. For “F” to occur under the F T main connective, P must be “T” and ⇒ must be “F” 3. For “F” to occur under ⇒ , T F Q must be “T” and P must be “F” P cannot be both “T” and “F”, thus P ⇒ (Q ⇒ P ) can only ever be true and is a tautology. WUCT121 Logic 39 • Determine if ( P ∧ Q) ⇒ (R ∧ S ) is a tautology, using the quick method (P Step ∧ 1 Q) ⇒ (R 3* 1.Place “F” under main ∧ 2 S) F connective 2. For “F” to occur under the T F main connective, ( P ∧ Q ) must be “T” and ( R ∧ S ) must be “F” T 3. For “T” to occur under T ( P ∧ Q ) , P must be “T” and Q must be “T” 3. For “F” to occur under T F (R ∧ S ), R can be “T” and S can be “F” As there is a valid combination of truth values which gives “F” under the main connective, ( P ∧ Q ) ⇒ (R ∧ S ) is not a tautology. WUCT121 Logic 40 Exercises: • Use the “quick” method for the statement (( P ⇒ Q ) ∧ P ) ⇒ Q to determine if it is a tautology. ((P ⇒ Q) Step 1 ∧ 2 P) ⇒ Q 3* 1. Place “F” under main F connective. 2. For “F” to occur under the T F main connective, ∧ must be “T” and Q must be “F” 3. For “T” to occur under ∧ , P T T must be “T” and P ⇒ Q must be “T” T 4. For “T” to occur under T P ⇒ Q ,when P is “T” Q must be “T” Q cannot be both “T” and “F”, thus (( P ⇒ Q ) ∧ P ) ⇒ Q can only ever be true and is a tautology. WUCT121 Logic 41 • Determine if the statement (( P ⇒ Q ) ∧ ~ Q ) ⇒ ~ P is a tautology, using the “quick” method. Step: ((P ⇒ Q) ∧ ~Q) ⇒ 2 3 1 4* 1.Place “F” under main ~P 1 F connective 2. For “F” to occur under T F the main connective, ∧ must be “T” and ~P must be “F” T 3. For “T” to occur under T ∧ , ~Q must be “T” and P ⇒ Q must be “T” 4. For “T” to occur under T T P ⇒ Q ,when P is “T”, Q must be “T” At step 2, ~P is “F”, thus P is “T”. Step 3 shows ~Q is “T” thus Q is “F”and step 4 gives Q is “T”. Q cannot be both “T” and “F”, thus (( P ⇒ Q ) ∧ ~ Q ) ⇒ ~ P can only ever be true and is a tautology. WUCT121 Logic 42 1.5.2. Contradiction Definition: Contradiction. Any statement that is false regardless of the truth values of the constituent parts is called a contradiction or contradictory statement. Examples: Complete the truth table for the statement ~ ( P ∧ Q ) ⇔ (Q ∧ P ) P Q ~ T T F ∧ T T F T F T F F Step: WUCT121 ⇔ F ∧ T F F F T F F F T F F F 2 1 4* 3 (P Logic Q) (Q P) 43 Exercises: • Complete the truth table for the statement ~ ( P ∨ Q ) ∧ P to show it is a contradiction. P Q ~(P T T F ∨ T T F F T F F T F T F F F T F F 2 1 3* Step: • Q) ∧ F P Complete the truth table for the statement ( P ∧ Q ) ∧ ~ Q to show it is a contradiction. P Q T T ∧ T T F F F Step: WUCT121 ∧ F ~Q) F F T T F F F F F T T 2 3* 1 (P Logic Q) F 44 1.5.2.1 Quick Method for Showing a Contradiction The quick method for determining if a compound statement is a tautology can be used similarly for showing a contradiction. The quick method relies on the fact that if a truth value of “T” can occur under the main connective (for some combination of truth values for the components), then the statement is not a contradiction. If this truth value is not possible, then we have a contradiction. Therefore, to determine whether a statement is a contradiction, we place a “T” under the main connective and work backwards. WUCT121 Logic 45 Example: • Use the “quick” method for the statement ~ ( P ∨ Q ) ∧ P to determine if it is a contradiction. ~ Step: (P 2 ∨ 1 Q) 1.Place “T” under main ∧ 3* P T connective 2. For “T” to occur T T under the main connective, ~ must be “T” and P must be “T” F 3. For “T” to occur under ~, P ∨ Q must be “F”. 4. For “F” to occur F F under P ∨ Q , P must be “F” and Q must be “F” P cannot be both “T” and “F”, thus ~ ( P ∨ Q ) ∧ P can only ever be false and is a contradiction. WUCT121 Logic 46 Exercise: • Use the “quick” method for the statement ( P ∧ Q ) ∧ ~ Q to determine if it is a contradiction. (P Step: ∧ 2 Q) 1.Place “T” under main ∧ 3* ~Q 1 T connective. T 2. For “T” to occur under T the main connective, ( P ∧ Q ) must be “T” and ~Q must be “T” 3. For “T” to occur under T T ( P ∧ Q ) , P must be “T” and Q must be “T”. At Step 2, ~Q is “T”, thus Q is “F”. Step 3 shows Q is “T”. Q cannot be both “T” and “F”, thus ( P ∧ Q ) ∧ ~ Q can only ever be false and is a contradiction. WUCT121 Logic 47 1.5.3. Contingent Definition: Contingent. Any statement that is neither a tautology nor a contradiction is called a contingent or intermediate statement. Examples: Complete the truth table for the statement Q ∨ (Q ⇒ P ) Q T T ∨ T T F T T F T F F F F T T 2* 1 Step: WUCT121 ⇒ P Q Logic (Q P) T 48 Exercises: • Complete the truth table for the statement ( p ∨ r ) ⇒ ( p ∧ q ) to show it is contingent. p T T T T F F F F Step: • q T T F F T T F F r T F T F T F T F (p ∨ T T T T T F T F 1 r) ⇒ T T F F F T F T 3* (p ∧ T T F F F F F F 2 q) Complete the truth table for the statement ~ (( p ∧ ~ q ) ∨ r ) ⇔ (r ⇒ q ) to show it is contingent. p q T T T T T F T F F T F T F F F F Step: WUCT121 r ~( (p ∧ T F F F T F T F T F F T T F F F T F T F F F T F 4 2 ~ q) ∨ F T F F T T T T F T F F T T T F 1 3 Logic r) ⇔ (r ⇒ q) F T T T T F F T F T T T T F T T 6* 5 49 1.6. Logical Equivalence Definition: Logical Equivalence. Two statements are logically equivalent if, and only if, they have identical truth values for each possible substitution of statements for their statements variables. The logical equivalence of two statements P and Q is denoted P ≡ Q . If two statements P and Q are logically equivalent then P ⇔ Q is a tautology 1.6.1. Determining Logical Equivalence. To determine if two statements P and Q are logically equivalent, construct a full truth table for each statement. If their truth values at the main connective are identical, the statements are equivalent. Alternatively show P ⇔ Q is a tautology and hence conclude P ≡ Q . WUCT121 Logic 50 Examples: • Determine if the following statements are logically equivalent. P : p ⇒ q, Q :~ p ∨ q ⇒ p q T T T F ∨ T T F F F F F T T T T F F T T T 1* 1 2* p Step: q ~p q Since the main connectives * are identical, the statements P and Q are equivalent. Thus P ≡ Q • i.e. p ⇒ q ≡ ~ p ∨ q Determine if the following statements are logically equivalent. P :~ ( p ∧ q ), Q :~ p ∧ ~ q p q ~( T T F ∧ T T F T F T F F Step: ~q F ∧ F F F F T T F T F F T F T T T 2* 1 1 2* 1 p q) ~p F Since the main connectives * are not identical, the statements P and Q are not equivalent. WUCT121 Logic 51 Exercises: • Determine if the following statements are logically equivalent. P :~ ( p ∨ q ), Q :~ p ∧ ~ q p q ~( T T F ∨ T T F F F T F F Step: ~q F ∧ F T F F T F T T F F T F T T T 2* 1 1 2* 1 p q) ~p F Since the main connectives are identical, the statements P and Q are equivalent. Thus P ≡ Q i.e. ~ ( p ∨ q ) ≡~ p ∧ ~ q Determine if ~ ( p ∧ q ) ⇔ ~ p ∨ ~ q is a tautology, and • hence if ~ ( p ∧ q ) ≡~ p ∨ ~ q . ⇔ ~p T F T p q ~( T T F ∧ T T F T F T F F Step: ~q F ∨ F T F T T F T T T F T F T T T T 2* 1 3* 1 2* 1 p q) F Since the main connective is all T, the statement ~ ( p ∧ q ) ⇔ ~ p ∨ ~ q is a tautology, and hence ~ ( p ∧ q ) ≡~ p ∨ ~ q . WUCT121 Logic 52 1.6.2. Substitution There are two different types of substitution into statements. Rule of Substitution: If in a tautology all occurrences of a variable are replaced by a statement, the result is still a tautology. Examples: • We know P ∨ ~ P is a tautology. Thus, by the rule of substitution, so too are: ∗ Q ∨ ~ Q , by letting Q = P . ∗ (( p ∧ q ) ⇒ r )∨ ~ (( p ∧ q ) ⇒ r ) , by letting ( p ∧ q) ⇒ r = P . Note: We have simply replaced every occurrence of P in the tautology P ∨ ~ P , by some other statement. WUCT121 Logic 53 Rule of Substitution of Equivalence: If in a tautology we replace any part of a statement by a statement equivalent to that part, the result is still a tautology. Example: • Determine if P ⇒ (~ Q ∨ P ) is a tautology. We know: P ⇒ (Q ⇒ P ) is a tautology and ( P ⇒ Q ) ≡~ P ∨ Q By the rule of substitution (Q ⇒ P ) ≡ ~ Q ∨ P Thus, by the rule of substitution of equivalence, P ⇒ (Q ⇒ P ) ≡ P ⇒ (~ Q ∨ P ) , and hence P ⇒ (~ Q ∨ P ) is also a tautology. Exercise: • ~ T ∨ (~ S ∨ T ) a tautology? Yes. We know ( P ⇒ Q ) ≡~ P ∨ Q . So, ( S ⇒ T ) ≡~ S ∨ T and T ⇒ (~ S ∨ T ) ≡ ~ T ∨ (~ S ∨ T ) (by RoS). Hence, ~ T ∨ (~ S ∨ T ) ≡ T ⇒ ( S ⇒ T ) (by SoE). P ⇒ (Q ⇒ P ) is a known tautology, thus (by (SoE) T ⇒ ( S ⇒ T ) is a tautology, and since ~ T ∨ (~ S ∨ T ) ≡ T ⇒ ( S ⇒ T ) , ~ T ∨ (~ S ∨ T ) is a tautology. WUCT121 Logic 54 1.6.3. Laws The following logical equivalences hold: Commutative Laws: 1. • • • ( P ∨ Q ) ≡ (Q ∨ P ) ( P ∧ Q ) ≡ (Q ∧ P ) ( P ⇔ Q ) ≡ (Q ⇔ P ) Associative Laws: 2. • • • (( P ∨ Q ) ∨ R ) ≡ (P ∨ (Q ∨ R )) (( P ∧ Q ) ∧ R ) ≡ (P ∧ (Q ∧ R )) (( P ⇔ Q ) ⇔ R ) ≡ (P ⇔ (Q ⇔ R )) Distributive Laws: 3. • • (P ∨ (Q ∧ R) ) ≡ (( P ∨ Q) ∧ ( P ∨ R) ) (P ∧ (Q ∨ R) ) ≡ (( P ∧ Q) ∨ ( P ∧ R) ) 4. • Double Negation (Involution) Law: ~~ P ≡ P 5. • • De Morgan’s Laws: ~ ( P ∨ Q ) ≡ (~ P ∧ ~ Q ) ~ ( P ∧ Q ) ≡ (~ P ∨ ~ Q ) WUCT121 Logic 55 6. • • Implication Laws: ( P ⇒ Q ) ≡ (~ P ∨ Q ) ( P ⇔ Q ) ≡ (( P ⇒ Q ) ∧ (Q ⇒ P ) ) ( Biconditional) 7. • • Identity Laws: (P ∨ F ) ≡ P (P ∧ T ) ≡ P 8. • • Negation (Complement) Laws: ( P∨ ~ P ) ≡ T ( P∧ ~ P) ≡ F 9. • • Dominance Laws: (P ∨ T ) ≡ T (P ∧ F ) ≡ F 10. • • ( Implication ) Idempotent Laws: ( P ∨ P) ≡ P ( P ∧ P) ≡ P 11. Absorption Laws: • P ∧ (P ∨ Q) ≡ P • P ∨ (P ∧ Q) ≡ P 12. • • Property of Implication: (P ⇒ (Q ∧ R) ) ≡ (( P ⇒ Q) ∧ ( P ⇒ R) ) (( P ∨ Q) ⇒ R ) ≡ (( P ⇒ R) ∧ (Q ⇒ R) ) WUCT121 Logic 56 Example: Prove the first of De Morgan’s Laws using truth tables. P Q ~( T T F ∨ T T F F F T F F Step: ~Q F ∧ F T F F T F T T F F T F T T T 2* 1 1 2* 1 P Q) ~P F Since the main connectives are identical, the statements are equivalent., and first of De Morgan’s Laws is true. Exercise: Prove the second of De Morgan’s Laws using truth tables. P Q ~( T T F ∧ T T F T F T F F Step: ~Q F ∨ F F F T T T F T T F T F T T T 2* 1 1 2* 1 P Q) ~P F Since the main connectives are identical, the statements are equivalent, and second of De Morgan’s Laws is true. WUCT121 Logic 57 Example: Using logically equivalent statements, without the direct use of truth tables, show: ~ (~ p ∧ q ) ∧ ( p ∨ q ) ≡ p ~ (~ p ∧ q ) ∧ ( p ∨ q ) ≡ (~ (~ p ) ∨ ~ q ) ∧ ( p ∨ q ) (De Morgan ) ≡ ( p ∨ ~ q ) ∧ ( p ∨ q ) (Double Negation) (Distributivity) ≡ p ∨ (~ q ∧ q ) (Commutativity) ≡ p ∨ (q ∧ ~ q ) (Negation) ≡ p∨F (Identity) ≡ p Exercises: Using logically equivalent statements, without the direct use of truth tables, show: • ~ ( p ⇔ q ) ≡ ( p ∧ ~ q ) ∨ (q ∧ ~ p ) ~ ( p ⇔ q ) ≡ ~ (( p ⇒ q ) ∧ (q ⇒ p )) (Biconditional ) (De Morgan ) ≡ ~ ( p ⇒ q ) ∨ ~ (q ⇒ p ) (Implication ) ≡ ~ (~ p ∨ q ) ∨ ~ (~ q ∨ p ) ≡ (~ ~ p ∧ ~ q ) ∨ (~ ~ q ∧ ~ p ) (De Morgan ) (Double Negation) ≡ ( p ∧ ~ q ) ∨ (q ∧ ~ p ) WUCT121 Logic 58 • ( p ⇒ q ) ≡ (~ q ⇒~ p ) ( p ⇒ q ) ≡ (~ p ∨ q ) (Implication ) (Commutativity ) ≡ (q ∨ ~ p ) (Double Negation) ≡ (~ (~ q )∨ ~ p ) (Implication ) ≡ (~ q ⇒ ~ p ) • p ⇒ (q ∧ r ) ≡ ( p ⇒ q ) ∧ ( p ⇒ r ) , without using the property of implication p ⇒ (q ∧ r ) ≡ ~ p ∨ (q ∧ r ) ≡ (~ p ∨ q ) ∧ (~ p ∨ r ) ≡ ( p ⇒ q) ∧ ( p ⇒ r ) WUCT121 Logic (Implication ) (Distributive) (Implication ) 59 Section 2. Predicate Logic Discussion: In Maths we use variables (usually ranging over numbers) in various ways. How does x differ in what it represents in the following statements? x is real. • x2 = 0 • x>2 • x+0 = x x represents all values • x2 +1 = 0 x represents no values x represents one value, x = 0 x represents some, but not all values Definition: Predicate A predicate is a sentence that contains one or more variables and becomes a statement when specific values are substituted for the variables. Definition: Domain The domain of a predicate variable consists of all values that may be substituted in place of the variable WUCT121 Logic 60 Definition: Truth Set If P(x) is a predicate and x has domain D, the truth set of P(x) is the set of all elements of D that make P(x) true. The truth set is denoted { x ∈ D : P( x )} and is read “the set of all x in D such that P(x).” Examples: • Let P(x) be the predicate “ x 2 > x ” with x ∈ i.e. domain the set of real numbers . Write down P( 2), P(1), P( −2) and indicate which are true and which are false. Determine the truth set of P(x) P( 2) : 2 2 > 2 or 4 > 2 True P(1) : (1)2 > 1 or 1 > 1 False P( −2) : ( −2)2 > ( −2) or 4 > ( −2) True { x ∈ : x 2 > x} = { x ∈ : x < 0 ∨ x > 1} • Let Q(n) be the predicate “n is factor of 8”. Determine the truth set of Q(n) if n ∈ + 8 = ±1 × ±8, 8 = ±2 × ±4 ∴{n ∈ + :" n is a factor of 8"} = {1, 2, 4, 8} WUCT121 Logic 61 Exercises: • 3 Let P(x) be the predicate “ x > x ” with x ∈ i.e. domain the set of integers, . Write down P(2), P(0), P( −2) and indicate which are true and which are false. Determine the truth set of P(x) P( 2) : 23 > 2 or 8 > 2 True P (0 ) : (0 ) 3 > 0 or 0 > 0 False P( −2) : ( −2) 2 > ( −2) or ( −8) > ( −2) False { x ∈ : x 3 > x} = { x ∈ : x > 1} • Let Q(n) be the predicate “n is factor of 6”. Determine the truth set of Q(n) if n ∈ 6 = ±1 × ±6, 6 = ±2 × ±3 ∴ {n ∈ :" n is a factor of 6" } = {±1, ± 2, ± 3, ± 6} WUCT121 Logic 62 2.1. Quantifiers A way to obtain statements from predicates is to add quantifiers. Quantifiers are words that refer to quantities such as “all”, “every”, or “some” and tell for how many elements a given predicate is true. 2.1.1. Universal Quantifier The symbol ∀ denotes “for all” and is called the universal quantifier. Definition: Universal Statement Let P(x) be a predicate and D the domain of x. A universal statement is a statement of the form “ ∀x ∈ D, P( x ) ”. It is defined to be true if, and only if, P(x) is true for every x in D. It is defined to be false if, and only if, P(x) is false for at least one x in D. A value of x for which P(x) is false is called a counterexample to the universal statement. Examples: • Write the sentence “All human beings are mortal” using the universal quantifier. Let H be the set of human beings. ∀h ∈ H ,h is mortal WUCT121 Logic 63 • Consider A = { x1 , x2 , x3 } . With ∀x ∈ A, P( x ) , the following must hold: P( x1 ) ∧ P( x2 ) ∧ P( x3 ) Thus there will be 3 predicates which must hold. Exercises: Write the following statements using the universal quantifier. Determine whether each statement is true or false. • “All dogs are animals” Let D be the set of dogs and A the set of animals ∀d ∈ D, d ∈ A . True • The square of any real number is positive. ∀x ∈ , x 2 > 0 . False, consider x = 0 ∈ , x 2 = 0 2 u0. Hence the statement is false by counterexample • Every integer is a rational number. ∀x ∈ , x ∈ . True WUCT121 Logic 64 Exercises: Write the following statements in words. Determine whether each statement is true or false. • ∀x ∈ , x ∈ The square root of any natural number is a natural number. False. Consider x = 2 ∈ , x = 2 ∉ . Hence the statement is false by counterexample. • ∀x ∈ , x 2 ≠ −1. The square of any real number does not equal –1. True. WUCT121 Logic 65 2.1.2. Existential Quantifier The symbol ∃ denotes “there exists” and is called the existential quantifier. Definition: Existential Statement Let P(x) be a predicate and D the domain of x. An existential statement is a statement of the form “ ∃x ∈ D, P( x ) ”. It is defined to be true if, and only if, P(x) is true for at least one x in D. It is defined to be false if, and only if, P(x) is false for all x in D. Examples: • Write the sentence “Some people are vegetarians” using the existential quantifier. Let H be the set of human beings. ∃h ∈ H , h is a vegetarian • Consider A = { x1 , x2 , x3 }. With ∃x ∈ A, P( x ) , the following must hold: P( x1 ) ∨ P( x2 ) ∨ P( x3 ) Thus there will be 1 predicate which must hold. WUCT121 Logic 66 Exercises: Write the following statements using the existential quantifier. Determine whether each statement is true or false. • “Some cats are black” Let C be the set of cats. ∃c ∈ C ,c is black . True • There is a real number whose square is negative. ∃x ∈ , x 2 < 0 .False. • Some programs are structured. Let P be the set of programs. ∃p ∈ P, p is structured . True WUCT121 Logic 67 Exercises: Write the following statements in words. Determine whether each statement is true or false. • ∃m ∈ , m 2 = m There is an integer whose square is equal to itself. True. Consider m = 1 ∈ , m 2 = 12 = 1 = m . Hence the statement is true. • ∃x ∈ , x 2 = −1. There is a real number whose square is –1. False. • 1 ∃ x ∈ , ∉ x The reciprocal of some integer is not rational. 1 1 True. Consider x = 0 ∈ , = ∉ . x 0 Hence the statement is true. WUCT121 Logic 68 2.1.3. Negation of Universal Statements Let P(x) be a predicate and D the domain of x. The negation of a universal statement of the form: ∀x ∈ D, P( x ) is logically equivalent to ∃x ∈ D , ~ P( x ) Symbolically ~ (∀x ∈ D , P( x )) ≡ ∃x ∈ D , ~ P( x ) Example: • Write down the negation of the following statement. ∀x ∈ , x 2 + 1 ≥ 2 x Negation: ~ (∀x ∈ , x 2 + 1 ≥ 2 x ) ≡ ∃x ∈ , ~ ( x 2 + 1 ≥ 2 x ) ≡ ∃x ∈ , x 2 + 1 < 2 x False. WUCT121 Logic 69 Exercises: • Write down the negation of the following statement. ∀x ∈ , x 2 ≥ 0 Negation: ~ (∀x ∈ , x 2 ≥ 0) ≡ ∃x ∈ , ~ ( x 2 ≥ 0) False. ≡ ∃x ∈ , x 2 < 0 • Write down the negation of the following statement. y +1 ⎞ ⎛ ∀y ∈ , ⎜ y ≠ 0 ⇒ < 1⎟ y ⎝ ⎠ Negation: ⎛ y + 1 ⎞⎞ ⎛ ~ ⎜⎜ ∀y ∈ , ⎜ y ≠ 0 ⇒ < 1⎟ ⎟⎟ y ⎠⎠ ⎝ ⎝ y +1 ⎞ ⎛ ≡ ∃y ∈ , ~ ⎜ y ≠ 0 ⇒ < 1⎟ y ⎠ ⎝ y +1 ⎞ ⎛ ≡ ∃y ∈ , ~ ⎜ ~ ( y ≠ 0) ∨ < 1⎟ y ⎠ ⎝ ⎛ y +1 ⎞ ≡ ∃y ∈ , y ≠ 0∧ ~ ⎜ < 1⎟ ⎝ y ⎠ y +1 ≡ ∃y ∈ , y ≠ 0 ∧ ≥1 y True, choose y = 1. WUCT121 Logic 70 Example: • Write the following statement using quantifiers. Find its negation and determine whether the statement or its negation is true, giving a brief reason.. “Every real number is either positive or negative.” Statement: ∀x ∈ , x < 0 ∨ x > 0 Negation: ~ (∀x ∈ , x < 0 ∨ x > 0) ≡ ∃x ∈ , ~ ( x < 0 ∨ x > 0) ≡ ∃x ∈ , ~ ( x < 0)∧ ~ ( x > 0) ≡ ∃x ∈ , ( x ≥ 0) ∧ ( x ≤ 0) ≡ ∃x ∈ , x = 0 The true statement is the negation because x = 0 is neither positive nor negative. WUCT121 Logic 71 Exercises: • Write the following statement using quantifiers. Find the negation. “The square of any integer is positive.” Statement: ∀x ∈ , x 2 > 0 Negation: ~ ( ∀x ∈ , x 2 > 0 ) ≡ ∃ x ∈ , ~ ( x 2 > 0 ) ≡ ∃ x ∈ , x 2 ≤ 0 There is an integer whose square is not positive. The negation is true, choose x = 0. • Write the following statement using quantifiers. Find the negation. “All computer programs are finite.” Let C be the set of computer programs Statement: ∀x ∈ C , x is finite Negation: ≡ ~ (∀x ∈ C , x is finite) ≡ ∃x ∈ C , x is not finite Not all computer programs are finite. Some computer programs are not finite. True? WUCT121 Logic 72 2.1.4. Negation of Existential Quantifiers Let P(x) be a predicate and D the domain of x. The negation of an existential statement of the form: ∃x ∈ D, P( x ) is logically equivalent to ∀x ∈ D , ~ P( x ) Symbolically ~ (∃x ∈ D, P( x )) ≡ ∀x ∈ D , ~ P( x ) Example: • Write down the negation of the following statement. ∃x ∈ , x 2 = 2 Negation: ~ (∃x ∈ , x 2 = 2) ≡ ∀x ∈ , ~ ( x 2 = 2) ≡ ∀x ∈ , x 2 ≠ 2 The negation is true. WUCT121 Logic 73 Exercises: • Write down the negation of the following statement. ∃z ∈ , ( z is odd ) ∨ ( z is even) Negation: ~ (∃z ∈ , ( z is odd ) ∨ ( z is even)) ≡ ∀z ∈ , ~ (( z is odd ) ∨ ( z is even)) ≡ ∀z ∈ , ~ ( z is odd ) ∧ ~ ( z is even) ≡ ∀z ∈ , ( z is not odd ) ∧ ( z is not even) The negation is false • Write down the negation of the following statement. ∃n ∈ , ( n is even) ∧ ( n is prime) Negation: ~ (∃n ∈ , ( n is even) ∧ ( n is prime)) ≡ ∀n ∈ , ~ (( n is even) ∧ ( n is prime)) ≡ ∀n ∈ , ~ ( n is even) ∨ ~ ( n is prime) ≡ ∀n ∈ , ( n is not even) ∨ ( n is not prime) The negation is false. WUCT121 Logic 74 Example: • Write the following statement using quantifiers. Find its negation “Some dogs are vegetarians.” Let D be the set of dogs. Statement: ∃d ∈ D , d is vegetarian Negation: ~ (∃d ∈ D, d is vegetarian) ≡ ∀d ∈ D , ~ ( d is vegetarian) ≡ ∀d ∈ D , d is not vegetarian All dogs are not vegetarian Exercises: • Write the following statement using quantifiers. Find the negation. “There is a real number that is rational.” Statement: ∃x ∈ , x ∈ Negation: ~ (∃x ∈ , x ∈ ) ≡ ∀x ∈ , ~ ( x ∈ ) False ≡ ∀x ∈ , x ∉ All real numbers are not rational WUCT121 Logic 75 • Write the following statement using quantifiers. Find the negation. P(p): Some computer hackers are over 40. Let C be the set of computer hackers. P( p ) : ∃p ∈ C , p is over 40 ~ P( p ) : ~ (∃p ∈ C , p is over 40) ≡ ∀p ∈ C , ~ ( p is over 40) ≡ ∀p ∈ C , p is not over 40 ≡ ∀p ∈ C , p is 40 or under All computer hackers are 40 or under False • Write the following statement using quantifiers. Find the negation. “Some animals are dogs.” Let A be the set of animals Statement: ∃x ∈ A, x is a dog Negation: ~ (∃x ∈ A, x is a dog ) ≡ ∀x ∈ A, x is not a dog All animals are not dogs. False WUCT121 Logic 76 2.1.5. Multiple Quantifiers When a statement contains multiple quantifiers their order must be applied as written and will produce different results for the truth set. Examples: Write the following statements using quantifiers: • “Everybody loves somebody.” Let H be the set of people. Statement: ∀x ∈ H , ∃y ∈ H , x loves y. • “Somebody loves everyone.” Let H be the set of people. Statement: ∃x ∈ H , ∀y ∈ H , x loves y. WUCT121 Logic 77 Exercises: Write the following statements using quantifiers: • “Everybody loves everybody.” Let H be the set of people. Statement: ∀x ∈ H , ∀y ∈ H , x loves y. • The Commutative Law of Addition for Statement: ∀x ∈ ,, ∀y ∈ , x + y = y + x • “Everyone had a mother.” Let H be the set of humans. Statement: ∀x ∈ H, ∃y ∈ H , y was the mother of x or x was the child of y. • “There is an oldest person.” Let H be the set of humans. Statement: ∃x ∈ H, ∀y ∈ H , x is older thany WUCT121 Logic 78 Examples: Write the following statements without using quantifiers: • ∀x ∈ ,, ∃y ∈ , x + y = 0 Statement: Given any real number, you can find a real number so that the sum of the two is zero. Alternatively: Every real number has an additive inverse. • ∃x ∈ ,, ∀y ∈ , x + y = y Statement: There is a real number, which added to any other real number results in the other number. Alternatively: Every real number has an additive identity. Exercises: Write the following statements without using quantifiers: • ∀c ∈ colours, ∃a ∈ animals, a is coloured c Statement: For every colour, there is an animal of that colour. Alternatively: There are animals of every colour. • ∃b ∈ books, ∀p ∈ people, p has read b Statement: There is a book everyone has read. WUCT121 Logic 79 2.1.6. Interpreting Statements with Multiple Quantifiers To establish the truth of a statement with more than one quantifier, take the action suggested by the quantifiers as being performed in the order in which the quantifiers occur. Consider A = { x1 , x 2 , x3 }, B = { y1 , y 2 } and the predicate P( x, y ) . There will be 6 possible predicates: P( x1 , y1 ) , P( x1 , y 2 ), P( x2 , y1 ), P( x2 , y 2 ), P( x3 , y1 ) , P( x3 , y 2 ). • For ∀x ∈ A, ∀y ∈ B, P( x, y ) to be true the following must hold: P( x1 , y1 ) ∧ P( x1 , y 2 ) ∧ P( x2 , y1 ) ∧ P( x2 , y 2 ) ∧ P( x3 , y1 ) ∧ P( x3 , y 2 ) Thus there will be 6 predicates which must all be true. That is for all pairs (x, y), P(x, y) must be true. It will be false if there is one pair (x, y), for which P(x, y) is false. WUCT121 Logic 80 • For ∀x ∈ A, ∃y ∈ B, P( x, y ) to be true, the following must hold: P( x1 , y1 ) ∨ P( x1 , y 2 ) ∧ P( x 2 , y1 ) ∨ P( x 2 , y 2 ) ∧ P( x3 , y1 ) ∨ P( x3 , y 2 ) Thus there will be 3 predicates which must be true. That is for every x there must be at least one y so that P(x, y) is true. Given any element x in A you can find an element y in B, so that P(x, y) is true. It will be false if there is one x in A for which P(x, y) is false for every y in B. • For ∃x ∈ A, ∀y ∈ B, P( x, y ) to be true, the following must hold: P( x1 , y1 ) ∧ P( x1 , y 2 ) ∨ P( x 2 , y1 ) ∧ P( x 2 , y 2 ) ∨ P( x3 , y1 ) ∧ P( x3 , y 2 ) Thus there will be 2 predicates which must be true. That is there is one x that when paired with any y, P(x, y) is true. You can find one element x in A that with all elements y in B, P(x, y) is true. It will be false if for every x in A, there is a y in B for which P(x, y) is false. WUCT121 Logic 81 • For ∃x ∈ A, ∃y ∈ B, P( x, y ) to be true, the following must hold: P( x1 , y1 ) ∨ P( x1 , y 2 ) ∨ P( x 2 , y1 ) ∨ P( x 2 , y 2 ) ∨ P( x3 , y1 ) ∨ P( x3 , y 2 ) Thus there will be 1 predicate which must be true. That is there is one x that when paired with one y, P(x, y) is true. You can find one element x in A and one element y in B, P(x, y) is true. It will be false if for all pairs (x, y), P(x, y) is false. Summary: Statement When true? ∀x, ∀y , P( x, y ) P(x, y) is true for all pairs (x, y) ∀x, ∃y , P( x, y ) For every x, there is a y for which P(x, y) is true ∃x, ∀y , P( x, y ) There is an x such that P(x, y) is true for every y ∃x, ∃y , P( x, y ) There is a pair (x, y) for which P(x, y) is true WUCT121 Logic When false? There is a pair (x, y) for which P(x, y) is false There is an x such that P(x, y) is false for every y For every x, there is a y for which P(x, y) is false P(x, y) is false for all pairs (x, y) 82 2.1.7. Negation of Statements with Multiple Quantifiers. To negate statements with multiple quantifiers, each quantifier is negated and the predicate must be negated. • To negate ∀x ∈ A, ∀y ∈ B, P( x, y ) ~ (∀x ∈ A, ∀y ∈ B, P( x, y ) ) ≡ ∃x ∈ A, ∃y ∈ B, ~ P( x, y ) • To negate ∀x ∈ A, ∃y ∈ B, P( x, y ) ~ (∀x ∈ A, ∃y ∈ B, P( x, y ) ) ≡ ∃x ∈ A, ∀y ∈ B, ~ P( x, y ) • To negate ∃x ∈ A, ∀y ∈ B, P( x, y ) ~ (∃x ∈ A, ∀y ∈ B, P( x, y ) ) ≡ ∀x ∈ A, ∃y ∈ B, ~ P( x, y ) • To negate ∃x ∈ A, ∃y ∈ B, P( x, y ) ~ (∃x ∈ A, ∃y ∈ B, P( x, y ) ) ≡ ∀x ∈ A, ∀y ∈ B, ~ P( x, y ) Examples: Write the negation of the following: • Statement: ∀x ∈ ,, ∃y ∈ , x + y = 0 Negation: ~ (∀x ∈ ,, ∃y ∈ , x + y = 0 ) ≡ ∃x ∈ ,, ∀y ∈ , x + y ≠ 0 False: Take y = − x , then x + y = x − x = 0 WUCT121 Logic 83 • Statement: ∃x ∈ ,, ∀y ∈ , xy = 1 Negation: ~ (∃x ∈ ,, ∀y ∈ , xy = 1) ≡ ∀x ∈ ,, ∃y ∈ , xy ≠ 1 True : Take y = − x, then xy = − x 2 ≠ 1 Exercises: Write the negation of the following: • Statement: ∀c ∈ colours, ∃a ∈ animals, a is coloured c Negation: ≡ ~ (∀c ∈ colours, ∃a ∈ animals, a is coloured c ) ≡ ∃c ∈ colours, ∀a ∈ animals, a is not coloured c There is a colour which every animal is not. True, my cat is not purple. • Statement: ∃b ∈ books, ∀p ∈ people, p has read b Negation: ≡ ~ (∃b ∈ books, ∀p ∈ people, p has read b ) ≡ ∀b ∈ books, ∃p ∈ people, p has not read b There is someone who has not read every book. True, me, I’ve not read every book. WUCT121 Logic 84 Section 3. 3.1. Proofs Introduction. A proof is a carefully reasoned argument which establishes that a given statement is true. Logic is a tool for the analysis of proofs. Each statement within a proof is an assumption, an axiom, a previously proven theorem, or follows from previous statements in the proof by a mathematical or logical rules and definitions. 3.1.1. Assumptions. Assumptions are the statements you assume to be true as you try to prove the result. Example: If you want to prove: “If x ∈ and n ∈ is even, then x n > 0 ” Your proof should start with the assumptions that x ∈ and n ∈ is even. Further, you can use the “definition” of an even natural number, and write the assumptions as follows: Let x ∈ , and n ∈ be even, that is, ∃p ∈ , n = 2 p . WUCT121 Logic 85 Assumptions are often thought to be the “given information” or information we “know” that can be used in our proof. As in the example above, when you are proving statements of the form P ⇒ Q , then the assumption is the statement P. Exercise: Write the statement to be proven in the previous example using logical notation: [( x ∈ ) ∧ ( n ∈ : ∃p ∈ , n = 2 p )] ⇒ x n > 0 3.1.2. Axioms. Axioms are laws in Mathematics that hold true and require no proof. Examples: • x=x • x+0 = x • ∀x, y , z ∈ , [ ( x = y ) ∧ ( y = z )] ⇒ ( x = z ) WUCT121 Logic 86 3.1.3. Mathematical Rules. Mathematical Rules are known rules that are often used. Example: ∀x, y , z ∈ , ( x = y ) ⇒ ( x + z = y + z ) 3.1.4. Logical Rules. Logical Rules are rules of logic such as Substitution and Substitution of Equivalence using the laws introduced earlier 3.2. The Law of Syllogism If P ⇒ Q and Q ⇒ R are both tautologies, then so is P ⇒ R. Exercise: • Write the Law of Syllogism using logical notation: (( P ⇒ Q ) ∧ (Q ⇒ R )) ⇒ ( P ⇒ R ) WUCT121 Logic 87 • Show, using the quick method that the Law of Syllogism is a tautology. ((P Step: 1. 2. 3. 4. 5. ⇒ 1 Q) ∧ 3 (Q ⇒ 2 R)) ⇒ 5* F (P T ⇒ 4 F T T T F T T F F 1. Place “F” under main connective 2. For “F” to occur under the main connective, ∧ must be “T” and ⇒ must be “F” 3. For “F” to occur under ⇒ , P must be “T” and R must be “F”. 4. For “T” under ∧ , both ⇒ must be “T” 5. For the first ⇒ to be true, given P is “T”, Q must be “T”. For the second ⇒ to be true, given R is “F”, Q must be “F”. Q cannot be both “T” and “F”, thus (( P ⇒ Q ) ∧ (Q ⇒ R )) ⇒ ( P ⇒ R ) can only ever be true and is a tautology. WUCT121 R) Logic 88 Examples: • s is a square ⇒ s is a rectangle s is a rectangle ⇒ s is a parallelogram s is a parallelogram ⇒ s is a quadrilateral ∴ s is a square ⇒ s is a quadrilateral. • x 2 ≥ 0 ⇒ ( x − 3) 2 ≥ 0 ( x − 3) 2 ≥ 0 ⇒ ( x 2 − 6 x + 9) ≥ 0 ( x 2 − 6 x + 9) ≥ 0 ⇒ x 2 − 6 x ≥ −9 ∴ x 2 ≥ 0 ⇒ x 2 − 6 x ≥ −9 Exercise: Complete the following using the Law of Syllogism: • t is studying WUCT121 ⇒ t is enrolled in a diploma t is enrolled in a diploma ⇒ t is student at WCA. ∴ t is studying WUCT121 ⇒ t is student at WCA. • x ∈ ⇒ x ∈ x ∈ ⇒ x ∈ x ∈ ⇒ x ∈ ∴ x ∈ ⇒ x ∈ WUCT121 Logic 89 Most results in Mathematics that require proofs are of the form P ⇒ Q . The Law of Syllogism provides the most common method of performing proofs of such statements. The Law of Syllogism is a kind of transitivity that can apply to ⇒ . To use the Law of Syllogism, we set up a sequence of statements, P ⇒ P1 , P1 ⇒ P2 , P2 ⇒ P3 ,K , Pn ⇒ Q . Then, by successive applications of the law, we have P ⇒ Q. Example. We wish to prove that for n ∈ , if n is even, then n 2 is even. In logic notation, we wish to prove: n is even (P) ⇒ n 2 is even (Q). This has the form P ⇒ Q and we note that our assumption includes n ∈ and P: n is even. WUCT121 Logic 90 Proof: K( P ⇒ P1 ) n is even ⇒ ∃p ∈ , n = 2 p ∃p ∈ , n = 2 p ⇒ n 2 = 4 p 2 K( P1 ⇒ P2 ) K( P2 ⇒ P3 ) n 2 = 4 p 2 ⇒ n 2 = 2( 2 p 2 ) n 2 = 2( 2 p 2 ) ⇒ n 2 is even K( P3 ⇒ Q ) Completing the proof is simply a matter of applying the Law of Syllogism three times to get n is even ⇒ n 2 is even. The previous proof can be simplified to: n is even ⇒ ∃p ∈ , n = 2 p ⇒ n2 = 4 p 2 ⇒ n 2 = 2( 2 p 2 ), 2 p 2 ∈ ⇒ n 2 is even The use of Law of Syllogism is a matter of common sense. We shall use the Law of Syllogism without direct reference. Note. The use of the connective ⇒ in the previous proof seems a little repetitive, albeit valid. For variety, the connective can be replaced by words such as therefore, thus, so we have, and hence. WUCT121 Logic 91 3.3. Modus Ponens 3.3.1. Rule of Modus Ponens: If P and P ⇒ Q are both tautologies, then so is Q. In other words, Modus Ponens simply says that if we know P to be true, and we know that P implies Q, then Q must also be true. Exercise: • Write the rule of Modus Ponens using logical notation: ( P ∧ ( P ⇒ Q )) ⇒ Q WUCT121 Logic 92 • Show, using the quick method that the rule of Modus Ponens is a tautology. (P Step ∧ 2 (P ⇒ Q)) ⇒ 1 Q 3* F 1. Place “F” under main connective. 2. For “F” to occur under the T F main connective, ∧ must be “T” and Q must be “F” 3. For “T” to occur under ∧ , P T T must be “T” and P ⇒ Q must be “T” 4. For “T” to occur under F F P ⇒ Q ,when P is “F” P must be “F” P cannot be both “T” and “F”, thus (( P ⇒ Q ) ∧ P ) ⇒ Q can only ever be true and is a tautology. WUCT121 Logic 93 Examples: • If Zak is a cheater, then Zak sits in the back row Zak is a cheater Therefore Zak sits in the back row. • If 2 = 3 then I will eat my hat 2=3 Therefore I will eat my hat Exercise: Complete the following using Modus Ponens • If Zeus is a God, then Zeus is immortal Zeus is a God Therefore Zeus is immortal. • If it is sunny then I will go to the beach It is sunny Therefore I will go to the beach • If I study hard then I will pass I study hard Therefore I will pass WUCT121 Logic 94 3.3.2. Universal Rule of Modus Ponens: If P(x) and Q(x) are predicates, the universal rule of Modus Ponens is (( P( x ) ⇒ Q ( x )) ∧ P( a )) ⇒ Q ( a ) . This means Modus Ponens can be applied to predicates using specific values for the variables in the domain. Examples: • If x is even [P(x)], then x 2 is even [Q(x)] x = 98374 [P(a)] Therefore 98374 2 is even. [Q(a)] • The Principle of Mathematical Induction says that when you have a statement, Claim(n), that concerns n ∈ , ⎧Claim(1) If P : ⎨ then Claim(n) is ⎩Claim( k ) ⇒ Claim( k + 1), ∀k ∈ true for all n ∈ (Q) Thus we have P ⇒ Q . WUCT121 Logic 95 Exercise: According to Modus Ponens, what must we establish so we can apply this principle to the following statement and be able to say “Claim(n) is true for all n ∈ ”? • Claim(n): 4 n − 1 is a multiple of 3. We must show that Claim(n) satisfies P. So we need to establish two things: 1. Claim(1), i.e. 41 − 1 is a multiple of 3; AND 2. Claim( k ) ⇒ Claim( k + 1), ∀k ∈ , i.e. If 4 k − 1 is a multiple of 3 for all k ∈ , then 4 (k +1) − 1 is a multiple of 3. WUCT121 Logic 96 3.4. Modus Tollens 3.4.1. Rule of Modus Tollens: If ~Q and P ⇒ Q are both tautologies, then so is ~P. In other words, Modus Ponens simply says that if we know ~Q to be true, and we know that P implies Q, then ~P must also be true. Similarly if we know Q to be false, and we know that P implies Q, then P must also be false Exercise: • Write the rule of Modus Ponens using logical notation: (( P ⇒ Q )∧ ~ Q ) ⇒ ~ P WUCT121 Logic 97 • Show, using the quick method that the rule of Modus Tollens is a tautology. ((P ⇒ Q) Step: 2 ∧ 3 ~Q ⇒ 1 1.Place “F” under main 4* ~P 5 F connective T 2. For “F” to occur under F the main connective, ∧ must be “T” and ~P must be “F” T 3. For “T” to occur under T ∧ , ~Q must be “T” and P ⇒ Q must be “T” 4. For “T” to occur under T T P ⇒ Q ,when P is “T”, Q must be “T” At step 2, ~P is “F”, thus P is “T”. Step 3 shows ~Q is “T” thus Q is “F” and step 4 gives Q is “T”. Q cannot be both “T” and “F”, thus (( P ⇒ Q ) ∧ ~ Q ) ⇒ ~ P can only ever be true and is a tautology. WUCT121 Logic 98 Examples: • If Zak is a cheater, then Zak sits in the back row Zak sits in the front row Therefore Zak is not a cheater. • If 2 > 3 then Earth is flat The Earth is not flat Therefore 2 u 3 Exercise: Complete the following using Modus Tollens • If Zeus is a God, then Zeus is immortal Zeus is not immortal Therefore Zeus is not a God. • If I go to the beach then it is sunny It is not sunny Therefore I don’t go to the beach • If I arrive on time then I will be marked present I was marked absent Therefore I did not arrive on time. WUCT121 Logic 99 3.4.2. Universal Rule of Modus Tollens: If P(x) and Q(x) are predicates, the universal rule of Modus Tollens is: (( P( x ) ⇒ Q ( x ))∧ ~ Q ( a )) ⇒ ~ P( a ) . This means Modus Tollens can be applied to predicates using specific values for the variables in the domain. Example: • If x ∈ , then ∃a , b ∈ , b ≠ 0, x = a b x= 2 Therefore 2 ∉ . Exercise: Complete the following using the universal rule of Modus Tollens • If x ∈ , then x ≥ 1 x = −1 Therefore − 1 ∉ . WUCT121 Logic 100 3.5. Proving Quantified Statements 3.5.1. Proving Existential Statements A statement of the form ∃x ∈ D , P ( x ) is true if and only if P ( x ) is true for at least one x ∈ D . To prove this kind of statement, we need to find one x ∈ D that makes P ( x ) true. Examples: • Prove that there exists an even integer that can be written two ways as the sum of two primes. The statement is of the form ∃x ∈ D , P ( x ) , where D is the set of even integers and P(x) is the statement “x can be written as the sum of two primes” Thus we need find only one even integer which satisfies P(x). Essentially, to find the appropriate number, we have to “guess”. Consider 14 = 7 + 7 (7 is prime); and 14 = 3 + 11 (3 and 11 are prime). Therefore, there exists an even integer that can be written two ways as the sum of two primes. WUCT121 Logic 101 • Let r , s ∈ . Prove ∃k ∈ , 22r + 18s = 2k The statement is of the form ∃k ∈ D, P (k ), where D is the set of integers and P(k) is the statement: “ 22r + 18s = 2k ”. Thus we need find only one integer which satisfies P(k) 22r + 18s = 2(11r + 9 s ) = 2k where k = 11r + 9 s ∈ Exercises: • Prove ∃x ∈ , x + 5 = 0 . Let x = −5 ∈ , then x + 5 = −5 + 5 = 0 . • Prove that if a , b ∈ ,then 10a + 8b is divisible by 2 (i.e., is even). 10a + 8b = 2(5a + 4b ) and 5a + 4b ∈ . Thus, 2 (10a + 8b ). WUCT121 Logic 102 3.5.2. Proving Universal Statements A statement of the form ∀x ∈ D , P ( x ) is true if and only if P ( x ) is true for at every x ∈ D . To prove this kind of statement, we need prove that for every x ∈ D , P ( x ) is true. In order to prove this kind of statement, there are two methods: Method 1: Method of Exhaustion. The method of exhaustion is used when the domain is finite. Exhaustion cannot be used when the domain is infinite. To perform the method of exhaustion, every member of the domain is tested to determine if it satisfies the predicate. WUCT121 Logic 103 Example: • Prove the following statement: Every even number between 2 and 16 can be written as a sum of two prime numbers. The statement is of the form ∀x ∈ D, P ( x ), where D = {4, 6, 8,10,12,14},and P(x) is the statement “x can be written as the sum of two prime numbers”. The domain D is finite so the method of exhaustion can be used. Thus we must test every number in D to show they can be written as the sum of two primes. 4 = 2+2 6 = 3+3 8 = 3+5 10 = 5 + 5 12 = 5 + 7 14 = 7 + 7 Thus by the method of exhaustion every even number between 2 and 16 can be written as a sum of two prime numbers. WUCT121 Logic 104 Exercise: • Prove for each integer n with 1 ≤ n ≤ 10 , n 2 − n + 11 is prime. The statement is of the form ∀n ∈ D, P (n ) , where D = {1, 2, 3, 4, 5, 6, 7, 8, 9,10},and P(n) is the statement “ n 2 − n + 11 is prime”. Thus we must show all numbers in D satisfy P(n). P(1) = 12 − 1 + 11 = 11 is prime P( 2) = 2 2 − 2 + 11 = 13 is prime P(3) = 32 − 3 + 11 = 17 is prime P( 4) = 4 2 − 4 + 11 = 23 is prime P(5) = 5 2 − 5 + 11 = 31 is prime P(6) = 6 2 − 6 + 11 = 41 is prime P(7) = 7 2 − 7 + 11 = 53 is prime P(8) = 8 2 − 8 + 11 = 67 is prime P(9) = 9 2 − 9 + 11 P(10) = 10 2 − 10 + 11 = 89 is prime = 101 is prime Thus by the method of exhaustion for each integer n with 1 ≤ n ≤ 10 , n 2 − n + 11 is prime. WUCT121 Logic 105 Method 2: Generalised Proof. The generalised proof method is used when the domain is infinite. It is called the method of generalizing from the generic particular. In order to show that every element of the domain satisfies the predicate, a particular but arbitrary element of the domain is chosen and shown to satisfy the predicate. The method to show the predicate is satisfied will vary depending on the form of the predicate. Specific techniques of generalized proof will be outlined later in this section. WUCT121 Logic 106 Example: • Pick any number, add 3, multiply by 4, subtract 6, divide by two and subtract twice the original. The result is 3. Proof: Choose a particular but arbitrary number, say x, and then determine if it satisfies the statement. Step Result Pick a number x Add 3 x+3 Multiply by 4 ( x + 3) × 4 = 4 x + 12 Subtract 6 4 x + 12 − 6 = 4 x + 6 Divide by 2 ( 4 x + 6) ÷ 2 = 2 x + 3 Subtract twice the original 2x + 3 = 2x = 3 In this example, x is particular in that it represents a single quantity, but arbitrarily chosen as it can represent any number. WUCT121 Logic 107 3.6. Disproving Quantified Statements 3.6.1. Disproving Existential Statements A statement of the form ∃x ∈ D , P ( x ) is false if and only if P ( x ) is false for all x ∈ D . To disprove this kind of statement, we need to show the for all x ∈ D , P ( x ) is false. That is we need to prove it’s negation: ~ (∃x ∈ D, P( x )) ≡ ∀x ∈ D , ~ P( x ) This is equivalent to proving a universal statement and so the method of exhaustion or the generalized proof method is used. Example: • Disprove: There exists a positive number n such that n 2 + 3n + 2 is prime. Proving the given statement is false is equivalent to proving its negation is true. That is proving that for all numbers n , n 2 + 3n + 2 is not prime. Since this statement is universal, its proof requires the generalised proof method. WUCT121 Logic 108 3.6.2. Disproving Universal Statements A statement of the form ∀x ∈ D , P ( x ) is false if and only if P ( x ) is false for at least one x ∈ D . To disprove this kind of statement, we need to find one x ∈ D such that P ( x ) is false. That is we need to prove it’s negation: ~ (∀x ∈ D , P( x )) ≡ ∃x ∈ D , ~ P( x ) This is known as finding a counterexample. Example: • Disprove: ∀a , b ∈ , ( a 2 = b 2 ) ⇒ ( a = b ). Let P( a , b ) : ( a 2 = b 2 ) ⇒ ( a = b ) . We need to show ∃a , b ∈ , ~ P( a , b ) Counterexample: Let a = 1, b = −1. Then a 2 = b 2 however a ≠ b . Now true ⇒ false is false, thus P( a , b ) is false, and ~ P( a , b ) is true So, we have shown, by counterexample ∃a , b ∈ , ~ P( a , b ) WUCT121 Logic 109 Exercises: • Disprove: ∀x ∈ , ( x > 0 ∨ x < 0). Need to prove: ∃x ∈ , ~ ( x > 0 ∨ x < 0). That is ∃x ∈ , ( x ≤ 0 ∧ x ≥ 0). Let x = 0 . • Disprove ∀z ∈ , ( z is odd ) ⇒ ( Let z = 5 ∈ , ( z is odd ) , ( • z −1 is odd ). 2 5 −1 4 = = 2 is even). 2 2 Prove or disprove: ∀x ∈ , ∃y ∈ , ( x + y = 0). To prove the statement: Find a specific y for each “general” x. Consider an x ∈ . Let y = − x ∈ , then x + y = x + (− x ) = 0 . WUCT121 Logic 110 3.7. Generalised Proof Methods Before proving a statement, it is of great use to write the statement using logic notation, including quantifiers, where appropriate. Doing this means you have clearly written the assumptions you can make AND the conclusion you are aiming to reach. Example: • Prove: For all integers n, if n is odd, then n 2 is odd. Rewritten using logic notation: ∀n ∈ , n is odd ⇒ n 2 is odd Here the domain is given as , , and the predicate involves the statements: P(n) is n is odd, Q(n) is n 2 is odd. The form of the predicate is P( n ) ⇒ Q ( n ) . Thus the assumption that can be made is P(n) and the conclusion to be reached is Q(n). WUCT121 Logic 111 3.7.1. Direct Proof A direct proof is one in which we begin with the assumptions and work in a straightforward fashion to the conclusion. The steps in the final proof must proceed in the correct “direction” beginning with the initial assumption and following known laws, rules, definitions etc. until the final conclusion is reached. The proof must not start with what you are trying to prove. Example: • Prove that if 3 x − 9 = 15 then x = 8 . Assuming the domain to be , then the statement is of the form ∀x ∈ , P( x ) ⇒ Q( x ) . Thus the assumption is P( x ) : 3 x − 9 = 15 , and the conclusion Q( x ) : x = 8 . 3 x − 9 = 15 ⇒ 3 x − 9 + 9 = 15 + 9 ⇒ 3 x = 24 3 x 24 ⇒ = 3 3 ⇒ x=8 WUCT121 Logic 112 Exercise: • Prove: For all integers n, if n is odd, then n 2 is odd. Rewritten using logic notation: ∀n ∈ , n is odd ⇒ n 2 is odd Here the domain is given as , , and the predicate involves the statements: P(n) is n is odd, Q(n) is n 2 is odd. The form of the predicate is P( n ) ⇒ Q ( n ) . Thus the assumption that can be made is P(n) and the conclusion to be reached is Q(n). Proof: n is odd ⇒ n = 2 p + 1 p ∈ definition of odd ⇒ n 2 = ( 2 p + 1) 2 ⇒ n2 = 4 p2 + 4 p + 1 ⇒ n 2 = 2( 2 p 2 + 2 p ) + 1 WUCT121 ⇒ n 2 = 2q + 1 q = 2 p2 + 2 p ∈ ⇒ n 2 is odd definition of odd Logic 113 When the statement to be proven is of the form: P( x ) ⇒ Q( x ) , the assumption which begins the proof is P( x ). If the form is not P( x ) ⇒ Q( x ) , or P( x ) is not clear, it may be necessary to examine what you are aiming to prove and establish an assumption from which to begin. Example: • ( ) Prove that for x ∈ , − x 2 + 2 x + 1 ≤ 2 . (Do not start with this!) In this case, the form is not P( x ) ⇒ Q( x ) . By examining what we are aiming to prove, i.e. (− x 2 + 2 x + 1) ≤ 2 a beginning to the proof can be found. ⎧− x 2 + 2 x + 1 ≤ 2 ⇒ x 2 − 2 x − 1 ≥ −2 ⎪⎪ ⇒ x2 − 2 x + 1 ≥ 0 working : ⎨ ⎪ ⇒ ( x − 1)2 ≥ 0 is true. ⎪⎩ We can now put the proof together: We know that ( x − 1)2 ≥ 0 for any x ∈ . Thus, WUCT121 Logic 114 ( x − 1)2 ≥ 0 what is known ⇒ x2 − 2x + 1 ≥ 0 expanding ⇒ x 2 − 2 x − 1 ≥ −2 subtracting 2 from both sides ⇒ − x2 + 2x + 1 ≥ 2 multiplying by − 1 Note. In the example, we did NOT start with the statement (− x 2 + 2 x + 1) ≤ 2 , as we technically do not know whether it is true or not. We started our proof with a statement we know to be true. Exercise: • Prove the following: If the right angled triangle XYZ with sides of length x and y z2 , then the triangle is and hypotenuse z has an area of 4 X isosceles. z y Y WUCT121 x Z Logic 115 The form of statement is P( x ) ⇒ Q( x ) . What is known. i.e. the assumptions that can be made are: • z2 Area of the triangle: A = , 4 • Area of any triangle: = 1 × (base) × (height ) = 1 xy 2 • (1) (2) 2 The sides are of length x and y and hypotenuse z so by Pythagoras: z 2 = x 2 + y 2 . (3) What is to be proven: That triangle XYZ is isosceles. Thus we must show two sides have equal length. Proof: Substituting (3) into (1) and equating with (2) gives: x 2 + y 2 xy = 4 2 x 2 + y 2 xy = ⇒ x 2 + y 2 = 2 xy 4 2 ⇒ x 2 − 2 xy + y 2 = 0 (multiplying both sides by 4) ⇒ (x − y ) = 0 ⇒x= y 2 So two sides are equal and thus triangle XZY is isosceles. WUCT121 Logic 116 3.8. Indirect Proofs. 3.8.1. Method of Proof by Contradiction The method of proof by contradiction can be used when the statement to be proven is not of the form P( x ) ⇒ Q( x ) . The method is as follows: Suppose the statement to be proven is false. That is, 1. suppose that the negation of the statement is true. 2. Show that this supposition leads to a contradiction 3. Conclude that the statement to be proven is true. Example: • Prove there is no greatest integer. Suppose not, that is suppose there is a greatest integer. N. Then N ≥ n for every integer n. Let M = N + 1 . Now M is an integer since it is the sum of integers. Also M > N since M = N +1 Thus M is an integer that is greater than N. So N is the greatest integer and N is not the greatest integer, which is a contradiction. Thus the assumption that there is a greatest integer is false, hence there is no greatest integer is true. WUCT121 Logic 117 Exercise: • Prove there is no integer that is both even and odd. Suppose not, that is suppose there is a greatest integer an integer n, that is both even and odd. By the definition of even n = 2k , k ∈ K (1) , and by the definition of odd n = 2l + 1, l ∈ K ( 2) . If n is both even and odd then equation (1) and (2) gives: 2k = 2l + 1 ⇒ 2k − 2l = 1 ⇒ 2( k − l ) = 1 1 ⇒ k −l = ∉ 2 Now since k and l are integers, the difference k – l must be an integer. However k − l = 1 ∉ . Thus k – l is an integer 2 and k – l is not an integer, which is a contradiction. Thus the supposition is false and hence the statement “There is no integer that is both even and odd” is true. WUCT121 Logic 118 3.8.2. Proof by Contraposition Recall the following logical equivalence: ( P ⇒ Q ) ≡ (~ Q ⇒ ~ P ). (~ Q ⇒ ~ P ) is known as the contrapositive of ( P ⇒ Q ) . This equivalence indicates that if (~ Q ⇒ ~ P ) is a true statement, then so too is ( P ⇒ Q ) . Thus, in order to prove ( P ⇒ Q ) , we prove the contrapositive, that is (~ Q ⇒ ~ P ) , is true. The method of proof by contraposition can be used when the statement to be proven is of the form P( x ) ⇒ Q( x ) . The method is as follows: 1. Express the statement to be proven in the form: ∀x ∈ D , P( x ) ⇒ Q ( x ). 2. Rewrite the statement in the contrapositive form: ∀x ∈ D, ~ Q( x ) ⇒ ~ P( x ). 3. a. Prove the contrapositive by a direct proof. Suppose that x is a particular but arbitrary element of D, such that Q(x) is false. b. WUCT121 Show that P(x) is false. Logic 119 Example: • Prove that for all integers n if n 2 is even, n is even. The statement can be expressed in the form: ∀n ∈ , n 2 is even ⇒ n is even. Thus the contrapositive is ∀n ∈ , n is not even ⇒ n 2 is not even. That is ∀n ∈ , n is odd ⇒ n 2 is odd. To prove the contrapositive: Let n be any odd integer. Then n = 2k + 1, k ∈ K(1) Show n 2 is odd, i.e. show n 2 = 2l + 1, l ∈ n 2 = ( 2k + 1)2 by (1) = 4k 2 + 4k + 1 = 2( 2k 2 + 2k ) + 1 = 2l + 1 l = 2k 2 + 2k ∈ So n 2 is odd, and the contrapositive is true. Hence the statement “for all integers n if n 2 .is even, n is even” is also true. WUCT121 Logic 120 Exercise: • Prove that for all integers n if 5 /| n 2 .then 5 /| n . The statement can be expressed in the form: ∀n ∈ , 5 /| n 2 ⇒ 5 /| n. Thus the contrapositive is ∀n ∈ , 5 | n ⇒ 5 | n 2 . To prove the contrapositive: Let n be any odd integer. Then 5 | n ⇒ n = 5k , k ∈ K (1) Show 5 | n 2 , i.e. show n 2 = 5l , l ∈ n 2 = (5k ) 2 by (1) = 25k 2 = 5(5k 2 ) = 5l l = 5k 2 ∈ So 5 | n 2 , and the contrapositive is true. Hence the statement “for all integers n if 5 /| n 2 .then 5 /| n ” is also true. WUCT121 Logic 121 Exercise: • Prove if y is irrational, then y + 7 is irrational. The statement can be expressed in the form: ∀y ∈ , y ∉ ⇒ y + 7 ∉ Thus the contrapositive is ∀y ∈ , y + 7 ∈ ⇒ y ∈ To prove the contrapositive: Let. y ∈ , y + 7 ∈ , so y + 7 = Show y ∈ , that is y = c , d a , b a , b ∈ , b ≠ 0 . c , d ∈ , d ≠ 0 a a ⇒ y = −7 b b a − 7b ⇒y= b c ⇒ y = c = a − 7b, d = b ∈ , d ≠ 0 d y +7 = Therefore y ∈ , and the contrapositive is true. Hence the statement “if y is irrational, then y + 7 is irrational” is also true. WUCT121 Logic 122 3.8.3. Proof by Cases When the statement to be proven is of the form, or can be written in the form: ( P ∨ Q ) ⇒ R , the method of proof by cases can be used. It relies on the logical equivalence (( P ⇒ R ) ∧ (Q ⇒ R )) ≡ (( P ∨ Q ) ⇒ R ). The method is as follows: 1. Prove P ⇒ R 2. Prove Q ⇒ R. 3. Conclude ( P ∨ Q ) ⇒ R. If the statement is not written in the form ( P ∨ Q ) ⇒ R , it is necessary to establish the particular cases by exhaustion. WUCT121 Logic 123 Example: • Prove: If x ≠ 0 or y ≠ 0 , then x 2 + y 2 > 0 . The statement can be expressed in the form: ( x ≠ 0) ∨ ( y ≠ 0) ⇒ x 2 + y 2 > 0 We assume x, y ∈ , thus x 2 ≥ 0, y 2 ≥ 0. Proof: Case 1: Prove x ≠ 0 ⇒ x 2 + y 2 > 0 2 2 Let x ≠ 0 , then x > 0 and y ≥ 0 . Thus x 2 + y 2 > 0 . Case 2: Prove y ≠ 0 ⇒ x 2 + y 2 > 0 Let y ≠ 0 , then y 2 > 0 and x 2 ≥ 0 . Thus x 2 + y 2 > 0 . Therefore If x ≠ 0 or y ≠ 0 , then x 2 + y 2 > 0 . WUCT121 Logic 124 Exercise. • Prove: If x ≤ −2 or x ≥ 2 , then x 2 − 4 ≥ 0 . The statement can be expressed in the form: ( x ≤ −2) ∨ ( x ≥ 2) ⇒ x 2 − 4 ≥ 0 Proof: Case 1: Prove x ≤ −2 ⇒ x 2 − 4 ≥ 0 x ≤ −2 ⇒ x2 ≥ 4 ⇒ x2 − 4 ≥ 0 Therefore x ≤ −2 ⇒ x 2 − 4 ≥ 0 Case 2: Prove ( x ≥ 2 ⇒ x 2 − 4 ≥ 0 x≥2 ⇒ x2 ≥ 4 ⇒ x2 − 4 ≥ 0 Therefore x ≥ 2 ⇒ x 2 − 4 ≥ 0 Thus if x ≤ −2 or x ≥ 2 , then x 2 − 4 ≥ 0 . WUCT121 Logic 125 If the statement is not written in the form ( P ∨ Q ) ⇒ R , it is necessary to establish the particular cases by exhaustion. Example. • Prove: ∀m ∈ , m 2 + m + 1 is odd. The statement is not in the form ( P ∨ Q ) ⇒ R. However by considering m ∈ ⇒ ( m is even) ∨ ( m is odd ) . Then the statement can be expressed in the form: ( m is even) ∨ ( m is odd ) ⇒ m2 + m + 1 is odd Case 1: Prove m is even ⇒ m 2 + m + 1 is odd m is even ⇒ m = 2 p, p∈ m 2 + m + 1 = (2 p )2 + 2 p + 1 K (1) . by (1) = 4 p2 + 2 p +1 ( ) = 2 2 p2 + p +1 ( ) = 2k + 1, where k = 2 p 2 + p ∈ Therefore, m is even ⇒ m 2 + m + 1 is odd . WUCT121 Logic 126 Case 2: Prove m is odd ⇒ m 2 + m + 1 is odd m is odd ⇒ m = 2q + 1, q ∈ K(2) . m 2 + m + 1 = (2q + 1)2 + 2q + 1 + 1 by ( 2) = 4q 2 + 4q + 1 + 2q + 1 + 1 = 4q 2 + 6q + 2 + 1 ( ) = 2 2q 2 + 3q + 1 + 1 ( ) = 2l + 1, where l = 2q 2 + 3q + 1 ∈ Therefore, m is odd ⇒ m 2 + m + 1 is odd . Therefore, ( m is even) ∨ ( m is odd ) ⇒ m2 + m + 1 is odd . Therefore, ∀m ∈ , m 2 + m + 1 is odd. WUCT121 Logic 127 Exercise. • Prove: ∀n ∈ , n 2 − n + 3 is odd. The statement is not in the form ( P ∨ Q ) ⇒ R. However by considering n ∈ ⇒ ( n is even) ∨ ( n is odd ) . Then the statement can be expressed in the form: ( n is even) ∨ ( n is odd ) ⇒ n 2 − n + 3 is odd Case 1: Prove n is even ⇒ n 2 − n + 3 is odd n is even ⇒ n = 2 p, p ∈ K (1) . n 2 − n + 3 = (2 p )2 − 2 p + 3 by (1) = 4 p2 − 2 p + 2 +1 ( ) = 2 2 p2 − p +1 +1 ( ) = 2k + 1, where k = 2 p 2 − p + 1 ∈ Therefore, n is even ⇒ n 2 − n + 3 is odd . WUCT121 Logic 128 Case 2: Prove n is odd ⇒ n 2 − n + 3 is odd n is odd ⇒ n = 2q + 1, q ∈ K(2) . n 2 − n + 3 = (2q + 1)2 − (2q + 1) + 3 by (2) = 4q 2 + 4q + 1 − 2q − 1 + 3 = 4q 2 + 2q + 2 + 1 ( ) = 2 2q 2 + q + 1 + 1 ( ) = 2l + 1, where l = 2q 2 + q + 1 ∈ Therefore, n is odd ⇒ n 2 − n + 3 is odd . Therefore, ( n is even) ∨ ( n is odd ) ⇒ n 2 − n + 3 is odd . Therefore, ∀n ∈ , n 2 − n + 3 is odd. WUCT121 Logic 129 Section 4. 4.1. Set Theory Definitions A set may be viewed as any well defined collection of objects, called elements or members of the set. Sets are usually denoted with upper case letters, A, B, X, Y,… while lower case letters are used to denote elements a, b, x, y,…of a set. Membership in a set is denoted as follows: • a ∈ S denotes that a is a member or element of a set S. Similarly a , b ∈ S denotes that a and b are both elements of a set S. • a ∉ S denotes that a is not an element of a set S. Similarly a , b ∉ S denotes that neither of a and b are elements of a set S. In Set Theory, we work within a Universe, U, and consider sets containing elements from U. WUCT121 Logic 130 A set may be specified in essentially two ways: The elements of the set are listed within braces, { 1. }, and separated by commas. Technically, the listing of elements can be done only for finite sets. However, if an infinite set is defined by a “simple” rule, we sometimes write a few elements and then use “…” to mean roughly “and so on” or “by the same rule”. Examples: • A = {1, 3, 5, 7, 9} . The set A is the finite collection of odd integers, 1 to 9 inclusive • B = {K, − 4, − 2, 0, 2, 4,K}. The set B is the infinite collection of even integers. Exercises: • List a finite set, C, containing even integers between 10 and 20 inclusive. C = {10,12,14,16,18, 20} • List an infinite set, D, containing natural numbers that are divisible by 3 D = {0, 3, 6, 9,K} WUCT121 Logic 131 2. A statement defining the properties which characterise the elements in the set is written within braces Examples: • A = {z ∈ :( z is odd ∧ 1 ≤ z ≤ 9)}. The set A is the finite collection of odd integers, 1 to 9 inclusive • B = {z ∈ : ∃k ∈ , z = 2k } . The set B is the infinite collection of even integers. Exercises: • Define a finite set, C, containing even integers between 10 and 20 inclusive C = {z ∈ : ( z is even ∧ 10 ≤ z ≤ 20)} • Define an infinite set, D, containing natural numbers that are divisible by 3 D = {n ∈ : 3 | n} WUCT121 Logic 132 4.1.2. Axiom of Specification. Given a Universe U and any statement P( x ) involving x ∈ U , then there exists a set A such that ∀x ∈ U , ( x ∈ A ⇔ P( x )). Further, we write A = { x ∈ U : P( x )}. In other words, the Axiom of Specification says that we can pick a set and a property and build a new set. This is why the notation for A is sometimes referred to as set-builder notation. Example: Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} and P( x ) be the statement “x is odd”. \ by the Axiom of Specification, A = { x ∈U : x is odd}. Notes: 1. We know an element x belongs to the set A = { x ∈ U : P( x )} if x satisfies the condition P( x ) . 2. This notation is more simply written { x ∈ D : P( x )} . This is called set builder notation. In using this notation, the elements of the domain, D, must belong to the Universe, U, WUCT121 Logic 133 and P ( x ) can be any predicate involving x. D could be all of U. Examples: • The interval [0, 1] can be written in set builder notation as: {x : x ∈ ∧ 0 ≤ x ≤ 1} = {x ∈ : 0 ≤ x ≤ 1} • The set of all rational numbers, – can be written as: ⎧a ⎫ = ⎨ : a, b ∈ ∧ b ≠ 0⎬ ⎩b ⎭ a ⎧ ⎫ = ⎨ x : x = : a, b ∈ ∧ b ≠ 0⎬ b ⎩ ⎭ • { x ∈ : x 3 = x} = {0, 1, − 1} . Exercises: Write down the following sets by listing their elements: • { x ∈ : x 3 = x} = {1} • { x ∈ : x 2 = 9} = {−3, 3} • { x ∈ : x 2 = 7} = { } WUCT121 Logic 134 4.2. Venn Diagrams Venn diagrams are a pictorial method of demonstrating the relationship between set. The universal set, U, is represented by a rectangle and sets within the universe are depicted with circles. While a Venn diagram may be used to demonstrate the relationship between sets, it does not provide a method of proving those relationships. WUCT121 Logic 135 4.3. Special Sets 4.3.1. The Singleton Set Sets having a single element are frequently called singleton sets. Example: • {1} is read “singleton 1”. • If a ∈U , then { x ∈U : x = a} = {a} Note: The singleton set {a} is NOT the same as the element a. 4.3.2. The Empty Set The empty set or null set is a set which contains no elements. It is denoted by the symbol ∆ or by empty braces { }. Using set builder notation, one way of defining the empty set is: ∆ = { x ∈ : x ≠ x} WUCT121 Logic 136 4.4. Subsets 4.4.1. Definition: Subset. If A and B are sets, then A is called a subset of B, written A ⊆ B , if and only if, every element in A is also in B. Examples: • {1, 2} ⊆ {1, 2, 3} • The Venn diagram demonstrating A ⊆ B is: Exercises: • Write the definition of subset using logic notation. A ⊆ B ⇔ (∀x ∈ U , x ∈ A ⇒ x ∈ B ) • Is {cat, dog} ⊆ {bird, fish, cat, dog}? Yes WUCT121 Logic 137 4.4.2. Definition: Proper Subset. If A and B are sets, then A is called a proper subset of B, written A ⊂ B , if and only if, every element in A is also in B but there is at least one element of B that is not in A. A is a proper subset of B if A ⊆ B but A ≠ B . Examples: • {1, 2} ⊂ {1, 2, 3} Exercises: • Draw a Venn diagram demonstrating A ⊂ B , where A = {1, 2} and B = {1, 2, 3, 4, 5} • Is {a , b, c} ⊂ {c, b, a}? WUCT121 No Logic 138 Notes. 1. If A ⊆ B , then each element of A belongs to B, or for each x ∈ A , it is true that x ∈ B . 2. If A is a subset of B, then B is sometimes called a superset of A. 3. If A and B are sets, then to prove A ⊆ B , we need to prove ∀x, x ∈ A ⇒ x ∈ B 4. If A is a proper subset of B, there must be at least one element in B that is not in A. 5. If A and B are sets, to prove A is not a subset of B, denoted A⊄B , we need to prove ~ ( A ⊆ B ) : ~ (∀x, x ∈ A ⇒ x ∈ B ) ≡ ∃x, ~ ( x ∈ A ⇒ x ∈ B ) ≡ ∃x , ~ ( x ∉ A ∨ x ∈ B ) ≡ ∃x , ( x ∈ A ∧ x ∉ B ) 6. The following relationships hold in the number system: ∆ ⊆ ⊆ ⊆ ⊆ WUCT121 Logic 139 4.4.3. The null set as a subset. For any set A in a Universe U, ∆ ⊆ A Proof: Suppose ~ ( ∆ ⊆ A) . Then, there exists x ∈ ∆ such that x ∉ A . This, therefore, means that ∆ is not empty, which is a contradiction. Therefore, ∆ ⊆ A . 4.4.4. Distinction between elements and subsets Examples: • 2 ∈ {1, 2, 3} , 2⊄{1, 2, 3} • {2} ∉ {1, 2, 3} , {2} ⊆ {1, 2, 3} • 1 ∈ { x ∈ : x 2 = 1}, {1} ⊆ { x ∈ : x 2 = 1} Exercises: Let S be a set in a Universe U. Determine whether the following are true or false. • S ∈S • False • False S ∈ {S } • True WUCT121 S ⊆ {S } ∆ ⊆ {S } True Logic 140 • • ∆ ∈ {S } False {∆ } ⊆ {S } False 4.5. Set Equality 4.5.1. Definition: Set Equality. If A and B are sets, then A equals B, written A = B , if and only if, every element in A is also in B and every element in B is also in A. Equivalently, A = B if, and only if A ⊆ B and B ⊆ A . Note: To prove that two sets are equal two things must be shown:: A ⊆ B and B ⊆ A . Examples: • The Venn diagram demonstrating A = B is: WUCT121 Logic 141 Exercises: • Write the definition of set equality using logic notation. A = B ⇔ (∀x ∈U , x ∈ A ⇒ x ∈ B ∧ x ∈ B ⇒ x ∈ A) ⇔ (∀x ∈U , A ⊆ B ∧ B ⊆ A) 4.5.2. Axiom of Extent. If A and B are sets then A = B ⇔ (∀x ∈ U , x ∈ A ⇔ x ∈ B ) . The Axiom of Extent says that a set is completely determined by its elements, the order in which the elements are listed is irrelevant, as is the fact that some members may be listed more than once. Examples: • {1, 2} = {1, 2} • {a , b, c} = {c, b, a} Exercises: • Is {a , b, c, d } = {b, d , a , c} Yes • Is {Ann, Bob, Cal} = {Bob, Cal, Ann, Cal} Yes WUCT121 Logic 142 4.5.3. Theorem: Equality by Specification Let U be a universe and let P ( x ) be a statement. If ∀x ∈U , ( P( x ) ⇔ Q( x )) , that is ∀x ∈U , ( P( x ) ≡ Q ( x )) then { x ∈ U : P( x )} = { x ∈ U : Q ( x )} The Theorem states that subsets of the same universe U which are defined by equivalent statements are equal sets. This theorem allows the use of tautologies of logic to prove set theoretic statements, as will be outlined later. Example: • We know that x 2 = 1 ⇔ ( x = 1 ∨ x = −1). Therefore { x ∈ : x 2 = 1} = {( x = 1 ∨ x = −1)} = {1,−1} • If a1, a2 , a3 ,K an ∈ U , then we can write A = {x ∈U : x = a1 ∨ x = a2 ∨ K ∨ x = an } = {a1 , a2 , a3 ,K an } In other words, if we know the elements of a set, we know the set. • A = {x ∈ : x = 1 ∨ x = 2 ∨ x = 3} = {1, 2, 3} WUCT121 Logic 143 Exercise: • Are the following sets equal? Using logic, can you prove your answer? {1, 3, 1, 2}, {3, 2, 1}, {1, 2, 3} Yes {1, 3,1, 2} = { x ∈ : x = 1 ∨ x = 3 ∨ x = 1 ∨ x = 2} = { x ∈ : x = 1 ∨ x = 1 ∨ x = 3 ∨ x = 2} = { x ∈ : x = 1 ∨ x = 3 ∨ x = 2} = { x ∈ : x = 1 ∨ x = 2 ∨ x = 3} = {1, 2, 3} • Are the following two sets equal? Give reasons. E = {n ∈ :: n is even} and T = {n ∈ :: n 2 is even}. Yes, previously is has been proven that n is even ⇔ n 2 is even , thus by equivalence of statements, the two sets are equal. WUCT121 Logic 144 4.6. Power Sets 4.6.1. Definition: Power Set If X is any set, then { A : A ⊆ X } is the power set of X. The power set of X is often written as ( X ) . So ( X ) = { A : A ⊆ X } . A power set is a set whose elements are sets. If the elements of X are in a universe U, those of ( X ) are in a universe (U ) . Examples: • Let X = {1} and let S be the set of all subsets of X. Write down the set S by listing its elements. S = { A : A ⊆ X }. ∆ ⊆ {1} and {1} ⊆ {1}. Thus S = {∆ , {1}} • Let X = {1, 2} and S = { A : A ⊆ X } . Write down the set S by listing its elements. ∆ ⊆ {1, 2} , {1} ⊆ {1, 2}, {2} ⊆ {1, 2}, and {1, 2} ⊆ {1, 2}. Thus S = {∆ , {1}, {2}, {1, 2}} WUCT121 Logic 145 Exercises: • Let X = {1, 2, 3} . o Write down the set ( X ) by listing its elements. ( X ) = {∆ , {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}} o How many elements are there in ( X ) ? o Is ∆ ∈ ( X ) ? Yes o Is ∆ ⊆ ( X ) ? Yes o Is 1 ∈ ( X ) ? No o Is {1} ∈ ( X ) ? Yes o Is {2} ⊆ ( X ) ? No o Is {{1, 2}} ⊆ ( X ) ? WUCT121 8 Yes Logic 146 4.7. Hasse Diagrams The elements of ( X ) can be represented by diagrams using the following procedure: 1. An upward directed line between two sets indicates that the “lower” set is a subset of the “upper” set. 2. ∆ is at the bottom and X is at the top. 3. Each pair of sets is joined by an upward directed line to the “smallest” set which contains each as a subset. 4. Each pair of sets is joined by a downward directed line to the “largest” set which is a subset of each. Example: Let X = {1, 2} , thus ( X ) = {∆ , {1}, {2}, {1, 2}} and the Hasse diagram is given by: {1, 2} {1} {2} ø WUCT121 Logic 147 4.8. Set Operations There are five main set theoretic operations, one corresponding to each of the logical connectives. Set Operation Name Logical Name Connective A Complement ~ P Negation A∪ B Union P∨Q Disjunction A∩ B Intersection P∧Q Conjunction A⊆ B Subset P⇒Q Conditional A=B Equality P⇔Q Biconditional P≡Q Equivalence The set operations can be defined in terms of the corresponding logical operations. This means that each of the tautologies proved by truth tables for the logical connectives will have a corresponding theorem in set theory. WUCT121 Logic 148 We have seen how the logical conditional operator, P ⇒ Q is related to subset, A ⊆ B and how the logical biconditional operator, P ⇔ Q (or equivalence, P ≡ Q ) is related to set equality, A = B . The following sections will cover the three remaining set operations: complement, union and intersection. In our discussion of set theory, we will let U be a fixed set and all other sets, whether denoted A, B, C, etc, will be subsets of U. In other words, A, B, C ∈ (U ) . Thus, each result should start with a statement similar to “Let A, B, C be subsets of a universal set U” or “Let A, B, C ∈ (U ) ”. 4.8.1. Definition: Compliment Let U be a universal set, and let A ⊆ U . Then the complement of A, denoted by A , is given by A = {x ∈ U : ~ ( x ∈ A)} = {x ∈ U : x ∉ A}. Notes. 1. U \ A , A ′ and Ac are also used for A in some books. WUCT121 Logic 149 If the set U is fixed in a discussion, then A is 2. sometimes written as A = {x : x ∉ A} Example: • The shaded area in the following Venn diagram depicts A : Exercises: Let U = . Write down A for the following sets: • A = {1, 2, 3} A = {x ∈ : x ≠ 1 ∧ x ≠ 2 ∧ x ≠ 3} • A = {x ∈ : x is even} A = {x ∈ : x is odd} • A = {x ∈ : x > 0 ∨ x < 0} A = {0} WUCT121 Logic 150 4.8.2. Definition: Union Let A and B be subsets of a universe U. Then the union of A and B, denoted by A ∪ B , is given by A ∪ B = {x ∈ U : x ∈ A ∨ x ∈ B}. Example: • The shaded area in the following Venn diagram depicts A ∪ B : Exercises: • Let U = . Write down A ∪ B for the following sets: o A = {1} and B = {2}. A ∪ B = {1, 2} o A is the set of all even integers, B is the set of all odd integers. A ∪ B = . WUCT121 Logic 151 A = {x ∈ : 0 ≤ x ≤ 2} and B = {x ∈ : 1 ≤ x ≤ 3} o A ∪ B = { x ∈ : 0 ≤ x ≤ 3} = [0, 3] • If A ⊆ U and B ⊆ U , is it true that A ∪ B ⊆ U ? Yes. x ∈ A∪ B ⇒ x ∈ A ∨ x ∈ B ⇒ x ∈U ∨ x ∈U ⇒ x ∈U 4.8.3. Definition: Intersection Let A and B be subsets of a universe U. Then the intersection of A and B, denoted by A ∩ B , is given by A ∩ B = {x ∈U : x ∈ A ∧ x ∈ B}. Example: • The shaded area in the following Venn diagram depicts A ∩ B : WUCT121 Logic 152 Exercises: • Let U = . Write down A ∩ B for the following sets: A = {1, 2, 3, 5} and B = {1, 4, 5, 6}. o A ∩ B = {1, 5}. A is the set of all even integers, B is the set of all odd o integers. A∩ B = . A = {x ∈ : 0 ≤ x ≤ 2} and B = {x ∈ : 1 ≤ x ≤ 3} o A ∩ B = { x ∈ : 1 ≤ x ≤ 2} = [1, 2] • If A ⊆ U and B ⊆ U , is it true that A ∩ B ⊆ U ? Yes. x ∈ A∩ B ⇒ x ∈ A ∧ x ∈ B ⇒ x ∈U ∧ x ∈U ⇒ x ∈U 4.8.4. Definition: Difference Let A and B be subsets of a universe U. Then the difference of A and B, denoted by A − B , is given by A − B = {x ∈ U : x ∈ A ∧ x ∉ B}. WUCT121 Logic 153 Example: • The shaded area in the following Venn diagram depicts A − B : Notes. 1. The difference of A − B is sometimes called the relative complement of B in A. 2. If we let A = U , then we have U − B = {x ∈ U : x ∈ U ∧ x ∉ B} = {x ∈ U : x ∈ B} =B 3. Using Definitions for complement and intersection, we can simplify the definition of difference as follows: A − B = {x ∈ U : x ∈ A ∧ x ∉ B} = {x ∈ U : x ∈ A ∧ x ∈ B} = A∩ B WUCT121 Logic 154 Exercises: • Let U = . Write down A − B for the following sets: A = {1, 2, 3, 5} and B = {1, 4, 5, 6}. o A − B = {2, 3}. A is the set of all even integers, B is the set of all odd o integers. A− B = A . A = {x ∈ : 0 ≤ x ≤ 2} and B = {x ∈ : 1 ≤ x ≤ 3} o A − B = { x ∈ : 0 ≤ x < 1} = [0, 1) • If A ⊆ U and B ⊆ U , is it true that A − B ⊆ U ? Yes. x∈A− B ⇒ x∈A∧ x∉B ⇒ x ∈U ∧ x ∈U ⇒ x ∈U • Let U = , A = {1, 2, 3}, B = {2}, C = {2, 3, 4} and D = [0, 1] = {x ∈ : 0 ≤ x ≤ 1}.Write down: o A − C = {1} o B−C = o D−B=D WUCT121 Logic o D − A = {x ∈ : 0 ≤ x < 1} o A − D = {2, 3} 155 4.8.5. Definition: Disjoint sets Let A and B be subsets of a universe U. Then A and B are said to be disjoint if A ∩ B = . Example: • The following Venn diagram depicts disjoint sets A and B: Note. Disjoint sets have no elements in common. Exercises: • Let U = , A = {1, 2, 3}, B = {2}, C = {2, 3, 4} and D = [0, 1] = {x ∈ : 0 ≤ x ≤ 1}. Which pairs of sets from A, B, C, D are disjoint? B and D are disjoint, as are C and D. WUCT121 Logic 156 4.9. Order of Operations for Set Operators. The order of operation for set operators is as follows: 1. Evaluate complement first 2. Evaluate ∪ and ∩ second. When both are present, parenthesis may be needed, otherwise work left to right. 3. Evaluate ⊆ and = third. When both are present, parenthesis may be needed, otherwise work left to right. Note: Use of parenthesis will determine order of operations which over ride the above order. Examples: Indicate the order of operations in the following: • A∩ B {{ • ( A∩ { B) 13 12 • 12 • A∩( B ∪ {{ {C ) 13 2 A⊆ { {C { B∩ 13 2 2 WUCT121 Logic 157 Exercises: Indicate the order of operations in the following: • ({ A⊆ {C { B )∩ • ( A∪ { B) 13 12 • 12 • A⊆ { {C { B∪ 13 3 2 A{ = B∩ { {C 1 3 2 2 Notes. 1. ∪ and ∩ are operations on sets, thus ∪ and ∩ can only be put between two sets. 2. ∨ and ∧ are operations on statements, thus ∨ and ∧ can only be placed between statements. Example: • If A, B, and C are sets then ( A ⊆ B ∧ B ⊆ C ) ⇒ A ⊆ C is interpreted as (( A ⊆ B ) ∧ ( B ⊆ C )) ⇒ ( A ⊆ C ) • ( A ⊆ B ∧ B ⊆ C ) ≡/ ( A ⊆ ( B ∧ B ) ⊆ C ) WUCT121 Logic 158 4.10. Set Laws Let A, B, and C be subsets of a universal set U. That is A, B, C ∈ (U ) . Then for all sets A, B, and C following set laws hold: 1. Commutative Laws: • • • ( A ∪ B ) = ( B ∪ A) ( A ∩ B ) = ( B ∩ A) ( A = B ) = ( B = A) 2. Associative Laws: • • • (( A ∪ B ) ∪ C ) = ( A ∪ ( B ∪ C )) (( A ∩ B ) ∩ C ) = ( A ∩ ( B ∩ C )) (( A = B ) = C ) = ( A = ( B = C )) 3. Distributive Laws: • • ( A ∪ ( B ∩ C )) = (( A ∪ B ) ∩ ( A ∪ C )) ( A ∩ ( B ∪ C )) = (( A ∩ B ) ∪ ( A ∩ C )) 4. Double Complement (Involution) Law: • ( A) = A 5. De Morgan’s Laws: • ( A ∪ B) = ( A ∩ B) • ( A ∩ B) = ( A ∪ B) WUCT121 Logic 159 6. Identity Laws: • • ( A ∪ ) = A (A ∩U ) = A 7. Negation (Complement) Laws: • ( A ∪ A) = U • ( A ∩ A) = • U = • =U 8. Dominance Laws: • • (A ∪U ) =U ( A ∩ ) = 9. Idempotent Laws: • • ( A ∪ A) = A ( A ∩ A) = A 10. Absorption Laws: • • A ∩ ( A ∪ B) = A A ∪ ( A ∩ B) = A 11. Set Difference • A− B = A∩ B WUCT121 Logic 160 12. Subset properties of ∪ and ∩ • • ( A ⊆ ( B ∩ C )) ⇔ (( A ⊆ B ) ∧ ( A ⊆ C )) (( A ∪ B ) ⊆ C ) ⇔ (( A ⊆ C ) ∧ ( B ⊆ C )) 13. Subset property inclusion of intersection • A∩ B ⊆ A • A∩ B ⊆ B 14. Subset property inclusion in union • A⊆ A∪ B • B⊆ A∪ B 15. Transitive Property. • • (( A ⊆ B ) ∧ ( B ⊆ C )) ⇒ ( A ⊆ C ) (( A = B ) ∧ ( B = C )) ⇒ ( A = C ) WUCT121 Logic 161 4.11. Proving and Disproving Set Statements. 4.11.1. Proof by Exhaustion To prove set results for finite sets, the method of exhaustion is used. That is every element in the set is tested to ensure it satisfies the condition. Example: • Let A = {1, 2} , B = {1, 2, 3, 4}. Prove A ⊆ A ∪ B . To prove the statement, we must show every element in A is in A ∪ B . Now A ∪ B = {1, 2, 3, 4} 1 ∈ A, 1 ∈ A ∪ B 2 ∈ A, 2 ∈ A ∪ B Thus all elements in A are in A ∪ B , and so by exhaustion A ⊆ A ∪ B. WUCT121 Logic 162 Exercise: • Let A = {1, 2} , B = {1, 2, 3, 4}. Prove A = A ∩ B . To prove the statement, we must show every element in A is in A ∩ B and every element in A ∩ B is in A. Now A ∩ B = {1, 2} 1 ∈ A and 1 ∈ A ∩ B 2 ∈ A and 2 ∈ A ∩ B Thus all elements in A are in A ∩ B and vice versa, and so by exhaustion A = A ∩ B . Exercise: • Give an example of three sets A, B and C such that C ⊆ A∩ B. Let A = {1, 2} , B = {1, 2, 3, 4}, C = {1} . To prove C ⊆ A ∩ B , we must show every element in C is in A ∩ B . Now A ∩ B = {1, 2} 1 ∈ C and 1 ∈ A ∩ B Thus all elements in C are in A ∩ B and so, for the given sets A, B and C, C ⊆ A ∩ B . WUCT121 Logic 163 4.11.2. Disproof by Counterexample. A set result can be disproven by giving a counterexample. To find a counterexample often creating a Venn diagram will be of benefit. Example: • Disprove A ⊆ A ∩ B . To disprove the statement, we must give a counterexample. Let A = {1, 2} , B = {3, 4} Now A ∩ B = 1 ∈ A, however 1 ∉ A ∩ B = Thus by counterexample A⊄A ∩ B . Exercise: • Disprove A ⊆ A − B . To disprove the statement, we must show a counterexample. Let A = {1, 2} , B = {1, 2, 3, 4}. Now A − B = 1 ∈ A, however 1 ∉ A − B = Thus by counterexample A⊄A − B . WUCT121 Logic 164 4.11.3. Proof by Typical Element. To prove set results for infinite sets, generalised methods must be used. The typical element method considers a particular but arbitrary element of the set and by applying knows laws, rules and definitions prove the result. It is the method for proving subset relationships. So prove that A ⊆ B , we must show that ∀x, ( x ∈ A ⇒ x ∈ B ) Begin by letting x ∈ A , that is, we take x to be a particular but arbitrary element of A. Using the definitions, we prove that x ∈ B . As long as we use no special properties of the element x, we can conclude that (U ) , which is what we wanted to prove. This method can be used to prove set equalities. By using the definition A = B ⇔ ( A ⊆ B ∧ B ⊆ A) and showing A ⊆ B ∧ B ⊆ A , that is proving ∀x, ( x ∈ A ⇒ x ∈ B ) and ∀x, ( x ∈ B ⇒ x ∈ A) , the result A = B follows. Using this definition is sometimes called a “double containment” proof. WUCT121 Logic 165 Examples: • Let U be a set and let A and B be elements of (U ) . Prove A ⊆ A ∪ B . Need to prove ∀x, ( x ∈ A ⇒ x ∈ A ∪ B ) Let x ∈ A , then x∈ A ⇒ x∈ A∨ x∈B ⇒ x∈ A∪ B ∴ A ⊆ A∪ B see note definition of ∪ Note: Appling rules of logic, we know P ⇒ P ∨ Q is a tautology. Let P( x ) : x ∈ A, Q( x ) : x ∈ B . Thus x ∈ A ⇒ x ∈ A ∨ x ∈ B is a tautology in the proof above. • Let U be a set and let A and B be elements of (U ) . Prove A ⊆ B ⇔ A ∪ B = B . Need to prove two parts: 1. A ⊆ B ⇒ A ∪ B = B 2. A ∪ B = B ⇒ A ⊆ B WUCT121 Logic 166 • Proof of 1: KNOW: A ⊆ B , that is ∀x, ( x ∈ A ⇒ x ∈ B ) K (1) PROVE: A ∪ B = B . Need to prove two parts: i. A ∪ B ⊆ B ii. B ⊆ A ∪ B Proof of i.: Let x ∈ A ∪ B then x∈ A∪ B ⇒ ⇒ ⇒ ∴ A∪ B ⊆ B Proof of ii.: x∈ A∨ x∈B x∈B∨ x∈B x∈B∨ x∈B definition of ∪ by (1) Logic rule P ∨ P ≡ P Let x ∈ B then x∈B ⇒ x∈ A∨ x∈B ⇒ x∈ A∪ B ∴B ⊆ A∪ B see previous example definition of ∪ Since A ∪ B ⊆ B and B ⊆ A ∪ B , A ∪ B = B Thus A ⊆ B ⇒ A ∪ B = B . WUCT121 Logic 167 Proof of 2: KNOW: A ∪ B = B , that is ∀x, ( x ∈ A ∪ B ⇔ x ∈ B ) K( 2) PROVE: A ⊆ B . Let x ∈ A then x∈ A ⇒ ⇒ ⇒ ∴A⊆ B x∈ A∨ x∈B x∈ A∪ B x∈B see previous example definition of ∪ by (2) Thus A ∪ B = B ⇒ A ⊆ B Since A ⊆ B ⇒ A ∪ B = B and A ∪ B = B ⇒ A ⊆ B it is proven that A ⊆ B ⇔ A ∪ B = B . Exercise: • Let U be a set and let A and B be elements of (U ) . Prove A ∩ B ⊆ A . that is, prove ∀x, ( x ∈ A ∩ B ⇒ x ∈ A) Let x ∈ A ∩ B , then x∈ A∩ B ⇒ ⇒ ∴ A∩ B ⊆ A WUCT121 x∈ A∧ x∈B x∈A Logic definition of ∩ 168 4.11.4. Proof by Equivalence of Statements. If A can be written as A = { x ∈ U : P( x )} and B = { x ∈ U : Q ( x )}, the equality of specification theorem to show that A = B by showing that P( x ) ≡ Q( x ) , that is, by showing that P( x ) ⇔ Q ( x ) is a tautology. Examples: • Let A = { x ∈ : x 2 ≤ 1} and B = { x ∈ : −1 ≤ x ≤ 1} . Prove A = B Let P( x ) : x 2 ≤ 1 and Q( x ) : −1 ≤ x ≤ 1 . Now x 2 ≤ 1 ⇔ −1 ≤ x ≤ 1 ∴ P( x ) ⇔ Q( x ) ∴A= B • Let U be a set and let A and B be elements of (U ) . Prove that ( A ∩ B ) = A ∪ B . We need to show that the statements defining the sets ( A ∩ B ) and A ∪ B are equivalent. ( A ∩ B ) = { x ∈ U :~ ( x ∈ A ∩ B )} definition of A A ∪ B = { x ∈ U : x ∈ A ∪ B} WUCT121 Logic 169 Let P( x ) :~ ( x ∈ A ∩ B ) , and Q( x ) : x ∈ A ∪ B x∈ A∪ B ≡ x∈ A ∨ x∈B by definition of ∪ ≡ ~ ( x ∈ A) ∨ ~ ( x ∈ B ) definition of A ≡ ~ (x ∈ A ∧ x ∈ B ) ≡ ~ (x ∈ A ∩ B ) by Logic De Morgan' s by definition of ∩ ∴ Q( x ) ≡ P( x ) ∴ (A ∩ B) = A ∪ B Exercise: • Let U be a set and let A and B be elements of (U ) . Prove that ( A ∪ B ) = A ∩ B . We need to show that the statements defining the sets ( A ∪ B ) and A ∩ B are equivalent. ( A ∪ B ) = { x ∈ U :~ ( x ∈ A ∪ B )} axiom of specification A ∩ B = { x ∈ U : x ∈ A ∩ B} axiom of specification Let P( x ) :~ ( x ∈ A ∪ B ) , and Q( x ) : x ∈ A ∩ B x∈ A∩ B ≡ x∈ A ∧ x∈B by definition of ∩ ≡ ~ ( x ∈ A) ∧ ~ ( x ∈ B ) definition of A ≡ ~ (x ∈ A ∨ x ∈ B ) ≡ ~ (x ∈ A ∪ B ) by Logic De Morgan' s by definition of ∩ ∴ Q( x ) ≡ P( x ) ∴ (A ∪ B) = A ∩ B WUCT121 Logic 170 • Let U be a set and let A, B and C be elements of P(U). Prove that ( A − B ) − C = ( A − C ) − B . Let P( x ) : x ∈ ( A − B ) − C , and Q( x ) : x ∈ ( A − C ) − B x ∈ (A − B) − C ⇔ (x ∈ A − B) ∧ x ∉ C ⇔ (x ∈ A ∧ x ∉ B ) ∧ x ∉ C ⇔ x ∈ A ∧ (x ∉ B ∧ x ∉ C ) ⇔ x ∈ A ∧ (x ∉ C ∧ x ∉ B ) ⇔ (x ∈ A ∧ x ∉ C ) ∧ x ∉ B ⇔ (x ∈ A − C ) ∧ x ∉ B ⇔ x ∈ (A − C ) − B ∴ P( x ) ⇔ Q( x ) ∴ (A − B) − C = (A − C ) − B • Let U be a set and let X and Y be elements of (U ) . Prove that X − Y = X ∩ Y . Let P( x ) : x ∈ X − Y , and Q( x ) : x ∈ X ∩ Y x ∈ X − Y ≡ x ∈ X ∧ x ∉ Y Definition of set difference ≡ x ∈ X ∧ x ∈Y Definition of complement ≡ x∈ X ∩Y Definition of intersection ∴ P( x ) ≡ Q( x ) ∴X −Y = X ∩Y WUCT121 Logic 171 4.11.5. Proof by Set Laws. Set equalities can be proven by using known set laws Examples: • Let U be a set and let A, B and C be elements of P(U). Prove ( A − B ) − C = ( A − C ) − B (A − B) − C = (A − B) ∩ C set difference = (A ∩ B ) ∩ C set difference = A ∩ (B ∩ C ) associativity = A ∩ (C ∩ B ) commutativity = (A ∩ C ) ∩ B associativity = (A − C ) ∩ B = (A − C ) − B WUCT121 set difference set difference Logic 172 4.11.6. Further Examples. Examples: • Let U be a set and let A, B and B be elements of P(U). Using the following: (i) A ⊆ B ⇔ A ∪ B = B , (ii): A ⊆ B ⇔ A ∩ B = A , (iii): A ∪ B = ( A ∩ B ) . Prove that A ⊆ B ⇔ B ⊆ A . Proof: A ⊆ B ⇔ A∩ B = A • by part (ii) ⇔ (A ∩ B) = A by taking complements ⇔ A∪ B = A by part (iii) ⇔B⊆A by part (i) Let U be a set and let A, B and C be elements of P(U). Disprove that A − (B − C ) = ( A − B ) − C . Let A = {1, 2, 3}, B = {2, 3}, C = {3}. A − (B − C ) = A − {2} = {1, 3} ( A − B ) − C = {1} − C = {1} ≠ A − (B − C ) WUCT121 Logic 173 • Let U be a set and let X and Y be elements of (U ) . Use a typical element argument to prove X − Y = X ∩ Y . Need to prove two parts: 1. X − Y ⊆ X ∩ Y 2. X ∩ Y ⊆ X − Y Proof of 1:Let x ∈ X − Y be a typical element. X − Y ≡ {x ∈ U : x ∈ X − Y } ⇒ {x ∈ U : x ∈ X ∧ x ∉ Y } Axiom of Specification Def of set difference ⇒ {x ∈ U : x ∈ X ∧ x ∈ Y } Def of complement ⇒ {x ∈ U : x ∈ X ∩ Y } Def of intersection ∴ ∀x ∈ U (x ∈ X − Y ⇒ x ∈ X ∩ Y ) ∴ X −Y ⊆ X ∩Y Proof 2: Let x ∈ X ∩ Y be a typical element. X ∩ Y ≡ {x ∈ U : x ∈ X ∩ Y } ⇒ {x ∈ U : x ∈ X ∧ x ∈ Y } Axiom of Specification ⇒ {x ∈ U : x ∈ X ∧ x ∉ Y } Def of intersection Def of complement ⇒ {x ∈ U : x ∈ X − Y } Def of set difference ∴ ∀x ∈ U (x ∈ X ∩ Y ⇒ x ∈ X − Y ) ∴ X ∩Y ⊆ X −Y ∴ ∀x ∈ U (x ∈ X − Y ⇔ x ∈ X ∩ Y ), i.e. X − Y ⊆ X ∩ Y ∧ X ∩ Y ⊆ X − Y , ∴ X −Y = X ∩Y WUCT121 Axiom of extent Logic 174 Section 5. Relations and Functions 5.1. Cartesian Product 5.1.1. Definition: Ordered Pair Let A and B be sets and let a ∈ A and b ∈ B . An ordered pair ( a , b ) is a pair of elements with the property that: ( a , b ) = ( c, d ) ⇔ ( a = c ) ∧ (b = d ) . Notes: ∗ A pair set {a , b} is NOT an ordered pair, since {a , b} = {b, a} . ∗ It should be clear from the context when ( a , b ) is an ordered pair, and when ( a , b ) = { x ∈ : a < x < b} is an open interval of real numbers. WUCT121 Logic 175 Examples: • Points in the plane 2 are represented as ordered pairs. y 3 2 (1, 2) 1 (2, 1) x -4 -3 -2 -1 0 1 2 3 4 (-2, -1) -1 -2 (-1, -2) -3 From the graph it can be seen (1, 2) ≠ (2,1) and ( −1, − 2) ≠ ( −2, − 1) . • Complex numbers a + ib where i = − 1 and a, b ∈ , are ordered pairs in the sense that, a + ib = c + id ⇔ ( a = c ) ∧ (b = d ) . WUCT121 Logic 176 5.1.2. Definition: Cartesian Product Let A and B be sets, then the Cartesian Product of A and B, denoted A × B , is defined by A × B = {(a , b ) : a ∈ A ∧ b ∈ B}. Example: • × = {( x, y ) : x ∈ : ∧ y ∈ }. Sketch a graph of × , otherwise known as 2 . 2 is the usual Cartesian plane with the usual graph. y 4 2 x -6 -4 -2 0 2 4 6 -2 -4 WUCT121 Logic 177 Exercises: • Let A = {3} and B = {2, 3} . Write down A × B . Sketch a graph of A × B in 2 . A × B = {(3, 2), (3, 3)} y 6 4 (3, 3) 2 (3, 2) x -6 -4 -2 0 2 4 6 -2 -4 -6 • Let C = { x ∈ : −1 ≤ x ≤ 1} and D = {1, 2} . Write down C × D . Sketch a graph of C × D in 2 . C × D = {( x, y ) : −1 ≤ x ≤ 1 ∧ y ∈ (1, 2)} y 4 2 x -4 -3 -2 -1 0 1 2 3 4 -2 -4 WUCT121 Logic 178 5.2. Relations 5.2.1. Definition: Binary Relation Let A and B be sets. We say that R is a (binary) relation from A to B if R ⊆ A × B . Notes: ∗ If R ⊆ A × A , we say that R is a relation on A. ∗ If ( a , b ) ∈ R , we will frequently write aRb and say that “a is in the relation R to b”. ∗ Every relation is a subset of a Cartesian product Examples: • Let A be the set of all male human beings and let B be the set of all human beings. The relation T from A to B is given by T = {( x, y ) : x is the father of y}. • W = {(1, 2 ), (2, 1), (5, π )}. Note: W cannot be defined by a “rule”. Sometimes relations are simply defined by a listing of elements. WUCT121 Logic 179 • Let R be the relation on , defined by R = {( x, y ) : x 2 + y 2 = 1} . Sketch the graph of R in 2 y x -2 -1 0 1 2 Exercise: • Let S be the relation on , defined by S = {( x, y ) : 4 x + y = 4} . Sketch the graph of S in 2 y 4 2 x -2 WUCT121 -1 0 Logic 1 2 180 Example: Consider the relation R on given by R = {( x, y ) : x = y} • Sketch the graph of R in 2 y 4 2 x -4 -3 -2 -1 0 1 2 3 4 -2 -4 • • Are the following true or false? o 1R1 True o 1R2.2 False o ( −3, 3) ∈ R False If aR100, what is the value of a? 100 Note. The relation R in this example is called the identity relation on and is usually written R = {( x, x ) : x ∈ }. WUCT121 Logic 181 Exercises: • Let X = {0, 1, 2, 3}, and let the relation R on X be given by R = {( x, y ) : ∃z ∈ , x + z = y}. o What is an easier way of expressing the relation R? R = {( x, y ) : x, y ∈ X ∧ x < y} o List all the elements of R. R = {(0, 1), (0, 2 ), (0, 3), (1, 2 ), (1, 3), (2, 3)} o Sketch X × X , and circle the elements of R. y 2 x 0 • 1 2 3 4 Let S be the relation on − {0} given by S = {( x, y ) : ∃z ∈ , xz = y} o Describe the relation S. x is a factor of y, or x | y . WUCT121 Logic 182 o Are the following true or false? • (2,−4) ∈ S −3S0 (3, 5) ∈ S True, since 2 | −4 . False, since 0 ∉ − {0}. False, since 3F5. Let R be the relation on given by R = {( x, y ) : y = x 2 } and let S be the relation on given by S = {( x, y ) : y = x 2 }. o Sketch each relation. What difference does the input” set make to the elements in each relation. y 8 6 4 2 x -4 -3 -2 -1 0 1 2 3 4 R is a set of isolated points. WUCT121 Logic 183 y 3 2 1 x -3 -2 -1 0 1 2 3 -1 S is a continuous curve. Note. Care must be taken when writing relations. As can be seen from this example, it must be very clear the sets a relation is from and to. • Let A = {0, 1} and B = {− 1, 0, 1}. Let two relations from A to B be given by R1 = {(0,−1), (1,−1), (1, 0 )}, and R2 = {(0, 0), (1,1), (1, − 1)}. Determine: o R 1 ∩ R 2 = {(1,−1)}. o R 1 ∪ R 2 = {(0,−1), (0, 0 ), (1,−1), (1, 0 ), (1, 1)} WUCT121 Logic 184 • Let R3 and R4 be relations on defined by R3 = {( x, y ) : x = y}, and R4 = {( x, y ) : x = − y}. Determine: o R3 ∪ R4 = {( x, y ) : x = y ∨ x = − y} = {( x, y ) : x = ± y} = {( x, y ) : x = y } o WUCT121 R3 ∩ R4 = {(0, 0 )} Logic 185 5.2.2. Definition: Domain Let R be a relation from A to B. Then the domain of R, denoted Dom R, is given by Dom R = {x : ∃y , xRy}. Notes: ∗ Let R be a relation from A to B, then Dom R ⊆ A . ∗ Dom R is the set of all first elements in the ordered pairs that belong to R. 5.2.3. Definition: Range Let R be a relation from A to B. Then the range of R, denoted Range R, is given by Range R = {y : ∃x, xRy}. Notes: ∗ Let R be a relation from A to B, then Range R ⊆ B . ∗ Range R is the set of all second elements in the ordered pairs that belong to R. WUCT121 Logic 186 Examples: • Let A = {0, 1, 2, 3} and let R1 be the relation on A given by R1 = {(0, 0), (0,1), (0, 2), (3, 0)}. Determine: o Dom R1 = {0, 3} o Range R1 = {0, 1, 2} Exercises: • Let R2 be the relation on given by R2 = {( x, y ) : xy ≠ 0}. Determine: • o Dom R2 = − {0} o Range R2 = − {0}. Let R3 be the relation from to given by { } R3 = ( x, y ) : x ≠ 0 ∧ y = 1 . x Determine: o Dom R3 = − {0} o Range R3 = 1 : n ∈ ∧ n ≠ 0 WUCT121 { } n Logic 187 5.2.4. Definition: Inverse Relations Let R be a relation from A to B. The inverse relation, denoted R −1 , from B to A is defined as R −1 = {( y , x ) : ( x, y ) ∈ R}. Notes: ∗ For a relation R from A to B, the inverse relation R −1 can be defined by interchanging the elements of all the ordered pairs of R. This turns out to be easier for a finite (listed) relation than an infinite (given by formula) relation. Dom R −1 = Range R ⊆ B and ∗ Range R −1 = Dom R ⊆ A . Examples: • Define a relation R on as R = {( x, y ) : y = 2 x}. o Write down 3 elements of R. (1, 2 ), (2, 4 ), (3, 6) o Write down 3 elements of R −1 (2, 1), (4, 2), (6, 3) WUCT121 Logic 188 o Sketch a graph of R and R −1 on coordinate axis, circle elements of R −1 . y 6 5 4 3 2 1 x -1 0 1 2 3 4 5 6 7 -1 o Write down a simple definition for R −1 . R −1 = {( y , x ) : y = 2 x} = {( x, y ) : x = 2 y} { = ( x, y ) : y = 12 x } Exercise: • Let S be the identity relation on the set of reals. What is S −1? S = {( x, x ) : x ∈ } S −1 = {( x, x ) : x ∈ } =S WUCT121 Logic 189 5.2.5. Directed Graph of a Relation When a relation R is defined on a set A, we can represent it with a directed graph. This is a graph in which an arrow is drawn from each point in A to each related point. ∀x, y ∈ A , there is an arrow from x to y ⇔ xRy , ⇔ ( x, y ) ∈ R If a point is related to itself, a loop is drawn that extends out from the point and goes back to it. Example: • Let A = {0, 1, 2, 3} and let R1 be the relation on A given by R1 = {(0, 0), (0,1), (0, 2), (3, 0)}. Draw the directed graph of R1 . 0 1 2 3 WUCT121 Logic 190 Exercise: • Let A = {0, 1, 2, 3} and let R2 be the relation on A given by R2 = {(0, 0), (1, 2), ( 2, 2)}. Draw the directed graph of R2 . 1 0 2 WUCT121 Logic 191 5.2.6. Properties of Relations Let R be a relation on the set A. Reflexivity: R is reflexive on A if and only if ∀x ∈ A, ( x, x ) ∈ R . Example: • Let R1 be the relation on defined by R1 = {( x, y ) : x is a factor of y}. For each x ∈ , we know that x is a factor of itself. Thus, ( x, x ) ∈ R1 , and so R1 is reflexive Symmetry: R is symmetric on A if and only if ∀x, y ∈ A, (( x, y ) ∈ R ⇒ ( y , x ) ∈ R ) . Example: • Let R2 be the identity relation on . For x, y ∈ , if x = y , then y = x , that is, if ( x, y ) ∈ R2 , then ( y , x ) ∈ R2 and so R2 is symmetric WUCT121 Logic 192 Transitivity: R is transitive on A if and only if ∀x, y , z ∈ A, ((( x, y ) ∈ R ∧ ( y , z ) ∈ R ) ⇒ ( x, z ) ∈ R ) . Example: • Let R3 be the relation on defined by R3 = {( x, y ) : x < y}. For x, y , z ∈ , if x < y and y < z , then x < z , that is, if ( x, y ) ∈ R3 and ( y, z ) ∈ R3 , then ( x, z ) ∈ R3and so R3 is transitive. Notes: ∗ A relation R on a set A is reflexive if each element in A is in relation to itself. ∗ A relation R on a set A is symmetric if you can “swap” the ordered pairs around and still get elements of R. ∗ A relation R on a set A is transitive if pairs of elements are “related via” a third element (x and z related via y). WUCT121 Logic 193 Exercises: Which of the three properties do the following relations satisfy? Give reasons why or why not. • R1 on , given by R1 = {( x, y ) : x | y}. ∀x ∈ , x | x. ∴ ( x, x ) ∈ R1 Thus R1 is reflexive. Consider ( 2, 4) ∈ R1 , since 2 | 4 , however ( 4, 2) ∉ R1 , as 4 F 2, so R1 is not symmetric. ∀x, y , z ∈ , x | y ∧ y | z ⇒ x | z. ∴ ( x, y ) ∈ R1 ∧ ∴ ( y , z ) ∈ R1 ⇒∴ ( x, z ) ∈ R1, thus R1 is transitive. • R2 , the identity relation on Reflexive: Yes Symmetric: Yes Transitive: Yes • R3 on given by R3 = {( x, y ) : x < y} Reflexive: No Symmetric: No Transitive: Yes WUCT121 Logic 194 • R4 on given by R4 = {( x, y ) : y = x 2 } Reflexive: No Symmetric: No Transitive: No • R5 on A where A is the set of all people. R5 = {( x, y ) : x is in the family of y} Reflexive: Yes Symmetric: Yes Transitive: Yes • R6 on A where A is the set of all people. R6 = {( x, y ) : x loves y} Reflexive: ? Symmetric: ? Transitive: ? WUCT121 Logic 195 5.2.7. Definition: Equivalence Relation Let R be a relation on the set A. R is an equivalence relation on A if and only if R is reflexive, symmetric and transitive on A. Example: From the previous exercises, R2 and R5 are equivalence relations. Notes: ∗ If R is a relation on a set A, you must be able to either prove or disprove the statement “R is an equivalence relation.” ∗ To prove a relation R is an equivalence relation, it is necessary to prove all three properties hold. ∗ To disprove that a relation R is an equivalence relation, it is sufficient to show that one of the three properties does not hold. This can usually be shown by counterexample. WUCT121 Logic 196 Example: • Let R1 be the identity relation on . Prove or disprove R1 is an equivalence relation. Proof: Reflexive: ∀a ∈ , a = a , that is (a , a ) ∈ R1 . Thus R1 is reflexive. Symmetric: ∀a , b ∈ , if a = b, then b = a , that is, (a , b ) ∈ R1 ⇒ (b, a ) ∈ R1. Thus R1 is symmetric. Transitive: ∀a , b, c ∈ , if a = b and b = c, then a = c , that is (( a , b ) ∈ R1 ∧ (b, c ) ∈ R1 ) ⇒ ( a , c ) ∈ R1 . Thus R1 is transitive. Since R1 is reflexive, symmetric and transitive, R1 is an equivalence relation. WUCT121 Logic 197 Exercises: • Let n ∈ . Consider the relation R2 on given by R2 = {(a , b ) : a ≡ b(mod n )}. Prove or disprove R2 is an equivalence relation. Recall: a ≡ b(mod n ) ⇔ ∃k ∈ , a − b = nk . Proof: Reflexive: ∀a ∈ , a − a = 0 = n × 0 , which implies that a ≡ a(mod n ) , ∴ (a , a ) ∈ R2 Thus R2 is reflexive. Symmetric: ∀a , b ∈ , if a ≡ b(mod n ), then a − b = nk ∴ b − a = − nk = n(− k ), giving b ≡ a (mod n ). Thus (a , b ) ∈ R2 ⇒ (b, a ) ∈ R2 . So R2 is symmetric. Transitive: ∀a, b, c ∈ , if a ≡ b(mod n ) and b ≡ c(mod n ), then ( a − b = nk ) ∧ (b − c = nl ) , ∴ a − c = n( k + l ) = np , so a ≡ c (mod n ) . That is (( a , b ) ∈ R2 ∧ (b, c ) ∈ R2 ) ⇒ ( a , c ) ∈ R2 . Thus R2 is transitive. Since R2 is reflexive, symmetric and transitive, R2 is an equivalence relation. WUCT121 Logic 198 • Let R3 be the relation on given by R3 = {(a , b ) : ab ≠ 0}. o Prove or disprove R3 is an equivalence relation. Disprove: Reflexive: We must show ∀a ∈ , a × a ≠ 0 . However 0 ∈ , and 0 × 0 = 0 . Thus R3 = {(a , b ) : ab ≠ 0} and so R3 is not reflexive. Therefore R3 is not an equivalence relation. o Is R3 symmetric or transitive? ab ≠ 0 ⇒ ba ≠ 0 ∴ symmetric ab ≠ 0 ∧ bc ≠ 0 ⇒ ac ≠ 0 ∴ transitive o How can we adjust the relation so it becomes an equivalence relation? R3 on − {0}. WUCT121 Logic 199 • Let A = {0, 1, 2} and let R be the relation on A given by R = {(0, 0 ), (1, 1), (2, 2 ), (0, 1), (1, 0 )}. Prove or disprove R is an equivalence relation on A. Reflexive: For a = 0 : (0, 0 ) ∈ R . For a = 1 : (1, 1) ∈ R . For a = 2 : (2, 2 ) ∈ R . So, ∀a ∈ A, (a , a ) ∈ R . Thus R is reflexive. Symmetric: For (0, 0 ), (1, 1) and (2, 2 ) symmetry obviously holds. (0, 1) ∈ R ⇒ (1, 0 ) ∈ R , (1, 0 ) ∈ R ⇒ (1, 0 ) ∈ R , So, ∀(a , b ) ∈ R ⇒ (b, a ) ∈ R , thus R is symmetric. Transitive: (0, 0 ), (0, 1) ∈ R ⇒ (0, 1) ∈ R , (1, 1), (1, 0 ) ∈ R ⇒ (1, 0 ) ∈ R , (0, 1), (1, 1) ∈ R ⇒ (0, 1) ∈ R , (0, 1), (1, 0 ) ∈ R ⇒ (0, 0 ) ∈ R (1, 0 ), (0, 1) ∈ R ⇒ (1, 1) ∈ R , (1, 0 ), (0, 0 ) ∈ R ⇒ (1, 0 ) ∈ R , So ∀(a , b ) ∧ (b, c ) ∈ R ⇒ (a , c ) ∈ R , thus R is transitive. Therefore, since R is reflexive, symmetric and transitive, R is an equivalence relation. WUCT121 Logic 200 5.2.8. Directed Graphs of Equivalence Relations The directed graph of an equivalence relation on A has the following properties: ∗ Each point of the graph has an arrow looping around from it back to itself. (Reflexivity) ∗ In each case where there is an arrow going from one point to a second, there is an arrow going from the second point back to the first. (Symmetry) ∗ In each case where there is an arrow going from one point to a second and from a second point to a third, there is an arrow going from the first point to the third. (Transitivity) WUCT121 Logic 201 Example: • Let A = {0, 1, 2} and let R be the relation on A given by R = {(0, 0 ), (1, 1), (2, 2 ), (0, 1), (1, 0 )}. Draw the directed graph for R. Previously R was shown to be an equivalence relation on A. The directed graph is then : 0 1 2 WUCT121 Logic 202 Exercise: Let A = {2, 3, 4, 6, 7, 9}, and define a relation R on A • by R = {(a , b ) : a ≡ b(mod 3)}. Draw the directed graph for R. Solution: R = {(2, 2 ), (3, 3), (4, 4 ), (6, 6 ), (7, 7 ), (9, 9 ), (3, 6 ), (6, 3), (3, 9 ), (9, 3), (6, 9 ), (9, 6 ), (4, 7 ), (7, 4)} It can be shown that R is an equivalence relation, and thus the directed graph is: 4 3 2 9 7 6 WUCT121 Logic 203 5.2.9. Equivalence Class The fundamental property of equivalence relations which makes them important is that each one determines a partition of the set A into a family of disjoint sets. Definition: Let R be an equivalence relation on the set A. Then for each a ∈ A , we define the equivalence class of a as class( a ) = {b ∈ A : (a , b ) ∈ R}. Example: • Let A = {0, 1, 2} and let R be the relation on A given by R = {(0, 0 ), (1, 1), (2, 2 ), (0, 1), (1, 0 )}. For each element in A, we define equivalence classes as follows: class(0 ) = {b ∈ A : (0, b ) ∈ R} = {0, 1} class(1) = {b ∈ A : (1, b ) ∈ R} = {1, 0} = class(0 ) class(2 ) = {b ∈ A : (2, b ) ∈ R} = {2} WUCT121 Logic 204 Exercises: • Let R1 be the identity relation on . Write down the following equivalence classes: o class(1) = {1} o class(π ) = {π } ( ) {} o class 12 = 12 o For any x ∈ , class( x ) = {x}. • Consider the relation R2 on given by R2 = {(a , b ) : a ≡ b(mod 3)}. What kind of numbers are in class(2) (otherwise written as [2])? class(2 ) = {K − 4,−1, 2, 5, 8, 11, K ,3k + 2,K}. • Let R3 on A, the set of all people, be given by R3 = {(a , b ) : a is in the family of b}. Who is in your equivalence class? WUCT121 Logic 205 5.3. Functions 5.3.1. Definition If F is a relation from A to B, then we say F is a function from A to B, if and only if the domain of F is all of A and for each element x ∈ A , there is only one value y ∈ B such that ( x, y ) ∈ F . Note: A relation from A to B becomes a function if the domain is all of A and if every first element is related to only one second element. This last property is sometimes known as the vertical line test. Examples: • Is R1 on , R1 = {( x, y ) : y = x 2 } a function? y 3 2 1 x -3 -2 -1 0 1 2 3 -1 Dom R1 = , vertical line test holds, thus R1 is a function. WUCT121 Logic 206 • Is R2 on , R2 = {( x, y ) : x = y 2 } a function? y 3 2 1 x -1 0 1 2 3 -1 -2 -3 Dom R2 = , vertical line test fails, thus R2 is not a function. Exercises: • Is R3 on A = {x ∈ : x ≥ 0}, R3 = {( x, y ) : x = y 2 } a function? y 3 2 1 x -1 0 1 2 3 -1 Dom R3 = A , vertical line test holds, thus R3 is a function. WUCT121 Logic 207 • Is R4 on , R4 = {( x, y ) : y = x } a function? y 3 2 1 x -1 0 1 2 3 -1 Dom R4 = [0, ∞ ) ≠ , thus R4 is not a function. Notes: When determining if a relation is a function: ∗ Infinite Case: Is the domain is the entire set A. Finite Case: Is every element of A a first element in an ordered pair? ∗ Infinite Case: Graph the relation and apply the vertical line test. Finite Case: List the ordered pairs and check each first element appears only once. WUCT121 Logic 208 Exercises: Let A = {2, 4, 6} and let B = {1, 3, 5}. Which of the • following relations from A to B are functions? o R1 = {( x, y ) : x + 1 = y} = {(2, 3), (4, 5)} Dom R1 = {2, 4} ≠ A . Thus R1 is not a function. o R2 = {(2, 5), (4, 1), (4, 5), (6, 5)}. Dom R2 = {2, 4, 6} = A . However, (4, 1) ∈ R2 ∧ (4, 5) ∈ R2 Thus R2 is not a function. o R3 = {(2, 5), (4, 1), (6, 5)}. Dom R3 = A , and each first element only appears once. Thus R3 is a function. WUCT121 Logic 209 • Which of the following are functions? o F1 , the identity relation on A = {1, 5, 10}. F1 = {(1,1), (5, 5), (10,10 )} Dom F1 = A , and each first element only appears once. Thus F1 is a function o F2 on , F2 = {( x, y ) : y = 1}. y 2 1 x -3 -2 -1 0 1 2 3 -1 Dom F2 = , vertical line test holds, thus F2 is a function. WUCT121 Logic 210 o F3 on , F3 = {( x, y ) : y = x + 1}. y 4 3 2 1 x -3 -2 -1 0 1 2 3 -1 -2 Dom F3 = , vertical line test holds, thus F3 is a function. WUCT121 Logic 211 5.3.2. One-to-one Let F be a function from A to B. F is one-to-one if and only if ∀x1 , x 2 ∈ A, (( x1 , y ) = ( x 2 , y ) ⇒ x1 = x 2 ). For one-to-one functions, any given element from the Range is related to only one element from the Domain. That is each element in both the domain and the range is related to just one element. Notes: ∗ Only functions can be one-to-one. ∗ It is often the case that if a function F is one-to-one, it satisfies a horizontal line test. ∗ To establish if a relation is one-to-one show if the relation is, in fact, a function. Then determine if it is one-to-one. ∗ To show a function is one-to-one, show each element in the range occurs once in an ordered pair. ∗ To show a function is not one-to-one, give a counterexample, that is, find an element of the range that is related to two elements in the domain. WUCT121 Logic 212 Examples: • Consider the relation F1 on given by F1 = {( x, y ) : y = x 2 } . Is F1 a one-to-one function? y 3 2 1 x -3 -2 -1 0 1 2 3 -1 Dom F1 = , vertical line test holds, thus F1 is a function. Horizontal line test fails: ( −1,1) ∈ F1 ∧ (1,1) ∈ F , therefore F1 is not a one-to-one function WUCT121 Logic 213 • Consider the relation F2 on + = {x ∈ : x ≥ 0} given by F2 = {( x, y ) : y = x 2 }. Is F2 a one-to-one function? y 4 3 2 1 x -3 -2 -1 0 1 2 3 -1 Dom F2 = + , vertical line test holds, thus F2 is a function. Horizontal line test holds, therefore F2 is a oneto-one function • Let X = {0, 1, 2, 3}. Consider the function F3 from ( X ) to given by F3 = {( A, n ) : n is the number of elements in the set A}. Is F3 a one-to-one function? Consider A = {0, 1}∈ ( X ) and B = {1, 2} ∈ ( X ) . Then ( A, 2 ) ∈ F3 and (B, 2 ) ∈ F3 , that is, 2 ∈ appears twice. Thus, F3 is not a one-to-one function. WUCT121 Logic 214 Exercises: Which of the following relations are one-to-one functions? • F1 on A = {1, 2, 3}, F1 = {(1, 2 ), (2, 3), (3, 1)}. 5 y 4 3 2 1 x 0 1 2 3 -1 -2 Dom F1 = A , vertical line test holds, thus F1 is a function. Horizontal line test holds, therefore F1 is a one-to-one function. • F2 on A = {1, 2, 3}, F2 = {(1, 2 ), (2, 1), (3, 1)}. 5 y 4 3 2 1 x 0 1 2 3 -1 -2 Dom F2 = A , vertical line test holds, thus F1 is a function. Horizontal line test fails: ( 2, 1) ∈ F2 ∧ (3, 1) ∈ F2 , therefore F2 is not a one-to-one function. WUCT121 Logic 215 • F3 on , F3 = {( x, y ) : y = 2 x}. y 4 3 2 1 x -3 -2 -1 0 1 2 3 -1 -2 -3 -4 Dom F3 = , vertical line test holds, thus F3 is a function. Horizontal line test holds, therefore F3 is a one-to-one function • { F4 from − {0} to , F4 = ( x, y ) : y = } x2 −1 . y 4 3 2 1 x -3 -2 -1 0 1 2 3 -1 Dom F4 = − {0}, vertical line test holds, thus F4 is a function. Horizontal line test fails: (1, 0) ∈ F4 ∧ ( −1, 0) ∈ F4 , therefore F4 is not a one-to-one function. WUCT121 Logic 216 5.3.3. Onto Let F be a function from A to B. F is onto if and only if Range F = B , that is, ∀y ∈ B, ∃x ∈ A, ( x, y ) ∈ F . For a function to be onto, every given element from the range must be related to at least one element from the domain. Notes: ∗ Only functions can be onto. ∗ To establish if a relation is onto show if the relation is, in fact, a function. Then determine if it is onto. ∗ To show a function F from A to B is onto, show that Range F = B , that is every element in the range occurs at least once in an ordered pair. ∗ To show a function is not onto, give a counterexample, that is, find an element of the range that is not related to an element in the domain. WUCT121 Logic 217 Example: • Consider the relation F1 from A = { x ∈ : −1 ≤ x ≤ 1} to given by F1 = {( x, y ) : y = 1 − x 2 }. Is F1 an onto function? y x -2 -1 0 1 2 Dom F1 = { x ∈ : −1 ≤ x ≤ 1} = A , vertical line test holds, thus F1 is a function. Range F1 = { y ∈ : 0 ≤ y ≤ 1} ≠ , thus F1 is not an onto function. By defining the function to F2 from A = { x ∈ : −1 ≤ x ≤ 1} to B = { x ∈ : 0 ≤ x ≤ 1} given by F2 = {( x, y ) : y = 1 − x 2 }. Now Range F2 = { y ∈ : 0 ≤ y ≤ 1} = B , thus the function F2 is an onto function WUCT121 Logic 218 Exercises: Which of the following functions are onto? • F1 from A = {1, 2, 3, 4, 5} to B = {a , b, c, d } , F1 = {(1, a ), ( 2, c ), (3, c ), ( 4, d ), (5, d )} Range F1 = {a , c, d } ≠ B . Therefore F1 is not an onto function. • F2 from A = {1, 2, 3, 4, 5} to B = {a , b, c, d } , F2 = {(1, a ), ( 2, b ), (3, c ), ( 4, d ), (5, a )}. Range F2 = {a , b, c, d } = B . Therefore F2 is an onto function. • F3 on , F3 = {( x, y ) : y = 4 x − 1}. For each y ∈ , let x = y +1 ∈ , then 4 ∀y ∈ , ∃x ∈ , ( x, y ) ∈ F3 . Thus Range F3 = . Therefore F3 is an onto function. • F4 on , F4 = {( x, y ) : y = 4 x − 1} . Consider y = 0 ∈ , then for ( x, 0) ∈ F4 requires x= 0 +1 ∉ . Thus Range F4 ≠ . Therefore F4 is not an 4 onto function WUCT121 Logic 219 5.3.4. Inverse Every relation has an inverse and this holds for functions also. For any function, there is an inverse relation; however, this inverse relation is not always a function. The inverse of a function F will also be a function when F is one-to-one and onto. Example: Consider the relation F on the interval [ −1,1] = { x ∈ : −1 ≤ x ≤ 1} , given by F = {( x, y ) : y = 1 − x 2 } . • Sketch F. Is F a one-to-one and onto function? y x -2 WUCT121 -1 0 1 Logic 2 220 Dom F = [−1,1] , and the vertical line test holds. Thus F is a function. Horizontal line test fails, thus F is not a one-toone function. Range F = [0,1] ≠ [ −1,1] , thus F is not an onto function. −1 −1 Sketch F . Is F a function? • Since F is function, and thus a relation, there is an inverse relation F −1 on [−1,1] given by F −1 = {( x, y ) : x = 1 − y 2 } . y x -2 -1 0 1 2 Dom F −1 = [0,1] ≠ [ −1,1] , and the vertical line test fails. Thus F −1 is not a function. WUCT121 Logic 221 Exercises: Consider the relation F on A = { x ∈ : x ≥ 0} given by F = {( x, y ) : y = x 2 } . • Sketch F. Is F a one-to-one and onto function? y 8 6 4 2 x 0 1 2 Dom F = A , vertical line test holds, horizontal line test holds, Range F = A , thus F is one-to-one and onto function. • Sketch F −1 . Is F −1 a function? y 2 x 0 1 2 Dom F −1 = A , vertical line test holds, thus F −1 a function. WUCT121 Logic 222 5.4. Permutations 5.4.1. Definition Let A be a set and let F be a function on A. Then F is a permutation of A if F is one-to-one and onto. Example: Let A = {0,1, 2, 3}. Define F = {(0,1), (1, 2), ( 2, 3), (3, 0)}. F is a one-to-one and onto function on A and thus is a permutation of the elements of A. Using conventional function notation each ordered pair in F can be written as: F (0) = 1, F (1) = 2, F (2) = 3, F (3) = 0 “Matrix” representation can also be used for permutations. The function F can be written as ⎛ 0 1 2 3⎞ F =⎜ ⎟ 1 2 3 0 ⎝ ⎠ F is one possible permutation of the set A. Other permutations are: ⎛ 0 1 2 3⎞ ⎛0 1 2 3⎞ ⎛ 0 1 2 3⎞ I =⎜ ⎟, H = ⎜ ⎟ ⎟ ,G = ⎜ 0 1 2 3 1 0 3 2 1 3 2 0 ⎝ ⎠ ⎝ ⎠ ⎝ ⎠ WUCT121 Logic 223 There will be 4! = 4 × 3 × 2 × 1 total different permutations of the set A. I is known as the identity permutation, where each element in A is mapped to itself. Notes: ∗ In general, if A is a set with n elements, there are n! different permutations of A. ∗ The set of all permutations on a set A with n elements is often denoted by S n . Exercises: ⎛0 1 2 3⎞ Let A = {0,1, 2, 3}and let G = ⎜ ⎟ and 1 0 3 2 ⎝ ⎠ ⎛ 0 1 2 3⎞ H =⎜ ⎟ be permutation on A. ⎝1 3 2 0⎠ Write down the following. • G (1) = 0 • H (1) = 3 • G (3) = 2 • G ( H (0)) = 0 • H (0 ) = 1 • G ( H (1)) = 2 WUCT121 Logic 224 5.4.2. Cycle notation Obviously, the matrix notation for permutations can be confusing when we start to combine permutations. This notation can be mistaken for “normal” matrix multiplication. Therefore, we introduce what is called cycle notation for permutations. Example: Let A = {1, 2, 3, 4, 5} and let F be a permutation on A given ⎛ 1 2 3 4 5⎞ by F = ⎜ ⎟ 2 3 4 5 1 ⎝ ⎠ we note that: 1 “goes to” 2 2 “goes to” 3 3 “goes to” 4 4 “goes to” 5 5 “goes to” 1. This can be written as a cycle: (1 2 3 4 5) . Diagrammatically, this can be represented as (1 2 3 4 5) WUCT121 Logic 225 If an element is mapped onto itself, then it is left out of the cycle. Examples: Write the following permutations using cycle notation. • Let A = {0,1, 2, 3} ⎛ 0 1 2 3⎞ F =⎜ ⎟ = (0 2 ) 2 1 0 3 ⎝ ⎠ • A = {1, 2, 3, 4, 5} ⎛1 2 3 4 5⎞ G=⎜ ⎟ = (1 2 )(4 5) 2 1 3 5 4 ⎝ ⎠ • A = {1, 2, 3} ⎛1 2 3 ⎞ I =⎜ ⎟ = (1) or (2 ) or (3) or (1)(2 )(3) ⎝1 2 3 ⎠ WUCT121 Logic 226 Exercises: Write down the following permutations on A = {0,1, 2, 3}, using cycle notation. • ⎛ 0 1 2 3⎞ F =⎜ ⎟ = (1 3) 0 3 2 1 ⎝ ⎠ • ⎛0 1 2 3⎞ G =⎜ ⎟ = (0 1 3 2 ) 1 3 0 2 ⎝ ⎠ • ⎛0 1 2 3⎞ H =⎜ ⎟ = (0 1)(2 3) 1 0 3 2 ⎝ ⎠ WUCT121 Logic 227 5.4.3. Composition In traditional Calculus, composition of functions is defined to be ( g o f )( x ) = g ( f ( x )) . The same idea is used when considering composition of permutations. Examples: Let A = {1, 2, 3, 4} and let F = (1 2 3 4) , G = (1 2)(3 4) be permutations on A. Write down the following: • G ( F (1)) = G (2) = 3 • G ( F (2)) = G (3) = 4 • G ( F (3)) = G (4) = 3 • G ( F (4)) = G (1) = 2 What is G o F written using cyclic notation? G o F = (2 4) WUCT121 Logic 228 This could be calculated by writing each function in cyclic notation in the appropriate order, then determining the resultant permutation. G o F = FG = (1 2 3 4)(1 2)(3 4) 1 “goes to” 2 in the first cycle, then 2 “goes to” 1 in the second. Thus, 1 “goes to” 1 overall. 2 “goes to” 3 in the first cycle, then 3 “goes to” 4 in the third. Thus, 2 “goes to” 4 overall. 3 “goes to” 4 in the first cycle, then 4 “goes to” 3 in the third. Thus, 3 “goes to” 3 overall. 4 “goes to” 1 in the first cycle, then 1 “goes to” 2 in the second. Thus, 4 “goes to” 2 overall. These calculations give G o F = FG = ( 2 4) . (1 2 3 4 )(1 2 )(3 4 ) = ⎛⎜11 24 33 42 ⎟⎞ = (2 4 ) ⎝ ⎠ WUCT121 Logic 229 Exercises: Calculate the following compositions of permutations on A = {0,1, 2, 3}. • ⎛ 0 1 2 3⎞ (1 2)(1 0 2) = ⎜ ⎟ = (0 2 ) 2 1 0 3 ⎝ ⎠ • ⎛ 0 1 2 3⎞ (0 1)(2 3)(0 1 2 3) = ⎜ ⎟ = (0 2 ) 2 1 0 3 ⎝ ⎠ • (1 2 3)(3 2) = ⎜ 5.4.4. ⎛ 0 1 2 3⎞ ⎟ = (1 3) ⎝ 0 3 2 1⎠ Inverse Permutations Permutations are one-to-one and onto functions, thus their inverses are also functions which are one-to-one and onto. Thus, the inverse of a permutation is also a permutation. Recall that to find the inverse of a relation or function, we simply reverse the ordered pairs. For permutations, the process is identical. WUCT121 Logic 230 Examples: Let A = {1, 2, 3, 4} and let F = (1 2 4 3) . In F: 1 “goes to” 2. Thus, in F −1 , 2 “goes to” 1. 2 “goes to” 4. Thus, in F −1 , 4 “goes to” 2. 3 “goes to” 1. Thus, in F −1 , 1 “goes to” 3. 4 “goes to” 3. Thus, in F −1 , 3 “goes to” 4. Putting all these calculations together, we have F −1 = (1 2 4 3) −1 = (1 3 4 2) = (3 4 2 1) Note that F −1 is just F written in the reverse order. Exercises: Let A = {0,1, 2, 3} Write down the following. • (1 2 3)−1 = (3 2 1) • (0 3 1)−1 = (1 3 0 ) WUCT121 Logic 231