cs100: discrete structures - wordpress.com propositional logic ¨a propositionis a...

77
CS 100 : DISCRETE STRUCTURES Lecture 5: Logic (Ch1)

Upload: nguyentuyen

Post on 17-May-2018

217 views

Category:

Documents


4 download

TRANSCRIPT

CS100: DISCRETE STRUCTURES

Lecture 5: Logic (Ch1)

Lecture Overview

¨ Statement

¨ Logical Connectives¤ Conjunction¤ Disjunction

¨ Propositions¤ Conditional¤ Bio-conditional¤ Converse¤ Inverse¤ Contrapositive

¨ Laws of Logic

¨ Quantifiers¤ Universal ¤ Existential

1438-06-27 Computer Science Department

2

What is a Statement ?

¨ A statement is a sentence having a form that is typically used to express acts

¨ Examples:¤ My name is Rawan¤ I like orange¤ 4 – 2 = 3¤ Do you live in Riyadh?

1438-06-27 Computer Science Department

3

1.1 Propositional Logic

¨ A proposition is a declarative sentence (a sentence that declares a fact) that is either true or false, but not both.

¨ Are the following sentences propositions?¤ Riyadh is the capital of K.S.A. ¤ Read this carefully. ¤ 2+2=3¤ x+1=2¤ What time is it¤ Take two books .¤ The sun will rise tomorrow .

(No à Because it is not declarative sentence)

(No à Because it is neither true or false)

(No à Because it is not declarative sentence)

(Yes)

(Yes)

1438-06-27 Computer Science Department

4

(No à Because it is not declarative sentence)(Yes)

Logical Connectives and Compound Statement¨ In mathematics, the letters x, y, z, … are used to donate

numerical variables that can be replaced by real numbers.¨ Those variables can then be combined with the familiar

operations +, -, x, ÷.¨ In logic, the letters p, q, r, s, … denote the propositional

variables; that can be replaced by a statements.

1438-06-27 Computer Science Department

5

1.1 Propositional Logic

¨ Propositional Logic: the area of logic that deals with propositions

¨ Propositional Variables: variables that represent propositions: p, q, r, s¤ E.g. Proposition p – “Today is Friday.”

¨ Truth values: T, F

1438-06-27 Computer Science Department

6

1.1 Propositional Logic

¨ Examples¤ Find the negation of the following propositions and express this in simple

English.n “Today is Friday.”

n “At least 10 inches of rain fell today in Miami” .

DEFINITION 1

Let p be a proposition. The negation of p, denoted by ¬p, is the statement “It is not the case that p.”

The proposition ¬p is read “not p.” The truth value of the negation of p, ¬pis the opposite of the truth value of p.

Solution: The negation is “It is not the case that today is Friday.”In simple English, “Today is not Friday.” or “It is not Friday today.”

Solution: The negation is “It is not the case that at least 10 inches of rain fell today in Miami.”In simple English, “Less than 10 inches of rain fell today in Miami.”1438-06-27

7

1.1 Propositional Logic8

Exercise ..¨ Give the negation of the following:

• p: 2 + 3 > 1

• q: It is cold .

• r: 2+3 ≠5

• g: 2 is a positive integer

¬ p: 2 + 3 ≤ 1

¬ q: It is not cold.

¬ r: 2 + 3 = 5

¬ g: 2 is not a positive integer . OR ¬g: 2 is a zero or negative integer .

1.1 Propositional Logic

¨ Truth table:

¨ Logical operators are used to form new propositions from two or more existing propositions. The logical operators are also called connectives.

The Truth Table for the Negation of a Proposition.

p ¬pTF

FT

1438-06-27

9

1.1 Propositional Logic

DEFINITION 2

Let p and q be propositions. The conjunction of p and q, denoted by p Λ q, is the proposition “p and q”. The conjunction p Λ q is true when both p and q are true and is false otherwise.

1438-06-27 Computer Science Department

10

The Truth Table for the Conjunction of Two Propositions.

p q p Λ qT TT FF TF F

TFFF

1.1 Propositional Logic

