Presentation is loading. Please wait.

Presentation is loading. Please wait.

Discrete Structures Prepositional Logic 2

Similar presentations


Presentation on theme: "Discrete Structures Prepositional Logic 2"โ€” Presentation transcript:

1 Discrete Structures Prepositional Logic 2
Dr. Muhammad Humayoun Assistant Professor COMSATS Institute of Computer Science, Lahore. Some of the material is taken from Dr. Muhammad Atifโ€™s slides

2 Recap Truth table: A truth table displays the relationship between the truth values of propositions. A table has 2 ๐‘› 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 (๐‘โŠ•๐‘ž)โˆจ(๐‘โ‡’๐‘ž)

3 Special Definitions ๐’‘โ†’๐’’ Inverse:ยฌ๐’‘โ†’ยฌ๐’’ Converse: ๐’’โ†’๐’‘
Contrapositive: ยฌ๐’’โ†’ยฌ๐’‘

4 Example Pakistani team wins whenever it is raining p: It is raining q: Pakistani team wins q 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.

5 ๐‘ ๐‘ž ๏ƒ˜๐‘ ๏ƒ˜๐‘ž ๐‘ ๏‚ฎ ๐‘ž ๏ƒ˜๐‘ ๏‚ฎ ๏ƒ˜๐‘ž ๐‘ž ๏‚ฎ ๐‘ ๏ƒ˜๐‘ž ๏‚ฎ ๏ƒ˜๐‘ ๐‘‡ ๐น Conditional Inverse Converse
Contrapositive ๐‘ ๐‘ž ๏ƒ˜๐‘ ๏ƒ˜๐‘ž ๐‘ ๏‚ฎ ๐‘ž ๏ƒ˜๐‘ ๏‚ฎ ๏ƒ˜๐‘ž ๐‘ž ๏‚ฎ ๐‘ ๏ƒ˜๐‘ž ๏‚ฎ ๏ƒ˜๐‘ ๐‘‡ ๐น

6 Conditional โ‰กContrapositive
๐‘โ†’๐‘ž โ‰กยฌ๐‘žโ†’ยฌ๐‘ Inverse โ‰ก Converse ยฌ๐‘โ†’ยฌ๐‘ž โ‰ก๐‘žโ†’๐‘

7 Biconditionals Definition 6 Let p and q be propositions. The biconditional statement p โ†” q is the proposition โ€œp if and 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.

8 Truth Table p โ†” q has exactly the same truth value as
(p โ†’ q) โˆง (q โ†’ p)

9 Common ways to express p โ†” q
โ€œp is necessary and sufficient for qโ€ โ€œif p then q, and converselyโ€ โ€œp iff qโ€

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

11 You can take flight if and only if you buy a ticket
p: You can take flight q: You buy a ticket ๐‘โ†”๐‘ž You can take flight if and only if you buy a ticket What 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 ?? ๐นโ†”๐‘‡โ‰ก๐น

12 Precedence of Logical Operators
(๐‘โŠ•๐‘ž)โˆจ(๐‘โ‡’๐‘ž) Can be written as (๐‘โŠ•๐‘ž)โˆจ๐‘โ‡’๐‘ž (T/F) ? ยฌ๐‘Žโˆง๐‘ ๐‘Žโˆจ๐‘โ‡”๐‘โˆจ๐‘Ž ๐‘Žโˆง๐‘โˆจ๐‘ ๐‘Žโˆง๐‘โˆง๐‘ ๐‘Žโˆจ๐‘โˆจ๐‘

13 Exercise: For which values of a, b and c one gets 0 in the truth table of ๐‘Žโˆง ๐‘โ‡’๐‘ โ‡’( ๐‘โ‡’๐‘Ž โˆง๐‘)

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. is eight Boolean values in one string We can then do operations on these Boolean strings Each column is its own boolean operation

