(LMCS, p. 317) V.1. First Order Logic. This is the most powerful, most expressive logic that we will examine.



Similar documents
CHAPTER 7 GENERAL PROOF SYSTEMS

INTRODUCTORY SET THEORY

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Handout #1: Mathematical Reasoning

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

Predicate Logic Review

Summary Last Lecture. Automated Reasoning. Outline of the Lecture. Definition sequent calculus. Theorem (Normalisation and Strong Normalisation)

it is easy to see that α = a

Chapter 4, Arithmetic in F [x] Polynomial arithmetic and the division algorithm.

A Beginner s Guide to Modern Set Theory

WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT?

Cartesian Products and Relations

ON FUNCTIONAL SYMBOL-FREE LOGIC PROGRAMS

CS510 Software Engineering

This asserts two sets are equal iff they have the same elements, that is, a set is determined by its elements.

Lecture 8: Resolution theorem-proving

This chapter is all about cardinality of sets. At first this looks like a

OHJ-2306 Introduction to Theoretical Computer Science, Fall

Predicate Logic. Example: All men are mortal. Socrates is a man. Socrates is mortal.

CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs

Labeling outerplanar graphs with maximum degree three

Lecture 17 : Equivalence and Order Relations DRAFT

Graphs without proper subgraphs of minimum degree 3 and short cycles

An Innocent Investigation

Basic Proof Techniques

Invalidity in Predicate Logic

MA651 Topology. Lecture 6. Separation Axioms.

2.3 Convex Constrained Optimization Problems

Predicate Logic. For example, consider the following argument:

Introduction to Logic in Computer Science: Autumn 2006

EQUATIONAL LOGIC AND ABSTRACT ALGEBRA * ABSTRACT

To define function and introduce operations on the set of functions. To investigate which of the field properties hold in the set of functions

The Classes P and NP

First-Order Logics and Truth Degrees

Fixed-Point Logics and Computation

Math Review. for the Quantitative Reasoning Measure of the GRE revised General Test

Schedule. Logic (master program) Literature & Online Material. gic. Time and Place. Literature. Exercises & Exam. Online Material

o-minimality and Uniformity in n 1 Graphs

GROUPS ACTING ON A SET

WOLLONGONG COLLEGE AUSTRALIA. Diploma in Information Technology

Factoring Polynomials

PROBLEM SET 6: POLYNOMIALS

Dedekind s forgotten axiom and why we should teach it (and why we shouldn t teach mathematical induction in our calculus classes)

Answer Key for California State Standards: Algebra I

FACTORING POLYNOMIALS IN THE RING OF FORMAL POWER SERIES OVER Z

Mathematical Induction

1 = (a 0 + b 0 α) (a m 1 + b m 1 α) 2. for certain elements a 0,..., a m 1, b 0,..., b m 1 of F. Multiplying out, we obtain

PUTNAM TRAINING POLYNOMIALS. Exercises 1. Find a polynomial with integral coefficients whose zeros include

A first step towards modeling semistructured data in hybrid multimodal logic

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

1 if 1 x 0 1 if 0 x 1

CHAPTER SIX IRREDUCIBILITY AND FACTORIZATION 1. BASIC DIVISIBILITY THEORY

9.2 Summation Notation

Prime Numbers and Irreducible Polynomials

Basic Concepts of Point Set Topology Notes for OU course Math 4853 Spring 2011

SUBGROUPS OF CYCLIC GROUPS. 1. Introduction In a group G, we denote the (cyclic) group of powers of some g G by

3. Mathematical Induction

11 Ideals Revisiting Z

Putnam Notes Polynomials and palindromes

Collinear Points in Permutations

Discrete Mathematics Problems

Indiana State Core Curriculum Standards updated 2009 Algebra I

Computability Theory

Automated Theorem Proving - summary of lecture 1

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion

136 CHAPTER 4. INDUCTION, GRAPHS AND TREES

DEFINABLE TYPES IN PRESBURGER ARITHMETIC

4. CLASSES OF RINGS 4.1. Classes of Rings class operator A-closed Example 1: product Example 2:

Midterm Practice Problems

A Propositional Dynamic Logic for CCS Programs

SQL Database queries and their equivalence to predicate calculus

The Division Algorithm for Polynomials Handout Monday March 5, 2012

Propositional Logic. A proposition is a declarative sentence (a sentence that declares a fact) that is either true or false, but not both.

CONTINUED FRACTIONS AND FACTORING. Niels Lauritzen

Regular Languages and Finite Automata

Row Ideals and Fibers of Morphisms

AN INTRODUCTION TO SET THEORY. Professor William A. R. Weiss

Introduction to Algebraic Geometry. Bézout s Theorem and Inflection Points

CS 3719 (Theory of Computation and Algorithms) Lecture 4

Lecture 13 - Basic Number Theory.

Quotient Rings and Field Extensions

LAKE ELSINORE UNIFIED SCHOOL DISTRICT

You know from calculus that functions play a fundamental role in mathematics.