¨ Example¤ Find the conjunction of the propositions p and q where p is the

proposition “Today is Friday.” and q is the proposition “It is raining today.”, and the truth value of the conjunction.

Solution: The conjunction is the proposition “Today is Friday and it is raining today” OR “Today is Friday but it is raining.”

The proposition is:

TRUE à on rainy Fridays.

FALSE à on any day that is not a Friday and on Fridays when it does not rain .

1438-06-27 Computer Science Department

11

1.1 Propositional Logic

¨ Note:inclusive or : The disjunction is true when at least one of the two propositions is true.

DEFINITION 3

Let p and q be propositions. The disjunction of p and q, denoted by p ν q, is the proposition “p or q”. The disjunction p ν q is false when both p and q are false and is true otherwise.

1438-06-27 Computer Science Department

12

The Truth Table for the Disjunction of Two Propositions.

p q p ν qT TT FF TF F

TTTF

¤ E.g. “Students who have taken calculus or computer science can take this class.” – those who take one OR both classes.

1.1 Propositional Logic

1438-06-27 Computer Science Department

13

¨ Example¤ Find the disjunction of the propositions p and q where p is the

proposition “Today is Friday.” and q is the proposition “It is raining today.”, and the truth value of the conjunction.

Solution: The conjunction is the proposition “Today is Friday or it is raining today”

The proposition is:

TRUE à whether today is Fridays or a rainy day including rainy Fridays

FALSE à on days that are not a Fridays and when it does not rain .

1.1 Propositional Logic

exclusive or : The disjunction is true only when one of theproposition is true.

¤ E.g. “Students who have taken calculus or computer science, but not both, can take this class.” – only those who take ONE of them.

1438-06-27 Computer Science Department

14

1.1 Propositional Logic

The Truth Table for the Exclusive Or (XOR) of Two Propositions.

p q p qT TT FF TF F

FTTF

Å

DEFINITION 4

Let p and q be propositions. The exclusive or of p and q, denoted by 𝒑⊕ 𝒒, is the proposition that is true when exactly one of p and q is true and is false otherwise.

Å

1438-06-27

15

1.1 Propositional Logic

Å

DEFINITION 5

Let p and q be propositions. The conditional statement p → q, is the proposition “if p, then q.” The conditional statement is false when p is true and q is false, and true otherwise. In the conditional statement p→ q, p is called the hypothesis (or antecedent or premise) and q is called the conclusion (or consequence).

Conditional Statements

l A conditional statement is also called an implication.l Example: “If I am elected, then I will lower taxes.”

implication: p q | p → qelected, lower taxes. T T | Tnot elected, lower taxes. F T | Tnot elected, not lower taxes. F F | Telected, not lower taxes. T F | F

1438-06-27

16

1.1 Propositional Logic

¨ Example:¤ Let p be the statement “Maria learns discrete mathematics.” and q the

statement “Maria will find a good job.” Express the statement p → q as a statement in English.

Solution: Any of the following -

“If Maria learns discrete mathematics, then she will find a good job.

“Maria will find a good job when she learns discrete mathematics.”

“For Maria to get a good job, it is sufficient for her to learn discrete mathematics.”

“Maria will find a good job unless she does not learn discrete mathematics.”

1438-06-27 Computer Science Department

17

1.1 Propositional Logic

¨ Other conditional statements:

¤ Converse of p → q : q → p

¤ Contrapositive of p → q : ¬ q → ¬ p¤ Inverse of p → q : ¬ p → ¬ q

¨ Equivalent Statements:¤ Statements with the same truth table values.

¤ Converse and Inverse are equivalents.

¤ Contrapositive and p → q are equivalents.

1438-06-27 Computer Science Department

18

1.1 Propositional Logic

¨ p ↔ q has the same truth value as (p → q) Λ (q → p)

¨ “if and only if” can be expressed by “iff”¨ Example:

¤ Let p be the statement “You can take the flight” and let q be the statement “You buy a ticket.” Then p ↔ q is the statement “You can take the flight if and only if you buy a ticket.”Implication:If you buy a ticket you can take the flight.If you don’t buy a ticket you cannot take the flight.

