discrete math

38
Department of Computer Science University of Karachi BSCS - 411 -- Discrete Mathematics -- Week 1 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: Week 1 Page 1

description

discrete math

Transcript of discrete math

Page 1: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

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:

• A language for expressing them.

Week 1 Page 1

Page 2: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

• 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 that’s 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.)

Week 1 Page 2

Page 3: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

[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?

• “Who’s 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 PropositionThis is a proposition which contains no other proposition, or which is regarded as containing no other proposition.

Examples of simple propositions (or statements) are:

2 is an even number. 5 is an even number.

Compound PropositionThis 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

Week 1 Page 3

Page 4: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

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)

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 Nickname Arity Symbol

Negation operator NOT Unary ¬

Conjunction operator AND Binary Ù

Disjunction operator OR Binary Ú

Exclusive-OR operator XOR Binary Å

Week 1 Page 4

Page 5: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

Implication operator (if … then)

IMPLIES Binary ®

Biconditional operator (… if and only if …)

IFF Binary ↔

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.”,

then

pÙq = “I will have salad for lunch and I will have steak for dinner.”

Conjunction Truth Table

• Note that a conjunction

p1 Ù p2 Ù … Ù pn

of n propositions

will have 2n rows

Week 1 Page 5

Page 6: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

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Úq = “Either my car has a bad engine, or my car has a bad carburetor.”

Disjunction Truth Table

• Note that pÚq means that p is true, or q is true, or both are true!

• So, this operation isalso called inclusive or,because it includes thepossibility that both p and q are true.

• “¬” and “Ú” together are also universal.

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 f riend , and either he’s g rown or I’ve s hrunk .” = f Ù (g Ú s)

– (f Ù g) Ú s would mean something different– f Ù g Ú s would be ambiguous

Week 1 Page 6

Page 7: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

• 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 didn’t rain last night.”

r Ù ¬p = “The lawn was wet this morning, and it didn’t rain last night.”

¬ r Ú p Ú q = “Either the lawn wasn’t wet this morning, or it rained last night, or the sprinklers came on last night.”

The Exclusive Or Operator

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 pÅq meansthat p is true, or q istrue, but not both!

• This operation iscalled exclusive or,because it excludes thepossibility that both p and q are true.

• “¬” and “Å” together are not universal.

Week 1 Page 7

Page 8: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

Natural Language is Ambiguous

Note that English “or” can be ambiguous regarding the “both” case!

“Pat is a singer or “Pat is a man or

Pat is a writer.” - Ú Pat is a woman.” - Å

Need context to disambiguate the meaning!

For this class, assume “or” means inclusive

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

Week 1 Page 8

Page 9: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

• p ® q is false only when p is true but q is not true.

• p ® q does not saythat p causes q!

• p ® q does not requirethat p or q are ever true!

• E.g. “(1=0) ® pigs can fly” is TRUE!

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?

• “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 don’t 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:

Week 1 Page 9

Page 10: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

– “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” . “if p, q”• “when p, q” . “whenever p, q”• “q if p” . “q when p”• “q whenever p” . “p only if q”• “p is sufficient for q” . “q is necessary for p”• “q follows from 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:

Week 1 Page 10

Page 11: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

The biconditional operator

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 theexact opposite of Å’s!

– p « q means ¬(p Å q)• p « q does not imply

p and q are true, or cause each other.

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 Page 11

Page 12: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

Some Alternative Notations

If p is the statement ''The wall is red'' and q is the statement ''Th

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

Week 1 Page 12

Page 13: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

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: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 ® qT T TT F FF T TF 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 don’t 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.

Week 1 Page 13

Page 14: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

Biconditional Connective « also needs special consideration:

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 q p « qT T TT F FF T FF 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 q r q Ú r pÙ(qÚr)F F F T FF F T F FF T F T FF T T T FT F F T TT F T F FT T F T TT T T 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.• By convention:

0 represents “false”; 1 represents “true”.

Week 1 Page 14

Page 15: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

• 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 1→0, then also flip the next bit to the left,• If that bit changes 1→0, then flip the next one, etc.

• 0000000000, 0000000001, 0000000010, ……, 1111111101, 1111111110, 1111111111

Bitwise Operations

• Boolean operations can be extended to operate on bit strings as well as single bits.

Week 1 Page 15

Page 16: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

E.g.:01 1011 011011 0001 110111 1011 1111 Bit-wise OR01 0001 0100 Bit-wise AND10 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

a) Construct the truth table for (p ® q) « (p Ú q).

p q p ® q p Ú q (p ® q) « (p Ú q)

T T T T TT F F F TF T T T TF F T T T

Since the last column contains all T's, (p ® q) « (p Ú q) is a tautology.

Week 1 Page 16

Page 17: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

b) Construct a truth table for (p ^ (p ® q)) ® q.

p q p ® q (p ^ (p ® q)) (p ^ (p ® q)) ® qT T T T TT F F F TF T T F TF F T F 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) r.

