Formal Logic PDF

You might also like

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

Formal Logic

Chapter 1 is an introduction to symbolic, or formal, logic and some of its applications to


computer science. We first must find a notation to represent logical arguments in a formal,
symbolic way. The idea behind representing arguments symbolically is to make them
meaningless. Initially, this seems strange - why would we try to make something
meaningless? Because stripping away the meaning (and any preconceived notions we
may have about that meaning) allows us to concentrate on the pure form of the argument.

Consider the following argument:

Hawaii is the 50th state.


Honolulu is on the island of Oahu.

Therefore Honolulu is the capital of Hawaii.

Because we understand the meaning of these statements - and because they are all true -
we may be convinced that this is a logical argument. But it isn't; these are just three
separate, true statements. The statement that Honolulu is the capital of Hawaii does not at
all follow in a logical fashion from the two previous statements.

If we symbolize this argument, it has the form

A
B

Therefore C.

Then it is easy to see that the various parts have nothing to do with each other, and this
argument isn't logical reasoning at all. In a logical argument, the conclusion follows
because of the way it is structurally related to the hypotheses. Symbolic logic studies these
structural relationships in an abstract way in order to concentrate on their form.

In Chapter 1, we'll see how to represent a simple argument symbolically and determine
whether it is a logically sound argument. Section 1.1 starts out with simple statements
(sometimes called propositions) that are either true or false, and then discusses how
these simple statements can be combined using logical connectives that manipulate truth
values according to strict rules. The resulting statements are called propositional well-
formed formulas. Section 1.2 discusses derivation rules that can be used to generate a
valid argument involving propositional well-formed formulas.

The statement letters, equivalence rules and inference rules of propositional logic are not
sufficient to let us prove everything we would consider a logically valid argument. Instead
of simple statement letters, we introduce quantifiers that let us decide whether "some" or
"all" elements of some domain have a certain property. Using the existential quantifier,
(∃ x ) P(x) says that at least one element in the domain has property P. Using the
universal quantifier, (∀ x) P(x) says that every element in the domain has property P.
Combining expressions of this sort with logical connectives gives us predicate well-
formed formulas, introduced in Section 1.3.

An argument in predicate logic has the form


P1 ‚ P2 ‚ …‚ Pn ‚ Q

where the Pis and the Q are predicate wffs. It is a valid argument if it is true in all possible
interpretations. To prove validity, we add additional inference rules to our formal logic
system that allow us to insert or strip off quantifiers. Like propositional logic, predicate
logic (Section 1.4) is a complete and correct formal system.

In addition to providing the underpinnings for logical thought, formal logic has two direct
applications to computer science - logic programming and proof of correctness. These are
discussed in Sections 1.5 and 1.6.

Completeness and Correctness

Formal logic systems seek to prove that certain implications of the form P Q are
inherently true. The conclusion Q must follow from the hypothesis P because of the way Q
and P are structurally related, not because of any particular meaning attached to P or Q.
(Recall this is the motivation behind symbolization.) So if the wffs in P and Q are
propositional wffs, then P Q must be true for all truth values, that is, P Q must be a
tautology. If the wffs in P and Q are predicate wffs, then P Q must be true for all
interpretations, that is, P Q must be valid. While we can test for a tautology by
constructing a truth table, there is no corresponding mechanical means to test for validity,
and we must depend on a system of derivation rules to prove that Q follows from P.

Logical Argument P Q

Propositional Logic Predicate Logic

P Q is a tautology P Q is valid

Can test by truth table No mechanical test

The derivation rules should allow us to prove every P Q that is true (the system is
complete) and nothing that is not true (the system is correct). Again, "true" in
propositional logic means tautology, and in predicate logic it means valid.

Overview of Section 1.1

Statements are sentences with truth values. A simple sentence can be represented
symbolically by a statement letter (A, B, etc.) Statement letters can be combined into
new statements using logical connectives of
conjunction
disjunction
implication
equivalence
negation

The truth value of the new statement is derived from the truth values of its components
according to the truth tables for the connectives. Truth tables define how each of the
connectives operate on truth values. The truth tables are relatively intuitive, except
perhaps for implication. The implication:

is defined to be true UNLESS A is T and B is F.

To find the truth value for a complex well-formed formula (wff), construct its truth table.
Build this up from the component parts of the wff, starting with the smallest pieces first.
Use the truth tables for each logical connective you encounter.

A wff that is true for any combination of truth values assigned to its statement letters is a
tautology. A wff that is false for any combination of truth values assigned to its statement
letters is a contradiction. You can identify tautologies and contradictions by doing a truth
table for the wff.