DEFINITION 6

Let p and q be propositions. The biconditional statement p ↔ q is the proposition “p if and only if q.” The biconditional statement p ↔ q is true when p and q have the same truth values, and is false otherwise. Biconditional statements are also called bi-implications.

1438-06-27 Computer Science Department

19

1.1 Propositional Logic

The Truth Table for the Biconditional p ↔ q.

p q p ↔ qT TT FF TF F

TFFT

1438-06-27

20

1.1 Propositional Logic

1438-06-27

21

Exercise ..¨ Let p and q be the propositions

p : I bought a lottery ticket this week.

q : I won the million dollar jackpot on Friday.

¨ Express each of these propositions as an English sentence.

1) ¬𝑝

2) ¬𝑝 → ¬𝑞

3) ¬ 𝑝 ∨ 𝑞

I did not buy a lottery ticket this week.

If I did not buy a lottery ticket this week, then I did not win the million dollar jackpot on Friday.

I did not buy a lottery ticket this week, and I did notwin the million dollar jackpot on Friday.

1.1 Propositional Logic

¨ We can use connectives to build up complicated compound propositions involving any number of propositional variables, then use truth tables to determine the truth value of these compound propositions.

¨ Example: Construct the truth table of the compound proposition

(p ν ¬q) → (p Λ q)

The Truth Table of (p ν ¬q) → (p Λ q).p q ¬q p ν ¬q p Λ q (p ν ¬q) → (p Λ q)

T TT FF TF F

FTFT

TTFT

TFFF

TFTF

Truth Tables of Compound Propositions22

Types of statements

¨ A statements that is true for all possible values of its propositional variables is called tautology

¨ (𝑝 ∨ 𝑞) ↔ (𝑞 ∨ 𝑝)¨ 𝑝 ∨∼ 𝑝

¨ A statement that is always false is called contradiction

¨ 𝑝 ∧∼ 𝑝

¨ A statement that can be either true or false, depending of the values of its propositional variables, is called a contingency

¨ (𝑝 ⟶ 𝑞) ∧ (𝑝 ∧ 𝑞)1438-06-27 Computer Science Department

23

Examples of a Tautology and a Contradiction.

p ¬p p ν ¬p p Λ ¬p

TF

FT

TT

FF

1.1 Propositional Logic

¨ We can use parentheses to specify the order in which logical operators in a compound proposition are to be applied.

¨ To reduce the number of parentheses, the precedence order is defined for logical operators.

Precedence of Logical Operators.Operator Precedence

¬ 1Λ

ν23

→↔

45

Precedence of Logical Operators

E.g. ¬p Λ q = (¬p ) Λ q

p Λ q ν r = (p Λ q ) ν r

p ν q Λ r = p ν (q Λ r)

1438-06-27

24

1.1 Propositional Logic

1438-06-27

25

Exercise ..

¨ find the truth table of the following proposition p ˄ ( ¬( q ˅ ¬p))

p q ¬p q ˅ ¬p ¬( q ˅ ¬p) p ˄ ( ¬( q ˅ ¬p))

T T F T F F

T F F F T T

F T T T F F

F F T T F F

1.1 Propositional Logic

¨ English (and every other human language) is often ambiguous. Translating sentences into compound statements removes the ambiguity.

¨ Example: How can this English sentence be translated into a logical expression?

“You cannot ride the roller coaster if you are under 4 feet tall and you are not older than 16 years old.”

Translating English Sentences

Solution: Let q, r, and s represent “You can ride the roller coaster,”

“You are under 4 feet tall,” and “You are older than

16 years old.” The sentence can be translated into:

(r Λ ¬ s) → ¬q.

1438-06-27

26

1.1 Propositional Logic

¨ Example: How can this English sentence be translated into a logical expression?

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

Solution: Let a, c, and f represent “You can access the Internet from

campus,” “You are a computer science major,” and “You are

a freshman.” The sentence can be translated into:

a → (c ν ¬f ) .

1438-06-27

