Sei sulla pagina 1di 21

Housekeeping

Tutorial sheet 2 is now available.


Assignment 1 is due at the beginning of your support class next week.

MAT1830

Lecture 5: Tautologies and logical equivalence

John Stillwell
The main problem of logic is to recognise
sentences that are logically true, that is, true
under all interpretations. In propositional
logic, such sentences are called tautologies.

5.1

Tautologies

A sentence in propositional logic is a formula with variables p, q, r, . . . which can take


the values T and F. The possible interpretations of are all possible assignments of
values to its variables. This means we can
check whether is a tautology by computing its value for all possible values of its variables.
Example. (p) = (p) p
For p = T we have
(T) = (T) T = F T = T,

One of the biggest


logic and computer s
ficient algorithm for

5.2

Logical equ

Sentences and ar
they are the same tru
means is a ta
between sentences is
.
Example. p q
We know that p q
p
T
T
F
F

q
T
F
T
F

and (p) q has the

ables.
p
T
T
F
F

Example. (p) = (p) p


For p = T we have
(T) = (T) T = F T = T,

and (p) q has the

using the known values of the and functions.


For p = F we have

(T) T =
(T) F =
(F) T =
(F) F =

(F) = (F) F = T F = T,
hence (p) p is a tautology. (It is known
as the law of excluded middle.)

It follows from this


be rewritten as (p)
functions can be exp
and , so it is enoug
involving just , a
This is like finding
one uses known equ
expand and simplify.

can similarly compute the values of


5. Tautologies andanyWe
Logical
Equivalence
truth function , so this is an algorithm
for recognising tautologies.
However, if has n variables, they have 2n
John Stillwell

logic is to recognise
lly true, that is, true
ns. In propositional
e called tautologies.

sets of values, so the amount of computation


grows rapidly with n.

One of the biggest unsolved problems of


logic and computer science is to find an efficient algorithm for recognising tautologies.

5.2

Logical equivalence

q
T
F
T
F

If Stuart Broad is limping and Ian Bell is looking grumpy, then England
are losing the cricket match.
p: Stuart Broad is limping.
q: Ian Bell is looking grumpy.
r : England are losing the cricket match.
(p q) r
p could be T or F, q could be T or F, and r could be T or F.
So there are 2 2 2 = 8 ways to assign truth values to this statement.
Thats why there would be eight rows in the truth table.

Question How many ways are there to assign truth values to the
following statement?
((p1 p2 ) ((p3 p4 ) p1 )) (p2 p5 )
2 2 2 2 2 = 32
Question 5.1 There are two possibilities for each of the variables and
this gives a total of 2 2 2 = 2n possibilities.

John Stillwell

f logic is to recognise
ally true, that is, true
ons. In propositional
re called tautologies.

One of the biggest unsolved problems of


logic and computer science is to find an efficient algorithm for recognising tautologies.

5.2

sitional logic is a forq, r, . . . which can take


he possible interpreossible assignments of
This means we can
autology by computsible values of its vari-

)p

T = F T = T,

s of the and func-

Logical equivalence

Sentences and are logically equivalent if


they are the same truth function, which also
means is a tautology. This relation
between sentences is written as or
.
Example. p q (p) q
We know that p q has the truth table
p
T
T
F
F

q
T
F
T
F

pq
T
F
T
T

and (p) q has the same table because

This means we can


autology by computble values of its vari-

p
= F T = T,

of the and func-

= T F = T,

tology. (It is known


middle.)

mpute the values of


this is an algorithm
ies.
riables, they have 2n
ount of computation

Example. p q (p) q
We know that p q has the truth table
p
T
T
F
F

q
T
F
T
F

pq
T
F
T
T

and (p) q has the same table because


(T) T = F T = T,
(T) F = F F = F,
(F) T = T T = T,
(F) F = T F = T.
It follows from this that p q can always
be rewritten as (p) q. In fact, all truth
functions can be expressed in terms of ,
and , so it is enough to find equivalences
involving just , and .
This is like finding identities in algebra
one uses known equivalences to rearrange,
expand and simplify.

Why should p q mean the same as p q?


If you train hard, then youll finish the marathon.
You wont train hard or youll finish the marathon.
If thats a lion, then were dead.
Thats not a lion or were dead.

The expression
x 3 3x 2 + 3x + 1 x 3 x

(x 1)4
x +1

is actually the same as the expression


x

(for x 6= 1, 1), but the second expression is nicer.

Similarly
((p (p q)) (p q)) (p q)
is logically equivalent to

q.

5.3

Useful equivalences

