The Foundations: Logic and Proofs: Chapter 1, Part I: Propositional Logic
The Foundations: Logic and Proofs: Chapter 1, Part I: Propositional Logic
The Foundations: Logic and Proofs: Chapter 1, Part I: Propositional Logic
my
Chapter Summary
Propositional Logic
The Language of Propositions
Applications
Logical Equivalences
Predicate Logic
The Language of Quantifiers
Logical Equivalences
Nested Quantifiers
Proofs
Rules of Inference
Proof Methods
Proof Strategy
http://fskik.upsi.edu.my
Propositional Logic
Section 1.1
http://fskik.upsi.edu.my
Section Summary
Propositions
Connectives
Negation
Conjunction
Disjunction
Implication; contrapositive, inverse, converse
Biconditional
Truth Tables
http://fskik.upsi.edu.my
Computer science:
to design computer circuits.
to construct computer programs.
to verify the correctness of programs.
http://fskik.upsi.edu.my
Logic
Logic is a study of reasoning.
Logic examines general forms which arguments
may take, which forms are valid, and which are
fallacies.
Axiomatic concepts in math:
Equals
Opposite
Truth and falsehood
Statement
Objects
Collections
http://fskik.upsi.edu.my
Logic
We intuitively know that Truth and Falsehood are
opposites. That statements describe the world
and can be true/false. That the world is made
up of objects and that objects can be organized
to form collections.
Propositions
To avoid painful head-aches, we ban such silly
non-sense and avoid the most general type of
statements limiting ourselves to statements
with valid truth-values instead.
Propositions
Basic building blocks of logic.
Propositions a statement / declarative
sentence (sentence that declares a fact) which is
either TRUE or FALSE, but not BOTH. It may also
change according to certain circumstances (ex:
Today is Friday).
Atomic proposition a statement with none
values (statements without first having to
determine the truth or falsity of other
propositions)
http://fskik.upsi.edu.my
Propositions
Examples of propositions:
a) The Moon is made of green cheese.
b) Trenton is the capital of New Jersey.
c) Melaka is the capital of Malaysia.
d) 1+0=1
e) 0+0=2
Examples that are not propositions.
a) Sit down!
b) What time is it?
c) x+1=2
d) x+y=z
http://fskik.upsi.edu.my
Propositions
The value of a proposition is called TRUTH VALUE
(T/1, F/O).
p q p q
p p 1 1 T T
1 T 1 0 T F
or 0 1
or F T
0 F
0 0 F F
Propositions - Opinions
Opinions:
http://fskik.upsi.edu.my
Propositions Examples
Examples:
1. 2 + 3 = 5.
2. 4 * 4 = 8.
3. Perak is the capital of Malaysia.
4. There are 12 months a year.
http://fskik.upsi.edu.my
Propositions Examples
Answers:
1. 2 + 3 = 5. (True)
2. 4 * 4 = 8. (False)
3. Perak is the capital of Malaysia. (False)
4. There are 12 months a year. (True)
http://fskik.upsi.edu.my
Propositions Exercise 1
Consider the following sentences:
Propositions Exercise 1
Consider the following sentences:
Propositions Exercise 1
Answers:
Questions 1 3
Not propositions because it is not a declarative sentences. It is a question.
Questions 4 6
Not propositions because it is not a declarative sentences. It is an order.
Question 7
Not propositions because it is not a declarative sentences. It is a statement
(either True, False, or Both).
Questions 8 9
Not propositions because it is neither True or False. No initial value for x, y
and z.
http://fskik.upsi.edu.my
Propositions Exercise 2
Friday is the day after Thursday.
It is raining.
The grass is green.
The sun orbits the earth.
Please close the windows.
I am happy.
10 < 15.
x + 7 = 10 where x = 3.
http://fskik.upsi.edu.my
Propositional Logic/Variables
(Statement Variables)
Variables that represent atomic propositions such
as p, q, r, s, .
Propositional Logic/Variables
(Statement Variables)
Propositional logic (propositional calculas) is a static
discipline of statements which lack semantic content.
the study of how simple propositions can come
together to make more complicated propositions.
Propositional Logic/Variables
(Statement Variables)
Constructing Propositions
Propositional Variables: p, q, r, s,
The proposition that is always true is denoted by T and
the proposition that is always false is denoted by F.
Compound Propositions; constructed from logical
connectives and other propositions
Negation
Conjunction
Disjunction
Implication
Biconditional
Exclusive OR
http://fskik.upsi.edu.my
Logical Connectives/Operators
Connectives or operators are used to create a
compound proposition from two or more other
propositions.
Negation.
Conjunction/logical conjunction/and.
Disjunction/logical disjunction/or.
Exclusive or/XOR.
Implication/imply.
Biconditional.
http://fskik.upsi.edu.my
Logical Connectives/Operators
Operator Symbol Usage
Negation not
Conjunction and
Disjunction or
Exclusive or xor
Conditional if,then
Biconditional iff
http://fskik.upsi.edu.my
Example
Example 1:
Compound Propositions
Compound propositions
Example:
p = 23 = 15 +7
p p
T F
F T
p p p p
1 0 T F
0 1 or F T
http://fskik.upsi.edu.my
p = Today is Monday.
Find p.
Conjunction
Conjunction is a binary operator in that it operates on two
propositions when creating compound proposition.
Conjunction
For p and q to be true, it must be the case
that BOTH p is true, as well as q.
Conjunction
Example:
Conjunction
The conjunction of propositions p and q is
denoted by p q and has this truth table:
p q pq
T T T
T F F
F T F
F F F
Conjunction
p q pq p q pq
1 1 1 T T T
1 0 0 T F F
0 1 0 F T F
0 0 0 F F F
http://fskik.upsi.edu.my
Conjunction - Exercise
Exercise:
p = Today is Monday.
q = Tomorrow is Friday.
r = 3 + 5 = 8
Disjunction
Conversely, disjunction is true when at least one
of the components is true.
The disjunction of propositions p and q is
denoted by p q.
Example: If p denotes I am at home. and q
denotes It is raining. then p q denotes I am
at home or it is raining.
http://fskik.upsi.edu.my
Disjunction
p q pq p Q pq
1 1 1 T T T
1 0 1 T F T
0 1 1 F T T
0 0 0 F F F
http://fskik.upsi.edu.my
Disjunction - Example
Example:
Students who have taken discrete or computer
science can take this class.
- Take both (T T = T).
- Take discrete (T F = T).
- Take computer science (F T = T).
- Not taken (F F = F).
http://fskik.upsi.edu.my
Disjunction - Exercise
Find the conjunction of the propositions p and
q where p is proposition Rebeccas PC has
more than 16 GB free hard disk space and q
is proposition The processor in Rebeccas PC
runs faster than 1 GHz.
http://fskik.upsi.edu.my
p q p q
T T T
T F T
F T T
F F F
http://fskik.upsi.edu.my
Disjunction : Caveat
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.
Disjunction : Caveat
A: The entre is served with
soup or salad.
Exclusive Or (XOR)
XOR of two propositions is true when exactly
one of its propositions is true and the other one
is false.
Example:
Exclusive Or (XOR)
p q P q p q P q
1 1 0 T T F
1 0 1 T F T
0 1 1 F T T
0 0 0 F F F
Note:
In this course any usage of or will connote the
logical operator as opposed to the exclusive-or.
http://fskik.upsi.edu.my
Conditional (Implication)
The proposition that is false when p is true and
q is false and true otherwise.
p = hypothesis/antecedent/premise
q = conclusion/ consequence.
Conditional (Implication)
This one is probably the least intuitive. Its only
partly akin to the English usage of if,then or
implies.
Semantics: p implies q is true if one can
mathematically derive q from p.
Example:
1. If it rains, the grass gets wet.
2. If the sprinklers operate, the grass gets wet.
3. If you buy your air ticket in advance, then it is
cheaper.
http://fskik.upsi.edu.my
Conditional (Implication)
In p q there does not need to be any connection between the
antecedent or the consequent. The meaning of p q depends
only on the truth values of p and q.
These implications are perfectly fine, but would not
be used in ordinary English.
If the moon is made of green cheese, then I have more
money than Bill Gates.
If the moon is made of green cheese then Im on welfare.
If 1 + 1 = 3, then your grandma wears combat boots.
http://fskik.upsi.edu.my
Conditional (Implication)
The implication p q can be equivalently read
as:
if p then q
p implies q
if p, q
p only if q
q if p
q when p
http://fskik.upsi.edu.my
Conditional (Implication)
The implication p q can be equivalently read
as:
q whenever p
p is a sufficient condition for q
q is a necessary condition for p
q follows from p
http://fskik.upsi.edu.my
if p, then q p implies q
if p, q p only if q
q unless p q when p
q if p q when p
q whenever p p is sufficient for q
q follows from p q is necessary for p
Conditional (Implication)
Some of the ways reverse the order of p and q
but have the same connotation:
Conditional (Implication)
p q P q p q P q
T T T
1 1 1
1 0 0 T F F
0 1 1 F T T
0 0 1 F F T
http://fskik.upsi.edu.my
Conditional (Implication)
Example 1:
Conditional (Implication)
Example 2:
Conditional (Implication)
One way to view the logical conditional is to think of an
obligation or contract.
If I am elected, then I will lower taxes.
If you get 100% on the final, then you will get an A.
Conditional (Implication)
Exercise:
3. If sin x = 0, then x = 0.
http://fskik.upsi.edu.my
Conditional (Implication)
Answers:
Question 1 2:
Conditional (Implication)
Answers:
Question 3:
Why F F is True?
Remember, all of these are mathematical
constructs, not attempts to mimic English.
Mathematically, p should imply q whenever it is
possible to derive q by from p by using valid
arguments.
For example consider the mathematical analog
of no. 4:
If 0 = 1 then 3 = 9.
Q: Is this true mathematically?
http://fskik.upsi.edu.my
Why F F is True?
A: YES mathematically and YES by the truth table.
Why F F is True?
A: YES mathematically and YES by the truth table.
Why F F is True?
As we want the conditional to make sense in
the semantic context of mathematics, we
better define it as we have!
Biconditional
If p and q are propositions, then we can form the biconditional
proposition p q , read as p if and only if q . The biconditional
p q denotes the proposition with this truth table:
p q p q
T T T
T F F
F T F
F F T
Biconditional
For p q to be true, p and q must have
the same truth value.
Else, p q is false:
p q P q p q P q
1 1 1 T T T
1 0 0 T F F
0 1 0 F T F
0 0 1 F F T
http://fskik.upsi.edu.my
p q pq q p P q
1 1 1 1 1
1 0 0 1 0
0 1 1 0 0
0 0 1 1 1
http://fskik.upsi.edu.my
Biconditional
Some common or alternative ways p if and
only if q is expressed in English:
p if and only if q
p is necessary and sufficient for q
if p then q, and conversely
p iff q
http://fskik.upsi.edu.my
Biconditional
Example:
Biconditional
Examples:
Biconditional
Exercises:
3. x 0 if and only if x 0.
http://fskik.upsi.edu.my
Biconditional
Answers:
Questions 1 -2
True: Both implications hold.
Question 3
False: The converse holds. That is if x 0
then x 0. However the implication is
false; consider x = -1. Then the hypothesis
is true, 1 0 but the conclusion fails.
http://fskik.upsi.edu.my
Biconditional
Q : Which operator is the opposite of?
A : has exactly the opposite truth table as .
p q r r pq p q r
T T T F T F
T T F T T T
T F T F T F
T F F T T T
F T T F T F
F T F T T T
F F T F F T
F F F T F T
http://fskik.upsi.edu.my
((p q) q)
0
http://fskik.upsi.edu.my
1 1
1 0
0 1
0 0
http://fskik.upsi.edu.my
1 1 1
1 0 0
0 1 0
0 0 0
http://fskik.upsi.edu.my
1 1 1 0
1 0 0 1
0 1 0 0
0 0 0 1
http://fskik.upsi.edu.my
1 1 1 0 1
1 0 0 1 1
0 1 0 0 0
0 0 0 1 1
http://fskik.upsi.edu.my
Equivalent Propositions
Two propositions are equivalent if they always
have the same truth value.
Example: Show using a truth table that the
biconditional is equivalent to the contrapositive.
Solution:
p q p q p q q p
T T F F T T
T F F T F F
F T T F T T
F F T T T T
http://fskik.upsi.edu.my
Problem
How many rows are there in a truth table with n
propositional variables?
p q r is equivalent to (p q) r
If the intended meaning is p (q r )
then parentheses must be used.
http://fskik.upsi.edu.my
Applications of Propositional
Logic
Section 1.2
http://fskik.upsi.edu.my
Example
Problem: Translate the following sentence into
propositional logic:
You can access the Internet from campus only if you
are a computer science major or you are not a
freshman.
One Solution: Let a, c, and f represent respectively
You can access the internet from campus, You are
a computer science major, and You are a
freshman.
a (c f )
http://fskik.upsi.edu.my
System Specifications
System and Software engineers take requirements in
English and express them in a precise specification
language based on logic.
Example: Express in propositional logic:
The automated reply cannot be sent when the file
system is full
Solution: One possible solution: Let p denote The
automated reply can be sent and q denote The file
system is full.
q p
http://fskik.upsi.edu.my
Logic Puzzles
An island has two kinds of inhabitants, knights, who always tell the truth,
and knaves, who always lie.
You go to the island and meet A and B. Raymond
Smullyan
A says B is a knight.
(Born
B says The two of us are of opposite types. 1919)
Example: What are the types of A and B?
Solution: Let p and q be the statements that A is a knight and B is a knight,
respectively. So, then p represents the proposition that A is a knave and
q that B is a knave.
If A is a knight, then p is true. Since knights tell the truth, q must also be true.
Then (p q) ( p q) would have to be true, but it is not. So, A is not a
knight and therefore p must be true.
If A is a knave, then B must not be a knight since knaves always lie. So, then
both p and q hold since both are knaves.
http://fskik.upsi.edu.my
Logic Circuits
(Studied in depth in Chapter 12)
Electronic circuits; each input/output signal can be viewed as a 0 or 1.
0 represents False
1 represents True
Complicated circuits are constructed from three basic circuits called gates.
The inverter (NOT gate)takes an input bit and produces the negation of that bit.
The OR gate takes two input bits and produces the value equivalent to the disjunction of the two
bits.
The AND gate takes two input bits and produces the value equivalent to the conjunction of the two
bits.
More complicated digital circuits can be constructed by combining these basic circuits to
produce the desired output given the input signals by building a circuit for each piece of the
output expression and then combining them. For example:
http://fskik.upsi.edu.my
l2
http://fskik.upsi.edu.my
Observations (opt)
Observations need to be added to the KB
Both Switches up
up_s1
up_s2
Both lights are dark
lit_l1
lit_l2
http://fskik.upsi.edu.my
Diagnosis (opt)
We assume that the components are working ok, unless we are
forced to assume otherwise. These atoms are called assumables.
The assumables (ok_cb1, ok_s1, ok_s2, ok_s3, ok_l1, ok_l2)
represent the assumption that we assume that the switches, lights,
and circuit breakers are ok.
If the system is working correctly (all assumables are true), the
observations and the knowledge base are consistent (i.e.,
satisfiable).
The augmented knowledge base is clearly not consistent if the
assumables are all true. The switches are both up, but the lights
are not lit. Some of the assumables must then be false. This is the
basis for the method to diagnose possible faults in the system.
A diagnosis is a minimal set of assumables which must be false to
explain the observations of the system.
http://fskik.upsi.edu.my
Propositional Equivalences
Section 1.3
http://fskik.upsi.edu.my
Section Summary
Tautologies, Contradictions, and Contingencies.
Logical Equivalence
Important Logical Equivalences
Showing Logical Equivalence
Normal Forms (optional, covered in exercises in
text)
Disjunctive Normal Form
Conjunctive Normal Form
Propositional Satisfiability
Sudoku Example
http://fskik.upsi.edu.my
Logically Equivalent
Two compound propositions p and q are logically equivalent if pq is a
tautology.
We write this as pq or as pq where p and q are compound
propositions.
Two compound propositions p and q are equivalent if and only if the
columns in a truth table giving their truth values agree.
This truth table show p q is equivalent to p q.
p q p p q p q
T T F T T
T F F F F
F T T T T
F F T T T
http://fskik.upsi.edu.my
Logically Equivalent
Exercises:
Are (p r) v (q r ) and (p q) r logically equivalent? Prove it using
truth table.
p q r pr qr (p r) v (q r ) pq (p q) r
1
1
1
1
0
0
0
0
http://fskik.upsi.edu.my
p q r pr qr (p r) v (q r ) pq (p q) r
1 1
1 1
1 0
1 0
0 1
0 1
0 0
0 0
http://fskik.upsi.edu.my
p q r pr qr (p r) v (q r ) pq (p q) r
1 1 1 1
1 1 0 0
1 0 1 1
1 0 0 0
0 1 1 1
0 1 0 1
0 0 1 1
0 0 0 1
http://fskik.upsi.edu.my
p q r pr qr (p r) v (q r ) pq (p q) r
1 1 1 1 1
1 1 0 0 0
1 0 1 1 1
1 0 0 0 1
0 1 1 1 1
0 1 0 1 0
0 0 1 1 1
0 0 0 1 1
http://fskik.upsi.edu.my
p q r pr qr (p r) v (q r ) pq (p q) r
1 1 1 1 1 1
1 1 0 0 0 0
1 0 1 1 1 1
1 0 0 0 1 1
0 1 1 1 1 1
0 1 0 1 1 1
0 0 1 1 1 1
0 0 0 1 1 1
http://fskik.upsi.edu.my
p q r pr qr (p r) v (q r ) pq (p q) r
1 1 1 1 1 1 1
1 1 0 0 0 0 1
1 0 1 1 1 1 0
1 0 0 0 1 1 0
0 1 1 1 1 1 0
0 1 0 1 1 1 0
0 0 1 1 1 1 0
0 0 0 1 1 1 0
http://fskik.upsi.edu.my
p q r pr qr (p r) v (q r ) pq (p q) r
1 1 1 1 1 1 1 1
1 1 0 0 0 0 1 0
1 0 1 1 1 1 0 1
1 0 0 0 1 1 0 1
0 1 1 1 1 1 0 1
0 1 0 1 1 1 0 1
0 0 1 1 1 1 0 1
0 0 0 1 1 1 0 1
http://fskik.upsi.edu.my
Logically Equivalent
Exercises:
Show that (p q) q is a tautology? Prove it using truth table.
p q pq (p q) q
1 1 1 1
1 0 0 1
0 1 0 1
0 0 0 1
http://fskik.upsi.edu.my
De Morgans Laws
Augustus De Morgan
1806-1871
Domination Laws: ,
Idempotent laws: ,
Negation Laws: ,
http://fskik.upsi.edu.my
Associative Laws:
Distributive Laws:
Absorption Laws:
http://fskik.upsi.edu.my
Equivalence Proofs
Example: Show that
is logically equivalent to
Solution:
http://fskik.upsi.edu.my
Equivalence Proofs
Example: Show that
is a tautology.
Solution:
http://fskik.upsi.edu.my
Equivalence Proofs
No
Disjunctive Normal Form is important for the circuit
design methods discussed in Chapter 12.
http://fskik.upsi.edu.my
Solution:
1. Eliminate implication signs:
Propositional Satisfiability
A compound proposition is satisfiable if there
is an assignment of truth values to its
variables that make it true. When no such
assignments exist, the compound proposition
is unsatisfiable.
A compound proposition is unsatisfiable if and
only if its negation is a tautology.
http://fskik.upsi.edu.my
Questions on Propositional
Satisfiability
Example: Determine the satisfiability of the following
compound propositions:
Notation
Sudoku
A Sudoku puzzle is represented by a 99 grid made
up of nine 33 subgrids, known as blocks. Some of
the 81 cells of the puzzle are assigned one of the
numbers 1,2, , 9.
The puzzle is solved by assigning numbers to each
blank cell so that every row, column and block
contains each of the nine possible numbers.
Example
http://fskik.upsi.edu.my
Encoding (cont)
For each cell with a given value, assert p(d,j,n), when
the cell in row i and column j has the given value.
Assert that every row contains every number.
Encoding (cont)
Assert that each of the 3 x 3 blocks contain every
number.
Bit Strings
Electronic computers achieve their calculations
inside semiconducting materials.
Bit Strings
In logic, only two truth values are allowed. Thus
propositional logic is ideal for modeling
computers.
Bit Strings
Thus voltage memory stored in a computer can
be represented by a sequence of 0s and 1s such
as:
01 1011 0010 1001
Another portion of the memory might look like
as follows:
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.
http://fskik.upsi.edu.my
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.
Example, the exclusive-or of the previous bit strings
is: