37
A R Usmani Skardu Gilgit-Baltistan [email protected]

Dscrete structure

Embed Size (px)

Citation preview

A R Usmani

Skardu Gilgit-Baltistan

[email protected]

1 Discret Structure for BSCS…… Prepared by Abdur-Rehman

Why is it

o “Discrete” (≠ “discreet”!) - Composed of distinct, separable parts.

o “Structures” - objects built up from simpler objects according to a definite pattern.

Why it is important

o Provides mathematical foundation for computer science courses such as

o data structures, algorithms, relational database theory, automata theory and

o formal languages, compiler design, and cryptography,

o Mathematics courses such as linear and abstract algebra, probability, logic and set

theory, and number theory.

What it does

o Describes processes that consist of a sequence of individual steps.

o Helps students to develop the ability to think abstractly.

ESSENTIAL TOPICS TO BE COVERED:

o Functions, relations and sets

o Basic logic

o Proof techniques

o Basics of counting

o Graphs and trees

o Recursion

Logic

o Crucial for mathematical reasoning

o Important for program design

o Used for designing electronic circuitry

o (Propositional )Logic is a system based on propositions.

o A proposition is a (declarative) statement that is either true or false (not both).

o We say that the truth value of a proposition is either true (T) or false (F).

2 Discret Structure for BSCS…… Prepared by Abdur-Rehman

o Corresponds to 1 and 0 in digital circuits

The Statement/Proposition Game

“Elephants are bigger than mice.”

Is this a statement? Yes

Is this a proposition? yes

What is the truth value

of the proposition? true

The Statement/Proposition Game

“520 < 111”

Is this a statement? yes

Is this a proposition? yes

What is the truth value

of the proposition? False

The Statement/Proposition Game

“y > 5”

Is this a statement? yes

Is this a proposition? no

Its truth value depends on the value of y, but this value is not specified.

We call this type of statement a propositional function or open sentence.

The Statement/Proposition Game

“Today is January 27 and 99 < 5.”

Is this a statement? yes

Is this a proposition? yes

What is the truth value

of the proposition? False

The Statement/Proposition Game

“Please do not fall asleep.”

3 Discret Structure for BSCS…… Prepared by Abdur-Rehman

Is this a statement? no

It’s a request.

Is this a proposition? no

Only statements can be propositions.

The Statement/Proposition Game

“If the moon is made of cheese,

then I will be rich.”

Is this a statement? yes

Is this a proposition? yes

What is the truth value

of the proposition? probably true

The Statement/Proposition Game

“x < y if and only if y > x.”

Is this a statement? yes

Is this a proposition? yes

… because its truth value does not depend on specific values of x and y.

What is the truth value

of the proposition? true

Combining Propositions

As we have seen in the previous examples, one or more propositions can be combined

to form a single compound proposition.

We formalize this by denoting propositions with letters such as p, q, r, s, and introducing

several logical operators or logical connectives.

Logical Operators (Connectives)

We will examine the following logical operators:

• Negation (NOT, )

• Conjunction (AND, )

4 Discret Structure for BSCS…… Prepared by Abdur-Rehman

• Disjunction (OR, )

• Exclusive-or (XOR, )

• Implication (if – then, )

• Biconditional (if and only if, )

Truth tables can be used to show how these operators can combine propositions to

compound propositions.

Negation (NOT)

Unary Operator, Symbol:

P P

true (T) false (F)

false (F) true (T)

Conjunction (AND)

Binary Operator, Symbol:

P Q P Q

T T T

T F F

F T F

F F F

Disjunction (OR)

Binary Operator, Symbol:

5 Discret Structure for BSCS…… Prepared by Abdur-Rehman

P Q P Q

T T T

T F T

F T T

F F F

Connectives

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

Connectives:

Let p= “It is hot”

q=““It is sunny”

1. It is not hot but it is sunny.

2. It is neither hot nor sunny.

Solution

1. ⌐p∧q

2. ⌐p∧ ⌐q

Exclusive Or (XOR)

6 Discret Structure for BSCS…… Prepared by Abdur-Rehman

Binary Operator, Symbol:

p = “I will earn an A in this course,”

q = “I will drop this course,”

p ⊕ q = “I will either earn an A in this course, or I will drop it (but not both!)”

True when exactly one of p and q is true and is false otherwise.0

P Q PQ

T T F

T F T

F T T

F F F

7 Discret Structure for BSCS…… Prepared by Abdur-Rehman

Truth Table

o The truth value of the compound proposition depends only on the truth value of the component

propositions. Such a list is a called a truth table.

Example

o (pq) ¬(pq)

p q pq pq ¬(pq) (pq) ¬(pq)

T T T T F F

T F T F T T

F T T F T T

F F F F T F

Example

o (p q) ¬r

P q r pq ¬r (pq)¬r

T T T

T T F

T F T

T F F

F T T

F T F

F F T

8 Discret Structure for BSCS…… Prepared by Abdur-Rehman

Implication (if - then)

o The conditional statement p → q is the proposition “if p, then q.”

o The conditional statement p → q is false when p is true and q is false, and true otherwise.

o p is called the hypothesis and q is called the conclusion.

Implication (if - then)

p = “You study hard.”

q = “You will get a good grade.”

p → q = “If you study hard, then you will get a good grade.”

P Q PQ

T T T

T F F

F T T

F F T

Biconditionals (if and Only If)

p = “Sharif wins the 2012 election.”

q = “Sharif will be prime minister for five years.”

p ↔ q = “If, and only if, Sharif wins the 2012 election, Sharif will be prime minister for five years.”

p ↔ q does not imply that p

and q are true, or that

either of them causes the other, or that they have a

common cause.

9 Discret Structure for BSCS…… Prepared by Abdur-Rehman

Precedence of Logical Connectives

o ~ highest

o Ʌ second highest

o V third highest

o → fourth highest

o ↔ fifth highest

Logical Equivalence

1. 6 is greater than 2

2. 2 is less than 6

two different ways of saying the same thing.

both be true or both be false.

logical form of the statements is important.

3. p ∧ q is true when, and only when, q ∧ p is true.

4. The statement forms are called logically equivalent

Logical Equivalence

10 Discret Structure for BSCS…… Prepared by Abdur-Rehman

o Two statement forms are called logically equivalent if, and only if, they have identical truth values for

each possible substitution of statements for their statement variables.

o P ≡ Q.

o Negation of the negation of a statement is logically equivalent to the statement.

o ∼(∼p) ≡ p

o ∼(p ∧ q) and ∼p ∧ ∼q are not logically equivalent

o p =“0 < 1” and let q =“1 < 0.”

Logical Equivalence

11 Discret Structure for BSCS…… Prepared by Abdur-Rehman

De Morgan’s Laws

o The negation of the conjunction of two statements is logically equivalent to the disjunction of their

negations.

o ∼(p ∧ q) and ∼p ∨ ∼q are logically equivalent i.e. ∼(p ∧ q) ≡ ∼p ∨ ∼q.

De Morgan’s Laws

o Negation of the disjunction of two statements is logically equivalent to the conjunction of their negations:

o Write negations for each of the following statements:

o John is 6 feet tall and he weighs at least 200 pounds.

o The bus was late or Tom’s watch was slow.

o Negation of these statements

o John is not 6 feet tall or he weighs less than 200 pounds.

o The bus was not late and Tom’s watch was not slow(/“Neither was the bus late nor was

Tom’s watch slow.”)

o Negation of a disjunction is formed by taking the conjunction of the negations of the component

propositions.

o Negation of a conjunction is formed by taking the disjunction of the negations of the component

propositions.

qpqp

