lecture slides for mat 60556 part iv first order logic
play

Lecture Slides for MAT-60556 PART IV: First Order Logic: - PowerPoint PPT Presentation

Lecture Slides for MAT-60556 PART IV: First Order Logic: Resolution, Logic programming and Model theory Henri Hansen October 1, 2013 1 Resolution Resolution is a sound and complete algorithm for propositional logic: A formula in clausal


  1. Lecture Slides for MAT-60556 PART IV: First Order Logic: Resolution, Logic programming and Model theory Henri Hansen October 1, 2013 1

  2. Resolution • Resolution is a sound and complete algorithm for propositional logic: A formula in clausal form is un- sat if and only if the algorithm reports unsat, and in propositional logic the procedure is guaranteed to terminate • The generalization to FOL is sound and complete as well, but the algorithm may fail to terminate • The generalization is done in two steps: First, we present ground resolution , which works on ground literals, and then general resolution , wchih uses uni- fication , to enable resolution on non-ground literals 2

  3. Ground Resolution • Let C 1 and C 2 be ground clauses such that l ∈ C 1 annd l c ∈ C 2 . We say that C 1 and C 2 are clashing clauses and they clash on the ground literals l and l c . The resolvent of C 1 and C 2 is the clause C = ( C 1 − { l } ) ∪ ( C 2 − { l c } ) C 1 and C 2 are the parent clauses of C • Theorem: The resolvent is satisfiable if and only if its parents are both satisfiable • Remember: A ground literal is a predicate where the parameters are ground terms (only constants and functions!) 3

  4. Substitution • A substitution of terms for variables is the set { x 1 ← t 1 , . . . , x n ← t n } where each x i is a distinct variable and t i is not identical to the corresponding variable. The set may be empty. • An expression is a term, a literal, a clause, or a set of clauses. If E is an expression and θ = { x 1 ← t 1 , . . . , x n ← t n } is a substitution, then an instance Eθ of E is obtained by simultaneously replacing x i with t i in E 4

  5. Unification • Let U = { A 1 , . . . , A n } be a set of atoms. A unifier of U is a substitution θ such that A 1 θ = · · · = A n θ • A most general unifier (mgu) is a unifier µ such that any unifier θ of U can be expressed as θ = µλ for some substitution λ • Note that not all atoms are unifiable, for instance, it is impossible to unify atoms when predicate sym- bols are different, as well as atoms whose outer functions are different, or, for instance the atoms p ( x ) , p ( f ( x )), which cannot be unified. 5

  6. Unification algorithm • A set of term equations is in solved form iff all equations are of the form x i = t i , where x i is a variable, and each variable that appears in the left- hand side of an equation, never appears anywhere else. • A set of equations in solved form defines a substi- tution, where x i ← t i for each i • It will turn out later, that the set in solved form is the mgu of the original set of term equations, 6

  7. and thus for the set of atoms from which the terms were taken • The following algorithm transforms a set of term equations into solved form, or reports if it cannot be done 1. Transform t = x when t is not a variable, into x = t 2. Erase the equation x = x 3. Let t ′ = t ′′ be an equation where t ′ and t ′′ are not variables – If the outermost functions are not identical, terminate, not unifiable

  8. – Otherwise, replace f ( t ′ 1 , . . . , t ′ k ) = f ( t ′′ 1 , . . . t ′′ k ) with the equations t ′ i = t ′′ i 4. Let x = t be an exuation such that x occurs elsewhere in the set – If x occurs in t and differs from t , terminate, not unifiable – Otherwise, transform the set by replacing oc- currences of x in other equations by t • note: Algorithms for unification may be extremely inefficient

  9. General resolution step • The general resolution rule: Let C 1 and C 2 be clauses such that some predicate appears in C 1 and its negation appears in C 2 . Let l 1 and l 2 be the corresponding literals, such that l 1 σ and ( l 2 σ ) c are unified, by an mgu σ . The resolvent of C 1 and C 2 is defined C = ( C 1 σ − { l 1 σ } ) ∪ ( C 2 σ − { l 2 σ } ) • The resolvent is satisfiable if and only if C 1 and C 2 are satisfiable. 7

  10. Resolution algorithm • Let S = S 0 be a set of clauses • S i +1 is constructed from S i by choosing a pair of clashing clauses C 1 , C 2 ∈ S i , and calculating the re- solvent C • If C = � , then terminate and S is not satisfiable. Otherwise S i +1 = S i ∪ { C } • If S i +1 = S i for all possible pairs of clashing clauses, then S is satisfiable 8

  11. Soundness of resolution • Theorem: If the empty clause � is derived from S , then S is unsatisfiable – Idea of proof: If the parent clauses are simul- taneously satisfiable, then the resolvent is also; Because � is unsat, then the parent clauses must also be unsat – If parent clauses are sat, then there is a Herbrand interpretation for them. The elements of the Herbrand base that satisfy C 1 and C 2 have the same form as ground atoms, so there is a sub- stitution that unifies C i with some ground clause C ′ i 9

  12. – We can infer that the Herbrand model for C 1 and C 2 is also a Herbrand model for C

  13. Completeness of resolution • Lifting Lemma: Let C ′ 1 and C ′ 2 be ground instances of C 1 and C 2 . Let C ′ be a ground resolvent for C ′ 1 and C ′ 2 Then there exists a resolvent C of C 1 and C 2 such that C ′ is a ground instance of C • Theorem: If a set of clauses is unsat, the empty clause can be derived by resolution • Resolution has an important application in Logic programming , which we shall discuss forthwith 10

  14. Logic Programming • Resolution was devoleped for automatic theorem proving • However, a restricted form of resolution can be used to carry out computation as well • Making use of this fact, logic programming has been developed • In logic programming, a program is a set of clauses, and and a query which is a negation of the results of the program. 11

  15. From formulas to logic programming • Consider a deductive system with two kinds of ax- ioms: 1. Universally closed predicates, like ∀ x ( x + 0 = x ) 2. Universally closed implication, like ∀ x ∀ y ∀ z ( x ≤ y ∧ y ≤ z → x ≤ z ) • In clausal form, the first is a literal x + 0 = x , and the second one negates the left hand side, in the example ¬ ( x ≤ y ) ∨¬ ( y ≤ z ) ∨ ( x ≤ z ), so that there is exactly one positive literal. These are the so-called program clauses 12

  16. From formulas to logic programming (contd) • Suppose that we ghave a set of program clauses and we want to prove G 1 ∧ · · · ∧ G n is a logical con- sequence of the set • The formula is negated to ¬ G 1 ∨ · · · ∨ ¬ G n , and this is refuted by resolution with program clauses • ¬ G 1 ∨ · · · ∨ ¬ G n is called the goal clause , and it can only clash on program clauses’ positive literal, as it consists of only negative literals 13

  17. From formulas to logic programming (contd II) • The sequence of resolution produces a sequence of unifying substitutions, which then become the answer to the query • The computation is implicitly carried out as part of the substitutions • Given a gaol clause, it is possible that several literals clash with a positive literal of a program clause, which means the computation is nondeterministic 14

  18. • A computation rule must be used to specify, how a literal in the goal is chosen • Once a literal is chosen, the next program rule must be chosen, so a search rule is needed

  19. Horn Clauses and SLD-resolution • A Horn clause is a clause of the form A ← B 1 ∧ · · · ∧ B n , which is equivalent to A ∨ ¬ B 1 ∨ · · · ∨ B n , and it has at most one positive literal – A fact is a positive unit Horn clause, i.e. A ← – A goal clause is a Horn clause with no positive literals, i.e., ← B 1 · · · B n – A program clause is a Horn clause with one pos- itive, and one or more negative literals • ← means reverse implication, with the meaning “To prove A , prove B 1 , . . . B n ” 15

  20. Correct Answer Substitution • Let P be a program and G be a goal clause. a sub- stitution θ for the variables in G is a correct answer substitution if P | = ∀ ( ¬ Gθ ), with quantification over all free variables in ¬ Gθ • Given a program, a goal clause G = ¬ G 1 ∨ · · · ¬ G n , and a correct substitution θ , P | = ∀ ( G 1 ∧ · · · G n ) θ , and therefore for any substitution σ that makes this conjunction into a ground formula ( G 1 ∧ · · · ∧ G n ) θσ is true for any model of P 16

  21. SLD-resolution • Let P be a set of program clauses, R a computation rule, and G a goal clause. A derivation by SLD- resolution is a sequence of resolution steps between goals and program clauses. 1. The first goal clause G 0 = G 2. The clause G i +1 is derived from G i by selecting a literal A j i ∈ G i and choosing a clause C i ∈ P such that the head of C i unifies with A j i by mgu θ i , and resolving • An SLD-refutation is an SLD-derivation that results in � . 17

  22. Excursion: Prolog • Prolog was the first logic programming language • The computation rule for Prolog is to choose the leftmost literal in the goal • The search rule is to choose clauses from top to bottom in the list of program clauses • In addition, Prolog implements some non-logic pred- icates whose purpose is to produce side-effects, such as I/O- functions 18

  23. Prolog (example) • Consider the following program in Prolog ancestor(X,Y) :- parent(X,Y). ancestor(X,Y) :- parent(X,Z), ancestor(Z,Y). • in addition we should have a database of facts, like parent(bob,allen) and parent(dave,bob) • the goal :- ancestor(Y,bob), ancestor(bob,Z) will succeed and the correct substitution Y = dave, X = allen will be returned 19

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend