Docsity

Propositional Logic and First-Order Logic: Derivation Rules and Semantics, Study notes of Health sciences

Toggle sidebar
bg1
Lecture Notes on Mathematical Logic
Vladimir Lifschitz
January 16, 2009
These notes provide an elementary, but mathematically solid, introduc-
tion to propositional and first-order logic. They contain many exercises.
Logic is the study of reasoning. The British mathematician and philoso-
pher George Boole (1815–1864) is the man who made logic mathematical.
His book The Mathematical Analysis of Logic was published in 1847.
Logic can be used in programming, and it can be applied to the analysis
and automation of reasoning about software and hardware. This is why
it is sometimes considered a part of theoretical computer science. Since
reasoning plays an important role in intelligent behavior, logic is closely
related to artificial intelligence.
The short book by the German philosopher Gottlob Frege (1848–1925)
with the long title Ideography, a Formula Language, Modeled upon that of
Arithmetic, for Pure Thought (1879), introduced notation that is somewhat
similar to what is now called first-order formulas. Frege wrote:
I believe that I can best make the relation of my ideography to
ordinary language clear if I compare it to that which the micro-
scope has to the eye. Because of the range of its possible uses
and the versatility with which it can adapt to the most diverse
circumstances, the eye is far superior to the microscope... But,
as soon as scientific goals demand great sharpness of resolution,
the eye proves to be insufficient.
... I am confident that my ideography can be successfully used
wherever special value must be placed on the validity of proofs, as
for example when the foundations of the differential and integral
calculus are established.
In logic and in linguistics, we distinguish between two languages: the
one that is the object of study and the one that we use to talk about that
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Propositional Logic and First-Order Logic: Derivation Rules and Semantics and more Study notes Health sciences in PDF only on Docsity!

Lecture Notes on Mathematical Logic

Vladimir Lifschitz

January 16, 2009

These notes provide an elementary, but mathematically solid, introduc- tion to propositional and first-order logic. They contain many exercises. Logic is the study of reasoning. The British mathematician and philoso- pher George Boole (1815–1864) is the man who made logic mathematical. His book The Mathematical Analysis of Logic was published in 1847. Logic can be used in programming, and it can be applied to the analysis and automation of reasoning about software and hardware. This is why it is sometimes considered a part of theoretical computer science. Since reasoning plays an important role in intelligent behavior, logic is closely related to artificial intelligence. The short book by the German philosopher Gottlob Frege (1848–1925) with the long title Ideography, a Formula Language, Modeled upon that of Arithmetic, for Pure Thought (1879), introduced notation that is somewhat similar to what is now called first-order formulas. Frege wrote:

I believe that I can best make the relation of my ideography to ordinary language clear if I compare it to that which the micro- scope has to the eye. Because of the range of its possible uses and the versatility with which it can adapt to the most diverse circumstances, the eye is far superior to the microscope... But, as soon as scientific goals demand great sharpness of resolution, the eye proves to be insufficient.

... I am confident that my ideography can be successfully used wherever special value must be placed on the validity of proofs, as for example when the foundations of the differential and integral calculus are established.

In logic and in linguistics, we distinguish between two languages: the one that is the object of study and the one that we use to talk about that

object. The former is called the object language; the latter is the metalan- guage. In Sections 1 and 2 below, the object language is the formal language of propositional formulas; in Section 3, we turn to first-order formulas. The metalanguage is the usual informal language of mathematics and theoretical computer science, which is a mixture of the English language and mathemat- ical notation. The importance of distinguishing between the object language and the metalanguage was emphasized by the mathematician and logician Alfred Tarski (1902–1983), who taught logic at Berkeley since 1942.

1 Syntax and Semantics of Propositional Formulas

Propositional Formulas

A propositional signature is a set of symbols called atoms. (In examples, we will assume that p, q, r are atoms.) The symbols

∧ ∨ → ↔ ¬ ⊥ ⊤

