Lecture 2
Lecture 2
The Foundations:
Logic and Proofs
Propositional Logic
3. 1 + 2 = 3 (Yes)
4. 2 + 2 = 3 (No)
Propositional Logic
Consider the following sentences.
3. x + 1 = 2.
4. x + y = z.
Sentences 1 and 2 are not propositions because they are
not declarative sentences.
Sentences 3 and 4 are not propositions because they are
neither true nor false.
Sentences 3 and 4 can be turned into a proposition if we
assign values to the variables.
Propositional Logic
DEFINITION 1
Example
Find the conjunction of the propositions p and q where p is
the proposition “Today is Friday.” and q is the proposition “It
is raining today.”, and the truth value of the conjunction.
Example
“Students who have taken calculus or computer science can take
this class.” – those who take one or both classes.
exclusive or : The disjunction is true only when one of the
proposition is true.
Propositional Logic
Example
What is the disjunction of the propositions p and q where p and q
are the same propositions as in
“Rahma’s PC has more than 16 GB free hard disk space” and q is
the proposition “The processor in Rahma’s PC runs faster than 1
GHz.”
Solution
The disjunction of p and q, p ∨ q, is the proposition.
“Rahma’s PC has at least 16 GB free hard disk space, or the
processor in Rahma’s PC runs faster than 1 GHz.”
Propositional Logic
Table below displays the truth table of p ∨ q.
Truth table:
The Truth Table for the
Disjunction of Two
Propositions.
p q pνq
T T T
T F T
F T T
F F F
Propositional Logic
DEFINITION 4
Let p and q be propositions. The exclusive or of p and q,
denoted by p ⊕ q, is the proposition that is true when
exactly one of p and q is true and is false otherwise.
p q pÅ q
T T F
T F T
F T T
F F F
Propositional Logic
DEFINITION 4
Let p and q be propositions. The exclusive or of p and q,
denoted by p ⊕ q, is the proposition that is true when
exactly one of p and q is true and is false otherwise.
p q pÅ q
T T F
T F T
F T T
F F F
Propositional Logic
Conditional Statements
DEFINITION 5
The conditional statement p → q, is the proposition “if p,
then q.” The conditional statement is false when p is true
and q is false, and true otherwise. In the conditional
statement p → q, p is called the hypothesis (or antecedent or
premise) and q is called the conclusion (or consequence).
implication:
elected, lower taxes. T T |T
not elected, lower taxes. F T |T
not elected, not lower taxes. F F |T
elected, not lower taxes. T F |F
Propositional Logic
The truth table for the conditional statement p → q is shown in
Table given below.
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.
Implication:
If you buy a ticket you can take the flight.
If you don’t buy a ticket you cannot take the flight.
Propositional Logic
Truth Tables of Compound Propositions
Example:
Construct the truth table of the compound proposition
(p ν ¬q) → (p Λ q).
DEFINITION 7
A bit string is a sequence of zero or more bits. The length of
this string is the number of bits in the string.
Example
101010011 is a bit string of length nine.
We can extend bit operations to bit strings. We define the bitwise OR, bitwise
AND, and bitwise XOR of two strings of the same length to be the strings that
have as their bits the OR, AND, and XOR of the corresponding bits in the two
strings, respectively. We use the symbols ∨, ∧, and ⊕ to represent it,
respectively.
Propositional Logic
Example
Find the bitwise OR, bitwise AND, and bitwise XOR of the bit
strings 0110110110 and 11 0001 1101.
(note: bit strings will be split into blocks of four bits to make them
easier to read)
Solution: The bitwise OR, bitwise AND, and bitwise XOR of these strings are
obtained by taking the OR, AND, and XOR of the corresponding bits, respectively.
This gives:
0 1 1 0 1 1 0 1 1 0
1 1 0 0 0 1 1 1 0 1
1 1 1 0 1 1 1 1 1 1 bitwise OR
0 1 0 0 0 1 0 1 0 0 bitwise AND
1 0 1 0 1 0 1 0 1 1 bitwise XOR
Propositional Logic
Example
Construct truth tables for the following
(p ∧ q) ∨ ¬ p
T T T T T T T T
T T F F T F F T
T F T F F F F T
T F F F F F F T
F T T T F F F T
F T F F F F F T
F F T F F F F T
F F F F F F F T