1 / 102

Chapter 4

Chapter 4. Predicate Logic [First-order Logic]. Contents. (first-order) conceptualization of the real world First-order structures Syntax of first-order logic vocabulary; terms; wffs Semantics of first-order logic Interpretations and variable assignments Meaning of terms

jihan
Télécharger la présentation

Chapter 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4 Predicate Logic [First-order Logic]

  2. Contents • (first-order) conceptualization of the real world • First-order structures • Syntax of first-order logic • vocabulary; terms; wffs • Semantics of first-order logic • Interpretations and variable assignments • Meaning of terms • Meaning of wffs • logical notions • Some syntactic concepts • substitutions; unifications • normal forms: pnf, cnf, dnf, snf, clausal forms etc. • Herbrand theorem • Undecidability • Axiom systems • H • soundness • completeness • compactness • Semi-decidability

  3. First-order Conceptualization of the real-world • Real-world [domain and problems] • Abstraction of real-world domain • Descriptions (specifications) of domain and problems • Representations (of domain and problems) • in human minds, • in computer (data structure or knowledge representation) • in language (text) (processor independent )

  4. Language, real-world and conceptualization referent(denotation) Natural Languages (strings of symbols) Real world (objects, facts, relationships,...) (ambiguous; imprecise) Symbolize Abstraction (conceptualization) specialization of language referent (denotation) Artificial Languages (propositional language first-order language, 2nd-order languages,..) Abstracted worlds (objects, facts, relationships,...) Artificial Languages (propositional language first-order language, 2nd-order languages,..) Abstracted worlds (objects, facts, relationships,...) (accurate and precise ) Symbolize Issues: Are all objects, concepts, facts, relatinships etc in the real (or abstracted) world representable in the corresponding languages ?

  5. 1 2 4 3 5 6.1 6 6.3 6.2 Problems:1. Is block 1 above block3 ? 2. Wha is the color of block 2 ? 3. .... The blocks world and problems real-world domain and conceptualization 1. identify the set of objects we are interested in, e.g., object1,...,6, color RED, GREEN,YELLOW,etc. (removed real-world objects : sun,6.1,..,6.3, blue,...) the collection of all interested objects is called the universe of discourse in the conceptualization. (first order ) conceptualization [abstraction] 2. There are various relationships existing among objects of the universe of discourse, some of which we may be interested in, some of which may be irrelevant to our problems. e.g, the is-on, is-above, is-clear, weigh-between(x,y,z) = "x’s weight is between those of y’s and z’s". The set of relations emphasized in a conceptualization is called the relational basis set.

  6. 3. Identify the set of all functions in the domain we are interested in. • e.g., color(x) = the color of object x, • weight(x) = the weight of object x, • height(x) = the height of object x,... • The set of all emphasized functions in a conceptualization is called thefunctional basis set. • Conclusion: • A (first-order) conceptualization of a real world domain RU is a triple (D, F, R) where • 1. D: (the universe of discourse) is the set of all objects of RU • which we are interested in. • 2. F:(the functional basis set) is a set of functions of U, and • 3. R:(the relational basis set) is a set of relations of U. • In mathematical notation, a conceptualization is called a • relational structure (or simply a structure). • Note: After conceptualization, we can focus our attention only to problems in abstracted worlds and disregard the complicated real world.

  7. First-order language for structures • S = (D, F={F1,..Fm}, R={R1,..Rn}) : a structure. • A language for representation or communication about S requires 1. A set of symbols (names) c={c0,c1,..} for representing (or denoting, or referring to) individual objects C0,C1,.. in D. • Each symbol of such kind is called a constant. • Note: not all objects need to be symbolized. • Ie. there may exist x in D not = Ci for any i. 2. A set of function symbols f={f1,..,fm}, each fj representing a function Fj: Da(j)-> D in F. • So, if Fj (ci) = Ck, then we may use string "fj(ci)" to refer to Ck. 3. A set of relation (or predicate) symbols r={r1,..,rn}, each rj representing a relation Rj : Db(j) in R. S=(c,f,r) collected together is called a vacabulary (or signature) [for the structure S].

  8. 1 2 4 3 5 6.1 6 6.2 6.3 Problems:1. Is block 1 above block3 ? 2. What is the color of block 2 ? 3. .... The blocks world and problems Example: The blocks world Problems: What are required to represent the blocks worlds and its associated many problems? 1. identify the set of all objects in the domain which we are going to talk about. Universe of discourse e.g., 5 blocks, 1 table, weights of blocks(1 pounds,...), colors of blocks(RED,GREEN, YELLOW,..), etc. 6.3 Types of objects: concrete: blocks, tables, RED, ... abstract: 1 pound, concept of color, the number 1,... Primitive: 1,2,3,4,5. Composite: 6 = (6.1+6.2+6.3) even fictional: ghost , unicorn,...

  9. 1 2 4 3 5 6.1 6 6.2 6.3 Problems:1. Is block 1 above block3 ? 2. Wha is the color of block 2 ? 3. .... The blocks world and problems • 2. For convenience of referring, some objects should each be given a name (I.e., a string for referring to the named object). • Example: 1 => r1, 2=> g1, 3=> y1, 4 => y2, 5=> r2, 6 => table; [6.1,6.2,. ] • color => red, green, yellow, deep-yellow [, blue, black, white,.. ] • [weights => 1 pound, 2 pounds, ... ] • [height, width, depth,... => 1 m, 1.5 m,...] • In a logical language, each name of an object is called a constant. • The referred object of a name (or constant) is called the denotationof the constant. 3. Sometimes we need to refer to objects in indirect ways, e.g., Is the color of r2 green ? So we need a function symbol: color for referring to the function: l(x) : {1,...,6} -> {RED,...,GREEN} s.t., l(x) = the color of block x. So color(r2) can be used to refer to the color of block 5, I.e., RED.

  10. 1 2 4 3 5 6.1 6 6.2 6.3 Problems:1. Is block 1 above block3 ? 2. What is the color of block 2 ? 3. .... The blocks world and problems Abstraction of the blocks world • 3. Besides functions, there is another kind of interrelationship among objects in a universe of discourse. • e.g., various spatial relationships among blocks and table. • 1. The “is-on” relation: 1 is-on 2; 2 is-on 3, 3 is-on 6, 4 is-on5, 5 is-on 6; • in mathematical notations, the is-on relation is the set of all pairs of objects (x,y) s.t., “x is on y”. I.e., is-on = {(x,y) | x is on y }. • = { (1,2),(2,3),(3,6),(4,5),(5,6)}. • For referring to the relation is-on, we need construct a (relation) symbol, say, on, to represent it. • We use the notation on(x,y) to symbolize the statement: • x is-on y • So on(r1,g1) = “ r1 is-on g1” is true since (1,2) Î is-on, while on(r1,y1) is false since (1,3) Ï is-on.

  11. The syntax of predicate logic • Definition (1.2): • A signature is a set S of strings of the form: f:sn->s or p:sn (n  0) (1) If f:sn->s ÎS, then f is a function symbol of S of arity n. (2) If n = 0, then f is a constant. (3) If p:snÎS, => p is a predicate symbol of arity n. (4) If n = 0 => p is an atom or proposition. (5) Fun(S) = {f | f:sn->s in S} is the set of function symbols (6) Pred(S) = {p | p:sn in S} is the set of predicate symbols (7): ar: Funs(S) U Pred(S) -> N (arity of symbols) s.t. ar(x) = n iff x:sn->s or x:sn in S. Note: we can instead use (Fun(S), Pred(S), ar) as the definiton of S. Ex: Arith ={0:s0->s; 1:s0->s; suc:s->s; +:s2->s; *:s2->s; >:s2; = : s2; } String={e:s0->s, *:s2->s, <: s2} ...

  12. Logical Symbols • Special symbols used in logical formulas(domain independent).

  13. Terms Def. 1.3: S : a signature, the set of S-terms is defined inductively as follows: • (init. case): Every variable is a S-term • (closure) : If f:sn->s is a function symbol in S, and t1,t2,...,tn are S-terms, then so is f(t1,...,tn). • Notes: • All constants of S are S-terms (defined by (closure)) • T(S) =def the set of all S-terms • A S-term is ground iff it does not contain variables. • T0(S) =def the set of all ground S-terms • Exercise: define T0(S) by induction.

  14. (well-formed) formulas Def. 1.4: Atomic S-formulas • If p:snS and t1,t2,...,tn are S-terms, then p(t1,t2,...,tn) is an atomic S-formula. • If t1,...,tn are ground => p(t1,..,tn) is a ground atomic S-formula. • At(S) =def the set of all atomic S-formulas • At0(S) =def the set of all atomic ground formulas. Def. 1.5: S-formulas (a) every atomic S-formula is an S-formula. (b) If A and B are S-formulas and X is a variable, then the followings are S-formulas: ~A, (A /\ B), (A \/ B), (A -> B), (A <-> B), "X A, $XA.

  15. well-formed formulas • F(S) =def the set of all S-formulas • "x and $x are called quantifications • Ex: Symbolize: 1. Some patients like every doctor. 2. No patient likes a fool. 3. Therefore, no doctor is a fool.” • solutions: I. $x (patient(x) /\ "y (doctor(Y) -> like(x,y))) II. ~$x (patient(x) /\ $y (fool(y) /\ like(x,y)) or "x (fool(x) -> ~$y (patient(y) /\ like(y,x)) III. ~$x (doctor(x) /\ fool(x)) 1. (1~3) collected together is called an (informal) argument (論證) 2. (I~III) are symbolizations(or formalizations) of (1~3) and is called a formal arguments. 3. If an argument is generated by “proof rules”, it is called a proof. 4. If the “proof rule” are collect, it is called a correct proof.

  16. S-structures and variable assignments • S : a signature. • A (first order) S-structure M is a triple: (D, {Ff}f ∈ Fun(S), {Pp}p ∈ Pred(S) ) where • D is a nonempty set (of objects), called the domain of M (,written DM). • Ff : Dar(f) -> D is a function on D of arity n. Ff is called the denotation(or referent, meaning) of f in M (, or written fM). • PpÍ Dar(p) is a ar(p)-ary relations on D (a subset of Dar(p)). Pp is called the denotation (or referent) of p in M (,written pM). • Variable M-assignment: • Any mapping a: Var -> DM from variables to the domain of a S-structure M is called a variable M-assignment (or simply an assignment).

  17. Denotations of terms in structures • syntactic objects semantic objects (M, a) ------------------------------------------------------------------------ function symbol(f) function (fM) constant(c) domain object (cM) predicate symbol(p) relation (pM) variable (X) domain object (a(X)) Terms ? Formula ?

  18. Denotation of terms in a S structure • Given the pair (M,a), we can define a meaning function (M,a) : T(S) -> DM inductively as follows: 1. (M, a) (X) = a(X) for any variable X. 2. (M, a)(f(t1,..,tn)) = fM( (M, a)(t1),...,(M, a)(tn)), where f is a function symbol of arity n, and t1,..,tn are terms. Note: (M,a)(c) = cM for constant symbol c (function of arity zero)

  19. Truth condition of formulas • The relation M, a |= A (A is true (satisfied) under interpretation M and assignment a) is defined inductively as follows: • 1. M, a |= p(t1,..,tn), iff pM((M, a)(t1),..,(M, a)(tn)) holds • i.e, ((M, a)(t1),..,(M,a)(tn))  pM. • 2. M, a |= ~A iff not M, a |= A • 3. M, a |= A \/ B iff M, a |= A or M, a |= B • 4. M, a |= A /\ B iff M, a |= A and M, a |= B • 5. M, a |= X A iff M, a[x/d] |= A for all d  D. • 6. M, a |= $X A iff M, a[x/d] |= A for some d  DM. • a: a variable assignment; d: an object  D; X: a variable, => a[X/d] is a new variable assignment agreeing with a on all variables but X, for which it is assigned d. Formally, a[X/d]is defined as follows: a[X/d] (Y) =def if Y = X then d else a(Y)

  20. Logical notions • A: a S-formula; T: a set of formulas 1. A is satisfiable iff there is S-structure M and an M-assignment a s.t. M, a |= A. 2. A is valid in M iff for all M-assignments a, M, a |=A. 3. A is satisfiabe in M iff M, a |= A for some M-assignment a. 4. A is valid iff for all S-structures M and for all M-assignment a, M, a |= A. 1' T is satisfiable iff there is a S-structure M and an M-assignment a s.t. M, a |= A for all A in T. 2' T is valid in M iff for all M-assignments a, M, a |=A for all A in T. 3' T is satisfiabe in M iff there is an assignment a s.t. M, a |= A for all A in T.

  21. Semantical conclusion • A [or T ] is valid iff for all S-structures M and for all M-assignment a, M, a |= A [for all A ∈ T ]. • If A is valid in M,(denoted M |= A) we say M is a model of A. • T: a (set of) formulas; A: a formula T |= A (,A is a logical consequence of T) iff Every model of T is a model of A. • A and B are logically equivalent (denoted A B) iff A |= B and B |= A (I.e., every model of A is a model of B and vice versa.) Note: 1. Alternative def. AB iff A<-> B is valid. (i.e., for any structure assignment pair (M, a), M, a |= A iff M, a |= B.) 2. A<-> B is valid ==> AB, but, in general, the converse is not true. Ex: p(X) p(Y) but p(X)<-> p(Y) is not valid. 3. If A and B are sentences, then both definitions collapse.

  22. Some syntactic concepts: • Subterms • Subformulas • Closed formulas (sentences) • universal (existential) closure of formulas • literals (potitive; negative; complementary) • free variables (bound variables) in formulas • substitutions • application of substitutions on formulas (and terms) • unifications • unifiers; most general unifiers [mgu]

  23. subterms; subformulas • Def: [subterm, subformula] : t: a term; s: a substring of t that is itself a term. Then s is a subterm of t: A: a formula; B : a substring of A that is itself a formula. s: a substring of A that is itself a term. ==>B is a subformula of A. t is a subterm of A. • Give an inductive definition of subterm and subformulas. Eg: A = "X(p(X) ∧ $Yq(Y)) has subformulas: A, (p(X) /\ $Yq(Y)), $Yq(Y), q(Y) subterms: X, Y.

  24. Variables, free variable and bound variables • t: a terms • var(t) = the set of variables occurring in t is defined as follows: • init: var(X) ={X}. • closure: var(f(t1,..,tn)) = Ui=1..n var(ti). • A: a formula • fv(A) = the set of free variables occurring in A. • bv(A) = the set of bound variables occurring in A. • These functions can be defined inductively as follows: • Init: fv(p(t1,..,tn)) = Ui=1..n var(ti); bv(p(t1,..,tn)) = {}, • closure: • 1. %(A @ B) = %A U %B, where % is fv or bv; @ is /\,\/,-> or <->. • 2. fv(~A) = fv(A); bv(~A) = bv(A). • 3. fv(QX A) = fv(A) \ {X}; • bv(QX A) = if X ∈ fv(A) then bv(A) U {X} else bv(A).

  25. Example variable occurrences Ex: Let A = " X (p(X) \/ ($Y q(Y) /\ $Z r(X,Y,Z))). => fv(A) = ? ; bv(A) = ? ; fv(A) Ç bv(A) = {} ? => In this example: X and Y occur twice and Z occurs once only. Def: [closed formula; universal formula, existential formula] 1. A formula A is closed iff fv(A) = {}. 2. Closed formulas are also called sentences. 3. universal formula : "X1"X2.."Xn A ,where A is quantifier free. 4. Existential formula : $X1$X2..$Xn A ,where A is quantifier free. 5. A: a formula s.t. fv(A) = {X1,..,Xn} ==> "(A) =def the universal closure of A = "X1"X2.."Xn A $(A) =def the existential closure of A = $X1$X2..$Xn A Ex: A = (p(X) \/ ($Y q(Y) /\ $Z r(X,Y,Z))) => "(A) = "Y"X (p(X) \/ ($Y q(Y) /\ $Z r(X,Y,Z))) => $(A) = $Y"X (p(X) \/ ($Y q(Y) /\ $Z r(X,Y,Z)))

  26. Substitutions • Def: A substitution s (over a signature S) is a finite set {X1/t1,...,Xn/tn} of pairs such that 1. X1, ….., Xn are different variables. {X1,.., Xn} =def dom(s) is called the domain of the subst . 2. t1,..,tn are S-terms. {t1,...,tn} =def Codom(s) is the codomain of s. 3. ti¹ Xi for i = 1 to n. • range(s) =def Ui=1,n var(ti) is called the range of s. • If t1,...,tn are ground ==> s is a ground subst. • s\{X/-} =defs \ {X/Xs}.

  27. Application of substitutions to terms and formulas • s = {X1/t1,...,Xn/tn} (n ³ 0) : a subst. • S: a term ; A : a formula • Ss (or As) is the term (or formula) obtained by simultaneously replacing every (free) occurrence of Xi in S ( or A) by ti, for i = 1 to n. • Ss (or As) is a ground instance of S (or A) if Ss (or As) contains no free variable. • inductive definition of Ss and As: • 1. Xs = ti if X = Xi • = X o/w • 2. f(t1,...,tn)s = f(t1s,...,tns) • 3. p(t1,...,tn)s = p(t1s,...,tns); • 4. (B1 @ B2)s = B1s @ B2s, where @ is any binary connective; • 5. (~B)s = ~(Bs). • 6. (QXB)s = QX (B(s \ {X/_}), where Q is any quantifier. • If T is a set of terms or formulas, define Ts = {Ss | S  T}

  28. Admissibility of subst on formulas Ex: A = ("XP(X) \/ $Z q(X,Y,Z)) s = {X/Y, Y/c} then As = ("XP(X) \/ $Z q(Y,c,Z)) • Def: s = {Xi/ti | i = 1..n} is a subst; A : a formula we say As is admissible iff no variables in any ti (i=1,.., n) become bound (or say ti is free for Xi in A) after substitution. Eg: A = "Xp(X,Y); s = {Y/f(X,Z)} ; Y is free in A As is not admissible ∵ As = "X p(X,f(X,Z)) the variable X in f(X,Z) becomes bound in As. Exercise: define admissibility of As by struc. Ind. on A. Sol: If s = {Xi/ti | i = 1..n} then • 1. p(s1,...,sm)s is admissible. • 2. (~A1)s, (A1 op A2)s are admissible if , A1s and A2s are admissible. • 3. (QX A)s is admissible if A(s\{X/_}) is admissible and for each Xi( i = 1..n), if Xi  fv(A) \{X}, then X must not occur in ti. (o/w X of ti would become bound)

  29. Notational conventions: • A formula or a term S such that all its free variables are among {X1,..., Xn} (i.e., fv(S)  {X1,...,Xn}) can be denoted as: S(X1,...,Xn) • S(X1,...,Xn) : a term or formula ; s = {x1/t1,...,xn/tn} ==> Sscan be represented as S(t1,..,tn). • Lem 1.1: s, r : two subst. over S . Then the following are equ. 1. s = r (as finite sets of pairs) 2. ts = tr for every S-term t. 3. Ys = Yr for every variable Y. pf: (1) => (2) => (3) : trivial. (3)=> (1) : By contraposition. case 1: dom(s) ¹ dom(r) ==> $ X/t in s \ r and t ¹ X. ==> Xs= t ¹ X = Xr case 2: dom(s) = dom(r) ==> $ X such that X/t1 ¹ X/t2 ==> Xs = t1 ¹ t2 = Xr.

  30. Motivation for the composition of substitutions • For functions f: A->B and g:B->C, we can always find a unique function h:A->C s.t. h(x) = g(f(x)) for all x  A. • h is called the composition of f and g, and is denoted gf • Similarly, given two substitutions s, r over S , can we always find a unique substitution t s.t. S t = (S s) r for all terms and formulas S ? Ans: yes! (for all terms and most formulas) The unique t is denoted s r and is called the composition of s and r. Problem: How to find sr given s and r ?

  31. Def 1.14: (composition of substitutions) • s = {X1/t1,...,Xn/tn}; r = {Y1/s1,...,Ym/sm} two subst over S. Then sr (the composition of s and r ) =def {Xi/tir | i =1..n and ti¹ Xir } U {Yj/sj | j =1.. m and Yi dom(s) } eg: s = {X1/Y1, X2/c, X3/Y3 }; r = {Y1/Z, X2/Y2, Y3/X3} ==> sr = ? Lem1.2: s,r ,t : substitutions; t: any term; A : any formula. Then 1. t(sr) = (ts)r. 2. If As and Asr are admissible then A(sr) is admissible 3. If As and Asr are admissible, then Asr = A(sr) 4. (sr)t = s(rt). Note: in general Asr¹ A(sr). Eg: A = "Xp(X,Y); s = {Y/X}, r={X/a } ==> sr = {Y/a, X/a}; A(sr) = "Xp(X,a), As ="Xp(X,X) --- not admissible, Asr= "XP(X,X)

  32. Proof of Lem 1.2 pf: Let s = {X1/t1,…,Xn/tn}; r = {Y1/s1,…,Ym/sm} (1) : To show (1) it suffices to show that for all variable Z, Z(sr) = (Zs)r Three cases: case Z(sr) Zs (Zs)r Z = Xi tir ti tir Z = Yj{X1,...,Xn} sj Yj sj Z  {x1,..Xn,Y1,..,Ym} Z Z Z In all cases, we have Z(sr) = (Zs)r (2) Assume , As ,(As) r are admissible. By def. sr = {Xi/tir | tir¹ Xi } U {Yj/sj | j =1..m and YjÏ dom(s) } Case 1: tir is free for Xi in A: 1. If Z Ï range(r) is any variable in tir ==> Z is free for Xi in A. 2. If Z  range(r) is any variable in tir ==> Z is also free for Xi in A ==>all variable in tir is free for Xi in A. Case 2: sj is free for Yj in A (where YjÏ dom(s) ): trival, o/w some sj would not be free for Yj in As. (3) left as an exercise. (4) For all variables Z, Z((sr)t) = (Z(sr))t = ((Zs)r)t = (Zs)(rt) = Z(s(rt)) Hence, by lem1.1, s(rt) = (sr)t.

  33. Unification (from section1.6) • T={t1,...,tm} is a nonempty set of S-terms F= {A1,..,An} is a set of S-formulas 1. A unifier of T is a substitution s s.t. Ts is a singleton set (i.e., t1s = t2s =...=tms ). 2. A unifier of F is a substitution s s.t. Fs is a singleton set (i.e., A1s = A2s =...=Ans ) and each Ais is admissible. 3. T ( or F) is called unifiable if such a unifier exists. Ex: T = {f(g(a,X),g(Y,b)), f(Z,g(U,V)) } s = {X/a, Z/g(a,a), Y/U, V/b} ==> Ts = ? ==> s is a unifier of T.

  34. Most general unifiers (mgu) • T={t1,...,tn} is a nonempty set of S-terms or S-formulas m: a substitution. m is a most general unifier(mgu) of T iff 1. m is a unifier of T and 2. for any subst q, if q is a unifier of T, then there is another subst t s.t. q = mt. (i.e., any unifier of T can be obtained from m by subsequent application of another subst t on m. ) Ex: m={Z/g(a,X), Y/U, V/b} is another unifier of T (last example). m is more general than s in that s = mt where t = {X/a}. In fact m is a mgu of T. Note: 1. mgu is not unigue. eg: n = {Z/g(a,X), U/Y, V/b} is another mgu of T besides m.

  35. renaming substitution • A substitution t = {X1/t1,...,Xn/tn} is a renaming substitution iff all t1,...,tn are distinct variables. • If q1 = q2t for some renaming substitution, we say q1 and q2 are identical (equal, equivalent) up to variable renaming. In symbol q1@q2. Fact0: if t = {X1/t1,...,Xn/tn} is a renaming subst, then its unique inverse subst is t-1 = {t1/X1,...,tn/Xn} Fact 1: mgu is unique up to variable renaming (i.e., if both q1 and q2 are mgus of a set of terms or formulas ) then q1@q2. Exercises 1. Show that the relation @ on substitutions is an equivalence(i.e., ref. symmetric and transitive.) relation. 2. Show fact 1.

  36. How to find a mgu • T = {t1,..,tn } is a set of terms or formulas • T' = ({t1 = t2, t2 = t3,.., tn-1 = tn}, {} ) • The unification rules: 1. Decomposition rule: (T U{f(u1,..,um) = f(v1,...,vm)} , q) ==>( T U {u1=v1,...,um=vm}, q) 2. Failure: (T U {f(u1,..um) = g(v1,...,vn)}, q) ==> return(no mgu) 3. identity elimination: (T U {X = X}, q) ==> (T, q). 4. substitution rule: 4.1 (T U {X= t}, q) and X Î var(t) ==> return(no mgu) 4.2 (T U {X= t}, q) and X Ï var(t) ==> (T{X/t}, q{X/t}) 5. exchange rule: (T U { t = X}, q) and t is not a variable ==> (T U {X = t}, q) If (T', {}) ==>* ({}, q) then q is a mgu of T.

  37. Example of finding mgu: Theorem: T is unifiable iff (T', {}) ==>* ({}, q) for some mgu q of T. • T = { f(X, g(a,Y), Z), f(h(U,c), g(U,W), k(X)) } (T'; {}) = ( { f(X, g(a,Y), Z) = f(h(U,c), g(U,W), k(X))} ; {} ) ==> ( {X=h(U,c), g(a,Y)=g(U,W), Z=k(X); {} ) ==> ( { g(a,Y)=g(U,W), Z=k(h(U,c)) }; {X/h(U,c)} ) ==> ( { a = U,Y= W, Z=k(h(U,c)) }; {X/h(U,c)} ) ==> ( {U=a, Y= W, Z=k(h(U,c)) }; {X/h(U,c)} ) ==> ( {Y= W, Z=k(h(a,c)) }; {X/h(a,c), U/a} ) ==> ( {Z=k(h(a,c))}; {X/h(a,c), U/a, Y/W} ) ==> ( {}; {X/h(a,c), U/a, Y/W, Z/k(h(a,c))} ).

  38. Termination of the algorithms Fact 0: The unification algorithm terminates on any input T. 1.1 For each system of equation T= {s1=t1,...,sn=tn}, let h(T) = (#var(T), Si=1..n size(si), n), where size(s) = #symbols of s. Let < be the lexicographical relation on N3: (i.e., (x1,x2,x3) < (y1,y2,y3) iff (x1 < y1) or (x1=y1/\ x2 < y2) or (x1=y2/\x2=y2/\x3<y3)) it is easy to see that < is well-founded! Ex: (3,2,7) > (2,100000, 59) > (2 10 22222) > (1 10000 22222) ... 1.2: If (T1;q1) ==> (T2;q2) then h(T1) > h(T2). eg. (T, f(t1,..tn)=f(s1,...,sn) ; q) ==> (T, t1=s1,..,tn=sn ; q) then h(LHS) - h(RHS) = (0, 1, -n+1). Hence h(LHS) > h(RHS). ... By 1.1 & 1.2, the program will terminate.

  39. Partial correctness of the unification program Fact1: If (T1;q1)==>(T2;q2) then • all unifiers of T1 are unifiers of T2. • hence if T2 is not unifiable, then so is T1. Hence let (T';{}) ==> (T2; q2)==> ... ==> (Tn={};qn) be any complete execution of the program. If (Tn;qn) halts at case 2 or case 4.1. ==> Tn is not unifiable => Tn-1 in not unifiable =>... => T' is not unifiable. Fact2: If sk is a unifier of Tk , then $ a unifier sk+1 of Tk+1 s.t. qksk = qk+1sk+1. ==> if s is a unifier of T, then s = qnsn for some sn. for case 1,3,5: qk+1=qk, and unifiers of Tk are unifiers of Tk+1 so simply let sk+1 = sk. Xsk = tsk = tsk+1 sincex var(t). For case 4.2: Let sk+1 = sk \ {X/Xsk}. Then sk={X/t}sk+1==>1. sk+1 is a unifier of Tk+1 and 2. qksk = qk ({X/t} sk+1) = qk+1sk+1.

  40. Correctness of the unification algorithm Fact3: If sk+1 is a unifier of Tk+1 ,s.t. dom(sk+1)  var(Tk+1) then $ a unifier sk of Tk with dom(sk)  var(Tk) s.t. qksk = qk+1sk+1. pf: For case 1,3,5: qk=qk+1, and unifier of Tk+1 are unifiers of Tk so simply let sk = sk+1. For case 4.2: Let sk = {X/t} sk+1 It is easy to see (like fact 2) that 1. sk is a unifier of Tk with domain in var(Tk) and 2. qksk = qk+1sk+1. Now the only possible sn is {} and qn = qn {} = qn-1sn-1 = ... = q1s1 = {}s = s where s is a unifier of T'. Hence qn is a unifier of T. By fact 1: if the program halts at case 2 and 4.1, T is not unifiable. O/w, by fact 3, qn is a unifier of T; by fact 2, any unifier of T is an instance of qn ,so qn is a mgu of T. Finally, by fact 0, the program always terminate. Hence the unification program always produces the correct result.

  41. Some auxiliary lemmas and exercises You should review 4-19~4-21 to know the related terminology. 1. A is valid iff M,a |= A for all structures M and all assignments a iff M |= A for all structures M iff "(A) is valid. 2. A is satisfiable in M iff M, a |= A for some assignment a iff $(A) is satisfiable in M. 3. A is satisfiable in M iff ~A is not valid in M 4. A is valid in M iff ~A is not satisfiable in M 5. A is satisfiable iff ~A is not valid 6. M |= ~A => not M |= A 7. M |= A => M |= A \/ B 8. M |= A /\ B iff M |= A and M |= B. 9. Show that the following formulas are not valid: 1. A{X/t} -> "XA 2. $XA -> A{X/t} 3. $XA -> "XA 4. "X(A \/ B) -> "XA \/ "XB

  42. Some lemmas and exercises 10. Which of the following are valid ? 1. $X"YA -> "Y$XA 2. "X$YA ->$Y"XA 11. 1. "XA <=> ~$X~A 2. $XA <=> ~"X~A 12. QXA  A provided X Ï fv(A). 13. Which of the following relations are always true? 1. $XA |= A{X/c} where c is a constant. 2. $XA |= A{X/Y}, Y is a new variable. 3. "XA |= A 4. A |= "XA 5. |= A->"XA 6. |="XA iff |=A{X/c} where c is a new constant. Note: A |= B means for any structure M, M |= A => M |= B. and M |= A means for any assignment a, M, a |= A.

  43. Some Lemmas 1. t: a term, M: a structure; a1, a2 : two variable assignments. If a1(X) = a2(X) for all X in var(t) then (M, a1)(t) = (M, a2 )(t). Pf: simple induction (on term structure). As an exercise. 2. A: a formula, M: structure; a1, a2 :two variable assignments: If a1(X) = a2 (X) for all X in fv(A) then M, a1 |= A iff M, a2 |= A. Pf: induction on A. case1: A = p(t1,...,tn). M, a1 |= A iff <(M, a1 )(t1),..,(M, a1 )(tn)>Î pM iff <(M, a2 )(t1),..,(M, a2 )(tn)>Î pM iff M, a2 |= A. case2: A = B @ C where @ is /\,\/,->,or <->. case3: A = ~B. left as an exercise. case4: A = $XB. M, a1 |= A iff $d  DM s.t. M, a1[X/d] |= B iff (by ind.hyp.) $d  DM s.t. M, a2 [X/d] |= B iff M, a2 |=A. case5: A = "XA. Similar to case 4. QED

  44. Some Lemmas: 3. A: a sentence, M: a structure; ==> M |= A iff $an assignment a, s.t. M, a |= A. Pf: (only if-part need to be proved). Let b be any M-assignment. Then a and b agree on all free variables of A (since fv(A) = {} ). By previous lemma, M, a |= A implies M, b |= A. Hence M |= A.

  45. Some lemmas (cont’d) 4. A: a sentence, s,t: two terms, M: a structure, a: an assignment. If (M, a)(t) = d, then 1. (M, a[X/d])(s) = (M, a)(s{X/t}) and 2. M, a[X/d]|=A iff M, a|= A{X/t}, where t is free for X in A. pf: induction on s and A. case1: s = X (then s{X/t}=t). (M, a[X/d])(X) = d = (M, a)(t). case2,3: s = Y( ¹ X) or s=f(t1,...,tn). Left as exercises. case 4: A=p(t1,..,tn). => by (1) (M, a[x/d])(ti) = (M, a)(ti{X/t}) for i=1..n. Hence M, a[X/d] |= A iff M, a |= A{X/t}. case5: A = $YB (Y¹ X). M, a[X/d] |=A iff $e ∈ DM s.t. M, a[X/d][Y/e] |= B iff M, a[Y/e][X/d] |= B iff M, a[Y/e] |= B{X/t} iff M, a |= A{X/t}. Other cases: exercises. QED

  46. s{x/t} d t t d s x x if (M,a)(t) =d then (M, a[X/d])(s) = (M,a)(s{X/t})

  47. Normal forms • Prenex normal form (pnf): • Q1X1...QnXn A, where Qi are quantifiers and A is a quantifier-free formula • Literals: 1. positive literal: p(t1,...,tn) 2. negative literal: ~p(t1,...,tn) 3. p(t1,...,tn) and ~p(t1,...,tn) are complementary to each other. • ∨ i=1..n Ai =def A1 ∨ A2 ∨ ... ∨ An (n³ 0) ∧ =1..n Bi =def B1 ∧ B2 ∧... ∧ Bn (n³ 0) • disjunctive normal form (dnf): \/i=1..n (/\j=1..k Lij) where each Lij is a literal. • conjunctive normal form (cnf): /\i=1..n (\/j=1..k Lij) where each Lij is a literal.

  48. Clausal form: • clause: L1 \/ L2 \/ ... \/ Lm , where each Li is a literal. • We use the (multi)set {L1,...,Lm} to represent a clause and use the set of clauses to represent conjunctions of clauses. • Ex: A = C1 /\ C2 /\ C3 where C1 = L1 \/ L2, C2 = L2 \/ L3 \/ L4, C3 = L2 \/ L3, is a formula in cnf. • The clausal form of A is { {L1,L2}, {L2,L3,L4}, {L2,L3}} • Problem: How to convert a quantifier-free formula into an equivalent one in cnf, dnf and clausal form? Sol: the same as the case of propositional logic.

  49. Prenex normal form: • Problem: how to transform a formula into pnf? • Lem: The following formulas are equivalent: 1. ~QX A  Q'X ~A 2. A /\ QXB  QX (A /\ B) 3. A \/ QXB  QX(A \/ B) 4. A->QXB  QX(A->B) 5. (QXB) -> A  Q'X (B->A) 6. QX A  QY A{X/Y} provided Y is not free in A. where 1. Q is either $ or ". 2. Q' is the dual of Q (i.e., Q' = " ($) if Q = $ (").) 3. X does not occur free in A for 2~5. • Pf: 1~5: direct from definition. left as an exercise.

  50. The procedure for converting wffs into pnf 1. removing <-> (and optionally ->) A <-> B ==> (A /\ B) \/ (~A /\ ~B) A -> B ==> ~A \/ B 2. quantification out: A /\ QX B and X ∉ fv(A) ==> QX (A /\ B) A \/ QX B and X ∉ fv(A) ==> QX (A /\ B) A -> QX B and X ∉ fv(A) ==> QX (A /\ B) QXB -> A and X ∉ fv(A) ==> Q'X (A -> B) ~QXA ==> Q'X ~A 3. Renaming variables: QXB ==> QY B{X/Y}, where Y is a new variable ∉ fv(B) . Note: step 3 should be applied only if step 2 cannot be carried out.

More Related