You are on page 1of 27

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -Week

Course Description This course covered the mathematical topics most directly related to computer science. Topics included: logic, relations, functions, basic set theory, countability and counting arguments, proof techniques, mathematical induction, graph theory, combinatorics, discrete probability, recursion, recurrence relations, and number theory. Emphasis will be placed on providing a context for the application of the mathematics within computer science. The analysis of algorithms requires the ability to count the number of operations in an algorithm. Recursive algorithms in particular depend on the solution to a recurrence equation, and a proof of correctness by mathematical induction. The design of a digital circuit requires the knowledge of Boolean algebra. Software engineering uses sets, graphs, trees and other data structures. Number theory is at the heart of secure messaging systems and cryptography. Logic is used in AI research in theorem proving and in database query systems. Proofs by induction and the more general notions of mathematical proof are ubiquitous in theory of computation, compiler design and formal grammars. Probabilistic notions crop up in architectural trade-offs in hardware design. Text:
o

Discrete Mathematics and its Applications, by Kenneth H. Rosen (Fifth Edition). References: o Discrete and Combinatorial Mathematics; An Applied Introduction, Ralph P. Grimaldi. o Discrete Mathematics with Applications (Second Edition), Susanna S. Epp.

Chapter 1 The Fondations: Logic and Proof, Sets, and Functions Why Logic? Mathematical Logic is a tool for working with complicated compound statements. It includes: Week 1 Page 1

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -Week

A language for expressing them. A concise notation for writing them. A methodology for objectively reasoning about their truth or falsity. It is the foundation for expressing formal proofs in all branches of mathematics. Foundations of Logic: Overview Propositional logic: Basic definitions. Equivalence rules & derivations. Predicate logic: Predicates. Quantified predicate expressions. Equivalences & derivations. Propositional Logic is the logic of compound statements built from simpler statements using so-called Boolean connectives. Some applications in computer science: Design of digital electronic circuits. Expressing conditions in programs. Queries to databases & search engines. Definition of a Proposition A proposition (denoted by p, q, r,) is simply a statement (i.e., a declarative sentence) with a definite meaning, having a truth value

Week 1

Page 2

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -Week

thats either true (T) or false (F) (never both, neither, or somewhere in between). (However, you might not know the actual truth value, and it might be situation-dependent.) [Later we will study probability theory, in which we assign degrees of certainty to propositions. But for now: think True/False only!] Examples of Propositions It is raining. (In a given situation.) Beijing is the capital of China. 2 + 3 = 5 But, the following are NOT propositions: Enter control / D to logout. What is the time? Whos there? (interrogative, question) La la la la la. (meaningless interjection) Just do it! (imperative, command) Yeah, I sorta dunno, whatever... (vague) 1 + 2 (expression with a non-true/false value) Propositions are divided into two types simple and compound. Simple Proposition This is a proposition which contains no other proposition, or which is regarded as containing no other proposition. Examples of simple propositions (or statements) are: Week 1 Page 3

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1 2 is an even number. 5 is an even number.

University of -Week

Compound Proposition This is a proposition which contains, or can be regarded as containing other propositions. Such statements usually involve one or more of the connectives ''and'', ''or'', ''not'', ''if then'' and '' if and only if ''. For example, ''It is not the case that 2 + 3 = 5'' is the negation of the statement above. Of course, it is stated more simply as ''2 + 3 5''. Other examples of compound propositions (or statements) are: If you finish your homework then you can watch T.V. I have read this and I understand the concept. Aslam teaches Computing and Aslam teaches Mathematics. For our purposes, statements will simply be denoted by lowercase letters of the alphabet, typically p, q, and r. We will refer to these as boolean variables as well. Operators / Connectives An operator or connective combines one or more operand expressions into a larger expression. (E.g., + in numeric expressions.) Unary operators take 1 operand (e.g., 3); binary operators take 2 operands (eg 3 4). Propositional or Boolean operators operate on propositions or truth values instead of on numbers.
Some Popular Boolean Operators (Also Called Propositional Connectives)

Week 1

Page 4

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -Week

