1 / 54

Chapter 2 Fundamentals of Logic

Discrete and Combinatorial Mathematics R. P. Grimaldi , 5 th edition, 2004. Chapter 2 Fundamentals of Logic. Logic. Logic = the study of correct reasoning Use of logic In mathematics: to prove theorems In computer science: to prove that programs do what they are supposed to do.

Download Presentation

Chapter 2 Fundamentals of Logic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Discrete and Combinatorial MathematicsR. P. Grimaldi,5th edition, 2004 Chapter 2 Fundamentals of Logic

  2. Logic Logic = the study of correct reasoning Use of logic In mathematics: to prove theorems In computer science: to prove that programs do what they are supposed to do

  3. Propositions (命題) A proposition or statement (陳述) is a declarative sentence that may be assigned a ‘true’ or ‘false’ value, but not both. This value is the truth value of the proposition. Propositions: “1+2=3”, “Peter is a programmer”, “It is snowing”. Not Propositions: “Is 1+2=3?”, “What a beautiful evening!”, “The number x is an integer”. Also Propositions: “There exists no ghost”.

  4. True or False, That’s All The proposition “There exists no ghost” is on equal footing with the “1+2=3” proposition. The only thing that matters is the fact that a proposition is ‘True’ or ‘False’. Because of this, we will often label our propositions simply p,q, etc. Sometimes we use 0 for False and 1 for True. Things become interesting if we combine propositions…

  5. Connectives (連接詞) If p and q are propositions, new compoundpropositions (複合命題) can be formed by using connectives. Most common connectives: Conjunction AND Symbol ^ (且) Disjunction OR Symbol v (或) Exclusive disjunction OR Symbol v (互斥或) Negation NOT Symbol  (非) Implication Symbol  (則,蘊含) Biconditional Symbol  (若且唯若) The truth values of compound propositions can be described by truth tables (真值表).

  6. Truth table of conjunction: p ^ q is true only when both p and q are true. Example: p = "Tigers are animals", q = "Lions are plants" p ^ q = "Tigers are animals and Lions are plants" Truth table of conjunction

  7. Truth table of disjunction The truth table of disjunction: p  q is false only when both p and q are false Example: p = "John is a programmer", q = "Mary is a lawyer" p v q = "John is a programmer or Mary is a lawyer"

  8. Exclusive disjunction “Either p or q” (but not both), in symbols p  q p  q is true only when p is true and q is false, or p is false and q is true. Example: p = "John is programmer, q = "Mary is a lawyer“ p v q = "Either John is a programmer or Mary is a lawyer but not both."

  9. Negation Negation of p: in symbols p • p is false when p is true,  p is true when p is false. Example: p = "John is a programmer“  p = "It is not true that John is a programmer"

  10. More compound propositions Let p, q, r be primitive propositions (簡單命題). We can form other compound propositions, such as (pq)^r p(q^r) ( p)( q) (pq)^( r) and many others…

  11. Example: truth table of (pq)^r

  12. Implication A conditionalproposition (條件命題) is of the form “p implies q”, denoted by p  q, where p is the hypothesis (前提) and q is the conclusion (結論). Also “If p then q”.“p is sufficient for q”, “p is a sufficient condition (充分條件) for q”, “q is necessary for p”, “q is a necessary condition (必要條件) for p”, “p only if q”. Example: p = " John is a programmer " q = " Mary is a lawyer " p  q = “If John is a programmer then Mary is a lawyer"

  13. Truth table of p  q p  q is true when both p and q are true or when p is false

  14. Biconditional The biconditional proposition (雙向命題) is of the form “p if and only if q” or “ p iff q ” (若且唯若), denoted by p  q. p  q is true when both p  q and q  p are true. Example: p = " John is a programmer " q = " Mary is a lawyer " p  q = “John is a programmer iff Mary is a lawyer"

  15. Logical equivalence (邏輯等價) Two propositions are said to be logically equivalent () if their truth tables are identical. Example:  p  q  p  q

  16. Biconditional vs. Equivalence Don’t confuse the equivalence  with the biconditional (only the biconditional has a truth table). For example:p  p is a proposition, a statement within logic, p  p is mathematically correct, … about logic. p  p is a False, p  p is incorrect Hence pp  (pp), and so on.

  17. Converse The converse of p  q is q  p These two propositions are not logically equivalent

  18. Contrapositive (對換句) The contrapositive of the proposition p  q is  q   p. They are logically equivalent.

  19. Tautology (恆真命題) A proposition is a tautology (T0) if its truth table contains only true values for every case.

  20. Contradiction (矛盾命題) A proposition is a contradiction (F0) if its truth table contains only false values for every case.

  21. Example Pay attention to the phrase “logically”: “2 = 3–1” is not a tautology, but “2=1 or 21” is;“1+1=3” is not a contradiction, but “1=1 and 11” is.As with equivalence: look at the truth tables.

  22. Proving Things in Logic The standard approach is to use truth tables. If we deal with n simple propositions p1,…,pn, our truth table will have size at least 2n. This becomes a substantial disadvantage if n is big. Sometimes there is a much more efficient way to prove equivalences. First, look at some very simple equivalences…

  23. The Laws of Logic • Double negation law: p  p       (雙否定定律) • De Morgan’s laws: (pq)  pq,(De Morgan 定律) (pq)  pq • Commutative laws: pq  qp and (交換律) pq  qp • Associative laws: p(qr)  (pq)r, (結合律) p(qr)  (pq)r • Distributive laws: p(qr)  (pq)(pr), (分配律)  p(qr)  (pq)(pr)

  24. The Laws of Logic (Cont.) • Idempotent laws: pp  p,(冪等定律) pp  p • Identity laws: pFalse  p,(恆等定律) pTrue  p • Inverse laws: pp  True,(逆定律) pp  False • Domination laws: pTrue  True,(支配律) pFalse  False • Absorption laws: p(pq)  p,(吸收律) p(pq)  p

  25. Proving Equivalences Prove (p  q )  (p  q)  p. (p  q )  (p  q)  (p  q )  (p  q) [DeMorgan’s Law]  (p  q )  (p  q) [Double Negation]  p (q  q) [Distributive Law]  p F0 [Inverse Law]  p [Identity Law] #

  26. Simplify Statements Simplify “(p  q  r)  (p  t  q) (p  t  r)”. (p  q  r)  (p  t  q) (p  t  r) • p  [(q  r)  (t q) (t  r)] [Distributive Law] • p  [(q  r)  (t  r)  (t q )] [Commutative Law] • p  [((q  t)  r)  (t q )] [Distributive Law] • p  [((q  t)  r)  (t q )] [Double Negation] • p  [((q  t)  r)  (t q )] [DeMorgan’s Law] • p  [(t q )  ((q  t)  r)] [Commutative Law] • p  [((t q )  (q  t))  ((t q )  r)] [Distributive Law] • p  [F0 ((t q )  r)] [s s  F0  s] • p  [(t q )  r] [F0 is the identity for ]

  27. Simplify Statements (Cont.) p  [(t q )  r] • p  [(t  q)  r] [DeMorgan’s Law] • p  [(t  q)  r] [Double Negation] • p  [r (t  q)] [Commutative Law] Hence (p  q  r)  (p  t  q) (p  t  r)  p  [r (t  q)]. #

  28. Valid arguments (有效論證) Deductive reasoning(演繹推導): the process of reaching a conclusion q from a sequence of propositions p1, p2, …, pn. The propositions p1, p2, …, pn are called premises or hypothesis. The proposition q that is logically obtained through the process is called the conclusion.

  29. 1. Modus ponens(肯定前件式) p  q p Therefore, q Example: Insects have six legs. Beetles are insects. Therefore beetles have six legs. Rules of inference

  30. Rules of inference (Cont.) 2. Modus tollens (否定後件式) • p  q • ~q • Therefore, ~p Example: • Insects have six legs. • Spiders have eight legs. • Therefore spiders are not insects.

  31. 3. Rule of disjunctive amplification p Therefore, p  q 4. Rule of conjunctive simplification p ^ q Therefore, p Rules of inference (Cont.) 5. Rule of conjunction • p • q • Therefore, p ^ q

  32. 6. Lawof thesyllogism (三段論法) p  q q  r Therefore, p  r Example: 72 is divisible by 6. 6 is divisible by 3. Therefore 72 is divisible by 3. Rules of inference (Cont.)

  33. Rules of inference (Cont.) 7. Ruleof disjunctivesyllogism(析取三段論法) • p  q • p • Therefore, q Example: • John is studying or sleeping. • John is not studying. • Therefore John is sleeping.

  34. Rules of inference (Cont.) 8. Ruleof contradiction(矛盾證法) • p  F0 • Therefore, p If we want to establish the validity of the argument (p1 p2  …  pn)  q, we can establish the validity of the logically equivalent argument (p1 p2  …  pn  q)  F0.

  35. Example Demonstrate the validity of the argument ((p  r)  (p q)  (q  s))  (r  s) (1) p  r (2) r  p (3) p  q (4) r  q (Law of the Syllogism) (5) q  s (6) Therefore r  s (Law of the Syllogism)

  36. Example Demonstrate the validity of the argument (((p  q)  (r  s))  (r t)  (t))  p (1) r  t (2) t (3) r (Rule of disjunctive syllogism) (4) r  s (Rule of disjunctive amplification) (5) (r  s) (De Morgan’s law) (6) (p  q)  (r  s) (7)  (p  q) (Rule of disjunctive syllogism) (8) p  q (De Morgan’s law) (9) Therefore p (Rule of conjunctive simplification)

  37. Quantifiers (量詞) A propositional function (命題函數) or open statement P(x) is a statement involving a variable x. For example: P(x): 2x is an even integer, where x is an element of a set D.

  38. Domain of a Propositional Function In the propositional function P(x): “2x is an even integer”, the domain or universe D of P(x) must be defined, for instance D = {integers}.D is the set where the x's come from.

  39. For every and for some Most statements in mathematics and computer science use terms such as for every and for some. For example: For every triangle T, the sum of the angles of T is 180 degrees. For every integer n, n is less than p, for some prime number p.

  40. Universal quantifier One can write P(x) for every x in a domain D In symbols: x P(x) “” is called the universal quantifier (通用量詞). The statement x P(x) is True if P(x) is true for every x  D False if P(x) is not true for some x  D Example: Let P(n) be the propositional function n2 + 2n is an odd integer n  D = {all integers} P(n) is True only when n is an odd integer, False if n is an even integer.

  41. Existential quantifier For some x  D, P(x) is true if there exists an element x in the domain D for which P(x) is true. In symbols: x, P(x) “” is called the existential quantifier (存在量詞).

  42. Counterexample The universal statement x P(x) is false if x  D such that P(x) is false. The value x that makes P(x) false is called a counterexample to the statement x P(x). Example: P(x) = "every x is a prime number", for every integer x. But if x = 4 (an integer) this x is not a primer number. Then 4 is a counterexample to P(x) being true.

  43. Generalized De Morgan’s Laws If P(x) is a propositional function, then each pair of propositions in a) and b) below have the same truth values: a) ~(x P(x)) and x: ~P(x) "It is not true that for every x, P(x) holds" is equivalent to "There exists an x for which P(x) is not true“ b) ~(x P(x)) and x: ~P(x) "It is not true that there exists an x for which P(x) is true" is equivalent to "For all x, P(x) is not true"

  44. 1. Universal instantiation  xD, P(x) d  D Therefore P(d) 2. Universal generalization P(d) for any d  D Therefore xD, P(x) 3. Existential instantiation  x  D, P(x) Therefore P(d) for some d D 4. Existential generalization P(d) for some d D Therefore  xD, P(x) Rules of inference for quantified statements

  45. Equivalences and Implicationsfor quantified statements For a prescribed universe and any open statements P(x) and q(x) in the variable x: x [p(x)  q(x)]  [x p(x)  x q(x)] x [p(x)  q(x)]  [x p(x)  x q(x)] x [p(x)  q(x)]  [x p(x)  x q(x)] [x p(x)  x q(x)]  x [p(x)  q(x)]

  46. In order to prove the universally quantified statement x P(x) is true It is not enough to show P(x) true for some x  D You must show P(x) is true for every x  D In order to prove the universally quantified statement x P(x) is false It is enough to exhibit some x  D for which P(x) is false This x is called the counterexample to the statement x P(x) is true Demonstrate Universally Quantified Statement

  47. Axioms (公設) An axiom is a proposition accepted as true without proof within the mathematical system. There are many examples of axioms in mathematics: Example: In Euclidean geometry the following are axioms Given two distinct points, there is exactly one line that contains them. Given a line and a point not on the line, there is exactly one line through the point which is parallel to the line.

  48. Theorems (定理) A theorem is a proposition of the form p  q which must be shown to be true by a sequence of logical steps that assume that p is true, and use definitions, axioms and previously proven theorems.

  49. A lemma (輔助定理) is a small theorem which is used to prove a bigger theorem. A corollary (引理) is a theorem that can be proven to be a logical consequence of another theorem. Example from Euclidean geometry: "If the three sides of a triangle have equal length, then its angles also have equal measure." Lemmas and corollaries

  50. Types of proof A proof is a logical argument that consists of a series of steps using propositions in such a way that the truth of the theorem is established. • Direct proof • Indirect proof

More Related