If the main connective of the wff is an implication, that is, if the wff at the "top level" looks
like:

you can also use Algorithm TautologyTest to decide if it is a tautology. This algorithm
works by assigning P the value T and Q the value F. You then follow the consequences of
this assignment down through the various components until every occurrence of a
statement letter has received a truth value assignment. If some letter has received two
different truth values by this process, then your original assignment of P-T and Q-F is
impossible, and the wff is a tautology. If not, then you found an assignment in which P-T
and Q-F is possible, and the wff is not a tautology.

Sample Problem Solutions

Sample Problem 1 - Constructing truth tables for compound wffs


Sample Problem 2 - Recognizing tautologies and contradictions

Truth Tables for Logical Connectives


Constructing Truth Tables For Compound Wffs

Problem:

Construct a truth table for the wff:

Solution:

Step 1. Construct the beginning of the truth table. Decide how many rows it will have and
give truth value assignments to the statement letters.

Recognizing Tautologies and Contradictions

Problem:

Determine whether the wff

is a tautology.

Solution:

Step 1. Decide on the method to use

Overview of Section 1.2

Suppose an argument has the form P1 ‚ P2 ‚ …‚ Pn ‚ Q. A proof in a formal logic system


that this argument is valid is a sequence

W1
W2
.
.
.
Q

where the Ws (and Q) are wffs that are either

one of the hypothesis Pi


obtainable from previous wffs in the proof by derivation rules of the formal system

In propositional logic, there are two types of derivation rules.

Equivalence rules: an equivalence rule states that wff R is equivalent to wff S. This
means if a wff containing R appears in a proof sequence, then the wff obtained from
this by substituting S for R can be added to the proof sequence.
Inference rules: an inference rule says that if wffs already in the proof sequence
match a certain pattern, then a certain new wff can be added to the proof sequence.

The derivation rules are simply patterns for transforming wffs, and we must be able to
recognize when some wff in the proof sequence matches all or part of one of these
patterns.

We can prove English language arguments valid by translating their components into
propositional logic and proving the resulting P1 ‚ P2 ‚ …‚ Pn ‚ Q implication.

Sample Problem Solutions

Sample Problem 1 - Proving a theorem in propositional logic


Sample Problem 2 - Using propositional logic to prove the validity of an English
language argument

Proving a theorem in propositional logic

Problem:

Prove that the wff

[A D (B DC) ‚ (B' DA')] D [A D (C ‚ B)]

is a theorem of propositional logic.

Solution:

We will construct a proof sequence. (A truth table would verify that the wff is a tautology,
which means - by completeness - that it is a theorem, but we want to actually construct the
proof.)

Using propositional logic to prove the validity of an English language argument


Problem:

Prove the validity of the following argument:

Either your car is damaged or you are not at fault. If your car was damaged, your
insurance will pay. You are at fault. Therefore your insurance will pay.

Solution:

We will represent the argument in propositional logic notation, then construct a proof.

Overview of Section 1.3

Consider the statement "Every student loves discrete math." This is a true statement (or
maybe not!), but at any rate the wffs of Section 1.1 (called propositional wffs) cannot
represent what this statement says, namely that all objects from a certain collection
(students) have some property (they love discrete math). We need a new representation
for properties objects may have, and whether some or all of the objects have that property.

Notations such as P(x), Q(y), W(x, y) are used to mean that x has property P, y has
property Q, and x and y have property W. Quantifiers (the universal quantifier,
symbolized by , and the existential quantifier, symbolized by ) indicate how many
objects have some property. Predicate wffs are made up of quantifiers, predicate
symbols, and constant symbols, as well as logical connectives.

The truth value of a predicate wff depends on its interpretation, which consists of three
parts:

the domain - the collection of objects under discussion, of which there must be at
least one
the assignment of a property of objects in the domain to each predicate symbol
the assignment of a particular domain object to each constant symbol

Thus the predicate wff

is true in the interpretation where the domain is the integers greater than 10 and P(x)
means "x is positive," because every integer greater than 10 is positive. The wff

is true in the interpretation where the domain is all the integers, the constant symbol 0
means zero, and G(y, z) means y > z, because there is at least one positive integer.

Giving an interpretation to a predicate wff is like assigning truth values to the statement
letters in a propositional wff - it determines the truth value of the statement. Valid predicate
wffs are true in all interpretations, just as tautologies are true for all truth values. But while
we can test, using a truth table, whether a propositional wff is a tautology, there is no
algorithm to decide whether a predicate wff is valid.
Sample Problem Solutions

Sample Problem 1 - Determining the truth value of a predicate wff in a given


