Professional Documents
Culture Documents
CS103 Slides Lecture 2 PDF
CS103 Slides Lecture 2 PDF
Propositional Logic
28
Motivation
29
Proposition
30
Proposition
• Example:
• “Today is Friday” is a proposition
• Because, its truth value is either true or false
• The truth value will be decided by the
moment/time the statement is made Proposition?
• If it is made in a Friday, then it is true • Today is Friday ✓
• If it is made in another day, then it is false • x+4 = 9
• Observe that, this example is different from the
example “x+4=9” in the previous slide
• Because, in this example, “today” is not like x. Unlike x,
“today” cannot have different values at a moment
31
Proposition
• Example:
• “Solve this problem” is not a proposition
• Because, it does not have any truth value Proposition?
• It is an order or instruction • Do this job
• It can have an outcome, such as • I did this job ✓
• the problem is solved • Don’t do this
• the problem was tried but not finished
• He did this ✓
• do nothing, just ignore the order
• etc.
• true or false is not a value of this statement
• Actually, truth value is meaningless for this
statement
32
Proposition?
Proposition • How is he?
• He is fine ✓
• Who is he?
• Example: • He is Osman ✓
• “What is your name?” is not a proposition
• Because, it is a question
• It has an answer, but it does not have a truth value
• The answer can be like this: “My name is Azad”
• True or false cannot be a value of this question
• Observe that (similarly in the previous example)
• The answer “My name is Azad” can itself be
true or false
• So, “My name is Azad” has a truth value
• But that does not give a truth value of the
original question “What is your name?”
33
Proposition
34
Compound Propositions
35
Not ()
36
Not ()
37
Not ()
38
Not ()
39
Double Negation
40
Truth Table
41
And ()
42
And ()
43
Truth Table for and ()
Truth Table for
• Example: Truth table for PQ P and Q (PQ)
• There will be three columns: P, Q, PQ
• Left side P, then Q, then PQ P Q PQ
• P and Q are given, we shall find PQ T T T
• P and Q can be T or F T F F
• So, there will be four possible combinations F T F
of P and Q: TT, TF, FT, FF
• So, four rows F F F
• PQ is true only for TT. For other cases, it is false
• The right-side picture is the truth table for PQ
• Exercise: In the truth table of P, the number of rows
was two. Here, it is four. Is there any formula here?
44
Truth Table for and ()
Truth Table for
• The operation and is commutative
and ()
• That means, PQ and QP are the same
• Sometimes, for better understanding, the variables F P FP
can be chosen close to the given statement 0 0 0
• For example, we can choose F for “Today is Friday” 0 1 0
and P for “We are going to Pray”
1 0 0
• Sometimes, T and F are written as binary digits
1 and 0, so the four combinations are 00, 01, 10, 11 1 1 1
• Usually with T and F, it starts with TT and ends to FF
• With 0 and 1, it starts with 00 and ends to 11, because
these are the four possible binary numbers by two digits
• Example: So, the truth table for and with 0 and 1 is this
45
Or ()
46
Or ()
47
Truth Table for or ()
48
Exclusive or (xor, )
49
Multiple and (), Multiple or ()
50
Multiple and (), Multiple or ()
Truth Table for
PQR and PQR
• Example: Truth table for PQR and PQR
with 0, 1 (see in the right-side table) P Q R PQR PQR
• Five columns: P, Q, R, PQR and PQR 0 0 0 0 0
• 8 rows: 000, 001, …, 111 0 0 1 0 1
• Number of rows in a truth table: 0 1 0 0 1
• If a compound statement has n variables, 0 1 1 0 1
then number of rows will be 2n 1 0 0 0 1
• Because, each variable can have two 1 0 1 0 1
values: T, F 1 1 0 0 1
• So, total possible combination for n 1 1 1 1 1
variables is: 2*2*… n times = 2n
• This is same as the number of n-bit binary numbers
51
Truth Tables for Multiple , , ,
52
Truth Tables for Multiple , , ,
53