Logical or Tautological Implication

A proposition p logically implies (tautologically implies) q if p q is a tautology. The fact that p logically implies q is written as p q.

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. The propositions p and q are called logically equivalent if p q is a

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) p ^ q (p Ú q) p ^ qT T F F T F F TT F F T T F F TF T T F T F F TF F T T F T T T

Week 1 Page 17

Page 18: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

The last two columns are the same, therefore, (pÚq) p ^ q. This result is half of the DeMorgan's Law, the other half is (p ^ q) p Ú q.

Exercise:- Show that p Ú q (p ^ q).

II) Show p q p Ú q.

p q p p q p Ú q p q pÚqT T F T T TT F F F F TF T T T T TF F T T T T

III) Show p q (p q) ^ (q p).

p q p q q p p q (p q) ^ (q p)T T T T T TT F F T F FF T T F F FF F T T T T

IV) Show that (p q) (q p) (if not q, then not p).

p q p q p q q pT T F F T TT F F T F FF T T F T TF F T T T T

Note:- The statement q p is called the contrapositive of the implication p q.

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

Week 1 Page 18

Page 19: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

also be true. However, it does necessitate the truth of the contrapositive q p.

V) Show that (p q) and (p Ú q) are logically equivalent.

p Q p q p Ú q (p q) « (p V q)T T T T TT F F F TF T T T TF F T T T

Therefore, (p q) (pÚq).

Exercises (Prove the following equivalences):

(p Å q) ((p Ù q) Ú (q Ùp)). (p Å q) ( (p « q)). ((p Ù q) Ú (q Ùp)) ( (p « q)).

Example

Translate each of the following sentences into the propositional calculus:-

a) Either the car passes the M.O.T. or it will be expensive to repair.b) The parts have been ordered but have not been received.c) 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” e = “it will be expensive to repair”o = “The parts have been ordered” r = “have not been received”p = “the parts have 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:-

Week 1 Page 19

Page 20: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

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”, a = “The alarm sounds”d = “The reactor will be damaged”, c = “The reactor core cools”v = “The reactor is vulnerable”

i). (w Ù a) ® dii). 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 a d w a w Ùa (w Ùa) ® d w Ú a Ú dT T T F F F T TT T F F F F T TT F T F T F T TT F F F T F T TF T T T F T T TF T F T F F T TF F T T T T T TF F F T T T F 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)

Week 1 Page 20

Page 21: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

Answer:

P q r p pÙq (pÙq) ( p) Ú r ( (p Ù q)) Ù (( p) Ú r)

Algebra of Propositions (Equivalence Laws)

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,

1) p Ù T0 p (Identity Laws)p Ú F0 p

2) p Ú T0 T0 (Domination Laws) p Ù F0 F0

3) p Ú p p (Idempotent Laws)

Week 1 Page 21

Page 22: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

p Ù p p

4) p p (Double Negation Law)

5) p Ú q q Ú p (Commutative Laws) p Ù q q Ù p

6) (p Ú q) Ú r p Ú (q Ú r) (Associative Laws) (p Ù q) Ù r p Ù (q Ù r) 7) p Ú (q Ù r) (p Ú q) Ù (p Ú r) (Distributive Laws) p Ù (q Ú r) (p Ù q) Ú (p Ù r)8) (p Ù q) p Ú q (De Morgan’s Laws) (p Ú q) p Ù q

Augustus De Morgan (1806-1871)

9) p Ú (p Ù q) p (Absorption Laws)p Ù (p Ú q) p

10)pÚp T0 (Negation Laws / Inverse Laws) pÙp F0 (Also called Trivial tautology/contradiction)

Defining Operators via Equivalences

Using equivalences, we can define operators in terms of other operators.• Exclusive or: pÅq (pÚq) Ù(pÙq)• pÅq (pÙq)Ú(qÙp)• Implies: p®q p Ú q• Biconditional: p«q (p®q) Ù (q®p) p«q (pÅq)

We can use these laws to simplify a statement. Consider the following statement:

(p Ú q) Ù (p Ù q) (p Ú q) Ù (p Ú q) (DeMorgans)Week 1 Page 22

Page 23: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

(p Ú q) Ù (p Ú q) (Double Neg.) p Ú (q Ù q) (Dist. Law) p Ú F0 (Inverse) p (Identity)

Another ExampleCheck 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 Morgan’s 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 Morgan’s 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)

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),

we find that the dual of s is Week 1 Page 23

Page 24: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

sd: (p Ú q) ^ (r Ú Fo).

(Note that q is unchanged as we go from s to sd.)

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) 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.

2) 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 DeMorgan’s 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.

p q q p Ù q p q Ùp (pÙq)Ú(qÙp) p Å qT T F F F F F FT F T T F F T TF T F F T T T TF F T F T F F F

Week 1 Page 24

Page 25: discrete math

Department of Computer Science University of KarachiBSCS - 411 -- Discrete Mathematics -- Week 1

Week 1 Page 25