interpretation
Sample Problem 2 - Translating English statements into predicate wffs
Sample Problem 3 - Recognizing valid and nonvalid wffs

Determining the truth value of a predicate wff in a given interpretation

Problem:

Given the interpretation:

domain = all animals


M(x) is "x is a mammal"
H(x) is "x is a horse"
E(x) is "x lays eggs"

determine the truth value of the wffs

Solution:

Step 1. Begin with wff (a). Translate the quantifiers and connectives into English.

Translating English statements into predicate wffs

Problem:

Represent the statements

a. There is a fuzzy cat.


b. Only cats hiss at dogs.

as predicate wffs. Assume that the domain consists of all animals.

Solution:

Step 1. Decide on the predicates and their notation.

Recognizing valid and nonvalid wffs


Problem:

Decide whether the following predicate wff is valid and justify your conclusion.

Solution:

Step 1. Think about what the wff says.

Overview of Section 1.4

Predicate logic works much like propositional logic. You construct a proof sequence using
the derivation rules of predicate logic. These include all the derivation rules for
propositional logic, except the well-formed formulas are now predicate wffs instead of
propositional wffs. Additional inference rules are added to handle quantifiers. These rules
have some restrictions on their use to insure that they are truth-preserving.

Predicate logic is complete and correct, so that all valid wffs and only valid wffs are
theorems, just as in propositional logic all tautologies and only tautologies are theorems.

But here's a big difference. You can test a propositional wff for whether it is a tautology by
building a truth table, so you never actually have to build a proof sequence (we did it for
practice). You cannot test a predicate wff for whether it is valid, so your only choice is to
build a proof sequence (that's why we practiced).

Sample Problem Solutions

Sample Problem 1 - Proving a theorem in predicate logic


Sample Problem 2 - Using predicate logic to prove the validity of an English language
argument

Proving a theorem in predicate logic

Problem:

Prove that the wff

is a theorem of predicate logic.

Solution:

We will construct a proof sequence. First, note that the wff seems valid - if P is always true
and there are two values for which Q is true, then there are two values for which both P
and Q are true.

Using predicate logic to prove the validity of an English language argument


Problem: Prove the validity of the following argument:

Every Congressman is a politician. Kevin is a lawyer who is not a politician. Therefore


there is at least one lawyer who is not a Congressman.

Solution:

We will represent the argument in predicate logic notation, then construct a proof.

Overview of Section 1.5

Formal logic is not only a way to think about things in a logical manner, it has direct
applications in computer science. A programming language (Prolog) based on predicate
logic is extensively used in artificial intelligence, particularly in the area of expert systems.
A Prolog program (a database) consists of statements of which objects in the domain
satisfy certain predicates, or statements that are definitions for new predicates. Executing
a Prolog program consists of posing queries about the logical conclusions that may be
derived from these hypotheses. The derivation rules and the means to do the derivations
are built into the language itself.

Sample Problem Solutions

Sample Problem 1 - Formulating Prolog-like facts, rules and queries.

Formulating Prolog-like facts, rules and queries

Problem:

A Prolog database currently contains information about companies that are direct parent
companies of other companies. The current facts are:

parent-of(Fun Foods, Kool Kolas)


parent-of(Fun Foods, Marvelous Munchies)
parent-of(Marvelous Munchies, Zucchini, Inc.)
parent-of(RJ Tipton, American Healthcare Products)
parent-of(American Healthcare Products, Farm-Fresh Fertilizers)
parent-of(Capital Corporation, Fun Foods)

Formulate a Prolog rule to define when one company owns another. Formulate a query as
to which companies are owned by Capital Corporation.

Solution:

First define the rule owns(x, y). This rule can become part of the Prolog database. Then
the query would be formulated during program execution.

Overview of Section 1.6


Another application of formal logic to computer science is in the area of program proof of
correctness. Proof of correctness mathematically assures, based on rules of inference,
that a program whose variables satisfy a certain predicate (the precondition) before the
program is executed must satisfy another specific predicate (the postcondition) after
program execution. The examples we'll see are so simple that it is easy to "reason about"
their correctness, but the idea behind the rules of inference is to provide a mechanical
process to prove correctness.

Sample Problem Solution

Sample Problem 1 - Verifying the correctness of a program segment that includes


conditional and assignment statements.

Verifying the correctness of a program segment that includes conditional and


assignment statements

Problem:

Verify the correctness of the following program segment with the assertions shown:

{x = 11}
y=x-1
{y = 10}
if y 0 then
z=y-1
else
z=y+3
end if
{z = 13}

Solution:

There are two program statements, the first an assignment statement and the second a
conditional statement. These must be handled separately.

You might also like