15 1.2 Applications of Propositional Logic
Translating English sentences (Formalization) System Specifications Boolean Searches Logic circuits โ€ฆ

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 ๐’‚โ†’ (๐’„โˆจยฌ๐’‡)

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 feet ๐‘œ : you are older than 16 years old ๐‘“โˆงยฌ๐‘œ โ†’ยฌ๐‘Ÿ

18 System Specifications
The automated reply cannot be sent when the file system is full p: The automated reply can be sent q: The system is full ๐‘ž โŸถยฌ๐‘

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

20 Determine whether these system specifications are consistent:
The diagnostic message is stored in the buffer or it is retransmitted. The diagnostic message is not stored in the buffer. If the diagnostic message is stored in the buffer, then it is retransmitted.

21 Determine whether these system specifications are consistent:
The diagnostic message is stored in the buffer or it is retransmitted. The diagnostic message is not stored in the buffer. 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. ๐’‘โˆจ๐’’ ยฌ๐’‘ ๐’‘โ†’๐’’

22 1. ๐’‘โˆจ๐’’ ยฌ๐’‘ ๐’‘โ†’๐’’ 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

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. ๐’‘โˆจ๐’’ ยฌ๐’‘ ๐’‘โ†’๐’’

24 Inconsistent 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. ๐’‘โˆจ๐’’ ยฌ๐’‘ ๐’‘โ†’๐’’ 4. ยฌ๐’’ Inconsistent

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.

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 Arizona Universities (Mexico AND Universities) NOT New

27 Quiz Let x = โ€œู„ฺ‘ฺฉโ€ Then x + โ€œุงโ€ = ู„ฺ‘ฺฉุง
Write Boolean search capturing this pattern

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?

29 p: A is a knight ยฌ๐‘: A is a knave q: B is a knight ยฌ๐‘ž: B is a knave
A says โ€œB is a knightโ€ B says โ€œThe two of us are opposite types? p: A is a knight ยฌ๐‘: A is a knave q: B is a knight ยฌ๐‘ž: B is a knave

30 p: A is a knight ยฌ๐‘: A is a knave q: B is a knight ยฌ๐‘ž: B is a knave
A says โ€œB is a knightโ€ B says โ€œThe two of us are opposite types? p: A is a knight ยฌ๐‘: A is a knave q: B is a knight ยฌ๐‘ž: B is a knave First possibility: A is a knight; that is p is true.

31 p: A is a knight ยฌ๐‘: A is a knave q: B is a knight ยฌ๐‘ž: B is a knave
A says โ€œB is a knightโ€ B says โ€œThe two of us are opposite types? p: A is a knight ยฌ๐‘: A is a knave q: B is a knight ยฌ๐‘ž: B is a knave First 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).

32 p: A is a knight ยฌ๐‘: A is a knave q: B is a knight ยฌ๐‘ž: B is a knave
A says โ€œB is a knightโ€ B says โ€œThe two of us are opposite types? p: A is a knight ยฌ๐‘: A is a knave q: B is a knight ยฌ๐‘ž: B is a knave Second 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.

33 Logic Circuits Propositional logic can be applied to the design of computer hardware A logic circuit (or digital circuit) receives input signals ๐‘ 1 , ๐‘ 2 , , ๐‘ ๐‘› , each a bit [either 0 (off) or 1 (on)], and produces output signals ๐‘  1 , ๐‘  2 , , ๐‘  ๐‘› , each a bit.

34 Quiz: Draw ๐’‘โˆงยฌ๐’’ โˆจยฌ๐’“

35 Quiz: Draw ๐’‘โˆงยฌ๐’’ โˆจยฌ๐’“

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.

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, ยฌ๐‘โˆง๐‘, ยฌ(๐‘Žโ‡’๐‘Ž), ๐‘Žโˆง๐‘ โˆงยฌ๐‘Ž

38 Example on notebook: ๐‘Žโ‡’(๐‘โ‡’๐‘Ž) ๐‘Žโ‡’๐‘Ž

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.

