34
CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 June 14, 2022 Introduction & Propositional Logic 1

CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Embed Size (px)

Citation preview

Page 1: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

CS 381 DISCRETE

STRUCTURES

Gongjun Yan

Aug 25, 2008 April 20, 2023Introduction & Propositional Logic 1

Page 2: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

CS381 Syllabus:

http://www.cs.odu.edu/~ygongjun/courses/cs381fall08/instructions/syllabus/syllabus.html

Home page: http://www.cs.odu.edu/~ygongjun/teaching/

Schedule:http://www.cs.odu.edu/~ygongjun/courses/cs381fall08/instructions/schedule.html

Submission web page: http://www.cs.odu.edu/~ygongjun/submit/

April 20, 2023Introduction & Propositional Logic 2

Page 3: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Statement / Proposition

Declarative Makes a statement Can be understood to be either true or false in an

interpretation Symbolized by a letter Examples:

Today is Wednesday. 5 + 2 = 7 3 * 6 > 18 The sky is blue. Why is the sky blue? Brett Favre This sentence is false.

Test Your Understanding of Proposition

April 20, 2023Introduction & Propositional Logic 3

Page 4: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Symbols & Definitions for Compound Statements

p q p q p q ~p1 1 1 1 01 0 0 1 00 1 0 1 10 0 0 0 1

April 20, 2023Introduction & Propositional Logic 4

Conjunction AND — symbolized by

Disjunction OR — symbolized by

Negation NOT — symbolized by ~ /

Truth Tables for these operators Alone Combined

Page 5: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Translation of English to Symbolic Logic Statements The sky is blue.

One simple (atomic) statement – assign to a letter i.e. b

The sky is blue and the grass is green. One statement Conjunction of two atomic statements Each single statement gets a letter i.e. b g And join with ^ i.e. b ^ g

The sky is blue or the sky is purple. One statement Disjunction of two atomic statements Each single statement gets a letter i.e. b p And join with i.e. b p

April 20, 2023Introduction & Propositional Logic 5

Page 6: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Trickier Translation 1

The sky is blue or purple.

Two statements (two concepts) The sky is blue (assign this to b) The sky is purple (assign this to p)

Still a disjunction The sky is blue or the sky is purple b v p

April 20, 2023Introduction & Propositional Logic 6

Page 7: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Trickier Translation 2

The sky is blue but not dark.

Two statements The sky is blue assign this to b The sky is dark assign this to d

Conjunction with negation The sky is blue and the sky is not dark The sky is blue and it is not the case that the sky is

dark "it is not the case that the sky is dark" is ~d b ^ ~ d

April 20, 2023Introduction & Propositional Logic 7

Page 8: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Trickier Translation 3

2 x 6

English: x is greater than or equal to 2 and less than or equal to 6

Two statements: x is greater than or equal to 2 assign this

to p x is less than or equal to 6 assign this to q

Becomes p ^ q

April 20, 2023Introduction & Propositional Logic 8

Page 9: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

… Continued 2 x 6

p is actually a compound statement x is greater than 2 or x is equal to 2 r

v s x is greater than 2 is symbolized by r x is equal to 2 is symbolized by s

q is actually a compound statement x is less than 6 or x is equal to 6 m v n x is less than 6 is symbolized by m x is equal to 6 is symbolized by n p ^ q becomes (r v s) ^ (m v n)

April 20, 2023Introduction & Propositional Logic 9

Page 10: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Truth Table Examples

Truth Table tabulates the value of a proposition for all possible values of its variables

Examples

Test Your Understanding of Truth Table

April 20, 2023Introduction & Propositional Logic 10

Page 11: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

More about Operators

Exclusive or: p, q: p or q but not both p q same as (p v q) ^ ~(p ^ q)

Precedence between the operators ~ (NOT) highest precedence ^ (AND) / v (OR) have equal

precedence Use parentheses to override default

precedence a ^ b v c

