0% found this document useful (0 votes)
29 views

Unit 3 Basic Logic

This document discusses basic propositional logic including propositional variables, logical connectives like AND, OR and NOT, truth tables, conditional and biconditional statements, logical equivalences, and normal forms like disjunctive normal form and conjunctive normal form. It provides examples and explanations of key concepts in propositional logic.

Uploaded by

animeshrajak649
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Unit 3 Basic Logic

This document discusses basic propositional logic including propositional variables, logical connectives like AND, OR and NOT, truth tables, conditional and biconditional statements, logical equivalences, and normal forms like disjunctive normal form and conjunctive normal form. It provides examples and explanations of key concepts in propositional logic.

Uploaded by

animeshrajak649
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

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:
Correctness of a program, automated testing and program analysis
etc.
Propositional Logic
Ø Simplest logic is propositional logic.
Ø Building blocks of propositional logic are propositions.
Ø A proposition is a statement that is either true or false.
Ø Examples:
1. UCS405 is a course in discrete mathematics in TIET :- True
2. Patiala is located in Haryana :- False
3. Pay attention, Attend all lectures :- Not a proposition
4. x + y>4 :- Not a proposition
5. Earth is the only planet that contains life. –T/F
Propositional Variables
ØEach proposition will be represented by a propositional variable.
Ø Propositional variables are usually represented as lower-case letters, such as p,
p1, p2, q, etc.
Ø Each variable can take one of two values: true or false.
ØWhat is truth value of “India hosted 2019 ICC Cricket World Cup”?
False
ØA truth table is a table showing the truth value of a propositional logic formula
as a function of its inputs.
Logical Connectives
Ø Three basic logical connectives:
1. Logical NOT: ¬p (not p)
Also called logical negation.
2. Logical AND: p ∧ q (p and q)
Also called logical conjunction.
3. Logical OR: p ∨ q (p or q)
Also called logical disjunction
Ø Propositions formed using logical connectives are called compound propositions
Truth Table
p q ¬p pᴧq p∨q

T T F T T
T F F F T
F T T F T
F F T F F
Example: Construct a truth table for (p ∨ q) ∨ (¬ r)
Summary
ØPropositional Logic
ØPropositional Variables
ØBasic Logical Connectives
ØTruth Table
Basic Logic

2: Conditional and Biconditional


Statements
Conditional Statements
ØThe conditional statement p → q is the proposition “if p, then q.”
ØThe conditional statement p → q is false when p is true and q is false, and true
otherwise.
ØThe statement p → q is called a conditional statement because it asserts that q
is true on the condition that p holds.
ØA conditional statement has two parts, a hypothesis and a conclusion.
ØThe part after the “if” is the hypothesis, and the part after the “then” is the
conclusion
ØA conditional statement is also called an implication.
Expressing Conditional Statements
“if p, then q” “p implies q”
“if p, q” “p only if q”
“p is sufficient for q” “a sufficient condition for q is p”
“q if p” “q whenever p”
“q when p” “q is necessary for p”
“a necessary condition for p is q” “q follows from p”
“q unless ¬p”
Converse, Inverse and Contrapositive
ØConverse
ØThe converse of a conditional is formed by switching the hypothesis and
the conclusion.
ØThe converse of p → q is q → p
ØContrapositive
ØNegate the hypothesis and the conclusion of the converse
ØThe contrapositive of p → q, is ¬ q → ¬ p.
ØInverse
ØNegate the hypothesis and the conclusion
ØThe inverse of p → q, is ¬ p → ¬ q

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.”
Biconditional Statement
ØThe biconditional statement p ↔ q is the proposition “p if and only if q.”
ØThe biconditional statement p ↔ q is true when p and q have the same truth
values, and is false otherwise.
Ø Biconditional statements are also called bi-implications.
Truth Table
p q p→q p↔q

T T T T
T F F F
F T T F
F F T T

UCS405 "DISCRETE MATHEMATICAL STRUCTURES"


Example: Construct a truth table for the formula ¬pᴧ(p → q)
Summary
ØConditional Statement
ØConverse, Inverse and Contrapositive
ØBiconditional Statement
Basic Logic

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)))
Operator Precedence
Example 1
Ø Construct Truth Table of (p ∨¬q) → (p ∧ q).
Translating into Propositional Logic
General rule for translation:
ØStep 1 find logical connectives
ØStep 2 break the sentence into elementary propositions
ØStep 3 rewrite the sentence in propositional logic
Example 2
Ø If you are older than 18 or you are with your parents then you can
drive a two-wheeler.
ØAtomic (elementary) propositions:
a= you are older than 18
b= you are with your parents
c=you can drive a two-wheeler
ØTranslation: a ∨ b → c
Example 3
ØYou can have free coffee if you are senior citizen and it is a
Tuesday
ØAtomic (elementary) propositions:
a= You can have free coffee
b= you are senior citizen
c= it is a Tuesday