qpqp

)(

)(

12 Discret Structure for BSCS…… Prepared by Abdur-Rehman

o Frequently used in writing computer programs.

o For instance, suppose you want your program to delete all files modified outside a certain range

of dates, say from date 1 through date 2 inclusive.

o ∼(date1 ≤ file_modification_date ≤ date2)

o is equivalent to

o ( file_modification_date < date1) or (date2 < file_modification_date).

13 Discret Structure for BSCS…… Prepared by Abdur-Rehman

Tautologies and Contradictions

A tautology is a statement that is always true.

Examples:

R(R)

(PQ) (P)( Q)

A contradiction is a statement that is always false.

Examples:

R(R)

((P Q) (P) (Q))

The negation of any tautology is a contradiction, and the negation of any contradiction is a tautology.

Equivalence

Definition: two propositional statements S1 and S2 are said to be (logically) equivalent, denoted S1 S2 if

They have the same truth table, or

S1 S2 is a tautology

Equivalence can be established by

Constructing truth tables

Using equivalence laws (Table 5 in Section 1.2)

Equivalence laws

Identity laws, P T P,

Domination laws, P F F,

Idempotent laws, P P P,

Double negation law, ( P) P

Commutative laws, P Q Q P,

Associative laws, P (Q R) (P Q) R,

Distributive laws, P (Q R) (P Q) (P R),

De Morgan’s laws, (PQ) ( P) ( Q)

Law with implication P Q P Q

14 Discret Structure for BSCS…… Prepared by Abdur-Rehman

Associative Laws

(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)

(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)

Simplifying Statement Forms

o ∼(∼p ∧ q) ∧ (p ∨ q) ≡ p

P q r pq (p ∧ q) ∧ r q ∧ r p ∧ (q ∧ r)

T T T T T T T

T T F T F F F

T F T F F F F

T F F F F F F

F T T F F T F

F T F F F F F

F F T F F F F

15 Discret Structure for BSCS…… Prepared by Abdur-Rehman

CONVERSE, CONTRAPOSITIVE, INVERSE

o The proposition q → p is called the converse of p → q.

o A conditional statement and its converse are NOT logically equivalent.

o The proposition ¬p →¬q is called the inverse of p → q.

o A conditional statement and its inverse are NOT logically equivalent.

o If a conditional statement is true, then its converse and inverse must also be true. This is not correct!

o If Howard can swim across the lake, then Howard can swim to the island.

o Converse:

o If Howard can swim to the island, then Howard can swim across the lake.

o Inverse:

o If Howard cannot swim across the lake, then Howard cannot swim to the island.

o If today is Easter, then tomorrow is Monday.

o Converse: If tomorrow is Monday, then today is Easter.

o Inverse: If today is not Easter, then tomorrow is not Monday.

o The contrapositive of p → q is the proposition ¬q →¬p.

o A conditional statement is logically equivalent to its contrapositive!

16 Discret Structure for BSCS…… Prepared by Abdur-Rehman

o If Howard can swim across the lake, then Howard can swim to the island.

o If today is Easter, then tomorrow is Monday.

o If Howard cannot swim to the island, then Howard cannot swim across the lake.

o If tomorrow is not Monday, then today is not Easter.

o The contrapositive of p → q is the proposition ¬q →¬p.

o A conditional statement is logically equivalent to its contrapositive!

o If Howard can swim across the lake, then Howard can swim to the island.

o If today is Easter, then tomorrow is Monday.

o If Howard cannot swim to the island, then Howard cannot swim across the lake.

o If tomorrow is not Monday, then today is not Easter.

Negations of If-Then Statements

If my car is in the repair shop, then I cannot get to class.

If Sara lives in Athens, then she lives in Greece.

o Negation

My car is in the repair shop and I can get to class.

Sara lives in Athens and she does not live in Greece.

o The negation of an if-then statement does not start with the word if.

17 Discret Structure for BSCS…… Prepared by Abdur-Rehman

Simplifying Statement

“you are hardworking and the sun shines, or you are hardworking and it rains.”

p=“ you are hardworking “.

q=“the sun shines”

r= “it rains”

(p q) (p r) p (q r) using distributive law

“you are hardworking and the sun shines or it rains”

Translating English Sentences

“If the moon is out and it is not snowing, then Sam goes out for a walk.”

p=“Phyllis goes out for a walk”.

q=“The moon is out”

r= “It is snowing”

If the moon is out and it is not snowing, then Sam goes out for a walk.

“If it is snowing and the moon is not out, then Sam will not go out for a walk.”

“You can access the Internet from campus only if you are a computer science major or you are not a freshman.”

a=“You can access the Internet from campus“.

c=“You are a computer science major”

pqr )(prq )(

18 Discret Structure for BSCS…… Prepared by Abdur-Rehman

f= “You are a freshman”

a → (c ∨¬f ).

o Let p, q, and r be the propositions:

p = “you have the flu”

q = “you miss the final exam”

r = “you pass the course”

o Express the following propositions as an English sentence.

o p → q

If you have flu, then you will miss the final exam.

o ~q → r

If you don’t miss the final exam, you will pass the course.

o ~p → ~q → r

If you neither have flu nor miss the final exam, then you will pass the course.

BICONDITIONALS

o If it is hot outside you buy an ice cream cone, and if you buy an ice cream cone it is hot outside.

You buy an ice cream cone if and only if it is hot outside.

o For you to win the contest it is necessary and sufficient that you have the only winning ticket.

You win the contest if and only if you hold the only winning ticket.

o If you read the news paper every day, you will be informed and conversely.

You will be informed if and only if you read the news paper every day.

o It rains if it is a weekend day, and it is a weekend day if it rains.

It rains if and only if it is a weekend day.

o The train runs late on exactly those days when I take it.

The train runs late if and only if it is a day I take the train.

o This number is divisible by 6 precisely when it is divisible by both 2 and 3.

This number is divisible by 6 if and only if it is divisible by both 2 and 3.

Predicate

o p=“is a student at Bedford College”

o q =“is a student at.”

• p & q are predicate symbols

19 Discret Structure for BSCS…… Prepared by Abdur-Rehman

• p(x)=“x is a student at Bedford College.

• q(x,y) =“x is a student at y.”

x and y are predicate variables that take values in appropriate sets.

• When concrete values are substituted in place of predicate variables, a statement results.

o A predicate is a predicate symbol together with suitable predicate variables.

o A predicate is a sentence that contains a finite number of variables and becomes a statement when

specific values are substituted for the variables.

o The domain of a predicate variable is the set of all values that may be substituted in place of the variable.

o Also referred as propositional functions or open sentences

Predicate(Example)

o Person(x), which is true if x is a person

o Person(Socrates) = T

o Person(dolly-the-sheep) = F

o Let U = Z, the integers = {. . . -2, -1, 0 , 1, 2, 3, . . .}

• P(x): x > 0 is the predicate. It has no truth value until the variable x is bound.

o Examples of propositions where x is assigned a value:

• P(-3) is false,

• P(0) is false,

• P(3) is true.

Truth Values of a Predicate

o P(x)=“x2 > x”

o Domain = set R of all real numbers

o Find truth values of P(2), P( 1/2 ), and P(−1/2 )

• P(2): 22 > 2, or 4 > 2. True

• P(1/2):(1/2)2<1/2 or (1/4)

<1/2 False

• P(-1/2):(-1/2)2>-1/2 or (1/4)

>-1/2 True

o If P(x) is a predicate and x has domain D, the truth set of P(x) is the set of all elements of D that make P(x)

true when they are substituted for x. The truth set of P(x) is denoted

{x ∈ D | P(x)}

“the set of all x in D such that P(x).”

o Let R be the three-variable predicate R(x, y z): x + y= z

20 Discret Structure for BSCS…… Prepared by Abdur-Rehman

o Find the truth value of

R(2, -1, 5), R(3, 4, 7), R(x, 3, z)

Universal Quantification

o To change predicates into statements is to assign specific values to all their variables.

if x represents the number 35, the sentence “x is divisible by 5” is a true statement since 35 = 5·

7.

o Another way is to add quantifiers.

Quantifiers are words that refer to quantities such as "some" or "all" and tell for how many

elements a given predicate is true.

o Let P(x) be a predicate (propositional function).

o Universally quantified sentence:

For all x in the universe of discourse P(x) is true.

o Using the universal quantifier :

" x ϵ D,Q(x).“ universal statement

It is defined to be true if, and only if, Q(x) is true for every x in D.

It is defined to be false if, and only if, Q(x) is false for at least one x in D.

A value for x for which Q(x) is false is called a counterexample to the universal statement.

o When all the elements in the universe of discourse can be listed —say x1, x2, ..., xn — it follows that the

universal quantification

o ∀x P(x) is the same as the conjunction

P(x1) ∧ P(x2) ∧ · · · ∧ P(xn)

o because this conjunction is true if and only if P(x1), P(x2), ...,P(xn) are all true.

o Example: Let the universe of discourse be U = {1,2,3}. Then

o ∀x P(x) ≡ P(1)∧ P(2)∧ P(3).

Truth and Falsity of Universal Statements

Sentence:

o All UAJ&K students are smart.

o Assume: the domain of discourse of x are UAJ&K students

o Translation:

o ∀ x Smart(x)

o Assume: the universe of discourse are students (all students):

21 Discret Structure for BSCS…… Prepared by Abdur-Rehman

o ∀ x at(x, UAJ&K) Smart(x)

o Assume: the universe of discourse are people:

o ∀ x student(x) Λ at(x, UAJ&K) Smart(x)

o Let D = {1, 2, 3, 4, 5}, and consider the statement

∀x ∈ D, x2 ≥ x.

Show that this statement is true.

Check that “x2 ≥ x” is true for each individual x in D.

12 ≥ 1, 2

2 ≥ 2, 3

2 ≥ 3, 4

2 ≥ 4, 5

2 ≥ 5.

Hence “∀x ∈ D, x2

≥ x” is true.

The Existential Quantifier: ∃

o The symbol ∃ denotes “there exists” and is called the existential quantifier.

o “There is a student in Math 140” can be written as

∃ a person p such that p is a student in Math 140,

or, more formally,

∃p ∈ P such that p is a student in Math 140,

where P is the set of all people.

o At least one member of the group satisfy the property

o Let Q(x) be a predicate and D the domain of x. An existential statement is a statement of the form “∃x ∈ D

such that Q(x).” It is defined to be true if, and only if, Q(x) is true for at least one x in D. It is false if, and

only if, Q(x) is false for all

o x in D:

o Let T(x) denote x > 5 and x is from Real numbers.

o What is the truth value of ∃ x T(x)?

o Answer:

o Since 10 > 5 is true. Therefore, it is true that ∃ x T(x).

o Consider the statement

∃m ∈ Z+ such that m2 = m.

Show that this statement is true.

Observe that 12 = 1. Thus “m

2 = m” is true for at least one integer m. Hence “∃m ∈ Z

such that m2 = m” is true.

o Assume two predicates S(x) and P(x)

22 Discret Structure for BSCS…… Prepared by Abdur-Rehman

o Universal statements typically tie with implications

o All S(x) is P(x)

o ∀x ( S(x) P(x) )

o No S(x) is P(x)

o ∀x( S(x) ¬P(x) )

o Existential statements typically tie with conjunctions

o Some S(x) is P(x)

o ∃x (S(x) P(x) )

o Some S(x) is not P(x)

o ∃x (S(x) ¬P(x) )

Quantifiers:Example

o There exist an x such that x is black

o ∃xb(x) where b(x):x is black.

o |x|={

1. (∀x)(x2 0) 2. (∀x)(|x| 0)

Nested quantifiers

o More than one quantifier may be necessary to capture the meaning of a statement in the predicate logic.

o Example:

Every real number has its corresponding negative.

Translation:

Assume:

a real number is denoted as x and its negative as y

A predicate P(x,y) denotes: “x + y =0”

Then we can write:

(∀x)(∃y)P(x,y)

o Translate the following English sentence into logical expression

“There is a rational number in between every pair of distinct rational numbers”

Use predicate Q(x), which is true when x is a rational number

x,y (Q(x) Q (y) (x < y) u (Q(u) (x < u) (u < y)))

23 Discret Structure for BSCS…… Prepared by Abdur-Rehman

Understanding Multiply Quantifiers

A college cafeteria line has four stations: salads, main courses, desserts, and beverages.

1. The salad station offers a choice of green salad or fruit salad.

2. The main course station offers spaghetti or fish;

3. The dessert station offers pie or cake;

4. The beverage station offers milk, soda, or coffee.

Three students, Uta, Tim, and Yuen, go through the line and make the following choices:

o Uta: green salad, spaghetti, pie, milk

o Tim: fruit salad, fish, pie, cake, milk, coffee

Yuen: spaghetti, fish, pie, soda

Understanding Multiply Quantifiers

a) ∃ an item I such that ∀ students S, S chose I .

b) ∃ a student S such that ∀ items I, S chose I .