April 20, 2023Introduction & Propositional Logic 11

Page 12: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Special Results in the Truth Table Tautological Proposition

A tautology is a statement that can never be false When all of the lines of the truth table have the result

"true" Contradictory Proposition

A contradiction is a statement that can never be true When all of the lines of the truth table have the result

"false" Logical Equivalence of two propositions

p q Two statements are logically equivalent if they will be true

in exactly the same cases and false in exactly the same cases

When all of the lines of one column of the truth table have all of the same truth values as the corresponding lines from another column of the truth table

April 20, 2023Introduction & Propositional Logic 12

Page 13: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Logical Equivalences

Double Negative: ~(~p) p

Commutative: p q q p, and p ^ q q ^ p

Associative: (p q) r p (q r), and (p ^ q) ^ r p ^ (q ^ r)

Distributive: p ^ (q r) (p ^ q) (p ^ r), and p (q ^ r) (p q) ^ (p r)

April 20, 2023Introduction & Propositional Logic 13

Page 14: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

More Logical Equivalences

Idempotent: p ^ p p, and p p p

Absorption: p (p ^ q) p, and p ^ (p q) p

Identity: p ^ t p, and p c p

Negation: p ~p t, and

p ^ ~p c Universal Bound:

p ^ c c, and p t t

Negations of t and c: ~t c, and ~c t

More ListApril 20, 2023Introduction & Propositional Logic 14

Page 15: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Simplification Examples

(~p (~p ^ q)) ^ (~p ^ (~p q)) ?= (~p ~p) ^(~p q)) ^ (~p ^ (~p q))

[distributive]= (~p ^ (~p q)) ^ (~p ^ (~p q))

[Idempotent]= (~p ^ (~p q)) [Absorption]=~p

Your turn(~p (~p ^ (z f))) (p ^ (p q)) ?

Game Time: Test your understanding April 20, 2023Introduction & Propositional Logic 15

Page 16: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

DeMorgan's Laws ~( p q ) ~p ^ ~q ~( p ^ q ) ~p ~q

It is not the case that Pete or Quincy went to the store. Pete did not go to the store and Quincy did not go to the store.

It is not the case that both Pete and Quincy went to the store. Pete did not go to the store or Quincy did not go to the store.

April 20, 2023Introduction & Propositional Logic 16

Page 17: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Venn Diagrams Circles used to tell "Truth Sets"

Where the predicate applied to a object is true If "all" then a completely contained circle If "some" then an overlapping circle

April 20, 2023Predicate Calculus 17

All college students are brilliant.All brilliant people are scientists.All college students are scientists.

Some poets are unsuccessful.Some athletes are unsuccessful. Some poets are athletes.

S B CP

A

U OR UP

A

Page 18: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Venn Diagrams

April 20, 2023Predicate Calculus 18

T

pq

P

A

U

10

1

6

3

Using VD prove DeMorgan

Page 19: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Prove by Truth Tables & by Rules & venn diagram ~(p ~q) (~q v ~p) ~p

DeMorgan pv~q^(pvq) = p

=pv(~q^(pvq)) =pv((~q^p)v(~q^q)) = pv(~q^p)vc =p Venn Diagram

~((~p ^ q) (~p ^ ~q)) (p ^ q) p DeMorgan

April 20, 2023Introduction & Propositional Logic 19

Page 20: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Conditional Statements Hypothesis Conclusion If this, then that; Hypothesis implies Conclusion has lowest precedence (~ / ^ / ) Examples

If it is raining, I will carry my umbrella. If you don’t eat your dinner, you will not get desert.Test your understanding

April 20, 2023Introduction & Propositional Logic 20

p q p q1 1 1

1 0 0

0 1 1

0 0 1

Page 21: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Converting: to p q ~p q Show with Truth Table

~(p q ) p ^ ~q Show with Truth Table and Rules Test Your understanding

April 20, 2023Introduction & Propositional Logic 21

