2. History and Applications
• Derived from the greek word ‘logos’.
• It is called science of thought.
• It starts from Aristotle.
• Real Life: Expert Systems, VLSI, Semantic Web.
• Computer Science: Godel’s incompleteness
theorem, Frame problem, Category theory, Curry-
Howard correspondence.
2
3. Statements in Grammar
• Declarative: The sky is blue.
• Imperative: Speak truth.
• Interrogative: Are you interested in maths?
• Exclamatory: Wow! You are so beautiful.
3
4. Propositional logic
• Propositional logic is the simplest logic – illustrates basic ideas.
• A declarative sentence which can be classified as either true or false.
• Simple statement
Eg. Aristotle was a philosopher
• Compound Statement
Eg. If you will commit a mistake, you will pay for it
5. Symbols of propositional logic
• Logical constants TRUE and FALSE are sentences
• Proposition symbols P,Q,S1,S2 are sentences
• ∧, V, , , are logical connectives
• parenthesis ( )
• Order of precedence (), , ∧, V, ,
6. Connectives
– If S is a sentence, S is a sentence
(negation)
– If S1 and S2 are sentences, S1 S2 is a sentence
(conjunction)
– If S1 and S2 are sentences, S1 S2 is a sentence
(disjunction)
– If S1 and S2 are sentences, S1 S2 is a sentence
(implication)
– If S1 and S2 are sentences, S1 S2 is a sentence
(biconditional)
6
7. Propositional logic: Semantics
Each model specifies true/false for each proposition symbol
E.g. P1 P2 P3
false true false
With these symbols, 8 possible models, can be enumerated automatically.
Rules for evaluating truth with respect to a model m:
S or S is true iff S is false
S1 S2 is true iff S1 is true and S2 is true
S1 S2 is true iff S1is true or S2 is true
S1 S2 is true iff S1 is false or S2 is true
i.e., is false iff S1 is true and S2 is false
S1 S2 is true iff S1S2 is true and S2S1 is true
Simple recursive process evaluates an arbitrary sentence, e.g.,
P1 (P2 P3) = true (true false) = true true = true
8. Truth tables for connectives
If P then Q
P V Q
If P then Q and If Q then P
(if and only if)
10. Converse, Inverse and Contrapositive
Given an implication "if p, then q“, we can create three related statements:
• A conditional statement consists of two parts, a premise in the “if” clause and a
conclusion in the “then” clause. For instance, “If it rains, then they cancel school.”
"It rains" is the premise.
"They cancel school" is the conclusion.
• To form the converse of the conditional statement, interchange the premise and the
conclusion.
The converse of "If it rains, then they cancel school" is
"If they cancel school, then it rains."
• To form the inverse of the conditional statement, take the negation of both the
premise and the conclusion.
The inverse of “If it rains, then they cancel school” is
“If it does not rain, then they do not cancel school.”
• To form the contrapositive of the conditional statement, interchange the premise
and the conclusion of the inverse statement.
The contrapositive of "If it rains, then they cancel school" is
"If they do not cancel school, then it does not rain."
11. Converse, Inverse and Contrapositive
Eg.1
Statement: If p, then q.
Converse: If q, then p.
Inverse: If not p, then not q.
Contrapositive: If not q, then not p.
Eg.2
Statement: If two angles are congruent, then they have the same measure.
Converse: If two angles have the same measure, then they are congruent.
Inverse: If two angles are not congruent, then they do not have the same measure.
Contrapositive: If two angles do not have the same measure, then they are not
congruent.
12. (Laws of Logic)
Logical equivalence - Biconditional
• Two sentences are logically equivalent iff true in same models:
i.e. they have identical truth tables
Involution law
13. • Two sentences are logically equivalent iff true in same models:
i.e. they have identical truth tables
α α ≡ α α ∧ α ≡ α Idempotent Law
α F ≡ α α ∧ T ≡ T Identity Law
α T ≡ T α ∧ F ≡ F Annihilation Law
α α ≡ T α ∧ α ≡ F Inverse Law
T ≡ F F ≡ T Complement Law
(Laws of Logic)
Logical equivalence
14. Validity (tautology), contradiction and contingency
A proposition which is always true is called tautology
α α
A proposition which is always false is called contradiction
α ∧ α
A proposition which is neither a tautology nor a contradiction is
called contingency
α , α , α
15. Propositions quantifying
• All humans are mortal.
• Everything is perishable.
• Some people have pink hair.
• Nothing is perfect.
• There exists a white crow.
15
16. 16
Quantifiers
• A quantifier is “an operator that limits the
variables of a proposition”
• Two types:
– Universal : the proposition is true for all, for
each, for every possible values in the universe
of discourse
– Existential : the proposition is true for some
value(s) in the universe of discourse
17. Universal quantification
• <variables> <sentence> or A <variables> <sentence>
Example:
“All elephants are gray”
(x )(elephant(x) color(x, GRAY))
• x P is true in a model m iff P is true with x being each possible
object in the model
• Roughly speaking, equivalent to the conjunction of instantiations of P
Example:
“Everyone at NUS is smart”
x At(x,NUS) Smart(x)
At(KingJohn,NUS) Smart(KingJohn) At(Richard,NUS)
Smart(Richard) At(NUS,NUS) Smart(NUS) …
18. Existential quantification
• <variables> <sentence> or E <variables> <sentence>
Example:
“Someone wrote Computer Chess”
(x write(x, COMPUTER-CHESS))
• x P is true in a model m iff P is true with x being some possible
object in the model
• Roughly speaking, equivalent to the disjunction of instantiations of P
Example:
Someone at NUS is smart:
x At(x,NUS) Smart(x)
At(KingJohn,NUS) Smart(KingJohn) At(Richard,NUS)
Smart(Richard) At(NUS,NUS) Smart(NUS) ...
19. Properties of quantifiers
• x y is the same as y x
• x y is the same as y x
• x y is not the same as y x
• “There is a person who loves everyone in the house”
x y Loves(x,y)
• “Everyone in the house loves at least one person”
x y Loves(x,y)
Quantifier duality(De Morgan’s law for quantification):
each can be expressed using the other
• x Likes(x,IceCream) x Likes(x,IceCream)
• x Likes(x,Broccoli) x Likes(x,Broccoli)
21. Examples on Predicate Logic
• x loves y Loves(x,y)
Everybody loves Jerry x Loves (x, Jerry)
• Everybody loves somebody x y Loves (x, y)
• There is somebody whom somebody loves y x Loves (x, y)
• Nobody loves everybody x y Loves (x, y) = x y Loves (x, y)
• There is somebody whom Rachita doesn’t love y Loves (Rachita, y)
• There is somebody whom no one loves y x Loves (x, y)
• Everybody loves himself or herself x Loves(x,x)
22. Normal Forms
A problem in logic is to find whether a given statement is
tautology or contradiction via truth tables, especially where the
statement form may contain a large no. of variables.
Hence reduce statement form to normal form.
• Disjunctive Normal Form (dnf): A statement form consisting
of disjunction of fundamental conjuncts (minterm)
(P Q R) V (X Y Z) [SOP]
• Conjunctive Normal Form (cnf): A statement form consisting
of conjunction of fundamental disjuncts (maxterm)
( P V X) (P V Y) (P V Z) (…..) [POS]
23. DNF (SOP) to CNF (POS)
for resolution refutation
Disjunctive Normal Form
(P Q R) V (X Y Z)
Conjunctive Normal Form
( P V X) (P V Y) (P V Z) (…..)
Every sentence of propositional logic is logically equivalent
to a conjunction of disjuncts of literals
24. Conversion to CNF
• Eliminate α ß to (α ß ) (ß α )
• Eliminate α ß to α V ß
• CNF requires to appear only with literals
For this apply
( α) ≡ α (double-negative elimination)
(α ß) ≡ α V ß (de Morgan)
(α V ß) ≡ α ß (de Morgan)
• Now we have a sentence with nested and V operators
applied to literals. Apply distributivity law distributing V
over
26. 26
Principle of Mathematical
Induction
Mathematical induction is a form of mathematical proof.
Just because a rule, pattern, or formula seems to work for several
values of n, you cannot simply decide that it is valid for all
values of n without going through a legitimate proof.
The Principle of Mathematical Induction
Let Pn be a statement involving the positive integer n. If
1. Verification: P1 is true, and
2. Induction: the truth of Pk implies the truth of Pk+1 ,
for every positive integer k,
Conclusion: then Pn must be true for all integers n.
27. 27
Example: Sum of Odd Integers
➢ Proposition: 1 + 3 + … + (2n-1) = n2
for all integers n≥1.
➢ Proof (by induction):
1) Basis step:
The statement is true for n=1: 1=12 .
2) Inductive step:
Assume the statement is true for some k≥1
(inductive hypothesis) ,
show that it is true for k+1 .
28. Example: Sum of Odd Integers
➢ Proof (cont.):
The statement is true for k:
1+3+…+(2k-1) = k2 (1)
We need to show it for k+1:
1+3+…+(2(k+1)-1) = (k+1)2 (2)
Showing (2):
1+3+…+(2(k+1)-1) = 1+3+…+(2k+1) =
1+3+…+(2k-1)+(2k+1) =
k2+(2k+1) = (k+1)2 .
We proved the basis and inductive steps,
so we conclude that the given statement true. ■
by (1)
29. 29
Example: Sum of square of
Integers
➢ Proposition:
for all integers n≥1.
➢ Proof (by induction):
1) Basis step:
The statement is true for n=1: 12= .
2) Inductive step:
Assume the statement is true for some k≥1
(inductive hypothesis) ,
show that it is true for k+1 .
Sn = 12 + 22 + 32 + 42 + . . . + n2 = ( )( )
6
121 ++ nnn
( )( )
6
321
30. Example: Sum of square of
Integers
➢ Proof (cont.):
The statement is true for k:
We need to show it for k+1:
by (1)
12 + 22 + 32 + 42 + . . . + k2 = (1)
( )( )
6
121 ++ kkk
( )( )( )
6
3221 +++ kkk
( )( ) ( )
6
16121
2
++++
=
kkkk
( ) ( ) ( )
6
16121 ++++
=
kkkk ( )
6
6721 2
+++
=
kkk ( )( )( )
6
3221 +++
=
kkk
Showing (2): (12 + 22 + 32 + 42 + . . . + k2) + (k + 1)2
=
k k +1( ) 2k +1( )
6
+ (k + 1)2
12 + 22 + 32 + 42 + . . . + k2 + (k+1)2 = (2)
We proved the basis and inductive steps,
so we conclude that the given statement true.