As mentioned above, if we are given simple statements, then we can construct more complex statements (called complex propositions) using logical connectives. Here are 6 logical connectives we will use: Formal Name Negation operator Conjunction operator Disjunction operator Implication operator (if then) Biconditional operator ( if and only if ) The Negation Operator The unary negation operator (NOT) transforms a proposition into its logical negation. E.g. If p = I have brown hair. then p = I do not have brown hair. Truth table for NOT: T : True; F : False : means is defined as The Conjunction Operator The binary conjunction operator (AND) combines two propositions to form their logical conjunction.
E.g. If p = I will have salad for lunch. and q = I will have steak for dinner.,

Nickname Arity NOT AND OR IMPLIES IFF Unary

Symbol

Binary Binary Binary Binary Binary

Exclusive-OR operator XOR

p p T F F T

Week 1

Page 5

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1 then

University of -Week

p = I will have salad for lunch and I will have steak for dinner. q Conjunction Truth Table

Note that a conjunction p1 p2 pn of n propositions will have 2n rows

p F F T T

q F T F T

pq F F F T

in its truth table.

Also: and operations together are sufficient to express any Boolean truth table!

The Disjunction Operator The binary disjunction operator (OR) combines two propositions to form their logical disjunction. p = My car has a bad engine. q = My car has a bad carburetor. p = Either my car has a bad engine, or my car has a bad carburetor. q Disjunction Truth Table

Note that p means q that p is true, or q is true, or both are true! So, this operation is also called inclusive or,

Week 1

p F F T T

q F T F T

pq F T T T Page 6

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1 because it includes the possibility that both p and q are true. and together are also universal.

University of -Week

Note that the connective ''OR'' in logic is used in the inclusive sense (not the exclusive sense as in English). Thus, the logical statement ''It is raining or the sun is shining'' means it is raining, or the sun is shining or it is raining and the sun is shining. Nested Propositional Expressions

Use parentheses to group sub-expressions: I just saw my old friend, and either hes grown or Ive shrunk. = f (g s) (f g) s would mean something different f g s would be ambiguous By convention, takes precedence over both and . s f means (s) f , not (s f)

A Simple Exercise Let p = It rained last night, q = The sprinklers came on last night, r = The lawn was wet this morning. Translate each of the following into English: p = It didnt rain last night.

r p = The lawn was wet this morning, and it didnt rain last night. r p q = Either the lawn wasnt wet this morning, or it rained last night, or the sprinklers came on last night. The Exclusive Or Operator

Week 1

Page 7

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -Week

The binary exclusive-or operator (XOR) combines two propositions to form their logical exclusive or (exjunction?). p = I will earn an A in this course, q = I will drop this course, p q = I will either earn an A for this course, or I will drop it (but not both!) Exclusive-Or Truth Table

Note that pq means that p is true, or q is true, but not both! This operation is called exclusive or, because it excludes the possibility that both p and q are true. and together are not universal.

p q p q F F F F T T T F T T T F

Natural Language is Ambiguous Note that English or can be ambiguous regarding the both case! Pat is a singer or Pat is a writer. Pat is a man or Pat is a woman. -

p q p "or" q For this class, assume or means inclusive F F F F T T T F T Week 1 T T ?


Need context to disambiguate the meaning!

Page 8

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -Week

The Implication Operator The implication p q states that p implies q. I.e., If p is true, then q is true; but if p is not true, then q could be either true or false. E.g., let p = You study hard. q = You will get a good grade. p q = If you study hard, then you will get a good grade. (else, it could go either way.) In p q, p is called antecedent and q is called consequent. Implication Truth Table

p q is false only when p is true but q is not true. p q does not say that p causes q! p q does not require that p or q are ever true! E.g. (1=0) pigs can fly is TRUE!

p q p q F F T F T T T F F T T T

Examples of Implications If this lecture ends, then the sun will rise tomorrow. True or False? If Tuesday is a day of the week, then I am a penguin. True or False? If 1+1=6, then Bush is president.

True or False? Week 1 Page 9

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -Week

If the moon is made of green cheese, then I am richer than Bill Gates. True or False?