are called propositional connectives. Among them, the symbols ∧ (con- junction), ∨ (disjunction), → (implication) and ↔ (equivalence) are called 2-place, or binary connectives; ¬ (negation) is a 1-place, or unary connective; ⊥ (false) and ⊤ (true) are 0-place. Take a propositional signature σ which contains neither the proposi- tional connectives nor the parentheses (, ). The alphabet of propositional logic consists of the atoms from σ, the propositional connectives, and the parentheses. By a string we understand a finite string of symbols in this alphabet. We define when a string is a (propositional) formula recursively, as follows:

  • every atom is a formula,
  • both 0-place connectives are formulas,
  • if F is a formula then ¬F is a formula,
  • for any binary connective ⊙, if F and G are formulas then (F ⊙ G) is a formula.

For instance, ¬(p → q)

and (¬p → q) (1)

Problem 1.3 No formula can be represented in the form (F ⊙ G), where F and G are formulas and ⊙ is a binary connective, in more than one way.

By representing a formula in the form ¬F or (F ⊙ G) we start “parsing” it. The assertion of the previous problem shows that a formula can be parsed in only one way. From now on, we will abbreviate formulas of the form (F ⊙ G) by drop- ping the outermost parentheses in them. We will also agree that ↔ has a lower binding power than the other binary connectives. For instance,

p ∨ q ↔ p → r

will be viewed as shorthand for

((p ∨ q) ↔ (p → r)).

Finally, for any formulas F 1 , F 2 ,... , Fn (n > 2),

F 1 ∧ F 2 ∧ · · · ∧ Fn

will stand for (· · · (F 1 ∧ F 2 ) ∧ · · · ∧ Fn).

The abbreviation F 1 ∨ F 2 ∨ · · · ∨ Fn will be understood in a similar way.

Semantics of Propositional Formulas

The symbols f and t are called truth values. An interpretation of a propo- sitional signature σ is a function from σ into {f, t}. If σ is finite then an interpretation can be defined by the table of its values, for instance:

p q r f f t

The semantics of propositional formulas that we are going to introduce defines which truth value is assigned to a formula F by an interpretation I. As a preliminary step, we need to associate functions with all unary and binary connectives: a function from {f, t} into {f, t} with the unary connective ¬, and a function from {f, t} × {f, t} into {f, t} with each of the binary connectives. These functions are denoted by the same symbols as the corresponding connectives, and defined by the following tables:

x ¬(x) f t t f

x y ∧(x, y) ∨(x, y) → (x, y) ↔ (x, y) f f f f t t f t f t t f t f f t f f t t t t t t

For any formula F and any interpretation I, the truth value F I^ that is assigned to F by I is defined recursively, as follows:

  • for any atom F , F I^ = I(F ),
  • ⊥I^ = f, ⊤I^ = t,
  • (¬F )I^ = ¬(F I^ ),
  • (F ⊙ G)I^ = ⊙(F I^ , GI^ ) for every binary connective ⊙. If F I^ = t then we say that the interpretation I satisfies F (symbolically, I |= F ). Exercise: Find a formula F of the signature {p, q, r} such that (3) is the only interpretation satisfying F. If the underlying signature is finite then the set of interpretations is finite also, and the values of F I^ for all interpretations I can be represented by a finite table. This table is called the truth table of F. For instance, the exercise above can be stated as follows: Find a formula with the truth table

p q r F f f f f f f t t f t f f f t t f t f f f t f t f t t f f t t t f

Exercise: prove that for any formulas F 1 ,... , Fn (n ≥ 1) and any inter- pretation I,

(F 1 ∧ · · · ∧ Fn)I^ = t iff F 1 I = · · · = F (^) nI = t, (F 1 ∨ · · · ∨ Fn)I^ = f iff F 1 I = · · · = F (^) nI = f.

In the following two problems, we assume that the underlying signature is finite: σ = {p 1 ,... , pn}.

disjunction distributes over conjunction:

F ∨ (G ∧ H) ∼ (F ∨ G) ∧ (F ∨ H).

Do these connectives distribute over equivalence?

(c) De Morgan’s laws

¬(F ∧ G) ∼ ¬F ∨ ¬G, ¬(F ∨ G) ∼ ¬F ∧ ¬G

