Discrete Mathematics Chapter 1 Logic and proofs 152022

  • Slides: 48
Download presentation
Discrete Mathematics Chapter 1 Logic and proofs 1/5/2022 1

Discrete Mathematics Chapter 1 Logic and proofs 1/5/2022 1

Logic = the study of correct reasoning p Use of logic p n In

Logic = the study of correct reasoning p Use of logic p n In mathematics: p n In computer science: p 1/5/2022 to prove theorems to prove that programs do what they are supposed to do 2

Section 1. 1 Propositions A proposition is a statement or sentence that can be

Section 1. 1 Propositions A proposition is a statement or sentence that can be determined to be either true or false. p Examples: p n n 1/5/2022 “John is a programmer" is a proposition “I wish I were wise” is not a proposition 3

Connectives If p and q are propositions, new compound propositions can be formed by

Connectives If p and q are propositions, new compound propositions can be formed by using connectives p Most common connectives: n n n 1/5/2022 Conjunction AND. Inclusive disjunction OR Exclusive disjunction OR Negation Implication Double implication Symbol ^ Symbol v Symbol ~ Symbol 4

Truth table of conjunction The truth values of compound propositions can be described by

Truth table of conjunction The truth values of compound propositions can be described by truth tables. p Truth table of conjunction p p 1/5/2022 p T T F q T F T p^q T F F F p ^ q is true only when both p and q are true. 5

Example Let p = “Tigers are wild animals” p Let q = “Chicago is

Example Let p = “Tigers are wild animals” p Let q = “Chicago is the capital of Illinois” p p ^ q = "Tigers are wild animals and Chicago is the capital of Illinois" p p ^ q is false. Why? p 1/5/2022 6

Truth table of disjunction q q The truth table of (inclusive) disjunction is q

Truth table of disjunction q q The truth table of (inclusive) disjunction is q T F T pvq T T T F F F p q is false only when both p and q are false q q 1/5/2022 p T T F Example: p = "John is a programmer", q = "Mary is a lawyer" p v q = "John is a programmer or Mary is a lawyer" 7

Exclusive disjunction p q “Either p or q” (but not both), in symbols p

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

Negation p p Negation of p: in symbols ~p ~p T F F T

Negation p p Negation of p: in symbols ~p ~p T F F T ~p is false when p is true, ~p is true when p is false n n 1/5/2022 p Example: p = "John is a programmer" ~p = "It is not true that John is a programmer" 9

More compound statements Let p, q, r be simple statements p We can form

More compound statements Let p, q, r be simple statements p We can form other compound statements, such as p n n n 1/5/2022 (p q)^r p (q^r) (~p) (~q) (p q)^(~r) and many others… 10

Example: truth table of (p q)^r 1/5/2022 p q r (p q) ^ r

Example: truth table of (p q)^r 1/5/2022 p q r (p q) ^ r T T T F F T T T F F F F T F F F 11

1. 2 Conditional propositions and logical equivalence A conditional proposition is of the form

1. 2 Conditional propositions and logical equivalence A conditional proposition is of the form “If p then q” p In symbols: p q p Example: p n n n 1/5/2022 p = " John is a programmer" q = " Mary is a lawyer " p q = “If John is a programmer then Mary is a lawyer" 12

Truth table of p q q 1/5/2022 p q T T F F F

Truth table of p q q 1/5/2022 p q T T F F F T T F F T p q is true when both p and q are true or when p is false 13

Hypothesis and conclusion In a conditional proposition p q, p is called the antecedent

Hypothesis and conclusion In a conditional proposition p q, p is called the antecedent or hypothesis q is called the consequent or conclusion q If "p then q" is considered logically the same as "p only if q" p 1/5/2022 14

Necessary and sufficient A necessary condition is expressed by the conclusion. p A sufficient

Necessary and sufficient A necessary condition is expressed by the conclusion. p A sufficient condition is expressed by the hypothesis. p n Example: n If John is a programmer then Mary is a lawyer" Necessary condition: “Mary is a lawyer” Sufficient condition: “John is a programmer” n 1/5/2022 15

Logical equivalence q q Two propositions are said to be logically equivalent if their

Logical equivalence q q Two propositions are said to be logically equivalent if their truth tables are identical. p q ~p q p q T T F T F F T T Example: ~p q is logically equivalent to p q 1/5/2022 16

Converse p The converse of p q is q p p T T F