Ø Translation: b ᴧ c → a
Example 4
Ø Consider following propositional variables:
a: I will get up early this morning
b: There is a lunar eclipse this morning
c: There are no clouds in the sky this morning
d: I will see the lunar eclipse
ØConvert the following sentence in to propositional form:
“I won’t see the lunar eclipse if I don’t get up early this morning”
Translation: ¬a → ¬d
Example 5
Ø Consider following propositional variables:
a: I will get up early this morning
b: There is a lunar eclipse this morning
c: There are no clouds in the sky this morning
d: I will see the lunar eclipse
ØConvert the following sentence in to propositional form:
“If I get up early this morning, but it's cloudy outside, I won't see the lunar
eclipse.
Translation: a ∧ ¬c → ¬d
Example 6
Let us use the following propositions:
a: It is raining.
b: I will go to college.
c: The computers are broken.
d: I have a headache.
Expression English meaning
a∧d It is raining and I have a headache.
c → ¬b If the computers are broken then I will not go to college.
a ∨ d → ¬b If it is raining or I have a headache then I will not go to college.
Basic Logic

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
Example
Show that the statement (p Ú q) Ù [(¬p) Ù(¬q)] is contradiction
Logical equivalence
ØTwo propositions p and q are logically equivalent if their truth tables are the
same.
ØAlso, p and q are logically equivalent if p ↔ q is a tautology.
ØIf p and q are logically equivalent, we write p ≡ q.
Example
Look at the these two compound propositions: p → q and q ∨ ¬p
Example
ØProve ¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧ ¬q
¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧ ¬(¬p ∧ q) DeMorgan
≡ ¬p ∧ (p ∨ ¬q) DeMorgan
≡ (¬p ∧ p) ∨ (¬p ∧ ¬q) Distributivity
≡ F ∨ (¬p ∧ ¬q) Because ¬p ∧ p ≡ F
≡ ¬p ∧ ¬q Because F ∨r ≡ r for any r (Identity Law)
Example
Use the logical equivalences to show that ¬(p ∨ ¬(p ∧ q)) is a contradiction.
¬(p ∨ ¬(p ∧ q))
⇔ ¬p ∧ ¬(¬(p ∧ q)) De Morgan’s Law
⇔ ¬p ∧ (p ∧ q) Double Negation Law
⇔ (¬p ∧ p) ∧ q Associative Law
⇔F∧q Contradiction
⇔q∧F Commutative Law
⇔F Domination Law
Basic Logic

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.
Ø This is called the disjunctive normal form of a proposition.
ØExample
(A∧B)∨(A∧C)∨(B∧C∧D)
ØThe individual conjunctions that make up the disjunctive normal form are
called minterms.
Method to construct DNF
ØConstruct a truth table for the proposition.
ØUse the rows of the truth table where the proposition is True to
construct minterms
ØIf the variable is true, use the propositional variable in the minterm
ØIf a variable is false, use the negation of the variable in the minterm
ØConnect the minterms with ∨’s(OR’s).
Example
Find the disjunctive normal form for the proposition p → q

p q p→q p → q is true when either


T T T 1. p is true and q is true,
2. or p is false and q is true,
T F F
3. or p is false and q is false.
F T T
F F T

The disjunctive normal form is then (p ∧ q) ∨ (¬p ∧ q) ∨ (¬p ∧ ¬q)


Conjunctive normal form(CNF)/POS
ØConjunctive normal form of a proposition is the equivalent form that consists
of a “conjunction of disjunctions.”
ØExample
(A∨B)∧(A∨C)∧(B∨C∨D)
ØIf we want to get the conjunctive normal form of a proposition, construct the
disjunctive normal form of its negation and then negate again and apply De
Morgan’s Laws.
Example: Find the conjunctive normal form of the proposition (p∧¬q)∨r.
Solution:
(1) Negate: ¬[(p ∧ ¬q) ∨ r] ⇔ (¬p ∨ q) ∧ ¬r.
(2) Find the disjunctive normal form of (¬p ∨ q) ∧ ¬r:

p q r ¬p ¬r (¬p ∨ q) (¬p ∨ q) ∧ ¬r The disjunctive normal form for (¬p ∨ q) ∧ ¬r is


