1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk...

28
Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya [email protected]

Transcript of 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk...

Page 1: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

1Introduction to Abstract Mathematics

The Logic of Compound Statements2.1 and 2.2

Instructor: Hayk Melikya [email protected]

Page 2: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

2Introduction to Abstract Mathematics

Logic Logic is not only the foundation of mathematics, but also isimportant in numerous fields including law, medicine, andscience. Although the study of logic originated in antiquity,it was rebuilt and formalized in the 19th and early 20th

century. George Boole (Boolean algebra) introducedMathematical methods to logic in 1847 while Georg Cantordid Theoretical work on sets and discovered that there aremany different sizes of infinite sets.

Page 3: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

3Introduction to Abstract Mathematics

Logic Mathematical logic is a tool for dealing with formal

reasoning Logic does:

– Assess if an argument is valid/invalid Logic does not directly:

– Assess the truth of atomic statements

Page 4: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

4Introduction to Abstract Mathematics

Logic can deduce that:– NCCU is in North Carolina

given these facts:– NCCU is in Durham– Durham is in North Carolina

Logic knows nothing of whether these facts actually hold in real life!

Page 5: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

5Introduction to Abstract Mathematics

Argument #1

All men are mortal Socrates is a man

Therefore, Socrates is mortal

Page 6: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

6Introduction to Abstract Mathematics

Where is COMP2200 ? How do we find such bugs in software?

– Tracing– Debug statements– Test cases– Many software testers working in parallel…

All of that had been employed in the previous cases Yet the disasters occurred…

Logic : means to prove correctness of softwareSometimes can be semi-automatedCan also verify a provided correctness proof

Page 7: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

7Introduction to Abstract Mathematics

Validity An argument is valid if and only if given that its premises

hold its conclusion also holds– Socrates argument: Valid or Invalid?– Sandwich argument: Valid or Invalid?

How can we tell ?

Common sense? Voting? Authority? What is valid argument anyway? Who cares? ???

Page 8: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

8Introduction to Abstract Mathematics

Arguments in Puzzles

The Island of Knights and Knaves

Never lieAlways lie

You meet two people: A, B A says: I am a Knave or B is a Knight

B says A and I are of opposite type

Who is A?

Who is B?

Page 9: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

9Introduction to Abstract Mathematics

Solution

The original statement can be written as: S = X or Y X = “A is a Knave” Y = “B is a Knight” Suppose A is a Knave Then S must be false since A said it Then both X and Y are false If X is false then A is not a Knave Contradiction : A cannot be a Knave and not a

Knave So A must be a Knight So S is true and X is not true Thus, to keep S true Y must be true So B is a Knight too

You meet just one guy : A

A says:“I’m a Knave!” Who is A?

Page 10: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

10Introduction to Abstract Mathematics

Statements or Propositions A proposition or statement is a declaration (sentence) which is

either true or false (but not both same time).

Some examples: 2+2 = 5 is a statement because it is a false declaration.

Orange juice contains vitamin C is a statement that is true.

Open the door. This is not considered a statement since we cannot assign a true or false value to this sentence. It is a command, but not a statement or proposition.

WHAT TIME IS IT?.

5 + 7. X + 5 = 13.

Page 11: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

11Introduction to Abstract Mathematics

Negation( or denial) The negation of a statement, p , is “not p” and is

denoted by ~p ( also ┐p ) If p is true, then its negation is false. If p is false,

then its negation is true. Truth table:

p ┐p T F F T

If p : “Jack went up the hill” then ~ p : “ Jack did not go up the hill”

Page 12: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

12Introduction to Abstract Mathematics

Conjunction (Logical AND)

In ordinary English, we are building new propositions from oldones via connectors. Similar way we will construct new

propositionsfrom old ones in mathematics too.

Definition: If P and Q are proposition then P Q is a new proposition which referred to as the conjunction of “P and Q”. The proposition P Q is true if both P and Q are true propositions and it is false otherwise.