show how to transform a formula of the form ¬(F ⊙ G) when ⊙ is conjunc- tion or disjunction. Find similar transformations for the cases when ⊙ is implication or equivalence.

(d) Implication distributes over conjunction:

F → (G ∧ H) ∼ (F → G) ∧ (F → H).

Find a similar transformation for (F ∨ G) → H.

(e) To simplify a formula means to find an equivalent formula that is shorter. Simplify the following formulas:

(i) F ↔ ¬F ,

(ii) F ∨ (F ∧ G),

(iii) F ∧ (F ∨ G),

(iv) F ∨ (¬F ∧ G).

(v) F ∧ (¬F ∨ G).

(f) For each of the formulas

p ∧ q, p ∨ q, p ↔ q, ¬p, ⊤

find an equivalent formula that contains no connectives other than → and ⊥.

(g) For each of the formulas

p → q, p ∧ q

find an equivalent formula that contains no connectives other than ↔ and ∨.

Adequate Sets of Connectives

Problem 1.6 For any formula, there exists an equivalent formula that contains no connectives other than → and ⊥.

In this sense, {→, ⊥} is an “adequate” set of connectives. Similarly, we can check that then each of the sets

{∧, ¬}, {∨, ¬}, {→, ¬}

is adequate, under the assumption that the underlying signature is non- empty.

Problem 1.7 Any propositional formula equivalent to ⊥ contains at least one of the connectives ⊥, ¬.

This fact shows that the set {∧, ∨, →, ↔, ⊤} is not adequate.

Disjunctive and Conjunctive Normal Forms

A literal is an atom or the negation of an atom. A simple conjunction is a formula of the form L 1 ∧ · · · ∧ Ln (n ≥ 1), where L 1 ,... , Ln are literals. A formula is in disjunctive normal form if it has the form C 1 ∨ · · · ∨ Cm (m ≥ 1), where C 1 ,... , Cm are simple conjunctions.

Problem 1.8 If the underlying signature is non-empty then any formula is equivalent to a formula in disjunctive normal form.

A simple disjunction is a formula of the form L 1 ∨ · · · ∨Ln (n ≥ 1), where L 1 ,... , Ln are literals. A formula is in conjunctive normal form if it has the form D 1 ∧ · · · ∧ Dm (m ≥ 1), where D 1 ,... , Dm are simple disjunctions.

Problem 1.9 Let F be a formula in disjunctive normal form. Show that ¬F is equivalent to a formula in conjunctive normal form.

Problem 1.10 If the underlying signature is non-empty then any formula is equivalent to a formula in conjunctive normal form.

Satisfiability and Entailment

A set Γ of formulas is satisfiable if there exists an interpretation that satisfies all formulas in Γ, and unsatisfiable otherwise. It is easy to check that a non- empty finite set {F 1 ,... , Fn} is unsatisfiable iff the conjunction ¬(F 1 ∧ · · · ∧ Fn) of its elements is a tautology. (Do it!)

H 2. (F → (G → H)) → ((F → G) → (F → H)).

H 3. ((F → ⊥) → ⊥) → F.

Each of the expressions H 1 , H 2 , H 3 is an “axiom schema” that represents infinitely many axioms of the system H, called the instances of the schema. For example, if p and q are atoms then the formula

(p → q) → ((⊥ → ⊥) → (p → q))

is an instance of the axiom schema H 1. The only inference rule of H is modus ponens: F F → G G

The two expressions above the horizontal bar show the form of the premises to which the rule can be applied, and the expression under the bar shows the form of the conclusion that is derived by the rule. An instance of the rule is obtained from it by substituting formulas for the symbols F and G. For example, p p → (q → p) q → p is an instance of modus ponens whose second premise is an instance of H 1. Let Γ be a set of formulas, called hypotheses. In the system H, a deriva- tion from Γ is a list F 1 ,... , Fn (n ≥ 1) of formulas such that, for every i ≤ n, formula Fi

  • is a hypothesis, or
  • is an instance of one of the axiom schemas H 1 , H 2 , H 3 , or
  • for some j, k < i, can be derived from Fj and Fk by modus ponens.

