discreet mathematics

56
Logic! Jan-May 2013 Introduction to Mathematical Logic: MATH-105 1

description

mathematical logics

Transcript of discreet mathematics

Page 1: discreet mathematics

Logic!

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 1

Page 2: discreet mathematics

• Crucial for mathematical reasoning• Important for program design• Used for designing electronic circuitry

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

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

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

• Corresponds to 1 and 0 in digital circuits

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 2

Page 3: discreet mathematics

“Elephants are bigger than mice.”

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 3

Is this a sentence?Is this a sentence? yesyes

Is this a proposition?Is this a proposition? yesyes

What is the truth What is the truth value value

of the proposition?of the proposition?truetrue

Page 4: discreet mathematics

“520 < 111”

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 4

Is this a sentence?Is this a sentence? yesyes

Is this a proposition?Is this a proposition? yesyes

What is the truth What is the truth value value

of the proposition?of the proposition?falsfals

ee

Page 5: discreet mathematics

“y > 5”

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 5

Is this a sentence?Is this a sentence? yesyes

Is this a proposition?Is this a proposition? nono

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

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

Page 6: discreet mathematics

“Today is January 27 and 99 < 5.”

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 6

Is this a sentence?Is this a sentence? yesyes

Is this a proposition?Is this a proposition? yesyes

What is the truth What is the truth value value

of the proposition?of the proposition?falsfals

ee

Page 7: discreet mathematics

“Please do not fall asleep.”

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 7

Is this a sentence?Is this a sentence? yesyes

Is this a proposition?Is this a proposition? nono

It’s a request.It’s a request.

Page 8: discreet mathematics

“If the moon is made of cheese,then I will be rich.”

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 8

Is this a sentence?Is this a sentence? yesyes

Is this a proposition?Is this a proposition? yesyes

What is the truth What is the truth value value

of the proposition?of the proposition?probably trueprobably true

Page 9: discreet mathematics

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

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 9

Is this a sentence?Is this a sentence? yesyes

Is this a proposition?Is this a proposition? yesyes

What is the truth What is the truth value value

of the proposition?of the proposition?truetrue

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

Page 10: discreet mathematics

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.

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 10

Page 11: discreet mathematics

We will examine the following logical operators:

• Negation (NOT, )• Conjunction (AND, )• 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.

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 11

Page 12: discreet mathematics

Unary Operator, Symbol:

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 12

PP PP

true (T)true (T) false (F)false (F)

false (F)false (F) true (T)true (T)

Page 13: discreet mathematics

Binary Operator, Symbol:

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 13

PP QQ P QP Q

TT TT TT

TT FF FF

FF TT FF

FF FF FF

Page 14: discreet mathematics

Binary Operator, Symbol:

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 14

PP QQ P P QQ

TT TT TT

TT FF TT

FF TT TT

FF FF FF

Page 15: discreet mathematics

Binary Operator, Symbol:

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 15

PP QQ PPQQ

TT TT FF

TT FF TT

FF TT TT

FF FF FF

Page 16: discreet mathematics

Binary Operator, Symbol:

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 16

PP QQ PPQQ

TT TT TT

TT FF FF

FF TT TT

FF FF TT

Page 17: discreet mathematics

Binary Operator, Symbol:

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 17

PP QQ PPQQ

TT TT TT

TT FF FF

FF TT FF

FF FF TT

Page 18: discreet mathematics

Statements and operators can be combined in any way to form new statements.

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 18

PP QQ PP QQ (P)(Q)(P)(Q)

TT TT FF FF FF

TT FF FF TT TT

FF TT TT FF TT

FF FF TT TT TT

Page 19: discreet mathematics

Statements and operators can be combined in any way to form new statements.

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 19

PP QQ PQPQ (PQ)(PQ) (P)(Q)(P)(Q)

TT TT TT FF FF

TT FF FF TT TT

FF TT FF TT TT

FF FF FF TT TT

Page 20: discreet mathematics

• To take discrete mathematics, you must have taken calculus or a course in computer science.

• When you buy a new car from Acme Motor Company, you get $2000 back in cash or a 2% car loan.

• School is closed if more than 2 feet of snow falls or if the wind chill is below -100.

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 20

Page 21: discreet mathematics

› P: take discrete mathematics

› Q: take calculus

› R: take a course in computer science

• P Q R

• Problem with proposition R

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 21

•To take discrete mathematics, you must To take discrete mathematics, you must have taken calculus or a course in have taken calculus or a course in computer science.computer science.

Page 22: discreet mathematics

› P: buy a car from Acme Motor Company

› Q: get $2000 cash back

› R: get a 2% car loan

• P Q R

• Why use XOR here? – example of ambiguity of natural languages

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 22

•When you buy a new car from Acme Motor When you buy a new car from Acme Motor Company, you get $2000 back in cash or a Company, you get $2000 back in cash or a 2% car loan.2% car loan.