P Q P Q

T T T

T F F

F T F

F F F

Page 13: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

13Introduction to Abstract Mathematics

Disjunction (Logical OR)

Definition: If P and Q are proposition then P Q is a new proposition which referred to as the disjunction of P and Q . The proposition P Q is false if both P and Q are false propositions and it is true otherwise.

P Q P Q

T T T

T F T

F T T

F F F

Page 14: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

14Introduction to Abstract Mathematics

The Implication (Conditional)

Definition: If P and Q are proposition then P Q is a new proposition which referred to as “P implies Q” . The proposition P Q is false if P is true and Q is false and it is true otherwise

P Q P Q

T T T

T F F

F T T

F F T

In conditional statements: p q

p is called the hypothesis and q is called the conclusion

The only combination of circumstances in which a conditional sentence is false is when the hypothesis is true and the conclusion is false

Page 15: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

15Introduction to Abstract Mathematics

Conditional Statements: P Q

P is also called: assumption or premise or antecedent

A conditional statements is called vacuously true or true by default when its hypothesis is false

Q is called : conclusion

There are several ways of expressing P Q :1. If P, then Q

2. Q if P3. P implies Q4. P only if Q

5. Q is necessary for P

6 P is sufficient for Q

Page 16: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

16Introduction to Abstract Mathematics

Exercise: Rewrite each of the following sentences in "if, then" form

(a) You will pass the test only if you study for at least four hours.

(b) Attending class regularly is a necessary condition for passing the course.

(c) In order to be a square, it is sufficient that the quadrilateral have four equal angles.

(d) In order to be a square, it is necessary that the quadrilateral have four equal angles.

(e) An integer is an odd prime only if it is greater than 22

Page 17: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

17Introduction to Abstract Mathematics

Conditional Statement : p q

Contrapositive of p q is another conditional statement ~q ~pA conditional statement is equivalent to its contrapositive

The converse of p q is q p

The inverse of p q is ~p ~q

Conditional statement and its converse are not equivalent Conditional statement and its inverse are not equivalent What do you think about convers and inverse of statement???????

Page 18: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

18Introduction to Abstract Mathematics

Conditional Statements

The converse and the inverse of a conditional statement are equivalent to each other

p only if q means ~q ~p, or p q Biconditional of p and q means “p if and only if

q” and is denoted as p q r is a sufficient condition for s means r s r is a necessary condition for s means ~r ~ s “if not r then not s” which is same as s

r

Page 19: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

19Introduction to Abstract Mathematics

Exercises: Write contrapositive, converse and inverse statements for

– If P is a square, then P is a rectangle

– If today is Thanksgiving, then tomorrow is Friday

– If c is rational, then the decimal expansion of c is repeating

– If n is prime, then n is odd or n is 2

– If x is nonnegative, then x is positive or x is 0

– If Tom is Ann’s father, then Jim is her uncle and Sue is her aunt

– If n is divisible by 6, then n is divisible by 2 and n is divisible by 3

Page 20: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

20Introduction to Abstract Mathematics

Contrapositive: Examples

The contrapositive of “if p then q” is “if ~q then ~p”.

Statement: If you don’t give me all your money, then you will die immediately.

Statement: If you are a CS year 1 student, then you are taking COMP 2200.

Contrapositive: If you don’t want to die immediately,then you give me all your money.

Contrapositive: If you are not taking COMP 2200, then you are not a CS year 1 student.

Fact: A conditional statement is logically equivalent to its contrapositive.

Page 21: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

21Introduction to Abstract Mathematics

Biconditional

P Q is often read as : P if and only if Q or P iff Q for shorthand.

phrasing of P Q is P is a necessary and sufficient condition for Q.

Definition: If P and Q are propositions then the biconditional P and Q is a proposition denoted by P Q whose truth value is given by the truth table

P Q P Q

T T T