A derivation whose last formula is F is said to be a derivation of F. If there exists a derivation of F from Γ in the system H then we say that F is derivable from Γ in H and write Γ ⊢H F. A derivation from the empty set of hypotheses is called a proof. If there exists a proof of F in the system H then we say that F is provable in H and write ⊢H F. For other deductive systems, the terminology and notation are similar. For instance, the following list of formulas is a derivation of p from ⊥:

  1. ⊥ — hypothesis
  2. ⊥ → ((p → ⊥) → ⊥) — H 1
  3. (p → ⊥) → ⊥ — from 1, 2
  4. ((p → ⊥) → ⊥) → p — H 3
  5. p — from 3, 4

The comments appended at the end of every line explain why this list of formulas is indeed a derivation. We have shown that

⊥ ⊢H p. (4)

Problem 2.1 ⊢H p → p.

Problem 2.2 ⊢H ⊥ → p.

Problem 2.3 For any set Γ of formulas and any formulas F and G, if Γ ⊢H F and Γ, F ⊢H G then Γ ⊢H G.

For instance, for any formula G, from

⊥ → p ⊢H G

we can conclude that ⊢H G.

Problem 2.4 For any set Γ of formulas and any formulas F and G, if Γ, F ⊢H G then Γ ⊢H F → G.

This fact is known as the deduction theorem for the system H. It allows us, for instance, to derive the assertion of Problem 2.2 from (4). The de- duction theorem (for first-order logic) was first proved by the French math- ematician Jacques Herbrand (1908–1931). The converse of the deduction theorem is true as well. (Prove it!) As an exercise on the use of the deduction theorem, prove that

F → ⊥ ⊢H F → G.

Problem 2.5 (F → ⊥) → G ⊢H (G → ⊥) → F.

Problem 2.6 F → G, (F → ⊥) → G ⊢H G.

Soundness and Completeness of H

Problem 2.7 For any set Γ of formulas and any formula F , if Γ ⊢H F then Γ |= F.

In particular, if ⊢H F then F is a tautology. The assertion of Problem 2. expresses the soundness of deductive system H.

Problem 2.8 Let A 1 ,... , An be the atoms that occur in a formula F , and let I be an interpretation. Define the formulas A′ 1 ,... , A′ n, F ′^ as follows:

A′ i =

