Lecture 13: First-Order Logic

10:30 AM, Mar 10, 2009

1 Overview

Thelanguage ofpredicate calculus asdefinedinLecture11did not consider variables orquantifiers. Thislectureisconcerned with first-orderlogic, whichincorporatesquantification overobjectsusing variables as placeholders. Higher-order logics allow for quantification over functions or relations.

The universal quantifier can be interpreted as conjunction, with a possibly infinite number of conjuncts. In finite domains, universal quantification and conjunction are equivalent: e.g., in the finite domain D = {sky, mountains}, the following formula holds: x blue(x)blue(sky)blue(mountains). Butininfinitedomains,universalquantification extends conjunction: e.g., the following formula holds in the infinite domain D = Z: x odd(x)even(x).

Analogously, the existential quantifier can be interpreted as disjunction, with a possibly infinite number of disjuncts. As above, existential quantification and disjunction are equivalent in finite domains: e.g., in domain D = {sky, grass}, the following formula holds: x green(x)green(sky)green(grass). But in infinite domains, existential quantification extends disjunction: e.g., the following formula holds in the infinite domain D = N: x, y ¬succ(x, y).

2 Syntax

First-order logic generalizes predicate calculus with variables and quantifiers. Like propositional logic and predicate calculus, a set of syntactic rules govern the construction of terms and formulas in first-orderlogic. Thealphabet of first-orderlogicextendsthealphabet ofpredicatecalculuswith the quantification symbols {∀, ∃} and the variables {x, y, z, . . .}.

The following definition extends the inductive definition of the terms of predicate calculus to first-order logic:

variables x, y, z, . . . are terms

Similarly, the following definition extends the inductive definition of the formulas of predicate calculus to first-order logic:

if x is a variable and φ is a formula, then

xφ is a formula
xφ is a formula

Semantics

The semantics of first-order logic associate meanings with formulas by extending the notion of interpretationinpredicate calculus(andpropositionallogic)to adomain-mapping-assignment triple D, M, α, where α mapsvariablestoobjectsinthedomain. In first-orderlogic,themappingfrom termsto objectsisdefined(inductively) asfollows:

for all variables x, I[x]= α(x)

M

  • for all constant symbols a, I[a]= a
  • for all terms t1,...,tn and n-ary function symbols f

I[f(t1,...,tn)]= fM(I[t1],..., I[tn])

The definition of entailment in first-order logic extends that of the predicate calculus. For atomic formulas P (t1,...,tn), as before,

I|= P (t1,...,tn)iff(I[t1],..., I[tn])P M

For complext first-order formulas other than those that involve quantification, the definition is as it was before: e.g., �I�|= φ ψ iff �I�|= φ or I|= ψ. In the remaining cases, the definition is as follows:

  • I|= xφ iff for all d D, I{d/x}|= φ
  • I|= xφ iff there exists d D s.t. I{d/x}|= φ

Here I{d/x} is an abbreviation for D, M, α{d/x}�, where the assignment α{d/x} maps x to d, but otherwise agrees with α: i.e.,

α(y) ify = x

α{d/x}(y)=

d otherwise Itisstraightforward toextend thenotionsof satisfiability, validity, and unsatisfiability to first-order logic.

Example: Given the infinite alphabet A = {add, mult, =, 0, 1, <, x1 ,x2,...}, consider the interpretation N, where the domain D = N, the nonvariable symbols in A are interpreted as usual, and α(xn) =2n, for all n N. Under this interpretation, φ mult(x1, add(x2,x3)) = x4 signifies 2(4+6) =8. Of course, N �|= φ. On the other hand, N|= mult(x1,x2)= x4.

Substitution

A substitution is a function from variables to terms: i.e., σ = {t1/x1,...,tn/xn}, where each xi is a variable and each ti is a term. The set of variables {x1,...,xn}is the domain of σ; the set of terms {t1,...,tn}is the range of σ.

Before we can define the substitution operation, that is, the result of applying the substitution σ to the formula φ (abbreviatedφ|σ), we needsome terminology:

  • The scope of a quantifier is that part of a formula to which the quantifier applies.
  • A bound variable is a variable that is within the scope of some quantifier.
  • A free variable is one that is not bound.
  • A closed formula, or sentence, has no free variables.
  • An open formula is one that is not closed.
  • A ground term (or formula), is a term (or formula) without any variables. (Note that all formulas of propositional logic and predicate calculus are sentences, and all terms and formulas of these languages are ground.)