T F F

F T F

F F T

Page 22: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

22Introduction to Abstract Mathematics

Propositional forms/ formulas

/expressions: • Alphabet:

variables (letters upper/lower X, Y, Z, … A, B, C ) symbols , , ~, and parentheses ( , ) also we add two more , , • Propositional expressions (propositional forms) are formed using these elements of alphabet as follows: 1. Each variable is propositional expression 2. IF p and q are propositinal expressions then

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

all are propositional expressions

3. Any expression is obtained by applying repeatedly steps 1 or 2.

Page 23: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

23Introduction to Abstract Mathematics

Truth TablesRecall that propositional forms are made up of propositional variablesand logical connectors in such a way that if one substitute the

propositional variables by actual propositions then it becomes proposition.

The truth table for a given propositional form displays the truth values that corresponds to all possible combinations of truth values for its propositional variables. Let us construct the truth table for propositional form (p q) ~(p q) which often denoted as p q (p XOR q) exclusive or

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

T T T T F F

T F T F T T

F T T F T T

F F T T F F

Page 24: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

24Introduction to Abstract Mathematics

Logical Equivalence

Two propositional forms are cold logically equivalent if they have identical truth tables.

If propositional forms p and q are logically equivalent we write p q ,

p q p q ~p ~p q

T T T F T

T F F F F

F T T T T

F F T T T

Show that p q is logically equivalent to ~p q

Page 25: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

25Introduction to Abstract Mathematics

Tautology and contradiction

Definition: A propositional form (compound proposition) is called a tautology if it is true for all possible combinations of truth values assigned to propositional variables (component propositions).

( p ~p ) t ( toutalogy)

Definition: A propositional form (compound proposition ) is called a contradiction if it is false for all possible combinations of truth values of the propositional variables (component propositions)

( p ~p ) c (contradiction)

A compound proposition is a proposition composed of one or more given propositions (called the component propositions in this context) and at least one logical connective.

Page 26: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

26Introduction to Abstract Mathematics

Examples:

Write truth table for: p q ~p

Show that (p q) r (p r) (q r)

Representation of : p q ~p qRe-write using if- then: Either you get in class on time, or you risk missing some material

Negation of : ~(p q) p ~qWrite negation for: If it is raining, then I cannot go to the beach

Page 27: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

27Introduction to Abstract Mathematics

Theorem RR ( See theorem 1.1.1) (replacement rules)

1. Commutative Law [Com] 2. Associative Law [Assoc]P Q Q P , (P Q ) R P (Q R) P Q Q P (P Q ) R P (Q R)

3. Distributive Law [Dist] 4. Contrapositive Law [Contr] P (Q R) (P Q) (P R) (P Q) (~ Q ~ P) P (Q R) (P Q) (P R)

5. DeMorgan Law [DeM] 6. Double Negation [DN]

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

7. Implication Law [Impl] 8. Equivalence Law [Equiv] (P Q) (~ P Q) P Q ( P Q) (Q P)

P Q (P Q) (~ Q ~ P) 9. Exportation [Exp] 10. Tautology (Identity) [Taut] (P Q) R P (Q R) P P P or P P P

11. P t P and P c c 12 P t t and P c P

t-tautolagy and c-contradiction

Page 28: 1 Introduction to Abstract Mathematics The Logic of Compound Statements 2.1 and 2.2 Instructor: Hayk Melikya melikyan@nccu.edu.

28Introduction to Abstract Mathematics

Practice problems

1. Study the Sections 2.1 and 2.2 from your textbook.2. Be sure that you understand all the examples

discussed in class and in textbook.3. Only after you complete the proof of the Theorem_RR

from the notes 4. Do the following problems from the textbook:

Exercise 2.1, # 2, 3, 7, 8, 15, 26, 36, 43, 44, 46, 51. Exercise 2.2, # 9, 15, 18, 21, 25, 27, 36, 44, 46, 48.