Converse p The converse of p q is q p p T T F q T F T p q T F T q p T T F F F T T These two propositions are not logically equivalent 1/5/2022 17

Contrapositive p The contrapositive of the proposition p q is ~q ~p. p T

Contrapositive p The contrapositive of the proposition p q is ~q ~p. p T q T p q T ~q ~p T T F F T F T F F T T They are logically equivalent. 1/5/2022 18

Double implication p The double implication “p if and only if q” is defined

Double implication p The double implication “p if and only if q” is defined in symbols as p q p q (p q) ^ (q p) T T T F F F F T T p q is logically equivalent to (p q)^(q p) 1/5/2022 19

Tautology p A proposition is a tautology if its truth table contains only true

Tautology p A proposition is a tautology if its truth table contains only true values for every case n 1/5/2022 Example: p p v q p pvq T T F F T 20

Contradiction p A proposition is a tautology if its truth table contains only false

Contradiction p A proposition is a tautology if its truth table contains only false values for every case n 1/5/2022 Example: p ^ ~p p p ^ (~p) T F F F 21

De Morgan’s laws for logic p The following pairs of propositions are logically equivalent:

De Morgan’s laws for logic p The following pairs of propositions are logically equivalent: ~ (p q) and (~p)^(~q) n ~ (p ^ q) and (~p) (~q) n 1/5/2022 22

1. 3 Quantifiers A propositional function P(x) is a statement involving a variable x

1. 3 Quantifiers A propositional function P(x) is a statement involving a variable x p For example: p n p x is an element of a set D n p 1/5/2022 P(x): 2 x is an even integer For example, x is an element of the set of integers D is called the domain of P(x) 23

Domain of a propositional function In the propositional function P(x): “ 2 x is

Domain of a propositional function In the propositional function P(x): “ 2 x is an even integer”, the domain D of P(x) must be defined, for instance D = {integers}. p D is the set where the x's come from. p 1/5/2022 24

For every and for some Most statements in mathematics and computer science use terms

For every and for some Most statements in mathematics and computer science use terms such as for every and for some. p For example: p n n 1/5/2022 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. 25

Universal quantifier p One can write P(x) for every x in a domain D

Universal quantifier p One can write P(x) for every x in a domain D n p 1/5/2022 In symbols: x P(x) is called the universal quantifier 26

Truth of as propositional function p The statement x P(x) is n n True

Truth of as propositional function p The statement x P(x) is n n 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 n 2 + 2 n is an odd integer n D = {all integers} p P(n) is true only when n is an odd integer, false if n is an even integer. p 1/5/2022 27

Existential quantifier For some x D, P(x) is true if there exists an element

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) p p 1/5/2022 The symbol is called the existential quantifier. 28

Counterexample p The universal statement x P(x) is false if x D such that

Counterexample p The universal statement x P(x) is false if x D such that P(x) is false. p The value x that makes P(x) false is called a counterexample to the statement x P(x). n n 1/5/2022 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. 29

Generalized De Morgan’s laws for Logic p If P(x) is a propositional function, then

Generalized De Morgan’s laws for Logic p 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" 1/5/2022 30

Summary of propositional logic p In order to prove the universally quantified statement x

Summary of propositional logic p In order to prove the universally quantified statement x P(x) is true n n 1/5/2022 It is not enough to show P(x) true for some x D You must show P(x) is true for every x D p In order to prove the universally quantified statement x P(x) is false n n 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 31

1. 4 Proofs p 1/5/2022 A mathematical system consists of n Undefined terms n

1. 4 Proofs p 1/5/2022 A mathematical system consists of n Undefined terms n Definitions n Axioms 32

Undefined terms p Undefined terms are the basic building blocks of a mathematical system.

Undefined terms p Undefined terms are the basic building blocks of a mathematical system. These are words that are accepted as starting concepts of a mathematical system. n 1/5/2022 Example: in Euclidean geometry we have undefined terms such as p Point p Line 33

Definitions p A definition is a proposition constructed from undefined terms and previously accepted

Definitions p A definition is a proposition constructed from undefined terms and previously accepted concepts in order to create a new concept. n n n 1/5/2022 Example. In Euclidean geometry the following are definitions: Two triangles are congruent if their vertices can be paired so that the corresponding sides are equal and so are the corresponding angles. Two angles are supplementary if the sum of their measures is 180 degrees. 34

Axioms An axiom is a proposition accepted as true without proof within the mathematical

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