T T T F F T F
(p ∧ q ∧ ¬r) ∨ (¬p ∧ q ∧ ¬r) ∨ (¬p ∧ ¬q ∧ ¬r)
T T F F T T T
The conjunctive normal form for (p∧ ¬q)∨r is
T F T F F F F
then the negation of this last expression, which,
T F F F T F F
by De Morgan’s Laws, is
F T T T F T F (¬p ∨ ¬q ∨ r) ∧ (p ∨ ¬q ∨ r) ∧ (p ∨ q ∨ r).
F T F T T T T
F F T T F T F
F F F T T T T
Well Formed Formula
Ø Any expression that obeys the syntactic rules of propositional logic
is called a well-formed formula, or WFF
Ø The well-formed formulas of propositional logic are obtained by
using the construction rules below:
ØAn atomic proposition p is a well-formed formula.
ØIf p is a well-formed formula, then so is ¬p.
Ø If p and q are well-formed formulas, then so are p ∨ q , p ∧ q ,
and p → q.
Basic Logic

6:Propositional Inference Rules


Argument
ØIn mathematics, an argument is a sequence of propositions (called premises)
followed by a proposition (called conclusion)
ØA valid argument is one that, if all its premises are true, then the conclusion is
true
Ø Ex: “If it rains, I drive to school.”
“It rains.”
∴ “I drive to school.”
Ø Rules of inference are templates for building valid arguments
Valid Argument Form
ØIn the previous example, the argument belongs to the following form:
p→q
p
∴q
Ø 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
Basic Logic

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
Predicate
ØA predicate is a statement that contains variables (predicate variables) and that
may be true or false depending on the values of these variables.
Example: P(x) = “x2 is greater than x” is a predicate
ØThe domain of a predicate variable is the collection of all possible values that
the variable may take.
e.g. the domain of x in P(x): integer
ØPredicate logic is an extension of Propositional logic.
ØIt adds the concept of predicates and quantifiers to better capture the meaning
of statements that cannot be adequately expressed by propositional logic.
Example
ØLet P(x, y) = “x > y”.
Domain: integers, i.e. both x and y are integers.
Ø P(4, 3) means “4 >3”, so P(4, 3) is TRUE;
ØP(1, 2) means “1>2” , so P(1, 2) is FALSE;
ØP(3,4) is false (in general, P(x, y) and P(y, x) not equal).
Quantifiers
Ø The variable of predicates is quantified by quantifiers.
Ø There are two types of quantifier in predicate logic −
1. Universal Quantifier
2. Existential Quantifier.
Universal Quantifiers
ØUniversal quantifier states that the statement within its scope is true for every
value of the specific variable.
Ø It is denoted by the symbol ∀.
Ø∀x P(x) is read as for every value of x, P(x) is true.
ØExample: Let P(x) denote x > x - 1.
What is the truth value of ∀x P(x) ?
Assume the universe of discourse of x is all real numbers.
Answer: Since every number x is greater than itself minus 1.
Therefore, ∀x P(x) is true
Existential quantifier
ØExistential quantifier states that the statement within its scope is true for some
values of the specific variable.
ØIt is denoted by the symbol ∃.
Ø∃x P(x) is read as for some values of x, P(x) is true.
ØExample Let T(x) denote x > 5 and x is from Real numbers.
Ø What is the truth value of ∃ x T(x)?
Ø Answer: Since 10 > 5 is true.
ØTherefore, it is true that ∃ x T(x).
Nested Quantification
ØA proposition can have multiple quantifier
– “All rabbits are faster than all tortoises.”
– Domains: R={rabbits}, T={tortoises}
– Predicate C(x, y): Rabbit x is faster than tortoise y
ØIn symbols
∀x ∈ R, ∀y ∈ T, C(x,y)
Ø In words
– For any rabbit x, and for any tortoise y, x is faster than y.
Truth Value of Quantified Statements
Statement When True When False
∀x ∈ D,P(x) P(x) is true for every x. There is one x for which
P(x) is false.
∃x ∈ D,P(x) There is at least one x for P(x) is false for every x.
which P(x) is true.
Negation of Quantification
ØNegation of a universal quantification becomes an existential quantification.
¬ (∀x ∈ D,P(x)) ≡ ∃x ∈ D, ¬P(x)
ØExample:
Not all students study hard ≡ There is at least one student who do not
study hard
ØNegation of an existential quantification becomes an universal quantification.
¬ (∃x ∈ D, P(x)) ≡ ∀x ∈ D, ¬ P(x)
ØExample:
It is not the case that some students in this class are from Jaipur≡ All
students in this class are not from Jaipur
Contd..
ج (∀x ∈ D,P(x) ∧ Q(x))
≡ ∃x ∈ D, ¬(P(x) ∧ Q(x)) (Negation of Quantification)
≡ ∃x ∈ D,( ¬P(x) ∨ ¬Q(x)) (DeMorgan Law)

Ø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)
Summary of Session
ØPropositional Logic
ØLogical Connectives
ØTruth tables
ØLogical Equivalences
ØNormal Forms
ØPropositional inference rules
ØPredicate Logic

You might also like