27

1.1 Propositional Logic

1438-06-27

28

Exercise ..¨ Write the following statement in logic :

¤ If I do not study discrete structure and I go to movie , then I am in a good mood .

Solution :p: I study discrete structure ,q: I go to movie , r: I am in a good mood(¬p ˄ q )➝ r

1.1 Propositional Logic

¨ Computers represent information using bits.

¨ A bit (Binary Digit) is a symbol with two possible values, 0 and 1.

¨ By convention, 1 represents T (true) and 0 represents F (false).

¨ A variable is called a Boolean variable if its value is either true or false.

¨ Bit operation – replace true by 1 and false by 0 in logical operations.

Table for the Bit Operators OR, AND, and XOR.x y 𝑥 ∨ 𝑦 𝑥 ∧ 𝑦 𝑥 ⊕ 𝑦

0011

0101

0111

0001

0110

Logic and Bit Operations

1438-06-27

29

1.1 Propositional Logic

¨ Example: Find the bitwise OR, bitwise AND, and bitwise XOR of the bit string 01 1011 0110 and 11 0001 1101.

DEFINITION 7

A bit string is a sequence of zero or more bits. The length of this string is the number of bits in the string.

Solution:

01 1011 0110

11 0001 1101-------------------11 1011 1111 bitwise OR01 0001 0100 bitwise AND10 1010 1011 bitwise XOR

1438-06-27 Computer Science Department

30

1.2 Propositional Equivalences

Examples of a Tautology and a Contradiction.

p ¬p p ν ¬p p Λ ¬p

TF

FT

TT

FF

DEFINITION 1

A compound proposition that is always true, no matter what the truth values of the propositions that occurs in it, is called a tautology. A compound proposition that is always false is called a contradiction. A compound proposition that is neither a tautology or a contradiction is called a contingency.

Introduction

1438-06-27

31

1.2 Propositional Equivalences

¨ Compound propositions that have the same truth values in all possible cases are called logically equivalent.

¨ Example: Show that ¬p ν q and p → q are logically equivalent.

Truth Tables for ¬p ν q and p → q .

p q ¬p ¬p ν q p → q

TTFF

TFTF

FFTT

TFTT

TFTT

DEFINITION 2

The compound propositions p and q are called logically equivalentif p ↔ q is a tautology. The notation p ≡ q denotes that p and q are logically equivalent.

Logical Equivalences

1438-06-27

32

1.2 Propositional Equivalences

1438-06-27

33

Exercise ..

¨ Show that this statements ((p ˄ q) → (p ˅ q)) istautology , by using The truth table :

p q q ˄ p p ˅ q (p ˄ q) → (p ˅ q) T T T T TT F F T TF T F T TF F F F T

Laws of Logic

¨ Identity LawsØ p v F ≡ pØ p ^ T ≡ p

¨ Domination LawsØ p v T ≡ T Ø P ^ F ≡ F

1438-06-27 Computer Science Department

34

Laws of Logic

¨ Idempotent LawsØ p v p ≡ p Ø p ^ p ≡ p

¨ Double Negation LawØ ¬(¬p) ≡ p

¨ Commutative LawsØ p v q ≡ q v pØ p ^ q ≡ q ^ p

1438-06-27 Computer Science Department

35

Laws of Logic

¨ Association LawsØ (p v q ) v r ≡ p v (q v r)

¨ Distributive LawsØ p v (q ^ r ) ≡ (p v q) ^ (p v r)Ø p ^ (q v r) ≡ (p ^ q) v (p ^ r)

Ø

1438-06-27 Computer Science Department

36

Contd.

¨ De Morgan’s LawsØ ~ (p v q) ≡ ~p ^ ~q

Ø ~ (p ^ q) ≡ ~p v ~q

Ø

¨ Absorption LawsØ p v (p ^ q) ≡ pØ p ^ (p v q) ≡ p

1438-06-27 Computer Science Department

37

Contd.

¨ Complement LawsØ p v ~p ≡ T p ^ ~p ≡ FØ ~ ~p ≡ p ~ T ≡ F , ~F ≡ T

