Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

LOGIC

UNIT 1: LOGIC AND PROOFS

Learning Objectives:

At the end of this unit, the students will be able to

• Learn the basic theory behind propositional logic.


• Perform the logical operations on propositions.
• Derive the truth tables for different propositions.
• Perform symbolic analysis of Predicates and Quantifiers
• Prove the logical statements.

1.1 Introduction

Logic is the basis of all mathematical reasoning.

Practical Applications of logic are:


– Design of computing machines
– Artificial Intelligence
– Computer Programming
– Many fields of study

Logic is categorized into,


– Propositional Logic
– Predicate Logic

1.2 Propositional Logic

1.2.1 Propositions

A proposition is a declarative sentence that is either true or false, but not both.

All the following declarative sentences are propositions.

1. Washington, D.C., is the capital of the USA.


2. 2 + 2 = 3
3. 1 + 2 = 3

Propositions 1 and 3 are true, whereas 2 is false.

MDIS-DIT Page 1- 1 Mathematics for computing


LOGIC

The following are NOT propositions:

1. “Who’s there?” (interrogative, question)


2. “Just do it!” (imperative, command)
3. “x+1 = 2” (expression with a non-true/false value)

The truth value of a proposition is either true or false denoted by T or F.

1.2.2 Logical operators

An operator or connective combines one or more operand expressions into a larger expression.
– (E.g., “+” in numeric expressions.)
Unary operators take 1 operand
– (e.g., -3);
Binary operators take 2 operands
– (eg 3  4).
Propositional or Boolean operators operate on propositions or truth values instead of numbers.
The Negation Operator

The unary negation operator “¬” (NOT) transforms a proposition into its logical negation.

Example:
If p = “Today is Friday.”
then ¬p = “Today is not Friday.”

Truth table for NOT:

p p
T F
F T
The Conjunction Operator

The binary conjunction operator “” (AND) combines two propositions to form their logical
conjunction.

Example:

If p=“I will have salad for lunch.”


and q=“I will have steak for dinner.”,
then pq=I will have salad for lunch and I will have steak for dinner.

Note: In logic, the word “but” is sometimes used instead of “and” in a conjunction.

MDIS-DIT Page 1- 2 Mathematics for computing


LOGIC

Conjunction Truth Table p q pq


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

The Disjunction Operator

The binary disjunction operator “” (OR) combines two propositions to form their logical
disjunction.

Example:
p=“That car has a bad engine.”
q=“That car has a bad carburetor.”
pq=Either that car has a bad engine or that car has a bad carburetor.

Disjunction Truth Table


p q pq
F F F
F T T
T F T
T T T
Note: pq means p is true or q is true or both are true. Hence this operator is called “inclusive”.

“¬” , “”, “” together are universal.

The Exclusive Or Operator

The binary exclusive-or operator “ ” (XOR) combines two propositions to form their logical
“exclusive or” (exjunction?).
Example:
p = “I will earn an A in this course,”
q = “I will drop this course,”
p  q = “I will either earn an A for this course, or I will drop it (but not both!)”

Exclusive-Or Truth Table


p q pq
F F F
F T T
T F T
T T F
MDIS-DIT Page 1- 3 Mathematics for computing
LOGIC

Note: pq means that p is true, or q is true, but not both!

• “¬” and “” together are not universal.

The Implication Operator

The implication p  q states that p implies q. It is FALSE only in the case that p is TRUE but q
is FALSE.

Example: p=“I am elected.”


q=“I will lower taxes.”
p  q = “If I am elected, then I will lower taxes” (else it could go either way)

Implication Truth Table


p q pq
F F T
F T T
T F F
T T T
Note:
• p  q is false only when p is true but q is not true.
• p  q does not imply that p causes q!
• p  q does not imply that p or q are ever true!

E.g. “(1=0)  pigs can fly” is TRUE!

Inverse, Converse, Contrapositive

Some terminology:

• The inverse of p  q is: ¬ p  ¬q


• The converse of p  q is: q  p.
• The contrapositive of p  q is: ¬q  ¬ p.

The biconditional operator

The biconditional p  q states that p is true if and only if (IFF) q is true. It is TRUE when both
p  q and q  p are TRUE.

p = “It is raining.”
q = “The home team wins.”

MDIS-DIT Page 1- 4 Mathematics for computing


LOGIC

p  q = “If and only if it is raining, the home team wins.”

Biconditional Truth Table


p q pq
F F T
F T F
T F F
T T T
Note: p  q means that p and q have the same truth value.
p  q means ¬(p  q)
p  q does not imply p and q are true, or cause each other.