MOP 2007 Black Group Integer Polynomials Yufei Zhao. Integer Polynomials. June 29, 2007 Yufei Zhao

def: An axiom is a statement that is assumed to be true, or in the case of a mathematical system, is used to specify the system.

Discrete Mathematics. Hans Cuypers. October 11, 2007

A Problem Course in Mathematical Logic Version 1.6. Stefan Bilaniuk

Predicate logic. Logic in computer science. Logic in Computer Science (lecture) PART II. first order logic

Logic, Algebra and Truth Degrees Siena. A characterization of rst order rational Pavelka's logic

Determination of the normalization level of database schemas through equivalence classes of attributes

Math 223 Abstract Algebra Lecture Notes

Introduction to Finite Fields (cont.)

CORRELATED TO THE SOUTH CAROLINA COLLEGE AND CAREER-READY FOUNDATIONS IN ALGEBRA

Examination paper for MA0301 Elementær diskret matematikk

CODING TRUE ARITHMETIC IN THE MEDVEDEV AND MUCHNIK DEGREES

SECTION 10-2 Mathematical Induction

x < y iff x < y, or x and y are incomparable and x χ(x,y) < y χ(x,y).

ML for the Working Programmer

Transcription:

(LMCS, p. 317) V.1 First Order Logic This is the most powerful, most expressive logic that we will examine. Our version of first-order logic will use the following symbols: variables connectives (,,,, ) function symbols relation symbols constant symbols equality ( ) quantifiers (, )

(LMCS, p. 318) V.2 Formulas for a first-order language L are defined inductively as follows: There are two kinds of atomic formulas: (s t), where s and t are terms, and (rt 1 t n ), where r is an n ary relation symbol and t 1,, t n are terms. If F is a formula, then so is ( F). If F and G are formulas, then so are (F G), (F G), (F G), (F G). If F is a formula and x is a variable, then ( x F) and ( x F) are formulas.

(LMCS, p. 318) V.3 Notational Conventions Drop outer parentheses Adopt the previous precedence conventions for the propositional connectives. Quantifiers bind more strongly than any of the connectives. Thus y (rxy) y (rxy) means ( y (rxy)) ( y (rxy)).

(LMCS, p. 318) V.4 The subformulas of a formula F : The only subformula of an atomic formula F is F itself. The subformulas of F are F itself and all the subformulas of F. The subformulas of F G are F G itself and all the subformulas of F and all the subformulas of G. ( is any of,,, r ). The subformulas of x F are x F itself and all the subformulas of F. The subformulas of x F are x F itself and all the subformulas of F.

(LMCS, p. 318-319) V.5 An occurrence of a variable x in a formula F is: bound if the occurrence is in a subformula of the form x G or of the form x G (such a subformula is called the scope of the quantifier that begins the subformula). Otherwise the occurrence of the variable is said to be free. A formula with no free occurrences of variables is called a sentence.

(LMCS, p. 318-319) V.6 Given a bound occurrence of x in F, we say that x is bound by an occurrence of a quantifier Q if (i) the occurrence of Q quantifies the variable x, and (ii) subject to this constraint the scope of this occurrence of Q is the smallest in which the given occurrence of x occurs.

