1. Trang chủ
  2. » Thể loại khác

Logic as a tool a guide to formal logical reasoning ( PDFDrive ) 220

1 2 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1
Dung lượng 74,07 KB

Nội dung

196 Logic as a Tool 4.5.3 Unification of terms A substitution σ unifies two words s and s if σ (s) = σ (s ) A substitution σ that unifies the respective arguments of the literals Q(s1 , , sn ) and Q(t1 , , tn ), that is, such that σ (s1 ) = σ (t1 ), , σ (sn ) = σ (tn ), is called a unifier of Q(s1 , , sn ) and Q(t1 , , tn ) For instance, the substitution σ = [f (c)/x, c/y, c/z ] unifies the literals Q(x, c, f (f (z ))) and Q(f (y ), z, f (x)) Two terms are unifiable if they have a unifier; otherwise they are non-unifiable A unifier τ of two terms (or literals) is more general than a unifier ρ, if there is a substitution σ such that ρ = τ σ (Note that, in the sense of this definition, every unifier is more general than itself!) For instance, ρ = [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 because ρ = τ σ , where σ = [c/x] A unifier of two terms (or literals) is their most general unifier (MGU) if it is more general than any unifier of these terms (literals) A most general unifier (if it exists) need not be unique For instance, in the example above, τ is a most general unifier, as well as [z/x, f (z )/y ] for any variable z We are eventually interested in unifying literals, that is, (possibly negated) atomic formulae Note that two atomic formulae P (t1 , , tm ) and Q(s1 , , sn ) cannot be unified unless P = Q and m = n If these are satisfied, in order to unify the formulae we need to unify the respective pairs of arguments, that is, we are looking for a (most general) unifier of the system t1 = s1 , tn = sn Informally, we 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, and applying it to both resulting lists of terms 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 A simple recursive algorithm for computing a most general unifier of two lists of terms p and q is provided in pseudocode as follows 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]);

Ngày đăng: 28/10/2022, 15:26