NOTES ON PREDICATE CALCULUS AND LOGIC PROGRAMMING

Size: px
Start display at page:

Download "NOTES ON PREDICATE CALCULUS AND LOGIC PROGRAMMING"

Transcription

1 NOTES ON PREDICATE CALCULUS AND LOGIC PROGRAMMING REFERENCES [1] Apt, K. R.: Logic Programming, Handbook of Theoretical Computer Science (J. van Leeuwen, ed.), Elsevier Science Publishers B.V., [2] Chang, C.-L. and Lee, R. C.-T.: Symbolic Logic and Mechanical Theorem Proving, Academic Press Inc., [3] Kowalski, R.: Logic for Problem Solving, North Holland, [4] Lloyd, J. W.: Foundations of Logic Programming, 2nd Edition, Springer Verlag, [5] Manna, Z.: Mathematical Theory of Computation, McGraw-Hill, [6] Mendelson, E.: Introduction to Mathematical Logic, 3rd Edition, Wadsworth & Brooks/Cole Advanced Books & Software, Monterey, California SUMMARY 1. SOME SYNTACTIC NOTIONS OF FIRST ORDER PREDICATE CALCULUS 2. SEMANTIC NOTIONS: INTERPRETATIONS AND MODELS 3. HERBRAND MODELS 4. HORN CLAUSES AND DEFINITE LOGIC PROGRAMS 4.1 LEAST HERBRAND MODELS OF DEFINITE LOGIC PROGRAMS 4.2 THE T P FUNCTION ON HERBRAND INTERPRETATIONS 4.3 THE SLD TREE AND THE SUCCESS SET 4.4 TURING COMPLETENESS OF HORN CLAUSES 4.5 NEGATIVE INFORMATION FROM DEFINITE LOGIC PROGRAMS 5. NORMAL PROGRAMS 6. PROGRAMS 1

2 1. SOME SYNTACTIC NOTIONS OF FIRST ORDER PREDICATE CALCULUS Consider a first order language L, that is, a language with: - variables: x, y, z,, - function symbols (of arity r 0): f, g, (function symbols of arity 0 are constant symbols), - predicate symbols (of arity r 0): p, q, (in particular, there may be a predicate symbol of arity 0, called true, and/or a predicate symbol of arity 0, called false), - terms constructed, as usual, from variables and function symbols of arity r applied to r terms, -atoms, also called atomic formulas, constructed from predicate symbols of arity r applied to r terms, - formulas which are either atoms or formulas constructed, as usual, from formulas using the connectives,,,,, and the quantifiers and with variables. (As usual, we can dispense with,,, and.) We will use the following auxiliary notions. - A literal is an atom or the negation of an atom. For instance, p(x,a) and p(f(x,y),b) are two literals. An atom is a positive literal and a negated atom is a negative literal. - A clause is a disjunction of zero or more literals. A clause with zero literals is called the empty clause, also written as, and it is identified with the predicate symbol false. - A formula is said to be in clausal form iff it is of the form: x 1 x 2 x m (C 1 C 2 C k ) where for 1 i k, C i is a clause and the variables x 1, x 2,, x m are all the distinct variables occurring in C 1 C 2 C k. x 1 x 2 x m (ϕ) is a shorthand for x 1 x 2 x m (ϕ). Instead of x (ϕ), we will also write x.ϕ or simply x ϕ. Analogously for, instead of. - In the formula x(ϕ) the subformula ϕ is said to be the scope of the quantifier ' x'. Analogously for, instead of. - An occurrence of a variable x is said to be bound in a formula ψ iff either it is the occurrence of x in ' x' or ' x' in ψ or it occurs in the scope of an occurrence of ' x' or ' x' in ψ. An occurrence of a variable is said to be free iff it is not bound. - A formula is said to be closed iff it has no occurrences of free variables, otherwise the formula is said to be open. Thus, every formula in clausal form is closed. - Given a clause C, a term (or a formula) is said to be ground iff that term (or formula) does not have any variable occurrence. Starting from Section 4 we restrict this notion so that ground terms (or atoms) belong to the Herbrand Universe (or Herbrand Base) generated by the programs and goals we consider. - Given a formula ϕ, the universal closure of ϕ is x 1 x m.ϕ, where x 1,, x m are the distinct variables occurring free in ϕ. It is denoted by (ϕ). Analogously for the existential closure of ϕ using, instead of. 2

3 - A substitution is a finite mapping from variables to terms. Given a substitution θ = {x 1 /t 1,, x n /t n }, the set {x 1,, x n }, where the variables x i 's, for i = 1,,n, are assumed to be distinct, is called the domain of θ and the set {t 1,, t n } is called the range of θ. For i = 1,, n, the pair x i /t i is called a binding for the variable x i. x/x is called an identity binding for the variable x. - If we apply a substitution θ to a term (or formula) t we obtain a new term (or formula), denoted by t θ, which is said to be an instance of t. Recall that a substitution should be applied 'in parallel and once', so that, for instance, f(g(x 1,x 1 ), g(x,b)){x/x 1, x 1 /b} = f(g(b,b), g(x 1,b)). - The composition θ σ of two substitutions θ = {x 1 /t 1,,x n /t n } and σ = {y 1 /s 1,,y m /s m } is the substitution obtained from the set {x 1 /(t 1 σ),, x n /(t n σ), y 1 /s 1,,y m /s m } by deleting the identity bindings and every binding y i /s i, for i i m, such that y i belongs to {x 1,, x n }. - A substitution µ is more general than a substitution θ iff there exists a substitution σ such that θ is equal to the composition µ σ, except for the possible presence of identity bindings. - A substitution θ = {x 1 /t 1,,x n /t n } is said to be in solved form iff the x i 's are all distinct and for i = 1,, n, the variable x i does not occur in {t 1,, t n }. - A substitution θ is idempotent iff θ θ = θ. - Given n ( 2) terms (or atoms) u 1,, u n, a substitution µ is said to be a unifier of u 1,, u n iff u 1 µ = = u n µ. If some terms (or atoms) have a unifier they are said to be unifiable. A unifier µ is said to be a most general unifier (or mgu, for short) iff µ is more general than any other unifier. It is the case that an mgu can always be chosen to be an idempotent substitution. An idempotent mgu µ is relevant, that is, each variable in domain(µ) range(µ) occurs in at least one of the terms (o atoms) to be unified. - As for any function, a substitution θ restricted to a set S of variables, is a substitution with domain S which agrees with θ for every variable in S. - A substitution θ is said to be grounding for the term t iff t θ is ground. Analogously for a formula ϕ, instead of a term t. Examples. (i) The term g(x,a) is an instance of the term g(x,y). (ii ) The composition θ σ of θ = {x/f(y), y/z} and σ = {x/a, y/b, z/y} is {x/f(b), z/y}, which has been obtained by deleting the identity binding y/y and the binding x/a from the set {x/f(b), y/y, x/a, y/b, z/y}. (iii) The composition {x/y, y/b}{x/y, y/b} is {x/b, y/b}. (iv) The substitution {x/y, z/g(x,a)} is more general than the substitution {x/f(y), z/g(x,a)}. (v) The most general unifier of p(a,f(y)) and p(x,f(t(x))) is {x/a, y/t(a)}. Given the two terms x and z, the substitutions: {x/y, z/y}, {x/z}, and {z/x} are unifiers. Only {x/z} and {z/x} are most general unifiers. Indeed, in particular, {x/z} is more general that {z/x}and vice versa. (vi) The substitution {x/y, z/g(x,a)} restricted to {x} is the substitution {x/y}. For other concepts not presented here and for more details we refer to [Kowalski, Lloyd]. 3

4 2. INTERPRETATIONS AND MODELS The interpretation I for the language L is obtained as follows: 1. take a non-empty set D, called the domain of the interpretation, 2. to each function symbol of arity r 0 we assign a function, that is, a mapping from D r to D. Thus, to each constant symbol we assign an element of D. 3. to each predicate symbol of arity r 0 we assign an r-ary relation, that is, a subset of D r, whose elements are r-tuples of elements in D. To true we assign the subset of D 0, which is the whole D 0, which is { }, that is, the set whose only element is the tuple, which is the tuple with zero components. To false we assign the subset of D 0 which is the empty set {}. A variable assignment σ for L is obtained as follows: to each variable of L we assign an element of D. Thus, given I and σ, we assign an element of D to every term t of L. Notation: σ[x/d] denotes the variable assignment which is equal to σ except that σ(x) = d. Satisfaction Relation =. For any given interpretation I, variable assignment σ, and formula ϕ we establish whether or not I,σ = ϕ holds, as we indicate below. If I,σ = ϕ holds we say that I and σ satisfies ϕ, or, equivalently, ϕ is true in the interpretation I and for the variable assignment σ. To denote that I,σ = ϕ holds, we write: I,σ = ϕ. To denote that I,σ = ϕ does not hold, we write: not I,σ = ϕ. In this case we may also write: I,σ ϕ. We give the definition of I,σ = ϕ by structural induction on ϕ. For any interpretation I, variable assignment σ, and atom p(t 1,,t r ) with predicate symbol p of arity r ( 0): I,σ = p(t 1,,t r ) iff the r-tuple v 1,, v r belongs to the relation assigned to the predicate symbol p by I, where v i, with 1 i r, is the value assigned to t i according to the given I and σ. Thus, since true and false have arity 0, for every I and σ we have that: I,σ = true because belongs to { }, and not I,σ = false because does not belong to the empty set. (Indeed, in any interpretation I the assignments to the predicate symbols true and false have been chosen with the objective of establishing that for every I and σ it is the case that I,σ = true and not I,σ = false.) For any interpretation I, variable assignment σ, and formula ϕ: I,σ = ϕ iff not I,σ = ϕ I,σ = ϕ ψ iff I,σ = ϕ and I,σ = ψ I,σ = ϕ ψ iff I,σ = ϕ or I,σ = ψ I,σ = ϕ ψ iff I,σ = ϕ implies I,σ = ψ, that is, if I,σ = ϕ then I,σ = ψ, that is, (not I,σ = ϕ) or (I,σ = ψ) I,σ = x.ϕ iff there exists d in D such that I,σ[x/d] = ϕ I,σ = x.ϕ iff for all d in D we have that I,σ[x/d] = ϕ. 4

