Upcoming SlideShare
×

# CPSC 125 Ch 1 sec 2

999 views

Published on

Published in: Technology, Education
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

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

• Be the first to like this

Views
Total views
999
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
51
0
Likes
0
Embeds 0
No embeds

No notes for slide

### CPSC 125 Ch 1 sec 2

1. 1. Formal Logic Mathematical Structures for Computer Science Chapter 1 Copyright © 2006 W.H. Freeman & Co. MSCS Slides Formal Logic
2. 2. Propositional Logic <ul><li>Deriving a logical conclusion by combining many propositions and using formal logic: hence, determining the truth of arguments. </li></ul><ul><li>Definition of Argument : </li></ul><ul><li>An argument is a sequence of statements in which the conjunction of the initial statements (called the premises/hypotheses) is said to imply the final statement (called the conclusion). </li></ul><ul><li>An argument can be presented symbolically as </li></ul><ul><li>(P 1 Λ P 2 Λ ... Λ P n )  Q </li></ul><ul><li>where P 1 , P 2 , ..., P n represent the hypotheses and Q represents the conclusion. </li></ul>
3. 3. Valid Argument <ul><li>What is a valid argument?  When does Q logically follow from P 1 , P 2 , ..., P n . </li></ul><ul><li>Informal answer: Whenever the truth of hypotheses leads to the conclusion </li></ul><ul><li>Note: We need to focus on the relationship of the conclusion to the hypotheses and not just any knowledge we might have about the conclusion Q. </li></ul><ul><li>Example: </li></ul><ul><ul><li>P 1 : Neil Armstrong was the first human to step on the moon. </li></ul></ul><ul><ul><li>P 2 : Mars is a red planet </li></ul></ul><ul><ul><li>And the conclusion </li></ul></ul><ul><ul><li>Q: No human has ever been to Mars. </li></ul></ul><ul><ul><li>This wff P 1 Λ P 2  Q is not a tautology </li></ul></ul>
4. 4. Valid Argument <ul><li>Definition of valid argument : </li></ul><ul><li>An argument is valid if whenever the hypotheses are all true, the conclusion must also be true. A valid argument is intrinsically true, i.e. (P 1 Λ P 2 Λ ... Λ P n )  Q is a tautology. </li></ul><ul><li>How to arrive at a valid argument </li></ul><ul><ul><li>Using a proof sequence </li></ul></ul><ul><li>Definition of Proof Sequence : </li></ul><ul><li>A proof sequence is a sequence of wffs in which each wff is either a hypothesis or the result of applying one of the formal system’s derivation rules to earlier wffs in the sequence. </li></ul>
5. 5. Rules for Propositional Logic <ul><li>Derivation rules for propositional logic </li></ul>Work only in one direction Truth preserving rules Allows new wffs to be derived Allows individual wffs to be rewritten Inference Rules Equivalence Rules
6. 6. Equivalence Rules <ul><li>These rules state that certain pairs of wffs are equivalent, hence one can be substituted for the other with no change to truth values. </li></ul><ul><li>The set of equivalence rules are summarized here: </li></ul><ul><li>Let R and S be statement variables </li></ul>Equivalance - equ (P  Q) Λ ( Q  P) P  Q Double Negation- dn (R  )  R implication - imp R  V S R  S De-Morgan’s Laws De-Morgan R  Λ S  R  V S  (R V S)  (R Λ S)  Associative- ass R Λ (S Λ Q) R V (S V Q) (R V S) V Q (R Λ S) Λ Q Commutative - comm S V R R V S Abbreviation for rule Equivalent to Expression
7. 7. Inference Rules <ul><li>Inference rules allow us to add a wff to the last part of the proof sequence, if one or more wffs that match the first part already exist in the proof sequence. </li></ul><ul><li>Note: Inference rules do not work in both directions, unlike equivalence rules. </li></ul>Addition- add R V S R Simplification- sim R, S R Λ S Conjunction-con R Λ S R, S Modus Tollens- mt R  R  S, S  Modus Ponens- mp S R, R  S Abbreviation for rule Can Derive From
8. 8. Examples <ul><li>Example for using Equivalence rule in a proof sequence: </li></ul><ul><ul><li>Simplify (A  V B  ) V C </li></ul></ul><ul><li>1. (A  V B  ) V C </li></ul><ul><li>2. (A Λ B)  V C 1, De Morgan </li></ul><ul><li>3. ( A Λ B)  C 2, imp </li></ul><ul><li>Example of using Inference Rule </li></ul><ul><ul><li>If it is bright and sunny today, then I will wear my sunglasses. </li></ul></ul><ul><li>Modus Ponens </li></ul><ul><li>It is bright and sunny today. Therefore, I will wear my sunglasses. </li></ul><ul><li>Modus Tollens </li></ul><ul><li>I will not wear my sunglasses. Therefore, it is not bright and sunny today. </li></ul>
9. 9. Deduction Method <ul><li>To prove an argument of the form </li></ul><ul><li> P 1 Λ P 2 Λ ... Λ P n  R  Q </li></ul><ul><li>Deduction method allows for the use of R as an additional hypothesis and thus prove </li></ul><ul><li> P 1 Λ P 2 Λ ... Λ P n Λ R  Q </li></ul><ul><li>Prove (A  B) Λ (B  C)  (A  C) </li></ul><ul><li>Using deduction method, prove (A  B) Λ (B  C) Λ A  C </li></ul><ul><ul><li>A  B hyp </li></ul></ul><ul><ul><li>B  C hyp </li></ul></ul><ul><ul><li>A hyp </li></ul></ul><ul><ul><li>B 1,3 mp </li></ul></ul><ul><ul><li>C 2,4 mp </li></ul></ul><ul><li>The above is called the rule of Hypothetical Syllogism or hs in short. </li></ul><ul><li>Many such other rules can be derived from existing rules which thus provide easier and faster proofs. </li></ul>
10. 10. More Inference Rules <ul><li>These rules can be derived using the previous rules. They provide a faster way of proving arguments. </li></ul>Distributive - dist (P V Q) Λ (P V R) P V (Q Λ R) Distributive - dist (P Λ Q) V (P Λ R) P Λ (Q V R) Inconsistency - inc Q P, P  Exportation - exp P  (Q  R) (P Λ Q)  R Self-reference - self P P V P Self-reference - self P Λ P P Contraposition- cont P  Q Q   P  Contraposition- cont Q   P  P  Q Disjunctive syllogism- ds Q P V Q, P  Hypothetical syllogism- hs P  R P  Q, Q  R Name / Abbreviation Can Derive From
11. 11. Proofs of inference rules <ul><li>Prove that (P  Q)  (Q   P  ) is a valid argument (called Contraposition – con). </li></ul><ul><ul><li>Hence prove, (P  Q) Λ Q   P  (using deduction method). </li></ul></ul><ul><ul><li>The above is true using the modus tollens inference rule. </li></ul></ul><ul><li>Prove P Λ P   Q (called Inconsistency) </li></ul><ul><ul><li>P hyp </li></ul></ul><ul><ul><li>P  hyp </li></ul></ul><ul><ul><li>P V Q 1, add </li></ul></ul><ul><ul><li>Q V P 3, comm </li></ul></ul><ul><ul><li>(Q  )  V P 4, dn </li></ul></ul><ul><ul><li>Q   P 5, imp </li></ul></ul><ul><ul><li>(Q  )  2, 6, mt </li></ul></ul><ul><ul><li>Q 7, dn </li></ul></ul>
12. 12. Proofs using Propositional Logic <ul><li>Prove the argument </li></ul><ul><li>A Λ (B  C) Λ [(A Λ B)  (D V C  )] Λ B  D </li></ul><ul><ul><li>First, write down all the hypotheses. </li></ul></ul><ul><ul><li>A </li></ul></ul><ul><ul><li>B  C </li></ul></ul><ul><ul><li>(A Λ B)  (D V C  ) </li></ul></ul><ul><ul><li>B </li></ul></ul><ul><ul><li>Use the inference and equivalence rules to get at the conclusion D. </li></ul></ul><ul><ul><li>C 2,4, mp </li></ul></ul><ul><ul><li>A Λ B 1,4, con </li></ul></ul><ul><ul><li>D V C  3,6, mp </li></ul></ul><ul><ul><li>C  V D 7, comm </li></ul></ul><ul><ul><li>C  D 8, imp </li></ul></ul><ul><ul><li>and finally </li></ul></ul><ul><ul><li>D 5,9 imp </li></ul></ul><ul><ul><li>The idea is to keep focused on the result and sometimes it is very easy to go down a longer path than necessary. </li></ul></ul>
13. 13. More Proofs <ul><li>(A Λ B)  Λ (C  Λ A)  Λ (C Λ B  )   A  is an argument </li></ul><ul><li>(A Λ B)  hyp </li></ul><ul><li>(C  Λ A)  hyp </li></ul><ul><li>(C Λ B  )  hyp </li></ul><ul><li>A  V B  1, De Morgan </li></ul><ul><li>B  V A  4, comm </li></ul><ul><li>B  A  5, imp </li></ul><ul><li>(C  )  V A  2, De Morgan </li></ul><ul><li>C   A  7, imp </li></ul><ul><li>C  V ( B  )  3, De Morgan </li></ul><ul><li>( B  )  V C  9, comm </li></ul><ul><li>B   C  10, imp </li></ul><ul><li>B   A  8, 11, hs </li></ul><ul><li>(B  A  ) Λ ( B   A  ) 6, 12, con </li></ul>
14. 14. Proof Continued <ul><li>At this point, we have now to prove that </li></ul><ul><li>(B  A  ) Λ ( B   A  )  A  </li></ul><ul><li>Proof sequence </li></ul><ul><li>B  A  hyp </li></ul><ul><li>B   A  hyp </li></ul><ul><li>A  B  1, cont </li></ul><ul><li>A  A  3, 2, hs </li></ul><ul><li>A  V A  4, imp </li></ul><ul><li>A  6, self </li></ul>
15. 15. Proving Verbal Arguments <ul><li>Russia was a superior power, and either France was not strong or Napoleon made an error. Napoleon did not make an error, but if the army did not fail, then France was strong. Hence the army failed and Russia was a superior power. </li></ul><ul><li>Converting it to a propositional form using letters A, B, C and D </li></ul><ul><ul><li>A: Russia was a superior power </li></ul></ul><ul><ul><li>B: France was strong B  : France was not strong </li></ul></ul><ul><ul><li>C: Napoleon made an error C  : Napoleon did not make an error </li></ul></ul><ul><ul><li>D: The army failed D  : The army did not fail </li></ul></ul><ul><li>Combining, the statements using logic </li></ul><ul><ul><li>(A Λ (B  V C)) hypothesis </li></ul></ul><ul><ul><li>C  hypothesis </li></ul></ul><ul><ul><li>( D   B) hypothesis </li></ul></ul><ul><ul><li>(D Λ A) conclusion </li></ul></ul><ul><li>Combining them, the propositional form is </li></ul><ul><ul><li>(A Λ (B  V C)) Λ C  Λ ( D   B)  (D Λ A) </li></ul></ul>
16. 16. Verbal Argument Proof <ul><li>Prove (A Λ (B  V C)) Λ C  Λ ( D   B)  (D Λ A) </li></ul><ul><li>Proof sequence </li></ul><ul><ul><li>A Λ (B  V C) hyp </li></ul></ul><ul><ul><li>C  hyp </li></ul></ul><ul><ul><li>D   B hyp </li></ul></ul><ul><ul><li>A 1, sim </li></ul></ul><ul><ul><li>B  V C 1, sim </li></ul></ul><ul><ul><li>C V B  5, comm </li></ul></ul><ul><ul><li>B  2, 6, ds </li></ul></ul><ul><ul><li>B   (D  )  3, cont </li></ul></ul><ul><ul><li>(D  )  7, 8, mp </li></ul></ul><ul><ul><li>D 9, dn </li></ul></ul><ul><ul><li>D Λ A 4, 10 , con </li></ul></ul>
17. 17. Class Exercise <ul><li>Prove the following arguments </li></ul><ul><ul><li>(A´  B´) Λ (A  C)  (B  C) </li></ul></ul><ul><ul><li>(Y  Z´) Λ (X´  Y) Λ [Y  (X  W)] Λ (Y  Z)  (Y  W) </li></ul></ul><ul><li>If the program is efficient, it executes quickly. Either the program is efficient, or it has a bug. However, the program does not execute quickly. Therefore it has a bug. (use letters E, Q, B) </li></ul><ul><li>The crop is good, but there is not enough water. If there is a lot of rain or not a lot of sun, then there is enough water. Therefore the crop is good and there is a lot of sun. (use letters C, W, R, S) </li></ul>
18. 18. Class Exercise <ul><li>Write down the propositional form of the following argument: </li></ul><ul><li>If my client is guilty, then the knife was in the drawer. Either the knife was not in the drawer or Jason Pritchard saw the knife. If the knife was not there on October 10, it follows that Jason Pritchard didn’t see the knife. Furthermore, if the knife was there on October 10, then the knife was in the drawer and also the hammer was in the barn. But we all know that the hammer was not in the barn. Therefore, ladies and gentlemen of the jury, my client is innocent. </li></ul>