c) ∃ a student S such that ∀ stations Z, ∃ an item I in Z such that S chose I .

d) ∀ students S and ∀ stations Z, ∃ an item I in Z such that S chose I .

a) ∃ an item I such that ∀ students S, S chose I .

b) ∃ a student S such that ∀ items I, S chose I .

c) ∃ a student S such that ∀ stations Z, ∃ an item I in Z such that S chose I .

d) ∀ students S and ∀ stations Z, ∃ an item I in Z such that S chose I .

24 Discret Structure for BSCS…… Prepared by Abdur-Rehman

e) There is an item that was chosen by every student. This is true; every student chose pie.

f) There is a student who chose every available item. This is false; no student chose all nine items.

g) There is a student who chose at least one item from every station. This is true; both Uta and Tim chose at

least one item from every station.

h) Every student chose at least one item from every station. This is false; Yuen did not choose a salad.

Order of quantifiers

o The order of nested quantifiers matters if quantifiers are of different type

1. ∀ people x, ∃ a person y such that x cares y.

2. ∃ a person y such that ∀ people x, x cares y.

o ∀ x ∃ y C(x,y) is not the same as ∃y ∀ x C(x,y)

1. Given any person, it is possible to find someone whom that person cares,

2. whereas the second means that there is one amazing individual who is cared by all people.