5 We say that ϕ is true in an interpretation I or I is a model of ϕ or else ϕ has model I, and we write I = ϕ, iff for all σ we have that I,σ = ϕ. We say that ϕ is false in an interpretation I, and we write I = ϕ, iff it does not exist σ such that I,σ = ϕ (that is, for all σ we have that not I,σ = ϕ). (Notice the overloading of the operator = in the notations I = ϕ and I,σ = ϕ.) Since 'for all σ' is not equivalent to the negation of 'it does not exist σ', the two cases above do not cover all possibilities. However, we have that (Mendelson, page 50): given a closed formula ϕ and an interpretation I we have that either I = ϕ or I = ϕ. (This is an exclusive or.) Indeed, for a closed ϕ, the quantification on σ is not significant. Thus, for a closed ϕ and an interpretation I, we have that either ϕ is true in I (that is, for all σ. I,σ = ϕ) or ϕ is false in I (that is, for all σ it is not the case that I,σ = ϕ, which is equivalent to: for all σ. I,σ = ϕ). We say that a formula ϕ is satisfiable iff there exist I and σ such that I,σ = ϕ. (This definition is according to the ones in the books by Manna and Mendelson.) Thus, a closed formula ϕ is satisfiable iff there exists an interpretation I such that I = ϕ, that is, ϕ is satisfiable iff there exists an interpretation I which is a model of ϕ. A formula ϕ is unsatisfiable iff ϕ is not satisfiable. NOTE. In [Apt, page 513] there is a different definition of satisfiability: ϕ is satisfiable iff there exists an interpretation I such that I = ϕ, that is, iff there exists an interpretation I such that for all σ we have that I,σ = ϕ. When ϕ is a closed formula there is no difference between the Apt's definition of satisfiability and the one by Manna and Mendelson. We say that a formula ϕ is valid (or logically valid) and we write = ϕ, iff for every interpretation I we have that I = ϕ (that is, for all I and for all σ we have that I,σ = ϕ). Theorem 1. For every interpretation I and every formula ϕ we have that: I = ϕ (that is, ϕ is true in I) iff I = x.ϕ (that is, x.ϕ is true in I). (Notice that it does not matter whether or not x occurs in ϕ.) In particular, for every interpretation I and formula ϕ we have that: I = ϕ iff I = (ϕ). Proof. Omitted [Mendelson, page 310]. Hint: by applying the definitions we have to show that: for all σ we have that I,σ = ϕ iff for all σ' and for all d in D we have that I,σ' [x/d] = ϕ. 5

6 As an exercise we leave to the reader to show the dual statement, that is: for every formula ϕ we have that: there exist an interpretation I and a variable assignment σ such that I,σ = ϕ (that is, ϕ is satisfiable) iff there exist an interpretation I and a variable assignment σ such that I,σ = x.ϕ (that is, x.ϕ is satisfiable). (Notice that it does not matter whether or not x occurs in ϕ.) Notice that this property is not true for Apt's definition of satisfiability. From Theorem 1 and this exercise it follows that: - a formula ϕ is satisfiable iff its existential closure (ϕ) is satisfiable (also this property is not true for Apt's definition of satisfiability), and - a formula ϕ is valid iff its universal closure (ϕ) is valid. A formula ϕ logically implies a formula ψ (or ψ is a semantic consequence of ϕ) iff for every interpretation I and every variable assignment σ we have that I,σ = ϕ implies I,σ = ψ. If ϕ logically implies ψ, we write ϕ = ψ. This writing may be confusing, because of the overloading of the operator =. Indeed, here to the left of that operator we have a formula, instead of an interpretation, as in I = ϕ. This overloading, however, is not a problem even when we do not write the formula to the left of = ϕ, instead of writing the empty conjunction true, because in this case "for every interpretation I I = ϕ" and "true = ϕ" are equivalent. From the definitions it follows that: (i) ϕ = ψ iff = ϕ ψ. (ii) if ϕ = ψ then (for all I. I = ϕ implies I = ψ). In words: if a formula ϕ logically implies a formula ψ then every model of ϕ is also a model of ψ. Notice that (ii) becomes an 'iff' only when ϕ is a closed formula. Indeed we have that: (iii) if ϕ is a closed formula and (for all I. I = ϕ implies I = ψ) then ϕ = ψ. Indeed, if ϕ is a closed formula then ( ) for all I. ((for all σ. I,σ = ϕ) implies (for all σ. I,σ = ψ)) is equivalent to: ( ) for all I and σ. ((I,σ = ϕ) implies (I,σ = ψ)), because, since ϕ is closed, the variable assignment σ does not modify the value of the terms occurring in ϕ. (Notice that ( ) implies ( ) if ϕ is closed, while ( ) implies ( ) unconditionally.) If ϕ is not a closed formula then (for all I. I = ϕ implies I = ψ) does not imply ϕ = ψ, as we now show. Let ϕ be x=a and ψ be y.y=a. We have that: (1) (for all I. I = x=a implies I = y.y=a) holds by Theorem 1, and (2) x=a = y.y=a does not hold (take the interpretation with domain {a,b}, and let σ(x) be a, and '=' be interpreted as the identity on {a,b}). By (ii) and (iii) ' ϕ = ψ' can be read as 'every model of ϕ is a model of ψ' only if ϕ is closed, because only if ϕ is closed we have that ϕ = ψ holds iff every model of ϕ is a model of ψ. A formula ϕ is semantically equivalent to a formula ψ iff ϕ logically implies ψ and ψ logically implies ϕ. The notions of model, satisfiability, validity, logical implication, and logical equivalence can be extended in the obvious way to a set of formulas, instead of a formula only. Thus, for instance, an interpretation I is a model of a set S of formulas iff for every formula ϕ of S we have that I is a model of ϕ. 6

7 We say that a conjunction S of closed formulas is consistent iff it has a model. It can be proved that S has a model iff there exists a formula in the language which cannot be derived from S [Mendelson, page 35]. We say that S is inconsistent iff S is not consistent. Theorem 2 (Skolem 1920). For any given (closed or open) formula ϕ there exists a closed formula ψ in clausal form such that ϕ is satisfiable iff ψ is satisfiable. Obviously, we get an equivalent formulation of Skolem's theorem if we replace 'satisfiable' by 'unsatisfiable'. Here is the construction of ψ from ϕ following Manna: 1. Take the existential closure (ϕ) of ϕ (recall that ϕ(x) is satisfiable iff (ϕ) is satisfiable), and eliminate all quantifiers in whose scope there is no occurrence of the corresponding bound variable. 2. Rename the bound variables, so that any two quantifiers have two distinct bound variables. 3. Eliminate all occurrences of connectives other than,, and. 4. Push inward by replacing: (i) x by x, (ii) x by x, (iii) A by A, and (iv) by using De Morgan's laws. 5. Push quantifiers inward by using distributivity of over and distributivity of over. 6. Eliminate all existential quantifiers by replacing x 1 x 2 x m y B(y), where y is the leftmost existential quantifier, by x 1 x 2 x m B(f(x 1, x 2,, x m )), where f is a new function symbol. If m=0 then y B(y) is replaced by B(c) where c is a new constant symbol. 7. Push universal quantifiers outward. 8. Simplify by factoring (for instance, p(x) p(a) is simplified to p(a)) (see Section 3 below for details) or eliminating tautologies (for instance, p p is simplified to true) or using any other transformation which can be shown to preserve satisfiability. In particular, if logical equivalence is preserved, also satisfiability is preserved. Example. From x (p(x) z ( y (q(x,y) p(f(w))) y (q(x,y) p(x)))) we get the following sequence of formulas: 1. w x (p(x) ( y (q(x,y) p(f(w))) y (q(x,y) p(x)))) 2. w x (p(x) ( y (q(x,y) p(f(w))) z (q(x,z) p(x)))) 3. w x ( p(x) ( y ( q(x,y) p(f(w))) z ( q(x,z) p(x)))) 4. w x ( p(x) ( y (q(x,y) p(f(w))) z ( q(x,z) p(x)))) 5. w x ( p(x) (( y q(x,y) p(f(w))) ( z q(x,z) p(x)))) 6. x ( p(x) ((q(x,g(x)) p(f(c))) ( z q(x,z) p(x)))) 7. x z ( p(x) ((q(x,g(x)) p(f(c))) ( q(x,z) p(x)))) 8.1 x z (( p(x) (q(x,g(x)) p(f(c)))) ( p(x) q(x,z) p(x))) 8.2 x z (( p(x) (q(x,g(x)) p(f(c))))) (from 8.1 by elimination of a tautology) 8.3 x z (( p(x) q(x,g(x))) ( p(x) p(f(c)))) (from 8.2 by distributivity) 8.4 x (( p(x) q(x,g(x))) p(f(c))) (from 8.3 by factoring and by elimination of z) The two clauses of formula (8.4) are: (i) p(x) q(x,g(x)) and (ii) p(f(c)). 7

8 3. HERBRAND MODELS Let us consider a first order language L with at least one constant symbol. The Herbrand Universe HU of L is the set of all ground terms which can be constructed in L. The Herbrand Universe of L is not empty because there is at least one constant symbol. The Herbrand Base HB of L is the set of all ground atoms which can be constructed in L. The Herbrand Base is empty iff in L there are no predicate symbols. An Herbrand interpretation on L is an interpretation such that: - it has HU as its domain, - to every function symbol f of arity r ( 0) we assign the mapping which maps the terms t 1,, t r to the term f(t 1,, t r ), and - to every predicate symbol of arity r ( 0) we assign a set of r-tuples of terms each of which belongs to HU. An Herbrand interpretation of L is uniquely determined by a subset of the Herbrand Base HB of L. Actually, in what follows we identify an Herbrand interpretation with a subset of the Herbrand Base, and for any predicate symbol p and Herbrand interpretation I, we write p(t 1,, t r ) I for denoting that t 1,, t r belongs to the relation assigned to p by I. For any formula ϕ in the language L, an Herbrand interpretation which is a model of ϕ is said to be an Herbrand model of ϕ. Theorem 3. A formula ϕ in clausal form is satisfiable iff ϕ has an Herbrand model. Thus, we have that ϕ in clausal form is satisfiable iff there exists an Herbrand interpretation I such that I = ϕ. We also have that a formula ϕ in clausal form is unsatisfiable iff ϕ has no Herbrand models iff ϕ is false in all Herbrand interpretations (recall that every formula in clausal form is a closed formula). Theorem 4 (Herbrand 1930). A formula ϕ in clausal form is unsatisfiable iff there exists a finite conjunction of ground instances of its clauses which is unsatisfiable. Theorem 5 (Robinson 1965). A formula ϕ in clausal form is unsatisfiable iff starting from the clauses of ϕ by zero or more resolution steps we can get the empty clause. Resolution. A resolution step is defined as follows. Given a set of clauses, consider two of them, say C 1 : L 1 L i L i+1 L k and C 2 : M 1 M j M j+1 M h. Without loss of generality, we may assume that these clauses do not have variables in common. (1) Choose nondeterministically from clause C 1 a disjunction of i ( 1) atoms, say p(u 11,,u 1r ) p(u i1,,u ir ), and from clause C 2 a disjunction of j ( 1) negated atoms, say p(v 11,,v 1r ) p(v j1,,v jr ), which all share the same predicate symbol p. Without loss of generality, we may assume that those disjunctions are at the 8