(LMCS, p. 319) V.7 It is easier to explain scope, and quantifiers that bind variables, with a diagram: An occurrence of the variable x bound by A x ( ( r x y ) ( y (( x ( r z x) ) ( r x z))) A E Scopes of quantifiers are underlined

(LMCS, p. 319) V.8 The following figure indicates all the bound and free variables in the previous formula: free occurrences A x ( ( r x y ) ( y (( x ( r z x) ) ( r x z))) A E bound occurrences

(LMCS, p. 322-323) V.9 Examples b. 2 + 2 < 3 is also an atomic sentence, which says four is less than three. False in N. c. x y (x < y) says that for every number there is a larger number. True in N. d. y x (x < y) says that there is a number that is larger than every other number. False in N.

(LMCS, p. 323-324) V.10 f. x ( (0 < x) y (y y x) ) says that every positive number is a square. False in N. h. x y ((x < y) z ( (x < z) (z < y) )) says that if one number is less than another, then there is a number properly between the two. False in N.

(LMCS, p. 323-324) V.11 We will use the shorthand notation F i 1 i n to mean the same as the notation F 1 F n. Likewise, we will use the notations F i 1 i n and F 1 F n.

(LMCS, p. 324-325) V.12 English to First-order Given a first order formula F(x) we can find first order sentences to say a. There is at least one number such that F(x) is true in N. x F(x) b. There are at least two numbers such that F(x) is true in N. x y ( (x y) F(x) F(y) )

(LMCS, p. 324-325) V.13 c. There are at least n numbers (n fixed) such that F(x) is true in N. x 1 x n (( 1 i<j n (x i x j ) ) ( 1 i n F(x i ) )) d. There are infinitely many numbers that make F(x) true in N. x y ( (x < y) F(y) ) e. There is at most one number such that F(x) is true in N. x y ( (F(x) F(y)) (x y) )

(LMCS, p. 325) V.14 Definable Relations To better understand what we can express with first order sentences we need to introduce definable relations. Given a first order formula F(x 1,..., x k ) we say F is true at a k tuple (a 1,..., a k ) of natural numbers if the expression F(a 1,..., a k ) is a true statement about the natural numbers.

(LMCS, p. 325) V.15 Example Let F(x, y) be the formula x < y. Then F is true at (a, b) iff a is less than b. Example Let F(x, y) be z (x z y). Then F is true at (a, b) iff a divides b, written a b. [Note: Don t confuse a b with a b. The first is true or false. The second has a value. Check that a 0 for any a, including a = 0.]

(LMCS, p. 325) V.16 Definition For F(x 1,..., x k ) a formula let F N be the set of k tuples (a 1,..., a k ) of natural numbers for which F(a 1,..., a k ) is true in N. F N is the relation on N defined by F. Definition A k ary relation r N k is definable in N if there is a formula F(x 1,..., x k ) such that r = F N.

(LMCS, p. 325-326) V.17 Example (Definable Relations) x is an even number is definable in N by y (x y + y) x divides y is definable in N by z (x z y) x is prime is definable in N by (1 < x) y ((y x) ( (y 1) (y x) )) x y modulo n is definable in N by z ( (x y + n z) (y x + n z) )

(LMCS, p. 326) V.18 We will adopt the following abbreviations: x y for the formula z (x z y) prime(x) for the formula (1 < x) y ( (y x) ( (y 1) (y x) )). Note that in the definition of prime(x) we have used the previous abbreviation. To properly write prime(x) as a first order formula we need to replace that abbreviation; doing so gives us (1 < x) y ( z (y z x) ( (y 1) (y x) ))

(LMCS, p. 326) V.19 Abbreviations are not a feature of first order logic, but rather they are a tool used by people to discuss first order logic. Why do we use abbreviations? Without them, writing out the first order sentences that we find interesting would fill up lines with tedious, hard to read symbolism.

(LMCS, p. 326) V.20 Given: x y abbreviates z (x z y. Then (u + 1) (u u + 1) is an abbreviation for z ((u + 1) z u u + 1) Now let us write out z 2 to obtain z (z z 1 + 1) Unfortunately, this last formula does not define the set of elements in N that divide 2. It is a first order sentence that is simply false in N the square root of 2 is not a natural number.

(LMCS, p. 326) V.21 We have stumbled onto one of the subtler points of first order logic, namely, we must be careful with substitution. The remedy for defining z divides 2 is to use another formula, like w (x w y), for x divides y.

(LMCS, p. 326) V.22 We obtain such a formula by simply renaming the bound variable z in the formula for x y. With this formula we can correctly express z divides 2 by w (z w 2). The danger in using abbreviations in first order logic is that we forget the names of the bound variables in the abbreviation.

(LMCS, p. 327) V.23 Our solution: add a to the abbreviation to alert the reader to the necessity for renaming the bound variables that overlap with the variables in the term to be substituted into the abbreviation. For example, prime (y + z) alerts the reader to the need to change the formula for prime(x), say to ( (1 < x) v (v x) ( (v 1) (v x) )), so that when we substitute y + z for x in the formula, no new occurrence of y or z becomes bound.

(LMCS, p. 327) V.24 Thus we could express prime(y + z) by (1 < y + z) v ( (v (y + z)) ( (v 1) (v y + z) )). Examples [Expressing statements in first-order logic.] a. The relation divides is transitive. x y z ( ((x y) (y z) ) (x z) ) b. There are an infinite number of primes. x y ( (x < y) prime (y) )

(LMCS, p. 327) V.25 d. There are an infinite number of pairs of primes that differ by the number 2. (Twin Prime Conjecture) x y ( (x < y) prime (y) prime (y + 2) ) e. All even numbers greater than two are the sum of two primes. (Goldbach s Conjecture) ( ((2 x) ) x (2 < x) y z ( prime (y) prime(z) (x y + z) ))

(LMCS, p. 329) V.26 Other Number Systems Our first order language L = {+,, <, 0, 1} can just as easily be used to study other number systems, in particular, the integers Z = (Z, +,, <, 0, 1), the rationals Q = (Q, +,, <, 0, 1), and the reals R = (R, +,, <, 0, 1). However, first order sentences that are true in one can be false in another.

(LMCS, p. 329-330) V.27 Example Consider the following first order sentences: a. x y (x < y) b. y x (x < y) c. x y ((x < y) z ( (x < z) (z < y) )) d. x y ( (0 < x) (x y y) ) e. x y (x < y).

(LMCS, p. 329-330) V.28 Then we have N Z Q R a. true true true true b. false true true true c. false false true true d. false false false true e. false false false false We arrive at the simple conclusion that the notion of truth depends on the structure being considered!

(LMCS, p. 332) V.29 First Order Syntax for (Directed) graphs The first order language of (directed) graphs is L = {r}, where r is a binary relation symbol. The only terms are the variables x. Atomic formulas look like (x y) or (rxy). Example The subformulas of are x ((rxy) y (ryx)) x ((rxy) y (ryx)) (rxy) y (ryx) rxy y (ryx) ryx.

(LMCS, p. 334-335) V.30 First Order to English b a d Graph A b c a e Graph B c d b. x (rxx) says the (directed) graph is irreflexive. False for Graph A, true for Graph B. c. x y ( (rxy) (ryx) ) says the (directed) graph is symmetric. False for Graph A, true for Graph B.

(LMCS, p. 334-335) V.31 b a d Graph A b c a e Graph B c d e. x y (rxy) says all possible edges are present. False for both examples. f. x y (rxy) says for every vertex x there is an edge going from x to some vertex y. True for both examples.

(LMCS, p. 335-336) V.32 English to First-Order a. The (directed) graph has at least two vertices. x y ( (x y)). b. Every vertex has an edge attached to it. x y ( (rxy) (ryx) ). c. Every vertex has at most two edges directed from it to other vertices. x y z w ( ((rxy) (rxz) (rxw) ) ( (y z) (y w) (w z) ) ).

(LMCS, p. 336-337) V.33 Statements About Graphs The degree of a vertex is the number of (undirected) edges attached to it. A path of length n from vertex x to vertex y is a sequence of vertices a 1,..., a n+1 with each (a i, a i+1 ) being an edge, and with x = a 1, y = a n+1. Two vertices are adjacent if there is an edge connecting them.

(LMCS) V.34 Some Definable Relations a. The degree of x is at least one. y (rxy) b. The degree of x is at least two. y z ( (y z) (rxy) (rxz)) Statements About Graphs a. Some vertex has degree at least two. x y z ( (y z) (rxy) (rxz) ) b. Every vertex has degree at least two. x y z ( (y z) (rxy) (rxz) )

(LMCS, p. 339) V.35 Semantics for First Order Logic Given a first order L structure S = (S, I), the interpretation I gives meaning to the symbols of the language L. We associate with each term t(x 1,, x n ) the n ary term function t S. We associate with each formula F(x 1,, x n ) an n ary relation F S S n : [The superscript S is omitted in the following for ease of reading.]

(LMCS, p. 339) V.36 F( x) is atomic: F is t 1 ( x ) t 2 ( x ) : F( a) holds iff t 1 ( a) = t 2 ( a) F is rt 1 ( x) t n ( x) F( a) holds iff r(t 1 ( a),..., t n ( a)) holds. F is G Then F( a ) holds iff G( a) does not hold.

(LMCS, p. 339) V.37 F is G H Then F( a ) holds iff G( a ) or H( a ) holds. F is G H Then F( a ) holds iff G( a ) and H( a ) holds. F is G H Then F( a ) holds iff G( a ) does not hold, or H( a ) holds.

(LMCS, p. 339) V.38 F is G H Then F( a ) holds iff both or neither of G( a ) and H( a ) holds. F( x) is y G(y, x) Then F( a ) holds iff G(b, a ) holds for every b S. F( x) is y G(y, x) Then F( a ) holds iff G(b, a ) holds for some b S.

(LMCS, p. 340) V.39 Example S = {a, b} r a b a 0 1 b 1 0 a b f b a F(x) = y z ((rfxfy) (rfyfz)). F S =? Let H 1 (x, y, z) = rfxfy H 2 (x, y, z) = rfyfz H(x, y, z) = H 1 (x, y, z) H 2 (x, y, z) G(x, y) = z H(x, y, z) F(x) = y G(x, y).

(LMCS, p. 340) V.40 Then x y z fx fy fz H 1 (x, y, z) H 2 (x, y, z) H(x, y, z) a a a b b b 0 0 0 a a b b b a 0 1 0 a b a b a b 1 1 1 a b b b a a 1 0 0 b a a a b b 1 0 0 b a b a b a 1 1 1 b b a a a b 0 1 0 b b b a a a 0 0 0 x y G(x, y) a a 0 a b 1 b a 1 b b 0 x F(x) a 0 b 0

(LMCS, p. 341) V.41 S = {a, b} r a b a 0 1 b 1 0 a b f b a F(x, y) = z ((rxfz) (fy z)) (fy fx). F S =? Let G 1 (x, y, z) = rxfz G 2 (x, y, z) = fy z G(x, y, z) = G 1 (x, y, z) G 2 (x, y, z) F 1 (x, y) = z G(x, y, z) F 2 (x, y) = fy fx F(x, y) = F 1 (x, y) F 2 (x, y).

(LMCS, p. 341) V.42 Then x y z fx fy fz G 1 (x, y, z) G 2 (x, y, z) G(x, y, z) a a a b b b 1 0 0 a a b b b a 0 1 0 a b a b a b 1 1 1 a b b b a a 0 0 0 b a a a b b 0 0 0 b a b a b a 1 1 1 b b a a a b 0 1 0 b b b a a a 1 0 0 so x y F 1 (x, y) F 2 (x, y) F(x, y) a a 0 1 1 a b 1 0 0 b a 1 0 0 b b 0 1 1

(LMCS, p. 342) V.43 Let F be a sentence and S a structure. Then F is true in S provided one of the following holds: F is rt 1 t n and r S (t S 1,..., ts n ) holds; F is t 1 t 2 and t S 1 = ts 2 ; F is G and G is not true in S; F is G H and at least one of G, H is true in S;

(LMCS, p. 342) V.44 F is G H and both of G, H are true in S; F is G H and G is not true in S or H is true in S; F is G H and both or neither of G, H is true in S; F is x G(x) and G S (a) is true for every a S; F is x G(x) and G S (a) is true for some a S. If F is not true in S, then we say F is false in S.

(LMCS, p. 342-343) V.45 Given a first order language L, let F be a sentence, S a set of sentences, and S a structure for this language. S = F means F is true in S. F is valid if it is true in all L structures. S = S means every sentence F in S is true in S. Sat(S) means S is satisfiable. S = F means every model of S is a model of F. We say F is a consequence of S.

(LMCS, p. 343) V.46 The Propositional Skeleton (A simple test for having a one element model.) The propositional skeleton, Skel(F), of a formula is defined as follows: Delete all quantifiers and terms. Replace with 1. Replace the relation symbols r with propositional variables R.

(LMCS, p. 343) V.47 Theorem F has a one element model iff Skel(F) is satisfiable. If Skel(F) is satisfiable, then choose an evaluation e that makes it true. Let r S (a,..., a) hold iff e(r) = 1 for r R. Let f S (a,..., a) = a for f F.

(LMCS, p. 343) V.48 To illustrate this, we consider the first order sentence F given by x y ( (x < y) z ((x < z) (fz y))). Then Skel(F) is the propositional formula P P 1 This is satisfiable by evaluating P as 0, so F has a one element model on the set {a}, namely < a a 0, and fa = a

(LMCS, p. 344) V.49 Equivalent Sentences The sentences F and G are equivalent, written F G, if they are true of the same L structures S, that is, for all structures S we have S = F iff S = G. x ( (x 0) y (x y 1)) and x y ( (x 0) (x y 1)) are equivalent. Proposition The sentences F and G are equivalent iff F G is a valid sentence.

(LMCS, p. 344) V.50 Equivalent Formulas Two formulas F(x 1,..., x n ) and G(x 1,..., x n ) are equivalent, written F(x 1,..., x n ) G(x 1,..., x n ), iff F and G define the same relation on any L structure S, that is, F S = G S. (x 0) y (x y 1) and y ( (x 0) (x y 1)) are equivalent.

(LMCS, p. 345) V.51 Proposition The formulas F( x) and G( x) are equivalent iff x(f( x) G( x)) is a valid sentence. Proposition The relation is an equivalence relation on sentences as well as on formulas. This is immediate from the definition of and the fact that ordinary equality (=) is an equivalence relation.

(LMCS, p. 346) V.52 Fundamental Equivalences x F x ( F) x F x ( F) ( x F) G x (F G) if x is not free in G ( x F) G x (F G) if x is not free in G ( x F) G x (F G) if x is not free in G ( x F) G x (F G) if x is not free in G ( x F) G x (F G) if x is not free in G ( x F) G x (F G) if x is not free in G F ( x G) x (F G) if x is not free in F F ( x G) x (F G) if x is not free in F x (F G) ( x F) ( x G) x (F G) ( x F) ( x G)

(LMCS, p. 346) V.53 Notes on the Fundamental Equivalences The first two, combined with the fundamental laws from propositional logic, are very useful in practice, e.g., the statement f is continuous at x: ε((ε > 0) δ((δ > 0) y( x y < δ fx fy < ε))), negates to f is not continuous at x: ε((ε > 0) δ((δ > 0) y(( x y < δ) ( fx fy < ε)))

(LMCS, p. 346) V.54 Comment If x occurs free in G then we cannot conclude ( x F) G x (F G), for example, ( x(x < 0)) (0 < x) and x((x < 0) (0 < x)) are not equivalent, for in the natural numbers the first is true of positive numbers x, whereas the second is false in the natural numbers.

(LMCS, p. 346) V.55 For implication we have: ( x F) G ( x F) G x ( F) G x ( F G) x (F G) To see that x (F G) ( x F) ( x G) need not be true consider the following example: x ((0 x) (0 < x)) and ( x (0 x)) ( x (0 < x)) And to see that x (F G) ( x F) ( x G) need not be true consider the example: x ((0 x) (0 < x)) and ( x (0 x)) ( x (0 < x))

(LMCS, p. 347) V.56 Replacement and Substitution Equivalent propositional formulas lead to equivalent first order formulas as follows. If F(P 1,..., P n ) and G(P 1,..., P n ) are equivalent propositional formulas, then for any sequence H 1,..., H n of first order formulas we have F(H 1,..., H n ) G(H 1,..., H n ) Example (P Q) P Q holds, so we have, in first order logic, ( ( x(x x 1)) ( x y(x y y x)) ) ( x(x x 1) ) ( x y(x y y x) )

(LMCS, p. 347) V.57 Equivalence is compatible with our connectives and quantifiers in the obvious sense. Lemma Suppose F 1 G 1 and F 2 G 2. Then F 1 G 1 F 1 F 2 G 1 G 2 F 1 F 2 G 1 G 2 F 1 F 2 G 1 G 2 F 1 F 2 G 1 G 2 x F 1 x G 1 x F 1 x G 1.

(LMCS, p. 347) V.58 This leads us to the basic replacement theorem for first order logic. Replacement Theorem If F G then H( F ) H( G ). Example Since ( ( x(x x 1)) ( x y(x y y x)) ) ( x(x x 1) ) ( x y(x y y x) ) we have ( x y(x < y)) ( ( x(x x 1)) ( x y(x y y x)) ) ( x y(x < y)) ( x(x x 1) ) ( x y(x y y x) )

(LMCS, p. 348) V.59 Substitution in first-order logic often requires the need to rename variables. We need to be careful with renaming variables to avoid binding any newly introduced occurrences of variables. Given a first order formula F, define a conjugate of F to be any formula F obtained by renaming the occurrences of bound variables of F so that no free occurrences of variables in F become bound. Keep bound occurrences of distinct variables distinct.

(LMCS, p. 348-349) V.60 Conjugates are equivalent: If F is a conjugate of F, then F F. Thus y(x y 1) w(x w 1). Substitution Theorem If F(x 1,..., x n ) G(x 1,..., x n ) and t 1,..., t n are terms, then Thus from follows F (t 1,..., t n ) G (t 1,..., t n ). y(x y 1) y( (x y 1)) u((y + w) u 1) u( ((y + w) u 1))

(LMCS, p. 349) V.61 Prenex Form A formula F is in prenex form if it looks like Q 1 x 1 Q n x n G where the Q i are quantifiers and G has no occurrences of quantifiers. A formula with no occurrences of quantifiers is called an open formula. The formula x ( (rxy) u (ruy) ) is not in prenex form, but it is equivalent to the prenex form formula x u ( (rxy) (ruy) ).

(LMCS, p. 349-350) V.62 Theorem Every formula is equivalent to a formula in prenex form. The following steps put F in prenex form: Rename the quantified variables so that distinct occurrences of quantifiers bind distinct variables, and no free variable is equal to a bound variable

(LMCS, p. 349-350) V.63 Thus change z((rzy) y((rxy) y(ryx))) to z((rzy) u((rxu) w(rwx))) Eliminate all occurrences of and using G H ( G H) ( H G) G H G H The above example becomes z( (rzy) u((rxu) w(rwx)))

(LMCS, p. 349-350) V.64 Pull the quantifiers to the front by repeated use of the following (F G) ( F G) (F G) ( F G) G ( x H) x (G H) G ( x H) x (G H) G ( x H) x (G H) G ( x H) x (G H) ( x G) H x (G H) ( x G) H x (G H) ( x G) H x (G H) ( x G) H x (G H) x G x G x G x G

(LMCS, p. 349-350) V.65 Applying these steps to z( (rzy) u((rxu) w(rwx))) gives z( (rzy) u((rxu) w(rwx))) z( (rzy) u( ((rxu) w(rwx)))) z u( (rzy) ((rxu) w(rwx))) z u( (rzy) ( (rxu) ( w(rwx)))) z u( (rzy) ( (rxu) w( (rwx)))) z u( (rzy) w( (rxu) ( (rwx)))) z u w( (rzy) ( (rxu) ( (rwx))))

(LMCS, p. 352) V.66 Valid Arguments Now we are working with sentences in a fixed first order language L. An argument F 1,, F n F is valid (or correct) in first order logic provided every structure S that makes F 1,..., F n true also makes F true, that is, for all S S = {F 1,..., F n } implies S = F.

(LMCS, p. 352) V.67 Proposition An argument F 1,, F n F in first order logic is valid iff F 1 F n F is a valid sentence; and this holds iff {F 1, F n, F} is not satisfiable.

(LMCS, p. 352) V.68 Example The work in Chapter 3 concerned equations. In first-order logic we treat equations as universally quantified sentences: x(s( x) t( x)) The argument x y u v (x y u v) x y z ((x y) z x (y z)) is valid. This is evident by considering that if a structure S satisfies the premiss then all multiplications give the same value. But then the multiplication must be associative.

(LMCS, p. 352) V.69 The argument y x (rxy) x y (rxy) is valid. To see this suppose S is a structure satisfying the premiss. Then choose an element a from S such that x (rxa) holds. From this we can conclude that x y (rxy) also holds since we can let y be a. We have demonstrated the validity of the above arguments by appealing to our reasoning skills in mathematics. It is fair to ask if one can now sit down and write out all the axioms and rules that one would ever need to justify valid arguments in first-order logic.

(LMCS, p. 352) V.70 This question was posed by Hilbert and Ackerman in 1928 in their slender book, the elementary and famous Principles of Logic. They proposed a collection of first-order axioms and rules of inference, and noted that they were correct rules of reasoning. But were they enough, that is, was their system complete? They said in their book that their proof system was sufficient for doing all the things they tried with first-order logic, and indeed asked if it was complete.

(LMCS) V.71 The brilliant young student Kurt Gödel in Vienna answered their question within a year, in the affirmitive, and used it for his PhD Thesis. This is the famous Gödel Completeness Theorem, discussed in Chapter 6 of the text. It says S = ϕ iff S ϕ. Another question that was prominent at the time was whether or not the powerful logical system of Principia Mathematica, developed by Whitehead and Russell in 3 volumes (1910-1913), was powerful enough to do all mathematics, forever.

(LMCS) V.72 This system of logic was higher-order, meaning that one could quantify over things other than just the variables for the elements of the universe. One could also quantify over relation symbols (and function symbols). Thus they could write r(rx ry) as a definition of x y. It was known, from looking at the examples in Principia, that all known mathematical proofs could be written up in this system (if one so desired). So perhaps this is all one would ever need. Within a year of his PhD Gödel had answered this (much more difficult) question as well.

(LMCS) V.73 To everyones astonishment he put together a (lowly) first-order sentence F in the language of the natural numbers N = {N, +,, <, 0, 1} that he could show was True of N But Principia Mathematica was not strong enough to prove it. (Assuming that the proof system of Principia did not lead to a contradiction G G, for then one could derive every formula!) This is the famous Gödel Incompleteness Theorem.

(LMCS, p. 353) V.74 Counterexamples To show that an argument F 1,, F n F is not valid it suffices to find a single structure S such that each of the premisses F 1,, F n is true in S, but the conclusion F is false in S. Such a structure S is a counterexample to the argument. The argument x y (rxy) y x (rxy) is not valid; a two element graph gives a counterexample: a b

(LMCS, p. 353-354) V.75 Skolemization Skolem, following the work of Löwenheim (1915), gave us a technique to convert a first-order sentence F into a sentence F in prenex form, with only universal quantifiers, such that F is satisfiable iff F is satisfiable. Universally quantified sentences are apparently much easier to understand. This has provided one of the powerful techniques in automated theorem proving.

(LMCS, p. 353-354) V.76 One takes a given assertion in mathematics and expresses it as a first-order sentence F. This means we want the assertion to be true iff F is valid (i.e., true in all structures). This sentence F is valid iff F is not satisfiable. One replaces F by a universal sentence F obtained by Skolem s process. Then F is valid iff F is not satisfiable. One puts the matrix of F in conjunctive form.

(LMCS, p. 353-354) V.77 Then it is easy to replace F by a finite set of clauses C such that F is not satisfiable iff C is not satisfiable. Namely the clauses come from the conjuncts of the matrix of F. Now one has F is valid iff C is not satisfiable. To show C is not satisfiable one can apply resolution theorem proving. Now we look at the details of Skolem s process, called skolemization.

(LMCS, p. 353-354) V.78 Lemma Given the sentence y G(y), augment the language with a new constant c and form the sentence G(c). Then Sat ( y G(y) ) iff Sat ( G(c) ). Given the sentence x 1 x n y G( x, y), augment the language with a new n ary function symbol f and form the sentence x 1 x n G ( x, f( x)). Then Sat ( x y G( x, y) ) iff Sat ( x G ( x, f( x)) ).

(LMCS, p. 354) V.79 Proof In each step we can expand a model of the sentence on the left hand side to one on the right hand side by adding the appropriately designated element for the constant, or by adding an appropriate function f. Conversely, we can take a model of the sentence on the right hand side and remove the constant symbol, respectively function symbol, and get a model for the left hand side.

(LMCS, p. 354) V.80 Definition A first order formula F is universal if it is in prenex form and all quantifiers are universal, that is, F is of the form x G, where G is quantifier free. G is called the matrix of F. Example x y z ((x y) (y z) (x z)) } {{ } matrix

(LMCS, p. 354) V.81 Theorem Given a first order sentence F, there is an effective procedure for finding a universal sentence F (usually in an extended language) such that Sat(F) iff Sat(F ). Furthermore, we can choose F such that every model of F can be expanded to a model of F, and every model of F can be reducted to a model of F. Proof First, we put F in prenex form. Then we just apply the Lemma repeatedly until there are no existential quantifiers.

(LMCS, p. 354) V.82 The process of converting a sentence to such a universal sentence is called skolemizing. The new constants and functions are called skolem constants and skolem functions. Example To skolemize the sentence F = x y ((x < y) z ((x < z) (z < y))) we first put it in prenex form F = x y z ((x < y) (x < z) (z < y))

(LMCS, p. 354) V.83 Applying the Lemma, we introduce a new binary function symbol, say f, and arrive at the universal sentence F = x y ((x < y) (x < f(x, y)) (f(x, y) < y)) The structure Q = (Q, <), consisting of the real numbers with the usual <, satisfies F. If we choose f(a, b) = a+b 2 for a, b Q, we see that the expansion (Q, <, f) of Q satisfies F. Now we extend these ideas to sets of sentences.

(LMCS, p. 356) V.84 Theorem Given a set of first order sentences S, there is a set S of universal sentences (usually in an extended language) such that Sat(S) iff Sat(S ). Furthermore, every model of S can be expanded to a model of S, and every model of S can be reducted to a model of S. Proof We skolemize each sentence in S as before, making sure that distinct sentences do not have any common skolem constants or functions.

(LMCS, p. 356) V.85 This theorem is at the heart of the translation from first order logic to clause logic, as we shall see in the next section. Example We skolemize the set of sentences { x y z (x < y + z), x y z ( (x < y + z))} and obtain a set of universal sentences { y (a < y + fy), x ( (b < y + gy))}.

(LMCS, p. 356) V.86 The Reduction of First-Order Logic to Clause Logic Now we show that first order formulas can be reduced to the predicate clause logic, and thus to the propositional clause logic. First we want to look at some basic translations between clauses and first order formulas. A clause C = {L 1 ( x),..., L k ( x)} is considered as the universal sentence F C = x (L 1 ( x) L k ( x)) in first-order logic.

(LMCS, p. 356) V.87 For indeed S = C iff S = F C. There is also a translation from universal first order sentences to clauses. Lemma One can effectively construct, for any given universal sentence F, a finite set C F of clauses such that for any structure S S = F iff S = C F.

(LMCS, p. 356) V.88 Proof Let F be x G( x) with G( x) quantifier free. Put G( x) in conjunctive form G( x) G 1 ( x) G k ( x), where each G i ( x) is a disjunction of literals. Then x G( x) x (G 1 ( x) G k ( x)) F 1 F k where F i = x G i ( x). Thus S = F iff S = {F 1,, F k }. Let C i be the clause C Fi associated with the matrix of F i. Then S = F iff S = C F

(LMCS, p. 356) V.89 Example Let F = x y z (rx ry rz). First, we put the matrix of F in conjunctive form: rx ry rz rx (ry rz) ( rx ry) ( rx rz). Now we can read off the clauses from the conjuncts, namely, C F = { { rx, ry}, { rx, rz} }.

(LMCS, p. 358) V.90 Definition For S a set of universal sentences let C S = C F, F S the union of the collection of all sets C F of clauses obtained from the universal sentences F in S. Lemma Given a set S of universal sentences and S a structure, S = S iff S = C S. Thus Sat(S) iff Sat(C S ).

(LMCS, p. 358) V.91 Now we can formulate a connection between satisfiability of a set of first order sentences (not necessarily universal) and a set of clauses. Lemma Given a set S of first order sentences, let S be a skolemization of S. Then Sat(S) iff Sat(C S ).

(LMCS, p. 358) V.92 Example For S = { x y (rxy), y x (rxy)} we have S = { y (ray), x (rxb)} C S = {{ray}, { rxb}}. We can easily derive the empty clause from C S (in one resolution step), so C S is not satisfiable. Thus S is also not satisfiable. Consequently, the sentence F = ( x y (rxy)) ( y x (rxy)), obtained by conjuncting the members of S, is not satisfiable. So F is a valid sentence. Clearly F ( x y (rxy)) ( y x (rxy))

(LMCS, p. 359) V.93 Now we can state the fundamental transformation from first order logic to clause logic. Theorem Given S, a set of sentences, and F, a sentence, S = F iff Sat( C S( F) ), where S( F) is the set S { F}, and the prime symbol refers to taking the skolemization, as before. Thus the argument S F is valid iff one cannot satisfy the set C S( F) of clauses.

(LMCS, p. 359) V.94 Example x y ( (rxy) (ryx) ) ( ((rxy) ) ) x y z (ryz) (rxz) x y (rxy (x y)). Let F be the conclusion. Then F x y (rxy (x y)). The premisses S are already skolemized, as they are universal sentences. For F we obtain the skolemized form (rab) (a b). Thus the set of clauses corresponding to the argument is { rxy, ryx} { rxy, ryz, rxz} {rab}, {a b}

(LMCS, p. 360) V.95 We can also handle equational arguments. Example Consider the argument x (x 1 x) x y (x y 1) x y z ( (x y) z x (y z) ) x (1 x x). The negation of the conclusion is the formula x ( (1 x x)).

(LMCS, p. 360) V.96 Thus skolemizing the premisses with the negated conclusion gives x (x 1 x) x (x fx 1) x y z ( (x y) z x (y z) ) (1 a a) These are ready to be converted to clauses, giving {x 1 x} {x fx 1} {(x y) z x (y z)} { (1 a a)}

(LMCS, p. 360) V.97 We can convert {x 1 x} {(x y) z x (y z)} {x fx 1} { (1 a a)} into a set of clauses without equality: {x x} {x y, y x} {x y, y z, x z} {x y, fx fy} {x 1 y 1, x 2 y 2, x 1 x 2 y 1 y 2 } {x 1 x} {x fx 1} {(x y) z x (y z)} {1 a a} Now we are ready to apply resolution theorem proving. (Go to Chapter 4!)