discrete structures prepositional logic 2

58
Discrete Structures Prepositional Logic 2 Dr. Muhammad Humayoun Assistant Professor COMSATS Institute of Computer Science, Lahore. [email protected] https://sites.google.com/a/ciitlahore.edu.pk/dstruct/ Some of the material is taken from Dr. Muhammad Atif’s slides 1

Upload: vera-bray

Post on 30-Dec-2015

58 views

Category:

Documents


2 download

DESCRIPTION

Discrete Structures Prepositional Logic 2. Dr. Muhammad Humayoun Assistant Professor COMSATS Institute of Computer Science, Lahore. [email protected] https://sites.google.com/a/ciitlahore.edu.pk/dstruct/ Some of the material is taken from Dr. Muhammad Atif’s slides. Recap. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Discrete Structures Prepositional Logic 2

1

Discrete StructuresPrepositional Logic 2

Dr. Muhammad HumayounAssistant Professor

COMSATS Institute of Computer Science, [email protected]

https://sites.google.com/a/ciitlahore.edu.pk/dstruct/

Some of the material is taken from Dr. Muhammad Atif’s slides

Page 2: Discrete Structures Prepositional Logic 2

2

Recap• Truth table:

A truth table displays the relationship between the truth values of propositions. A table has rows where is number of proposition variables.

• Exclusive or: is true when exactly one of and is true and is false otherwise.

• Exercise: Draw a truth table of

Page 3: Discrete Structures Prepositional Logic 2

3

Special Definitions

Inverse:

Converse:

Contrapositive:

Page 4: Discrete Structures Prepositional Logic 2

4

ExamplePakistani team wins whenever it is rainingp: It is rainingq: Pakistani team winsq whenever p if p, then q If it is raining, then Pakistani team wins.Inverse:If it isn’t raining, then Pakistani team doesn’t win.Converse : If Pakistani team wins, then it is raining.Contrapositive: If Pakistani team doesn’t win, then it isn’t raining.

Page 5: Discrete Structures Prepositional Logic 2

5

Conditional Inverse Converse Contrapositive

Page 6: Discrete Structures Prepositional Logic 2

6

• Inverse Converse

Page 7: Discrete Structures Prepositional Logic 2

7

Biconditionals

Definition 6Let p and q be propositions. The biconditional statement p ↔ q is the proposition “p ifand 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.

Page 8: Discrete Structures Prepositional Logic 2

8

Truth Table

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

Page 9: Discrete Structures Prepositional Logic 2

9

Common ways to express p ↔ q

• “p is necessary and sufficient for q”• “if p then q, and conversely”• “p iff q”

Page 10: Discrete Structures Prepositional Logic 2

10

Example

p: “You can take the flight”q: “You buy a ticket”p ↔ q:

You can take the flight if and only if you buy a ticket

You can take the flight iff you buy a ticket

The fact that you can take the flight is necessary and sufficient for buying a ticket

Page 11: Discrete Structures Prepositional Logic 2

11

p: You can take flightq: You buy a ticket

You can take flight if and only if you buy a ticketWhat is the truth value when:• you buy a ticket and you can take the flight ??

• you don’t buy a ticket and you can’t take the flight ??

• you buy a ticket but you can’t take the flight ??

• you can’t buy a ticket but can take the flight ??

Page 12: Discrete Structures Prepositional Logic 2

12

Precedence of Logical Operators

Can be written as

(T/F) ?

¬𝑎∧𝑏 𝑎∧𝑏∧𝑐

Page 13: Discrete Structures Prepositional Logic 2

13

Exercise:For which values of a, b and c one gets 0 in the truth table of

Page 14: Discrete Structures Prepositional Logic 2

14

Logic and Bit Operations• Boolean values can be represented as 1 (true)

and 0 (false)• A bit string is a series of Boolean values. Length of

the string is the number of bits.– 10110100 is eight Boolean values in one string

• We can then do operations on these Boolean strings– Each column is its own

boolean operation

Page 15: Discrete Structures Prepositional Logic 2

15

1.2 Applications of Propositional Logic

• Translating English sentences (Formalization)• System Specifications• Boolean Searches • Logic circuits• …

