0% found this document useful (0 votes)
15 views56 pages

CHAP-2 Prepositional and Predicate Logic

Uploaded by

kaurtarunpreet2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views56 pages

CHAP-2 Prepositional and Predicate Logic

Uploaded by

kaurtarunpreet2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 56

P R E P O S I T I O NA L A N D P R E D I C AT E L O G I C :

SYLLABUS
 Propositional logic,
 Truth tables,

 Normal forms (conjunctive and disjunctive),

 Validity of well-formed formula,

 Propositional inference rules,

 Predicate logic,

 Universal and existential quantifiers


PROPOSITION

 A proposition (or statement) is a declarative


statement which is true or false, but not both.
 Each proposition will be represented by a

propositional variable.
 Propositional variables are usually represented

as lower-case letters, such as p, q, r, s, etc.


 Each variable can take one of two values:

true or false.
PROPOSITION

(i) Ice floats in water.


(ii) China is in Europe.
(iii) 2 + 2 = 4
(iv) 2 + 2 = 5
(v) Where are you going?
(vi) Do your homework.
 The first four are propositions, the last two are

not.
 Also, (i) and (iii) are true,

but (ii) and (iv) are false.


A P P L I C AT I O N S O F P RO P O S I T I O NA L L O G I C
 Translation of English sentences

 Inference and reasoning:


 New true propositions are inferred from existing
ones
 Used in Artificial Intelligence:
 Rule based (expert) systems
 Automatic theorem provers

 Design of logic circuit


B A S I C L O G I C A L O P E R AT I O N S
 The three basic logical operations are
conjunction, disjunction, and negation which
correspond, respectively, to “and,” “or,” and “not.”
Logical NOT: ¬p Read “not p”
 ¬p is true if and only if p is false.
 Also called logical negation.

 p 𝖠 q is true if both p and q are true.


Logical AND: p 𝖠 q Read “p and q.”

 Also called logical conjunction.

 p ∨ q is true if at least one of p or q are


Logical OR: p ∨ q Read “p or q.”

true (inclusive OR)


 Also called logical disjunction.
B A S I C L O G I C A L O P E R AT I O N S

Some other representations


AND p & q, p ・ q or pq for p 𝖠
q
OR p + q for p ∨
q
N E G A T IO N p’  ̄ p or ∼ p for ¬
p
P R E C E D E N C E O F O P E R ATO RS
 Example: ¬ p 𝖠 q means (¬ p) 𝖠

p 𝖠 q → r means (p 𝖠 q) →
q

r
T RU T H T A B L E S
 A truth table is a table showing the truth value of
a propositional logic formula as a function of its
inputs.
 Implication

 The → connective is used to represent

implications.
 Its technical name is the material conditional

operator
T RU T H T A B L E S

N OT E : ¬ p 𝖠 q means ( ¬ p) 𝖠 q an d not ¬ (p 𝖠
q).
TAU T O L O G I E S
AND
CONTRADICTIONS
 TAU T O L O G I E S : Some propositions P(p, q, . . .)
contain only T (True) in the last column of their
truth tables or, in other words, they are true for
any truth values of their variables

 C O N T R A D I C T I O N S : if propositions P(p, q, . . .)
contains only F in the last column of its truth
table or, in other words, if it is false for any truth
values of its variables.
 Note: The negation of a tautology is a
contradiction since it is always false, and the
negation of a contradiction is a tautology since it
is always true.
TAU T O L O G I E S A N D
CONTRADICTIONS
PROVE
[(A→B)𝖠A]→B[(A→B)𝖠A]→B IS A
TAU T O L O GY
PROVE
(A∨B)𝖠[(¬A)𝖠(¬B)](A∨B)𝖠[(¬A)𝖠(¬B)]
IS A CONTRADICTION
CONTINGENCY
 A Contingency is a formula which has both some
true and some false values for every value of its
propositional variables.
 It is also said to be Satisfiable.

 Example − Prove (A∨B)𝖠(¬A) is a


contingency
INVERSE, CON VERS E , AND CONTRA-POSITIVE

 Implication / if-then (→) is also called a


conditional statement. It has two parts −
Hypothesis, p
Conclusion, q
As mentioned earlier, it is denoted as p
→ q
 Example of Conditional Statement −