¨ p → q ≡ ¬p ˅ q

¨ ¬(p → q ) ≡ p Λ ¬q

¨ Note: See tables 7 & 8 page 25

1438-06-27 Computer Science Department

38

1.2 Propositional Equivalences

¨ Example: Show that ¬(p → q ) and p Λ ¬q are logically equivalent. Solution:

¬(p → q ) ≡ ¬(¬p ν q)≡ ¬(¬p) Λ ¬q (by the second De Morgan law)

≡ p Λ ¬q (by the double negation law)

Constructing New Logical Equivalences39

1.2 Propositional Equivalences

¨ Example: Show that (p Λ q) → (p ν q) is a tautology.Solution: To show that this statement is a tautology, we will use logical equivalences to demonstrate that it is logically equivalent to T. (p Λ q) → (p ν q) ≡ ¬ (p Λ q) ν (p ν q)

≡ (¬ p ν¬q) ν (p ν q) (by the first De Morgan law)

≡ (¬ p νp) ν (¬ q νq) (by the associative and communicative law for disjunction)

≡ T ν T≡ T

¨ Note: The above examples can also be done using truth tables.

1438-06-27

40

Exercises

v Simplify the following statement(p v q ) ^ ~p

v Show that ~p ^ (~q ^ r) v (q ^ r) v (p ^ r) ≡ r

(p → q) v (p → r) ≡ p → q v r

1438-06-27 Computer Science Department

41

Exercises – Continue

Computer Science Department

¨ (p v q ) ^ ~p¤ ≡ ~p ^ ( p v q )¤ ≡ ( ~p ^ p ) v ( ~ p ^ q )¤ ≡ F v ( ~p ^ q )¤ ≡ ~p ^ q

1438-06-27

42

Exercises – Continue

Computer Science Department

¨ ~p ^ (~q ^ r) v (q ^ r) v (p ^ r) ≡ r¤ ≡ ~p ^ r ^ (~q v q) v (p ^ r)¤ ≡ ~p ^ r ^ T v (p ^ r) ¤ ≡ ~p ^ r v (p ^ r)¤ ≡ (~p ^ r) v (p ^ r)¤ ≡ r ^ (~p v p)¤ ≡ r ^ T¤ ≡ r

1438-06-27

43

Exercises – Continue

Computer Science Department

¨ (p → q) v (p → r) ≡ p → q v r¤ ≡ ¬ 𝑝 ⋁ 𝑞 ⋁ ( ¬ 𝑝 ⋁ 𝑟 )¤ ≡ ¬ 𝑝 ⋁ 𝑞 ⋁ ¬ 𝑝 ⋁ 𝑟¤ ≡ ¬ 𝑝 ⋁ ¬ 𝑝 ⋁ 𝑞 ⋁ 𝑟¤ ≡ ¬ 𝑝 ⋁ 𝑞 ⋁ 𝑟¤ ≡ ¬ 𝑝 ⋁ ( 𝑞 ⋁ 𝑟 )¤ ≡ 𝑝 → ( 𝑞 ⋁ 𝑟 )

1438-06-27

44

Exercises – Continue

1438-06-27 Computer Science Department

45

