Chapter 1: Formal Logic: Tannaz R.Damavandi Cal Poly Pomona
Chapter 1: Formal Logic: Tannaz R.Damavandi Cal Poly Pomona
Tannaz R.Damavandi
Cal Poly Pomona
Credit for some of the slides in this lecture goes to Dr.Fang Tang
Outline
• 1.1 – Statements, Symbolic Representation,
and Tautologies
• 1.2- Propositional Logic
• 1.3- Quantifiers, Predicates and Validity
• 1.4- Predicate Logic
• 1.5- Logic Programming (Not covered in this
class)
Section 1.1 – Statements, Symbolic Representation,
and Tautologies
3
Statement
A statement (or proposition) is a sentence that is
either true or false but not both.
4
Practice 1
Which ones are statements?
• 2 is an integer number.
• 5 is less than 0.
• Do your best!
• How are you?
• All mathematicians wear sandals.
• X -2 >0
Convention: When there is a non-specific item in the
sentence, then it is not considered as a statement.
5
What is logic?
Although logic was introduced and used by Aristotle and Plato in the
ancient world, the best quick phrase for logic was presented by John
Locke (British Philosopher and Physician (1632- 1704) as, “Logic is
the anatomy of thoughts”.
Logic
Formal
Informal:
(Symbolic):
concerned with
concerned with
content
form
8
Formal Logic- more definitions:
Example:
A A'
A : 2*2 is less than 5.
A : 2*2 is greater or equal than 5. T F
11
Truth Table
Definition:
A truth table is a table which displays the truth
values of a compound statement that correspond to
all different combinations of truth values of the
statement variables.
12
Truth Table (Cont’d)
The total number of rows in a truth table for n statement letters is 2n.
Connective #2: Conjunction(Λ)
• If A and B are statement variables, the conjunction of A and B
is A Λ B, which is read "A and B“
• A Λ B is true when both A and B are true. A Λ B is false when at
least one of A or B is false.
• Logical expression: A Λ B.
• English words: and; but; also; in addition; moreover
A B AΛB
T T T
T F F
F T F
F F F
14
Connective #3: Disjunction (V)
• If A and B are statement variables, the disjunction of A and B is
A V B, which is read "A or B"
• A V B is true when at least one of A or B is true. A V B is false
when both A and B are false.
• Logical expression: A V B
• English word: or
A B AVB
T T T
T F T
F T T
F F F
15
Important Note!
Negation, Conjunction and Disjunction
Expressing the negation of a statement must be done
with care, especially for a compound statement.
Example:
A : She hates math and likes history.
A : She likes math or hates history.
16
Practice 2
A = It will rain tomorrow. What’s A’?
◦ It is false that it will rain tomorrow.
◦ It will not rain tomorrow.
B = Peter is tall and thin. What’s B’?
◦ (1) Peter is not tall or he is not thin.
◦ (2) Peter is short or fat.
◦ (3) It is false that Peter is tall and thin.
◦ (4) Peter is short and fat. Too strong! Peter fails to have both
properties (tallness and thinness) both may still have one of
them.(WRONG!)
C = The river is shallow or polluted. What’s C’?
◦ (1) The river is neither shallow nor polluted.
◦ (2) The river is deep and unpolluted.
◦ (3) It is false that the river is shallow or polluted.
◦ (4) The river is not shallow or not polluted .Too weak a statement.
The river fails to have either property, not just fails to have one
property.(WRONG!)
17
De Morgan’s Laws
1.(A V B) A Λ B
2.(A Λ B) A V B
Augustus De Morgan (1806 – 1871) was a British mathematician and logician. He formulated De Morgan's
laws and introduced the term mathematical induction, making its idea rigorous.
Source : https://en.wikipedia.org/wiki/Augustus_De_Morgan
Example:
Constructing truth table prove:
(A V B) A Λ B
Practice 3
Constructing truth table prove:
(A Λ B) A V B
Connective #4: Implication()
• If A and B are statement variables, the symbolic form of "if A then B" is AB.
• Here A is called the hypothesis/antecedent statement and B is called the
conclusion/consequent statement.
• "If A then B'' is false when A is true and B is false, and it is true otherwise.
• Logical Expression : AB
• English words:
– A implies B.
– B if A.
– Whenever A, B A B AB
– A, therefore B. T T T
– B follows from A. T F F
– A is a sufficient condition for B. F T T
– B is a necessary condition for A. F F T
– A only if B.
21
Example
If you get 90 or above then you are guaranteed an A.
22
Practice 4
Rewrite each of the following statements in the form “if A,
then B.”
Errors were introduced only if there was a modification
of the program.
If errors were introduced, then there was a modification of
the program.
Fuel saving implies good insulation or storm windows
throughout.
If there is a fuel saving, then there is good insulation or
storm windows throughout.
Increased availability of information is a necessary
condition for future technological advances.
If there are future technological advances, then there is
increased availability of information.
23
Practice 5
What’s the truth value of the following:
– 8 is even or 6 is odd.
– 8 is even and 6 is odd.
– If 8 is odd, then 6 is odd.
– If 8 is even, then 6 is even.
– If 8 is even, then 6 is odd.
24
Practice 5
What’s the truth value of the following:
– 8 is even or 6 is odd.
– 8 is even and 6 is odd.
– If 8 is odd, then 6 is odd.
– If 8 is even, then 6 is even.
– If 8 is even, then 6 is odd.
25
Another Form of Implication
Representation of If-Then using Or
A B = “If you do not do your homework, then you will flunk”
A = “You do not your homework”
B = “You will flunk”
A' = “You do your homework”
A' V B = “Either you do your homework or you will flunk”
Therefore , A B A V B
26
Connective #5: Equivalence ()
If A and B are statement variables, the symbolic form of “A if, and only
if, B" and is denoted A B.
It is true if both A and B have the same truth values and is false if A and B
have opposite truth values.
Logical Expression: A B
English word: “A is necessary and sufficient for B”, “A is equivalent to
B”, “A if and only if B”.
Note: A B is a short form for (A B) Λ (B A)
27
Truth Tables
Well-Formed Formula (wff)
We can string statement letters, connectives, and parentheses (or brackets) together
to form new expressions.
Formally:
All propositional variables and the constants True and False are wffs.
If A and B are wffs, then A’, B’, A Λ B, A V B, AB, AB, (A’), (B’),
(A Λ B), (A V B), (AB), (AB) are wffs.
Hence:
A V B C is the same as (A V B) C.
A Λ B’ stands for A Λ(B’) not (A ΛB)’.
31
Challenge 1
Using the rules of precedence, construct the truth table
of the following wff:
A V B (A V B)
32
Tautology and Contradiction
Tautology :
A wff that its truth values are always true, is called a “tautology”.
A tautology is “intrinsically true” by its very structure; it is true no matter what
truth values are assigned to its statement letters.
Example:
It will rain today or it will not rain today ( A V A )
Contradiction :
A wff that its truth values are always false, is called a “contradiction”.
A contradiction is “intrinsically false” by its very structure; it is false no matter
what truth values are assigned to its statement letters.
Example:
It will rain today and it will not rain today ( A Λ A )
33
Tautological Equivalences
Two statement forms are called logically equivalent if, and only if, they
have identical truth values for each row of the truth table.
The logical equivalence of statement forms P and Q is denoted by
writing P Q or P Q.
Prove by constructing truth table
(A V B) V C A V (B V C)
34
Some Common Equivalences
Since the equivalences are listed in pairs, they are called duals of
each other.
One equivalence can be obtained from another by replacing V with
Λ and 0 with 1 or vice versa.
Distributive A V (B Λ C) (A V B) Λ (A V C) A Λ (B V C) (A Λ B) V (A Λ C)
Complement A V A´ 1 A Λ A´ 0
35
Practice 6
Using truth table prove following equivalence
A V (B Λ C) (A V B) Λ (A V C)
36
Additional Equivalences
• De Morgan’s Laws
– (A V B)’ A’ Λ B’
– (A Λ B)’ A’ V B’
Example : if A is the statement “Julie likes butter but hates cream”,
what is A’?
• Double negation: (A’)’ A
• Rewriting implication: (A B) A’ V B
• Contraposition: (A B) (B’ A’)
• Conditional proof: A (B C) (A Λ B) C
– “If I miss the train today, then I can arrive only 5 minutes
late, assuming that the next train is on time.”
37
Additional Equivalences
• Suppose P and Q are equivalent wffs. Then P can be replaced
by Q in any wff R containing P, resulting in a wff RQ that is
equivalent to R
• Example:
– R: (A B) B
– P: A B, Q: B’ A’
– RQ : (B’ A’) B
Prove: R ↔ RQ
38
Algorithm
Definition of an algorithm:
A set of instructions that can be mechanically executed in a
finite amount of time in order to solve a problem
unambiguously.
Pseudo code that prints all positive multiples of 5 between 1 and 100
(including 100)
x = 5 // initial value
i = 1 // Initial value
While(i <= 20)
write x
i = i +1
x = i*5
end while
40
Logical Connectives in Computer Science
• Web search engine
• Conditional statement in programming use logical connectives with
statements
• Example:
if ((outflow > inflow) and
not ((outflow > inflow) and (pressure < 1000)))
do something;
else
do something else;
• A: outflow > inflow
• B: pressure < 1000
• A Λ (A Λ B)’
• Can we simplify this?
41
Review of Section 1.1
Techniques:
◦ construct truth tables for compound wffs
◦ recognize tautologies and contradictions
Main ideas:
◦ wffs are symbolic representation of statements
◦ truth values for compound wffs depend on the truth value
of their components and the types of connectives used
◦ tautologies are intrinsically true wffs – true for all truth
values
42
Section 1.2 Propositional Logic
Propositional Logic
Statements are called propositions.
Wffs are also called propositional wffs.
44
Argument
An argument is a sequence of statements in which the
conjunction of the initial statements (called the
premises/hypotheses) is said to imply the final statement
(called the conclusion).
45
Argument (Cont’d)
(P1 Λ P2 Λ ... Λ Pn) Q
Of course this implication is true if any of the hypothesis
is false. Why?
But in an argument we usually care about what happens
when all the hypothesis are true.
Also, this implication should be true based on
relationship of the conclusion to hypothesis.
Example:
◦ P1: George Washington was the first president of the United States.
◦ P2 : Thomas Jefferson wrote the Declaration of Independence.
◦ Q : Everyday has 24 hours.
Even though both hypothesis and conclusion are true statements, we
wouldn’t consider this argument valid. 46
Valid Argument
An argument is valid if whenever the hypotheses
are all true, the conclusion must also be true.
Hence (P1 Λ P2 Λ ... Λ Pn) Q is a tautology.
47
Proof Sequence
• To test whether (P1 Λ P2 Λ ... Λ Pn) Q is a tautology:
– Build a truth table
– Generate a proof sequence (new way) by applying
derivation rules.
49
Derivation Rules for Propositional Logic
50
Equivalence Rules
• These rules state that certain pairs of wffs are equivalent,
hence one can be substituted for the other with no change to
its truth values.
• Allows substitution in either direction
Let R and S be statement variables
52