Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
34 views
56 pages
Chapter 2
Uploaded by
Rajesh Koothrasali
AI-enhanced title
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
Download
Save
Save chapter 2 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
34 views
56 pages
Chapter 2
Uploaded by
Rajesh Koothrasali
AI-enhanced title
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
Carousel Previous
Carousel Next
Download
Save
Save chapter 2 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save chapter 2 For Later
You are on page 1
/ 56
Search
Fullscreen
Chapter 2 Logic NA SENSH, we know a lot more than we realise, because everything that ‘we know has consequences—logical consequences—that follow automat- ically. If you know that all humans are mortal, and you know that Socrates is human, then ina sense you know that Socrates is mortal, whether or not you have ever considered or wanted to consider that fact. This is an example of logical deduction: from the premises that “All humans are mortal” and “So- crates is human’, the conclusion that “Socrates is mortal” can be deduced by logic. Socrates wasa Greek philosopher who sufeed a a most unfortunate fate. In one of the most famous mathematical argument—the one out lined above-she isthe man that is destined to Sie, History os since ought us se were night as Socrates ded after along fe (7 years), ene tenced fo death for corrupting the minds ofthe Youthof Athens is disciple Pato wrote many Sreratc dialogues which pve an insight In the philosophy of Socrates ofen summarised es “Tknow that iow nothing” The ast words ofthis mortal man were (ccord- ing to Pato) “Crit, we owe a cock to Aslepis. pay hand do rot neglect.” The fate ofthe chicken unknove, Source: en. wikipedia. org/wiki/Socrates.6 Chapter 2. Logic Logical deduction is a kind of computation. By applying rules of logic toa given set of premises, conclusions that follow from those premises can. be generated automatically. This computational process could for instance be carried out by a computer. Once you know the premises, or are will- ing to accept them for the sake of argument, you are forced by logic to ac- cept the conclusions. Stil, to say that you “know” those conclusions would bbe misleading. The problem is that there are too many of them (infinitely many), and, in general, most of them are not particularly interesting. Until you have actually made the deduction, you don't really know the conclusion, and knowing which of the possible chains of deduction to follow is not easy. ‘The art of logic isto find an interesting conclusion and a chain of logical de- ductions that leads from the premises to that conclusion. Checking that the deductions are valid is the mechanical, computational side of logic: This chapter is mostly about the mechanics of logic. We will investig ate logic as a branch of mathematics, with its own symbols, formulas and rules of computation. Your objective is to learn the rules of logic, to under- stand why they are valid, and to develop skill in applying them. As with any branch of mathematics, there is a certain beauty to the symbols and for mulas themselves. But itis the applications that bring the subject to life for most people. We will, of course, cover some applications as we go along, Ina sense, though, the real applications of logic include much of computer science and of mathematics itself ‘Among the fundamental clements of thought, and therefore of logic, are propositions. A proposition isa statement that has a truth value: itis either true or false. “Delft is a city” and “2+2 — 42” are propositions. In the first part of this chapter, we will study propositional logic, which takes pro- positions and considers how they can be combined and manipulated. This branch of logic has surprising application to the design of the electronic cir- cuits that make up computers. This ties closely to the digital and boolean logic you will study in your course Computer Organisation. Logie gets more interesting when we consider the internal structure of propositions, In English, a proposition is expressed as a sentence, and, as ‘you know from studying grammar, sentences have parts. A simple sentence like “Delft is a city” has a subject and a predicate. ‘The sentence says some:2.1. Propositional Logic thing about its subject. The subject of "Delft isa city” is Delft. The sentence says something about Delft. The somcthing that the sentence says about its subject is the predicate, In the example, the predicate isthe phrase ‘is city’ Once we start working with predicates, we can create propositions using quantifiers like ‘all, ‘some’ and ‘no’. For example, working with the predic- ate ‘has a university’ we can move from simple propositions like “Delft has university” to “All ities have a university” or to “No city has a university” or to the rather more realistic “Some cities have a university” Logical deduction usually deals with quantified statements, as shown by the basic example of human mortality with which we began this chapter. Logical deduction will be a major topic ofthis chapter; and under the name of proof, it will be the topic of the next chapter and a major tool for the rest of this book and indeed your computer science degece programme. 2.1 Propositional Logic We humans use a natural language when we speak, such as Dutch, English or Flemish. Natural languages are ambiguous and often vague. ‘To start modelling them we first consider propositional logic. This form of logic is arguably the easiest to work with, but also has limited expressive power. However even with this form we can already encapsulate many arguments and power a number of applications, for instance digital logic in chip design 2.1.1 Propositions A proposition is a statement which is either true or false. In propositional logic, we reason only about propositions and see what we can do with them. Since this is mathematics, we need to be able to talk about propositions ‘without saying which particular propositions we are talking about, so we use symbolicnames to represent them. We will always use lowercase letters such as p, q and r to represent propositions. A letter used in this way is called a propositional variable, Remember that when we say something like “Let p be a proposition”, we mean “For the rest of this discussion, let the symbol p stand for some particular statement, which is either true or false (although we're not at the moment making any assumption about which itis).” The discussion has mathematical generality in that p can represent any statement, and the discussion will be valid no matter which statement it represents,8 Chapter 2. Logic Qo Propositional variables are alittle bit like variables in a program- ming language such as Java. A basic Java variable such as int x can take any integer value. There is ‘a little bit’ of similarity between the two notions of variables—don't take the analogy too far at this point in your learning! 21.2 Logical operators What we do with propositions is combine them with logical operators, also referred to as logical connectives. A logical operator can be applied to one lor more propositions to produce a new proposition. The truth value of the new proposition is completely determined by the operator and by the truth values of the propositions to which itis applied." In English, logical oper- alors are represented by words such as ‘and’, ‘or’ and ‘not’. For example, the proposition “T wanted to leave and I left” is formed from two simpler propositions joined by the word ‘and’. Adding the word ‘not’ to the pro- position “Tleft” gives "I did not leave” (after a bit of necessary grammatical adjustment) But English is a little too rich for mathematical logic. When you read the sentence “I wanted to leave and I left”, you probably see a connotation of causality: I left because I wanted to leave. This implication does not follow from the logical combination of the truth values of the two propositions “I wanted to leave” and “left”. Or consider the proposition “I wanted to leave but I did not leave”. Here, the word ‘but’ has the same logical meaning as the word ‘and’, but the connotation is very different. So, in mathematical logic, we use symbols to represent logical operators. ‘These symbols do not carry any connotation beyond their defined logical meaning. The logical operators corresponding tothe English words ‘and, ‘or’ and ‘not are AV and Definition 2.1. Let p and q be propositions. Then p Vq, p Aq, and =p are propositions, whose truth values are given by the rules: # pAqis true when both p is true and q is true, and in no other case # p\vqistrue when either pis true, or qis true, or both p and q are true, and in no other case isnot always true thatthe ruth value of a sentence can be determined from the truth values of is component pars. For example, fps a proposition, then Jahan Cruyit believes p” Isalso a proposition, so Cruyif believes is some kind of operator. However, i des nol count asa loicl operator because just from knowing whether or not pis re, we get no information tall about whether Johan Cray believes pis true. Other textbooks might use diferent notations to represent a negation. For instance 3 har ‘over the variable (2) or a~ symbol (~ 2). In Boolean algebra (and thus in your Computer Organisation course) you wil also often find the + symbol to represent an ‘or and a" (ot) sytnbol to eepresent an ‘and’2.1. Propositional Logic 9 “pis true when p is false, and in no other case The operators /, V and ~ are referred to as conjunction, disjunction and negation, respectively. (Note that pq is read as ‘p and q, pV q is read as ‘por q’, and “pis read as ‘not p’) @ | Comsiser te statement “Iam a CSE student or lam nota TPM student.” Taking p to mean “Iam a CSE student” and q to mean “Lama IPM student”, you can write this as p V4, 2.13 Precedence rules These operators can be used in more complicated expressions, such as p A xq or (pVq) A (qr). A proposition made up of simpler propositions and logical operators is called a compound proposition. Just ike in mathemat- ics, parentheses can be used in compound expressions to indicate the order in which the operators are to be evaluated. In the absence of parentheses, the order of evaluation is determined by precedence rules. For the logical operators defined above, the rules are that ~ has higher precedence than /\, and /\has precedence over V. This means that in the absence of parentheses, any > operators are evaluated first, followed by any A operators, followed by any V operators, For example, the expression “pV q /\r is equivalent to the expression (-p) vq Ar), while pV q Aq V ris equivalent to p (qq) Vr This still ieaves open the question of which of the A operators in the ex- pression p Aq /\r is evaluated first. This is settled by the following rule: ‘When several operators of equal precedence occur in the absence of paren- theses, they are evaluated from left to right. Thus, the expression p Aq Aris equivalent to (pq) Ar rather than to p 4 (q Ar). In this particular case, as ‘a matter of fact, it doesn’t really matter which A operator is evaluated first, since the two compound propositions (pq) Arand pA (q Ar) always have the same value, no matter what logical values the component propositions ,q,and r have. We say that / is an associative operation. We'll see more about associativity and other properties of operations in the next section, places where ambiguity may arise, In fact some textbooks even. fd them to single operators as well, eg, writing (pq) instead of pq. Although for this course we do not require them around single dperators we should never need the precedence ules out- lined above, Your parentheses should make clear the order of operations!10 Chapter 2. Logic pa T1pAq aAr_(pAaAr_pAw@An ooolo o 0 0 oo1fo0 0 0 0 o1o0fo0 0 0 0 o1ifo 4 ° 0 ro 0/0 0 0 0 roi; oo 0 0 110/10 0 0 viata. 1 1 Figure 21, A truth table that demonstrates the logical equtoalenice of (p q) Arand p A (q Ar). The fact thatthe last two colunms of ths table are identical shows that these two expressions hace the same value for all eight possible combinations of values of p, 9, andr. Every compound proposition has a main connective. The main connect- iveis the connective that is evaluated last, according to the precedence rules and parentheses. There should be no ambiguity over which is the main con- nective in a compound proposition. 21.4 Logical equivalence ‘Suppose we want to verify that, in fact, (p Aq) Ar and pA (q Ar) doalways have the same value, To do so, we have to consider all possible combina- tions of values of p, q, and r, and check that for all such combinations, the two compound expressions do indeed have the same value. It is conveni- ent to organize this computation into a truth table. A truth tables a table that shows the value of one or more compound propositions for each pos- sible combination of values of the propositional variables that they contain. We call each such combination a situation. Figure 2.1 is a truth table that compares the value of (p /.q) Ar to the value of p A (q Ar) for all possible values of p,q, and r. There are eight rows in the table because there are ex- actly eight different ways in which truth values can be assigned to p,q, and. 72 In this table, we see that the last two columns, representing the values of (pAq) Arand p A(q Ar), are identical Sin genaral if there aren variables, thon there are 2" differnt ways to assign truth values to the Varabes, Le, 2" stuations. This might become clear to you if You try to come up with 2 scheme for systematically listing ll possible sets of values, As this should not saisty you, You'll find a rigorous proof of the fact ater inthis chapter.2.1. Propositional Logic " I discuss the creation of truth tables for statements written in propositional logic in more detail in one of the pencasts of this, course: youtu.be/oua_nvpFECQ, In another pencast of this course, we discuss how you should formulate your answer when using truth tables to test for equi- FEE | valence: BYES | youtu.be/stuotUu7sse. F) | You can write the rows in a truth table in any order you like. We \/ suggest you write them in a sorted order, as in Table 2.1. This helps you to be systematic in writing out the table. It also helps us to provide feedback on your answers! More generally, we say that two compound propositions are logically ‘equivalent if they always have the same value, no matter what truth values are assigned to the propositional variables that they contain. If the number of propositional variables is small, it is easy to use a truth table to check whether or not two propositions are logically equivalent. 2.1.5 More logical operators There are other logical operators besides A, V, and —. We will consider the conditional operator, -, the biconditional operator, «>, and the exclusive2 Chapter 2. Logic or operator, <).* These operators can be completely defined by a truth table that shows their values for the four possible combinations of truth values of pand 4. Definition 2.2. For any propositions p and q, we define the propositions Pq, p © 4, and p@q according to the truth table: P oof a 1 0 oi] 4 0 1 a) 0 1 1 1 o In order to work effectively with the logical operators, you need to know more about their meaning and how they relate to ordinary English expres: sions. To that end we first consider the conditional operator in more detail im the next section, 2.1.6 Implications in English The proposition p —+ q is called an implication or a conditional. Itis usually read as ‘p implies q’. In such an implication p and q also get special names of their own. p is called the hypothesis or antecedent and q is called the conclusion or consequent. Furthermore we say that if the implication p > q holds, then p is suffi- cient for q. Thatis if pis truc thatis sufficient to also make q true. Conversel “Note thatthe symbols for these operations also die fom textbook to textbook. While —+ is fiely standard, + Is sometimes represented by = of ¢2. There is even less standardszation lof the exclusive or operator, ut that operator is generally no! so important asthe others2.1. Propositional Logic 1B ‘we say that q is necessary for p. Without q being true, itis impossible for p tobe true. That is ifq is false, then p also has to be false. In English, p + q is often expressed as ‘if p then q’. For example, if p represents the proposition “Karel Luyben is Rector Magnificus of TU Delft” and q represents “Prometheus is blessed by the gods”, then p —> q could be expressed in English as “If Karel Luyben is Rector Magnificus of TU Delft, then Prometheus is blessed by the gods.” In this example, p is false and 7 is also false. Checking the definition of p —> 9, we sce that p —> q isa true statement. Most people would agree with this, even though it is not immediately obvious, ‘The letter ‘T’ in the TUDelft logo bears, a stylized flame on top, referring to the flame that Prometheus brought from Mount Olympus to the people, against the will of Zeus. Because of this, Pro- _metheus is sometimes considered as the first engineer, and he is an important symbol for the university. His bronze statue stands in the Mekelpark at the centre of campus, Source: en.wikipedia. org/wiki/ Delft_University_of Technology. Image: weblog. library.tudel#?.nl/ 2016/01/04/english~pronetheus-is~back/. It is worth looking at a similar example in more detail. Suppose that assert that “If Feyenoord is a great team, then I'm the King of the Neth- erlands”. This statement has the form m —+ k where m is the proposition “Feyenoord is a great team” and k is the proposition “I'm the king of the Netherlands”. Now, demonstrably Iam not the king of the Netherlands, 50 kis false. Since kis false, the only way for m — k tobe trues for m tobe false as well. (Check the definition of -> in the table, if you are not convinced!) So, by asserting m — k, lam really asserting that the Feyenoord is not a great team. Or consider the statement, “Ifthe party is on Tuesday, then I'l be there”uu Chapter 2. Logic What am I trying to say if I assert this statement? Iam asserting that p — g Is true, where p represents “The party is on Tuesday” and q represents “I will be at the party”. Suppose that p is true, that is, the party does in fact take place on Tuesday. Checking the definition of —+, we sce that in the only case where pis true and p + q is true, qis also true. So from the truth of “If the party is on Tuesday, then I will be at the party” and “The party is in fact on Tuesday”, you can deduce that “T will be at the party” is also true. But suppose, on the other hand, that the party is actually on Wednesday. Then pis false. When pis false and p + q is true, the definition of p -> q allows 7 to be either true or false. So, in this case, you can’t make any deduction about whether or not I will be at the party. The statement “If the party is on ‘Tuesday, then I'll be there” doesn’t assert anything about what will happen if the party is on some other day than Tuesday. 2.1.7 More forms of implication ‘The implication -q + =p is called the contrapositive of p + q. An implic~ ation is logically equivalent to its contrapositive. The contrapositive of “If this is Tuesday, then we are in Belgium” is “If we aren‘t in Belgium, then this isn’t Tuesday”. These two sentences assert exactly the same thing, Note that p —+ q is not logically equivalent to q —> p. The implication 4 > piscalled the converse of p > q. The converse of “If this is Tuesday, then we are in Belgium’ is “If we are in Belgium, then thisis Tuesday”. Note that it is possible for either one of these statements to be true while the other is false. In English, we might express the fact that both statements are true by saying “Ifthisis Tuesday, then we are in Belgium, and conversely”. In logic, this would be expressed with a proposition of the form (p -+ 4) A (q > p) Similarly p —> q is not logically equivalent to ~p ~> -9. The implication p> -q is called the inverse of p —» g. Although this mistake is commonly made in English, for instance people often assume that when I say: “If it is morning, I drink some coffee”, I also mean that when it is not morning I do not drink coffee. But my original statement does not tell you anything, about what I do when itis not morning, ‘The biconditional operator is closcly related to the conditional operator. In fact, p ¢> q is logically equivalent to (p -> 4) A (q -* p). The proposition p © qs usually read as ‘p sf and only if q’. (The ‘p ifq’ part represents q+ p, while ‘p only if q’ is another way of asserting that p + 4.) It could also be expressed as ‘if p then g, and conversely’. Occasionally in English, ‘if.. then’ is used when what is really meant is ‘if and only if. For example, if.a parent tells a child, “If you are good, Sinterklaas will bring you toys”, the parent probably really means to say “Sinterklaas will bring you toys if and only if you are good”. (‘The parent would probably not respond well to2.1. Propositional Logic 15 the child’s perfectly logical plea “But you never said what would happen if I wasn't good!” 2.1.8 Exclusive or Finally, we turn to the exclusive or operator. The English word ‘or’ is ac- tually somewhat ambiguous. The two operators () and V express the two possible meanings of this word. The proposition pV q can be expressed unambiguously as “p or q, or both", while p @ q stands for “p or 4, but not Doth”. If'a menu says that you can choose soup or salad, it doesn’t mean that you can have both. In this case, ‘or’ is an exclusive or. On the other hand, in “You are at risk of heart disease if you smoke or drink”, the or is inclusive since you certainly don’t get off the hook if you both smoke and drink. In theoretical computer science and mathematics, the word ‘or’ is always taken in the inclusive sense of p V 4. 2.1.9 Universal operators Now, any compound proposition that uses any of the operators ~», ¢2, and canbe rewritten asa logically equivalent proposition that uses only A\, V, and ~. Itis easy to check that p —+ qis logically equivalent to -p Vg. (Just make a truth table for +p V4.) Similarly, p ¢> 4 can be expressed as (=p V 9). \(-qV p), So, in a strict logical sense, ->, «, and @ are unnecessary: (Nevertheless, they are useful and important, and we won't give them up.) Even more is true: in a strict logical sense, we could do without the con- junction operator A. It is easy to check that p A q is logically equivalent to “(ap Vg), 80 any expression that uses A can be rewritten as one that uses only >and V. Alternatively, we could do without V and write everything in terms of ~ and A. We shall study some of these rewrite rules in more detail in Section 2.2 We call a set of operators that can express all operations: functionally complete. More formally we would state the following: Definition 2.3. A set of logical operators is functionally complete if and only if all formulas in propositional logic can be rewritten to an equivalent form that uses only operators from the set Consider for instance the set {=,V}. As shown above the A, -> and operators can be expressed using only these operators. In fact all possible operations can be expressed using only (=, V}. To prove this you will show in one of the exercises that all possible formulas in propositional logic can bbe expressed using {=,V, A, +, ¢}. So by showing that we do not need A, », and © we can prove that {~, V) is also functionally complete.16 Chapter 2. Logic 2.1.10 Classifying propositions Certain types of proposition will play a special role in our further work with logic. In particular, we define tautologies, contradictions, and contingencies as follows: Definition 2.4. A compound proposition is said to be a tautology if and only if it is true for all possible combinations of truth values of the proposi- tional variables which it contains. A compound proposition is said to be a contradiction if and only if itis false for all possible combinations of truth, values of the propositional variables which it contains. A compound pro- position is said to be a contingency if and only ifit is neither a tatstology nor a contradiction For example, the proposition ((p V q) Ag) + pisa tautology. This can be checked with a truth table: P (eva Ang (PV) A~a) >? 0 0 1 0 o 1 1 1 1 1 a 1 The fact that all entries in the last column are true tells us that this ex: pression is a tautology. Note that for any compound proposition P, Pis a tautology if and only if +P is a contradiction. (Here and moving forward, ‘we use uppercase letters to represent compound propositions. P stands for any formula made up of simple propositions, propositional variables, and logical operators.) Logical equivalence can be defined in terms of tautology: Definition 2.5. Two compound propositions, P and Q, are said to be logic- ally equivalent if and only if the proposition P ¢+ Q is a tautology. ‘The assertion that P is logically equivalent to Q will be expressed sym- bolically as ‘P = Q’. For example, (p + q) = (-pVq), and p@q = (pv) Amp Aq).2.1. Propositional Logic 7 What if P > Q and P is false? From a false premise we can Exercises Recall that solutions to some ofthe exercises start on page 183. Exercises that have a solution are marked with a dagger (+) symbol. We suggest ‘you attempt the exercise first before looking at the solution! +1. Give the three truth tables that define the logical operators A, Vand ~. 12, Some of the following compound propositions are tautologies, some are contra: dictions, and some are neither (ie, so are contingencies). In each case, use a ‘ruth table to decide to which of these categories the proposition belongs DPA) a BYP FA)AG1)) > (1) ©) pAnp 4) (pva)>(pan) pvp 8) (pAg) (Pv a) 18: Use truth tables to show that each of the following propositions is logically equ valent to p 64 a) (pg lg->p) b) pong ©) (p49) Ap >) 4) (p24) 14.18 > an associative operation? This s,s (p ~> 4) > r logically equivalent to p+ (qr) 15: Let p represent the proposition “You leave" and let represent the proposition ‘Tleave”. Express the following sentences as compound propositions using p and q,and show that they are logically equivalent 2) Either you leave or I do. (Or both!) ) Ifyou don't leave, 1 will 16. Suppose that m represents the proposition “The Earth moves", ¢ represents "The Earth isthe centre of the universe", and g represents "Galileo was falsely ac cused”, Translate each ofthe following compound propositions inte English a) ag Ac b) me mere 4) (m9 g) Ale+-8) 17.Give the converse and the contrapositive of each of the following English sen- tence: a) If you are good, Sinterklaas brings you toys. ') If the package weighs more than one kilo, then you need extra postage.18 Chapter 2. Logic 6) IfThave a choice, I don't eat courgette {8.Inan ordinary deck of fily-two playing cards, for how many cards is i true 2) that “This card isa ten and this card isa heart”? 'b) that “This card isa ten or this card is a heart"? «) that “If this card is ten, then this card is a heart"? 4) that “This card isa ten ifand only if this card is a heart”? 49. Define a logical operator | so that p | qis logically equivalent to ~(p vq). (This ‘operator is usually referred to as Nox, short for ‘not or’) Show that each ofthe propositions =p, Pg, V4. P > 4, p © q, and pq can be rewritten as a logically equivalent proposition that uses | as its only operator. #10. For our proof that {-,V} is functionally complete, we need to show that all for: mulas in propositional logic can be expressed in an equivalent form using only (Av) 3) How many unique truth tables exist for formulas containing two atoms? 'b) Create a function for each of the possible truth tables that uses only the 5 ‘operators listed above ©) Give an (informal) argument why this means all formulas in propost= tional logic can be expressed using only these five operators. 2.2 Boolean Algebra So far we have discussed how to write and interpret propositions. This sec- tion deals with manipulating them. For this, we need algebra. Ordinary algebra, of the sort taught in high school, is about manipulating numbers, variables that represent numbers, and operators such as + and x that apply to numbers. Now, we need an algebra that applies to logical values, propos itional variables, and logical operators. The first person to think of logic in terms of algebra was the mathematician, George Boole, who introduced the idea in a book that he published in 1854, The algebra of logic is now called Boolean algebra in his honour.2.2. Boolean Algebra 19 George Boole (1815-1864) was a largely self = taught British mathematician, philosopher and Iogician, most of whose short career was spent as the first professor of mathematics at Queen's College, Cork in Ireland. He worked in the fields of differential equations and algebraic lo- gic, and is best known as the author of The Laws of Thought (1854). Among TU Delft stu- dents he is best known for the room named after him in the EEMCS building 36. Boolean logic is credited with laying the foundations for the in- formation age: essentially, computer science. Boole maintained that: "No general method for the solution of questions in the the- ory of probabilities can be established which does not explicitly recognise, not only the special numerical bases of the science, but also those universal laws of thought which are the basis of all reasoning, and which, whatever they may be as to their essence, are at least mathematical as to their form.” Source: en.wikipedia .org/viki /George Boole, ‘The algebra of numbers includes a large number of rules for manipu- lating expressions. The distributive law, for example, says that x(y +2) xy +xz, where x, y,and z are variables that stand for any numbers or nume ical expressions. This law means that whenever you see something of the form xy + 22 ina numerical expression, you can substitute x(y +2) without changing the value of the expression, and vice versa. Note that the equals sign in x(y +z) = xy +.xz means “has the same value as, no matter what numerical values x, y, and z have", In Boolean algebra, we work with logical values instead of numerical values. There are only two logical values, true and false. We will write these values as T and F or 1 and 0, The symbols T and F play a similar role in Boolean algebra to the role that constant numbers such as 1 and 3.14159 play in ordinary algebra. Instead of the equals sign, Boolean algebra uses logical equivalence, =, which has essentially the same meaning,” For example, for propositions p, q, and r, the = operator in p (qr) = (p Aq) Ar means Sin ordinary algebra is easy fo be confused by the equals sign, because it has two very different roles, In an identity auch as the distributive lw, st means i always equal to’. On the other hand, an equation such as x? + 3x = 4 isa statement that might oF might not be tue, depending on the value of x. Boolean algebra has two operators, = and ¢, that play soles similar tothe two tole ofthe equals sign. = i used for identi, whereas 418 Used ih ‘equations that may or may not be tue20 Chapter 2. Logic Double negation | =(Gp) =P Excluded middle | pVap=T Contradiction pA-p=F Identity laws TAp=P RVp=p Idempotentlaws | pAp—p pYp=P Commutative laws | pAq=qAp pVq=4qvp “Associative laws | (pAq)Ar=pA(@An) @vavr=pvave Distributive laws | pA(qV1r) = (pAq)¥ (pAr) PV (Gr) = (pV a) A(pVr) DeMorgan'slaws | =(p..g) = (=p) V (=a) APY 9) = (oP) Aa) Figure 22: Laws of Boolean Algebra These laws hold for any propositions p.qeand r “pas the same value as, no matter what logical values p,q, and r have". 2.2.1 Basics of Boolean Algebra Many of the rules of Boolean algebra are fairly obvious, if you think a bit about what they mean. Even those that are not obvious can be verified easily by using a truth table. Figure 22 lists the most important of these laws. You will notice that all these laws, except the first, come in pairs: each law in the pair can be obtained from the other by interchanging A with V and T with F. This cuts down on the number of facts you have to remember Just as an example, let's verify the first rule in the table, the Law of Double Negation. This law is ust the old, basic grammar rule that two neg- “iisalso an example of a more general fact known as duality, which assorts that given ary tautology that uses enly the operators fv, and ~, another tautelogy ean be obtained from iby interchanging A with V and T with F, We won't atempt to prove this here but we encourage yo to try it2.2. Boolean Algebra 2 atives makea positive. Although the way this rule applies to English is ques- tionable, if you look at how itis used—no matter what the grammarian says, “Lcan‘t get no satisfaction” doesn’t really mean “I can get satisfaction”—the validity of the rule in logic can be verified just by computing the two pos- sible cases: when p is true and when pis false. When p is true, then by the definition of the ~ operator, ~p is false. But then, again by the definition of », the value of >(-p) is true, which is the same as the value of p, Similarly, in the case where p is false, ~(=p) is also false. Organized into a truth table, this argument takes the rather simple form ‘The fact that the first and last columns ate identical shows the logical equivalence of p and (-p). The point here is not just that (=p) = p, but also that this logical equivalence is valid because it can be verified compu- tationally based just on the relevant definitions. ts validity does not follow from the fact that “it obvious” or “its a well-known tule of grammar” Students often ask “Why do I have to prove something when generally—is its own little world with its own set of rules. Al- though this world is related somchow to the real world, when you say that something is obvious (in the real world), you aren't playing by the rules of the world of logic. The real magic of math- ‘ematics is that by playing by its rules, you can come up with things that are decidedly not obvious, but that still say some- thing about the real world or the computational world—often, something interesting and important, Each of the rules in Figure 2.2 can be verified in the same way, by making. a truth table to check all the possible cases. In one of the pencasts of this course we further discuss how to check the equivalence of two propositions using truth tables. 2.2.2 Substitution laws It’s important to understand that the propositional variables in the laws of Boolean algebra can stand for any propositions, including compound propositions. It is not just true, as the Double Negation Law states, that22 Chapter 2. Logic (ap) = p. Itis also true that +(-9) = q, that +(-(p Aq)) = (pq), that (lp > (7A-p))) = (p > Amp), and an infinite number of other statements of the same form, Here, a ‘statement of the same form’ is one that can be obtained by substituting something for p in both places where it occurs in (=p) = p. How can Ibe sure that all these infinitely many statements are valid when all that I've checked is one little two-line truth, table? The answer is that any given proposition, Q, no matter how complic- ated, has a particular truth value, either true or false. So, the question of the validity of -(-Q) = Q always reduces to one of the two cases I already checked in the truth table. (Note that for this argument tobe valid, the same Q must be substituted for p in every position where it occurs.) While this, argument may be ‘obvious’, itis not exactly a proof, but for now we will just accept the validity of the following theorem: ‘Theorem 2.1 (First Substitution Law). Suppose that Q is any proposition, and that p is a propositional variable. Consider any tautology. If (Q) is substituted for Pp inall places where p occurs in the tautology, then the result is also a tautology. Since logical equivalence is defined in terms of tautology, itis also true that when (Q) is substituted for p ina logical equivalence, the result is again a logical equivalence” The First Substitution Law lets you do algebra! For example, you can substitute p + g for pin the law of double negation, (+p) = p. Thisallows, you to ‘simplify’ the expression -(—(r + q)) tor ++ g with confidence that the resulting expression has the same logical value as the expression you started with (That’s what it means for “(-(r ~> q)) andr > q to bbe logically equivalent.) You can play similar tricks with all the laws in Figure 2.2. Even more importantis the Second Substitution Law, which says that you can substitute an expression for a logically equivalent expression, wherever it occurs. Once again, we will accept this as a theorem without trying to prove it here. Itis surprisingly hard to put this law into words: ‘Theorem 2.2 (Second Substitution Law). Suppose that P and Q are any pro positions such that P = Q. Suppose that R is any compound proposition in which (P) occurs as a sub-proposition. Let R’ be the proposition that is obtained by sub- stituting (Q) for that occurrence of (P) in R. Then R = R! Note that in this case, the theorem does not require (Q) tobe substituted for every occurrence of (P) in R. You are free to substitute for one, two, "Eve added parentheses around (here for technical reasons, Sometimes, the parentheses aronecessary to make sue that is evaluated as whole, so thal ts final values used in place fof p_ Asan example of what can go wzong, consider © I this is substituted literally for p in (7p), without parentheses the results “(9 hr). But this expression means ~((-g) 47), Which fs not equivalent tog Ar, Did wesay to always write parentheses i you're in doubt? See pase’.2.2. Boolean Algebra 23 or as many occurrences of (P) as you like, and the result is still logically equivalent to R. ‘The Second Substitution Law allows us to use the logical equivalence = (=p) = p to simplify’ the expression q + ((-p)) by substituting +(-p) for p. The resulting expression, q -> p, is logically equivalent to the original 4 + (-(-p)}. Once again, we have to be careful about parentheses: The fact that pV p = p does not allow us to rewrite q A pV p ArasqAp Ar. The problem is that q A pV p Ar means (q A p) V (p Ar), So that (pV p) is not a sub-expression. This again underlines the importance of always writing parentheses in your propositional formulas, 2.2.3 Simplifications The final piece of algebra in Boolean algebra is the observation that we can chain logical equivalences together. That is, from P = Q and Q = R, it follows that P = R. This is really just a consequence of the Second Substi- tution Law. The equivalence Q = R allows us to substitute R for Q in the statement P = Q, giving P = R. (Remember that, by Definition 25, logical equivalence is defined in terms of a proposition.) This means that we can show that two compound propositions are logically equivalent by finding a chain of logical equivalences that lead from one to the other. Here is an example of such a chain of logical equivalences: pA(p—q) =pA(-pva) definition of p + q, Theorem 22 (pAnp)V(pAq) Distributive Law =FV(paq) Law of Contradiction, Theorem 2.2 = (pag) Identity Law Each step in the chain has its own justification, In several cases, a substitu: tion law is used without stating as much, In the first line, for example, the definition of p ~> q is that p> q = >p\q. The Second Substitution Law allows us to substitute (pV q) for (p —> q)- In the last line, we implicitly applied the First Substitution Law to the Identity Law, F'v p = p, to obtain FV (pAq) = (pq) The chain of equivalences in the above example allows us to conclude that pA (p > 9) is logically equivalent to p Aq. This means that if you were to make a truth table for these two expressions, the truth values in the column for p A (p —> q) would be identical to those in the column for pg. We know this without actually making the table. Don’t believe it? Go ahead and make the truth table, In this case, the table is only be four lines Tong and easy enough to make. But Boolean algebra can be applied in cases24 Chapter 2. Logic where the number of propositional variables is too large for a truth table to be practical. @ | wets do another example, Real that compound proposition is a tautology if itis true for all possible combinations of truth values of the propositional variables that it contains. But another ‘way of saying the same thing is that P is a tautology if P = T. S ‘we can prove that a compound proposition, P, is a tautology by finding a chain of logical equivalences leading from P to T. For example: (Pv 9) A>) > =(-((pvg) Ap) vq definition of > = ((P Vg) Va(-p)) Vq_ DeMorgan’s Law, Theorem 2.2 = (va) vp) vq Double Negation, Theorem 2.2 =(-(PV9)) V(PVq) Associative Law for V =T Law of Excluded Middle From this chain of equivalences, we can conclude that ((p'V q) »p) isa tautology. Now, it takes some practice to look at an expression and see which rules can be applied to it; to see (-(p V 4) V (pV q) as an application of the law of the excluded middle for example, you need to mentally substitute (p V q) for pin the law as itis stated in Figure 2.2. Often, there are several rules that apply, and there are no definite guidelines about which one you should try. This is what makes algebra something of an art 2.2.4 More rules of Boolean algebra Itis certainly not true that all possible rules of Boolean algebra are given in Figure 2.2. For one thing, there are many rules that are easy consequences of the rules that are listed there. For example, although the table asserts only that FV p = p, itis also true that p VF = p. This can be checked directly or by a simple calculation’ pVE=Fvp Commutative Law =p Identity Law as given in the table2.2. Boolean Algebra 25 Additional rules can be obtained by applying the Commutative Law to other rrules in the table, and we will use such rules freely in the future. Another sort of easy extension can be applied to the Associative Law, (pv q) Vr = pv (qV7). The law is stated for the V operator applied to thrce terms, but it generalizes to four or more terms. For example (wvavnvs =(p¥q)V(rVs) _ by the Associative Law for three terms PV(@V (VS) _ by the Associative Law for three terms ‘We will, of course, often write this expression as p V q Vr V's, with no par entheses at all, knowing that wherever we put the parentheses the value is the same. © | Qre-ether hing that you shoul Keepin mind is that rules can be applied in either direction, The Distributive Law, for example, allows you to distribute the p in pV (q 7p) to.get (pV) A(pV 1). But it can also be used in reverse to factor out’ a term, as when you start with (q V (p> q)) (qv (q — p)) and factor out the g to get qv ((p > 4) A (q > p)) So far in this section, we have been working with the laws of Boolean, algebra without saying much about what they mean or why they are reas- onable. Of course, you can apply the laws in calculations without under- standing them. But if you want to figure out which calculations to do, you need some understanding. Most of the laws are clear enough with a little thought. For example, if we already know that q is false, then pV q will be true when p is true and false when p is false. That is, p V F has the same logical value as p. But that’s just what the Identity Law for V says. A few of the laws need more discussion. ‘The Law of the Excluded Middle, pV =p = T,, says that given any pro- position p, at least one of p or ap must be true. Since +p is true exactly when p is false, this is the same as saying that p must be either true or false. There is no middle ground. The Law of Contradiction, pA ap = E, says that it is not possible for both p and -p to be true. Both of these rules are obvious.26 Chapter 2. Logic @ _ | There are some who set out to question the law of there being no @@ | Middle ground. Already in the 1920's people like Tarski (who ‘we will meet later) talked about other forms of logic where another value representing ‘unknown’ or ‘not proven’ also exists. You can also see this in some programming languages where they are referred to as ‘tri-state booleans. ‘These so-called non-standard logics have been developed and have also lead to things like “fuzzy logic’, which some consider quite contro- versial. Lotfi Zadch is credited as the first per- s0n to refer to this type of logic as fuzzy logic in his work on ‘fuzzy sets’ in 1965. Zadeh was Inter quoted as saying, "Not being afraid to get { embroiled in controversy. .. That's part of my character, too. I can be very stubborn. ‘That's probably been beneficial for the development of Fuzzy Logic.” Source: on.vikipedia.org/viki/Lotfi_A._Zadeh ‘The Distributive Laws cannot be called obvious, but a few examples can show that they are reasonable. Consider the statement, “This card is the ace of spades or clubs.” Clearly, this is equivalent to “This card is the ace of spaces or this card is the ace of clubs.” But this is just an example of the first distributive law! For, let a represent the proposition “This card is an acc’, let s represent “This card is a spade” and let c represent “This card is a club”, Then “This card is the ace of spades or clubs” can be translated. into logic as a (sV c), while “This card is the ace of spades or this card is, the ace of clubs” becomes (a As) V (a/c). And the distributive law assures us that a “(5 Ve) = (as) V (@ Ac). The second distributive law tells us, for example, that “This card is either a joker or is the ten of diamonds” is, logically equivalent to “This card is either a joker or a ten, and itis either a joker or a diamond”. That is, jV (Fd) = (JV) A(j Vd). The distributive laws are powerful tools and you should keep them in mind whenever you are faced with a mixture of 4 and \V operators. DeMorgan’s Laws must also be less than obvious, since people often get, them wrong. Fortunately you get to practice them both in Reasoning & Logic, as well as in Computer Organisation, so you will soon get them right. More importantly perhaps they do also make sense. When considering ~(p Aq), you should ask yourself, how can ‘p and q’ fail to be true. It will fail to be2.2. Boolean Algebra 7 true if either p is false or if qis false (or both). That is, -(p Aq) is equivalent to (>p) V (-9). Consider the sentence “A raven is large and black” Ifa bird isnot large and black, then itis nota raven. But what exactly does it mean to be ‘not (large and black)’? How can you tell whether the assertion ‘not (large and black)’ is true of something? This will be true if tis either not large or not black. (It doesn’t have to be both—it could be large and white, it could be small and black.) Similarly, for ‘p or q’to fail tobe true, both p and q must be false. That is, ~(p V q) is equivalent to (=p) A (=). This is DeMorgan’s second law. Recalling that p > qis equivalent to (~p) Vg, we can apply DeMorgan’s law to obtain a formula for the negation an implication: ap + 4) = (Cp) V9) =P) \(-9) =panq That is, p > q is false exactly when both p is true and q is false. For example, the negation of “If you have an ace, you win” is “You have an ace, and you don’t win”. Think of it this way: if you had an ace and you didn’t win, then the statement “If you have an ace, you win” was not true. Exercises truth tables to demonstrate the validity of each of the distributive truct the following truth tables: ‘) Construct truth tables to demonstrate that ~(p /\q) is not logically equi- valent to (=p) A (-9). 1b) Construct truth tables to demonstrate that (pV 4) is not logically equi- valent to (=p) ¥ (-q). ©) Construct truth tables to demonstrate the validity of both DeMorgan’s Laws. 3. Construct truth tables to demonstrate that ~(p + q) i no logically equivalent to any of the folowing 3) p) +9) BOP) 99 ©) p> (-9) Refer back to this section for a formula that is logically equivalent to >(p -» 4) #415 =(p 4) logically equivalent to =p) ¢» (9)? 5. In the algebra of numbers, there isa distributive law of multiplication over ad- dition: a(y + 2) = xy sz. What would a distributive law of addition over ‘multiphiation look lke? Isita valid law inthe algebra of numbers?28 Chapter 2. Logic 6. The distributive laws given in Figure 2.2 are sometimes called the left distributive laws. The right distributive laws say that (pV 9) Ar = (pr) v (g Ar) and that (pag) Vr = (pV) A Gv). Show that the right distributive laws are also valid laws of Boolean algebra. (Note: In practice, both the left and the right distributive laws are referred to simply as the distributive laws, and both ean be used freely in proofs.) 7.Show that pA (Vrs) = (pg) V (p Ar) V (ps) for any propositions p, 4,7, ands, In words, we can say that conjunction distributes over a disjunction of three terms. (Recall that the / operator is called conjunction and is called. disjunction.) Translate into logic and verify the fact that conjunction distributes over a disjunction of four terms. Argue that, in fact, conjunction distributes over a disjunction of any number of terms, 8. There are two additional basic laws of logic, involving the two expression p AF and pV'T. What are the missing laws? Show that your answers ar, in fact, laws. 9. For each of the following pairs of propositions, show that the two propositions are logically equivalent by finding a chain of equivalences from one to the other. State which definition or law of logic justifies each equivalence in the chain, PAAR), PAG BOP) 4 PvE OWVDA~E PAmY a) por), Page e)(PanaQqor, (pyaar Dpa(prqh prog 10. For each of the following compound propositions, find a simpler proposition ‘thats logically equivalent. Try to find a proposition that is as simple as possible. a) (pag) vg b)ipva)ap poop 4) op A(pva) ©) GAP) +g H(pPo aac a) #11. Express the negation of each of the following sentences in natural English: a) Itis sunny and cold 'b) [will have stroopwafel or I will have appeltaart. «) Iftoday is Tuesday, this is Belgium, 4) Ifyou pass the final exam, you pass the course, 12 Apply one of the laws of logte to each of the following sentences, and rewrite as an equivalent sentence. State which law you are applying, 3) [will have coffee and stroopwafel or appeltaart b) He has neither talent nor ambition. «¢) You can have oliebollen, oF you can have oliebollen 1, Suppose itis simultaneously teue that “All lemons are yellow” and “Not all em- tons ate yellow”. Derive the conclusion "Unicorns exist”. (Ifyou get stuck, check out en. wikipedia. org/viki/Principle_of explosion.) 2.3. Application: Logic Circuits As we saw in Chapter 1, computers have a reputation—not always deserved— for being ‘logical’. But fundamentally, deep down, they are made of logic in a very real sense. The building blocks of computers are logic gates, which23. Application: Logic Circuits 29 are electronic components that compute the values of simple propositions such as p /\q and sp. (Each gate is in turn built of even smaller clectronic components called transistors, but this needn’t concern us here: see the course Computer Organisation.) isation, not in Reasoning & Logic. They are a good example and application of propositional logic, and that’s why we're talking about them in this section. Normal forms (Section 2.3.4) are def- initely on the syllabus, however, so pay attention! e Don’t worry, logic circuits will be examined in Computer Organ- 2.3.1 Logic gates A wire ina computercanbe in one of two states, which we can think of as be- ing on and off. These two states can be naturally associated with the Boolean values T and F. When a computer computes, the multitude of wires inside itare turned on and off in patterns that are determined by certain rules. The rules involved can be most naturally expressed in terms of logic. A simple rule might be: “turn wire C on whenever wire A is on and wire B is on’. This rule can be implemented in hardware as an AND gate, An anv gate is an electronic component with two input wires and one output wire, whose job is to turn its output on when both of its inputs are on and to tum its out put off in any other case. If we associate ‘on’ with T and ‘off’ with F, and if we give the names A and B to the inputs of the gate, then the gate computes the value of the logical expression A /\B. In effect, A is a proposition with the meaning “the first input is on”, and B is a proposition with the meaning “the second input is on”, The anv gate functions to ensure that the output is described by the proposition A /\B. That is, the output is on if and only if the first mput is on and the second input is on. ‘As you hopefully know from Computer Organisation, an OR gate is an electronic component with two inputs and one output which tums its out put on if either (or both) of its inputs is on. If the inputs are given names Aaand B, then the ox gate computes the logical value of A V B. A NOT gate has one input and one output, and it turns its output off when the input is on and on when the input is off. Ifthe input is named A, then the Nor gate computes the value of A. As we mentioned earlier, other textbooks might use different A notations to represent a negation. For instance a bar over the variable @ or a ~ symbol. In digital logic (and thus in your Com- puter Organisation course) you will also often find the + symbol to represent an ‘or’ and a - (dot) symbol to represent an ‘and’30 Chapter 2. Logic DD LS AND gate OR gate NOT gate ay = Ly output co Figure 23; The standard symbols for the three basic logic gates, and a logic circuit that computes the value of the logical expression (—A) A (BY (AAC). The input wires to each logic gate are on the left, with the output wire on the right. Note that when wires cross each other in a diagram such as this, the wires don’t actually intersect unless there isa black circle at the point where they cross. Other types of logic gates are, of course, possible, Gates could be made to compute A + Bor A B, for example. However, any computation that can be performed by logic gates can be done using only AND, ox, and. Nor gates, as we will see below. (In practice, however, NaND gates and NoR gates, which compute the values of +(A A B) and ~(A'V B) respectively, are often used because they are easier to build from transistors than aNp and ‘on gates.) 2.3.2 Combining gates to create circuits The three types of logic gates are represented by standard symbols, as shown in Figure 2.3. Since the inputs and outputs of logic gates are just wires carry- ing on/off signals, logic gates can be wired together by connecting outputs from some gates to inputs of other gates. The result isa logic circuit. An ‘example is also shown in Figure 23. ‘The logic circuit in the figure has three inputs, labeled A, B, and C. The circuit computes the value of the compound proposition (A) A (BY 9(A.\ )). That is, when A represents the proposition “the input wire labeled A is on,” and similarly for B and C, then the output of the circuit is on if and. only if the value of the compound proposition (A) A (BV (A AC) is true, Given any compound proposition made from the operators A, V, and —, itis possible to build a logic circuit that computes the value of that propos.23. Application: Logic Circuits 31 ition. The proposition itself is a blueprint for the circuit. As noted in Sec~ tion 2.1, every logical operator that we have encountered can be expressed interms of A, V, and >, Soin fact every compound proposition that we know how to write can be computed by a logic circuit Given a proposition constructed from A, V, and - operators, its easy to build a circuit to compute it, First, identify the main operator in the proposition—the one whose value will be computed last. Consider (A V B) A-(A AB). This circuit has two input values, A and B, which are rep resented by wires coming into the circuit, ‘The circuit has an output wire that represents the computed value of the proposition. The main operator in (AV B) A-(A/\B), is the first A, which computes the value of the ex- pression as a whole by combining the values of the subexpressions AV B and =(A A.B). This A operator corresponds to an ano gate in the circuit that computes the final output of the circuit. ‘Once the main operator has been identified and represented as a logic gate, you just have to build circuits to compute the input or inputs to that operator. In the example, the inputs to the main ax gate come from two subeircuits. One subcircuit computes the value of AV B and the other com- putes the value of =(A \ B). Building each subcircuit is a separate problem, ‘but smaller than the problem you started with, Eventually, you'll come to 2 gate whose input comes directly from one of the input wires—A or B in this case—instead of from a subcircuit 2.3.3. From circuits to propositions So, every compound proposition is computed by a logic circuit with one out- put wire. Is the reverse true? That is, given a logic circuit with one output, is there a proposition that expresses the value of the output in terms of the values of the inputs? Not quite. When you wire together some logic gates to make a circuit, there is nothing to stop you from introducing feedback loops. A feedback loop occurs when the output from a gate is connected— possibly through one or more intermediate gates—back to an input of the same gate. Figure 2.5 shows an example of a circuit with a feedback loop. Feedback loops cannot be described by compound propositions, basically because there is no place to start, no input to associate with a propositional variable. But feedback loops are the only thing that can go wrong. A logic circuit that does not contain any feedback loops is called a combinatorial lo- gic circuit. Every combinatorial logic circuit with just one output computes the value of some compound proposition. ‘The propositional variables in the compound proposition are just names associated with the input wires of the circuit. (Of course, if the circuit has more than one output, you can simply use a different proposition for cach output.)32, Chapter 2. Logic 1, We know that the final ‘output of the circuit is ave computed by an AND gate, (AA B)-] ‘whose inputs are as shown. A (AV B) 2. These inputs, in B > turn come from an OR gate and a NOT art gate, with inputs as v(AA B) shown. 3. The circuit is completed by adding an AND gate to compute the input for the NOT gate, and and connecting the circuit inputs, A and B, to the apropriate gate inputs. , 5 [- (AA B) (AA Figure 24: Stages in the construction of a circuit that computes the com pound proposition (AV B) A=(A A.B). ‘The key to understanding why this s true is to note that each wire in the ircuit—not just the final output wire—represents the value of some pro- position, Furthermore, once you know which proposition is represented by ‘cach input wire to a gate, it's obvious what proposition is represented by the output: You just combine the input propositions with the appropriate A,V, oF operator, depending on what type of gate itis. To find the propos- ition associated with the final output, you just have to start from the inputs, and move through the circuit, labeling the output wire of each gate with the proposition that it represents. Figure 2.6 illustrates this process. 2.34 Disjunctive Normal Form Compound propositions, then, correspond naturally with combinatorial lo- gic circuits. But we have still not quite settled the question of just how23. Application: Logic Circuits 33 r } Figure 2.5: This circuit contains a feedback loop, soit isnot a combinatorial logic circuit. The feedback loop includes the anp gate and the ox gate on the right. This circuit does not compute the value of a compound proposition. This circuit does, however, play an important role in computer memories, since it can be used to store a logical value. on A (AA B) ~ ees @ 4 rian) B an st ® ® Figure 2.6: Finding the proposition whose value is computed by a combin atorial logic circuit. Each wire inthe circuit is labeled withthe proposition that it represents. The mumbering of the labels shows one of the orders in which they can be associated with the wires. The circuit as a whole com- putes the oalue of (A A.B) A (BV ~C) powerful these circuits and propositions are. We've looked at a number of logical operators and noted that they can all be expressed in terms of A, V, and 7. But might there be other operators that cannot be so expressed? Equivalently, might there be other types of logic gates—possibly with some large number of inputs—whose computations cannot be duplicated with ‘AnD, on, and Nor gates? Any logical operator or logic gate computes a value for each possible combination of logical values of its inputs. We could al- ways make a truth table showing the output for each possible combination of inputs. As it tums out, given ay such truth table, itis possible to find proposition, containing only the A, V, and — operators, whose value for cach combination of inputs is given precisely by that table. ‘To see why this is true, itis useful to introduce a particular type of com- pound proposition. Define a simple term to be either a propositional vari34 Chapter 2. Logic able or the negation of a propositional variable. A conjunction of simple terms would then consist of one or more simple terms put together with (\ operators. (A ‘conjunction of one simple term’ is just a single simple term by itself This might not make grammatical sense, but it’s the way math- ‘ematicians think.) Some examples of conjunctions of simple terms would be pAG, py -g, and p Amr A-w As At. Finally, we can take one or more such conjunctions and join them into a ‘disjunction of conjunctions ofsimple terms’, This is the type of compound proposition we need. We can avoid some redundancy by assuming that no propositional variable occurs more than once in a single conjunction (since p A p can be replaced by p, and if p and —p both occur in a conjunction, then the value of the conjuction is false, and it can be eliminated.) We can also assume that the same conjunction does not occur twice in the disjunction. QA | Hrectoratioms’stctasDigurctve Normal orm (sat Piscean Definition 2.6. A compound proposition is said to be in disjunctive normal form, or DNF, if itis a disjunction of conjunctions of simple terms, and if, furthermore, each propositional variable occurs at most once in each con’ junction and each conjunction occurs at most once in the disjunction, Using p, q, 1, 5, A, and B as propositional variables, here are a few ex- amples of propositions that are in disjunctive normal form: (PAGAT)Y (pAngArAS)Y (=p 4-9) (pA~a) (AAAB) v (SAAB) PY (PAQ)Y Op A—gAr)Y (—pA~ghar Aw) Propositions in DNF are just what we need to deal with input/output tables of the type that we have been discussing. Any such table can be computed. by a proposition in disjunctive normal form. It follows that it is possible to build a circuit to compute that table using only Axo, ox, and Nor gates. Theorem 2.3. Consider a table that lists a logical output value for every combin- ation of values of several propositional variables, Assume that at least one of the ‘output oalues is true. Then there is a proposition containing those variables such that the value of the proposition for each possible combination of the values of the
You might also like
Chapter 1: The Foundations: Logic and Proofs: Discrete Mathematics and Its Applications Kenneth H. Rosen
PDF
No ratings yet
Chapter 1: The Foundations: Logic and Proofs: Discrete Mathematics and Its Applications Kenneth H. Rosen
23 pages
MCA Mathematical Foundation For Computer Application 01
PDF
No ratings yet
MCA Mathematical Foundation For Computer Application 01
22 pages
5 - Predicate Logic (Lecture 19-22)
PDF
No ratings yet
5 - Predicate Logic (Lecture 19-22)
46 pages
Discrete Mathematics
PDF
100% (1)
Discrete Mathematics
210 pages
Disc Lec2 The Foundations of Logic - Part I
PDF
No ratings yet
Disc Lec2 The Foundations of Logic - Part I
18 pages
Logic PDF
PDF
No ratings yet
Logic PDF
113 pages
Proposition Al
PDF
No ratings yet
Proposition Al
137 pages
Lec02 Prop Syntax
PDF
No ratings yet
Lec02 Prop Syntax
51 pages
Block-1 Elementary Logic
PDF
No ratings yet
Block-1 Elementary Logic
63 pages
Logical: Form and Logical Equivalence
PDF
No ratings yet
Logical: Form and Logical Equivalence
14 pages
Lecture 1-DCS
PDF
No ratings yet
Lecture 1-DCS
16 pages
MLF 00028
PDF
No ratings yet
MLF 00028
38 pages
Bce111 L1
PDF
No ratings yet
Bce111 L1
12 pages
Abhi Class NNNNN
PDF
No ratings yet
Abhi Class NNNNN
270 pages
Propositional Logic: Logic and Problem Solving
PDF
No ratings yet
Propositional Logic: Logic and Problem Solving
57 pages
Unit 3
PDF
No ratings yet
Unit 3
128 pages
Prop Pred
PDF
No ratings yet
Prop Pred
7 pages
Logic Preparation CSE
PDF
No ratings yet
Logic Preparation CSE
14 pages
Lecture1 1250496729597372
PDF
No ratings yet
Lecture1 1250496729597372
6 pages
Img 20240920211938375
PDF
No ratings yet
Img 20240920211938375
31 pages
Logic and Set Theory
PDF
100% (1)
Logic and Set Theory
17 pages
Lec 1
PDF
No ratings yet
Lec 1
51 pages
UNIT 3 Logic
PDF
100% (1)
UNIT 3 Logic
78 pages
3 - Principaux Formalismes - en
PDF
No ratings yet
3 - Principaux Formalismes - en
58 pages
Logic (1st Part)
PDF
No ratings yet
Logic (1st Part)
23 pages
Propositonal Logic Theory 2025
PDF
No ratings yet
Propositonal Logic Theory 2025
41 pages
Ai Chapter-4
PDF
No ratings yet
Ai Chapter-4
13 pages
Lesson 1 Foundation Logic
PDF
No ratings yet
Lesson 1 Foundation Logic
26 pages
MCS 013
PDF
No ratings yet
MCS 013
128 pages
Slide 5 - Logic and Proof
PDF
No ratings yet
Slide 5 - Logic and Proof
116 pages
Lecture Week - 1 - Propositional Logic PDF
PDF
No ratings yet
Lecture Week - 1 - Propositional Logic PDF
55 pages
Logic
PDF
No ratings yet
Logic
37 pages
L 1
PDF
No ratings yet
L 1
52 pages
CH 4
PDF
No ratings yet
CH 4
33 pages
Block 1
PDF
No ratings yet
Block 1
61 pages
Block 2 PDF
PDF
No ratings yet
Block 2 PDF
62 pages
Cour 1,2
PDF
No ratings yet
Cour 1,2
16 pages
CS101 Chapter 1 - Week 1 - MG
PDF
No ratings yet
CS101 Chapter 1 - Week 1 - MG
33 pages
2023 09-09-08!27!17 9cqRiPmZhZxLHhxPGxNvcmMgQPRkVosy1K8hbf4k
PDF
No ratings yet
2023 09-09-08!27!17 9cqRiPmZhZxLHhxPGxNvcmMgQPRkVosy1K8hbf4k
14 pages
5 Logic
PDF
No ratings yet
5 Logic
29 pages
Propositional and First Order Logic
PDF
No ratings yet
Propositional and First Order Logic
27 pages
Lesson 2 Logic and Proof Part 12
PDF
No ratings yet
Lesson 2 Logic and Proof Part 12
51 pages
DFoC+v2 0 1-Part-2
PDF
No ratings yet
DFoC+v2 0 1-Part-2
56 pages
5 - Predicate Logic (Lecture 19-22)
PDF
No ratings yet
5 - Predicate Logic (Lecture 19-22)
47 pages
Mcs 013
PDF
No ratings yet
Mcs 013
128 pages
Chapter 1 - V2
PDF
No ratings yet
Chapter 1 - V2
85 pages
5 Logic
PDF
No ratings yet
5 Logic
29 pages
Chapter 1 Fundamental of Logic Part 3
PDF
No ratings yet
Chapter 1 Fundamental of Logic Part 3
45 pages
Lect W02 CHP 02b Propositional
PDF
No ratings yet
Lect W02 CHP 02b Propositional
46 pages
Lecture 6
PDF
No ratings yet
Lecture 6
56 pages
CS5002 Lecture Notes - Week 1
PDF
No ratings yet
CS5002 Lecture Notes - Week 1
16 pages
1 Chap1
PDF
No ratings yet
1 Chap1
47 pages
EM214 - Logic - Part 1
PDF
No ratings yet
EM214 - Logic - Part 1
19 pages
Lecture2 Logic&Proofs
PDF
No ratings yet
Lecture2 Logic&Proofs
22 pages
FoundationsOfComputation 2.3.2 6x9
PDF
No ratings yet
FoundationsOfComputation 2.3.2 6x9
256 pages
Chapter 1: The Foundations: Logic and Proofs: Discrete Mathematics and Its Applications
PDF
No ratings yet
Chapter 1: The Foundations: Logic and Proofs: Discrete Mathematics and Its Applications
23 pages
Discrete Structures Unit 1
PDF
No ratings yet
Discrete Structures Unit 1
21 pages
FoundationsOfComputation 2.3 8
PDF
No ratings yet
FoundationsOfComputation 2.3 8
223 pages