40 Show that ยฌ ๐‘โˆจ๐‘ž โ‰กยฌ๐‘โˆงยฌ๐‘ž

41 Standard equivalences
Identity ๐‘ โˆง ๐‘ป โ‰ก ๐‘ ๐‘ โˆจ ๐‘ญ โ‰ก ๐‘ Domination ๐‘ โˆจ ๐‘ป โ‰ก ๐‘ป ๐‘ โˆง ๐‘ญ โ‰ก ๐‘ญ

42 Standard equivalences
Idempotence ๐‘โˆง๐‘โ‰ก๐‘ ๐‘โˆจ๐‘โ‰ก๐‘ Double Negation ยฌยฌ๐‘โ‰ก๐‘

43 Standard Equivalences
Commutative law: ๐‘โˆง๐‘žโ‰ก๐‘žโˆง๐‘ ๐‘โˆจ๐‘žโ‰ก๐‘žโˆจ๐‘ ๐‘โ‡”๐‘žโ‰ก๐‘žโ‡”๐‘

44 Standard equivalences
Associativity ๐‘โˆง๐‘ž โˆง๐‘Ÿโ‰ก๐‘โˆง ๐‘žโˆง๐‘Ÿ ๐‘โˆจ๐‘ž โˆจ๐‘Ÿโ‰ก๐‘โˆจ ๐‘žโˆจ๐‘Ÿ ๐‘โ‡”๐‘ž โ‡”๐‘Ÿโ‰ก๐‘โ‡”(๐‘žโ‡”๐‘Ÿ)

45 Standard equivalences
Inversion ยฌ๐‘‡โ‰ก๐น ยฌ๐นโ‰ก๐‘‡ Negation ยฌ๐‘ โ‰ก (๐‘โ‡’๐น) Contradiction ๐‘โˆงยฌ๐‘ โ‰ก ๐น

46 Distributive Law ๐‘โˆง ๐‘žโˆจ๐‘Ÿ โ‰ก ๐‘โˆง๐‘ž โˆจ ๐‘โˆง๐‘Ÿ ๐‘โˆจ ๐‘žโˆง๐‘Ÿ โ‰ก ๐‘โˆจ๐‘ž โˆง ๐‘โˆจ๐‘Ÿ

47

48 ยฌ ๐‘โˆง๐‘ž โ‰กยฌ๐‘โˆจยฌ๐‘ž ยฌ ๐‘โˆจ๐‘ž โ‰กยฌ๐‘โˆงยฌ๐‘ž De Morganโ€™s Law
ยฌ( ๐‘ 1 โˆง ๐‘ 2 โˆง ยท ยท ยท โˆง ๐‘ ๐‘› ) โ‰ก (ยฌ ๐‘ 1 โˆจยฌ ๐‘ 2 โˆจ ยทยทยท โˆจยฌ ๐‘ ๐‘› ) ยฌ ๐‘โˆจ๐‘ž โ‰กยฌ๐‘โˆงยฌ๐‘ž ยฌ ( ๐‘ 1 โˆจ ๐‘ 2 โˆจ ยท ยท ยท โˆจ ๐‘ ๐‘› )โ‰ก (ยฌ ๐‘ 1 โˆงยฌ ๐‘ 2 โˆง ยทยทยท โˆง ยฌ๐‘ ๐‘› )

49 Generalization De Morganโ€™s Laws ยฌ ๐‘–=1 ๐‘› ๐‘ ๐‘– โ‰ก ๐‘–=1 ๐‘› ยฌ ๐‘ ๐‘–
๐‘–=1 ๐‘› ๐‘ ๐‘– ๐‘๐‘Ž๐‘› ๐‘๐‘’ ๐‘ข๐‘ ๐‘’๐‘‘ ๐‘“๐‘œ๐‘Ÿ ๐‘ 1 โˆง ๐‘ 2 โˆงโ€ฆโˆง ๐‘ ๐‘› ๐‘–=1 ๐‘› ๐‘ ๐‘– ๐‘๐‘Ž๐‘› ๐‘๐‘’ ๐‘ข๐‘ ๐‘’๐‘‘ ๐‘“๐‘œ๐‘Ÿ ๐‘ 1 โˆจ ๐‘ 2 โˆจโ€ฆโˆจ ๐‘ ๐‘› De Morganโ€™s Laws ยฌ ๐‘–=1 ๐‘› ๐‘ ๐‘– โ‰ก ๐‘–=1 ๐‘› ยฌ ๐‘ ๐‘– ยฌ( ๐‘–=1 ๐‘› ๐‘ ๐‘– ) โ‰ก ๐‘–=1 ๐‘› ยฌ๐‘ ๐‘–