o If one quantifier immediately follows another quantifier of the same type, then the order of the

quantifiers does not affect the meaning.

o Let Q(x, y, z) be the predicate:“x + y = z.”

o ∀x ∀y ∃z Q(x, y, z) True

1. “For all real numbers x and for all real numbers y there is a real number z such that x + y = z,”

o ∃z ∀x ∀y Q(x, y, z) False

1. “There is a real number z such that for all real numbers x and for all real numbers y it is true that

x + y = z,”

2. because there is no value of z that satisfies the equation x + y = z for all values of x and y.

25 Discret Structure for BSCS…… Prepared by Abdur-Rehman

Bound and Free Variables

o Definitions: If a quantifier is used on the variable x, then this variable is bound.

o An occurrence of a variable that is not bound by a quantifier or set equal to a particular value is said to be

free.

o When all the variables that occur in a propositional function are bound or set to a particular value, then

the propositional function is a proposition.

Bound and Free Variables-Example

o Let P(x, y), the propositional function “x + y = 0”.

o The logical variables x and y are free and we cannot evaluate the truth value of P(x, y).

o If the value 3 is set to x, then x is no longer a free variable, but P(3, y) is still a propositional function

because y is still a free variable.

o If we apply the universal quantification to the variable y, the propositional function ∀y P(3, y) is now a