“ If you do your homework, you will not be


punished.”
Here, "you do your homework" is the hypothesis,
p, and
"you will not be punished" is the conclusion, q.
 Inverse − An inverse of the conditional
statement is the negation of both the hypothesis
and the conclusion.
 If the statement is “If p, then q”, the inverse

will be “If not p, then not q”.


 Thus the inverse of p → q is ¬p →¬q.

 Example − The inverse of “If you do your


homework, you will not be punished” is
“If you do not do your homework, you will be
punished.”
 Converse − The converse of the conditional
statement is computed by interchanging
the hypothesis and the conclusion.
 If the statement is “If p, then q”, the converse will

be “If q, then p”. The converse of p → q is q → p.

 Example − The converse of "If you do your


homework, you will not be punished" is
"If you will not be punished, you do your
homework”.
 Contra-positive − The contra-positive of
the conditional is computed by interchanging
the hypothesis and the conclusion of the
inverse statement.
 If the statement is “If p, then q”, the

contra- positive will be “If not q, then not


p”.
The contra-positive of p → q is ¬q →
¬p. (1 inverse ¬p →¬q. ; 2
converse : ¬q → ¬p)
 Example − The Contra-positive of " If you do

your homework, you will not be punished” is


"If you are punished, you did not do your
homework”.
CONTRAPOSITIVES

 The proposition ¬ q → ¬ p is called the


Contrapositive of the proposition p → q.
 They are logically equivalent. p → q ≡ ¬ q → ¬ p
L O G I C A L E Q U I VA L E N C E
 Two propositions P(p, q, . . .) and Q(p, q, . . .) are
said to be logically equivalent, or simply
equivalent or equal, denoted by
P(p, q, . . .) ≡ Q(p, q, . . .)

¬ (p 𝖠 q) ≡ ¬ p ∨ ¬ q
if they have identical truth tables.
 E xample:
L O G I C A L E Q U I VA L E N C E
 Let p be “Roses are red” and q be “Violets are
blue.” Let S be the statement:
“It is not true that roses are red and violets
are

¬ (p 𝖠 q). However,, ¬ (p 𝖠 q) ≡ ¬ p ∨ ¬ q.
blue.” Then S can be written in the form

Accordingly, S has the same meaning as


the statement:
“Roses are not red, or violets are not blue.”
A L G E B R A O F P RO P O S I T I O N S
P RO O F O F A P RO P O S I T I O N
P RO V E (P 𝖠 Q ) → (P ∨ Q ) ≡
T.
(p 𝖠 q) → (p ∨ q) ≡ ¬(p 𝖠 q) ∨ (p ∨ q)

≡ (¬p ∨ ¬q) ∨ (p ∨ q) DeMorgan


Substitution for →

≡ (¬p ∨ p) ∨ (¬q ∨ q) Commutativity


and Associativity

Because ¬p ∨ p ≡ T
≡ T∨T

≡T
P R O V E (P → Q ) 𝖠 (P → R ) ≡ P → (Q 𝖠
R ).
¬ p ∨ (q 𝖠 r).
Note that, by “Substitution for →”, we have: R H S =

So, we start from the L H S and try to get this


proposition:

(p → q) 𝖠 (p → r) ≡ (¬ p ∨ q) 𝖠 (¬ p
∨ r)
Substitution

≡ ¬p ∨ (q 𝖠 r)
for → , twice

≡ p → (q 𝖠 r)
Distribution law
CONDITIONAL AND
B I C O N D I T I O N A L S TAT E M E N T S
 Conditional statements: “If p then q.” p→ q
 The conditional p → q is frequently read
 “p implies q” or “p only if q.”

The conditional p → q is false only when the
first part p is true and the second part q is false.
 When p is false, the conditional p → q is true
regardless of the truth value of q.
 Bi-conditional statements: “p if and only

if q.”
p↔q
 The bi-conditional p ↔ q is true whenever p and q

 A ↔ B is shorthand for (A → B) 𝖠 (B → A).


have the same truth values and false otherwise.
CONDITIONAL AND
B I C O N D I T I O N A L S TAT E M E N T S

