Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 2006 310205 Mathematics for Comter I Lecture 2: Logic (1) Basic definitions Logical operators Translating English sentences.

Similar presentations


Presentation on theme: "1 2006 310205 Mathematics for Comter I Lecture 2: Logic (1) Basic definitions Logical operators Translating English sentences."— Presentation transcript:

1 1 2006 310205 Mathematics for Comter I Lecture 2: Logic (1) Basic definitions Logical operators Translating English sentences

2 2 2006 310205 Mathematics for Comter I 2.1. Logic Rules of logic: Give precise meaning to mathematical statements. Distinguish between valid and invalid mathematical arguments. Applications: Design of computer circuits. Construction of computer programs. Verification of correctness of programs.

3 3 2006 310205 Mathematics for Comter I 2.1. Logic Logic deals with statements and their truth sets. The statements are called propositions. proposition : true = T (or 1) or false = F (or 0) (binary logic) 1+1 = 2 (Y) ‘the moon is made of green cheese’ (Y) y+1=2 (X) - Uncertain ‘go to town!’ (X) - imperative ‘What time is it?’ (X) - interrogative propositional variables: P, Q, R, S,...

4 4 2006 310205 Mathematics for Comter I 2.1. Logic Calculus of propositions: Relate new propositions to old using TRUTH TABLES logical operators (op): Unary: negation Binary: conjunction, disjunction, exclusive or, implication, biconditional

5 5 2006 310205 Mathematics for Comter I 2.1. Logic Truth Table Displays the relationships between the truth values of propositions. P1P2P1 op P2 00 01 10 11

6 6 2006 310205 Mathematics for Comter I 2.2. Unary Operator Negation ‘not’ Symbol:  Example: P : I am going to town  P: I am not going to town or It is not the case that I am going to town Truth table: P PP F (0)T (1) F (0)

7 7 2006 310205 Mathematics for Comter I 2.3. Binary Operators Binary Conjunction ‘and’ Symbol:  Example: P: I am going to town Q: It is going to rain P  Q: I am going to town and it is going to rain. Truth Table: Both P and Q must be true !!! PQ PQPQ 000 010 100 111

8 8 2006 310205 Mathematics for Comter I 2.3. Binary Operators Binary Disjunction – Inclusive ‘or’ Symbol:  Example: P: I am going to town Q: It is going to rain P  Q: I am going to town or it is going to rain. Truth Table: Only one of P, Q need be true. Hence, the inclusive nature. PQ PQPQ 000 011 101 111

9 9 2006 310205 Mathematics for Comter I 2.3. Binary Operators Exclusive ‘or’ Symbol:  Example: P: I am going to town Q: It is going to rain P  Q: Either I am going to town or it is going to rain. Truth Table: Only one of P and Q must be true. PQ PQPQ 000 011 101 110

10 10 2006 310205 Mathematics for Comter I 2.3. Binary Operators Implication ‘If...then...’ Symbol:  Example: P: I am going to town Q: It is going to rain P  Q: If I am going to town then it is going to rain. Truth Table: The implication is false only when P is true and Q is false! PQ PQPQ 001 011 100 111

11 11 2006 310205 Mathematics for Comter I 2.3. Binary Operators In C programming language AND && Inclusive OR || Exclusive OR ^ Not !

12 12 2006 310205 Mathematics for Comter I 2.3. Binary Operators Implication (continued) Equivalent forms: If P, then Q P implies Q If P, Q P is a sufficient condition for Q Q if P Q whenever P Q is a necessary condition for P Terminology: P = premise, hypothesis, antecedent Q = conclusion, consequence

13 13 2006 310205 Mathematics for Comter I 2.3. Binary Operators Implication (continued) A useful way to remember the truth table is to think of a contract or an obligation.

14 14 2006 310205 Mathematics for Comter I 2.3. Binary Operators Example: If you make more than $ 25,000, then you must file a tax return. The statement says nothing about someone making less than $ 25,000 – so true every time. You violate the obligation only if you make more than $ 25,000 and do not file a return. If the total marks of a student are more than 55%, then the student will pass this course. A student whose marks less than 55% may still pass. It is wrong if a student has more than 55% and fails.

15 15 2006 310205 Mathematics for Comter I 2.3. Binary Operators Implication (continued) There is no causality implied here! If today is Friday, then 2+3 = 5. True, since its conclusion is true. If today is Friday, then 2+3 = 6. True everyday except Friday, even though 2+3 = 6 is false. Compare implications used in normal language: If it is sunny today, then we will go to the beach

16 16 2006 310205 Mathematics for Comter I 2.3. Binary Operators Implication (continued) More terminology: Q  P is the CONVERSE of P  Q  Q  P is the CONTRAPOSITIVE of P  Q Example: Find the converse and contrapositive of the following statement: R: Raining tomorrow is a sufficient condition for my not going to town. Step 1: Assign propositional variables to component propositions P: It will rain tomorrow Q: I will not go to town

17 17 2006 310205 Mathematics for Comter I 2.3. Binary Operators Example (continued): Step 2: Symbolize the assertion R: P  Q Step 3: Symbolize the converse Q  P Step 4: Convert the symbols back into word If I don’t go to town then it will rain tomorrow. or Raining tomorrow is a necessary condition for my not going to town. or My not going to town is a sufficient condition for it raining tomorrow.

18 18 2006 310205 Mathematics for Comter I 2.3. Binary Operators Biconditional ‘If and only if’, ‘iff’ Symbol:  Example: P: I am going to town Q: It is going to rain P  Q: I am going to town if and only if it is going to rain. Truth Table: Both P and Q must have the same truth value. PQ PQPQ 001 010 100 111

19 19 2006 310205 Mathematics for Comter I 2.3. Binary Operators Biconditional (continued) Example: You must file a tax return if and only if you make more than $ 25,000. The statement now says something about someone making less than $ 25,000 – the rule is violated if somebody asks to pay tax but your income is less than $ 25,000. You violate the obligation if you make more than $ 25,000 and do not file a return.

20 20 2006 310205 Mathematics for Comter I 2.4. Translating English Sentences Breaking assertions into component propositions - look for the logical operators! Example: If I go to Harry’s or go to the country I will not go shopping. P: I go to Harry’s Q: I go to the country R: I will go shopping If......P......or.....Q.....then....not.....R (P  Q)  R

21 21 2006 310205 Mathematics for Comter I 2.4. Translating English Sentences Constructing a truth table: one column for each propositional variable one for the compound proposition count in binary n propositional variables = 2 n rows You may find it easier to include columns for propositions which themselves are component propositions. e.g. columns for P  Q.

22 22 2006 310205 Mathematics for Comter I 2.4. Translating English Sentences Truth Table: PQR PQPQ(P  Q)  R 00001 00101 01011 01110 10011 10110 11011 11110

23 23 2006 310205 Mathematics for Comter I 2.4. Translating English Sentences Question: How many different propositions can be constructed from n propositional variables?

24 24 2006 310205 Mathematics for Comter I 2.5. Further Readings Basic definitions Rosen: Section 1.1 Logical operators Rosen: Section 1.1 Translating English sentences Rosen: Section 1.1


Download ppt "1 2006 310205 Mathematics for Comter I Lecture 2: Logic (1) Basic definitions Logical operators Translating English sentences."

Similar presentations


Ads by Google