Page 16: Discrete Structures Prepositional Logic 2

16

Translating English Sentences

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

You can access the Internet from campus You are a computer science major you are a freshman

Page 17: Discrete Structures Prepositional Logic 2

17

• You cannot ride the roller coaster if you are under 4 feet tall unless you are older than 16 years old.

you can ride roller coaster you are under 4 feetyou are older than 16 years old

Page 18: Discrete Structures Prepositional Logic 2

18

System Specifications

• The automated reply cannot be sent when the file system is fullp: The automated reply can be sentq: The system is full

Page 19: Discrete Structures Prepositional Logic 2

19

Consistency

• System specifications should be consistent,– They should not contain conflicting

requirements that could be used to derive a contradiction

• When specifications are not consistent, there would be no way to develop a system that satisfies all specifications

Page 20: Discrete Structures Prepositional Logic 2

20

Determine whether these system specifications are consistent:1. The diagnostic message is stored in the buffer or

it is retransmitted.2. The diagnostic message is not stored in the

buffer.3. If the diagnostic message is stored in the buffer,

then it is retransmitted.

Page 21: Discrete Structures Prepositional Logic 2

21

Determine whether these system specifications are consistent:1. The diagnostic message is stored in the buffer or

it is retransmitted.2. The diagnostic message is not stored in the

buffer.3. If the diagnostic message is stored in the buffer,

then it is retransmitted.p: The diagnostic message is stored in the buffer q: The diagnostic message is retransmitted 1. 2. 3.

Page 22: Discrete Structures Prepositional Logic 2

22

1. 2. 3. Reasoning• An assignment of truth values that makes all three

specifications true must have p false to make true.

• Because we want to be true but must be false, q must be true.

• Because is true when is false and is true• we conclude that these specifications are

consistent• Let us do it with truth table now

Page 23: Discrete Structures Prepositional Logic 2

23

• Is it remain consistent if the specification “The diagnostic message is not retransmitted” is added?p: The diagnostic message is stored in the buffer q: The diagnostic message is retransmitted

1. 2. 3.

Page 24: Discrete Structures Prepositional Logic 2

24

• Is it remain consistent if the specification “The diagnostic message is not retransmitted” is added?p: The diagnostic message is stored in the buffer q: The diagnostic message is retransmitted

1. 2. 3. 4.

Inconsistent

Page 25: Discrete Structures Prepositional Logic 2

25

Boolean Searches

• Logical connectives are used extensively in searches of large collections of information, such as indexes of Web pages.

• Because these searches employ techniques from propositional logic, they are called Boolean searches.

Page 26: Discrete Structures Prepositional Logic 2

26

• Finding Web pages about universities in New Mexico:

• New AND Mexico AND Universities – ‘New Mexico’ Universities– New Universities in Mexico

• “New Mexico” AND Universities

• (New AND Mexico OR Arizona) AND Universities– ‘New Mexico’ Universities– Arizona Universities

• (Mexico AND Universities) NOT New

Page 27: Discrete Structures Prepositional Logic 2

27

Quiz

• Let x = “لڑک”Then x + “ لڑکا” = اWrite Boolean search capturing this pattern

Page 28: Discrete Structures Prepositional Logic 2

28

Logic Puzzles

• An island has two kinds of inhabitants,– Knights, who always tell the truth– Knaves, who always lie.

• You encounter two people A and B. • What are A and B if – A says “B is a knight” – B says “The two of us are opposite types?

Page 29: Discrete Structures Prepositional Logic 2

29

– A says “B is a knight” – B says “The two of us are opposite types?

p: A is a knight : A is a knaveq: B is a knight : B is a knave

Page 30: Discrete Structures Prepositional Logic 2

30

– A says “B is a knight” – B says “The two of us are opposite types?

p: A is a knight : A is a knaveq: B is a knight : B is a knaveFirst possibility:A is a knight; that is p is true.

Page 31: Discrete Structures Prepositional Logic 2

31

– A says “B is a knight” – B says “The two of us are opposite types?

p: A is a knight : A is a knaveq: B is a knight : B is a knaveFirst possibility:A is a knight; that is p is true.• If A is a knight, then he is telling the truth when he