Page 22: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

How to use p q ~p q

April 20, 2023Introduction & Propositional Logic 22

Page 23: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Contrapositive p q ~q ~p Negate both the conclusion and the hyp

othesis Use the negated Conclusion as the new

Hypothesis and the negated Hypothesis as the Conclusion

Example 1 If I turn in my homework late, I will not get c

redit. If I get credit for my homework, I turned it in

on time. Test Your Understanding of Converse

and Contrapositive Test 2

April 20, 2023Introduction & Propositional Logic 23

Page 24: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Converse and Inverse

p → q If Paula is here, then Quincy is here.

Converse: q → p Swap the hypothesis and the conclusion If Quincy is here, then Paula is here.

Inverse: ~p → ~q Negate the hypothesis and negate the

conclusion If Paula is not here, then Quincy is not here.

April 20, 2023Introduction & Propositional Logic 24

Page 25: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Only If

Translation to if-then form p only if q p can be true only if q is true if q is not true then p cannot be true if not q then not p (~q ~p) if p then q (p q)

Game Time: Test your understanding of if-then

April 20, 2023Introduction & Propositional Logic 25

Page 26: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

From English to Proposition Translation in English

You will graduate in CS only if you pass this course. G only if P

If you do not pass this course then you will not graduate in CS. ~P ~G

If you graduate in CS then you passed this course. G P

Game Time: Test Your Understanding of English to Logic Translation

April 20, 2023Introduction & Propositional Logic 26

Page 27: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Biconditional

p if and only if q p q p iff q

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

April 20, 2023Introduction & Propositional Logic 27

p q p q1 1 1

1 0 0

0 1 0

0 0 1

Page 28: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Other English Words for Implication Sufficient Condition

"if r, then s" r s The truth of r is sufficient to ensure the truth

of s Means r is a sufficient condition for s

Necessary Condition Equivalent to "if not r, then not s" ~r ~s If r does not occur, then s cannot occur either The truth of r is necessary if s is true Means r is a necessary condition for s

Sufficient and Necessary Condition r if, and only if s r s The truth of r is enough to ensure the truth of

s and vice versa

April 20, 2023Introduction & Propositional Logic 28

Page 29: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

April 20, 2023Introduction & Propositional Logic 29

Page 30: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

April 20, 2023Introduction & Propositional Logic 30

Page 31: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Rules of Inference Provide the justification of the steps used to

show that a conclusion follows logically from a set of hypotheses.

General Form: hypothesis 1 hypothesis 2 … ∴ conclusion Note: “∴” means therefore”

Each valid logical inference rule corresponds to an implication that is a tautology.

(hypothesis 1 ∧ hypothesis 2 ∧ …)→ conclusion

April 20, 2023Introduction & Propositional Logic 31

Page 32: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Rules of Inference

Modus Ponens Modus Tollens Disjunctive Syllogism

p qp q

p q~q

~p

p q~q p

p q~p q

Disjunctive AdditionConjunctive

SimplificationRule of Contradiction

p p q

q p q

p ^ q p

p ^ q q

~p c p

Hypothetical Syllogism

Conjunctive Addition Dilemma

p qq r p r

pq p ^ q

p qp rq r r

April 20, 2023 Introduction & Propositional Logic 32

Page 33: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Proofs Using Rules of Inference

April 20, 2023Introduction & Propositional Logic 33

P1 p qP2 ~(q r)P3 p (m r) ~m

P1 p ^ qP2 p sP3 ~r

~q s ^ r

P1 p q

P2 q r

P3 ~p

r

Page 34: CS 381 DISCRETE STRUCTURES Gongjun Yan Aug 25, 2008 15 November 2015Introduction & Propositional Logic 1

Exercises

Test On You Own http://www.cs.odu.edu/~ygongjun/

courses/cs381fall09/cs381content/logic/identities-exercise.html

April 20, 2023Introduction & Propositional Logic 34