¨ Show that this statements (¬ q ˄ (p ® q ) ® ¬pis tautology , by using The laws of logic :¤ ≡ ¬ (¬ q ˄ (p ® q ) ˅ ¬p ¤ ≡ ¬ (¬ q ˄ (¬p ˅ q ) ˅ ¬p ¤ ≡ q ˅ ¬ (¬p ˅ q ) ˅ ¬p ¤ ≡ (¬p ˅ q ) ˅ ¬ (¬p ˅ q )¤ ≡ T

Exercises – Continue

1438-06-27 Computer Science Department

46

¨ Without using truth tables prove the statement (P ∧( P ➝ q)) ➝ q is tautology.

(P ∧( P ➝ q)) ➝ q ≡ ¬ 𝑝˄ 𝑝 → 𝑞 ˅𝑞≡ ¬𝑝˅¬(¬𝑝˅𝑞 ˅𝑞≡ ¬𝑝˅𝑞 ˅¬ ¬𝑝˅𝑞≡ 𝑇

Computer Science Department

47

25-Mar-17

1.5 Rules of Inference page 63

Valid Arguments in Propositional Logic:

DEFINITION 1

An argument in propositional logic is a sequence of propositions. All but the final proposition in the final argument are called premises and the final proposition is called the conclusion..An argument is valid of the truth of all its premises implies that the conclusion is true.

An argument form in propositional logic is a sequence of compound propositions involving propositional variables.

Computer Science Department

48

25-Mar-17

1.5 Rules of Inference page 63

Example:“If you have access to the network, then you can change your grade”“You have access to the network”--------------------------------------------------∴ “You can change your grade” Valid

Argument

Computer Science Department

49

25-Mar-17

Rules of Inference for Propositional Logic:

¨ We can always use a truth table to show that an argument form is valid.

¨ This is a tedious approach. ¨ when, for example, an argument involves 9

different propositional variables.¨ To use a truth table to show this argument is valid.¨ It requires 2⁹= 512 different rows !!!!!!!

Computer Science Department

50

25-Mar-17

Rules of Inference:

¨ Fortunately, we do not have to resort to truth tables.¨ Instead we can first establish the validity of some

simple argument forms, called rules of inference.¨ These rules of inference can then be used to

construct more complicated valid argument forms.

Computer Science Department

51

25-Mar-17

Rules of Inference

NameTautologyRules of Inference

Modus ponens[p ^ (p ® q)] ® qp p ® q

--------------------∴q

Modus tollens[¬ q ^ (p ® q)] ® ¬ p¬ qp ® q

------------------------∴ ¬ p

Hypothetical syllogism[(p ® q) ^ (q ® r)] ® (p ® r)p ® qq ® r

-----------------------∴ p ® r

Disjunctive syllogism[(p v q) ^ ¬ p] ® qp v q¬P

---------------------∴ q

Additionp ® (p v q)p------------------∴ (p v q)

Simplification(p ^ q) ® pp ^ q-----------------------

∴ p

Conjunction(p) ^ (q) ® (p ^ q)pq

--------------------∴ (p ^ q)

Resolution(p v q) ^ (¬p v r) ® (q v r)p v q¬p v r

---------------∴ q v r

Computer Science Department

52

25-Mar-17

Rules of Inference (Cont.) :

EXAMPLE

State which rule of inference is the basis of the following statement:

¨ “it is below freezing now. Therefore, it is either freezing or raining now”

SOLTUION:¨ Let p: “it is below freezing now”

q: “it is raining now”Then this argument is of the formp

------------- (Addition)∴ p v q

Computer Science Department

53

25-Mar-17

Rules of Inference (Cont.) :

EXAMPLE

“ it is below freezing and it is raining now. Therefore, it is below freezing”SOLUTION:

Let p: “it is below freezing now”q: “it is raining now”

Then this argument is of the formp ^ q----------- (Simplification)

∴ p

Rules of Inference (Cont.) :

25-Mar-17 Computer Science Department

54

What rule of inference is used in each

of these arguments ?

¨ If it is rainy, then the pool will be closed. Itis rainy. Therefore, the pool is closed.

SOLUTION:

Let p: “It is rainy”q: “the pool is closed”

Then this argument is of the formp p®q---------------- (Modus ponens)

∴q

Rules of Inference (Cont.) :

25-Mar-17 Computer Science Department

55

What rule of inference is used in each

of these arguments ?

¨ If I go swimming, then I will stay in the sun too long.If I stay in the sun too long, then I will sunburn.Therefore, if I go swimming, then I will sunburn.

SOLUTION:

Let p: “I go swimming”q: “I stay in the sun too long”r: “I will sunburn”

Then this argument is of the formp→qq→ r------- (Hypothetical syllogism)p→r

Rules of Inference (Cont.) :

25-Mar-17 Computer Science Department

56

What rule of inference is used in each

of these arguments ?

¨ If it snows today, the university will close.The university is not closed today.Therefore, it did not snow today.

SOLUTION:

Let p: “it snows today”q: “The university is not closed today”

Then this argument is of the form¬ qp®q-------------- (Modus tollens)

∴¬ p

Computer Science Department

57

25-Mar-17

¨ When there are many premises, several rules of inference are often needed to show that an argument is valid.

Using Rules of Inference to Build Arguments:

Computer Science Department

58

25-Mar-17

Find the argument

form for the following argument

and determine

whether it is valid or invalid.

¨ If I try hard and I have talent, then I will become a musician.

¨ If I become a musician, then I will be happy.∴ If I will not happy, then I did not try hard or I do not have talent.

It's valid, Hypothetical syllogism.

Using Rules of Inference to Build Arguments (Cont.):

Computer Science Department

59

25-Mar-17

Find the argument

form for the following argument

and determine

whether it is valid or invalid.

¨ If I drive to work, then I will arrive tired.¨ I do not drive to work.∴ I will not arrive tired.

It's invalid

Using Rules of Inference to Build Arguments (Cont.):

Computer Science Department

60

25-Mar-17

Find the argument

form for the following argument

and determine

whether it is valid or invalid.

¨ I will become famous or I will become a writer.

¨ I will not become a writer.∴ I will become famous

Its valid, Disjunctive syllogism

Using Rules of Inference to Build Arguments (Cont.):

Computer Science Department

61

25-Mar-17

Find the argument

form for the following argument

and determine

whether it is valid or invalid.

¨ If taxes are lowered, then income rises.¨ Income rises.∴ Taxes are lowered

It's invalid

Using Rules of Inference to Build Arguments (Cont.):

Computer Science Department

62

25-Mar-17

Using Rules of Inference to Build Arguments (Cont.) :

EXAMPLE

Show that the hypotheses “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, we will be home by sunset.” lead to “we will be home by sunset”

Computer Science Department

63

25-Mar-17

SOLUTION

¨ Let p: “it is sunny this afternoon”q: “it is colder than yesterday”r: “we will go swimming”s: “we will take a canoe trip”t: “we will be home by sunset”

The hypotheses become¬ p ^ q, r ® p, ¬ r ® s, s ® t the conclusion is t

Using Rules of Inference to Build Arguments (Cont.) :

Computer Science Department

64

25-Mar-17

Cont’d:

¨ We construct an argument to show that our hypotheses lead to desired conclusion as followsStep Reason

1. ¬ p ^ q Hypothesis2. ¬ p Simplification using (1)3. r ® p Hypothesis4. ¬ r Modus tollens (2,3)5. ¬ r ® s Hypothesis6. s Modus ponens (4,5)7. s ® t Hypothesis8. t Modus ponens (6,7)Note that if we used the truth table, we would end up with 32

rows !!!

Resolution:

Computer Science Department

65

¨ Computer programs make use of rule of inference

called resolution to automate the task of reasoning

and proving theorems.

¨ This rule of inference is based on the tautology

((p v q) ^ (¬ p v r)) ® ( q v r )

25-Mar-17

Resolution (Cont.):

Computer Science Department

66

25-Mar-17

EXAMPLE

Use resolution to show that the hypotheses

“Jasmine is skiing or it is not snowing”

and “it is snowing or Bart is playing

hockey” imply that “Jasmine is skiing or

Bart is playing hockey”

Resolution (Cont.):

Computer Science Department

67

25-Mar-17

SOLUTION

p: “it is snowing”,

q: “Jasmine is skiing”,

r: “Bart is playing hockey”

We can represent the hypotheses as

¬ p v q and p v r, respectively

Using Resolution, the proposition q v r, “Jasmine is

skiing or Bart is playing hockey” follows

1.3 Quantifiers page 33

v So far we have discussed the propositions in which each statement has been about a particular object. In this section we shall see how to write propositions that are about whole classes of objects.

v Consider the statement: p: x is an even number

v The truth value of p depends on the value of x.e.g.

p is true when x = 4, and false when x = 7

1438-06-27 Computer Science Department

68

1.Universal Quantifiers

¨ “For all values of x, P(x) is true”.For every xFor any x ∀ xEvery x

¨ We assume that only values of x that make sense in P(x) are considered.

∀ x P(x)1438-06-27 Computer Science Department

69

DEFINITION 1

The universal quantification of p(x) is the statement“P(x) for all values of x in the domain.”

The notation ∀ x P(x) denotes the universal quantification of P(x). Here ∀is called the universal quantifier. We read ∀ x P(x) as “for all x P(x)” or “for every x P(x) ”. An element for which P(x) is false called counterexample of ∀ x P(x)

1.Universal Quantifiers

1438-06-27 Computer Science Department

70

Example 8..Let P(X) be the statement “x+1>x”. What is the truth value of the quantification ∀ x P(x), where the domain consists of all real numbers?

Solution¨ The quantification ∀ x P(x),is true because P(x) is true for all real numbers.

1.Universal Quantifiers

1438-06-27 Computer Science Department

71

Example 9..Let Q(X) be the statement “x < 2”. What is the truth value of the quantification ∀ x Q(x), where the domain consists of all real numbers?

Solution¨ Q(x) is not true for every real number x, because Q(3) is false. That is, x=3

is a counterexample for the statement ∀ x Q(x), thus

∀ x Q(x) is false

1.Universal Quantifiers

1438-06-27 Computer Science Department

72

Example 11..What is the truth value of the quantification ∀ x P(x), where P(X) is the statement “x2 < 10” and the domain consists of the positive integers not exceeding 4 ?

Solution¨ The statement ∀ x P(x) is the same as the conjunction

P(1) ^ P(2) ^ P(3) ^ P(4)

¨ Because the domain consists of the positive integers 1,2,3 and 4.

¨ Because P(4), which the statement “42 < 10” is false, it follows that ∀ x P(x) is false.

2.Existential Quantifiers

¨ In some situations, we only require that there is at least one value for which the predicate is true.

¨ The existential quantification of a predicate P(x) is the statement “there exists a value of x, for which P(x) is true.

∃x P(x)There is a dog without tail (∃ a dog) (a dog without tail)

1438-06-27 Computer Science Department

73

DEFINITION 2

The essential quantification of p(x) is the proposition“There exists an element x in the domain such that P(x).”

We use the notation ∃ x P(x) for the essential quantification of P(x). Here ∃ is called the essential quantifier.

1438-06-27 Computer Science Department

74

Example 16..What is the truth value of ∃x P(x), where P(X) is the statement “x2 > 10” and the universe of discourse consists of the positive integers not exceeding 4?

Solution¨ Because the domain is {1, 2, 3, 4}, the proposition ∃ x P(x) is the same as

the disjunction

P(1) v P(2) v P(3) v P(4)

¨ Because P(4), which the statement “42 > 10” is true, it follows that ∃x P(x) is true.

2.Existential Quantifiers

Quantifiers - Negation

¨ Rule:

¨ ∀x p(x) à∃x ¬p(x)¨ ∃x p(x) à ∀ x ¬p(x)

¨ Negate the following:

( ∀ integers x) (x > 8) à (∃ an integer x) (x ≤ 8)

¨ Negate the following;

(∃ an integer x) (0 ≤ x ≤ 8) à ( ∀ integers x) (x < 0 OR x > 8)

1438-06-27 Computer Science Department

75

Quantifiers

1438-06-27 Computer Science Department

76

Exercise ..¤ p(x): x is even

¤ q(x): x is a prime number

¤ r(x,y): x+y is even .

¨ Write an English sentence that represent the following :A. ∀x P(x)

B. ∃x Q(x)

C. ∀x ∃y R(x,y)

¨ Find negation for a. and b.∃x ¬p(x) there is exist x where x is odd

∀x ¬q(x) for every x where x not prime number

for every x where x is even

there is exists x where x is a prime numberfor all x there exists y where x+y is even

Any Questions

¨ Refer to chapter 1 of the book for further reading

1438-06-27 Computer Science Department

77