0% found this document useful (0 votes)
165 views510 pages

Discrete Mathematical Structures With AP

Uploaded by

cbsegirlsaipmt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
165 views510 pages

Discrete Mathematical Structures With AP

Uploaded by

cbsegirlsaipmt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
Discrete Mathematical Structures with Applications to Computer Science J.P. Tremblay R. Manohar ° stereos @ @ @ @ a) 1 4 AP xchiy Weg) en eae) FOR SALE IN INDIA ONLY Tata McGraw-Hill Discrete Mathematical Structures with Applications to Computer Science Copyright © 1975 by McGraw-Hill, Inc. All rights reserved. No part of this publication may be reproduced or distributed in any form or by any means, or stored in a data base or retrieval system, without the prior written permission of the publisher Tata McGraw-Hill Edition 1997 35th reprint 2008 RYLYYDLXRZQXX Reprinted in India by arrangement with The McGraw-Hill Companies, Inc., New York For Sale in India Only Library of Congress Cataloging-in-Publication Data Tremblay, Jean-Paul, date Discrete mathematical structures with applications to computer science. (McGraw-Hill computer science series) Includes bibliographies 1. Mathematics —1961 2. Electronic data processing. 3. Machine theory. 1. Manohar, R., date joint author. 11. Title. QA39.2.T72 $10°.2°40901 74-23954 ISBN 0-07-065142-6 ISBN-13: 978-0-07-463 113-3 ISBN-10: 0-07-463113-6 Published by Tata McGraw-Hill Publishing Company Limited, T West Patel Nagar, New Delhi 110 008, and printed at Sai Printo Pack Pvt. Lid., New Delhi 110.020 CONTENTS Preface 1_Mathematieal Logic i 1-1 Statements and Notation 2 1-2 Connectives 7 1-21 Negation 8 Conjunction 9 Disjunction 10 Statement Formulas and Truth Tables 1B oreises 1-2.4 14 Logical Capabilities of Programming Languages 14 Jonditios iconditi 1 Exercises 1-28 22 12.7 ~Well-forme: 9 1-28 Tautologics 3 24 Exercises 1-2.8 26 1-29 Equivalence of Formulas 26 1-2.10 Duality Law 30 .11 ‘Tautological Implications 32 Exercises 1-211 34 oie F jai Dune ater 2 1-2.18 Functionally Complete Sets of Connectives 37 Exercises 2.18 38 1-€.14 Other Connectives 39 Exercises 1-214 al 1-2.16 Two-state Devices and Statement Logic 4i Exercises 1-215 49 Exercises 1-2 2 j8Noetad Forma 50 1-3.1 Disjunctive Normal Forms 50 13.8 Conjunctive Normal Forms 52 1-3.3_ Principal Disjunctive Normal Forms 53 1-8.4 Principal Conjunctive Normal Forms 1-8.5__Ordering and Uniqueness of Normal Forms Exercises 1+ 1-3.6 Completely Parenthesized Infix Notation and Polish Notation 61 Exercises 1-3.6 64 1-4 The Theory of Inference for the Statement Caleulus 65 14.1 Validity Using Truth Tables 66 Exercises 1-4.1 87 1.4.2 Rules of Inference 68 1.4.3 Consisteney of Premises and Indirect Method of Proof. 72 1-4.4 Automatic Theorem Proving 74 Exercises [- 79 1-6_The Predicate Calculus 79 1-5.1 Predicate: 80 1-52 The Statement Function, Variables, and Quantifiers 82 5.8 Predi 7 85 1-5.4_ Free and Bound Variables 86 : tee o Exercises 1-6 89 16_Inference Theory of the Predicate Calculus 90 16.1 Valid Formulas and Equivalences 90 aaa ae r = 16.3 Special Valid Formulas Involving Quantifiers Od 14.4 Theory of Inference for the Predicate Calculus 96 16.5 Formulas Involving More Than One Quantifier 99 Exercises 1-6 101 Bibliography 102 104 104 pts of Set Theory 105 2-11 Notation 105 + CONTENTS ix 2-12 Inclusion and Equality of Sets 107 2-13 The Power Set 109 Exercises 21.8 uu 2.1.4 Some Operations on Sets Lt Exercises 2-1.4 115 21.6 Venn Diagrams 116 Exercises 22.6 (\|2 2-1.6 Some Basic Set Identiti 118 2-1,7 The Principle of Specification 121 2-18 Ordered Pairs and n-tuples 122 2-19 Cartesian Products 123 Exercises 2-1 125 22 Representation of Discrete Structures 126 2-21 Data Structures ||| NB 2-2.2 Storage Structures 129 2-2.3 Sequential Allocation 130 2-24 Pointers and Linked Allocation 132 22.5 An Application of Bit Represented Sets 141 Exercises 2-2 147 28 Relations and Ordering 148 2-31 Relation: 149 Exercises 2-3.f- 2.9.2 2-8.2 Properties of Binary Relations in a Set 154 Exercises 2-3.2 155 28.8 Relation Matrix and the Graph of a Relation 156 2-3.4 Partition and Covering of a Set - 162 Exercises 2-3.4 164 2-8.5 Equivalence Relations 164 2-3.6 Compatibility Relations Fra Exercises 23.6 175 £-8.7 Composition of Binary Relations 176 Exercises 2-3.7 182 23.8 Partial Ordering 183 28.9 Partially Ordered & epresentation and Associated Terminology 186 Exercises 2.3.9 191 24 Functions 192 2-4.1 Definition and Introduction 192 Exercises 2-4.1 197 2-4.2 Composition of Functions 198 2-48 Inverse Functions 201 Exercises 2-4.3 204 %-4.4 Binary and n-ary Operations 205 Exercises 2-4. 210 24.6 Characteristic Function of a Set 210 X CONTENTS 26 2-4.6 Hashing Functions 212 Exercises 2-4.6 219 Exercises 2-4 219 Natural Numbers 220 26.1 Peano Axioms and Mathematical Induction 22 25.2 Cardinality 224 Exercises 2-6 231 Recursion 232 28.1 Recursive Functions, Sets, and Predicates Exercises 2-6.1 232 26.2 Recursion in Programming Languages 243 Exercises 2-6 259 2-7 Recursion in Mechanical Theorem Proving 261 Exercises 2-7 268 Bibliography 268 3_ Algebraic Structures Bl 32 Introduction Algebraic Systems: Examples and General Properties $-1.1 Definition and Examples 31.2 Some Simple Algebraic Systems and General Properties Exercises 3-1 Semigroups and Monoids 33 3-4 8-6 3-2.4 Definitions and Examples 3-2.2_Homomorphism of Semigroups and Monoids 8-2.3 Subsemigroups and Submonoids Exercises 3-2 Grammars and Languages 8-3.1 Discussion of Grammars $3.2 Formal Definition of a Language 3-3.3 Notions of Syntax Analysis Exercises 3-3 Polish Expressions and Their Compilation 8-4.1 Polish Notation 8-4.2 Conversion of Infix Expressions to Polish Notation Exercises 3-4 Groups 3-5.1 Definitions and Examples Exercises 3-5.1 3-5.2 Subgroups and Homomorphisms Exercises 3-5.2 8-6.8 Cosets and Lagrange’s Theorem 8-5.4 Normal Subgroups 3-5.5 Algebraic Systems with Two Binary Operations Exercises 3-6.5 conTENTS xi Exercises 3-6 344 846 The Application of Residue Arithmetic tq Computers 344 36.1 Introduction to Number Systems 345 $6.2 Residue Arithmetic 348, Exercises 3-6 359 $7 Group Codes 339 $7.1 The Communication Model and Basic Notions of Error Correction 360 8-72 Generation of Codes by Using Parity Checks 364 3-7.8 Exror Recovery in Group Codes 373 Exercises 3-7 76 Bibliography 376 4 Lattices and Boolean Algebra 378 Introduction BB 4-1 Lattices as Partially Ordered Sets 379 4-41 Definition and Examples 379 Exercises 4-1.1 382 4-12 Some Properties of Lattices 382 Exercises 4-1.2 385 41.8 Lattices as Algebraic Systems 385 4-14 Sublattices, Direct Product, and Homomorphism 387 Exercises 4-1.4 391 4-16 Some Special Lattices 392 Exercises 4-1.5 397 48 Boolean Algebra 397 4-81 Definition and Examples 398 422 Subalgebra, Direct Product, and Homomorphism 401 Exercises 4-2 405 48 Boolean Functions 406 4-3.1_ Boolean Forms and Free Boolean Algebras 406 43.2 Values of Boolean Expressions and Boolean Functions 410 Exercises 4-8 Al7 4-4 Representation and Minimization of Boolean Functions 418 4-41 Representation of Boolean Functions 418 4-42 Minimization of Boolean Functions 424 Exercises 4-4 433 4-6 Design Examples Using Boolean Algebra 436, Exercises 4-5 451 46 Finite-state Machines 453 46.1 Introductory Sequential Circuits 453 46.2 Equivalence of Finite-state Machines 456 Exercises 4-6 465 Bibliography 466 xii CONTENTS 5 Graph Theory 468 Introduction 468 6-1__Basie Concepts of Graph Theory 469 6-1,{ Basic Definitions 469 Exercises 6-1.1 5, 4-1.2 Paths, Reachability, and Connectedness 476 Exercises 6-.@ || §-1.3 Matrix Representation of Graphs 484 Exercises 5-1.3 493 6-1.4 Trees 494 Exercises 5-1.4 _ _ 501 6-2 Storage Representation and Manipulation of Graphs 501 62.1 Trees: Their Representation and Operations 501 52.2 List Structures and Graphs 509 Exercises 5-2 514 §-3 Simple Precedence Grammars 515 5-8.1 Syntax Terminology 516 6-3.2 A View of Parsing 520 6-8.8 Notion and Use of Precedence Relations 523 6-3.4 Formal Definition of Precedence Relations 526 63.5 Parsing Algorithm for Simple Precedence Grammars 530 Exercises 5-$ 532 5-4 Fault Detection in Combinational Switching Circuits 533 &-4.1 Faults in Combinational Circuits 534 6-42 Notions of Fault Detection _ 535 64.3 Algorithm for Generating a Fault Matrix 537 5-4.4 Procedure for the Detection of Faults 547 Exercises 5-4 549 6-5 PERT and Related Techniques 550 Exercises 5-6 555 Bibliography 555 6 Introduction to Computability Theory 357 Introduction oy 6-1 Finite-state Acceptors and Regular Grammars 558 Exercises 6-1 566 6-2 Turing Machines and Partial Recursive Functions 566 Exercises 6-2 584 Bibliography 584 Appendix 585 Index 591 PREFACE Several advanced books in computer science begin with a chapter consisting of a selection of mathematical topics that the reader is assumed to know. The exposition of such topics is usually brief, and the principal results that are summarized become prerequisites for the remainder of the text. It is not possible to learn these topics from such a brief treatment. Nor is it possible for under- graduate students in computer science to study all the topics they are required to know by attending courses dealing with each individual topic as given by mathematics departments. In general, the trend is to select several topics in mathematics that are essential to the study of many computer science areas and to expose the students to the mathematical prerequisites in some other way. A similar development has occurred in most engineering curricula. In the same spirit, this book discusses certain selected topics in mathematics which can be referred to as “discrete mathematics.”” No prerequisites except the mathe- matical maturity of a high school student are assumed, Although many students taking a course in discrete mathematics may have had a freshman course in calculus, such a course is by no means a prerequisite to the study of this book. However, any additional mathematical courses taken by students will aid in their development of mathematical maturity. It is not our intention to cover all topics in discrete mathematics. The omission of counting techniques, permutations, and probability will be felt by xiv PREFACE some readers. We have assumed that many high school students will have had some exposure to these topics. The selection of the topics was governed by our desire to introduce most of the basic terminology used in as many advanced courses in computer science as possible. In order to motivate the students properly, we feel that it'is im- portant to consider certain applications as the terminology is introduced. There are several advantages in using this approach. Students begin to see the relevance of abstract ideas and are therefore better motivated. Moreover, they gain confidence in applying these ideas to solve practical problems. We wish to emphasize that concepts and terminology should be introduced well before they are used. Otherwise, students must invariably struggle both with the basic tools and with the subject matter to which the tools are applied. Most of the material in this book is properly a prerequisite to so many computer science courses that it should be taught no later than at the sophomore level. The book has been written with this objective in mind. The mathematical topics to be discussed are logic, set theory, algebraic structures, Boolean algebra, graph theory, and basic computability theory. Although well-known and excellent books exist in these areas, we introduce these topics still keeping in mind that the reader will eventually use them in certain practical applications particularly related to computer science. We have strived to introduce the theoretical material in a reasonably mathematically precise manner whenever possible, while avoiding long philosophical discussions, questions of paradoxes, and any axiomatic approach to certain theories. The topics selected will also support the more advanced courses in computer science programs such as in the areas of automata, computability, artificial intelligence, formal languages and syntactical analysis, information organization and retrieval, switching theory, computer representation of discrete structures, and pro- gramming languages. It is hoped that a grasp of the theoretical material in this book will permit a student to understand most of the mathematical pre- liminaries which are briefly discussed at the beginning of many articles and books in the areas of computer science just mentioned. Because the relation between the mathematics aud how or where it could be applied may not be clear to the reader, the computer representation of certain mathematical structures is discussed. The need for discrete structures in com- puter science is motivated by the selection of certain applications from various areas in the field. Algorithms are developed for most applications, and computer programs are given for some of them. The computer representation and manip- ulation of discrete structures such as strings, trees, groups, and plexes are not discussed in great detail, but only to the extent which permits the formulation of a solution to a particular application. _ Chapter 1 discusses mathematical logic. An elementary introduction to certain topics in logic is given to students in education, commerce, economics, and social sciences in courses usually entitled “Finite Mathematics.” However, such discussions usually end with the construction of truth tables, and in certain instances a brief introduction to the inference theory of the statement calculus is included. In order for students to be able to read technical articles and books PREFACE xv in computer science, it is necessary for them to know something about predicate calculus. Therefore, we have gone further in our discussion of logic than is usually done in books on finite mathematics. Yet we have avoided the philo- sophical discussions and intricate details that are found in the books on mathe- matical logic meant for mathematicians and philosophers. The chapter contains a brief introduction to the application of logic to two-state devices. Chapter 2 deals with sct theory. Some mathematical rigor is maintained in the discussions and proofs are sometimes given, but we do not raiso the ques- tion of paradoxes and the axiomatic approach to set theory. Sets, relations, orderings, and recursive functions are discussed. The computer representation and manipulation of certain structures are introduced in this chapter. An example of the interrelationship of set theory and logic is given. The topic of recursion (and its implementation) is dealt with in some detail since many pro- gramming languages permit its use. Furthermore, the concept of recursion is important in its own right because computer scientists will encounter, throughout their careers, problems where recursion is unavoidable. The chapter concludes with an algorithm for proving theorems in the propositional calculus. Chapter 3 discusses algebraic structures. Most books in modern algebra devote almost all their attention to group theory while little is said about semi- groups and monoids. The latter are also emphasized in this chapter since it is semigroup and monoid theory which is very important in certain areas of com- puter science such as formal language theory, syntactic analysis, and automata. This chapter contains a number of applications dealing with topics such as the compilation of Polish expressions, languages and grammars, the theory of fast-adders, and error detecting and correcting codes. Chapter 4 is concerned with Boolean algebra and its application to switching theory and sequential machines. An introduction to the minimization of Boolean functions and to its use in the logical design of digital computer systems is given. Sequential machines and their equivalence are also discussed. Chapter 5 gives a brief introduction to graph theory. Elements of graph theory are indispensable in almost all computer science areas. Examples are given of its use in such areas as syntactic analysis, fault detection and diagnosis in computers, and minimal-path problems. The computer representation and manipulation of graphs are also discussed so that certain important algorithms can be included. Finally, Chapter 6 gives a very brief introduetion to computability theory. The equivalence of finite-state acceptors and regular grammars is shown. Finally, the concept of an effective procedure is introduced. It is shown that a Turing machine can evaluate any partial recursive function. The exercises are of both a theoretical and a programming nature and are meant to further the understanding of the application of the concepts to various areas of computer science. The material in this book incorporates, in addition to logic, most of what the ACM Curriculum Committee on Computer Science recommends for the course “Introduction to Discrete Structures,” * * Course B3 in CACM 11, pp. 172-173, 1968. xvi PREFACE ‘We hope that this book will be of use to computer scientists, engineers, nonmathematics students who desire an intermediate coverage of topics in discrete mathematics, and mathematicians who want to familiarize themselves with the application of the theory to computer science. Students who have some previous background in modern logic and algebra will be able to master the material in one semester. For other students who have no previous knowl- edge of logic and algebra, this book can be used in a two-semester course. Certain topies can be selected to form a one-semester course. The omission of the applica- tions discussed in the text will not result in any loss of continuity in the material. This book is based on the experience gained in teaching a course on discrete structures at the University of Saskatchewan at Saskatoon during the past four years. A basic familiarity with either standard FORTRAN or PL/I is assumed. PL/1 is useful in applications that involve recursion or list structures. We owe a great deal to John A. Copeck and Richard F. Deutscher, who made many valuable criticisms and suggestions throughout the entire prepara- tion and proofreading of the book. They also helped us in formulating and testing most of the algorithms. In particular, John Copeck assisted in the preparation of Chapter 1 and Sections 2-7, 4-4, 4-5, 5-2, 5-5, and 6-2. Also, Richard Deutscher assisted in the preparation of Chapter 2, Sections 4-4 and 5-1, and many of the figures. We aiso thank Peter Hardie for his assistance in working out the details on fault diagnosis in Section 5-4 and Andrew Carson for hissuggestions in Chapter 3. Robert Probert proofread Sections 5-1 and 6-2, Don McKillican and Allan Listol worked out the exercises, and Gail Galgan helped in proofreading and constructing the index, We owe a very special thanks to Alice Mae MacDonald who did such an excellent job of typing themanuscript, and to Helen Henderson and Dorothy Peake for providing typing support. This work would not have been possible without the support given by the University of Saskatchewan J. P. TREMBLAY R. MANOHAR DISCRETE MATHEMATICAL STRUCTURES WITH APPLICATIONS TO COMPUTER SCIENCE 1 MATHEMATICAL LOGIC INTRODUCTION One of the main aims of logic is to provide rules by which one can determine whether any particular argument or reasoning is valid (correct). Logic is concerned with all kinds of reasonings, whether they be legal argu- ments or mathematical proofs or conclusions in a scientific theory based upon a set of hypotheses. Because of the diversity of their application, these rules, called rules of inference, must be stated in general terms and must be independ- ent of any particular argument or discipline involved. These rules should also be independent of any particular language used in the arguments. More pre- cisely, in logic we are concerned with the forms of the arguments rather than with the arguments themselves. Like any other theory in science, the theory of inference is formulated in such a way that we should be able to decide about the validity of an argument by following the rules mechanically and independently of our own feelings about the argument. Of course, to proceed in this manner Tequires that the rules be stated unambiguously. Any collection of rules or any theory needs a language in which these rules or theory can be stated. Natural languages are not always precise enough. They 2 MATHEMATICAL Logic are also ambiguous and, as such, are not suitable for this purpose. It is therefore nécessary first to develop a formal language called the object language. A formal language is one in which the syntax is well defined. In fact, every scientific dis- cipline develops its own object language which consists of certain well-defined: terms and well-specified uses of these terms. The only difference between logic and other disciplines is that in other disciplines we are concerned with the use of the object language while in logic we are as interested in analyzing our object language as we are in using it. In fact, in the first half of this chapter we shall be concerned with the development and analysis of an object language without considering its use in the theory of inference. This study has important applica- tions in the design of computers and several other two-state devices, as is shown in Sec. 1-2.15. We emphasize this part of logic because the study of formal lan- guages constitutes an important part in the development of means of communica- tion with computing machines, This study is followed by the study of inference theory in Sec. 1-4. It soon becomes apparent that the object language developed thus far is very limited, and we cannot include some very simple argument forms in our inference theory. Therefore, in Sec. 1-5 we expand our object language to include predicates, and then in Sec. 1-6 we discuss the inference theory of predicate logic. In order to avoid ambiguity, we use symbols which have been clearly de- fined in the object languages. An additional reason to use symbols is that they are easy to write and manipulate. Because of this use of symbols, the logic that we shall study is also called symbolic logic. Our study of the object language re- quires the use of another language. For this purpose we can choose any of the natural languages. In this case our choice is English, and so the statements about the object language will be made in English. This natural language (English) will then be called our metalanguage. Certain inherent difficulties in this pro- cedure could be anticipated, because we wish to study a precise language while using another language which is not so precise. 1-1 STATEMENTS AND NOTATION In this section we introduce certain basic units of our object language called primary (primitive, atomic) statements. We begin by assuming that the object language contains a set of declarative sentences which cannot be further broken down or analyzed into simpler sentences. These are the primary statements. Only those declarative sentences will be admitted in the object language which have one and only one of two possible values called “truth values.” The two truth values are true and false and are denoted by the symbols T and F respectively. Occasionally they are also denoted by the symbols 1 and 0. The truth values have nothing to do with our feelings of the truth or falsity of these admissible sentences because these feelings are subjective and depend upon context. For _ our purpose, it is enough to assume that it is possible to assign one and only one of the two possible values to a declarative sentence. We are concerned in our study with the effect of assigning any particular truth value to declarative sen- tences rather than with the actual truth value of these sentences. Since we admit only two possible truth values, our logic is sometimes called a two-valued logic. 1-1 STATEMENTS AND NoTATION 3 We develop a mechanism by which we can construct in our object language other declarative sentences having one of the two possible truth values. Note that we do not admit any other types of sentence, such as exclamatory, interrogative, ete., in the object language. Declarative sentences in the object language are of two types. The first type includes those sentences which are considered to be primitive in the object language. These will be denoted by distinct symbols selected from the capital letters.A, B,C, ..., P,Q, ..., while declarative sentences of the second type are obtained from the primitive ones by using certain symbols, called connectives, and certain punctuation marks, such as parentheses, to join primitive sentences. In any case, all the declarative sentences to which it is possible to assign one and only one of the two possible truth values are called statements. These state- ments which do not contain any of the connectives are called atomic (primary, primitive) statements. We shall néw give examples of sentences and show why some of them are not admissible in the object language and, hence, will not be symbolized. 1 Canada is a country. 2 Moscow is the capital of Spain. 8 This statement is false. 4 1+ 101 = 110. & Close the door. 6 Toronto is an old city. ? Man will reach Mars by 1980. Obviously Statements (1) and (2) have truth values true and false respec- tively. Statement (3) is not a statement according to our definition, because we cannot properly assign to it a definite truth value. If we assign the value true, then Sentence (3) says that Statement (3) is false. On the other hand, if we assign it the value false, then Sentence (3) implies that Statement (3) is true. This example illustrates a semantic paradox. In (4) we have a statement whose truth value depends upon the context; viz., if we arc talking about numbers in the decimal system, then it is a false statement. On the other hand, for numbers in binary, it is a true statement. The truth value of a statement often depends upon its context, which is generally unstated but nonetheless understood. We shall soon see that we are not going to be preoccupied with the actual truth value of a statement. We shall be interested only in the fact that it has a truth value. In this sense (4), (6), and (7) are all statements. Note that Statement (6) is considered: true in some parts of the world and false in certain other parts. The truth value of (7) could be determined only in the year 1980, or earlier if a man reaches Mars before that date, But this aspect is not of interest to us. Note that (5) is not a statement; it is a command. Once we know those atomic statements which are admissible in the object language, we can use symbols to denote them. Methods of constructing and analyzing statements constructed from one or more atomic statements are dis- cussed in Sec. 1-2, while the method of symbolizing atomic statements will be described here after we discuss some conventions regarding the use and mention of names in statements. 4) MATHEMATICAL LOGIC It is customary to use the name of an object, not the object itself, when making a statement about the object. As an example, consider the statement & This table is big. ‘The expression “this table” is used as a name of the object. The actual object, namely a particular table, is not used in the statement. It would be inconvenient to put the actual table in place of the expression ‘this table.”” Even for the case of small objects, where it may be possible to insert the actual object in place of its name, this practice would not permit us to make two simultaneous state- ments about the same object. without using its name at one place or the other. For this reason it may be agreed that a statement about an object would contain never the object itself but only its name. In fact, we are so familiar with this convention that we take it for granted. Consider, now, a situation in which we wish to discuss something about a name, so that the name is the object about which a statement is to be made. According to the rule just stated, we should use not the name itself in the state- ment but some name of that name. How does one give a name to a name? A usual method is to enclose the name in quotation marks and to treat it as aname for the name. For example, let us look at the following two statements. 9 Clara is smart. 10 “Clara” contains five letters. In (9) something is said about a person whose name is Clara. But Statement (10) is not about a person but about a name. Thus “Clara” is used as a name of this name. By enclosing the name of a person in quotation marks it is made clear that the statement made in (10) is about a name and not about a person. This convention can be explained alternatively by saying that we use a certain word in a sentence when that word serves as the name of an object under consideration. On the other hand, we mention a word in a sentence when that word is acting not as the name of an object but as the name of the word itself. To “mention” a word means that the word itself has been converted into an object of our consideration. Throughout the text we shall be making statements not only about what we normally consider objects but also about other statements. Thus it would be necessary to name the statements under consideration. The same device used for naming names could also be used for naming statements. A statement en- closed in quotation marks will be used as the name of the statement. More gen- erally, any expression enclosed in quotation marks will be used as the name of that expression. In other words, any expression that is mentioned is placed in quotation marks. The following statement illustrates the above discussion. 11 “Clara is smart” contains “Clara.” Statement (11) is a statement about Statement (9) and the word “Clara.” Here Statement (9) was named first by enclosing it in quotation marks and then by using this name in (11) along with the name “Clara”! In this discussion we have used certain other devices to name statements. One such device is to display a statement on a line separated from the main text. This method of display is assumed to have the same effect as that obtained 1-L STATEMENTS AND NOTATION § by using quotation marks to delimit a statement within the text. Further, we have sometimes numbered these statements by inserting a number to the left of the statement. In a later reference this number is used as a name of the state- ment. This number is written within the text without quotation marks. Such a display and the numbering of statements permit some reduction in the number of quotation marks. Combinations of these different devices will be used throughout the text in naming statements. Thus the statement 12 “Clara is smart” is true. could be written as “(9) is true,” or equivalently, 12a (9) is true. A particular person or an object may have more than one name. [t is an accepted principle that one may substitute for the name of an object in a given statement any other name of the same object without altering the meaning of the statement. This principle was used in Statements (12) and (12a). We shall be using the name-forming devices just discussed to form the names of statements. Very often such distinctions are not made in mathematical writings, and generally the difference between the name and the object is as- sumed to be clear from the context. However, this practice sometimes leads to confusion. ‘A situation analogous to the name-object concept just discussed exists in many programming languages. In particular, the distinction between the name of a variable and its value is frequently required when a procedure (function or subroutine) is invoked (called). The arguments (also called actual parameters) in the statement which invokes the procedure are associated with the (formal) parameters of the procedure either by name or by value. If the association is made by value, then only the value of an argument is passed to its corresponding parameter. This procedure implies that we canriot change the value of the argu- ment from within the function since it is not known where this argument is stored in the computer memory. On the other hand, a call-by-name association makes the name or address of the argument available to the procedure. Such an association allows the value of an argument to be changed by instructions in the procedure. We shall now discuss how call-by-name and call-by-value as- sociations are made in a number of programming languages. In certain versions of FORTRAN compilers (such as IBM’s FORTRAN H and G) the name of an argument, not its value, is passed to a function or sub- routine. This convention also applies to the case of an arguments being a con- stant. The address of a constant (stored in some symbol table of the compiler) is passed to the corresponding parameter of the function. This process could lead to catastrophic results. For example, consider the simple function FUN de- scribed by the following sequence of statements: INTEGER FUNCTION FUN(I) I=5 FUN=1 RETURN END 6 MATHEMATICAL Logic Suppose that the main program, which invokes FUN, consists of the trivial statements K=3 J = FUN(K) * 3 L= FUN(3) *3 PRINT 10, J, L 10 FORMAT(1H , 13, 18) STOP END This program yields values of 15 and Yo for variables J and L respectively. In the evaluation of J, the address of K is known within the function. K is changed in the function to a value of 5 by the statement I = 5. The functional value re- turned by the function is 5, and a value of 15 for J results. The computation of L, however, is quite different. The address of 3 is passed to the function. Since the corresponding parameter I is changed to 5, the value of 3 in the symbol table in the main program will also be changed to 5, Note that since all references to the symbol table entry for constant 3 were made at compile time, all such future references in the remainder of the main program still refer to that entry or loca- tion, but the value will now be 5, not 3. More specifically, the name 3 in the right operand of the multiplication of L has a value of 5. In other versions of FORTRAN compilers, such results are prevented by creating a dummy variable for each argument that is a constant. These internal (dummy) variables are not accessible to the programmer. A change in parameter corresponding to a dummy variable changes the value of that variable, but it does not change the value of the original argument from which it was constructed. WATFIV permits the passing of arguments by value by merely enclosing such arguments in slashes. For example, in the function call TEST(L/K/,5) the value of K is passed to the function TEST. In PL/I arguments can be passed by value or by name. An argument is passed by value if it is enclosed within parentheses; otherwise it is passed by name. In the function call TEST(I,(K),5) the arguments I and K are passed by name and by value respectively. As mentioned earlier, we shall use the capital letters A, B, ..., P,Q, ... (with the exception of T and F) as well as subscripted capital letters to represent statements in symbolic logic. As an illustration, we write 13 P: It is raining today. In Statement (13) we are including the information that “P” is a statement in symbolic logic which corresponds to the statement in English, “It is raining today.” This situation is similar to the translation of the same statement into French as “Aujourd’hui il pleut.” Thus “P” in (13)—“‘It is raining today”-—and. “Aujourd’hui il pleut” are the names of the same statement. Note that “P” and not P is used as the name of a statement. 1-2 connectives 7 1-2 CONNECTIVES The notions of a statement and of its truth value have already been introduced. In the case of simple statements, their truth values are fairly obvious. However, it is possible to construct rather complicated statements from simpler statements by using certain connecting words or expressions known as “sentential connec- tives.” Several such connectives are used in the English language. Because they are used with a variety of meanings, it is necessary to define a set of connectives with definite meanings. It is convenient to denote these new connectives by means of symbols. We define these connectives in this section and then develop methods to determine the truth values of statements that are formed by using them. Various properties of these statements and some relationships between them are also discussed. In addition, we show that the statements along with the connectives define an algebra that satisfies 2 set of properties. These properties enable us to do some calculations by using statements as objects. The algebra developed here has interesting and important applications in the field of switching theory and logical design of computers, as is shown in Sec. 1-2.15. Some of these results are also used in the theory of inference discussed in Sec. 1-4. The statements that we consider initially are simple statements, called atomic or primary statements. As already indicated, new statements can be formed from atomic statements through the use ot sentential connectives. The resulting statements are called molecular or compound statements. Thus the atomic state- ments are those which do not have any connectives. In our everyday language we use connectives such as “and,” “but,” “or, ete., to combine two or more statements to form other statements. However, their use is not always precise and unambiguous. Therefore, we will not sym- bolize these connectives in our object language; however, we will define connec- tives which have some resemblance to the connectives in the English language. The idea of using the capital letters P,Q, ..., Pi, Px, ... to denote state- ments was already introduced in Sec. 1-1. Now the same symbols, namely, the capital letters with or without subscripts, will also be used to denote arbitrary statements. In this sense, a statement “P” either denotes a particular statement or serves as a placeholder for any statement whatsoever. This dual use of the same symbol to denote either a definite statement, called a constant, or an arbi- trary statement, called a variable, does not cause any confusion as its use will be clear from the context. The truth value of “P” is the truth value of the actual statement which it represents. It should be emphasized that when “P”’ is used as astatement variable, it has no truth value and as such does not represent a state- ment in symbolic logic. We understand that if it is to be replaced, then its re- placement must be a statement. Then the truth value of P could be determined. It is convenient to call “P” in this case a ‘statement formula.” We discuss the notion of “statement formula” in Sec. 1-2.4. However, in the sections that follow, we often abbreviate the term “statement formula” simply by “statement.” This abbreviation keeps our discussion simple and emphasizes the meaning of the connectives introduced. As an illustration, let. ” P: It is raining today. Q: It is snowing. 8 MATHEMATICAL Lore and let R be a statement. variable whose possible replacements are P and Q. If no replacement for R is specified, it remains a statement variable and has no truth value. On the other hand, the truth values of P and Q can be determined because they are statements. 1-21 Negation The negation of a statement is generally formed by introducing the word “not” at a proper place in the statement or by prefixing the statement with the phrase “It is not the case that.” If “P” denotes a statement, then the negation of “P” is written as ‘“]P” and read as “not P.” If the truth value of “P” is T, then the truth value of ““]P” is F. Also if the truth value of “P” is F, then the truth value of ““]P” is T. This definition of the negation is summarized by Table 1-2.1, Notice that we have not used the quotaticn marks to denote the names of he statements in the table. This practice is in keeping with the one adopted earlier, when a statement was separated from the main text and written on a separate line. From now on we shall drop the quotation marks even within the text when we use symbolic names for the statements, except in the case where this practice may lead to confusion. We now illustrate the formation of the nega- tion of a statement. Consider the statement P: London is a city. Then —|P is the statement “TP: It is not the case that London is a city. Normally ]P can be written as P: London is not a city Although the two statements “It is not the case that London is a city’’ and “London is not a city” are not identical, we have translated both of them by P. The reason is that both these statements have the same meaning in English. A given statement in the object language is denoted by a symbol, and it may correspond to several statements in English. This multiplicity happens because in a natural language one can express oneself in a variety of ways. As an illustration, if a statement is P: L went to my class yesterday. then (is any one of the following 1 {did not go to my class vesterday. TRUTH TABLE FOR NEGATION 1-2 CONNECTIVES 9 2 I was absent from my class yesterday. 8 It is not the case that I went to my class yesterday. The symbol ‘“]" has been used here to denote the negation. Alternate symbols used in the literature are “‘~,” a bar, or “NOT,” so that ~]P is written as ~P, P, or NOT P. Note that a negation is called a connective although it only modifies a statement. In this sense, negation is a unary operation which operates on a single statement or a variable. The word “operation” will be explained in Chap. 2. For the present it is sufficient to note that an operation on statements generates other statements. We have chosen ‘|’ to denote negation because this symbol is commonly used in the textbooks on logic and also in several program- ming languages, one of which will be used here, 1-2.2 Conjunction The conjunction of two statements P and Q is the statement P A Q which is read as “P and Q.” The statement P A Q has the truth value T whenever both P and Q have the truth value 7; otherwise it has the truth value F. The conjunc- tion is defined by Table 1 EXAMPLE 1 Form the conjunction of P:Itis raining today. Q: There are 20 tables in this room. SOLUTION It is raining today and there are 20 tables in this room. //// Normally, in our everyday language the conjunction “and” is used between two statements which have some kind of relation. Thus a statement “It is raining today and 2 + 2 = 4” sounds odd, but in logic it is a perfectly acceptable state- ment formed from the statements “It is raining today” and “2 + 2 = 4.” EXAMPLE 2 Translate into symbolic form the statement Jack and Jill went up the hill. sourtmoN In order to write it as a conjunetion of two statements, it is necessary tirst to paraphrase the statement ax Jack went up the hili avd Jill wert ap the bill Table 122 TRUTH TABLE FOR CONJUNCTION P 9 Pg 10 MATHEMATICAL LoGic If we now write P: Jack went up the hill, Q: Jill went up the hill. then the given statement can be written in symbolic form as P A Q. Ht So far we have seen that the symbol A is used as a translation of the con- nective “and” appearing in English. However, the connective “and” is sometimes used in a different sense, and in such cases it cannot be translated by the symbol A defined above. In order to see this difference, consider the statements: 1 Roses are red and violets are blue. 2 He opened the book and started to read. 8 Jack and Jill are cousins. In Statement (1) the conjunction “and” is used in the same sense as the symbol A. In (2) the word “and” is used in the sense of “and then,” because the action described in “‘he started to read” occurs after the action described in “he opened the book.” In (3) the word “and” is not a conjunction. Note that our definition of conjunction is symmetric as far as P and Q are concerned; that is to say, the truth values of P A Q and of Q A P are the same for specific values of P and Q. Obviously the truth value of (1) will not change if we write it as Violets are blue and roses are red. On the other hand, we cannot write (2) as He started to read and opened the book. These examples show that the symbol A has a specific meaning which corre- sponds to the connective “and” in general, although “and” may also be used with some other meanings. Some authors use the symbol &, or a dot, or “AND” to denote the conjunction, Note that the conjunction is a binary operation in the sense that it connects two statements to form a new statement. 1-2.3 Disjunetion The disjunction of two statements P and Q is the statement P V Q which is read as “P or Q.” The statement P V Q has the truth value F only when both P and Q have the truth value F; otherwise it is true. The disjunction is defined by Table 1-2.3. Table 1-23 TRUTH TABLE FOR DISJUNCTION uv PVO Is IIs! oO mAs 1-2 connectives 11 The connectives ~] and A defined earlier have the same meaning aa the words “not” and “and” in general. However, the connective V is not always the same as the word “or” because of the fact that the word “or” in English is commonly used both as an “exclusive OR” and as an “inclusive OR.” For example, consider the following statements: 1 T shall watch the game on television or go to the game. 2 There is something wrong with the bulb or with the wiring. $ Twenty or thirty animals were killed in the fire today. In Statement (1), the connective “or” is used in the exclusive sense; that is to say, one or the other possibility exists but not both. In (2) the intended meaning is clearly one or the other or both. The connective “or” used in (2) is the “inclusive OR.” In (3) the “or” is used for indicating an approximate num- ber of animals, and it is not used as 8 connective. From the definition of disjunction it is clear that V is “inclusive OR.” The symbol V comes from the Latin word “vel” which is the “inclusive OR.” It is not necessary to introduce a new symbol for “exclusive OR,” since there are other ways to express it in terms of the symbols already defined. We demonstrate this point in Sec. 1-2.14. Normally in our everyday language, the disjunction “or” is used between two statements which have some kind of relationship between them. It is not necessary in logic that there be any relationship between them according to the definition of disjunction. The truth value of P V Q depends only upon the truth values of P and Q. As before, it may be necessary to paraphrase given statements in English before they can be translated into symbolic form. Similarly, transla- tions of statements from symbolic logic into statements in English may require paraphrasing in order to make them grammatically acceptable. 1-2.4 Statement Formulas and Truth Tables We have defined the connectives “], A, and V so far. Other connectives will be defined subsequently. We shall occasionally distinguish between two types of statements in our symbolic language. Those statements which do not contain any connectives are called alomic or primary or simple statements. On the other hand, those statements which contain one or more primary statements and some connectives are called molecular or composite or compound statements, As an ex- ample, let P and Q be any two statements. Some of the compound statements formed by using P and Q are “RP PVQ (PAQVCWP) PAC) qd) ‘The compound statements given above are statement formulas derived from the statement variables P and Q. Therefore, P and Q may be called the components of the statement formulas. Observe that in addition to the connectives we have also used parentheses in some cases in order to make the formula unambiguous. We discuss the rules of constructing statement formulas in Sec. 1-2.7, Recall that a statement formula has no truth value. It is only when the statement variables in a formula are replaced by definite statements that we get 12 MATHEMATICAL LoGic a statement. This statement has a truth value which depends upon the truth values of the statements used in replacing the variables. In the construction of formulas, the parentheses will be used in the same sense in which they are used in elementary arithmetic or algebra or sometimes in a computer programming language. This usage means that the expressions in the innermost parentheses are simplified first. With this convention in mind, “|(P_A Q) means the negation of P A Q. Similarly (P A Q) V (Q A R) means the disjunction of P A Q and QA R. ((P AQ) V R) A (P) means the conjunetion of P and (P A Q) V R, while (P A Q) V R means the disjunc- tion of P A Q and R. In order to reduce the number of parentheses, we will assume that the nega- tion affects as little as possible of what follows. Thus ]P V Q is written for (TP) V Q, and the negation means the negation of the statement immediately following the symbol ~]. On the other hand, according to our convention, “V(P A Q) V RB stands for the disjunction of “](P A Q) and R. The negation affects P A Q but not 2. Truth tables have already been introduced in the definitions of the connec- tives. Our basic concern is to determine the truth value of a statement formula for each possible combination of the truth values of the component statements. A table showing all such truth values is called the truth table of the formula. In Table 1-2.1 we constructed the truth table for “]P. There is only one component, or atomic statement, namely P, and so there are only two possible truth values to be considered. Thus Table 1-2.1 has only two rows. In Tables 1-2.2 and 1-2.3 we constructed truth tables for P A Qand P V Qrespectively. These statement formulas have two component statements, namely P and Q, and there are 2? pos- sible combinations of truth values that must be considered. Thus each of the two tables has 2? rows. In general, if there are n distinct components in a statement formula, we need to consider 2" possible combinations of truth values in order to obtain the truth table. Two methods of constructing truth tables are shown in the following examples. EXAMPLE | Construct the truth table for the statement formula P V “]Q. SoLUTION It is necessary to consider all possible truth values of P and Q. These values are entered in the first two columns of Table 1-2.4 for both methods. In the table which is arrived at by method 1, the truth values of —]@Q are entered Table 1-2.4a Table 1-2.46 P @ e PV 10 P QO P Vv qT Q TT F Tr ror 7p rf F Pf T F T r TF T 7 TF PF FOOT F P P oT F PF F f FOF T T F FP F T T F Method 1 Step Number 1 39 2 1 Method 2 1-2 connectives 13 in the third column, and the truth values of P V 1Q are entered in the fourth column. In method 2, as given in Table 1-2.4b, a column is drawn for each state- ment as well as for the connectives that appear. The truth values are entered step by step. The step numbers at the bottom of the table show the sequence followed in arriving at the final step. Mt EXAMPLE 2 Construct the truth table for P A “]P. soLuTIoN See Table 1-2.5. Note that the truth value is F for every pos- sible truth value of P. In this special case, the truth value of P A ~1P is inde- pendent of the truth value of P. MMT EXAMPLE 3 Construct the truth table for (P V Q) V “TP. soLUTION See Table 1-2.6. In this case the truth value of the formula (P V Q) V —Pis independent of the truth values of P and Q. Thisindependence is due to the special construction of the formula, as we shall see in Sec. 1-2.8, Ml Table 1-2.5 P “P PAW? P # A ¥ P rT F F ' T F F T Fr T F F ¥ F T ¥ Method 1 Step Num- ber 1 3 2 1 Method 2 Table 1-2.6 P Q PVO 1? (P VQ) Vv 1P rT T F T T OF Tr F Tr F Tr ¥ Tv Tr F F F T a Method 1 P @ @ v @ v q P rT f° T T T T FP Tr rT OP T Tr P T F T rF oT F T i T T F F F F PF P T T F Step Number 1 2 1 3 2 1 14 MATHEMATICAL LoGic Observe that if the truth values of the component statements are known, then the truth value of the resulting statement can be readily determined from the truth table by reading along the row which corresponds to the correct truth values of the component statements. EXERCISES 1-2.4 1 Using the statements R: Mark is rich. H: Mark is happy. write the following statements in symbolic form: (a) Mark is poor but happy. (b) Mark is rich or unhappy. (c). Mark is neither rich nor happy. (a) Mark is poor or he is both rich and unhappy. 2 Construct the truth tables for the following formulas. (a) “CPV 71) (6) “ICP A 1) (ce) PA (PY Q) (d) PA(QAP) fe) CIPACTIOA BV (QA RV (PA R) (A) (PA QV CIPA QV (PA TQ) V CIP A 10) 5 For what truth values will the following statement be true? “It is not the case that houses are cold or haunted and it is false that cottages are warm or houses ugly.” (Hint: There are four atomic statements. ) 4 Given the truth values of P and Qas T and those of R and Sas F, find the truth values of the following: (a) PV (QAR) (b+) (PA (QA B))VIUPV Q) A (RV S)) fe) CUP AQ) V TR) (OOTP A Q) V71R) AS) 1-2.5 Logical Capabilities of Programming Languages In this section we discuss the logical connectives available in certain programming languages and how these connectives can be used to generate a truth table for a statement formula. The logical connectives discussed thus far are available in most programming languages. In PL/I, the connectives A, V, and ~] are written. as &, |, and ~] respeetively. The truth values 7’ and F are written as ‘I’B and ‘0’B respectively. In ALGOL the connectives are represented as we have written them, while 7 and F are written as true and false respe: FORTRAN also permits the use of logical variables and expressions, and it is these facilities which are to be discussed in this section. In FORTRAN, the truth values 7 and F are denoted by the logical con- stants .TRUE. and .FALSE. respectively. Logical variables and expressions in the language assume only one of the logical values at any given time. All logical variables must be explicitly declared as in the statement LOGICAL P, Q, R which declares the three variables P, Q, and R. 1-2 connectives 15 The statement that a relation exists between arithmetic expressions is itself an expression that has a truth value; in FORTRAN, these expressions are formu- lated from the following relational operators: ALT(<) .LE(S) EQ(=) .GE(2) .GT>) .NK(=) For example, if P has been declared LOGICAL, the statement P=5%2.LT17 assigns a value of .TRUE. to P. Similarly, if Q has been appropriately declared, the statement Q=A+[Link].C+D assigns the value . TRUE. to Qif A + 5 is greater than or equal to C + D when the statement is executed, and the value .FALSE. otherwise. From the truth values arising, for example, from relations, more complex logical expressions can be obtained in FORTRAN by using one or more of the three logical connectives previously discussed. The logical operators .AND., -OR., and ,NOT. correspond to the symbolic logical operators A, V, and ~] respectively. The statement PV CTQN R)) is equivalent to the FORTRAN statement [Link]. (.NOT. ([Link]. R)) Unnecessary parentheses are avoided in FORTRAN by using the following precedence scheme. The arithmetic operators, with their usual order of prece- dence, are the highest in rank and are consequently evaluated first. All relational operators have the same rank and are evaluated after the arithmetic operators. The logical operators are the last to be evaluated, and .NOT., .AND., and .OR. is their decreasing order of precedence. Of two or more binary operators having the same precedence value in an expression, the leftmost is evaluated first; for unary operators, it is the rightmost which is evaluated first. Thus, NOT. P -AND. Q means (.NOT. P) AND. Q; and A+ B + 5.0 .LT. C + D means ((A + B) + 5.0) .LT. (C + D). FORTRAN has a logical “IF statement” whose form is IF (logical expression) statement If the logical expression in the “IF statement” is true, then the statement follow- ‘ing the expression is executed; otherwise, it is skipped. For example, when the statement IF (.NOT. POR. Q) GO TO 100 is executed, it will not transfer control to statement 100 if P and Q have the values .TRUE. and .FALSE. respectively. Arrays of logical variables can also be used in FORTRAN. The statement LOGICAL CASE(10) declares a one-dimensional array of type LOGICAL consisting of 10 elements. Elements of logical arrays are referenced in the same manner as any other sub- scripted variable. 16 MATHEMATICAL Losic Consider the problem of generating all possible assignments of truth values to the logical variables P, Q, and R, as shown in Table 1-2.7, There are 2? = 8 possible assignments. Notice that the truth value of the variable P remains at the same value of’ 7 or F for each of four consecutive assignments of logical values. The values of variables Q and R remain at T or F for two assignments and one assignment of logical values respectively. The value of variable R changes more frequently than the value of variable Q, and that of Q more frequently than that of P, The number of times the kth logical variable remains at a constant truth value can be easily computed and is denoted by BASE[K]. In the case under discussion, we have three variables, and the values can be computed as BASE[K] = 20» =k = 1,2,3 where we have associated BASE[1], BASE[2], and BASE[3] with variables P,Q, and R respectively. In addition to computing the BASE elements, we also need to know the number of assignments which remain to be generated with a particular logical variable remaining at the same value. For example, if we had already generated the assignments TTT and TTF, then variable P would remain at its present value of T throughout the generation of the next two assignments. This in- formation is stored in an element denoted by LENGTH[K]. For variable P, LENGTH(L1] would have a value of 2 after generation of TTT and TTF. The LENGTH values associated with variables P, Q, and R are initially the same as their corresponding BASE values. Therefore, initially LENGTH[k] = BASE[k] k= 1,2,3 Every time an assignment is generated, each element of LENGTH is decremented by 1. When the LENGTH value associated with a variable becomes zero, then the truth value of that variable is negated, and the LENGTH value is reset to the BASE value. The algorithm for the generation of such assignments can now be precisely formulated. Table 1-27 P @ R T T T\|—BASEI3] Tr Tr P BASE\\}— Tr F T T F F F T Tr BASE{2} ——— F T F F F T F F F 1-2 connectives 17 Algorithm NEXT Given n logical variables having values stored in CASE[1), CASE[2], ..., CASE[n] and two vectors BASE and LENGTH each having n elements, it is required to generate the next assignment of truth values for these variables. 1 [Initialize counter] Set k— 1. 2 [Decrement LENGTH([K]] Set LENGTH[k] — LENGTH[k] — 1. 3 [Negate variable and reset LENGTH ([k]?] If LENGTH(k] = 0 then set CASE[k] — \CASE(k] and LENGTH(k] — BASE[K]. 4 [Increment counter] Set k —k + 1. If k < x then go to step 2; other- wise Exit. Mt A program for algorithn NEXT is given in Fig. 1-2.1. The subroutine has the four parameters CASE, N, BASE, and LENGTH. All parameters except N are arrays. The logical array CASE contains an assignment of truth values for the logical variables from which the subroutine is to generate a new assignment of values. l'or example, for the case of three logical variables, CASE(1), CASE(2), and CASE(3) could be associated with the variable names P, Q, and 2 respec- tively. The new assignment of truth values is returned to the main program via the logical array CASE. Let us now consider the problem of constructing a truth table for a state- ment formula, The following straightforward algorithm uses the various logical arrays such as CASE, BASE, and LENGTH which were discussed in algorithm NEXT. Algorithm TRUTH Givena statement formula in n variables and subalgorithm NEXT which generates a new assignment of truth values, it is required to con- struct a truth table for the given statement formula. 1 [Initialize] Repeat for k = 1,2,...,n: Set BASEL] — 26-6, LENGTH{k] — BASE[k), and CASE[K] < F. Set i — 1 and print headings for the truth table. 2 [Evaluate statement] Substitute the logical values in array CASE into the statement formula. Print the values in array CASE and the value of the statement. & [Obtain next assignment for variables] Invoke subalgorithm NEXT. SUBROUTINE NEXTCASE,N»BASE sLENGTH) © GENERATE THE NEXT ASSIGNMENT OF LOGICAL VALUES. LOGICAL CASEIN) INTEGER BASFIN),LENGTHIND OO 1K = ten LENGTHIK) = LENGTH(K) - 1 TFCLENGTH(K) .NE%O) GO TO L CASEIKD = LENGTHIK) = 8A CONTINUE FIGURE 1-2.1 Program for algorithm NEXT, 18 MATHEMATICAL Logic 4 [Increment counter] Set ii + 1. If i < 2" then go to step 2; other- wise Exit Mil The FORTRAN program for the algorithm is given in Fig. 1-2.2. As an example, the formula TVUPAQ) V (RY P) was used in the program. The program consists of a main program, a subroutine, and a function. The subroutine NEXT, given in Fig. 1-2.1, generates an assign- ment each time it is invoked. The function LOGIC is very simple, and its purpose is to generate a single truth value for the statement formula each time the func- tion is invoked. The number of logical variables in the given statement formula and their associated values are passed to the function LOGIC by using the in- teger variable N and the logical vector CASE respectively. For our example, the variables P, Q, and 2 are denoted in the program by the subscripted variables CASE(1), CASE(2), and CASE(3) respectively. Each time the main program needs a new assignment of truth values for the variables, it calls on procedure NEXT after which the function LOGIC is invoked to evaluate the statement formula for this new assignment of values. The main program computes the BASE and LENGTH vectors for subroutine NEXT. Initially, all logical variables are set to false, which enables subroutine NEXT to obtain the next assignment. Note that all variables could have been set to true instead. This assignment, of course, would have produced a truth table with the same information as shown in the sample output but in a different order. 1-2.6 Conditional and Biconditional If P and Q are any two statements, then the statement P — & which is read as “If P, then Q” is called a conditional statement. The statement P — @ has a truth value F when Q has the truth value F and P the truth value 7; otherwise it has the truth value 7. The conditional is defined by Table 1-2.8. The statement P is called the antecedent and Q the consequent in P > Q. Again, according to the definition, it is not necessary that there be any kind of relation between P and Q in order to form P > Q. Table 1-28 TRUTH TABLE FOR CONDITIONAL P Q PO T T e T PF F F T T F F tT 1-2 connzcrives 19 MAINLINE THIS PROGRAM EVALUATES A STATEMENT FORMULA AND GENERATES I7S TRUTH TABLE, VARTABLES TITLE: TITLE FOR THE STATEMENT FORMULA NAME VARTABLE NAMES VALUE: LOGICAL VALUE OF STATEMENT FORMULA NUMBER: NUMBER OF ROWS IN THE TRUTH TABLE aaananaaaar PECLAPATIANS AND TITLES INTEGER®2 NAME(3)/#P9, 908, 1RO/ REALSS TITLE(G1/*eNOTs (Poy AND. Q)60! LOGICAL CASE(10),LOGIC, VALUE INTEGER BASE(19) sLENGTH(LO) C INITIALIZE BASE, LENGTH, CASE, Ny AND NUMBERS N23 NUMBER = 2 #0 N on i K = IyN BASELK) = 2 #* IN - KD LENGTH(K) = BASE(K) CASE(K) = eFALSES 1_ CONTINUE © OUTPUT HEADINGS WRITEC6,10) TITLE 1D FORMAT (TL? (13%, " VARTABLES', 13%, 448) WRITE(6,20) NAME 20 FORMATC® F,AX,4CASE 1 2 3% y/y# %y13Xy3UA2¢ 2K) y21Ky *VALUE? 9) FIND VALUE OF THE STATEMENT FORMULA, OUTPUT TRUT4 VALUES, AND GENERATS NEW TRUTH VALUES FOR THE LOGICAL VARIABLES. 90 2-1 2 [Link] VALUS = [Link] WRITE(6,39) (CASECK) 9K = 1) NPs VALUE 3D FORMATE® 4 13X53(L1 43K) 23K oL LD CALL NEXTECASE Ny BASE, LENGTH) 2 CONTINUE stop end RetReO%e eh) ao LOGICAL FUNCTION LOGICICASE WN) © THIS FUNCTION DFFINFS THE STATEMENT FORMULA TO BE EVALUATED. LOGICAL CASEEND LOGIC = eNOTs(CASECL) sANDeCASE(2) ORs (CASE 3) oORSCASELIDD RETURN END. VARIABLES eNOT.(P6AND.W) OR ([Link] cased 2) 3 Poo k VALUE eo oF oF r FoF T T FoT F T For f T TOF F T Tor T Tt TOT € T ro4rr T FIGURE 1-2.2 Program for generating truth tables—mainline and func- tion LOGIC. 20 MATHEMATICAL LoGIc EXAMPLE 1 Express in English the statement P — Q where P: The sun is shining today. Q24+7>4. soLurion If the sun is shining today, then 2+ 7 > 4. Mf The conditional often appears very confusing to a beginner, particularly when one tries to translate a conditional in English into symbolic form. A variety of expressions are used in English which can be appropriately translated by the symbol —. It is customary to represent any one of the following expressions by PQ: 1 Qis necessary for P. 2 P is sufficient for Q. 3 QifP. 4 Ponlyif@ 5 P implies Q. We shall avoid the translation “implies.” Although, in mathematics, the statements “If P, then Q” and “P implies (”' are used interchangeably, we want to use the word “implies” in a different way. In our everyday language, we use the conditional statements in a more restricted sense. It is customary to assume some kind of relationship or implica- tion or feeling of cause and effect between the antecedent, and the consequent in using the conditional. For example, the statement “If I get the book, then I shall read it tonight” sounds reasonable because the second statement “I shall read it (the book) tonight” refers to the book mentioned in the first part of the state- ment. On the other hand, a statement such as “If I get the book, then this room is red” does not make sense to us in our conventional language. However, ac- cording to our definition of the conditional, the last statement is perfectly ac- ceptable and has a truth value which depends on the truth values of the two statements being connected. The first two entries in Table 1-2.8 are similar to what we would expect in our everyday language. Thus, if P is true and @ is true, then P — Q is true. Similarly, if P is true and Qs false, then “If P, then Q” appears to be false. Con- sider, for example, the statement “If I get the money, then I shall buy the car.” If I actually get the money and buy the car, then the statement appears to be correct or true. On the other hand, if I do not buy the car even though I get the money, then the statement is false. Normally, when a conditional statement is made, we assume that the antecedent is true. Because of this convention in English, the first two entries in the truth table do not appear strange. Referring to the above statement again, if I do not get the money and J still buy the car, it is not so clear whether the statement made earlier is true or false. Also, if I do not buy the car and I do not get the money, then it is not intuitively clear whether the statement made is true or false, It may be possible to justify entries in the last two rows of the truth table by considering special examples or even by emphasizing certain aspects of the statements given in the above examples. How- ever, it is best to consider Table 1-2.8 as the definition of the conditional in which the entries in the last two rows are arbitrarily assigned in order to avoid any am- 1-2 connectives 21 biguity. Any other choice for the last two entries would correspond to some other connective which has either been defined or will be defined. In general, the use of “If ..., then ...”” in English has only partial resemblance to the use of the conditional — as defined here. EXAMPLE 2 Write the following statement in symbolic form. If either Jerry takes Calculus or Ken takes Sociology, then Larry will take English. souution Denoting the statements as J: Jerry takes Calculus. K: Ken takes Sociology. L: Larry takes English the above statement can be symbolized as WV K) SL Md EXAMPLE 3. Write in symbolic form the statement, The crop will be destroyed if there is a flood. soLution Let the statements be denoted as €: The erop will he destroyed. F: There is a flood. Note that the given statement uses “if” in the sense of “If ..., then ....” It is better to rewrite the given statement as “If there is a flood, then the erop will be destroyed.” Now it is easy to symbolize it-as FOC Hd} EXAMPLE 4 Construct the truth table for (P > Q) A (QP). soLuTion See Table 9. Note that the given formula has the truth value T whenever both ? and Q have identical truth values, M1) If P and Q are any two statements, then the statement /’? = Q, which is read as “P if and only if Q” and abbreviated as “7 iff Q,” is called a biconditional statement. The statement /’ = Q has the truth value T whenever both / and Table 1-2.9 PQ PQ Q>P (P>0)A QP) ror v T T F F T F F T T F F F F fT T T 22 MATHEMATICAL LocIc Table 1-210 TRUTH TABLE FOR BICONDITIONAL P @ Pee Tr T T r F F F T F F F r Table 1-2.11 P @ PAQ “PAQ TP 10 TPVT@ WPA) (7PV 70) rrr P F F F rT T F F ¥: F r T T For F T Tr F Tr Tr PF F F Tr £ e Tr T Q have identical truth values. Table 1-2.10 defines the biconditional. The state- ment P = Q is also translated as “P is necessary and sufficient for Q.”” Note that the truth values of (P + Q) A (Q— P) given in Table 1-2.9 are identical to the truth values of P = Q defined here. EXAMPLE 5 Construct the truth table for the formula TP AQ =P Vv 1) soLuTion See Table 1-2.11. Note that the truth values of the given for- mula are T for all possible truth values of P and Q. Wt EXERCISES 1-2.6 1 Show that the truth values of the following formulas are independent of their com- ponents. (a) (PA (P>Q)) > @ (0) (PAQeBCIPV Q) ‘c) ((P->Q) A (Q— R)) > (PR) (a) (P2Q)= (PA Q) V CPA 710)) # Construct the truth tables of the following formulas. (a) (QA (P>Q))>P () “UPV (QA R)) = (PV Q) A (PV R)) 3 A connective denoted by V isdefined by Table 1-2.12. Find a formula using P, Q, and Rseanectivs A, V,, and —] whose truth values are identical to the truth values of PVa@ 4 Given the truth values of P and Q as T and those of # and S as F, find the truth values of the following: (a) CPA 0) VR) V (QP) (BV 18)) (o) (P= R) A(T 8) (ce) (PV (Q-+ (RA TP))) = QV 1S) 1-2 connectivrs 23 Table 1-212 P Q Pve T + F r F T F T T F F F 1-2.7 Well-formed Formulas The notion of a statement formula has already been introduced. A statement formula is not a statement (although, for the sake of brevity, we have often called it a statement) ; however, a statement can be obtained from it by replacing the variables by statements. A statement formula is an expression which is a string consisting of variables (capital letters with or without subscripts), parentheses, and connective symbols. Not every string of these symbols is a formula. We shall now give a recursive definition of a statement formula, often called a well-formed formula (wf). A well-formed formula can be generated by the following rules: 1 Astatement variable standing alone is a well-formed formula. 2 If A is a well-formed formula, then “]A is a well-formed formula. 8 IfA ard Bare well-formed formulas, then (A A B),(A V B), (A > B), and (A = B) are well-formed formulas. 4 A string of symbols containing the statement variables, connectives, and parentheses is a well-formed formula, iff it can be obtained by finitely many applications of the rules 1, 2, and 3. According to this definition, the following are well-formed formulas: “UP AQ) UPVQ (Pa (PV Q)) (P>(Q@>R)) (PQ) A (Q>R)) &(P>R)) The following are not well-formed formulas. 1 “PA Q. Obviously P and Q are well-formed formulas. A wif would be either (TP A Q) or 1(P A Q). 2 (P+Q) > (A Q). This is not a wi because A Q is not. 3 (PQ. Note that (P +@Q) isa wi. 4 (P AQ) + Q). The reason for this not being a wf is that one of the pa- rentheses in the beginning is missing, ((P A Q) > Q) isa wff, while (P A Q)>Q is still not a wif. It is possible to introduce some conventions so that the number of paren- theses used can be reduced. In fact, there are conventions which, when followed, allow one to dispense with all the parentheses. We shall not discuss these conven- tions here. For the sake of convenience we shall omit the outer parentheses. Thus we write P A Qin place of (P A Q), (P A Q) > Qin place of ((P A Q) > Q), and ((P>Q) A (Q—> R)) = (P > R) instead of (((PQ) A (Q—>R)) & (P = R)). Since the only formulas we will encounter are well-formed formulas, we will refer to well-formed formulas as formulas. ‘24 MATHEMATICAL LOGIC 1-28 Tantologies Well-formed formulas have been defined. We also know how to construct the truth table of 2 given formula. Let us consider what a truth table represents. If definite statements sre substituted for the variables in a formula, there results a statement. The truth value of this resulting statement depends upon the truth values of the statements substituted for the variables. Such a truth value appears as one of the entries in the final column of the truth table. Observe that this entry will not change even if any of the definite statements that replace particular variables are themselves replaced by other statements, as long as the truth values associated with all variables are unchanged. In other words, an entry in the final column depends only on the truth values of the statements assigned to the vari- ables rather than on the statements themselves. Different. rows correspond to different sets of truth value assignments. A truth table is therefore 2 summary of the truth values of the resulting statements for all possible assignments of values to the variables appearing in a formula. It must be emphasized that a statemen‘ formula does not have a truth value. In our discussion which follows we shall, for the sake of simplicity, use the expression “the truth value of a state- Ment formula” to mean the entries in the final column of the truth table of the formula. In general, the final column of a truth table of a given formula contains both T and F. There are some formulas whose truth values are always T or always F regardless of the truth value assignments to the variables. This situ- ation occurs because of the special construction of these formulas. We have already seen some examples of such formulas. Consider, for example, the statement formulas P V —]P and P A ~]P in Table 1-2.13. The truth values of P V “|P and P A “P, which are T and F respectively, are independent of the statement by which the variable P may be replaced. A statement formula which is true regardless of the truth values of the statements which replace the variables in it is called a universally valid formula or a tautology or a logical truth. A statement formula which is false regardless of the truth values of the statements which replace the variables in it is called a contradiction. Obviously, the negation of a contradiction is a tautology. We may say that a statement formula which is a tautology is identically true and a formula which is a contradiction is identically false. A straightforward method to determine whether a given formula is a tautology is to construct its truth table. This process can always be used but often becomes tedious, particularly when the number of distinct variables is large or when the formula is complicated. Recall that the numbers of rows in a truth table is 2”, where n is the number of distinct variables in the formula. Later, Table 1-2.13 P .? PY? PAT? T F T PF F z T F 1-2 connnerives 25 alternative methods will be developed that will be able to determine whether a statement formula is a tautology without having to construct its truth table, A simple fact about tautologies is that the conjunction of two tautologies is also a tautology. Let us denote by A and B two statement formulas which are tautologies. If we assign any truth values to the variables of A and B, then the truth values of both A and B will be T. Thus the truth value of A A B will be T, 80 that A A B will be a tautology. A formula A is called a substitution instance of another formula B if A can be obtained from B by substituting formulas for some variables of B, with the condition that the same formula is substituted for the same variable each time it occurs. We now illustrate this concept. Let B: P (J A‘P) Substitute R = S for P in B, and we get A: (R@S) > WA (RBS)) Then A is a substitution instance of B. Note that (R&S) (J A P) is not a substitution instance of B because the variable P in J A P was not re- placed by R = S. It is possible to substitute more than one variable by other formulas, provided that all substitutions are considered to occur simultaneously, For example, substitution instances of P —- ~]Q are 1 (RAS) >1W VM) 2 (RAS) > (RAS) 8 (RAS) >7P 4 Q—>U(P A712) In (2) both P and @ have been replaced by & A “|S. In (4), P is replaced by Qand Q by PA “19. Next, consider the following formulas which result from P — “]Q. 1 Substitute P V Q for P and R for Q to get the substitution instance (PV Q) > 77k. 2 First substitute P VQ for P to obtain the substitution instance (PV Q) +1. Next, substitute R for Q in (P V Q) > 1Q, and we get (PV &) > 1. This formula is a substitution instance of (P V Q) > 1Q, but it is not a substitution instance of P > ~|Q under the substitution (P V Q) for P and R for Q. This statement is true because we did not .ubstitute simul- taneously as we did in (1). It may be noted that in constructing substitution instances of a formula, substitutions are made for the atomic formula and never for the molecular for- mula, Thus P — Q is not a substitution instance of P— “]R, because it is R which must be replaced and not “1B. The importance of the above concept lies in the fact that any substitution instance of a tautology is a tautology. Consider the tautology P V “|P. Regard- Jess of what is substituted for P, the truth value of P V ~ |P is always I’. There- fore, it we substitute any statement formula for P, the resulting formula will be 28 MATHEMATICAL Loaic a tautology. Hence the following substitution instances of P V “|P are tau- tologies. (RS) V VR 8) UP V 8) AR) V VP VS) AR) (CPV 1Q@) > R) @ 8) V TWP V 71) > RB) & 8) Thus, if it is possible to detect whether a given formula is a substitution instance of a tautology, then it is immediately known that the given formula is also a tautology. Similarly, one can start with a tautology and write a large number of formulas which are substitution instances of this tautology and hence are themselves tautologies. EXERCISES 1-28 1 From the formulas given below select those which are well-formed according to the definition in Sec. 1-2.7, and indicate which ones are tautologies or contradictions. (a) (P> (PY Q)) (b+) ((P—> CP) > TP) (ce) (CIQA P) A Q) (4) (P— (Q— R)) > (PQ) > (P> R))) (2) (TPQ) > (Q@> P))) (f) (PA Q) = P) 2 Produce the substitution instances of the following formulas for the given substitutions. (a) (((P—>Q) > P) > P); substitute (P— Q) for P and ((P AQ) R) for Q. (8) ((P—Q)—4 (Q— P)) ; substitute Q for P and (P AP) for Q. 3 Determine the formulas which are substitution instances of other formulas in the list and give the substitutions. (a) (P+ (Q— P)) (8) ((((P—+Q) A (R>8)) A (PV R)) > @YV 8)) (c) (Q— ((P> P)Q)) (a) (P— ((P— (QP) > P)) (e) ((((R> 8) A (Q> P)) A (RV Q)) > (SV P)) 1-2.9 Equivalence of Formulas Let A and B be two statement formulas and let P;, Pz, ..., Px denote all the variables occurring in both A and B. Consider an assignment of truth values to P), Po, ..., Pa and the resulting truth values of A and B. If the truth value of A is equal to the truth value of B for every one of the 2" possible sets of truth values assigned to P;, P2, ..., Pa, then A and B are said to be equivalent. Assum- ing that the variables and the assignment of truth values to the variables appear in the same order in the truth tables of A and 8, then the final columns in the truth tables for A and B are identical if A and B are equivalent. Here are some examples of formulas which are equivalent. Verify their equivalence by truth tables. 1 WP is equivalent to P. “ PV P is equivalent to P. 1-2 connectives 27 8 (PAW) V Qis equivalent to Q. 4 PV “Ps equivalent to Q V 10. In the definition of equivalence of two formulas, it is not necessary to as- sume that they both contain the same variables. This point is illustrated in the examples given in (3) and (4) above. It may, however, be noted that if two formulas are equivalent and a particular variable occurs in only one of them, then the truth value of this formula is independent of this variable. For example, in (3) the truth value of (P A —1P) V Q is independent of the truth value of P. Similarly in (4), the truth values of P V “|Pand Q V ~]Q are each independent of P and Q. Recalling the truth table (Table 1-2.10) in the definition of the bicondi- tional, it is clear that P = Q is true whenever both P and Q have the same truth values. Therefore the statement formulas A and B are equivalent provided A= Bis a tautology; and, conversely, if A = B is a tautology, then A and B are equivalent. We shall represent the equivalence of two formulas, say A and B, by writing “A = B,” which is read as “A is equivalent to B.” Note that the expression ‘(A <> B” which can also be displayed as AB should be written as AP ee HBP according to the rules given earlier (in Sec. 1-1) regarding the use and mention of expressions. Observe that ‘‘A < B’’ is a statement in English (the metalan- guage) and not in the object language. Also the symbol ‘'¢>" is not a connective but a symbol in the metalanguage. Having noted this, we shall often drop the quotation marks because this will not lead to any ambiguity. Equivalence is a symmetric relation; that is, “A is equivalent to B” is the same as “B is equivalent to A.” Also if A Band BC, then ASC. This relationship may also be expressed by saying that the equivalence of state- ment formulas is transitive. As in the case of tautologies, one method to determine whether any two statement formulas are equivalent is to construct their truth tables. All com- binations of truth values associated with the variables appearing in both formulas are presented in the table, and the final columns (for the two formulas) are compared. EXAMPLE 1 Prove (P > Q) # (]P V Q). soLuTion See Table 1-2.14. Note that the truth values in the columns for P—Qand “TP V Q are identical, and so the biconditional will have the truth value 7’. To compare columns, it is not necessary to form the biconditional; thus the last column could have been avoided. Af A list of some basic equivalent formulas which will be found useful is given in Table 1-2.15, In order to make the list complete, we use T and F as special variables in the sense that T can be replaced by only a tautology and F by only @ contradiction.

You might also like