The following equivalences are the most frequently used in this algebra of logic.
Equivalence law
p q (p q) (q p)
Implication law
p q p q
Double negation law
p p
Idempotent laws
ppp
ppp
Commutative laws
pq qp
pq qp
Associative laws
p (q r) (p q) r
p (q r) (p q) r
Distributive laws

Remarks

1. The commutative
range terms, as in or
p q q p is like p
algebra, and p q
2. The associative
brackets. Since p (
can write either side
is like p + (q + r) =
in ordinary algebra.
3. The distributiv
pand combinations

p (q r)
is like

p(q + r)

The other distribut


thing in ordinary alg
4. Some of these
the sense that other
example, the absorp

p (p

p (q r) (p q) r
p (q r) (p q) r

the sense that other


example, the absorp

Distributive laws
p (q r) (p q) (p r)
p (q r) (p q) (p r)

p (p

follows from the di


identity and annihil

De Morgans laws
(p q) (p) (q)
(p q) (p) (q)

p (p q)

Identity laws
pTp
pFp

Annihilation laws
pFF
pTT

Inverse laws
p (p) F
p (p) T

Absorption laws
p (p q) p
p (p q) p

Question 5.2 First show that (p q) p q.


p
T
T
F
F

q
T
F
T
F

pq
T
F
F
F

(p q)
F
T
T
T

p
F
F
T
T

q
F
T
F
T

p q
F
T
T
T

The columns for (p q) and p q are the same so


(p q) p q.

Question 5.2 (cont)

p
T
T
F
F

q
T
F
T
F

Next show that (p q) p q.

pq
T
T
T
F

(p q)
F
F
F
T

p
F
F
T
T

q
F
T
F
T

p q
F
F
F
T

The columns for (p q) and p q are the same so


(p q) p q.
Absorption laws left as an exercise.

valences

ces are the most fregebra of logic.

p)

Remarks
1. The commutative laws are used to rearrange terms, as in ordinary algebra. The law
p q q p is like p + q = q + p in ordinary
algebra, and p q q p is like pq = qp.
2. The associative laws are used to remove
brackets. Since p (q r) (p q) r, we
can write either side simply as pq r. This
is like p + (q + r) = (p + q) + r = p + q + r
in ordinary algebra.
3. The distributive laws are used to expand combinations of and .
p (q r) (p q) (p r)
is like
p(q + r) = pq + pr.
The other distributive law is not like anything in ordinary algebra.
4. Some of these laws are redundant, in
the sense that other laws imply them. For
example, the absorption law

p r)
p r)

thing in ordinary algebra.


4. Some of these laws are redundant, in
the sense that other laws imply them. For
example, the absorption law
p (p q) p
follows from the distributive, idempotent,
identity and annihilation laws:
p (p q)

(p p) (p q)

by distributive law
p (p q)
by idempotent law
(p T) (p q)
by identity law

p (T q)
by distributive law
pT
by annihilation law
p
by identity law

Question 5.3 First show that p (qr ) (p q)(p r ).


p
T
T
T
T
F
F
F
F

q
T
T
F
F
T
T
F
F

r
T
F
T
F
T
F
T
F

qr
F
T
T
F
F
T
T
F

p (qr )
F
T
T
F
F
F
F
F

pq
T
T
F
F
F
F
F
F

pr
T
F
T
F
F
F
F
F

(p q)(p r )
F
T
T
F
F
F
F
F

The columns for p (qr ) and (p q)(p r ) are the same so


p (qr ) (p q)(p r ).
Second statement left as an exercise (but theyre not logically
equivalent).

SAT

this last part of the lecture is not assessable

Problem (SAT): Given a sentence in propositional logic using , ,


and n variables, is there an assignment of truth values to the variables
that makes the sentence evaluate to T?
SAT is an example of a decision problem.
P is the class of all decision problems which there is an efficient
(polynomial-time) algorithm for solving.
NP is the class of all decision problems for which there is an efficient
(polynomial-time) algorithm for checking that a given solution is correct.
Obviously every problem in P is also in NP.
SAT is in NP, but we dont know whether its in P.

Huge question: Is P=NP?


Everybody thinks P 6= NP, but no-one has proven it.

SAT

this last part of the lecture is not assessable

In fact, SAT is what we call NP-complete.


This means that if we had an efficient algorithm for solving it we could
translate that algorithm to make it solve any problem in NP efficiently,
and we would have P = NP.
Examples of other NP-complete problems are the travelling salesman
problem and the problem of finding a hamilton path in a graph.

Potrebbero piacerti anche