Unification

 

´ÜÀÏÈ­(Unification) : ÀÌÀç±Ô ¿Ü : ±àÁ¤½Ä (Modus Ponens) ¿Í °°Àº Ã߷бÔÄ¢ (Inference Rule) À» Àû¿ëÇϱâ À§Çؼ­´Â µÎ °³ÀÇ ¹®ÀåÀÌ ¹®¹ýÀûÀ¸·Î ¼­·Î µ¿ÀÏÇÑ ÇüŸ¦ °®´ÂÁö¸¦ Æò°¡ÇÏ´Â ¸ÅĪ (Matching) ±â´ÉÀÌ ÀÖ¾î¾ß ÇÑ´Ù. ¸íÁ¦°è»ê (Propositional Calculus) ¿¡¼­´Â ¸ÅĪÀÌ °£´ÜÇÏ°Ô ÀÌ·ç¾îÁú ¼ö ÀÖÁö¸¸, ¼ú¾î°è»ê (Predicate Calculus) ¿¡¼­´Â º¯¼öºÎÈ£°¡ ÀÖÀ¸¹Ç·Î ¸ÅĪ°úÁ¤ÀÌ º¹ÀâÇÏ°Ô µÈ´Ù. ÀÌ·¯ÇÑ ¹®Àå°£ÀÇ ¸ÅĪÀ» È¿°úÀûÀ¸·Î ó¸®ÇØÁÖ´Â °úÁ¤À» ´ÜÀÏÈ­ ¶ó°í ÇÑ´Ù.

Wikipedia : Unification : ´ÜÀÏÈ­´Â Prolog ÀÇ ÁÖ¿ä °³³äÁßÀÇ ÇϳªÀÌ´Ù. ±×°ÍÀº º¯¼öÀÇ ³»¿ëÀ» bind ÇÏ´Â ¸ÞÄ«´ÏÁòÀ» ³ªÅ¸³»¸ç ÀÏÁ¾ÀÇ ÇѹøÀÇ ÇÒ´ç (one-time assignment) À¸·Î º¸¿©Áú ¼ö ÀÖ´Ù. Prolog ¿¡¼­ ÀÌ µ¿ÀÛÀº ±âÈ£ "=" À¸·Î Ç¥±âÇÑ´Ù.

  1. uninstantiated º¯¼ö X (¿¹¸¦µé¸é ÀÌÀü¿¡ ¾î¶² ´ÜÀÏÈ­µµ ¼öÇàµÇÁö ¾Ê¾Ò´ø º¯¼ö) ´Â uninstantiated variable (±×¸®°í È¿À²ÀûÀ¸·Î ±× alias °¡ µÈ´Ù) À̳ª atom ¶Ç´Â term °ú ´ÜÀÏÈ­ µÉ¼öÀÖ´Ù.
  2. ÇϳªÀÇ atom Àº °°Àº atom °ú¸¸ ´ÜÀÏÈ­ ÇÒ¼öÀÖ´Ù.
  3. ¸¸ÀÏ terms ÀÇ heads ¿Í arities °¡ °°Àº ¹®ÀåÀÌ°í ÀμöµéÀÌ ´ÜÀÏÈ­µÈ´Ù¸é, ÇϳªÀÇ term Àº ¶Ç´Ù¸¥ term °ú ´ÜÀÏÈ­µÈ´Ù (ÀÌ°ÍÀº Àç±Í ÇൿÀ̶ó´Â °ÍÀ» ÁÖ¸ñ).

±× ¼±¾ðÀû ¼º°Ý ¶§¹®¿¡, ´ÜÀÏÈ­ÀÇ ¼ø¼­¿¡¼­ ±× ¸í·ÉÀº (º¸Åë) ¾î¶² ¿ªÇÒµµ °¡ÁöÁö ¾Ê´Â´Ù.

´ÜÀÏÈ­ÀÇ ¿¹

A=A
Succeeds (Ç×Áø¸íÁ¦ (Tautology))
A=B, B=abc
Both A and B are unified with the atom abc
xyz=C, C=D
Unification is symmetric
abc=abc
Unification succeeds
abc=xyz
Fails to unify, atoms are different
f(A)=f(B)
A is unified with B
f(A)=g(B)
Fails, the heads of terms are different
f(A)=f(B,C)
Fails to unify, because terms have different arity
f(g(A))=f(B)
Unifies B with the term g(A)
f(g(A), A)=f(B, xyz)
Unifies A with the atom xyz and B with the term g(xyz)
A=f(A)
Infinite unification, A is unified with f(f(f(f(...)))).
A=abc, xyz=X, A=X
Fails to unify; effectively abc=xyz

Visual Prolog : Matching Things Up: Unification : goal À» ¸¸Á·½ÃÅ°±â À§ÇØ °¢ÀÚÀÇ subgoal À» ¸¸Á·½ÃÄÑ¾ß ÇÏ°í ¶ÇÇÑ °¢ Àμö¿Í match µÇ´Â clause ¸¦ ã±âÀ§ÇØ ÇÁ·Î±×·¥ÀÇ À§¿¡¼­ ¾Æ·¡·Î search ÇÏ°Ô µÈ´Ù. goal °ú match µÇ´Â clause ¸¦ ãÀ¸¸é goal °ú clause °¡ identical ÇØÁöµµ·Ï free variable ¿¡ °ªÀÌ bind µÈ´Ù. À̶§ goal Àº clause ¿¡ unify µÇ¾ú´Ù°í ¸»ÇØÁö°í ÀÌ·¯ÇÑ matching °úÁ¤À» unification À̶ó ÇÑ´Ù.

´ÜÀÏÈ­ ¾Ë°í¸®Áò (Unification Algorithm) : Elaine Rich