9 leftmost position in the corresponding clauses. Let θ be a most general unifier of the atoms p(u 11,,u 1r ),, p(u i1,,u ir ), p(v 11,,v 1r ),, p(v j1,,v jr ) occurring in those disjunctions, that is, let θ be a most general substitution such that: p(u 11,,u 1r ) θ = = p(u i1,,u ir ) θ = p(v 11,,v 1r ) θ = = p(v j1,,v jr ) θ. (2)Add to the set of clauses the following clause: (L i+1 L k M j+1 M h ) θ. Given set P of clauses, a resolution step generates a new set Q such that P Q. A resolution step preserves satisfiability and unsatisfiability of a set of clauses. To compute a most general unifier of two atoms one can use the following algorithm. Unification Algorithm (1st version for 2 atoms) (Martelli-Montanari [Apt, page 501]). Let u 1,, u r, v 1,, v r, s 1,, s n, t 1,, t n, t denote terms and x denote a variable. In order to unify the atoms p(u 1,, u r ) and p(v 1,, v r ), consider the following set of equations: {u 1 = v 1,, u r = v r }. Then: REPEAT choose nondeterministically one equation, say E, from the set of equations at hand and perform one, if any, of the following actions: (i) if E is f(s 1,, s n ) = f(t 1,, t n ) then replace E by: s 1 = t 1,, s n = t n (ii) if E is f(s 1,, s n ) = g(t 1,, t m ) where f is different from g then 'halt with failure' (iii) if E is x = x then delete E (iv) if E is t = x where t is not a variable then replace E by: x = t (v) if E is x = t where (1) t is not x and (2) x occurs elsewhere in the set of equations at hand then if x occurs in t then 'halt with failure' else substitute t for x in every other equation UNTIL 'halt with failure' or no action in (i) (v) can be performed. The unification algorithm either (1) halts by producing an idempotent most general unifier of p(u 1,, u r ) and p(v 1,, v r ) or (2) halts with failure, that is, halts by declaring failure of unification. This unification algorithm can be extended to any finite set of atoms with the same predicate symbol. Indeed, it is enough to start from a set equations which, for any two atoms in the given set, entails by transitivity the equalities of their corresponding arguments. For instance, given the set {p(u 11,u 12 ), p(u 21,u 22 ), p(u 31,u 32 )} of atoms, a possible set of equations is {u 11 =u 21, u 12 =u 22, u 21 =u 31, u 22 =u 32 }. Unification Algorithm (2nd version for 2 atoms) (Robinson [Manna, page 139]). Given the atoms p(u 1,, u r ) and p(v 1,, v r ), we either construct an idempotent most general unifier of those atoms or we halt by declaring failure of unification, by applying the following algorithm: 9

10 σ, p1, p2 := {}, p(u 1,, u r ), p(v 1,, v r ) ; while (T does not 'halt with failure') and p1 p2 do σ, p1, p2 := T(σ, p1, p2) od where {} denotes the identity substitution, and the transformation T given a substitution σ and two atoms p1 and p2, generates a new substitution σ' and two new atoms p1' and p2' as we now indicate: let s1 and s2 be the two terms (or subterms) in p1 and p2, respectively, such that s1 and s2 are rooted at the leftmost position where p1 and p2, when considered as strings of symbols, do not have the same symbol, if either s1,s2 or s2,s1 is equal to x,t, where x is a variable and t is a term in which x does not occur then σ', p1', p2' := (σ{x/t}) {x/t}, p1{x/t}, p2{x/t} else 'halt with failure'. When the algorithm halts and failure of unification is not declared we have that σ is an idempotent most general unifier of the atoms p(u 1,, u r ) and p(v 1,, v r ). Example. Given the atoms p1 = p(a,x,f(g(y))) and p2 = p(z,h(z,w),f(w)), the Robinson's unification algorithm generates the following sequence of substitutions and atoms during the execution of the various iterations of the while-do statement: substitution σ: atom p1: atom p2: initialization: {} p(a, x, f(g(y))) p(z, h(z,w), f(w)) 1st iteration: {z/a} p(a, x, f(g(y))) p(a, h(a,w), f(w)) 2nd iteration: {z/a, x/h(a,w)} p(a, h(a,w), f(g(y))) p(a, h(a,w), f(w)) 3rd iteration: {z/a, x/h(a,g(y)), w/g(y)} p(a, h(a,g(y)), f(g(y))) p(a, h(a,g(y)), f(g(y))). The resulting idempotent most general unifier of p1 and p2 is {z/a, x/h(a,g(y)), w/g(y)}. Unification Algorithm (2nd version for n atoms) (Robinson [Manna, page 139]). The second version of the unification algorithm can be extended to any given set {p(u 11,,u 1r ),, p(u n1,,u nr )} of n ( 2) atoms with the same predicate symbol as follows. σ, p1,, pn := {}, p(u 11,,u 1r ),, p(u n1,,u nr ) ; while (T does not 'halt with failure') and there exist i and j in {1,,n} such that pi pj do σ, p1,, pn := T(σ, p1,, pn) od where {} denotes the identity substitution, and the transformation T given a substitution σ and the atoms p1,, pn, generates a new substitution σ' and the new atoms p1',, pn' as we now indicate. 10

11 Let us consider two different atoms, say pi and pj, in the set {p1,, pn}, with 1 i,j n. Let s1 and s2 be the two terms (or subterms) in pi and pj, respectively, such that s1 and s2 are rooted at the leftmost position where pi and pj, when considered as strings of symbols, do not have the same symbol, if either s1,s2 or s2,s1 is equal to x,t, where x is a variable and t is a term in which x does not occur then σ', p1',, pi',, pj',, pn' := (σ{x/t}) {x/t}, p1{x/t},, pi{x/t},, pj{x/t},, pn{x/t} else 'halt with failure'. NOTE. If we restrict ourselves to a version of the resolution method, call it 1-to-1 resolution, where each disjunction to be chosen, consists of one atom only, we are requested to unify two atoms only. However, there is a price to pay, as we now explain. (In the literature 1-to-1 resolution is also called binary resolution.) Factoring. Let us call a factoring step the one which given a clause, produces an instance of it in order to delete duplicate atoms. For instance, from the clause p(x,y) p(y,y) q(x) by factoring we can get the new clause p(x,x) q(x). Theorem 5a (Robinson 1965). A formula ϕ in clausal form is unsatisfiable iff starting from the clauses of ϕ by zero or more steps of 1-to-1 resolution or factoring we can get the empty clause. The notions of unifier and most general unifier for atoms can be extended in the obvious way to terms. In particular, the unifier of the terms t 1,, t n is the unifier of the atoms p(t 1 ),, p(t n ), where p is a new unary predicate symbol. Paramodulation. In order to deal with the equality predicate = which, as usual, is assumed to be reflexive, symmetric, transitive, and substitutive, that is, given any two terms r and s, if r=s then C[r]=C[s], for any context C[ ], we can use the inference rule called paramodulation [Chang- Lee, page 168]. 11

12 Let the clause C 1 be: L[t] D 1 and the clause C 2 be either r=s D 2 or s=r D 2 where L[t] is a (positive or negative) literal where we singled out an occurrence of the term t, and D 1 and D 2 are disjunctions of literals. Let us assume that the clauses C 1 and C 2 have no variables in common and let θ be the idempotent mgu of t and r. Let us consider the instances C 1 θ and C 2 θ of the clauses C 1 and C 2, respectively. Thus, in (L[t])θ we have an occurrence of the term t θ which is identical to r θ. By a paramodulation step from C 1 and C 2 we get the clause: (L[s] D 1 D 2 )θ where L[s] is the result of replacing the selected occurrence of t in L[t] by s. Examples. (1) From C 1 : q(x,a) p(x) and C 2 : a=b by paramodulation we get: q(x,b) p(x). In this case θ is the empty substitution {}, because it is the most general unifier of a and a. From C 1 and C 2 we can also get q(b,a) p(a), obtained for θ={x/a}. We can also get q(a,a) p(b). However, we cannot get q(a,b) p(a) because the occurrence of the term a which has been replaced by b, does not correspond to an occurrence of x in C 1. (2) From C 1 : p(f(g(y),z), z) w(z)=m and C 2 : a=f(x,g(x)) by paramodulation we get: p(a,g(g(y))) w(g(g(y)))=m. In this case the term t is f(g(y),z) and the term r is f(x,g(x)). Their idempotent mgu is the substitution {x/g(y), z/g(g(y))}. Given a formula ϕ, let us consider the conjunction E(ϕ) of the following equality clauses relative to ϕ: x = x and for each function symbol f of arity n ( 0) occurring in ϕ: f(x 1,, x n ) = f(x 1,, x n ). We have the following theorem. 12

13 Theorem 5b. (i) A formula ϕ in clausal form is unsatisfiable iff starting from the clauses of ϕ together with E(ϕ), by zero or more steps of resolution or paramodulation we can get the empty clause. (ii) A formula ϕ in clausal form is unsatisfiable iff starting from the clauses of ϕ together with E(ϕ), by zero or more steps of 1-to-1 resolution or factoring or paramodulation we can get the empty clause. NOTE. In the propositional case, factoring is not significant and we can drop factoring from Theorems 5a and 5b. NOTE. Unsatisfiability, satisfiability, and validity, are all decidable in propositional calculus (in at most exponential time on the length of the input formula). In first order predicate calculus unsatisfiability and validity are semidecidable. Satisfiability is undecidable and not semidecidable. By Post's Theorem, if satisfiability were semidecidable then both unsatisfiability and satisfiability would have been decidable. In second order predicate calculus unsatisfiability, satisfiability, and validity are undecidable and not semidecidable. NOTE. Let us consider a closed formula P and a formula A. We have that: (1) P A is different from (2) P = A. Indeed, (1) is a formula which may be true or false in a given interpretation, while (2) is a relation which states that every model of P is also a model of A. By Gödel's Completeness Theorem for the first order predicate calculus we have that: P = A iff P A. We also have that P A iff P A by the Deduction Theorem [Mendelson, page 59]. The relation P A says that P A is provable in the theory of the first order predicate calculus via a proof which starts from the axioms and uses the modus ponens rule and the generalization rule, which indeed, can be chosen to be the only inference rules for the first order predicate calculus [Mendelson, page 56]. NOTE. The resolution approach to theorem proving is based on the fact that given a set Γ {ϕ} of closed formulas, in order to show Γ ϕ, we may show that Γ { ϕ} is unsatisfiable. Indeed, Γ { ϕ} is unsatisfiable {by definition of unsatisfiability} iff Γ { ϕ} false {by the Deduction Theorem [Mendelson, page 59]} iff Γ ( ϕ false) {by ( ϕ false) ϕ} iff Γ ϕ. 13