equivalent to ¬ p ∨ q; that is, p → q ≡ ¬ p ∨


 Conditional Statement : p → q is logically

q
 “If p then q” is logically equivalent to the

statement “Not p or q”
L O G I C A L E Q U I VA L E N C E S
C O N S T R U C T I N G T H E T RU T H TA B L E

(p → q) 𝖠 (¬p ↔q)
 Example: Construct the truth table for
C O N S T R U C T I N G T H E T RU T H TA B L E
C O N S T R U C T I N G T H E T RU T H TA B L E
T R A N S L AT I N G L O G I C A L F O R M U L A S TO
ENGLISH SENTENCES
 Using the above logic operators, we can construct
more complicated logical formulas. (They are
called compound propositions.)
 Example;

Proposition p: Alice is
smart. Proposition q: Alice is

 ¬p 𝖠 q: Alice is not smart but


honest

 p ∨ (¬p 𝖠 q): Either Alice is smart, or she is


honest.

not smart but honest.


 p → ¬q: If Alice is smart, then she is not

honest.
T R A N S L AT I N G L O G I C A L F O R M U L A S F RO M
ENGLISH SENTENCES
 We can also go in the other direction, translating
English sentences to logical formulas:
Proposition p: Alice is
smart. Proposition q: Alice is
honest
 Alice is either smart or honest, but Alice is not

(p ∨ q) 𝖠 (p → ¬ q).
honest if she is smart:


Alice is smart is necessary and sufficient

(p → q) 𝖠 (q → p).
for Alice to be honest:

(This is often written as p ↔ q).


T R A N S L AT I O N
 Assume a sentence: If you are older than 13 or
you are with your parents then you can attend a
PG-13 movie.
 If ( you are older than 13 or you are with your

parents ) then ( you can attend a PG-13 movie)


 Propositions: –

A= you are older than 13


B= you are with your parents

 Translation: A ∨ B → C
C=you can attend a PG-13 movie
T R A N S L AT I O N :G E N E R A L RULE

 Look for patterns corresponding to logical


connectives in the sentence and use them to
define elementary propositions.
 Step 1: find logical connectives : if, and
You can have free coffee if you are senior
citizen
and it is a Tuesday
 Step 2: break the sentence into elementary

propositions
You can have free coffee (a) if you are
senior
citizen (b) and it is a Tuesday (c)
 Step 3: rewrite the sentence in propositional

logic
 Assume two elementary statements:
p: you drive over 65 mph ;
q: you get a speeding ticket
ARGUMENTS
 An argument is an assertion that a given set of
propositions P1, P2, . . . , Pn, called premises, yields
(has a consequence) another proposition Q, called
the conclusion.
 Such an argument is denoted by P1, P2, . . . , Pn | - Q

 An argument P1, P2, . . . , Pn | - Q is said to be valid


if Q is true whenever all the premises
 P1, P2, . . . , Pn are true.

 An argument which is not valid is called fallacy.


the proposition (P1 𝖠 P2 . . . 𝖠 Pn) → Q
 The argument P1, P2, . . . , Pn | - Q is valid if and only if

is a tautology.
Example: “If p implies q and q implies r, then p
implies r”
 That is, the following argument is valid:
 p → q, q → r | - p → r (Law of Syllogism)
EXAMPLE:
S 1 : If a man is a bachelor, he is
unhappy. S 2 : If a man is unhappy, he
dies young.

S : Bachelors die young

 p → q, q → r | - p→ r
 where p is “He is a bachelor,” q is “He is

unhappy” and r is “He dies young;”


 By Law of Syllogism the above

argument is valid.
PROPOSITIONAL FUNCTIONS,
Q UA N T I F I E R S
 A propositional function (or an open sentence or
condition) defined on A is an expression

false for each a ∈ A. That is, p(x) becomes a


p(x) which has the property that p(a) is true or

element a ∈ A is substituted for the variable x.


statement (with a truth value) whenever any

 The set A is called the domain of p(x), and the set

Tp of all elements of A for which p(a) is true is


called the truth set of p(x).

Tp = {x | x ∈ A, p(x) is true} or Tp = {x | p(x)}


 In other words,
