You are on page 1of 36

Discrete Structures

LECTURE 3
Conditional Statements, Bit
Operations & Fuzzy Logic

Course Instructor:
1 Rida Memon
Recap

 Making Truth Tables


 Exclusive OR
 Logical Equivalence
 Tautology
 Contradiction
 Laws of Logic
 Introduction to Conditional & Bi-conditional Statements

2
Conditional Statement

 If p and q are statement variables, the conditional of q


by p is “If p then q”
or “p implies q” and is denoted p → q.

 p → q is false when p is true and q is false; otherwise it


is true.

 The arrow "→ " is the conditional operator.

 In p → q, the statement p is called the hypothesis (or


antecedent) and q is called the
conclusion (or consequent).
3
Truth Table

4
Translation Summary
of p → q

5
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 If p, then q.

 If you will attend the classes, then you will be allowed to participate in
the exams.
6
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 If p, q.

 If you will attend the classes, you will be allowed to participate in the
exams.
7
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 q, if p.

 You will be allowed to participate in the exams if you will attend the
classes.
8
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 q when p.

 You will be allowed to participate in the exams when you will attend the
classes.
9
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 q whenever p.

 You will be allowed to participate in the exams whenever you will attend
the classes.
10
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 q follows from p.

 You will be allowed to participate in the exams follows


from your attendance in the classes.
11
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 p implies q.

 You will attend the classes implies that you will be allowed to participate
in the exams.
12
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 If p, then q.

 If you will attend the classes, then you will be allowed to participate in
the exams.
13
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 p is sufficient for q.

 You will attend the classes is sufficient to allow you to participate in the
exams.
14
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 A sufficient condition for q is p.

 A sufficient condition to allow you to participate in the


exams is that you will attend the classes.
15
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 q is necessary for p.

 To allow you to participate in the exams is necessary for you to attend the
classes.
16
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 A necessary condition for p is q.

 A necessary condition to attend the classes is to allow you to participate


in the exams.
17
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 p only if q.

 You will attend the classes only if you will be allowed to participate in the
exams.
18
Translation of p → q
p: You will attend the classes.
q: You will be allowed to participate in the exams.

 q unless ~p.

 You will be allowed to participate in the exams unless you don’t attend
the classes.
19
Remarks

 In mathematical reasoning, we consider conditional


statements of a more general sort than we use in
English.

 Propositional language is an artificial language; we only


parallel English usage to make it easy to use and
remember.

 The if-then construction used in many programming


languages is different from that used in logic.

20
BICONDITIONAL STATEMENTS

 If p and q are statement variables, the biconditional of


p and q is “p if and only if q”.

 It is denoted p↔q. “if and only if” is abbreviated as iff.

 The double headed arrow " ↔" is the biconditional


operator.

21
Truth Table

 p ↔ q is true only when p and q both are true or both


are false.
 p ↔ q is false when either p or q is false.
 Just the negation of XOR.
 Translation:

22
BICONDITIONAL STATEMENT

 It is the conjunction of
p → q and q → p
i.e. (p → q) ^ (q → p)

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 T T T

23
Bit Operations

 TRUE is the same as 1.


 FALSE is the same as 0.

 If we have two bit strings


 0 1 1 0 1 1 0 1 1 0
 1 1 0 0 0 1 1 1 0 1
--------------
Then
 1 1 1 0 1 1 1 1 1 1 is bitwise OR
 0 1 0 0 0 1 0 1 0 0 is bitwise AND
 1 0 1 0 1 0 1 0 1 1 is bitwise XOR
24
Fuzzy Logic

 Fuzzy logic is used in artificial intelligence. In fuzzy logic, a


proposition has a truth value that is a number between 0 and 1,
inclusive.
 A proposition with a truth value of 0 is false and one with a
truth value of 1 is true.
 Truth values that are between 0 and 1 indicate varying degrees
of truth.
 For instance, the truth value 0.8 can be assigned to the
statement “Fred is happy,” because Fred is happy most of the
time, and the truth value 0.4 can be assigned to the statement
“John is happy,” because John is happy slightly less than half
the time.

25
Example

 The truth value 0.9 can be assigned to the statement


“Hasan visits the university.”, because Hassan has
attended 90% of classes.

 The truth value 0.4 can be assigned to the statement


“Babar visits the university.”, because Babar’s
attendance is only 40%.

26
Example 1:
 The truth value of the negation of a proposition in fuzzy
logic is 1 minus the truth value of the proposition. What are
the truth values of the statements “Fred is not happy” and
“John is not happy?”

27
Example 2:
 The truth value of the conjunction of two propositions in
fuzzy logic is the minimum of the truth values of the two
propositions. What are the truth values of the statements
“Fred and John are happy” and “Neither Fred nor John is
happy?”

For “Fred and John are happy” the truth value is min(0.8, 0.4) = 0.4.
For 'Neither Fred nor John is happy?," the truth value is min(0.2, 0.6) = 0.2

28
Example 3:
 The truth value of the disjunction of two propositions in
fuzzy logic is the maximum of the truth values of the two
propositions. What are the truth values of the statements
“Fred is happy, or John is happy” and “Fred is not happy,
or John is not happy?”

29
Thanks

 End of Lecture
 Q/A

30
Next Lecture

 Converse
 Contrapositive
 Inverse
 Simplification of Complex Propositions
 Examples

31
Practice Questions
 Chapter 1, Section 1.1
 Problems (21 – 26),(36 – 47)

32
Practice Questions

33
Practice Questions

The truth value 0.8 can be assigned to the statement


“Fred is happy,” because Fred is happy most of the
time, and the truth value 0.4 can be assigned to the
statement “John is happy,” because John is happy
slightly less than half the time. Use these truth values
to solve Exercises 45–47.

34
Reading Assignment

 Chapter 1
 Page 11 to 16

35
Thanks

 End of Lecture
 Q/A

36

You might also like