Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 31

The Foundations: Logic and Proofs

Srikrishnan Divakaran
School of Engineering and Applied Sciences
Ahmedabad University
Content

1. Propositional Logic

2. Propositional Equivalences

3. Predicates and Quantifiers

4. Nested Quantifiers

5. Rules of Inference

6. Introduction to Proofs
What is a Proposition?

A proposition is a declarative sentence that is either True or False but not both

Examples: 2+2=4 True


2 +2 = 3 False

Gandhinagar is the capital of India


Today is Tuesday.

Non-examples: x+1 = 2

What time is this?


Logic Operator (Negation)
Logic operators are used to construct compound propositions from simple
propositions. There are three main logic operators, NOT, AND, OR.

Definition: Let P be a proposition. The negation of P denoted by ⌐P is the


Statement “It is not the case that p”.

Example: Let p be the proposition “Today is Friday”. Then the proposition


⌐P is “Today is not Friday”

P ⌐P
T F
F T
Logic Operator (AND)

Definition: Let p and q be propositions. The conjunction of p and q denoted by


pq pq
. The conjunction is true when both p and q are True and is
False otherwise.
pq
Example: Let p: “Today is Friday” and q: “It is raining today”. Then is
The proposition “Today is Friday and It is raining today”.

P Q p^q
T T T
T F F
F T F
F F F
Logic Operator (OR)

Definition: Let p and q be propositions. The disjunction of p and q denoted by


pq pq
. The conjunction is true when both p and q are True and is
False otherwise.
pq
Example: Let p: “Today is Friday” and q: “It is raining today”. Then is
The proposition “Today is Friday or It is raining today”.

P Q pq
T T T
T F T
F T T
F F F
Logic Operator (Exclusive OR)

Definition: Let p and q be propositions. The exclusive or of p and q denoted by


pq pq
. The conjunction is true when both p and q are True and is
False otherwise.
pq
Example: Let p: “Today is Friday” and q: “It is raining today”. Then is
The proposition “Either Today is Friday or It is raining today”.

P Q pq
T T F
T F T
F T T
F F F
Conditional Statement (Implication)

Definition: Let p and q be propositions. The conditional statement p  q is


the proposition “if p then q”. The conditional statementp  q is false
pq
when p is true and q is false, and true otherwise. In the conditional statement
p is called the hypothesis and q is called the conclusion.

Example: Let p: “Maria learns Discrete Mathematics” and q: “Maria will find a
good job”. Then p  q is the proposition “If Maria learns discrete
mathematics then she will find a good job”.

P Q pq
T T T
T F F
F T T
F F T
Different ways of expressing Implication

Definition: Let p and q be propositions. The conditional statement p  q can


be expressed in the following ways:

“p implies q”, “if p then q”, “p is sufficient for q”, “q is necessary for p”, “q
follows from p”, “q unless ~p”,
“p only if q” = p cannot be true when q is not true.
Converse, Contra-positive and Inverse

Definition: The proposition q  p is called the converse of p  q . The


contra-positive of p  q is the proposition q  p . The proposition
p  q is called the inverse of p  q .

Notice that q  p has the same truth values as p  q and similarly


p  q has the same truth value as q  p .

Definition: When two compound propositions have the same truth value we
call them equivalent.

Example: p  q  q  p

q  p  p  q
Bi-conditional Statement

Definition: Let p and q be propositions. The bi-conditional statement p  q


Is the proposition “p if and only if q”. The bi-conditional statement p  q is
True when p and q have the same truth values.

Example: Let p: “You can take the flight” and q: “You buy a ticket”. Then
pq is the proposition “You can take the flight if and only if you buy a
ticket”.

P Q pq
T T T
T F F
F T F
F F T
Different ways of expressing Double Implication

Definition: Let p and q be propositions. The bi-conditional statement p  q


can be expressed in the following ways:

“p necessary and sufficient for q”, “if p then q and conversely”, “p iff q”.
Equivalent Expression for Exclusive-Or