proposition. Both variables x and y are no longer free and the truth value of the proposition is false.

Negation of quantifiers

o ∼(∀x, if P(x) then Q(x)) ≡ ∃x such that P(x) and ∼Q(x).

1. ∀ people p, if p is blond then p has blue eyes.

∃ a person p such that p is blond and p does not have blue eyes.

1. If a computer program has more than 100,000 lines, then it contains a bug.

There is at least one computer program that has more than 100,000 lines and does not contain a bug.

26 Discret Structure for BSCS…… Prepared by Abdur-Rehman

o ∼(∃x ∈ D such that Q(x)) ≡ ∀x ∈ D,∼Q(x).

o The negation of an existential statement (“some are”) is logically equivalent to a universal statement

(“none are” or “all are not”).

1. Some computer hackers are over 40.

No computer hackers are over 40 Or: All computer hackers are 40 or under

1. ∃ a triangle T such that the sum of the angles of T equals 200◦.

∀ triangles T, the sum of the angles of T does not equal 200◦.

o English statement:

It is not the case that all dogs are fleabags.

Translation: ¬ ∀ x Dog(x) Fleabag(x)

o Another way to express the same meaning:

There is a dog that is not a fleabag.

o Translation: ∃ x Dog(x) ¬ Fleabag(x)

Logically equivalent to:

∃ x ¬ ( Dog(x) Fleabag(x) )

o Conclusion: ¬ ∀ x P (x) is equivalent to ∃ x ¬ P(x)

(a) rewrite the statement formally

using quantifiers

and variables, and (b) write a

negation for the statement.

27 Discret Structure for BSCS…… Prepared by Abdur-Rehman

.

Valid & Invalid Arguments

o Argument is a sequence of statements ending in a conclusion.

o Determination of validity of an argument depends only on the form of an argument, not on its content.

“If you have a current password, then you can log onto the network.”

p=“You have a current password”

q=“You can log onto the network.”

p → q

p

∴ q where ∴ is the symbol that denotes “therefore.”

o An argument is a sequence of statements, and an argument form is a sequence of statement forms(have

proposition var.).

o All statements in an argument and all statement forms in an argument form, except for the final one, are

called premises (or assumptions or hypotheses).

o The final statement or statement form is called the conclusion. The symbol ∴, which is read “therefore,” is

normally placed just before the conclusion.

o To say that an argument form is valid means that no matter what particular statements are substituted for

the statement variables in its premises, if the resulting premises are all true, then the conclusion is also

true. Conclusion q is valid, when (p1 ∧ p2 ∧ · · · ∧ pn) → q is a tautology.

o To say that an argument is valid means that its form is valid.

o The truth of its conclusion follows necessarily or by logical form alone from the truth of its premises.

o When an argument is valid and its premises are true, the truth of the conclusion is said to be

inferred or deduced from the truth of the premises.

o If a conclusion “ain’t necessarily so,” then it isn’t a valid deduction.

Testing an Argument Form for Validity

1. Identify the premises and conclusion of the argument form.

2. Construct a truth table showing the truth values of all the premises and the conclusion.

3. A row of the truth table in which all the premises are true is called a critical row.

If there is a critical row in which the conclusion is false, then it is possible for an argument of the

given form to have true premises and a false conclusion, and so the argument form is invalid.

If the conclusion in every critical row is true, then the argument form is valid.

Testing an Argument Form for Validity