Page 23: discreet mathematics

› P: School is closed

› Q: 2 feet of snow falls

› R: wind chill is below -100

• Q R P

• Precedence among operators: , , , ,

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 23

•School is closed if more than 2 feet of School is closed if more than 2 feet of snow falls or if the wind chill is below -100.snow falls or if the wind chill is below -100.

Page 24: discreet mathematics

The statements (PQ) and (P) (Q) are logically equivalent, since they have the same truth table, or put it in another way,

(PQ) (P) (Q) is always true.

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 24

PP QQ (PQ)(PQ) (P)(Q)(P)(Q) (PQ)(PQ)(P)(Q)(P)(Q)

TT TT FF FF TT

TT FF TT TT TT

FF TT TT TT TT

FF FF TT TT TT

Page 25: discreet mathematics

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.

If A has the truth value, T for at least one combination of truth values of P1, P2 , P3 ,…, Pn then A is said to be satisfiable.

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 25

Page 26: discreet mathematics

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

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 26

Page 27: discreet mathematics

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

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 27

Page 28: discreet mathematics

• Show that P Q P Q: by truth table

• Show that (P Q) (P R) P (Q R): by equivalence laws:

› Law with implication on both sides› Distribution law on LHS

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 28

Page 29: discreet mathematics

•Proposition› Statement, Truth value, › Proposition, Propositional symbol, Open proposition

•Operators › Define by truth tables› Composite propositions› Tautology and contradiction

•Equivalence of propositional statements› Definition › Proving equivalence (by truth table or equivalence

laws)

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 29

Page 30: discreet mathematics

Propositional function (open sentence):statement involving one or more variables, e.g.: x-3 > 5.Let us call this propositional function P(x), where P is the predicate and x is the variable.

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 30

What is the truth value of P(2) ?What is the truth value of P(2) ? falsefalse

What is the truth value of P(8) ?What is the truth value of P(8) ?

What is the truth value of P(9) ?What is the truth value of P(9) ?

falsefalse

truetrueWhen a variable is given a value, it is said When a variable is given a value, it is said to be instantiatedto be instantiated

Truth value depends on value of Truth value depends on value of variablevariable

Page 31: discreet mathematics

Let us consider the propositional function Q(x, y, z) defined as:

x + y = z.Here, Q is the predicate and x, y, and z are the variables.

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 31

What is the truth value of Q(2, 3, 5) What is the truth value of Q(2, 3, 5) ??

truetrue

What is the truth value of Q(0, 1, What is the truth value of Q(0, 1, 2) ?2) ?What is the truth value of Q(9, -9, 0) ?What is the truth value of Q(9, -9, 0) ?

falsefalsetruetrue

A propositional function (predicate) becomes a A propositional function (predicate) becomes a proposition when proposition when allall its variables are its variables are instantiatedinstantiated..

Page 32: discreet mathematics

Other examples of propositional functions

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

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 32

Person(Socrates) = T Person(Socrates) = T

CSCourse(x),CSCourse(x), which is true if x is a which is true if x is a computer science coursecomputer science course

CS Course(C-language) = TCS Course(C-language) = T

Person(dog) = FPerson(dog) = F

CS Course(MATH 102) = FCS Course(MATH 102) = F

Page 33: discreet mathematics

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

Universally quantified sentence:For all x in the universe of discourse P(x) is true.

Using the universal quantifier :x P(x) “for all x P(x)” or “for every x P(x)”

(Note: x P(x) is either true or false, so it is a proposition, not a propositional function.)

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 33

Page 34: discreet mathematics

Example: Let the universe of discourse be all peopleS(x): x is a Mathematics student.G(x): x is a genius.

What does x (S(x) G(x)) mean ?

“If x is a mathematics student, then x is a genius.” or“All Mathematics students are geniuses.”

If the universe of discourse is all mathematics students, then the same statement can be written as

x G(x)

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 34

Page 35: discreet mathematics

Existentially quantified sentence:There exists an x in the universe of discourse for which P(x) is true.

Using the existential quantifier :x P(x) “There is an x such that P(x).”

“There is at least one x such that P(x).”

(Note: x P(x) is either true or false, so it is a proposition, but no propositional function.)

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 35

Page 36: discreet mathematics

Example: P(x): x is a Mathematics professor.G(x): x is a genius.

What does x (P(x) G(x)) mean ?

“There is an x such that x is a Mathematics professor and x is a genius.” or“At least one Mathematics professor is a genius.”

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 36

Page 37: discreet mathematics

Another example:Let the universe of discourse be the real numbers.

What does xy (x + y = 320) mean ?

“For every x there exists a y so that x + y = 320.”

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 37

Is it true?Is it true?

Is it true for the natural Is it true for the natural numbers?numbers?

yesyes