U N I V E R S A L Q UA N T I F I E R
 Let p(x) be a propositional function defined on a

(∀x ∈ A)p(x) or ∀x p(x) which reads


set A. Consider the expression

“For every x in A, p(x) is a true statement”


or, simply, “For all x, p(x).”

 The symbol ∀ which reads “for all” or “for


every” is called the universal quantifier.
E X I S T E N T I A L Q UA N T I F I E R
Let p(x) be a propositional function defined on a

(∃x ∈ A)p(x) or ∃ x, p(x) which reads


set A. Consider the expression

“There exists an x in A such that p(x) is a true


statement” or, simply, “For some x, p(x).”


The symbol ∃ which reads “there exists” or
“for some” or “for at least one” is called the
existential quantifier
D UA L I T Y P R I N C I P L E

 Duality principle states that for any true


statement, the dual statement obtained by
interchanging unions into intersections (and vice
versa) and interchanging Universal set into Null
set (and vice versa) is also true.
 If dual of any statement is the statement itself, it

is said self-dual statement.


 Example − The dual of (A∩B)𝖴C is (A𝖴B)∩C
NORMAL FORMS
 Due to the problem of finding whether a given
statement is a tautology or contradiction or
satisfiable in a number of steps, is called
Decision Making.
 For decision problems, the construction of truth

tables may not be practical always. So we


consider alternate way known as reduction
to normal forms.
 2 normal forms are:

-- Disjunctive Normal Form (DNF)


-- Conjunctive Normal Form (CNF)
D I S J U N C T I V E N O R M A L F O R M (DNF)
 A compound statement is in disjunctive normal
form if it is obtained by operating O R among
variables (negation of variables included)
connected with ANDs.
 In terms of set operations, it is a compound

statement obtained by Union among variables

 D N F is an ∨ of 𝖠s; an 𝖠 of literals is called a


connected with Intersections.

(A𝖠B) ∨ (A𝖠C) ∨ (B𝖠C𝖠D)


term.

(P∩Q) 𝖴 (Q∩R)
 Example:
C O N J U N C T I V E N O R M A L F O R M (CNF)
 A compound statement is in conjunctive normal
form if it is obtained by operating A N D among
variables (negation of variables included) connected
with ORs.
 In terms of set operations, it is a compound
statement obtained by Intersection among variables
connected with Unions.
C N F is an 𝖠 of ∨s, where ∨ is over variables or
their negations (literals); an ∨ of literals is also

called (A∨B) 𝖠 (A∨C)


a clause.
𝖠(B∨C∨D)
 Example:

(P𝖴Q) ∩ (Q𝖴R)
F R O M T RU T H TA B L E TO D N F A N D C N F
 A minterm is a conjunction of literals in which
each variable is represented exactly once

variables (p,q,r)then p 𝖠 ¬q 𝖠 r is a minterm


 If a Boolean function (truth table) has the

but p𝖠 ¬q is not.

p 𝖠 ¬q 𝖠 r is true if p is true (1) , q is false (0)


 Each minterm is true for exactly one assignment.

and r is true (1).



Any deviation from this assignment would
make this particular minterm false.
 A disjunction of minterms is true only if at

least one of its constituents minterms is true.


F R O M T RU T H TA B L E TO D N F
 If a function, e.g. F, is given by a truth table, we
know exactly for which assignments it is true.

Consequently, we can select the minterms
that make the function true and form the
disjunction of these minterms.

 p, q, r are all true, (p 𝖠 q 𝖠 r )


 F is true for three assignments:

 p, ¬q, r are all true, ( p 𝖠 ¬q 𝖠 r )

 ¬p, ¬q, r are all true, (¬p𝖠 ¬q 𝖠 r)

 (p 𝖠 q 𝖠 r ) ∨ (p 𝖠 ¬q 𝖠 r ) ∨ (¬p𝖠 ¬q 𝖠 r)
 D N F of F:
F R O M T RU T H TA B L E TO C N F
 Complementation can be used to obtain
conjunctive normal forms from truth tables.

¬, ∨ and 𝖠 , then its complement is formed by


 If A is a formula containing only the connectives

replacing all ∨ by 𝖠
replacing all 𝖠 by ∨
replacing all atoms by their complements.
 The complement of q is ¬ q

 The complement of ¬ q is q

 Example: Find the complement of the formula

