Lec 1
Lec 1
Maria Tamoor
Agenda
Course policies
Logic
Lecture 1 2
Course Policies, Schedule,
Syllabus
Quizzes can be online or on
campus There is no such thing as
make-up quiz/test or make-up
exam.
There will be one extra quiz
Late assignments will be graded
after 50% deduction. Students are
encouraged to submit assignments
before time.
Lecture 1 3
Tentative Grading criteria
Quizzes/Tests 20%
Assignments 10%
Mid Term 30%
Final Examination 40%
Lecture 1 4
Textbook
Lecture 1 8
False, True, Statements
Axiom: False is the opposite to Truth.
A statement is a description of
something.
Examples of statements:
I have -17 students in dm class.
You always tell the truth.
Q’s: Which statements are True? False?
Both? Neither?
Lecture 1 9
False, True, Statements
True: I live in Lahore.
False: We live on MARS
Lecture 1 10
Propositions
To avoid painful head-aches, we ban
silly non-sense and avoid the most
general type of statements limiting
ourselves to statements with valid
truth-values instead:
DEF: A proposition is a statement
that is true or false.
Lecture 1 11
Propositions
Propositional Logic is a static discipline of
statements which lack semantic
content.
E.G. p = “Clinton was the president.”
q = “The list of U.S. presidents
includes
Clinton.”
r = “Lions like to sleep.”
All p and q are no more closely related
than q and r are, in propositional
calculus. They are both equally related
as all three statements are true.
Lecture 1 12
Semantically, however, p and q are the
Propositions
So why waste time on such matters?
Propositional logic is the study of how
simple propositions can come together
to make more complicated propositions.
If the simple propositions get some
meaning then the complicated
proposition would have meaning as
well, and then finding out the truth
value is actually important!
Lecture 1 13
Compound Propositions
In Propositional Logic, we assume a
collection of atomic propositions
are given: p, q, r, s, t, ….
Then we form compound
propositions by using logical
connectives (logical operators)
to form propositional “molecules”.
Lecture 1 14
Examples of proposition
Propositions??
Lecture 1 20
Conjunction
Conjunction is a binary operator in
that it operates on two
propositions when creating
compound proposition. On the
other hand, negation is a unary
operator.
Lecture 1 21
Conjunction
Conjunction is supposed to
encapsulate what happens when
we use the word “and” in English.
I.e., for “p and q ” to be true, it
must be the case that BOTH p is
true, as well as q. If one of these is
false, than the compound
statement is false as well.
Lecture 1 22
Conjunction
EG. p = “Clinton was the president.”
q = “Monica was the president.”
r = “The meaning of is is important.”
Assuming p and r are true, while q false.
Out of pq, pr, qr
which are true??
only pr is true.
Java: x==3 && x!=3
T or F ??
Evaluates to false for any possible value of23
Lecture 1
Conjunction – truth table
p q p q
T T T
T F F
F T F
F F F
Lecture 1 24
Disjunction – truth table
Conversely, disjunction is true when
at least one of the components is
true:
p q p q
T T T
T F T
F T T
F F F
Lecture 1 25
Disjunction
Note: English version of disjunction
“or” does not always satisfy the
assumption that one of p/q being
true implies that “p or q ” is true.
Q: Can someone come up with an
example?
Lecture 1 26
Disjunction
A: guests are served with soup or
salad.
Most restaurants definitely don’t
allow you to get both soup and
salad so that the statement is false
when both soup and salad is
served.
To address this situation, exclusive-
or is introduced next.
Lecture 1 27
Exclusive-Or – truth table
p q p q
T T F
T F T
F T T
F F F
Lecture 1 30
Lecture 1 31
Lecture 1 32
Conditional (Implication)
This one is probably the least
intuitive. It’s like English usage of
“if,then” or “implies”.
DEF: p q is true if q is true, or if p
is false. In the final case (p is true
while q is false) p q is false.
Semantics: “p implies q ” is true if
one can mathematically derive q
from p.
Lecture 1 33
Conditional -- truth table
p q p q
T T T
T F F
F T T
F F T
Lecture 1 35
Examples of Implications
“If this lecture ever ends, then the
sun will rise tomorrow.” True or
False?
“If Tuesday is a day of the week,
then you are a penguin.” True or
False?
. “If 1+1=6, then Obama is still
president.” True or False?
“If the moon is made of green
Lecture 1 36
Examples of Implications
“If this lecture ever ends, then the
sun will rise tomorrow.” True or
False?
“If Tuesday is a day of the week,
then you are a penguin.” True or
False?
. “If 1+1=6, then Obama is still
president.” True or False?
“If the moon is made of green
Lecture 1 37
Lecture 1 38
Converse, Inverse,
Contrapositive
contrapositive
Lecture 1 39
Examples
If today is Thursday, then I have a
test today.
Converse:
If I have a test today , then today
is Thursday. q
Contrapositive:
If I don’t have a test today then
today is not Thursday.
Inverse: If today is not Thursday,
then
Lecture 1 I don’t have a test today 40
Bi-Conditional -- truth
table
For p q to be true, p and q must have
the same truth value. Else, p q is false:
p q pq
T T T
T F F
F T F
F F T
42
. The contrapositive of “If you get
100% in this course, you will get
an A+” is
“If you do not get an A+ in this
course, you did not get 100%”.
Lecture 1 43
Bi-Conditional
A: has exactly the opposite truth table
as .
Lecture 1 44
Bi-Conditional
The biconditional p ↔ q states that p
is true if and only if (IFF) q is true.
p = “You get full score in all exams
and all homework.”
q = “You get an A+ in ICS 141.”
p ↔ q = “If, and only if, you get full
score in all exams and all
homework, you get an A+ in Comp
113.”
Lecture 1 45
Bit Strings
Electronic computers achieve their
calculations inside semiconducting
materials. For reliability, only two
stable voltage states are used and so
the most fundamental operations are
carried out by switching voltages
between these two stable states.
In logic, only two truth values are allowed.
Thus propositional logic is ideal for
modeling computers. High voltage
values are modeled by True, which for
brevity we call the number 1, while low
voltage
Lecture 1 values are modeled by False or 46
Bit Strings
Thus voltage memory stored in a
computer can be represented by a
sequence of 0’s and 1’s such as
01 1011 0010 1001
Another portion of the memory might look
like
10 0010 1111 1001
Each of the number in the sequence is
called a bit, and the whole sequence of
bits is called a bit string.
Lecture 1 47
Bit Strings
It turns out that the analogs of the logical
operations can be carried out quite
easily inside the computer, one bit at a
time. This can then be transferred to
whole bit strings. For example, the
exclusive-or of the previous bit strings
is:
01 1011 0010 1001
10 0010 1111 1001
11 1001 1101 0000
Lecture 1 48
Bitwise operations
E.g.:
01 1011 0110
11 0001 1101
11 1011 1111 Bit-wise OR
01 0001 0100 Bit-wise AND
10 1010 1011 Bit-wise XOR
Lecture 1 49
Exercises
q = “You miss the final exam.”
r = “You pass the course.”
Express q r in English.
1. Construct a truth table for p q.
2. Can one determine relative salaries of
F (Fannie), J (Janice) and M (Maggie)
from the following?
1. If F is not highest paid, then J is.
2. If J is not lowest paid, then M is highest
paid.
Lecture 1 50
Exercise question
Q 3,4,5,9,21,24,25 of section 1.1
Lecture 1 51