14 In the next section we will consider the SLD-resolution method which can be considered both as a restriction and an extension of the resolution method. In particular, it is a restriction because clauses are restricted to Horn clauses and it is an extension because while resolution is applied, substitutions are recorded and suitably composed, so that they can be viewed as a result of a computation [3]. Indeed, as we will see in the next section, it is possible within logic to view the process of computing as the process of recording substitutions while generating constructive proofs. 14

15 4. HORN CLAUSES AND DEFINITE LOGIC PROGRAMS Let us consider a first order language L. Let atom 0, atom 1,, atom n be atoms in the language L. A definite clause C is a formula of the form: atom 0 atom 1,, atom n for n 0 atom 0 should not be false. (As explained later, if we allow atom 0 to be false then a definite program may have no models.) A definite clause is implicitly universally quantified. ' ' denotes reverse logical implication, that is, 'a b' stands for 'b a'. If n=0 then 'a ' stands for 'true a'. atom 0 is said to be the head of the definite clause C and it is denoted by hd(c). The sequence of atoms 'atom 1,, atom n ' is said to be the body of the definite clause, it is denoted by bd(c), and in that sequence ',' stands for (logical and). Thus, the body of a definite clause is a conjunction of atoms. A definite goal is a formula of the form: atom 1,, atom n for n 0 A definite goal is implicitly universally quantified. ' b' stands for 'b false'. ',' stands for (logical and). If n=0 then a definite goal is said to be empty. The empty goal is the same as the empty clause. A variant of a definite clause C (or a definite goal G) is obtained by applying to C (or G) a substitution of the form {x 1 /y 1,, x n /y n }, such that: (i) the set of variables {x 1,, x n } is contained in the set V of variables occurring in C, (ii) the variables y i 's are distinct, and (iii) (V {x 1,, x n }) {y 1,, y n } =. A Horn clause is either a definite clause or a definite goal. Thus, a Horn clause is a clause with at most one positive literal. A definite program is a finite conjunction of n ( 1) definite clauses which are implicitly universally quantified at the front. Given a definite program, we get an equivalent definite program if we delete a clause whose head is the atom true. The program C 1 C n will also be written as {C 1,, C n }. For the rest of this Section 4, unless otherwise specified or understood from the context, by clauses, goals, and programs we mean definite clauses, definite goals, and definite programs, respectively. 15

