21
Outline Propositional Logic Propositional Equivalences Proof SWER ENG 2DM3 Tutorial 1 Min Jing Liu Department of Computing and Software McMaster University Sept 15, 2011 Min Jing Liu Department of Computing and Software McMaster University SWER ENG 2DM3 Tutorial 1

SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

SWER ENG 2DM3 Tutorial 1

Min Jing Liu

Department of Computing and SoftwareMcMaster University

Sept 15, 2011

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3 Tutorial 1

Page 2: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Outline

1 Propositional Logic

2 Propositional Equivalences

3 Proof

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 3: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Propositional Logic

Propositional Logic

Example for proposition:

5 is odd.

3 + 4 = 8

A proposition is a declarative sentence is eithertrue or false, but not both.

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 4: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Propositional Logic

Propositional Logic

Question:

1. x2 + 1 = 3

2. The moon is made of green cheese. (Page 12,Ex 2 f)

3. Answer this question. (Page 12,Ex 1 f)

1 and 3 is not a proposition, 2 is false proposition.

We use letter to denote propositional variable: p, q, r,...The truth value of a proposition is true: TThe truth value of a proposition is false: F

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 5: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Propositional Logic

Negation

Let p be a proposition: The negation of p denotedby ¬p(also denoted by p̄)

”It is not the case that p”

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 6: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Propositional Logic

Negation

Example: p: Mei have an Iphone 5.¬p: Mei does not have an Iphone 5.

Truth Table for negation:

p ¬pT FF T

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 7: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Propositional Logic

And, Or

Let p, q be proposition:

The conjunction of p and q: p ∧ q

The disjunction of p and q: p ∨ q

Truth Table:

p q p ∧ q p ∨ q

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

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 8: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Propositional Logic

Conditional Statements

Let p, q be proposition:The conditional statement p → q is the proposition

”if p, then q.”

Truth Table:

p q p → q

T T TT F FF T TF F T

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 9: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Propositional Logic

Biconditional

Let p, q be proposition:The Biconditional statement p ↔ q is the proposition

”p if and only if q.”

Truth Table:

p q p ↔ q

T T TT F FF T FF F T

Remark: p ↔ q has exactly the same truth value as (p → q) ∧ (q → p)

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 10: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Exercise

Example for Logic

Write the truth table of the proposition:

1. (p ∨ q) ∧ ¬pSolution:

p q p ∨ q ¬p (p ∨ q) ∧ ¬pT T T F FT F T F FF T T T TF F F T F

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 11: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Exercise

Example for Logic

Write the truth table of the proposition:

2. [¬(p ∧ q)]→ (q ∧ ¬p)

Solution:

p q p ∧ q ¬(p ∧ q) ¬p q ∧ ¬p [¬(p ∧ q)]→ (q ∧ ¬p)

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

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 12: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Logical Equivalences

Tautology

A compound proposition that is always true, no matter what thetruth value of the propositional variables that occurs in it, is calleda tautology.E.g (p → q) ∨ (p ∧ ¬q)

p q p → q ¬q p ∧ ¬q (p → q) ∨ (p ∧ ¬q)

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

This is a tautology.

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 13: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Logical Equivalences

Logically Equivalent

The compound propositions p and q are called logicallyequivalent if p ↔ q is tautology.

The notation p ≡ q denotes that p and q are logicallyequivalent.

How to determine whether two compound propositions areequivalent:Truth Table

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 14: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Predicates and Quantifiers

Predicates

Statement involving variables, such as x > 3, x2 = 4, ...

Example:P(x , y) denote the statement ”x + y > 5”. What are the truthvalue of P(2, 4), P(1, 3)?

solution:P(2, 4) is True, P(1, 3) is False.

P denote the predicate ”the sum is greater than 5” and x,y are the

variable.

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 15: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Predicates and Quantifiers

Quantifiers

A quantifier is ”an operator that limits the variables of aproposition”

Two types:

Universal: ∀Existential: ∃

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 16: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Predicates and Quantifiers

Exercise

Page 67, Ex 27 (a, c, e, g, i)

a) ∀n∃m(n2 < m)

c) ∀n∃m(n + m = 0)

e) ∃n∃m(n2 + m2 = 5)

g) ∃n∃m(n + m = 4 ∧ n −m = 1)

i) ∀n∀m∃p(p = (m + n)/2)

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 17: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Proof methods

Proof methods

We will discuss three proof methods for prove:

”If P then Q”:

Direct proof

Proof by Contraposition

Proof by Contradiction

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 18: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Proof methods

”If P then Q” - Direct Proof

”If P then Q”:

Assume P is true, and show Q must therefor be true.

Example

Proof ”if n is even, then n2 is even”.

solution

Assume n is even:

Thus, n = 2k , for some k (definition of even numbers)

n2 = (2k)2 = 4k2 = 2(2k2)

As n2 is 2 times an integer, n2 is thus even.

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 19: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Proof methods

”If P then Q” - by Contraposition

”If P then Q”:

Assume Q is false; prove P is false.

Example

Proof ”If n is an integer and n3 + 5 is odd, then n is even”.

Solution

We must prove the contrapositive: If n is odd, then n3 + 5 is even.Assume n is odd:

Thus, n = 2k + 1, for some k (definition of odd numbers)

n3 +5 = (2k +1)3 +5 = 8k3 +12k2 +6k +6 = 2(4k3 +6k2 +3k +2)

n3 + 5 is thus even.

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 20: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Proof methods

”If P then Q” - by Contradiction

”If P then Q”:Showing that the proposition’s being false would imply acontradiction

Example

Proof ”If n is an integer and n3 + 5 is odd, then n is even”.

Solution

Suppose that n3 + 5 is odd and that n is odd.

Since n is odd, the product of odd number is odd. Thus n3 is odd

5 is odd, the sum of odd number is even. Thus n3 + 5 is even

This is not true. Therefore our supposition was wrong

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3

Page 21: SWER ENG 2DM3 Tutorial 1 - McMaster Universityoptlab.mcmaster.ca/~jessiel/SWFR2DMTUT/TUT1_online.pdf · 2011. 9. 15. · Outline Propositional Logic Propositional Equivalences Proof

Outline Propositional Logic Propositional Equivalences Proof

Exercise

Exercise

Every odd integer is the difference of two squares (Directproof) (pg 91, ex 7)

Prove that if m and n are integers and mn is even, then m iseven or n is even.(contradiction) (pg 91, ex 16)

If x + y ≥ 2, where x and y are real numbers, then x ≥ 1 ory ≥ 1 (contraposition) (pg 91, ex 15)

Min Jing Liu Department of Computing and Software McMaster University

SWER ENG 2DM3