50

51 Absorption laws ๐‘ โˆจ (๐‘ โˆง ๐‘ž) โ‰ก ๐‘ ๐‘ โˆง ๐‘ โˆจ ๐‘ž โ‰ก ๐‘

52 Negation laws ๐‘ โˆจ๏ฟข๐‘ โ‰ก ๐‘ป ๐‘ โˆง๏ฟข๐‘ โ‰ก ๐‘ญ

53 Implication ๐‘โ‡’๐‘žโ‰กยฌ๐‘โˆจ๐‘ž ๐‘โˆจ๐‘žโ‰กยฌ๐‘โ‡’๐‘ž

54 More Implication Laws ๐‘ โ†’ ๐‘ž โ‰ก ๏ฟข๐‘ž โ†’๏ฟข๐‘ ๐‘ โˆง ๐‘ž โ‰ก ๏ฟข(๐‘ โ†’๏ฟข๐‘ž) ยฌ(๐‘ โ†’ ๐‘ž) โ‰ก ๐‘ โˆง๏ฟข๐‘ž
(๐‘ โ†’ ๐‘ž) โˆง (๐‘ โ†’ ๐‘Ÿ) โ‰ก ๐‘ โ†’ (๐‘ž โˆง ๐‘Ÿ) (๐‘ โ†’ ๐‘Ÿ) โˆง (๐‘ž โ†’ ๐‘Ÿ) โ‰ก (๐‘ โˆจ ๐‘ž) โ†’ ๐‘Ÿ (๐‘ โ†’ ๐‘ž) โˆจ (๐‘ โ†’ ๐‘Ÿ) โ‰ก ๐‘ โ†’ (๐‘ž โˆจ ๐‘Ÿ) (๐‘ โ†’ ๐‘Ÿ) โˆจ (๐‘ž โ†’ ๐‘Ÿ) โ‰ก (๐‘ โˆง ๐‘ž) โ†’ ๐‘Ÿ

55 Bi-implications ๐‘ โ†” ๐‘ž โ‰ก (๐‘ โ†’ ๐‘ž) โˆง (๐‘ž โ†’ ๐‘) ๐‘ โ†” ๐‘ž โ‰ก ๏ฟข๐‘ โ†”๏ฟข๐‘ž
๐‘ โ†” ๐‘ž โ‰ก (๐‘ โˆง ๐‘ž) โˆจ (๏ฟข๐‘ โˆง๏ฟข๐‘ž) ๏ฟข(๐‘ โ†” ๐‘ž) โ‰ก ๐‘ โ†”๏ฟข๐‘ž

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.

57 Using Logical Equivalence
Ex: 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 โ‰กยฌ๐‘โˆจ(ยฌ๐‘žโˆจ ๐‘ โˆจ ๐‘ž ) Associative law โ‰กยฌ๐‘โˆจ(๐‘โˆจ ยฌq โˆจ ๐‘ž ) Commutative law โ‰ก(ยฌ๐‘โˆจ๐‘)โˆจ ยฌq โˆจ ๐‘ž Associative law โ‰ก๐‘‡โˆจ๐‘‡ Tautologies โ‰ก๐‘‡ Idempotence

58 Do Exercises


Download ppt "Discrete Structures Prepositional Logic 2"

Similar presentations


Ads by Google