Why does this seem wrong? Consider a sentence like, If I wear a red shirt tomorrow, then the U.S. will attack Iraq the same day. In logic, we consider the sentence True so long as either I dont wear a red shirt, or the US attacks. But in normal English conversation, if I were to make this claim, you would think I was lying. Why this discrepancy between logic & language? Resolving the Discrepancy

In English, a sentence if p then q usually really implicitly means something like, In all possible situations, if p then q. That is, For p to be true and q false is impossible. Or, I guarantee that no matter what, if p, then q. This can be expressed in predicate logic as: For all situations s, if p is true in situation s, then q is also true in situation s Formally, we could write: s, P(s) Q(s) This sentence is logically False in our example, because for me to wear a red shirt and the U.S. not to attack Iraq is a possible (even if not actual) situation. Natural language and logic then agree with each other.

English Phrases Meaning p q p implies q if p, then q when p, q q if p Week 1 10

. if p, q . whenever p, q . q when p Page

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1


University of -Week

q whenever p p is sufficient for q q follows from p

. p only if q . q is necessary for p . q is implied by p

We will see some equivalent logic expressions later. Converse, Inverse, Contrapositive Some terminology, for an implication p q:

Its converse is: q p. Its inverse is: p q. Its contrapositive: q p. One of these three has the same meaning (same truth table) as p q. Can you figure out which?

How do we know for sure? Proving the equivalence of p q and its contrapositive using truth tables:

p F F T T
Week 1 11

q F T F T

q T F T F

p T T F F

pq q p T T T T F F T T
Page

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1 The biconditional operator

University of -Week

The biconditional p q states that p is true if and only if (IFF) q is true. p = Bush wins the 2004 election. q = Bush will be president for all of 2005. p q = If, and only if, Bush wins the 2004 election, Bush will be president for all of 2005. Biconditional Truth Table

p q means that p and q have the same truth value. Note this truth table is the exact opposite of s! p q means (p q) p q does not imply p and q are true, or cause each other.

p F F T T

q pq F T T F F F T T

Boolean Operations Summary We have seen 1 unary operator (out of the 4 possible) and 5 binary operators (out of the 16 possible). Their truth tables are below.

Week 1 12

p F F T T

q F T F T

p T T F F

pq F F F T

pq pq pq pq F F T T T T T F T T F F T F T T
Page

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -Week

Some Alternative Notations

n o ta n d o r x o ri m p l i e si f f P r o p o s i ti o n a l l o g c : i B o o le a n a lg e b ra : p p q + C / C + + / J a v a ( w o r ! w &s e ) :| | ! = d i & == C / is the / J a v a ( ''The wall & | q i : If p C + + statement b i t w~ s e )is red'' and ^ is the statement ''Th
L o g ic g a te s :
Few More Examples If p is the statement The wall is red and q is the statement The lamp is on'', then p q is the statement ''The wall is red or the lamp is on (or both)'' whereas q p is the statement ''If the lamp is on then the wall is red''. The statement p q translates to ''The wall isn't red and the lamp is on''. Statements given symbolically have easy translations into English but it should be noted that there are several ways to write a statement in English. For example, with the examples above, the statement p q directly translates as ''If the wall is red then the lamp is on''. It can also be stated as ''The wall is red only if the lamp is on'' or ''The lamp is on if the wall is red''. Similarly, p q directly translates as ''The wall is red and the lamp is not on'' but it would be preferable to say ''The wall is red but the the lamp is off ''. Conditional connective ( ) needs special consideration: Week 1 13 Page

N am e:

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -Week

Recall that p q means that 'if p is true, then q is true'. The truth table of this connective is shown below. p q p q T T T T F F F T T F F T p q is false only when p is True and q is False. Here p is called the condition and q the consequence. Note that if first part is true only then you look at the second part, in order to find the truth value of the whole expression. On the other hand if first part is false you dont have to look at the second part, the whole story will be taken as true irrespective of the truth value of the second part (there is nothing to check if the first part is false). To further elaborate the matter, let us consider the following implications: If my bread is green, then I will not eat it. Here, if the bread is not green, that does not guarantee that I will eat it. I may eat it or I may not eat it. In either case the implication will be true. Perhaps it is wheat bread and I hate wheat bread. All I know is that if my bread is green, I will definitely NOT eat it. If Pluto is the largest planet in our solar system, then pigs will fly out of my butt. Wayne would actually be making a correct implication here (assuming that we currently have accurate knowledge about our solar system). Since the first part of our implication is false, the entire implication is automatically true. Biconditional Connective also needs special consideration: Week 1 14 Page

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -Week