28 Discret Structure for BSCS…… Prepared by Abdur-Rehman

o p →q ∨ ∼r

o q → p ∧ r

o ∴ p →r

“If 101 is divisible by 3, then 1012 is divisible by 9. 101 is divisible by 3. Consequently, 101

2 is divisible by 9.”

Although the argument is valid, its conclusion is incorrect, because one of the hypotheses is false (“101 is divisible

by 3.”).

If in the above argument we replace 101 with 102, we could correctly conclude that 1022 is divisible by 9.

Rules of Inference for Propositional Logic

o An argument form consisting of two premises and a conclusion is called a syllogism.

o The first and second premises are called the major premise and minor premise, respectively.

o The most famous form of syllogism in logic is called modus ponens.

Modus Ponens

o The modus ponens argument form has the following form(“method of affirming”):

If p then q.

p

∴ q

If the sum of the digits of 371,487 is divisible by 3, then 371,487 is divisible by 3.

The sum of the digits of 371,487 is divisible by 3.

∴ 371,487 is divisible by 3.

o if a conditional statement and the hypothesis of this conditional statement are both true, then the

conclusion must also be true.

29 Discret Structure for BSCS…… Prepared by Abdur-Rehman

Modus Tollens

o Modus tollens(“method of denying” (the conclusion is a denial)) has the following form:

If p then q.

∼q

∴ ∼p

If Zeus is human, then Zeus is mortal.

Zeus is not mortal.

∴ Zeus is not human.

1) If Zeus is human, then Zeus is mortal; and

(2) Zeus is not mortal.

Must Zeus necessarily be nonhuman?

Yes!

Because, if Zeus were human, then by (1) he would be mortal.

But by (2) he is not mortal.

Hence, Zeus cannot be human.

Translating Propositions

Rules of Inference for Propositional Logic

o When an argument form involves 10 different propositional variables, to use a truth table to show this

argument form is valid requires 210

= 1024 different rows.

o Rules of inference.

First establish the validity of some relatively simple argument forms.

30 Discret Structure for BSCS…… Prepared by Abdur-Rehman

A rule of inference is a form of argument that is valid.

Thus modus ponens and modus tollens are both rules of inference.

o Generalization

The following argument forms are valid:

a. p b. q

∴ p ∨ q ∴ p ∨ q

if p is true, then, more generally, “p or q” is true for any other statement q.

Anton is a junior.

∴ (more generally) Anton is a junior or Anton is a senior.

o At some places with the name Addition

It is below freezing now. Therefore, it is below freezing or raining snow.

o Specialization

The following argument forms are valid:

a. p ∧ q b. p ∧ q

∴ p ∴ q

These argument forms are used for specializing.

Ana knows numerical analysis and Ana knows graph algorithms.

∴ (in particular) Ana knows graph algorithms.

o At some places with the name simplification

It is below freezing and snowing. Therefore it is below freezing.

o Elimination

The following argument forms are valid:

a. p ∨ q b. p ∨ q

∼q ∼p

∴ p ∴ q

o These argument forms say that when you have only two possibilities and you can rule one out, the other

must be the case.

31 Discret Structure for BSCS…… Prepared by Abdur-Rehman

x − 3 =0 or x + 2 = 0.

If you also know that x is not negative, then x ≠ −2, so

x + 2 ≠ 0.

By elimination, you can then conclude that

∴ x − 3 = 0.

o At some places with the name Disjunctive Syllogism

o Transitivity

o The following argument form is valid:

p →q

q →r

∴ p →r

If 18,486 is divisible by 18, then 18,486 is divisible by 9.

If 18,486 is divisible by 9, then the sum of the digits of 18,486 is divisible by 9.

∴ If 18,486 is divisible by 18, then the sum of the digits of 18,486 is divisible by 9.

o At some places with the name Hypothetical Syllogism

o Proof by Division into Cases

The following argument form is valid:

p ∨ q

p →r

q →r

∴ r

o If you can show that in either case a certain conclusion follows, then this conclusion must also be true.

x is positive or x is negative.

If x is positive, then x2 > 0.

If x is negative, then x2 > 0.

∴ x2 > 0.

o Conjunction

p

q

∴ p ∧ q

o Resolution

32 Discret Structure for BSCS…… Prepared by Abdur-Rehman

p ∨ q

¬p ∨ r

∴ q ∨ r

Rules of Inference for Propositional Logic-Example

o “If it rains today, then we will not have a barbeque today. If we do not have a barbeque today, then we

will have a barbeque tomorrow.