nono

Page 38: discreet mathematics

A counterexample to x P(x) is an object c so that P(c) is false.

Statements such as x (P(x) Q(x)) can be disproved by simply providing a counterexample.

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 38

Statement: “All birds can fly.”Statement: “All birds can fly.”Disproved by counterexample: Penguin.Disproved by counterexample: Penguin.

Page 39: discreet mathematics

(x P(x)) is logically equivalent to x (P(x)).

(x P(x)) is logically equivalent to x (P(x)).

This is de Morgan’s law for quantifiers

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 39

Page 40: discreet mathematics

Examples

Not all roses are red x (Rose(x) Red(x)) x (Rose(x) Red(x))

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 40

Nobody is perfectNobody is perfect x (Person(x)x (Person(x) Perfect(x) Perfect(x)))

x (Person(x)x (Person(x) Perfect(x)Perfect(x)))

Page 41: discreet mathematics

A predicate can have more than one variables.› S(x, y, z): z is the sum of x and y› F(x, y): x and y are friends

We can quantify individual variables in different ways› x, y, z (S(x, y, z) (x <= z y <= z))› x y z (F(x, y) F(x, z) (y != z) F(y, z)

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 41

Page 42: discreet mathematics

Exercise: 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)))

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 42

Page 43: discreet mathematics

• Propositional functions (predicates)• Universal and existential quantifiers,

and the duality of the two• When predicates become propositions

› All of its variables are instantiated› All of its variables are quantified

• Nested quantifiers› Quantifiers with negation

• Logical expressions formed by predicates, operators, and quantifiers

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 43

Page 44: discreet mathematics

Mathematical Reasoning

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 44

Page 45: discreet mathematics

We need mathematical reasoning to determine whether a mathematical argument is correct or incorrect and construct mathematical arguments.

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 45

Page 46: discreet mathematics

Argument: An argument is an assertion; that a group of propositions called premises, yields an other proposition, called the conclusion.

Let P1, P2 , P3 ,…, Pn is the group of propositions that yields the conclusion Q. Then, it is denoted as P1, P2 , P3 ,…, Pn |- Q

Valid Argument: An argument is called valid

argument if the conclusion is true whenever all the premises are true orThe argument is valid iff the ANDing of the group of propositions implies conclusion is a tautologyie: P(P1, P2 , P3 ,…, Pn ) Q is a tautology

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 46

Page 47: discreet mathematics

Fallacy Argument: An argument is called fallacy or an invalid argument if it is not a valid argument.

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 47

Page 48: discreet mathematics

Translate the following into symbolic form and test the validity of the argument:

1.“ If I will select in IAS examination, then I will not be able to go to London. Since, I am going to London, I will not select in IAS examination”.

2. “If 6 is even then 2 does not divide 7. Either 5 is not prime or 2 divides 7. But 5 is prime, therefore, 6 is not even”.

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 48

Page 49: discreet mathematics

Ans-1: p: I will select in IAS examinationq: I will go to London Premises: 1. p ~q 2. q

Conclusion: ~p

Verify: [(p ~q) (q)] ~p is a tautology

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 49

Page 50: discreet mathematics

Ans-2:p: 6 is evenq: 2 divides 7r: 5 is prime

Premises: 1. p ~q 2. ~r q 3. rConclusion: ~p

Verify: [ (1) (2) (3) ] ~p is a tautology

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 50

Page 51: discreet mathematics

The problem of finding whether a given statement is tautology or contradiction or satisfiable in a finite number of steps, is called as decision problem, the construction of truth tables may not be often a practical solution. We therefore consider alternate procedure known as reduction to normal forms. The two such forms are:

Disjunctive Normal Form (DNF) Conjunctive Normal Form (CNF)

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 51

Page 52: discreet mathematics

A compound statement is said to be in dnf if it is disjunction of conjunction of the variables or their negations.

Ex:(p q r) (~p q r) (~p ~q r)

A compound statement is said to be in cnf if it is conjunction of disjunction of the variables or their negations.

Ex:(p q ~r) (p ~q r) (~p ~q r)

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 52

Page 53: discreet mathematics

The truth table for the given statement is:

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 53

P Q P Q

Q P

(P Q) (Q P)

T T T T T

T F F T F

F T T F F

F F F T T

Page 54: discreet mathematics

DNF:

DNF: (P Q) (~P ~Q)

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 54

Page 55: discreet mathematics

CNF:

CNF: ~(P ~Q) ~(~P Q) ≡ (~P Q) (P ~Q)

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 55

Page 56: discreet mathematics

• Mathematical Reasoning• Terminology (argument, valid argument

and fallacy argument)• Examples on valid arguments• Normal forms (DNF and CNF)• Truth table method to express the

statements as dnf and cnf forms

Jan-May 2013 Introduction to Mathematical Logic: MATH-105 56