{ Ai, if I |= Ai, Ai → ⊥, otherwise;

The axioms of N are sequents of the forms

F ⇒ F

and ⇒ F ∨ ¬F. The latter is called the law of excluded middle. In the list of inference rules below, Γ, ∆, ∆ 1 , ∆ 2 are finite sets of formu- las, and Σ is a formula or the empty string. All inference rules of N except for the two rules at the end are classified into introduction rules (the left column) and elimination rules (the right column); the exceptions are the contradiction rule (C) and the weakening rule (W ):

(∧I) Γ Γ^ ⇒, ∆^ F ⇒^ ∆F ∧⇒ G^ G (∧E) Γ^ ⇒ Γ ⇒^ F^ F∧ G Γ^ ⇒ Γ ⇒^ F^ G∧^ G

(∨I) Γ Γ⇒^ ⇒ F^ F∨ G Γ ⇒Γ^ ⇒ F^ G∨ G (∨E) Γ^ ⇒^ F^ ∨^ G^ Γ,∆ ∆^1 , F^ ⇒^ Σ^ ∆^2 , G^ ⇒^ Σ

1 ,^ ∆ 2 ⇒^ Σ

(→I) ΓΓ ⇒, F F^ ⇒ →^ G G (→E) Γ^ ⇒^ F Γ^ , ∆∆ ⇒⇒ GF^ →^ G

(¬I) ΓΓ , F⇒ ¬^ ⇒F (¬E) Γ^ ⇒^ F Γ^ , ∆∆ ⇒^ ⇒ ¬F

(C) ΓΓ ⇒^ ⇒ F

(W ) ΓΓ, ∆^ ⇒ ⇒^ Σ Σ

System N is sound and complete:

(a) a sequent Γ ⇒ F is provable in N iff Γ entails F ;

(b) a sequent Γ ⇒ is provable in N iff Γ is unsatisfiable.

To prove a formula F in System N means to prove the sequent ⇒ F. Assertion (a) above shows that a formula is provable in N iff it is a tautology. Natural deduction was invented by the German logician Gerhard Gentzen (1909–1945).

A 1. p → (q → r)

  1. A 1 ⇒ p → (q → r) — axiom Assume p → (q → r). Now our goal is to prove (p ∧ q) → r. A 2. p ∧ q
  2. A 2 ⇒ p ∧ q — axiom Assume p ∧ q. Now our goal is to prove r.
  3. A 2 ⇒ p — by (∧E) from 2 From the second assumption, p.
  4. A 1 , A 2 ⇒ q → r — by (→ E) from 3, 1 Consequently, by the first assumption, q → r.
  5. A 2 ⇒ q — by (∧E) from 2 On the other hand, from the second assumption, q.
  6. A 1 , A 2 ⇒ r — by (→ E) from 5, 4 Consequently r.
  7. A 1 ⇒ (p ∧ q) → r — by (→ I) from 6 Thus we proved (p ∧ q) → r
  8. ⇒ (p → (q → r)) → ((p ∧ q) → r) — by (→ I) from 7 and consequently we are done.

Figure 1: A proof of (p → (q → r)) → ((p ∧ q) → r)

In proofs in system N, it is convenient to denote the “assumptions” appearing in sequents to the left of ⇒ by A 1 , A 2 ,.. .. Figure 1 shows a proof of the formula (p → (q → r)) → ((p ∧ q) → r) written in this manner, with the corresponding “informal proof” to the right of the bar. Figure 2 is a proof of

(¬p → q) → (¬q → p)

in N, again with an “English translation.” As an exercise, find a proof of each of the formulas (p → (q → r)) → ((p → q) → (p → r)), (p → q) → (¬q → ¬p) in System N, and show also the corresponding informal proof.

A predicate signature is a set of symbols of two kinds—object constants and predicate constants—with a nonnegative integer, called the arity, as- signed to every predicate constant. A predicate constant is said to be propo- sitional if its arity is 0. Propositional constants are similar to atoms in propositional logic. A predicate constant is unary if its arity is 1, and bi- nary if its arity is 2. For instance, we can define a predicate signature

{a, P, Q} (11)

by saying that a is an object constant, P is a unary predicate constant, and Q is a binary predicate constant. Take a predicate signature σ that does not include any of the following symbols:

  • the object variables x, y, z, x 1 , y 1 , z 1 , x 2 , y 2 , z 2 ,.. .,
  • the propositional connectives,
  • the universal quantifier ∀ and the existential quantifier ∃,
  • the parentheses and the comma.

The alphabet of predicate logic consists of the elements of σ and of the four groups of additional symbols listed above. A string is a finite string of symbols in this alphabet. A term is an object constant or an object variable. A string is called an atomic formula if it is a propositional constant or has the form

R(t 1 ,... , tn)

where R is a predicate constant of arity n (n > 0) and t 1 ,... , tn are terms. For instance, if the underlying signature is (11) then P (a) and Q(a, x) are atomic formulas. We define when a string is a (predicate) formula recursively, as follows:

  • every atomic formula is a formula,
  • both 0-place connectives are formulas,
  • if F is a formula then ¬F is a formula,
  • for any binary connective ⊙, if F and G are formulas then (F ⊙ G) is a formula,
  • for any quantifier K and any variable v, if F is a formula then KvF is a formula.

For instance, if the underlying signature is (11) then

(¬P (a) ∨ ∃x(P (x) ∧ Q(x, y)))

is a formula. When we write predicate formulas, we will drop some parentheses and use other abbreviations introduced in Section 1. A string of the form ∀v 1 · · · ∀vn (n ≥ 0) will be written as ∀v 1 · · · vn, and similarly for the ex- istential quantifier. An occurrence of a variable v in a formula F is bound if it occurs in a part of F of the form KvG; otherwise it is free in F. For instance, in the formula ∃yP (x, y) ∧ ¬∃xP (x, x) (12)

the first occurrence of x is free, and the other three are bound; both occur- rences of y in (12) are bound. We say that v is free (bound) in F if some occurrence of v is free (bound) in F. A formula without free variables is called a closed formula, or a sentence.

Representing English Sentences by Predicate Formulas

Before we continue the study of the syntax of predicate logic, it is useful to get some experience in translating sentences from English into the language of predicate formulas. The translation exercises below are different from the other problems in that they are not precisely stated mathematical questions: there is no way to prove, in the mathematical sense, that a translation is adequate (at least until the semantics of predicate logic is defined). There is sometimes no clear-cut difference between good and bad translations; it may happen that one translation is somewhat less adequate than another but still satisfactory. In these translation exercises, the underlying signature is (11). We will think of object variables as ranging over the set ω of nonnegative integers, and interpret the signature as follows:

  • a represents the number 10,
  • P (x) represents the condition “x is a prime number,”
  • Q(x, y) represents the condition “x is less than y.”

are greater than y” by a predicate formula, we would have to use a bound variable different from y and write, for instance,

∀z(P (z) → Q(y, z)). To distinguish “bad” substitutions, as in the last example, from “good” substitutions, we introduce the following definition. A term t is substitutable for a variable v in a formula F if

  • t is a constant, or
  • t is a variable w, and no part of F of the form KwG contains an occurrence of v which is free in F.

For instance, a and z 2 are substitutable in (13) for x, and y is not substi- tutable.

Semantics of Predicate Formulas

The semantics of propositional formulas described in Section 1 defined which truth value F I^ is assigned to a propositional formula F by an interpretation I. Our next goal is to extend this definition to predicate formulas. First we need to extend the definition of an interpretation to predicate signatures. An interpretation I of a predicate signature σ consists of

  • a non-empty set |I|, called the universe of I,
  • for every object constant c of σ, an element cI^ of |I|,
  • for every propositional constant R of σ, an element RI^ of {f, t},
  • for every predicate constant R of σ of arity n > 0, a function RI^ from |I|n^ to {f, t}. For instance, the second paragraph of the section on representing En- glish sentences by predicate formulas can be viewed as the definition of an interpretation of signature (11). For this interpretation I,

|I| = ω,

aI^ = 10,

P I^ (n) =

{ t, if n is prime, f, otherwise,

QI^ (m, n) =

{ t, if m < n, f, otherwise.

The semantics of predicate logic introduced below defines the truth value F I^ only for the case when F is a sentence. As in propositional logic, the definition is recursive. For propositional constants, there is nothing to define: the truth value RI^ is part of the interpretation I. For other atomic sentences, we can define R(t 1 ,... , tn)I^ = RI^ (tI 1 ,... , tIn).

(Since R(t 1 ,... , tn) is a sentence, each term ti is an object constant, and consequently tIi is part of I). For propositional connectives, we can use the same clauses as in propositional logic. But the case of quantifiers presents a difficulty. One possibility would be to define

∃wF (w)I^ = t iff, for some object constant c, F (c)I^ = t

and similarly for the universal quantifier. But this formulation is unsatis- factory: it disregards the fact that some elements of the universe |I| may be not represented by object constants. For instance, in the example above 10 is the only element of the universe ω for which there is a corresponding object constant in signature (11); we expect to find that

(∃xQ(x, a))I^ = t

(there exists a number that is less than 10) although

Q(a, a)I^ = f

(10 does not have this property). Because of this difficulty, some additional work is needed before we define F I^. Consider an interpretation I of a predicate signature σ. For any ele- ment ξ of its universe |I|, select a new symbol ξ∗, called the name of ξ. By σI^ we denote the predicate signature obtained from σ by adding all names ξ∗^ as additional object constants. For instance, if σ is (11) and I is (14) then σI^ = {a, 0 ∗, 1 ∗, 2 ∗,... , P, Q}. The interpretation I can be extended to the new signature σI^ by defining

(ξ∗)I^ = ξ

for all ξ ∈ |I|. We will denote this interpretation of σI^ by the same symbol I.