p q is shorthand for (p q) (q p). It means "p is true if and only if q is true". The truth table of this connective is shown below. p T T F F q T F T F pq T F F T

p q is true only when p and q have the same truth values. Truth tables involving n statements will have 2n rows unless additional information about the truth values of some of these statements is known. E.g. for three boolean variables p, q and r we have the following truth table for the compound statement p (q r): p F F F F T T T T q F F T T F F T T r F T F T F T F T q r T F T T T F T T p (q r) F F F F T F T T

Thus there are three possible combinations of values for p, q, and r that make p (q r) true. Bits and Bit Operations A bit is a binary (base 2) digit: 0 or 1. Bits may be used to represent truth values.

Week 1 15

Page

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -Week

By convention: 0 represents false; 1 represents true. Boolean algebra is like ordinary algebra except that variables stand for bits, + means or, and multiplication means and. See chapter 10 for more details. Bit Strings

A Bit string of length n is an ordered series or sequence of n 0 bits. More on sequences in 3.2. By convention, bit strings are written left to right: e.g. the first bit of 1001101010 is 1. When a bit string represents a base-2 number, by convention the first bit is the most significant bit. Ex. 11012=8+4+1=13.

Counting in Binary

Did you know that you can count to 1,023 just using two hands? How? Count in binary! Each finger (up/down) represents 1 bit. To increment: Flip the rightmost (low-order) bit. If it changes 10, then also flip the next bit to the left, If that bit changes 10, then flip the next one, etc.

Week 1 16

Page

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -Week

0000000000, 0000000001, , 1111111101, 1111111110, 1111111111

0000000010,

Bitwise Operations Boolean operations can be extended to operate on bit strings as well as single bits. E.g.: 01 1011 0110 11 0001 1101 11 1011 1111 Bit-wise OR 01 0001 0100 Bit-wise AND 10 1010 1011 Bit-wise XOR Propositional Equivalence Two syntactically (i.e., textually) different compound propositions may be the semantically identical (i.e., have the same meaning). We call them equivalent. Learn:

Various equivalence rules or laws. How to prove equivalences using symbolic derivations?

Tautologies and Contradictions A compound proposition that is always true is called logically true or a tautology. A compound proposition that is always false is called logically false or a contradiction. Symbolically, we denote a tautology by T0 and a contradiction by F0. Note that p p is an example of tautology and p p is an example of contradiction. Other compound propositions are contingencies. Examples Week 1 17 Page

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1 a) Construct the truth table for (p q) (p q). p T T F F q T F T F p q T F T T p q T F T T

University of -Week

(p q) (p q) T T T T

Since the last column contains all T's, (p q) (p q) is a tautology. b) Construct a truth table for (p ^ (p q)) q. p T T F F q T F T F p q T F T T (p ^ (p q)) T F F F (p ^ (p q)) q T T T T

(p ^ (p q)) q is called modus ponens: '' if both p and (p implies q) hold then q holds.'' This is also a tautology. Exercise: Make a truth table for the statement: (p q) Logical or Tautological Implication A proposition p logically implies (tautologically implies) q if p tautology. The fact that p logically implies q is written as p q.

r.

q is a

Example. As shown above, modus ponens ((p ^ (p q)) q) is a tautology. So we can say (p ^ (p q)) q. Logical or Tautological Equivalence

Compound propositions that always have the same truth value are called logically equivalent (tautologically equivalent). This can be written p q. Page

Week 1 18

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -

Week q is a

The propositions p and q are called logically equivalent if p tautology.

