logic as a tool chapter 4 deductive reasoning in first
play

Logic as a Tool Chapter 4: Deductive Reasoning in First-Order Logic - PowerPoint PPT Presentation

Logic as a Tool Chapter 4: Deductive Reasoning in First-Order Logic 4.5 Resolution for First-order Logic Valentin Goranko Stockholm University October 2016 Goranko First-order resolution The Propositional Resolution rule in clausal form


  1. Logic as a Tool Chapter 4: Deductive Reasoning in First-Order Logic 4.5 Resolution for First-order Logic Valentin Goranko Stockholm University October 2016 Goranko

  2. First-order resolution The Propositional Resolution rule in clausal form extended to first-order logic: { A 1 , . . . , Q ( s 1 , . . . , s n ) , . . . , A m } { B 1 , . . . , ¬ Q ( s 1 , . . . , s n ) , . . . , B n } . { A 1 , . . . , A m , B 1 , . . . , B n } This rule, however, is not strong enough. Example: the clause set {{ P ( x ) } , {¬ P ( f ( y )) }} is not satisfiable, as it corresponds to the unsatisfiable formula ∀ x ∀ y ( P ( x ) ∧ ¬ P ( f ( y ))) . However, the resolution rule above cannot derive an empty clause from that clause set, because it cannot unify the two clauses in order to resolve them. So, we need a stronger resolution rule. Goranko

  3. Two solutions Solution 1 : Ground resolution: generate sufficiently many ground instances of every clause over a Herbrand universe of the language. In the example, ground resolution would generate the ground clauses { P ( f ( c )) } and {¬ P ( f ( c )) } for some constant symbol c . This method is sound and complete but inefficient, as it leads to the generation of too many unnecessary clauses. Ground resolution was introduced in: John Alan Robinson: A Machine-Oriented Logic Based on the Resolution Principle, JACM, 1965. Will not be discussed further. Solution 2 : Resolution with unification. Goranko

  4. Substitutions of terms for variables revisited s [ t / x ] is the result of simultaneous replacements of all occurrences of x in s by t . For instance: f ( g ( x ) , f ( y , x )) [ g ( a ) / x ] = f ( g ( g ( a )) , f ( y , g ( a ))) . This can generalize to simultaneous substitutions of several terms for different variables, denoted s [ t 1 / x 1 , . . . , t k / x k ]. For instance: f ( g ( x ) , f ( y , x )) [ g ( y ) / x , f ( x , b ) / y ] = f ( g ( g ( y )) , f ( f ( x , b ) , g ( y ))) . Given the substitution σ = [ t 1 / x 1 , . . . , t k / x k ], the set of variables { x 1 , . . . , x k } is called the domain of σ . Simultaneity is important: if we first substituted g ( y ) for x and then f ( x , b ) for y the result would have been different (and wrong). Substitution in a literal is a substitution in all of it argument terms simultaneously. For instance: P ( x , f ( x , y ) , g ( y )) [ g ( y ) / x , a / y ] = P ( g ( y ) , f ( g ( y ) , a ) , g ( a )) . Goranko

  5. Composition of substitutions Substitutions can be composed by consecutive application: the composition of substitutions τ and σ is a substitution τσ obtained by applying τ followed by applying σ to the result, i.e., t τσ = ( t τ ) σ (note the order). For instance: f ( g ( x ) , f ( y , x )) [ f ( x , y ) / x ][ g ( a ) / x , x / y ] = f ( g ( f ( x , y )) , f ( y , f ( x , y ))) [ g ( a ) / x , x / y ] = f ( g ( f ( g ( a ) , x )) , f ( x , f ( g ( a ) , x ))) . Goranko

  6. Computing the composition of substitutions The composition of two substitutions τ = [ t 1 / x 1 , . . . , t k / x k ] and σ can be computed as follows: 1. Extend dom ( τ ) to cover dom ( σ ) by adding to τ substitutions [ x / x ] for every variable x in dom ( σ ) \ dom ( τ ). 2. Apply the substitution σ simultaneously to all terms [ t 1 , . . . , t k ] to obtain the substitution [ t 1 σ/ x 1 , . . . , t k σ/ x k ]. 3. Remove from the result all cases x i / x i , if any. Example: [ f ( x , y ) / x , x / y ][ y / x , a / y , g ( y ) / z ] = [ f ( x , y ) / x , x / y , z / z ][ y / x , a / y , g ( y ) / z ] = [ f ( y , a ) / x , y / y , g ( y ) / z ] = [ f ( y , a ) / x , g ( y ) / z ] . Goranko

  7. Unification of terms A substitution σ that makes two terms s and t identical is called a unifier of s and t . Examples: • the substitution [ f ( y ) / x ] unifies the terms x and f ( y ); • the substitution [ f ( c ) / x , c / y , c / z ] unifies the terms g ( x , f ( f ( z ))) and g ( f ( y ) , f ( x )). • There is no unifier for the pair of terms f ( x ) and g ( y ), nor for the pair of terms f ( x ) and x . Goranko

  8. Unification of atomic formulae A substitution σ that makes the (respective arguments of the) atomic formulae Q ( s 1 , . . . , s n ) and Q ( t 1 , . . . , t n ) identical is called a unifier of Q ( s 1 , . . . , s n ) and Q ( t 1 , . . . , t n ). Examples: • [ f ( y ) / x ] unifies P ( x ) and P ( f ( y )); • [ f ( c ) / x , c / y , c / z ] unifies Q ( x , c , f ( f ( z ))) and Q ( f ( y ) , z , f ( x )). Indeed, the results of applying the substitution σ are: Q ( x , c , f ( f ( z ))) σ = Q ( f ( c ) , c , f ( f ( c ))), Q ( f ( y ) , z , f ( x )) σ = Q ( f ( c ) , c , f ( f ( c ))) . Goranko

  9. Most general unifiers A unifier τ of two terms (or, atomic formulae) is more general than a unifier ρ , if ρ = τσ , where σ is some substitution and τσ is the composition of σ with τ (i.e, σ applied after τ ). Remark: Every unifier is ’more general’ than itself. Better terminology: ’at least as general’. Example: ρ = [ c / x , f ( c ) / y ] is a unifier of the literals P ( f ( x )) and P ( y ), but τ = [ f ( x ) / y ] is a more general unifier than ρ , because ρ = τσ , where σ = [ c / x ]. A unifier of two terms is their most general unifier (MGU) if it is more general than any unifier of theirs. Likewise for atomic formulae. If two terms (or, atomic formulae) are unifiable then they have a most general unifier. However, it need not be unique. In the example above, τ is a most general unifier, as well as the unifier [ z / x , f ( z ) / y ] for any variable z . Goranko

  10. Computing a most general unifier of list of terms In order to unify two literals Q ( s 1 , . . . , s n ) and Q ( t 1 , . . . , t n ), we must unify their respective pairs of arguments, i.e., we are looking for a (most general) unifier of the system: t 1 = s 1 , . . . t n = s n . Informally, we do that by computing a most general unifier (if one exists) of the first pair, then applying it to both lists of terms, then computing a most general unifier of the next pair (if there is one) in the resulting lists, applying it to the resulting lists of terms, etc. In order to unify the current pair of terms we apply the algorithm recursively to the pair of lists of their respective arguments. The composition of all most general unifiers computed as above, if they all exist, is a most general unifier of the two input lists. Goranko

  11. Algorithm for computing most general unifiers procedure mgu(p, q) θ := ε ( the empty substitution ). Scan p and q simultaneously, left-to-right, and search for the first corresponding subterms where p and q disagree (mismatch). If there is no mismatch, return θ . Else, let s and t be the first respective subterms in p and q where mismatch occurs. If variable(s) and s / ∈ Var(t) then θ := compose( θ ,[t/s]); θ := compose( θ , mgu(p θ ,q θ )). Else, if variable(t) and t / ∈ Var(s) then θ := compose( θ ,[s/t]); θ := compose( θ , mgu(p θ ,q θ )). Else, return failure. end Goranko

  12. Examples of computing most general unifiers 1. Literal 1: parents(x, father(x), mother(Bill)) , Literal 2: parents(Bill, father(Bill), y) , MGU: [ Bill/x, mother(Bill)/y ]. 2. Literal 1: parents(x, father(x), mother(Bill)) . Literal 2: parents(Bill, father(y), z) . MGU: [ Bill/x, Bill/y, mother(Bill)/z ]. 3. Literal 1: parents(x, father(x), mother(Jane)) . Literal 2: parents(Bill, father(y), mother(y)) . MGU: [ Bill/x, Bill/y, ...failure ]. Therefore, MGU does not exist. 4. Term 1: g ( x , f ( x )). Term 2: g ( f ( y ) , y ). MGU: [f(y)/x, . . . failure]. MGU does not exist. Goranko

  13. First-order resolution with unification The First-order Clausal Resolution rule is combined with a preceding unification of the clausal set, in order to produce a complementary pair of literals in the resolving clauses: FO-Res: { A 1 , . . . , Q ( s 1 , . . . , s n ) , . . . , A m } { B 1 , . . . , ¬ Q ( t 1 , . . . , t n ) , . . . , B n } { A 1 , . . . , A m , B 1 , . . . , B n } σ where: (i) the two clauses have no variables in common (achieved by renaming of variables, if necessary), and (ii) σ is an MGU of the literals Q ( s 1 , . . . , s n ) and Q ( t 1 , . . . , t n ). We require that the unifier applied in the rule is a most general unifier of the respective literals in order not to weaken the resolvent unnecessarily. Goranko

  14. First-order resolution with unification: some examples of applications of the rule { P ( x ) } , {¬ P ( f ( y )) } ( MGU : [ f ( y ) / x ]) {} { P ( a , y ) , Q ( y ) }{¬ P ( x , b ) , Q ( x ) } ( MGU : [ a / x , b / y ]) { Q ( b ) , Q ( a ) } { P ( a , y ) , Q ( y ) }{¬ P ( x , f ( x )) , Q ( f ( x )) } ( MGU : [ a / x , f ( a ) / y ]) { Q ( f ( a )) } Note that both literals in the resolvent become equal. { P ( a , y ) , P ( x , f ( x )) }{¬ P ( x , f ( a )) } ( MGU : [ a / x , f ( a ) / y ]) . {} Note that, after unification, both literals in the first clause become P ( a , f ( a )). Goranko

  15. First-order resolution: factoring • Factoring: { . . . P ( s ) , P ( t ) . . . } Fac: , ( σ = MGU ( s , t )) { . . . P ( s ) . . . } σ • Example: { P ( x ) , P ( c ) , ¬ Q ( x , y ) } ( MGU : [ c / x ]) { P ( c ) , ¬ Q ( c , y ) } • Factoring is a sound rule. It is needed for completeness. E.g.. consider the clause set { P ( x ) , P ( c ) } , {¬ P ( y ) , ¬ P ( c ) } . The empty clause cannot be derived without using Fac . So, FO resolution employs Fac together with FO-Res . Goranko

Recommend


More recommend