1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
S 50 R 51
1st Pass Pages
1019763_FM_VOL-I.qxp 9/17/07 4:22 PM Page viii
User
Zone de texte
This page was intentionally left blank
List of Symbols
Subject Symbol Meaning Page
Logic ∼p not p 25 p ∧ q p and q 25 p ∨ q p or q 25 p ⊕ q or p XOR q p or q but not both p and q 28 P ≡ Q P is logically equivalent to Q 30 p→ q if p then q 40 p↔ q p if and only if q 45 ∴ therefore 51 P(x) predicate in x 97
P(x)⇒ Q(x) every element in the truth set for P(x) is in 104 the truth set for Q(x)
P(x)⇔ Q(x) P(x) and Q(x) have identical truth sets 104 ∀ for all 101 ∃ there exists 103
Applications of Logic NOT NOT-gate 67
AND AND-gate 67
OR OR-gate 67
NAND NAND-gate 75
NOR NOR-gate 75
| Sheffer stroke 74
↓ Peirce arrow 74 n2 number written in binary notation 78
n10 number written in decimal notation 78
n16 number written in hexadecimal notation 91
Number Theory and Applications
d | n d divides n 170 d |/ n d does not divide n 172 n div d the integer quotient of n divided by d 181
n mod d the integer remainder of n divided by d 181
�x� the floor of x 191 �x� the ceiling of x 191 |x | the absolute value of x 187 gcd(a, b) the greatest common divisor of a and b 220
x := e x is assigned the value e 214
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Subject Symbol Meaning Page
Sequences . . . and so forth 227 n∑
k=m ak the summation from k equals m to n of ak 230
n∏ k=m
ak the product from k equals m to n of ak 223
n! n factorial 237 Set a ∈ A a is an element of A 7 Theory a /∈ A a is not an element of A 7
{a1, a2, . . . , an} the set with elements a1, a2, . . . , an 7 {x ∈ D | P(x)} the set of all x in D for which P(x) is true 8 R,R−,R+,Rnonneg the sets of all real numbers, negative real 7, 8
numbers, positive real numbers, and nonnegative real numbers
Z,Z−,Z+,Znonneg the sets of all integers, negative integers, 7, 8 positive integers, and nonnegative integers
Q,Q−,Q+,Qnonneg the sets of all rational numbers, negative 7, 8 rational numbers, positive rational numbers, and nonnegative rational numbers
N the set of natural numbers 8
A ⊆ B A is a subset of B 9 A �⊆ B A is not a subset of B 9 A = B A equals B 339 A ∪ B A union B 341 A ∩ B A intersect B 341 B − A the difference of B minus A 341 Ac the complement of A 341
(x, y) ordered pair 11
(x1, x2, . . . , xn) ordered n-tuple 346
A × B the Cartesian product of A and B 12 A1 × A2 × · · · × An the Cartesian product of A1, A2, . . . , An 347 ∅ the empty set 361 P(A) the power set of A 346
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
List of Symbols
Subject Symbol Meaning Page
Counting and N (A) the number of elements in set A 518 Probability P(A) the probability of a set A 518
P(n, r) the number of r -permutations of a set of 553 n elements(n
r
) n choose r , the number of r -combinations 566 of a set of n elements, the number of r -element subsets of a set of n elements
[xi1 , xi2 , . . . , xir ] multiset of size r 584 P(A | B) the probability of A given B 612
Functions f : X → Y f is a function from X to Y 384 f (x) the value of f at x 384
x f→y f sends x to y 384
f (A) the image of A 397
f −1(C) the inverse image of C 397
Ix the identity function on X 387
bx b raised to the power x 405, 406
expb(x) b raised to the power x 405, 406
logb(x) logarithm with base b of x 388
F−1 the inverse function of F 411
f ◦ g the composition of g and f 417 Algorithm x ∼= y x is approximately equal to y 237 Efficiency O( f (x)) big-O of f of x 727
�( f (x)) big-Omega of f of x 727
�( f (x)) big-Theta of f of x 727
Relations x R y x is related to y by R 14
R−1 the inverse relation of R 444
m ≡ n (mod d) m is congruent to n modulo d 473 [a] the equivalence class of a 465 x � y x is related to y by a partial order relation � 502
Continued on first page of back endpapers.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
DISCRETE MATHEMATICS
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
DISCRETE MATHEMATICS WITH APPLICATIONS
FOURTH EDITION
SUSANNA S. EPP DePaul University
Australia · Brazil · Japan · Korea ·Mexico · Singapore · Spain · United Kingdom · United States
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
S 50 R 51
1st Pass Pages
1019763_FM_VOL-I.qxp 9/17/07 4:22 PM Page viii
User
Zone de texte
This page was intentionally left blank
52609_00_fm_pi-pxxvi.indd ii52609_00_fm_pi-pxxvi.indd ii 2/1/10 11:37:43 PM2/1/10 11:37:43 PM
This is an electronic version of the print textbook. Due to electronic rights
restrictions, some third party content may be suppressed. Editorial review has deemed that any suppres ed content does not materially
affect the overall learning experience. The publisher reserves the right to remove content from this title at any time if subsequent rights restrictions require it. For valuable information on pricing, previous editions, changes to current editions, and alternate formats, please visit www.cengage.com/highered to search by ISBN#, author, title, or keyword for materials in your areas of interest.
s
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Cover Photo: The stones are discrete objects placed one on top of another like a chain of careful reasoning. A person who decides to build such a tower aspires to the heights and enjoys playing with a challenging problem. Choosing the stones takes both a scientific and an aesthetic sense. Getting them to balance requires patient effort and careful thought. And the tower that results is beautiful. A perfect metaphor for discrete mathematics!
DiscreteMathematics with Applications, Fourth Edition Susanna S. Epp
Publisher: Richard Stratton
Senior Sponsoring Editor: Molly Taylor
Associate Editor: Daniel Seibert
Editorial Assistant: Shaylin Walsh
Associate Media Editor: Andrew Coppola
Senior Marketing Manager: Jennifer Pursley Jones
Marketing Communications Manager: Mary Anne Payumo
Marketing Coordinator: Erica O’Connell
Content Project Manager: Alison Eigel Zade
Senior Art Director: Jill Ort
Senior Print Buyer: Diane Gibbons
Right Acquisition Specialists: Timothy Sisler and Don Schlotman
Production Service: Elm Street Publishing Services
Photo Manager: Chris Althof, Bill Smith Group
Cover Designer: Hanh Luu
Cover Image: GettyImages.com (Collection: OJO Images, Photographer: Martin Barraud)
Compositor: Integra Software Services Pvt. Ltd.
c© 2011, 2004, 1995 Brooks/Cole Cengage Learning ALL RIGHTS RESERVED. No part of this work covered by the copyright herein may be reproduced, transmitted, stored, or used in any form or by any means graphic, electronic, or mechanical, including but not limited to photocopying, recording, scanning, digitizing, taping, Web distribution, information networks, or information storage and retrieval systems, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the publisher.
For product information and technology assistance, contact us at Cengage Learning Customer & Sales Support, 1-800-354-9706.
For permission to use material from this text or product, submit all requests online at www.cengage.com/permissions.
Further permissions questions can be emailed to permissionrequest@cengage.com.
Library of Congress Control Number: 2010927831
Student Edition: ISBN-13: 978-0-495-39132-6 ISBN-10: 0-495-39132-8
Brooks/Cole 20 Channel Center Street Boston, MA 02210 USA
Cengage Learning is a leading provider of customized learning solutions with office locations around the globe, including Singapore, the United Kingdom, Australia, Mexico, Brazil, and Japan. Locate your local office at: international.cengage.com/region.
Cengage Learning products are represented in Canada by Nelson Education, Ltd.
For your course and learning solutions, visit www.cengage.com
Purchase any of our products at your local college store or at our preferred online store www.cengagebrain.com.
Printed in Canada 1 2 3 4 5 6 7 14 13 12 11 10
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
To Jayne and Ernest
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
vi
CONTENTS
Chapter 1 Speaking Mathematically 1
1.1 Variables 1 Using Variables in Mathematical Discourse; Introduction to Universal, Existential, and Conditional Statements
1.2 The Language of Sets 6 The Set-Roster and Set-Builder Notations; Subsets; Cartesian Products
1.3 The Language of Relations and Functions 13 Definition of a Relation from One Set to Another; Arrow Diagram of a Relation; Definition of Function; Function Machines; Equality of Functions
Chapter 2 The Logic of Compound Statements 23
2.1 Logical Form and Logical Equivalence 23 Statements; Compound Statements; Truth Values; Evaluating the Truth of More Gen- eral Compound Statements; Logical Equivalence; Tautologies and Contradictions; Summary of Logical Equivalences
2.2 Conditional Statements 39 Logical Equivalences Involving →; Representation of If-Then As Or; The Nega- tion of a Conditional Statement; The Contrapositive of a Conditional Statement; The Converse and Inverse of a Conditional Statement; Only If and the Biconditional; Necessary and Sufficient Conditions; Remarks
2.3 Valid and Invalid Arguments 51 Modus Ponens and Modus Tollens; Additional Valid Argument Forms: Rules of Inference; Fallacies; Contradictions and Valid Arguments; Summary of Rules of Inference
2.4 Application: Digital Logic Circuits 64 Black Boxes and Gates; The Input/Output Table for a Circuit; The Boolean Expres- sion Corresponding to a Circuit; The Circuit Corresponding to a Boolean Expres- sion; Finding a Circuit That Corresponds to a Given Input/Output Table; Simplifying Combinational Circuits; NAND and NOR Gates
2.5 Application: Number Systems and Circuits for Addition 78 Binary Representation of Numbers; Binary Addition and Subtraction; Circuits for Computer Addition; Two’s Complements and the Computer Representation of
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents vii
Negative Integers; 8-Bit Representation of a Number; Computer Addition with Negative Integers; Hexadecimal Notation
Chapter 3 The Logic of Quantified Statements 96
3.1 Predicates and Quantified Statements I 96 The Universal Quantifier: ∀; The Existential Quantifier: ∃; Formal Versus Informal Language; Universal Conditional Statements; Equivalent Forms of Universal and Existential Statements; Implicit Quantification; Tarski’s World
3.2 Predicates and Quantified Statements II 108 Negations of Quantified Statements; Negations of Universal Conditional Statements; The Relation among ∀, ∃, ∧, and ∨; Vacuous Truth of Universal Statements; Variants of Universal Conditional Statements; Necessary and Sufficient Conditions, Only If
3.3 Statements with Multiple Quantifiers 117 Translating from Informal to Formal Language; Ambiguous Language; Negations of Multiply-Quantified Statements; Order of Quantifiers; Formal Logical Notation; Prolog
3.4 Arguments with Quantified Statements 132 Universal Modus Ponens; Use of Universal Modus Ponens in a Proof; Universal Modus Tollens; Proving Validity of Arguments with Quantified Statements; Using Diagrams to Test for Validity; Creating Additional Forms of Argument; Remark on the Converse and Inverse Errors
Chapter 4 Elementary Number Theory and Methods of Proof 145
4.1 Direct Proof and Counterexample I: Introduction 146 Definitions; Proving Existential Statements; Disproving Universal Statements by Counterexample; Proving Universal Statements; Directions for Writing Proofs of Universal Statements; Variations among Proofs; Common Mistakes; Getting Proofs Started; Showing That an Existential Statement Is False; Conjecture, Proof, and Disproof
4.2 Direct Proof and Counterexample II: Rational Numbers 163 More on Generalizing from the Generic Particular; Proving Properties of Rational Numbers; Deriving New Mathematics from Old
4.3 Direct Proof and Counterexample III: Divisibility 170 Proving Properties of Divisibility; Counterexamples and Divisibility; The Unique Factorization of Integers Theorem
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
viii Contents
4.4 Direct Proof and Counterexample IV: Division into Cases and the Quotient-Remainder Theorem 180 Discussion of the Quotient-Remainder Theorem and Examples; div and mod; Alter- native Representations of Integers and Applications to Number Theory; Absolute Value and the Triangle Inequality
4.5 Direct Proof and Counterexample V: Floor and Ceiling 191 Definition and Basic Properties; The Floor of n/2
4.6 Indirect Argument: Contradiction and Contraposition 198 Proof by Contradiction; Argument by Contraposition; Relation between Proof by Contradiction and Proof by Contraposition; Proof as a Problem-Solving Tool
4.7 Indirect Argument: Two Classical Theorems 207 The Irrationality of
√ 2; Are There Infinitely Many Prime Numbers?; When to Use
Indirect Proof; Open Questions in Number Theory
4.8 Application: Algorithms 214 An Algorithmic Language; A Notation for Algorithms; Trace Tables; The Division Algorithm; The Euclidean Algorithm
Chapter 5 Sequences, Mathematical Induction, and Recursion 227
5.1 Sequences 227 Explicit Formulas for Sequences; Summation Notation; Product Notation; Properties of Summations and Products; Change of Variable; Factorial and n Choose r Notation; Sequences in Computer Programming; Application: Algorithm to Convert from Base 10 to Base 2 Using Repeated Division by 2
5.2 Mathematical Induction I 244 Principle of Mathematical Induction; Sum of the First n Integers; Proving an Equal- ity; Deducing Additional Formulas; Sum of a Geometric Sequence
5.3 Mathematical Induction II 258 Comparison of Mathematical Induction and Inductive Reasoning; Proving Divisibil- ity Properties; Proving Inequalities; A Problem with Trominoes
5.4 Strong Mathematical Induction and the Well-Ordering Principle for the Integers 268 StrongMathematical Induction;Binary Representation of Integers;TheWell-Ordering Principle for the Integers
5.5 Application: Correctness of Algorithms 279 Assertions; Loop Invariants; Correctness of the Division Algorithm; Correctness of the Euclidean Theorem
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents ix
5.6 Defining Sequences Recursively 290 Definition of Recurrence Relation; Examples of Recursively Defined Sequences; Recursive Definitions of Sum and Product
5.7 Solving Recurrence Relations by Iteration 304 The Method of Iteration; Using Formulas to Simplify Solutions Obtained by Itera- tion; Checking the Correctness of a Formula byMathematical Induction; Discovering That an Explicit Formula Is Incorrect
5.8 Second-Order Linear Homogenous Recurrence Relations with Constant Coefficients 317 Derivation of a Technique for Solving These Relations; The Distinct-Roots Case; The Single-Root Case
5.9 General Recursive Definitions and Structural Induction 328 Recursively Defined Sets; Using Structural Induction to Prove Properties about Recursively Defined Sets; Recursive Functions
Chapter 6 Set Theory 336
6.1 Set Theory: Definitions and the Element Method of Proof 336 Subsets; Proof and Disproof; Set Equality; Venn Diagrams; Operations on Sets; The Empty Set; Partitions of Sets; Power Sets; Cartesian Products; An Algorithm to Check Whether One Set Is a Subset of Another (Optional)
6.2 Properties of Sets 352 Set Identities; Proving Set Identities; Proving That a Set Is the Empty Set
6.3 Disproofs, Algebraic Proofs, and Boolean Algebras 367 Disproving an Alleged Set Property; Problem-Solving Strategy; The Number of Sub- sets of a Set; “Algebraic” Proofs of Set Identities
6.4 Boolean Algebras, Russell’s Paradox, and the Halting Problem 374 Boolean Algebras; Description of Russell’s Paradox; The Halting Problem
Chapter 7 Functions 383
7.1 Functions Defined on General Sets 383 Additional Function Terminology; More Examples of Functions; Boolean Functions; Checking Whether a Function Is Well Defined; Functions Acting on Sets
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
x Contents
7.2 One-to-One and Onto, Inverse Functions 397 One-to-One Functions; One-to-One Functions on Infinite Sets; Application: Hash Functions; Onto Functions; Onto Functions on Infinite Sets; Relations between Expo- nential and Logarithmic Functions; One-to-One Correspondences; Inverse Functions
7.3 Composition of Functions 416 Definition and Examples; Composition of One-to-One Functions; Composition of Onto Functions
7.4 Cardinality with Applications to Computability 428 Definition of Cardinal Equivalence; Countable Sets; The Search for Larger Infinities: The Cantor Diagonalization Process; Application: Cardinality and Computability
Chapter 8 Relations 442
8.1 Relations on Sets 442 Additional Examples of Relations; The Inverse of a Relation; Directed Graph of a Relation; N -ary Relations and Relational Databases
8.2 Reflexivity, Symmetry, and Transitivity 449 Reflexive, Symmetric, and Transitive Properties; Properties of Relations on Infinite Sets; The Transitive Closure of a Relation
8.3 Equivalence Relations 459 The Relation Induced by a Partition; Definition of an Equivalence Relation; Equiva- lence Classes of an Equivalence Relation
8.4 Modular Arithmetic with Applications to Cryptography 478 Properties of Congruence Modulo n; Modular Arithmetic; Extending the Euclidean Algorithm; Finding an Inverse Modulo n; RSA Cryptography; Euclid’s Lemma; Fermat’s Little Theorem; Why Does the RSA Cipher Work?; Additional Remarks on Number Theory and Cryptography
8.5 Partial Order Relations 498 Antisymmetry; Partial Order Relations; Lexicographic Order; Hasse Diagrams; Partially and Totally Ordered Sets; Topological Sorting; An Application; PERT and CPM
Chapter 9 Counting and Probability 516
9.1 Introduction 517 Definition of Sample Space and Event; Probability in the Equally Likely Case; Count- ing the Elements of Lists, Sublists, and One-Dimensional Arrays
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents xi
9.2 Possibility Trees and the Multiplication Rule 525 Possibility Trees; The Multiplication Rule; When the Multiplication Rule Is Difficult or Impossible to Apply; Permutations; Permutations of Selected Elements
9.3 Counting Elements of Disjoint Sets: The Addition Rule 540 The Addition Rule; The Difference Rule; The Inclusion/Exclusion Rule
9.4 The Pigeonhole Principle 554 Statement and Discussion of the Principle; Applications; Decimal Expansions of Fractions; Generalized Pigeonhole Principle; Proof of the Pigeonhole Principle
9.5 Counting Subsets of a Set: Combinations 565 r -Combinations; Ordered and Unordered Selections; Relation between Permutations and Combinations; Permutation of a Set with Repeated Elements; Some Advice about Counting; The Number of Partitions of a Set into r Subsets
9.6 r-Combinations with Repetition Allowed 584 Multisets and How to Count Them; Which Formula to Use?
9.7 Pascal’s Formula and the Binomial Theorem 592 Combinatorial Formulas; Pascal’s Triangle; Algebraic and Combinatorial Proofs of Pascal’s Formula; The Binomial Theorem and Algebraic and Combinatorial Proofs for It; Applications
9.8 Probability Axioms and Expected Value 605 Probability Axioms; Deriving Additional Probability Formulas; Expected Value
9.9 Conditional Probability, Bayes’ Formula, and Independent Events 611 Conditional Probability; Bayes’ Theorem; Independent Events
Chapter 10 Graphs and Trees 625
10.1 Graphs: Definitions and Basic Properties 625 Basic Terminology and Examples of Graphs; Special Graphs; The Concept of Degree
10.2 Trails, Paths, and Circuits 642 Definitions; Connectedness; Euler Circuits; Hamiltonian Circuits
10.3 Matrix Representations of Graphs 661 Matrices; Matrices and Directed Graphs; Matrices and Undirected Graphs; Matrices and Connected Components; Matrix Multiplication; Counting Walks of Length N
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xii Contents
10.4 Isomorphisms of Graphs 675 Definition of Graph Isomorphism and Examples; Isomorphic Invariants; Graph Isomorphism for Simple Graphs
10.5 Trees 683 Definition and Examples of Trees; Characterizing Trees
10.6 Rooted Trees 694 Definition and Examples of Rooted Trees; Binary Trees and Their Properties
10.7 Spanning Trees and Shortest Paths 701 Definition of a Spanning Tree; Minimum Spanning Trees; Kruskal’s Algorithm; Prim’s Algorithm; Dijkstra’s Shortest Path Algorithm
Chapter 11 Analysis of Algorithm Efficiency 717
11.1 Real-Valued Functions of a Real Variable and Their Graphs 717 Graph of a Function; Power Functions; The Floor Function; Graphing Functions Defined on Sets of Integers; Graph of a Multiple of a Function; Increasing and Decreasing Functions
11.2 O-, �-, and �-Notations 725 Definition and General Properties of O-, �-, and �-Notations; Orders of Power Functions; Orders of Polynomial Functions; Orders for Functions of Integer Vari- ables; Extension to Functions Composed of Rational Power Functions
11.3 Application: Analysis of Algorithm Efficiency I 739 Computing Orders of Simple Algorithms; The Sequential Search Algorithm; The Insertion Sort Algorithm; Time Efficiency of an Algorithm
11.4 Exponential and Logarithmic Functions: Graphs and Orders 751 Graphs of Exponential and Logarithmic Functions; Application: Number of Bits Needed to Represent an Integer in Binary Notation; Application: Using Logarithms to Solve Recurrence Relations; Exponential and Logarithmic Orders
11.5 Application: Analysis of Algorithm Efficiency II 764 Binary Search; Divide-and-Conquer Algorithms; The Efficiency of the Binary Search Algorithm; Merge Sort; Tractable and Intractable Problems; A Final Remark on Algorithm Efficiency
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Contents xiii
Chapter 12 Regular Expressions and Finite-State Automata 779
12.1 Formal Languages and Regular Expressions 780 Definitions and Examples of Formal Languages and Regular Expressions; The Lan- guage Defined by a Regular Expression; Practical Uses of Regular Expressions
12.2 Finite-State Automata 791 Definition of a Finite-State Automaton; The Language Accepted by an Automa- ton; The Eventual-State Function; Designing a Finite-State Automaton; Simulating a Finite-State Automaton Using Software; Finite-State Automata and Regular Expres- sions; Regular Languages
12.3 Simplifying Finite-State Automata 808
*-Equivalence of States; k-Equivalence of States; Finding the *-Equivalence Classes; TheQuotientAutomaton;Constructing theQuotientAutomaton; EquivalentAutomata
Appendix A Properties of the Real Numbers A-1
Appendix B Solutions and Hints to Selected Exercises A-4
Index I-1
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xiv
PREFACE
My purpose in writing this book was to provide a clear, accessible treatment of discrete mathematics for students majoring or minoring in computer science, mathematics, math- ematics education, and engineering. The goal of the book is to lay the mathematical foundation for computer science courses such as data structures, algorithms, relational database theory, automata theory and formal languages, compiler design, and cryptog- raphy, and for mathematics courses such as linear and abstract algebra, combinatorics, probability, logic and set theory, and number theory. By combining discussion of theory and practice, I have tried to show that mathematics has engaging and important applica- tions as well as being interesting and beautiful in its own right.
A good background in algebra is the only prerequisite; the course may be taken by students either before or after a course in calculus. Previous editions of the book have been used successfully by students at hundreds of institutions in North and South Amer- ica, Europe, the Middle East, Asia, and Australia.
Recent curricular recommendations from the Institute for Electrical and Electronic Engineers Computer Society (IEEE-CS) and the Association for Computing Machinery (ACM) include discrete mathematics as the largest portion of “core knowledge” for com- puter science students and state that students should take at least a one-semester course in the subject as part of their first-year studies, with a two-semester course preferred when possible. This book includes the topics recommended by those organizations and can be used effectively for either a one-semester or a two-semester course.
At one time, most of the topics in discrete mathematics were taught only to upper- level undergraduates. Discovering how to present these topics in ways that can be under- stood by first- and second-year students was the major and most interesting challenge of writing this book. The presentation was developed over a long period of experimentation during which my students were in many ways my teachers. Their questions, comments, and written work showed me what concepts and techniques caused them difficulty, and their reaction to my exposition showed me what worked to build their understanding and to encourage their interest. Many of the changes in this edition have resulted from con- tinuing interaction with students.
Themes of a Discrete Mathematics Course Discrete mathematics describes processes that consist of a sequence of individual steps. This contrasts with calculus, which describes processes that change in a continuous fash- ion. Whereas the ideas of calculus were fundamental to the science and technology of the industrial revolution, the ideas of discrete mathematics underlie the science and technol- ogy of the computer age. The main themes of a first course in discrete mathematics are logic and proof, induction and recursion, discrete structures, combinatorics and discrete probability, algorithms and their analysis, and applications and modeling.
Logic and Proof Probably the most important goal of a first course in discrete math- ematics is to help students develop the ability to think abstractly. This means learning to use logically valid forms of argument and avoid common logical errors, appreciating what it means to reason from definitions, knowing how to use both direct and indirect
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface xv
argument to derive new results from those already known to be true, and being able to work with symbolic representations as if they were concrete objects.
Induction and Recursion An exciting development of recent years has been the increased appreciation for the power and beauty of “recursive thinking.” To think recur- sively means to address a problem by assuming that similar problems of a smaller nature have already been solved and figuring out how to put those solutions together to solve the larger problem. Such thinking is widely used in the analysis of algorithms, where recurrence relations that result from recursive thinking often give rise to formulas that are verified by mathematical induction.
Discrete Structures Discrete mathematical structures are the abstract structures that describe, categorize, and reveal the underlying relationships among discrete mathemat- ical objects. Those studied in this book are the sets of integers and rational numbers, general sets, Boolean algebras, functions, relations, graphs and trees, formal languages and regular expressions, and finite-state automata.
Combinatorics and Discrete Probability Combinatorics is the mathematics of count- ing and arranging objects, and probability is the study of laws concerning the measure- ment of random or chance events. Discrete probability focuses on situations involving discrete sets of objects, such as finding the likelihood of obtaining a certain number of heads when an unbiased coin is tossed a certain number of times. Skill in using combina- torics and probability is needed in almost every discipline where mathematics is applied, from economics to biology, to computer science, to chemistry and physics, to business management.
Algorithms and Their Analysis The word algorithm was largely unknown in the mid- dle of the twentieth century, yet now it is one of the first words encountered in the study of computer science. To solve a problem on a computer, it is necessary to find an algo- rithm or step-by-step sequence of instructions for the computer to follow. Designing an algorithm requires an understanding of the mathematics underlying the problem to be solved. Determining whether or not an algorithm is correct requires a sophisticated use of mathematical induction. Calculating the amount of time or memory space the algo- rithm will need in order to compare it to other algorithms that produce the same output requires knowledge of combinatorics, recurrence relations, functions, and O-, �-, and �-notations.
Applications and Modeling Mathematical topics are best understood when they are seen in a variety of contexts and used to solve problems in a broad range of applied situations. One of the profound lessons of mathematics is that the same mathematical model can be used to solve problems in situations that appear superficially to be totally dissimilar. A goal of this book is to show students the extraordinary practical utility of some very abstract mathematical ideas.
Special Features of This Book Mathematical Reasoning The feature that most distinguishes this book from other discrete mathematics texts is that it teaches—explicitly but in a way that is accessible to first- and second-year college and university students—the unspoken logic and reasoning that underlie mathematical thought. For many years I taught an intensively interactive transition-to-abstract-mathematics course to mathematics and computer science majors. This experience showed me that while it is possible to teach the majority of students to
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xvi Preface
understand and construct straightforward mathematical arguments, the obstacles to doing so cannot be passed over lightly. To be successful, a text for such a course must address students’ difficulties with logic and language directly and at some length. It must also include enough concrete examples and exercises to enable students to develop the mental models needed to conceptualize more abstract problems. The treatment of logic and proof in this book blends common sense and rigor in a way that explains the essentials, yet avoids overloading students with formal detail.
Spiral Approach to Concept Development A number of concepts in this book appear in increasingly more sophisticated forms in successive chapters to help students develop the ability to deal effectively with increasing levels of abstraction. For example, by the time students encounter the relatively advanced mathematics of Fermat’s little theorem in Section 8.4, they have been introduced to the logic of mathematical discourse in Chapters 1, 2, and 3, learned the basic methods of proof and the concepts of mod and div in Chapter 4, explored mod and div as functions in Chapter 7, and become familiar with equivalence relations in Sections 8.2 and 8.3. This approach builds in useful review and develops mathematical maturity in natural stages.
Support for the Student Students at colleges and universities inevitably have to learn a great deal on their own. Though it is often frustrating, learning to learn through self- study is a crucial step toward eventual success in a professional career. This book has a number of features to facilitate students’ transition to independent learning.
Worked Examples The book contains over 500 worked examples, which are written using a problem- solution format and are keyed in type and in difficulty to the exercises. Many solutions for the proof problems are developed in two stages: first a discussion of how one might come to think of the proof or disproof and then a summary of the solution, which is enclosed in a box. This format allows students to read the problem and skip immediately to the summary, if they wish, only going back to the discussion if they have trouble understanding the summary. The format also saves time for students who are rereading the text in preparation for an examination.
Marginal Notes and Test Yourself Questions Notes about issues of particular importance and cautionary comments to help students avoid common mistakes are included in the margins throughout the book. Questions designed to focus attention on the main ideas of each section are located between the text and the exercises. For convenience, the questions use a fill-in-the-blank format, and the answers are found immediately after the exercises.
Exercises The book contains almost 2600 exercises. The sets at the end of each section have been designed so that students with widely varying backgrounds and ability levels will find some exercises they can be sure to do successfully and also some exercises that will challenge them.
Solutions for Exercises To provide adequate feedback for students between class sessions, Appendix B con- tains a large number of complete solutions to exercises. Students are strongly urged not to consult solutions until they have tried their best to answer the questions on their own. Once they have done so, however, comparing their answers with those given can lead to significantly improved understanding. In addition, many problems, including some of the most challenging, have partial solutions or hints so that students can determine whether they are on the right track and make adjustments if necessary.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface xvii
There are also plenty of exercises without solutions to help students learn to grapple with mathematical problems in a realistic environment.
Reference Features Many students have written me to say that the book helped them succeed in their advanced courses. One even wrote that he had used one edition so extensively that it had fallen apart, and he actually went out and bought a copy of the next edition, which he was continuing to use in a master’s program. Figures and tables are included where doing so would help readers to a better understanding. In most, a second color is used to highlight meaning. My rationale for screening statements of definitions and theorems, for putting titles on exercises, and for giving the meanings of symbols and a list of reference formulas in the endpapers is to make it easier for students to use this book for review in a current course and as a reference in later ones.
Support for the Instructor I have received a great deal of valuable feedback from instructors who have used previous editions of this book. Many aspects of the book have been improved through their suggestions. In addition to the following items, there is additional instructor support on the book’s website, described later in the preface.
Exercises The large variety of exercises at all levels of difficulty allows instructors great free- dom to tailor a course to the abilities of their students. Exercises with solutions in the back of the book have numbers in blue, and those whose solutions are given in a separate Student Solutions Manual and Study Guide have numbers that are a multi- ple of three. There are exercises of every type that are represented in this book that have no answer in either location to enable instructors to assign whatever mixture they prefer of exercises with and without answers. The ample number of exercises of all kinds gives instructors a significant choice of problems to use for review assign- ments and exams. Instructors are invited to use the many exercises stated as questions rather than in “prove that” form to stimulate class discussion on the role of proof and counterexample in problem solving.
Flexible Sections Most sections are divided into subsections so that an instructor who is pressed for time can choose to cover certain subsections only and either omit the rest or leave them for the students to study on their own. The division into subsections also makes it easier for instructors to break up sections if they wish to spend more then one day on them.
Presentation of Proof Methods It is inevitable that the proofs and disproofs in this book will seem easy to instructors. Many students, however, find them difficult. In showing students how to discover and construct proofs and disproofs, I have tried to describe the kinds of approaches that mathematicians use when confronting challenging problems in their own research.
Instructor Solutions Complete instructor solutions to all exercises are available to anyone teaching a course from this book via Cengage’s Solution Builder service. Instructors can sign up for access at www.cengage.com/solutionbuilder.
Highlights of the Fourth Edition The changes made for this edition are based on suggestions from colleagues and other long-time users of previous editions, on continuing interactions with my students, and on developments within the evolving fields of computer science and mathematics.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xviii Preface
Reorganization A new Chapter 1 introduces students to some of the precise language that is a foun- dation for much mathematical thought: the language of variables, sets, relations, and functions. In response to requests from some instructors, core material is now placed together in Chapter 1–8, with the chapter on recursion now joined to the chapter on induction. Chapters 9–12 were placed together at the end because, although many instructors cover one or more of them, there is considerable diversity in their choices, with some of the topics from these chapters being included in other courses.
Improved Pedagogy
• The number of exercises has been increased to almost 2600. Approximately 300 new exercises have been added.
• Exercises have been added for topics where students seemed to need additional practice, and they have been modified, as needed, to address student difficulties.
• Additional full answers have been incorporated into Appendix B to give students more help for difficult topics.
• The exposition has been reexamined throughout and revised where needed. • Discussion of historical background and recent results has been expanded and the number of photographs of mathematicians and computer scientists whose contribu- tions are discussed in the book has been increased.
Logic and Set theory
• The definition of sound argument is now included, and there is additional clarifica- tion of the difference between a valid argument and a true conclusion.
• Examples and exercises about trailing quantifiers have been added. • Definitions for infinite unions and intersections have been incorporated. Introduction to Proof
• The directions for writing proofs and the discussion of common mistakes have been expanded.
• The descriptions of methods of proof have been made clearer. • Exercises have been revised and/or relocated to promote the development of student understanding.
Induction and Recursion
• The format for outlining proofs by mathematical induction has been improved. • The subsections in the section on sequences have been reorganized. • The sets of exercises for the sections on strong mathematical induction and the well-ordering principle and on recursive definitions have been expanded.
• Increased attention has been given to structural induction. Number Theory
• A subsection on open problems in number theory has been expanded and includes additional discussion of recent mathematical discoveries in number theory.
• The presentation in the section on modular arithmetic and cryptography has been streamlined.
• The discussion of testing for primality has been clarified.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface xix
Combinatorics and Discrete Probability
• The discussion of the pigeonhole principle has been moved to this chapter. Functions
• There is increased coverage of functions of more than one variable and of functions acting on sets.
Graph Theory
• The terminology about traveling in a graph has been updated. • Dijkstra’s shortest path algorithm is now included. • Exercises were added to introduce students to graph coloring.
Companion Website www.cengage.com/math/epp
A website has been developed for this book that contains information and materials for both students and instructors. It includes:
• descriptions and links to many sites on the Internet with accessible information about discrete mathematical topics,
• links to applets that illustrate or provide practice in the concepts of discrete mathe- matics,
• additional examples and exercises with solutions, • review guides for the chapters of the book. A special section for instructors contains:
• suggestions about how to approach the material of each chapter, • solutions for all exercises not fully solved in Appendix B, • ideas for projects and writing assignments, • PowerPoint slides, • review sheets and additional exercises for quizzes and exams.
Student Solutions Manual and Study Guide (ISBN-10: 0-495-82613-8; ISBN-13: 978-0-495-82613-2)
In writing this book, I strove to give sufficient help to students through the exposition in the text, the worked examples, and the exercise solutions, so that the book itself would provide all that a student would need to successfully master the material of the course. I believe that students who finish the study of this book with the ability to solve, on their own, all the exercises with full solutions in Appendix B will have developed an excellent command of the subject. Nonetheless, I became aware that some students wanted the opportunity to obtain additional helpful materials. In response, I developed a Student Solutions Manual and Study Guide, available separately from this book, which contains complete solutions to every exercise that is not completely answered in Appendix B and whose number is divisible by 3. The guide also includes alternative explanations for some of the concepts and review questions for each chapter.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xx Preface
Organization This book may be used effectively for a one- or two-semester course. Chapters contain core sections, sections covering optional mathematical material, and sections covering optional applications. Instructors have the flexibility to choose whatever mixture will best serve the needs of their students. The following table shows a division of the sections into categories.
Sections Containing Optional Sections Containing Optional Chapter Core Sections Mathematical Material Computer Science Applications
1 1.1–1.3
2 2.1–2.3 2.5 2.4, 2.5
3 3.1–3.4 3.3 3.3
4 4.1–4.4, 4.6 4.5, 4.7 4.8
5 5.1, 5.2, 5.6, 5.7 5.3, 5.4, 5.8 5.1, 5.5, 5.9
6 6.1 6.2–6.4 6.1, 6.4
7 7.1, 7.2 7.3, 7.4 7.1, 7.2, 7.4
8 8.1–8.3 8.4, 8.5 8.4, 8.5
9 9.1–9.4 9.5–9.9 9.3
10 10.1, 10.5 10.2–10.4, 10.6 10.1, 10.2, 10.5–10.7
11 11.1, 11.2 11.4 11.3, 11.5
12 12.1, 12.2 12.3 12.1–12.3
The following tree diagram shows, approximately, how the chapters of this book depend on each other. Chapters on different branches of the tree are sufficiently inde- pendent that instructors need to make at most minor adjustments if they skip chapters but follow paths along branches of the tree.
In most cases, covering only the core sections of the chapters is adequate preparation for moving down the tree.
34
1
2
33
5
10 12*
6
8
11
7 9
∗Section 8.3 is needed for Section 12.3 but not for Sections 12.1 and 12.2.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Preface xxi
Acknowledgments I owe a debt of gratitude to many people at DePaul University for their support and encouragement throughout the years I worked on editions of this book. A number of my colleagues used early versions and previous editions and provided many excellent suggestions for improvement. For this, I am thankful to Louis Aquila, J. Marshall Ash, Allan Berele, Jeffrey Bergen, William Chin, Barbara Cortzen, Constantine Georgakis, Sigrun Goes, Jerry Goldman, Lawrence Gluck, Leonid Krop, Carolyn Narasimhan, Wal- ter Pranger, Eric Rieders, Ayse Sahin, Yuen-Fat Wong, and, most especially, Jeanne LaDuke. The thousands of students to whom I have taught discrete mathematics have had a profound influence on the book’s form. By sharing their thoughts and thought pro- cesses with me, they taught me how to teach them better. I am very grateful for their help. I owe the DePaul University administration, especially my dean, Charles Suchar, and my former deans, Michael Mezey and Richard Meister, a special word of thanks for considering the writing of this book a worthwhile scholarly endeavor.
My thanks to the reviewers for their valuable suggestions for this edition of the book: David Addis, Texas Christian University; Rachel Esselstein, California State University- Monterrey Bay; William Marion, Valparaiso University; Michael McClendon, Univer- sity of Central Oklahoma; and Steven Miller, Brown University. For their help with previous editions of the book, I am grateful to Itshak Borosh, Texas A & M Univer- sity; Douglas M. Campbell, Brigham Young University; David G. Cantor, University of California at Los Angeles; C. Patrick Collier, University of Wisconsin-Oshkosh; Kevan H. Croteau, Francis Marion University; Irinel Drogan, University of Texas at Arling- ton; Pablo Echeverria, Camden County College; Henry A. Etlinger, Rochester Insti- tute of Technology; Melvin J. Friske, Wisconsin Lutheran College; William Gasarch, University of Maryland; Ladnor Geissinger, University of North Carolina; Jerrold R. Griggs, University of South Carolina; Nancy Baxter Hastings, Dickinson College; Lillian Hupert, Loyola University Chicago; Joseph Kolibal, University of Southern Mississippi; Benny Lo, International Technological University; George Luger, University of New Mexico; Leonard T. Malinowski, Finger Lakes Community College; John F. Morrison, Towson State Unviersity; Paul Pederson, University of Denver; George Peck, Arizona State University; Roxy Peck, California Polytechnic State University, San Luis Obispo; Dix Pettey, University of Missouri; Anthony Ralston, State University of New York at Buffalo; Norman Richert, University of Houston–Clear Lake; John Roberts, University of Louisville; and George Schultz, St. Petersburg Junior College, Clearwater. Special thanks are due John Carroll, San Diego State University; Dr. Joseph S. Fulda; and Porter G. Webster, University of Southern Mississippi; Peter Williams, California State Uni- versity at San Bernardino; and Jay Zimmerman, Towson University for their unusual thoroughness and their encouragement.
I have also benefitted greatly from the suggestions of the many instructors who have generously offered me their ideas for improvement based on their experiences with pre- vious editions of the book, especially Jonathan Goldstine, Pennsylvania State University; David Hecker, St. Joseph’s University; Edward Huff, Northern Virginia Community Col- lege; Robert Messer, Albion College; Sophie Quigley, Ryerson University; Piotr Rud- nicki, University of Alberta; Anwar Shiek, Diné College; Norton Starr, Amherst College; and Eng Wee, National University of Singapore. Production of the third edition received valuable assistance from Christopher Novak, University of Michigan, Dearborn, and Ian Crewe, Ascension Collegiate School. For the third and fourth editions I am especially grateful for the many excellent suggestions for improvement made by Tom Jenkyns, Brock University, whose assistance throughout the production process was invaluable.
I owe many thanks to the Brooks/Cole staff, especially my editor, Dan Seibert, for his thoughtful advice and reassuringly calm direction of the production process, and my
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xxii Preface
previous editors, Stacy Green, Robert Pirtle, Barbara Holland, and Heather Bennett, for their encouragement and enthusiasm.
The older I get the more I realize the profound debt I owe my own mathematics teach- ers for shaping the way I perceive the subject. My first thanks must go to my husband, Helmut Epp, who, on a high school date (!), introduced me to the power and beauty of the field axioms and the view that mathematics is a subject with ideas as well as formulas and techniques. In my formal education, I am most grateful to Daniel Zelinsky and Ky Fan at Northwestern University and Izaak Wirszup, I. N. Herstein, and Irving Kaplansky at the University of Chicago, all of whom, in their own ways, helped lead me to appreciate the elegance, rigor, and excitement of mathematics.
To my family, I owe thanks beyond measure. I am grateful to my mother, whose keen interest in the workings of the human intellect started me many years ago on the track that led ultimately to this book, and to my late father, whose devotion to the written word has been a constant source of inspiration. I thank my children and grandchildren for their affection and cheerful acceptance of the demands this book has placed on my life. And, most of all, I am grateful to my husband, who for many years has encouraged me with his faith in the value of this project and supported me with his love and his wise advice.
Susanna Epp
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1
CHAPTER 1
SPEAKING MATHEMATICALLY
Therefore O students study mathematics and do not build without foundations. —Leonardo da Vinci (1452–1519)
The aim of this book is to introduce you to a mathematical way of thinking that can serve you in a wide variety of situations. Often when you start work on a mathematical problem, you may have only a vague sense of how to proceed. You may begin by looking at examples, drawing pictures, playing around with notation, rereading the problem to focus on more of its details, and so forth. The closer you get to a solution, however, the more your thinking has to crystallize. And the more you need to understand, the more you need language that expresses mathematical ideas clearly, precisely, and unambiguously.
This chapter will introduce you to some of the special language that is a foundation for much mathematical thought, the language of variables, sets, relations, and functions. Think of the chapter like the exercises you would do before an important sporting event. Its goal is to warm up your mental muscles so that you can do your best.
1.1 Variables A variable is sometimes thought of as a mathematical “John Doe” because you can use it as a placeholder when you want to talk about something but either (1) you imagine that it has one or more values but you don’t know what they are, or (2) you want whatever you say about it to be equally true for all elements in a given set, and so you don’t want to be restricted to considering only a particular, concrete value for it. To illustrate the first use, consider asking
Is there a number with the following property: doubling it and adding 3 gives the same result as squaring it?
In this sentence you can introduce a variable to replace the potentially ambiguous word “it”:
Is there a number x with the property that 2x + 3 = x2? The advantage of using a variable is that it allows you to give a temporary name to what you are seeking so that you can perform concrete computations with it to help discover its possible values. To emphasize the role of the variable as a placeholder, you might write the following:
Is there a number � with the property that 2 ·�+ 3 = �2? The emptiness of the box can help you imagine filling it in with a variety of different values, some of which might make the two sides equal and others of which might not.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2 Chapter 1 Speaking Mathematically
To illustrate the second use of variables, consider the statement:
No matter what number might be chosen, if it is greater than 2, then its square is greater than 4.
In this case introducing a variable to give a temporary name to the (arbitrary) number you might choose enables you to maintain the generality of the statement, and replacing all instances of the word “it” by the name of the variable ensures that possible ambiguity is avoided:
No matter what number n might be chosen, if n is greater than 2, then n2 is greater than 4.
Example 1.1.1 Writing Sentences Using Variables
Use variables to rewrite the following sentences more formally.
a. Are there numbers with the property that the sum of their squares equals the square of their sum?
b. Given any real number, its square is nonnegative.
Solution
a. Are there numbers a and b with the property that a2 + b2 = (a + b)2? Or: Are there numbers a and b such that a2 + b2 = (a + b)2? Or: Do there exist any numbers a and b such that a2 + b2 = (a + b)2?
Note In part (a) the answer is yes. For instance, a = 1 and b = 0 would work. Can you think of other numbers that would also work?
b. Given any real number r, r2 is nonnegative. Or: For any real number r, r2 ≥ 0. Or: For all real numbers r, r2 ≥ 0. ■
Some Important Kinds of Mathematical Statements Three of the most important kinds of sentences in mathematics are universal statements, conditional statements, and existential statements:
A universal statement says that a certain property is true for all elements in a set. (For example: All positive numbers are greater than zero.)
A conditional statement says that if one thing is true then some other thing also has to be true. (For example: If 378 is divisible by 18, then 378 is divisible by 6.)
Given a property that may or may not be true, an existential statement says that there is at least one thing for which the property is true. (For example: There is a prime number that is even.)
In later sections we will define each kind of statement carefully and discuss all of them in detail. The aim here is for you to realize that combinations of these statements can be expressed in a variety of different ways. One way uses ordinary, everyday language and another expresses the statement using one or more variables. The exercises are designed to help you start becoming comfortable in translating from one way to another.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1.1 Variables 3
Universal Conditional Statements Universal statements contain some variation of the words “for all” and conditional state- ments contain versions of the words “if-then.” A universal conditional statement is a statement that is both universal and conditional. Here is an example:
For all animals a, if a is a dog, then a is a mammal.
One of the most important facts about universal conditional statements is that they can be rewritten in ways that make them appear to be purely universal or purely conditional. For example, the previous statement can be rewritten in a way that makes its conditional nature explicit but its universal nature implicit:
If a is a dog, then a is a mammal. Or : If an animal is a dog, then the animal is a mammal.
The statement can also be expressed so as to make its universal nature explicit and its conditional nature implicit:
For all dogs a, a is a mammal. Or : All dogs are mammals.
The crucial point is that the ability to translate among various ways of expressing univer- sal conditional statements is enormously useful for doing mathematics and many parts of computer science.
Example 1.1.2 Rewriting a Universal Conditional Statement
Fill in the blanks to rewrite the following statement:
For all real numbers x , if x is nonzero then x2 is positive.
a. If a real number is nonzero, then its square .
Note If you introduce x in the first part of the sentence, be sure to include it in the second part of the sentence.
b. For all nonzero real numbers x , .
c. If x , then .
d. The square of any nonzero real number is .
e. All nonzero real numbers have .
Solution
a. is positive
b. x2 is positive
c. is a nonzero real number; x2 is positive
d. positive
e. positive squares (or: squares that are positive) ■
Universal Existential Statements A universal existential statement is a statement that is universal because its first part says that a certain property is true for all objects of a given type, and it is existential because its second part asserts the existence of something. For example:Note For a number b to
be an additive inverse for a number a means that a + b = 0. Every real number has an additive inverse.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
4 Chapter 1 Speaking Mathematically
In this statement the property “has an additive inverse” applies universally to all real num- bers. “Has an additive inverse” asserts the existence of something—an additive inverse— for each real number. However, the nature of the additive inverse depends on the real number; different real numbers have different additive inverses. Knowing that an additive inverse is a real number, you can rewrite this statement in several ways, some less formal and some more formal∗:
All real numbers have additive inverses. Or : For all real numbers r , there is an additive inverse for r . Or : For all real numbers r, there is a real number s such that s is an additive inverse
for r.
Introducing names for the variables simplifies references in further discussion. For instance, after the third version of the statement you might go on to write: When r is positive, s is negative, when r is negative, s is positive, and when r is zero, s is also zero.
One of the most important reasons for using variables in mathematics is that it gives you the ability to refer to quantities unambiguously throughout a lengthy mathematical argument, while not restricting you to consider only specific values for them.
Example 1.1.3 Rewriting a Universal Existential Statement
Fill in the blanks to rewrite the following statement: Every pot has a lid.
a. All pots .
b. For all pots P , there is .
c. For all pots P , there is a lid L such that .
Solution
a. have lids
b. a lid for P
c. L is a lid for P ■
Existential Universal Statements An existential universal statement is a statement that is existential because its first part asserts that a certain object exists and is universal because its second part says that the object satisfies a certain property for all things of a certain kind. For example:
There is a positive integer that is less than or equal to every positive integer:
This statement is true because the number one is a positive integer, and it satisfies the property of being less than or equal to every positive integer. We can rewrite the statement in several ways, some less formal and some more formal:
Some positive integer is less than or equal to every positive integer. Or : There is a positive integer m that is less than or equal to every positive integer. Or : There is a positive integer m such that every positive integer is greater than or
equal to m. Or : There is a positive integer m with the property that for all positive integers
n,m ≤ n.
∗A conditional could be used to help express this statement, but we postpone the additional com- plexity to a later chapter.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
1.1 Variables 5
Example 1.1.4 Rewriting an Existential Universal Statement
Fill in the blanks to rewrite the following statement in three different ways:
There is a person in my class who is at least as old as every person in my class.
a. Some is at least as old as .
b. There is a person p in my class such that p is .
c. There is a person p in my class with the property that for every person q in my class, p is .
Solution a. person in my class; every person in my class
b. at least as old as every person in my class
c. at least as old as q ■
Some of the most important mathematical concepts, such as the definition of limit of a sequence, can only be defined using phrases that are universal, existential, and condi- tional, and they require the use of all three phrases “for all,” “there is,” and “if-then.” For example, if a1, a2, a3, . . . is a sequence of real numbers, saying that
the limit of an as n approaches infinity is L
means that
for all positive real numbers ε, there is an integer N such that for all integers n, if n > N then −ε < an − L < ε. Test Yourself Answers to Test Yourself questions are located at the end of each section. 1. A universal statement asserts that a certain property is for . 2. A conditional statement asserts that if one thing then some other thing . 3. Given a property that may or may not be true, an existential statement asserts that for which the property is true. Exercise Set 1.1 Appendix B contains either full or partial solutions to all exercises with blue numbers. When the solution is not complete, the exercise number has an H next to it. A ✶ next to an exercise number signals that the exercise is more challenging than usual. Be careful not to get into the habit of turning to the solutions too quickly. Make every effort to work exercises on your own before checking your answers. See the Preface for additional sources of assistance and further study. In each of 1–6, fill in the blanks using a variable or variables to rewrite the given statement. 1. Is there a real number whose square is −1? a. Is there a real number x such that ? b. Does there exist such that x2 = −1? 2. Is there an integer that has a remainder of 2 when it is divided by 5 and a remainder of 3 when it is divided by 6? a. Is there an integer n such that n has ? b. Does there exist such that if n is divided by 5 the remainder is 2 and if ? Note: There are integers with this property. Can you think of one? Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 6 Chapter 1 Speaking Mathematically 3. Given any two real numbers, there is a real number in between. a. Given any two real numbers a and b, there is a real num- ber c such that c is . b. For any two , such that a < c < b. 4. Given any real number, there is a real number that is greater. a. Given any real number r , there is s such that s is . b. For any , such that s > r .
5. The reciprocal of any positive real number is positive. a. Given any positive real number r , the reciprocal of . b. For any real number r , if r is , then . c. If a real number r , then .
6. The cube root of any negative real number is negative. a. Given any negative real number s, the cube root of . b. For any real number s, if s is , then . c. If a real number s , then .
7. Rewrite the following statements less formally, without using variables. Determine, as best as you can, whether the statements are true or false.
a. There are real numbers u and v with the property that u + v < u − v. b. There is a real number x such that x2 < x . c. For all positive integers n, n2 ≥ n. d. For all real numbers a and b, |a + b| ≤ |a| + |b|. In each of 8–13, fill in the blanks to rewrite the given statement. 8. For all objects J , if J is a square then J has four sides. a. All squares . b. Every square . c. If an object is a square, then it . d. If J , then J . e. For all squares J , . 9. For all equations E , if E is quadratic then E has at most two real solutions. a. All quadratic equations . b. Every quadratic equation . c. If an equation is quadratic, then it . d. If E , then E . e. For all quadratic equations E , . 10. Every nonzero real number has a reciprocal. a. All nonzero real numbers . b. For all nonzero real numbers r , there is for r . c. For all nonzero real numbers r , there is a real number s such that . 11. Every positive number has a positive square root. a. All positive numbers . b. For any positive number e, there is for e. c. For all positive numbers e, there is a positive number r such that . 12. There is a real number whose product with every number leaves the number unchanged. a. Some has the property that its . b. There is a real number r such that the product of r . c. There is a real number r with the property that for every real number s, . 13. There is a real number whose product with every real number equals zero. a. Some has the property that its . b. There is a real number a such that the product of a . c. There is a real number a with the property that for every real number b, . Answers for Test Yourself 1. true; all elements of a set 2. is true; also has to be true 3. there is at least one thing 1.2 The Language of Sets . . . when we attempt to express in mathematical symbols a condition proposed in words. First, we must understand thoroughly the condition. Second, we must be familiar with the forms of mathematical expression. —George Polyá (1887–1985) Use of the word set as a formal mathematical term was introduced in 1879 by Georg Cantor (1845–1918). For most mathematical purposes we can think of a set intuitively, as Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 1.2 The Language of Sets 7 Cantor did, simply as a collection of elements. For instance, if C is the set of all countries that are currently in the United Nations, then the United States is an element of C , and if I is the set of all integers from 1 to 100, then the number 57 is an element of I . • Notation If S is a set, the notation x ∈ S means that x is an element of S. The notation x /∈ S means that x is not an element of S. A set may be specified using the set-roster notation by writing all of its elements between braces. For example, {1, 2, 3} denotes the set whose elements are 1, 2, and 3. A variation of the notation is sometimes used to describe a very large set, as when we write {1, 2, 3, . . . , 100} to refer to the set of all integers from 1 to 100. A similar notation can also describe an infinite set, as when we write {1, 2, 3, . . .} to refer to the set of all positive integers. (The symbol . . . is called an ellipsis and is read “and so forth.”) The axiom of extension says that a set is completely determined by what its elements are—not the order in which they might be listed or the fact that some elements might be listed more than once. Example 1.2.1 Using the Set-Roster Notation a. Let A = {1, 2, 3}, B = {3, 1, 2}, and C = {1, 1, 2, 3, 3, 3}. What are the elements of A, B, and C? How are A, B, and C related? b. Is {0} = 0? c. How many elements are in the set {1, {1}}? d. For each nonnegative integer n, let Un = {n,−n}. Find U1, U2, and U0. Solution a. A, B, and C have exactly the same three elements: 1, 2, and 3. Therefore, A, B, and C are simply different ways to represent the same set. b. {0} �= 0 because {0} is a set with one element, namely 0, whereas 0 is just the symbol that represents the number zero. c. The set {1, {1}} has two elements: 1 and the set whose only element is 1. d. U1 = {1,−1}, U2 = {2,−2}, U0 = {0,−0} = {0, 0} = {0}. Certain sets of numbers are so frequently referred to that they are given special symbolic names. These are summarized in the table on the next page. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 8 Chapter 1 Speaking Mathematically Symbol Set R set of all real numbers Z set of all integers Q set of all rational numbers, or quotients of integers Note The Z is the first letter of the German word for integers, Zahlen. It stands for the set of all integers and should not be used as a shorthand for the word integer. Addition of a superscript + or − or the letters nonneg indicates that only the positive or negative or nonnegative elements of the set, respectively, are to be included. Thus R+ denotes the set of positive real numbers, and Znonneg refers to the set of nonnegative integers: 0, 1, 2, 3, 4, and so forth. Some authors refer to the set of nonnegative integers as the set of natural numbers and denote it as N. Other authors call only the positive integers natural numbers. To prevent confusion, we simply avoid using the phrase natural numbers in this book. The set of real numbers is usually pictured as the set of all points on a line, as shown below. The number 0 corresponds to a middle point, called the origin. A unit of dis- tance is marked off, and each point to the right of the origin corresponds to a positive real number found by computing its distance from the origin. Each point to the left of the origin corresponds to a negative real number, which is denoted by computing its dis- tance from the origin and putting a minus sign in front of the resulting number. The set of real numbers is therefore divided into three parts: the set of positive real numbers, the set of negative real numbers, and the number 0. Note that 0 is neither positive nor neg- ative Labels are given for a few real numbers corresponding to points on the line shown below. –3 –2 –1 0 1 2 3 13 4 1 3 2.6–0.8–√35 2 – √2 The real number line is called continuous because it is imagined to have no holes. The set of integers corresponds to a collection of points located at fixed intervals along the real number line. Thus every integer is a real number, and because the integers are all separated from each other, the set of integers is called discrete. The name discrete mathematics comes from the distinction between continuous and discrete mathematical objects. Another way to specify a set uses what is called the set-builder notation. Note We read the left-hand brace as “the set of all” and the vertical line as “such that.” In all other mathematical contexts, however, we do not use a vertical line to denote the words “such that”; we abbreviate “such that” as “s. t.” or “s. th.” or “ · � · .” • Set-Builder Notation Let S denote a set and let P(x) be a property that elements of S may or may not satisfy. We may define a new set to be the set of all elements x in S such that P(x) is true. We denote this set as follows: {x ∈ S | P(x)}↗ ↖ the set of all such that Occasionally we will write {x | P(x)} without being specific about where the ele- ment x comes from. It turns out that unrestricted use of this notation can lead to genuine contradictions in set theory. We will discuss one of these in Section 6.4 and will be careful to use this notation purely as a convenience in cases where the set S could be specified if necessary. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 1.2 The Language of Sets 9 Example 1.2.2 Using the Set-Builder Notation Given that R denotes the set of all real numbers, Z the set of all integers, and Z+ the set of all positive integers, describe each of the following sets. a. {x ∈ R | −2 < x < 5} b. {x ∈ Z | −2 < x < 5} c. {x ∈ Z+ |−2 < x < 5} Solution a. {x ∈ R | −2 < x < 5} is the open interval of real numbers (strictly) between −2 and 5. It is pictured as follows: –2–3 –1 0 1 2 3 4 5 6 7 8 b. {x ∈ Z | −2 < x < 5} is the set of all integers (strictly) between −2 and 5. It is equal to the set {−1, 0, 1, 2, 3, 4}. c. Since all the integers in Z+ are positive, {x ∈ Z+|−2 < x < 5} = {1, 2, 3, 4}. ■ Subsets A basic relation between sets is that of subset. • Definition If A and B are sets, then A is called a subset of B, written A ⊆ B, if, and only if, every element of A is also an element of B. Symbolically: A ⊆ B means that For all elements x , if x ∈ A then x ∈ B. The phrases A is contained in B and B contains A are alternative ways of saying that A is a subset of B. It follows from the definition of subset that for a set A not to be a subset of a set B means that there is at least one element of A that is not an element of B. Symbolically: A � B means that There is at least one element x such that x ∈ A and x /∈ B. • Definition Let A and B be sets. A is a proper subset of B if, and only if, every element of A is in B but there is at least one element of B that is not in A. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 10 Chapter 1 Speaking Mathematically Example 1.2.3 Subsets Let A = Z+, B = {n ∈ Z | 0 ≤ n ≤ 100}, and C = {100, 200, 300, 400, 500}. Evaluate the truth and falsity of each of the following statements. a. B ⊆ A b. C is a proper subset of A c. C and B have at least one element in common d. C ⊆ B e. C ⊆ C Solution a. False. Zero is not a positive integer. Thus zero is in B but zero is not in A, and so B � A. b. True. Each element in C is a positive integer and, hence, is in A, but there are elements in A that are not in C . For instance, 1 is in A and not in C . c. True. For example, 100 is in both C and B. d. False. For example, 200 is in C but not in B. e. True. Every element in C is in C . In general, the definition of subset implies that all sets are subsets of themselves. Example 1.2.4 Distinction between ∈ and ⊆ Which of the following are true statements? a. 2 ∈ {1, 2, 3} b. {2} ∈ {1, 2, 3} c. 2 ⊆ {1, 2, 3} d. {2} ⊆ {1, 2, 3} e. {2} ⊆ {{1}, {2}} f. {2} ∈ {{1}, {2}} Solution Only (a), (d), and (f) are true. For (b) to be true, the set {1, 2, 3} would have to contain the element {2}. But the only elements of {1, 2, 3} are 1, 2, and 3, and 2 is not equal to {2}. Hence (b) is false. For (c) to be true, the number 2 would have to be a set and every element in the set 2 would have to be an element of {1, 2, 3}. This is not the case, so (c) is false. For (e) to be true, every element in the set containing only the number 2 would have to be an element of the set whose elements are {1} and {2}. But 2 is not equal to either {1} or {2}, and so (e) is false. ■ Cartesian Products P ro bl em y m on th ly , Ju ly 1 9 5 9 Kazimierz Kuratowski (1896–1980) With the introduction of Georg Cantor’s set theory in the late nineteenth century, it began to seem possible to put mathematics on a firm logical foundation by developing all of its various branches from set theory and logic alone. A major stumbling block was how to use sets to define an ordered pair because the definition of a set is unaffected by the order in which its elements are listed. For example, {a, b} and {b, a} represent the same set, whereas in an ordered pair we want to be able to indicate which element comes first. In 1914 crucial breakthroughs were made by Norbert Wiener (1894–1964), a young American who had recently received his Ph.D. from Harvard and the German mathe- matician Felix Hausdorff (1868–1942). Both gave definitions showing that an ordered pair can be defined as a certain type of set, but both definitions were somewhat awkward. Finally, in 1921, the Polish mathematician Kazimierz Kuratowski (1896–1980) published Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 1.2 The Language of Sets 11 the following definition, which has since become standard. It says that an ordered pair is a set of the form {{a}, {a, b}}. This set has elements, {a} and {a, b}. If a �= b, then the two sets are distinct and a is in both sets whereas b is not. This allows us to distinguish between a and b and say that a is the first element of the ordered pair and b is the second element of the pair. If a = b, then we can simply say that a is both the first and the second element of the pair. In this case the set that defines the ordered pair becomes {{a}, {a, a}}, which equals {{a}}. However, it was only long after ordered pairs had been used extensively in mathemat- ics that mathematicians realized that it was possible to define them entirely in terms of sets, and, in any case, the set notation would be cumbersome to use on a regular basis. The usual notation for ordered pairs refers to {{a}, {a, b}} more simply as (a, b). • Notation Given elements a and b, the symbol (a, b) denotes the ordered pair consisting of a and b together with the specification that a is the first element of the pair and b is the second element. Two ordered pairs (a, b) and (c, d) are equal if, and only if, a = c and b = d. Symbolically: (a, b) = (c, d) means that a = c and b = d. Example 1.2.5 Ordered Pairs a. Is (1, 2) = (2, 1)? b. Is ( 3, 510 ) = (√ 9, 12 ) ? c. What is the first element of (1, 1)? Solution a. No. By definition of equality of ordered pairs, (1, 2) = (2.1) if, and only if, 1 = 2 and 2 = 1. But 1 �= 2, and so the ordered pairs are not equal. b. Yes. By definition of equality of ordered pairs,( 3, 510 ) = (√ 9, 12 ) if, and only if, 3 = √9 and 510 = 12 . Because these equations are both true, the ordered pairs are equal. c. In the ordered pair (1, 1), the first and the second elements are both 1. • Definition Given sets A and B, the Cartesian product of A and B, denoted A× B and read “A cross B,” is the set of all ordered pairs (a, b), where a is in A and b is in B. Symbolically: A× B = {(a, b) | a ∈ A and b ∈ B} . Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 12 Chapter 1 Speaking Mathematically Example 1.2.6 Cartesian Products Let A = {1, 2, 3} and B = {u, v}. a. Find A × B b. Find B × A c. Find B × B d. How many elements are in A × B, B × A, and B × B? e. Let R denote the set of all real numbers. Describe R× R. Solution a. A × B = {(1, u), (2, u), (3, u), (1, v), (2, v), (3, v)} b. B × A = {(u, 1), (u, 2), (u, 3), (v, 1), (v, 2), (v, 3)} c. B × B = {(u, u), (u, v), (v, u), (v, v)} d. A × B has six elements. Note that this is the number of elements in A times the num- ber of elements in B. B × A has six elements, the number of elements in B times the number of elements in A. B × B has four elements, the number of elements in B times the number of elements in B. e. R× R is the set of all ordered pairs (x, y) where both x and y are real numbers. If horizontal and vertical axes are drawn on a plane and a unit length is marked off, then each ordered pair in R× R corresponds to a unique point in the plane, with the first and second elements of the pair indicating, respectively, the horizontal and vertical positions of the point. The term Cartesian plane is often used to refer to a plane with this coordinate system, as illustrated in Figure 1.2.1. Note This is why it makes sense to call a Cartesian product a product! x y 1 1 2 3 –2–3–4 –1 –1 –2 –3 2 (1, –2)(–2, –2) (–3, 2) (2, 1) 3 4 Figure 1.2.1: A Cartesian Plane Test Yourself 1. When the elements of a set are given using the set-roster notation, the order in which they are listed . 2. The symbol R denotes . 3. The symbol Z denotes . 4. The symbol Q denotes . 5. The notation {x | P(x)} is read . 6. For a set A to be a subset of a set B means that, . 7. Given sets A and B, the Cartesian product A × B is . Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 1.3 The Language of Relations and Functions 13 Exercise Set 1.2 1. Which of the following sets are equal? A = {a, b, c, d} B = {d, e, a, c} C = {d, b, a, c} D = {a, a, d, e, c, e} 2. Write in words how to read each of the following out loud. a. {x ∈ R+ | 0 < x < 1} b. {x ∈ R | x ≤ 0 or x ≥ 1} c. {n ∈ Z | n is a factor of 6} d. {n ∈ Z+ | n is a factor of 6} 3. a. Is 4 = {4}? b. How many elements are in the set {3, 4, 3, 5}? c. How many elements are in the set {1, {1}, {1, {1}}}? 4. a. Is 2 ∈ {2}? b. How many elements are in the set {2, 2, 2, 2}? c. How many elements are in the set {0, {0}}? d. Is {0} ∈ {{0}, {1}}? e. Is 0 ∈ {{0}, {1}}? 5.H Which of the following sets are equal? A = {0, 1, 2} B = {x ∈ R | −1 ≤ x < 3} C = {x ∈ R | −1 < x < 3} D = {x ∈ Z | −1 < x < 3} E = {x ∈ Z+ |−1 < x < 3} 6.H For each integer n, let Tn = {n, n2}. How many elements are in each of T2, T−3, T1 and T0? Justify your answers. 7. Use the set-roster notation to indicate the elements in each of the following sets. a. S = {n ∈ Z | n = (−1)k , for some integer k}. b. T = {m ∈ Z |m = 1+ (−1)i, for some integer i}. c. U = {r ∈ Z | 2 ≤ r ≤ −2} d. V = {s ∈ Z | s > 2 or s < 3} e. W = {t ∈ Z | 1 < t < −3} f. X = {u ∈ Z | u ≤ 4 or u ≥ 1} 8. Let A = {c, d, f, g}, B = { f, j}, and C = {d, g}. Answer each of the following questions. Give reasons for your answers. a. Is B ⊆ A? b. Is C ⊆ A? b. Is C ⊆ C? d. Is C a proper subset of A? 9. a. Is 3 ∈ {1, 2, 3}? b. Is 1 ⊆ {1}? c. Is {2} ∈ {1, 2}? d. Is {3} ∈ {1, {2}, {3}}? e. Is 1 ∈ {1}? f. Is {2} ⊆ {1, {2}, {3}}? g. Is {1} ⊆ {1, 2}? h. Is 1 ∈ {{1}, 2}? i. Is {1} ⊆ {1, {2}}? j. Is {1} ⊆ {1}? 10. a. Is ((−2)2,−22) = (−22, (−2)2)? b. Is (5,−5) = (−5, 5)? c. Is ( 8− 9, 3√−1) = (−1,−1)? d. Is (−2 −4 , (−2)3 ) = ( 3 6 ,−8 ) ? 11. Let A = {w, x, y, z} and B = {a, b}. Use the set-roster notation to write each of the following sets, and indicate the number of elements that are in each set: a. A × B b. B × A c. A × A d. B × B 12. Let S = {2, 4, 6} and T = {1, 3, 5}. Use the set-roster notation to write each of the following sets, and indicate the number of elements that are in each set: a. S × T b. T × S c. S × S d. T × T Answers for Test Yourself 1. does not matter 2. the set of all real numbers 3. the set of all integers 4. the set of all rational numbers 5. the set of all x such that P(x) 6. every element in A is an element in B 7. the set of all ordered pairs (a, b) where a is in A and b is in B 1.3 The Language of Relations and Functions Mathematics is a language. — Josiah Willard Gibbs (1839–1903) There are many kinds of relationships in the world. For instance, we say that two people are related by blood if they share a common ancestor and that they are related by marriage if one shares a common ancestor with the spouse of the other. We also speak of the rela- tionship between student and teacher, between people who work for the same employer, and between people who share a common ethnic background. Similarly, the objects of mathematics may be related in various ways. A set A may be said to be related to a set B if A is a subset of B, or if A is not a subset of B, or if A and B have at least one element in common. A number x may be said to be related to a number y if x < y, or if x is a factor of y, or if x2 + y2 = 1. Two identifiers in a computer Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 14 Chapter 1 Speaking Mathematically program may be said to be related if they have the same first eight characters, or if the same memory location is used to store their values when the program is executed. And the list could go on! Let A = {0, 1, 2} and B = {1, 2, 3} and let us say that an element x in A is related to an element y in B if, and only if, x is less than y. Let us use the notation x R y as a shorthand for the sentence “x is related to y.” Then 0 R 1 since 0 < 1, 0 R 2 since 0 < 2, 0 R 3 since 0 < 3, 1 R 2 since 1 < 2, 1 R 3 since 1 < 3, and 2 R 3 since 2 < 3. On the other hand, if the notation x �R y represents the sentence “x is not related to y,” then 1 �R 1 since 1 �< 1, 2 �R 1 since 2 �< 1, and 2 �R 2 since 2 �< 2. Recall that the Cartesian product of A and B, A × B, consists of all ordered pairs whose first element is in A and whose second element is in B: A × B = {(x, y) | x ∈ A and y ∈ B}. In this case, A × B = {(0, 1) , (0, 2), (0, 3), (1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3)}. The elements of some ordered pairs in A × B are related, whereas the elements of other ordered pairs are not. Consider the set of all ordered pairs in A × B whose elements are related { (0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3) } . Observe that knowing which ordered pairs lie in this set is equivalent to knowing which elements are related to which. The relation itself can therefore be thought of as the totality of ordered pairs whose elements are related by the given condition. The formal mathe- matical definition of relation, based on this idea, was introduced by the American math- ematician and logician C. S. Peirce in the nineteenth century. • Definition Let A and B be sets. A relation R from A to B is a subset of A × B. Given an ordered pair (x, y) in A × B, x is related to y by R, written x R y, if, and only if, (x, y) is in R. The set A is called the domain of R and the set B is called its co-domain. The notation for a relation R may be written symbolically as follows: x R y means that (x, y) ∈ R. The notation x �R y means that x is not related to y by R: x �R y means that (x, y) /∈ R. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 1.3 The Language of Relations and Functions 15 Example 1.3.1 A Relation as a Subset Let A = {1, 2} and B = {1, 2, 3} and define a relation R from A to B as follows: Given any (x, y) ∈ A × B, (x, y) ∈ R means that x − y 2 is an integer. a. State explicitly which ordered pairs are in A × B and which are in R. b. Is 1 R 3? Is 2 R 3? Is 2 R 2? c. What are the domain and co-domain of R? Solution a. A × B = {(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3)}. To determine explicitly the com- position of R, examine each ordered pair in A × B to see whether its elements satisfy the defining condition for R. (1, 1) ∈ R because 1−12 = 02 = 0, which is an integer. (1, 2) /∈ R because 1−22 = −12 , which is not an integer. (1, 3) ∈ R because 1−32 = −22 = −1, which is an integer. (2, 1) /∈ R because 2−12 = 12 , which is not an integer. (2, 2) ∈ R because 2−22 = 02 = 0, which is an integer. (2, 3) /∈ R because 2−32 = −12 , which is an integer. Thus R = {(1, 1), (1, 3), (2, 2)} b. Yes, 1 R 3 because (1, 3) ∈ R. No, 2 �R 3 because (2, 3) /∈ R. Yes, 2 R 2 because (2, 2) ∈ R. c. The domain of R is {1, 2} and the co-domain is {1, 2, 3}. ■ Example 1.3.2 The Circle Relation Define a relation C from R to R as follows: For any (x, y) ∈ R× R, (x, y) ∈ C means that x2 + y2 = 1. a. Is (1, 0) ∈ C? Is (0, 0) ∈ C? Is ( −12 , √ 3 2 ) ∈ C? Is −2 C 0? Is 0 C (−1)? Is 1 C 1? b. What are the domain and co-domain of C? c. Draw a graph for C by plotting the points of C in the Cartesian plane. Solution a. Yes, (1, 0) ∈ C because 12 + 02 = 1. No, (0, 0) /∈ C because 02 + 02 = 0 �= 1. Yes, ( −12 , √ 3 2 ) ∈ C because ( −12 )2 + (√32 )2 = 14 + 34 = 1. No, −2 C/ 0 because (−2)2 + 02 = 4 �= 1. Yes, 0C (−1) because 02 + (−1)2 = 1. No, 1 C/ 1 because 12 + 12 = 2 �= 1. b. The domain and co-domain of C are both R, the set of all real numbers. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 16 Chapter 1 Speaking Mathematically c. x y x2 + y2 = 1 1–1 ■ Arrow Diagram of a Relation Suppose R is a relation from a set A to a set B. The arrow diagram for R is obtained as follows: 1. Represent the elements of A as points in one region and the elements of B as points in another region. 2. For each x in A and y in B, draw an arrow from x to y if, and only if, x is related to y by R. Symbolically: Draw an arrow from x to y if, and only if, x R y if, and only if, (x, y) ∈ R. Example 1.3.3 Arrow Diagrams of Relations Let A = {1, 2, 3} and B = {1, 3, 5} and define relations S and T from A to B as follows: For all (x, y) ∈ A × B, (x, y) ∈ S means that x < y S is a “less than” relation. T = {(2, 1), (2, 5)}. Draw arrow diagrams for S and T . Solution 1 2 3 S 1 3 5 1 2 3 T 1 3 5 These example relations illustrate that it is possible to have several arrows coming out of the same element of A pointing in different directions. Also, it is quite possible to have an element of A that does not have an arrow coming out of it. ■ Functions In Section 1.2 we showed that ordered pairs can be defined in terms of sets and we defined Cartesian products in terms of ordered pairs. In this section we introduced relations as subsets of Cartesian products. Thus we can now define functions in a way that depends only on the concept of set. Although this definition is not obviously related to the way we usually work with functions in mathematics, it is satisfying from a theoretical point Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 1.3 The Language of Relations and Functions 17 of view and computer scientists like it because it is particularly well suited for operating with functions on a computer. • Definition A function F from a set A to a set B is a relation with domain A and co-domain B that satisfies the following two properties: 1. For every element x in A, there is an element y in B such that (x, y) ∈ F . 2. For all elements x in A and y and z in B, if (x, y) ∈ F and (x, z) ∈ F, then y = z. Properties (1) and (2) can be stated less formally as follows: A relation F from A to B is a function if, and only if: 1. Every element of A is the first element of an ordered pair of F . 2. No two distinct ordered pairs in F have the same first element. In most mathematical situations we think of a function as sending elements from one set, the domain, to elements of another set, the co-domain. Because of the definition of function, each element in the domain corresponds to one and only one element of the co-domain. More precisely, if F is a function from a set A to a set B, then given any element x in A, property (1) from the function definition guarantees that there is at least one element of B that is related to x by F and property (2) guarantees that there is at most one such element. This makes it possible to give the element that corresponds to x a special name. • Notation If A and B are sets and F is a function from A to B, then given any element x in A, the unique element in B that is related to x by F is denoted F(x), which is read “F of x.” Example 1.3.4 Functions and Relations on Finite Sets Let A = {2, 4, 6} and B = {1, 3, 5}. Which of the relations R, S, and T defined below are functions from A to B? a. R = {(2, 5), (4, 1), (4, 3), (6, 5)} b. For all (x, y) ∈ A × B, (x, y) ∈ S means that y = x + 1. c. T is defined by the arrow diagram B 1 3 5 A 2 4 6 Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 18 Chapter 1 Speaking Mathematically Solution a. R is not a function because it does not satisfy property (2). The ordered pairs (4, 1) and (4, 3) have the same first element but different second elements. You can see this graphically if you draw the arrow diagram for R. There are two arrows coming out of 4: One points to 1 and the other points to 3. BR 1 3 5 A 2 4 6 b. S is not a function because it does not satisfy property (1). It is not true that every element of A is the first element of an ordered pair in S. For example, 6 ∈ A but there is no y in B such that y = 6+ 1 = 7. You can also see this graphically by drawing the arrow diagram for S. BS 1 3 5 A 2 4 6 c. T is a function: Each element in {2, 4, 6} is related to some element in {1, 3, 5} and no element in {2, 4, 6} is related to more than one element in {1, 3, 5}. When these properties are stated in terms of the arrow diagram, they become (1) there is an arrow coming out of each element of the domain, and (2) no element of the domain has more than one arrow coming out of it. So you can write T (2) = 5, T (4) = 1, and T (6) = 1. ■ Note In part (c), T (4) = T (6). This illustrates the fact that although no element of the domain of a function can be related to more than one element of the co-domain, several elements in the domain can be related to the same element in the co-domain. Example 1.3.5 Functions and Relations on Sets of Real Numbers a. In Example 1.3.2 the circle relation C was defined as follows: For all (x, y) ∈ R× R, (x, y) ∈ C means that x2 + y2 = 1. Is C a function? If it is, find C(0) and C(1). b. Define a relation from R to R as follows: For all (x, y) ∈ R× R, (x, y) ∈ L means that y = x − 1. Is L a function? If it is, find L(0) and L(1). Solution a. The graph of C , shown on the next page, indicates that C does not satisfy either func- tion property. To see why C does not satisfy property (1), observe that there are many real numbers x such that (x, y) /∈ C for any y. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 1.3 The Language of Relations and Functions 19 x = 2 Graph of C x2 + y2 = 1 1 2 2 ,( ) 1 2 √3 2 , –( ) x = 1 2 √3 For instance, when x = 2, there is no real number y so that x2 + y2 = 22 + y2 = 4+ y2 = 1 because if there were, then it would have to be true that y2 = −3. which is not the case for any real number y. To see why C does not satisfy property (2), note that for some values of x there are two distinct values of y so that (x, y) ∈ C . One way to see this graphically is to observe that there are vertical lines, such as x = 12 , that intersect the graph of C at two separate points: ( 1 2 , √ 3 2 ) and ( 1 2 , − √ 3 2 ) . b. L is a function. For each real number x, y = x − 1 is a real number, and so there is a real number y with (x, y) ∈ L . Also if (x, y) ∈ L and (x, z) ∈ L , then y = x − 1 and z = x − 1, and so y = z. In particular, L(0) = 0− 1 = −1 and L(1) = 1− 1 = 0. You can also check these results by inspecting the graph of L , shown below. Note that for every real number x , the vertical line through (x , 0) passes through the graph of L exactly once. This indicates both that every real number x is the first element of an ordered pair in L and also that no two distinct ordered pairs in L have the same first element. (x, 0) y = x – 1 Graph of L ■ Function Machines Another useful way to think of a function is as a machine. Suppose f is a function from X to Y and an input x of X is given. Imagine f to be a machine that processes x in a certain way to produce the output f (x). This is illustrated in Figure 1.3.1 on the next page. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 20 Chapter 1 Speaking Mathematically function machine Input x f (x) Output Figure 1.3.1 Example 1.3.6 Functions Defined by Formulas The squaring function f from R to R is defined by the formula f (x) = x2 for all real numbers x . This means that no matter what real number input is substituted for x , the output of f will be the square of that number. This idea can be represented by writing f (�) = �2. In other words, f sends each real number x to x2, or, symbolically, f : x → x2. Note that the variable x is a dummy variable; any other symbol could replace it, as long as the replacement is made everywhere the x appears. The successor function g from Z to Z is defined by the formula g(n) = n + 1. Thus, no matter what integer is substituted for n, the output of g will be that number plus one: g(�) = �+ 1. In other words, g sends each integer n to n + 1, or, symbolically, g: n→ n + 1. An example of a constant function is the function h from Q to Z defined by the formula h(r) = 2 for all rational numbers r . This function sends each rational number r to 2. In other words, no matter what the input, the output is always 2: h(�) = 2 or h: r → 2. The functions f, g, and h are represented by the function machines in Figure 1.3.2. squaring function x f (x) = x2 (a) successor function n g(n) = n + 1 (b) constant function r h(r) = 2 (c) Figure 1.3.2 ■ A function is an entity in its own right. It can be thought of as a certain relationship between sets or as an input/output machine that operates according to a certain rule. This is the reason why a function is generally denoted by a single symbol or string of symbols, such as f, G, of log, or sin. A relation is a subset of a Cartesian product and a function is a special kind of relation. Specifically, if f and g are functions from a set A to a set B, then f = {(x, y) ∈ A × B | y = f (x)} and g = {(x, y) ∈ A × B | y = g(x)}. It follows that f equals g, written f = g, if, and only if, f (x) = g(x) for all x in A. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 1.3 The Language of Relations and Functions 21 Example 1.3.7 Equality of Functions Define f : R→ R and g: R→ R by the following formulas: f (x) = |x | for all x ∈ R. g(x) = √x2 for all x ∈ R. Does f = g? Solution Yes. Because the absolute value of any real number equals the square root of its square, |x | = √x2 for all x ∈ R. Hence f = g. ■ Test Yourself 1. Given sets A and B, a relation from A to B is . 2. A function F from A to B is a relation from A to B that satisfies the following two properties: a. for every element x of A, there is . b. for all elements x in A and y and z in B, if then . 3. If F is a function from A to B and x is an element of A, then F(x) is . Exercise Set 1.3 1. Let A = {2, 3, 4} and B = {6, 8, 10} and define a relation R from A to B as follows: For all (x, y) ∈ A × B, (x, y) ∈ R means that y x is an integer. a. Is 4 R 6? Is 4 R 8? Is (3, 8) ∈ R? Is (2, 10) ∈ R? b. Write R as a set of ordered pairs. c. Write the domain and co-domain of R. d. Draw an arrow diagram for R. 2. Let C = D = {−3,−2,−1, 1, 2, 3} and define a relation S from C to D as follows: For all (x, y) ∈ C × D, (x, y) ∈ S means that 1 x − 1 y is an integer. a. Is 2 S 2? Is −1S − 1? Is (3, 3) ∈ S? Is (3,−3) ∈ S? b. Write S as a set of ordered pairs. c. Write the domain and co-domain of S. d. Draw an arrow diagram for S. 3. Let E = {1, 2, 3} and F = {−2,−1, 0} and define a rela- tion T from E to F as follows: For all (x, y) ∈ E × F , (x, y) ∈ T means that x − y 3 is an integer. a. Is 3 T 0? Is 1T (−1)? Is (2,−1) ∈ T ? Is (3,−2) ∈ T ? b. Write T as a set of ordered pairs. c. Write the domain and co-domain of T . d. Draw an arrow diagram for T . 4. Let G = {−2, 0, 2} and H = {4, 6, 8} and define a relation V from G to H as follows: For all (x, y) ∈ G × H , (x, y) ∈ V means that x − y 4 is an integer. a. Is 2 V 6? Is (−2)V (−6)? Is (0, 6) ∈ V ? Is (2, 4) ∈ V ? b. Write V as a set of ordered pairs. c. Write the domain and co-domain of V . d. Draw an arrow diagram for V . 5. Define a relation S from R to R as follows: For all (x, y) ∈ R× R, (x, y) ∈ S means that x ≥ y. a. Is (2, 1) ∈ S? Is (2, 2) ∈ S? Is 2 S 3? Is (−1) S (−2)? b. Draw the graph of S in the Cartesian plane. 6. Define a relation R from R to R as follows: For all (x, y) ∈ R× R, (x, y) ∈ R means that y = x2. a. Is (2, 4) ∈ R? Is (4, 2) ∈ R? Is (−3) R 9? Is 9 R (−3)? b. Draw the graph of R in the Cartesian plane. 7. Let A = {4, 5, 6} and B = {5, 6, 7} and define relations R, S, and T from A to B as follows: For all (x, y) ∈ A × B, (x, y) ∈ R means that x ≥ y. (x, y) ∈ S means that x − y 2 is an integer. T = {(4, 7), (6, 5), (6, 7)}. a. Draw arrow diagrams for R, S, and T . b. Indicate whether any of the relations R, S, and T are functions. 8. Let A = {2, 4} and B = {1, 3, 5} and define relations U, V, and W from A to B as follows: For all (x, y) ∈ A × B, (x, y) ∈ U means that y − x > 2. (x, y) ∈ V means that y − 1 = x
2 .
W = {(2, 5), (4, 1), (2, 3)}.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
22 Chapter 1 Speaking Mathematically
a. Draw arrow diagrams for U, V, and W . b. Indicate whether any of the relations U, V, and W are
functions.
9. a. Find all relations from {0,1} to {1}. b. Find all functions from {0,1} to {1}. c. What fraction of the relations from {0,1} to {1} are
functions?
10. Find four relations from {a, b} to {x, y} that are not func- tions from {a, b} to {x, y}.
11. Define a relation P from R+ to R as follows: For all real numbers x and y with x > 0,
(x, y) ∈ P means that x = y2. Is P a function? Explain.
12. Define a relation T from R to R as follows: For all real numbers x and y,
(x, y) ∈ T means that y2 − x2 = 1. Is T a function? Explain.
13. Let A = {−1, 0, 1} and B = {t, u, v, w}. Define a function F : A→ B by the following arrow diagram:
B
t
u
v
w
A
–1
0
1
a. Write the domain and co-domain of F . b. Find F(−1), F(0), and F(1).
14. Let C = {1, 2, 3, 4} and D = {a, b, c, d}. Define a function G: C → D by the following arrow diagram:
a
b
c
d
1
2
3
4
a. Write the domain and co-domain of G. b. Find G(1), G(2), G(3), and G(4).
15. Let X = {2, 4, 5} and Y = {1, 2, 4, 6}. Which of the fol- lowing arrow diagrams determine functions from X to Y ?
a. Y
6
X
2
2
1
4 4
5
b. Y
6
X
2
2
1
4 4
5
c. Y
1
2
4
6
X
2
4
5
d.
2
1
4
6
2
4
5
YX
e.
2
1
4
6
2
4
5
YX
16. Let f be the squaring function defined in Example 1.3.6.
Find f (−1), f (0), and f ( 1 2
) .
17. Let g be the successor function defined in Example 1.3.6. Find g(−1000), g(0), and g(999).
18. Let h be the constant function defined in Example 1.3.6.
Find h ( − 125
) , h
( 0 1
) , and h
( 9 17
) .
19. Define functions f and g from R to R by the following formulas: For all x ∈ R,
f (x) = 2x and g(x) = 2x 3 + 2x
x2 + 1 . Does f = g? Explain.
20. Define functions H and K from R to R by the following formulas: For all x ∈ R, H(x) = (x − 2)2 and K (x) = (x − 1)(x − 3)+ 1.
Does H = K ? Explain.
Answers for Test Yourself 1. a subset of the Cartesian product A × B 2. a. an element y of B such that (x, y) ∈ F (i.e., such that x is related to y by F) b. (x, y) ∈ F and (x, z) ∈ F; y = z 3. the unique element of B that is related to x by F
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
23
CHAPTER 2
THE LOGIC OF COMPOUND STATEMENTS
The first great treatises on logic were written by the Greek philosopher Aristotle. They
B et
tm an
n/ C
O R
B IS
Aristotle (384 B.C.–322 B.C.)
were a collection of rules for deductive reasoning that were intended to serve as a basis for the study of every branch of knowledge. In the seventeenth century, the German philosopher and mathematician Gottfried Leibniz conceived the idea of using symbols to mechanize the process of deductive reasoning in much the same way that algebraic notation had mechanized the process of reasoning about numbers and their relationships. Leibniz’s idea was realized in the nineteenth century by the English mathematicians George Boole and Augustus De Morgan, who founded the modern subject of symbolic logic. With research continuing to the present day, symbolic logic has provided, among other things, the theoretical basis for many areas of computer science such as digital logic circuit design (see Sections 2.4 and 2.5), relational database theory (see Section 8.1), automata theory and computability (see Section 7.4 and Chapter 12), and artificial intel- ligence (see Sections 3.3, 10.1, and 10.5).
2.1 Logical Form and Logical Equivalence Logic is a science of the necessary laws of thought, without which no employment of the understanding and the reason takes place. —Immanuel Kant, 1785
The central concept of deductive logic is the concept of argument form. An argument is a sequence of statements aimed at demonstrating the truth of an assertion. The assertion at the end of the sequence is called the conclusion, and the preceding statements are called premises. To have confidence in the conclusion that you draw from an argument, you must be sure that the premises are acceptable on their own merits or follow from other statements that are known to be true.
In logic, the form of an argument is distinguished from its content. Logical analysis won’t help you determine the intrinsic merit of an argument’s content, but it will help you analyze an argument’s form to determine whether the truth of the conclusion follows necessarily from the truth of the premises. For this reason logic is sometimes defined as the science of necessary inference or the science of reasoning.
Consider the following two arguments, for example. Although their content is very different, their logical form is the same. Both arguments are valid in the sense that if their premises are true, then their conclusions must also be true. (In Section 2.3 you will learn how to test whether an argument is valid.)
Argument 1 If the program syntax is faulty or if program execution results in division by zero, then the computer will generate an error message. Therefore, if the computer does
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
24 Chapter 2 The Logic of Compound Statements
not generate an error message, then the program syntax is correct and program execution does not result in division by zero.
Argument 2 If x is a real number such that x < −2 or x > 2, then x2 > 4. Therefore, if x2 ≯ 4, then x ≮ −2 and x ≯ 2.
To illustrate the logical form of these arguments, we use letters of the alphabet (such as p, q, and r ) to represent the component sentences and the expression “not p” to refer to the sentence “It is not the case that p.” Then the common logical form of both the previous arguments is as follows:
If p or q, then r .
Therefore, if not r , then not p and not q.
Example 2.1.1 Identifying Logical Form
Fill in the blanks below so that argument (b) has the same form as argument (a). Then represent the common form of the arguments using letters to stand for component sentences.
a. If Jane is a math major or Jane is a computer science major, then Jane will take Math 150. Jane is a computer science major. Therefore, Jane will take Math 150.
b. If logic is easy or (1) , then (2) . I will study hard. Therefore, I will get an A in this course.
Solution
1. I (will) study hard.
2. I will get an A in this course.
Common form: If p or q, then r .
q.
Therefore, r . ■
Statements Most of the definitions of formal logic have been developed so that they agree with the natural or intuitive logic used by people who have been educated to think clearly and use language carefully. The differences that exist between formal and intuitive logic are necessary to avoid ambiguity and obtain consistency.
In any mathematical theory, new terms are defined by using those that have been previously defined. However, this process has to start somewhere. A few initial terms necessarily remain undefined. In logic, the words sentence, true, and false are the initial undefined terms.
• Definition A statement (or proposition) is a sentence that is true or false but not both.
For example, “Two plus two equals four” and “Two plus two equals five” are both statements, the first because it is true and the second because it is false. On the other
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.1 Logical Form and Logical Equivalence 25
hand, the truth or falsity of “He is a college student” depends on the reference for the pronoun he. For some values of he the sentence is true; for others it is false. If the sen- tence were preceded by other sentences that made the pronoun’s reference clear, then the sentence would be a statement. Considered on its own, however, the sentence is neither true nor false, and so it is not a statement. We will discuss ways of transforming sentences of this form into statements in Section 3.1.
Similarly, “x + y > 0” is not a statement because for some values of x and y the sentence is true, whereas for others it is false. For instance, if x = 1 and y = 2, the sentence is true; if x = −1 and y = 0, the sentence is false.
Compound Statements We now introduce three symbols that are used to build more complicated logical expressions out of simpler ones. The symbol∼denotes not,∧ denotes and, and∨ denotes or. Given a statement p, the sentence “∼p” is read “not p” or “It is not the case that p” and is called the negation of p. In some computer languages the symbol � is used in place of ∼. Given another statement q, the sentence “p ∧ q” is read “p and q” and is called the conjunction of p and q. The sentence “p ∨ q” is read “p or q” and is called the disjunction of p and q.
In expressions that include the symbol ∼as well as ∧ or ∨, the order of operations specifies that ∼ is performed first. For instance, ∼p ∧ q = (∼p) ∧ q. In logical expres- sions, as in ordinary algebraic expressions, the order of operations can be overridden through the use of parentheses. Thus∼(p ∧ q) represents the negation of the conjunction of p and q. In this, as in most treatments of logic, the symbols ∧ and ∨ are considered coequal in order of operation, and an expression such as p ∧ q ∨ r is considered ambigu- ous. This expressionmust be written as either (p ∧ q) ∨ r or p ∧ (q ∨ r) to havemeaning.
A variety of English words translate into logic as ∧,∨, or ∼. For instance, the word but translates the same as and when it links two independent clauses, as in “Jim is tall but he is not heavy.” Generally, the word but is used in place of and when the part of the sentence that follows is, in some way, unexpected. Another example involves the words neither-nor. When Shakespeare wrote, “Neither a borrower nor a lender be,” he meant, “Do not be a borrower and do not be a lender.” So if p and q are statements, then
p but q means p and q
neither p nor q means ∼p and ∼q.
Example 2.1.2 Translating from English to Symbols: But and Neither-Nor
Write each of the following sentences symbolically, letting h = “It is hot” and s = “It is sunny.”
a. It is not hot but it is sunny.
b. It is neither hot nor sunny.
Solution
a. The given sentence is equivalent to “It is not hot and it is sunny,” which can be written symbolically as ∼h ∧ s.
b. To say it is neither hot nor sunny means that it is not hot and it is not sunny. Therefore, the given sentence can be written symbolically as ∼h ∧ ∼s. ■
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
26 Chapter 2 The Logic of Compound Statements
The notation for inequalities involves and and or statements. For instance, if x, a, and b are particular real numbers, then
x ≤ a means x < a or x = a a ≤ x ≤ b means a ≤ x and x ≤ b. Note that the inequality 2 ≤ x ≤ 1 is not satisfied by any real numbers because 2 ≤ x ≤ 1 means 2 ≤ x and x ≤ 1, and this is false no matter what number x happens to be. By the way, the point of specify- ing x, a, and b to be particular real numbers is to ensure that sentences such as “x < a” and “x ≥ b” are either true or false and hence that they are statements. Example 2.1.3 And, Or, and Inequalities Suppose x is a particular real number. Let p, q, and r symbolize “0 < x ,” “x < 3,” and “x = 3,” respectively. Write the following inequalities symbolically: a. x ≤ 3 b. 0 < x < 3 c. 0 < x ≤ 3 Solution a. q ∨ r b. p ∧ q c. p ∧ (q ∨ r) ■ Truth Values In Examples 2.1.2 and 2.1.3 we built compound sentences out of component statements and the terms not, and, and or. If such sentences are to be statements, however, they must have well-defined truth values—they must be either true or false. We now define such compound sentences as statements by specifying their truth values in terms of the statements that compose them. The negation of a statement is a statement that exactly expresses what it would mean for the statement to be false. • Definition If p is a statement variable, the negation of p is “not p” or “It is not the case that p” and is denoted ∼p. It has opposite truth value from p: if p is true, ∼p is false; if p is false, ∼p is true. The truth values for negation are summarized in a truth table. Truth Table for ∼p p ∼p T F F T Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.1 Logical Form and Logical Equivalence 27 In ordinary language the sentence “It is hot and it is sunny” is understood to be true when both conditions—being hot and being sunny—are satisfied. If it is hot but not sunny, or sunny but not hot, or neither hot nor sunny, the sentence is understood to be false. The formal definition of truth values for an and statement agrees with this general understanding. • Definition If p and q are statement variables, the conjunction of p and q is “p and q,” denoted p ∧ q. It is true when, and only when, both p and q are true. If either p or q is false, or if both are false, p ∧ q is false. The truth values for conjunction can also be summarized in a truth table. The table is obtained by considering the four possible combinations of truth values for p and q. Each combination is displayed in one row of the table; the corresponding truth value for the whole statement is placed in the right-most column of that row. Note that the only row containing a T is the first one since the only way for an and statement to be true is for both component statements to be true. Truth Table for p ∧ q p q p ∧ q T T T T F F F T F F F F By the way, the order of truth values for p and q in the table above is TT, TF, FT, FF. It is not absolutely necessary to write the truth values in this order, although it is customary to do so. We will use this order for all truth tables involving two statement variables. In Example 2.1.5 we will show the standard order for truth tables that involve three statement variables. In the case of disjunction—statements of the form “p or q”—intuitive logic offers two alternative interpretations. In ordinary language or is sometimes used in an exclusive sense (p or q but not both) and sometimes in an inclusive sense (p or q or both). A waiter who says you may have “coffee, tea, or milk” uses the word or in an exclusive sense: Extra payment is generally required if you want more than one beverage. On the other hand, a waiter who offers “cream or sugar” uses the word or in an inclusive sense: You are entitled to both cream and sugar if you wish to have them. Mathematicians and logicians avoid possible ambiguity about the meaning of the word or by understanding it to mean the inclusive “and/or.” The symbol ∨ comes from the Latin word vel, which means or in its inclusive sense. To express the exclusive or, the phrase p or q but not both is used. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 28 Chapter 2 The Logic of Compound Statements • Definition If p and q are statement variables, the disjunction of p and q is “p or q,” denoted p ∨ q. It is true when either p is true, or q is true, or both p and q are true; it is false only when both p and q are false. Here is the truth table for disjunction: Truth Table for p ∨ q p q p ∨ q T T T T F T F T T F F F Note The statement “2 ≤ 2” means that 2 is less than 2 or 2 equals 2. It is true because 2 = 2. Evaluating the Truth of More General Compound Statements Now that truth values have been assigned to ∼p, p ∧ q, and p ∨ q, consider the question of assigning truth values to more complicated expressions such as ∼p ∨ q, (p ∨ q) ∧ ∼(p ∧ q), and (p ∧ q) ∨ r . Such expressions are called statement forms (or propositional forms). The close relationship between statement forms and Boolean expressions is discussed in Section 2.4. • Definition A statement form (or propositional form) is an expression made up of statement variables (such as p, q, and r ) and logical connectives (such as ∼,∧, and ∨) that becomes a statement when actual statements are substituted for the component state- ment variables. The truth table for a given statement form displays the truth values that correspond to all possible combinations of truth values for its component state- ment variables. To compute the truth values for a statement form, follow rules similar to those used to evaluate algebraic expressions. For each combination of truth values for the statement variables, first evaluate the expressions within the innermost parentheses, then evaluate the expressions within the next innermost set of parentheses, and so forth until you have the truth values for the complete expression. Example 2.1.4 Truth Table for Exclusive Or Construct the truth table for the statement form (p ∨ q) ∧ ∼(p ∧ q). Note that when or is used in its exclusive sense, the statement “p or q” means “p or q but not both” or “p or q and not both p and q,” which translates into symbols as (p ∨ q) ∧ ∼(p ∧ q). This is sometimes abbreviated p ⊕ q or p XOR q. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.1 Logical Form and Logical Equivalence 29 Solution Set up columns labeled p, q, p ∨ q, p ∧ q,∼(p ∧ q), and (p ∨ q) ∧ ∼(p ∧ q). Fill in the p and q columns with all the logically possible combinations of T’s and F’s. Then use the truth tables for ∨ and ∧ to fill in the p ∨ q and p ∧ q columns with the appropriate truth values. Next fill in the ∼(p ∧ q) column by taking the opposites of the truth values for p ∧ q. For example, the entry for ∼(p ∧ q) in the first row is F because in the first row the truth value of p ∧ q is T. Finally, fill in the (p ∨ q) ∧ ∼(p ∧ q) col- umn by considering the truth table for an and statement together with the computed truth values for p ∨ q and ∼(p ∧ q). For example, the entry in the first row is F because the entry for p ∨ q is T, the entry for∼(p ∧ q) is F, and an and statement is false unless both components are true. The entry in the second row is T because both components are true in this row. Truth Table for Exclusive Or: ( p ∨ q) ∧ ∼( p ∧ q) p q p ∨ q p ∧ q ∼( p ∧ q) ( p ∨ q)∧ ∼( p ∧ q) T T T T F F T F T F T T F T T F T T F F F F T F ■ Example 2.1.5 Truth Table for ( p ∧ q) ∨ ∼r Construct a truth table for the statement form (p ∧ q) ∨ ∼r . Solution Make columns headed p, q, r, p ∧ q, ∼r, and (p ∧ q) ∨ ∼r . Enter the eight logically possible combinations of truth values for p, q, and r in the three left-most columns. Then fill in the truth values for p ∧ q and for ∼r . Complete the table by con- sidering the truth values for (p ∧ q) and for ∼r and the definition of an or statement. Since an or statement is false only when both components are false, the only rows in which the entry is F are the third, fifth, and seventh rows because those are the only rows in which the expressions p ∧ q and ∼r are both false. The entry for all the other rows is T. p q r p ∧ q ∼r ( p ∧ q)∨ ∼r T T T T F T T T F T T T T F T F F F T F F F T T F T T F F F F T F F T T F F T F F F F F F F T T ■ The essential point about assigning truth values to compound statements is that it allows you—using logic alone—to judge the truth of a compound statement on the basis of your knowledge of the truth of its component parts. Logic does not help you determine the truth or falsity of the component statements. Rather, logic helps link these separate pieces of information together into a coherent whole. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 30 Chapter 2 The Logic of Compound Statements Logical Equivalence The statements 6 is greater than 2 and 2 is less than 6 are two different ways of saying the same thing. Why? Because of the definition of the phrases greater than and less than. By contrast, although the statements (1) Dogs bark and cats meow and (2) Cats meow and dogs bark are also two different ways of saying the same thing, the reason has nothing to do with the definition of the words. It has to do with the logical form of the statements. Any two statements whose logical forms are related in the same way as (1) and (2) would either both be true or both be false. You can see this by examining the following truth table, where the statement variables p and q are substituted for the component statements “Dogs bark” and “Cats meow,” respectively. The table shows that for each combination of truth values for p and q, p ∧ q is true when, and only when, q ∧ p is true. In such a case, the statement forms are called logically equivalent, and we say that (1) and (2) are logically equivalent statements. p q p ∧ q q ∧ p T T T T T F F F F T F F F F F F ↑ ↑ p ∧ q and q ∧ p always have the same truth values, so they are logically equivalent • Definition Two statement forms are called logically equivalent if, and only if, they have identical truth values for each possible substitution of statements for their statement variables. The logical equivalence of statement forms P and Q is denoted by writing P ≡ Q. Two statements are called logically equivalent if, and only if, they have logically equivalent forms when identical component statement variables are used to replace identical component statements. Testing Whether Two Statement Forms P and Q Are Logically Equivalent 1. Construct a truth table with one column for the truth values of P and another column for the truth values of Q. 2. Check each combination of truth values of the statement variables to see whether the truth value of P is the same as the truth value of Q. a. If in each row the truth value of P is the same as the truth value of Q, then P and Q are logically equivalent. b. If in some row P has a different truth value from Q, then P and Q are not logically equivalent. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.1 Logical Form and Logical Equivalence 31 Example 2.1.6 Double Negative Property: ∼(∼p) ≡ p Construct a truth table to show that the negation of the negation of a statement is logically equivalent to the statement, annotating the table with a sentence of explanation. Solution p ∼p ∼(∼p) T F T F T F ↑ ↑ p and∼(∼p) always have the same truth values, so they are logically equivalent ■ There are two ways to show that statement forms P and Q are not logically equiva- lent. As indicated previously, one is to use a truth table to find rows for which their truth values differ. The other way is to find concrete statements for each of the two forms, one of which is true and the other of which is false. The next example illustrates both of these ways. Example 2.1.7 Showing Nonequivalence Show that the statement forms ∼(p ∧ q) and ∼p ∧ ∼q are not logically equivalent. Solution a. This method uses a truth table annotated with a sentence of explanation. p q ∼p ∼q p ∧ q ∼( p ∧ q) ∼p ∧ ∼q T T F F T F F T F F T F T �= F F T T F F T �= F F F T T F T T ↑ ↑ ∼(p ∧ q) and∼p ∧ ∼q have different truth values in rows 2 and 3, so they are not logically equivalent b. This method uses an example to show that ∼(p ∧ q) and ∼p ∧ ∼q are not logically equivalent. Let p be the statement “0 < 1” and let q be the statement “1 < 0.” Then ∼(p ∧ q) is “It is not the case that both 0 < 1 and 1 < 0, ” which is true. On the other hand, ∼p ∧ ∼q is “0 ≮ 1 and 1 ≮ 0, ” which is false. This example shows that there are concrete statements you can substi- tute for p and q to make one of the statement forms true and the other false. Therefore, the statement forms are not logically equivalent. ■ Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 32 Chapter 2 The Logic of Compound Statements Example 2.1.8 Negations of And and Or: De Morgan’s Laws For the statement “John is tall and Jim is redheaded” to be true, both components must be true. So for the statement to be false, one or both components must be false. Thus the negation can be written as “John is not tall or Jim is not redheaded.” In general, the negation of the conjunction of two statements is logically equivalent to the disjunction of their negations. That is, statements of the forms ∼(p ∧ q) and ∼p ∨ ∼q are logically equivalent. Check this using truth tables. Solution p q ∼p ∼q p ∧ q ∼( p ∧ q) ∼p ∨ ∼q T T F F T F F T F F T F T T F T T F F T T F F T T F T T ↑ ↑ ∼(p ∧ q) and∼p ∨ ∼q always have the same truth values, so they are logically equivalent C ul ve r P ic tu re s Augustus De Morgan (1806–1871) Symbolically, ∼(p ∧ q) ≡ ∼p ∨ ∼q. In the exercises at the end of this section you are asked to show the analogous law that the negation of the disjunction of two statements is logically equivalent to the conjunction of their negations: ∼(p ∨ q) ≡ ∼p ∧ ∼q. ■ The two logical equivalences of Example 2.1.8 are known as De Morgan’s laws of logic in honor of Augustus De Morgan, who was the first to state them in formal mathematical terms. De Morgan’s Laws The negation of an and statement is logically equivalent to the or statement in which each component is negated. The negation of an or statement is logically equivalent to the and statement in which each component is negated. Example 2.1.9 Applying De Morgan’s Laws Write negations for each of the following statements: a. John is 6 feet tall and he weighs at least 200 pounds. b. The bus was late or Tom’s watch was slow. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.1 Logical Form and Logical Equivalence 33 Solution a. John is not 6 feet tall or he weighs less than 200 pounds. b. The bus was not late and Tom’s watch was not slow. Since the statement “neither p nor q” means the same as “∼p and ∼q,” an alternative answer for (b) is “Neither was the bus late nor was Tom’s watch slow.” ■ If x is a particular real number, saying that x is not less than 2 (x ≮ 2) means that x does not lie to the left of 2 on the number line. This is equivalent to saying that either x = 2 or x lies to the right of 2 on the number line (x = 2 or x > 2). Hence,
x ≮ 2 is equivalent to x ≥ 2. Pictorially,
–2 –1 0 1 2 3 4 5
If x � 2, then x lies in here.
Similarly,
x ≯ 2 is equivalent to x ≤ 2, x � 2 is equivalent to x > 2, and
x � 2 is equivalent to x < 2. Example 2.1.10 Inequalities and De Morgan’s Laws Use De Morgan’s laws to write the negation of −1 < x ≤ 4. Solution The given statement is equivalent to −1 < x and x ≤ 4. By De Morgan’s laws, the negation is −1 ≮ x or x � 4, which is equivalent to −1 ≥ x or x > 4.
! Caution! The negation of −1 < x ≤ 4 is not −1 ≮ x � 4. It is also not −1 ≥ x > 4.
Pictorially, if −1 ≥ x or x > 4, then x lies in the shaded region of the number line, as shown below.
–2 –1 0 1 2 3 4 5 6
■
De Morgan’s laws are frequently used in writing computer programs. For instance, suppose you want your program to delete all files modified outside a certain range of dates, say from date 1 through date 2 inclusive. You would use the fact that
∼(date1 ≤ file_modification_date ≤ date2)
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
34 Chapter 2 The Logic of Compound Statements
is equivalent to
( file_modification_date < date1) or (date2 < file_modification_date). Example 2.1.11 A Cautionary Example According to De Morgan’s laws, the negation of p: Jim is tall and Jim is thin is ∼p: Jim is not tall or Jim is not thin because the negation of an and statement is the or statement in which the two components are negated. Unfortunately, a potentially confusing aspect of the English language can arise when you are taking negations of this kind. Note that statement p can be written more com- pactly as p′: Jim is tall and thin. When it is so written, another way to negate it is ∼(p′): Jim is not tall and thin. But in this form the negation looks like an and statement. Doesn’t that violate De Morgan’s laws? Actually no violation occurs. The reason is that in formal logic the words and and or are allowed only between complete statements, not between sentence fragments. One lesson to be learned from this example is that when you apply De Morgan’s laws, you must have complete statements on either side of each and and on either side of each or. ! Caution! Although the laws of logic are extremely useful, they should be used as an aid to thinking, not as a mechanical substitute for it. ■ Tautologies and Contradictions It has been said that all of mathematics reduces to tautologies. Although this is formally true, most working mathematicians think of their subject as having substance as well as form. Nonetheless, an intuitive grasp of basic logical tautologies is part of the equipment of anyone who reasons with mathematics. • Definition A tautology is a statement form that is always true regardless of the truth values of the individual statements substituted for its statement variables. A statement whose form is a tautology is a tautological statement. A contradication is a statement form that is always false regardless of the truth val- ues of the individual statements substituted for its statement variables. A statement whose form is a contradication is a contradictory statement. According to this definition, the truth of a tautological statement and the falsity of a contradictory statement are due to the logical structure of the statements themselves and are independent of the meanings of the statements. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.1 Logical Form and Logical Equivalence 35 Example 2.1.12 Tautologies and Contradictions Show that the statement form p ∨ ∼p is a tautology and that the statement form p ∧ ∼p is a contradiction. Solution p ∼p p ∨ ∼p p ∧ ∼p T F T F F T T F ↑ ↑ all T’s so all F’s so p ∨ ∼p is p ∧ ∼p is a a tautology contradiction ■ Example 2.1.13 Logical Equivalence Involving Tautologies and Contradictions If t is a tautology and c is a contradiction, show that p∧ t ≡ p and p∧ c ≡ c. Solution p t p ∧ t p c p ∧ c T T T T F F F T F F F F ↑ ↑ ↑ ↑ same truth same truth values, so values, so p ∧ t ≡ p p ∧ c ≡ c ■ Summary of Logical Equivalences Knowledge of logically equivalent statements is very useful for constructing arguments. It often happens that it is difficult to see how a conclusion follows from one form of a statement, whereas it is easy to see how it follows from a logically equivalent form of the statement. A number of logical equivalences are summarized in Theorem 2.1.1 for future reference. Theorem 2.1.1 Logical Equivalences Given any statement variables p, q, and r , a tautology t and a contradiction c, the following logical equivalences hold. 1. Commutative laws: p ∧ q ≡ q ∧ p p ∨ q ≡ q ∨ p 2. Associative laws: (p ∧ q) ∧ r ≡ p ∧ (q ∧ r) (p ∨ q) ∨ r ≡ p ∨ (q ∨ r) 3. Distributive laws: p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r) p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) 4. Identity laws: p ∧ t ≡ p p ∨ c ≡ p 5. Negation laws: p ∨ ∼p ≡ t p ∧ ∼p ≡ c 6. Double negative law: ∼(∼p) ≡ p 7. Idempotent laws: p ∧ p ≡ p p ∨ p ≡ p 8. Universal bound laws: p ∨ t ≡ t p ∧ c ≡ c 9. De Morgan’s laws: ∼(p ∧ q) ≡ ∼p ∨ ∼q ∼(p ∨ q) ≡ ∼p ∧ ∼q 10. Absorption laws: p ∨ (p ∧ q) ≡ p p ∧ (p ∨ q) ≡ p 11. Negations of t and c: ∼t ≡ c ∼c ≡ t Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 36 Chapter 2 The Logic of Compound Statements The proofs of laws 4 and 6, the first parts of laws 1 and 5, and the second part of law 9 have already been given as examples in the text. Proofs of the other parts of the theorem are left as exercises. In fact, it can be shown that the first five laws of Theorem 2.1.1 form a core from which the other laws can be derived. The first five laws are the axioms for a mathematical structure known as a Boolean algebra, which is discussed in Section 6.4. The equivalences of Theorem 2.1.1 are general laws of thought that occur in all areas of human endeavor. They can also be used in a formal way to rewrite complicated state- ment forms more simply. Example 2.1.14 Simplifying Statement Forms Use Theorem 2.1.1 to verify the logical equivalence ∼(∼p ∧ q) ∧ (p ∨ q) ≡ p. Solution Use the laws of Theorem 2.1.1 to replace sections of the statement form on the left by logically equivalent expressions. Each time you do this, you obtain a logically equivalent statement form. Continue making replacements until you obtain the statement form on the right. ∼(∼p ∧ q) ∧ (p ∨ q) ≡ (∼(∼p)∨ ∼q) ∧ (p ∨ q) by De Morgan’s laws ≡ (p∨ ∼q) ∧ (p ∨ q) by the double negative law ≡ p ∨ (∼q ∧ q) by the distributive law ≡ p ∨ (q ∧ ∼q) by the commutative law for ∧ ≡ p ∨ c by the negation law ≡ p by the identity law. ■ Skill in simplifying statement forms is useful in constructing logically efficient computer programs and in designing digital logic circuits. Although the properties in Theorem 2.1.1 can be used to prove the logical equivalence of two statement forms, they cannot be used to prove that statement forms are not logically equivalent. On the other hand, truth tables can always be used to determine both equivalence and nonequivalence, and truth tables are easy to program on a computer. When truth tables are used, however, checking for equivalence always requires 2n steps, where n is the number of variables. Sometimes you can quickly see that two statement forms are equivalent by Theorem 2.1.1, whereas it would take quite a bit of calculating to show their equivalence using truth tables. For instance, it follows immediately from the associative law for ∧ that p ∧ (∼q ∧ ∼r) ≡ (p∧ ∼q)∧ ∼r , whereas a truth table verification requires constructing a table with eight rows. Test Yourself Answers to Test Yourself questions are located at the end of each section. 1. An and statement is true if, and only if, both components are . 2. An or statement is false if, and only if, both components are . 3. Two statement forms are logically equivalent if, and only if, they always have . 4. De Morgan’s laws say (1) that the negation of an and state- ment is logically equivalent to the statement in which each component is , and (2) that the negation of an or statement is logically equivalent to the statement in which each component is . 5. A tautology is a statement that is always . 6. A contradiction is a statement that is always . Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.1 Logical Form and Logical Equivalence 37 Exercise Set 2.1 * In each of 1–4 represent the common form of each argument using letters to stand for component sentences, and fill in the blanks so that the argument in part (b) has the same logical form as the argument in part (a). 1. a. If all integers are rational, then the number 1 is rational. All integers are rational. Therefore, the number 1 is rational. b. If all algebraic expressions can be written in prefix notation, then . . Therefore, (a + 2b)(a2 − b) can be written in prefix notation. 2. a. If all computer programs contain errors, then this program contains an error. This program does not contain an error. Therefore, it is not the case that all computer programs contain errors. b. If , then . 2 is not odd. Therefore, it is not the case that all prime numbers are odd. 3. a. This number is even or this number is odd. This number is not even. Therefore, this number is odd. b. or logic is confusing. My mind is not shot. Therefore, . 4. a. If n is divisible by 6, then n is divisible by 3. If n is divisible by 3, then the sum of the digits of n is divisible by 3. Therefore, if n is divisible by 6, then the sum of the dig- its of n is divisible by 3. (Assume that n is a particular, fixed integer.) b. If this function is then this function is differen- tiable. If this function is then this function is continuous. Therefore, if this function is a polynomial, then this function . 5. Indicate which of the following sentences are statements. a. 1,024 is the smallest four-digit number that is a perfect square. b. She is a mathematics major. c. 128 = 26 d. x = 26 Write the statements in 6–9 in symbolic form using the symbols ∼,∨, and ∧ and the indicated letters to represent component statements. 6. Let s = “stocks are increasing” and i = “interest rates are steady.” a. Stocks are increasing but interest rates are steady. b. Neither are stocks increasing nor are interest rates steady. 7. Juan is a math major but not a computer science major. (m = “Juan is a math major,” c = “Juan is a computer science major”) 8. Let h = “John is healthy,” w = “John is wealthy,” and s = “John is wise.” a. John is healthy and wealthy but not wise. b. John is not wealthy but he is healthy and wise. c. John is neither healthy, wealthy, nor wise. d. John is neither wealthy nor wise, but he is healthy. e. John is wealthy, but he is not both healthy and wise. 9. Either this polynomial has degree 2 or it has degree 3 but not both. (n = “This polynomial has degree 2,” k = “This polynomial has degree 3”) 10. Let p be the statement “DATAENDFLAG is off,” q the statement “ERROR equals 0,” and r the statement “SUM is less than 1,000.” Express the following sentences in sym- bolic notation. a. DATAENDFLAG is off, ERROR equals 0, and SUM is less than 1,000. b. DATAENDFLAG is off but ERROR is not equal to 0. c. DATAENDFLAG is off; however, ERROR is not 0 or SUM is greater than or equal to 1,000. d. DATAENDFLAG is on and ERROR equals 0 but SUM is greater than or equal to 1,000. e. Either DATAENDFLAG is on or it is the case that both ERROR equals 0 and SUM is less than 1,000. 11. In the following sentence, is the word or used in its inclu- sive or exclusive sense? A team wins the playoffs if it wins two games in a row or a total of three games. Write truth tables for the statement forms in 12–15. 12. ∼p ∧ q 13. ∼(p ∧ q) ∨ (p ∨ q) 14. p ∧ (q ∧ r) 15. p ∧ (∼q ∨ r) Determine whether the statement forms in 16–24 are logically equivalent. In each case, construct a truth table and include a sentence justifying your answer. Your sentence should show that you understand the meaning of logical equivalence. 16. p ∨ (p ∧ q) and p 17. ∼(p ∧ q) and ∼p ∧ ∼q 18. p ∨ t and t 19. p ∧ t and p 20. p ∧ c and p ∨ c 21. (p ∧ q) ∧ r and p ∧ (q ∧ r) *For exercises with blue numbers or letters, solutions are given in Appendix B. The symbol H indicates that only a hint or a partial solution is given. The symbol ✶ signals that an exercise is more challenging than usual. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 38 Chapter 2 The Logic of Compound Statements 22. p ∧ (q ∨ r) and (p ∧ q) ∨ (p ∧ r) 23. (p ∧ q) ∨ r and p ∧ (q ∨ r) 24. (p ∨ q) ∨ (p ∧ r) and (p ∨ q) ∧ r Use De Morgan’s laws to write negations for the statements in 25–31. 25. Hal is a math major and Hal’s sister is a computer science major. 26. Sam is an orange belt and Kate is a red belt. 27. The connector is loose or the machine is unplugged. 28. The units digit of 467 is 4 or it is 6. 29. This computer program has a logical error in the first ten lines or it is being run with an incomplete data set. 30. The dollar is at an all-time high and the stock market is at a record low. 31. The train is late or my watch is fast. Assume x is a particular real number and use De Morgan’s laws to write negations for the statements in 32–37. 32. −2 < x < 7 33. −10 < x < 2 34. x < 2 or x > 5 35. x ≤ −1 or x > 1 36. 1 > x ≥ −3 37. 0 > x ≥ −7
In 38 and 39, imagine that num_orders and num_instock are par- ticular values, such as might occur during execution of a com- puter program. Write negations for the following statements.
38. (num_orders > 100 and num_instock ≤ 500) or num_instock < 200 39. (num_orders < 50 and num_instock > 300) or (50 ≤ num_orders < 75 and num_instock > 500)
Use truth tables to establish which of the statement forms in 40–43 are tautologies and which are contradictions.
40. (p ∧ q) ∨ (∼p ∨ (p ∧ ∼q)) 41. (p ∧ ∼q) ∧ (∼p ∨ q) 42. ((∼p ∧ q) ∧ (q ∧ r))∧ ∼q 43. (∼p ∨ q) ∨ (p ∧ ∼q) In 44 and 45, determine whether the statements in (a) and (b) are logically equivalent.
44. Assume x is a particular real number.
a. x < 2 or it is not the case that 1 < x < 3. b. x ≤ 1 or either x < 2 or x ≥ 3. 45. a. Bob is a double math and computer science major and Ann is a math major, but Ann is not a double math and computer science major. b. It is not the case that both Bob and Ann are dou- ble math and computer science majors, but it is the case that Ann is a math major and Bob is a double math and computer science major. 46.✶ In Example 2.1.4, the symbol ⊕ was introduced to denote exclusive or, so p ⊕ q ≡ (p ∨ q)∧ ∼(p ∧ q). Hence the truth table for exclusive or is as follows: p q p ⊕ q T T F T F T F T T F F F a. Find simpler statement forms that are logically equiva- lent to p ⊕ p and (p ⊕ p)⊕ p. b. Is (p ⊕ q)⊕ r ≡ p ⊕ (q ⊕ r)? Justify your answer. c. Is (p ⊕ q) ∧ r ≡ (p ∧ r)⊕ (q ∧ r)? Justify your answer. 47.✶ In logic and in standard English, a double negative is equiv- alent to a positive. There is one fairly common English usage in which a “double positive” is equivalent to a nega- tive. What is it? Can you think of others? In 48 and 49 below, a logical equivalence is derived from Theo- rem 2.1.1. Supply a reason for each step. 48. (p ∧ ∼q) ∨ (p ∧ q) ≡ p ∧ (∼q ∨ q) by (a) ≡ p ∧ (q ∨ ∼q) by (b) ≡ p ∧ t by (c) ≡ p by (d) Therefore, (p ∧ ∼q) ∨ (p ∧ q) ≡ p. 49. (p ∨ ∼q) ∧ (∼p ∨ ∼q) ≡ (∼q ∨ p) ∧ (∼q ∨ ∼p) by (a) ≡ ∼q ∨ (p ∧ ∼p) by (b) ≡ ∼q ∨ c by (c) ≡ ∼q by (d) Therefore, (p ∨ ∼q) ∧ (∼p ∨ ∼q) ≡ ∼q. Use Theorem 2.1.1 to verify the logical equivalences in 50–54. Supply a reason for each step. 50. (p ∧ ∼q) ∨ p ≡ p 51. p ∧ (∼q ∨ p) ≡ p 52. ∼(p ∨ ∼q) ∨ (∼p ∧ ∼q) ≡ ∼p 53. ∼((∼p ∧ q) ∨ (∼p ∧ ∼q)) ∨ (p ∧ q) ≡ p 54. (p ∧ (∼(∼p ∨ q))) ∨ (p ∧ q) ≡ p Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.2 Conditional Statements 39 Answers for Test Yourself 1. true 2. false 3. the same truth values 4. or; negated; and; negated 5. true 6. false 2.2 Conditional Statements . . . hypothetical reasoning implies the subordination of the real to the realm of the possible . . . — Jean Piaget, 1972 When you make a logical inference or deduction, you reason from a hypothesis to a conclusion. Your aim is to be able to say, “If such and such is known, then something or other must be the case.” Let p and q be statements. A sentence of the form “If p then q” is denoted symboli- cally by “p→ q”; p is called the hypothesis and q is called the conclusion. For instance, consider the following statement: If 4,686 is divisible by 6︸ ︷︷ ︸, then 4,686 is divisible by 3︸ ︷︷ ︸ hypothesis conclusion Such a sentence is called conditional because the truth of statement q is conditioned on the truth of statement p. The notation p→ q indicates that→ is a connective, like ∧ or ∨, that can be used to join statements to create new statements. To define p→ q as a statement, therefore, we must specify the truth values for p→ q as we specified truth values for p ∧ q and for p ∨ q. As is the case with the other connectives, the formal definition of truth values for → (if-then) is based on its everyday, intuitive meaning. Consider an example. Suppose you go to interview for a job at a store and the owner of the store makes you the following promise: If you show up for work Monday morning, then you will get the job. Under what circumstances are you justified in saying the owner spoke falsely? That is, under what circumstances is the above sentence false? The answer is: You do show up for work Monday morning and you do not get the job. After all, the owner’s promise only says you will get the job if a certain condition (showing up for work Monday morning) is met; it says nothing about what will hap- pen if the condition is not met. So if the condition is not met, you cannot in fairness say the promise is false regardless of whether or not you get the job. The above example was intended to convince you that the only combination of circum- stances in which you would call a conditional sentence false occurs when the hypothesis is true and the conclusion is false. In all other cases, you would not call the sentence false. This implies that the only row of the truth table for p→ q that should be filled in with an F is the row where p is T and q is F. No other row should contain an F. But each row of a truth table must be filled in with either a T or an F. Thus all other rows of the truth table for p→ q must be filled in with T’s. Truth Table for p → q p q p → q T T T T F F F T T F F T Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 40 Chapter 2 The Logic of Compound Statements • Definition If p and q are statement variables, the conditional of q by p is “If p then q” or “p implies q” and is denoted p→ q. It is false when p is true and q is false; otherwise it is true. We call p the hypothesis (or antecedent) of the conditional and q the conclusion (or consequent). A conditional statement that is true by virtue of the fact that its hypothesis is false is often called vacuously true or true by default. Thus the statement “If you show up for work Monday morning, then you will get the job” is vacuously true if you do not show up for work Monday morning. In general, when the “if” part of an if-then statement is false, the statement as a whole is said to be true, regardless of whether the conclusion is true or false. Example 2.2.1 A Conditional Statement with a False Hypothesis Consider the statement: If 0 = 1 then 1 = 2. As strange as it may seem, since the hypothesis of this statement is false, the statement as a whole is true. ■ The philosopherWillard Van Orman Quine advises against using the phrase “p implies q” to mean “p→ q” because the word implies suggests that q can be logically deduced from p and this is often not the case. Nonetheless, the phrase is used by many people, probably because it is a convenient replacement for the → symbol. And, of course, in many cases a conclusion can be deduced from a hypothesis, even when the hypothesis is false. Note For example, if 0 = 1, then, by adding 1 to both sides of the equation, you can deduce that 1 = 2. In expressions that include→ as well as other logical operators such as ∧,∨, and ∼, the order of operations is that→ is performed last. Thus, according to the specification of order of operations in Section 2.1, ∼ is performed first, then ∧ and ∨, and finally→. Example 2.2.2 Truth Table for p ∨ ∼q →∼p Construct a truth table for the statement form p ∨ ∼q →∼p. Solution By the order of operations given above, the following two expressions are equiv- alent: p ∨ ∼q →∼p and (p ∨ (∼q))→ (∼p), and this order governs the construction of the truth table. First fill in the four possible combinations of truth values for p and q, and then enter the truth values for∼p and∼q using the definition of negation. Next fill in the p ∨ ∼q column using the definition of ∨. Finally, fill in the p ∨ ∼q →∼p column using the definition of→. The only rows in which the hypothesis p ∨ ∼q is true and the conclusion ∼p is false are the first and second rows. So you put F’s in those two rows and T’s in the other two rows. conclusion︷ ︸︸ ︷ hypothesis︷ ︸︸ ︷ p q ∼p ∼q p ∨ ∼q p ∨ ∼q → ∼p T T F F T F T F F T T F F T T F F T F F T T T T ■ Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.2 Conditional Statements 41 Logical Equivalences Involving → Imagine that you are trying to solve a problem involving three statements: p, q, and r . Suppose you know that the truth of r follows from the truth of p and also that the truth of r follows from the truth of q. Then no matter whether p or q is the case, the truth of r must follow. The division-into-cases method of analysis is based on this idea. Example 2.2.3 Division into Cases: Showing that p ∨ q → r ≡ ( p → r) ∧ (q → r) Use truth tables to show the logical equivalence of the statement forms p ∨ q → r and (p→ r) ∧ (q → r). Annotate the table with a sentence of explanation. Solution First fill in the eight possible combinations of truth values for p, q, and r . Then fill in the columns for p ∨ q, p→ r , and q → r using the definitions of or and if-then. For instance, the p→ r column has F’s in the second and fourth rows because these are the rows in which p is true and q is false. Next fill in the p ∨ q → r column using the definition of if-then. The rows in which the hypothesis p ∨ q is true and the conclusion r is false are the second, fourth, and sixth. So F’s go in these rows and T’s in all the others. The complete table shows that p ∨ q → r and (p→ r) ∧ (q → r) have the same truth values for each combination of truth values of p, q, and r . Hence the two statement forms are logically equivalent. p q r p ∨ q p → r q → r p ∨ q → r ( p → r) ∧ (q → r) T T T T T T T T T T F T F F F F T F T T T T T T T F F T F T F F F T T T T T T T F T F T T F F F F F T F T T T T F F F F T T T T ↑ ↑ p ∨ q → r and (p→ r) ∧ (q → r) always have the same truth values, so they are logically equivalent ■ Representation of If-Then As Or In exercise 13(a) at the end of this section you are asked to use truth tables to show that p→ q ≡ ∼p ∨ q. The logical equivalence of “if p then q” and “not p or q” is occasionally used in everyday speech. Here is one instance. Example 2.2.4 Application of the Equivalence between ∼p ∨ q and p → q Rewrite the following statement in if-then form. Either you get to work on time or you are fired. Solution Let ∼p be You get to work on time. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 42 Chapter 2 The Logic of Compound Statements and q be You are fired. Then the given statement is ∼p ∨ q. Also p is You do not get to work on time. So the equivalent if-then version, p→ q, is If you do not get to work on time, then you are fired. ■ The Negation of a Conditional Statement By definition, p→ q is false if, and only if, its hypothesis, p, is true and its conclusion, q, is false. It follows that The negation of “if p then q” is logically equivalent to “p and not q.” This can be restated symbolically as follows: ∼(p→ q) ≡ p ∧ ∼q You can also obtain this result by starting from the logical equivalence p→ q ≡ ∼ p ∨ q. Take the negation of both sides to obtain ∼(p→ q) ≡ ∼(∼p ∨ q) ≡ ∼(∼p) ∧ (∼q) by De Morgan’s laws ≡ p ∧ ∼q by the double negative law. Yet another way to derive this result is to construct truth tables for ∼(p→ q) and for p ∧ ∼q and to check that they have the same truth values. (See exercise 13(b) at the end of this section.) Example 2.2.5 Negations of If-Then Statements Write negations for each of the following statements: a. If my car is in the repair shop, then I cannot get to class. b. If Sara lives in Athens, then she lives in Greece. Solution a. My car is in the repair shop and I can get to class. b. Sara lives in Athens and she does not live in Greece. (Sara might live in Athens, Georgia; Athens, Ohio; or Athens, Wisconsin.) ■ It is tempting to write the negation of an if-then statement as another if-then statement. Please resist that temptation! ! Caution! Remember that the negation of an if-then statement does not start with the word if. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.2 Conditional Statements 43 The Contrapositive of a Conditional Statement One of the most fundamental laws of logic is the equivalence between a conditional statement and its contrapositive. • Definition The contrapositive of a conditional statement of the form “If p then q” is If ∼q then ∼p. Symbolically, The contrapositive of p→ q is ∼q →∼p. The fact is that A conditional statement is logically equivalent to its contrapositive. You are asked to establish this equivalence in exercise 26 at the end of this section. Example 2.2.6 Writing the Contrapositive Write each of the following statements in its equivalent contrapositive form: a. If Howard can swim across the lake, then Howard can swim to the island. b. If today is Easter, then tomorrow is Monday. Solution a. If Howard cannot swim to the island, then Howard cannot swim across the lake. b. If tomorrow is not Monday, then today is not Easter. ■ When you are trying to solve certain problems, you may find that the contrapositive form of a conditional statement is easier to work with than the original statement. Replac- ing a statement by its contrapositive may give the extra push that helps you over the top in your search for a solution. This logical equivalence is also the basis for one of the most important laws of deduction, modus tollens (to be explained in Section 2.3), and for the contrapositive method of proof (to be explained in Section 4.6). The Converse and Inverse of a Conditional Statement The fact that a conditional statement and its contrapositive are logically equivalent is very important and has wide application. Two other variants of a conditional statement are not logically equivalent to the statement. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 44 Chapter 2 The Logic of Compound Statements • Definition Suppose a conditional statement of the form “If p then q” is given. 1. The converse is “If q then p.” 2. The inverse is “If ∼p then ∼q.” Symbolically, The converse of p→ q is q → p, and The inverse of p→ q is ∼p→∼q. Example 2.2.7 Writing the Converse and the Inverse Write the converse and inverse of each of the following statements: a. If Howard can swim across the lake, then Howard can swim to the island. b. If today is Easter, then tomorrow is Monday. Solution a. Converse: If Howard can swim to the island, then Howard can swim across the lake. Inverse: If Howard cannot swim across the lake, then Howard cannot swim to the island. b. Converse: If tomorrow is Monday, then today is Easter. Inverse: If today is not Easter, then tomorrow is not Monday. ■ Note that while the statement “If today is Easter, then tomorrow is Monday” is always true, both its converse and inverse are false on every Sunday except Easter. 1. A conditional statement and its converse are not logically equivalent. 2. A conditional statement and its inverse are not logically equivalent. 3. The converse and the inverse of a conditional statement are logically equivalent to each other. ! Caution! Many people believe that if a conditional statement is true, then its converse and inverse must also be true. This is not correct! In exercises 24, 25, and 27 at the end of this section, you are asked to use truth tables to verify the statements in the box above. Note that the truth of statement 3 also follows from the observation that the inverse of a conditional statement is the contrapositive of its converse. Only If and the Biconditional To say “p only if q” means that p can take place only if q takes place also. That is, if q does not take place, then p cannot take place. Another way to say this is that if p occurs, then q must also occur (by the logical equivalence between a statement and its contrapositive). Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.2 Conditional Statements 45 • Definition It p and q are statements, p only if q means “if not q then not p,” or, equivalently, “if p then q.” Example 2.2.8 Converting Only If to If-Then Rewrite the following statement in if-then form in two ways, one of which is the contra- positive of the other. John will break the world’s record for the mile run only if he runs the mile in under four minutes. Solution Version 1: If John does not run the mile in under four minutes, then he will not break the world’s record. Version 2: If John breaks the world’s record, then he will have run the mile in under four minutes. ■ ! Caution! “p only if q” does not mean “p if q.” Note that it is possible for “p only if q” to be true at the some time that “p if q” is false. For instance, to say that John will break the world’s record only if he runs the mile in under four minutes does not mean that John will break the world’s record if he runs the mile in under four minutes. His time could be under four minutes but still not be fast enough to break the record. • Definition Given statement variables p and q, the biconditional of p and q is “p if, and only if, q” and is denoted p↔ q. It is true if both p and q have the same truth values and is false if p and q have opposite truth values. The words if and only if are sometimes abbreviated iff. The biconditional has the following truth table: Truth Table for p ↔ q p q p ↔ q T T T T F F F T F F F T In order of operations↔ is coequal with→. As with ∧ and ∨, the only way to indicate precedence between them is to use parentheses. The full hierarchy of operations for the five logical operators is on the next page. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 46 Chapter 2 The Logic of Compound Statements Order of Operations for Logical Operators 1. ∼ Evaluate negations first. 2. ∧,∨ Evaluate ∧ and ∨ second. When both are present, parentheses may be needed. 3. →,↔ Evaluate → and ↔ third. When both are present, parentheses may be needed. According to the separate definitions of if and only if, saying “p if, and only if, q” should mean the same as saying both “p if q” and “p only if q.” The following annotated truth table shows that this is the case: Truth Table Showing that p ↔ q ≡ ( p → q) ∧ (q → p) p q p → q q → p p ↔ q ( p → q) ∧ (q → p) T T T T T T T F F T F F F T T F F F F F T T T T ↑ ↑ p↔ q and (p→ q) ∧ (q → p) always have the same truth values, so they are logically equivalent Example 2.2.9 If and Only If Rewrite the following statement as a conjunction of two if-then statements: This computer program is correct if, and only if, it produces correct answers for all possible sets of input data. Solution If this program is correct, then it produces the correct answes for all possible sets of input data; and if this program produces the correct answers for all possible sets of input data, then it is correct. ■ Necessary and Sufficient Conditions The phrases necessary condition and sufficient condition, as used in formal English, cor- respond exactly to their definitions in logic. • Definition If r and s are statements: r is a sufficient condition for s means “if r then s.” r is a necessary condition for s means “if not r then not s.” In other words, to say “r is a sufficient condition for s” means that the occurrence of r is sufficient to guarantee the occurrence of s. On the other hand, to say “r is a necessary condition for s” means that if r does not occur, then s cannot occur either: Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.2 Conditional Statements 47 The occurrence of r is necessary to obtain the occurrence of s. Note that because of the equivalence between a statement and its contrapositive, r is a necessary condition for s also means “if s then r.” Consequently, r is a necessary and sufficient condition for s means “r if, and only if, s.” Example 2.2.10 Interpreting Necessary and Sufficient Conditions Consider the statement “If John is eligible to vote, then he is at least 18 years old.” The truth of the condition “John is eligible to vote” is sufficient to ensure the truth of the condition “John is at least 18 years old.” In addition, the condition “John is at least 18 years old” is necessary for the condition “John is eligible to vote” to be true. If John were younger than 18, then he would not be eligible to vote. ■ Example 2.2.11 Converting a Sufficient Condition to If-Then Form Rewrite the following statement in the form “If A then B”: Pia’s birth on U.S soil is a sufficient condition for her to be a U.S. citizen. Solution If Pia was born on U.S. soil, then she is a U.S. citizen. ■ Example 2.2.12 Converting a Necessary Condition to If-Then Form Use the contrapositive to rewrite the following statement in two ways: George’s attaining age 35 is a necessary condition for his being president of the United States. Solution Version 1: If George has not attained the age of 35, then he cannot be presi- dent of the United States. Version 2: If George can be president of the United States, then he has attained the age of 35. ■ Remarks 1. In logic, a hypothesis and conclusion are not required to have related subject matters. In ordinary speech we never say things like “If computers are machines, then Babe Ruth was a baseball player” or “If 2+ 2 = 5, then Mickey Mouse is president of the United States.” We formulate a sentence like “If p then q” only if there is some connection of content between p and q. In logic, however, the two parts of a conditional statement need not have related meanings. The reason? If there were such a requirement, who would enforce it? What one person perceives as two unrelated clauses may seem related to someone else. There would have to be a central arbiter to check each conditional sentence before anyone could use it, to be sure its clauses were in proper relation. This is impractical, to say the least! Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 48 Chapter 2 The Logic of Compound Statements Thus a statement like “if computers are machines, then Babe Ruth was a baseball player” is allowed, and it is even called true because both its hypothesis and its conclu- sion are true. Similarly, the statement “If 2+ 2 = 5, then Mickey Mouse is president of the United States” is allowed and is called true because its hypothesis is false, even though doing so may seem ridiculous. In mathematics it often happens that a carefully formulated definition that suc- cessfully covers the situations for which it was primarily intended is later seen to be satisfied by some extreme cases that the formulator did not have in mind. But those are the breaks, and it is important to get into the habit of exploring definitions fully to seek out and understand all their instances, even the unusual ones. 2. In informal language, simple conditionals are often used to mean biconditionals. The formal statement “p if, and only if, q” is seldom used in ordinary language. Frequently, when people intend the biconditional they leave out either the and only if or the if and. That is, they say either “p if q” or “p only if q” when they really mean “p if, and only if, q.” For example, consider the statement “You will get dessert if, and only if, you eat your dinner.” Logically, this is equivalent to the conjunction of the following two statements. Statement 1: If you eat your dinner, then you will get dessert. Statement 2: You will get dessert only if you eat your dinner. or If you do not eat your dinner, then you will not get dessert. Now how many parents in the history of the world have said to their children “You will get dessert if, and only if, you eat your dinner”? Not many! Most say either “If you eat your dinner, you will get dessert” (these take the positive approach—they emphasize the reward) or “You will get dessert only if you eat your dinner” (these take the negative approach—they emphasize the punishment). Yet the parents who promise the reward intend to suggest the punishment as well, and those who threaten the punishment will certainly give the reward if it is earned. Both sets of parents expect that their conditional statements will be interpreted as biconditionals. Since we often (correctly) interpret conditional statements as biconditionals, it is not surprising that we may come to believe (mistakenly) that conditional statements are always logically equivalent to their inverses and converses. In formal settings, however, statements must have unambiguous interpretations. If-then statements can’t sometimes mean “if-then” and other times mean “if and only if.” When using language in mathe- matics, science, or other situations where precision is important, it is essential to interpret if-then statements according to the formal definition and not to confuse them with their converses and inverses. Test Yourself 1. An if-then statement is false if, and only if, the hypothesis is and the conclusion is . 2. The negation of “if p then q” is . 3. The converse of “if p then q” is . 4. The contrapositive of “if p then q” is . 5. The inverse of “if p then q” is . 6. A conditional statement and its contrapositive are . 7. A conditional statement and its converse are not . 8. “R is a sufficient condition for S” means “if then .” 9. “R is a necessary condition for S” means “if then .” 10. “R only if S” means “if then .” Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.2 Conditional Statements 49 Exercise Set 2.2 Rewrite the statements in 1–4 in if-then form. 1. This loop will repeat exactly N times if it does not contain a stop or a go to. 2. I am on time for work if I catch the 8:05 bus. 3. Freeze or I’ll shoot. 4. Fix my ceiling or I won’t pay my rent. Construct truth tables for the statement forms in 5–11. 5. ∼p ∨ q →∼q 6. (p ∨ q) ∨ (∼p ∧ q)→ q 7. p ∧ ∼q → r 8. ∼p ∨ q → r 9. p ∧ ∼r ↔ q ∨ r 10. (p→ r)↔ (q → r) 11. (p→ (q → r))↔ ((p ∧ q)→ r) 12. Use the logical equivalence established in Example 2.2.3, p ∨ q → r ≡ (p→ r) ∧ (q → r), to rewrite the follow- ing statement. (Assume that x represents a fixed real number.) If x > 2 or x < −2, then x2 > 4. 13. Use truth tables to verify the following logical equiv-
alences. Include a few words of explanation with your answers.
a. p→ q ≡ ∼p ∨ q b. ∼(p→ q) ≡ p ∧ ∼q. 14.H a. Show that the following statement forms are all logically
equivalent.
p→ q ∨ r, p ∧ ∼q → r, and p ∧ ∼r → q b. Use the logical equivalences established in part (a) to
rewrite the following sentence in two different ways. (Assume that n represents a fixed integer.)
If n is prime, then n is odd or n is 2.
15. Determine whether the following statement forms are logi- cally equivalent:
p→ (q → r) and (p→ q)→ r
In 16 and 17, write each of the two statements in symbolic form and determine whether they are logically equivalent. Include a truth table and a few words of explanation.
16. If you paid full price, you didn’t buy it at Crown Books. You didn’t buy it at Crown Books or you paid full price.
17. If 2 is a factor of n and 3 is a factor of n, then 6 is a factor of n. 2 is not a factor of n or 3 is not a factor of n or 6 is a factor of n.
18. Write each of the following three statements in symbolic form and determine which pairs are logically equivalent. Include truth tables and a few words of explanation.
If it walks like a duck and it talks like a duck, then it is a duck.
Either it does not walk like a duck or it does not talk like a duck, or it is a duck.
If it does not walk like a duck and it does not talk like a duck, then it is not a duck.
19. True or false? The negation of “If Sue is Luiz’s mother, then Ali is his cousin” is “If Sue is Luiz’s mother, then Ali is not his cousin.”
20. Write negations for each of the following statements. (Assume that all variables represent fixed quantities or enti- ties, as appropriate.)
a. If P is a square, then P is a rectangle. b. If today is New Year’s Eve, then tomorrow is January. c. If the decimal expansion of r is terminating, then r is
rational. d. If n is prime, then n is odd or n is 2. e. If x is nonnegative, then x is positive or x is 0. f. If Tom is Ann’s father, then Jim is her uncle and Sue is
her aunt. g. If n is divisible by 6, then n is divisible by 2 and n is
divisible by 3.
21. Suppose that p and q are statements so that p→ q is false. Find the truth values of each of the following:
a. ∼p→ q b. p ∨ q c. q → p 22.H Write contrapositives for the statements of exercise 20.
23.H Write the converse and inverse for each statement of exercise 20.
Use truth tables to establish the truth of each statement in 24–27.
24. A conditional statement is not logically equivalent to its converse.
25. A conditional statement is not logically equivalent to its inverse.
26. A conditional statement and its contrapositive are logically equivalent to each other.
27. The converse and inverse of a conditional statement are log- ically equivalent to each other.
28.H “Do you mean that you think you can find out the answer to it?” said the March Hare.
“Exactly so,” said Alice. “Then you should say what you mean,” the March Hare
went on. “I do,” Alice hastily replied; “at least—at least I mean
what I say—that’s the same thing, you know.”
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
50 Chapter 2 The Logic of Compound Statements
“Not the same thing a bit!” said the Hatter. “Why, you might just as well say that ‘I see what I eat’ is the same thing as ‘I eat what I see’!”
—from “A Mad Tea-Party” in Alice in Wonderland, by Lewis Carroll
The Hatter is right. “I say what I mean” is not the same thing as “I mean what I say.” Rewrite each of these two sentences in if-then form and explain the logical relation between them. (This exercise is referred to in the introduc- tion to Chapter 4.)
If statement forms P and Q are logically equivalent, then P ↔ Q is a tautology. Conversely, if P ↔ Q is a tautology, then P and Q are logically equivalent. Use↔ to convert each of the logical equivalences in 29–31 to a tautology. Then use a truth table to verify each tautology.
29. p→ (q ∨ r) ≡ (p ∧ ∼q)→ r 30. p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r) 31. p→ (q → r) ≡ (p ∧ q)→ r Rewrite each of the statements in 32 and 33 as a conjunction of two if-then statements.
32. This quadratic equation has two distinct real roots if, and only if, its discriminant is greater than zero.
33. This integer is even if, and only if, it equals twice some integer.
Rewrite the statements in 34 and 35 in if-then form in two ways, one of which is the contrapositive of the other.
34. The Cubs will win the pennant only if they win tomorrow’s game.
35. Sam will be allowed on Signe’s racing boat only if he is an expert sailor.
36. Taking the long view on your education, you go to the Pres- tige Corporation and ask what you should do in college to be hired when you graduate. The personnel director replies that you will be hired only if you major in mathematics or computer science, get a B average or better, and take accounting. You do, in fact, become a math major, get a B+
average, and take accounting. You return to Prestige Cor- poration, make a formal application, and are turned down. Did the personnel director lie to you?
Some programming languages use statements of the form “r unless sn” to mean that as long as s does not happen, then r will happen. More formally:
Definition: If r and s are statements, r unless s means if ∼s then r.
In 37–39, rewrite the statements in if-then form.
37. Payment will be made on the fifth unless a new hearing is granted.
38. Ann will go unless it rains.
39. This door will not open unless a security code is entered.
Rewrite the statements in 40 and 41 in if-then form.
40. Catching the 8:05 bus is a sufficient condition for my being on time for work.
41. Having two 45◦ angles is a sufficient condition for this tri- angle to be a right triangle.
Use the contrapositive to rewrite the statements in 42 and 43 in if-then form in two ways.
42. Being divisible by 3 is a necessary condition for this num- ber to be divisible by 9.
43. Doing homework regularly is a necessary condition for Jim to pass the course.
Note that “a sufficient condition for s is r” means r is a suffi- cient condition for s and that “a necessary condition for s is r” means r is a necessary condition for s. Rewrite the statements in 44 and 45 in if-then form.
44. A sufficient condition for Jon’s team to win the champi- onship is that it win the rest of its games.
45. A necessary condition for this computer program to be cor- rect is that it not produce error messages during translation.
46. “If compound X is boiling, then its temperature must be at least 150◦C.” Assuming that this statement is true, which of the following must also be true? a. If the temperature of compound X is at least 150◦C, then
compound X is boiling. b. If the temperature of compound X is less than 150◦C,
then compound X is not boiling. c. Compound X will boil only if its temperature is at least
150◦C. d. If compound X is not boiling, then its temperature is less
than 150◦C. e. A necessary condition for compound X to boil is that its
temperature be at least 150◦C. f. A sufficient condition for compound X to boil is that its
temperature be at least 150◦C.
In 47–50 (a) use the logical equivalences p→ q ≡∼p ∨ q and p↔ q ≡ (∼p ∨ q) ∧ (∼q ∨ p) to rewrite the given statement forms without using the symbol→ or↔, and (b) use the logi- cal equivalence p ∨ q ≡∼(∼p∧ ∼q) to rewrite each statement form using only ∧ and ∼.
47. p ∧ ∼q → r 48. p ∨ ∼q → r ∨ q 49. (p→ r)↔ (q → r) 50. (p→ (q → r))↔ ((p ∧ q)→ r) 51. Given any statement form, is it possible to find a logi-
cally equivalent form that uses only ∼ and ∧? Justify your answer.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.3 Valid and Invalid Arguments 51
Answers for Test Yourself 1. true; false 2. p∧ ∼q 3. if q then p 4. if ∼q then ∼p 5. if ∼p then ∼q 6. logically equivalent 7. logically equivalent 8. R; S 9. S; R 10. R; S
2.3 Valid and Invalid Arguments “Contrariwise,” continued Tweedledee, “if it was so, it might be; and if it were so, it would be; but as it isn’t, it ain’t. That’s logic.” — Lewis Carroll, Through the Looking Glass
In mathematics and logic an argument is not a dispute. It is a sequence of statements ending in a conclusion. In this section we show how to determine whether an argument is valid—that is, whether the conclusion follows necessarily from the preceding statements. We will show that this determination depends only on the form of an argument, not on its content.
It was shown in Section 2.1 that the logical form of an argument can be abstracted from its content. For example, the argument
If Socrates is a man, then Socrates is mortal.
Socrates is a man.
∴ Socrates is mortal.
has the abstract form
If p then q p
∴ q When considering the abstract form of an argument, think of p and q as variables
for which statements may be substituted. An argument form is called valid if, and only if, whenever statements are substituted that make all the premises true, the conclusion is also true.
• Definition An argument is a sequence of statements, and an argument form is a sequence of statement forms. All statements in an argument and all statement forms in an argument form, except for the final one, are called premises (or assumptions or hypotheses). The final statement or statement form is called the conclusion. The symbol ∴ , which is read “therefore,” is normally placed just before the conclusion.
To say that an argument form is validmeans that no matter what particular state- ments are substituted for the statement variables in its premises, if the resulting premises are all true, then the conclusion is also true. To say that an argument is valid means that its form is valid.
The crucial fact about a valid argument is that the truth of its conclusion follows necessarily or inescapably or by logical form alone from the truth of its premises. It is impossible to have a valid argument with true premises and a false conclusion. When an argument is valid and its premises are true, the truth of the conclusion is said to be inferred or deduced from the truth of the premises. If a conclusion “ain’t necessarily so,” then it isn’t a valid deduction.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
52 Chapter 2 The Logic of Compound Statements
Testing an Argument Form for Validity
1. Identify the premises and conclusion of the argument form.
2. Construct a truth table showing the truth values of all the premises and the con- clusion.
3. A row of the truth table in which all the premises are true is called a critical row. If there is a critical row in which the conclusion is false, then it is possible for an argument of the given form to have true premises and a false conclusion, and so the argument form is invalid. If the conclusion in every critical row is true, then the argument form is valid.
Example 2.3.1 Determining Validity or Invalidity
Determine whether the following argument form is valid or invalid by drawing a truth table, indicating which columns represent the premises and which represent the conclu- sion, and annotating the table with a sentence of explanation. When you fill in the table, you only need to indicate the truth values for the conclusion in the rows where all the premises are true (the critical rows) because the truth values of the conclusion in the other rows are irrelevant to the validity or invalidity of the argument.
p→ q ∨ ∼r q → p ∧ r
∴ p→ r Solution The truth table shows that even though there are several situations in which the
premises and the conclusion are all true (rows 1, 7, and 8), there is one situation (row 4) where the premises are true and the conclusion is false.
premises︷ ︸︸ ︷ conclusion p q r ∼r q ∨ ∼r p ∧ r p → q ∨ ∼r q → p ∧ r p → r T T T F T T T T T
T T F T T F T F
T F T F F T F T
T F F T T F T T F
→
This row shows that an argument of this form can have true premises and a false conclusion. Hence this form of argument is invalid.F T T F T F T F
F T F T T F T F
F F T F F F T T T
F F F T T F T T T ■
Modus Ponens and Modus Tollens An argument form consisting of two premises and a conclusion is called a syllogism. The first and second premises are called themajor premise andminor premise, respectively.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.3 Valid and Invalid Arguments 53
The most famous form of syllogism in logic is calledmodus ponens. It has the following form:
If p then q.
p
∴ q Here is an argument of this form:
If the sum of the digits of 371,487 is divisible by 3, then 371,487 is divisible by 3.
The sum of the digits of 371,487 is divisible by 3.
∴ 371,487 is divisible by 3. The term modus ponens is Latin meaning “method of affirming” (the conclusion is an affirmation). Long before you saw your first truth table, you were undoubtedly being convinced by arguments of this form. Nevertheless, it is instructive to prove that modus ponens is a valid form of argument, if for no other reason than to confirm the agreement between the formal definition of validity and the intuitive concept. To do so, we construct a truth table for the premises and conclusion.
premises︷ ︸︸ ︷ conclusion p q p → q p q T T T T T ←− critical row T F F T
F T T F
F F T F
The first row is the only one in which both premises are true, and the conclusion in that row is also true. Hence the argument form is valid.
Now consider another valid argument form calledmodus tollens. It has the following form:
If p then q.
∼q ∴ ∼p
Here is an example of modus tollens:
If Zeus is human, then Zeus is mortal.
Zeus is not mortal.
∴ Zeus is not human. An intuitive explanation for the validity of modus tollens uses proof by contradiction.
It goes like this:
Suppose
(1) If Zeus is human, then Zeus is mortal; and
(2) Zeus is not mortal.
Must Zeus necessarily be nonhuman?
Yes!
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
54 Chapter 2 The Logic of Compound Statements
Because, if Zeus were human, then by (1) he would be mortal.
But by (2) he is not mortal.
Hence, Zeus cannot be human.
Modus tollens is Latin meaning “method of denying” (the conclusion is a denial). The validity of modus tollens can be shown to follow from modus ponens together with the fact that a conditional statement is logically equivalent to its contrapositive. Or it can be established formally by using a truth table. (See exercise 13.)
Studies by cognitive psychologists have shown that although nearly 100% of college students have a solid, intuitive understanding of modus ponens, less than 60% are able to apply modus tollens correctly.∗ Yet in mathematical reasoning, modus tollens is used almost as often as modus ponens. Thus it is important to study the form of modus tollens carefully to learn to use it effectively.
Example 2.3.2 Recognizing Modus Ponens and Modus Tollens
Use modus ponens or modus tollens to fill in the blanks of the following arguments so that they become valid inferences.
a. If there are more pigeons than there are pigeonholes, then at least two pigeons roost in the same hole. There are more pigeons than there are pigeonholes. ∴ .
b. If 870,232 is divisible by 6, then it is divisible by 3. 870,232 is not divisible by 3. ∴ .
Solution
a. At least two pigeons roost in the same hole. by modus ponens
b. 870,232 is not divisible by 6. by modus tollens ■
Additional Valid Argument Forms: Rules of Inference A rule of inference is a form of argument that is valid. Thus modus ponens and modus tollens are both rules of inference. The following are additional examples of rules of inference that are frequently used in deductive reasoning.
Example 2.3.3 Generalization
The following argument forms are valid: a. p ∴ p ∨ q
b. q ∴ p ∨ q
These argument forms are used for making generalizations. For instance, according to the first, if p is true, then, more generally, “p or q” is true for any other statement q. As an example, suppose you are given the job of counting the upperclassmen at your school. You ask what class Anton is in and are told he is a junior.
∗Cognitive Psychology and Its Implications, 3d ed. by John R. Anderson (New York: Freeman, 1990), pp. 292–297.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.3 Valid and Invalid Arguments 55
You reason as follows:
Anton is a junior.
∴ (more generally) Anton is a junior or Anton is a senior. Knowing that upperclassman means junior or senior, you add Anton to your list. ■
Example 2.3.4 Specialization
The following argument forms are valid: a. p ∧ q ∴ p
b. p ∧ q ∴ q
These argument forms are used for specializing. When classifying objects according to some property, you often know much more about them than whether they do or do not have that property. When this happens, you discard extraneous information as you con- centrate on the particular property of interest.
For instance, suppose you are looking for a person who knows graph algorithms to work with you on a project. You discover that Ana knows both numerical analysis and graph algorithms. You reason as follows:
Ana knows numerical analysis and Ana knows graph algorithms.
∴ (in particular) Ana knows graph algorithms. Accordingly, you invite her to work with you on your project. ■
Both generalization and specialization are used frequently in mathematics to tailor facts to fit into hypotheses of known theorems in order to draw further conclusions. Elim- ination, transitivity, and proof by division into cases are also widely used tools.
Example 2.3.5 Elimination
The following argument forms are valid:
a. p ∨ q ∼q
∴ p
b. p ∨ q ∼p
∴ q These argument forms say that when you have only two possibilities and you can rule one out, the other must be the case. For instance, suppose you know that for a particular number x ,
x − 3 = 0 or x + 2 = 0. If you also know that x is not negative, then x �= −2, so
x + 2 �= 0. By elimination, you can then conclude that
∴ x − 3 = 0. ■ Example 2.3.6 Transitivity
The following argument form is valid:
p→ q q → r
∴ p→ r
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
56 Chapter 2 The Logic of Compound Statements
Many arguments in mathematics contain chains of if-then statements. From the fact that one statement implies a second and the second implies a third, you can conclude that the first statement implies the third. Here is an example:
If 18,486 is divisible by 18, then 18,486 is divisible by 9.
If 18,486 is divisible by 9, then the sum of the digits of 18,486 is divisible by 9.
∴ If 18,486 is divisible by 18, then the sum of the digits of 18,486 is divisible by 9. ■
Example 2.3.7 Proof by Division into Cases
The following argument form is valid:
p ∨ q p→ r q → r
∴ r It often happens that you know one thing or another is true. If you can show that in either case a certain conclusion follows, then this conclusion must also be true. For instance, suppose you know that x is a particular nonzero real number. The trichotomy property of the real numbers says that any number is positive, negative, or zero. Thus (by elimination) you know that x is positive or x is negative. You can deduce that x2 > 0 by arguing as follows:
x is positive or x is negative.
If x is positive, then x2 > 0.
If x is negative, then x2 > 0.
∴ x2 > 0. ■
The rules of valid inference are used constantly in problem solving. Here is an example from everyday life.
Example 2.3.8 Application: A More Complex Deduction
You are about to leave for school in the morning and discover that you don’t have your glasses. You know the following statements are true:
a. If I was reading the newspaper in the kitchen, then my glasses are on the kitchen table.
b. If my glasses are on the kitchen table, then I saw them at breakfast.
c. I did not see my glasses at breakfast.
d. I was reading the newspaper in the living room or I was reading the newspaper in the kitchen.
e. If I was reading the newspaper in the living room then my glasses are on the coffee table.
Where are the glasses?
Solution Let RK = I was reading the newspaper in the kitchen. GK = My glasses are on the kitchen table. SB = I saw my glasses at breakfast. RL = I was reading the newspaper in the living room. GC = My glasses are on the coffee table.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.3 Valid and Invalid Arguments 57
Here is a sequence of steps you might use to reach the answer, together with the rules of inference that allow you to draw the conclusion of each step:
1. RK → GK by (a) GK → SB by (d)
∴ RK → SB by transitivity 2. RK → SB by the conclusion of (1)
∼SB by (c) ∴ ∼RK by modus tollens
3. RL ∨ RK by (d) ∼RK by the conclusion of (2)
∴ RL by elimination 4. RL→ GC by (e)
RL by the conclusion of (3)
∴ GC by modus ponens
Thus the glasses are on the coffee table. ■
Fallacies A fallacy is an error in reasoning that results in an invalid argument. Three common fallacies are using ambiguous premises, and treating them as if they were unambiguous, circular reasoning (assuming what is to be proved without having derived it from the premises), and jumping to a conclusion (without adequate grounds). In this section we discuss two other fallacies, called converse error and inverse error, which give rise to arguments that superficially resemble those that are valid by modus ponens and modus tollens but are not, in fact, valid.
As in previous examples, you can show that an argument is invalid by constructing a truth table for the argument form and finding at least one critical row in which all the premises are true but the conclusion is false. Another way is to find an argument of the same form with true premises and a false conclusion.
For an argument to be valid, every argument of the same form whose premises are all true must have a true conclusion. It follows that for an argument to be invalid means that there is an argument of that form whose premises are all true and whose conclusion is false.
Example 2.3.9 Converse Error
Show that the following argument is invalid:
If Zeke is a cheater, then Zeke sits in the back row.
Zeke sits in the back row.
∴ Zeke is a cheater. Solution Many people recognize the invalidity of the above argument intuitively, reasoning
something like this: The first premise gives information about Zeke if it is known he is a cheater. It doesn’t give any information about him if it is not already known that he is a cheater. One can certainly imagine a person who is not a cheater but happens to sit in the
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
58 Chapter 2 The Logic of Compound Statements
back row. Then if that person’s name is substituted for Zeke, the first premise is true by default and the second premise is also true but the conclusion is false.
The general form of the previous argument is as follows:
p→ q q
∴ p
In exercise 12(a) at the end of this section you are asked to use a truth table to show that this form of argument is invalid. ■
The fallacy underlying this invalid argument form is called the converse error because the conclusion of the argument would follow from the premises if the premise p→ q were replaced by its converse. Such a replacement is not allowed, however, because a conditional statement is not logically equivalent to its converse. Converse error is also known as the fallacy of affirming the consequent.
Another common error in reasoning is called the inverse error.
Example 2.3.10 Inverse Error
Consider the following argument:
If interest rates are going up, stock market prices will go down.
Interest rates are not going up.
∴ Stock market prices will not go down.
Note that this argument has the following form:
p→ q ∼p
∴ ∼q You are asked to give a truth table verification of the invalidity of this argument form in exercise 12(b) at the end of this section.
The fallacy underlying this invalid argument form is called the inverse error because the conclusion of the argument would follow from the premises if the premise p→ q were replaced by its inverse. Such a replacement is not allowed, however, because a conditional statement is not logically equivalent to its inverse. Inverse error is also known as the fallacy of denying the antecedent. ■
! Caution! In logic, the words true and valid have very different meanings. A valid argument may have a false conclusion, and an invalid argument may have a true conclusion.
Sometimes people lump together the ideas of validity and truth. If an argument seems valid, they accept the conclusion as true. And if an argument seems fishy (really a slang expression for invalid), they think the conclusion must be false. This is not correct!
Example 2.3.11 A Valid Argument with a False Premise and a False Conclusion
The argument below is valid by modus ponens. But its major premise is false, and so is its conclusion.
If John Lennon was a rock star, then John Lennon had red hair.
John Lennon was a rock star.
∴ John Lennon had red hair. ■
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.3 Valid and Invalid Arguments 59
Example 2.3.12 An Invalid Argument with True Premises and a True Conclusion
The argument below is invalid by the converse error, but it has a true conclusion.
If New York is a big city, then New York has tall buildings.
New York has tall buildings.
∴ New York is a big city. ■
• Definition An argument is called sound if, and only if, it is valid and all its premises are true. An argument that is not sound is called unsound.
The important thing to note is that validity is a property of argument forms: If an argument is valid, then so is every other argument that has the same form. Similarly, if an argument is invalid, then so is every other argument that has the same form. What characterizes a valid argument is that no argument whose form is valid can have all true premises and a false conclusion. For each valid argument, there are arguments of that form with all true premises and a true conclusion, with at least one false premise and a true conclusion, and with at least one false premise and a false conclusion. On the other hand, for each invalid argument, there are arguments of that form with every combination of truth values for the premises and conclusion, including all true premises and a false conclusion. The bottom line is that we can only be sure that the conclusion of an argument is true when we know that the argument is sound, that is, when we know both that the argument is valid and that it has all true premises.
Contradictions and Valid Arguments The concept of logical contradiction can be used to make inferences through a technique of reasoning called the contradiction rule. Suppose p is some statement whose truth you wish to deduce.
Contradiction Rule
If you can show that the supposition that statement p is false leads logically to a contradiction, then you can conclude that p is true.
Example 2.3.13 Contradiction Rule
Show that the following argument form is valid:
∼p→ c, where c is a contradiction ∴ p
Solution Construct a truth table for the premise and the conclusion of this argument. premises conclusion
p ∼p c ∼p → c p T F F T T
→
There is only one critical row in which the premise is true, and in this row the conclusion is also true. Hence this form of argument is valid.F T F F ■
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
60 Chapter 2 The Logic of Compound Statements
The contradiction rule is the logical heart of the method of proof by contradiction. A slight variation also provides the basis for solving many logical puzzles by eliminating contradictory answers: If an assumption leads to a contradiction, then that assumption must be false.
Example 2.3.14 Knights and Knaves
The logician Raymond Smullyan describes an island containing two types of people: knights who always tell the truth and knaves who always lie.∗ You visit the island and are approached by two natives who speak to you as follows:
A says: B is a knight.
B says: A and I are of opposite type.
What are A and B?
Solution A and B are both knaves. To see this, reason as follows: Suppose A is a knight.
∴ What A says is true. by definition of knight
In di
an a
U ni
ve rs
it y
A rc
hi ve
s
Raymond Smullyan (born 1919)
∴ B is also a knight. That’s what A said. ∴ What B says is true. by definition of knight ∴ A and B are of opposite types. That’s what B said. ∴ We have arrived at the following contradiction: A and B are both knights and A and B are of opposite type.
∴ The supposition is false. by the contradiction rule ∴ A is not a knight. negation of supposition ∴ A is a knave. by elimination: It’s given that all inhabitants
are knights or knaves, so since A is not a knight, A is a knave.
∴ What A says is false. ∴ B is not a knight. ∴ B is also a knave. by elimination
This reasoning shows that if the problem has a solution at all, then A and B must both be knaves. It is conceivable, however, that the problem has no solution. The problem statement could be inherently contradictory. If you look back at the solution, though, you can see that it does work out for both A and B to be knaves. ■
Summary of Rules of Inference Table 2.3.1 summarizes some of the most important rules of inference.
∗Raymond Smullyan has written a delightful series of whimsical yet profound books of logical puzzles starting withWhat Is the Name of This Book? (Englewood Cliffs, New Jersey: Prentice-Hall, 1978). Other good sources of logical puzzles are the many excellent books of Martin Gardner, such as Aha! Insight and Aha! Gotcha (New York: W. H. Freeman, 1978, 1982).
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.3 Valid and Invalid Arguments 61
Table 2.3.1 Valid Argument Forms
Modus Ponens p→ q Elimination a. p ∨ q b. p ∨ q p ∼q ∼p
∴ q ∴ p ∴ q Modus Tollens p→ q Transitivity p→ q
∼q q → r ∴ ∼p ∴ p→ r
Generalization a. p b. q Proof by p ∨ q ∴ p ∨ q ∴ p ∨ q Division into Cases p→ r
Specialization a. p ∧ q b. p ∧ q q → r ∴ p ∴ q ∴ r
Conjunction p Contradiction Rule ∼p→ c q ∴ p
∴ p ∧ q
Test Yourself 1. For an argument to be valid means that every argument of
the same form whose premises has a conclusion.
2. For an argument to be invalid means that there is an argument of the same form whose premises and whose conclu- sion .
3. For an argument to be sound means that it is and its premises . In this case we can be sure that its conclu- sion .
Exercise Set 2.3 Use modus ponens or modus tollens to fill in the blanks in the arguments of 1–5 so as to produce valid inferences.
1. If √ 2 is rational, then
√ 2 = a/b for some integers a
and b. It is not true that
√ 2 = a/b for some integers a and b.
∴ .
2. If 1− 0.99999 . . . is less than every positive real number, then it equals zero.
. ∴ The number 1− 0.99999 . . . equals zero.
3. If logic is easy, then I am a monkey’s uncle. I am not a monkey’s uncle.
∴ .
4. If this figure is a quadrilateral, then the sum of its interior angles is 360◦. The sum of the interior angles of this figure is not 360◦.
∴ .
5. If they were unsure of the address, then they would have telephoned.
. ∴ They were sure of the address.
Use truth tables to determine whether the argument forms in 6– 11 are valid. Indicate which columns represent the premises and which represent the conclusion, and include a sentence explain- ing how the truth table supports your answer. Your explanation should show that you understand what it means for a form of argument to be valid or invalid.
6. p→ q q → p
∴ p ∨ q
7. p p→ q ∼q ∨ r
∴ r
8. p ∨ q p→∼q p→ r
∴ r
9. p ∧ q →∼r p ∨ ∼q ∼q → p
∴ ∼r
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
62 Chapter 2 The Logic of Compound Statements
10. p→ r q → r
∴ p ∨ q → r
11. p→ q ∨ r ∼q ∨ ∼r
∴ ∼p ∨ ∼r 12. Use truth tables to show that the following forms of argu-
ment are invalid. a. p→ q
q ∴ p (converse error)
b. p→ q ∼p
∴ ∼q (inverse error)
Use truth tables to show that the argument forms referred to in 13–21 are valid. Indicate which columns represent the premises and which represent the conclusion, and include a sen- tence explaining how the truth table supports your answer. Your explanation should show that you understand what it means for a form of argument to be valid.
13. Modus tollens: p→ q ∼q
∴ ∼p 14. Example 2.3.3(a) 15. Example 2.3.3(b)
16. Example 2.3.4(a) 17. Example 2.3.4(b)
18. Example 2.3.5(a) 19. Example 2.3.5(b)
20. Example 2.3.6 21. Example 2.3.7
Use symbols to write the logical form of each argument in 22 and 23, and then use a truth table to test the argument for valid- ity. Indicate which columns represent the premises and which represent the conclusion, and include a few words of explana- tion showing that you understand the meaning of validity.
22. If Tom is not on team A, then Hua is on team B. If Hua is not on team B, then Tom is on team A.
∴ Tom is not on team A or Hua is not on team B.
23. Oleg is a math major or Oleg is an economics major. If Oleg is a math major, then Oleg is required to take Math 362.
∴ Oleg is an economics major or Oleg is not required to take Math 362.
Some of the arguments in 24–32 are valid, whereas others exhibit the converse or the inverse error. Use symbols to write the logical form of each argument. If the argument is valid, iden- tify the rule of inference that guarantees its validity. Otherwise, state whether the converse or the inverse error is made.
24. If Jules solved this problem correctly, then Jules obtained the answer 2. Jules obtained the answer 2.
∴ Jules solved this problem correctly.
25. This real number is rational or it is irrational. This real number is not rational.
∴ This real number is irrational.
26. If I go to the movies, I won’t finish my homework. If I don’t finish my homework, I won’t do well on the
exam tomorrow. ∴ If I go to the movies, I won’t do well on the exam
tomorrow.
27. If this number is larger than 2, then its square is larger than 4. This number is not larger than 2.
∴ The square of this number is not larger than 4.
28. If there are as many rational numbers as there are irrational numbers, then the set of all irrational numbers is infinite. The set of all irrational numbers is infinite.
∴ There are as many rational numbers as there are irrational numbers.
29. If at least one of these two numbers is divisible by 6, then the product of these two numbers is divisible by 6. Neither of these two numbers is divisible by 6.
∴ The product of these two numbers is not divisible by 6.
30. If this computer program is correct, then it produces the correct output when run with the test data my teacher gave me. This computer program produces the correct output when run with the test data my teacher gave me. ∴ This computer program is correct.
31. Sandra knows Java and Sandra knows C++. ∴ Sandra knows C++.
32. If I get a Christmas bonus, I’ll buy a stereo. If I sell my motorcycle, I’ll buy a stereo.
∴ If I get a Christmas bonus or I sell my motorcycle, then I’ll buy a stereo.
33. Give an example (other than Example 2.3.11) of a valid argument with a false conclusion.
34. Give an example (other than Example 2.3.12) of an invalid argument with a true conclusion.
35. Explain in your own words what distinguishes a valid form of argument from an invalid one.
36. Given the following information about a computer pro- gram, find the mistake in the program. a. There is an undeclared variable or there is a syntax error
in the first five lines. b. If there is a syntax error in the first five lines, then there
is a missing semicolon or a variable name is misspelled. c. There is not a missing semicolon. d. There is not a misspelled variable name.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.3 Valid and Invalid Arguments 63
37. In the back of an old cupboard you discover a note signed by a pirate famous for his bizarre sense of humor and love of logical puzzles. In the note he wrote that he had hidden treasure somewhere on the property. He listed five true statements (a–e below) and challenged the reader to use them to figure out the location of the treasure. a. If this house is next to a lake, then the treasure is not in
the kitchen. b. If the tree in the front yard is an elm, then the treasure is
in the kitchen. c. This house is next to a lake. d. The tree in the front yard is an elm or the treasure is
buried under the flagpole. e. If the tree in the back yard is an oak, then the treasure is
in the garage. Where is the treasure hidden?
38. You are visiting the island described in Example 2.3.14 and have the following encounters with natives. a. Two natives A and B address you as follows:
A says: Both of us are knights. B says: A is a knave. What are A and B?
b. Another two natives C and D approach you but only C speaks. C says: Both of us are knaves. What are C and D?
c. You then encounter natives E and F . E says: F is a knave. F says: E is a knave. How many knaves are there?
d.H Finally, you meet a group of six natives, U, V,W, X, Y , and Z , who speak to you as follows: U says: None of us is a knight. V says: At least three of us are knights. W says: At most three of us are knights. X says: Exactly five of us are knights. Y says: Exactly two of us are knights. Z says: Exactly one of us is a knight. Which are knights and which are knaves?
39. The famous detective Percule Hoirot was called in to solve a baffling murder mystery. He determined the following facts: a. Lord Hazelton, the murdered man, was killed by a blow
on the head with a brass candlestick. b. Either Lady Hazelton or a maid, Sara, was in the dining
room at the time of the murder.
c. If the cook was in the kitchen at the time of the murder, then the butler killed Lord Hazelton with a fatal dose of strychnine.
d. If Lady Hazelton was in the dining room at the time of the murder, then the chauffeur killed Lord Hazelton.
e. If the cook was not in the kitchen at the time of the mur- der, then Sara was not in the dining room when the mur- der was committed.
f. If Sara was in the dining room at the time the murder was committed, then the wine steward killed Lord Hazelton.
Is it possible for the detective to deduce the identity of the murderer from these facts? If so, who did murder Lord Hazelton? (Assume there was only one cause of death.)
40. Sharky, a leader of the underworld, was killed by one of his own band of four henchmen. Detective Sharp interviewed the men and determined that all were lying except for one. He deduced who killed Sharky on the basis of the following statements: a. Socko: Lefty killed Sharky. b. Fats: Muscles didn’t kill Sharky. c. Lefty: Muscles was shooting craps with Socko when
Sharky was knocked off. d. Muscles: Lefty didn’t kill Sharky. Who did kill Sharky?
In 41–44 a set of premises and a conclusion are given. Use the valid argument forms listed in Table 2.3.1 to deduce the con- clusion from the premises, giving a reason for each step as in Example 2.3.8. Assume all variables are statement variables.
41. a. ∼p ∨ q → r b. s ∨ ∼q c. ∼t d. p→ t e. ∼p ∧ r →∼s f. ∴ ∼q
42. a. p ∨ q b. q → r c. p ∧ s → t d. ∼r e. ∼q → u ∧ s f. ∴ t
43. a. ∼p→ r ∧ ∼s b. t → s c. u →∼p d. ∼w e. u ∨ w f. ∴ ∼t
44. a. p→ q b. r ∨ s c. ∼s →∼t d. ∼q ∨ s e. ∼s f. ∼p ∧ r → u g. w ∨ t h. ∴ u ∧ w
Answers for Test Yourself 1. are all true; true 2. are all true; is false 3. valid; are all true; is true
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
64 Chapter 2 The Logic of Compound Statements
2.4 Application: Digital Logic Circuits Only connect! — E. M. Forster, Howards End
In the late 1930s, a young M.I.T. graduate student named Claude Shannon noticed an M
IT M
us eu
m
Claude Shannon (1916–2001)
analogy between the operations of switching devices, such as telephone switching circuits, and the operations of logical connectives. He used this analogy with striking success to solve problems of circuit design and wrote up his results in his master’s thesis, which was published in 1938.
The drawing in Figure 2.4.1(a) shows the appearance of the two positions of a simple switch. When the switch is closed, current can flow from one terminal to the other; when it is open, current cannot flow. Imagine that such a switch is part of the circuit shown in Figure 2.4.1(b). The light bulb turns on if, and only if, current flows through it. And this happens if, and only if, the switch is closed.
Open Closed
The symbol denotes a battery and the symbol
denotes a light bulb.
(a) (b)
Figure 2.4.1
Now consider the more complicated circuits of Figures 2.4.2(a) and 2.4.2(b).
P Q Q
P
Switches “in series” Switches “in parallel”
(a) (b)
Figure 2.4.2
In the circuit of Figure 2.4.2(a) current flows and the light bulb turns on if, and only if, both switches P and Q are closed. The switches in this circuit are said to be in series. In the circuit of Figure 2.4.2(b) current flows and the light bulb turns on if, and only if, at least one of the switches P or Q is closed. The switches in this circuit are said to be in parallel. All possible behaviors of these circuits are described by Table 2.4.1.
Table 2.4.1
(a) Switches in Series (b) Switches in Parallel
Switches Light Bulb
P Q State
closed closed on
closed open off
open closed off
open open off
Switches Light Bulb
P Q State
closed closed on
closed open on
open closed on
open open off
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.4 Application: Digital Logic Circuits 65
Observe that if the words closed and on are replaced by T and open and off are replaced by F, Table 2.4.1(a) becomes the truth table for and and Table 2.4.1(b) becomes the truth table for or. Consequently, the switching circuit of Figure 2.4.2(a) is said to cor- respond to the logical expression P ∧ Q, and that of Figure 2.4.2(b) is said to correspond to P ∨ Q.
More complicated circuits correspond to more complicated logical expressions. This correspondence has been used extensively in the design and study of circuits.
In the 1940s and 1950s, switches were replaced by electronic devices, with the physical states of closed and open corresponding to electronic states such as high and low voltages. The new electronic technology led to the development of modern digi- tal systems such as electronic computers, electronic telephone switching systems, traffic light controls, electronic calculators, and the control mechanisms used in hundreds of other types of electronic equipment. The basic electronic components of a digital system are called digital logic circuits. The word logic indicates the important role of logic in the design of such circuits, and the word digital indicates that the circuits process discrete, or separate, signals as opposed to continuous ones.
C ou
rt es
y of
IB M
John W. Tukey (1915–2000)
The Intel 4004, introduced in 1971, is generally considered to be the first commercially viable microprocessor or central pro- cessing unit (CPU) contained on a chip about the size of a fingernail. It consisted of 2,300 transistors and could execute 70,000 instructions per second, essentially the same computing power as the first electronic computer, the ENIAC, built in 1946, which filled an entire room. Modern microprocessors consist of several CPUs on one chip, contain close to a billion transistors and many hundreds of millions of logic circuits, and can compute hundreds of millions of instructions per second. In
te l
Electrical engineers continue to use the language of logic when they refer to values of signals produced by an electronic switch as being “true” or “false.” But they generally use the symbols 1 and 0 rather than T and F to denote these values. The symbols 0 and 1 are called bits, short for binary digits. This terminology was introduced in 1946 by the statistician John Tukey.
Black Boxes and Gates Combinations of signal bits (1’s and 0’s) can be transformed into other combinations of signal bits (1’s and 0’s) by means of various circuits. Because a variety of different
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
66 Chapter 2 The Logic of Compound Statements
technologies are used in circuit construction, computer engineers and digital system designers find it useful to think of certain basic circuits as black boxes. The inside of a black box contains the detailed implementation of the circuit and is often ignored while attention is focused on the relation between the input and the output signals.
P Q R
S Input
signals Output signalblack box
The operation of a black box is completely specified by constructing an input/output table that lists all its possible input signals together with their corresponding output signals. For example, the black box pictured above has three input signals. Since each of these signals can take the value 1 or 0, there are eight possible combinations of input signals. One possible correspondence of input to output signals is as follows:
An Input/Output Table
Input Output
P Q R S
1 1 1 1
1 1 0 0
1 0 1 0
1 0 0 1
0 1 1 0
0 1 0 1
0 0 1 1
0 0 0 0
The third row, for instance, indicates that for inputs P = 1, Q = 0, and R = 1, the output S is 0.
An efficient method for designing more complicated circuits is to build them by con- necting less complicated black box circuits. Three such circuits are known as NOT-, AND-, and OR-gates.
A NOT-gate (or inverter) is a circuit with one input signal and one output signal. If the input signal is 1, the output signal is 0. Conversely, if the input signal is 0, then the output signal is 1. An AND-gate is a circuit with two input signals and one output signal. If both input signals are 1, then the output signal is 1. Otherwise, the output signal is 0. An OR-gate also has two input signals and one output signal. If both input signals are 0, then the output signal is 0. Otherwise, the output signal is 1.
The actions of NOT-, AND-, and OR-gates are summarized in Figure 2.4.3, where P and Q represent input signals and R represents the output signal. It should be clear from Figure 2.4.3 that the actions of the NOT-, AND-, and OR-gates on signals correspond exactly to those of the logical connectives ∼,∧, and ∨ on statements, if the symbol 1 is identified with T and the symbol 0 is identified with F.
Gates can be combined into circuits in a variety of ways. If the rules shown on the next page are obeyed, the result is a combinational circuit, one whose output at any time is determined entirely by its input at that time without regard to previous inputs.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.4 Application: Digital Logic Circuits 67
Type of Symbolic Gate Representation Action
NOT P RNOT
Input Output
P R
1 0
0 1
AND P
Q RAND
Input Output
P Q R
1 1 1
1 0 0
0 1 0
0 0 0
OR P
Q ROR
Input Output
P Q R
1 1 1
1 0 1
0 1 1
0 0 0
Figure 2.4.3
Rules for a Combinational Circuit
Never combine two input wires. 2.4.1
A single input wire can be split partway and used as input for two separate gates. 2.4.2
An output wire can be used as input. 2.4.3
No output of a gate can eventually feed back into that gate. 2.4.4
Rule (2.4.4) is violated in more complex circuits, called sequential circuits, whose output at any given time depends both on the input at that time and also on previous inputs. These circuits are discussed in Section 12.2.
The Input/Output Table for a Circuit If you are given a set of input signals for a circuit, you can find its output by tracing through the circuit gate by gate.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
68 Chapter 2 The Logic of Compound Statements
Example 2.4.1 Determining Output for a Given Input
Indicate the output of the circuits shown below for the given input signals.
a.
P
Q
RAND NOT
Input signals: P = 0 and Q = 1
b.
P
Q
R SAND
OR NOT
Input signals: P = 1, Q = 0, R = 1
Solution
a. Move from left to right through the diagram, tracing the action of each gate on the input signals. The NOT-gate changes P = 0 to a 1, so both inputs to the AND-gate are 1; hence the output R is 1. This is illustrated by annotating the diagram as shown below.
P
Q
NOT RAND
0 1 1
1
b. The output of the OR-gate is 1 since one of the input signals, P , is 1. The NOT-gate changes this 1 into a 0, so the two inputs to the AND-gate are 0 and R = 1. Hence the output S is 0. The trace is shown below.
P
Q
R SAND
OR NOT
1
1
1 0
0
0
■
To construct the entire input/output table for a circuit, trace through the circuit to find the corresponding output signals for each possible combination of input signals.
Example 2.4.2 Constructing the Input/Output Table for a Circuit
Construct the input/output table for the following circuit.
P
Q
ROR
NOT
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.4 Application: Digital Logic Circuits 69
Solution List the four possible combinations of input signals, and find the output for each by tracing through the circuit.
C O
R B
IS
George Boole (1815–1864)
Input Output
P Q R
1 1 1
1 0 1
0 1 0
0 0 1 ■
The Boolean Expression Corresponding to a Circuit In logic, variables such as p, q and r represent statements, and a statement can have one of only two truth values: T (true) or F (false). A statement form is an expression, such as p ∧ (∼q ∨ r), composed of statement variables and logical connectives.
As noted earlier, one of the founders of symbolic logic was the English mathemati- cian George Boole. In his honor, any variable, such as a statement variable or an input signal, that can take one of only two values is called a Boolean variable. An expres- sion composed of Boolean variables and the connectives ∼,∧, and ∨ is called a Boolean expression.
Note Strictly speaking, only meaningful expressions such as (∼p ∧ q) ∨ (p ∧ r) and ∼(∼(p ∧ q) ∨ r) are allowed as Boolean, not meaningless ones like p ∼q((rs ∨ ∧ q ∼. We use recursion to give a careful definition of Boolean expressions in Section 5.9.
Given a circuit consisting of combined NOT-, AND-, and OR-gates, a correspond- ing Boolean expression can be obtained by tracing the actions of the gates on the input variables.
Example 2.4.3 Finding a Boolean Expression for a Circuit
Find the Boolean expressions that correspond to the circuits shown below. A dot indicates a soldering of two wires; wires that cross without a dot are assumed not to touch.
P
Q
R
P
Q AND OR
NOTAND NOT
AND
(a) (b)
AND
Solution
a. Trace through the circuit from left to right, indicating the output of each gate symbol- ically, as shown below.
P
Q
P ∧ Q
P ∨ Q
~(P ∧ Q)
(P ∨ Q) ∧ ~(P ∧ Q)
NOT
AND
AND
OR
The final expression obtained, (P ∨ Q)∧ ∼(P ∧ Q), is the expression for exclusive or: P or Q but not both.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
70 Chapter 2 The Logic of Compound Statements
b. The Boolean expression corresponding to the circuit is (P ∧ Q)∧ ∼R, as shown below.
P
Q
R
P ∧ Q ~R
(P ∧ Q) ∧~RAND AND
NOT
■
Observe that the output of the circuit shown in Example 2.4.3(b) is 1 for exactly one combination of inputs (P = 1, Q = 1, and R = 0) and is 0 for all other combinations of inputs. For this reason, the circuit can be said to “recognize” one particular combination of inputs. The output column of the input/output table has a 1 in exactly one row and 0’s in all other rows.
• Definition A recognizer is a circuit that outputs a 1 for exactly one particular combination of input signals and outputs 0’s for all other combinations.
Input/Output Table for a Recognizer
P Q R (P ∧ Q)∧ ∼R 1 1 1 0
1 1 0 1
1 0 1 0
1 0 0 0
0 1 1 0
0 1 0 0
0 0 1 0
0 0 0 0
The Circuit Corresponding to a Boolean Expression The preceding examples showed how to find a Boolean expression corresponding to a cir- cuit. The following example shows how to construct a circuit corresponding to a Boolean expression.
Example 2.4.4 Constructing Circuits for Boolean Expressions
Construct circuits for the following Boolean expressions.
a. (∼P ∧ Q)∨ ∼Q b. ((P ∧ Q) ∧ (R ∧ S)) ∧ T Solution
a. Write the input variables in a column on the left side of the diagram. Then go from the right side of the diagram to the left, working from the outermost part of the expression to the innermost part. Since the last operation executed when evaluating (∼P ∧ Q)∨ ∼Q is ∨, put an OR-gate at the extreme right of the diagram. One input to this gate is ∼P ∧ Q, so draw an AND-gate to the left of the OR-gate and show its
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.4 Application: Digital Logic Circuits 71
output coming into the OR-gate. Since one input to the AND-gate is ∼P , draw a line from P to a NOT-gate and from there to the AND-gate. Since the other input to the AND-gate is Q, draw a line from Q directly to the AND-gate. The other input to the OR-gate is ∼Q, so draw a line from Q to a NOT-gate and from the NOT-gate to the OR-gate. The circuit you obtain is shown below.
P
Q AND
NOT
OR
NOT
b. To start constructing this circuit, put one AND-gate at the extreme right for the ∧ between ((P ∧ Q) ∧ (R ∧ S)) and T . To the left of that put the AND-gate corre- sponding to the ∧ between P ∧ Q and R ∧ S. To the left of that put the AND-gates corresponding to the ∧’s between P and Q and between R and S. The circuit is shown in Figure 2.4.4.
P
Q
R
S
T
AND AND
AND
AND
Figure 2.4.4 ■
It follows from Theorem 2.1.1 that all the ways of adding parentheses to P ∧ Q ∧ R ∧ S ∧ T are logically equivalent. Thus, for example,
((P ∧ Q) ∧ (R ∧ S)) ∧ T ≡ (P ∧ (Q ∧ R)) ∧ (S ∧ T ). It also follows that the circuit in Figure 2.4.5, which corresponds to (P ∧ (Q ∧ R)) ∧ (S ∧ T ), has the same input/output table as the circuit in Figure 2.4.4, which corresponds to ((P ∧ Q) ∧ (R ∧ S)) ∧ T .
P
Q
R
S
T
AND AND AND
AND
Figure 2.4.5
Each of the circuits in Figures 2.4.4 and 2.4.5 is, therefore, an implementation of the expression P ∧ Q ∧ R ∧ S ∧ T . Such a circuit is called amultiple-input AND-gate and is represented by the diagram shown in Figure 2.4.6. Multiple-input OR-gates are constructed similarly.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
72 Chapter 2 The Logic of Compound Statements
P
Q
R
S
T
AND
Figure 2.4.6
Finding a Circuit That Corresponds to a Given Input/Output Table
To this point, we have discussed how to construct the input/output table for a circuit, how to find the Boolean expression corresponding to a given circuit, and how to construct the circuit corresponding to a given Boolean expression. Now we address the question of how to design a circuit (or find a Boolean expression) corresponding to a given input/output table. The way to do this is to put several recognizers together in parallel.
Example 2.4.5 Designing a Circuit for a Given Input/Output Table
Design a circuit for the following input/output table:
Input Output
P Q R S
1 1 1 1
1 1 0 0
1 0 1 1
1 0 0 1
0 1 1 0
0 1 0 0
0 0 1 0
0 0 0 0
Solution First construct a Boolean expression with this table as its truth table. To do this, identify each row for which the output is 1—in this case, the first, third, and fourth rows. For each such row, construct an and expression that produces a 1 (or true) for the exact combination of input values for that row and a 0 (or false) for all other combinations of input values. For example, the expression for the first row is P ∧ Q ∧ R because P ∧ Q ∧ R is 1 if P = 1 and Q = 1 and R = 1, and it is 0 for all other values of P, Q, and R. The expression for the third row is P ∧ ∼Q ∧ R because P ∧ ∼Q ∧ R is 1 if P = 1 and Q = 0 and R = 1, and it is 0 for all other values of P, Q, and R. Similarly, the expression for the fourth row is P ∧ ∼Q ∧ ∼R.
Now any Boolean expression with the given table as its truth table has the value 1 in case P ∧ Q ∧ R = 1, or in case P ∧ ∼Q ∧ R = 1, or in case P ∧ ∼Q ∧ ∼R = 1, and in no other cases. It follows that a Boolean expression with the given truth table is
(P ∧ Q ∧ R) ∨ (P ∧ ∼Q ∧ R) ∨ (P ∧ ∼Q ∧ ∼R). 2.4.5 The circuit corresponding to this expression has the diagram shown in Figure 2.4.7. Observe that expression (2.4.5) is a disjunction of terms that are themselves conjunc- tions in which one of P or ∼P , one of Q or ∼Q, and one of R or ∼R all appear. Such expressions are said to be in disjunctive normal form or sum-of-products form.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.4 Application: Digital Logic Circuits 73
AND P Q R
AND
NOT
NOT
ANDNOT
OR
Figure 2.4.7 ■
Simplifying Combinational Circuits Consider the two combinational circuits shown in Figure 2.4.8.
R
AND P
Q NOT OR
AND
AND
R
P
Q
(a)
(b)
AND
Figure 2.4.8
If you trace through circuit (a), you will find that its input/output table is
Input Output
P Q R
1 1 1
1 0 0
0 1 0
0 0 0
which is the same as the input/output table for circuit (b). Thus these two circuits do the same job in the sense that they transform the same combinations of input signals
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
74 Chapter 2 The Logic of Compound Statements
into the same output signals. Yet circuit (b) is simpler than circuit (a) in that it contains many fewer logic gates. Thus, as part of an integrated circuit, it would take less space and require less power.
• Definition Two digital logic circuits are equivalent if, and only if, their input/output tables are identical.
Since logically equivalent statement forms have identical truth tables, you can determine that two circuits are equivalent by finding the Boolean expressions corresponding to the circuits and showing that these expressions, regarded as statement forms, are logically equivalent. Example 2.4.6 shows how this procedure works for cir- cuits (a) and (b) in Figure 2.4.8.
Example 2.4.6 Showing That Two Circuits Are Equivalent
Find the Boolean expressions for each circuit in Figure 2.4.8. Use Theorem 2.1.1 to show that these expressions are logically equivalent when regarded as statement forms.
Solution The Boolean expressions that correspond to circuits (a) and (b) are ((P ∧ ∼Q) ∨ (P ∧ Q)) ∧ Q and P ∧ Q, respectively. By Theorem 2.1.1,
((P ∧ ∼Q) ∨ (P ∧ Q)) ∧ Q ≡ (P ∧ (∼Q ∨ Q)) ∧ Q by the distributive law ≡ (P ∧ (Q ∨ ∼Q)) ∧ Q by the commutative law for ∨ ≡ (P ∧ t) ∧ Q by the negation law ≡ P ∧ Q by the identity law.
It follows that the truth tables for ((P ∧ ∼Q) ∨ (P ∧ Q)) ∧ Q and P ∧ Q are the same. Hence the input/output tables for the circuits corresponding to these expressions are also the same, and so the circuits are equivalent. ■
In general, you can simplify a combinational circuit by finding the corresponding Boolean expression, using the properties listed in Theorem 2.1.1 to find a Boolean expres- sion that is shorter and logically equivalent to it (when both are regarded as statement forms), and constructing the circuit corresponding to this shorter Boolean expression.
NAND and NOR Gates Another way to simplify a circuit is to find an equivalent circuit that uses the least number of different kinds of logic gates. Two gates not previously introduced are particularly
H ar
va rd
U ni
ve rs
it y
A rc
hi ve
s
H. M. Sheffer (1882–1964)
useful for this: NAND-gates and NOR-gates. A NAND-gate is a single gate that acts like an AND-gate followed by a NOT-gate. A NOR-gate acts like an OR-gate followed by a NOT-gate. Thus the output signal of a NAND-gate is 0 when, and only when, both input signals are 1, and the output signal for a NOR-gate is 1 when, and only when, both input signals are 0. The logical symbols corresponding to these gates are | (for NAND) and ↓ (for NOR), where | is called a Sheffer stroke (after H. M. Sheffer, 1882–1964) and ↓ is called a Peirce arrow (after C. S. Peirce, 1839–1914; see page 101). Thus
P | Q ≡ ∼(P ∧ Q) and P ↓ Q ≡ ∼(P ∨ Q).
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.4 Application: Digital Logic Circuits 75
The table below summarizes the actions of NAND and NOR gates.
Type of Gate Symbolic Representation Action
NAND P
Q NAND R
Input Output
P Q R = P | Q 1 1 0
1 0 1
0 1 1
0 0 1
NOR P
Q RNOR
Input Output
P Q R = P ↓ Q 1 1 0
1 0 0
0 1 0
0 0 1
It can be shown that any Boolean expression is equivalent to one written entirely with Sheffer strokes or entirely with Peirce arrows. Thus any digital logic circuit is equivalent to one that uses only NAND-gates or only NOR-gates. Example 2.4.7 develops part of the derivation of this result; the rest is left for the exercises.
Example 2.4.7 Rewriting Expressions Using the Sheffer Stroke
Use Theorem 2.1.1 and the definition of Sheffer stroke to show that
a. ∼P ≡ P | P and b. P ∨ Q ≡ (P | P) | (Q | Q). Solution
a. ∼P ≡ ∼(P ∧ P) by the idempotent law for ∧ ≡ P | P by definition of |.
b. P ∨ Q ≡ ∼(∼(P ∨ Q)) by the double negative law ≡ ∼(∼P ∧ ∼Q) by De Morgan’s laws ≡ ∼((P | P) ∧ (Q | Q)) by part (a) ≡ (P | P) | (Q | Q) by definition of |. ■
Test Yourself 1. The input/output table for a digital logic circuit is a table that
shows .
2. The Boolean expression that corresponds to a digital logic circuit is .
3. A recognizer is a digital logic circuit that .
4. Two digital logic circuits are equivalent if, and only if, .
5. A NAND-gate is constructed by placing a gate imme- diately following an gate.
6. A NOR-gate is constructed by placing a gate immedi- ately following an gate.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
76 Chapter 2 The Logic of Compound Statements
Exercise Set 2.4 Give the output signals for the circuits in 1–4 if the input signals are as indicated.
1. P
Q
ROR
NOT
input signals: P = 1 and Q = 1 2.
OR
NOT
P
RQ AND
input signals: P = 1 and Q = 0 3. P
Q
R
ORNOT AND
S
input signals: P = 1, Q = 0, R = 0 4. P
Q
R NOT
OR OR
AND
S
input signals: P = 0, Q = 0, R = 0
In 5–8, write an input/output table for the circuit in the refer- enced exercise.
5. Exercise 1 6. Exercise 2
7. Exercise 3 8. Exercise 4
In 9–12, find the Boolean expression that corresponds to the cir- cuit in the referenced exercise.
9. Exercise 1 10. Exercise 2
11. Exercise 3 12. Exercise 4
Construct circuits for the Boolean expressions in 13–17.
13. ∼P ∨ Q 14. ∼(P ∨ Q) 15. P ∨ (∼P ∧ ∼Q) 16. (P ∧ Q)∨ ∼R 17. (P ∧ ∼Q) ∨ (∼P ∧ R) For each of the tables in 18–21, construct (a) a Boolean expres- sion having the given table as its truth table and (b) a circuit having the given table as its input/output table.
18. P Q R S
1 1 1 0
1 1 0 1
1 0 1 0
1 0 0 0
0 1 1 1
0 1 0 0
0 0 1 0
0 0 0 0
19. P Q R S
1 1 1 0
1 1 0 1
1 0 1 0
1 0 0 1
0 1 1 0
0 1 0 1
0 0 1 0
0 0 0 0
20. P Q R S
1 1 1 1
1 1 0 0
1 0 1 1
1 0 0 0
0 1 1 0
0 1 0 0
0 0 1 0
0 0 0 1
21. P Q R S
1 1 1 0
1 1 0 1
1 0 1 0
1 0 0 0
0 1 1 1
0 1 0 1
0 0 1 0
0 0 0 0
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.4 Application: Digital Logic Circuits 77
22. Design a circuit to take input signals P, Q, and R and out- put a 1 if, and only if, P and Q have the same value and Q and R have opposite values.
23. Design a circuit to take input signals P , Q, and R and out- put a 1 if, and only if, all three of P, Q, and R have the same value.
24. The lights in a classroom are controlled by two switches: one at the back and one at the front of the room. Moving either switch to the opposite position turns the lights off if they are on and on if they are off. Assume the lights have been installed so that when both switches are in the down position, the lights are off. Design a circuit to control the switches.
25. An alarm system has three different control panels in three different locations. To enable the system, switches in at least two of the panels must be in the on position. If fewer than two are in the on position, the system is disabled. Design a circuit to control the switches.
Use the properties listed in Theorem 2.1.1 to show that each pair of circuits in 26–29 have the same input/output table. (Find the Boolean expressions for the circuits and show that they are logically equivalent when regarded as statement forms.)
26. a. P
Q OR AND
b. P
Q OR
AND
27. a. P
Q
AND
AND
NOT
NOT
b. P
Q NOTOR
28. a. P
Q
NOT
NOT
NOT
AND
AND
AND
OR
b. P
Q NOT OR
29. a. P
Q AND
AND OR NOT
AND NOT
b. P
Q OR
For the circuits corresponding to the Boolean expressions in each of 30 and 31 there is an equivalent circuit with at most two logic gates. Find such a circuit.
30. (P ∧ Q) ∨ (∼P ∧ Q) ∨ (∼P ∧ ∼Q) 31. (∼P ∧ ∼Q) ∨ (∼P ∧ Q) ∨ (P ∧ ∼Q) 32. The Boolean expression for the circuit in Example 2.4.5 is
(P ∧ Q ∧ R) ∨ (P ∧ ∼Q ∧ R) ∨ (P ∧ ∼Q ∧ ∼R) (a disjunctive normal form). Find a circuit with at most three logic gates that is equivalent to this circuit.
33. a. Show that for the Sheffer stroke |, P ∧ Q ≡ (P | Q) | (P | Q).
b. Use the results of Example 2.4.7 and part (a) above to write P ∧ (∼Q ∨ R) using only Sheffer strokes.
34. Show that the following logical equivalences hold for the Peirce arrow ↓, where P ↓ Q ≡ ∼(P ∨ Q). a. ∼P ≡ P ↓ P b. P ∨ Q ≡ (P ↓ Q) ↓ (P ↓ Q) c. P ∧ Q ≡ (P ↓ P) ↓ (Q ↓ Q) d.H Write P → Q using Peirce arrows only. e. Write P ↔ Q using Peirce arrows only.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
78 Chapter 2 The Logic of Compound Statements
Answers for Test Yourself 1. the output signal(s) that correspond to all possible combinations of input signals to the circuit 2. a Boolean expression that represents the input signals as variables and indicates the successive actions of the logic gates on the input signals 3. outputs a 1 for exactly one particular combination of input signals and outputs 0’s for all other combinations 4. they have the same input/output table 5. NOT; AND 6. NOT; OR
2.5 Application: Number Systems and Circuits for Addition Counting in binary is just like counting in decimal if you are all thumbs. —Glaser and Way
In elementary school, you learned the meaning of decimal notation: that to interpret a string of decimal digits as a number, you mentally multiply each digit by its place value. For instance, 5,049 has a 5 in the thousands place, a 0 in the hundreds place, a 4 in the tens place, and a 9 in the ones place. Thus
5,049 = 5 ·(1,000)+ 0 ·(100)+ 4 ·(10)+ 9 ·(1). Using exponential notation, this equation can be rewritten as
5,049 = 5 ·103 + 0 ·102 + 4 ·101 + 9 ·100. More generally, decimal notation is based on the fact that any positive integer can be written uniquely as a sum of products of the form
d ·10n, where each n is a nonnegative integer and each d is one of the decimal digits 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9. The word decimal comes from the Latin root deci,meaning “ten.” Decimal (or base 10) notation expresses a number as a string of digits in which each digit’s position indicates the power of 10 by which it is multiplied. The right-most position is the ones place (or 100 place), to the left of that is the tens place (or 101 place), to the left of that is the hundreds place (or 102 place), and so forth, as illustrated below.
Place 103 102 101 100
thousands hundreds tens ones
Decimal Digit 5 0 4 9
Binary Representation of Numbers There is nothing sacred about the number 10; we use 10 as a base for our usual number system because we happen to have ten fingers. In fact, any integer greater than 1 can serve as a base for a number system. In computer science, base 2 notation, or binary notation, is of special importance because the signals used in modern electronics are always in one of only two states. (The Latin root bi means “two.”)
In Section 5.4, we show that any integer can be represented uniquely as a sum of products of the form
d ·2n, where each n is an integer and each d is one of the binary digits (or bits) 0 or 1. For example,
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.5 Application: Number Systems and Circuits for Addition 79
27 = 16+ 8+ 2+ 1 = 1 ·24 + 1 ·23 + 0 ·22 + 1 ·21 + 1 ·20.
In binary notation, as in decimal notation, we write just the binary digits, and not the powers of the base. In binary notation, then,
1
→
· 24 + 1 →
· 23 + 0 →
· 22 + 1 →
· 21 + 1 →
· 20
2710 = 1 1 0 1 1 2
where the subscripts indicate the base, whether 10 or 2, in which the number is written. The places in binary notation correspond to the various powers of 2. The right-most position is the ones place (or 20 place), to the left of that is the twos place (or 21 place), to the left of that is the fours place (or 22 place), and so forth, as illustrated below.
Place 24 23 22 21 20
sixteens eights fours twos ones
Binary Digit 1 1 0 1 1
As in the decimal notation, leading zeros may be added or dropped as desired. For example,
00310 = 310 = 1 ·21 + 1 ·20 = 112 = 0112.
Example 2.5.1 Binary Notation for Integers from 1 to 9
Derive the binary notation for the integers from 1 to 9.
Solution 110 = 1 ·20 = 12 210 = 1 ·21 + 0 ·20 = 102 310 = 1 ·21 + 1 ·20 = 112 410 = 1 ·22 + 0 ·21 + 0 ·20 = 1002 510 = 1 ·22 + 0 ·21 + 1 ·20 = 1012 610 = 1 ·22 + 1 ·21 + 0 ·20 = 1102 710 = 1 ·22 + 1 ·21 + 1 ·20 = 1112 810 = 1 ·23 + 0 ·22 + 0 ·21 + 0 ·20 = 10002 910 = 1 ·23 + 0 ·22 + 0 ·21 + 1 ·20 = 10012 ■
A list of powers of 2 is useful for doing binary-to-decimal and decimal-to-binary conversions. See Table 2.5.1.
Table 2.5.1 Powers of 2
Power of 2 210 29 28 27 26 25 24 23 22 21 20
Decimal Form 1024 512 256 128 64 32 16 8 4 2 1
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
80 Chapter 2 The Logic of Compound Statements
Example 2.5.2 Converting a Binary to a Decimal Number
Represent 1101012 in decimal notation.
Solution 1101012 = 1 ·25 + 1 ·24 + 0 ·23 + 1 ·22 + 0 ·21 + 1 ·20 = 32+ 16+ 4+ 1 = 5310
Alternatively, the schema below may be used.
2 5 =
32
2 4 =
16
2 3 =
8
2 2 =
4
2 1 =
2
2 0 =
1
1
→
1
→
0
→
1
→
0
→
12 → 1 ·1 = 1
0 ·2 = 0 1 ·4 = 4 0 ·8 = 0 1 ·16 = 16 1 ·32 = 32
5310 ■
Example 2.5.3 Converting a Decimal to a Binary Number
Represent 209 in binary notation.
Solution Use Table 2.5.1 to write 209 as a sum of powers of 2, starting with the highest power of 2 that is less than 209 and continuing to lower powers.
Since 209 is between 128 and 256, the highest power of 2 that is less than 209 is 128. Hence
20910 = 128+ a smaller number. Now 209− 128 = 81, and 81 is between 64 and 128, so the highest power of 2 that is less than 81 is 64. Hence
20910 = 128+ 64+ a smaller number. Continuing in this way, you obtain
20910 = 128+ 64+ 16+ 1 = 1 ·27 + 1 ·26 + 0 ·25 + 1 ·24 + 0 ·23 + 0 ·22 + 0 ·21 + 1 ·20.
For each power of 2 that occurs in the sum, there is a 1 in the corresponding position of the binary number. For each power of 2 that is missing from the sum, there is a 0 in the corresponding position of the binary number. Thus
20910 = 110100012 ■
Another procedure for converting from decimal to binary notation is discussed in Section 5.1.
! Caution! Do not read 102 as “ten”; it is the number two. Read 102 as “one oh base two.”
Binary Addition and Subtraction The computational methods of binary arithmetic are analogous to those of decimal arith- metic. In binary arithmetic the number 2 (= 102 in binary notation) plays a role similar to that of the number 10 in decimal arithmetic.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.5 Application: Number Systems and Circuits for Addition 81
Example 2.5.4 Addition in Binary Notation
Add 11012 and 1112 using binary notation.
Solution Because 210 = 102 and 110 = 12, the translation of 110 + 110 = 210 to binary notation is
12 + 12
102
It follows that adding two 1’s together results in a carry of 1 when binary notation is used. Adding three 1’s together also results in a carry of 1 since 310 = 112 (“one one base two”).
12 + 12 + 12
112
Thus the addition can be performed as follows:
1 1 1 ← carry row 1 1 0 12
+ 1 1 12 1 0 1 0 02 ■
Example 2.5.5 Subtraction in Binary Notation
Subtract 10112 from 110002 using binary notation.
Solution In decimal subtraction the fact that 1010 − 110 = 910 is used to borrow across several columns. For example, consider the following:
9 9 1 1 ← borrow row
1 0 0 010 − 5 810
9 4 210
In binary subtraction it may also be necessary to borrow across more than one column. But when you borrow a 12 from 102, what remains is 12.
102 − 12
12
Thus the subtraction can be performed as follows:
0 1 1 1 1 1 ← borrow row
1 1 0 0 02 − 1 0 1 12
1 1 0 12 ■
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
82 Chapter 2 The Logic of Compound Statements
Circuits for Computer Addition Consider the question of designing a circuit to produce the sum of two binary digits P and Q. Both P and Q can be either 0 or 1. And the following facts are known:
12 + 12 = 102, 12 + 02 = 12 = 012, 02 + 12 = 12 = 012, 02 + 02 = 02 = 002.
It follows that the circuit to be designed must have two outputs—one for the left binary digit (this is called the carry) and one for the right binary digit (this is called the sum). The carry output is 1 if both P and Q are 1; it is 0 otherwise. Thus the carry can be produced using the AND-gate circuit that corresponds to the Boolean expression P ∧ Q. The sum output is 1 if either P or Q, but not both, is 1. The sum can, therefore, be produced using a circuit that corresponds to the Boolean expression for exclusive or: (P ∨ Q)∧ ∼(P ∧ Q). (See Example 2.4.3(a).) Hence, a circuit to add two binary digits P and Q can be constructed as in Figure 2.5.1. This circuit is called a half-adder.
HALF-ADDER
Circuit Input/Output Table
P
Q NOT
AND
AND
OR Sum
Carry
P Q Carry Sum
1 1 1 0
1 0 0 1
0 1 0 1
0 0 0 0
Figure 2.5.1 Circuit to Add P + Q, Where P and Q Are Binary Digits
Now consider the question of how to construct a circuit to add two binary integers, each with more than one digit. Because the addition of two binary digits may result in a carry to the next column to the left, it may be necessary to add three binary digits at certain points. In the following example, the sum in the right column is the sum of two binary digits, and, because of the carry, the sum in the left column is the sum of three binary digits.
1 ← carry row 1 12
+ 1 12 1 1 02
Thus, in order to construct a circuit that will add multidigit binary numbers, it is necessary to incorporate a circuit that will compute the sum of three binary digits. Such a circuit is called a full-adder. Consider a general addition of three binary digits P, Q, and R that results in a carry (or left-most digit) C and a sum (or right-most digit) S.
P + Q + R
CS
The operation of the full-adder is based on the fact that addition is a binary operation: Only two numbers can be added at one time. Thus P is first added to Q and then the
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.5 Application: Number Systems and Circuits for Addition 83
result is added to R. For instance, consider the following addition:
12 + 02 + 12 102
} 12 + 02 = 012
⎫⎬ ⎭ 12 + 12 = 102
The process illustrated here can be broken down into steps that use half-adder circuits.
Step 1: Add P and Q using a half-adder to obtain a binary number with two digits.
P + Q C1S1
Step 2: Add R to the sum C1S1 of P and Q.
C1S1 + R
To do this, proceed as follows:
Step 2a: Add R to S1 using a half-adder to obtain the two-digit number C2S.
S1 + R C2S
Then S is the right-most digit of the entire sum of P, Q, and R.
Step 2b: Determine the left-most digit, C , of the entire sum as follows: First note that it is impossible for both C1 and C2 to be 1’s. For if C1 = 1, then P and Q are both 1, and so S1 = 0. Consequently, the addition of S1 and R gives a binary number C2S1 where C2 = 0. Next observe that C will be a 1 in the case that the addition of P and Q gives a carry of 1 or in the case that the addition of S1 (the right-most digit of P + Q) and R gives a carry of 1. In other words, C = 1 if, and only if,C1 = 1 orC2 = 1. It follows that the circuit shown in Figure 2.5.2 will compute the sum of three binary digits.
FULL-ADDER Circuit Input/Output Table
half-adder #1
half-adder #2
AND P
Q
R
S
T
C1
C2
S1
P Q R C S
1 1 1 1 1
1 1 0 1 0
1 0 1 1 0
1 0 0 0 1
0 1 1 1 0
0 1 0 0 1
0 0 1 0 1
0 0 0 0 0
Figure 2.5.2 Circuit to Add P + Q + R, Where P, Q, and R Are Binary Digits
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
84 Chapter 2 The Logic of Compound Statements
Two full-adders and one half-adder can be used together to build a circuit that will add two three-digit binary numbers PQR and STU to obtain the sum WXY Z . This is illustrated in Figure 2.5.3. Such a circuit is called a parallel adder. Parallel adders can be constructed to add binary numbers of any finite length.
half-adder
U
Q
P
S1 = Z
S2 = Y
half-adder
R
U
Q
T
P
S
C2
C1
S1 = Z
S2 = Y
S3 = X
C3 = W
full-adder
full-adder
Figure 2.5.3 A Parallel Adder to Add P Q R and STU to Obtain W XY Z
Two’s Complements and the Computer Representation of Negative Integers
Typically, a fixed number of bits is used to represent integers on a computer, and these are required to represent negative as well as nonnegative integers. Sometimes a particular bit, normally the left-most, is used as a sign indicator, and the remaining bits are taken to be the absolute value of the number in binary notation. The problem with this approach is that the procedures for adding the resulting numbers are somewhat complicated and the representation of 0 is not unique. A more common approach, using two’s complements, makes it possible to add integers quite easily and results in a unique representation for 0. The two’s complement of an integer relative to a fixed bit length is defined as follows:
• Definition Given a positive integer a, the two’s complement of a relative to a fixed bit length n is the n-bit binary representation of
2n − a.
Bit lengths of 16 and 32 are the most commonly used in practice. However, because the principles are the same for all bit lengths, we use a bit length of 8 for simplicity in this discussion. For instance, because
(28 − 27)10 = (256− 27)10 = 22910 = (128+ 64+ 32+ 4+ 1)10 = 111001012, the 8-bit two’s complement of 27 is 111001012.
It turns out that there is a convenient way to compute two’s complements that involves less arithmetic than direct application of the definition. For an 8-bit representation, it is based on three facts:
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2.5 Application: Number Systems and Circuits for Addition 85
1. 28 − a = [(28 − 1)− a]+ 1. 2. The binary representation of 28 − 1 is 111111112. 3. Subtracting an 8-bit binary number a from 111111112 just switches all the 0’s in a
to 1’s and all the 1’s to 0’s. (The resulting number is called the one’s complement of the given number.)
For instance, by (2) and (3), with a = 27,
1 1 1 1 1 1 1 1 28 − 1 −
0 0 0 1 1 0 1 1 270’s and 1’s are switched
→ →
1 1 1 0 0 1 0 0 (28 − 1)− 27 2.5.1
and so in binary notation the difference (28 − 1)− 27 is 111001002. But by (1) with a = 27, 28 − 27 = [(28 − 1)− 27] + 1, and so if we add 1 to (2.5.1), we obtain the 8-bit binary representation of 28 − 27, which is the 8-bit two’s complement of 27:
1 1 1 0 0 1 0 0 (28 − 1)− 27 +
0 0 0 0 0 0 0 1 1
1 1 1 0 0 1 0 1 28 − 27
In general,
To find the 8-bit two’s complement of a positive integer a that is at most 255:
• Write the 8-bit binary representation for a. • Flip the bits (that is, switch all the 1’s to 0’s and all the 0’s to 1’s). • Add 1 in binary notation.
Example 2.5.6 Finding a Two’s Complement
Find the 8-bit two’s complement of 19.
Solution Write the 8-bit binary representation for 19, switch all the 0’s to 1’s and all the 1’s to 0’s, and add 1.
1910 = (16+ 2+ 1)10 = 000100112 flip the bits−−−−−−−→ 11101100 add 1−−−−→ 11101101 To check this result, note that
111011012 = (128+ 64+ 32+ 8+ 4+ 1)10 = 23710 = (256− 19)10 = (28 − 19)10,
which is the two’s complement of 19. ■
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
86 Chapter 2 The Logic of Compound Statements
Observe that because
28 − (28 − a) = a the two’s complement of the two’s complement of a number is the number itself, and therefore,
To find the decimal representation of the integer with a given 8-bit two’s complement:
• Find the two’s complement of the given two’s complement. • Write the decimal equivalent of the result.
Example 2.5.7 Finding a Number with a Given Two’s Complement
What is the decimal representation for the integer with two’s complement 10101001?
Solution
101010012 flip the bits−−−−−−−→ 01010110 add 1−−−−→ 010101112 = (64+ 16+ 4+ 2+ 1)10 = 8710
To check this result, note that the given number is
101010012 = (128+ 32+ 8+ 1)10 = 16910 = (256− 87)10 = (28 − 87)10, which is the two’s complement of 87. ■
8-Bit Representation of a Number Now consider the two’s complement of an integer n that satisfies the inequality 1 ≤ n ≤ 128. Then
−1 ≥ −n ≥ −128 because multiplying by −1 reverses the direction of the inequality
and
28 − 1 ≥ 28 − n ≥ 28 − 128 by adding 28 to all parts of the inequality. But 28 − 128 = 256− 128 = 128 = 27. Hence
27 ≤ the two’s complement of n < 28. It follows that the 8-bit two’s complement of an integer from 1 through 128 has a leading bit of 1. Note also that the ordinary 8-bit representation of an integer from 0 through 127 has a leading bit of 0. Consequently, eight bits can be used to represent both nonnegative and negative integers by representing each nonnegative integer up through 127 using ordinary 8-bit binary notation and representing each negative integer from −1 through −128 as the two’s complement of its absolute value. That is, for any integer a from −128 through 127, The 8-bit representation of a = { the 8-bit binary representation of a if a ≥ 0 the 8-bit binary representation of 28 − |a| if a < 0 . Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.5 Application: Number Systems and Circuits for Addition 87 The representations are illustrated in Table 2.5.2. Table 2.5.2 8-Bit Representation (ordinary 8-bit Decimal Form of binary notation if nonnegative or 8-bit two’s Two’s Complement Integer complement of absolute value if negative) for Negative Integers 127 01111111 126 01111110 ... ... 2 00000010 1 00000001 0 00000000 −1 11111111 28 − 1 −2 11111110 28 − 2 −3 11111101 28 − 3 ... ... ... −127 10000001 28 − 127 −128 10000000 28 − 128 Computer Addition with Negative Integers Here is an example of how two’s complements enable addition circuits to perform sub- traction. Suppose you want to compute 72− 54. First note that this is the same as 72+ (−54), and the 8-bit binary representations of 72 and −54 are 01001000 and 11001010, respectively. So if you add the 8-bit binary representations for both numbers, you get 0 1 0 0 1 0 0 0 + 1 1 0 0 1 0 1 0 1 0 0 0 1 0 0 1 0 And if you truncate the leading 1, you get 00010010. This is the 8-bit binary representation for 18, which is the right answer! The description below explains how to use this method to add any two integers between −128 and 127. It is easily generalized to apply to 16-bit and 32-bit represen- tations in order to add integers between about −2,000,000,000 and 2,000,000,000. To add two integers in the range −128 through 127 whose sum is also in the range −128 through 127: • Convert both integers to their 8-bit representations (representing negative integers by using the two’s complements of their absolute values). • Add the resulting integers using ordinary binary addition. • Truncate any leading 1 (overflow) that occurs in the 28th position. • Convert the result back to decimal form (interpreting 8-bit integers with leading 0’s as nonnegative and 8-bit integers with leading 1’s as negative). Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 88 Chapter 2 The Logic of Compound Statements To see why this result is true, consider four cases: (1) both integers are nonnegative, (2) one integer is nonnegative and the other is negative and the absolute value of the nonnegative integer is less than that of the negative one, (3) one integer is nonnegative and the other is negative and the absolute value of the negative integer is less than or equal to that of the nonnegative one, and (4) both integers are negative. Case 1, (both integers are nonnegative): This case is easy because if two nonnegative integers from 0 through 127 are written in their 8-bit representations and if their sum is also in the range 0 through 127, then the 8-bit representation of their sum has a lead- ing 0 and is therefore interpreted correctly as a nonnegative integer. The example below illustrates what happens when 38 and 69 are added. 0 0 1 0 0 1 1 0 38 + 0 1 0 0 0 1 0 1 69 0 1 1 0 1 0 1 1 107 Cases (2) and (3) both involve adding a negative and a nonnegative integer. To be concrete, let the nonnegative integer be a and the negative integer be −b and suppose both a and −b are in the range −128 through 127. The crucial observation is that adding the 8-bit representations of a and −b is equivalent to computing a + (28 − b) because the 8-bit representation of −b is the binary representation of 28 − b. Case 2 (a is nonnegative and −b is negative and |a| < |b|): In this case, observe that a = |a| < |b| = b and a + (28 − b) = 28 − (b − a), and the binary representation of this number is the 8-bit representation of −(b − a) = a + (−b). We must be careful to check that 28 − (b − a) is between 27 and 28. But it is because 27 = 28 − 27 ≤ 28 − (b − a) < 28 since 0 < b − a ≤ b ≤ 128 = 27. Hence in case |a| < |b|, adding the 8-bit representations of a and −b gives the 8-bit representation of a + (−b). Example 2.5.8 Computing a + (−b) Where 0 ≤ a < b ≤ 128 Use 8-bit representations to compute 39+ (−89). Solution Step 1: Change from decimal to 8-bit representations using the two’s complement to represent −89. Since 3910 = (32+ 4+ 2+ 1)10 = 1001112, the 8-bit representation of 39 is 00100111. Now the 8-bit representation of −89 is the two’s complement of 89. This is obtained as follows: 8910 = (64+ 16+ 8+ 1)10 = 010110012 flip the bits−−−−−−−→ 10100110 add 1−−−−→ 10100111 Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.5 Application: Number Systems and Circuits for Addition 89 So the 8-bit representation of −89 is 10100111. Step 2: Add the 8-bit representations in binary notation and truncate the 1 in the 28th position if there is one: 0 0 1 0 0 1 1 1 + 1 0 1 0 0 1 1 1 There is no 1 in the 28th position to truncate→ 1 1 0 0 1 1 1 0 Step 3: Find the decimal equivalent of the result. Since its leading bit is 1, this number is the 8-bit representation of a negative integer. 11001110 flip the bits−−−−−−−→ 00110001 add 1−−−−→ 00110010 ↔ −(32+ 16+ 2)10 = −5010 Note that since 39− 89 = −50, this procedure gives the correct answer. ■ Case 3 (a is nonnegative and −b is negative and |b| ≤ |a|): In this case, observe that b = |b| ≤ |a| = a and a + (28 − b) = 28 + (a − b). Also 28 ≤ 28 + (a − b) < 28 + 27 because 0 ≤ a − b ≤ a < 128 = 27. So the binary representation of a + (28 − b) = 28 + (a − b) has a leading 1 in the ninth (28th) position. This leading 1 is often called “overflow” because it does not fit in the 8-bit integer format. Now subtracting 28 from 28 + (a − b) is equivalent to truncating the leading 1 in the 28th position of the binary representation of the number. But [a + (28 − b)]− 28 = 28 + (a − b)− 28 = a − b = a + (−b). Hence in case |a| ≥ |b|, adding the 8-bit representations of a and −b and truncating the leading 1 (which is sure to be present) gives the 8-bit representation of a + (−b). Example 2.5.9 Computing a + (−b) Where 1 ≤ b ≤ a ≤ 127 Use 8-bit representations to compute 39+ (−25). Solution Step 1: Change from decimal to 8-bit representations using the two’s complement to represent −25. As in Example 2.5.8, the 8-bit representation of 39 is 00100111. Now the 8-bit representation of −25 is the two’s complement of 25, which is obtained as follows: 2510 = (16+ 8+ 1)10 = 000110012 flip the bits−−−−−−−→ 11100110 add 1−−−−→ 11100111 So the 8-bit representation of −25 is 11100111. Step 2: Add the 8-bit representations in binary notation and truncate the 1 in the 28th position if there is one: Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 90 Chapter 2 The Logic of Compound Statements 0 0 1 0 0 1 1 1 + 1 1 1 0 0 1 1 1 Truncate→ 1 0 0 0 0 1 1 1 0 Step 3: Find the decimal equivalent of the result: 000011102 = (8+ 4+ 2)10 = 1410. Since 39− 25 = 14, this is the correct answer. ■ Case 4 (both integers are negative): This case involves adding two negative integers in the range −1 through −128 whose sum is also in this range. To be specific, consider the sum (−a)+ (−b) where a, b, and a + b are all in the range 1 through 128. In this case, the 8-bit representations of−a and−b are the 8-bit representations of 28 − a and 28 − b. So if the 8-bit representations of −a and −b are added, the result is (28 − a)+ (28 − b) = [28 − (a + b)]+ 28. Recall that truncating a leading 1 in the ninth (28th) position of a binary number is equivalent to subtracting 28. So when the leading 1 is truncated from the 8-bit repre- sentation of (28 − a)+ (28 − b), the result is 28 − (a + b), which is the 8-bit represen- tation of −(a + b) = (−a)+ (−b). (In exercise 37 you are asked to show that the sum (28 − a)+ (28 − b) has a leading 1 in the ninth (28th) position.) Example 2.5.10 Computing (−a) + (−b) Where 1 ≤ a, b ≤ 128, and 1 ≤ a + b ≤ 128 Use 8-bit representations to compute (−89)+ (−25). Solution Step 1: Change from decimal to 8-bit representations using the two’s complements to represent −89 and −25. The 8-bit representations of−89 and−25 were shown in Examples 2.5.8 and 2.5.9 to be 10100111 and 11100111, respectively. Step 2: Add the 8-bit representations in binary notation and truncate the 1 in the 28th position if there is one: 1 0 1 0 0 1 1 1 + 1 1 1 0 0 1 1 1 Truncate→ 1 1 0 0 0 1 1 1 0 Step 3: Find the decimal equivalent of the result. Because its leading bit is 1, this number is the 8-bit representation of a negative integer. 10001110 flip the bits−−−−−−−→ 01110001 add 1−−−−→ 011100102 ↔ −(64+ 32+ 16+ 2)10 = −11410 Since (−89)+ (−25) = −114, that is the correct answer. ■ Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.5 Application: Number Systems and Circuits for Addition 91 Hexadecimal Notation It should now be obvious that numbers written in binary notation take up much more space than numbers written in decimal notation. Yet many aspects of computer opera- tion can best be analyzed using binary numbers. Hexadecimal notation is even more compact than decimal notation, and it is much easier to convert back and forth between hexadecimal and binary notation than it is between binary and decimal notation. The word hexadecimal comes from the Greek root hex-, meaning “six,” and the Latin root deci-,meaning “ten.” Hence hexadecimal refers to “sixteen,” and hexadecimal notation is also called base 16 notation. Hexadecimal notation is based on the fact that any integer can be uniquely expressed as a sum of numbers of the form d ·16n, where each n is a nonnegative integer and each d is one of the integers from 0 to 15. In order to avoid ambiguity, each hexadecimal digit must be represented by a single symbol. The integers 10 through 15 are represented by the symbols A, B, C, D, E, and F. The sixteen hexadecimal digits are shown in Table 2.5.3, together with their decimal equivalents and, for future reference, their 4-bit binary equivalents. Table 2.5.3 4-Bit Binary Decimal Hexadecimal Equivalent 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 7 7 0111 8 8 1000 9 9 1001 10 A 1010 11 B 1011 12 C 1100 13 D 1101 14 E 1110 15 F 1111 Example 2.5.11 Converting from Hexadecimal to Decimal Notation Convert 3CF16 to decimal notation. Solution A schema similar to the one introduced in Example 2.5.2 can be used here. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 92 Chapter 2 The Logic of Compound Statements 16 2 = 25 6 16 1 = 16 16 0 = 1 316 C16 F16 = = = 310 1210 1510 → → →15 · 1 = 15 12 · 16 = 192 3 ·256= 768 97510 So 3CF16 = 97510. ■ Now consider how to convert from hexadecimal to binary notation. In the example below the numbers are rewritten using powers of 2, and the laws of exponents are applied. The result suggests a general procedure. 16 3 = 40 96 16 2 = 25 6 16 1 = 16 16 0 = 1 C16 516 016 A16 = = = = 1210 510 010 1010 → → → → 10 ·160 = (23 + 2) ·1 = 23 + 2 since 10 = 23 + 2 0 ·161 = 0 ·24 = 0 since 161 = 24 5 ·162 = (22 + 1) ·28 = 210 + 28 since 5 = 22 + 1, 162 = (24)2 = 28 and 22 ·28 = 210 12 ·163 = (23 + 22) ·212 = 215 + 214 since 12 = 23 + 22, 162 = (24)3 = 212, 23 ·212 = 215, and 22 ·212 = 214 But (215 + 214)+ (210 + 28)+ 0+ (23 + 2) = 1100 0000 0000 00002 + 0101 0000 00002 by the rules for writing binary numbers.+ 0000 00002 + 10102 So C50A16 = 1100︸︷︷︸ 0101︸︷︷︸ 0000︸︷︷︸ 10102︸ ︷︷ ︸ C16 516 016 A16 by the rules for adding binary numbers. The procedure illustrated in this example can be generalized. In fact, the following sequence of steps will always give the correct answer: To convert an integer from hexadecimal to binary notation: • Write each hexadecimal digit of the integer in 4-bit binary notation. • Juxtapose the results. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.5 Application: Number Systems and Circuits for Addition 93 Example 2.5.12 Converting from Hexadecimal to Binary Notation Convert B09F16 to binary notation. Solution B16 = 1110 = 10112, 016 = 010 = 00002, 916 = 910 = 10012, and F16 = 1510 = 11112. Consequently, B 0 9 F ↔ ↔ ↔ ↔ 1011 0000 1001 1111 and the answer is 10110000100111112. ■ To convert integers written in binary notation into hexadecimal notation, reverse the steps of the previous procedure. To convert an integer from binary to hexadecimal notation: • Group the digits of the binary number into sets of four, starting from the right and adding leading zeros as needed. • Convert the binary numbers in each set of four into hexadecimal digits. Juxtapose those hexadecimal digits. Example 2.5.13 Converting from Binary to Hexadecimal Notation Convert 1001101101010012 to hexadecimal notation. Solution First group the binary digits in sets of four, working from right to left and adding leading 0’s if necessary. 0100 1101 1010 1001. Convert each group of four binary digits into a hexadecimal digit. 0100 1101 1010 1001 ↔ ↔ ↔ ↔ 4 D A 9 Then juxtapose the hexadecimal digits. 4DA916 ■ Example 2.5.14 Reading a Memory Dump The smallest addressable memory unit on most computers is one byte, or eight bits. In some debugging operations a dump is made of memory contents; that is, the contents of each memory location are displayed or printed out in order. To save space and make the output easier on the eye, the hexadecimal versions of the memory contents are given, rather than the binary versions. Suppose, for example, that a segment of the memory dump looks like A3 BB 59 2E. What is the actual content of the four memory locations? Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 94 Chapter 2 The Logic of Compound Statements Solution A316 = 101000112 BB16 = 101110112 5916 = 010110012 2E16 = 001011102 ■ Test Yourself 1. To represent a nonnegative integer in binary notation means to write it as a sum of products of the form , where . 2. To add integers in binary notation, you use the facts that 12 + 12 = and 12 + 12 + 12 = . 3. To subtract integers in binary notation, you use the facts that 102 − 12 = and 112 − 12 = . 4. A half-adder is a digital logic circuit that , and a full-adder is a digital logic circuit that . 5. The 8-bit two’s complement of a positive integer a is . 6. To find the 8-bit two’s complement of a positive integer a that is at most 255, you , , and . 7. If a is an integer with −128 ≤ a ≤ 127, the 8-bit represen- tation of a is if a ≥ 0 and is if a < 0. 8. To add two integers in the range −128 through 127 whose sum is also in the range −128 through 127, you , , , and . 9. To represent a nonnegative integer in hexadecimal notation means to write it as a sum of products of the form , where . 10. To convert a nonnegative integer from hexadecimal to binary notation, you and . Exercise Set 2.5 Represent the decimal integers in 1–6 in binary notation. 1. 19 2. 55 3. 287 4. 458 5. 1609 6. 1424 Represent the integers in 7–12 in decimal notation. 7. 11102 8. 101112 9. 1101102 10. 11001012 11. 10001112 12. 10110112 Perform the arithmetic in 13–20 using binary notation. 13. 10112 + 1012 14. 10012 + 10112 15. 1011012 + 111012 16. 1101110112 + 10010110102 17. 101002 − 11012 18. 110102 − 11012 19. 1011012 − 100112 20. 10101002 − 101112 21. Give the output signals S and T for the circuit in the right column if the input signals P, Q, and R are as specified. Note that this is not the circuit for a full-adder. a. P = 1, Q = 1, R = 1 b. P = 0, Q = 1, R = 0 c. P = 1, Q = 0, R = 1 half-adder #1 half-adder #2 AND P Q R S T C1 C2 S1 22. Add 111111112 + 12 and convert the result to decimal nota- tion, to verify that 111111112 = (28 − 1)10. Find the 8-bit two’s complements for the integers in 23–26. 23. 23 24. 67 25. 4 26. 115 Find the decimal representations for the integers with the 8-bit representations given in 27–30. 27. 11010011 28. 10011001 29. 11110010 30. 10111010 Use 8-bit representations to compute the sums in 31–36. 31. 57+ (−118) 32. 62+ (−18) 33. (−6)+ (−73) 34. 89+ (−55) 35. (−15)+ (−46) 36. 123+ (−94) Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 2.5 Application: Number Systems and Circuits for Addition 95 37.✶ Show that if a, b, and a + b are integers in the range 1 through 128, then (28 − a)+ (28 − b) = (28 − (a + b))+ 28 ≥ 28 + 27. Explain why it follows that if the 8-bit binary representa- tion of the sum of the negatives of two numbers in the given range is computed, the result is a negative number. Convert the integers in 38–40 from hexadecimal to decimal notation. 38. A2BC16 39. E0D16 40. 39EB16 Convert the integers in 41–43 from hexadecimal to binary nota- tion. 41. 1C0ABE16 42. B53DF816 43. 4ADF8316 Convert the integers in 44–46 from binary to hexadecimal notation. 44. 001011102 45. 10110111110001012 46. 110010010111002 47. Octal Notation: In addition to binary and hexadecimal, computer scientists also use octal notation (base 8) to rep- resent numbers. Octal notation is based on the fact that any integer can be uniquely represented as a sum of numbers of the form d · 8n , where each n is a nonnegative integer and each d is one of the integers from 0 to 7. Thus, for example, 50738 = 5 ·83 + 0 ·82 + 7 ·81 + 3 ·80 = 261910. a. Convert 615028 to decimal notation. b. Convert 207638 to decimal notation. c. Describe methods for converting integers from octal to binary notation and the reverse that are similar to the methods used in Examples 2.5.12 and 2.5.13 for con- verting back and forth from hexadecimal to binary nota- tion. Give examples showing that these methods result in correct answers. Answers for Test Yourself 1. d ·2n; d = 0 or d = 1, and n is a nonnegative integer 2. 102;112 3. 12;102 4. outputs the sum of any two binary digits; outputs the sum of any three binary digits 5. 28 − a 6. write the 8-bit binary representation of a; flip the bits; add 1 in binary notation 7. the 8-bit binary representation of a; the 8-bit binary representation of 28 − a 8. convert both integers to their 8-bit binary representations; add the results using binary notation; truncate any leading 1; convert back to decimal form 9. d ·16n; d = 0, 1, 2, . . . 9, A, B,C, D, E, F , and n is a nonnegative integer 10. write each hexadecimal digit in 4-bit binary notation; juxtapose the results Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 96 CHAPTER 3 THE LOGIC OF QUANTIFIED STATEMENTS In Chapter 2 we discussed the logical analysis of compound statements—those made of simple statements joined by the connectives ∼,∧,∨,→, and ↔. Such analysis casts light on many aspects of human reasoning, but it cannot be used to determine validity in the majority of everyday and mathematical situations. For example, the argument All men are mortal. Socrates is a man. ∴ Socrates is mortal. is intuitively perceived as correct. Yet its validity cannot be derived using the methods outlined in Section 2.3. To determine validity in examples like this, it is necessary to separate the statements into parts in much the same way that you separate declarative sentences into subjects and predicates. And you must analyze and understand the special role played by words that denote quantities such as “all” or “some.” The symbolic analysis of predicates and quantified statements is called the predicate calculus. The symbolic analysis of ordinary compound statements (as outlined in Sections 2.1–2.3) is called the statement calculus (or the propositional calculus). 3.1 Predicates and Quantified Statements I . . . it was not till within the last few years that it has been realized how fundamental any and some are to the very nature of mathematics. — A. N. Whitehead (1861–1947) As noted in Section 2.1, the sentence “He is a college student” is not a statement because it may be either true or false depending on the value of the pronoun he. Similarly, the sentence “x + y is greater than 0” is not a statement because its truth value depends on the values of the variables x and y. In grammar, the word predicate refers to the part of a sentence that gives information about the subject. In the sentence “James is a student at Bedford College,” the word James is the subject and the phrase is a student at Bedford College is the predicate. The predicate is the part of the sentence from which the subject has been removed. In logic, predicates can be obtained by removing some or all of the nouns from a statement. For instance, let P stand for “is a student at Bedford College” and let Q stand for “is a student at.” Then both P and Q are predicate symbols. The sentences “x is a student at Bedford College” and “x is a student at y” are symbolized as P(x) and as Q(x, y) respectively, where x and y are predicate variables that take values in appropri- ate sets. When concrete values are substituted in place of predicate variables, a statement results. For simplicity, we define a predicate to be a predicate symbol together with suit- able predicate variables. In some other treatments of logic, such objects are referred to as propositional functions or open sentences. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 3.1 Predicates and Quantified Statements I 97 • Definition A predicate is a sentence that contains a finite number of variables and becomes a statement when specific values are substituted for the variables. The domain of a predicate variable is the set of all values that may be substituted in place of the variable. Example 3.1.1 Finding Truth Values of a Predicate Let P(x) be the predicate “x2 > x” with domain the set R of all real numbers. Write P(2), P( 12 ), and P(− 12 ), and indicate which of these statements are true and which are false.
Solution P(2): 22 > 2, or 4 > 2. True. P ( 1 2
) :
( 1 2
)2 >
1 2 , or
1 4 >
1 2 . False.
P ( −12
) :
( −12
)2 > −12 , or 14 > −12 . True. ■
When an element in the domain of the variable of a one-variable predicate is substi- tuted for the variable, the resulting statement is either true or false. The set of all such elements that make the predicate true is called the truth set of the predicate.
Note Recall that we read these symbols as “the set of all x in D such that P(x).”
• Definition If P(x) is a predicate and x has domain D, the truth set of P(x) is the set of all elements of D that make P(x) true when they are substituted for x . The truth set of P(x) is denoted
{x ∈ D | P(x)}.
Example 3.1.2 Finding the Truth Set of a Predicate
Let Q(n) be the predicate “n is a factor of 8.” Find the truth set of Q(n) if
a. the domain of n is the set Z+ of all positive integers
b. the domain of n is the set Z of all integers.
Solution
a. The truth set is {1, 2, 4, 8} because these are exactly the positive integers that divide 8 evenly.
b. The truth set is {1, 2, 4, 8,−1,−2,−4,−8} because the negative integers−1,−2,−4, and −8 also divide into 8 without leaving a remainder. ■
The Universal Quantifier: ∀ One sure way to change predicates into statements is to assign specific values to all their variables. For example, if x represents the number 35, the sentence “x is (evenly) divis- ible by 5” is a true statement since 35 = 5 ·7. Another way to obtain statements from predicates is to add quantifiers. Quantifiers are words that refer to quantities such as “some” or “all” and tell for how many elements a given predicate is true. The formal concept of quantifier was introduced into symbolic logic in the late nineteenth century by
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
98 Chapter 3 The Logic of Quantified Statements
the American philosopher, logician, and engineer Charles Sanders Peirce and, indepen- dently, by the German logician Gottlob Frege.
The symbol ∀ denotes “for all” and is called the universal quantifier. For example, another way to express the sentence “All human beings are mortal” is to write
∀ human beings x, x is mortal. C
ul ve
r P
ic tu
re s
Charles Sanders Peirce (1839–1914)
When the symbol x is introduced into the phrase “∀ human beings x ,” you are sup- posed to think of x as an individual, but generic, object—with all the properties shared by every human being but no other properties. Thus you should say “x is mortal” rather than “x are mortal.” In other words, use the singular “is” rather than the plural verb “are” when describing the property satisfied by x . If you let H be the set of all human beings, then you can symbolize the statement more formally by writing
∀x ∈ H, x is mortal, which is read as “For all x in the set of all human beings, x is mortal.”
Note Think “for all” when you see the symbol ∀.
The domain of the predicate variable is generally indicated between the ∀ symbol and the variable name (as in ∀ human beings x) or immediately following the variable name (as in ∀x ∈ H ). Some other expressions that can be used instead of for all are for every, for arbitrary, for any, for each, and given any. In a sentence such as “∀ real numbers x and y, x + y = y + x ,” the ∀ symbol is understood to refer to both x and y.∗
Fr ie
dr ic
h S
ch ill
er ,
U ni
ve rs
ít at
Je na
Gottlob Frege (1848–1925)
Sentences that are quantified universally are defined as statements by giving them the truth values specified in the following definition:
• Definition Let Q(x) be a predicate and D the domain of x . A universal statement is a statement of the form “∀x ∈ D, Q(x).” It is defined to be true if, and only if, Q(x) is true for every x in D. It is defined to be false if, and only if, Q(x) is false for at least one x in D. A value for x for which Q(x) is false is called a counterexample to the universal statement.
Example 3.1.3 Truth and Falsity of Universal Statements
a. Let D = {1, 2, 3, 4, 5}, and consider the statement ∀x ∈ D, x2 ≥ x .
Show that this statement is true.
b. Consider the statement
∀x ∈ R, x2 ≥ x . Find a counterexample to show that this statement is false.
Solution
a. Check that “x2 ≥ x” is true for each individual x in D. 12 ≥ 1, 22 ≥ 2, 32 ≥ 3, 42 ≥ 4, 52 ≥ 5.
Hence “∀x ∈ D, x2 ≥ x” is true.
∗More formal versions of symbolic logic would require writing a separate ∀ for each variable: “∀x ∈ R(∀y ∈ R(x + y = y + x)).”
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3.1 Predicates and Quantified Statements I 99
b. Counterexample: Take x = 12 . Then x is in R (since 12 is a real number) and( 1
2
)2 = 1
4 �
1
2 .
Hence “∀x ∈ R, x2 ≥ x” is false. ■ The technique used to show the truth of the universal statement in Example 3.1.3(a)
is called themethod of exhaustion. It consists of showing the truth of the predicate sep- arately for each individual element of the domain. (The idea is to exhaust the possibilities before you exhaust yourself!) This method can, in theory, be used whenever the domain of the predicate variable is finite. In recent years the prevalence of digital computers has greatly increased the convenience of using the method of exhaustion. Computer expert systems, or knowledge-based systems, use this method to arrive at answers to many of the questions posed to them. Because most mathematical sets are infinite, however, the method of exhaustion can rarely be used to derive general mathematical results.
The Existential Quantifier: ∃ The symbol ∃ denotes “there exists” and is called the existential quantifier. For example, the sentence “There is a student in Math 140” can be written as
∃ a person p such that p is a student in Math 140, or, more formally,
∃p ∈ P such that p is a student in Math 140, Note Think “there exists” when you see the symbol ∃.
where P is the set of all people. The domain of the predicate variable is generally indi- cated either between the ∃ symbol and the variable name or immediately following the variable name. The words such that are inserted just before the predicate. Some other expressions that can be used in place of there exists are there is a, we can find a, there is at least one, for some, and for at least one. In a sentence such as “∃ integers m and n such that m + n = m ·n,” the ∃ symbol is understood to refer to both m and n.∗
Sentences that are quantified existentially are defined as statements by giving them the truth values specified in the following definition.
• Definition Let Q(x) be a predicate and D the domain of x . An existential statement is a statement of the form “∃x ∈ D such that Q(x).” It is defined to be true if, and only if, Q(x) is true for at least one x in D. It is false if, and only if, Q(x) is false for all x in D.
Example 3.1.4 Truth and Falsity of Existential Statements
a. Consider the statement
∃m ∈ Z+ such that m2 = m. Show that this statement is true.
∗In more formal versions of symbolic logic, the words such that are not written out (although they are understood) and a separate ∃ symbol is used for each variable: “∃m ∈ Z(∃n ∈ Z(m + n = m ·n)).”
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
100 Chapter 3 The Logic of Quantified Statements
b. Let E = {5, 6, 7, 8} and consider the statement ∃m ∈ E such that m2 = m.
Show that this statement is false.
Solution
a. Observe that 12 = 1. Thus “m2 = m” is true for at least one integerm. Hence “∃m ∈ Z such that m2 = m” is true.
b. Note that m2 = m is not true for any integers m from 5 through 8: 52 = 25 �= 5, 62 = 36 �= 6, 72 = 49 �= 7, 82 = 64 �= 8.
Thus “∃m ∈ E such that m2 = m” is false. ■
Formal Versus Informal Language It is important to be able to translate from formal to informal language when trying to make sense of mathematical concepts that are new to you. It is equally important to be able to translate from informal to formal language when thinking out a complicated problem.
Example 3.1.5 Translating from Formal to Informal Language
Rewrite the following formal statements in a variety of equivalent but more informal ways. Do not use the symbol ∀ or ∃. a. ∀x ∈ R, x2 ≥ 0. b. ∀x ∈ R, x2 �= −1. c. ∃m ∈ Z+such that m2 = m.
Solution
a. All real numbers have nonnegative squares. Or: Every real number has a nonnegative square. Or: Any real number has a nonnegative square. Or: The square of each real number is nonnegative.
Note The singular noun is used to refer to the domain when the ∀ symbol is translated as every, any, or each.
b. All real numbers have squares that are not equal to −1. Or: No real numbers have squares equal to −1. (The words none are or no . . . are are equivalent to the words all are not.)
c. There is a positive integer whose square is equal to itself. Or:We can find at least one positive integer equal to its own square. Or: Some positive integer equals its own square. Or: Some positive integers equal their own squares.
Note In ordinary English, the statement in part (c) might be taken to be true only if there are at least two positive integers equal to their own squares. In mathematics, we understand the last two statements in part (c) to mean the same thing.
■
Another way to restate universal and existential statements informally is to place the quantification at the end of the sentence. For instance, instead of saying “For any real number x , x2 is nonnegative,” you could say “x2 is nonnegative for any real number x .” In such a case the quantifier is said to “trail” the rest of the sentence.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3.1 Predicates and Quantified Statements I 101
Example 3.1.6 Trailing Quantifiers
Rewrite the following statements so that the quantifier trails the rest of the sentence.
a. For any integer n, 2n is even.
b. There exists at least one real number x such that x2 ≤ 0. Solution
a. 2n is even for any integer n.
b. x2 ≤ 0 for some real number x . Or: x2 ≤ 0 for at least one real number x . ■
Example 3.1.7 Translating from Informal to Formal Language
Rewrite each of the following statements formally. Use quantifiers and variables.
a. All triangles have three sides.
b. No dogs have wings.
c. Some programs are structured.
Solution
a. ∀ triangles t, t has three sides. Or: ∀t ∈ T, t has three sides (where T is the set of all triangles).
b. ∀ dogs d, d does not have wings. Or: ∀d ∈ D, d does not have wings (where D is the set of all dogs).
c. ∃ a program p such that p is structured. Or: ∃p ∈ P such that p is structured (where P is the set of all programs). ■
Universal Conditional Statements A reasonable argument can be made that the most important form of statement in mathe- matics is the universal conditional statement:
∀x, if P(x) then Q(x). Familiarity with statements of this form is essential if you are to learn to speak mathematics.
Example 3.1.8 Writing Universal Conditional Statements Informally
Rewrite the following statement informally, without quantifiers or variables.
∀x ∈ R, if x > 2 then x2 > 4. Solution If a real number is greater than 2 then its square is greater than 4.
Or: Whenever a real number is greater than 2, its square is greater than 4.
Or: The square of any real number greater than 2 is greater than 4.
Or: The squares of all real numbers greater than 2 are greater than 4. ■
Example 3.1.9 Writing Universal Conditional Statements Formally
Rewrite each of the following statements in the form
∀ , if then . a. If a real number is an integer, then it is a rational number.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
102 Chapter 3 The Logic of Quantified Statements
b. All bytes have eight bits.
c. No fire trucks are green.
Solution
a. ∀ real numbers x , if x is an integer, then x is a rational number. Or: ∀x ∈ R, if x ∈ Z then x ∈ Q.
b. ∀x , if x is a byte, then x has eight bits. c. ∀x , if x is a fire truck, then x is not green.
It is common, as in (b) and (c) above, to omit explicit identification of the domain of predicate variables in universal conditional statements. ■
Careful thought about the meaning of universal conditional statements leads to another level of understanding for why the truth table for an if-then statement must be defined as it is. Consider again the statement
∀ real numbers x, if x > 2 then x2 > 4. Your experience and intuition tell you that this statement is true. But that means that
If x > 2 then x2 > 4
must be true for every single real number x . Consequently, it must be true even for values of x that make its hypothesis “x > 2” false. In particular, both statements
If 1 > 2 then 12 > 4 and If − 3 > 2 then (−3)2 > 4 must be true. In both cases the hypothesis is false, but in the first case the conclusion “12 > 4” is false, and in the second case the conclusion “(−3)2 > 4” is true. Hence, regardless of whether its conclusion is true or false, an if-then statement with a false hypothesis must be true.
Note also that the definition of valid argument is a universal conditional statement:
∀ combinations of truth values for the component statements, if the premises are all true then the conclusion is also true.
Equivalent Forms of Universal and Existential Statements Observe that the two statements “∀ real numbers x , if x is an integer then x is rational” and “∀ integers x, x is rational” mean the same thing. Both have informal translations “All integers are rational.” In fact, a statement of the form
∀x ∈ U, if P(x) then Q(x) can always be rewritten in the form
∀x ∈ D, Q(x) by narrowing U to be the domain D consisting of all values of the variable x that make P(x) true. Conversely, a statement of the form
∀x ∈ D, Q(x) can be rewritten as
∀x, if x is in D then Q(x).
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3.1 Predicates and Quantified Statements I 103
Example 3.1.10 Equivalent Forms for Universal Statements
Rewrite the following statement in the two forms “∀x , if then ” and “∀ x , ”: All squares are rectangles.
Solution ∀x , if x is a square then x is a rectangle. ∀ squares x, x is a rectangle. ■
Similarly, a statement of the form “∃x such that p(x) and Q(x)” can be rewritten as “∃xεD such that Q(x),” where D is the set of all x for which P(x) is true.
Example 3.1.11 Equivalent Forms for Existential Statements
A prime number is an integer greater than 1 whose only positive integer factors are itself and 1. Consider the statement “There is an integer that is both prime and even.” Let Prime(n) be “n is prime” and Even(n) be “n is even.” Use the notation Prime(n) and Even(n) to rewrite this statement in the following two forms:
a. ∃n such that ∧ . b. ∃ n such that .
Solution
a. ∃n such that Prime(n)∧ Even(n). b. Two answers: ∃ a prime number n such that Even(n).
∃ an even number n such that Prime(n). ■
Implicit Quantification Consider the statement
If a number is an integer, then it is a rational number.
As shown earlier, this statement is equivalent to a universal statement. However, it does not contain the telltale word all or every or any or each. The only clue to indicate its universal quantification comes from the presence of the indefinite article a. This is an example of implicit universal quantification.
Existential quantification can also be implicit. For instance, the statement “The num- ber 24 can be written as a sum of two even integers” can be expressed formally as “∃ even integers m and n such that 24 = m + n.”
Mathematical writing contains many examples of implicitly quantified statements. Some occur, as in the first example above, through the presence of the word a or an. Others occur in cases where the general context of a sentence supplies part of its meaning. For example, in an algebra course in which the letter x is always used to indicate a real number, the predicate
If x > 2 then x2 > 4
is interpreted to mean the same as the statement
∀ real numbers x, if x > 2 then x2 > 4. Mathematicians often use a double arrow to indicate implicit quantification symbolically. For instance, they might express the above statement as
x > 2 ⇒ x2 > 4.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
104 Chapter 3 The Logic of Quantified Statements
• Notation Let P(x) and Q(x) be predicates and suppose the common domain of x is D.
• The notation P(x) ⇒ Q (x) means that every element in the truth set of P(x) is in the truth set of Q(x), or, equivalently, ∀x, P(x)→ Q(x).
• The notation P(x) ⇔ Q (x) means that P(x) and Q(x) have identical truth sets, or, equivalently, ∀x, P(x)↔ Q(x).
Example 3.1.12 Using ⇒ and ⇔ Let
Q(n) be “n is a factor of 8,”
R(n) be “n is a factor of 4,”
S(n) be “n < 5 and n �= 3,” and suppose the domain of n is Z+, the set of positive integers. Use the⇒ and⇔ symbols to indicate true relationships among Q(n), R(n), and S(n). Solution 1. As noted in Example 3.1.2, the truth set of Q(n) is {1, 2, 4, 8} when the domain of n is Z+. By similar reasoning the truth set of R(n) is {1, 2, 4}. Thus it is true that every element in the truth set of R(n) is in the truth set of Q(n), or, equivalently, ∀n in Z+, R(n)→ Q(n). So R(n)⇒ Q(n), or, equivalently n is a factor of 4 ⇒ n is a factor of 8. 2. The truth set of S(n) is {1, 2, 4}, which is identical to the truth set of R(n), or, equiv- alently, ∀n in Z+, R(n)↔ S(n). So R(n)⇔ S(n), or, equivalently, n is a factor of 4 ⇔ n < 5 and n �= 3. Moreover, since every element in the truth set of S(n) is in the truth set of Q(n), or, equivalently, ∀n in Z+, S(n)→ Q(n), then S(n)⇒ Q(n), or, equivalently, n < 5 and n �= 3 ⇒ n is a factor of 8. ■ Some questions of quantification can be quite subtle. For instance, a mathematics text might contain the following: a. (x + 1)2 = x2 + 2x + 1. b. Solve 3x − 4 = 5. Although neither (a) nor (b) contains explicit quantification, the reader is supposed to understand that the x in (a) is universally quantified whereas the x in (b) is existentially quantified. When the quantification is made explicit, (a) and (b) become a. ∀ real numbers x, (x + 1)2 = x2 + 2x + 1. b. Show (by finding a value) that ∃ a real number x such that 3x − 4 = 5. The quantification of a statement—whether universal or existential—crucially deter- mines both how the statement can be applied and what method must be used to establish its truth. Thus it is important to be alert to the presence of hidden quantifiers when you read mathematics so that you will interpret statements in a logically correct way. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 3.1 Predicates and Quantified Statements I 105 Tarski’s World Tarski’s World is a computer program developed by information scientists Jon Barwise and John Etchemendy to help teach the principles of logic. It is described in their book The Language of First-Order Logic, which is accompanied by a CD-Rom containing the program Tarski’s World, named after the great logician Alfred Tarski. Example 3.1.13 Investigating Tarski’s World The program for Tarski’s World provides pictures of blocks of various sizes, shapes, and colors, which are located on a grid. Shown in Figure 3.1.1 is a picture of an arrangement of objects in a two-dimensional Tarski world. The configuration can be described using logical operators and—for the two-dimensional version—notation such as Triangle(x), meaning “x is a triangle,” Blue(y), meaning “y is blue,” and RightOf(x, y), meaning “x is to the right of y (but possibly in a different row).” Individual objects can be given names such as a, b, or c. Alfred Tarski (1902–1983) ba d f i k e h j c g Figure 3.1.1 Determine the truth or falsity of each of the following statements. The domain for all variables is the set of objects in the Tarski world shown above. a. ∀t , Triangle(t)→ Blue(t). b. ∀x , Blue(x)→ Triangle(x). c. ∃y such that Square(y)∧ RightOf(d, y). d. ∃z such that Square(z)∧ Gray(z). Solution a. This statement is true: All the triangles are blue. b. This statement is false. As a counterexample, note that e is blue and it is not a triangle. c. This statement is true because e and h are both square and d is to their right. d. This statement is false: All the squares are either blue or black. ■ Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 106 Chapter 3 The Logic of Quantified Statements Test Yourself Answers to Test Yourself questions are located at the end of each section. 1. If P(x) is a predicate with domain D, the truth set of P(x) is denoted . We read these symbols out loud as . 2. Some ways to express the symbol ∀ in words are . 3. Some ways to express the symbol ∃ in words are . 4. A statement of the form ∀x ∈ D, Q(x) is true if, and only if, Q(x) is for . 5. A statement of the form ∃x ∈ D such that Q(x) is true if, and only if, Q(x) is for . Exercise Set 3.1* 1. A menagerie consists of seven brown dogs, two black dogs, six gray cats, ten black cats, five blue birds, six yellow birds, and one black bird. Determine which of the following state- ments are true and which are false. a. There is an animal in the menagerie that is red. b. Every animal in the menagerie is a bird or a mammal. c. Every animal in the menagerie is brown or gray or black. d. There is an animal in the menagerie that is neither a cat nor a dog. e. No animal in the menagerie is blue. f. There are in the menagerie a dog, a cat, and a bird that all have the same color. 2. Indicate which of the following statements are true and which are false. Justify your answers as best as you can. a. Every integer is a real number. b. 0 is a positive real number. c. For all real numbers r,−r is a negative real number. d. Every real number is an integer. 3. Let P(x) be the predicate “x > 1/x .” a. Write P(2), P( 12 ), P(−1), P(− 12 ), and P(−8), and
indicate which of these statements are true and which are false.
b. Find the truth set of P(x) if the domain of x is R, the set of all real numbers.
c. If the domain is the set R+ of all positive real numbers, what is the truth set of P(x)?
4. Let Q(n) be the predicate “n2 ≤ 30.” a. Write Q(2), Q(−2), Q(7), and Q(−7), and indicate
which of these statements are true and which are false. b. Find the truth set of Q(n) if the domain of n is Z, the set
of all integers. c. If the domain is the set Z+ of all positive integers, what
is the truth set of Q(n)?
5. Let Q(x, y) be the predicate “If x < y then x2 < y2” with domain for both x and y being the set R of real numbers. a. Explain why Q(x, y) is false if x = −2 and y = 1. b. Give values different from those in part (a) for which Q(x, y) is false. c. Explain why Q(x, y) is true if x = 3 and y = 8. d. Give values different from those in part (c) for which Q(x, y) is true. 6. Let R(m, n) be the predicate “If m is a factor of n2 then m is a factor of n,” with domain for both m and n being the set Z of integers. a. Explain why R(m, n) is false if m = 25 and n = 10. b. Give values different from those in part (a) for which R(m, n) is false. c. Explain why R(m, n) is true if m = 5 and n = 10. d. Give values different from those in part (c) for which R(m, n) is true. 7. Find the truth set of each predicate. a. predicate: 6/d is an integer, domain: Z b. predicate: 6/d is an integer, domain: Z+ c. predicate: 1 ≤ x2 ≤ 4, domain: R d. predicate: 1 ≤ x2 ≤ 4, domain: Z 8. Let B(x) be “−10 < x < 10.” Find the truth set of B(x) for each of the following domains. a. Z b. Z+ c. The set of all even integers Find counterexamples to show that the statements in 9–12 are false. 9. ∀x ∈ R, x > 1/x . 10. ∀a ∈ Z, (a − 1)/a is not an integer. 11. ∀ positive integers m and n,m ·n ≥ m + n. 12. ∀ real numbers x and y,√x + y = √x +√y. 13. Consider the following statement:
∀ basketball players x, x is tall. Which of the following are equivalent ways of expressing this statement? a. Every basketball player is tall. b. Among all the basketball players, some are tall. c. Some of all the tall people are basketball players. d. Anyone who is tall is a basketball player. e. All people who are basketball players are tall. f. Anyone who is a basketball player is a tall person.
∗For exercises with blue numbers or letters, solutions are given in Appendix B. The symbol H indicates that only a hint or a partial solution is given. The symbol ✶ signals that an exercise is more challenging than usual.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3.1 Predicates and Quantified Statements I 107
14. Consider the following statement:
∃x ∈ R such that x2 = 2. Which of the following are equivalent ways of expressing this statement? a. The square of each real number is 2. b. Some real numbers have square 2. c. The number x has square 2, for some real number x . d. If x is a real number, then x2 = 2. e. Some real number has square 2. f. There is at least one real number whose square is 2.
15.H Rewrite the following statements informally in at least two different ways without using variables or quantifiers. a. ∀ rectangles x, x is a quadrilateral. b. ∃ a set A such that A has 16 subsets.
16. Rewrite each of the following statements in the form “∀ x, .” a. All dinosaurs are extinct. b. Every real number is positive, negative, or zero. c. No irrational numbers are integers. d. No logicians are lazy. e. The number 2,147,581,953 is not equal to the square of
any integer. f. The number −1 is not equal to the square of any real
number.
17. Rewrite each of the following in the form “∃ x such that .” a. Some exercises have answers. b. Some real numbers are rational.
18. Let D be the set of all students at your school, and let M(s) be “s is a math major,” let C(s) be “s is a computer sci- ence student,” and let E(s) be “s is an engineering student.” Express each of the following statements using quantifiers, variables, and the predicates M(s),C(s), and E(s). a. There is an engineering student who is a math major. b. Every computer science student is an engineering stu-
dent. c. No computer science students are engineering students. d. Some computer science students are also math majors. e. Some computer science students are engineering stu-
dents and some are not.
19. Consider the following statement:
∀ integers n, if n2 is even then n is even. Which of the following are equivalent ways of expressing this statement? a. All integers have even squares and are even. b. Given any integer whose square is even, that integer is
itself even. c. For all integers, there are some whose square is even. d. Any integer with an even square is even. e. If the square of an integer is even, then that integer is
even. f. All even integers have even squares.
20.H Rewrite the following statement informally in at least two different ways without using variables or the symbol ∀ or the words “for all.”
∀ real numbers x, if x is positive, then the square root of x is positive.
21. Rewrite the following statements so that the quantifier trails the rest of the sentence. a. For any graph G, the total degree of G is even. b. For any isosceles triangle T , the base angles of T are
equal. c. There exists a prime number p such that p is even. d. There exists a continuous function f such that f is not
differentiable.
22. Rewrite each of the following statements in the form “∀ x , if then .” a. All Java programs have at least 5 lines. b. Any valid argument with true premises has a true con-
clusion.
23. Rewrite each of the following statements in the two forms “∀x , if then ” and “∀ x , ” (without an if-then). a. All equilateral triangles are isosceles. b. Every computer science student needs to take data struc-
tures.
24. Rewrite the following statements in the two forms “∃ x such that ” and “∃x such that and .” a. Some hatters are mad. b. Some questions are easy.
25. The statement “The square of any rational number is ratio- nal” can be rewritten formally as “For all rational numbers x , x2 is rational” or as “For all x , if x is rational then x2
is rational.” Rewrite each of the following statements in the two forms “∀ x , ” and “∀x , if , then
” or in the two forms “∀ x and y, ” and “∀x and y, if , then .” a. The reciprocal of any nonzero fraction is a fraction. b. The derivative of any polynomial function is a polyno-
mial function. c. The sum of the angles of any triangle is 180◦. d. The negative of any irrational number is irrational. e. The sum of any two even integers is even. f. The product of any two fractions is a fraction.
26. Consider the statement “All integers are rational numbers but some rational numbers are not integers.” a. Write this statement in the form “∀x , if then
, but ∃ x such that .” b. Let Ratl(x) be “x is a rational number” and Int(x) be “x
is an integer.” Write the given statement formally using only the symbols Ratl(x), Int(x),∀, ∃,∧,∨,∼, and→.
27. Refer to the picture of Tarski’s world given in Example 3.1.13. Let Above(x, y) mean that x is above y (but pos- sibly in a different column). Determine the truth or falsity
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
108 Chapter 3 The Logic of Quantified Statements
of each of the following statements. Give reasons for your answers. a. ∀u, Circle(u)→ Gray(u). b. ∀u, Gray(u)→ Circle(u). c. ∃y such that Square(y) ∧ Above(y, d). d. ∃z such that Triangle(z) ∧ Above( f, z).
In 28–30, rewrite each statement without using quantifiers or variables. Indicate which are true and which are false, and jus- tify your answers as best as you can.
28. Let the domain of x be the set D of objects discussed in mathematics courses, and let Real(x) be “x is a real number,” Pos(x) be “x is a positive real number,” Neg(x) be “x is a negative real number,” and Int(x) be “x is an integer.” a. Pos(0) b. ∀x , Real(x) ∧ Neg(x) → Pos(−x). c. ∀x , Int(x)→ Real(x). d. ∃x such that Real(x) ∧ ∼Int(x).
29. Let the domain of x be the set of geometric figures in the plane, and let Square(x) be “x is a square” and Rect(x) be “x is a rectangle.” a. ∃x such that Rect(x) ∧ Square(x). b. ∃x such that Rect(x) ∧ ∼Square(x). c. ∀x , Square(x)→ Rect(x).
30. Let the domain of x be the set Z of integers, and let Odd(x) be “x is odd,” Prime(x) be “x is prime,” and Square(x) be
“x is a perfect square.” (An integer n is said to be a perfect square if, and only if, it equals the square of some integer. For example, 25 is a perfect square because 25 = 52.) a. ∃x such that Prime(x) ∧ ∼Odd(x). b. ∀x , Prime(x)→∼Square(x). c. ∃x such that Odd(x) ∧ Square(x).
31.H In any mathematics or computer science text other than this book, find an example of a statement that is universal but is implicitly quantified. Copy the statement as it appears and rewrite it making the quantification explicit. Give a com- plete citation for your example, including title, author, pub- lisher, year, and page number.
32. Let R be the domain of the predicate variable x . Which of the following are true and which are false? Give counter examples for the statements that are false. a. x > 2⇒ x > 1 b. x > 2⇒ x2 > 4 c. x2 > 4⇒ x > 2 d. x2 > 4⇔ |x | > 2
33. Let R be the domain of the predicate variables a, b, c, and d. Which of the following are true and which are false? Give counterexamples for the statements that are false. a. a > 0 and b > 0⇒ ab > 0 b. a < 0 and b < 0⇒ ab < 0 c. ab = 0⇒ a = 0 or b = 0 d. a < b and c < d ⇒ ac < bd Answers for Test Yourself 1. {x ∈ D | P(x)}; the set of all x in D such that P(x) 2. Possible answers: for all, for every, for any, for each, for arbitrary, given any 3. Possible answers: there exists, there exist, there exists at least one, for some, for at least one, we can find a 4. true; every x in D (Alternative answers: all x in D; each x in D) 5. true; at least one x in D (Alternative answer: some x in D) 3.2 Predicates and Quantified Statements II TOUCHSTONE: Stand you both forth now: stroke your chins, and swear by your beards that I am a knave. CELIA: By our beards—if we had them—thou art. TOUCHSTONE: By my knavery—if I had it—then I were; but if you swear by that that is not, you are not forsworn. —William Shakespeare, As You Like It This section continues the discussion of predicates and quantified statements begun in Section 3.1. It contains the rules for negating quantified statements; an exploration of the relation among ∀, ∃,∧, and∨; an introduction to the concept of vacuous truth of universal statements; examples of variants of universal conditional statements; and an extension of the meaning of necessary, sufficient, and only if to quantified statements. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 3.2 Predicates and Quantified Statements II 109 Negations of Quantified Statements Consider the statement “All mathematicians wear glasses.” Many people would say that its negation is “No mathematicians wear glasses,” but if even one mathematician does not wear glasses, then the sweeping statement that all mathematicians wear glasses is false. So a correct negation is “There is at least one mathematician who does not wear glasses.” The general form of the negation of a universal statement follows immediately from the definitions of negation and of the truth values for universal and existential statements. Theorem 3.2.1 Negation of a Universal Statement The negation of a statement of the form ∀x in D, Q(x) is logically equivalent to a statement of the form ∃x in D such that ∼Q(x). Symbolically, ∼(∀x ∈ D, Q(x)) ≡ ∃x ∈ D such that ∼Q(x). Thus The negation of a universal statement (“all are”) is logically equivalent to an existential statement (“some are not” or “there is at least one that is not”). Note that when we speak of logical equivalence for quantified statements, we mean that the statements always have identical truth values no matter what predicates are sub- stituted for the predicate symbols and no matter what sets are used for the domains of the predicate variables. Now consider the statement “Some snowflakes are the same.” What is its negation? For this statement to be false means that not a single snowflake is the same as any other. In other words, “No snowflakes are the same,” or “All snowflakes are different.” The general form for the negation of an existential statement follows immediately from the definitions of negation and of the truth values for existential and universal statements. Theorem 3.2.2 Negation of an Existential Statement The negation of a statement of the form ∃x in D such that Q(x) is logically equivalent to a statement of the form ∀x in D,∼Q(x). Symbolically, ∼(∃x ∈ D such that Q(x)) ≡ ∀x ∈ D,∼Q(x). Thus The negation of an existential statement (“some are”) is logically equivalent to a universal statement (“none are” or “all are not”). Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 110 Chapter 3 The Logic of Quantified Statements Example 3.2.1 Negating Quantified Statements Write formal negations for the following statements: a. ∀ primes p, p is odd. b. ∃ a triangle T such that the sum of the angles of T equals 200◦. Solution a. By applying the rule for the negation of a ∀ statement, you can see that the answer is ∃ a prime p such that p is not odd. b. By applying the rule for the negation of a ∃ statement, you can see that the answer is ∀ triangles T, the sum of the angles of T does not equal 200◦. ■ You need to exercise special care to avoid mistakes when writing negations of state- ments that are given informally. One way to avoid error is to rewrite the statement for- mally and take the negation using the formal rule. Example 3.2.2 More Negations Rewrite the following statement formally. Then write formal and informal negations. No politicians are honest. Solution Formal version: ∀ politicians x, x is not honest. Formal negation: ∃ a politician x such that x is honest. Informal negation: Some politicians are honest. ■ Another way to avoid error when taking negations of statements that are given in informal language is to ask yourself, “What exactlywould it mean for the given statement to be false?What statement, if true, would be equivalent to saying that the given statement is false?” Example 3.2.3 Still More Negations Write informal negations for the following statements: a. All computer programs are finite. b. Some computer hackers are over 40. c. The number 1,357 is divisible by some integer between 1 and 37. Solution a. What exactly would it mean for this statement to be false? The statement asserts that all computer programs satisfy a certain property. So for it to be false, there would have to be at least one computer program that does not satisfy the property. Thus the answer is There is a computer program that is not finite. Or: Some computer programs are infinite. b. This statement is equivalent to saying that there is at least one computer hacker with a certain property. So for it to be false, not a single computer hacker can have that property. Thus the negation is No computer hackers are over 40. Or: All computer hackers are 40 or under. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 3.2 Predicates and Quantified Statements II 111 c. This statement has a trailing quantifier. Written formally it becomes:Note Which is true: the statement in part (c) or its negation? Is 1,357 divisible by some integer between 1 and 37? Or is 1,357 not divisible by any integer between 1 and 37? ∃ an integer n between 1 and 37 such that 1,357 is divisible by n. Its negation is therefore ∀ integers n between 1 and 37; 1,357 is not divisible by n. An informal version of the negation is The number 1,357 is not divisible by any integer between 1 and 37. ■ ! Caution! Just inserting the word not to negate a quantified statement can result in a statement that is ambiguous. Informal negations of many universal statements can be constructed simply by insert- ing the word not or the words do not at an appropriate place. However, the resulting state- ments may be ambiguous. For example, a possible negation of “All mathematicians wear glasses” is “All mathematicians do not wear glasses.” The problem is that this sentence has two meanings. With the proper verbal stress on the word not, it could be interpreted as the logical negation. (What! You say that all mathematicians wear glasses? Nonsense! All mathematicians do not wear glasses.) On the other hand, stated in a flat tone of voice (try it!), it would mean that all mathematicians are nonwearers of glasses; that is, not a single mathematician wears glasses. This is a much stronger statement than the logical negation: It implies the negation but is not equivalent to it. Negations of Universal Conditional Statements Negations of universal conditional statements are of special importance in mathematics. The form of such negations can be derived from facts that have already been established. By definition of the negation of a for all statement, ∼(∀x, P(x)→ Q(x)) ≡ ∃x such that ∼(P(x)→ Q(x)). 3.2.1 But the negation of an if-then statement is logically equivalent to an and statement. More precisely, ∼(P(x)→ Q(x)) ≡ P(x) ∧ ∼Q(x). 3.2.2 Substituting (3.2.2) into (3.2.1) gives ∼(∀x, P(x)→ Q(x)) ≡ ∃x such that (P(x)∧ ∼Q(x)). Written less symbolically, this becomes Negation of a Universal Conditional Statement ∼(∀x, if P(x) then Q(x)) ≡ ∃x such that P(x) and ∼Q(x). Example 3.2.4 Negating Universal Conditional Statements Write a formal negation for statement (a) and an informal negation for statement (b). a. ∀ people p, if p is blond then p has blue eyes. b. If a computer program has more than 100,000 lines, then it contains a bug. Solution a. ∃ a person p such that p is blond and p does not have blue eyes. b. There is at least one computer program that has more than 100,000 lines and does not contain a bug. ■ Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 112 Chapter 3 The Logic of Quantified Statements The Relation among ∀, ∃, ∧, and ∨ The negation of a for all statement is a there exists statement, and the negation of a there exists statement is a for all statement. These facts are analogous to De Morgan’s laws, which state that the negation of an and statement is an or statement and that the nega- tion of an or statement is an and statement. This similarity is not accidental. In a sense, universal statements are generalizations of and statements, and existential statements are generalizations of or statements. If Q(x) is a predicate and the domain D of x is the set {x1, x2, . . . , xn}, then the statements ∀x ∈ D, Q(x) and Q(x1) ∧ Q(x2) ∧ · · · ∧ Q(xn) are logically equivalent. For example, let Q(x) be “x ·x = x” and suppose D = {0, 1}. Then ∀x ∈ D, Q(x) can be rewritten as ∀ binary digits x, x ·x = x . This is equivalent to 0 ·0 = 0 and 1 ·1 = 1, which can be rewritten in symbols as Q(0) ∧ Q(1). Similarly, if Q(x) is a predicate and D = {x1, x2, . . . , xn}, then the statements ∃x ∈ D such that Q(x) and Q(x1) ∨ Q(x2) ∨ · · · ∨ Q(xn) are logically equivalent. For example, let Q(x) be “x + x = x” and suppose D = {0, 1}. Then ∃x ∈ D such that Q(x) can be rewritten as ∃ a binary digit x such that x + x = x . This is equivalent to 0+ 0 = 0 or 1+ 1 = 1, which can be rewritten in symbols as Q(0) ∨ Q(1). Vacuous Truth of Universal Statements Suppose a bowl sits on a table and next to the bowl is a pile of five blue and five gray balls, any of which may be placed in the bowl. If three blue balls and one gray ball are placed in the bowl, as shown in Figure 3.2.1(a), the statement “All the balls in the bowl are blue” would be false (since one of the balls in the bowl is gray). Now suppose that no balls at all are placed in the bowl, as shown in Figure 3.2.1(b). Consider the statement All the balls in the bowl are blue. Is this statement true or false? The statement is false if, and only if, its negation is true. And its negation is There exists a ball in the bowl that is not blue. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 3.2 Predicates and Quantified Statements II 113 But the only way this negation can be true is for there actually to be a nonblue ball in the bowl. And there is not! Hence the negation is false, and so the statement is true “by default.” (a) (b) Figure 3.2.1 In general, a statement of the form ∀x in D, if P(x) then Q(x) is called vacuously true or true by default if, and only if, P(x) is false for every x in D. By the way, in ordinary language the words in general mean that something is usu- ally, but not always, the case. (In general, I take the bus home, but today I walked.) In mathematics, the words in general are used quite differently. When they occur just after discussion of a particular example (as in the preceding paragraph), they are a signal that what is to follow is a generalization of some aspect of the example that always holds true. Variants of Universal Conditional Statements Recall from Section 2.2 that a conditional statement has a contrapositive, a converse, and an inverse. The definitions of these terms can be extended to universal conditional statements. • Definition Consider a statement of the form: ∀x ∈ D, if P(x) then Q(x). 1. Its contrapositive is the statement: ∀x ∈ D, if ∼Q(x) then ∼P(x). 2. Its converse is the statement: ∀x ∈ D, if Q(x) then P(x). 3. Its inverse is the statement: ∀x ∈ D, if ∼P(x) then ∼Q(x). Example 3.2.5 Contrapositive, Converse, and Inverse of a Universal Conditional Statement Write a formal and an informal contrapositive, converse, and inverse for the following statement: If a real number is greater than 2, then its square is greater than 4. Solution The formal version of this statement is ∀x ∈ R, if x > 2 then x2 > 4. Contrapositive: ∀x ∈ R, if x2 ≤ 4 then x ≤ 2.
Or: If the square of a real number is less than or equal to 4, then the number is less than or equal to 2.
Converse: ∀x ∈ R, if x2 > 4 then x > 2. Or: If the square of a real number is greater than 4, then the number is greater than 2.
Inverse: ∀x ∈ R, if x ≤ 2 then x2 ≤ 4. Or: If a real number is less than or equal to 2, then the square of the number is less than or equal to 4.
Note that in solving this example, we have used the equivalence of “x ≯ a” and “x ≤ a” for all real numbers x and a. (See page 33.) ■
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
114 Chapter 3 The Logic of Quantified Statements
In Section 2.2 we showed that a conditional statement is logically equivalent to its contrapositive and that it is not logically equivalent to either its converse or its inverse. The following discussion shows that these facts generalize to the case of universal condi- tional statements and their contrapositives, converses, and inverses.
Let P(x) and Q(x) be any predicates, let D be the domain of x , and consider the statement
∀x ∈ D, if P(x) then Q(x) and its contrapositive
∀x ∈ D, if ∼Q(x) then ∼P(x). Any particular x in D that makes “if P(x) then Q(x)” true also makes “if ∼Q(x) then ∼P(x)” true (by the logical equivalence between p→ q and ∼q →∼p). It follows that the sentence “If P(x) then Q(x)” is true for all x in D if, and only if, the sentence “If ∼Q(x) then ∼P(x)” is true for all x in D.
Thus we write the following and say that a universal conditional statement is logically equivalent to its contrapositive:
∀x ∈ D, if P(x) then Q(x) ≡ ∀x ∈ D, if ∼Q(x) then ∼P(x)
In Example 3.2.5 we noted that the statement
∀x ∈ R, if x > 2 then x2 > 4 has the converse ∀x ∈ R, if x2 > 4 then x > 2. Observe that the statement is true whereas its converse is false (since, for instance, (−3)2 = 9 > 4 but −3 ≯ 2). This shows that a universal conditional statement may have a different truth value from its converse. Hence a universal conditional statement is not logically equivalent to its converse. This is written in symbols as follows:
∀x ∈ D, if P(x) then Q(x) ≡/ ∀x ∈ D, if Q(x) then P(x).
In the exercises at the end of this section, you are asked to show similarly that a universal conditional statement is not logically equivalent to its inverse.
∀x ∈ D, if P(x) then Q(x) ≡/ ∀x ∈ D, if ∼P(x) then ∼Q(x).
Necessary and Sufficient Conditions, Only If The definitions of necessary, sufficient, and only if can also be extended to apply to uni- versal conditional statements.
• Definition • “∀x, r(x) is a sufficient condition for s(x)” means “∀x , if r(x) then s(x).” • “∀x, r(x) is a necessary condition for s(x)” means “∀x , if ∼r(x) then ∼s(x)” or, equivalently, “∀x , if s(x) then r(x).”
• “∀x, r(x) only if s(x)” means “∀x , if ∼s(x) then ∼r(x)” or, equivalently, “∀x , if r(x) then s(x).”
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3.2 Predicates and Quantified Statements II 115
Example 3.2.6 Necessary and Sufficient Conditions
Rewrite the following statements as quantified conditional statements. Do not use the word necessary or sufficient.
a. Squareness is a sufficient condition for rectangularity.
b. Being at least 35 years old is a necessary condition for being President of the United States.
Solution
a. A formal version of the statement is
∀x , if x is a square, then x is a rectangle. Or, in informal language:
If a figure is a square, then it is a rectangle.
b. Using formal language, you could write the answer as
∀ people x, if x is younger than 35, then x cannot be President of the United States.
Or, by the equivalence between a statement and its contrapositive:
∀ people x, if x is President of the United States, then x is at least 35 years old. ■
Example 3.2.7 Only If
Rewrite the following as a universal conditional statement:
A product of two numbers is 0 only if one of the numbers is 0.
Solution Using informal language, you could write the answer as
If neither of two numbers is 0, then the product of the numbers is not 0.
Or, by the equivalence between a statement and its contrapositive,
If a product of two numbers is 0, then one of the numbers is 0. ■
Test Yourself 1. A negation for “All R have property S” is “There is R
that .”
2. A negation for “Some R have property S” is “ .”
3. A negation for “For all x , if x has property P then x has property Q” is “ .”
4. The converse of “For all x , if x has property P then x has property Q” is “ .”
5. The contrapositive of “For all x , if x has property P then x has property Q” is “ .”
6. The inverse of “For all x , if x has property P then x has property Q” is “ .”
Exercise Set 3.2 1. Which of the following is a negation for “All discrete math-
ematics students are athletic”? More than one answer may be correct. a. There is a discrete mathematics student who is nonath-
letic. b. All discrete mathematics students are nonathletic.
c. There is an athletic person who is a discrete mathematics student.
d. No discrete mathematics students are athletic. e. Some discrete mathematics students are nonathletic. f. No athletic people are discrete mathematics students.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
116 Chapter 3 The Logic of Quantified Statements
2. Which of the following is a negation for “All dogs are loyal”? More than one answer may be correct. a. All dogs are disloyal. b. No dogs are loyal. c. Some dogs are disloyal. d. Some dogs are loyal. e. There is a disloyal animal that is not a dog. f. There is a dog that is disloyal. g. No animals that are not dogs are loyal. h. Some animals that are not dogs are loyal.
3. Write a formal negation for each of the following state- ments: a. ∀ fish x, x has gills. b. ∀ computers c, c has a CPU. c. ∃ a movie m such that m is over 6 hours long. d. ∃ a band b such that b has won at least 10 Grammy
awards.
4. Write an informal negation for each of the following state- ments. Be careful to avoid negations that are ambiguous. a. All dogs are friendly. b. All people are happy. c. Some suspicions were substantiated. d. Some estimates are accurate.
5. Write a negation for each of the following statements. a. Any valid argument has a true conclusion. b. Every real number is positive, negative, or zero.
6. Write a negation for each of the following statements. a. Sets A and B do not have any points in common. b. Towns P and Q are not connected by any road on the
map.
7. Informal language is actually more complex than formal language. For instance, the sentence “There are no orders from store A for item B” contains the words there are. Is the statement existential? Write an informal negation for the statement, and then write the statement formally using quantifiers and variables.
8. Consider the statement “There are no simple solutions to life’s problems.” Write an informal negation for the state- ment, and then write the statement formally using quanti- fiers and variables.
Write a negation for each statement in 9 and 10.
9. ∀ real numbers x , if x > 3 then x2 > 9. 10. ∀ computer programs P , if P compiles without error mes-
sages, then P is correct.
In each of 11–14 determine whether the proposed negation is correct. If it is not, write a correct negation.
11. Statement: The sum of any two irrational numbers is irrational.
Proposed negation: The sum of any two irrational numbers is rational.
12. Statement: The product of any irrational number and any rational number is irrational.
Proposed negation: The product of any irrational number and any rational number is rational.
13. Statement: For all integers n, if n2 is even then n is even.
Proposed negation: For all integers n, if n2 is even then n is not even.
14. Statement: For all real numbers x1 and x2, if x21 = x22 then x1 = x2.
Proposed negation: For all real numbers x1 and x2, if x21 = x22 then x1 �= x2.
15. Let D = {−48, −14, −8, 0, 1, 3, 16, 23, 26, 32, 36}. Determine which of the following statements are true and which are false. Provide counterexamples for those state- ments that are false. a. ∀x ∈ D, if x is odd then x > 0. b. ∀x ∈ D, if x is less than 0 then x is even. c. ∀x ∈ D, if x is even then x ≤ 0. d. ∀x ∈ D, if the ones digit of x is 2, then the tens digit is
3 or 4. e. ∀x ∈ D, if the ones digit of x is 6, then the tens digit is
1 or 2.
In 16–23, write a negation for each statement.
16. ∀ real numbers x , if x2 ≥ 1 then x > 0. 17. ∀ integers d, if 6/d is an integer then d = 3. 18. ∀x ∈ R, if x(x + 1) > 0 then x > 0 or x < −1. 19. ∀n ∈ Z, if n is prime then n is odd or n = 2. 20. ∀ integers a, b and c, if a − b is even and b − c is even, then a − c is even. 21. ∀ integers n, if n is divisible by 6, then n is divisible by 2 and n is divisible by 3. 22. If the square of an integer is odd, then the integer is odd. 23. If a function is differentiable then it is continuous. 24. Rewrite the statements in each pair in if-then form and indi- cate the logical relationship between them. a. All the children in Tom’s family are female. All the females in Tom’s family are children. b. All the integers that are greater than 5 and end in 1, 3, 7, or 9 are prime. All the integers that are greater than 5 and are prime end in 1, 3, 7, or 9. 25. Each of the following statements is true. In each case write the converse of the statement, and give a counterexample showing that the converse is false. a. If n is any prime number that is greater than 2, then n + 1 is even. b. If m is any odd integer, then 2m is even. c. If two circles intersect in exactly two points, then they do not have a common center. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 3.3 Statements with Multiple Quantifiers 117 In 26–33, for each statement in the referenced exercise write the converse, inverse, and contrapositive. Indicate as best as you can which among the statement, its converse, its inverse, and its con- trapositive are true and which are false. Give a counterexample for each that is false. 26. Exercise 16 27. Exercise 17 28. Exercise 18 29. Exercise 19 30. Exercise 20 31. Exercise 21 32. Exercise 22 33. Exercise 23 34. Write the contrapositive for each of the following state- ments. a. If n is prime, then n is not divisible by any prime num- ber between 1 and √ n strictly. (Assume that n is a fixed integer that is greater than 1.) b. If A and B do not have any elements in common, then they are disjoint. (Assume that A and B are fixed sets.) 35. Give an example to show that a universal conditional state- ment is not logically equivalent to its inverse. 36.✶ If P(x) is a predicate and the domain of x is the set of all real numbers, let R be “∀x ∈ Z, P(x),” let S be “∀x ∈ Q, P(x),” and let T be “∀x ∈ R, P(x).” a. Find a definition for P(x) (but do not use “x ∈ Z”) so that R is true and both S and T are false. b. Find a definition for P(x) (but do not use “x ∈ Q”) so that both R and S are true and T is false. 37. Consider the following sequence of digits: 0204. A person claims that all the 1’s in the sequence are to the left of all the 0’s in the sequence. Is this true? Justify your answer. (Hint: Write the claim formally and write a formal negation for it. Is the negation true or false?) 38. True or false? All occurrences of the letter u in Discrete Mathematics are lowercase. Justify your answer. Rewrite each statement of 39–42 in if-then form. 39. Earning a grade of C− in this course is a sufficient condi- tion for it to count toward graduation. 40. Being divisible by 8 is a sufficient condition for being divis- ible by 4. 41. Being on time each day is a necessary condition for keeping this job. 42. Passing a comprehensive exam is a necessary condition for obtaining a master’s degree. Use the facts that the negation of a ∀ statement is a ∃ statement and that the negation of an if-then statement is an and statement to rewrite each of the statements 43–46 without using the word necessary or sufficient. 43. Being divisible by 8 is not a necessary condition for being divisible by 4. 44. Having a large income is not a necessary condition for a person to be happy. 45. Having a large income is not a sufficient condition for a person to be happy. 46. Being a polynomial is not a sufficient condition for a func- tion to have a real root. 47. The computer scientists Richard Conway and David Gries once wrote: The absence of error messages during translation of a computer program is only a necessary and not a sufficient condition for reasonable [program] correctness. Rewrite this statement without using the words necessary or sufficient. 48. A frequent-flyer club brochure states, “You may select among carriers only if they offer the same lowest fare.” Assuming that “only if” has its formal, logical meaning, does this statement guarantee that if two carriers offer the same lowest fare, the customer will be free to choose between them? Explain. Answers for Test Yourself 1. some (Alternative answers: at least one; an); does not have property S. 2. No R have property S. 3. There is an x such that x has property P and x does not have property Q. 4. For all x , if x has property Q then x has property P . 5. For all x , if x does not have property Q then x does not have property P . 6. For all x , if x does not have property P then x does not have property Q. 3.3 Statements with Multiple Quantifiers It is not enough to have a good mind. The main thing is to use it well. —René Descartes Imagine you are visiting a factory that manufactures computer microchips. The factory guide tells you, There is a person supervising every detail of the production process. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 118 Chapter 3 The Logic of Quantified Statements Note that this statement contains informal versions of both the existential quantifier there is and the universal quantifier every. Which of the following best describes its meaning? • There is one single person who supervises all the details of the production process. • For any particular production detail, there is a person who supervises that detail, but there might be different supervisors for different details. As it happens, either interpretation could be what the guide meant. (Reread the sentence to be sure you agree!) Taken by itself, his statement is genuinely ambiguous, although other things he may have said (the context for his statement) might have clarified it. In our ordinary lives, we deal with this kind of ambiguity all the time. Usually context helps resolve it, but sometimes we simply misunderstand each other. In mathematics, formal logic, and computer science, by contrast, it is essential that we all interpret statements in exactly the same way. For instance, the initial stage of software development typically involves careful discussion between a programmer analyst and a client to turn vague descriptions of what the client wants into unambiguous program specifications that client and programmer can mutually agree on. Because many important technical statements contain both ∃ and ∀, a convention has developed for interpreting them uniformly. When a statement contains more than one quantifier, we imagine the actions suggested by the quantifiers as being performed in the order in which the quantifiers occur. For instance, consider a statement of the form ∀x in set D, ∃y in set E such that x and y satisfy property P(x, y). To show that such a statement is true, you must be able to meet the following challenge: • Imagine that someone is allowed to choose any element whatsoever from the set D, and imagine that the person gives you that element. Call it x . • The challenge for you is to find an element y in E so that the person’s x and your y, taken together, satisfy property P(x, y). Note that because you do not have to specify the y until after the other person has specified the x, you are allowed to find a different value of y for each different x you are given. Example 3.3.1 Truth of a ∀∃ Statement in a Tarski World Consider the Tarski world shown in Figure 3.3.1. a b c f i e g h j d Figure 3.3.1 Show that the following statement is true in this world: For all triangles x , there is a square y such that x and y have the same color. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 3.3 Statements with Multiple Quantifiers 119 Solution The statement says that no matter which triangle someone gives you, you will be able to find a square of the same color. There are only three triangles, d, f , and i . The following table shows that for each of these triangles a square of the same color can be found. Given x = choose y = and check that y is the same color as x. d e yes � f or i h or g yes � ■ Now consider a statement containing both ∀ and ∃, where the ∃ comes before the ∀: ∃ an x in D such that ∀y in E, x and y satisfy property P(x, y). To show that a statement of this form is true: You must find one single element (call it x) in D with the following property: • After you have found your x , someone is allowed to choose any element whatsoever from E . The person challenges you by giving you that element. Call it y. • Your job is to show that your x together with the person’s y satisfy property P(x, y). Note that your x has to work for any y the person gives you; you are not allowed to change your x once you have specified it initially. Example 3.3.2 Truth of a ∃∀ Statement in a Tarski World Consider again the Tarski world in Figure 3.3.1. Show that the following statement is true: There is a triangle x such that for all circles y, x is to the right of y. Solution The statement says that you can find a triangle that is to the right of all the circles. Actually, either d or i would work for all of the three circles, a, b, and c, as you can see in the following table. Choose x = Then, given y = check that x is to the right of y. d or i a yes � b yes � c yes � ■ Here is a summary of the convention for interpreting statements with two different quantifiers: Interpreting Statements with Two Different Quantifiers If you want to establish the truth of a statement of the form ∀x in D, ∃y in E such that P(x, y) your challenge is to allow someone else to pick whatever element x in D they wish and then you must find an element y in E that “works” for that particular x . If you want to establish the truth of a statement of the form ∃x in D such that ∀y in E, P(x, y) your job is to find one particular x in D that will “work” no matter what y in E anyone might choose to challenge you with. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 120 Chapter 3 The Logic of Quantified Statements Example 3.3.3 Interpreting Multiply-Quantified∗ Statements A college cafeteria line has four stations: salads, main courses, desserts, and beverages. The salad station offers a choice of green salad or fruit salad; the main course station offers spaghetti or fish; the dessert station offers pie or cake; and the beverage station offers milk, soda, or coffee. Three students, Uta, Tim, and Yuen, go through the line and make the following choices: Uta: green salad, spaghetti, pie, milk Tim: fruit salad, fish, pie, cake, milk, coffee Yuen: spaghetti, fish, pie, soda These choices are illustrated in Figure 3.3.2. green salad fruit salad Salads spaghetti fish Main courses pie cake Desserts milk soda coffee Beverages Uta Tim Yuen Figure 3.3.2 Write each of following statements informally and find its truth value. a. ∃ an item I such that ∀ students S, S chose I . b. ∃ a student S such that ∀ items I, S chose I . c. ∃ a student S such that ∀ stations Z , ∃ an item I in Z such that S chose I . d. ∀ students S and ∀ stations Z , ∃ an item I in Z such that S chose I . Solution a. There is an item that was chosen by every student. This is true; every student chose pie. b. There is a student who chose every available item. This is false; no student chose all nine items. c. There is a student who chose at least one item from every station. This is true; both Uta and Tim chose at least one item from every station. d. Every student chose at least one item from every station. This is false; Yuen did not choose a salad. ■ ∗The term “multiply-quantified” is pronounced MUL-ti-plee QUAN-ti-fied. A multiply-quantified statement is a statement that contains more than one quantifier.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3.3 Statements with Multiple Quantifiers 121
Translating from Informal to Formal Language Most problems are stated in informal language, but solving them often requires translating them into more formal terms.
Example 3.3.4 Translating Multiply-Quantified Statements from Informal to Formal Language
The reciprocal of a real number a is a real number b such that ab = 1. The following two statements are true. Rewrite them formally using quantifiers and variables:
a. Every nonzero real number has a reciprocal.
b. There is a real number with no reciprocal. The number 0 has no reciprocal.
Solution
a. ∀ nonzero real numbers u, ∃ a real number v such that uv = 1. b. ∃ a real number c such that ∀ real numbers d, cd �= 1. ■
Example 3.3.5 There Is a Smallest Positive Integer
Recall that every integer is a real number and that real numbers are of three types: posi- tive, negative, and zero (zero being neither positive nor negative). Consider the statement “There is a smallest positive integer.” Write this statement formally using both symbols ∃ and ∀.
Solution To say that there is a smallest positive integer means that there is a positive integer m with the property that no matter what positive integer n a person might pick, m will be less than or equal to n:
∃ a positive integerm such that ∀ positive integers n,m ≤ n. Note that this statement is true because 1 is a positive integer that is less than or equal to every positive integer.
–3–4–5 –2 –1 0 1 2 3 4 5
positive integers
■
Example 3.3.6 There Is No Smallest Positive Real Number
Imagine any positive real number x on the real number line. These numbers correspond to all the points to the right of 0. Observe that no matter how small x is, the number x/2 will be both positive and less than x .∗
–2 –1 0 1 2x
x 2
∗This can be deduced from the properties of the real numbers given in Appendix A. Because x is positive, 0 < x . Add x to both sides to obtain x < 2x . Then 0 < x < 2x . Now multiply all parts of the inequality by the positive number 1/2. This does not change the direction of the inequality, so 0 < x/2 < x . Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 122 Chapter 3 The Logic of Quantified Statements Thus the following statement is true: “There is no smallest positive real number.” Write this statement formally using both symbols ∀ and ∃. Solution ∀ positive real numbers x, ∃ a positive real number y such that y < x . ■ Example 3.3.7 The Definition of Limit of a Sequence The definition of limit of a sequence, studied in calculus, uses both quantifiers ∀ and ∃ and also if-then. We say that the limit of the sequence an as n goes to infinity equals L and write lim n→∞ an = L if, and only if, the values of an become arbitrarily close to L as n gets larger and larger without bound. More precisely, this means that given any positive number ε, we can find an integer N such that whenever n is larger than N , the number an sits between L − ε and L + ε on the number line. L – ε L + εL an must lie in here when n > N
Symbolically:
∀ε > 0, ∃ an integer N such that ∀ integers n, if n > N then L − ε < an < L + ε. Considering the logical complexity of this definition, it is no wonder that many students find it hard to understand. ■ Ambiguous Language The drawing in Figure 3.3.3 is a famous example of visual ambiguity. When you look at it for a while, you will probably see either a silhouette of a young woman wearing a large hat or an elderly woman with a large nose. Whichever image first pops into your mind, Figure 3.3.3 Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 3.3 Statements with Multiple Quantifiers 123 try to see how the drawing can be interpreted in the other way. (Hint: The mouth of the elderly woman is the necklace on the young woman.) Once most people see one of the images, it is difficult for them to perceive the other. So it is with ambiguous language. Once you interpreted the sentence at the beginning of this section in one way, it may have been hard for you to see that it could be understood in the other way. Perhaps you had difficulty even though the two possible meanings were explained, just as many people have difficulty seeing the second interpretation for the drawing even when they are told what to look for. Although statements written informally may be open to multiple interpretations, we cannot determine their truth or falsity without interpreting them one way or another. Therefore, we have to use context to try to ascertain their meaning as best we can. Negations of Multiply-Quantified Statements You can use the same rules to negate multiply-quantified statements that you used to negate simpler quantified statements. Recall that ∼(∀x in D, P(x)) ≡ ∃x in D such that ∼P(x). and ∼(∃x in D such that P(x)) ≡ ∀x in D,∼P(x). We apply these laws to find ∼(∀x in D, ∃y in E such that P(x, y)) by moving in stages from left to right along the sentence. First version of negation: ∃x in D such that ∼(∃y in E such that P(x, y)). Final version of negation: ∃x in D such that ∀y in E,∼P(x, y). Similarly, to find ∼(∃x in D such that ∀y in E, P(x, y)), we have First version of negation: ∀x in D,∼(∀y in E, P(x, y)). Final version of negation: ∀x in D, ∃y in E such that ∼P(x, y). These facts can be summarized as follows: Negations of Multiply-Quantified Statements ∼(∀ x in D, ∃y in E such that P(x, y)) ≡ ∃x in D such that ∀y in E,∼P(x, y). ∼(∃x in D such that ∀y in E, P(x, y)) ≡ ∀x in D, ∃y in E such that ∼P(x, y). Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 124 Chapter 3 The Logic of Quantified Statements Example 3.3.8 Negating Statements in a Tarski World Refer to the Tarski world of Figure 3.3.1, which is reprinted here for reference. a b c f i e g h j d Write a negation for each of the following statements, and determine which is true, the given statement or its negation. a. For all squares x , there is a circle y such that x and y have the same color. b. There is a triangle x such that for all squares y, x is to the right of y. Solution a. First version of negation: ∃ a square x such that ∼(∃ a circle y such that x and y have the same color). Final version of negation: ∃ a square x such that ∀ circles y, x and y do not have the same color. The negation is true. Square e is black and no circle is black, so there is a square that does not have the same color as any circle. b. First version of negation: ∀ triangles x,∼ (∀ squares y, x is to the right of y). Final version of negation: ∀ triangles x, ∃ a square y such that x is not to the right of y. The negation is true because no matter what triangle is chosen, it is not to the right of square g (or square j). ■ Order of Quantifiers Consider the following two statements: ∀ people x, ∃ a person y such that x loves y. ∃ a person y such that ∀ people x, x loves y. Note that except for the order of the quantifiers, these statements are identical. How- ever, the first means that given any person, it is possible to find someone whom that person loves, whereas the second means that there is one amazing individual who is loved by all people. (Reread the statements carefully to verify these interpretations!) The two sentences illustrate an extremely important property about multiply-quantified statements: Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 3.3 Statements with Multiple Quantifiers 125 In a statement containing both ∀ and ∃, changing the order of the quantifiers usually changes the meaning of the statement.! Caution! If a statement contains two different quantifiers, reversing their order can change the truth value of the statement to its opposite. Interestingly, however, if one quantifier immediately follows another quantifier of the same type, then the order of the quantifiers does not affect the meaning. Consider the commutative property of addition of real numbers, for example: ∀ real numbers x and ∀ real numbers y, x + y = y + x . This means the same as ∀ real numbers y and ∀ real numbers x, x + y = y + x . Thus the property can be expressed more briefly as ∀ real numbers x and y, x + y = y + x . Example 3.3.9 Quantifier Order in a Tarski World Look again at the Tarski world of Figure 3.3.1. Do the following two statements have the same truth value? a. For every square x there is a triangle y such that x and y have different colors. b. There exists a triangle y such that for every square x, x and y have different colors. Solution Statement (a) says that if someone gives you one of the squares from the Tarski world, you can find a triangle that has a different color. This is true. If someone gives you square g or h (which are gray), you can use triangle d (which is black); if someone gives you square e (which is black), you can use either triangle f or triangle i (which are both gray); and if someone gives you square j (which is blue), you can use triangle d (which is black) or triangle f or i (which are both gray). Statement (b) says that there is one particular triangle in the Tarski world that has a different color from every one of the squares in the world. This is false. Two of the triangles are gray, but they cannot be used to show the truth of the statement because the Tarski world contains gray squares. The only other triangle is black, but it cannot be used either because there is a black square in the Tarski world. Thus one of the statements is true and the other is false, and so they have opposite truth values. ■ Formal Logical Notation In some areas of computer science, logical statements are expressed in purely symbolic notation. The notation involves using predicates to describe all properties of variables and omitting the words such that in existential statements. (When you try to figure out the meaning of a formal statement, however, it is helpful to think the words such that to yourself each time they are appropriate.) The formalism also depends on the following facts: “∀x in D, P(x)” can be written as“∀x(x in D→ P(x)),” and “∃x in D such that P(x)” can be written as “∃x(x in D ∧ P(x)).” We illustrate the use of these facts in Example 3.3.10. Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 126 Chapter 3 The Logic of Quantified Statements Example 3.3.10 Formalizing Statements in a Tarski World Consider once more the Tarski world of Figure 3.3.1: a b c f i e g h j d Let Triangle(x), Circle(x), and Square(x) mean “x is a triangle,” “x is a circle,” and “x is a square”; let Blue(x), Gray(x), and Black(x) mean “x is blue,” “x is gray,” and “x is black”; let RightOf(x, y), Above(x, y), and SameColorAs(x, y) mean “x is to the right of y,” “x is above y,” and “x has the same color as y”; and use the notation x = y to denote the predicate “x is equal to y”. Let the common domain D of all variables be the set of all the objects in the Tarski world. Use formal, logical notation to write each of the following statements, and write a formal negation for each statement. a. For all circles x, x is above f . b. There is a square x such that x is black. c. For all circles x , there is a square y such that x and y have the same color. d. There is a square x such that for all triangles y, x is to right of y. Solution a. Statement: ∀x(Circle(x)→ Above(x, f )). Negation: ∼(∀x(Circle(x)→ Above(x, f ))) ≡ ∃x ∼ (Circle(x)→ Above(x, f )) by the law for negating a ∀ statement ≡ ∃x(Circle(x) ∧ ∼Above(x, f )) by the law of negating an if-then statement b. Statement: ∃x(Square(x) ∧ Black(x)). Negation: ∼(∃x(Square(x) ∧ Black(x))) ≡ ∀x ∼ (Square(x) ∧ Black(x)) by the law for negating a ∃ statement ≡ ∀x(∼Square(x) ∨ ∼Black(x)) by De Morgan’s law c. Statement: ∀x(Circle(x)→ ∃y(Square(y) ∧ SameColor(x, y))). Negation: ∼(∀x(Circle(x)→ ∃y(Square(y) ∧ SameColor(x, y)))) ≡ ∃x ∼ (Circle(x)→ ∃y(Square(y) ∧ SameColor(x, y))) by the law for negating a ∀ statement ≡ ∃x(Circle(x) ∧ ∼(∃y(Square(y) ∧ SameColor(x, y)))) by the law for negating an if-then statement Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 3.3 Statements with Multiple Quantifiers 127 ≡ ∃x(Circle(x) ∧ ∀y(∼(Square(y) ∧ SameColor(x, y)))) by the law for negating a ∃ statement ≡ ∃x(Circle(x) ∧ ∀y(∼Square(y) ∨ ∼SameColor(x, y))) by De Morgan’s law d. Statement: ∃x(Square(x) ∧ ∀y(Triangle(y)→ RightOf(x, y))). Negation: ∼(∃x(Square(x) ∧ ∀y(Triangle(y)→ RightOf(x, y)))) ≡ ∀x ∼ (Square(x) ∧ ∀y(Triangle(x)→ RightOf(x, y))) by the law for negating a ∃ statement ≡ ∀x(∼Square(x) ∨ ∼(∀y(Triangle(y)→ RightOf(x, y)))) by De Morgan’s law ≡ ∀x(∼Square(x) ∨ ∃y(∼(Triangle(y)→ RightOf(x, y)))) by the law for negating a ∀ statement ≡ ∀x(∼Square(x) ∨ ∃y(Triangle(y) ∧ ∼RightOf(x, y))) by the law for negating an if-then statement ■ The disadvantage of the fully formal notation is that because it is complex and somewhat remote from intuitive understanding, when we use it, we may make errors that go unrecognized. The advantage, however, is that operations, such as taking nega- tions, can be made completely mechanical and programmed on a computer. Also, when we become comfortable with formal manipulations, we can use them to check our intu- ition, and then we can use our intuition to check our formal manipulations. Formal logical notation is used in branches of computer science such as artificial intelligence, program verification, and automata theory and formal languages. Taken together, the symbols for quantifiers, variables, predicates, and logical connectives make up what is known as the language of first-order logic. Even though this language is simpler in many respects than the language we use every day, learning it requires the same kind of practice needed to acquire any foreign language. Prolog The programming language Prolog (short for programming in logic) was developed in France in the 1970s by A. Colmerauer and P. Roussel to help programmers working in the field of artificial intelligence. A simple Prolog program consists of a set of statements describing some situation together with questions about the situation. Built into the lan- guage are search and inference techniques needed to answer the questions by deriving the answers from the given statements. This frees the programmer from the necessity of having to write separate programs to answer each type of question. Example 3.3.11 gives a very simple example of a Prolog program. Example 3.3.11 A Prolog Program Consider the following picture, which shows colored blocks stacked on a table. g b1 w1 w2 b2 b3 g b1 w1 = gray block = blue block 1 = blue block 2 = blue block 3 = white block 1 = white block 2w2b2 b3 Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 128 Chapter 3 The Logic of Quantified Statements The following are statements in Prolog that describe this picture and ask two questions about it. Note Different Prolog implementations follow different conventions as to how to represent constant, variable, and predicate names and forms of questions and answers. The conventions used here are similar to those of Edinburgh Prolog. isabove(g, b1) color(g, gray) color(b3, blue) isabove(b1, w1) color(b1, blue) color(w1,white) isabove(w2, b2) color(b2, blue) color(w2,white) isabove(b2, b3) isabove(X, Z) if isabove(X, Y ) and isabove(Y, Z) ?color(b1, blue) ?isabove(X, w1) The statements “isabove(g, b1)” and “color(g, gray)” are to be interpreted as “g is above b1” and “g is colored gray”. The statement “isabove(X, Z) if isabove(X, Y ) and isabove(Y, Z)” is to be interpreted as “For all X , Y , and Z , if X is above Y and Y is above Z , then X is above Z .” The program statement ?color(b1, blue) is a question asking whether block b1 is colored blue. Prolog answers this by writing Yes. The statement ?isabove(X, w1) is a question asking for which blocks X the predicate “X is above w1” is true. Prolog answers by giving a list of all such blocks. In this case, the answer is X = b1, X = g. Note that Prolog can find the solution X = b1 by merely searching the original set of given facts. However, Prolog must infer the solution X = g from the following statements: isabove(g, b1), isabove(b1, w1), isabove(X, Z) if isabove(X, Y ) and isabove(Y, Z). Write the answers Prolog would give if the following questions were added to the pro- gram above. a. ?isabove(b2, w1) b. ?color(w1, X) c. ?color(X , blue) Solution a. The question means “Is b2 above w1?”; so the answer is “No.” b. The question means “For what colors X is the predicate ‘w1 is colored X ’ true?”; so the answer is “X = white.” c. The question means “For what blocks is the predicate ‘X is colored blue’ true?”; so the answer is “X = b1,” “X = b2,” and “X = b3.” ■ Test Yourself 1. To establish the truth of a statement of the form “∀x in D, ∃y in E such that P(x, y),” you imagine that some- one has given you an element x from D but that you have no control over what that element is. Then you need to find with the property that the x the person gave you together with the you subsequently found satisfy . 2. To establish the truth of a statement of the form “∃x in D such that ∀y in E , P(x, y),” you need to find so that no matter what a person might subsequently give you, will be true. 3. Consider the statement “∀x , ∃y such that P(x, y), a property involving x and y, is true.” A negation for this statement is “ .” Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 3.3 Statements with Multiple Quantifiers 129 4. Consider the statement “∃x such that ∀y, P(x, y), a prop- erty involing x and y, is true.” A negation for this statement is “ .” 5. Suppose P(x, y) is some property involving x and y, and suppose the statement“∀x in D, ∃y in E such that P(x, y)” is true. Then the statement “∃x in D such that ∀y in E , P(x, y)” a. is true. b. is false. c. may be true or may be false. Exercise Set 3.3 1. Let C be the set of cities in the world, let N be the set of nations in the world, and let P(c, n) be “c is the capi- tal city of n.” Determine the truth values of the following statements. a. P(Tokyo, Japan) b. P(Athens, Egypt) c. P(Paris, France) d. P(Miami, Brazil) 2. Let G(x, y) be “x2 > y.” Indicate which of the following statements are true and which are false. a. G(2, 3) b. G(1, 1) c. G
( 1 2 ,
1 2
) d. G(−2, 2)
3. The following statement is true: “∀ nonzero numbers x, ∃ a real number y such that xy = 1.” For each x given below, find a y to make the predicate “xy = 1” true. a. x = 2 b. x = −1 c. x = 3/4
4. The following statement is true: “∀ real numbers x, ∃ an integer n such that n > x .”∗ For each x given below, find an n to make the predicate “n > x” true. a. x = 15.83 b. x = 108 c. x = 101010
The statements in exercises 5–8 refer to the Tarski world given in Example 3.3.1. Explain why each is true.
5. For all circles x there is a square y such that x and y have the same color.
6. For all squares x there is a circle y such that x and y have different colors and y is above x .
7. There is a triangle x such that for all squares y, x is above y.
8. There is a triangle x such that for all circles y, y is above x .
9. Let D = E = {−2,−1, 0, 1, 2}. Explain why the following statements are true. a. ∀x in D, ∃y in E such that x + y = 0. b. ∃x in D such that ∀y in E, x + y = y.
10. This exercise refers to Example 3.3.3. Determine whether each of the following statements is true or false. a. ∀ students S, ∃ a dessert D such that S chose D. b. ∀ students S, ∃ a salad T such that S chose T . c. ∃ a dessert D such that ∀ students S, S chose D. d. ∃ a beverage B such that ∀ students D, D chose B. e. ∃ an item I such that ∀ students S, S did not choose I . f. ∃ a station Z such that ∀ students S, ∃ an item I such
that S chose I from Z .
11. Let S be the set of students at your school, let M be the set of movies that have ever been released, and let V (s,m) be “student s has seen movie m.” Rewrite each of the follow- ing statements without using the symbol ∀, the symbol ∃, or variables. a. ∃s ∈ S such that V (s, Casablanca). b. ∀s ∈ S, V (s, Star Wars). c. ∀s ∈ S, ∃m ∈ M such that V (s,m). d. ∃m ∈ M such that ∀s ∈ S, V (s,m). e. ∃s ∈ S, ∃t ∈ S, and ∃m ∈ M such that s �= t and
V (s,m) ∧ V (t,m). f. ∃s ∈ S and ∃t ∈ S such that s �= t and ∀m ∈ M,
V (s,m)→ V (t,m). 12. Let D = E = {−2,−1, 0, 1, 2}. Write negations for each
of the following statements and determine which is true, the given statement or its negation. a. ∀x in D, ∃y in E such that x + y = 1. b. ∃x in D such that ∀y in E, x + y = −y. c. ∀x in D, ∃y in E such that xy ≥ y. d. ∃x in D such that ∀y in E , x ≤ y.
In each of 13–19, (a) rewrite the statement in English without using the symbol ∀ or ∃ or variables and expressing your answer as simply as possible, and (b) write a negation for the statement.
13. ∀ colors C, ∃ an animal A such that A is colored C . 14. ∃ a book b such that ∀ people p, p has read b. 15. ∀ odd integers n, ∃ an integer k such that n = 2k + 1. 16. ∃ a real number u such that ∀ real numbers v, uv = v. 17. ∀r ∈ Q, ∃ integers a and b such that r = a/b. 18. ∀x ∈ R, ∃ a real number y such that x + y = 0. 19. ∃x ∈ R such that for all real numbers y, x + y = 0. 20. Recall that reversing the order of the quantifiers in a state-
ment with two different quantifiers may change the truth value of the statement—but it does not necessarily do so. All the statements in