Now, the substitution operation is subject to the following two constraints:

  • Substitutions cannot be made for bound variables. For example, consider the formula φ ≡∃yy + y = 0, which is true in the standard interpretation of the natural numbers(let y =0). After applying the(illegal) substitution φ|{1/y}, we obtain the sentence y 1+1 =0,whichisfalse.
  • Substitutions cannot be made that bind variables. Consider the formula φ ≡∃yy + y = x, which states that “x is even.” After applying the (legal) substitution φ|{1/x}, we obtain the sentence yy + y = 1, which is false. But after applying the (illegal) substitution φ|{y/x}, which yields yy + y = y, the meaning changes—the new sentenceistrue(let y =0).

Note that variable renaming does not change the meaning of formulas: e.g., yy + y = 0 ≡∃zz + z = 0. Hence, to preserve meaning, first rename any bound variables whose names appear in the range of a substitution: e.g., φ ≡∃zz + z = x|{y/x}, which reduces to zz + z = y.

These constraints ensure soundness: i.e., no change in meaning. This property is stated formally in the following theorem, known as the Substitution Lemma.

Theorem: For all formulas φ, I|= φ|{t1 /x1 ,...,tn /xn} iff I{t1/x1,...,tn/xn}|= φ.

Given two substitutions σ and τ, sequential substitution στ is achieved via composition of substitutions, defined as follows: φ|στ =(φ|σ)|τ. For example, if σ = {f(y)/x} and τ = {b/y}, then R(x, y)|στ = R(f(b),b). But if θ = {f(y)/x, b/y}, then R(x, y)|θ = R(f(y),b)R(f(b),b). Note

= that if σ binds all free variables to ground terms, then e|σσ= e|σ, for all substitutions σ and all expressions e: e.g., if σ = {f(0)/x, 0/y}, then R(x, y)|στ = R(f(0), 0).

5 Logical Entailment

A variant of Herbrand’s theorem holds for universal logic, that is, first-order logic formulas with universal quantifiers only. But Herbrand’s theorem does not hold for formulas of first-order logic with existential quantifiers.

Counterexample: Consider the pair of sentences xP (x) and ¬P (a). These sentences are sat-

M

isfiable: e.g., D = {◦, ⋄}, a= , and P M = {⋄}. But these sentences do not have a Herbrand model. The Herbrand universe A = {a}and the Herbrand base B = {P (a)}. Thus, there are only two Herbrand models: P = and P = A. But neither of these models satisfy thepairof sentences.

In other words, there is no known semantic technique for deciding logical entailment. This is not surprising, as logical entailment in first-order logic is not decidable, meaning there is no effective procedure(of any complexity),and thereneverwillbe,thatcananswerthequestion “isformula φ entailed by a knowledge base KB?”

However, logical entailment in first-order logic is semi-decidable. That is, there do exist effective procedures that correctly conclude that a formula φ is entailed by a knowledge base KB when in fact thisis the case; butwhenKB �|= φ, suchprocedures need not terminate. The only semi-decision procedures known for first-order logic are proof-theoretic.

5.1 Logical Inference: Natural Deduction

Additional rules of natural deduction that extend the rules for propositional logic to quantified formulas Table 1. The following restrictions apply:

  • (I) a does not occur in φ, or in any assumptions on which φ|{a/x} depends
  • (E) a does not occur in φ or ψ, or in any of the assumptions used in the derivation of ψ from φ|{a/x} other than φ|{a/x} itself

Gentzen’s Soundness Theorem First-order logic is sound. G¨odel’s Completeness Theorem First-order logic is complete. Natural deduction is a sound and complete proof theory for first-order logic.

5.2 Logical Inference: Modus Ponens, Resolution

GENERALIZED MODUS PONENS(GMP)

Introduction Elimination

φ|{a/x} xφ

(I) (E)

xφ φ|{t/x}

[φ|{a/x}]

.

.

.

.

φ|{t/x} xφ ψ

(I) (E)

xφ ψ

Table1: Rules ofNaturalDeductionforQuantifiedFormulas.

if τ|σ = φi|σ, then

φ1 ... φm ψχ1 ... χn τ

(GMP)

(φ1 ... φi1 χ1 ... χn φi+1 ... φm ψ)|σ

Theorem: GMP is sound. Theorem: GMP is complete for Horn databases. Remark: Not all knowledge bases are convertible to Horn databases.

GENERALIZED RESOLUTION(R)

if τj|σ = φi|σ, then

φ1 ... φm ψ1 ... ψn χ1 ... χk τ1 ... τl

(R)

(φ1 ... φi1 χ1 ... χk φi+1 ... φm ψ1 ... ψn τ1 ... τj1 τj+1 ... τl)|σ

Theorem: Resolution is sound. Theorem: Resolution is refutation complete for normal form knowledge bases. Theorem: All knowledge bases are convertible to normal form knowledge bases.