We can also define the tautological equivalence of p and q to be the case if and only if p tautologically implies q and q tautologically implies p. Examples I) Show (p q) p ^ q. p q p q P q (p q) T T F F T F T F F T T F F T T F T F F F T T F T p ^ q F F F T (p q)
p

T T T T

^ q

The last two columns are the same, therefore, (p p ^ q. This result q) is half of the DeMorgan's Law, the other half is (p ^ q) p q. Exercise:- Show that p q II) Show p p T T F F q T F T F

(p ^ q).

p q. p

p F F T T

T F T T

p q T F T T

p q

p q

T T T T

III) Show p p T T F F q T F T F

(p

q) ^ (q

p). p

(p

T F T T

T T F T

T F F T

q) ^ (q T F F T

p)

Week 1 19

Page

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1 IV) Show that (p p T T F F q T F T F

University of -Week

q)

(q q F T F T

p) (if not q, then not p). p

p F F T T

T F T T

T F T T

Note:- The statement q p q.

p is called the contrapositive of the implication

The statement q p is called the converse of p q; p q is called the inverse of p q. One can show that p q is not equivalent to q p; and also p q is not equivalent to q p. Consequently, we must keep the implication and its converse straight. The fact that a certain implication p q is true does not require that converse q p also be true. However, it does necessitate the truth of the contrapositive q p. V) Show that (p p T T F F Q T F T F p

q) and (p q) are logically equivalent. q p q T F T T (p q). (p

T F T T

q) (p V q) T T T T

Therefore, (p q)

Exercises (Prove the following equivalences):


(p q) ((p q) (q p)). (p q) ( (p q)). ((p q) (q ( (p q)). p)) Page

Week 1 20

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1

University of -Week

Example Translate each of the following sentences into the propositional calculus:a) b) c) Either the car passes the M.O.T. or it will be expensive to repair. The parts have been ordered but have not been received. Either the parts have been received or the car cannot be repaired.

Solution The relevant simple propositions are m = the car passes the M.O.T o = The parts have been ordered p = the parts have been received e = it will be expensive to repair r = have not been received n = the car cannot be repaired

So the given propositions are translated as follows:a) m e b) o r c) p n Example Translate each of the following sentences into the propositional calculus:i). If the reactor works abnormally but the alarm does not sound, then the reactor will be damaged. ii). The reactor is vulnerable and it is not the case if the reactor core cools, then the reactor works normally. iii). The reactor works normally or the alarm sounds or the reactor will be damaged. Answer The relevant simple propositions are w = The reactor works normally, d = The reactor will be damaged, v = The reactor is vulnerable
i).

a = The alarm sounds c = The reactor core cools

(w a) d Page

Week 1 21

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1


ii).

University of -Week

v (c c) w iii). (w a d) By means of a truth table show that the propositions i) and iii) are equivalent. Solution W T T T T F F F F a T T F F T T F F d T F T F T F T F w F F F F T T T T a F F T T F F T T w a F F F F T F T T (w d a) T T T T T T T F w a d T T T T T T T F

As last two columns are identical, so propositions i) and iii) are equivalent. Example Construct a truth table for the proposition ((p q)) (( p) r) Answer: P q r p p q (p q) ( p) r ( (p q)) (( p) r)

Week 1 22

Page

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1 Algebra of Propositions (Equivalence Laws)

University of -Week

It would be nice if we had some methodology for determining if two logical expressions are equal (logically speaking equivalent), or a method of simplifying a given logical expression. Perhaps the most obvious way to check for the equality of two logical expressions is to write out truth tables for both. It always works. However, it may be quite tedious. (A compound expression consisting of 10 simple expressions would need a truth table of 1024 rows!) We will need some laws to simplify logical expressions. These are similar to the arithmetic identities you may have learned in algebra, but for propositional equivalences instead. They provide a pattern or template that can be used to match all or part of a much more complicated proposition and to find an equivalence for it. Here is the list of Laws of Logic: For any primitive statements p, q, r, any tautology T0 and any contradiction F0, p T0 p (Identity Laws) p F0 p p T0 T0 p F0 F0 p p p p p p p p p q q p p q q p (p q) r p (q r) (p q) r p (q r) (Domination Laws) (Idempotent Laws) (Double Negation Law) (Commutative Laws) (Associative Laws)