p q p  q p  q p  q ( p  q )  (p  q )
T T F F F F
T F T T F T
F T T F T T
F F F F F F

Logical equivalence: Two boxed logical expressions have the same truth table.
There are many different ways of writing the same logical expression.
Logical Expression Corresponding to a bit adder

Digital logic:

Given a digital circuit, we can easily construct the truth table. However, if we
Know the truth table, can we construct the logical expression corresponding to
That truth table.
Logical Expression Corresponding to a bit adder

P Q Sum pq carry pq


1 1 0 1
1 0 1 0
0 1 1 0
0 0 0 0

Given a digital circuit, we can easily construct the truth table. However, if we
Know the truth table, can we construct the logical expression corresponding to
That truth table.
Writing Logical Expression for a Truth Table

Idea 1: Look at the true rows and take the “or”.

p q r output
T T T F
T T F T
T F T T
T F F F
F T T T
F T F T
F F T T
F F F F

The formula is true exactly when the input is one of the true rows.
Writing Logical Expression for a Truth Table

Idea 1: Look at the false rows negate and take the “and”.

p q r output
T T T F
T T F T
T F T T
T F F F
F T T T
F T F T
F F T T
F F F F

The formula is true exactly when the input is not one of the false row.
Logic Puzzles
Puzzle 1: In an island there are two kinds of inhabitants, knights, who
always tell the truth and knaves, who always lie. You encounter two
people A and B. what are A and B if A says “B is a knight” and B says “the
two of us are opposite types”?

Let Statement 1: B is a knight.


Statement 2: A and B are of opposite type.

A B Statement 1 Statement 2
Knight Knight T F
Knight Knave F T
Knave Knight F T
Knave Knave F T
Tautology, Contradiction and Contingency

Definition: A compound proposition that is always true, no matter what the


truth values of the propositions that occur in it, is called a tautology. A
compound proposition that is always false is called a contradiction. A
compound proposition that is neither a tautology nor a contradiction is called a
contingency.

Examples: p  p Tautology
p  p Contradiction
Logical Equivalences

Definition: Compound propositions p and q are logically equivalent to each


other iff p and q contain the same truth values as each other in all rows of their
truth tables.

Compound proposition p is logically equivalent to compound proposition q,


written pq, iff the compound proposition pq is a tautology

Example: Prove that pq  (p  q).


Logical Equivalences
• Identity: pT  p pF  p
• Domination: pT  T pF  F
• Idempotent: pp  p pp  p
• Double negation: p  p
• Commutative: pq  qp pq  qp
• Associative: (pq)r  p(qr)
(pq)r  p(qr)
• Distributive: p(qr)  (pq)(pr)
p(qr)  (pq)(pr)
• De Morgan’s:
(pq)  p  q
(pq)  p  q
• Absorption:
p(pq)  p
p (p  q)  p
Equivalences for Logical Operators
• Implication: pq  p  q
• Biconditional: pq  (pq)  (qp)
pq  (pq)
• Exclusive or: pq  (pq)(pq)
pq  (pq)(qp)
Propositional Functions
Predicate logic is an extension of propositional logic that permits
propositions to be stated in terms of variables. Such propositional
functions are neither true or false when the values of the variables are
not specified.

Example: “x>1”, “x+y=10”

The propositional function P(x): “x is greater than 3” has two parts:

 “x ” denotes the subject - the object or entity that the sentence is


about.;
 “is greater than 3” denotes the predicate- a property that the
subject can have.
 P(5) is true whereas P(2) is false
Quantifiers
Example: Given a propositional function P(x)=“x+1>x”, the collection of
values that a variable x can take is called x’s universe of discourse. In this
example, we could define the course of universe as the set of integers.

Quantifiers allows us to compactly represent the predicate over a range


of elements in its universe of discourse.

Definition: The universal quantification of P(x) is the statement “P(x) for


