DSGT
DSGT
DSGT
LOGIC
Introduction
• Logic is a discipline that deals with methods of reasoning.
• It provides the rules by which one can determine whether any particular proof or argument is
valid or not.
• Logical reasoning is used in mathematics to prove theorems, in Computer Science to verify the
correctness of programs and to prove theorems, and in social sciences and everyday lives to
solve a multitude of problems.
• Indeed, we constantly are using logical reasoning.
• E.g. He tries to study hard.
He tries hard to study.
• To avoid such mishaps, a formal language is developed using symbols and well defined rules
for calculating with those symbols.
• Examples-
i. There are seven days in a week-True
ii. The earth is in spherical shape.-True
iii. 2+5=8 -False
• But,
1. X+3=5 -is not a preposition since its truth value depends on value of x.
2. Bring that Book- is a command, not a statement.
• The statements which can not be further split or broken down into simpler sentences
are called as Primary, Primitive or atomic statements.
Logical Operations
1. Negation-
If p denotes a statement, then negation of P is ~ p or
e.g. p - I am going for a walk
~p –I am not going for a walk OR
It is not the case that I am going for a walk.
2. Conjunction (and)-
If p and q are statements, the compound statement ‘p and q’ is called as the
conjunction pf p and q.
It is denoted by p˄q.
Examples-
a) p:The sun is shining
q: The birds are singing
Then
p˄q: The sun is shining and the birds are singing.
p: Rahul is poor.
q: Rahul is happy.
• Example 2 –
• Put the statement into Symbolic form-
Unless I reach the station on time, I will miss the train.
Solution-
Let p: I reach the station on time.
q: I will miss the train.
E.g.
1. An integer is even if and only if it is divisible by 2.
2. Two lines are parallel if and only if they have the same slope.
Prepositional or Statement Form
• Using the logical connectives, defined above, we can construct or form an
expression.
• Examples of Statement form-
1. ~ (p˅q) →p
2. (p → q) ↔(p˄ ~ q)
2. p ˄q (AND)
P q p ˄q
T T T
T F F
F T F
F F F
3. p˅q (OR) P q p˅q
T T T
T F T
F T T
F F F
4. p → q(Conditional)
P q p→q
T T T
T F F
F T T
F F T
5.p ↔q(Biconditional)
P q p ↔q
T T T
T F F
F T F
F F T
6.p↑q (NAND)
P q p↑q
T T F
T F T
F T T
F F T
7. p ↓q(NOR)
P q p ↓q
T T F
T F F
F T F
F F T
8. p⨁q(EX-OR)
P q p⨁q
T T F
T F T
F T T
F F F
• Construct a truth table for- 1. ~[p ˄(p ˅ ~ q)]
T T F T T F
T F T T T F
F T F F F T
F F T T F T
2. (~p ˅q) →q
p q ~p (~p ˅q) (~p ˅q) →q
T T F T T
T F F F T
F T T T T
F F T T F
3. (~p →r) ˄p ↔q
Tautology and Contradiction
• Tautology-A proposition P is a tautology if it is true under all circumstances.
It means it contains the only T in the final column of its truth table.
• Example: Prove that the statement (p⟶q) ↔(∼q⟶∼p) is a tautology.
T T T F F T T
T F F T F F T
F T T F T T T
F F T T T T T
• Contigency:
A statement which is neither p q p →q p∧q (p →q)⟶ (p∧q )
Tautology nor contradiction T T T T T
is called a contigency. T F F F T
F T T F F
F F T F F
• Construct a truth table to determine whether each of the following is a
Tautology, a Contigency or a Contradiction.
1. p →(q→p)
2. (p ˄q ) ˄ ~(p ˅q)
Propositional Equivalences
• Two statement forms are logically equivalent if both have the same truth
values.
• Example-
• 1. Prove p∧q and q∧p are logically equivalent.
p q p∧q q∧p
T T T T
T F F F
F T F F
F F F F
2. p and ∼ (∼p)
Laws of Logic
1. Idempotent laws- p ˅p ≡ p
p∧p≡p
2. Commutative Laws- p ˅q ≡ q ˅ p
p∧q≡q∧p
3. Associative laws- (p∧q)∧r≡p∧(q∧r)
(p∨q)∨r≡p∨(q∨r)
4. Distributive laws: p∨(q∧r)≡(p∨q)∧(p∨r)
p∧(q∨r)≡(p∧q)∨(p∧r)
5. Absorption laws: p∨(p∧q)≡p
p∧(p∨q)≡p
6. De Morgan’s Laws: ∼(p∧q)≡ ∼ p∨ ∼ q
∼(p∨q)≡ ∼ p∧ ∼ q
7. Identity Laws: p∨T≡T p∧T≡p
p∨F≡p p∧F≡F
8. Complement/Inverse Laws: p ∨ ∼ p ≡ T p∧∼p≡F
∼T≡F ∼F≡T
∼ (∼ p)=p
9. Implication law: p ⟶ q= ∼ p ∨q
• Using laws of logic, show that ∼(∼ p ∧ q) ∧(p ˅ q) ≡p.
Solution-
∼(∼ p ∧ q) ∧(p ˅ q)
≡ (∼(∼ p) ˅ ∼ q) ∧(p ˅ q) (by De Morgan’s laws) ∼(p∧q)≡ ∼ p∨ ∼ q
≡ (p ˅ ∼ q) ∧(p ˅ q) (by complement law) ∼ (∼ p)=p
≡ p ˅(∼ q ∧ q) (by distributive law) p∨(q∧r)≡(p∨q)∧(p∨r)
≡ p ˅(q ∧ ∼ q) (by the commutative law) p ∧ q ≡ q ∧ p
≡p˅F (by the Complement law) p ∧ ∼ p ≡ F
≡p (by the identity law) p∨F≡p
p q p˅q p→(p˅q)
T T T T
T F T T
F T T T
F F F T
Quantifiers
• x+3=5 -not a preposition if x=2,becomes a preposition.
• An assertion that contains 1 or more variables is called a Predicate.
• A predicate P containing n variables x1,x2….xn is called n-place predicate.
• E.g. x is a city in India - P(x)
• The values which the variables may assume constitute a collection or set called
as the Universe of discourse.
• When we specify a value for a variable appearing in a predicate, we bind that
variable.
• A predicate becomes a preposition only when all its variables are bound.
• Consider, P(x):x+3=5
• Let the Universe of discourse be set of all integers.
• Binding x=-1,we get False preposition. x=2 True preposition.
Quantifiers
• The second method of binding individual variables in a predicate is by Quantification
of variable.
• Types of Quantifiers-
• 1. Universal Quantifiers- If P(x) is a predicate with the individual variable x as an
argument, then the assertion ‘For all x P(x)’ is a statement in which the variable x is
said to be universally quantified.
• For all- ∀
• E.g. P(x)- predicate and x>=0 (integer), then the preposition ∀xP(x) is True.
But if x is any real number, then its False preposition.
2. Existential Quantifiers-Suppose, for predicate P(x), ∀xP(x) is false, but there exists
at lest 1 value of x for which P(x) is true, then we say that in this preposition, x is bound
by existential quantification.
There exists- ∃
∃x P(x) means there exists a value of x(in Universe of discourse) for which P(x) is true.
Examples- Let P(x,y) be a 2-phase predicate, then
∀y ∃x P(x,y)- For each value of y, there exists an x such that P(x,y) is true.
∃ y ∃x P(x,y)-There exists a value of x and a value of y such that P(x,y) is true.
∀y ∀ x P(x,y)- For all values of x and y, P(x,y) is true.
Rules of Inference for Prepositional Calculus
• In logical reasoning, some prepositions are assumed to be true and based on
those assumptions, other prepositions are inferred or derived.
• The prepositions that are assumed to be true are called Premises or hypotheses.
Example
Let P be the proposition, “He studies very hard” is true
Therefore − "Either he studies very hard Or he is a very bad student." Here Q is the proposition
“he is a very bad student”.
2. Conjunction
If P and Q are two premises, we can use Conjunction rule to derive P∧Q.
Example
Let P − “He studies very hard”
Let Q − “He is the best boy in the class”
Therefore − "He studies very hard and he is the best boy in the class"
3. Simplification
If P∧Q is a premise, we can use Simplification rule to derive P.
Example
"He studies very hard and he is the best boy in the class", P∧Q
Therefore − "He studies very hard“
4. Modus Ponens
If P and P→Q are two premises, we can use Modus Ponens to derive Q.
Example
"If you have a password, then you can log on to facebook", P→Q
"You have a password", P
Therefore − "You can log on to facebook"
5. Modus Tollens
If P→Q and ¬Q are two premises, we can use Modus Tollens to derive ¬P.
Example
"If you have a password, then you can log on to facebook", P→Q
"You cannot log on to facebook", ¬Q
Therefore − "You do not have a password "
6.Disjunctive Syllogism
If ¬P and P∨Q are two premises, we can use Disjunctive Syllogism to derive Q.
Example
"The ice cream is not vanilla flavored", ¬P
"The ice cream is either vanilla flavored or chocolate flavored", P∨Q
Therefore − "The ice cream is chocolate flavored”
7. Hypothetical Syllogism
If P→Q and Q→R are two premises, we can use Hypothetical Syllogism to derive P→R
Example
"If it rains, I shall not go to school”, P→Q
"If I don't go to school, I won't need to do homework", Q→R
Therefore − "If it rains, I won't need to do homework“
8. Constructive Dilemma
If (P→Q)∧(R→S) and P∨R are two premises, we can use constructive dilemma to derive Q∨S.
Example
“If it rains, I will take a leave”, (P→Q)
“If it is hot outside, I will go for a shower”, (R→S)
“Either it will rain or it is hot outside”, P∨R
Therefore − "I will take a leave or I will go for a shower"
9. Destructive Dilemma
If (P→Q)∧(R→S) and ¬Q∨¬S are two premises, we can use destructive dilemma to
derive ¬P∨¬R.
Example
“If it rains, I will take a leave”, (P→Q)
“If it is hot outside, I will go for a shower”, (R→S)
“Either I will not take a leave or I will not go for a shower”, ¬Q∨¬S
Therefore − "Either it does not rain or it is not hot outside"
• Test the validity of the following argument-
p⇒r
∼ p ⇒q
q ⇒s
∼r ⇒ s
∴
Solution-
p ⇒ r can be written as ∼r⇒∼p (If p → q, then ~ q → ~ p is called its Contrapositive)