Handout 4 VII. First-Order Logic
Total Page:16
File Type:pdf, Size:1020Kb
06-26264 Reasoning The University of Birmingham Spring Semester 2019 School of Computer Science Volker Sorge 5 February, 2019 Handout 4 Summary of this handout: First-Order Logic — Syntax — Terms — Predicates — Quantifiers — Seman- tics — Substitution — Renaming — Ground Terms — Prenex Normal Form — Skolemisation — Clause Normal Form VII. First-Order Logic While propositional logic can express some basic facts we want to reason about, it is not rich enough to express many aspects of intelligent discourse or reasoning. We can talk about facts only very broadly, as we have no means of restricting ourselves to talking about what or who these facts apply to. We can express “it is raining” with a proposition, but we can not restrict it to a particular place like “it is raining in Birmingham” versus “it is not raining in London”. Moreover, we can not talk about general or abstract facts. E.g., a classic example which we can not yet express is: Socrates is a man, all men are mortal, therefore Socrates is mortal. In the following we will build the theoretical foundations for first-order predicate logic (FOL) that gives us a much more powerful instrument to reason. VII.1 Syntax Since the main purpose of first-order logic is to allow us to make statements about distinct entities in a particular domain or universe of discourse, we first need some notation to represent this. 29. Constants represent concrete individuals in our universe of discourse. Example: 0; 1; 2; 3 or “Birming- ham, London” or “John, Paul, Mary” are constants. 30. Functions maps individuals in the universe to other individuals, thereby relating them to each other. Example: father(John) = Paul expresses the Paul is John’s father. Functions have different arities, e.g., the sin function has arity one, + has arity two and so on. 31. Variables are symbolic representations of an entity that is not (or not yet) determined. They are similar to the variables you know from programming languages or from mathematics, e.g., as in 2x2 +x+1 = 0. With these three components we now formally define a notion of terms: Definition 20 (Terms). Let V; C; F be disjoint sets of symbols, representing variables, constants and functions, respectively. Then we define terms inductively as follows: 1. Any variable in V is a term. 2. Any constant symbol in C is a term. 3. If t1; : : : ; tn are terms and f 2 F has arity n, then f(t1; : : : ; tn) is a term. 4. Nothing else is an term. Often constant, function and even variables have names that are in someway connected to their semantic meaning (e.g., we use digits for numbers or meaningful function names like sin). However, this is not strictly necessary, and in general, we will avoid confusing syntax and semantic, by using uniform naming conventions for Constants to be c; d; e or c0; c1;::: 24 Functions to be f; g; h or f0; f1;::: Variables to be x; y; z or x0; x1;::: 32. Predicates In propositional logic the basic components were propositional variables that expressed the statements that could either be true or false. In first-order logic this role is played by predicates that can be applied to terms and are similarly statements that are either true or false. Thus, similar to functions, predicates have also an arity and we can view propositional variables as predicates of arity 0. We can then more formally define atomic formulas. For notation we will us capital roman letters, similar to our propositional variables. Normally, we will use P; Q; R; : : : or P0;P1;:::. Definition 21 (Atomic Formulae). Let P be a set of symbols representing predicates. (i) Let P 2 P a predicate taking n arguments and t1; t2; : : : ; tn are terms then P (t1; t2; : : : ; tn) is an atomic formula or atom. (ii) Nothing else is an atomic formula. Example: We can now formalise that Socrates is mortal by M(s), where s denotes Socrates and M denotes that its argument is mortal. 33. Ground Terms and Atoms In the above definitions, both terms and hence atoms can contain variables. We say that a term is ground if it does not contain any variables; that is, it is generated from C; F, only. Similarly we say an atom (or later formula) is ground, if it contains only ground terms. 34. Free and bound variables So far in our terms and atoms variables would occur free that is they serve the role of a placeholder for some term by which they can be substituted. We call a variable bound if it either is either substituted by a specific value or restricted to a set of values. For example, the x in sin(x) is free, while in the following expression it is bound to a specific interval 0 ≤ x ≤ π : sin(x) ≥ 0 35. Quantifiers While one can think of different ways to bind variables to sets of values, we are primarily interested in two ways: binding a variable to all possible values or to at least on value. As an example consider the sentences For all x, x2 ≥ 0 and there exists x, x2 = 1. More formally we will use the quantifiers 8 (for all) and 9 (there exists): 8x x2 ≥ 0 9x x2 = 1 Observe that in the quantifier notation we use the as a shorthand for parentheses. That is, we could have also written 8x(x2 ≥ 0) and 9x(x2 = 1). But since in our notation quantifiers will only ever be applied from the left, this notation will save us a lot of writing (and counting) of parentheses. 36. Scope of a quantifier is how far the “influence” of a quantifier reaches in our formula. This is given by the dot and parentheses notation. This point is best illustrated with an example: scope of 8x z }| { scope of 8z z }| { 8x (9y P (x; y) ) _ 8y Q(y; x) _ 8z R(x; z) | {z } | {z } scope of 9y scope of 8y We can now finalise the definition of the full syntax of first-order logic. 25 Definition 22 (Well Formed Fomulae). We define the well formed formulae of first-order logic as follows: (i) > and ? are well-formed formulae. (ii) Every atomic formula is a well-formed formula. (iii) If ' and are well-formed formulas, then so are: :'; ' ^ ; ' _ ; ' ! ; ' $ (iv) If ' is a well-formed formula and x 2 V is a variable, then 9x ' and 8x ' are well-formed formulae. (v) Nothing else is a well-formed formula. We will sometimes denote the set of well formed formulae in first-order logic as Wff(FOL), in particular, if we do not want to specify the underlying term set in detail. Example: This now allows us finally to simply denote our statement on Socrates formally as: (H(s) ^ 8x H(x) ! M(x)) ! M(s) VII.2 Semantics In propositional logic we gave the propositional variables meaning by interpreting them into a set of truth values. We now do something very similar, however we have to start by interpreting terms first. This is done by mapping them into a universe, which is a non-empty set U. Apart from the non-emptiness requirement, we have no restrictions on U; that is, it can be finite of any size, or infinite countable (e.g., the natural numbers) or uncountable (e.g., the real numbers). We formally define an interpretation as follows: Definition 23 (Interpretation). Let U be a non-empty set called universe. An interpretation I over U is a function that (i) maps each c 2 C to an element of U, (ii) maps each f 2 F with n arguments to a concrete function f I : U n ! U, i.e., the set of n-tuples over U to U, (iii) maps echo P 2 P with n arguments to a concrete function P I : U n ! fT; Fg. Observe that we use the superscript notation to distinguish between the syntactic and semantic entities, and in particular that I(f) = f I and I(P ) = P I . The distinction between f and f I and between P and P I is important. The symbols f and P are just that: symbols. Whereas f I and P I denote a concrete function and a concrete relation on an interpretation I, respectively. Example: Let C = fc0; c1; c2g, F = fsg, P = fMg. Assume we have the following universe U = fSocrates; Zeus; Heraclesg. We can now construct the following interpretation: I(c0) = Socrates I(c1) = Zeus I(c2) = Heracles I(s) = Son I(M) = is mortal Similar to propositional variables in an interpretation I an atomic formula is interpreted either as true, T, or as false, F. Also I is called a model of an atomic formula P (t1; : : : ; tn), i.e., I j= P (t1; : : : ; tn), I if and only if P (I(t1);:::;I(tn)) = T for ground terms t1; : : : ; tn. Example: Let C = fcg, F = ffg, and P = fP g; and given the atomic formulae P (c; c) P (c; f(c)) P (f(c); c) One possible interpretation is for example into the universe of natural numbers, where U= IN0 and 26 1. I(c) = 0, 2. I(f) = s, where s is the successor function (for example, ++ in Java or incr in Ocaml), then f I (I(c)) = s(0) = 1. 3. I(P ) =≤, the usual less-or-equal, which we normally write in infix notation. The interpretation of the three formulas is then I(P (c; c)) = P I (I(c); I(c))= 0 ≤ 0 = T I(P (c; f(c))) = 0 ≤ 1 = T I(P (f(c); c)) = 1 ≤ 0 = F Observe that = is not part of the syntax of our language! 37.