First Order Logic: First-order resolution. Valentin Goranko DTU Informatics September 2010 V Goranko
First-order resolution The Propositional Resolution rule extended to first-order logic: C ∨ Q ( s 1 , . . . , s n ) , D ∨ ¬ Q ( s 1 , . . . , s n ) C ∨ D 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. V Goranko
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. V Goranko
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 )) . V Goranko
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 ))) . V Goranko
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 ] . V Goranko
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 . V Goranko
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 ))) . V Goranko
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 . V Goranko
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. V Goranko
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 V Goranko
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. V Goranko
First-order resolution with unification The first-order 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: C ∨ Q ( s 1 , . . . , s n ) , D ∨ ¬ Q ( t 1 , . . . , t n ) Res : ( C ∨ D ) σ 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. V Goranko
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 )). V Goranko
Derivations with first-order resolution A resolution-based derivation of a formula C from a list of formulae A 1 , . . . , A n , denoted A 1 , . . . , A n , ⊢ Res C , is a derivation of the empty clause {} from the set of clauses obtained from A 1 , . . . , A n , ¬ C , by successive applications of the rule Res . Theorem : The method of First-order Resolution is sound and complete, i.e., for every first-order formulae A 1 , . . . , A n , C : A 1 , . . . , A n , ⊢ Res C iff A 1 , . . . , A n , | = C . However, unlike Propositional Resolution, First-order Resolution may run forever, i.e., never terminate, in some cases when the conclusion does not follow logically from the premises. It may also run forever even when the conclusion follows logically from the premises, if unnecessary resolvents are produced. To avoid that, special strategies or additional mechanisms for disposal of used-up clauses need to be applied. V Goranko
Recommend
More recommend