⚫ (p 𝖠 q) ∨ ¬ r ( ¬ p ∨ ¬ q) 𝖠 r
F R O M T RU T H TA B L E TO C N F
 Solution: ¬ G is true for the following
assignments.
 p = 1; q = 0; r = 1

 p = 1; q = 0; r = 0

 p = 0; q = 0; r = 1

(p 𝖠 ¬q 𝖠 r) ∨ ( p𝖠 ¬q 𝖠 ¬r) ∨ (¬p 𝖠
 The D N F of ¬ G is therefore:

¬q 𝖠 r)
 The formula has the complement:

(¬p ∨ q ∨ ¬r) 𝖠 (¬p ∨ q ∨ r) 𝖠 (p ∨ q


∨ ¬r) It is the desired C N F of G
T R A N S F O R M AT I O N I N TO CONJUNCTIVE
NORMAL FORM

 A literal is either a propositional variable, or the


negation of one.
Examples: p, ¬p.

Example: p ∨ ¬q ∨ r.
 A clause is a disjunction of literals.

 A formula in conjunctive normal form (CNF) is a

Example: (p ∨ ¬q ∨ r) 𝖠 (¬p ∨ ¬r).


conjunction of clauses.

 Similarly, one defines formulae in

disjunctive normal form (DNF) by swapping


¬(P → Q) ∨ (R → P)
TRANSFORM T H E F O L L O W I N G F O R M U L A I N TO C N F.

Express implication by disjunction and negation.


¬(¬p ∨ q) ∨ (¬r ∨ p)

 Push negation inwards by De Morgan’s laws and


double negation.
(p 𝖠 ¬q) ∨ (¬r ∨ p)
Convert to C N F by associative and distributive laws.
(p ∨ ¬r ∨ p) 𝖠 (¬q ∨ ¬r ∨ p)

 Optionally simplify by commutative and idempotent


laws.
(p ∨ ¬r) 𝖠 (¬q ∨ ¬r ∨ p)
By commutative and absorbtion
laws (p ∨ ¬r)

E X E RC I S E :
Q1. Let p be “It is cold” and let q be “It is raining”. Give
a simple verbal sentence which describes each of the

(b) p 𝖠 q (c) p ∨ q (d) q ∨ ¬ p.


following statements:

Q2. Verify that the proposition p ∨ ¬ (p 𝖠 q) is a


(a) ¬ p

Q3. Show that the propositions ¬ (p 𝖠 q) and


tautology.

¬ p ∨ ¬ q are logically equivalent.

¬ (p 𝖠 q) ∨ ( ¬ p 𝖠 q) ≡ ¬ p.
Q4. Check if its true or not

Q5. Consider the conditional proposition p → q. The simple


propositions q → p, ¬ p → ¬ q and ¬ q → ¬ p
are called, respectively, the converse, inverse, and
contrapositive of the conditional p → q.
Which if any of these propositions are logically
equivalent
to p → q?
E X E RC I S E :
Q6. Test the validity of the following argument:
If I study, then I will not fail mathematics.
If I do not play basketball, then I will study. But I
failed mathematics.
S O,
Therefore I must have played basketball

Q7. Prove the following argument is valid: p → ¬ q,


r → q, r | - ¬ p.
S O LU T I O N
A1. (a) It is not cold. (c) It is cold or it is raining.
(b) It is cold and raining. (d) It is raining or it is not cold.
A2. Y E S
A3. Y E S (F T T T)
A4. False
A5. Only the contra-positive ¬ q → ¬ p is logically equivalent
to the original conditional proposition p → q.
A6. Let p be “I study,” q be “I failed mathematics,” and r be “I
play basketball.” The argument has the form:p → ¬ q, ¬ r → p,
q | - r.
Construct the truth, where the premises p → ¬ q, ¬ r → p, and
q are true simultaneously only in the fifth line of the table,
and in that case the conclusion r is also true. Hence the
argument is valid.
A7. Here, p → ¬ q, r → q, and r are
true simultaneously only in the fifth row of the table, where
¬ p is also true. Hence the argument is valid.

You might also like