Theorems p 1/5/2022 A theorem is a proposition of the form p q which

Theorems p 1/5/2022 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. 36

Lemmas and corollaries p A lemma is a small theorem which is used to

Lemmas and corollaries p A lemma is a small theorem which is used to prove a bigger theorem. p A corollary is a theorem that can be proven to be a logical consequence of another theorem. n 1/5/2022 Example from Euclidean geometry: "If the three sides of a triangle have equal length, then its angles also have equal measure. " 37

Types of proof A proof is a logical argument that consists of a series

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 theorem is established. p Direct proof: p q p n 1/5/2022 A direct method of attack that assumes the truth of proposition p, axioms and proven theorems so that the truth of proposition q is obtained. 38

Indirect proof q The method of proof by contradiction of a theorem p q

Indirect proof q The method of proof by contradiction of a theorem p q consists of the following steps: 1. Assume p is true and q is false 2. Show that ~p is also true. 3. Then we have that p ^ (~p) is true. 4. But this is impossible, since the statement p ^ (~p) is always false. There is a contradiction! 5. So, q cannot be false and therefore it is true. q OR: show that the contrapositive (~q) (~p) is true. q 1/5/2022 Since (~q) (~p) is logically equivalent to p q, then theorem is proved. 39

Valid arguments Deductive reasoning: the process of reaching a conclusion q from a sequence

Valid arguments Deductive reasoning: the process of reaching a conclusion q from a sequence of propositions p 1, p 2, …, pn. p The propositions p 1, p 2, …, pn are called premises or hypothesis. p The proposition q that is logically obtained through the process is called the conclusion. p 1/5/2022 40

Rules of inference (1) 1. Law of detachment or modus ponens n n n

Rules of inference (1) 1. Law of detachment or modus ponens n n n 1/5/2022 p q p Therefore, q 2. Modus tollens n n n p q ~q Therefore, ~p 41

Rules of inference (2) 3. Rule of Addition n n p Therefore, p q

Rules of inference (2) 3. Rule of Addition n n p Therefore, p q 5. Rule of conjunction n n 4. Rule of simplification n n 1/5/2022 n p q Therefore, p ^ q p^q Therefore, p 42

Rules of inference (3) 6. Rule of hypothetical syllogism np q nq r n

Rules of inference (3) 6. Rule of hypothetical syllogism np q nq r n Therefore, p r 7. Rule of disjunctive syllogism np q n ~p n Therefore, q 1/5/2022 43

Rules of inference for quantified statements 1. Universal instantiation 3. Existential instantiation n x

Rules of inference for quantified statements 1. Universal instantiation 3. Existential instantiation n x D, P(x) n x D, P(x) n d D n Therefore P(d) for some d D n Therefore P(d) 2. Universal generalization 4. Existential generalization n P(d) for some d D n P(d) for any d D n Therefore x, P(x) n Therefore x, P(x) 1/5/2022 44

1. 5 Resolution proofs p p Due to J. A. Robinson (1965) A clause

1. 5 Resolution proofs p p Due to J. A. Robinson (1965) A clause is a compound statement with terms separated by “or”, and each term is a single variable or the negation of a single variable n p p Example: p q (~r) is a clause (p ^ q) r (~s) is not a clause Hypothesis and conclusion are written as clauses Only one rule: n n n 1/5/2022 p q ~p r Therefore, q r 45

1. 6 Mathematical induction p Useful for proving statements of the form n A

1. 6 Mathematical induction p Useful for proving statements of the form n A S(n) where N is the set of positive integers or natural numbers, A is an infinite subset of N S(n) is a propositional function 1/5/2022 46

Mathematical Induction: strong form q Suppose we want to show that for each positive

Mathematical Induction: strong form q Suppose we want to show that for each positive integer n the statement S(n) is either true or false. n n 1/5/2022 1. Verify that S(1) is true. 2. Let n be an arbitrary positive integer. Let i be a positive integer such that i < n. 3. Show that S(i) true implies that S(i+1) is true, i. e. show S(i) S(i+1). 4. Then conclude that S(n) is true for all positive integers n. 47

Mathematical induction: terminology Basis step: p Inductive step: p p Conclusion: 1/5/2022 Verify that

Mathematical induction: terminology Basis step: p Inductive step: p p Conclusion: 1/5/2022 Verify that S(1) is true. Assume S(i) is true. Prove S(i) S(i+1). Therefore S(n) is true for all positive integers n. 48