16 Given a program P, below we will define the denotational semantics of P via the so called least Herbrand model, denoted by M(P), and we will also define the operational semantics of P for a given goal A via the so called SLD tree. We will show that they are equivalent in the sense specified by the Theorems 8 and LEAST HERBRAND MODELS OF DEFINITE LOGIC PROGRAMS Let us consider a program P and a goal A. We assume that: (i) the first order language which we use for writing our terms and formulas, and generating the Herbrand Universe and the Herbrand Base, has exactly the constant symbols, the function symbols, and the predicate symbols occurring in P or in A, and (ii) if in P or in A there is one variable then there is at least one constant symbol. This Condition (ii) can always be fulfilled by adding to P the clause: newp(b) newp(b), where b is new constant symbol and newp is new predicate symbol. As we will see, the addition of this extra clause does not modify the computational behaviour of the given program P w.r.t. goals not involving newp. In what follows, when referring to 'ground instances of clauses' or 'ground atoms' or 'ground literals' we mean instances of clauses or atoms or literals, respectively, whose terms belong to the Herbrand Universe generated by the given program (and goal, if any). Let the definite program P be the conjunction C 1 C n of clauses. We recall that an Herbrand model of P is a set of ground atoms which is a subset of the Herbrand Base, and M is an Herbrand model of P, that is, M = P, iff M = (C 1 ) (C n ) (1) iff for each ground instance A A 1,, A n of a clause of P, M = ((A 1 A n ) A) (2) iff for each ground instance A A 1,, A n of a clause of P, if {A 1,,A n } M then A M. To understand how (2) is derived from (1), recall that by the definition of the satisfaction relation for a universally quantified formula we have to consider variable assignments which assign to every variable a term of the Herbrand Universe. It follows from our conventions stated at the beginning of Section 3 that for every Herbrand interpretation I, for all ground atoms A, A 1,, A n, we have that: (i) I = A iff A I, (ii) I = (A 1 A n ) iff {A 1,, A n } I, (iii) I = ((A 1 A n ) A) iff if {A 1,, A n } I then A I. The least Herbrand model M(P) of a program P is the least subset of the Herbrand Base which is a model of P. Example. For P = {p q(y), q(a) } we have that M(P) = {p, q(a)}. For P = {p(0), p(s(x)) p(x), p(s(s(a))) } we have that M(P) = {p(0), p(s(0)), 16

17 p(s(s(0)),, p(s(s(a))), p(s(s(s(a)))), }. M(P) {p(a)} is an Herbrand model of P and it properly includes the least Herbrand model. We now prove the so called Model Intersection Property for definite logic programs, that is, we prove that, given a set {M i i I} of Herbrand models of a given definite logic program P, their intersection i I M i is an Herbrand model of P. Obviously, i I M i is an Herbrand interpretation. Moreover i I M i is a model of P because for each ground instance A A 1,, A n of a clause of P if {A 1,, A n } i I M i then A i I M i. Indeed, {A 1,, A n } i I M i implies that for every i I, {A 1,, A n } M i, which in turn, implies that for every i I, A M i, because M i is a model of P. Thus, we have that: A i I M i. Notice that for programs which are not definite programs, the Model Intersection Property does not hold. Indeed, let us consider the program P = {p(a) p(b)} with one clause only, that is, p(a) p(b), which is not a definite clause. Thus, P is not a definite program. The sets {p(a)} and {p(b)} are two distinct Herbrand models of P, but their intersection which is the empty set, is not a model of P. The intersection of all Herbrand models of a given program P is an Herbrand model. It always exists. It is the least Herbrand model. It may be the empty model, that is, the empty subset of the Herbrand Base (actually, if we were to consider also the atom true, the empty model is the singleton {true}). Notice that the empty model has a non-empty domain, which is the Herbrand Universe (otherwise the empty model would not be an interpretation). The least Herbrand model of the program {p(0) q(y)} is the empty model. Theorem 6 (Kowalski - van Emden 1976). M(P) is the set of ground atoms which are semantic consequences of P, that is, M(P) = {A A is a ground atom and P = A}. Proof. P = A (that is, every model of P is a model of A, that is, for every interpretation I if P is true in I then A is true in I) iff P A false (that is, P A is unsatisfiable) (by Gödel's Completeness Theorem) iff P A is false in all interpretations (a) iff P A is false in all Herbrand interpretations (by Theorem 3) (b) iff A is false in all Herbrand interpretations which are models of P, (that is, A is false in all Herbrand models of P) (c) iff A is false in the least Herbrand model of P (d) iff A is true in the least Herbrand model of P, that is, A M(P). NOTE. (b) implies (a) because P and A are in clausal form. Moreover, (d) implies (c) because P is a definite program and the Model Intersection Property holds. 17

18 As a consequence of Theorem 6, for any definite program P and any ground conjunction A 1 A n of atoms, we have that: P = (A 1 A n ) iff M(P) = (A 1 A n ). ( ) If A 1 A n is not ground, we have that: (i) formula ( ) holds with 'implies', instead of 'iff', and (ii) formula ( ) with 'if ', instead of 'iff ', does not hold. Indeed, Property (i) follows from the fact that P = (A 1 A n ) means that (A 1 A n ) holds in every model of P, and thus, it holds also in the least Herbrand model of P. Property (ii) follows from the following example. Let us consider the program P = {p(0) } and the goal p(x). We have that: P = p(x) does not hold and M(P) = p(x) holds. Indeed, P does not implies p(x), that is, not in every model of P the formula p(x) is true, because: (i) P is equivalent to p(0), and (ii) it is not the case that {p(0)} p(x), that is, it is not the case that p(0) p(x) (Recall that by Gödel's Theorem [Mendelson], P = p(x) iff P p(x).) However, in the least Herbrand model of P which is {p(0)}, the formula p(x) holds, because x p(x) holds (recall that by Theorem 1, we have that: M(P) = p(x) holds iff M(P) = x p(x) holds): indeed, the variable x may only be assigned to the value 0 which is the only element in the Herbrand Universe of P. Finally, we notice that formula ( ) does not hold even with 'implies', instead of 'iff', if when constructing the domain of an interpretation, we do not comply with the restriction of using symbols which occur in the given program or goal. Indeed, let us consider the program P = {p(x), q(0) }. We have that: P = p(b) for some constant b which does not belong to the Herbrand Universe generated by P, and it is not the case that M(P) = p(b) because M(P) = {p(0), q(0)}. 4.2 THE T P FUNCTION ON HERBRAND INTERPRETATIONS Let us first recall a few basic definitions. A lattice L is a set, also denoted by L, together with a partial order, denoted by, and two operations, denoted by glb and lub, which are the greatest lower bound (w.r.t. ) and the least upper bound (w.r.t. ), respectively. As usual, the greatest lower bound of the elements x and y is denoted by glb(x,y), and the 18

19 greatest lower bound of a set S is denoted by glb(s), or simply glb S. Analogously for lub, instead of glb. For any x, y, and z, we have that: (i) the glb is a lower bound, that is, glb(x,y) x and glb(x,y) y, and (ii) the glb is the greatest lower bound, that is, if z x and z y then z glb(x,y). Analogously, for any x, y, and z, we have that: (i) the lub is a upper bound, that is, x lub(x,y) and y lub(x,y), and (ii) the lub is the least upper bound, that is, if x z and y z then lub(x,y) z. Obviously, when we say 'least' and 'greatest', we mean 'least' and 'greatest', respectively, w.r.t. the partial order. A lattice L is said to be complete iff the glb and the lub operations are defined for every (finite or infinite) subset of L. The lub of a complete lattice L is denoted by and is the least element of L. Let L be a complete lattice ordered by and T be a function from L to L. We say that x is a prefixpoint of T iff T(x) x. We also say that x is a fixpoint of T iff T(x) = x. Let us define T 0 (x) to be x, T k+1 (x) to be T(T k (x)) for any k 0, and T ω (x) to be lub{t k (x) k 0}. The function T: L L is said to be monotonic iff for every x and y if x y then T(x) T(y). The function T: L L is said to be continuous iff it is monotonic and for every infinite sequence x 0 x 1 of elements (possibly not all distinct) of L we have that: T(lub{x i i=0,1, }) = lub({t(x i ) i=0,1, }). Now we recall three well known lemmata. Lemma 1. Let T: L L be a monotonic function on a complete lattice L ordered by. glb{x T(x) x}, that is, the glb of all prefixpoints of T, is the least prefixpoint of T. Proof. We have to show that: (1) T(glb{x T(x) x}) glb{x T(x) x}, that is, glb{x T(x) x} is a prefixpoint of T, and (2) given any other prefixpoint z of T we have that glb{x T(x) x} z. Proof of (1). For every x such that T(x) x, we have that: glb{x T(x) x} x by definition of glb T(glb{x T(x) x}) T(x) by monotonicity of T ( ) T(glb{x T(x) x}) x because T(x) x. 19

20 Now since ( ) holds for every x such that T(x) x, T(glb{x T(x) x}) is a lower bound of the set {x T(x) x}. Since glb{x T(x) x} is the glb of that set we get: T(glb{x T(x) x}) glb{x T(x) x}. Proof of (2). It is trivial because for the glb, say u, of a set S we have that: u x for every element x in S. Lemma 2 (Knaster - Tarski 1955). Let T: L L be a monotonic function on a complete lattice L ordered by. T has a least fixpoint, denoted by lfp(t). We have that: lfp(t) = glb{x T(x) = x} = glb{x T(x) x}, that is, glb{x T(x) = x} is the least fixpoint of T, and glb{x T(x) x} is the least prefixpoint of T. Proof. We first show that: (1) T(glb{x T(x) x}) = glb{x T(x) x}, that is, glb{x T(x) x} is a fixpoint of T. (1) can be shown by proving that: (1.1) T(glb{x T(x) x}) glb{x T(x) x}, and (1.2) T(glb{x T(x) x}) glb{x T(x) x}. The proof of (1.1) is by Lemma 1. The proof of (1.2) is as follows. From (1.1) by monotonicity of T we get: T(T(glb{x T(x) x})) T(glb{x T(x) x}) Thus, T(glb{x T(x) x}) is a prefixpoint of T and hence, it belongs to the set {x T(x) x}. Thus, glb{x T(x) x} T(glb{x T(x) x}), as it should have been proved in (1.2). We also have: (2) glb{x T(x) = x} glb{x T(x) x} because glb{x T(x) = x} x for every x which is a fixpoint of T and glb{x T(x) x} is a fixpoint of T as we have shown in (1). We also have that: (3) glb{x T(x) x} glb{x T(x) = x} because {x T(x) = x} {x T(x) x}. From (2) and (3) we get: glb{x T(x) = x} = glb{x T(x) x}. Thus, also glb{x T(x) = x} is a fixpoint of T, because glb{x T(x) x} is a fixpoint of T, as we have shown in (1) above. We finally have that: glb{x T(x) = x} is the least fixpoint of T. Indeed, glb{x T(x) = x} is a fixpoint of T and it is a lower bound of every fixpoint of T. By Lemma 1 glb{x T(x) x} is the least prefixpoint of T and the proof of the lemma is completed. Note. The proof of Lemma 2 shows the usefulness of introducing the notion of prefixpoint, together with the notion of fixpoint. 20

21 Lemma 3. Let T: L L be a continuous function on a complete lattice L ordered by with least element. T ω ( ) is the least fixpoint of T and T ω ( ) is also the least prefixpoint of T. Proof. (1) We first show that T ω ( ) is a fixpoint of T. Indeed, T(T ω ( )) = T(lub{T k ( ) k 0}) = {by continuity of T} = = lub{t(t k ( )) k 0} = lub{t k ( ) k 1} = {by T( )} = = lub{t k ( ) k 0} = T ω ( ). (2) We then show that T ω ( ) is the least fixpoint of T. Indeed, take any other fixpoint z of T. We have that: T(z) = z. To show that T ω ( ) z we need to show that lub{t k ( ) k 0} z, or equivalently, we have to show that: for any k 0, T k ( ) z. This is shown by induction on k. (Basis) Obviously, z. (Step) Assume that T k ( ) z. Then T k+1 ( ) Τ(z) (by monotonicity of T) and since Τ(z) = z we get: T k+1 ( ) z, as desired. (3) We finally show that T ω ( ) is also the least prefixpoint of T. Indeed, T ω ( ) is a prefixpoint of T because it is a fixpoint of T. It can be shown that T ω ( ) is the least prefixpoint of T by a proof which is the one at point (2) above, by replacing '=' by ' ' and 'fixpoint' by 'prefixpoint'. Since an Herbrand interpretation is a subset of the Herbrand Base, the set of all Herbrand interpretations is a complete lattice, that is, the lattice of all the subsets of the Herbrand Base. This complete lattice is ordered by set inclusion, denoted by, as usual. The least element of this complete lattice is the empty set, denoted by, while the greatest element is the whole Herbrand Base. The glb and lub operations are, respectively, set intersection, denoted by, and set union, denoted by. Given a definite program P, let us consider the following function T P which takes an Herbrand interpretation and returns a new Herbrand interpretation: T P (I) = {A A A 1,, A n is a ground instance of a clause of P and {A 1,, A n } I}, that is, A T P (I) iff a ground instance A A 1,, A n of a clause of P and {A 1,, A n } I. Lemma 4. An Herbrand interpretation I is a model of a definite program P iff T P (I) I. Proof. I = P iff for each ground instance A A 1,, A n of a clause of P we have that I = ((A 1 A n ) A) iff for each ground instance A A 1,, A n of a clause of P we have that if {A 1,, A n } I then A I iff T P (I) I. This last step is justified by the fact that by definition of T P (I), we have that for each ground instance A A 1,, A n of a clause of P if {A 1,, A n } I then A T P (I). 21

22 We have that T P is a monotonic function on the complete lattice of all Herbrand interpretations, that is, if I 1 I 2 then T P (I 1 ) T P (I 2 ). We also have that T P is a continuous function on the complete lattice of all Herbrand interpretations. Indeed, given an infinite sequence I 0 I 1 of Herbrand interpretations, T P ( {I k k 0}) = {T P (I k ) k 0}. To show this, we have to show that: (1) T P ( {I k k 0}) {T P (I k ) k 0}, and (2) T P ( {I k k 0}) {T P (I k ) k 0}. Inclusion (1) easily follows from the fact that: for all k 0, {I k k 0}) I k which implies that for all k 0, T P ( {I k k 0}) T P (I k ) by monotonicity of T P. Thus, T P ( {I k k 0}) is an upper bound of the set {T P (I k ) k 0}, and the least upper bound {T P (I k ) k 0} of that set is included in the upper bound T P ( {I k k 0}). Inclusion (2), that is, T P ( {I k k 0}) {T P (I k ) k 0}, is proved as follows. Let us consider an infinite sequence I 0 I 1 of Herbrand interpretations and let us suppose that A T P ( {I k k 0}). Then, there exist some atoms A 1,, A n such that the clause A A 1,, A n is a ground instance of a clause of P and {A 1,, A n } {I k k 0}. Since for i = 1,, n, the atom A i belongs to the union {I k k 0} iff it belongs to I hi for some hi 0, we have that there exists h = max{h1,, hn} such that {A 1,, A n } I h. Thus, A T P (I h ), and hence, A {T P (I k ) k 0}. Theorem 7 (van Emden - Kowalski 1976). M(P) = least fixpoint of T P = T P ω ( ). Proof. M(P) = glb{i I is an Herbrand model of P} = (by Lemma 4) = glb{i T P (I) I} = (by Lemma 1) = the least prefixpoint of T P = (by Lemma 2) = the least fixpoint of T P = (by continuity of T P and Lemma 3) = T P ω ( ). 4.3 THE SLD TREE AND THE SUCCESS SET A computation rule is a total function that given a non-empty goal, selects an atom in that goal. A search rule is a partial function that given a program and an atom, returns a clause. Given a program P, a goal G, and a computation rule R, an SLD derivation for P, G, and R consists in: (i) choosing a search rule and (ii) constructing a (finite or infinite) sequence G 0, G 1, of goals, with G 0 =G, together with a corresponding sequence C 0, C 1, of variants of clauses of P and a corresponding sequence θ 0, θ 1, of most general unifiers. The construction of these three sequences is done incrementally, starting from G 0,,, 22

23 respectively. Then, for any i 0, goal G i+1, clause C i, and mgu θ i are constructed from goal G i by performing an SLD resolution step, as we now indicate. An SLD resolution step. Let G i be A 1,, A m 1, A m, A m+1,, A n, with n>0. (1) The computation rule R selects in G i an atom, say A m. (Since R is a total function, this step is always performed.) (2) Given P and A m, the search rule determines, if any, a clause D i in P such that hd(d i ) unifies with A m. We construct a variant C i of D i with no variable in common with G 0, G 1,, G i and we compute an idempotent mgu, call it θ i, such that hd(c i ) θ i = A m θ i. (3) G i+1 is the goal (A 1,, A m 1, bd(c i ), A m+1,, A n )θ i. If goal G i is empty or no clause D i exists such that hd(d i ) unifies with A m then G i+1, C i, and θ i are not constructed and the SLD derivation ends with the current sequences of goals, clauses, and mgu's. To perform an SLD resolution step using G i we require that C i does not have any variable in common with G 0, G 1,, G i for an easier construction of the computed answer substitutions (see below). Notice that an SLD resolution step is an 1-to-1 resolution step, and thus, the unification algorithm involves two atoms only. In the acronym SLD the letters S, L, and D stand for: (i) Selection (according to the computation rule) of the atom chosen for unification (indeed, step (1) of an SLD resolution has been called 'selection' precisely because of the SLD acronym), (ii) Linear resolution, because as in Linear resolution, at each step the new resolvent comes from the resolvent of the previous step and one clause of the program at hand (actually, in Linear resolution, at each step the new resolvent comes from the resolvent of the previous step and either one clause of the program or a resolvent obtained in one of the previous resolution steps) [Chang-Lee, page 131], and (iii) Definite logic programs. An SLD derivation which ends with the empty goal is called an SLD refutation. The computed answer substitution (c.a.s., for short) of an SLD refutation for a program P, a goal G, and a computation rule R is obtained by: (i) taking the composition of the most general unifiers of the sequence relative to that SLD refutation, and (ii) restricting the resulting substitution to the variables of G. Independence of the computation rule. If there is an SLD refutation for a program P, a goal G, and a computation rule R with c.a.s. θ, then for any other computation rule R' there exists an 23

The non-logical symbols determine a specific F OL language and consists of the following sets. Σ = {Σ n } n<ω

The non-logical symbols determine a specific F OL language and consists of the following sets. Σ = {Σ n } n<ω 1 Preliminaries In this chapter we first give a summary of the basic notations, terminology and results which will be used in this thesis. The treatment here is reduced to a list of definitions. For the

More information

Propositional Logic Language

Propositional Logic Language Propositional Logic Language A logic consists of: an alphabet A, a language L, i.e., a set of formulas, and a binary relation = between a set of formulas and a formula. An alphabet A consists of a finite

More information

INF3170 / INF4171 Notes on Resolution

INF3170 / INF4171 Notes on Resolution INF3170 / INF4171 Notes on Resolution Andreas Nakkerud Autumn 2015 1 Introduction This is a short description of the Resolution calculus for propositional logic, and for first order logic. We will only

More information

Top-Down Execution CS240B Notes

Top-Down Execution CS240B Notes Top-Down Execution CS240B Notes Notes based on Section 9.4 of Advanced Database Systems Morgan Kaufmann, 1997 C. Zaniolo, March 2002 p.1/22 Top-Down Execution of Datalog A strict bottom-up execution strategy

More information

Computational Logic Automated Deduction Fundamentals

Computational Logic Automated Deduction Fundamentals Computational Logic Automated Deduction Fundamentals 1 Elements of First-Order Predicate Logic First Order Language: An alphabet consists of the following classes of symbols: 1. variables denoted by X,

More information

Syntax. Notation Throughout, and when not otherwise said, we assume a vocabulary V = C F P.

Syntax. Notation Throughout, and when not otherwise said, we assume a vocabulary V = C F P. First-Order Logic Syntax The alphabet of a first-order language is organised into the following categories. Logical connectives:,,,,, and. Auxiliary symbols:.,,, ( and ). Variables: we assume a countable

More information

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms First-Order Logic 1 Syntax Domain of Discourse The domain of discourse for first order logic is FO structures or models. A FO structure contains Relations Functions Constants (functions of arity 0) FO

More information

ISTITUTO DI ANALISI DEI SISTEMI ED INFORMATICA

ISTITUTO DI ANALISI DEI SISTEMI ED INFORMATICA ISTITUTO DI ANALISI DEI SISTEMI ED INFORMATICA CONSIGLIO NAZIONALE DELLE RICERCHE A. Pettorossi, M. Proietti TOTALLY CORRECT LOGIC PROGRAM TRANSFORMATIONS VIA WELL-FOUNDED ANNOTATIONS R. 639 Febbraio 2006

More information

Computational Logic Fundamentals (of Definite Programs): Syntax and Semantics

Computational Logic Fundamentals (of Definite Programs): Syntax and Semantics Computational Logic Fundamentals (of Definite Programs): Syntax and Semantics 1 Towards Logic Programming Conclusion: resolution is a complete and effective deduction mechanism using: Horn clauses (related

More information

Chapter 2. Unification. Foundations of Logic Programming

Chapter 2. Unification. Foundations of Logic Programming Chapter 2 1 Outline Understanding the need for unification Defining alphabets, terms, and substitutions Introducing the Martelli-Montanari Algorithm for unification Proving correctness of the algorithm

More information

Přednáška 12. Důkazové kalkuly Kalkul Hilbertova typu. 11/29/2006 Hilbertův kalkul 1

Přednáška 12. Důkazové kalkuly Kalkul Hilbertova typu. 11/29/2006 Hilbertův kalkul 1 Přednáška 12 Důkazové kalkuly Kalkul Hilbertova typu 11/29/2006 Hilbertův kalkul 1 Formal systems, Proof calculi A proof calculus (of a theory) is given by: A. a language B. a set of axioms C. a set of

More information

Computational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/26)

Computational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/26) Computational Logic Davide Martinenghi Free University of Bozen-Bolzano Spring 2010 Computational Logic Davide Martinenghi (1/26) Propositional Logic - algorithms Complete calculi for deciding logical

More information

Definite Logic Programs

Definite Logic Programs Chapter 2 Definite Logic Programs 2.1 Definite Clauses The idea of logic programming is to use a computer for drawing conclusions from declarative descriptions. Such descriptions called logic programs

More information

1 FUNDAMENTALS OF LOGIC NO.10 HERBRAND THEOREM Tatsuya Hagino hagino@sfc.keio.ac.jp lecture URL https://vu5.sfc.keio.ac.jp/slide/ 2 So Far Propositional Logic Logical connectives (,,, ) Truth table Tautology

More information

Propositional and Predicate Logic - V

Propositional and Predicate Logic - V Propositional and Predicate Logic - V Petr Gregor KTIML MFF UK WS 2016/2017 Petr Gregor (KTIML MFF UK) Propositional and Predicate Logic - V WS 2016/2017 1 / 21 Formal proof systems Hilbert s calculus

More information

Outline. Logic. Definition. Theorem (Gödel s Completeness Theorem) Summary of Previous Week. Undecidability. Unification

Outline. Logic. Definition. Theorem (Gödel s Completeness Theorem) Summary of Previous Week. Undecidability. Unification Logic Aart Middeldorp Vincent van Oostrom Franziska Rapp Christian Sternagel Department of Computer Science University of Innsbruck WS 2017/2018 AM (DCS @ UIBK) week 11 2/38 Definitions elimination x φ

More information

A Tableau Calculus for Minimal Modal Model Generation

A Tableau Calculus for Minimal Modal Model Generation M4M 2011 A Tableau Calculus for Minimal Modal Model Generation Fabio Papacchini 1 and Renate A. Schmidt 2 School of Computer Science, University of Manchester Abstract Model generation and minimal model

More information

Introduction to Logic in Computer Science: Autumn 2007

Introduction to Logic in Computer Science: Autumn 2007 Introduction to Logic in Computer Science: Autumn 2007 Ulle Endriss Institute for Logic, Language and Computation University of Amsterdam Ulle Endriss 1 Tableaux for First-order Logic The next part of

More information

Syntax of FOL. Introduction to Logic in Computer Science: Autumn Tableaux for First-order Logic. Syntax of FOL (2)

Syntax of FOL. Introduction to Logic in Computer Science: Autumn Tableaux for First-order Logic. Syntax of FOL (2) Syntax of FOL Introduction to Logic in Computer Science: Autumn 2007 Ulle Endriss Institute for Logic, Language and Computation University of Amsterdam The syntax of a language defines the way in which

More information

Introduction to Metalogic

Introduction to Metalogic Philosophy 135 Spring 2008 Tony Martin Introduction to Metalogic 1 The semantics of sentential logic. The language L of sentential logic. Symbols of L: Remarks: (i) sentence letters p 0, p 1, p 2,... (ii)

More information

Logic Part I: Classical Logic and Its Semantics

Logic Part I: Classical Logic and Its Semantics Logic Part I: Classical Logic and Its Semantics Max Schäfer Formosan Summer School on Logic, Language, and Computation 2007 July 2, 2007 1 / 51 Principles of Classical Logic classical logic seeks to model

More information

Informal Statement Calculus

Informal Statement Calculus FOUNDATIONS OF MATHEMATICS Branches of Logic 1. Theory of Computations (i.e. Recursion Theory). 2. Proof Theory. 3. Model Theory. 4. Set Theory. Informal Statement Calculus STATEMENTS AND CONNECTIVES Example

More information

4 Predicate / First Order Logic

4 Predicate / First Order Logic 4 Predicate / First Order Logic 4.1 Syntax 4.2 Substitutions 4.3 Semantics 4.4 Equivalence and Normal Forms 4.5 Unification 4.6 Proof Procedures 4.7 Implementation of Proof Procedures 4.8 Properties First

More information

7.5.2 Proof by Resolution

7.5.2 Proof by Resolution 137 7.5.2 Proof by Resolution The inference rules covered so far are sound Combined with any complete search algorithm they also constitute a complete inference algorithm However, removing any one inference

More information

Mathematics 114L Spring 2018 D.A. Martin. Mathematical Logic

Mathematics 114L Spring 2018 D.A. Martin. Mathematical Logic Mathematics 114L Spring 2018 D.A. Martin Mathematical Logic 1 First-Order Languages. Symbols. All first-order languages we consider will have the following symbols: (i) variables v 1, v 2, v 3,... ; (ii)

More information

3 Propositional Logic

3 Propositional Logic 3 Propositional Logic 3.1 Syntax 3.2 Semantics 3.3 Equivalence and Normal Forms 3.4 Proof Procedures 3.5 Properties Propositional Logic (25th October 2007) 1 3.1 Syntax Definition 3.0 An alphabet Σ consists

More information

Herbrand Theorem, Equality, and Compactness

Herbrand Theorem, Equality, and Compactness CSC 438F/2404F Notes (S. Cook and T. Pitassi) Fall, 2014 Herbrand Theorem, Equality, and Compactness The Herbrand Theorem We now consider a complete method for proving the unsatisfiability of sets of first-order

More information

Some Rewriting Systems as a Background of Proving Methods

Some Rewriting Systems as a Background of Proving Methods Some Rewriting Systems as a Background of Proving Methods Katalin Pásztor Varga Department of General Computer Science Eötvös Loránd University e-mail: pkata@ludens.elte.hu Magda Várterész Institute of

More information

Outline. Formale Methoden der Informatik First-Order Logic for Forgetters. Why PL1? Why PL1? Cont d. Motivation

Outline. Formale Methoden der Informatik First-Order Logic for Forgetters. Why PL1? Why PL1? Cont d. Motivation Outline Formale Methoden der Informatik First-Order Logic for Forgetters Uwe Egly Vienna University of Technology Institute of Information Systems Knowledge-Based Systems Group Motivation Syntax of PL1

More information

SLD-Resolution And Logic Programming (PROLOG)

SLD-Resolution And Logic Programming (PROLOG) Chapter 9 SLD-Resolution And Logic Programming (PROLOG) 9.1 Introduction We have seen in Chapter 8 that the resolution method is a complete procedure for showing unsatisfiability. However, finding refutations

More information

First-Order Theorem Proving and Vampire

First-Order Theorem Proving and Vampire First-Order Theorem Proving and Vampire Laura Kovács 1,2 and Martin Suda 2 1 TU Wien 2 Chalmers Outline Introduction First-Order Logic and TPTP Inference Systems Saturation Algorithms Redundancy Elimination

More information

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig First-Order Logic First-Order Theories Roopsha Samanta Partly based on slides by Aaron Bradley and Isil Dillig Roadmap Review: propositional logic Syntax and semantics of first-order logic (FOL) Semantic

More information

Handout Proof Methods in Computer Science

Handout Proof Methods in Computer Science Handout Proof Methods in Computer Science Sebastiaan A. Terwijn Institute of Logic, Language and Computation University of Amsterdam Plantage Muidergracht 24 1018 TV Amsterdam the Netherlands terwijn@logic.at

More information

Part 1: Propositional Logic

Part 1: Propositional Logic Part 1: Propositional Logic Literature (also for first-order logic) Schöning: Logik für Informatiker, Spektrum Fitting: First-Order Logic and Automated Theorem Proving, Springer 1 Last time 1.1 Syntax

More information

8 General first order representation

8 General first order representation Intro. to Artificial Intelligence: Dale Schuurmans, Relu Patrascu 1 8 General first order representation 8.1 First order language Propositional core constants A, B, C, D predicates on(, ) associated arity,

More information

First Order Logic (FOL) 1 znj/dm2017

First Order Logic (FOL) 1   znj/dm2017 First Order Logic (FOL) 1 http://lcs.ios.ac.cn/ znj/dm2017 Naijun Zhan March 19, 2017 1 Special thanks to Profs Hanpin Wang (PKU) and Lijun Zhang (ISCAS) for their courtesy of the slides on this course.

More information

03 Review of First-Order Logic

03 Review of First-Order Logic CAS 734 Winter 2014 03 Review of First-Order Logic William M. Farmer Department of Computing and Software McMaster University 18 January 2014 What is First-Order Logic? First-order logic is the study of

More information

Automated Reasoning in First-Order Logic

Automated Reasoning in First-Order Logic Automated Reasoning in First-Order Logic Peter Baumgartner http://users.cecs.anu.edu.au/~baumgart/ 7/11/2011 Automated Reasoning in First-Order Logic... First-Order Logic Can express (mathematical) structures,

More information

Duality in Logic Programming

Duality in Logic Programming Syracuse University SURFACE Electrical Engineering and Computer Science Technical Reports College of Engineering and Computer Science 3-1991 Duality in Logic Programming Feng Yang Follow this and additional

More information

Version January Please send comments and corrections to

Version January Please send comments and corrections to Mathematical Logic for Computer Science Second revised edition, Springer-Verlag London, 2001 Answers to Exercises Mordechai Ben-Ari Department of Science Teaching Weizmann Institute of Science Rehovot

More information

Part 2: First-Order Logic

Part 2: First-Order Logic Part 2: First-Order Logic First-order logic formalizes fundamental mathematical concepts is expressive (Turing-complete) is not too expressive (e. g. not axiomatizable: natural numbers, uncountable sets)

More information

Advanced Topics in LP and FP

Advanced Topics in LP and FP Lecture 1: Prolog and Summary of this lecture 1 Introduction to Prolog 2 3 Truth value evaluation 4 Prolog Logic programming language Introduction to Prolog Introduced in the 1970s Program = collection

More information

Chapter 2: Basic Notions of Predicate Logic

Chapter 2: Basic Notions of Predicate Logic 2. Basic Notions of Predicate Logic 2-1 Deductive Databases and Logic Programming (Winter 2009/2010) Chapter 2: Basic Notions of Predicate Logic Signature, Formula Interpretation, Model Implication, Consistency,

More information

Inference in First Order Logic

Inference in First Order Logic Inference in First Order Logic Course: CS40002 Instructor: Dr. Pallab Dasgupta Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Inference rules Universal elimination:

More information

Notes. Corneliu Popeea. May 3, 2013

Notes. Corneliu Popeea. May 3, 2013 Notes Corneliu Popeea May 3, 2013 1 Propositional logic Syntax We rely on a set of atomic propositions, AP, containing atoms like p, q. A propositional logic formula φ Formula is then defined by the following

More information

Predicate Logic: Sematics Part 1

Predicate Logic: Sematics Part 1 Predicate Logic: Sematics Part 1 CS402, Spring 2018 Shin Yoo Predicate Calculus Propositional logic is also called sentential logic, i.e. a logical system that deals with whole sentences connected with

More information

Logic. Knowledge Representation & Reasoning Mechanisms. Logic. Propositional Logic Predicate Logic (predicate Calculus) Automated Reasoning

Logic. Knowledge Representation & Reasoning Mechanisms. Logic. Propositional Logic Predicate Logic (predicate Calculus) Automated Reasoning Logic Knowledge Representation & Reasoning Mechanisms Logic Logic as KR Propositional Logic Predicate Logic (predicate Calculus) Automated Reasoning Logical inferences Resolution and Theorem-proving Logic

More information

1 Introduction to Predicate Resolution

1 Introduction to Predicate Resolution 1 Introduction to Predicate Resolution The resolution proof system for Predicate Logic operates, as in propositional case on sets of clauses and uses a resolution rule as the only rule of inference. The

More information

3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas.

3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas. 1 Chapter 1 Propositional Logic Mathematical logic studies correct thinking, correct deductions of statements from other statements. Let us make it more precise. A fundamental property of a statement is

More information

Propositional Logic: Models and Proofs

Propositional Logic: Models and Proofs Propositional Logic: Models and Proofs C. R. Ramakrishnan CSE 505 1 Syntax 2 Model Theory 3 Proof Theory and Resolution Compiled at 11:51 on 2016/11/02 Computing with Logic Propositional Logic CSE 505

More information

185.A09 Advanced Mathematical Logic

185.A09 Advanced Mathematical Logic 185.A09 Advanced Mathematical Logic www.volny.cz/behounek/logic/teaching/mathlog13 Libor Běhounek, behounek@cs.cas.cz Lecture #1, October 15, 2013 Organizational matters Study materials will be posted

More information

Definite Logic Programs: Derivation and Proof Trees. CSE 505 Computing with Logic Stony Brook University

Definite Logic Programs: Derivation and Proof Trees. CSE 505 Computing with Logic Stony Brook University Definite Logic Programs: Derivation and Proof Trees CSE 505 Computing with Logic Stony Brook University http://www.cs.stonybrook.edu/~cse505 1 Refutation in Predicate Logic parent(pam, bob). parent(tom,

More information

Mathematical Preliminaries. Sipser pages 1-28

Mathematical Preliminaries. Sipser pages 1-28 Mathematical Preliminaries Sipser pages 1-28 Mathematical Preliminaries This course is about the fundamental capabilities and limitations of computers. It has 3 parts 1. Automata Models of computation

More information

Overview of Logic and Computation: Notes

Overview of Logic and Computation: Notes Overview of Logic and Computation: Notes John Slaney March 14, 2007 1 To begin at the beginning We study formal logic as a mathematical tool for reasoning and as a medium for knowledge representation The

More information

Predicate Calculus. Formal Methods in Verification of Computer Systems Jeremy Johnson

Predicate Calculus. Formal Methods in Verification of Computer Systems Jeremy Johnson Predicate Calculus Formal Methods in Verification of Computer Systems Jeremy Johnson Outline 1. Motivation 1. Variables, quantifiers and predicates 2. Syntax 1. Terms and formulas 2. Quantifiers, scope

More information

COMP9414: Artificial Intelligence First-Order Logic

COMP9414: Artificial Intelligence First-Order Logic COMP9414, Wednesday 13 April, 2005 First-Order Logic 2 COMP9414: Artificial Intelligence First-Order Logic Overview Syntax of First-Order Logic Semantics of First-Order Logic Conjunctive Normal Form Wayne

More information

From Constructibility and Absoluteness to Computability and Domain Independence

From Constructibility and Absoluteness to Computability and Domain Independence From Constructibility and Absoluteness to Computability and Domain Independence Arnon Avron School of Computer Science Tel Aviv University, Tel Aviv 69978, Israel aa@math.tau.ac.il Abstract. Gödel s main

More information

Transformation Rules for Locally Stratied Constraint Logic Programs

Transformation Rules for Locally Stratied Constraint Logic Programs Transformation Rules for Locally Stratied Constraint Logic Programs Fabio Fioravanti 1, Alberto Pettorossi 2, Maurizio Proietti 3 (1) Dipartimento di Informatica, Universit dell'aquila, L'Aquila, Italy

More information

On the Complexity of the Reflected Logic of Proofs

On the Complexity of the Reflected Logic of Proofs On the Complexity of the Reflected Logic of Proofs Nikolai V. Krupski Department of Math. Logic and the Theory of Algorithms, Faculty of Mechanics and Mathematics, Moscow State University, Moscow 119899,

More information

07 Equational Logic and Algebraic Reasoning

07 Equational Logic and Algebraic Reasoning CAS 701 Fall 2004 07 Equational Logic and Algebraic Reasoning Instructor: W. M. Farmer Revised: 17 November 2004 1 What is Equational Logic? Equational logic is first-order logic restricted to languages

More information

2.5.2 Basic CNF/DNF Transformation

2.5.2 Basic CNF/DNF Transformation 2.5. NORMAL FORMS 39 On the other hand, checking the unsatisfiability of CNF formulas or the validity of DNF formulas is conp-complete. For any propositional formula φ there is an equivalent formula in

More information

Exercises 1 - Solutions

Exercises 1 - Solutions Exercises 1 - Solutions SAV 2013 1 PL validity For each of the following propositional logic formulae determine whether it is valid or not. If it is valid prove it, otherwise give a counterexample. Note

More information

CSC384: Intro to Artificial Intelligence Knowledge Representation II. Required Readings: 9.1, 9.2, and 9.5 Announcements:

CSC384: Intro to Artificial Intelligence Knowledge Representation II. Required Readings: 9.1, 9.2, and 9.5 Announcements: CSC384: Intro to Artificial Intelligence Knowledge Representation II Required Readings: 9.1, 9.2, and 9.5 Announcements: 1 Models Examples. Environment A Language (Syntax) Constants: a,b,c,e Functions:

More information

Logic and Reasoning. Foundations of Computing Science. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

Logic and Reasoning. Foundations of Computing Science. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Logic and Reasoning Foundations of Computing Science Pallab Dasgupta Professor, Dept. of Computer Sc & Engg 2 Knowledge and Reasoning Representation, Reasoning and Logic Propositional Logic First-Order

More information

Conjunction: p q is true if both p, q are true, and false if at least one of p, q is false. The truth table for conjunction is as follows.

Conjunction: p q is true if both p, q are true, and false if at least one of p, q is false. The truth table for conjunction is as follows. Chapter 1 Logic 1.1 Introduction and Definitions Definitions. A sentence (statement, proposition) is an utterance (that is, a string of characters) which is either true (T) or false (F). A predicate is

More information

Introduction to Logic in Computer Science: Autumn 2006

Introduction to Logic in Computer Science: Autumn 2006 Introduction to Logic in Computer Science: Autumn 2006 Ulle Endriss Institute for Logic, Language and Computation University of Amsterdam Ulle Endriss 1 Plan for Today Today s class will be an introduction

More information

CS 730/730W/830: Intro AI

CS 730/730W/830: Intro AI CS 730/730W/830: Intro AI 1 handout: slides 730W journal entries were due Wheeler Ruml (UNH) Lecture 9, CS 730 1 / 16 Logic First-Order Logic The Joy of Power Wheeler Ruml (UNH) Lecture 9, CS 730 2 / 16

More information

INTRODUCTION TO PREDICATE LOGIC HUTH AND RYAN 2.1, 2.2, 2.4

INTRODUCTION TO PREDICATE LOGIC HUTH AND RYAN 2.1, 2.2, 2.4 INTRODUCTION TO PREDICATE LOGIC HUTH AND RYAN 2.1, 2.2, 2.4 Neil D. Jones DIKU 2005 Some slides today new, some based on logic 2004 (Nils Andersen), some based on kernebegreber (NJ 2005) PREDICATE LOGIC:

More information

Intelligent Agents. First Order Logic. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University. last change: 19.

Intelligent Agents. First Order Logic. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University. last change: 19. Intelligent Agents First Order Logic Ute Schmid Cognitive Systems, Applied Computer Science, Bamberg University last change: 19. Mai 2015 U. Schmid (CogSys) Intelligent Agents last change: 19. Mai 2015

More information

Equational Logic. Chapter Syntax Terms and Term Algebras

Equational Logic. Chapter Syntax Terms and Term Algebras Chapter 2 Equational Logic 2.1 Syntax 2.1.1 Terms and Term Algebras The natural logic of algebra is equational logic, whose propositions are universally quantified identities between terms built up from

More information

Part II. Logic and Set Theory. Year

Part II. Logic and Set Theory. Year Part II Year 2018 2017 2016 2015 2014 2013 2012 2011 2010 2009 2008 2007 2006 2005 2018 60 Paper 4, Section II 16G State and prove the ǫ-recursion Theorem. [You may assume the Principle of ǫ- Induction.]

More information

Gödel s Completeness Theorem

Gödel s Completeness Theorem A.Miller M571 Spring 2002 Gödel s Completeness Theorem We only consider countable languages L for first order logic with equality which have only predicate symbols and constant symbols. We regard the symbols

More information

CS 730/830: Intro AI. 3 handouts: slides, asst 6, asst 7. Wheeler Ruml (UNH) Lecture 12, CS / 16. Reasoning.

CS 730/830: Intro AI. 3 handouts: slides, asst 6, asst 7. Wheeler Ruml (UNH) Lecture 12, CS / 16. Reasoning. CS 730/830: Intro AI 3 handouts: slides, asst 6, asst 7 Wheeler Ruml (UNH) Lecture 12, CS 730 1 / 16 Logic First-Order Logic The Joy of Power in First-order Logic Wheeler Ruml (UNH) Lecture 12, CS 730

More information

Predicate Calculus. CS 270 Math Foundations of Computer Science Jeremy Johnson

Predicate Calculus. CS 270 Math Foundations of Computer Science Jeremy Johnson Predicate Calculus CS 270 Math Foundations of Computer Science Jeremy Johnson Presentation uses material from Huth and Ryan, Logic in Computer Science: Modelling and Reasoning about Systems, 2nd Edition

More information

A Unit Resolution Approach to Knowledge Compilation. 2. Preliminaries

A Unit Resolution Approach to Knowledge Compilation. 2. Preliminaries A Unit Resolution Approach to Knowledge Compilation Arindama Singh and Manoj K Raut Department of Mathematics Indian Institute of Technology Chennai-600036, India Abstract : Knowledge compilation deals

More information

CS2742 midterm test 2 study sheet. Boolean circuits: Predicate logic:

CS2742 midterm test 2 study sheet. Boolean circuits: Predicate logic: x NOT ~x x y AND x /\ y x y OR x \/ y Figure 1: Types of gates in a digital circuit. CS2742 midterm test 2 study sheet Boolean circuits: Boolean circuits is a generalization of Boolean formulas in which

More information

Prolog. Resolution (for beginners?) Resolution (cont.) Resolution (cont.) Unification. Resolution (still cont.) Resolution & Unification

Prolog. Resolution (for beginners?) Resolution (cont.) Resolution (cont.) Unification. Resolution (still cont.) Resolution & Unification Resolution & Unification Prolog Computer Science Resolution (for beginners?) Resolution is a theorem proving method developed by Robinson based on representing logical formulas as clauses Clauses are build

More information

CS589 Principles of DB Systems Fall 2008 Lecture 4e: Logic (Model-theoretic view of a DB) Lois Delcambre

CS589 Principles of DB Systems Fall 2008 Lecture 4e: Logic (Model-theoretic view of a DB) Lois Delcambre CS589 Principles of DB Systems Fall 2008 Lecture 4e: Logic (Model-theoretic view of a DB) Lois Delcambre lmd@cs.pdx.edu 503 725-2405 Goals for today Review propositional logic (including truth assignment)

More information

MAI0203 Lecture 7: Inference and Predicate Calculus

MAI0203 Lecture 7: Inference and Predicate Calculus MAI0203 Lecture 7: Inference and Predicate Calculus Methods of Artificial Intelligence WS 2002/2003 Part II: Inference and Knowledge Representation II.7 Inference and Predicate Calculus MAI0203 Lecture

More information

First-Order Logic. Chapter Overview Syntax

First-Order Logic. Chapter Overview Syntax Chapter 10 First-Order Logic 10.1 Overview First-Order Logic is the calculus one usually has in mind when using the word logic. It is expressive enough for all of mathematics, except for those concepts

More information

Propositional Resolution Introduction

Propositional Resolution Introduction Propositional Resolution Introduction (Nilsson Book Handout) Professor Anita Wasilewska CSE 352 Artificial Intelligence Propositional Resolution Part 1 SYNTAX dictionary Literal any propositional VARIABLE

More information

Negative Hyper-Resolution as Procedural Semantics of Disjunctive Logic Programs

Negative Hyper-Resolution as Procedural Semantics of Disjunctive Logic Programs Negative Hyper-Resolution as Procedural Semantics of Disjunctive Logic Programs Linh Anh Nguyen Institute of Informatics, University of Warsaw ul. Banacha 2, 02-097 Warsaw, Poland nguyen@mimuw.edu.pl Abstract.

More information

Classical First-Order Logic

Classical First-Order Logic Classical First-Order Logic Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2008/09

More information

Resolution for Predicate Logic

Resolution for Predicate Logic Logic and Proof Hilary 2016 James Worrell Resolution for Predicate Logic A serious drawback of the ground resolution procedure is that it requires looking ahead to predict which ground instances of clauses

More information

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw

Applied Logic. Lecture 1 - Propositional logic. Marcin Szczuka. Institute of Informatics, The University of Warsaw Applied Logic Lecture 1 - Propositional logic Marcin Szczuka Institute of Informatics, The University of Warsaw Monographic lecture, Spring semester 2017/2018 Marcin Szczuka (MIMUW) Applied Logic 2018

More information

Restricted truth predicates in first-order logic

Restricted truth predicates in first-order logic Restricted truth predicates in first-order logic Thomas Bolander 1 Introduction It is well-known that there exist consistent first-order theories that become inconsistent when we add Tarski s schema T.

More information

CHAPTER 2. FIRST ORDER LOGIC

CHAPTER 2. FIRST ORDER LOGIC CHAPTER 2. FIRST ORDER LOGIC 1. Introduction First order logic is a much richer system than sentential logic. Its interpretations include the usual structures of mathematics, and its sentences enable us

More information

First order Logic ( Predicate Logic) and Methods of Proof

First order Logic ( Predicate Logic) and Methods of Proof First order Logic ( Predicate Logic) and Methods of Proof 1 Outline Introduction Terminology: Propositional functions; arguments; arity; universe of discourse Quantifiers Definition; using, mixing, negating

More information

CS156: The Calculus of Computation Zohar Manna Winter 2010

CS156: The Calculus of Computation Zohar Manna Winter 2010 Page 3 of 35 Page 4 of 35 quantifiers CS156: The Calculus of Computation Zohar Manna Winter 2010 Chapter 2: First-Order Logic (FOL) existential quantifier x. F [x] there exists an x such that F [x] Note:

More information

Notation for Logical Operators:

Notation for Logical Operators: Notation for Logical Operators: always true always false... and...... or... if... then...... if-and-only-if... x:x p(x) x:x p(x) for all x of type X, p(x) there exists an x of type X, s.t. p(x) = is equal

More information

Lecture 2: Syntax. January 24, 2018

Lecture 2: Syntax. January 24, 2018 Lecture 2: Syntax January 24, 2018 We now review the basic definitions of first-order logic in more detail. Recall that a language consists of a collection of symbols {P i }, each of which has some specified

More information

Marie Duží

Marie Duží Marie Duží marie.duzi@vsb.cz 1 Formal systems, Proof calculi A proof calculus (of a theory) is given by: 1. a language 2. a set of axioms 3. a set of deduction rules ad 1. The definition of a language

More information

First-Order Theorem Proving and Vampire. Laura Kovács (Chalmers University of Technology) Andrei Voronkov (The University of Manchester)

First-Order Theorem Proving and Vampire. Laura Kovács (Chalmers University of Technology) Andrei Voronkov (The University of Manchester) First-Order Theorem Proving and Vampire Laura Kovács (Chalmers University of Technology) Andrei Voronkov (The University of Manchester) Outline Introduction First-Order Logic and TPTP Inference Systems

More information

Yet Another Proof of the Strong Equivalence Between Propositional Theories and Logic Programs

Yet Another Proof of the Strong Equivalence Between Propositional Theories and Logic Programs Yet Another Proof of the Strong Equivalence Between Propositional Theories and Logic Programs Joohyung Lee and Ravi Palla School of Computing and Informatics Arizona State University, Tempe, AZ, USA {joolee,

More information

Logic as a Tool Chapter 4: Deductive Reasoning in First-Order Logic 4.4 Prenex normal form. Skolemization. Clausal form.

Logic as a Tool Chapter 4: Deductive Reasoning in First-Order Logic 4.4 Prenex normal form. Skolemization. Clausal form. Logic as a Tool Chapter 4: Deductive Reasoning in First-Order Logic 4.4 Prenex normal form. Skolemization. Clausal form. Valentin Stockholm University October 2016 Revision: CNF and DNF of propositional

More information

AAA615: Formal Methods. Lecture 2 First-Order Logic

AAA615: Formal Methods. Lecture 2 First-Order Logic AAA615: Formal Methods Lecture 2 First-Order Logic Hakjoo Oh 2017 Fall Hakjoo Oh AAA615 2017 Fall, Lecture 2 September 24, 2017 1 / 29 First-Order Logic An extension of propositional logic with predicates,

More information

Automated Reasoning Lecture 5: First-Order Logic

Automated Reasoning Lecture 5: First-Order Logic Automated Reasoning Lecture 5: First-Order Logic Jacques Fleuriot jdf@inf.ac.uk Recap Over the last three lectures, we have looked at: Propositional logic, semantics and proof systems Doing propositional

More information

Critical Reading of Optimization Methods for Logical Inference [1]

Critical Reading of Optimization Methods for Logical Inference [1] Critical Reading of Optimization Methods for Logical Inference [1] Undergraduate Research Internship Department of Management Sciences Fall 2007 Supervisor: Dr. Miguel Anjos UNIVERSITY OF WATERLOO Rajesh

More information

CTL-RP: A Computational Tree Logic Resolution Prover

CTL-RP: A Computational Tree Logic Resolution Prover 1 -RP: A Computational Tree Logic Resolution Prover Lan Zhang a,, Ullrich Hustadt a and Clare Dixon a a Department of Computer Science, University of Liverpool Liverpool, L69 3BX, UK E-mail: {Lan.Zhang,

More information

Logic, Sets, and Proofs

Logic, Sets, and Proofs Logic, Sets, and Proofs David A. Cox and Catherine C. McGeoch Amherst College 1 Logic Logical Operators. A logical statement is a mathematical statement that can be assigned a value either true or false.

More information