all values in its domain/universe of discourse”. The notation xP(x)
Denotes the universal quantification of P(x). Here  is called the
universal quantifier. We read xP(x) as “for all x P(x)” or “for every x
P(x)”. An element for which P(x) is false is called a counterexample of
xP(x) .
Example: For P(x) : “x + 1 > x”, xP(x) is true.
For Q(x) : “x > 5 and x  Z “, xQ(x) is false since
Q(4)
is false.
Quantifiers
Example: What does the statement xP(x) , where P(x) is “Computer x
is connected to the network” and the domain consists of all computers
on campus.

xP(x) means that every computer on campus is connected to the


network.

Definition: The existential quantification of P(x) is the proposition “There


exists an element x in the domain such that P(x)”. We use the notation
xP(x) for the existential quantification of P(x). Here  is called the
existential quantifier.

Example: For P(x) : “x + 1 < x”, xP(x) is false.


For Q(x) : “x > 5 and x is an integer“, is true since Q(6)
is true.
Equivalence Rules for Quantifiers
If domain for x is = a,b,c,…

x P(x)  P(a)  P(b)  P(c)  …


x P(x)  P(a)  P(b)  P(c)  …

Using Demorgan’s law, we can prove the following laws:

x P(x)  x P(x)


x P(x)  x P(x)

x P(x)  x  P(x)


x P(x)  x  P(x)

x y P(x,y)  y x P(x,y)
x y P(x,y)  y x P(x,y)

x (P(x)  Q(x))  (x P(x))  (x Q(x))


x (P(x)  Q(x))  (x P(x))  (x Q(x))
Translating from English into Logical Expressions
Example: Express the statement “Every student in this class has studied
calculus” using predicates and quantifiers.

The domain for x is the set of all students in AU. Let


C(x): x is a student of the class MAT102.
S(x): x has studied calculus.
x(c( x)  s ( x))
Example: Express the statements “Some student in this class has visited
Mexico” and “Every student in this class has visited either Canada or
Mexico” using predicates and quantifiers.

The domain for x is the set of all students in AU. Let


S(x): x is a student of the class MAT102.
M(x): x has visited Mexico.
C(x): x has visited Canada.
x( s ( x)  M ( x)) and x ( s ( x)  (C ( x )  M ( x )))
Nested Quantifiers
Example: Let Q ( x, y ) denote “x + y = 0”. What are the truth values of
the quantifications
1. yxQ( x, y )
2. xyQ( x, y )
yxQ( x, y ) : There exists an y such that for all y x+ y = 0 is False

xyQ( x, y ) : For all x there exists a y such that x + y = 0 is True

Example: Translate the following statements


1. “The sum of two positive integers is always positive”.
2. “Every real number except zero has a multiplicative inverse”.
Translating from Nested Quantifiers into English
Example: Let C(x): “x has a computer”, F(x, y): “x and y are friends”,
where the domain of x and y are all students in AU. Translate the
statement

x(C ( x)  y (C ( y )  F ( x, y )))

Example: Let F(a,b): “a and b are friends”. Let x, y and z are variables
whose domain consists of all students at AU. Translate the statement

xyz (( F ( x, y )  F ( x, z )  ( y  z ))  F ( y, z ))
Translating English sentences into Logical Expressions
Example: Express the statement “If a person is female and is a parent,
then this person is someone’s mother”.

Let F(x): x is a female, P(x): x is a parent and M(x,y): x is the mother of y.


Then the above statement can be logically expressed as follows:
x(( F ( x)  P( x))  yM ( x, y ))

Example: Express the statement “Everyone has exactly one best friend”.

Let B(x,y): y is the best friend of x. Then the above statement can be
logically expressed as follows:
xy ( B( x, y )  z ( y  z ))  B ( x, z )
Acknowledgements
1. Introduction to Discrete Mathematics, Lectures of Prof. Lap Chi Lau,
Chinese University of Honk Kong.
2. Mathematics for Computer Science, Lectures of Prof. Tom Leighton,
MIT open courseware.
3. Discrete Mathematics and its Applications, Kenneth Rosen, 6th
edition, McGraw Hill Publishing.

You might also like