Logic
Logic is the process by which we arrive at the conclusion from the given statement with the
valid reason.
Logic expressions are written in symbolic form.
Statement
An declarative sentence which is expressed in words, symbols, which is either true or false but
not both at same time, is known as a statement.
There are two types of statement:
Simple statement: A statement that declares only one thing
Compound statement: A statement that explains two or more than two things
Also a declarative sentence which has the property of being either true or false but not both simultaneously is
called a statement or proposition.
Thus a statement is a declarative sentence which has a truth value .
Moreover, not all declarative sentences are statements.
Statements are generally denoted by p,q,r,s...
Commands, requests, questionnaires or exclamations are examples of sentences that are not propositions or
statements.
Consider the following examples:
1. Kathmandu is the capital of Nepal.
2. An elephant is a small animal.
3. Give me the book.
4. Jiri is far away.
5. 5+2=7
6. 374 is a real number.
7. How old are you?
8. x+3=58.
9. x>0.
10. The sun rises in the west
A statement is said to be compound statement if it consists of other statements as components. In other words, a statement
is called compound statement if it can be separated into two or more components where each of which has a truth value.
A statement is called simple statement if it canot be so separated.
Let us consider some examples
a. Priya is a Nepali citizen.
b. All polygons are regular.
c. Some horses are black.
d. Seema went to Pokhara and Grishma went to Dharan.
Logical Connectives
Conjunction (AND)
We can join two statements by “AND” operand. It is also known as a conjunction.
Its symbolic form is “∧“. In this operator,
if anyone of the statement is false,then the result will be false.
If both the statements are true, then the result will be true.
It has two or more inputs but only one output.
The statement pɅq is true exactly when both p and q are true.
Example 1:Let p be the statement "It is raining" and q the statement "2+2=4". Then, pɅq denotes the statement "It is raining
and 2+2=4" is true.
Example 2: Let p be the statement "It is raining and q the statement "2+2=5". Then, pɅ[Link] the statement "It is raining
and 2+2=5" is [Link] truth values of pɅq can be summarized nicely by the following truth table:
Truth Table for Conjunction (AND)
Input Input Output
p q p AND q (p ∧ q)
T T T
T F F
F T F
F F F
Disjunction (OR)
We can join two statements by “OR” operand.
It is also known as disjunction. It’s symbolic form is “∨”.
In this operator, if anyone of the statement is true, then the result is true.
If both the statements are false, then the result will be false.
It has two or more inputs but only one output.
Truth Table for Disjunction (OR)
Input Input Output
p q p or q (p ∨ q)
T T T
T F T
F T T
F F F
Negation (NOT)
Negation is an operator which gives the opposite statement of the given
statement.
It is also known as NOT, denoted by “∼”.
It is an operation that gives the opposite result. If the input is true, then the
output will be false.
If the input is false, then the output will be true.
It has one input and one output.
The truth table for NOT is given below:
Input Output
P Negation P (∼P)
T F
F T
Conditional Statement(implication)
When a compound statement is formed by two simple statements,
connected with the phrase ‘if and then’, that is called conditional
operation,
where the conditional symbol is denoted by ‘⇒’. This symbol also
denotes as implies.
1. If two triangles are congruent then their areas are equal.
2. If a number 12 is divisible by 2 and 3 then it is divisible by 6.
3. If 4>3 then 2+3=4.
4. If is an integer then 3 > 2.
An implication is a statement of the form "if p then q", sometimes written as p→ q or p ⇒ q and read "p implies q" or if p
then q" or "q if p" or "p only if q".
The statement p associated with the word "if" is called the hypothesis, premise or antecedent and q associated with the
word "then" in called the conclusion or consequent of the implication.
The statement p ⇒ q is false only if the hypothesis p is true and the conclusion q is false and is true in all cases.
A class teacher says to his students:
"If you get A on the final exam, I will assign you letter grade A for the course."
Here, the hypothesis p is "You get A on the final exam" and the conclusion q is "teacher assigns grade A for the course".
The only case in which you have reason to be angry (the statement is false) is when p is true and q is false.
If both p and q are false, you may not be happy, but of course have no reason to be angry with your teacher.
Finally if p is false and q is true, you certainly willbe angry.
1. If two triangles are congruent then their areas are equal. P q p⇒q
2. If a number 12 is divisible by 2 and 3 then it is divisible by 6.
3. If 4>3 then 2+3=4. T T T
4. If is an integer then 3 > 2.
Truth table for implication or conditional is T F F
F T T
F F T
Bi-Conditional or Equivalence
When a compound statement is formed by two simple statements, connected with
the phrase ‘if and only if’, that is called bi-conditional operation, where the bi-
conditional symbol is denoted by ‘⇔’. It also indicated as an equivalent symbol.
The biconditional statement p ⇔ q is true when p and q have the same truth values,
otherwise it is false
Examples
p q p⇔q 1. The statement "Kathmandu is in Nepal iff 2+3=4", is false.
2. The statement "Kathmandu is in Nepal iff 2+3=5", is true.
T T T 3. The statement "Kathmandu is in Europe iff 2+3=7", is true.
4. The statement "Kathmandu is in Europe iff 2+3=5", is false.
T F F 5. 2+3=5 iff3-2=1, is true.
F T F
F F T
Tautology and Contradiction
Let x and y are two given statements. As per the definition of tautology, the compound statement
should be true for every value.
The truth table helps to understand the definition of tautology in a better way. Now, let us discuss how
to construct the truth table. Generally, the truth table helps to test various logical statements and
compound statements. The first part of the compound statement is symbolized in the first column of
the truth table. The second part of the compound statement, which is following the logical connector,
is symbolized in the second column. The logical connectors such as and, or, etc provide the meaning of
the compound statement. The third column of the truth table should contain the relationship between
the two statements. If every result in the third column is True (T), then the given compound statement
is a tautology.
Similarly If every result in the third column is False (F), then the given compound statement is a Contradiction.
p q p⇒q q⇒p Tautology = (p ⇒ q) ∨ (q ⇒ p) Contradiction = ~(p ⇒ q) ∨ (q ⇒ p)
T T T T T F
T F F T T F
F T T F T F
F F T T T F
Tautology – always true
P ~p P v ~p
T F T
F T T
Contradiction –always false
P ~p P ^~p
T F F
F T F
Contigency –Nither Tautology nor Contradiction
P ~p
T F
F T
If a function is differentiable,then the function is continuous.
If a function is continuous,then the function is differentiable.
If a function is not differentiable,then the function is not continuous.
If a function is not continuous,then the function is not differentiable.
If p→q is a conditional statement , then If x=5 ,then x2 ≠ 2
Converse :- q→ p If x2 ≠ 2, then x=5
Inverse :- ~p→~q If x≠5 ,then x2 = 2
Contrapositive :- ~q→~p If x2 = 2, then x≠ 5
Prove That the converse and inverse of the conditional statement are logically equivalent.
Sol: let p and q are two simple statements
p q p→q q→p ~p ~q ~p → ~q
T T T T F F T
T F F T F T T
F T T F T F F
F F T T T T T
Therefore, the converse and inverse of the conditional statement are logically
equivalent.
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
Since ,the truth value of p→q and ~q→~p is same.
So they are logically equivalent.
Mathematically, p→q ≡ ~q→~p
Construct the truth tables for the following statements.
a) (~p˄ q) c) ~q→(~p v ~q)
b) ~p v ~q d)(p→q)↔ (~pv q)
p q ~p (~p˄ q) p q ~p ~q ~p v ~q
T T F F T T F F T
T F F F T F F T T
F T T T F T T F F
F F T F F F T T T
Construct a truth table of (~p) v (pv q).
Also, is (~p) v (pv q) a tautology?
Sol:
p q ~p Pvq (~p) v (pv q)
T T F T T
T F F F T
F T T T T
F F T F T
Therefore, (~p) v (pv q) is a tautology.