Therefore, if it rains today, then we will have a barbeque tomorrow.”

p: “It is raining today.”

q: “We will not have a barbecue today.”

r: “We will have a barbecue tomorrow.”

So the argument is of the following form:

o “If it rains today, then we will not have a barbeque today. If we do not have a barbeque today, then we

will have a barbeque tomorrow.

Therefore, if it rains today, then we will have a barbeque tomorrow.”

p: “It is raining today.”

q: “We will not have a barbecue today.”

r: “We will have a barbecue tomorrow.”

So the argument is of the following form:

o “It is not sunny this afternoon and it is colder than yesterday,” “We will go swimming only if it is sunny,”

“If we do not go swimming, then we will take a canoe trip,” and “If we take a canoe trip, then we will be

home by sunset” lead to the conclusion “We will be home by sunset.”

p: “It is sunny this afternoon ”

q: “It is colder than yesterday.”

33 Discret Structure for BSCS…… Prepared by Abdur-Rehman

r: “We will go swimming .”

s:” we will take a canoe trip”

t: “We will be home by sunset”

Step Reason

1. ¬pΛq Premise

2. ¬p Simplification using (1)

3. r → p Premise

4. ¬r Modus tollens using (2) and (3)

5. ¬r → s Premise

6. s 7. s→t

Modus ponens using (4) and (5) Premise

8. t Modus ponens using (6) and (7)

Fallacies

o A fallacy is an error in reasoning that results in an invalid argument.

1. Using ambiguous premises, and treating them as if they were unambiguous.

2. Circular reasoning (assuming what is to be proved without having derived it from the premises)

3. Jumping to a conclusion (without adequate grounds).

o An argument is invalid means that there is an argument of that form whose premises are all true and

whose conclusion is false.

o A fallacy is an error in reasoning that results in an invalid argument.

1. Using ambiguous premises, and treating them as if they were unambiguous.

2. Circular reasoning (assuming what is to be proved without having derived it from the premises)

3. Jumping to a conclusion (without adequate grounds).

o An argument is invalid means that there is an argument of that form whose premises are all true and

whose conclusion is false.

o Inverse Error

1. The conclusion of the argument would follow from the premises if the premise p →q were

replaced by its inverse. Such a replacement is not allowed, however, because a conditional

statement is not logically equivalent to its inverse. Inverse error is also known as the fallacy of

denying the antecedent.

2. “A cow eats grass. This animal is not a cow, so it won't eat grass.“

34 Discret Structure for BSCS…… Prepared by Abdur-Rehman

3. “An odd number is prime, 15 is odd, so 15 is prime" is not fallacious| it is a logically correct

argument based on an incorrect hypothesis.”

Rules of Inference for Propositional Logic

In logic, the words true and valid have very different meanings. A valid argument may have a false

conclusion, and an invalid argument may have a true conclusion.

Example

Arguments with Quantified Statements

All men are mortal.

valid by modus ponens. But its major premise is false, and so is its conclusion.

The argument is invalid by the converse error, but it has a true conclusion.

35 Discret Structure for BSCS…… Prepared by Abdur-Rehman

Socrates is a man.

∴ Socrates is mortal.

o Universal Instantiation

If some property is true of everything in a set, then it is true of any particular thing in the set.

For all real numbers x, x1 = x. universal truth

r is a particular real number. particular instance

∴ r 1

= r.

Universal Modus Ponens

o Could be written as “All things that make P(x) true make Q(x) true,” in which case the conclusion would

follow by universal instantiation alone.

If an integer is even, then its square is even.

k is a particular integer that is even.

∴ k2 is even.

o Major premise can be written as ∀x, if x is an even integer then x2 is even.

o Let E(x) be “x is an even integer,” let S(x) be “x2 is even,” and let k stand for a particular integer that is

even. Then the argument has the following form:

∀x, if E(x) then S(x).

E(k), for a particular k.

∴ S(k).

o This argument has the form of universal modus ponens and is therefore valid.

Universal Modus Tollens

36 Discret Structure for BSCS…… Prepared by Abdur-Rehman

All human beings are mortal.

Zeus is not mortal.

∴ Zeus is not human.

Solution The major premise can be rewritten as ∀x, if x is human then x is mortal.

Let H(x) be “x is human,” let M(x) be “x is mortal,” and let Z stand for Zeus. The argument becomes

∀x, if H(x) then M(x)

∼M(Z)

∴ ∼H(Z).

This argument has the form of universal modus tollens and is therefore valid.