Boolean Operations Summary

p q p pq pq pq pq pq


F F T F F F T T
F T T F T T T F
T F F F T T F F
T T F T T F T T
1.3 Precedence of Logical Operators

Operator Precedence

MDIS-DIT Page 1- 5 Mathematics for computing


LOGIC

1.4 Tautologies and Contradictions

• A tautology is a compound proposition that is true no matter what the truth values of its
atomic propositions are!
Eg.,
p  p [What is its truth table?]
• A contradiction is a compound proposition that is false no matter what!
Eg.,
p  p [Truth table?]

1.5 Propositional Equivalence

Two syntactically (i.e., textually) different compound propositions may be semantically identical
(i.e., have the same meaning). We call them equivalent.

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.

1.6 Proving Equivalence via Truth Tables

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

p q pq p q p  q (p  q)


F F
F T T T F
F T T T F F T
T F
T F T F T
T T
T F F F T
1.7 Equivalence Laws

MDIS-DIT Page 1- 6 Mathematics for computing


LOGIC

• 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

1.8 Translating English sentences


How can this English sentence be translated into a logical expression?

“You can access the Internet from campus only if you are a computer science major or you are
not a freshman.”

Let a, c, and f represent “You can access Internet from campus,” “You are a computer science
major,” and “You are a freshman,” respectively.

This sentence can be represented as  f).

1.9 Predicate Logic

The symbolic analysis of predicates and quantified statements is called the predicate calculus.

The sentence “He is a college student” is not a statement because it may be either true or false
depending on the value of the pronoun he.

Similarly, the sentence “x + y is greater than 0” is not a statement because its truth value depends
on the values of the variables x and y.

In grammar, the word predicate refers to the part of a sentence that gives information about the
subject. In the sentence “James is a student at Bedford College,” the word James is the subject
and the phrase is a student at Bedford College is the predicate. The predicate is the part of the
sentence from which the subject has been removed.

In logic, predicates can be obtained by removing some or all of the nouns from a statement.

For instance, let P stand for “is a student at Bedford College” and let Q stand for “is a student at.”
Then both P and Q are predicate symbols. The sentences “x is a student at Bedford College” and
“x is a student at y” are symbolized as P(x) and as Q(x, y) respectively, where x and y are
predicate variables that take values in appropriate sets.

MDIS-DIT Page 1- 7 Mathematics for computing


LOGIC

Exercises

1) Which of these are propositions? What are the truth values of those that are propositions?

a) Do not pass go.


b) What time is it?
c) 4 + x = 5.
d) The sun rises in the west.
e)

2) What is the negation of these propositions?

a) Today is Thursday.
b) There is no pollution in New Jersey.
c) 2+1=3

3) Let p and q be the propositions


p: I am happy.
q:I won a jackpot last Friday.
Express each of these propositions as an English sentence:
a) p
b) q
c) pq
d) pq
e) pq
f) p  q
g) pq
h) p( pq)

4) Let p and q be the propositions


p: You drive over 65 miles per hour.
q: You get a speeding ticket.
Write these propositions using p and q as logical connectives.
a) You do not drive over 65 miles per hour.
b) You drive over 65 miles per hour, but you do not get a speeding ticket.
c) If you drive over 65 miles per hour, then you will get a speeding ticket.
d) If you do not drive over 65 miles per hour, then you will not get a speeding ticket.
e) You will get a speeding ticket, if and only if you are driving over 65 miles per hour.
f) Either you get a speeding ticket, or you do not drive over 65 miles per hour.
g) Either you get a speeding ticket or you are driving over 65 miles per hour, and you do
not drive over 65 miles per hour or you will get a speeding ticket .

5) State the converse, contra positive and inverse of the following conditional statements.

MDIS-DIT Page 1- 8 Mathematics for computing


LOGIC

a) If it snows tonight, then I will stay at home.


b) If it rains, then the home team wins.

6) Construct a truth table for each of these compound propositions.


a) p  q
b) (  q)  (pq)
c) (pq)  r
d) (p  q)  (p  r )
e) (p  q)  (q  p )

7) Show that each of these statements is a tautology by using truth tables.


a)  (  q)] q
b) ( q)] q
c) [(pq) (qr)] (pr)

8) Show that p  q and q  p are logically equivalent.

9) Show that (p  q)  (p  r ) and p  (q  r ) are logically equivalent.

10) Show that (p  q )  r and (p  r)  (q  r ) are not equivalent.

MDIS-DIT Page 1- 9 Mathematics for computing

You might also like