says that B is a knight, so that q is true, and A and B are the same type (both knight).

• But, if B is a knight, then B’s statement that A and B are of opposite types (p ∧¬ q) ∨ (¬ p ∧ q), have to be true. But it is not; because A and B are both knights. Not consistent.

• Conclusion: A is not a knight (p is false).

Page 32: Discrete Structures Prepositional Logic 2

32

– A says “B is a knight” – B says “The two of us are opposite types?

p: A is a knight : A is a knaveq: B is a knight : B is a knaveSecond possibility:A is a knave; that is p is false.• If A is a knave, then he is telling lie when he says

that B is a knight. So B is knave (q is false).• Also when B says that A and B are of opposite

types (p ∧¬ q) ∨ (¬ p ∧ q), he again lies. • Conclusion: A and B are both knaves.

Page 33: Discrete Structures Prepositional Logic 2

33

Logic Circuits

• Propositional logic can be applied to the design of computer hardware

• A logic circuit (or digital circuit) receives input signals , each a bit [either 0 (off) or 1 (on)], and produces output signals , each a bit.

Page 34: Discrete Structures Prepositional Logic 2

34

Quiz: Draw

Page 35: Discrete Structures Prepositional Logic 2

35

Quiz: Draw

Page 36: Discrete Structures Prepositional Logic 2

36

1.3 Propositional Equivalence

• An important type of step used in a mathematical argument is the replacement of a statement with another statement with the same truth value

• Propositional Equivalence is extensively used in the construction of mathematical arguments.

Page 37: Discrete Structures Prepositional Logic 2

37

Tautology and Contradiction

• A compound proposition which is always true, is called tautology. For example, , ,

• A compound proposition which is always false, is called contradiction. For example, , ,

Page 38: Discrete Structures Prepositional Logic 2

38

Example on notebook:

Page 39: Discrete Structures Prepositional Logic 2

39

Logical Equivalences

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

• The compound propositions p and q are called logically equivalent if p ↔ q is a tautology.

• The notation p ≡ q denotes that p and q are logically equivalent.

Page 40: Discrete Structures Prepositional Logic 2

40

• Show that

Page 41: Discrete Structures Prepositional Logic 2

41

Standard equivalences

Identity

Domination

Page 42: Discrete Structures Prepositional Logic 2

42

Standard equivalences

Idempotence

Double Negation

Page 43: Discrete Structures Prepositional Logic 2

43

Standard Equivalences

Commutative law:

Page 44: Discrete Structures Prepositional Logic 2

44

Standard equivalences

Associativity

Page 45: Discrete Structures Prepositional Logic 2

45

Standard equivalences• Inversion

• Negation

• Contradiction

Page 46: Discrete Structures Prepositional Logic 2

46

Distributive Law

Page 47: Discrete Structures Prepositional Logic 2

47

Page 48: Discrete Structures Prepositional Logic 2

48

De Morgan’s Law

Page 49: Discrete Structures Prepositional Logic 2

49

Generalization

De Morgan’s Laws

Page 50: Discrete Structures Prepositional Logic 2

50

Page 51: Discrete Structures Prepositional Logic 2

51

Absorption laws

Page 52: Discrete Structures Prepositional Logic 2

52

Negation laws

Page 53: Discrete Structures Prepositional Logic 2

53

Implication

Page 54: Discrete Structures Prepositional Logic 2

54

More Implication Laws

Page 55: Discrete Structures Prepositional Logic 2

55

Bi-implications

Page 56: Discrete Structures Prepositional Logic 2

56

Using Logical Equivalence

• Show that and are logically equivalent.

• Show that and are logically equivalent by developing a series of logical equivalences.

• Prove that is a tautology.

Page 57: Discrete Structures Prepositional Logic 2

57

Using Logical EquivalenceEx: Prove that is a tautology.To show that this statement is a tautology, we will use logical equivalences to demonstrate that it is logically equivalent to T

Implication equivalence 1st De Morgan law

Tautologies Idempotence

Page 58: Discrete Structures Prepositional Logic 2

58

Do Exercises