1)

2)

3)

4) 5)

6)

7)

p (q r) (p q) (p r) (Distributive Laws) Page

Week 1 23

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1 p (q r) (p q) (p r)


8)

University of -Week

(p q) p q (p q) p q

(De Morgans Laws)

Augustus De Morgan (1806-1871)


9)

p (p q) p p (p q) p

(Absorption Laws) (Negation Laws / Inverse Laws) (Also called Trivial tautology/contradiction)

10)p T0 p p F0 p

Defining Operators via Equivalences Using equivalences, we can define operators in terms of other operators. Exclusive or: pq (p q) q) (p pq (p (q q) p) Implies: pq p q Biconditional: pq (pq) (qp) pq (pq) We can use these laws to simplify a statement. Consider the following statement: (p q) (p q) (p q) (p q) (DeMorgans) (p q) (p q) (Double Neg.) p (q q) (Dist. Law) p F0 (Inverse) p (Identity) Page

Week 1 24

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1 Another Example Check using a symbolic derivation whether (p q) (p r) p q r. (p q) (p r) [Expanded definition of ] (p q) (p r) [Definition of ] (p q) ((p r) (p r)) [De Morgans Law] (p q) ((p r) (p r)) [Commutes] (q p) ((p r) (p r)) [Associative] q (p ((p r) (p r))) [Distributive over q (((p (p r)) (p (p r))) ] [Association] q (((p p) r) (p (p r))) [Trivial Tautology] q ((T0 r) (p (p r))) [Domination] q (T0 (p (p r))) [Identity] q (p (p r)) [De Morgans Law] q (p (p r)) [Associative] q ((p p) r) [Idempotent] q (p r) [Associative] (q p) r [Commutative] p q r Q.E.D. (quod erat demonstrandum)

University of -Week

Definition:- Let s be a statement. If s contains no logical connectives other than ^ and then the dual of s, denoted sd, is the statement obtained from s by , replacing each occurrence of ^ by by and ^ respectively, and each occurrence of T0 and F0 by F0 and T0, respectively. If p is any primitive statement, then pd is the same as p that is, the dual of a primitive statement is simply the same primitive statement. And ( p)d is the same as p. The statements p p and p ^ p are duals of each other whenever p is primitive and so are the statements p T0 and p ^ F0. Given the primitive statements p, q, r and the compound statement s: (p ^ q) (r ^ To), Week 1 25 Page

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1 we find that the dual of s is sd: (p q) ^ (r Fo). (Note that q is unchanged as we go from s to sd.)

University of -Week

Theorem (The Principle of Duality) Let s and t be statements as described in above Definition. If s t, then sd td. As a result of this, laws 2 through 10 in our list can be established by proving one of the laws in each pair and then invoking this principal. It is also possible to derive new logical equivalences starting from a given equivalence by using the following substitution rules:
1)

2)

Suppose that the compound statement P is a tautology. If p is a primitive statement that appears in P and we replace each occurrence of p by the same statement q, then the resulting compound statement P1 is also a tautology. Let P be a compound statement where p is an arbitrary statement that appears in P, and let q be a statement such that q p. Suppose that in P we replace one or more occurrence of p by q. Then this replacement yields the compound statement P1. Under these circumstances P1 P.

Example We know that (p q) (p q) is a tautology. If we replace each occurrence of p by r ^ s then we get another tautology: ((r ^ s) q) ( (r ^ s) q). This means ((r ^ s) q) ( (r ^ s) q). Exercise:Show that P1: [(r ^ s) q)] [ (r ^ s) ^ q) is a tautology. Hint:- Use DeMorgans Law and above substitution rule. Exercise: Show that one can also define p q either by (p q) (q p) or by (p q). Solution:- We establish the validity of first claim. The proof of second is left as an exercise. Week 1 26 Page

Department of Computer Science Karachi BSCS - 411 -Discrete Mathematics 1 p T T F F q T F T F q F T F T p q F T F F p F F T T q p F F T F

University of -Week p q F T T F

(p (q q) p) F T T F

Week 1 27

Page