Basic Logic
Basic Logic
1: Propositional Logic
Logic
Study of valid reasoning.
Allows us to represent knowledge in precise, mathematical way.
Allows us to make valid inferences using a set of precise rules.
Many applications in CS:
AI, programming languages, databases, computer architecture,
automated testing and program analysis etc.
T T F T T
T F F F T
F T T F T
F F T F F
12
Example
Conditional statement is “If it rained last night, then the sidewalk is
wet.”
The converse of the conditional statement is
“If the sidewalk is wet, then it rained last night.”
The contrapositive of the conditional statement is
“If the sidewalk is not wet, then it did not rain last night.”
The inverse of the conditional statement is
“If it did not rain last night, then the sidewalk is not wet.”
T T T T
T F F F
F T T F
F F T T
3: Practice on Propositional
Logic
Operator Precedence
How do we parse this statement?
¬x → y ∨ z → x ∨ y ∧ z
Operator precedence for propositional logic:
¬
∧
∨
→
↔
Above expression is same as:
(¬x) → ((y ∨ z) → (x ∨ (y ∧ z)))
Translation: b ᴧ c → a
4:Propositional Equivalences
Tautology and Contradiction
Some propositions are interesting since their values in the truth table are
always the same
A compound proposition that is always true for all possible truth values of the
propositions is called a tautology.
A compound proposition that is always false is called a contradiction.
A proposition that is neither a tautology nor contradiction is called a
contingency.
Example: p ∨ ¬p is a tautology
5:Normal Forms
Normal Forms
We can convert any proposition in two normal forms −
1. Disjunctive normal form
2. Conjunctive normal form
Disjunctive normal form(DNF)/SOP
Every compound proposition in the propositional variables p, q, r, ..., is uniquely equivalent to a
proposition that is formed by taking the disjunction of conjunctions of some combination of that
variables or their negations.
Indeed, the above form is valid no matter what propositions are substituted to the
variables
This is called a valid argument form
By definition, if a valid argument form consists
– premises: p1 , p2 , … , pk
– conclusion: q
then ( p1 ∧ p2 ∧ … ∧ pk ) → q is a tautology
UCS405 "DISCRETE MATHEMATICAL STRUCTURES"
Rules of Inference
1. Addition
premise: p
conclusion: p ∨ q
2. Simplification
premise: p ∧ q
conclusion: p
Corresponding Tautology: (p∧q) →p
UCS405 "DISCRETE MATHEMATICAL STRUCTURES"
Rules of Inference
3. Modus Ponens (method of affirming) or law of detachment
premises: p, p → q
conclusion: q
Corresponding Tautology: (p ∧ (p →q)) → q
4. Modus Tollens (method of denying)
premises: ¬q, p → q
conclusion: ¬p
Corresponding Tautology: (¬q ∧(p →q))→¬p
8. Resolution
premises: p ∨ q, ¬p ∨ r
conclusion: q ∨ r
Corresponding Tautology: ((p ∨ q) ∧ (¬p ∨ r )) →(q ∨ r)
UCS405 "DISCRETE MATHEMATICAL STRUCTURES"
Rules of Inference
9. Constructive Dilemma
premises: (p → q) ∧ (r → s)
(p ∨ r)
conclusion: (q ∨ s)
Corresponding Tautology: (((p → q) ∧ (r → s)) ∧ (p ∨ r) ) →(q ∨ s)
premise: p
conclusion: p ∨ q
This is an argument that uses the addition rule.
premise: p ∧ q
conclusion: p
This is an argument that uses the Simplification rule.
premises: p → q, q → r
conclusion: p r
This is an argument that uses the Hypothetical Syllogism rule.
7:Predicate Logic
Limitation of Propositional Logic
Every COE student must study discrete mathematics
Deepak is a COE student
– So Deepak must study discrete mathematics
This idea can’t be expressed with propositional logic
What propositional logic allows to express:
If Deepak is a COE student he must study discrete mathematics
Deepak is a COE student
So Deepak must study discrete mathematics
Example: Not all students in this class are using Facebook and (also) Google+
There is some (at least one) student in this class who is not using
Facebook or not using Google+ (or may be using neither)