770 likes | 1.35k Views
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.
E N D
Discrete and Combinatorial MathematicsR. P. Grimaldi,5th 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
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”.
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…
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 (真值表).
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
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"
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."
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"
More compound propositions Let p, q, r be primitive propositions (簡單命題). We can form other compound propositions, such as (pq)^r p(q^r) ( p)( q) (pq)^( r) and many others…
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"
Truth table of p q p q is true when both p and q are true or when p is false
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"
Logical equivalence (邏輯等價) Two propositions are said to be logically equivalent () if their truth tables are identical. Example: p q p q
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 pp (pp), and so on.
Converse The converse of p q is q p These two propositions are not logically equivalent
Contrapositive (對換句) The contrapositive of the proposition p q is q p. They are logically equivalent.
Tautology (恆真命題) A proposition is a tautology (T0) if its truth table contains only true values for every case.
Contradiction (矛盾命題) A proposition is a contradiction (F0) if its truth table contains only false values for every case.
Example Pay attention to the phrase “logically”: “2 = 3–1” is not a tautology, but “2=1 or 21” is;“1+1=3” is not a contradiction, but “1=1 and 11” is.As with equivalence: look at the truth tables.
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…
The Laws of Logic • Double negation law: p p (雙否定定律) • De Morgan’s laws: (pq) pq,(De Morgan 定律) (pq) pq • Commutative laws: pq qp and (交換律) pq qp • Associative laws: p(qr) (pq)r, (結合律) p(qr) (pq)r • Distributive laws: p(qr) (pq)(pr), (分配律) p(qr) (pq)(pr)
The Laws of Logic (Cont.) • Idempotent laws: pp p,(冪等定律) pp p • Identity laws: pFalse p,(恆等定律) pTrue p • Inverse laws: pp True,(逆定律) pp False • Domination laws: pTrue True,(支配律) pFalse False • Absorption laws: p(pq) p,(吸收律) p(pq) p
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] #
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 ]
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)]. #
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.
1. Modus ponens(肯定前件式) p q p Therefore, q Example: Insects have six legs. Beetles are insects. Therefore beetles have six legs. Rules of inference
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.
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
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.)
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.
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.
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)
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)
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.
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.
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.
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.
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 (存在量詞).
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.
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"
1. Universal instantiation xD, P(x) d D Therefore P(d) 2. Universal generalization P(d) for any d D Therefore xD, 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 xD, P(x) Rules of inference for quantified statements
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)]
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
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.
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.
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
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